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_c</code>
37//! <td>Enables features that require a C compiler on wasm32 targets, such as
38//! the <code>constant_time</code> module, HMAC verification, and PBKDF2
39//! verification. Without this feature, only a subset of functionality
40//! is provided to wasm32 targets so that a C compiler isn't needed. A
41//! typical invocation would be:
42//! <code>TARGET_CC=clang-10 TARGET_AR=llvm-ar-10 cargo test --target=wasm32-unknown-unknown --features=wasm32_c</code>
43//! with <code>llvm-ar-10</code> and <code>clang-10</code> in <code>$PATH</code>.
44//! (Going forward more functionality should be enabled by default, without
45//! requiring these hacks, and without requiring a C compiler.)
46//! </table>
47
48#![doc(html_root_url = "https://briansmith.org/rustdoc/")]
49#![allow(
50 clippy::collapsible_if,
51 clippy::identity_op,
52 clippy::len_without_is_empty,
53 clippy::len_zero,
54 clippy::let_unit_value,
55 clippy::many_single_char_names,
56 clippy::needless_range_loop,
57 clippy::new_without_default,
58 clippy::neg_cmp_op_on_partial_ord,
59 clippy::range_plus_one,
60 clippy::too_many_arguments,
61 clippy::trivially_copy_pass_by_ref,
62 clippy::type_complexity,
63 clippy::unreadable_literal,
64 missing_copy_implementations,
65 missing_debug_implementations,
66 non_camel_case_types,
67 non_snake_case,
68 unsafe_code
69)]
70// `#[derive(...)]` uses `trivial_numeric_casts` and `unused_qualifications`
71// internally.
72#![deny(missing_docs, unused_qualifications, variant_size_differences)]
73#![forbid(unused_results)]
74#![no_std]
75
76#[cfg(feature = "alloc")]
77extern crate alloc;
78
79#[macro_use]
80mod debug;
81
82#[macro_use]
83pub mod test;
84
85#[macro_use]
86mod arithmetic;
87
88#[macro_use]
89mod bssl;
90
91#[macro_use]
92mod polyfill;
93
94pub mod aead;
95pub mod agreement;
96
97mod bits;
98
99pub(crate) mod c;
100pub mod constant_time;
101
102pub mod io;
103
104mod cpu;
105pub mod digest;
106mod ec;
107mod endian;
108pub mod error;
109pub mod hkdf;
110pub mod hmac;
111mod limb;
112pub mod pbkdf2;
113pub mod pkcs8;
114pub mod rand;
115
116#[cfg(feature = "alloc")]
117mod rsa;
118
119pub mod signature;
120
121mod sealed {
122 /// Traits that are designed to only be implemented internally in *ring*.
123 //
124 // Usage:
125 // ```
126 // use crate::sealed;
127 //
128 // pub trait MyType: sealed::Sealed {
129 // // [...]
130 // }
131 //
132 // impl sealed::Sealed for MyType {}
133 // ```
134 pub trait Sealed {}
135}