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>std</code>
26 //!     <td>Enable features that use libstd, in particular
27 //!         <code>std::error::Error</code> integration. Implies `alloc`.
28 //! <tr><td><code>wasm32_unknown_unknown_js</code>
29 //!     <td>When this feature is enabled, for the wasm32-unknown-unknown target,
30 //!         Web APIs will be used to implement features like `ring::rand` that
31 //!         require an operating environment of some kind. This has no effect
32 //!         for any other target. This enables the `getrandom` crate's `js`
33 //!         feature.
34 //! </table>
35 
36 // When running mk/package.sh, don't actually build any code.
37 #![cfg(not(pregenerate_asm_only))]
38 #![doc(html_root_url = "https://briansmith.org/rustdoc/")]
39 #![allow(
40     missing_copy_implementations,
41     missing_debug_implementations,
42     non_camel_case_types,
43     non_snake_case,
44     unsafe_code
45 )]
46 // `#[derive(...)]` uses `trivial_numeric_casts` and `unused_qualifications`
47 // internally.
48 #![deny(missing_docs, variant_size_differences)]
49 #![forbid(unused_results)]
50 #![no_std]
51 
52 #[cfg(feature = "alloc")]
53 extern crate alloc;
54 
55 #[macro_use]
56 mod debug;
57 
58 #[macro_use]
59 mod prefixed;
60 
61 #[macro_use]
62 pub mod test;
63 
64 #[macro_use]
65 mod arithmetic;
66 
67 #[macro_use]
68 mod bssl;
69 
70 #[macro_use]
71 mod polyfill;
72 
73 pub mod aead;
74 
75 #[cfg(not(target_arch = "wasm32"))]
76 pub mod agreement;
77 
78 mod bits;
79 
80 pub(crate) mod c;
81 pub mod constant_time;
82 
83 pub mod io;
84 
85 mod cpu;
86 pub mod digest;
87 mod ec;
88 mod endian;
89 pub mod error;
90 pub mod hkdf;
91 pub mod hmac;
92 mod limb;
93 pub mod pbkdf2;
94 pub mod pkcs8;
95 pub mod rand;
96 
97 #[cfg(feature = "alloc")]
98 pub mod rsa;
99 
100 pub mod signature;
101 
102 mod sealed {
103     /// Traits that are designed to only be implemented internally in *ring*.
104     //
105     // Usage:
106     // ```
107     // use crate::sealed;
108     //
109     // pub trait MyType: sealed::Sealed {
110     //     // [...]
111     // }
112     //
113     // impl sealed::Sealed for MyType {}
114     // ```
115     pub trait Sealed {}
116 }
117