< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 298
Coverable lines: 298
Total lines: 1066
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 76
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
File 1: GetMaxDecodedLength(...)0%220%
File 1: DecodeFromUtf8(...)100%110%
File 1: DecodeFromUtf8InPlace(...)0%220%
File 1: DecodeFromUtf8(...)0%440%
File 1: TryDecodeFromUtf8(...)0%440%
File 1: DecodeFromUtf8(...)0%10100%
File 1: DecodeFromChars(...)100%110%
File 1: DecodeFromChars(...)0%440%
File 1: TryDecodeFromChars(...)0%220%
File 1: DecodeFromChars(...)0%660%
File 1: GetMaxDecodedLength(...)100%110%
File 1: IsInvalidLength(...)100%110%
File 1: IsValidPadding(...)0%440%
File 1: SrcLength(...)0%220%
File 1: TryDecode128Core(...)0%220%
File 1: TryDecode256Core(...)0%220%
File 1: TryLoadVector512(...)100%110%
File 1: TryLoadAvxVector256(...)100%110%
File 1: TryLoadVector128(...)100%110%
File 1: TryLoadArmVector128x4(...)100%110%
File 1: DecodeFourElements(...)100%110%
File 1: DecodeRemaining(...)100%110%
File 1: IndexOfAnyExceptWhiteSpace(...)100%110%
File 1: DecodeWithWhiteSpaceBlockwiseWrapper(...)100%110%
File 1: GetMaxDecodedLength(...)100%110%
File 1: IsInvalidLength(...)100%110%
File 1: IsValidPadding(...)100%110%
File 1: SrcLength(...)100%110%
File 1: TryDecode128Core(...)100%110%
File 1: TryDecode256Core(...)100%110%
File 1: TryLoadVector512(...)100%110%
File 1: TryLoadAvxVector256(...)100%110%
File 1: TryLoadVector128(...)100%110%
File 1: TryLoadArmVector128x4(...)100%110%
File 1: DecodeFourElements(...)100%110%
File 1: DecodeRemaining(...)100%110%
File 1: IndexOfAnyExceptWhiteSpace(...)100%110%
File 1: DecodeWithWhiteSpaceBlockwiseWrapper(...)100%110%
File 2: EncodeToUtf8(...)100%110%
File 2: GetEncodedLength(...)0%220%
File 2: EncodeToUtf8(...)0%220%
File 2: EncodeToUtf8(...)100%110%
File 2: EncodeToChars(...)100%110%
File 2: EncodeToChars(...)0%220%
File 2: EncodeToChars(...)100%110%
File 2: EncodeToString(...)0%220%
File 2: TryEncodeToChars(...)100%110%
File 2: TryEncodeToUtf8(...)100%110%
File 2: TryEncodeToUtf8InPlace(...)100%110%
File 2: GetMaxSrcLength(...)0%440%
File 2: GetInPlaceDestinationLength(...)0%220%
File 2: GetMaxEncodedLength(...)100%110%
File 2: EncodeOneOptionallyPadTwo(...)100%110%
File 2: EncodeTwoOptionallyPadOne(...)100%110%
File 2: StoreVector512ToDestination(...)100%110%
File 2: StoreVector256ToDestination(...)100%110%
File 2: StoreVector128ToDestination(...)100%110%
File 2: StoreArmVector128x4ToDestination(...)100%110%
File 2: EncodeThreeAndWrite(...)100%110%
File 2: GetMaxSrcLength(...)100%110%
File 2: GetInPlaceDestinationLength(...)100%110%
File 2: GetMaxEncodedLength(...)100%110%
File 2: EncodeOneOptionallyPadTwo(...)100%110%
File 2: EncodeTwoOptionallyPadOne(...)100%110%
File 2: StoreVector512ToDestination(...)100%110%
File 2: StoreVector256ToDestination(...)100%110%
File 2: StoreVector128ToDestination(...)100%110%
File 2: StoreArmVector128x4ToDestination(...)100%110%
File 2: EncodeThreeAndWrite(...)100%110%
File 3: IsValid(...)100%110%
File 3: IsValid(...)100%110%
File 3: IsValid(...)100%110%
File 3: IsValid(...)100%110%
File 3: .cctor()100%110%
File 3: IndexOfAnyExcept(...)100%110%
File 3: IsWhiteSpace(...)100%110%
File 3: IsEncodingPad(...)0%220%
File 3: ValidateAndDecodeLength(...)100%110%
File 3: .cctor()100%110%
File 3: IndexOfAnyExcept(...)100%110%
File 3: IsWhiteSpace(...)100%110%
File 3: IsEncodingPad(...)0%220%
File 3: ValidateAndDecodeLength(...)0%14140%

File(s)

C:\h\w\B7B10A05\w\A2F5091A\e\runtime-utils\Runner\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Url\Base64UrlDecoder.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Diagnostics;
 5using System.Runtime.CompilerServices;
 6using System.Runtime.InteropServices;
 7#if NET
 8using System.Runtime.Intrinsics;
 9using System.Runtime.Intrinsics.Arm;
 10using System.Runtime.Intrinsics.X86;
 11#endif
 12using static System.Buffers.Text.Base64Helper;
 13
 14namespace System.Buffers.Text
 15{
 16    // AVX2 and Vector128 version based on https://github.com/gfoidl/Base64/blob/5383320e28cac6c7ac6f86502fb05d23a048a21
 17#pragma warning disable 1591 // TODO: Document this API. https://github.com/dotnet/runtime/issues/105974
 18    public static partial class Base64Url
 19#pragma warning restore 1591
 20    {
 21        private const int MaxStackallocThreshold = 256;
 22
 23        /// <summary>
 24        /// Returns the maximum length (in bytes) of the result if you were to decode base 64 encoded text from a span o
 25        /// </summary>
 26        /// <exception cref="ArgumentOutOfRangeException">The specified <paramref name="base64Length"/> is less than 0.
 27        /// </exception>
 28        public static int GetMaxDecodedLength(int base64Length)
 29        {
 30#if NET
 031            ArgumentOutOfRangeException.ThrowIfNegative(base64Length);
 32
 033            (uint whole, uint remainder) = uint.DivRem((uint)base64Length, 4);
 34
 035            return (int)(whole * 3 + (remainder > 0 ? remainder - 1 : 0));
 36#else
 37            if (base64Length < 0)
 38            {
 39                throw new ArgumentOutOfRangeException(nameof(base64Length));
 40            }
 41
 42            int remainder = (int)((uint)base64Length % 4);
 43
 44            return (base64Length >> 2) * 3 + (remainder > 0 ? remainder - 1 : 0);
 45#endif
 46        }
 47
 48        /// <summary>
 49        /// Decodes the span of UTF-8 encoded text represented as Base64Url into binary data.
 50        /// </summary>
 51        /// <param name="source">The input span which contains UTF-8 encoded text in Base64Url that needs to be decoded.
 52        /// <param name="destination">The output span which contains the result of the operation, i.e. the decoded binar
 53        /// <param name="bytesConsumed">When this method returns, contains the number of input bytes consumed during the
 54        /// <param name="bytesWritten">When this method returns, contains the number of bytes written into the output sp
 55        /// <param name="isFinalBlock"><see langword="true"/> when the input span contains the entirety of data to encod
 56        /// such as when calling in a loop. Calls with <see langword="false"/> should be followed up with another call w
 57        /// <returns>One of the enumeration values that indicates the success or failure of the operation.</returns>
 58        /// <remarks>
 59        /// As padding is optional for Base64Url the <paramref name="source"/> length not required to be a multiple of 4
 60        /// If the <paramref name="source"/> length is not a multiple of 4 and <paramref name="isFinalBlock"/> is <see l
 61        /// - Remainder of 3 bytes - decoded into 2 bytes data, decoding succeeds.
 62        /// - Remainder of 2 bytes - decoded into 1 byte data. decoding succeeds.
 63        /// - Remainder of 1 byte - will cause OperationStatus.InvalidData result.
 64        /// </remarks>
 65        public static OperationStatus DecodeFromUtf8(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesCon
 066            DecodeFrom(default(Base64UrlDecoderByte), source, destination, out bytesConsumed, out bytesWritten, isFinalB
 67
 68        /// <summary>
 69        /// Decodes the span of UTF-8 encoded text in Base64Url into binary data, in-place.
 70        /// The decoded binary output is smaller than the text data contained in the input (the operation deflates the d
 71        /// </summary>
 72        /// <param name="buffer">The input span which contains the base 64 text data that needs to be decoded.</param>
 73        /// <returns>The number of bytes written into <paramref name="buffer"/>. This can be used to slice the output fo
 74        /// <exception cref="FormatException"><paramref name="buffer"/> contains an invalid Base64Url character,
 75        /// more than two padding characters, or a non white space character among the padding characters.</exception>
 76        /// <remarks>
 77        /// As padding is optional for Base64Url the <paramref name="buffer"/> length not required to be a multiple of 4
 78        /// If the <paramref name="buffer"/> length is not a multiple of 4 the remainders decoded accordingly:
 79        /// - Remainder of 3 bytes - decoded into 2 bytes data, decoding succeeds.
 80        /// - Remainder of 2 bytes - decoded into 1 byte data. decoding succeeds.
 81        /// - Remainder of 1 byte - is invalid input, causes FormatException.
 82        /// </remarks>
 83        public static int DecodeFromUtf8InPlace(Span<byte> buffer)
 84        {
 085            OperationStatus status = DecodeFromUtf8InPlace<Base64UrlDecoderByte>(default, buffer, out int bytesWritten, 
 86
 87            // Base64.DecodeFromUtf8InPlace returns OperationStatus, therefore doesn't throw.
 88            // For Base64Url, this is not an OperationStatus API and thus throws.
 089            if (status == OperationStatus.InvalidData)
 90            {
 091                throw new FormatException(SR.Format_BadBase64Char);
 92            }
 93
 094            Debug.Assert(status is OperationStatus.Done);
 095            return bytesWritten;
 96        }
 97
 98        /// <summary>
 99        /// Decodes the span of UTF-8 encoded text represented as Base64Url into binary data.
 100        /// </summary>
 101        /// <param name="source">The input span which contains UTF-8 encoded text in Base64Url that needs to be decoded.
 102        /// <param name="destination">The output span which contains the result of the operation, i.e. the decoded binar
 103        /// <returns>The number of bytes written into <paramref name="destination"/>. This can be used to slice the outp
 104        /// <exception cref="ArgumentException">The buffer in <paramref name="destination"/> is too small to hold the en
 105        /// <exception cref="FormatException"><paramref name="source"/> contains an invalid Base64Url character,
 106        /// more than two padding characters, or a non white space character among the padding characters.</exception>
 107        /// <remarks>
 108        /// As padding is optional for Base64Url the <paramref name="source"/> length not required to be a multiple of 4
 109        /// If the <paramref name="source"/> length is not a multiple of 4 the remainders decoded accordingly:
 110        /// - Remainder of 3 bytes - decoded into 2 bytes data, decoding succeeds.
 111        /// - Remainder of 2 bytes - decoded into 1 byte data. decoding succeeds.
 112        /// - Remainder of 1 byte - is invalid input, causes FormatException.
 113        /// </remarks>
 114        public static int DecodeFromUtf8(ReadOnlySpan<byte> source, Span<byte> destination)
 115        {
 0116            OperationStatus status = DecodeFromUtf8(source, destination, out _, out int bytesWritten);
 117
 0118            if (status == OperationStatus.Done)
 119            {
 0120                return bytesWritten;
 121            }
 122
 0123            if (status == OperationStatus.DestinationTooSmall)
 124            {
 0125                throw new ArgumentException(SR.Argument_DestinationTooShort, nameof(destination));
 126            }
 127
 0128            Debug.Assert(status is OperationStatus.InvalidData);
 0129            throw new FormatException(SR.Format_BadBase64Char);
 130        }
 131
 132        /// <summary>
 133        /// Decodes the span of UTF-8 encoded text represented as Base64Url into binary data.
 134        /// </summary>
 135        /// <param name="source">The input span which contains UTF-8 encoded text in Base64Url that needs to be decoded.
 136        /// <param name="destination">The output span which contains the result of the operation, i.e. the decoded binar
 137        /// <param name="bytesWritten">When this method returns, contains the number of bytes written into the output sp
 138        /// <returns><see langword="true"/> if bytes decoded successfully, otherwise <see langword="false"/>.</returns>
 139        /// <exception cref="FormatException"><paramref name="source"/> contains an invalid Base64Url character,
 140        /// more than two padding characters, or a non white space character among the padding characters.</exception>
 141        public static bool TryDecodeFromUtf8(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten)
 142        {
 0143            OperationStatus status = DecodeFromUtf8(source, destination, out _, out bytesWritten);
 144
 0145            if (status == OperationStatus.InvalidData)
 146            {
 0147                throw new FormatException(SR.Format_BadBase64Char);
 148            }
 149
 0150            Debug.Assert(status is OperationStatus.Done or OperationStatus.DestinationTooSmall);
 0151            return status == OperationStatus.Done;
 152        }
 153
 154        /// <summary>
 155        /// Decodes the span of UTF-8 encoded text represented as Base64Url into binary data.
 156        /// </summary>
 157        /// <param name="source">The input span which contains UTF-8 encoded text in Base64Url that needs to be decoded.
 158        /// <returns>>A byte array which contains the result of the decoding operation.</returns>
 159        /// <exception cref="FormatException"><paramref name="source"/> contains an invalid Base64Url character,
 160        /// more than two padding characters, or a non white space character among the padding characters.</exception>
 161        public static byte[] DecodeFromUtf8(ReadOnlySpan<byte> source)
 162        {
 0163            int upperBound = GetMaxDecodedLength(source.Length);
 0164            byte[]? rented = null;
 165
 0166            Span<byte> destination = (uint)upperBound <= MaxStackallocThreshold
 0167                ? stackalloc byte[MaxStackallocThreshold]
 0168                : (rented = ArrayPool<byte>.Shared.Rent(upperBound));
 169
 0170            OperationStatus status = DecodeFromUtf8(source, destination, out _, out int bytesWritten);
 0171            Debug.Assert(status is OperationStatus.Done or OperationStatus.InvalidData);
 0172            byte[] ret = destination.Slice(0, bytesWritten).ToArray();
 173
 0174            if (rented is not null)
 175            {
 0176                ArrayPool<byte>.Shared.Return(rented);
 177            }
 178
 0179            return status == OperationStatus.Done ? ret : throw new FormatException(SR.Format_BadBase64Char);
 180        }
 181
 182        /// <summary>
 183        /// Decodes the span of unicode ASCII chars represented as Base64Url into binary data.
 184        /// </summary>
 185        /// <param name="source">The input span which contains unicode ASCII chars in Base64Url that needs to be decoded
 186        /// <param name="destination">The output span which contains the result of the operation, i.e. the decoded binar
 187        /// <param name="charsConsumed">When this method returns, contains the number of input chars consumed during the
 188        /// <param name="bytesWritten">When this method returns, contains the number of bytes written into the output sp
 189        /// <param name="isFinalBlock"><see langword="true"/> when the input span contains the entirety of data to encod
 190        /// such as when calling in a loop. Calls with <see langword="false"/> should be followed up with another call w
 191        /// <returns>One of the enumeration values that indicates the success or failure of the operation.</returns>
 192        /// <remarks>
 193        /// As padding is optional for Base64Url the <paramref name="source"/> length not required to be a multiple of 4
 194        /// If the <paramref name="source"/> length is not a multiple of 4 and <paramref name="isFinalBlock"/> is <see l
 195        /// - Remainder of 3 chars - decoded into 2 bytes data, decoding succeeds.
 196        /// - Remainder of 2 chars - decoded into 1 byte data. decoding succeeds.
 197        /// - Remainder of 1 char - will cause OperationStatus.InvalidData result.
 198        /// </remarks>
 199        public static OperationStatus DecodeFromChars(ReadOnlySpan<char> source, Span<byte> destination,
 200            out int charsConsumed, out int bytesWritten, bool isFinalBlock = true) =>
 0201            DecodeFrom(default(Base64UrlDecoderChar), MemoryMarshal.Cast<char, ushort>(source), destination,
 0202                out charsConsumed, out bytesWritten, isFinalBlock, ignoreWhiteSpace: true);
 203
 204        /// <summary>
 205        /// Decodes the span of unicode ASCII chars represented as Base64Url into binary data.
 206        /// </summary>
 207        /// <param name="source">The input span which contains ASCII chars in Base64Url that needs to be decoded.</param
 208        /// <param name="destination">The output span which contains the result of the operation, i.e. the decoded binar
 209        /// <returns>The number of bytes written into the output span. This can be used to slice the output for subseque
 210        /// <exception cref="ArgumentException">The buffer in <paramref name="destination"/> is too small to hold the en
 211        /// <exception cref="FormatException"><paramref name="source"/> contains a invalid Base64Url character,
 212        /// more than two padding characters, or a non white space character among the padding characters.</exception>
 213        public static int DecodeFromChars(ReadOnlySpan<char> source, Span<byte> destination)
 214        {
 0215            OperationStatus status = DecodeFromChars(source, destination, out _, out int bytesWritten);
 216
 0217            if (status == OperationStatus.Done)
 218            {
 0219                return bytesWritten;
 220            }
 221
 0222            if (status == OperationStatus.DestinationTooSmall)
 223            {
 0224                throw new ArgumentException(SR.Argument_DestinationTooShort, nameof(destination));
 225            }
 226
 0227            Debug.Assert(status == OperationStatus.InvalidData);
 0228            throw new FormatException(SR.Format_BadBase64Char);
 229        }
 230
 231        /// <summary>
 232        /// Decodes the span of unicode ASCII chars represented as Base64Url into binary data.
 233        /// </summary>
 234        /// <param name="source">The input span which contains ASCII chars in Base64Url that needs to be decoded.</param
 235        /// <param name="destination">The output span which contains the result of the operation, i.e. the decoded binar
 236        /// <param name="bytesWritten">When this method returns, contains the number of bytes written into the output sp
 237        /// <returns><see langword="true"/> if bytes decoded successfully, otherwise <see langword="false"/>.</returns>
 238        /// <exception cref="FormatException"><paramref name="source"/> contains an invalid Base64Url character,
 239        /// more than two padding characters, or a non white space character among the padding characters.</exception>
 240        public static bool TryDecodeFromChars(ReadOnlySpan<char> source, Span<byte> destination, out int bytesWritten)
 241        {
 0242            OperationStatus status = DecodeFromChars(source, destination, out _, out bytesWritten);
 243
 0244            if (status == OperationStatus.InvalidData)
 245            {
 0246                throw new FormatException(SR.Format_BadBase64Char);
 247            }
 248
 0249            return status == OperationStatus.Done;
 250        }
 251
 252        /// <summary>
 253        /// Decodes the span of unicode ASCII chars represented as Base64Url into binary data.
 254        /// </summary>
 255        /// <param name="source">The input span which contains ASCII chars in Base64Url that needs to be decoded.</param
 256        /// <returns>A byte array which contains the result of the decoding operation.</returns>
 257        /// <exception cref="FormatException"><paramref name="source"/> contains a invalid Base64Url character,
 258        /// more than two padding characters, or a non white space character among the padding characters.</exception>
 259        public static byte[] DecodeFromChars(ReadOnlySpan<char> source)
 260        {
 0261            int upperBound = GetMaxDecodedLength(source.Length);
 0262            byte[]? rented = null;
 263
 0264            Span<byte> destination = (uint)upperBound <= MaxStackallocThreshold
 0265                ? stackalloc byte[MaxStackallocThreshold]
 0266                : (rented = ArrayPool<byte>.Shared.Rent(upperBound));
 267
 0268            OperationStatus status = DecodeFromChars(source, destination, out _, out int bytesWritten);
 0269            byte[] ret = destination.Slice(0, bytesWritten).ToArray();
 270
 0271            if (rented is not null)
 272            {
 0273                ArrayPool<byte>.Shared.Return(rented);
 274            }
 275
 0276            return status == OperationStatus.Done ? ret : throw new FormatException(SR.Format_BadBase64Char);
 277        }
 278
 279        private readonly struct Base64UrlDecoderByte : IBase64Decoder<byte>
 280        {
 281            public ReadOnlySpan<sbyte> DecodingMap =>
 0282                [
 0283                    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 0284                    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 0285                    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1,         //62 is placed at index 45 (
 0286                    52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,         //52-61 are placed at index 
 0287                    -1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,
 0288                    15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63,         //0-25 are placed at index 6
 0289                    -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
 0290                    41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,         //26-51 are placed at index 
 0291                    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,         // Bytes over 122 ('z') are 
 0292                    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,         // Hence, padding the map wi
 0293                    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 0294                    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 0295                    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 0296                    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 0297                    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 0298                    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 0299                ];
 300
 301            public ReadOnlySpan<uint> VbmiLookup0 =>
 0302                [
 0303                    0x80808080, 0x80808080, 0x80808080, 0x80808080,
 0304                    0x80808080, 0x80808080, 0x80808080, 0x80808080,
 0305                    0x80808080, 0x80808080, 0x80808080, 0x80803e80,
 0306                    0x37363534, 0x3b3a3938, 0x80803d3c, 0x80808080
 0307                ];
 308
 309            public ReadOnlySpan<uint> VbmiLookup1 =>
 0310                [
 0311                    0x02010080, 0x06050403, 0x0a090807, 0x0e0d0c0b,
 0312                    0x1211100f, 0x16151413, 0x80191817, 0x3f808080,
 0313                    0x1c1b1a80, 0x201f1e1d, 0x24232221, 0x28272625,
 0314                    0x2c2b2a29, 0x302f2e2d, 0x80333231, 0x80808080
 0315                ];
 316
 317            public ReadOnlySpan<sbyte> Avx2LutHigh =>
 0318                [
 0319                    0x00, 0x00, 0x2d, 0x39,
 0320                    0x4f, 0x5a, 0x6f, 0x7a,
 0321                    0x00, 0x00, 0x00, 0x00,
 0322                    0x00, 0x00, 0x00, 0x00,
 0323                    0x00, 0x00, 0x2d, 0x39,
 0324                    0x4f, 0x5a, 0x6f, 0x7a,
 0325                    0x00, 0x00, 0x00, 0x00,
 0326                    0x00, 0x00, 0x00, 0x00
 0327                ];
 328
 329            public ReadOnlySpan<sbyte> Avx2LutLow =>
 0330                [
 0331                    0x01, 0x01, 0x2d, 0x30,
 0332                    0x41, 0x50, 0x61, 0x70,
 0333                    0x01, 0x01, 0x01, 0x01,
 0334                    0x01, 0x01, 0x01, 0x01,
 0335                    0x01, 0x01, 0x2d, 0x30,
 0336                    0x41, 0x50, 0x61, 0x70,
 0337                    0x01, 0x01, 0x01, 0x01,
 0338                    0x01, 0x01, 0x01, 0x01
 0339                ];
 340
 341            public ReadOnlySpan<sbyte> Avx2LutShift =>
 0342                [
 0343                    0,   0,  17,   4,
 0344                  -65, -65, -71, -71,
 0345                    0,   0,   0,   0,
 0346                    0,   0,   0,   0,
 0347                    0,   0,  17,   4,
 0348                  -65, -65, -71, -71,
 0349                    0,   0,   0,   0,
 0350                    0,   0,   0,   0
 0351                ];
 352
 0353            public byte MaskSlashOrUnderscore => (byte)'_'; // underscore
 354
 0355            public ReadOnlySpan<int> Vector128LutHigh => [0x392d0000, 0x7a6f5a4f, 0x00000000, 0x00000000];
 356
 0357            public ReadOnlySpan<int> Vector128LutLow => [0x302d0101, 0x70615041, 0x01010101, 0x01010101];
 358
 0359            public ReadOnlySpan<uint> Vector128LutShift => [0x04110000, 0xb9b9bfbf, 0x00000000, 0x00000000];
 360
 0361            public ReadOnlySpan<uint> AdvSimdLutOne3 => [0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFF3EFF];
 362
 0363            public uint AdvSimdLutTwo3Uint1 => 0x1B1AFF3F;
 364
 0365            public int GetMaxDecodedLength(int sourceLength) => Base64Url.GetMaxDecodedLength(sourceLength);
 366
 0367            public bool IsInvalidLength(int bufferLength) => (bufferLength & 3) == 1; // One byte cannot be decoded comp
 368
 0369            public bool IsValidPadding(uint padChar) => padChar is EncodingPad or UrlEncodingPad;
 370
 0371            public int SrcLength(bool isFinalBlock, int sourceLength) => isFinalBlock ? sourceLength : sourceLength & ~0
 372
 373#if NET
 374            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 375            [CompExactlyDependsOn(typeof(AdvSimd.Arm64))]
 376            [CompExactlyDependsOn(typeof(Ssse3))]
 377            public bool TryDecode128Core(
 378                Vector128<byte> str,
 379                Vector128<byte> hiNibbles,
 380                Vector128<byte> maskSlashOrUnderscore,
 381                Vector128<byte> mask8F,
 382                Vector128<byte> lutLow,
 383                Vector128<byte> lutHigh,
 384                Vector128<sbyte> lutShift,
 385                Vector128<byte> shiftForUnderscore,
 386                out Vector128<byte> result)
 387            {
 0388                Vector128<byte> lowerBound = SimdShuffle(lutLow, hiNibbles, mask8F);
 0389                Vector128<byte> upperBound = SimdShuffle(lutHigh, hiNibbles, mask8F);
 390
 0391                Vector128<byte> below = Vector128.LessThan(str, lowerBound);
 0392                Vector128<byte> above = Vector128.GreaterThan(str, upperBound);
 0393                Vector128<byte> eq5F = Vector128.Equals(str, maskSlashOrUnderscore);
 394
 395                // Take care as arguments are flipped in order!
 0396                Vector128<byte> outside = Vector128.AndNot(below | above, eq5F);
 397
 0398                if (outside != Vector128<byte>.Zero)
 399                {
 0400                    result = default;
 0401                    return false;
 402                }
 403
 0404                Vector128<byte> shift = SimdShuffle(lutShift.AsByte(), hiNibbles, mask8F);
 0405                str += shift;
 406
 0407                result = str + (eq5F & shiftForUnderscore);
 0408                return true;
 409            }
 410
 411            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 412            [CompExactlyDependsOn(typeof(Avx2))]
 413            public bool TryDecode256Core(
 414                Vector256<sbyte> str,
 415                Vector256<sbyte> hiNibbles,
 416                Vector256<sbyte> maskSlashOrUnderscore,
 417                Vector256<sbyte> lutLow,
 418                Vector256<sbyte> lutHigh,
 419                Vector256<sbyte> lutShift,
 420                Vector256<sbyte> shiftForUnderscore,
 421                out Vector256<sbyte> result)
 422            {
 0423                Vector256<sbyte> lowerBound = Avx2.Shuffle(lutLow, hiNibbles);
 0424                Vector256<sbyte> upperBound = Avx2.Shuffle(lutHigh, hiNibbles);
 425
 0426                Vector256<sbyte> below = Vector256.LessThan(str, lowerBound);
 0427                Vector256<sbyte> above = Vector256.GreaterThan(str, upperBound);
 0428                Vector256<sbyte> eq5F = Vector256.Equals(str, maskSlashOrUnderscore);
 429
 430                // Take care as arguments are flipped in order!
 0431                Vector256<sbyte> outside = Vector256.AndNot(below | above, eq5F);
 432
 0433                if (outside != Vector256<sbyte>.Zero)
 434                {
 0435                    result = default;
 0436                    return false;
 437                }
 438
 0439                Vector256<sbyte> shift = Avx2.Shuffle(lutShift, hiNibbles);
 0440                str += shift;
 441
 0442                result = str + (eq5F & shiftForUnderscore);
 0443                return true;
 444            }
 445
 446            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 447            public unsafe bool TryLoadVector512(byte* src, byte* srcStart, int sourceLength, out Vector512<sbyte> str) =
 0448                default(Base64DecoderByte).TryLoadVector512(src, srcStart, sourceLength, out str);
 449
 450            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 451            [CompExactlyDependsOn(typeof(Avx2))]
 452            public unsafe bool TryLoadAvxVector256(byte* src, byte* srcStart, int sourceLength, out Vector256<sbyte> str
 0453                default(Base64DecoderByte).TryLoadAvxVector256(src, srcStart, sourceLength, out str);
 454
 455            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 456            public unsafe bool TryLoadVector128(byte* src, byte* srcStart, int sourceLength, out Vector128<byte> str) =>
 0457                default(Base64DecoderByte).TryLoadVector128(src, srcStart, sourceLength, out str);
 458
 459            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 460            [CompExactlyDependsOn(typeof(AdvSimd.Arm64))]
 461            public unsafe bool TryLoadArmVector128x4(byte* src, byte* srcStart, int sourceLength,
 462                out Vector128<byte> str1, out Vector128<byte> str2, out Vector128<byte> str3, out Vector128<byte> str4) 
 0463                default(Base64DecoderByte).TryLoadArmVector128x4(src, srcStart, sourceLength, out str1, out str2, out st
 464#endif // NET
 465
 466            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 467            public unsafe int DecodeFourElements(byte* source, ref sbyte decodingMap) =>
 0468                default(Base64DecoderByte).DecodeFourElements(source, ref decodingMap);
 469
 470            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 471            public unsafe int DecodeRemaining(byte* srcEnd, ref sbyte decodingMap, long remaining, out uint t2, out uint
 0472                default(Base64DecoderByte).DecodeRemaining(srcEnd, ref decodingMap, remaining, out t2, out t3);
 473
 474            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 0475            public int IndexOfAnyExceptWhiteSpace(ReadOnlySpan<byte> span) => default(Base64DecoderByte).IndexOfAnyExcep
 476
 477            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 478            public OperationStatus DecodeWithWhiteSpaceBlockwiseWrapper<TBase64Decoder>(TBase64Decoder decoder, ReadOnly
 479                ref int bytesConsumed, ref int bytesWritten, bool isFinalBlock = true) where TBase64Decoder : IBase64Dec
 0480                DecodeWithWhiteSpaceBlockwise(decoder, utf8, bytes, ref bytesConsumed, ref bytesWritten, isFinalBlock);
 481        }
 482
 483        private readonly struct Base64UrlDecoderChar : IBase64Decoder<ushort>
 484        {
 0485            public ReadOnlySpan<sbyte> DecodingMap => default(Base64UrlDecoderByte).DecodingMap;
 486
 0487            public ReadOnlySpan<uint> VbmiLookup0 => default(Base64UrlDecoderByte).VbmiLookup0;
 488
 0489            public ReadOnlySpan<uint> VbmiLookup1 => default(Base64UrlDecoderByte).VbmiLookup1;
 490
 0491            public ReadOnlySpan<sbyte> Avx2LutHigh => default(Base64UrlDecoderByte).Avx2LutHigh;
 492
 0493            public ReadOnlySpan<sbyte> Avx2LutLow => default(Base64UrlDecoderByte).Avx2LutLow;
 494
 0495            public ReadOnlySpan<sbyte> Avx2LutShift => default(Base64UrlDecoderByte).Avx2LutShift;
 496
 0497            public byte MaskSlashOrUnderscore => default(Base64UrlDecoderByte).MaskSlashOrUnderscore;
 498
 0499            public ReadOnlySpan<int> Vector128LutHigh => default(Base64UrlDecoderByte).Vector128LutHigh;
 500
 0501            public ReadOnlySpan<int> Vector128LutLow => default(Base64UrlDecoderByte).Vector128LutLow;
 502
 0503            public ReadOnlySpan<uint> Vector128LutShift => default(Base64UrlDecoderByte).Vector128LutShift;
 504
 0505            public ReadOnlySpan<uint> AdvSimdLutOne3 => default(Base64UrlDecoderByte).AdvSimdLutOne3;
 506
 0507            public uint AdvSimdLutTwo3Uint1 => default(Base64UrlDecoderByte).AdvSimdLutTwo3Uint1;
 508
 0509            public int GetMaxDecodedLength(int sourceLength) => default(Base64UrlDecoderByte).GetMaxDecodedLength(source
 510
 0511            public bool IsInvalidLength(int bufferLength) => default(Base64UrlDecoderByte).IsInvalidLength(bufferLength)
 512
 0513            public bool IsValidPadding(uint padChar) => default(Base64UrlDecoderByte).IsValidPadding(padChar);
 514
 0515            public int SrcLength(bool isFinalBlock, int sourceLength) => default(Base64UrlDecoderByte).SrcLength(isFinal
 516
 517#if NET
 518            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 519            [CompExactlyDependsOn(typeof(AdvSimd.Arm64))]
 520            [CompExactlyDependsOn(typeof(Ssse3))]
 521            public bool TryDecode128Core(Vector128<byte> str, Vector128<byte> hiNibbles, Vector128<byte> maskSlashOrUnde
 522                Vector128<byte> lutLow, Vector128<byte> lutHigh, Vector128<sbyte> lutShift, Vector128<byte> shiftForUnde
 0523                default(Base64UrlDecoderByte).TryDecode128Core(str, hiNibbles, maskSlashOrUnderscore, mask8F, lutLow, lu
 524
 525            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 526            [CompExactlyDependsOn(typeof(Avx2))]
 527            public bool TryDecode256Core(Vector256<sbyte> str, Vector256<sbyte> hiNibbles, Vector256<sbyte> maskSlashOrU
 528                Vector256<sbyte> lutHigh, Vector256<sbyte> lutShift, Vector256<sbyte> shiftForUnderscore, out Vector256<
 0529                default(Base64UrlDecoderByte).TryDecode256Core(str, hiNibbles, maskSlashOrUnderscore, lutLow, lutHigh, l
 530
 531            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 532            public unsafe bool TryLoadVector512(ushort* src, ushort* srcStart, int sourceLength, out Vector512<sbyte> st
 0533                default(Base64DecoderChar).TryLoadVector512(src, srcStart, sourceLength, out str);
 534
 535            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 536            [CompExactlyDependsOn(typeof(Avx2))]
 537            public unsafe bool TryLoadAvxVector256(ushort* src, ushort* srcStart, int sourceLength, out Vector256<sbyte>
 0538                default(Base64DecoderChar).TryLoadAvxVector256(src, srcStart, sourceLength, out str);
 539
 540            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 541            public unsafe bool TryLoadVector128(ushort* src, ushort* srcStart, int sourceLength, out Vector128<byte> str
 0542                default(Base64DecoderChar).TryLoadVector128(src, srcStart, sourceLength, out str);
 543
 544            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 545            [CompExactlyDependsOn(typeof(AdvSimd.Arm64))]
 546            public unsafe bool TryLoadArmVector128x4(ushort* src, ushort* srcStart, int sourceLength,
 547                out Vector128<byte> str1, out Vector128<byte> str2, out Vector128<byte> str3, out Vector128<byte> str4) 
 0548                default(Base64DecoderChar).TryLoadArmVector128x4(src, srcStart, sourceLength, out str1, out str2, out st
 549#endif // NET
 550
 551            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 552            public unsafe int DecodeFourElements(ushort* source, ref sbyte decodingMap) =>
 0553                default(Base64DecoderChar).DecodeFourElements(source, ref decodingMap);
 554
 555            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 556            public unsafe int DecodeRemaining(ushort* srcEnd, ref sbyte decodingMap, long remaining, out uint t2, out ui
 0557                default(Base64DecoderChar).DecodeRemaining(srcEnd, ref decodingMap, remaining, out t2, out t3);
 558
 559            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 0560            public int IndexOfAnyExceptWhiteSpace(ReadOnlySpan<ushort> span) => default(Base64DecoderChar).IndexOfAnyExc
 561
 562            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 563            public OperationStatus DecodeWithWhiteSpaceBlockwiseWrapper<TBase64Decoder>(TBase64Decoder decoder, ReadOnly
 564                ref int bytesConsumed, ref int bytesWritten, bool isFinalBlock = true) where TBase64Decoder : IBase64Dec
 0565                DecodeWithWhiteSpaceBlockwise(decoder, source, bytes, ref bytesConsumed, ref bytesWritten, isFinalBlock)
 566        }
 567    }
 568}

C:\h\w\B7B10A05\w\A2F5091A\e\runtime-utils\Runner\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Url\Base64UrlEncoder.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Diagnostics;
 5using System.Runtime.CompilerServices;
 6using System.Runtime.InteropServices;
 7#if NET
 8using System.Runtime.Intrinsics;
 9using System.Runtime.Intrinsics.Arm;
 10using System.Runtime.Intrinsics.X86;
 11#endif
 12using static System.Buffers.Text.Base64Helper;
 13
 14namespace System.Buffers.Text
 15{
 16    public static partial class Base64Url
 17    {
 18        /// <summary>
 19        /// Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.
 20        /// </summary>
 21        /// <param name="source">The input span which contains binary data that needs to be encoded.</param>
 22        /// <param name="destination">The output span which contains the result of the operation, i.e. the UTF-8 encoded
 23        /// <param name="bytesConsumed">When this method returns, contains the number of input bytes consumed during the
 24        /// <param name="bytesWritten">When this method returns, contains the number of bytes written into the output sp
 25        /// <param name="isFinalBlock"><see langword="true"/> when the input span contains the entirety of data to encod
 26        /// such as when calling in a loop, subsequent calls with <see langword="false"/> should end with <see langword=
 27        /// <returns>One of the enumeration values that indicates the success or failure of the operation.</returns>
 28        /// <remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
 29        public static OperationStatus EncodeToUtf8(ReadOnlySpan<byte> source,
 30            Span<byte> destination, out int bytesConsumed, out int bytesWritten, bool isFinalBlock = true) =>
 031            EncodeTo(default(Base64UrlEncoderByte), source, destination, out bytesConsumed, out bytesWritten, isFinalBlo
 32
 33        /// <summary>
 34        /// Returns the length (in bytes) of the result if you were to encode binary data within a byte span of size <pa
 35        /// </summary>
 36        /// <exception cref="ArgumentOutOfRangeException">
 37        /// <paramref name="bytesLength"/> is less than 0 or greater than 1610612733.
 38        /// </exception>
 39        public static int GetEncodedLength(int bytesLength)
 40        {
 41#if NET
 042            ArgumentOutOfRangeException.ThrowIfGreaterThan<uint>((uint)bytesLength, MaximumEncodeLength);
 43
 044            (uint whole, uint remainder) = uint.DivRem((uint)bytesLength, 3);
 45
 046            return (int)(whole * 4 + (remainder > 0 ? remainder + 1 : 0)); // if remainder is 1 or 2, the encoded length
 47#else
 48            if ((uint)bytesLength > MaximumEncodeLength)
 49            {
 50                throw new ArgumentOutOfRangeException(nameof(bytesLength));
 51            }
 52
 53            int remainder = (int)((uint)bytesLength % 3);
 54
 55            return (bytesLength / 3) * 4 + (remainder > 0 ? remainder + 1 : 0);
 56#endif
 57        }
 58
 59        /// <summary>
 60        /// Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.
 61        /// </summary>
 62        /// <param name="source">The input span which contains binary data that needs to be encoded.</param>
 63        /// <param name="destination">The output span which contains the result of the operation, i.e. the UTF-8 encoded
 64        /// <returns>The number of bytes written into the destination span. This can be used to slice the output for sub
 65        /// <exception cref="ArgumentException">The buffer in <paramref name="destination"/> is too small to hold the en
 66        /// <remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
 67        public static int EncodeToUtf8(ReadOnlySpan<byte> source, Span<byte> destination)
 68        {
 069            OperationStatus status = EncodeToUtf8(source, destination, out _, out int bytesWritten);
 70
 071            if (status == OperationStatus.Done)
 72            {
 073                return bytesWritten;
 74            }
 75
 076            Debug.Assert(status == OperationStatus.DestinationTooSmall);
 077            throw new ArgumentException(SR.Argument_DestinationTooShort, nameof(destination));
 78        }
 79
 80        /// <summary>
 81        /// Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.
 82        /// </summary>
 83        /// <param name="source">The input span which contains binary data that needs to be encoded.</param>
 84        /// <returns>The output byte array which contains the result of the operation, i.e. the UTF-8 encoded text in Ba
 85        /// <remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
 86        public static byte[] EncodeToUtf8(ReadOnlySpan<byte> source)
 87        {
 088            byte[] destination = new byte[GetEncodedLength(source.Length)];
 089            EncodeToUtf8(source, destination, out _, out int bytesWritten);
 090            Debug.Assert(destination.Length == bytesWritten);
 91
 092            return destination;
 93        }
 94
 95        /// <summary>
 96        /// Encodes the span of binary data into unicode ASCII chars represented as Base64Url.
 97        /// </summary>
 98        /// <param name="source">The input span which contains binary data that needs to be encoded.</param>
 99        /// <param name="destination">The output span which contains the result of the operation, i.e. the ASCII chars i
 100        /// <param name="bytesConsumed">>When this method returns, contains the number of input bytes consumed during th
 101        /// <param name="charsWritten">>When this method returns, contains the number of chars written into the output s
 102        /// <param name="isFinalBlock"><see langword="true"/> when the input span contains the entirety of data to encod
 103        /// such as when calling in a loop, subsequent calls with <see langword="false"/> should end with <see langword=
 104        /// <returns>One of the enumeration values that indicates the success or failure of the operation.</returns>
 105        /// <remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
 106        public static OperationStatus EncodeToChars(ReadOnlySpan<byte> source, Span<char> destination,
 107            out int bytesConsumed, out int charsWritten, bool isFinalBlock = true) =>
 0108            EncodeTo(default(Base64UrlEncoderChar), source, MemoryMarshal.Cast<char, ushort>(destination), out bytesCons
 109
 110        /// <summary>
 111        /// Encodes the span of binary data into unicode ASCII chars represented as Base64Url.
 112        /// </summary>
 113        /// <param name="source">The input span which contains binary data that needs to be encoded.</param>
 114        /// <param name="destination">The output span which contains the result of the operation, i.e. the ASCII chars i
 115        /// <returns>The number of bytes written into the destination span. This can be used to slice the output for sub
 116        /// <exception cref="ArgumentException">The buffer in <paramref name="destination"/> is too small to hold the en
 117        /// <remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
 118        public static int EncodeToChars(ReadOnlySpan<byte> source, Span<char> destination)
 119        {
 0120            OperationStatus status = EncodeToChars(source, destination, out _, out int charsWritten);
 121
 0122            if (status == OperationStatus.Done)
 123            {
 0124                return charsWritten;
 125            }
 126
 0127            Debug.Assert(status == OperationStatus.DestinationTooSmall);
 0128            throw new ArgumentException(SR.Argument_DestinationTooShort, nameof(destination));
 129        }
 130
 131        /// <summary>
 132        /// Encodes the span of binary data into unicode ASCII chars represented as Base64Url.
 133        /// </summary>
 134        /// <param name="source">The input span which contains binary data that needs to be encoded.</param>
 135        /// <returns>A char array which contains the result of the operation, i.e. the ASCII chars in Base64Url.</return
 136        /// <remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
 137        public static char[] EncodeToChars(ReadOnlySpan<byte> source)
 138        {
 0139            char[] destination = new char[GetEncodedLength(source.Length)];
 0140            EncodeToChars(source, destination, out _, out int charsWritten);
 0141            Debug.Assert(destination.Length == charsWritten);
 142
 0143            return destination;
 144        }
 145
 146        /// <summary>
 147        /// Encodes the span of binary data into unicode string represented as Base64Url ASCII chars.
 148        /// </summary>
 149        /// <param name="source">The input span which contains binary data that needs to be encoded.</param>
 150        /// <returns>A string which contains the result of the operation, i.e. the ASCII string in Base64Url.</returns>
 151        /// <remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
 152        public static unsafe string EncodeToString(ReadOnlySpan<byte> source)
 153        {
 154#if NET
 0155            int encodedLength = GetEncodedLength(source.Length);
 156
 0157            return string.Create(encodedLength, (IntPtr)(&source), static (buffer, spanPtr) =>
 0158            {
 0159                ReadOnlySpan<byte> source = *(ReadOnlySpan<byte>*)spanPtr;
 0160                EncodeToChars(source, buffer, out _, out int charsWritten);
 0161                Debug.Assert(buffer.Length == charsWritten, $"The source length: {source.Length}, bytes written: {charsW
 0162            });
 163#else
 164            char[] destination = new char[GetEncodedLength(source.Length)];
 165            EncodeToChars(source, destination, out _, out int charsWritten);
 166            Debug.Assert(destination.Length == charsWritten);
 167
 168            return new string(destination);
 169#endif
 170        }
 171
 172        /// <summary>
 173        /// Encodes the span of binary data into unicode ASCII chars represented as Base64Url.
 174        /// </summary>
 175        /// <param name="source">The input span which contains binary data that needs to be encoded.</param>
 176        /// <param name="destination">The output span which contains the result of the operation, i.e. the ASCII chars i
 177        /// <param name="charsWritten">When this method returns, contains the number of chars written into the output sp
 178        /// <returns><see langword="true"/> if chars encoded successfully, otherwise <see langword="false"/>.</returns>
 179        /// <remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
 180        public static bool TryEncodeToChars(ReadOnlySpan<byte> source, Span<char> destination, out int charsWritten)
 181        {
 0182            OperationStatus status = EncodeToChars(source, destination, out _, out charsWritten);
 183
 0184            return status == OperationStatus.Done;
 185        }
 186
 187        /// <summary>
 188        /// Encodes the span of binary data into UTF-8 encoded chars represented as Base64Url.
 189        /// </summary>
 190        /// <param name="source">The input span which contains binary data that needs to be encoded.</param>
 191        /// <param name="destination">The output span which contains the result of the operation, i.e. the UTF-8 encoded
 192        /// <param name="bytesWritten">When this method returns, contains the number of chars written into the output sp
 193        /// <returns><see langword="true"/> if bytes encoded successfully, otherwise <see langword="false"/>.</returns>
 194        /// <remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
 195        public static bool TryEncodeToUtf8(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten)
 196        {
 0197            OperationStatus status = EncodeToUtf8(source, destination, out _, out bytesWritten);
 198
 0199            return status == OperationStatus.Done;
 200        }
 201
 202        /// <summary>
 203        /// Encodes the span of binary data (in-place) into UTF-8 encoded text represented as base 64.
 204        /// The encoded text output is larger than the binary data contained in the input (the operation inflates the da
 205        /// </summary>
 206        /// <param name="buffer">The input span which contains binary data that needs to be encoded.
 207        /// It needs to be large enough to fit the result of the operation.</param>
 208        /// <param name="dataLength">The amount of binary data contained within the buffer that needs to be encoded
 209        /// (and needs to be smaller than the buffer length).</param>
 210        /// <param name="bytesWritten">When this method returns, contains the number of bytes written into the buffer. T
 211        /// <returns><see langword="true"/> if bytes encoded successfully, otherwise <see langword="false"/>.</returns>
 212        /// <remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
 213        public static bool TryEncodeToUtf8InPlace(Span<byte> buffer, int dataLength, out int bytesWritten)
 214        {
 0215            OperationStatus status = EncodeToUtf8InPlace(default(Base64UrlEncoderByte), buffer, dataLength, out bytesWri
 216
 0217            return status == OperationStatus.Done;
 218        }
 219
 220        private readonly struct Base64UrlEncoderByte : Base64Helper.IBase64Encoder<byte>
 221        {
 0222            public ReadOnlySpan<byte> EncodingMap => "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"u
 223
 0224            public sbyte Avx2LutChar62 => -17;  // char '-' diff
 225
 0226            public sbyte Avx2LutChar63 => 32;   // char '_' diff
 227
 0228            public ReadOnlySpan<byte> AdvSimdLut4 => "wxyz0123456789-_"u8;
 229
 0230            public uint Ssse3AdvSimdLutE3 => 0x000020EF;
 231
 0232            public int IncrementPadTwo => 2;
 233
 0234            public int IncrementPadOne => 3;
 235
 236            public int GetMaxSrcLength(int srcLength, int destLength) =>
 0237                srcLength <= MaximumEncodeLength && destLength >= GetEncodedLength(srcLength) ?
 0238                srcLength : GetMaxDecodedLength(destLength);
 239
 240            public uint GetInPlaceDestinationLength(int encodedLength, int leftOver) =>
 0241                leftOver > 0 ? (uint)(encodedLength - leftOver - 1) : (uint)(encodedLength - 4);
 242
 0243            public int GetMaxEncodedLength(int srcLength) => GetEncodedLength(srcLength);
 244
 245            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 246            public unsafe void EncodeOneOptionallyPadTwo(byte* oneByte, byte* dest, ref byte encodingMap)
 247            {
 248                uint t0 = oneByte[0];
 249
 0250                uint i = t0 << 8;
 251
 0252                byte i0 = Unsafe.Add(ref encodingMap, (IntPtr)(i >> 10));
 0253                byte i1 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 4) & 0x3F));
 254
 255                ushort result;
 256
 0257                if (BitConverter.IsLittleEndian)
 258                {
 0259                    result = (ushort)(i0 | (i1 << 8));
 260                }
 261                else
 262                {
 263                    result = (ushort)((i0 << 8) | i1);
 264                }
 265
 0266                Unsafe.WriteUnaligned(dest, result);
 0267            }
 268
 269            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 270            public unsafe void EncodeTwoOptionallyPadOne(byte* twoBytes, byte* dest, ref byte encodingMap)
 271            {
 0272                uint t0 = twoBytes[0];
 0273                uint t1 = twoBytes[1];
 274
 0275                uint i = (t0 << 16) | (t1 << 8);
 276
 0277                byte i0 = Unsafe.Add(ref encodingMap, (IntPtr)(i >> 18));
 0278                byte i1 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 12) & 0x3F));
 0279                byte i2 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 6) & 0x3F));
 280
 0281                dest[0] = i0;
 0282                dest[1] = i1;
 0283                dest[2] = i2;
 0284            }
 285
 286#if NET
 287            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 288            public unsafe void StoreVector512ToDestination(byte* dest, byte* destStart, int destLength, Vector512<byte> 
 0289                default(Base64EncoderByte).StoreVector512ToDestination(dest, destStart, destLength, str);
 290
 291            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 292            [CompExactlyDependsOn(typeof(Avx2))]
 293            public unsafe void StoreVector256ToDestination(byte* dest, byte* destStart, int destLength, Vector256<byte> 
 0294                default(Base64EncoderByte).StoreVector256ToDestination(dest, destStart, destLength, str);
 295
 296            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 297            public unsafe void StoreVector128ToDestination(byte* dest, byte* destStart, int destLength, Vector128<byte> 
 0298                default(Base64EncoderByte).StoreVector128ToDestination(dest, destStart, destLength, str);
 299
 300            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 301            [CompExactlyDependsOn(typeof(AdvSimd.Arm64))]
 302            public unsafe void StoreArmVector128x4ToDestination(byte* dest, byte* destStart, int destLength,
 303                Vector128<byte> res1, Vector128<byte> res2, Vector128<byte> res3, Vector128<byte> res4) =>
 0304                default(Base64EncoderByte).StoreArmVector128x4ToDestination(dest, destStart, destLength, res1, res2, res
 305#endif // NET
 306
 307            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 308            public unsafe void EncodeThreeAndWrite(byte* threeBytes, byte* destination, ref byte encodingMap) =>
 0309                default(Base64EncoderByte).EncodeThreeAndWrite(threeBytes, destination, ref encodingMap);
 310        }
 311
 312        private readonly struct Base64UrlEncoderChar : IBase64Encoder<ushort>
 313        {
 0314            public ReadOnlySpan<byte> EncodingMap => default(Base64UrlEncoderByte).EncodingMap;
 315
 0316            public sbyte Avx2LutChar62 => default(Base64UrlEncoderByte).Avx2LutChar62;
 317
 0318            public sbyte Avx2LutChar63 => default(Base64UrlEncoderByte).Avx2LutChar63;
 319
 0320            public ReadOnlySpan<byte> AdvSimdLut4 => default(Base64UrlEncoderByte).AdvSimdLut4;
 321
 0322            public uint Ssse3AdvSimdLutE3 => default(Base64UrlEncoderByte).Ssse3AdvSimdLutE3;
 323
 0324            public int IncrementPadTwo => default(Base64UrlEncoderByte).IncrementPadTwo;
 325
 0326            public int IncrementPadOne => default(Base64UrlEncoderByte).IncrementPadOne;
 327
 328            public int GetMaxSrcLength(int srcLength, int destLength) =>
 0329                default(Base64UrlEncoderByte).GetMaxSrcLength(srcLength, destLength);
 330
 0331            public uint GetInPlaceDestinationLength(int encodedLength, int _) => 0; // not used for char encoding
 332
 0333            public int GetMaxEncodedLength(int _) => 0;  // not used for char encoding
 334
 335            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 336            public unsafe void EncodeOneOptionallyPadTwo(byte* oneByte, ushort* dest, ref byte encodingMap) =>
 0337                Base64Helper.EncodeOneOptionallyPadTwo(oneByte, dest, ref encodingMap);
 338
 339            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 340            public unsafe void EncodeTwoOptionallyPadOne(byte* twoBytes, ushort* dest, ref byte encodingMap) =>
 0341                Base64Helper.EncodeTwoOptionallyPadOne(twoBytes, dest, ref encodingMap);
 342
 343#if NET
 344            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 345            public unsafe void StoreVector512ToDestination(ushort* dest, ushort* destStart, int destLength, Vector512<by
 0346                default(Base64EncoderChar).StoreVector512ToDestination(dest, destStart, destLength, str);
 347
 348            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 349            public unsafe void StoreVector256ToDestination(ushort* dest, ushort* destStart, int destLength, Vector256<by
 0350                default(Base64EncoderChar).StoreVector256ToDestination(dest, destStart, destLength, str);
 351
 352            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 353            public unsafe void StoreVector128ToDestination(ushort* dest, ushort* destStart, int destLength, Vector128<by
 0354                default(Base64EncoderChar).StoreVector128ToDestination(dest, destStart, destLength, str);
 355
 356            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 357            [CompExactlyDependsOn(typeof(AdvSimd.Arm64))]
 358            public unsafe void StoreArmVector128x4ToDestination(ushort* dest, ushort* destStart, int destLength,
 359                Vector128<byte> res1, Vector128<byte> res2, Vector128<byte> res3, Vector128<byte> res4) =>
 0360                default(Base64EncoderChar).StoreArmVector128x4ToDestination(dest, destStart, destLength, res1, res2, res
 361#endif // NET
 362
 363            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 364            public unsafe void EncodeThreeAndWrite(byte* threeBytes, ushort* destination, ref byte encodingMap) =>
 0365                default(Base64EncoderChar).EncodeThreeAndWrite(threeBytes, destination, ref encodingMap);
 366        }
 367    }
 368}

C:\h\w\B7B10A05\w\A2F5091A\e\runtime-utils\Runner\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Url\Base64UrlValidator.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Diagnostics;
 5using System.Runtime.CompilerServices;
 6
 7namespace System.Buffers.Text
 8{
 9    public static partial class Base64Url
 10    {
 11        /// <summary>Validates that the specified span of text is comprised of valid base-64 encoded data.</summary>
 12        /// <param name="base64UrlText">A span of text to validate.</param>
 13        /// <returns><see langword="true"/> if <paramref name="base64UrlText"/> contains a valid, decodable sequence of 
 14        /// <remarks>
 15        /// If the method returns <see langword="true"/>, the same text passed to <see cref="Base64Url.DecodeFromChars(R
 16        /// <see cref="Base64Url.TryDecodeFromChars(ReadOnlySpan{char}, Span{byte}, out int)"/> would successfully decod
 17        /// of <see cref="Base64Url.TryDecodeFromChars(ReadOnlySpan{char}, Span{byte}, out int)"/> assuming sufficient o
 18        /// Any amount of whitespace is allowed anywhere in the input, where whitespace is defined as the characters ' '
 19        /// </remarks>
 20        public static bool IsValid(ReadOnlySpan<char> base64UrlText) =>
 021            Base64Helper.IsValid(default(Base64UrlCharValidatable), base64UrlText, out _);
 22
 23        /// <summary>Validates that the specified span of text is comprised of valid base-64 encoded data.</summary>
 24        /// <param name="base64UrlText">A span of text to validate.</param>
 25        /// <param name="decodedLength">If the method returns true, the number of decoded bytes that will result from de
 26        /// <returns><see langword="true"/> if <paramref name="base64UrlText"/> contains a valid, decodable sequence of 
 27        /// <remarks>
 28        /// If the method returns <see langword="true"/>, the same text passed to <see cref="Base64Url.DecodeFromChars(R
 29        /// <see cref="Base64Url.TryDecodeFromChars(ReadOnlySpan{char}, Span{byte}, out int)"/> would successfully decod
 30        /// of <see cref="Base64Url.TryDecodeFromChars(ReadOnlySpan{char}, Span{byte}, out int)"/> assuming sufficient o
 31        /// Any amount of whitespace is allowed anywhere in the input, where whitespace is defined as the characters ' '
 32        /// </remarks>
 33        public static bool IsValid(ReadOnlySpan<char> base64UrlText, out int decodedLength) =>
 034            Base64Helper.IsValid(default(Base64UrlCharValidatable), base64UrlText, out decodedLength);
 35
 36        /// <summary>Validates that the specified span of UTF-8 text is comprised of valid base-64 encoded data.</summar
 37        /// <param name="utf8Base64UrlText">A span of UTF-8 text to validate.</param>
 38        /// <returns><see langword="true"/> if <paramref name="utf8Base64UrlText"/> contains a valid, decodable sequence
 39        /// <remarks>
 40        /// where whitespace is defined as the characters ' ', '\t', '\r', or '\n' (as bytes).
 41        /// </remarks>
 42        public static bool IsValid(ReadOnlySpan<byte> utf8Base64UrlText) =>
 043            Base64Helper.IsValid(default(Base64UrlByteValidatable), utf8Base64UrlText, out _);
 44
 45        /// <summary>Validates that the specified span of UTF-8 text is comprised of valid base-64 encoded data.</summar
 46        /// <param name="utf8Base64UrlText">A span of UTF-8 text to validate.</param>
 47        /// <param name="decodedLength">If the method returns true, the number of decoded bytes that will result from de
 48        /// <returns><see langword="true"/> if <paramref name="utf8Base64UrlText"/> contains a valid, decodable sequence
 49        /// <remarks>
 50        /// where whitespace is defined as the characters ' ', '\t', '\r', or '\n' (as bytes).
 51        /// </remarks>
 52        public static bool IsValid(ReadOnlySpan<byte> utf8Base64UrlText, out int decodedLength) =>
 053            Base64Helper.IsValid(default(Base64UrlByteValidatable), utf8Base64UrlText, out decodedLength);
 54
 55        private const uint UrlEncodingPad = '%'; // allowed for url padding
 56
 57        private readonly struct Base64UrlCharValidatable : Base64Helper.IBase64Validatable<char>
 58        {
 59#if NET
 060            private static readonly SearchValues<char> s_validBase64UrlChars = SearchValues.Create("ABCDEFGHIJKLMNOPQRST
 61
 062            public int IndexOfAnyExcept(ReadOnlySpan<char> span) => span.IndexOfAnyExcept(s_validBase64UrlChars);
 63#else
 64            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 65            public int DecodeValue(char value)
 66            {
 67                if (value > byte.MaxValue)
 68                {
 69                    // Invalid char was found.
 70                    return -2;
 71                }
 72
 73                return default(Base64UrlDecoderByte).DecodingMap[value];
 74            }
 75#endif
 076            public bool IsWhiteSpace(char value) => Base64Helper.IsWhiteSpace(value);
 077            public bool IsEncodingPad(char value) => value == Base64Helper.EncodingPad || value == UrlEncodingPad;
 78            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 79            public bool ValidateAndDecodeLength(char lastChar, int length, int paddingCount, out int decodedLength) =>
 080                default(Base64UrlByteValidatable).ValidateAndDecodeLength((byte)lastChar, length, paddingCount, out deco
 81        }
 82
 83        private readonly struct Base64UrlByteValidatable : Base64Helper.IBase64Validatable<byte>
 84        {
 85#if NET
 086            private static readonly SearchValues<byte> s_validBase64UrlChars = SearchValues.Create(default(Base64UrlEnco
 87
 088            public int IndexOfAnyExcept(ReadOnlySpan<byte> span) => span.IndexOfAnyExcept(s_validBase64UrlChars);
 89#else
 90            public int DecodeValue(byte value) => default(Base64UrlDecoderByte).DecodingMap[value];
 91#endif
 092            public bool IsWhiteSpace(byte value) => Base64Helper.IsWhiteSpace(value);
 093            public bool IsEncodingPad(byte value) => value == Base64Helper.EncodingPad || value == UrlEncodingPad;
 94            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 95            public bool ValidateAndDecodeLength(byte lastChar, int length, int paddingCount, out int decodedLength)
 96            {
 97                // Padding is optional for Base64Url, so need to account remainder.
 098                int remainder = (int)((uint)length % 4);
 99
 0100                if (paddingCount != 0)
 101                {
 0102                    length -= paddingCount;
 0103                    remainder = (int)((uint)length % 4);
 104
 105                    // if there is a padding, there should be remainder and the sum of remainder and padding should not 
 0106                    if (remainder == 0 || remainder + paddingCount > 4)
 107                    {
 0108                        decodedLength = 0;
 0109                        return false;
 110                    }
 111                }
 112
 0113                decodedLength = (length >> 2) * 3 + (remainder > 0 ? remainder - 1 : 0);
 114
 0115                if (remainder > 0)
 116                {
 0117                    int decoded = default(Base64UrlDecoderByte).DecodingMap[lastChar];
 118                    switch (remainder)
 119                    {
 0120                        case 1: return false; // 1 byte is not decodable => invalid.
 0121                        case 2: return ((decoded & 0x0F) == 0); // if unused lower 4 bits are set to 0
 0122                        case 3: return ((decoded & 0x03) == 0); // if unused lower 2 bits are set to 0
 123                    }
 124                }
 125
 0126                return true;
 127            }
 128        }
 129    }
 130}

Methods/Properties

GetMaxDecodedLength(System.Int32)
DecodeFromUtf8(System.ReadOnlySpan`1<System.Byte>,System.Span`1<System.Byte>,System.Int32&,System.Int32&,System.Boolean)
DecodeFromUtf8InPlace(System.Span`1<System.Byte>)
DecodeFromUtf8(System.ReadOnlySpan`1<System.Byte>,System.Span`1<System.Byte>)
TryDecodeFromUtf8(System.ReadOnlySpan`1<System.Byte>,System.Span`1<System.Byte>,System.Int32&)
DecodeFromUtf8(System.ReadOnlySpan`1<System.Byte>)
DecodeFromChars(System.ReadOnlySpan`1<System.Char>,System.Span`1<System.Byte>,System.Int32&,System.Int32&,System.Boolean)
DecodeFromChars(System.ReadOnlySpan`1<System.Char>,System.Span`1<System.Byte>)
TryDecodeFromChars(System.ReadOnlySpan`1<System.Char>,System.Span`1<System.Byte>,System.Int32&)
DecodeFromChars(System.ReadOnlySpan`1<System.Char>)
DecodingMap()
VbmiLookup0()
VbmiLookup1()
Avx2LutHigh()
Avx2LutLow()
Avx2LutShift()
MaskSlashOrUnderscore()
Vector128LutHigh()
Vector128LutLow()
Vector128LutShift()
AdvSimdLutOne3()
AdvSimdLutTwo3Uint1()
GetMaxDecodedLength(System.Int32)
IsInvalidLength(System.Int32)
IsValidPadding(System.UInt32)
SrcLength(System.Boolean,System.Int32)
TryDecode128Core(System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.SByte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>&)
TryDecode256Core(System.Runtime.Intrinsics.Vector256`1<System.SByte>,System.Runtime.Intrinsics.Vector256`1<System.SByte>,System.Runtime.Intrinsics.Vector256`1<System.SByte>,System.Runtime.Intrinsics.Vector256`1<System.SByte>,System.Runtime.Intrinsics.Vector256`1<System.SByte>,System.Runtime.Intrinsics.Vector256`1<System.SByte>,System.Runtime.Intrinsics.Vector256`1<System.SByte>,System.Runtime.Intrinsics.Vector256`1<System.SByte>&)
TryLoadVector512(System.Byte*,System.Byte*,System.Int32,System.Runtime.Intrinsics.Vector512`1<System.SByte>&)
TryLoadAvxVector256(System.Byte*,System.Byte*,System.Int32,System.Runtime.Intrinsics.Vector256`1<System.SByte>&)
TryLoadVector128(System.Byte*,System.Byte*,System.Int32,System.Runtime.Intrinsics.Vector128`1<System.Byte>&)
TryLoadArmVector128x4(System.Byte*,System.Byte*,System.Int32,System.Runtime.Intrinsics.Vector128`1<System.Byte>&,System.Runtime.Intrinsics.Vector128`1<System.Byte>&,System.Runtime.Intrinsics.Vector128`1<System.Byte>&,System.Runtime.Intrinsics.Vector128`1<System.Byte>&)
DecodeFourElements(System.Byte*,System.SByte&)
DecodeRemaining(System.Byte*,System.SByte&,System.Int64,System.UInt32&,System.UInt32&)
IndexOfAnyExceptWhiteSpace(System.ReadOnlySpan`1<System.Byte>)
DecodeWithWhiteSpaceBlockwiseWrapper(TBase64Decoder,System.ReadOnlySpan`1<System.Byte>,System.Span`1<System.Byte>,System.Int32&,System.Int32&,System.Boolean)
DecodingMap()
VbmiLookup0()
VbmiLookup1()
Avx2LutHigh()
Avx2LutLow()
Avx2LutShift()
MaskSlashOrUnderscore()
Vector128LutHigh()
Vector128LutLow()
Vector128LutShift()
AdvSimdLutOne3()
AdvSimdLutTwo3Uint1()
GetMaxDecodedLength(System.Int32)
IsInvalidLength(System.Int32)
IsValidPadding(System.UInt32)
SrcLength(System.Boolean,System.Int32)
TryDecode128Core(System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.SByte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>&)
TryDecode256Core(System.Runtime.Intrinsics.Vector256`1<System.SByte>,System.Runtime.Intrinsics.Vector256`1<System.SByte>,System.Runtime.Intrinsics.Vector256`1<System.SByte>,System.Runtime.Intrinsics.Vector256`1<System.SByte>,System.Runtime.Intrinsics.Vector256`1<System.SByte>,System.Runtime.Intrinsics.Vector256`1<System.SByte>,System.Runtime.Intrinsics.Vector256`1<System.SByte>,System.Runtime.Intrinsics.Vector256`1<System.SByte>&)
TryLoadVector512(System.UInt16*,System.UInt16*,System.Int32,System.Runtime.Intrinsics.Vector512`1<System.SByte>&)
TryLoadAvxVector256(System.UInt16*,System.UInt16*,System.Int32,System.Runtime.Intrinsics.Vector256`1<System.SByte>&)
TryLoadVector128(System.UInt16*,System.UInt16*,System.Int32,System.Runtime.Intrinsics.Vector128`1<System.Byte>&)
TryLoadArmVector128x4(System.UInt16*,System.UInt16*,System.Int32,System.Runtime.Intrinsics.Vector128`1<System.Byte>&,System.Runtime.Intrinsics.Vector128`1<System.Byte>&,System.Runtime.Intrinsics.Vector128`1<System.Byte>&,System.Runtime.Intrinsics.Vector128`1<System.Byte>&)
DecodeFourElements(System.UInt16*,System.SByte&)
DecodeRemaining(System.UInt16*,System.SByte&,System.Int64,System.UInt32&,System.UInt32&)
IndexOfAnyExceptWhiteSpace(System.ReadOnlySpan`1<System.UInt16>)
DecodeWithWhiteSpaceBlockwiseWrapper(TBase64Decoder,System.ReadOnlySpan`1<System.UInt16>,System.Span`1<System.Byte>,System.Int32&,System.Int32&,System.Boolean)
EncodeToUtf8(System.ReadOnlySpan`1<System.Byte>,System.Span`1<System.Byte>,System.Int32&,System.Int32&,System.Boolean)
GetEncodedLength(System.Int32)
EncodeToUtf8(System.ReadOnlySpan`1<System.Byte>,System.Span`1<System.Byte>)
EncodeToUtf8(System.ReadOnlySpan`1<System.Byte>)
EncodeToChars(System.ReadOnlySpan`1<System.Byte>,System.Span`1<System.Char>,System.Int32&,System.Int32&,System.Boolean)
EncodeToChars(System.ReadOnlySpan`1<System.Byte>,System.Span`1<System.Char>)
EncodeToChars(System.ReadOnlySpan`1<System.Byte>)
EncodeToString(System.ReadOnlySpan`1<System.Byte>)
TryEncodeToChars(System.ReadOnlySpan`1<System.Byte>,System.Span`1<System.Char>,System.Int32&)
TryEncodeToUtf8(System.ReadOnlySpan`1<System.Byte>,System.Span`1<System.Byte>,System.Int32&)
TryEncodeToUtf8InPlace(System.Span`1<System.Byte>,System.Int32,System.Int32&)
EncodingMap()
Avx2LutChar62()
Avx2LutChar63()
AdvSimdLut4()
Ssse3AdvSimdLutE3()
IncrementPadTwo()
IncrementPadOne()
GetMaxSrcLength(System.Int32,System.Int32)
GetInPlaceDestinationLength(System.Int32,System.Int32)
GetMaxEncodedLength(System.Int32)
EncodeOneOptionallyPadTwo(System.Byte*,System.Byte*,System.Byte&)
EncodeTwoOptionallyPadOne(System.Byte*,System.Byte*,System.Byte&)
StoreVector512ToDestination(System.Byte*,System.Byte*,System.Int32,System.Runtime.Intrinsics.Vector512`1<System.Byte>)
StoreVector256ToDestination(System.Byte*,System.Byte*,System.Int32,System.Runtime.Intrinsics.Vector256`1<System.Byte>)
StoreVector128ToDestination(System.Byte*,System.Byte*,System.Int32,System.Runtime.Intrinsics.Vector128`1<System.Byte>)
StoreArmVector128x4ToDestination(System.Byte*,System.Byte*,System.Int32,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>)
EncodeThreeAndWrite(System.Byte*,System.Byte*,System.Byte&)
EncodingMap()
Avx2LutChar62()
Avx2LutChar63()
AdvSimdLut4()
Ssse3AdvSimdLutE3()
IncrementPadTwo()
IncrementPadOne()
GetMaxSrcLength(System.Int32,System.Int32)
GetInPlaceDestinationLength(System.Int32,System.Int32)
GetMaxEncodedLength(System.Int32)
EncodeOneOptionallyPadTwo(System.Byte*,System.UInt16*,System.Byte&)
EncodeTwoOptionallyPadOne(System.Byte*,System.UInt16*,System.Byte&)
StoreVector512ToDestination(System.UInt16*,System.UInt16*,System.Int32,System.Runtime.Intrinsics.Vector512`1<System.Byte>)
StoreVector256ToDestination(System.UInt16*,System.UInt16*,System.Int32,System.Runtime.Intrinsics.Vector256`1<System.Byte>)
StoreVector128ToDestination(System.UInt16*,System.UInt16*,System.Int32,System.Runtime.Intrinsics.Vector128`1<System.Byte>)
StoreArmVector128x4ToDestination(System.UInt16*,System.UInt16*,System.Int32,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>,System.Runtime.Intrinsics.Vector128`1<System.Byte>)
EncodeThreeAndWrite(System.Byte*,System.UInt16*,System.Byte&)
IsValid(System.ReadOnlySpan`1<System.Char>)
IsValid(System.ReadOnlySpan`1<System.Char>,System.Int32&)
IsValid(System.ReadOnlySpan`1<System.Byte>)
IsValid(System.ReadOnlySpan`1<System.Byte>,System.Int32&)
.cctor()
IndexOfAnyExcept(System.ReadOnlySpan`1<System.Char>)
IsWhiteSpace(System.Char)
IsEncodingPad(System.Char)
ValidateAndDecodeLength(System.Char,System.Int32,System.Int32,System.Int32&)
.cctor()
IndexOfAnyExcept(System.ReadOnlySpan`1<System.Byte>)
IsWhiteSpace(System.Byte)
IsEncodingPad(System.Byte)
ValidateAndDecodeLength(System.Byte,System.Int32,System.Int32,System.Int32&)