Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose content length decoder on AsnDecoder #101125

Closed
bartonjs opened this issue Apr 16, 2024 · 2 comments · Fixed by #101141
Closed

Expose content length decoder on AsnDecoder #101125

bartonjs opened this issue Apr 16, 2024 · 2 comments · Fixed by #101141
Assignees
Labels
api-approved API was approved in API review, it can be implemented area-System.Formats.Asn1
Milestone

Comments

@bartonjs
Copy link
Member

bartonjs commented Apr 16, 2024

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);
    }
}
@bartonjs bartonjs added this to the 9.0.0 milestone Apr 16, 2024
@bartonjs bartonjs self-assigned this Apr 16, 2024
@bartonjs bartonjs added blocking Marks issues that we want to fast track in order to unblock other important work api-ready-for-review API is ready for review, it is NOT ready for implementation labels Apr 16, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-formats-asn1, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

@bartonjs
Copy link
Member Author

bartonjs commented Apr 16, 2024

Video

Looks good as proposed

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);
    }
}

@bartonjs bartonjs added api-approved API was approved in API review, it can be implemented and removed blocking Marks issues that we want to fast track in order to unblock other important work api-ready-for-review API is ready for review, it is NOT ready for implementation labels Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-approved API was approved in API review, it can be implemented area-System.Formats.Asn1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant