1 /*
2  * Copyright 2018-2021 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 #ifndef FSL_SSS_CONFIG_ELEMU_H
8 #define FSL_SSS_CONFIG_ELEMU_H
9 
10 #include <stdint.h>
11 
12 #define SSS_SESSION_MAX_CONTEXT_SIZE      (16)
13 #define SSS_KEY_STORE_MAX_CONTEXT_SIZE    (16 + 80)
14 #define SSS_KEY_OBJECT_MAX_CONTEXT_SIZE   (16)
15 #define SSS_SYMMETRIC_MAX_CONTEXT_SIZE    (16 + 80)
16 #define SSS_AEAD_MAX_CONTEXT_SIZE         (16)
17 #define SSS_DIGEST_MAX_CONTEXT_SIZE       (16 + 80)
18 #define SSS_MAC_MAX_CONTEXT_SIZE          (16 + 16)
19 #define SSS_ASYMMETRIC_MAX_CONTEXT_SIZE   (16)
20 #define SSS_TUNNEL_MAX_CONTEXT_SIZE       (16)
21 #define SSS_DERIVE_KEY_MAX_CONTEXT_SIZE   (16)
22 #define SSS_RNG_MAX_CONTEXT_SIZE          (16)
23 #define SSS_PH_CLSHA_CTX_MAX_CONTEXT_SIZE (216)
24 
25 #define SSS_TYPE_ENUM_ALT
26 typedef uint32_t sss_type_t;
27 #define kType_SSS_Software      ((sss_type_t)0x00u)
28 #define kType_SSS_SECO          ((sss_type_t)0x01u)
29 #define kType_SSS_Ele200        ((sss_type_t)0x02u)
30 #define kType_SSS_Ele300        ((sss_type_t)0x03u)
31 #define kType_SSS_Ele400        ((sss_type_t)0x04u)
32 #define kType_SSS_Ele500        ((sss_type_t)0x05u)
33 #define kType_SSS_SecureElement ((sss_type_t)0x06u)
34 
35 #define SSS_MODE_ENUM_ALT
36 typedef uint32_t sss_mode_t;
37 #define kMode_SSS_Encrypt             ((sss_mode_t)0x00u)
38 #define kMode_SSS_Decrypt             ((sss_mode_t)0x01u)
39 #define kMode_SSS_Sign                ((sss_mode_t)0x02u)
40 #define kMode_SSS_Verify              ((sss_mode_t)0x03u)
41 #define kMode_SSS_ComputeSharedSecret ((sss_mode_t)0x04u)
42 #define kMode_SSS_Digest              ((sss_mode_t)0x05u)
43 #define kMode_SSS_Mac                 ((sss_mode_t)0x06u)
44 #if (defined(KW47) && KW47)
45 #define kMode_SSS_SymmetricKDF ((sss_mode_t)0x07u)
46 #else
47 #define kMode_SSS_SymmetricKDF ((sss_mode_t)0x04u)
48 #endif /* KW47 */
49 
50 #define SSS_ALGORITHM_ENUM_ALT
51 typedef uint32_t sss_algorithm_t;
52 /* AES */
53 #define kAlgorithm_SSS_AES_ECB ((sss_algorithm_t)0x00u)
54 #define kAlgorithm_SSS_AES_CBC ((sss_algorithm_t)0x01u)
55 #define kAlgorithm_SSS_AES_CTR ((sss_algorithm_t)0x02u)
56 #define kAlgorithm_SSS_AES_GCM ((sss_algorithm_t)0x03u)
57 #define kAlgorithm_SSS_AES_CCM ((sss_algorithm_t)0x04u)
58 /* CHACHA_POLY */
59 #define kAlgorithm_SSS_CHACHA_POLY ((sss_algorithm_t)0x05u)
60 /* DES3 */
61 #define kAlgorithm_SSS_DES3_ECB ((sss_algorithm_t)0x06u)
62 #define kAlgorithm_SSS_DES3_CBC ((sss_algorithm_t)0x07u)
63 /* digest */
64 #define kAlgorithm_SSS_SHA1   ((sss_algorithm_t)0x08u)
65 #define kAlgorithm_SSS_SHA224 ((sss_algorithm_t)0x09u)
66 #define kAlgorithm_SSS_SHA256 ((sss_algorithm_t)0x0au)
67 #define kAlgorithm_SSS_SHA384 ((sss_algorithm_t)0x0bu)
68 #define kAlgorithm_SSS_SHA512 ((sss_algorithm_t)0x0cu)
69 /* MAC */
70 #define kAlgorithm_SSS_CMAC_AES    ((sss_algorithm_t)0x0du)
71 #define kAlgorithm_SSS_HMAC_SHA256 ((sss_algorithm_t)0x0eu)
72 /* Diffie-Helmann */
73 #define kAlgorithm_SSS_DH   ((sss_algorithm_t)0x0fu)
74 #define kAlgorithm_SSS_ECDH ((sss_algorithm_t)0x10u)
75 #define kAlgorithm_MONTDH   ((sss_algorithm_t)0x30u)
76 /* DSA */
77 #define kAlgorithm_SSS_DSA_SHA1   ((sss_algorithm_t)0x11u)
78 #define kAlgorithm_SSS_DSA_SHA224 ((sss_algorithm_t)0x12u)
79 #define kAlgorithm_SSS_DSA_SHA256 ((sss_algorithm_t)0x13u)
80 /* RSA */
81 #define kAlgorithm_SSS_RSASSA_PKCS1_V1_5_SHA1       ((sss_algorithm_t)0x14u)
82 #define kAlgorithm_SSS_RSASSA_PKCS1_V1_5_SHA224     ((sss_algorithm_t)0x15u)
83 #define kAlgorithm_SSS_RSASSA_PKCS1_V1_5_SHA256     ((sss_algorithm_t)0x16u)
84 #define kAlgorithm_SSS_RSASSA_PKCS1_V1_5_SHA384     ((sss_algorithm_t)0x17u)
85 #define kAlgorithm_SSS_RSASSA_PKCS1_V1_5_SHA512     ((sss_algorithm_t)0x18u)
86 #define kAlgorithm_SSS_RSASSA_PKCS1_PSS_MGF1_SHA1   ((sss_algorithm_t)0x19u)
87 #define kAlgorithm_SSS_RSASSA_PKCS1_PSS_MGF1_SHA224 ((sss_algorithm_t)0x1au)
88 #define kAlgorithm_SSS_RSASSA_PKCS1_PSS_MGF1_SHA256 ((sss_algorithm_t)0x1bu)
89 #define kAlgorithm_SSS_RSASSA_PKCS1_PSS_MGF1_SHA384 ((sss_algorithm_t)0x1cu)
90 #define kAlgorithm_SSS_RSASSA_PKCS1_PSS_MGF1_SHA512 ((sss_algorithm_t)0x1du)
91 /* ECDSA */
92 #define kAlgorithm_SSS_ECDSA_SHA1   ((sss_algorithm_t)0x1eu)
93 #define kAlgorithm_SSS_ECDSA_SHA224 ((sss_algorithm_t)0x1fu)
94 #define kAlgorithm_SSS_ECDSA_SHA256 ((sss_algorithm_t)0x20u)
95 #define kAlgorithm_SSS_ECDSA_SHA384 ((sss_algorithm_t)0x21u)
96 #define kAlgorithm_SSS_ECDSA_SHA512 ((sss_algorithm_t)0x22u)
97 /* KDF */
98 #define kAlgorithm_SSS_E2E_BLOB ((sss_algorithm_t)0x40u)
99 #define kAlgorithm_SSS_BLE_F5   ((sss_algorithm_t)0x50u)
100 
101 #define SAB_KEY_TYPE_SYMMETRIC  (0x00)
102 #define SAB_KEY_TYPE_ASYMMETRIC (0x01)
103 #define SSS_KEY_CIPHER_TYPE_ENUM_ALT
104 typedef uint32_t sss_cipher_type_t;
105 #define kSSS_CipherType_NONE      ((sss_cipher_type_t)0x10u)
106 #define kSSS_CipherType_AES       ((sss_cipher_type_t)0x10u)
107 #define kSSS_CipherType_DES       ((sss_cipher_type_t)0x10u)
108 #define kSSS_CipherType_CMAC      ((sss_cipher_type_t)0x10u)
109 #define kSSS_CipherType_HMAC      ((sss_cipher_type_t)0x10u)
110 #define kSSS_CipherType_MAC       ((sss_cipher_type_t)0x10u)
111 #define kSSS_CipherType_SYMMETRIC ((sss_cipher_type_t)0x10u)
112 #define kSSS_CipherType_RSA       ((sss_cipher_type_t)0x1u) /*! RSA RAW format      */
113 #define kSSS_CipherType_RSA_CRT   ((sss_cipher_type_t)0x1u) /*! RSA CRT format      */
114 /* The following keys can be identified
115  * solely by the *Family* and bit length */
116 #define kSSS_CipherType_EC_NIST_P ((sss_cipher_type_t)0x40u) /*! Keys Part of NIST-P Family */
117 #define kSSS_CipherType_EC_NIST_K ((sss_cipher_type_t)0x1u)  /*! Keys Part of NIST-K Family */
118 /* The following keys need their full curve parameters (p,a,b,x,y,n,h) */
119 /*! Montgomery Key,   */
120 #define kSSS_CipherType_EC_MONTGOMERY ((sss_cipher_type_t)0x50u)
121 /*! twisted Edwards form elliptic curve public key */
122 #define kSSS_CipherType_EC_TWISTED_ED ((sss_cipher_type_t)0x51u)
123 /*! Brainpool form elliptic curve public key */
124 #define kSSS_CipherType_EC_BRAINPOOL ((sss_cipher_type_t)0x1u)
125 /*! Barreto Naehrig curve */
126 #define kSSS_CipherType_EC_BARRETO_NAEHRIG ((sss_cipher_type_t)0x1u)
127 #define kSSS_CipherType_UserID             ((sss_cipher_type_t)0x1u)
128 #define kSSS_CipherType_Certificate        ((sss_cipher_type_t)0x1u)
129 #define kSSS_CipherType_Binary             ((sss_cipher_type_t)0x1u)
130 #define kSSS_CipherType_Count              ((sss_cipher_type_t)0x1u)
131 #define kSSS_CipherType_PCR                ((sss_cipher_type_t)0x1u)
132 #define kSSS_CipherType_ReservedPin        ((sss_cipher_type_t)0x1u)
133 
134 #define SSS_STATUS_ENUM_ALT
135 typedef uint32_t sss_status_t;
136 /** Operation was successful */
137 #define kStatus_SSS_Success ((sss_status_t)0x5a5a5a5au)
138 /** Operation failed */
139 #define kStatus_SSS_Fail ((sss_status_t)0x3c3c0000u)
140 /** Operation not performed because some of the passed parameters
141  * were found inappropriate */
142 #define kStatus_SSS_InvalidArgument ((sss_status_t)0x3c3c0001u)
143 /** Where the underlying sub-system *supports* multi-threading,
144  * Internal status to handle simultaneous access.
145  *
146  * This status is not expected to be returned to higher layers.
147  * */
148 #define kStatus_SSS_ResourceBusy ((sss_status_t)0x3c3c0002u)
149 
150 #define SSS_KEY_PART_ENUM_ALT
151 typedef uint32_t sss_key_part_t;
152 /** Part of a key */
153 #define kSSS_KeyPart_NONE ((sss_key_part_t)0x0u)
154 /** Applicable where we have UserID, PIN, Binary Files,
155  * Certificates, Symmetric Keys, PCR */
156 #define kSSS_KeyPart_Default ((sss_key_part_t)0x1u)
157 /** Public part of asymmetric key */
158 #define kSSS_KeyPart_Public ((sss_key_part_t)0x2u)
159 /** Private only part of asymmetric key */
160 #define kSSS_KeyPart_Private ((sss_key_part_t)0x3u)
161 /** Both, public and private part of asymmetric key */
162 #define kSSS_KeyPart_Pair ((sss_key_part_t)0x4u)
163 
164 typedef uint32_t sss_mgmt_security_level_t;
165 #define kSSS_mgmt_security_lvl_NON_SECURE            ((sss_mgmt_security_level_t)0x0u)
166 #define kSSS_mgmt_security_lvl_NON_SECURE_PRIVILEGED ((sss_mgmt_security_level_t)0x1u)
167 #define kSSS_mgmt_security_lvl_SECURE                ((sss_mgmt_security_level_t)0x2u)
168 #define kSSS_mgmt_security_lvl_SECURE_PRIVILEGED     ((sss_mgmt_security_level_t)0x3u)
169 
170 typedef uint32_t sss_sscp_key_store_property_t;
171 #define kSSS_key_store_prop_totalAllocatedMemory    ((sss_sscp_key_store_property_t)0x0u)
172 #define kSSS_key_store_prop_availableMemory         ((sss_sscp_key_store_property_t)0x1u)
173 #define kSSS_key_store_prop_totalNumberOfKeyObjects ((sss_sscp_key_store_property_t)0x2u)
174 #define kSSS_key_store_prop_availableKeyObjects     ((sss_sscp_key_store_property_t)0x3u)
175 
176 typedef uint32_t sss_sscp_key_property_t;
177 #define kSSS_KeyProp_Locked                    ((sss_sscp_key_property_t)0x80000000u)
178 #define kSSS_KeyProp_SecAccess_NS_USER         ((sss_sscp_key_property_t)0x00000000u)
179 #define kSSS_KeyProp_SecAccess_NS_PRIV         ((sss_sscp_key_property_t)0x20000000u)
180 #define kSSS_KeyProp_SecAccess_S_USER          ((sss_sscp_key_property_t)0x40000000u)
181 #define kSSS_KeyProp_SecAccess_S_PRIV          ((sss_sscp_key_property_t)0x60000000u)
182 #define kSSS_KeyProp_TrustedKey                ((sss_sscp_key_property_t)0x10000000u)
183 #define kSSS_KeyProp_NoImportExport            ((sss_sscp_key_property_t)0x00010000u)
184 #define kSSS_KeyProp_NoPlainRead               ((sss_sscp_key_property_t)0x00008000u)
185 #define kSSS_KeyProp_NoPlainWrite              ((sss_sscp_key_property_t)0x00004000u)
186 #define kSSS_KeyProp_NoVerify                  ((sss_sscp_key_property_t)0x00002000u)
187 #define kSSS_KeyProp_NoSign                    ((sss_sscp_key_property_t)0x00001000u)
188 #define kSSS_KeyProp_CryptoAlgo_KDF            ((sss_sscp_key_property_t)0x00000010u)
189 #define kSSS_KeyProp_CryptoAlgo_AsymSignVerify ((sss_sscp_key_property_t)0x00000008u)
190 #define kSSS_KeyProp_CryptoAlgo_AEAD           ((sss_sscp_key_property_t)0x00000004u)
191 #define kSSS_KeyProp_CryptoAlgo_MAC            ((sss_sscp_key_property_t)0x00000002u)
192 #define kSSS_KeyProp_CryptoAlgo_AES            ((sss_sscp_key_property_t)0x00000001u)
193 
194 typedef uint32_t sss_sscp_keyObjFree_options_t;
195 #define kSSS_keyObjFree_KeysStoreNoDefragment ((sss_sscp_keyObjFree_options_t)0x0u)
196 #define kSSS_keyObjFree_KeysStoreDefragment   ((sss_sscp_keyObjFree_options_t)0x1u)
197 
198 typedef uint32_t sss_sscp_blob_type_t;
199 #define kSSS_blobType_ELKE_blob     ((sss_sscp_blob_type_t)0x1u)
200 #define kSSS_blobType_E2E_blob      ((sss_sscp_blob_type_t)0x2u)
201 #define kSSS_blobType_NBU_ESK_blob  ((sss_sscp_blob_type_t)0x3u)
202 #define kSSS_blobType_NBU_EIRK_blob ((sss_sscp_blob_type_t)0x4u)
203 
204 typedef uint32_t sss_internal_keyID_t;
205 #define kSSS_internalKey_NPX          ((sss_internal_keyID_t)0x80000007u)
206 #define kSSS_internalKey_NBU_DKEY_SK  ((sss_internal_keyID_t)0x80000009u)
207 #define kSSS_internalKey_NBU_DKEY_IRK ((sss_internal_keyID_t)0x8000000Au)
208 
209 #endif /* FSL_SSS_CONFIG_H */
210