public abstract class RsaProvider extends Object
| Modifier and Type | Field and Description |
|---|---|
protected SignatureAlgorithm |
alg |
static SecureRandom |
DEFAULT_SECURE_RANDOM
JJWT's default SecureRandom number generator.
|
protected Key |
key |
| Modifier | Constructor and Description |
|---|---|
protected |
RsaProvider(SignatureAlgorithm alg,
Key key) |
| Modifier and Type | Method and Description |
|---|---|
protected Signature |
createSignatureInstance() |
protected void |
doSetParameter(Signature sig,
PSSParameterSpec spec) |
static KeyPair |
generateKeyPair()
Generates a new RSA secure-random 4096 bit key pair.
|
static KeyPair |
generateKeyPair(int keySizeInBits)
Generates a new RSA secure-randomly key pair of the specified size using JJWT's default
SecureRandom instance. |
static KeyPair |
generateKeyPair(int keySizeInBits,
SecureRandom random)
Generates a new RSA secure-random key pair of the specified size using the given SecureRandom number generator.
|
static KeyPair |
generateKeyPair(SignatureAlgorithm alg)
Generates a new RSA secure-randomly key pair suitable for the specified SignatureAlgorithm using JJWT's
default
SecureRandom instance. |
protected static KeyPair |
generateKeyPair(String jcaAlgorithmName,
int keySizeInBits,
SecureRandom random)
Generates a new secure-random key pair of the specified size using the specified SecureRandom according to the
specified
jcaAlgorithmName. |
protected Signature |
getSignatureInstance() |
protected boolean |
isBouncyCastleAvailable() |
protected void |
setParameter(Signature sig,
PSSParameterSpec spec) |
public static final SecureRandom DEFAULT_SECURE_RANDOM
static {
DEFAULT_SECURE_RANDOM = new SecureRandom();
DEFAULT_SECURE_RANDOM.nextBytes(new byte[64]);
}
nextBytes is called to force the RNG to initialize itself if not already initialized. The
byte array is not used and discarded immediately for garbage collection.
protected final SignatureAlgorithm alg
protected final Key key
protected RsaProvider(SignatureAlgorithm alg, Key key)
protected Signature createSignatureInstance()
protected void setParameter(Signature sig, PSSParameterSpec spec)
protected void doSetParameter(Signature sig, PSSParameterSpec spec) throws InvalidAlgorithmParameterException
public static KeyPair generateKeyPair()
generateKeyPair(int).generateKeyPair(int),
generateKeyPair(int, SecureRandom),
generateKeyPair(String, int, SecureRandom)public static KeyPair generateKeyPair(int keySizeInBits)
SecureRandom instance. This is a convenience method that immediately
delegates to generateKeyPair(int, SecureRandom).keySizeInBits - the key size in bits (NOT bytes).generateKeyPair(),
generateKeyPair(int, SecureRandom),
generateKeyPair(String, int, SecureRandom)public static KeyPair generateKeyPair(SignatureAlgorithm alg)
SecureRandom instance. This is a convenience method
that immediately delegates to generateKeyPair(int) based on the relevant key size for the specified
algorithm.alg - the signature algorithm to inspect to determine a size in bits.generateKeyPair(),
generateKeyPair(int, SecureRandom),
generateKeyPair(String, int, SecureRandom)public static KeyPair generateKeyPair(int keySizeInBits, SecureRandom random)
generateKeyPair(String, int, SecureRandom)
using RSA as the jcaAlgorithmName argument.keySizeInBits - the key size in bits (NOT bytes)random - the secure random number generator to use during key generation.generateKeyPair(),
generateKeyPair(int),
generateKeyPair(String, int, SecureRandom)protected static KeyPair generateKeyPair(String jcaAlgorithmName, int keySizeInBits, SecureRandom random)
jcaAlgorithmName.jcaAlgorithmName - the name of the JCA algorithm to use for key pair generation, for example, RSA.keySizeInBits - the key size in bits (NOT bytes)random - the SecureRandom generator to use during key generation.jcaAlgorithmName.generateKeyPair(),
generateKeyPair(int),
generateKeyPair(int, SecureRandom)protected Signature getSignatureInstance() throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionprotected boolean isBouncyCastleAvailable()
Copyright © 2020. All rights reserved.