コード例 #1
0
 public byte[] GetCertHash()
 {
     if (otherCertHash.ToAsn1Object() is Asn1OctetString)
     {
         return(((Asn1OctetString)otherCertHash.ToAsn1Object()).GetOctets());
     }
     return(DigestInfo.GetInstance(otherCertHash).GetDigest());
 }
コード例 #2
0
        private static void CheckAsn1(byte[] result)
        {
            Assert.IsNotNull(result);

            DigestInfo digestInfo = DigestInfo.GetInstance(Asn1Object.FromByteArray(result));

            Assert.IsNotNull(digestInfo.AlgorithmID.Algorithm);
            Assert.IsNotNull(digestInfo.GetDigest());
        }
コード例 #3
0
        private DigestInfo DerDecode(
            byte[] encoding)
        {
            if (encoding[0] != (int)(Asn1Tags.Constructed | Asn1Tags.Sequence))
            {
                throw new IOException("not a digest info object");
            }

            return(DigestInfo.GetInstance(Asn1Object.FromByteArray(encoding)));
        }
コード例 #4
0
 private MacData(Asn1Sequence seq)
 {
     this.digInfo = DigestInfo.GetInstance(seq[0]);
     this.salt    = ((Asn1OctetString)seq[1]).GetOctets();
     if (seq.Count == 3)
     {
         this.iterationCount = ((DerInteger)seq[2]).Value;
         return;
     }
     this.iterationCount = BigInteger.One;
 }
コード例 #5
0
        private DigestInfo DerDecode(byte[] encoding)
        {
            if (encoding[0] != 48)
            {
                throw new IOException("not a digest info object");
            }
            DigestInfo instance = DigestInfo.GetInstance(Asn1Object.FromByteArray(encoding));

            if (instance.GetEncoded().Length != encoding.Length)
            {
                throw new CmsException("malformed RSA signature");
            }
            return(instance);
        }
コード例 #6
0
        private DigestInfo DerDecode(byte[] encoding)
        {
            //IL_000c: Unknown result type (might be due to invalid IL or missing references)
            if (encoding[0] != 48)
            {
                throw new IOException("not a digest info object");
            }
            DigestInfo instance = DigestInfo.GetInstance(Asn1Object.FromByteArray(encoding));

            if (instance.GetEncoded().Length != encoding.Length)
            {
                throw new CmsException("malformed RSA signature");
            }
            return(instance);
        }
コード例 #7
0
        private DigestInfo DerDecode(
            byte[] encoding)
        {
            if (encoding[0] != (int)(Asn1Tags.Constructed | Asn1Tags.Sequence))
            {
                throw new IOException("not a digest info object");
            }

            DigestInfo digInfo = DigestInfo.GetInstance(Asn1Object.FromByteArray(encoding));

            // length check to avoid Bleichenbacher vulnerability

            if (digInfo.GetEncoded().Length != encoding.Length)
            {
                throw new CmsException("malformed RSA signature");
            }

            return(digInfo);
        }
コード例 #8
0
 public OtherCertID(Asn1Sequence seq)
 {
     if (seq.Count < 1 || seq.Count > 2)
     {
         throw new ArgumentException("Bad sequence size: " + seq.Count);
     }
     if (seq[0].ToAsn1Object() is Asn1OctetString)
     {
         otherCertHash = Asn1OctetString.GetInstance(seq[0]);
     }
     else
     {
         otherCertHash = DigestInfo.GetInstance(seq[0]);
     }
     if (seq.Count > 1)
     {
         issuerSerial = IssuerSerial.GetInstance(Asn1Sequence.GetInstance(seq[1]));
     }
 }
コード例 #9
0
 public OtherCertID(Asn1Sequence seq)
 {
     //IL_002d: Unknown result type (might be due to invalid IL or missing references)
     if (seq.Count < 1 || seq.Count > 2)
     {
         throw new ArgumentException(string.Concat((object)"Bad sequence size: ", (object)seq.Count));
     }
     if (seq[0].ToAsn1Object() is Asn1OctetString)
     {
         otherCertHash = Asn1OctetString.GetInstance(seq[0]);
     }
     else
     {
         otherCertHash = DigestInfo.GetInstance(seq[0]);
     }
     if (seq.Count > 1)
     {
         issuerSerial = IssuerSerial.GetInstance(Asn1Sequence.GetInstance(seq[1]));
     }
 }
コード例 #10
0
        private LinkedCertificate(Asn1Sequence seq)
        {
            this.mDigest       = DigestInfo.GetInstance(seq[0]);
            this.mCertLocation = GeneralName.GetInstance(seq[1]);

            for (int i = 2; i < seq.Count; ++i)
            {
                Asn1TaggedObject tagged = Asn1TaggedObject.GetInstance(seq[i]);

                switch (tagged.TagNo)
                {
                case 0:
                    this.mCertIssuer = X509Name.GetInstance(tagged, false);
                    break;

                case 1:
                    this.mCACerts = GeneralNames.GetInstance(tagged, false);
                    break;

                default:
                    throw new ArgumentException("unknown tag in tagged field");
                }
            }
        }