STM mbedtls: clear algo value for md5/sha1 and sha256

The hw block for mbedtls is shared, thus HASH algo value should be cleared
in the init.
pull/4695/head
Martin Kojtal 2017-08-02 14:04:15 +01:00
parent d92e4b5fcd
commit 744c364683
3 changed files with 6 additions and 0 deletions

View File

@ -100,6 +100,8 @@ void mbedtls_md5_starts( mbedtls_md5_context *ctx )
/* HASH Configuration */
ctx->hhash_md5.Init.DataType = HASH_DATATYPE_8B;
/* clear CR ALGO value */
HASH->CR &= ~HASH_CR_ALGO_Msk;
if (HAL_HASH_Init(&ctx->hhash_md5) != 0) {
// return error code
return;

View File

@ -98,6 +98,8 @@ void mbedtls_sha1_starts( mbedtls_sha1_context *ctx )
/* HASH Configuration */
ctx->hhash_sha1.Init.DataType = HASH_DATATYPE_8B;
/* clear CR ALGO value */
HASH->CR &= ~HASH_CR_ALGO_Msk;
if (HAL_HASH_Init(&ctx->hhash_sha1) == HAL_ERROR) {
// error found to be returned
return;

View File

@ -99,6 +99,8 @@ void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 )
ctx->is224 = is224;
/* HASH Configuration */
ctx->hhash_sha256.Init.DataType = HASH_DATATYPE_8B;
/* clear CR ALGO value */
HASH->CR &= ~HASH_CR_ALGO_Msk;
if (HAL_HASH_Init(&ctx->hhash_sha256) == HAL_ERROR) {
// error found to be returned
return;