pub struct KemContext { /* private fields */ }Expand description
KEM context for key encapsulation operations
Implementations§
Source§impl KemContext
impl KemContext
Sourcepub fn with_provider(provider: Box<dyn CryptoProvider>) -> Self
pub fn with_provider(provider: Box<dyn CryptoProvider>) -> Self
Create a new KEM context with a provider
Sourcepub fn with_default_provider() -> Self
pub fn with_default_provider() -> Self
Create a new KEM context with the default provider
Sourcepub fn set_provider(&mut self, provider: Box<dyn CryptoProvider>)
pub fn set_provider(&mut self, provider: Box<dyn CryptoProvider>)
Set the cryptographic provider
Sourcepub fn provider(&self) -> Option<&dyn CryptoProvider>
pub fn provider(&self) -> Option<&dyn CryptoProvider>
Get the current provider
Sourcepub fn generate_keypair(
&mut self,
algorithm: Algorithm,
randomness: Option<&[u8]>,
) -> Result<KemKeypair>
pub fn generate_keypair( &mut self, algorithm: Algorithm, randomness: Option<&[u8]>, ) -> Result<KemKeypair>
Generate a keypair for the specified algorithm
Sourcepub fn encapsulate(
&self,
algorithm: Algorithm,
public_key: &KemPublicKey,
randomness: Option<&[u8]>,
) -> Result<(Vec<u8>, Vec<u8>)>
pub fn encapsulate( &self, algorithm: Algorithm, public_key: &KemPublicKey, randomness: Option<&[u8]>, ) -> Result<(Vec<u8>, Vec<u8>)>
Encapsulate a key using the given public key
Sourcepub fn decapsulate(
&self,
algorithm: Algorithm,
secret_key: &KemSecretKey,
ciphertext: &[u8],
) -> Result<Vec<u8>>
pub fn decapsulate( &self, algorithm: Algorithm, secret_key: &KemSecretKey, ciphertext: &[u8], ) -> Result<Vec<u8>>
Decapsulate a key using the given secret key and ciphertext
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the context is initialized
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KemContext
impl !RefUnwindSafe for KemContext
impl Send for KemContext
impl Sync for KemContext
impl Unpin for KemContext
impl UnsafeUnpin for KemContext
impl !UnwindSafe for KemContext
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