Class AsymmetricRSAKey
- java.lang.Object
-
- org.bouncycastle.crypto.asymmetric.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".
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AsymmetricRSAKey.Usage
Specific RSA key usages.
-
Field Summary
Fields Modifier and Type Field Description protected static AlgorithmIdentifier
DEF_ALG_ID
protected java.math.BigInteger
modulus
protected AlgorithmIdentifier
rsaAlgIdentifier
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canBeUsed(AsymmetricRSAKey.Usage usage)
Check to see if a key can be used for a specific usage.protected void
checkApprovedOnlyModeStatus()
Algorithm
getAlgorithm()
Return the algorithm this RSA key is for.java.math.BigInteger
getModulus()
Return the modulus for this RSA key.protected void
zeroize()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bouncycastle.crypto.AsymmetricKey
getEncoded
-
-
-
-
Field Detail
-
DEF_ALG_ID
protected static final AlgorithmIdentifier DEF_ALG_ID
-
modulus
protected java.math.BigInteger modulus
-
rsaAlgIdentifier
protected final AlgorithmIdentifier rsaAlgIdentifier
-
-
Method Detail
-
getAlgorithm
public Algorithm getAlgorithm()
Return the algorithm this RSA key is for.- Specified by:
getAlgorithm
in interfaceKey
- 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()
-
-