Skip to content

Commit 7f8eb38

Browse files
jh6186andrewc-arm
authored andcommitted
tidy up PR comments ARMmbed#3
Signed-off-by: PARKJIHOON <[email protected]>
1 parent 39e43bf commit 7f8eb38

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

features/mbedtls/targets/TARGET_Samsung/sha/sha256_alt.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ int mbedtls_sha256_finish_ret(mbedtls_sha256_context *ctx, unsigned char output[
197197

198198
//! assign hash_byte_len to compare returned result from sss_fw after hash operation
199199
object_id = OID_SHA2_256;
200-
block_byte_len = 64; /* dummy */
200+
block_byte_len = 64;
201201

202202
//! step 1 : set message length parameter to SSS
203203
ret = mb_hash_init(&ctx->pstMessage, object_id);
@@ -216,10 +216,13 @@ int mbedtls_sha256_finish_ret(mbedtls_sha256_context *ctx, unsigned char output[
216216
if (ret != SSSR_SUCCESS) {
217217
return ret;
218218
}
219-
220219

221220
//! step 3 : get hash result from SSS
222221
ret = mb_hash_final(&stHASH_Input, &ctx->pstDigest);
222+
if (ret != SSSR_SUCCESS) {
223+
return ret;
224+
}
225+
223226
}
224227
return 0;
225228
}
@@ -328,7 +331,7 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
328331
for( i = 0; i < 8; i++ )
329332
ctx->state[i] += A[i];
330333

331-
return( 0 );
334+
return 0;
332335
}
333336

334337

@@ -439,10 +442,8 @@ int mbedtls_sha256_sw_update_ret(mbedtls_sha256_context *ctx, const unsigned cha
439442
if( ilen > 0 )
440443
memcpy( (void *) (ctx->buffer + left), input, ilen );
441444

442-
return( 0 );
445+
return 0;
443446
}
444-
445-
446447

447448
#endif /* MBEDTLS_SHA256_ALT */
448449
#endif /* MBEDTLS_SHA256_C */

features/mbedtls/targets/TARGET_Samsung/sha/sha512_alt.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ void mbedtls_sha512_clone(mbedtls_sha512_context *dst,
121121
return;
122122
}
123123

124-
//SHA256_VALIDATE( dst != NULL );
125-
//SHA256_VALIDATE( src != NULL );
124+
SHA512_VALIDATE( dst != NULL );
125+
SHA512_VALIDATE( src != NULL );
126126

127127
memcpy(dst, src, sizeof(mbedtls_sha512_context));
128128
}
@@ -137,7 +137,7 @@ int mbedtls_sha512_starts_ret(mbedtls_sha512_context *ctx, int is384)
137137
memset( ctx, 0, sizeof( mbedtls_sha512_context ) );
138138
ctx->is384 = is384;
139139

140-
return( 0 );
140+
return 0;
141141
}
142142

143143
/*
@@ -148,7 +148,6 @@ int mbedtls_sha512_update_ret(mbedtls_sha512_context *ctx, const unsigned char *
148148
if(ilen > MAX_MB_HASH_BLOCK_BLEN || ctx->totals > MAX_MB_HASH_BLOCK_BLEN) {
149149
// H/W SHA has limitation to seperated API with oversized message.
150150
// fall back to S/W SHA-512
151-
//memset( ctx, 0, sizeof( mbedtls_sha512_context ) );
152151
if(ctx->totals == 0) {
153152
ctx->total[0] = 0;
154153
ctx->total[1] = 0;
@@ -181,6 +180,7 @@ int mbedtls_sha512_update_ret(mbedtls_sha512_context *ctx, const unsigned char *
181180
memcpy(ctx->sbuf + ctx->pstMessage.u32DataByteLen, input, ilen);
182181
ctx->pstMessage.u32DataByteLen += ilen;
183182
}
183+
184184
return 0;
185185
}
186186

@@ -212,7 +212,7 @@ int mbedtls_sha512_finish_ret(mbedtls_sha512_context *ctx, unsigned char output[
212212
else
213213
object_id = OID_SHA2_384;
214214

215-
block_byte_len = 64; /* meaningless*/
215+
block_byte_len = 64;
216216

217217
//! step 1 : set message length parameter to SSS
218218
ret = mb_hash_init(&ctx->pstMessage, object_id);
@@ -234,6 +234,11 @@ int mbedtls_sha512_finish_ret(mbedtls_sha512_context *ctx, unsigned char output[
234234

235235
//! step 3 : get hash result from SSS
236236
ret = mb_hash_final(&stHASH_Input, &ctx->pstDigest);
237+
238+
if (ret != SSSR_SUCCESS) {
239+
return ret;
240+
}
241+
237242
}
238243
return 0;
239244
}
@@ -366,7 +371,7 @@ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx,
366371
for( i = 0; i < 8; i++ )
367372
ctx->state[i] += A[i];
368373

369-
return( 0 );
374+
return 0;
370375
}
371376

372377
int mbedtls_sha512_sw_finish_ret( mbedtls_sha512_context *ctx,
@@ -431,7 +436,7 @@ int mbedtls_sha512_sw_finish_ret( mbedtls_sha512_context *ctx,
431436
sha512_put_uint64_be( ctx->state[7], output, 56 );
432437
}
433438

434-
return( 0 );
439+
return 0;
435440
}
436441

437442
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
478483
if( ilen > 0 )
479484
memcpy( (void *) (ctx->buffer + left), input, ilen );
480485

481-
return( 0 );
486+
return 0;
482487
}
483488

484489

0 commit comments

Comments
 (0)