Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chacha20poly1305 enc/dec function not symmetrical #12

Open
sacca97 opened this issue Sep 5, 2023 · 0 comments
Open

Chacha20poly1305 enc/dec function not symmetrical #12

sacca97 opened this issue Sep 5, 2023 · 0 comments

Comments

@sacca97
Copy link

sacca97 commented Sep 5, 2023

Not sure you intended this, but the encryption and decryption function are not symmetrical. (i.e. the ct length is not encoded in the padding)

Basic code sample follows.

` uint8_t msg[7] = "Simola";
size_t pad = (sizeof(msg) + 15) & 0xFFFFFFF0;
uint8_t enc[16 + pad];
aead_encrypt(enc, msg, 7, NULL, 0, 0, key_bytes);
uint8_t dec[16];
int rc = aead_decrypt(dec, enc, sizeof(enc), NULL, 0, 0, key_bytes);

assert(crypto_equal(msg, dec, 7) && rc == 1);`

The assertion fails, but If I call the decryption function with srclen = 16+7 then the decryption is successfull.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant