Skip to content

Commit

Permalink
Use 2048-bit key sizes for RSA tests
Browse files Browse the repository at this point in the history
Also enabled RSACng tests for Windows.
  • Loading branch information
jstedfast committed Feb 22, 2025
1 parent dded6a2 commit 12a0047
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions UnitTests/Cryptography/AsymmetricAlgorithmExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
//

using System.Security.Cryptography;
using System.Diagnostics.CodeAnalysis;

using Org.BouncyCastle.Math;
using Org.BouncyCastle.Crypto;
Expand Down Expand Up @@ -126,11 +127,16 @@ public void TestDSACryptoServiceProvider ()
}

[Test]
[SuppressMessage ("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
public void TestDSACng ()
{
#if !MONO && ENABLE_DSA_CNG
using (var dsa = new DSACng (1024))
AssertDSA (dsa);
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
using (var dsa = new DSACng (1024))
AssertDSA (dsa);
} else {
Assert.Ignore ("DSACng is only supported on Windows systems.");
}
#else
Assert.Ignore ("Mono does not implement DSACng");
#endif
Expand Down Expand Up @@ -189,16 +195,21 @@ static void AssertRSA (RSA rsa)
[Test]
public void TestRSACryptoServiceProvider ()
{
using (var rsa = new RSACryptoServiceProvider (1024))
using (var rsa = new RSACryptoServiceProvider (2048))
AssertRSA (rsa);
}

[Test]
[SuppressMessage ("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
public void TestRSACng ()
{
#if !MONO && ENABLE_RSA_CNG
using (var rsa = new RSACng (1024))
AssertRSA (rsa);
#if !MONO
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
using (var rsa = new RSACng (2048))
AssertRSA (rsa);
} else {
Assert.Ignore ("RSACng is only supported on Windows systems.");
}
#else
Assert.Ignore ("Mono does not implement RSACng");
#endif
Expand Down

0 comments on commit 12a0047

Please sign in to comment.