summary refs log tree commit diff
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
parentAdd sanity checks on scalar mult. outputs (diff)
downloadBouncyCastle.NET-ed25519-71a58e93463e0a7e4f277069f9e133a98a9a8bcb.tar.xz
Port of strict hex decoding from bc-java
-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
-rw-r--r--crypto/src/crypto/agreement/DHStandardGroups.cs2
-rw-r--r--crypto/src/crypto/agreement/srp/SRP6StandardGroups.cs2
-rw-r--r--crypto/src/crypto/ec/CustomNamedCurves.cs44
-rw-r--r--crypto/src/crypto/generators/DsaParametersGenerator.cs2
-rw-r--r--crypto/src/crypto/prng/drbg/CtrSP800Drbg.cs2
-rw-r--r--crypto/src/crypto/signers/SM2Signer.cs2
-rw-r--r--crypto/src/crypto/tls/TlsDHUtilities.cs2
-rw-r--r--crypto/src/math/ec/custom/djb/Curve25519.cs6
-rw-r--r--crypto/src/math/ec/custom/gm/SM2P256V1Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/gm/SM2P256V1FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP128R1Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecP128R1FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP160K1Curve.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP160R1Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecP160R1FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP160R2Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecP160R2FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP192K1Curve.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP192K1FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP192R1Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecP192R1FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP224K1Curve.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP224K1FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP224R1Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecP224R1FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP256K1Curve.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP256K1FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP256R1Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecP256R1FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP384R1Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecP384R1FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecP521R1Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecP521R1FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecT113R1Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecT113R2Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecT131R1Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecT131R2Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecT163K1Curve.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecT163R1Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecT163R2Curve.cs4
-rw-r--r--crypto/src/math/ec/custom/sec/SecT193R1Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecT193R2Curve.cs6
-rw-r--r--crypto/src/math/ec/custom/sec/SecT233K1Curve.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecT233R1Curve.cs4
-rw-r--r--crypto/src/math/ec/custom/sec/SecT239K1Curve.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecT283K1Curve.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecT283R1Curve.cs4
-rw-r--r--crypto/src/math/ec/custom/sec/SecT409K1Curve.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecT409R1Curve.cs4
-rw-r--r--crypto/src/math/ec/custom/sec/SecT571K1Curve.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecT571R1Curve.cs4
-rw-r--r--crypto/src/util/encoders/Hex.cs24
-rw-r--r--crypto/src/util/encoders/HexEncoder.cs26
61 files changed, 362 insertions, 306 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,
diff --git a/crypto/src/crypto/agreement/DHStandardGroups.cs b/crypto/src/crypto/agreement/DHStandardGroups.cs
index 0143c6325..59f1ae72b 100644
--- a/crypto/src/crypto/agreement/DHStandardGroups.cs
+++ b/crypto/src/crypto/agreement/DHStandardGroups.cs
@@ -11,7 +11,7 @@ namespace Org.BouncyCastle.Crypto.Agreement
     {
         private static BigInteger FromHex(string hex)
         {
-            return new BigInteger(1, Hex.Decode(hex));
+            return new BigInteger(1, Hex.DecodeStrict(hex));
         }
 
         private static DHParameters FromPG(string hexP, string hexG)
diff --git a/crypto/src/crypto/agreement/srp/SRP6StandardGroups.cs b/crypto/src/crypto/agreement/srp/SRP6StandardGroups.cs
index 36f4aba11..464777d2a 100644
--- a/crypto/src/crypto/agreement/srp/SRP6StandardGroups.cs
+++ b/crypto/src/crypto/agreement/srp/SRP6StandardGroups.cs
@@ -10,7 +10,7 @@ namespace Org.BouncyCastle.Crypto.Agreement.Srp
     {
         private static BigInteger FromHex(string hex)
         {
-            return new BigInteger(1, Hex.Decode(hex));
+            return new BigInteger(1, Hex.DecodeStrict(hex));
         }
 
         private static Srp6GroupParameters FromNG(string hexN, string hexG)
diff --git a/crypto/src/crypto/ec/CustomNamedCurves.cs b/crypto/src/crypto/ec/CustomNamedCurves.cs
index a9f60dd8c..a508a4252 100644
--- a/crypto/src/crypto/ec/CustomNamedCurves.cs
+++ b/crypto/src/crypto/ec/CustomNamedCurves.cs
@@ -26,7 +26,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
         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;
         }
@@ -43,7 +43,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
         private static BigInteger FromHex(string hex)
         {
-            return new BigInteger(1, Hex.Decode(hex));
+            return new BigInteger(1, Hex.DecodeStrict(hex));
         }
 
         /*
@@ -89,7 +89,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("000E0D4D696E6768756151750CC03A4473D03679");
+                byte[] S = Hex.DecodeStrict("000E0D4D696E6768756151750CC03A4473D03679");
                 ECCurve curve = ConfigureCurve(new SecP128R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "04161FF7528B899B2D0C28607CA52C5B86CF5AC8395BAFEB13C02DA292DDED7A83"); 
@@ -142,7 +142,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("1053CDE42C14D696E67687561517533BF3F83345");
+                byte[] S = Hex.DecodeStrict("1053CDE42C14D696E67687561517533BF3F83345");
                 ECCurve curve = ConfigureCurve(new SecP160R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "044A96B5688EF573284664698968C38BB913CBFC8223A628553168947D59DCC912042351377AC5FB32"); 
@@ -162,7 +162,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("B99B99B099B323E02709A4D696E6768756151751");
+                byte[] S = Hex.DecodeStrict("B99B99B099B323E02709A4D696E6768756151751");
                 ECCurve curve = ConfigureCurve(new SecP160R2Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "0452DCB034293A117E1F4FF11B30F7199D3144CE6DFEAFFEF2E331F296E071FA0DF9982CFEA7D43F2E"); 
@@ -215,7 +215,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("3045AE6FC8422F64ED579528D38120EAE12196D5");
+                byte[] S = Hex.DecodeStrict("3045AE6FC8422F64ED579528D38120EAE12196D5");
                 ECCurve curve = ConfigureCurve(new SecP192R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "04188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF101207192B95FFC8DA78631011ED6B24CDD573F977A11E794811"); 
@@ -268,7 +268,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("BD71344799D5C7FCDC45B59FA3B9AB8F6A948BC5");
+                byte[] S = Hex.DecodeStrict("BD71344799D5C7FCDC45B59FA3B9AB8F6A948BC5");
                 ECCurve curve = ConfigureCurve(new SecP224R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "04B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34"); 
@@ -321,7 +321,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("C49D360886E704936A6678E1139D26B7819F7E90");
+                byte[] S = Hex.DecodeStrict("C49D360886E704936A6678E1139D26B7819F7E90");
                 ECCurve curve = ConfigureCurve(new SecP256R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "046B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C2964FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5"); 
@@ -341,7 +341,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("A335926AA319A27A1D00896A6773A4827ACDAC73");
+                byte[] S = Hex.DecodeStrict("A335926AA319A27A1D00896A6773A4827ACDAC73");
                 ECCurve curve = ConfigureCurve(new SecP384R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve, "04"
                     + "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7"
@@ -362,7 +362,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("D09E8800291CB85396CC6717393284AAA0DA64BA");
+                byte[] S = Hex.DecodeStrict("D09E8800291CB85396CC6717393284AAA0DA64BA");
                 ECCurve curve = ConfigureCurve(new SecP521R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve, "04"
                     + "00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66"
@@ -383,7 +383,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("10E723AB14D696E6768756151756FEBF8FCB49A9");
+                byte[] S = Hex.DecodeStrict("10E723AB14D696E6768756151756FEBF8FCB49A9");
                 ECCurve curve = ConfigureCurve(new SecT113R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "04009D73616F35F4AB1407D73562C10F00A52830277958EE84D1315ED31886"); 
@@ -403,7 +403,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("10C0FB15760860DEF1EEF4D696E676875615175D");
+                byte[] S = Hex.DecodeStrict("10C0FB15760860DEF1EEF4D696E676875615175D");
                 ECCurve curve = ConfigureCurve(new SecT113R2Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "0401A57A6A7B26CA5EF52FCDB816479700B3ADC94ED1FE674C06E695BABA1D"); 
@@ -423,7 +423,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("4D696E676875615175985BD3ADBADA21B43A97E2");
+                byte[] S = Hex.DecodeStrict("4D696E676875615175985BD3ADBADA21B43A97E2");
                 ECCurve curve = ConfigureCurve(new SecT131R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "040081BAF91FDF9833C40F9C181343638399078C6E7EA38C001F73C8134B1B4EF9E150"); 
@@ -443,7 +443,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("985BD3ADBAD4D696E676875615175A21B43A97E3");
+                byte[] S = Hex.DecodeStrict("985BD3ADBAD4D696E676875615175A21B43A97E3");
                 ECCurve curve = ConfigureCurve(new SecT131R2Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "040356DCD8F2F95031AD652D23951BB366A80648F06D867940A5366D9E265DE9EB240F"); 
@@ -483,7 +483,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("24B7B137C8A14D696E6768756151756FD0DA2E5C");
+                byte[] S = Hex.DecodeStrict("24B7B137C8A14D696E6768756151756FD0DA2E5C");
                 ECCurve curve = ConfigureCurve(new SecT163R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "040369979697AB43897789566789567F787A7876A65400435EDB42EFAFB2989D51FEFCE3C80988F41FF883"); 
@@ -503,7 +503,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("85E25BFE5C86226CDB12016F7553F9D0E693A268");
+                byte[] S = Hex.DecodeStrict("85E25BFE5C86226CDB12016F7553F9D0E693A268");
                 ECCurve curve = ConfigureCurve(new SecT163R2Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "0403F0EBA16286A2D57EA0991168D4994637E8343E3600D51FBC6C71A0094FA2CDD545B11C5C0C797324F1"); 
@@ -523,7 +523,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("103FAEC74D696E676875615175777FC5B191EF30");
+                byte[] S = Hex.DecodeStrict("103FAEC74D696E676875615175777FC5B191EF30");
                 ECCurve curve = ConfigureCurve(new SecT193R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "0401F481BC5F0FF84A74AD6CDF6FDEF4BF6179625372D8C0C5E10025E399F2903712CCF3EA9E3A1AD17FB0B3201B6AF7CE1B05"); 
@@ -543,7 +543,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("10B7B4D696E676875615175137C8A16FD0DA2211");
+                byte[] S = Hex.DecodeStrict("10B7B4D696E676875615175137C8A16FD0DA2211");
                 ECCurve curve = ConfigureCurve(new SecT193R2Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "0400D9B67D192E0367C803F39E1A7E82CA14A651350AAE617E8F01CE94335607C304AC29E7DEFBD9CA01F596F927224CDECF6C"); 
@@ -583,7 +583,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("74D59FF07F6B413D0EA14B344B20A2DB049B50C3");
+                byte[] S = Hex.DecodeStrict("74D59FF07F6B413D0EA14B344B20A2DB049B50C3");
                 ECCurve curve = ConfigureCurve(new SecT233R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve,
                     "0400FAC9DFCBAC8313BB2139F1BB755FEF65BC391F8B36F8F8EB7371FD558B01006A08A41903350678E58528BEBF8A0BEFF867A7CA36716F7E01F81052"); 
@@ -644,7 +644,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("77E2B07370EB0F832A6DD5B62DFC88CD06BB84BE");
+                byte[] S = Hex.DecodeStrict("77E2B07370EB0F832A6DD5B62DFC88CD06BB84BE");
                 ECCurve curve = ConfigureCurve(new SecT283R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve, "04"
                     + "05F939258DB7DD90E1934F8C70B0DFEC2EED25B8557EAC9C80E2E198F8CDBECD86B12053"
@@ -686,7 +686,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("4099B5A457F9D69F79213D094C4BCD4D4262210B");
+                byte[] S = Hex.DecodeStrict("4099B5A457F9D69F79213D094C4BCD4D4262210B");
                 ECCurve curve = ConfigureCurve(new SecT409R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve, "04"
                     + "015D4860D088DDB3496B0C6064756260441CDE4AF1771D4DB01FFE5B34E59703DC255A868A1180515603AEAB60794E54BB7996A7"
@@ -728,7 +728,7 @@ namespace Org.BouncyCastle.Crypto.EC
 
             protected override X9ECParameters CreateParameters()
             {
-                byte[] S = Hex.Decode("2AA058F73A0E33AB486B0F610410C53A7F132310");
+                byte[] S = Hex.DecodeStrict("2AA058F73A0E33AB486B0F610410C53A7F132310");
                 ECCurve curve = ConfigureCurve(new SecT571R1Curve());
                 X9ECPoint G = ConfigureBasepoint(curve, "04"
                     + "0303001D34B856296C16C0D40D3CD7750A93D1D2955FA80AA5F40FC8DB7B2ABDBDE53950F4C0D293CDD711A35B67FB1499AE60038614F1394ABFA3B4C850D927E1E7769C8EEC2D19"
diff --git a/crypto/src/crypto/generators/DsaParametersGenerator.cs b/crypto/src/crypto/generators/DsaParametersGenerator.cs
index d7ae3ec54..97c20d1d9 100644
--- a/crypto/src/crypto/generators/DsaParametersGenerator.cs
+++ b/crypto/src/crypto/generators/DsaParametersGenerator.cs
@@ -300,7 +300,7 @@ namespace Org.BouncyCastle.Crypto.Generators
         {
             // A.2.3 Verifiable Canonical Generation of the Generator g
             BigInteger e = p.Subtract(BigInteger.One).Divide(q);
-            byte[] ggen = Hex.Decode("6767656E");
+            byte[] ggen = Hex.DecodeStrict("6767656E");
 
             // 7. U = domain_parameter_seed || "ggen" || index || count.
             byte[] U = new byte[seed.Length + ggen.Length + 1 + 2];
diff --git a/crypto/src/crypto/prng/drbg/CtrSP800Drbg.cs b/crypto/src/crypto/prng/drbg/CtrSP800Drbg.cs
index eca1821d3..5715a915e 100644
--- a/crypto/src/crypto/prng/drbg/CtrSP800Drbg.cs
+++ b/crypto/src/crypto/prng/drbg/CtrSP800Drbg.cs
@@ -148,7 +148,7 @@ namespace Org.BouncyCastle.Crypto.Prng.Drbg
 
 	    // -- Internal state migration ---
 
-        private static readonly byte[] K_BITS = Hex.Decode("000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F");
+        private static readonly byte[] K_BITS = Hex.DecodeStrict("000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F");
 
         // 1. If (number_of_bits_to_return > max_number_of_bits), then return an
 	    // ERROR_FLAG.
diff --git a/crypto/src/crypto/signers/SM2Signer.cs b/crypto/src/crypto/signers/SM2Signer.cs
index 56ec17cf3..2597cbf3d 100644
--- a/crypto/src/crypto/signers/SM2Signer.cs
+++ b/crypto/src/crypto/signers/SM2Signer.cs
@@ -66,7 +66,7 @@ namespace Org.BouncyCastle.Crypto.Signers
             {
                 baseParam = parameters;
                 // the default value, string value is "1234567812345678"
-                userID = Hex.Decode("31323334353637383132333435363738");
+                userID = Hex.DecodeStrict("31323334353637383132333435363738");
             }
 
             if (forSigning)
diff --git a/crypto/src/crypto/tls/TlsDHUtilities.cs b/crypto/src/crypto/tls/TlsDHUtilities.cs
index ec5909f48..59006018e 100644
--- a/crypto/src/crypto/tls/TlsDHUtilities.cs
+++ b/crypto/src/crypto/tls/TlsDHUtilities.cs
@@ -21,7 +21,7 @@ namespace Org.BouncyCastle.Crypto.Tls
          */
         private static BigInteger FromHex(String hex)
         {
-            return new BigInteger(1, Hex.Decode(hex));
+            return new BigInteger(1, Hex.DecodeStrict(hex));
         }
 
         private static DHParameters FromSafeP(String hexP)
diff --git a/crypto/src/math/ec/custom/djb/Curve25519.cs b/crypto/src/math/ec/custom/djb/Curve25519.cs
index 190edf6ec..f9a1b450c 100644
--- a/crypto/src/math/ec/custom/djb/Curve25519.cs
+++ b/crypto/src/math/ec/custom/djb/Curve25519.cs
@@ -10,8 +10,8 @@ namespace Org.BouncyCastle.Math.EC.Custom.Djb
     {
         public static readonly BigInteger q = Curve25519FieldElement.Q;
 
-        private static readonly BigInteger C_a = new BigInteger(1, Hex.Decode("2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA984914A144"));
-        private static readonly BigInteger C_b = new BigInteger(1, Hex.Decode("7B425ED097B425ED097B425ED097B425ED097B425ED097B4260B5E9C7710C864"));
+        private static readonly BigInteger C_a = new BigInteger(1, Hex.DecodeStrict("2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA984914A144"));
+        private static readonly BigInteger C_b = new BigInteger(1, Hex.DecodeStrict("7B425ED097B425ED097B425ED097B425ED097B425ED097B4260B5E9C7710C864"));
 
         private const int CURVE25519_DEFAULT_COORDS = COORD_JACOBIAN_MODIFIED;
         private const int CURVE25519_FE_INTS = 8;
@@ -26,7 +26,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Djb
 
             this.m_a = FromBigInteger(C_a);
             this.m_b = FromBigInteger(C_b);
-            this.m_order = new BigInteger(1, Hex.Decode("1000000000000000000000000000000014DEF9DEA2F79CD65812631A5CF5D3ED"));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("1000000000000000000000000000000014DEF9DEA2F79CD65812631A5CF5D3ED"));
             this.m_cofactor = BigInteger.ValueOf(8);
             this.m_coord = CURVE25519_DEFAULT_COORDS;
         }
diff --git a/crypto/src/math/ec/custom/gm/SM2P256V1Curve.cs b/crypto/src/math/ec/custom/gm/SM2P256V1Curve.cs
index 4978a2beb..3135cbb06 100644
--- a/crypto/src/math/ec/custom/gm/SM2P256V1Curve.cs
+++ b/crypto/src/math/ec/custom/gm/SM2P256V1Curve.cs
@@ -22,10 +22,10 @@ namespace Org.BouncyCastle.Math.EC.Custom.GM
             this.m_infinity = new SM2P256V1Point(this, null, null);
 
             this.m_a = FromBigInteger(new BigInteger(1,
-                Hex.Decode("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC")));
+                Hex.DecodeStrict("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC")));
             this.m_b = FromBigInteger(new BigInteger(1,
-                Hex.Decode("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93")));
-            this.m_order = new BigInteger(1, Hex.Decode("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123"));
+                Hex.DecodeStrict("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123"));
             this.m_cofactor = BigInteger.One;
             this.m_coord = SM2P256V1_DEFAULT_COORDS;
         }
diff --git a/crypto/src/math/ec/custom/gm/SM2P256V1FieldElement.cs b/crypto/src/math/ec/custom/gm/SM2P256V1FieldElement.cs
index a1f675f90..a9331eb52 100644
--- a/crypto/src/math/ec/custom/gm/SM2P256V1FieldElement.cs
+++ b/crypto/src/math/ec/custom/gm/SM2P256V1FieldElement.cs
@@ -10,7 +10,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.GM
         : AbstractFpFieldElement
     {
         public static readonly BigInteger Q = new BigInteger(1,
-            Hex.Decode("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF"));
+            Hex.DecodeStrict("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF"));
 
         protected internal readonly uint[] x;
 
diff --git a/crypto/src/math/ec/custom/sec/SecP128R1Curve.cs b/crypto/src/math/ec/custom/sec/SecP128R1Curve.cs
index 58bff2390..e92aca75b 100644
--- a/crypto/src/math/ec/custom/sec/SecP128R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecP128R1Curve.cs
@@ -22,10 +22,10 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             this.m_infinity = new SecP128R1Point(this, null, null);
 
             this.m_a = FromBigInteger(new BigInteger(1,
-                Hex.Decode("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC")));
+                Hex.DecodeStrict("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC")));
             this.m_b = FromBigInteger(new BigInteger(1,
-                Hex.Decode("E87579C11079F43DD824993C2CEE5ED3")));
-            this.m_order = new BigInteger(1, Hex.Decode("FFFFFFFE0000000075A30D1B9038A115"));
+                Hex.DecodeStrict("E87579C11079F43DD824993C2CEE5ED3")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("FFFFFFFE0000000075A30D1B9038A115"));
             this.m_cofactor = BigInteger.One;
 
             this.m_coord = SECP128R1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecP128R1FieldElement.cs b/crypto/src/math/ec/custom/sec/SecP128R1FieldElement.cs
index 04f432ced..8ddabe9a7 100644
--- a/crypto/src/math/ec/custom/sec/SecP128R1FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecP128R1FieldElement.cs
@@ -10,7 +10,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         : AbstractFpFieldElement
     {
         public static readonly BigInteger Q = new BigInteger(1,
-            Hex.Decode("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF"));
+            Hex.DecodeStrict("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF"));
 
         protected internal readonly uint[] x;
 
diff --git a/crypto/src/math/ec/custom/sec/SecP160K1Curve.cs b/crypto/src/math/ec/custom/sec/SecP160K1Curve.cs
index 1b5bbfe96..fbc928ab7 100644
--- a/crypto/src/math/ec/custom/sec/SecP160K1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecP160K1Curve.cs
@@ -23,7 +23,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
             this.m_a = FromBigInteger(BigInteger.Zero);
             this.m_b = FromBigInteger(BigInteger.ValueOf(7));
-            this.m_order = new BigInteger(1, Hex.Decode("0100000000000000000001B8FA16DFAB9ACA16B6B3"));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("0100000000000000000001B8FA16DFAB9ACA16B6B3"));
             this.m_cofactor = BigInteger.One;
             this.m_coord = SECP160K1_DEFAULT_COORDS;
         }
diff --git a/crypto/src/math/ec/custom/sec/SecP160R1Curve.cs b/crypto/src/math/ec/custom/sec/SecP160R1Curve.cs
index 42f2f467b..39855c549 100644
--- a/crypto/src/math/ec/custom/sec/SecP160R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecP160R1Curve.cs
@@ -22,10 +22,10 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             this.m_infinity = new SecP160R1Point(this, null, null);
 
             this.m_a = FromBigInteger(new BigInteger(1,
-                Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC")));
+                Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC")));
             this.m_b = FromBigInteger(new BigInteger(1,
-                Hex.Decode("1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45")));
-            this.m_order = new BigInteger(1, Hex.Decode("0100000000000000000001F4C8F927AED3CA752257"));
+                Hex.DecodeStrict("1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("0100000000000000000001F4C8F927AED3CA752257"));
             this.m_cofactor = BigInteger.One;
 
             this.m_coord = SECP160R1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecP160R1FieldElement.cs b/crypto/src/math/ec/custom/sec/SecP160R1FieldElement.cs
index 5365d7cd0..eade0b8e9 100644
--- a/crypto/src/math/ec/custom/sec/SecP160R1FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecP160R1FieldElement.cs
@@ -10,7 +10,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         : AbstractFpFieldElement
     {
         public static readonly BigInteger Q = new BigInteger(1,
-            Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF"));
+            Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF"));
 
         protected internal readonly uint[] x;
 
diff --git a/crypto/src/math/ec/custom/sec/SecP160R2Curve.cs b/crypto/src/math/ec/custom/sec/SecP160R2Curve.cs
index 17f73d7ce..c8ac2e0ab 100644
--- a/crypto/src/math/ec/custom/sec/SecP160R2Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecP160R2Curve.cs
@@ -22,10 +22,10 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             this.m_infinity = new SecP160R2Point(this, null, null);
 
             this.m_a = FromBigInteger(new BigInteger(1,
-                Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC70")));
+                Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC70")));
             this.m_b = FromBigInteger(new BigInteger(1,
-                Hex.Decode("B4E134D3FB59EB8BAB57274904664D5AF50388BA")));
-            this.m_order = new BigInteger(1, Hex.Decode("0100000000000000000000351EE786A818F3A1A16B"));
+                Hex.DecodeStrict("B4E134D3FB59EB8BAB57274904664D5AF50388BA")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("0100000000000000000000351EE786A818F3A1A16B"));
             this.m_cofactor = BigInteger.One;
 
             this.m_coord = SECP160R2_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecP160R2FieldElement.cs b/crypto/src/math/ec/custom/sec/SecP160R2FieldElement.cs
index 95d3c0b31..b67fc44f0 100644
--- a/crypto/src/math/ec/custom/sec/SecP160R2FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecP160R2FieldElement.cs
@@ -10,7 +10,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         : AbstractFpFieldElement
     {
         public static readonly BigInteger Q = new BigInteger(1,
-            Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73"));
+            Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73"));
 
         protected internal readonly uint[] x;
 
diff --git a/crypto/src/math/ec/custom/sec/SecP192K1Curve.cs b/crypto/src/math/ec/custom/sec/SecP192K1Curve.cs
index 6647ebab9..6f1069af9 100644
--- a/crypto/src/math/ec/custom/sec/SecP192K1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecP192K1Curve.cs
@@ -23,7 +23,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
             this.m_a = FromBigInteger(BigInteger.Zero);
             this.m_b = FromBigInteger(BigInteger.ValueOf(3));
-            this.m_order = new BigInteger(1, Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D"));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D"));
             this.m_cofactor = BigInteger.One;
             this.m_coord = SECP192K1_DEFAULT_COORDS;
         }
diff --git a/crypto/src/math/ec/custom/sec/SecP192K1FieldElement.cs b/crypto/src/math/ec/custom/sec/SecP192K1FieldElement.cs
index d3de532d9..7d5beaed8 100644
--- a/crypto/src/math/ec/custom/sec/SecP192K1FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecP192K1FieldElement.cs
@@ -11,7 +11,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         : AbstractFpFieldElement
     {
         public static readonly BigInteger Q = new BigInteger(1,
-            Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37"));
+            Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37"));
 
         protected internal readonly uint[] x;
 
diff --git a/crypto/src/math/ec/custom/sec/SecP192R1Curve.cs b/crypto/src/math/ec/custom/sec/SecP192R1Curve.cs
index a65afd0b0..249542449 100644
--- a/crypto/src/math/ec/custom/sec/SecP192R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecP192R1Curve.cs
@@ -22,10 +22,10 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             this.m_infinity = new SecP192R1Point(this, null, null);
 
             this.m_a = FromBigInteger(new BigInteger(1,
-                Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC")));
+                Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC")));
             this.m_b = FromBigInteger(new BigInteger(1,
-                Hex.Decode("64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1")));
-            this.m_order = new BigInteger(1, Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831"));
+                Hex.DecodeStrict("64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831"));
             this.m_cofactor = BigInteger.One;
 
             this.m_coord = SECP192R1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecP192R1FieldElement.cs b/crypto/src/math/ec/custom/sec/SecP192R1FieldElement.cs
index 65a1aadb3..d197cb698 100644
--- a/crypto/src/math/ec/custom/sec/SecP192R1FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecP192R1FieldElement.cs
@@ -10,7 +10,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         : AbstractFpFieldElement
     {
         public static readonly BigInteger Q = new BigInteger(1,
-            Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF"));
+            Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF"));
 
         protected internal readonly uint[] x;
 
diff --git a/crypto/src/math/ec/custom/sec/SecP224K1Curve.cs b/crypto/src/math/ec/custom/sec/SecP224K1Curve.cs
index ce56fbf52..7f45b14f6 100644
--- a/crypto/src/math/ec/custom/sec/SecP224K1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecP224K1Curve.cs
@@ -23,7 +23,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
             this.m_a = FromBigInteger(BigInteger.Zero);
             this.m_b = FromBigInteger(BigInteger.ValueOf(5));
-            this.m_order = new BigInteger(1, Hex.Decode("010000000000000000000000000001DCE8D2EC6184CAF0A971769FB1F7"));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("010000000000000000000000000001DCE8D2EC6184CAF0A971769FB1F7"));
             this.m_cofactor = BigInteger.One;
             this.m_coord = SECP224K1_DEFAULT_COORDS;
         }
diff --git a/crypto/src/math/ec/custom/sec/SecP224K1FieldElement.cs b/crypto/src/math/ec/custom/sec/SecP224K1FieldElement.cs
index 0614b7def..422b8294a 100644
--- a/crypto/src/math/ec/custom/sec/SecP224K1FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecP224K1FieldElement.cs
@@ -11,7 +11,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         : AbstractFpFieldElement
     {
         public static readonly BigInteger Q = new BigInteger(1,
-            Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFE56D"));
+            Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFE56D"));
 
         // Calculated as BigInteger.Two.ModPow(Q.ShiftRight(2), Q)
         private static readonly uint[] PRECOMP_POW2 = new uint[]{ 0x33bfd202, 0xdcfad133, 0x2287624a, 0xc3811ba8,
diff --git a/crypto/src/math/ec/custom/sec/SecP224R1Curve.cs b/crypto/src/math/ec/custom/sec/SecP224R1Curve.cs
index a37fc282f..1f75dc1db 100644
--- a/crypto/src/math/ec/custom/sec/SecP224R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecP224R1Curve.cs
@@ -22,10 +22,10 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             this.m_infinity = new SecP224R1Point(this, null, null);
 
             this.m_a = FromBigInteger(new BigInteger(1,
-                Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE")));
+                Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE")));
             this.m_b = FromBigInteger(new BigInteger(1,
-                Hex.Decode("B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4")));
-            this.m_order = new BigInteger(1, Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D"));
+                Hex.DecodeStrict("B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D"));
             this.m_cofactor = BigInteger.One;
 
             this.m_coord = SECP224R1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecP224R1FieldElement.cs b/crypto/src/math/ec/custom/sec/SecP224R1FieldElement.cs
index 968bc0baa..e44b4f7b7 100644
--- a/crypto/src/math/ec/custom/sec/SecP224R1FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecP224R1FieldElement.cs
@@ -10,7 +10,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         : AbstractFpFieldElement
     {
         public static readonly BigInteger Q = new BigInteger(1,
-            Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001"));
+            Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001"));
 
         protected internal readonly uint[] x;
 
diff --git a/crypto/src/math/ec/custom/sec/SecP256K1Curve.cs b/crypto/src/math/ec/custom/sec/SecP256K1Curve.cs
index 26c788b5f..f51477c63 100644
--- a/crypto/src/math/ec/custom/sec/SecP256K1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecP256K1Curve.cs
@@ -23,7 +23,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
             this.m_a = FromBigInteger(BigInteger.Zero);
             this.m_b = FromBigInteger(BigInteger.ValueOf(7));
-            this.m_order = new BigInteger(1, Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"));
             this.m_cofactor = BigInteger.One;
             this.m_coord = SECP256K1_DEFAULT_COORDS;
         }
diff --git a/crypto/src/math/ec/custom/sec/SecP256K1FieldElement.cs b/crypto/src/math/ec/custom/sec/SecP256K1FieldElement.cs
index d24f8d0df..5d1fea8b5 100644
--- a/crypto/src/math/ec/custom/sec/SecP256K1FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecP256K1FieldElement.cs
@@ -11,7 +11,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         : AbstractFpFieldElement
     {
         public static readonly BigInteger Q = new BigInteger(1,
-            Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F"));
+            Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F"));
 
         protected internal readonly uint[] x;
 
diff --git a/crypto/src/math/ec/custom/sec/SecP256R1Curve.cs b/crypto/src/math/ec/custom/sec/SecP256R1Curve.cs
index 504d7edc6..7cc456b2d 100644
--- a/crypto/src/math/ec/custom/sec/SecP256R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecP256R1Curve.cs
@@ -22,10 +22,10 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             this.m_infinity = new SecP256R1Point(this, null, null);
 
             this.m_a = FromBigInteger(new BigInteger(1,
-                Hex.Decode("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC")));
+                Hex.DecodeStrict("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC")));
             this.m_b = FromBigInteger(new BigInteger(1,
-                Hex.Decode("5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B")));
-            this.m_order = new BigInteger(1, Hex.Decode("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551"));
+                Hex.DecodeStrict("5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551"));
             this.m_cofactor = BigInteger.One;
             this.m_coord = SECP256R1_DEFAULT_COORDS;
         }
diff --git a/crypto/src/math/ec/custom/sec/SecP256R1FieldElement.cs b/crypto/src/math/ec/custom/sec/SecP256R1FieldElement.cs
index be4021485..1a18ec38e 100644
--- a/crypto/src/math/ec/custom/sec/SecP256R1FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecP256R1FieldElement.cs
@@ -10,7 +10,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         : AbstractFpFieldElement
     {
         public static readonly BigInteger Q = new BigInteger(1,
-            Hex.Decode("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF"));
+            Hex.DecodeStrict("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF"));
 
         protected internal readonly uint[] x;
 
diff --git a/crypto/src/math/ec/custom/sec/SecP384R1Curve.cs b/crypto/src/math/ec/custom/sec/SecP384R1Curve.cs
index 5c6afc2e5..890a72329 100644
--- a/crypto/src/math/ec/custom/sec/SecP384R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecP384R1Curve.cs
@@ -22,10 +22,10 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             this.m_infinity = new SecP384R1Point(this, null, null);
 
             this.m_a = FromBigInteger(new BigInteger(1,
-                Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC")));
+                Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC")));
             this.m_b = FromBigInteger(new BigInteger(1,
-                Hex.Decode("B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF")));
-            this.m_order = new BigInteger(1, Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973"));
+                Hex.DecodeStrict("B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973"));
             this.m_cofactor = BigInteger.One;
             this.m_coord = SECP384R1_DEFAULT_COORDS;
         }
diff --git a/crypto/src/math/ec/custom/sec/SecP384R1FieldElement.cs b/crypto/src/math/ec/custom/sec/SecP384R1FieldElement.cs
index 9d3f51d87..00046b495 100644
--- a/crypto/src/math/ec/custom/sec/SecP384R1FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecP384R1FieldElement.cs
@@ -10,7 +10,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         : AbstractFpFieldElement
     {
         public static readonly BigInteger Q = new BigInteger(1,
-            Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF"));
+            Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF"));
 
         protected internal readonly uint[] x;
 
diff --git a/crypto/src/math/ec/custom/sec/SecP521R1Curve.cs b/crypto/src/math/ec/custom/sec/SecP521R1Curve.cs
index cca86e2cb..28db11aea 100644
--- a/crypto/src/math/ec/custom/sec/SecP521R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecP521R1Curve.cs
@@ -22,10 +22,10 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             this.m_infinity = new SecP521R1Point(this, null, null);
 
             this.m_a = FromBigInteger(new BigInteger(1,
-                Hex.Decode("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC")));
+                Hex.DecodeStrict("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC")));
             this.m_b = FromBigInteger(new BigInteger(1,
-                Hex.Decode("0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00")));
-            this.m_order = new BigInteger(1, Hex.Decode("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409"));
+                Hex.DecodeStrict("0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409"));
             this.m_cofactor = BigInteger.One;
             this.m_coord = SECP521R1_DEFAULT_COORDS;
         }
diff --git a/crypto/src/math/ec/custom/sec/SecP521R1FieldElement.cs b/crypto/src/math/ec/custom/sec/SecP521R1FieldElement.cs
index a428a1243..c677b2610 100644
--- a/crypto/src/math/ec/custom/sec/SecP521R1FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecP521R1FieldElement.cs
@@ -10,7 +10,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         : AbstractFpFieldElement
     {
         public static readonly BigInteger Q = new BigInteger(1,
-            Hex.Decode("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"));
+            Hex.DecodeStrict("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"));
 
         protected internal readonly uint[] x;
 
diff --git a/crypto/src/math/ec/custom/sec/SecT113R1Curve.cs b/crypto/src/math/ec/custom/sec/SecT113R1Curve.cs
index ea9ea0b0c..492b1d8b5 100644
--- a/crypto/src/math/ec/custom/sec/SecT113R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT113R1Curve.cs
@@ -19,9 +19,9 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         {
             this.m_infinity = new SecT113R1Point(this, null, null);
 
-            this.m_a = FromBigInteger(new BigInteger(1, Hex.Decode("003088250CA6E7C7FE649CE85820F7")));
-            this.m_b = FromBigInteger(new BigInteger(1, Hex.Decode("00E8BEE4D3E2260744188BE0E9C723")));
-            this.m_order = new BigInteger(1, Hex.Decode("0100000000000000D9CCEC8A39E56F"));
+            this.m_a = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("003088250CA6E7C7FE649CE85820F7")));
+            this.m_b = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("00E8BEE4D3E2260744188BE0E9C723")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("0100000000000000D9CCEC8A39E56F"));
             this.m_cofactor = BigInteger.Two;
 
             this.m_coord = SECT113R1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT113R2Curve.cs b/crypto/src/math/ec/custom/sec/SecT113R2Curve.cs
index 84b20e026..d0fad0ff7 100644
--- a/crypto/src/math/ec/custom/sec/SecT113R2Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT113R2Curve.cs
@@ -19,9 +19,9 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         {
             this.m_infinity = new SecT113R2Point(this, null, null);
 
-            this.m_a = FromBigInteger(new BigInteger(1, Hex.Decode("00689918DBEC7E5A0DD6DFC0AA55C7")));
-            this.m_b = FromBigInteger(new BigInteger(1, Hex.Decode("0095E9A9EC9B297BD4BF36E059184F")));
-            this.m_order = new BigInteger(1, Hex.Decode("010000000000000108789B2496AF93"));
+            this.m_a = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("00689918DBEC7E5A0DD6DFC0AA55C7")));
+            this.m_b = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("0095E9A9EC9B297BD4BF36E059184F")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("010000000000000108789B2496AF93"));
             this.m_cofactor = BigInteger.Two;
 
             this.m_coord = SECT113R2_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT131R1Curve.cs b/crypto/src/math/ec/custom/sec/SecT131R1Curve.cs
index 1a8c01670..2b2636901 100644
--- a/crypto/src/math/ec/custom/sec/SecT131R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT131R1Curve.cs
@@ -19,9 +19,9 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         {
             this.m_infinity = new SecT131R1Point(this, null, null);
 
-            this.m_a = FromBigInteger(new BigInteger(1, Hex.Decode("07A11B09A76B562144418FF3FF8C2570B8")));
-            this.m_b = FromBigInteger(new BigInteger(1, Hex.Decode("0217C05610884B63B9C6C7291678F9D341")));
-            this.m_order = new BigInteger(1, Hex.Decode("0400000000000000023123953A9464B54D"));
+            this.m_a = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("07A11B09A76B562144418FF3FF8C2570B8")));
+            this.m_b = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("0217C05610884B63B9C6C7291678F9D341")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("0400000000000000023123953A9464B54D"));
             this.m_cofactor = BigInteger.Two;
 
             this.m_coord = SECT131R1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT131R2Curve.cs b/crypto/src/math/ec/custom/sec/SecT131R2Curve.cs
index 4a90a74f3..123362f4d 100644
--- a/crypto/src/math/ec/custom/sec/SecT131R2Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT131R2Curve.cs
@@ -19,9 +19,9 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         {
             this.m_infinity = new SecT131R2Point(this, null, null);
 
-            this.m_a = FromBigInteger(new BigInteger(1, Hex.Decode("03E5A88919D7CAFCBF415F07C2176573B2")));
-            this.m_b = FromBigInteger(new BigInteger(1, Hex.Decode("04B8266A46C55657AC734CE38F018F2192")));
-            this.m_order = new BigInteger(1, Hex.Decode("0400000000000000016954A233049BA98F"));
+            this.m_a = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("03E5A88919D7CAFCBF415F07C2176573B2")));
+            this.m_b = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("04B8266A46C55657AC734CE38F018F2192")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("0400000000000000016954A233049BA98F"));
             this.m_cofactor = BigInteger.Two;
 
             this.m_coord = SECT131R2_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT163K1Curve.cs b/crypto/src/math/ec/custom/sec/SecT163K1Curve.cs
index 6cdb7bdd6..31c63a8c4 100644
--- a/crypto/src/math/ec/custom/sec/SecT163K1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT163K1Curve.cs
@@ -22,7 +22,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
             this.m_a = FromBigInteger(BigInteger.One);
             this.m_b = this.m_a;
-            this.m_order = new BigInteger(1, Hex.Decode("04000000000000000000020108A2E0CC0D99F8A5EF"));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("04000000000000000000020108A2E0CC0D99F8A5EF"));
             this.m_cofactor = BigInteger.Two;
 
             this.m_coord = SECT163K1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT163R1Curve.cs b/crypto/src/math/ec/custom/sec/SecT163R1Curve.cs
index bee0d3c80..61c452ea7 100644
--- a/crypto/src/math/ec/custom/sec/SecT163R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT163R1Curve.cs
@@ -19,9 +19,9 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         {
             this.m_infinity = new SecT163R1Point(this, null, null);
 
-            this.m_a = FromBigInteger(new BigInteger(1, Hex.Decode("07B6882CAAEFA84F9554FF8428BD88E246D2782AE2")));
-            this.m_b = FromBigInteger(new BigInteger(1, Hex.Decode("0713612DCDDCB40AAB946BDA29CA91F73AF958AFD9")));
-            this.m_order = new BigInteger(1, Hex.Decode("03FFFFFFFFFFFFFFFFFFFF48AAB689C29CA710279B"));
+            this.m_a = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("07B6882CAAEFA84F9554FF8428BD88E246D2782AE2")));
+            this.m_b = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("0713612DCDDCB40AAB946BDA29CA91F73AF958AFD9")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("03FFFFFFFFFFFFFFFFFFFF48AAB689C29CA710279B"));
             this.m_cofactor = BigInteger.Two;
 
             this.m_coord = SECT163R1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT163R2Curve.cs b/crypto/src/math/ec/custom/sec/SecT163R2Curve.cs
index 35e91ddf1..c610b5722 100644
--- a/crypto/src/math/ec/custom/sec/SecT163R2Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT163R2Curve.cs
@@ -20,8 +20,8 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             this.m_infinity = new SecT163R2Point(this, null, null);
 
             this.m_a = FromBigInteger(BigInteger.One);
-            this.m_b = FromBigInteger(new BigInteger(1, Hex.Decode("020A601907B8C953CA1481EB10512F78744A3205FD")));
-            this.m_order = new BigInteger(1, Hex.Decode("040000000000000000000292FE77E70C12A4234C33"));
+            this.m_b = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("020A601907B8C953CA1481EB10512F78744A3205FD")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("040000000000000000000292FE77E70C12A4234C33"));
             this.m_cofactor = BigInteger.Two;
 
             this.m_coord = SECT163R2_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT193R1Curve.cs b/crypto/src/math/ec/custom/sec/SecT193R1Curve.cs
index 8ba83689e..32bc434c7 100644
--- a/crypto/src/math/ec/custom/sec/SecT193R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT193R1Curve.cs
@@ -19,9 +19,9 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         {
             this.m_infinity = new SecT193R1Point(this, null, null);
 
-            this.m_a = FromBigInteger(new BigInteger(1, Hex.Decode("0017858FEB7A98975169E171F77B4087DE098AC8A911DF7B01")));
-            this.m_b = FromBigInteger(new BigInteger(1, Hex.Decode("00FDFB49BFE6C3A89FACADAA7A1E5BBC7CC1C2E5D831478814")));
-            this.m_order = new BigInteger(1, Hex.Decode("01000000000000000000000000C7F34A778F443ACC920EBA49"));
+            this.m_a = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("0017858FEB7A98975169E171F77B4087DE098AC8A911DF7B01")));
+            this.m_b = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("00FDFB49BFE6C3A89FACADAA7A1E5BBC7CC1C2E5D831478814")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("01000000000000000000000000C7F34A778F443ACC920EBA49"));
             this.m_cofactor = BigInteger.Two;
 
             this.m_coord = SECT193R1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT193R2Curve.cs b/crypto/src/math/ec/custom/sec/SecT193R2Curve.cs
index 46790e7e4..7f5357177 100644
--- a/crypto/src/math/ec/custom/sec/SecT193R2Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT193R2Curve.cs
@@ -19,9 +19,9 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         {
             this.m_infinity = new SecT193R2Point(this, null, null);
 
-            this.m_a = FromBigInteger(new BigInteger(1, Hex.Decode("0163F35A5137C2CE3EA6ED8667190B0BC43ECD69977702709B")));
-            this.m_b = FromBigInteger(new BigInteger(1, Hex.Decode("00C9BB9E8927D4D64C377E2AB2856A5B16E3EFB7F61D4316AE")));
-            this.m_order = new BigInteger(1, Hex.Decode("010000000000000000000000015AAB561B005413CCD4EE99D5"));
+            this.m_a = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("0163F35A5137C2CE3EA6ED8667190B0BC43ECD69977702709B")));
+            this.m_b = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("00C9BB9E8927D4D64C377E2AB2856A5B16E3EFB7F61D4316AE")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("010000000000000000000000015AAB561B005413CCD4EE99D5"));
             this.m_cofactor = BigInteger.Two;
 
             this.m_coord = SECT193R2_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT233K1Curve.cs b/crypto/src/math/ec/custom/sec/SecT233K1Curve.cs
index c01247446..7a3f55f87 100644
--- a/crypto/src/math/ec/custom/sec/SecT233K1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT233K1Curve.cs
@@ -22,7 +22,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
             this.m_a = FromBigInteger(BigInteger.Zero);
             this.m_b = FromBigInteger(BigInteger.One);
-            this.m_order = new BigInteger(1, Hex.Decode("8000000000000000000000000000069D5BB915BCD46EFB1AD5F173ABDF"));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("8000000000000000000000000000069D5BB915BCD46EFB1AD5F173ABDF"));
             this.m_cofactor = BigInteger.ValueOf(4);
 
             this.m_coord = SECT233K1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT233R1Curve.cs b/crypto/src/math/ec/custom/sec/SecT233R1Curve.cs
index a5d3b86fd..7b7e59386 100644
--- a/crypto/src/math/ec/custom/sec/SecT233R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT233R1Curve.cs
@@ -20,8 +20,8 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             this.m_infinity = new SecT233R1Point(this, null, null);
 
             this.m_a = FromBigInteger(BigInteger.One);
-            this.m_b = FromBigInteger(new BigInteger(1, Hex.Decode("0066647EDE6C332C7F8C0923BB58213B333B20E9CE4281FE115F7D8F90AD")));
-            this.m_order = new BigInteger(1, Hex.Decode("01000000000000000000000000000013E974E72F8A6922031D2603CFE0D7"));
+            this.m_b = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("0066647EDE6C332C7F8C0923BB58213B333B20E9CE4281FE115F7D8F90AD")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("01000000000000000000000000000013E974E72F8A6922031D2603CFE0D7"));
             this.m_cofactor = BigInteger.Two;
 
             this.m_coord = SECT233R1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT239K1Curve.cs b/crypto/src/math/ec/custom/sec/SecT239K1Curve.cs
index 5748942e2..48854ce7e 100644
--- a/crypto/src/math/ec/custom/sec/SecT239K1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT239K1Curve.cs
@@ -22,7 +22,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
             this.m_a = FromBigInteger(BigInteger.Zero);
             this.m_b = FromBigInteger(BigInteger.One);
-            this.m_order = new BigInteger(1, Hex.Decode("2000000000000000000000000000005A79FEC67CB6E91F1C1DA800E478A5"));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("2000000000000000000000000000005A79FEC67CB6E91F1C1DA800E478A5"));
             this.m_cofactor = BigInteger.ValueOf(4);
 
             this.m_coord = SECT239K1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT283K1Curve.cs b/crypto/src/math/ec/custom/sec/SecT283K1Curve.cs
index e97a0f01d..c4d182435 100644
--- a/crypto/src/math/ec/custom/sec/SecT283K1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT283K1Curve.cs
@@ -22,7 +22,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
             this.m_a = FromBigInteger(BigInteger.Zero);
             this.m_b = FromBigInteger(BigInteger.One);
-            this.m_order = new BigInteger(1, Hex.Decode("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE9AE2ED07577265DFF7F94451E061E163C61"));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE9AE2ED07577265DFF7F94451E061E163C61"));
             this.m_cofactor = BigInteger.ValueOf(4);
 
             this.m_coord = SECT283K1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT283R1Curve.cs b/crypto/src/math/ec/custom/sec/SecT283R1Curve.cs
index a8a50c22a..c29413788 100644
--- a/crypto/src/math/ec/custom/sec/SecT283R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT283R1Curve.cs
@@ -20,8 +20,8 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             this.m_infinity = new SecT283R1Point(this, null, null);
 
             this.m_a = FromBigInteger(BigInteger.One);
-            this.m_b = FromBigInteger(new BigInteger(1, Hex.Decode("027B680AC8B8596DA5A4AF8A19A0303FCA97FD7645309FA2A581485AF6263E313B79A2F5")));
-            this.m_order = new BigInteger(1, Hex.Decode("03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF90399660FC938A90165B042A7CEFADB307"));
+            this.m_b = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("027B680AC8B8596DA5A4AF8A19A0303FCA97FD7645309FA2A581485AF6263E313B79A2F5")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF90399660FC938A90165B042A7CEFADB307"));
             this.m_cofactor = BigInteger.Two;
 
             this.m_coord = SECT283R1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT409K1Curve.cs b/crypto/src/math/ec/custom/sec/SecT409K1Curve.cs
index 2f6503692..9e5fe88c7 100644
--- a/crypto/src/math/ec/custom/sec/SecT409K1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT409K1Curve.cs
@@ -22,7 +22,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
             this.m_a = FromBigInteger(BigInteger.Zero);
             this.m_b = FromBigInteger(BigInteger.One);
-            this.m_order = new BigInteger(1, Hex.Decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE5F83B2D4EA20400EC4557D5ED3E3E7CA5B4B5C83B8E01E5FCF"));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE5F83B2D4EA20400EC4557D5ED3E3E7CA5B4B5C83B8E01E5FCF"));
             this.m_cofactor = BigInteger.ValueOf(4);
 
             this.m_coord = SECT409K1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT409R1Curve.cs b/crypto/src/math/ec/custom/sec/SecT409R1Curve.cs
index 0e767504b..845c14b40 100644
--- a/crypto/src/math/ec/custom/sec/SecT409R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT409R1Curve.cs
@@ -20,8 +20,8 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             this.m_infinity = new SecT409R1Point(this, null, null);
 
             this.m_a = FromBigInteger(BigInteger.One);
-            this.m_b = FromBigInteger(new BigInteger(1, Hex.Decode("0021A5C2C8EE9FEB5C4B9A753B7B476B7FD6422EF1F3DD674761FA99D6AC27C8A9A197B272822F6CD57A55AA4F50AE317B13545F")));
-            this.m_order = new BigInteger(1, Hex.Decode("010000000000000000000000000000000000000000000000000001E2AAD6A612F33307BE5FA47C3C9E052F838164CD37D9A21173"));
+            this.m_b = FromBigInteger(new BigInteger(1, Hex.DecodeStrict("0021A5C2C8EE9FEB5C4B9A753B7B476B7FD6422EF1F3DD674761FA99D6AC27C8A9A197B272822F6CD57A55AA4F50AE317B13545F")));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("010000000000000000000000000000000000000000000000000001E2AAD6A612F33307BE5FA47C3C9E052F838164CD37D9A21173"));
             this.m_cofactor = BigInteger.Two;
 
             this.m_coord = SECT409R1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT571K1Curve.cs b/crypto/src/math/ec/custom/sec/SecT571K1Curve.cs
index 1ab3b0941..544a1ba4b 100644
--- a/crypto/src/math/ec/custom/sec/SecT571K1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT571K1Curve.cs
@@ -22,7 +22,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
             this.m_a = FromBigInteger(BigInteger.Zero);
             this.m_b = FromBigInteger(BigInteger.One);
-            this.m_order = new BigInteger(1, Hex.Decode("020000000000000000000000000000000000000000000000000000000000000000000000131850E1F19A63E4B391A8DB917F4138B630D84BE5D639381E91DEB45CFE778F637C1001"));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("020000000000000000000000000000000000000000000000000000000000000000000000131850E1F19A63E4B391A8DB917F4138B630D84BE5D639381E91DEB45CFE778F637C1001"));
             this.m_cofactor = BigInteger.ValueOf(4);
 
             this.m_coord = SECT571K1_DEFAULT_COORDS;
diff --git a/crypto/src/math/ec/custom/sec/SecT571R1Curve.cs b/crypto/src/math/ec/custom/sec/SecT571R1Curve.cs
index 840c29638..67343b0c9 100644
--- a/crypto/src/math/ec/custom/sec/SecT571R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecT571R1Curve.cs
@@ -15,7 +15,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         protected readonly SecT571R1Point m_infinity;
 
         internal static readonly SecT571FieldElement SecT571R1_B = new SecT571FieldElement(
-            new BigInteger(1, Hex.Decode("02F40E7E2221F295DE297117B7F3D62F5C6A97FFCB8CEFF1CD6BA8CE4A9A18AD84FFABBD8EFA59332BE7AD6756A66E294AFD185A78FF12AA520E4DE739BACA0C7FFEFF7F2955727A")));
+            new BigInteger(1, Hex.DecodeStrict("02F40E7E2221F295DE297117B7F3D62F5C6A97FFCB8CEFF1CD6BA8CE4A9A18AD84FFABBD8EFA59332BE7AD6756A66E294AFD185A78FF12AA520E4DE739BACA0C7FFEFF7F2955727A")));
         internal static readonly SecT571FieldElement SecT571R1_B_SQRT = (SecT571FieldElement)SecT571R1_B.Sqrt();
 
         public SecT571R1Curve()
@@ -25,7 +25,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
             this.m_a = FromBigInteger(BigInteger.One);
             this.m_b = SecT571R1_B;
-            this.m_order = new BigInteger(1, Hex.Decode("03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE661CE18FF55987308059B186823851EC7DD9CA1161DE93D5174D66E8382E9BB2FE84E47"));
+            this.m_order = new BigInteger(1, Hex.DecodeStrict("03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE661CE18FF55987308059B186823851EC7DD9CA1161DE93D5174D66E8382E9BB2FE84E47"));
             this.m_cofactor = BigInteger.Two;
 
             this.m_coord = SECT571R1_DEFAULT_COORDS;
diff --git a/crypto/src/util/encoders/Hex.cs b/crypto/src/util/encoders/Hex.cs
index 3540a9d1e..dc4871352 100644
--- a/crypto/src/util/encoders/Hex.cs
+++ b/crypto/src/util/encoders/Hex.cs
@@ -9,7 +9,7 @@ namespace Org.BouncyCastle.Utilities.Encoders
     /// </summary>
     public sealed class Hex
     {
-        private static readonly IEncoder encoder = new HexEncoder();
+        private static readonly HexEncoder encoder = new HexEncoder();
 
         private Hex()
         {
@@ -126,5 +126,27 @@ namespace Org.BouncyCastle.Utilities.Encoders
         {
             return encoder.DecodeString(data, outStream);
         }
+
+        /**
+         * Decode the hexadecimal-encoded string strictly i.e. any non-hexadecimal characters will be
+         * considered an error.
+         *
+         * @return a byte array representing the decoded data.
+         */
+        public static byte[] DecodeStrict(string str)
+        {
+            return encoder.DecodeStrict(str, 0, str.Length);
+        }
+
+        /**
+         * Decode the hexadecimal-encoded string strictly i.e. any non-hexadecimal characters will be
+         * considered an error.
+         *
+         * @return a byte array representing the decoded data.
+         */
+        public static byte[] DecodeStrict(string str, int off, int len)
+        {
+            return encoder.DecodeStrict(str, off, len);
+        }
     }
 }
diff --git a/crypto/src/util/encoders/HexEncoder.cs b/crypto/src/util/encoders/HexEncoder.cs
index af526e0da..950bc8477 100644
--- a/crypto/src/util/encoders/HexEncoder.cs
+++ b/crypto/src/util/encoders/HexEncoder.cs
@@ -172,5 +172,31 @@ namespace Org.BouncyCastle.Utilities.Encoders
 
             return length;
         }
+
+        internal byte[] DecodeStrict(string str, int off, int len)
+        {
+            if (null == str)
+                throw new ArgumentNullException("str");
+            if (off < 0 || len < 0 || off > (str.Length - len))
+                throw new IndexOutOfRangeException("invalid offset and/or length specified");
+            if (0 != (len & 1))
+                throw new ArgumentException("a hexadecimal encoding must have an even number of characters", "len");
+
+            int resultLen = len >> 1;
+            byte[] result = new byte[resultLen];
+
+            int strPos = off;
+            for (int i = 0; i < resultLen; ++i)
+            {
+                byte b1 = decodingTable[str[strPos++]];
+                byte b2 = decodingTable[str[strPos++]];
+
+                if ((b1 | b2) >= 0x80)
+                    throw new IOException("invalid characters encountered in Hex data");
+
+                result[i] = (byte)((b1 << 4) | b2);
+            }
+            return result;
+        }
     }
 }