diff options
author | Niels Möller <nisse@lysator.liu.se> | 2014-04-25 20:44:58 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2014-04-25 20:44:58 +0200 |
commit | 91d0c1b519a29bc29b6d71396e467fb975ad3bd7 (patch) | |
tree | 5e4d452a2877f63953af7c9120a3740984dbcce5 /ccm.c | |
parent | c8e472cb2bf066d0207093815f912860dff5ce94 (diff) | |
download | nettle-91d0c1b519a29bc29b6d71396e467fb975ad3bd7.tar.gz |
ccm_decrypt_message: length argument is cleartext (dst) length
Also updated related functions.
Diffstat (limited to 'ccm.c')
-rw-r--r-- | ccm.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -250,14 +250,13 @@ int ccm_decrypt_message(const void *cipher, nettle_cipher_func *f, size_t nlength, const uint8_t *nonce, size_t alength, const uint8_t *adata, size_t tlength, - size_t clength, uint8_t *dst, const uint8_t *src) + size_t mlength, uint8_t *dst, const uint8_t *src) { struct ccm_ctx ctx; uint8_t tag[CCM_BLOCK_SIZE]; - assert(clength >= tlength); - ccm_set_nonce(&ctx, cipher, f, nlength, nonce, alength, clength-tlength, tlength); + ccm_set_nonce(&ctx, cipher, f, nlength, nonce, alength, mlength, tlength); ccm_update(&ctx, cipher, f, alength, adata); - ccm_decrypt(&ctx, cipher, f, clength-tlength, dst, src); + ccm_decrypt(&ctx, cipher, f, mlength, dst, src); ccm_digest(&ctx, cipher, f, tlength, tag); - return (memcmp(tag, src + (clength-tlength), tlength) == 0); + return (memcmp(tag, src + mlength, tlength) == 0); } |