diff --git a/src/credentials/FabricTable.h b/src/credentials/FabricTable.h index 83603f0866b09c..af6f6312232e52 100644 --- a/src/credentials/FabricTable.h +++ b/src/credentials/FabricTable.h @@ -215,67 +215,68 @@ class DLL_EXPORT FabricInfo chip::Platform::Delete(mOperationalKey); } mOperationalKey = nullptr; - } - ReleaseOperationalCerts(); - mFabricIndex = kUndefinedFabricIndex; } + ReleaseOperationalCerts(); + mFabricIndex = kUndefinedFabricIndex; +} - CHIP_ERROR SetFabricInfo(FabricInfo & fabric); +CHIP_ERROR +SetFabricInfo(FabricInfo & fabric); - /* Generate a compressed peer ID (containing compressed fabric ID) using provided fabric ID, node ID and - root public key of the provided root certificate. The generated compressed ID is returned via compressedPeerId - output parameter */ - static CHIP_ERROR GeneratePeerId(const ByteSpan & rcac, FabricId fabricId, NodeId nodeId, PeerId * compressedPeerId); +/* Generate a compressed peer ID (containing compressed fabric ID) using provided fabric ID, node ID and + root public key of the provided root certificate. The generated compressed ID is returned via compressedPeerId + output parameter */ +static CHIP_ERROR GeneratePeerId(const ByteSpan & rcac, FabricId fabricId, NodeId nodeId, PeerId * compressedPeerId); - friend class FabricTable; +friend class FabricTable; - // Test-only, build a fabric using given root cert and NOC - CHIP_ERROR TestOnlyBuildFabric(ByteSpan rootCert, ByteSpan icacCert, ByteSpan nocCert, ByteSpan nocKey); +// Test-only, build a fabric using given root cert and NOC +CHIP_ERROR TestOnlyBuildFabric(ByteSpan rootCert, ByteSpan icacCert, ByteSpan nocCert, ByteSpan nocKey); private: - static constexpr size_t MetadataTLVMaxSize() - { - return TLV::EstimateStructOverhead(sizeof(VendorId), kFabricLabelMaxLengthInBytes); - } +static constexpr size_t MetadataTLVMaxSize() +{ + return TLV::EstimateStructOverhead(sizeof(VendorId), kFabricLabelMaxLengthInBytes); +} - static constexpr size_t OpKeyTLVMaxSize() - { - return TLV::EstimateStructOverhead(sizeof(uint16_t), Crypto::P256SerializedKeypair::Capacity()); - } +static constexpr size_t OpKeyTLVMaxSize() +{ + return TLV::EstimateStructOverhead(sizeof(uint16_t), Crypto::P256SerializedKeypair::Capacity()); +} - PeerId mOperationalId; +PeerId mOperationalId; - FabricIndex mFabricIndex = kUndefinedFabricIndex; - uint16_t mVendorId = VendorId::NotSpecified; - char mFabricLabel[kFabricLabelMaxLengthInBytes + 1] = { '\0' }; +FabricIndex mFabricIndex = kUndefinedFabricIndex; +uint16_t mVendorId = VendorId::NotSpecified; +char mFabricLabel[kFabricLabelMaxLengthInBytes + 1] = { '\0' }; #ifdef ENABLE_HSM_CASE_OPS_KEY - mutable Crypto::P256KeypairHSM * mOperationalKey = nullptr; +mutable Crypto::P256KeypairHSM * mOperationalKey = nullptr; #else - mutable Crypto::P256Keypair * mOperationalKey = nullptr; +mutable Crypto::P256Keypair * mOperationalKey = nullptr; #endif - bool mHasExternallyOwnedOperationalKey = false; +bool mHasExternallyOwnedOperationalKey = false; - MutableByteSpan mRootCert; - MutableByteSpan mICACert; - MutableByteSpan mNOCCert; +MutableByteSpan mRootCert; +MutableByteSpan mICACert; +MutableByteSpan mNOCCert; - FabricId mFabricId = 0; +FabricId mFabricId = 0; - CHIP_ERROR CommitToStorage(PersistentStorageDelegate * storage); - CHIP_ERROR LoadFromStorage(PersistentStorageDelegate * storage); - static CHIP_ERROR DeleteFromStorage(PersistentStorageDelegate * storage, FabricIndex fabricIndex); +CHIP_ERROR CommitToStorage(PersistentStorageDelegate * storage); +CHIP_ERROR LoadFromStorage(PersistentStorageDelegate * storage); +static CHIP_ERROR DeleteFromStorage(PersistentStorageDelegate * storage, FabricIndex fabricIndex); - void ReleaseCert(MutableByteSpan & cert); - void ReleaseOperationalCerts() - { - ReleaseCert(mRootCert); - ReleaseCert(mICACert); - ReleaseCert(mNOCCert); - } +void ReleaseCert(MutableByteSpan & cert); +void ReleaseOperationalCerts() +{ + ReleaseCert(mRootCert); + ReleaseCert(mICACert); + ReleaseCert(mNOCCert); +} - CHIP_ERROR SetCert(MutableByteSpan & dstCert, const ByteSpan & srcCert); -}; +CHIP_ERROR SetCert(MutableByteSpan & dstCert, const ByteSpan & srcCert); +}; // namespace chip // Once attribute store has persistence implemented, FabricTable shoud be backed using // attribute store so no need for this Delegate API anymore