public abstract class KDFSpi extends Object
KDF) class. All the abstract methods in this class must be implemented by each cryptographic service provider who wishes to supply the implementation of a particular key derivation function algorithm.
Implementations must provide a public constructor which accepts a
KDFParameters object if they depend on the default implementation of Provider.Service.newInstance to construct KDFSpi instances. The constructor must call super(params) passing the parameters supplied. The constructor must also throw an InvalidAlgorithmParameterException if the supplied parameters are inappropriate. If a KDF object is instantiated with one of the getInstance methods that contains a KDFParameters parameter, the user-provided KDFParameters object will be passed to the constructor of the KDFSpi implementation. Otherwise, if it is instantiated with one of the getInstance methods without a KDFParameters parameter, a null value will be passed to the constructor.
Implementations which do not support KDFParameters must require null to be passed, otherwise an InvalidAlgorithmParameterException will be thrown. On the other hand, implementations which require KDFParameters should throw an InvalidAlgorithmParameterException upon receiving a null value if default parameters cannot be generated or upon receiving
KDFParameters which are not supported by the implementation.
To aid the caller, implementations may return parameters with additional default values or supply random values as used by the underlying KDF algorithm. See engineGetParameters() for more details.
| Modifier | Constructor | Description |
|---|---|---|
protected |
The sole constructor. |
| Modifier and Type | Method | Description |
|---|---|---|
protected abstract byte[] |
engineDeriveData |
Derives a key, returns raw data as a byte array. |
protected abstract SecretKey |
engineDeriveKey |
Derives a key, returned as a SecretKey object. |
protected abstract KDFParameters |
engineGetParameters() |
Returns the KDFParameters used with this KDF object. |
protected KDFSpi(KDFParameters kdfParameters) throws InvalidAlgorithmParameterException
A KDFParameters object may be specified for KDF algorithms that support initialization parameters.
kdfParameters - the initialization parameters for the KDF algorithm (may be null)InvalidAlgorithmParameterException - if the initialization parameters are inappropriate for this KDFSpi
protected abstract KDFParameters engineGetParameters()
KDFParameters used with this KDF object. The returned parameters may be the same that were used to initialize this KDF object, or may contain additional default or random parameter values used by the underlying KDF algorithm. If the required parameters were not supplied and can be generated by the KDF object, the generated parameters are returned; otherwise null is returned.
KDF object, or null
protected abstract SecretKey engineDeriveKey(String alg, AlgorithmParameterSpec derivationSpec) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException
SecretKey object.getEncoded value should have the same content as the result of deriveData.alg - the algorithm of the resultant SecretKey object. See the SecretKey Algorithms section in the Java Security Standard Algorithm Names Specification for information about standard secret key algorithm names.derivationSpec - derivation parametersInvalidAlgorithmParameterException - if the information contained within the derivationSpec is invalid or if the combination of alg and the derivationSpec results in something invalidNoSuchAlgorithmException - if alg is empty or invalidNullPointerException - if alg or derivationSpec is nullprotected abstract byte[] engineDeriveData(AlgorithmParameterSpec derivationSpec) throws InvalidAlgorithmParameterException
derivationSpec - derivation parametersInvalidAlgorithmParameterException - if the information contained within the derivationSpec is invalidUnsupportedOperationException - if the derived keying material is not extractableNullPointerException - if derivationSpec is null
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/javax/crypto/KDFSpi.html