Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/aead/chacha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use super::{
Block, BLOCK_LEN,
};
use crate::{endian::*, polyfill::convert::*};
use core;
use libc::size_t;

#[repr(C)]
Expand Down Expand Up @@ -145,6 +144,7 @@ pub const KEY_LEN: usize = KEY_BLOCKS * BLOCK_LEN;
mod tests {
use super::*;
use crate::test;
use std::vec;

// This verifies the encryption functionality provided by ChaCha20_ctr32
// is successful when either computed on disjoint input/output buffers,
Expand Down
3 changes: 2 additions & 1 deletion src/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// as possible.

use crate::{cpu, debug, endian::*, polyfill};
use core::{self, num::Wrapping};
use core::num::Wrapping;
use libc::size_t;

mod sha1;
Expand Down Expand Up @@ -507,6 +507,7 @@ mod tests {
mod max_input {
use super::super::super::digest;
use crate::polyfill;
use std::vec;

macro_rules! max_input_tests {
( $algorithm_name:ident ) => {
Expand Down
2 changes: 1 addition & 1 deletion src/digest/sha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

use crate::polyfill;
use core::{self, num::Wrapping};
use core::num::Wrapping;
use libc::size_t;

pub const BLOCK_LEN: usize = 512 / 8;
Expand Down
1 change: 0 additions & 1 deletion src/ec/curve25519/ed25519/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use crate::{
rand,
signature::{self, KeyPair as SigningKeyPair},
};
use core;
use untrusted;

use super::digest::*;
Expand Down
1 change: 0 additions & 1 deletion src/ec/curve25519/ed25519/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

use super::super::ops::*;
use crate::{error, polyfill::convert::*, sealed, signature};
use core;
use untrusted;

use super::digest::*;
Expand Down
1 change: 0 additions & 1 deletion src/ec/suite_b/ecdh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ fn ecdh(
mod tests {
use super::super::ops;
use crate::{agreement, ec, limb, test};
use core;

static SUPPORTED_SUITE_B_ALGS: [(&str, &agreement::Algorithm, &ec::Curve, &ops::CommonOps); 2] = [
(
Expand Down
1 change: 0 additions & 1 deletion src/ec/suite_b/ecdsa/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use crate::{
io::der,
limb, pkcs8, rand, sealed, signature,
};
use core;
use untrusted;

/// An ECDSA signing algorithm.
Expand Down
1 change: 1 addition & 0 deletions src/ec/suite_b/ecdsa/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ pub static ECDSA_P384_SHA384_ASN1: EcdsaVerificationAlgorithm = EcdsaVerificatio
mod tests {
use super::*;
use crate::test;
use std::vec::Vec;

#[test]
fn test_digest_based_test_vectors() {
Expand Down
2 changes: 1 addition & 1 deletion src/ec/suite_b/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ extern "C" {
mod tests {
use super::*;
use crate::test;
use std;
use std::{format, print, vec, vec::Vec};
use untrusted;

const ZERO_SCALAR: Scalar = Scalar {
Expand Down
7 changes: 1 addition & 6 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@
//! Error reporting.

use crate::polyfill::convert::*;
use core;
use untrusted;

#[cfg(feature = "use_heap")]
use std;

/// An error with absolutely no details.
///
/// *ring* uses this unit type as the error type in most of its results
Expand Down Expand Up @@ -212,8 +208,7 @@ impl std::error::Error for KeyRejected {
}
}

#[cfg(feature = "use_heap")]
impl std::fmt::Display for KeyRejected {
impl core::fmt::Display for KeyRejected {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.write_str(self.description_())
}
Expand Down
1 change: 1 addition & 0 deletions src/io/der_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

use super::{der::*, writer::*, *};
use std::boxed::Box;

pub(crate) fn write_positive_integer(output: &mut Accumulator, value: &Positive) {
let first_byte = value.first_byte();
Expand Down
2 changes: 2 additions & 0 deletions src/io/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

use std::{boxed::Box, vec::Vec};

pub trait Accumulator {
fn write_byte(&mut self, value: u8);
fn write_bytes(&mut self, value: &[u8]);
Expand Down
17 changes: 4 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,12 @@
unused_results,
warnings
)]
#![cfg_attr(
any(
target_os = "redox",
all(
not(test),
not(feature = "use_heap"),
unix,
not(any(target_os = "macos", target_os = "ios")),
any(not(target_os = "linux"), feature = "dev_urandom_fallback")
)
),
no_std
)]
#![no_std]
#![cfg_attr(feature = "internal_benches", allow(unstable_features), feature(test))]

#[cfg(any(test, feature = "use_heap"))]
extern crate std;

#[macro_use]
mod debug;

Expand Down
1 change: 0 additions & 1 deletion src/pkcs8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
//! [RFC 5958]: https://tools.ietf.org/html/rfc5958.

use crate::{ec, error, io::der};
use core;
use untrusted;

pub(crate) enum Version {
Expand Down
2 changes: 0 additions & 2 deletions src/polyfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
//! Polyfills for functionality that will (hopefully) be added to Rust's
//! standard library soon.

use core;

#[macro_use]
pub mod convert;

Expand Down
3 changes: 1 addition & 2 deletions src/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ mod sysrand_chunk {
#[cfg(windows)]
mod sysrand_chunk {
use crate::{error, polyfill};
use core;

#[inline]
pub fn chunk(dest: &mut [u8]) -> Result<usize, error::Unspecified> {
Expand Down Expand Up @@ -212,7 +211,6 @@ mod sysrand {
))]
mod urandom {
use crate::error;
use std;

pub fn fill(dest: &mut [u8]) -> Result<(), error::Unspecified> {
use lazy_static::lazy_static;
Expand Down Expand Up @@ -321,6 +319,7 @@ mod fuchsia {
#[cfg(test)]
mod tests {
use crate::rand::{self, SecureRandom};
use std::vec;

#[test]
fn test_system_random_lengths() {
Expand Down
9 changes: 7 additions & 2 deletions src/rsa/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ use crate::{
limb::{self, Limb, LimbMask, LIMB_BITS, LIMB_BYTES},
};
use core::{
self,
marker::PhantomData,
ops::{Deref, DerefMut},
};
use libc::size_t;
use std::borrow::ToOwned as _; // TODO: Remove; Redundant as of Rust 1.36.
use std::{
borrow::ToOwned as _, // TODO: Remove; Redundant as of Rust 1.36.
boxed::Box,
vec,
vec::Vec,
};
use untrusted;

pub unsafe trait Prime {}
Expand Down Expand Up @@ -1294,6 +1298,7 @@ extern "C" {
mod tests {
use super::*;
use crate::test;
use std::format;
use untrusted;

// Type-level representation of an arbitrary modulus.
Expand Down
1 change: 1 addition & 0 deletions src/rsa/padding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ rsa_pss_padding!(
mod test {
use super::*;
use crate::{digest, error, test};
use std::vec;
use untrusted;

#[test]
Expand Down
2 changes: 2 additions & 0 deletions src/rsa/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::{
io::{self, der, der_writer},
pkcs8, rand, signature,
};
use std::boxed::Box;
use untrusted;

/// An RSA key pair, used for signing.
Expand Down Expand Up @@ -609,6 +610,7 @@ mod tests {
// We intentionally avoid `use super::*` so that we are sure to use only
// the public API; this ensures that enough of the API is public.
use crate::{rand, signature};
use std::vec;

// `KeyPair::sign` requires that the output buffer is the same length as
// the public key modulus. Test what happens when it isn't the same length.
Expand Down
1 change: 0 additions & 1 deletion src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@
//! ```

use crate::{cpu, ec, error, sealed};
use core;
use untrusted;

pub use crate::ec::{
Expand Down
7 changes: 3 additions & 4 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ use crate::bits;

use crate::{digest, error};

use core;
use std::{self, string::String, vec::Vec};
use std::{format, string::String, vec::Vec};
use std::{panic, println};

/// `compile_time_assert_clone::<T>();` fails to compile if `T` doesn't
/// implement `Clone`.
Expand Down Expand Up @@ -310,7 +310,7 @@ where

#[allow(box_pointers)]
while let Some(mut test_case) = parse_test_case(&mut current_section, lines) {
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
let result = panic::catch_unwind(panic::AssertUnwindSafe(|| {
f(&current_section, &mut test_case)
}));
let result = match result {
Expand Down Expand Up @@ -455,7 +455,6 @@ fn parse_test_case(
#[allow(missing_docs)]
pub mod rand {
use crate::{error, polyfill, rand, sealed};
use core;

/// An implementation of `SecureRandom` that always fills the output slice
/// with the given byte.
Expand Down