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