public abstract class EllipticCurveProvider 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 |
EllipticCurveProvider(SignatureAlgorithm alg,
Key key) |
| Modifier and Type | Method and Description |
|---|---|
protected Signature |
createSignatureInstance() |
static KeyPair |
generateKeyPair()
Generates a new secure-random key pair assuming strength enough for the
SignatureAlgorithm.ES512 algorithm. |
static KeyPair |
generateKeyPair(SignatureAlgorithm alg)
Generates a new secure-random key pair of sufficient strength for the specified Elliptic Curve
SignatureAlgorithm (must be one of ES256, ES384 or ES512) using JJWT's default SecureRandom instance. |
static KeyPair |
generateKeyPair(SignatureAlgorithm alg,
SecureRandom random)
Generates a new secure-random key pair of sufficient strength for the specified Elliptic Curve
SignatureAlgorithm (must be one of ES256, ES384 or ES512) using the specified SecureRandom random number generator. |
static KeyPair |
generateKeyPair(String jcaAlgorithmName,
String jcaProviderName,
SignatureAlgorithm alg,
SecureRandom random)
Generates a new secure-random key pair of sufficient strength for the specified Elliptic Curve
SignatureAlgorithm (must be one of ES256, ES384 or ES512) using the specified SecureRandom random number generator via the specified JCA provider and algorithm name. |
protected Signature |
getSignatureInstance() |
protected boolean |
isBouncyCastleAvailable() |
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 EllipticCurveProvider(SignatureAlgorithm alg, Key key)
public static KeyPair generateKeyPair()
SignatureAlgorithm.ES512 algorithm. This is a convenience method that immediately delegates to generateKeyPair(SignatureAlgorithm) using SignatureAlgorithm.ES512 as the method argument.SignatureAlgorithm.ES512 algorithm.generateKeyPair(SignatureAlgorithm),
generateKeyPair(SignatureAlgorithm, SecureRandom),
generateKeyPair(String, String, SignatureAlgorithm, SecureRandom)public static KeyPair generateKeyPair(SignatureAlgorithm alg)
SignatureAlgorithm (must be one of ES256, ES384 or ES512) using JJWT's default SecureRandom instance. This is a convenience method that immediately
delegates to generateKeyPair(SignatureAlgorithm, SecureRandom).alg - the algorithm indicating strength, must be one of ES256, ES384 or ES512SignatureAlgorithm (must be one of ES256, ES384 or ES512) using JJWT's default SecureRandom instance.generateKeyPair(),
generateKeyPair(SignatureAlgorithm, SecureRandom),
generateKeyPair(String, String, SignatureAlgorithm, SecureRandom)public static KeyPair generateKeyPair(SignatureAlgorithm alg, SecureRandom random)
SignatureAlgorithm (must be one of ES256, ES384 or ES512) using the specified SecureRandom random number generator. This is a convenience method that immediately delegates to generateKeyPair(String, String, SignatureAlgorithm, SecureRandom) using "ECDSA" as the jcaAlgorithmName and "BC" as the jcaProviderName since EllipticCurve requires the use of an
external JCA provider (BC stands for BouncyCastle. This will work as expected as long as the
BouncyCastle dependency is in the runtime classpath.alg - alg the algorithm indicating strength, must be one of ES256, ES384 or ES512random - the SecureRandom generator to use during key generation.SignatureAlgorithm (must be one of ES256, ES384 or ES512) using the specified SecureRandom random number generator.generateKeyPair(),
generateKeyPair(SignatureAlgorithm),
generateKeyPair(String, String, SignatureAlgorithm, SecureRandom)public static KeyPair generateKeyPair(String jcaAlgorithmName, String jcaProviderName, SignatureAlgorithm alg, SecureRandom random)
SignatureAlgorithm (must be one of ES256, ES384 or ES512) using the specified SecureRandom random number generator via the specified JCA provider and algorithm name.jcaAlgorithmName - the JCA name of the algorithm to use for key pair generation, for example, ECDSA.jcaProviderName - the JCA provider name of the algorithm implementation, for example BC for
BouncyCastle.alg - alg the algorithm indicating strength, must be one of ES256, ES384 or
ES512random - the SecureRandom generator to use during key generation.SignatureAlgorithm (must be one of ES256, ES384 or ES512) using the specified SecureRandom random number generator via the specified JCA provider and algorithm name.generateKeyPair(),
generateKeyPair(SignatureAlgorithm),
generateKeyPair(SignatureAlgorithm, SecureRandom)protected Signature createSignatureInstance()
protected Signature getSignatureInstance() throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionprotected boolean isBouncyCastleAvailable()
Copyright © 2015. All rights reserved.