1 /***************************************************************************//**
2 * \file cy_crypto_config.h
3 * \version 2.90
4 *
5 * \brief
6 *  This file provides default configuration parameters
7 *  for the Crypto driver.
8 *
9 ********************************************************************************
10 * Copyright 2016-2022 Cypress Semiconductor Corporation
11 * SPDX-License-Identifier: Apache-2.0
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 *    http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *******************************************************************************/
25 
26 
27 #if !defined(CY_CRYPTO_CONFIG_H)
28 #define CY_CRYPTO_CONFIG_H
29 
30 #include "cy_device.h"
31 #include "cy_device_headers.h"
32 
33 #if defined (CY_IP_MXCRYPTO)
34 
35 #include "cy_syslib.h"
36 
37 CY_MISRA_DEVIATE_BLOCK_START('MISRA C-2012 Rule 20.5', 2, \
38 'Since hardware configurations are decided by CRYPTO hardware IP version, use of #undef will not make it ambiguous that which macros exist at a particular point within a translation unit.')
39 
40 #if defined(CY_CRYPTO_USER_CONFIG_FILE)
41 #include CY_CRYPTO_USER_CONFIG_FILE
42 #else
43 
44 /*
45  * Use hardware specific model instead of PDL device agnostic model.
46  *   Disabled by default.
47  */
48 #define CY_CRYPTO_CFG_HW_USE_MPN_SPECIFIC
49 
50 /* CRYPTO hardware version 1 support */
51 #define CY_CRYPTO_CFG_HW_V1_ENABLE
52 
53 /* CRYPTO hardware version 2 support */
54 #define CY_CRYPTO_CFG_HW_V2_ENABLE
55 
56 /* Default configuration:
57  *
58  * - SHA1
59  * - SHA256
60  * - SHA512
61  * - HMAC
62  * - AES ECB
63  * - AES CBC
64  * - AES CFB
65  * - AES CTR
66  * - CMAC
67  * - CRC
68  * - PRNG
69  * - TRNG
70  * - DES/TDES
71  * - RSA encrypt/decrypt
72  * - RSA PKCS#1.l5 verification
73  * - ECP multiplication
74  * - ECDSA key generation
75  * - ECDSA sign
76  * - ECDSA verification
77  */
78 
79 #define CY_CRYPTO_CFG_CRC_C
80 #define CY_CRYPTO_CFG_DES_C
81 #define CY_CRYPTO_CFG_PRNG_C
82 #define CY_CRYPTO_CFG_TRNG_C
83 
84 /* Currently this driver supports CBC, CFB, CTR cipher modes */
85 #define CY_CRYPTO_CFG_AES_C
86 #define CY_CRYPTO_CFG_CMAC_C
87 #define CY_CRYPTO_CFG_GCM_C
88 
89 /* AES Cipher modes */
90 #define CY_CRYPTO_CFG_CIPHER_MODE_CBC
91 #define CY_CRYPTO_CFG_CIPHER_MODE_CFB
92 #define CY_CRYPTO_CFG_CIPHER_MODE_CTR
93 
94 /* Currently OFB, XTS cipher modes are not implemented */
95 // #define CY_CRYPTO_CFG_CIPHER_MODE_OFB
96 // #define CY_CRYPTO_CFG_CIPHER_MODE_XTS
97 
98 #define CY_CRYPTO_CFG_SHA_C
99 #define CY_CRYPTO_CFG_HMAC_C
100 
101 #define CY_CRYPTO_CFG_SHA1_ENABLED
102 #define CY_CRYPTO_CFG_SHA2_256_ENABLED
103 #define CY_CRYPTO_CFG_SHA2_512_ENABLED
104 
105 /* Currently SHA3 is not implemented */
106 // #define CY_CRYPTO_CFG_SHA3_C
107 
108 
109 /* RSA functionality */
110 #define CY_CRYPTO_CFG_RSA_C
111 /* RSA PKCS 1.5 verification */
112 #define CY_CRYPTO_CFG_RSA_VERIFY_ENABLED
113 
114 /* Only NIST-P curves are currently supported */
115 #define CY_CRYPTO_CFG_ECP_C
116 
117 #define CY_CRYPTO_CFG_ECP_DP_SECP192R1_ENABLED
118 #define CY_CRYPTO_CFG_ECP_DP_SECP224R1_ENABLED
119 #define CY_CRYPTO_CFG_ECP_DP_SECP256R1_ENABLED
120 #define CY_CRYPTO_CFG_ECP_DP_SECP384R1_ENABLED
121 #define CY_CRYPTO_CFG_ECP_DP_SECP521R1_ENABLED
122 
123 /* Currently CURVE25519 support is not implemented */
124 // #define CY_CRYPTO_CFG_ECP_DP_CURVE25519_ENABLED
125 
126 /* ECDSA functionality */
127 #define CY_CRYPTO_CFG_ECDSA_C
128 
129 /* ECDSA key generation */
130 #define CY_CRYPTO_CFG_ECDSA_GENKEY_C
131 /* ECDSA sign */
132 #define CY_CRYPTO_CFG_ECDSA_SIGN_C
133 /* ECDSA verification */
134 #define CY_CRYPTO_CFG_ECDSA_VERIFY_C
135 
136 /* External memory use */
137 //#define CY_CRYPTO_CFG_EXTERNAL_MEMORY_ENABLE
138 
139 #if (CY_IP_MXCRYPTO_VERSION == 2u)
140 /* Disabled chacha20 functionality */
141 //#define CY_CRYPTO_CFG_CHACHA_ENABLED
142 
143 /* Disabled poly1305 functionality */
144 //#define CY_CRYPTO_CFG_POLY1305_ENABLED
145 #endif
146 
147 #endif
148 
149 /* Check hardware configuration */
150 #if defined(CY_CRYPTO_CFG_HW_USE_MPN_SPECIFIC)
151      #undef CY_CRYPTO_CFG_HW_V1_ENABLE
152      #undef CY_CRYPTO_CFG_HW_V2_ENABLE
153 
154      #if (CY_IP_MXCRYPTO_VERSION == 1u)
155      /* CRYPTO hardware version 1 support */
156      #define CY_CRYPTO_CFG_HW_V1_ENABLE
157      #endif
158 
159      #if (CY_IP_MXCRYPTO_VERSION == 2u)
160      /* CRYPTO hardware version 2 support */
161      #define CY_CRYPTO_CFG_HW_V2_ENABLE
162      #endif
163 #else
164      #if !defined(CY_CRYPTO_CFG_HW_V1_ENABLE) && !defined(CY_CRYPTO_CFG_HW_V2_ENABLE)
165      #error "Select proper hardware configuration (CY_CRYPTO_CFG_HW_V1_ENABLE or CY_CRYPTO_CFG_HW_V2_ENABLE)"
166      #endif /* !defined(CY_CRYPTO_CFG_HW_V1_ENABLE) && !defined(CY_CRYPTO_CFG_HW_V2_ENABLE) */
167 
168 #endif
169 
170 /* Check AES configuration */
171 #if (defined(CY_CRYPTO_CFG_CIPHER_MODE_CBC) || \
172      defined(CY_CRYPTO_CFG_CIPHER_MODE_CFB) || \
173      defined(CY_CRYPTO_CFG_CIPHER_MODE_CTR)) \
174      && !defined(CY_CRYPTO_CFG_AES_C)
175 #error "CY_CRYPTO_CFG_AES_C is not defined to use any AES ciphers"
176 #endif
177 
178 /* Check CMAC configuration */
179 #if defined(CY_CRYPTO_CFG_CMAC_C) && !defined(CY_CRYPTO_CFG_AES_C)
180 #error "CY_CRYPTO_CFG_AES_C is not defined to use CMAC calculation"
181 #endif /* defined(CY_CRYPTO_CFG_CMAC_C) && !defined(CY_CRYPTO_CFG_AES_C) */
182 
183 /* Check GCM configuration */
184 #if defined(CY_CRYPTO_CFG_GCM_C) && !defined(CY_CRYPTO_CFG_AES_C)
185 #error "CY_CRYPTO_CFG_AES_C is not defined to use GCM calculation"
186 #endif /* defined(CY_CRYPTO_CFG_GCM_C) && !defined(CY_CRYPTO_CFG_AES_C) */
187 
188 /* Check SHA configuration */
189 #if (defined(CY_CRYPTO_CFG_SHA1_ENABLED) || \
190      defined(CY_CRYPTO_CFG_SHA2_256_ENABLED) || \
191      defined(CY_CRYPTO_CFG_SHA2_512_ENABLED)) \
192      && !defined(CY_CRYPTO_CFG_SHA_C)
193 #error "CY_CRYPTO_CFG_SHA_C is not defined to use SHA digests"
194 #endif
195 
196 #if defined(CY_CRYPTO_CFG_SHA_C) && (!defined(CY_CRYPTO_CFG_SHA1_ENABLED) && \
197      !defined(CY_CRYPTO_CFG_SHA2_256_ENABLED) && \
198      !defined(CY_CRYPTO_CFG_SHA2_512_ENABLED))
199 #error "CY_CRYPTO_CFG_SHA_C is defined but no SHA mode is selected"
200 #endif
201 
202 
203 /* Check HMAC configuration */
204 #if defined(CY_CRYPTO_CFG_HMAC_C) && !defined(CY_CRYPTO_CFG_SHA_C)
205 #error "CY_CRYPTO_CFG_SHA_C is not defined to use HMAC calculation"
206 #endif /* defined(CY_CRYPTO_CFG_HMAC_C) && !defined(CY_CRYPTO_CFG_SHA_C) */
207 
208 /* Check RSA verify configuration */
209 #if defined(CY_CRYPTO_CFG_RSA_VERIFY_ENABLED) && !defined(CY_CRYPTO_CFG_RSA_C)
210 #error "CY_CRYPTO_CFG_RSA_C is not defined to use RSA verification functionality"
211 #endif
212 
213 #if defined(CY_CRYPTO_CFG_RSA_VERIFY_ENABLED) && !defined(CY_CRYPTO_CFG_SHA_C)
214 #error "CY_CRYPTO_CFG_SHA_C is not defined to use RSA verification functionality"
215 #endif
216 
217 /* Check ECDSA configuration */
218 #if (defined(CY_CRYPTO_CFG_ECDSA_GENKEY_C) || defined(CY_CRYPTO_CFG_ECDSA_SIGN_C) || \
219      defined(CY_CRYPTO_CFG_ECDSA_VERIFY_C)) && !defined(CY_CRYPTO_CFG_ECDSA_C)
220 #error "CY_CRYPTO_CFG_ECDSA_C is not defined to use ECDSA functionalities"
221 #endif
222 
223 #if !(defined(CY_CRYPTO_CFG_ECDSA_GENKEY_C) || defined(CY_CRYPTO_CFG_ECDSA_SIGN_C) || \
224      defined(CY_CRYPTO_CFG_ECDSA_VERIFY_C)) && defined(CY_CRYPTO_CFG_ECDSA_C)
225 #error "CY_CRYPTO_CFG_ECDSA_C is defined but no ECDSA functionality is selected"
226 #endif
227 
228 #if defined(CY_CRYPTO_CFG_ECDSA_C) && !defined(CY_CRYPTO_CFG_ECP_C)
229 #define CY_CRYPTO_CFG_ECP_C
230 #endif /* defined(CY_CRYPTO_CFG_ECDSA_C) && !defined(CY_CRYPTO_CFG_ECP_C) */
231 
232 /* Check ECP configuration */
233 #if !(defined(CY_CRYPTO_CFG_ECP_DP_SECP192R1_ENABLED) || \
234      defined(CY_CRYPTO_CFG_ECP_DP_SECP224R1_ENABLED) || \
235      defined(CY_CRYPTO_CFG_ECP_DP_SECP256R1_ENABLED) || \
236      defined(CY_CRYPTO_CFG_ECP_DP_SECP384R1_ENABLED) || \
237      defined(CY_CRYPTO_CFG_ECP_DP_SECP521R1_ENABLED)) \
238      && defined(CY_CRYPTO_CFG_ECP_C)
239 #error "CY_CRYPTO_CFG_ECP_C is defined but no curve is selected"
240 #endif
241 
242 #if (defined(CY_CRYPTO_CFG_ECP_DP_SECP192R1_ENABLED) || \
243      defined(CY_CRYPTO_CFG_ECP_DP_SECP224R1_ENABLED) || \
244      defined(CY_CRYPTO_CFG_ECP_DP_SECP256R1_ENABLED) || \
245      defined(CY_CRYPTO_CFG_ECP_DP_SECP384R1_ENABLED) || \
246      defined(CY_CRYPTO_CFG_ECP_DP_SECP521R1_ENABLED)) \
247      && !defined(CY_CRYPTO_CFG_ECP_C)
248 #error "CY_CRYPTO_CFG_ECP_C is not defined to use ECP functionality"
249 #endif
250 
251 #if defined(CY_CRYPTO_CFG_CHACHA_ENABLED) && defined(CY_CRYPTO_CFG_HW_V1_ENABLE)
252 #error "CHACHA functionality is not available in HW_V1"
253 #endif
254 
255 CY_MISRA_BLOCK_END('MISRA C-2012 Rule 20.5')
256 
257 #endif /* CY_IP_MXCRYPTO */
258 
259 #endif /* #if !defined(CY_CRYPTO_CONFIG_H) */
260 
261 /* [] END OF FILE */
262