Class BCDHPrivateKey
java.lang.Object
org.bouncycastle.jcajce.provider.asymmetric.dh.BCDHPrivateKey
- All Implemented Interfaces:
Serializable, AsymmetricKey, DEREncodablePREVIEW, Key, PrivateKey, DHKey, DHPrivateKey, Destroyable, PKCS12BagAttributeCarrier
public class BCDHPrivateKey
extends Object
implements DHPrivateKey, Destroyable, PKCS12BagAttributeCarrier
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Destroy this key, clearing the key material it holds.booleanbyte[]Return a PKCS8 representation of the key.return the encoding format we produce in getEncoded().getX()booleaninthashCode()booleanvoidsetBagAttribute(ASN1ObjectIdentifier oid, ASN1Encodable attribute) voidsetFriendlyName(String friendlyName) toString()
-
Constructor Details
-
BCDHPrivateKey
protected BCDHPrivateKey() -
BCDHPrivateKey
- Throws:
IOException
-
-
Method Details
-
getAlgorithm
- Specified by:
getAlgorithmin interfaceKey
-
getFormat
-
getEncoded
public byte[] getEncoded()Return a PKCS8 representation of the key. The sequence returned represents a full PrivateKeyInfo object.- Specified by:
getEncodedin interfaceKey- Returns:
- a PKCS8 representation of the key.
-
toString
-
getParams
- Specified by:
getParamsin interfaceAsymmetricKey- Specified by:
getParamsin interfaceDHKey- Specified by:
getParamsin interfaceDHPrivateKey
-
getX
- Specified by:
getXin interfaceDHPrivateKey
-
equals
-
hashCode
-
destroy
public void destroy()Destroy this key, clearing the key material it holds.The private value is held as a
BigInteger, which is immutable and so cannot be zeroized in place - destruction drops the internal reference so the value becomes unreachable (cleared on garbage collection). A PKCS#8 PrivateKeyInfo retained from decoding is dropped with it, and the underlyingDHPrivateKeyParametersobject, where one is held, is destroyed as well, so keys sharing it are invalidated too. The (public) domain parameters are retained. After destructionisDestroyed()returns true, the secret-bearing accessors (getEncoded()andgetX()) throwIllegalStateException, the key can no longer be serialized, and it is equal only to itself;hashCode()retains its pre-destruction value.- Specified by:
destroyin interfaceDestroyable
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfaceDestroyable
-
setBagAttribute
- Specified by:
setBagAttributein interfacePKCS12BagAttributeCarrier
-
getBagAttribute
- Specified by:
getBagAttributein interfacePKCS12BagAttributeCarrier
-
getBagAttributeKeys
- Specified by:
getBagAttributeKeysin interfacePKCS12BagAttributeCarrier
-
hasFriendlyName
public boolean hasFriendlyName()- Specified by:
hasFriendlyNamein interfacePKCS12BagAttributeCarrier
-
setFriendlyName
- Specified by:
setFriendlyNamein interfacePKCS12BagAttributeCarrier
-