Skip to content

Commit

Permalink
Add a few missing ReusabilityFacts cases
Browse files Browse the repository at this point in the history
  • Loading branch information
sergezhigunov committed Feb 16, 2025
1 parent 120aae5 commit ec0e59d
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions tests/OpenGost.Security.Cryptography.Tests/ReusabilityFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@
public class ReusabilityFacts
{
[Theory]
[MemberData(nameof(ReusabilityHashAlgorithms))]
public void ReuseHashAlgorithm(Func<HashAlgorithm> hashAlgorithmFactory)
[InlineData(typeof(CMACGrasshopper))]
[InlineData(typeof(CMACMagma))]
[InlineData(typeof(HMACStreebog256))]
[InlineData(typeof(HMACStreebog512))]
[InlineData(typeof(Streebog256Managed))]
[InlineData(typeof(Streebog512Managed))]
public void ReuseHashAlgorithm(Type hashAlgorithmType)
{
using var hashAlgorithm = hashAlgorithmFactory.Invoke();
using var hashAlgorithm = (HashAlgorithm)Activator.CreateInstance(hashAlgorithmType)!;
byte[] input = [0x08, 0x06, 0x07, 0x05, 0x03, 0x00, 0x09];

var hash1 = hashAlgorithm.ComputeHash(input);
var hash2 = hashAlgorithm.ComputeHash(input);

Assert.Equal(hash1, hash2);
Assert.NotSame(hash1, hash2);
}

public static TheoryData<Func<HashAlgorithm>> ReusabilityHashAlgorithms()
=> new()
{
{ () => new Streebog256Managed() },
{ () => new Streebog512Managed() },
{ () => new CMACGrasshopper() },
{ () => new CMACMagma() },
};
}

0 comments on commit ec0e59d

Please sign in to comment.