mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
adding self-healing function for User::sign, working only while passphrase is saved not encrypted
This commit is contained in:
parent
c9d1a0f268
commit
0366c782f1
@ -1111,9 +1111,22 @@ MemoryBin* User::sign(const unsigned char* message, size_t messageSize)
|
||||
}
|
||||
}
|
||||
if (correctPassphraseFound) {
|
||||
|
||||
// save corrected key into db
|
||||
auto encyrptedPrivKey = encrypt(privKey);
|
||||
auto newUser = controller::User::create();
|
||||
if (1 == newUser->load(mDBId)) {
|
||||
auto userModel = newUser->getModel();
|
||||
userModel->setPrivateKey(encyrptedPrivKey);
|
||||
userModel->updatePrivkey();
|
||||
|
||||
mm->releaseMemory(encyrptedPrivKey);
|
||||
|
||||
}
|
||||
|
||||
// sign with received key
|
||||
auto const_privKey = keys.getPrivateKey();
|
||||
auto signBinBuffer = mm->getFreeMemory(crypto_sign_BYTES);
|
||||
|
||||
unsigned long long actualSignLength = 0;
|
||||
|
||||
if (crypto_sign_detached(*signBinBuffer, &actualSignLength, message, messageSize, *const_privKey)) {
|
||||
|
||||
@ -140,6 +140,7 @@ namespace model {
|
||||
return select;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
std::string mEmail;
|
||||
std::string mFirstName;
|
||||
|
||||
@ -41,6 +41,9 @@ namespace model {
|
||||
const char* getTableName() const { return "users"; }
|
||||
std::string toString();
|
||||
std::string toHTMLString();
|
||||
|
||||
// specific db operation
|
||||
inline size_t updatePrivkey() { lock(); auto result = updateIntoDB("privkey", mPrivateKey); unlock(); return result; }
|
||||
|
||||
|
||||
// default getter unlocked
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user