public static void Decode(ref AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory <byte> rebind, out EnvelopedDataAsn decoded) { decoded = default; AsnValueReader sequenceReader = reader.ReadSequence(expectedTag); AsnValueReader collectionReader; if (!sequenceReader.TryReadInt32(out decoded.Version)) { sequenceReader.ThrowIfNotEmpty(); } if (sequenceReader.HasData && sequenceReader.PeekTag().HasSameClassAndValue(new Asn1Tag(TagClass.ContextSpecific, 0))) { OriginatorInfoAsn tmpOriginatorInfo; OriginatorInfoAsn.Decode(ref sequenceReader, new Asn1Tag(TagClass.ContextSpecific, 0), rebind, out tmpOriginatorInfo); decoded.OriginatorInfo = tmpOriginatorInfo; } // Decode SEQUENCE OF for RecipientInfos { collectionReader = sequenceReader.ReadSetOf(); var tmpList = new List <RecipientInfoAsn>(); RecipientInfoAsn tmpItem; while (collectionReader.HasData) { RecipientInfoAsn.Decode(ref collectionReader, rebind, out tmpItem); tmpList.Add(tmpItem); } decoded.RecipientInfos = tmpList.ToArray(); } EncryptedContentInfoAsn.Decode(ref sequenceReader, rebind, out decoded.EncryptedContentInfo); if (sequenceReader.HasData && sequenceReader.PeekTag().HasSameClassAndValue(new Asn1Tag(TagClass.ContextSpecific, 1))) { // Decode SEQUENCE OF for UnprotectedAttributes { collectionReader = sequenceReader.ReadSetOf(new Asn1Tag(TagClass.ContextSpecific, 1)); var tmpList = new List <AttributeAsn>(); AttributeAsn tmpItem; while (collectionReader.HasData) { AttributeAsn.Decode(ref collectionReader, rebind, out tmpItem); tmpList.Add(tmpItem); } decoded.UnprotectedAttributes = tmpList.ToArray(); } } sequenceReader.ThrowIfNotEmpty(); }
public static void Decode(ref AsnValueReader reader, ReadOnlyMemory <byte> rebind, out EnvelopedDataAsn decoded) { Decode(ref reader, Asn1Tag.Sequence, rebind, out decoded); }