MCUX CLNS
MCUX Crypto Library Normal Secure
mcuxClEcc_Types.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 
20 #ifndef MCUXCLECC_TYPES_H_
21 #define MCUXCLECC_TYPES_H_
22 
23 
24 #include <stdint.h>
25 
26 
27 /**********************************************************/
28 /* Return codes of mcuxClEcc */
29 /**********************************************************/
38 typedef uint32_t mcuxClEcc_Status_t;
39 
42 
45 
49 #define MCUXCLECC_STATUS_OK ((mcuxClEcc_Status_t) 0x55555555u)
50 #define MCUXCLECC_STATUS_KEYGEN_OK ((mcuxClEcc_Status_t) 0x55553CC3u)
51 #define MCUXCLECC_STATUS_KEYGEN_INVALID_PARAMS ((mcuxClEcc_Status_t) 0x55551DE2u)
52 #define MCUXCLECC_STATUS_KEYGEN_RNG_ERROR ((mcuxClEcc_Status_t) 0x555527D8u)
53 #define MCUXCLECC_STATUS_SIGN_OK ((mcuxClEcc_Status_t) 0x55555AA5u)
54 #define MCUXCLECC_STATUS_SIGN_INVALID_PARAMS ((mcuxClEcc_Status_t) 0x55551EE1u)
55 #define MCUXCLECC_STATUS_SIGN_RNG_ERROR ((mcuxClEcc_Status_t) 0x55552DD2u)
56 #if 0
57 #define MCUXCLECC_STATUS_CALCPP_OK ((mcuxClEcc_Status_t) 0x555539C6u)
58 #define MCUXCLECC_STATUS_CALCPP_INVALID_PARAMS ((mcuxClEcc_Status_t) 0x55551BE4u)
59 #endif
60 #define MCUXCLECC_STATUS_VERIFY_OK ((mcuxClEcc_Status_t) 0x55556996u)
61 #define MCUXCLECC_STATUS_VERIFY_NOT_OK ((mcuxClEcc_Status_t) 0x555517E8u)
62 #define MCUXCLECC_STATUS_VERIFY_INVALID_PARAMS ((mcuxClEcc_Status_t) 0x55552BD4u)
63 #define MCUXCLECC_STATUS_POINTMULT_OK ((mcuxClEcc_Status_t) 0x55553AC5u)
64 #define MCUXCLECC_STATUS_POINTMULT_INVALID_PARAMS ((mcuxClEcc_Status_t) 0x55554BB4u)
65 #define MCUXCLECC_STATUS_POINTMULT_NEUTRAL_POINT ((mcuxClEcc_Status_t) 0x55558778u)
66 #define MCUXCLECC_STATUS_POINTMULT_RNG_ERROR ((mcuxClEcc_Status_t) 0x55552ED1u)
67 #define MCUXCLECC_STATUS_FAULT_ATTACK ((mcuxClEcc_Status_t) 0x5555F00Fu)
68 
73 #define MCUXCLECC_STATUS_MONT_DHKEYGENERATION_OK ((mcuxClEcc_Status_t) 0x555533CCu)
74 
75 #define MCUXCLECC_STATUS_MONT_DHKEYAGREEMENT_OK ((mcuxClEcc_Status_t) 0x555535CAu)
76 #define MCUXCLECC_STATUS_MONT_DHKEYAGREEMENT_ERROR_SMALL_SUBGROUP ((mcuxClEcc_Status_t) 0x55554DB2u)
77 #define MCUXCLECC_STATUS_MONT_RNG_ERROR ((mcuxClEcc_Status_t) 0x55551BE4u)
78 
79 
84 #define MCUXCLECC_MONT_CURVE25519_SIZE_PRIVATEKEY (32u)
85 #define MCUXCLECC_MONT_CURVE25519_SIZE_PUBLICKEY (32u)
86 #define MCUXCLECC_MONT_CURVE25519_SIZE_SHAREDSECRET (32u)
87 #define MCUXCLECC_MONT_CURVE25519_SIZE_PRIMEP (32u)
88 #define MCUXCLECC_MONT_CURVE25519_SIZE_BASEPOINTORDER (32u)
89  /* mcuxClEcc_Macros */
94 
95 
96 /**********************************************************/
97 /* Parameter structure of mcuxClEcc APIs */
98 /**********************************************************/
111 typedef struct
112 {
113  const uint8_t *pA;
114  const uint8_t *pB;
115  const uint8_t *pP;
116  const uint8_t *pG;
118  const uint8_t *pN;
120  uint32_t misc;
126 
128 #define mcuxClEcc_DomainParam_misc_Pack(byteLenN, byteLenP) MCUXCLPKC_PACKARGS4(0u, 0u, (uint8_t) byteLenN, (uint8_t) byteLenP)
129 #define mcuxClEcc_DomainParam_misc_byteLenP_offset 0
130 #define mcuxClEcc_DomainParam_misc_byteLenP_mask ((uint32_t) 0x000000FFu)
131 #define mcuxClEcc_DomainParam_misc_byteLenN_offset 8
132 #define mcuxClEcc_DomainParam_misc_byteLenN_mask ((uint32_t) 0x0000FF00u)
133 
134 
135 typedef struct
136 {
138  uint8_t * pPrivateKey;
139  uint8_t * pPublicKey;
141  uint32_t optLen;
145 
147 typedef struct
148 {
150  const uint8_t * pHash;
151  const uint8_t * pPrivateKey;
152  uint8_t * pSignature;
153  uint32_t optLen;
159 
161 #define mcuxClEcc_Sign_Param_optLen_Pack(byteLenHash) ((uint32_t) (byteLenHash) & 0xFFu)
162 #define mcuxClEcc_Sign_Param_optLen_byteLenHash_offset 0
163 #define mcuxClEcc_Sign_Param_optLen_byteLenHash_mask ((uint32_t) 0x000000FFu)
164 
165 #if 0
166 
167 typedef struct
168 {
169  mcuxClEcc_DomainParam_t curveParam;
170  uint8_t * pPrecG;
171 } mcuxClEcc_CalcPrecomputedPoint_Param_t;
174 #endif
175 
177 typedef struct
178 {
180  const uint8_t * pPrecG;
181  const uint8_t * pHash;
183  const uint8_t * pSignature;
184  const uint8_t * pPublicKey;
186  uint8_t * pOutputR;
187  uint32_t optLen;
192 
194 #define mcuxClEcc_Verify_Param_optLen_Pack(byteLenHash) ((uint32_t) (byteLenHash) & 0xFFu)
195 #define mcuxClEcc_Verify_Param_optLen_byteLenHash_offset 0
196 #define mcuxClEcc_Verify_Param_optLen_byteLenHash_mask ((uint32_t) 0x000000FFu)
197 
198 
199 typedef struct
200 {
202  const uint8_t * pScalar;
203  const uint8_t * pPoint;
204  uint8_t * pResult;
205  uint32_t optLen;
209  /* mcuxClEcc_Types */
213 
214 
215 #endif /* MCUXCLECC_TYPES_H_ */
Parameter structure for function mcuxClEcc_Sign.
Definition: mcuxClEcc_Types.h:147
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:151
const uint8_t * pSignature
[in] pointer to octet string of signature R and S.
Definition: mcuxClEcc_Types.h:183
Parameter structure for function mcuxClEcc_KeyGen.
Definition: mcuxClEcc_Types.h:135
uint8_t * pPrivateKey
[out] pointer to memory area, where the private key will be exported if KeyGen is executed successful...
Definition: mcuxClEcc_Types.h:138
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:204
const uint8_t * pHash
[in] pointer to string of message digest (hash), of which the length is byteLenHash (in optLen).
Definition: mcuxClEcc_Types.h:150
uint64_t mcuxClEcc_Status_Protected_t
Type for mcuxClEcc component return codes.
Definition: mcuxClEcc_Types.h:41
mcuxClEcc_DomainParam_t curveParam
[in] structure of pointers to curve parameters and length of parameters.
Definition: mcuxClEcc_Types.h:201
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:202
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:203
const uint8_t * pP
[in] pointer to octet string of prime modulus p, of which the length is byteLenP.
Definition: mcuxClEcc_Types.h:115
uint32_t mcuxClEcc_Status_t
Type for mcuxClEcc component return codes.
Definition: mcuxClEcc_Types.h:38
mcuxClEcc_DomainParam_t curveParam
[in] structure of pointers to curve parameters and length of parameters.
Definition: mcuxClEcc_Types.h:179
Parameter structure for function mcuxClEcc_Verify.
Definition: mcuxClEcc_Types.h:177
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:186
struct mcuxClEcc_Mont_DomainParams_t mcuxClEcc_Mont_DomainParams_t
Type for mcuxClEcc Mont domainParameters type.
Definition: mcuxClEcc_Types.h:44
const uint8_t * pB
[in] pointer to octet string of curve parameter b (< p), of which the length is byteLenP.
Definition: mcuxClEcc_Types.h:114
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:180
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:152
mcuxClEcc_DomainParam_t curveParam
[in] structure of pointers to curve parameters and length of parameters.
Definition: mcuxClEcc_Types.h:137
mcuxClEcc_DomainParam_t curveParam
[in] structure of pointers to curve parameters and length of parameters.
Definition: mcuxClEcc_Types.h:149
Parameter structure for function mcuxClEcc_PointMult.
Definition: mcuxClEcc_Types.h:199
const uint8_t * pA
[in] pointer to octet string of curve parameter a (< p), of which the length is byteLenP.
Definition: mcuxClEcc_Types.h:113
Parameter structure of elliptic curve of the form, y^2 = x^3 + a*x + b modulo prime p.
Definition: mcuxClEcc_Types.h:111