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)); }
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); }
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)); }
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); }
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)); }
private EssCertId(byte[] hash, IssuerSerial issuerSerial) { CertificateHash = hash; IssuerSerial = issuerSerial; }
private EssCertIdV2(AlgorithmIdentifier hashAlgorithm, byte[] hash, IssuerSerial issuerSerial) { HashAlgorithm = hashAlgorithm; CertificateHash = hash; IssuerSerial = issuerSerial; }