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_secp192k1: 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_secp192k1 = {
53 /* Field modulus : GF_Modulus = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37 - big end*/
54 {0xFFFFEE37,0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
55 /* EC equation parameters a, b */
56 /* a = 0 - big end from SEC2 */
57 {0x0},
58 /* b = 3 - big end from SEC2 */
59 {0x3},
60 /* Order of generator: FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D big end from SEC2 */
61 {0x74DEFD8D,0x0F69466A,0x26F2FC17,0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFF},
62 /* Generator coordinates in affine form: EC_Gener_X, EC_Gener_Y (in ordinary representation) */
63 /* DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D X - big end from SEC2 */
64 {0xEAE06C7D,0x1DA5D1B1,0x80B7F434,0x26B07D02,0xC057E9AE,0xDB4FF10E},
65 /* 9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D Y - big end from SEC2 */
66 {0xD95E2F9D,0x4082AA88,0x15BE8634,0x844163D0,0x9C5628A7,0x9B2F2F6D},
67 1, /* EC cofactor K */
68
69 /* Barrett tags NP,RP */
70 #ifdef CC_SUPPORT_PKA_128_32
71 {0x00000000,0x00000000,0x00000000,0x00000000,0x00000080,
72 0x8681F478,0x000000EC,0x00000000,0x00000000,0x00000080}, //80 00000000 00000000 000000EC 8681F478
73 #else // CC_SUPPORT_PKA_64_16
74 {0x00000000,0x00000000,0x00000080,0x00000000, 0x00000000,
75 0x00000000,0x00000000,0x00000080,0x00000000,0x00000000},
76 #endif
77
78 192, /* Size of field modulus in bits */
79 192, /* Size of order of generator in bits */
80 5, /* Size of each inserted Barret tag in words; 0 - if not inserted */
81
82 CC_ECPKI_DomainID_secp192k1, /* EC Domain identifier - enum */
83 "SECG_PRIME_192K1"
84 };
85
86
87
88
89 /**
90 @brief the function returns the domain pointer id the domain is supported for the product;
91 otherwise return NULL
92 @return return domain pointer or NULL
93
94 */
CC_EcpkiGetSecp192k1DomainP(void)95 const CCEcpkiDomain_t *CC_EcpkiGetSecp192k1DomainP(void)
96 {
97 return &ecpki_domain_secp192k1;
98 }
99
100