From 1e3d65331924ac2cea24155266a1caa9e4ffdbfb Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Fri, 10 Feb 2023 17:29:43 +0700 Subject: Refactor Haraka --- crypto/src/crypto/digests/Haraka256_X86.cs | 8 ++++---- crypto/src/crypto/digests/Haraka512_X86.cs | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crypto/src/crypto/digests/Haraka256_X86.cs b/crypto/src/crypto/digests/Haraka256_X86.cs index 4c9a798c0..51642a65b 100644 --- a/crypto/src/crypto/digests/Haraka256_X86.cs +++ b/crypto/src/crypto/digests/Haraka256_X86.cs @@ -98,11 +98,11 @@ namespace Org.BouncyCastle.Crypto.Digests [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void ImplAes(ref Vector128 s0, ref Vector128 s1, ReadOnlySpan> rc) { - s0 = Aes.Encrypt(s0, rc[0]); - s1 = Aes.Encrypt(s1, rc[1]); + var t0 = Aes.Encrypt(s0, rc[0]); + var t1 = Aes.Encrypt(s1, rc[1]); - s0 = Aes.Encrypt(s0, rc[2]); - s1 = Aes.Encrypt(s1, rc[3]); + s0 = Aes.Encrypt(t0, rc[2]); + s1 = Aes.Encrypt(t1, rc[3]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/crypto/src/crypto/digests/Haraka512_X86.cs b/crypto/src/crypto/digests/Haraka512_X86.cs index 6dcd3e782..fb979ab48 100644 --- a/crypto/src/crypto/digests/Haraka512_X86.cs +++ b/crypto/src/crypto/digests/Haraka512_X86.cs @@ -166,15 +166,15 @@ namespace Org.BouncyCastle.Crypto.Digests private static void ImplAes(ref Vector128 s0, ref Vector128 s1, ref Vector128 s2, ref Vector128 s3, ReadOnlySpan> rc) { - s0 = Aes.Encrypt(s0, rc[0]); - s1 = Aes.Encrypt(s1, rc[1]); - s2 = Aes.Encrypt(s2, rc[2]); - s3 = Aes.Encrypt(s3, rc[3]); - - s0 = Aes.Encrypt(s0, rc[4]); - s1 = Aes.Encrypt(s1, rc[5]); - s2 = Aes.Encrypt(s2, rc[6]); - s3 = Aes.Encrypt(s3, rc[7]); + var t0 = Aes.Encrypt(s0, rc[0]); + var t1 = Aes.Encrypt(s1, rc[1]); + var t2 = Aes.Encrypt(s2, rc[2]); + var t3 = Aes.Encrypt(s3, rc[3]); + + s0 = Aes.Encrypt(t0, rc[4]); + s1 = Aes.Encrypt(t1, rc[5]); + s2 = Aes.Encrypt(t2, rc[6]); + s3 = Aes.Encrypt(t3, rc[7]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] -- cgit 1.4.1