de.flexiprovider.core.kdf
Class X963

java.lang.Object
  |
  +--de.flexiprovider.api.KeyDerivation
        |
        +--de.flexiprovider.core.kdf.X963

public class X963
extends KeyDerivation

X963 is a key derivation function defined in ANSI X9.63.

X963 can be used as follows:

 KeyDerivation kdf = Registry.getKeyDerivation("X963");
 kdf.init(secretKey.toByteArray());
 kdf.setSharedInfo(byte[] sharedInfo);
 byte[] derivedKey = kdf.doFinal(int keyDataLen);
 

Author:
Jochen Hechler, Marcus Stögbauer, Martin Döring

Constructor Summary
X963()
          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
 

Constructor Detail

X963

public X963()
Constructor. Set the message digest.
Method Detail

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 key
params - 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 from above and the given key size with the desired hash function H and the optional SharedInfo and computes
 Hash<sup>i</sup> = H(Z || counter || [SharedInfo])
 
where the counter is a 32 bit string.
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.