Struct DhKem
pub struct DhKem {}
dep_orion
only.Expand description
DHKEM(X25519, HKDF-SHA256) as specified in HPKE RFC 9180.
Implementations§
§impl DhKem
impl DhKem
pub const KEM_ID: u16 = 32u16
pub const KEM_ID: u16 = 32u16
ID for this DH-KEM. See https://www.rfc-editor.org/rfc/rfc9180.html#section-7.1
pub const HPKE_VERSION_ID: &'static str = "HPKE-v1"
pub const HPKE_VERSION_ID: &'static str = "HPKE-v1"
Version of HPKE implemented. See https://www.rfc-editor.org/rfc/rfc9180.html#section-4-10.
pub fn generate_keypair() -> Result<(PrivateKey, PublicKey), UnknownCryptoError> ⓘ
pub fn generate_keypair() -> Result<(PrivateKey, PublicKey), UnknownCryptoError> ⓘ
Generate random X25519 keypair.
pub fn derive_keypair(
ikm: &[u8],
) -> Result<(PrivateKey, PublicKey), UnknownCryptoError> ⓘ
pub fn derive_keypair( ikm: &[u8], ) -> Result<(PrivateKey, PublicKey), UnknownCryptoError> ⓘ
Deterministically derive a X25519 keyapir from ikm
.
pub fn encap(
public_recipient: &PublicKey,
) -> Result<(SharedSecret, PublicKey), UnknownCryptoError> ⓘ
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
.
pub fn decap(
public_ephemeral: &PublicKey,
secret_recipient: &PrivateKey,
) -> Result<SharedSecret, UnknownCryptoError> ⓘ
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.
pub fn auth_encap(
public_recipient: &PublicKey,
secret_sender: &PrivateKey,
) -> Result<(SharedSecret, PublicKey), UnknownCryptoError> ⓘ
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.
pub fn auth_decap(
public_ephemeral: &PublicKey,
secret_recipient: &PrivateKey,
public_sender: &PublicKey,
) -> Result<SharedSecret, UnknownCryptoError> ⓘ
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 Freeze for DhKem
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId
of Self
using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more