Skip to content

Commit

Permalink
Merge branch 'example/fix_dynamic_commission_data_provider' into 'main'
Browse files Browse the repository at this point in the history
example: fix build of light switch when using dynamic commission data provider

See merge request app-frameworks/esp-matter!1066
  • Loading branch information
chshu committed Mar 6, 2025
2 parents 33ec416 + 83f9ce1 commit 51e5f95
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <custom_provider/dynamic_commissionable_data_provider.h>
#include <esp_log.h>
#include <lib/support/Base64.h>
#include <lib/support/CodeUtils.h>
#include <platform/ESP32/ESP32Config.h>
#include <setup_payload/SetupPayload.h>

Expand Down Expand Up @@ -64,12 +65,12 @@ static bool is_valid_base64_str(const char *str)
CHIP_ERROR dynamic_commissionable_data_provider::GetSpake2pSalt(MutableByteSpan &saltBuf)
{
const char *saltB64 = CONFIG_DYNAMIC_PASSCODE_PROVIDER_SALT_BASE64;
ReturnErrorCodeIf(!is_valid_base64_str(saltB64), CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(is_valid_base64_str(saltB64), CHIP_ERROR_INVALID_ARGUMENT);
size_t saltB64Len = strlen(saltB64);
uint8_t salt[chip::Crypto::kSpake2p_Max_PBKDF_Salt_Length];
size_t saltLen = chip::Base64Decode32(saltB64, saltB64Len, salt);
ReturnErrorCodeIf(saltLen < chip::Crypto::kSpake2p_Min_PBKDF_Salt_Length, CHIP_ERROR_INVALID_ARGUMENT);
ReturnErrorCodeIf(saltLen > saltBuf.size(), CHIP_ERROR_BUFFER_TOO_SMALL);
VerifyOrReturnError(saltLen >= chip::Crypto::kSpake2p_Min_PBKDF_Salt_Length, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(saltLen <= saltBuf.size(), CHIP_ERROR_BUFFER_TOO_SMALL);

memcpy(saltBuf.data(), salt, saltLen);
saltBuf.reduce_size(saltLen);
Expand Down

0 comments on commit 51e5f95

Please sign in to comment.