aboutsummaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorAdam Langley <agl@chromium.org>2024-01-05 15:53:32 -0800
committerBoringssl LUCI CQ <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-01-13 14:49:52 +0000
commit190cc52a0b8ddab3b5f4ac86980d14baeabc7907 (patch)
tree173fa58644bc39a5fb9cb0c5815ceb4388c48e47 /rust
parent677414b2f2bbcb2fff5744aa1dbbec555f1f8672 (diff)
downloadboringssl-190cc52a0b8ddab3b5f4ac86980d14baeabc7907.zip
boringssl-190cc52a0b8ddab3b5f4ac86980d14baeabc7907.tar.gz
boringssl-190cc52a0b8ddab3b5f4ac86980d14baeabc7907.tar.bz2
Reworking bssl_crypto: imports_granularity = "Crate"
This is mostly what was used already, but not uniformly. This change is exactly the result of running `cargo fmt` with the included .rustfmt.toml. Change-Id: Ib85687edffeecfb64938f556e54beb263f0b1d13 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/65169 Reviewed-by: Bob Beck <bbe@google.com> Commit-Queue: Adam Langley <agl@google.com>
Diffstat (limited to 'rust')
-rw-r--r--rust/bssl-crypto/src/.rustfmt.toml1
-rw-r--r--rust/bssl-crypto/src/aes.rs6
-rw-r--r--rust/bssl-crypto/src/cipher/mod.rs6
-rw-r--r--rust/bssl-crypto/src/ec.rs7
-rw-r--r--rust/bssl-crypto/src/hkdf.rs15
-rw-r--r--rust/bssl-crypto/src/pkey.rs3
-rw-r--r--rust/bssl-crypto/src/x25519.rs4
7 files changed, 20 insertions, 22 deletions
diff --git a/rust/bssl-crypto/src/.rustfmt.toml b/rust/bssl-crypto/src/.rustfmt.toml
new file mode 100644
index 0000000..c3c8c37
--- /dev/null
+++ b/rust/bssl-crypto/src/.rustfmt.toml
@@ -0,0 +1 @@
+imports_granularity = "Crate"
diff --git a/rust/bssl-crypto/src/aes.rs b/rust/bssl-crypto/src/aes.rs
index e5a1607..0900420 100644
--- a/rust/bssl-crypto/src/aes.rs
+++ b/rust/bssl-crypto/src/aes.rs
@@ -122,8 +122,10 @@ fn new_decrypt_key<const N: usize>(key: [u8; N]) -> AesDecryptKey {
#[cfg(test)]
mod tests {
- use crate::aes::{Aes, AesDecryptKey, AesEncryptKey};
- use crate::test_helpers::decode_hex;
+ use crate::{
+ aes::{Aes, AesDecryptKey, AesEncryptKey},
+ test_helpers::decode_hex,
+ };
// test data from https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf F.1.1
#[test]
diff --git a/rust/bssl-crypto/src/cipher/mod.rs b/rust/bssl-crypto/src/cipher/mod.rs
index 16def56..b8c3d80 100644
--- a/rust/bssl-crypto/src/cipher/mod.rs
+++ b/rust/bssl-crypto/src/cipher/mod.rs
@@ -16,11 +16,9 @@
extern crate alloc;
use crate::{CSlice, CSliceMut};
-use alloc::vec;
-use alloc::vec::Vec;
+use alloc::{vec, vec::Vec};
use bssl_sys::EVP_CIPHER;
-use core::ffi::c_int;
-use core::marker::PhantomData;
+use core::{ffi::c_int, marker::PhantomData};
/// AES-CTR stream cipher operations.
pub mod aes_ctr;
diff --git a/rust/bssl-crypto/src/ec.rs b/rust/bssl-crypto/src/ec.rs
index 55fe4e9..8bd8bda 100644
--- a/rust/bssl-crypto/src/ec.rs
+++ b/rust/bssl-crypto/src/ec.rs
@@ -17,11 +17,8 @@
//! intended for internal use within this crate only, to create higher-level abstractions suitable
//! to be exposed externally.
-use alloc::borrow::ToOwned;
-use alloc::vec;
-use alloc::vec::Vec;
-use core::panic;
-use core::{borrow::Borrow, fmt::Debug, ops::Deref};
+use alloc::{borrow::ToOwned, vec, vec::Vec};
+use core::{borrow::Borrow, fmt::Debug, ops::Deref, panic};
use crate::{bn::BigNum, CSlice, CSliceMut, ForeignType, ForeignTypeRef};
diff --git a/rust/bssl-crypto/src/hkdf.rs b/rust/bssl-crypto/src/hkdf.rs
index f3a68ee..83c1e65 100644
--- a/rust/bssl-crypto/src/hkdf.rs
+++ b/rust/bssl-crypto/src/hkdf.rs
@@ -12,10 +12,11 @@
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-use crate::digest;
-use crate::digest::{Sha256, Sha512};
-use crate::sealed;
-use crate::{CSlice, CSliceMut, ForeignTypeRef};
+use crate::{
+ digest,
+ digest::{Sha256, Sha512},
+ sealed, CSlice, CSliceMut, ForeignTypeRef,
+};
use alloc::vec::Vec;
use core::marker::PhantomData;
@@ -103,8 +104,10 @@ impl<MD: digest::Algorithm> Hkdf<MD> {
clippy::unwrap_used
)]
mod tests {
- use crate::hkdf::{HkdfSha256, HkdfSha512};
- use crate::test_helpers::{decode_hex, decode_hex_into_vec};
+ use crate::{
+ hkdf::{HkdfSha256, HkdfSha512},
+ test_helpers::{decode_hex, decode_hex_into_vec},
+ };
use core::iter;
struct Test {
diff --git a/rust/bssl-crypto/src/pkey.rs b/rust/bssl-crypto/src/pkey.rs
index 3d4a62b..aa60a9f 100644
--- a/rust/bssl-crypto/src/pkey.rs
+++ b/rust/bssl-crypto/src/pkey.rs
@@ -18,8 +18,7 @@
//! externally.
use crate::{ec::EcKey, CSliceMut, ForeignType};
-use alloc::borrow::ToOwned;
-use alloc::string::String;
+use alloc::{borrow::ToOwned, string::String};
pub(crate) struct Pkey {
ptr: *mut bssl_sys::EVP_PKEY,
diff --git a/rust/bssl-crypto/src/x25519.rs b/rust/bssl-crypto/src/x25519.rs
index 8f6440d..b91af54 100644
--- a/rust/bssl-crypto/src/x25519.rs
+++ b/rust/bssl-crypto/src/x25519.rs
@@ -44,9 +44,7 @@
//! // real protocols from a Diffie-Hellman primitive.
//! ```
-use crate::with_output_array;
-use crate::with_output_array_fallible;
-use crate::FfiSlice;
+use crate::{with_output_array, with_output_array_fallible, FfiSlice};
/// Number of bytes in a private key in X25519
pub const PRIVATE_KEY_LEN: usize = bssl_sys::X25519_PRIVATE_KEY_LEN as usize;