From 361d804e2e772df30789f7f985c2107d2cff51e4 Mon Sep 17 00:00:00 2001 From: Juho Eskeli Date: Mon, 3 Dec 2018 12:22:58 +0200 Subject: [PATCH] STM32L4: before calling HAL_CRYP_DeInit initialize the Instance member --- features/mbedtls/targets/TARGET_STM/aes_alt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/features/mbedtls/targets/TARGET_STM/aes_alt.c b/features/mbedtls/targets/TARGET_STM/aes_alt.c index dae8721634..84d3ed2c64 100644 --- a/features/mbedtls/targets/TARGET_STM/aes_alt.c +++ b/features/mbedtls/targets/TARGET_STM/aes_alt.c @@ -56,13 +56,14 @@ static int aes_set_key(mbedtls_aes_context *ctx, const unsigned char *key, unsig return (MBEDTLS_ERR_AES_INVALID_KEY_LENGTH); } + ctx->hcryp_aes.Init.DataType = CRYP_DATATYPE_8B; + ctx->hcryp_aes.Instance = CRYP; + /* Deinitializes the CRYP peripheral */ if (HAL_CRYP_DeInit(&ctx->hcryp_aes) == HAL_ERROR) { return (HAL_ERROR); } - ctx->hcryp_aes.Init.DataType = CRYP_DATATYPE_8B; - ctx->hcryp_aes.Instance = CRYP; /* Enable CRYP clock */ __HAL_RCC_CRYP_CLK_ENABLE();