embassy-crypto-driver

Crates

git

Versions

default

Flavors

Skip to main content

X25519Impl

Struct X25519Impl 

Source
pub struct X25519Impl;
Expand description

The global X25519 implementation.

Implementations§

Source§

impl X25519Impl

Source

pub fn generate_keypair( rng: &mut dyn Rng, ) -> Result<(X25519PrivateKey, X25519PublicKey), CryptoError>

Generate a fresh keypair: scalar k, Q = X25519(k, 9).

Used for TLS 1.3 ECDHE keygen.

Source

pub fn public_key(k: X25519PrivateKey) -> Result<X25519PublicKey, CryptoError>

Derive the public key from a known private scalar.

No RNG: used for persistent keys (e.g. a TLS static ECDH identity loaded from flash) where the caller already holds k.

Source

pub fn ecdh_shared_secret( k: X25519PrivateKey, peer: X25519PublicKey, ) -> Result<[u8; 32], CryptoError>

X25519 shared secret: X25519(k, peer), 32 bytes.

This is the TLS 1.3 ecdhe_shared_secret (fed into HKDF via HmacSha256).

Trait Implementations§

Source§

impl X25519 for X25519Impl

Source§

fn generate_keypair( rng: &mut dyn Rng, ) -> Result<(X25519PrivateKey, X25519PublicKey), CryptoError>

Generate a fresh keypair: scalar k, Q = X25519(k, 9). Read more
Source§

fn public_key(k: X25519PrivateKey) -> Result<X25519PublicKey, CryptoError>

Derive the public key from a known private scalar. Read more
Source§

fn ecdh_shared_secret( k: X25519PrivateKey, peer: X25519PublicKey, ) -> Result<[u8; 32], CryptoError>

X25519 shared secret: X25519(k, peer), 32 bytes. Read more

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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>,

Source§

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.