Skip to content

Commit

Permalink
Pass VerificationCertificate slightly deeper in the callstack (#11865)
Browse files Browse the repository at this point in the history
refs #11160
  • Loading branch information
alex authored Oct 30, 2024
1 parent 436542e commit 73f5758
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/rust/cryptography-x509-verification/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl<'a, 'chain: 'a, B: CryptoOps> ChainBuilder<'a, 'chain, B> {
let issuer_extensions = issuing_cert_candidate.certificate().extensions()?;
match self.policy.valid_issuer(
issuing_cert_candidate,
working_cert.certificate(),
working_cert,
current_depth,
&issuer_extensions,
) {
Expand Down
10 changes: 5 additions & 5 deletions src/rust/cryptography-x509-verification/src/policy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ impl<'a, B: CryptoOps> Policy<'a, B> {
pub(crate) fn valid_issuer(
&self,
issuer: &VerificationCertificate<'_, B>,
child: &Certificate<'_>,
child: &VerificationCertificate<'_, B>,
current_depth: u8,
issuer_extensions: &Extensions<'_>,
) -> Result<(), ValidationError> {
Expand All @@ -520,7 +520,7 @@ impl<'a, B: CryptoOps> Policy<'a, B> {
{
return Err(ValidationError::Other(format!(
"Forbidden public key algorithm: {:?}",
&child.tbs_cert.spki.algorithm
&issuer.certificate().tbs_cert.spki.algorithm
)));
}

Expand All @@ -532,11 +532,11 @@ impl<'a, B: CryptoOps> Policy<'a, B> {
// position).
if !self
.permitted_signature_algorithms
.contains(&child.signature_alg)
.contains(&child.certificate().signature_alg)
{
return Err(ValidationError::Other(format!(
"Forbidden signature algorithm: {:?}",
&child.signature_alg
&child.certificate().signature_alg
)));
}

Expand All @@ -559,7 +559,7 @@ impl<'a, B: CryptoOps> Policy<'a, B> {
let pk = issuer
.public_key(&self.ops)
.map_err(|_| ValidationError::Other("issuer has malformed public key".to_string()))?;
if self.ops.verify_signed_by(child, pk).is_err() {
if self.ops.verify_signed_by(child.certificate(), pk).is_err() {
return Err(ValidationError::Other(
"signature does not match".to_string(),
));
Expand Down

0 comments on commit 73f5758

Please sign in to comment.