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