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