1 /*
2  * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef COT_DEF_H
8 #define COT_DEF_H
9 
10 #ifdef MBEDTLS_CONFIG_FILE
11 #include MBEDTLS_CONFIG_FILE
12 #endif
13 
14 /* TBBR CoT definitions */
15 #if defined(SPD_spmd)
16 #define COT_MAX_VERIFIED_PARAMS		8
17 #else
18 #define COT_MAX_VERIFIED_PARAMS		4
19 #endif
20 
21 /*
22  * Maximum key and hash sizes (in DER format).
23  *
24  * Both RSA and ECDSA keys may be used at the same time. In this case, the key
25  * buffers must be big enough to hold either. As RSA keys are bigger than ECDSA
26  * ones for all key sizes we support, they impose the minimum size of these
27  * buffers.
28  */
29 #if TF_MBEDTLS_USE_RSA
30 #if TF_MBEDTLS_KEY_SIZE == 1024
31 #define PK_DER_LEN                      162
32 #elif TF_MBEDTLS_KEY_SIZE == 2048
33 #define PK_DER_LEN                      294
34 #elif TF_MBEDTLS_KEY_SIZE == 3072
35 #define PK_DER_LEN                      422
36 #elif TF_MBEDTLS_KEY_SIZE == 4096
37 #define PK_DER_LEN                      550
38 #else
39 #error "Invalid value for TF_MBEDTLS_KEY_SIZE"
40 #endif
41 #else /* Only using ECDSA keys. */
42 #define PK_DER_LEN                      91
43 #endif
44 
45 #if TF_MBEDTLS_HASH_ALG_ID == TF_MBEDTLS_SHA256
46 #define HASH_DER_LEN                    51
47 #elif TF_MBEDTLS_HASH_ALG_ID == TF_MBEDTLS_SHA384
48 #define HASH_DER_LEN                    67
49 #elif TF_MBEDTLS_HASH_ALG_ID == TF_MBEDTLS_SHA512
50 #define HASH_DER_LEN                    83
51 #else
52 #error "Invalid value for TF_MBEDTLS_HASH_ALG_ID"
53 #endif
54 
55 #endif /* COT_DEF_H */
56