public static class KeyDerivationFunction.Default extends Object implements KeyDerivationFunction
KeyDerivationFunction.Default| Modifier and Type | Method and Description |
|---|---|
byte[] |
derive(byte[] salt,
byte[] ikm,
int costFactor,
byte[] infoParam,
int outLengthByte)
Derive high entropy key material from given salt, user password.
|
byte[] |
derive(byte[] salt,
char[] password,
int costFactor,
byte[] infoParam,
int outLengthByte)
Derive high entropy key material from given salt, user password.
|
public Default(Version version)
public byte[] derive(byte[] salt,
char[] password,
int costFactor,
byte[] infoParam,
int outLengthByte)
KeyDerivationFunctionThe output key material can be used as secret key like that:
byte[] okm = kdf.derive(...);
SecretKey secretKey = new SecretKeySpec(okm,"AES");
This will create a AES key from the okm (output key material).
derive in interface KeyDerivationFunctionsalt - at least 16 byte long nonce (number used once); salt is not required to be secretpassword - user provided passwordcostFactor - exponential cost (log2 factor) between 4 and 31 e.g. 12 -->
2^12 = 4,096 iterations (higher == slower == more secure)infoParam - optional parameter that can be used to pin the key material to a specific context (e.g.
creating a MAC and AES key from same password, just pass "mac".getBytes() and
"aes".getBytes() as parameter. Can be null.outLengthByte - how many bytes long the resulting key material should be (usually 16 or 32 bytes)public byte[] derive(byte[] salt,
byte[] ikm,
int costFactor,
byte[] infoParam,
int outLengthByte)
KeyDerivationFunctionThe output key material can be used as secret key like that:
byte[] okm = kdf.derive(...);
SecretKey secretKey = new SecretKeySpec(okm,"AES");
This will create a AES key from the okm (output key material).
derive in interface KeyDerivationFunctionsalt - at least 16 byte long nonce (number used once); salt is not required to be secretikm - user provided password as byte array or other password reheated entropycostFactor - exponential cost (log2 factor) between 4 and 31 e.g. 12 -->
2^12 = 4,096 iterations (higher == slower == more secure)infoParam - optional parameter that can be used to pin the key material to a specific context (e.g.
creating a MAC and AES key from same password, just pass "mac".getBytes() and
"aes".getBytes() as parameter. Can be null.outLengthByte - how many bytes long the resulting key material should be (usually 16 or 32 bytes)Copyright © 2018. All rights reserved.