1dff93c86SJuan Castillo /* 2c1ec23ddSlaurenw-arm * Copyright (c) 2015-2023, 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 10a9edc32cSGovindraj Raja /* 11a9edc32cSGovindraj Raja * Guard here with availability of mbedtls config since PLAT=lx2162aqds 12a9edc32cSGovindraj Raja * uses custom tbbr from 'drivers/nxp/auth/tbbr/tbbr_cot.c' and also may 13a9edc32cSGovindraj Raja * build without mbedtls folder only with TRUSTED_BOOT enabled. 14a9edc32cSGovindraj Raja */ 15a9edc32cSGovindraj Raja #ifdef MBEDTLS_CONFIG_FILE 16a8eadc51SGovindraj Raja #include <mbedtls/version.h> 17a9edc32cSGovindraj Raja #endif 18ff67fca5SPankaj Gupta 19dff93c86SJuan Castillo /* TBBR CoT definitions */ 2044f1aa8eSManish Pandey #if defined(SPD_spmd) 2144f1aa8eSManish Pandey #define COT_MAX_VERIFIED_PARAMS 8 2256b741d3Slaurenw-arm #elif defined(ARM_COT_cca) 2356b741d3Slaurenw-arm #define COT_MAX_VERIFIED_PARAMS 8 2444f1aa8eSManish Pandey #else 25dff93c86SJuan Castillo #define COT_MAX_VERIFIED_PARAMS 4 2644f1aa8eSManish Pandey #endif 27dff93c86SJuan Castillo 28ad43c49eSManish V Badarkhe /* 29ad43c49eSManish V Badarkhe * Maximum key and hash sizes (in DER format). 30ad43c49eSManish V Badarkhe * 31ad43c49eSManish V Badarkhe * Both RSA and ECDSA keys may be used at the same time. In this case, the key 32ad43c49eSManish V Badarkhe * buffers must be big enough to hold either. As RSA keys are bigger than ECDSA 33ad43c49eSManish V Badarkhe * ones for all key sizes we support, they impose the minimum size of these 34ad43c49eSManish V Badarkhe * buffers. 35*81c2e156SManish V Badarkhe * 36*81c2e156SManish V Badarkhe * If the platform employs its own mbedTLS configuration, it is the platform's 37*81c2e156SManish V Badarkhe * responsibility to define TF_MBEDTLS_USE_RSA or TF_MBEDTLS_USE_ECDSA to 38*81c2e156SManish V Badarkhe * establish the appropriate PK_DER_LEN size. 39ad43c49eSManish V Badarkhe */ 40*81c2e156SManish V Badarkhe #ifdef MBEDTLS_CONFIG_FILE 41ad43c49eSManish V Badarkhe #if TF_MBEDTLS_USE_RSA 42ad43c49eSManish V Badarkhe #if TF_MBEDTLS_KEY_SIZE == 1024 43ad43c49eSManish V Badarkhe #define PK_DER_LEN 162 44ad43c49eSManish V Badarkhe #elif TF_MBEDTLS_KEY_SIZE == 2048 45ad43c49eSManish V Badarkhe #define PK_DER_LEN 294 46ad43c49eSManish V Badarkhe #elif TF_MBEDTLS_KEY_SIZE == 3072 47ad43c49eSManish V Badarkhe #define PK_DER_LEN 422 48ad43c49eSManish V Badarkhe #elif TF_MBEDTLS_KEY_SIZE == 4096 49ad43c49eSManish V Badarkhe #define PK_DER_LEN 550 50ad43c49eSManish V Badarkhe #else 51ad43c49eSManish V Badarkhe #error "Invalid value for TF_MBEDTLS_KEY_SIZE" 52ad43c49eSManish V Badarkhe #endif 532ea42fecSManish V Badarkhe #elif TF_MBEDTLS_USE_ECDSA 54c1ec23ddSlaurenw-arm #if TF_MBEDTLS_KEY_SIZE == 384 55c1ec23ddSlaurenw-arm #define PK_DER_LEN 120 56c1ec23ddSlaurenw-arm #elif TF_MBEDTLS_KEY_SIZE == 256 571ef303f9SNicolas Toromanoff #define PK_DER_LEN 92 58c1ec23ddSlaurenw-arm #else 59c1ec23ddSlaurenw-arm #error "Invalid value for TF_MBEDTLS_KEY_SIZE" 60c1ec23ddSlaurenw-arm #endif 612ea42fecSManish V Badarkhe #else 622ea42fecSManish V Badarkhe #error "Invalid value of algorithm" 632ea42fecSManish V Badarkhe #endif /* TF_MBEDTLS_USE_RSA */ 64ad43c49eSManish V Badarkhe 65ad43c49eSManish V Badarkhe #if TF_MBEDTLS_HASH_ALG_ID == TF_MBEDTLS_SHA256 66ad43c49eSManish V Badarkhe #define HASH_DER_LEN 51 67ad43c49eSManish V Badarkhe #elif TF_MBEDTLS_HASH_ALG_ID == TF_MBEDTLS_SHA384 68ad43c49eSManish V Badarkhe #define HASH_DER_LEN 67 69ad43c49eSManish V Badarkhe #elif TF_MBEDTLS_HASH_ALG_ID == TF_MBEDTLS_SHA512 70ad43c49eSManish V Badarkhe #define HASH_DER_LEN 83 71ad43c49eSManish V Badarkhe #else 72ad43c49eSManish V Badarkhe #error "Invalid value for TF_MBEDTLS_HASH_ALG_ID" 73ad43c49eSManish V Badarkhe #endif 74*81c2e156SManish V Badarkhe #endif /* MBEDTLS_CONFIG_FILE */ 75ad43c49eSManish V Badarkhe 76c3cf06f1SAntonio Nino Diaz #endif /* COT_DEF_H */ 77