mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-24 15:40:03 +00:00
Replace BAD_SEQUENCE error with BAD_INPUT
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
This commit is contained in:
parent
e40ae6bbed
commit
7251eda6ff
@ -61,8 +61,6 @@
|
|||||||
#define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D
|
#define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D
|
||||||
/** Authenticated decryption failed. */
|
/** Authenticated decryption failed. */
|
||||||
#define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F
|
#define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F
|
||||||
/** CCM functions called in the wrong sequence. */
|
|
||||||
#define MBEDTLS_ERR_CCM_BAD_SEQUENCE -0x0011
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -270,7 +270,7 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx,
|
|||||||
{
|
{
|
||||||
if( ctx->state & CCM_STATE__AUTH_DATA_FINISHED )
|
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) )
|
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 ) )
|
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 )
|
if( ctx->plaintext_len > 0 && ctx->processed != ctx->plaintext_len )
|
||||||
{
|
{
|
||||||
return MBEDTLS_ERR_CCM_BAD_SEQUENCE;
|
return MBEDTLS_ERR_CCM_BAD_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -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) );
|
TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len/2) );
|
||||||
|
|
||||||
ASSERT_ALLOC( output, 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:
|
exit:
|
||||||
mbedtls_free( output );
|
mbedtls_free( output );
|
||||||
@ -585,7 +585,7 @@ void mbedtls_ccm_full_ad_and_overflow( int cipher_id, int mode,
|
|||||||
// pass full auth data
|
// pass full auth data
|
||||||
TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len) );
|
TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len) );
|
||||||
// pass 1 extra byte
|
// 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:
|
exit:
|
||||||
mbedtls_ccm_free( &ctx );
|
mbedtls_ccm_free( &ctx );
|
||||||
}
|
}
|
||||||
@ -644,7 +644,7 @@ void mbedtls_ccm_incomplete_update( int cipher_id, int mode,
|
|||||||
output = NULL;
|
output = NULL;
|
||||||
|
|
||||||
ASSERT_ALLOC( output, 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:
|
exit:
|
||||||
mbedtls_free( output );
|
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 ) );
|
TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, 16, 16, 16 ) );
|
||||||
|
|
||||||
ASSERT_ALLOC( output, 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:
|
exit:
|
||||||
mbedtls_free( output );
|
mbedtls_free( output );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user