public class PBKDF2KeyAndParameterSpec extends PBEKeyAndParameterSpec
parameters
specify salt value, iteration count,
length of the to-be-derived key (optional), and (MAC based) pseudo random function
(default: HMCA/SHA1) to be used by the PBKDF2 function for deriving a secret key
from a password according to
PKCS#5 v2.1.:
PBKDF2-params ::= SEQUENCE { salt CHOICE { specified OCTET STRING, otherSource AlgorithmIdentifier {{PBKDF2-SaltSources}} }, iterationCount INTEGER (1..MAX), keyLength INTEGER (1..MAX) OPTIONAL, prf AlgorithmIdentifier {{PBKDF2-PRFs}} DEFAULT algid-hmacWithSHA1 }The PBKDF2-params ASN.1 definition allows to specify the salt value as OCTET STRING or otherSource algorithm id. However, this implementation does not support the otherSource alternative because until now it is not yet fully specified by PKCS#5 (version v2.1).
Constructor and Description |
---|
PBKDF2KeyAndParameterSpec(byte[] password,
byte[] salt,
int iterationCount,
int derivedKeyLength)
Creates a PBKDF2KeyAndParameterSpec from given password and parameters.
|
PBKDF2KeyAndParameterSpec(byte[] password,
PBKDF2ParameterSpec pbkdf2Params)
Creates a PBKDF2KeyAndParameterSpec from given password and parameters.
|
PBKDF2KeyAndParameterSpec(char[] password,
PBKDF2ParameterSpec pbkdf2Params)
Creates a PBKDF2KeyAndParameterSpec from given password and parameters.
|
Modifier and Type | Method and Description |
---|---|
AlgorithmID |
getPrf()
Gets the pseudo random function to be used.
|
void |
setPrf(AlgorithmID prf)
Sets the pseudo random function to be used.
|
finalize, getDerivedKeyLength, getIterationCount, getPassword, getSalt
public PBKDF2KeyAndParameterSpec(byte[] password, byte[] salt, int iterationCount, int derivedKeyLength)
password
- the (encoded) passwordsalt
- the saltiterationCount
- the iteration countderivedKeyLength
- the length (number of bytes) the derived key should havejava.lang.IllegalArgumentException
- if password or salt are null, or iteration count or derived key length are < 1public PBKDF2KeyAndParameterSpec(byte[] password, PBKDF2ParameterSpec pbkdf2Params)
password
- the (encoded) passwordpbkdf2Params
- the PBKDF2 parameters (salt, iteration count, length of the derived key)public PBKDF2KeyAndParameterSpec(char[] password, PBKDF2ParameterSpec pbkdf2Params) throws UTF8CodingException
password
- the as char arraypbkdf2Params
- the PBKDF2 parameters (salt, iteration count, length of the derived key)UTF8CodingException
- if the password cannot be UTF-8 encodedpublic void setPrf(AlgorithmID prf)
prf
- the pseudo random MAC function to be usedpublic AlgorithmID getPrf()
null
if no prf has been set (in this case the default prf
HMAC/SHA1
shall
be used)