Skip to content

Commit 83f9ce1

Browse files
committed
example: fix build of light switch when using dynamic commission data provider
1 parent 33ec416 commit 83f9ce1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

examples/light_switch/main/custom_provider/dynamic_commissionable_data_provider.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <custom_provider/dynamic_commissionable_data_provider.h>
1717
#include <esp_log.h>
1818
#include <lib/support/Base64.h>
19+
#include <lib/support/CodeUtils.h>
1920
#include <platform/ESP32/ESP32Config.h>
2021
#include <setup_payload/SetupPayload.h>
2122

@@ -64,12 +65,12 @@ static bool is_valid_base64_str(const char *str)
6465
CHIP_ERROR dynamic_commissionable_data_provider::GetSpake2pSalt(MutableByteSpan &saltBuf)
6566
{
6667
const char *saltB64 = CONFIG_DYNAMIC_PASSCODE_PROVIDER_SALT_BASE64;
67-
ReturnErrorCodeIf(!is_valid_base64_str(saltB64), CHIP_ERROR_INVALID_ARGUMENT);
68+
VerifyOrReturnError(is_valid_base64_str(saltB64), CHIP_ERROR_INVALID_ARGUMENT);
6869
size_t saltB64Len = strlen(saltB64);
6970
uint8_t salt[chip::Crypto::kSpake2p_Max_PBKDF_Salt_Length];
7071
size_t saltLen = chip::Base64Decode32(saltB64, saltB64Len, salt);
71-
ReturnErrorCodeIf(saltLen < chip::Crypto::kSpake2p_Min_PBKDF_Salt_Length, CHIP_ERROR_INVALID_ARGUMENT);
72-
ReturnErrorCodeIf(saltLen > saltBuf.size(), CHIP_ERROR_BUFFER_TOO_SMALL);
72+
VerifyOrReturnError(saltLen >= chip::Crypto::kSpake2p_Min_PBKDF_Salt_Length, CHIP_ERROR_INVALID_ARGUMENT);
73+
VerifyOrReturnError(saltLen <= saltBuf.size(), CHIP_ERROR_BUFFER_TOO_SMALL);
7374

7475
memcpy(saltBuf.data(), salt, saltLen);
7576
saltBuf.reduce_size(saltLen);

0 commit comments

Comments
 (0)