Skip to content

Commit 8f27338

Browse files
committed
fix: argument check
1 parent 6f530bc commit 8f27338

File tree

4 files changed

+2
-4
lines changed

4 files changed

+2
-4
lines changed

src/CryptoBase/SymmetricCryptos/BlockCryptos/SM4/SM4Crypto.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ public SM4Crypto(ReadOnlySpan<byte> key)
123123

124124
public override void Encrypt(ReadOnlySpan<byte> source, Span<byte> destination)
125125
{
126-
base.Encrypt(source, destination);
126+
ArgumentOutOfRangeException.ThrowIfLessThan(source.Length, BlockSize, nameof(source));
127+
ArgumentOutOfRangeException.ThrowIfLessThan(destination.Length, BlockSize, nameof(destination));
127128

128129
uint x0 = BinaryPrimitives.ReadUInt32BigEndian(source);
129130
uint x1 = BinaryPrimitives.ReadUInt32BigEndian(source[4..]);

src/CryptoBase/SymmetricCryptos/BlockCryptos/SM4/SM4CryptoBlock16X86.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public class SM4CryptoBlock16X86(ReadOnlySpan<byte> key) : SM4Crypto(key)
99
public override void Encrypt(ReadOnlySpan<byte> source, Span<byte> destination)
1010
{
1111
ArgumentOutOfRangeException.ThrowIfLessThan(source.Length, BlockSize, nameof(source));
12-
1312
ArgumentOutOfRangeException.ThrowIfLessThan(destination.Length, BlockSize, nameof(destination));
1413

1514
SM4Utils.Encrypt16(Rk, source, destination);

src/CryptoBase/SymmetricCryptos/BlockCryptos/SM4/SM4CryptoBlock8X86.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public class SM4CryptoBlock8X86(ReadOnlySpan<byte> key) : SM4Crypto(key)
99
public override void Encrypt(ReadOnlySpan<byte> source, Span<byte> destination)
1010
{
1111
ArgumentOutOfRangeException.ThrowIfLessThan(source.Length, BlockSize, nameof(source));
12-
1312
ArgumentOutOfRangeException.ThrowIfLessThan(destination.Length, BlockSize, nameof(destination));
1413

1514
SM4Utils.Encrypt8(Rk, source, destination);

src/CryptoBase/SymmetricCryptos/BlockCryptos/SM4/SM4CryptoX86.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public class SM4CryptoX86(ReadOnlySpan<byte> key) : SM4Crypto(key)
99
public override void Encrypt(ReadOnlySpan<byte> source, Span<byte> destination)
1010
{
1111
ArgumentOutOfRangeException.ThrowIfLessThan(source.Length, BlockSize, nameof(source));
12-
1312
ArgumentOutOfRangeException.ThrowIfLessThan(destination.Length, BlockSize, nameof(destination));
1413

1514
SM4Utils.Encrypt4(Rk, source, destination);

0 commit comments

Comments
 (0)