-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Return an error from mbedtls_cipher_set_iv
for an invalid IV length with ChaCha20 and ChaCha20+Poly
#5253
Return an error from mbedtls_cipher_set_iv
for an invalid IV length with ChaCha20 and ChaCha20+Poly
#5253
Conversation
c27cd42
to
72f0905
Compare
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.
All looks good. I left few minor comments.
|
||
ChaCha20 IV Length 12 | ||
depends_on:MBEDTLS_CHACHA20_C | ||
check_iv:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":12:0 |
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.
Use macro also on success.
|
||
if( cipher_info->type == MBEDTLS_CIPHER_CHACHA20 || | ||
cipher_info->type == MBEDTLS_CIPHER_CHACHA20_POLY1305 ) | ||
iv_len = 12; |
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 understand that 16 byes for iv is default (and max) length and for those two cipher types we are only limiting the length, but maybe we could first determine the iv length and then allocate memory?
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.
Done that :) It has an additional advantage as described in my comment below.
The implementation was silently overwriting the IV length to 12 even though the caller passed a different value. Change the behavior to signal that a different length is not supported. Signed-off-by: Andrzej Kurek <[email protected]>
The implementation was silently overwriting the IV length to 12 even though the caller passed a different value. Change the behavior to signal that a different length is not supported. Signed-off-by: Andrzej Kurek <[email protected]>
Signed-off-by: Andrzej Kurek <[email protected]>
Signed-off-by: Andrzej Kurek <[email protected]>
Signed-off-by: Andrzej Kurek <[email protected]>
4739eab
to
b9fbc11
Compare
Signed-off-by: Andrzej Kurek <[email protected]>
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.
LGTM
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.
Looks good to me
mbedtls_cipher_set_iv
was silently overwritting theiv_len
set by the caller, thus leading to potential API misuse.Fixes #4301.