LCOV - code coverage report
Current view: top level - app/icd/client - ICDClientStorage.h (source / functions) Hit Total Coverage
Test: lcov_final.info Lines: 1 1 100.0 %
Date: 2024-02-15 08:20:41 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /*
       2             :  *
       3             :  *    Copyright (c) 2023 Project CHIP Authors
       4             :  *
       5             :  *    Licensed under the Apache License, Version 2.0 (the "License");
       6             :  *    you may not use this file except in compliance with the License.
       7             :  *    You may obtain a copy of the License at
       8             :  *
       9             :  *        http://www.apache.org/licenses/LICENSE-2.0
      10             :  *
      11             :  *    Unless required by applicable law or agreed to in writing, software
      12             :  *    distributed under the License is distributed on an "AS IS" BASIS,
      13             :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      14             :  *    See the License for the specific language governing permissions and
      15             :  *    limitations under the License.
      16             :  */
      17             : 
      18             : #pragma once
      19             : 
      20             : #include "ICDClientInfo.h"
      21             : #include <crypto/CHIPCryptoPAL.h>
      22             : #include <lib/core/CHIPConfig.h>
      23             : #include <lib/core/CHIPPersistentStorageDelegate.h>
      24             : #include <lib/core/DataModelTypes.h>
      25             : #include <lib/core/ScopedNodeId.h>
      26             : #include <lib/support/CodeUtils.h>
      27             : #include <lib/support/CommonIterator.h>
      28             : #include <protocols/secure_channel/CheckinMessage.h>
      29             : #include <stddef.h>
      30             : 
      31             : namespace chip {
      32             : namespace app {
      33             : 
      34             : using namespace Protocols::SecureChannel;
      35             : /**
      36             :  * The ICDClientStorage class is an abstract interface that defines the operations
      37             :  * for storing, retrieving and deleting ICD client information in persistent storage.
      38             :  */
      39             : class ICDClientStorage
      40             : {
      41             : public:
      42           4 :     virtual ~ICDClientStorage() = default;
      43             : 
      44             :     /**
      45             :      * Called during ICD device registration in commissioning, commissioner/controller
      46             :      * provides raw key data, the shared aes key handle and hmac key handle in clientInfo are updated based upon raw key data
      47             :      *
      48             :      * @param[inout] clientInfo the ICD Client information to be updated with keyData and be saved
      49             :      * @param[in] aKeyData raw key data provided by application
      50             :      */
      51             :     virtual CHIP_ERROR SetKey(ICDClientInfo & clientInfo, const ByteSpan keyData) = 0;
      52             : 
      53             :     /**
      54             :      * Store updated ICD ClientInfo to storage when ICD registration completes or check-in message
      55             :      * comes.
      56             :      *
      57             :      * @param[in] clientInfo the updated ICD Client Info.
      58             :      */
      59             :     virtual CHIP_ERROR StoreEntry(const ICDClientInfo & clientInfo) = 0;
      60             : 
      61             :     /**
      62             :      * This function removes the ICD key from the provided clientInfo object in the event
      63             :      *  of a failed LIT ICD device registration attempt. If the key handle is not found within
      64             :      *  the Keystore, the function will not perform any operation.
      65             :      * @param[inout] clientInfo The ICD Client Info to update with uninitialized key handle if key is removed successfully.
      66             :      */
      67             :     virtual void RemoveKey(ICDClientInfo & clientInfo) = 0;
      68             : 
      69             :     /**
      70             :      * Delete ICD Client persistent information associated with the specified scoped node Id.
      71             :      * when ICD device is unpaired/removed, the corresponding entry in ICD storage is removed.
      72             :      * @param peerNode scoped node with peer node id and fabric index
      73             :      */
      74             :     virtual CHIP_ERROR DeleteEntry(const ScopedNodeId & peerNode) = 0;
      75             : 
      76             :     /**
      77             :      * Process received ICD check-in message payload.  The implementation needs to parse the payload,
      78             :      * look for a key that allows successfully decrypting the payload, verify that the counter in the payload is valid,
      79             :      * and populate the clientInfo with the stored information corresponding to the key.
      80             :      * @param[in] payload received check-in Message payload
      81             :      * @param[out] clientInfo retrieved matched clientInfo from storage
      82             :      * @param[out] counter counter value received in the check-in message
      83             :      */
      84             :     virtual CHIP_ERROR ProcessCheckInPayload(const ByteSpan & payload, ICDClientInfo & clientInfo, CounterType & counter) = 0;
      85             : 
      86             :     // 4 bytes for counter + 2 bytes for ActiveModeThreshold
      87             :     static inline constexpr uint8_t kAppDataLength = 6;
      88             : };
      89             : } // namespace app
      90             : } // namespace chip

Generated by: LCOV version 1.14