public class PBKDF2ParameterSpec
extends javax.crypto.spec.PBEParameterSpec
implements java.lang.Cloneable
PBKDF2 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:
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 |
---|
PBKDF2ParameterSpec(byte[] salt,
int iterationCount,
int derivedKeyLength)
Creates a PBKDF2 parameter set for PBKDF2 key derivation.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns a clone of this PBKDF2ParameterSpec.
|
int |
getDerivedKeyLength()
Returns the length the derived key should have.
|
int |
getIterationCount()
Returns the iteration count.
|
AlgorithmID |
getPrf()
Gets the pseudo random function to be used.
|
byte[] |
getSalt()
Returns the salt.
|
void |
setPrf(AlgorithmID prf)
Sets the pseudo random function to be used.
|
java.lang.String |
toString()
Returns a String representation of this PBKDF2ParameterSpec object.
|
public PBKDF2ParameterSpec(byte[] salt, int iterationCount, int derivedKeyLength)
salt
- the saltiterationCount
- the iteration countderivedKeyLength
- the length the derived key should havejava.lang.IllegalArgumentException
- if salt is null, or iteration count or derived key length are < 1public void setPrf(AlgorithmID prf)
prf
- the pseudo random MAC function to be usedpublic AlgorithmID getPrf()
HMAC/SHA1
)public int getIterationCount()
getIterationCount
in class javax.crypto.spec.PBEParameterSpec
0
if no
iteration count has been setpublic final int getDerivedKeyLength()
0
if no
key length has been setpublic final byte[] getSalt()
getSalt
in class javax.crypto.spec.PBEParameterSpec
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object