Greetings stackoverflow users.
I need to decrypt AES256-GCM
I use the libsodium library with this documentation, but am willing to switch to any other library.
I have a few parameters to parse this text: Payload, IV, master key
But when writing this code like this:
int iv_len = 12;
BYTE* iv = new BYTE[iv_len]; // From 3 to 15 (15-3=12)
for (int i = 3; i < 15; i++) {
iv[i - 3] = pwd[i];
}
int payload_len = pwd_len - 15;
BYTE* payload = new BYTE[payload_len]; // from 15 to end (length-15)
for (int i = 15; i < pwd_len; i++) {
payload[i - 15] = pwd[i];
}
unsigned char decrypted[1000];
unsigned long decrypted_len;
int res = crypto_aead_aes256gcm_decrypt(decrypted, &decrypted_len, NULL, payload, payload_len + crypto_aead_aes256gcm_ABYTES, NULL, NULL, iv, masterKeyBytes);
cout << res;
Well, the problem is that the program returns int -1
The data is correct, that’s for sure!
THX FOR HELP!
Source: Windows Questions C++