summary refs log tree commit diff
path: root/crypto/src/asn1
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
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')
-rw-r--r--crypto/src/asn1/anssi/ANSSINamedCurves.cs4
-rw-r--r--crypto/src/asn1/gm/GMNamedCurves.cs4
-rw-r--r--crypto/src/asn1/sec/SECNamedCurves.cs50
-rw-r--r--crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs161
-rw-r--r--crypto/src/asn1/x500/style/IetfUtilities.cs2
-rw-r--r--crypto/src/asn1/x509/X509Name.cs2
-rw-r--r--crypto/src/asn1/x509/X509NameEntryConverter.cs4
-rw-r--r--crypto/src/asn1/x9/X962NamedCurves.cs169
8 files changed, 202 insertions, 194 deletions
diff --git a/crypto/src/asn1/anssi/ANSSINamedCurves.cs b/crypto/src/asn1/anssi/ANSSINamedCurves.cs
index ce941709f..26222581e 100644
--- a/crypto/src/asn1/anssi/ANSSINamedCurves.cs
+++ b/crypto/src/asn1/anssi/ANSSINamedCurves.cs
@@ -15,7 +15,7 @@ namespace Org.BouncyCastle.Asn1.Anssi
     {
         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;
         }
@@ -27,7 +27,7 @@ namespace Org.BouncyCastle.Asn1.Anssi
 
         private static BigInteger FromHex(string hex)
         {
-            return new BigInteger(1, Hex.Decode(hex));
+            return new BigInteger(1, Hex.DecodeStrict(hex));
         }
 
         /*
diff --git a/crypto/src/asn1/gm/GMNamedCurves.cs b/crypto/src/asn1/gm/GMNamedCurves.cs
index 5b1072f8c..97485e258 100644
--- a/crypto/src/asn1/gm/GMNamedCurves.cs
+++ b/crypto/src/asn1/gm/GMNamedCurves.cs
@@ -20,7 +20,7 @@ namespace Org.BouncyCastle.Asn1.GM
 
         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;
         }
@@ -32,7 +32,7 @@ namespace Org.BouncyCastle.Asn1.GM
 
         private static BigInteger FromHex(string hex)
         {
-            return new BigInteger(1, Hex.Decode(hex));
+            return new BigInteger(1, Hex.DecodeStrict(hex));
         }
 
         /*
diff --git a/crypto/src/asn1/sec/SECNamedCurves.cs b/crypto/src/asn1/sec/SECNamedCurves.cs
index 44190d2b2..8ca0a6e21 100644
--- a/crypto/src/asn1/sec/SECNamedCurves.cs
+++ b/crypto/src/asn1/sec/SECNamedCurves.cs
@@ -21,7 +21,7 @@ namespace Org.BouncyCastle.Asn1.Sec
 
         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;
         }
@@ -38,7 +38,7 @@ namespace Org.BouncyCastle.Asn1.Sec
 
         private static BigInteger FromHex(string hex)
         {
-            return new BigInteger(1, Hex.Decode(hex));
+            return new BigInteger(1, Hex.DecodeStrict(hex));
         }
 
         /*
@@ -57,7 +57,7 @@ namespace Org.BouncyCastle.Asn1.Sec
                 BigInteger p = FromHex("DB7C2ABF62E35E668076BEAD208B");
                 BigInteger a = FromHex("DB7C2ABF62E35E668076BEAD2088");
                 BigInteger b = FromHex("659EF8BA043916EEDE8911702B22");
-                byte[] S = Hex.Decode("00F50B028E4D696E676875615175290472783FB1");
+                byte[] S = Hex.DecodeStrict("00F50B028E4D696E676875615175290472783FB1");
                 BigInteger n = FromHex("DB7C2ABF62E35E7628DFAC6561C5");
                 BigInteger h = BigInteger.One;
 
@@ -86,7 +86,7 @@ namespace Org.BouncyCastle.Asn1.Sec
                 BigInteger p = FromHex("DB7C2ABF62E35E668076BEAD208B");
                 BigInteger a = FromHex("6127C24C05F38A0AAAF65C0EF02C");
                 BigInteger b = FromHex("51DEF1815DB5ED74FCC34C85D709");
-                byte[] S = Hex.Decode("002757A1114D696E6768756151755316C05E0BD4");
+                byte[] S = Hex.DecodeStrict("002757A1114D696E6768756151755316C05E0BD4");
                 BigInteger n = FromHex("36DF0AAFD8B8D7597CA10520D04B");
                 BigInteger h = BigInteger.ValueOf(4);
 
@@ -115,7 +115,7 @@ namespace Org.BouncyCastle.Asn1.Sec
                 BigInteger p = FromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF");
                 BigInteger a = FromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC");
                 BigInteger b = FromHex("E87579C11079F43DD824993C2CEE5ED3");
-                byte[] S = Hex.Decode("000E0D4D696E6768756151750CC03A4473D03679");
+                byte[] S = Hex.DecodeStrict("000E0D4D696E6768756151750CC03A4473D03679");
                 BigInteger n = FromHex("FFFFFFFE0000000075A30D1B9038A115");
                 BigInteger h = BigInteger.One;
 
@@ -144,7 +144,7 @@ namespace Org.BouncyCastle.Asn1.Sec
                 BigInteger p = FromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF");
                 BigInteger a = FromHex("D6031998D1B3BBFEBF59CC9BBFF9AEE1");
                 BigInteger b = FromHex("5EEEFCA380D02919DC2C6558BB6D8A5D");
-                byte[] S = Hex.Decode("004D696E67687561517512D8F03431FCE63B88F4");
+                byte[] S = Hex.DecodeStrict("004D696E67687561517512D8F03431FCE63B88F4");
                 BigInteger n = FromHex("3FFFFFFF7FFFFFFFBE0024720613B5A3");
                 BigInteger h = BigInteger.ValueOf(4);
 
@@ -216,7 +216,7 @@ namespace Org.BouncyCastle.Asn1.Sec
                 BigInteger p = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF");
                 BigInteger a = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC");
                 BigInteger b = FromHex("1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45");
-                byte[] S = Hex.Decode("1053CDE42C14D696E67687561517533BF3F83345");
+                byte[] S = Hex.DecodeStrict("1053CDE42C14D696E67687561517533BF3F83345");
                 BigInteger n = FromHex("0100000000000000000001F4C8F927AED3CA752257");
                 BigInteger h = BigInteger.One;
 
@@ -245,7 +245,7 @@ namespace Org.BouncyCastle.Asn1.Sec
                 BigInteger p = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73");
                 BigInteger a = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC70");
                 BigInteger b = FromHex("B4E134D3FB59EB8BAB57274904664D5AF50388BA");
-                byte[] S = Hex.Decode("B99B99B099B323E02709A4D696E6768756151751");
+                byte[] S = Hex.DecodeStrict("B99B99B099B323E02709A4D696E6768756151751");
                 BigInteger n = FromHex("0100000000000000000000351EE786A818F3A1A16B");
                 BigInteger h = BigInteger.One;
 
@@ -317,7 +317,7 @@ namespace Org.BouncyCastle.Asn1.Sec
                 BigInteger p = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF");
                 BigInteger a = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC");
                 BigInteger b = FromHex("64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1");
-                byte[] S = Hex.Decode("3045AE6FC8422F64ED579528D38120EAE12196D5");
+                byte[] S = Hex.DecodeStrict("3045AE6FC8422F64ED579528D38120EAE12196D5");
                 BigInteger n = FromHex("FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831");
                 BigInteger h = BigInteger.One;
 
@@ -389,7 +389,7 @@ namespace Org.BouncyCastle.Asn1.Sec
                 BigInteger p = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001");
                 BigInteger a = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE");
                 BigInteger b = FromHex("B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4");
-                byte[] S = Hex.Decode("BD71344799D5C7FCDC45B59FA3B9AB8F6A948BC5");
+                byte[] S = Hex.DecodeStrict("BD71344799D5C7FCDC45B59FA3B9AB8F6A948BC5");
                 BigInteger n = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D");
                 BigInteger h = BigInteger.One;
 
@@ -461,7 +461,7 @@ namespace Org.BouncyCastle.Asn1.Sec
                 BigInteger p = FromHex("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF");
                 BigInteger a = FromHex("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC");
                 BigInteger b = FromHex("5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B");
-                byte[] S = Hex.Decode("C49D360886E704936A6678E1139D26B7819F7E90");
+                byte[] S = Hex.DecodeStrict("C49D360886E704936A6678E1139D26B7819F7E90");
                 BigInteger n = FromHex("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551");
                 BigInteger h = BigInteger.One;
 
@@ -490,7 +490,7 @@ namespace Org.BouncyCastle.Asn1.Sec
                 BigInteger p = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF");
                 BigInteger a = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC");
                 BigInteger b = FromHex("B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF");
-                byte[] S = Hex.Decode("A335926AA319A27A1D00896A6773A4827ACDAC73");
+                byte[] S = Hex.DecodeStrict("A335926AA319A27A1D00896A6773A4827ACDAC73");
                 BigInteger n = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973");
                 BigInteger h = BigInteger.One;
 
@@ -520,7 +520,7 @@ namespace Org.BouncyCastle.Asn1.Sec
                 BigInteger p = FromHex("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
                 BigInteger a = FromHex("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC");
                 BigInteger b = FromHex("0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00");
-                byte[] S = Hex.Decode("D09E8800291CB85396CC6717393284AAA0DA64BA");
+                byte[] S = Hex.DecodeStrict("D09E8800291CB85396CC6717393284AAA0DA64BA");
                 BigInteger n = FromHex("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409");
                 BigInteger h = BigInteger.One;
 
@@ -551,7 +551,7 @@ namespace Org.BouncyCastle.Asn1.Sec
             {
                 BigInteger a = FromHex("003088250CA6E7C7FE649CE85820F7");
                 BigInteger b = FromHex("00E8BEE4D3E2260744188BE0E9C723");
-                byte[] S = Hex.Decode("10E723AB14D696E6768756151756FEBF8FCB49A9");
+                byte[] S = Hex.DecodeStrict("10E723AB14D696E6768756151756FEBF8FCB49A9");
                 BigInteger n = FromHex("0100000000000000D9CCEC8A39E56F");
                 BigInteger h = BigInteger.ValueOf(2);
 
@@ -581,7 +581,7 @@ namespace Org.BouncyCastle.Asn1.Sec
             {
                 BigInteger a = FromHex("00689918DBEC7E5A0DD6DFC0AA55C7");
                 BigInteger b = FromHex("0095E9A9EC9B297BD4BF36E059184F");
-                byte[] S = Hex.Decode("10C0FB15760860DEF1EEF4D696E676875615175D");
+                byte[] S = Hex.DecodeStrict("10C0FB15760860DEF1EEF4D696E676875615175D");
                 BigInteger n = FromHex("010000000000000108789B2496AF93");
                 BigInteger h = BigInteger.ValueOf(2);
 
@@ -613,7 +613,7 @@ namespace Org.BouncyCastle.Asn1.Sec
             {
                 BigInteger a = FromHex("07A11B09A76B562144418FF3FF8C2570B8");
                 BigInteger b = FromHex("0217C05610884B63B9C6C7291678F9D341");
-                byte[] S = Hex.Decode("4D696E676875615175985BD3ADBADA21B43A97E2");
+                byte[] S = Hex.DecodeStrict("4D696E676875615175985BD3ADBADA21B43A97E2");
                 BigInteger n = FromHex("0400000000000000023123953A9464B54D");
                 BigInteger h = BigInteger.ValueOf(2);
 
@@ -645,7 +645,7 @@ namespace Org.BouncyCastle.Asn1.Sec
             {
                 BigInteger a = FromHex("03E5A88919D7CAFCBF415F07C2176573B2");
                 BigInteger b = FromHex("04B8266A46C55657AC734CE38F018F2192");
-                byte[] S = Hex.Decode("985BD3ADBAD4D696E676875615175A21B43A97E3");
+                byte[] S = Hex.DecodeStrict("985BD3ADBAD4D696E676875615175A21B43A97E3");
                 BigInteger n = FromHex("0400000000000000016954A233049BA98F");
                 BigInteger h = BigInteger.ValueOf(2);
 
@@ -709,7 +709,7 @@ namespace Org.BouncyCastle.Asn1.Sec
             {
                 BigInteger a = FromHex("07B6882CAAEFA84F9554FF8428BD88E246D2782AE2");
                 BigInteger b = FromHex("0713612DCDDCB40AAB946BDA29CA91F73AF958AFD9");
-                byte[] S = Hex.Decode("24B7B137C8A14D696E6768756151756FD0DA2E5C");
+                byte[] S = Hex.DecodeStrict("24B7B137C8A14D696E6768756151756FD0DA2E5C");
                 BigInteger n = FromHex("03FFFFFFFFFFFFFFFFFFFF48AAB689C29CA710279B");
                 BigInteger h = BigInteger.ValueOf(2);
 
@@ -741,7 +741,7 @@ namespace Org.BouncyCastle.Asn1.Sec
             {
                 BigInteger a = BigInteger.One;
                 BigInteger b = FromHex("020A601907B8C953CA1481EB10512F78744A3205FD");
-                byte[] S = Hex.Decode("85E25BFE5C86226CDB12016F7553F9D0E693A268");
+                byte[] S = Hex.DecodeStrict("85E25BFE5C86226CDB12016F7553F9D0E693A268");
                 BigInteger n = FromHex("040000000000000000000292FE77E70C12A4234C33");
                 BigInteger h = BigInteger.ValueOf(2);
 
@@ -771,7 +771,7 @@ namespace Org.BouncyCastle.Asn1.Sec
             {
                 BigInteger a = FromHex("0017858FEB7A98975169E171F77B4087DE098AC8A911DF7B01");
                 BigInteger b = FromHex("00FDFB49BFE6C3A89FACADAA7A1E5BBC7CC1C2E5D831478814");
-                byte[] S = Hex.Decode("103FAEC74D696E676875615175777FC5B191EF30");
+                byte[] S = Hex.DecodeStrict("103FAEC74D696E676875615175777FC5B191EF30");
                 BigInteger n = FromHex("01000000000000000000000000C7F34A778F443ACC920EBA49");
                 BigInteger h = BigInteger.ValueOf(2);
 
@@ -801,7 +801,7 @@ namespace Org.BouncyCastle.Asn1.Sec
             {
                 BigInteger a = FromHex("0163F35A5137C2CE3EA6ED8667190B0BC43ECD69977702709B");
                 BigInteger b = FromHex("00C9BB9E8927D4D64C377E2AB2856A5B16E3EFB7F61D4316AE");
-                byte[] S = Hex.Decode("10B7B4D696E676875615175137C8A16FD0DA2211");
+                byte[] S = Hex.DecodeStrict("10B7B4D696E676875615175137C8A16FD0DA2211");
                 BigInteger n = FromHex("010000000000000000000000015AAB561B005413CCD4EE99D5");
                 BigInteger h = BigInteger.ValueOf(2);
 
@@ -861,7 +861,7 @@ namespace Org.BouncyCastle.Asn1.Sec
             {
                 BigInteger a = BigInteger.One;
                 BigInteger b = FromHex("0066647EDE6C332C7F8C0923BB58213B333B20E9CE4281FE115F7D8F90AD");
-                byte[] S = Hex.Decode("74D59FF07F6B413D0EA14B344B20A2DB049B50C3");
+                byte[] S = Hex.DecodeStrict("74D59FF07F6B413D0EA14B344B20A2DB049B50C3");
                 BigInteger n = FromHex("01000000000000000000000000000013E974E72F8A6922031D2603CFE0D7");
                 BigInteger h = BigInteger.ValueOf(2);
 
@@ -956,7 +956,7 @@ namespace Org.BouncyCastle.Asn1.Sec
             {
                 BigInteger a = BigInteger.One;
                 BigInteger b = FromHex("027B680AC8B8596DA5A4AF8A19A0303FCA97FD7645309FA2A581485AF6263E313B79A2F5");
-                byte[] S = Hex.Decode("77E2B07370EB0F832A6DD5B62DFC88CD06BB84BE");
+                byte[] S = Hex.DecodeStrict("77E2B07370EB0F832A6DD5B62DFC88CD06BB84BE");
                 BigInteger n = FromHex("03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF90399660FC938A90165B042A7CEFADB307");
                 BigInteger h = BigInteger.ValueOf(2);
 
@@ -1018,7 +1018,7 @@ namespace Org.BouncyCastle.Asn1.Sec
             {
                 BigInteger a = BigInteger.One;
                 BigInteger b = FromHex("0021A5C2C8EE9FEB5C4B9A753B7B476B7FD6422EF1F3DD674761FA99D6AC27C8A9A197B272822F6CD57A55AA4F50AE317B13545F");
-                byte[] S = Hex.Decode("4099B5A457F9D69F79213D094C4BCD4D4262210B");
+                byte[] S = Hex.DecodeStrict("4099B5A457F9D69F79213D094C4BCD4D4262210B");
                 BigInteger n = FromHex("010000000000000000000000000000000000000000000000000001E2AAD6A612F33307BE5FA47C3C9E052F838164CD37D9A21173");
                 BigInteger h = BigInteger.ValueOf(2);
 
@@ -1084,7 +1084,7 @@ namespace Org.BouncyCastle.Asn1.Sec
             {
                 BigInteger a = BigInteger.One;
                 BigInteger b = FromHex("02F40E7E2221F295DE297117B7F3D62F5C6A97FFCB8CEFF1CD6BA8CE4A9A18AD84FFABBD8EFA59332BE7AD6756A66E294AFD185A78FF12AA520E4DE739BACA0C7FFEFF7F2955727A");
-                byte[] S = Hex.Decode("2AA058F73A0E33AB486B0F610410C53A7F132310");
+                byte[] S = Hex.DecodeStrict("2AA058F73A0E33AB486B0F610410C53A7F132310");
                 BigInteger n = FromHex("03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE661CE18FF55987308059B186823851EC7DD9CA1161DE93D5174D66E8382E9BB2FE84E47");
                 BigInteger h = BigInteger.ValueOf(2);
 
diff --git a/crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs b/crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs
index 8393f3ea5..c9a1e7d76 100644
--- a/crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs
+++ b/crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs
@@ -18,7 +18,7 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
     {
         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;
         }
@@ -28,6 +28,11 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
             return curve;
         }
 
+        private static BigInteger FromHex(string hex)
+        {
+            return new BigInteger(1, Hex.DecodeStrict(hex));
+        }
+
         internal class BrainpoolP160r1Holder
             : X9ECParametersHolder
         {
@@ -37,13 +42,13 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("E95E4A5F737059DC60DF5991D45029409E60FC09", 16);
-                BigInteger h = new BigInteger("01", 16);
+                BigInteger n = FromHex("E95E4A5F737059DC60DF5991D45029409E60FC09");
+                BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    new BigInteger("E95E4A5F737059DC60DFC7AD95B3D8139515620F", 16), // q
-                    new BigInteger("340E7BE2A280EB74E2BE61BADA745D97E8F7C300", 16), // a
-                    new BigInteger("1E589A8595423412134FAA2DBDEC95C8D8675E58", 16), // b
+                    FromHex("E95E4A5F737059DC60DFC7AD95B3D8139515620F"), // q
+                    FromHex("340E7BE2A280EB74E2BE61BADA745D97E8F7C300"), // a
+                    FromHex("1E589A8595423412134FAA2DBDEC95C8D8675E58"), // b
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -62,14 +67,14 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("E95E4A5F737059DC60DF5991D45029409E60FC09", 16);
-                BigInteger h = new BigInteger("01", 16);
+                BigInteger n = FromHex("E95E4A5F737059DC60DF5991D45029409E60FC09");
+                BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    //new BigInteger("24DBFF5DEC9B986BBFE5295A29BFBAE45E0F5D0B", 16), // Z
-                    new BigInteger("E95E4A5F737059DC60DFC7AD95B3D8139515620F", 16), // q
-                    new BigInteger("E95E4A5F737059DC60DFC7AD95B3D8139515620C", 16), // a'
-                    new BigInteger("7A556B6DAE535B7B51ED2C4D7DAA7A0B5C55F380", 16), // b'
+                    //FromHex("24DBFF5DEC9B986BBFE5295A29BFBAE45E0F5D0B"), // Z
+                    FromHex("E95E4A5F737059DC60DFC7AD95B3D8139515620F"), // q
+                    FromHex("E95E4A5F737059DC60DFC7AD95B3D8139515620C"), // a
+                    FromHex("7A556B6DAE535B7B51ED2C4D7DAA7A0B5C55F380"), // b
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -88,13 +93,13 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1", 16);
-                BigInteger h = new BigInteger("01", 16);
+                BigInteger n = FromHex("C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1");
+                BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    new BigInteger("C302F41D932A36CDA7A3463093D18DB78FCE476DE1A86297", 16), // q
-                    new BigInteger("6A91174076B1E0E19C39C031FE8685C1CAE040E5C69A28EF", 16), // a
-                    new BigInteger("469A28EF7C28CCA3DC721D044F4496BCCA7EF4146FBF25C9", 16), // b
+                    FromHex("C302F41D932A36CDA7A3463093D18DB78FCE476DE1A86297"), // q
+                    FromHex("6A91174076B1E0E19C39C031FE8685C1CAE040E5C69A28EF"), // a
+                    FromHex("469A28EF7C28CCA3DC721D044F4496BCCA7EF4146FBF25C9"), // b
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -113,14 +118,14 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1", 16);
-                BigInteger h = new BigInteger("01", 16);
+                BigInteger n = FromHex("C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1");
+                BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    //new BigInteger("1B6F5CC8DB4DC7AF19458A9CB80DC2295E5EB9C3732104CB") //Z
-                    new BigInteger("C302F41D932A36CDA7A3463093D18DB78FCE476DE1A86297", 16), // q
-                    new BigInteger("C302F41D932A36CDA7A3463093D18DB78FCE476DE1A86294", 16), // a'
-                    new BigInteger("13D56FFAEC78681E68F9DEB43B35BEC2FB68542E27897B79", 16), // b'
+                    //FromHex("1B6F5CC8DB4DC7AF19458A9CB80DC2295E5EB9C3732104CB") // Z
+                    FromHex("C302F41D932A36CDA7A3463093D18DB78FCE476DE1A86297"), // q
+                    FromHex("C302F41D932A36CDA7A3463093D18DB78FCE476DE1A86294"), // a
+                    FromHex("13D56FFAEC78681E68F9DEB43B35BEC2FB68542E27897B79"), // b
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -139,13 +144,13 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F", 16);
-                BigInteger h = new BigInteger("01", 16);
+                BigInteger n = FromHex("D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F");
+                BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    new BigInteger("D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FF", 16), // q
-                    new BigInteger("68A5E62CA9CE6C1C299803A6C1530B514E182AD8B0042A59CAD29F43", 16), // a
-                    new BigInteger("2580F63CCFE44138870713B1A92369E33E2135D266DBB372386C400B", 16), // b
+                    FromHex("D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FF"), // q
+                    FromHex("68A5E62CA9CE6C1C299803A6C1530B514E182AD8B0042A59CAD29F43"), // a
+                    FromHex("2580F63CCFE44138870713B1A92369E33E2135D266DBB372386C400B"), // b
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -164,14 +169,14 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F", 16);
-                BigInteger h = new BigInteger("01", 16);
+                BigInteger n = FromHex("D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F");
+                BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    //new BigInteger("2DF271E14427A346910CF7A2E6CFA7B3F484E5C2CCE1C8B730E28B3F") //Z
-                    new BigInteger("D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FF", 16), // q
-                    new BigInteger("D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FC", 16), // a'
-                    new BigInteger("4B337D934104CD7BEF271BF60CED1ED20DA14C08B3BB64F18A60888D", 16), // b'
+                    //FromHex("2DF271E14427A346910CF7A2E6CFA7B3F484E5C2CCE1C8B730E28B3F") // Z
+                    FromHex("D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FF"), // q
+                    FromHex("D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FC"), // a
+                    FromHex("4B337D934104CD7BEF271BF60CED1ED20DA14C08B3BB64F18A60888D"), // b
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -190,13 +195,13 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("A9FB57DBA1EEA9BC3E660A909D838D718C397AA3B561A6F7901E0E82974856A7", 16);
-                BigInteger h = new BigInteger("01", 16);
+                BigInteger n = FromHex("A9FB57DBA1EEA9BC3E660A909D838D718C397AA3B561A6F7901E0E82974856A7");
+                BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    new BigInteger("A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E5377", 16), // q
-                    new BigInteger("7D5A0975FC2C3057EEF67530417AFFE7FB8055C126DC5C6CE94A4B44F330B5D9", 16), // a
-                    new BigInteger("26DC5C6CE94A4B44F330B5D9BBD77CBF958416295CF7E1CE6BCCDC18FF8C07B6", 16), // b
+                    FromHex("A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E5377"), // q
+                    FromHex("7D5A0975FC2C3057EEF67530417AFFE7FB8055C126DC5C6CE94A4B44F330B5D9"), // a
+                    FromHex("26DC5C6CE94A4B44F330B5D9BBD77CBF958416295CF7E1CE6BCCDC18FF8C07B6"), // b
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -215,14 +220,14 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("A9FB57DBA1EEA9BC3E660A909D838D718C397AA3B561A6F7901E0E82974856A7", 16);
-                BigInteger h = new BigInteger("01", 16);
+                BigInteger n = FromHex("A9FB57DBA1EEA9BC3E660A909D838D718C397AA3B561A6F7901E0E82974856A7");
+                BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    //new BigInteger("3E2D4BD9597B58639AE7AA669CAB9837CF5CF20A2C852D10F655668DFC150EF0") //Z
-                    new BigInteger("A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E5377", 16), // q
-                    new BigInteger("A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E5374", 16), // a'
-                    new BigInteger("662C61C430D84EA4FE66A7733D0B76B7BF93EBC4AF2F49256AE58101FEE92B04", 16), // b'
+                    //FromHex("3E2D4BD9597B58639AE7AA669CAB9837CF5CF20A2C852D10F655668DFC150EF0") // Z
+                    FromHex("A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E5377"), // q
+                    FromHex("A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E5374"), // a
+                    FromHex("662C61C430D84EA4FE66A7733D0B76B7BF93EBC4AF2F49256AE58101FEE92B04"), // b
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -241,13 +246,13 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D482EC7EE8658E98691555B44C59311", 16);
-                BigInteger h = new BigInteger("01", 16);
+                BigInteger n = FromHex("D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D482EC7EE8658E98691555B44C59311");
+                BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    new BigInteger("D35E472036BC4FB7E13C785ED201E065F98FCFA6F6F40DEF4F92B9EC7893EC28FCD412B1F1B32E27", 16), // q
-                    new BigInteger("3EE30B568FBAB0F883CCEBD46D3F3BB8A2A73513F5EB79DA66190EB085FFA9F492F375A97D860EB4", 16), // a
-                    new BigInteger("520883949DFDBC42D3AD198640688A6FE13F41349554B49ACC31DCCD884539816F5EB4AC8FB1F1A6", 16), // b
+                    FromHex("D35E472036BC4FB7E13C785ED201E065F98FCFA6F6F40DEF4F92B9EC7893EC28FCD412B1F1B32E27"), // q
+                    FromHex("3EE30B568FBAB0F883CCEBD46D3F3BB8A2A73513F5EB79DA66190EB085FFA9F492F375A97D860EB4"), // a
+                    FromHex("520883949DFDBC42D3AD198640688A6FE13F41349554B49ACC31DCCD884539816F5EB4AC8FB1F1A6"), // b
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -266,14 +271,14 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D482EC7EE8658E98691555B44C59311", 16);
-                BigInteger h = new BigInteger("01", 16);
+                BigInteger n = FromHex("D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D482EC7EE8658E98691555B44C59311");
+                BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    //new BigInteger("15F75CAF668077F7E85B42EB01F0A81FF56ECD6191D55CB82B7D861458A18FEFC3E5AB7496F3C7B1") //Z
-                    new BigInteger("D35E472036BC4FB7E13C785ED201E065F98FCFA6F6F40DEF4F92B9EC7893EC28FCD412B1F1B32E27", 16), // q
-                    new BigInteger("D35E472036BC4FB7E13C785ED201E065F98FCFA6F6F40DEF4F92B9EC7893EC28FCD412B1F1B32E24", 16), // a'
-                    new BigInteger("A7F561E038EB1ED560B3D147DB782013064C19F27ED27C6780AAF77FB8A547CEB5B4FEF422340353", 16), // b'
+                    //FromHex("15F75CAF668077F7E85B42EB01F0A81FF56ECD6191D55CB82B7D861458A18FEFC3E5AB7496F3C7B1") // Z
+                    FromHex("D35E472036BC4FB7E13C785ED201E065F98FCFA6F6F40DEF4F92B9EC7893EC28FCD412B1F1B32E27"), // q
+                    FromHex("D35E472036BC4FB7E13C785ED201E065F98FCFA6F6F40DEF4F92B9EC7893EC28FCD412B1F1B32E24"), // a
+                    FromHex("A7F561E038EB1ED560B3D147DB782013064C19F27ED27C6780AAF77FB8A547CEB5B4FEF422340353"), // b
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -292,13 +297,13 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC3103B883202E9046565", 16);
-                BigInteger h = new BigInteger("01", 16);
+                BigInteger n = FromHex("8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC3103B883202E9046565");
+                BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    new BigInteger("8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A71874700133107EC53", 16), // q
-                    new BigInteger("7BC382C63D8C150C3C72080ACE05AFA0C2BEA28E4FB22787139165EFBA91F90F8AA5814A503AD4EB04A8C7DD22CE2826", 16), // a
-                    new BigInteger("4A8C7DD22CE28268B39B55416F0447C2FB77DE107DCD2A62E880EA53EEB62D57CB4390295DBC9943AB78696FA504C11", 16), // b
+                    FromHex("8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A71874700133107EC53"), // q
+                    FromHex("7BC382C63D8C150C3C72080ACE05AFA0C2BEA28E4FB22787139165EFBA91F90F8AA5814A503AD4EB04A8C7DD22CE2826"), // a
+                    FromHex("04A8C7DD22CE28268B39B55416F0447C2FB77DE107DCD2A62E880EA53EEB62D57CB4390295DBC9943AB78696FA504C11"), // b
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -317,14 +322,14 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC3103B883202E9046565", 16);
-                BigInteger h = new BigInteger("01", 16);
+                BigInteger n = FromHex("8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC3103B883202E9046565");
+                BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    //new BigInteger("41DFE8DD399331F7166A66076734A89CD0D2BCDB7D068E44E1F378F41ECBAE97D2D63DBC87BCCDDCCC5DA39E8589291C") //Z
-                    new BigInteger("8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A71874700133107EC53", 16), // q
-                    new BigInteger("8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A71874700133107EC50", 16), // a'
-                    new BigInteger("7F519EADA7BDA81BD826DBA647910F8C4B9346ED8CCDC64E4B1ABD11756DCE1D2074AA263B88805CED70355A33B471EE", 16), // b'
+                    //FromHex("41DFE8DD399331F7166A66076734A89CD0D2BCDB7D068E44E1F378F41ECBAE97D2D63DBC87BCCDDCCC5DA39E8589291C") // Z
+                    FromHex("8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A71874700133107EC53"), // q
+                    FromHex("8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A71874700133107EC50"), // a
+                    FromHex("7F519EADA7BDA81BD826DBA647910F8C4B9346ED8CCDC64E4B1ABD11756DCE1D2074AA263B88805CED70355A33B471EE"), // b
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -343,13 +348,13 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA92619418661197FAC10471DB1D381085DDADDB58796829CA90069", 16);
-                BigInteger h = new BigInteger("01", 16);
+                BigInteger n = FromHex("AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA92619418661197FAC10471DB1D381085DDADDB58796829CA90069");
+                BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    new BigInteger("AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3", 16), // q
-                    new BigInteger("7830A3318B603B89E2327145AC234CC594CBDD8D3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CA", 16), // a
-                    new BigInteger("3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CADC083E67984050B75EBAE5DD2809BD638016F723", 16), // b
+                    FromHex("AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3"), // q
+                    FromHex("7830A3318B603B89E2327145AC234CC594CBDD8D3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CA"), // a
+                    FromHex("3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CADC083E67984050B75EBAE5DD2809BD638016F723"), // b
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
@@ -368,14 +373,14 @@ namespace Org.BouncyCastle.Asn1.TeleTrust
 
             protected override X9ECParameters CreateParameters()
             {
-                BigInteger n = new BigInteger("AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA92619418661197FAC10471DB1D381085DDADDB58796829CA90069", 16);
-                BigInteger h = new BigInteger("01", 16);
+                BigInteger n = FromHex("AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA92619418661197FAC10471DB1D381085DDADDB58796829CA90069");
+                BigInteger h = BigInteger.One;
 
                 ECCurve curve = ConfigureCurve(new FpCurve(
-                    //new BigInteger("12EE58E6764838B69782136F0F2D3BA06E27695716054092E60A80BEDB212B64E585D90BCE13761F85C3F1D2A64E3BE8FEA2220F01EBA5EEB0F35DBD29D922AB") //Z
-                    new BigInteger("AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3", 16), // q
-                    new BigInteger("AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F0", 16), // a'
-                    new BigInteger("7CBBBCF9441CFAB76E1890E46884EAE321F70C0BCB4981527897504BEC3E36A62BCDFA2304976540F6450085F2DAE145C22553B465763689180EA2571867423E", 16), // b'
+                    //FromHex("12EE58E6764838B69782136F0F2D3BA06E27695716054092E60A80BEDB212B64E585D90BCE13761F85C3F1D2A64E3BE8FEA2220F01EBA5EEB0F35DBD29D922AB") // Z
+                    FromHex("AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3"), // q
+                    FromHex("AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F0"), // a
+                    FromHex("7CBBBCF9441CFAB76E1890E46884EAE321F70C0BCB4981527897504BEC3E36A62BCDFA2304976540F6450085F2DAE145C22553B465763689180EA2571867423E"), // b
                     n, h));
 
                 X9ECPoint G = ConfigureBasepoint(curve,
diff --git a/crypto/src/asn1/x500/style/IetfUtilities.cs b/crypto/src/asn1/x500/style/IetfUtilities.cs
index 2c0ab45bc..53e5fccf4 100644
--- a/crypto/src/asn1/x500/style/IetfUtilities.cs
+++ b/crypto/src/asn1/x500/style/IetfUtilities.cs
@@ -138,7 +138,7 @@ namespace Org.BouncyCastle.Asn1.X500.Style
         {
             try
             {
-                return Asn1Object.FromByteArray(Hex.Decode(oValue.Substring(1)));
+                return Asn1Object.FromByteArray(Hex.DecodeStrict(oValue, 1, oValue.Length - 1));
             }
             catch (IOException e)
             {
diff --git a/crypto/src/asn1/x509/X509Name.cs b/crypto/src/asn1/x509/X509Name.cs
index aa46caaac..c3c3cc6c9 100644
--- a/crypto/src/asn1/x509/X509Name.cs
+++ b/crypto/src/asn1/x509/X509Name.cs
@@ -928,7 +928,7 @@ namespace Org.BouncyCastle.Asn1.X509
         {
             try
             {
-                return Asn1Object.FromByteArray(Hex.Decode(v.Substring(1)));
+                return Asn1Object.FromByteArray(Hex.DecodeStrict(v, 1, v.Length - 1));
             }
             catch (IOException e)
             {
diff --git a/crypto/src/asn1/x509/X509NameEntryConverter.cs b/crypto/src/asn1/x509/X509NameEntryConverter.cs
index 5872656a9..a5a00cc59 100644
--- a/crypto/src/asn1/x509/X509NameEntryConverter.cs
+++ b/crypto/src/asn1/x509/X509NameEntryConverter.cs
@@ -61,9 +61,7 @@ namespace Org.BouncyCastle.Asn1.X509
             string	hexString,
             int		offset)
         {
-			string str = hexString.Substring(offset);
-
-			return Asn1Object.FromByteArray(Hex.Decode(str));
+            return Asn1Object.FromByteArray(Hex.DecodeStrict(hexString, offset, hexString.Length - offset));
         }
 
 		/**
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,