1 19 20 package com.maverick.crypto.publickey; 21 22 import java.math.BigInteger ; 23 24 import com.maverick.crypto.digests.SHA1Digest; 25 26 public class DsaPrivateKey 27 extends DsaKey { 28 29 protected BigInteger x; 30 31 public DsaPrivateKey(BigInteger p, BigInteger q, BigInteger g, BigInteger x) { 32 super(p, q, g); 33 this.x = x; 34 } 35 36 39 public BigInteger getX() { 40 return x; 41 } 42 43 46 49 public byte[] sign(byte[] msg) { 50 51 SHA1Digest h = new SHA1Digest(); 52 h.update(msg, 0, msg.length); 53 byte[] data = new byte[h.getDigestSize()]; 54 h.doFinal(data, 0); 55 return Dsa.sign(x, p, q, g, data); 56 } 57 58 public boolean equals(Object obj) { 59 if (obj instanceof DsaPrivateKey) { 60 DsaPrivateKey key = (DsaPrivateKey) obj; 61 return x.equals(key.x) 62 && p.equals(key.p) 63 && q.equals(key.q) 64 && g.equals(key.g); 65 } 66 return false; 67 } 68 69 } 70 | Popular Tags |