public class DHPrivateKey extends DHKey implements PrivateKey, javax.crypto.interfaces.DHPrivateKey
The Diffie-Hellman private key contains a DHParams and the private key value x. The encoding is based on the PKCS #8 type PrivateKeyInfo.
DHKey, DHPublicKey, DHParams, Serialized Form| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
getAlgorithm, getBitLength, getParams, readExternal, writeExternalequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetAlgorithm, getBitLengthpublic DHPrivateKey()
public DHPrivateKey(java.math.BigInteger x,
DHParams params)
DHParams.x - xparams - the DHParams of this DHPrivateKey
public DHPrivateKey(java.io.InputStream is)
throws java.io.IOException
is - the InputStream for the DHPrivateKey objectjava.io.IOException - If an input exception occured.
public DHPrivateKey(java.io.File f)
throws java.io.IOException
f - the file stores a DHPrivateKey objectjava.io.IOException - If an input exception occured.public byte[] getEncoded()
getEncoded in interface java.security.Keypublic boolean getAllowExport()
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.
false if plaintext key material export is not allowed, true if allowed.FIPS_140_2.getAllowKeyExport(), Cipher.wrapKey(PrivateKey key)public void setAllowExport(boolean value)
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.
value - false to disallow plaintext key material export, true to allow.FIPS_140_2.setAllowKeyExport(boolean), Cipher.wrapKey(PrivateKey key)public java.lang.String getFormat()
getFormat in interface java.security.Keypublic void erase()
KeyNote: 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.
public java.lang.Object clone()
DHKeyDHKey object.public void initialize(AlgorithmIdentifier algID, ASN1Object contents) throws AlgorithmIdentifierException, InvalidInputException
PrivateKeypublic AlgorithmIdentifier getAlgID()
PrivateKeypublic ASN1Object getContents()
PrivateKeypublic void setParams(DHParams params)
DHKeypublic java.math.BigInteger getX()
getX in interface javax.crypto.interfaces.DHPrivateKeypublic java.lang.String toString()
toString in class java.lang.Object
public void input(java.io.InputStream is)
throws java.io.IOException
DHPrivateKey object by reading its encoding from the given input stream.input in interface Streamableis - The input stream from which this object will be readjava.io.IOException - If an input exception occured.
public void output(java.io.OutputStream os)
throws java.io.IOException
output in interface Streamableos - The output stream to which the encoding of this object will be written.java.io.IOException - If an output exception occured.public int length()
length in interface Streamable