mirror of https://github.com/ARMmbed/mbed-os.git
Style fixes
1. Remove redundant extra lines. 2. Have the function parameters aligned. 3. Remove redundant white spaces.pull/10907/head
parent
a99ce834bd
commit
d09e3ef3b4
|
@ -114,9 +114,8 @@ void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx ){}
|
||||||
static int CC_aes_setkey( mbedtls_aes_context *ctx, const unsigned char *key,
|
static int CC_aes_setkey( mbedtls_aes_context *ctx, const unsigned char *key,
|
||||||
unsigned int keybits, SaSiAesEncryptMode_t cipher_flag )
|
unsigned int keybits, SaSiAesEncryptMode_t cipher_flag )
|
||||||
{
|
{
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if ( ctx == NULL )
|
if( ctx == NULL )
|
||||||
return( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
|
return( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
|
||||||
|
|
||||||
switch( keybits )
|
switch( keybits )
|
||||||
|
@ -135,8 +134,7 @@ static int CC_aes_setkey( mbedtls_aes_context *ctx, const unsigned char *key,
|
||||||
return( MBEDTLS_ERR_AES_INVALID_KEY_LENGTH );
|
return( MBEDTLS_ERR_AES_INVALID_KEY_LENGTH );
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( 0 );
|
return( 0 );
|
||||||
|
|
||||||
}
|
}
|
||||||
int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
|
int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
|
||||||
unsigned int keybits )
|
unsigned int keybits )
|
||||||
|
@ -177,17 +175,17 @@ static int CC_aes_cipher( mbedtls_aes_context *ctx,
|
||||||
if( iv )
|
if( iv )
|
||||||
{
|
{
|
||||||
if( iv_len != SASI_AES_IV_SIZE_IN_BYTES )
|
if( iv_len != SASI_AES_IV_SIZE_IN_BYTES )
|
||||||
return MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH;
|
return( MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH );
|
||||||
|
|
||||||
ret = SaSi_AesSetIv ( &ctx->CC_Context, iv );
|
ret = SaSi_AesSetIv( &ctx->CC_Context, iv );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
|
return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SaSi_AesFinish( &ctx->CC_Context, length,
|
ret = SaSi_AesFinish( &ctx->CC_Context, length,
|
||||||
( unsigned char* )input, length, output, &length );
|
( unsigned char* )input, length, output, &length );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
|
return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
|
||||||
|
|
||||||
/* update the IV for next block
|
/* update the IV for next block
|
||||||
* For CTR mode, update the nonce only if the current length is a full AES block length
|
* For CTR mode, update the nonce only if the current length is a full AES block length
|
||||||
|
@ -199,14 +197,14 @@ static int CC_aes_cipher( mbedtls_aes_context *ctx,
|
||||||
{
|
{
|
||||||
ret = SaSi_AesGetIv( &ctx->CC_Context, iv );
|
ret = SaSi_AesGetIv( &ctx->CC_Context, iv );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
|
return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SaSi_AesFree( &ctx->CC_Context );
|
ret = SaSi_AesFree( &ctx->CC_Context );
|
||||||
if ( ret != 0 )
|
if( ret != 0 )
|
||||||
return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
|
return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
|
||||||
|
|
||||||
return ( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
|
int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
|
||||||
|
@ -233,7 +231,7 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
|
||||||
unsigned char *output )
|
unsigned char *output )
|
||||||
{
|
{
|
||||||
if( ctx == NULL )
|
if( ctx == NULL )
|
||||||
return ( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
|
return( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
|
||||||
|
|
||||||
if( length % SASI_AES_BLOCK_SIZE_IN_BYTES )
|
if( length % SASI_AES_BLOCK_SIZE_IN_BYTES )
|
||||||
return( MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH );
|
return( MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH );
|
||||||
|
@ -262,7 +260,7 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
|
||||||
if( ctx == NULL )
|
if( ctx == NULL )
|
||||||
return( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
|
return( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
|
||||||
|
|
||||||
if ( *nc_off )
|
if( *nc_off )
|
||||||
{
|
{
|
||||||
/* handle corner case where we are resuming a previous encryption,
|
/* handle corner case where we are resuming a previous encryption,
|
||||||
* and we are resuming within current cipher stream(stream_block) */
|
* and we are resuming within current cipher stream(stream_block) */
|
||||||
|
@ -304,7 +302,7 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
|
||||||
*nc_off = ( length % SASI_AES_BLOCK_SIZE_IN_BYTES );
|
*nc_off = ( length % SASI_AES_BLOCK_SIZE_IN_BYTES );
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return ret;
|
return( ret );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_CIPHER_MODE_CTR */
|
#endif /* MBEDTLS_CIPHER_MODE_CTR */
|
||||||
#endif/* MBEDTLS_AES_ALT */
|
#endif/* MBEDTLS_AES_ALT */
|
||||||
|
|
Loading…
Reference in New Issue