Mistake on this page?
Report an issue in GitHub or email us
cryp_stm32.h
1 /**
2  ******************************************************************************
3  * @brief Header file of mbed TLS HW crypto (CRYP) implementation.
4  ******************************************************************************
5  * @attention
6  *
7  * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
8  * SPDX-License-Identifier: Apache-2.0
9  * Copyright (C) 2019-2020 STMicroelectronics, All Rights Reserved
10  *
11  * This software component is licensed by ST under Apache 2.0 license,
12  * the "License"; You may not use this file except in compliance with the
13  * License. You may obtain a copy of the License at:
14  * https://opensource.org/licenses/Apache-2.0
15  *
16  ******************************************************************************
17  */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef __CRYP_H
21 #define __CRYP_H
22 
23 #if !(TARGET_STM32L4)
24 #if defined(MBEDTLS_AES_ALT) || defined(MBEDTLS_CCM_ALT) || defined(MBEDTLS_GCM_ALT)
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /* Includes ------------------------------------------------------------------*/
31 #include "cmsis.h"
32 
33 #if defined(MBEDTLS_THREADING_C)
34 #include "mbedtls/threading.h"
35 #endif
36 
37 /* macros --------------------------------------------------------------------*/
38 /*
39  * 32-bit integer manipulation macros (big endian)
40  */
41 #ifndef GET_UINT32_BE
42 #define GET_UINT32_BE(n,b,i) \
43 do { \
44  (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
45  | ( (uint32_t) (b)[(i) + 1] << 16 ) \
46  | ( (uint32_t) (b)[(i) + 2] << 8 ) \
47  | ( (uint32_t) (b)[(i) + 3] ); \
48 } while( 0 )
49 #endif
50 
51 #ifndef PUT_UINT32_BE
52 #define PUT_UINT32_BE(n,b,i) \
53 do { \
54  (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
55  (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
56  (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
57  (b)[(i) + 3] = (unsigned char) ( (n) ); \
58 } while( 0 )
59 #endif
60 
61 /* constants -----------------------------------------------------------------*/
62 #define ST_CRYP_TIMEOUT 1000 /* timeout (in ms) for the crypto processor */
63 
64 /* defines -------------------------------------------------------------------*/
65 /* AES 192 bits key length may be optional in the HW */
66 #if defined CRYP_KEYSIZE_192B
67 #define USE_AES_KEY192 1
68 #else
69 #define USE_AES_KEY192 0
70 #endif /* USE_AES_KEY192 */
71 
72 /* variables -----------------------------------------------------------------*/
73 #if defined(MBEDTLS_THREADING_C)
74 extern mbedtls_threading_mutex_t cryp_mutex;
75 extern unsigned char cryp_mutex_started;
76 #endif /* MBEDTLS_THREADING_C */
77 
78 extern unsigned int cryp_context_count;
79 
80 /* functions prototypes ------------------------------------------------------*/
81 extern void cryp_zeroize(void *v, size_t n);
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 #endif /* MBEDTLS_AES_ALT or MBEDTLS_CCM_ALT or MBEDTLS_GCM_ALT */
88 #endif /* ! TARGET_STM32L4 */
89 #endif /*__CRYP_H */
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.