Line data Source code
1 : /*
2 : *
3 : * Copyright (c) 2021 Project CHIP Authors
4 : * All rights reserved.
5 : *
6 : * Licensed under the Apache License, Version 2.0 (the "License");
7 : * you may not use this file except in compliance with the License.
8 : * You may obtain a copy of the License at
9 : *
10 : * http://www.apache.org/licenses/LICENSE-2.0
11 : *
12 : * Unless required by applicable law or agreed to in writing, software
13 : * distributed under the License is distributed on an "AS IS" BASIS,
14 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 : * See the License for the specific language governing permissions and
16 : * limitations under the License.
17 : */
18 :
19 : #pragma once
20 :
21 : #include <credentials/attestation_verifier/DeviceAttestationVerifier.h>
22 : #include <lib/core/Optional.h>
23 :
24 : namespace chip {
25 :
26 : class DeviceProxy;
27 :
28 : namespace Controller {
29 : class DeviceCommissioner;
30 : } // namespace Controller
31 :
32 : namespace Credentials {
33 :
34 : /// Callbacks for CHIP device attestation status
35 : class DeviceAttestationDelegate
36 : {
37 : public:
38 1 : virtual ~DeviceAttestationDelegate() {}
39 :
40 : /**
41 : * @brief
42 : * If valid, value to set for the fail-safe timer before the delegate's OnDeviceAttestationFailed is invoked.
43 : *
44 : * @return Optional value for the fail-safe timer in seconds.
45 : */
46 : virtual Optional<uint16_t> FailSafeExpiryTimeoutSecs() const = 0;
47 :
48 : /**
49 : * @brief
50 : * This method is invoked when device attestation fails for a device that is being commissioned. The client
51 : * handling the failure has the option to continue commissioning or fail the operation.
52 : *
53 : * Optionally, when ShouldWaitAfterDeviceAttestation is overridden to return true, this method is also
54 : * invoked when device attestation succeeds.
55 : *
56 : * @param deviceCommissioner The commissioner object that is commissioning the device
57 : * @param device The proxy represent the device being commissioned
58 : * @param info The structure holding device info for additional verification by the application
59 : * @param attestationResult The failure code for the device attestation validation operation
60 : */
61 : virtual void OnDeviceAttestationCompleted(Controller::DeviceCommissioner * deviceCommissioner, DeviceProxy * device,
62 : const DeviceAttestationVerifier::AttestationDeviceInfo & info,
63 : AttestationVerificationResult attestationResult) = 0;
64 :
65 : /**
66 : * @brief
67 : * Override this method to return whether the attestation delegate wants the commissioner to wait for a
68 : * ContinueCommissioningAfterDeviceAttestation call in the case attestationResult is successful.
69 : */
70 0 : virtual bool ShouldWaitAfterDeviceAttestation() { return false; }
71 : };
72 :
73 : } // namespace Credentials
74 : } // namespace chip
|