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

Commit 4cc2a21

Browse files
committed
Move the AlgorithmLookups test into the CSP-specific test suite.
1 parent 00de558 commit 4cc2a21

File tree

3 files changed

+49
-39
lines changed

3 files changed

+49
-39
lines changed

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -607,45 +607,6 @@ public static void VerifyHashSignature_SHA256_2048()
607607
VerifyHashSignature(hashSignature, dataHash, "SHA256", TestData.RSA2048Params);
608608
}
609609

610-
[Theory]
611-
[MemberData("AlgorithmIdentifiers")]
612-
public static void AlgorithmLookups(string primaryId, object halg)
613-
{
614-
byte[] data = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
615-
616-
using (var rsa = new RSACryptoServiceProvider())
617-
{
618-
rsa.ImportParameters(TestData.RSA2048Params);
619-
620-
byte[] primary = rsa.SignData(data, primaryId);
621-
byte[] lookup = rsa.SignData(data, halg);
622-
623-
Assert.Equal(primary, lookup);
624-
}
625-
}
626-
627-
public static IEnumerable<object[]> AlgorithmIdentifiers()
628-
{
629-
return new[]
630-
{
631-
new object[] { "MD5", MD5.Create() },
632-
new object[] { "MD5", typeof(MD5) },
633-
new object[] { "MD5", "1.2.840.113549.2.5" },
634-
new object[] { "SHA1", SHA1.Create() },
635-
new object[] { "SHA1", typeof(SHA1) },
636-
new object[] { "SHA1", "1.3.14.3.2.26" },
637-
new object[] { "SHA256", SHA256.Create() },
638-
new object[] { "SHA256", typeof(SHA256) },
639-
new object[] { "SHA256", "2.16.840.1.101.3.4.2.1" },
640-
new object[] { "SHA384", SHA384.Create() },
641-
new object[] { "SHA384", typeof(SHA384) },
642-
new object[] { "SHA384", "2.16.840.1.101.3.4.2.2" },
643-
new object[] { "SHA512", SHA512.Create() },
644-
new object[] { "SHA512", typeof(SHA512) },
645-
new object[] { "SHA512", "2.16.840.1.101.3.4.2.3" },
646-
};
647-
}
648-
649610
private static void ExpectSignature(
650611
byte[] expectedSignature,
651612
byte[] data,
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System.Collections.Generic;
2+
using System.Security.Cryptography.Rsa.Tests;
3+
using Xunit;
4+
5+
namespace System.Security.Cryptography.Csp.Tests
6+
{
7+
public class RSACryptoServiceProviderBackCompat
8+
{
9+
[Theory]
10+
[MemberData("AlgorithmIdentifiers")]
11+
public static void AlgorithmLookups(string primaryId, object halg)
12+
{
13+
byte[] data = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
14+
15+
using (var rsa = new RSACryptoServiceProvider())
16+
{
17+
rsa.ImportParameters(TestData.RSA2048Params);
18+
19+
byte[] primary = rsa.SignData(data, primaryId);
20+
byte[] lookup = rsa.SignData(data, halg);
21+
22+
Assert.Equal(primary, lookup);
23+
}
24+
}
25+
26+
public static IEnumerable<object[]> AlgorithmIdentifiers()
27+
{
28+
return new[]
29+
{
30+
new object[] { "MD5", MD5.Create() },
31+
new object[] { "MD5", typeof(MD5) },
32+
new object[] { "MD5", "1.2.840.113549.2.5" },
33+
new object[] { "SHA1", SHA1.Create() },
34+
new object[] { "SHA1", typeof(SHA1) },
35+
new object[] { "SHA1", "1.3.14.3.2.26" },
36+
new object[] { "SHA256", SHA256.Create() },
37+
new object[] { "SHA256", typeof(SHA256) },
38+
new object[] { "SHA256", "2.16.840.1.101.3.4.2.1" },
39+
new object[] { "SHA384", SHA384.Create() },
40+
new object[] { "SHA384", typeof(SHA384) },
41+
new object[] { "SHA384", "2.16.840.1.101.3.4.2.2" },
42+
new object[] { "SHA512", SHA512.Create() },
43+
new object[] { "SHA512", typeof(SHA512) },
44+
new object[] { "SHA512", "2.16.840.1.101.3.4.2.3" },
45+
};
46+
}
47+
}
48+
}

src/System.Security.Cryptography.Csp/tests/System.Security.Cryptography.Csp.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
</ItemGroup>
2727
<ItemGroup>
2828
<Compile Include="ImportExportCspBlob.cs" />
29+
<Compile Include="RSACryptoServiceProviderBackCompat.cs" />
2930
<Compile Include="$(CommonTestPath)\Cryptography\AlgorithmImplementations\RSA\EncryptDecrypt.cs" />
3031
<Compile Include="$(CommonTestPath)\Cryptography\AlgorithmImplementations\RSA\ImportExport.cs" />
3132
<Compile Include="$(CommonTestPath)\Cryptography\AlgorithmImplementations\RSA\KeyGeneration.cs" />

0 commit comments

Comments
 (0)