Struct elliptic_curve::ecdh::EphemeralSecret

source ·
pub struct EphemeralSecret<C>{ /* private fields */ }
Expand description

Ephemeral Diffie-Hellman Secret.

These are ephemeral “secret key” values which are deliberately designed to avoid being persisted.

To perform an ephemeral Diffie-Hellman exchange, do the following:

§⚠️ SECURITY WARNING ⚠️

Ephemeral Diffie-Hellman exchanges are unauthenticated and without a further authentication step are trivially vulnerable to man-in-the-middle attacks!

These exchanges should be performed in the context of a protocol which takes further steps to authenticate the peers in a key exchange.

Implementations§

source§

impl<C> EphemeralSecret<C>

source

pub fn random(rng: impl CryptoRng + RngCore) -> Self

Generate a cryptographically random EphemeralSecret.

source

pub fn public_key(&self) -> PublicKey<C>

Get the public key associated with this ephemeral secret.

The compress flag enables point compression.

source

pub fn diffie_hellman(&self, public_key: &PublicKey<C>) -> SharedSecret<C>

Compute a Diffie-Hellman shared secret from an ephemeral secret and the public key of the other participant in the exchange.

Trait Implementations§

source§

impl<C> Drop for EphemeralSecret<C>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<C> From<&EphemeralSecret<C>> for PublicKey<C>

source§

fn from(ephemeral_secret: &EphemeralSecret<C>) -> Self

Converts to this type from the input type.
source§

impl<C> Zeroize for EphemeralSecret<C>

source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
source§

impl<C> ZeroizeOnDrop for EphemeralSecret<C>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.