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 <crypto/CHIPCryptoPAL.h>
21 : #include <lib/core/CHIPConfig.h>
22 : #include <lib/core/ClusterEnums.h>
23 : #include <lib/core/DataModelTypes.h>
24 : #include <lib/core/ScopedNodeId.h>
25 : #include <lib/support/CodeUtils.h>
26 : #include <stddef.h>
27 :
28 : namespace chip {
29 : namespace app {
30 :
31 : struct ICDClientInfo
32 : {
33 : ScopedNodeId peer_node;
34 : ScopedNodeId check_in_node;
35 : uint32_t start_icd_counter = 0;
36 : uint32_t offset = 0;
37 : Clusters::IcdManagement::ClientTypeEnum client_type = Clusters::IcdManagement::ClientTypeEnum::kPermanent;
38 : uint64_t monitored_subject = static_cast<uint64_t>(0);
39 : Crypto::Aes128KeyHandle aes_key_handle = Crypto::Aes128KeyHandle();
40 : Crypto::Hmac128KeyHandle hmac_key_handle = Crypto::Hmac128KeyHandle();
41 :
42 86 : ICDClientInfo() {}
43 81 : ICDClientInfo(const ICDClientInfo & other) { *this = other; }
44 :
45 111 : ICDClientInfo & operator=(const ICDClientInfo & other)
46 : {
47 111 : peer_node = other.peer_node;
48 111 : check_in_node = other.check_in_node;
49 111 : start_icd_counter = other.start_icd_counter;
50 111 : offset = other.offset;
51 111 : client_type = other.client_type;
52 111 : monitored_subject = other.monitored_subject;
53 111 : ByteSpan aes_buf(other.aes_key_handle.As<Crypto::Symmetric128BitsKeyByteArray>());
54 111 : memcpy(aes_key_handle.AsMutable<Crypto::Symmetric128BitsKeyByteArray>(), aes_buf.data(),
55 : sizeof(Crypto::Symmetric128BitsKeyByteArray));
56 111 : ByteSpan hmac_buf(other.hmac_key_handle.As<Crypto::Symmetric128BitsKeyByteArray>());
57 111 : memcpy(hmac_key_handle.AsMutable<Crypto::Symmetric128BitsKeyByteArray>(), hmac_buf.data(),
58 : sizeof(Crypto::Symmetric128BitsKeyByteArray));
59 111 : return *this;
60 : }
61 : };
62 :
63 : } // namespace app
64 : } // namespace chip
|