1#![doc = include_str!("../README.md")]
2#![no_std]
3#![cfg_attr(docsrs, feature(doc_cfg))]
4#![doc(
5 html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg",
6 html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg"
7)]
8#![forbid(unsafe_code)]
9#![warn(missing_docs, unused_qualifications, missing_debug_implementations)]
10
11pub use crypto_common::{KeyInit, KeySizeUser, typenum::consts};
12
13use core::fmt::Debug;
14use rand_core::TryCryptoRng;
15
16pub trait Encapsulate<EK, SS> {
20 type Error: Debug;
22
23 fn encapsulate<R: TryCryptoRng + ?Sized>(&self, rng: &mut R) -> Result<(EK, SS), Self::Error>;
25}
26
27pub trait Decapsulate<EK, SS> {
32 type Encapsulator: Encapsulate<EK, SS>;
34
35 type Error: Debug;
37
38 fn decapsulate(&self, encapsulated_key: &EK) -> Result<SS, Self::Error>;
40
41 fn encapsulator(&self) -> Self::Encapsulator;
43}