Class BCRSAPrivateKey

  • All Implemented Interfaces:
    java.io.Serializable, java.security.interfaces.RSAKey, java.security.interfaces.RSAPrivateKey, java.security.Key, java.security.PrivateKey, javax.security.auth.Destroyable, BCKey, PKCS12BagAttributeCarrier
    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
    • 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)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • 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
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object