summary refs log tree commit diff
path: root/crypto/src/util
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-08-07 20:35:20 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-08-07 20:35:20 +0700
commit94a215651b23921043cb3d7d41550ea49dd7a79c (patch)
tree5b498f9b9462f029e9c7616fde43293d1170e93e /crypto/src/util
parentFix Encode return values (diff)
downloadBouncyCastle.NET-ed25519-94a215651b23921043cb3d7d41550ea49dd7a79c.tar.xz
Cleanup after bc-fips-csharp updates
Diffstat (limited to 'crypto/src/util')
-rw-r--r--crypto/src/util/Integers.cs22
-rw-r--r--crypto/src/util/Longs.cs10
2 files changed, 19 insertions, 13 deletions
diff --git a/crypto/src/util/Integers.cs b/crypto/src/util/Integers.cs
index cc46862bd..efa437e17 100644
--- a/crypto/src/util/Integers.cs
+++ b/crypto/src/util/Integers.cs
@@ -37,16 +37,28 @@ namespace Org.BouncyCastle.Utilities
 
         public static int Reverse(int i)
         {
-            i = (int)Bits.BitPermuteStepSimple((uint)i, 0x55555555U, 1);
-            i = (int)Bits.BitPermuteStepSimple((uint)i, 0x33333333U, 2);
-            i = (int)Bits.BitPermuteStepSimple((uint)i, 0x0F0F0F0FU, 4);
+            return (int)Reverse((uint)i);
+        }
+
+        [CLSCompliantAttribute(false)]
+        public static uint Reverse(uint i)
+        {
+            i = Bits.BitPermuteStepSimple(i, 0x55555555U, 1);
+            i = Bits.BitPermuteStepSimple(i, 0x33333333U, 2);
+            i = Bits.BitPermuteStepSimple(i, 0x0F0F0F0FU, 4);
             return ReverseBytes(i);
         }
 
         public static int ReverseBytes(int i)
         {
-            return RotateLeft((int)((uint)i & 0xFF00FF00U),  8) |
-                   RotateLeft((int)((uint)i & 0x00FF00FFU), 24);
+            return (int)ReverseBytes((uint)i);
+        }
+
+        [CLSCompliantAttribute(false)]
+        public static uint ReverseBytes(uint i)
+        {
+            return RotateLeft(i & 0xFF00FF00U,  8) |
+                   RotateLeft(i & 0x00FF00FFU, 24);
         }
 
         public static int RotateLeft(int i, int distance)
diff --git a/crypto/src/util/Longs.cs b/crypto/src/util/Longs.cs
index 66b14b95c..4d675bdba 100644
--- a/crypto/src/util/Longs.cs
+++ b/crypto/src/util/Longs.cs
@@ -35,10 +35,7 @@ namespace Org.BouncyCastle.Utilities
 
         public static long Reverse(long i)
         {
-            i = (long)Bits.BitPermuteStepSimple((ulong)i, 0x5555555555555555UL, 1);
-            i = (long)Bits.BitPermuteStepSimple((ulong)i, 0x3333333333333333UL, 2);
-            i = (long)Bits.BitPermuteStepSimple((ulong)i, 0x0F0F0F0F0F0F0F0FUL, 4);
-            return ReverseBytes(i);
+            return (long)Reverse((ulong)i);
         }
 
         [CLSCompliantAttribute(false)]
@@ -52,10 +49,7 @@ namespace Org.BouncyCastle.Utilities
 
         public static long ReverseBytes(long i)
         {
-            return RotateLeft((long)((ulong)i & 0xFF000000FF000000UL),  8) |
-                   RotateLeft((long)((ulong)i & 0x00FF000000FF0000UL), 24) |
-                   RotateLeft((long)((ulong)i & 0x0000FF000000FF00UL), 40) |
-                   RotateLeft((long)((ulong)i & 0x000000FF000000FFUL), 56);
+            return (long)ReverseBytes((ulong)i);
         }
 
         [CLSCompliantAttribute(false)]