Class HkdfKeyDerivationExample
java.lang.Object
net.jrodolfo.java_evolution.java25.key_derivation.HkdfKeyDerivationExample
Demonstrates the Java 25 Key Derivation Function API with HKDF-SHA256.
HKDF is the HMAC-based Key Derivation Function. It takes input key material, an optional salt, and application-specific context information, then derives key bytes for a concrete purpose. This is useful after a key exchange, such as KEM, because raw shared material is usually not the exact key an application should use directly.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionderiveAes256Key(byte[] inputKeyMaterial, byte[] salt, String contextLabel) Derives 256-bit key material for a specific application context.
-
Field Details
-
ALGORITHM
-
-
Constructor Details
-
HkdfKeyDerivationExample
public HkdfKeyDerivationExample()
-
-
Method Details
-
deriveAes256Key
public DerivedKeyMaterial deriveAes256Key(byte[] inputKeyMaterial, byte[] salt, String contextLabel) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException Derives 256-bit key material for a specific application context.- Parameters:
inputKeyMaterial- the existing secret materialsalt- additional random or protocol-specific saltcontextLabel- purpose-specific context information- Returns:
- derived key material
- Throws:
NoSuchAlgorithmException- if HKDF-SHA256 is not availableInvalidAlgorithmParameterException- if the HKDF parameters are invalid
-