use futures::prelude::*;
use crate::SecioError;
#[path = "exchange/impl_ring.rs"]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
mod platform;
#[path = "exchange/impl_webcrypto.rs"]
#[cfg(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown"))]
mod platform;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum KeyAgreement {
EcdhP256,
EcdhP384
}
pub struct AgreementPrivateKey(platform::AgreementPrivateKey);
#[inline]
pub fn generate_agreement(algorithm: KeyAgreement) -> impl Future<Output = Result<(AgreementPrivateKey, Vec<u8>), SecioError>> {
platform::generate_agreement(algorithm).map_ok(|(pr, pu)| (AgreementPrivateKey(pr), pu))
}
#[inline]
pub fn agree(algorithm: KeyAgreement, my_private_key: AgreementPrivateKey, other_public_key: &[u8], out_size: usize)
-> impl Future<Output = Result<Vec<u8>, SecioError>>
{
platform::agree(algorithm, my_private_key.0, other_public_key, out_size)
}