Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly manage operational key lifecycle for fail-safe #19277

Merged
merged 36 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f29b087
Properly manage operational key lifecycle for fail-safe
tcarmelveilleux Jun 7, 2022
afe825d
Merge remote-tracking branch 'upstream/master' into keystore-wip2
tcarmelveilleux Jun 7, 2022
538eed3
Fix merge of upstream
tcarmelveilleux Jun 7, 2022
d7d2be9
Restyled by whitespace
restyled-commits Jun 7, 2022
7adf8df
Restyled by clang-format
restyled-commits Jun 7, 2022
cfe632e
Revert unintended testing changes
tcarmelveilleux Jun 7, 2022
09e9f93
Add remove operation
tcarmelveilleux Jun 7, 2022
1f63076
Fix CI and add tests to support further tests
tcarmelveilleux Jun 7, 2022
1037160
Fix more CI
tcarmelveilleux Jun 7, 2022
a719d77
Restyled by clang-format
restyled-commits Jun 7, 2022
65742b1
Darwin changes to use the new setup
bzbarsky-apple Jun 8, 2022
9350b1f
Added unit test and HasOpKeypairForFabric()
tcarmelveilleux Jun 8, 2022
b44d4d7
Restyled by clang-format
restyled-commits Jun 8, 2022
7f422cd
Restyled by gn
restyled-commits Jun 8, 2022
2d01768
Apply review comments from @msandstedt
tcarmelveilleux Jun 8, 2022
a7062a3
Merge pull request #4 from bzbarsky-apple/testing
tcarmelveilleux Jun 8, 2022
6d36c2c
Add plumbing for init of controllers
tcarmelveilleux Jun 8, 2022
f89a544
Restyled by clang-format
restyled-commits Jun 8, 2022
bb698d3
Fix darwin tests
bzbarsky-apple Jun 8, 2022
d145381
Merge pull request #5 from bzbarsky-apple/testing
tcarmelveilleux Jun 8, 2022
a3f25a2
Fix CI and address review comments
tcarmelveilleux Jun 8, 2022
95f98d6
Merge remote-tracking branch 'upstream/master' into keystore-wip2
tcarmelveilleux Jun 8, 2022
59cb65a
Fix comment typos
tcarmelveilleux Jun 8, 2022
622121b
Apply review comments from @bzbarsky-apple and @tehampson
tcarmelveilleux Jun 9, 2022
f3d9cfb
Restyled by clang-format
restyled-commits Jun 9, 2022
9b5a0e4
Fix more comments
tcarmelveilleux Jun 9, 2022
e351173
Restyled by clang-format
restyled-commits Jun 9, 2022
4d16e81
Fix CI
tcarmelveilleux Jun 9, 2022
7686d00
Merge remote-tracking branch 'upstream/master' into keystore-wip2
tcarmelveilleux Jun 9, 2022
c2db517
Fix cirque
tcarmelveilleux Jun 9, 2022
c68bbf6
Restyled by clang-format
restyled-commits Jun 9, 2022
cf8c225
Update src/crypto/tests/TestPersistentStorageOpKeyStore.cpp
woody-apple Jun 9, 2022
7a701eb
Address review comments
tcarmelveilleux Jun 9, 2022
7de88ed
Merge remote-tracking branch 'origin/keystore-wip2' into keystore-wip2
tcarmelveilleux Jun 9, 2022
94aafd7
Fix CI
tcarmelveilleux Jun 10, 2022
1f8717b
More clang-tidy fixes
tcarmelveilleux Jun 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix merge of upstream
  • Loading branch information
tcarmelveilleux committed Jun 7, 2022
commit 538eed33a162759c2c96a0363697351e51e4cb61
1 change: 1 addition & 0 deletions src/app/CASEClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ CHIP_ERROR CASEClient::EstablishSession(PeerId peer, const Transport::PeerAddres
const ReliableMessageProtocolConfig & remoteMRPConfig,
SessionEstablishmentDelegate * delegate)
{
VerifyOrDie(mInitParams.fabricTable != nullptr);
// Create a UnauthenticatedSession for CASE pairing.
Optional<SessionHandle> session = mInitParams.sessionManager->CreateUnauthenticatedSession(peerAddress, remoteMRPConfig);
VerifyOrReturnError(session.HasValue(), CHIP_ERROR_NO_MEMORY);
Expand Down
1 change: 0 additions & 1 deletion src/app/OperationalDeviceProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class DLL_EXPORT OperationalDeviceProxy : public DeviceProxy,
mFabricIndex = fabricInfo->GetFabricIndex();
}
}
mFabricIndex = fabricInfo->GetFabricIndex();
mState = State::NeedsAddress;
mAddressLookupHandle.SetListener(this);
}
Expand Down
2 changes: 1 addition & 1 deletion src/credentials/FabricTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class DLL_EXPORT FabricInfo
// Validate an NOC chain at time of adding/updating a fabric (uses VerifyCredentials with additional checks)
static CHIP_ERROR ValidateIncomingNOCChain(const ByteSpan & noc, const ByteSpan & icac, const ByteSpan & rcac, FabricId existingFabricId,
Credentials::CertificateValidityPolicy * policy,
PeerId & outOperationalId, FabricId & outFabricId, Crypto::P256PublicKey & outNocPubkey)
PeerId & outOperationalId, FabricId & outFabricId, Crypto::P256PublicKey & outNocPubkey);

/**
* Reset the state to a completely uninitialized status.
Expand Down
7 changes: 3 additions & 4 deletions src/protocols/secure_channel/CASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ CASESession::ListenForSessionEstablishment(SessionManager & sessionManager, Fabr
VerifyOrReturnError(fabrics != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
ReturnErrorOnFailure(Init(sessionManager, policy, delegate));

mRole = CryptoContext::SessionRole::kResponder;
mFabricsTable = fabrics;
mRole = CryptoContext::SessionRole::kResponder;
mSessionResumptionStorage = sessionResumptionStorage;
mLocalMRPConfig = mrpConfig;

Expand All @@ -197,17 +197,15 @@ CHIP_ERROR CASESession::EstablishSession(SessionManager & sessionManager, Fabric
{
MATTER_TRACE_EVENT_SCOPE("EstablishSession", "CASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
FabricInfo * fabricInfo = nullptr;

// Return early on error here, as we have not initialized any state yet
ReturnErrorCodeIf(exchangeCtxt == nullptr, CHIP_ERROR_INVALID_ARGUMENT);
ReturnErrorCodeIf(fabricTable == nullptr, CHIP_ERROR_INVALID_ARGUMENT);

// Use FabricTable directly to avoid situation of dangling index from stale FabricInfo
// until we factor-out any FabricInfo direct usage.
mFabricsTable = fabricTable;
ReturnErrorCodeIf(peerScopedNodeId.GetFabricIndex() == kUndefinedFabricIndex, CHIP_ERROR_INVALID_ARGUMENT);
auto * fabricInfo = mFabricsTable->FindFabricWithIndex(peerScopedNodeId.GetFabricIndex());
auto * fabricInfo = fabricTable->FindFabricWithIndex(peerScopedNodeId.GetFabricIndex());
ReturnErrorCodeIf(fabricInfo == nullptr, CHIP_ERROR_INVALID_ARGUMENT);

err = Init(sessionManager, policy, delegate);
Expand All @@ -222,6 +220,7 @@ CHIP_ERROR CASESession::EstablishSession(SessionManager & sessionManager, Fabric
// been initialized
SuccessOrExit(err);

mFabricsTable = fabricTable;
mFabricIndex = fabricInfo->GetFabricIndex();
mSessionResumptionStorage = sessionResumptionStorage;
mLocalMRPConfig = mrpConfig;
Expand Down
2 changes: 2 additions & 0 deletions src/protocols/secure_channel/tests/TestCASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class TestOperationalKeystore : public chip::Crypto::OperationalKeystore
mKeypair = std::move(keypair);
}

bool HasPendingOpKeypair() const override { return false; }

CHIP_ERROR NewOpKeypairForFabric(FabricIndex fabricIndex, MutableByteSpan & outCertificateSigningRequest) override
{
return CHIP_ERROR_NOT_IMPLEMENTED;
Expand Down