01: // Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
02:
03: package org.xbill.DNS.security;
04:
05: import java.math.*;
06: import javax.crypto.interfaces.*;
07: import javax.crypto.spec.*;
08:
09: /**
10: * A stub implementation of a Diffie-Hellman public key
11: *
12: * @author Brian Wellington
13: */
14:
15: class DHPubKey implements DHPublicKey {
16:
17: private DHParameterSpec params;
18: private BigInteger Y;
19:
20: /** Create a Diffie-Hellman public key from its parts */
21: public DHPubKey(BigInteger p, BigInteger g, BigInteger y) {
22: params = new DHParameterSpec(p, g);
23: Y = y;
24: }
25:
26: /** Obtain the public value of a Diffie-Hellman public key */
27: public BigInteger getY() {
28: return Y;
29: }
30:
31: /** Obtain the parameters of a Diffie-Hellman public key */
32: public DHParameterSpec getParams() {
33: return params;
34: }
35:
36: /** Obtain the algorithm of a Diffie-Hellman public key */
37: public String getAlgorithm() {
38: return "DH";
39: }
40:
41: /** Obtain the format of a Diffie-Hellman public key (unimplemented) */
42: public String getFormat() {
43: return null;
44: }
45:
46: /**
47: * Obtain the encoded representation of a Diffie-Hellman public key
48: * (unimplemented)
49: */
50: public byte[] getEncoded() {
51: return null;
52: }
53:
54: public String toString() {
55: StringBuffer sb = new StringBuffer();
56: sb.append("P = ");
57: sb.append(params.getP());
58: sb.append("\nG = ");
59: sb.append(params.getG());
60: sb.append("\nY = ");
61: sb.append(Y);
62: return sb.toString();
63: }
64:
65: }
|