01: package org.bouncycastle.crypto.params;
02:
03: import java.math.BigInteger;
04:
05: import org.bouncycastle.crypto.CipherParameters;
06:
07: public class ElGamalParameters implements CipherParameters {
08: private BigInteger g;
09: private BigInteger p;
10: private int l;
11:
12: public ElGamalParameters(BigInteger p, BigInteger g) {
13: this .g = g;
14: this .p = p;
15: }
16:
17: public ElGamalParameters(BigInteger p, BigInteger g, int l) {
18: this .g = g;
19: this .p = p;
20: this .l = l;
21: }
22:
23: public BigInteger getP() {
24: return p;
25: }
26:
27: /**
28: * return the generator - g
29: */
30: public BigInteger getG() {
31: return g;
32: }
33:
34: /**
35: * return private value limit - l
36: */
37: public int getL() {
38: return l;
39: }
40:
41: public boolean equals(Object obj) {
42: if (!(obj instanceof ElGamalParameters)) {
43: return false;
44: }
45:
46: ElGamalParameters pm = (ElGamalParameters) obj;
47:
48: return pm.getP().equals(p) && pm.getG().equals(g)
49: && pm.getL() == l;
50: }
51:
52: public int hashCode() {
53: return (getP().hashCode() ^ getG().hashCode()) + l;
54: }
55: }
|