Skip to content

Commit

Permalink
refactor: remove dependency on tracing crate
Browse files Browse the repository at this point in the history
- Remove tracing::instrument annotations
- Adapt log statements to log crate API
  • Loading branch information
typfel committed Oct 22, 2024
1 parent 0042726 commit 8d37d2a
Show file tree
Hide file tree
Showing 37 changed files with 35 additions and 243 deletions.
46 changes: 0 additions & 46 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ hex = "0.4"
idb = "0.6"
indexmap = "2"
itertools = "0.13"
log = "0.4"
log = { version = "0.4", features = ["kv"] }
mls-crypto-provider = { path = "mls-provider" }
pem = "3.0"
rand = { version = "0.8", features = ["getrandom"] }
Expand All @@ -45,8 +45,6 @@ sha2 = "0.10"
strum = { version = "0.26", features = ["derive"] }
thiserror = "1.0"
tls_codec = "0.4.1"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["json"] }
uniffi = "0.28"
url = "2.5"
uuid = "1.11"
Expand Down
2 changes: 0 additions & 2 deletions crypto-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ futures-util.workspace = true
async-trait.workspace = true
tls_codec.workspace = true
async-lock.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
log.workspace = true

# see https://github.com/RustCrypto/hashes/issues/404
Expand Down
1 change: 0 additions & 1 deletion crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ uniffi = { workspace = true, optional = true }
itertools.workspace = true
uuid.workspace = true
base64.workspace = true
tracing.workspace = true
log.workspace = true
proteus-wasm = { workspace = true, features = ["hazmat"], optional = true }
proteus-traits = { workspace = true, optional = true }
Expand Down
6 changes: 0 additions & 6 deletions crypto/src/e2e_identity/conversation_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub enum E2eiConversationState {
impl MlsCentral {
/// Indicates when to mark a conversation as not verified i.e. when not all its members have a X509
/// Credential generated by Wire's end-to-end identity enrollment
#[cfg_attr(not(test), tracing::instrument(err, skip(self), fields(id = base64::Engine::encode(&base64::prelude::BASE64_STANDARD, id))))]
pub async fn e2ei_conversation_state(&mut self, id: &ConversationId) -> CryptoResult<E2eiConversationState> {
let conversation = self.get_conversation(id).await?;
let conversation_lock = conversation.read().await;
Expand All @@ -41,7 +40,6 @@ impl MlsCentral {
}

/// Verifies a Group state before joining it
#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
pub async fn e2ei_verify_group_state(
&self,
group_info: VerifiableGroupInfo,
Expand Down Expand Up @@ -74,7 +72,6 @@ impl MlsCentral {

/// Gets the e2ei conversation state from a `GroupInfo`. Useful to check if the group has e2ei
/// turned on or not before joining it.
#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
pub async fn get_credential_in_use(
&self,
group_info: VerifiableGroupInfo,
Expand All @@ -93,7 +90,6 @@ impl MlsCentral {
.await
}

#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
async fn get_credential_in_use_in_ratchet_tree(
&self,
ciphersuite: MlsCiphersuite,
Expand All @@ -115,7 +111,6 @@ impl MlsCentral {
}

impl MlsConversation {
#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
async fn e2ei_conversation_state(&self, backend: &MlsCryptoProvider) -> CryptoResult<E2eiConversationState> {
backend.authentication_service().refresh_time_of_interest().await;
Ok(compute_state(
Expand All @@ -130,7 +125,6 @@ impl MlsConversation {

/// _credential_type will be used in the future to get the usage of VC Credentials, even Basics one.
/// Right now though, we do not need anything other than X509 so let's keep things simple.
#[cfg_attr(not(test), tracing::instrument(ret, skip(credentials, env)))]
pub(crate) async fn compute_state<'a>(
ciphersuite: MlsCiphersuite,
credentials: impl Iterator<Item = &'a Credential>,
Expand Down
2 changes: 0 additions & 2 deletions crypto/src/e2e_identity/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use wire_e2e_identity::prelude::JwsAlgorithm;
use zeroize::Zeroize;

impl super::E2eiEnrollment {
#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
pub(super) fn new_sign_key(
ciphersuite: MlsCiphersuite,
backend: &MlsCryptoProvider,
Expand All @@ -23,7 +22,6 @@ impl super::E2eiEnrollment {
E2eiSignatureKeypair::try_new(ciphersuite.signature_algorithm(), sk)
}

#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
pub(super) fn get_sign_key_for_mls(&self) -> CryptoResult<Vec<u8>> {
let sk = match self.ciphersuite.signature_algorithm() {
SignatureScheme::ECDSA_SECP256R1_SHA256 | SignatureScheme::ECDSA_SECP384R1_SHA384 => self.sign_sk.to_vec(),
Expand Down
1 change: 0 additions & 1 deletion crypto/src/e2e_identity/enabled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use openmls_traits::types::SignatureScheme;

impl MlsCentral {
/// Returns true when end-to-end-identity is enabled for the given SignatureScheme
#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
pub fn e2ei_is_enabled(&self, signature_scheme: SignatureScheme) -> CryptoResult<bool> {
let client = self.mls_client.as_ref().ok_or(CryptoError::MlsNotInitialized)?;
let maybe_x509 = client.find_most_recent_credential_bundle(signature_scheme, MlsCredentialType::X509);
Expand Down
4 changes: 0 additions & 4 deletions crypto/src/e2e_identity/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ impl MlsCentral {
/// From a given conversation, get the identity of the members supplied. Identity is only present for
/// members with a Certificate Credential (after turning on end-to-end identity).
/// If no member has a x509 certificate, it will return an empty Vec
#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
pub async fn get_device_identities(
&mut self,
conversation_id: &ConversationId,
Expand All @@ -108,7 +107,6 @@ impl MlsCentral {
///
/// Returns a Map with all the identities for a given users. Consumers are then recommended to
/// reduce those identities to determine the actual status of a user.
#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
pub async fn get_user_identities(
&mut self,
conversation_id: &ConversationId,
Expand All @@ -130,7 +128,6 @@ impl MlsCentral {
}

impl MlsConversation {
#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
fn get_device_identities(
&self,
device_ids: &[ClientId],
Expand All @@ -146,7 +143,6 @@ impl MlsConversation {
.collect::<CryptoResult<Vec<_>>>()
}

#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
fn get_user_identities(
&self,
user_ids: &[String],
Expand Down
8 changes: 0 additions & 8 deletions crypto/src/e2e_identity/init_certificates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ impl MlsCentral {
}

/// Dumps the PKI environment as PEM
#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
pub async fn e2ei_dump_pki_env(&self) -> CryptoResult<Option<E2eiDumpedPkiEnv>> {
if !self.e2ei_is_pki_env_setup().await {
return Ok(None);
Expand Down Expand Up @@ -106,7 +105,6 @@ impl MlsCentral {
///
/// # Parameters
/// * `trust_anchor_pem` - PEM certificate to anchor as a Trust Root
#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
pub async fn e2ei_register_acme_ca(&self, trust_anchor_pem: String) -> CryptoResult<()> {
{
let mut conn = self.mls_backend.key_store().borrow_conn().await?;
Expand Down Expand Up @@ -154,14 +152,12 @@ impl MlsCentral {
///
/// # Parameters
/// * `cert_pem` - PEM certificate to register as an Intermediate CA
#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
pub async fn e2ei_register_intermediate_ca_pem(&self, cert_pem: String) -> CryptoResult<NewCrlDistributionPoint> {
// Parse/decode PEM cert
let inter_ca = PkiEnvironment::decode_pem_cert(cert_pem).map_err(|e| CryptoError::E2eiError(e.into()))?;
self.e2ei_register_intermediate_ca(inter_ca).await
}

#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
pub(crate) async fn e2ei_register_intermediate_ca_der(
&self,
cert_der: &[u8],
Expand All @@ -170,7 +166,6 @@ impl MlsCentral {
self.e2ei_register_intermediate_ca(inter_ca).await
}

#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
async fn e2ei_register_intermediate_ca(
&self,
inter_ca: x509_cert::Certificate,
Expand Down Expand Up @@ -230,7 +225,6 @@ impl MlsCentral {
///
/// # Returns
/// A [CrlRegistration] with the dirty state of the new CRL (see struct) and its expiration timestamp
#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
pub async fn e2ei_register_crl(&self, crl_dp: String, crl_der: Vec<u8>) -> CryptoResult<CrlRegistration> {
// Parse & Validate CRL
let crl = {
Expand Down Expand Up @@ -269,7 +263,6 @@ impl MlsCentral {
Ok(CrlRegistration { expiration, dirty })
}

#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
pub(crate) async fn init_pki_env(&self) -> CryptoResult<()> {
if let Some(pki_env) = Self::restore_pki_env(&self.mls_backend).await? {
self.mls_backend.update_pki_env(pki_env).await?;
Expand All @@ -278,7 +271,6 @@ impl MlsCentral {
Ok(())
}

#[cfg_attr(not(test), tracing::instrument(err, skip_all))]
pub(crate) async fn restore_pki_env(backend: &MlsCryptoProvider) -> CryptoResult<Option<PkiEnvironment>> {
let keystore = backend.key_store();
let mut conn = keystore.borrow_conn().await?;
Expand Down
Loading

0 comments on commit 8d37d2a

Please sign in to comment.