pub struct KemContext { /* private fields */ }Expand description
KEM context for key encapsulation operations
Implementations§
Source§impl KemContext
impl KemContext
Sourcepub fn new() -> KemContext
pub fn new() -> KemContext
Create a new KEM context with no provider
Sourcepub fn with_provider(provider: Box<dyn CryptoProvider>) -> KemContext
pub fn with_provider(provider: Box<dyn CryptoProvider>) -> KemContext
Create a new KEM context with a provider
Sourcepub fn with_default_provider() -> KemContext
pub fn with_default_provider() -> KemContext
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, Error>
pub fn generate_keypair( &mut self, algorithm: Algorithm, randomness: Option<&[u8]>, ) -> Result<KemKeypair, Error>
Generate a keypair for the specified algorithm
Sourcepub fn encapsulate(
&self,
algorithm: Algorithm,
public_key: &KemPublicKey,
randomness: Option<&[u8]>,
) -> Result<(Vec<u8>, Vec<u8>), Error>
pub fn encapsulate( &self, algorithm: Algorithm, public_key: &KemPublicKey, randomness: Option<&[u8]>, ) -> Result<(Vec<u8>, Vec<u8>), Error>
Encapsulate a key using the given public key
Sourcepub fn decapsulate(
&self,
algorithm: Algorithm,
secret_key: &KemSecretKey,
ciphertext: &[u8],
) -> Result<Vec<u8>, Error>
pub fn decapsulate( &self, algorithm: Algorithm, secret_key: &KemSecretKey, ciphertext: &[u8], ) -> Result<Vec<u8>, Error>
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§
Source§impl Default for KemContext
Available on crate feature alloc only.
impl Default for KemContext
Available on crate feature
alloc only.Source§fn default() -> KemContext
fn default() -> KemContext
Returns the “default value” for a type. Read more
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more