Skip to content

Commit

Permalink
Merge branch 'master' into fix_basic_composition_error_msg_test_vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
soares-sergio authored Oct 10, 2024
2 parents c52ccfb + 6880437 commit 47df7a7
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 261 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ jobs:
env:
BUILD_TYPE: default
run: |
# We want to build various standalone example apps similar to what examples-linux-standalone.yaml
# We want to build various standalone example apps (similar to what examples-linux-standalone.yaml
# does), so use target_os="all" to get those picked up as part of the "unified" build. But then
# to save CI resources we want to exclude the "host clang" build, which uses the pigweed clang.
scripts/build/gn_gen.sh --args='target_os="all" is_asan=true enable_host_clang_build=false chip_data_model_check_die_on_failure=true' --export-compile-commands
Expand Down
8 changes: 8 additions & 0 deletions config/esp32/components/chip/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ dependencies:
- if: "idf_version >=5.0"
- if: "target != esp32h2"

# This matches the dependency of esp_insights
espressif/esp_diag_data_store:
version: "1.0.1"
require: public
rules:
- if: "idf_version >=5.0"
- if: "target != esp32h2"

espressif/esp_rcp_update:
version: "1.2.0"
rules:
Expand Down
27 changes: 0 additions & 27 deletions examples/all-clusters-minimal-app/tizen/.gn

This file was deleted.

82 changes: 0 additions & 82 deletions examples/all-clusters-minimal-app/tizen/BUILD.gn

This file was deleted.

25 changes: 0 additions & 25 deletions examples/all-clusters-minimal-app/tizen/args.gni

This file was deleted.

1 change: 0 additions & 1 deletion examples/all-clusters-minimal-app/tizen/build_overrides

This file was deleted.

This file was deleted.

63 changes: 0 additions & 63 deletions examples/all-clusters-minimal-app/tizen/src/main.cpp

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions examples/all-clusters-minimal-app/tizen/tizen-manifest.xml

This file was deleted.

1 change: 0 additions & 1 deletion scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,6 @@ def BuildTizenTarget():
# apps
target.AppendFixedTargets([
TargetPart('all-clusters', app=TizenApp.ALL_CLUSTERS),
TargetPart('all-clusters-minimal', app=TizenApp.ALL_CLUSTERS_MINIMAL),
TargetPart('chip-tool', app=TizenApp.CHIP_TOOL),
TargetPart('light', app=TizenApp.LIGHT),
TargetPart('tests', app=TizenApp.TESTS),
Expand Down
5 changes: 0 additions & 5 deletions scripts/build/builders/tizen.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ class TizenApp(Enum):
'examples/all-clusters-app/tizen',
('chip-all-clusters-app',
'chip-all-clusters-app.map'))
ALL_CLUSTERS_MINIMAL = App(
'chip-all-clusters-minimal-app',
'examples/all-clusters-minimal-app/tizen',
('chip-all-clusters-minimal-app',
'chip-all-clusters-minimal-app.map'))
LIGHT = App(
'chip-lighting-app',
'examples/lighting-app/tizen',
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/testdata/all_targets_linux_x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ nrf-native-posix-64-tests
nuttx-x64-light
qpg-qpg6105-{lock,light,shell,persistent-storage,light-switch,thermostat}[-updateimage][-data-model-disabled][-data-model-enabled]
stm32-stm32wb5mm-dk-light
tizen-arm-{all-clusters,all-clusters-minimal,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan][-with-ui]
tizen-arm-{all-clusters,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan][-with-ui]
telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tlsr9258a,tlsr9258a_retention}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb][-data-model-disabled][-data-model-enabled]
openiotsdk-{shell,lock}[-mbedtls][-psa]
5 changes: 1 addition & 4 deletions src/protocols/secure_channel/PASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ CHIP_ERROR PASESession::GeneratePASEVerifier(Spake2pVerifier & verifier, uint32_

if (useRandomPIN)
{
ReturnErrorOnFailure(DRBG_get_bytes(reinterpret_cast<uint8_t *>(&setupPINCode), sizeof(setupPINCode)));

// Passcodes shall be restricted to the values 00000001 to 99999998 in decimal, see 5.1.1.6
setupPINCode = (setupPINCode % kSetupPINCodeMaximumValue) + 1;
ReturnErrorOnFailure(SetupPayload::generateRandomSetupPin(setupPINCode));
}

return verifier.Generate(pbkdf2IterCount, salt, setupPINCode);
Expand Down
29 changes: 29 additions & 0 deletions src/setup_payload/SetupPayload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "SetupPayload.h"

#include <crypto/CHIPCryptoPAL.h>
#include <lib/core/CHIPCore.h>
#include <lib/core/CHIPVendorIdentifiers.hpp>
#include <lib/core/TLV.h>
Expand Down Expand Up @@ -207,6 +208,34 @@ CHIP_ERROR SetupPayload::removeSerialNumber()
return CHIP_NO_ERROR;
}

CHIP_ERROR SetupPayload::generateRandomSetupPin(uint32_t & setupPINCode)
{
uint8_t retries = 0;
const uint8_t maxRetries = 10;

do
{
ReturnErrorOnFailure(Crypto::DRBG_get_bytes(reinterpret_cast<uint8_t *>(&setupPINCode), sizeof(setupPINCode)));

// Passcodes shall be restricted to the values 00000001 to 99999998 in decimal, see 5.1.1.6
// TODO: Consider revising this method to ensure uniform distribution of setup PIN codes
setupPINCode = (setupPINCode % kSetupPINCodeMaximumValue) + 1;

// Make sure that the Generated Setup Pin code is not one of the invalid passcodes/pin codes defined in the
// specification.
if (IsValidSetupPIN(setupPINCode))
{
return CHIP_NO_ERROR;
}

retries++;
// We got pretty unlucky with the random number generator, Just try again.
// This shouldn't take many retries assuming DRBG_get_bytes is not broken.
} while (retries < maxRetries);

return CHIP_ERROR_INTERNAL;
}

CHIP_ERROR SetupPayload::addOptionalVendorData(const OptionalQRCodeInfo & info)
{
VerifyOrReturnError(IsVendorTag(info.tag), CHIP_ERROR_INVALID_ARGUMENT);
Expand Down
11 changes: 11 additions & 0 deletions src/setup_payload/SetupPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,17 @@ class SetupPayload : public PayloadContents
**/
static bool IsVendorTag(uint8_t tag) { return !IsCommonTag(tag); }

/** @brief Generate a Random Setup Pin Code (Passcode)
*
* This function generates a random passcode within the defined limits (00000001 to 99999998)
* It also checks that the generated passcode is not equal to any invalid passcode values as defined in 5.1.7.1.
*
* @param[out] setupPINCode The generated random setup PIN code.
* @return Returns a CHIP_ERROR_INTERNAL if unable to generate a valid passcode within a reasonable number of attempts,
* CHIP_NO_ERROR otherwise
**/
static CHIP_ERROR generateRandomSetupPin(uint32_t & setupPINCode);

private:
std::map<uint8_t, OptionalQRCodeInfo> optionalVendorData;
std::map<uint8_t, OptionalQRCodeInfoExtension> optionalExtensionData;
Expand Down

0 comments on commit 47df7a7

Please sign in to comment.