Exemplo n.º 1
0
        internal static void Decode(AsnReader reader, out Rfc3161Accuracy decoded)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            Decode(reader, Asn1Tag.Sequence, out decoded);
        }
Exemplo n.º 2
0
        internal static void Decode(AsnReader reader, Asn1Tag expectedTag, out Rfc3161Accuracy decoded)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            decoded = default;
            AsnReader sequenceReader = reader.ReadSequence(expectedTag);


            if (sequenceReader.HasData && sequenceReader.PeekTag().HasSameClassAndValue(Asn1Tag.Integer))
            {
                if (sequenceReader.TryReadInt32(out int tmpSeconds))
                {
                    decoded.Seconds = tmpSeconds;
                }
                else
                {
                    sequenceReader.ThrowIfNotEmpty();
                }
            }


            if (sequenceReader.HasData && sequenceReader.PeekTag().HasSameClassAndValue(new Asn1Tag(TagClass.ContextSpecific, 0)))
            {
                if (sequenceReader.TryReadInt32(new Asn1Tag(TagClass.ContextSpecific, 0), out int tmpMillis))
                {
                    decoded.Millis = tmpMillis;
                }
                else
                {
                    sequenceReader.ThrowIfNotEmpty();
                }
            }


            if (sequenceReader.HasData && sequenceReader.PeekTag().HasSameClassAndValue(new Asn1Tag(TagClass.ContextSpecific, 1)))
            {
                if (sequenceReader.TryReadInt32(new Asn1Tag(TagClass.ContextSpecific, 1), out int tmpMicros))
                {
                    decoded.Micros = tmpMicros;
                }
                else
                {
                    sequenceReader.ThrowIfNotEmpty();
                }
            }


            sequenceReader.ThrowIfNotEmpty();
        }
 internal static void Decode(ref AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory <byte> rebind, out Rfc3161Accuracy decoded)
 {
     try
     {
         DecodeCore(ref reader, expectedTag, rebind, out decoded);
     }
     catch (AsnContentException e)
     {
         throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding, e);
     }
 }
        private static void DecodeCore(ref AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory <byte> rebind, out Rfc3161Accuracy decoded)
        {
            decoded = default;
            AsnValueReader sequenceReader = reader.ReadSequence(expectedTag);


            if (sequenceReader.HasData && sequenceReader.PeekTag().HasSameClassAndValue(Asn1Tag.Integer))
            {
                if (sequenceReader.TryReadInt32(out int tmpSeconds))
                {
                    decoded.Seconds = tmpSeconds;
                }
                else
                {
                    sequenceReader.ThrowIfNotEmpty();
                }
            }


            if (sequenceReader.HasData && sequenceReader.PeekTag().HasSameClassAndValue(new Asn1Tag(TagClass.ContextSpecific, 0)))
            {
                if (sequenceReader.TryReadInt32(out int tmpMillis, new Asn1Tag(TagClass.ContextSpecific, 0)))
                {
                    decoded.Millis = tmpMillis;
                }
                else
                {
                    sequenceReader.ThrowIfNotEmpty();
                }
            }
 internal static void Decode(ref AsnValueReader reader, ReadOnlyMemory <byte> rebind, out Rfc3161Accuracy decoded)
 {
     Decode(ref reader, Asn1Tag.Sequence, rebind, out decoded);
 }