Skip to content

Expose content length decoder on AsnDecoder #101125

Closed
@bartonjs

Description

@bartonjs

When reading ASN.1 BER/CER/DER content from a Stream it's not currently possible to know how far ahead one needs to buffer in order to read the next item.

namespace System.Formats.Asn1
{
    public static partial class AsnDecoder
    {
        // returns null for "indefinite length"
        // (local length 0, but keep seeking until you find the "end of indefinite length" marker)
        public static int? DecodeLength(
            ReadOnlySpan<byte> source,
            AsnEncodingRules ruleSet,
            out int bytesConsumed);
       
        public static bool TryDecodeLength(
            ReadOnlySpan<byte> source,
            AsnEncodingRules ruleSet,
            out int? decodedLength,
            out int bytesConsumed);
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions