diff --git a/src/LibHac/Common/SpanHelpers.cs b/src/LibHac/Common/SpanHelpers.cs index aee202ff..aef00193 100644 --- a/src/LibHac/Common/SpanHelpers.cs +++ b/src/LibHac/Common/SpanHelpers.cs @@ -1,6 +1,9 @@ using System; using System.Runtime.CompilerServices; + +#if NETCOREAPP using System.Runtime.InteropServices; +#endif namespace LibHac.Common { diff --git a/src/LibHac/Crypto2/Aes.cs b/src/LibHac/Crypto2/Aes.cs index 47129638..d985ec3c 100644 --- a/src/LibHac/Crypto2/Aes.cs +++ b/src/LibHac/Crypto2/Aes.cs @@ -1,7 +1,9 @@ -using System; +// ReSharper disable AssignmentIsFullyDiscarded +using System; #if HAS_INTRINSICS using System.Runtime.Intrinsics.X86; +using LibHac.Crypto2.Detail; #endif namespace LibHac.Crypto2 @@ -25,7 +27,7 @@ namespace LibHac.Crypto2 #if HAS_INTRINSICS if (IsAesNiSupported() && !preferDotNetCrypto) { - return new AesEcbDecryptorHw(key); + return new AesEcbDecryptorNi(key); } #endif return new AesEcbDecryptor(key); @@ -36,7 +38,7 @@ namespace LibHac.Crypto2 #if HAS_INTRINSICS if (IsAesNiSupported() && !preferDotNetCrypto) { - return new AesEcbEncryptorHw(key); + return new AesEcbEncryptorNi(key); } #endif return new AesEcbEncryptor(key); @@ -47,7 +49,7 @@ namespace LibHac.Crypto2 #if HAS_INTRINSICS if (IsAesNiSupported() && !preferDotNetCrypto) { - return new AesCbcDecryptorHw(key, iv); + return new AesCbcDecryptorNi(key, iv); } #endif return new AesCbcDecryptor(key, iv); @@ -58,7 +60,7 @@ namespace LibHac.Crypto2 #if HAS_INTRINSICS if (IsAesNiSupported() && !preferDotNetCrypto) { - return new AesCbcEncryptorHw(key, iv); + return new AesCbcEncryptorNi(key, iv); } #endif return new AesCbcEncryptor(key, iv); @@ -66,6 +68,12 @@ namespace LibHac.Crypto2 public static ICipher CreateCtrDecryptor(ReadOnlySpan key, ReadOnlySpan iv, bool preferDotNetCrypto = false) { +#if HAS_INTRINSICS + if (IsAesNiSupported() && !preferDotNetCrypto) + { + return new AesCtrCipherNi(key, iv); + } +#endif // Encryption and decryption in counter mode is the same operation return CreateCtrEncryptor(key, iv, preferDotNetCrypto); } @@ -75,7 +83,7 @@ namespace LibHac.Crypto2 #if HAS_INTRINSICS if (IsAesNiSupported() && !preferDotNetCrypto) { - return new AesCtrEncryptorHw(key, iv); + return new AesCtrCipherNi(key, iv); } #endif return new AesCtrEncryptor(key, iv); @@ -87,7 +95,7 @@ namespace LibHac.Crypto2 #if HAS_INTRINSICS if (IsAesNiSupported() && !preferDotNetCrypto) { - return new AesXtsCipherHw(key1, key2, iv, true); + return new AesXtsDecryptorNi(key1, key2, iv); } #endif return new AesXtsCipher(key1, key2, iv, true); @@ -99,7 +107,7 @@ namespace LibHac.Crypto2 #if HAS_INTRINSICS if (IsAesNiSupported() && !preferDotNetCrypto) { - return new AesXtsCipherHw(key1, key2, iv, false); + return new AesXtsEncryptorNi(key1, key2, iv); } #endif return new AesXtsCipher(key1, key2, iv, false); @@ -108,6 +116,17 @@ namespace LibHac.Crypto2 public static void EncryptEcb128(ReadOnlySpan input, Span output, ReadOnlySpan key, bool preferDotNetCrypto = false) { +#if HAS_INTRINSICS + if (IsAesNiSupported() && !preferDotNetCrypto) + { + AesEcbModeNi cipherNi; + unsafe { _ = &cipherNi; } // workaround for CS0165 + + cipherNi.Initialize(key, false); + cipherNi.Encrypt(input, output); + return; + } +#endif ICipher cipher = CreateEcbEncryptor(key, preferDotNetCrypto); cipher.Transform(input, output); @@ -116,6 +135,17 @@ namespace LibHac.Crypto2 public static void DecryptEcb128(ReadOnlySpan input, Span output, ReadOnlySpan key, bool preferDotNetCrypto = false) { +#if HAS_INTRINSICS + if (IsAesNiSupported() && !preferDotNetCrypto) + { + AesEcbModeNi cipherNi; + unsafe { _ = &cipherNi; } // workaround for CS0165 + + cipherNi.Initialize(key, true); + cipherNi.Decrypt(input, output); + return; + } +#endif ICipher cipher = CreateEcbDecryptor(key, preferDotNetCrypto); cipher.Transform(input, output); @@ -124,6 +154,17 @@ namespace LibHac.Crypto2 public static void EncryptCbc128(ReadOnlySpan input, Span output, ReadOnlySpan key, ReadOnlySpan iv, bool preferDotNetCrypto = false) { +#if HAS_INTRINSICS + if (IsAesNiSupported() && !preferDotNetCrypto) + { + AesCbcModeNi cipherNi; + unsafe { _ = &cipherNi; } // workaround for CS0165 + + cipherNi.Initialize(key, iv, false); + cipherNi.Encrypt(input, output); + return; + } +#endif ICipher cipher = CreateCbcEncryptor(key, iv, preferDotNetCrypto); cipher.Transform(input, output); @@ -132,6 +173,17 @@ namespace LibHac.Crypto2 public static void DecryptCbc128(ReadOnlySpan input, Span output, ReadOnlySpan key, ReadOnlySpan iv, bool preferDotNetCrypto = false) { +#if HAS_INTRINSICS + if (IsAesNiSupported() && !preferDotNetCrypto) + { + AesCbcModeNi cipherNi; + unsafe { _ = &cipherNi; } // workaround for CS0165 + + cipherNi.Initialize(key, iv, true); + cipherNi.Decrypt(input, output); + return; + } +#endif ICipher cipher = CreateCbcDecryptor(key, iv, preferDotNetCrypto); cipher.Transform(input, output); @@ -140,6 +192,17 @@ namespace LibHac.Crypto2 public static void EncryptCtr128(ReadOnlySpan input, Span output, ReadOnlySpan key, ReadOnlySpan iv, bool preferDotNetCrypto = false) { +#if HAS_INTRINSICS + if (IsAesNiSupported() && !preferDotNetCrypto) + { + AesCtrModeNi cipherNi; + unsafe { _ = &cipherNi; } // workaround for CS0165 + + cipherNi.Initialize(key, iv); + cipherNi.Transform(input, output); + return; + } +#endif ICipher cipher = CreateCtrEncryptor(key, iv, preferDotNetCrypto); cipher.Transform(input, output); @@ -148,6 +211,17 @@ namespace LibHac.Crypto2 public static void DecryptCtr128(ReadOnlySpan input, Span output, ReadOnlySpan key, ReadOnlySpan iv, bool preferDotNetCrypto = false) { +#if HAS_INTRINSICS + if (IsAesNiSupported() && !preferDotNetCrypto) + { + AesCtrModeNi cipherNi; + unsafe { _ = &cipherNi; } // workaround for CS0165 + + cipherNi.Initialize(key, iv); + cipherNi.Transform(input, output); + return; + } +#endif ICipher cipher = CreateCtrDecryptor(key, iv, preferDotNetCrypto); cipher.Transform(input, output); @@ -156,6 +230,17 @@ namespace LibHac.Crypto2 public static void EncryptXts128(ReadOnlySpan input, Span output, ReadOnlySpan key1, ReadOnlySpan key2, ReadOnlySpan iv, bool preferDotNetCrypto = false) { +#if HAS_INTRINSICS + if (IsAesNiSupported() && !preferDotNetCrypto) + { + AesXtsModeNi cipherNi; + unsafe { _ = &cipherNi; } // workaround for CS0165 + + cipherNi.Initialize(key1, key2, iv, false); + cipherNi.Encrypt(input, output); + return; + } +#endif ICipher cipher = CreateXtsEncryptor(key1, key2, iv, preferDotNetCrypto); cipher.Transform(input, output); @@ -164,6 +249,17 @@ namespace LibHac.Crypto2 public static void DecryptXts128(ReadOnlySpan input, Span output, ReadOnlySpan key1, ReadOnlySpan key2, ReadOnlySpan iv, bool preferDotNetCrypto = false) { +#if HAS_INTRINSICS + if (IsAesNiSupported() && !preferDotNetCrypto) + { + AesXtsModeNi cipherNi; + unsafe { _ = &cipherNi; } // workaround for CS0165 + + cipherNi.Initialize(key1, key2, iv, true); + cipherNi.Decrypt(input, output); + return; + } +#endif ICipher cipher = CreateXtsDecryptor(key1, key2, iv, preferDotNetCrypto); cipher.Transform(input, output); diff --git a/src/LibHac/Crypto2/AesCbcMode.cs b/src/LibHac/Crypto2/AesCbcCipher.cs similarity index 100% rename from src/LibHac/Crypto2/AesCbcMode.cs rename to src/LibHac/Crypto2/AesCbcCipher.cs diff --git a/src/LibHac/Crypto2/AesCbcCipherNi.cs b/src/LibHac/Crypto2/AesCbcCipherNi.cs new file mode 100644 index 00000000..9166329e --- /dev/null +++ b/src/LibHac/Crypto2/AesCbcCipherNi.cs @@ -0,0 +1,39 @@ +#if HAS_INTRINSICS +using System; +using LibHac.Crypto2.Detail; + +namespace LibHac.Crypto2 +{ + public struct AesCbcEncryptorNi : ICipher + { + private AesCbcModeNi _baseCipher; + + public AesCbcEncryptorNi(ReadOnlySpan key, ReadOnlySpan iv) + { + _baseCipher = new AesCbcModeNi(); + _baseCipher.Initialize(key, iv, false); + } + + public void Transform(ReadOnlySpan input, Span output) + { + _baseCipher.Encrypt(input, output); + } + } + + public struct AesCbcDecryptorNi : ICipher + { + private AesCbcModeNi _baseCipher; + + public AesCbcDecryptorNi(ReadOnlySpan key, ReadOnlySpan iv) + { + _baseCipher = new AesCbcModeNi(); + _baseCipher.Initialize(key, iv, true); + } + + public void Transform(ReadOnlySpan input, Span output) + { + _baseCipher.Decrypt(input, output); + } + } +} +#endif \ No newline at end of file diff --git a/src/LibHac/Crypto2/AesCtrMode.cs b/src/LibHac/Crypto2/AesCtrCipher.cs similarity index 100% rename from src/LibHac/Crypto2/AesCtrMode.cs rename to src/LibHac/Crypto2/AesCtrCipher.cs diff --git a/src/LibHac/Crypto2/AesCtrCipherNi.cs b/src/LibHac/Crypto2/AesCtrCipherNi.cs new file mode 100644 index 00000000..99a0c17d --- /dev/null +++ b/src/LibHac/Crypto2/AesCtrCipherNi.cs @@ -0,0 +1,23 @@ +#if HAS_INTRINSICS +using System; +using LibHac.Crypto2.Detail; + +namespace LibHac.Crypto2 +{ + public class AesCtrCipherNi : ICipher + { + private AesCtrModeNi _baseCipher; + + public AesCtrCipherNi(ReadOnlySpan key, ReadOnlySpan iv) + { + _baseCipher = new AesCtrModeNi(); + _baseCipher.Initialize(key, iv); + } + + public void Transform(ReadOnlySpan input, Span output) + { + _baseCipher.Transform(input, output); + } + } +} +#endif diff --git a/src/LibHac/Crypto2/AesEcbMode.cs b/src/LibHac/Crypto2/AesEcbCipher.cs similarity index 100% rename from src/LibHac/Crypto2/AesEcbMode.cs rename to src/LibHac/Crypto2/AesEcbCipher.cs diff --git a/src/LibHac/Crypto2/AesEcbCipherNi.cs b/src/LibHac/Crypto2/AesEcbCipherNi.cs new file mode 100644 index 00000000..16e5ff16 --- /dev/null +++ b/src/LibHac/Crypto2/AesEcbCipherNi.cs @@ -0,0 +1,39 @@ +#if HAS_INTRINSICS +using System; +using LibHac.Crypto2.Detail; + +namespace LibHac.Crypto2 +{ + public class AesEcbEncryptorNi : ICipher + { + private AesEcbModeNi _baseCipher; + + public AesEcbEncryptorNi(ReadOnlySpan key) + { + _baseCipher = new AesEcbModeNi(); + _baseCipher.Initialize(key, false); + } + + public void Transform(ReadOnlySpan input, Span output) + { + _baseCipher.Encrypt(input, output); + } + } + + public class AesEcbDecryptorNi : ICipher + { + private AesEcbModeNi _baseCipher; + + public AesEcbDecryptorNi(ReadOnlySpan key) + { + _baseCipher = new AesEcbModeNi(); + _baseCipher.Initialize(key, true); + } + + public void Transform(ReadOnlySpan input, Span output) + { + _baseCipher.Decrypt(input, output); + } + } +} +#endif diff --git a/src/LibHac/Crypto2/AesEcbModeHw.cs b/src/LibHac/Crypto2/AesEcbModeHw.cs deleted file mode 100644 index c673e9b9..00000000 --- a/src/LibHac/Crypto2/AesEcbModeHw.cs +++ /dev/null @@ -1,38 +0,0 @@ -#if HAS_INTRINSICS -using System; - -namespace LibHac.Crypto2 -{ - public class AesEcbEncryptorHw : ICipher - { - private AesCoreNi _aesCore; - - public AesEcbEncryptorHw(ReadOnlySpan key) - { - _aesCore = new AesCoreNi(); - _aesCore.Initialize(key, false); - } - - public void Transform(ReadOnlySpan input, Span output) - { - _aesCore.Encrypt(input, output); - } - } - - public class AesEcbDecryptorHw : ICipher - { - private AesCoreNi _aesCore; - - public AesEcbDecryptorHw(ReadOnlySpan key) - { - _aesCore = new AesCoreNi(); - _aesCore.Initialize(key, true); - } - - public void Transform(ReadOnlySpan input, Span output) - { - _aesCore.Decrypt(input, output); - } - } -} -#endif diff --git a/src/LibHac/Crypto2/AesXtsMode.cs b/src/LibHac/Crypto2/AesXtsCipher.cs similarity index 100% rename from src/LibHac/Crypto2/AesXtsMode.cs rename to src/LibHac/Crypto2/AesXtsCipher.cs diff --git a/src/LibHac/Crypto2/AesXtsCipherNi.cs b/src/LibHac/Crypto2/AesXtsCipherNi.cs new file mode 100644 index 00000000..b53a8b1f --- /dev/null +++ b/src/LibHac/Crypto2/AesXtsCipherNi.cs @@ -0,0 +1,39 @@ +#if HAS_INTRINSICS +using System; +using LibHac.Crypto2.Detail; + +namespace LibHac.Crypto2 +{ + public class AesXtsEncryptorNi : ICipher + { + private AesXtsModeNi _baseCipher; + + public AesXtsEncryptorNi(ReadOnlySpan key1, ReadOnlySpan key2, ReadOnlySpan iv) + { + _baseCipher = new AesXtsModeNi(); + _baseCipher.Initialize(key1, key2, iv, false); + } + + public void Transform(ReadOnlySpan input, Span output) + { + _baseCipher.Encrypt(input, output); + } + } + + public class AesXtsDecryptorNi : ICipher + { + private AesXtsModeNi _baseCipher; + + public AesXtsDecryptorNi(ReadOnlySpan key1, ReadOnlySpan key2, ReadOnlySpan iv) + { + _baseCipher = new AesXtsModeNi(); + _baseCipher.Initialize(key1, key2, iv, true); + } + + public void Transform(ReadOnlySpan input, Span output) + { + _baseCipher.Decrypt(input, output); + } + } +} +#endif diff --git a/src/LibHac/Crypto2/AesCbcModeHw.cs b/src/LibHac/Crypto2/Detail/AesCbcModeNi.cs similarity index 63% rename from src/LibHac/Crypto2/AesCbcModeHw.cs rename to src/LibHac/Crypto2/Detail/AesCbcModeNi.cs index 4735befd..6f9c0bf7 100644 --- a/src/LibHac/Crypto2/AesCbcModeHw.cs +++ b/src/LibHac/Crypto2/Detail/AesCbcModeNi.cs @@ -1,28 +1,28 @@ #if HAS_INTRINSICS using System; -using System.Runtime.InteropServices; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; -namespace LibHac.Crypto2 +namespace LibHac.Crypto2.Detail { - public struct AesCbcEncryptorHw : ICipher + public struct AesCbcModeNi { +#pragma warning disable 649 private AesCoreNi _aesCore; +#pragma warning restore 649 + private Vector128 _iv; - [MethodImpl(MethodImplOptions.AggressiveOptimization)] - public AesCbcEncryptorHw(ReadOnlySpan key, ReadOnlySpan iv) + public void Initialize(ReadOnlySpan key, ReadOnlySpan iv, bool isDecrypting) { - _aesCore = new AesCoreNi(); - _aesCore.Initialize(key, false); + _aesCore.Initialize(key, isDecrypting); _iv = Unsafe.ReadUnaligned>(ref MemoryMarshal.GetReference(iv)); } - [MethodImpl(MethodImplOptions.AggressiveOptimization)] - public void Transform(ReadOnlySpan input, Span output) + public void Encrypt(ReadOnlySpan input, Span output) { int blockCount = Math.Min(input.Length, output.Length) >> 4; @@ -43,24 +43,8 @@ namespace LibHac.Crypto2 _iv = iv; } - } - public struct AesCbcDecryptorHw : ICipher - { - private AesCoreNi _aesCore; - private Vector128 _iv; - - [MethodImpl(MethodImplOptions.AggressiveOptimization)] - public AesCbcDecryptorHw(ReadOnlySpan key, ReadOnlySpan iv) - { - _aesCore = new AesCoreNi(); - _aesCore.Initialize(key, true); - - _iv = Unsafe.ReadUnaligned>(ref MemoryMarshal.GetReference(iv)); - } - - [MethodImpl(MethodImplOptions.AggressiveOptimization)] - public void Transform(ReadOnlySpan input, Span output) + public void Decrypt(ReadOnlySpan input, Span output) { int blockCount = Math.Min(input.Length, output.Length) >> 4; @@ -84,4 +68,4 @@ namespace LibHac.Crypto2 } } } -#endif \ No newline at end of file +#endif diff --git a/src/LibHac/Crypto2/AesCoreNi.cs b/src/LibHac/Crypto2/Detail/AesCoreNi.cs similarity index 95% rename from src/LibHac/Crypto2/AesCoreNi.cs rename to src/LibHac/Crypto2/Detail/AesCoreNi.cs index 04b95f1b..2d2a82ae 100644 --- a/src/LibHac/Crypto2/AesCoreNi.cs +++ b/src/LibHac/Crypto2/Detail/AesCoreNi.cs @@ -1,11 +1,11 @@ #if NETCOREAPP -using System; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using System; +using System.Runtime.CompilerServices; -namespace LibHac.Crypto2 +namespace LibHac.Crypto2.Detail { [StructLayout(LayoutKind.Sequential, Size = RoundKeyCount * RoundKeySize)] public struct AesCoreNi @@ -15,13 +15,6 @@ namespace LibHac.Crypto2 private Vector128 _roundKeys; - public AesCoreNi(ReadOnlySpan key, bool isDecrypting) - { - _roundKeys = default; - - KeyExpansion(key, MemoryMarshal.CreateSpan(ref _roundKeys, RoundKeyCount), isDecrypting); - } - public void Initialize(ReadOnlySpan key, bool isDecrypting) { KeyExpansion(key, MemoryMarshal.CreateSpan(ref _roundKeys, RoundKeyCount), isDecrypting); @@ -30,7 +23,6 @@ namespace LibHac.Crypto2 public readonly ReadOnlySpan> RoundKeys => MemoryMarshal.CreateReadOnlySpan(ref Unsafe.AsRef(in _roundKeys), RoundKeyCount); - [MethodImpl(MethodImplOptions.AggressiveOptimization)] public readonly void Encrypt(ReadOnlySpan input, Span output) { diff --git a/src/LibHac/Crypto2/AesCtrModeHw.cs b/src/LibHac/Crypto2/Detail/AesCtrModeNi.cs similarity index 90% rename from src/LibHac/Crypto2/AesCtrModeHw.cs rename to src/LibHac/Crypto2/Detail/AesCtrModeNi.cs index f5e57ad1..b7638698 100644 --- a/src/LibHac/Crypto2/AesCtrModeHw.cs +++ b/src/LibHac/Crypto2/Detail/AesCtrModeNi.cs @@ -5,17 +5,18 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; -namespace LibHac.Crypto2 +namespace LibHac.Crypto2.Detail { - public class AesCtrEncryptorHw : ICipher + public struct AesCtrModeNi { +#pragma warning disable 649 private AesCoreNi _aesCore; +#pragma warning restore 649 + private Vector128 _iv; - [MethodImpl(MethodImplOptions.AggressiveOptimization)] - public AesCtrEncryptorHw(ReadOnlySpan key, ReadOnlySpan iv) + public void Initialize(ReadOnlySpan key, ReadOnlySpan iv) { - _aesCore = new AesCoreNi(); _aesCore.Initialize(key, false); _iv = Unsafe.ReadUnaligned>(ref MemoryMarshal.GetReference(iv)); diff --git a/src/LibHac/Crypto2/Detail/AesEcbModeNi.cs b/src/LibHac/Crypto2/Detail/AesEcbModeNi.cs new file mode 100644 index 00000000..90b066ac --- /dev/null +++ b/src/LibHac/Crypto2/Detail/AesEcbModeNi.cs @@ -0,0 +1,28 @@ +#if HAS_INTRINSICS +using System; + +namespace LibHac.Crypto2.Detail +{ + public struct AesEcbModeNi + { +#pragma warning disable 649 + private AesCoreNi _aesCore; +#pragma warning restore 649 + + public void Initialize(ReadOnlySpan key, bool isDecrypting) + { + _aesCore.Initialize(key, isDecrypting); + } + + public void Encrypt(ReadOnlySpan input, Span output) + { + _aesCore.Encrypt(input, output); + } + + public void Decrypt(ReadOnlySpan input, Span output) + { + _aesCore.Decrypt(input, output); + } + } +} +#endif diff --git a/src/LibHac/Crypto2/AesXtsModeHw.cs b/src/LibHac/Crypto2/Detail/AesXtsModeNi.cs similarity index 90% rename from src/LibHac/Crypto2/AesXtsModeHw.cs rename to src/LibHac/Crypto2/Detail/AesXtsModeNi.cs index 1a67d077..479c46a9 100644 --- a/src/LibHac/Crypto2/AesXtsModeHw.cs +++ b/src/LibHac/Crypto2/Detail/AesXtsModeNi.cs @@ -7,30 +7,27 @@ using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; using LibHac.Common; -namespace LibHac.Crypto2 +namespace LibHac.Crypto2.Detail { - public class AesXtsCipherHw : ICipher + public struct AesXtsModeNi { +#pragma warning disable 649 private AesCoreNi _dataAesCore; private AesCoreNi _tweakAesCore; - private Vector128 _iv; - private bool _decrypting; +#pragma warning restore 649 - public AesXtsCipherHw(ReadOnlySpan key1, ReadOnlySpan key2, ReadOnlySpan iv, bool decrypting) + private Vector128 _iv; + + public void Initialize(ReadOnlySpan key1, ReadOnlySpan key2, ReadOnlySpan iv, bool decrypting) { Debug.Assert(key1.Length == AesCrypto.KeySize128); Debug.Assert(key2.Length == AesCrypto.KeySize128); Debug.Assert(iv.Length == AesCrypto.KeySize128); - _dataAesCore = new AesCoreNi(); _dataAesCore.Initialize(key1, decrypting); - - _tweakAesCore = new AesCoreNi(); _tweakAesCore.Initialize(key2, false); _iv = Unsafe.ReadUnaligned>(ref MemoryMarshal.GetReference(iv)); - - _decrypting = decrypting; } public void Encrypt(ReadOnlySpan input, Span output) @@ -158,18 +155,6 @@ namespace LibHac.Crypto2 prevOutBlock = Sse2.Xor(tmp, tweak); } - public void Transform(ReadOnlySpan input, Span output) - { - if (_decrypting) - { - Decrypt(input, output); - } - else - { - Encrypt(input, output); - } - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector128 Gf128Mul(Vector128 iv, Vector128 mask) {