pub struct DhKem {}
safe_api
only.Expand description
DHKEM(X25519, HKDF-SHA256) as specified in HPKE RFC 9180.
Implementations§
source§impl DhKem
impl DhKem
sourcepub 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
sourcepub 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.
sourcepub fn generate_keypair() -> Result<(PrivateKey, PublicKey), UnknownCryptoError>
pub fn generate_keypair() -> Result<(PrivateKey, PublicKey), UnknownCryptoError>
Generate random X25519 keypair.
sourcepub 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
.
sourcepub 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
.
sourcepub 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.
sourcepub 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.
sourcepub 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.