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

Have PairingSession::EncodeSessionParameters require local MRP values #32324

Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
4 changes: 2 additions & 2 deletions src/protocols/secure_channel/CASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ CASESession::PrepareForSessionEstablishment(SessionManager & sessionManager, Fab
mFabricsTable = fabricTable;
mRole = CryptoContext::SessionRole::kResponder;
mSessionResumptionStorage = sessionResumptionStorage;
mLocalMRPConfig = mrpLocalConfig;
mLocalMRPConfig = mrpLocalConfig.ValueOr(GetDefaultMRPConfig());

ChipLogDetail(SecureChannel, "Allocated SecureSession (%p) - waiting for Sigma1 msg",
mSecureSessionHolder.Get().Value()->AsSecureSession());
Expand Down Expand Up @@ -525,7 +525,7 @@ CHIP_ERROR CASESession::EstablishSession(SessionManager & sessionManager, Fabric
mFabricsTable = fabricTable;
mFabricIndex = fabricInfo->GetFabricIndex();
mSessionResumptionStorage = sessionResumptionStorage;
mLocalMRPConfig = mrpLocalConfig;
mLocalMRPConfig = mrpLocalConfig.ValueOr(GetDefaultMRPConfig());

mExchangeCtxt->UseSuggestedResponseTimeout(kExpectedSigma1ProcessingTime);
mPeerNodeId = peerScopedNodeId.GetNodeId();
Expand Down
4 changes: 2 additions & 2 deletions src/protocols/secure_channel/PASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ CHIP_ERROR PASESession::WaitForPairing(SessionManager & sessionManager, const Sp
mIterationCount = pbkdf2IterCount;
mNextExpectedMsg.SetValue(MsgType::PBKDFParamRequest);
mPairingComplete = false;
mLocalMRPConfig = mrpLocalConfig;
mLocalMRPConfig = mrpLocalConfig.ValueOr(GetDefaultMRPConfig());

ChipLogDetail(SecureChannel, "Waiting for PBKDF param request");

Expand Down Expand Up @@ -225,7 +225,7 @@ CHIP_ERROR PASESession::Pair(SessionManager & sessionManager, uint32_t peerSetUp

mExchangeCtxt->UseSuggestedResponseTimeout(kExpectedLowProcessingTime);

mLocalMRPConfig = mrpLocalConfig;
mLocalMRPConfig = mrpLocalConfig.ValueOr(GetDefaultMRPConfig());

err = SendPBKDFParamRequest();
SuccessOrExit(err);
Expand Down
10 changes: 1 addition & 9 deletions src/protocols/secure_channel/PairingSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,9 @@ void PairingSession::DiscardExchange()
}
}

CHIP_ERROR PairingSession::EncodeSessionParameters(TLV::Tag tag, const Optional<ReliableMessageProtocolConfig> & providedMrpConfig,
CHIP_ERROR PairingSession::EncodeSessionParameters(TLV::Tag tag, const ReliableMessageProtocolConfig & mrpLocalConfig,
TLV::TLVWriter & tlvWriter)
{
// TODO: https://github.com/project-chip/connectedhomeip/issues/30456. Based on the spec we need to send values here now,
// but it is not entirely clear what we should be sending here when `providedMrpConfig.HasValue() == false`. For now we
// are sending the default MRP config values.
ReliableMessageProtocolConfig mrpLocalConfig = GetDefaultMRPConfig();
if (providedMrpConfig.HasValue())
{
mrpLocalConfig = providedMrpConfig.Value();
}
TLV::TLVType mrpParamsContainer;
ReturnErrorOnFailure(tlvWriter.StartContainer(tag, TLV::kTLVType_Structure, mrpParamsContainer));
ReturnErrorOnFailure(
Expand Down
4 changes: 2 additions & 2 deletions src/protocols/secure_channel/PairingSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class DLL_EXPORT PairingSession : public SessionDelegate
/**
* Encode the Session Parameters using the provided TLV tag.
*/
static CHIP_ERROR EncodeSessionParameters(TLV::Tag tag, const Optional<ReliableMessageProtocolConfig> & mrpLocalConfig,
static CHIP_ERROR EncodeSessionParameters(TLV::Tag tag, const ReliableMessageProtocolConfig & mrpLocalConfig,
TLV::TLVWriter & tlvWriter);

protected:
Expand Down Expand Up @@ -238,7 +238,7 @@ class DLL_EXPORT PairingSession : public SessionDelegate

// mLocalMRPConfig is our config which is sent to the other end and used by the peer session.
// mRemoteSessionParams is received from other end and set to our session.
Optional<ReliableMessageProtocolConfig> mLocalMRPConfig;
ReliableMessageProtocolConfig mLocalMRPConfig = GetDefaultMRPConfig();
tehampson marked this conversation as resolved.
Show resolved Hide resolved
SessionParameters mRemoteSessionParams;

private:
Expand Down
3 changes: 1 addition & 2 deletions src/protocols/secure_channel/tests/TestPairingSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ void PairingSessionEncodeDecodeMRPParams(nlTestSuite * inSuite, void * inContext
NL_TEST_ASSERT(inSuite,
writer.StartContainer(TLV::AnonymousTag(), TLV::kTLVType_Structure, outerContainerType) == CHIP_NO_ERROR);

NL_TEST_ASSERT(inSuite,
PairingSession::EncodeSessionParameters(TLV::ContextTag(1), MakeOptional(config), writer) == CHIP_NO_ERROR);
NL_TEST_ASSERT(inSuite, PairingSession::EncodeSessionParameters(TLV::ContextTag(1), config, writer) == CHIP_NO_ERROR);

NL_TEST_ASSERT(inSuite, writer.EndContainer(outerContainerType) == CHIP_NO_ERROR);
NL_TEST_ASSERT(inSuite, writer.Finalize(&buf) == CHIP_NO_ERROR);
Expand Down
Loading