@@ -121,8 +121,8 @@ void mbedtls_sha512_clone(mbedtls_sha512_context *dst,
121
121
return ;
122
122
}
123
123
124
- //SHA256_VALIDATE ( dst != NULL );
125
- //SHA256_VALIDATE ( src != NULL );
124
+ SHA512_VALIDATE ( dst != NULL );
125
+ SHA512_VALIDATE ( src != NULL );
126
126
127
127
memcpy (dst , src , sizeof (mbedtls_sha512_context ));
128
128
}
@@ -137,7 +137,7 @@ int mbedtls_sha512_starts_ret(mbedtls_sha512_context *ctx, int is384)
137
137
memset ( ctx , 0 , sizeof ( mbedtls_sha512_context ) );
138
138
ctx -> is384 = is384 ;
139
139
140
- return ( 0 ) ;
140
+ return 0 ;
141
141
}
142
142
143
143
/*
@@ -148,7 +148,6 @@ int mbedtls_sha512_update_ret(mbedtls_sha512_context *ctx, const unsigned char *
148
148
if (ilen > MAX_MB_HASH_BLOCK_BLEN || ctx -> totals > MAX_MB_HASH_BLOCK_BLEN ) {
149
149
// H/W SHA has limitation to seperated API with oversized message.
150
150
// fall back to S/W SHA-512
151
- //memset( ctx, 0, sizeof( mbedtls_sha512_context ) );
152
151
if (ctx -> totals == 0 ) {
153
152
ctx -> total [0 ] = 0 ;
154
153
ctx -> total [1 ] = 0 ;
@@ -181,6 +180,7 @@ int mbedtls_sha512_update_ret(mbedtls_sha512_context *ctx, const unsigned char *
181
180
memcpy (ctx -> sbuf + ctx -> pstMessage .u32DataByteLen , input , ilen );
182
181
ctx -> pstMessage .u32DataByteLen += ilen ;
183
182
}
183
+
184
184
return 0 ;
185
185
}
186
186
@@ -212,7 +212,7 @@ int mbedtls_sha512_finish_ret(mbedtls_sha512_context *ctx, unsigned char output[
212
212
else
213
213
object_id = OID_SHA2_384 ;
214
214
215
- block_byte_len = 64 ; /* meaningless*/
215
+ block_byte_len = 64 ;
216
216
217
217
//! step 1 : set message length parameter to SSS
218
218
ret = mb_hash_init (& ctx -> pstMessage , object_id );
@@ -234,6 +234,11 @@ int mbedtls_sha512_finish_ret(mbedtls_sha512_context *ctx, unsigned char output[
234
234
235
235
//! step 3 : get hash result from SSS
236
236
ret = mb_hash_final (& stHASH_Input , & ctx -> pstDigest );
237
+
238
+ if (ret != SSSR_SUCCESS ) {
239
+ return ret ;
240
+ }
241
+
237
242
}
238
243
return 0 ;
239
244
}
@@ -366,7 +371,7 @@ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx,
366
371
for ( i = 0 ; i < 8 ; i ++ )
367
372
ctx -> state [i ] += A [i ];
368
373
369
- return ( 0 ) ;
374
+ return 0 ;
370
375
}
371
376
372
377
int mbedtls_sha512_sw_finish_ret ( mbedtls_sha512_context * ctx ,
@@ -431,7 +436,7 @@ int mbedtls_sha512_sw_finish_ret( mbedtls_sha512_context *ctx,
431
436
sha512_put_uint64_be ( ctx -> state [7 ], output , 56 );
432
437
}
433
438
434
- return ( 0 ) ;
439
+ return 0 ;
435
440
}
436
441
437
442
int mbedtls_sha512_sw_update_ret (mbedtls_sha512_context * ctx , const unsigned char * input , size_t ilen )
@@ -478,7 +483,7 @@ int mbedtls_sha512_sw_update_ret(mbedtls_sha512_context *ctx, const unsigned cha
478
483
if ( ilen > 0 )
479
484
memcpy ( (void * ) (ctx -> buffer + left ), input , ilen );
480
485
481
- return ( 0 ) ;
486
+ return 0 ;
482
487
}
483
488
484
489
0 commit comments