Skip to content

Commit d09e3ef

Browse files
Ron EldorRon Eldor
authored andcommitted
Style fixes
1. Remove redundant extra lines. 2. Have the function parameters aligned. 3. Remove redundant white spaces.
1 parent a99ce83 commit d09e3ef

File tree

1 file changed

+34
-36
lines changed
  • features/cryptocell/FEATURE_CRYPTOCELL310

1 file changed

+34
-36
lines changed

features/cryptocell/FEATURE_CRYPTOCELL310/aes_alt.c

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
* AES-CFB128 buffer encryption/decryption
3030
*/
3131
int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
32-
int mode,
33-
size_t length,
34-
size_t *iv_off,
35-
unsigned char iv[16],
36-
const unsigned char *input,
37-
unsigned char *output )
32+
int mode,
33+
size_t length,
34+
size_t *iv_off,
35+
unsigned char iv[16],
36+
const unsigned char *input,
37+
unsigned char *output )
3838
{
3939
return( MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED );
4040
}
@@ -43,11 +43,11 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
4343
* AES-CFB8 buffer encryption/decryption
4444
*/
4545
int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
46-
int mode,
47-
size_t length,
48-
unsigned char iv[16],
49-
const unsigned char *input,
50-
unsigned char *output )
46+
int mode,
47+
size_t length,
48+
unsigned char iv[16],
49+
const unsigned char *input,
50+
unsigned char *output )
5151
{
5252
return( MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED );
5353
}
@@ -82,11 +82,11 @@ int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
8282

8383
#if defined(MBEDTLS_CIPHER_MODE_OFB)
8484
int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx,
85-
size_t length,
86-
size_t *iv_off,
87-
unsigned char iv[16],
88-
const unsigned char *input,
89-
unsigned char *output );
85+
size_t length,
86+
size_t *iv_off,
87+
unsigned char iv[16],
88+
const unsigned char *input,
89+
unsigned char *output );
9090
{
9191
return( MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED );
9292
}
@@ -114,9 +114,8 @@ void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx ){}
114114
static int CC_aes_setkey( mbedtls_aes_context *ctx, const unsigned char *key,
115115
unsigned int keybits, SaSiAesEncryptMode_t cipher_flag )
116116
{
117-
118117
int ret = 0;
119-
if ( ctx == NULL )
118+
if( ctx == NULL )
120119
return( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
121120

122121
switch( keybits )
@@ -135,17 +134,16 @@ static int CC_aes_setkey( mbedtls_aes_context *ctx, const unsigned char *key,
135134
return( MBEDTLS_ERR_AES_INVALID_KEY_LENGTH );
136135
}
137136

138-
return ( 0 );
139-
137+
return( 0 );
140138
}
141139
int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
142-
unsigned int keybits )
140+
unsigned int keybits )
143141
{
144142
return( CC_aes_setkey( ctx, key, keybits, SASI_AES_ENCRYPT ) );
145143
}
146144

147145
int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
148-
unsigned int keybits )
146+
unsigned int keybits )
149147
{
150148
return( CC_aes_setkey( ctx, key, keybits, SASI_AES_DECRYPT ) );
151149
}
@@ -177,17 +175,17 @@ static int CC_aes_cipher( mbedtls_aes_context *ctx,
177175
if( iv )
178176
{
179177
if( iv_len != SASI_AES_IV_SIZE_IN_BYTES )
180-
return MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH;
178+
return( MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH );
181179

182-
ret = SaSi_AesSetIv ( &ctx->CC_Context, iv );
180+
ret = SaSi_AesSetIv( &ctx->CC_Context, iv );
183181
if( ret != 0 )
184-
return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
182+
return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
185183
}
186184

187185
ret = SaSi_AesFinish( &ctx->CC_Context, length,
188186
( unsigned char* )input, length, output, &length );
189187
if( ret != 0 )
190-
return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
188+
return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
191189

192190
/* update the IV for next block
193191
* For CTR mode, update the nonce only if the current length is a full AES block length
@@ -199,20 +197,20 @@ static int CC_aes_cipher( mbedtls_aes_context *ctx,
199197
{
200198
ret = SaSi_AesGetIv( &ctx->CC_Context, iv );
201199
if( ret != 0 )
202-
return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
200+
return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
203201
}
204202

205203
ret = SaSi_AesFree( &ctx->CC_Context );
206-
if ( ret != 0 )
207-
return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
204+
if( ret != 0 )
205+
return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
208206

209-
return ( 0 );
207+
return( 0 );
210208
}
211209

212210
int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
213-
int mode,
214-
const unsigned char input[16],
215-
unsigned char output[16] )
211+
int mode,
212+
const unsigned char input[16],
213+
unsigned char output[16] )
216214
{
217215
if( ctx == NULL )
218216
return( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
@@ -233,7 +231,7 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
233231
unsigned char *output )
234232
{
235233
if( ctx == NULL )
236-
return ( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
234+
return( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
237235

238236
if( length % SASI_AES_BLOCK_SIZE_IN_BYTES )
239237
return( MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH );
@@ -262,7 +260,7 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
262260
if( ctx == NULL )
263261
return( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
264262

265-
if ( *nc_off )
263+
if( *nc_off )
266264
{
267265
/* handle corner case where we are resuming a previous encryption,
268266
* and we are resuming within current cipher stream(stream_block) */
@@ -304,7 +302,7 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
304302
*nc_off = ( length % SASI_AES_BLOCK_SIZE_IN_BYTES );
305303

306304
exit:
307-
return ret;
305+
return( ret );
308306
}
309307
#endif /* MBEDTLS_CIPHER_MODE_CTR */
310308
#endif/* MBEDTLS_AES_ALT */

0 commit comments

Comments
 (0)