summary refs log tree commit diff
path: root/crypto/src/math/raw/Bits.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/math/raw/Bits.cs')
-rw-r--r--crypto/src/math/raw/Bits.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/crypto/src/math/raw/Bits.cs b/crypto/src/math/raw/Bits.cs
new file mode 100644
index 000000000..d344e1672
--- /dev/null
+++ b/crypto/src/math/raw/Bits.cs
@@ -0,0 +1,29 @@
+using System;
+
+namespace Org.BouncyCastle.Math.Raw
+{
+    internal abstract class Bits
+    {
+        internal static uint BitPermuteStep(uint x, uint m, int s)
+        {
+            uint t = (x ^ (x >> s)) & m;
+            return (t ^ (t << s)) ^ x;
+        }
+
+        internal static ulong BitPermuteStep(ulong x, ulong m, int s)
+        {
+            ulong t = (x ^ (x >> s)) & m;
+            return (t ^ (t << s)) ^ x;
+        }
+
+        internal static uint BitPermuteStepSimple(uint x, uint m, int s)
+        {
+            return ((x & m) << s) | ((x >> s) & m);
+        }
+
+        internal static ulong BitPermuteStepSimple(ulong x, ulong m, int s)
+        {
+            return ((x & m) << s) | ((x >> s) & m);
+        }
+    }
+}