pub struct Kem { /* private fields */ }
Expand description
KEM algorithm
§Example
use oqs;
oqs::init();
let kem = oqs::kem::Kem::new(oqs::kem::Algorithm::MlKem512).unwrap();
let (pk, sk) = kem.keypair().unwrap();
let (ct, ss) = kem.encapsulate(&pk).unwrap();
let ss2 = kem.decapsulate(&sk, &ct).unwrap();
assert_eq!(ss, ss2);
Implementations§
source§impl Kem
impl Kem
sourcepub fn claimed_nist_level(&self) -> u8
pub fn claimed_nist_level(&self) -> u8
Get the claimed nist level
sourcepub fn is_ind_cca(&self) -> bool
pub fn is_ind_cca(&self) -> bool
Is the algorithm ind_cca secure
sourcepub fn length_public_key(&self) -> usize
pub fn length_public_key(&self) -> usize
Get the length of the public key
sourcepub fn length_secret_key(&self) -> usize
pub fn length_secret_key(&self) -> usize
Get the length of the secret key
sourcepub fn length_ciphertext(&self) -> usize
pub fn length_ciphertext(&self) -> usize
Get the length of the ciphertext
Get the length of a shared secret
sourcepub fn secret_key_from_bytes<'a>(
&self,
buf: &'a [u8],
) -> Option<SecretKeyRef<'a>>
pub fn secret_key_from_bytes<'a>( &self, buf: &'a [u8], ) -> Option<SecretKeyRef<'a>>
Obtain a secret key objects from bytes
Returns None if the secret key is not the correct length.
sourcepub fn public_key_from_bytes<'a>(
&self,
buf: &'a [u8],
) -> Option<PublicKeyRef<'a>>
pub fn public_key_from_bytes<'a>( &self, buf: &'a [u8], ) -> Option<PublicKeyRef<'a>>
Obtain a public key from bytes
Returns None if the public key is not the correct length.
sourcepub fn ciphertext_from_bytes<'a>(
&self,
buf: &'a [u8],
) -> Option<CiphertextRef<'a>>
pub fn ciphertext_from_bytes<'a>( &self, buf: &'a [u8], ) -> Option<CiphertextRef<'a>>
Obtain a ciphertext from bytes
Returns None if the ciphertext is not the correct length.
Obtain a secret key from bytes
Returns None if the shared secret is not the correct length.
sourcepub fn encapsulate<'a, P: Into<PublicKeyRef<'a>>>(
&self,
pk: P,
) -> Result<(Ciphertext, SharedSecret)>
pub fn encapsulate<'a, P: Into<PublicKeyRef<'a>>>( &self, pk: P, ) -> Result<(Ciphertext, SharedSecret)>
Encapsulate to the provided public key
sourcepub fn decapsulate<'a, 'b, S: Into<SecretKeyRef<'a>>, C: Into<CiphertextRef<'b>>>(
&self,
sk: S,
ct: C,
) -> Result<SharedSecret>
pub fn decapsulate<'a, 'b, S: Into<SecretKeyRef<'a>>, C: Into<CiphertextRef<'b>>>( &self, sk: S, ct: C, ) -> Result<SharedSecret>
Decapsulate the provided ciphertext
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more