diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-07-18 14:04:40 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-07-18 14:04:40 +0700 |
commit | 2a27035daa92bb2fc1c89914481db58e9336d35e (patch) | |
tree | 84737dbc459344c32878722e1787fe097e766f62 /crypto/src/math/raw/Interleave.cs | |
parent | LongArray cleanup and refactoring (diff) | |
download | BouncyCastle.NET-ed25519-2a27035daa92bb2fc1c89914481db58e9336d35e.tar.xz |
Factor out Unshuffle methods
Diffstat (limited to 'crypto/src/math/raw/Interleave.cs')
-rw-r--r-- | crypto/src/math/raw/Interleave.cs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crypto/src/math/raw/Interleave.cs b/crypto/src/math/raw/Interleave.cs index 4d866c245..409ab83e8 100644 --- a/crypto/src/math/raw/Interleave.cs +++ b/crypto/src/math/raw/Interleave.cs @@ -135,6 +135,21 @@ namespace Org.BouncyCastle.Math.Raw return x; } + internal static ulong Unshuffle(ulong x, out ulong even) + { + ulong u0 = Unshuffle(x); + even = u0 & 0x00000000FFFFFFFFUL; + return u0 >> 32; + } + + internal static ulong Unshuffle(ulong x0, ulong x1, out ulong even) + { + ulong u0 = Unshuffle(x0); + ulong u1 = Unshuffle(x1); + even = (u1 << 32) | (u0 & 0x00000000FFFFFFFFUL); + return (u0 >> 32) | (u1 & 0xFFFFFFFF00000000UL); + } + internal static uint Unshuffle2(uint x) { // "unshuffle" (twice) even bits to low half and odd bits to high half |