Trait hpke::kem::Kem

source ·
pub trait Kem: Sized {
    type PublicKey: Clone + Serializable + Deserializable;
    type PrivateKey: Clone + Serializable + Deserializable;
    type EncappedKey: Clone + Serializable + Deserializable;

    const KEM_ID: u16;

    // Required method
    fn derive_keypair(ikm: &[u8]) -> (Self::PrivateKey, Self::PublicKey);

    // Provided method
    fn gen_keypair<R: CryptoRng + RngCore>(
        csprng: &mut R
    ) -> (Self::PrivateKey, Self::PublicKey) { ... }
}
Expand description

Represents authenticated encryption functionality

Required Associated Types§

source

type PublicKey: Clone + Serializable + Deserializable

The key exchange’s public key type. If you want to generate a keypair, see Kem::gen_keypair or Kem::derive_keypair

source

type PrivateKey: Clone + Serializable + Deserializable

The key exchange’s private key type. If you want to generate a keypair, see Kem::gen_keypair or Kem::derive_keypair

source

type EncappedKey: Clone + Serializable + Deserializable

The encapsulated key for this KEM. This is used by the recipient to derive the shared secret.

Required Associated Constants§

source

const KEM_ID: u16

The algorithm identifier for a KEM implementation

Required Methods§

source

fn derive_keypair(ikm: &[u8]) -> (Self::PrivateKey, Self::PublicKey)

Deterministically derives a keypair from the given input keying material

Requirements

This keying material SHOULD have as many bits of entropy as the bit length of a secret key, i.e., 8 * Self::PrivateKey::size(). For X25519 and P-256, this is 256 bits of entropy.

Provided Methods§

source

fn gen_keypair<R: CryptoRng + RngCore>( csprng: &mut R ) -> (Self::PrivateKey, Self::PublicKey)

Generates a random keypair using the given RNG

Implementors§

source§

impl Kem for DhP256HkdfSha256

§

type PublicKey = <DhP256 as DhKeyExchange>::PublicKey

§

type PrivateKey = <DhP256 as DhKeyExchange>::PrivateKey

§

type EncappedKey = EncappedKey

source§

const KEM_ID: u16 = 16u16

source§

impl Kem for X25519HkdfSha256

§

type PublicKey = <X25519 as DhKeyExchange>::PublicKey

§

type PrivateKey = <X25519 as DhKeyExchange>::PrivateKey

§

type EncappedKey = EncappedKey

source§

const KEM_ID: u16 = 32u16