public abstract class RsaProvider
extends java.lang.Object
限定符和类型 | 字段和说明 |
---|---|
protected SignatureAlgorithm |
alg |
static java.security.SecureRandom |
DEFAULT_SECURE_RANDOM
JJWT's default SecureRandom number generator.
|
protected java.security.Key |
key |
限定符 | 构造器和说明 |
---|---|
protected |
RsaProvider(SignatureAlgorithm alg,
java.security.Key key) |
限定符和类型 | 方法和说明 |
---|---|
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. 4096 bits is JJWT's current recommended minimum key size
for use in modern applications (during or after year 2015).
|
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.
|
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.InvalidAlgorithmParameterException
public 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(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.NoSuchAlgorithmException
protected boolean isBouncyCastleAvailable()