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

Set peer node ID for PASE sessions #13372

Merged
merged 2 commits into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions src/lib/core/NodeId.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ constexpr NodeId NodeIdFromGroupId(GroupId aGroupId)
return kMinGroupNodeId | aGroupId;
}

constexpr NodeId NodeIdFromPAKEKeyId(GroupId aPAKEKeyId)
{
return kMinPAKEKeyId | aPAKEKeyId;
}

} // namespace chip
6 changes: 6 additions & 0 deletions src/protocols/secure_channel/PASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ CHIP_ERROR PASESession::WaitForPairing(uint32_t mySetUpPINCode, uint32_t pbkdf2I
mPasscodeID = 0;
mLocalMRPConfig = mrpConfig;

SetPeerNodeId(NodeIdFromPAKEKeyId(mPasscodeID));

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

exit:
Expand All @@ -298,12 +300,15 @@ CHIP_ERROR PASESession::WaitForPairing(const PASEVerifier & verifier, uint32_t p
uint16_t passcodeID, uint16_t mySessionId, Optional<ReliableMessageProtocolConfig> mrpConfig,
SessionEstablishmentDelegate * delegate)
{
ReturnErrorCodeIf(passcodeID == 0, CHIP_ERROR_INVALID_ARGUMENT);
ReturnErrorOnFailure(WaitForPairing(0, pbkdf2IterCount, salt, mySessionId, mrpConfig, delegate));

memmove(&mPASEVerifier, &verifier, sizeof(verifier));
mComputeVerifier = false;
mPasscodeID = passcodeID;

SetPeerNodeId(NodeIdFromPAKEKeyId(mPasscodeID));

return CHIP_NO_ERROR;
}

Expand All @@ -319,6 +324,7 @@ CHIP_ERROR PASESession::Pair(const Transport::PeerAddress peerAddress, uint32_t
mExchangeCtxt->SetResponseTimeout(kSpake2p_Response_Timeout + mExchangeCtxt->GetAckTimeout());

SetPeerAddress(peerAddress);
SetPeerNodeId(NodeIdFromPAKEKeyId(mPasscodeID));

mLocalMRPConfig = mrpConfig;

Expand Down
4 changes: 2 additions & 2 deletions src/protocols/secure_channel/PASESession.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ class DLL_EXPORT PASESession : public Messaging::ExchangeDelegate, public Pairin

virtual ~PASESession();

// TODO: The SetPeerNodeId method should not be exposed; we should not need
// to associate a node ID with a PASE session.
// TODO: The SetPeerNodeId method should not be exposed; PASE sessions
// should not need to be told their peer node ID
using PairingSession::SetPeerNodeId;

/**
Expand Down