1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef _CC_CRYPTO_X509_DEFS_H 8 #define _CC_CRYPTO_X509_DEFS_H 9 10 #include "stdint.h" 11 12 #define CERTIFICATE_VALIDITY_ENDLESS 0 13 #define CC_X509_CERT_PKG_TOKEN 0x43504B47 14 #define CC_X509_CERT_PKG_VERSION 0x01000000 15 #define CC_X509_MAX_CERT_SIZE 0xFFFF 16 17 /* CC object Id's */ 18 /* all object ID's under CC category */ 19 #define CC_X509_OBJ_ID_DX 0x2 20 /* enable user category */ 21 #define CC_X509_OBJ_ID_ANY 0x14 22 /* MAX NONCE size */ 23 #define CC_X509_MAX_NONCE_SIZE_BYTES 8 24 25 26 #define CC_X509_CERT_ISSUER_NAME "ARM" 27 #define CC_X509_CERT_KEY_CERT "KeyCert" 28 #define CC_X509_CERT_CNT_CERT "CntCert" 29 #define CC_X509_CERT_ENABLER_CERT "EnablerDbg" 30 #define CC_X509_CERT_DEVELOPER_CERT "DeveloperDbg" 31 32 /* certificate type category */ 33 typedef enum { 34 CC_X509_CERT_TYPE_MIN = 0x0, 35 CC_X509_CERT_TYPE_KEY = 0x1, /* 0x1 */ 36 CC_X509_CERT_TYPE_CONTENT, /* 0x2 */ 37 CC_X509_CERT_TYPE_ENABLER_DBG, /* 0x3 */ 38 CC_X509_CERT_TYPE_DEVELOPER_DBG, /* 0x4 */ 39 CC_X509_CERT_TYPE_MAX, 40 CC_X509_CERT_TYPE_RESERVED = 0xFF 41 }CCX509CertType_t; 42 43 44 /* certificate type category */ 45 typedef enum { 46 CC_X509_PKG_TYPE_MIN = 0x0, 47 CC_X509_PKG_TYPE_KEY = 0x1, /* 0x1 */ 48 CC_X509_PKG_TYPE_CONTENT, /* 0x2 */ 49 CC_X509_PKG_TYPE_ENABLER_DBG, /* 0x3 */ 50 CC_X509_PKG_TYPE_DEVELOPER_DBG, /* 0x4 */ 51 CC_X509_PKG_TYPE_MAX, 52 CC_X509_PKG_TYPE_RESERVED = 0xFF 53 }CCX509PkgType_t; 54 55 #ifdef CC_SB_SUPPORT_IOT 56 /* specific certificate extension category */ 57 typedef enum { 58 CC_X509_ID_EXT_NONE = 0, 59 CC_X509_ID_EXT_PROPRIETARY_HEADER, 60 CC_X509_ID_EXT_PUB_KEY_NP, 61 CC_X509_ID_EXT_KEY_CERT_MAIN_VAL, 62 CC_X509_ID_EXT_CONTENT_CERT_MAIN_VAL, 63 CC_X509_ID_EXT_ENABLER_CERT_MAIN_VAL, 64 CC_X509_ID_EXT_DEVELOPER_CERT_MAIN_VAL, 65 CC_X509_ID_EXT_MAX, 66 CC_X509_ID_EXT_RESERVED = 0xFF 67 }CCX509ExtType_t; 68 69 #define CC3X_X509_CERT_EXT_NUMBER 3 70 #else 71 /* specific certificate extension category */ 72 typedef enum { 73 CC_X509_ID_EXT_NONE = 0, /*0x0 */ 74 CC_X509_ID_EXT_NV_COUNTER_ID = 0x1, /*0x1 */ 75 CC_X509_ID_EXT_NV_COUNTER_VAL, /*0x2 */ 76 CC_X509_ID_EXT_PUB_KEY_NP, /*0x3 */ 77 CC_X509_ID_EXT_PUB_KEY_HASH, /*0x4 */ 78 CC_X509_ID_EXT_NUM_OF_SW_IMAGES, /*0x5 */ 79 CC_X509_ID_EXT_SW_IMAGE_NONCE, /*0x6 */ 80 CC_X509_ID_EXT_SW_IMAGE_INFO, /*0x7 */ 81 CC_X509_ID_EXT_SOC_SPECIFIC, /*0x8 */ 82 CC_X509_ID_EXT_SOC_ID, /*0x9 */ 83 CC_X509_ID_EXT_VALID_LCS, /*0xA */ 84 CC_X509_ID_EXT_RMA_MODE, /*0xB */ 85 #ifdef CC_SB_CERT_USER_DATA_EXT 86 CC_X509_ID_EXT_USER_DATA, /*0xC */ 87 #endif 88 CC_X509_ID_EXT_MAX, 89 CC_X509_ID_EXT_RESERVED = 0xFF 90 }CCX509ExtType_t; 91 #endif 92 93 typedef union { 94 struct { 95 uint32_t certOffset:16; 96 uint32_t certSize:16; 97 }certInfoBits; 98 uint32_t certInfoWord; 99 }CCX509CertInfo_t; 100 101 typedef union { 102 struct { 103 uint32_t certType:8; 104 uint32_t imageEnc:8; 105 uint32_t hbkType:8; 106 uint32_t reserved:8; 107 }pkgFlagsBits; 108 uint32_t pkgFlagsWord; 109 }CCX509PkgFlag_t; 110 111 typedef struct { 112 uint32_t pkgToken; 113 uint32_t pkgVer; 114 CCX509PkgFlag_t pkgFlags; 115 CCX509CertInfo_t certInfo; 116 }CCX509PkgHeader_t; 117 118 #endif 119