void decode(Byte[] rawData) { Asn1Reader asn = new Asn1Reader(rawData); asn.MoveNext(); ContentType = new Asn1ObjectIdentifier(asn.GetTagRawData()).Value; asn.MoveNextAndExpectTags(0xa0); // [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL, 0xa0 asn.MoveNextAndExpectTags(0x30); // SEQUENCE OF ANY asn.MoveNextAndExpectTags((Byte)Asn1Type.INTEGER); // version Version = (Int32)new Asn1Integer(asn.GetTagRawData()).Value; asn.MoveNextCurrentLevelAndExpectTags(0x31); decodeDigestAlgorithms(asn); asn.MoveNextCurrentLevelAndExpectTags(0x30); // ContentInfo Byte[] content = extractContent(asn); while (asn.MoveNextCurrentLevel()) { switch (asn.Tag) { case 0xa0: decodeCertificates(asn); break; case 0xa1: decodeCrls(asn); break; case 0x31: decodeSignerInfos(asn); break; default: throw new ArgumentException("Invalid type."); } } RawData = rawData; DecodeContent(content); }
public static X500RdnAttribute[] GetRdnAttributes(this X500DistinguishedName name) { if (name == null) { throw new ArgumentNullException("name"); } if (name.RawData == null || name.RawData.Length == 0) { return(null); } Asn1Reader asn = new Asn1Reader(name.RawData); if (!asn.MoveNext()) { return(null); } if (asn.NextCurrentLevelOffset == 0) { return(null); } var retValue = new List <X500RdnAttribute>(); do { Asn1Reader asn2 = new Asn1Reader(asn.GetPayload()); asn2.MoveNext(); Oid oid = Asn1Utils.DecodeObjectIdentifier(asn2.GetTagRawData()); asn2.MoveNext(); String value = Asn1Utils.DecodeAnyString(asn2.GetTagRawData(), null); retValue.Add(new X500RdnAttribute(oid, value)); } while (asn.MoveNextCurrentLevel()); return(retValue.ToArray()); }
void decodeCms(Asn1Reader asn) { asn.MoveNextAndExpectTags(48, (Byte)Asn1Type.OBJECT_IDENTIFIER); if (asn.Tag == 48) { Status = new TspStatusInfo(asn.GetTagRawData()); if (Status.ResponseStatus != TspResponseStatus.Granted && Status.ResponseStatus != TspResponseStatus.GrantedWithModifications) { return; } asn.MoveNextCurrentLevelAndExpectTags(48); } else { asn.MoveToPosition(0); } signedCms = new DefaultSignedPkcs7(asn.GetTagRawData()); ResponseType = signedCms.ContentType; switch (ResponseType.Value) { // TimeStamp Token case "1.2.840.113549.1.9.16.1.4": decodeTstInfo(new Asn1Reader(signedCms.Content)); break; // PKCS 7 DATA case "1.2.840.113549.1.7.1": break; } getSigningTime(); _rawData.AddRange(asn.GetRawData()); validate(); }
void decode(Asn1Reader asn) { if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } RawData = asn.GetTagRawData(); Int32 offset = asn.Offset; asn.MoveNext(); SerialNumber = Asn1Utils.DecodeInteger(asn.GetTagRawData(), true); asn.MoveNextAndExpectTags(Asn1Type.UTCTime, Asn1Type.GeneralizedTime); switch (asn.Tag) { case (Byte)Asn1Type.UTCTime: RevocationDate = new Asn1UtcTime(asn.GetTagRawData()).Value; break; case (Byte)Asn1Type.GeneralizedTime: RevocationDate = Asn1Utils.DecodeGeneralizedTime(asn.GetTagRawData()); break; } if (asn.MoveNextSibling()) { // use high-performant extension decoder instead of generic one. // Since CRLs may store a hundreds of thousands entries, this is // pretty reasonable to save loops whenever possible. readCrlReasonCode(asn); } asn.Seek(offset); }
void m_decode(Byte[] rawData) { Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } asn.MoveNextAndExpectTags((Byte)Asn1Type.OBJECT_IDENTIFIER); Oid = Asn1Utils.DecodeObjectIdentifier(asn.GetTagRawData()); asn.MoveNext(); Asn1Type[] types = { Asn1Type.IA5String, Asn1Type.PrintableString, Asn1Type.VisibleString, Asn1Type.UTF8String, Asn1Type.UniversalString, Asn1Type.BMPString, Asn1Type.TeletexString }; encodingTag = (Asn1Type)asn.Tag; Value = Asn1Utils.DecodeAnyString(asn.GetTagRawData(), types); RawData = rawData; }
void decode(Asn1Reader asn) { asn.MoveNextAndExpectTags((Byte)Asn1Type.INTEGER); Version = (Int32) new Asn1Integer(asn).Value; asn.MoveNextAndExpectTags(48); RequestMessage = new TspMessageImprint(asn.GetTagRawData()); while (asn.MoveNextCurrentLevel()) { switch (asn.Tag) { case (Byte)Asn1Type.OBJECT_IDENTIFIER: PolicyID = new Asn1ObjectIdentifier(asn).Value; break; case (Byte)Asn1Type.INTEGER: UseNonce = true; nonce = new Asn1Integer(asn).Value.ToByteArray(); break; case (Byte)Asn1Type.BOOLEAN: RequestCertificates = new Asn1Boolean(asn).Value; break; case 0xa0: var extList = new X509ExtensionCollection(); extList.Decode(asn.GetTagRawData()); foreach (X509Extension extension in extList) { _extensions.Add(extension); } break; } } }
void m_decode(Byte[] rawData) { CrossCertDistributionPoints = new X509AlternativeNameCollection(); Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new ArgumentException("The data is invalid"); } asn.MoveNext(); if (asn.Tag == (Byte)Asn1Type.INTEGER) { DeltaSyncTimeInSeconds = (Int32)Asn1Utils.DecodeInteger(asn.GetTagRawData()); asn.MoveNext(); } asn.MoveNext(); do { var altNames = new X509AlternativeNameCollection(); altNames.Decode(asn.GetTagRawData()); CrossCertDistributionPoints.AddRange(altNames); } while (asn.MoveNextCurrentLevel()); CrossCertDistributionPoints.Close(); }
void m_initialize(Byte[] rawData) { Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } asn.MoveNext(); SerialNumber = Asn1Utils.DecodeInteger(asn.GetTagRawData(), true); asn.MoveNext(); if (asn.Tag != (Byte)Asn1Type.UTCTime && asn.Tag != (Byte)Asn1Type.GeneralizedTime) { throw new Asn1InvalidTagException(asn.Offset); } if (asn.Tag == (Byte)Asn1Type.UTCTime) { RevocationDate = new Asn1UtcTime(asn.GetTagRawData()).Value; } if (asn.Tag == (Byte)Asn1Type.GeneralizedTime) { RevocationDate = Asn1Utils.DecodeGeneralizedTime(asn.GetTagRawData()); } if (asn.MoveNext()) { var extensions = new X509ExtensionCollection(); extensions.Decode(asn.GetTagRawData()); X509Extension crlReason = extensions[X509CertExtensions.X509CRLReasonCode]; if (crlReason != null) { ReasonCode = crlReason.RawData[2]; } } RawData = rawData; }
void m_decode(Byte[] rawData) { Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } if (!asn.MoveNext()) { throw new Asn1InvalidTagException(asn.Offset); } if (asn.Tag != (Byte)Asn1Type.OBJECT_IDENTIFIER) { throw new Asn1InvalidTagException(asn.Offset); } AlgorithmId = Asn1Utils.DecodeObjectIdentifier(asn.GetTagRawData()); //Oid2 oid2 = new Oid2(oid.Value, OidGroupEnum.SignatureAlgorithm, false); //AlgorithmId = String.IsNullOrEmpty(oid2.Value) // ? oid // : new Oid(oid2.Value, oid2.FriendlyName); Parameters = asn.MoveNext() ? asn.GetTagRawData() : Asn1Utils.EncodeNull(); RawData = rawData; }
void m_decode(Byte[] asnData) { Asn1Reader asn = new Asn1Reader(asnData); asn.MoveNext(); IssuerDomainOid = Asn1Utils.DecodeObjectIdentifier(asn.GetTagRawData()); asn.MoveNext(); SubjectDomainOid = Asn1Utils.DecodeObjectIdentifier(asn.GetTagRawData()); }
void m_decode(Byte[] rawData) { Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new ArgumentException("The data is invalid."); } asn.MoveNext(); Oid oid = Asn1Utils.DecodeObjectIdentifier(asn.GetTagRawData()); switch (oid.Value) { case "1.3.6.1.5.5.7.2.1": Type = X509PolicyQualifierType.CpsUrl; asn.MoveNext(); PolicyUrl = new Uri(Asn1Utils.DecodeIA5String(asn.GetTagRawData()).Replace("\0", null)); break; case "1.3.6.1.5.5.7.2.2": Type = X509PolicyQualifierType.UserNotice; if (!asn.MoveNext()) { return; } if (asn.Tag != 48) { throw new ArgumentException("The data is invalid."); } asn.MoveNext(); if (asn.Tag == 48) { Asn1Reader asn2 = new Asn1Reader(asn.GetTagRawData()); asn2.MoveNext(); NoticeReference = Asn1Utils.DecodeAnyString(asn2.GetTagRawData(), new[] { Asn1Type.IA5String, Asn1Type.VisibleString, Asn1Type.BMPString, Asn1Type.UTF8String }); asn2.MoveNext(); asn2.MoveNext(); NoticeNumber = (Int32)Asn1Utils.DecodeInteger(asn2.GetTagRawData()); if (asn.MoveNextCurrentLevel()) { NoticeText = Asn1Utils.DecodeAnyString(asn.GetTagRawData(), new[] { Asn1Type.IA5String, Asn1Type.VisibleString, Asn1Type.BMPString, Asn1Type.UTF8String }); } } else { NoticeText = Asn1Utils.DecodeAnyString(asn.GetTagRawData(), new[] { Asn1Type.IA5String, Asn1Type.VisibleString, Asn1Type.BMPString, Asn1Type.UTF8String }); } break; default: m_reset(); return; } }
void m_decode(Byte[] rawData) { Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } asn.MoveNextAndExpectTags((Byte)Asn1Type.OBJECT_IDENTIFIER); AlgorithmId = Asn1Utils.DecodeObjectIdentifier(asn.GetTagRawData()); Parameters = asn.MoveNext() ? asn.GetTagRawData() : null; RawData = rawData; }
void m_initialize(Asn1Reader response) { response.MoveNext(); CertId = new CertID(Asn1Utils.Encode(response.GetPayload(), 48)); response.MoveNextCurrentLevel(); switch (response.Tag) { case 128: CertStatus = CertificateStatus.Good; response.MoveNextCurrentLevel(); break; case 161: CertStatus = CertificateStatus.Revoked; response.MoveNext(); DateTime revokedWhen = Asn1Utils.DecodeGeneralizedTime(response.GetTagRawData()); response.MoveNext(); Int16 reason = 0; if (response.Tag == 160) { response.MoveNext(); reason = response.GetPayload()[0]; response.MoveNext(); } RevocationInfo = new X509CRLEntry(CertId.SerialNumber, revokedWhen, reason); break; case 130: CertStatus = CertificateStatus.Unknown; response.MoveNextCurrentLevel(); break; } //response.MoveNextCurrentLevel(); ThisUpdate = Asn1Utils.DecodeGeneralizedTime(response.GetTagRawData()); while (response.MoveNextCurrentLevel()) { switch (response.Tag) { case 160: Asn1Reader asn = new Asn1Reader(response.GetPayload()); NextUpdate = Asn1Utils.DecodeGeneralizedTime(asn.GetTagRawData()); break; case 161: Extensions.Decode(response.GetPayload()); break; } } }
void m_decode(Byte[] rawData) { Asn1Reader asn = new Asn1Reader(rawData); asn.MoveNext(); do { switch (asn.Tag) { case 0xa0: PermittedSubtree = decodeNamesFromAsn(asn.GetTagRawData()); break; case 0xa1: ExcludedSubtree = decodeNamesFromAsn(asn.GetTagRawData()); break; } } while (asn.MoveNextCurrentLevel()); }
void m_decode(Byte[] rawData) { Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } asn.MoveNextAndExpectTags(0x30); ToBeSignedData = asn.GetTagRawData(); asn.MoveNextCurrentLevelAndExpectTags(0x30); SignatureAlgorithm = new AlgorithmIdentifier(asn.GetTagRawData()); asn.MoveNextCurrentLevelAndExpectTags((Byte)Asn1Type.BIT_STRING); Signature = new Asn1BitString(asn); }
/// <summary> /// /// </summary> /// <param name="rawData"></param> /// <returns></returns> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="InvalidDataException"></exception> public static X509ExtensionCollection DecodeX509Extensions(Byte[] rawData) { if (rawData == null) { throw new ArgumentNullException("rawData"); } Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new InvalidDataException(); } X509ExtensionCollection exts = new X509ExtensionCollection(); if (!asn.MoveNext()) { throw new Asn1InvalidTagException(); } if (asn.NextOffset == 0) { return(exts); } do { exts.Add(DecodeX509Extension(asn.GetTagRawData())); } while (asn.MoveNextCurrentLevel()); return(exts); }
void decode(Byte[] rawData) { Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } asn.MoveNextAndExpectTags((Byte)Asn1Type.OBJECT_IDENTIFIER); algId = Asn1Utils.DecodeObjectIdentifier(asn.GetTagRawData()); if (asn.MoveNext()) { param = asn.GetTagRawData(); } _rawData.AddRange(rawData); }
void m_decode(Byte[] rawData) { var aiaUrls = new List <String>(); var ocspUrls = new List <String>(); var asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } asn.MoveNext(); do { Int32 offset = asn.Offset; if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } asn.MoveNext(); String oidString = Asn1Utils.DecodeObjectIdentifier(asn.GetTagRawData()).Value; asn.MoveNextAndExpectTags(0x86); switch (oidString) { case "1.3.6.1.5.5.7.48.2": aiaUrls.Add(Encoding.ASCII.GetString(asn.GetPayload())); break; case "1.3.6.1.5.5.7.48.1": ocspUrls.Add(Encoding.ASCII.GetString(asn.GetPayload())); break; } asn.MoveToPosition(offset); } while (asn.MoveNextCurrentLevel()); CertificationAuthorityIssuer = aiaUrls.ToArray(); OnlineCertificateStatusProtocol = ocspUrls.ToArray(); }
/// <summary> /// Decodes ASN.1-encoded byte array that represents a collection of <see cref="X509Extension"/> objects. /// </summary> /// <param name="extensions">Destination collection where decoded extensions will be added.</param> /// <param name="rawData">ASN.1-encoded byte array that represents extension collection.</param> /// <exception cref="Asn1InvalidTagException">Decoder encountered an unexpected ASN.1 type identifier.</exception> /// <exception cref="ArgumentNullException"> /// <strong>extensions</strong> and/or <strong>rawData</strong> parameter is null. /// </exception> /// <remarks>If current collection contains items, decoded items will be appended to existing items.</remarks> public static void Decode(this X509ExtensionCollection extensions, Byte[] rawData) { if (extensions == null) { throw new ArgumentNullException(nameof(extensions)); } if (rawData == null) { throw new ArgumentNullException(nameof(rawData)); } Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new Asn1InvalidTagException(); } if (!asn.MoveNext() || asn.NextOffset == 0) { return; } do { extensions.Add(X509ExtensionExtensions.Decode(asn.GetTagRawData())); } while (asn.MoveNextCurrentLevel()); }
// decoders void decodeOtherName() { try { Asn1Reader asn = new Asn1Reader(rawData); if (!asn.MoveNext()) { throw new ArgumentException("Input data is not valid OtherName."); } Oid oid = new Oid(Asn1Utils.DecodeObjectIdentifier(asn.GetTagRawData())); asn.MoveNextAndExpectTags(0xa0); asn.MoveNext(); OID = oid; switch (oid.Value) { // UPN case "1.3.6.1.4.1.311.20.2.3": Type = X509AlternativeNamesEnum.UserPrincipalName; if (asn.PayloadLength == 0) { return; } Value = Encoding.UTF8.GetString(asn.GetPayload()); break; // GUID case "1.3.6.1.4.1.311.25.1": if (asn.PayloadLength == 0) { return; } Guid guid = new Guid(asn.GetPayload()); Type = X509AlternativeNamesEnum.Guid; Value = guid.ToString(); break; default: Value = String.Empty; Type = X509AlternativeNamesEnum.OtherName; foreach (Byte B in asn.GetPayload()) { Value += $"{B:x2}" + " "; } Value = Value.Trim(); break; } } catch { throw new ArgumentException("Input data is not valid OtherName."); } }
void decode(Asn1Reader asn) { asn.MoveNextAndExpectTags(48); AlgorithmIdentifier = new AlgorithmIdentifier(asn.GetTagRawData()); asn.MoveNextCurrentLevelAndExpectTags((Byte)Asn1Type.OCTET_STRING); _msgHash.AddRange(new Asn1OctetString(asn).Value); }
void m_decode(Byte[] rawData) { List <String> aiaUrls = new List <String>(); List <String> ocspUrls = new List <String>(); Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new ArgumentException("The data is invalid"); } asn.MoveNext(); do { Asn1Reader asnurl = new Asn1Reader(asn.GetTagRawData()); if (asnurl.Tag != 48) { throw new ArgumentException("The data is invalid"); } asnurl.MoveNext(); String oidString = Asn1Utils.DecodeObjectIdentifier(asnurl.GetTagRawData()).Value; asnurl.MoveNext(); if (asnurl.Tag != 134) { throw new ArgumentException("The data is invalid"); } switch (oidString) { case "1.3.6.1.5.5.7.48.2": aiaUrls.Add(Encoding.ASCII.GetString(asnurl.GetPayload())); break; case "1.3.6.1.5.5.7.48.1": ocspUrls.Add(Encoding.ASCII.GetString(asnurl.GetPayload())); break; } } while (asn.MoveNextCurrentLevel()); CertificationAuthorityIssuer = aiaUrls.ToArray(); OnlineCertificateStatusProtocol = ocspUrls.ToArray(); }
void decodeValidity(Asn1Reader asn) { ThisUpdate = Asn1Utils.DecodeDateTime(asn.GetTagRawData()); Int32 offset = asn.Offset; asn.MoveNext(); if (asn.Tag == (Byte)Asn1Type.UTCTime || asn.Tag == (Byte)Asn1Type.GeneralizedTime) { NextUpdate = Asn1Utils.DecodeDateTime(asn.GetTagRawData()); } else { asn.MoveToPosition(offset); } //asn.MoveToPosition(offset); }
void getAttributes(Asn1Reader asn) { asn.MoveNext(); if (asn.PayloadLength == 0) { return; } do { X509Attribute attribute = X509Attribute.Decode(asn.GetTagRawData()); if (attribute.Oid.Value == X509ExtensionOid.CertificateExtensions) { //Extensions var extensions = new X509ExtensionCollection(); extensions.Decode(attribute.RawData); foreach (X509Extension extension in extensions) { _extensions.Add(extension); } } else { _attributes.Add(attribute); } } while (asn.MoveNextCurrentLevel()); }
void m_decode(Byte[] raw) { PolicyQualifiers = new X509PolicyQualifierCollection(); Asn1Reader asn = new Asn1Reader(raw); if (asn.Tag != 48) { throw new InvalidDataException("The data is invalid."); } asn.MoveNext(); PolicyOid = Asn1Utils.DecodeObjectIdentifier(asn.GetTagRawData()); if (asn.MoveNext()) { PolicyQualifiers.Decode(asn.GetTagRawData()); } }
/// <summary> /// Initializes <strong>UniversalTagBase</strong> object from an existing <see cref="Asn1Reader"/> object. /// </summary> /// <param name="asn">Existing <see cref="Asn1Reader"/> object.</param> protected void Initialize(Asn1Reader asn) { Tag = asn.Tag; TagName = asn.TagName; IsContainer = asn.IsConstructed; RawData = asn.GetTagRawData(); }
public static X509Extension DecodeX509Extension(Byte[] rawData) { if (rawData == null) { throw new ArgumentNullException(nameof(rawData)); } Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } asn.MoveNext(); if (asn.Tag != (Byte)Asn1Type.OBJECT_IDENTIFIER) { throw new Asn1InvalidTagException(asn.Offset); } Oid oid = new Asn1ObjectIdentifier(asn).Value; Boolean critical = false; asn.MoveNext(); if (asn.Tag == (Byte)Asn1Type.BOOLEAN) { critical = Asn1Utils.DecodeBoolean(asn.GetTagRawData()); asn.MoveNext(); } if (asn.Tag != (Byte)Asn1Type.OCTET_STRING) { throw new Asn1InvalidTagException(asn.Offset); } return(new X509Extension(oid, asn.GetPayload(), critical).ConvertExtension()); }
/// <summary> /// Decodes ASN.1-encoded byte array to an instance of <see cref="X509Extension"/> class. /// </summary> /// <param name="asn">ASN.1 reader that points to the beginning of the X.509 extension structure.</param> /// <exception cref="ArgumentNullException"><strong>asn</strong> parameter is null.</exception> /// <exception cref="Asn1InvalidTagException">Decoder encountered an unexpected ASN.1 type identifier.</exception> /// <returns>Decoded extension object.</returns> public static X509Extension Decode(Asn1Reader asn) { if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } Int32 offset = asn.Offset; asn.MoveNextAndExpectTags((Byte)Asn1Type.OBJECT_IDENTIFIER); Oid oid = new Asn1ObjectIdentifier(asn).Value; Boolean critical = false; asn.MoveNextAndExpectTags((Byte)Asn1Type.BOOLEAN, (Byte)Asn1Type.OCTET_STRING); if (asn.Tag == (Byte)Asn1Type.BOOLEAN) { critical = Asn1Utils.DecodeBoolean(asn.GetTagRawData()); asn.MoveNextAndExpectTags((Byte)Asn1Type.OCTET_STRING); } // at this point ASN points to OCTET_STRING X509Extension retValue = new X509Extension(oid, asn.GetPayload(), critical).ConvertExtension(); asn.Seek(offset); return(retValue); }
void decodeResponse() { asn = new Asn1Reader(RawData); if (asn.Tag != 48) { throw new Asn1InvalidTagException("Response data is not valid ASN.1 encoded data."); } //response status asn.MoveNextAndExpectTags((Byte)Asn1Type.ENUMERATED); ResponseStatus = (OCSPResponseStatus)asn.GetPayload()[0]; if (asn.NextOffset == 0) { return; } //responseBytesCS asn.MoveNextAndExpectTags(0xa0); asn.MoveNext(); asn.MoveNext(); decodeResponseType(new Asn1ObjectIdentifier(asn.GetTagRawData()).Value); asn.MoveNextAndExpectTags((Byte)Asn1Type.OCTET_STRING); //BasicOCSPResponse asn.MoveNextAndExpectTags(0x30); asn.MoveNext(); //tbsResponseData Asn1Reader tbsResponseData = new Asn1Reader(asn.GetTagRawData()); //decodetbsResponse(tbsResponseData); //signatureAlgorithm asn.MoveNextCurrentLevel(); SignatureAlgorithm = new AlgorithmIdentifier(Asn1Utils.Encode(asn.GetPayload(), 48)).AlgorithmId; //signature asn.MoveNextCurrentLevel(); Byte[] signature = asn.GetPayload().Skip(1).ToArray(); // GenericArray.GetSubArray(asn1.Payload, 1, asn1.Payload.Length - 1); SignerCertificates = new X509Certificate2Collection(); if (asn.MoveNext()) { asn.MoveNext(); Asn1Reader cert = new Asn1Reader(asn.GetPayload()); do { SignerCertificates.Add(new X509Certificate2(Asn1Utils.Encode(cert.GetPayload(), 48))); } while (cert.MoveNextCurrentLevel()); verifySigner(SignerCertificates[0], true); } // optional. Find cert in store. verifyAll(tbsResponseData, signature, SignatureAlgorithm); }
/// <summary> /// Initializes a new instance of the <strong>Asn1GeneralizedTime</strong> class from an existing /// <see cref="Asn1Reader"/> object. /// </summary> /// <param name="asn"><see cref="Asn1Reader"/> object in the position that represents Generalized Time.</param> /// <exception cref="Asn1InvalidTagException"> /// The current state of <strong>ASN1</strong> object is not Generalized Time. /// </exception> public Asn1GeneralizedTime(Asn1Reader asn) : base(asn) { if (asn.Tag != tag) { throw new Asn1InvalidTagException(String.Format(InvalidType, tagName)); } m_decode(asn.GetTagRawData()); }