Skip to content

Commit fd23bda

Browse files
authored
Format all rust imports consistently (#12381)
1 parent 13a2e6f commit fd23bda

File tree

37 files changed

+136
-157
lines changed

37 files changed

+136
-157
lines changed

src/rust/cryptography-keepalive/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
#![deny(rust_2018_idioms, clippy::undocumented_unsafe_blocks)]
66

7-
use pyo3::pybacked::{PyBackedBytes, PyBackedStr};
87
use std::cell::UnsafeCell;
98
use std::ops::Deref;
109

10+
use pyo3::pybacked::{PyBackedBytes, PyBackedStr};
11+
1112
pub struct KeepAlive<T: StableDeref> {
1213
values: UnsafeCell<Vec<T>>,
1314
}

src/rust/cryptography-key-parsing/src/ec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// 2.0, and the BSD License. See the LICENSE file in the root of this repository
33
// for complete details.
44

5-
use crate::{KeyParsingError, KeyParsingResult};
6-
75
use cryptography_x509::common::EcParameters;
86

7+
use crate::{KeyParsingError, KeyParsingResult};
8+
99
pub(crate) fn ec_params_to_group(
1010
params: &EcParameters<'_>,
1111
) -> KeyParsingResult<openssl::ec::EcGroup> {

src/rust/cryptography-openssl/src/aead.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// 2.0, and the BSD License. See the LICENSE file in the root of this repository
33
// for complete details.
44

5+
use foreign_types_shared::{ForeignType, ForeignTypeRef};
56
use openssl_sys as ffi;
67

78
use crate::{cvt, cvt_p, OpenSSLResult};
8-
use foreign_types_shared::{ForeignType, ForeignTypeRef};
99

1010
pub enum AeadType {
1111
ChaCha20Poly1305,

src/rust/cryptography-openssl/src/fips.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
// 2.0, and the BSD License. See the LICENSE file in the root of this repository
33
// for complete details.
44

5-
#[cfg(not(any(CRYPTOGRAPHY_IS_LIBRESSL, CRYPTOGRAPHY_IS_BORINGSSL)))]
6-
use openssl_sys as ffi;
7-
8-
#[cfg(CRYPTOGRAPHY_OPENSSL_300_OR_GREATER)]
9-
use crate::{cvt, OpenSSLResult};
105
#[cfg(all(
116
CRYPTOGRAPHY_OPENSSL_300_OR_GREATER,
127
not(any(CRYPTOGRAPHY_IS_LIBRESSL, CRYPTOGRAPHY_IS_BORINGSSL))
138
))]
149
use std::ptr;
1510

11+
#[cfg(not(any(CRYPTOGRAPHY_IS_LIBRESSL, CRYPTOGRAPHY_IS_BORINGSSL)))]
12+
use openssl_sys as ffi;
13+
14+
#[cfg(CRYPTOGRAPHY_OPENSSL_300_OR_GREATER)]
15+
use crate::{cvt, OpenSSLResult};
16+
1617
pub fn is_enabled() -> bool {
1718
cfg_if::cfg_if! {
1819
if #[cfg(any(CRYPTOGRAPHY_IS_LIBRESSL, CRYPTOGRAPHY_IS_BORINGSSL))] {

src/rust/cryptography-openssl/src/hmac.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ impl std::ops::Deref for DigestBytes {
9292

9393
#[cfg(test)]
9494
mod tests {
95-
use super::DigestBytes;
9695
use openssl_sys as ffi;
9796

97+
use super::DigestBytes;
98+
9899
#[test]
99100
fn test_digest_bytes() {
100101
let d = DigestBytes {

src/rust/cryptography-x509-verification/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ use std::fmt::Display;
1616
use std::vec;
1717

1818
use asn1::ObjectIdentifier;
19-
use cryptography_x509::extensions::{DuplicateExtensionsError, Extensions};
20-
use cryptography_x509::{
21-
common::Asn1Read,
22-
extensions::{NameConstraints, SubjectAlternativeName},
23-
name::GeneralName,
24-
oid::{NAME_CONSTRAINTS_OID, SUBJECT_ALTERNATIVE_NAME_OID},
19+
use cryptography_x509::common::Asn1Read;
20+
use cryptography_x509::extensions::{
21+
DuplicateExtensionsError, Extensions, NameConstraints, SubjectAlternativeName,
2522
};
26-
use types::{DNSPattern, RFC822Constraint, RFC822Name};
23+
use cryptography_x509::name::GeneralName;
24+
use cryptography_x509::oid::{NAME_CONSTRAINTS_OID, SUBJECT_ALTERNATIVE_NAME_OID};
2725

2826
use crate::certificate::cert_is_self_issued;
2927
use crate::ops::{CryptoOps, VerificationCertificate};
3028
use crate::policy::Policy;
3129
use crate::trust_store::Store;
32-
use crate::types::{DNSConstraint, IPAddress, IPConstraint};
30+
use crate::types::{
31+
DNSConstraint, DNSPattern, IPAddress, IPConstraint, RFC822Constraint, RFC822Name,
32+
};
3333
use crate::ApplyNameConstraintStatus::{Applied, Skipped};
3434

3535
pub enum ValidationErrorKind<'chain, B: CryptoOps> {

src/rust/cryptography-x509-verification/src/ops.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ pub trait CryptoOps {
9090

9191
#[cfg(test)]
9292
pub(crate) mod tests {
93+
use cryptography_x509::certificate::Certificate;
94+
9395
use super::VerificationCertificate;
9496
use crate::certificate::tests::PublicKeyErrorOps;
95-
use cryptography_x509::certificate::Certificate;
9697

9798
pub(crate) fn v1_cert_pem() -> pem::Pem {
9899
pem::parse(

src/rust/cryptography-x509-verification/src/policy/extension.rs

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
// 2.0, and the BSD License. See the LICENSE file in the root of this repository
33
// for complete details.
44

5+
use cryptography_x509::certificate::Certificate;
6+
use cryptography_x509::extensions::{Extension, Extensions};
57
use cryptography_x509::oid::{
68
AUTHORITY_INFORMATION_ACCESS_OID, AUTHORITY_KEY_IDENTIFIER_OID, BASIC_CONSTRAINTS_OID,
79
EXTENDED_KEY_USAGE_OID, KEY_USAGE_OID, NAME_CONSTRAINTS_OID, SUBJECT_ALTERNATIVE_NAME_OID,
810
SUBJECT_KEY_IDENTIFIER_OID,
911
};
10-
use cryptography_x509::{
11-
certificate::Certificate,
12-
extensions::{Extension, Extensions},
13-
};
1412

15-
use crate::{
16-
ops::CryptoOps, policy::Policy, ValidationError, ValidationErrorKind, ValidationResult,
17-
};
13+
use crate::ops::CryptoOps;
14+
use crate::policy::Policy;
15+
use crate::{ValidationError, ValidationErrorKind, ValidationResult};
1816

1917
pub(crate) struct ExtensionPolicy<B: CryptoOps> {
2018
pub(crate) authority_information_access: ExtensionValidator<B>,
@@ -266,17 +264,13 @@ impl<B: CryptoOps> ExtensionValidator<B> {
266264
}
267265

268266
pub(crate) mod ee {
269-
use cryptography_x509::{
270-
certificate::Certificate,
271-
extensions::{
272-
BasicConstraints, ExtendedKeyUsage, Extension, KeyUsage, SubjectAlternativeName,
273-
},
267+
use cryptography_x509::certificate::Certificate;
268+
use cryptography_x509::extensions::{
269+
BasicConstraints, ExtendedKeyUsage, Extension, KeyUsage, SubjectAlternativeName,
274270
};
275271

276-
use crate::{
277-
ops::CryptoOps,
278-
policy::{Policy, ValidationError, ValidationErrorKind, ValidationResult},
279-
};
272+
use crate::ops::CryptoOps;
273+
use crate::policy::{Policy, ValidationError, ValidationErrorKind, ValidationResult};
280274

281275
pub(crate) fn basic_constraints<'chain, B: CryptoOps>(
282276
_policy: &Policy<'_, B>,
@@ -379,20 +373,16 @@ pub(crate) mod ee {
379373
}
380374

381375
pub(crate) mod ca {
382-
use cryptography_x509::{
383-
certificate::Certificate,
384-
common::Asn1Read,
385-
extensions::{
386-
AuthorityKeyIdentifier, BasicConstraints, ExtendedKeyUsage, Extension, KeyUsage,
387-
NameConstraints,
388-
},
389-
oid::EKU_ANY_KEY_USAGE_OID,
376+
use cryptography_x509::certificate::Certificate;
377+
use cryptography_x509::common::Asn1Read;
378+
use cryptography_x509::extensions::{
379+
AuthorityKeyIdentifier, BasicConstraints, ExtendedKeyUsage, Extension, KeyUsage,
380+
NameConstraints,
390381
};
382+
use cryptography_x509::oid::EKU_ANY_KEY_USAGE_OID;
391383

392-
use crate::{
393-
ops::CryptoOps,
394-
policy::{Policy, ValidationError, ValidationErrorKind, ValidationResult},
395-
};
384+
use crate::ops::CryptoOps;
385+
use crate::policy::{Policy, ValidationError, ValidationErrorKind, ValidationResult};
396386

397387
pub(crate) fn authority_key_identifier<'chain, B: CryptoOps>(
398388
_policy: &Policy<'_, B>,
@@ -529,16 +519,12 @@ pub(crate) mod ca {
529519
}
530520

531521
pub(crate) mod common {
532-
use cryptography_x509::{
533-
certificate::Certificate,
534-
common::Asn1Read,
535-
extensions::{Extension, SequenceOfAccessDescriptions},
536-
};
522+
use cryptography_x509::certificate::Certificate;
523+
use cryptography_x509::common::Asn1Read;
524+
use cryptography_x509::extensions::{Extension, SequenceOfAccessDescriptions};
537525

538-
use crate::{
539-
ops::CryptoOps,
540-
policy::{Policy, ValidationResult},
541-
};
526+
use crate::ops::CryptoOps;
527+
use crate::policy::{Policy, ValidationResult};
542528

543529
pub(crate) fn authority_information_access<'chain, B: CryptoOps>(
544530
_policy: &Policy<'_, B>,

src/rust/cryptography-x509-verification/src/policy/mod.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -601,24 +601,20 @@ mod tests {
601601

602602
use asn1::{DateTime, SequenceOfWriter};
603603
use cryptography_x509::common::Time;
604-
use cryptography_x509::{
605-
extensions::SubjectAlternativeName,
606-
name::{GeneralName, UnvalidatedIA5String},
607-
};
604+
use cryptography_x509::extensions::SubjectAlternativeName;
605+
use cryptography_x509::name::{GeneralName, UnvalidatedIA5String};
608606

609607
use super::{
610608
permits_validity_date, ECDSA_SHA256, ECDSA_SHA384, ECDSA_SHA512, RSASSA_PKCS1V15_SHA256,
611609
RSASSA_PKCS1V15_SHA384, RSASSA_PKCS1V15_SHA512, RSASSA_PSS_SHA256, RSASSA_PSS_SHA384,
612610
RSASSA_PSS_SHA512, WEBPKI_PERMITTED_SIGNATURE_ALGORITHMS,
613611
};
614612
use crate::certificate::tests::PublicKeyErrorOps;
615-
use crate::{
616-
policy::{
617-
Subject, SPKI_RSA, SPKI_SECP256R1, SPKI_SECP384R1, SPKI_SECP521R1,
618-
WEBPKI_PERMITTED_SPKI_ALGORITHMS,
619-
},
620-
types::{DNSName, IPAddress},
613+
use crate::policy::{
614+
Subject, SPKI_RSA, SPKI_SECP256R1, SPKI_SECP384R1, SPKI_SECP521R1,
615+
WEBPKI_PERMITTED_SPKI_ALGORITHMS,
621616
};
617+
use crate::types::{DNSName, IPAddress};
622618

623619
#[test]
624620
fn test_webpki_permitted_spki_algorithms_canonical_encodings() {

src/rust/cryptography-x509-verification/src/trust_store.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use std::collections::HashMap;
66

77
use cryptography_x509::name::Name;
88

9-
use crate::CryptoOps;
10-
use crate::VerificationCertificate;
9+
use crate::{CryptoOps, VerificationCertificate};
1110

1211
/// A `Store` represents the core state needed for X.509 path validation.
1312
pub struct Store<'a, B: CryptoOps> {

0 commit comments

Comments
 (0)