Skip to content

Commit

Permalink
Restore RSA 16384 tests to innerloop
Browse files Browse the repository at this point in the history
  • Loading branch information
vcsjones authored and pull[bot] committed Jul 2, 2024
1 parent 8b81fc8 commit 1538737
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ namespace System.Security.Cryptography.Rsa.Tests
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public partial class ImportExport
{
private static readonly Lazy<bool> s_supports16384 = new Lazy<bool>(TestRsa16384);
public static bool Supports16384 => s_supports16384.Value;
public static bool Supports16384 { get; } = TestRsa16384();

[Fact]
public static void ExportAutoKey()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Security.Cryptography.Encryption.RC2.Tests;
using System.Text;
using Microsoft.DotNet.XUnitExtensions;
using Test.Cryptography;
using Xunit;

Expand Down Expand Up @@ -123,17 +122,9 @@ public static void ReadWriteDiminishedDPPrivatePkcs1()
TestData.DiminishedDPParameters);
}

[ConditionalFact]
[OuterLoop("RSA 16384 takes considerable time.")]
[ConditionalFact(typeof(ImportExport), nameof(ImportExport.Supports16384))]
public static void ReadWritePublicPkcs1()
{
// Do not move this to the [ConditionalFact], otherwise the platform will check if RSA 16384 is supported
// during test discovery for innerloop, and the check itself is expensive.
if (!ImportExport.Supports16384)
{
throw new SkipTestException("Platform does not support RSA 16384.");
}

ReadWriteBase64PublicPkcs1(
@"
MIIICgKCCAEAmyxwX6kQNx+LSMao1StC1p5rKCEwcBjzI136An3B/BjthgezAOuu
Expand Down Expand Up @@ -207,18 +198,9 @@ public static void ReadWriteSubjectPublicKeyInfo_DiminishedDPKey()
TestData.DiminishedDPParameters);
}


[ConditionalFact]
[OuterLoop("RSA 16384 takes considerable time.")]
[ConditionalFact(typeof(ImportExport), nameof(ImportExport.Supports16384))]
public static void ReadWriteRsa16384SubjectPublicKeyInfo()
{
// Do not move this to the [ConditionalFact], otherwise the platform will check if RSA 16384 is supported
// during test discovery for innerloop, and the check itself is expensive.
if (!ImportExport.Supports16384)
{
throw new SkipTestException("Platform does not support RSA 16384.");
}

ReadWriteBase64SubjectPublicKeyInfo(
@"
MIIIIjANBgkqhkiG9w0BAQEFAAOCCA8AMIIICgKCCAEAmyxwX6kQNx+LSMao1StC
Expand Down Expand Up @@ -268,17 +250,9 @@ public static void ReadWriteRsa16384SubjectPublicKeyInfo()
TestData.RSA16384Params);
}

[ConditionalFact]
[OuterLoop("RSA 16384 takes considerable time.")]
[ConditionalFact(typeof(ImportExport), nameof(ImportExport.Supports16384))]
public static void ReadWrite16384Pkcs8()
{
// Do not move this to the [ConditionalFact], otherwise the platform will check if RSA 16384 is supported
// during test discovery for innerloop, and the check itself is expensive.
if (!ImportExport.Supports16384)
{
throw new SkipTestException("Platform does not support RSA 16384");
}

ReadWriteBase64Pkcs8(
@"
MIIkQgIBADANBgkqhkiG9w0BAQEFAASCJCwwgiQoAgEAAoIIAQCbLHBfqRA3H4tI
Expand Down Expand Up @@ -551,17 +525,9 @@ public static void ReadEncryptedRsa1032()
TestData.RSA1032Parameters);
}

[ConditionalFact]
[OuterLoop("RSA 16384 takes considerable time.")]
[ConditionalFact(typeof(ImportExport), nameof(ImportExport.Supports16384))]
public static void ReadEncryptedRsa16384()
{
// Do not move this to the [ConditionalFact], otherwise the platform will check if RSA 16384 is supported
// during test discovery for innerloop, and the check itself is expensive.
if (!ImportExport.Supports16384)
{
throw new SkipTestException("Platform does not support RSA 16384");
}

// PBES2: PBKDF2 + des (single DES, not 3DES).
const string base64 = @"
MIIkizA9BgkqhkiG9w0BBQ0wMDAbBgkqhkiG9w0BBQwwDgQI63upT8JPNNcCAggA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Collections.Generic;
using System.Xml.Linq;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;

namespace System.Security.Cryptography.Rsa.Tests
Expand Down Expand Up @@ -77,17 +76,9 @@ public static void TestRead1032Parameters_Private()
TestData.RSA1032Parameters);
}

[ConditionalFact]
[OuterLoop("RSA 16384 takes considerable time.")]
[ConditionalFact(typeof(ImportExport), nameof(ImportExport.Supports16384))]
public static void TestRead16384Parameters_Public()
{
// Do not move this to the [ConditionalFact], otherwise the platform will check if RSA 16384 is supported
// during test discovery for innerloop, and the check itself is expensive.
if (!ImportExport.Supports16384)
{
throw new SkipTestException("Platform does not support RSA 16384");
}

RSAParameters expectedParameters = ImportExport.MakePublic(TestData.RSA16384Params);

// Bonus trait of this XML: the Modulus and Exponent parameters
Expand Down Expand Up @@ -166,16 +157,9 @@ iC2wXFMDafnWp1lxXiGcVVu9dE2LeglCgnMUps9QlJD0aXaJHYi2VDQ3zFdMvn8A imlqKtZGdGf9
expectedParameters);
}

[ConditionalFact]
[ConditionalFact(typeof(ImportExport), nameof(ImportExport.Supports16384))]
public static void TestRead16384Parameters_Private()
{
// Do not move this to the [ConditionalFact], otherwise the platform will check if RSA 16384 is supported
// during test discovery for innerloop, and the check itself is expensive.
if (!ImportExport.Supports16384)
{
throw new SkipTestException("Platform does not support RSA 16384");
}

// Bonus trait of this XML: the D parameter is not in
// canonical order.
TestReadXml(
Expand Down Expand Up @@ -650,19 +634,11 @@ public static void TestWrite2048Parameters(bool includePrivateParameters)
));
}

[ConditionalTheory]
[ConditionalTheory(typeof(ImportExport), nameof(ImportExport.Supports16384))]
[InlineData(true)]
[InlineData(false)]
[OuterLoop("RSA 16384 takes considerable time for primality tests.")]
public static void TestWrite16384Parameters(bool includePrivateParameters)
{
// Do not move this to the [ConditionalFact], otherwise the platform will check if RSA 16384 is supported
// during test discovery for innerloop, and the check itself is expensive.
if (!ImportExport.Supports16384)
{
throw new SkipTestException("Platform does not support RSA 16384");
}

TestWriteXml(
TestData.RSA16384Params,
includePrivateParameters,
Expand Down

0 comments on commit 1538737

Please sign in to comment.