xref: /titanic_51/usr/src/common/crypto/ecc/ecl-exp.h (revision a31148363f598def767ac48c5d82e1572e44b935)
1 /*
2  * ***** BEGIN LICENSE BLOCK *****
3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  * http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * The Original Code is the elliptic curve math library.
16  *
17  * The Initial Developer of the Original Code is
18  * Sun Microsystems, Inc.
19  * Portions created by the Initial Developer are Copyright (C) 2003
20  * the Initial Developer. All Rights Reserved.
21  *
22  * Contributor(s):
23  *   Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
24  *
25  * Alternatively, the contents of this file may be used under the terms of
26  * either the GNU General Public License Version 2 or later (the "GPL"), or
27  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28  * in which case the provisions of the GPL or the LGPL are applicable instead
29  * of those above. If you wish to allow use of your version of this file only
30  * under the terms of either the GPL or the LGPL, and not to allow others to
31  * use your version of this file under the terms of the MPL, indicate your
32  * decision by deleting the provisions above and replace them with the notice
33  * and other provisions required by the GPL or the LGPL. If you do not delete
34  * the provisions above, a recipient may use your version of this file under
35  * the terms of any one of the MPL, the GPL or the LGPL.
36  *
37  * ***** END LICENSE BLOCK ***** */
38 /*
39  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
40  * Use is subject to license terms.
41  *
42  * Sun elects to use this software under the MPL license.
43  */
44 
45 #ifndef _ECL_EXP_H
46 #define _ECL_EXP_H
47 
48 #pragma ident	"%Z%%M%	%I%	%E% SMI"
49 
50 /* Curve field type */
51 typedef enum {
52 	ECField_GFp,
53 	ECField_GF2m
54 } ECField;
55 
56 /* Hexadecimal encoding of curve parameters */
57 struct ECCurveParamsStr {
58 	char *text;
59 	ECField field;
60 	unsigned int size;
61 	char *irr;
62 	char *curvea;
63 	char *curveb;
64 	char *genx;
65 	char *geny;
66 	char *order;
67 	int cofactor;
68 };
69 typedef struct ECCurveParamsStr ECCurveParams;
70 
71 /* Named curve parameters */
72 typedef enum {
73 
74 	ECCurve_noName = 0,
75 
76 	/* NIST prime curves */
77 	ECCurve_NIST_P192,
78 	ECCurve_NIST_P224,
79 	ECCurve_NIST_P256,
80 	ECCurve_NIST_P384,
81 	ECCurve_NIST_P521,
82 
83 	/* NIST binary curves */
84 	ECCurve_NIST_K163,
85 	ECCurve_NIST_B163,
86 	ECCurve_NIST_K233,
87 	ECCurve_NIST_B233,
88 	ECCurve_NIST_K283,
89 	ECCurve_NIST_B283,
90 	ECCurve_NIST_K409,
91 	ECCurve_NIST_B409,
92 	ECCurve_NIST_K571,
93 	ECCurve_NIST_B571,
94 
95 	/* ANSI X9.62 prime curves */
96 	/* ECCurve_X9_62_PRIME_192V1 == ECCurve_NIST_P192 */
97 	ECCurve_X9_62_PRIME_192V2,
98 	ECCurve_X9_62_PRIME_192V3,
99 	ECCurve_X9_62_PRIME_239V1,
100 	ECCurve_X9_62_PRIME_239V2,
101 	ECCurve_X9_62_PRIME_239V3,
102 	/* ECCurve_X9_62_PRIME_256V1 == ECCurve_NIST_P256 */
103 
104 	/* ANSI X9.62 binary curves */
105 	ECCurve_X9_62_CHAR2_PNB163V1,
106 	ECCurve_X9_62_CHAR2_PNB163V2,
107 	ECCurve_X9_62_CHAR2_PNB163V3,
108 	ECCurve_X9_62_CHAR2_PNB176V1,
109 	ECCurve_X9_62_CHAR2_TNB191V1,
110 	ECCurve_X9_62_CHAR2_TNB191V2,
111 	ECCurve_X9_62_CHAR2_TNB191V3,
112 	ECCurve_X9_62_CHAR2_PNB208W1,
113 	ECCurve_X9_62_CHAR2_TNB239V1,
114 	ECCurve_X9_62_CHAR2_TNB239V2,
115 	ECCurve_X9_62_CHAR2_TNB239V3,
116 	ECCurve_X9_62_CHAR2_PNB272W1,
117 	ECCurve_X9_62_CHAR2_PNB304W1,
118 	ECCurve_X9_62_CHAR2_TNB359V1,
119 	ECCurve_X9_62_CHAR2_PNB368W1,
120 	ECCurve_X9_62_CHAR2_TNB431R1,
121 
122 	/* SEC2 prime curves */
123 	ECCurve_SECG_PRIME_112R1,
124 	ECCurve_SECG_PRIME_112R2,
125 	ECCurve_SECG_PRIME_128R1,
126 	ECCurve_SECG_PRIME_128R2,
127 	ECCurve_SECG_PRIME_160K1,
128 	ECCurve_SECG_PRIME_160R1,
129 	ECCurve_SECG_PRIME_160R2,
130 	ECCurve_SECG_PRIME_192K1,
131 	/* ECCurve_SECG_PRIME_192R1 == ECCurve_NIST_P192 */
132 	ECCurve_SECG_PRIME_224K1,
133 	/* ECCurve_SECG_PRIME_224R1 == ECCurve_NIST_P224 */
134 	ECCurve_SECG_PRIME_256K1,
135 	/* ECCurve_SECG_PRIME_256R1 == ECCurve_NIST_P256 */
136 	/* ECCurve_SECG_PRIME_384R1 == ECCurve_NIST_P384 */
137 	/* ECCurve_SECG_PRIME_521R1 == ECCurve_NIST_P521 */
138 
139 	/* SEC2 binary curves */
140 	ECCurve_SECG_CHAR2_113R1,
141 	ECCurve_SECG_CHAR2_113R2,
142 	ECCurve_SECG_CHAR2_131R1,
143 	ECCurve_SECG_CHAR2_131R2,
144 	/* ECCurve_SECG_CHAR2_163K1 == ECCurve_NIST_K163 */
145 	ECCurve_SECG_CHAR2_163R1,
146 	/* ECCurve_SECG_CHAR2_163R2 == ECCurve_NIST_B163 */
147 	ECCurve_SECG_CHAR2_193R1,
148 	ECCurve_SECG_CHAR2_193R2,
149 	/* ECCurve_SECG_CHAR2_233K1 == ECCurve_NIST_K233 */
150 	/* ECCurve_SECG_CHAR2_233R1 == ECCurve_NIST_B233 */
151 	ECCurve_SECG_CHAR2_239K1,
152 	/* ECCurve_SECG_CHAR2_283K1 == ECCurve_NIST_K283 */
153 	/* ECCurve_SECG_CHAR2_283R1 == ECCurve_NIST_B283 */
154 	/* ECCurve_SECG_CHAR2_409K1 == ECCurve_NIST_K409 */
155 	/* ECCurve_SECG_CHAR2_409R1 == ECCurve_NIST_B409 */
156 	/* ECCurve_SECG_CHAR2_571K1 == ECCurve_NIST_K571 */
157 	/* ECCurve_SECG_CHAR2_571R1 == ECCurve_NIST_B571 */
158 
159 	/* WTLS curves */
160 	ECCurve_WTLS_1,
161 	/* there is no WTLS 2 curve */
162 	/* ECCurve_WTLS_3 == ECCurve_NIST_K163 */
163 	/* ECCurve_WTLS_4 == ECCurve_SECG_CHAR2_113R1 */
164 	/* ECCurve_WTLS_5 == ECCurve_X9_62_CHAR2_PNB163V1 */
165 	/* ECCurve_WTLS_6 == ECCurve_SECG_PRIME_112R1 */
166 	/* ECCurve_WTLS_7 == ECCurve_SECG_PRIME_160R1 */
167 	ECCurve_WTLS_8,
168 	ECCurve_WTLS_9,
169 	/* ECCurve_WTLS_10 == ECCurve_NIST_K233 */
170 	/* ECCurve_WTLS_11 == ECCurve_NIST_B233 */
171 	/* ECCurve_WTLS_12 == ECCurve_NIST_P224 */
172 
173 	ECCurve_pastLastCurve
174 } ECCurveName;
175 
176 /* Aliased named curves */
177 
178 #define ECCurve_X9_62_PRIME_192V1 ECCurve_NIST_P192
179 #define ECCurve_X9_62_PRIME_256V1 ECCurve_NIST_P256
180 #define ECCurve_SECG_PRIME_192R1 ECCurve_NIST_P192
181 #define ECCurve_SECG_PRIME_224R1 ECCurve_NIST_P224
182 #define ECCurve_SECG_PRIME_256R1 ECCurve_NIST_P256
183 #define ECCurve_SECG_PRIME_384R1 ECCurve_NIST_P384
184 #define ECCurve_SECG_PRIME_521R1 ECCurve_NIST_P521
185 #define ECCurve_SECG_CHAR2_163K1 ECCurve_NIST_K163
186 #define ECCurve_SECG_CHAR2_163R2 ECCurve_NIST_B163
187 #define ECCurve_SECG_CHAR2_233K1 ECCurve_NIST_K233
188 #define ECCurve_SECG_CHAR2_233R1 ECCurve_NIST_B233
189 #define ECCurve_SECG_CHAR2_283K1 ECCurve_NIST_K283
190 #define ECCurve_SECG_CHAR2_283R1 ECCurve_NIST_B283
191 #define ECCurve_SECG_CHAR2_409K1 ECCurve_NIST_K409
192 #define ECCurve_SECG_CHAR2_409R1 ECCurve_NIST_B409
193 #define ECCurve_SECG_CHAR2_571K1 ECCurve_NIST_K571
194 #define ECCurve_SECG_CHAR2_571R1 ECCurve_NIST_B571
195 #define ECCurve_WTLS_3 ECCurve_NIST_K163
196 #define ECCurve_WTLS_4 ECCurve_SECG_CHAR2_113R1
197 #define ECCurve_WTLS_5 ECCurve_X9_62_CHAR2_PNB163V1
198 #define ECCurve_WTLS_6 ECCurve_SECG_PRIME_112R1
199 #define ECCurve_WTLS_7 ECCurve_SECG_PRIME_160R1
200 #define ECCurve_WTLS_10 ECCurve_NIST_K233
201 #define ECCurve_WTLS_11 ECCurve_NIST_B233
202 #define ECCurve_WTLS_12 ECCurve_NIST_P224
203 
204 #endif /* _ECL_EXP_H */
205