Available on crate feature
unstable only.Expand description
Unstable KEM Algorithms for usage with the crate::kem module.
§⚠️ Warning
Algorithms contained in this module are subject to changes, relocation, or removal across minor releases, and thus are not subject to semantic versioning policies.
§Example
use aws_lc_rs::{
error::Unspecified,
kem::{Ciphertext, DecapsulationKey, EncapsulationKey},
unstable::kem::{AlgorithmId, get_algorithm}
};
let kyber512_r3 = get_algorithm(AlgorithmId::Kyber512_R3).ok_or(Unspecified)?;
// Alice generates their (private) decapsulation key.
let decapsulation_key = DecapsulationKey::generate(kyber512_r3)?;
// Alices computes the (public) encapsulation key.
let encapsulation_key = decapsulation_key.encapsulation_key()?;
let encapsulation_key_bytes = encapsulation_key.key_bytes()?;
// Alice sends the encapsulation key bytes to bob through some
// protocol message.
let encapsulation_key_bytes = encapsulation_key_bytes.as_ref();
// Bob constructs the (public) encapsulation key from the key bytes provided by Alice.
let retrieved_encapsulation_key = EncapsulationKey::new(kyber512_r3, encapsulation_key_bytes)?;
// Bob executes the encapsulation algorithm to to produce their copy of the secret, and associated ciphertext.
let (ciphertext, bob_secret) = retrieved_encapsulation_key.encapsulate()?;
// Alice recieves ciphertext bytes from bob
let ciphertext_bytes = ciphertext.as_ref();
// Bob sends Alice the ciphertext computed from the encapsulation algorithm, Alice runs decapsulation to derive their
// copy of the secret.
let alice_secret = decapsulation_key.decapsulate(Ciphertext::from(ciphertext_bytes))?;
// Alice and Bob have now arrived to the same secret
assert_eq!(alice_secret.as_ref(), bob_secret.as_ref());
Enums§
- Identifier for an unstable KEM algorithm.
Functions§
- Retrieve an unstable KEM
Algorithmusing theAlgorithmIdspecified byid. May returnOption::Noneif support for the algorithm has been removed from the unstable module.