Skip to main content

orion/
lib.rs

1// MIT License
2
3// Copyright (c) 2018-2026 The orion Developers
4
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22
23//! A usable pure-Rust cryptography library.
24//!
25//! ## Authenticated secret-key encryption
26//! [`orion::aead`] offers authenticated secret-key encryption using
27//! XChaCha20Poly1305.
28//!
29//! ## Password hashing and verification
30//! [`orion::pwhash`] offers password hashing and verification using Argon2i.
31//!
32//! ## Key derivation
33//! [`orion::kdf`] offers key derivation using Argon2i.
34//!
35//! ## Message authentication
36//! [`orion::auth`] offers message authentication and verification using BLAKE2b.
37//!
38//! ## Hashing
39//! [`orion::hash`] offers hashing using BLAKE2b.
40//!
41//! ## Key exchange
42//! [`orion::kex`] offers ephemeral key exchange using X25519 and BLAKE2b.
43//!
44//! ### A note on `no_std`:
45//! When Orion is used in a `no_std` context, the high-level API is not available, since it relies on access to the systems random number generator.
46//!
47//! More information about Orion is available in the [wiki].
48//!
49//! [`orion::aead`]: crate::aead
50//! [`orion::pwhash`]: crate::pwhash
51//! [`orion::kdf`]: crate::kdf
52//! [`orion::auth`]: crate::auth
53//! [`orion::hash`]: crate::hash
54//! [`orion::kex`]: crate::kex
55//! [wiki]: https://github.com/orion-rs/orion/wiki
56
57#![cfg_attr(not(feature = "safe_api"), no_std)]
58#![forbid(unsafe_code)]
59#![deny(clippy::mem_forget)]
60#![warn(
61    missing_docs,
62    rust_2018_idioms,
63    trivial_casts,
64    unused_qualifications,
65    overflowing_literals
66)]
67#![cfg_attr(docsrs, feature(doc_cfg))]
68
69#[cfg(test)]
70#[cfg(feature = "safe_api")]
71#[macro_use(quickcheck)]
72extern crate quickcheck_macros;
73
74#[cfg(feature = "alloc")]
75extern crate alloc;
76#[cfg(all(not(feature = "alloc"), feature = "safe_api"))]
77extern crate std as alloc;
78
79#[macro_use]
80mod typedefs;
81pub(crate) use typedefs::ZeroizeWrap;
82
83#[macro_use]
84/// Utilities such as constant-time comparison.
85pub mod util;
86
87/// Errors for Orion's cryptographic operations.
88pub mod errors;
89
90/// \[__**Caution**__\] Low-level API.
91pub mod hazardous;
92
93#[cfg(feature = "safe_api")]
94mod high_level;
95
96#[cfg(feature = "safe_api")]
97pub use high_level::hash;
98
99#[cfg(feature = "safe_api")]
100pub use high_level::aead;
101
102#[cfg(feature = "safe_api")]
103pub use high_level::auth;
104
105#[cfg(feature = "safe_api")]
106pub use high_level::pwhash;
107
108#[cfg(feature = "safe_api")]
109pub use high_level::kdf;
110
111#[cfg(feature = "safe_api")]
112pub use high_level::kex;
113
114#[doc(hidden)]
115/// Testing framework.
116pub mod test_framework;