Skip to content
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

set imports_granularity = "Module" #476

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
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
edition = "2018"
license_template_path = ".rustfmt.license-template"

imports_granularity = "Module"
4 changes: 1 addition & 3 deletions rust/attest/src/cds2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ use displaydoc::Display;
use prost::Message;
use std::convert::From;

use crate::client_connection;
use crate::dcap;
use crate::proto::cds2;
use crate::snow_resolver;
use crate::{client_connection, dcap, snow_resolver};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. I didn't expect this change, but I am still in favor of rustfmt managing imports, so okay.


/// Error types for CDS2.
#[derive(Display, Debug)]
Expand Down
3 changes: 1 addition & 2 deletions rust/attest/src/hsm_enclave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use log::*;
use std::convert::From;
use std::fmt;

use crate::client_connection;
use crate::snow_resolver;
use crate::{client_connection, snow_resolver};

/// Error types for HSM enclave.
#[derive(Debug)]
Expand Down
3 changes: 1 addition & 2 deletions rust/bridge/ffi/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use libsignal_bridge::ffi::*;
use libsignal_protocol::*;
use signal_crypto::Error as SignalCryptoError;
use std::ffi::CString;
use zkgroup::ZkGroupDeserializationFailure;
use zkgroup::ZkGroupVerificationFailure;
use zkgroup::{ZkGroupDeserializationFailure, ZkGroupVerificationFailure};

#[derive(Debug)]
#[repr(C)]
Expand Down
3 changes: 1 addition & 2 deletions rust/bridge/shared/macros/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
//

use proc_macro2::Span;
use proc_macro2::TokenStream as TokenStream2;
use proc_macro2::{Span, TokenStream as TokenStream2};
use quote::*;
use std::fmt::Display;
use syn::spanned::Spanned;
Expand Down
3 changes: 1 addition & 2 deletions rust/bridge/shared/src/ffi/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use attest::hsm_enclave::Error as HsmEnclaveError;
use device_transfer::Error as DeviceTransferError;
use libsignal_protocol::*;
use signal_crypto::Error as SignalCryptoError;
use zkgroup::ZkGroupDeserializationFailure;
use zkgroup::ZkGroupVerificationFailure;
use zkgroup::{ZkGroupDeserializationFailure, ZkGroupVerificationFailure};

use crate::support::describe_panic;

Expand Down
3 changes: 1 addition & 2 deletions rust/bridge/shared/src/hsm_enclave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

use std::panic::RefUnwindSafe;

use ::attest::client_connection;
use ::attest::hsm_enclave;
use ::attest::{client_connection, hsm_enclave};
use libsignal_bridge_macros::*;

use self::hsm_enclave::Result;
Expand Down
3 changes: 1 addition & 2 deletions rust/bridge/shared/src/jni/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use attest::hsm_enclave::Error as HsmEnclaveError;
use device_transfer::Error as DeviceTransferError;
use libsignal_protocol::*;
use signal_crypto::Error as SignalCryptoError;
use zkgroup::ZkGroupDeserializationFailure;
use zkgroup::ZkGroupVerificationFailure;
use zkgroup::{ZkGroupDeserializationFailure, ZkGroupVerificationFailure};

use crate::support::describe_panic;

Expand Down
10 changes: 4 additions & 6 deletions rust/crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ mod hash;
mod aes_ctr;
mod aes_gcm;

pub use {
aes_ctr::Aes256Ctr32,
aes_gcm::{Aes256GcmDecryption, Aes256GcmEncryption},
error::{Error, Result},
hash::{CryptographicHash, CryptographicMac},
};
pub use aes_ctr::Aes256Ctr32;
pub use aes_gcm::{Aes256GcmDecryption, Aes256GcmEncryption};
pub use error::{Error, Result};
pub use hash::{CryptographicHash, CryptographicMac};
6 changes: 4 additions & 2 deletions rust/device-transfer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
#![warn(missing_docs)]

use chrono::{Datelike, Duration, Utc};
use picky::hash::HashAlgorithm;
use picky::key::PrivateKey;
use picky::signature::SignatureAlgorithm;
use picky::x509::certificate::CertificateBuilder;
use picky::x509::date::UTCDate;
use picky::x509::name::{DirectoryName, NameAttr};
use picky::x509::{certificate::CertificateBuilder, date::UTCDate};
use picky::{hash::HashAlgorithm, signature::SignatureAlgorithm};
use std::fmt;

/// Error types for device transfer.
Expand Down
6 changes: 3 additions & 3 deletions rust/protocol/src/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// SPDX-License-Identifier: AGPL-3.0-only
//

use crate::proto;
use crate::{IdentityKey, Result, SignalProtocolError};
use crate::{proto, IdentityKey, Result, SignalProtocolError};
use prost::Message;
use sha2::{digest::Digest, Sha512};
use sha2::digest::Digest;
use sha2::Sha512;
use std::fmt;
use std::fmt::Write;
use subtle::ConstantTimeEq;
Expand Down
3 changes: 1 addition & 2 deletions rust/protocol/src/group_cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
//

use crate::consts;
use crate::crypto;
use crate::{consts, crypto};

use crate::{
CiphertextMessageType, Context, KeyPair, ProtocolAddress, Result, SenderKeyDistributionMessage,
Expand Down
3 changes: 1 addition & 2 deletions rust/protocol/src/identity_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
//

use crate::proto;
use crate::{KeyPair, PrivateKey, PublicKey, Result, SignalProtocolError};
use crate::{proto, KeyPair, PrivateKey, PublicKey, Result, SignalProtocolError};

use rand::{CryptoRng, Rng};
use std::convert::TryFrom;
Expand Down
70 changes: 34 additions & 36 deletions rust/protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,40 +43,38 @@ mod utils;

use error::Result;

pub use {
address::{DeviceId, ProtocolAddress},
curve::{KeyPair, PrivateKey, PublicKey},
error::SignalProtocolError,
fingerprint::{DisplayableFingerprint, Fingerprint, ScannableFingerprint},
group_cipher::{
create_sender_key_distribution_message, group_decrypt, group_encrypt,
process_sender_key_distribution_message,
},
identity_key::{IdentityKey, IdentityKeyPair},
protocol::{
extract_decryption_error_message_from_serialized_content, CiphertextMessage,
CiphertextMessageType, DecryptionErrorMessage, PlaintextContent, PreKeySignalMessage,
SenderKeyDistributionMessage, SenderKeyMessage, SignalMessage,
},
ratchet::{
initialize_alice_session_record, initialize_bob_session_record,
AliceSignalProtocolParameters, BobSignalProtocolParameters,
},
sealed_sender::{
sealed_sender_decrypt, sealed_sender_decrypt_to_usmc, sealed_sender_encrypt,
sealed_sender_encrypt_from_usmc, sealed_sender_multi_recipient_encrypt,
sealed_sender_multi_recipient_fan_out, ContentHint, SealedSenderDecryptionResult,
SenderCertificate, ServerCertificate, UnidentifiedSenderMessageContent,
},
sender_keys::SenderKeyRecord,
session::{process_prekey, process_prekey_bundle},
session_cipher::{
message_decrypt, message_decrypt_prekey, message_decrypt_signal, message_encrypt,
},
state::{PreKeyBundle, PreKeyRecord, SessionRecord, SignedPreKeyRecord},
storage::{
Context, Direction, IdentityKeyStore, InMemIdentityKeyStore, InMemPreKeyStore,
InMemSenderKeyStore, InMemSessionStore, InMemSignalProtocolStore, InMemSignedPreKeyStore,
PreKeyStore, ProtocolStore, SenderKeyStore, SessionStore, SignedPreKeyStore,
},
pub use address::{DeviceId, ProtocolAddress};
pub use curve::{KeyPair, PrivateKey, PublicKey};
pub use error::SignalProtocolError;
pub use fingerprint::{DisplayableFingerprint, Fingerprint, ScannableFingerprint};
pub use group_cipher::{
create_sender_key_distribution_message, group_decrypt, group_encrypt,
process_sender_key_distribution_message,
};
pub use identity_key::{IdentityKey, IdentityKeyPair};
pub use protocol::{
extract_decryption_error_message_from_serialized_content, CiphertextMessage,
CiphertextMessageType, DecryptionErrorMessage, PlaintextContent, PreKeySignalMessage,
SenderKeyDistributionMessage, SenderKeyMessage, SignalMessage,
};
pub use ratchet::{
initialize_alice_session_record, initialize_bob_session_record, AliceSignalProtocolParameters,
BobSignalProtocolParameters,
};
pub use sealed_sender::{
sealed_sender_decrypt, sealed_sender_decrypt_to_usmc, sealed_sender_encrypt,
sealed_sender_encrypt_from_usmc, sealed_sender_multi_recipient_encrypt,
sealed_sender_multi_recipient_fan_out, ContentHint, SealedSenderDecryptionResult,
SenderCertificate, ServerCertificate, UnidentifiedSenderMessageContent,
};
pub use sender_keys::SenderKeyRecord;
pub use session::{process_prekey, process_prekey_bundle};
pub use session_cipher::{
message_decrypt, message_decrypt_prekey, message_decrypt_signal, message_encrypt,
};
pub use state::{PreKeyBundle, PreKeyRecord, SessionRecord, SignedPreKeyRecord};
pub use storage::{
Context, Direction, IdentityKeyStore, InMemIdentityKeyStore, InMemPreKeyStore,
InMemSenderKeyStore, InMemSessionStore, InMemSignalProtocolStore, InMemSignedPreKeyStore,
PreKeyStore, ProtocolStore, SenderKeyStore, SessionStore, SignedPreKeyStore,
};
3 changes: 1 addition & 2 deletions rust/protocol/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
//

use crate::proto;
use crate::{IdentityKey, PrivateKey, PublicKey, Result, SignalProtocolError};
use crate::{proto, IdentityKey, PrivateKey, PublicKey, Result, SignalProtocolError};

use std::convert::TryFrom;

Expand Down
3 changes: 1 addition & 2 deletions rust/protocol/src/ratchet/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

use arrayref::array_ref;

use crate::crypto;
use crate::{PrivateKey, PublicKey, Result};
use crate::{crypto, PrivateKey, PublicKey, Result};
use std::fmt;

pub(crate) struct MessageKeys {
Expand Down
5 changes: 1 addition & 4 deletions rust/protocol/src/sealed_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ use crate::{
SignedPreKeyStore,
};

use crate::crypto;
use crate::curve;
use crate::proto;
use crate::session_cipher;
use crate::{crypto, curve, proto, session_cipher};

use aes_gcm_siv::aead::{AeadInPlace, NewAead};
use aes_gcm_siv::Aes256GcmSiv;
Expand Down
3 changes: 1 addition & 2 deletions rust/protocol/src/sender_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ use std::convert::TryFrom;
use itertools::Itertools;
use prost::Message;

use crate::consts;
use crate::crypto::hmac_sha256;
use crate::proto::storage as storage_proto;
use crate::{PrivateKey, PublicKey, SignalProtocolError};
use crate::{consts, PrivateKey, PublicKey, SignalProtocolError};

/// A distinct error type to keep from accidentally propagating deserialization errors.
#[derive(Debug)]
Expand Down
3 changes: 1 addition & 2 deletions rust/protocol/src/session_cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ use crate::{
};

use crate::consts::MAX_FORWARD_JUMPS;
use crate::crypto;
use crate::ratchet::{ChainKey, MessageKeys};
use crate::session;
use crate::state::{InvalidSessionError, SessionState};
use crate::{crypto, session};

use rand::{CryptoRng, Rng};

Expand Down
3 changes: 1 addition & 2 deletions rust/protocol/src/state/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use crate::ratchet::{ChainKey, MessageKeys, RootKey};
use crate::{IdentityKey, KeyPair, PrivateKey, PublicKey, SignalProtocolError};

use crate::consts;
use crate::proto::storage::session_structure;
use crate::proto::storage::{RecordStructure, SessionStructure};
use crate::proto::storage::{session_structure, RecordStructure, SessionStructure};
use crate::state::{PreKeyId, SignedPreKeyId};

/// A distinct error type to keep from accidentally propagating deserialization errors.
Expand Down
16 changes: 7 additions & 9 deletions rust/protocol/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
mod inmem;
mod traits;

pub use {
inmem::{
InMemIdentityKeyStore, InMemPreKeyStore, InMemSenderKeyStore, InMemSessionStore,
InMemSignalProtocolStore, InMemSignedPreKeyStore,
},
traits::{
Context, Direction, IdentityKeyStore, PreKeyStore, ProtocolStore, SenderKeyStore,
SessionStore, SignedPreKeyStore,
},
pub use inmem::{
InMemIdentityKeyStore, InMemPreKeyStore, InMemSenderKeyStore, InMemSessionStore,
InMemSignalProtocolStore, InMemSignedPreKeyStore,
};
pub use traits::{
Context, Direction, IdentityKeyStore, PreKeyStore, ProtocolStore, SenderKeyStore, SessionStore,
SignedPreKeyStore,
};
3 changes: 1 addition & 2 deletions rust/protocol/src/storage/inmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use crate::{
};

use crate::state::{PreKeyId, SignedPreKeyId};
use crate::storage::traits;
use crate::storage::Context;
use crate::storage::{traits, Context};

use async_trait::async_trait;
use std::borrow::Cow;
Expand Down
3 changes: 2 additions & 1 deletion rust/protocol/tests/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
//

use libsignal_protocol::*;
use rand::{rngs::OsRng, CryptoRng, Rng};
use rand::rngs::OsRng;
use rand::{CryptoRng, Rng};

pub fn test_in_memory_protocol_store() -> Result<InMemSignalProtocolStore, SignalProtocolError> {
let mut csprng = OsRng;
Expand Down
3 changes: 1 addition & 2 deletions rust/zkgroup/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ pub mod receipts;

pub mod server_params;

pub use server_params::ServerPublicParams;
pub use server_params::ServerSecretParams;
pub use server_params::{ServerPublicParams, ServerSecretParams};
8 changes: 4 additions & 4 deletions rust/zkgroup/src/api/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ pub mod auth_credential_with_pni;
pub mod auth_credential_with_pni_response;

pub use auth_credential::AuthCredential;
pub use auth_credential_presentation::AnyAuthCredentialPresentation;
pub use auth_credential_presentation::AuthCredentialPresentationV1;
pub use auth_credential_presentation::AuthCredentialPresentationV2;
pub use auth_credential_presentation::AuthCredentialWithPniPresentation;
pub use auth_credential_presentation::{
AnyAuthCredentialPresentation, AuthCredentialPresentationV1, AuthCredentialPresentationV2,
AuthCredentialWithPniPresentation,
};
pub use auth_credential_response::AuthCredentialResponse;
pub use auth_credential_with_pni::AuthCredentialWithPni;
pub use auth_credential_with_pni_response::AuthCredentialWithPniResponse;
6 changes: 2 additions & 4 deletions rust/zkgroup/src/api/auth/auth_credential_presentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
// SPDX-License-Identifier: AGPL-3.0-only
//

use crate::api;
use crate::common::constants::*;
use crate::common::errors::*;
use crate::common::simple_types::*;
use crate::crypto;
use serde::Serializer;
use serde::{Deserialize, Serialize};
use crate::{api, crypto};
use serde::{Deserialize, Serialize, Serializer};

#[derive(Serialize, Deserialize)]
pub struct AuthCredentialPresentationV1 {
Expand Down
4 changes: 1 addition & 3 deletions rust/zkgroup/src/api/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ pub mod group_params;
pub mod profile_key_ciphertext;
pub mod uuid_ciphertext;

pub use group_params::GroupMasterKey;
pub use group_params::GroupPublicParams;
pub use group_params::GroupSecretParams;
pub use group_params::{GroupMasterKey, GroupPublicParams, GroupSecretParams};
pub use profile_key_ciphertext::ProfileKeyCiphertext;
pub use uuid_ciphertext::UuidCiphertext;
6 changes: 3 additions & 3 deletions rust/zkgroup/src/api/groups/group_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

use std::convert::TryInto;

use crate::api;
use crate::common::constants::*;
use crate::common::errors::*;
use crate::common::sho::*;
use crate::common::simple_types::*;
use crate::crypto;
use aead::{generic_array::GenericArray, Aead, NewAead};
use crate::{api, crypto};
use aead::generic_array::GenericArray;
use aead::{Aead, NewAead};
use aes_gcm_siv::Aes256GcmSiv;
use serde::{Deserialize, Serialize};

Expand Down
Loading