Skip to content
Closed
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
with:
persist-credentials: false

- run: cargo fmt --all -- --check
- run: rustup toolchain install nightly --profile minimal --component rustfmt
- run: cargo +nightly fmt --all -- --check

clippy:
runs-on: ${{ matrix.host_os }}
Expand Down
12 changes: 7 additions & 5 deletions bench/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#![allow(missing_docs)]

use criterion::{BatchSize, BenchmarkId, Criterion, black_box, criterion_group, criterion_main};
use ring::{
aead::{self, BoundKey},
error,
rand::{SecureRandom, SystemRandom},
use {
criterion::{BatchSize, BenchmarkId, Criterion, black_box, criterion_group, criterion_main},
ring::{
aead::{self, BoundKey},
error,
rand::{SecureRandom, SystemRandom},
},
};

static ALGORITHMS: &[(&str, &aead::Algorithm)] = &[
Expand Down
10 changes: 6 additions & 4 deletions bench/agreement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#![allow(missing_docs)]

use criterion::{BatchSize, Criterion, black_box, criterion_group, criterion_main};
use ring::{
agreement::{self, EphemeralPrivateKey, UnparsedPublicKey},
rand,
use {
criterion::{BatchSize, Criterion, black_box, criterion_group, criterion_main},
ring::{
agreement::{self, EphemeralPrivateKey, UnparsedPublicKey},
rand,
},
};

static ALGORITHMS: &[(&str, &agreement::Algorithm)] = &[
Expand Down
6 changes: 4 additions & 2 deletions bench/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#![allow(missing_docs)]

use criterion::{BenchmarkId, Criterion, black_box, criterion_group, criterion_main};
use ring::digest;
use {
criterion::{BenchmarkId, Criterion, black_box, criterion_group, criterion_main},
ring::digest,
};

static ALGORITHMS: &[(&str, &digest::Algorithm)] = &[
("sha256", &digest::SHA256),
Expand Down
12 changes: 8 additions & 4 deletions bench/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#![allow(missing_docs)]

use criterion::{BatchSize, Criterion, black_box, criterion_group, criterion_main};
use ring::{
rand,
signature::{self, EcdsaKeyPair, EcdsaSigningAlgorithm, EcdsaVerificationAlgorithm, KeyPair},
use {
criterion::{BatchSize, Criterion, black_box, criterion_group, criterion_main},
ring::{
rand,
signature::{
self, EcdsaKeyPair, EcdsaSigningAlgorithm, EcdsaVerificationAlgorithm, KeyPair,
},
},
};

static ALGORITHMS: &[(&str, &EcdsaSigningAlgorithm, &EcdsaVerificationAlgorithm)] = &[
Expand Down
6 changes: 4 additions & 2 deletions bench/rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#![allow(missing_docs)]

use criterion::{Criterion, criterion_group, criterion_main};
use ring::signature::{RSA_PKCS1_2048_8192_SHA256, UnparsedPublicKey};
use {
criterion::{Criterion, criterion_group, criterion_main},
ring::signature::{RSA_PKCS1_2048_8192_SHA256, UnparsedPublicKey},
};

macro_rules! verify_case {
( $modulus_bits:expr, $exponent_value:expr ) => {
Expand Down
16 changes: 9 additions & 7 deletions build/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
// Avoid `std::env` here. All configuration should be done through `Target`,
// `Profile`, and `Tools`.

use self::path::{join_components_with_forward_slashes_if_windows, walk_dir};
use std::{
ffi::{OsStr, OsString},
fs,
io::Write,
path::{Path, PathBuf},
process::{Command, Stdio},
use {
self::path::{join_components_with_forward_slashes_if_windows, walk_dir},
std::{
ffi::{OsStr, OsString},
fs,
io::Write,
path::{Path, PathBuf},
process::{Command, Stdio},
},
};

mod path;
Expand Down
4 changes: 1 addition & 3 deletions cavp/tests/shavs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ mod digest_shavs {
( $file_name:ident, $algorithm_name:ident ) => {
#[allow(non_snake_case)]
mod $algorithm_name {
use super::run_known_answer_test;
use ring::digest;
#[allow(deprecated)]
use ring::test_file;

#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
use wasm_bindgen_test::wasm_bindgen_test as test;
use {super::run_known_answer_test, ring::digest};

#[test]
fn short_msg_known_answer_test() {
Expand Down
2 changes: 2 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
edition = "2024"
style_edition = "2024"
group_imports = "One"
imports_granularity = "One"
max_width = 100
newline_style = "Unix"
reorder_imports = true
Expand Down
6 changes: 4 additions & 2 deletions src/aead/aes/bs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@

#![cfg(all(target_arch = "arm", target_endian = "little"))]

use super::{Counter, Overlapping, ffi::AES_KEY, vp};
use core::mem::MaybeUninit;
use {
super::{Counter, Overlapping, ffi::AES_KEY, vp},
core::mem::MaybeUninit,
};

#[repr(transparent)]
struct Key(AES_KEY);
Expand Down
13 changes: 7 additions & 6 deletions src/aead/aes/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@

#[allow(unused_imports)]
use crate::polyfill::prelude::*;

use super::{
super::overlapping::IndexError, BLOCK_LEN, Block, Counter, EncryptBlock, EncryptCtr32, Iv,
KeyBytes, Overlapping, ffi,
use {
super::{
super::overlapping::IndexError, BLOCK_LEN, Block, Counter, EncryptBlock, EncryptCtr32, Iv,
KeyBytes, Overlapping, ffi,
},
crate::{bb, polyfill::usize_from_u32},
core::{array, mem::size_of, num::NonZero},
};
use crate::{bb, polyfill::usize_from_u32};
use core::{array, mem::size_of, num::NonZero};

#[derive(Clone)]
pub enum Key {
Expand Down
15 changes: 8 additions & 7 deletions src/aead/aes/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@

#[allow(unused_imports)]
use crate::polyfill::prelude::*;

use super::{AES_128_KEY_LEN, AES_256_KEY_LEN, BLOCK_LEN, KeyBytes, Overlapping};
use crate::{bits::BitLength, c};
use core::{
ffi::{c_int, c_uint},
mem::MaybeUninit,
num::NonZero,
use {
super::{AES_128_KEY_LEN, AES_256_KEY_LEN, BLOCK_LEN, KeyBytes, Overlapping},
crate::{bits::BitLength, c},
core::{
ffi::{c_int, c_uint},
mem::MaybeUninit,
num::NonZero,
},
};

/// nonce || big-endian counter.
Expand Down
10 changes: 5 additions & 5 deletions src/aead/aes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

use super::{NONCE_LEN, Overlapping, nonce::Nonce, overlapping, quic::Sample};
use crate::cpu::{self, GetFeature as _};
use core::num::NonZero;

#[cfg(all(target_arch = "aarch64", target_endian = "little"))]
pub(super) use self::ffi::{RdKey, Rounds};

pub(super) use ffi::Counter;
use {
super::{NONCE_LEN, Overlapping, nonce::Nonce, overlapping, quic::Sample},
crate::cpu::{self, GetFeature as _},
core::num::NonZero,
};

#[macro_use]
mod ffi;
Expand Down
6 changes: 4 additions & 2 deletions src/aead/aes/tests/aes_gcm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
// These AES-GCM-specific tests are here instead of in `aead/tess/` because
// `Counter`'s API isn't visible at that level.

use super::super::{super::aes_gcm::MAX_IN_OUT_LEN, *};
use core::num::NonZero;
use {
super::super::{super::aes_gcm::MAX_IN_OUT_LEN, *},
core::num::NonZero,
};

#[test]
fn test_aes_gcm_counter_blocks_max() {
Expand Down
7 changes: 4 additions & 3 deletions src/aead/aes/tests/aes_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

use super::super::*;
use crate::cpu;
use crate::testutil as test;
use {
super::super::*,
crate::{cpu, testutil as test},
};

#[test]
pub fn test_aes() {
Expand Down
17 changes: 10 additions & 7 deletions src/aead/aes/vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@
target_arch = "x86_64"
))]

#[allow(unused_imports)]
use crate::polyfill::prelude::*;

use super::{Block, Counter, EncryptBlock, EncryptCtr32, Iv, KeyBytes, Overlapping, ffi};
use crate::cpu;
#[cfg(all(target_arch = "aarch64", target_endian = "little"))]
use crate::polyfill::StartMutPtr;
#[allow(unused_imports)]
use crate::polyfill::prelude::*;
#[cfg(any(
all(target_arch = "arm", target_endian = "little"),
target_arch = "x86",
target_arch = "x86_64"
))]
use ffi::AES_KEY;
use {
super::{Block, Counter, EncryptBlock, EncryptCtr32, Iv, KeyBytes, Overlapping, ffi},
crate::cpu,
};

#[cfg(all(target_arch = "aarch64", target_endian = "little"))]
#[derive(Clone)]
Expand Down Expand Up @@ -227,8 +228,10 @@ impl EncryptBlock for Key {
#[cfg(target_arch = "x86")]
impl EncryptCtr32 for Key {
fn ctr32_encrypt_within(&self, mut in_out: Overlapping<'_>, ctr: &mut Counter) {
use super::{BLOCK_LEN, overlapping::IndexError};
use crate::polyfill::sliceutil;
use {
super::{BLOCK_LEN, overlapping::IndexError},
crate::polyfill::sliceutil,
};

assert_eq!(in_out.len() % BLOCK_LEN, 0);
let blocks = in_out.len() / BLOCK_LEN;
Expand Down
9 changes: 5 additions & 4 deletions src/aead/aes_gcm/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

#[allow(unused_imports)]
use crate::polyfill::prelude::*;

use super::{BLOCK_LEN, Counter, Overlapping, aes, gcm};
use crate::{bits::BitLength, polyfill::u64_from_usize};
use core::num::NonZero;
use {
super::{BLOCK_LEN, Counter, Overlapping, aes, gcm},
crate::{bits::BitLength, polyfill::u64_from_usize},
core::num::NonZero,
};

pub(super) fn seal_whole(
aes_key: &aes::hw::Key,
Expand Down
15 changes: 8 additions & 7 deletions src/aead/aes_gcm/aeshwclmulmovbe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@

#[allow(unused_imports)]
use crate::polyfill::prelude::*;

use super::{
super::overlapping::IndexError,
Aad, BLOCK_LEN, Overlapping, Tag,
aes::{self, Counter, EncryptCtr32, OverlappingPartialBlock},
gcm, open_whole_partial_tail,
use {
super::{
super::overlapping::IndexError,
Aad, BLOCK_LEN, Overlapping, Tag,
aes::{self, Counter, EncryptCtr32, OverlappingPartialBlock},
gcm, open_whole_partial_tail,
},
crate::{c, error::InputTooLongError},
};
use crate::{c, error::InputTooLongError};

const STRIDE_LEN: usize = 6 * BLOCK_LEN;

Expand Down
26 changes: 13 additions & 13 deletions src/aead/aes_gcm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@

#[allow(unused_imports)]
use crate::polyfill::prelude::*;

use super::{
Aad, AuthError, ForgedPlaintext, Nonce, Overlapping, Tag,
aes::{self, BLOCK_LEN, Counter, OverlappingPartialBlock, ZERO_BLOCK},
gcm,
overlapping::IndexError,
};
use crate::{
cpu,
error::InputTooLongError,
polyfill::{sliceutil::overwrite_at_start, usize_from_u64_saturated},
};

#[cfg(any(
all(target_arch = "aarch64", target_endian = "little"),
all(target_arch = "arm", target_endian = "little"),
target_arch = "x86",
target_arch = "x86_64"
))]
use cpu::GetFeature as _;
use {
super::{
Aad, AuthError, ForgedPlaintext, Nonce, Overlapping, Tag,
aes::{self, BLOCK_LEN, Counter, OverlappingPartialBlock, ZERO_BLOCK},
gcm,
overlapping::IndexError,
},
crate::{
cpu,
error::InputTooLongError,
polyfill::{sliceutil::overwrite_at_start, usize_from_u64_saturated},
},
};

mod aarch64;
mod aeshwclmulmovbe;
Expand Down
9 changes: 5 additions & 4 deletions src/aead/aes_gcm/vaesclmulavx2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

#[allow(unused_imports)]
use crate::polyfill::prelude::*;

use super::{BLOCK_LEN, Counter, Overlapping, aes, gcm};
use crate::c;
use core::num::NonZero;
use {
super::{BLOCK_LEN, Counter, Overlapping, aes, gcm},
crate::c,
core::num::NonZero,
};

pub(super) fn seal_whole_vaes_clmul_avx2(
aes_key: &aes::hw::Key,
Expand Down
Loading
Loading