com.ibm.crypto.fips.provider

Class DHPrivateKey

  1. java.lang.Object
  2. extended bycom.ibm.crypto.fips.provider.DHPrivateKey
All implemented interfaces:
java.io.Serializable, java.security.Key, java.security.PrivateKey, javax.crypto.interfaces.DHKey, javax.crypto.interfaces.DHPrivateKey

  1. public final class DHPrivateKey
  2. extends java.lang.Object
  3. implements java.security.PrivateKey, javax.crypto.interfaces.DHPrivateKey, java.io.Serializable
A private key in PKCS#8 format for the Diffie-Hellman key agreement algorithm.
Version:
1.0, 05/19/03
Author:
Jan Luehe, John Peck
See Also:
DHPublicKey, java.security.KeyAgreement, Serialized Form

Constructor Summary

Constructor and Description
DHPrivateKey(java.math.BigInteger x,java.math.BigInteger p,java.math.BigInteger g)
Make a DH private key out of a private value x, a prime modulus p, and a base generator g.
DHPrivateKey(java.math.BigInteger x,java.math.BigInteger p,java.math.BigInteger g,int l)
Make a DH private key out of a private value x, a prime modulus p, a base generator g, and a private-value length l.
DHPrivateKey(byte[] encodedKey)
Make a DH private key from its DER encoding (PKCS #8).

Method Summary

Modifier and Type Method and Description
  1. boolean
equals(java.lang.Object obj)
  1. protected
  2. void
finalize()
This function zeroizes the key so that it isn't in memory when GC is done.
  1. java.lang.String
getAlgorithm()
Returns the name of the algorithm associated with this key: "DH"
  1. byte[]
getEncoded()
Get the encoding of the key.
  1. java.lang.String
getFormat()
Returns the encoding format of this key: "PKCS#8"
  1. javax.crypto.spec.DHParameterSpec
getParams()
Returns the key parameters.
  1. java.math.BigInteger
getX()
Returns the private value, x.
  1. int
hashCode()
Calculates a hash code value for the object.
  1. java.lang.String
toString()
  1. void
zeroize()
This function zeroizes the key so that it isn't in memory
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait

Constructor Detail

DHPrivateKey

  1. public DHPrivateKey(java.math.BigInteger x,
  2. java.math.BigInteger p,
  3. java.math.BigInteger g)
  4. throws java.security.InvalidKeyException
Make a DH private key out of a private value x, a prime modulus p, and a base generator g.
Parameters:
x - the private value
p - the prime modulus
g - the base generator
Throws:
java.security.InvalidKeyException - if the key cannot be encoded

DHPrivateKey

  1. public DHPrivateKey(java.math.BigInteger x,
  2. java.math.BigInteger p,
  3. java.math.BigInteger g,
  4. int l)
  5. throws java.security.InvalidKeyException
Make a DH private key out of a private value x, a prime modulus p, a base generator g, and a private-value length l.
Parameters:
x - the private value
p - the prime modulus
g - the base generator
l - the private-value length
Throws:
java.security.InvalidKeyException - if the key cannot be encoded

DHPrivateKey

  1. public DHPrivateKey(byte[] encodedKey)
  2. throws java.security.InvalidKeyException
Make a DH private key from its DER encoding (PKCS #8).
Parameters:
encodedKey - the encoded key
Throws:
java.security.InvalidKeyException - if the encoded key does not represent a Diffie-Hellman private key

Method Detail

getFormat

  1. public java.lang.String getFormat( )
Returns the encoding format of this key: "PKCS#8"
Specified by:
getFormat in interface java.security.Key

getAlgorithm

  1. public java.lang.String getAlgorithm( )
Returns the name of the algorithm associated with this key: "DH"
Specified by:
getAlgorithm in interface java.security.Key

getEncoded

  1. public byte[] getEncoded()
Get the encoding of the key.
Specified by:
getEncoded in interface java.security.Key

getX

  1. public java.math.BigInteger getX( )
Returns the private value, x.
Specified by:
getX in interface javax.crypto.interfaces.DHPrivateKey
Returns:
the private value, x

getParams

  1. public javax.crypto.spec.DHParameterSpec getParams( )
Returns the key parameters.
Specified by:
getParams in interface javax.crypto.interfaces.DHKey
Returns:
the key parameters

toString

  1. public java.lang.String toString( )
Overrides:
toString in class java.lang.Object

hashCode

  1. public int hashCode()
Calculates a hash code value for the object. Objects that are equal will also have the same hashcode.
Overrides:
hashCode in class java.lang.Object

equals

  1. public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

zeroize

  1. public void zeroize()
This function zeroizes the key so that it isn't in memory

finalize

  1. protected void finalize()
This function zeroizes the key so that it isn't in memory when GC is done.
Overrides:
finalize in class java.lang.Object