public class KDF3 extends KDF2
This class implements the Key Derivation Function (KDF) 3, defined in ANSI X9.44. A KDF is a function which derives keying material of desired length from a shared secret and additional, optional information. The KDF itself is further parameterized with, e.g., a cryptographic hash function.
An application which wants to use KDF3 has to obtain it via the KeyGenerator engine class.
KeyGenerator kdf3 = KeyGenerator.getInstance("KDF3", "IAIK")
A caller has to configure the KDF3 with a cryptographic hash function, like
SHA2-256, SHA3-256,...
. For that use KDF3ParameterSpec.
An example usage may look like this:
AlgorithmID hashAlg = ...; int keyLength = ...; byte[] secretValue = ... KDF3ParameterSpec spec = new KDF3ParameterSpec(hashAlg, keyLength); spec.setSecretValue(secretValue); kg.init(spec); SecretKey key = (SecretKey) kg.generateKey();
If an implementation tries to use the KDF3 without a call to KDF1.engineInit(AlgorithmParameterSpec, SecureRandom), the class will throw an exception.
This class extends KDF2, because of the similarity of their workflow.
KDF3ParameterSpec
Modifier and Type | Field and Description |
---|---|
static ObjectID |
OID
The ASN.1 object identifier (1.3.133.16.840.9.44.1.2) for the KDF3 key derivation
function.
|
Constructor and Description |
---|
KDF3() |
Modifier and Type | Method and Description |
---|---|
protected javax.crypto.SecretKey |
engineGenerateKey()
Generates a key according to the specification of KDF3 with the provided
information.
|
protected HashBasedGenerationFunction |
generateHBGF(KDF1ParameterSpec spec)
Intern helper function to create an instance of HashBasedGenerationFunction.
|
protected java.lang.String |
name()
Outputs the algorithm name.
|
engineInit, engineInit, engineInit
public static final ObjectID OID
protected java.lang.String name()
protected HashBasedGenerationFunction generateHBGF(KDF1ParameterSpec spec)
generateHBGF
in class KDF2
protected javax.crypto.SecretKey engineGenerateKey()
Generates a key according to the specification of KDF3 with the provided information. This method returns an instance of SecretKey. To obtain the secret, call SecretKey.getEncoded().
engineGenerateKey
in class KDF2
InternalErrorException
- if the caller did not initialize the object accordingly.