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