Skip to content

Commit aa09e7d

Browse files
committed
STM32 MBEDTLS: Keep specific STM32L4 implementation
1 parent 47aba83 commit aa09e7d

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

features/mbedtls/targets/TARGET_STM/TARGET_STM32L4/aes_alt.c renamed to features/mbedtls/targets/TARGET_STM/aes_alt_stm32l4.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Hardware aes implementation for STM32F4 STM32F7 and STM32L4 families
2+
* Hardware AES implementation for STM32L4 family
33
*******************************************************************************
44
* Copyright (c) 2017, STMicroelectronics
55
* SPDX-License-Identifier: Apache-2.0
@@ -18,17 +18,15 @@
1818
*
1919
*/
2020

21-
#include <string.h>
21+
#if (TARGET_STM32L4)
22+
2223
#include "mbedtls/aes.h"
2324

2425
#if defined(MBEDTLS_AES_ALT)
2526

27+
#include <string.h>
28+
2629
#include "mbedtls/platform.h"
27-
//the following defines are provided to maintain compatibility between STM32 families
28-
#define __HAL_RCC_CRYP_CLK_ENABLE __HAL_RCC_AES_CLK_ENABLE
29-
#define __HAL_RCC_CRYP_FORCE_RESET __HAL_RCC_AES_FORCE_RESET
30-
#define __HAL_RCC_CRYP_RELEASE_RESET __HAL_RCC_AES_RELEASE_RESET
31-
#define CRYP AES
3230

3331
static int aes_set_key(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
3432
{
@@ -48,15 +46,15 @@ static int aes_set_key(mbedtls_aes_context *ctx, const unsigned char *key, unsig
4846
}
4947

5048
ctx->hcryp_aes.Init.DataType = CRYP_DATATYPE_8B;
51-
ctx->hcryp_aes.Instance = CRYP;
49+
ctx->hcryp_aes.Instance = AES;
5250

5351
/* Deinitializes the CRYP peripheral */
5452
if (HAL_CRYP_DeInit(&ctx->hcryp_aes) == HAL_ERROR) {
5553
return (HAL_ERROR);
5654
}
5755

5856
/* Enable CRYP clock */
59-
__HAL_RCC_CRYP_CLK_ENABLE();
57+
__HAL_RCC_AES_CLK_ENABLE();
6058

6159
ctx->hcryp_aes.Init.pKey = ctx->aes_key;
6260
ctx->hcryp_aes.Init.KeyWriteFlag = CRYP_KEY_WRITE_ENABLE;
@@ -97,10 +95,10 @@ void mbedtls_aes_free(mbedtls_aes_context *ctx)
9795
}
9896
#endif /* DUAL_CORE */
9997
/* Force the CRYP Periheral Clock Reset */
100-
__HAL_RCC_CRYP_FORCE_RESET();
98+
__HAL_RCC_AES_FORCE_RESET();
10199

102100
/* Release the CRYP Periheral Clock Reset */
103-
__HAL_RCC_CRYP_RELEASE_RESET();
101+
__HAL_RCC_AES_RELEASE_RESET();
104102
#if defined(DUAL_CORE)
105103
LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, HSEM_CR_COREID_CURRENT);
106104
#endif /* DUAL_CORE */
@@ -388,3 +386,4 @@ void mbedtls_aes_decrypt(mbedtls_aes_context *ctx,
388386
}
389387
#endif /* MBEDTLS_DEPRECATED_REMOVED */
390388
#endif /*MBEDTLS_AES_ALT*/
389+
#endif /* TARGET_STM32L4 */

features/mbedtls/targets/TARGET_STM/TARGET_STM32L4/aes_alt.h renamed to features/mbedtls/targets/TARGET_STM/aes_alt_stm32l4.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
* limitations under the License.
1818
*
1919
*/
20-
#ifndef MBEDTLS_AES_ALT_H
21-
#define MBEDTLS_AES_ALT_H
20+
#ifndef MBEDTLS_STM32L4_AES_ALT_H
21+
#define MBEDTLS_STM32L4_AES_ALT_H
2222

2323

24+
#if (TARGET_STM32L4)
2425
#if defined(MBEDTLS_AES_ALT)
2526
#include "mbedtls/platform.h"
2627
#include "mbedtls/config.h"
@@ -303,5 +304,6 @@ MBEDTLS_DEPRECATED void mbedtls_aes_decrypt(mbedtls_aes_context *ctx,
303304

304305
#endif /* MBEDTLS_AES_ALT */
305306

306-
#endif /* MBEDTLS_AES_ALT_H */
307+
#endif /* TARGET_STM32L4 */
307308

309+
#endif /* MBEDTLS_STM32L4_AES_ALT_H */

0 commit comments

Comments
 (0)