mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 13:55:45 +01:00
cmac: fix whitespace/codingstyle issues
This commit is contained in:
parent
690083c21d
commit
3da5402a89
@ -64,7 +64,8 @@
|
|||||||
*/
|
*/
|
||||||
#define UPDATE_CMAC( x ) \
|
#define UPDATE_CMAC( x ) \
|
||||||
XOR_128( Mn, ( x ), Mn ); \
|
XOR_128( Mn, ( x ), Mn ); \
|
||||||
if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, Mn, 16, Mn, &olen ) ) != 0 ) \
|
if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, \
|
||||||
|
Mn, 16, Mn, &olen ) ) != 0 ) \
|
||||||
return( ret );
|
return( ret );
|
||||||
|
|
||||||
/* Implementation that should never be optimized out by the compiler */
|
/* Implementation that should never be optimized out by the compiler */
|
||||||
@ -97,6 +98,7 @@ static void leftshift_onebit(unsigned char *input, unsigned char *output)
|
|||||||
output[i] |= overflow;
|
output[i] |= overflow;
|
||||||
overflow = temp >> 7;
|
overflow = temp >> 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,14 +107,15 @@ static void leftshift_onebit(unsigned char *input, unsigned char *output)
|
|||||||
*/
|
*/
|
||||||
static int generate_subkeys( mbedtls_cmac_context *ctx )
|
static int generate_subkeys( mbedtls_cmac_context *ctx )
|
||||||
{
|
{
|
||||||
static const unsigned char Rb[2] = {0x00, 0x87}; /* Note - block size 16 only */
|
static const unsigned char Rb[2] = { 0x00, 0x87 }; /* block size 16 only */
|
||||||
int ret;
|
int ret;
|
||||||
unsigned char L[16];
|
unsigned char L[16];
|
||||||
size_t olen;
|
size_t olen;
|
||||||
|
|
||||||
/* Calculate Ek(0) */
|
/* Calculate Ek(0) */
|
||||||
memset( L, 0, 16 );
|
memset( L, 0, 16 );
|
||||||
if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, L, 16, L, &olen ) ) != 0 )
|
if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx,
|
||||||
|
L, 16, L, &olen ) ) != 0 )
|
||||||
{
|
{
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
@ -144,7 +147,8 @@ int mbedtls_cmac_setkey( mbedtls_cmac_context *ctx,
|
|||||||
int ret;
|
int ret;
|
||||||
const mbedtls_cipher_info_t *cipher_info;
|
const mbedtls_cipher_info_t *cipher_info;
|
||||||
|
|
||||||
cipher_info = mbedtls_cipher_info_from_values( cipher, keybits, MBEDTLS_MODE_ECB );
|
cipher_info = mbedtls_cipher_info_from_values( cipher, keybits,
|
||||||
|
MBEDTLS_MODE_ECB );
|
||||||
if( cipher_info == NULL )
|
if( cipher_info == NULL )
|
||||||
return( MBEDTLS_ERR_CMAC_BAD_INPUT );
|
return( MBEDTLS_ERR_CMAC_BAD_INPUT );
|
||||||
|
|
||||||
@ -175,7 +179,9 @@ void mbedtls_cmac_free( mbedtls_cmac_context *ctx )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Use cipher padding function? */
|
/* TODO: Use cipher padding function? */
|
||||||
static void padding(const unsigned char *lastb, unsigned char *pad, const size_t length)
|
static void padding( const unsigned char *lastb,
|
||||||
|
unsigned char *pad,
|
||||||
|
const size_t length )
|
||||||
{
|
{
|
||||||
size_t j;
|
size_t j;
|
||||||
|
|
||||||
@ -318,7 +324,8 @@ int mbedtls_aes_cmac_prf_128( mbedtls_cmac_context *ctx,
|
|||||||
/* Key is AES_CMAC(0, key) */
|
/* Key is AES_CMAC(0, key) */
|
||||||
mbedtls_cmac_init( &zero_ctx );
|
mbedtls_cmac_init( &zero_ctx );
|
||||||
memset( zero_key, 0, 16 );
|
memset( zero_key, 0, 16 );
|
||||||
ret = mbedtls_cmac_setkey( &zero_ctx, MBEDTLS_CIPHER_ID_AES, zero_key, 8 * sizeof zero_key );
|
ret = mbedtls_cmac_setkey( &zero_ctx, MBEDTLS_CIPHER_ID_AES,
|
||||||
|
zero_key, 8 * sizeof zero_key );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
return( ret );
|
return( ret );
|
||||||
@ -330,7 +337,8 @@ int mbedtls_aes_cmac_prf_128( mbedtls_cmac_context *ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mbedtls_cmac_setkey( ctx, MBEDTLS_CIPHER_ID_AES, int_key, 8 * sizeof int_key );
|
ret = mbedtls_cmac_setkey( ctx, MBEDTLS_CIPHER_ID_AES,
|
||||||
|
int_key, 8 * sizeof int_key );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
return( ret );
|
return( ret );
|
||||||
@ -482,6 +490,7 @@ int mbedtls_cmac_self_test( int verbose )
|
|||||||
|
|
||||||
return( 1 );
|
return( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mbedtls_cmac_verify( &ctx, M, Mlen[i], T[i], 16 );
|
ret = mbedtls_cmac_verify( &ctx, M, Mlen[i], T[i], 16 );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user