Skip to content

Commit

Permalink
clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
justAnIdentity committed Mar 20, 2024
1 parent 3d97c1e commit d43c6c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions src/presentation/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AttributeTypeAndValue> = cert
.tbs_certificate
Expand All @@ -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::<Vec<AttributeTypeAndValue>>()
})
Expand All @@ -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)
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/presentation/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8, U32> = reader_signing_key.to_bytes().into();
let reader_auth_key: GenericArray<u8, U32> = reader_signing_key.to_bytes();

let mut session_manager = Self {
session_transcript,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit d43c6c7

Please sign in to comment.