diff --git a/src/commissioner/ExampleCommissioningStateMachine.h b/src/commissioner/ExampleCommissioningStateMachine.h index 0480efe7945921..8be07ad25adc7b 100644 --- a/src/commissioner/ExampleCommissioningStateMachine.h +++ b/src/commissioner/ExampleCommissioningStateMachine.h @@ -172,13 +172,23 @@ struct AttestationVerification : chip::Commissioner::States::Base { auto testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); auto verifier = chip::Credentials::GetDefaultDACVerifier(testingRootStore); - auto result = verifier->VerifyAttestationInformation( + Callback::Callback callback(OnVerification, this); + verifier->VerifyAttestationInformation( mAttestationInformation.AttestationElements()->Get(), mAttestationInformation.Challenge()->Get(), mAttestationInformation.Signature()->Get(), mAttestationInformation.Pai()->Get(), mAttestationInformation.Dac()->Get(), - mAttestationInformation.Nonce()->Get()); + mAttestationInformation.Nonce()->Get(), &callback); + } + + void DispatchSuccess() { this->mCtx.Dispatch(Event::Create(mAttestationInformation)); } + void DispatchFailure() { this->mCtx.Dispatch(Event::Create()); } + +private: + static void OnVerification(void * context, Credentials::AttestationVerificationResult result) + { + auto state = static_cast(context); if (result == chip::Credentials::AttestationVerificationResult::kSuccess) { - this->mCtx.Dispatch(Event::Create(mAttestationInformation)); + state->DispatchSuccess(); } else { @@ -188,11 +198,10 @@ struct AttestationVerification : chip::Commissioner::States::Base static_cast(result)); // Go look at AttestationVerificationResult enum in src/credentials/DeviceAttestationVerifier.h to understand the // errors. - this->mCtx.Dispatch(Event::Create()); + state->DispatchFailure(); } } -private: AttestationInformation mAttestationInformation; };