Mistake on this page?
Report an issue in GitHub or email us
crys_ecpki_types.h
Go to the documentation of this file.
1 /**************************************************************************************
2 * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved *
3 * *
4 * This file and the related binary are licensed under the following license: *
5 * *
6 * ARM Object Code and Header Files License, v1.0 Redistribution. *
7 * *
8 * Redistribution and use of object code, header files, and documentation, without *
9 * modification, are permitted provided that the following conditions are met: *
10 * *
11 * 1) Redistributions must reproduce the above copyright notice and the *
12 * following disclaimer in the documentation and/or other materials *
13 * provided with the distribution. *
14 * *
15 * 2) Unless to the extent explicitly permitted by law, no reverse *
16 * engineering, decompilation, or disassembly of is permitted. *
17 * *
18 * 3) Redistribution and use is permitted solely for the purpose of *
19 * developing or executing applications that are targeted for use *
20 * on an ARM-based product. *
21 * *
22 * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
23 * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT *
24 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, *
25 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
26 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED *
28 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
30 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
33 **************************************************************************************/
34 
35 
36 
37 #ifndef CRYS_ECPKI_TYPES_H
38 #define CRYS_ECPKI_TYPES_H
39 
40 /*!
41 @file
42 @brief Contains all of the enums and definitions that are used for the CRYS ECPKI APIs.
43 @defgroup crys_ecpki_types CryptoCell ECC specific types
44 @{
45 @ingroup cryptocell_ecpki
46 */
47 
48 #include "ssi_pal_types_plat.h"
49 #include "crys_hash.h"
50 #include "crys_pka_defs_hw.h"
51 #include "ssi_pal_compiler.h"
52 
53 #ifdef __cplusplus
54 extern "C"
55 {
56 #endif
57 
58 
59 /************************ Defines ******************************/
60 /*! Internal buffer size in words. */
61 #define CRYS_PKA_DOMAIN_LLF_BUFF_SIZE_IN_WORDS (10 + 3*CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS)
62 
63 /**************************************************************************************
64  * Enumerators
65  ***************************************************************************************/
66 
67 /*------------------------------------------------------------------*/
68 /*! Enumerator for the EC Domain idetifier
69  References: [13] - SEC 2: Recommended elliptic curve domain parameters.
70  Version 1.0. Certicom 2000.
71  [8] - WAP-261-WTLS-20010406-a, Version 06-April-2001. */
72 
73 typedef enum
74 {
75  /* For prime field */
76  CRYS_ECPKI_DomainID_secp160k1, /*!< EC secp160r1 */
77  CRYS_ECPKI_DomainID_secp160r1, /*!< EC secp160k1 */
78  CRYS_ECPKI_DomainID_secp160r2, /*!< EC secp160r2 */
79  CRYS_ECPKI_DomainID_secp192k1, /*!< EC secp192k1 */
80  CRYS_ECPKI_DomainID_secp192r1, /*!< EC secp192r1 */
81  CRYS_ECPKI_DomainID_secp224k1, /*!< EC secp224k1 */
82  CRYS_ECPKI_DomainID_secp224r1, /*!< EC secp224r1 */
83  CRYS_ECPKI_DomainID_secp256k1, /*!< EC secp256k1 */
84  CRYS_ECPKI_DomainID_secp256r1, /*!< EC secp256r1 */
85  CRYS_ECPKI_DomainID_secp384r1, /*!< EC secp384r1 */
86  CRYS_ECPKI_DomainID_secp521r1, /*!< EC secp521r1 */
87 
88  CRYS_ECPKI_DomainID_Builded, /*!< User given, not identified. */
89  CRYS_ECPKI_DomainID_OffMode, /*!< Reserved.*/
90 
91  CRYS_ECPKI_DomainIDLast = 0x7FFFFFFF, /*! Reserved.*/
92 
94 
95 
96 /*------------------------------------------------------------------*/
97 /*! Defines the enum for the HASH operation mode.
98  * The enumerator defines 6 HASH modes according to IEEE 1363.
99  *
100  */
101 typedef enum
102 {
103  CRYS_ECPKI_HASH_SHA1_mode = 0, /*!< The message data will be hashed with SHA1. */
104  CRYS_ECPKI_HASH_SHA224_mode = 1, /*!< The message data will be hashed with SHA224. */
105  CRYS_ECPKI_HASH_SHA256_mode = 2, /*!< The message data will be hashed with SHA256. */
106  CRYS_ECPKI_HASH_SHA384_mode = 3, /*!< The message data will be hashed with SHA384. */
107  CRYS_ECPKI_HASH_SHA512_mode = 4, /*!< The message data will be hashed with SHA512. */
108 
109  CRYS_ECPKI_AFTER_HASH_SHA1_mode = 5, /*!< The message data is a digest of SHA1 and will not be hashed. */
110  CRYS_ECPKI_AFTER_HASH_SHA224_mode = 6, /*!< The message data is a digest of SHA224 and will not be hashed. */
111  CRYS_ECPKI_AFTER_HASH_SHA256_mode = 7, /*!< The message data is a digest of SHA256 and will not be hashed. */
112  CRYS_ECPKI_AFTER_HASH_SHA384_mode = 8, /*!< The message data is a digest of SHA384 and will not be hashed. */
113  CRYS_ECPKI_AFTER_HASH_SHA512_mode = 9, /*!< The message data is a digest of SHA512 and will not be hashed. */
114 
115 
116  CRYS_ECPKI_HASH_NumOfModes, /*!< Maximal number of HASH modes. */
117  CRYS_ECPKI_HASH_OpModeLast = 0x7FFFFFFF, /*!< Reserved. */
118 
120 
121 
122 /*---------------------------------------------------*/
123 /*! Enumerator for the EC point compression idetifier. */
124 typedef enum
125 {
126  CRYS_EC_PointCompressed = 2, /*!< Compressed point. */
127  CRYS_EC_PointUncompressed = 4, /*!< Uncompressed point. */
128  CRYS_EC_PointContWrong = 5, /*!< Wrong Point Control value. */
129  CRYS_EC_PointHybrid = 6, /*!< Hybrid point. */
130 
131  CRYS_EC_PointCompresOffMode = 8, /*!< Reserved. */
132 
133  CRYS_ECPKI_PointCompressionLast= 0x7FFFFFFF, /*!< Reserved. */
134 
136 
137 
138 /*! EC key checks defintions. */
139 typedef enum {
140  CheckPointersAndSizesOnly = 0, /*!< Only preliminary input parameters are checked. */
141  ECpublKeyPartlyCheck = 1, /*!< Preliminary input parameters check and verify that EC PubKey point is on the curve. */
142  ECpublKeyFullCheck = 2, /*!< All the above and in addition verifies that EC_GeneratorOrder*PubKey = O */
143 
144  PublKeyChecingOffMode, /*! Reserved. */
145  EC_PublKeyCheckModeLast = 0x7FFFFFFF, /*! Reserved. */
147 
148 /*----------------------------------------------------*/
149 /*! Defintion of sw SCA protection. */
150 typedef enum {
151  SCAP_Inactive, /*! Inactive.*/
152  SCAP_Active, /*! Active.*/
153  SCAP_OFF_MODE, /*! Reserved. */
154  SCAP_LAST = 0x7FFFFFFF /*! Reserved. */
156 
157 
158 /**************************************************************************************
159  * EC Domain structure definition
160  ***************************************************************************************/
161 
162 /*! The structure containing the EC domain parameters in little-endian form
163  EC equation: Y^2 = X^3 + A*X + B over prime fild GFp. */
164 typedef struct {
165 
166  /*! EC modulus: P. */
168  /*! EC equation parameter a. */
170  /*! EC equation parameter b. */
172  /*! Order of generator. */
174  /*! EC cofactor EC_Cofactor_K
175  Generator (EC base point) coordinates in projective form. */
177  /*! EC cofactor EC_Cofactor_K
178  Generator (EC base point) coordinates in projective form. */
180  /*! EC cofactor EC_Cofactor_K
181  Generator (EC base point) coordinates in projective form. */
182  uint32_t ecH;
183  /*! Specific fields that are used by the low level.*/
185  /*! Size of fields in bits. */
186  uint32_t modSizeInBits;
187  /*! Order size in bits. */
188  uint32_t ordSizeInBits;
189  /*! Size of each inserted Barret tag in words; 0 - if not inserted.*/
191  /*! EC Domain identifier.*/
193 
194  /*! Internal buffer. */
195  int8_t name[20];
196 
198 
199 
200 
201 /**************************************************************************************
202  * EC point structures definitions
203  ***************************************************************************************/
204 
205 /*! The structure containing the EC point in affine coordinates
206  and little endian form. */
207 typedef struct
208 {
209  /*! Point coordinate X. */
211  /*! Point coordinate Y. */
213 
215 
216 
217 /**************************************************************************************
218  * ECPKI public and private key Structures
219  ***************************************************************************************/
220 
221 /* --------------------------------------------------------------------- */
222 /* .................. The public key structures definitions ............ */
223 /* --------------------------------------------------------------------- */
224 
225 /*! The structure containing the Public Key in affine coordinates.*/
226 typedef struct
227 {
228  /*! Public Key coordinate X.*/
230  /*! Public Key coordinate Y.*/
232  /*! EC Domain.*/
234  /*! Point type.*/
235  uint32_t pointType;
237 
238 /*! The EC public key's user structure prototype. This structure must be saved by the user, and is used as input to the ECC functions
239 (such as ::CRYS_ECDSA_Verify etc.). */
241 {
242  /*! Validation tag.*/
243  uint32_t valid_tag;
244  /*! Public key data. */
245  uint32_t PublKeyDbBuff[(sizeof(CRYS_ECPKI_PublKey_t)+3)/4];
246 
248 
249 
250 /* --------------------------------------------------------------------- */
251 /* .................. The private key structures definitions ........... */
252 /* --------------------------------------------------------------------- */
253 
254 /*! Structure containing the Private key data. */
255 typedef struct
256 {
257  /*! Private Key data. */
259  /*! Domain. */
261  /*! SCA protection mode. */
263 
265 
266 
267 /*! The EC private key's user structure prototype. This structure must be saved by the user, and is used as input to the ECC functions
268 (such as ::CRYS_ECDSA_Sign etc.). */
270 {
271  /*! Validation tag. */
272  uint32_t valid_tag;
273  /*! Private key data. */
274  uint32_t PrivKeyDbBuff[(sizeof(CRYS_ECPKI_PrivKey_t)+3)/4];
275 
277 
278 /*! ECDH temporary data type */
279 typedef struct CRYS_ECDH_TempData_t
280 {
281  /*! Temporary buffers. */
282  uint32_t crysEcdhIntBuff[CRYS_PKA_ECDH_BUFF_MAX_LENGTH_IN_WORDS];
284 
285 /*! EC build temporary data. */
287 {
288  /*! Temporary buffers. */
291 
292 
293 
294 /**************************************************************************
295  * CRYS ECDSA context structures
296  **************************************************************************/
297 
298 /* --------------------------------------------------------------------- */
299 /* CRYS ECDSA Signing context structure */
300 /* --------------------------------------------------------------------- */
301 /*! Internal buffer used in the signing process. */
303 
304 /*! Context definition for Signing operation. */
305 typedef struct
306 {
307  /*! Private Key data. */
309 
310  /*! HASH context. */
312  /*! HASH result buffer. */
314  /*! HASH result size in words. */
316  /*! HASH mode. */
318  /*! Internal buffer. */
321 
322 
323 /* --------------------------------------------------------------------- */
324 /* CRYS ECDSA Signing User context database */
325 /* --------------------------------------------------------------------- */
326 
327 /*! User's context definition for signing operation. The context saves the state of the operation and must be saved by the user
328  till the end of the APIs flow */
330 {
331  /*! Signing process data. */
332  uint32_t context_buff [(sizeof(ECDSA_SignContext_t)+3)/4];
333  /*! Validation tag*/
334  uint32_t valid_tag;
336 
337 
338 
339 /****************************************************************************/
340 
341 /* --------------------------------------------------------------------- */
342 /* CRYS ECDSA Verifying context structure */
343 /* --------------------------------------------------------------------- */
344 /*! Internal buffer used in the verification process. */
346 
347 /*! Context definition for verification operation. */
348 typedef struct
349 {
350  /*! Public key data. */
352 
353  /*! HASH context. */
355  /*! HASH result. */
357  /*! HASH result size in words. */
359  /*! HASH mode. */
361  /*! Internal buffer. */
363 
365 
366 
367 /* --------------------------------------------------------------------- */
368 /* CRYS ECDSA Verifying User context database */
369 /* --------------------------------------------------------------------- */
370 /*! User's context definition for verification operation. The context saves the state of the operation and must be saved by the user
371  till the end of the APIs flow */
373 {
374  /*! Verification process data. */
375  uint32_t context_buff[(sizeof(ECDSA_VerifyContext_t)+3)/4];
376  /*! Validation tag. */
377  uint32_t valid_tag;
379 
380 
381 
382 
383 /* --------------------------------------------------------------------- */
384 /* .................. key generation temp buffer ........... */
385 /* --------------------------------------------------------------------- */
386 
387 /*! ECPKI KG temporary data type */
389 {
390  /*! Internal buffer. */
391  uint32_t crysKGIntBuff[CRYS_PKA_KG_BUFF_MAX_LENGTH_IN_WORDS];
393 
394 /*! ECIES temporary data definition. */
395 typedef struct CRYS_ECIES_TempData_t {
396 
397  /*! Private key data. */
399  /*! Public key data. */
401  /*! Internal buffer. */
403  /*! Internal buffers. */
404  union {
405  CRYS_ECPKI_BUILD_TempData_t buildTempbuff;
406  CRYS_ECPKI_KG_TempData_t KgTempBuff;
407  CRYS_ECDH_TempData_t DhTempBuff;
408  } tmp;
409 
411 
412 
413 /* --------------------------------------------------------------------- */
414 /* .................. defines for FIPS ........... */
415 /* --------------------------------------------------------------------- */
416 
417 /*! Order length for the FIPS ECC tests. */
418 #define CRYS_ECPKI_FIPS_ORDER_LENGTH (256/SASI_BITS_IN_BYTE) // the order of secp256r1 in bytes
419 
420 /*! Context definition required for internal FIPS verification for ECPKI key generation. */
422 {
423  /*! Signing and verification data. */
424  union {
427  }operationCtx;
428  /*! Internal buffer. */
431 
432 
433 
434 /*! Context defintion, required for internal FIPS verification for ECDSA KAT. *
435 * The ECDSA KAT tests defined for domain 256r1. */
437  /*! Key data. */
438  union {
439  /*! Private key data. */
440  struct {
441  CRYS_ECPKI_UserPrivKey_t PrivKey;
443  }userSignData;
444  /*! Public key data. */
445  struct {
446  CRYS_ECPKI_UserPublKey_t PublKey;
447  union {
450  }buildOrVerify;
451  }userVerifyData;
452  }keyContextData;
453  /*! Internal buffer. */
454  uint8_t signBuff[2*CRYS_ECPKI_FIPS_ORDER_LENGTH];
456 
457 /*! Context definition, required for internal FIPS verification for ECDH KAT. */
459  /*! Public key data. */
461  /*! Private key data. */
463  /*! Internal buffers. */
464  union {
465  CRYS_ECPKI_BUILD_TempData_t ecpkiTempData;
466  CRYS_ECDH_TempData_t ecdhTempBuff;
467  }tmpData;
468  /*! Buffer for the secret key. */
469  uint8_t secretBuff[CRYS_ECPKI_FIPS_ORDER_LENGTH];
471 
472 #ifdef __cplusplus
473 }
474 #endif
475 /**
476 @}
477  */
478 #endif
struct CRYS_ECPKI_UserPrivKey_t CRYS_ECPKI_UserPrivKey_t
#define CRYS_PKA_KG_BUFF_MAX_LENGTH_IN_WORDS
#define CRYS_PKA_ECDSA_VERIFY_BUFF_MAX_LENGTH_IN_WORDS
struct CRYS_ECDHFipsKatContext_t CRYS_ECDHFipsKatContext_t
uint32_t CRYS_ECDSA_SignIntBuff[(6 *18+((8 *(18 +1)+1)+18+2))]
CRYS_ECPKI_DomainID_t
struct CRYS_ECDSA_VerifyUserContext_t CRYS_ECDSA_VerifyUserContext_t
EC_PublKeyCheckMode_t
CRYS_ECPKI_HASH_OpMode_t hashMode
#define CRYS_PKA_ECDH_BUFF_MAX_LENGTH_IN_WORDS
This file contains compiler related definitions.
struct CRYS_ECPKI_UserPublKey_t CRYS_ECPKI_UserPublKey_t
struct CRYS_ECDSAFipsKatContext_t CRYS_ECDSAFipsKatContext_t
CRYS_ECPKI_Domain_t domain
CRYS_HASHUserContext_t hashUserCtxBuff
This file contains basic type definitions that are platform dependent.
CRYS_ECPKI_UserPrivKey_t ECDSA_SignerPrivKey
The file contains all of the enums and definitions that are used in the PKA related code...
CRYS_ECPKI_ScaProtection_t scaProtection
CRYS_ECPKI_UserPublKey_t ECDSA_SignerPublKey
CRYS_HASH_Result_t hashResult
#define CRYS_ECPKI_FIPS_ORDER_LENGTH
struct CRYS_ECPKI_BUILD_TempData_t CRYS_ECPKI_BUILD_TempData_t
struct CRYS_ECPKI_KG_FipsContext_t CRYS_ECPKI_KG_FipsContext_t
CRYS_ECPKI_UserPrivKey_t privKey
CRYS_ECPKI_UserPrivKey_t PrivKey
struct CRYS_ECDH_TempData_t CRYS_ECDH_TempData_t
CRYS_ECDSA_VerifyIntBuff crysEcdsaVerIntBuff
#define CRYS_PKA_DOMAIN_LLF_BUFF_SIZE_IN_WORDS
#define CRYS_PKA_ECDSA_SIGN_BUFF_MAX_LENGTH_IN_WORDS
CRYS_ECPKI_HASH_OpMode_t
struct CRYS_ECDSA_SignUserContext_t CRYS_ECDSA_SignUserContext_t
#define CRYS_ECPKI_ORDER_MAX_LENGTH_IN_WORDS
uint32_t CRYS_HASH_Result_t[16]
Definition: crys_hash.h:162
#define CRYS_ECPKI_MODUL_MAX_LENGTH_IN_WORDS
CRYS_ECDSA_SignIntBuff crysEcdsaSignIntBuff
This file contains all of the enums and definitions that are used for the CRYS HASH APIs...
CRYS_ECPKI_HASH_OpMode_t hashMode
CRYS_ECPKI_PointCompression_t
CRYS_ECPKI_Domain_t domain
CRYS_ECPKI_UserPublKey_t PublKey
CRYS_ECPKI_ScaProtection_t
CRYS_ECPKI_UserPublKey_t pubKey
#define CRYS_PKA_ECPKI_BUILD_TMP_BUFF_MAX_LENGTH_IN_WORDS
CRYS_HASHUserContext_t hashUserCtxBuff
struct CRYS_ECPKI_KG_TempData_t CRYS_ECPKI_KG_TempData_t
uint32_t CRYS_ECDSA_VerifyIntBuff[(3 *18)]
CRYS_HASH_Result_t hashResult
CRYS_ECPKI_DomainID_t DomainID
struct CRYS_ECIES_TempData_t CRYS_ECIES_TempData_t
uint32_t PublKeyDbBuff[(sizeof(CRYS_ECPKI_PublKey_t)+3)/4]
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.