summaryrefslogtreecommitdiffstats
path: root/base/util/src/netscape/security/x509/AlgIdDSA.java
diff options
context:
space:
mode:
authorAbhishek Koneru <akoneru@redhat.com>2012-06-11 16:21:26 -0400
committerEndi Sukma Dewata <edewata@redhat.com>2012-06-15 17:12:15 -0500
commit10326ad4fe1b3db620f43feb3f47c4fd008f3f33 (patch)
tree4d4a0f719bbbea6d6db53ef3fab5f3717411cfb9 /base/util/src/netscape/security/x509/AlgIdDSA.java
parentc53ca291e21761f1de5417ef596afba395a7f5d1 (diff)
downloadpki-10326ad4fe1b3db620f43feb3f47c4fd008f3f33.tar.gz
pki-10326ad4fe1b3db620f43feb3f47c4fd008f3f33.tar.xz
pki-10326ad4fe1b3db620f43feb3f47c4fd008f3f33.zip
Fixes for Coverity issues of type Stringbuffer, NO_EQUALS_METHOD , REVERSE_INULL,Wrong_Map_Iterators
Diffstat (limited to 'base/util/src/netscape/security/x509/AlgIdDSA.java')
-rw-r--r--base/util/src/netscape/security/x509/AlgIdDSA.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/base/util/src/netscape/security/x509/AlgIdDSA.java b/base/util/src/netscape/security/x509/AlgIdDSA.java
index a34c5f59f..1f00b0355 100644
--- a/base/util/src/netscape/security/x509/AlgIdDSA.java
+++ b/base/util/src/netscape/security/x509/AlgIdDSA.java
@@ -174,4 +174,46 @@ public final class AlgIdDSA extends AlgorithmId implements DSAParams {
"\n g:\n" + (new BigInt(g)).toString() +
"\n";
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((g == null) ? 0 : g.hashCode());
+ result = prime * result + ((p == null) ? 0 : p.hashCode());
+ result = prime * result + ((q == null) ? 0 : q.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null) {
+ return false;
+ }
+ if (other instanceof AlgIdDSA) {
+ AlgIdDSA rhs = (AlgIdDSA) other;
+ if (this == rhs) {
+ return true;
+ }
+ if (!(bigIntEquals(this.p, rhs.p) && bigIntEquals(this.q, rhs.q) && bigIntEquals(this.g, rhs.g))) {
+ return false;
+ }
+ return super.equals(rhs);
+ }
+ return false;
+ }
+
+ public boolean bigIntEquals(BigInteger x, BigInteger y) {
+ if (x == null) {
+ if (y != null) {
+ return false;
+ }
+ } else {
+ if (!x.equals(y)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
}