Skip to main content

oxicrypto_core/
lib.rs

1#![forbid(unsafe_code)]
2#![no_std]
3
4//! `oxicrypto-core` -- pure-Rust trait surface, error types, and secure
5//! wrappers for the OxiCrypto stack.
6//!
7//! This crate is `no_std`.  With the default `alloc` feature it is
8//! `no_std + alloc`; with `--no-default-features` it links only `core` and
9//! exposes a genuinely allocation-free API surface (`SecretKey<N>`,
10//! `Hash::hash` / `hash_to_array::<N>`, constant-time utilities, `CryptoError`,
11//! `AlgorithmId`).  It defines the trait objects, error enum, constant-time
12//! utilities, and secret-key wrappers shared by every other `oxicrypto-*`
13//! sub-crate.  No crypto implementation lives here.
14
15#[cfg(feature = "alloc")]
16extern crate alloc;
17
18#[cfg(feature = "alloc")]
19pub use alloc::boxed::Box;
20#[cfg(feature = "alloc")]
21pub use alloc::string::String;
22#[cfg(feature = "alloc")]
23pub use alloc::vec::Vec;
24
25// Re-export `subtle` so downstream crates use a single version.
26pub use subtle::ConstantTimeEq;
27pub use zeroize::{Zeroize, ZeroizeOnDrop};
28
29// ---------------------------------------------------------------------------
30// Submodules
31// ---------------------------------------------------------------------------
32
33mod algo_id;
34mod ct;
35mod error;
36mod secret;
37pub mod traits;
38
39// ---------------------------------------------------------------------------
40// Public re-exports
41// ---------------------------------------------------------------------------
42
43pub use algo_id::{AlgorithmCategory, AlgorithmId};
44pub use ct::{ct_eq, ct_is_zero, ct_select};
45pub use error::CryptoError;
46#[cfg(feature = "alloc")]
47pub use secret::SecretVec;
48pub use secret::{KeyPair, SecretKey};
49#[cfg(feature = "alloc")]
50pub use traits::KeyGenerator;
51pub use traits::{
52    Aead, Hash, Kdf, Kem, KeyAgreement, Mac, PasswordHash, PasswordHashParams, Rng, Signer,
53    StreamingAead, StreamingHash, StreamingMac, Verifier,
54};
55
56// ---------------------------------------------------------------------------
57// Tests
58// ---------------------------------------------------------------------------
59
60// The in-crate test suite exercises the alloc-returning convenience methods, so
61// it is only compiled when the `alloc` feature is on (the default).
62#[cfg(all(test, feature = "alloc"))]
63mod tests;