Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
HMBSbige committed Jan 14, 2024
1 parent c4c4a3f commit 332e44e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/CryptoBase.Tests/SM4Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using CryptoBase.SymmetricCryptos.BlockCryptos.SM4;
using CryptoBase.SymmetricCryptos.StreamCryptos;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Runtime.Intrinsics.X86;
using System.Security.Cryptography;

namespace CryptoBase.Tests;
Expand Down Expand Up @@ -90,10 +89,17 @@ public void Test(string keyHex, string hex1, string hex2, string hex3)
public void TestN()
{
ReadOnlySpan<byte> key = RandomNumberGenerator.GetBytes(16);
TestN(4, new SM4CryptoX86(key), key);
if (Avx.IsSupported)

if (SM4CryptoX86.IsSupported)
{
TestN(4, new SM4CryptoX86(key), key);
}
if (SM4CryptoBlock8X86.IsSupported)
{
TestN(8, new SM4CryptoBlock8X86(key), key);
}
if (SM4CryptoBlock16X86.IsSupported)
{
TestN(16, new SM4CryptoBlock16X86(key), key);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace CryptoBase.SymmetricCryptos.BlockCryptos.SM4;

public class SM4CryptoBlock16X86(ReadOnlySpan<byte> key) : SM4Crypto(key)
{
public static bool IsSupported => Aes.IsSupported && Avx.IsSupported && Avx2.IsSupported;
public static bool IsSupported => Aes.IsSupported && Avx2.IsSupported;

public override int BlockSize => 256;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace CryptoBase.SymmetricCryptos.BlockCryptos.SM4;

public class SM4CryptoBlock8X86(ReadOnlySpan<byte> key) : SM4Crypto(key)
{
public static bool IsSupported => Aes.IsSupported && Avx.IsSupported && Avx2.IsSupported;
public static bool IsSupported => Aes.IsSupported && Sse2.IsSupported && Ssse3.IsSupported;

public override int BlockSize => 128;

Expand Down

0 comments on commit 332e44e

Please sign in to comment.