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>less-safe-getrandom-custom-or-rdrand</code>
26//!     <td>Treat user-provided ("custom") and RDRAND-based <code>getrandom</code>
27//!         implementations as secure random number generators (see
28//!         <code>SecureRandom</code>). This feature only works with
29//!         <code>os = "none"</code> targets. See
30//!         <a href="https://docs.rs/getrandom/0.2.10/getrandom/macro.register_custom_getrandom.html">
31//!             <code>register_custom_getrandom</code>
32//!         </a> and <a href="https://docs.rs/getrandom/0.2.10/getrandom/#rdrand-on-x86">
33//!             RDRAND on x86
34//!         </a> for additional details.
35//! <tr><td><code>std</code>
36//!     <td>Enable features that use libstd, in particular
37//!         <code>std::error::Error</code> integration. Implies `alloc`.
38//! <tr><td><code>wasm32_unknown_unknown_js</code>
39//!     <td>When this feature is enabled, for the wasm32-unknown-unknown target,
40//!         Web APIs will be used to implement features like `ring::rand` that
41//!         require an operating environment of some kind. This has no effect
42//!         for any other target. This enables the `getrandom` crate's `js`
43//!         feature.
44//! </table>
45
46// When running mk/package.sh, don't actually build any code.
47#![cfg(not(pregenerate_asm_only))]
48#![allow(
49    clippy::collapsible_if,
50    clippy::identity_op,
51    clippy::len_without_is_empty,
52    clippy::let_unit_value,
53    clippy::new_without_default,
54    clippy::neg_cmp_op_on_partial_ord,
55    clippy::too_many_arguments,
56    clippy::type_complexity,
57    non_camel_case_types,
58    non_snake_case,
59    unsafe_code
60)]
61#![deny(variant_size_differences)]
62#![forbid(
63    unused_results,
64    clippy::char_lit_as_u8,
65    clippy::fn_to_numeric_cast,
66    clippy::fn_to_numeric_cast_with_truncation,
67    clippy::ptr_as_ptr
68)]
69#![warn(
70    clippy::unnecessary_cast,
71    clippy::cast_lossless,
72    clippy::cast_possible_truncation,
73    clippy::cast_possible_wrap,
74    clippy::cast_precision_loss,
75    clippy::cast_sign_loss
76)]
77#![no_std]
78
79#[cfg(feature = "alloc")]
80extern crate alloc;
81
82#[macro_use]
83mod debug;
84
85#[macro_use]
86mod prefixed;
87
88#[macro_use]
89pub mod test;
90
91#[macro_use]
92mod arithmetic;
93
94#[macro_use]
95mod bssl;
96
97#[macro_use]
98mod polyfill;
99
100pub mod aead;
101
102pub mod agreement;
103
104mod bits;
105
106pub(crate) mod c;
107pub mod constant_time;
108
109pub mod io;
110
111mod cpu;
112pub mod digest;
113mod ec;
114mod endian;
115pub mod error;
116pub mod hkdf;
117pub mod hmac;
118mod limb;
119pub mod pbkdf2;
120pub mod pkcs8;
121pub mod rand;
122
123#[cfg(feature = "alloc")]
124pub mod rsa;
125
126pub mod signature;
127
128mod sealed {
129    /// Traits that are designed to only be implemented internally in *ring*.
130    //
131    // Usage:
132    // ```
133    // use crate::sealed;
134    //
135    // pub trait MyType: sealed::Sealed {
136    //     // [...]
137    // }
138    //
139    // impl sealed::Sealed for MyType {}
140    // ```
141    pub trait Sealed {}
142}