MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxClEls_Kdf.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
41
42
49
56
57#ifndef MCUXCLELS_KDF_H_
58#define MCUXCLELS_KDF_H_
59
60#include <mcuxClConfig.h> // Exported features flags header
61
62
63
64
65
66#include <mcuxClEls_Common.h> // Common functionality
67
68#ifdef __cplusplus
69extern "C" {
70#endif
71
72/**********************************************
73 * CONSTANTS
74 **********************************************/
75
82
83
84#define MCUXCLELS_CKDF_DERIVATIONDATA_SIZE 12u
85#define MCUXCLELS_CKDF_ALGO_SP800108 0x0u
86
87
88
89
90#define MCUXCLELS_HKDF_RFC5869_DERIVATIONDATA_SIZE 32u
91#define MCUXCLELS_HKDF_SP80056C_TARGETKEY_SIZE 32u
92
93#define MCUXCLELS_HKDF_VALUE_RTF_DERIV ((uint32_t) 1u<< 0u)
94#define MCUXCLELS_HKDF_VALUE_MEMORY_DERIV ((uint32_t) 0u<< 0u)
95
96#define MCUXCLELS_HKDF_ALGO_RFC5869 0x0u
97#define MCUXCLELS_HKDF_ALGO_SP80056C 0x1u
98
99#define MCUXCLELS_HKDF_RTF_DERIV 1U
100#define MCUXCLELS_HKDF_SYSTEM_MEMORY_DERIV 0U
101
102#define MCUXCLELS_TLS_DERIVATIONDATA_SIZE ((size_t) 80u)
103#define MCUXCLELS_TLS_RANDOM_SIZE ((size_t) 32u)
104
105#define MCUXCLELS_TLS_INIT 0u
106#define MCUXCLELS_TLS_FINALIZE 1u
107 /* mcuxClEls_Kdf_Define */
111
112/**********************************************
113 * TYPEDEFS
114 **********************************************/
115
122
124typedef union
125{
126 struct
127 {
128 uint32_t value;
129 } word;
130 struct
131 {
132 uint32_t :12;
133 uint32_t ckdf_algo :2;
135 uint32_t :18;
136 } bits;
138
140typedef union
141{
142 struct
143 {
144 uint32_t value;
145 } word;
146 struct
147 {
148 uint32_t rtfdrvdat :1;
149 uint32_t hkdf_algo :1;
152 uint32_t :30;
153 } bits;
155
157typedef union
158{
159 struct
160 {
161 uint32_t value;
162 } word;
163 struct
164 {
165 uint32_t :10;
166 uint32_t mode :1;
169 uint32_t :21;
170 } bits;
172 /* mcuxClEls_Kdf_Types */
176 /* mcuxClEls_Kdf_Macros */
180
181
182/**********************************************
183 * FUNCTIONS
184 **********************************************/
191
192
218 mcuxClEls_KeyIndex_t derivationKeyIdx,
219 mcuxClEls_KeyIndex_t targetKeyIdx,
220 mcuxClEls_KeyProp_t targetKeyProperties,
221 uint8_t const * pDerivationData
222 );
223
246 mcuxClEls_KeyIndex_t derivationKeyIdx,
247 uint8_t * pTagetKey,
248 uint8_t const * pDerivationData,
249 size_t derivationDataLength
250 );
251
252
276 mcuxClEls_KeyIndex_t derivationKeyIdx,
277 mcuxClEls_KeyIndex_t targetKeyIdx,
278 mcuxClEls_KeyProp_t targetKeyProperties,
279 uint8_t const * pDerivationData
280 );
281
282
283
306 uint8_t const * pDerivationData,
307 mcuxClEls_KeyProp_t keyProperties,
309 );
310
341 uint8_t const * pDerivationData,
342 mcuxClEls_KeyProp_t keyProperties,
344 );
345 /* mcuxClEls_Kdf_Functions */
349 /* mcuxClEls_Kdf */
353
354#ifdef __cplusplus
355} /* extern "C" */
356#endif
357
358#endif /* MCUXCLELS_KDF_H_ */
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_Ckdf_Sp800108_Async(mcuxClEls_KeyIndex_t derivationKeyIdx, mcuxClEls_KeyIndex_t targetKeyIdx, mcuxClEls_KeyProp_t targetKeyProperties, uint8_t const *pDerivationData)
Derives a key using the NIST SP 800-108 CMAC-based Extract-and-Expand Key Derivation Function.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_TlsGenerateSessionKeysFromMasterKey_Async(uint8_t const *pDerivationData, mcuxClEls_KeyProp_t keyProperties, mcuxClEls_KeyIndex_t keyIdx)
Generates TLS session keys based on a master key and derivation data, according to the TLS 1....
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Hkdf_Sp80056c_Async(mcuxClEls_KeyIndex_t derivationKeyIdx, uint8_t *pTagetKey, uint8_t const *pDerivationData, size_t derivationDataLength)
Derives a key using the HKDF (HMAC-based key derivation function) according to SP800-56C one-step app...
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Hkdf_Rfc5869_Async(mcuxClEls_HkdfOption_t options, mcuxClEls_KeyIndex_t derivationKeyIdx, mcuxClEls_KeyIndex_t targetKeyIdx, mcuxClEls_KeyProp_t targetKeyProperties, uint8_t const *pDerivationData)
Derives a key using the HKDF (HMAC-based key derivation function) according to RFC5869.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_TlsGenerateMasterKeyFromPreMasterKey_Async(uint8_t const *pDerivationData, mcuxClEls_KeyProp_t keyProperties, mcuxClEls_KeyIndex_t keyIdx)
Generates a TLS master key based on a pre-master key and derivation data, according to the TLS 1....
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
Internal command option bit field for CKDF functions.
Definition mcuxClEls_Kdf.h:125
uint32_t value
Accesses the bit field as a full word; initialize with a combination of constants from MCUXCLELS_HKDF...
Definition mcuxClEls_Kdf.h:128
uint32_t ckdf_algo
Defines which algorithm and mode shall be used.
Definition mcuxClEls_Kdf.h:133
Command option bit field for mcuxClEls_Hkdf_Rfc5869_Async.
Definition mcuxClEls_Kdf.h:141
uint32_t rtfdrvdat
MCUXCLELS_HKDF_SYSTEM_MEMORY_DERIV=use derivation input from system memory, MCUXCLELS_HKDF_RTF_DERIV=...
Definition mcuxClEls_Kdf.h:148
uint32_t value
Accesses the bit field as a full word; initialize with a combination of constants from MCUXCLELS_HKDF...
Definition mcuxClEls_Kdf.h:144
uint32_t hkdf_algo
Defines which algorithm shall be used.
Definition mcuxClEls_Kdf.h:149
Internal command option bit field for mcuxClEls_TlsGenerateMasterKeyFromPreMasterKey_Async,...
Definition mcuxClEls_Kdf.h:158
uint32_t mode
Defines which phase of the key generation is performed.
Definition mcuxClEls_Kdf.h:166
uint32_t value
Accesses the bit field as a full word; initialize with a combination of constants from MCUXCLELS_HKDF...
Definition mcuxClEls_Kdf.h:161
Type for ELS key store key properties.
Definition mcuxClEls_Types.h:246