-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix CCM mode encryption when length of message > 256 #12364
Conversation
Note: This is based on the branch of pull request #12362 to avoid conflicts later on. I will rebase it once that PR is merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find a text vector either so lets go with your manually generated test vector. Other than that just one minor comment where I think an assert could be good.
@@ -37,7 +37,8 @@ static inline int min(int a, int b) | |||
int ccm_compute_cbc_mac(cipher_t *cipher, const uint8_t iv[16], | |||
const uint8_t *input, size_t length, uint8_t *mac) | |||
{ | |||
uint8_t offset, block_size, mac_enc[16] = { 0 }; | |||
uint8_t block_size, mac_enc[16] = { 0 }; | |||
uint32_t offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this limit the message length to 2^32
and isn't the message limit 2^8L
so 2^64
? I think its OK not to expect messages longer than 2^32
(which is already huge!) buy maybe this should be checked and asserted?
I think the doc should be updated with your changes in #12362 as well but this could be left for a follow up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I change length from size_t
to uint32_t
? That would make the size limitation obvious and lead to a better defined situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I think this is something with public API, but I'll handle it in a separate PR. Lets get this fix in, lets wait for #12362 to get in and then we will go with this one as well.
1f4e154
to
fe0beda
Compare
@mtausig this one needs rebase now. |
Rebased to master |
Ran test locally:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, tested locally and murdock will do the rest. I would like to see the implementation restrictions reflected in the API, but I would rather leave that for another PR.
Failing tests seem an issue with the board connected to murodck, locally I can't reproduce:
Re-triggering build. |
All green here! |
@mtausig thanks for the fix! |
Contribution description
Encryption/Decryption using CCM mode did not work when the message had a size that exceeded 256. This patch fixes it
Testing procedure
I was unable to find a public test vector for messages of large size. I have therefore created a new one manually and validated it against two other crypto libraries (BouncyCastle and pycrpytodome)
Issues/PRs references
Fixes part of issue #8107