From 997e85c049c122357387e4c077d1045b8142e819 Mon Sep 17 00:00:00 2001 From: Janos Follath Date: Tue, 29 May 2018 11:33:45 +0100 Subject: [PATCH] CCM*: Remove nested if --- library/ccm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index b195a7165..32f8bb098 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -152,14 +152,12 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, * Check length requirements: SP800-38C A.1 * Additional requirement: a < 2^16 - 2^8 to simplify the code. * 'length' checked later (when writing it to the first block) + * + * Also, loosen the requirements to enable support for CCM* (IEEE 802.15.4). */ - if( tag_len < 4 || tag_len > 16 || tag_len % 2 != 0 ) + if( tag_len == 2 || tag_len > 16 || tag_len % 2 != 0 ) { - /* - * Loosen the requirements to enable support for CCM* (IEEE 802.15.4) - */ - if( tag_len != 0 ) - return( MBEDTLS_ERR_CCM_BAD_INPUT ); + return( MBEDTLS_ERR_CCM_BAD_INPUT ); } /* Also implies q is within bounds */