1#![forbid(unsafe_code)]
13#![warn(missing_docs, rust_2018_idioms)]
14
15pub mod error;
16pub mod keys;
17pub mod cipher;
18pub mod kdf;
19pub mod cert;
20pub mod hmac_auth;
21
22pub use error::{CryptoError, Result};
23pub use keys::{
24 StaticSecret, PublicKey, SharedSecret,
25 SigningKey, VerifyingKey, Signature,
26 KeyPair,
27};
28pub use cipher::{Cipher, CipherSuite, DataChannelKey, PacketCipher};
29pub use kdf::{derive_keys, KeyMaterial};
30pub use cert::{CertificateAuthority, Certificate, CertificateRequest};
31pub use hmac_auth::HmacAuth;
32
33pub fn random_bytes<const N: usize>() -> [u8; N] {
35 let mut buf = [0u8; N];
36 rand::RngCore::fill_bytes(&mut rand::rngs::OsRng, &mut buf);
37 buf
38}
39
40pub fn generate_session_id() -> [u8; 8] {
42 random_bytes()
43}
44
45pub fn generate_packet_id() -> u32 {
47 u32::from_be_bytes(random_bytes())
48}