diff options
Diffstat (limited to 'base/util/src/netscape/security/provider')
-rw-r--r-- | base/util/src/netscape/security/provider/DSA.java | 9 | ||||
-rw-r--r-- | base/util/src/netscape/security/provider/RSAPublicKey.java | 39 |
2 files changed, 30 insertions, 18 deletions
diff --git a/base/util/src/netscape/security/provider/DSA.java b/base/util/src/netscape/security/provider/DSA.java index 64575b870..9403475e0 100644 --- a/base/util/src/netscape/security/provider/DSA.java +++ b/base/util/src/netscape/security/provider/DSA.java @@ -311,11 +311,12 @@ public final class DSA extends Signature { */ private int compareSeeds(int[] seed1, int[] seed2) { - if ((seed1 == null && seed1 == null) || - (seed1 == null && seed2 != null) || - (seed1 != null && seed2 == null) || - seed1.length != seed2.length) + if (seed1 == null || seed2 == null) { return 1; + } + if (seed1.length != seed2.length) { + return 1; + } for (int i = 0; i < seed1.length; i++) { if (seed1[i] != seed2[i]) diff --git a/base/util/src/netscape/security/provider/RSAPublicKey.java b/base/util/src/netscape/security/provider/RSAPublicKey.java index 40f5583ac..bd5aa2fe4 100644 --- a/base/util/src/netscape/security/provider/RSAPublicKey.java +++ b/base/util/src/netscape/security/provider/RSAPublicKey.java @@ -150,23 +150,34 @@ public final class RSAPublicKey extends X509Key implements Serializable { } @Override - public boolean equals(Object object) { + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((modulus == null) ? 0 : modulus.hashCode()); + result = prime * result + ((publicExponent == null) ? 0 : publicExponent.hashCode()); + return result; + } - if (object == null) { + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) return false; - } - if (object instanceof RSAPublicKey) { - RSAPublicKey rhs = (RSAPublicKey) object; - if (this == rhs) { - return true; - } - if (!(bigIntEquals(this.modulus, rhs.modulus) && bigIntEquals(this.publicExponent, rhs.publicExponent))) { + if (getClass() != obj.getClass()) + return false; + RSAPublicKey other = (RSAPublicKey) obj; + if (modulus == null) { + if (other.modulus != null) return false; - } - return super.equals(rhs); - } - - return false; + } else if (!modulus.equals(other.modulus)) + return false; + if (publicExponent == null) { + if (other.publicExponent != null) + return false; + } else if (!publicExponent.equals(other.publicExponent)) + return false; + return true; } public boolean bigIntEquals(BigInt x, BigInt y) { |