ring/
lib.rs

1// Copyright 2015-2016 Brian Smith.
2//
3// Permission to use, copy, modify, and/or distribute this software for any
4// purpose with or without fee is hereby granted, provided that the above
5// copyright notice and this permission notice appear in all copies.
6//
7// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
8// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
10// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
15//! Safe, fast, small crypto using Rust with BoringSSL's cryptography
16//! primitives.
17//!
18//! # Feature Flags
19//!
20//! <table>
21//! <tr><th>Feature
22//!     <th>Description
23//! <tr><td><code>alloc (default)</code>
24//!     <td>Enable features that require use of the heap, RSA in particular.
25//! <tr><td><code>dev_urandom_fallback (default)</code>
26//!     <td>This is only applicable to Linux. On Linux, by default,
27//!         <code>ring::rand::SystemRandom</code> will fall back to reading
28//!         from <code>/dev/urandom</code> if the <code>getrandom()</code>
29//!         syscall isn't supported at runtime. When the
30//!         <code>dev_urandom_fallback</code> feature is disabled, such
31//!         fallbacks will not occur. See the documentation for
32//!         <code>rand::SystemRandom</code> for more details.
33//! <tr><td><code>std</code>
34//!     <td>Enable features that use libstd, in particular
35//!         <code>std::error::Error</code> integration. Implies `alloc`.
36//! <tr><td><code>wasm32_unknown_unknown_js</code>
37//!     <td>When this feature is enabled, for the wasm32-unknown-unknown target,
38//!         Web APIs will be used to implement features like `ring::rand` that
39//!         require an operating environment of some kind. This has no effect
40//!         for any other target.
41//! </table>
42
43#![doc(html_root_url = "https://briansmith.org/rustdoc/")]
44#![allow(
45    clippy::collapsible_if,
46    clippy::identity_op,
47    clippy::len_without_is_empty,
48    clippy::len_zero,
49    clippy::let_unit_value,
50    clippy::many_single_char_names,
51    clippy::needless_range_loop,
52    clippy::new_without_default,
53    clippy::neg_cmp_op_on_partial_ord,
54    clippy::range_plus_one,
55    clippy::too_many_arguments,
56    clippy::trivially_copy_pass_by_ref,
57    clippy::type_complexity,
58    clippy::unreadable_literal,
59    missing_copy_implementations,
60    missing_debug_implementations,
61    non_camel_case_types,
62    non_snake_case,
63    unsafe_code
64)]
65// `#[derive(...)]` uses `trivial_numeric_casts` and `unused_qualifications`
66// internally.
67#![deny(missing_docs, unused_qualifications, variant_size_differences)]
68#![forbid(unused_results)]
69#![no_std]
70
71#[cfg(feature = "alloc")]
72extern crate alloc;
73
74#[macro_use]
75mod debug;
76
77#[macro_use]
78pub mod test;
79
80#[macro_use]
81mod arithmetic;
82
83#[macro_use]
84mod bssl;
85
86#[macro_use]
87mod polyfill;
88
89pub mod aead;
90pub mod agreement;
91
92mod bits;
93
94pub(crate) mod c;
95pub mod constant_time;
96
97pub mod io;
98
99mod cpu;
100pub mod digest;
101mod ec;
102mod endian;
103pub mod error;
104pub mod hkdf;
105pub mod hmac;
106mod limb;
107pub mod pbkdf2;
108pub mod pkcs8;
109pub mod rand;
110
111#[cfg(feature = "alloc")]
112mod rsa;
113
114pub mod signature;
115
116mod sealed {
117    /// Traits that are designed to only be implemented internally in *ring*.
118    //
119    // Usage:
120    // ```
121    // use crate::sealed;
122    //
123    // pub trait MyType: sealed::Sealed {
124    //     // [...]
125    // }
126    //
127    // impl sealed::Sealed for MyType {}
128    // ```
129    pub trait Sealed {}
130}