diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanFactory.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanFactory.cs index d3d00c754d584e..ece11f82401232 100644 --- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanFactory.cs +++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanFactory.cs @@ -12,7 +12,7 @@ public interface IECDiffieHellmanProvider #endif bool IsCurveValid(Oid oid); bool ExplicitCurvesSupported { get; } - bool ExplicitCurvesSupportFailOnUseOnly => PlatformDetection.IsAzureLinux; + bool ExplicitCurvesSupportFailOnUseOnly => PlatformDetection.IsSymCryptOpenSsl; bool CanDeriveNewPublicKey { get; } bool SupportsRawDerivation { get; } bool SupportsSha3 { get; } diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaFactory.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaFactory.cs index 7571ec641fb718..244fcfe9c0c73b 100644 --- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaFactory.cs +++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaFactory.cs @@ -12,7 +12,7 @@ public interface IECDsaProvider #endif bool IsCurveValid(Oid oid); bool ExplicitCurvesSupported { get; } - bool ExplicitCurvesSupportFailOnUseOnly => PlatformDetection.IsAzureLinux; + bool ExplicitCurvesSupportFailOnUseOnly => PlatformDetection.IsSymCryptOpenSsl; } public static partial class ECDsaFactory diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/KeyGeneration.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/KeyGeneration.cs index 601118c17bd01c..f69cf0c1ec5fd9 100644 --- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/KeyGeneration.cs +++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/KeyGeneration.cs @@ -8,13 +8,13 @@ namespace System.Security.Cryptography.Rsa.Tests [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")] public class KeyGeneration { - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotAzureLinux))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotSymCryptOpenSsl))] public static void GenerateMinKey() { GenerateKey(rsa => GetMin(rsa.LegalKeySizes)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotAzureLinux))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotSymCryptOpenSsl))] public static void GenerateSecondMinKey() { GenerateKey(rsa => GetSecondMin(rsa.LegalKeySizes)); diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs index f84bc20c1ef662..2036a50f5d48df 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs @@ -34,7 +34,6 @@ public static partial class PlatformDetection public static bool IsNotMonoLinuxArm64 => !IsMonoLinuxArm64; public static bool IsQemuLinux => IsLinux && Environment.GetEnvironmentVariable("DOTNET_RUNNING_UNDER_QEMU") != null; public static bool IsNotQemuLinux => !IsQemuLinux; - public static bool IsNotAzureLinux => !IsAzureLinux; // OSX family public static bool IsApplePlatform => IsOSX || IsiOS || IstvOS || IsMacCatalyst; @@ -57,6 +56,18 @@ public static partial class PlatformDetection public static bool IsOpenSsl3_4 => IsOpenSslVersionAtLeast(s_openssl3_4Version); public static bool IsOpenSsl3_5 => IsOpenSslVersionAtLeast(s_openssl3_5Version); + private static readonly Lazy s_isSymCryptOpenSsl = new(() => + { + return IsAzureLinux && + ( + File.Exists("/usr/lib/ossl-modules/symcryptprovider.so") || + File.Exists("/usr/lib64/ossl-modules/symcryptprovider.so") + ); + }); + + public static bool IsSymCryptOpenSsl => s_isSymCryptOpenSsl.Value; + public static bool IsNotSymCryptOpenSsl => !IsSymCryptOpenSsl; + /// /// If gnulibc is available, returns the release, such as "stable". /// Otherwise returns "glibc_not_found". diff --git a/src/libraries/System.Security.Cryptography.OpenSsl/tests/EcDsaOpenSslProvider.cs b/src/libraries/System.Security.Cryptography.OpenSsl/tests/EcDsaOpenSslProvider.cs index 4735038ec0184c..82607d480b5353 100644 --- a/src/libraries/System.Security.Cryptography.OpenSsl/tests/EcDsaOpenSslProvider.cs +++ b/src/libraries/System.Security.Cryptography.OpenSsl/tests/EcDsaOpenSslProvider.cs @@ -46,13 +46,7 @@ private static bool IsValueOrFriendlyNameValid(string friendlyNameOrValue) return false; } - public bool ExplicitCurvesSupported - { - get - { - return !PlatformDetection.IsAzureLinux; - } - } + public bool ExplicitCurvesSupported => PlatformDetection.IsNotSymCryptOpenSsl; } public partial class ECDsaFactory diff --git a/src/libraries/System.Security.Cryptography/tests/DefaultECDiffieHellmanProvider.Unix.cs b/src/libraries/System.Security.Cryptography/tests/DefaultECDiffieHellmanProvider.Unix.cs index 77c32104f2d575..c6fe568486c0bf 100644 --- a/src/libraries/System.Security.Cryptography/tests/DefaultECDiffieHellmanProvider.Unix.cs +++ b/src/libraries/System.Security.Cryptography/tests/DefaultECDiffieHellmanProvider.Unix.cs @@ -25,7 +25,7 @@ public bool ExplicitCurvesSupported { get { - if (PlatformDetection.IsApplePlatform || PlatformDetection.IsAzureLinux) + if (PlatformDetection.IsApplePlatform || PlatformDetection.IsSymCryptOpenSsl) { return false; } diff --git a/src/libraries/System.Security.Cryptography/tests/DefaultECDsaProvider.Unix.cs b/src/libraries/System.Security.Cryptography/tests/DefaultECDsaProvider.Unix.cs index cec7aac4895ab5..11ea1c6d2d84fc 100644 --- a/src/libraries/System.Security.Cryptography/tests/DefaultECDsaProvider.Unix.cs +++ b/src/libraries/System.Security.Cryptography/tests/DefaultECDsaProvider.Unix.cs @@ -25,7 +25,7 @@ public bool ExplicitCurvesSupported { get { - if (PlatformDetection.IsApplePlatform || PlatformDetection.IsAzureLinux) + if (PlatformDetection.IsApplePlatform || PlatformDetection.IsSymCryptOpenSsl) { return false; } diff --git a/src/libraries/System.Security.Cryptography/tests/HKDFTests.cs b/src/libraries/System.Security.Cryptography/tests/HKDFTests.cs index 882e7b6372de6f..460b81c9435727 100644 --- a/src/libraries/System.Security.Cryptography/tests/HKDFTests.cs +++ b/src/libraries/System.Security.Cryptography/tests/HKDFTests.cs @@ -14,8 +14,8 @@ public abstract class HKDFTests protected abstract byte[] Expand(HashAlgorithmName hash, byte[] prk, int outputLength, byte[] info); protected abstract byte[] DeriveKey(HashAlgorithmName hash, byte[] ikm, int outputLength, byte[] salt, byte[] info); - internal static bool MD5Supported => !PlatformDetection.IsBrowser && !PlatformDetection.IsAzureLinux; - internal static bool EmptyKeysSupported => !PlatformDetection.IsAzureLinux; + internal static bool MD5Supported => !PlatformDetection.IsBrowser && !PlatformDetection.IsSymCryptOpenSsl; + internal static bool EmptyKeysSupported => !PlatformDetection.IsSymCryptOpenSsl; [Theory] [MemberData(nameof(GetHkdfTestCases))] diff --git a/src/libraries/System.Security.Cryptography/tests/HmacMD5Tests.cs b/src/libraries/System.Security.Cryptography/tests/HmacMD5Tests.cs index 1099b65976a2cf..740310b5b0aa28 100644 --- a/src/libraries/System.Security.Cryptography/tests/HmacMD5Tests.cs +++ b/src/libraries/System.Security.Cryptography/tests/HmacMD5Tests.cs @@ -14,7 +14,7 @@ public class HmacMD5Tests : Rfc2202HmacTests { public sealed class Traits : IHmacTrait { - public static bool IsSupported => !PlatformDetection.IsAzureLinux && !PlatformDetection.IsBrowser; + public static bool IsSupported => !PlatformDetection.IsSymCryptOpenSsl && !PlatformDetection.IsBrowser; public static int HashSizeInBytes => HMACMD5.HashSizeInBytes; } diff --git a/src/libraries/System.Security.Cryptography/tests/KmacTestDriver.cs b/src/libraries/System.Security.Cryptography/tests/KmacTestDriver.cs index 4d7c10b317add9..50b79114590131 100644 --- a/src/libraries/System.Security.Cryptography/tests/KmacTestDriver.cs +++ b/src/libraries/System.Security.Cryptography/tests/KmacTestDriver.cs @@ -95,7 +95,7 @@ public abstract class KmacTestDriver public static bool IsSupported => TKmacTrait.IsSupported; public static bool IsNotSupported => !IsSupported; public static KeySizes? PlatformKeySizeRequirements { get; } = - PlatformDetection.IsOpenSslSupported && !PlatformDetection.IsAzureLinux ? new KeySizes(4, 512, 1) : null; + PlatformDetection.IsOpenSslSupported && !PlatformDetection.IsSymCryptOpenSsl ? new KeySizes(4, 512, 1) : null; public static int? PlatformMaxOutputSize { get; } = PlatformDetection.IsOpenSslSupported ? 0xFFFFFF / 8 : null; public static int? PlatformMaxCustomizationStringSize { get; } = PlatformDetection.IsOpenSslSupported ? 512 : null;