public abstract class RsaProvider
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected SignatureAlgorithm |
alg |
static java.security.SecureRandom |
DEFAULT_SECURE_RANDOM
JJWT's default SecureRandom number generator.
|
protected java.security.Key |
key |
| Modifier | Constructor and Description |
|---|---|
protected |
RsaProvider(SignatureAlgorithm alg,
java.security.Key key) |
| Modifier and Type | Method and Description |
|---|---|
protected java.security.Signature |
createSignatureInstance() |
protected void |
doSetParameter(java.security.Signature sig,
java.security.spec.PSSParameterSpec spec) |
static java.security.KeyPair |
generateKeyPair()
Generates a new RSA secure-random 4096 bit key pair.
|
static java.security.KeyPair |
generateKeyPair(int keySizeInBits)
Generates a new RSA secure-randomly key pair of the specified size using JJWT's default
SecureRandom instance. |
static java.security.KeyPair |
generateKeyPair(int keySizeInBits,
java.security.SecureRandom random)
Generates a new RSA secure-random key pair of the specified size using the given SecureRandom number generator.
|
static java.security.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 java.security.KeyPair |
generateKeyPair(java.lang.String jcaAlgorithmName,
int keySizeInBits,
java.security.SecureRandom random)
Generates a new secure-random key pair of the specified size using the specified SecureRandom according to the
specified
jcaAlgorithmName. |
protected java.security.Signature |
getSignatureInstance() |
protected boolean |
isBouncyCastleAvailable() |
protected void |
setParameter(java.security.Signature sig,
java.security.spec.PSSParameterSpec spec) |
public static final java.security.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 java.security.Key key
protected RsaProvider(SignatureAlgorithm alg, java.security.Key key)
protected java.security.Signature createSignatureInstance()
protected void setParameter(java.security.Signature sig,
java.security.spec.PSSParameterSpec spec)
protected void doSetParameter(java.security.Signature sig,
java.security.spec.PSSParameterSpec spec)
throws java.security.InvalidAlgorithmParameterException
java.security.InvalidAlgorithmParameterExceptionpublic static java.security.KeyPair generateKeyPair()
generateKeyPair(int).generateKeyPair(int),
generateKeyPair(int, SecureRandom),
generateKeyPair(String, int, SecureRandom)public static java.security.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 java.security.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 java.security.KeyPair generateKeyPair(int keySizeInBits,
java.security.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 java.security.KeyPair generateKeyPair(java.lang.String jcaAlgorithmName,
int keySizeInBits,
java.security.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 java.security.Signature getSignatureInstance()
throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmExceptionprotected boolean isBouncyCastleAvailable()
Copyright © 2014-2022 jsonwebtoken.io. All Rights Reserved.