public class PBKDF2
extends javax.crypto.KeyGeneratorSpi
KeyGenerator Service Provider
Interface (SPI) for the
password-based-key-derivation-function-2
from the PKCS #5: Password-Based Cryptography Specification Version 2.0 (RFC 2898).
Use this class as you can read here:
KeyGenerator pKCS5_PBKDF2 = null;
try {
pKCS5_PBKDF2 = KeyGenerator.getInstance("PBKDF2", "IAIK");
} catch (Exception e) {
....
}
iaik.security.spec.PBEKeyAndParameterSpec parameterSpec;
parameterSpec = new PBEKeyAndParameterSpec(password,
salt,
iterationCount,
derivedKeyLength);
try {
pKCS5_PBKDF2.init(parameterSpec, null);
} catch (InvalidAlgorithmParameterException e) {
...
}
SecretKey derivedKey;
derivedKey = pKCS5_PBKDF2.generateKey();
This class SHOULD NOT be used directly; it should only be used through the JCA/JCE.
KeyGenerator| Constructor and Description |
|---|
PBKDF2()
The constructor; creates a new instance of the PBKDF2 key generation
algorithm.
|
| Modifier and Type | Method and Description |
|---|---|
javax.crypto.SecretKey |
engineGenerateKey()
Generates a secret key.
|
void |
engineInit(java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
Initializes the key generator with the specified parameter set and a
user-provided source of randomness.
|
void |
engineInit(int int1,
java.security.SecureRandom secureRandom)
Not supported.
|
void |
engineInit(java.security.SecureRandom secureRandom)
Not supported.
|
public PBKDF2()
Applications should not use this constructor, instead the key generation
algorithm should be requested from the appropriate JCA/JCE cryptographic
service provider as follows:
KeyGenerator.getInstance("PBKDF2", "IAIK").
public javax.crypto.SecretKey engineGenerateKey()
engineGenerateKey in class javax.crypto.KeyGeneratorSpiFips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationspublic void engineInit(int int1,
java.security.SecureRandom secureRandom)
engineInit in class javax.crypto.KeyGeneratorSpikeysize - [FIPS 140-2 data input] the keysize. This is an
algorithm-specific metric, specified in number of bits.random - [FIPS 140-2 control input] the source of randomness for this
key generatorjava.security.InvalidParameterException - [FIPS 140-2 status output] if the keysize is wrong or not
supported.InternalErrorException - [FIPS 140-2 status output] always thrownpublic void engineInit(java.security.SecureRandom secureRandom)
engineInit in class javax.crypto.KeyGeneratorSpikeysize - [FIPS 140-2 data input] the keysize. This is an
algorithm-specific metric, specified in number of bits.java.security.InvalidParameterException - [FIPS 140-2 status output] if the keysize is wrong or not
supported.InternalErrorException - [FIPS 140-2 status output] always thrownpublic void engineInit(java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
throws java.security.InvalidAlgorithmParameterException
engineInit in class javax.crypto.KeyGeneratorSpiparams - [FIPS 140-2 data input] the key generation parametersrandom - [FIPS 140-2 control input] the source of randomness for this
key generatorjava.security.InvalidAlgorithmParameterException - [FIPS 140-2 status output] if params is
inappropriate for this key generatorFips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operations