diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2018-10-06 16:44:01 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2018-10-06 16:44:01 +0700 |
commit | f5078e451501d43882308d8322b9c8863e2a2723 (patch) | |
tree | 6fe93ae3363b7a7492e099a363286fee29bc8115 /crypto/src/util/Arrays.cs | |
parent | Fix initialization checks (diff) | |
download | BouncyCastle.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.cs | 10 |
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) |