fix(picrypt): use crypto_box_* constants for public-key decrypt

The decrypt() function for crypto_box (public-key) used
crypto_secretbox_NONCEBYTES and crypto_secretbox_MACBYTES
(secret-key constants) instead of crypto_box_* constants.
These happen to be equal in libsodium but are semantically
different APIs. Fix ensures consistency with the encrypt()
counterpart.
This commit is contained in:
2026-08-10 16:26:08 +03:00
parent 16adea05af
commit 9294cd7b7b
+2 -2
View File
@@ -317,10 +317,10 @@ PIByteArray PICrypt::decrypt(const PIByteArray & crypt_data, const PIByteArray &
return PIByteArray();
}
PIByteArray n;
n.resize(crypto_secretbox_NONCEBYTES);
n.resize(crypto_box_NONCEBYTES);
const ullong data_size = crypt_data.size() - n.size();
PIByteArray ret;
ret.resize(data_size - crypto_secretbox_MACBYTES);
ret.resize(data_size - crypto_box_MACBYTES);
memcpy(n.data(), crypt_data.data(data_size), n.size());
if (crypto_box_open_easy(ret.data(), crypt_data.data(), data_size, n.data(), public_key.data(), secret_key.data()) != 0) {
// Bad key