diff options
author | bouncy <bouncy@deimos.tauceti.org.au> | 2014-01-08 07:31:34 +0400 |
---|---|---|
committer | bouncy <bouncy@deimos.tauceti.org.au> | 2014-01-08 07:31:34 +0400 |
commit | dea90dc25613ce01128264d2bb0c45e1a32b662c (patch) | |
tree | 849fb86d7153758a6967a3b380e008b98500771f | |
parent | 7078d576cf1ba691509b94bb71790bbdc3012b60 (diff) | |
parent | 5a07d5ebcbc81f1af253e541fe7a86d2a5e3b74f (diff) |
Merge remote branch 'origin/master'master
3 files changed, 21 insertions, 93 deletions
diff --git a/core/src/main/java/org/bouncycastle/math/ec/ECCurve.java b/core/src/main/java/org/bouncycastle/math/ec/ECCurve.java index 2a93ff63..c2506f3d 100644 --- a/core/src/main/java/org/bouncycastle/math/ec/ECCurve.java +++ b/core/src/main/java/org/bouncycastle/math/ec/ECCurve.java @@ -6,6 +6,7 @@ import java.util.Random; import org.bouncycastle.math.field.FiniteField; import org.bouncycastle.math.field.FiniteFields; import org.bouncycastle.util.BigIntegers; +import org.bouncycastle.util.Integers; /** * base class for an elliptic curve @@ -337,6 +338,26 @@ public abstract class ECCurve } } + public boolean equals(ECCurve other) + { + return this == other + || (getField().equals(other.getField()) + && getA().equals(other.getA()) + && getB().equals(other.getB())); + } + + public boolean equals(Object obj) + { + return this == obj || (obj instanceof ECCurve && equals((ECCurve)obj)); + } + + public int hashCode() + { + return getField().hashCode() + ^ Integers.rotateLeft(getA().hashCode(), 8) + ^ Integers.rotateLeft(getB().hashCode(), 16); + } + /** * Elliptic curve over Fp */ @@ -476,30 +497,6 @@ public abstract class ECCurve { return infinity; } - - public boolean equals( - Object anObject) - { - if (anObject == this) - { - return true; - } - - if (!(anObject instanceof ECCurve.Fp)) - { - return false; - } - - ECCurve.Fp other = (ECCurve.Fp) anObject; - - return this.q.equals(other.q) - && a.equals(other.a) && b.equals(other.b); - } - - public int hashCode() - { - return a.hashCode() ^ b.hashCode() ^ q.hashCode(); - } } /** @@ -944,31 +941,6 @@ public abstract class ECCurve return z; } - - public boolean equals( - Object anObject) - { - if (anObject == this) - { - return true; - } - - if (!(anObject instanceof ECCurve.F2m)) - { - return false; - } - - ECCurve.F2m other = (ECCurve.F2m)anObject; - - return (this.m == other.m) && (this.k1 == other.k1) - && (this.k2 == other.k2) && (this.k3 == other.k3) - && a.equals(other.a) && b.equals(other.b); - } - - public int hashCode() - { - return this.a.hashCode() ^ this.b.hashCode() ^ m ^ k1 ^ k2 ^ k3; - } public int getM() { diff --git a/core/src/main/java/org/bouncycastle/math/ec/custom/sec/SecP256K1Curve.java b/core/src/main/java/org/bouncycastle/math/ec/custom/sec/SecP256K1Curve.java index 001a446e..bcdc70b5 100644 --- a/core/src/main/java/org/bouncycastle/math/ec/custom/sec/SecP256K1Curve.java +++ b/core/src/main/java/org/bouncycastle/math/ec/custom/sec/SecP256K1Curve.java @@ -96,26 +96,4 @@ public class SecP256K1Curve extends ECCurve { return infinity; } - - public boolean equals(Object anObject) - { - if (anObject == this) - { - return true; - } - - if (!(anObject instanceof SecP256K1Curve)) - { - return false; - } - - SecP256K1Curve other = (SecP256K1Curve)anObject; - - return this.q.equals(other.q) && a.equals(other.a) && b.equals(other.b); - } - - public int hashCode() - { - return a.hashCode() ^ b.hashCode() ^ q.hashCode(); - } } diff --git a/core/src/main/java/org/bouncycastle/math/ec/custom/sec/SecP256R1Curve.java b/core/src/main/java/org/bouncycastle/math/ec/custom/sec/SecP256R1Curve.java index ebddd858..e1344f3b 100644 --- a/core/src/main/java/org/bouncycastle/math/ec/custom/sec/SecP256R1Curve.java +++ b/core/src/main/java/org/bouncycastle/math/ec/custom/sec/SecP256R1Curve.java @@ -99,26 +99,4 @@ public class SecP256R1Curve extends ECCurve { return infinity; } - - public boolean equals(Object anObject) - { - if (anObject == this) - { - return true; - } - - if (!(anObject instanceof SecP256R1Curve)) - { - return false; - } - - SecP256R1Curve other = (SecP256R1Curve)anObject; - - return this.q.equals(other.q) && a.equals(other.a) && b.equals(other.b); - } - - public int hashCode() - { - return a.hashCode() ^ b.hashCode() ^ q.hashCode(); - } } |