Skip to content

Commit a99b483

Browse files
vcsjonesrichlander
andauthored
[release/8.0-staging] Backport Azure Linux test changes
* Disable MD5 tests on Azure Linux * Handle disabled algorithms on Azure Linux * Fix MD5 failures on Azure Linux in System.Security.Cryptography.Pkcs * Change BuildWithFactoryReadDirect to not use RSA+MD5 * Add Azure 3.0 helix test --------- Co-authored-by: Rich Lander <[email protected]>
1 parent 1f47f6d commit a99b483

File tree

25 files changed

+71
-28
lines changed

25 files changed

+71
-28
lines changed

eng/pipelines/libraries/helix-queues-setup.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ jobs:
7272
- Ubuntu.2204.Amd64.Open
7373
- (Debian.12.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:debian-12-helix-amd64
7474
- (Mariner.2.0.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:cbl-mariner-2.0-helix-amd64
75+
- (AzureLinux.3.0.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:azurelinux-3.0-helix-amd64
7576
- (openSUSE.15.2.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:opensuse-15.2-helix-amd64
7677
- ${{ if or(ne(parameters.jobParameters.isExtraPlatforms, true), eq(parameters.jobParameters.includeAllPlatforms, true)) }}:
7778
- (Centos.9.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:centos-stream9-helix

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/EC/ECKeyFileTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public abstract partial class ECKeyFileTests<T> where T : ECAlgorithm
1818

1919
// This would need to be virtualized if there was ever a platform that
2020
// allowed explicit in ECDH or ECDSA but not the other.
21-
public static bool SupportsExplicitCurves { get; } = EcDiffieHellman.Tests.ECDiffieHellmanFactory.ExplicitCurvesSupported;
21+
public static bool SupportsExplicitCurves { get; } =
22+
EcDiffieHellman.Tests.ECDiffieHellmanFactory.ExplicitCurvesSupported ||
23+
EcDiffieHellman.Tests.ECDiffieHellmanFactory.ExplicitCurvesSupportFailOnUseOnly;
2224

2325
public static bool CanDeriveNewPublicKey { get; } = EcDiffieHellman.Tests.ECDiffieHellmanFactory.CanDeriveNewPublicKey;
2426

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanFactory.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public interface IECDiffieHellmanProvider
1212
#endif
1313
bool IsCurveValid(Oid oid);
1414
bool ExplicitCurvesSupported { get; }
15+
bool ExplicitCurvesSupportFailOnUseOnly => PlatformDetection.IsAzureLinux;
1516
bool CanDeriveNewPublicKey { get; }
1617
bool SupportsRawDerivation { get; }
1718
bool SupportsSha3 { get; }
@@ -48,5 +49,7 @@ public static bool IsCurveValid(Oid oid)
4849
public static bool SupportsRawDerivation => s_provider.SupportsRawDerivation;
4950

5051
public static bool SupportsSha3 => s_provider.SupportsSha3;
52+
53+
public static bool ExplicitCurvesSupportFailOnUseOnly => s_provider.ExplicitCurvesSupportFailOnUseOnly;
5154
}
5255
}

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanTests.ImportExport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ public static void TestGeneralExportWithExplicitParameters()
319319
[Fact]
320320
public static void TestExplicitCurveImportOnUnsupportedPlatform()
321321
{
322-
if (ECDiffieHellmanFactory.ExplicitCurvesSupported)
322+
if (ECDiffieHellmanFactory.ExplicitCurvesSupported || ECDiffieHellmanFactory.ExplicitCurvesSupportFailOnUseOnly)
323323
{
324324
return;
325325
}

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public interface IECDsaProvider
1212
#endif
1313
bool IsCurveValid(Oid oid);
1414
bool ExplicitCurvesSupported { get; }
15+
bool ExplicitCurvesSupportFailOnUseOnly => PlatformDetection.IsAzureLinux;
1516
}
1617

1718
public static partial class ECDsaFactory
@@ -39,5 +40,6 @@ public static bool IsCurveValid(Oid oid)
3940
}
4041

4142
public static bool ExplicitCurvesSupported => s_provider.ExplicitCurvesSupported;
43+
public static bool ExplicitCurvesSupportFailOnUseOnly => s_provider.ExplicitCurvesSupportFailOnUseOnly;
4244
}
4345
}

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/KeyGeneration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ namespace System.Security.Cryptography.Rsa.Tests
88
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
99
public class KeyGeneration
1010
{
11-
[Fact]
11+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotAzureLinux))]
1212
public static void GenerateMinKey()
1313
{
1414
GenerateKey(rsa => GetMin(rsa.LegalKeySizes));
1515
}
1616

17-
[Fact]
17+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotAzureLinux))]
1818
public static void GenerateSecondMinKey()
1919
{
2020
GenerateKey(rsa => GetSecondMin(rsa.LegalKeySizes));

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/RSAFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public interface IRSAProvider
1212
bool SupportsSha2Oaep { get; }
1313
bool SupportsPss { get; }
1414
bool SupportsSha1Signatures { get; }
15+
bool SupportsMd5Signatures { get; }
1516
bool SupportsSha3 { get; }
1617
}
1718

@@ -43,6 +44,7 @@ public static RSA Create(RSAParameters rsaParameters)
4344
public static bool SupportsPss => s_provider.SupportsPss;
4445

4546
public static bool SupportsSha1Signatures => s_provider.SupportsSha1Signatures;
47+
public static bool SupportsMd5Signatures => s_provider.SupportsMd5Signatures;
4648

4749
public static bool SupportsSha3 => s_provider.SupportsSha3;
4850
public static bool NoSupportsSha3 => !SupportsSha3;

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/SignVerify.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,11 @@ public static IEnumerable<object[]> RoundTripTheories
600600
yield return new object[] { nameof(HashAlgorithmName.SHA1), rsaParameters };
601601
}
602602

603-
yield return new object[] { nameof(HashAlgorithmName.MD5), rsaParameters };
603+
if (RSAFactory.SupportsMd5Signatures)
604+
{
605+
yield return new object[] { nameof(HashAlgorithmName.MD5), rsaParameters };
606+
}
607+
604608
yield return new object[] { nameof(HashAlgorithmName.SHA256), rsaParameters };
605609
}
606610

@@ -1589,7 +1593,11 @@ public static IEnumerable<object[]> HashAlgorithmNames
15891593
yield return new object[] { HashAlgorithmName.SHA256.Name };
15901594
yield return new object[] { HashAlgorithmName.SHA384.Name };
15911595
yield return new object[] { HashAlgorithmName.SHA512.Name };
1592-
yield return new object[] { HashAlgorithmName.MD5.Name };
1596+
1597+
if (RSAFactory.SupportsMd5Signatures)
1598+
{
1599+
yield return new object[] { HashAlgorithmName.MD5.Name };
1600+
}
15931601

15941602
if (RSAFactory.SupportsSha1Signatures)
15951603
{

src/libraries/Common/tests/System/Security/Cryptography/SignatureSupport.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ namespace System.Security.Cryptography.Tests
55
{
66
internal static class SignatureSupport
77
{
8-
internal static bool CanProduceSha1Signature(AsymmetricAlgorithm algorithm)
8+
internal static bool CanProduceSha1Signature(AsymmetricAlgorithm algorithm) => CanProduceSignature(algorithm, HashAlgorithmName.SHA1);
9+
internal static bool CanProduceMd5Signature(AsymmetricAlgorithm algorithm) => CanProduceSignature(algorithm, HashAlgorithmName.MD5);
10+
11+
private static bool CanProduceSignature(AsymmetricAlgorithm algorithm, HashAlgorithmName hashAlgorithmName)
912
{
1013
using (algorithm)
1114
{
1215
#if NETFRAMEWORK
1316
return true;
1417
#else
15-
// We expect all non-Linux platforms to support SHA1 signatures, currently.
18+
// We expect all non-Linux platforms to support any signatures, currently.
1619
if (!OperatingSystem.IsLinux())
1720
{
1821
return true;
@@ -23,7 +26,7 @@ internal static bool CanProduceSha1Signature(AsymmetricAlgorithm algorithm)
2326
case ECDsa ecdsa:
2427
try
2528
{
26-
ecdsa.SignData(Array.Empty<byte>(), HashAlgorithmName.SHA1);
29+
ecdsa.SignData(Array.Empty<byte>(), hashAlgorithmName);
2730
return true;
2831
}
2932
catch (CryptographicException)
@@ -33,7 +36,7 @@ internal static bool CanProduceSha1Signature(AsymmetricAlgorithm algorithm)
3336
case RSA rsa:
3437
try
3538
{
36-
rsa.SignData(Array.Empty<byte>(), HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1);
39+
rsa.SignData(Array.Empty<byte>(), hashAlgorithmName, RSASignaturePadding.Pkcs1);
3740
return true;
3841
}
3942
catch (CryptographicException)

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ public static partial class PlatformDetection
2727
public static bool IsTizen => IsDistroAndVersion("tizen");
2828
public static bool IsFedora => IsDistroAndVersion("fedora");
2929
public static bool IsLinuxBionic => IsBionic();
30+
public static bool IsAzureLinux => IsDistroAndVersionOrHigher("azurelinux", 3);
3031

3132
public static bool IsMonoLinuxArm64 => IsMonoRuntime && IsLinux && IsArm64Process;
3233
public static bool IsNotMonoLinuxArm64 => !IsMonoLinuxArm64;
34+
public static bool IsNotAzureLinux => !IsAzureLinux;
3335

3436
// OSX family
3537
public static bool IsOSXLike => IsOSX || IsiOS || IstvOS || IsMacCatalyst;

0 commit comments

Comments
 (0)