Class HybridDerived
This class does not implement new cryptographic primitives. It derives keying
bytes via HKDF labels (using HybridKexExporter) and injects them into
existing builder instances.
Labeling
Derivation uses a base label, plus fixed suffixes for individual fields:
label + "/key"for the secret keylabel + "/aad"for AEAD AAD (optional, if derived)
A caller-supplied transcript binding (public handshake context) may be
included and will be passed to the exporter as info. This improves
cross-protocol separation and reduces configuration mistakes.
Thread safety
Instances are mutable and not thread-safe.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionaad(byte[] aad) Supplies explicit AAD bytes to be injected into AEAD builders.applyToAesGcm(AesDataContentBuilder aes, int keyBits) Derives an AES key and applies it with optional AAD to the provided AES builder.applyToChaChaAead(ChaChaDataContentBuilder chacha, int keyBits) Derives a ChaCha key and applies it with optional AAD to the provided ChaCha builder.Derives a MAC key using the builder's recommended size and applies it to the provided HMAC builder.applyToHmac(HmacDataContentBuilder hmac, int keyBits) Derives a MAC key of an explicit size (override) and applies it to the provided HMAC builder.deriveAad(int aadLen) Requests deterministic derivation of AAD bytes from the exporter.static HybridDerivedfrom(HybridKexExporter exporter) Creates a new derived-material builder backed by an exporter.Sets the base label used for purpose separation.transcript(byte[] transcript) Sets transcript binding bytes used as exporterinfo.
-
Method Details
-
from
Creates a new derived-material builder backed by an exporter.- Parameters:
exporter- exporter seeded from a hybrid KEX result (must not be null)- Returns:
- new derived-material builder
- Throws:
NullPointerException- if exporter is null- Since:
- 1.0
-
label
Sets the base label used for purpose separation.The label should identify the protocol purpose of the derived material, for example
"app/enc"or"handshake/confirm".- Parameters:
label- base label (must not be null or empty)- Returns:
- this builder
- Throws:
NullPointerException- if label is nullIllegalArgumentException- if label is empty- Since:
- 1.0
-
transcript
Sets transcript binding bytes used as exporterinfo.The transcript should contain only public context (negotiated suite, public keys/messages, channel binding, etc.). It must not contain secrets.
- Parameters:
transcript- transcript bytes (may be null to clear)- Returns:
- this builder
- Since:
- 1.0
-
aad
Supplies explicit AAD bytes to be injected into AEAD builders.If set, no AAD derivation is performed.
- Parameters:
aad- AAD bytes (may be null to clear)- Returns:
- this builder
- Since:
- 1.0
-
deriveAad
Requests deterministic derivation of AAD bytes from the exporter.This is optional. Many applications prefer to keep AAD as an application-defined, already-available public context. If derived, the AAD is separated using
label + "/aad".- Parameters:
aadLen- number of bytes to derive (must be >= 1)- Returns:
- this builder
- Throws:
IllegalArgumentException- if aadLen < 1- Since:
- 1.0
-
applyToAesGcm
Derives an AES key and applies it with optional AAD to the provided AES builder.The returned value is the same builder instance to preserve fluent pipeline construction.
- Parameters:
aes- AES builder to configure (must not be null)keyBits- AES key size in bits (128/192/256)- Returns:
- the provided builder instance
- Throws:
NullPointerException- if aes is nullIllegalArgumentException- if keyBits is invalid- Since:
- 1.0
-
applyToChaChaAead
Derives a ChaCha key and applies it with optional AAD to the provided ChaCha builder.The returned value is the same builder instance to preserve fluent pipeline construction.
- Parameters:
chacha- ChaCha builder to configure (must not be null)keyBits- key size in bits (typically 256)- Returns:
- the provided builder instance
- Throws:
NullPointerException- if chacha is nullIllegalArgumentException- if keyBits is invalid- Since:
- 1.0
-
applyToHmac
Derives a MAC key using the builder's recommended size and applies it to the provided HMAC builder.This is the preferred integration method because it avoids duplicated configuration: the HMAC variant is chosen by the builder (
HmacDataContentBuilder.spec()), and the key size recommendation is provided byHmacDataContentBuilder.recommendedKeyBits().The returned value is the same builder instance to preserve fluent pipeline construction.
- Parameters:
hmac- HMAC builder to configure (must not be null)- Returns:
- the provided builder instance
- Throws:
NullPointerException- ifhmacis nullIllegalStateException- if thisHybridDerivedinstance is missing required base configuration- Since:
- 1.0
-
applyToHmac
Derives a MAC key of an explicit size (override) and applies it to the provided HMAC builder.This overload exists for advanced use-cases where the application intentionally chooses a key size different from
HmacSpec.recommendedKeyBits(), for example to align a policy across different MAC functions or to satisfy interoperability constraints.Because HMAC accepts arbitrary key lengths, this method does not attempt to validate semantic suitability of
keyBits. Applications that require stricter controls should enforce them via policy (for example minimum bit strength) and use transcript-bound labels to guarantee key separation.The returned value is the same builder instance to preserve fluent pipeline construction.
- Parameters:
hmac- HMAC builder to configure (must not be null)keyBits- key size in bits (must be a positive multiple of 8)- Returns:
- the provided builder instance
- Throws:
NullPointerException- ifhmacis nullIllegalArgumentException- ifkeyBitsis invalidIllegalStateException- if thisHybridDerivedinstance is missing required base configuration- Since:
- 1.0
-