summary refs log tree commit diff
path: root/crypto/src/math
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-03-01 17:20:21 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-03-01 17:20:21 +0700
commit4de18964f35fc169cb94058dcfe2e1ccb59b2524 (patch)
tree289c3b209782ce0af94f5bf0362a68b3e3764ec2 /crypto/src/math
parentBIKE init perf. opts. (diff)
downloadBouncyCastle.NET-ed25519-4de18964f35fc169cb94058dcfe2e1ccb59b2524.tar.xz
Add Integers.PopCount
Diffstat (limited to 'crypto/src/math')
-rw-r--r--crypto/src/math/BigInteger.cs17
1 files changed, 1 insertions, 16 deletions
diff --git a/crypto/src/math/BigInteger.cs b/crypto/src/math/BigInteger.cs
index 5b2ea0d87..d84680de5 100644
--- a/crypto/src/math/BigInteger.cs
+++ b/crypto/src/math/BigInteger.cs
@@ -942,7 +942,7 @@ namespace Org.BouncyCastle.Math
                         int sum = 0;
                         for (int i = 0; i < magnitude.Length; ++i)
                         {
-                            sum += BitCnt(magnitude[i]);
+                            sum += Integers.PopCount(magnitude[i]);
                         }
                         nBits = sum;
                     }
@@ -952,21 +952,6 @@ namespace Org.BouncyCastle.Math
             }
         }
 
-        internal static int BitCnt(uint u)
-        {
-#if NETCOREAPP3_0_OR_GREATER
-            return BitOperations.PopCount(u);
-#else
-            u = u - ((u >> 1) & 0x55555555);
-            u = (u & 0x33333333) + ((u >> 2) & 0x33333333);
-            u = (u + (u >> 4)) & 0x0f0f0f0f;
-            u += (u >> 8);
-            u += (u >> 16);
-            u &= 0x3f;
-            return (int)u;
-#endif
-        }
-
         private static int CalcBitLength(int sign, int indx, uint[]	mag)
         {
             for (;;)