MCUX CLNS MCUX Crypto Library Normal Secure |

mcuxClCss_Kdf.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------*/
2 /* Copyright 2020-2021 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
19
49 #ifndef MCUXCLCSS_KDF_H_
50 #define MCUXCLCSS_KDF_H_
51
52 #include <mcuxClCss_Common.h> // Common functionality
53
54 /**********************************************
55 * CONSTANTS
56 **********************************************/
57
65 #define MCUXCLCSS_HKDF_VALUE_RTF_DERIV ((uint32_t) 1u<< 0u)
66 #define MCUXCLCSS_HKDF_VALUE_MEMORY_DERIV ((uint32_t) 0u<< 0u)
67
68 #define MCUXCLCSS_CKDF_RTF_DERIV 1U
69 #define MCUXCLCSS_CKDF_SYSTEM_MEMORY_DERIV 0U
70
71 #define MCUXCLCSS_CKDF_DERIVATIONDATA_SIZE 12u
72
73 #define MCUXCLCSS_CKDF_ALGO_SP800108 0x0u
74
75 #define MCUXCLCSS_HKDF_RFC5869_DERIVATIONDATA_SIZE 32u
76 #define MCUXCLCSS_HKDF_SP80056C_TARGETKEY_SIZE 32u
77
78 #define MCUXCLCSS_HKDF_ALGO_RFC5869 0x0u
79 #define MCUXCLCSS_HKDF_ALGO_SP80056C 0x1u
80
81
82 #define MCUXCLCSS_TLS_DERIVATIONDATA_SIZE ((size_t) 80u)
83 #define MCUXCLCSS_TLS_RANDOM_SIZE ((size_t) 32u)
84
85 #define MCUXCLCSS_TLS_INIT 0u
86 #define MCUXCLCSS_TLS_FINALIZE 1u
87
88 /* MCUXCLCSS_KDF_DEFINE */
91
92 /**********************************************
93 * TYPEDEFS
94 **********************************************/
95
104 typedef union
105 {
106 struct
107 {
108 uint32_t value;
109 } word;
110 struct
111 {
112 uint32_t :12;
113 uint32_t ckdf_algo :2;
114 uint32_t :18;
116 } bits;
117 } mcuxClCss_CkdfOption_t;
118
120 typedef union
121 {
122 struct
123 {
124 uint32_t value;
125 } word;
126 struct
127 {
128 uint32_t rtfdrvdat :1;
129 uint32_t hkdf_algo :1;
130 uint32_t :30;
133 } bits;
134 } mcuxClCss_HkdfOption_t;
135
137 typedef union
138 {
139 struct
140 {
141 uint32_t value;
142 } word;
143 struct
144 {
145 uint32_t :10;
146 uint32_t mode :1;
147 uint32_t :21;
150 } bits;
151 } mcuxClCss_TlsOption_t;
152 /* mcuxClCss_Kdf_Types */
156 /* mcuxClCss_Kdf_Macros */
160
161
162 /**********************************************
163 * FUNCTIONS
164 **********************************************/
195 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_Hkdf_Rfc5869_Async)
196 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Hkdf_Rfc5869_Async(
197 mcuxClCss_HkdfOption_t options,
198 mcuxClCss_KeyIndex_t derivationKeyIdx,
199 mcuxClCss_KeyIndex_t targetKeyIdx,
200 mcuxClCss_KeyProp_t targetKeyProperties,
201 uint8_t const * pDerivationData
202 );
203
224 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_Hkdf_Sp80056c_Async)
225 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Hkdf_Sp80056c_Async(
226 mcuxClCss_KeyIndex_t derivationKeyIdx,
227 uint8_t * pTagetKey,
228 uint8_t const * pDerivationData,
229 size_t derivationDataLength
230 );
231
232
254 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_Ckdf_Sp800108_Async)
255 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Ckdf_Sp800108_Async(
256 mcuxClCss_KeyIndex_t derivationKeyIdx,
257 mcuxClCss_KeyIndex_t targetKeyIdx,
258 mcuxClCss_KeyProp_t targetKeyProperties,
259 uint8_t const * pDerivationData
260 );
261
262
263
284 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_TlsGenerateMasterKeyFromPreMasterKey_Async)
285 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_TlsGenerateMasterKeyFromPreMasterKey_Async(
286 uint8_t const * pDerivationData,
287 mcuxClCss_KeyProp_t keyProperties,
288 mcuxClCss_KeyIndex_t keyIdx
289 );
290
319 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_TlsGenerateSessionKeysFromMasterKey_Async)
320 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_TlsGenerateSessionKeysFromMasterKey_Async(
321 uint8_t const * pDerivationData,
322 mcuxClCss_KeyProp_t keyProperties,
323 mcuxClCss_KeyIndex_t keyIdx
324 );
325 /* mcuxClCss_Kdf_Functions */
329 /* mcuxClCss_Kdf */
333
334 #endif /* MCUXCLCSS_KDF_H_ */
335
MCUXCLCSS_API
#define MCUXCLCSS_API
Marks a function as a public API function of the mcuxClCss component.
Definition: mcuxClCss_Common.h:40
mcuxClCss_TlsGenerateSessionKeysFromMasterKey_Async
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_TlsGenerateSessionKeysFromMasterKey_Async(uint8_t const *pDerivationData, mcuxClCss_KeyProp_t keyProperties, mcuxClCss_KeyIndex_t keyIdx)
Generates TLS session keys based on a master key and derivation data, according to the TLS 1....
mcuxClCss_KeyProp_t
Type for CSS key store key properties.
Definition: mcuxClCss_Types.h:196
mcuxClCss_KeyIndex_t
uint8_t mcuxClCss_KeyIndex_t
Type for CSS keystore indices.
Definition: mcuxClCss_Types.h:193
mcuxClCss_CkdfOption_t::ckdf_algo
uint32_t ckdf_algo
Defines which algorithm and mode shall be used.
Definition: mcuxClCss_Kdf.h:113
mcuxClCss_Common.h
CSSv2 header for common functionality.
mcuxClCss_HkdfOption_t
Command option bit field for mcuxClCss_Hkdf_Rfc5869_Async.
Definition: mcuxClCss_Kdf.h:120
mcuxClCss_HkdfOption_t::value
uint32_t value
Accesses the bit field as a full word; initialize with a combination of constants from MCUXCLCSS_HKDF...
Definition: mcuxClCss_Kdf.h:124
mcuxClCss_Ckdf_Sp800108_Async
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Ckdf_Sp800108_Async(mcuxClCss_KeyIndex_t derivationKeyIdx, mcuxClCss_KeyIndex_t targetKeyIdx, mcuxClCss_KeyProp_t targetKeyProperties, uint8_t const *pDerivationData)
Derives a key using the NIST SP 800-108 CMAC-based Extract-and-Expand Key Derivation Function.
mcuxClCss_Hkdf_Rfc5869_Async
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Hkdf_Rfc5869_Async(mcuxClCss_HkdfOption_t options, mcuxClCss_KeyIndex_t derivationKeyIdx, mcuxClCss_KeyIndex_t targetKeyIdx, mcuxClCss_KeyProp_t targetKeyProperties, uint8_t const *pDerivationData)
Derives a key using the HKDF (HMAC-based key derivation function) according to RFC5869.
mcuxClCss_TlsOption_t::mode
uint32_t mode
Defines which phase of the key generation is performed.
Definition: mcuxClCss_Kdf.h:146
mcuxClCss_CkdfOption_t
Internal command option bit field for CKDF functions.
Definition: mcuxClCss_Kdf.h:104
mcuxClCss_HkdfOption_t::hkdf_algo
uint32_t hkdf_algo
Defines which algorithm shall be used.
Definition: mcuxClCss_Kdf.h:129
mcuxClCss_TlsOption_t
Internal command option bit field for mcuxClCss_TlsGenerateMasterKeyFromPreMasterKey_Async,...
Definition: mcuxClCss_Kdf.h:137
mcuxClCss_Hkdf_Sp80056c_Async
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Hkdf_Sp80056c_Async(mcuxClCss_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...
mcuxClCss_HkdfOption_t::rtfdrvdat
uint32_t rtfdrvdat
MCUXCLCSS_CKDF_SYSTEM_MEMORY_DERIV=use derivation input from system memory, MCUXCLCSS_CKDF_RTF_DERIV=...
Definition: mcuxClCss_Kdf.h:128
mcuxClCss_TlsOption_t::value
uint32_t value
Accesses the bit field as a full word; initialize with a combination of constants from MCUXCLCSS_HKDF...
Definition: mcuxClCss_Kdf.h:141
mcuxClCss_TlsGenerateMasterKeyFromPreMasterKey_Async
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_TlsGenerateMasterKeyFromPreMasterKey_Async(uint8_t const *pDerivationData, mcuxClCss_KeyProp_t keyProperties, mcuxClCss_KeyIndex_t keyIdx)
Generates a TLS master key based on a pre-master key and derivation data, according to the TLS 1....
MCUX_CSSL_FP_FUNCTION_DECL
#define MCUX_CSSL_FP_FUNCTION_DECL(id)
Declaration of a flow protected function.
Definition: mcuxCsslFlowProtection.h:119
mcuxClCss_CkdfOption_t::value
uint32_t value
Accesses the bit field as a full word; initialize with a combination of constants from MCUXCLCSS_HKDF...
Definition: mcuxClCss_Kdf.h:108
mcuxClCss_Status_Protected_t
uint64_t mcuxClCss_Status_Protected_t
Type for CSS driver protected status codes.
Definition: mcuxClCss_Types.h:183