Skip to main content

Dh

Trait Dh 

Source
pub trait Dh: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn pub_len(&self) -> usize;
    fn priv_len(&self) -> usize;
    fn set(&mut self, privkey: &[u8]);
    fn generate(&mut self, rng: &mut dyn Random) -> Result<(), Error>;
    fn pubkey(&self) -> &[u8] ;
    fn privkey(&self) -> &[u8] ;
    fn dh(&self, pubkey: &[u8], out: &mut [u8]) -> Result<(), Error>;

    // Provided method
    fn dh_len(&self) -> usize { ... }
}
Expand description

Diffie-Hellman operations

Required Methods§

Source

fn name(&self) -> &'static str

The string that the Noise spec defines for the primitive

Source

fn pub_len(&self) -> usize

The length in bytes of a public key for this primitive

Source

fn priv_len(&self) -> usize

The length in bytes of a private key for this primitive

Source

fn set(&mut self, privkey: &[u8])

Set the private key

Source

fn generate(&mut self, rng: &mut dyn Random) -> Result<(), Error>

Generate a new private key

§Errors

Returns Error::Rng in the event that the provided RNG failed.

Source

fn pubkey(&self) -> &[u8]

Get the public key

Source

fn privkey(&self) -> &[u8]

Get the private key

Source

fn dh(&self, pubkey: &[u8], out: &mut [u8]) -> Result<(), Error>

Calculate a Diffie-Hellman exchange.

§Errors

Returns Error::Dh in the event that the Diffie-Hellman failed.

Provided Methods§

Source

fn dh_len(&self) -> usize

The lenght in bytes of of the DH key exchange. Defaults to the public key.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§