当前位置: 首页>>代码示例>>C#>>正文


C# Parameters.ECDomainParameters类代码示例

本文整理汇总了C#中Org.BouncyCastle.Crypto.Parameters.ECDomainParameters的典型用法代码示例。如果您正苦于以下问题:C# ECDomainParameters类的具体用法?C# ECDomainParameters怎么用?C# ECDomainParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ECDomainParameters类属于Org.BouncyCastle.Crypto.Parameters命名空间,在下文中一共展示了ECDomainParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestECNR192bitPrime

        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);
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:32,代码来源:ECNRTest.cs

示例2: ECDiffieHellmanBc

        public ECDiffieHellmanBc(Int32 keySize)
        {
            Org.BouncyCastle.Asn1.X9.X9ECParameters ecParams;
            switch (keySize) {
            case 256:
                ecParams = Org.BouncyCastle.Asn1.Sec.SecNamedCurves.GetByName("secp256r1");
                break;
            case 384:
                ecParams = Org.BouncyCastle.Asn1.Sec.SecNamedCurves.GetByName("secp384r1");
                break;
            case 521:
                ecParams = Org.BouncyCastle.Asn1.Sec.SecNamedCurves.GetByName("secp521r1");
                break;
            default:
                throw new ArgumentException("ECDiffieHellman key size " + keySize + " not supported");
            }
            _keySize = keySize;
            _domainParameters = new ECDomainParameters(ecParams.Curve, ecParams.G, ecParams.N, ecParams.H, ecParams.GetSeed());

            // Initialize key generation parameters with new SecureRandom
            Org.BouncyCastle.Security.SecureRandom secureRandom = new Org.BouncyCastle.Security.SecureRandom();
            ECKeyGenerationParameters keyGenParams = new ECKeyGenerationParameters(_domainParameters, secureRandom);

            // Generate key pair from domain parameters
            Org.BouncyCastle.Crypto.Generators.ECKeyPairGenerator generator = new Org.BouncyCastle.Crypto.Generators.ECKeyPairGenerator();
            generator.Init(keyGenParams);
            Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair keyPair = generator.GenerateKeyPair();

            // Save the private and public key parameters
            _privateKeyParameters = (ECPrivateKeyParameters) keyPair.Private;
            _publicKeyParameters = (ECPublicKeyParameters) keyPair.Public;

            _kdf = ECDiffieHellmanKeyDerivationFunction.Hash;
            _hashAlgorithm = CngAlgorithm.Sha256;
        }
开发者ID:mikoskinen,项目名称:AaltoTLS,代码行数:35,代码来源:ECDiffieHellmanBc.cs

示例3: PerformTest

		public override void PerformTest()
		{
			IAsymmetricCipherKeyPairGenerator g = GeneratorUtilities.GetKeyPairGenerator("ECIES");

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

			ECDomainParameters ecSpec = new ECDomainParameters(
				curve,
				curve.DecodePoint(Hex.Decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
				new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307")); // n

			g.Init(
				new ECKeyGenerationParameters(
					ecSpec,
					new SecureRandom()));

			IBufferedCipher c1 = CipherUtilities.GetCipher("ECIES");
			IBufferedCipher c2 = CipherUtilities.GetCipher("ECIES");

			doTest(g, c1, c2);

			g = GeneratorUtilities.GetKeyPairGenerator("ECIES");

			g.Init(new KeyGenerationParameters(new SecureRandom(), 192));

			doTest(g, c1, c2);

			g = GeneratorUtilities.GetKeyPairGenerator("ECIES");

			g.Init(new KeyGenerationParameters(new SecureRandom(), 239));

			doTest(g, c1, c2);

			g = GeneratorUtilities.GetKeyPairGenerator("ECIES");

			g.Init(new KeyGenerationParameters(new SecureRandom(), 256));

			doTest(g, c1, c2);

			doDefTest(g, c1, c2);

			c1 = CipherUtilities.GetCipher("IES");
			c2 = CipherUtilities.GetCipher("IES");

			g = GeneratorUtilities.GetKeyPairGenerator("DH");

//			DHParameterSpec dhParams = new DHParameterSpec(p512, g512);
//			g.initialize(dhParams);
			g.Init(
				new DHKeyGenerationParameters(
					new SecureRandom(),
					new DHParameters(p512, g512)));

			doTest(g, c1, c2);

			doDefTest(g, c1, c2);
		}
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:60,代码来源:IESTest.cs

示例4: ECKeyGenerationParameters

		public ECKeyGenerationParameters(
			ECDomainParameters	domainParameters,
			SecureRandom		random)
			: base(random, domainParameters.N.BitLength)
        {
            this.domainParams = domainParameters;
        }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:7,代码来源:ECKeyGenerationParameters.cs

示例5: CalculateMqvAgreement

        // The ECMQV Primitive as described in SEC-1, 3.4
        private static ECPoint CalculateMqvAgreement(
			ECDomainParameters		parameters,
			ECPrivateKeyParameters	d1U,
			ECPrivateKeyParameters	d2U,
			ECPublicKeyParameters	q2U,
			ECPublicKeyParameters	q1V,
			ECPublicKeyParameters	q2V)
        {
            var n = parameters.N;
            var e = (n.BitLength + 1) / 2;
            var powE = BigInteger.One.ShiftLeft(e);

            // The Q2U public key is optional
            var q = q2U == null ? parameters.G.Multiply(d2U.D) : q2U.Q;

            var x = q.X.ToBigInteger();
            var xBar = x.Mod(powE);
            var q2UBar = xBar.SetBit(e);
            var s = d1U.D.Multiply(q2UBar).Mod(n).Add(d2U.D).Mod(n);

            var xPrime = q2V.Q.X.ToBigInteger();
            var xPrimeBar = xPrime.Mod(powE);
            var q2VBar = xPrimeBar.SetBit(e);

            var hs = parameters.H.Multiply(s).Mod(n);

            //ECPoint p = Q1V.Q.Multiply(Q2VBar).Add(Q2V.Q).Multiply(hs);
            var p = ECAlgorithms.SumOfTwoMultiplies(
                q1V.Q, q2VBar.Multiply(hs).Mod(n), q2V.Q, hs);

            if (p.IsInfinity)
                throw new InvalidOperationException("Infinity is not a valid agreement value for MQV");

            return p;
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:36,代码来源:ECMqvBasicAgreement.cs

示例6: EcKey

 static EcKey()
 {
     // All clients must agree on the curve to use by agreement. BitCoin uses secp256k1.
     var @params = SecNamedCurves.GetByName("secp256k1");
     _ecParams = new ECDomainParameters(@params.Curve, @params.G, @params.N, @params.H);
     _secureRandom = new SecureRandom();
 }
开发者ID:TangibleCryptography,项目名称:BitSharper,代码行数:7,代码来源:EcKey.cs

示例7: ParsePublicKey

		public static ECPublicKeyParameters ParsePublicKey(byte[] keyBytes)
		{
            var curve = SecNamedCurves.GetByName("secp256r1");
		    var point = curve.Curve.DecodePoint(keyBytes);
            var parameters = new ECDomainParameters(curve.Curve, curve.G, curve.N, curve.H);
            return new ECPublicKeyParameters(point, parameters);
		}
开发者ID:vbfox,项目名称:U2FExperiments,代码行数:7,代码来源:TestUtils.cs

示例8: TestECNR239bitPrime

		public void TestECNR239bitPrime()
		{
			BigInteger r = new BigInteger("308636143175167811492623515537541734843573549327605293463169625072911693");
			BigInteger s = new BigInteger("852401710738814635664888632022555967400445256405412579597015412971797143");

			byte[] kData = new BigInteger("700000017569056646655505781757157107570501575775705779575555657156756655").ToByteArrayUnsigned();

			SecureRandom k = FixedSecureRandom.From(kData);

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

			ECDomainParameters spec = new ECDomainParameters(
				curve,
				curve.DecodePoint(Hex.Decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
				new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307")); // n

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

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

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

			checkSignature(239, priKey, pubKey, sgr, k, message, r, s);
		}
开发者ID:randombit,项目名称:hacrypto,代码行数:32,代码来源:ECNRTest.cs

示例9: ECDHPublicKeyParameters

 /// <summary>
 /// Initializes a new instance of the <see cref="ECDHPublicKeyParameters" /> class.
 /// </summary>
 /// <param name="q">The q.</param>
 /// <param name="parameters">The parameters.</param>
 /// <param name="hashAlgorithm">The hash algorithm.</param>
 /// <param name="symmetricKeyAlgorithm">The symmetric key algorithm.</param>
 public ECDHPublicKeyParameters(ECPoint q, ECDomainParameters parameters, HashAlgorithmTag hashAlgorithm,
                                SymmetricKeyAlgorithmTag symmetricKeyAlgorithm)
     : base("ECDH", q, parameters)
 {
     this.HashAlgorithm = hashAlgorithm;
     this.SymmetricKeyAlgorithm = symmetricKeyAlgorithm;
 }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:14,代码来源:ECDHPublicKeyParameters.cs

示例10: ECKeyGenerationParameters

 /// <summary>
 /// Initializes a new instance of the <see cref="ECKeyGenerationParameters"/> class.
 /// </summary>
 /// <param name="domainParameters">The domain parameters.</param>
 /// <param name="random">The random.</param>
 /// <param name="hashAlgorithm">The hash algorithm.</param>
 /// <param name="symmetricKeyAlgorithm">The symmetric key algorithm.</param>
 public ECKeyGenerationParameters(ECDomainParameters domainParameters, ISecureRandom random, HashAlgorithmTag hashAlgorithm, SymmetricKeyAlgorithmTag symmetricKeyAlgorithm)
     : base(random, domainParameters.N.BitLength)
 {
     _domainParams = domainParameters;
     _hashAlgorithm = hashAlgorithm;
     _symmetricKeyAlgorithm = symmetricKeyAlgorithm;
 }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:14,代码来源:ECKeyGenerationParameters.cs

示例11: TestECNR192bitPrime

        public void TestECNR192bitPrime()
        {
            BigInteger r  = new BigInteger("2474388605162950674935076940284692598330235697454145648371");
            BigInteger s  = new BigInteger("2997192822503471356158280167065034437828486078932532073836");

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

            SecureRandom k = FixedSecureRandom.From(kData);

            X9ECParameters p = X962NamedCurves.GetByOid(X9ObjectIdentifiers.Prime192v1);
            ECDomainParameters spec = new ECDomainParameters(p.Curve, p.G, p.N, p.H);
            ECCurve curve = spec.Curve;

            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);
        }
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:26,代码来源:ECNRTest.cs

示例12: TestECNR239bitPrime

        public void TestECNR239bitPrime()
        {
            BigInteger r = new BigInteger("308636143175167811492623515537541734843573549327605293463169625072911693");
            BigInteger s = new BigInteger("852401710738814635664888632022555967400445256405412579597015412971797143");

            byte[] kData = new BigInteger("700000017569056646655505781757157107570501575775705779575555657156756655").ToByteArrayUnsigned();

            SecureRandom k = FixedSecureRandom.From(kData);

            X9ECParameters p = X962NamedCurves.GetByOid(X9ObjectIdentifiers.Prime239v1);
            ECDomainParameters spec = new ECDomainParameters(p.Curve, p.G, p.N, p.H);
            ECCurve curve = spec.Curve;

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

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

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

            checkSignature(239, priKey, pubKey, sgr, k, message, r, s);
        }
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:26,代码来源:ECNRTest.cs

示例13: KeyAgreement

        public KeyAgreement()
        {
            _curve = new FpCurve(
                new BigInteger("BDB6F4FE3E8B1D9E0DA8C0D46F4C318CEFE4AFE3B6B8551F", 16), // q
                new BigInteger("BB8E5E8FBC115E139FE6A814FE48AAA6F0ADA1AA5DF91985", 16), // a
                new BigInteger("1854BEBDC31B21B7AEFC80AB0ECD10D5B1B3308E6DBF11C1", 16)  // b
                );

            _ecSpec = new ECDomainParameters(
                _curve,
                new FpPoint(_curve,
                        new FpFieldElement(
                            _curve.Q,
                            new BigInteger("4AD5F7048DE709AD51236DE65E4D4B482C836DC6E4106640", 16)
                        ),
                        new FpFieldElement(
                            _curve.Q,
                            new BigInteger("02BB3A02D4AAADACAE24817A4CA3A1B014B5270432DB27D2", 16))
                        ), // G
                        new BigInteger("BDB6F4FE3E8B1D9E0DA8C0D40FC962195DFAE76F56564677", 16), // n
                        BigInteger.One// h
                );
            _keyGen = GeneratorUtilities.GetKeyPairGenerator("ECDH");
            _keyGen.Init(new ECKeyGenerationParameters(_ecSpec, new SecureRandom()));
        }
开发者ID:daluobohao,项目名称:RFIDReader_vfinal,代码行数:25,代码来源:KeyAgreement.cs

示例14: TestECDsa192bitPrime

		public void TestECDsa192bitPrime()
		{
			BigInteger r = new BigInteger("3342403536405981729393488334694600415596881826869351677613");
			BigInteger s = new BigInteger("5735822328888155254683894997897571951568553642892029982342");

			byte[] kData = BigIntegers.AsUnsignedByteArray(new BigInteger("6140507067065001063065065565667405560006161556565665656654"));

			SecureRandom k = FixedSecureRandom.From(kData);

			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

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

			ParametersWithRandom param = new ParametersWithRandom(priKey, k);

			ECDsaSigner ecdsa = new ECDsaSigner();

			ecdsa.Init(true, param);

			byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").ToByteArray();
			BigInteger[] sig = ecdsa.GenerateSignature(message);

			if (!r.Equals(sig[0]))
			{
				Fail("r component wrong." + SimpleTest.NewLine
					+ " expecting: " + r + SimpleTest.NewLine
					+ " got      : " + sig[0]);
			}

			if (!s.Equals(sig[1]))
			{
				Fail("s component wrong." + SimpleTest.NewLine
					+ " expecting: " + s + SimpleTest.NewLine
					+ " got      : " + sig[1]);
			}

			// Verify the signature
			ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
				"ECDSA",
				curve.DecodePoint(Hex.Decode("0262b12d60690cdcf330babab6e69763b471f994dd702d16a5")), // Q
				parameters);

			ecdsa.Init(false, pubKey);
			if (!ecdsa.VerifySignature(message, sig[0], sig[1]))
			{
				Fail("verification fails");
			}
		}
开发者ID:randombit,项目名称:hacrypto,代码行数:59,代码来源:ECTest.cs

示例15: ECPrivateKeyParameters

        public ECPrivateKeyParameters(string algorithm, IBigInteger d, ECDomainParameters parameters)
            : base(algorithm, true, parameters)
        {
            if (d == null)
                throw new ArgumentNullException("d");

            _d = d;
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:8,代码来源:ECPrivateKeyParameters.cs


注:本文中的Org.BouncyCastle.Crypto.Parameters.ECDomainParameters类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。