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 missing_copy_implementations,
51 missing_debug_implementations,
52 non_camel_case_types,
53 non_snake_case,
54 unsafe_code
55)]
56// `#[derive(...)]` uses `trivial_numeric_casts` and `unused_qualifications`
57// internally.
58#![deny(missing_docs, unused_qualifications, variant_size_differences)]
59#![forbid(unused_results)]
60#![no_std]
61
62#[cfg(feature = "alloc")]
63extern crate alloc;
64
65#[macro_use]
66mod debug;
67
68#[macro_use]
69mod prefixed;
70
71#[macro_use]
72pub mod test;
73
74#[macro_use]
75mod arithmetic;
76
77#[macro_use]
78mod bssl;
79
80#[macro_use]
81mod polyfill;
82
83pub mod aead;
84pub mod agreement;
85
86mod bits;
87
88pub(crate) mod c;
89pub mod constant_time;
90
91pub mod io;
92
93mod cpu;
94pub mod digest;
95mod ec;
96mod endian;
97pub mod error;
98pub mod hkdf;
99pub mod hmac;
100mod limb;
101pub mod pbkdf2;
102pub mod pkcs8;
103pub mod rand;
104
105#[cfg(feature = "alloc")]
106mod rsa;
107
108pub mod signature;
109
110mod sealed {
111 /// Traits that are designed to only be implemented internally in *ring*.
112 //
113 // Usage:
114 // ```
115 // use crate::sealed;
116 //
117 // pub trait MyType: sealed::Sealed {
118 // // [...]
119 // }
120 //
121 // impl sealed::Sealed for MyType {}
122 // ```
123 pub trait Sealed {}
124}