Skip to content

Format with imports_granularity = "Module" #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 2 additions & 4 deletions mls-rs-codec-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

use std::str::FromStr;

use darling::{
ast::{self, Fields},
FromDeriveInput, FromField, FromVariant,
};
use darling::ast::{self, Fields};
use darling::{FromDeriveInput, FromField, FromVariant};
use proc_macro2::{Literal, TokenStream};
use quote::quote;
use syn::{
Expand Down
3 changes: 2 additions & 1 deletion mls-rs-codec/src/byte_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Copyright by contributors to this project.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use crate::{iter::mls_decode_split_on_collection, Error, MlsEncode, MlsSize, VarInt};
use crate::iter::mls_decode_split_on_collection;
use crate::{Error, MlsEncode, MlsSize, VarInt};

use alloc::vec::Vec;

Expand Down
6 changes: 2 additions & 4 deletions mls-rs-codec/src/cow.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use alloc::{
borrow::{Cow, ToOwned},
vec::Vec,
};
use alloc::borrow::{Cow, ToOwned};
use alloc::vec::Vec;

use crate::{Error, MlsDecode, MlsEncode, MlsSize};

Expand Down
3 changes: 2 additions & 1 deletion mls-rs-codec/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Copyright by contributors to this project.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use alloc::{collections::BTreeMap, vec::Vec};
use alloc::collections::BTreeMap;
use alloc::vec::Vec;

#[cfg(feature = "std")]
use std::{collections::HashMap, hash::Hash};
Expand Down
3 changes: 2 additions & 1 deletion mls-rs-codec/src/string.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{MlsDecode, MlsEncode, MlsSize};
use alloc::{string::String, vec::Vec};
use alloc::string::String;
use alloc::vec::Vec;

impl MlsSize for str {
fn mls_encoded_len(&self) -> usize {
Expand Down
3 changes: 2 additions & 1 deletion mls-rs-codec/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ where
#[cfg(test)]
mod tests {
use crate::{Error, MlsDecode, MlsEncode};
use alloc::{vec, vec::Vec};
use alloc::vec;
use alloc::vec::Vec;
use assert_matches::assert_matches;

#[cfg(target_arch = "wasm32")]
Expand Down
6 changes: 2 additions & 4 deletions mls-rs-core/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
use crate::error::IntoAnyError;
use alloc::vec;
use alloc::vec::Vec;
use core::{
fmt::{self, Debug},
ops::Deref,
};
use core::fmt::{self, Debug};
use core::ops::Deref;
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};
use zeroize::{ZeroizeOnDrop, Zeroizing};

Expand Down
6 changes: 2 additions & 4 deletions mls-rs-core/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// Copyright by contributors to this project.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use core::{
fmt::{self, Debug},
ops::Deref,
};
use core::fmt::{self, Debug};
use core::ops::Deref;

use crate::error::{AnyError, IntoAnyError};
use alloc::vec::Vec;
Expand Down
5 changes: 2 additions & 3 deletions mls-rs-core/src/extension/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ mod tests {
use assert_matches::assert_matches;
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};

use crate::extension::{
list::ExtensionList, Extension, ExtensionType, MlsCodecExtension, MlsExtension,
};
use crate::extension::list::ExtensionList;
use crate::extension::{Extension, ExtensionType, MlsCodecExtension, MlsExtension};

#[derive(Debug, Clone, MlsSize, MlsEncode, MlsDecode, PartialEq, Eq)]
struct TestExtensionA(u32);
Expand Down
10 changes: 4 additions & 6 deletions mls-rs-core/src/group/roster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ use alloc::vec;
use alloc::vec::Vec;
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};

use crate::{
crypto::CipherSuite,
extension::{ExtensionList, ExtensionType},
identity::{CredentialType, SigningIdentity},
protocol_version::ProtocolVersion,
};
use crate::crypto::CipherSuite;
use crate::extension::{ExtensionList, ExtensionType};
use crate::identity::{CredentialType, SigningIdentity};
use crate::protocol_version::ProtocolVersion;

use super::ProposalType;

Expand Down
6 changes: 2 additions & 4 deletions mls-rs-core/src/identity/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// Copyright by contributors to this project.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use core::{
convert::Infallible,
fmt::{self, Debug},
};
use core::convert::Infallible;
use core::fmt::{self, Debug};

use alloc::vec::Vec;
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};
Expand Down
6 changes: 2 additions & 4 deletions mls-rs-core/src/identity/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// Copyright by contributors to this project.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use core::{
fmt::{self, Debug},
ops::Deref,
};
use core::fmt::{self, Debug};
use core::ops::Deref;

use alloc::vec::Vec;
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};
Expand Down
4 changes: 3 additions & 1 deletion mls-rs-core/src/identity/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Copyright by contributors to this project.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use crate::{error::IntoAnyError, extension::ExtensionList, time::MlsTime};
use crate::error::IntoAnyError;
use crate::extension::ExtensionList;
use crate::time::MlsTime;
#[cfg(mls_build_async)]
use alloc::boxed::Box;
use alloc::vec::Vec;
Expand Down
8 changes: 3 additions & 5 deletions mls-rs-core/src/identity/x509.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
// Copyright by contributors to this project.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use core::{
convert::Infallible,
fmt::{self, Debug},
ops::{Deref, DerefMut},
};
use core::convert::Infallible;
use core::fmt::{self, Debug};
use core::ops::{Deref, DerefMut};

use alloc::vec::Vec;
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};
Expand Down
3 changes: 2 additions & 1 deletion mls-rs-core/src/key_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use alloc::vec::Vec;
use core::fmt::{self, Debug};
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};

use crate::{crypto::HpkeSecretKey, error::IntoAnyError};
use crate::crypto::HpkeSecretKey;
use crate::error::IntoAnyError;

#[derive(Clone, PartialEq, Eq, MlsEncode, MlsDecode, MlsSize)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
6 changes: 2 additions & 4 deletions mls-rs-core/src/psk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ use crate::error::IntoAnyError;
#[cfg(mls_build_async)]
use alloc::boxed::Box;
use alloc::vec::Vec;
use core::{
fmt::{self, Debug},
ops::Deref,
};
use core::fmt::{self, Debug};
use core::ops::Deref;
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};
use zeroize::Zeroizing;

Expand Down
6 changes: 2 additions & 4 deletions mls-rs-core/src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use alloc::vec::Vec;
use core::{
fmt::{self, Debug},
ops::{Deref, DerefMut},
};
use core::fmt::{self, Debug};
use core::ops::{Deref, DerefMut};
use zeroize::Zeroizing;

#[cfg_attr(
Expand Down
3 changes: 2 additions & 1 deletion mls-rs-crypto-awslc/src/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Copyright by contributors to this project.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use std::{os::raw::c_void, ptr::null_mut};
use std::os::raw::c_void;
use std::ptr::null_mut;

use aws_lc_rs::error::Unspecified;
use aws_lc_sys::{
Expand Down
20 changes: 10 additions & 10 deletions mls-rs-crypto-awslc/src/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// Copyright by contributors to this project.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use std::{ffi::c_void, mem::MaybeUninit, ops::Deref, ptr::null_mut};
use std::ffi::c_void;
use std::mem::MaybeUninit;
use std::ops::Deref;
use std::ptr::null_mut;

use aws_lc_rs::{
digest,
error::Unspecified,
signature::{self, UnparsedPublicKey, ED25519_PUBLIC_KEY_LEN},
};
use aws_lc_rs::digest;
use aws_lc_rs::error::Unspecified;
use aws_lc_rs::signature::{self, UnparsedPublicKey, ED25519_PUBLIC_KEY_LEN};

use aws_lc_sys::{
ECDSA_SIG_free, ECDSA_SIG_to_bytes, ECDSA_do_sign, ED25519_keypair, ED25519_sign,
Expand All @@ -18,11 +19,10 @@ use aws_lc_sys::{
use mls_rs_core::crypto::{CipherSuite, SignaturePublicKey, SignatureSecretKey};
use mls_rs_crypto_traits::Curve;

use crate::{
check_non_null,
ec::{ec_generate, ec_public_key, EcPrivateKey, EcPublicKey, EvpPkey, SUPPORTED_NIST_CURVES},
AwsLcCryptoError,
use crate::ec::{
ec_generate, ec_public_key, EcPrivateKey, EcPublicKey, EvpPkey, SUPPORTED_NIST_CURVES,
};
use crate::{check_non_null, AwsLcCryptoError};

#[derive(Clone)]
pub struct AwsLcEcdsa(Curve);
Expand Down
24 changes: 11 additions & 13 deletions mls-rs-crypto-awslc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,26 @@ mod kdf;

pub mod x509;

use std::{ffi::c_int, mem::MaybeUninit};
use std::ffi::c_int;
use std::mem::MaybeUninit;

use aead::AwsLcAead;
use aws_lc_rs::{digest, error::Unspecified, hmac};
use aws_lc_rs::error::Unspecified;
use aws_lc_rs::{digest, hmac};

use aws_lc_sys::SHA256;
use mls_rs_core::{
crypto::{
CipherSuite, CipherSuiteProvider, CryptoProvider, HpkeCiphertext, HpkePublicKey,
HpkeSecretKey, SignaturePublicKey, SignatureSecretKey,
},
error::IntoAnyError,
use mls_rs_core::crypto::{
CipherSuite, CipherSuiteProvider, CryptoProvider, HpkeCiphertext, HpkePublicKey, HpkeSecretKey,
SignaturePublicKey, SignatureSecretKey,
};
use mls_rs_core::error::IntoAnyError;

use ec::Ecdh;
use ecdsa::AwsLcEcdsa;
use kdf::AwsLcHkdf;
use mls_rs_crypto_hpke::{
context::{ContextR, ContextS},
dhkem::DhKem,
hpke::{Hpke, HpkeError},
};
use mls_rs_crypto_hpke::context::{ContextR, ContextS};
use mls_rs_crypto_hpke::dhkem::DhKem;
use mls_rs_crypto_hpke::hpke::{Hpke, HpkeError};
use mls_rs_crypto_traits::{AeadType, KdfType, KemId};
use thiserror::Error;
use zeroize::Zeroizing;
Expand Down
47 changes: 18 additions & 29 deletions mls-rs-crypto-awslc/src/x509/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
// Copyright by contributors to this project.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use std::{
ffi::{c_long, c_void},
mem,
ptr::null_mut,
time::Duration,
};
use std::ffi::{c_long, c_void};
use std::mem;
use std::ptr::null_mut;
use std::time::Duration;

use aws_lc_sys::{
d2i_X509, i2d_X509, i2d_X509_NAME, ASN1_INTEGER_free, ASN1_INTEGER_to_BN, ASN1_TIME_free,
Expand All @@ -20,24 +18,18 @@ use aws_lc_sys::{
X509_set_issuer_name, X509_set_notAfter, X509_set_notBefore, X509_set_pubkey,
X509_set_serialNumber, X509_set_subject_name, X509_set_version, X509_sign, ASN1_TIME, X509,
};
use mls_rs_core::{
crypto::{CipherSuite, SignaturePublicKey, SignatureSecretKey},
time::MlsTime,
};
use mls_rs_core::crypto::{CipherSuite, SignaturePublicKey, SignatureSecretKey};
use mls_rs_core::time::MlsTime;
use mls_rs_identity_x509::{DerCertificate, SubjectAltName, SubjectComponent};

use crate::{
check_int_return, check_non_null, check_non_null_const, check_res, ecdsa::AwsLcEcdsa,
AwsLcCryptoError,
};
use crate::ecdsa::AwsLcEcdsa;
use crate::{check_int_return, check_non_null, check_non_null_const, check_res, AwsLcCryptoError};

use super::{
component::{
components_from_name, GeneralName, Stack, StackItem, X509Extension, X509ExtensionContext,
X509Name,
},
request::digest_for_curve,
use super::component::{
components_from_name, GeneralName, Stack, StackItem, X509Extension, X509ExtensionContext,
X509Name,
};
use super::request::digest_for_curve;

pub struct Certificate(*mut X509);

Expand Down Expand Up @@ -346,19 +338,16 @@ unsafe fn posix_to_asn1_time(time: MlsTime) -> Result<*mut ASN1_TIME, AwsLcCrypt

#[cfg(test)]
mod tests {
use mls_rs_core::{crypto::CipherSuite, time::MlsTime};
use mls_rs_core::crypto::CipherSuite;
use mls_rs_core::time::MlsTime;
use mls_rs_identity_x509::{
CertificateChain, SubjectAltName, SubjectComponent, X509CredentialValidator,
};

use crate::{
ecdsa::AwsLcEcdsa,
x509::{
component::{KeyUsage, X509Extension},
test_utils::{test_root_ca, test_root_ca_key},
CertificateValidator,
},
};
use crate::ecdsa::AwsLcEcdsa;
use crate::x509::component::{KeyUsage, X509Extension};
use crate::x509::test_utils::{test_root_ca, test_root_ca_key};
use crate::x509::CertificateValidator;

use super::Certificate;

Expand Down
10 changes: 4 additions & 6 deletions mls-rs-crypto-awslc/src/x509/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use core::slice;
use std::{
ffi::{c_int, c_void, CString},
marker::PhantomData,
net::IpAddr,
ptr::null_mut,
};
use std::ffi::{c_int, c_void, CString};
use std::marker::PhantomData;
use std::net::IpAddr;
use std::ptr::null_mut;

use aws_lc_sys::{
stack_st, ASN1_STRING_data, ASN1_STRING_free, ASN1_STRING_get0_data, ASN1_STRING_length,
Expand Down
10 changes: 4 additions & 6 deletions mls-rs-crypto-awslc/src/x509/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,10 @@ mod tests {
use mls_rs_core::crypto::CipherSuite;
use mls_rs_identity_x509::{SubjectAltName, SubjectComponent, X509CertificateReader};

use crate::{
ecdsa::AwsLcEcdsa,
x509::{
component::X509Name,
test_utils::{load_github_leaf, load_ip_cert, load_test_ca, test_leaf, test_leaf_key},
},
use crate::ecdsa::AwsLcEcdsa;
use crate::x509::component::X509Name;
use crate::x509::test_utils::{
load_github_leaf, load_ip_cert, load_test_ca, test_leaf, test_leaf_key,
};

use super::CertificateParser;
Expand Down
Loading
Loading