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.
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_conversion,
52     clippy::identity_op,
53     clippy::len_without_is_empty,
54     clippy::len_zero,
55     clippy::let_unit_value,
56     clippy::many_single_char_names,
57     clippy::needless_range_loop,
58     clippy::new_without_default,
59     clippy::neg_cmp_op_on_partial_ord,
60     clippy::range_plus_one,
61     clippy::too_many_arguments,
62     clippy::trivially_copy_pass_by_ref,
63     clippy::type_complexity,
64     clippy::unreadable_literal,
65     missing_copy_implementations,
66     missing_debug_implementations,
67     non_camel_case_types,
68     non_snake_case,
69     unsafe_code
70 )]
71 // `#[derive(...)]` uses `trivial_numeric_casts` and `unused_qualifications`
72 // internally.
73 #![deny(missing_docs, unused_qualifications, variant_size_differences)]
74 #![forbid(
75     anonymous_parameters,
76     trivial_casts,
77     trivial_numeric_casts,
78     unstable_features,
79     unused_extern_crates,
80     unused_import_braces,
81     unused_results,
82     warnings
83 )]
84 #![no_std]
85 
86 #[cfg(feature = "alloc")]
87 extern crate alloc;
88 
89 #[macro_use]
90 mod debug;
91 
92 #[macro_use]
93 pub mod test;
94 
95 #[macro_use]
96 mod arithmetic;
97 
98 #[macro_use]
99 mod bssl;
100 
101 #[macro_use]
102 mod polyfill;
103 
104 pub mod aead;
105 pub mod agreement;
106 
107 mod bits;
108 
109 pub(crate) mod c;
110 pub mod constant_time;
111 
112 pub mod io;
113 
114 mod cpu;
115 pub mod digest;
116 mod ec;
117 mod endian;
118 pub mod error;
119 pub mod hkdf;
120 pub mod hmac;
121 mod limb;
122 pub mod pbkdf2;
123 pub mod pkcs8;
124 pub mod rand;
125 
126 #[cfg(feature = "alloc")]
127 mod rsa;
128 
129 pub mod signature;
130 
131 mod sealed {
132     /// Traits that are designed to only be implemented internally in *ring*.
133     //
134     // Usage:
135     // ```
136     // use crate::sealed;
137     //
138     // pub trait MyType: sealed::Sealed {
139     //     // [...]
140     // }
141     //
142     // impl sealed::Sealed for MyType {}
143     // ```
144     pub trait Sealed {}
145 }
146