de.flexiprovider.core.kdf
Class KDF2
java.lang.Object
|
+--de.flexiprovider.api.KeyDerivation
|
+--de.flexiprovider.core.kdf.KDF2
- public class KDF2
- extends KeyDerivation
KDF2 is a key derivation function descriped in IEEE 1363a-2004. It is based
on the constructions given in ANSI X9.42:2001 and X9.63.
KDF2 can be used as follows:
KeyDerivation kdf = Registry.getKeyDerivation("KDF2");
kdf.init(secretKey.toByteArray());
kdf.setSharedInfo(sharedInfo.toByteArray());
byte[] derivedKey = kdf.doFinal(int keyDataLen);
- Author:
- Jochen Hechler, Marcus Stögbauer, Martin Döring
|
Constructor Summary |
KDF2()
Constructor. |
|
Method Summary |
byte[] |
deriveKey(int keySize)
This function does the actual key derivation. |
void |
init(byte[] secret,
AlgorithmParameterSpec params)
Initialize the KDF with a secret and parameters. |
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
KDF2
public KDF2()
- Constructor. Set the message digest.
init
public void init(byte[] secret,
AlgorithmParameterSpec params)
throws InvalidKeyException,
InvalidAlgorithmParameterException
- Initialize the KDF with a secret and parameters. The parameters have to
be null or an instance of
KDFParameterSpec.
- Overrides:
init in class KeyDerivation
- Parameters:
secret - the secret from which to derive the keyparams - the parameters- Throws:
InvalidKeyException - if the secret is null.InvalidAlgorithmParameterException - if the parameters are not null and not an
instance of KDFParameterSpec.
deriveKey
public byte[] deriveKey(int keySize)
- This function does the actual key derivation. It uses the shared key
value z and the given key size, with the desired hash function
H and the optional SharedInfo and computes
Hash(i) = H(Z || counter || [SharedInfo])
where the counter is a 32-bit string. The counter is increased by one in
for every round.
- Overrides:
deriveKey in class KeyDerivation
- Parameters:
keySize - the desired length of the derived key- Returns:
- the derived key with the specified length, or null if
the key size is < 0.