Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits committed May 16, 2022
1 parent 1097515 commit 96319e7
Showing 1 changed file with 43 additions and 42 deletions.
85 changes: 43 additions & 42 deletions src/credentials/FabricTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 96319e7

Please sign in to comment.