Top Description Inners Fields Constructors Methods
org.bouncycastle.crypto.asymmetric

public abstract Class AsymmetricRSAKey

extends Object
implements AsymmetricKey
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.AsymmetricKey, org.bouncycastle.crypto.Key
Known Direct Subclasses
org.bouncycastle.crypto.asymmetric.AsymmetricRSAPrivateKey, org.bouncycastle.crypto.asymmetric.AsymmetricRSAPublicKey
Imports
java.lang.ref.WeakReference, java.math.BigInteger, java.util.HashSet, .Set, .WeakHashMap, java.util.concurrent.atomic.AtomicReference, org.bouncycastle.asn1.ASN1ObjectIdentifier, .DERNull, org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers, org.bouncycastle.asn1.x509.AlgorithmIdentifier, .X509ObjectIdentifiers, org.bouncycastle.crypto.Algorithm, .AsymmetricKey, .CryptoServicesRegistrar, org.bouncycastle.crypto.fips.FipsUnapprovedOperationError, org.bouncycastle.util.Properties

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 and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static enum
AsymmetricRSAKey.Usage

Specific RSA key usages.

Field Summary

Modifier and TypeField and Description
private Algorithm
private final boolean
protected static final AlgorithmIdentifier
private final AsymmetricRSAKey.KeyMarker
private static WeakHashMap<BigInteger, WeakReference<AsymmetricRSAKey.KeyMarker>>
protected BigInteger
protected final AlgorithmIdentifier
private static final Set<ASN1ObjectIdentifier>

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
AsymmetricRSAKey(Algorithm algorithm, AlgorithmIdentifier rsaAlgIdentifier, BigInteger modulus)

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the modulus is already associated with the usage, or has not being used already.
canBeUsed
(AsymmetricRSAKey.Usage
usage for the RSA key.
usage
)

Check to see if a key can be used for a specific usage.

protected final void
public Algorithm

Returns:

the key's algorithm.
getAlgorithm
()

Implements org.bouncycastle.crypto.Key.getAlgorithm.

Return the algorithm this RSA key is for.
pack-priv static synchronized AsymmetricRSAKey.KeyMarker
public BigInteger

Returns:

the key's modulus.
getModulus
()

Return the modulus for this RSA key.

pack-priv static synchronized boolean
protected void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

algorithmback to summary
private Algorithm algorithm
approvedModeOnlyback to summary
private final boolean approvedModeOnly
DEF_ALG_IDback to summary
protected static final AlgorithmIdentifier DEF_ALG_ID
keyMarkerback to summary
private final AsymmetricRSAKey.KeyMarker keyMarker
markersback to summary
private static WeakHashMap<BigInteger, WeakReference<AsymmetricRSAKey.KeyMarker>> markers
modulusback to summary
protected BigInteger modulus
rsaAlgIdentifierback to summary
protected final AlgorithmIdentifier rsaAlgIdentifier
rsaOidsback to summary
private static final Set<ASN1ObjectIdentifier> rsaOids

Constructor Detail

AsymmetricRSAKeyback to summary
pack-priv AsymmetricRSAKey(Algorithm algorithm, BigInteger modulus)
AsymmetricRSAKeyback to summary
pack-priv AsymmetricRSAKey(Algorithm algorithm, AlgorithmIdentifier rsaAlgIdentifier, BigInteger modulus)

Method Detail

canBeUsedback to summary
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:AsymmetricRSAKey.Usage

usage for the RSA key.

Returns:boolean

true if the modulus is already associated with the usage, or has not being used already.

checkApprovedOnlyModeStatusback to summary
protected final void checkApprovedOnlyModeStatus()
getAlgorithmback to summary
public Algorithm getAlgorithm()

Implements org.bouncycastle.crypto.Key.getAlgorithm.

Return the algorithm this RSA key is for.

Returns:Algorithm

the key's algorithm.

getKeyMarkerback to summary
pack-priv static synchronized AsymmetricRSAKey.KeyMarker getKeyMarker(BigInteger modulus)
getModulusback to summary
public BigInteger getModulus()

Return the modulus for this RSA key.

Returns:BigInteger

the key's modulus.

isAlreadySeenback to summary
pack-priv static synchronized boolean isAlreadySeen(BigInteger modulus)
zeroizeback to summary
protected void zeroize()
org.bouncycastle.crypto.asymmetric back to summary

private Class AsymmetricRSAKey.KeyMarker

extends Object
Class Inheritance
  • java.lang.Object
  • org.bouncycastle.crypto.asymmetric.AsymmetricRSAKey.KeyMarker

Field Summary

Modifier and TypeField and Description
private final AtomicReference<AsymmetricRSAKey.Usage>
private final BigInteger

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

keyUsageback to summary
private final AtomicReference<AsymmetricRSAKey.Usage> keyUsage
modulusback to summary
private final BigInteger modulus

Constructor Detail

KeyMarkerback to summary
pack-priv KeyMarker(BigInteger modulus)

Method Detail

canBeUsedback to summary
public boolean canBeUsed(AsymmetricRSAKey.Usage usage)
org.bouncycastle.crypto.asymmetric back to summary

public final Enum AsymmetricRSAKey.Usage

extends Enum<AsymmetricRSAKey.Usage>
Class Inheritance

Specific RSA key usages.

Field Summary

Modifier and TypeField and Description
public static final AsymmetricRSAKey.Usage
ENCRYPT_OR_DECRYPT

Key usage encryption or decryption.

public static final AsymmetricRSAKey.Usage
SIGN_OR_VERIFY

Key usage signing or verification.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static AsymmetricRSAKey.Usage
public static AsymmetricRSAKey.Usage[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ENCRYPT_OR_DECRYPTback to summary
public static final AsymmetricRSAKey.Usage ENCRYPT_OR_DECRYPT

Key usage encryption or decryption.

SIGN_OR_VERIFYback to summary
public static final AsymmetricRSAKey.Usage SIGN_OR_VERIFY

Key usage signing or verification.

Constructor Detail

Usageback to summary
private Usage()

Method Detail

valueOfback to summary
public static AsymmetricRSAKey.Usage valueOf(String name)
valuesback to summary
public static AsymmetricRSAKey.Usage[] values()