diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ecef4f5a31da24..6bf171d668b920 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -122,7 +122,7 @@ jobs: retention-days: 5 build_linux: name: Build on Linux (fake, gcc_release, clang, simulated) - timeout-minutes: 120 + timeout-minutes: 150 runs-on: ubuntu-latest if: github.actor != 'restyled-io[bot]' @@ -185,31 +185,14 @@ jobs: - name: Setup Build, Run Build and Run Tests timeout-minutes: 90 run: | - for BUILD_TYPE in gcc_release clang; do - case $BUILD_TYPE in - "gcc_release") GN_ARGS='is_debug=false';; - "clang") GN_ARGS='is_clang=true';; - esac - - BUILD_TYPE=$BUILD_TYPE scripts/build/gn_gen.sh --args="$GN_ARGS" --export-compile-commands - scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE" - BUILD_TYPE=$BUILD_TYPE scripts/tests/gn_tests.sh - done - - name: Clang-tidy validation - timeout-minutes: 45 - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/run-clang-tidy-on-compile-commands.py \ - --no-log-timestamps \ - --compile-database out/clang/compile_commands.json \ - check \ - " + BUILD_TYPE=gcc_release scripts/build/gn_gen.sh --args="is_debug=false" + scripts/run_in_build_env.sh "ninja -C ./out/gcc_release" + BUILD_TYPE=gcc_release scripts/tests/gn_tests.sh - name: Run Tests with sanitizers timeout-minutes: 60 env: LSAN_OPTIONS: detect_leaks=1 run: | - # for BUILD_TYPE in asan msan tsan ubsan; do for BUILD_TYPE in asan tsan ubsan; do case $BUILD_TYPE in "asan") GN_ARGS='is_clang=true is_asan=true';; @@ -218,9 +201,20 @@ jobs: "ubsan") GN_ARGS='is_clang=true is_ubsan=true';; esac - scripts/build/gn_gen.sh --args="$GN_ARGS" - scripts/tests/gn_tests.sh + rm -rf ./out/sanitizers + BUILD_TYPE=sanitizers scripts/build/gn_gen.sh --args="$GN_ARGS" --export-compile-commands + BUILD_TYPE=sanitizers scripts/tests/gn_tests.sh done + - name: Clang-tidy validation + timeout-minutes: 45 + run: | + ./scripts/run_in_build_env.sh \ + "./scripts/run-clang-tidy-on-compile-commands.py \ + --no-log-timestamps \ + --compile-database out/sanitizers/compile_commands.json \ + --file-exclude-regex '/(repo|zzz_generated|lwip/standalone)/' \ + check \ + " - name: Build using build_examples.py timeout-minutes: 60 run: | @@ -245,14 +239,19 @@ jobs: path: /tmp/cores/ # Cores are big; don't hold on to them too long. retention-days: 5 - - name: Uploading objdir for debugging - uses: actions/upload-artifact@v2 - if: ${{ failure() && !env.ACT }} - with: - name: crash-objdir-linux - path: out/ - # objdirs are big; don't hold on to them too long. - retention-days: 5 + # OBJDIR on linux is > 10K files and takes more than 50 minutes to upload, usually + # having the job timeout. + # + # If re-enabling, some subset of this should be picked + # + # - name: Uploading objdir for debugging + # uses: actions/upload-artifact@v2 + # if: ${{ failure() && !env.ACT }} + # with: + # name: crash-objdir-linux + # path: out/ + # # objdirs are big; don't hold on to them too long. + # retention-days: 5 # TODO Log Upload https://github.com/project-chip/connectedhomeip/issues/2227 # TODO https://github.com/project-chip/connectedhomeip/issues/1512 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index f17293a19f381d..ffac7539ec7936 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -282,6 +282,10 @@ jobs: timeout-minutes: 40 run: | scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --script-args "--log-level INFO -t 3600 --disable-test ClusterObjectTests.TestTimedRequestTimeout"' + # the below tests are broken, enable them when they are fixed. Suspect hermetic issues for now + # scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_RR_1_1.py" --script-args "--commissioning-method on-network --discriminator 1234 --passcode 20202021"' + # scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_SC_3_6.py" --script-args "--commissioning-method on-network --discriminator 1234 --passcode 20202021"' + # scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_DA_1_7.py"' - name: Uploading core files uses: actions/upload-artifact@v2 if: ${{ failure() && !env.ACT }} diff --git a/config/nrfconnect/chip-module/generate_factory_data.cmake b/config/nrfconnect/chip-module/generate_factory_data.cmake index fb0d0cd354eb35..55b247619a0c84 100644 --- a/config/nrfconnect/chip-module/generate_factory_data.cmake +++ b/config/nrfconnect/chip-module/generate_factory_data.cmake @@ -25,7 +25,6 @@ # - To use default certification paths set CONFIG_CHIP_FACTORY_DATA_USE_DEFAULTS_CERTS_PATH=y # # During generation process a some file will be created in zephyr's build directory: -# - .args a file containing arguments for nrfconnect_generate_partition.py script. # - .json a file containing all factory data written in JSON format. # # [Args]: @@ -80,6 +79,7 @@ string(APPEND script_args "--spake2_it \"${CONFIG_CHIP_DEVICE_SPAKE2_IT}\"\n") string(APPEND script_args "--spake2_salt \"${CONFIG_CHIP_DEVICE_SPAKE2_SALT}\"\n") string(APPEND script_args "--discriminator ${CONFIG_CHIP_DEVICE_DISCRIMINATOR}\n") string(APPEND script_args "--passcode ${CONFIG_CHIP_DEVICE_SPAKE2_PASSCODE}\n") +string(APPEND script_args "--overwrite\n") # check if spake2 verifier should be generated using script if(CONFIG_CHIP_FACTORY_DATA_GENERATE_SPAKE2_VERIFIER) @@ -98,15 +98,21 @@ string(APPEND script_args "--enable_key \"${CONFIG_CHIP_DEVICE_ENABLE_KEY}\"\n") endif() # Set output JSON file and path to SCHEMA file to validate generated factory data -string(APPEND script_args "-o \"${output_path}/${factory_data_target}.json\"\n") +set(factory_data_json ${output_path}/${factory_data_target}.json) +string(APPEND script_args "-o \"${factory_data_json}\"\n") string(APPEND script_args "-s \"${schema_path}\"\n") # execute first script to create a JSON file separate_arguments(separated_script_args NATIVE_COMMAND ${script_args}) -add_custom_target(${factory_data_target} ALL +add_custom_command( + OUTPUT ${factory_data_json} + DEPENDS ${FACTORY_DATA_SCRIPT_PATH} COMMAND ${Python3_EXECUTABLE} ${FACTORY_DATA_SCRIPT_PATH} ${separated_script_args} COMMENT "Generating new Factory Data..." ) +add_custom_target(${factory_data_target} ALL + DEPENDS ${factory_data_json} + ) endfunction() @@ -117,17 +123,16 @@ endfunction() # # # During generation process some files will be created in zephyr's build directory: -# - _cbor.args a file containing arguments for nrfconnect_generate_partition.py script. # - .hex a file containing all factory data in CBOR format. # - .bin a binary file containing all raw factory data in CBOR format. # - .cbor a file containing all factory data in CBOR format. # # [Args]: -# factory_data_target - a name for target to generate factory_data. -# script_path - a path to script that makes a factory data .hex file from given arguments. -# output_path - a path to output directory, where created JSON file will be stored. -# output_hex - an output variable to store a .hex file. This variable can be used to merge with firmware .hex file. -function(nrfconnect_create_factory_data_hex_file factory_data_target script_path output_path output_hex) +# factory_data_hex_target - a name for target to generate factory data HEX file. +# factory_data_target - a name for target to generate factory data JSON file. +# script_path - a path to script that makes a factory data .hex file from given arguments. +# output_path - a path to output directory, where created JSON file will be stored. +function(nrfconnect_create_factory_data_hex_file factory_data_hex_target factory_data_target script_path output_path) # Pass the argument list via file set(cbor_script_args "-i ${output_path}/${factory_data_target}.json\n") @@ -141,12 +146,13 @@ string(APPEND cbor_script_args "-r\n") separate_arguments(separated_cbor_script_args NATIVE_COMMAND ${cbor_script_args}) set(factory_data_hex ${output_path}/${factory_data_target}.hex) -# return output hex to parent scope -set(${output_hex} ${factory_data_hex} PARENT_SCOPE) add_custom_command(OUTPUT ${factory_data_hex} COMMAND ${Python3_EXECUTABLE} ${script_path} ${separated_cbor_script_args} COMMENT "Generating factory data HEX file..." - DEPENDS ${factory_data_target} + DEPENDS ${factory_data_target} ${script_path} + ) +add_custom_target(${factory_data_hex_target} + DEPENDS ${factory_data_hex} ) endfunction() @@ -170,7 +176,6 @@ endif() # Localize all scripts needed to generate factory data partition set(FACTORY_DATA_SCRIPT_PATH ${CHIP_ROOT}/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py) set(GENERATE_CBOR_SCRIPT_PATH ${CHIP_ROOT}/scripts/tools/nrfconnect/nrfconnect_generate_partition.py) -SET(MERGE_HEX_SCRIPT_PATH ${CHIP_ROOT}/config/nrfconnect/chip-module/merge_factory_data.py) set(FACTORY_DATA_SCHEMA_PATH ${CHIP_ROOT}/scripts/tools/nrfconnect/nrfconnect_factory_data.schema) set(OUTPUT_FILE_PATH ${APPLICATION_BINARY_DIR}/zephyr) @@ -181,24 +186,15 @@ nrfconnect_create_factory_data_json(factory_data ${OUTPUT_FILE_PATH}) # create a .hex file with factory data in CBOR format based on the JSON file created previously -nrfconnect_create_factory_data_hex_file(factory_data +nrfconnect_create_factory_data_hex_file(factory_data_hex + factory_data ${GENERATE_CBOR_SCRIPT_PATH} - ${OUTPUT_FILE_PATH} - factory_data_hex) + ${OUTPUT_FILE_PATH}) if(CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE) # set custom target for merging factory_data hex file - add_custom_target(factory_data_merge - DEPENDS ${factory_data_hex} - ) - set_property(GLOBAL PROPERTY - factory_data_PM_HEX_FILE - ${factory_data_hex} - ) - set_property(GLOBAL PROPERTY - ${parent_slot}_PM_TARGET - ${target_name}_merge - ) + set_property(GLOBAL PROPERTY factory_data_PM_HEX_FILE ${OUTPUT_FILE_PATH}/factory_data.hex) + set_property(GLOBAL PROPERTY factory_data_PM_TARGET factory_data_hex) endif() diff --git a/examples/all-clusters-app/ameba/main/BindingHandler.cpp b/examples/all-clusters-app/ameba/main/BindingHandler.cpp index ccfb210a50a80d..29acdaae952896 100644 --- a/examples/all-clusters-app/ameba/main/BindingHandler.cpp +++ b/examples/all-clusters-app/ameba/main/BindingHandler.cpp @@ -133,12 +133,20 @@ void LightSwitchChangedHandler(const EmberBindingTableEntry & binding, Operation } } +void LightSwitchContextReleaseHandler(void * context) +{ + VerifyOrReturn(context != nullptr, ChipLogError(NotSpecified, "Invalid context for Light switch context release handler")); + + Platform::Delete(static_cast(context)); +} + void InitBindingHandlerInternal(intptr_t arg) { auto & server = chip::Server::GetInstance(); chip::BindingManager::GetInstance().Init( { &server.GetFabricTable(), server.GetCASESessionManager(), &server.GetPersistentStorage() }); chip::BindingManager::GetInstance().RegisterBoundDeviceChangedHandler(LightSwitchChangedHandler); + chip::BindingManager::GetInstance().RegisterBoundDeviceContextReleaseHandler(LightSwitchContextReleaseHandler); } #ifdef CONFIG_ENABLE_CHIP_SHELL @@ -400,8 +408,6 @@ void SwitchWorkerFunction(intptr_t context) BindingCommandData * data = reinterpret_cast(context); BindingManager::GetInstance().NotifyBoundClusterChanged(data->localEndpointId, data->clusterId, static_cast(data)); - - Platform::Delete(data); } void BindingWorkerFunction(intptr_t context) diff --git a/examples/light-switch-app/ameba/main/BindingHandler.cpp b/examples/light-switch-app/ameba/main/BindingHandler.cpp index ccfb210a50a80d..29acdaae952896 100644 --- a/examples/light-switch-app/ameba/main/BindingHandler.cpp +++ b/examples/light-switch-app/ameba/main/BindingHandler.cpp @@ -133,12 +133,20 @@ void LightSwitchChangedHandler(const EmberBindingTableEntry & binding, Operation } } +void LightSwitchContextReleaseHandler(void * context) +{ + VerifyOrReturn(context != nullptr, ChipLogError(NotSpecified, "Invalid context for Light switch context release handler")); + + Platform::Delete(static_cast(context)); +} + void InitBindingHandlerInternal(intptr_t arg) { auto & server = chip::Server::GetInstance(); chip::BindingManager::GetInstance().Init( { &server.GetFabricTable(), server.GetCASESessionManager(), &server.GetPersistentStorage() }); chip::BindingManager::GetInstance().RegisterBoundDeviceChangedHandler(LightSwitchChangedHandler); + chip::BindingManager::GetInstance().RegisterBoundDeviceContextReleaseHandler(LightSwitchContextReleaseHandler); } #ifdef CONFIG_ENABLE_CHIP_SHELL @@ -400,8 +408,6 @@ void SwitchWorkerFunction(intptr_t context) BindingCommandData * data = reinterpret_cast(context); BindingManager::GetInstance().NotifyBoundClusterChanged(data->localEndpointId, data->clusterId, static_cast(data)); - - Platform::Delete(data); } void BindingWorkerFunction(intptr_t context) diff --git a/examples/light-switch-app/esp32/main/BindingHandler.cpp b/examples/light-switch-app/esp32/main/BindingHandler.cpp index 179c8e4a7c7a41..5cc520fd2accd0 100644 --- a/examples/light-switch-app/esp32/main/BindingHandler.cpp +++ b/examples/light-switch-app/esp32/main/BindingHandler.cpp @@ -131,12 +131,20 @@ void LightSwitchChangedHandler(const EmberBindingTableEntry & binding, Operation } } +void LightSwitchContextReleaseHandler(void * context) +{ + VerifyOrReturn(context != nullptr, ChipLogError(NotSpecified, "Invalid context for Light switch context release handler")); + + Platform::Delete(static_cast(context)); +} + void InitBindingHandlerInternal(intptr_t arg) { auto & server = chip::Server::GetInstance(); chip::BindingManager::GetInstance().Init( { &server.GetFabricTable(), server.GetCASESessionManager(), &server.GetPersistentStorage() }); chip::BindingManager::GetInstance().RegisterBoundDeviceChangedHandler(LightSwitchChangedHandler); + chip::BindingManager::GetInstance().RegisterBoundDeviceContextReleaseHandler(LightSwitchContextReleaseHandler); } #ifdef CONFIG_ENABLE_CHIP_SHELL @@ -398,8 +406,6 @@ void SwitchWorkerFunction(intptr_t context) BindingCommandData * data = reinterpret_cast(context); BindingManager::GetInstance().NotifyBoundClusterChanged(data->localEndpointId, data->clusterId, static_cast(data)); - - Platform::Delete(data); } void BindingWorkerFunction(intptr_t context) diff --git a/examples/light-switch-app/telink/src/binding-handler.cpp b/examples/light-switch-app/telink/src/binding-handler.cpp index 9483448c70b34b..ed6b07f8df467e 100755 --- a/examples/light-switch-app/telink/src/binding-handler.cpp +++ b/examples/light-switch-app/telink/src/binding-handler.cpp @@ -133,6 +133,13 @@ void LightSwitchChangedHandler(const EmberBindingTableEntry & binding, Operation } } +void LightSwitchContextReleaseHandler(void * context) +{ + VerifyOrReturn(context != nullptr, ChipLogError(NotSpecified, "Invalid context for Light switch context release handler")); + + Platform::Delete(static_cast(context)); +} + #ifdef ENABLE_CHIP_SHELL /******************************************************** @@ -385,6 +392,7 @@ void InitBindingHandlerInternal(intptr_t arg) chip::BindingManager::GetInstance().Init( { &server.GetFabricTable(), server.GetCASESessionManager(), &server.GetPersistentStorage() }); chip::BindingManager::GetInstance().RegisterBoundDeviceChangedHandler(LightSwitchChangedHandler); + chip::BindingManager::GetInstance().RegisterBoundDeviceContextReleaseHandler(LightSwitchContextReleaseHandler); } } // namespace @@ -413,8 +421,6 @@ void SwitchWorkerFunction(intptr_t context) BindingCommandData * data = reinterpret_cast(context); BindingManager::GetInstance().NotifyBoundClusterChanged(data->localEndpointId, data->clusterId, static_cast(data)); - - Platform::Delete(data); } void BindingWorkerFunction(intptr_t context) diff --git a/examples/lighting-app/esp32/CMakeLists.txt b/examples/lighting-app/esp32/CMakeLists.txt index 8abe862af3120d..06359e838141bc 100644 --- a/examples/lighting-app/esp32/CMakeLists.txt +++ b/examples/lighting-app/esp32/CMakeLists.txt @@ -45,3 +45,25 @@ idf_build_set_property(COMPILE_OPTIONS "-Wno-error=maybe-uninitialized" APPEND) idf_build_set_property(COMPILE_OPTIONS "-Wno-error=uninitialized" APPEND) flashing_script() + +if (CONFIG_ENABLE_PW_RPC) +get_filename_component(CHIP_ROOT ./third_party/connectedhomeip REALPATH) +include(third_party/connectedhomeip/third_party/pigweed/repo/pw_build/pigweed.cmake) + +pw_set_module_config(pw_rpc_CONFIG pw_rpc.disable_global_mutex_config) + +pw_set_backend(pw_log pw_log_basic) +pw_set_backend(pw_assert.check pw_assert_log.check_backend) +pw_set_backend(pw_assert.assert pw_assert.assert_compatibility_backend) +pw_set_backend(pw_sys_io pw_sys_io.esp32) +pw_set_backend(pw_trace pw_trace_tokenized) + +add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo) +add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo) +add_subdirectory(third_party/connectedhomeip/examples/platform/esp32/pw_sys_io) + +get_target_property(_target_cxx_flags pw_build.cpp17 INTERFACE_COMPILE_OPTIONS) +list(REMOVE_ITEM _target_cxx_flags $<$:-std=c++17>) +list(APPEND _target_cxx_flags $<$:-std=gnu++17>) +set_target_properties(pw_build.cpp17 PROPERTIES INTERFACE_COMPILE_OPTIONS "${_target_cxx_flags}") +endif(CONFIG_ENABLE_PW_RPC) diff --git a/examples/lighting-app/esp32/main/CMakeLists.txt b/examples/lighting-app/esp32/main/CMakeLists.txt index 233b25d29ada1f..ff9fac181e2e5d 100644 --- a/examples/lighting-app/esp32/main/CMakeLists.txt +++ b/examples/lighting-app/esp32/main/CMakeLists.txt @@ -16,13 +16,14 @@ # # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) -idf_component_register(PRIV_INCLUDE_DIRS +set(PRIV_INCLUDE_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/lighting-app" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/lighting-app/lighting-common/include" "${CMAKE_CURRENT_LIST_DIR}/include" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" - SRC_DIRS +) +set(SRC_DIRS_LIST "${CMAKE_CURRENT_LIST_DIR}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" @@ -65,10 +66,161 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/groups-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" - PRIV_REQUIRES chip QRCode bt led_strip app_update openthread driver nvs_flash) +) + +set(PRIV_REQUIRES_LIST chip QRCode bt led_strip app_update openthread driver nvs_flash) + +if (CONFIG_ENABLE_PW_RPC) +# Append additional directories for RPC build +set(PRIV_INCLUDE_DIRS_LIST "${PRIV_INCLUDE_DIRS_LIST}" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/pw_sys_io/public" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed/esp32" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/lib/support" + "${IDF_PATH}/components/freertos/include/freertos" +) +set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed/esp32" +) +endif (CONFIG_ENABLE_PW_RPC) + +idf_component_register(PRIV_INCLUDE_DIRS ${PRIV_INCLUDE_DIRS_LIST} + SRC_DIRS ${SRC_DIRS_LIST} + PRIV_REQUIRES ${PRIV_REQUIRES_LIST}) set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17) target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H") target_compile_options(${COMPONENT_LIB} PUBLIC "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" ) + +if (CONFIG_ENABLE_PW_RPC) + +get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH) + +set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo") +include(${PIGWEED_ROOT}/pw_build/pigweed.cmake) +include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake) +set(dir_pw_third_party_nanopb "${CHIP_ROOT}/third_party/nanopb/repo" CACHE STRING "" FORCE) + +pw_proto_library(attributes_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/attributes_service.proto + INPUTS + ${CHIP_ROOT}/examples/common/pigweed/protos/attributes_service.options + PREFIX + attributes_service + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos + DEPS + pw_protobuf.common_proto +) + +pw_proto_library(button_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/button_service.proto + PREFIX + button_service + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos + DEPS + pw_protobuf.common_proto +) + +pw_proto_library(descriptor_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/descriptor_service.proto + PREFIX + descriptor_service + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos + DEPS + pw_protobuf.common_proto +) + +pw_proto_library(device_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/device_service.proto + INPUTS + ${CHIP_ROOT}/examples/common/pigweed/protos/device_service.options + PREFIX + device_service + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos + DEPS + pw_protobuf.common_proto +) + +pw_proto_library(lighting_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/lighting_service.proto + PREFIX + lighting_service + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos + DEPS + pw_protobuf.common_proto +) + +pw_proto_library(locking_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/locking_service.proto + PREFIX + locking_service + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos + DEPS + pw_protobuf.common_proto +) + +pw_proto_library(wifi_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/wifi_service.proto + INPUTS + ${CHIP_ROOT}/examples/common/pigweed/protos/wifi_service.options + PREFIX + wifi_service + DEPS + pw_protobuf.common_proto + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos +) + +target_link_libraries(${COMPONENT_LIB} PUBLIC + attributes_service.nanopb_rpc + button_service.nanopb_rpc + descriptor_service.nanopb_rpc + device_service.nanopb_rpc + lighting_service.nanopb_rpc + locking_service.nanopb_rpc + wifi_service.nanopb_rpc + pw_checksum + pw_hdlc + pw_log + pw_rpc.server + pw_trace_tokenized + pw_trace_tokenized.trace_buffer + pw_trace_tokenized.rpc_service + pw_trace_tokenized.protos.nanopb_rpc +) + +target_link_options(${COMPONENT_LIB} + PUBLIC + "-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld" +) + +target_compile_options(${COMPONENT_LIB} PRIVATE + "-DPW_RPC_ATTRIBUTE_SERVICE=1" + "-DPW_RPC_BUTTON_SERVICE=1" + "-DPW_RPC_DESCRIPTOR_SERVICE=1" + "-DPW_RPC_DEVICE_SERVICE=1" + "-DPW_RPC_LIGHTING_SERVICE=1" + "-DPW_RPC_LOCKING_SERVICE=1" + "-DPW_RPC_TRACING_SERVICE=1" + "-DPW_RPC_WIFI_SERVICE=1" + "-DPW_TRACE_BACKEND_SET=1") + +endif (CONFIG_ENABLE_PW_RPC) diff --git a/examples/lighting-app/esp32/main/Kconfig.projbuild b/examples/lighting-app/esp32/main/Kconfig.projbuild index a13c76c28249b0..43d7d9f0e75381 100644 --- a/examples/lighting-app/esp32/main/Kconfig.projbuild +++ b/examples/lighting-app/esp32/main/Kconfig.projbuild @@ -107,3 +107,41 @@ menu "Demo" default 8 if RENDEZVOUS_MODE_ETHERNET endmenu + +menu "PW RPC Debug channel" +depends on ENABLE_PW_RPC + config EXAMPLE_UART_PORT_NUM + int "UART port number" + range 0 2 if IDF_TARGET_ESP32 + range 0 1 if IDF_TARGET_ESP32C3 + default 0 + help + UART communication port number for the example. + See UART documentation for available port numbers. + + config EXAMPLE_UART_BAUD_RATE + int "UART communication speed" + range 1200 115200 + default 115200 + help + UART communication speed for Modbus example. + + config EXAMPLE_UART_RXD + int "UART RXD pin number" + range 0 34 if IDF_TARGET_ESP32 + range 0 19 if IDF_TARGET_ESP32C3 + default 5 + help + GPIO number for UART RX pin. See UART documentation for more information + about available pin numbers for UART. + + config EXAMPLE_UART_TXD + int "UART TXD pin number" + range 0 34 if IDF_TARGET_ESP32 + range 0 19 if IDF_TARGET_ESP32C3 + default 4 + help + GPIO number for UART TX pin. See UART documentation for more information + about available pin numbers for UART. + +endmenu diff --git a/examples/lighting-app/esp32/main/main.cpp b/examples/lighting-app/esp32/main/main.cpp index a551a6e76199b9..02381fd651fe0d 100644 --- a/examples/lighting-app/esp32/main/main.cpp +++ b/examples/lighting-app/esp32/main/main.cpp @@ -37,6 +37,10 @@ #include #endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER +#if CONFIG_ENABLE_PW_RPC +#include "Rpc.h" +#endif + #if CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER #include #else @@ -81,6 +85,9 @@ extern "C" void app_main() ESP_LOGE(TAG, "nvs_flash_init() failed: %s", esp_err_to_name(err)); return; } +#if CONFIG_ENABLE_PW_RPC + chip::rpc::Init(); +#endif ESP_LOGI(TAG, "=================================================="); ESP_LOGI(TAG, "chip-esp32-light-example starting"); diff --git a/examples/lighting-app/esp32/sdkconfig_rpc.defaults b/examples/lighting-app/esp32/sdkconfig_rpc.defaults new file mode 100644 index 00000000000000..968efdb31ff16f --- /dev/null +++ b/examples/lighting-app/esp32/sdkconfig_rpc.defaults @@ -0,0 +1,52 @@ +# +# Copyright (c) 2020 Project CHIP Authors +# Copyright (c) 2018 Nest Labs, Inc. +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Description: +# CI uses this to select the ESP32C3-DevKitM. +# +# Default to 921600 baud when flashing and monitoring device +CONFIG_ESPTOOLPY_BAUD_921600B=y +CONFIG_ESPTOOLPY_BAUD=921600 +CONFIG_ESPTOOLPY_COMPRESSED=y +CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y +CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 + +#enable BT +CONFIG_BT_ENABLED=y +CONFIG_BT_NIMBLE_ENABLED=y + +#enable lwip ipv6 autoconfig +CONFIG_LWIP_IPV6_AUTOCONFIG=y + +# Use a custom partition table +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" + +#enable lwIP route hooks +CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y +CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y + +# Serial Flasher config +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" + +# PW RPC Debug channel +CONFIG_EXAMPLE_UART_PORT_NUM=0 +CONFIG_EXAMPLE_UART_BAUD_RATE=115200 +CONFIG_EXAMPLE_UART_RXD=3 +CONFIG_EXAMPLE_UART_TXD=1 +CONFIG_ENABLE_PW_RPC=y diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index c9edb01794bca9..c291a111b66f61 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -376,6 +376,7 @@ def Esp32Targets(): yield devkitc.Extend('all-clusters-minimal-ipv6only', app=Esp32App.ALL_CLUSTERS_MINIMAL, enable_ipv4=False) yield devkitc.Extend('shell', app=Esp32App.SHELL) yield devkitc.Extend('light', app=Esp32App.LIGHT) + yield devkitc.Extend('light-rpc', app=Esp32App.LIGHT, enable_rpcs=True) yield devkitc.Extend('lock', app=Esp32App.LOCK) yield devkitc.Extend('bridge', app=Esp32App.BRIDGE) yield devkitc.Extend('temperature-measurement', app=Esp32App.TEMPERATURE_MEASUREMENT) diff --git a/scripts/build/builders/esp32.py b/scripts/build/builders/esp32.py index 53929a7015898d..d84e8f56e8edbc 100644 --- a/scripts/build/builders/esp32.py +++ b/scripts/build/builders/esp32.py @@ -105,6 +105,7 @@ def IsCompatible(self, board: Esp32Board): def DefaultsFileName(board: Esp32Board, app: Esp32App, enable_rpcs: bool): rpc_enabled_apps = [Esp32App.ALL_CLUSTERS, Esp32App.ALL_CLUSTERS_MINIMAL, + Esp32App.LIGHT, Esp32App.OTA_REQUESTOR, Esp32App.TEMPERATURE_MEASUREMENT] if app == Esp32App.TESTS: diff --git a/scripts/build/testdata/all_targets_except_host.txt b/scripts/build/testdata/all_targets_except_host.txt index ffbe1be7a1a4f2..571f1dc197d9ff 100644 --- a/scripts/build/testdata/all_targets_except_host.txt +++ b/scripts/build/testdata/all_targets_except_host.txt @@ -149,6 +149,7 @@ esp32-devkitc-all-clusters-minimal esp32-devkitc-all-clusters-minimal-ipv6only esp32-devkitc-bridge esp32-devkitc-light +esp32-devkitc-light-rpc esp32-devkitc-lock esp32-devkitc-ota-requestor esp32-devkitc-ota-requestor-rpc diff --git a/scripts/build/testdata/build_all_except_host.txt b/scripts/build/testdata/build_all_except_host.txt index ea86e68d1139fd..f2266a5ceeaad1 100644 --- a/scripts/build/testdata/build_all_except_host.txt +++ b/scripts/build/testdata/build_all_except_host.txt @@ -612,6 +612,17 @@ bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh; export SDKCONFIG_DEFAULTS={out}/esp32-devkitc-light/sdkconfig.defaults idf.py -C examples/lighting-app/esp32 -B {out}/esp32-devkitc-light reconfigure' +# Generating esp32-devkitc-light-rpc +mkdir -p {out}/esp32-devkitc-light-rpc + +cp examples/lighting-app/esp32/sdkconfig_rpc.defaults {out}/esp32-devkitc-light-rpc/sdkconfig.defaults + +rm -f examples/lighting-app/esp32/sdkconfig + +bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh; +export SDKCONFIG_DEFAULTS={out}/esp32-devkitc-light-rpc/sdkconfig.defaults +idf.py -C examples/lighting-app/esp32 -B {out}/esp32-devkitc-light-rpc reconfigure' + # Generating esp32-devkitc-lock mkdir -p {out}/esp32-devkitc-lock @@ -1948,6 +1959,13 @@ bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh; export SDKCONFIG_DEFAULTS={out}/esp32-devkitc-light/sdkconfig.defaults idf.py -C examples/lighting-app/esp32 -B {out}/esp32-devkitc-light build' +rm -f examples/lighting-app/esp32/sdkconfig + +# Building esp32-devkitc-light-rpc +bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh; +export SDKCONFIG_DEFAULTS={out}/esp32-devkitc-light-rpc/sdkconfig.defaults +idf.py -C examples/lighting-app/esp32 -B {out}/esp32-devkitc-light-rpc build' + rm -f examples/lock-app/esp32/sdkconfig # Building esp32-devkitc-lock diff --git a/scripts/build/testdata/glob_star_targets_except_host.txt b/scripts/build/testdata/glob_star_targets_except_host.txt index 9d7a22bfc4c937..c20b95528852e5 100644 --- a/scripts/build/testdata/glob_star_targets_except_host.txt +++ b/scripts/build/testdata/glob_star_targets_except_host.txt @@ -43,6 +43,7 @@ esp32-devkitc-all-clusters-minimal esp32-devkitc-all-clusters-minimal-ipv6only esp32-devkitc-bridge esp32-devkitc-light +esp32-devkitc-light-rpc esp32-devkitc-lock esp32-devkitc-ota-requestor esp32-devkitc-ota-requestor-rpc diff --git a/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py b/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py index be06dad9bd355d..f4e9a2b2bfb014 100644 --- a/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py +++ b/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py @@ -70,6 +70,7 @@ def gen_test_certs(chip_cert_exe: str, product_id: int, device_name: str, generate_cd: bool = False, + cd_type: int = 1, paa_cert_path: str = None, paa_key_path: str = None): """ @@ -109,15 +110,15 @@ def gen_test_certs(chip_cert_exe: str, "--key", CD_KEY_PATH, "--cert", CD_PATH, "--out", output + "/CD.der", - "--format-version", str(1), + "--format-version", "1", "--vendor-id", hex(vendor_id), "--product-id", hex(product_id), - "--device-type-id", "0xA", - "--certificate-id", "ZIG20142ZB330003-24", - "--security-level", str(0), - "--security-info", str(0), - "--certification-type", str(0), - "--version-number", "0x2694", + "--device-type-id", "0", + "--certificate-id", "FFFFFFFFFFFFFFFFFFF", + "--security-level", "0", + "--security-info", "0", + "--certification-type", str(cd_type), + "--version-number", "0xFFFF", ] subprocess.run(cmd) @@ -270,6 +271,7 @@ def generate_json(self): self._args.product_id, self._args.vendor_name + "_" + self._args.product_name, self._args.gen_cd, + self._args.cd_type, self._args.paa_cert, self._args.paa_key) dac_cert = certs.dac_cert @@ -464,6 +466,8 @@ def base64_str(s): return base64.b64decode(s) help="[string] Provide additional user-specific keys in JSON format: {'name_1': 'value_1', 'name_2': 'value_2', ... 'name_n', 'value_n'}.") optional_arguments.add_argument("--gen_cd", action="store_true", default=False, help="Generate a new Certificate Declaration in .der format according to used Vendor ID and Product ID. This certificate will not be included to the factory data.") + optional_arguments.add_argument("--cd_type", type=int, default=1, + help="[int] Type of generated Certification Declaration: 0 - development, 1 - provisional, 2 - official") optional_arguments.add_argument("--paa_cert", type=str, help="Provide a path to the Product Attestation Authority (PAA) certificate to generate the PAI certificate. Without providing it, a testing PAA stored in the Matter repository will be used.") optional_arguments.add_argument("--paa_key", type=str, diff --git a/src/app/clusters/bindings/BindingManager.cpp b/src/app/clusters/bindings/BindingManager.cpp index db07abe3ed9f34..ad13376a0dfe42 100644 --- a/src/app/clusters/bindings/BindingManager.cpp +++ b/src/app/clusters/bindings/BindingManager.cpp @@ -101,12 +101,12 @@ CHIP_ERROR BindingManager::EstablishConnection(const ScopedNodeId & nodeId) VerifyOrReturnError(mInitParams.mCASESessionManager != nullptr, CHIP_ERROR_INCORRECT_STATE); mLastSessionEstablishmentError = CHIP_NO_ERROR; - mInitParams.mCASESessionManager->FindOrEstablishSession(nodeId, &mOnConnectedCallback, &mOnConnectionFailureCallback); + auto * connectionCallback = Platform::New(*this); + mInitParams.mCASESessionManager->FindOrEstablishSession(nodeId, connectionCallback->GetOnDeviceConnected(), + connectionCallback->GetOnDeviceConnectionFailure()); if (mLastSessionEstablishmentError == CHIP_ERROR_NO_MEMORY) { // Release the least recently used entry - // TODO: Some reference counting mechanism shall be added the CASESessionManager - // so that other session clients don't get accidentally closed. ScopedNodeId peerToRemove; if (mPendingNotificationMap.FindLRUConnectPeer(peerToRemove) == CHIP_NO_ERROR) { @@ -114,18 +114,15 @@ CHIP_ERROR BindingManager::EstablishConnection(const ScopedNodeId & nodeId) // Now retry mLastSessionEstablishmentError = CHIP_NO_ERROR; - mInitParams.mCASESessionManager->FindOrEstablishSession(nodeId, &mOnConnectedCallback, &mOnConnectionFailureCallback); + // At this point connectionCallback is null since it deletes itself when the callback is called. + connectionCallback = Platform::New(*this); + mInitParams.mCASESessionManager->FindOrEstablishSession(nodeId, connectionCallback->GetOnDeviceConnected(), + connectionCallback->GetOnDeviceConnectionFailure()); } } return mLastSessionEstablishmentError; } -void BindingManager::HandleDeviceConnected(void * context, Messaging::ExchangeManager & exchangeMgr, SessionHandle & sessionHandle) -{ - BindingManager * manager = static_cast(context); - manager->HandleDeviceConnected(exchangeMgr, sessionHandle); -} - void BindingManager::HandleDeviceConnected(Messaging::ExchangeManager & exchangeMgr, SessionHandle & sessionHandle) { FabricIndex fabricToRemove = kUndefinedFabricIndex; @@ -149,17 +146,15 @@ void BindingManager::HandleDeviceConnected(Messaging::ExchangeManager & exchange mPendingNotificationMap.RemoveAllEntriesForNode(ScopedNodeId(nodeToRemove, fabricToRemove)); } -void BindingManager::HandleDeviceConnectionFailure(void * context, const ScopedNodeId & peerId, CHIP_ERROR error) -{ - BindingManager * manager = static_cast(context); - manager->HandleDeviceConnectionFailure(peerId, error); -} - void BindingManager::HandleDeviceConnectionFailure(const ScopedNodeId & peerId, CHIP_ERROR error) { // Simply release the entry, the connection will be re-established as needed. ChipLogError(AppServer, "Failed to establish connection to node 0x" ChipLogFormatX64, ChipLogValueX64(peerId.GetNodeId())); mLastSessionEstablishmentError = error; + // We don't release the entry when connection fails, because inside + // BindingManager::EstablishConnection we may try again the connection. + // TODO(#22173): The logic in there doesn't actually make any sense with how + // mPendingNotificationMap and CASESessionManager are implemented today. } void BindingManager::FabricRemoved(FabricIndex fabricIndex) @@ -188,9 +183,10 @@ CHIP_ERROR BindingManager::NotifyBoundClusterChanged(EndpointId endpoint, Cluste { if (iter->type == EMBER_UNICAST_BINDING) { - mPendingNotificationMap.AddPendingNotification(iter.GetIndex(), bindingContext); + error = mPendingNotificationMap.AddPendingNotification(iter.GetIndex(), bindingContext); + SuccessOrExit(error); error = EstablishConnection(ScopedNodeId(iter->nodeId, iter->fabricIndex)); - SuccessOrExit(error == CHIP_NO_ERROR); + SuccessOrExit(error); } else if (iter->type == EMBER_MULTICAST_BINDING) { diff --git a/src/app/clusters/bindings/BindingManager.h b/src/app/clusters/bindings/BindingManager.h index 578ad4af9e4b76..646281f6718e4f 100644 --- a/src/app/clusters/bindings/BindingManager.h +++ b/src/app/clusters/bindings/BindingManager.h @@ -72,9 +72,7 @@ struct BindingManagerInitParams class BindingManager { public: - BindingManager() : - mOnConnectedCallback(HandleDeviceConnected, this), mOnConnectionFailureCallback(HandleDeviceConnectionFailure, this) - {} + BindingManager() {} void RegisterBoundDeviceChangedHandler(BoundDeviceChangedHandler handler) { mBoundDeviceChangedHandler = handler; } @@ -123,13 +121,47 @@ class BindingManager static BindingManager & GetInstance() { return sBindingManager; } private: - static BindingManager sBindingManager; - - static void HandleDeviceConnected(void * context, Messaging::ExchangeManager & exchangeMgr, SessionHandle & sessionHandle); - void HandleDeviceConnected(Messaging::ExchangeManager & exchangeMgr, SessionHandle & sessionHandle); + /* + * Used when providing OnConnection/Failure callbacks to CASESessionManager when establishing session. + * + * Since the BindingManager calls EstablishConnection inside of a loop, and it is possible that the + * callback is called some time after the loop is completed, we need a separate callbacks for each + * connection we are trying to establish. Failure to provide different instances of the callback + * to CASESessionManager may result in the callback only be called for that last EstablishConnection + * that was called when it establishes the connections asynchronously. + * + */ + class ConnectionCallback + { + public: + ConnectionCallback(BindingManager & bindingManager) : + mBindingManager(bindingManager), mOnConnectedCallback(HandleDeviceConnected, this), + mOnConnectionFailureCallback(HandleDeviceConnectionFailure, this) + {} + + Callback::Callback * GetOnDeviceConnected() { return &mOnConnectedCallback; } + Callback::Callback * GetOnDeviceConnectionFailure() { return &mOnConnectionFailureCallback; } + + private: + static void HandleDeviceConnected(void * context, Messaging::ExchangeManager & exchangeMgr, SessionHandle & sessionHandle) + { + ConnectionCallback * _this = static_cast(context); + _this->mBindingManager.HandleDeviceConnected(exchangeMgr, sessionHandle); + Platform::Delete(_this); + } + static void HandleDeviceConnectionFailure(void * context, const ScopedNodeId & peerId, CHIP_ERROR error) + { + ConnectionCallback * _this = static_cast(context); + _this->mBindingManager.HandleDeviceConnectionFailure(peerId, error); + Platform::Delete(_this); + } + + BindingManager & mBindingManager; + Callback::Callback mOnConnectedCallback; + Callback::Callback mOnConnectionFailureCallback; + }; - static void HandleDeviceConnectionFailure(void * context, const ScopedNodeId & peerId, CHIP_ERROR error); - void HandleDeviceConnectionFailure(const ScopedNodeId & peerId, CHIP_ERROR error); + static BindingManager sBindingManager; CHIP_ERROR EstablishConnection(const ScopedNodeId & nodeId); @@ -137,8 +169,8 @@ class BindingManager BoundDeviceChangedHandler mBoundDeviceChangedHandler; BindingManagerInitParams mInitParams; - Callback::Callback mOnConnectedCallback; - Callback::Callback mOnConnectionFailureCallback; + void HandleDeviceConnected(Messaging::ExchangeManager & exchangeMgr, SessionHandle & sessionHandle); + void HandleDeviceConnectionFailure(const ScopedNodeId & peerId, CHIP_ERROR error); // Used to keep track of synchronous failures from FindOrEstablishSession. CHIP_ERROR mLastSessionEstablishmentError; diff --git a/src/app/clusters/bindings/PendingNotificationMap.cpp b/src/app/clusters/bindings/PendingNotificationMap.cpp index a7e6adb595ce59..7e279b2449c7fb 100644 --- a/src/app/clusters/bindings/PendingNotificationMap.cpp +++ b/src/app/clusters/bindings/PendingNotificationMap.cpp @@ -78,9 +78,14 @@ CHIP_ERROR PendingNotificationMap::FindLRUConnectPeer(ScopedNodeId & nodeId) return CHIP_ERROR_NOT_FOUND; } -void PendingNotificationMap::AddPendingNotification(uint8_t bindingEntryId, PendingNotificationContext * context) +CHIP_ERROR PendingNotificationMap::AddPendingNotification(uint8_t bindingEntryId, PendingNotificationContext * context) { RemoveEntry(bindingEntryId); + if (mNumEntries == EMBER_BINDING_TABLE_SIZE) + { + // We know that the RemoveEntry above did not do anything so we don't need to try restoring it. + return CHIP_ERROR_NO_MEMORY; + } mPendingBindingEntries[mNumEntries] = bindingEntryId; mPendingContexts[mNumEntries] = context; if (context) @@ -88,6 +93,7 @@ void PendingNotificationMap::AddPendingNotification(uint8_t bindingEntryId, Pend context->IncrementConsumersNumber(); } mNumEntries++; + return CHIP_NO_ERROR; } void PendingNotificationMap::RemoveEntry(uint8_t bindingEntryId) diff --git a/src/app/clusters/bindings/PendingNotificationMap.h b/src/app/clusters/bindings/PendingNotificationMap.h index 2e70a0718d047b..99dd3e8eb73cd3 100644 --- a/src/app/clusters/bindings/PendingNotificationMap.h +++ b/src/app/clusters/bindings/PendingNotificationMap.h @@ -102,7 +102,7 @@ class PendingNotificationMap CHIP_ERROR FindLRUConnectPeer(ScopedNodeId & nodeId); - void AddPendingNotification(uint8_t bindingEntryId, PendingNotificationContext * context); + CHIP_ERROR AddPendingNotification(uint8_t bindingEntryId, PendingNotificationContext * context); void RemoveEntry(uint8_t bindingEntryId); diff --git a/src/app/tests/TestPendingNotificationMap.cpp b/src/app/tests/TestPendingNotificationMap.cpp index 271b427f31013a..7f5f091a253252 100644 --- a/src/app/tests/TestPendingNotificationMap.cpp +++ b/src/app/tests/TestPendingNotificationMap.cpp @@ -64,8 +64,11 @@ void TestAddRemove(nlTestSuite * aSuite, void * aContext) CreateDefaultFullBindingTable(BindingTable::GetInstance()); for (uint8_t i = 0; i < EMBER_BINDING_TABLE_SIZE; i++) { - pendingMap.AddPendingNotification(i, nullptr); + NL_TEST_ASSERT(aSuite, pendingMap.AddPendingNotification(i, nullptr) == CHIP_NO_ERROR); } + // Confirm adding in one more element fails + NL_TEST_ASSERT(aSuite, pendingMap.AddPendingNotification(EMBER_BINDING_TABLE_SIZE, nullptr) == CHIP_ERROR_NO_MEMORY); + auto iter = pendingMap.begin(); for (uint8_t i = 0; i < EMBER_BINDING_TABLE_SIZE; i++) { @@ -102,11 +105,11 @@ void TestLRUEntry(nlTestSuite * aSuite, void * aContext) PendingNotificationMap pendingMap; ClearBindingTable(BindingTable::GetInstance()); CreateDefaultFullBindingTable(BindingTable::GetInstance()); - pendingMap.AddPendingNotification(0, nullptr); - pendingMap.AddPendingNotification(1, nullptr); - pendingMap.AddPendingNotification(5, nullptr); - pendingMap.AddPendingNotification(7, nullptr); - pendingMap.AddPendingNotification(11, nullptr); + NL_TEST_ASSERT(aSuite, pendingMap.AddPendingNotification(0, nullptr) == CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, pendingMap.AddPendingNotification(1, nullptr) == CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, pendingMap.AddPendingNotification(5, nullptr) == CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, pendingMap.AddPendingNotification(7, nullptr) == CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, pendingMap.AddPendingNotification(11, nullptr) == CHIP_NO_ERROR); chip::ScopedNodeId node; diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index 30c05e81759d8d..c36054278ea4a6 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -5157,12 +5157,6 @@ PICS: - label: "Does the Controller DUT support Service Advertising?" id: MCORE.SC.ADV - - label: "Does the DUT(Client) implement sending Keysetwrite Command?" - id: GRPKEY.C.C00.Tx - - - label: "Does the DUT(Client) support the GroupKeyMap attribute?" - id: GRPKEY.C.A0000 - #133.1. Bridged Device Basic Information Cluster - label: "Does the DUT(server) support the DataModelRevision attribute?" id: BRBINFO.S.A0000 @@ -5564,3 +5558,6 @@ PICS: "Is the device a Client and supports subscribing for multiple attribute" id: MCORE.IDM.C.SubscribeRequest.MultipleAttributes + + - label: "Does the device support the Factory Reset Method?" + id: MCORE.UI.FACTORYRESET diff --git a/src/app/tests/suites/certification/Test_TC_ACL_1_1.yaml b/src/app/tests/suites/certification/Test_TC_ACL_1_1.yaml index 95ac110e222ffa..ed79c6ef263ded 100644 --- a/src/app/tests/suites/certification/Test_TC_ACL_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_ACL_1_1.yaml @@ -53,7 +53,16 @@ tests: response: constraints: type: list - contains: [0, 1, 2, 3, 4, 65528, 65529, 65531, 65532, 65533] + contains: [0, 2, 3, 4, 65528, 65529, 65531, 65532, 65533] + + - label: "TH reads optional attribute (Extension) in AttributeList" + PICS: ACL.S.A0001 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [1] - label: "TH reads AcceptedCommandList attribute from DUT" command: "readAttribute" diff --git a/src/app/tests/suites/certification/Test_TC_DA_1_1.yaml b/src/app/tests/suites/certification/Test_TC_DA_1_1.yaml index 17004ee5e47712..486bdf4bc9a00f 100644 --- a/src/app/tests/suites/certification/Test_TC_DA_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_DA_1_1.yaml @@ -78,6 +78,7 @@ tests: - label: "Factory reset DUT Perform the device discovery flow checks as covered in TC-DD-2.2" + PICS: MCORE.UI.FACTORYRESET verification: | 1. TH starts matter announcement procedure using BLE transport : verify this by sending "./chip-tool discover commissionables" after launching all-clusters-app on DUT @@ -90,31 +91,20 @@ tests: - label: "Commission DUT to TH2s Fabric" verification: | - To commission DUT to TH2 follow below procedure - 1../chip-tool pairing open-commissioning-window 1 1 400 2000 3840 on TH - - Verify manual parin code on TH1 (chip-tool) Log: - CHIP:IN: Sending encrypted msg 0xaaaad3464d10 with MessageCounter:0 to 0x0000000000000001 at monotonic time: 5805157 msec - [1635691999.946536][3822:3827] CHIP:DMG: ICR moving to [CommandSen] - [1635691999.946586][3822:3827] CHIP:CTL: Manual pairing code: [35407541839] - [1635691999.946650][3822:3827] CHIP:CTL: SetupQRCode: [MT:00000CQM00G6V851H10] - [1635691999.946802][3822:3827] CHIP:EM: Sending Standalone Ack for MessageCounter:3234931243 on exchange 35324i - [1635691999.946850][3822:3827] CHIP:IN: Prepared plaintext message 0xffffaa58a960 to 0x0000000000000000 of type 0x10 and protocolId (0, 0) on exchange 35324i with MessageCounter:1726016118. - [1635691999.946895][3822:3827] CHIP:IN: Sending plaintext msg 0xffffaa58a960 with MessageCounter:1726016118 to 0x0000000000000000 at monotonic time: 5805158 msec - [1635691999.946983][3822:3827] CHIP:EM: Flushed pending ack for MessageCounter:3234931243 on exchange 35324i + sudo ./chip-all-clusters-app --wifi + ./chip-tool pairing ble-wifi 2 zigbeehome matter123 20202021 3841 --trace_decode 1 - 2. Verify TH2 is commissioned by using "./chip-tool pairing code 2 36199720672" considering 36199720672 as manualcode generated in TH1 + Verify in TH2 log: - Verify whether you got below message on TH2 (chip-tool) log - Device commissioning completed with success + [1650455358.501816][4366:4371] CHIP:TOO: Device commissioning completed with success disabled: true - label: "TH2 does a non-fabric-filtered read of Fabrics attribute list from DUT" verification: | - ./chip-tool operationalcredentials read fabrics 2 0 + ./chip-tool operationalcredentials read fabrics 2 0 --commissioner-name beta Verify there is single entry and FabricID matches the FabricID of TH2 on TH2 (chip-tool) log @@ -133,7 +123,7 @@ tests: - label: "TH2 does a non-fabric-filtered read of NOCs attribute list from DUT" verification: | - ./chip-tool operationalcredentials read nocs 2 0 + ./chip-tool operationalcredentials read nocs 2 0 --commissioner-name beta Verify there is single entry on TH2 (chip-tool) log diff --git a/src/app/tests/suites/certification/Test_TC_DA_1_2.yaml b/src/app/tests/suites/certification/Test_TC_DA_1_2.yaml index bec42cb3f42cbb..81cadd47d012eb 100644 --- a/src/app/tests/suites/certification/Test_TC_DA_1_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_DA_1_2.yaml @@ -26,6 +26,11 @@ config: endpoint: 0 tests: + - label: "Pre-Conditions" + verification: | + PAA certificates were obtained externally + disabled: true + - label: "TH1 generates 32-byte AttestationNonce" verification: | To generate the Attestation Nonce give below command @@ -186,11 +191,34 @@ tests: CertificateChainResponse: { [1657814457.685538][2491:2496] CHIP:TOO: certificate: 308201E73082018EA003020102020869CDF10DE9E54ED1300A06082A8648CE3D040302303D3125302306035504030C1C4D6174746572204465762050414920307846464631206E6F2050494431143012060A2B0601040182A27C02010C04464646313020170D3232303230353030303030305A180F39393939313233313233353935395A30533125302306035504030C1C4D61747465722044657620444143203078464646312F30783830303131143012060A2B0601040182A27C02010C044646463131143012060A2B0601040182A27C02020C04383030313059301306072A8648CE3D020106082A8648CE3D03010703420004463AC69342910A0E5588FC6FF56BB63E62ECCECB148F7D4EB03EE552601415767D16A5C663F793E49123260B8297A7CD7E7CFC7B316B39D98E90D29377738E82A360305E300C0603551D130101FF04023000300E0603551D0F0101FF040403020780301D0603551D0E0416041488DDE7B300382932CFF734C04624810F44168A6F301F0603551D2304183016801463540E47F64B1C38D13884A462D16C195D8FFB3C300A06082A8648CE3D040302 [1657814457.685600][2491:2496] CHIP:TOO: ...........: 034700304402200127A27B4B44610EE2FCDC4D2B7885563660BC0F76F17219ED6A08DFB2B3C1CD02206B59E0AF45F3EB2A85B919D35731528C6028C415239545E108E4E54E70971353 + + The log has certificate details (starting with ---BEGIN CERTIFICATE and ending with ---END CERTIFICATE ) as highlighted below, save the certificate in .pem file format. Open editor on your TH , save that in file , example: dac.pem + + 1660951953700] [17233:5262446] CHIP: [DMG] data = 0068e9001f1f110e4f813e5e997100f2b1c69eb72b23bd4e69002a0485ecc741a33706d82f20c8ea99d6b830b2f60ed69c07cecba48142c7f3c8ded67e9ed878b5d68fe28facaf111ee3ce4510fc9b00ad13d57c2a7bd8bdcf868ca8e0aa0bb96c873862f32f12a32207a22e33fe3d8124435207df4f5747414a21b9674685a486f0d3c0aae5d96ba2f02067be2221b98415244522a221f570b62c21a83d88a9ee1a085c5a8c8f5d598f7cb168b4b36ca2306a4554a062e058dba25e7058a4e2f9f976fc71e3d6fcdafb40346d74600e033100243c0837f30f2e6fb337582f6a7d122ffc8943bbc17ba447f80fbac538609c9822d0ab95f6c831071a68ccc9cb1e5180f4daf0a1ae16a33ee3ac7d4754d5f6dca657e44f5a1f9405e668ce848132bb62b1fab6f5cd9aa2d4357fd14e516f18f5c158373f21479aef4c290477141e6d1894901a1c88db870fc1fc005be219dce3f708868ba532c657cf98b8d154d569d6f3de7639cdf72cc43af330ddbac0b910a839416e38a8b305a7eb1b069d274c8c31868363615adb08bfe99a4353f34927785acdb8c1619e1d4f8574491a3e77a46e6c5b47bdd722adfcb00937be7f9ba8c53a8188d42795439a435e6f6a26288c9278981dcac442d480ee40397e2a808d4ae55139562111120bd69411ef301d1b6caf3a4793d143c57092d4944ca93e848f553a19145dc6c02a0b68a67ea83b66afd10988737a753ea8d1f49ca534d12590bf7c3fddd0d7d00baf0121c883a743fcd289dab3d2a8e5131bd987 + [1660951953700] [17233:5262446] CHIP: [DMG] buffer_ptr = 140355398986080 + [1660951953700] [17233:5262446] CHIP: [DMG] } + [1660951953700] [17233:5262446] CHIP: [DMG] + [1660951953700] [17233:5262446] CHIP: [DMG] DAC/PAI (491) = + [1660951953700] [17233:5262446] CHIP: [DMG] { + -----BEGIN CERTIFICATE----- + MIIB5zCCAY6gAwIBAgIIac3xDenlTtEwCgYIKoZIzj0EAwIwPTElMCMGA1UEAwwc + TWF0dGVyIERldiBQQUkgMHhGRkYxIG5vIFBJRDEUMBIGCisGAQQBgqJ8AgEMBEZG + RjEwIBcNMjIwMjA1MDAwMDAwWhgPOTk5OTEyMzEyMzU5NTlaMFMxJTAjBgNVBAMM + HE1hdHRlciBEZXYgREFDIDB4RkZGMS8weDgwMDExFDASBgorBgEEAYKifAIBDARG + RkYxMRQwEgYKKwYBBAGConwCAgwEODAwMTBZMBMGByqGSM49AgEGCCqGSM49AwEH + A0IABEY6xpNCkQoOVYj8b/Vrtj5i7M7LFI99TrA+5VJgFBV2fRalxmP3k+SRIyYL + gpenzX58/HsxaznZjpDSk3dzjoKjYDBeMAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/ + BAQDAgeAMB0GA1UdDgQWBBSI3eezADgpMs/3NMBGJIEPRBaKbzAfBgNVHSMEGDAW + gBRjVA5H9kscONE4hKRi0WwZXY/7PDAKBggqhkjOPQQDAgNHADBEAiABJ6J7S0Rh + DuL83E0reIVWNmC8D3bxchntagjfsrPBzQIga1ngr0Xz6yqFuRnTVzFSjGAoxBUj + lUXhCOTlTnCXE1M= + -----END CERTIFICATE----- + [1660951953700] [17233:5262446] CHIP: [DMG] } disabled: true - label: "TH1 saves DAC certificate" verification: | - Verify the size of certificate is less than or equal to 600 bytes and of type octstr from the above log + Verify the size of certificate is less than or equal to 600 bytes and of type octstr from the above log, You have saved the file already in the above step Example : 308201E73082018EA003020102020869CDF10DE9E54ED1300A06082A8648CE3D040302303D3125302306035504030C1C4D6174746572204465762050414920307846464631206E6F2050494431143012060A2B0601040182A27C02010C04464646313020170D3232303230353030303030305A180F39393939313233313233353935395A30533125302306035504030C1C4D61747465722044657620444143203078464646312F30783830303131143012060A2B0601040182A27C02010C044646463131143012060A2B0601040182A27C02020C04383030313059301306072A8648CE3D020106082A8648CE3D03010703420004463AC69342910A0E5588FC6FF56BB63E62ECCECB148F7D4EB03EE552601415767D16A5C663F793E49123260B8297A7CD7E7CFC7B316B39D98E90D29377738E82A360305E300C0603551D130101FF04023000300E0603551D0F0101FF040403020780301D0603551D0E0416041488DDE7B300382932CFF734C04624810F44168A6F301F0603551D2304183016801463540E47F64B1C38D13884A462D16C195D8FFB3C300A06082A8648CE3D040302 @@ -209,11 +237,36 @@ tests: [1657814533.326158][2501:2506] CHIP:TOO: CertificateChainResponse: { [1657814533.326229][2501:2506] CHIP:TOO: certificate: 308201CB30820171A003020102020856AD8222AD945B64300A06082A8648CE3D04030230303118301606035504030C0F4D617474657220546573742050414131143012060A2B0601040182A27C02010C04464646313020170D3232303230353030303030305A180F39393939313233313233353935395A303D3125302306035504030C1C4D6174746572204465762050414920307846464631206E6F2050494431143012060A2B0601040182A27C02010C04464646313059301306072A8648CE3D020106082A8648CE3D03010703420004419A9315C2173E0C8C876D03CCFC944852647F7FEC5E5082F4059928ECA894C594151309AC631E4CB03392AF684B0BAFB7E65B3B8162C2F52BF931B8E77AAA82A366306430120603551D130101FF040830060101FF020100300E0603551D0F0101FF040403020106301D0603551D0E0416041463540E47F64B1C38D13884A462D16C195D8FFB3C301F0603551D230418301680146AFD22771F511FECBF1641976710DCDC31A1717E300A06082A8648CE3D0403020348003045022100B2EF27F49AE9B50FB91EEAC94C4D0BDBB8D7929C6C [1657814533.326315][2501:2506] CHIP:TOO: ...........: B88FACE529368D12054C0C0220655DC92B86BD909882A6C62177B825D7D05EDBE7C22F9FEA71220E7EA703F891 + + The log has certificate details (starting with ---BEGIN CERTIFICATE and ending with ---END CERTIFICATE ) as highlighted below , save the certificate in .pem file format. Open editor on your TH , save that in file , example: pai.pem + + [1660952198157] [17290:5268348] CHIP: [DMG] Encrypted Payload (531 bytes) = + [1660952198157] [17290:5268348] CHIP: [DMG] { + [1660952198157] [17290:5268348] CHIP: [DMG] data = 001c39000820730541fea9f0e9b148d6c50bdd30d20acef8a0ee67b0458c5fe377d9793092b83e0670ad46770ce44154de4d131731f7065b8329d08be8a280db77f8c12b48300c5fb009c0d3f4b0b1b0a8f4523e319db11ee5d8eb679325c2982248aa5c75b474c50f3bbb0f617ab06a04df403557a564bac4cf08c56fd2eb951d4be875f290dd7b9da01e558fc85ad7b4922d804029410735cae9910a6df282145059b3228e9349467ddc917a268638fa7882a3f7b278355ec848c2ac3f466d3cca746ca416733b85dc6bd8e99ecd35bfc0d3b85f28db6e897636bec89fc41ee2eba78bc7ca11fe959a913ec37901b30a193e6665672e8159e194ca133831251205bca75c00dd8b10160a5b6b814e0cc4fc52f48cc2b68819212bcf71ba11785d2c4628363718e9943216a3f4a3f28adcb988997af982a48d793cd9bd0b62648aa2ffed8f373cd7d5ca86ae703415016adf45a1e8ee26a62d023a6a09accca619ca28e3db15cd4ee5b850608c8319e166dc540877683d960d4b9fde0ae4042096ce696532e9d6b8c96f030def011e59a8762753fc0d50ecf30842377249f78c9b3ee164f5f7988a777a4a1ca407f40923737480eca5e0181977b6048d8835b3d3cedd0d36b9c39098e49048c31db9b48decd744f3121b0260e07b9afe9a8a71d9c14a230e48a1b56894c0453b9779bc8fe269e072ee842aa17821ee09b83cfab5e852918a37bbc1414b7f62cd5dc4c254bfa4 + [1660952198157] [17290:5268348] CHIP: [DMG] buffer_ptr = 140233457951312 + [1660952198157] [17290:5268348] CHIP: [DMG] } + [1660952198157] [17290:5268348] CHIP: [DMG] + [1660952198157] [17290:5268348] CHIP: [DMG] DAC/PAI (463) = + [1660952198157] [17290:5268348] CHIP: [DMG] { + -----BEGIN CERTIFICATE----- + MIIByzCCAXGgAwIBAgIIVq2CIq2UW2QwCgYIKoZIzj0EAwIwMDEYMBYGA1UEAwwP + TWF0dGVyIFRlc3QgUEFBMRQwEgYKKwYBBAGConwCAQwERkZGMTAgFw0yMjAyMDUw + MDAwMDBaGA85OTk5MTIzMTIzNTk1OVowPTElMCMGA1UEAwwcTWF0dGVyIERldiBQ + QUkgMHhGRkYxIG5vIFBJRDEUMBIGCisGAQQBgqJ8AgEMBEZGRjEwWTATBgcqhkjO + PQIBBggqhkjOPQMBBwNCAARBmpMVwhc+DIyHbQPM/JRIUmR/f+xeUIL0BZko7KiU + xZQVEwmsYx5MsDOSr2hLC6+35ls7gWLC9Sv5MbjneqqCo2YwZDASBgNVHRMBAf8E + CDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUY1QOR/ZLHDjROISk + YtFsGV2P+zwwHwYDVR0jBBgwFoAUav0idx9RH+y/FkGXZxDc3DGhcX4wCgYIKoZI + zj0EAwIDSAAwRQIhALLvJ/Sa6bUPuR7qyUxNC9u415KcbLiPrOUpNo0SBUwMAiBl + Xckrhr2QmIKmxiF3uCXX0F7b58Ivn+pxIg5+pwP4kQ== + -----END CERTIFICATE----- + [1660952198157] [17290:5268348] CHIP: [DMG] } + [1660952198157] [17290:5268348] CHIP: [DMG] disabled: true - label: "TH1 saves PAI certificate" verification: | - Verify the size of certificate is less than or equal to 600 bytes and of type octstr from the above log + Verify the size of certificate is less than or equal to 600 bytes and of type octstr from the above log, already saved the file in the above step Example : 308201CB30820171A003020102020856AD8222AD945B64300A06082A8648CE3D04030230303118301606035504030C0F4D617474657220546573742050414131143012060A2B0601040182A27C02010C04464646313020170D3232303230353030303030305A180F39393939313233313233353935395A303D3125302306035504030C1C4D6174746572204465762050414920307846464631206E6F2050494431143012060A2B0601040182A27C02010C04464646313059301306072A8648CE3D020106082A8648CE3D03010703420004419A9315C2173E0C8C876D03CCFC944852647F7FEC5E5082F4059928ECA894C594151309AC631E4CB03392AF684B0BAFB7E65B3B8162C2F52BF931B8E77AAA82A366306430120603551D130101FF040830060101FF020100300E0603551D0F0101FF040403020106301D0603551D0E0416041463540E47F64B1C38D13884A462D16C195D8FFB3C301F0603551D230418301680146AFD22771F511FECBF1641976710DCDC31A1717E300A06082A8648CE3D0403020348003045022100B2EF27F49AE9B50FB91EEAC94C4D0BDBB8D7929C6C @@ -225,7 +278,7 @@ tests: verification: | ./chip-tool basic read vendor-id 1 0 --trace_decode 1 - Verify the vendorId in TH (chip-tool) Log + Verify the vendorId in TH (chip-tool) Log , Note this Vendor ID and you are going to verify this matching with CD in the steps below [1654068802.514300][10990:10995] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0028 Attribute 0x0000_0002 DataVersion: 2079473956 [1654068802.514357][10990:10995] CHIP:TOO: VendorID: 65521 @@ -238,7 +291,7 @@ tests: verification: | ./chip-tool basic read product-id 1 0 --trace_decode 1 - Verify ProductId in TH (chip-tool) Log + Verify ProductId in TH (chip-tool) Log, Note this PID and you are going to verify this matching with CD in the steps below [1654068987.385768][11050:11055] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0028 Attribute 0x0000_0004 DataVersion: 2079473956 [1654068987.385820][11050:11055] CHIP:TOO: ProductID: 32769 @@ -267,7 +320,9 @@ tests: [1658223434.719135][5712:5717] CHIP:TOO: } disabled: true - - label: "" + - label: + "Verify that the DUT generated the AttestationResponse has the + following fields: AttestationElements ,AttestationSignature" verification: | Verify that the DUT generated the AttestationResponse has the following fields in the TH (Chip-Tool ) log generated from the previous step command 1. AttestationElements @@ -685,6 +740,7 @@ tests: version_number should be in range 0..65535, certification_type should be between 1..2 + Verify if the VID PID info in here matches with the steps above [1655374218.453303][35023:35028] CHIP:DMG: Attestation Elements (585 bytes) = [1655374218.453366][35023:35028] CHIP:DMG: { @@ -812,7 +868,7 @@ tests: MCORE.DA.CERTDECL_ORIGIN_VENDORID && MCORE.DA.CERTDECL_ORIGIN_PRODUCTID verification: | - Verify vendor_id and product_id are present in Certification Declaration in TH(chip-tool) log: + Verify dac_origin_vendor_id and dac_origin_product_id are present in Certification Declaration in TH(chip-tool) log: , These are optional parameters, we need not fail the test step if those are not present [1655374218.453303][35023:35028] CHIP:DMG: Attestation Elements (585 bytes) = [1655374218.453366][35023:35028] CHIP:DMG: { @@ -945,11 +1001,12 @@ tests: MCORE.DA.CERTDECL_ORIGIN_VENDORID && MCORE.DA.CERTDECL_ORIGIN_PRODUCTID verification: | - Verify The Vendor ID (VID) in the DAC subject and PAI subject are the same as the vendor_id field in the Certification Declaration. - To decode the DAC/PAI subject, refer TC-DA-1.7 - step 6 & then verify the vendorID and ProductID is same from the previous step log output. - + Print the DAC and PAI that you saved earlier using + openssl x509 -in dac.pem -text + openssl x509 -in pai.pem -text + The output looks like something below. Pls verify if the VID and PIDs mentioned here are matching with information in CD Certificate: Data: Version: 3 (0x2) @@ -1022,7 +1079,12 @@ tests: PAI certificate matches the one found in the authorized_paa_list" PICS: MCORE.DA.CERTDECL_AUTH_PAA verification: | - Not verifiable, authorized_paa_list is optional + The reference applications (all-cluster-app..etc) do not have the authorized_paa_list as it is optional. + + If the authorized_paa_list is available, verify if the PAI chains to PAA using the commands + 1. openssl x509 -in pai.pem -text + 2. openssl x509 -in .pem -text + compare the Authority Key Identifier printed in step1 with the printed in step2. Repeat this to verify on all PAAs. disabled: true - label: @@ -1030,7 +1092,7 @@ tests: verified with the well-known Certification Declaration public key used to originally sign the Certification Declaration" verification: | - Not verifiable, which requires a specific decode tool + Out of scope for V1.0, disabled: true - label: @@ -1065,14 +1127,52 @@ tests: secure session over which the AttestationResponse was obtained, using the subject public key found in the DAC." verification: | - Not verifiable, which requires a specific decode tool to decode the signature & construct a new message. + Out of scope for V1.0, which requires a specific decode tool in chip-cert tool to decode the signature & construct a new message. disabled: true - label: "Verify that the PAA subject public key and subject match one of the official PAA certificates found in the Distributed Compliance Ledger." verification: | - Not verifiable because DCL data + For SVE-2, verify if the PAA subject key matches with the list of PAA stored in the TH. For 1.0 certification, verify the PAA subject matches one of the official PAA certificates found in DCL. To get the PAA subject public key from the test PAA stored in TH, use the command below. For 1.0 cert, Extract the subject public key in similar way and compare if it matches with the certs stored in DCL. + + $openssl x509 -in credentials/development/paa-root-certs/Chip-Test-PAA-FFF1-Cert.pem -text + Certificate: + Data: + Version: 3 (0x2) + Serial Number: 5668035430391749660 (0x4ea8e83182d41c1c) + Signature Algorithm: ecdsa-with-SHA256 + Issuer: CN = Matter Test PAA, 1.3.6.1.4.1.37244.2.1 = FFF1 + Validity + Not Before: Jun 28 14:23:43 2021 GMT + Not After : Dec 31 23:59:59 9999 GMT + Subject: CN = Matter Test PAA, 1.3.6.1.4.1.37244.2.1 = FFF1 + Subject Public Key Info: + Public Key Algorithm: id-ecPublicKey + Public-Key: (256 bit) + pub: + 04:b6:cb:63:72:88:7f:29:28:f5:ba:c8:1a:a9:d9: + 3a:e2:43:1c:ad:a9:d7:9e:24:2f:65:17:7e:f9:ce: + d9:32:a2:8e:cd:03:ba:af:6a:8f:ca:18:4a:1a:50: + 35:42:96:0d:45:3f:30:3f:1f:19:42:1d:75:1e:8f: + 8f:1a:9a:9b:75 + ASN1 OID: prime256v1 + NIST CURVE: P-256 + X509v3 extensions: + X509v3 Basic Constraints: critical + CA:TRUE, pathlen:1 + X509v3 Key Usage: critical + Certificate Sign, CRL Sign + X509v3 Subject Key Identifier: + 6A:FD:22:77:1F:51:1F:EC:BF:16:41:97:67:10:DC:DC:31:A1:71:7E + X509v3 Authority Key Identifier: + keyid:6A:FD:22:77:1F:51:1F:EC:BF:16:41:97:67:10:DC:DC:31:A1:71:7E + + Signature Algorithm: ecdsa-with-SHA256 + 30:44:02:20:50:aa:80:02:f4:d9:32:a9:a0:05:38:f6:53:68: + ad:0f:ff:c8:ef:bb:c9:be:b7:da:56:98:35:cf:9a:a7:51:0e: + 02:20:23:ba:c8:fe:0f:23:e7:54:45:b6:53:39:08:1a:47:99: + 49:29:c7:2a:af:0a:15:48:d4:0d:03:4d:51:4b:25:de disabled: true - label: diff --git a/src/app/tests/suites/certification/Test_TC_DA_1_3.yaml b/src/app/tests/suites/certification/Test_TC_DA_1_3.yaml index 05ce3ac3d23a07..7eff4aa56fa801 100644 --- a/src/app/tests/suites/certification/Test_TC_DA_1_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_DA_1_3.yaml @@ -31,6 +31,13 @@ tests: Chip-tool command used below are an example to verify the DUT as client test cases. For certification test, we expect DUT should have a capability or way to run the equivalent command. disabled: true + - label: "Pre-Conditions" + verification: | + 1. PAI, DAC certificates are obtained and validated against externally obtained PAA certificate + 2. Operations happen within the Fail-Safe Context + 3. TH1 should be known about Commissioner based error condition/warning + disabled: true + - label: "Start the commissioning process of TH1 on DUT" verification: | sudo ./chip-all-clusters-app --wifi --trace_decode 1 @@ -182,7 +189,7 @@ tests: [1659763321.704116][2548:2548] CHIP:DMG: ICR moving to [AwaitingDe]" disabled: true - - label: "" + - label: "Verify that DUT Completes the commissioning process successfully" verification: | Verify that DUT Completes the commissioning process successfully on TH(all-clusters-app) @@ -311,7 +318,7 @@ tests: [1659766925.558805][2548:2548] CHIP:DMG: } disabled: true - - label: "" + - label: "Verify that the Nonce_1 and Nonce_2 are different." verification: | Verify the value of NONCE in step 9 and 3 are different diff --git a/src/app/tests/suites/certification/Test_TC_DGSW_2_3.yaml b/src/app/tests/suites/certification/Test_TC_DGSW_2_3.yaml index 406d02672771c3..b86349da970c7d 100644 --- a/src/app/tests/suites/certification/Test_TC_DGSW_2_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_DGSW_2_3.yaml @@ -39,7 +39,7 @@ tests: - label: "Reads a list of ThreadMetrics struct attribute from DUT." command: "readAttribute" attribute: "ThreadMetrics" - PICS: DGSW.S.A0001 + PICS: DGSW.S.A0000 response: constraints: type: list diff --git a/src/app/tests/suites/certification/Test_TC_DRLK_2_2.yaml b/src/app/tests/suites/certification/Test_TC_DRLK_2_2.yaml index 82e79debbf4c59..6e34679157e549 100644 --- a/src/app/tests/suites/certification/Test_TC_DRLK_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_DRLK_2_2.yaml @@ -33,7 +33,7 @@ tests: - label: "Create new user" command: "SetUser" - timedInteractionTimeoutMs: 10000 + timedInteractionTimeoutMs: 1000 arguments: values: - name: "operationType" @@ -82,7 +82,7 @@ tests: - label: "Create new PIN credential and lock/unlock user" command: "SetCredential" - timedInteractionTimeoutMs: 10000 + timedInteractionTimeoutMs: 1000 arguments: values: - name: "operationType" @@ -155,22 +155,22 @@ tests: - label: "TH sends Lock Door Command to the DUT without PINCode" PICS: DRLK.S.C00.Rsp command: "LockDoor" - timedInteractionTimeoutMs: 10000 + timedInteractionTimeoutMs: 1000 response: error: 0x00 - label: "TH sends Lock Door Command to the DUT with valid PINCode" PICS: DRLK.S.C00.Rsp command: "LockDoor" - timedInteractionTimeoutMs: 10000 + timedInteractionTimeoutMs: 1000 arguments: values: - name: "pinCode" value: "123456" - label: - "TH writes the RequirePINforRemoteOperation attribute value as True on - the DUT" + "TH writes the RequirePINforRemoteOperation attribute value as False + on the DUT" PICS: DRLK.S.A0033 command: "writeAttribute" attribute: "RequirePINforRemoteOperation" @@ -178,8 +178,8 @@ tests: value: true - label: - "TH writes the RequirePINforRemoteOperation attribute value as True on - the DUT and Verify DUT responds with UNSUPPORTED_WRITE" + "TH writes the RequirePINforRemoteOperation attribute value as False + on the DUT and Verify DUT responds with UNSUPPORTED_WRITE" PICS: "!DRLK.S.A0033" command: "writeAttribute" attribute: "RequirePINforRemoteOperation" @@ -198,7 +198,7 @@ tests: - label: "TH sends Lock Door Command to the DUT with valid PINCode" PICS: DRLK.S.C00.Rsp && DRLK.S.A0033 command: "LockDoor" - timedInteractionTimeoutMs: 10000 + timedInteractionTimeoutMs: 1000 arguments: values: - name: "pinCode" @@ -207,7 +207,7 @@ tests: - label: "TH sends Lock Door Command to the DUT without valid PINCode" PICS: DRLK.S.C00.Rsp && DRLK.S.A0033 command: "LockDoor" - timedInteractionTimeoutMs: 10000 + timedInteractionTimeoutMs: 1000 arguments: values: - name: "pinCode" @@ -219,13 +219,41 @@ tests: "TH sends Lock Door Command to the DUT without any argument PINCode" PICS: DRLK.S.C00.Rsp && DRLK.S.A0033 command: "LockDoor" - timedInteractionTimeoutMs: 10000 + timedInteractionTimeoutMs: 1000 response: error: FAILURE + - label: "TH reads the WrongCodeEntryLimit attribute from the DUT" + PICS: DRLK.S.A0030 + command: "readAttribute" + attribute: "WrongCodeEntryLimit" + constraints: + minValue: 1 + maxValue: 255 + + - label: "TH sends the unlock Door command to the DUT with invalid PINCode" + PICS: DRLK.S.A0030 + command: "UnlockDoor" + timedInteractionTimeoutMs: 1000 + arguments: + values: + - name: "PINCode" + value: "1234568" + response: + error: FAILURE + + - label: "TH sends the unlock Door command to the DUT with valid PINCode" + PICS: DRLK.S.A0030 + command: "UnlockDoor" + timedInteractionTimeoutMs: 1000 + arguments: + values: + - name: "PINCode" + value: "123456" + - label: - "TH writes WrongCodeEntryLimit attribute value as 3 on the DUT and - Verify that the DUT sends Success response" + "TH writes WrongCodeEntryLimit attribute value as between 1 and 255 on + the DUT and Verify that the DUT sends Success response" PICS: DRLK.S.A0030 command: "writeAttribute" attribute: "WrongCodeEntryLimit" @@ -233,8 +261,8 @@ tests: value: 3 - label: - "TH writes WrongCodeEntryLimit attribute value as 3 on the DUT and - verify DUT responds with UNSUPPORTED_WRITE" + "TH writes WrongCodeEntryLimit attribute value as between 1 and 255 on + the DUT and verify DUT responds with UNSUPPORTED_WRITE" PICS: "!DRLK.S.A0030" command: "writeAttribute" attribute: "WrongCodeEntryLimit" @@ -243,9 +271,17 @@ tests: response: error: UNSUPPORTED_WRITE + - label: "TH reads the UserCodeTemporaryDisableTime attribute from the DUT" + PICS: DRLK.S.A0031 + command: "readAttribute" + attribute: "UserCodeTemporaryDisableTime" + constraints: + minValue: 1 + maxValue: 255 + - label: - "TH writes UserCodeTemporaryDisableTime attribute value as 15 seconds - on the DUT and Verify that the DUT send the Success response" + "TH writes UserCodeTemporaryDisableTime attribute value as between 1 + and 255 on the DUT and Verify that the DUT sends Success response" PICS: DRLK.S.A0031 command: "writeAttribute" attribute: "UserCodeTemporaryDisableTime" @@ -253,8 +289,8 @@ tests: value: 15 - label: - "TH writes UserCodeTemporaryDisableTime attribute value as 15 seconds - on the DUT and Verify DUT responds with UNSUPPORTED_WRITE" + "TH writes UserCodeTemporaryDisableTime attribute value as between 1 + and 255 on the DUT and verify DUT responds with UNSUPPORTED_WRITE" PICS: "!DRLK.S.A0031" command: "writeAttribute" attribute: "UserCodeTemporaryDisableTime" @@ -263,93 +299,9 @@ tests: response: error: UNSUPPORTED_WRITE - - label: "TH sends Lock Door Command to the DUT with invalid PINCode" - PICS: DRLK.S.C00.Rsp - command: "LockDoor" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "pinCode" - value: "123458" - response: - error: FAILURE - - - label: "TH sends Lock Door Command to the DUT with invalid PINCode" - PICS: DRLK.S.C00.Rsp - command: "LockDoor" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "pinCode" - value: "123458" - response: - error: FAILURE - - - label: "TH sends Lock Door Command to the DUT with invalid PINCode" - PICS: DRLK.S.C00.Rsp - command: "LockDoor" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "pinCode" - value: "123458" - response: - error: FAILURE - - - label: "TH sends Lock Door Command to the DUT with invalid PINCode" - PICS: DRLK.S.C00.Rsp - command: "LockDoor" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "pinCode" - value: "123458" - response: - error: FAILURE - - - label: - "TH reads UserCodeTemporaryDisableTime attribute from DUT and After - sending 3 failure responses verify that UserCodeTemporaryDisableTime - attribute is triggered" - verification: | - ./chip-tool doorlock read user-code-temporary-disable-time 1 1 - - On TH, verify the UserCodeTemporaryDisableTime value as 15 - - [1657867358.396037][2551:2556] CHIP:DMG: - [1657867358.396067][2551:2556] CHIP:DMG: SuppressResponse = true, - [1657867358.396099][2551:2556] CHIP:DMG: InteractionModelRevision = 1 - [1657867358.396129][2551:2556] CHIP:DMG: } - [1657867358.396286][2551:2556] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0101 Attribute 0x0000_0031 DataVersion: 2082875948 - [1657867358.396378][2551:2556] CHIP:TOO: UserCodeTemporaryDisableTime: 15 - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_USER_PROMPT && DRLK.S.A0031 - arguments: - values: - - name: "message" - value: "Please enter 'y' for success" - - name: "expectedValue" - value: "y" - - - label: - "TH sends Lock Command to the DUT with valid PINCode before - UserCodeTemporaryDisableTime attribute time expires" - verification: | - Verify that DUT sends failure response to the TH - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_USER_PROMPT && DRLK.S.C00.Rsp - arguments: - values: - - name: "message" - value: "Please enter 'y' for success" - - name: "expectedValue" - value: "y" - - label: "Clean the created user" command: "ClearUser" - timedInteractionTimeoutMs: 10000 + timedInteractionTimeoutMs: 1000 arguments: values: - name: "userIndex" @@ -358,7 +310,7 @@ tests: - label: "Cleanup the created credential" PICS: DRLK.S.C26.Rsp command: "ClearCredential" - timedInteractionTimeoutMs: 10000 + timedInteractionTimeoutMs: 1000 arguments: values: - name: "credential" diff --git a/src/app/tests/suites/certification/Test_TC_LVL_3_1.yaml b/src/app/tests/suites/certification/Test_TC_LVL_3_1.yaml index cff9707bda319c..28fd797de4d4c7 100644 --- a/src/app/tests/suites/certification/Test_TC_LVL_3_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_LVL_3_1.yaml @@ -142,7 +142,6 @@ tests: value: 0 - label: "Wait 10000ms" - PICS: LVL.S.M.VarRate cluster: "DelayCommands" command: "WaitForMs" arguments: @@ -160,7 +159,6 @@ tests: maxValue: 115 - label: "Wait 10000ms" - PICS: LVL.S.M.VarRate cluster: "DelayCommands" command: "WaitForMs" arguments: @@ -178,7 +176,6 @@ tests: maxValue: 173 - label: "Wait 10000ms" - PICS: LVL.S.M.VarRate cluster: "DelayCommands" command: "WaitForMs" arguments: @@ -196,7 +193,6 @@ tests: maxValue: 200 - label: "Wait 5000ms" - PICS: LVL.S.M.VarRate cluster: "DelayCommands" command: "WaitForMs" arguments: diff --git a/src/app/tests/suites/certification/Test_TC_LVL_5_1.yaml b/src/app/tests/suites/certification/Test_TC_LVL_5_1.yaml index 239a16fbadcae7..a909f16b621c88 100644 --- a/src/app/tests/suites/certification/Test_TC_LVL_5_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_LVL_5_1.yaml @@ -138,7 +138,6 @@ tests: value: 0 - label: "Wait 10s" - PICS: LVL.S.M.VarRate cluster: "DelayCommands" command: "WaitForMs" arguments: @@ -156,7 +155,6 @@ tests: maxValue: 115 - label: "Wait 10s" - PICS: LVL.S.M.VarRate cluster: "DelayCommands" command: "WaitForMs" arguments: @@ -174,7 +172,6 @@ tests: maxValue: 173 - label: "Wait 10s" - PICS: LVL.S.M.VarRate cluster: "DelayCommands" command: "WaitForMs" arguments: @@ -192,7 +189,6 @@ tests: maxValue: 200 - label: "Wait 5000ms" - PICS: LVL.S.M.VarRate cluster: "DelayCommands" command: "WaitForMs" arguments: diff --git a/src/app/tests/suites/certification/Test_TC_MEDIAPLAYBACK_6_3.yaml b/src/app/tests/suites/certification/Test_TC_MEDIAPLAYBACK_6_3.yaml index 3bc927d533f6cb..96e11ccf86c241 100644 --- a/src/app/tests/suites/certification/Test_TC_MEDIAPLAYBACK_6_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_MEDIAPLAYBACK_6_3.yaml @@ -81,9 +81,13 @@ tests: - label: "TH reads the StartTime attribute from the DUT" PICS: MEDIAPLAYBACK.S.A0001 && PICS_USER_PROMPT verification: | + "The TH commands for this test step can be invoked using chip-tool (when DUT is a commissionee) or tv-casting-app (when DUT is a commissioner): ./chip-tool mediaplayback read start-time 1 1 + ./chip-tv-casting-app mediaplayback read start-time 1 1 + + On TH Verify that the response is a valid start time or null. [1654001778189] [97015:7707437] CHIP: [TOO] Endpoint: 1 Cluster: 0x0000_0506 Attribute 0x0000_0001 DataVersion: 775839144 - [1654001778190] [97015:7707437] CHIP: [TOO] StartTime: 0 + [1654001778190] [97015:7707437] CHIP: [TOO] StartTime: 0" cluster: "LogCommands" command: "UserPrompt" arguments: @@ -96,7 +100,11 @@ tests: #Issue 10988 - label: "TH reads the SeekRangeEnd attribute from the DUT" verification: | + The TH commands for this test step can be invoked using chip-tool (when DUT is a commissionee) or tv-casting-app (when DUT is a commissioner): ./chip-tool mediaplayback read seek-range-end 1 1 + ./chip-tv-casting-app mediaplayback read seek-range-end 1 1 + + On TH Verify that the response is a valid position or Nas. [1654002119527] [97409:7712444] CHIP: [TOO] Endpoint: 1 Cluster: 0x0000_0506 Attribute 0x0000_0005 DataVersion: 775839144 [1654002119527] [97409:7712444] CHIP: [TOO] SeekRangeEnd: 80000 cluster: "LogCommands" @@ -112,10 +120,18 @@ tests: #Issue 10988 - label: "TH reads the SeekRangeStart attribute from the DUT" verification: | + The TH commands for this test step can be invoked using chip-tool (when DUT is a commissionee) or tv-casting-app (when DUT is a commissioner): ./chip-tool mediaplayback read seek-range-start 1 1 - [1654751320.161753][2491:2496] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0506 Attribute 0x0000_0006 DataVersion: 1615951406 - [1654751320.161846][2491:2496] CHIP:TOO: SeekRangeStart: 10000 - [1654751320.161941][2491:2496] CHIP:EM: Sending Standalone Ack for MessageCounter:120565821 on exchange 1929 + ./chip-tv-casting-app mediaplayback read seek-range-start 1 1 + + On TH Verify that the response is a valid position or Nas. + [1661240180.806771][2930:2935] CHIP:DMG: SuppressResponse = true, + [1661240180.806809][2930:2935] CHIP:DMG: InteractionModelRevision = 1 + [1661240180.806844][2930:2935] CHIP:DMG: } + [1661240180.807024][2930:2935] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0506 Attribute 0x0000_0006 DataVersion: 1520269522 + [1661240180.807103][2930:2935] CHIP:TOO: SeekRangeStart: 0 + [1661240180.807211][2930:2935] CHIP:EM: Sending Standalone Ack for MessageCounter:164562596 on exchange 31684i + [1661240180.807299][2930:2935] CHIP:IN: Prepared secure message 0xffff95f5d978 to 0x0000000000000001 (1) of type 0x10 and protocolId (0, 0) on exchange 31684i with MessageCounter:104721987.s cluster: "LogCommands" command: "UserPrompt" PICS: PICS_USER_PROMPT && MEDIAPLAYBACK.S.A0006 @@ -129,7 +145,11 @@ tests: #Issue 10988 - label: "TH reads the Duration attribute from the DUT" verification: | + The TH commands for this test step can be invoked using chip-tool (when DUT is a commissionee) or tv-casting-app (when DUT is a commissioner): ./chip-tool mediaplayback read duration 1 1 + ./chip-tv-casting-app mediaplayback read duration 1 1 + + On TH Verify that the response is null or not 0. [1654001869267] [97168:7708957] CHIP: [TOO] Endpoint: 1 Cluster: 0x0000_0506 Attribute 0x0000_0002 DataVersion: 775839144 [1654001869267] [97168:7708957] CHIP: [TOO] Duration: 80000 cluster: "LogCommands" diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index adef2a6a62af76..5f22d02e45d4ea 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -1681,3 +1681,4 @@ MCORE.IDM.C.WriteRequest.Attribute.DataType_Enum=1 MCORE.IDM.C.WriteRequest.Attribute.DataType_Bitmap=1 MCORE.IDM.C.SubscribeRequest.Attribute.DataType_Bool=1 MCORE.IDM.C.SubscribeRequest.MultipleAttributes=1 +MCORE.UI.FACTORYRESET=1 diff --git a/src/darwin/Framework/CHIP/MTRSetupPayload.h b/src/darwin/Framework/CHIP/MTRSetupPayload.h index 926e344fa06f90..e82ab104e7467d 100644 --- a/src/darwin/Framework/CHIP/MTRSetupPayload.h +++ b/src/darwin/Framework/CHIP/MTRSetupPayload.h @@ -73,6 +73,10 @@ typedef NS_ENUM(NSUInteger, MTROptionalQRCodeInfoType) { * Generate a random Matter-valid setup PIN. */ + (NSUInteger)generateRandomPIN; + +/** Get 11 digit manual entry code from the setup payload. */ +- (nullable NSString *)manualEntryCode; + @end NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/MTRSetupPayload.mm b/src/darwin/Framework/CHIP/MTRSetupPayload.mm index 17f1696d23770a..39c18a33d1a66c 100644 --- a/src/darwin/Framework/CHIP/MTRSetupPayload.mm +++ b/src/darwin/Framework/CHIP/MTRSetupPayload.mm @@ -18,6 +18,7 @@ #import "MTRError.h" #import "MTRError_Internal.h" #import "MTRSetupPayload_Internal.h" +#import "setup_payload/ManualSetupPayloadGenerator.h" #import @implementation MTROptionalQRCodeInfo @@ -196,4 +197,29 @@ - (nullable instancetype)initWithCoder:(NSCoder *)decoder return payload; } +- (nullable NSString *)manualEntryCode +{ + CHIP_ERROR err = CHIP_NO_ERROR; + std::string outDecimalString; + chip::SetupPayload payload; + + /// The 11 digit manual pairing code only requires the version, VID_PID present flag, + /// discriminator, and the setup pincode. + payload.version = [self.version unsignedCharValue]; + if (self.hasShortDiscriminator) { + payload.discriminator.SetShortValue([self.discriminator unsignedCharValue]); + } else { + payload.discriminator.SetLongValue([self.discriminator unsignedShortValue]); + } + payload.setUpPINCode = [self.setUpPINCode unsignedIntValue]; + + err = chip::ManualSetupPayloadGenerator(payload).payloadDecimalStringRepresentation(outDecimalString); + + if (err != CHIP_NO_ERROR) { + return nil; + } + + return [NSString stringWithUTF8String:outDecimalString.c_str()]; +} + @end diff --git a/src/platform/Darwin/DnssdContexts.cpp b/src/platform/Darwin/DnssdContexts.cpp index a047eced226687..9fe9a5a4f37ae0 100644 --- a/src/platform/Darwin/DnssdContexts.cpp +++ b/src/platform/Darwin/DnssdContexts.cpp @@ -374,8 +374,40 @@ bool ResolveContext::HasAddress() void ResolveContext::OnNewInterface(uint32_t interfaceId, const char * fullname, const char * hostnameWithDomain, uint16_t port, uint16_t txtLen, const unsigned char * txtRecord) { - ChipLogDetail(Discovery, "Mdns : %s hostname:%s fullname:%s interface: %" PRIu32 " port: %u TXT:\"%.*s\"", __func__, - hostnameWithDomain, fullname, interfaceId, port, static_cast(txtLen), txtRecord); +#if CHIP_DETAIL_LOGGING + std::string txtString; + auto txtRecordIter = txtRecord; + size_t remainingLen = txtLen; + while (remainingLen > 0) + { + size_t len = *txtRecordIter; + ++txtRecordIter; + --remainingLen; + len = min(len, remainingLen); + chip::Span bytes(txtRecordIter, len); + if (txtString.size() > 0) + { + txtString.push_back(','); + } + for (auto & byte : bytes) + { + if ((std::isalnum(byte) || std::ispunct(byte)) && byte != '\\' && byte != ',') + { + txtString.push_back(static_cast(byte)); + } + else + { + char hex[5]; + snprintf(hex, sizeof(hex), "\\x%02x", byte); + txtString.append(hex); + } + } + txtRecordIter += len; + remainingLen -= len; + } +#endif // CHIP_DETAIL_LOGGING + ChipLogDetail(Discovery, "Mdns : %s hostname:%s fullname:%s interface: %" PRIu32 " port: %u TXT:\"%s\"", __func__, + hostnameWithDomain, fullname, interfaceId, port, txtString.c_str()); InterfaceInfo interface; interface.service.mPort = ntohs(port); diff --git a/src/tools/chip-cert/CertUtils.cpp b/src/tools/chip-cert/CertUtils.cpp index 0c22503628bc31..5afaa3c29d561f 100644 --- a/src/tools/chip-cert/CertUtils.cpp +++ b/src/tools/chip-cert/CertUtils.cpp @@ -508,51 +508,52 @@ bool AddAuthorityKeyId(X509 * cert, X509 * caCert) return res; } -bool ReadCertPEM(const char * fileName, X509 * cert) -{ - bool res = true; - FILE * file = nullptr; - - res = OpenFile(fileName, file); - VerifyTrueOrExit(res); - - if (PEM_read_X509(file, &cert, nullptr, nullptr) == nullptr) - { - ReportOpenSSLErrorAndExit("PEM_read_X509", res = false); - } - -exit: - CloseFile(file); - return res; -} - } // namespace -bool ReadCert(const char * fileName, X509 * cert) +bool ReadCert(const char * fileNameOrStr, X509 * cert) { CertFormat origCertFmt; - return ReadCert(fileName, cert, origCertFmt); + return ReadCert(fileNameOrStr, cert, origCertFmt); } -bool ReadCert(const char * fileName, X509 * cert, CertFormat & certFmt) +bool ReadCert(const char * fileNameOrStr, X509 * cert, CertFormat & certFmt) { bool res = true; uint32_t certLen = 0; std::unique_ptr certBuf; - res = ReadFileIntoMem(fileName, nullptr, certLen); - VerifyTrueOrExit(res); + // If fileNameOrStr is a file name + if (access(fileNameOrStr, R_OK) == 0) + { + res = ReadFileIntoMem(fileNameOrStr, nullptr, certLen); + VerifyTrueOrExit(res); - certBuf = std::unique_ptr(new uint8_t[certLen]); + certBuf = std::unique_ptr(new uint8_t[certLen]); - res = ReadFileIntoMem(fileName, certBuf.get(), certLen); - VerifyTrueOrExit(res); + res = ReadFileIntoMem(fileNameOrStr, certBuf.get(), certLen); + VerifyTrueOrExit(res); - certFmt = DetectCertFormat(certBuf.get(), certLen); - if (certFmt == kCertFormat_Unknown) + certFmt = DetectCertFormat(certBuf.get(), certLen); + if (certFmt == kCertFormat_Unknown) + { + fprintf(stderr, "Unrecognized Cert Format in File: %s\n", fileNameOrStr); + return false; + } + } + // Otherwise, treat fileNameOrStr as a pointer to the certificate string + else { - fprintf(stderr, "Unrecognized Cert Format in File: %s\n", fileName); - return false; + certLen = static_cast(strlen(fileNameOrStr)); + + certFmt = DetectCertFormat(reinterpret_cast(fileNameOrStr), certLen); + if (certFmt == kCertFormat_Unknown) + { + fprintf(stderr, "Unrecognized Cert Format in the Input Argument: %s\n", fileNameOrStr); + return false; + } + + certBuf = std::unique_ptr(new uint8_t[certLen]); + memcpy(certBuf.get(), fileNameOrStr, certLen); } if ((certFmt == kCertFormat_X509_Hex) || (certFmt == kCertFormat_Chip_Hex)) @@ -565,8 +566,15 @@ bool ReadCert(const char * fileName, X509 * cert, CertFormat & certFmt) if (certFmt == kCertFormat_X509_PEM) { - res = ReadCertPEM(fileName, cert); - VerifyTrueOrExit(res); + VerifyOrReturnError(chip::CanCastTo(certLen), false); + + std::unique_ptr certBIO( + BIO_new_mem_buf(static_cast(certBuf.get()), static_cast(certLen)), &BIO_free_all); + + if (PEM_read_bio_X509(certBIO.get(), &cert, nullptr, nullptr) == nullptr) + { + ReportOpenSSLErrorAndExit("PEM_read_bio_X509", res = false); + } } else if ((certFmt == kCertFormat_X509_DER) || (certFmt == kCertFormat_X509_Hex)) { @@ -612,12 +620,12 @@ bool ReadCert(const char * fileName, X509 * cert, CertFormat & certFmt) return res; } -bool ReadCertDERRaw(const char * fileName, MutableByteSpan & cert) +bool ReadCertDER(const char * fileNameOrStr, MutableByteSpan & cert) { bool res = true; std::unique_ptr certX509(X509_new(), &X509_free); - VerifyOrReturnError(ReadCertPEM(fileName, certX509.get()) == true, false); + VerifyOrReturnError(ReadCert(fileNameOrStr, certX509.get()), false); uint8_t * certPtr = cert.data(); int certLen = i2d_X509(certX509.get(), &certPtr); @@ -660,14 +668,14 @@ bool X509ToChipCert(X509 * cert, MutableByteSpan & chipCert) return res; } -bool LoadChipCert(const char * fileName, bool isTrused, ChipCertificateSet & certSet, MutableByteSpan & chipCert) +bool LoadChipCert(const char * fileNameOrStr, bool isTrused, ChipCertificateSet & certSet, MutableByteSpan & chipCert) { bool res = true; CHIP_ERROR err; BitFlags decodeFlags; std::unique_ptr cert(X509_new(), &X509_free); - res = ReadCert(fileName, cert.get()); + res = ReadCert(fileNameOrStr, cert.get()); VerifyTrueOrExit(res); res = X509ToChipCert(cert.get(), chipCert); @@ -685,7 +693,7 @@ bool LoadChipCert(const char * fileName, bool isTrused, ChipCertificateSet & cer err = certSet.LoadCert(chipCert, decodeFlags); if (err != CHIP_NO_ERROR) { - fprintf(stderr, "Error reading %s\n%s\n", fileName, chip::ErrorStr(err)); + fprintf(stderr, "Error reading %s\n%s\n", fileNameOrStr, chip::ErrorStr(err)); ExitNow(res = false); } @@ -747,8 +755,6 @@ bool WriteCert(const char * fileName, X509 * cert, CertFormat certFmt) ExitNow(res = false); } - printf("\r\n"); - exit: OPENSSL_free(derCert); CloseFile(file); diff --git a/src/tools/chip-cert/Cmd_ConvertCert.cpp b/src/tools/chip-cert/Cmd_ConvertCert.cpp index a1379388f02d0c..7eba1cc2f8868c 100644 --- a/src/tools/chip-cert/Cmd_ConvertCert.cpp +++ b/src/tools/chip-cert/Cmd_ConvertCert.cpp @@ -87,21 +87,21 @@ OptionSet gCmdOptions = HelpOptions gHelpOptions( CMD_NAME, - "Usage: " CMD_NAME " [ ] \n", + "Usage: " CMD_NAME " [ ] \n", CHIP_VERSION_STRING "\n" COPYRIGHT_STRING, - "Convert a certificate between CHIP and X509 forms.\n" + "Convert operational certificate between CHIP and X.509 formats.\n" "\n" "ARGUMENTS\n" "\n" - " \n" + " \n" "\n" - " The input certificate file name, or - to read from stdin. The\n" - " format of the input certificate is auto-detected and can be any\n" - " of: X.509 PEM, X.509 DER, CHIP base-64 or CHIP raw TLV.\n" + " File or string containing certificate to be converted.\n" + " The format of the input certificate is auto-detected and can be any of:\n" + " X.509 PEM, X.509 DER, X.509 HEX, CHIP base-64, CHIP raw TLV or CHIP HEX.\n" "\n" - " \n" + " \n" "\n" - " The output certificate file name, or - to write to stdout.\n" + " The output certificate file name, or '-' to write to stdout.\n" "\n" ); @@ -113,9 +113,9 @@ OptionSet * gCmdOptionSets[] = }; // clang-format on -const char * gInFileName = nullptr; -const char * gOutFileName = nullptr; -CertFormat gOutCertFormat = kCertFormat_Default; +const char * gInFileNameOrStr = nullptr; +const char * gOutFileName = nullptr; +CertFormat gOutCertFormat = kCertFormat_Default; bool HandleOption(const char * progName, OptionSet * optSet, int id, const char * name, const char * arg) { @@ -151,7 +151,7 @@ bool HandleNonOptionArgs(const char * progName, int argc, char * const argv[]) { if (argc == 0) { - PrintArgError("%s: Please specify the name of the input certificate file, or - for stdin.\n", progName); + PrintArgError("%s: Please specify the name of the input certificate file or the certificate string.\n", progName); return false; } @@ -167,8 +167,8 @@ bool HandleNonOptionArgs(const char * progName, int argc, char * const argv[]) return false; } - gInFileName = argv[0]; - gOutFileName = argv[1]; + gInFileNameOrStr = argv[0]; + gOutFileName = argv[1]; return true; } @@ -192,7 +192,7 @@ bool Cmd_ConvertCert(int argc, char * argv[]) res = InitOpenSSL(); VerifyTrueOrExit(res); - res = ReadCert(gInFileName, cert.get()); + res = ReadCert(gInFileNameOrStr, cert.get()); VerifyTrueOrExit(res); res = WriteCert(gOutFileName, cert.get(), gOutCertFormat); diff --git a/src/tools/chip-cert/Cmd_ConvertKey.cpp b/src/tools/chip-cert/Cmd_ConvertKey.cpp index 8f08c41d19ab9d..0df462b45663e3 100644 --- a/src/tools/chip-cert/Cmd_ConvertKey.cpp +++ b/src/tools/chip-cert/Cmd_ConvertKey.cpp @@ -110,21 +110,26 @@ OptionSet gCmdOptions = HelpOptions gHelpOptions( CMD_NAME, - "Usage: " CMD_NAME " [ ] \n", + "Usage: " CMD_NAME " [ ] \n", CHIP_VERSION_STRING "\n" COPYRIGHT_STRING, - "Convert a private key between CHIP and PEM/DER forms." + "Convert private/public key between CHIP and X.509 formats.\n" "\n" "ARGUMENTS\n" "\n" - " \n" + " \n" "\n" - " The input private key file name, or - to read from stdin. The\n" - " format of the input key is auto-detected and can be any\n" - " of: PEM, DER, CHIP base-64 or CHIP raw.\n" + " File or string containing private/public key to be converted.\n" + " The format of the input key is auto-detected and can be any of:\n" + " X.509 PEM, X.509 DER, X.509 HEX, CHIP base-64, CHIP raw TLV or CHIP HEX.\n" "\n" - " \n" + " Note: the private key formats include both private and public keys, while\n" + " the public key formats include only public keys. Therefore, conversion from any\n" + " private key format to public key is supported but conversion from public key\n" + " to private CANNOT be done.\n" "\n" - " The output private key file name, or - to write to stdout.\n" + " \n" + "\n" + " The output private key file name, or '-' to write to stdout.\n" "\n" ); @@ -136,7 +141,7 @@ OptionSet *gCmdOptionSets[] = }; // clang-ormat on -const char * gInFileName = nullptr; +const char * gInFileNameOrStr = nullptr; const char * gOutFileName = nullptr; KeyFormat gOutFormat = kKeyFormat_Chip_Base64; @@ -203,7 +208,7 @@ bool HandleNonOptionArgs(const char * progName, int argc, char * const argv[]) return false; } - gInFileName = argv[0]; + gInFileNameOrStr = argv[0]; gOutFileName = argv[1]; return true; @@ -228,7 +233,7 @@ bool Cmd_ConvertKey(int argc, char * argv[]) res = InitOpenSSL(); VerifyTrueOrExit(res); - res = ReadKey(gInFileName, key); + res = ReadKey(gInFileNameOrStr, key); VerifyTrueOrExit(res); if (IsPrivateKeyFormat(gOutFormat) && EC_KEY_get0_private_key(EVP_PKEY_get1_EC_KEY(key.get())) == nullptr) diff --git a/src/tools/chip-cert/Cmd_GenAttCert.cpp b/src/tools/chip-cert/Cmd_GenAttCert.cpp index 5425e5de6a6e7a..845344860c49cd 100644 --- a/src/tools/chip-cert/Cmd_GenAttCert.cpp +++ b/src/tools/chip-cert/Cmd_GenAttCert.cpp @@ -90,27 +90,29 @@ const char * const gCmdOptionHelp = " If not specified then by default the VID and PID fields are encoded using\n" " Matter specific OIDs.\n" "\n" - " -C, --ca-cert \n" + " -C, --ca-cert \n" "\n" - " File containing CA certificate to be used to sign the new certificate.\n" + " File or string containing CA certificate to be used to sign the new certificate.\n" "\n" - " -K, --ca-key \n" + " -K, --ca-key \n" "\n" - " File containing CA private key to be used to sign the new certificate.\n" + " File or string containing CA private key to be used to sign the new certificate.\n" "\n" - " -k, --key \n" + " -k, --key \n" "\n" - " File containing the public and private keys for the new certificate (in an X.509 PEM format).\n" + " File or string containing the public and private keys for the new certificate (in an X.509 PEM format).\n" " If not specified, a new key pair will be generated.\n" "\n" - " -o, --out \n" + " -o, --out \n" "\n" " File to contain the new certificate (in an X.509 PEM format).\n" + " If specified '-' then output is written to stdout.\n" "\n" - " -O, --out-key \n" + " -O, --out-key \n" "\n" " File to contain the public/private key for the new certificate (in an X.509 PEM format).\n" " This option must be specified if the --key option is not.\n" + " If specified '-' then output is written to stdout.\n" "\n" " -f, --valid-from --
[ :: ]\n" "\n" @@ -188,7 +190,7 @@ HelpOptions gHelpOptions( CMD_NAME, "Usage: " CMD_NAME " [ ]\n", CHIP_VERSION_STRING "\n" COPYRIGHT_STRING, - "Generate a CHIP certificate" + "Generate a CHIP Attestation certificate" ); OptionSet *gCmdOptionSets[] = @@ -199,17 +201,17 @@ OptionSet *gCmdOptionSets[] = }; // clang-format on -AttCertType gAttCertType = kAttCertType_NotSpecified; -const char * gSubjectCN = nullptr; -uint16_t gSubjectVID = VendorId::NotSpecified; -uint16_t gSubjectPID = 0; -bool gEncodeVIDandPIDasCN = false; -const char * gCACertFileName = nullptr; -const char * gCAKeyFileName = nullptr; -const char * gInKeyFileName = nullptr; -const char * gOutCertFileName = nullptr; -const char * gOutKeyFileName = nullptr; -uint32_t gValidDays = kCertValidDays_Undefined; +AttCertType gAttCertType = kAttCertType_NotSpecified; +const char * gSubjectCN = nullptr; +uint16_t gSubjectVID = VendorId::NotSpecified; +uint16_t gSubjectPID = 0; +bool gEncodeVIDandPIDasCN = false; +const char * gCACertFileNameOrStr = nullptr; +const char * gCAKeyFileNameOrStr = nullptr; +const char * gInKeyFileNameOrStr = nullptr; +const char * gOutCertFileName = nullptr; +const char * gOutKeyFileName = nullptr; +uint32_t gValidDays = kCertValidDays_Undefined; struct tm gValidFrom; CertStructConfig gCertConfig; @@ -261,13 +263,13 @@ bool HandleOption(const char * progName, OptionSet * optSet, int id, const char gEncodeVIDandPIDasCN = true; break; case 'k': - gInKeyFileName = arg; + gInKeyFileNameOrStr = arg; break; case 'C': - gCACertFileName = arg; + gCACertFileNameOrStr = arg; break; case 'K': - gCAKeyFileName = arg; + gCAKeyFileNameOrStr = arg; break; case 'o': gOutCertFileName = arg; @@ -474,19 +476,19 @@ bool Cmd_GenAttCert(int argc, char * argv[]) } } - if (gCACertFileName == nullptr && gAttCertType != kAttCertType_PAA) + if (gCACertFileNameOrStr == nullptr && gAttCertType != kAttCertType_PAA) { fprintf(stderr, "Please specify the CA certificate file name using the --ca-cert option.\n"); return false; } - if (gCACertFileName != nullptr && gAttCertType == kAttCertType_PAA) + if (gCACertFileNameOrStr != nullptr && gAttCertType == kAttCertType_PAA) { fprintf(stderr, "Please don't specify --ca-cert option for the self signed certificate. \n"); return false; } - if (gCACertFileName != nullptr && gCAKeyFileName == nullptr) + if (gCACertFileNameOrStr != nullptr && gCAKeyFileNameOrStr == nullptr) { fprintf(stderr, "Please specify the CA key file name using the --ca-key option.\n"); return false; @@ -498,7 +500,7 @@ bool Cmd_GenAttCert(int argc, char * argv[]) return false; } - if (gInKeyFileName == nullptr && gOutKeyFileName == nullptr) + if (gInKeyFileNameOrStr == nullptr && gOutKeyFileName == nullptr) { fprintf(stderr, "Please specify the file name for the new public/private key using the --out-key option.\n"); return false; @@ -531,9 +533,9 @@ bool Cmd_GenAttCert(int argc, char * argv[]) res = InitOpenSSL(); VerifyTrueOrExit(res); - if (gInKeyFileName != nullptr) + if (gInKeyFileNameOrStr != nullptr) { - res = ReadKey(gInKeyFileName, newKey); + res = ReadKey(gInKeyFileNameOrStr, newKey); VerifyTrueOrExit(res); } else @@ -561,10 +563,10 @@ bool Cmd_GenAttCert(int argc, char * argv[]) std::unique_ptr caCert(X509_new(), &X509_free); std::unique_ptr caKey(EVP_PKEY_new(), &EVP_PKEY_free); - res = ReadCert(gCACertFileName, caCert.get()); + res = ReadCert(gCACertFileNameOrStr, caCert.get()); VerifyTrueOrExit(res); - res = ReadKey(gCAKeyFileName, caKey, gCertConfig.IsErrorTestCaseEnabled()); + res = ReadKey(gCAKeyFileNameOrStr, caKey, gCertConfig.IsErrorTestCaseEnabled()); VerifyTrueOrExit(res); res = MakeAttCert(gAttCertType, gSubjectCN, gSubjectVID, gSubjectPID, gEncodeVIDandPIDasCN, caCert.get(), caKey.get(), diff --git a/src/tools/chip-cert/Cmd_GenCD.cpp b/src/tools/chip-cert/Cmd_GenCD.cpp index 07d2ac2b510c83..36f15f1a5a8324 100644 --- a/src/tools/chip-cert/Cmd_GenCD.cpp +++ b/src/tools/chip-cert/Cmd_GenCD.cpp @@ -72,19 +72,20 @@ OptionDef gCmdOptionDefs[] = }; const char * const gCmdOptionHelp = - " -K, --key \n" + " -K, --key \n" "\n" - " File containing private key to be used to sign the Certification Declaration.\n" + " File or string containing private key to be used to sign the Certification Declaration.\n" "\n" - " -C, --cert \n" + " -C, --cert \n" "\n" - " File containing certificate associated with the private key that is used\n" + " File or string containing certificate associated with the private key that is used\n" " to sign the Certification Declaration. The Subject Key Identifier in the\n" " certificate will be included in the signed Certification Declaration message.\n" "\n" - " -O, --out \n" + " -O, --out \n" "\n" " File to contain the signed Certification Declaration message.\n" + " If specified '-' then output is written to stdout.\n" "\n" " -f, --format-version \n" "\n" @@ -134,9 +135,9 @@ const char * const gCmdOptionHelp = "\n" " DAC Origin Product Id in hex.\n" "\n" - " -a, --authorized-paa-cert \n" + " -a, --authorized-paa-cert \n" "\n" - " File containing PAA certificate authorized to sign PAI which signs the DAC\n" + " File or string containing PAA certificate authorized to sign PAI which signs the DAC\n" " for a product carrying this CD. This field is optional and if present, only specified\n" " PAAs will be authorized to sign device's PAI for the lifetime of the generated CD.\n" " Maximum 10 authorized PAA certificates can be specified.\n" @@ -360,9 +361,9 @@ class CDStructConfig }; CertificationElements gCertElements; -const char * gCertFileName = nullptr; -const char * gKeyFileName = nullptr; -const char * gSignedCDFileName = nullptr; +const char * gCertFileNameOrStr = nullptr; +const char * gKeyFileNameOrStr = nullptr; +const char * gSignedCDFileName = nullptr; CDStructConfig gCDConfig; bool ExtractSKIDFromX509Cert(X509 * cert, ByteSpan & skid) @@ -380,10 +381,10 @@ bool HandleOption(const char * progName, OptionSet * optSet, int id, const char switch (id) { case 'C': - gCertFileName = arg; + gCertFileNameOrStr = arg; break; case 'K': - gKeyFileName = arg; + gKeyFileNameOrStr = arg; break; case 'O': gSignedCDFileName = arg; @@ -483,9 +484,9 @@ bool HandleOption(const char * progName, OptionSet * optSet, int id, const char return false; } { - const char * fileName = arg; + const char * fileNameOrStr = arg; std::unique_ptr cert(X509_new(), &X509_free); - VerifyOrReturnError(ReadCert(fileName, cert.get()), false); + VerifyOrReturnError(ReadCert(fileNameOrStr, cert.get()), false); ByteSpan skid; VerifyOrReturnError(ExtractSKIDFromX509Cert(cert.get(), skid), false); @@ -1098,15 +1099,15 @@ bool Cmd_GenCD(int argc, char * argv[]) "declaration.\n"); } - if (gKeyFileName == nullptr) + if (gKeyFileNameOrStr == nullptr) { - fprintf(stderr, "Please specify the signing private key file name using the --key option.\n"); + fprintf(stderr, "Please specify the signing private key using the --key option.\n"); return false; } - if (gCertFileName == nullptr) + if (gCertFileNameOrStr == nullptr) { - fprintf(stderr, "Please specify the signing certificate file name using the --cert option.\n"); + fprintf(stderr, "Please specify the signing certificate using the --cert option.\n"); return false; } @@ -1146,8 +1147,8 @@ bool Cmd_GenCD(int argc, char * argv[]) std::unique_ptr cert(X509_new(), &X509_free); std::unique_ptr key(EVP_PKEY_new(), &EVP_PKEY_free); - VerifyOrReturnError(ReadCert(gCertFileName, cert.get()), false); - VerifyOrReturnError(ReadKey(gKeyFileName, key), false); + VerifyOrReturnError(ReadCert(gCertFileNameOrStr, cert.get()), false); + VerifyOrReturnError(ReadKey(gKeyFileNameOrStr, key), false); // Extract the subject key id from the X509 certificate. ByteSpan signerKeyId; diff --git a/src/tools/chip-cert/Cmd_GenCert.cpp b/src/tools/chip-cert/Cmd_GenCert.cpp index 6a0a1c6784335d..ab0bc0c63587c6 100644 --- a/src/tools/chip-cert/Cmd_GenCert.cpp +++ b/src/tools/chip-cert/Cmd_GenCert.cpp @@ -110,27 +110,29 @@ const char * const gCmdOptionHelp = "\n" " NID_info_access extension to be added to the list of certificate extensions.\n" "\n" - " -C, --ca-cert \n" + " -C, --ca-cert \n" "\n" - " File containing CA certificate to be used to sign the new certificate.\n" + " File or string containing CA certificate to be used to sign the new certificate.\n" "\n" - " -K, --ca-key \n" + " -K, --ca-key \n" "\n" - " File containing CA private key to be used to sign the new certificate.\n" + " File or string containing CA private key to be used to sign the new certificate.\n" "\n" - " -k, --key \n" + " -k, --key \n" "\n" - " File containing the public and private keys for the new certificate.\n" + " File or string containing the public and private keys for the new certificate.\n" " If not specified, a new key pair will be generated.\n" "\n" - " -o, --out \n" + " -o, --out \n" "\n" " File to contain the new certificate.\n" + " If specified '-' then output is written to stdout.\n" "\n" - " -O, --out-key \n" + " -O, --out-key \n" "\n" " File to contain the public/private key for the new certificate.\n" " This option must be specified if the --key option is not.\n" + " If specified '-' then output is written to stdout.\n" "\n" " -F, --out-format \n" "\n" @@ -246,9 +248,9 @@ ToolChipDN gSubjectDN; uint8_t gCertType = kCertType_NotSpecified; int gPathLengthConstraint = kPathLength_NotSpecified; bool gSelfSign = false; -const char * gCACertFileName = nullptr; -const char * gCAKeyFileName = nullptr; -const char * gInKeyFileName = nullptr; +const char * gCACertFileNameOrStr = nullptr; +const char * gCAKeyFileNameOrStr = nullptr; +const char * gInKeyFileNameOrStr = nullptr; const char * gOutCertFileName = nullptr; const char * gOutKeyFileName = nullptr; CertFormat gOutCertFormat = kCertFormat_Default; @@ -426,13 +428,13 @@ bool HandleOption(const char * progName, OptionSet * optSet, int id, const char gFutureExtensionsCount++; break; case 'k': - gInKeyFileName = arg; + gInKeyFileNameOrStr = arg; break; case 'C': - gCACertFileName = arg; + gCACertFileNameOrStr = arg; break; case 'K': - gCAKeyFileName = arg; + gCAKeyFileNameOrStr = arg; break; case 'o': gOutCertFileName = arg; @@ -747,18 +749,18 @@ bool Cmd_GenCert(int argc, char * argv[]) } } - if (gCACertFileName == nullptr && !gSelfSign) + if (gCACertFileNameOrStr == nullptr && !gSelfSign) { - fprintf(stderr, "Please specify the CA certificate file name using the --ca-cert option.\n"); + fprintf(stderr, "Please specify the CA certificate using the --ca-cert option.\n"); ExitNow(res = false); } - else if (gCACertFileName != nullptr && gSelfSign) + else if (gCACertFileNameOrStr != nullptr && gSelfSign) { fprintf(stderr, "Please don't specify --ca-cert option for the self signed certificate. \n"); ExitNow(res = false); } - if (gCACertFileName != nullptr && gCAKeyFileName == nullptr) + if (gCACertFileNameOrStr != nullptr && gCAKeyFileNameOrStr == nullptr) { fprintf(stderr, "Please specify the CA key file name using the --ca-key option.\n"); ExitNow(res = false); @@ -770,7 +772,7 @@ bool Cmd_GenCert(int argc, char * argv[]) ExitNow(res = false); } - if (gInKeyFileName == nullptr && gOutKeyFileName == nullptr) + if (gInKeyFileNameOrStr == nullptr && gOutKeyFileName == nullptr) { fprintf(stderr, "Please specify the file name for the new public/private key using the --out-key option.\n"); ExitNow(res = false); @@ -810,9 +812,9 @@ bool Cmd_GenCert(int argc, char * argv[]) res = InitOpenSSL(); VerifyTrueOrExit(res); - if (gInKeyFileName != nullptr) + if (gInKeyFileNameOrStr != nullptr) { - res = ReadKey(gInKeyFileName, newKey); + res = ReadKey(gInKeyFileNameOrStr, newKey); VerifyTrueOrExit(res); } else @@ -836,10 +838,10 @@ bool Cmd_GenCert(int argc, char * argv[]) } else { - res = ReadCert(gCACertFileName, caCert.get()); + res = ReadCert(gCACertFileNameOrStr, caCert.get()); VerifyTrueOrExit(res); - res = ReadKey(gCAKeyFileName, caKey); + res = ReadKey(gCAKeyFileNameOrStr, caKey); VerifyTrueOrExit(res); caCertPtr = caCert.get(); diff --git a/src/tools/chip-cert/Cmd_PrintCert.cpp b/src/tools/chip-cert/Cmd_PrintCert.cpp index 2bef2ed868c2a2..5ccc9fb536b446 100644 --- a/src/tools/chip-cert/Cmd_PrintCert.cpp +++ b/src/tools/chip-cert/Cmd_PrintCert.cpp @@ -46,10 +46,10 @@ OptionDef gCmdOptionDefs[] = }; const char * const gCmdOptionHelp = - " -o, --out\n" + " -o, --out \n" "\n" " The output printed certificate file name. If not specified\n" - " or if specified - then output is written to stdout.\n" + " or if specified '-' then output is written to stdout.\n" "\n" ; @@ -63,15 +63,15 @@ OptionSet gCmdOptions = HelpOptions gHelpOptions( CMD_NAME, - "Usage: " CMD_NAME " [] \n", + "Usage: " CMD_NAME " [] \n", CHIP_VERSION_STRING "\n" COPYRIGHT_STRING, - "Print a CHIP certificate.\n" + "Print a CHIP operational certificate.\n" "\n" "ARGUMENTS\n" "\n" - " \n" + " \n" "\n" - " A file containing a CHIP certificate.\n" + " File or string containing a CHIP certificate.\n" "\n" ); @@ -83,8 +83,8 @@ OptionSet *gCmdOptionSets[] = }; // clang-format on -const char * gInFileName = nullptr; -const char * gOutFileName = "-"; +const char * gInFileNameOrStr = nullptr; +const char * gOutFileName = "-"; bool HandleOption(const char * progName, OptionSet * optSet, int id, const char * name, const char * arg) { @@ -115,7 +115,7 @@ bool HandleNonOptionArgs(const char * progName, int argc, char * const argv[]) return false; } - gInFileName = argv[0]; + gInFileNameOrStr = argv[0]; return true; } @@ -385,7 +385,7 @@ bool Cmd_PrintCert(int argc, char * argv[]) res = ParseArgs(CMD_NAME, argc, argv, gCmdOptionSets, HandleNonOptionArgs); VerifyTrueOrExit(res); - res = ReadCert(gInFileName, cert.get()); + res = ReadCert(gInFileNameOrStr, cert.get()); VerifyTrueOrExit(res); res = PrintCert(gOutFileName, cert.get()); diff --git a/src/tools/chip-cert/Cmd_ResignCert.cpp b/src/tools/chip-cert/Cmd_ResignCert.cpp index 53d33ad480f23b..053b5ff917d0b9 100644 --- a/src/tools/chip-cert/Cmd_ResignCert.cpp +++ b/src/tools/chip-cert/Cmd_ResignCert.cpp @@ -52,21 +52,22 @@ OptionDef gCmdOptionDefs[] = }; const char * const gCmdOptionHelp = - " -c, --cert \n" + " -c, --cert \n" "\n" - " File containing the certificate to be re-signed.\n" + " File or string containing the certificate to be re-signed.\n" "\n" - " -o, --out \n" + " -o, --out \n" "\n" " File to contain the re-signed certificate.\n" + " If specified '-' then output is written to stdout.\n" "\n" - " -C, --ca-cert \n" + " -C, --ca-cert \n" "\n" - " File containing CA certificate to be used to re-sign the certificate.\n" + " File or string containing CA certificate to be used to re-sign the certificate.\n" "\n" - " -K, --ca-key \n" + " -K, --ca-key \n" "\n" - " File containing CA private key to be used to re-sign the certificate.\n" + " File or string containing CA private key to be used to re-sign the certificate.\n" "\n" " -s, --self\n" "\n" @@ -97,27 +98,27 @@ OptionSet * gCmdOptionSets[] = }; // clang-format on -const char * gInCertFileName = nullptr; -const char * gOutCertFileName = nullptr; -const char * gCACertFileName = nullptr; -const char * gCAKeyFileName = nullptr; -bool gSelfSign = false; +const char * gInCertFileNameOrStr = nullptr; +const char * gOutCertFileName = nullptr; +const char * gCACertFileNameOrStr = nullptr; +const char * gCAKeyFileNameOrStr = nullptr; +bool gSelfSign = false; bool HandleOption(const char * progName, OptionSet * optSet, int id, const char * name, const char * arg) { switch (id) { case 'c': - gInCertFileName = arg; + gInCertFileNameOrStr = arg; break; case 'o': gOutCertFileName = arg; break; case 'C': - gCACertFileName = arg; + gCACertFileNameOrStr = arg; break; case 'K': - gCAKeyFileName = arg; + gCAKeyFileNameOrStr = arg; break; case 's': gSelfSign = true; @@ -148,7 +149,7 @@ bool Cmd_ResignCert(int argc, char * argv[]) res = ParseArgs(CMD_NAME, argc, argv, gCmdOptionSets); VerifyTrueOrExit(res); - if (gInCertFileName == nullptr) + if (gInCertFileNameOrStr == nullptr) { fprintf(stderr, "Please specify certificate to be resigned using --cert option.\n"); ExitNow(res = false); @@ -160,22 +161,22 @@ bool Cmd_ResignCert(int argc, char * argv[]) ExitNow(res = false); } - if (gCACertFileName == nullptr && !gSelfSign) + if (gCACertFileNameOrStr == nullptr && !gSelfSign) { fprintf(stderr, "Please specify a CA certificate to be used to sign the new certificate (using\n" "the --ca-cert option) or --self to generate a self-signed certificate.\n"); ExitNow(res = false); } - else if (gCACertFileName != nullptr && gSelfSign) + else if (gCACertFileNameOrStr != nullptr && gSelfSign) { fprintf(stderr, "Please specify only one of --ca-cert and --self.\n"); ExitNow(res = false); } - if (gCAKeyFileName == nullptr) + if (gCAKeyFileNameOrStr == nullptr) { - fprintf(stderr, "Please specify the CA key file name using the --ca-key option.\n"); + fprintf(stderr, "Please specify the CA key using the --ca-key option.\n"); ExitNow(res = false); } @@ -191,17 +192,17 @@ bool Cmd_ResignCert(int argc, char * argv[]) res = InitOpenSSL(); VerifyTrueOrExit(res); - res = ReadCert(gInCertFileName, cert.get(), inCertFmt); + res = ReadCert(gInCertFileNameOrStr, cert.get(), inCertFmt); VerifyTrueOrExit(res); - res = ReadKey(gCAKeyFileName, caKey); + res = ReadKey(gCAKeyFileNameOrStr, caKey); VerifyTrueOrExit(res); if (!gSelfSign) { std::unique_ptr caCert(X509_new(), &X509_free); - res = ReadCert(gCACertFileName, caCert.get()); + res = ReadCert(gCACertFileNameOrStr, caCert.get()); VerifyTrueOrExit(res); res = ResignCert(cert.get(), caCert.get(), caKey.get()); diff --git a/src/tools/chip-cert/Cmd_ValidateAttCert.cpp b/src/tools/chip-cert/Cmd_ValidateAttCert.cpp index 0d048b6898604c..15d33ca7bd2a5c 100644 --- a/src/tools/chip-cert/Cmd_ValidateAttCert.cpp +++ b/src/tools/chip-cert/Cmd_ValidateAttCert.cpp @@ -49,20 +49,20 @@ OptionDef gCmdOptionDefs[] = }; const char * const gCmdOptionHelp = - " -d, --dac \n" + " -d, --dac \n" "\n" - " A file containing Device Attestation Certificate (DAC) to be\n" - " validated. The DAC is provided in the DER encoded format.\n" + " File or string containing Device Attestation Certificate (DAC) to be validated.\n" + " The DAC format is auto-detected and can be any of: X.509 PEM, DER or HEX formats.\n" "\n" - " -i, --pai \n" + " -i, --pai \n" "\n" - " A file containing Product Attestation Intermediate (PAI) Certificate.\n" - " The PAI is provided in the DER encoded format.\n" + " File or string containing Product Attestation Intermediate (PAI) Certificate.\n" + " The PAI format is auto-detected and can be any of: X.509 PEM, DER or HEX formats.\n" "\n" - " -a, --paa \n" + " -a, --paa \n" "\n" - " A file containing trusted Product Attestation Authority (PAA) Certificate.\n" - " The PAA is provided in the DER encoded format.\n" + " File or string containing trusted Product Attestation Authority (PAA) Certificate.\n" + " The PAA format is auto-detected and can be any of: X.509 PEM, DER or HEX formats.\n" "\n" ; @@ -89,22 +89,22 @@ OptionSet * gCmdOptionSets[] = }; // clang-format on -const char * gDACFileName = nullptr; -const char * gPAIFileName = nullptr; -const char * gPAAFileName = nullptr; +const char * gDACFileNameOrStr = nullptr; +const char * gPAIFileNameOrStr = nullptr; +const char * gPAAFileNameOrStr = nullptr; bool HandleOption(const char * progName, OptionSet * optSet, int id, const char * name, const char * arg) { switch (id) { case 'd': - gDACFileName = arg; + gDACFileNameOrStr = arg; break; case 'i': - gPAIFileName = arg; + gPAIFileNameOrStr = arg; break; case 'a': - gPAAFileName = arg; + gPAAFileNameOrStr = arg; break; default: PrintArgError("%s: Unhandled option: %s\n", progName, name); @@ -171,37 +171,37 @@ bool Cmd_ValidateAttCert(int argc, char * argv[]) VerifyOrReturnError(ParseArgs(CMD_NAME, argc, argv, gCmdOptionSets), false); - if (gDACFileName == nullptr) + if (gDACFileNameOrStr == nullptr) { - fprintf(stderr, "Please specify the DAC certificate file name using the --dac option.\n"); + fprintf(stderr, "Please specify the DAC certificate using the --dac option.\n"); return false; } - if (gPAIFileName == nullptr) + if (gPAIFileNameOrStr == nullptr) { - fprintf(stderr, "Please specify the PAI certificate file name using the --pai option.\n"); + fprintf(stderr, "Please specify the PAI certificate using the --pai option.\n"); return false; } - if (gPAAFileName == nullptr) + if (gPAAFileNameOrStr == nullptr) { - fprintf(stderr, "Please specify the PAA certificate file name using the --paa option.\n"); + fprintf(stderr, "Please specify the PAA certificate using the --paa option.\n"); return false; } - if (!ReadCertDERRaw(gDACFileName, dac)) + if (!ReadCertDER(gDACFileNameOrStr, dac)) { - fprintf(stderr, "Unable to open DAC Certificate File: %s\n", gDACFileName); + fprintf(stderr, "Failed to read DAC Certificate: %s\n", gDACFileNameOrStr); return false; } - if (!ReadCertDERRaw(gPAIFileName, pai)) + if (!ReadCertDER(gPAIFileNameOrStr, pai)) { - fprintf(stderr, "Unable to open PAI Certificate File: %s\n", gPAIFileName); + fprintf(stderr, "Failed to read PAI Certificate: %s\n", gPAIFileNameOrStr); return false; } - if (!ReadCertDERRaw(gPAAFileName, paa)) + if (!ReadCertDER(gPAAFileNameOrStr, paa)) { - fprintf(stderr, "Unable to open PAA Certificate File: %s\n", gPAAFileName); + fprintf(stderr, "Failed to read PAA Certificate: %s\n", gPAAFileNameOrStr); return false; } diff --git a/src/tools/chip-cert/Cmd_ValidateCert.cpp b/src/tools/chip-cert/Cmd_ValidateCert.cpp index 3417f8d089ba27..7cc8a8289196bf 100644 --- a/src/tools/chip-cert/Cmd_ValidateCert.cpp +++ b/src/tools/chip-cert/Cmd_ValidateCert.cpp @@ -50,15 +50,15 @@ OptionDef gCmdOptionDefs[] = }; const char * const gCmdOptionHelp = - " -c, --cert \n" + " -c, --cert \n" "\n" - " A file containing an untrusted CHIP certificate to be used during\n" - " validation. Usually, it is Intermediate CA certificate.\n" + " File or string containing an untrusted CHIP certificate to be used during\n" + " validation. Usually, it is Intermediate CA certificate (ICAC).\n" "\n" - " -t, --trusted-cert \n" + " -t, --trusted-cert \n" "\n" - " A file containing a trusted CHIP certificate to be used during\n" - " validation. Usually, it is trust anchor root certificate.\n" + " File or string containing a trusted CHIP certificate to be used during\n" + " validation. Usually, it is trust anchor root certificate (RCAC).\n" "\n" ; @@ -72,15 +72,17 @@ OptionSet gCmdOptions = HelpOptions gHelpOptions( CMD_NAME, - "Usage: " CMD_NAME " [ ] \n", + "Usage: " CMD_NAME " [ ] \n", CHIP_VERSION_STRING "\n" COPYRIGHT_STRING, "Validate a chain of CHIP certificates.\n" "\n" "ARGUMENTS\n" "\n" - " \n" + " \n" "\n" - " A file containing the certificate to be validated.\n" + " File or string containing the certificate to be validated.\n" + " The formats of all input certificates are auto-detected and can be any of:\n" + " X.509 PEM, X.509 DER, X.509 HEX, CHIP base-64, CHIP raw TLV or CHIP HEX.\n" "\n" ); diff --git a/src/tools/chip-cert/KeyUtils.cpp b/src/tools/chip-cert/KeyUtils.cpp index 07cb7503701cb4..9cc7fc484cdc80 100644 --- a/src/tools/chip-cert/KeyUtils.cpp +++ b/src/tools/chip-cert/KeyUtils.cpp @@ -183,26 +183,45 @@ bool SerializeKeyPair(EVP_PKEY * key, P256SerializedKeypair & serializedKeypair) return true; } -bool ReadKey(const char * fileName, std::unique_ptr & key, bool ignorErrorIfUnsupportedCurve) +bool ReadKey(const char * fileNameOrStr, std::unique_ptr & key, bool ignorErrorIfUnsupportedCurve) { bool res = true; uint32_t keyDataLen = 0; KeyFormat keyFormat = kKeyFormat_Unknown; std::unique_ptr keyData; - res = ReadFileIntoMem(fileName, nullptr, keyDataLen); - VerifyTrueOrExit(res); + // If fileNameOrStr is a file name + if (access(fileNameOrStr, R_OK) == 0) + { + res = ReadFileIntoMem(fileNameOrStr, nullptr, keyDataLen); + VerifyTrueOrExit(res); - keyData = std::unique_ptr(new uint8_t[keyDataLen]); + keyData = std::unique_ptr(new uint8_t[keyDataLen]); - res = ReadFileIntoMem(fileName, keyData.get(), keyDataLen); - VerifyTrueOrExit(res); + res = ReadFileIntoMem(fileNameOrStr, keyData.get(), keyDataLen); + VerifyTrueOrExit(res); - keyFormat = DetectKeyFormat(keyData.get(), keyDataLen); - if (keyFormat == kKeyFormat_Unknown) + keyFormat = DetectKeyFormat(keyData.get(), keyDataLen); + if (keyFormat == kKeyFormat_Unknown) + { + fprintf(stderr, "Unrecognized Key Format in File: %s\n", fileNameOrStr); + return false; + } + } + // Otherwise, treat fileNameOrStr as a pointer to the key string + else { - fprintf(stderr, "Unrecognized Key Format in File: %s\n", fileName); - return false; + keyDataLen = static_cast(strlen(fileNameOrStr)); + + keyFormat = DetectKeyFormat(reinterpret_cast(fileNameOrStr), keyDataLen); + if (keyFormat == kKeyFormat_Unknown) + { + fprintf(stderr, "Unrecognized Key Format in Input Argument: %s\n", fileNameOrStr); + return false; + } + + keyData = std::unique_ptr(new uint8_t[keyDataLen]); + memcpy(keyData.get(), fileNameOrStr, keyDataLen); } if ((keyFormat == kKeyFormat_X509_Hex) || (keyFormat == kKeyFormat_Chip_Hex) || (keyFormat == kKeyFormat_Chip_Pubkey_Hex)) @@ -269,13 +288,6 @@ bool ReadKey(const char * fileName, std::unique_ptr(keyBIO.get()), keyDataLen, - reinterpret_cast(keyBIO.get()), keyDataLen); - VerifyOrReturnError(2 * len == keyDataLen, false); - } - if (d2i_PrivateKey_bio(keyBIO.get(), &tmpKeyPtr) == nullptr) { ReportOpenSSLErrorAndExit("d2i_PrivateKey_bio", res = false); @@ -426,8 +438,6 @@ bool WriteKey(const char * fileName, EVP_PKEY * key, KeyFormat keyFmt) ExitNow(res = false); } - printf("\r\n"); - exit: CloseFile(file); OPENSSL_free(derKey); diff --git a/src/tools/chip-cert/README.md b/src/tools/chip-cert/README.md index 6d7227b593baba..9c8ae1f8aaaf97 100644 --- a/src/tools/chip-cert/README.md +++ b/src/tools/chip-cert/README.md @@ -84,6 +84,18 @@ Note that in the last example the generated Node certificate and private key are stored in base-64 encoded CHIP native format and not in PEM format as in the previous examples. +The following example generates Node certificate, where the CA cert/key and the +Node key are provided as a command line arguments: + +``` +./chip-cert gen-cert --type n --subject-chip-id DEDEDEDE0000001E --subject-fab-id FAB000000000001D --valid-from "2020-10-15 14:23:43" --lifetime 7305 --ca-key 30770201010420C31A9FD24F91B28F3553C6DD0BC05DFB264FB19DE4A293457FF61CF08656F795A00A06082A8648CE3D030107A144034200046909160652E60035DEAFF5EE4DCED6E451BB171D39972874193CBDEA79E2C81198A8CA5151F0FC086556B8D63610E9DDB237DA1AFAC7378838897FA46A776BE5 --ca-cert FTABCEV4XDq64xZcJAIBNwMnFAEAAADKysrKGCYE7xcbJyYFbrW5TDcGJxMEAAAAysrKyicVHQAAAAAAsPoYJAcBJAgBMAlBBGkJFgZS5gA13q/17k3O1uRRuxcdOZcodBk8vep54sgRmKjKUVHw/AhlVrjWNhDp3bI32hr6xzeIOIl/pGp3a+U3CjUBKQEkAgAYJAJgMAQUTMntCbE2MN9jRhRZ0bmiX4LtcIYwBRTwPNuYHS2KwOmYp5Apx6b9P/ztyBgwC0D8Ieqk5XNVp4h3De3CAlndmNqPzT/yGQFkgjozuBz41efPVctoPODsGq6zKv/0RIO45obJNN8X1pGQrtv/9JVSGA== --key 04F1C53AFB1761A75FF07437018E5B76BC75F852904DC7C4607839A5D953140FFE253626FB737647F1043F61D91B5EC0D3B42A7A25FA209CAB7ACD1A76CA46ECD2 --out Chip-Node02-Cert.chip-b64 --out-format chip-b64 +``` + +Note that in the last example, to illustrate the fact that multiple key/cert +formats are supported, the CA private key is in the X509 Hex format, the CA +certificate is in the CHIP TLV base64 format and the Node public key is in the +CHIP TLV Hex format. + Now the 'chip-cert' tool can be used to validate generated Node certificate: ``` @@ -228,27 +240,29 @@ COMMAND OPTIONS NID_info_access extension to be added to the list of certificate extensions. - -C, --ca-cert + -C, --ca-cert - File containing CA certificate to be used to sign the new certificate. + File or string containing CA certificate to be used to sign the new certificate. - -K, --ca-key + -K, --ca-key - File containing CA private key to be used to sign the new certificate. + File or string containing CA private key to be used to sign the new certificate. - -k, --key + -k, --key - File containing the public and private keys for the new certificate. + File or string containing the public and private keys for the new certificate. If not specified, a new key pair will be generated. - -o, --out + -o, --out File to contain the new certificate. + If specified '-' then output is written to stdout. - -O, --out-key + -O, --out-key File to contain the public/private key for the new certificate. This option must be specified if the --key option is not. + If specified '-' then output is written to stdout. -F, --out-format @@ -256,10 +270,11 @@ COMMAND OPTIONS If not specified, the default base-64 encoded CHIP format is used. Supported format parametes are: x509-pem - X.509 PEM format - x509-der - X.509 DER format + x509-der - X.509 DER raw format + x509-hex - X.509 DER hex encoded format chip - raw CHIP TLV format - chip-hex - hex encoded CHIP TLV format chip-b64 - base-64 encoded CHIP TLV format (default) + chip-hex - hex encoded CHIP TLV format -V, --valid-from --
[ :: ] @@ -287,19 +302,19 @@ HELP OPTIONS $ ./out/debug/standalone/chip-cert convert-cert -h Usage: chip-cert convert-cert [ ] -Convert a certificate between CHIP and X509 forms. +Convert operational certificate between CHIP and X.509 formats. ARGUMENTS - + - The input certificate file name, or - to read from stdin. The - format of the input certificate is auto-detected and can be any - of: X.509 PEM, X.509 DER, CHIP base-64 or CHIP raw TLV. + File or string containing certificate to be converted. + The format of the input certificate is auto-detected and can be any of: + X.509 PEM, X.509 DER, X.509 HEX, CHIP base-64, CHIP raw TLV or CHIP HEX. - + - The output certificate file name, or - to write to stdout. + The output certificate file name, or '-' to write to stdout. COMMAND OPTIONS @@ -311,6 +326,10 @@ COMMAND OPTIONS Output certificate in X.509 DER format. + -X, --x509-hex + + Output certificate in X.509 DER hex encoded format. + -c, --chip Output certificate in raw CHIP TLV format. @@ -339,18 +358,24 @@ HELP OPTIONS $ ./out/debug/standalone/chip-cert convert-key -h Usage: chip-cert convert-key [ ] -Convert a private key between CHIP and PEM/DER forms. +Convert private/public key between CHIP and X.509 formats. + ARGUMENTS - + - The input private key file name, or - to read from stdin. The - format of the input key is auto-detected and can be any - of: PEM, DER, CHIP base-64 or CHIP raw. + File or string containing private/public key to be converted. + The format of the input key is auto-detected and can be any of: + X.509 PEM, X.509 DER, X.509 HEX, CHIP base-64, CHIP raw TLV or CHIP HEX. - + Note: the private key formats include both private and public keys, while + the public key formats include only public keys. Therefore, conversion from any + private key format to public key is supported but conversion from public key + to private CANNOT be done. - The output private key file name, or - to write to stdout. + + + The output private key file name, or '-' to write to stdout. COMMAND OPTIONS @@ -362,6 +387,14 @@ COMMAND OPTIONS Output the private key in SEC1/RFC-5915 DER format. + -x, --x509-hex + + Output the private key in SEC1/RFC-5915 DER hex encoded format. + + -P, --x509-pubkey-pem + + Output the public key in SEC1/RFC-5915 PEM format. + -c, --chip Output the private key in raw CHIP serialized format. @@ -374,6 +407,22 @@ COMMAND OPTIONS Output the private key in base-64 encoded CHIP serialized format. This is the default. + -e, --chip-hex + + Output the private key in hex encoded CHIP serialized format. + + -C, --chip-pubkey + + Output the raw public key. + + -B, --chip-pubkey-b64 + + Output the public key in base-64 encoded format. + + -E, --chip-pubkey-hex + + Output the public key in hex encoded format. + HELP OPTIONS -h, --help @@ -393,21 +442,22 @@ Resign a CHIP certificate using a new CA certificate/key. COMMAND OPTIONS - -c, --cert + -c, --cert - File containing the certificate to be re-signed. + File or string containing the certificate to be re-signed. - -o, --out + -o, --out File to contain the re-signed certificate. + If specified '-' then output is written to stdout. - -C, --ca-cert + -C, --ca-cert - File containing CA certificate to be used to re-sign the certificate. + File or string containing CA certificate to be used to re-sign the certificate. - -K, --ca-key + -K, --ca-key - File containing CA private key to be used to re-sign the certificate. + File or string containing CA private key to be used to re-sign the certificate. -s, --self @@ -432,21 +482,23 @@ Validate a chain of CHIP certificates. ARGUMENTS - + - A file containing the certificate to be validated. + File or string containing the certificate to be validated. + The formats of all input certificates are auto-detected and can be any of: + X.509 PEM, X.509 DER, X.509 HEX, CHIP base-64, CHIP raw TLV or CHIP HEX. COMMAND OPTIONS - -c, --cert + -c, --cert - A file containing an untrusted CHIP certificate to be used during - validation. Usually, it is Intermediate CA certificate. + File or string containing an untrusted CHIP certificate to be used during + validation. Usually, it is Intermediate CA certificate (ICAC). - -t, --trusted-cert + -t, --trusted-cert - A file containing a trusted CHIP certificate to be used during - validation. Usually, it is trust anchor root certificate. + File or string containing a trusted CHIP certificate to be used during + validation. Usually, it is trust anchor root certificate (RCAC). HELP OPTIONS @@ -463,20 +515,20 @@ HELP OPTIONS $ ./out/debug/standalone/chip-cert print-cert -h Usage: chip-cert print-cert [] -Print a CHIP certificate. +Print a CHIP operational certificate. ARGUMENTS - + - A file containing a CHIP certificate. + File or string containing a CHIP certificate. COMMAND OPTIONS - -o, --out + -o, --out The output printed certificate file name. If not specified - or if specified - then output is written to stdout. + or if specified '-' then output is written to stdout. HELP OPTIONS @@ -493,7 +545,7 @@ HELP OPTIONS $ ./out/debug/standalone/chip-cert gen-att-cert -h Usage: chip-cert gen-att-cert [ ] -Generate a CHIP certificate +Generate a CHIP Attestation certificate COMMAND OPTIONS @@ -522,27 +574,29 @@ COMMAND OPTIONS If not specified then by default the VID and PID fields are encoded using Matter specific OIDs. - -C, --ca-cert + -C, --ca-cert - File containing CA certificate to be used to sign the new certificate. + File or string containing CA certificate to be used to sign the new certificate. - -K, --ca-key + -K, --ca-key - File containing CA private key to be used to sign the new certificate. + File or string containing CA private key to be used to sign the new certificate. - -k, --key + -k, --key - File containing the public and private keys for the new certificate (in an X.509 PEM format). + File or string containing the public and private keys for the new certificate (in an X.509 PEM format). If not specified, a new key pair will be generated. - -o, --out + -o, --out File to contain the new certificate (in an X.509 PEM format). + If specified '-' then output is written to stdout. - -O, --out-key + -O, --out-key File to contain the public/private key for the new certificate (in an X.509 PEM format). This option must be specified if the --key option is not. + If specified '-' then output is written to stdout. -f, --valid-from --
[ :: ] @@ -574,20 +628,20 @@ Validate a chain of CHIP attestation certificates COMMAND OPTIONS - -d, --dac + -d, --dac - A file containing Device Attestation Certificate (DAC) to be - validated. The DAC is provided in the DER encoded format. + File or string containing Device Attestation Certificate (DAC) to be validated. + The DAC format is auto-detected and can be any of: X.509 PEM, DER or HEX formats. - -i, --pai + -i, --pai - A file containing Product Attestation Intermediate (PAI) Certificate. - The PAI is provided in the DER encoded format. + File or string containing Product Attestation Intermediate (PAI) Certificate. + The PAI format is auto-detected and can be any of: X.509 PEM, DER or HEX formats. - -a, --paa + -a, --paa - A file containing trusted Product Attestation Authority (PAA) Certificate. - The PAA is provided in the DER encoded format. + File or string containing trusted Product Attestation Authority (PAA) Certificate. + The PAA format is auto-detected and can be any of: X.509 PEM, DER or HEX formats. HELP OPTIONS @@ -608,19 +662,20 @@ Generate CD CMS Signed Message COMMAND OPTIONS - -K, --key + -K, --key - File containing private key to be used to sign the Certification Declaration. + File or string containing private key to be used to sign the Certification Declaration. - -C, --cert + -C, --cert - File containing certificate associated with the private key that is used + File or string containing certificate associated with the private key that is used to sign the Certification Declaration. The Subject Key Identifier in the certificate will be included in the signed Certification Declaration message. - -O, --out + -O, --out File to contain the signed Certification Declaration message. + If specified '-' then output is written to stdout. -f, --format-version diff --git a/src/tools/chip-cert/chip-cert.h b/src/tools/chip-cert/chip-cert.h index 39e32fbe580c8b..2075285c6c7d8f 100644 --- a/src/tools/chip-cert/chip-cert.h +++ b/src/tools/chip-cert/chip-cert.h @@ -400,10 +400,10 @@ extern bool Cmd_ValidateCert(int argc, char * argv[]); extern bool Cmd_PrintCert(int argc, char * argv[]); extern bool Cmd_GenAttCert(int argc, char * argv[]); -extern bool ReadCert(const char * fileName, X509 * cert); -extern bool ReadCert(const char * fileName, X509 * cert, CertFormat & origCertFmt); -extern bool ReadCertDERRaw(const char * fileName, chip::MutableByteSpan & cert); -extern bool LoadChipCert(const char * fileName, bool isTrused, chip::Credentials::ChipCertificateSet & certSet, +extern bool ReadCert(const char * fileNameOrStr, X509 * cert); +extern bool ReadCert(const char * fileNameOrStr, X509 * cert, CertFormat & origCertFmt); +extern bool ReadCertDER(const char * fileNameOrStr, chip::MutableByteSpan & cert); +extern bool LoadChipCert(const char * fileNameOrStr, bool isTrused, chip::Credentials::ChipCertificateSet & certSet, chip::MutableByteSpan & chipCert); extern bool WriteCert(const char * fileName, X509 * cert, CertFormat certFmt); @@ -423,7 +423,7 @@ extern bool MakeAttCert(AttCertType attCertType, const char * subjectCN, uint16_ X509 * newCert, EVP_PKEY * newKey, CertStructConfig & certConfig); extern bool GenerateKeyPair(EVP_PKEY * key); extern bool GenerateKeyPair_Secp256k1(EVP_PKEY * key); -extern bool ReadKey(const char * fileName, std::unique_ptr & key, +extern bool ReadKey(const char * fileNameOrStr, std::unique_ptr & key, bool ignorErrorIfUnsupportedCurve = false); extern bool WriteKey(const char * fileName, EVP_PKEY * key, KeyFormat keyFmt); extern bool SerializeKeyPair(EVP_PKEY * key, chip::Crypto::P256SerializedKeypair & serializedKeypair); diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 7dc0408dd1d8eb..e3cad481ffec12 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -1889,7 +1889,7 @@ class TestAccessControlClusterSuite : public TestCommand class Test_TC_ACL_1_1Suite : public TestCommand { public: - Test_TC_ACL_1_1Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_ACL_1_1", 6, credsIssuerConfig) + Test_TC_ACL_1_1Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_ACL_1_1", 7, credsIssuerConfig) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("cluster", &mCluster); @@ -1951,7 +1951,6 @@ class Test_TC_ACL_1_1Suite : public TestCommand VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); VerifyOrReturn(CheckConstraintType("value", "list", "list")); VerifyOrReturn(CheckConstraintContains("value", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("value", value, 1UL)); VerifyOrReturn(CheckConstraintContains("value", value, 2UL)); VerifyOrReturn(CheckConstraintContains("value", value, 3UL)); VerifyOrReturn(CheckConstraintContains("value", value, 4UL)); @@ -1963,6 +1962,15 @@ class Test_TC_ACL_1_1Suite : public TestCommand } break; case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::DecodableList value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckConstraintType("value", "list", "list")); + VerifyOrReturn(CheckConstraintContains("value", value, 1UL)); + } + break; + case 5: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::DataModel::DecodableList value; @@ -1974,7 +1982,7 @@ class Test_TC_ACL_1_1Suite : public TestCommand VerifyOrReturn(CheckConstraintType("value", "list", "list")); } break; - case 5: + case 6: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::DataModel::DecodableList value; @@ -2024,12 +2032,18 @@ class Test_TC_ACL_1_1Suite : public TestCommand true, chip::NullOptional); } case 4: { - LogStep(4, "TH reads AcceptedCommandList attribute from DUT"); + LogStep(4, "TH reads optional attribute (Extension) in AttributeList"); + VerifyOrDo(!ShouldSkip("ACL.S.A0001"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), AccessControl::Id, AccessControl::Attributes::AttributeList::Id, + true, chip::NullOptional); + } + case 5: { + LogStep(5, "TH reads AcceptedCommandList attribute from DUT"); return ReadAttribute(kIdentityAlpha, GetEndpoint(0), AccessControl::Id, AccessControl::Attributes::AcceptedCommandList::Id, true, chip::NullOptional); } - case 5: { - LogStep(5, "TH reads GeneratedCommandList attribute from DUT"); + case 6: { + LogStep(6, "TH reads GeneratedCommandList attribute from DUT"); return ReadAttribute(kIdentityAlpha, GetEndpoint(0), AccessControl::Id, AccessControl::Attributes::GeneratedCommandList::Id, true, chip::NullOptional); } @@ -18756,7 +18770,6 @@ class Test_TC_LVL_3_1Suite : public TestCommand } case 13: { LogStep(13, "Wait 10000ms"); - VerifyOrDo(!ShouldSkip("LVL.S.M.VarRate"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; value.ms = 10000UL; @@ -18771,7 +18784,6 @@ class Test_TC_LVL_3_1Suite : public TestCommand } case 15: { LogStep(15, "Wait 10000ms"); - VerifyOrDo(!ShouldSkip("LVL.S.M.VarRate"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; value.ms = 10000UL; @@ -18786,7 +18798,6 @@ class Test_TC_LVL_3_1Suite : public TestCommand } case 17: { LogStep(17, "Wait 10000ms"); - VerifyOrDo(!ShouldSkip("LVL.S.M.VarRate"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; value.ms = 10000UL; @@ -18801,7 +18812,6 @@ class Test_TC_LVL_3_1Suite : public TestCommand } case 19: { LogStep(19, "Wait 5000ms"); - VerifyOrDo(!ShouldSkip("LVL.S.M.VarRate"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; value.ms = 5000UL; @@ -19765,7 +19775,6 @@ class Test_TC_LVL_5_1Suite : public TestCommand } case 12: { LogStep(12, "Wait 10s"); - VerifyOrDo(!ShouldSkip("LVL.S.M.VarRate"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; value.ms = 10000UL; @@ -19780,7 +19789,6 @@ class Test_TC_LVL_5_1Suite : public TestCommand } case 14: { LogStep(14, "Wait 10s"); - VerifyOrDo(!ShouldSkip("LVL.S.M.VarRate"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; value.ms = 10000UL; @@ -19795,7 +19803,6 @@ class Test_TC_LVL_5_1Suite : public TestCommand } case 16: { LogStep(16, "Wait 10s"); - VerifyOrDo(!ShouldSkip("LVL.S.M.VarRate"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; value.ms = 10000UL; @@ -19810,7 +19817,6 @@ class Test_TC_LVL_5_1Suite : public TestCommand } case 18: { LogStep(18, "Wait 5000ms"); - VerifyOrDo(!ShouldSkip("LVL.S.M.VarRate"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; value.ms = 5000UL; @@ -61366,7 +61372,7 @@ class Test_TC_DGSW_2_3Suite : public TestCommand } case 2: { LogStep(2, "Reads a list of ThreadMetrics struct attribute from DUT."); - VerifyOrDo(!ShouldSkip("DGSW.S.A0001"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + VerifyOrDo(!ShouldSkip("DGSW.S.A0000"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); return ReadAttribute(kIdentityAlpha, GetEndpoint(0), SoftwareDiagnostics::Id, SoftwareDiagnostics::Attributes::ThreadMetrics::Id, true, chip::NullOptional); } @@ -68559,7 +68565,7 @@ class Test_TC_DRLK_1_1Suite : public TestCommand class Test_TC_DRLK_2_2Suite : public TestCommand { public: - Test_TC_DRLK_2_2Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DRLK_2_2", 28, credsIssuerConfig) + Test_TC_DRLK_2_2Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DRLK_2_2", 26, credsIssuerConfig) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("cluster", &mCluster); @@ -68694,40 +68700,40 @@ class Test_TC_DRLK_2_2Suite : public TestCommand break; case 16: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + uint8_t value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + } break; case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 18: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); break; case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + uint8_t value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + } break; case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); break; case 24: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; break; case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; default: @@ -68769,7 +68775,7 @@ class Test_TC_DRLK_2_2Suite : public TestCommand value.credentialRule.SetNonNull(); value.credentialRule.Value() = static_cast(0); return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::SetUser::Id, value, - chip::Optional(10000), chip::NullOptional + chip::Optional(1000), chip::NullOptional ); } @@ -68798,7 +68804,7 @@ class Test_TC_DRLK_2_2Suite : public TestCommand value.userStatus.SetNull(); value.userType.SetNull(); return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::SetCredential::Id, value, - chip::Optional(10000), chip::NullOptional + chip::Optional(1000), chip::NullOptional ); } @@ -68849,7 +68855,7 @@ class Test_TC_DRLK_2_2Suite : public TestCommand ListFreer listFreer; chip::app::Clusters::DoorLock::Commands::LockDoor::Type value; return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::LockDoor::Id, value, - chip::Optional(10000), chip::NullOptional + chip::Optional(1000), chip::NullOptional ); } @@ -68861,12 +68867,12 @@ class Test_TC_DRLK_2_2Suite : public TestCommand value.pinCode.Emplace(); value.pinCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::LockDoor::Id, value, - chip::Optional(10000), chip::NullOptional + chip::Optional(1000), chip::NullOptional ); } case 10: { - LogStep(10, "TH writes the RequirePINforRemoteOperation attribute value as True on the DUT"); + LogStep(10, "TH writes the RequirePINforRemoteOperation attribute value as False on the DUT"); VerifyOrDo(!ShouldSkip("DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; bool value; @@ -68877,7 +68883,7 @@ class Test_TC_DRLK_2_2Suite : public TestCommand } case 11: { LogStep(11, - "TH writes the RequirePINforRemoteOperation attribute value as True on the DUT and Verify DUT responds with " + "TH writes the RequirePINforRemoteOperation attribute value as False on the DUT and Verify DUT responds with " "UNSUPPORTED_WRITE"); VerifyOrDo(!ShouldSkip("!DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; @@ -68901,7 +68907,7 @@ class Test_TC_DRLK_2_2Suite : public TestCommand value.pinCode.Emplace(); value.pinCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::LockDoor::Id, value, - chip::Optional(10000), chip::NullOptional + chip::Optional(1000), chip::NullOptional ); } @@ -68913,7 +68919,7 @@ class Test_TC_DRLK_2_2Suite : public TestCommand value.pinCode.Emplace(); value.pinCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("645321garbage: not in length on purpose"), 6); return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::LockDoor::Id, value, - chip::Optional(10000), chip::NullOptional + chip::Optional(1000), chip::NullOptional ); } @@ -68923,13 +68929,44 @@ class Test_TC_DRLK_2_2Suite : public TestCommand ListFreer listFreer; chip::app::Clusters::DoorLock::Commands::LockDoor::Type value; return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::LockDoor::Id, value, - chip::Optional(10000), chip::NullOptional + chip::Optional(1000), chip::NullOptional ); } case 16: { - LogStep(16, - "TH writes WrongCodeEntryLimit attribute value as 3 on the DUT and Verify that the DUT sends Success response"); + LogStep(16, "TH reads the WrongCodeEntryLimit attribute from the DUT"); + VerifyOrDo(!ShouldSkip("DRLK.S.A0030"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::WrongCodeEntryLimit::Id, true, + chip::NullOptional); + } + case 17: { + LogStep(17, "TH sends the unlock Door command to the DUT with invalid PINCode"); + VerifyOrDo(!ShouldSkip("DRLK.S.A0030"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + ListFreer listFreer; + chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type value; + value.pinCode.Emplace(); + value.pinCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("1234568garbage: not in length on purpose"), 7); + return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnlockDoor::Id, value, + chip::Optional(1000), chip::NullOptional + + ); + } + case 18: { + LogStep(18, "TH sends the unlock Door command to the DUT with valid PINCode"); + VerifyOrDo(!ShouldSkip("DRLK.S.A0030"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + ListFreer listFreer; + chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type value; + value.pinCode.Emplace(); + value.pinCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); + return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnlockDoor::Id, value, + chip::Optional(1000), chip::NullOptional + + ); + } + case 19: { + LogStep(19, + "TH writes WrongCodeEntryLimit attribute value as between 1 and 255 on the DUT and Verify that the DUT sends " + "Success response"); VerifyOrDo(!ShouldSkip("DRLK.S.A0030"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; uint8_t value; @@ -68937,9 +68974,10 @@ class Test_TC_DRLK_2_2Suite : public TestCommand return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::WrongCodeEntryLimit::Id, value, chip::NullOptional, chip::NullOptional); } - case 17: { - LogStep(17, - "TH writes WrongCodeEntryLimit attribute value as 3 on the DUT and verify DUT responds with UNSUPPORTED_WRITE"); + case 20: { + LogStep(20, + "TH writes WrongCodeEntryLimit attribute value as between 1 and 255 on the DUT and verify DUT responds with " + "UNSUPPORTED_WRITE"); VerifyOrDo(!ShouldSkip("!DRLK.S.A0030"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; uint8_t value; @@ -68947,10 +68985,16 @@ class Test_TC_DRLK_2_2Suite : public TestCommand return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::WrongCodeEntryLimit::Id, value, chip::NullOptional, chip::NullOptional); } - case 18: { - LogStep(18, - "TH writes UserCodeTemporaryDisableTime attribute value as 15 seconds on the DUT and Verify that the DUT send " - "the Success response"); + case 21: { + LogStep(21, "TH reads the UserCodeTemporaryDisableTime attribute from the DUT"); + VerifyOrDo(!ShouldSkip("DRLK.S.A0031"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, + DoorLock::Attributes::UserCodeTemporaryDisableTime::Id, true, chip::NullOptional); + } + case 22: { + LogStep(22, + "TH writes UserCodeTemporaryDisableTime attribute value as between 1 and 255 on the DUT and Verify that the " + "DUT sends Success response"); VerifyOrDo(!ShouldSkip("DRLK.S.A0031"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; uint8_t value; @@ -68959,10 +69003,10 @@ class Test_TC_DRLK_2_2Suite : public TestCommand DoorLock::Attributes::UserCodeTemporaryDisableTime::Id, value, chip::NullOptional, chip::NullOptional); } - case 19: { - LogStep(19, - "TH writes UserCodeTemporaryDisableTime attribute value as 15 seconds on the DUT and Verify DUT responds with " - "UNSUPPORTED_WRITE"); + case 23: { + LogStep(23, + "TH writes UserCodeTemporaryDisableTime attribute value as between 1 and 255 on the DUT and verify DUT " + "responds with UNSUPPORTED_WRITE"); VerifyOrDo(!ShouldSkip("!DRLK.S.A0031"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; uint8_t value; @@ -68971,90 +69015,18 @@ class Test_TC_DRLK_2_2Suite : public TestCommand DoorLock::Attributes::UserCodeTemporaryDisableTime::Id, value, chip::NullOptional, chip::NullOptional); } - case 20: { - LogStep(20, "TH sends Lock Door Command to the DUT with invalid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C00.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::LockDoor::Type value; - value.pinCode.Emplace(); - value.pinCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123458garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::LockDoor::Id, value, - chip::Optional(10000), chip::NullOptional - - ); - } - case 21: { - LogStep(21, "TH sends Lock Door Command to the DUT with invalid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C00.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::LockDoor::Type value; - value.pinCode.Emplace(); - value.pinCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123458garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::LockDoor::Id, value, - chip::Optional(10000), chip::NullOptional - - ); - } - case 22: { - LogStep(22, "TH sends Lock Door Command to the DUT with invalid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C00.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::LockDoor::Type value; - value.pinCode.Emplace(); - value.pinCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123458garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::LockDoor::Id, value, - chip::Optional(10000), chip::NullOptional - - ); - } - case 23: { - LogStep(23, "TH sends Lock Door Command to the DUT with invalid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C00.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::LockDoor::Type value; - value.pinCode.Emplace(); - value.pinCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123458garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::LockDoor::Id, value, - chip::Optional(10000), chip::NullOptional - - ); - } case 24: { - LogStep(24, - "TH reads UserCodeTemporaryDisableTime attribute from DUT and After sending 3 failure responses verify that " - "UserCodeTemporaryDisableTime attribute is triggered"); - VerifyOrDo(!ShouldSkip("PICS_USER_PROMPT && DRLK.S.A0031"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt(kIdentityAlpha, value); - } - case 25: { - LogStep( - 25, - "TH sends Lock Command to the DUT with valid PINCode before UserCodeTemporaryDisableTime attribute time expires"); - VerifyOrDo(!ShouldSkip("PICS_USER_PROMPT && DRLK.S.C00.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt(kIdentityAlpha, value); - } - case 26: { - LogStep(26, "Clean the created user"); + LogStep(24, "Clean the created user"); ListFreer listFreer; chip::app::Clusters::DoorLock::Commands::ClearUser::Type value; value.userIndex = 1U; return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::ClearUser::Id, value, - chip::Optional(10000), chip::NullOptional + chip::Optional(1000), chip::NullOptional ); } - case 27: { - LogStep(27, "Cleanup the created credential"); + case 25: { + LogStep(25, "Cleanup the created credential"); VerifyOrDo(!ShouldSkip("DRLK.S.C26.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); ListFreer listFreer; chip::app::Clusters::DoorLock::Commands::ClearCredential::Type value; @@ -69064,7 +69036,7 @@ class Test_TC_DRLK_2_2Suite : public TestCommand value.credential.Value().credentialIndex = 1U; return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::ClearCredential::Id, value, - chip::Optional(10000), chip::NullOptional + chip::Optional(1000), chip::NullOptional ); } diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index 0cd184a35f8a40..497e858bbc1414 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -2161,12 +2161,20 @@ class Test_TC_ACL_1_1 : public TestCommandBridge { err = TestThReadsAttributeListAttributeFromDut_3(); break; case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : TH reads AcceptedCommandList attribute from DUT\n"); - err = TestThReadsAcceptedCommandListAttributeFromDut_4(); + ChipLogProgress(chipTool, " ***** Test Step 4 : TH reads optional attribute (Extension) in AttributeList\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestThReadsOptionalAttributeExtensionInAttributeList_4(); break; case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : TH reads GeneratedCommandList attribute from DUT\n"); - err = TestThReadsGeneratedCommandListAttributeFromDut_5(); + ChipLogProgress(chipTool, " ***** Test Step 5 : TH reads AcceptedCommandList attribute from DUT\n"); + err = TestThReadsAcceptedCommandListAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : TH reads GeneratedCommandList attribute from DUT\n"); + err = TestThReadsGeneratedCommandListAttributeFromDut_6(); break; } @@ -2197,6 +2205,9 @@ class Test_TC_ACL_1_1 : public TestCommandBridge { case 5: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; } // Go on to the next test. @@ -2210,7 +2221,7 @@ class Test_TC_ACL_1_1 : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; + const uint16_t mTestCount = 7; chip::Optional mNodeId; chip::Optional mCluster; @@ -2289,7 +2300,6 @@ class Test_TC_ACL_1_1 : public TestCommandBridge { VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); @@ -2305,7 +2315,29 @@ class Test_TC_ACL_1_1 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThReadsAcceptedCommandListAttributeFromDut_4() + CHIP_ERROR TestThReadsOptionalAttributeExtensionInAttributeList_4() + { + MTRBaseDevice * device = GetDevice("alpha"); + MTRBaseClusterAccessControl * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device + endpoint:0 + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads optional attribute (Extension) in AttributeList Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThReadsAcceptedCommandListAttributeFromDut_5() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterAccessControl * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device @@ -2330,7 +2362,7 @@ class Test_TC_ACL_1_1 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThReadsGeneratedCommandListAttributeFromDut_5() + CHIP_ERROR TestThReadsGeneratedCommandListAttributeFromDut_6() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterAccessControl * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device @@ -26613,10 +26645,6 @@ class Test_TC_LVL_3_1 : public TestCommandBridge { break; case 13: ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 10000ms\n"); - if (ShouldSkip("LVL.S.M.VarRate")) { - NextTest(); - return; - } err = TestWait10000ms_13(); break; case 14: @@ -26629,10 +26657,6 @@ class Test_TC_LVL_3_1 : public TestCommandBridge { break; case 15: ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 10000ms\n"); - if (ShouldSkip("LVL.S.M.VarRate")) { - NextTest(); - return; - } err = TestWait10000ms_15(); break; case 16: @@ -26645,10 +26669,6 @@ class Test_TC_LVL_3_1 : public TestCommandBridge { break; case 17: ChipLogProgress(chipTool, " ***** Test Step 17 : Wait 10000ms\n"); - if (ShouldSkip("LVL.S.M.VarRate")) { - NextTest(); - return; - } err = TestWait10000ms_17(); break; case 18: @@ -26661,10 +26681,6 @@ class Test_TC_LVL_3_1 : public TestCommandBridge { break; case 19: ChipLogProgress(chipTool, " ***** Test Step 19 : Wait 5000ms\n"); - if (ShouldSkip("LVL.S.M.VarRate")) { - NextTest(); - return; - } err = TestWait5000ms_19(); break; case 20: @@ -29008,10 +29024,6 @@ class Test_TC_LVL_5_1 : public TestCommandBridge { break; case 12: ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 10s\n"); - if (ShouldSkip("LVL.S.M.VarRate")) { - NextTest(); - return; - } err = TestWait10s_12(); break; case 13: @@ -29024,10 +29036,6 @@ class Test_TC_LVL_5_1 : public TestCommandBridge { break; case 14: ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 10s\n"); - if (ShouldSkip("LVL.S.M.VarRate")) { - NextTest(); - return; - } err = TestWait10s_14(); break; case 15: @@ -29040,10 +29048,6 @@ class Test_TC_LVL_5_1 : public TestCommandBridge { break; case 16: ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 10s\n"); - if (ShouldSkip("LVL.S.M.VarRate")) { - NextTest(); - return; - } err = TestWait10s_16(); break; case 17: @@ -29056,10 +29060,6 @@ class Test_TC_LVL_5_1 : public TestCommandBridge { break; case 18: ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 5000ms\n"); - if (ShouldSkip("LVL.S.M.VarRate")) { - NextTest(); - return; - } err = TestWait5000ms_18(); break; case 19: @@ -103733,7 +103733,7 @@ class Test_TC_DGSW_2_3 : public TestCommandBridge { break; case 2: ChipLogProgress(chipTool, " ***** Test Step 2 : Reads a list of ThreadMetrics struct attribute from DUT.\n"); - if (ShouldSkip("DGSW.S.A0001")) { + if (ShouldSkip("DGSW.S.A0000")) { NextTest(); return; } @@ -118591,22 +118591,22 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { break; case 10: ChipLogProgress( - chipTool, " ***** Test Step 10 : TH writes the RequirePINforRemoteOperation attribute value as True on the DUT\n"); + chipTool, " ***** Test Step 10 : TH writes the RequirePINforRemoteOperation attribute value as False on the DUT\n"); if (ShouldSkip("DRLK.S.A0033")) { NextTest(); return; } - err = TestThWritesTheRequirePINforRemoteOperationAttributeValueAsTrueOnTheDut_10(); + err = TestThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDut_10(); break; case 11: ChipLogProgress(chipTool, - " ***** Test Step 11 : TH writes the RequirePINforRemoteOperation attribute value as True on the DUT and Verify " + " ***** Test Step 11 : TH writes the RequirePINforRemoteOperation attribute value as False on the DUT and Verify " "DUT responds with UNSUPPORTED_WRITE\n"); if (ShouldSkip("!DRLK.S.A0033")) { NextTest(); return; } - err = TestThWritesTheRequirePINforRemoteOperationAttributeValueAsTrueOnTheDutAndVerifyDutRespondsWithUnsupportedWrite_11(); + err = TestThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDutAndVerifyDutRespondsWithUnsupportedWrite_11(); break; case 12: ChipLogProgress(chipTool, " ***** Test Step 12 : TH reads the RequirePINforRemoteOperation attribute from the DUT\n"); @@ -118641,108 +118641,88 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { err = TestThSendsLockDoorCommandToTheDutWithoutAnyArgumentPINCode_15(); break; case 16: - ChipLogProgress(chipTool, - " ***** Test Step 16 : TH writes WrongCodeEntryLimit attribute value as 3 on the DUT and Verify that the DUT sends " - "Success response\n"); + ChipLogProgress(chipTool, " ***** Test Step 16 : TH reads the WrongCodeEntryLimit attribute from the DUT\n"); if (ShouldSkip("DRLK.S.A0030")) { NextTest(); return; } - err = TestThWritesWrongCodeEntryLimitAttributeValueAs3OnTheDutAndVerifyThatTheDutSendsSuccessResponse_16(); + err = TestThReadsTheWrongCodeEntryLimitAttributeFromTheDut_16(); break; case 17: - ChipLogProgress(chipTool, - " ***** Test Step 17 : TH writes WrongCodeEntryLimit attribute value as 3 on the DUT and verify DUT responds with " - "UNSUPPORTED_WRITE\n"); - if (ShouldSkip("!DRLK.S.A0030")) { + ChipLogProgress(chipTool, " ***** Test Step 17 : TH sends the unlock Door command to the DUT with invalid PINCode\n"); + if (ShouldSkip("DRLK.S.A0030")) { NextTest(); return; } - err = TestThWritesWrongCodeEntryLimitAttributeValueAs3OnTheDutAndVerifyDutRespondsWithUnsupportedWrite_17(); + err = TestThSendsTheUnlockDoorCommandToTheDutWithInvalidPINCode_17(); break; case 18: - ChipLogProgress(chipTool, - " ***** Test Step 18 : TH writes UserCodeTemporaryDisableTime attribute value as 15 seconds on the DUT and Verify " - "that the DUT send the Success response\n"); - if (ShouldSkip("DRLK.S.A0031")) { + ChipLogProgress(chipTool, " ***** Test Step 18 : TH sends the unlock Door command to the DUT with valid PINCode\n"); + if (ShouldSkip("DRLK.S.A0030")) { NextTest(); return; } - err = TestThWritesUserCodeTemporaryDisableTimeAttributeValueAs15SecondsOnTheDutAndVerifyThatTheDutSendTheSuccessResponse_18(); + err = TestThSendsTheUnlockDoorCommandToTheDutWithValidPINCode_18(); break; case 19: ChipLogProgress(chipTool, - " ***** Test Step 19 : TH writes UserCodeTemporaryDisableTime attribute value as 15 seconds on the DUT and Verify " - "DUT responds with UNSUPPORTED_WRITE\n"); - if (ShouldSkip("!DRLK.S.A0031")) { + " ***** Test Step 19 : TH writes WrongCodeEntryLimit attribute value as between 1 and 255 on the DUT and Verify " + "that the DUT sends Success response\n"); + if (ShouldSkip("DRLK.S.A0030")) { NextTest(); return; } - err = TestThWritesUserCodeTemporaryDisableTimeAttributeValueAs15SecondsOnTheDutAndVerifyDutRespondsWithUnsupportedWrite_19(); + err = TestThWritesWrongCodeEntryLimitAttributeValueAsBetween1And255OnTheDutAndVerifyThatTheDutSendsSuccessResponse_19(); break; case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : TH sends Lock Door Command to the DUT with invalid PINCode\n"); - if (ShouldSkip("DRLK.S.C00.Rsp")) { + ChipLogProgress(chipTool, + " ***** Test Step 20 : TH writes WrongCodeEntryLimit attribute value as between 1 and 255 on the DUT and verify " + "DUT responds with UNSUPPORTED_WRITE\n"); + if (ShouldSkip("!DRLK.S.A0030")) { NextTest(); return; } - err = TestThSendsLockDoorCommandToTheDutWithInvalidPINCode_20(); + err = TestThWritesWrongCodeEntryLimitAttributeValueAsBetween1And255OnTheDutAndVerifyDutRespondsWithUnsupportedWrite_20(); break; case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : TH sends Lock Door Command to the DUT with invalid PINCode\n"); - if (ShouldSkip("DRLK.S.C00.Rsp")) { + ChipLogProgress(chipTool, " ***** Test Step 21 : TH reads the UserCodeTemporaryDisableTime attribute from the DUT\n"); + if (ShouldSkip("DRLK.S.A0031")) { NextTest(); return; } - err = TestThSendsLockDoorCommandToTheDutWithInvalidPINCode_21(); + err = TestThReadsTheUserCodeTemporaryDisableTimeAttributeFromTheDut_21(); break; case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : TH sends Lock Door Command to the DUT with invalid PINCode\n"); - if (ShouldSkip("DRLK.S.C00.Rsp")) { + ChipLogProgress(chipTool, + " ***** Test Step 22 : TH writes UserCodeTemporaryDisableTime attribute value as between 1 and 255 on the DUT and " + "Verify that the DUT sends Success response\n"); + if (ShouldSkip("DRLK.S.A0031")) { NextTest(); return; } - err = TestThSendsLockDoorCommandToTheDutWithInvalidPINCode_22(); + err = TestThWritesUserCodeTemporaryDisableTimeAttributeValueAsBetween1And255OnTheDutAndVerifyThatTheDutSendsSuccessResponse_22(); break; case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : TH sends Lock Door Command to the DUT with invalid PINCode\n"); - if (ShouldSkip("DRLK.S.C00.Rsp")) { + ChipLogProgress(chipTool, + " ***** Test Step 23 : TH writes UserCodeTemporaryDisableTime attribute value as between 1 and 255 on the DUT and " + "verify DUT responds with UNSUPPORTED_WRITE\n"); + if (ShouldSkip("!DRLK.S.A0031")) { NextTest(); return; } - err = TestThSendsLockDoorCommandToTheDutWithInvalidPINCode_23(); + err = TestThWritesUserCodeTemporaryDisableTimeAttributeValueAsBetween1And255OnTheDutAndVerifyDutRespondsWithUnsupportedWrite_23(); break; case 24: - ChipLogProgress(chipTool, - " ***** Test Step 24 : TH reads UserCodeTemporaryDisableTime attribute from DUT and After sending 3 failure " - "responses verify that UserCodeTemporaryDisableTime attribute is triggered\n"); - if (ShouldSkip("PICS_USER_PROMPT && DRLK.S.A0031")) { - NextTest(); - return; - } - err = TestThReadsUserCodeTemporaryDisableTimeAttributeFromDutAndAfterSending3FailureResponsesVerifyThatUserCodeTemporaryDisableTimeAttributeIsTriggered_24(); + ChipLogProgress(chipTool, " ***** Test Step 24 : Clean the created user\n"); + err = TestCleanTheCreatedUser_24(); break; case 25: - ChipLogProgress(chipTool, - " ***** Test Step 25 : TH sends Lock Command to the DUT with valid PINCode before UserCodeTemporaryDisableTime " - "attribute time expires\n"); - if (ShouldSkip("PICS_USER_PROMPT && DRLK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestThSendsLockCommandToTheDutWithValidPINCodeBeforeUserCodeTemporaryDisableTimeAttributeTimeExpires_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Clean the created user\n"); - err = TestCleanTheCreatedUser_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Cleanup the created credential\n"); + ChipLogProgress(chipTool, " ***** Test Step 25 : Cleanup the created credential\n"); if (ShouldSkip("DRLK.S.C26.Rsp")) { NextTest(); return; } - err = TestCleanupTheCreatedCredential_27(); + err = TestCleanupTheCreatedCredential_25(); break; } @@ -118807,25 +118787,25 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 18: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); break; case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); break; case 24: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -118833,12 +118813,6 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { case 25: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; } // Go on to the next test. @@ -118852,7 +118826,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 28; + const uint16_t mTestCount = 26; chip::Optional mNodeId; chip::Optional mCluster; @@ -119176,7 +119150,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThWritesTheRequirePINforRemoteOperationAttributeValueAsTrueOnTheDut_10() + CHIP_ERROR TestThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDut_10() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; @@ -119186,7 +119160,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { requirePINforRemoteOperationArgument = [NSNumber numberWithBool:true]; [cluster writeAttributeRequirePINforRemoteOperationWithValue:requirePINforRemoteOperationArgument completionHandler:^(NSError * _Nullable err) { - NSLog(@"TH writes the RequirePINforRemoteOperation attribute value as True " + NSLog(@"TH writes the RequirePINforRemoteOperation attribute value as False " @"on the DUT Error: %@", err); @@ -119198,7 +119172,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThWritesTheRequirePINforRemoteOperationAttributeValueAsTrueOnTheDutAndVerifyDutRespondsWithUnsupportedWrite_11() + CHIP_ERROR TestThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDutAndVerifyDutRespondsWithUnsupportedWrite_11() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; @@ -119208,7 +119182,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { requirePINforRemoteOperationArgument = [NSNumber numberWithBool:true]; [cluster writeAttributeRequirePINforRemoteOperationWithValue:requirePINforRemoteOperationArgument completionHandler:^(NSError * _Nullable err) { - NSLog(@"TH writes the RequirePINforRemoteOperation attribute value as True " + NSLog(@"TH writes the RequirePINforRemoteOperation attribute value as False " @"on the DUT and Verify DUT responds with UNSUPPORTED_WRITE Error: %@", err); @@ -119308,7 +119282,66 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThWritesWrongCodeEntryLimitAttributeValueAs3OnTheDutAndVerifyThatTheDutSendsSuccessResponse_16() + CHIP_ERROR TestThReadsTheWrongCodeEntryLimitAttributeFromTheDut_16() + { + MTRBaseDevice * device = GetDevice("alpha"); + MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWrongCodeEntryLimitWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads the WrongCodeEntryLimit attribute from the DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsTheUnlockDoorCommandToTheDutWithInvalidPINCode_17() + { + MTRBaseDevice * device = GetDevice("alpha"); + MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterUnlockDoorParams alloc] init]; + params.pinCode = [[NSData alloc] initWithBytes:"1234568" length:7]; + [cluster + unlockDoorWithParams:params + completionHandler:^(NSError * _Nullable err) { + NSLog(@"TH sends the unlock Door command to the DUT with invalid PINCode Error: %@", err); + + VerifyOrReturn(CheckValue("status", + err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, + EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsTheUnlockDoorCommandToTheDutWithValidPINCode_18() + { + MTRBaseDevice * device = GetDevice("alpha"); + MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterUnlockDoorParams alloc] init]; + params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; + [cluster unlockDoorWithParams:params + completionHandler:^(NSError * _Nullable err) { + NSLog(@"TH sends the unlock Door command to the DUT with valid PINCode Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThWritesWrongCodeEntryLimitAttributeValueAsBetween1And255OnTheDutAndVerifyThatTheDutSendsSuccessResponse_19() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; @@ -119318,8 +119351,8 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { wrongCodeEntryLimitArgument = [NSNumber numberWithUnsignedChar:3U]; [cluster writeAttributeWrongCodeEntryLimitWithValue:wrongCodeEntryLimitArgument completionHandler:^(NSError * _Nullable err) { - NSLog(@"TH writes WrongCodeEntryLimit attribute value as 3 on the DUT and Verify " - @"that the DUT sends Success response Error: %@", + NSLog(@"TH writes WrongCodeEntryLimit attribute value as between 1 and 255 on the " + @"DUT and Verify that the DUT sends Success response Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); @@ -119330,7 +119363,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThWritesWrongCodeEntryLimitAttributeValueAs3OnTheDutAndVerifyDutRespondsWithUnsupportedWrite_17() + CHIP_ERROR TestThWritesWrongCodeEntryLimitAttributeValueAsBetween1And255OnTheDutAndVerifyDutRespondsWithUnsupportedWrite_20() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; @@ -119340,8 +119373,8 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { wrongCodeEntryLimitArgument = [NSNumber numberWithUnsignedChar:3U]; [cluster writeAttributeWrongCodeEntryLimitWithValue:wrongCodeEntryLimitArgument completionHandler:^(NSError * _Nullable err) { - NSLog(@"TH writes WrongCodeEntryLimit attribute value as 3 on the DUT and verify DUT " - @"responds with UNSUPPORTED_WRITE Error: %@", + NSLog(@"TH writes WrongCodeEntryLimit attribute value as between 1 and 255 on the " + @"DUT and verify DUT responds with UNSUPPORTED_WRITE Error: %@", err); VerifyOrReturn(CheckValue("status", @@ -119356,8 +119389,26 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { return CHIP_NO_ERROR; } + CHIP_ERROR TestThReadsTheUserCodeTemporaryDisableTimeAttributeFromTheDut_21() + { + MTRBaseDevice * device = GetDevice("alpha"); + MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster + readAttributeUserCodeTemporaryDisableTimeWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads the UserCodeTemporaryDisableTime attribute from the DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + CHIP_ERROR - TestThWritesUserCodeTemporaryDisableTimeAttributeValueAs15SecondsOnTheDutAndVerifyThatTheDutSendTheSuccessResponse_18() + TestThWritesUserCodeTemporaryDisableTimeAttributeValueAsBetween1And255OnTheDutAndVerifyThatTheDutSendsSuccessResponse_22() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; @@ -119368,8 +119419,8 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { [cluster writeAttributeUserCodeTemporaryDisableTimeWithValue:userCodeTemporaryDisableTimeArgument completionHandler:^(NSError * _Nullable err) { - NSLog(@"TH writes UserCodeTemporaryDisableTime attribute value as 15 seconds on " - @"the DUT and Verify that the DUT send the Success response Error: %@", + NSLog(@"TH writes UserCodeTemporaryDisableTime attribute value as between 1 and " + @"255 on the DUT and Verify that the DUT sends Success response Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); @@ -119381,7 +119432,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { } CHIP_ERROR - TestThWritesUserCodeTemporaryDisableTimeAttributeValueAs15SecondsOnTheDutAndVerifyDutRespondsWithUnsupportedWrite_19() + TestThWritesUserCodeTemporaryDisableTimeAttributeValueAsBetween1And255OnTheDutAndVerifyDutRespondsWithUnsupportedWrite_23() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; @@ -119392,8 +119443,8 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { [cluster writeAttributeUserCodeTemporaryDisableTimeWithValue:userCodeTemporaryDisableTimeArgument completionHandler:^(NSError * _Nullable err) { - NSLog(@"TH writes UserCodeTemporaryDisableTime attribute value as 15 seconds on " - @"the DUT and Verify DUT responds with UNSUPPORTED_WRITE Error: %@", + NSLog(@"TH writes UserCodeTemporaryDisableTime attribute value as between 1 and " + @"255 on the DUT and verify DUT responds with UNSUPPORTED_WRITE Error: %@", err); VerifyOrReturn(CheckValue("status", @@ -119408,110 +119459,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThSendsLockDoorCommandToTheDutWithInvalidPINCode_20() - { - MTRBaseDevice * device = GetDevice("alpha"); - MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterLockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123458" length:6]; - [cluster lockDoorWithParams:params - completionHandler:^(NSError * _Nullable err) { - NSLog(@"TH sends Lock Door Command to the DUT with invalid PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsLockDoorCommandToTheDutWithInvalidPINCode_21() - { - MTRBaseDevice * device = GetDevice("alpha"); - MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterLockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123458" length:6]; - [cluster lockDoorWithParams:params - completionHandler:^(NSError * _Nullable err) { - NSLog(@"TH sends Lock Door Command to the DUT with invalid PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsLockDoorCommandToTheDutWithInvalidPINCode_22() - { - MTRBaseDevice * device = GetDevice("alpha"); - MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterLockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123458" length:6]; - [cluster lockDoorWithParams:params - completionHandler:^(NSError * _Nullable err) { - NSLog(@"TH sends Lock Door Command to the DUT with invalid PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsLockDoorCommandToTheDutWithInvalidPINCode_23() - { - MTRBaseDevice * device = GetDevice("alpha"); - MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterLockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123458" length:6]; - [cluster lockDoorWithParams:params - completionHandler:^(NSError * _Nullable err) { - NSLog(@"TH sends Lock Door Command to the DUT with invalid PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR - TestThReadsUserCodeTemporaryDisableTimeAttributeFromDutAndAfterSending3FailureResponsesVerifyThatUserCodeTemporaryDisableTimeAttributeIsTriggered_24() - { - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestThSendsLockCommandToTheDutWithValidPINCodeBeforeUserCodeTemporaryDisableTimeAttributeTimeExpires_25() - { - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestCleanTheCreatedUser_26() + CHIP_ERROR TestCleanTheCreatedUser_24() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; @@ -119531,7 +119479,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestCleanupTheCreatedCredential_27() + CHIP_ERROR TestCleanupTheCreatedCredential_25() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterDoorLock * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue];