Class KDFSpi
KDFSpi is a preview API of the Java platform.
KDFPREVIEW) 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.
- Since:
- 24
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedKDFSpi(KDFParametersPREVIEW kdfParameters) The sole constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract byte[]engineDeriveData(AlgorithmParameterSpec derivationSpec) Derives a key, returns raw data as a byte array.protected abstract SecretKeyengineDeriveKey(String alg, AlgorithmParameterSpec derivationSpec) Derives a key, returned as aSecretKeyobject.protected abstract KDFParametersPREVIEWReturns theKDFParametersused with thisKDFobject.
-
Constructor Details
-
KDFSpi
The sole constructor.A
KDFParametersobject may be specified for KDF algorithms that support initialization parameters.- Parameters:
kdfParameters- the initialization parameters for theKDFalgorithm (may benull)- Throws:
InvalidAlgorithmParameterException- if the initialization parameters are inappropriate for thisKDFSpi- See Also:
-
-
Method Details
-
engineGetParameters
Returns theKDFParametersused with thisKDFobject.The returned parameters may be the same that were used to initialize this
KDFobject, 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 theKDFobject, the generated parameters are returned; otherwisenullis returned.- Returns:
- the parameters used with this
KDFobject, ornull
-
engineDeriveKey
protected abstract SecretKey engineDeriveKey(String alg, AlgorithmParameterSpec derivationSpec) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException Derives a key, returned as aSecretKeyobject.- Implementation Note:
- If the resultant key is extractable, then its
getEncodedvalue should have the same content as the result ofderiveData. - Parameters:
alg- the algorithm of the resultantSecretKeyobjectderivationSpec- derivation parameters- Returns:
- the derived key.
- Throws:
InvalidAlgorithmParameterException- if the information contained within thederivationSpecis invalid or if the combination ofalgand thederivationSpecresults in something invalidNoSuchAlgorithmException- ifalgis empty or invalidNullPointerException- ifalgorderivationSpecis null
-
engineDeriveData
protected abstract byte[] engineDeriveData(AlgorithmParameterSpec derivationSpec) throws InvalidAlgorithmParameterException Derives a key, returns raw data as a byte array.- Parameters:
derivationSpec- derivation parameters- Returns:
- the derived key in its raw bytes.
- Throws:
InvalidAlgorithmParameterException- if the information contained within thederivationSpecis invalidUnsupportedOperationException- if the derived keying material is not extractableNullPointerException- ifderivationSpecis null
-
KDFSpiwhen preview features are enabled.