APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.util

public final Class PBKDF2Parameters

extends Object
Class Inheritance
Imports
java.io.IOException, sun.security.x509.AlgorithmId

This class implements the parameter set used with password-based key derivation function 2 (PBKDF2), which is defined in PKCS#5 as follows:

PBKDF2Algorithms ALGORITHM-IDENTIFIER ::=
  { {PBKDF2-params IDENTIFIED BY id-PBKDF2}, ...}

id-PBKDF2 OBJECT IDENTIFIER ::= {pkcs-5 12}

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
}

PBKDF2-SaltSources ALGORITHM-IDENTIFIER ::= { ... }

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}, ... }

algid-hmacWithSHA1 AlgorithmIdentifier {{PBKDF2-PRFs}} ::=
    {algorithm id-hmacWithSHA1, parameters NULL : NULL}

id-hmacWithSHA1 OBJECT IDENTIFIER ::= {digestAlgorithm 7}

For more information, see
RFC 8018:
PKCS #5: Password-Based Cryptography Specification.

Field Summary

Modifier and TypeField and Description
private final int
private final int
private final String
private final byte[]

Constructor Summary

AccessConstructor and Description
public
PBKDF2Parameters(DerValue
the DER encoding of the parameter block
pBKDF2_params
)

Initialize PBKDF2Parameters from a DER encoded parameter block.

Method Summary

Modifier and TypeMethod and Description
public static byte[]
encode(byte[] salt, int iterationCount, int keyLength, String kdfHmac)

public static byte[]
encode(byte[] salt, int iterationCount, int keyLength, ObjectIdentifier prf)

public int

Returns:

the iteration count
getIterationCount
()

Returns the iteration count.

public int

Returns:

size of key generated by PBKDF2, or -1 if not found/set
getKeyLength
()

Returns size of key generated by PBKDF2, or -1 if not found/set.

public String

Returns:

name of Hmac
getPrfAlgo
()

Returns name of Hmac.

public byte[]

Returns:

the salt
getSalt
()

Returns the salt.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

iterationCountback to summary
private final int iterationCount
keyLengthback to summary
private final int keyLength
prfAlgoback to summary
private final String prfAlgo
saltback to summary
private final byte[] salt

Constructor Detail

PBKDF2Parametersback to summary
public PBKDF2Parameters(DerValue pBKDF2_params) throws IOException

Initialize PBKDF2Parameters from a DER encoded parameter block.

Parameters
pBKDF2_params:DerValue

the DER encoding of the parameter block

Exceptions
IOException:
for parsing errors in the input stream

Method Detail

encodeback to summary
public static byte[] encode(byte[] salt, int iterationCount, int keyLength, String kdfHmac)
encodeback to summary
public static byte[] encode(byte[] salt, int iterationCount, int keyLength, ObjectIdentifier prf)
getIterationCountback to summary
public int getIterationCount()

Returns the iteration count.

Returns:int

the iteration count

getKeyLengthback to summary
public int getKeyLength()

Returns size of key generated by PBKDF2, or -1 if not found/set.

Returns:int

size of key generated by PBKDF2, or -1 if not found/set

getPrfAlgoback to summary
public String getPrfAlgo()

Returns name of Hmac.

Returns:String

name of Hmac

getSaltback to summary
public byte[] getSalt()

Returns the salt.

Returns:byte[]

the salt