Skip navigation links

Oracle Fusion Middleware Crypto Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10668-05


oracle.security.crypto.core
Class DHPrivateKey

java.lang.Object
  extended by oracle.security.crypto.core.DHKey
      extended by oracle.security.crypto.core.DHPrivateKey

All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.security.Key, java.security.PrivateKey, javax.crypto.interfaces.DHKey, javax.crypto.interfaces.DHPrivateKey, ASN1Object, Streamable

public class DHPrivateKey
extends DHKey
implements PrivateKey, javax.crypto.interfaces.DHPrivateKey

A Diffie-Hellman private key.

The Diffie-Hellman private key contains a DHParams and the private key value x. The encoding is based on the PKCS #8 type PrivateKeyInfo.

See Also:
DHKey, DHPublicKey, DHParams, Serialized Form

Field Summary

 

Fields inherited from class oracle.security.crypto.core.DHKey
params

 

Fields inherited from interface javax.crypto.interfaces.DHPrivateKey
serialVersionUID

 

Constructor Summary
DHPrivateKey()
          Constructs a new, uninitialized instance.
DHPrivateKey(java.math.BigInteger x, DHParams params)
          Constructs a new instance with the give value of x and DHParams.
DHPrivateKey(java.io.File f)
          Constructs a new instance by reading its encoding from the given file.
DHPrivateKey(java.io.InputStream is)
          Constructs a new instance by reading its encoding from the given InputStream.

 

Method Summary
 java.lang.Object clone()
          Create a deep clone of this DHKey object.
 void erase()
          Erases the sensitive key material of a private or symmetric key, making the key un-usable.
 AlgorithmIdentifier getAlgID()
          Returns the algorithm identifier for this key.
 boolean getAllowExport()
          Returns false if plaintext export of this key's key material is not allowed; returns true if plaintext export is allowed.
 ASN1Object getContents()
          Returns the contents of this key.
 byte[] getEncoded()
          Returns ASN.1 DER bytes containing the PKCS#8 PrivateKeyInfo encoding of this private key.
 java.lang.String getFormat()
          Returns a string which indicates the format of this object's encoding.
 java.math.BigInteger getX()
          Gets the private key value x.
 void initialize(AlgorithmIdentifier algID, ASN1Object contents)
          Initializes this instance from the given algorithm paramters and key contents.
 void input(java.io.InputStream is)
          Inputs a DHPrivateKey object by reading its encoding from the given input stream.
 int length()
          Gets the length of the encoding of this object.
 void output(java.io.OutputStream os)
          Outputs the ASN1 encoding of this object to a given output stream.
 void setAllowExport(boolean value)
          Set to false to disallow plaintext export of this key's key material; set to true to allow plaintext export if the global value in FIPS_140_2 is also set to true.
 void setParams(DHParams params)
          Sets the parameters for the Diffie-Hellman key.
 java.lang.String toString()
          Returns a string representation of this object.

 

Methods inherited from class oracle.security.crypto.core.DHKey
getAlgorithm, getBitLength, getParams, readExternal, writeExternal

 

Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Methods inherited from interface oracle.security.crypto.core.Key
getAlgorithm, getBitLength

 

Methods inherited from interface java.io.Externalizable
readExternal, writeExternal

 

Methods inherited from interface javax.crypto.interfaces.DHKey
getParams

 

Constructor Detail

DHPrivateKey

public DHPrivateKey()
Constructs a new, uninitialized instance.

DHPrivateKey

public DHPrivateKey(java.math.BigInteger x,
                    DHParams params)
Constructs a new instance with the give value of x and DHParams.
Parameters:
x - x
params - the DHParams of this DHPrivateKey

DHPrivateKey

public DHPrivateKey(java.io.InputStream is)
             throws java.io.IOException
Constructs a new instance by reading its encoding from the given InputStream.
Parameters:
is - the InputStream for the DHPrivateKey object
Throws:
java.io.IOException - If an input exception occured.

DHPrivateKey

public DHPrivateKey(java.io.File f)
             throws java.io.IOException
Constructs a new instance by reading its encoding from the given file.
Parameters:
f - the file stores a DHPrivateKey object
Throws:
java.io.IOException - If an input exception occured.

Method Detail

getEncoded

public byte[] getEncoded()
Returns ASN.1 DER bytes containing the PKCS#8 PrivateKeyInfo encoding of this private key.
Specified by:
getEncoded in interface java.security.Key

getAllowExport

public boolean getAllowExport()
Returns false if plaintext export of this key's key material is not allowed; returns true if plaintext export is allowed.

If either this value or the global value is false, the output(java.io.OutputStream), getContents() and getEncoded() methods will throw a KeyExportException.

Returns:
false if plaintext key material export is not allowed, true if allowed.
Since:
3.0
See Also:
FIPS_140_2.getAllowKeyExport(), Cipher.wrapKey(PrivateKey key)

setAllowExport

public void setAllowExport(boolean value)
Set to false to disallow plaintext export of this key's key material; set to true to allow plaintext export if the global value in FIPS_140_2 is also set to true.

If either this value or the global value is false, the output(java.io.OutputStream), getContents() and getEncoded() methods will throw a KeyExportException.

Parameters:
value - false to disallow plaintext key material export, true to allow.
Since:
3.0
See Also:
FIPS_140_2.setAllowKeyExport(boolean), Cipher.wrapKey(PrivateKey key)

getFormat

public java.lang.String getFormat()
Returns a string which indicates the format of this object's encoding.
Specified by:
getFormat in interface java.security.Key
Returns:
"PKCS#8"

erase

public void erase()
Description copied from interface: Key
Erases the sensitive key material of a private or symmetric key, making the key un-usable. Keys may be erased multiple times with no consequences.

Note: After erase() has been invoked, no other methods of the Key object are guaranteed to function correctly. In particular, invoking another method after erase() may result in a NullPointerException being thrown.


clone

public java.lang.Object clone()
Description copied from class: DHKey
Create a deep clone of this DHKey object.
Specified by:
clone in class DHKey
Returns:
A deep clone of the Key instance.

initialize

public void initialize(AlgorithmIdentifier algID,
                       ASN1Object contents)
                throws AlgorithmIdentifierException,
                       InvalidInputException
Description copied from interface: PrivateKey
Initializes this instance from the given algorithm paramters and key contents.
Throws:
AlgorithmIdentifierException
InvalidInputException

getAlgID

public AlgorithmIdentifier getAlgID()
Description copied from interface: PrivateKey
Returns the algorithm identifier for this key.

getContents

public ASN1Object getContents()
Description copied from interface: PrivateKey
Returns the contents of this key.

setParams

public void setParams(DHParams params)
Description copied from class: DHKey
Sets the parameters for the Diffie-Hellman key. This method is used to set Diffie-Hellman parameters common to a group of users which are known from application context.
Specified by:
setParams in class DHKey
Parameters:
params - An instance of DHParams.

getX

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

toString

public java.lang.String toString()
Returns a string representation of this object.
Overrides:
toString in class java.lang.Object
Returns:
A string representation of this object.

input

public void input(java.io.InputStream is)
           throws java.io.IOException
Inputs a DHPrivateKey object by reading its encoding from the given input stream.
Specified by:
input in interface Streamable
Parameters:
is - The input stream from which this object will be read
Throws:
java.io.IOException - If an input exception occured.

output

public void output(java.io.OutputStream os)
            throws java.io.IOException
Outputs the ASN1 encoding of this object to a given output stream.
Specified by:
output in interface Streamable
Parameters:
os - The output stream to which the encoding of this object will be written.
Throws:
java.io.IOException - If an output exception occured.

length

public int length()
Gets the length of the encoding of this object.
Specified by:
length in interface Streamable
Returns:
The length of the ASN1 encoding of this object.

Skip navigation links

Oracle Fusion Middleware Crypto Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10668-05


Copyright © 2005, 2013, Oracle. All rights reserved.