Skip to content

Commit

Permalink
Use PasscodeId Type Instead of uint16_t/uint32_t Where Appropriate (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
emargolis authored and pull[bot] committed Jan 18, 2024
1 parent 8de9966 commit 2234258
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ CHIP_ERROR CommissioningWindowManager::OpenBasicCommissioningWindow(uint16_t com

CHIP_ERROR CommissioningWindowManager::OpenEnhancedCommissioningWindow(uint16_t commissioningTimeoutSeconds, uint16_t discriminator,
PASEVerifier & verifier, uint32_t iterations, ByteSpan salt,
uint16_t passcodeID)
PasscodeId passcodeID)
{
// Once a device is operational, it shall be commissioned into subsequent fabrics using
// the operational network only.
Expand Down
6 changes: 3 additions & 3 deletions src/app/server/CommissioningWindowManager.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2021 Project CHIP Authors
* Copyright (c) 2021-2022 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -55,7 +55,7 @@ class CommissioningWindowManager : public SessionEstablishmentDelegate

CHIP_ERROR OpenEnhancedCommissioningWindow(uint16_t commissioningTimeoutSeconds, uint16_t discriminator,
PASEVerifier & verifier, uint32_t iterations, chip::ByteSpan salt,
uint16_t passcodeID);
PasscodeId passcodeID);

void CloseCommissioningWindow();

Expand Down Expand Up @@ -108,7 +108,7 @@ class CommissioningWindowManager : public SessionEstablishmentDelegate
bool mUseECM = false;
PASEVerifier mECMPASEVerifier;
uint16_t mECMDiscriminator = 0;
uint16_t mECMPasscodeID = 0;
PasscodeId mECMPasscodeID = kDefaultCommissioningPasscodeId;
uint32_t mECMIterations = 0;
uint32_t mECMSaltLength = 0;
uint8_t mECMSalt[kPBKDFMaximumSaltLen];
Expand Down
4 changes: 2 additions & 2 deletions src/app/tests/TestCommissionManager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2021 Project CHIP Authors
* Copyright (c) 2021-2022 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -121,7 +121,7 @@ void CheckCommissioningWindowManagerEnhancedWindowTask(intptr_t context)
constexpr uint32_t kIterations = chip::kPBKDFMinimumIterations;
uint8_t salt[chip::kPBKDFMinimumSaltLen];
chip::ByteSpan saltData(salt);
constexpr uint16_t kPasscodeID = 1;
constexpr chip::PasscodeId kPasscodeID = 1;
uint16_t currentDiscriminator;

err = commissionMgr.OpenEnhancedCommissioningWindow(kNoCommissioningTimeout, newDiscriminator, verifier, kIterations, saltData,
Expand Down
2 changes: 1 addition & 1 deletion src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ void DeviceController::OnOpenPairingWindowFailureResponse(void * context, CHIP_E
}

CHIP_ERROR DeviceController::ComputePASEVerifier(uint32_t iterations, uint32_t setupPincode, const ByteSpan & salt,
PASEVerifier & outVerifier, uint32_t & outPasscodeId)
PASEVerifier & outVerifier, PasscodeId & outPasscodeId)
{
ReturnErrorOnFailure(PASESession::GeneratePASEVerifier(outVerifier, iterations, salt, /* useRandomPIN= */ false, setupPincode));

Expand Down
4 changes: 2 additions & 2 deletions src/controller/CHIPDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class DLL_EXPORT DeviceController : public SessionRecoveryDelegate
* @return CHIP_ERROR CHIP_NO_ERROR on success, or corresponding error
*/
CHIP_ERROR ComputePASEVerifier(uint32_t iterations, uint32_t setupPincode, const ByteSpan & salt, PASEVerifier & outVerifier,
uint32_t & outPasscodeId);
PasscodeId & outPasscodeId);

/**
* @brief
Expand Down Expand Up @@ -434,7 +434,7 @@ class DLL_EXPORT DeviceController : public SessionRecoveryDelegate
static void OnOpenPairingWindowFailureResponse(void * context, CHIP_ERROR error);

CHIP_ERROR ProcessControllerNOCChain(const ControllerInitParams & params);
uint16_t mPAKEVerifierID = 1;
PasscodeId mPAKEVerifierID = 1;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ JNI_METHOD(jobject, computePaseVerifier)
CHIP_ERROR err = CHIP_NO_ERROR;
jobject params;
jbyteArray verifierBytes;
uint32_t passcodeId;
PasscodeId passcodeId;
PASEVerifier verifier;
PASEVerifierSerialized serializedVerifier;
MutableByteSpan serializedVerifierSpan(serializedVerifier);
Expand Down
8 changes: 4 additions & 4 deletions src/protocols/secure_channel/PASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ CHIP_ERROR PASESession::WaitForPairing(uint32_t mySetUpPINCode, uint32_t pbkdf2I

mNextExpectedMsg = MsgType::PBKDFParamRequest;
mPairingComplete = false;
mPasscodeID = 0;
mPasscodeID = kDefaultCommissioningPasscodeId;
mLocalMRPConfig = mrpConfig;

SetPeerNodeId(NodeIdFromPAKEKeyId(mPasscodeID));
Expand All @@ -312,8 +312,8 @@ CHIP_ERROR PASESession::WaitForPairing(uint32_t mySetUpPINCode, uint32_t pbkdf2I
}

CHIP_ERROR PASESession::WaitForPairing(const PASEVerifier & verifier, uint32_t pbkdf2IterCount, const ByteSpan & salt,
uint16_t passcodeID, uint16_t mySessionId, Optional<ReliableMessageProtocolConfig> mrpConfig,
SessionEstablishmentDelegate * delegate)
PasscodeId passcodeID, uint16_t mySessionId,
Optional<ReliableMessageProtocolConfig> mrpConfig, SessionEstablishmentDelegate * delegate)
{
ReturnErrorCodeIf(passcodeID == 0, CHIP_ERROR_INVALID_ARGUMENT);
ReturnErrorOnFailure(WaitForPairing(0, pbkdf2IterCount, salt, mySessionId, mrpConfig, delegate));
Expand Down Expand Up @@ -388,7 +388,7 @@ CHIP_ERROR PASESession::SendPBKDFParamRequest()
const size_t mrpParamsSize = mLocalMRPConfig.HasValue() ? TLV::EstimateStructOverhead(sizeof(uint16_t), sizeof(uint16_t)) : 0;
const size_t max_msg_len = TLV::EstimateStructOverhead(kPBKDFParamRandomNumberSize, // initiatorRandom,
sizeof(uint16_t), // initiatorSessionId
sizeof(uint16_t), // passcodeId,
sizeof(PasscodeId), // passcodeId,
sizeof(uint8_t), // hasPBKDFParameters
mrpParamsSize // MRP Parameters
);
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 @@ -138,7 +138,7 @@ class DLL_EXPORT PASESession : public Messaging::ExchangeDelegate, public Pairin
*
* @return CHIP_ERROR The result of initialization
*/
CHIP_ERROR WaitForPairing(const PASEVerifier & verifier, uint32_t pbkdf2IterCount, const ByteSpan & salt, uint16_t passcodeID,
CHIP_ERROR WaitForPairing(const PASEVerifier & verifier, uint32_t pbkdf2IterCount, const ByteSpan & salt, PasscodeId passcodeID,
uint16_t mySessionId, Optional<ReliableMessageProtocolConfig> mrpConfig,
SessionEstablishmentDelegate * delegate);

Expand Down Expand Up @@ -299,7 +299,7 @@ class DLL_EXPORT PASESession : public Messaging::ExchangeDelegate, public Pairin
/* w0s and w1s */
PASEVerifier mPASEVerifier;

uint16_t mPasscodeID = 0;
PasscodeId mPasscodeID = kDefaultCommissioningPasscodeId;

uint32_t mSetupPINCode;

Expand Down

0 comments on commit 2234258

Please sign in to comment.