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


C# IBigInteger.Equals方法代码示例

本文整理汇总了C#中IBigInteger.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# IBigInteger.Equals方法的具体用法?C# IBigInteger.Equals怎么用?C# IBigInteger.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IBigInteger的用法示例。


在下文中一共展示了IBigInteger.Equals方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidatePublicValue

        public static IBigInteger ValidatePublicValue(IBigInteger N, IBigInteger val)
        {
            val = val.Mod(N);

            // Check that val % N != 0
            if (val.Equals(BigInteger.Zero))
                throw new CryptoException("Invalid public value: 0");

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

示例2: checkOptionalField

 protected void checkOptionalField(string name, IBigInteger expected, IBigInteger present)
 {
     if (expected != null)
     {
         if (!expected.Equals(present))
         {
             Fail(name + " field doesn't match.");
         }
     }
     else if (present != null)
     {
         Fail(name + " field found when none expected.");
     }
 }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:14,代码来源:ASN1UnitTest.cs

示例3: checkSignature

        private void checkSignature(
			int						size,
			ECPrivateKeyParameters	sKey,
			ECPublicKeyParameters	vKey,
			ISigner					sgr,
			SecureRandom			k,
			byte[]					message,
			IBigInteger				r,
			IBigInteger				s)
        {
            sgr.Init(true, new ParametersWithRandom(sKey, k));

            sgr.BlockUpdate(message, 0, message.Length);

            byte[] sigBytes = sgr.GenerateSignature();

            sgr.Init(false, vKey);

            sgr.BlockUpdate(message, 0, message.Length);

            if (!sgr.VerifySignature(sigBytes))
            {
                Fail(size + " bit EC verification failed");
            }

            IBigInteger[] sig = derDecode(sigBytes);

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

            if (!s.Equals(sig[1]))
            {
                Fail(size + "bit"
                    + ": s component wrong." + SimpleTest.NewLine
                    + " expecting: " + s + SimpleTest.NewLine
                    + " got      : " + sig[1]);
            }
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:43,代码来源:ECNRTest.cs

示例4: ModPow

        public IBigInteger ModPow(
            IBigInteger exponent,
            IBigInteger m)
        {
            if (m.SignValue < 1)
                throw new ArithmeticException("Modulus must be positive");

            if (m.Equals(One))
                return Zero;

            if (exponent.SignValue == 0)
                return One;

            if (SignValue == 0)
                return Zero;

            int[] zVal = null;
            int[] yAccum = null;
            int[] yVal;

            // Montgomery exponentiation is only possible if the modulus is odd,
            // but AFAIK, this is always the case for crypto algo's
            bool useMonty = ((m.Magnitude[m.Magnitude.Length - 1] & 1) == 1);
            long mQ = 0;
            if (useMonty)
            {
                mQ = m.GetMQuote();

                // tmp = this * R mod m
                IBigInteger tmp = ShiftLeft(32*m.Magnitude.Length).Mod(m);
                zVal = tmp.Magnitude;

                useMonty = (zVal.Length <= m.Magnitude.Length);

                if (useMonty)
                {
                    yAccum = new int[m.Magnitude.Length + 1];
                    if (zVal.Length < m.Magnitude.Length)
                    {
                        var longZ = new int[m.Magnitude.Length];
                        zVal.CopyTo(longZ, longZ.Length - zVal.Length);
                        zVal = longZ;
                    }
                }
            }

            if (!useMonty)
            {
                if (Magnitude.Length <= m.Magnitude.Length)
                {
                    //zAccum = new int[m.Magnitude.Length * 2];
                    zVal = new int[m.Magnitude.Length];
                    Magnitude.CopyTo(zVal, zVal.Length - Magnitude.Length);
                }
                else
                {
                    //
                    // in normal practice we'll never see this...
                    //
                    IBigInteger tmp = Remainder(m);

                    //zAccum = new int[m.Magnitude.Length * 2];
                    zVal = new int[m.Magnitude.Length];
                    tmp.Magnitude.CopyTo(zVal, zVal.Length - tmp.Magnitude.Length);
                }

                yAccum = new int[m.Magnitude.Length*2];
            }

            yVal = new int[m.Magnitude.Length];

            //
            // from LSW to MSW
            //
            for (int i = 0; i < exponent.Magnitude.Length; i++)
            {
                int v = exponent.Magnitude[i];
                int bits = 0;

                if (i == 0)
                {
                    while (v > 0)
                    {
                        v <<= 1;
                        bits++;
                    }

                    //
                    // first time in initialise y
                    //
                    zVal.CopyTo(yVal, 0);

                    v <<= 1;
                    bits++;
                }

                while (v != 0)
                {
                    if (useMonty)
                    {
//.........这里部分代码省略.........
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:101,代码来源:BigInteger.cs

示例5: GetRevokedCertificate

        public virtual X509CrlEntry GetRevokedCertificate(
			IBigInteger serialNumber)
        {
            IEnumerable certs = c.GetRevokedCertificateEnumeration();

            X509Name previousCertificateIssuer = IssuerDN;
            foreach (CrlEntry entry in certs)
            {
                X509CrlEntry crlEntry = new X509CrlEntry(entry, isIndirect, previousCertificateIssuer);

                if (serialNumber.Equals(entry.UserCertificate.Value))
                {
                    return crlEntry;
                }

                previousCertificateIssuer = crlEntry.GetCertificateIssuer();
            }

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


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