1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /* Copyright (c) 2018, Linaro Limited */
3 #ifndef __MBEDTLS_CONFIG_KERNEL_H
4 #define __MBEDTLS_CONFIG_KERNEL_H
5 
6 #ifdef ARM32
7 #define MBEDTLS_HAVE_INT32
8 #endif
9 #ifdef ARM64
10 #define MBEDTLS_HAVE_INT64
11 #endif
12 #define MBEDTLS_BIGNUM_C
13 #define MBEDTLS_GENPRIME
14 
15 /* Test if Mbedtls is the primary crypto lib */
16 #ifdef CFG_CRYPTOLIB_NAME_mbedtls
17 
18 #if defined(CFG_CRYPTO_MD5)
19 #define MBEDTLS_MD5_C
20 #define MBEDTLS_MD_C
21 #endif
22 
23 #if defined(CFG_CRYPTO_SHA1)
24 #define MBEDTLS_SHA1_C
25 #define MBEDTLS_MD_C
26 #if defined(CFG_CORE_CRYPTO_SHA1_ACCEL)
27 #define MBEDTLS_SHA1_PROCESS_ALT
28 #endif
29 #endif
30 
31 #if defined(CFG_CRYPTO_SHA224) || defined(CFG_CRYPTO_SHA256)
32 #define MBEDTLS_SHA256_C
33 #define MBEDTLS_MD_C
34 #if defined(CFG_CORE_CRYPTO_SHA256_ACCEL)
35 #define MBEDTLS_SHA256_PROCESS_ALT
36 #endif
37 #endif
38 
39 #if defined(CFG_CRYPTO_SHA384) || defined(CFG_CRYPTO_SHA512)
40 #define MBEDTLS_SHA512_C
41 #define MBEDTLS_MD_C
42 #if defined(CFG_CORE_CRYPTO_SHA512_ACCEL)
43 #define MBEDTLS_SHA512_PROCESS_ALT
44 #endif
45 #endif
46 
47 #if defined(CFG_CRYPTO_HMAC)
48 #define MBEDTLS_MD_C
49 #endif
50 
51 #if defined(CFG_CRYPTO_AES)
52 #define MBEDTLS_AES_C
53 #define MBEDTLS_AES_ROM_TABLES
54 #if defined(CFG_CORE_CRYPTO_AES_ACCEL)
55 #define MBEDTLS_AES_ALT
56 #endif
57 #endif
58 
59 #if defined(CFG_CRYPTO_DES)
60 #define MBEDTLS_DES_C
61 #endif
62 
63 #if defined(CFG_CRYPTO_CBC)
64 #define MBEDTLS_CIPHER_MODE_CBC
65 #endif
66 
67 #if defined(CFG_CRYPTO_CTR)
68 #define MBEDTLS_CIPHER_MODE_CTR
69 #endif
70 
71 #if defined(CFG_CRYPTO_CMAC)
72 #define MBEDTLS_CMAC_C
73 #define MBEDTLS_CIPHER_C
74 #endif
75 
76 #if defined(CFG_CRYPTO_RSA) || defined(CFG_CRYPTO_DH) || defined(CFG_CRYPTO_ECC)
77 #define MBEDTLS_BIGNUM_C
78 #define MBEDTLS_OID_C
79 #define MBEDTLS_PKCS1_V15
80 #define MBEDTLS_PKCS1_V21
81 #define MBEDTLS_PK_C
82 #define MBEDTLS_GENPRIME
83 #define MBEDTLS_CTR_DRBG_C
84 #endif
85 
86 #if defined(CFG_CRYPTO_RSA)
87 #define MBEDTLS_RSA_C
88 #define MBEDTLS_RSA_NO_CRT
89 #endif
90 
91 #if defined(CFG_CRYPTO_RSA) || defined(CFG_CRYPTO_ECC)
92 #define MBEDTLS_ASN1_PARSE_C
93 #define MBEDTLS_ASN1_WRITE_C
94 #endif
95 
96 #if defined(CFG_CRYPTO_DH)
97 #define MBEDTLS_DHM_C
98 #endif
99 
100 #if defined(CFG_CRYPTO_ECC)
101 #define MBEDTLS_ECP_DP_SECP192R1_ENABLED
102 #define MBEDTLS_ECP_DP_SECP224R1_ENABLED
103 #define MBEDTLS_ECP_DP_SECP256R1_ENABLED
104 #define MBEDTLS_ECP_DP_SECP384R1_ENABLED
105 #define MBEDTLS_ECP_DP_SECP521R1_ENABLED
106 #define MBEDTLS_ECP_DP_SECP192K1_ENABLED
107 #define MBEDTLS_ECP_DP_SECP224K1_ENABLED
108 #define MBEDTLS_ECP_DP_SECP256K1_ENABLED
109 #define MBEDTLS_ECP_DP_BP256R1_ENABLED
110 #define MBEDTLS_ECP_DP_BP384R1_ENABLED
111 #define MBEDTLS_ECP_DP_BP512R1_ENABLED
112 #define MBEDTLS_ECP_DP_CURVE25519_ENABLED
113 #define MBEDTLS_ECP_C
114 #define MBEDTLS_ECDSA_C
115 #define MBEDTLS_ECDH_C
116 #define MBEDTLS_ECDH_LEGACY_CONTEXT
117 #if defined(CFG_CRYPTO_DSA) || defined(CFG_CRYPTO_SM2_PKE) || \
118 	defined(CFG_CRYPTO_SM2_KEP)
119 #define MBEDTLS_ECP_DP_SM2_ENABLED
120 #endif
121 #endif
122 
123 #endif /*CFG_CRYPTOLIB_NAME_mbedtls*/
124 
125 #include <mbedtls/check_config.h>
126 
127 #endif /* __MBEDTLS_CONFIG_KERNEL_H */
128