Skip to content

Commit

Permalink
src: clippy --fix
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodruff <william@trailofbits.com>
  • Loading branch information
woodruffw committed Jun 27, 2023
1 parent 6fed27e commit e93c80b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/rust/cryptography-x509-validation/src/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ impl<'a> CertificateExt<'a> for Certificate<'a> {
}

fn is_self_signed<B: Backend>(&self) -> bool {
let pk = B::public_key(&self);
self.is_self_issued() && B::is_signed_by(&self, pk)
let pk = B::public_key(self);
self.is_self_issued() && B::is_signed_by(self, pk)
}

fn issuer(&self) -> &Name<'a> {
&self.tbs_cert.issuer.unwrap_read()
self.tbs_cert.issuer.unwrap_read()
}

fn subject(&self) -> &Name<'a> {
&self.tbs_cert.subject.unwrap_read()
self.tbs_cert.subject.unwrap_read()
}

fn extensions(&'a self) -> Result<Extensions<'a>, CertificateError> {
Expand Down
6 changes: 3 additions & 3 deletions src/rust/cryptography-x509-validation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ where
// policy.
if let Ok(next_depth) =
self.policy
.valid_issuer(&issuing_cert_candidate, working_cert, current_depth)
.valid_issuer(issuing_cert_candidate, working_cert, current_depth)
{
println!("descending: {current_depth} -> {next_depth}");
let mut chain = vec![working_cert.clone()];
chain.extend(self.build_chain_inner(&issuing_cert_candidate, next_depth)?);
chain.extend(self.build_chain_inner(issuing_cert_candidate, next_depth)?);
return Ok(chain);
}
}
Expand Down Expand Up @@ -193,7 +193,7 @@ pub(crate) mod tests {
type Key = ();

fn public_key(_cert: &Certificate) -> Self::Key {
()

}

fn is_signed_by(_cert: &Certificate, _key: Self::Key) -> bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,10 @@ impl<B: Backend> Profile<B> for RFC5280 {
if aki.key_identifier.is_none() {
return Err("AuthorityKeyIdentifier.keyIdentifier must be present".into());
}
} else {
if !cert.is_self_signed::<B>() {
return Err(
"certificates must have a AuthorityKeyIdentifier unless self-signed".into(),
);
}
} else if !cert.is_self_signed::<B>() {
return Err(
"certificates must have a AuthorityKeyIdentifier unless self-signed".into(),
);
}

// 4.2.1.2: Subject Key Identifier
Expand Down
2 changes: 1 addition & 1 deletion src/rust/cryptography-x509-validation/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl DNSString {
let hostname = self.as_str();
let pattern = pattern.as_str();

match (hostname.split_once("."), pattern.split_once(".")) {
match (hostname.split_once('.'), pattern.split_once('.')) {
// If both hostname and pattern contain multiple labels, then
// we attempt to match using a subset of RFC 6125 6.4.3.
// In particular, we don't attempt to support anything
Expand Down

0 comments on commit e93c80b

Please sign in to comment.