Bouncy Castle Cryptography Library 1.85.2

org.bouncycastle.jcajce.provider.asymmetric.rsa
Class BCRSAPrivateKey

java.lang.Object
  extended byorg.bouncycastle.jcajce.provider.asymmetric.rsa.BCRSAPrivateKey
All Implemented Interfaces:
BCKey, javax.security.auth.Destroyable, java.security.Key, PKCS12BagAttributeCarrier, java.security.PrivateKey, java.security.interfaces.RSAKey, java.security.interfaces.RSAPrivateKey, java.io.Serializable
Direct Known Subclasses:
BCRSAPrivateCrtKey

public class BCRSAPrivateKey
extends java.lang.Object
implements java.security.interfaces.RSAPrivateKey, javax.security.auth.Destroyable, PKCS12BagAttributeCarrier, BCKey

See Also:
Serialized Form

Field Summary
protected  AlgorithmIdentifier algorithmIdentifier
           
protected  PKCS12BagAttributeCarrierImpl attrCarrier
           
protected  java.math.BigInteger modulus
           
protected  java.math.BigInteger privateExponent
           
protected  RSAKeyParameters rsaPrivateKey
           
 
Method Summary
 void destroy()
          Destroy this key, clearing the key material it holds.
 boolean equals(java.lang.Object o)
           
 java.lang.String getAlgorithm()
           
 ASN1Encodable getBagAttribute(ASN1ObjectIdentifier oid)
           
 java.util.Enumeration getBagAttributeKeys()
           
 byte[] getEncoded()
           
 java.lang.String getFormat()
           
 java.math.BigInteger getModulus()
           
 java.math.BigInteger getPrivateExponent()
           
 boolean hasFriendlyName()
           
 int hashCode()
           
 boolean isDestroyed()
           
 void setBagAttribute(ASN1ObjectIdentifier oid, ASN1Encodable attribute)
           
 void setFriendlyName(java.lang.String friendlyName)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

modulus

protected java.math.BigInteger modulus

privateExponent

protected java.math.BigInteger privateExponent

algorithmIdentifier

protected transient AlgorithmIdentifier algorithmIdentifier

rsaPrivateKey

protected transient RSAKeyParameters rsaPrivateKey

attrCarrier

protected transient PKCS12BagAttributeCarrierImpl attrCarrier
Method Detail

getModulus

public java.math.BigInteger getModulus()
Specified by:
getModulus in interface java.security.interfaces.RSAKey

getPrivateExponent

public java.math.BigInteger getPrivateExponent()
Specified by:
getPrivateExponent in interface java.security.interfaces.RSAPrivateKey

getAlgorithm

public java.lang.String getAlgorithm()
Specified by:
getAlgorithm in interface java.security.Key

getFormat

public java.lang.String getFormat()
Specified by:
getFormat in interface java.security.Key

getEncoded

public byte[] getEncoded()
Specified by:
getEncoded in interface java.security.Key

equals

public boolean equals(java.lang.Object o)

hashCode

public int hashCode()

destroy

public void destroy()
Destroy this key, clearing the key material it holds.

The values are held as BigIntegers, which are immutable and so cannot be zeroized in place - destruction drops the internal references so the values become unreachable (cleared on garbage collection). The (public) modulus is retained, so hashCode() and getModulus() remain stable across destruction. The underlying RSAKeyParameters object is destroyed as well, so keys sharing it are invalidated too. After destruction isDestroyed() returns true, getEncoded() and getPrivateExponent() throw IllegalStateException, and the key can no longer be serialized.

Specified by:
destroy in interface javax.security.auth.Destroyable

isDestroyed

public boolean isDestroyed()
Specified by:
isDestroyed in interface javax.security.auth.Destroyable

setBagAttribute

public void setBagAttribute(ASN1ObjectIdentifier oid,
                            ASN1Encodable attribute)
Specified by:
setBagAttribute in interface PKCS12BagAttributeCarrier

getBagAttribute

public ASN1Encodable getBagAttribute(ASN1ObjectIdentifier oid)
Specified by:
getBagAttribute in interface PKCS12BagAttributeCarrier

getBagAttributeKeys

public java.util.Enumeration getBagAttributeKeys()
Specified by:
getBagAttributeKeys in interface PKCS12BagAttributeCarrier

hasFriendlyName

public boolean hasFriendlyName()
Specified by:
hasFriendlyName in interface PKCS12BagAttributeCarrier

setFriendlyName

public void setFriendlyName(java.lang.String friendlyName)
Specified by:
setFriendlyName in interface PKCS12BagAttributeCarrier

toString

public java.lang.String toString()

Bouncy Castle Cryptography Library 1.85.2