public class HybridValueParameterSpec
extends java.lang.Object
implements java.security.spec.AlgorithmParameterSpec, javax.security.auth.Destroyable
KeyAgreement derives keys from becomes Z' = Z || T, where Z is the agreement's own
shared secret and T is a secret established by some other scheme (SP 800-56C Rev. 2, Section
2). NIST IR 8547, Section 3.2.1, names this generic composite as the way to combine a
classical key agreement with a post-quantum KEM during the transition to post-quantum
cryptography: T can be the shared secret of an ML-KEM encapsulation, and the result stays
secure while either component does.
The spec is accepted by every DH, ECDH and XDH KeyAgreement of the BC provider that
applies a KDF (the "...withSHA256KDF", "...withSHA256CKDF", "...withSHA256HKDF" and similar
services): KeyAgreement.init(key, spec) then generateSecret(...) derives the
keying material from Z' rather than Z, and the base spec supplies what the KDF would otherwise
have been given (for example a UserKeyingMaterialSpec). By default T is appended; with
doPrepend set the spec calculates Z' = T || Z instead, which NIST IR 8547 states will
also be allowed. The two orders give different keys, so the order is part of the protocol
being implemented and both parties must fix it in advance.
// T from an ML-KEM encapsulation, Z from X25519
KeyAgreement agreement = KeyAgreement.getInstance("X25519withSHA256HKDF", "BC");
agreement.init(ourX25519Key, new HybridValueParameterSpec(mlkemSharedSecret, new UserKeyingMaterialSpec(ukm)));
agreement.doPhase(theirX25519Key, true);
SecretKey key = agreement.generateSecret("AES[256]");
Get methods throw IllegalStateException if destroy() is called.
| Constructor and Description |
|---|
HybridValueParameterSpec(byte[] t,
java.security.spec.AlgorithmParameterSpec baseSpec)
Create a spec with T set to t and the spec for the KDF in the agreement to baseSpec.
|
HybridValueParameterSpec(byte[] t,
boolean doPrepend,
java.security.spec.AlgorithmParameterSpec baseSpec)
Create a spec with T set to t and the spec for the KDF in the agreement to baseSpec,
choosing which side of Z the value T goes on.
|
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Destroy this parameter spec, explicitly erasing its contents.
|
java.security.spec.AlgorithmParameterSpec |
getBaseParameterSpec()
Return the base parameter spec.
|
byte[] |
getT()
Return a reference to the T value.
|
boolean |
isDestroyed()
Return true if the destroy() method is called and the contents are
erased.
|
boolean |
isPrependedT()
Return whether or not T should be prepended.
|
public HybridValueParameterSpec(byte[] t,
java.security.spec.AlgorithmParameterSpec baseSpec)
t - a shared secret to be concatenated with the agreement's Z value.baseSpec - the base spec for the agreements KDF.public HybridValueParameterSpec(byte[] t,
boolean doPrepend,
java.security.spec.AlgorithmParameterSpec baseSpec)
t - a shared secret to be concatenated with the agreement's Z value.doPrepend - true to derive from T || Z, false to derive from Z || T.baseSpec - the base spec for the agreements KDF.public boolean isPrependedT()
public byte[] getT()
public java.security.spec.AlgorithmParameterSpec getBaseParameterSpec()
public boolean isDestroyed()
isDestroyed in interface javax.security.auth.Destroyablepublic void destroy()
destroy in interface javax.security.auth.Destroyable