com.ibm.crypto.fips.provider
Class DHPublicKey
- java.lang.Object
-
- com.ibm.crypto.fips.provider.DHPublicKey
-
- All Implemented Interfaces:
- java.io.Serializable, java.security.Key, java.security.PublicKey, javax.crypto.interfaces.DHKey, javax.crypto.interfaces.DHPublicKey
public final class DHPublicKey extends java.lang.Object implements java.security.PublicKey, javax.crypto.interfaces.DHPublicKey, java.io.SerializableA public key in X.509 format for the Diffie-Hellman key agreement algorithm.- See Also:
DHPrivateKey,java.security.KeyAgreement, Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description DHPublicKey(java.math.BigInteger y, java.math.BigInteger p, java.math.BigInteger g)Make a DH public key out of a public valuey, a prime modulusp, and a base generatorg.DHPublicKey(java.math.BigInteger y, java.math.BigInteger p, java.math.BigInteger g, int l)Make a DH public key out of a public valuey, a prime modulusp, a base generatorg, and a private-value lengthl.DHPublicKey(byte[] encodedKey)Make a DH public key from its DER encoding (X.509).
-
Method Summary
Methods Modifier and Type Method and Description booleanequals(java.lang.Object obj)protected voidfinalize()This function zeroizes the key so that it isn't in memory when GC is done.java.lang.StringgetAlgorithm()Returns the name of the algorithm associated with this key: "DH"byte[]getEncoded()Get the encoding of the key.java.lang.StringgetFormat()Returns the encoding format of this key: "X.509"javax.crypto.spec.DHParameterSpecgetParams()Returns the key parameters.java.math.BigIntegergetY()Returns the public value,y.inthashCode()Calculates a hash code value for the object.java.lang.StringtoString()voidzeroize()This function zeroizes the key so that it isn't in memory
-
-
-
Constructor Detail
-
DHPublicKey
public DHPublicKey(java.math.BigInteger y, java.math.BigInteger p, java.math.BigInteger g) throws java.security.InvalidKeyExceptionMake a DH public key out of a public valuey, a prime modulusp, and a base generatorg.- Parameters:
y- the public valuep- the prime modulusg- the base generator- Throws:
java.security.InvalidKeyException- if the key cannot be encoded
-
DHPublicKey
public DHPublicKey(java.math.BigInteger y, java.math.BigInteger p, java.math.BigInteger g, int l) throws java.security.InvalidKeyExceptionMake a DH public key out of a public valuey, a prime modulusp, a base generatorg, and a private-value lengthl.- Parameters:
y- the public valuep- the prime modulusg- the base generatorl- the private-value length- Throws:
java.security.InvalidKeyException- if the key cannot be encoded
-
DHPublicKey
public DHPublicKey(byte[] encodedKey) throws java.security.InvalidKeyExceptionMake a DH public key from its DER encoding (X.509).- Parameters:
encodedKey- the encoded key- Throws:
java.security.InvalidKeyException- if the encoded key does not represent a Diffie-Hellman public key
-
-
Method Detail
-
getFormat
public java.lang.String getFormat()
Returns the encoding format of this key: "X.509"- Specified by:
getFormatin interfacejava.security.Key
-
getAlgorithm
public java.lang.String getAlgorithm()
Returns the name of the algorithm associated with this key: "DH"- Specified by:
getAlgorithmin interfacejava.security.Key
-
getEncoded
public byte[] getEncoded()
Get the encoding of the key.- Specified by:
getEncodedin interfacejava.security.Key
-
getY
public java.math.BigInteger getY()
Returns the public value,y.- Specified by:
getYin interfacejavax.crypto.interfaces.DHPublicKey- Returns:
- the public value,
y
-
getParams
public javax.crypto.spec.DHParameterSpec getParams()
Returns the key parameters.- Specified by:
getParamsin interfacejavax.crypto.interfaces.DHKey- Returns:
- the key parameters
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
Calculates a hash code value for the object. Objects that are equal will also have the same hashcode.- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
zeroize
public void zeroize()
This function zeroizes the key so that it isn't in memory
-
finalize
protected void finalize()
This function zeroizes the key so that it isn't in memory when GC is done.- Overrides:
finalizein classjava.lang.Object
-
-