From 0e34be0e21d7f1c0bab3a5b01cecad3c23557202 Mon Sep 17 00:00:00 2001 From: shripad621git Date: Thu, 11 Jan 2024 17:34:32 +0530 Subject: [PATCH] Restlyed the code --- .../operational-credentials-server.cpp | 5 +-- src/credentials/BUILD.gn | 2 +- src/credentials/FabricTable.cpp | 34 +++++++++---------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp index e7ddd22cff405d..459c42fcbcc8b3 100644 --- a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp +++ b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp @@ -365,10 +365,7 @@ class OpCredsFabricTableDelegate : public chip::FabricTable::Delegate } // Gets called when a fabric is added/updated, but not necessarily committed to storage - void OnFabricUpdated(const FabricTable & fabricTable, FabricIndex fabricIndex) override - { - NotifyFabricTableChanged(); - } + void OnFabricUpdated(const FabricTable & fabricTable, FabricIndex fabricIndex) override { NotifyFabricTableChanged(); } // Gets called when a fabric in FabricTable is persisted to storage void OnFabricCommitted(const FabricTable & fabricTable, FabricIndex fabricIndex) override diff --git a/src/credentials/BUILD.gn b/src/credentials/BUILD.gn index a9de193e55d153..6aa10311560fa5 100644 --- a/src/credentials/BUILD.gn +++ b/src/credentials/BUILD.gn @@ -127,9 +127,9 @@ static_library("credentials") { "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", "${chip_root}/src/platform", + "${chip_root}/src/protocols:type_definitions", "${chip_root}/src/tracing", "${chip_root}/src/tracing:macros", - "${chip_root}/src/protocols:type_definitions", "${nlassert_root}:nlassert", ] } diff --git a/src/credentials/FabricTable.cpp b/src/credentials/FabricTable.cpp index 236807aba17f0a..971b7cbfb2fb24 100644 --- a/src/credentials/FabricTable.cpp +++ b/src/credentials/FabricTable.cpp @@ -280,7 +280,7 @@ CHIP_ERROR FabricTable::ValidateIncomingNOCChain(const ByteSpan & noc, const Byt NodeId & outNodeId, Crypto::P256PublicKey & outNocPubkey, Crypto::P256PublicKey & outRootPubkey) { - MATTER_TRACE_SCOPE("ValidateIncomingNOCChain","Fabric"); + MATTER_TRACE_SCOPE("ValidateIncomingNOCChain", "Fabric"); Credentials::ValidationContext validContext; // Note that we do NOT set a time in the validation context. This will @@ -330,7 +330,7 @@ CHIP_ERROR FabricTable::ValidateIncomingNOCChain(const ByteSpan & noc, const Byt CHIP_ERROR FabricInfo::SignWithOpKeypair(ByteSpan message, P256ECDSASignature & outSignature) const { - MATTER_TRACE_SCOPE("SignWithOpKeypair","Fabric"); + MATTER_TRACE_SCOPE("SignWithOpKeypair", "Fabric"); VerifyOrReturnError(mOperationalKey != nullptr, CHIP_ERROR_KEY_NOT_FOUND); return mOperationalKey->ECDSA_sign_msg(message.data(), message.size(), outSignature); @@ -338,7 +338,7 @@ CHIP_ERROR FabricInfo::SignWithOpKeypair(ByteSpan message, P256ECDSASignature & CHIP_ERROR FabricInfo::FetchRootPubkey(Crypto::P256PublicKey & outPublicKey) const { - MATTER_TRACE_SCOPE("FetchRootPubKey","Fabric"); + MATTER_TRACE_SCOPE("FetchRootPubKey", "Fabric"); VerifyOrReturnError(IsInitialized(), CHIP_ERROR_KEY_NOT_FOUND); outPublicKey = mRootPublicKey; return CHIP_NO_ERROR; @@ -349,7 +349,7 @@ CHIP_ERROR FabricTable::VerifyCredentials(FabricIndex fabricIndex, const ByteSpa FabricId & outFabricId, NodeId & outNodeId, Crypto::P256PublicKey & outNocPubkey, Crypto::P256PublicKey * outRootPublicKey) const { - MATTER_TRACE_SCOPE("VerifyCredentials","Fabric"); + MATTER_TRACE_SCOPE("VerifyCredentials", "Fabric"); assertChipStackLockedByCurrentThread(); uint8_t rootCertBuf[kMaxCHIPCertLength]; MutableByteSpan rootCertSpan{ rootCertBuf }; @@ -567,14 +567,14 @@ const FabricInfo * FabricTable::FindFabricWithCompressedId(CompressedFabricId co CHIP_ERROR FabricTable::FetchRootCert(FabricIndex fabricIndex, MutableByteSpan & outCert) const { - MATTER_TRACE_SCOPE("FetchRootCert","Fabric"); + MATTER_TRACE_SCOPE("FetchRootCert", "Fabric"); VerifyOrReturnError(mOpCertStore != nullptr, CHIP_ERROR_INCORRECT_STATE); return mOpCertStore->GetCertificate(fabricIndex, CertChainElement::kRcac, outCert); } CHIP_ERROR FabricTable::FetchPendingNonFabricAssociatedRootCert(MutableByteSpan & outCert) const { - MATTER_TRACE_SCOPE("FetchPendingNonFabricAssociatedRootCert","Fabric"); + MATTER_TRACE_SCOPE("FetchPendingNonFabricAssociatedRootCert", "Fabric"); VerifyOrReturnError(mOpCertStore != nullptr, CHIP_ERROR_INCORRECT_STATE); if (!mStateFlags.Has(StateFlags::kIsTrustedRootPending)) { @@ -593,7 +593,7 @@ CHIP_ERROR FabricTable::FetchPendingNonFabricAssociatedRootCert(MutableByteSpan CHIP_ERROR FabricTable::FetchICACert(FabricIndex fabricIndex, MutableByteSpan & outCert) const { - MATTER_TRACE_SCOPE("FetchICACert","Fabric"); + MATTER_TRACE_SCOPE("FetchICACert", "Fabric"); VerifyOrReturnError(mOpCertStore != nullptr, CHIP_ERROR_INCORRECT_STATE); CHIP_ERROR err = mOpCertStore->GetCertificate(fabricIndex, CertChainElement::kIcac, outCert); @@ -613,14 +613,14 @@ CHIP_ERROR FabricTable::FetchICACert(FabricIndex fabricIndex, MutableByteSpan & CHIP_ERROR FabricTable::FetchNOCCert(FabricIndex fabricIndex, MutableByteSpan & outCert) const { - MATTER_TRACE_SCOPE("FetchNOCCert","Fabric"); + MATTER_TRACE_SCOPE("FetchNOCCert", "Fabric"); VerifyOrReturnError(mOpCertStore != nullptr, CHIP_ERROR_INCORRECT_STATE); return mOpCertStore->GetCertificate(fabricIndex, CertChainElement::kNoc, outCert); } CHIP_ERROR FabricTable::FetchRootPubkey(FabricIndex fabricIndex, Crypto::P256PublicKey & outPublicKey) const { - MATTER_TRACE_SCOPE("FetchRootPubkey","Fabric"); + MATTER_TRACE_SCOPE("FetchRootPubkey", "Fabric"); const FabricInfo * fabricInfo = FindFabricWithIndex(fabricIndex); ReturnErrorCodeIf(fabricInfo == nullptr, CHIP_ERROR_INVALID_FABRIC_INDEX); return fabricInfo->FetchRootPubkey(outPublicKey); @@ -758,7 +758,7 @@ class NotBeforeCollector : public Credentials::CertificateValidityPolicy CHIP_ERROR FabricTable::NotifyFabricUpdated(FabricIndex fabricIndex) { - MATTER_TRACE_SCOPE("NotifyFabricUpdated","Fabric"); + MATTER_TRACE_SCOPE("NotifyFabricUpdated", "Fabric"); FabricTable::Delegate * delegate = mDelegateListRoot; while (delegate) { @@ -773,7 +773,7 @@ CHIP_ERROR FabricTable::NotifyFabricUpdated(FabricIndex fabricIndex) CHIP_ERROR FabricTable::NotifyFabricCommitted(FabricIndex fabricIndex) { - MATTER_TRACE_SCOPE("NotifyFabricCommitted","Fabric"); + MATTER_TRACE_SCOPE("NotifyFabricCommitted", "Fabric"); FabricTable::Delegate * delegate = mDelegateListRoot; while (delegate) @@ -933,7 +933,7 @@ FabricTable::AddOrUpdateInner(FabricIndex fabricIndex, bool isAddition, Crypto:: CHIP_ERROR FabricTable::Delete(FabricIndex fabricIndex) { - MATTER_TRACE_SCOPE("Delete","Fabric"); + MATTER_TRACE_SCOPE("Delete", "Fabric"); VerifyOrReturnError(mStorage != nullptr, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(IsValidFabricIndex(fabricIndex), CHIP_ERROR_INVALID_ARGUMENT); @@ -1623,7 +1623,7 @@ CHIP_ERROR FabricTable::AddNewPendingTrustedRootCert(const ByteSpan & rcac) CHIP_ERROR FabricTable::FindExistingFabricByNocChaining(FabricIndex pendingFabricIndex, const ByteSpan & noc, FabricIndex & outMatchingFabricIndex) const { - MATTER_TRACE_SCOPE("FindExistingFabricByNocChaining","Fabric"); + MATTER_TRACE_SCOPE("FindExistingFabricByNocChaining", "Fabric"); // Check whether we already have a matching fabric from a cert chain perspective. // To do so we have to extract the FabricID from the NOC and the root public key from the RCAC. // We assume the RCAC is currently readable from OperationalCertificateStore, whether pending @@ -1669,7 +1669,7 @@ CHIP_ERROR FabricTable::AddNewPendingFabricCommon(const ByteSpan & noc, const By Crypto::P256Keypair * existingOpKey, bool isExistingOpKeyExternallyOwned, AdvertiseIdentity advertiseIdentity, FabricIndex * outNewFabricIndex) { - MATTER_TRACE_SCOPE("AddNewPendingFabricCommon","Fabric"); + MATTER_TRACE_SCOPE("AddNewPendingFabricCommon", "Fabric"); VerifyOrReturnError(mOpCertStore != nullptr, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnError(outNewFabricIndex != nullptr, CHIP_ERROR_INVALID_ARGUMENT); static_assert(kMaxValidFabricIndex <= UINT8_MAX, "Cannot create more fabrics than UINT8_MAX"); @@ -1741,7 +1741,7 @@ CHIP_ERROR FabricTable::UpdatePendingFabricCommon(FabricIndex fabricIndex, const Crypto::P256Keypair * existingOpKey, bool isExistingOpKeyExternallyOwned, AdvertiseIdentity advertiseIdentity) { - MATTER_TRACE_SCOPE("UpdatePendingFabricCommon","Fabric"); + MATTER_TRACE_SCOPE("UpdatePendingFabricCommon", "Fabric"); VerifyOrReturnError(mOpCertStore != nullptr, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnError(IsValidFabricIndex(fabricIndex), CHIP_ERROR_INVALID_ARGUMENT); @@ -2027,7 +2027,7 @@ CHIP_ERROR FabricTable::CommitPendingFabricData() void FabricTable::RevertPendingFabricData() { - MATTER_TRACE_SCOPE("RevertPendingFabricData","Fabric"); + MATTER_TRACE_SCOPE("RevertPendingFabricData", "Fabric"); // Will clear pending UpdateNoc/AddNOC RevertPendingOpCertsExceptRoot(); @@ -2050,7 +2050,7 @@ void FabricTable::RevertPendingFabricData() void FabricTable::RevertPendingOpCertsExceptRoot() { - MATTER_TRACE_SCOPE("RevertPendingOpCertsExceptRoot","Fabric"); + MATTER_TRACE_SCOPE("RevertPendingOpCertsExceptRoot", "Fabric"); mPendingFabric.Reset(); if (mStateFlags.Has(StateFlags::kIsPendingFabricDataPresent))