diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-07-23 15:17:12 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-07-23 15:17:12 +0700 |
commit | 6e306046568f9a4d13639b913f0ff6d5879fa165 (patch) | |
tree | 994b8711674bb146ff578c1f0dff649282962acb /crypto/test/src/math | |
parent | Update encrypt_then_mac entry (diff) | |
download | BouncyCastle.NET-ed25519-6e306046568f9a4d13639b913f0ff6d5879fa165.tar.xz |
Add automatic EC point validation for decoded points and for multiplier outputs
Diffstat (limited to 'crypto/test/src/math')
-rw-r--r-- | crypto/test/src/math/ec/test/ECPointTest.cs | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/crypto/test/src/math/ec/test/ECPointTest.cs b/crypto/test/src/math/ec/test/ECPointTest.cs index 1a23e0bc7..8430f437d 100644 --- a/crypto/test/src/math/ec/test/ECPointTest.cs +++ b/crypto/test/src/math/ec/test/ECPointTest.cs @@ -288,35 +288,6 @@ namespace Org.BouncyCastle.Math.EC.Tests } /** - * Simple shift-and-add multiplication. Serves as reference implementation - * to verify (possibly faster) implementations in - * {@link org.bouncycastle.math.ec.ECPoint ECPoint}. - * - * @param p - * The point to multiply. - * @param k - * The multiplier. - * @return The result of the point multiplication <code>kP</code>. - */ - private ECPoint Multiply(ECPoint p, BigInteger k) - { - ECPoint q = p.Curve.Infinity; - int t = k.BitLength; - for (int i = 0; i < t; i++) - { - if (i != 0) - { - p = p.Twice(); - } - if (k.TestBit(i)) - { - q = q.Add(p); - } - } - return q; - } - - /** * Checks, if the point multiplication algorithm of the given point yields * the same result as point multiplication done by the reference * implementation given in <code>multiply()</code>. This method chooses a @@ -331,7 +302,7 @@ namespace Org.BouncyCastle.Math.EC.Tests private void ImplTestMultiply(ECPoint p, int numBits) { BigInteger k = new BigInteger(numBits, secRand); - ECPoint reff = Multiply(p, k); + ECPoint reff = ECAlgorithms.ReferenceMultiply(p, k); ECPoint q = p.Multiply(k); AssertPointsEqual("ECPoint.Multiply is incorrect", reff, q); } @@ -355,7 +326,7 @@ namespace Org.BouncyCastle.Math.EC.Tests do { - ECPoint reff = Multiply(p, k); + ECPoint reff = ECAlgorithms.ReferenceMultiply(p, k); ECPoint q = p.Multiply(k); AssertPointsEqual("ECPoint.Multiply is incorrect", reff, q); k = k.Add(BigInteger.One); |