From eeb5f4074e5556a62848238c7754cee89d223ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Mon, 27 Jul 2026 20:51:24 +0200 Subject: [PATCH] Remove the Convert.FromHexString()/SHA384.HashData()/SHA512.HashData() polyfills --- .../OpenIddictPolyfills.cs | 77 ------------------- 1 file changed, 77 deletions(-) diff --git a/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs b/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs index f778d16b..59ead315 100644 --- a/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs +++ b/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs @@ -17,34 +17,6 @@ namespace OpenIddict.Extensions; /// internal static class OpenIddictPolyfills { - extension(Convert) - { -#if !NET - /// Converts the specified string, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. - /// The string to convert. - /// An array of 8-bit unsigned integers that is equivalent to . - /// is null. - /// The length of , is not zero or a multiple of 2. - /// The format of is invalid. contains a non-hex character. - public static byte[] FromHexString(string s) - { - if ((uint) s.Length % 2 is not 0) - { - throw new FormatException(SR.GetResourceString(SR.ID0413)); - } - - var array = new byte[s.Length / 2]; - - for (var index = 0; index < s.Length; index += 2) - { - array[index / 2] = Convert.ToByte(s.Substring(index, 2), 16); - } - - return array; - } -#endif - } - extension(CryptographicOperations) { #if !NET @@ -250,27 +222,6 @@ internal static class OpenIddictPolyfills #endif } - extension(SHA384) - { -#if !NET - /// - /// Computes the hash of data using the SHA384 algorithm. - /// - /// The data to hash. - /// The hash of the data. - /// - /// is . - /// - public static byte[] HashData(byte[] source) - { - ArgumentNullException.ThrowIfNull(source); - - using var algorithm = SHA384.Create(); - return algorithm.ComputeHash(source); - } -#endif - } - extension(ValueTask) { #if !NET @@ -355,31 +306,3 @@ internal static class OpenIddictPolyfills #endif } } - - -/// -/// Exposes common polyfills used by the OpenIddict assemblies. -/// -internal static class OpenIddictPolyfills_SHA512 -{ - extension(SHA512) - { -#if !NET - /// - /// Computes the hash of data using the SHA512 algorithm. - /// - /// The data to hash. - /// The hash of the data. - /// - /// is . - /// - public static byte[] HashData(byte[] source) - { - ArgumentNullException.ThrowIfNull(source); - - using var algorithm = SHA512.Create(); - return algorithm.ComputeHash(source); - } -#endif - } -}