Skip to content

Commit

Permalink
Revise for compatibility with project-chip#12657
Browse files Browse the repository at this point in the history
  • Loading branch information
msandstedt committed Jan 27, 2022
1 parent 71fb1f4 commit a73b973
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/commissioner/ExampleCommissioningStateMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,23 @@ struct AttestationVerification : chip::Commissioner::States::Base<Context>
{
auto testingRootStore = chip::Credentials::GetTestAttestationTrustStore();
auto verifier = chip::Credentials::GetDefaultDACVerifier(testingRootStore);
auto result = verifier->VerifyAttestationInformation(
Callback::Callback<Credentials::OnAttestationInformationVerification> 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<AttestationInformation>(mAttestationInformation)); }
void DispatchFailure() { this->mCtx.Dispatch(Event::Create<Failure>()); }

private:
static void OnVerification(void * context, Credentials::AttestationVerificationResult result)
{
auto state = static_cast<AttestationVerification *>(context);
if (result == chip::Credentials::AttestationVerificationResult::kSuccess)
{
this->mCtx.Dispatch(Event::Create<AttestationInformation>(mAttestationInformation));
state->DispatchSuccess();
}
else
{
Expand All @@ -188,11 +198,10 @@ struct AttestationVerification : chip::Commissioner::States::Base<Context>
static_cast<uint16_t>(result));
// Go look at AttestationVerificationResult enum in src/credentials/DeviceAttestationVerifier.h to understand the
// errors.
this->mCtx.Dispatch(Event::Create<Failure>());
state->DispatchFailure();
}
}

private:
AttestationInformation mAttestationInformation;
};

Expand Down

0 comments on commit a73b973

Please sign in to comment.