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


C# Math.BigInteger类代码示例

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


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

示例1: TestRsaDigestSigner

        public void TestRsaDigestSigner()
        {
            BigInteger rsaPubMod = new BigInteger(Base64.Decode("AIASoe2PQb1IP7bTyC9usjHP7FvnUMVpKW49iuFtrw/dMpYlsMMoIU2jupfifDpdFxIktSB4P+6Ymg5WjvHKTIrvQ7SR4zV4jaPTu56Ys0pZ9EDA6gb3HLjtU+8Bb1mfWM+yjKxcPDuFjwEtjGlPHg1Vq+CA9HNcMSKNn2+tW6qt"));
            BigInteger rsaPubExp = new BigInteger(Base64.Decode("EQ=="));
            BigInteger rsaPrivMod = new BigInteger(Base64.Decode("AIASoe2PQb1IP7bTyC9usjHP7FvnUMVpKW49iuFtrw/dMpYlsMMoIU2jupfifDpdFxIktSB4P+6Ymg5WjvHKTIrvQ7SR4zV4jaPTu56Ys0pZ9EDA6gb3HLjtU+8Bb1mfWM+yjKxcPDuFjwEtjGlPHg1Vq+CA9HNcMSKNn2+tW6qt"));
            BigInteger rsaPrivDP = new BigInteger(Base64.Decode("JXzfzG5v+HtLJIZqYMUefJfFLu8DPuJGaLD6lI3cZ0babWZ/oPGoJa5iHpX4Ul/7l3s1PFsuy1GhzCdOdlfRcQ=="));
            BigInteger rsaPrivDQ = new BigInteger(Base64.Decode("YNdJhw3cn0gBoVmMIFRZzflPDNthBiWy/dUMSRfJCxoZjSnr1gysZHK01HteV1YYNGcwPdr3j4FbOfri5c6DUQ=="));
            BigInteger rsaPrivExp = new BigInteger(Base64.Decode("DxFAOhDajr00rBjqX+7nyZ/9sHWRCCp9WEN5wCsFiWVRPtdB+NeLcou7mWXwf1Y+8xNgmmh//fPV45G2dsyBeZbXeJwB7bzx9NMEAfedchyOwjR8PYdjK3NpTLKtZlEJ6Jkh4QihrXpZMO4fKZWUm9bid3+lmiq43FwW+Hof8/E="));
            BigInteger rsaPrivP = new BigInteger(Base64.Decode("AJ9StyTVW+AL/1s7RBtFwZGFBgd3zctBqzzwKPda6LbtIFDznmwDCqAlIQH9X14X7UPLokCDhuAa76OnDXb1OiE="));
            BigInteger rsaPrivQ = new BigInteger(Base64.Decode("AM3JfD79dNJ5A3beScSzPtWxx/tSLi0QHFtkuhtSizeXdkv5FSba7lVzwEOGKHmW829bRoNxThDy4ds1IihW1w0="));
            BigInteger rsaPrivQinv = new BigInteger(Base64.Decode("Lt0g7wrsNsQxuDdB8q/rH8fSFeBXMGLtCIqfOec1j7FEIuYA/ACiRDgXkHa0WgN7nLXSjHoy630wC5Toq8vvUg=="));
            RsaKeyParameters rsaPublic = new RsaKeyParameters(false, rsaPubMod, rsaPubExp);
			RsaPrivateCrtKeyParameters rsaPrivate = new RsaPrivateCrtKeyParameters(rsaPrivMod, rsaPubExp, rsaPrivExp, rsaPrivP, rsaPrivQ, rsaPrivDP, rsaPrivDQ, rsaPrivQinv);

            byte[] msg = new byte[] { 1, 6, 3, 32, 7, 43, 2, 5, 7, 78, 4, 23 };

            RsaDigestSigner signer = new RsaDigestSigner(new Sha1Digest());
            signer.Init(true, rsaPrivate);
            signer.BlockUpdate(msg, 0, msg.Length);
            byte[] sig = signer.GenerateSignature();

            signer.Init(false,rsaPublic);
            signer.BlockUpdate(msg, 0, msg.Length);
            Assert.IsTrue(signer.VerifySignature(sig), "RSA IDigest Signer failed.");
        }
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:25,代码来源:TestCertificateGen.cs

示例2: RsaPublicBcpgKey

		/// <param name="n">The modulus.</param>
		/// <param name="e">The public exponent.</param>
		public RsaPublicBcpgKey(
			BigInteger	n,
			BigInteger	e)
		{
			this.n = new MPInteger(n);
			this.e = new MPInteger(e);
		}
开发者ID:MBrekhof,项目名称:pleiobox-clients,代码行数:9,代码来源:RsaPublicBcpgKey.cs

示例3: ImplShamirsTrick

		private static ECPoint ImplShamirsTrick(ECPoint P, BigInteger k,
			ECPoint Q, BigInteger l)
		{
			int m = System.Math.Max(k.BitLength, l.BitLength);
			ECPoint Z = P.Add(Q);
			ECPoint R = P.Curve.Infinity;

			for (int i = m - 1; i >= 0; --i)
			{
				R = R.Twice();

				if (k.TestBit(i))
				{
					if (l.TestBit(i))
					{
						R = R.Add(Z);
					}
					else
					{
						R = R.Add(P);
					}
				}
				else
				{
					if (l.TestBit(i))
					{
						R = R.Add(Q);
					}
				}
			}

			return R;
		}
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:33,代码来源:ECAlgorithms.cs

示例4: ECPublicBcpgKey

 protected ECPublicBcpgKey(
     DerObjectIdentifier oid,
     ECPoint point)
 {
     this.point = new BigInteger(1, point.GetEncoded());
     this.oid = oid;
 }
开发者ID:ALange,项目名称:OutlookPrivacyPlugin,代码行数:7,代码来源:ECPublicBCPGKey.cs

示例5: ECPrivateKeyStructure

		public ECPrivateKeyStructure(
            BigInteger key)
        {
			this.seq = new DerSequence(
				new DerInteger(1),
				new DerOctetString(key.ToByteArrayUnsigned()));
        }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:7,代码来源:ECPrivateKeyStructure.cs

示例6: 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);

			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:randombit,项目名称:hacrypto,代码行数:33,代码来源:ECNRTest.cs

示例7: ECDomainParameters

		public ECDomainParameters(
            ECCurve     curve,
            ECPoint     g,
            BigInteger  n)
			: this(curve, g, n, BigInteger.One)
        {
        }
开发者ID:VimalKumarS,项目名称:mono-tls,代码行数:7,代码来源:ECDomainParameters.cs

示例8: RsaPublicKeyStructure

		public RsaPublicKeyStructure(
            BigInteger	modulus,
            BigInteger	publicExponent)
        {
            this.modulus = modulus;
            this.publicExponent = publicExponent;
        }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:7,代码来源:RSAPublicKeyStructure.cs

示例9: CalculatePrivate

        internal BigInteger CalculatePrivate(
			BigInteger		p,
			SecureRandom	random,
			int				limit)
        {
            //
            // calculate the private key
            //
            BigInteger pSub2 = p.Subtract(BigInteger.Two);
            BigInteger x;

            if (limit == 0)
            {
                x = createInRange(pSub2, random);
            }
            else
            {
                do
                {
                    // TODO Check this (should the generated numbers always be odd,
                    // and length 'limit'?)
                    x = new BigInteger(limit, 0, random);
                }
                while (x.SignValue == 0);
            }

            return x;
        }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:28,代码来源:DHKeyGeneratorHelper.cs

示例10: DsaParameters

		public DsaParameters(
            BigInteger	p,
            BigInteger	q,
            BigInteger	g)
			: this(p, q, g, null)
        {
        }
开发者ID:htlp,项目名称:itextsharp,代码行数:7,代码来源:DsaParameters.cs

示例11: AddCrlEntry

        /**
        * Reason being as indicated by ReasonFlags, i.e. ReasonFlags.keyCompromise
        * or 0 if ReasonFlags are not to be used
        **/
        public void AddCrlEntry(
			BigInteger	userCertificate,
			DateTime	revocationDate,
			int			reason)
        {
            tbsGen.AddCrlEntry(new DerInteger(userCertificate), new Time(revocationDate), reason);
        }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:11,代码来源:X509V2CRLGenerator.cs

示例12: Generate

		public TimeStampRequest Generate(
			string		digestAlgorithmOid,
			byte[]		digest,
			BigInteger	nonce)
		{
			if (digestAlgorithmOid == null)
			{
				throw new ArgumentException("No digest algorithm specified");
			}

			DerObjectIdentifier digestAlgOid = new DerObjectIdentifier(digestAlgorithmOid);

			AlgorithmIdentifier algID = new AlgorithmIdentifier(digestAlgOid, DerNull.Instance);
			MessageImprint messageImprint = new MessageImprint(algID, digest);

			X509Extensions  ext = null;

			if (extOrdering.Count != 0)
			{
				ext = new X509Extensions(extOrdering, extensions);
			}

			DerInteger derNonce = nonce == null
				?	null
				:	new DerInteger(nonce);

			return new TimeStampRequest(
				new TimeStampReq(messageImprint, reqPolicy, derNonce, certReq, ext));
		}
开发者ID:ktw,项目名称:OutlookPrivacyPlugin,代码行数:29,代码来源:TimeStampRequestGenerator.cs

示例13: GenerateKeyPair

        /**
         * Given the domain parameters this routine Generates an EC key
         * pair in accordance with X9.62 section 5.2.1 pages 26, 27.
         */
        public IAsymmetricCipherKeyPair GenerateKeyPair()
        {
            var n = _parameters.N;
            IBigInteger d;
            do
            {
                d = new BigInteger(n.BitLength, _random);
            }
            while (d.SignValue == 0 || (d.CompareTo(n) >= 0));

            var isEcdh = _algorithm == "ECDH";

            var q = _parameters.G.Multiply(d);

            if (_publicKeyParamSet != null)
            {
                return new AsymmetricCipherKeyPair(
                    isEcdh
                        ? new ECDHPublicKeyParameters(q, _publicKeyParamSet, _hashAlgorithm, _symmetricKeyAlgorithm)
                        : new ECPublicKeyParameters(_algorithm, q, _publicKeyParamSet),
                    new ECPrivateKeyParameters(_algorithm, d, _publicKeyParamSet));
            }
            return new AsymmetricCipherKeyPair(
                isEcdh
                    ? new ECDHPublicKeyParameters(q, _parameters, _hashAlgorithm, _symmetricKeyAlgorithm)
                    : new ECPublicKeyParameters(_algorithm, q, _parameters),
                new ECPrivateKeyParameters(_algorithm, d, _parameters));
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:32,代码来源:ECKeyPairGenerator.cs

示例14: Gost3410Parameters

		public Gost3410Parameters(
			BigInteger	p,
			BigInteger	q,
			BigInteger	a)
			: this(p, q, a, null)
		{
		}
开发者ID:ktw,项目名称:OutlookPrivacyPlugin,代码行数:7,代码来源:GOST3410Parameters.cs

示例15: X9ECParameters

		public X9ECParameters(
            ECCurve		curve,
            ECPoint		g,
            BigInteger	n)
            : this(curve, g, n, BigInteger.One, null)
        {
        }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:7,代码来源:X9ECParameters.cs


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