Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<bool> 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;

/// <summary>
/// If gnulibc is available, returns the release, such as "stable".
/// Otherwise returns "glibc_not_found".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public bool ExplicitCurvesSupported
{
get
{
if (PlatformDetection.IsApplePlatform || PlatformDetection.IsAzureLinux)
if (PlatformDetection.IsApplePlatform || PlatformDetection.IsSymCryptOpenSsl)
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public bool ExplicitCurvesSupported
{
get
{
if (PlatformDetection.IsApplePlatform || PlatformDetection.IsAzureLinux)
if (PlatformDetection.IsApplePlatform || PlatformDetection.IsSymCryptOpenSsl)
{
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/System.Security.Cryptography/tests/HKDFTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class HmacMD5Tests : Rfc2202HmacTests<HmacMD5Tests.Traits>
{
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public abstract class KmacTestDriver<TKmacTrait, TKmac>
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;
Expand Down
Loading