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