use futures::prelude::*;
use crate::SecioError;
#[path = "impl_ring.rs"]
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
mod platform;
#[path = "impl_webcrypto.rs"]
#[cfg(any(target_os = "emscripten", 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<Item = (AgreementPrivateKey, Vec<u8>), Error = SecioError> {
platform::generate_agreement(algorithm).map(|(pr, pu)| (AgreementPrivateKey(pr), pu))
}
#[inline]
pub fn agree(algorithm: KeyAgreement, my_private_key: AgreementPrivateKey, other_public_key: &[u8], out_size: usize)
-> impl Future<Item = Vec<u8>, Error = SecioError>
{
platform::agree(algorithm, my_private_key.0, other_public_key, out_size)
}