• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.bouncycastle.asn1.sec;
2 
3 import java.math.BigInteger;
4 import java.util.Enumeration;
5 import java.util.Hashtable;
6 
7 import org.bouncycastle.asn1.ASN1ObjectIdentifier;
8 import org.bouncycastle.asn1.x9.X9ECParameters;
9 import org.bouncycastle.asn1.x9.X9ECParametersHolder;
10 import org.bouncycastle.asn1.x9.X9ECPoint;
11 import org.bouncycastle.math.ec.ECConstants;
12 import org.bouncycastle.math.ec.ECCurve;
13 import org.bouncycastle.math.ec.endo.GLVTypeBEndomorphism;
14 import org.bouncycastle.math.ec.endo.GLVTypeBParameters;
15 import org.bouncycastle.util.Strings;
16 import org.bouncycastle.util.encoders.Hex;
17 
18 public class SECNamedCurves
19 {
configureCurve(ECCurve curve)20     private static ECCurve configureCurve(ECCurve curve)
21     {
22         return curve;
23     }
24 
configureCurveGLV(ECCurve c, GLVTypeBParameters p)25     private static ECCurve configureCurveGLV(ECCurve c, GLVTypeBParameters p)
26     {
27         return c.configure().setEndomorphism(new GLVTypeBEndomorphism(c, p)).create();
28     }
29 
fromHex( String hex)30     private static BigInteger fromHex(
31         String hex)
32     {
33         return new BigInteger(1, Hex.decode(hex));
34     }
35 
36     /*
37      * secp112r1
38      */
39     static X9ECParametersHolder secp112r1 = new X9ECParametersHolder()
40     {
41         protected X9ECParameters createParameters()
42         {
43             // p = (2^128 - 3) / 76439
44             BigInteger p = fromHex("DB7C2ABF62E35E668076BEAD208B");
45             BigInteger a = fromHex("DB7C2ABF62E35E668076BEAD2088");
46             BigInteger b = fromHex("659EF8BA043916EEDE8911702B22");
47             byte[] S = Hex.decode("00F50B028E4D696E676875615175290472783FB1");
48             BigInteger n = fromHex("DB7C2ABF62E35E7628DFAC6561C5");
49             BigInteger h = BigInteger.valueOf(1);
50 
51             ECCurve curve = configureCurve(new ECCurve.Fp(p, a, b, n, h));
52             //ECPoint G = curve.decodePoint(Hex.decode("02"
53             //+ "09487239995A5EE76B55F9C2F098"));
54             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
55                 + "09487239995A5EE76B55F9C2F098"
56                 + "A89CE5AF8724C0A23E0E0FF77500"));
57 
58             return new X9ECParameters(curve, G, n, h, S);
59         }
60     };
61 
62     /*
63      * secp112r2
64      */
65     static X9ECParametersHolder secp112r2 = new X9ECParametersHolder()
66     {
67         protected X9ECParameters createParameters()
68         {
69             // p = (2^128 - 3) / 76439
70             BigInteger p = fromHex("DB7C2ABF62E35E668076BEAD208B");
71             BigInteger a = fromHex("6127C24C05F38A0AAAF65C0EF02C");
72             BigInteger b = fromHex("51DEF1815DB5ED74FCC34C85D709");
73             byte[] S = Hex.decode("002757A1114D696E6768756151755316C05E0BD4");
74             BigInteger n = fromHex("36DF0AAFD8B8D7597CA10520D04B");
75             BigInteger h = BigInteger.valueOf(4);
76 
77             ECCurve curve = configureCurve(new ECCurve.Fp(p, a, b, n, h));
78             //ECPoint G = curve.decodePoint(Hex.decode("03"
79             //+ "4BA30AB5E892B4E1649DD0928643"));
80             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
81                 + "4BA30AB5E892B4E1649DD0928643"
82                 + "ADCD46F5882E3747DEF36E956E97"));
83 
84             return new X9ECParameters(curve, G, n, h, S);
85         }
86     };
87 
88     /*
89      * secp128r1
90      */
91     static X9ECParametersHolder secp128r1 = new X9ECParametersHolder()
92     {
93         protected X9ECParameters createParameters()
94         {
95             // p = 2^128 - 2^97 - 1
96             BigInteger p = fromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF");
97             BigInteger a = fromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC");
98             BigInteger b = fromHex("E87579C11079F43DD824993C2CEE5ED3");
99             byte[] S = Hex.decode("000E0D4D696E6768756151750CC03A4473D03679");
100             BigInteger n = fromHex("FFFFFFFE0000000075A30D1B9038A115");
101             BigInteger h = BigInteger.valueOf(1);
102 
103             ECCurve curve = configureCurve(new ECCurve.Fp(p, a, b, n, h));
104             //ECPoint G = curve.decodePoint(Hex.decode("03"
105             //+ "161FF7528B899B2D0C28607CA52C5B86"));
106             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
107                 + "161FF7528B899B2D0C28607CA52C5B86"
108                 + "CF5AC8395BAFEB13C02DA292DDED7A83"));
109 
110             return new X9ECParameters(curve, G, n, h, S);
111         }
112     };
113 
114     /*
115      * secp128r2
116      */
117     static X9ECParametersHolder secp128r2 = new X9ECParametersHolder()
118     {
119         protected X9ECParameters createParameters()
120         {
121             // p = 2^128 - 2^97 - 1
122             BigInteger p = fromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF");
123             BigInteger a = fromHex("D6031998D1B3BBFEBF59CC9BBFF9AEE1");
124             BigInteger b = fromHex("5EEEFCA380D02919DC2C6558BB6D8A5D");
125             byte[] S = Hex.decode("004D696E67687561517512D8F03431FCE63B88F4");
126             BigInteger n = fromHex("3FFFFFFF7FFFFFFFBE0024720613B5A3");
127             BigInteger h = BigInteger.valueOf(4);
128 
129             ECCurve curve = configureCurve(new ECCurve.Fp(p, a, b, n, h));
130             //ECPoint G = curve.decodePoint(Hex.decode("02"
131             //+ "7B6AA5D85E572983E6FB32A7CDEBC140"));
132             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
133                 + "7B6AA5D85E572983E6FB32A7CDEBC140"
134                 + "27B6916A894D3AEE7106FE805FC34B44"));
135 
136             return new X9ECParameters(curve, G, n, h, S);
137         }
138     };
139 
140     /*
141      * secp160k1
142      */
143     static X9ECParametersHolder secp160k1 = new X9ECParametersHolder()
144     {
145         protected X9ECParameters createParameters()
146         {
147             // p = 2^160 - 2^32 - 2^14 - 2^12 - 2^9 - 2^8 - 2^7 - 2^3 - 2^2 - 1
148             BigInteger p = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73");
149             BigInteger a = ECConstants.ZERO;
150             BigInteger b = BigInteger.valueOf(7);
151             byte[] S = null;
152             BigInteger n = fromHex("0100000000000000000001B8FA16DFAB9ACA16B6B3");
153             BigInteger h = BigInteger.valueOf(1);
154 
155             GLVTypeBParameters glv = new GLVTypeBParameters(
156                 new BigInteger("9ba48cba5ebcb9b6bd33b92830b2a2e0e192f10a", 16),
157                 new BigInteger("c39c6c3b3a36d7701b9c71a1f5804ae5d0003f4", 16),
158                 new BigInteger[]{
159                     new BigInteger("9162fbe73984472a0a9e", 16),
160                     new BigInteger("-96341f1138933bc2f505", 16) },
161                 new BigInteger[]{
162                     new BigInteger("127971af8721782ecffa3", 16),
163                     new BigInteger("9162fbe73984472a0a9e", 16) },
164                 new BigInteger("9162fbe73984472a0a9d0590", 16),
165                 new BigInteger("96341f1138933bc2f503fd44", 16),
166                 176);
167 
168             ECCurve curve = configureCurveGLV(new ECCurve.Fp(p, a, b, n, h), glv);
169 //            ECPoint G = curve.decodePoint(Hex.decode("02"
170 //                + "3B4C382CE37AA192A4019E763036F4F5DD4D7EBB"));
171             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
172                 + "3B4C382CE37AA192A4019E763036F4F5DD4D7EBB"
173                 + "938CF935318FDCED6BC28286531733C3F03C4FEE"));
174 
175             return new X9ECParameters(curve, G, n, h, S);
176         }
177     };
178 
179     /*
180      * secp160r1
181      */
182     static X9ECParametersHolder secp160r1 = new X9ECParametersHolder()
183     {
184         protected X9ECParameters createParameters()
185         {
186             // p = 2^160 - 2^31 - 1
187             BigInteger p = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF");
188             BigInteger a = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC");
189             BigInteger b = fromHex("1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45");
190             byte[] S = Hex.decode("1053CDE42C14D696E67687561517533BF3F83345");
191             BigInteger n = fromHex("0100000000000000000001F4C8F927AED3CA752257");
192             BigInteger h = BigInteger.valueOf(1);
193 
194             ECCurve curve = configureCurve(new ECCurve.Fp(p, a, b, n, h));
195             //ECPoint G = curve.decodePoint(Hex.decode("02"
196                 //+ "4A96B5688EF573284664698968C38BB913CBFC82"));
197             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
198                 + "4A96B5688EF573284664698968C38BB913CBFC82"
199                 + "23A628553168947D59DCC912042351377AC5FB32"));
200 
201             return new X9ECParameters(curve, G, n, h, S);
202         }
203     };
204 
205     /*
206      * secp160r2
207      */
208     static X9ECParametersHolder secp160r2 = new X9ECParametersHolder()
209     {
210         protected X9ECParameters createParameters()
211         {
212             // p = 2^160 - 2^32 - 2^14 - 2^12 - 2^9 - 2^8 - 2^7 - 2^3 - 2^2 - 1
213             BigInteger p = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73");
214             BigInteger a = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC70");
215             BigInteger b = fromHex("B4E134D3FB59EB8BAB57274904664D5AF50388BA");
216             byte[] S = Hex.decode("B99B99B099B323E02709A4D696E6768756151751");
217             BigInteger n = fromHex("0100000000000000000000351EE786A818F3A1A16B");
218             BigInteger h = BigInteger.valueOf(1);
219 
220             ECCurve curve = configureCurve(new ECCurve.Fp(p, a, b, n, h));
221             //ECPoint G = curve.decodePoint(Hex.decode("02"
222             //+ "52DCB034293A117E1F4FF11B30F7199D3144CE6D"));
223             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
224                 + "52DCB034293A117E1F4FF11B30F7199D3144CE6D"
225                 + "FEAFFEF2E331F296E071FA0DF9982CFEA7D43F2E"));
226 
227             return new X9ECParameters(curve, G, n, h, S);
228         }
229     };
230 
231     /*
232      * secp192k1
233      */
234     static X9ECParametersHolder secp192k1 = new X9ECParametersHolder()
235     {
236         protected X9ECParameters createParameters()
237         {
238             // p = 2^192 - 2^32 - 2^12 - 2^8 - 2^7 - 2^6 - 2^3 - 1
239             BigInteger p = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37");
240             BigInteger a = ECConstants.ZERO;
241             BigInteger b = BigInteger.valueOf(3);
242             byte[] S = null;
243             BigInteger n = fromHex("FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D");
244             BigInteger h = BigInteger.valueOf(1);
245 
246             GLVTypeBParameters glv = new GLVTypeBParameters(
247                 new BigInteger("bb85691939b869c1d087f601554b96b80cb4f55b35f433c2", 16),
248                 new BigInteger("3d84f26c12238d7b4f3d516613c1759033b1a5800175d0b1", 16),
249                 new BigInteger[]{
250                     new BigInteger("71169be7330b3038edb025f1", 16),
251                     new BigInteger("-b3fb3400dec5c4adceb8655c", 16) },
252                 new BigInteger[]{
253                     new BigInteger("12511cfe811d0f4e6bc688b4d", 16),
254                     new BigInteger("71169be7330b3038edb025f1", 16) },
255                 new BigInteger("71169be7330b3038edb025f1d0f9", 16),
256                 new BigInteger("b3fb3400dec5c4adceb8655d4c94", 16),
257                 208);
258 
259             ECCurve curve = configureCurveGLV(new ECCurve.Fp(p, a, b, n, h), glv);
260             //ECPoint G = curve.decodePoint(Hex.decode("03"
261             //+ "DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D"));
262             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
263                 + "DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D"
264                 + "9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D"));
265 
266             return new X9ECParameters(curve, G, n, h, S);
267         }
268     };
269 
270     /*
271      * secp192r1
272      */
273     static X9ECParametersHolder secp192r1 = new X9ECParametersHolder()
274     {
275         protected X9ECParameters createParameters()
276         {
277             // p = 2^192 - 2^64 - 1
278             BigInteger p = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF");
279             BigInteger a = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC");
280             BigInteger b = fromHex("64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1");
281             byte[] S = Hex.decode("3045AE6FC8422F64ED579528D38120EAE12196D5");
282             BigInteger n = fromHex("FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831");
283             BigInteger h = BigInteger.valueOf(1);
284 
285             ECCurve curve = configureCurve(new ECCurve.Fp(p, a, b, n, h));
286             //ECPoint G = curve.decodePoint(Hex.decode("03"
287             //+ "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012"));
288             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
289                 + "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012"
290                 + "07192B95FFC8DA78631011ED6B24CDD573F977A11E794811"));
291 
292             return new X9ECParameters(curve, G, n, h, S);
293         }
294     };
295 
296     /*
297      * secp224k1
298      */
299     static X9ECParametersHolder secp224k1 = new X9ECParametersHolder()
300     {
301         protected X9ECParameters createParameters()
302         {
303             // p = 2^224 - 2^32 - 2^12 - 2^11 - 2^9 - 2^7 - 2^4 - 2 - 1
304             BigInteger p = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFE56D");
305             BigInteger a = ECConstants.ZERO;
306             BigInteger b = BigInteger.valueOf(5);
307             byte[] S = null;
308             BigInteger n = fromHex("010000000000000000000000000001DCE8D2EC6184CAF0A971769FB1F7");
309             BigInteger h = BigInteger.valueOf(1);
310 
311             GLVTypeBParameters glv = new GLVTypeBParameters(
312                 new BigInteger("fe0e87005b4e83761908c5131d552a850b3f58b749c37cf5b84d6768", 16),
313                 new BigInteger("60dcd2104c4cbc0be6eeefc2bdd610739ec34e317f9b33046c9e4788", 16),
314                 new BigInteger[]{
315                     new BigInteger("6b8cf07d4ca75c88957d9d670591", 16),
316                     new BigInteger("-b8adf1378a6eb73409fa6c9c637d", 16) },
317                 new BigInteger[]{
318                     new BigInteger("1243ae1b4d71613bc9f780a03690e", 16),
319                     new BigInteger("6b8cf07d4ca75c88957d9d670591", 16) },
320                 new BigInteger("6b8cf07d4ca75c88957d9d67059037a4", 16),
321                 new BigInteger("b8adf1378a6eb73409fa6c9c637ba7f5", 16),
322                 240);
323 
324             ECCurve curve = configureCurveGLV(new ECCurve.Fp(p, a, b, n, h), glv);
325             //ECPoint G = curve.decodePoint(Hex.decode("03"
326             //+ "A1455B334DF099DF30FC28A169A467E9E47075A90F7E650EB6B7A45C"));
327             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
328                 + "A1455B334DF099DF30FC28A169A467E9E47075A90F7E650EB6B7A45C"
329                 + "7E089FED7FBA344282CAFBD6F7E319F7C0B0BD59E2CA4BDB556D61A5"));
330 
331             return new X9ECParameters(curve, G, n, h, S);
332         }
333     };
334 
335     /*
336      * secp224r1
337      */
338     static X9ECParametersHolder secp224r1 = new X9ECParametersHolder()
339     {
340         protected X9ECParameters createParameters()
341         {
342             // p = 2^224 - 2^96 + 1
343             BigInteger p = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001");
344             BigInteger a = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE");
345             BigInteger b = fromHex("B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4");
346             byte[] S = Hex.decode("BD71344799D5C7FCDC45B59FA3B9AB8F6A948BC5");
347             BigInteger n = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D");
348             BigInteger h = BigInteger.valueOf(1);
349 
350             ECCurve curve = configureCurve(new ECCurve.Fp(p, a, b, n, h));
351             //ECPoint G = curve.decodePoint(Hex.decode("02"
352             //+ "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21"));
353             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
354                 + "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21"
355                 + "BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34"));
356 
357             return new X9ECParameters(curve, G, n, h, S);
358         }
359     };
360 
361     /*
362      * secp256k1
363      */
364     static X9ECParametersHolder secp256k1 = new X9ECParametersHolder()
365     {
366         protected X9ECParameters createParameters()
367         {
368             // p = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1
369             BigInteger p = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F");
370             BigInteger a = ECConstants.ZERO;
371             BigInteger b = BigInteger.valueOf(7);
372             byte[] S = null;
373             BigInteger n = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141");
374             BigInteger h = BigInteger.valueOf(1);
375 
376             GLVTypeBParameters glv = new GLVTypeBParameters(
377                 new BigInteger("7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", 16),
378                 new BigInteger("5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", 16),
379                 new BigInteger[]{
380                     new BigInteger("3086d221a7d46bcde86c90e49284eb15", 16),
381                     new BigInteger("-e4437ed6010e88286f547fa90abfe4c3", 16) },
382                 new BigInteger[]{
383                     new BigInteger("114ca50f7a8e2f3f657c1108d9d44cfd8", 16),
384                     new BigInteger("3086d221a7d46bcde86c90e49284eb15", 16) },
385                 new BigInteger("3086d221a7d46bcde86c90e49284eb153dab", 16),
386                 new BigInteger("e4437ed6010e88286f547fa90abfe4c42212", 16),
387                 272);
388 
389             ECCurve curve = configureCurveGLV(new ECCurve.Fp(p, a, b, n, h), glv);
390             //ECPoint G = curve.decodePoint(Hex.decode("02"
391             //+ "79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798"));
392             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
393                 + "79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798"
394                 + "483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8"));
395 
396             return new X9ECParameters(curve, G, n, h, S);
397         }
398     };
399 
400     /*
401      * secp256r1
402      */
403     static X9ECParametersHolder secp256r1 = new X9ECParametersHolder()
404     {
405         protected X9ECParameters createParameters()
406         {
407             // p = 2^224 (2^32 - 1) + 2^192 + 2^96 - 1
408             BigInteger p = fromHex("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF");
409             BigInteger a = fromHex("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC");
410             BigInteger b = fromHex("5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B");
411             byte[] S = Hex.decode("C49D360886E704936A6678E1139D26B7819F7E90");
412             BigInteger n = fromHex("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551");
413             BigInteger h = BigInteger.valueOf(1);
414 
415             ECCurve curve = configureCurve(new ECCurve.Fp(p, a, b, n, h));
416             //ECPoint G = curve.decodePoint(Hex.decode("03"
417             //+ "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296"));
418             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
419                 + "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296"
420                 + "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5"));
421 
422             return new X9ECParameters(curve, G, n, h, S);
423         }
424     };
425 
426     /*
427      * secp384r1
428      */
429     static X9ECParametersHolder secp384r1 = new X9ECParametersHolder()
430     {
431         protected X9ECParameters createParameters()
432         {
433             // p = 2^384 - 2^128 - 2^96 + 2^32 - 1
434             BigInteger p = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF");
435             BigInteger a = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC");
436             BigInteger b = fromHex("B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF");
437             byte[] S = Hex.decode("A335926AA319A27A1D00896A6773A4827ACDAC73");
438             BigInteger n = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973");
439             BigInteger h = BigInteger.valueOf(1);
440 
441             ECCurve curve = configureCurve(new ECCurve.Fp(p, a, b, n, h));
442             //ECPoint G = curve.decodePoint(Hex.decode("03"
443             //+ "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7"));
444             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
445                 + "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7"
446                 + "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F"));
447 
448             return new X9ECParameters(curve, G, n, h, S);
449         }
450     };
451 
452     /*
453      * secp521r1
454      */
455     static X9ECParametersHolder secp521r1 = new X9ECParametersHolder()
456     {
457         protected X9ECParameters createParameters()
458         {
459             // p = 2^521 - 1
460             BigInteger p = fromHex("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
461             BigInteger a = fromHex("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC");
462             BigInteger b = fromHex("0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00");
463             byte[] S = Hex.decode("D09E8800291CB85396CC6717393284AAA0DA64BA");
464             BigInteger n = fromHex("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409");
465             BigInteger h = BigInteger.valueOf(1);
466 
467             ECCurve curve = configureCurve(new ECCurve.Fp(p, a, b, n, h));
468 
469             //ECPoint G = curve.decodePoint(Hex.decode("02"
470             //+ "00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66"));
471             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
472                 + "00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66"
473                 + "011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650"));
474 
475             return new X9ECParameters(curve, G, n, h, S);
476         }
477     };
478 
479     /*
480      * sect113r1
481      */
482     static X9ECParametersHolder sect113r1 = new X9ECParametersHolder()
483     {
484         protected X9ECParameters createParameters()
485         {
486             int m = 113;
487             int k = 9;
488 
489             BigInteger a = fromHex("003088250CA6E7C7FE649CE85820F7");
490             BigInteger b = fromHex("00E8BEE4D3E2260744188BE0E9C723");
491             byte[] S = Hex.decode("10E723AB14D696E6768756151756FEBF8FCB49A9");
492             BigInteger n = fromHex("0100000000000000D9CCEC8A39E56F");
493             BigInteger h = BigInteger.valueOf(2);
494 
495             ECCurve curve = configureCurve(new ECCurve.F2m(m, k, a, b, n, h));
496             //ECPoint G = curve.decodePoint(Hex.decode("03"
497             //+ "009D73616F35F4AB1407D73562C10F"));
498             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
499                 + "009D73616F35F4AB1407D73562C10F"
500                 + "00A52830277958EE84D1315ED31886"));
501 
502             return new X9ECParameters(curve, G, n, h, S);
503         }
504     };
505 
506     /*
507      * sect113r2
508      */
509     static X9ECParametersHolder sect113r2 = new X9ECParametersHolder()
510     {
511         protected X9ECParameters createParameters()
512         {
513             int m = 113;
514             int k = 9;
515 
516             BigInteger a = fromHex("00689918DBEC7E5A0DD6DFC0AA55C7");
517             BigInteger b = fromHex("0095E9A9EC9B297BD4BF36E059184F");
518             byte[] S = Hex.decode("10C0FB15760860DEF1EEF4D696E676875615175D");
519             BigInteger n = fromHex("010000000000000108789B2496AF93");
520             BigInteger h = BigInteger.valueOf(2);
521 
522             ECCurve curve = configureCurve(new ECCurve.F2m(m, k, a, b, n, h));
523             //ECPoint G = curve.decodePoint(Hex.decode("03"
524             //+ "01A57A6A7B26CA5EF52FCDB8164797"));
525             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
526                 + "01A57A6A7B26CA5EF52FCDB8164797"
527                 + "00B3ADC94ED1FE674C06E695BABA1D"));
528 
529             return new X9ECParameters(curve, G, n, h, S);
530         }
531     };
532 
533     /*
534      * sect131r1
535      */
536     static X9ECParametersHolder sect131r1 = new X9ECParametersHolder()
537     {
538         protected X9ECParameters createParameters()
539         {
540             int m = 131;
541             int k1 = 2;
542             int k2 = 3;
543             int k3 = 8;
544 
545             BigInteger a = fromHex("07A11B09A76B562144418FF3FF8C2570B8");
546             BigInteger b = fromHex("0217C05610884B63B9C6C7291678F9D341");
547             byte[] S = Hex.decode("4D696E676875615175985BD3ADBADA21B43A97E2");
548             BigInteger n = fromHex("0400000000000000023123953A9464B54D");
549             BigInteger h = BigInteger.valueOf(2);
550 
551             ECCurve curve = configureCurve(new ECCurve.F2m(m, k1, k2, k3, a, b, n, h));
552             //ECPoint G = curve.decodePoint(Hex.decode("03"
553             //+ "0081BAF91FDF9833C40F9C181343638399"));
554             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
555                 + "0081BAF91FDF9833C40F9C181343638399"
556                 + "078C6E7EA38C001F73C8134B1B4EF9E150"));
557 
558             return new X9ECParameters(curve, G, n, h, S);
559         }
560     };
561 
562     /*
563      * sect131r2
564      */
565     static X9ECParametersHolder sect131r2 = new X9ECParametersHolder()
566     {
567         protected X9ECParameters createParameters()
568         {
569             int m = 131;
570             int k1 = 2;
571             int k2 = 3;
572             int k3 = 8;
573 
574             BigInteger a = fromHex("03E5A88919D7CAFCBF415F07C2176573B2");
575             BigInteger b = fromHex("04B8266A46C55657AC734CE38F018F2192");
576             byte[] S = Hex.decode("985BD3ADBAD4D696E676875615175A21B43A97E3");
577             BigInteger n = fromHex("0400000000000000016954A233049BA98F");
578             BigInteger h = BigInteger.valueOf(2);
579 
580             ECCurve curve = configureCurve(new ECCurve.F2m(m, k1, k2, k3, a, b, n, h));
581             //ECPoint G = curve.decodePoint(Hex.decode("03"
582             //+ "0356DCD8F2F95031AD652D23951BB366A8"));
583             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
584                 + "0356DCD8F2F95031AD652D23951BB366A8"
585                 + "0648F06D867940A5366D9E265DE9EB240F"));
586 
587             return new X9ECParameters(curve, G, n, h, S);
588         }
589     };
590 
591     /*
592      * sect163k1
593      */
594     static X9ECParametersHolder sect163k1 = new X9ECParametersHolder()
595     {
596         protected X9ECParameters createParameters()
597         {
598             int m = 163;
599             int k1 = 3;
600             int k2 = 6;
601             int k3 = 7;
602 
603             BigInteger a = BigInteger.valueOf(1);
604             BigInteger b = BigInteger.valueOf(1);
605             byte[] S = null;
606             BigInteger n = fromHex("04000000000000000000020108A2E0CC0D99F8A5EF");
607             BigInteger h = BigInteger.valueOf(2);
608 
609             ECCurve curve = configureCurve(new ECCurve.F2m(m, k1, k2, k3, a, b, n, h));
610             //ECPoint G = curve.decodePoint(Hex.decode("03"
611             //+ "02FE13C0537BBC11ACAA07D793DE4E6D5E5C94EEE8"));
612             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
613                 + "02FE13C0537BBC11ACAA07D793DE4E6D5E5C94EEE8"
614                 + "0289070FB05D38FF58321F2E800536D538CCDAA3D9"));
615 
616             return new X9ECParameters(curve, G, n, h, S);
617         }
618     };
619 
620     /*
621      * sect163r1
622      */
623     static X9ECParametersHolder sect163r1 = new X9ECParametersHolder()
624     {
625         protected X9ECParameters createParameters()
626         {
627             int m = 163;
628             int k1 = 3;
629             int k2 = 6;
630             int k3 = 7;
631 
632             BigInteger a = fromHex("07B6882CAAEFA84F9554FF8428BD88E246D2782AE2");
633             BigInteger b = fromHex("0713612DCDDCB40AAB946BDA29CA91F73AF958AFD9");
634             byte[] S = Hex.decode("24B7B137C8A14D696E6768756151756FD0DA2E5C");
635             BigInteger n = fromHex("03FFFFFFFFFFFFFFFFFFFF48AAB689C29CA710279B");
636             BigInteger h = BigInteger.valueOf(2);
637 
638             ECCurve curve = configureCurve(new ECCurve.F2m(m, k1, k2, k3, a, b, n, h));
639             //ECPoint G = curve.decodePoint(Hex.decode("03"
640             //+ "0369979697AB43897789566789567F787A7876A654"));
641             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
642                 + "0369979697AB43897789566789567F787A7876A654"
643                 + "00435EDB42EFAFB2989D51FEFCE3C80988F41FF883"));
644 
645             return new X9ECParameters(curve, G, n, h, S);
646         }
647     };
648 
649     /*
650      * sect163r2
651      */
652     static X9ECParametersHolder sect163r2 = new X9ECParametersHolder()
653     {
654         protected X9ECParameters createParameters()
655         {
656             int m = 163;
657             int k1 = 3;
658             int k2 = 6;
659             int k3 = 7;
660 
661             BigInteger a = BigInteger.valueOf(1);
662             BigInteger b = fromHex("020A601907B8C953CA1481EB10512F78744A3205FD");
663             byte[] S = Hex.decode("85E25BFE5C86226CDB12016F7553F9D0E693A268");
664             BigInteger n = fromHex("040000000000000000000292FE77E70C12A4234C33");
665             BigInteger h = BigInteger.valueOf(2);
666 
667             ECCurve curve = configureCurve(new ECCurve.F2m(m, k1, k2, k3, a, b, n, h));
668             //ECPoint G = curve.decodePoint(Hex.decode("03"
669             //+ "03F0EBA16286A2D57EA0991168D4994637E8343E36"));
670             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
671                 + "03F0EBA16286A2D57EA0991168D4994637E8343E36"
672                 + "00D51FBC6C71A0094FA2CDD545B11C5C0C797324F1"));
673 
674             return new X9ECParameters(curve, G, n, h, S);
675         }
676     };
677 
678     /*
679      * sect193r1
680      */
681     static X9ECParametersHolder sect193r1 = new X9ECParametersHolder()
682     {
683         protected X9ECParameters createParameters()
684         {
685             int m = 193;
686             int k = 15;
687 
688             BigInteger a = fromHex("0017858FEB7A98975169E171F77B4087DE098AC8A911DF7B01");
689             BigInteger b = fromHex("00FDFB49BFE6C3A89FACADAA7A1E5BBC7CC1C2E5D831478814");
690             byte[] S = Hex.decode("103FAEC74D696E676875615175777FC5B191EF30");
691             BigInteger n = fromHex("01000000000000000000000000C7F34A778F443ACC920EBA49");
692             BigInteger h = BigInteger.valueOf(2);
693 
694             ECCurve curve = configureCurve(new ECCurve.F2m(m, k, a, b, n, h));
695             //ECPoint G = curve.decodePoint(Hex.decode("03"
696             //+ "01F481BC5F0FF84A74AD6CDF6FDEF4BF6179625372D8C0C5E1"));
697             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
698                 + "01F481BC5F0FF84A74AD6CDF6FDEF4BF6179625372D8C0C5E1"
699                 + "0025E399F2903712CCF3EA9E3A1AD17FB0B3201B6AF7CE1B05"));
700 
701             return new X9ECParameters(curve, G, n, h, S);
702         }
703     };
704 
705     /*
706      * sect193r2
707      */
708     static X9ECParametersHolder sect193r2 = new X9ECParametersHolder()
709     {
710         protected X9ECParameters createParameters()
711         {
712             int m = 193;
713             int k = 15;
714 
715             BigInteger a = fromHex("0163F35A5137C2CE3EA6ED8667190B0BC43ECD69977702709B");
716             BigInteger b = fromHex("00C9BB9E8927D4D64C377E2AB2856A5B16E3EFB7F61D4316AE");
717             byte[] S = Hex.decode("10B7B4D696E676875615175137C8A16FD0DA2211");
718             BigInteger n = fromHex("010000000000000000000000015AAB561B005413CCD4EE99D5");
719             BigInteger h = BigInteger.valueOf(2);
720 
721             ECCurve curve = configureCurve(new ECCurve.F2m(m, k, a, b, n, h));
722             //ECPoint G = curve.decodePoint(Hex.decode("03"
723             //+ "00D9B67D192E0367C803F39E1A7E82CA14A651350AAE617E8F"));
724             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
725                 + "00D9B67D192E0367C803F39E1A7E82CA14A651350AAE617E8F"
726                 + "01CE94335607C304AC29E7DEFBD9CA01F596F927224CDECF6C"));
727 
728             return new X9ECParameters(curve, G, n, h, S);
729         }
730     };
731 
732     /*
733      * sect233k1
734      */
735     static X9ECParametersHolder sect233k1 = new X9ECParametersHolder()
736     {
737         protected X9ECParameters createParameters()
738         {
739             int m = 233;
740             int k = 74;
741 
742             BigInteger a = ECConstants.ZERO;
743             BigInteger b = BigInteger.valueOf(1);
744             byte[] S = null;
745             BigInteger n = fromHex("8000000000000000000000000000069D5BB915BCD46EFB1AD5F173ABDF");
746             BigInteger h = BigInteger.valueOf(4);
747 
748             ECCurve curve = configureCurve(new ECCurve.F2m(m, k, a, b, n, h));
749             //ECPoint G = curve.decodePoint(Hex.decode("02"
750             //+ "017232BA853A7E731AF129F22FF4149563A419C26BF50A4C9D6EEFAD6126"));
751             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
752                 + "017232BA853A7E731AF129F22FF4149563A419C26BF50A4C9D6EEFAD6126"
753                 + "01DB537DECE819B7F70F555A67C427A8CD9BF18AEB9B56E0C11056FAE6A3"));
754 
755             return new X9ECParameters(curve, G, n, h, S);
756         }
757     };
758 
759     /*
760      * sect233r1
761      */
762     static X9ECParametersHolder sect233r1 = new X9ECParametersHolder()
763     {
764         protected X9ECParameters createParameters()
765         {
766             int m = 233;
767             int k = 74;
768 
769             BigInteger a = BigInteger.valueOf(1);
770             BigInteger b = fromHex("0066647EDE6C332C7F8C0923BB58213B333B20E9CE4281FE115F7D8F90AD");
771             byte[] S = Hex.decode("74D59FF07F6B413D0EA14B344B20A2DB049B50C3");
772             BigInteger n = fromHex("01000000000000000000000000000013E974E72F8A6922031D2603CFE0D7");
773             BigInteger h = BigInteger.valueOf(2);
774 
775             ECCurve curve = configureCurve(new ECCurve.F2m(m, k, a, b, n, h));
776             //ECPoint G = curve.decodePoint(Hex.decode("03"
777             //+ "00FAC9DFCBAC8313BB2139F1BB755FEF65BC391F8B36F8F8EB7371FD558B"));
778             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
779                 + "00FAC9DFCBAC8313BB2139F1BB755FEF65BC391F8B36F8F8EB7371FD558B"
780                 + "01006A08A41903350678E58528BEBF8A0BEFF867A7CA36716F7E01F81052"));
781 
782             return new X9ECParameters(curve, G, n, h, S);
783         }
784     };
785 
786     /*
787      * sect239k1
788      */
789     static X9ECParametersHolder sect239k1 = new X9ECParametersHolder()
790     {
791         protected X9ECParameters createParameters()
792         {
793             int m = 239;
794             int k = 158;
795 
796             BigInteger a = ECConstants.ZERO;
797             BigInteger b = BigInteger.valueOf(1);
798             byte[] S = null;
799             BigInteger n = fromHex("2000000000000000000000000000005A79FEC67CB6E91F1C1DA800E478A5");
800             BigInteger h = BigInteger.valueOf(4);
801 
802             ECCurve curve = configureCurve(new ECCurve.F2m(m, k, a, b, n, h));
803             //ECPoint G = curve.decodePoint(Hex.decode("03"
804             //+ "29A0B6A887A983E9730988A68727A8B2D126C44CC2CC7B2A6555193035DC"));
805             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
806                 + "29A0B6A887A983E9730988A68727A8B2D126C44CC2CC7B2A6555193035DC"
807                 + "76310804F12E549BDB011C103089E73510ACB275FC312A5DC6B76553F0CA"));
808 
809             return new X9ECParameters(curve, G, n, h, S);
810         }
811     };
812 
813     /*
814      * sect283k1
815      */
816     static X9ECParametersHolder sect283k1 = new X9ECParametersHolder()
817     {
818         protected X9ECParameters createParameters()
819         {
820             int m = 283;
821             int k1 = 5;
822             int k2 = 7;
823             int k3 = 12;
824 
825             BigInteger a = ECConstants.ZERO;
826             BigInteger b = BigInteger.valueOf(1);
827             byte[] S = null;
828             BigInteger n = fromHex("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE9AE2ED07577265DFF7F94451E061E163C61");
829             BigInteger h = BigInteger.valueOf(4);
830 
831             ECCurve curve = configureCurve(new ECCurve.F2m(m, k1, k2, k3, a, b, n, h));
832             //ECPoint G = curve.decodePoint(Hex.decode("02"
833             //+ "0503213F78CA44883F1A3B8162F188E553CD265F23C1567A16876913B0C2AC2458492836"));
834             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
835                 + "0503213F78CA44883F1A3B8162F188E553CD265F23C1567A16876913B0C2AC2458492836"
836                 + "01CCDA380F1C9E318D90F95D07E5426FE87E45C0E8184698E45962364E34116177DD2259"));
837 
838             return new X9ECParameters(curve, G, n, h, S);
839         }
840     };
841 
842     /*
843      * sect283r1
844      */
845     static X9ECParametersHolder sect283r1 = new X9ECParametersHolder()
846     {
847         protected X9ECParameters createParameters()
848         {
849             int m = 283;
850             int k1 = 5;
851             int k2 = 7;
852             int k3 = 12;
853 
854             BigInteger a = BigInteger.valueOf(1);
855             BigInteger b = fromHex("027B680AC8B8596DA5A4AF8A19A0303FCA97FD7645309FA2A581485AF6263E313B79A2F5");
856             byte[] S = Hex.decode("77E2B07370EB0F832A6DD5B62DFC88CD06BB84BE");
857             BigInteger n = fromHex("03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF90399660FC938A90165B042A7CEFADB307");
858             BigInteger h = BigInteger.valueOf(2);
859 
860             ECCurve curve = configureCurve(new ECCurve.F2m(m, k1, k2, k3, a, b, n, h));
861             //ECPoint G = curve.decodePoint(Hex.decode("03"
862             //+ "05F939258DB7DD90E1934F8C70B0DFEC2EED25B8557EAC9C80E2E198F8CDBECD86B12053"));
863             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
864                 + "05F939258DB7DD90E1934F8C70B0DFEC2EED25B8557EAC9C80E2E198F8CDBECD86B12053"
865                 + "03676854FE24141CB98FE6D4B20D02B4516FF702350EDDB0826779C813F0DF45BE8112F4"));
866 
867             return new X9ECParameters(curve, G, n, h, S);
868         }
869     };
870 
871     /*
872      * sect409k1
873      */
874     static X9ECParametersHolder sect409k1 = new X9ECParametersHolder()
875     {
876         protected X9ECParameters createParameters()
877         {
878             int m = 409;
879             int k = 87;
880 
881             BigInteger a = ECConstants.ZERO;
882             BigInteger b = BigInteger.valueOf(1);
883             byte[] S = null;
884             BigInteger n = fromHex("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE5F83B2D4EA20400EC4557D5ED3E3E7CA5B4B5C83B8E01E5FCF");
885             BigInteger h = BigInteger.valueOf(4);
886 
887             ECCurve curve = configureCurve(new ECCurve.F2m(m, k, a, b, n, h));
888             //ECPoint G = curve.decodePoint(Hex.decode("03"
889             //+ "0060F05F658F49C1AD3AB1890F7184210EFD0987E307C84C27ACCFB8F9F67CC2C460189EB5AAAA62EE222EB1B35540CFE9023746"));
890             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
891                 + "0060F05F658F49C1AD3AB1890F7184210EFD0987E307C84C27ACCFB8F9F67CC2C460189EB5AAAA62EE222EB1B35540CFE9023746"
892                 + "01E369050B7C4E42ACBA1DACBF04299C3460782F918EA427E6325165E9EA10E3DA5F6C42E9C55215AA9CA27A5863EC48D8E0286B"));
893 
894             return new X9ECParameters(curve, G, n, h, S);
895         }
896     };
897 
898     /*
899      * sect409r1
900      */
901     static X9ECParametersHolder sect409r1 = new X9ECParametersHolder()
902     {
903         protected X9ECParameters createParameters()
904         {
905             int m = 409;
906             int k = 87;
907 
908             BigInteger a = BigInteger.valueOf(1);
909             BigInteger b = fromHex("0021A5C2C8EE9FEB5C4B9A753B7B476B7FD6422EF1F3DD674761FA99D6AC27C8A9A197B272822F6CD57A55AA4F50AE317B13545F");
910             byte[] S = Hex.decode("4099B5A457F9D69F79213D094C4BCD4D4262210B");
911             BigInteger n = fromHex("010000000000000000000000000000000000000000000000000001E2AAD6A612F33307BE5FA47C3C9E052F838164CD37D9A21173");
912             BigInteger h = BigInteger.valueOf(2);
913 
914             ECCurve curve = configureCurve(new ECCurve.F2m(m, k, a, b, n, h));
915             //ECPoint G = curve.decodePoint(Hex.decode("03"
916             //+ "015D4860D088DDB3496B0C6064756260441CDE4AF1771D4DB01FFE5B34E59703DC255A868A1180515603AEAB60794E54BB7996A7"));
917             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
918                 + "015D4860D088DDB3496B0C6064756260441CDE4AF1771D4DB01FFE5B34E59703DC255A868A1180515603AEAB60794E54BB7996A7"
919                 + "0061B1CFAB6BE5F32BBFA78324ED106A7636B9C5A7BD198D0158AA4F5488D08F38514F1FDF4B4F40D2181B3681C364BA0273C706"));
920 
921             return new X9ECParameters(curve, G, n, h, S);
922         }
923     };
924 
925     /*
926      * sect571k1
927      */
928     static X9ECParametersHolder sect571k1 = new X9ECParametersHolder()
929     {
930         protected X9ECParameters createParameters()
931         {
932             int m = 571;
933             int k1 = 2;
934             int k2 = 5;
935             int k3 = 10;
936 
937             BigInteger a = ECConstants.ZERO;
938             BigInteger b = BigInteger.valueOf(1);
939             byte[] S = null;
940             BigInteger n = fromHex("020000000000000000000000000000000000000000000000000000000000000000000000131850E1F19A63E4B391A8DB917F4138B630D84BE5D639381E91DEB45CFE778F637C1001");
941             BigInteger h = BigInteger.valueOf(4);
942 
943             ECCurve curve = configureCurve(new ECCurve.F2m(m, k1, k2, k3, a, b, n, h));
944             //ECPoint G = curve.decodePoint(Hex.decode("02"
945             //+ "026EB7A859923FBC82189631F8103FE4AC9CA2970012D5D46024804801841CA44370958493B205E647DA304DB4CEB08CBBD1BA39494776FB988B47174DCA88C7E2945283A01C8972"));
946             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
947                 + "026EB7A859923FBC82189631F8103FE4AC9CA2970012D5D46024804801841CA44370958493B205E647DA304DB4CEB08CBBD1BA39494776FB988B47174DCA88C7E2945283A01C8972"
948                 + "0349DC807F4FBF374F4AEADE3BCA95314DD58CEC9F307A54FFC61EFC006D8A2C9D4979C0AC44AEA74FBEBBB9F772AEDCB620B01A7BA7AF1B320430C8591984F601CD4C143EF1C7A3"));
949 
950             return new X9ECParameters(curve, G, n, h, S);
951         }
952     };
953 
954     /*
955      * sect571r1
956      */
957     static X9ECParametersHolder sect571r1 = new X9ECParametersHolder()
958     {
959         protected X9ECParameters createParameters()
960         {
961             int m = 571;
962             int k1 = 2;
963             int k2 = 5;
964             int k3 = 10;
965 
966             BigInteger a = BigInteger.valueOf(1);
967             BigInteger b = fromHex("02F40E7E2221F295DE297117B7F3D62F5C6A97FFCB8CEFF1CD6BA8CE4A9A18AD84FFABBD8EFA59332BE7AD6756A66E294AFD185A78FF12AA520E4DE739BACA0C7FFEFF7F2955727A");
968             byte[] S = Hex.decode("2AA058F73A0E33AB486B0F610410C53A7F132310");
969             BigInteger n = fromHex("03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE661CE18FF55987308059B186823851EC7DD9CA1161DE93D5174D66E8382E9BB2FE84E47");
970             BigInteger h = BigInteger.valueOf(2);
971 
972             ECCurve curve = configureCurve(new ECCurve.F2m(m, k1, k2, k3, a, b, n, h));
973             //ECPoint G = curve.decodePoint(Hex.decode("03"
974             //+ "0303001D34B856296C16C0D40D3CD7750A93D1D2955FA80AA5F40FC8DB7B2ABDBDE53950F4C0D293CDD711A35B67FB1499AE60038614F1394ABFA3B4C850D927E1E7769C8EEC2D19"));
975             X9ECPoint G = new X9ECPoint(curve, Hex.decode("04"
976                 + "0303001D34B856296C16C0D40D3CD7750A93D1D2955FA80AA5F40FC8DB7B2ABDBDE53950F4C0D293CDD711A35B67FB1499AE60038614F1394ABFA3B4C850D927E1E7769C8EEC2D19"
977                 + "037BF27342DA639B6DCCFFFEB73D69D78C6C27A6009CBBCA1980F8533921E8A684423E43BAB08A576291AF8F461BB2A8B3531D2F0485C19B16E2F1516E23DD3C1A4827AF1B8AC15B"));
978 
979             return new X9ECParameters(curve, G, n, h, S);
980         }
981     };
982 
983 
984     static final Hashtable objIds = new Hashtable();
985     static final Hashtable curves = new Hashtable();
986     static final Hashtable names = new Hashtable();
987 
defineCurve(String name, ASN1ObjectIdentifier oid, X9ECParametersHolder holder)988     static void defineCurve(String name, ASN1ObjectIdentifier oid, X9ECParametersHolder holder)
989     {
990         objIds.put(name, oid);
991         names.put(oid, name);
992         curves.put(oid, holder);
993     }
994 
995     static
996     {
997         defineCurve("secp112r1", SECObjectIdentifiers.secp112r1, secp112r1);
998         defineCurve("secp112r2", SECObjectIdentifiers.secp112r2, secp112r2);
999         defineCurve("secp128r1", SECObjectIdentifiers.secp128r1, secp128r1);
1000         defineCurve("secp128r2", SECObjectIdentifiers.secp128r2, secp128r2);
1001         defineCurve("secp160k1", SECObjectIdentifiers.secp160k1, secp160k1);
1002         defineCurve("secp160r1", SECObjectIdentifiers.secp160r1, secp160r1);
1003         defineCurve("secp160r2", SECObjectIdentifiers.secp160r2, secp160r2);
1004         defineCurve("secp192k1", SECObjectIdentifiers.secp192k1, secp192k1);
1005         defineCurve("secp192r1", SECObjectIdentifiers.secp192r1, secp192r1);
1006         defineCurve("secp224k1", SECObjectIdentifiers.secp224k1, secp224k1);
1007         defineCurve("secp224r1", SECObjectIdentifiers.secp224r1, secp224r1);
1008         defineCurve("secp256k1", SECObjectIdentifiers.secp256k1, secp256k1);
1009         defineCurve("secp256r1", SECObjectIdentifiers.secp256r1, secp256r1);
1010         defineCurve("secp384r1", SECObjectIdentifiers.secp384r1, secp384r1);
1011         defineCurve("secp521r1", SECObjectIdentifiers.secp521r1, secp521r1);
1012 
1013         defineCurve("sect113r1", SECObjectIdentifiers.sect113r1, sect113r1);
1014         defineCurve("sect113r2", SECObjectIdentifiers.sect113r2, sect113r2);
1015         defineCurve("sect131r1", SECObjectIdentifiers.sect131r1, sect131r1);
1016         defineCurve("sect131r2", SECObjectIdentifiers.sect131r2, sect131r2);
1017         defineCurve("sect163k1", SECObjectIdentifiers.sect163k1, sect163k1);
1018         defineCurve("sect163r1", SECObjectIdentifiers.sect163r1, sect163r1);
1019         defineCurve("sect163r2", SECObjectIdentifiers.sect163r2, sect163r2);
1020         defineCurve("sect193r1", SECObjectIdentifiers.sect193r1, sect193r1);
1021         defineCurve("sect193r2", SECObjectIdentifiers.sect193r2, sect193r2);
1022         defineCurve("sect233k1", SECObjectIdentifiers.sect233k1, sect233k1);
1023         defineCurve("sect233r1", SECObjectIdentifiers.sect233r1, sect233r1);
1024         defineCurve("sect239k1", SECObjectIdentifiers.sect239k1, sect239k1);
1025         defineCurve("sect283k1", SECObjectIdentifiers.sect283k1, sect283k1);
1026         defineCurve("sect283r1", SECObjectIdentifiers.sect283r1, sect283r1);
1027         defineCurve("sect409k1", SECObjectIdentifiers.sect409k1, sect409k1);
1028         defineCurve("sect409r1", SECObjectIdentifiers.sect409r1, sect409r1);
1029         defineCurve("sect571k1", SECObjectIdentifiers.sect571k1, sect571k1);
1030         defineCurve("sect571r1", SECObjectIdentifiers.sect571r1, sect571r1);
1031     }
1032 
getByName( String name)1033     public static X9ECParameters getByName(
1034         String name)
1035     {
1036         ASN1ObjectIdentifier oid = getOID(name);
1037         return oid == null ? null : getByOID(oid);
1038     }
1039 
1040     /**
1041      * return the X9ECParameters object for the named curve represented by
1042      * the passed in object identifier. Null if the curve isn't present.
1043      *
1044      * @param oid an object identifier representing a named curve, if present.
1045      */
getByOID( ASN1ObjectIdentifier oid)1046     public static X9ECParameters getByOID(
1047         ASN1ObjectIdentifier oid)
1048     {
1049         X9ECParametersHolder holder = (X9ECParametersHolder)curves.get(oid);
1050         return holder == null ? null : holder.getParameters();
1051     }
1052 
1053     /**
1054      * return the object identifier signified by the passed in name. Null
1055      * if there is no object identifier associated with name.
1056      *
1057      * @return the object identifier associated with name, if present.
1058      */
getOID( String name)1059     public static ASN1ObjectIdentifier getOID(
1060         String name)
1061     {
1062         return (ASN1ObjectIdentifier)objIds.get(Strings.toLowerCase(name));
1063     }
1064 
1065     /**
1066      * return the named curve name represented by the given object identifier.
1067      */
getName( ASN1ObjectIdentifier oid)1068     public static String getName(
1069         ASN1ObjectIdentifier oid)
1070     {
1071         return (String)names.get(oid);
1072     }
1073 
1074     /**
1075      * returns an enumeration containing the name strings for curves
1076      * contained in this structure.
1077      */
getNames()1078     public static Enumeration getNames()
1079     {
1080         return names.elements();
1081     }
1082 }
1083