Class AsymmetricRSAKey

  • All Implemented Interfaces:
    AsymmetricKey, Key
    Direct Known Subclasses:
    AsymmetricRSAPrivateKey, AsymmetricRSAPublicKey

    public abstract class AsymmetricRSAKey
    extends java.lang.Object
    implements AsymmetricKey
    Base class for RSA keys.

    Note: the module attempts to prevent accidental recent use of RSA keys for signing and encryption purposes by associating a specific usage with a modulus. If the module is not running in approved mode this behavior can be overridden by setting the system property "org.bouncycastle.rsa.allow_multi_use" to "true".

    • Method Detail

      • getAlgorithm

        public Algorithm getAlgorithm()
        Return the algorithm this RSA key is for.
        Specified by:
        getAlgorithm in interface Key
        Returns:
        the key's algorithm.
      • getModulus

        public java.math.BigInteger getModulus()
        Return the modulus for this RSA key.
        Returns:
        the key's modulus.
      • canBeUsed

        public boolean canBeUsed​(AsymmetricRSAKey.Usage usage)
        Check to see if a key can be used for a specific usage. Essentially this will return false if the modulus is associated with a different usage already. The system property "org.bouncycastle.rsa.allow_multi_use" can be set to "true" to override this check.
        Parameters:
        usage - usage for the RSA key.
        Returns:
        true if the modulus is already associated with the usage, or has not being used already.
      • zeroize

        protected void zeroize()
      • checkApprovedOnlyModeStatus

        protected final void checkApprovedOnlyModeStatus()