From 7251eda6ff7106752eab172862cc74f476e2b049 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 1 Sep 2021 13:26:44 +0200 Subject: [PATCH] Replace BAD_SEQUENCE error with BAD_INPUT Signed-off-by: Mateusz Starzyk --- include/mbedtls/ccm.h | 2 -- library/ccm.c | 6 +++--- tests/suites/test_suite_ccm.function | 8 ++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index c78af48e4..6f991fefb 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -61,8 +61,6 @@ #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D /** Authenticated decryption failed. */ #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F -/** CCM functions called in the wrong sequence. */ -#define MBEDTLS_ERR_CCM_BAD_SEQUENCE -0x0011 #ifdef __cplusplus extern "C" { diff --git a/library/ccm.c b/library/ccm.c index 0a904613e..d9d25cecd 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -270,7 +270,7 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, { if( ctx->state & CCM_STATE__AUTH_DATA_FINISHED ) { - return MBEDTLS_ERR_CCM_BAD_SEQUENCE; + return MBEDTLS_ERR_CCM_BAD_INPUT; } if( !(ctx->state & CCM_STATE__AUTH_DATA_STARTED) ) @@ -444,12 +444,12 @@ int mbedtls_ccm_finish( mbedtls_ccm_context *ctx, if( ctx->add_len > 0 && !( ctx->state & CCM_STATE__AUTH_DATA_FINISHED ) ) { - return MBEDTLS_ERR_CCM_BAD_SEQUENCE; + return MBEDTLS_ERR_CCM_BAD_INPUT; } if( ctx->plaintext_len > 0 && ctx->processed != ctx->plaintext_len ) { - return MBEDTLS_ERR_CCM_BAD_SEQUENCE; + return MBEDTLS_ERR_CCM_BAD_INPUT; } /* diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 48c4fe919..128bd86d9 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -559,7 +559,7 @@ void mbedtls_ccm_incomplete_ad( int cipher_id, int mode, TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len/2) ); ASSERT_ALLOC( output, 16 ); - TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_SEQUENCE, mbedtls_ccm_finish( &ctx, output, 16 ) ); + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_finish( &ctx, output, 16 ) ); exit: mbedtls_free( output ); @@ -585,7 +585,7 @@ void mbedtls_ccm_full_ad_and_overflow( int cipher_id, int mode, // pass full auth data TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len) ); // pass 1 extra byte - TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_SEQUENCE, mbedtls_ccm_update_ad( &ctx, add->x, 1) ); + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_update_ad( &ctx, add->x, 1) ); exit: mbedtls_ccm_free( &ctx ); } @@ -644,7 +644,7 @@ void mbedtls_ccm_incomplete_update( int cipher_id, int mode, output = NULL; ASSERT_ALLOC( output, 16 ); - TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_SEQUENCE, mbedtls_ccm_finish( &ctx, output, 16 ) ); + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_finish( &ctx, output, 16 ) ); exit: mbedtls_free( output ); @@ -699,7 +699,7 @@ void mbedtls_ccm_instant_finish( int cipher_id, int mode, TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, 16, 16, 16 ) ); ASSERT_ALLOC( output, 16 ); - TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_SEQUENCE, mbedtls_ccm_finish( &ctx, output, 16 ) ); + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_finish( &ctx, output, 16 ) ); exit: mbedtls_free( output );