Commit d18c7070 authored by Manuel Pégourié-Gonnard's avatar Manuel Pégourié-Gonnard Committed by Simon Butcher

cmac: reduce visibility of macros

The #undef is usefull for people who want to to amalgamated releases
parent 2c063063
......@@ -46,29 +46,6 @@
#endif /* MBEDTLS_PLATFORM_C */
#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
/*
* Macros for common operations.
* Results in smaller compiled code than static inline functions.
*/
/*
* XOR 128-bit
*/
#define XOR_128( o, i1, i2 ) \
for( i = 0; i < 16; i++ ) \
( o )[i] = ( i1 )[i] ^ ( i2 )[i];
/*
* Update the CMAC state using an input block x
*/
#define UPDATE_CMAC( x ) \
do { \
XOR_128( state, ( x ), state ); \
if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, \
state, 16, state, &olen ) ) != 0 ) \
return( ret ); \
} while( 0 )
/* Implementation that should never be optimized out by the compiler */
static void mbedtls_zeroize( void *v, size_t n ) {
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
......@@ -211,6 +188,25 @@ static void padding( unsigned char padded_block[16],
}
}
/*
* XOR 128-bit
* Here, macro results in smaller compiled code than static inline function
*/
#define XOR_128( o, i1, i2 ) \
for( i = 0; i < 16; i++ ) \
( o )[i] = ( i1 )[i] ^ ( i2 )[i];
/*
* Update the CMAC state using an input block x
*/
#define UPDATE_CMAC( x ) \
do { \
XOR_128( state, ( x ), state ); \
if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, \
state, 16, state, &olen ) ) != 0 ) \
return( ret ); \
} while( 0 )
/*
* Generate tag on complete message
*/
......@@ -261,6 +257,9 @@ static int cmac_generate( mbedtls_cmac_context *ctx,
return( 0 );
}
#undef XOR_128
#undef UPDATE_CMAC
int mbedtls_cmac_generate( mbedtls_cmac_context *ctx,
const unsigned char *input, size_t in_len,
unsigned char *tag, size_t tag_len )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment