public class PBKDF2KeyDerivation extends Object implements ConfigurableKey
ConfigurableKey
implementation that derives a secret key from the input password using the PBKDF2 key
deriviation algorithm. The following system properties can be used to configure how the key is derived:
org.forgerock.openam.encryption.key.digest
- the message digest (hash) algorithm to use with
PBKDF2. Defaults to "SHA1".org.forgerock.openam.encryption.key.iterations
- the number of iterations of PBKDF2 to apply
when generating keys. Must be at least 10,000, but should typically be as large as you can compute in a
reasonable time.Constructor and Description |
---|
PBKDF2KeyDerivation()
Default private constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the configured password for this key derivation function.
|
PBEKey |
deriveSecretKey(int keySize)
Derives a secret key of the requested size using a fresh random salt and the configured password and iteration
count.
|
PBEKey |
deriveSecretKey(int keySize,
byte[] salt)
Derives a secret key of the requested using using the given salt and the configured password and iteration count.
|
void |
setPassword(String password)
Sets password-based key to use
|
public PBKDF2KeyDerivation()
IllegalStateException
- if the configured message digest or iteration count is invalid.public void setPassword(String password) throws Exception
ConfigurableKey
setPassword
in interface ConfigurableKey
Exception
public PBEKey deriveSecretKey(int keySize)
keySize
- the size of the key (in bits) to generate.public PBEKey deriveSecretKey(int keySize, byte[] salt)
keySize
- the size of the key (in bits) to generate.salt
- the salt to use to generate the key.public void clear()
Copyright © 2010–2025 Open Identity Platform Community. All rights reserved.