Skip to content

Commit

Permalink
Added ClientType to ICDClientInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed Jun 10, 2024
1 parent 2ddc97d commit e1b5467
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/app/icd/client/DefaultICDClientStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ CHIP_ERROR DefaultICDClientStorage::Load(FabricIndex fabricIndex, std::vector<IC
memcpy(clientInfo.hmac_key_handle.AsMutable<Crypto::Symmetric128BitsKeyByteArray>(), hmacBuf.data(),
sizeof(Crypto::Symmetric128BitsKeyByteArray));

// ClientType
ReturnErrorOnFailure(reader.Next(TLV::ContextTag(ClientInfoTag::kClientType)));
ReturnErrorOnFailure(reader.Get(clientInfo.client_type));

ReturnErrorOnFailure(reader.ExitContainer(ICDClientInfoType));
clientInfoVector.push_back(clientInfo);
}
Expand Down Expand Up @@ -327,6 +331,7 @@ CHIP_ERROR DefaultICDClientStorage::SerializeToTlv(TLV::TLVWriter & writer, cons
ReturnErrorOnFailure(writer.Put(TLV::ContextTag(ClientInfoTag::kAesKeyHandle), aesBuf));
ByteSpan hmacBuf(clientInfo.hmac_key_handle.As<Crypto::Symmetric128BitsKeyByteArray>());
ReturnErrorOnFailure(writer.Put(TLV::ContextTag(ClientInfoTag::kHmacKeyHandle), hmacBuf));
ReturnErrorOnFailure(writer.Put(TLV::ContextTag(ClientInfoTag::kClientType), clientInfo.client_type));
ReturnErrorOnFailure(writer.EndContainer(ICDClientInfoContainerType));
}
return writer.EndContainer(arrayType);
Expand Down
1 change: 1 addition & 0 deletions src/app/icd/client/DefaultICDClientStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class DefaultICDClientStorage : public ICDClientStorage
kMonitoredSubject = 5,
kAesKeyHandle = 6,
kHmacKeyHandle = 7,
kClientType = 8,
};

enum class CounterTag : uint8_t
Expand Down
13 changes: 8 additions & 5 deletions src/app/icd/client/ICDClientInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <crypto/CHIPCryptoPAL.h>
#include <lib/core/CHIPConfig.h>
#include <lib/core/ClusterEnums.h>
#include <lib/core/DataModelTypes.h>
#include <lib/core/ScopedNodeId.h>
#include <lib/support/CodeUtils.h>
Expand All @@ -30,11 +31,12 @@ namespace app {
struct ICDClientInfo
{
ScopedNodeId peer_node;
uint32_t start_icd_counter = 0;
uint32_t offset = 0;
uint64_t monitored_subject = static_cast<uint64_t>(0);
Crypto::Aes128KeyHandle aes_key_handle = Crypto::Aes128KeyHandle();
Crypto::Hmac128KeyHandle hmac_key_handle = Crypto::Hmac128KeyHandle();
uint32_t start_icd_counter = 0;
uint32_t offset = 0;
Clusters::IcdManagement::ClientTypeEnum client_type = Clusters::IcdManagement::ClientTypeEnum::kPermanent;
uint64_t monitored_subject = static_cast<uint64_t>(0);
Crypto::Aes128KeyHandle aes_key_handle = Crypto::Aes128KeyHandle();
Crypto::Hmac128KeyHandle hmac_key_handle = Crypto::Hmac128KeyHandle();

ICDClientInfo() {}
ICDClientInfo(const ICDClientInfo & other) { *this = other; }
Expand All @@ -44,6 +46,7 @@ struct ICDClientInfo
peer_node = other.peer_node;
start_icd_counter = other.start_icd_counter;
offset = other.offset;
client_type = other.client_type;
monitored_subject = other.monitored_subject;
ByteSpan aes_buf(other.aes_key_handle.As<Crypto::Symmetric128BitsKeyByteArray>());
memcpy(aes_key_handle.AsMutable<Crypto::Symmetric128BitsKeyByteArray>(), aes_buf.data(),
Expand Down

0 comments on commit e1b5467

Please sign in to comment.