public void TestDecode()
        {
            var curve = new FPCurve(
                new BigInteger("6277101735386680763835789423207666416083908700390324961279"), // q
                new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
                new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16)); // b

            ECPoint p = curve.DecodePoint(Hex.Decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"));

            if (!p.X.ToBigInteger().Equals(new BigInteger("188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012", 16)))
            {
                Fail("x uncompressed incorrectly");
            }

            if (!p.Y.ToBigInteger().Equals(new BigInteger("7192b95ffc8da78631011ed6b24cdd573f977a11e794811", 16)))
            {
                Fail("y uncompressed incorrectly");
            }

            byte[] encoding = p.GetEncoded();

            if (!AreEqual(encoding, Hex.Decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012")))
            {
                Fail("point compressed incorrectly");
            }
        }
        public void TestECNR192bitPrime()
        {
            IBigInteger r  = new BigInteger("2474388605162950674935076940284692598330235697454145648371");
            IBigInteger s  = new BigInteger("2997192822503471356158280167065034437828486078932532073836");

            byte[] kData = new BigInteger("dcc5d1f1020906df2782360d36b2de7a17ece37d503784af", 16).ToByteArrayUnsigned();

            SecureRandom k = FixedSecureRandom.From(kData);

            FPCurve curve = new FPCurve(
                new BigInteger("6277101735386680763835789423207666416083908700390324961279"), // q (or p)
                new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC", 16),   // a
                new BigInteger("64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1", 16));  // b

            ECDomainParameters spec = new ECDomainParameters(
                curve,
                curve.DecodePoint(Hex.Decode("03188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012")), // G
                new BigInteger("6277101735386680763835789423176059013767194773182842284081")); // n

            ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
                new BigInteger("651056770906015076056810763456358567190100156695615665659"), // d
                spec);

            ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
                curve.DecodePoint(Hex.Decode("0262B12D60690CDCF330BABAB6E69763B471F994DD702D16A5")), // Q
                spec);

            ISigner sgr = SignerUtilities.GetSigner("SHA1withECNR");
            byte[] message = new byte[] { (byte)'a', (byte)'b', (byte)'c' };

            checkSignature(192, priKey, pubKey, sgr, k, message, r, s);
        }
        public void DecodeTest()
        {
            //			EllipticCurve curve = new EllipticCurve(
            //				new ECFieldFp(new BigInteger("6277101735386680763835789423207666416083908700390324961279")), // q
            //				new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
            //				new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16)); // b
            ECCurve curve = new FPCurve(
                new BigInteger("6277101735386680763835789423207666416083908700390324961279"), // q
                new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
                new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16)); // b

            //			ECPoint p = ECPointUtil.DecodePoint(curve, Hex.Decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"));
            ECPoint p = curve.DecodePoint(Hex.Decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"));

            IBigInteger x = p.X.ToBigInteger(); //p.getAffineX();

            if (!x.Equals(new BigInteger("188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012", 16)))
            {
                Fail("x uncompressed incorrectly");
            }

            IBigInteger y = p.Y.ToBigInteger(); //p.getAffineX();
            if (!y.Equals(new BigInteger("7192b95ffc8da78631011ed6b24cdd573f977a11e794811", 16)))
            {
                Fail("y uncompressed incorrectly");
            }
        }
        /**
         * Test Sign and Verify with A parameters
         * see: http://www.ietf.org/internet-drafts/draft-popov-cryptopro-cpalgs-01.txt
         * gostR3410-2001-CryptoPro-A-ParamSet  P.47
         */
        public void ecGOST3410_AParam()
        {
            SecureRandom    random = new SecureRandom();

            IBigInteger mod_p = new BigInteger("115792089237316195423570985008687907853269984665640564039457584007913129639319"); //p

            FPCurve curve = new FPCurve(
                mod_p, // p
                new BigInteger("115792089237316195423570985008687907853269984665640564039457584007913129639316"), // a
                new BigInteger("166")); // b

            ECDomainParameters parameters = new ECDomainParameters(
                curve,
                new FPPoint(curve,
                new FPFieldElement(mod_p, new BigInteger("1")), // x
                new FPFieldElement(mod_p, new BigInteger("64033881142927202683649881450433473985931760268884941288852745803908878638612"))), // y
                new BigInteger("115792089237316195423570985008687907853073762908499243225378155805079068850323")); // q

            ECKeyPairGenerator pGen = new ECKeyPairGenerator("ECGOST3410");
            ECKeyGenerationParameters genParam = new ECKeyGenerationParameters(
                parameters,
                random);

            pGen.Init(genParam);

            IAsymmetricCipherKeyPair  pair = pGen.GenerateKeyPair();

            ParametersWithRandom param = new ParametersWithRandom(pair.Private, random);

            ECGost3410Signer ecgost3410 = new ECGost3410Signer();

            ecgost3410.Init(true, param);

            IBigInteger[] sig = ecgost3410.GenerateSignature(hashmessage);

            ecgost3410.Init(false, pair.Public);

            if (!ecgost3410.VerifySignature(hashmessage, sig[0], sig[1]))
            {
                Fail("signature fails");
            }
        }
        public override void PerformTest()
        {
            StaticTest();

            FPCurve curve = new FPCurve(
                new BigInteger("6277101735386680763835789423207666416083908700390324961279"), // q
                new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
                new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16)); // b

            ECDomainParameters parameters = new ECDomainParameters(
                curve,
                curve.DecodePoint(Hex.Decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012")), // G
                new BigInteger("6277101735386680763835789423176059013767194773182842284081")); // n

            ECKeyPairGenerator eGen = new ECKeyPairGenerator();
            KeyGenerationParameters gParam = new ECKeyGenerationParameters(parameters, new SecureRandom());

            eGen.Init(gParam);

            IAsymmetricCipherKeyPair p1 = eGen.GenerateKeyPair();
            IAsymmetricCipherKeyPair p2 = eGen.GenerateKeyPair();

            DoTest(p1, p2);
        }
        public void TestCreationECDSA()
        {
            IBigInteger ECParraGX = new BigInteger(Base64.Decode("D/qWPNyogWzMM7hkK+35BcPTWFc9Pyf7vTs8uaqv"));
            IBigInteger ECParraGY = new BigInteger(Base64.Decode("AhQXGxb1olGRv6s1LPRfuatMF+cx3ZTGgzSE/Q5R"));
            IBigInteger ECParraH = new BigInteger(Base64.Decode("AQ=="));
            IBigInteger ECParraN = new BigInteger(Base64.Decode("f///////////////f///nl6an12QcfvRUiaIkJ0L"));
            IBigInteger ECPubQX = new BigInteger(Base64.Decode("HWWi17Yb+Bm3PYr/DMjLOYNFhyOwX1QY7ZvqqM+l"));
            IBigInteger ECPubQY = new BigInteger(Base64.Decode("JrlJfxu3WGhqwtL/55BOs/wsUeiDFsvXcGhB8DGx"));
            IBigInteger ECPrivD = new BigInteger(Base64.Decode("GYQmd/NF1B+He1iMkWt3by2Az6Eu07t0ynJ4YCAo"));
            FPCurve curve = new FPCurve(
               new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
                new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
                new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16)); // b
            ECDomainParameters ecDomain =
                new ECDomainParameters(curve, new FPPoint(curve, curve.FromBigInteger(ECParraGX), curve.FromBigInteger(ECParraGY)), ECParraN);
            ECPublicKeyParameters ecPub = new ECPublicKeyParameters(
                "ECDSA",
                new FPPoint(curve,
                    curve.FromBigInteger(ECPubQX),
                    curve.FromBigInteger(ECPubQY)),
                ecDomain);
            ECPrivateKeyParameters ecPriv = new ECPrivateKeyParameters("ECDSA", ECPrivD, ecDomain);

            IDictionary attrs = new Hashtable();
            attrs[X509Name.C] = "AU";
            attrs[X509Name.O] = "The Legion of the Bouncy Castle";
            attrs[X509Name.L] = "Melbourne";
            attrs[X509Name.ST] = "Victoria";
            attrs[X509Name.E] = "*****@*****.**";

            IList ord = new ArrayList();
            ord.Add(X509Name.C);
            ord.Add(X509Name.O);
            ord.Add(X509Name.L);
            ord.Add(X509Name.ST);
            ord.Add(X509Name.E);

            IList values = new ArrayList();
            values.Add("AU");
            values.Add("The Legion of the Bouncy Castle");
            values.Add("Melbourne");
            values.Add("Victoria");
            values.Add("*****@*****.**");

            X509V3CertificateGenerator certGen = new X509V3CertificateGenerator();

            certGen.SetSerialNumber(BigInteger.One);

            certGen.SetIssuerDN(new X509Name(ord, attrs));
            certGen.SetNotBefore(DateTime.Today.Subtract(new TimeSpan(1, 0, 0, 0)));
            certGen.SetNotAfter(DateTime.Today.AddDays(1));
            certGen.SetSubjectDN(new X509Name(ord, attrs));
            certGen.SetPublicKey(ecPub);
            certGen.SetSignatureAlgorithm("SHA1WITHECDSA");

            X509Certificate cert = certGen.Generate(ecPriv);

            //            Assert.IsTrue((cert.IsValidNow && cert.Verify(ecPub)), "Certificate failed to be valid (ECDSA)");
            cert.CheckValidity();
            cert.Verify(ecPub);

            ISet dummySet = cert.GetNonCriticalExtensionOids();

            if (dummySet != null)
            {
                foreach (string key in dummySet)
                {
                    Console.WriteLine("\t{0}:\t{1}", key);
                }
            }

            Console.WriteLine();

            dummySet = cert.GetNonCriticalExtensionOids();

            if (dummySet != null)
            {
                foreach (string key in dummySet)
                {
                    Console.WriteLine("\t{0}:\t{1}", key);
                }
            }

            Console.WriteLine();
        }
            protected override X9ECParameters CreateParameters()
            {
                // p = 2^521 - 1
                IBigInteger p = FromHex("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
                IBigInteger a = FromHex("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC");
                IBigInteger b = FromHex("0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00");
                byte[] S = Hex.Decode("D09E8800291CB85396CC6717393284AAA0DA64BA");
                IBigInteger n = FromHex("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409");
                IBigInteger h = BigInteger.ValueOf(1);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("02"
                //+ "00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66"
                    + "011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650"));

                return new X9ECParameters(curve, G, n, h, S);
            }
            protected override X9ECParameters CreateParameters()
            {
                // p = 2^224 (2^32 - 1) + 2^192 + 2^96 - 1
                IBigInteger p = FromHex("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF");
                IBigInteger a = FromHex("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC");
                IBigInteger b = FromHex("5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B");
                byte[] S = Hex.Decode("C49D360886E704936A6678E1139D26B7819F7E90");
                IBigInteger n = FromHex("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551");
                IBigInteger h = BigInteger.ValueOf(1);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("03"
                //+ "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296"
                    + "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5"));

                return new X9ECParameters(curve, G, n, h, S);
            }
            protected override X9ECParameters CreateParameters()
            {
                // p = 2^224 - 2^96 + 1
                IBigInteger p = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001");
                IBigInteger a = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE");
                IBigInteger b = FromHex("B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4");
                byte[] S = Hex.Decode("BD71344799D5C7FCDC45B59FA3B9AB8F6A948BC5");
                IBigInteger n = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D");
                IBigInteger h = BigInteger.ValueOf(1);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("02"
                //+ "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21"
                    + "BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34"));

                return new X9ECParameters(curve, G, n, h, S);
            }
            protected override X9ECParameters CreateParameters()
            {
                // p = 2^192 - 2^64 - 1
                IBigInteger p = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF");
                IBigInteger a = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC");
                IBigInteger b = FromHex("64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1");
                byte[] S = Hex.Decode("3045AE6FC8422F64ED579528D38120EAE12196D5");
                IBigInteger n = FromHex("FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831");
                IBigInteger h = BigInteger.ValueOf(1);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("03"
                //+ "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012"
                    + "07192B95FFC8DA78631011ED6B24CDD573F977A11E794811"));

                return new X9ECParameters(curve, G, n, h, S);
            }
            protected override X9ECParameters CreateParameters()
            {
                // p = 2^160 - 2^32 - 2^14 - 2^12 - 2^9 - 2^8 - 2^7 - 2^3 - 2^2 - 1
                IBigInteger p = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73");
                IBigInteger a = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC70");
                IBigInteger b = FromHex("B4E134D3FB59EB8BAB57274904664D5AF50388BA");
                byte[] S = Hex.Decode("B99B99B099B323E02709A4D696E6768756151751");
                IBigInteger n = FromHex("0100000000000000000000351EE786A818F3A1A16B");
                IBigInteger h = BigInteger.ValueOf(1);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("02"
                //+ "52DCB034293A117E1F4FF11B30F7199D3144CE6D"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "52DCB034293A117E1F4FF11B30F7199D3144CE6D"
                    + "FEAFFEF2E331F296E071FA0DF9982CFEA7D43F2E"));

                return new X9ECParameters(curve, G, n, h, S);
            }
            protected override X9ECParameters CreateParameters()
            {
                // p = 2^160 - 2^32 - 2^14 - 2^12 - 2^9 - 2^8 - 2^7 - 2^3 - 2^2 - 1
                IBigInteger p = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73");
                IBigInteger a = BigInteger.Zero;
                IBigInteger b = BigInteger.ValueOf(7);
                byte[] S = null;
                IBigInteger n = FromHex("0100000000000000000001B8FA16DFAB9ACA16B6B3");
                IBigInteger h = BigInteger.ValueOf(1);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("02"
                    //+ "3B4C382CE37AA192A4019E763036F4F5DD4D7EBB"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "3B4C382CE37AA192A4019E763036F4F5DD4D7EBB"
                    + "938CF935318FDCED6BC28286531733C3F03C4FEE"));

                return new X9ECParameters(curve, G, n, h, S);
            }
            protected override X9ECParameters CreateParameters()
            {
                ECCurve cFp192v1 = new FPCurve(
                    new BigInteger("6277101735386680763835789423207666416083908700390324961279"),
                    new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16),
                    new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16));

                return new X9ECParameters(
                    cFp192v1,
                    cFp192v1.DecodePoint(
                        Hex.Decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012")),
                    new BigInteger("ffffffffffffffffffffffff99def836146bc9b1b4d22831", 16),
                    BigInteger.One,
                    Hex.Decode("3045AE6FC8422f64ED579528D38120EAE12196D5"));
            }
            protected override X9ECParameters CreateParameters()
            {
                ECCurve cFp256v1 = new FPCurve(
                    new BigInteger("115792089210356248762697446949407573530086143415290314195533631308867097853951"),
                    new BigInteger("ffffffff00000001000000000000000000000000fffffffffffffffffffffffc", 16),
                    new BigInteger("5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", 16));

                return new X9ECParameters(
                    cFp256v1,
                    cFp256v1.DecodePoint(
                        Hex.Decode("036b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296")),
                    new BigInteger("ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", 16),
                    BigInteger.One,
                    Hex.Decode("c49d360886e704936a6678e1139d26b7819f7e90"));
            }
            protected override X9ECParameters CreateParameters()
            {
                ECCurve cFp192v2 = new FPCurve(
                    new BigInteger("6277101735386680763835789423207666416083908700390324961279"),
                    new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16),
                    new BigInteger("cc22d6dfb95c6b25e49c0d6364a4e5980c393aa21668d953", 16));

                return new X9ECParameters(
                    cFp192v2,
                    cFp192v2.DecodePoint(
                        Hex.Decode("03eea2bae7e1497842f2de7769cfe9c989c072ad696f48034a")),
                    new BigInteger("fffffffffffffffffffffffe5fb1a724dc80418648d8dd31", 16),
                    BigInteger.One,
                    Hex.Decode("31a92ee2029fd10d901b113e990710f0d21ac6b6"));
            }
            protected override X9ECParameters CreateParameters()
            {
                // p = 2^128 - 2^97 - 1
                IBigInteger p = FromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF");
                IBigInteger a = FromHex("D6031998D1B3BBFEBF59CC9BBFF9AEE1");
                IBigInteger b = FromHex("5EEEFCA380D02919DC2C6558BB6D8A5D");
                byte[] S = Hex.Decode("004D696E67687561517512D8F03431FCE63B88F4");
                IBigInteger n = FromHex("3FFFFFFF7FFFFFFFBE0024720613B5A3");
                IBigInteger h = BigInteger.ValueOf(4);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("02"
                //+ "7B6AA5D85E572983E6FB32A7CDEBC140"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "7B6AA5D85E572983E6FB32A7CDEBC140"
                    + "27B6916A894D3AEE7106FE805FC34B44"));

                return new X9ECParameters(curve, G, n, h, S);
            }
            protected override X9ECParameters CreateParameters()
            {
                ECCurve cFp192v3 = new FPCurve(
                    new BigInteger("6277101735386680763835789423207666416083908700390324961279"),
                    new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16),
                    new BigInteger("22123dc2395a05caa7423daeccc94760a7d462256bd56916", 16));

                return new X9ECParameters(
                    cFp192v3,
                    cFp192v3.DecodePoint(
                        Hex.Decode("027d29778100c65a1da1783716588dce2b8b4aee8e228f1896")),
                    new BigInteger("ffffffffffffffffffffffff7a62d031c83f4294f640ec13", 16),
                    BigInteger.One,
                    Hex.Decode("c469684435deb378c4b65ca9591e2a5763059a2e"));
            }
            protected override X9ECParameters CreateParameters()
            {
                // p = 2^160 - 2^31 - 1
                IBigInteger p = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF");
                IBigInteger a = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC");
                IBigInteger b = FromHex("1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45");
                byte[] S = Hex.Decode("1053CDE42C14D696E67687561517533BF3F83345");
                IBigInteger n = FromHex("0100000000000000000001F4C8F927AED3CA752257");
                IBigInteger h = BigInteger.ValueOf(1);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("02"
                    //+ "4A96B5688EF573284664698968C38BB913CBFC82"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "4A96B5688EF573284664698968C38BB913CBFC82"
                    + "23A628553168947D59DCC912042351377AC5FB32"));

                return new X9ECParameters(curve, G, n, h, S);
            }
            protected override X9ECParameters CreateParameters()
            {
                ECCurve cFp239v1 = new FPCurve(
                    new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"),
                    new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16),
                    new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16));

                return new X9ECParameters(
                    cFp239v1,
                    cFp239v1.DecodePoint(
                        Hex.Decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")),
                    new BigInteger("7fffffffffffffffffffffff7fffff9e5e9a9f5d9071fbd1522688909d0b", 16),
                    BigInteger.One,
                    Hex.Decode("e43bb460f0b80cc0c0b075798e948060f8321b7d"));
            }
            protected override X9ECParameters CreateParameters()
            {
                // p = 2^192 - 2^32 - 2^12 - 2^8 - 2^7 - 2^6 - 2^3 - 1
                IBigInteger p = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37");
                IBigInteger a = BigInteger.Zero;
                IBigInteger b = BigInteger.ValueOf(3);
                byte[] S = null;
                IBigInteger n = FromHex("FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D");
                IBigInteger h = BigInteger.ValueOf(1);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("03"
                //+ "DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D"
                    + "9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D"));

                return new X9ECParameters(curve, G, n, h, S);
            }
            protected override X9ECParameters CreateParameters()
            {
                ECCurve cFp239v2 = new FPCurve(
                    new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"),
                    new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16),
                    new BigInteger("617fab6832576cbbfed50d99f0249c3fee58b94ba0038c7ae84c8c832f2c", 16));

                return new X9ECParameters(
                    cFp239v2,
                    cFp239v2.DecodePoint(
                        Hex.Decode("0238af09d98727705120c921bb5e9e26296a3cdcf2f35757a0eafd87b830e7")),
                    new BigInteger("7fffffffffffffffffffffff800000cfa7e8594377d414c03821bc582063", 16),
                    BigInteger.One,
                    Hex.Decode("e8b4011604095303ca3b8099982be09fcb9ae616"));
            }
            protected override X9ECParameters CreateParameters()
            {
                // p = 2^224 - 2^32 - 2^12 - 2^11 - 2^9 - 2^7 - 2^4 - 2 - 1
                IBigInteger p = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFE56D");
                IBigInteger a = BigInteger.Zero;
                IBigInteger b = BigInteger.ValueOf(5);
                byte[] S = null;
                IBigInteger n = FromHex("010000000000000000000000000001DCE8D2EC6184CAF0A971769FB1F7");
                IBigInteger h = BigInteger.ValueOf(1);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("03"
                //+ "A1455B334DF099DF30FC28A169A467E9E47075A90F7E650EB6B7A45C"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "A1455B334DF099DF30FC28A169A467E9E47075A90F7E650EB6B7A45C"
                    + "7E089FED7FBA344282CAFBD6F7E319F7C0B0BD59E2CA4BDB556D61A5"));

                return new X9ECParameters(curve, G, n, h, S);
            }
            protected override X9ECParameters CreateParameters()
            {
                ECCurve cFp239v3 = new FPCurve(
                    new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"),
                    new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16),
                    new BigInteger("255705fa2a306654b1f4cb03d6a750a30c250102d4988717d9ba15ab6d3e", 16));

                return new X9ECParameters(
                    cFp239v3,
                    cFp239v3.DecodePoint(
                        Hex.Decode("036768ae8e18bb92cfcf005c949aa2c6d94853d0e660bbf854b1c9505fe95a")),
                    new BigInteger("7fffffffffffffffffffffff7fffff975deb41b3a6057c3c432146526551", 16),
                    BigInteger.One,
                    Hex.Decode("7d7374168ffe3471b60a857686a19475d3bfa2ff"));
            }
            protected override X9ECParameters CreateParameters()
            {
                // p = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1
                IBigInteger p = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F");
                IBigInteger a = BigInteger.Zero;
                IBigInteger b = BigInteger.ValueOf(7);
                byte[] S = null;
                IBigInteger n = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141");
                IBigInteger h = BigInteger.ValueOf(1);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("02"
                //+ "79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798"
                    + "483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8"));

                return new X9ECParameters(curve, G, n, h, S);
            }
            protected override X9ECParameters CreateParameters()
            {
                // p = (2^128 - 3) / 76439
                IBigInteger p = FromHex("DB7C2ABF62E35E668076BEAD208B");
                IBigInteger a = FromHex("DB7C2ABF62E35E668076BEAD2088");
                IBigInteger b = FromHex("659EF8BA043916EEDE8911702B22");
                byte[] S = Hex.Decode("00F50B028E4D696E676875615175290472783FB1");
                IBigInteger n = FromHex("DB7C2ABF62E35E7628DFAC6561C5");
                IBigInteger h = BigInteger.ValueOf(1);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("02"
                //+ "09487239995A5EE76B55F9C2F098"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "09487239995A5EE76B55F9C2F098"
                    + "A89CE5AF8724C0A23E0E0FF77500"));

                return new X9ECParameters(curve, G, n, h, S);
            }
            protected override X9ECParameters CreateParameters()
            {
                // p = 2^384 - 2^128 - 2^96 + 2^32 - 1
                IBigInteger p = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF");
                IBigInteger a = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC");
                IBigInteger b = FromHex("B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF");
                byte[] S = Hex.Decode("A335926AA319A27A1D00896A6773A4827ACDAC73");
                IBigInteger n = FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973");
                IBigInteger h = BigInteger.ValueOf(1);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("03"
                //+ "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7"
                    + "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F"));

                return new X9ECParameters(curve, G, n, h, S);
            }
            protected override X9ECParameters CreateParameters()
            {
                // p = (2^128 - 3) / 76439
                IBigInteger p = FromHex("DB7C2ABF62E35E668076BEAD208B");
                IBigInteger a = FromHex("6127C24C05F38A0AAAF65C0EF02C");
                IBigInteger b = FromHex("51DEF1815DB5ED74FCC34C85D709");
                byte[] S = Hex.Decode("002757A1114D696E6768756151755316C05E0BD4");
                IBigInteger n = FromHex("36DF0AAFD8B8D7597CA10520D04B");
                IBigInteger h = BigInteger.ValueOf(4);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("03"
                //+ "4BA30AB5E892B4E1649DD0928643"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "4BA30AB5E892B4E1649DD0928643"
                    + "ADCD46F5882E3747DEF36E956E97"));

                return new X9ECParameters(curve, G, n, h, S);
            }
        public void TestAlgorithms()
        {
            //
            // RSA parameters
            //
            IBigInteger rsaMod = new BigInteger("a7295693155b1813bb84877fb45343556e0568043de5910872a3a518cc11e23e2db74eaf4545068c4e3d258a2718fbacdcc3eafa457695b957e88fbf110aed049a992d9c430232d02f3529c67a3419935ea9b569f85b1bcd37de6b899cd62697e843130ff0529d09c97d813cb15f293751ff56f943fbdabb63971cc7f4f6d5bff1594416b1f5907bde5a84a44f9802ef29b43bda1960f948f8afb8766c1ab80d32eec88ed66d0b65aebe44a6d0b3c5e0ab051aaa1b912fbcc17b8e751ddecc5365b6db6dab0020c3057db4013a51213a5798a3aab67985b0f4d88627a54a0f3f0285fbcb4afdfeb65cb153af66825656d43238b75503231500753f4e421e3c57", 16);
            IBigInteger rsaPubExp = new BigInteger("10001", 16);

            IBigInteger rsaPrivExp = new BigInteger("65dad56ac7df7abb434e4cb5eeadb16093aa6da7f0033aad3815289b04757d32bfee6ade7749c8e4a323b5050a2fb9e2a99e23469e1ed4ba5bab54336af20a5bfccb8b3424cc6923db2ffca5787ed87aa87aa614cd04cedaebc8f623a2d2063017910f436dff18bb06f01758610787f8b258f0a8efd8bd7de30007c47b2a1031696c7d6523bc191d4d918927a7e0b09584ed205bd2ff4fc4382678df82353f7532b3bbb81d69e3f39070aed3fb64fce032a089e8e64955afa5213a6eb241231bd98d702fba725a9b205952fda186412d9e0d9344d2998c455ad8c2bae85ee672751466d5288304032b5b7e02f7e558c7af82c7fbf58eea0bb4ef0f001e6cd0a9", 16);
            IBigInteger rsaPrivP = new BigInteger("d4fd9ac3474fb83aaf832470643609659e511b322632b239b688f3cd2aad87527d6cf652fb9c9ca67940e84789444f2e99b0cb0cfabbd4de95396106c865f38e2fb7b82b231260a94df0e01756bf73ce0386868d9c41645560a81af2f53c18e4f7cdf3d51d80267372e6e0216afbf67f655c9450769cca494e4f6631b239ce1b", 16);
            IBigInteger rsaPrivQ = new BigInteger("c8eaa0e2a1b3a4412a702bccda93f4d150da60d736c99c7c566fdea4dd1b401cbc0d8c063daaf0b579953d36343aa18b33dbf8b9eae94452490cc905245f8f7b9e29b1a288bc66731a29e1dd1a45c9fd7f8238ff727adc49fff73991d0dc096206b9d3a08f61e7462e2b804d78cb8c5eccdb9b7fbd2ad6a8fea46c1053e1be75", 16);
            IBigInteger rsaPrivDP = new BigInteger("10edcb544421c0f9e123624d1099feeb35c72a8b34e008ac6fa6b90210a7543f293af4e5299c8c12eb464e70092805c7256e18e5823455ba0f504d36f5ccacac1b7cd5c58ff710f9c3f92646949d88fdd1e7ea5fed1081820bb9b0d2a8cd4b093fecfdb96dabd6e28c3a6f8c186dc86cddc89afd3e403e0fcf8a9e0bcb27af0b", 16);
            IBigInteger rsaPrivDQ = new BigInteger("97fc25484b5a415eaa63c03e6efa8dafe9a1c8b004d9ee6e80548fefd6f2ce44ee5cb117e77e70285798f57d137566ce8ea4503b13e0f1b5ed5ca6942537c4aa96b2a395782a4cb5b58d0936e0b0fa63b1192954d39ced176d71ef32c6f42c84e2e19f9d4dd999c2151b032b97bd22aa73fd8c5bcd15a2dca4046d5acc997021", 16);
            IBigInteger rsaPrivQinv = new BigInteger("4bb8064e1eff7e9efc3c4578fcedb59ca4aef0993a8312dfdcb1b3decf458aa6650d3d0866f143cbf0d3825e9381181170a0a1651eefcd7def786b8eb356555d9fa07c85b5f5cbdd74382f1129b5e36b4166b6cc9157923699708648212c484958351fdc9cf14f218dbe7fbf7cbd93a209a4681fe23ceb44bab67d66f45d1c9d", 16);

            RsaKeyParameters rsaPublic = new RsaKeyParameters(false, rsaMod, rsaPubExp);
            RsaPrivateCrtKeyParameters rsaPrivate = new RsaPrivateCrtKeyParameters(
                rsaMod, rsaPubExp, rsaPrivExp, rsaPrivP, rsaPrivQ, rsaPrivDP, rsaPrivDQ, rsaPrivQinv);

            //
            // ECDSA parameters
            //
            IBigInteger ECParraGX = new BigInteger(Base64.Decode("D/qWPNyogWzMM7hkK+35BcPTWFc9Pyf7vTs8uaqv"));
            IBigInteger ECParraGY = new BigInteger(Base64.Decode("AhQXGxb1olGRv6s1LPRfuatMF+cx3ZTGgzSE/Q5R"));
            IBigInteger ECParraH = new BigInteger(Base64.Decode("AQ=="));
            IBigInteger ECParraN = new BigInteger(Base64.Decode("f///////////////f///nl6an12QcfvRUiaIkJ0L"));
            IBigInteger ECPubQX = new BigInteger(Base64.Decode("HWWi17Yb+Bm3PYr/DMjLOYNFhyOwX1QY7ZvqqM+l"));
            IBigInteger ECPubQY = new BigInteger(Base64.Decode("JrlJfxu3WGhqwtL/55BOs/wsUeiDFsvXcGhB8DGx"));
            IBigInteger ECPrivD = new BigInteger(Base64.Decode("GYQmd/NF1B+He1iMkWt3by2Az6Eu07t0ynJ4YCAo"));

            FPCurve curve = new FPCurve(
                new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
                new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
                new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16)); // b

            ECDomainParameters ecDomain = new ECDomainParameters(curve,
                new FPPoint(curve,
                    curve.FromBigInteger(ECParraGX),
                    curve.FromBigInteger(ECParraGY)),
                ECParraN);

            ECPublicKeyParameters ecPub = new ECPublicKeyParameters(
                new FPPoint(curve,
                    curve.FromBigInteger(ECPubQX),
                    curve.FromBigInteger(ECPubQY)),
                ecDomain);

            ECPrivateKeyParameters ecPriv = new ECPrivateKeyParameters(ECPrivD, ecDomain);

            //
            // DSA parameters
            //
            IBigInteger DSAParaG = new BigInteger(Base64.Decode("AL0fxOTq10OHFbCf8YldyGembqEu08EDVzxyLL29Zn/t4It661YNol1rnhPIs+cirw+yf9zeCe+KL1IbZ/qIMZM="));
            IBigInteger DSAParaP = new BigInteger(Base64.Decode("AM2b/UeQA+ovv3dL05wlDHEKJ+qhnJBsRT5OB9WuyRC830G79y0R8wuq8jyIYWCYcTn1TeqVPWqiTv6oAoiEeOs="));
            IBigInteger DSAParaQ = new BigInteger(Base64.Decode("AIlJT7mcKL6SUBMmvm24zX1EvjNx"));
            IBigInteger DSAPublicY = new BigInteger(Base64.Decode("TtWy2GuT9yGBWOHi1/EpCDa/bWJCk2+yAdr56rAcqP0eHGkMnA9s9GJD2nGU8sFjNHm55swpn6JQb8q0agrCfw=="));
            IBigInteger DsaPrivateX = new BigInteger(Base64.Decode("MMpBAxNlv7eYfxLTZ2BItJeD31A="));

            DsaParameters para = new DsaParameters(DSAParaP, DSAParaQ, DSAParaG);
            DsaPrivateKeyParameters dsaPriv = new DsaPrivateKeyParameters(DsaPrivateX, para);
            DsaPublicKeyParameters dsaPub = new DsaPublicKeyParameters(DSAPublicY, para);

            //
            // ECGOST3410 parameters
            //
            IAsymmetricCipherKeyPairGenerator ecGostKpg = GeneratorUtilities.GetKeyPairGenerator("ECGOST3410");
            ecGostKpg.Init(
                new ECKeyGenerationParameters(
                    CryptoProObjectIdentifiers.GostR3410x2001CryptoProA,
                    new SecureRandom()));

            IAsymmetricCipherKeyPair ecGostPair = ecGostKpg.GenerateKeyPair();

            //
            // GOST3410 parameters
            //
            IAsymmetricCipherKeyPairGenerator gostKpg = GeneratorUtilities.GetKeyPairGenerator("GOST3410");
            gostKpg.Init(
                new Gost3410KeyGenerationParameters(
                    new SecureRandom(),
                    CryptoProObjectIdentifiers.GostR3410x94CryptoProA));

            IAsymmetricCipherKeyPair gostPair = gostKpg.GenerateKeyPair();

            //
            // signer loop
            //
            byte[] shortMsg = new byte[] { 1, 4, 5, 6, 8, 8, 4, 2, 1, 3 };
            byte[] longMsg = new byte[100];
            new SecureRandom().NextBytes(longMsg);

            foreach (string algorithm in SignerUtilities.Algorithms)
            {
                ISigner signer = SignerUtilities.GetSigner(algorithm);

                string upper = algorithm.ToUpper(CultureInfo.InvariantCulture);
                int withPos = upper.LastIndexOf("WITH");

                string cipherName = withPos < 0
                    ?	upper
                    :	upper.Substring(withPos + "WITH".Length);

                ICipherParameters signParams = null, verifyParams = null;

                if (cipherName == "RSA" || cipherName == "RSAANDMGF1")
                {
                    signParams = rsaPrivate;
                    verifyParams = rsaPublic;
                }
                else if (cipherName == "ECDSA")
                {
                    signParams = ecPriv;
                    verifyParams = ecPub;
                }
                else if (cipherName == "DSA")
                {
                    signParams = dsaPriv;
                    verifyParams = dsaPub;
                }
                else if (cipherName == "ECGOST3410")
                {
                    signParams = ecGostPair.Private;
                    verifyParams = ecGostPair.Public;
                }
                else if (cipherName == "GOST3410")
                {
                    signParams = gostPair.Private;
                    verifyParams = gostPair.Public;
                }
                else
                {
                    Assert.Fail("Unknown algorithm encountered: " + cipherName);
                }

                signer.Init(true, signParams);
                foreach (byte b in shortMsg)
                {
                    signer.Update(b);
                }
                signer.BlockUpdate(longMsg, 0, longMsg.Length);
                byte[] sig = signer.GenerateSignature();

                signer.Init(false, verifyParams);
                foreach (byte b in shortMsg)
                {
                    signer.Update(b);
                }
                signer.BlockUpdate(longMsg, 0, longMsg.Length);

                Assert.IsTrue(signer.VerifySignature(sig), cipherName + " signer " + algorithm + " failed.");
            }
        }
            protected override X9ECParameters CreateParameters()
            {
                // p = 2^128 - 2^97 - 1
                IBigInteger p = FromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF");
                IBigInteger a = FromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC");
                IBigInteger b = FromHex("E87579C11079F43DD824993C2CEE5ED3");
                byte[] S = Hex.Decode("000E0D4D696E6768756151750CC03A4473D03679");
                IBigInteger n = FromHex("FFFFFFFE0000000075A30D1B9038A115");
                IBigInteger h = BigInteger.ValueOf(1);

                ECCurve curve = new FPCurve(p, a, b);
                //ECPoint G = curve.DecodePoint(Hex.Decode("03"
                //+ "161FF7528B899B2D0C28607CA52C5B86"));
                ECPoint G = curve.DecodePoint(Hex.Decode("04"
                    + "161FF7528B899B2D0C28607CA52C5B86"
                    + "CF5AC8395BAFEB13C02DA292DDED7A83"));

                return new X9ECParameters(curve, G, n, h, S);
            }
        static ECGost3410NamedCurves()
        {
            IBigInteger mod_p = new BigInteger("115792089237316195423570985008687907853269984665640564039457584007913129639319");
            IBigInteger mod_q = new BigInteger("115792089237316195423570985008687907853073762908499243225378155805079068850323");

            FPCurve curve = new FPCurve(
                mod_p, // p
                new BigInteger("115792089237316195423570985008687907853269984665640564039457584007913129639316"), // a
                new BigInteger("166")); // b

            ECDomainParameters ecParams = new ECDomainParameters(
                curve,
                curve.CreatePoint(
                    BigInteger.One, // x
                    new BigInteger("64033881142927202683649881450433473985931760268884941288852745803908878638612"), // y
                    false),
                mod_q);

            parameters[CryptoProObjectIdentifiers.GostR3410x2001CryptoProA] = ecParams;

            mod_p = new BigInteger("115792089237316195423570985008687907853269984665640564039457584007913129639319");
            mod_q = new BigInteger("115792089237316195423570985008687907853073762908499243225378155805079068850323");

            curve = new FPCurve(
                mod_p, // p
                new BigInteger("115792089237316195423570985008687907853269984665640564039457584007913129639316"),
                new BigInteger("166"));

            ecParams = new ECDomainParameters(
                curve,
                curve.CreatePoint(
                    BigInteger.One, // x
                    new BigInteger("64033881142927202683649881450433473985931760268884941288852745803908878638612"), // y
                    false),
                mod_q);

            parameters[CryptoProObjectIdentifiers.GostR3410x2001CryptoProXchA] = ecParams;

            mod_p = new BigInteger("57896044618658097711785492504343953926634992332820282019728792003956564823193"); //p
            mod_q = new BigInteger("57896044618658097711785492504343953927102133160255826820068844496087732066703"); //q

            curve = new FPCurve(
                mod_p, // p
                new BigInteger("57896044618658097711785492504343953926634992332820282019728792003956564823190"), // a
                new BigInteger("28091019353058090096996979000309560759124368558014865957655842872397301267595")); // b

            ecParams = new ECDomainParameters(
                curve,
                curve.CreatePoint(
                    BigInteger.One, // x
                    new BigInteger("28792665814854611296992347458380284135028636778229113005756334730996303888124"), // y
                    false),
                mod_q); // q

            parameters[CryptoProObjectIdentifiers.GostR3410x2001CryptoProB] = ecParams;

            mod_p = new BigInteger("70390085352083305199547718019018437841079516630045180471284346843705633502619");
            mod_q = new BigInteger("70390085352083305199547718019018437840920882647164081035322601458352298396601");

            curve = new FPCurve(
                mod_p, // p
                new BigInteger("70390085352083305199547718019018437841079516630045180471284346843705633502616"),
                new BigInteger("32858"));

            ecParams = new ECDomainParameters(
                curve,
                curve.CreatePoint(
                    BigInteger.Zero, // x
                    new BigInteger("29818893917731240733471273240314769927240550812383695689146495261604565990247"), // y
                    false),
                mod_q);

            parameters[CryptoProObjectIdentifiers.GostR3410x2001CryptoProXchB] = ecParams;

            mod_p = new BigInteger("70390085352083305199547718019018437841079516630045180471284346843705633502619"); //p
            mod_q = new BigInteger("70390085352083305199547718019018437840920882647164081035322601458352298396601"); //q
            curve = new FPCurve(
                mod_p, // p
                new BigInteger("70390085352083305199547718019018437841079516630045180471284346843705633502616"), // a
                new BigInteger("32858")); // b

            ecParams = new ECDomainParameters(
                curve,
                curve.CreatePoint(
                    BigInteger.Zero, // x
                    new BigInteger("29818893917731240733471273240314769927240550812383695689146495261604565990247"), // y
                    false),
                mod_q); // q

            parameters[CryptoProObjectIdentifiers.GostR3410x2001CryptoProC] = ecParams;

            objIds["GostR3410-2001-CryptoPro-A"] = CryptoProObjectIdentifiers.GostR3410x2001CryptoProA;
            objIds["GostR3410-2001-CryptoPro-B"] = CryptoProObjectIdentifiers.GostR3410x2001CryptoProB;
            objIds["GostR3410-2001-CryptoPro-C"] = CryptoProObjectIdentifiers.GostR3410x2001CryptoProC;
            objIds["GostR3410-2001-CryptoPro-XchA"] = CryptoProObjectIdentifiers.GostR3410x2001CryptoProXchA;
            objIds["GostR3410-2001-CryptoPro-XchB"] = CryptoProObjectIdentifiers.GostR3410x2001CryptoProXchB;

            names[CryptoProObjectIdentifiers.GostR3410x2001CryptoProA] = "GostR3410-2001-CryptoPro-A";
            names[CryptoProObjectIdentifiers.GostR3410x2001CryptoProB] = "GostR3410-2001-CryptoPro-B";
            names[CryptoProObjectIdentifiers.GostR3410x2001CryptoProC] = "GostR3410-2001-CryptoPro-C";
            names[CryptoProObjectIdentifiers.GostR3410x2001CryptoProXchA] = "GostR3410-2001-CryptoPro-XchA";
            names[CryptoProObjectIdentifiers.GostR3410x2001CryptoProXchB] = "GostR3410-2001-CryptoPro-XchB";
        }
示例#31
0
 protected bool Equals(FPCurve other)
 {
     return(base.Equals(other) && _q.Equals(other._q));
 }