summary refs log tree commit diff
path: root/crypto/src/asn1/x9/X962NamedCurves.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2019-09-09 15:52:36 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2019-09-09 15:52:36 +0700
commit71a58e93463e0a7e4f277069f9e133a98a9a8bcb (patch)
treeb14b3c28149ece39a59bf14d6f2d45bed7774dcd /crypto/src/asn1/x9/X962NamedCurves.cs
parentAdd sanity checks on scalar mult. outputs (diff)
downloadBouncyCastle.NET-ed25519-71a58e93463e0a7e4f277069f9e133a98a9a8bcb.tar.xz
Port of strict hex decoding from bc-java
Diffstat (limited to 'crypto/src/asn1/x9/X962NamedCurves.cs')
-rw-r--r--crypto/src/asn1/x9/X962NamedCurves.cs169
1 files changed, 87 insertions, 82 deletions
diff --git a/crypto/src/asn1/x9/X962NamedCurves.cs b/crypto/src/asn1/x9/X962NamedCurves.cs
index f8ba4144b..131e58ea3 100644
--- a/crypto/src/asn1/x9/X962NamedCurves.cs
+++ b/crypto/src/asn1/x9/X962NamedCurves.cs
@@ -21,7 +21,7 @@ namespace Org.BouncyCastle.Asn1.X9
 
         private static X9ECPoint ConfigureBasepoint(ECCurve curve, string encoding)
         {
-            X9ECPoint G = new X9ECPoint(curve, Hex.Decode(encoding));
+            X9ECPoint G = new X9ECPoint(curve, Hex.DecodeStrict(encoding));
             WNafUtilities.ConfigureBasepoint(G.Point);
             return G;
         }
@@ -31,6 +31,11 @@ namespace Org.BouncyCastle.Asn1.X9
             return curve;
         }
 
+        private static BigInteger FromHex(string hex)
+        {
+            return new BigInteger(1, Hex.DecodeStrict(hex));
+        }
+
         internal class Prime192v1Holder
             : X9ECParametersHolder
         {
@@ -40,19 +45,19 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("ffffffffffffffffffffffff99def836146bc9b1b4d22831", 16);
+                BigInteger n = FromHex("ffffffffffffffffffffffff99def836146bc9b1b4d22831");
                 BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF", 16),
-                    new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16),
-                    new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16),
+                    FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF"),
+                    FromHex("fffffffffffffffffffffffffffffffefffffffffffffffc"),
+                    FromHex("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012");
 
-                return new X9ECParameters(curve, G, n, h, Hex.Decode("3045AE6FC8422f64ED579528D38120EAE12196D5"));
+                return new X9ECParameters(curve, G, n, h, Hex.DecodeStrict("3045AE6FC8422f64ED579528D38120EAE12196D5"));
             }
         }
 
@@ -65,19 +70,19 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("fffffffffffffffffffffffe5fb1a724dc80418648d8dd31", 16);
+                BigInteger n = FromHex("fffffffffffffffffffffffe5fb1a724dc80418648d8dd31");
                 BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF", 16),
-                    new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16),
-                    new BigInteger("cc22d6dfb95c6b25e49c0d6364a4e5980c393aa21668d953", 16),
+                    FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF"),
+                    FromHex("fffffffffffffffffffffffffffffffefffffffffffffffc"),
+                    FromHex("cc22d6dfb95c6b25e49c0d6364a4e5980c393aa21668d953"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "03eea2bae7e1497842f2de7769cfe9c989c072ad696f48034a");
 
-                return new X9ECParameters(curve, G, n, h, Hex.Decode("31a92ee2029fd10d901b113e990710f0d21ac6b6"));
+                return new X9ECParameters(curve, G, n, h, Hex.DecodeStrict("31a92ee2029fd10d901b113e990710f0d21ac6b6"));
             }
         }
 
@@ -90,19 +95,19 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("ffffffffffffffffffffffff7a62d031c83f4294f640ec13", 16);
+                BigInteger n = FromHex("ffffffffffffffffffffffff7a62d031c83f4294f640ec13");
                 BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF", 16),
-                    new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16),
-                    new BigInteger("22123dc2395a05caa7423daeccc94760a7d462256bd56916", 16),
+                    FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF"),
+                    FromHex("fffffffffffffffffffffffffffffffefffffffffffffffc"),
+                    FromHex("22123dc2395a05caa7423daeccc94760a7d462256bd56916"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "027d29778100c65a1da1783716588dce2b8b4aee8e228f1896");
 
-                return new X9ECParameters(curve, G, n, h, Hex.Decode("c469684435deb378c4b65ca9591e2a5763059a2e"));
+                return new X9ECParameters(curve, G, n, h, Hex.DecodeStrict("c469684435deb378c4b65ca9591e2a5763059a2e"));
             }
         }
 
@@ -115,19 +120,19 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("7fffffffffffffffffffffff7fffff9e5e9a9f5d9071fbd1522688909d0b", 16);
+                BigInteger n = FromHex("7fffffffffffffffffffffff7fffff9e5e9a9f5d9071fbd1522688909d0b");
                 BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
                     new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"),
-                    new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16),
-                    new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16),
+                    FromHex("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc"),
+                    FromHex("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf");
 
-                return new X9ECParameters(curve, G, n, h, Hex.Decode("e43bb460f0b80cc0c0b075798e948060f8321b7d"));
+                return new X9ECParameters(curve, G, n, h, Hex.DecodeStrict("e43bb460f0b80cc0c0b075798e948060f8321b7d"));
             }
         }
 
@@ -140,19 +145,19 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("7fffffffffffffffffffffff800000cfa7e8594377d414c03821bc582063", 16);
+                BigInteger n = FromHex("7fffffffffffffffffffffff800000cfa7e8594377d414c03821bc582063");
                 BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
                     new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"),
-                    new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16),
-                    new BigInteger("617fab6832576cbbfed50d99f0249c3fee58b94ba0038c7ae84c8c832f2c", 16),
+                    FromHex("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc"),
+                    FromHex("617fab6832576cbbfed50d99f0249c3fee58b94ba0038c7ae84c8c832f2c"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "0238af09d98727705120c921bb5e9e26296a3cdcf2f35757a0eafd87b830e7");
 
-                return new X9ECParameters(curve, G, n, h, Hex.Decode("e8b4011604095303ca3b8099982be09fcb9ae616"));
+                return new X9ECParameters(curve, G, n, h, Hex.DecodeStrict("e8b4011604095303ca3b8099982be09fcb9ae616"));
             }
         }
 
@@ -165,19 +170,19 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("7fffffffffffffffffffffff7fffff975deb41b3a6057c3c432146526551", 16);
+                BigInteger n = FromHex("7fffffffffffffffffffffff7fffff975deb41b3a6057c3c432146526551");
                 BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
                     new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"),
-                    new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16),
-                    new BigInteger("255705fa2a306654b1f4cb03d6a750a30c250102d4988717d9ba15ab6d3e", 16),
+                    FromHex("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc"),
+                    FromHex("255705fa2a306654b1f4cb03d6a750a30c250102d4988717d9ba15ab6d3e"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "036768ae8e18bb92cfcf005c949aa2c6d94853d0e660bbf854b1c9505fe95a");
 
-                return new X9ECParameters(curve, G, n, h, Hex.Decode("7d7374168ffe3471b60a857686a19475d3bfa2ff"));
+                return new X9ECParameters(curve, G, n, h, Hex.DecodeStrict("7d7374168ffe3471b60a857686a19475d3bfa2ff"));
             }
         }
 
@@ -190,19 +195,19 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", 16);
+                BigInteger n = FromHex("ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551");
                 BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
                     new BigInteger("115792089210356248762697446949407573530086143415290314195533631308867097853951"),
-                    new BigInteger("ffffffff00000001000000000000000000000000fffffffffffffffffffffffc", 16),
-                    new BigInteger("5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", 16),
+                    FromHex("ffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),
+                    FromHex("5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "036b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296");
 
-                return new X9ECParameters(curve, G, n, h, Hex.Decode("c49d360886e704936a6678e1139d26b7819f7e90"));
+                return new X9ECParameters(curve, G, n, h, Hex.DecodeStrict("c49d360886e704936a6678e1139d26b7819f7e90"));
             }
         }
 
@@ -218,20 +223,20 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("0400000000000000000001E60FC8821CC74DAEAFC1", 16);
+                BigInteger n = FromHex("0400000000000000000001E60FC8821CC74DAEAFC1");
                 BigInteger h = BigInteger.Two;
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     163,
                     1, 2, 8,
-                    new BigInteger("072546B5435234A422E0789675F432C89435DE5242", 16),
-                    new BigInteger("00C9517D06D5240D3CFF38C74B20B6CD4D6F9DD4D9", 16),
+                    FromHex("072546B5435234A422E0789675F432C89435DE5242"),
+                    FromHex("00C9517D06D5240D3CFF38C74B20B6CD4D6F9DD4D9"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "0307AF69989546103D79329FCC3D74880F33BBE803CB");
 
-                return new X9ECParameters(curve, G, n, h, Hex.Decode("D2C0FB15760860DEF1EEF4D696E6768756151754"));
+                return new X9ECParameters(curve, G, n, h, Hex.DecodeStrict("D2C0FB15760860DEF1EEF4D696E6768756151754"));
             }
         }
 
@@ -244,14 +249,14 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("03FFFFFFFFFFFFFFFFFFFDF64DE1151ADBB78F10A7", 16);
+                BigInteger n = FromHex("03FFFFFFFFFFFFFFFFFFFDF64DE1151ADBB78F10A7");
                 BigInteger h = BigInteger.Two;
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     163,
                     1, 2, 8,
-                    new BigInteger("0108B39E77C4B108BED981ED0E890E117C511CF072", 16),
-                    new BigInteger("0667ACEB38AF4E488C407433FFAE4F1C811638DF20", 16),
+                    FromHex("0108B39E77C4B108BED981ED0E890E117C511CF072"),
+                    FromHex("0667ACEB38AF4E488C407433FFAE4F1C811638DF20"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -270,14 +275,14 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("03FFFFFFFFFFFFFFFFFFFE1AEE140F110AFF961309", 16);
+                BigInteger n = FromHex("03FFFFFFFFFFFFFFFFFFFE1AEE140F110AFF961309");
                 BigInteger h = BigInteger.Two;
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     163,
                     1, 2, 8,
-                    new BigInteger("07A526C63D3E25A256A007699F5447E32AE456B50E", 16),
-                    new BigInteger("03F7061798EB99E238FD6F1BF95B48FEEB4854252B", 16),
+                    FromHex("07A526C63D3E25A256A007699F5447E32AE456B50E"),
+                    FromHex("03F7061798EB99E238FD6F1BF95B48FEEB4854252B"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -296,14 +301,14 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("010092537397ECA4F6145799D62B0A19CE06FE26AD", 16);
+                BigInteger n = FromHex("010092537397ECA4F6145799D62B0A19CE06FE26AD");
                 BigInteger h = BigInteger.ValueOf(0xFF6E);
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     176,
                     1, 2, 43,
-                    new BigInteger("00E4E6DB2995065C407D9D39B8D0967B96704BA8E9C90B", 16),
-                    new BigInteger("005DDA470ABE6414DE8EC133AE28E9BBD7FCEC0AE0FFF2", 16),
+                    FromHex("E4E6DB2995065C407D9D39B8D0967B96704BA8E9C90B"),
+                    FromHex("5DDA470ABE6414DE8EC133AE28E9BBD7FCEC0AE0FFF2"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -322,20 +327,20 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("40000000000000000000000004A20E90C39067C893BBB9A5", 16);
+                BigInteger n = FromHex("40000000000000000000000004A20E90C39067C893BBB9A5");
                 BigInteger h = BigInteger.Two;
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     191,
                     9,
-                    new BigInteger("2866537B676752636A68F56554E12640276B649EF7526267", 16),
-                    new BigInteger("2E45EF571F00786F67B0081B9495A3D95462F5DE0AA185EC", 16),
+                    FromHex("2866537B676752636A68F56554E12640276B649EF7526267"),
+                    FromHex("2E45EF571F00786F67B0081B9495A3D95462F5DE0AA185EC"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "0236B3DAF8A23206F9C4F299D7B21A9C369137F2C84AE1AA0D");
 
-                return new X9ECParameters(curve, G, n, h, Hex.Decode("4E13CA542744D696E67687561517552F279A8C84"));
+                return new X9ECParameters(curve, G, n, h, Hex.DecodeStrict("4E13CA542744D696E67687561517552F279A8C84"));
             }
         }
 
@@ -348,14 +353,14 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("20000000000000000000000050508CB89F652824E06B8173", 16);
+                BigInteger n = FromHex("20000000000000000000000050508CB89F652824E06B8173");
                 BigInteger h = BigInteger.ValueOf(4);
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     191,
                     9,
-                    new BigInteger("401028774D7777C7B7666D1366EA432071274F89FF01E718", 16),
-                    new BigInteger("0620048D28BCBD03B6249C99182B7C8CD19700C362C46A01", 16),
+                    FromHex("401028774D7777C7B7666D1366EA432071274F89FF01E718"),
+                    FromHex("0620048D28BCBD03B6249C99182B7C8CD19700C362C46A01"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -374,14 +379,14 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("155555555555555555555555610C0B196812BFB6288A3EA3", 16);
+                BigInteger n = FromHex("155555555555555555555555610C0B196812BFB6288A3EA3");
                 BigInteger h = BigInteger.ValueOf(6);
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     191,
                     9,
-                    new BigInteger("6C01074756099122221056911C77D77E77A777E7E7E77FCB", 16),
-                    new BigInteger("71FE1AF926CF847989EFEF8DB459F66394D90F32AD3F15E8", 16),
+                    FromHex("6C01074756099122221056911C77D77E77A777E7E7E77FCB"),
+                    FromHex("71FE1AF926CF847989EFEF8DB459F66394D90F32AD3F15E8"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -400,14 +405,14 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("0101BAF95C9723C57B6C21DA2EFF2D5ED588BDD5717E212F9D", 16);
+                BigInteger n = FromHex("0101BAF95C9723C57B6C21DA2EFF2D5ED588BDD5717E212F9D");
                 BigInteger h = BigInteger.ValueOf(0xFE48);
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     208,
                     1, 2, 83,
-                    new BigInteger("0", 16),
-                    new BigInteger("00C8619ED45A62E6212E1160349E2BFA844439FAFC2A3FD1638F9E", 16),
+                    BigInteger.Zero,
+                    FromHex("C8619ED45A62E6212E1160349E2BFA844439FAFC2A3FD1638F9E"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -426,14 +431,14 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("2000000000000000000000000000000F4D42FFE1492A4993F1CAD666E447", 16);
+                BigInteger n = FromHex("2000000000000000000000000000000F4D42FFE1492A4993F1CAD666E447");
                 BigInteger h = BigInteger.ValueOf(4);
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     239,
                     36,
-                    new BigInteger("32010857077C5431123A46B808906756F543423E8D27877578125778AC76", 16),
-                    new BigInteger("790408F2EEDAF392B012EDEFB3392F30F4327C0CA3F31FC383C422AA8C16", 16),
+                    FromHex("32010857077C5431123A46B808906756F543423E8D27877578125778AC76"),
+                    FromHex("790408F2EEDAF392B012EDEFB3392F30F4327C0CA3F31FC383C422AA8C16"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -452,14 +457,14 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("1555555555555555555555555555553C6F2885259C31E3FCDF154624522D", 16);
+                BigInteger n = FromHex("1555555555555555555555555555553C6F2885259C31E3FCDF154624522D");
                 BigInteger h = BigInteger.ValueOf(6);
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     239,
                     36,
-                    new BigInteger("4230017757A767FAE42398569B746325D45313AF0766266479B75654E65F", 16),
-                    new BigInteger("5037EA654196CFF0CD82B2C14A2FCF2E3FF8775285B545722F03EACDB74B", 16),
+                    FromHex("4230017757A767FAE42398569B746325D45313AF0766266479B75654E65F"),
+                    FromHex("5037EA654196CFF0CD82B2C14A2FCF2E3FF8775285B545722F03EACDB74B"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -478,14 +483,14 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("0CCCCCCCCCCCCCCCCCCCCCCCCCCCCCAC4912D2D9DF903EF9888B8A0E4CFF", 16);
+                BigInteger n = FromHex("0CCCCCCCCCCCCCCCCCCCCCCCCCCCCCAC4912D2D9DF903EF9888B8A0E4CFF");
                 BigInteger h = BigInteger.ValueOf(10);
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     239,
                     36,
-                    new BigInteger("01238774666A67766D6676F778E676B66999176666E687666D8766C66A9F", 16),
-                    new BigInteger("6A941977BA9F6A435199ACFC51067ED587F519C5ECB541B8E44111DE1D40", 16),
+                    FromHex("01238774666A67766D6676F778E676B66999176666E687666D8766C66A9F"),
+                    FromHex("6A941977BA9F6A435199ACFC51067ED587F519C5ECB541B8E44111DE1D40"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -504,14 +509,14 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("0100FAF51354E0E39E4892DF6E319C72C8161603FA45AA7B998A167B8F1E629521", 16);
+                BigInteger n = FromHex("0100FAF51354E0E39E4892DF6E319C72C8161603FA45AA7B998A167B8F1E629521");
                 BigInteger h = BigInteger.ValueOf(0xFF06);
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     272,
                     1, 3, 56,
-                    new BigInteger("0091A091F03B5FBA4AB2CCF49C4EDD220FB028712D42BE752B2C40094DBACDB586FB20", 16),
-                    new BigInteger("7167EFC92BB2E3CE7C8AAAFF34E12A9C557003D7C73A6FAF003F99F6CC8482E540F7", 16),
+                    FromHex("91A091F03B5FBA4AB2CCF49C4EDD220FB028712D42BE752B2C40094DBACDB586FB20"),
+                    FromHex("7167EFC92BB2E3CE7C8AAAFF34E12A9C557003D7C73A6FAF003F99F6CC8482E540F7"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -530,14 +535,14 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("0101D556572AABAC800101D556572AABAC8001022D5C91DD173F8FB561DA6899164443051D", 16);
+                BigInteger n = FromHex("0101D556572AABAC800101D556572AABAC8001022D5C91DD173F8FB561DA6899164443051D");
                 BigInteger h = BigInteger.ValueOf(0xFE2E);
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     304,
                     1, 2, 11,
-                    new BigInteger("00FD0D693149A118F651E6DCE6802085377E5F882D1B510B44160074C1288078365A0396C8E681", 16),
-                    new BigInteger("00BDDB97E555A50A908E43B01C798EA5DAA6788F1EA2794EFCF57166B8C14039601E55827340BE", 16),
+                    FromHex("FD0D693149A118F651E6DCE6802085377E5F882D1B510B44160074C1288078365A0396C8E681"),
+                    FromHex("BDDB97E555A50A908E43B01C798EA5DAA6788F1EA2794EFCF57166B8C14039601E55827340BE"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -556,14 +561,14 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("01AF286BCA1AF286BCA1AF286BCA1AF286BCA1AF286BC9FB8F6B85C556892C20A7EB964FE7719E74F490758D3B", 16);
+                BigInteger n = FromHex("01AF286BCA1AF286BCA1AF286BCA1AF286BCA1AF286BC9FB8F6B85C556892C20A7EB964FE7719E74F490758D3B");
                 BigInteger h = BigInteger.ValueOf(0x4C);
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     359,
                     68,
-                    new BigInteger("5667676A654B20754F356EA92017D946567C46675556F19556A04616B567D223A5E05656FB549016A96656A557", 16),
-                    new BigInteger("2472E2D0197C49363F1FE7F5B6DB075D52B6947D135D8CA445805D39BC345626089687742B6329E70680231988", 16),
+                    FromHex("5667676A654B20754F356EA92017D946567C46675556F19556A04616B567D223A5E05656FB549016A96656A557"),
+                    FromHex("2472E2D0197C49363F1FE7F5B6DB075D52B6947D135D8CA445805D39BC345626089687742B6329E70680231988"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -582,14 +587,14 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("010090512DA9AF72B08349D98A5DD4C7B0532ECA51CE03E2D10F3B7AC579BD87E909AE40A6F131E9CFCE5BD967", 16);
+                BigInteger n = FromHex("010090512DA9AF72B08349D98A5DD4C7B0532ECA51CE03E2D10F3B7AC579BD87E909AE40A6F131E9CFCE5BD967");
                 BigInteger h = BigInteger.ValueOf(0xFF70);
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     368,
                     1, 2, 85,
-                    new BigInteger("00E0D2EE25095206F5E2A4F9ED229F1F256E79A0E2B455970D8D0D865BD94778C576D62F0AB7519CCD2A1A906AE30D", 16),
-                    new BigInteger("00FC1217D4320A90452C760A58EDCD30C8DD069B3C34453837A34ED50CB54917E1C2112D84D164F444F8F74786046A", 16),
+                    FromHex("E0D2EE25095206F5E2A4F9ED229F1F256E79A0E2B455970D8D0D865BD94778C576D62F0AB7519CCD2A1A906AE30D"),
+                    FromHex("FC1217D4320A90452C760A58EDCD30C8DD069B3C34453837A34ED50CB54917E1C2112D84D164F444F8F74786046A"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -608,14 +613,14 @@ namespace Org.BouncyCastle.Asn1.X9
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("0340340340340340340340340340340340340340340340340340340323C313FAB50589703B5EC68D3587FEC60D161CC149C1AD4A91", 16);
+                BigInteger n = FromHex("0340340340340340340340340340340340340340340340340340340323C313FAB50589703B5EC68D3587FEC60D161CC149C1AD4A91");
                 BigInteger h = BigInteger.ValueOf(0x2760);
 
                 ECCurve curve = ConfigureCurve(new F2mCurve(
                     431,
                     120,
-                    new BigInteger("1A827EF00DD6FC0E234CAF046C6A5D8A85395B236CC4AD2CF32A0CADBDC9DDF620B0EB9906D0957F6C6FEACD615468DF104DE296CD8F", 16),
-                    new BigInteger("10D9B4A3D9047D8B154359ABFB1B7F5485B04CEB868237DDC9DEDA982A679A5A919B626D4E50A8DD731B107A9962381FB5D807BF2618", 16),
+                    FromHex("1A827EF00DD6FC0E234CAF046C6A5D8A85395B236CC4AD2CF32A0CADBDC9DDF620B0EB9906D0957F6C6FEACD615468DF104DE296CD8F"),
+                    FromHex("10D9B4A3D9047D8B154359ABFB1B7F5485B04CEB868237DDC9DEDA982A679A5A919B626D4E50A8DD731B107A9962381FB5D807BF2618"),
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,