6using System.Diagnostics.CodeAnalysis;
7using System.Formats.Asn1;
46 this.PublicKey = CertificatePublicKey;
60 int c = TbsCert.Length;
66 if (TbsCert.FirstElement is not
System.Numerics.BigInteger V)
68 if (TbsCert.FirstElement is not Vector VersionVector ||
69 VersionVector.Length != 1 ||
70 VersionVector.FirstElement is not
System.Numerics.BigInteger V2)
78 if (V < int.MinValue || V >
int.MaxValue)
91 object? Obj = TbsCert[i++];
95 if (Obj is not Vector AlgorithmIdentifier)
99 if (IssuerSignatureAlgorithm2 is
null)
105 if (i >= c || TbsCert[i++] is not Vector
Issuer)
109 TbsCert[i++] is not Vector Validity ||
110 Validity.Length != 2 ||
111 Validity.FirstElementNested is not DateTimeOffset
NotBefore ||
112 Validity.LastElementNested is not DateTimeOffset
NotAfter)
117 if (i >= c || TbsCert[i++] is not Vector
Subject)
120 if (i >= c || TbsCert[i++] is not Vector SubjectPublicKeyInfo)
123 if (SubjectPublicKeyInfo.Length != 2)
126 Obj = SubjectPublicKeyInfo.FirstElementNested;
130 if (Obj is Vector v &&
147 Vector? ListExtensions;
151 if (i < c && TbsCert[i] is
byte[] ExtensionsBin)
153 if (!
ASN1.
TryDecodeDerAs(UniversalTagNumber.Sequence, ExtensionsBin, out
object? Extensions2))
156 TbsCert.Elements.SetValue(Extensions2, i);
159 if (i < c && TbsCert[i] is Vector ListExtensions2)
163 if (ListExtensions2.Length == 1 &&
164 ListExtensions2.FirstElementNested is Vector ListExtensions3 &&
165 (ListExtensions2.SubSection[0] & 0x80) != 0)
167 ListExtensions2 = ListExtensions3;
170 ListExtensions = ListExtensions2;
172 foreach (
object? Extension
in ListExtensions2)
181 ListExtensions =
null;
Static class for parsing and decoding security objects encoded using Abstract Syntax Notation 1 (ASN....
static bool TryDecodeDerAs(UniversalTagNumber TagNumber, byte[] Data, out object? Value)
Decodes a DER-encoded object.
Certificate, without signature, as defined in RFC 5280, §4.1
ISignatureAlgorithm IssuerSignatureAlgorithm
Signature algorithm used by issuer to sign the certificate.
System.Numerics.BigInteger SerialNumber
Serial Number
DateTimeOffset NotAfter
Signatures cannot be created after this timestamp.
byte?[] AuthorityKeyIdentifier
Authority Key Identifier
DateTimeOffset NotBefore
Signatures cannot be created before this timestamp.
Vector? Extensions
Extensions
static bool TryParse(Vector TbsCert, [NotNullWhen(true)] out ToBeSignedCertificate? Parsed)
Tries to parse an ASN.1-encoded Certificate, as defined in RFC 5280, §4.1
byte[] Binary
Binary representation of certificate to be signed.
int Version
Version of document.
byte?[] SubjectKeyIdentifier
Subject Key Identifier
byte[] Identifier
Key identifier
Abstract base class for public keys.
abstract bool SetPublicKey(object? PublicKey)
Sets the public key, based on the security information provided.
abstract bool IsConfigured
If the object has been configured.
Abstract base class for signature algorithms, as defined in RFC 5280.
static ? ISignatureAlgorithm TryDecode(Vector AlgorithmIdentifier)
Tries to decode an ASN.1-decoded algorithm identifier into an instance of the corresponding signature...
Interface for public keys.
Interface for signature algorithms, as defined in RFC 5280.
class Names(Vector NamesVector)
Contains a collection of distinguished names.