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