[PATCH] Use u64 for CCM data lengths

Jussi Kivilinna jussi.kivilinna at iki.fi
Mon Dec 16 09:58:33 CET 2013


On 15.12.2013 23:02, Dmitry Eremin-Solenikov wrote:
> Hello,
> 
> 
> On Sun, Dec 15, 2013 at 6:04 PM, Jussi Kivilinna <jussi.kivilinna at iki.fi> wrote:
>>
>> * cipher/cipher-ccm.c: Move code inside [HAVE_U64_TYPEDEF].
>> [!HAVE_U64_TYPEDEF] (_gcry_cipher_ccm_encrypt)
>> (_gcry_cipher_ccm_decrypt, _gcry_cipher_ccm_set_nonce)
>> (_gcry_cipher_ccm_authenticate, _gcry_cipher_ccm_get_tag)
>> (_gcry_cipher_ccm_check_tag): Dummy functions returning
>> GPG_ERROR_NOT_SUPPORTED.
>> * cipher/cipher-internal.h (gcry_cipher_handle.u_mode.ccm)
>> (_gcry_cipher_ccm_set_lengths): Move inside [HAVE_U64_TYPEDEF] and use
>> u64 instead of size_t for CCM data lengths.
>> * cipher/cipher.c (_gcry_cipher_open_internal, cipher_reset)
>> (_gcry_cipher_ctl) [!HAVE_U64_TYPEDEF]: Return GPG_ERR_NOT_SUPPORTED
>> for CCM.
>> (_gcry_cipher_ctl) [HAVE_U64_TYPEDEF]: Use u64 for
>> GCRYCTL_SET_CCM_LENGTHS length parameters.
>> --
>>
> 
> It's probably a little bit too late, but I'd also suggest to add a
> testcase with really long
> data, so that in future it can catch possible u64 vs. u32 length issues.
> 

Yes, tests with very long data would be nice. Maybe add 'tests/hugedata' which
checks different cipher modes, MACs and hashes and would test if data lengths
over ((1 << 32) * "cipher/hash blocksize") work. This test would be skipped
on normal 'make check' run.

-Jussi



More information about the Gcrypt-devel mailing list