Skip to main content

KemPlugin

Trait KemPlugin 

Source
pub trait KemPlugin: Sized {
    // Required methods
    fn encapsulator_create(
        algorithm: &str,
        recipient_pubkey: &[u8],
        opts: Option<OptionView<'_>>,
    ) -> PluginResult<Self>;
    fn encapsulate(
        &mut self,
        ct_out: &mut [u8],
        ss_out: &mut [u8],
    ) -> PluginResult<KemEncapsulateResult>;
    fn decapsulator_create(
        algorithm: &str,
        recipient_seckey: &[u8],
        opts: Option<OptionView<'_>>,
    ) -> PluginResult<Self>;
    fn decapsulate(
        &mut self,
        ciphertext: &[u8],
        ss_out: &mut [u8],
    ) -> PluginResult<usize>;
    fn shared_secret_size(algorithm: &str) -> PluginResult<u32>;
    fn keypair_generate(
        algorithm: &str,
        seed: Option<&[u8]>,
        opts: Option<OptionView<'_>>,
    ) -> PluginResult<KemKeypair>;
}
Expand description

Trait implemented by KEM plugins. The type Self serves as both the encapsulator and decapsulator state — the plugin dispatches internally based on which entry points are called.

Required Methods§

Source

fn encapsulator_create( algorithm: &str, recipient_pubkey: &[u8], opts: Option<OptionView<'_>>, ) -> PluginResult<Self>

Construct an encapsulator from the recipient’s public key.

Source

fn encapsulate( &mut self, ct_out: &mut [u8], ss_out: &mut [u8], ) -> PluginResult<KemEncapsulateResult>

Encapsulate: produce a ciphertext and shared secret. Writes the ciphertext and shared secret into the provided output buffers and returns their lengths.

Source

fn decapsulator_create( algorithm: &str, recipient_seckey: &[u8], opts: Option<OptionView<'_>>, ) -> PluginResult<Self>

Construct a decapsulator from the recipient’s secret key.

Source

fn decapsulate( &mut self, ciphertext: &[u8], ss_out: &mut [u8], ) -> PluginResult<usize>

Decapsulate: recover the shared secret from the ciphertext. Writes the shared secret into ss_out and returns its length.

Source

fn shared_secret_size(algorithm: &str) -> PluginResult<u32>

Query the shared secret size for the named algorithm.

Source

fn keypair_generate( algorithm: &str, seed: Option<&[u8]>, opts: Option<OptionView<'_>>, ) -> PluginResult<KemKeypair>

Generate a keypair for the named algorithm. If seed is provided, it is used deterministically.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§