diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-07-30 15:33:52 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-07-30 15:33:52 +0700 |
commit | e43524058b43fc5c9c2ae63f31376f1bf27b6986 (patch) | |
tree | b96136e2e89e486944cc56bab691cd27ca8c6f5a /crypto/src/math/raw | |
parent | Misc. updates from bc-java (diff) | |
download | BouncyCastle.NET-ed25519-e43524058b43fc5c9c2ae63f31376f1bf27b6986.tar.xz |
For safe primes, use Legendre symbol
- DH public key validation when 'Q' available - In particular, greatly speeds up TLS FFDHE groups
Diffstat (limited to 'crypto/src/math/raw')
-rw-r--r-- | crypto/src/math/raw/Nat.cs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/crypto/src/math/raw/Nat.cs b/crypto/src/math/raw/Nat.cs index 8ec328d11..69942661f 100644 --- a/crypto/src/math/raw/Nat.cs +++ b/crypto/src/math/raw/Nat.cs @@ -278,6 +278,34 @@ namespace Org.BouncyCastle.Math.Raw //} } + public static int Compare(int len, uint[] x, uint[] y) + { + for (int i = len - 1; i >= 0; --i) + { + uint x_i = x[i]; + uint y_i = y[i]; + if (x_i < y_i) + return -1; + if (x_i > y_i) + return 1; + } + return 0; + } + + public static int Compare(int len, uint[] x, int xOff, uint[] y, int yOff) + { + for (int i = len - 1; i >= 0; --i) + { + uint x_i = x[xOff + i]; + uint y_i = y[yOff + i]; + if (x_i < y_i) + return -1; + if (x_i > y_i) + return 1; + } + return 0; + } + public static void Copy(int len, uint[] x, uint[] z) { Array.Copy(x, 0, z, 0, len); |