LCOV - code coverage report
Current view: top level - protocols/secure_channel - DefaultSessionResumptionStorage.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             :  *    Copyright (c) 2022 Project CHIP Authors
       3             :  *    All rights reserved.
       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 <protocols/secure_channel/SessionResumptionStorage.h>
      21             : 
      22             : namespace chip {
      23             : 
      24             : /**
      25             :  * @brief Stores assets for session resumption. The resumption data are indexed by 2 indexes: ScopedNodeId and ResumptionId. The
      26             :  *   index of ScopedNodeId is used when initiating a CASE session, it will look up the storage and check whether it is able to
      27             :  *   resume a previous session. The index of ResumptionId is used when receiving a Sigma1 with ResumptionId.
      28             :  *
      29             :  *   The implementation saves 2 maps:
      30             :  *     * <FabricIndex, PeerNodeId>   => <ResumptionId, ShareSecret, PeerCATs>
      31             :  *     * <ResumptionId>              => <FabricIndex, PeerNodeId>
      32             :  */
      33             : class DefaultSessionResumptionStorage : public SessionResumptionStorage
      34             : {
      35             : public:
      36             :     using ResumptionIdView = FixedSpan<uint8_t, kResumptionIdSize>;
      37             : 
      38             :     struct SessionIndex
      39             :     {
      40             :         size_t mSize;
      41             :         ScopedNodeId mNodes[CHIP_CONFIG_CASE_SESSION_RESUME_CACHE_SIZE];
      42             :     };
      43             : 
      44           1 :     virtual ~DefaultSessionResumptionStorage() {}
      45             : 
      46             :     CHIP_ERROR FindByScopedNodeId(const ScopedNodeId & node, ResumptionIdStorage & resumptionId,
      47             :                                   Crypto::P256ECDHDerivedSecret & sharedSecret, CATValues & peerCATs) override;
      48             :     CHIP_ERROR FindByResumptionId(ConstResumptionIdView resumptionId, ScopedNodeId & node,
      49             :                                   Crypto::P256ECDHDerivedSecret & sharedSecret, CATValues & peerCATs) override;
      50             :     CHIP_ERROR FindNodeByResumptionId(ConstResumptionIdView resumptionId, ScopedNodeId & node);
      51             :     CHIP_ERROR Save(const ScopedNodeId & node, ConstResumptionIdView resumptionId,
      52             :                     const Crypto::P256ECDHDerivedSecret & sharedSecret, const CATValues & peerCATs) override;
      53             :     CHIP_ERROR Delete(const ScopedNodeId & node);
      54             :     CHIP_ERROR DeleteAll(FabricIndex fabricIndex) override;
      55             : 
      56             : protected:
      57             :     CHIP_ERROR virtual SaveIndex(const SessionIndex & index) = 0;
      58             :     CHIP_ERROR virtual LoadIndex(SessionIndex & index)       = 0;
      59             : 
      60             :     CHIP_ERROR virtual SaveLink(ConstResumptionIdView resumptionId, const ScopedNodeId & node) = 0;
      61             :     CHIP_ERROR virtual LoadLink(ConstResumptionIdView resumptionId, ScopedNodeId & node)       = 0;
      62             :     CHIP_ERROR virtual DeleteLink(ConstResumptionIdView resumptionId)                          = 0;
      63             : 
      64             :     CHIP_ERROR virtual SaveState(const ScopedNodeId & node, ConstResumptionIdView resumptionId,
      65             :                                  const Crypto::P256ECDHDerivedSecret & sharedSecret, const CATValues & peerCATs) = 0;
      66             :     CHIP_ERROR virtual LoadState(const ScopedNodeId & node, ResumptionIdStorage & resumptionId,
      67             :                                  Crypto::P256ECDHDerivedSecret & sharedSecret, CATValues & peerCATs)             = 0;
      68             :     CHIP_ERROR virtual DeleteState(const ScopedNodeId & node)                                                    = 0;
      69             : };
      70             : 
      71             : } // namespace chip

Generated by: LCOV version 1.14