Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 0218670

Browse files
safernstephentoub
authored andcommitted
Fix S.Security.Cryptography desktop tests (#19505)
* Fix 19283 * Fix 19238 * Fix 19080 * Fix 19079
1 parent 0d8de93 commit 0218670

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/ImportExport.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ public static void ExportAutoKey()
4242
Assert.Equal(privateParams.Exponent, publicParams.Exponent);
4343
}
4444

45-
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "dotnet/corefx #19238")]
46-
[Fact]
45+
[ConditionalFact(nameof(EphemeralKeysAreExportable))]
4746
public static void PaddedExport()
4847
{
4948
// OpenSSL's numeric type for the storage of RSA key parts disregards zero-valued
@@ -70,8 +69,7 @@ public static void PaddedExport()
7069
AssertKeyEquals(ref diminishedDPParameters, ref exported);
7170
}
7271

73-
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "dotnet/corefx #19238")]
74-
[Fact]
72+
[ConditionalFact(nameof(EphemeralKeysAreExportable))]
7573
public static void LargeKeyImportExport()
7674
{
7775
RSAParameters imported = TestData.RSA16384Params;
@@ -100,8 +98,7 @@ public static void LargeKeyImportExport()
10098
}
10199
}
102100

103-
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "dotnet/corefx #19238")]
104-
[Fact]
101+
[ConditionalFact(nameof(EphemeralKeysAreExportable))]
105102
public static void UnusualExponentImportExport()
106103
{
107104
// Most choices for the Exponent value in an RSA key use a Fermat prime.
@@ -146,8 +143,7 @@ public static void ImportExport1032()
146143
Assert.Null(exportedPublic.D);
147144
}
148145

149-
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "dotnet/corefx #19238")]
150-
[Fact]
146+
[ConditionalFact(nameof(EphemeralKeysAreExportable))]
151147
public static void ImportReset()
152148
{
153149
using (RSA rsa = RSAFactory.Create())
@@ -195,8 +191,7 @@ public static void ImportPrivateExportPublic()
195191
}
196192
}
197193

198-
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "dotnet/corefx #19238")]
199-
[Fact]
194+
[ConditionalFact(nameof(EphemeralKeysAreExportable))]
200195
public static void MultiExport()
201196
{
202197
RSAParameters imported = TestData.RSA1024Params;

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ namespace System.Security.Cryptography.Rsa.Tests
1010
{
1111
public class SignVerify
1212
{
13+
public static bool BadKeyFormatDoesntThrow => !PlatformDetection.IsFullFramework || PlatformDetection.IsNetfx462OrNewer();
14+
public static bool InvalidKeySizeDoesntThrow => !PlatformDetection.IsFullFramework || PlatformDetection.IsNetfx462OrNewer();
15+
1316
[Fact]
1417
public static void InvalidKeySize_DoesNotInvalidateKey()
1518
{
@@ -57,7 +60,7 @@ public static void SignNullHash()
5760
}
5861
}
5962

60-
[Fact]
63+
[ConditionalFact(nameof(InvalidKeySizeDoesntThrow))]
6164
public static void ExpectedSignature_SHA1_384()
6265
{
6366
byte[] expectedSignature =
@@ -88,7 +91,7 @@ public static void ExpectedSignature_SHA1_384()
8891
}
8992
}
9093

91-
[Fact]
94+
[ConditionalFact(nameof(InvalidKeySizeDoesntThrow))]
9295
public static void ExpectedSignature_SHA1_1032()
9396
{
9497
byte[] expectedSignature =
@@ -260,7 +263,7 @@ public static void ExpectSignature_SHA256_1024_Stream()
260263
Assert.Equal(expectedSignature, signature);
261264
}
262265

263-
[Fact]
266+
[ConditionalFact(nameof(InvalidKeySizeDoesntThrow))]
264267
public static void VerifySignature_SHA1_384()
265268
{
266269
byte[] signature =
@@ -276,7 +279,7 @@ public static void VerifySignature_SHA1_384()
276279
VerifySignature(signature, TestData.HelloBytes, "SHA1", TestData.RSA384Parameters);
277280
}
278281

279-
[Fact]
282+
[ConditionalFact(nameof(InvalidKeySizeDoesntThrow))]
280283
public static void VerifySignature_SHA1_1032()
281284
{
282285
byte[] signature =
@@ -472,7 +475,7 @@ public static void NegativeVerify_TamperedData()
472475
}
473476
}
474477

475-
[Fact]
478+
[ConditionalFact(nameof(BadKeyFormatDoesntThrow))]
476479
public static void NegativeVerify_BadKeysize()
477480
{
478481
byte[] signature;

src/System.Security.Cryptography.Cng/tests/RsaCngTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace System.Security.Cryptography.Cng.Tests
1616
{
1717
public static class RsaCngTests
1818
{
19+
public static bool KeySizeTrustsOSValue => !PlatformDetection.IsFullFramework || PlatformDetection.IsNetfx462OrNewer();
20+
1921
[Fact]
2022
public static void SignVerifyHashRoundTrip()
2123
{
@@ -77,7 +79,7 @@ public static void VerifyHashPss()
7779
}
7880
}
7981

80-
[Fact]
82+
[ConditionalFact(nameof(KeySizeTrustsOSValue))]
8183
public static void RSACng_Ctor_UnusualKeysize_384()
8284
{
8385
const int ExpectedKeySize = 384;
@@ -108,7 +110,7 @@ public static void RSACng_Ctor_UnusualKeysize_384()
108110
}
109111
}
110112

111-
[Fact]
113+
[ConditionalFact(nameof(KeySizeTrustsOSValue))]
112114
public static void RSACng_Ctor_UnusualKeysize_1032()
113115
{
114116
const int ExpectedKeySize = 1032;

0 commit comments

Comments
 (0)