[][src]Trait hpke::KeyExchange

pub trait KeyExchange {
    type PublicKey: Clone + Marshallable + Unmarshallable;
    type PrivateKey: Clone + Marshallable + Unmarshallable;
    type KexResult: Marshallable;
    fn gen_keypair<R: CryptoRng + RngCore>(
        csprng: &mut R
    ) -> (Self::PrivateKey, Self::PublicKey);
fn sk_to_pk(sk: &Self::PrivateKey) -> Self::PublicKey;
fn kex(
        sk: &Self::PrivateKey,
        pk: &Self::PublicKey
    ) -> Result<Self::KexResult, HpkeError>; }

This trait captures the requirements of a key exchange mechanism. It must have a way to generate keypairs, perform the KEX computation, and marshal/umarshal KEX pubkeys

Associated Types

Loading content...

Required methods

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

fn sk_to_pk(sk: &Self::PrivateKey) -> Self::PublicKey

fn kex(
    sk: &Self::PrivateKey,
    pk: &Self::PublicKey
) -> Result<Self::KexResult, HpkeError>

Loading content...

Implementors

impl KeyExchange for DhP256[src]

type PublicKey = PublicKey

type PrivateKey = PrivateKey

type KexResult = KexResult

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

Generates an P256 keypair

fn sk_to_pk(sk: &PrivateKey) -> PublicKey[src]

Converts an P256 private key to a public key

fn kex(sk: &PrivateKey, pk: &PublicKey) -> Result<KexResult, HpkeError>[src]

Does the DH operation. Returns HpkeError::InvalidKeyExchange if and only if the DH result was all zeros. This is required by the HPKE spec.

impl KeyExchange for X25519[src]

type PublicKey = PublicKey

type PrivateKey = PrivateKey

type KexResult = KexResult

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

Generates an X25519 keypair

fn sk_to_pk(sk: &PrivateKey) -> PublicKey[src]

Converts an X25519 private key to a public key

fn kex(sk: &PrivateKey, pk: &PublicKey) -> Result<KexResult, HpkeError>[src]

Does the DH operation. Returns HpkeError::InvalidKeyExchange if and only if the DH result was all zeros. This is required by the HPKE spec.

Loading content...