summary refs log tree commit diff
path: root/crypto/src/util/Arrays.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2018-10-06 16:44:01 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2018-10-06 16:44:01 +0700
commitf5078e451501d43882308d8322b9c8863e2a2723 (patch)
tree6fe93ae3363b7a7492e099a363286fee29bc8115 /crypto/src/util/Arrays.cs
parentFix initialization checks (diff)
downloadBouncyCastle.NET-ed25519-f5078e451501d43882308d8322b9c8863e2a2723.tar.xz
RFC 7748: Exclude all-zeroes agreement value
Diffstat (limited to 'crypto/src/util/Arrays.cs')
-rw-r--r--crypto/src/util/Arrays.cs10
1 files changed, 10 insertions, 0 deletions
diff --git a/crypto/src/util/Arrays.cs b/crypto/src/util/Arrays.cs
index 3df908240..a9a574dbf 100644
--- a/crypto/src/util/Arrays.cs
+++ b/crypto/src/util/Arrays.cs
@@ -11,6 +11,16 @@ namespace Org.BouncyCastle.Utilities
         public static readonly byte[] EmptyBytes = new byte[0];
         public static readonly int[] EmptyInts = new int[0];
 
+        public static bool AreAllZeroes(byte[] buf, int off, int len)
+        {
+            uint bits = 0;
+            for (int i = 0; i < len; ++i)
+            {
+                bits |= buf[off + i];
+            }
+            return bits == 0;
+        }
+
         public static bool AreEqual(
             bool[]  a,
             bool[]  b)