MCUX CLNS
MCUX Crypto Library Normal Secure
mcuxClEls_KeyManagement.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------*/
2 /* Copyright 2020-2023 NXP */
3 /* */
4 /* NXP Confidential. This software is owned or controlled by NXP and may */
5 /* only be used strictly in accordance with the applicable license terms. */
6 /* By expressly accepting such terms or by downloading, installing, */
7 /* activating and/or otherwise using the software, you are agreeing that */
8 /* you have read, and that you agree to comply with and are bound by, such */
9 /* license terms. If you do not agree to be bound by the applicable license */
10 /* terms, then you may not retain, install, activate or otherwise use the */
11 /* software. */
12 /*--------------------------------------------------------------------------*/
13 
36 #ifndef MCUXCLELS_KEYMANAGEMENT_H_
37 #define MCUXCLELS_KEYMANAGEMENT_H_
38 
39 #include <mcuxClConfig.h> // Exported features flags header
40 #include <mcuxClEls_Common.h> // Common functionality
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**********************************************
47  * CONSTANTS
48  **********************************************/
64 #define MCUXCLELS_KEYIMPORT_VALUE_KFMT_UDF ((uint32_t) 0u<< 6u)
65 #define MCUXCLELS_KEYIMPORT_VALUE_KFMT_RFC3394 ((uint32_t) 1u<< 6u)
66 #define MCUXCLELS_KEYIMPORT_VALUE_KFMT_PUF ((uint32_t) 2u<< 6u)
67 #ifdef MCUXCL_FEATURE_ELS_PUK_INTERNAL
68 #define MCUXCLELS_KEYIMPORT_VALUE_KFMT_PBK ((uint32_t) 3u<< 6u)
69 #endif /* MCUXCL_FEATURE_ELS_PUK_INTERNAL */
70 
82 #define MCUXCLELS_KEYIMPORT_KFMT_UDF (0x00u)
83 #define MCUXCLELS_KEYIMPORT_KFMT_RFC3394 (0x01u)
84 #define MCUXCLELS_KEYIMPORT_KFMT_PUF (0x02u)
85 #ifdef MCUXCL_FEATURE_ELS_PUK_INTERNAL
86 #define MCUXCLELS_KEYIMPORT_KFMT_PBK (0x03u)
87 #endif /* MCUXCL_FEATURE_ELS_PUK_INTERNAL */
88 
89 #ifdef MCUXCL_FEATURE_ELS_PUK_INTERNAL
90 #define MCUXCLELS_KEYIMPORT_REVERSEFETCH_ENABLE (0x01U)
91 #define MCUXCLELS_KEYIMPORT_REVERSEFETCH_DISABLE (0x00U)
92 #endif /* MCUXCL_FEATURE_ELS_PUK_INTERNAL */
93 
94 #define MCUXCLELS_RFC3394_OVERHEAD ((size_t) 16u)
95 
106 #define MCUXCLELS_RFC3394_CONTAINER_SIZE_128 ((size_t) 256u/8u)
107 #define MCUXCLELS_RFC3394_CONTAINER_SIZE_256 ((size_t) 384u/8u)
108 #ifdef MCUXCL_FEATURE_ELS_PUK_INTERNAL
109 #define MCUXCLELS_RFC3394_CONTAINER_SIZE_P256 ((size_t) 640u/8u)
110 #endif /* MCUXCL_FEATURE_ELS_PUK_INTERNAL */
111 
119 /**********************************************
120  * TYPEDEFS
121  **********************************************/
136 typedef union
137 {
138  struct
139  {
140  uint32_t value;
141  } word;
142  struct
143  {
144  uint32_t :4;
145  uint32_t revf :1;
146  uint32_t :1;
147  uint32_t kfmt :2;
148  uint32_t :24;
149  } bits;
151 
156 /**********************************************
157  * FUNCTIONS
158  **********************************************/
186  mcuxClEls_KeyIndex_t keyIdx
187 );
188 
189 
190 
230  uint8_t const * pImportKey,
231  size_t importKeyLength,
232  mcuxClEls_KeyIndex_t wrappingKeyIdx,
233  mcuxClEls_KeyIndex_t targetKeyIdx
234  );
235 
236 #ifdef MCUXCL_FEATURE_ELS_PUK_INTERNAL
237 
260 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_KeyImportPuk_Async)
261 MCUXCLELS_API MCUX_CSSL_FP_PROTECTED_TYPE(mcuxClEls_Status_t) mcuxClEls_KeyImportPuk_Async(
262  uint8_t const * pCertificate,
263  size_t certificateLength,
264  size_t publicKeyOffset,
265  uint8_t const * pSignature,
266  mcuxClEls_KeyIndex_t verifyingKeyIdx,
267  mcuxClEls_KeyProp_t keyProperties,
268  mcuxClEls_KeyIndex_t targetKeyIdx,
269  uint8_t * pOutput
270  );
271 #endif /* MCUXCL_FEATURE_ELS_PUK_INTERNAL */
272 
295  mcuxClEls_KeyIndex_t wrappingKeyIdx,
296  mcuxClEls_KeyIndex_t exportKeyIdx,
297  uint8_t * pOutput
298  );
299 
316  mcuxClEls_KeyIndex_t keyIdx,
317  mcuxClEls_KeyProp_t * pKeyProp
318  );
319 
324 #ifdef __cplusplus
325 } /* extern "C" */
326 #endif
327 
328 #endif /* MCUXCLELS_KEYMANAGEMENT_H_ */
329 
uint32_t kfmt
Defines the key import format, one of MCUXCLELS_KEYIMPORT_KFMT_.
Definition: mcuxClEls_KeyManagement.h:147
uint32_t mcuxClEls_Status_t
Type for ELS driver status codes.
Definition: mcuxClEls_Types.h:211
ELS header for common functionality.
uint32_t revf
This field is managed internally.
Definition: mcuxClEls_KeyManagement.h:145
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_KeyImport_Async(mcuxClEls_KeyImportOption_t options, uint8_t const *pImportKey, size_t importKeyLength, mcuxClEls_KeyIndex_t wrappingKeyIdx, mcuxClEls_KeyIndex_t targetKeyIdx)
Imports a key from external storage to an internal key register.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_GetKeyProperties(mcuxClEls_KeyIndex_t keyIdx, mcuxClEls_KeyProp_t *pKeyProp)
Exports the properties of the keys stored in the ELS internal keystore.
Type for ELS key store key properties.
Definition: mcuxClEls_Types.h:224
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_KeyExport_Async(mcuxClEls_KeyIndex_t wrappingKeyIdx, mcuxClEls_KeyIndex_t exportKeyIdx, uint8_t *pOutput)
Exports a key from an internal key register to external storage, using a wrapping key.
#define MCUX_CSSL_FP_FUNCTION_DECL(...)
Declaration of a flow protected function.
Definition: mcuxCsslFlowProtection.h:125
uint32_t value
Accesses the bit field as a full word; initialize with a combination of constants from MCUXCLELS_KEYI...
Definition: mcuxClEls_KeyManagement.h:140
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_KeyDelete_Async(mcuxClEls_KeyIndex_t keyIdx)
Deletes a key from keystore at the given index.
#define MCUXCLELS_API
Marks a function as a public API function of the mcuxClEls component.
Definition: mcuxClEls_Common.h:47
uint32_t mcuxClEls_KeyIndex_t
Type for ELS keystore indices.
Definition: mcuxClEls_Types.h:221
#define MCUX_CSSL_FP_PROTECTED_TYPE(resultType)
Based on a given base type, builds a return type with flow protection.
Definition: mcuxCsslFlowProtection.h:81
Command option bit field for mcuxClEls_KeyImport_Async.
Definition: mcuxClEls_KeyManagement.h:136