Class MLKEMCompositeSecretBCPGKey
java.lang.Object
org.bouncycastle.bcpg.BCPGObject
org.bouncycastle.bcpg.OctetArrayBCPGKey
org.bouncycastle.bcpg.MLKEMCompositeSecretBCPGKey
- All Implemented Interfaces:
BCPGKey, org.bouncycastle.util.Encodable
Secret key of the ML-KEM + ECDH composite encryption algorithms
PublicKeyAlgorithmTags.MLKEM768_X25519
and PublicKeyAlgorithmTags.MLKEM1024_X448 (RFC 9980 sec. 4.3.2.2): the fixed-length ECDH secret key
in the RFC 7748 encoding of its curve, followed by the 64 octet ML-KEM secret key in seed format - the
concatenation of the values d and z of FIPS 203 ML-KEM.KeyGen, from which the decapsulation key is expanded
with ML-KEM.KeyGen_internal before use.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intLength of the ML-KEM secret key in seed format: d || z, 32 octets each. -
Constructor Summary
ConstructorsConstructorDescriptionMLKEMCompositeSecretBCPGKey(int algorithm, byte[] ecdhSecretKey, byte[] mlkemSeed) Construct the secret key of the given composite algorithm from its two components.MLKEMCompositeSecretBCPGKey(int algorithm, BCPGInputStream in) Parse the secret key of the given composite algorithm from the (decrypted) secret key material. -
Method Summary
Modifier and TypeMethodDescriptionintReturn the public key algorithm ID this key belongs to.byte[]Return the ECDH (X25519 or X448) secret key component.static intgetECDHSecretKeyLength(int algorithm) Return the length of the ECDH secret key component (RFC 9980 Table 3).static intgetLength(int algorithm) Return the length of the algorithm-specific secret key material for the given composite algorithm.byte[]Return the ML-KEM seed d || z.Methods inherited from class OctetArrayBCPGKey
encode, getEncoded, getFormat, getKey
-
Field Details
-
MLKEM_SEED_LENGTH
public static final int MLKEM_SEED_LENGTHLength of the ML-KEM secret key in seed format: d || z, 32 octets each.- See Also:
-
-
Constructor Details
-
MLKEMCompositeSecretBCPGKey
Parse the secret key of the given composite algorithm from the (decrypted) secret key material.- Parameters:
algorithm- public key algorithm ID,PublicKeyAlgorithmTags.MLKEM768_X25519orPublicKeyAlgorithmTags.MLKEM1024_X448in- input stream positioned at the algorithm-specific secret key material- Throws:
IOException- if the key cannot be read
-
MLKEMCompositeSecretBCPGKey
public MLKEMCompositeSecretBCPGKey(int algorithm, byte[] ecdhSecretKey, byte[] mlkemSeed) Construct the secret key of the given composite algorithm from its two components.- Parameters:
algorithm- public key algorithm ID,PublicKeyAlgorithmTags.MLKEM768_X25519orPublicKeyAlgorithmTags.MLKEM1024_X448ecdhSecretKey- the X25519 (32 octets) or X448 (56 octets) secret keymlkemSeed- the 64 octet ML-KEM seed d || z
-
-
Method Details
-
getAlgorithm
public int getAlgorithm()Return the public key algorithm ID this key belongs to. -
getECDHSecretKey
public byte[] getECDHSecretKey()Return the ECDH (X25519 or X448) secret key component.- Returns:
- ECDH secret key in RFC 7748 encoding
-
getMLKEMSeed
public byte[] getMLKEMSeed()Return the ML-KEM seed d || z.- Returns:
- 64 octet ML-KEM seed
-
getLength
public static int getLength(int algorithm) Return the length of the algorithm-specific secret key material for the given composite algorithm.- Parameters:
algorithm- public key algorithm ID- Returns:
- total octet length of the ECDH secret key and the ML-KEM seed
-
getECDHSecretKeyLength
public static int getECDHSecretKeyLength(int algorithm) Return the length of the ECDH secret key component (RFC 9980 Table 3).- Parameters:
algorithm- public key algorithm ID- Returns:
- 32 for X25519, 56 for X448
-