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 /***********************************************************************************
50  *   Data base of CC_ECPKI_DomainID_secp384r1: structure of type  CCEcpkiDomain_t    *
51  *       All data is given in little endian order of words in arrays               *
52  ***********************************************************************************/
53 static const CCEcpkiDomain_t ecpki_domain_secp384r1 = {
54     /* Field modulus :                            *
55     *  GF_Modulus =  FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF - big end*/
56     {0xFFFFFFFF,0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
57         0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
58     /* EC equation parameters a, b  */
59     /* a = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC   - big end  from SEC2 */
60     {0xFFFFFFFC,0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
61         0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
62     /* b = B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF  - big end  from SEC2 */
63     {0xD3EC2AEF,0x2A85C8ED,0x8A2ED19D,0xC656398D,0x5013875A,0x0314088F,0xFE814112,0x181D9C6E,
64         0xE3F82D19,0x988E056B,0xE23EE7E4,0xB3312FA7},
65 
66     /* Order of generator: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973  big end  from SEC2 */
67     {0xCCC52973,0xECEC196A,0x48B0A77A,0x581A0DB2,0xF4372DDF,0xC7634D81,0xFFFFFFFF,0xFFFFFFFF,
68         0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
69 
70     /* Generator  coordinates in affine form: EC_Gener_X, EC_Gener_Y (in ordinary representation) */
71     /* AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7    X - big end  from SEC2 */
72     {0x72760AB7,0x3A545E38,0xBF55296C,0x5502F25D,0x82542A38,0x59F741E0,0x8BA79B98,0x6E1D3B62,
73         0xF320AD74,0x8EB1C71E,0xBE8B0537,0xAA87CA22},
74     /* 3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F   Y - big end  from SEC2 */
75     {0x90EA0E5F,0x7A431D7C,0x1D7E819D,0x0A60B1CE,0xB5F0B8C0,0xE9DA3113,0x289A147C,0xF8F41DBD,
76         0x9292DC29,0x5D9E98BF,0x96262C6F,0x3617DE4A},
77 
78     1, /* EC cofactor K */
79 
80     /* Barrett tags NP,RP */
81     #ifdef CC_SUPPORT_PKA_128_32
82     {0x00000000,0x00000000,0x00000000,0x00000000,0x00000080,
83         0x00000000,0x00000000,0x00000000,0x00000000,0x00000080},
84     #else  // CC_SUPPORT_PKA_64_16
85     {0x00000000,0x00000000,0x00000080,0x00000000, 0x00000000,
86         0x00000000,0x00000000,0x00000080,0x00000000,0x00000000},
87     #endif
88 
89     384, /* Size of field modulus in bits */
90     384, /* Size of order of generator in bits */
91     5,   /* Size of each inserted Barret tag in words; 0 - if not inserted */
92 
93     CC_ECPKI_DomainID_secp384r1,    /* EC Domain identifier - enum */
94     "SECG_PRIME_384R1"
95 
96 };
97 
98 
99 /**
100  @brief    the function returns the domain pointer id the domain is supported for the product;
101         otherwise return NULL
102  @return   return domain pointer or NULL
103 
104 */
CC_EcpkiGetSecp384r1DomainP(void)105 const CCEcpkiDomain_t *CC_EcpkiGetSecp384r1DomainP(void)
106 {
107     return &ecpki_domain_secp384r1;
108 }
109 
110