Skip to content

Commit e4f44ab

Browse files
authored
Formatting: Change import granularity to "Module" (#672)
* Change import granularity to Module * Use 'Module' granularity
1 parent 76bcc06 commit e4f44ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+201
-263
lines changed

.rustfmt.toml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
imports_granularity = "Module"

aws-lc-rs-testing/benches/kem_benchmark.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0 OR ISC
33

4-
use aws_lc_rs::{
5-
kem::DecapsulationKey,
6-
kem::{Algorithm, ML_KEM_1024, ML_KEM_512, ML_KEM_768},
7-
};
4+
use aws_lc_rs::kem::{Algorithm, DecapsulationKey, ML_KEM_1024, ML_KEM_512, ML_KEM_768};
85
use criterion::{criterion_group, criterion_main, Criterion};
96

107
const KEM_ALGORITHMS: &[Algorithm; 3] = &[ML_KEM_512, ML_KEM_768, ML_KEM_1024];

aws-lc-rs/examples/cipher.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,12 @@
2424
//! $ cargo run --example cipher -- decrypt --mode cbc --key 6489d8ce0c4facf18b872705a05d5ee4 --iv 5cd56fb752830ec2459889226c5431bd 6311c14e8104730be124ce1e57e51fe3
2525
//! Hello World
2626
//! ```
27-
use aws_lc_rs::{
28-
cipher::{
29-
DecryptingKey, DecryptionContext, EncryptingKey, EncryptionContext,
30-
PaddedBlockDecryptingKey, PaddedBlockEncryptingKey, UnboundCipherKey, AES_128,
31-
AES_128_KEY_LEN, AES_192, AES_192_KEY_LEN, AES_256, AES_256_KEY_LEN, AES_CBC_IV_LEN,
32-
AES_CTR_IV_LEN,
33-
},
34-
iv::FixedLength,
27+
use aws_lc_rs::cipher::{
28+
DecryptingKey, DecryptionContext, EncryptingKey, EncryptionContext, PaddedBlockDecryptingKey,
29+
PaddedBlockEncryptingKey, UnboundCipherKey, AES_128, AES_128_KEY_LEN, AES_192, AES_192_KEY_LEN,
30+
AES_256, AES_256_KEY_LEN, AES_CBC_IV_LEN, AES_CTR_IV_LEN,
3531
};
32+
use aws_lc_rs::iv::FixedLength;
3633
use clap::{Parser, Subcommand, ValueEnum};
3734

3835
#[derive(Parser)]

aws-lc-rs/src/aead.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,12 @@
180180
//! # }
181181
//! ```
182182
183-
use crate::{derive_debug_via_id, error::Unspecified, hkdf};
183+
use crate::error::Unspecified;
184+
use crate::{derive_debug_via_id, hkdf};
184185
use aead_ctx::AeadCtx;
185-
use core::{fmt::Debug, ops::RangeFrom, stringify};
186+
use core::fmt::Debug;
187+
use core::ops::RangeFrom;
188+
use core::stringify;
186189
use paste::paste;
187190

188191
mod aead_ctx;
@@ -197,14 +200,12 @@ mod rand_nonce;
197200
mod tls;
198201
mod unbound_key;
199202

200-
pub use self::{
201-
aes_gcm::{AES_128_GCM, AES_128_GCM_SIV, AES_192_GCM, AES_256_GCM, AES_256_GCM_SIV},
202-
chacha::CHACHA20_POLY1305,
203-
nonce::{Nonce, NONCE_LEN},
204-
rand_nonce::RandomizedNonceKey,
205-
tls::{TlsProtocolId, TlsRecordOpeningKey, TlsRecordSealingKey},
206-
unbound_key::UnboundKey,
207-
};
203+
pub use self::aes_gcm::{AES_128_GCM, AES_128_GCM_SIV, AES_192_GCM, AES_256_GCM, AES_256_GCM_SIV};
204+
pub use self::chacha::CHACHA20_POLY1305;
205+
pub use self::nonce::{Nonce, NONCE_LEN};
206+
pub use self::rand_nonce::RandomizedNonceKey;
207+
pub use self::tls::{TlsProtocolId, TlsRecordOpeningKey, TlsRecordSealingKey};
208+
pub use self::unbound_key::UnboundKey;
208209

209210
/// A sequences of unique nonces.
210211
///
@@ -1019,7 +1020,8 @@ mod tests {
10191020
use nonce_sequence::Counter32Builder;
10201021

10211022
use super::*;
1022-
use crate::{iv::FixedLength, test::from_hex};
1023+
use crate::iv::FixedLength;
1024+
use crate::test::from_hex;
10231025

10241026
#[cfg(feature = "fips")]
10251027
mod fips;

aws-lc-rs/src/aead/chacha20_poly1305_openssh.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
use super::{poly1305, Nonce, Tag};
2727
use crate::cipher::block::BLOCK_LEN;
2828
use crate::cipher::chacha::{self, ChaCha20Key};
29+
use crate::endian::BigEndian;
2930
use crate::iv::FixedLength;
30-
use crate::{constant_time, endian::BigEndian, error};
31+
use crate::{constant_time, error};
3132

3233
/// A key for sealing packets.
3334
pub struct SealingKey {

aws-lc-rs/src/aead/rand_nonce.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
use crate::error::Unspecified;
55
use core::fmt::Debug;
66

7-
use super::{aead_ctx::AeadCtx, Aad, Algorithm, AlgorithmID, Nonce, Tag, UnboundKey};
7+
use super::aead_ctx::AeadCtx;
8+
use super::{Aad, Algorithm, AlgorithmID, Nonce, Tag, UnboundKey};
89

910
/// AEAD Cipher key using a randomized nonce.
1011
///
@@ -148,10 +149,8 @@ impl Debug for RandomizedNonceKey {
148149
#[cfg(test)]
149150
mod tests {
150151
use super::{Aad, RandomizedNonceKey};
151-
use crate::{
152-
aead::{AES_128_GCM, AES_256_GCM, CHACHA20_POLY1305},
153-
test::from_hex,
154-
};
152+
use crate::aead::{AES_128_GCM, AES_256_GCM, CHACHA20_POLY1305};
153+
use crate::test::from_hex;
155154
use paste::paste;
156155

157156
const TEST_128_BIT_KEY: &[u8] = &[

aws-lc-rs/src/aead/tests/fips.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
mod chacha20_poly1305_openssh;
77
mod quic;
88

9-
use crate::{
10-
aead::{
11-
nonce_sequence::Counter64Builder, Aad, BoundKey, Nonce, OpeningKey, RandomizedNonceKey,
12-
SealingKey, TlsProtocolId, TlsRecordOpeningKey, TlsRecordSealingKey, UnboundKey,
13-
AES_128_GCM, AES_256_GCM, CHACHA20_POLY1305,
14-
},
15-
fips::{assert_fips_status_indicator, FipsServiceStatus},
9+
use crate::aead::nonce_sequence::Counter64Builder;
10+
use crate::aead::{
11+
Aad, BoundKey, Nonce, OpeningKey, RandomizedNonceKey, SealingKey, TlsProtocolId,
12+
TlsRecordOpeningKey, TlsRecordSealingKey, UnboundKey, AES_128_GCM, AES_256_GCM,
13+
CHACHA20_POLY1305,
1614
};
15+
use crate::fips::{assert_fips_status_indicator, FipsServiceStatus};
1716

1817
const TEST_KEY_128_BIT: [u8; 16] = [
1918
0x9f, 0xd9, 0x41, 0xc3, 0xa6, 0xfe, 0xb9, 0x26, 0x2a, 0x35, 0xa7, 0x44, 0xbb, 0xc0, 0x3a, 0x6a,

aws-lc-rs/src/aead/tests/fips/chacha20_poly1305_openssh.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0 OR ISC
33

4-
use crate::{
5-
aead::chacha20_poly1305_openssh::{OpeningKey, SealingKey},
6-
fips::{assert_fips_status_indicator, FipsServiceStatus},
7-
};
4+
use crate::aead::chacha20_poly1305_openssh::{OpeningKey, SealingKey};
5+
use crate::fips::{assert_fips_status_indicator, FipsServiceStatus};
86

97
use super::TEST_MESSAGE;
108

aws-lc-rs/src/aead/tests/fips/quic.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0 OR ISC
33

4-
use crate::{
5-
aead::quic::{HeaderProtectionKey, AES_128, AES_256, CHACHA20},
6-
fips::{assert_fips_status_indicator, FipsServiceStatus},
7-
};
4+
use crate::aead::quic::{HeaderProtectionKey, AES_128, AES_256, CHACHA20};
5+
use crate::fips::{assert_fips_status_indicator, FipsServiceStatus};
86

97
use super::{TEST_KEY_128_BIT, TEST_KEY_256_BIT};
108

aws-lc-rs/src/aead/tls.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0 OR ISC
33

4-
use super::{
5-
aead_ctx::{self, AeadCtx},
6-
Aad, Algorithm, AlgorithmID, Nonce, Tag, UnboundKey,
7-
};
4+
use super::aead_ctx::{self, AeadCtx};
5+
use super::{Aad, Algorithm, AlgorithmID, Nonce, Tag, UnboundKey};
86
use crate::error::Unspecified;
97
use core::fmt::Debug;
108
use core::ops::RangeFrom;
@@ -298,11 +296,8 @@ impl Debug for TlsRecordOpeningKey {
298296
#[cfg(test)]
299297
mod tests {
300298
use super::{TlsProtocolId, TlsRecordOpeningKey, TlsRecordSealingKey};
301-
use crate::{
302-
aead::Aad,
303-
aead::{Nonce, AES_128_GCM, AES_256_GCM, CHACHA20_POLY1305},
304-
test::from_hex,
305-
};
299+
use crate::aead::{Aad, Nonce, AES_128_GCM, AES_256_GCM, CHACHA20_POLY1305};
300+
use crate::test::from_hex;
306301
use paste::paste;
307302

308303
const TEST_128_BIT_KEY: &[u8] = &[

aws-lc-rs/src/aead/unbound_key.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0 OR ISC
33

4-
use super::{aead_ctx::AeadCtx, Algorithm, Nonce, MAX_KEY_LEN, MAX_TAG_LEN, NONCE_LEN};
4+
use super::aead_ctx::AeadCtx;
55
use super::{
6-
Tag, AES_128_GCM, AES_128_GCM_SIV, AES_192_GCM, AES_256_GCM, AES_256_GCM_SIV, CHACHA20_POLY1305,
6+
Algorithm, Nonce, Tag, AES_128_GCM, AES_128_GCM_SIV, AES_192_GCM, AES_256_GCM, AES_256_GCM_SIV,
7+
CHACHA20_POLY1305, MAX_KEY_LEN, MAX_TAG_LEN, NONCE_LEN,
78
};
89
use crate::aws_lc::{
910
EVP_AEAD_CTX_open, EVP_AEAD_CTX_open_gather, EVP_AEAD_CTX_seal, EVP_AEAD_CTX_seal_scatter,
1011
};
12+
use crate::error::Unspecified;
13+
use crate::fips::indicator_check;
14+
use crate::hkdf;
1115
use crate::iv::FixedLength;
12-
use crate::{error::Unspecified, fips::indicator_check, hkdf};
1316
use core::fmt::Debug;
14-
use core::{mem::MaybeUninit, ops::RangeFrom, ptr::null};
17+
use core::mem::MaybeUninit;
18+
use core::ops::RangeFrom;
19+
use core::ptr::null;
1520

1621
/// The maximum length of a nonce returned by our AEAD API.
1722
const MAX_NONCE_LEN: usize = NONCE_LEN;

aws-lc-rs/src/agreement.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1199,8 +1199,7 @@ mod tests {
11991199
#[test]
12001200
fn agreement_traits() {
12011201
use crate::test;
1202-
use regex;
1203-
use regex::Regex;
1202+
use regex::{self, Regex};
12041203

12051204
let rng = rand::SystemRandom::new();
12061205
let private_key = PrivateKey::generate_for_test(&ECDH_P256, &rng).unwrap();

aws-lc-rs/src/cipher/aes.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use crate::aws_lc::{
77
AES_cbc_encrypt, AES_cfb128_encrypt, AES_ctr128_encrypt, AES_ecb_encrypt, AES_DECRYPT,
88
AES_ENCRYPT, AES_KEY,
99
};
10-
use crate::{cipher::block::Block, error::Unspecified, fips::indicator_check};
10+
use crate::cipher::block::Block;
11+
use crate::error::Unspecified;
12+
use crate::fips::indicator_check;
1113
use zeroize::Zeroize;
1214

1315
use super::{DecryptionContext, EncryptionContext, OperatingMode, SymmetricCipherKey};

aws-lc-rs/src/cipher/padded.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,10 @@ impl Debug for PaddedBlockDecryptingKey {
291291

292292
#[cfg(test)]
293293
mod tests {
294+
use crate::cipher::padded::PaddingStrategy;
294295
use crate::cipher::{
295-
padded::PaddingStrategy, Algorithm, EncryptionContext, OperatingMode,
296-
PaddedBlockDecryptingKey, PaddedBlockEncryptingKey, UnboundCipherKey, AES_128, AES_256,
296+
Algorithm, EncryptionContext, OperatingMode, PaddedBlockDecryptingKey,
297+
PaddedBlockEncryptingKey, UnboundCipherKey, AES_128, AES_256,
297298
};
298299
use crate::iv::FixedLength;
299300
use crate::test::from_hex;

aws-lc-rs/src/cipher/tests/fips.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33

44
#![cfg(debug_assertions)]
55

6-
use crate::{
7-
cipher::{
8-
DecryptingKey, EncryptingKey, PaddedBlockDecryptingKey, PaddedBlockEncryptingKey,
9-
StreamingDecryptingKey, StreamingEncryptingKey, UnboundCipherKey, AES_128, AES_192,
10-
AES_256,
11-
},
12-
fips::{assert_fips_status_indicator, FipsServiceStatus},
6+
use crate::cipher::{
7+
DecryptingKey, EncryptingKey, PaddedBlockDecryptingKey, PaddedBlockEncryptingKey,
8+
StreamingDecryptingKey, StreamingEncryptingKey, UnboundCipherKey, AES_128, AES_192, AES_256,
139
};
10+
use crate::fips::{assert_fips_status_indicator, FipsServiceStatus};
1411

1512
const TEST_KEY_128_BIT: [u8; 16] = [
1613
0x9f, 0xd9, 0x41, 0xc3, 0xa6, 0xfe, 0xb9, 0x26, 0x2a, 0x35, 0xa7, 0x44, 0xbb, 0xc0, 0x3a, 0x6a,

aws-lc-rs/src/digest/tests/fips.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33

44
#![cfg(debug_assertions)]
55

6-
use crate::{
7-
digest::{
8-
Context, SHA1_FOR_LEGACY_USE_ONLY, SHA224, SHA256, SHA384, SHA3_256, SHA3_384, SHA3_512,
9-
SHA512, SHA512_256,
10-
},
11-
fips::{assert_fips_status_indicator, FipsServiceStatus},
6+
use crate::digest::{
7+
Context, SHA1_FOR_LEGACY_USE_ONLY, SHA224, SHA256, SHA384, SHA3_256, SHA3_384, SHA3_512,
8+
SHA512, SHA512_256,
129
};
10+
use crate::fips::{assert_fips_status_indicator, FipsServiceStatus};
1311

1412
const TEST_MESSAGE: &str = "test message";
1513

aws-lc-rs/src/ec.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
use crate::ec::signature::AlgorithmID;
77
use core::mem::MaybeUninit;
8-
use core::ptr::null;
9-
use core::ptr::null_mut;
8+
use core::ptr::{null, null_mut};
109
// TODO: Uncomment when MSRV >= 1.64
1110
// use core::ffi::c_int;
1211
use std::os::raw::c_int;
@@ -427,8 +426,10 @@ mod tests {
427426
use crate::encoding::{
428427
AsBigEndian, AsDer, EcPublicKeyCompressedBin, EcPublicKeyUncompressedBin, PublicKeyX509Der,
429428
};
430-
use crate::signature::{EcdsaKeyPair, UnparsedPublicKey, ECDSA_P256_SHA256_FIXED};
431-
use crate::signature::{KeyPair, ECDSA_P256_SHA256_FIXED_SIGNING};
429+
use crate::signature::{
430+
EcdsaKeyPair, KeyPair, UnparsedPublicKey, ECDSA_P256_SHA256_FIXED,
431+
ECDSA_P256_SHA256_FIXED_SIGNING,
432+
};
432433
use crate::test::from_dirty_hex;
433434
use crate::{signature, test};
434435

aws-lc-rs/src/hkdf/tests/fips.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33

44
#![cfg(debug_assertions)]
55

6-
use crate::{
7-
fips::{assert_fips_status_indicator, FipsServiceStatus},
8-
hkdf::{
9-
KeyType, Prk, Salt, HKDF_SHA1_FOR_LEGACY_USE_ONLY, HKDF_SHA256, HKDF_SHA384, HKDF_SHA512,
10-
},
6+
use crate::fips::{assert_fips_status_indicator, FipsServiceStatus};
7+
use crate::hkdf::{
8+
KeyType, Prk, Salt, HKDF_SHA1_FOR_LEGACY_USE_ONLY, HKDF_SHA256, HKDF_SHA384, HKDF_SHA512,
119
};
1210

1311
const TEST_KEY_128_BIT: [u8; 16] = [

aws-lc-rs/src/hmac/tests/fips.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33

44
#![cfg(debug_assertions)]
55

6-
use crate::{
7-
digest::{SHA1_OUTPUT_LEN, SHA224_OUTPUT_LEN, SHA256_OUTPUT_LEN, SHA512_OUTPUT_LEN},
8-
fips::{assert_fips_status_indicator, FipsServiceStatus},
9-
hmac::{
10-
sign, verify, Key, HMAC_SHA1_FOR_LEGACY_USE_ONLY, HMAC_SHA224, HMAC_SHA256, HMAC_SHA384,
11-
HMAC_SHA512,
12-
},
13-
rand::{self, SystemRandom},
6+
use crate::digest::{SHA1_OUTPUT_LEN, SHA224_OUTPUT_LEN, SHA256_OUTPUT_LEN, SHA512_OUTPUT_LEN};
7+
use crate::fips::{assert_fips_status_indicator, FipsServiceStatus};
8+
use crate::hmac::{
9+
sign, verify, Key, HMAC_SHA1_FOR_LEGACY_USE_ONLY, HMAC_SHA224, HMAC_SHA256, HMAC_SHA384,
10+
HMAC_SHA512,
1411
};
12+
use crate::rand::{self, SystemRandom};
1513

1614
const TEST_MESSAGE: &str = "test message";
1715

aws-lc-rs/src/kdf.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ pub use sskdf::{
225225

226226
#[cfg(test)]
227227
mod tests {
228+
use crate::kdf::sskdf::SskdfHmacAlgorithmId;
228229
use crate::kdf::{
229230
get_kbkdf_ctr_hmac_algorithm, get_sskdf_digest_algorithm, get_sskdf_hmac_algorithm,
230-
kbkdf_ctr_hmac, sskdf::SskdfHmacAlgorithmId, sskdf_digest, sskdf_hmac,
231-
KbkdfCtrHmacAlgorithmId, SskdfDigestAlgorithmId,
231+
kbkdf_ctr_hmac, sskdf_digest, sskdf_hmac, KbkdfCtrHmacAlgorithmId, SskdfDigestAlgorithmId,
232232
};
233233

234234
#[test]

aws-lc-rs/src/kdf/kbkdf.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33

44
#![allow(clippy::module_name_repetitions)]
55

6-
use crate::aws_lc::KBKDF_ctr_hmac;
7-
use crate::aws_lc::EVP_MD;
6+
use crate::aws_lc::{KBKDF_ctr_hmac, EVP_MD};
87

9-
use crate::{
10-
digest::{match_digest_type, AlgorithmID},
11-
error::Unspecified,
12-
ptr::ConstPointer,
13-
};
8+
use crate::digest::{match_digest_type, AlgorithmID};
9+
use crate::error::Unspecified;
10+
use crate::ptr::ConstPointer;
1411

1512
/// KBKDF in Counter Mode with HMAC-SHA224
1613
#[allow(dead_code)]

aws-lc-rs/src/kdf/sskdf.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33

44
#![allow(clippy::module_name_repetitions)]
55

6-
use crate::aws_lc::EVP_MD;
7-
use crate::aws_lc::{SSKDF_digest, SSKDF_hmac};
6+
use crate::aws_lc::{SSKDF_digest, SSKDF_hmac, EVP_MD};
87

9-
use crate::{
10-
digest::{match_digest_type, AlgorithmID},
11-
error::Unspecified,
12-
ptr::ConstPointer,
13-
};
8+
use crate::digest::{match_digest_type, AlgorithmID};
9+
use crate::error::Unspecified;
10+
use crate::ptr::ConstPointer;
1411

1512
/// SSKDF with HMAC-SHA224
1613
#[allow(dead_code)]

0 commit comments

Comments
 (0)