@ThreadSafe public class PasswordBasedEncrypter extends PasswordBasedCryptoProvider implements JWEEncrypter
JWE objects
.
Expects a password.
See RFC 7518 section 4.8 for more information.
This class is thread-safe.
Supports the following key management algorithms:
Supports the following content encryption algorithms:
Modifier and Type | Field and Description |
---|---|
static int |
MIN_RECOMMENDED_ITERATION_COUNT
The minimum recommended iteration count (1000).
|
static int |
MIN_SALT_LENGTH
The minimum salt length (8 bytes).
|
SUPPORTED_ALGORITHMS, SUPPORTED_ENCRYPTION_METHODS
Constructor and Description |
---|
PasswordBasedEncrypter(byte[] password,
int saltLength,
int iterationCount)
Creates a new password-based encrypter.
|
PasswordBasedEncrypter(String password,
int saltLength,
int iterationCount)
Creates a new password-based encrypter.
|
Modifier and Type | Method and Description |
---|---|
JWECryptoParts |
encrypt(JWEHeader header,
byte[] clearText)
Encrypts the specified clear text of a
JWE object . |
int |
getIterationCount()
Returns the pseudo-random function (PRF) iteration count.
|
JWEJCAContext |
getJCAContext()
Returns the Java Cryptography Architecture (JCA) context.
|
int |
getSaltLength()
Returns the length of the generated cryptographic salts.
|
Set<EncryptionMethod> |
supportedEncryptionMethods()
Returns the names of the supported encryption methods by the JWE
provier.
|
Set<JWEAlgorithm> |
supportedJWEAlgorithms()
Returns the names of the supported algorithms by the JWE provider
instance.
|
getPassword, getPasswordString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
supportedEncryptionMethods, supportedJWEAlgorithms
getJCAContext
public static final int MIN_SALT_LENGTH
public static final int MIN_RECOMMENDED_ITERATION_COUNT
public PasswordBasedEncrypter(byte[] password, int saltLength, int iterationCount)
password
- The password bytes. Must not be empty or
null
.saltLength
- The length of the generated cryptographic
salts, in bytes. Must be at least 8 bytes.iterationCount
- The pseudo-random function (PRF) iteration
count. Must be at least 1000.public PasswordBasedEncrypter(String password, int saltLength, int iterationCount)
password
- The password, as a UTF-8 encoded string. Must
not be empty or null
.saltLength
- The length of the generated cryptographic
salts, in bytes. Must be at least 8 bytes.iterationCount
- The pseudo-random function (PRF) iteration
count. Must be at least 1000.public JWECryptoParts encrypt(JWEHeader header, byte[] clearText) throws JOSEException
JWEEncrypter
JWE object
.encrypt
in interface JWEEncrypter
header
- The JSON Web Encryption (JWE) header. Must specify
a supported JWE algorithm and method. Must not be
null
.clearText
- The clear text to encrypt. Must not be null
.JOSEException
- If the JWE algorithm or method is not
supported or if encryption failed for some
other internal reason.public int getSaltLength()
public int getIterationCount()
public Set<JWEAlgorithm> supportedJWEAlgorithms()
JWEProvider
alg
JWE header parameter.supportedJWEAlgorithms
in interface JWEProvider
public Set<EncryptionMethod> supportedEncryptionMethods()
JWEProvider
enc
JWE header parameter.supportedEncryptionMethods
in interface JWEProvider
public JWEJCAContext getJCAContext()
JCAAware
getJCAContext
in interface JCAAware<JWEJCAContext>
null
.Copyright © 2021 Connect2id Ltd.. All rights reserved.