29
29
* AES-CFB128 buffer encryption/decryption
30
30
*/
31
31
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 )
38
38
{
39
39
return ( MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED );
40
40
}
@@ -43,11 +43,11 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
43
43
* AES-CFB8 buffer encryption/decryption
44
44
*/
45
45
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 )
51
51
{
52
52
return ( MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED );
53
53
}
@@ -82,11 +82,11 @@ int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
82
82
83
83
#if defined(MBEDTLS_CIPHER_MODE_OFB )
84
84
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 );
90
90
{
91
91
return ( MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED );
92
92
}
@@ -114,9 +114,8 @@ void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx ){}
114
114
static int CC_aes_setkey ( mbedtls_aes_context * ctx , const unsigned char * key ,
115
115
unsigned int keybits , SaSiAesEncryptMode_t cipher_flag )
116
116
{
117
-
118
117
int ret = 0 ;
119
- if ( ctx == NULL )
118
+ if ( ctx == NULL )
120
119
return ( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
121
120
122
121
switch ( keybits )
@@ -135,17 +134,16 @@ static int CC_aes_setkey( mbedtls_aes_context *ctx, const unsigned char *key,
135
134
return ( MBEDTLS_ERR_AES_INVALID_KEY_LENGTH );
136
135
}
137
136
138
- return ( 0 );
139
-
137
+ return ( 0 );
140
138
}
141
139
int mbedtls_aes_setkey_enc ( mbedtls_aes_context * ctx , const unsigned char * key ,
142
- unsigned int keybits )
140
+ unsigned int keybits )
143
141
{
144
142
return ( CC_aes_setkey ( ctx , key , keybits , SASI_AES_ENCRYPT ) );
145
143
}
146
144
147
145
int mbedtls_aes_setkey_dec ( mbedtls_aes_context * ctx , const unsigned char * key ,
148
- unsigned int keybits )
146
+ unsigned int keybits )
149
147
{
150
148
return ( CC_aes_setkey ( ctx , key , keybits , SASI_AES_DECRYPT ) );
151
149
}
@@ -177,17 +175,17 @@ static int CC_aes_cipher( mbedtls_aes_context *ctx,
177
175
if ( iv )
178
176
{
179
177
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 ) ;
181
179
182
- ret = SaSi_AesSetIv ( & ctx -> CC_Context , iv );
180
+ ret = SaSi_AesSetIv ( & ctx -> CC_Context , iv );
183
181
if ( ret != 0 )
184
- return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
182
+ return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
185
183
}
186
184
187
185
ret = SaSi_AesFinish ( & ctx -> CC_Context , length ,
188
186
( unsigned char * )input , length , output , & length );
189
187
if ( ret != 0 )
190
- return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
188
+ return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
191
189
192
190
/* update the IV for next block
193
191
* 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,
199
197
{
200
198
ret = SaSi_AesGetIv ( & ctx -> CC_Context , iv );
201
199
if ( ret != 0 )
202
- return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
200
+ return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
203
201
}
204
202
205
203
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 );
208
206
209
- return ( 0 );
207
+ return ( 0 );
210
208
}
211
209
212
210
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 ] )
216
214
{
217
215
if ( ctx == NULL )
218
216
return ( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
@@ -233,7 +231,7 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
233
231
unsigned char * output )
234
232
{
235
233
if ( ctx == NULL )
236
- return ( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
234
+ return ( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
237
235
238
236
if ( length % SASI_AES_BLOCK_SIZE_IN_BYTES )
239
237
return ( MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH );
@@ -262,7 +260,7 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
262
260
if ( ctx == NULL )
263
261
return ( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
264
262
265
- if ( * nc_off )
263
+ if ( * nc_off )
266
264
{
267
265
/* handle corner case where we are resuming a previous encryption,
268
266
* and we are resuming within current cipher stream(stream_block) */
@@ -304,7 +302,7 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
304
302
* nc_off = ( length % SASI_AES_BLOCK_SIZE_IN_BYTES );
305
303
306
304
exit :
307
- return ret ;
305
+ return ( ret ) ;
308
306
}
309
307
#endif /* MBEDTLS_CIPHER_MODE_CTR */
310
308
#endif /* MBEDTLS_AES_ALT */
0 commit comments