コード例 #1
0
ファイル: EssCertIdV2.cs プロジェクト: dslzuha/nugetclient
        internal static EssCertIdV2 Read(DerSequenceReader reader)
        {
            var sequenceReader = reader.ReadSequence();

            AlgorithmIdentifier algorithm;

            if (sequenceReader.HasTag(DerSequenceReader.ConstructedSequence))
            {
                algorithm = AlgorithmIdentifier.Read(sequenceReader);
            }
            else
            {
                algorithm = new AlgorithmIdentifier(new Oid(Oids.Sha256));
            }

            var          hash         = sequenceReader.ReadOctetString();
            IssuerSerial issuerSerial = null;

            if (sequenceReader.HasData)
            {
                issuerSerial = IssuerSerial.Read(sequenceReader);

                if (sequenceReader.HasData)
                {
                    throw new SignatureException(Strings.SigningCertificateV2Invalid);
                }
            }

            return(new EssCertIdV2(algorithm, hash, issuerSerial));
        }
コード例 #2
0
        public static void VerifySerialNumber(X509Certificate2 certificate, NuGet.Packaging.Signing.IssuerSerial issuerSerial)
        {
            var serialNumber = certificate.GetSerialNumber();

            // Convert from little endian to big endian.
            Array.Reverse(serialNumber);

            VerifyByteArrays(serialNumber, issuerSerial.SerialNumber);
        }
コード例 #3
0
        private static bool AreSerialNumbersEqual(IssuerSerial issuerSerial, X509Certificate2 certificate)
        {
            var certificateSerialNumber = certificate.GetSerialNumber();

            // Convert from little endian to big endian.
            Array.Reverse(certificateSerialNumber);

            return(issuerSerial.SerialNumber.SequenceEqual(certificateSerialNumber));
        }
コード例 #4
0
        private static bool AreGeneralNamesEqual(IssuerSerial issuerSerial, X509Certificate2 certificate)
        {
            var generalName = issuerSerial.GeneralNames.FirstOrDefault();

            if (generalName != null &&
                generalName.DirectoryName != null)
            {
                return(string.Equals(generalName.DirectoryName.Name, certificate.IssuerName.Name, StringComparison.Ordinal));
            }

            return(true);
        }
コード例 #5
0
        internal static EssCertId Read(DerSequenceReader reader)
        {
            var          sequenceReader = reader.ReadSequence();
            var          hash           = sequenceReader.ReadOctetString();
            IssuerSerial issuerSerial   = null;

            if (sequenceReader.HasData)
            {
                issuerSerial = IssuerSerial.Read(sequenceReader);

                if (sequenceReader.HasData)
                {
                    throw new SignatureException(Strings.SigningCertificateInvalid);
                }
            }

            return(new EssCertId(hash, issuerSerial));
        }
コード例 #6
0
 private EssCertId(byte[] hash, IssuerSerial issuerSerial)
 {
     CertificateHash = hash;
     IssuerSerial    = issuerSerial;
 }
コード例 #7
0
ファイル: EssCertIdV2.cs プロジェクト: dslzuha/nugetclient
 private EssCertIdV2(AlgorithmIdentifier hashAlgorithm, byte[] hash, IssuerSerial issuerSerial)
 {
     HashAlgorithm   = hashAlgorithm;
     CertificateHash = hash;
     IssuerSerial    = issuerSerial;
 }