mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2024-12-27 12:16:07 +00:00
Merge pull request #9497 from minosgalanakis/bugfix/return_early_in_ccm_star
ccm.c: Return early when ccm* is used without tag.
This commit is contained in:
commit
de4d5b7855
@ -167,11 +167,12 @@ static int ccm_calculate_first_block_if_ready(mbedtls_ccm_context *ctx)
|
||||
}
|
||||
|
||||
/* CCM expects non-empty tag.
|
||||
* CCM* allows empty tag. For CCM* without tag, ignore plaintext length.
|
||||
* CCM* allows empty tag. For CCM* without tag, the tag calculation is skipped.
|
||||
*/
|
||||
if (ctx->tag_len == 0) {
|
||||
if (ctx->mode == MBEDTLS_CCM_STAR_ENCRYPT || ctx->mode == MBEDTLS_CCM_STAR_DECRYPT) {
|
||||
ctx->plaintext_len = 0;
|
||||
return 0;
|
||||
} else {
|
||||
return MBEDTLS_ERR_CCM_BAD_INPUT;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user