From c4c4a3f05a3fb14cc47118714a7d92ce49742559 Mon Sep 17 00:00:00 2001 From: Bruce Wayne Date: Sun, 14 Jan 2024 17:29:30 +0800 Subject: [PATCH] refactor: drop Xor --- .../StreamCryptos/ChaCha20/ChaCha20CryptoSF.cs | 5 ----- .../StreamCryptos/ChaCha20/ChaCha20CryptoX86.cs | 5 ----- .../ChaCha20Original/ChaCha20OriginalCryptoSF.cs | 5 ----- .../ChaCha20Original/ChaCha20OriginalCryptoX86.cs | 5 ----- .../StreamCryptos/Salsa20/Salsa20CryptoSF.cs | 5 ----- .../StreamCryptos/Salsa20/Salsa20CryptoX86.cs | 5 ----- .../SymmetricCryptos/StreamCryptos/SnuffleCrypto.cs | 3 +-- .../StreamCryptos/XChaCha20/XChaCha20CryptoSF.cs | 5 ----- .../StreamCryptos/XChaCha20/XChaCha20CryptoX86.cs | 5 ----- .../StreamCryptos/XSalsa20/XSalsa20CryptoSF.cs | 5 ----- .../StreamCryptos/XSalsa20/XSalsa20CryptoX86.cs | 5 ----- 11 files changed, 1 insertion(+), 52 deletions(-) diff --git a/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20/ChaCha20CryptoSF.cs b/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20/ChaCha20CryptoSF.cs index e3a7d8d..b35440d 100644 --- a/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20/ChaCha20CryptoSF.cs +++ b/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20/ChaCha20CryptoSF.cs @@ -12,9 +12,4 @@ protected override void UpdateKeyStream() { ChaCha20Utils.UpdateKeyStream(Rounds, State, KeyStream); } - - protected override unsafe void Xor(byte* stream, byte* source, byte* destination, int length) - { - IntrinsicsUtils.Xor(stream, source, destination, length); - } } diff --git a/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20/ChaCha20CryptoX86.cs b/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20/ChaCha20CryptoX86.cs index 782d60e..a9a4385 100644 --- a/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20/ChaCha20CryptoX86.cs +++ b/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20/ChaCha20CryptoX86.cs @@ -49,9 +49,4 @@ protected override unsafe void UpdateKeyStream() ChaCha20Utils.UpdateKeyStream(x, s, Rounds); } } - - protected override unsafe void Xor(byte* stream, byte* source, byte* destination, int length) - { - IntrinsicsUtils.Xor(stream, source, destination, length); - } } diff --git a/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20Original/ChaCha20OriginalCryptoSF.cs b/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20Original/ChaCha20OriginalCryptoSF.cs index 3333e0d..d03f71e 100644 --- a/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20Original/ChaCha20OriginalCryptoSF.cs +++ b/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20Original/ChaCha20OriginalCryptoSF.cs @@ -10,9 +10,4 @@ protected override void UpdateKeyStream() { ChaCha20Utils.UpdateKeyStream(Rounds, State, KeyStream); } - - protected override unsafe void Xor(byte* stream, byte* source, byte* destination, int length) - { - IntrinsicsUtils.Xor(stream, source, destination, length); - } } diff --git a/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20Original/ChaCha20OriginalCryptoX86.cs b/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20Original/ChaCha20OriginalCryptoX86.cs index ea04540..289b072 100644 --- a/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20Original/ChaCha20OriginalCryptoX86.cs +++ b/src/CryptoBase/SymmetricCryptos/StreamCryptos/ChaCha20Original/ChaCha20OriginalCryptoX86.cs @@ -49,9 +49,4 @@ protected override unsafe void UpdateKeyStream() ChaCha20Utils.UpdateKeyStream(x, s, Rounds); } } - - protected override unsafe void Xor(byte* stream, byte* source, byte* destination, int length) - { - IntrinsicsUtils.Xor(stream, source, destination, length); - } } diff --git a/src/CryptoBase/SymmetricCryptos/StreamCryptos/Salsa20/Salsa20CryptoSF.cs b/src/CryptoBase/SymmetricCryptos/StreamCryptos/Salsa20/Salsa20CryptoSF.cs index 5e4b97a..29b925d 100644 --- a/src/CryptoBase/SymmetricCryptos/StreamCryptos/Salsa20/Salsa20CryptoSF.cs +++ b/src/CryptoBase/SymmetricCryptos/StreamCryptos/Salsa20/Salsa20CryptoSF.cs @@ -10,9 +10,4 @@ protected override void UpdateKeyStream() { Salsa20Utils.UpdateKeyStream(Rounds, State, KeyStream); } - - protected override unsafe void Xor(byte* stream, byte* source, byte* destination, int length) - { - IntrinsicsUtils.Xor(stream, source, destination, length); - } } diff --git a/src/CryptoBase/SymmetricCryptos/StreamCryptos/Salsa20/Salsa20CryptoX86.cs b/src/CryptoBase/SymmetricCryptos/StreamCryptos/Salsa20/Salsa20CryptoX86.cs index 2218b62..bf14fd9 100644 --- a/src/CryptoBase/SymmetricCryptos/StreamCryptos/Salsa20/Salsa20CryptoX86.cs +++ b/src/CryptoBase/SymmetricCryptos/StreamCryptos/Salsa20/Salsa20CryptoX86.cs @@ -105,9 +105,4 @@ protected override unsafe void UpdateKeyStream() Salsa20Utils.UpdateKeyStream(x, s, Rounds); } } - - protected override unsafe void Xor(byte* stream, byte* source, byte* destination, int length) - { - IntrinsicsUtils.Xor(stream, source, destination, length); - } } diff --git a/src/CryptoBase/SymmetricCryptos/StreamCryptos/SnuffleCrypto.cs b/src/CryptoBase/SymmetricCryptos/StreamCryptos/SnuffleCrypto.cs index 0aba092..d1f4815 100644 --- a/src/CryptoBase/SymmetricCryptos/StreamCryptos/SnuffleCrypto.cs +++ b/src/CryptoBase/SymmetricCryptos/StreamCryptos/SnuffleCrypto.cs @@ -60,7 +60,7 @@ private unsafe void Update(int length, uint* state, byte* stream, byte* source, } var r = 64 - Index; - Xor(stream + Index, source, destination, Math.Min(r, length)); + IntrinsicsUtils.Xor(stream + Index, source, destination, Math.Min(r, length)); if (length < r) { @@ -78,7 +78,6 @@ private unsafe void Update(int length, uint* state, byte* stream, byte* source, protected abstract unsafe void UpdateBlocks(ref uint* state, ref byte* source, ref byte* destination, ref int length); protected abstract void UpdateKeyStream(); protected abstract unsafe void IncrementCounter(uint* state); - protected abstract unsafe void Xor(byte* stream, byte* source, byte* destination, int length); public override void Dispose() { diff --git a/src/CryptoBase/SymmetricCryptos/StreamCryptos/XChaCha20/XChaCha20CryptoSF.cs b/src/CryptoBase/SymmetricCryptos/StreamCryptos/XChaCha20/XChaCha20CryptoSF.cs index 280ca5f..0f1e8a8 100644 --- a/src/CryptoBase/SymmetricCryptos/StreamCryptos/XChaCha20/XChaCha20CryptoSF.cs +++ b/src/CryptoBase/SymmetricCryptos/StreamCryptos/XChaCha20/XChaCha20CryptoSF.cs @@ -15,9 +15,4 @@ protected override void UpdateKeyStream() { ChaCha20Utils.UpdateKeyStream(Rounds, State, KeyStream); } - - protected override unsafe void Xor(byte* stream, byte* source, byte* destination, int length) - { - IntrinsicsUtils.Xor(stream, source, destination, length); - } } diff --git a/src/CryptoBase/SymmetricCryptos/StreamCryptos/XChaCha20/XChaCha20CryptoX86.cs b/src/CryptoBase/SymmetricCryptos/StreamCryptos/XChaCha20/XChaCha20CryptoX86.cs index 136e6ba..a3d5915 100644 --- a/src/CryptoBase/SymmetricCryptos/StreamCryptos/XChaCha20/XChaCha20CryptoX86.cs +++ b/src/CryptoBase/SymmetricCryptos/StreamCryptos/XChaCha20/XChaCha20CryptoX86.cs @@ -57,9 +57,4 @@ protected override unsafe void UpdateKeyStream() ChaCha20Utils.UpdateKeyStream(x, s, Rounds); } } - - protected override unsafe void Xor(byte* stream, byte* source, byte* destination, int length) - { - IntrinsicsUtils.Xor(stream, source, destination, length); - } } diff --git a/src/CryptoBase/SymmetricCryptos/StreamCryptos/XSalsa20/XSalsa20CryptoSF.cs b/src/CryptoBase/SymmetricCryptos/StreamCryptos/XSalsa20/XSalsa20CryptoSF.cs index f13b331..c72321a 100644 --- a/src/CryptoBase/SymmetricCryptos/StreamCryptos/XSalsa20/XSalsa20CryptoSF.cs +++ b/src/CryptoBase/SymmetricCryptos/StreamCryptos/XSalsa20/XSalsa20CryptoSF.cs @@ -15,9 +15,4 @@ protected override void UpdateKeyStream() { Salsa20Utils.UpdateKeyStream(Rounds, State, KeyStream); } - - protected override unsafe void Xor(byte* stream, byte* source, byte* destination, int length) - { - IntrinsicsUtils.Xor(stream, source, destination, length); - } } diff --git a/src/CryptoBase/SymmetricCryptos/StreamCryptos/XSalsa20/XSalsa20CryptoX86.cs b/src/CryptoBase/SymmetricCryptos/StreamCryptos/XSalsa20/XSalsa20CryptoX86.cs index bcc22be..ca84b08 100644 --- a/src/CryptoBase/SymmetricCryptos/StreamCryptos/XSalsa20/XSalsa20CryptoX86.cs +++ b/src/CryptoBase/SymmetricCryptos/StreamCryptos/XSalsa20/XSalsa20CryptoX86.cs @@ -113,9 +113,4 @@ protected override unsafe void UpdateKeyStream() Salsa20Utils.UpdateKeyStream(x, s, Rounds); } } - - protected override unsafe void Xor(byte* stream, byte* source, byte* destination, int length) - { - IntrinsicsUtils.Xor(stream, source, destination, length); - } }