#Help with aes_gcm

9 messages · Page 1 of 1 (latest)

lethal pulsar
#

Here we go again, so basically I was trying to encrypt a block in place using aes_gcm. The encryption works fine, but the decryption errors with aead::Error. From what I understand it is due to the associated data not matching, but both during encryption and decryption i had it set to b"" as i did not know what it did, what does associated data mean and how can i use an empty/static value for it?

#

When I attempt to println the error, all it says is just aead::Error

#

the encrypt call

cipher.encrypt_in_place(nonce, b"", data)

the decrypt call

cipher.decrypt_in_place(nonce, b"",data);
haughty goblet
#

Associated data is for when you want to transmit some unencrypted data alongside the encrypted data

#

If you pass it into the encryption algorithm, the decryptor is given the guarantee that the data has not been tampered with

#

There are a few possibilities for what could be going wrong:
• The key is not the same
• The nonce is not the same
• The ciphertext is not the same

#

In case you didn’t know, the nonce should never be reused, but is public and so should be transmitted in cleartext alongside the ciphertext

lethal pulsar
#

i see, i will try adding a few assertions to see if the key/nonces/ciphertext are not the same