MCUX CLNS
MCUX Crypto Library Normal Secure
mcuxClEcc_Types.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------*/
2 /* Copyright 2020-2023 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 
20 #ifndef MCUXCLECC_TYPES_H_
21 #define MCUXCLECC_TYPES_H_
22 
23 
24 #include <stdint.h>
25 #include <mcuxClConfig.h> // Exported features flags header
26 #include <mcuxCsslFlowProtection.h>
28 #include <mcuxCsslAnalysis.h>
29 
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /**********************************************************/
36 /* Return codes of mcuxClEcc */
37 /**********************************************************/
48 typedef uint32_t mcuxClEcc_Status_t;
49 
54 
55 
60 #define MCUXCLECC_STATUS_OK ((mcuxClEcc_Status_t) 0x04442E03u)
61 #define MCUXCLECC_STATUS_INVALID_PARAMS ((mcuxClEcc_Status_t) 0x044453F8u)
62 #define MCUXCLECC_STATUS_RNG_ERROR ((mcuxClEcc_Status_t) 0x04445334u)
63 #define MCUXCLECC_STATUS_INVALID_SIGNATURE ((mcuxClEcc_Status_t) 0x04448930u)
64 #define MCUXCLECC_STATUS_NEUTRAL_POINT ((mcuxClEcc_Status_t) 0x04448934u)
65 #define MCUXCLECC_STATUS_FAULT_ATTACK ((mcuxClEcc_Status_t) 0x0444F0F0u)
66 #define MCUXCLECC_STATUS_NOT_SUPPORTED ((mcuxClEcc_Status_t) 0x04445370u)
67 
73 #define MCUXCLECC_STATUS_ERROR_SMALL_SUBGROUP ((mcuxClEcc_Status_t) 0x04445374u)
74  /* MCUXCLECC_MONTDH_STATUS_ */
75  /* mcuxClEcc_Macros */
78 
79 
80 /**********************************************************/
81 /* Parameter structure of mcuxClEcc APIs */
82 /**********************************************************/
92 typedef struct mcuxClEcc_MontDH_DomainParams mcuxClEcc_MontDH_DomainParams_t;
93 
94 
96 typedef struct mcuxClEcc_EdDSA_DomainParams mcuxClEcc_EdDSA_DomainParams_t;
97 
101 struct mcuxClEcc_EdDSA_GenerateKeyPairDescriptor;
102 
106 typedef struct mcuxClEcc_EdDSA_GenerateKeyPairDescriptor mcuxClEcc_EdDSA_GenerateKeyPairDescriptor_t;
107 
111 struct mcuxClEcc_EdDSA_SignatureProtocolDescriptor;
112 
116 typedef struct mcuxClEcc_EdDSA_SignatureProtocolDescriptor mcuxClEcc_EdDSA_SignatureProtocolDescriptor_t;
117 
118 
120 typedef struct mcuxClEcc_Weier_DomainParams mcuxClEcc_Weier_DomainParams_t;
121 
127 typedef struct
128 {
129  const uint8_t *pA;
130  const uint8_t *pB;
131  const uint8_t *pP;
132  const uint8_t *pG;
134  const uint8_t *pN;
136  uint32_t misc;
142 
144 #define mcuxClEcc_DomainParam_misc_Pack(byteLenN, byteLenP) MCUXCLPKC_PACKARGS4(0u, 0u, (uint8_t) byteLenN, (uint8_t) byteLenP)
145 #define mcuxClEcc_DomainParam_misc_byteLenP_offset 0
146 #define mcuxClEcc_DomainParam_misc_byteLenP_mask ((uint32_t) 0x000000FFu)
147 #define mcuxClEcc_DomainParam_misc_byteLenN_offset 8
148 #define mcuxClEcc_DomainParam_misc_byteLenN_mask ((uint32_t) 0x0000FF00u)
149 
150 
152 typedef struct
153 {
155  uint8_t * pPrivateKey;
156  uint8_t * pPublicKey;
158  uint32_t optLen;
162 
164 typedef struct
165 {
167  const uint8_t * pHash;
168  const uint8_t * pPrivateKey;
169  uint8_t * pSignature;
170  uint32_t optLen;
176 
178 #define mcuxClEcc_Sign_Param_optLen_Pack(byteLenHash) ((uint32_t) (byteLenHash) & 0xFFu)
179 #define mcuxClEcc_Sign_Param_optLen_byteLenHash_offset 0
180 #define mcuxClEcc_Sign_Param_optLen_byteLenHash_mask ((uint32_t) 0x000000FFu)
181 
182 
183 typedef struct
184 {
186  const uint8_t * pPrecG;
187  const uint8_t * pHash;
189  const uint8_t * pSignature;
190  const uint8_t * pPublicKey;
192  uint8_t * pOutputR;
193  uint32_t optLen;
198 
200 #define mcuxClEcc_Verify_Param_optLen_Pack(byteLenHash) ((uint32_t) (byteLenHash) & 0xFFu)
201 #define mcuxClEcc_Verify_Param_optLen_byteLenHash_offset 0
202 #define mcuxClEcc_Verify_Param_optLen_byteLenHash_mask ((uint32_t) 0x000000FFu)
203 
204 
205 typedef struct
206 {
208  const uint8_t * pScalar;
209  const uint8_t * pPoint;
210  uint8_t * pResult;
211  uint32_t optLen;
213 } mcuxClEcc_PointMult_Param_t; /* mcuxClEcc_Types */
218 
219 /**********************************************************/
220 /* Descriptors of mcuxClEcc APIs */
221 /**********************************************************/
229 /**********************************************************/
230 /* Key pair generation descriptors */
231 /**********************************************************/
232 
233 /* EdDSA key pair generation descriptor to be used when the private key shall be generated by the
234  * EdDSA key pair generation function */
235 extern const mcuxClEcc_EdDSA_GenerateKeyPairDescriptor_t mcuxClEcc_EdDsa_GeneratePrivKeyDescriptor;
236 
237 
238 /**********************************************************/
239 /* Signature ProtocolDescriptors and ModeDescriptors */
240 /**********************************************************/
241 
252 
253 
254 
255  /* mcuxClEcc_Descriptors */
259 
260 #ifdef __cplusplus
261 } /* extern "C" */
262 #endif
263 
264 #endif /* MCUXCLECC_TYPES_H_ */
Parameter structure for function mcuxClEcc_PointMult.
Definition: mcuxClEcc_Types.h:205
Parameter structure of elliptic curve of the form, y^2 = x^3 + a*x + b modulo prime p.
Definition: mcuxClEcc_Types.h:127
uint8_t * pPrivateKey
[out] pointer to memory area, where the private key will be exported if KeyGen is executed successful...
Definition: mcuxClEcc_Types.h:155
Parameter structure for function mcuxClEcc_Verify.
Definition: mcuxClEcc_Types.h:183
struct mcuxClEcc_Weier_DomainParams mcuxClEcc_Weier_DomainParams_t
Type for Weierstrass ECC domain parameters.
Definition: mcuxClEcc_Types.h:120
struct mcuxClEcc_MontDH_DomainParams mcuxClEcc_MontDH_DomainParams_t
Type for MontDH domain parameters.
Definition: mcuxClEcc_Types.h:92
const uint8_t * pA
[in] pointer to octet string of curve parameter a (< p), of which the length is byteLenP.
Definition: mcuxClEcc_Types.h:129
const uint8_t * pScalar
[in] pointer to octet string of scalar d, which is of the same format as base point order n.
Definition: mcuxClEcc_Types.h:208
struct mcuxClEcc_EdDSA_SignatureProtocolDescriptor mcuxClEcc_EdDSA_SignatureProtocolDescriptor_t
EdDSA SignatureProtocol variant descriptor type.
Definition: mcuxClEcc_Types.h:116
const uint8_t * pPrivateKey
[in] pointer to octet string of private key, which is of the same format as base point order n.
Definition: mcuxClEcc_Types.h:168
mcuxClEcc_Status_t mcuxClEcc_Status_Protected_t
Deprecated type for mcuxClEcc component return codes.
Definition: mcuxClEcc_Types.h:53
mcuxClEcc_DomainParam_t curveParam
[in] structure of pointers to curve parameters and length of parameters.
Definition: mcuxClEcc_Types.h:154
struct mcuxClEcc_EdDSA_DomainParams mcuxClEcc_EdDSA_DomainParams_t
Type for EdDSA domain parameters.
Definition: mcuxClEcc_Types.h:96
const uint8_t * pPoint
[in] pointer to octet string of EC point Q, which is of the same format as base point G.
Definition: mcuxClEcc_Types.h:209
uint32_t mcuxClEcc_Status_t
Type for mcuxClEcc component return codes.
Definition: mcuxClEcc_Types.h:48
Parameter structure for function mcuxClEcc_Sign.
Definition: mcuxClEcc_Types.h:164
mcuxClEcc_DomainParam_t curveParam
[in] structure of pointers to curve parameters and length of parameters.
Definition: mcuxClEcc_Types.h:185
const mcuxClEcc_EdDSA_SignatureProtocolDescriptor_t mcuxClEcc_EdDsa_Ed25519ProtocolDescriptor
Ed25519 signature protocol descriptor.
const uint8_t * pP
[in] pointer to octet string of prime modulus p, of which the length is byteLenP.
Definition: mcuxClEcc_Types.h:131
Parameter structure for function mcuxClEcc_KeyGen.
Definition: mcuxClEcc_Types.h:152
uint8_t * pOutputR
[out] pointer to memory area in which signature R calculated by verify function will be exported if s...
Definition: mcuxClEcc_Types.h:192
struct mcuxClEcc_EdDSA_GenerateKeyPairDescriptor mcuxClEcc_EdDSA_GenerateKeyPairDescriptor_t
EdDSA GenerateKeyPair variant descriptor type.
Definition: mcuxClEcc_Types.h:106
const uint8_t * pPrecG
[in] pointer to octet string of pre-computed point of base point G, which is of the same format as ba...
Definition: mcuxClEcc_Types.h:186
const uint8_t * pB
[in] pointer to octet string of curve parameter b (< p), of which the length is byteLenP.
Definition: mcuxClEcc_Types.h:130
const uint8_t * pSignature
[in] pointer to octet string of signature R and S.
Definition: mcuxClEcc_Types.h:189
Definitions of ECC domain parameter, key and signature sizes.
Provides the API for the CSSL flow protection mechanism.
mcuxClEcc_DomainParam_t curveParam
[in] structure of pointers to curve parameters and length of parameters.
Definition: mcuxClEcc_Types.h:166
uint8_t * pSignature
[out] pointer to memory area in which signature R and S will be exported if signature is generated su...
Definition: mcuxClEcc_Types.h:169
const uint8_t * pHash
[in] pointer to string of message digest (hash), of which the length is byteLenHash (in optLen).
Definition: mcuxClEcc_Types.h:167
uint8_t * pResult
[out] pointer to memory area, where the result R = dQ will be exported if PointMult is executed succe...
Definition: mcuxClEcc_Types.h:210
#define MCUX_CSSL_FP_PROTECTED_TYPE(resultType)
Based on a given base type, builds a return type with flow protection.
Definition: mcuxCsslFlowProtection.h:81
mcuxClEcc_DomainParam_t curveParam
[in] structure of pointers to curve parameters and length of parameters.
Definition: mcuxClEcc_Types.h:207