Replace BAD_SEQUENCE error with BAD_INPUT
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h
index c78af48..6f991fe 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 0a90461..d9d25ce 100644
--- a/library/ccm.c
+++ b/library/ccm.c
@@ -270,7 +270,7 @@
{
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 @@
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 48c4fe9..128bd86 100644
--- a/tests/suites/test_suite_ccm.function
+++ b/tests/suites/test_suite_ccm.function
@@ -559,7 +559,7 @@
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 @@
// 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 @@
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 @@
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 );