2using System.Diagnostics.CodeAnalysis;
3using System.Runtime.ConstrainedExecution;
5using System.Threading.Tasks;
48 if (Content is not Vector CertificateListVector)
51 return TryParse(CertificateListVector, out Parsed);
65 if (CertificateListVector.Length != 3)
68 if (CertificateListVector.FirstElement is not Vector TbsCertList)
75 else if (CertificateListVector[1] is Vector AlgorithmIdentifier)
83 if (CertificateListVector[2] is not
byte[]
Signature)
181 if (this.Signature is
null)
183 Client?.
Error(
"No signature in CRL.");
187 if (this.AuthorityKeyIdentifier is
null)
189 Client?.
Error(
"No AKI in CRL.");
194 IdDomain, CountryCode, this.AuthorityKeyIdentifier, Client);
196 if (SignerCertificate is
null)
198 Client?.
Error(
"Unable to load issuer certificate from the AKI: " +
205 Client?.
Error(
"Unable to decode public key from issuer certificate.\r\n\r\n" +
206 Convert.ToBase64String(SignerCertificate.
Binary, Base64FormattingOptions.InsertLineBreaks));
210 if (this.SignatureAlgorithm.
VerifySignature(
this.ToBeSignedCertificateList.Binary,
211 this.Signature, SignerCertificate.
PublicKey, Client))
216 if (Client?.HasSniffers ??
false)
218 StringBuilder sb =
new();
220 sb.AppendLine(
"CRL signature verification failed.");
222 sb.AppendLine(
"Data to be signed:");
223 sb.AppendLine(Convert.ToBase64String(
this.ToBeSignedCertificateList.Binary,
224 Base64FormattingOptions.InsertLineBreaks));
226 sb.AppendLine(
"Signature:");
227 sb.AppendLine(Convert.ToBase64String(
this.Signature,
228 Base64FormattingOptions.InsertLineBreaks));
230 sb.AppendLine(
"Authority Key Identifier:");
233 sb.AppendLine(
"Public Key to verify signature:");
Static class for parsing and decoding security objects encoded using Abstract Syntax Notation 1 (ASN....
static bool TryDecodeDer(byte[] Data, out object? Value)
Decodes a DER-encoded object.
Certificate, as defined in RFC 5280, §4.1.
IPublicKey PublicKey
Certificate public key, used to verify signatures issued by the certificate.
byte[] Binary
ASN.1 DER encoded certificate.
Internal store of ICAO certificates
static Task< Certificate?> TryLoadCertificate(string IdDomain, string Country, byte[] KeyReference)
Tries to load an ICAO certificate, provided its country and key reference.
Certificate List, as defined in RFC 5280, §5.1
ToBeSignedCertificateList ToBeSignedCertificateList
List of certificates that is signed.
ISignatureAlgorithm SignatureAlgorithm
Algorithm used to sign the certificate list.
static bool TryParse(Vector CertificateListVector, [NotNullWhen(true)] out CertificateList? Parsed)
Tries to parse an ASN.1-encoded Certificate List, as defined in RFC 5280, §5.1
DateTimeOffset ThisUpdate
This update
byte[] Signature
Digital signature.
bool HasBeenRevoked(Certificate Certificate, out RevokedReason Reason)
Checks if a certificate has been revoked.
Vector Asn1Vector
ASN.1 decoded vector
int? Version
Version of document.
async Task< bool > VerifySignature(string IdDomain, string CountryCode, ICommunicationLayer? Client)
Verifies the signature of the CRL
DateTimeOffset NextUpdate
Next update, or DateTime.MaxValue if not specified.
byte?[] AuthorityKeyIdentifier
Authority Key Identifier
Vector? Extensions
Extensions
RevokedCertificate[] RevokedCertificates
List of revoked certificates.
Task< bool > VerifySignature(string IdDomain, string CountryCode)
Verifies the signature of the CRL
static bool TryParse(byte[] RawCertificateList, [NotNullWhen(true)] out CertificateList? Parsed)
Tries to parse an ASN.1-encoded Certificate List, as defined in RFC 5280, §5.1.
Reference to a revoked certificate.
Certificate List, without signature, as defined in RFC 5280, §5.1
int? Version
Version of document.
Vector? Extensions
Extensions
DateTimeOffset NextUpdate
Next update, or DateTime.MaxValue if not specified.
DateTimeOffset ThisUpdate
This update
byte?[] AuthorityKeyIdentifier
Authority Key Identifier
RevokedCertificate[] RevokedCertificates
List of revoked certificates.
static bool TryParse(Vector TbsCertList, [NotNullWhen(true)] out ToBeSignedCertificateList? Parsed)
Tries to parse an ASN.1-encoded Certificate List, as defined in RFC 5280, §5.1
bool HasBeenRevoked(Certificate Certificate, out RevokedReason Reason)
Checks if a certificate has been revoked.
Abstract base class for signature algorithms, as defined in RFC 5280.
SignatureAlgorithm()
Abstract base class for signature algorithms, as defined in RFC 5280.
Helps with common JSON-related tasks.
static string Encode(string s)
Encodes a string for inclusion in JSON.
Contains methods for simple hash calculations.
static string BinaryToString(byte[] Data)
Converts an array of bytes to a string with their hexadecimal representations (in lower case).
Interface for signature algorithms, as defined in RFC 5280.
bool VerifySignature(byte[] Data, byte[] Signature, IPublicKey PublicKey, ICommunicationLayer? Client)
Verifies a digital signature.
void Error(string Error)
Called to inform the viewer of an error state.
void Warning(string Warning)
Called to inform the viewer of a warning state.
Interface for observable classes implementing communication protocols.
RevokedReason
Reason for revoking a certificate