#[cfg(feature = "crypto-aws-lc-rs")]
mod aws_lc_rs;
pub(crate) mod global;
#[cfg(feature = "crypto-graviola")]
mod graviola;
#[cfg(feature = "crypto-openssl")]
mod openssl;
#[cfg(feature = "crypto-ring")]
mod ring;
use crate::{crypto::dummy_impl_call, misc::DefaultArray, rng::CryptoRng};
use core::marker::PhantomData;
pub trait Agreement: Sized {
type EphemeralSecretKey;
type PublicKey: AsRef<[u8]>;
type SharedSecret: AsRef<[u8]>;
fn diffie_hellman(
esk: Self::EphemeralSecretKey,
other_participant_pk: &[u8],
) -> crate::Result<Self::SharedSecret>;
fn ephemeral_secret_key<RNG>(rng: &mut RNG) -> crate::Result<Self::EphemeralSecretKey>
where
RNG: CryptoRng;
fn public_key(esk: &Self::EphemeralSecretKey) -> crate::Result<Self::PublicKey>;
}
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AgreementDummy<ESK, PK, SS>(PhantomData<(ESK, PK, SS)>);
impl<ESK, PK, SS> Agreement for AgreementDummy<ESK, PK, SS>
where
ESK: Default,
PK: AsRef<[u8]> + DefaultArray,
SS: AsRef<[u8]> + DefaultArray,
{
type EphemeralSecretKey = ESK;
type PublicKey = PK;
type SharedSecret = SS;
#[inline]
fn diffie_hellman(_: Self::EphemeralSecretKey, _: &[u8]) -> crate::Result<Self::SharedSecret> {
dummy_impl_call();
}
#[inline]
fn ephemeral_secret_key<RNG>(_: &mut RNG) -> crate::Result<Self::EphemeralSecretKey>
where
RNG: CryptoRng,
{
dummy_impl_call();
}
#[inline]
fn public_key(_: &Self::EphemeralSecretKey) -> crate::Result<Self::PublicKey> {
dummy_impl_call();
}
}