diff --git a/pallets/attestation/src/lib.rs b/pallets/attestation/src/lib.rs index a8827e007..0ce7791a4 100644 --- a/pallets/attestation/src/lib.rs +++ b/pallets/attestation/src/lib.rs @@ -232,8 +232,7 @@ pub mod pallet { let accepted_mrtd_values = pallet_parameters::Pallet::::accepted_mrtd_values(); ensure!(accepted_mrtd_values.contains(&mrtd_value), Error::::BadMrtdValue); - let pck = - verify_pck_certificate_chain::("e).map_err(|_| Error::::PckVerification); + let pck = verify_pck_certificate_chain::("e)?; PendingAttestations::::remove(attestee); @@ -259,6 +258,9 @@ pub mod pallet { Ok(quote.verify().map_err(|_| Error::::PckVerification)?) } + /// A mock version of verifying the PCK certificate chain. + /// When generating mock quotes, we just put the encoded PCK in place of the certificate chain + /// so this function just decodes it, checks it was used to sign the quote, and returns it #[cfg(not(feature = "production"))] fn verify_pck_certificate_chain( quote: &Quote, @@ -271,6 +273,11 @@ pub mod pallet { .map_err(|_| Error::::CannotDecodeVerifyingKey)?, ) .map_err(|_| Error::::CannotDecodeVerifyingKey)?; + + ensure!( + quote.verify_with_pck(&provisioning_certification_key), + Error::::PckVerification + ); Ok(provisioning_certification_key) } }