1#![warn(rust_2018_idioms)]
2#![allow(dead_code)]
3
4use std::io;
5
6use async_trait::async_trait;
7use thiserror::Error;
8
9#[cfg(feature = "vnet")]
10#[macro_use]
11extern crate lazy_static;
12
13#[cfg(target_family = "windows")]
14#[macro_use]
15extern crate bitflags;
16
17pub mod fixed_big_int;
18pub mod replay_detector;
19
20#[async_trait]
25pub trait KeyingMaterialExporter {
26 async fn export_keying_material(
27 &self,
28 label: &str,
29 context: &[u8],
30 length: usize,
31 ) -> std::result::Result<Vec<u8>, KeyingMaterialExporterError>;
32}
33
34#[derive(Debug, Error, PartialEq)]
40#[non_exhaustive]
41pub enum KeyingMaterialExporterError {
42 #[error("tls handshake is in progress")]
43 HandshakeInProgress,
44 #[error("context is not supported for export_keying_material")]
45 ContextUnsupported,
46 #[error("export_keying_material can not be used with a reserved label")]
47 ReservedExportKeyingMaterial,
48 #[error("no cipher suite for export_keying_material")]
49 CipherSuiteUnset,
50 #[error("export_keying_material io: {0}")]
51 Io(#[source] error::IoError),
52 #[error("export_keying_material hash: {0}")]
53 Hash(String),
54}
55
56impl From<io::Error> for KeyingMaterialExporterError {
57 fn from(e: io::Error) -> Self {
58 KeyingMaterialExporterError::Io(error::IoError(e))
59 }
60}
61
62#[cfg(feature = "buffer")]
63pub mod buffer;
64
65#[cfg(feature = "conn")]
66pub mod conn;
67
68#[cfg(feature = "ifaces")]
69pub mod ifaces;
70
71#[cfg(feature = "vnet")]
72pub mod vnet;
73
74#[cfg(feature = "marshal")]
75pub mod marshal;
76
77#[cfg(feature = "buffer")]
78pub use crate::buffer::Buffer;
79#[cfg(feature = "conn")]
80pub use crate::conn::Conn;
81#[cfg(feature = "marshal")]
82pub use crate::marshal::{exact_size_buf::ExactSizeBuf, Marshal, MarshalSize, Unmarshal};
83
84mod error;
85pub use error::{Error, Result};
86
87#[cfg(feature = "sync")]
88pub mod sync;