APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.crypto.provider

pack-priv abstract Class HKDFKeyDerivation

extends KDFSpi
Class Inheritance
Known Direct Subclasses
com.sun.crypto.provider.HKDFKeyDerivation.HKDFSHA256, com.sun.crypto.provider.HKDFKeyDerivation.HKDFSHA384, com.sun.crypto.provider.HKDFKeyDerivation.HKDFSHA512
Imports
jdk.internal.access.SharedSecrets, javax.crypto.KDFSpi, .Mac, .SecretKey, .ShortBufferException, .KDFParameters, javax.crypto.spec.HKDFParameterSpec, .SecretKeySpec, java.io.ByteArrayOutputStream, java.security.InvalidAlgorithmParameterException, .InvalidKeyException, .NoSuchAlgorithmException, .ProviderException, java.security.spec.AlgorithmParameterSpec, java.util.ArrayList, .Arrays, .List

KDF implementation for the HKDF function.

This class implements the HKDF-Extract and HKDF-Expand functions from RFC 5869. This implementation provides the complete Extract-then-Expand HKDF function as well as Extract-only and Expand-only variants.

External Specification
https://www.rfc-editor.org/info/rfc5869

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class
private static enum

Field Summary

Modifier and TypeField and Description
private final String
private final int

Constructor Summary

AccessConstructor and Description
private
HKDFKeyDerivation(HKDFKeyDerivation.SupportedHmac supportedHmac, KDFParameters
the initialization parameters (may be null)
kdfParameters
)

The sole constructor.

Method Summary

Modifier and TypeMethod and Description
private byte[]
protected byte[]

Returns:

a derived byte[]
engineDeriveData
(AlgorithmParameterSpec derivationSpec)

Implements abstract javax.crypto.KDFSpi.engineDeriveData.

Obtain raw data from a key derivation function.

protected SecretKey

Returns:

a derived SecretKey object of the specified algorithm
engineDeriveKey
(String alg, AlgorithmParameterSpec derivationSpec)

Implements abstract javax.crypto.KDFSpi.engineDeriveKey.

Derive a key, returned as a SecretKey object.

protected KDFParameters
engineGetParameters()

Implements abstract javax.crypto.KDFSpi.engineGetParameters.

Returns the KDFParameters used with this KDF object.

private byte[]

Returns:

a byte array containing the complete KDF output. This will be at least as long as the requested length in the outLen parameter, but will be rounded up to the nearest multiple of the HMAC output length.
hkdfExpand
(byte[]
the pseudorandom key used for HKDF-Expand
prk
,
byte[]
optional context and application specific information or null if no info data is provided.
info
,
int
the length in bytes of the required output
outLen
)

Perform the HKDF-Expand operation.

private byte[]

Returns:

a byte array containing the pseudorandom key (PRK)
hkdfExtract
(byte[]
the input keying material used for the HKDF-Extract operation.
inputKeyMaterial
,
byte[]
the salt value used for HKDF-Extract
salt
)

Perform the HKDF-Extract operation.

Field Detail

hmacAlgNameback to summary
private final String hmacAlgName
hmacLenback to summary
private final int hmacLen

Constructor Detail

HKDFKeyDerivationback to summary
private HKDFKeyDerivation(HKDFKeyDerivation.SupportedHmac supportedHmac, KDFParameters kdfParameters) throws InvalidAlgorithmParameterException

The sole constructor.

Parameters
kdfParameters:KDFParameters

the initialization parameters (may be null)

Exceptions
InvalidAlgorithmParameterException:
if the initialization parameters are inappropriate for this KDFSpi

Method Detail

consolidateKeyMaterialback to summary
private byte[] consolidateKeyMaterial(List<SecretKey> keys) throws InvalidKeyException
engineDeriveDataback to summary
protected byte[] engineDeriveData(AlgorithmParameterSpec derivationSpec) throws InvalidAlgorithmParameterException

Implements abstract javax.crypto.KDFSpi.engineDeriveData.

Obtain raw data from a key derivation function.

Returns:byte[]

a derived byte[]

Annotations
@Override
Exceptions
InvalidAlgorithmParameterException:
if the information contained within the KDFParameterSpec is invalid or incorrect for the type of key to be derived
UnsupportedOperationException:
if the derived keying material is not extractable
engineDeriveKeyback to summary
protected SecretKey engineDeriveKey(String alg, AlgorithmParameterSpec derivationSpec) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException

Implements abstract javax.crypto.KDFSpi.engineDeriveKey.

Derive a key, returned as a SecretKey object.

Returns:SecretKey

a derived SecretKey object of the specified algorithm

Annotations
@Override
Exceptions
InvalidAlgorithmParameterException:
if the information contained within the derivationSpec is invalid or if the combination of alg and the derivationSpec results in something invalid
NoSuchAlgorithmException:
if alg is empty
NullPointerException:
if alg is null
engineGetParametersback to summary
protected KDFParameters engineGetParameters()

Implements abstract javax.crypto.KDFSpi.engineGetParameters.

Doc from javax.crypto.KDFSpi.engineGetParameters.

Returns the 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.

hkdfExpandback to summary
private byte[] hkdfExpand(byte[] prk, byte[] info, int outLen) throws InvalidKeyException, NoSuchAlgorithmException

Perform the HKDF-Expand operation.

Parameters
prk:byte[]

the pseudorandom key used for HKDF-Expand

info:byte[]

optional context and application specific information or null if no info data is provided.

outLen:int

the length in bytes of the required output

Returns:byte[]

a byte array containing the complete KDF output. This will be at least as long as the requested length in the outLen parameter, but will be rounded up to the nearest multiple of the HMAC output length.

Exceptions
InvalidKeyException:
if an invalid PRK was provided through the HKDFParameterSpec or derived during the extract phase.
hkdfExtractback to summary
private byte[] hkdfExtract(byte[] inputKeyMaterial, byte[] salt) throws InvalidKeyException, NoSuchAlgorithmException

Perform the HKDF-Extract operation.

Parameters
inputKeyMaterial:byte[]

the input keying material used for the HKDF-Extract operation.

salt:byte[]

the salt value used for HKDF-Extract

Returns:byte[]

a byte array containing the pseudorandom key (PRK)

Exceptions
InvalidKeyException:
if an invalid salt was provided through the HKDFParameterSpec
com.sun.crypto.provider back to summary

public final Class HKDFKeyDerivation.HKDFSHA256

extends HKDFKeyDerivation
Class Inheritance

Constructor Summary

AccessConstructor and Description
public
HKDFSHA256(KDFParameters kdfParameters)

Method Summary

Inherited from com.sun.crypto.provider.HKDFKeyDerivation:
engineDeriveDataengineDeriveKeyengineGetParameters

Constructor Detail

HKDFSHA256back to summary
public HKDFSHA256(KDFParameters kdfParameters) throws InvalidAlgorithmParameterException
com.sun.crypto.provider back to summary

public final Class HKDFKeyDerivation.HKDFSHA384

extends HKDFKeyDerivation
Class Inheritance

Constructor Summary

AccessConstructor and Description
public
HKDFSHA384(KDFParameters kdfParameters)

Method Summary

Inherited from com.sun.crypto.provider.HKDFKeyDerivation:
engineDeriveDataengineDeriveKeyengineGetParameters

Constructor Detail

HKDFSHA384back to summary
public HKDFSHA384(KDFParameters kdfParameters) throws InvalidAlgorithmParameterException
com.sun.crypto.provider back to summary

public final Class HKDFKeyDerivation.HKDFSHA512

extends HKDFKeyDerivation
Class Inheritance

Constructor Summary

AccessConstructor and Description
public
HKDFSHA512(KDFParameters kdfParameters)

Method Summary

Inherited from com.sun.crypto.provider.HKDFKeyDerivation:
engineDeriveDataengineDeriveKeyengineGetParameters

Constructor Detail

HKDFSHA512back to summary
public HKDFSHA512(KDFParameters kdfParameters) throws InvalidAlgorithmParameterException
com.sun.crypto.provider back to summary

private final Enum HKDFKeyDerivation.SupportedHmac

extends Enum<HKDFKeyDerivation.SupportedHmac>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final String
private final int
public static final HKDFKeyDerivation.SupportedHmac
public static final HKDFKeyDerivation.SupportedHmac
public static final HKDFKeyDerivation.SupportedHmac

Constructor Summary

AccessConstructor and Description
private
SupportedHmac(String hmacAlg, int hmacLen)

Method Summary

Modifier and TypeMethod and Description
public static HKDFKeyDerivation.SupportedHmac
public static HKDFKeyDerivation.SupportedHmac[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

hmacAlgback to summary
private final String hmacAlg
hmacLenback to summary
private final int hmacLen
SHA256back to summary
public static final HKDFKeyDerivation.SupportedHmac SHA256
SHA384back to summary
public static final HKDFKeyDerivation.SupportedHmac SHA384
SHA512back to summary
public static final HKDFKeyDerivation.SupportedHmac SHA512

Constructor Detail

SupportedHmacback to summary
private SupportedHmac(String hmacAlg, int hmacLen)

Method Detail

valueOfback to summary
public static HKDFKeyDerivation.SupportedHmac valueOf(String name)
valuesback to summary
public static HKDFKeyDerivation.SupportedHmac[] values()