Owen Kirby is working on an implementation of the CCM mode. I'm forwarding my comments here (with permission).
Regards, /Niels
nisse@lysator.liu.se (Niels Möller) writes:
Owen Kirby is working on an implementation of the CCM mode. I'm forwarding my comments here (with permission).
Ooops, I got bitten by the bad mailman configuration regarding attachments. New attempt below. /Niels
Owen Kirby osk@exegin.com writes:
Makes sense to me.
I haven't looked carefully at CCM, I've only read the critique in the eax paper (eax is also CTR-mode + CBC-mac, but in a better way, according to the eax authors).
Let me know if you think these might be suitable for inclusion to nettle, or if there is anything that you think needs to be changed.
I think it looks pretty good. Thanks!
Some initial comments below. I think it would make sense to discuss it on the public nettle mailing list, in particular any interface issues. Feel free to reply on-list. And if you don't object, I'd like to forward this reply to the list.
If you make another revision of these patches, GNU-style ChangeLog entries are also appreciated. And documentation, but it's probably good to wait with that until any interface issues are sorted out.
I don't think the ccm_aes family of functions are needed. ccm_aes128 etc should be sufficient, and since it's a new feature, there's nothing to be backwards compatible with.
I think we need to be a bit clearer about the copyright. We currently don't do any copyright assignments for Nettle. I take it you wrote the ccm implementation, so you own the copyright. Unless it's owned by your employer or client?
(BTW, I've been very sloppy with copyright headers in the test programs, but it would be good with an accurate header also for ccm-test.c).
In nettle, the update functions usually accept arbitrary size, just like you do. Complete blocks are only required for crypt functions.
Are there any sanity checks that the lengths match the ones specified with set_nonce?
Are there any alternative ways to design this interface? E.g., one could specify that for ccm, the update and encrypt/decrypt functions may be called at most once for each message, with no possibility for streaming or incremental processing. But that won't help if one needs *both* lengths before processing either the message data or the associated data.
The general aead interface should include some easy-to-use functions for "all-in-one" processing of messages. It would be nice if ccm could be made to fit into that framework sufficiently well to make such functions work.
--- /dev/null +++ b/testsuite/ccm-test.c
Thanks for including thorough tests.
Regards, /Niels
nisse@lysator.liu.se (Niels Möller) writes:
Owen Kirby osk@exegin.com writes:
It looks like that isn't possible. Reading the code (I haven't read the spec yet), it seems like the message length must be known before processing of the associated data.
However we decide to do the incremental interface for CCM, I think it would be good to also provide an all-in-one function, something like
void ccm_encrypt_message (void *cipher_ctx, nettle_crypt_func *f, size_t nonce_length, const uint8_t *nonce, size_t adata_length, const uint8_t *adata, size_t tag_length, size_t msg_length, uint8_t *dst, const uint8_t *src);
/* Return 1 on success, 0 on authentication failure */ int ccm_decrypt_message (void *cipher_ctx, nettle_crypt_func *f, size_t nonce_length, const uint8_t *nonce, size_t adata_length, const uint8_t *adata, size_t tag_length, size_t msg_length, uint8_t *dst, const uint8_t *src);
(since CCM doesn't quite fit in Nettle's aead framework, it can't easily use any general construction on top of that framework). But there are usecases where incremental processing is desired. E.g, processing a large file (size limited to 16 MB - 1 byte with RFC 5116 parameters for CCM, so maybe not *extremely* large), where you could know the size in advance, e.g., from stat(2), but still might want to do the processing with an i/o buffer in memory limited to, say, 64 KB.
Regards, /Niels
nettle-bugs@lists.lysator.liu.se