public class PBKDF2KeyAndParameterSpec extends PBEKeyAndParameterSpec implements ASN1Type
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 }
For the salt CHOICE option, this implementation always uses the specified
OCTET STRING, and does not currently work with any other SaltSources.
For the PRF AlgorithmIdentifier, the following values are supported:
PBKDF2-PRFs ALGORITHM-IDENTIFIER ::= {
{NULL IDENTIFIED BY id-hmacWithSHA1},
{NULL IDENTIFIED BY id-hmacWithSHA224},
{NULL IDENTIFIED BY id-hmacWithSHA256},
{NULL IDENTIFIED BY id-hmacWithSHA384},
{NULL IDENTIFIED BY id-hmacWithSHA512},
}
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_ITERATION_COUNT
The default iteration count
|
static int |
DEFAULT_KEY_LENGTH
The default key length in bytes
|
static int |
DEFAULT_SALT_LENGTH
This is the default SALT length in bytes
|
static int |
MIN_ITERATION_COUNT
The minimum allowed iteration count
|
static int |
MIN_KEY_LENGTH
The Minimum key length in bytes
|
| Constructor and Description |
|---|
PBKDF2KeyAndParameterSpec(ASN1Object algorithmParameter,
SecureStringBuffer password,
int keyLength)
Creates a PBEKDF2 parameter specification from an ASN1Object.
|
PBKDF2KeyAndParameterSpec(javax.crypto.spec.PBEKeySpec spec,
java.lang.String prf) |
PBKDF2KeyAndParameterSpec(SecureStringBuffer password)
The constructor with recommended parameter settings.
|
PBKDF2KeyAndParameterSpec(SecureStringBuffer password,
byte[] inputSalt,
int iterationCount,
int keyLength,
AlgorithmID kdfAlg)
The PBKDF2KeyAndParameterSpec constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
decode(ASN1Object obj)
Decodes the specified PBEKCS2KeyAndParameterSpec
|
AlgorithmID |
getKDF() |
byte[] |
getPassword()
Deprecated.
use getSecurePassword
|
SecureStringBuffer |
getSecurePassword() |
ASN1Object |
toASN1Object()
Returns this PBEKDF2 parameter specification as an ASN1Object.
|
getDerivedKeyLength, getIterationCount, getSaltpublic static final int DEFAULT_ITERATION_COUNT
public static final int MIN_ITERATION_COUNT
public static final int DEFAULT_KEY_LENGTH
public static final int MIN_KEY_LENGTH
public static final int DEFAULT_SALT_LENGTH
public PBKDF2KeyAndParameterSpec(SecureStringBuffer password)
This default constructor will use the following default properties
password - the password as a SecureStringBuffer used to derive the Keypublic PBKDF2KeyAndParameterSpec(SecureStringBuffer password, byte[] inputSalt, int iterationCount, int keyLength, AlgorithmID kdfAlg)
If no salt is specified, a randomly generated value of length 16 bytes will be used. If iteration count is less than 1 then an iteration count of 1 will be used. If the keyLength specified is lower than MIN_KEY_LENGTH of 4 then the MIN_KEY_LENGTH will be used.
inputSalt - The bytes of salt to use for this parameterSpeciterationCount - The iteration count. If a value less than
MIN_ITERATION_COUNT is specified, then the
MIN_ITERATION_COUNT will be usedkeyLength - of the key that will be generated from the password.
This value will correspond to the type of key being
generated. For example, if the password is used to
derive an AES-256 key, the length of the key would be
256 bitskdfAlg - The MacAlgorithm to use for the PBKDF2 algorithmpublic PBKDF2KeyAndParameterSpec(ASN1Object algorithmParameter, SecureStringBuffer password, int keyLength) throws CodingException
IaikPBEParameterSpec params = new IaikPBEParameterSpec(encryptionAlg.getParameter());
algorithmParameter - the algorithm parameters as ASN1Objectpassword - the SecureStringBuffer containing the password used for the PBE algorithmkeyLength - the length of the keyCodingException - if the parameter could not be decodedpublic PBKDF2KeyAndParameterSpec(javax.crypto.spec.PBEKeySpec spec,
java.lang.String prf)
public AlgorithmID getKDF()
public void decode(ASN1Object obj) throws CodingException
decode in interface ASN1Typeobj - The ASN1Objet to decode fromCodingException - if the ASN1Object could not be parsedpublic byte[] getPassword()
PBEKeyAndParameterSpecgetPassword in class PBEKeyAndParameterSpecpublic SecureStringBuffer getSecurePassword()
public ASN1Object toASN1Object()
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 }
toASN1Object in interface ASN1Type