1 /*
2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 /*
8 * All the includes that are needed for code using this module to
9 * compile correctly should be #included here.
10 */
11 #include "cc_pal_types.h"
12 #include "cc_ecpki_types.h"
13
14
15 /**************** The domain structure describing *************/
16 /**
17 // The structure containing EC domain parameters in little-endian form.
18 // Elliptic curve: Y^2 = X^3 + A*X + B over prime fild GFp
19
20 typedef struct {
21
22 // Field modulus: GF_Modulus = P
23 uint32_t ecP [CC_ECPKI_MODUL_MAX_LENGTH_IN_WORDS];
24 // EC equation parameters a, b
25 uint32_t ecA [CC_ECPKI_MODUL_MAX_LENGTH_IN_WORDS];
26 uint32_t ecB [CC_ECPKI_MODUL_MAX_LENGTH_IN_WORDS];
27 // Order of generator: EC_GenerOrder
28 uint32_t ecOrd [CC_ECPKI_MODUL_MAX_LENGTH_IN_WORDS + 1];
29 // Generator (EC base point) coordinates in projective form
30 uint32_t ecGx [CC_ECPKI_MODUL_MAX_LENGTH_IN_WORDS];
31 uint32_t ecGy [CC_ECPKI_MODUL_MAX_LENGTH_IN_WORDS];
32 // EC cofactor EC_Cofactor_K
33 uint32_t ecH;
34 // include the specific fields that are used by the low level
35 uint32_t barrTagBuff[CC_PKA_DOMAIN_BUFF_SIZE_IN_WORDS];
36 // Size of fields in bits
37 uint32_t modSizeInBits;
38 uint32_t ordSizeInBits;
39 // Size of each inserted Barret tag in words; 0 - if not inserted
40 uint32_t barrTagSizeInWords;
41 CCEcpkiDomainID_t DomainID;
42 int8_t name[20];
43
44 } CCEcpkiDomain_t;
45
46 */
47
48 /***********************************************************************************
49 * Data base of ecpki_domain_secp192r1: structure of type CCEcpkiDomain_t *
50 * All data is given in little endian order of words in arrays *
51 ***********************************************************************************/
52 static const CCEcpkiDomain_t ecpki_domain_secp192r1 = {
53 /* Field modulus : GF_Modulus = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF - big end*/
54 {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
55 /* EC equation parameters a, b */
56 /* a = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC - big end from SEC2 */
57 {0xFFFFFFFC,0xFFFFFFFF,0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
58 /* b = 64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1 - big end from SEC2 */
59 {0xC146B9B1,0xFEB8DEEC,0x72243049,0x0FA7E9AB,0xE59C80E7,0x64210519},
60
61 /* Order of generator: FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831 big end from SEC2 */
62 {0xB4D22831,0x146BC9B1,0x99DEF836,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
63
64 /* Generator coordinates in affine form: EC_Gener_X, EC_Gener_Y (in ordinary representation) */
65 /* 188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012 X - big end from SEC2 */
66 {0x82FF1012,0xF4FF0AFD,0x43A18800,0x7CBF20EB,0xB03090F6,0x188DA80E},
67 /* 7192B95FFC8DA78631011ED6B24CDD573F977A11E794811 Y - big end from SEC2 */
68 {0x1E794811,0x73F977A1,0x6B24CDD5,0x631011ED,0xFFC8DA78,0x07192B95},
69
70 1, /* EC cofactor K */
71
72 /* Barrett tags NP,RP */
73 #ifdef CC_SUPPORT_PKA_128_32
74 {0x00000080,0x00000000,0x00000000,0x00000000,0x00000080,
75 0x1083E4F5,0x00000033,0x00000000,0x00000000,0x00000080},
76 #else // CC_SUPPORT_PKA_64_16
77 {0x00000000,0x00000000,0x00000080,0x00000000, 0x00000000,
78 0x00000000,0x00000000,0x00000080,0x00000000,0x00000000},
79 #endif
80
81 192, /* Size of field modulus in bits */
82 192, /* Size of order of generator in bits */
83 5, /* Size of each inserted Barret tag in words; 0 - if not inserted */
84
85 CC_ECPKI_DomainID_secp192r1, /* EC Domain identifier - enum */
86 "SECG_PRIME_192R1" /*NIST_P192*/
87 };
88
89
90
91
92 /**
93 @brief the function returns the domain pointer id the domain is supported for the product;
94 otherwise return NULL
95 @return return domain pointer or NULL
96
97 */
CC_EcpkiGetSecp192r1DomainP(void)98 const CCEcpkiDomain_t *CC_EcpkiGetSecp192r1DomainP(void)
99 {
100 return &ecpki_domain_secp192r1;
101 }
102
103