Skip to content

Commit

Permalink
Use HasDiscriminator()/HasNodeId(), return ERROR_INVALID_ARGUMENT
Browse files Browse the repository at this point in the history
  • Loading branch information
samadDotDev committed Jul 19, 2024
1 parent da28dd6 commit 19c0ffe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/controller/CommissioningWindowOpener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ CHIP_ERROR CommissioningWindowOpener::OpenCommissioningWindow(const Commissionin
SetupPayload & payload)
{
VerifyOrReturnError(mNextStep == Step::kAcceptCommissioningStart, CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(params.HasNodeId(), CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(params.HasDiscriminator(), CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(kSpake2p_Min_PBKDF_Iterations <= params.GetIteration() &&
params.GetIteration() <= kSpake2p_Max_PBKDF_Iterations,
CHIP_ERROR_INVALID_ARGUMENT);
Expand Down Expand Up @@ -140,6 +142,8 @@ CHIP_ERROR CommissioningWindowOpener::OpenCommissioningWindow(const Commissionin
CHIP_ERROR CommissioningWindowOpener::OpenCommissioningWindow(const CommissioningWindowVerifierParams & params)
{
VerifyOrReturnError(mNextStep == Step::kAcceptCommissioningStart, CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(params.HasNodeId(), CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(params.HasDiscriminator(), CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(kSpake2p_Min_PBKDF_Iterations <= params.GetIteration() &&
params.GetIteration() <= kSpake2p_Max_PBKDF_Iterations,
CHIP_ERROR_INVALID_ARGUMENT);
Expand Down
3 changes: 2 additions & 1 deletion src/controller/CommissioningWindowParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ class CommissioningWindowCommonParams
public:
CommissioningWindowCommonParams() = default;

bool HasNodeId() const { return mNodeId != kUndefinedNodeId; }
NodeId GetNodeId() const
{
VerifyOrDie(mNodeId != kUndefinedNodeId);
VerifyOrDie(HasNodeId());
return mNodeId;
}
// The node identifier of device
Expand Down

0 comments on commit 19c0ffe

Please sign in to comment.