Skip to content

Commit

Permalink
Showing 3 changed files with 67 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -10,7 +10,8 @@ namespace System.Security.Cryptography.Rsa.Tests
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public partial class ImportExport
{
public static bool Supports16384 { get; } = TestRsa16384();
private static readonly Lazy<bool> s_supports16384 = new Lazy<bool>(TestRsa16384);
public static bool Supports16384 => s_supports16384.Value;

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

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

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

[ConditionalFact(typeof(ImportExport), nameof(ImportExport.Supports16384))]
[ConditionalFact]
[OuterLoop("RSA 16384 takes considerable time.")]
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
@@ -198,9 +207,18 @@ public static void ReadWriteSubjectPublicKeyInfo_DiminishedDPKey()
TestData.DiminishedDPParameters);
}

[ConditionalFact(typeof(ImportExport), nameof(ImportExport.Supports16384))]

[ConditionalFact]
[OuterLoop("RSA 16384 takes considerable time.")]
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
@@ -250,9 +268,17 @@ public static void ReadWriteRsa16384SubjectPublicKeyInfo()
TestData.RSA16384Params);
}

[ConditionalFact(typeof(ImportExport), nameof(ImportExport.Supports16384))]
[ConditionalFact]
[OuterLoop("RSA 16384 takes considerable time.")]
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
@@ -525,9 +551,17 @@ public static void ReadEncryptedRsa1032()
TestData.RSA1032Parameters);
}

[ConditionalFact(typeof(ImportExport), nameof(ImportExport.Supports16384))]
[ConditionalFact]
[OuterLoop("RSA 16384 takes considerable time.")]
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
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@

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

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

[ConditionalFact(typeof(ImportExport), nameof(ImportExport.Supports16384))]
[ConditionalFact]
[OuterLoop("RSA 16384 takes considerable time.")]
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
@@ -157,9 +166,16 @@ iC2wXFMDafnWp1lxXiGcVVu9dE2LeglCgnMUps9QlJD0aXaJHYi2VDQ3zFdMvn8A imlqKtZGdGf9
expectedParameters);
}

[ConditionalFact(typeof(ImportExport), nameof(ImportExport.Supports16384))]
[ConditionalFact]
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(
@@ -634,11 +650,19 @@ public static void TestWrite2048Parameters(bool includePrivateParameters)
));
}

[ConditionalTheory(typeof(ImportExport), nameof(ImportExport.Supports16384))]
[ConditionalTheory]
[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,

0 comments on commit 69d7219

Please sign in to comment.