Skip to main content

tls2/
tls.rs

1//! Zero-allocation, `no_std` compatible TLS
2//!
3
4#![cfg_attr(not(feature = "std"), no_std)]
5#![cfg(feature = "std")]
6extern crate alloc;
7
8mod client;
9mod crypto;
10mod errors;
11pub mod key_schedule;
12mod message;
13mod record;
14
15#[cfg(feature = "std")]
16mod certificates;
17
18#[cfg(feature = "std")]
19pub use certificates::*;
20
21#[cfg(feature = "crypto-default-provider")]
22pub mod crypto_default_provider;
23
24#[cfg(feature = "tokio")]
25pub mod tokio;
26
27// Re-exports from the public API
28
29pub use client::*;
30pub use crypto::*;
31pub use errors::*;
32
33/// The maximum size, in bytes, of a hash
34pub const MAX_HASH_SIZE: usize = 48;
35pub const PSK_MAX_SIZE: usize = MAX_HASH_SIZE;
36pub const AEAD_MAX_KEY_SIZE: usize = 32;
37/// The fixed size of AEAD tags
38pub const AEAD_TAG_SIZE: usize = 16;
39/// 32-byte X25519 seed + 64-byte ML-KEM 768 seed
40pub const KEY_EXCHANGE_SECRET_KEY_MAX_SIZE: usize = 32 + 64;
41/// The maximum size, in bytes, of a key exchange public key
42pub const KEY_EXCHANGE_PUBLIC_KEY_MAX_SIZE: usize = 1216;
43pub const KEY_EXCHANGE_SHARED_SECRET_MAX_SIZE: usize = 64;
44/// The maximum number of supported key exchange groups in ClientHello
45pub const KEY_EXCHANGE_MAX_GROUPS: usize = 3;
46/// The maximum size, in bytes, of a SPKI-encoded signing public key
47pub const SIGNING_PUBLIC_KEY_MAX_SIZE: usize = 294;
48pub const SIGNATURE_MAX_SIZE: usize = 256;
49pub const ALPN_PROTOCOL_MAX_SIZE: usize = 32;
50
51/// Maximum size of a fully framed TLS record (5-byte header + payload + padding + tag).
52/// 5 + 16384 + 1 + 256 + 16 = 16662.
53pub const MAX_RECORD_SIZE: usize = 16662;
54
55/// Maximum number of certificates allowed in a chain.
56pub const MAX_CERTS: usize = 10;