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;
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;
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;
152  /* mcuxClCss_Kdf_Types */
156  /* mcuxClCss_Kdf_Macros */
160 
161 
162 /**********************************************
163  * FUNCTIONS
164  **********************************************/
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 
226  mcuxClCss_KeyIndex_t derivationKeyIdx,
227  uint8_t * pTagetKey,
228  uint8_t const * pDerivationData,
229  size_t derivationDataLength
230  );
231 
232 
256  mcuxClCss_KeyIndex_t derivationKeyIdx,
257  mcuxClCss_KeyIndex_t targetKeyIdx,
258  mcuxClCss_KeyProp_t targetKeyProperties,
259  uint8_t const * pDerivationData
260  );
261 
262 
263 
286  uint8_t const * pDerivationData,
287  mcuxClCss_KeyProp_t keyProperties,
288  mcuxClCss_KeyIndex_t keyIdx
289  );
290 
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 
#define MCUXCLCSS_API
Marks a function as a public API function of the mcuxClCss component.
Definition: mcuxClCss_Common.h:40
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....
Type for CSS key store key properties.
Definition: mcuxClCss_Types.h:196
uint8_t mcuxClCss_KeyIndex_t
Type for CSS keystore indices.
Definition: mcuxClCss_Types.h:193
uint32_t ckdf_algo
Defines which algorithm and mode shall be used.
Definition: mcuxClCss_Kdf.h:113
CSSv2 header for common functionality.
Command option bit field for mcuxClCss_Hkdf_Rfc5869_Async.
Definition: mcuxClCss_Kdf.h:120
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_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_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.
uint32_t mode
Defines which phase of the key generation is performed.
Definition: mcuxClCss_Kdf.h:146
Internal command option bit field for CKDF functions.
Definition: mcuxClCss_Kdf.h:104
uint32_t hkdf_algo
Defines which algorithm shall be used.
Definition: mcuxClCss_Kdf.h:129
Internal command option bit field for mcuxClCss_TlsGenerateMasterKeyFromPreMasterKey_Async,...
Definition: mcuxClCss_Kdf.h:137
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...
uint32_t rtfdrvdat
MCUXCLCSS_CKDF_SYSTEM_MEMORY_DERIV=use derivation input from system memory, MCUXCLCSS_CKDF_RTF_DERIV=...
Definition: mcuxClCss_Kdf.h:128
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_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....
#define MCUX_CSSL_FP_FUNCTION_DECL(id)
Declaration of a flow protected function.
Definition: mcuxCsslFlowProtection.h:119
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
uint64_t mcuxClCss_Status_Protected_t
Type for CSS driver protected status codes.
Definition: mcuxClCss_Types.h:183