public final class DHPrivateKey
extends java.lang.Object
implements java.security.PrivateKey, javax.crypto.interfaces.DHPrivateKey, java.io.Serializable
DHPublicKey
,
java.security.KeyAgreement
,
Serialized FormConstructor 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).
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getAlgorithm()
Returns the name of the algorithm associated with this key: "DH"
|
byte[] |
getEncoded()
Get the encoding of the key.
|
java.lang.String |
getFormat()
Returns the encoding format of this key: "PKCS#8"
|
javax.crypto.spec.DHParameterSpec |
getParams()
Returns the key parameters.
|
java.math.BigInteger |
getX()
Returns the private value,
x . |
int |
hashCode()
Calculates a hash code value for the object.
|
java.lang.String |
toString() |
void |
zeroize()
This function zeroizes the key so that it isn't in memory
|
public DHPrivateKey(java.math.BigInteger x, java.math.BigInteger p, java.math.BigInteger g) throws java.security.InvalidKeyException
x
, a prime
modulus p
, and a base generator g
.x
- the private valuep
- the prime modulusg
- the base generatorjava.security.InvalidKeyException
- if the key cannot be encodedpublic DHPrivateKey(java.math.BigInteger x, java.math.BigInteger p, java.math.BigInteger g, int l) throws java.security.InvalidKeyException
x
, a prime
modulus p
, a base generator g
, and a
private-value length l
.x
- the private valuep
- the prime modulusg
- the base generatorl
- the private-value lengthjava.security.InvalidKeyException
- if the key cannot be encodedpublic DHPrivateKey(byte[] encodedKey) throws java.security.InvalidKeyException
encodedKey
- the encoded keyjava.security.InvalidKeyException
- if the encoded key does not represent
a Diffie-Hellman private keypublic java.lang.String getFormat()
getFormat
in interface java.security.Key
public java.lang.String getAlgorithm()
getAlgorithm
in interface java.security.Key
public byte[] getEncoded()
getEncoded
in interface java.security.Key
public java.math.BigInteger getX()
x
.getX
in interface javax.crypto.interfaces.DHPrivateKey
x
public javax.crypto.spec.DHParameterSpec getParams()
getParams
in interface javax.crypto.interfaces.DHKey
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public void zeroize()
© Portions Copyright 2003, 2012 IBM Corporation. All rights reserved.
© Portions Copyright 2003, 2012, Oracle and/or its affiliates. All rights reserved.