Update remote nonce only if decryption succeeds
This commit is contained in:
@@ -235,9 +235,6 @@ QString AppDataServer::decryptMessage(QJsonDocument msg, QString secretHex, bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the last seem remote hex
|
|
||||||
saveNonceHex(NonceType::REMOTE, noncehex);
|
|
||||||
|
|
||||||
unsigned char* secret = new unsigned char[crypto_secretbox_KEYBYTES];
|
unsigned char* secret = new unsigned char[crypto_secretbox_KEYBYTES];
|
||||||
sodium_hex2bin(secret, crypto_secretbox_KEYBYTES, secretHex.toStdString().c_str(), crypto_secretbox_KEYBYTES*2,
|
sodium_hex2bin(secret, crypto_secretbox_KEYBYTES, secretHex.toStdString().c_str(), crypto_secretbox_KEYBYTES*2,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
@@ -254,6 +251,9 @@ QString AppDataServer::decryptMessage(QJsonDocument msg, QString secretHex, bool
|
|||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
payload = "error";
|
payload = "error";
|
||||||
} else {
|
} else {
|
||||||
|
// Update the last seen remote hex
|
||||||
|
saveNonceHex(NonceType::REMOTE, noncehex);
|
||||||
|
|
||||||
char* decryptedStr = new char[decryptedLen + 1];
|
char* decryptedStr = new char[decryptedLen + 1];
|
||||||
sodium_memzero(decryptedStr, decryptedLen + 1);
|
sodium_memzero(decryptedStr, decryptedLen + 1);
|
||||||
memcpy(decryptedStr, decrypted, decryptedLen);
|
memcpy(decryptedStr, decrypted, decryptedLen);
|
||||||
|
|||||||
Reference in New Issue
Block a user