java.lang.Object
org.bouncycastle.pqc.crypto.mlkem.MLKEMGenerator
Generator for ML-KEM encapsulated secrets. Creates encapsulated secrets for secure key exchange in post-quantum cryptography.
Field Summary
FieldsConstructor Summary
ConstructorsConstructorDescriptionMLKEMGenerator(SecureRandom random) Creates a generator that draws its randomness from the given source.Method Summary
All MethodsModifier and TypeMethodDescriptiongenerateEncapsulated(AsymmetricKeyParameter recipientKey) Draws 32 fresh random bytes and encapsulates a shared secret for the recipient.internalGenerateEncapsulated(AsymmetricKeyParameter recipientKey, byte[] randBytes) Encapsulates a secret using the supplied randomness instead of drawing fresh bytes.
Field Details
sr
The source of randomness.
Constructor Details
MLKEMGenerator
Creates a generator that draws its randomness from the given source.- Parameters:
random- the source of randomness the KEM engine is initialized from
Method Details
generateEncapsulated
Draws 32 fresh random bytes and encapsulates a shared secret for the recipient.- Parameters:
recipientKey- the recipient's ML-KEM public key, from which the parameter set and engine are taken- Returns:
- the freshly drawn shared secret together with the ciphertext to send to the recipient
internalGenerateEncapsulated
public SecretWithEncapsulation internalGenerateEncapsulated(AsymmetricKeyParameter recipientKey, byte[] randBytes) Encapsulates a secret using the supplied randomness instead of drawing fresh bytes.- Parameters:
recipientKey- the recipient's ML-KEM public key, from which the parameter set and engine are takenrandBytes- the 32 bytes of randomness to encrypt with, instead of drawing fresh ones for reproducible tests- Returns:
- the shared secret derived from randBytes together with the ciphertext to send to the recipient