All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.xbill.DNS.security.DHPubKey Maven / Gradle / Ivy

There is a newer version: 2.0-beta-7
Show newest version
// Copyright (c) 1999-2004 Brian Wellington ([email protected])

package org.xbill.DNS.security;

import javax.crypto.interfaces.DHPublicKey;
import javax.crypto.spec.DHParameterSpec;
import java.math.BigInteger;

/**
 * A stub implementation of a Diffie-Hellman public key
 *
 * @author Brian Wellington
 */

class DHPubKey implements DHPublicKey {

private DHParameterSpec params;
private BigInteger Y;

/** Create a Diffie-Hellman public key from its parts */
public
DHPubKey(BigInteger p, BigInteger g, BigInteger y) {
	params = new DHParameterSpec(p, g);
	Y = y;
}

/** Obtain the public value of a Diffie-Hellman public key */
public BigInteger
getY() {
	return Y;
}

/** Obtain the parameters of a Diffie-Hellman public key */
public DHParameterSpec
getParams() {
	return params;
}

/** Obtain the algorithm of a Diffie-Hellman public key */
public String
getAlgorithm() {
	return "DH";
}

/** Obtain the format of a Diffie-Hellman public key (unimplemented) */
public String
getFormat() {
	return null;
}

/**
 * Obtain the encoded representation of a Diffie-Hellman public key
 * (unimplemented)
 */
public byte []
getEncoded() {
	return null;
}

public String
toString() {
	StringBuffer sb = new StringBuffer();
	sb.append("P = ");
	sb.append(params.getP());
	sb.append("\nG = ");
	sb.append(params.getG());
	sb.append("\nY = ");
	sb.append(Y);
	return sb.toString();
}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy