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_secp224k1: 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_secp224k1 = {
54 /* Field modulus : GF_Modulus = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFE56D - big end*/
55 {0xFFFFE56D,0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
56 /* EC equation parameters a, b */
57 /* a = -0 - big end from SEC2 */
58 {0},
59 /* b = 5 - big end from SEC2 */
60 {5},
61 /* Order of generator: 10000000000000000000000000001DCE8D2EC6184CAF0A971769FB1F7 big end from SEC2 */
62 {0x769FB1F7,0xCAF0A971,0xD2EC6184,0x0001DCE8,0x00000000,0x00000000,0x00000000,0x00000001},
63
64 /* Generator coordinates in affine form: EC_Gener_X, EC_Gener_Y (in ordinary representation) */
65 /* A1455B334DF099DF30FC28A169A467E9E47075A90F7E650EB6B7A45C X - big end from SEC2 */
66 {0xB6B7A45C,0x0F7E650E,0xE47075A9,0x69A467E9,0x30FC28A1,0x4DF099DF,0xA1455B33},
67 /* 7E089FED7FBA344282CAFBD6F7E319F7C0B0BD59E2CA4BDB556D61A5 Y - big end from SEC2 */
68 {0x556D61A5,0xE2CA4BDB,0xC0B0BD59,0xF7E319F7,0x82CAFBD6,0x7FBA3442,0x7E089FED},
69
70 1, /* EC cofactor K */
71
72 /* Barrett tags NP,RP */
73 #ifdef CC_SUPPORT_PKA_128_32
74 {0x00000000,0x00000000,0x00000000,0x00000000,0x00000080,
75 0xFE23172D,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0x000000FF},
76 #else // CC_SUPPORT_PKA_64_16
77 {0x00000000,0x00000000,0x00000080,0x00000000, 0x00000000,
78 0xFFFFFFFF,0xFFFFFFFF,0x000000FF,0x00000000,0x00000000},
79 #endif
80
81 224, /* Size of field modulus in bits */
82 225, /* 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_secp224k1, /* EC Domain identifier - enum */
86 "SECG_PRIME_224K1"
87 };
88
89
90
91
92
93 /**
94 @brief the function returns the domain pointer id the domain is supported for the product;
95 otherwise return NULL
96 @return return domain pointer or NULL
97
98 */
CC_EcpkiGetSecp224k1DomainP(void)99 const CCEcpkiDomain_t *CC_EcpkiGetSecp224k1DomainP(void)
100 {
101 return &ecpki_domain_secp224k1;
102 }
103
104