summaryrefslogtreecommitdiffstats
path: root/base/util/src/netscape/security/provider
diff options
context:
space:
mode:
Diffstat (limited to 'base/util/src/netscape/security/provider')
-rw-r--r--base/util/src/netscape/security/provider/DSAPrivateKey.java26
-rw-r--r--base/util/src/netscape/security/provider/DSAPublicKey.java26
-rw-r--r--base/util/src/netscape/security/provider/RSAPublicKey.java32
3 files changed, 84 insertions, 0 deletions
diff --git a/base/util/src/netscape/security/provider/DSAPrivateKey.java b/base/util/src/netscape/security/provider/DSAPrivateKey.java
index 8b64fbf6c..385aa173c 100644
--- a/base/util/src/netscape/security/provider/DSAPrivateKey.java
+++ b/base/util/src/netscape/security/provider/DSAPrivateKey.java
@@ -141,4 +141,30 @@ public final class DSAPrivateKey extends PKCS8Key
throw new InvalidKeyException(e.getMessage());
}
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((x == null) ? 0 : x.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ DSAPrivateKey other = (DSAPrivateKey) obj;
+ if (x == null) {
+ if (other.x != null)
+ return false;
+ } else if (!x.equals(other.x))
+ return false;
+ return true;
+ }
+
}
diff --git a/base/util/src/netscape/security/provider/DSAPublicKey.java b/base/util/src/netscape/security/provider/DSAPublicKey.java
index 66c3eb45a..481b9ee7f 100644
--- a/base/util/src/netscape/security/provider/DSAPublicKey.java
+++ b/base/util/src/netscape/security/provider/DSAPublicKey.java
@@ -130,4 +130,30 @@ public final class DSAPublicKey extends X509Key
e.getMessage());
}
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((y == null) ? 0 : y.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ DSAPublicKey other = (DSAPublicKey) obj;
+ if (y == null) {
+ if (other.y != null)
+ return false;
+ } else if (!y.equals(other.y))
+ return false;
+ return true;
+ }
+
}
diff --git a/base/util/src/netscape/security/provider/RSAPublicKey.java b/base/util/src/netscape/security/provider/RSAPublicKey.java
index a70d1aeee..40f5583ac 100644
--- a/base/util/src/netscape/security/provider/RSAPublicKey.java
+++ b/base/util/src/netscape/security/provider/RSAPublicKey.java
@@ -149,4 +149,36 @@ public final class RSAPublicKey extends X509Key implements Serializable {
}
}
+ @Override
+ public boolean equals(Object object) {
+
+ if (object == null) {
+ 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))) {
+ return false;
+ }
+ return super.equals(rhs);
+ }
+
+ return false;
+ }
+
+ public boolean bigIntEquals(BigInt x, BigInt y) {
+ if (x == null) {
+ if (y != null) {
+ return false;
+ }
+ } else {
+ if (!x.equals(y)) {
+ return false;
+ }
+ }
+ return true;
+ }
}