Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use separate key instances for span/array/array+offset test classes #34199

Merged
merged 1 commit into from
Mar 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ namespace System.Security.Cryptography.Dsa.Tests
{
public abstract class DSASignatureFormatTests : DsaFamilySignatureFormatTests
{
private static readonly KeyDescription[] s_keys = LocalGenerateTestKeys().ToArray();

protected override KeyDescription[] GenerateTestKeys() => s_keys;
protected override bool SupportsSha2 => DSAFactory.SupportsFips186_3;
protected override string HashParameterName => "rgbHash";
protected override string SignatureParameterName => "rgbSignature";
Expand Down Expand Up @@ -50,7 +47,7 @@ private static KeyDescription OpenKey(in DSAParameters dsaParameters)
dsaParameters.Q.Length * 8);
}

private static IEnumerable<KeyDescription> LocalGenerateTestKeys()
protected static IEnumerable<KeyDescription> LocalGenerateTestKeys()
{
if (DSAFactory.SupportsKeyGeneration)
{
Expand All @@ -73,6 +70,9 @@ private static IEnumerable<KeyDescription> LocalGenerateTestKeys()

public sealed class DsaArraySignatureFormatTests : DSASignatureFormatTests
{
private static readonly KeyDescription[] s_keys = LocalGenerateTestKeys().ToArray();

protected override KeyDescription[] GenerateTestKeys() => s_keys;
protected override bool IsArrayBased => true;

protected override byte[] SignHash(
Expand Down Expand Up @@ -114,6 +114,9 @@ protected override bool VerifyData(

public sealed class DsaArrayOffsetSignatureFormatTests : DSASignatureFormatTests
{
private static readonly KeyDescription[] s_keys = LocalGenerateTestKeys().ToArray();

protected override KeyDescription[] GenerateTestKeys() => s_keys;
protected override bool IsArrayBased => true;

protected override byte[] SignHash(
Expand Down Expand Up @@ -232,6 +235,9 @@ public void OffsetAndCountOutOfRange()

public sealed class DsaSpanSignatureFormatTests : DSASignatureFormatTests
{
private static readonly KeyDescription[] s_keys = LocalGenerateTestKeys().ToArray();

protected override KeyDescription[] GenerateTestKeys() => s_keys;
protected override bool IsArrayBased => false;

protected override byte[] SignHash(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ namespace System.Security.Cryptography.EcDsa.Tests
{
public abstract class ECDsaSignatureFormatTests : DsaFamilySignatureFormatTests
{
private static readonly KeyDescription[] s_keys = LocalGenerateTestKeys().ToArray();

protected override KeyDescription[] GenerateTestKeys() => s_keys;
protected override bool SupportsSha2 => true;

private static KeyDescription CreateKey(ECCurve curve)
Expand All @@ -38,7 +35,7 @@ private static KeyDescription OpenKey(in ECParameters ecParameters)
dsa.KeySize);
}

private static IEnumerable<KeyDescription> LocalGenerateTestKeys()
protected static IEnumerable<KeyDescription> LocalGenerateTestKeys()
{
if (ECDsaFactory.IsCurveValid(EccTestData.BrainpoolP160r1Key1.Curve.Oid))
{
Expand All @@ -58,8 +55,11 @@ private static IEnumerable<KeyDescription> LocalGenerateTestKeys()

public sealed class ECDsaArraySignatureFormatTests : ECDsaSignatureFormatTests
{
protected override bool IsArrayBased => true;
private static readonly KeyDescription[] s_keys = LocalGenerateTestKeys().ToArray();

protected override KeyDescription[] GenerateTestKeys() => s_keys;
protected override bool IsArrayBased => true;

protected override byte[] SignHash(
KeyDescription key,
byte[] hash,
Expand Down Expand Up @@ -99,6 +99,9 @@ protected override bool VerifyData(

public sealed class ECDsaArrayOffsetSignatureFormatTests : ECDsaSignatureFormatTests
{
private static readonly KeyDescription[] s_keys = LocalGenerateTestKeys().ToArray();

protected override KeyDescription[] GenerateTestKeys() => s_keys;
protected override bool IsArrayBased => true;

protected override byte[] SignHash(
Expand Down Expand Up @@ -217,6 +220,9 @@ public void OffsetAndCountOutOfRange()

public sealed class ECDsaSpanSignatureFormatTests : ECDsaSignatureFormatTests
{
private static readonly KeyDescription[] s_keys = LocalGenerateTestKeys().ToArray();

protected override KeyDescription[] GenerateTestKeys() => s_keys;
protected override bool IsArrayBased => false;

protected override byte[] SignHash(
Expand Down