Class MLKEMCompositePublicBCPGKey
java.lang.Object
org.bouncycastle.bcpg.BCPGObject
org.bouncycastle.bcpg.OctetArrayBCPGKey
org.bouncycastle.bcpg.MLKEMCompositePublicBCPGKey
- All Implemented Interfaces:
BCPGKey, org.bouncycastle.util.Encodable
Public key of the ML-KEM + ECDH composite encryption algorithms
PublicKeyAlgorithmTags.MLKEM768_X25519
and PublicKeyAlgorithmTags.MLKEM1024_X448 (RFC 9980 sec. 4.3.2.1): the fixed-length ECDH public key
in the RFC 7748 encoding of its curve, followed by the fixed-length ML-KEM encapsulation key in the FIPS 203
encoding.
The component lengths are fixed by the algorithm ID (RFC 9980 Tables 3 and 4), so the key knows which
algorithm it belongs to and the two components can be read back with getECDHPublicKey() and
getMLKEMPublicKey().
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMLKEMCompositePublicBCPGKey(int algorithm, byte[] ecdhPublicKey, byte[] mlkemPublicKey) Construct the public key of the given composite algorithm from its two components.MLKEMCompositePublicBCPGKey(int algorithm, BCPGInputStream in) Parse the public key of the given composite algorithm from the packet stream. -
Method Summary
Modifier and TypeMethodDescriptionintReturn the public key algorithm ID this key belongs to.byte[]Return the ECDH (X25519 or X448) public key component.static intgetECDHPublicKeyLength(int algorithm) Return the length of the ECDH public key component (RFC 9980 Table 3).static intgetLength(int algorithm) Return the length of the algorithm-specific public key material for the given composite algorithm.static intgetMLKEMCiphertextLength(int algorithm) Return the length of the ML-KEM ciphertext carried in a PKESK packet (RFC 9980 Table 4).byte[]Return the ML-KEM encapsulation key component.static intgetMLKEMPublicKeyLength(int algorithm) Return the length of the ML-KEM encapsulation key component (RFC 9980 Table 4).Methods inherited from class OctetArrayBCPGKey
encode, getEncoded, getFormat, getKey
-
Constructor Details
-
MLKEMCompositePublicBCPGKey
Parse the public key of the given composite algorithm from the packet stream.- Parameters:
algorithm- public key algorithm ID,PublicKeyAlgorithmTags.MLKEM768_X25519orPublicKeyAlgorithmTags.MLKEM1024_X448in- packet input stream positioned at the algorithm-specific key material- Throws:
IOException- if the key cannot be read
-
MLKEMCompositePublicBCPGKey
public MLKEMCompositePublicBCPGKey(int algorithm, byte[] ecdhPublicKey, byte[] mlkemPublicKey) Construct the public key of the given composite algorithm from its two components.- Parameters:
algorithm- public key algorithm ID,PublicKeyAlgorithmTags.MLKEM768_X25519orPublicKeyAlgorithmTags.MLKEM1024_X448ecdhPublicKey- the X25519 (32 octets) or X448 (56 octets) public keymlkemPublicKey- the ML-KEM-768 (1184 octets) or ML-KEM-1024 (1568 octets) encapsulation key
-
-
Method Details
-
getAlgorithm
public int getAlgorithm()Return the public key algorithm ID this key belongs to. -
getECDHPublicKey
public byte[] getECDHPublicKey()Return the ECDH (X25519 or X448) public key component.- Returns:
- ECDH public key in RFC 7748 encoding
-
getMLKEMPublicKey
public byte[] getMLKEMPublicKey()Return the ML-KEM encapsulation key component.- Returns:
- ML-KEM public key in FIPS 203 encoding
-
getLength
public static int getLength(int algorithm) Return the length of the algorithm-specific public key material for the given composite algorithm.- Parameters:
algorithm- public key algorithm ID- Returns:
- total octet length of the ECDH and ML-KEM public keys
-
getECDHPublicKeyLength
public static int getECDHPublicKeyLength(int algorithm) Return the length of the ECDH public key component (RFC 9980 Table 3).- Parameters:
algorithm- public key algorithm ID- Returns:
- 32 for X25519, 56 for X448
-
getMLKEMPublicKeyLength
public static int getMLKEMPublicKeyLength(int algorithm) Return the length of the ML-KEM encapsulation key component (RFC 9980 Table 4).- Parameters:
algorithm- public key algorithm ID- Returns:
- 1184 for ML-KEM-768, 1568 for ML-KEM-1024
-
getMLKEMCiphertextLength
public static int getMLKEMCiphertextLength(int algorithm) Return the length of the ML-KEM ciphertext carried in a PKESK packet (RFC 9980 Table 4).- Parameters:
algorithm- public key algorithm ID- Returns:
- 1088 for ML-KEM-768, 1568 for ML-KEM-1024
-