pub struct DhKem {}
Available on crate feature safe_api only.
Expand description

DHKEM(X25519, HKDF-SHA256) as specified in HPKE RFC 9180.

Implementations§

source§

impl DhKem

source

pub const KEM_ID: u16 = 32u16

source

pub const HPKE_VERSION_ID: &'static str = "HPKE-v1"

source

pub fn generate_keypair() -> Result<(PrivateKey, PublicKey), UnknownCryptoError>

Generate random X25519 keypair.

source

pub fn derive_keypair( ikm: &[u8] ) -> Result<(PrivateKey, PublicKey), UnknownCryptoError>

Deterministically derive a X25519 keyapir from ikm.

source

pub fn encap( public_recipient: &PublicKey ) -> Result<(SharedSecret, PublicKey), UnknownCryptoError>

Derive ephemeral shared secret and encapsulation thereof, which can be decapsulated by the holder of public_recipient.

source

pub fn decap( public_ephemeral: &PublicKey, secret_recipient: &PrivateKey ) -> Result<SharedSecret, UnknownCryptoError>

Decapsulate public_ephemeral and return the shared ephemeral secrety, using secret_recipient private key.

source

pub fn auth_encap( public_recipient: &PublicKey, secret_sender: &PrivateKey ) -> Result<(SharedSecret, PublicKey), UnknownCryptoError>

Equivalent to Self::encap(), additionally ensuring the holder of secret_sender was the one to generate the shared secret.

source

pub fn auth_decap( public_ephemeral: &PublicKey, secret_recipient: &PrivateKey, public_sender: &PublicKey ) -> Result<SharedSecret, UnknownCryptoError>

Equivalent to Self::decap(), additionally ensuring the holder of secret_sender was the one to generate the shared secret.

Auto Trait Implementations§

§

impl RefUnwindSafe for DhKem

§

impl Send for DhKem

§

impl Sync for DhKem

§

impl Unpin for DhKem

§

impl UnwindSafe for DhKem

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.