Skip to main content

fast_floe/
lib.rs

1#![forbid(unsafe_code)]
2#![doc = include_str!("../README.md")]
3
4#[cfg(not(any(
5    feature = "rustcrypto",
6    feature = "aws-lc-rs",
7    feature = "boring",
8    feature = "ring"
9)))]
10compile_error!("enable at least one FLOE provider: aws-lc-rs, boring, ring, or rustcrypto");
11
12mod backends;
13mod buffer;
14mod error;
15pub mod io;
16mod key;
17pub mod online;
18mod parameters;
19mod provider;
20pub mod random_access;
21mod state;
22mod wire;
23
24pub use error::{Error, LengthRequirement, Result};
25pub use key::Key;
26pub use online::{decrypt, decrypt_with_parameters, encrypt};
27pub use parameters::{Parameters, SEGMENT_PREFIX_LENGTH, SegmentFraming, SegmentKind};
28pub use provider::Provider;
29pub use state::Header;
30
31/// Framing, backend, and raw random-access primitives for experts.
32///
33/// These APIs expose more of the FLOE state machine and require callers
34/// to preserve message-level invariants (and to know those invariants exist).
35///
36/// In particular, callers processing segments themselves must uphold the
37/// obligations that higher-level APIs abstract away:
38///
39///   - Encrypt each position at most once
40///   - Produce exactly one final segment
41///   - Leave no gaps
42///   - Never process positions beyond the final segment.
43///
44/// Prefer the higher-level APIs unless manual segment processing or parallel
45/// access is required.
46pub mod low_level {
47    pub use crate::buffer::SegmentBuffer;
48    pub use crate::parameters::{
49        MessageLayout, SEGMENT_PAYLOAD_OFFSET, SegmentKind, SegmentLayout, Segments,
50    };
51    pub use crate::state::{
52        DecryptionState, EncryptionState, SharedDecryptionContext, SharedEncryptionContext,
53        start_decryption, start_decryption_inferred, start_encryption,
54    };
55}
56
57pub(crate) use buffer::SegmentBuffer;
58pub(crate) use parameters::{
59    AEAD_IV_LENGTH, AEAD_MAX_SEGMENTS, AEAD_TAG_LENGTH, ENCODED_PARAMETERS_LENGTH, FLOE_IV_LENGTH,
60    HEADER_LENGTH, HEADER_LENGTH_U64, HEADER_TAG_LENGTH, SEGMENT_OVERHEAD, SEGMENT_PAYLOAD_OFFSET,
61    SegmentLayout, length_u32_to_usize, length_u64_to_usize_saturating, length_usize_to_u64,
62};
63pub(crate) use state::{
64    DecryptionState, EncryptionState, start_decryption, start_decryption_inferred, start_encryption,
65};
66
67#[cfg(test)]
68mod tests;