summary refs log tree commit diff
path: root/crypto/src/math/raw
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-07-19 18:04:59 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-07-19 18:04:59 +0700
commitf58628a8b4264239dbb51f2f726701cf80804689 (patch)
tree82b5e7509d2206beacd4ec6b3e64c0927cb6663b /crypto/src/math/raw
parentRun tests with netcoreapp2.1 (diff)
downloadBouncyCastle.NET-ed25519-f58628a8b4264239dbb51f2f726701cf80804689.tar.xz
Small GCM squaring perf. opts.
Diffstat (limited to 'crypto/src/math/raw')
-rw-r--r--crypto/src/math/raw/Interleave.cs11
1 files changed, 5 insertions, 6 deletions
diff --git a/crypto/src/math/raw/Interleave.cs b/crypto/src/math/raw/Interleave.cs
index a71b4a1b8..f22177fe8 100644
--- a/crypto/src/math/raw/Interleave.cs
+++ b/crypto/src/math/raw/Interleave.cs
@@ -90,14 +90,13 @@ namespace Org.BouncyCastle.Math.Raw
             }
         }
 
-        internal static void Expand64To128Rev(ulong x, ulong[] z, int zOff)
+        internal static ulong Expand64To128Rev(ulong x, out ulong low)
         {
 #if NETCOREAPP3_0_OR_GREATER
             if (Bmi2.X64.IsSupported)
             {
-                z[zOff    ] = Bmi2.X64.ParallelBitDeposit(x >> 32, 0xAAAAAAAAAAAAAAAAUL);
-                z[zOff + 1] = Bmi2.X64.ParallelBitDeposit(x      , 0xAAAAAAAAAAAAAAAAUL);
-                return;
+                low  = Bmi2.X64.ParallelBitDeposit(x >> 32, 0xAAAAAAAAAAAAAAAAUL);
+                return Bmi2.X64.ParallelBitDeposit(x, 0xAAAAAAAAAAAAAAAAUL);
             }
 #endif
 
@@ -108,8 +107,8 @@ namespace Org.BouncyCastle.Math.Raw
             x = Bits.BitPermuteStep(x, 0x0C0C0C0C0C0C0C0CUL, 2);
             x = Bits.BitPermuteStep(x, 0x2222222222222222UL, 1);
 
-            z[zOff    ] = (x     ) & M64R;
-            z[zOff + 1] = (x << 1) & M64R;
+            low  = (x     ) & M64R;
+            return (x << 1) & M64R;
         }
 
         internal static uint Shuffle(uint x)