MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxClEls_KeyManagement.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/* Copyright 2020-2023 NXP */
3/* */
4/* SPDX-License-Identifier: BSD-3-Clause */
5/* */
6/* Redistribution and use in source and binary forms, with or without */
7/* modification, are permitted provided that the following conditions are */
8/* met: */
9/* */
10/* 1. Redistributions of source code must retain the above copyright */
11/* notice, this list of conditions and the following disclaimer. */
12/* */
13/* 2. Redistributions in binary form must reproduce the above copyright */
14/* notice, this list of conditions and the following disclaimer in the */
15/* documentation and/or other materials provided with the distribution. */
16/* */
17/* 3. Neither the name of the copyright holder nor the names of its */
18/* contributors may be used to endorse or promote products derived from */
19/* this software without specific prior written permission. */
20/* */
21/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS */
22/* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
23/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
24/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
25/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
26/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
27/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR */
28/* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
29/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
30/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
31/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
32/*--------------------------------------------------------------------------*/
33
48
55
56#ifndef MCUXCLELS_KEYMANAGEMENT_H_
57#define MCUXCLELS_KEYMANAGEMENT_H_
58
59#include <mcuxClConfig.h> // Exported features flags header
60#include <mcuxClEls_Common.h> // Common functionality
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66/**********************************************
67 * CONSTANTS
68 **********************************************/
75
83
84#define MCUXCLELS_KEYIMPORT_VALUE_KFMT_UDF ((uint32_t) 0u<< 6u)
85#define MCUXCLELS_KEYIMPORT_VALUE_KFMT_RFC3394 ((uint32_t) 1u<< 6u)
86#define MCUXCLELS_KEYIMPORT_VALUE_KFMT_PUF ((uint32_t) 2u<< 6u)
87#ifdef MCUXCL_FEATURE_ELS_PUK_INTERNAL
88#define MCUXCLELS_KEYIMPORT_VALUE_KFMT_PBK ((uint32_t) 3u<< 6u)
89#endif /* MCUXCL_FEATURE_ELS_PUK_INTERNAL */
90
94
102#define MCUXCLELS_KEYIMPORT_KFMT_UDF (0x00u)
103#define MCUXCLELS_KEYIMPORT_KFMT_RFC3394 (0x01u)
104#define MCUXCLELS_KEYIMPORT_KFMT_PUF (0x02u)
105#ifdef MCUXCL_FEATURE_ELS_PUK_INTERNAL
106#define MCUXCLELS_KEYIMPORT_KFMT_PBK (0x03u)
107#endif /* MCUXCL_FEATURE_ELS_PUK_INTERNAL */
108
109#ifdef MCUXCL_FEATURE_ELS_PUK_INTERNAL
110#define MCUXCLELS_KEYIMPORT_REVERSEFETCH_ENABLE (0x01U)
111#define MCUXCLELS_KEYIMPORT_REVERSEFETCH_DISABLE (0x00U)
112#endif /* MCUXCL_FEATURE_ELS_PUK_INTERNAL */
113
114#define MCUXCLELS_RFC3394_OVERHEAD ((size_t) 16u)
118
126#define MCUXCLELS_RFC3394_CONTAINER_SIZE_128 ((size_t) 256u/8u)
127#define MCUXCLELS_RFC3394_CONTAINER_SIZE_256 ((size_t) 384u/8u)
128#ifdef MCUXCL_FEATURE_ELS_PUK_INTERNAL
129#define MCUXCLELS_RFC3394_CONTAINER_SIZE_P256 ((size_t) 640u/8u)
130#endif /* MCUXCL_FEATURE_ELS_PUK_INTERNAL */
134
138
139/**********************************************
140 * TYPEDEFS
141 **********************************************/
148
156typedef union
157{
158 struct
159 {
160 uint32_t value;
161 } word;
162 struct
163 {
164 uint32_t :4;
165 uint32_t revf :1;
166 uint32_t :1;
167 uint32_t kfmt :2;
168 uint32_t :24;
169 } bits;
171
175
176/**********************************************
177 * FUNCTIONS
178 **********************************************/
185
207);
208
209
210
250 uint8_t const * pImportKey,
251 size_t importKeyLength,
252 mcuxClEls_KeyIndex_t wrappingKeyIdx,
253 mcuxClEls_KeyIndex_t targetKeyIdx
254 );
255
256#ifdef MCUXCL_FEATURE_ELS_PUK_INTERNAL
280MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_KeyImportPuk_Async)
282 uint8_t const * pCertificate,
283 size_t certificateLength,
284 size_t publicKeyOffset,
285 uint8_t const * pSignature,
286 mcuxClEls_KeyIndex_t verifyingKeyIdx,
287 mcuxClEls_KeyProp_t keyProperties,
288 mcuxClEls_KeyIndex_t targetKeyIdx,
289 uint8_t * pOutput
290 );
291#endif /* MCUXCL_FEATURE_ELS_PUK_INTERNAL */
292
315 mcuxClEls_KeyIndex_t wrappingKeyIdx,
316 mcuxClEls_KeyIndex_t exportKeyIdx,
317 uint8_t * pOutput
318 );
319
337 mcuxClEls_KeyProp_t * pKeyProp
338 );
339
343
344#ifdef __cplusplus
345} /* extern "C" */
346#endif
347
348#endif /* MCUXCLELS_KEYMANAGEMENT_H_ */
349
ELS header for common functionality.
#define MCUXCLELS_API
Marks a function as a public API function of the mcuxClEls component.
Definition mcuxClEls_Common.h:66
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_KeyDelete_Async(mcuxClEls_KeyIndex_t keyIdx)
Deletes a key from keystore at the given index.
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.
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.
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.
uint32_t mcuxClEls_Status_t
Type for ELS driver status codes.
Definition mcuxClEls_Types.h:232
uint32_t mcuxClEls_KeyIndex_t
Type for ELS keystore indices.
Definition mcuxClEls_Types.h:242
#define MCUX_CSSL_FP_FUNCTION_DECL(...)
Declaration of a flow protected function.
Definition mcuxCsslFlowProtection.h:145
#define MCUX_CSSL_FP_PROTECTED_TYPE(resultType)
Based on a given base type, builds a return type with flow protection.
Definition mcuxCsslFlowProtection.h:101
Command option bit field for mcuxClEls_KeyImport_Async.
Definition mcuxClEls_KeyManagement.h:157
uint32_t revf
This field is managed internally.
Definition mcuxClEls_KeyManagement.h:165
uint32_t value
Accesses the bit field as a full word; initialize with a combination of constants from MCUXCLELS_KEYI...
Definition mcuxClEls_KeyManagement.h:160
uint32_t kfmt
Defines the key import format, one of MCUXCLELS_KEYIMPORT_KFMT_.
Definition mcuxClEls_KeyManagement.h:167
Type for ELS key store key properties.
Definition mcuxClEls_Types.h:246