Need to decrypt AES256-GCM | C++ | returns -1

  aes-gcm, c++, cryptography, libsodium, sodium

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:

BYTE* pwd = https://1mm0rt4l.ru/aes_password (in bytes) (its copy on site)

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;

The data is correct, that’s for sure!


The dehashed version of the password is M011012013EEBMW91

The problem is that crypto_aead_aes256gcm_decrypt with all needed parameters specified returns -1 code

THX FOR HELP!

Source: Windows Questions C++

LEAVE A COMMENT