MCUX CLNS MCUX Crypto Library Normal Secure |

mcuxClCss_Ecc.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
26 #ifndef MCUXCLCSS_ECC_H_
27 #define MCUXCLCSS_ECC_H_
28
29 #include <mcuxClCss_Common.h> // Common types & functionality
30
31
40 /**********************************************
41 * CONSTANTS
42 **********************************************/
56 #define MCUXCLCSS_ECC_VALUE_HASHED ((uint32_t) 0u<< 0u)
57 #define MCUXCLCSS_ECC_VALUE_NOT_HASHED ((uint32_t) 1u<< 0u)
58 #define MCUXCLCSS_ECC_VALUE_RTF ((uint32_t) 1u<< 1u)
59 #define MCUXCLCSS_ECC_VALUE_NO_RTF ((uint32_t) 0u<< 1u)
60
70 #define MCUXCLCSS_KEYGEN_VALUE_SIGN_PUBLICKEY ((uint32_t) 1u<< 0u)
71 #define MCUXCLCSS_KEYGEN_VALUE_TYPE_SIGN ((uint32_t) 0u<< 1u)
72 #define MCUXCLCSS_KEYGEN_VALUE_TYPE_KEYEXCHANGE ((uint32_t) 1u<< 1u)
73 #define MCUXCLCSS_KEYGEN_VALUE_DETERMINISTIC ((uint32_t) 0u<< 2u)
74 #define MCUXCLCSS_KEYGEN_VALUE_RANDOM ((uint32_t) 1u<< 2u)
75 #define NXFCLCSS_KEYGEN_VALUE_GEN_PUB_KEY ((uint32_t) 0u<< 3u)
76 #define NXFCLCSS_KEYGEN_VALUE_NO_PUB_KEY ((uint32_t) 1u<< 3u)
77 #define MCUXCLCSS_KEYGEN_VALUE_NO_RANDOM_DATA ((uint32_t) 0u<< 5u)
78 #define MCUXCLCSS_KEYGEN_VALUE_USE_RANDOM_DATA ((uint32_t) 1u<< 5u)
79
89 #define MCUXCLCSS_ECC_HASHED 0U
90 #define MCUXCLCSS_ECC_NOT_HASHED 1U
91
92 #define MCUXCLCSS_ECC_RTF 1U
93 #define MCUXCLCSS_ECC_NO_RTF 0U
94
104 #define MCUXCLCSS_ECC_PUBLICKEY_SIGN_ENABLE 1U
105 #define MCUXCLCSS_ECC_PUBLICKEY_SIGN_DISABLE 0U
106
107 #define MCUXCLCSS_ECC_OUTPUTKEY_SIGN 0U
108 #define MCUXCLCSS_ECC_OUTPUTKEY_KEYEXCHANGE 1U
109
110 #define MCUXCLCSS_ECC_OUTPUTKEY_DETERMINISTIC 0U
111 #define MCUXCLCSS_ECC_OUTPUTKEY_RANDOM 1U
112
113 #define MCUXCLCSS_ECC_GEN_PUBLIC_KEY 0U
114 #define MCUXCLCSS_ECC_SKIP_PUBLIC_KEY 1U
115
117 #define MCUXCLCSS_ECC_NO_RANDOM_DATA 0U
118 #define MCUXCLCSS_ECC_INCLUDE_RANDOM_DATA 1U
119
130 #define MCUXCLCSS_ECC_PUBLICKEY_SIZE ((size_t) 64U)
131 #define MCUXCLCSS_ECC_SIGNATURE_SIZE ((size_t) 64U)
132 #define MCUXCLCSS_ECC_SIGNATURE_R_SIZE ((size_t) 32U)
133 /* mcuxClCss_Ecc_Macros */
140
141
142 /**********************************************
143 * TYPEDEFS
144 **********************************************/
156 typedef uint8_t mcuxClCss_EccByte_t;
157
162 typedef union
163 {
164 struct
165 {
166 uint32_t value;
167 } word;
168 struct
169 {
170 uint32_t echashchl :1;
171 uint32_t signrtf :1;
172 uint32_t :2;
173 uint32_t revf :1;
174 uint32_t :27;
175 } bits;
176 } mcuxClCss_EccSignOption_t;
177
182 typedef union
183 {
184 struct
185 {
186 uint32_t value;
187 } word;
188 struct
189 {
190 uint32_t echashchl :1;
191 uint32_t :3;
192 uint32_t revf :1;
193 uint32_t :27;
194 } bits;
195 } mcuxClCss_EccVerifyOption_t;
196
201 typedef union
202 {
203 struct
204 {
205 uint32_t value;
206 } word;
207 struct
208 {
209 uint32_t kgsign :1;
210 uint32_t kgtypedh :1;
211 uint32_t kgsrc :1;
212 uint32_t skip_pbk :1;
213 uint32_t revf :1;
214 uint32_t kgsign_rnd :1;
215 uint32_t :26;
216 } bits;
217 } mcuxClCss_EccKeyGenOption_t;
218 /* mcuxClCss_Ecc_Types */
222
223
224 /**********************************************
225 * FUNCTIONS
226 **********************************************/
272 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_EccKeyGen_Async)
273 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_EccKeyGen_Async(
274 mcuxClCss_EccKeyGenOption_t options,
275 mcuxClCss_KeyIndex_t signingKeyIdx,
276 mcuxClCss_KeyIndex_t privateKeyIdx,
277 mcuxClCss_KeyProp_t generatedKeyProperties,
278 uint8_t const * pRandomData,
279 uint8_t * pPublicKey
280 );
281
313 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_EccKeyExchange_Async)
314 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_EccKeyExchange_Async(
315 mcuxClCss_KeyIndex_t privateKeyIdx,
316 uint8_t const * pPublicKey,
317 mcuxClCss_KeyIndex_t sharedSecretIdx,
318 mcuxClCss_KeyProp_t sharedSecretProperties
319 );
320
321
366 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_EccSign_Async)
367 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_EccSign_Async(
368 mcuxClCss_EccSignOption_t options,
369 mcuxClCss_KeyIndex_t keyIdx,
370 uint8_t const * pInputHash,
371 uint8_t const * pInputMessage,
372 size_t inputMessageLength,
373 uint8_t * pOutput
374 );
375
428 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_EccVerify_Async)
429 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_EccVerify_Async(
430 mcuxClCss_EccVerifyOption_t options,
431 uint8_t const * pInputHash,
432 uint8_t const * pInputMessage,
433 size_t inputMessageLength,
434 uint8_t const * pSignatureAndPubKey,
435 uint8_t * pOutput
436 );
437
438 /* mcuxClCss_Ecc_Functions */
442
443 /* mcuxClCss_Ecc */
447
448 #endif /* MCUXCLCSS_ECC_H_ */
mcuxClCss_EccKeyGenOption_t::kgsign_rnd
uint32_t kgsign_rnd
Define if using user provided random data for the signature.
Definition: mcuxClCss_Ecc.h:214
MCUXCLCSS_API
#define MCUXCLCSS_API
Marks a function as a public API function of the mcuxClCss component.
Definition: mcuxClCss_Common.h:40
mcuxClCss_KeyProp_t
Type for CSS key store key properties.
Definition: mcuxClCss_Types.h:196
mcuxClCss_EccVerifyOption_t::echashchl
uint32_t echashchl
Define type of input, plain message or hash of message.
Definition: mcuxClCss_Ecc.h:190
mcuxClCss_KeyIndex_t
uint8_t mcuxClCss_KeyIndex_t
Type for CSS keystore indices.
Definition: mcuxClCss_Types.h:193
mcuxClCss_EccSignOption_t::revf
uint32_t revf
This field is managed internally.
Definition: mcuxClCss_Ecc.h:173
mcuxClCss_EccKeyExchange_Async
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_EccKeyExchange_Async(mcuxClCss_KeyIndex_t privateKeyIdx, uint8_t const *pPublicKey, mcuxClCss_KeyIndex_t sharedSecretIdx, mcuxClCss_KeyProp_t sharedSecretProperties)
Performs a Diffie-Hellman key exchange with an internal ECC private key and an external ECC public ke...
mcuxClCss_Common.h
CSSv2 header for common functionality.
mcuxClCss_EccKeyGenOption_t
Command option bit field for mcuxClCss_EccKeyGen_Async Bit field to configure mcuxClCss_EccKeyGenOpti...
Definition: mcuxClCss_Ecc.h:201
mcuxClCss_EccSignOption_t::value
uint32_t value
Access the bit field as a full word; initialize with a combination of constants from MCUXCLCSS_ECC (S...
Definition: mcuxClCss_Ecc.h:166
mcuxClCss_EccKeyGenOption_t::kgtypedh
uint32_t kgtypedh
Define the usage of the output key.
Definition: mcuxClCss_Ecc.h:210
mcuxClCss_EccKeyGen_Async
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_EccKeyGen_Async(mcuxClCss_EccKeyGenOption_t options, mcuxClCss_KeyIndex_t signingKeyIdx, mcuxClCss_KeyIndex_t privateKeyIdx, mcuxClCss_KeyProp_t generatedKeyProperties, uint8_t const *pRandomData, uint8_t *pPublicKey)
Generates an ECC key pair on the NIST P-256 curve.
mcuxClCss_EccKeyGenOption_t::skip_pbk
uint32_t skip_pbk
Define if generating a public key.
Definition: mcuxClCss_Ecc.h:212
mcuxClCss_EccKeyGenOption_t::value
uint32_t value
Accesses the bit field as a full word; initialize with a combination of constants from MCUXCLCSS_KEYG...
Definition: mcuxClCss_Ecc.h:205
mcuxClCss_EccByte_t
uint8_t mcuxClCss_EccByte_t
Data type for ECC parameters in CSS format.
Definition: mcuxClCss_Ecc.h:156
mcuxClCss_EccKeyGenOption_t::kgsrc
uint32_t kgsrc
Define if the output key is deterministic or random.
Definition: mcuxClCss_Ecc.h:211
mcuxClCss_EccVerifyOption_t::value
uint32_t value
Access the bit field as a full word; initialize with a combination of constants from MCUXCLCSS_ECC (S...
Definition: mcuxClCss_Ecc.h:186
mcuxClCss_EccVerify_Async
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_EccVerify_Async(mcuxClCss_EccVerifyOption_t options, uint8_t const *pInputHash, uint8_t const *pInputMessage, size_t inputMessageLength, uint8_t const *pSignatureAndPubKey, uint8_t *pOutput)
Verifies an ECDSA signature of a given message.
mcuxClCss_EccKeyGenOption_t::kgsign
uint32_t kgsign
Define if signing the output public key.
Definition: mcuxClCss_Ecc.h:209
mcuxClCss_EccVerifyOption_t
Command option bit field for mcuxClCss_EccVerify_Async Bit field to configure mcuxClCss_EccVerifyOpti...
Definition: mcuxClCss_Ecc.h:182
mcuxClCss_EccKeyGenOption_t::revf
uint32_t revf
This field is managed internally.
Definition: mcuxClCss_Ecc.h:213
mcuxClCss_EccVerifyOption_t::revf
uint32_t revf
This field is managed internally.
Definition: mcuxClCss_Ecc.h:192
mcuxClCss_EccSignOption_t::signrtf
uint32_t signrtf
Define if signing the Run-Time Fingerprint.
Definition: mcuxClCss_Ecc.h:171
mcuxClCss_EccSignOption_t
Command option bit field for mcuxClCss_EccSign_Async Bit field to configure mcuxClCss_EccSign_Async.
Definition: mcuxClCss_Ecc.h:162
mcuxClCss_EccSignOption_t::echashchl
uint32_t echashchl
Define type of input, plain message or hash of message.
Definition: mcuxClCss_Ecc.h:170
mcuxClCss_EccSign_Async
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_EccSign_Async(mcuxClCss_EccSignOption_t options, mcuxClCss_KeyIndex_t keyIdx, uint8_t const *pInputHash, uint8_t const *pInputMessage, size_t inputMessageLength, uint8_t *pOutput)
Generates an ECDSA signature of a given message.
MCUX_CSSL_FP_FUNCTION_DECL
#define MCUX_CSSL_FP_FUNCTION_DECL(id)
Declaration of a flow protected function.
Definition: mcuxCsslFlowProtection.h:119
mcuxClCss_Status_Protected_t
uint64_t mcuxClCss_Status_Protected_t
Type for CSS driver protected status codes.
Definition: mcuxClCss_Types.h:183