Skip to content

Commit

Permalink
tidy up PR comments ARMmbed#3
Browse files Browse the repository at this point in the history
Signed-off-by: PARKJIHOON <[email protected]>
  • Loading branch information
jh6186 authored and andrewc-arm committed Jan 14, 2020
1 parent bfb2444 commit 521ece9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
13 changes: 7 additions & 6 deletions features/mbedtls/targets/TARGET_Samsung/sha/sha256_alt.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ int mbedtls_sha256_finish_ret(mbedtls_sha256_context *ctx, unsigned char output[

//! assign hash_byte_len to compare returned result from sss_fw after hash operation
object_id = OID_SHA2_256;
block_byte_len = 64; /* dummy */
block_byte_len = 64;

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


//! step 3 : get hash result from SSS
ret = mb_hash_final(&stHASH_Input, &ctx->pstDigest);
if (ret != SSSR_SUCCESS) {
return ret;
}

}
return 0;
}
Expand Down Expand Up @@ -328,7 +331,7 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
for( i = 0; i < 8; i++ )
ctx->state[i] += A[i];

return( 0 );
return 0;
}


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

return( 0 );
return 0;
}



#endif /* MBEDTLS_SHA256_ALT */
#endif /* MBEDTLS_SHA256_C */
21 changes: 13 additions & 8 deletions features/mbedtls/targets/TARGET_Samsung/sha/sha512_alt.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ void mbedtls_sha512_clone(mbedtls_sha512_context *dst,
return;
}

//SHA256_VALIDATE( dst != NULL );
//SHA256_VALIDATE( src != NULL );
SHA512_VALIDATE( dst != NULL );
SHA512_VALIDATE( src != NULL );

memcpy(dst, src, sizeof(mbedtls_sha512_context));
}
Expand All @@ -137,7 +137,7 @@ int mbedtls_sha512_starts_ret(mbedtls_sha512_context *ctx, int is384)
memset( ctx, 0, sizeof( mbedtls_sha512_context ) );
ctx->is384 = is384;

return( 0 );
return 0;
}

/*
Expand All @@ -148,7 +148,6 @@ int mbedtls_sha512_update_ret(mbedtls_sha512_context *ctx, const unsigned char *
if(ilen > MAX_MB_HASH_BLOCK_BLEN || ctx->totals > MAX_MB_HASH_BLOCK_BLEN) {
// H/W SHA has limitation to seperated API with oversized message.
// fall back to S/W SHA-512
//memset( ctx, 0, sizeof( mbedtls_sha512_context ) );
if(ctx->totals == 0) {
ctx->total[0] = 0;
ctx->total[1] = 0;
Expand Down Expand Up @@ -181,6 +180,7 @@ int mbedtls_sha512_update_ret(mbedtls_sha512_context *ctx, const unsigned char *
memcpy(ctx->sbuf + ctx->pstMessage.u32DataByteLen, input, ilen);
ctx->pstMessage.u32DataByteLen += ilen;
}

return 0;
}

Expand Down Expand Up @@ -212,7 +212,7 @@ int mbedtls_sha512_finish_ret(mbedtls_sha512_context *ctx, unsigned char output[
else
object_id = OID_SHA2_384;

block_byte_len = 64; /* meaningless*/
block_byte_len = 64;

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

//! step 3 : get hash result from SSS
ret = mb_hash_final(&stHASH_Input, &ctx->pstDigest);

if (ret != SSSR_SUCCESS) {
return ret;
}

}
return 0;
}
Expand Down Expand Up @@ -366,7 +371,7 @@ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx,
for( i = 0; i < 8; i++ )
ctx->state[i] += A[i];

return( 0 );
return 0;
}

int mbedtls_sha512_sw_finish_ret( mbedtls_sha512_context *ctx,
Expand Down Expand Up @@ -431,7 +436,7 @@ int mbedtls_sha512_sw_finish_ret( mbedtls_sha512_context *ctx,
sha512_put_uint64_be( ctx->state[7], output, 56 );
}

return( 0 );
return 0;
}

int mbedtls_sha512_sw_update_ret(mbedtls_sha512_context *ctx, const unsigned char *input, size_t ilen)
Expand Down Expand Up @@ -478,7 +483,7 @@ int mbedtls_sha512_sw_update_ret(mbedtls_sha512_context *ctx, const unsigned cha
if( ilen > 0 )
memcpy( (void *) (ctx->buffer + left), input, ilen );

return( 0 );
return 0;
}


Expand Down

0 comments on commit 521ece9

Please sign in to comment.