From d43c6c75c4aff29cc1ebd98f88666b3ecb51b6d7 Mon Sep 17 00:00:00 2001 From: Arjen van Veen Date: Wed, 20 Mar 2024 13:03:08 +0100 Subject: [PATCH] clippy fix --- src/presentation/device.rs | 16 ++++++++-------- src/presentation/reader.rs | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/presentation/device.rs b/src/presentation/device.rs index 8aefad3a..9012eca7 100644 --- a/src/presentation/device.rs +++ b/src/presentation/device.rs @@ -428,7 +428,7 @@ impl SessionManager { match x5c { CborValue::Bytes(x509) => { - match x509_cert::Certificate::from_der(&x509) { + match x509_cert::Certificate::from_der(x509) { Ok(cert) => { let distinguished_names: Vec = cert .tbs_certificate @@ -441,7 +441,7 @@ impl SessionManager { .into_iter() .filter(|atv| { //common name - atv.oid.to_string() == "2.5.4.3".to_string() + atv.oid.to_string() == *"2.5.4.3" }) .collect::>() }) @@ -451,24 +451,24 @@ impl SessionManager { .collect(); if let Some(common_name) = distinguished_names.first() { - return (validation_errors, Some(common_name.to_string())); + (validation_errors, Some(common_name.to_string())) } else { - return (validation_errors, None); + (validation_errors, None) } } Err(e) => { validation_errors.push(X509Error::ValidationError(e.to_string())); - return (validation_errors, None); + (validation_errors, None) } } } - _ => return (validation_errors, None), + _ => (validation_errors, None), } } else { - return (validation_errors, None); + (validation_errors, None) } } else { - return (validation_errors, None); + (validation_errors, None) } } } diff --git a/src/presentation/reader.rs b/src/presentation/reader.rs index 35bdd4cf..2321f266 100644 --- a/src/presentation/reader.rs +++ b/src/presentation/reader.rs @@ -185,7 +185,7 @@ impl SessionManager { derive_session_key(&shared_secret, &session_transcript_bytes, false)?.into(); let reader_signing_key: SigningKey = ecdsa::SigningKey::from_sec1_pem(reader_key)?; - let reader_auth_key: GenericArray = reader_signing_key.to_bytes().into(); + let reader_auth_key: GenericArray = reader_signing_key.to_bytes(); let mut session_manager = Self { session_transcript, @@ -332,15 +332,15 @@ impl SessionManager { }; match parse_namespaces(&device_response) { Ok(parsed_response) => { - return self.validate_response(x5chain, document.clone(), parsed_response) + self.validate_response(x5chain, document.clone(), parsed_response) } Err(e) => { validated_response .errors .insert("parsing_errors".to_string(), json!(vec![e])); - return validated_response; + validated_response } - }; + } } pub fn validate_response( @@ -573,13 +573,13 @@ pub mod test { #[test] fn validate_x509_with_trust_anchor() { let result = validate(IACA_SIGNER, IACA_ROOT).unwrap(); - assert!(result.len() == 0, "{result:?}"); + assert!(result.is_empty(), "{result:?}"); } #[test] fn validate_incorrect_x509_with_trust_anchor() { let result = validate(INCORRECT_IACA_SIGNER, IACA_ROOT).unwrap(); - assert!(result.len() > 0, "{result:?}"); + assert!(!result.is_empty(), "{result:?}"); } // TODO: Fix test -- intermediate and leaf are not in a chain.