diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f04ec307f090b0..5d02a93e4e82b1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,7 +17,7 @@ "build": { "dockerfile": "Dockerfile", "args": { - "BUILD_VERSION": "0.5.99" + "BUILD_VERSION": "0.6.02" } }, "remoteUser": "vscode", diff --git a/.github/.wordlist.txt b/.github/.wordlist.txt index e693e22c2850be..ca364bc513ae9c 100644 --- a/.github/.wordlist.txt +++ b/.github/.wordlist.txt @@ -20,7 +20,6 @@ accessor AccountLogin acdbc ack -ACK ACKed ACL ACLs @@ -156,7 +155,6 @@ bootable Bootloader BorderRouterAP bouffalolab -Bouffalolab BRD breakpoint bredr @@ -332,6 +330,7 @@ cxx CY CYW DAC +DACs dadbdcdddedf DAP DAPLINK @@ -449,6 +448,7 @@ dryrun DS duplicative DUT +DUTS DV DVK dynload @@ -596,9 +596,9 @@ GPL GPLv Gradle gradlew +Groupcast GroupId GroupKeyManagement -Groupcast groupKeySecurityPolicy groupKeySetID groupsettings @@ -652,7 +652,6 @@ ignoreQueryImage ihex IlluminanceMeasurement IM -IsInitiator imager imagetool imageUri @@ -990,6 +989,7 @@ PAAs PacketBuffer PAI PairDevice +PAIs PAKE palletsprojects pankore @@ -1376,13 +1376,14 @@ uint ULA UNBLUR uncommissioned +Unencrypted unfocus Unicast UniFlash UnitLocalization -Unencrypted unpair unprovisioned +Unsecure untrusted updateAvailable updateNotAvailable @@ -1400,7 +1401,6 @@ userConsentState userguide USERINTERFACE UserLabel -Unsecure usermod usr UTF @@ -1419,6 +1419,7 @@ ver Verifier Verifiers VID +vids virtualenv visualstudio vlatest diff --git a/.github/workflows/bloat_check.yaml b/.github/workflows/bloat_check.yaml index 1511d7034216cf..1b7f75c58cbc9d 100644 --- a/.github/workflows/bloat_check.yaml +++ b/.github/workflows/bloat_check.yaml @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.5.99 + image: connectedhomeip/chip-build:0.6.02 steps: - uses: Wandalen/wretry.action@v1.0.15 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d53b6d4393f3a3..dd810ac638db46 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.99 + image: connectedhomeip/chip-build:0.6.02 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -133,7 +133,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.99 + image: connectedhomeip/chip-build:0.6.02 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -283,7 +283,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.99 + image: connectedhomeip/chip-build:0.6.02 volumes: - "/tmp/log_output:/tmp/test_logs" options: --sysctl "net.ipv6.conf.all.disable_ipv6=0 diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 9237a1a9f393f7..e127a4a7a61cc5 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -29,7 +29,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.99 + image: connectedhomeip/chip-build:0.6.02 options: --user root steps: @@ -57,7 +57,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.5.99 + image: connectedhomeip/chip-build-esp32:0.6.02 options: --user root steps: @@ -85,7 +85,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.5.99 + image: connectedhomeip/chip-build-nrf-platform:0.6.02 options: --user root steps: diff --git a/.github/workflows/cirque.yaml b/.github/workflows/cirque.yaml index e267c4d07bdf2a..575deb2224a29f 100644 --- a/.github/workflows/cirque.yaml +++ b/.github/workflows/cirque.yaml @@ -29,7 +29,7 @@ jobs: timeout-minutes: 90 env: - DOCKER_RUN_VERSION: 0.5.99 + DOCKER_RUN_VERSION: 0.6.02 GITHUB_CACHE_PATH: /tmp/cirque-cache/ runs-on: ubuntu-latest @@ -38,7 +38,7 @@ jobs: # need to run with privilege, which isn't supported by job.XXX.contaner # https://github.com/actions/container-action/issues/2 # container: - # image: connectedhomeip/chip-build-cirque:0.5.99 + # image: connectedhomeip/chip-build-cirque:0.6.02 # volumes: # - "/tmp:/tmp" # - "/dev/pts:/dev/pts" diff --git a/.github/workflows/doxygen.yaml b/.github/workflows/doxygen.yaml index 2313ff34f66c51..5e15bef5dd1969 100644 --- a/.github/workflows/doxygen.yaml +++ b/.github/workflows/doxygen.yaml @@ -82,7 +82,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build-doxygen:0.5.99 + image: connectedhomeip/chip-build-doxygen:0.6.02 if: github.actor != 'restyled-io[bot]' diff --git a/.github/workflows/examples-ameba.yaml b/.github/workflows/examples-ameba.yaml index 15e193eb5be452..a320dd8a74d08f 100644 --- a/.github/workflows/examples-ameba.yaml +++ b/.github/workflows/examples-ameba.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ameba:0.5.99 + image: connectedhomeip/chip-build-ameba:0.6.02 options: --user root steps: diff --git a/.github/workflows/examples-cc13x2x7_26x2x7.yaml b/.github/workflows/examples-cc13x2x7_26x2x7.yaml index e6c33251f5bacf..2c45231a6752a0 100644 --- a/.github/workflows/examples-cc13x2x7_26x2x7.yaml +++ b/.github/workflows/examples-cc13x2x7_26x2x7.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ti:0.5.99 + image: connectedhomeip/chip-build-ti:0.6.02 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 188c11157ba1f4..897908b8bd7c8d 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-efr32:0.5.99 + image: connectedhomeip/chip-build-efr32:0.6.02 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-esp32.yaml b/.github/workflows/examples-esp32.yaml index 64fb6e1ecca5ba..d3736684e4a132 100644 --- a/.github/workflows/examples-esp32.yaml +++ b/.github/workflows/examples-esp32.yaml @@ -31,7 +31,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.5.99 + image: connectedhomeip/chip-build-esp32:0.6.02 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -117,7 +117,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.5.99 + image: connectedhomeip/chip-build-esp32:0.6.02 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml index 6c75729e0cec11..a162a6b12d4db9 100644 --- a/.github/workflows/examples-infineon.yaml +++ b/.github/workflows/examples-infineon.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-infineon:0.5.99 + image: connectedhomeip/chip-build-infineon:0.6.02 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-k32w.yaml index 81dfa05f5f014a..ffdfe159633598 100644 --- a/.github/workflows/examples-k32w.yaml +++ b/.github/workflows/examples-k32w.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-k32w:0.5.99 + image: connectedhomeip/chip-build-k32w:0.6.02 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-linux-arm.yaml b/.github/workflows/examples-linux-arm.yaml index 6a4b6355c4601c..ad84e2787a89f8 100644 --- a/.github/workflows/examples-linux-arm.yaml +++ b/.github/workflows/examples-linux-arm.yaml @@ -31,7 +31,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-crosscompile:0.5.99 + image: connectedhomeip/chip-build-crosscompile:0.6.02 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-linux-imx.yaml b/.github/workflows/examples-linux-imx.yaml index f16fb4cedcbab5..66cd818ce81bac 100644 --- a/.github/workflows/examples-linux-imx.yaml +++ b/.github/workflows/examples-linux-imx.yaml @@ -31,7 +31,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-imx:0.5.99 + image: connectedhomeip/chip-build-imx:0.6.02 steps: - uses: Wandalen/wretry.action@v1.0.15 diff --git a/.github/workflows/examples-linux-standalone.yaml b/.github/workflows/examples-linux-standalone.yaml index ec84a6fe4e97ba..9c2de92393ef92 100644 --- a/.github/workflows/examples-linux-standalone.yaml +++ b/.github/workflows/examples-linux-standalone.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.99 + image: connectedhomeip/chip-build:0.6.02 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mbed.yaml b/.github/workflows/examples-mbed.yaml index 594914d955f0c0..c80b89d4fee1e3 100644 --- a/.github/workflows/examples-mbed.yaml +++ b/.github/workflows/examples-mbed.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-mbed-os:0.5.99 + image: connectedhomeip/chip-build-mbed-os:0.6.02 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mw320.yaml b/.github/workflows/examples-mw320.yaml index 444f44c12ca133..eaa87206501d06 100755 --- a/.github/workflows/examples-mw320.yaml +++ b/.github/workflows/examples-mw320.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.99 + image: connectedhomeip/chip-build:0.6.02 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index 55638802e93039..9983d2e7cdafcd 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.5.99 + image: connectedhomeip/chip-build-nrf-platform:0.6.02 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-qpg.yaml b/.github/workflows/examples-qpg.yaml index 432dffd8b86f5e..58861751dadd42 100644 --- a/.github/workflows/examples-qpg.yaml +++ b/.github/workflows/examples-qpg.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.99 + image: connectedhomeip/chip-build:0.6.02 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 10fbac508d9448..dfb5fc75929f1c 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-telink:0.5.99 + image: connectedhomeip/chip-build-telink:0.6.02 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-tizen.yaml b/.github/workflows/examples-tizen.yaml index 8ae6041eff5d39..561170f1ea22b5 100644 --- a/.github/workflows/examples-tizen.yaml +++ b/.github/workflows/examples-tizen.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-tizen:0.5.99 + image: connectedhomeip/chip-build-tizen:0.6.02 options: --user root volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/full-android.yaml b/.github/workflows/full-android.yaml index fcf4fc0a14619a..c17a46350971c3 100644 --- a/.github/workflows/full-android.yaml +++ b/.github/workflows/full-android.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.5.99 + image: connectedhomeip/chip-build-android:0.6.02 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/fuzzing-build.yaml b/.github/workflows/fuzzing-build.yaml index 1bdbf74d621f7d..dde6575742b382 100644 --- a/.github/workflows/fuzzing-build.yaml +++ b/.github/workflows/fuzzing-build.yaml @@ -31,7 +31,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.99 + image: connectedhomeip/chip-build:0.6.02 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2ffc3ffa19498b..6c980a2dbd1445 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,7 +28,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.99 + image: connectedhomeip/chip-build:0.6.02 steps: - uses: Wandalen/wretry.action@v1.0.15 diff --git a/.github/workflows/qemu.yaml b/.github/workflows/qemu.yaml index 82a0d2a9af5797..853d833f563f1f 100644 --- a/.github/workflows/qemu.yaml +++ b/.github/workflows/qemu.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32-qemu:0.5.99 + image: connectedhomeip/chip-build-esp32-qemu:0.6.02 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/release_artifacts.yaml b/.github/workflows/release_artifacts.yaml index d379868bb54b7f..1cb4aa641073c3 100644 --- a/.github/workflows/release_artifacts.yaml +++ b/.github/workflows/release_artifacts.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-esp32:0.5.99 + image: connectedhomeip/chip-build-esp32:0.6.02 steps: - uses: Wandalen/wretry.action@v1.0.15 @@ -75,7 +75,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-efr32:0.5.99 + image: connectedhomeip/chip-build-efr32:0.6.02 steps: - uses: Wandalen/wretry.action@v1.0.15 name: Checkout diff --git a/.github/workflows/smoketest-android.yaml b/.github/workflows/smoketest-android.yaml index e8bced07a0045d..1d6bfbc02d2e12 100644 --- a/.github/workflows/smoketest-android.yaml +++ b/.github/workflows/smoketest-android.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.5.99 + image: connectedhomeip/chip-build-android:0.6.02 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ed0f24bad7eec9..e2542c27c78711 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -44,12 +44,13 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.5.99 + image: connectedhomeip/chip-build:0.6.02 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" steps: - uses: Wandalen/wretry.action@v1.0.15 + if: ${{ !env.ACT }} name: Checkout with: action: actions/checkout@v3 @@ -57,6 +58,15 @@ jobs: token: ${{ github.token }} attempt_limit: 3 attempt_delay: 2000 + # To use act like: + # act -j test_suites_linux + # + # Note you likely still need to have non submodules setup for the + # local machine, like: + # git submodule deinit --all + - uses: actions/checkout@v3 + if: ${{ env.ACT }} + name: Checkout (ACT for local build) - name: Checkout submodules run: scripts/checkout_submodules.py --shallow --platform linux - name: Try to ensure the directories for core dumping exist and we @@ -76,6 +86,98 @@ jobs: path: | .environment/gn_out/.ninja_log .environment/pigweed-venv/*.log + - name: Validate that xml are parseable + timeout-minutes: 10 + # The sub-items being run here are the same as the input XMLs listed + # at src/app/zap-templates/zcl/zcl.json + # + # This ensures that the syntax of the XML can always be parsed/validated, however it + # does not enforce that the content is understood (that part is covered by parser + # unit tests) + # + # Also note ordering: global attributes are parsed first because other XML files may + # reference these. + # + # TODO: some multipass/postprocess may be more appropriate to allow any ordering of + # things. + run: | + ./scripts/run_in_build_env.sh \ + "./scripts/idl/xml_parser.py \ + --no-print \ + --log-level info \ + src/app/zap-templates/zcl/data-model/chip/global-attributes.xml \ + src/app/zap-templates/zcl/data-model/chip/access-control-definitions.xml \ + src/app/zap-templates/zcl/data-model/chip/access-control-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/account-login-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/administrator-commissioning-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/application-basic-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/application-launcher-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/audio-output-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/basic-information-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/binding-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/boolean-state-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/actions-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/bridged-device-basic.xml \ + src/app/zap-templates/zcl/data-model/chip/chip-ota.xml \ + src/app/zap-templates/zcl/data-model/chip/chip-types.xml \ + src/app/zap-templates/zcl/data-model/chip/channel-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/clusters-extensions.xml \ + src/app/zap-templates/zcl/data-model/chip/content-launch-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/descriptor-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/diagnostic-logs-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/door-lock-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/ethernet-network-diagnostics-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/fault-injection-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/fixed-label-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/flow-measurement-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/general-commissioning-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/general-diagnostics-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/global-attributes.xml \ + src/app/zap-templates/zcl/data-model/chip/group-key-mgmt-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/identify-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/illuminance-measurement-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/keypad-input-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/localization-configuration-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/low-power-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/media-input-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/media-playback-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/mode-select-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/network-commissioning-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/onoff-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/operational-credentials-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/pressure-measurement-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/power-source-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/power-source-configuration-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/proxy-configuration-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/proxy-discovery-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/proxy-valid-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/pump-configuration-and-control-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/pwm-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/relative-humidity-measurement-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/scene.xml \ + src/app/zap-templates/zcl/data-model/chip/software-diagnostics-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/switch-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/target-navigator-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/temperature-measurement-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/test-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/thermostat-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/thread-network-diagnostics-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/time-format-localization-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/time-synchronization-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/user-label-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/unit-localization-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/wake-on-lan-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/wifi-network-diagnostics-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/window-covering.xml \ + src/app/zap-templates/zcl/data-model/chip/matter-devices.xml \ + src/app/zap-templates/zcl/data-model/silabs/general.xml \ + src/app/zap-templates/zcl/data-model/silabs/ha-devices.xml \ + src/app/zap-templates/zcl/data-model/silabs/ha.xml \ + src/app/zap-templates/zcl/data-model/silabs/lo-devices.xml \ + src/app/zap-templates/zcl/data-model/silabs/types.xml \ + src/app/zap-templates/zcl/data-model/silabs/zll-devices.xml \ + src/app/zap-templates/zcl/data-model/silabs/zll.xml \ + " - name: Build Apps timeout-minutes: 45 run: | @@ -241,7 +343,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.5.99 + image: connectedhomeip/chip-build:0.6.02 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" diff --git a/.github/workflows/unit_integration_test.yaml b/.github/workflows/unit_integration_test.yaml index 5facff0983b010..7173657665ff29 100644 --- a/.github/workflows/unit_integration_test.yaml +++ b/.github/workflows/unit_integration_test.yaml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.5.99 + image: connectedhomeip/chip-build:0.6.02 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" diff --git a/.github/workflows/zap_regeneration.yaml b/.github/workflows/zap_regeneration.yaml index 5b08563e04075e..88c8df95ca79fd 100644 --- a/.github/workflows/zap_regeneration.yaml +++ b/.github/workflows/zap_regeneration.yaml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build-zap:0.5.99 + image: connectedhomeip/chip-build-zap:0.6.02 defaults: run: shell: sh diff --git a/.github/workflows/zap_templates.yaml b/.github/workflows/zap_templates.yaml index 978bc5ce8d7737..66b049da979517 100644 --- a/.github/workflows/zap_templates.yaml +++ b/.github/workflows/zap_templates.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build-zap:0.5.99 + image: connectedhomeip/chip-build-zap:0.6.02 defaults: run: shell: sh diff --git a/.restyled.yaml b/.restyled.yaml index 8de3586a65401b..9b6e7bcde82817 100644 --- a/.restyled.yaml +++ b/.restyled.yaml @@ -74,6 +74,7 @@ exclude: - "examples/chef/zzz_generated/**/*" - "src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm" # https://github.com/project-chip/connectedhomeip/issues/20236 - "src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h" # https://github.com/project-chip/connectedhomeip/issues/20236 + - "examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/**/*" changed_paths: diff --git a/config/esp32/components/chip/CMakeLists.txt b/config/esp32/components/chip/CMakeLists.txt index 707d23784bc350..a8b1be9bab9a53 100644 --- a/config/esp32/components/chip/CMakeLists.txt +++ b/config/esp32/components/chip/CMakeLists.txt @@ -33,7 +33,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/ota-image.cmake) set(CHIP_REQURIE_COMPONENTS freertos lwip bt mbedtls fatfs app_update console openthread nvs_flash) -if(NOT "${IDF_TARGET}" STREQUAL "esp32h2") +if((NOT "${IDF_TARGET}" STREQUAL "esp32h2") AND (NOT "${IDF_TARGET}" STREQUAL "esp32c2")) list(APPEND CHIP_REQURIE_COMPONENTS mdns) endif() @@ -289,6 +289,11 @@ if(CONFIG_BT_ENABLED) if(CONFIG_IDF_TARGET_ESP32H2_BETA_VERSION_2) list(APPEND chip_libraries ${bt_dir}/controller/lib_esp32h2/esp32h2-bt-lib/beta2/libble_app.a) endif() + elseif("${CONFIG_IDF_TARGET}" STREQUAL "esp32c2") + idf_component_get_property(bt_lib bt COMPONENT_LIB) + idf_component_get_property(bt_dir bt COMPONENT_DIR) + list(APPEND chip_libraries $) + list(APPEND chip_libraries ${bt_dir}/controller/lib_esp32c2/esp32c2-bt-lib/libble_app.a) else() idf_component_get_property(bt_lib bt COMPONENT_LIB) list(APPEND chip_libraries $ -lbtdm_app) @@ -305,7 +310,7 @@ if(CONFIG_OPENTHREAD_ENABLED) list(APPEND chip_libraries $) endif() -if(NOT CONFIG_USE_MINIMAL_MDNS AND NOT CONFIG_IDF_TARGET_ESP32H2) +if((NOT CONFIG_USE_MINIMAL_MDNS) AND (NOT CONFIG_IDF_TARGET_ESP32H2) AND (NOT CONFIG_IDF_TARGET_ESP32C2)) idf_component_get_property(mdns_lib mdns COMPONENT_LIB) list(APPEND chip_libraries $) endif() diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index 273a3a7e736087..3ce6c9cf014bd6 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -497,11 +497,14 @@ menu "CHIP Device Layer" When set, WoBLE advertisements will stop while a WoBLE connection is active. - config DEINIT_BLE_ON_COMMISSIONING_COMPLETE - bool "Disable and DeInit BLE on commissioning complete" + config USE_BLE_ONLY_FOR_COMMISSIONING + bool "Use BLE only for commissioning" default y help - Disable and deinit BLE and reclaim all its memory, once the commissioning is successful and Commissioning complete event is received in the application. + Disable this flag if BLE is used for any other purpose than commissioning. + When enabled, it deinitialized the BLE on successful commissioning, and on + bootup do not initialize the BLE if device is already provisioned with Wi-Fi/Thread credentials. + endmenu menu "CHIP Thread Options" diff --git a/config/telink/app/zephyr.conf b/config/telink/app/zephyr.conf index 92944dbed8616f..c83f5aeccca9c4 100644 --- a/config/telink/app/zephyr.conf +++ b/config/telink/app/zephyr.conf @@ -66,7 +66,7 @@ CONFIG_OPENTHREAD_DEBUG=y CONFIG_OPENTHREAD_L2_DEBUG=y CONFIG_OPENTHREAD_L2_LOG_LEVEL_INF=y -CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154" +CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154_b91" CONFIG_NET_CONFIG_MY_IPV6_ADDR="fdde:ad00:beef::1" CONFIG_NET_CONFIG_PEER_IPV6_ADDR="fdde:ad00:beef::2" @@ -87,7 +87,8 @@ CONFIG_OPENTHREAD_DUA=y CONFIG_OPENTHREAD_MLR=y # mbedTLS tweaks -CONFIG_MBEDTLS_DEBUG=y +CONFIG_MBEDTLS_TEST=y +CONFIG_MBEDTLS_PKCS5_C=y CONFIG_MBEDTLS_USER_CONFIG_ENABLE=y CONFIG_MBEDTLS_USER_CONFIG_FILE="telink-mbedtls-config.h" diff --git a/config/telink/chip-module/CMakeLists.txt b/config/telink/chip-module/CMakeLists.txt index 7b4c76555a62e6..f6d93210b4a416 100644 --- a/config/telink/chip-module/CMakeLists.txt +++ b/config/telink/chip-module/CMakeLists.txt @@ -108,16 +108,7 @@ if (CONFIG_POSIX_API) ) endif() -# Add MbedTLS config file -list(APPEND CHIP_CFLAGS -DMBEDTLS_CONFIG_FILE=CONFIG_MBEDTLS_CFG_FILE) - -# Add hardware cryptography dependencies -zephyr_include_directories(${ZEPHYR_BASE}/../modules/crypto/mbedtls/include) -zephyr_include_directories(${ZEPHYR_BASE}/modules/mbedtls/configs) zephyr_include_directories(${CHIP_ROOT}/src/platform/telink/) -zephyr_include_directories(${CHIP_ROOT}/src/platform/telink/crypto/) -zephyr_sources(${ZEPHYR_BASE}/../modules/hal/telink/tlsr9/drivers/B91/aes.c) -zephyr_sources(${ZEPHYR_BASE}/../modules/hal/telink/tlsr9/drivers/B91/pke.c) zephyr_get_compile_flags(CHIP_CFLAGS_C C) zephyr_get_compile_flags(CHIP_CFLAGS_CC CXX) diff --git a/docs/guides/README.md b/docs/guides/README.md index 44d0a8dc9fcb4a..67bb8b66001830 100644 --- a/docs/guides/README.md +++ b/docs/guides/README.md @@ -18,8 +18,9 @@ - [nRF Connect - Software Update](./nrfconnect_examples_software_update.md) - [NXP - Android Commissioning](./nxp_k32w_android_commissioning.md) - [NXP - Linux Examples](./nxp_imx8m_linux_examples.md) +- [Silicon Labs - Documentation](https://github.com/SiliconLabs/matter#readme) - [Silicon Labs - Building](./silabs_efr32_building.md) -- [Silicon Labs - Building](./silabs_efr32_software_update.md) +- [Silicon Labs - Software Update](./silabs_efr32_software_update.md) - [TI - Platform Overview](./ti_platform_overview.md) ## Development Guides diff --git a/docs/guides/silabs_efr32_building.md b/docs/guides/silabs_efr32_building.md index 46792d545eceb5..a3e4ed8ed0c0be 100644 --- a/docs/guides/silabs_efr32_building.md +++ b/docs/guides/silabs_efr32_building.md @@ -13,8 +13,18 @@ The full list of examples can be found [here](https://github.com/project-chip/connectedhomeip/tree/master/examples). The GitHub repository also includes tools for testing your Matter project. +## Silicon Labs Matter Github + +Silicon Laboratories now maintains a public matter GitHub repo with frequent +releases thoroughly tested and validated. Developers looking to develop matter +products with silabs hardware are encouraged to use our latest release with +added tools and documentation. +[Silabs Matter Github](https://github.com/SiliconLabs/matter/releases) + +The complete Silabs documentation can be found here +[Silabs Matter Github Documentation](https://github.com/SiliconLabs/matter#readme) + ## Getting Started with Matter on EFR32 Developers can find more resources on -[Silicon Labs Matter Community Page](https://community.silabs.com/s/article/connected-home-over-ip-chip-faq?language=en_US) -. +[Silicon Labs Matter Community Page](https://community.silabs.com/s/article/connected-home-over-ip-chip-faq?language=en_US). diff --git a/examples/all-clusters-minimal-app/esp32/sdkconfig.old b/examples/all-clusters-minimal-app/esp32/sdkconfig.old deleted file mode 100644 index 77d2115a14eb6d..00000000000000 --- a/examples/all-clusters-minimal-app/esp32/sdkconfig.old +++ /dev/null @@ -1,1551 +0,0 @@ -# -# Automatically generated file. DO NOT EDIT. -# Espressif IoT Development Framework (ESP-IDF) Project Configuration -# -CONFIG_IDF_CMAKE=y -CONFIG_IDF_TARGET_ARCH_XTENSA=y -CONFIG_IDF_TARGET="esp32" -CONFIG_IDF_TARGET_ESP32=y -CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000 - -# -# SDK tool configuration -# -CONFIG_SDK_TOOLPREFIX="xtensa-esp32-elf-" -# CONFIG_SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS is not set -# end of SDK tool configuration - -# -# Build type -# -CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y -# CONFIG_APP_BUILD_TYPE_ELF_RAM is not set -CONFIG_APP_BUILD_GENERATE_BINARIES=y -CONFIG_APP_BUILD_BOOTLOADER=y -CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y -# end of Build type - -# -# Application manager -# -CONFIG_APP_COMPILE_TIME_DATE=y -# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set -# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set -# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set -CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 -# end of Application manager - -# -# Bootloader config -# -CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000 -CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y -# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set -# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set -# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set -# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set -# CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set -# CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set -CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y -# CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set -# CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set -CONFIG_BOOTLOADER_LOG_LEVEL=3 -# CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_8V is not set -CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y -# CONFIG_BOOTLOADER_FACTORY_RESET is not set -# CONFIG_BOOTLOADER_APP_TEST is not set -CONFIG_BOOTLOADER_WDT_ENABLE=y -# CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set -CONFIG_BOOTLOADER_WDT_TIME_MS=9000 -# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set -# CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set -# CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set -# CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set -CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 -# CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set -CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y -# end of Bootloader config - -# -# Security features -# -# CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set -# CONFIG_SECURE_BOOT is not set -# CONFIG_SECURE_FLASH_ENC_ENABLED is not set -# end of Security features - -# -# Serial flasher config -# -CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 -# CONFIG_ESPTOOLPY_NO_STUB is not set -# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set -# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set -CONFIG_ESPTOOLPY_FLASHMODE_DIO=y -# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set -CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y -CONFIG_ESPTOOLPY_FLASHMODE="dio" -# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set -CONFIG_ESPTOOLPY_FLASHFREQ_40M=y -# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set -CONFIG_ESPTOOLPY_FLASHFREQ="40m" -# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y -# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE="4MB" -CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y -CONFIG_ESPTOOLPY_BEFORE_RESET=y -# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set -CONFIG_ESPTOOLPY_BEFORE="default_reset" -CONFIG_ESPTOOLPY_AFTER_RESET=y -# CONFIG_ESPTOOLPY_AFTER_NORESET is not set -CONFIG_ESPTOOLPY_AFTER="hard_reset" -# CONFIG_ESPTOOLPY_MONITOR_BAUD_CONSOLE is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B is not set -CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y -# CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set -CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=115200 -CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 -# end of Serial flasher config - -# -# Partition Table -# -# CONFIG_PARTITION_TABLE_SINGLE_APP is not set -# CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set -# CONFIG_PARTITION_TABLE_TWO_OTA is not set -CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" -CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" -CONFIG_PARTITION_TABLE_OFFSET=0x8000 -CONFIG_PARTITION_TABLE_MD5=y -# end of Partition Table - -# -# Demo -# -# CONFIG_DEVICE_TYPE_ESP32_DEVKITC is not set -# CONFIG_DEVICE_TYPE_ESP32_WROVER_KIT is not set -CONFIG_DEVICE_TYPE_M5STACK=y -# CONFIG_RENDEZVOUS_MODE_SOFTAP is not set -CONFIG_RENDEZVOUS_MODE_BLE=y -# CONFIG_RENDEZVOUS_MODE_ON_NETWORK is not set -# CONFIG_RENDEZVOUS_MODE_SOFTAP_ON_NETWORK is not set -# CONFIG_RENDEZVOUS_MODE_BLE_ON_NETWORK is not set -CONFIG_TFT_PREDEFINED_DISPLAY_TYPE=3 -CONFIG_RENDEZVOUS_MODE=2 -CONFIG_DISPLAY_AUTO_OFF=y -CONFIG_STATUS_LED_GPIO_NUM=40 -CONFIG_DEINIT_BLE_ON_COMMISSIONING_COMPLETE=y -# end of Demo - -# -# Compiler options -# -CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y -# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set -# CONFIG_COMPILER_OPTIMIZATION_PERF is not set -# CONFIG_COMPILER_OPTIMIZATION_NONE is not set -CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y -# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set -# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set -CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2 -# CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set -CONFIG_COMPILER_HIDE_PATHS_MACROS=y -# CONFIG_COMPILER_CXX_EXCEPTIONS is not set -# CONFIG_COMPILER_CXX_RTTI is not set -CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y -# CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set -# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set -# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set -# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set -# CONFIG_COMPILER_DISABLE_GCC8_WARNINGS is not set -# CONFIG_COMPILER_DUMP_RTL_FILES is not set -# end of Compiler options - -# -# Component config -# - -# -# Application Level Tracing -# -# CONFIG_APPTRACE_DEST_JTAG is not set -CONFIG_APPTRACE_DEST_NONE=y -CONFIG_APPTRACE_LOCK_ENABLE=y -# end of Application Level Tracing - -# -# ESP-ASIO -# -# CONFIG_ASIO_SSL_SUPPORT is not set -# end of ESP-ASIO - -# -# Bluetooth -# -CONFIG_BT_ENABLED=y - -# -# Bluetooth controller -# -CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y -# CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY is not set -# CONFIG_BTDM_CTRL_MODE_BTDM is not set -CONFIG_BTDM_CTRL_BLE_MAX_CONN=3 -CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF=0 -CONFIG_BTDM_CTRL_PCM_ROLE_EFF=0 -CONFIG_BTDM_CTRL_PCM_POLAR_EFF=0 -CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF=3 -CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF=0 -CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF=0 -CONFIG_BTDM_CTRL_PINNED_TO_CORE_0=y -# CONFIG_BTDM_CTRL_PINNED_TO_CORE_1 is not set -CONFIG_BTDM_CTRL_PINNED_TO_CORE=0 -CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y -# CONFIG_BTDM_CTRL_HCI_MODE_UART_H4 is not set - -# -# MODEM SLEEP Options -# -# CONFIG_BTDM_CTRL_MODEM_SLEEP is not set -# end of MODEM SLEEP Options - -CONFIG_BTDM_BLE_DEFAULT_SCA_250PPM=y -CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF=1 -CONFIG_BTDM_BLE_SCAN_DUPL=y -CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE=y -# CONFIG_BTDM_SCAN_DUPL_TYPE_DATA is not set -# CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE is not set -CONFIG_BTDM_SCAN_DUPL_TYPE=0 -CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE=200 -# CONFIG_BTDM_BLE_MESH_SCAN_DUPL_EN is not set -CONFIG_BTDM_CTRL_FULL_SCAN_SUPPORTED=y -CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y -CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM=100 -CONFIG_BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 -CONFIG_BTDM_RESERVE_DRAM=0xdb5c -CONFIG_BTDM_CTRL_HLI=y -# end of Bluetooth controller - -# CONFIG_BT_BLUEDROID_ENABLED is not set -CONFIG_BT_NIMBLE_ENABLED=y -# CONFIG_BT_CONTROLLER_ONLY is not set - -# -# NimBLE Options -# -CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL=y -# CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT is not set -# CONFIG_BT_NIMBLE_LOG_LEVEL_NONE is not set -# CONFIG_BT_NIMBLE_LOG_LEVEL_ERROR is not set -# CONFIG_BT_NIMBLE_LOG_LEVEL_WARNING is not set -CONFIG_BT_NIMBLE_LOG_LEVEL_INFO=y -# CONFIG_BT_NIMBLE_LOG_LEVEL_DEBUG is not set -CONFIG_BT_NIMBLE_LOG_LEVEL=1 -CONFIG_BT_NIMBLE_MAX_CONNECTIONS=3 -CONFIG_BT_NIMBLE_MAX_BONDS=3 -CONFIG_BT_NIMBLE_MAX_CCCDS=8 -CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM=0 -CONFIG_BT_NIMBLE_PINNED_TO_CORE_0=y -# CONFIG_BT_NIMBLE_PINNED_TO_CORE_1 is not set -CONFIG_BT_NIMBLE_PINNED_TO_CORE=0 -CONFIG_BT_NIMBLE_TASK_STACK_SIZE=4096 -CONFIG_BT_NIMBLE_ROLE_CENTRAL=y -CONFIG_BT_NIMBLE_ROLE_PERIPHERAL=y -CONFIG_BT_NIMBLE_ROLE_BROADCASTER=y -CONFIG_BT_NIMBLE_ROLE_OBSERVER=y -CONFIG_BT_NIMBLE_NVS_PERSIST=y -CONFIG_BT_NIMBLE_SM_LEGACY=y -CONFIG_BT_NIMBLE_SM_SC=y -# CONFIG_BT_NIMBLE_DEBUG is not set -# CONFIG_BT_NIMBLE_SM_SC_DEBUG_KEYS is not set -CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME="nimble" -CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN=31 -CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU=256 -CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE=0 -CONFIG_BT_NIMBLE_ACL_BUF_COUNT=20 -CONFIG_BT_NIMBLE_ACL_BUF_SIZE=255 -CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70 -CONFIG_BT_NIMBLE_HCI_EVT_HI_BUF_COUNT=30 -CONFIG_BT_NIMBLE_HCI_EVT_LO_BUF_COUNT=8 -CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT=12 -CONFIG_BT_NIMBLE_HS_FLOW_CTRL=y -CONFIG_BT_NIMBLE_HS_FLOW_CTRL_ITVL=1000 -CONFIG_BT_NIMBLE_HS_FLOW_CTRL_THRESH=2 -CONFIG_BT_NIMBLE_HS_FLOW_CTRL_TX_ON_DISCONNECT=y -CONFIG_BT_NIMBLE_RPA_TIMEOUT=900 -# CONFIG_BT_NIMBLE_MESH is not set -CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS=y -CONFIG_BT_NIMBLE_HS_STOP_TIMEOUT_MS=2000 -# CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT is not set -# CONFIG_BT_NIMBLE_BLUFI_ENABLE is not set -CONFIG_BT_NIMBLE_USE_ESP_TIMER=y -# end of NimBLE Options -# end of Bluetooth - -# CONFIG_BLE_MESH is not set - -# -# CoAP Configuration -# -CONFIG_COAP_MBEDTLS_PSK=y -# CONFIG_COAP_MBEDTLS_PKI is not set -# CONFIG_COAP_MBEDTLS_DEBUG is not set -CONFIG_COAP_LOG_DEFAULT_LEVEL=0 -# end of CoAP Configuration - -# -# Driver configurations -# - -# -# ADC configuration -# -# CONFIG_ADC_FORCE_XPD_FSM is not set -CONFIG_ADC_DISABLE_DAC=y -# end of ADC configuration - -# -# MCPWM configuration -# -# CONFIG_MCPWM_ISR_IN_IRAM is not set -# end of MCPWM configuration - -# -# SPI configuration -# -# CONFIG_SPI_MASTER_IN_IRAM is not set -CONFIG_SPI_MASTER_ISR_IN_IRAM=y -# CONFIG_SPI_SLAVE_IN_IRAM is not set -CONFIG_SPI_SLAVE_ISR_IN_IRAM=y -# end of SPI configuration - -# -# TWAI configuration -# -# CONFIG_TWAI_ISR_IN_IRAM is not set -# CONFIG_TWAI_ERRATA_FIX_BUS_OFF_REC is not set -# CONFIG_TWAI_ERRATA_FIX_TX_INTR_LOST is not set -# CONFIG_TWAI_ERRATA_FIX_RX_FRAME_INVALID is not set -# CONFIG_TWAI_ERRATA_FIX_RX_FIFO_CORRUPT is not set -# end of TWAI configuration - -# -# UART configuration -# -# CONFIG_UART_ISR_IN_IRAM is not set -# end of UART configuration - -# -# RTCIO configuration -# -# CONFIG_RTCIO_SUPPORT_RTC_GPIO_DESC is not set -# end of RTCIO configuration - -# -# GPIO Configuration -# -# CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL is not set -# end of GPIO Configuration - -# -# GDMA Configuration -# -# CONFIG_GDMA_CTRL_FUNC_IN_IRAM is not set -# CONFIG_GDMA_ISR_IRAM_SAFE is not set -# end of GDMA Configuration -# end of Driver configurations - -# -# eFuse Bit Manager -# -# CONFIG_EFUSE_CUSTOM_TABLE is not set -# CONFIG_EFUSE_VIRTUAL is not set -# CONFIG_EFUSE_CODE_SCHEME_COMPAT_NONE is not set -CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4=y -# CONFIG_EFUSE_CODE_SCHEME_COMPAT_REPEAT is not set -CONFIG_EFUSE_MAX_BLK_LEN=192 -# end of eFuse Bit Manager - -# -# ESP-TLS -# -CONFIG_ESP_TLS_USING_MBEDTLS=y -# CONFIG_ESP_TLS_USE_SECURE_ELEMENT is not set -# CONFIG_ESP_TLS_SERVER is not set -# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set -# CONFIG_ESP_TLS_PSK_VERIFICATION is not set -# CONFIG_ESP_TLS_INSECURE is not set -# end of ESP-TLS - -# -# ESP32-specific -# -CONFIG_ESP32_REV_MIN_0=y -# CONFIG_ESP32_REV_MIN_1 is not set -# CONFIG_ESP32_REV_MIN_2 is not set -# CONFIG_ESP32_REV_MIN_3 is not set -CONFIG_ESP32_REV_MIN=0 -CONFIG_ESP32_DPORT_WORKAROUND=y -# CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set -CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y -# CONFIG_ESP32_DEFAULT_CPU_FREQ_240 is not set -CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 -# CONFIG_ESP32_SPIRAM_SUPPORT is not set -# CONFIG_ESP32_TRAX is not set -CONFIG_ESP32_TRACEMEM_RESERVE_DRAM=0x0 -# CONFIG_ESP32_ULP_COPROC_ENABLED is not set -CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=0 -CONFIG_ESP32_DEBUG_OCDAWARE=y -CONFIG_ESP32_BROWNOUT_DET=y -CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_1 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set -CONFIG_ESP32_BROWNOUT_DET_LVL=0 -CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y -# CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set -# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set -# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set -CONFIG_ESP32_RTC_CLK_SRC_INT_RC=y -# CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS is not set -# CONFIG_ESP32_RTC_CLK_SRC_EXT_OSC is not set -# CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256 is not set -CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 -CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000 -CONFIG_ESP32_XTAL_FREQ_40=y -# CONFIG_ESP32_XTAL_FREQ_26 is not set -# CONFIG_ESP32_XTAL_FREQ_AUTO is not set -CONFIG_ESP32_XTAL_FREQ=40 -# CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set -# CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set -# CONFIG_ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS is not set -# CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE is not set -CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5 -# end of ESP32-specific - -# -# ADC-Calibration -# -CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y -CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y -CONFIG_ADC_CAL_LUT_ENABLE=y -# end of ADC-Calibration - -# -# Common ESP-related -# -CONFIG_ESP_ERR_TO_NAME_LOOKUP=y -# end of Common ESP-related - -# -# Ethernet -# -CONFIG_ETH_ENABLED=y -CONFIG_ETH_USE_ESP32_EMAC=y -CONFIG_ETH_PHY_INTERFACE_RMII=y -CONFIG_ETH_RMII_CLK_INPUT=y -# CONFIG_ETH_RMII_CLK_OUTPUT is not set -CONFIG_ETH_RMII_CLK_IN_GPIO=0 -CONFIG_ETH_DMA_BUFFER_SIZE=512 -CONFIG_ETH_DMA_RX_BUFFER_NUM=10 -CONFIG_ETH_DMA_TX_BUFFER_NUM=10 -CONFIG_ETH_USE_SPI_ETHERNET=y -# CONFIG_ETH_SPI_ETHERNET_DM9051 is not set -# CONFIG_ETH_SPI_ETHERNET_W5500 is not set -# CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL is not set -# CONFIG_ETH_USE_OPENETH is not set -# end of Ethernet - -# -# Event Loop Library -# -# CONFIG_ESP_EVENT_LOOP_PROFILING is not set -CONFIG_ESP_EVENT_POST_FROM_ISR=y -CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y -# end of Event Loop Library - -# -# GDB Stub -# -# end of GDB Stub - -# -# ESP HTTP client -# -CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y -# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set -CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH=y -# end of ESP HTTP client - -# -# HTTP Server -# -CONFIG_HTTPD_MAX_REQ_HDR_LEN=512 -CONFIG_HTTPD_MAX_URI_LEN=512 -CONFIG_HTTPD_ERR_RESP_NO_DELAY=y -CONFIG_HTTPD_PURGE_BUF_LEN=32 -# CONFIG_HTTPD_LOG_PURGE_DATA is not set -# CONFIG_HTTPD_WS_SUPPORT is not set -# end of HTTP Server - -# -# ESP HTTPS OTA -# -# CONFIG_OTA_ALLOW_HTTP is not set -# end of ESP HTTPS OTA - -# -# ESP HTTPS server -# -# CONFIG_ESP_HTTPS_SERVER_ENABLE is not set -# end of ESP HTTPS server - -# -# Hardware Settings -# - -# -# MAC Config -# -CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y -CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y -CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y -CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y -# CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_TWO is not set -CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y -CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 -# end of MAC Config - -# -# Sleep Config -# -CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y -CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y -# CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND is not set -# CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set -# end of Sleep Config -# end of Hardware Settings - -# -# IPC (Inter-Processor Call) -# -CONFIG_ESP_IPC_TASK_STACK_SIZE=1536 -CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y -CONFIG_ESP_IPC_ISR_ENABLE=y -# end of IPC (Inter-Processor Call) - -# -# LCD and Touch Panel -# - -# -# LCD Peripheral Configuration -# -CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=32 -# end of LCD Peripheral Configuration -# end of LCD and Touch Panel - -# -# ESP NETIF Adapter -# -CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 -CONFIG_ESP_NETIF_TCPIP_LWIP=y -# CONFIG_ESP_NETIF_LOOPBACK is not set -CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=y -# end of ESP NETIF Adapter - -# -# PHY -# -CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y -# CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set -CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 -CONFIG_ESP_PHY_MAX_TX_POWER=20 -CONFIG_ESP_PHY_REDUCE_TX_POWER=y -# end of PHY - -# -# Power Management -# -# CONFIG_PM_ENABLE is not set -# end of Power Management - -# -# ESP System Settings -# -# CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set -CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y -# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set -# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set -# CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set - -# -# Memory protection -# -# end of Memory protection - -CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 -CONFIG_ESP_MAIN_TASK_STACK_SIZE=5120 -CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y -# CONFIG_ESP_MAIN_TASK_AFFINITY_CPU1 is not set -# CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set -CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 -CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 -CONFIG_ESP_CONSOLE_UART_DEFAULT=y -# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set -# CONFIG_ESP_CONSOLE_NONE is not set -CONFIG_ESP_CONSOLE_UART=y -CONFIG_ESP_CONSOLE_MULTIPLE_UART=y -CONFIG_ESP_CONSOLE_UART_NUM=0 -CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 -CONFIG_ESP_INT_WDT=y -CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 -CONFIG_ESP_INT_WDT_CHECK_CPU1=y -CONFIG_ESP_TASK_WDT=y -# CONFIG_ESP_TASK_WDT_PANIC is not set -CONFIG_ESP_TASK_WDT_TIMEOUT_S=5 -CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y -CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y -# CONFIG_ESP_PANIC_HANDLER_IRAM is not set -CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5=y -# end of ESP System Settings - -# -# High resolution timer (esp_timer) -# -# CONFIG_ESP_TIMER_PROFILING is not set -CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y -CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y -CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 -CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 -# CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set -# CONFIG_ESP_TIMER_IMPL_FRC2 is not set -CONFIG_ESP_TIMER_IMPL_TG0_LAC=y -# end of High resolution timer (esp_timer) - -# -# Wi-Fi -# -CONFIG_ESP32_WIFI_ENABLED=y -CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE=y -CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 -CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 -# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set -CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y -CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 -CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 -# CONFIG_ESP32_WIFI_CSI_ENABLED is not set -CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y -CONFIG_ESP32_WIFI_TX_BA_WIN=6 -CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y -CONFIG_ESP32_WIFI_RX_BA_WIN=6 -CONFIG_ESP32_WIFI_NVS_ENABLED=y -CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y -# CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set -CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 -CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 -CONFIG_ESP32_WIFI_IRAM_OPT=y -CONFIG_ESP32_WIFI_RX_IRAM_OPT=y -CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y -# CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set -# CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set -# CONFIG_ESP_WIFI_GMAC_SUPPORT is not set -CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y -# end of Wi-Fi - -# -# Core dump -# -# CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH is not set -# CONFIG_ESP_COREDUMP_ENABLE_TO_UART is not set -CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y -# end of Core dump - -# -# FAT Filesystem support -# -# CONFIG_FATFS_CODEPAGE_DYNAMIC is not set -CONFIG_FATFS_CODEPAGE_437=y -# CONFIG_FATFS_CODEPAGE_720 is not set -# CONFIG_FATFS_CODEPAGE_737 is not set -# CONFIG_FATFS_CODEPAGE_771 is not set -# CONFIG_FATFS_CODEPAGE_775 is not set -# CONFIG_FATFS_CODEPAGE_850 is not set -# CONFIG_FATFS_CODEPAGE_852 is not set -# CONFIG_FATFS_CODEPAGE_855 is not set -# CONFIG_FATFS_CODEPAGE_857 is not set -# CONFIG_FATFS_CODEPAGE_860 is not set -# CONFIG_FATFS_CODEPAGE_861 is not set -# CONFIG_FATFS_CODEPAGE_862 is not set -# CONFIG_FATFS_CODEPAGE_863 is not set -# CONFIG_FATFS_CODEPAGE_864 is not set -# CONFIG_FATFS_CODEPAGE_865 is not set -# CONFIG_FATFS_CODEPAGE_866 is not set -# CONFIG_FATFS_CODEPAGE_869 is not set -# CONFIG_FATFS_CODEPAGE_932 is not set -# CONFIG_FATFS_CODEPAGE_936 is not set -# CONFIG_FATFS_CODEPAGE_949 is not set -# CONFIG_FATFS_CODEPAGE_950 is not set -CONFIG_FATFS_CODEPAGE=437 -CONFIG_FATFS_LFN_NONE=y -# CONFIG_FATFS_LFN_HEAP is not set -# CONFIG_FATFS_LFN_STACK is not set -CONFIG_FATFS_FS_LOCK=0 -CONFIG_FATFS_TIMEOUT_MS=10000 -CONFIG_FATFS_PER_FILE_CACHE=y -# CONFIG_FATFS_USE_FASTSEEK is not set -# end of FAT Filesystem support - -# -# Modbus configuration -# -CONFIG_FMB_COMM_MODE_TCP_EN=y -CONFIG_FMB_TCP_PORT_DEFAULT=502 -CONFIG_FMB_TCP_PORT_MAX_CONN=5 -CONFIG_FMB_TCP_CONNECTION_TOUT_SEC=20 -CONFIG_FMB_COMM_MODE_RTU_EN=y -CONFIG_FMB_COMM_MODE_ASCII_EN=y -CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=150 -CONFIG_FMB_MASTER_DELAY_MS_CONVERT=200 -CONFIG_FMB_QUEUE_LENGTH=20 -CONFIG_FMB_PORT_TASK_STACK_SIZE=4096 -CONFIG_FMB_SERIAL_BUF_SIZE=256 -CONFIG_FMB_SERIAL_ASCII_BITS_PER_SYMB=8 -CONFIG_FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS=1000 -CONFIG_FMB_PORT_TASK_PRIO=10 -# CONFIG_FMB_PORT_TASK_AFFINITY_NO_AFFINITY is not set -CONFIG_FMB_PORT_TASK_AFFINITY_CPU0=y -# CONFIG_FMB_PORT_TASK_AFFINITY_CPU1 is not set -CONFIG_FMB_PORT_TASK_AFFINITY=0x0 -CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT=y -CONFIG_FMB_CONTROLLER_SLAVE_ID=0x00112233 -CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT=20 -CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 -CONFIG_FMB_CONTROLLER_STACK_SIZE=4096 -CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20 -# CONFIG_FMB_TIMER_PORT_ENABLED is not set -CONFIG_FMB_TIMER_GROUP=0 -CONFIG_FMB_TIMER_INDEX=0 -CONFIG_FMB_MASTER_TIMER_GROUP=0 -CONFIG_FMB_MASTER_TIMER_INDEX=0 -# CONFIG_FMB_TIMER_ISR_IN_IRAM is not set -# end of Modbus configuration - -# -# FreeRTOS -# -# CONFIG_FREERTOS_UNICORE is not set -CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF -CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER=y -CONFIG_FREERTOS_CORETIMER_0=y -# CONFIG_FREERTOS_CORETIMER_1 is not set -CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y -CONFIG_FREERTOS_HZ=100 -CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y -# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set -# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set -CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y -# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set -CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y -CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 -CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y -# CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set -# CONFIG_FREERTOS_ASSERT_DISABLE is not set -CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 -CONFIG_FREERTOS_ISR_STACKSIZE=1536 -# CONFIG_FREERTOS_LEGACY_HOOKS is not set -CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 -CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y -# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set -CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 -CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 -CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10 -CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 -# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set -# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set -CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y -CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y -# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set -# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set -CONFIG_FREERTOS_DEBUG_OCDAWARE=y -# CONFIG_FREERTOS_FPU_IN_ISR is not set -CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y -# CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set -# end of FreeRTOS - -# -# Hardware Abstraction Layer (HAL) and Low Level (LL) -# -CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y -# CONFIG_HAL_ASSERTION_DISABLE is not set -# CONFIG_HAL_ASSERTION_SILIENT is not set -# CONFIG_HAL_ASSERTION_ENABLE is not set -CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2 -# end of Hardware Abstraction Layer (HAL) and Low Level (LL) - -# -# Heap memory debugging -# -CONFIG_HEAP_POISONING_DISABLED=y -# CONFIG_HEAP_POISONING_LIGHT is not set -# CONFIG_HEAP_POISONING_COMPREHENSIVE is not set -CONFIG_HEAP_TRACING_OFF=y -# CONFIG_HEAP_TRACING_STANDALONE is not set -# CONFIG_HEAP_TRACING_TOHOST is not set -# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set -# end of Heap memory debugging - -# -# jsmn -# -# CONFIG_JSMN_PARENT_LINKS is not set -# CONFIG_JSMN_STRICT is not set -# end of jsmn - -# -# libsodium -# -# end of libsodium - -# -# Log output -# -# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set -# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set -# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set -CONFIG_LOG_DEFAULT_LEVEL_INFO=y -# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set -# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set -CONFIG_LOG_DEFAULT_LEVEL=3 -CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y -# CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set -# CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set -CONFIG_LOG_MAXIMUM_LEVEL=3 -CONFIG_LOG_COLORS=y -CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y -# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set -# end of Log output - -# -# LWIP -# -CONFIG_LWIP_LOCAL_HOSTNAME="espressif" -# CONFIG_LWIP_NETIF_API is not set -# CONFIG_LWIP_TCPIP_CORE_LOCKING is not set -CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y -# CONFIG_LWIP_L2_TO_L3_COPY is not set -# CONFIG_LWIP_IRAM_OPTIMIZATION is not set -CONFIG_LWIP_TIMERS_ONDEMAND=y -CONFIG_LWIP_MAX_SOCKETS=10 -# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set -# CONFIG_LWIP_SO_LINGER is not set -CONFIG_LWIP_SO_REUSE=y -CONFIG_LWIP_SO_REUSE_RXTOALL=y -# CONFIG_LWIP_SO_RCVBUF is not set -# CONFIG_LWIP_NETBUF_RECVINFO is not set -CONFIG_LWIP_IP4_FRAG=y -CONFIG_LWIP_IP6_FRAG=y -# CONFIG_LWIP_IP4_REASSEMBLY is not set -# CONFIG_LWIP_IP6_REASSEMBLY is not set -# CONFIG_LWIP_IP_FORWARD is not set -# CONFIG_LWIP_STATS is not set -# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set -CONFIG_LWIP_ESP_GRATUITOUS_ARP=y -CONFIG_LWIP_GARP_TMR_INTERVAL=60 -CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 -CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y -# CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set -CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y -# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set -CONFIG_LWIP_DHCP_OPTIONS_LEN=68 - -# -# DHCP server -# -CONFIG_LWIP_DHCPS=y -CONFIG_LWIP_DHCPS_LEASE_UNIT=60 -CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 -# end of DHCP server - -# CONFIG_LWIP_AUTOIP is not set -CONFIG_LWIP_IPV6=y -CONFIG_LWIP_IPV6_AUTOCONFIG=y -CONFIG_LWIP_IPV6_NUM_ADDRESSES=3 -# CONFIG_LWIP_IPV6_FORWARD is not set -CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS=0 -# CONFIG_LWIP_IPV6_DHCP6 is not set -# CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set -CONFIG_LWIP_NETIF_LOOPBACK=y -CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 - -# -# TCP -# -CONFIG_LWIP_MAX_ACTIVE_TCP=16 -CONFIG_LWIP_MAX_LISTENING_TCP=16 -CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y -CONFIG_LWIP_TCP_MAXRTX=12 -CONFIG_LWIP_TCP_SYNMAXRTX=12 -CONFIG_LWIP_TCP_MSS=1440 -CONFIG_LWIP_TCP_TMR_INTERVAL=250 -CONFIG_LWIP_TCP_MSL=60000 -CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744 -CONFIG_LWIP_TCP_WND_DEFAULT=5744 -CONFIG_LWIP_TCP_RECVMBOX_SIZE=6 -CONFIG_LWIP_TCP_QUEUE_OOSEQ=y -# CONFIG_LWIP_TCP_SACK_OUT is not set -# CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set -CONFIG_LWIP_TCP_OVERSIZE_MSS=y -# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set -# CONFIG_LWIP_TCP_OVERSIZE_DISABLE is not set -CONFIG_LWIP_TCP_RTO_TIME=1500 -# end of TCP - -# -# UDP -# -CONFIG_LWIP_MAX_UDP_PCBS=16 -CONFIG_LWIP_UDP_RECVMBOX_SIZE=6 -# end of UDP - -# -# Checksums -# -# CONFIG_LWIP_CHECKSUM_CHECK_IP is not set -# CONFIG_LWIP_CHECKSUM_CHECK_UDP is not set -CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y -# end of Checksums - -CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 -CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y -# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set -# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set -CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF -# CONFIG_LWIP_PPP_SUPPORT is not set -CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 -CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 -# CONFIG_LWIP_SLIP_SUPPORT is not set - -# -# ICMP -# -CONFIG_LWIP_ICMP=y -# CONFIG_LWIP_MULTICAST_PING is not set -# CONFIG_LWIP_BROADCAST_PING is not set -# end of ICMP - -# -# LWIP RAW API -# -CONFIG_LWIP_MAX_RAW_PCBS=16 -# end of LWIP RAW API - -# -# SNTP -# -CONFIG_LWIP_SNTP_MAX_SERVERS=1 -# CONFIG_LWIP_DHCP_GET_NTP_SRV is not set -CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 -# end of SNTP - -CONFIG_LWIP_ESP_LWIP_ASSERT=y - -# -# Hooks -# -# CONFIG_LWIP_HOOK_TCP_ISN_NONE is not set -CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT=y -# CONFIG_LWIP_HOOK_TCP_ISN_CUSTOM is not set -# CONFIG_LWIP_HOOK_IP6_ROUTE_NONE is not set -CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y -# CONFIG_LWIP_HOOK_IP6_ROUTE_CUSTOM is not set -# CONFIG_LWIP_HOOK_ND6_GET_GW_NONE is not set -CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y -# CONFIG_LWIP_HOOK_ND6_GET_GW_CUSTOM is not set -CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y -# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set -# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set -# end of Hooks - -# CONFIG_LWIP_DEBUG is not set -# end of LWIP - -# -# mbedTLS -# -CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y -# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set -# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set -CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y -CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 -CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 -# CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set -# CONFIG_MBEDTLS_DEBUG is not set - -# -# Certificate Bundle -# -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y -# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set -# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set -# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set -# end of Certificate Bundle - -CONFIG_MBEDTLS_ECP_RESTARTABLE=y -CONFIG_MBEDTLS_CMAC_C=y -CONFIG_MBEDTLS_HARDWARE_AES=y -CONFIG_MBEDTLS_HARDWARE_MPI=y -CONFIG_MBEDTLS_HARDWARE_SHA=y -CONFIG_MBEDTLS_ROM_MD5=y -# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set -# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set -CONFIG_MBEDTLS_HAVE_TIME=y -# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set -CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y -CONFIG_MBEDTLS_SHA512_C=y -CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y -# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set -# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set -# CONFIG_MBEDTLS_TLS_DISABLED is not set -CONFIG_MBEDTLS_TLS_SERVER=y -CONFIG_MBEDTLS_TLS_CLIENT=y -CONFIG_MBEDTLS_TLS_ENABLED=y - -# -# TLS Key Exchange Methods -# -# CONFIG_MBEDTLS_PSK_MODES is not set -CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y -# end of TLS Key Exchange Methods - -CONFIG_MBEDTLS_SSL_RENEGOTIATION=y -# CONFIG_MBEDTLS_SSL_PROTO_SSL3 is not set -CONFIG_MBEDTLS_SSL_PROTO_TLS1=y -CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y -CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y -# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set -# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set -CONFIG_MBEDTLS_SSL_ALPN=y -CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y -CONFIG_MBEDTLS_X509_CHECK_KEY_USAGE=y -CONFIG_MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE=y -CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y - -# -# Symmetric Ciphers -# -CONFIG_MBEDTLS_AES_C=y -# CONFIG_MBEDTLS_CAMELLIA_C is not set -# CONFIG_MBEDTLS_DES_C is not set -CONFIG_MBEDTLS_RC4_DISABLED=y -# CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT is not set -# CONFIG_MBEDTLS_RC4_ENABLED is not set -# CONFIG_MBEDTLS_BLOWFISH_C is not set -# CONFIG_MBEDTLS_XTEA_C is not set -CONFIG_MBEDTLS_CCM_C=y -CONFIG_MBEDTLS_GCM_C=y -# CONFIG_MBEDTLS_NIST_KW_C is not set -# end of Symmetric Ciphers - -# CONFIG_MBEDTLS_RIPEMD160_C is not set - -# -# Certificates -# -CONFIG_MBEDTLS_PEM_PARSE_C=y -CONFIG_MBEDTLS_PEM_WRITE_C=y -CONFIG_MBEDTLS_X509_CRL_PARSE_C=y -CONFIG_MBEDTLS_X509_CSR_PARSE_C=y -# end of Certificates - -CONFIG_MBEDTLS_ECP_C=y -CONFIG_MBEDTLS_ECDH_C=y -CONFIG_MBEDTLS_ECDSA_C=y -# CONFIG_MBEDTLS_ECJPAKE_C is not set -CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y -CONFIG_MBEDTLS_ECP_NIST_OPTIM=y -# CONFIG_MBEDTLS_POLY1305_C is not set -# CONFIG_MBEDTLS_CHACHA20_C is not set -# CONFIG_MBEDTLS_HKDF_C is not set -# CONFIG_MBEDTLS_THREADING_C is not set -# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set -# CONFIG_MBEDTLS_SECURITY_RISKS is not set -# end of mbedTLS - -# -# mDNS -# -CONFIG_MDNS_MAX_SERVICES=10 -CONFIG_MDNS_TASK_PRIORITY=1 -CONFIG_MDNS_TASK_STACK_SIZE=4096 -# CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY is not set -CONFIG_MDNS_TASK_AFFINITY_CPU0=y -# CONFIG_MDNS_TASK_AFFINITY_CPU1 is not set -CONFIG_MDNS_TASK_AFFINITY=0x0 -CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS=2000 -# CONFIG_MDNS_STRICT_MODE is not set -CONFIG_MDNS_TIMER_PERIOD_MS=100 -# CONFIG_MDNS_NETWORKING_SOCKET is not set -CONFIG_MDNS_MULTIPLE_INSTANCE=y -# end of mDNS - -# -# ESP-MQTT Configurations -# -CONFIG_MQTT_PROTOCOL_311=y -CONFIG_MQTT_TRANSPORT_SSL=y -CONFIG_MQTT_TRANSPORT_WEBSOCKET=y -CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y -# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set -# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set -# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set -# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set -# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set -# CONFIG_MQTT_CUSTOM_OUTBOX is not set -# end of ESP-MQTT Configurations - -# -# Newlib -# -CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y -# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set -# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set -# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set -# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set -CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y -# CONFIG_NEWLIB_NANO_FORMAT is not set -# end of Newlib - -# -# NVS -# -# end of NVS - -# -# OpenSSL -# -# CONFIG_OPENSSL_DEBUG is not set -CONFIG_OPENSSL_ERROR_STACK=y -# CONFIG_OPENSSL_ASSERT_DO_NOTHING is not set -CONFIG_OPENSSL_ASSERT_EXIT=y -# end of OpenSSL - -# -# OpenThread -# -# CONFIG_OPENTHREAD_ENABLED is not set -# end of OpenThread - -# -# PThreads -# -CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5 -CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 -CONFIG_PTHREAD_STACK_MIN=768 -CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY=y -# CONFIG_PTHREAD_DEFAULT_CORE_0 is not set -# CONFIG_PTHREAD_DEFAULT_CORE_1 is not set -CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 -CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" -# end of PThreads - -# -# SPI Flash driver -# -# CONFIG_SPI_FLASH_VERIFY_WRITE is not set -# CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set -CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y -CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y -# CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set -# CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set -# CONFIG_SPI_FLASH_USE_LEGACY_IMPL is not set -# CONFIG_SPI_FLASH_SHARE_SPI1_BUS is not set -# CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE is not set -CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y -CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=20 -CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=1 -CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192 -# CONFIG_SPI_FLASH_SIZE_OVERRIDE is not set -# CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED is not set -# CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST is not set - -# -# Auto-detect flash chips -# -CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y -CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y -CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y -CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP=y -# end of Auto-detect flash chips - -CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=y -# end of SPI Flash driver - -# -# SPIFFS Configuration -# -CONFIG_SPIFFS_MAX_PARTITIONS=3 - -# -# SPIFFS Cache Configuration -# -CONFIG_SPIFFS_CACHE=y -CONFIG_SPIFFS_CACHE_WR=y -# CONFIG_SPIFFS_CACHE_STATS is not set -# end of SPIFFS Cache Configuration - -CONFIG_SPIFFS_PAGE_CHECK=y -CONFIG_SPIFFS_GC_MAX_RUNS=10 -# CONFIG_SPIFFS_GC_STATS is not set -CONFIG_SPIFFS_PAGE_SIZE=256 -CONFIG_SPIFFS_OBJ_NAME_LEN=32 -# CONFIG_SPIFFS_FOLLOW_SYMLINKS is not set -CONFIG_SPIFFS_USE_MAGIC=y -CONFIG_SPIFFS_USE_MAGIC_LENGTH=y -CONFIG_SPIFFS_META_LENGTH=4 -CONFIG_SPIFFS_USE_MTIME=y - -# -# Debug Configuration -# -# CONFIG_SPIFFS_DBG is not set -# CONFIG_SPIFFS_API_DBG is not set -# CONFIG_SPIFFS_GC_DBG is not set -# CONFIG_SPIFFS_CACHE_DBG is not set -# CONFIG_SPIFFS_CHECK_DBG is not set -# CONFIG_SPIFFS_TEST_VISUALISATION is not set -# end of Debug Configuration -# end of SPIFFS Configuration - -# -# TCP Transport -# - -# -# Websocket -# -CONFIG_WS_TRANSPORT=y -CONFIG_WS_BUFFER_SIZE=1024 -# end of Websocket -# end of TCP Transport - -# -# Unity unit testing library -# -CONFIG_UNITY_ENABLE_FLOAT=y -CONFIG_UNITY_ENABLE_DOUBLE=y -# CONFIG_UNITY_ENABLE_64BIT is not set -# CONFIG_UNITY_ENABLE_COLOR is not set -CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y -# CONFIG_UNITY_ENABLE_FIXTURE is not set -# CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set -# end of Unity unit testing library - -# -# Virtual file system -# -CONFIG_VFS_SUPPORT_IO=y -CONFIG_VFS_SUPPORT_DIR=y -CONFIG_VFS_SUPPORT_SELECT=y -CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y -CONFIG_VFS_SUPPORT_TERMIOS=y - -# -# Host File System I/O (Semihosting) -# -CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 -CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 -# end of Host File System I/O (Semihosting) -# end of Virtual file system - -# -# Wear Levelling -# -# CONFIG_WL_SECTOR_SIZE_512 is not set -CONFIG_WL_SECTOR_SIZE_4096=y -CONFIG_WL_SECTOR_SIZE=4096 -# end of Wear Levelling - -# -# Wi-Fi Provisioning Manager -# -CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 -CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30 -# CONFIG_WIFI_PROV_BLE_BONDING is not set -# end of Wi-Fi Provisioning Manager - -# -# Supplicant -# -CONFIG_WPA_MBEDTLS_CRYPTO=y -# CONFIG_WPA_WAPI_PSK is not set -# CONFIG_WPA_SUITE_B_192 is not set -# CONFIG_WPA_DEBUG_PRINT is not set -# CONFIG_WPA_TESTING_OPTIONS is not set -# CONFIG_WPA_WPS_STRICT is not set -# CONFIG_WPA_11KV_SUPPORT is not set -# end of Supplicant - -# -# CHIP Core -# - -# -# General Options -# -CONFIG_MAX_EXCHANGE_CONTEXTS=8 -CONFIG_MAX_BINDINGS=8 -CONFIG_MAX_FABRICS=5 -CONFIG_MAX_PEER_NODES=16 -CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS=8 -# CONFIG_ENABLE_PW_RPC is not set -CONFIG_USE_MINIMAL_MDNS=y -CONFIG_ENABLE_CHIP_SHELL=y -# CONFIG_DISABLE_IPV4 is not set -CONFIG_BUILD_CHIP_TESTS=y -# end of General Options - -# -# Networking Options -# -CONFIG_NUM_TCP_ENDPOINTS=8 -CONFIG_NUM_UDP_ENDPOINTS=8 -CONFIG_MAX_CONNECTIONS=8 -CONFIG_DEFAULT_INCOMING_CONNECTION_IDLE_TIMEOUT=15000 -# end of Networking Options - -# -# System Options -# -CONFIG_NUM_TIMERS=32 -# CONFIG_ENABLE_OTA_REQUESTOR is not set -# end of System Options - -# -# Security Options -# -CONFIG_MAX_SESSION_KEYS=8 - -# -# Debugging -# -# CONFIG_SECURITY_TEST_MODE is not set -# CONFIG_DISABLE_PROVISIONING_AUTH is not set -# end of Debugging -# end of Security Options -# end of CHIP Core - -# -# CHIP Device Layer -# - -# -# General Options -# -CONFIG_CHIP_PROJECT_CONFIG="" -CONFIG_CHIP_TASK_STACK_SIZE=8192 -CONFIG_CHIP_TASK_PRIORITY=1 -CONFIG_MAX_EVENT_QUEUE_SIZE=25 -CONFIG_SERVICE_DIRECTORY_CACHE_SIZE=512 -# CONFIG_ENABLE_EXTENDED_DISCOVERY is not set -# CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE is not set -# end of General Options - -# -# Device Identification Options -# -CONFIG_DEVICE_VENDOR_ID=0xFFF1 -CONFIG_DEVICE_PRODUCT_ID=0x8001 -CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION=0 -CONFIG_DEVICE_SOFTWARE_VERSION="v1.0" -CONFIG_DEVICE_SOFTWARE_VERSION_NUMBER=1 -CONFIG_DEVICE_TYPE=0 -# end of Device Identification Options - -# -# WiFi Station Options -# -CONFIG_ENABLE_WIFI_STATION=y -CONFIG_DEFAULT_WIFI_SSID="" -CONFIG_DEFAULT_WIFI_PASSWORD="" -CONFIG_WIFI_STATION_RECONNECT_INTERVAL=5000 -CONFIG_MAX_SCAN_NETWORKS_RESULTS=10 -CONFIG_WIFI_SCAN_COMPLETION_TIMEOUT=10000 -CONFIG_WIFI_CONNECTIVITY_TIMEOUT=30000 -# end of WiFi Station Options - -# -# WiFi AP Options -# -CONFIG_ENABLE_WIFI_AP=y -CONFIG_WIFI_AP_SSID_PREFIX="MATTER-" -CONFIG_WIFI_AP_CHANNEL=1 -CONFIG_WIFI_AP_MAX_STATIONS=4 -CONFIG_WIFI_AP_BEACON_INTERVAL=100 -CONFIG_WIFI_AP_IDLE_TIMEOUT=120000 -# end of WiFi AP Options - -# -# BLE Options -# -CONFIG_ENABLE_CHIPOBLE=y -CONFIG_BLE_DEVICE_NAME_PREFIX="MATTER-" -CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MIN=40 -CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX=40 -CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN=800 -CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX=800 -CONFIG_CHIPOBLE_SINGLE_CONNECTION=y -# CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED is not set -# end of BLE Options - -# -# CHIP Trait Manager -# -CONFIG_ENABLE_TRAIT_MANAGER=y -# end of CHIP Trait Manager - -# -# Time Sync Options -# -CONFIG_ENABLE_SERVICE_DIRECTORY_TIME_SYNC=y -# CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC is not set -# end of Time Sync Options - -# -# Service Provisioning Options -# -CONFIG_SERVICE_PROVISIONING_ENDPOINT_ID=18B4300200000010 -CONFIG_SERVICE_PROVISIONING_CONNECTIVITY_TIMEOUT=10000 -CONFIG_SERVICE_PROVISIONING_REQUEST_TIMEOUT=10000 -# end of Service Provisioning Options - -# -# Commissioning options -# -CONFIG_RENDEZVOUS_WAIT_FOR_COMMISSIONING_COMPLETE=0 -# CONFIG_ENABLE_ROTATING_DEVICE_ID is not set -# CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER is not set -# end of Commissioning options - -# -# Testing Options -# -CONFIG_USE_TEST_SERIAL_NUMBER="TEST_SN" -CONFIG_ENABLE_TEST_SETUP_PARAMS=y -# CONFIG_ENABLE_FIXED_TUNNEL_SERVER is not set -# CONFIG_LOG_PROVISIONING_HASH is not set -# end of Testing Options - -# -# Network Telemetry Options -# -CONFIG_ENABLE_WIFI_TELEMETRY=y -# CONFIG_ENABLE_THREAD_TELEMETRY is not set -# CONFIG_ENABLE_THREAD_TELEMETRY_FULL is not set -# CONFIG_ENABLE_TUNNEL_TELEMETRY is not set -# end of Network Telemetry Options - -# -# Event Logging Options -# -CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE=4096 -CONFIG_EVENT_LOGGING_PROD_BUFFER_SIZE=2048 -CONFIG_EVENT_LOGGING_INFO_BUFFER_SIZE=1024 -CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE=1024 -CONFIG_CHIP_ENABLE_SCHEMA_CHECK=y -# end of Event Logging Options - -# -# Matter OTA Image -# -# CONFIG_CHIP_OTA_IMAGE_BUILD is not set -# end of Matter OTA Image - -# -# External Platform -# -# CONFIG_CHIP_ENABLE_EXTERNAL_PLATFORM is not set -# end of External Platform - -# -# Matter Manufacturing Options -# -CONFIG_CHIP_FACTORY_NAMESPACE_PARTITION_LABEL="nvs" -CONFIG_CHIP_CONFIG_NAMESPACE_PARTITION_LABEL="nvs" -CONFIG_CHIP_COUNTERS_NAMESPACE_PARTITION_LABEL="nvs" -# end of Matter Manufacturing Options -# end of CHIP Device Layer - -# -# TFT Display -# -CONFIG_TFT_PREDEFINED_DISPLAY_TYPE0=y -# CONFIG_TFT_PREDEFINED_DISPLAY_TYPE1 is not set -# CONFIG_TFT_PREDEFINED_DISPLAY_TYPE4 is not set -# CONFIG_TFT_PREDEFINED_DISPLAY_TYPE2 is not set -# CONFIG_TFT_PREDEFINED_DISPLAY_TYPE3 is not set -# CONFIG_TFT_PREDEFINED_DISPLAY_TYPE5 is not set -# CONFIG_TFT_PREDEFINED_DISPLAY_TYPE6 is not set -CONFIG_TFT_DISPLAY_CONTROLLER_MODEL=0 -CONFIG_TFT_DISPLAY_CONTROLLER_ILI9341=y -# CONFIG_TFT_DISPLAY_CONTROLLER_ILI9488 is not set -# CONFIG_TFT_DISPLAY_CONTROLLER_ST7789V is not set -# CONFIG_TFT_DISPLAY_CONTROLLER_ST7735 is not set -# CONFIG_TFT_DISPLAY_CONTROLLER_ST7735R is not set -# CONFIG_TFT_DISPLAY_CONTROLLER_ST7735B is not set -CONFIG_TFT_DISPLAY_WIDTH=240 -CONFIG_TFT_DISPLAY_HEIGHT=320 -# CONFIG_TFT_RGB_BGR is not set -CONFIG_TFT_TOUCH_CONTROLLER=0 -CONFIG_TFT_TOUCH_CONTROLLER0=y -# CONFIG_TFT_TOUCH_CONTROLLER1 is not set -# CONFIG_TFT_TOUCH_CONTROLLER2 is not set -# CONFIG_TFT_INVERT_ROTATION1 is not set -CONFIG_TFT_PIN_NUM_MOSI=23 -CONFIG_TFT_PIN_NUM_MISO=19 -CONFIG_TFT_PIN_NUM_CLK=18 -CONFIG_TFT_PIN_NUM_CS=5 -CONFIG_TFT_PIN_NUM_DC=26 -CONFIG_TFT_PIN_NUM_TCS=25 -CONFIG_TFT_PIN_NUM_RST=0 -CONFIG_TFT_PIN_NUM_BCKL=0 -# end of TFT Display -# end of Component config - -# -# Compatibility options -# -# CONFIG_LEGACY_INCLUDE_COMMON_HEADERS is not set -# end of Compatibility options diff --git a/examples/chef/efr32/src/AppTask.cpp b/examples/chef/efr32/src/AppTask.cpp index 9b2593f4736ef8..a14eece74d85d3 100644 --- a/examples/chef/efr32/src/AppTask.cpp +++ b/examples/chef/efr32/src/AppTask.cpp @@ -49,8 +49,6 @@ #include #include -#include - #include #include diff --git a/examples/light-switch-app/efr32/src/AppTask.cpp b/examples/light-switch-app/efr32/src/AppTask.cpp index 9fddca1d1aa98c..96459f9a188bb1 100644 --- a/examples/light-switch-app/efr32/src/AppTask.cpp +++ b/examples/light-switch-app/efr32/src/AppTask.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include diff --git a/examples/light-switch-app/telink/include/AppTask.h b/examples/light-switch-app/telink/include/AppTask.h index b682884b30155d..7fd67ff34abdad 100755 --- a/examples/light-switch-app/telink/include/AppTask.h +++ b/examples/light-switch-app/telink/include/AppTask.h @@ -20,7 +20,7 @@ #include "AppEvent.h" -#include +#include #include diff --git a/examples/light-switch-app/telink/prj.conf b/examples/light-switch-app/telink/prj.conf index 9e16c86b92c43e..05b92e9169eb6e 100755 --- a/examples/light-switch-app/telink/prj.conf +++ b/examples/light-switch-app/telink/prj.conf @@ -33,7 +33,7 @@ CONFIG_OPENTHREAD_PANID=4660 CONFIG_OPENTHREAD_CHANNEL=15 CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" -CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154" +CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154_b91" # Disable Matter OTA DFU CONFIG_CHIP_OTA_REQUESTOR=n diff --git a/examples/light-switch-app/telink/src/AppTask.cpp b/examples/light-switch-app/telink/src/AppTask.cpp index 7365515e0773f6..e8d3d0049dc095 100644 --- a/examples/light-switch-app/telink/src/AppTask.cpp +++ b/examples/light-switch-app/telink/src/AppTask.cpp @@ -50,8 +50,8 @@ #include "OTAUtil.h" #endif -#include -#include +#include +#include #include diff --git a/examples/light-switch-app/telink/src/main.cpp b/examples/light-switch-app/telink/src/main.cpp index 9c61b313f87569..6fdd0367cbe006 100755 --- a/examples/light-switch-app/telink/src/main.cpp +++ b/examples/light-switch-app/telink/src/main.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include LOG_MODULE_REGISTER(app); diff --git a/examples/lighting-app/efr32/src/AppTask.cpp b/examples/lighting-app/efr32/src/AppTask.cpp index 820cbe7049f44f..5735943282d21c 100644 --- a/examples/lighting-app/efr32/src/AppTask.cpp +++ b/examples/lighting-app/efr32/src/AppTask.cpp @@ -40,8 +40,6 @@ #include #include -#include - #include #include diff --git a/examples/lighting-app/esp32/main/main.cpp b/examples/lighting-app/esp32/main/main.cpp index 02381fd651fe0d..6e3aaf367f8512 100644 --- a/examples/lighting-app/esp32/main/main.cpp +++ b/examples/lighting-app/esp32/main/main.cpp @@ -22,7 +22,11 @@ #include #include "esp_log.h" +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) +#include "spi_flash_mmap.h" +#else #include "esp_spi_flash.h" +#endif #include "esp_system.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" diff --git a/examples/lighting-app/esp32/sdkconfig.defaults.esp32h2 b/examples/lighting-app/esp32/sdkconfig.defaults.esp32h2 index dc637d31dc7a2e..57c480716e0abd 100644 --- a/examples/lighting-app/esp32/sdkconfig.defaults.esp32h2 +++ b/examples/lighting-app/esp32/sdkconfig.defaults.esp32h2 @@ -20,7 +20,7 @@ CONFIG_BT_ENABLED=y CONFIG_BT_NIMBLE_ENABLED=y CONFIG_BT_NIMBLE_EXT_ADV=n CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70 -CONFIG_DEINIT_BLE_ON_COMMISSIONING_COMPLETE=n +CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING=n # Enable OpenThread CONFIG_OPENTHREAD_ENABLED=y diff --git a/examples/lighting-app/infineon/cyw30739/src/main.cpp b/examples/lighting-app/infineon/cyw30739/src/main.cpp index 136af11cb04fa7..639ca07595c304 100644 --- a/examples/lighting-app/infineon/cyw30739/src/main.cpp +++ b/examples/lighting-app/infineon/cyw30739/src/main.cpp @@ -27,6 +27,7 @@ #include #endif #include +#include #include #include #include @@ -54,6 +55,11 @@ static wiced_led_config_t chip_lighting_led_config = { .bright = 50, }; +// NOTE! This key is for test/certification only and should not be available in production devices! +uint8_t sTestEventTriggerEnableKey[chip::TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, + 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, + 0xcc, 0xdd, 0xee, 0xff }; + /********************************************************** * Identify Callbacks *********************************************************/ @@ -177,8 +183,10 @@ void InitApp(intptr_t args) // Print QR Code URL PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); /* Start CHIP datamodel server */ + static chip::OTATestEventTriggerDelegate testEventTriggerDelegate{ chip::ByteSpan(sTestEventTriggerEnableKey) }; static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); + initParams.testEventTriggerDelegate = &testEventTriggerDelegate; gExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; diff --git a/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn b/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn index c19ccbac46f23a..ff271fc042ffa4 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn +++ b/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn @@ -79,10 +79,13 @@ k32w0_executable("light_app") { "main/main.cpp", ] + public = [ "${chip_root}/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h" ] + deps = [ ":sdk", "${chip_root}/examples/common/QRCode", - "${chip_root}/examples/lighting-app/lighting-common/", + "${chip_root}/examples/lighting-app/nxp/zap/", + "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/lib", "${chip_root}/third_party/mbedtls:mbedtls", "${k32w0_platform_dir}/app/support:freertos_mbedtls_utils", @@ -113,16 +116,7 @@ k32w0_executable("light_app") { "-Wl,--defsym", "-Wl,__app_load_address__=0x4000", "-Wl,--defsym", - "-Wl,__app_stated_size__=0x99A00", - ] - } - - if (chip_enable_ota_requestor) { - ldflags += [ - "-Wl,--defsym", - "-Wl,__app_load_address__=0x4000", - "-Wl,--defsym", - "-Wl,__app_stated_size__=0x99A00", + "-Wl,__app_stated_size__=0x99200", ] } diff --git a/examples/lighting-app/nxp/k32w/k32w0/README.md b/examples/lighting-app/nxp/k32w/k32w0/README.md index 8ea1d9848debcd..6b7f6d83a44d6c 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/README.md +++ b/examples/lighting-app/nxp/k32w/k32w0/README.md @@ -22,6 +22,8 @@ network. - [Bluetooth LE Rendezvous](#bluetooth-le-rendezvous) - [Device UI](#device-ui) - [Building](#building) + - [Known issues](#building-issues) +- [Manufacturing data](#manufacturing) - [Flashing and debugging](#flashdebug) - [Pigweed Tokenizer](#tokenizer) - [Detokenizer script](#detokenizer) @@ -193,18 +195,15 @@ effects: In order to build the Project CHIP example, we recommend using a Linux distribution (the demo-application was compiled on Ubuntu 20.04). -- Download [K32W0 SDK 2.6.6 for Project CHIP](https://mcuxpresso.nxp.com/). - Creating an nxp.com account is required before being able to download the - SDK. Once the account is created, login and follow the steps for downloading - SDK_2_6_6_K32W061DK6 (required for K32W061 flavor). The SDK Builder UI - selection should be similar with the one from the image below. - ![MCUXpresso SDK Download](../../../../platform/nxp/k32w/k32w0/doc/images/mcux-sdk-download.JPG) +- Download + [K32W0 SDK 2.6.7](https://cache.nxp.com/lgfiles/bsps/SDK_2_6_7_K32W061DK6.zip). - Start building the application either with Secure Element or without - without Secure Element ``` -user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W0_SDK_ROOT=/home/user/Desktop/SDK_2_6_6_K32W061DK6/ +user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W0_SDK_ROOT=/home/user/Desktop/SDK_2_6_7_K32W061DK6/ +user@ubuntu:~/Desktop/git/connectedhomeip$ ./third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh user@ubuntu:~/Desktop/git/connectedhomeip$ source ./scripts/activate.sh user@ubuntu:~/Desktop/git/connectedhomeip$ cd examples/lighting-app/nxp/k32w/k32w0 user@ubuntu:~/Desktop/git/connectedhomeip/examples/lighting-app/nxp/k32w/k32w0$ gn gen out/debug --args="k32w0_sdk_root=\"${NXP_K32W0_SDK_ROOT}\" chip_with_OM15082=1 chip_with_ot_cli=0 is_debug=false chip_crypto=\"tinycrypt\" chip_with_se05x=0 chip_pw_tokenizer_logging=true mbedtls_repo=\"//third_party/connectedhomeip/third_party/nxp/libs/mbedtls\"" @@ -246,6 +245,20 @@ pycryptodome 3.9.8 The resulting output file can be found in out/debug/chip-k32w0x-light-example. + + +## Known issues + +- When using Secure element and cross-compiling on Linux, log messages from + the Plug&Trust middleware stack may not echo to the console. + + + +## Manufacturing data + +See +[Guide for writing manufacturing data on NXP devices](../../../../platform/nxp/doc/manufacturing_flow.md). + ## Flashing and debugging @@ -414,14 +427,14 @@ Here is the interpretation of the fields: Second, image directory 1 must be written: ``` -DK6Programmer.exe -V5 -s -P 1000000 -w image_dir_1=00400000CD040101 +DK6Programmer.exe -V5 -s -P 1000000 -w image_dir_1=00400000C9040101 ``` Here is the interpretation of the fields: ``` 00400000 -> start address 0x00004000 -CD04 -> 0x4CD pages of 512-bytes (= 614,5kB) +CD04 -> 0x4C9 pages of 512-bytes (= 612,5kB) 01 -> bootable flag 01 -> image type for the application ``` @@ -482,42 +495,42 @@ used for connecting the RPis to WiFi. Build the Linux OTA provider application: ``` -doru@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/ota-provider-app chip_config_network_layer_ble=false +user@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/ota-provider-app chip_config_network_layer_ble=false ``` Build OTA image and start the OTA Provider Application: ``` -doru@computer1:~/connectedhomeip$ : ./src/app/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 1 -vs "1.0" -da sha256 chip-k32w0x-light-example.bin chip-k32w0x-light-example.ota -doru@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_* -doru@computer1:~/connectedhomeip$ : ./out/ota-provider-app/chip-ota-provider-app -f chip-k32w0x-light-example.ota +user@computer1:~/connectedhomeip$ : ./src/app/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 1 -vs "1.0" -da sha256 chip-k32w0x-light-example.bin chip-k32w0x-light-example.ota +user@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_* +user@computer1:~/connectedhomeip$ : ./out/ota-provider-app/chip-ota-provider-app -f chip-k32w0x-light-example.ota ``` Build Linux chip-tool: ``` -doru@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/chip-tool out/chip-tool-app +user@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/chip-tool out/chip-tool-app ``` Provision the OTA provider application and assign node id _1_. Also, grant ACL entries to allow OTA requestors: ``` -doru@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_* -doru@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing onnetwork 1 20202021 -doru@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": null, "targets": null}]' 1 0 +user@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_* +user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing onnetwork 1 20202021 +user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": null, "targets": null}]' 1 0 ``` Provision the device and assign node id _2_: ``` -doru@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing ble-thread 2 hex: 20202021 3840 +user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing ble-thread 2 hex: 20202021 3840 ``` Start the OTA process: ``` -doru@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 0 2 0 +user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 0 2 0 ``` @@ -537,7 +550,7 @@ doru@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool otasoftwareupd command: ``` -doru@computer1:~/connectedhomeip$ : sudo docker kill $container_id +user@computer1:~/connectedhomeip$ : sudo docker kill $container_id ``` - In order to avoid MDNS issues, only one interface should be active at one @@ -545,8 +558,8 @@ doru@computer1:~/connectedhomeip$ : sudo docker kill $container_id disable multicast on that interface: ``` -doru@computer1:~/connectedhomeip$ sudo ip link set dev eth0 down -doru@computer1:~/connectedhomeip$ sudo ifconfig eth0 -multicast +user@computer1:~/connectedhomeip$ sudo ip link set dev eth0 down +user@computer1:~/connectedhomeip$ sudo ifconfig eth0 -multicast ``` - If OTBR Docker image is used, then the "-B" parameter should point to the diff --git a/examples/lighting-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h b/examples/lighting-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h index e0b01be6a7a421..e10bf8522eaf0b 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h +++ b/examples/lighting-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h @@ -34,20 +34,55 @@ // including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS. #define CHIP_CONFIG_SECURITY_TEST_MODE 0 -// Use a default setup PIN code if one hasn't been provisioned in flash. -#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 -#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 +// Use hard-coded test certificates already embedded in generic chip code => set it to 0 +// Use real/development certificates => set it to 1 + file the provisioning section from +// the internal flash +#ifndef CONFIG_CHIP_K32W0_REAL_FACTORY_DATA +#define CONFIG_CHIP_K32W0_REAL_FACTORY_DATA 0 +#endif -// Use a default pairing code if one hasn't been provisioned in flash. -#define CHIP_DEVICE_CONFIG_USE_TEST_PAIRING_CODE "CHIPUS" +#if CONFIG_CHIP_K32W0_REAL_FACTORY_DATA + +// VID/PID for product => will be used by Basic Information Cluster +#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0x1037 +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0xA220 + +// set it to 0 for the moment +#define CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER 0 + +#ifndef CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION +//-> format_version = 1 +//-> vendor_id = 0x1037 +//-> product_id_array = [ 0xA220 ] +//-> device_type_id = 0x0100 +//-> certificate_id = "ZIG20142ZB330003-24" +//-> security_level = 0 +//-> security_information = 0 +//-> version_number = 0x2694 +//-> certification_type = 1 +//-> dac_origin_vendor_id is not present +//-> dac_origin_product_id is not present +#define CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION \ + { \ + 0x30, 0x81, 0xe7, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0, 0x81, 0xd9, 0x30, 0x81, 0xd6, \ + 0x02, 0x01, 0x03, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, \ + 0x44, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x37, 0x04, 0x35, 0x15, 0x24, 0x00, \ + 0x01, 0x25, 0x01, 0x37, 0x10, 0x36, 0x02, 0x05, 0x20, 0xa2, 0x18, 0x25, 0x03, 0x00, 0x01, 0x2c, 0x04, 0x13, 0x5a, \ + 0x49, 0x47, 0x32, 0x30, 0x31, 0x34, 0x31, 0x5a, 0x42, 0x33, 0x33, 0x30, 0x30, 0x30, 0x31, 0x2d, 0x32, 0x34, 0x24, \ + 0x05, 0x00, 0x24, 0x06, 0x00, 0x24, 0x07, 0x01, 0x24, 0x08, 0x01, 0x18, 0x31, 0x7c, 0x30, 0x7a, 0x02, 0x01, 0x03, \ + 0x80, 0x14, 0x62, 0xfa, 0x82, 0x33, 0x59, 0xac, 0xfa, 0xa9, 0x96, 0x3e, 0x1c, 0xfa, 0x14, 0x0a, 0xdd, 0xf5, 0x04, \ + 0xf3, 0x71, 0x60, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, 0x0a, 0x06, \ + 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x04, 0x46, 0x30, 0x44, 0x02, 0x20, 0x5f, 0x32, 0xbc, 0x8b, \ + 0xa7, 0xd6, 0x1c, 0xfc, 0x6b, 0xc2, 0x1f, 0xbb, 0x42, 0xc2, 0xa7, 0x93, 0x45, 0x8a, 0xd9, 0xa6, 0x62, 0x15, 0xb6, \ + 0x93, 0xc4, 0x90, 0x24, 0xdf, 0xca, 0x03, 0x3a, 0x96, 0x02, 0x20, 0x5f, 0xc6, 0x62, 0x7a, 0x84, 0x49, 0x13, 0xf9, \ + 0x99, 0xd5, 0xbb, 0xab, 0xa0, 0x26, 0x22, 0xad, 0xdc, 0x32, 0xe6, 0x02, 0x2f, 0xf2, 0xaa, 0x52, 0x09, 0x86, 0x1d, \ + 0xe4, 0x76, 0x1b, 0xfd, 0x05, \ + } + +// All remaining data will be pulled from provisioning region of flash. +#endif -/** - * CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER - * - * Enables the use of a hard-coded default serial number if none - * is found in CHIP NV storage. - */ -#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN" +#else /** * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID @@ -63,6 +98,23 @@ */ #define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8005 +// Use a default setup PIN code if one hasn't been provisioned in flash. +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 + +// Use a default pairing code if one hasn't been provisioned in flash. +#define CHIP_DEVICE_CONFIG_USE_TEST_PAIRING_CODE "CHIPUS" + +/** + * CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER + * + * Enables the use of a hard-coded default serial number if none + * is found in CHIP NV storage. + */ +#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN" + +#endif + /** * CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION * @@ -126,7 +178,7 @@ * provision the device with its unique operational credentials and manage * its own access control lists. */ -#define CHIP_CONFIG_MAX_FABRICS 4 // 3 fabrics + 1 for rotation slack +#define CHIP_CONFIG_MAX_FABRICS 5 // 5 is the minimum number of supported fabrics /** * @def CHIP_IM_MAX_NUM_COMMAND_HANDLER @@ -156,3 +208,24 @@ #endif // BUILD_RELEASE #define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 + +/** + * CHIP_DEVICE_CONFIG_BLE_SET_PHY_2M_REQ + * + * This define enables/disables the Gap_LeSetPhy request to switch to 2M. + * It is disabled here for interoperability reasons just to be extra cautious. + * Both devices may send a Link Layer control procedure in parallel resulting in a + * LPM Error Transaction Collision. + * If the peer device doesn't accept our reject command, this can result in a BLE + * connection timeout. + */ +#define CHIP_DEVICE_CONFIG_BLE_SET_PHY_2M_REQ 0 + +/** + * CHIP_DEVICE_CONFIG_INIT_OTA_DELAY + * + * The amount of time in miliseconds after which OTA initialization should be + * scheduled after a new image is applied. + * + */ +#define CHIP_DEVICE_CONFIG_INIT_OTA_DELAY 3000 diff --git a/examples/lighting-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h b/examples/lighting-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h index 8c533831108e98..7990935565ce51 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h +++ b/examples/lighting-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h @@ -56,7 +56,10 @@ #define configUSE_ALTERNATIVE_API 0 /* Deprecated! */ #define configQUEUE_REGISTRY_SIZE 8 #define configUSE_QUEUE_SETS 0 -#define configUSE_TIME_SLICING 0 +/* make sure that Thread task can interrupt lengthy Matter + * processing in case priority inversion occurs + */ +#define configUSE_TIME_SLICING 1 #define configUSE_NEWLIB_REENTRANT 0 #define configENABLE_BACKWARD_COMPATIBILITY 1 #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp index 8d3f2f0bd0afac..ab05f79d417c4e 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp @@ -24,17 +24,19 @@ #include #include #include +#include #include #include #include - -#include +#include #include #include #include #include +#include + /* OTA related includes */ #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR #include "OTAImageProcessorImpl.h" @@ -56,6 +58,7 @@ #ifdef ENABLE_HSM_DEVICE_ATTESTATION #include "DeviceAttestationSe05xCredsExample.h" #endif +#include "CHIPProjectConfig.h" #define FACTORY_RESET_TRIGGER_TIMEOUT 6000 #define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 @@ -70,8 +73,9 @@ static QueueHandle_t sAppEventQueue; static LEDWidget sStatusLED; static LEDWidget sLightLED; -static bool sIsThreadProvisioned = false; -static bool sHaveBLEConnections = false; +static bool sIsThreadProvisioned = false; +static bool sHaveBLEConnections = false; +static bool sIsDnssdPlatformInitialized = false; static uint32_t eventMask = 0; @@ -85,6 +89,11 @@ using namespace chip; AppTask AppTask::sAppTask; +// This key is for testing/certification only and should not be used in production devices. +// For production devices this key must be provided from factory data. +uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; + static Identify gIdentify = { chip::EndpointId{ 1 }, AppTask::OnIdentifyStart, AppTask::OnIdentifyStop, EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, AppTask::OnTriggerEffect, // Use invalid value for identifiers to enable TriggerEffect command @@ -122,22 +131,30 @@ CHIP_ERROR AppTask::Init() { CHIP_ERROR err = CHIP_NO_ERROR; + PlatformMgr().AddEventHandler(MatterEventHandler, 0); + // Init ZCL Data Model and start server PlatformMgr().ScheduleWork(InitServer, 0); - // Initialize device attestation config +// Initialize device attestation config +#if CONFIG_CHIP_K32W0_REAL_FACTORY_DATA + // Initialize factory data provider + ReturnErrorOnFailure(K32W0FactoryDataProvider::GetDefaultInstance().Init()); +#if CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER + SetDeviceInstanceInfoProvider(&mK32W0FactoryDataProvider); +#endif + SetDeviceAttestationCredentialsProvider(&K32W0FactoryDataProvider::GetDefaultInstance()); + SetCommissionableDataProvider(&K32W0FactoryDataProvider::GetDefaultInstance()); +#else #ifdef ENABLE_HSM_DEVICE_ATTESTATION SetDeviceAttestationCredentialsProvider(Examples::GetExampleSe05xDACProvider()); #else SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif -#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR - PlatformMgr().ScheduleWork(InitOTA, 0); -#endif - // QR code will be used with CHIP Tool PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); +#endif /* HW init leds */ LED_Init(); @@ -185,8 +202,20 @@ CHIP_ERROR AppTask::Init() K32W_LOG("Current Software Version: %s", currentSoftwareVer); - PlatformMgr().AddEventHandler(ThreadProvisioningHandler, 0); - +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR + if (gImageProcessor.IsFirstImageRun()) + { + // If DNS-SD initialization was captured by MatterEventHandler, then + // OTA initialization will be started as soon as possible. Otherwise, + // a periodic timer is started until the DNS-SD initialization event + // is received. Configurable delay: CHIP_DEVICE_CONFIG_INIT_OTA_DELAY + AppTask::OnScheduleInitOTA(nullptr, nullptr); + } + else + { + PlatformMgr().ScheduleWork(AppTask::InitOTA, 0); + } +#endif return err; } @@ -205,7 +234,13 @@ void AppTask::InitServer(intptr_t arg) static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); + auto & infoProvider = chip::DeviceLayer::DeviceInfoProviderImpl::GetDefaultInstance(); + infoProvider.SetStorageDelegate(initParams.persistentStorageDelegate); + chip::DeviceLayer::SetDeviceInfoProvider(&infoProvider); + // Init ZCL Data Model and start server + static DefaultTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + initParams.testEventTriggerDelegate = &testEventTriggerDelegate; chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; nativeParams.lockCb = LockOpenThreadTask; nativeParams.unlockCb = UnlockOpenThreadTask; @@ -266,7 +301,7 @@ void AppTask::AppTaskMain(void * pvParameter) PlatformMgr().UnlockChipStack(); } - // Update the status LED if factory reset has not been initiated. + // Update the status LED if factory reset or identify process have not been initiated. // // If system has "full connectivity", keep the LED On constantly. // @@ -469,6 +504,8 @@ void AppTask::LightActionEventHandler(AppEvent * aEvent) } else if (aEvent->Type == AppEvent::kEventType_Button) { + actor = AppEvent::kEventType_Button; + if (LightingMgr().IsTurnedOff()) { action = LightingManager::TURNON_ACTION; @@ -524,6 +561,24 @@ void AppTask::PostOTAResume() event.Handler = OTAResumeEventHandler; sAppTask.PostEvent(&event); } + +void AppTask::OnScheduleInitOTA(chip::System::Layer * systemLayer, void * appState) +{ + if (sIsDnssdPlatformInitialized) + { + PlatformMgr().ScheduleWork(AppTask::InitOTA, 0); + } + else + { + CHIP_ERROR error = chip::DeviceLayer::SystemLayer().StartTimer( + chip::System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_INIT_OTA_DELAY), AppTask::OnScheduleInitOTA, nullptr); + + if (error != CHIP_NO_ERROR) + { + K32W_LOG("Failed to schedule OTA initialization timer."); + } + } +} #endif void AppTask::BleHandler(AppEvent * aEvent) @@ -536,7 +591,11 @@ void AppTask::BleHandler(AppEvent * aEvent) K32W_LOG("Another function is scheduled. Could not toggle BLE state!"); return; } + PlatformMgr().ScheduleWork(AppTask::BleStartAdvertising, 0); +} +void AppTask::BleStartAdvertising(intptr_t arg) +{ if (ConnectivityMgr().IsBLEAdvertisingEnabled()) { ConnectivityMgr().SetBLEAdvertisingEnabled(false); @@ -557,7 +616,7 @@ void AppTask::BleHandler(AppEvent * aEvent) } } -void AppTask::ThreadProvisioningHandler(const ChipDeviceEvent * event, intptr_t) +void AppTask::MatterEventHandler(const ChipDeviceEvent * event, intptr_t) { if (event->Type == DeviceEventType::kServiceProvisioningChange && event->ServiceProvisioningChange.IsServiceProvisioned) { @@ -576,6 +635,12 @@ void AppTask::ThreadProvisioningHandler(const ChipDeviceEvent * event, intptr_t) { sAppTask.PostOTAResume(); } + + if (event->Type == DeviceEventType::kDnssdPlatformInitialized) + { + K32W_LOG("Dnssd platform initialized."); + sIsDnssdPlatformInitialized = true; + } #endif #if CONFIG_CHIP_NFC_COMMISSIONING @@ -879,6 +944,7 @@ void AppTask::UpdateDeviceStateInternal(intptr_t arg) /* set the device state */ sLightLED.Set(onoffAttrValue); + LightingMgr().SetState(onoffAttrValue); } extern "C" void OTAIdleActivities(void) diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/LightingManager.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/LightingManager.cpp index af2dae0f3ff062..7a5cefc9b668fc 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/LightingManager.cpp +++ b/examples/lighting-app/nxp/k32w/k32w0/main/LightingManager.cpp @@ -39,6 +39,11 @@ void LightingManager::SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Ca mActionCompleted_CB = aActionCompleted_CB; } +void LightingManager::SetState(bool state) +{ + mState = state ? kState_On : kState_Off; +} + bool LightingManager::IsTurnedOff() { return (mState == kState_Off) ? true : false; diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/ZclCallbacks.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/ZclCallbacks.cpp index 0503bd2c71b488..5a4eee6e2c09e4 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/ZclCallbacks.cpp +++ b/examples/lighting-app/nxp/k32w/k32w0/main/ZclCallbacks.cpp @@ -68,23 +68,3 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(path.mAttributeId)); } } - -/** @brief OnOff Cluster Init - * - * This function is called when a specific cluster is initialized. It gives the - * application an opportunity to take care of cluster initialization procedures. - * It is called exactly once for each endpoint where cluster is present. - * - * @param endpoint Ver.: always - * - * TODO Issue #3841 - * emberAfOnOffClusterInitCallback happens before the stack initialize the cluster - * attributes to the default value. - * The logic here expects something similar to the deprecated Plugins callback - * emberAfPluginOnOffClusterServerPostInitCallback. - * - */ -void emberAfOnOffClusterInitCallback(EndpointId endpoint) -{ - GetAppTask().UpdateClusterState(); -} diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/include/AppEvent.h b/examples/lighting-app/nxp/k32w/k32w0/main/include/AppEvent.h index f067c2ed86368c..902c70b3cb656f 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/include/AppEvent.h +++ b/examples/lighting-app/nxp/k32w/k32w0/main/include/AppEvent.h @@ -25,7 +25,8 @@ struct AppEvent { enum AppEventTypes { - kEventType_Button = 0, + kEventType_None = 0, + kEventType_Button, kEventType_Timer, kEventType_TurnOn, kEventType_Install, diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/include/AppTask.h b/examples/lighting-app/nxp/k32w/k32w0/main/include/AppTask.h index fc8c164871d15e..e47c217bae169e 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/include/AppTask.h +++ b/examples/lighting-app/nxp/k32w/k32w0/main/include/AppTask.h @@ -22,6 +22,7 @@ #include #include "AppEvent.h" +#include "K32W0FactoryDataProvider.h" #include "LightingManager.h" #include @@ -73,6 +74,7 @@ class AppTask static void HandleKeyboard(void); static void OTAHandler(AppEvent * aEvent); static void BleHandler(AppEvent * aEvent); + static void BleStartAdvertising(intptr_t arg); static void LightActionEventHandler(AppEvent * aEvent); static void OTAResumeEventHandler(AppEvent * aEvent); static void ResetActionEventHandler(AppEvent * aEvent); @@ -81,7 +83,7 @@ class AppTask static void ButtonEventHandler(uint8_t pin_no, uint8_t button_action); static void TimerEventHandler(TimerHandle_t xTimer); - static void ThreadProvisioningHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); + static void MatterEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); void StartTimer(uint32_t aTimeoutInMs); static void RestoreLightingState(void); @@ -90,6 +92,7 @@ class AppTask static void InitOTA(intptr_t arg); static void StartOTAQuery(intptr_t arg); static void PostOTAResume(); + static void OnScheduleInitOTA(chip::System::Layer * systemLayer, void * appState); #endif static void UpdateClusterStateInternal(intptr_t arg); diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/include/LightingManager.h b/examples/lighting-app/nxp/k32w/k32w0/main/include/LightingManager.h index 6fa7aef75c0c27..327bf3bdf02763 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/include/LightingManager.h +++ b/examples/lighting-app/nxp/k32w/k32w0/main/include/LightingManager.h @@ -50,6 +50,7 @@ class LightingManager typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); typedef void (*Callback_fn_completed)(Action_t); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); + void SetState(bool state); private: friend LightingManager & LightingMgr(void); diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/main.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/main.cpp index 58091c8fba4dae..4c2ce040d2b786 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/main.cpp +++ b/examples/lighting-app/nxp/k32w/k32w0/main/main.cpp @@ -31,6 +31,14 @@ #include "FreeRtosHooks.h" #include "app_config.h" +#ifdef K32WMCM_APP_BUILD +#define string string_shadow +#include "AppApi.h" +#include "MMAC.h" +#include "mac_sap.h" +#undef string +#endif + using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; @@ -45,6 +53,31 @@ uint8_t __attribute__((section(".heap"))) ucHeap[HEAP_SIZE]; extern "C" void sched_enable(); +#define NORMAL_PWR_LIMIT 10 /* dBm */ + +#ifdef K32WMCM_APP_BUILD +/* Must be called before zps_eAplAfInit() */ +void APP_SetHighTxPowerMode(); + +/* Must be called after zps_eAplAfInit() */ +void APP_SetMaxTxPower(); + +#undef HIGH_TX_PWR_LIMIT +#define HIGH_TX_PWR_LIMIT 15 /* dBm */ +/* High Tx power */ +void APP_SetHighTxPowerMode() +{ + if (CHIP_IS_HITXPOWER_CAPABLE()) + vMMAC_SetTxPowerMode(TRUE); +} + +void APP_SetMaxTxPower() +{ + if (CHIP_IS_HITXPOWER_CAPABLE()) + eAppApiPlmeSet(PHY_PIB_ATTR_TX_POWER, HIGH_TX_PWR_LIMIT); +} +#endif + extern "C" void main_task(void const * argument) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -73,6 +106,10 @@ extern "C" void main_task(void const * argument) // Init Chip memory management before the stack chip::Platform::MemoryInit(); +#ifdef K32WMCM_APP_BUILD + APP_SetHighTxPowerMode(); +#endif + err = PlatformMgr().InitChipStack(); if (err != CHIP_NO_ERROR) { @@ -98,12 +135,12 @@ extern "C" void main_task(void const * argument) goto exit; } - err = PlatformMgr().StartEventLoopTask(); - if (err != CHIP_NO_ERROR) - { - K32W_LOG("Error during PlatformMgr().StartEventLoopTask();"); - goto exit; - } +#ifdef K32WMCM_APP_BUILD + APP_SetMaxTxPower(); + otPlatRadioSetTransmitPower(ThreadStackMgrImpl().OTInstance(), HIGH_TX_PWR_LIMIT); +#else + otPlatRadioSetTransmitPower(ThreadStackMgrImpl().OTInstance(), NORMAL_PWR_LIMIT); +#endif // Start OpenThread task err = ThreadStackMgrImpl().StartThreadTask(); @@ -120,6 +157,13 @@ extern "C" void main_task(void const * argument) goto exit; } + err = PlatformMgr().StartEventLoopTask(); + if (err != CHIP_NO_ERROR) + { + K32W_LOG("Error during PlatformMgr().StartEventLoopTask();"); + goto exit; + } + GetAppTask().AppTaskMain(NULL); exit: diff --git a/examples/lighting-app/nxp/zap/BUILD.gn b/examples/lighting-app/nxp/zap/BUILD.gn new file mode 100644 index 00000000000000..fd4026e2b9dbf7 --- /dev/null +++ b/examples/lighting-app/nxp/zap/BUILD.gn @@ -0,0 +1,25 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# 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. + +import("//build_overrides/chip.gni") +import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") +import("${chip_root}/src/app/chip_data_model.gni") + +chip_data_model("zap") { + zap_file = "lighting-on-off.zap" + + zap_pregenerated_dir = + "${chip_root}/zzz_generated/lighting-app/nxp/zap-generated" + is_server = true +} diff --git a/examples/lighting-app/nxp/zap/lighting-on-off.matter b/examples/lighting-app/nxp/zap/lighting-on-off.matter new file mode 100644 index 00000000000000..f3c1b5aba6a0b0 --- /dev/null +++ b/examples/lighting-app/nxp/zap/lighting-on-off.matter @@ -0,0 +1,1431 @@ +// This IDL was generated automatically by ZAP. +// It is for view/code review purposes only. + +server cluster Identify = 3 { + enum IdentifyEffectIdentifier : ENUM8 { + kBlink = 0; + kBreathe = 1; + kOkay = 2; + kChannelChange = 11; + kFinishEffect = 254; + kStopEffect = 255; + } + + enum IdentifyEffectVariant : ENUM8 { + kDefault = 0; + } + + enum IdentifyIdentifyType : ENUM8 { + kNone = 0; + kVisibleLight = 1; + kVisibleLED = 2; + kAudibleBeep = 3; + kDisplay = 4; + kActuator = 5; + } + + attribute int16u identifyTime = 0; + readonly attribute enum8 identifyType = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct IdentifyRequest { + INT16U identifyTime = 0; + } + + request struct TriggerEffectRequest { + IdentifyEffectIdentifier effectIdentifier = 0; + IdentifyEffectVariant effectVariant = 1; + } + + command access(invoke: manage) Identify(IdentifyRequest): DefaultSuccess = 0; + command access(invoke: manage) TriggerEffect(TriggerEffectRequest): DefaultSuccess = 64; +} + +server cluster Groups = 4 { + bitmap GroupClusterFeature : BITMAP32 { + kGroupNames = 0x1; + } + + readonly attribute bitmap8 nameSupport = 0; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AddGroupRequest { + group_id groupId = 0; + CHAR_STRING groupName = 1; + } + + request struct ViewGroupRequest { + group_id groupId = 0; + } + + request struct GetGroupMembershipRequest { + group_id groupList[] = 0; + } + + request struct RemoveGroupRequest { + group_id groupId = 0; + } + + request struct AddGroupIfIdentifyingRequest { + group_id groupId = 0; + CHAR_STRING groupName = 1; + } + + response struct AddGroupResponse = 0 { + ENUM8 status = 0; + group_id groupId = 1; + } + + response struct ViewGroupResponse = 1 { + ENUM8 status = 0; + group_id groupId = 1; + CHAR_STRING groupName = 2; + } + + response struct GetGroupMembershipResponse = 2 { + nullable INT8U capacity = 0; + group_id groupList[] = 1; + } + + response struct RemoveGroupResponse = 3 { + ENUM8 status = 0; + group_id groupId = 1; + } + + fabric command access(invoke: manage) AddGroup(AddGroupRequest): AddGroupResponse = 0; + fabric command ViewGroup(ViewGroupRequest): ViewGroupResponse = 1; + fabric command GetGroupMembership(GetGroupMembershipRequest): GetGroupMembershipResponse = 2; + fabric command access(invoke: manage) RemoveGroup(RemoveGroupRequest): RemoveGroupResponse = 3; + fabric command access(invoke: manage) RemoveAllGroups(): DefaultSuccess = 4; + fabric command access(invoke: manage) AddGroupIfIdentifying(AddGroupIfIdentifyingRequest): DefaultSuccess = 5; +} + +server cluster OnOff = 6 { + enum OnOffDelayedAllOffEffectVariant : ENUM8 { + kFadeToOffIn0p8Seconds = 0; + kNoFade = 1; + k50PercentDimDownIn0p8SecondsThenFadeToOffIn12Seconds = 2; + } + + enum OnOffDyingLightEffectVariant : ENUM8 { + k20PercenterDimUpIn0p5SecondsThenFadeToOffIn1Second = 0; + } + + enum OnOffEffectIdentifier : ENUM8 { + kDelayedAllOff = 0; + kDyingLight = 1; + } + + enum OnOffStartUpOnOff : ENUM8 { + kOff = 0; + kOn = 1; + kTogglePreviousOnOff = 2; + } + + bitmap OnOffControl : BITMAP8 { + kAcceptOnlyWhenOn = 0x1; + } + + bitmap OnOffFeature : BITMAP32 { + kLighting = 0x1; + } + + bitmap SceneFeatures : BITMAP32 { + kSceneNames = 0x1; + } + + readonly nosubscribe attribute boolean onOff = 0; + readonly attribute boolean globalSceneControl = 16384; + attribute int16u onTime = 16385; + attribute int16u offWaitTime = 16386; + attribute access(write: manage) nullable OnOffStartUpOnOff startUpOnOff = 16387; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct OffWithEffectRequest { + OnOffEffectIdentifier effectId = 0; + OnOffDelayedAllOffEffectVariant effectVariant = 1; + } + + request struct OnWithTimedOffRequest { + OnOffControl onOffControl = 0; + int16u onTime = 1; + int16u offWaitTime = 2; + } + + command Off(): DefaultSuccess = 0; + command On(): DefaultSuccess = 1; + command Toggle(): DefaultSuccess = 2; + command OffWithEffect(OffWithEffectRequest): DefaultSuccess = 64; + command OnWithRecallGlobalScene(): DefaultSuccess = 65; + command OnWithTimedOff(OnWithTimedOffRequest): DefaultSuccess = 66; +} + +server cluster LevelControl = 8 { + enum MoveMode : ENUM8 { + kUp = 0; + kDown = 1; + } + + enum StepMode : ENUM8 { + kUp = 0; + kDown = 1; + } + + bitmap LevelControlFeature : BITMAP32 { + kOnOff = 0x1; + kLighting = 0x2; + kFrequency = 0x4; + } + + readonly attribute nullable int8u currentLevel = 0; + readonly attribute int16u remainingTime = 1; + readonly attribute int8u minLevel = 2; + readonly attribute int8u maxLevel = 3; + attribute bitmap8 options = 15; + attribute nullable int8u onLevel = 17; + attribute access(write: manage) nullable int8u startUpCurrentLevel = 16384; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct MoveToLevelRequest { + INT8U level = 0; + nullable INT16U transitionTime = 1; + BITMAP8 optionsMask = 2; + BITMAP8 optionsOverride = 3; + } + + request struct MoveRequest { + MoveMode moveMode = 0; + nullable INT8U rate = 1; + BITMAP8 optionsMask = 2; + BITMAP8 optionsOverride = 3; + } + + request struct StepRequest { + StepMode stepMode = 0; + INT8U stepSize = 1; + nullable INT16U transitionTime = 2; + BITMAP8 optionsMask = 3; + BITMAP8 optionsOverride = 4; + } + + request struct StopRequest { + BITMAP8 optionsMask = 0; + BITMAP8 optionsOverride = 1; + } + + request struct MoveToLevelWithOnOffRequest { + INT8U level = 0; + nullable INT16U transitionTime = 1; + BITMAP8 optionsMask = 2; + BITMAP8 optionsOverride = 3; + } + + request struct MoveWithOnOffRequest { + MoveMode moveMode = 0; + nullable INT8U rate = 1; + BITMAP8 optionsMask = 2; + BITMAP8 optionsOverride = 3; + } + + request struct StepWithOnOffRequest { + StepMode stepMode = 0; + INT8U stepSize = 1; + nullable INT16U transitionTime = 2; + BITMAP8 optionsMask = 3; + BITMAP8 optionsOverride = 4; + } + + request struct StopWithOnOffRequest { + BITMAP8 optionsMask = 0; + BITMAP8 optionsOverride = 1; + } + + command MoveToLevel(MoveToLevelRequest): DefaultSuccess = 0; + command Move(MoveRequest): DefaultSuccess = 1; + command Step(StepRequest): DefaultSuccess = 2; + command Stop(StopRequest): DefaultSuccess = 3; + command MoveToLevelWithOnOff(MoveToLevelWithOnOffRequest): DefaultSuccess = 4; + command MoveWithOnOff(MoveWithOnOffRequest): DefaultSuccess = 5; + command StepWithOnOff(StepWithOnOffRequest): DefaultSuccess = 6; + command StopWithOnOff(StopWithOnOffRequest): DefaultSuccess = 7; +} + +server cluster Descriptor = 29 { + struct DeviceTypeStruct { + devtype_id type = 0; + int16u revision = 1; + } + + readonly attribute DeviceTypeStruct deviceTypeList[] = 0; + readonly attribute CLUSTER_ID serverList[] = 1; + readonly attribute CLUSTER_ID clientList[] = 2; + readonly attribute ENDPOINT_NO partsList[] = 3; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +server cluster AccessControl = 31 { + enum AuthMode : ENUM8 { + kPase = 1; + kCase = 2; + kGroup = 3; + } + + enum ChangeTypeEnum : ENUM8 { + kChanged = 0; + kAdded = 1; + kRemoved = 2; + } + + enum Privilege : ENUM8 { + kView = 1; + kProxyView = 2; + kOperate = 3; + kManage = 4; + kAdminister = 5; + } + + struct AccessControlEntry { + Privilege privilege = 1; + AuthMode authMode = 2; + nullable int64u subjects[] = 3; + nullable Target targets[] = 4; + fabric_idx fabricIndex = 254; + } + + struct Target { + nullable cluster_id cluster = 0; + nullable endpoint_no endpoint = 1; + nullable devtype_id deviceType = 2; + } + + info event access(read: administer) AccessControlEntryChanged = 0 { + nullable node_id adminNodeID = 1; + nullable INT16U adminPasscodeID = 2; + ChangeTypeEnum changeType = 3; + nullable AccessControlEntry latestValue = 4; + fabric_idx fabricIndex = 254; + } + + info event access(read: administer) AccessControlExtensionChanged = 1 { + nullable node_id adminNodeID = 1; + nullable INT16U adminPasscodeID = 2; + ChangeTypeEnum changeType = 3; + nullable ExtensionEntry latestValue = 4; + fabric_idx fabricIndex = 254; + } + + attribute access(read: administer, write: administer) AccessControlEntry acl[] = 0; + readonly attribute int16u subjectsPerAccessControlEntry = 2; + readonly attribute int16u targetsPerAccessControlEntry = 3; + readonly attribute int16u accessControlEntriesPerFabric = 4; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +server cluster Basic = 40 { + struct CapabilityMinimaStruct { + int16u caseSessionsPerFabric = 0; + int16u subscriptionsPerFabric = 1; + } + + critical event StartUp = 0 { + INT32U softwareVersion = 0; + } + + critical event ShutDown = 1 { + } + + info event Leave = 2 { + fabric_idx fabricIndex = 0; + } + + info event ReachableChanged = 3 { + boolean reachableNewValue = 0; + } + + readonly attribute int16u dataModelRevision = 0; + readonly attribute char_string<32> vendorName = 1; + readonly attribute vendor_id vendorID = 2; + readonly attribute char_string<32> productName = 3; + readonly attribute int16u productID = 4; + attribute access(write: manage) char_string<32> nodeLabel = 5; + attribute access(write: administer) char_string<2> location = 6; + readonly attribute int16u hardwareVersion = 7; + readonly attribute char_string<64> hardwareVersionString = 8; + readonly attribute int32u softwareVersion = 9; + readonly attribute char_string<64> softwareVersionString = 10; + readonly attribute CapabilityMinimaStruct capabilityMinima = 19; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +client cluster OtaSoftwareUpdateProvider = 41 { + enum OTAApplyUpdateAction : ENUM8 { + kProceed = 0; + kAwaitNextAction = 1; + kDiscontinue = 2; + } + + enum OTADownloadProtocol : ENUM8 { + kBDXSynchronous = 0; + kBDXAsynchronous = 1; + kHttps = 2; + kVendorSpecific = 3; + } + + enum OTAQueryStatus : ENUM8 { + kUpdateAvailable = 0; + kBusy = 1; + kNotAvailable = 2; + kDownloadProtocolNotSupported = 3; + } + + readonly attribute int16u clusterRevision = 65533; + + request struct QueryImageRequest { + vendor_id vendorId = 0; + INT16U productId = 1; + INT32U softwareVersion = 2; + OTADownloadProtocol protocolsSupported[] = 3; + optional INT16U hardwareVersion = 4; + optional CHAR_STRING<2> location = 5; + optional BOOLEAN requestorCanConsent = 6; + optional OCTET_STRING<512> metadataForProvider = 7; + } + + request struct ApplyUpdateRequestRequest { + OCTET_STRING<32> updateToken = 0; + INT32U newVersion = 1; + } + + request struct NotifyUpdateAppliedRequest { + OCTET_STRING<32> updateToken = 0; + INT32U softwareVersion = 1; + } + + response struct QueryImageResponse = 1 { + OTAQueryStatus status = 0; + optional INT32U delayedActionTime = 1; + optional CHAR_STRING<256> imageURI = 2; + optional INT32U softwareVersion = 3; + optional CHAR_STRING<64> softwareVersionString = 4; + optional OCTET_STRING<32> updateToken = 5; + optional BOOLEAN userConsentNeeded = 6; + optional OCTET_STRING<512> metadataForRequestor = 7; + } + + response struct ApplyUpdateResponse = 3 { + OTAApplyUpdateAction action = 0; + INT32U delayedActionTime = 1; + } + + command QueryImage(QueryImageRequest): QueryImageResponse = 0; + command ApplyUpdateRequest(ApplyUpdateRequestRequest): ApplyUpdateResponse = 2; + command NotifyUpdateApplied(NotifyUpdateAppliedRequest): DefaultSuccess = 4; +} + +server cluster OtaSoftwareUpdateRequestor = 42 { + enum OTAAnnouncementReason : ENUM8 { + kSimpleAnnouncement = 0; + kUpdateAvailable = 1; + kUrgentUpdateAvailable = 2; + } + + enum OTAChangeReasonEnum : ENUM8 { + kUnknown = 0; + kSuccess = 1; + kFailure = 2; + kTimeOut = 3; + kDelayByProvider = 4; + } + + enum OTAUpdateStateEnum : ENUM8 { + kUnknown = 0; + kIdle = 1; + kQuerying = 2; + kDelayedOnQuery = 3; + kDownloading = 4; + kApplying = 5; + kDelayedOnApply = 6; + kRollingBack = 7; + kDelayedOnUserConsent = 8; + } + + struct ProviderLocation { + node_id providerNodeID = 1; + endpoint_no endpoint = 2; + fabric_idx fabricIndex = 254; + } + + info event StateTransition = 0 { + OTAUpdateStateEnum previousState = 0; + OTAUpdateStateEnum newState = 1; + OTAChangeReasonEnum reason = 2; + nullable INT32U targetSoftwareVersion = 3; + } + + critical event VersionApplied = 1 { + INT32U softwareVersion = 0; + INT16U productID = 1; + } + + info event DownloadError = 2 { + INT32U softwareVersion = 0; + INT64U bytesDownloaded = 1; + nullable INT8U progressPercent = 2; + nullable INT64S platformCode = 3; + } + + attribute ProviderLocation defaultOtaProviders[] = 0; + readonly attribute boolean updatePossible = 1; + readonly attribute OTAUpdateStateEnum updateState = 2; + readonly attribute nullable int8u updateStateProgress = 3; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AnnounceOtaProviderRequest { + node_id providerNodeId = 0; + vendor_id vendorId = 1; + OTAAnnouncementReason announcementReason = 2; + optional OCTET_STRING<512> metadataForNode = 3; + endpoint_no endpoint = 4; + } + + command AnnounceOtaProvider(AnnounceOtaProviderRequest): DefaultSuccess = 0; +} + +server cluster GeneralCommissioning = 48 { + enum CommissioningError : ENUM8 { + kOk = 0; + kValueOutsideRange = 1; + kInvalidAuthentication = 2; + kNoFailSafe = 3; + kBusyWithOtherAdmin = 4; + } + + enum RegulatoryLocationType : ENUM8 { + kIndoor = 0; + kOutdoor = 1; + kIndoorOutdoor = 2; + } + + struct BasicCommissioningInfo { + int16u failSafeExpiryLengthSeconds = 0; + int16u maxCumulativeFailsafeSeconds = 1; + } + + attribute access(write: administer) int64u breadcrumb = 0; + readonly attribute BasicCommissioningInfo basicCommissioningInfo = 1; + readonly attribute RegulatoryLocationType regulatoryConfig = 2; + readonly attribute RegulatoryLocationType locationCapability = 3; + readonly attribute boolean supportsConcurrentConnection = 4; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct ArmFailSafeRequest { + INT16U expiryLengthSeconds = 0; + INT64U breadcrumb = 1; + } + + request struct SetRegulatoryConfigRequest { + RegulatoryLocationType newRegulatoryConfig = 0; + CHAR_STRING countryCode = 1; + INT64U breadcrumb = 2; + } + + response struct ArmFailSafeResponse = 1 { + CommissioningError errorCode = 0; + CHAR_STRING debugText = 1; + } + + response struct SetRegulatoryConfigResponse = 3 { + CommissioningError errorCode = 0; + CHAR_STRING debugText = 1; + } + + response struct CommissioningCompleteResponse = 5 { + CommissioningError errorCode = 0; + CHAR_STRING debugText = 1; + } + + command access(invoke: administer) ArmFailSafe(ArmFailSafeRequest): ArmFailSafeResponse = 0; + command access(invoke: administer) SetRegulatoryConfig(SetRegulatoryConfigRequest): SetRegulatoryConfigResponse = 2; + fabric command access(invoke: administer) CommissioningComplete(): CommissioningCompleteResponse = 4; +} + +server cluster NetworkCommissioning = 49 { + enum NetworkCommissioningStatus : ENUM8 { + kSuccess = 0; + kOutOfRange = 1; + kBoundsExceeded = 2; + kNetworkIDNotFound = 3; + kDuplicateNetworkID = 4; + kNetworkNotFound = 5; + kRegulatoryError = 6; + kAuthFailure = 7; + kUnsupportedSecurity = 8; + kOtherConnectionFailure = 9; + kIPV6Failed = 10; + kIPBindFailed = 11; + kUnknownError = 12; + } + + enum WiFiBand : ENUM8 { + k2g4 = 0; + k3g65 = 1; + k5g = 2; + k6g = 3; + k60g = 4; + } + + bitmap NetworkCommissioningFeature : BITMAP32 { + kWiFiNetworkInterface = 0x1; + kThreadNetworkInterface = 0x2; + kEthernetNetworkInterface = 0x4; + } + + bitmap WiFiSecurity : BITMAP8 { + kUnencrypted = 0x1; + kWepPersonal = 0x2; + kWpaPersonal = 0x4; + kWpa2Personal = 0x8; + kWpa3Personal = 0x10; + } + + struct NetworkInfo { + octet_string<32> networkID = 0; + boolean connected = 1; + } + + struct WiFiInterfaceScanResult { + WiFiSecurity security = 0; + octet_string<32> ssid = 1; + octet_string<6> bssid = 2; + int16u channel = 3; + WiFiBand wiFiBand = 4; + int8s rssi = 5; + } + + struct ThreadInterfaceScanResult { + int16u panId = 0; + int64u extendedPanId = 1; + char_string<16> networkName = 2; + int16u channel = 3; + int8u version = 4; + octet_string<8> extendedAddress = 5; + int8s rssi = 6; + int8u lqi = 7; + } + + readonly attribute access(read: administer) int8u maxNetworks = 0; + readonly attribute access(read: administer) NetworkInfo networks[] = 1; + readonly attribute int8u scanMaxTimeSeconds = 2; + readonly attribute int8u connectMaxTimeSeconds = 3; + attribute access(write: administer) boolean interfaceEnabled = 4; + readonly attribute access(read: administer) nullable NetworkCommissioningStatus lastNetworkingStatus = 5; + readonly attribute access(read: administer) nullable octet_string<32> lastNetworkID = 6; + readonly attribute access(read: administer) nullable int32s lastConnectErrorValue = 7; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct ScanNetworksRequest { + optional nullable OCTET_STRING<32> ssid = 0; + optional INT64U breadcrumb = 1; + } + + request struct AddOrUpdateThreadNetworkRequest { + OCTET_STRING<254> operationalDataset = 0; + optional INT64U breadcrumb = 1; + } + + request struct RemoveNetworkRequest { + OCTET_STRING<32> networkID = 0; + optional INT64U breadcrumb = 1; + } + + request struct ConnectNetworkRequest { + OCTET_STRING<32> networkID = 0; + optional INT64U breadcrumb = 1; + } + + request struct ReorderNetworkRequest { + OCTET_STRING<32> networkID = 0; + INT8U networkIndex = 1; + optional INT64U breadcrumb = 2; + } + + response struct ScanNetworksResponse = 1 { + NetworkCommissioningStatus networkingStatus = 0; + optional CHAR_STRING debugText = 1; + optional WiFiInterfaceScanResult wiFiScanResults[] = 2; + optional ThreadInterfaceScanResult threadScanResults[] = 3; + } + + response struct NetworkConfigResponse = 5 { + NetworkCommissioningStatus networkingStatus = 0; + optional CHAR_STRING<512> debugText = 1; + optional INT8U networkIndex = 2; + } + + response struct ConnectNetworkResponse = 7 { + NetworkCommissioningStatus networkingStatus = 0; + optional CHAR_STRING debugText = 1; + nullable INT32S errorValue = 2; + } + + command access(invoke: administer) ScanNetworks(ScanNetworksRequest): ScanNetworksResponse = 0; + command access(invoke: administer) AddOrUpdateThreadNetwork(AddOrUpdateThreadNetworkRequest): NetworkConfigResponse = 3; + command access(invoke: administer) RemoveNetwork(RemoveNetworkRequest): NetworkConfigResponse = 4; + command access(invoke: administer) ConnectNetwork(ConnectNetworkRequest): ConnectNetworkResponse = 6; + command access(invoke: administer) ReorderNetwork(ReorderNetworkRequest): NetworkConfigResponse = 8; +} + +server cluster GeneralDiagnostics = 51 { + enum BootReasonType : ENUM8 { + kUnspecified = 0; + kPowerOnReboot = 1; + kBrownOutReset = 2; + kSoftwareWatchdogReset = 3; + kHardwareWatchdogReset = 4; + kSoftwareUpdateCompleted = 5; + kSoftwareReset = 6; + } + + enum HardwareFaultType : ENUM8 { + kUnspecified = 0; + kRadio = 1; + kSensor = 2; + kResettableOverTemp = 3; + kNonResettableOverTemp = 4; + kPowerSource = 5; + kVisualDisplayFault = 6; + kAudioOutputFault = 7; + kUserInterfaceFault = 8; + kNonVolatileMemoryError = 9; + kTamperDetected = 10; + } + + enum InterfaceType : ENUM8 { + kUnspecified = 0; + kWiFi = 1; + kEthernet = 2; + kCellular = 3; + kThread = 4; + } + + enum NetworkFaultType : ENUM8 { + kUnspecified = 0; + kHardwareFailure = 1; + kNetworkJammed = 2; + kConnectionFailed = 3; + } + + enum RadioFaultType : ENUM8 { + kUnspecified = 0; + kWiFiFault = 1; + kCellularFault = 2; + kThreadFault = 3; + kNFCFault = 4; + kBLEFault = 5; + kEthernetFault = 6; + } + + struct NetworkInterfaceType { + char_string<32> name = 0; + boolean isOperational = 1; + nullable boolean offPremiseServicesReachableIPv4 = 2; + nullable boolean offPremiseServicesReachableIPv6 = 3; + octet_string<8> hardwareAddress = 4; + octet_string IPv4Addresses[] = 5; + octet_string IPv6Addresses[] = 6; + InterfaceType type = 7; + } + + critical event HardwareFaultChange = 0 { + HardwareFaultType current[] = 0; + HardwareFaultType previous[] = 1; + } + + critical event RadioFaultChange = 1 { + RadioFaultType current[] = 0; + RadioFaultType previous[] = 1; + } + + critical event NetworkFaultChange = 2 { + NetworkFaultType current[] = 0; + NetworkFaultType previous[] = 1; + } + + critical event BootReason = 3 { + BootReasonType bootReason = 0; + } + + readonly attribute NetworkInterfaceType networkInterfaces[] = 0; + readonly attribute int16u rebootCount = 1; + readonly attribute boolean testEventTriggersEnabled = 8; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct TestEventTriggerRequest { + OCTET_STRING<16> enableKey = 0; + INT64U eventTrigger = 1; + } + + command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; +} + +server cluster SoftwareDiagnostics = 52 { + bitmap SoftwareDiagnosticsFeature : BITMAP32 { + kWaterMarks = 0x1; + } + + struct ThreadMetrics { + int64u id = 0; + optional char_string<8> name = 1; + optional int32u stackFreeCurrent = 2; + optional int32u stackFreeMinimum = 3; + optional int32u stackSize = 4; + } + + info event SoftwareFault = 0 { + INT64U id = 0; + optional CHAR_STRING name = 1; + optional OCTET_STRING faultRecording = 2; + } + + readonly attribute ThreadMetrics threadMetrics[] = 0; + readonly attribute int64u currentHeapFree = 1; + readonly attribute int64u currentHeapUsed = 2; + readonly attribute int64u currentHeapHighWatermark = 3; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + command ResetWatermarks(): DefaultSuccess = 0; +} + +server cluster ThreadNetworkDiagnostics = 53 { + enum NetworkFault : ENUM8 { + kUnspecified = 0; + kLinkDown = 1; + kHardwareFailure = 2; + kNetworkJammed = 3; + } + + enum RoutingRole : ENUM8 { + kUnspecified = 0; + kUnassigned = 1; + kSleepyEndDevice = 2; + kEndDevice = 3; + kReed = 4; + kRouter = 5; + kLeader = 6; + } + + enum ThreadConnectionStatus : ENUM8 { + kConnected = 0; + kNotConnected = 1; + } + + bitmap ThreadNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + kMLECounts = 0x4; + kMACCounts = 0x8; + } + + struct NeighborTable { + int64u extAddress = 0; + int32u age = 1; + int16u rloc16 = 2; + int32u linkFrameCounter = 3; + int32u mleFrameCounter = 4; + int8u lqi = 5; + nullable int8s averageRssi = 6; + nullable int8s lastRssi = 7; + int8u frameErrorRate = 8; + int8u messageErrorRate = 9; + boolean rxOnWhenIdle = 10; + boolean fullThreadDevice = 11; + boolean fullNetworkData = 12; + boolean isChild = 13; + } + + struct RouteTable { + int64u extAddress = 0; + int16u rloc16 = 1; + int8u routerId = 2; + int8u nextHop = 3; + int8u pathCost = 4; + int8u LQIIn = 5; + int8u LQIOut = 6; + int8u age = 7; + boolean allocated = 8; + boolean linkEstablished = 9; + } + + struct SecurityPolicy { + int16u rotationTime = 0; + bitmap16 flags = 1; + } + + struct OperationalDatasetComponents { + boolean activeTimestampPresent = 0; + boolean pendingTimestampPresent = 1; + boolean masterKeyPresent = 2; + boolean networkNamePresent = 3; + boolean extendedPanIdPresent = 4; + boolean meshLocalPrefixPresent = 5; + boolean delayPresent = 6; + boolean panIdPresent = 7; + boolean channelPresent = 8; + boolean pskcPresent = 9; + boolean securityPolicyPresent = 10; + boolean channelMaskPresent = 11; + } + + info event ConnectionStatus = 0 { + ThreadConnectionStatus connectionStatus = 0; + } + + info event NetworkFaultChange = 1 { + NetworkFault current[] = 0; + NetworkFault previous[] = 1; + } + + readonly attribute nullable int16u channel = 0; + readonly attribute nullable RoutingRole routingRole = 1; + readonly attribute nullable char_string<16> networkName = 2; + readonly attribute nullable int16u panId = 3; + readonly attribute nullable int64u extendedPanId = 4; + readonly attribute nullable octet_string<17> meshLocalPrefix = 5; + readonly attribute int64u overrunCount = 6; + readonly attribute NeighborTable neighborTableList[] = 7; + readonly attribute RouteTable routeTableList[] = 8; + readonly attribute nullable int32u partitionId = 9; + readonly attribute nullable int8u weighting = 10; + readonly attribute nullable int8u dataVersion = 11; + readonly attribute nullable int8u stableDataVersion = 12; + readonly attribute nullable int8u leaderRouterId = 13; + readonly attribute int16u detachedRoleCount = 14; + readonly attribute int16u childRoleCount = 15; + readonly attribute int16u routerRoleCount = 16; + readonly attribute int16u leaderRoleCount = 17; + readonly attribute int16u attachAttemptCount = 18; + readonly attribute int16u partitionIdChangeCount = 19; + readonly attribute int16u betterPartitionAttachAttemptCount = 20; + readonly attribute int16u parentChangeCount = 21; + readonly attribute int32u txTotalCount = 22; + readonly attribute int32u txUnicastCount = 23; + readonly attribute int32u txBroadcastCount = 24; + readonly attribute int32u txAckRequestedCount = 25; + readonly attribute int32u txAckedCount = 26; + readonly attribute int32u txNoAckRequestedCount = 27; + readonly attribute int32u txDataCount = 28; + readonly attribute int32u txDataPollCount = 29; + readonly attribute int32u txBeaconCount = 30; + readonly attribute int32u txBeaconRequestCount = 31; + readonly attribute int32u txOtherCount = 32; + readonly attribute int32u txRetryCount = 33; + readonly attribute int32u txDirectMaxRetryExpiryCount = 34; + readonly attribute int32u txIndirectMaxRetryExpiryCount = 35; + readonly attribute int32u txErrCcaCount = 36; + readonly attribute int32u txErrAbortCount = 37; + readonly attribute int32u txErrBusyChannelCount = 38; + readonly attribute int32u rxTotalCount = 39; + readonly attribute int32u rxUnicastCount = 40; + readonly attribute int32u rxBroadcastCount = 41; + readonly attribute int32u rxDataCount = 42; + readonly attribute int32u rxDataPollCount = 43; + readonly attribute int32u rxBeaconCount = 44; + readonly attribute int32u rxBeaconRequestCount = 45; + readonly attribute int32u rxOtherCount = 46; + readonly attribute int32u rxAddressFilteredCount = 47; + readonly attribute int32u rxDestAddrFilteredCount = 48; + readonly attribute int32u rxDuplicatedCount = 49; + readonly attribute int32u rxErrNoFrameCount = 50; + readonly attribute int32u rxErrUnknownNeighborCount = 51; + readonly attribute int32u rxErrInvalidSrcAddrCount = 52; + readonly attribute int32u rxErrSecCount = 53; + readonly attribute int32u rxErrFcsCount = 54; + readonly attribute int32u rxErrOtherCount = 55; + readonly attribute nullable SecurityPolicy securityPolicy = 59; + readonly attribute nullable octet_string<4> channelPage0Mask = 60; + readonly attribute nullable OperationalDatasetComponents operationalDatasetComponents = 61; + readonly attribute NetworkFault activeNetworkFaultsList[] = 62; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + command ResetCounts(): DefaultSuccess = 0; +} + +server cluster AdministratorCommissioning = 60 { + enum CommissioningWindowStatus : ENUM8 { + kWindowNotOpen = 0; + kEnhancedWindowOpen = 1; + kBasicWindowOpen = 2; + } + + enum StatusCode : ENUM8 { + kBusy = 2; + kPAKEParameterError = 3; + kWindowNotOpen = 4; + } + + readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute nullable fabric_idx adminFabricIndex = 1; + readonly attribute nullable int16u adminVendorId = 2; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct OpenCommissioningWindowRequest { + INT16U commissioningTimeout = 0; + OCTET_STRING PAKEVerifier = 1; + INT16U discriminator = 2; + INT32U iterations = 3; + OCTET_STRING salt = 4; + } + + timed command access(invoke: administer) OpenCommissioningWindow(OpenCommissioningWindowRequest): DefaultSuccess = 0; + timed command access(invoke: administer) RevokeCommissioning(): DefaultSuccess = 2; +} + +server cluster OperationalCredentials = 62 { + enum OperationalCertStatus : ENUM8 { + kSuccess = 0; + kInvalidPublicKey = 1; + kInvalidNodeOpId = 2; + kInvalidNOC = 3; + kMissingCsr = 4; + kTableFull = 5; + kInvalidAdminSubject = 6; + kFabricConflict = 9; + kLabelConflict = 10; + kInvalidFabricIndex = 11; + } + + struct NOCStruct { + octet_string noc = 1; + nullable octet_string icac = 2; + fabric_idx fabricIndex = 254; + } + + struct FabricDescriptor { + octet_string<65> rootPublicKey = 1; + vendor_id vendorId = 2; + fabric_id fabricId = 3; + node_id nodeId = 4; + char_string<32> label = 5; + fabric_idx fabricIndex = 254; + } + + readonly attribute access(read: administer) NOCStruct NOCs[] = 0; + readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute int8u supportedFabrics = 2; + readonly attribute int8u commissionedFabrics = 3; + readonly attribute OCTET_STRING trustedRootCertificates[] = 4; + readonly attribute int8u currentFabricIndex = 5; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AttestationRequestRequest { + OCTET_STRING attestationNonce = 0; + } + + request struct CertificateChainRequestRequest { + INT8U certificateType = 0; + } + + request struct CSRRequestRequest { + OCTET_STRING CSRNonce = 0; + optional boolean isForUpdateNOC = 1; + } + + request struct AddNOCRequest { + OCTET_STRING NOCValue = 0; + optional OCTET_STRING ICACValue = 1; + OCTET_STRING IPKValue = 2; + Int64u caseAdminSubject = 3; + VENDOR_ID adminVendorId = 4; + } + + request struct UpdateNOCRequest { + OCTET_STRING NOCValue = 0; + optional OCTET_STRING ICACValue = 1; + } + + request struct UpdateFabricLabelRequest { + CHAR_STRING<32> label = 0; + } + + request struct RemoveFabricRequest { + fabric_idx fabricIndex = 0; + } + + request struct AddTrustedRootCertificateRequest { + OCTET_STRING rootCertificate = 0; + } + + response struct AttestationResponse = 1 { + OCTET_STRING attestationElements = 0; + OCTET_STRING signature = 1; + } + + response struct CertificateChainResponse = 3 { + OCTET_STRING certificate = 0; + } + + response struct CSRResponse = 5 { + OCTET_STRING NOCSRElements = 0; + OCTET_STRING attestationSignature = 1; + } + + response struct NOCResponse = 8 { + OperationalCertStatus statusCode = 0; + optional fabric_idx fabricIndex = 1; + optional CHAR_STRING debugText = 2; + } + + command access(invoke: administer) AttestationRequest(AttestationRequestRequest): AttestationResponse = 0; + command access(invoke: administer) CertificateChainRequest(CertificateChainRequestRequest): CertificateChainResponse = 2; + command access(invoke: administer) CSRRequest(CSRRequestRequest): CSRResponse = 4; + command access(invoke: administer) AddNOC(AddNOCRequest): NOCResponse = 6; + fabric command access(invoke: administer) UpdateNOC(UpdateNOCRequest): NOCResponse = 7; + fabric command access(invoke: administer) UpdateFabricLabel(UpdateFabricLabelRequest): NOCResponse = 9; + command access(invoke: administer) RemoveFabric(RemoveFabricRequest): NOCResponse = 10; + command access(invoke: administer) AddTrustedRootCertificate(AddTrustedRootCertificateRequest): DefaultSuccess = 11; +} + +server cluster GroupKeyManagement = 63 { + enum GroupKeySecurityPolicy : ENUM8 { + kTrustFirst = 0; + kCacheAndSync = 1; + } + + struct GroupKeyMapStruct { + group_id groupId = 1; + int16u groupKeySetID = 2; + fabric_idx fabricIndex = 254; + } + + struct GroupInfoMapStruct { + group_id groupId = 1; + endpoint_no endpoints[] = 2; + optional char_string<16> groupName = 3; + fabric_idx fabricIndex = 254; + } + + struct GroupKeySetStruct { + int16u groupKeySetID = 0; + GroupKeySecurityPolicy groupKeySecurityPolicy = 1; + nullable octet_string<16> epochKey0 = 2; + nullable epoch_us epochStartTime0 = 3; + nullable octet_string<16> epochKey1 = 4; + nullable epoch_us epochStartTime1 = 5; + nullable octet_string<16> epochKey2 = 6; + nullable epoch_us epochStartTime2 = 7; + } + + attribute access(write: manage) GroupKeyMapStruct groupKeyMap[] = 0; + readonly attribute GroupInfoMapStruct groupTable[] = 1; + readonly attribute int16u maxGroupsPerFabric = 2; + readonly attribute int16u maxGroupKeysPerFabric = 3; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct KeySetWriteRequest { + GroupKeySetStruct groupKeySet = 0; + } + + request struct KeySetReadRequest { + INT16U groupKeySetID = 0; + } + + request struct KeySetRemoveRequest { + INT16U groupKeySetID = 0; + } + + request struct KeySetReadAllIndicesRequest { + INT16U groupKeySetIDs[] = 0; + } + + response struct KeySetReadResponse = 2 { + GroupKeySetStruct groupKeySet = 0; + } + + response struct KeySetReadAllIndicesResponse = 5 { + INT16U groupKeySetIDs[] = 0; + } + + fabric command access(invoke: administer) KeySetWrite(KeySetWriteRequest): DefaultSuccess = 0; + fabric command access(invoke: administer) KeySetRead(KeySetReadRequest): KeySetReadResponse = 1; + fabric command access(invoke: administer) KeySetRemove(KeySetRemoveRequest): DefaultSuccess = 3; + fabric command access(invoke: administer) KeySetReadAllIndices(KeySetReadAllIndicesRequest): KeySetReadAllIndicesResponse = 4; +} + +endpoint 0 { + device type rootdevice = 22; + binding cluster OtaSoftwareUpdateProvider; + + server cluster Descriptor { + callback attribute deviceTypeList; + callback attribute serverList; + callback attribute clientList; + callback attribute partsList; + ram attribute featureMap; + callback attribute clusterRevision default = 1; + } + + server cluster AccessControl { + callback attribute acl; + callback attribute subjectsPerAccessControlEntry default = 4; + callback attribute targetsPerAccessControlEntry default = 3; + callback attribute accessControlEntriesPerFabric default = 3; + callback attribute attributeList; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster Basic { + callback attribute dataModelRevision default = 10; + callback attribute vendorName; + callback attribute vendorID; + callback attribute productName; + callback attribute productID; + persist attribute nodeLabel; + callback attribute location default = "XX"; + callback attribute hardwareVersion; + callback attribute hardwareVersionString; + callback attribute softwareVersion; + callback attribute softwareVersionString; + callback attribute capabilityMinima; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster OtaSoftwareUpdateRequestor { + callback attribute defaultOtaProviders; + ram attribute updatePossible default = 1; + ram attribute updateState; + ram attribute updateStateProgress; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster GeneralCommissioning { + ram attribute breadcrumb; + callback attribute basicCommissioningInfo; + callback attribute regulatoryConfig; + callback attribute locationCapability; + callback attribute supportsConcurrentConnection default = 1; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster NetworkCommissioning { + ram attribute maxNetworks; + callback attribute networks; + ram attribute scanMaxTimeSeconds; + ram attribute connectMaxTimeSeconds; + ram attribute interfaceEnabled; + ram attribute lastNetworkingStatus; + ram attribute lastNetworkID; + ram attribute lastConnectErrorValue; + ram attribute featureMap default = 2; + ram attribute clusterRevision default = 1; + } + + server cluster GeneralDiagnostics { + callback attribute networkInterfaces; + callback attribute rebootCount; + callback attribute testEventTriggersEnabled; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster SoftwareDiagnostics { + callback attribute threadMetrics; + callback attribute currentHeapFree; + callback attribute currentHeapUsed; + callback attribute currentHeapHighWatermark; + ram attribute featureMap default = 1; + ram attribute clusterRevision default = 1; + } + + server cluster ThreadNetworkDiagnostics { + callback attribute channel; + callback attribute routingRole; + callback attribute networkName; + callback attribute panId; + callback attribute extendedPanId; + callback attribute meshLocalPrefix; + callback attribute overrunCount; + callback attribute neighborTableList; + callback attribute routeTableList; + callback attribute partitionId; + callback attribute weighting; + callback attribute dataVersion; + callback attribute stableDataVersion; + callback attribute leaderRouterId; + callback attribute detachedRoleCount; + callback attribute childRoleCount; + callback attribute routerRoleCount; + callback attribute leaderRoleCount; + callback attribute attachAttemptCount; + callback attribute partitionIdChangeCount; + callback attribute betterPartitionAttachAttemptCount; + callback attribute parentChangeCount; + callback attribute txTotalCount; + callback attribute txUnicastCount; + callback attribute txBroadcastCount; + callback attribute txAckRequestedCount; + callback attribute txAckedCount; + callback attribute txNoAckRequestedCount; + callback attribute txDataCount; + callback attribute txDataPollCount; + callback attribute txBeaconCount; + callback attribute txBeaconRequestCount; + callback attribute txOtherCount; + callback attribute txRetryCount; + callback attribute txDirectMaxRetryExpiryCount; + callback attribute txIndirectMaxRetryExpiryCount; + callback attribute txErrCcaCount; + callback attribute txErrAbortCount; + callback attribute txErrBusyChannelCount; + callback attribute rxTotalCount; + callback attribute rxUnicastCount; + callback attribute rxBroadcastCount; + callback attribute rxDataCount; + callback attribute rxDataPollCount; + callback attribute rxBeaconCount; + callback attribute rxBeaconRequestCount; + callback attribute rxOtherCount; + callback attribute rxAddressFilteredCount; + callback attribute rxDestAddrFilteredCount; + callback attribute rxDuplicatedCount; + callback attribute rxErrNoFrameCount; + callback attribute rxErrUnknownNeighborCount; + callback attribute rxErrInvalidSrcAddrCount; + callback attribute rxErrSecCount; + callback attribute rxErrFcsCount; + callback attribute rxErrOtherCount; + callback attribute securityPolicy; + callback attribute channelPage0Mask; + callback attribute operationalDatasetComponents; + callback attribute activeNetworkFaultsList; + ram attribute featureMap default = 0x000F; + ram attribute clusterRevision default = 1; + } + + server cluster AdministratorCommissioning { + callback attribute windowStatus; + callback attribute adminFabricIndex default = 1; + callback attribute adminVendorId; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster OperationalCredentials { + callback attribute NOCs; + callback attribute fabrics; + callback attribute supportedFabrics; + callback attribute commissionedFabrics; + callback attribute trustedRootCertificates; + callback attribute currentFabricIndex; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster GroupKeyManagement { + callback attribute groupKeyMap; + callback attribute groupTable; + callback attribute maxGroupsPerFabric; + callback attribute maxGroupKeysPerFabric; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } +} +endpoint 1 { + device type dimmablelight = 256; + + server cluster Identify { + ram attribute identifyTime; + ram attribute identifyType; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap; + ram attribute clusterRevision default = 4; + } + + server cluster Groups { + ram attribute nameSupport; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap; + ram attribute clusterRevision default = 4; + } + + server cluster OnOff { + persist attribute onOff; + ram attribute globalSceneControl default = 0x01; + ram attribute onTime; + ram attribute offWaitTime; + persist attribute startUpOnOff default = 0xFF; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap default = 1; + ram attribute clusterRevision default = 4; + } + + server cluster LevelControl { + persist attribute currentLevel default = 0x01; + ram attribute remainingTime; + ram attribute minLevel default = 0x01; + ram attribute maxLevel default = 0xFE; + ram attribute options; + ram attribute onLevel; + persist attribute startUpCurrentLevel default = 254; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap default = 3; + ram attribute clusterRevision default = 5; + } + + server cluster Descriptor { + callback attribute deviceTypeList; + callback attribute serverList; + callback attribute clientList; + callback attribute partsList; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap; + callback attribute clusterRevision default = 1; + } +} + + diff --git a/examples/lighting-app/nxp/zap/lighting-on-off.zap b/examples/lighting-app/nxp/zap/lighting-on-off.zap new file mode 100644 index 00000000000000..c9421d4b35f342 --- /dev/null +++ b/examples/lighting-app/nxp/zap/lighting-on-off.zap @@ -0,0 +1,9118 @@ +{ + "featureLevel": 81, + "creator": "zap", + "keyValuePairs": [ + { + "key": "commandDiscovery", + "value": "1" + }, + { + "key": "defaultResponsePolicy", + "value": "always" + }, + { + "key": "manufacturerCodes", + "value": "0x1002" + } + ], + "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../../src/app/zap-templates/zcl/zcl.json", + "type": "zcl-properties", + "category": "matter", + "version": 1, + "description": "Matter SDK ZCL data" + }, + { + "pathRelativity": "relativeToZap", + "path": "../../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + } + ], + "endpointTypes": [ + { + "name": "MA-rootdevice", + "deviceTypeName": "MA-rootdevice", + "deviceTypeCode": 22, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "Identify", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "identify time", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AddGroup", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ViewGroup", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "GetGroupMembership", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveGroup", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveAllGroups", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "AddGroupIfIdentifying", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "AddGroupResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "ViewGroupResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "GetGroupMembershipResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveGroupResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "name support", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Scenes", + "code": 5, + "mfgCode": null, + "define": "SCENES_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AddScene", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ViewScene", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveScene", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveAllScenes", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StoreScene", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RecallScene", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "GetSceneMembership", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Scenes", + "code": 5, + "mfgCode": null, + "define": "SCENES_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "AddSceneResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "ViewSceneResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveSceneResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveAllScenesResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "StoreSceneResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "GetSceneMembershipResponse", + "code": 6, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "SceneCount", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentScene", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentGroup", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "group_id", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SceneValid", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NameSupport", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/Off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "Off", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "On", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Toggle", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/Off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "OnOff", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/off Switch Configuration", + "code": 7, + "mfgCode": null, + "define": "ON_OFF_SWITCH_CONFIG_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/off Switch Configuration", + "code": 7, + "mfgCode": null, + "define": "ON_OFF_SWITCH_CONFIG_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "switch type", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "switch actions", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Level Control", + "code": 8, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "MoveToLevel", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Move", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Step", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Stop", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveToLevelWithOnOff", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveWithOnOff", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StepWithOnOff", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StopWithOnOff", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Level Control", + "code": 8, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "CurrentLevel", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DeviceTypeList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ServerList", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClientList", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PartsList", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Access Control", + "code": 31, + "mfgCode": null, + "define": "ACCESS_CONTROL_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Access Control", + "code": 31, + "mfgCode": null, + "define": "ACCESS_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "ACL", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Extension", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SubjectsPerAccessControlEntry", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TargetsPerAccessControlEntry", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AccessControlEntriesPerFabric", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "AccessControlEntryChanged", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "AccessControlExtensionChanged", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DataModelRevision", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "10", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "vendor_id", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NodeLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "NVM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "XX", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ManufacturingDate", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 0, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "20210614123456ZZ", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PartNumber", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 0, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductURL", + "code": 13, + "mfgCode": null, + "side": "server", + "type": "long_char_string", + "included": 0, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductLabel", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 0, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SerialNumber", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 0, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LocalConfigDisabled", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 0, + "storageOption": "NVM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Reachable", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 0, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UniqueID", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 0, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CapabilityMinima", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "CapabilityMinimaStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "OTA Software Update Provider", + "code": 41, + "mfgCode": null, + "define": "OTA_PROVIDER_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "QueryImage", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "ApplyUpdateRequest", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "NotifyUpdateApplied", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "OTA Software Update Provider", + "code": 41, + "mfgCode": null, + "define": "OTA_PROVIDER_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "QueryImageResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ApplyUpdateResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "OTA Software Update Requestor", + "code": 42, + "mfgCode": null, + "define": "OTA_REQUESTOR_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AnnounceOtaProvider", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "OTA Software Update Requestor", + "code": 42, + "mfgCode": null, + "define": "OTA_REQUESTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DefaultOtaProviders", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "UpdatePossible", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpdateState", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "OTAUpdateStateEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpdateStateProgress", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "StateTransition", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "VersionApplied", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "DownloadError", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Localization Configuration", + "code": 43, + "mfgCode": null, + "define": "LOCALIZATION_CONFIGURATION_CLUSTER", + "side": "client", + "enabled": 0 + }, + { + "name": "Localization Configuration", + "code": 43, + "mfgCode": null, + "define": "LOCALIZATION_CONFIGURATION_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "ActiveLocale", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "en-US", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedLocales", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "client", + "enabled": 0 + }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "HourFormat", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "HourFormat", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveCalendarType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "CalendarType", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedCalendarTypes", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Unit Localization", + "code": 45, + "mfgCode": null, + "define": "UNIT_LOCALIZATION_CLUSTER", + "side": "client", + "enabled": 0 + }, + { + "name": "Unit Localization", + "code": 45, + "mfgCode": null, + "define": "UNIT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "TemperatureUnit", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "TempUnit", + "included": 0, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "General Commissioning", + "code": 48, + "mfgCode": null, + "define": "GENERAL_COMMISSIONING_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ArmFailSafe", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetRegulatoryConfig", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "CommissioningComplete", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "General Commissioning", + "code": 48, + "mfgCode": null, + "define": "GENERAL_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ArmFailSafeResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetRegulatoryConfigResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "CommissioningCompleteResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "Breadcrumb", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "BasicCommissioningInfo", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "BasicCommissioningInfo", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RegulatoryConfig", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "RegulatoryLocationType", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LocationCapability", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "RegulatoryLocationType", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportsConcurrentConnection", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Network Commissioning", + "code": 49, + "mfgCode": null, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ScanNetworks", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddOrUpdateWiFiNetwork", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 0 + }, + { + "name": "AddOrUpdateThreadNetwork", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveNetwork", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ConnectNetwork", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ReorderNetwork", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Network Commissioning", + "code": 49, + "mfgCode": null, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ScanNetworksResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "NetworkConfigResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "ConnectNetworkResponse", + "code": 7, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "MaxNetworks", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Networks", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ScanMaxTimeSeconds", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ConnectMaxTimeSeconds", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "InterfaceEnabled", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastNetworkingStatus", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "NetworkCommissioningStatus", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastNetworkID", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastConnectErrorValue", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int32s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "2", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Diagnostic Logs", + "code": 50, + "mfgCode": null, + "define": "DIAGNOSTIC_LOGS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "RetrieveLogsRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Diagnostic Logs", + "code": 50, + "mfgCode": null, + "define": "DIAGNOSTIC_LOGS_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "RetrieveLogsRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RetrieveLogsResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "General Diagnostics", + "code": 51, + "mfgCode": null, + "define": "GENERAL_DIAGNOSTICS_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "General Diagnostics", + "code": 51, + "mfgCode": null, + "define": "GENERAL_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "TestEventTrigger", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "NetworkInterfaces", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RebootCount", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TotalOperationalHours", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BootReasons", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveHardwareFaults", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveRadioFaults", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveNetworkFaults", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TestEventTriggersEnabled", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "false", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "BootReason", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Software Diagnostics", + "code": 52, + "mfgCode": null, + "define": "SOFTWARE_DIAGNOSTICS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ResetWatermarks", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Software Diagnostics", + "code": 52, + "mfgCode": null, + "define": "SOFTWARE_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "ThreadMetrics", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentHeapFree", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentHeapUsed", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentHeapHighWatermark", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Thread Network Diagnostics", + "code": 53, + "mfgCode": null, + "define": "THREAD_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ResetCounts", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Thread Network Diagnostics", + "code": 53, + "mfgCode": null, + "define": "THREAD_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "channel", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RoutingRole", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "RoutingRole", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NetworkName", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PanId", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ExtendedPanId", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "MeshLocalPrefix", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OverrunCount", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NeighborTableList", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RouteTableList", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PartitionId", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "weighting", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "DataVersion", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "StableDataVersion", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LeaderRouterId", + "code": 13, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "DetachedRoleCount", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ChildRoleCount", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RouterRoleCount", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LeaderRoleCount", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "AttachAttemptCount", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PartitionIdChangeCount", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "BetterPartitionAttachAttemptCount", + "code": 20, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ParentChangeCount", + "code": 21, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxTotalCount", + "code": 22, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxUnicastCount", + "code": 23, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxBroadcastCount", + "code": 24, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxAckRequestedCount", + "code": 25, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxAckedCount", + "code": 26, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxNoAckRequestedCount", + "code": 27, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxDataCount", + "code": 28, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxDataPollCount", + "code": 29, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxBeaconCount", + "code": 30, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxBeaconRequestCount", + "code": 31, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxOtherCount", + "code": 32, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxRetryCount", + "code": 33, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxDirectMaxRetryExpiryCount", + "code": 34, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxIndirectMaxRetryExpiryCount", + "code": 35, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxErrCcaCount", + "code": 36, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxErrAbortCount", + "code": 37, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxErrBusyChannelCount", + "code": 38, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxTotalCount", + "code": 39, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxUnicastCount", + "code": 40, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxBroadcastCount", + "code": 41, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxDataCount", + "code": 42, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxDataPollCount", + "code": 43, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxBeaconCount", + "code": 44, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxBeaconRequestCount", + "code": 45, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxOtherCount", + "code": 46, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxAddressFilteredCount", + "code": 47, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxDestAddrFilteredCount", + "code": 48, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxDuplicatedCount", + "code": 49, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrNoFrameCount", + "code": 50, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrUnknownNeighborCount", + "code": 51, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrInvalidSrcAddrCount", + "code": 52, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrSecCount", + "code": 53, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrFcsCount", + "code": 54, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrOtherCount", + "code": 55, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ActiveTimestamp", + "code": 56, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PendingTimestamp", + "code": 57, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Delay", + "code": 58, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SecurityPolicy", + "code": 59, + "mfgCode": null, + "side": "server", + "type": "SecurityPolicy", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ChannelPage0Mask", + "code": 60, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OperationalDatasetComponents", + "code": 61, + "mfgCode": null, + "side": "server", + "type": "OperationalDatasetComponents", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ActiveNetworkFaultsList", + "code": 62, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x000F", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "WiFi Network Diagnostics", + "code": 54, + "mfgCode": null, + "define": "WIFI_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ResetCounts", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "WiFi Network Diagnostics", + "code": 54, + "mfgCode": null, + "define": "WIFI_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "bssid", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SecurityType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "SecurityType", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "WiFiVersion", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "WiFiVersionType", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ChannelNumber", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Rssi", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int8s", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "BeaconLostCount", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BeaconRxCount", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketMulticastRxCount", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketMulticastTxCount", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketUnicastRxCount", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketUnicastTxCount", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentMaxRate", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OverrunCount", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Ethernet Network Diagnostics", + "code": 55, + "mfgCode": null, + "define": "ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ResetCounts", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Ethernet Network Diagnostics", + "code": 55, + "mfgCode": null, + "define": "ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "PHYRate", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "PHYRateType", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FullDuplex", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketRxCount", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PacketTxCount", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxErrCount", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CollisionCount", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OverrunCount", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CarrierDetect", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeSinceReset", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Switch", + "code": 59, + "mfgCode": null, + "define": "SWITCH_CLUSTER", + "side": "client", + "enabled": 0 + }, + { + "name": "Switch", + "code": 59, + "mfgCode": null, + "define": "SWITCH_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "AdministratorCommissioning", + "code": 60, + "mfgCode": null, + "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "OpenCommissioningWindow", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "OpenBasicCommissioningWindow", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RevokeCommissioning", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "AdministratorCommissioning", + "code": 60, + "mfgCode": null, + "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "WindowStatus", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "CommissioningWindowStatus", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AdminFabricIndex", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "fabric_idx", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AdminVendorId", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Operational Credentials", + "code": 62, + "mfgCode": null, + "define": "OPERATIONAL_CREDENTIALS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AttestationRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "CertificateChainRequest", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "CSRRequest", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddNOC", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "UpdateNOC", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "UpdateFabricLabel", + "code": 9, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveFabric", + "code": 10, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddTrustedRootCertificate", + "code": 11, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Operational Credentials", + "code": 62, + "mfgCode": null, + "define": "OPERATIONAL_CREDENTIALS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AttestationResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "CertificateChainResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "CSRResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "NOCResponse", + "code": 8, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "NOCs", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Fabrics", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SupportedFabrics", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CommissionedFabrics", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TrustedRootCertificates", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentFabricIndex", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Group Key Management", + "code": 63, + "mfgCode": null, + "define": "GROUP_KEY_MANAGEMENT_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "KeySetWrite", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "KeySetRead", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "KeySetRemove", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "KeySetReadAllIndices", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ] + }, + { + "name": "Group Key Management", + "code": 63, + "mfgCode": null, + "define": "GROUP_KEY_MANAGEMENT_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "KeySetReadResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "KeySetReadAllIndicesResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "GroupKeyMap", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GroupTable", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxGroupsPerFabric", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxGroupKeysPerFabric", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Fixed Label", + "code": 64, + "mfgCode": null, + "define": "FIXED_LABEL_CLUSTER", + "side": "client", + "enabled": 0 + }, + { + "name": "Fixed Label", + "code": 64, + "mfgCode": null, + "define": "FIXED_LABEL_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0 + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + } + ] + }, + { + "name": "MA-dimmablelight", + "deviceTypeName": "MA-onofflight", + "deviceTypeCode": 256, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "Identify", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "TriggerEffect", + "code": 64, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "identify time", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "identify type", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AddGroup", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ViewGroup", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "GetGroupMembership", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveGroup", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveAllGroups", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "AddGroupIfIdentifying", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AddGroupResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "ViewGroupResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "GetGroupMembershipResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveGroupResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "name support", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Scenes", + "code": 5, + "mfgCode": null, + "define": "SCENES_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AddScene", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ViewScene", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveScene", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveAllScenes", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StoreScene", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RecallScene", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "GetSceneMembership", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedAddScene", + "code": 64, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedViewScene", + "code": 65, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "CopyScene", + "code": 66, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Scenes", + "code": 5, + "mfgCode": null, + "define": "SCENES_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "AddSceneResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "ViewSceneResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveSceneResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveAllScenesResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "StoreSceneResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "GetSceneMembershipResponse", + "code": 6, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "SceneCount", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentScene", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentGroup", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "group_id", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SceneValid", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NameSupport", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LastConfiguredBy", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "node_id", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/Off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "Off", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "On", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Toggle", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "OffWithEffect", + "code": 64, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "OnWithRecallGlobalScene", + "code": 65, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "OnWithTimedOff", + "code": 66, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/Off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "OnOff", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "GlobalSceneControl", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OnTime", + "code": 16385, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OffWaitTime", + "code": 16386, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "StartUpOnOff", + "code": 16387, + "mfgCode": null, + "side": "server", + "type": "OnOffStartUpOnOff", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFF", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Level Control", + "code": 8, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "MoveToLevel", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Move", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Step", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Stop", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveToLevelWithOnOff", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveWithOnOff", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StepWithOnOff", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StopWithOnOff", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Level Control", + "code": 8, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "CurrentLevel", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RemainingTime", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "MinLevel", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxLevel", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFE", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentFrequency", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MinFrequency", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxFrequency", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Options", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OnOffTransitionTime", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OnLevel", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OnTransitionTime", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OffTransitionTime", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DefaultMoveRate", + "code": 20, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "50", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "StartUpCurrentLevel", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "254", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DeviceTypeList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ServerList", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClientList", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PartsList", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Binding", + "code": 30, + "mfgCode": null, + "define": "BINDING_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Binding", + "code": 30, + "mfgCode": null, + "define": "BINDING_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "Binding", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "DataModelRevision", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "10", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "vendor_id", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NodeLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "NVM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "XX", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ManufacturingDate", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "20210614123456ZZ", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PartNumber", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductURL", + "code": 13, + "mfgCode": null, + "side": "server", + "type": "long_char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductLabel", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SerialNumber", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LocalConfigDisabled", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "NVM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Reachable", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UniqueID", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CapabilityMinima", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "CapabilityMinimaStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Color Control", + "code": 768, + "mfgCode": null, + "define": "COLOR_CONTROL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "MoveToHue", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveHue", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StepHue", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveToSaturation", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveSaturation", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StepSaturation", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveToHueAndSaturation", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveToColor", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "MoveColor", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StepColor", + "code": 9, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "MoveToColorTemperature", + "code": 10, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedMoveToHue", + "code": 64, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedMoveHue", + "code": 65, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedStepHue", + "code": 66, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedMoveToHueAndSaturation", + "code": 67, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ColorLoopSet", + "code": 68, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StopMoveStep", + "code": 71, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveColorTemperature", + "code": 75, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StepColorTemperature", + "code": 76, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Color Control", + "code": 768, + "mfgCode": null, + "define": "COLOR_CONTROL_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "CurrentHue", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentSaturation", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RemainingTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentX", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x616B", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentY", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x607D", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "DriftCompensation", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CompensationText", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTemperatureMireds", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00FA", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorMode", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Options", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NumberOfPrimaries", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Primary1X", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary1Y", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary1Intensity", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2X", + "code": 21, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2Y", + "code": 22, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2Intensity", + "code": 23, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3X", + "code": 25, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3Y", + "code": 26, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3Intensity", + "code": 27, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4X", + "code": 32, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4Y", + "code": 33, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4Intensity", + "code": 34, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5X", + "code": 36, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5Y", + "code": 37, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5Intensity", + "code": 38, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6X", + "code": 40, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6Y", + "code": 41, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6Intensity", + "code": 42, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "WhitePointX", + "code": 48, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "WhitePointY", + "code": 49, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointRX", + "code": 50, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointRY", + "code": 51, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointRIntensity", + "code": 52, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointGX", + "code": 54, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointGY", + "code": 55, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointGIntensity", + "code": 56, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointBX", + "code": 58, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointBY", + "code": 59, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointBIntensity", + "code": 60, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EnhancedCurrentHue", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "EnhancedColorMode", + "code": 16385, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopActive", + "code": 16386, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopDirection", + "code": 16387, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopTime", + "code": 16388, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0019", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopStartEnhancedHue", + "code": 16389, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x2300", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopStoredEnhancedHue", + "code": 16390, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorCapabilities", + "code": 16394, + "mfgCode": null, + "side": "server", + "type": "bitmap16", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x1F", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTempPhysicalMinMireds", + "code": 16395, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTempPhysicalMaxMireds", + "code": 16396, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFEFF", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CoupleColorTempToLevelMinMireds", + "code": 16397, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "StartUpColorTemperatureMireds", + "code": 16400, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x1F", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Occupancy Sensing", + "code": 1030, + "mfgCode": null, + "define": "OCCUPANCY_SENSING_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Occupancy Sensing", + "code": 1030, + "mfgCode": null, + "define": "OCCUPANCY_SENSING_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "occupancy", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "occupancy sensor type", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "occupancy sensor type bitmap", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PIR occupied to unoccupied delay", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PIR unoccupied to occupied delay", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PIR unoccupied to occupied threshold", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ultrasonic occupied to unoccupied delay", + "code": 32, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ultrasonic unoccupied to occupied delay", + "code": 33, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ultrasonic unoccupied to occupied threshold", + "code": 34, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "physical contact occupied to unoccupied delay", + "code": 48, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "physical contact unoccupied to occupied delay", + "code": 49, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "physical contact unoccupied to occupied threshold", + "code": 50, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + } + ] + } + ], + "endpoints": [ + { + "endpointTypeName": "MA-rootdevice", + "endpointTypeIndex": 0, + "profileId": 259, + "endpointId": 0, + "networkId": 0, + "endpointVersion": 1, + "deviceIdentifier": 22 + }, + { + "endpointTypeName": "MA-dimmablelight", + "endpointTypeIndex": 1, + "profileId": 259, + "endpointId": 1, + "networkId": 0, + "endpointVersion": 1, + "deviceIdentifier": 256 + } + ], + "log": [] +} \ No newline at end of file diff --git a/examples/lighting-app/qpg/BUILD.gn b/examples/lighting-app/qpg/BUILD.gn index 4745c5d1f26f55..01046f05aa99a6 100644 --- a/examples/lighting-app/qpg/BUILD.gn +++ b/examples/lighting-app/qpg/BUILD.gn @@ -62,6 +62,7 @@ qpg_executable("lighting_app") { ] deps = [ + ":factorydata_lib", ":sdk", "${chip_root}/examples/lighting-app/lighting-common", "${chip_root}/examples/lighting-app/lighting-common:color-format", @@ -153,3 +154,15 @@ group("qpg") { group("default") { deps = [ ":qpg" ] } + +static_library("factorydata_lib") { + libs = [ "${qpg_sdk_root}/Binaries/FactoryData/FactoryData_example/FactoryData_example.a" ] + public_configs = [ ":qpg_retain_factorydata" ] +} + +config("qpg_retain_factorydata") { + ldflags = [ + "-Wl,-u_binary_factory_data_bin_start", + "-Wl,-u_binary_factory_data_start", + ] +} diff --git a/examples/lighting-app/qpg/include/AppTask.h b/examples/lighting-app/qpg/include/AppTask.h index 510478fb9be3e3..f91eb971c2ca17 100644 --- a/examples/lighting-app/qpg/include/AppTask.h +++ b/examples/lighting-app/qpg/include/AppTask.h @@ -29,6 +29,8 @@ #include "timers.h" // provides FreeRTOS timer support #include +#include + #define APP_NAME "Lighting-app" class AppTask @@ -78,6 +80,8 @@ class AppTask bool mFunctionTimerActive; bool mSyncClusterToButtonAction; + chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; + static AppTask sAppTask; }; diff --git a/examples/lighting-app/qpg/include/CHIPProjectConfig.h b/examples/lighting-app/qpg/include/CHIPProjectConfig.h index 98f0f4f8992918..63b3c719c37100 100644 --- a/examples/lighting-app/qpg/include/CHIPProjectConfig.h +++ b/examples/lighting-app/qpg/include/CHIPProjectConfig.h @@ -50,7 +50,7 @@ * 0xFFF1: Test Vendor. */ #ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID -#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1 +#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0x10D0 #endif // CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID /** diff --git a/examples/lighting-app/qpg/src/AppTask.cpp b/examples/lighting-app/qpg/src/AppTask.cpp index 25b89e41b29ddc..e00e90ff8c6ce3 100644 --- a/examples/lighting-app/qpg/src/AppTask.cpp +++ b/examples/lighting-app/qpg/src/AppTask.cpp @@ -254,8 +254,11 @@ CHIP_ERROR AppTask::Init() // Init ZCL Data Model and start server PlatformMgr().ScheduleWork(InitServer, 0); - // Initialize device attestation config - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); + ReturnErrorOnFailure(mFactoryDataProvider.Init()); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + SetCommissionableDataProvider(&mFactoryDataProvider); + + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); // Setup light err = LightingMgr().Init(); diff --git a/examples/lighting-app/telink/include/LightingManager.h b/examples/lighting-app/telink/include/LightingManager.h index 2af544ada8625b..5ac8187f001e7f 100644 --- a/examples/lighting-app/telink/include/LightingManager.h +++ b/examples/lighting-app/telink/include/LightingManager.h @@ -23,7 +23,7 @@ #include #include -#include +#include class LightingManager { diff --git a/examples/lighting-app/telink/prj.conf b/examples/lighting-app/telink/prj.conf index e7228bff883154..8c2317982e35b4 100644 --- a/examples/lighting-app/telink/prj.conf +++ b/examples/lighting-app/telink/prj.conf @@ -33,7 +33,7 @@ CONFIG_OPENTHREAD_PANID=4660 CONFIG_OPENTHREAD_CHANNEL=15 CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" -CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154" +CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154_b91" # Disable Matter OTA DFU CONFIG_CHIP_OTA_REQUESTOR=n diff --git a/examples/lighting-app/telink/src/AppTask.cpp b/examples/lighting-app/telink/src/AppTask.cpp index 5c537b26a0d39e..fd9eabc82976e5 100644 --- a/examples/lighting-app/telink/src/AppTask.cpp +++ b/examples/lighting-app/telink/src/AppTask.cpp @@ -51,8 +51,8 @@ #include "OTAUtil.h" #endif -#include -#include +#include +#include #include diff --git a/examples/lighting-app/telink/src/LightingManager.cpp b/examples/lighting-app/telink/src/LightingManager.cpp index c89bbf6bf25aa2..3aad922a3516af 100644 --- a/examples/lighting-app/telink/src/LightingManager.cpp +++ b/examples/lighting-app/telink/src/LightingManager.cpp @@ -22,9 +22,9 @@ #include -#include -#include -#include +#include +#include +#include LOG_MODULE_DECLARE(app); diff --git a/examples/lighting-app/telink/src/main.cpp b/examples/lighting-app/telink/src/main.cpp index 28c080dc0bdc0f..4ea2a51acd6b2e 100644 --- a/examples/lighting-app/telink/src/main.cpp +++ b/examples/lighting-app/telink/src/main.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include LOG_MODULE_REGISTER(app); diff --git a/examples/lock-app/efr32/src/AppTask.cpp b/examples/lock-app/efr32/src/AppTask.cpp index c39b109fb6a2af..f624eb50073234 100644 --- a/examples/lock-app/efr32/src/AppTask.cpp +++ b/examples/lock-app/efr32/src/AppTask.cpp @@ -51,8 +51,6 @@ #include #include -#include - #include #include diff --git a/examples/lock-app/infineon/cyw30739/src/main.cpp b/examples/lock-app/infineon/cyw30739/src/main.cpp index d72d154e7c3a10..2f8bd88eeff599 100644 --- a/examples/lock-app/infineon/cyw30739/src/main.cpp +++ b/examples/lock-app/infineon/cyw30739/src/main.cpp @@ -30,6 +30,7 @@ #endif #include #include +#include #include #include #include @@ -69,6 +70,11 @@ static void UpdateClusterState(intptr_t context); #define _countof(a) (sizeof(a) / sizeof(a[0])) #endif +// NOTE! This key is for test/certification only and should not be available in production devices! +uint8_t sTestEventTriggerEnableKey[chip::TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, + 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, + 0xcc, 0xdd, 0xee, 0xff }; + static wiced_led_config_t chip_lighting_led_config[2] = { { .led = PLATFORM_LED_1, @@ -174,8 +180,10 @@ void InitApp(intptr_t args) // Print QR Code URL PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); /* Start CHIP datamodel server */ + static chip::OTATestEventTriggerDelegate testEventTriggerDelegate{ chip::ByteSpan(sTestEventTriggerEnableKey) }; static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); + initParams.testEventTriggerDelegate = &testEventTriggerDelegate; gExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; diff --git a/examples/lock-app/lock-common/BUILD.gn b/examples/lock-app/lock-common/BUILD.gn old mode 100755 new mode 100644 diff --git a/examples/lock-app/lock-common/lock-app.matter b/examples/lock-app/lock-common/lock-app.matter index d63b33ff03da77..6d1572d55b10f4 100644 --- a/examples/lock-app/lock-common/lock-app.matter +++ b/examples/lock-app/lock-common/lock-app.matter @@ -41,66 +41,6 @@ server cluster Identify = 3 { command access(invoke: manage) Identify(IdentifyRequest): DefaultSuccess = 0; } -server cluster Groups = 4 { - bitmap GroupClusterFeature : BITMAP32 { - kGroupNames = 0x1; - } - - readonly attribute bitmap8 nameSupport = 0; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; - - request struct AddGroupRequest { - group_id groupId = 0; - CHAR_STRING groupName = 1; - } - - request struct ViewGroupRequest { - group_id groupId = 0; - } - - request struct GetGroupMembershipRequest { - group_id groupList[] = 0; - } - - request struct RemoveGroupRequest { - group_id groupId = 0; - } - - request struct AddGroupIfIdentifyingRequest { - group_id groupId = 0; - CHAR_STRING groupName = 1; - } - - response struct AddGroupResponse = 0 { - ENUM8 status = 0; - group_id groupId = 1; - } - - response struct ViewGroupResponse = 1 { - ENUM8 status = 0; - group_id groupId = 1; - CHAR_STRING groupName = 2; - } - - response struct GetGroupMembershipResponse = 2 { - nullable INT8U capacity = 0; - group_id groupList[] = 1; - } - - response struct RemoveGroupResponse = 3 { - ENUM8 status = 0; - group_id groupId = 1; - } - - fabric command access(invoke: manage) AddGroup(AddGroupRequest): AddGroupResponse = 0; - fabric command ViewGroup(ViewGroupRequest): ViewGroupResponse = 1; - fabric command GetGroupMembership(GetGroupMembershipRequest): GetGroupMembershipResponse = 2; - fabric command access(invoke: manage) RemoveGroup(RemoveGroupRequest): RemoveGroupResponse = 3; - fabric command access(invoke: manage) RemoveAllGroups(): DefaultSuccess = 4; - fabric command access(invoke: manage) AddGroupIfIdentifying(AddGroupIfIdentifyingRequest): DefaultSuccess = 5; -} - server cluster OnOff = 6 { enum OnOffDelayedAllOffEffectVariant : ENUM8 { kFadeToOffIn0p8Seconds = 0; @@ -2216,12 +2156,6 @@ endpoint 1 { ram attribute clusterRevision default = 4; } - server cluster Groups { - ram attribute nameSupport; - ram attribute featureMap; - ram attribute clusterRevision default = 4; - } - server cluster OnOff { ram attribute onOff; ram attribute globalSceneControl default = 1; diff --git a/examples/lock-app/lock-common/lock-app.zap b/examples/lock-app/lock-common/lock-app.zap old mode 100755 new mode 100644 index 73a79fa0d9e633..8cae50f997d655 --- a/examples/lock-app/lock-common/lock-app.zap +++ b/examples/lock-app/lock-common/lock-app.zap @@ -1,5 +1,5 @@ { - "featureLevel": 80, + "featureLevel": 81, "creator": "zap", "keyValuePairs": [ { @@ -5482,7 +5482,7 @@ "mfgCode": null, "define": "GROUPS_CLUSTER", "side": "server", - "enabled": 1, + "enabled": 0, "commands": [ { "name": "AddGroupResponse", @@ -7758,5 +7758,6 @@ "endpointVersion": 1, "deviceIdentifier": 10 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lock-app/nxp/k32w/k32w0/BUILD.gn b/examples/lock-app/nxp/k32w/k32w0/BUILD.gn index 57d4498ce98ad0..95f1a8c02a7848 100644 --- a/examples/lock-app/nxp/k32w/k32w0/BUILD.gn +++ b/examples/lock-app/nxp/k32w/k32w0/BUILD.gn @@ -83,6 +83,7 @@ k32w0_executable("lock_app") { ":sdk", "${chip_root}/examples/common/QRCode", "${chip_root}/examples/lock-app/lock-common", + "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/crypto", "${chip_root}/src/lib", "${chip_root}/third_party/mbedtls:mbedtls", diff --git a/examples/lock-app/nxp/k32w/k32w0/README.md b/examples/lock-app/nxp/k32w/k32w0/README.md index 9c1ef8ef3170f2..352d03055e862d 100644 --- a/examples/lock-app/nxp/k32w/k32w0/README.md +++ b/examples/lock-app/nxp/k32w/k32w0/README.md @@ -22,16 +22,18 @@ network. - [Bluetooth LE Rendezvous](#bluetooth-le-rendezvous) - [Device UI](#device-ui) - [Building](#building) + - [Known issues](#building-issues) +- [Manufacturing data](#manufacturing) - [Flashing and debugging](#flashdebug) -- [Known Issues](#knownissues) -- [Testing the example](#testing-the-example) - [Pigweed Tokenizer](#tokenizer) - [Detokenizer script](#detokenizer) - [Notes](#detokenizer-notes) - [Known issues](#detokenizer-known-issues) - [Tinycrypt ECC operations](#tinycrypt) - - [Building steps](#tinycrypt-building-steps) +- [Low power](#low-power) + + - [Known issues](#low-power-issues) @@ -172,21 +174,18 @@ will be initiated. In order to build the Project CHIP example, we recommend using a Linux distribution (the demo-application was compiled on Ubuntu 20.04). -- Download [K32W061 SDK 2.6.6 for Project CHIP](https://mcuxpresso.nxp.com/). - Creating an nxp.com account is required before being able to download the - SDK. Once the account is created, login and follow the steps for downloading - SDK_2_6_6_K32W061DK6. The SDK Builder UI selection should be similar with - the one from the image below. - ![MCUXpresso SDK Download](../../../../platform/nxp/k32w/k32w0/doc/images/mcux-sdk-download.JPG) +- Download + [K32W0 SDK 2.6.7](https://cache.nxp.com/lgfiles/bsps/SDK_2_6_7_K32W061DK6.zip). - Start building the application either with Secure Element or without - without Secure Element ``` -user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W0_SDK_ROOT=/home/user/Desktop/SDK_2_6_6_K32W061DK6/ +user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W0_SDK_ROOT=/home/user/Desktop/SDK_2_6_7_K32W061DK6/ +user@ubuntu:~/Desktop/git/connectedhomeip$ ./third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh user@ubuntu:~/Desktop/git/connectedhomeip$ source ./scripts/activate.sh -user@ubuntu:~/Desktop/git/connectedhomeip$ cd examples/lock-app/nxp/k32w/k32w0/ +user@ubuntu:~/Desktop/git/connectedhomeip$ cd examples/lock-app/nxp/k32w/k32w0 user@ubuntu:~/Desktop/git/connectedhomeip/examples/lock-app/nxp/k32w/k32w0$ gn gen out/debug --args="k32w0_sdk_root=\"${NXP_K32W0_SDK_ROOT}\" chip_with_OM15082=1 chip_with_ot_cli=0 is_debug=false chip_crypto=\"tinycrypt\" chip_with_se05x=0 chip_pw_tokenizer_logging=true mbedtls_repo=\"//third_party/connectedhomeip/third_party/nxp/libs/mbedtls\"" user@ubuntu:~/Desktop/git/connectedhomeip/examples/lock-app/nxp/k32w/k32w0$ ninja -C out/debug user@ubuntu:~/Desktop/git/connectedhomeip/examples/lock-app/nxp/k32w/k32w0$ $NXP_K32W0_SDK_ROOT/tools/imagetool/sign_images.sh out/debug/ @@ -218,6 +217,20 @@ pycryptodome 3.9.8 The resulting output file can be found in out/debug/chip-k32w0x-lock-example. + + +## Known issues + +- When using Secure element and cross-compiling on Linux, log messages from + the Plug&Trust middleware stack may not echo to the console. + + + +## Manufacturing data + +See +[Guide for writing manufacturing data on NXP devices](../../../../platform/nxp/doc/manufacturing_flow.md). + ## Flashing and debugging @@ -229,58 +242,6 @@ All you have to do is to replace the Openthread binaries from the above documentation with _out/debug/chip-k32w0x-lock-example.bin_ if DK6Programmer is used or with _out/debug/chip-k32w0x-lock-example_ if MCUXpresso is used. - - -## Low power - -The example also offers the possibility to run in low power mode. This means -that the board will go in a deep power down mode most of the time and the power -consumption will be very low. - -In order build with low power support, the _chip_with_low_power=1_ must be -provided to the build system. In this case, please note that the GN build -arguments chip*with_OM15082 and \_chip_with_ot_cli* must be set to 0. - -In order to maintain a low power consumption, the LEDs showing the state of the -elock and the internal state are disabled. Console logs can be used instead. -Also, please note that once the board is flashed with MCUXpresso the debugger -disconnects because the board enters low power. - -Power Measurement Tool can be used inside MCUXpresso for checking the power -consumption pattern: Window -> Show View -> Other -> Power Measurement Tool. The -configuration for this tool is the next one: - -![POWER_CONF](../../../../platform/nxp/k32w/k32w0/doc/images/power_conf.JPG) - -Also, please make sure that the J14 jumper is set to the _ENABLED_ position and -no expansion board is attached to the DK6. A view from this tool is illustrated -below: - -![POWER_VIEW](../../../../platform/nxp/k32w/k32w0/doc/images/power_view.JPG) - -Please note that that the Power Measurement Tool is not very accurate and -professional tools must be used if exact power consumption needs to be known. - -## Known issues - -- When cross-compiling on Linux - Log messages from the Plug&Trust middleware - stack may not echo to the console; -- Power Measurement Tool may not work correctly in MCUXpresso versions greater - that 11.0.1. - -## Testing the example - -The app can be deployed against any generic OpenThread Border Router. See the -guide -[Commissioning NXP K32W using Android CHIPTool](../../../docs/guides/nxp_k32w_android_commissioning.md) -for step-by-step instructions. - -## Video demo - -See -[Unlocking the Future of Project CHIP Webinar](https://www.nxp.com/design/training/unlocking-the-future-of-project-chip:TIP-EEE-UNLOCKING-THE-FUTURE-OF-PROJECT-CHIP) -for an in-depth analysis of NXP capabilities for Project CHIP. - ## Pigweed tokenizer @@ -374,3 +335,43 @@ In order to use the tinycrypt ecc operations, use the following build arguments: To disable tinycrypt ecc operations, simply build with _chip_crypto=\"mbedtls\"_ and with or without _mbedtls_repo_. If used with _mbedtls_repo_ the mbedtls implementation from `NXPmicro/mbedtls` library will be used. + + + +## Low power + +The example also offers the possibility to run in low power mode. This means +that the board will go in a deep power down mode most of the time and the power +consumption will be very low. + +In order to build with low power support, the _chip_with_low_power=1_ must be +provided to the build system. In this case, please note that the GN build +arguments _chip_with_OM15082_ and _chip_with_ot_cli_ must be set to 0 and +_chip_logging_ must be set to false to disable logging. + +In order to maintain a low power consumption, the LEDs showing the state of the +elock and the internal state are disabled. Console logs can be used instead. +Also, please note that once the board is flashed with MCUXpresso the debugger +disconnects because the board enters low power. + +Power Measurement Tool can be used inside MCUXpresso for checking the power +consumption pattern: Window -> Show View -> Other -> Power Measurement Tool. The +configuration for this tool is the next one: + +![POWER_CONF](../../../../platform/nxp/k32w/k32w0/doc/images/power_conf.JPG) + +Also, please make sure that the J14 jumper is set to the _ENABLED_ position and +no expansion board is attached to the DK6. A view from this tool is illustrated +below: + +![POWER_VIEW](../../../../platform/nxp/k32w/k32w0/doc/images/power_view.JPG) + +Please note that that the Power Measurement Tool is not very accurate and +professional tools must be used if exact power consumption needs to be known. + + + +## Known issues + +- Power Measurement Tool may not work correctly in MCUXpresso versions greater + that 11.0.1. diff --git a/examples/lock-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h b/examples/lock-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h index 26b42ea1acd871..cca7403d37767f 100644 --- a/examples/lock-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h +++ b/examples/lock-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h @@ -34,6 +34,56 @@ // including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS. #define CHIP_CONFIG_SECURITY_TEST_MODE 0 +// Use hard-coded test certificates already embedded in generic chip code => set it to 0 +// Use real/development certificates => set it to 1 + file the provisioning section from +// the internal flash +#ifndef CONFIG_CHIP_K32W0_REAL_FACTORY_DATA +#define CONFIG_CHIP_K32W0_REAL_FACTORY_DATA 0 +#endif + +#if CONFIG_CHIP_K32W0_REAL_FACTORY_DATA + +// VID/PID for product => will be used by Basic Information Cluster +#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0x1037 +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0xA220 + +// set it to 0 for the moment +#define CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER 0 + +#ifndef CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION +//-> format_version = 1 +//-> vendor_id = 0x1037 +//-> product_id_array = [ 0xA220 ] +//-> device_type_id = 0x0015 +//-> certificate_id = "ZIG20142ZB330003-24" +//-> security_level = 0 +//-> security_information = 0 +//-> version_number = 0x2694 +//-> certification_type = 0 +//-> dac_origin_vendor_id is not present +//-> dac_origin_product_id is not present +#define CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION \ + { \ + 0x30, 0x81, 0xe8, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0, 0x81, 0xda, 0x30, 0x81, 0xd7, \ + 0x02, 0x01, 0x03, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, \ + 0x44, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x37, 0x04, 0x35, 0x15, 0x24, 0x00, \ + 0x01, 0x25, 0x01, 0x37, 0x10, 0x36, 0x02, 0x05, 0x20, 0xa2, 0x18, 0x24, 0x03, 0x15, 0x2c, 0x04, 0x13, 0x5a, 0x49, \ + 0x47, 0x32, 0x30, 0x31, 0x34, 0x31, 0x5a, 0x42, 0x33, 0x33, 0x30, 0x30, 0x30, 0x31, 0x2d, 0x32, 0x34, 0x24, 0x05, \ + 0x00, 0x24, 0x06, 0x00, 0x25, 0x07, 0x76, 0x98, 0x24, 0x08, 0x00, 0x18, 0x31, 0x7d, 0x30, 0x7b, 0x02, 0x01, 0x03, \ + 0x80, 0x14, 0x62, 0xfa, 0x82, 0x33, 0x59, 0xac, 0xfa, 0xa9, 0x96, 0x3e, 0x1c, 0xfa, 0x14, 0x0a, 0xdd, 0xf5, 0x04, \ + 0xf3, 0x71, 0x60, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, 0x0a, 0x06, \ + 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x04, 0x47, 0x30, 0x45, 0x02, 0x20, 0x29, 0x7f, 0xf6, 0x0e, \ + 0x4c, 0x72, 0x38, 0x77, 0x19, 0xfc, 0xb9, 0x7c, 0x08, 0x71, 0x8a, 0x88, 0x61, 0xf7, 0x0a, 0xf7, 0xf0, 0x63, 0x43, \ + 0x09, 0x69, 0xb0, 0x40, 0xf2, 0xce, 0xfd, 0x69, 0x15, 0x02, 0x21, 0x00, 0xa8, 0xd1, 0x6e, 0xae, 0xd5, 0x7f, 0x28, \ + 0x34, 0x0d, 0x21, 0x65, 0xa3, 0x3f, 0xc4, 0x4c, 0x8b, 0x26, 0x26, 0x3f, 0xb2, 0xac, 0x8f, 0x22, 0xe4, 0xff, 0xbd, \ + 0x9b, 0x48, 0x2d, 0x7e, 0xc9, 0x17, \ + } + +// All remaining data will be pulled from the provisioning region of flash. +#endif + +#else + // Use a default setup PIN code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 @@ -63,6 +113,8 @@ */ #define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8006 +#endif + /** * CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION * @@ -126,7 +178,7 @@ * provision the device with its unique operational credentials and manage * its own access control lists. */ -#define CHIP_CONFIG_MAX_FABRICS 4 // 3 fabrics + 1 for rotation slack +#define CHIP_CONFIG_MAX_FABRICS 5 // 5 is the minimum number of supported fabrics #define CHIP_DEVICE_CONFIG_ENABLE_SED 1 #define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL 1000_ms32 diff --git a/examples/lock-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h b/examples/lock-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h index 25c298f039198b..22d311ad15326c 100644 --- a/examples/lock-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h +++ b/examples/lock-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h @@ -67,7 +67,10 @@ #define configUSE_ALTERNATIVE_API 0 /* Deprecated! */ #define configQUEUE_REGISTRY_SIZE 8 #define configUSE_QUEUE_SETS 0 -#define configUSE_TIME_SLICING 0 +/* make sure that Thread task can interrupt lengthy Matter + * processing in case priority inversion occurs + */ +#define configUSE_TIME_SLICING 1 #define configUSE_NEWLIB_REENTRANT 0 #define configENABLE_BACKWARD_COMPATIBILITY 1 #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 diff --git a/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp b/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp index 3a78c9c7f632c4..cb78aef83ee0cd 100644 --- a/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp @@ -21,15 +21,15 @@ #include #include +#include #include #include #include +#include #include #include #include -#include - #include #include #include @@ -38,6 +38,7 @@ #include "Keyboard.h" #include "LED.h" #include "LEDWidget.h" +#include "PWR_Interface.h" #include "app_config.h" #if CHIP_CRYPTO_HSM @@ -52,7 +53,6 @@ constexpr uint8_t kAppEventQueueSize = 10; TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer. -static SemaphoreHandle_t sCHIPEventLock; static QueueHandle_t sAppEventQueue; #if !cPWR_UsePowerDownMode @@ -95,7 +95,16 @@ CHIP_ERROR AppTask::Init() // Init ZCL Data Model and start server PlatformMgr().ScheduleWork(InitServer, 0); - // Initialize device attestation config +// Initialize device attestation config +#if CONFIG_CHIP_K32W0_REAL_FACTORY_DATA + // Initialize factory data provider + ReturnErrorOnFailure(K32W0FactoryDataProvider::GetDefaultInstance().Init()); +#if CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER + SetDeviceInstanceInfoProvider(&K32W0FactoryDataProvider::GetDefaultInstance()); +#endif + SetDeviceAttestationCredentialsProvider(&K32W0FactoryDataProvider::GetDefaultInstance()); + SetCommissionableDataProvider(&K32W0FactoryDataProvider::GetDefaultInstance()); +#else #ifdef ENABLE_HSM_DEVICE_ATTESTATION SetDeviceAttestationCredentialsProvider(Examples::GetExampleSe05xDACProvider()); #else @@ -104,6 +113,7 @@ CHIP_ERROR AppTask::Init() // QR code will be used with CHIP Tool PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); +#endif /* HW init leds */ #if !cPWR_UsePowerDownMode @@ -142,13 +152,6 @@ CHIP_ERROR AppTask::Init() BoltLockMgr().SetCallbacks(ActionInitiated, ActionCompleted); - sCHIPEventLock = xSemaphoreCreateMutex(); - if (sCHIPEventLock == NULL) - { - K32W_LOG("xSemaphoreCreateMutex() failed"); - assert(err == CHIP_NO_ERROR); - } - // Print the current software version char currentSoftwareVer[ConfigurationManager::kMaxSoftwareVersionStringLength + 1] = { 0 }; err = ConfigurationMgr().GetSoftwareVersionString(currentSoftwareVer, sizeof(currentSoftwareVer)); @@ -158,7 +161,7 @@ CHIP_ERROR AppTask::Init() assert(err == CHIP_NO_ERROR); } - PlatformMgr().AddEventHandler(ThreadProvisioningHandler, 0); + PlatformMgr().AddEventHandler(MatterEventHandler, 0); K32W_LOG("Current Software Version: %s", currentSoftwareVer); return err; @@ -181,6 +184,10 @@ void AppTask::InitServer(intptr_t arg) static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); + auto & infoProvider = chip::DeviceLayer::DeviceInfoProviderImpl::GetDefaultInstance(); + infoProvider.SetStorageDelegate(initParams.persistentStorageDelegate); + chip::DeviceLayer::SetDeviceInfoProvider(&infoProvider); + // Init ZCL Data Model and start server chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; nativeParams.lockCb = LockOpenThreadTask; @@ -542,7 +549,11 @@ void AppTask::BleHandler(void * aGenericEvent) K32W_LOG("Another function is scheduled. Could not toggle BLE state!"); return; } + PlatformMgr().ScheduleWork(AppTask::BleStartAdvertising, 0); +} +void AppTask::BleStartAdvertising(intptr_t arg) +{ if (ConnectivityMgr().IsBLEAdvertisingEnabled()) { ConnectivityMgr().SetBLEAdvertisingEnabled(false); @@ -563,7 +574,7 @@ void AppTask::BleHandler(void * aGenericEvent) } } -void AppTask::ThreadProvisioningHandler(const ChipDeviceEvent * event, intptr_t) +void AppTask::MatterEventHandler(const ChipDeviceEvent * event, intptr_t) { if (event->Type == DeviceEventType::kServiceProvisioningChange && event->ServiceProvisioningChange.IsServiceProvisioned) { diff --git a/examples/lock-app/nxp/k32w/k32w0/main/include/AppTask.h b/examples/lock-app/nxp/k32w/k32w0/main/include/AppTask.h index 9e0116cacf7e8d..db06766b56c193 100644 --- a/examples/lock-app/nxp/k32w/k32w0/main/include/AppTask.h +++ b/examples/lock-app/nxp/k32w/k32w0/main/include/AppTask.h @@ -23,6 +23,7 @@ #include "AppEvent.h" #include "BoltLockManager.h" +#include "K32W0FactoryDataProvider.h" #include @@ -57,6 +58,7 @@ class AppTask static void HandleKeyboard(void); static void JoinHandler(void * aGenericEvent); static void BleHandler(void * aGenericEvent); + static void BleStartAdvertising(intptr_t arg); static void LockActionEventHandler(void * aGenericEvent); static void ResetActionEventHandler(void * aGenericEvent); static void InstallEventHandler(void * aGenericEvent); @@ -64,7 +66,7 @@ class AppTask static void ButtonEventHandler(uint8_t pin_no, uint8_t button_action); static void TimerEventHandler(TimerHandle_t xTimer); - static void ThreadProvisioningHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); + static void MatterEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); static void UpdateClusterStateInternal(intptr_t arg); static void ThreadStart(); static void InitServer(intptr_t arg); diff --git a/examples/lock-app/nxp/k32w/k32w0/main/main.cpp b/examples/lock-app/nxp/k32w/k32w0/main/main.cpp index a792030a7c78b0..4692a4068c6d52 100644 --- a/examples/lock-app/nxp/k32w/k32w0/main/main.cpp +++ b/examples/lock-app/nxp/k32w/k32w0/main/main.cpp @@ -36,8 +36,6 @@ using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; using namespace ::chip::Logging; -#define ENABLE_LOW_POWER_LOGS 0 - #if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) #include "Keyboard.h" #include "OtaSupport.h" @@ -52,39 +50,18 @@ using namespace ::chip::Logging; #include "MacSched.h" typedef void (*InitFunc)(void); + extern InitFunc __init_array_start; extern InitFunc __init_array_end; +extern "C" void sched_enable(); + /* low power requirements */ #if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) -extern "C" void vMMAC_IntHandlerBbc(); -extern "C" void vMMAC_IntHandlerPhy(); -extern "C" void BOARD_SetClockForPowerMode(void); -extern "C" void stopM2(); - -static void dm_switch_wakeupCallBack(void); -static void dm_switch_preSleepCallBack(void); -static void ThreadExitSleep(); -static void BOARD_SetClockForWakeup(void); - -typedef struct -{ - bool_t bleAppRunning; - bool_t bleAppStopInprogress; - bool_t threadInitialized; - uint32_t threadWarmBootInitTime; -} sDualModeAppStates; - -typedef void * appCallbackParam_t; -typedef void (*appCallbackHandler_t)(appCallbackParam_t param); - -static sDualModeAppStates dualModeStates; - -#define THREAD_WARM_BOOT_INIT_DURATION_DEFAULT_VALUE 4000 +extern "C" void setThreadInitialized(bool isInitialized); +extern "C" bool isThreadInitialized(); #endif -extern "C" void sched_enable(); - /* needed for FreeRtos Heap 4 */ uint8_t __attribute__((section(".heap"))) ucHeap[HEAP_SIZE]; @@ -99,26 +76,13 @@ extern "C" void main_task(void const * argument) (*pFunc)(); } + mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree); err = PlatformMgrImpl().InitBoardFwk(); if (err != CHIP_NO_ERROR) { return; } -#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) - PWR_Init(); - - /* Internal - MATTER-303: keep in retention the entire RAM1 for the moment */ - PWR_vAddRamRetention((uint32_t) 0x4020000, 0x10000); - - PWR_RegisterLowPowerExitCallback(dm_switch_wakeupCallBack); - PWR_RegisterLowPowerEnterCallback(dm_switch_preSleepCallBack); - - dm_lp_init(); -#endif - - mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree); - K32W_LOG("Welcome to NXP ELock Demo App"); /* Mbedtls Threading support is needed because both @@ -147,23 +111,15 @@ extern "C" void main_task(void const * argument) */ sched_enable(); -#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) - dualModeStates.threadWarmBootInitTime = THREAD_WARM_BOOT_INIT_DURATION_DEFAULT_VALUE; - dualModeStates.threadInitialized = TRUE; -#endif - ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); if (ret != CHIP_NO_ERROR) { goto exit; } - ret = PlatformMgr().StartEventLoopTask(); - if (ret != CHIP_NO_ERROR) - { - K32W_LOG("Error during PlatformMgr().StartEventLoopTask();"); - goto exit; - } +#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) + setThreadInitialized(TRUE); +#endif // Start OpenThread task ret = ThreadStackMgrImpl().StartThreadTask(); @@ -180,6 +136,13 @@ extern "C" void main_task(void const * argument) goto exit; } + ret = PlatformMgr().StartEventLoopTask(); + if (ret != CHIP_NO_ERROR) + { + K32W_LOG("Error during PlatformMgr().StartEventLoopTask();"); + goto exit; + } + GetAppTask().AppTaskMain(NULL); exit: @@ -195,180 +158,10 @@ extern "C" void otSysEventSignalPending(void) #if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) /* make sure that 15.4 radio is initialized before waking up the Thread task */ - if (dualModeStates.threadInitialized == TRUE) + if (isThreadInitialized()) #endif { BaseType_t yieldRequired = ThreadStackMgrImpl().SignalThreadActivityPendingFromISR(); portYIELD_FROM_ISR(yieldRequired); } } - -#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) -uint32_t dm_switch_get15_4InitWakeUpTime(void) -{ - return dualModeStates.threadWarmBootInitTime; -} - -extern "C" bleResult_t App_PostCallbackMessage(appCallbackHandler_t handler, appCallbackParam_t param) -{ - AppEvent event; - event.Type = AppEvent::kEventType_Lp; - - event.Handler = handler; - event.param = param; - -#if ENABLE_LOW_POWER_LOGS - K32W_LOG("App_PostCallbackMessage %d", (uint32_t) param); -#endif - - GetAppTask().PostEvent(&event); - - return gBleSuccess_c; -} - -static void dm_switch_wakeupCallBack(void) -{ - BOARD_SetClockForWakeup(); - -#if ENABLE_LOW_POWER_LOGS - K32W_LOG("dm_switch_wakeupCallBack"); - K32W_LOG("Warm up time actual value: %d", dualModeStates.threadWarmBootInitTime); -#endif - - RNG_Init(); - SecLib_Init(); - - KBD_PrepareExitLowPower(); - - PWR_WakeupReason_t wakeReason = PWR_GetWakeupReason(); - if (wakeReason.Bits.FromBLE_LLTimer == 1) - { -#if ENABLE_LOW_POWER_LOGS - K32W_LOG("woken up from LL"); -#endif - } - else if (wakeReason.Bits.FromKeyBoard == 1) - { -#if ENABLE_LOW_POWER_LOGS - K32W_LOG("woken up from FromKeyBoard"); -#endif - } - else if (wakeReason.Bits.FromTMR == 1) - { -#if ENABLE_LOW_POWER_LOGS - K32W_LOG("woken up from TMR"); -#endif - } - dm_lp_wakeup(); -} - -static void dm_switch_preSleepCallBack(void) -{ -#if ENABLE_LOW_POWER_LOGS - K32W_LOG("dm_switch_preSleepCallBack"); -#endif - - if (dualModeStates.threadInitialized) - { - /* stop the internal MAC Scheduler timer */ - stopM2(); - /* disable the MAC scheduler */ - sched_disable(); - otPlatRadioDisable(NULL); - dualModeStates.threadInitialized = FALSE; - } - /* Inform the low power dual mode module that we will sleep */ - dm_lp_preSleep(); - - /* configure pins for power down mode */ - BOARD_SetPinsForPowerMode(); - /* DeInitialize application support for drivers */ - BOARD_DeInitAdc(); - /* DeInit the necessary clocks */ - BOARD_SetClockForPowerMode(); -} - -extern "C" void vDynStopAll(void) -{ - vDynRequestState(E_DYN_SLAVE, E_DYN_STATE_OFF); - vDynRequestState(E_DYN_MASTER, E_DYN_STATE_OFF); -} - -void dm_switch_init15_4AfterWakeUp(void) -{ - uint32_t tick1 = 0; - uint32_t tick2 = 0; - - if (dualModeStates.threadWarmBootInitTime == THREAD_WARM_BOOT_INIT_DURATION_DEFAULT_VALUE) - { - /* Get a 32K tick */ - PWR_Start32kCounter(); - tick1 = PWR_Get32kTimestamp(); - } - - /* Radio must be re-enabled after waking up from sleep. - * The module is completely disabled in power down mode */ - ThreadExitSleep(); - - if (dualModeStates.threadWarmBootInitTime == THREAD_WARM_BOOT_INIT_DURATION_DEFAULT_VALUE) - { - tick2 = PWR_Get32kTimestamp(); - dualModeStates.threadWarmBootInitTime = ((tick2 - tick1) * 15625u) >> 9; - - /* Add a margin of 1 ms */ - dualModeStates.threadWarmBootInitTime += 1000; - -#if ENABLE_LOW_POWER_LOGS - K32W_LOG("Calibration: %d", dualModeStates.threadWarmBootInitTime); -#endif - } -} - -static void ThreadExitSleep() -{ - if (!dualModeStates.threadInitialized && ConnectivityMgr().IsThreadEnabled()) - { - /* Install uMac interrupt handlers */ - OSA_InstallIntHandler(ZIGBEE_MAC_IRQn, vMMAC_IntHandlerBbc); - OSA_InstallIntHandler(ZIGBEE_MODEM_IRQn, vMMAC_IntHandlerPhy); - - /* Radio must be re-enabled after waking up from sleep. - * The module is completely disabled in power down mode */ - otPlatRadioEnable(NULL); - sched_enable(); - - dualModeStates.threadInitialized = TRUE; - - /* wake up the Thread stack and check if any processing needs to be done */ - otTaskletsSignalPending(NULL); - } -} - -extern "C" void App_NotifyWakeup(void) -{ - if ((!dualModeStates.threadInitialized)) - { - /* Notify the dual mode low power mode */ - (void) App_PostCallbackMessage(dm_lp_processEvent, (void *) e15_4WakeUpEnded); - } -} - -extern "C" void App_AllowDeviceToSleep() -{ - PWR_PreventEnterLowPower(false); -} - -extern "C" void App_DisallowDeviceToSleep() -{ - PWR_PreventEnterLowPower(true); -} - -static void BOARD_SetClockForWakeup(void) -{ - /* Enables the clock for the I/O controller block. 0: Disable. 1: Enable.: 0x01u */ - CLOCK_EnableClock(kCLOCK_Iocon); - /* Enables the clock for the GPIO0 module */ - CLOCK_EnableClock(kCLOCK_Gpio0); -} - -#endif diff --git a/examples/lock-app/qpg/BUILD.gn b/examples/lock-app/qpg/BUILD.gn index 60bdcd4bf75ced..ac901678db266c 100644 --- a/examples/lock-app/qpg/BUILD.gn +++ b/examples/lock-app/qpg/BUILD.gn @@ -61,6 +61,7 @@ qpg_executable("lock_app") { ] deps = [ + ":factorydata_lib", ":sdk", "${chip_root}/examples/lock-app/lock-common", "${chip_root}/examples/providers:device_info_provider", @@ -151,3 +152,15 @@ group("qpg") { group("default") { deps = [ ":qpg" ] } + +static_library("factorydata_lib") { + libs = [ "${qpg_sdk_root}/Binaries/FactoryData/FactoryData_example/FactoryData_example.a" ] + public_configs = [ ":qpg_retain_factorydata" ] +} + +config("qpg_retain_factorydata") { + ldflags = [ + "-Wl,-u_binary_factory_data_bin_start", + "-Wl,-u_binary_factory_data_start", + ] +} diff --git a/examples/lock-app/qpg/include/AppTask.h b/examples/lock-app/qpg/include/AppTask.h index 005d0aeb9da6e0..997257ed8352bf 100644 --- a/examples/lock-app/qpg/include/AppTask.h +++ b/examples/lock-app/qpg/include/AppTask.h @@ -31,6 +31,8 @@ #include #include +#include + // Application-defined error codes in the CHIP_ERROR space. #define APP_ERROR_CREATE_TIMER_FAILED CHIP_APPLICATION_ERROR(0x01) @@ -82,6 +84,8 @@ class AppTask bool mFunctionTimerActive; bool mSyncClusterToButtonAction; + chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; + static AppTask sAppTask; }; diff --git a/examples/lock-app/qpg/include/CHIPProjectConfig.h b/examples/lock-app/qpg/include/CHIPProjectConfig.h index cd3121bab0be33..6977241a195b00 100644 --- a/examples/lock-app/qpg/include/CHIPProjectConfig.h +++ b/examples/lock-app/qpg/include/CHIPProjectConfig.h @@ -48,7 +48,7 @@ * 0xFFF1: Test vendor. */ #ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID -#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1 +#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0x10D0 #endif // CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID /** diff --git a/examples/lock-app/qpg/src/AppTask.cpp b/examples/lock-app/qpg/src/AppTask.cpp index 80217ecf0437ff..993a91068049b9 100644 --- a/examples/lock-app/qpg/src/AppTask.cpp +++ b/examples/lock-app/qpg/src/AppTask.cpp @@ -140,8 +140,11 @@ CHIP_ERROR AppTask::Init() // Init ZCL Data Model and start server PlatformMgr().ScheduleWork(InitServer, 0); - // Initialize device attestation config - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); + ReturnErrorOnFailure(mFactoryDataProvider.Init()); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + SetCommissionableDataProvider(&mFactoryDataProvider); + + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); // Setup Bolt err = BoltLockMgr().Init(); diff --git a/examples/ota-requestor-app/telink/include/AppTask.h b/examples/ota-requestor-app/telink/include/AppTask.h index 296e45746e1fc3..712212e38fd80d 100755 --- a/examples/ota-requestor-app/telink/include/AppTask.h +++ b/examples/ota-requestor-app/telink/include/AppTask.h @@ -20,7 +20,7 @@ #include "AppEvent.h" -#include +#include #include diff --git a/examples/ota-requestor-app/telink/prj.conf b/examples/ota-requestor-app/telink/prj.conf index 5850ae2cd7ee51..7f270da20b8e5f 100755 --- a/examples/ota-requestor-app/telink/prj.conf +++ b/examples/ota-requestor-app/telink/prj.conf @@ -30,7 +30,7 @@ CONFIG_OPENTHREAD_PANID=4660 CONFIG_OPENTHREAD_CHANNEL=15 CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" -CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154" +CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154_b91" # Disable Matter OTA DFU CONFIG_CHIP_OTA_REQUESTOR=y diff --git a/examples/ota-requestor-app/telink/src/AppTask.cpp b/examples/ota-requestor-app/telink/src/AppTask.cpp index 169606c5ece510..182f5732d0ec59 100644 --- a/examples/ota-requestor-app/telink/src/AppTask.cpp +++ b/examples/ota-requestor-app/telink/src/AppTask.cpp @@ -49,8 +49,8 @@ #include "OTAUtil.h" #endif -#include -#include +#include +#include #include diff --git a/examples/ota-requestor-app/telink/src/main.cpp b/examples/ota-requestor-app/telink/src/main.cpp index e10d113c62adec..48adaee45a5115 100644 --- a/examples/ota-requestor-app/telink/src/main.cpp +++ b/examples/ota-requestor-app/telink/src/main.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include LOG_MODULE_REGISTER(app); diff --git a/examples/platform/efr32/BaseApplication.cpp b/examples/platform/efr32/BaseApplication.cpp index 517f53de08a04d..bef8eb6ef54e0c 100644 --- a/examples/platform/efr32/BaseApplication.cpp +++ b/examples/platform/efr32/BaseApplication.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include diff --git a/examples/platform/efr32/MemMonitoring.cpp b/examples/platform/efr32/MemMonitoring.cpp index db8e3b752033fd..dff743aa17711e 100644 --- a/examples/platform/efr32/MemMonitoring.cpp +++ b/examples/platform/efr32/MemMonitoring.cpp @@ -21,7 +21,6 @@ #include "AppConfig.h" #include "FreeRTOS.h" #include -#include static StackType_t monitoringStack[MONITORING_STACK_SIZE_byte / sizeof(StackType_t)]; static StaticTask_t monitoringTaskStruct; diff --git a/examples/platform/esp32/common/CommonDeviceCallbacks.cpp b/examples/platform/esp32/common/CommonDeviceCallbacks.cpp index ba9eafc19c1397..754d3ef2e86211 100644 --- a/examples/platform/esp32/common/CommonDeviceCallbacks.cpp +++ b/examples/platform/esp32/common/CommonDeviceCallbacks.cpp @@ -79,7 +79,7 @@ void CommonDeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, i case DeviceEventType::kCommissioningComplete: { ESP_LOGI(TAG, "Commissioning complete"); -#if CONFIG_BT_NIMBLE_ENABLED && CONFIG_DEINIT_BLE_ON_COMMISSIONING_COMPLETE +#if CONFIG_BT_NIMBLE_ENABLED && CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING if (ble_hs_is_enabled()) { diff --git a/examples/platform/nxp/doc/manufacturing_flow.md b/examples/platform/nxp/doc/manufacturing_flow.md new file mode 100644 index 00000000000000..83afb4ab85335b --- /dev/null +++ b/examples/platform/nxp/doc/manufacturing_flow.md @@ -0,0 +1,116 @@ + + +## Manufacturing data + +By default, the example application is configured to use generic test +certificates and provisioning data embedded with the application code. It is +possible for a final stage application to generate its own manufacturing data: + +- Generate new certificates + + _PAI_VID_ and _PAI_PID_ variables must be changed accordingly inside + generate_cert.sh script + + _generate_cert.sh_ script needs as input parameter the path to chip-cert + tool (compile it from ./src/tools/chip-cert). The output of the script is: + the DAC, PAI and PAA certificates. The DAC and PAI certificates will be + written in a special section of the internal flash, while the PAA will be + used on the chip-tool side as trust anchor. Please note that for _real + production manufacturing_ the "production PAA" is trusted via the DCL rather + than thorough PAA certificate generated along with DAC and PAI. The PAI cert + may also have a different lifecycle. + + ``` + user@ubuntu:~/Desktop/git/connectedhomeip$ ./examples/platform/nxp/k32w/k32w0/scripts/generate_cert.sh ./src/tools/chip-cert/out/chip-cert + ``` + +* Generate new provisioning data and convert all the data to a binary: + + ``` + user@ubuntu:~/Desktop/git/connectedhomeip$ python3 ./scripts/tools/nxp/generate_nxp_chip_factory_bin.py -i 10000 -s ABCDEFGHIJKLMNOPQRSXYZ -p 14014 -d 1000 --dac_cert /home/ubuntu/manufacturing/Chip-DAC-NXP-Cert.der --dac_key /home/ubuntu/manufacturing/Chip-DAC-NXP-Key.der --pai_cert /home/ubuntu/manufacturing/Chip-PAI-NXP-Cert.der --spake2p_path ./src/tools/spake2p/out/spake2p --out out.bin + ``` + + Here is the interpretation of the parameters: + + ``` + -i -> SPAKE2+ iteration + -s -> SPAKE2+ salt + -p -> SPAKE2+ passcode + - d -> discriminator + --dac_cert -> path to the DAC (der format) location + --dac_key -> path to the DAC key (der format) location + --pai_cert -> path to the PAI (der format) location + --spake2p_path -> path to the spake2p tool (compile it from ./src/tools/spake2p) + --out -> name of the binary that will be used for storing all the generated data + + ``` + +* Write out.bin to the internal flash at location 0x9D200: + + ``` + DK6Programmer.exe -Y -V2 -s -P 1000000 -Y -p FLASH@0x9D200="out.bin" + ``` + +* Generate a new CD (certification declaration): + + Inside _gen-test-cds.sh_, the parameters _vids_, _pid0_, _device_type_id_ + must be changed accordingly. Use _Chip-Test-CD-Signing-\*_ key and + certificate already available in + _./credentials/test/certification-declaration/_ which acts as CSA + Certificate. This CSA certificate is also hard-coded as Trust Anchor in the + current chip-tool version. To use this certificate and avoid generating a + new one, lines 69-70 must be commented in the _gen-test-cds.sh_ script (the + ones that are generating a new CD signing authority). + + ``` + user@ubuntu:~/Desktop/git/connectedhomeip$ ./credentials/test/gen-test-cds.sh ./src/tools/chip-cert/out/chip-cert + ``` + +* Set the correct VID/PID and CD in the + examples/\$APP_NAME/nxp/k32w/k32w0/ChipProjectConfig.h file VID and PID + values should correspond to the ones used for DAC. CD bytes should be the + ones obtained at the step above: + + ``` + user@ubuntu:~/manufacturing hexdump -ve '1/1 "0x%.2x, "' Chip-Test-CD-1037-A220.der + ``` + +* Use _chip_with_factory_data=1_ gn compilation argument + + This is needed in order to load the data from the special flash section. + Build and flash the application. + +* Run chip-tool with a new PAA: + + ``` + ./chip-tool pairing ble-thread 2 hex: $hex_value 14014 1000 --paa-trust-store-path /home/ubuntu/certs/paa + ``` + + Here is the interpretation of the parameters: + + ``` + --paa-trust-store-path -> path to the generated PAA (der format) + ``` + + _paa-trust-store-path_ must contain only the PAA certificate. Avoid placing + other certificates in the same location as this may confuse chip-tool. + + PAA certificate can be copied to the chip-tool machine using SCP for + example. + + This is needed for testing self-generated DACs, but likely not required for + "true production" with production PAI issued DACs. + +* Useful information/Known issues + + Implementation of manufacturing data provisioning has been validated using test certificates generated by OpenSSL 1.1.1l. + + Also, demo DAC, PAI and PAA certificates needed in case _chip_with_factory_data=1_ is used can be found in examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs. + + dut1/dut2 folders contains different DACs/Private Keys and can be used for testing topologies with 2 DUTS. + + out_dut1.bin/out2_dut2.bin contains the corresponding DACs/PAIs generated using generate_nxp_chip_factory_bin.py script. The discriminator is 14014 and the passcode is 1000. + + These demo certificates are working with the CDs installed in CHIPProjectConfig.h. + + diff --git a/examples/platform/nxp/k32w/k32w0/app/ldscripts/chip-k32w0x-linker.ld b/examples/platform/nxp/k32w/k32w0/app/ldscripts/chip-k32w0x-linker.ld index 359a9ef790336d..996d7d16e73766 100644 --- a/examples/platform/nxp/k32w/k32w0/app/ldscripts/chip-k32w0x-linker.ld +++ b/examples/platform/nxp/k32w/k32w0/app/ldscripts/chip-k32w0x-linker.ld @@ -54,11 +54,22 @@ m_int_sector_size = 512; /* first 8K: SSBL, next 8K: SSBL update region */ m_app_start = DEFINED(__app_load_address__) ? __app_load_address__ : 0x0; +/* PSECT: 8.5K */ +m_psect_size = 0x2200; + /* sizeof(BOOT_BLOCK_T) + sizeof(IMAGE_CERT_T) + SIGNATURE_LEN + alignment = 1024 bytes */ m_app_meta_data = 0x400; -/* 640K (Total Flash size) - 16K (SSBL + SSBL update region) - 8.5K (PSECT) - m_app_meta_data */ -m_app_size = DEFINED(__app_stated_size__) ? __app_stated_size__ : 0x9DE00; +/* manufacturing data: 2K */ +m_factory_data_size = 0x800; + +/* 16K: SSBL + SSBL update region */ +m_ssbl_size = 0x4000; + +/* default app size, without OTA */ +m_app_default_size = m_int_flash_size - m_psect_size - m_app_meta_data - m_factory_data_size; + +m_app_size = DEFINED(__app_stated_size__) ? __app_stated_size__ : m_app_default_size; MEMORY { @@ -88,9 +99,8 @@ NV_STORAGE_SECTOR_SIZE = m_ext_flash_sector_size; NV_STORAGE_START_ADDRESS = m_ext_flash_size - 1; NV_STORAGE_END_ADDRESS = NV_STORAGE_START_ADDRESS - NV_STORAGE_SIZE + 1; -INT_STORAGE_START = m_int_flash_size - 17 * m_int_sector_size - 1; -INT_STORAGE_END = INT_STORAGE_START; -INT_STORAGE_SIZE = INT_STORAGE_START - INT_STORAGE_END; +FACTORY_DATA_START_ADDRESS = m_int_flash_size - m_psect_size - m_app_meta_data - m_factory_data_size; +FACTORY_DATA_END_ADDRESS = FACTORY_DATA_START_ADDRESS + m_factory_data_size - 1; __ram_vector_table__ = 1; vector_table_size = 0x120; @@ -213,9 +223,8 @@ SECTIONS _etext = .; - .heap_packet_buffer (COPY): + .heap (COPY): { - *(.bss._ZN4chip6System12PacketBuffer11sBufferPoolE) __HeapBase = .; _heap = .; KEEP(*(.heap*)) @@ -353,4 +362,7 @@ SECTIONS PROVIDE(_scratch_buf_end = __scratch_area_top__); __StackLimit = _vStackTop - STACK_SIZE; + + __FACTORY_DATA_START = FACTORY_DATA_START_ADDRESS; + __FACTORY_DATA_SIZE = m_factory_data_size; } diff --git a/examples/platform/nxp/k32w/k32w0/app/project_include/OpenThreadConfig.h b/examples/platform/nxp/k32w/k32w0/app/project_include/OpenThreadConfig.h index ef95988da9ab24..93f6d442baefe9 100644 --- a/examples/platform/nxp/k32w/k32w0/app/project_include/OpenThreadConfig.h +++ b/examples/platform/nxp/k32w/k32w0/app/project_include/OpenThreadConfig.h @@ -94,9 +94,17 @@ #undef OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS #define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 44 -#undef OPENTHREAD_CONFIG_PLATFORM_CSL_UNCERT +#undef OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE +#define OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE 0 + +#undef OPENTHREAD_CONFIG_SRP_SERVER_ENABLE +#define OPENTHREAD_CONFIG_SRP_SERVER_ENABLE 0 + +#undef OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE +#define OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE 0 #define UART_USE_SERIAL_MGR 1 +#define UART_USE_SERIAL_MGR_LOG 1 //#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG diff --git a/examples/platform/nxp/k32w/k32w0/app/support/FreeRtosHooks.c b/examples/platform/nxp/k32w/k32w0/app/support/FreeRtosHooks.c index e6a445c1c086ff..508db54ca5dec2 100644 --- a/examples/platform/nxp/k32w/k32w0/app/support/FreeRtosHooks.c +++ b/examples/platform/nxp/k32w/k32w0/app/support/FreeRtosHooks.c @@ -236,14 +236,11 @@ extern void OTAIdleActivities(void); void vApplicationIdleHook(void) { - // Data queued by PDM will be written to external flash - // when PDM_vIdleTask is called. Interrupts are disabled - // to ensure there is no context switch during the actual - // writing, thus avoiding race conditions. - OSA_InterruptDisable(); + vTaskSuspendAll(); PDM_vIdleTask(PDM_MAX_WRITES_INFINITE); - OSA_InterruptEnable(); + xTaskResumeAll(); OTAIdleActivities(); + BOARD_ActionOnIdle(); } diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Cert.der b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Cert.der new file mode 100755 index 00000000000000..80eb11aa573fee Binary files /dev/null and b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Cert.der differ diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Cert.pem b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Cert.pem new file mode 100755 index 00000000000000..e467b093f6a28a --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Cert.pem @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIIB5jCCAYygAwIBAgIIZgPMHtK+Wn4wCgYIKoZIzj0EAwIwOzEjMCEGA1UEAwwa +TWF0dGVyIERldmVsb3BtZW50IFBBSSBOWFAxFDASBgorBgEEAYKifAIBDAQxMDM3 +MB4XDTIyMDYyMTEyMzUwMFoXDTQyMDYyMTEyMzQ1OVowVTEnMCUGA1UEAwweTWF0 +dGVyIERldmVsb3BtZW50IERBQyBOWFAgRFUxMRQwEgYKKwYBBAGConwCAQwEMTAz +NzEUMBIGCisGAQQBgqJ8AgIMBEEyMjAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNC +AAQ2xRRlWgCVrPUWGVwwXjd7BGCfeoxR43oFf0T955Yhyb62bfjGyxoqgVRhALev +xZ1HCOZFFgAArF+pTwTl9xHMo2AwXjAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQE +AwIHgDAdBgNVHQ4EFgQUBJFdqWUeMYS6IHLXMfkD8SnetdEwHwYDVR0jBBgwFoAU +fRAzA1R+yGDsCvy0Xa92l7FVBAcwCgYIKoZIzj0EAwIDSAAwRQIgTjcPmGhCLfkW +GmIyGbVmZlYjRcTy2PdkwPKRomH3KhkCIQCEqPhvzv7vQ8IHN/Fcrxx/7PJspPWX +oqjcqu2kLbw1gg== +-----END CERTIFICATE----- diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Key.der b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Key.der new file mode 100755 index 00000000000000..f0943691f6e016 Binary files /dev/null and b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Key.der differ diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Key.pem b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Key.pem new file mode 100755 index 00000000000000..7e45934095653a --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIKmuMMUZ81nVyLaRPvz66ExigTk8agUMb2yICgB0rv9CoAoGCCqGSM49 +AwEHoUQDQgAENsUUZVoAlaz1FhlcMF43ewRgn3qMUeN6BX9E/eeWIcm+tm34xssa +KoFUYQC3r8WdRwjmRRYAAKxfqU8E5fcRzA== +-----END EC PRIVATE KEY----- diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/out_dut1.bin b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/out_dut1.bin new file mode 100644 index 00000000000000..44370e1deb3a2f Binary files /dev/null and b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/out_dut1.bin differ diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Cert.der b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Cert.der new file mode 100755 index 00000000000000..54dd60e3afc3c4 Binary files /dev/null and b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Cert.der differ diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Cert.pem b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Cert.pem new file mode 100755 index 00000000000000..b1ca72c3fd85e5 --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Cert.pem @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIIB5jCCAYygAwIBAgIIKgA7aa0WwLIwCgYIKoZIzj0EAwIwOzEjMCEGA1UEAwwa +TWF0dGVyIERldmVsb3BtZW50IFBBSSBOWFAxFDASBgorBgEEAYKifAIBDAQxMDM3 +MB4XDTIyMDYyMTEyMzUwMFoXDTQyMDYyMTEyMzQ1OVowVTEnMCUGA1UEAwweTWF0 +dGVyIERldmVsb3BtZW50IERBQyBOWFAgRFUyMRQwEgYKKwYBBAGConwCAQwEMTAz +NzEUMBIGCisGAQQBgqJ8AgIMBEEyMjAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNC +AATt1g9trweSBeebJqzVEKEGbqb9d25stXL7rYpDDJW3ReN6fsZPE63wUNfCAR4r +1C5XLeDZ9iWik+aOjk6VrIP9o2AwXjAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQE +AwIHgDAdBgNVHQ4EFgQU/f51OzcNZuWpWCe/fJTPx+WHtO0wHwYDVR0jBBgwFoAU +fRAzA1R+yGDsCvy0Xa92l7FVBAcwCgYIKoZIzj0EAwIDSAAwRQIgH1isFOQqCvx7 +8qnqgWX+q1G51r75/T8GivnrXL0rXGUCIQCzb09PQFpbI2/ByhrcfzgnQ21IJU9o +oexByare1eLdKQ== +-----END CERTIFICATE----- diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Key.der b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Key.der new file mode 100755 index 00000000000000..a8e3adccff66d4 Binary files /dev/null and b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Key.der differ diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Key.pem b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Key.pem new file mode 100755 index 00000000000000..df1f3ce731ebbf --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIDHJPAvGN+VO8BjTlewIRqc6zNpduVXS4g+t22jGRqcSoAoGCCqGSM49 +AwEHoUQDQgAE7dYPba8HkgXnmyas1RChBm6m/XdubLVy+62KQwyVt0Xjen7GTxOt +8FDXwgEeK9QuVy3g2fYlopPmjo5OlayD/Q== +-----END EC PRIVATE KEY----- diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/out_dut2.bin b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/out_dut2.bin new file mode 100644 index 00000000000000..f47a8b4c53a908 Binary files /dev/null and b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/out_dut2.bin differ diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/paa/Chip-PAA-NXP-Cert.der b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/paa/Chip-PAA-NXP-Cert.der new file mode 100755 index 00000000000000..6cac4f1b9b2bc4 Binary files /dev/null and b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/paa/Chip-PAA-NXP-Cert.der differ diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/paa/Chip-PAA-NXP-Cert.pem b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/paa/Chip-PAA-NXP-Cert.pem new file mode 100755 index 00000000000000..afe76f7d88289e --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/paa/Chip-PAA-NXP-Cert.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIBrzCCAVagAwIBAgIIeg5y/dGw1n4wCgYIKoZIzj0EAwIwKjEoMCYGA1UEAwwf +TWF0dGVyIERldmVsb3BtZW50IFBBQSBOWFAgRFVUMTAeFw0yMjA2MjExMjM1MDBa +Fw00MjA2MjExMjM0NTlaMCoxKDAmBgNVBAMMH01hdHRlciBEZXZlbG9wbWVudCBQ +QUEgTlhQIERVVDEwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQfWsi2VGaKXnUU +y5RGlxG6KpWa1Ah4kH4Y04awekKIP40ThTehyFjA5Eodk3iKHMWToql6qgb9bGI3 +dlZqcaJ/o2YwZDASBgNVHRMBAf8ECDAGAQH/AgEBMA4GA1UdDwEB/wQEAwIBBjAd +BgNVHQ4EFgQUGCGzIijRrTSwo2WQ/vNpHwXGDigwHwYDVR0jBBgwFoAUGCGzIijR +rTSwo2WQ/vNpHwXGDigwCgYIKoZIzj0EAwIDRwAwRAIgLrcK1ajZ9t3wFdvJSlTD +Pxs1vX9Yupo6gkTYPT402/gCIHI0t7/vBtbrIzkQjECaP8RKjZBRnHZMJKmq/iC1 +TE2d +-----END CERTIFICATE----- diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/paa/Chip-PAA-NXP-Key.pem b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/paa/Chip-PAA-NXP-Key.pem new file mode 100755 index 00000000000000..c23bda31c672bb --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/paa/Chip-PAA-NXP-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIGCbZQaonIEp+xqd8cBnOBetY0DWNBhkZj6SV1HXqhtnoAoGCCqGSM49 +AwEHoUQDQgAEH1rItlRmil51FMuURpcRuiqVmtQIeJB+GNOGsHpCiD+NE4U3ochY +wORKHZN4ihzFk6KpeqoG/WxiN3ZWanGifw== +-----END EC PRIVATE KEY----- diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Cert.der b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Cert.der new file mode 100755 index 00000000000000..752de457abb0bf Binary files /dev/null and b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Cert.der differ diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Cert.pem b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Cert.pem new file mode 100755 index 00000000000000..851c024c11355a --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Cert.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIBwjCCAWegAwIBAgIIVqlFNQn5J8owCgYIKoZIzj0EAwIwKjEoMCYGA1UEAwwf +TWF0dGVyIERldmVsb3BtZW50IFBBQSBOWFAgRFVUMTAeFw0yMjA2MjExMjM1MDBa +Fw00MjA2MjExMjM0NTlaMDsxIzAhBgNVBAMMGk1hdHRlciBEZXZlbG9wbWVudCBQ +QUkgTlhQMRQwEgYKKwYBBAGConwCAQwEMTAzNzBZMBMGByqGSM49AgEGCCqGSM49 +AwEHA0IABO1YVFx9LQaA2mcD5DnpA0QTHmotGERCvb8ujV7k9h9VNQ9/4/moeLAa +aXmeEhbKQSfmffTtIkg4sbou5Lb/TW2jZjBkMBIGA1UdEwEB/wQIMAYBAf8CAQAw +DgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR9EDMDVH7IYOwK/LRdr3aXsVUEBzAf +BgNVHSMEGDAWgBQYIbMiKNGtNLCjZZD+82kfBcYOKDAKBggqhkjOPQQDAgNJADBG +AiEAzaTJNdqkVxeRSuVEMhQj6TytmpcozfWQ4j3qAVETw0YCIQCmRN7DwYCowfAx +Czx5cgJwHbqbEVy5C39voNFTAMouFg== +-----END CERTIFICATE----- diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Key.pem b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Key.pem new file mode 100755 index 00000000000000..8fdf7698dbc1e2 --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEICQz6OJVkUzCuN9bJOvSBzcO/YZke3JfahE5kMVTCv2moAoGCCqGSM49 +AwEHoUQDQgAE7VhUXH0tBoDaZwPkOekDRBMeai0YREK9vy6NXuT2H1U1D3/j+ah4 +sBppeZ4SFspBJ+Z99O0iSDixui7ktv9NbQ== +-----END EC PRIVATE KEY----- diff --git a/examples/platform/nxp/k32w/k32w0/scripts/generate_cert.sh b/examples/platform/nxp/k32w/k32w0/scripts/generate_cert.sh new file mode 100755 index 00000000000000..172662ed192496 --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/generate_cert.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +# +# +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# 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: +# This is a utility script that creates PAA, PAI and DAC certificates for NXP factory data. +# + +if [ -z "$1" ]; then + echo "Usage: ./generate_cert.sh chip-cert-path" + exit 1 +fi + +CHIP_CERT_TOOL="$1" + +function exit_err() { + echo "${1}" + exit 1 +} + +DATE="2022-06-21 12:35:00" +LIFETIME="7305" + +PAA_DATE="$DATE" +PAA_LIFETIME="$LIFETIME" +PAA_CERT="Chip-PAA-NXP-Cert.pem" +PAA_KEY="Chip-PAA-NXP-Key.pem" + +PAI_DATE="$DATE" +PAI_LIFETIME="$LIFETIME" +PAI_VID="1037" +PAI_PID="A220" +PAI_CERT="Chip-PAI-NXP-"$PAI_VID"-"$PAI_PID"-Cert.pem" +PAI_CERT_DER="Chip-PAI-NXP-"$PAI_VID"-"$PAI_PID"-Cert.der" +PAI_KEY="Chip-PAI-NXP-"$PAI_VID"-"$PAI_PID"-Key.pem" + +DAC_DATE="$DATE" +DAC_LIFETIME="$LIFETIME" +DAC_VID="$PAI_VID" +DAC_PID="$PAI_PID" +DAC_CERT="Chip-DAC-NXP-"$DAC_VID"-"$DAC_PID"-Cert.pem" +DAC_CERT_DER="Chip-DAC-NXP-"$DAC_VID"-"$DAC_PID"-Cert.der" +DAC_KEY="Chip-DAC-NXP-"$DAC_VID"-"$DAC_PID"-Key.pem" +DAC_KEY_DER="Chip-DAC-NXP-"$DAC_VID"-"$DAC_PID"-Key.der" + +# Remove certificates if present +rm -rf "$PAA_CERT" "$PAA_KEY" "$PAI_CERT" "$PAI_KEY" "$DAC_CERT" "$DAC_KEY" "$PAI_CERT_DER" "$DAC_CERT_DER" "$DAC_KEY_DER" >/dev/null 2>&1 + +# Generate certificates +echo "Generate certificates" + +# PAA (root authoritity) +"$CHIP_CERT_TOOL" gen-att-cert --type a --subject-cn "Matter Development PAA NXP" --valid-from "$PAA_DATE" --lifetime "$PAA_LIFETIME" --out-key "$PAA_KEY" --out "$PAA_CERT" && echo "Generated PAA" || exit_err "Failed to generate PAA" + +# PAI (vendor) +"$CHIP_CERT_TOOL" gen-att-cert --type i --subject-cn "Matter Development PAI NXP" --subject-vid "$PAI_VID" --valid-from "$PAI_DATE" --lifetime "$PAI_LIFETIME" --ca-key "$PAA_KEY" --ca-cert "$PAA_CERT" --out-key "$PAI_KEY" --out "$PAI_CERT" && echo "Generated PAI" || exit_err "Failed to generate PAI" + +# DAC (product) +"$CHIP_CERT_TOOL" gen-att-cert --type d --subject-cn "Matter Development DAC NXP" --subject-vid "$DAC_VID" --subject-pid "$DAC_PID" --valid-from "$DAC_DATE" --lifetime "$DAC_LIFETIME" --ca-key "$PAI_KEY" --ca-cert "$PAI_CERT" --out-key "$DAC_KEY" --out "$DAC_CERT" && echo "Generated DAC" || exit_err "Failed to generate DAC" + +# Convert certificates and keys to der format (binary x509) +echo "Convert certificates and keys to DER format" + +# PAI +"$CHIP_CERT_TOOL" convert-cert -d "$PAI_CERT" "$PAI_CERT_DER" && echo "Converted PAI" || exit_err "Failed to convert PAI" + +# DAC Cer +"$CHIP_CERT_TOOL" convert-cert -d "$DAC_CERT" "$DAC_CERT_DER" && echo "Converted DAC Cert" || exit_err "Failed to convert DAC Cert" + +# DAC Key +"$CHIP_CERT_TOOL" convert-key -d "$DAC_KEY" "$DAC_KEY_DER" && echo "Converted DAC Key" || exit_err "Failed to convert DAC Key" diff --git a/examples/platform/telink/util/include/ButtonManager.h b/examples/platform/telink/util/include/ButtonManager.h index 165ac19f71bf37..9c164fd7120c82 100644 --- a/examples/platform/telink/util/include/ButtonManager.h +++ b/examples/platform/telink/util/include/ButtonManager.h @@ -17,8 +17,8 @@ #pragma once -#include #include +#include #define STATE_HIGH 1 #define STATE_LOW 0 diff --git a/examples/platform/telink/util/include/LEDWidget.h b/examples/platform/telink/util/include/LEDWidget.h index b83b6dd0d19c0e..e851c03ccc04e2 100644 --- a/examples/platform/telink/util/include/LEDWidget.h +++ b/examples/platform/telink/util/include/LEDWidget.h @@ -18,7 +18,7 @@ #pragma once #include -#include +#include class LEDWidget { diff --git a/examples/platform/telink/util/src/ButtonManager.cpp b/examples/platform/telink/util/src/ButtonManager.cpp index a730b4677a8a82..6a5d6055f53702 100644 --- a/examples/platform/telink/util/src/ButtonManager.cpp +++ b/examples/platform/telink/util/src/ButtonManager.cpp @@ -17,11 +17,11 @@ */ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include LOG_MODULE_REGISTER(ButtonManager); diff --git a/examples/platform/telink/util/src/LEDWidget.cpp b/examples/platform/telink/util/src/LEDWidget.cpp index abd45d415c4931..3b97fe64375058 100644 --- a/examples/platform/telink/util/src/LEDWidget.cpp +++ b/examples/platform/telink/util/src/LEDWidget.cpp @@ -18,7 +18,7 @@ #include "LEDWidget.h" -#include +#include const struct device * LEDWidget::mPort = NULL; diff --git a/examples/platform/telink/util/src/ThreadUtil.cpp b/examples/platform/telink/util/src/ThreadUtil.cpp index 12bfb00f82507c..dad09fe3e945eb 100644 --- a/examples/platform/telink/util/src/ThreadUtil.cpp +++ b/examples/platform/telink/util/src/ThreadUtil.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include diff --git a/examples/shell/nxp/k32w/k32w0/BUILD.gn b/examples/shell/nxp/k32w/k32w0/BUILD.gn index f6c4039783a5dd..19e52dcd502c7b 100644 --- a/examples/shell/nxp/k32w/k32w0/BUILD.gn +++ b/examples/shell/nxp/k32w/k32w0/BUILD.gn @@ -15,6 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/k32w0_sdk.gni") import("//build_overrides/openthread.gni") +import("${chip_root}/src/platform/device.gni") import("${chip_root}/third_party/simw-top-mini/simw_config.gni") import("${k32w0_sdk_build_root}/k32w0_executable.gni") @@ -39,16 +40,11 @@ k32w0_sdk("sdk") { "main/include", "main", "include", - "${k32w0_platform_dir}/app/project_include", "${k32w0_platform_dir}/app/support", "${k32w0_platform_dir}/util/include", ] - defines = [ - # shell app uses openthread but does not have the NETWORK_COMMISSIONING cluster or zap config. - "_NO_NETWORK_COMMISSIONING_DRIVER_", - ] - + defines = [] if (is_debug) { defines += [ "BUILD_RELEASE=0" ] } else { @@ -68,6 +64,7 @@ k32w0_executable("shell_app") { deps = [ ":sdk", + "${chip_root}/examples/common/QRCode", "${chip_root}/examples/lock-app/lock-common", "${chip_root}/examples/shell/shell_common:shell_common", "${chip_root}/third_party/mbedtls:mbedtls", diff --git a/examples/shell/nxp/k32w/k32w0/include/AppTask.h b/examples/shell/nxp/k32w/k32w0/include/AppTask.h index cdfbf664746404..28480735fef81d 100644 --- a/examples/shell/nxp/k32w/k32w0/include/AppTask.h +++ b/examples/shell/nxp/k32w/k32w0/include/AppTask.h @@ -66,6 +66,7 @@ class AppTask static void ThreadStart(); void StartTimer(uint32_t aTimeoutInMs); + static void InitServer(intptr_t arg); enum Function_t { diff --git a/examples/shell/nxp/k32w/k32w0/include/FreeRTOSConfig.h b/examples/shell/nxp/k32w/k32w0/include/FreeRTOSConfig.h index 9419372bbed91a..f25e96df522d13 100644 --- a/examples/shell/nxp/k32w/k32w0/include/FreeRTOSConfig.h +++ b/examples/shell/nxp/k32w/k32w0/include/FreeRTOSConfig.h @@ -55,7 +55,10 @@ #define configUSE_ALTERNATIVE_API 0 /* Deprecated! */ #define configQUEUE_REGISTRY_SIZE 8 #define configUSE_QUEUE_SETS 0 -#define configUSE_TIME_SLICING 0 +/* make sure that Thread task can interrupt lengthy Matter + * processing in case priority inversion occurs + */ +#define configUSE_TIME_SLICING 1 #define configUSE_NEWLIB_REENTRANT 0 #define configENABLE_BACKWARD_COMPATIBILITY 1 #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 diff --git a/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp b/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp index efb0ccdadeaaf5..0ceec53420993b 100644 --- a/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp @@ -30,14 +30,18 @@ #include +#include +#include +#include +#include + #include "Keyboard.h" #include "LED.h" #include "LEDWidget.h" #include "app_config.h" -#define FACTORY_RESET_TRIGGER_TIMEOUT 6000 -#define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 -#define APP_EVENT_QUEUE_SIZE 10 +constexpr uint32_t kFactoryResetTriggerTimeout = 6000; +constexpr uint8_t kAppEventQueueSize = 10; TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer. @@ -46,7 +50,6 @@ static QueueHandle_t sAppEventQueue; static LEDWidget sStatusLED; static bool sIsThreadProvisioned = false; -static bool sIsThreadEnabled = false; static bool sHaveBLEConnections = false; static uint32_t eventMask = 0; @@ -60,40 +63,23 @@ CHIP_ERROR AppTask::StartAppTask() { CHIP_ERROR err = CHIP_NO_ERROR; - sAppEventQueue = xQueueCreate(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent)); + sAppEventQueue = xQueueCreate(kAppEventQueueSize, sizeof(AppEvent)); if (sAppEventQueue == NULL) { err = APP_ERROR_EVENT_QUEUE_FAILED; K32W_LOG("Failed to allocate app event queue"); - assert(err == CHIP_NO_ERROR); + assert(false); } return err; } -void LockOpenThreadTask(void) -{ - chip::DeviceLayer::ThreadStackMgr().LockThreadStack(); -} - -void UnlockOpenThreadTask(void) -{ - chip::DeviceLayer::ThreadStackMgr().UnlockThreadStack(); -} - CHIP_ERROR AppTask::Init() { CHIP_ERROR err = CHIP_NO_ERROR; // Init ZCL Data Model and start server - static chip::CommonCaseDeviceServerInitParams initParams; - (void) initParams.InitializeStaticResourcesBeforeServerInit(); - chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; - nativeParams.lockCb = LockOpenThreadTask; - nativeParams.unlockCb = UnlockOpenThreadTask; - nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); - initParams.endpointNativeParams = static_cast(&nativeParams); - chip::Server::GetInstance().Init(initParams); + PlatformMgr().ScheduleWork(InitServer, 0); // Initialize device attestation config SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); @@ -126,15 +112,15 @@ CHIP_ERROR AppTask::Init() } // Print the current software version - char softwareVersionString[ConfigurationManager::kMaxSoftwareVersionStringLength + 1] = { 0 }; - err = ConfigurationMgr().GetSoftwareVersionString(softwareVersionString, sizeof(softwareVersionString)); + char currentSoftwareVer[ConfigurationManager::kMaxSoftwareVersionStringLength + 1] = { 0 }; + err = ConfigurationMgr().GetSoftwareVersionString(currentSoftwareVer, sizeof(currentSoftwareVer)); if (err != CHIP_NO_ERROR) { K32W_LOG("Get version error"); assert(err == CHIP_NO_ERROR); } - K32W_LOG("Current Software Version: %s", softwareVersionString); + K32W_LOG("Current Software Version: %s", currentSoftwareVer); #if CONFIG_CHIP_NFC_COMMISSIONING PlatformMgr().AddEventHandler(ThreadProvisioningHandler, 0); @@ -143,6 +129,30 @@ CHIP_ERROR AppTask::Init() return err; } +void LockOpenThreadTask(void) +{ + chip::DeviceLayer::ThreadStackMgr().LockThreadStack(); +} + +void UnlockOpenThreadTask(void) +{ + chip::DeviceLayer::ThreadStackMgr().UnlockThreadStack(); +} + +void AppTask::InitServer(intptr_t arg) +{ + static chip::CommonCaseDeviceServerInitParams initParams; + (void) initParams.InitializeStaticResourcesBeforeServerInit(); + + // Init ZCL Data Model and start server + chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; + nativeParams.lockCb = LockOpenThreadTask; + nativeParams.unlockCb = UnlockOpenThreadTask; + nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); + initParams.endpointNativeParams = static_cast(&nativeParams); + VerifyOrDie((chip::Server::GetInstance().Init(initParams)) == CHIP_NO_ERROR); +} + void AppTask::AppTaskMain(void * pvParameter) { AppEvent event; @@ -156,7 +166,8 @@ void AppTask::AppTaskMain(void * pvParameter) while (true) { - BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, pdMS_TO_TICKS(10)); + TickType_t xTicksToWait = pdMS_TO_TICKS(10); + BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, xTicksToWait); while (eventReceived == pdTRUE) { sAppTask.DispatchEvent(&event); @@ -170,9 +181,7 @@ void AppTask::AppTaskMain(void * pvParameter) // task is busy (e.g. with a long crypto operation). if (PlatformMgr().TryLockChipStack()) { - sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned(); - sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); - sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0); + sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0); PlatformMgr().UnlockChipStack(); } @@ -190,7 +199,7 @@ void AppTask::AppTaskMain(void * pvParameter) // Otherwise, blink the LED ON for a very short time. if (sAppTask.mFunction != kFunction_FactoryReset) { - if (sIsThreadProvisioned && sIsThreadEnabled) + if (sIsThreadProvisioned) { sStatusLED.Blink(950, 50); } @@ -205,7 +214,6 @@ void AppTask::AppTaskMain(void * pvParameter) } sStatusLED.Animate(); - HandleKeyboard(); } } @@ -242,6 +250,8 @@ void AppTask::ButtonEventHandler(uint8_t pin_no, uint8_t button_action) void AppTask::KBD_Callback(uint8_t events) { eventMask = eventMask | (uint32_t)(1 << events); + + HandleKeyboard(); } void AppTask::HandleKeyboard(void) @@ -319,7 +329,7 @@ void AppTask::ResetActionEventHandler(AppEvent * aEvent) } else { - uint32_t resetTimeout = FACTORY_RESET_TRIGGER_TIMEOUT; + uint32_t resetTimeout = kFactoryResetTriggerTimeout; if (sAppTask.mFunction != kFunction_NoneSelected) { @@ -334,7 +344,7 @@ void AppTask::ResetActionEventHandler(AppEvent * aEvent) sStatusLED.Set(false); sStatusLED.Blink(500); - sAppTask.StartTimer(FACTORY_RESET_TRIGGER_TIMEOUT); + sAppTask.StartTimer(kFactoryResetTriggerTimeout); } } @@ -369,9 +379,21 @@ void AppTask::BleHandler(AppEvent * aEvent) } } -#if CONFIG_CHIP_NFC_COMMISSIONING void AppTask::ThreadProvisioningHandler(const ChipDeviceEvent * event, intptr_t) { + if (event->Type == DeviceEventType::kServiceProvisioningChange && event->ServiceProvisioningChange.IsServiceProvisioned) + { + if (event->ServiceProvisioningChange.IsServiceProvisioned) + { + sIsThreadProvisioned = TRUE; + } + else + { + sIsThreadProvisioned = FALSE; + } + } + +#if CONFIG_CHIP_NFC_COMMISSIONING if (event->Type == DeviceEventType::kCHIPoBLEAdvertisingChange && event->CHIPoBLEAdvertisingChange.Result == kActivity_Stopped) { if (!NFCMgr().IsTagEmulationStarted()) @@ -397,8 +419,8 @@ void AppTask::ThreadProvisioningHandler(const ChipDeviceEvent * event, intptr_t) K32W_LOG("Started NFC Tag Emulation!"); } } -} #endif +} void AppTask::CancelTimer() { @@ -431,9 +453,21 @@ void AppTask::StartTimer(uint32_t aTimeoutInMs) void AppTask::PostEvent(const AppEvent * aEvent) { + portBASE_TYPE taskToWake = pdFALSE; if (sAppEventQueue != NULL) { - if (!xQueueSend(sAppEventQueue, aEvent, 1)) + if (__get_IPSR()) + { + if (!xQueueSendToFrontFromISR(sAppEventQueue, aEvent, &taskToWake)) + { + K32W_LOG("Failed to post event to app task event queue"); + } + if (taskToWake) + { + portYIELD_FROM_ISR(taskToWake); + } + } + else if (!xQueueSend(sAppEventQueue, aEvent, 0)) { K32W_LOG("Failed to post event to app task event queue"); } diff --git a/examples/shell/nxp/k32w/k32w0/main/main.cpp b/examples/shell/nxp/k32w/k32w0/main/main.cpp index 0693ba7213316d..152900341c4067 100644 --- a/examples/shell/nxp/k32w/k32w0/main/main.cpp +++ b/examples/shell/nxp/k32w/k32w0/main/main.cpp @@ -44,6 +44,7 @@ using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; using namespace ::chip::Logging; using chip::Shell::Engine; +#include "MacSched.h" typedef void (*InitFunc)(void); extern InitFunc __init_array_start; @@ -61,6 +62,7 @@ extern "C" unsigned int sleep(unsigned int seconds) static void shell_task(void * args) { + Engine::Root().Init(); Engine::Root().RunMainLoop(); } @@ -109,6 +111,11 @@ extern "C" void main_task(void const * argument) goto exit; } + /* Enable the MAC scheduler after BLEManagerImpl::_Init() and V2MMAC_Enable(). + * This is needed to register properly the active protocols. + */ + sched_enable(); + ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); if (ret != CHIP_NO_ERROR) { @@ -130,8 +137,6 @@ extern "C" void main_task(void const * argument) goto exit; } - // cmd_otcli_init(); - shellTaskHandle = xTaskCreate(shell_task, "shell_task", shell_task_size / sizeof(StackType_t), NULL, shell_task_priority, NULL); if (!shellTaskHandle) { diff --git a/examples/thermostat/efr32/src/AppTask.cpp b/examples/thermostat/efr32/src/AppTask.cpp index 2b518669162649..37ab028045fe35 100644 --- a/examples/thermostat/efr32/src/AppTask.cpp +++ b/examples/thermostat/efr32/src/AppTask.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include diff --git a/integrations/cloudbuild/build-all.yaml b/integrations/cloudbuild/build-all.yaml index 4cf106b326b5ad..bae33cbf0e1a9b 100644 --- a/integrations/cloudbuild/build-all.yaml +++ b/integrations/cloudbuild/build-all.yaml @@ -6,7 +6,7 @@ steps: - "--init" - "--recursive" id: Submodules - - name: "connectedhomeip/chip-build-vscode:0.5.99" + - name: "connectedhomeip/chip-build-vscode:0.6.02" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -21,7 +21,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.5.99" + - name: "connectedhomeip/chip-build-vscode:0.6.02" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/chef.yaml b/integrations/cloudbuild/chef.yaml index b46ab6a2917f8a..ecbb7842aec8fe 100644 --- a/integrations/cloudbuild/chef.yaml +++ b/integrations/cloudbuild/chef.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.5.99" + - name: "connectedhomeip/chip-build-vscode:0.6.02" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -12,7 +12,7 @@ steps: path: /pwenv timeout: 2700s - - name: "connectedhomeip/chip-build-vscode:0.5.99" + - name: "connectedhomeip/chip-build-vscode:0.6.02" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -26,7 +26,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.5.99" + - name: "connectedhomeip/chip-build-vscode:0.6.02" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/smoke-test.yaml b/integrations/cloudbuild/smoke-test.yaml index 3707014c6ce849..1f855431754a1e 100644 --- a/integrations/cloudbuild/smoke-test.yaml +++ b/integrations/cloudbuild/smoke-test.yaml @@ -6,7 +6,7 @@ steps: - "--init" - "--recursive" id: Submodules - - name: "connectedhomeip/chip-build-vscode:0.5.99" + - name: "connectedhomeip/chip-build-vscode:0.6.02" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -21,7 +21,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.5.99" + - name: "connectedhomeip/chip-build-vscode:0.6.02" id: ESP32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -37,7 +37,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.5.99" + - name: "connectedhomeip/chip-build-vscode:0.6.02" id: NRFConnect env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -54,7 +54,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.5.99" + - name: "connectedhomeip/chip-build-vscode:0.6.02" id: EFR32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -71,7 +71,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.5.99" + - name: "connectedhomeip/chip-build-vscode:0.6.02" id: Linux env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -88,7 +88,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.5.99" + - name: "connectedhomeip/chip-build-vscode:0.6.02" id: Android env: - PW_ENVIRONMENT_ROOT=/pwenv diff --git a/integrations/docker/images/chip-build-k32w/Dockerfile b/integrations/docker/images/chip-build-k32w/Dockerfile index d07d868e59c19a..10d376127a1745 100644 --- a/integrations/docker/images/chip-build-k32w/Dockerfile +++ b/integrations/docker/images/chip-build-k32w/Dockerfile @@ -21,4 +21,4 @@ FROM connectedhomeip/chip-build:${VERSION} COPY --from=build /opt/sdk/ /opt/sdk/ -ENV NXP_K32W0_SDK_ROOT=/opt/sdk +ENV NXP_K32W0_SDK_ROOT=/opt/sdk/SDK_2_6_7_K32W061DK6 diff --git a/integrations/docker/images/chip-build-vscode/Dockerfile b/integrations/docker/images/chip-build-vscode/Dockerfile index bbb1521693903e..669d00f80138f1 100644 --- a/integrations/docker/images/chip-build-vscode/Dockerfile +++ b/integrations/docker/images/chip-build-vscode/Dockerfile @@ -80,7 +80,7 @@ ENV IDF_PATH=/opt/espressif/esp-idf/ ENV IDF_TOOLS_PATH=/opt/espressif/tools ENV IMX_SDK_ROOT=/opt/fsl-imx-xwayland/5.15-kirkstone/ ENV NRF5_TOOLS_ROOT=/opt/NordicSemiconductor/nRF5_tools -ENV NXP_K32W0_SDK_ROOT=/opt/k32w_sdk +ENV NXP_K32W0_SDK_ROOT=/opt/k32w_sdk/SDK_2_6_7_K32W061DK6 ENV OPENOCD_PATH=/opt/openocd/ ENV PW_ENVIRONMENT_ROOT=/home/vscode/pigweed/env ENV QEMU_ESP32=/opt/espressif/qemu/xtensa-softmmu/qemu-system-xtensa diff --git a/integrations/docker/images/chip-build/version b/integrations/docker/images/chip-build/version index 9545a592275e7d..1683f3fe2579b9 100644 --- a/integrations/docker/images/chip-build/version +++ b/integrations/docker/images/chip-build/version @@ -1 +1 @@ -0.6.01 Version bump reason: Update Telink Docker +0.6.02 Version bump reason: Update NXP SDK PATH diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 648b053c6bff54..6c4fcc8649cf8a 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -553,10 +553,10 @@ def K32WTargets(): yield target.Extend('light-ota-se', app=K32WApp.LIGHT, release=True, disable_ble=True, se05x=True).GlobBlacklist("Only on demand build") yield target.Extend('light-release-no-ota', app=K32WApp.LIGHT, tokenizer=True, disable_ota=True, release=True, tinycrypt=True) - yield target.Extend('shell-release', app=K32WApp.SHELL, release=True) + yield target.Extend('shell-release', app=K32WApp.SHELL, disable_logs=True, release=True) yield target.Extend('lock-release', app=K32WApp.LOCK, release=True) yield target.Extend('lock-low-power-release', app=K32WApp.LOCK, - low_power=True, release=True).GlobBlacklist("Only on demand build") + low_power=True, disable_logs=True, release=True).GlobBlacklist("Only on demand build") def cc13x2x7_26x2x7Targets(): diff --git a/scripts/build/builders/k32w.py b/scripts/build/builders/k32w.py index 39828157e934eb..f00c21a5ac3344 100644 --- a/scripts/build/builders/k32w.py +++ b/scripts/build/builders/k32w.py @@ -60,6 +60,7 @@ def __init__(self, tokenizer: bool = False, disable_ble: bool = False, disable_ota: bool = False, + disable_logs: bool = False, se05x: bool = False, tinycrypt: bool = False): super(K32WBuilder, self).__init__( @@ -72,6 +73,7 @@ def __init__(self, self.release = release self.disable_ble = disable_ble self.disable_ota = disable_ota + self.disable_logs = disable_logs self.se05x = se05x self.tinycrypt = tinycrypt @@ -97,6 +99,9 @@ def GnBuildArgs(self): if self.disable_ota: args.append('chip_enable_ota_requestor=false') + if self.disable_logs: + args.append('chip_logging=false') + if self.se05x: args.append('chip_with_se05x=true') diff --git a/scripts/build/testdata/build_all_except_host.txt b/scripts/build/testdata/build_all_except_host.txt index 127b9a9f329724..48b2f68c78ba30 100644 --- a/scripts/build/testdata/build_all_except_host.txt +++ b/scripts/build/testdata/build_all_except_host.txt @@ -927,7 +927,7 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa {root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh # Generating k32w-lock-low-power-release -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/nxp/k32w/k32w0 '--args=k32w0_sdk_root="TEST_NXP_K32W0_SDK_ROOT" chip_with_low_power=1 is_debug=false' {out}/k32w-lock-low-power-release +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/nxp/k32w/k32w0 '--args=k32w0_sdk_root="TEST_NXP_K32W0_SDK_ROOT" chip_with_low_power=1 is_debug=false chip_logging=false' {out}/k32w-lock-low-power-release {root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh @@ -937,7 +937,7 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa {root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh # Generating k32w-shell-release -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/shell/nxp/k32w/k32w0 '--args=k32w0_sdk_root="TEST_NXP_K32W0_SDK_ROOT" chip_with_low_power=0 is_debug=false' {out}/k32w-shell-release +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/shell/nxp/k32w/k32w0 '--args=k32w0_sdk_root="TEST_NXP_K32W0_SDK_ROOT" chip_with_low_power=0 is_debug=false chip_logging=false' {out}/k32w-shell-release # Generating config mbed-CY8CPROTO_062_4343W-all-clusters-debug mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/all-clusters-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-all-clusters-debug --mbed-os-path {root}/third_party/mbed-os/repo diff --git a/scripts/idl/BUILD.gn b/scripts/idl/BUILD.gn index d17697ffb40f1b..9e85b73a2db0b2 100644 --- a/scripts/idl/BUILD.gn +++ b/scripts/idl/BUILD.gn @@ -59,10 +59,18 @@ pw_python_package("idl") { "generators/types.py", "matter_idl_parser.py", "matter_idl_types.py", + "xml_parser.py", + "zapxml/__init__.py", + "zapxml/handlers/__init__.py", + "zapxml/handlers/base.py", + "zapxml/handlers/context.py", + "zapxml/handlers/handlers.py", + "zapxml/handlers/parsing.py", ] tests = [ "test_matter_idl_parser.py", "test_generators.py", + "test_xml_parser.py", ] } diff --git a/scripts/idl/test_xml_parser.py b/scripts/idl/test_xml_parser.py new file mode 100755 index 00000000000000..31c49c731d6ea5 --- /dev/null +++ b/scripts/idl/test_xml_parser.py @@ -0,0 +1,245 @@ +#!/usr/bin/env python3 +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# 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. + +import unittest +import io + +from typing import Optional, Union, List + +try: + from idl.matter_idl_types import * + from idl.zapxml import ParseSource, ParseXmls +except: + import os + import sys + + sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) + + from idl.matter_idl_types import * + from idl.zapxml import ParseSource, ParseXmls + + +def XmlToIdl(what: Union[str, List[str]]) -> Idl: + if not isinstance(what, list): + what = [what] + + sources = [] + for idx, txt in enumerate(what): + sources.append(ParseSource(source=io.StringIO(txt), name=("Input %d" % (idx + 1)))) + + return ParseXmls(sources, include_meta_data=False) + + +class TestXmlParser(unittest.TestCase): + + def testEmptyInput(self): + idl = XmlToIdl('') + self.assertEqual(idl, Idl()) + + def testCluster(self): + idl = XmlToIdl(''' + + + + Test Cluster + 0x1234 + + SomeIntAttribute + + + AttributeWithAccess + + + + + + This is just a test: client to server + + + + + + + Reply from server + + + + + + ''') + self.assertEqual(idl, + Idl(clusters=[ + Cluster( + side=ClusterSide.CLIENT, + name='TestCluster', + code=0x1234, + attributes=[ + Attribute(definition=Field(data_type=DataType(name='INT32U'), code=11, name='SomeIntAttribute', + attributes={FieldAttribute.NULLABLE}), tags={AttributeTag.READABLE}, + readacl=AccessPrivilege.VIEW, writeacl=AccessPrivilege.OPERATE), + Attribute(definition=Field(data_type=DataType(name='INT8U'), code=22, name='AttributeWithAccess', + attributes={FieldAttribute.OPTIONAL}), + tags={AttributeTag.READABLE, AttributeTag.WRITABLE}, readacl=AccessPrivilege.OPERATE, + writeacl=AccessPrivilege.MANAGE) + ], + structs=[ + Struct(name='GetSomeDataRequest', + fields=[ + Field(data_type=DataType(name='INT8U'), code=1, name='firstInput'), + Field(data_type=DataType(name='INT16U'), code=2, name='secondInput') + ], + tag=StructTag.REQUEST), + Struct(name='GetSomeDataResponse', + fields=[ + Field(data_type=DataType(name='INT8U'), code=1, + name='dataPoint1'), + Field(data_type=DataType(name='INT8U'), code=2, name='dataPoint2', + attributes={FieldAttribute.OPTIONAL}) + ], + tag=StructTag.RESPONSE, code=0x44) + ], + commands=[ + Command(name='GetSomeData', code=33, input_param='GetSomeDataRequest', output_param='GetSomeDataResponse', + invokeacl=AccessPrivilege.ADMINISTER) + ]) + ])) + + def testBitmap(self): + idl = XmlToIdl(''' + + Test10x0001 + Test20x0002 + + + + + + + + + + ''') + bitmap = Bitmap( + name='MyBitmap', + base_type='BITMAP32', + entries=[ + ConstantEntry(name='BitmapMask1', code=1), + ConstantEntry(name='BitmapMask2', code=2), + ConstantEntry(name='BitmapMask3', code=4) + ]) + + self.assertEqual(idl, + Idl(clusters=[ + Cluster(side=ClusterSide.CLIENT, name='Test1', code=1, bitmaps=[bitmap]), + Cluster(side=ClusterSide.CLIENT, name='Test2', code=2, bitmaps=[bitmap]), + ])) + + def testStruct(self): + idl = XmlToIdl(''' + + Test10x000A + + Test2 + 20 + + + FabricAttribute + + + + + + + + + + + + ''') + struct = Struct( + name='SomeStruct', + fields=[ + Field(data_type=DataType(name='int16u'), code=1, name='FirstMember'), + Field(data_type=DataType(name='int32u'), code=2, name='SecondMember') + ] + ) + self.assertEqual(idl, + Idl(clusters=[ + Cluster(side=ClusterSide.CLIENT, name='Test1', code=10, structs=[struct]), + Cluster(side=ClusterSide.CLIENT, name='Test2', code=20, + structs=[struct], + attributes=[ + Attribute( + definition=Field( + data_type=DataType(name='SomeStruct'), + code=123, + name='FabricAttribute', + attributes={FieldAttribute.NULLABLE} + ), + tags={AttributeTag.READABLE, AttributeTag.FABRIC_SCOPED}, + readacl=AccessPrivilege.VIEW, + writeacl=AccessPrivilege.OPERATE)]), ])) + + def testSkipsNotProcessedFields(self): + # Zap has extra fields that are generally not processed + # This includes such fields and ansures we do not consider them + idl = XmlToIdl(''' + + + + + Window Covering + Closures + 0x0102 + WINDOW_COVERING_CLUSTER + Provides an interface for controlling and adjusting automatic window coverings. + + + + + + + + + true + true + + + + Type + + + ''') + self.assertEqual(idl, + Idl(clusters=[ + Cluster(side=ClusterSide.CLIENT, name='WindowCovering', code=0x102, + structs=[], + attributes=[ + Attribute( + definition=Field( + data_type=DataType(name='Type'), + code=0, + name='Type', + ), + tags={AttributeTag.READABLE}, + readacl=AccessPrivilege.VIEW, + writeacl=AccessPrivilege.OPERATE)]), ])) + + +if __name__ == '__main__': + unittest.main() diff --git a/scripts/idl/xml_parser.py b/scripts/idl/xml_parser.py new file mode 100755 index 00000000000000..979167ca11b156 --- /dev/null +++ b/scripts/idl/xml_parser.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# 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. + +import enum +import logging +import os +import xml.sax +import xml.sax.handler + +try: + from idl.matter_idl_types import Idl +except: + import sys + + sys.path.append(os.path.abspath( + os.path.join(os.path.dirname(__file__), '..'))) + from idl.matter_idl_types import Idl + +from idl.zapxml import ParseSource, ParseXmls + + +if __name__ == '__main__': + # This Parser is generally not intended to be run as a stand-alone binary. + # The ability to run is for debug and to print out the parsed AST. + import click + import coloredlogs + import pprint + + # Supported log levels, mapping string values required for argument + # parsing into logging constants + __LOG_LEVELS__ = { + 'debug': logging.DEBUG, + 'info': logging.INFO, + 'warn': logging.WARN, + 'fatal': logging.FATAL, + } + + @ click.command() + @ click.option( + '--log-level', + default='INFO', + show_default=True, + type=click.Choice(__LOG_LEVELS__.keys(), case_sensitive=False), + help='Determines the verbosity of script output.') + @ click.option( + '--no-print', + show_default=True, + default=False, + is_flag=True, + help='Do not pring output data (parsed data)') + @ click.argument('filenames', nargs=-1) + def main(log_level, no_print, filenames): + coloredlogs.install(level=__LOG_LEVELS__[ + log_level], fmt='%(asctime)s %(levelname)-7s %(message)s') + + logging.info("Starting to parse ...") + + sources = [ParseSource(source=name) for name in filenames] + data = ParseXmls(sources) + logging.info("Parse completed") + + if not no_print: + print("Data:") + pprint.pp(data) + + main() diff --git a/scripts/idl/zapxml/__init__.py b/scripts/idl/zapxml/__init__.py new file mode 100644 index 00000000000000..332d1c244bea3b --- /dev/null +++ b/scripts/idl/zapxml/__init__.py @@ -0,0 +1,118 @@ +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# 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. + +import logging +import typing +import xml.sax.handler + +from dataclasses import dataclass +from typing import Optional, Union, List + +from idl.zapxml.handlers import Context, ZapXmlHandler +from idl.matter_idl_types import Idl + + +class ParseHandler(xml.sax.handler.ContentHandler): + """A parser for ZAP-style XML data definitions. + + Defers its processing to ZapXmlHandler and keeps track of: + - an internal context for all handlers + - the parsed Idl structure that is incrementally built + - sets up parsing location within the context + - keeps track of ParsePath + + Overall converts a python SAX handler into idl.zapxml.handlers + """ + + def __init__(self, include_meta_data=True): + super().__init__() + self._idl = Idl() + self._processing_stack = [] + # Context persists across all + self._context = Context() + self._include_meta_data = include_meta_data + + def PrepareParsing(self, filename): + # This is a bit ugly: filename keeps changing during parse + # IDL meta is not prepared for this (as source is XML and .matter is + # single file) + if self._include_meta_data: + self._idl.parse_file_name = filename + + def Finish(self) -> Idl: + self._context.PostProcess(self._idl) + return self._idl + + def startDocument(self): + if self._include_meta_data: + self._context.locator = self._locator + self._processing_stack = [ZapXmlHandler(self._context, self._idl)] + + def endDocument(self): + if len(self._processing_stack) != 1: + raise Exception("Unexpected nesting!") + + def startElement(self, name: str, attrs): + logging.debug("ELEMENT START: %r / %r" % (name, attrs)) + self._context.path.push(name) + self._processing_stack.append(self._processing_stack[-1].GetNextProcessor(name, attrs)) + + def endElement(self, name: str): + logging.debug("ELEMENT END: %r" % name) + + last = self._processing_stack.pop() + last.EndProcessing() + + # important to pop AFTER processing end to allow processing + # end to access the current context + self._context.path.pop() + + def characters(self, content): + self._processing_stack[-1].HandleContent(content) + + +@dataclass +class ParseSource: + """Represents an input sopurce for ParseXmls. + + Allows for named data sources to be parsed. + """ + source: Union[str, typing.IO] # filename or stream + name: Optional[str] = None # actual filename to use, None if the source is a filename already + + @ property + def source_file_name(self): + if self.name: + return self.name + return self.source # assume string + + +def ParseXmls(sources: List[ParseSource], include_meta_data=True) -> Idl: + """Parse one or more XML inputs and return the resulting Idl data. + + Params: + sources - what to parse + include_meta_data - if parsing location data should be included in the Idl + """ + handler = ParseHandler(include_meta_data=include_meta_data) + + for source in sources: + logging.info('Parsing %s...' % source.source_file_name) + handler.PrepareParsing(source.source_file_name) + + parser = xml.sax.make_parser() + parser.setContentHandler(handler) + parser.parse(source.source) + + return handler.Finish() diff --git a/scripts/idl/zapxml/handlers/__init__.py b/scripts/idl/zapxml/handlers/__init__.py new file mode 100644 index 00000000000000..7a6bfa04682921 --- /dev/null +++ b/scripts/idl/zapxml/handlers/__init__.py @@ -0,0 +1,36 @@ +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# 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. + +from .base import BaseHandler +from .context import Context +from .handlers import ConfiguratorHandler + +from idl.matter_idl_types import Idl + + +class ZapXmlHandler(BaseHandler): + """Handles the top level (/) of a zap xml file. + + Generally these files only contain a 'configurator' element in them + """ + + def __init__(self, context: Context, idl: Idl): + super().__init__(context) + self._idl = idl + + def GetNextProcessor(self, name, attrs): + if name.lower() == 'configurator': + return ConfiguratorHandler(self.context, self._idl) + else: + return BaseHandler(self.context) diff --git a/scripts/idl/zapxml/handlers/base.py b/scripts/idl/zapxml/handlers/base.py new file mode 100644 index 00000000000000..bb2ca95566a4ae --- /dev/null +++ b/scripts/idl/zapxml/handlers/base.py @@ -0,0 +1,62 @@ +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# 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. + +import enum +from .context import Context + + +class HandledDepth: + """Defines how deep a XML element has been handled.""" + NOT_HANDLED = enum.auto() # Unknown/parsed element + ENTIRE_TREE = enum.auto() # Entire tree can be ignored + SINGLE_TAG = enum.auto() # Single tag processed, but not sub-items + + +class BaseHandler: + """A generic element handler. + + XML processing is done in the form of depth-first processing: + - Tree is descended into using `GetNextProcessor` + - Processors are expected to extend `BaseHandler` and allow for: + - GetNextProcessor to recurse + - HandleContent in case the text content is relevant + - EndProcessing once the entire tree has been walked (when xml element ends) + + BaseHandler keeps track if it has been handled or ot by its `_handled` setting and + init parameter. Non-handled elements will be tagged within the context, resulting + in logs. This is to detect if unknown/new tags appear in XML files. + """ + + def __init__(self, context: Context, handled=HandledDepth.NOT_HANDLED): + self.context = context + self._handled = handled + + def GetNextProcessor(self, name, attrs): + """Get the next processor to use for the given name""" + + if self._handled == HandledDepth.SINGLE_TAG: + handled = HandledDepth.NOT_HANDLED + else: + handled = self._handled + + return BaseHandler(context=self.context, handled=handled) + + def HandleContent(self, content): + """Processes some content""" + pass + + def EndProcessing(self): + """Finalizes the processing of the current element""" + if self._handled == HandledDepth.NOT_HANDLED: + self.context.MarkTagNotHandled() diff --git a/scripts/idl/zapxml/handlers/context.py b/scripts/idl/zapxml/handlers/context.py new file mode 100644 index 00000000000000..2d82153d76d959 --- /dev/null +++ b/scripts/idl/zapxml/handlers/context.py @@ -0,0 +1,124 @@ +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# 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. + +import logging +import xml.sax.xmlreader + +from idl.matter_idl_types import Idl, ParseMetaData, Attribute +from typing import Optional, List + + +class IdlPostProcessor: + """Defines a callback that will apply after an entire parsing + is complete. + """ + + def FinalizeProcessing(self, idl: Idl): + """Update idl with any post-processing directives.""" + pass + + +class ProcessingPath: + """Maintains the current path of tags within xml processing. + + As processing descents into an xml like `....` + paths will have contents like ['configurator', 'cluster', ...]. + + The main purpose for this is to log and keep track of what was visited + and in general to report things like 'this path found but was not handled'. + """ + + def __init__(self, paths: List[str] = None): + if paths is None: + paths = [] + self.paths = paths + + def push(self, name: str): + self.paths.append(name) + + def pop(self): + self.paths.pop() + + def __str__(self): + return '::'.join(self.paths) + + def __repr__(self): + return 'ProcessingPath(%r)' % self.paths + + +class Context: + """ + Contains a processing state during XML reading. + + The purpose of this is to allow elements to interact with each other, share + data and defer processing. + + Usage: + - globally shared data: + > locator: parsing location, for error reporting + > path: current ProcessingPath for any logging of where we are located + - shared data: + > global attributes are parsed by one handler, but used by others + - post-processing support: + > can register AddIdlPostProcessor to perform some processing once + a full parsing pass has been done + + More data may be added in time if it involves separate XML parse handlers + needing to interact with each other. + """ + + def __init__(self, locator: Optional[xml.sax.xmlreader.Locator] = None): + self.path = ProcessingPath() + self.locator = locator + self._not_handled = set() + self._idl_post_processors = [] + + # Map of code -> attribute + self._global_attributes = {} + + def GetCurrentLocationMeta(self) -> ParseMetaData: + if not self.locator: + return None + + return ParseMetaData(line=self.locator.getLineNumber(), column=self.locator.getColumnNumber()) + + def GetGlobalAttribute(self, code): + if code in self._global_attributes: + return self._global_attributes[code] + + raise Exception( + 'Global attribute 0x%X (%d) not found. You probably need to load global-attributes.xml' % (code, code)) + + def AddGlobalAttribute(self, attribute: Attribute): + # NOTE: this may get added several times as both 'client' and 'server' + # however matter should not differentiate between the two + code = attribute.definition.code + logging.info('Adding global attribute 0x%X (%d): %s' % (code, code, attribute.definition.name)) + + self._global_attributes[code] = attribute + + def MarkTagNotHandled(self): + path = str(self.path) + if path not in self._not_handled: + logging.warning("TAG %s was not handled/recognized" % path) + self._not_handled.add(path) + + def AddIdlPostProcessor(self, processor: IdlPostProcessor): + self._idl_post_processors.append(processor) + + def PostProcess(self, idl: Idl): + for p in self._idl_post_processors: + p.FinalizeProcessing(idl) + + self._idl_post_processors = [] diff --git a/scripts/idl/zapxml/handlers/handlers.py b/scripts/idl/zapxml/handlers/handlers.py new file mode 100644 index 00000000000000..a27f48970342f8 --- /dev/null +++ b/scripts/idl/zapxml/handlers/handlers.py @@ -0,0 +1,616 @@ +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# 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. + +import logging + +from idl.matter_idl_types import * +from typing import Optional, Union, List + +from .context import Context, IdlPostProcessor +from .parsing import ParseInt, AttrsToAccessPrivilege, AttrsToAttribute +from .base import HandledDepth, BaseHandler + + +class ClusterNameHandler(BaseHandler): + """Handles /configurator/cluster/name elements.""" + + def __init__(self, context: Context, cluster: Cluster): + super().__init__(context, handled=HandledDepth.SINGLE_TAG) + self._cluster = cluster + + def HandleContent(self, content): + self._cluster.name = content.replace(' ', '') + + +class AttributeDescriptionHandler(BaseHandler): + """Handles /configurator/cluster/attribute/description elements.""" + + def __init__(self, context: Context, attribute: Attribute): + super().__init__(context, handled=HandledDepth.SINGLE_TAG) + self._attribute = attribute + + def HandleContent(self, content: str): + self._attribute.definition.name = content.replace(' ', '') + + +class ClusterCodeHandler(BaseHandler): + """Handles /configurator/cluster/code elements.""" + + def __init__(self, context: Context, cluster: Cluster): + super().__init__(context, handled=HandledDepth.SINGLE_TAG) + self._cluster = cluster + + def HandleContent(self, content: str): + self._cluster.code = ParseInt(content) + + +class EventHandler(BaseHandler): + """Handles /configurator/cluster/event elements.""" + + def __init__(self, context: Context, cluster: Cluster, attrs): + super().__init__(context) + self._cluster = cluster + + if attrs['priority'] == 'debug': + priority = EventPriority.DEBUG + elif attrs['priority'] == 'info': + priority = EventPriority.INFO + elif attrs['priority'] == 'critical': + priority = EventPriority.CRITICAL + else: + raise Exception("Unknown event priority: %s" % attrs['priority']) + + self._event = Event( + priority=priority, + code=ParseInt(attrs['code']), + name=attrs['name'], + fields=[], + ) + + def GetNextProcessor(self, name: str, attrs): + if name.lower() == 'field': + data_type = DataType(name=attrs['type']) + if 'length' in attrs: + data_type.max_length = ParseInt(attrs['length']) + + field = Field( + data_type=data_type, + code=ParseInt(attrs['id']), + name=attrs['name'], + is_list=(attrs.get('array', 'false').lower() == 'true'), + ) + + if attrs.get('optional', "false").lower() == 'true': + field.attributes.add(FieldAttribute.OPTIONAL) + + if attrs.get('isNullable', "false").lower() == 'true': + field.attributes.add(FieldAttribute.NULLABLE) + + self._event.fields.append(field) + return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) + elif name.lower() == 'access': + self._event.readacl = AttrsToAccessPrivilege(attrs) + return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) + elif name.lower() == 'description': + return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE) + else: + return BaseHandler(self.context) + + def EndProcessing(self): + self._cluster.events.append(self._event) + + +class AttributeHandler(BaseHandler): + """Handles /configurator/cluster/attribute elements.""" + + def __init__(self, context: Context, cluster: Cluster, attrs): + super().__init__(context) + self._cluster = cluster + self._attribute = AttrsToAttribute(attrs) + + def GetNextProcessor(self, name: str, attrs): + if name.lower() == 'access': + if 'modifier' in attrs: + if attrs['modifier'] != 'fabric-scoped': + raise Exception("UNKNOWN MODIFIER: %s" % attrs['modifier']) + self._attribute.tags.add(AttributeTag.FABRIC_SCOPED) + else: + role = AttrsToAccessPrivilege(attrs) + + if attrs['op'] == 'read': + self._attribute.readacl = role + elif attrs['op'] == 'write': + self._attribute.writeacl = role + else: + logging.error("Unknown access: %r" % attrs['op']) + return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) + elif name.lower() == 'description': + return AttributeDescriptionHandler(self.context, self._attribute) + else: + return BaseHandler(self.context) + + def HandleContent(self, content: str): + # Content generally is the name EXCEPT if access controls + # exist, in which case `description` contains the name + content = content.strip() + if content and not self._attribute.definition.name: + self._attribute.definition.name = content + + def EndProcessing(self): + if self._attribute.definition.name is None: + raise Exception("Name for attribute was not parsed.") + + self._cluster.attributes.append(self._attribute) + + +class StructHandler(BaseHandler, IdlPostProcessor): + """ Handling /configurator/struct elements.""" + + def __init__(self, context: Context, attrs): + super().__init__(context) + + # if set, struct belongs to a specific cluster + self._cluster_codes = set() + self._struct = Struct(name=attrs['name'], fields=[]) + self._field_index = 0 + # The following are not set: + # - tag not set because not a request/response + # - code not set because not a response + + self._is_fabric_scoped = (attrs.get('isFabricScoped', "false").lower() == 'true') + + def GetNextProcessor(self, name: str, attrs): + if name.lower() == 'item': + data_type = DataType( + name=attrs['type'] + ) + + # TODO(#22938): IDL should keep track and use the + # isFabricSensitive attribute here + + if 'fieldId' in attrs: + self._field_index = ParseInt(attrs['fieldId']) + else: + # NOTE: code does NOT exist, so the number is incremental here + # this seems a defficiency in XML format. + self._field_index += 1 + + if 'length' in attrs: + data_type.max_length = ParseInt(attrs['length']) + + field = Field( + data_type=data_type, + code=self._field_index, + name=attrs['name'], + is_list=(attrs.get('array', 'false').lower() == 'true'), + ) + + if attrs.get('optional', "false").lower() == 'true': + field.attributes.add(FieldAttribute.OPTIONAL) + + if attrs.get('isNullable', "false").lower() == 'true': + field.attributes.add(FieldAttribute.NULLABLE) + + self._struct.fields.append(field) + return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) + elif name.lower() == 'cluster': + self._cluster_codes.add(ParseInt(attrs['code'])) + return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) + else: + return BaseHandler(self.context) + + def FinalizeProcessing(self, idl: Idl): + # We have two choices of adding a struct: + # - inside a cluster if a code exists + # - inside top level if no codes were associated + if self._cluster_codes: + for code in self._cluster_codes: + found = False + for c in idl.clusters: + if c.code == code: + c.structs.append(self._struct) + found = True + + if not found: + logging.error('Enum %s could not find cluster (code %d/0x%X)' % + (self._struct.name, code, code)) + else: + idl.structs.append(self._struct) + + # Secondary processing, for fabric scoped: + # while ZAP XML maintains these at a struct level. Update attributes + if self._is_fabric_scoped: + for cluster in idl.clusters: + for attribute in cluster.attributes: + if self._struct.name == attribute.definition.data_type.name: + attribute.tags.add(AttributeTag.FABRIC_SCOPED) + + def EndProcessing(self): + self.context.AddIdlPostProcessor(self) + + +class EnumHandler(BaseHandler, IdlPostProcessor): + """ Handling /configurator/enum elements.""" + + def __init__(self, context: Context, attrs): + super().__init__(context) + self._cluster_code = None # if set, enum belongs to a specific cluster + self._enum = Enum(name=attrs['name'], base_type=attrs['type'], entries=[]) + + def GetNextProcessor(self, name, attrs): + if name.lower() == 'item': + self._enum.entries.append(ConstantEntry( + name=attrs['name'], + code=ParseInt(attrs['value']) + )) + return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) + elif name.lower() == 'cluster': + if self._cluster_code is not None: + raise Exception('Multiple cluster codes for enum %s' % self._enum.name) + self._cluster_code = ParseInt(attrs['code']) + return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) + else: + return BaseHandler(self.context) + + def FinalizeProcessing(self, idl: Idl): + # We have two choices of adding an enum: + # - inside a cluster if a code exists + # - inside top level if a code does not exist + + if self._cluster_code is None: + idl.enums.append(self._enum) + else: + found = False + for c in idl.clusters: + if c.code == self._cluster_code: + c.enums.append(self._enum) + found = True + + if not found: + logging.error('Enum %s could not find its cluster (code %d/0x%X)' % + (self._enum.name, self._cluster_code, self._cluster_code)) + + def EndProcessing(self): + self.context.AddIdlPostProcessor(self) + + +class BitmapHandler(BaseHandler): + """ Handling /configurator/bitmap elements.""" + + def __init__(self, context: Context, attrs): + super().__init__(context) + self._cluster_codes = set() + self._bitmap = Bitmap(name=attrs['name'], base_type=attrs['type'], entries=[]) + + def GetNextProcessor(self, name, attrs): + if name.lower() == 'cluster': + # Multiple clusters may be associated, like IasZoneStatus + self._cluster_codes.add(ParseInt(attrs['code'])) + return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) + elif name.lower() == 'field': + self._bitmap.entries.append(ConstantEntry( + name=attrs['name'], + code=ParseInt(attrs['mask']) + )) + return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) + elif name.lower() == 'description': + return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE) + else: + return BaseHandler(self.context) + + def FinalizeProcessing(self, idl: Idl): + # We have two choices of adding an enum: + # - inside a cluster if a code exists + # - inside top level if a code does not exist + if not self._cluster_codes: + # Log only instead of critical, as not our XML is well formed. + # For example at the time of writing this, SwitchFeature in switch-cluster.xml + # did not have a code associated with it. + logging.error("Bitmap %r has no cluster codes" % self._bitmap) + return + + for code in self._cluster_codes: + found = False + for c in idl.clusters: + if c.code == code: + c.bitmaps.append(self._bitmap) + found = True + if not found: + logging.error('Bitmap %s could not find its cluster (code %d/0x%X)' % + (self._bitmap.name, code, code)) + + def EndProcessing(self): + self.context.AddIdlPostProcessor(self) + + +class CommandHandler(BaseHandler): + """Handles /configurator/cluster/command elements.""" + + def __init__(self, context: Context, cluster: Cluster, attrs): + super().__init__(context) + self._cluster = cluster + self._command = None + self._struct = Struct(name=attrs['name'], fields=[]) + self._field_index = 0 # commands DO NOT support field index it seems + + if attrs['source'].lower() == 'client': + self._struct.tag = StructTag.REQUEST + + name = attrs['name'] + + if name.endswith('Request'): + request_name = name + command_name = name[:-7] + else: + request_name = name+'Request' + command_name = name + + self._struct.name = request_name + + if 'response' in attrs: + response_name = attrs['response'] + else: + response_name = 'DefaultResponse' + + self._command = Command( + name=name, + code=ParseInt(attrs['code']), + input_param=request_name, + output_param=response_name, + ) + + if attrs.get('isFabricScoped', 'false') == 'true': + self._command.attributes.add(CommandAttribute.FABRIC_SCOPED) + + if attrs.get('mustUseTimedInvoke', 'false') == 'true': + self._command.attributes.add(CommandAttribute.TIMED_INVOKE) + + else: + self._struct.tag = StructTag.RESPONSE + self._struct.code = ParseInt(attrs['code']) + + def GetArgumentField(self, attrs): + data_type = DataType(name=attrs['type']) + + if 'length' in attrs: + data_type.max_length = ParseInt(attrs['length']) + + self._field_index += 1 + + field = Field( + data_type=data_type, + code=self._field_index, + name=attrs['name'], + is_list=(attrs.get('array', 'false') == 'true') + ) + + if attrs.get('optional', "false").lower() == 'true': + field.attributes.add(FieldAttribute.OPTIONAL) + + if attrs.get('isNullable', "false").lower() == 'true': + field.attributes.add(FieldAttribute.NULLABLE) + + return field + + def GetNextProcessor(self, name: str, attrs): + if name.lower() == 'access': + if attrs['op'] != 'invoke': + raise Exception('Unknown access for %r' % self._struct) + + if self._command: + self._command.invokeacl = AttrsToAccessPrivilege(attrs) + else: + logging.warning("Ignored access role for reply %r" % self._struct) + return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) + elif name.lower() == 'arg': + self._struct.fields.append(self.GetArgumentField(attrs)) + return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) + elif name.lower() == 'description': + return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE) + else: + return BaseHandler(self.context) + + def EndProcessing(self): + + if self._struct.fields: + self._cluster.structs.append(self._struct) + else: + # no input + self._command.input_param = None + + if self._command: + self._cluster.commands.append(self._command) + + +class ClusterGlobalAttributeHandler(BaseHandler): + """Handles /configurator/cluster/globalAttribute elements.""" + + def __init__(self, context: Context, cluster: Cluster, code: int): + super().__init__(context) + self._cluster = cluster + self._code = code + + def GetNextProcessor(self, name: str, attrs): + if name.lower() == 'featurebit': + # It is uncler what featurebits mean. likely a bitmap should be created + # here, however only one such example exists currently: door-lock-cluster.xml + logging.info('Ignoring featurebit tag for global attribute 0x%X (%d)' % (self._code, self._code)) + return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) + else: + return BaseHandler(self.context) + + def EndProcessing(self): + self._cluster.attributes.append(self.context.GetGlobalAttribute(self._code)) + + +class ClusterHandler(BaseHandler): + """Handles /configurator/cluster elements.""" + + def __init__(self, context: Context, idl: Idl): + super().__init__(context) + self._cluster = Cluster( + side=ClusterSide.CLIENT, + name=None, + code=None, + parse_meta=context.GetCurrentLocationMeta() + ) + self._idl = idl + + def GetNextProcessor(self, name: str, attrs): + if name.lower() == 'code': + return ClusterCodeHandler(self.context, self._cluster) + elif name.lower() == 'name': + return ClusterNameHandler(self.context, self._cluster) + elif name.lower() == 'attribute': + return AttributeHandler(self.context, self._cluster, attrs) + elif name.lower() == 'event': + return EventHandler(self.context, self._cluster, attrs) + elif name.lower() == 'globalattribute': + # We ignore 'side' and 'value' since they do not seem useful + return ClusterGlobalAttributeHandler(self.context, self._cluster, ParseInt(attrs['code'])) + elif name.lower() == 'command': + return CommandHandler(self.context, self._cluster, attrs) + elif name.lower() in ['define', 'description', 'domain', 'tag', 'client', 'server']: + # NOTE: we COULD use client and server to create separate definitions + # of each, but the usefulness of this is unclear as the definitions are + # likely identical and matter has no concept of differences between the two + return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE) + else: + return BaseHandler(self.context) + + def EndProcessing(self): + if self._cluster.name is None: + raise Exception("Missing cluster name") + elif self._cluster.code is None: + raise Exception("Missing cluster code") + + self._idl.clusters.append(self._cluster) + +# Cluster extensions have extra bits for existing clusters. Can only be loaded +# IF the underlying cluster exits + + +class ClusterExtensionHandler(ClusterHandler, IdlPostProcessor): + """Handling /configurator/clusterExtension elements.""" + + def __init__(self, context: Context, code: int): + # NOTE: IDL is set to NONE so that ClusterHandler cannot + # inadvertently change it (it will be invalid anyway) + super().__init__(context, None) + self._cluster_code = code + + def EndProcessing(self): + self.context.AddIdlPostProcessor(self) + + def FinalizeProcessing(self, idl: Idl): + found = False + for c in idl.clusters: + if c.code == self._cluster_code: + found = True + + # Append everything that can be appended + c.enums.extend(self._cluster.enums) + c.bitmaps.extend(self._cluster.bitmaps) + c.events.extend(self._cluster.events) + c.attributes.extend(self._cluster.attributes) + c.structs.extend(self._cluster.structs) + c.commands.extend(self._cluster.commands) + + if not found: + logging.error('Could not extend cluster 0x%X (%d): cluster not found' % + (self._cluster_code, self._cluster_code)) + + +class GlobalAttributeHandler(BaseHandler): + """Handling configurator/global/globalAttribute elements.""" + + def __init__(self, context: Context, attribute: Attribute): + super().__init__(context, handled=HandledDepth.SINGLE_TAG) + self._attribute = attribute + + def HandleContent(self, content: str): + # Content generally is the name EXCEPT if access controls + # exist, in which case `description` contains the name + # + # Global attributes do not currently have access controls, so this + # case is not handled here + content = content.strip() + if content and not self._attribute.definition.name: + self._attribute.definition.name = content + + def EndProcessing(self): + if self._attribute.definition.name is None: + raise Exception("Name for attribute was not parsed.") + + self.context.AddGlobalAttribute(self._attribute) + + +class GlobalHandler(BaseHandler): + """Handling configurator/global elements.""" + + def __init__(self, context: Context): + super().__init__(context, handled=HandledDepth.SINGLE_TAG) + + def GetNextProcessor(self, name, attrs): + if name.lower() == 'attribute': + if attrs['side'].lower() == 'client': + # We expect to also have 'server' equivalent, so ignore client + # side attributes + logging.debug('Ignoring global client-side attribute %s' % (attrs['code'])) + return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) + + return GlobalAttributeHandler(self.context, AttrsToAttribute(attrs)) + else: + return BaseHandler(self.context) + + +class ConfiguratorHandler(BaseHandler): + """ Handling /configurator elements.""" + + def __init__(self, context: Context, idl: Idl): + super().__init__(context, handled=HandledDepth.SINGLE_TAG) + self._idl = idl + + def GetNextProcessor(self, name: str, attrs): + if name.lower() == 'cluster': + return ClusterHandler(self.context, self._idl) + elif name.lower() == 'enum': + return EnumHandler(self.context, attrs) + elif name.lower() == 'struct': + return StructHandler(self.context, attrs) + elif name.lower() == 'bitmap': + return BitmapHandler(self.context, attrs) + elif name.lower() == 'domain': + return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE) + elif name.lower() == 'clusterextension': + return ClusterExtensionHandler(self.context, ParseInt(attrs['code'])) + elif name.lower() == 'accesscontrol': + # These contain operation/role/modifier and generally only contain a + # description. These do not seem as useful to parse. + return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE) + elif name.lower() == 'atomic': + # A list of types in 'chip-types' + # Generally does not seem useful - matches a type id to a description, size and some discrete/analog flags + # + # Could be eventually used as a preload of types into base types, however matter idl + # generator logic has hardcoded sizing as well. + return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE) + elif name.lower() == 'devicetype': + # A list of device types in 'matter-devices.xml' + # Useful for conformance tests, but does not seem usable for serialization logic + return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE) + elif name.lower() == 'global': + return GlobalHandler(self.context) + else: + return BaseHandler(self.context) diff --git a/scripts/idl/zapxml/handlers/parsing.py b/scripts/idl/zapxml/handlers/parsing.py new file mode 100644 index 00000000000000..d5b45dc722a632 --- /dev/null +++ b/scripts/idl/zapxml/handlers/parsing.py @@ -0,0 +1,96 @@ +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# 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. + +from idl.matter_idl_types import * + + +def ParseInt(value: str) -> int: + """Convert a string that is a known integer into an actual number. + + Supports decimal or hex values prefixed with '0x' + """ + if value.startswith('0x'): + return int(value[2:], 16) + else: + return int(value) + + +def AttrsToAccessPrivilege(attrs) -> AccessPrivilege: + """Given attributes of an '' tag, generate the underlying + access privilege by looking at the role/privilege attribute. + """ + + # XML seems to use both role and privilege to mean the same thing + # they are used interchangeably + if 'role' in attrs: + role = attrs['role'] + else: + role = attrs['privilege'] + + if role.lower() == 'view': + return AccessPrivilege.VIEW + elif role.lower() == 'operate': + return AccessPrivilege.OPERATE + elif role.lower() == 'manage': + return AccessPrivilege.MANAGE + elif role.lower() == 'administer': + return AccessPrivilege.ADMINISTER + else: + raise Exception('Unknown ACL role: %r' % role) + + +def AttrsToAttribute(attrs) -> Attribute: + """Given the attributes of an '' tag, generate the + underlying IDL Attribute dataclass. + """ + + if attrs['type'].lower() == 'array': + data_type = DataType(name=attrs['entryType']) + else: + data_type = DataType(name=attrs['type']) + + if 'length' in attrs: + data_type.max_length = ParseInt(attrs['length']) + + field = Field( + data_type=data_type, + code=ParseInt(attrs['code']), + name=None, + is_list=(attrs['type'].lower() == 'array') + ) + + attribute = Attribute(definition=field) + + if attrs.get('optional', "false").lower() == 'true': + attribute.definition.attributes.add(FieldAttribute.OPTIONAL) + + if attrs.get('isNullable', "false").lower() == 'true': + attribute.definition.attributes.add(FieldAttribute.NULLABLE) + + if attrs.get('readable', "true").lower() == 'true': + attribute.tags.add(AttributeTag.READABLE) + + if attrs.get('writable', "false").lower() == 'true': + attribute.tags.add(AttributeTag.WRITABLE) + + # TODO(#22937): NOSUBSCRIBE attribute tag is not available - could find no + # clear source to get this info. + + # NOTE: default values are also present in this XML, however generally IDL + # **DATA** definitions would not care about the defaults. The + # defaults should be used to initializ storage for devices, hence + # they are part of endpoint definition/composition. We are not doing + # that here, so defaults are ignored. + + return attribute diff --git a/scripts/tools/nxp/generate_nxp_chip_factory_bin.py b/scripts/tools/nxp/generate_nxp_chip_factory_bin.py new file mode 100755 index 00000000000000..17b8b388d21855 --- /dev/null +++ b/scripts/tools/nxp/generate_nxp_chip_factory_bin.py @@ -0,0 +1,170 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2022 Project CHIP Authors +# 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. +# + +import argparse +import subprocess +import base64 +import logging +import os +from cryptography.hazmat.backends import default_backend +from cryptography.hazmat.primitives.serialization import load_der_private_key + +# Keys used to store KLV +KLV_KEYS = { + "Verifier": 1, + "Salt": 2, + "IC": 3, + "DacPKey": 4, + "DacCert": 5, + "PaiCert": 6, + "Disc": 7 +} + + +def type_int(n): + return int(n, 0) + + +def read_der(der_file): + with open(der_file, "rb") as file: + return file.read() + + +def generate_spake2_params(spake2_path, passcode, it, salt): + cmd = [ + spake2_path, "gen-verifier", "--iteration-count", + str(it), "--salt", + str(salt), "--pin-code", + str(passcode), "--out", "-" + ] + + out = subprocess.run(cmd, check=True, stdout=subprocess.PIPE).stdout + out = out.decode("utf-8").splitlines() + return dict(zip(out[0].split(','), out[1].split(','))) + + +def get_private_key_der(der_file, password): + data = read_der(der_file) + keys = load_der_private_key(data, password, backend=default_backend()) + private_key = keys.private_numbers().private_value.to_bytes( + 32, byteorder='big') + return private_key + + +def generate_klv(spake2_params, args): + klv = [] + + spake2p_verifier = str.encode(spake2_params["Verifier"]) + spake2p_salt = str.encode(spake2_params["Salt"]) + spake2p_it = int(spake2_params["Iteration Count"]).to_bytes(4, "little") + dac_private_key = get_private_key_der(args.dac_key, args.dac_key_password) + dac_cert = read_der(args.dac_cert) + pai_cert = read_der(args.pai_cert) + discriminator = int(args.discrimnator).to_bytes(4, "little") + + klv.append((KLV_KEYS["Verifier"], len(spake2p_verifier), spake2p_verifier)) + print("Verifier length: ", len(spake2p_verifier)) + klv.append((KLV_KEYS["Salt"], len(spake2p_salt), spake2p_salt)) + print("SALT length: ", len(spake2p_salt)) + klv.append((KLV_KEYS["IC"], 4, spake2p_it)) + klv.append((KLV_KEYS["DacPKey"], len(dac_private_key), dac_private_key)) + print("DAC Private Key length: ", len(dac_private_key)) + klv.append((KLV_KEYS["DacCert"], len(dac_cert), dac_cert)) + print("DAC Certificate length: ", len(dac_cert)) + klv.append((KLV_KEYS["PaiCert"], len(pai_cert), pai_cert)) + print("PAI Certificate length: ", len(pai_cert)) + klv.append((KLV_KEYS["Disc"], 4, discriminator)) + return klv + + +def klv_to_bin(klv, out): + with open(out, "wb") as file: + for entry in klv: + file.write(entry[0].to_bytes(1, "little")) + file.write(entry[1].to_bytes(2, "little")) + file.write(entry[2]) + size = file.seek(0, os.SEEK_END) + print("Size of generated binary is:", size, "bytes") + + +def main(): + parser = argparse.ArgumentParser(description="NXP Factory Data Generator") + + parser.add_argument("-i", + "--it", + required=True, + type=type_int, + help="[int | hex] Spake2 Iteration Counter") + parser.add_argument("-s", + "--salt", + type=str, + required=True, + help="[ascii] Spake2 Salt") + parser.add_argument("-p", + "--passcode", + type=type_int, + required=True, + help="[int | hex] PASE session passcode") + parser.add_argument("-d", + "--discrimnator", + type=type_int, + required=True, + help="[int | hex] BLE Pairing discrimantor") + parser.add_argument("--dac_cert", + type=str, + required=True, + help="[path] Path to DAC certificate in DER format") + parser.add_argument("--dac_key", + type=str, + required=True, + help="[path] Path to DAC key in DER format") + parser.add_argument("--dac_key_password", + type=str, + required=False, + help="[path] Password to decode DAC Key if available") + parser.add_argument("--pai_cert", + type=str, + required=True, + help="[path] Path to PAI certificate in DER format") + parser.add_argument("--spake2p_path", + type=str, + required=True, + help="[path] Path to Spake2P") + parser.add_argument("--out", + type=str, + required=True, + help="[path] Path to output binary") + + args = parser.parse_args() + + if args.dac_key_password is None: + logging.warning( + "DAC Key password not provided. It means DAC Key is not protected." + ) + + spake2_params = generate_spake2_params(args.spake2p_path, args.passcode, + args.it, args.salt) + klv = generate_klv(spake2_params, args) + klv_to_bin(klv, args.out) + + +if __name__ == "__main__": + main() + +# Example usage: +# python3 generate_nxp_chip_factory_bin.py -i 10000 -s ABCDEFGHIJKLMNOPQRS -p 14014 -d 1000 --dac_cert /home/john/nxp/connectedhomeip_nxp/Chip-DAC-NXP-Cert.der --dac_key /home/john/nxp/connectedhomeip_nxp/Chip-DAC-NXP-Key.der --pai_cert /home/john/nxp/connectedhomeip_nxp/Chip-PAI-NXP-Cert.der --spake2p_path /home/john/nxp/connectedhomeip_nxp/out/host/spake2p --out out.bin diff --git a/src/controller/CHIPDeviceControllerFactory.cpp b/src/controller/CHIPDeviceControllerFactory.cpp index 45ab785e508640..84a7c4388525bd 100644 --- a/src/controller/CHIPDeviceControllerFactory.cpp +++ b/src/controller/CHIPDeviceControllerFactory.cpp @@ -463,6 +463,7 @@ void DeviceControllerSystemState::Shutdown() if (mTempFabricTable != nullptr) { + mTempFabricTable->Shutdown(); chip::Platform::Delete(mTempFabricTable); mTempFabricTable = nullptr; // if we created a temp fabric table, then mFabrics points to it. diff --git a/src/controller/python/chip/ChipStack.py b/src/controller/python/chip/ChipStack.py index c6b5ebac7fbaf1..77d36b39d511c0 100644 --- a/src/controller/python/chip/ChipStack.py +++ b/src/controller/python/chip/ChipStack.py @@ -328,11 +328,14 @@ def setLogFunct(self, logFunct): self._ChipStackLib.pychip_Stack_SetLogFunct(logFunct) def Shutdown(self): - # Make sure PersistentStorage is destructed before chipStack - # to avoid accessing builtins.chipStack after destruction. + self.Call(lambda: self._ChipStackLib.pychip_DeviceController_StackShutdown()) + + # + # We only shutdown the persistent storage layer AFTER we've shut down the stack, + # since there is a possibility of interactions with the storage layer during shutdown. + # self._persistentStorage.Shutdown() self._persistentStorage = None - self.Call(lambda: self._ChipStackLib.pychip_DeviceController_StackShutdown()) # # Stack init happens in native, but shutdown happens here unfortunately. diff --git a/src/controller/python/chip/storage/__init__.py b/src/controller/python/chip/storage/__init__.py index ad51c75754f9f4..926b7e12855849 100644 --- a/src/controller/python/chip/storage/__init__.py +++ b/src/controller/python/chip/storage/__init__.py @@ -90,6 +90,8 @@ class PersistentStorage: This interfaces with a C++ adapter that implements the PersistentStorageDelegate interface and can be passed into C++ logic that needs an instance of that interface. + + Object must be resident before the Matter stack starts up and last past its shutdown. ''' @classmethod def logger(cls): @@ -241,15 +243,21 @@ def DeleteSdkKey(self, key: str): def Shutdown(self): ''' Shuts down the object by free'ing up the associated adapter instance. - You cannot interact with this object there-after. + + This should only be called after the CHIP stack has shutdown (i.e + after calling pychip_DeviceController_StackShutdown()). ''' - self._handle.pychip_Storage_ShutdownAdapter.argtypes = [c_void_p] - builtins.chipStack.Call( - lambda: self._handle.pychip_Storage_ShutdownAdapter(self._closure) - ) + if (self._isActive): + self._handle.pychip_Storage_ShutdownAdapter.argtypes = [c_void_p] - self._isActive = False + # + # Since the stack is not running at this point, we can safely call + # C++ method directly on the current execution context without worrying + # about race conditions. + # + self._handle.pychip_Storage_ShutdownAdapter(self._closure) + self._isActive = False @property def jsonData(self) -> Dict: @@ -258,7 +266,4 @@ def jsonData(self) -> Dict: return copy.deepcopy(self._jsonData) def __del__(self): - if (self._isActive): - builtins.chipStack.Call( - lambda: self._handle.pychip_Storage_ShutdownAdapter() - ) + self.Shutdown() diff --git a/src/controller/python/chip/tlv/__init__.py b/src/controller/python/chip/tlv/__init__.py index 20f2bfebd2f2dd..5665c5e2a4f46b 100644 --- a/src/controller/python/chip/tlv/__init__.py +++ b/src/controller/python/chip/tlv/__init__.py @@ -680,13 +680,11 @@ def _get(self, tlv, decodings, out): if "profileTag" in list(decoding.keys()): out[decoding["profileTag"]] = decoding["value"] elif "tag" in list(decoding.keys()): - if decoding["tag"] is not None: - out[decoding["tag"]] = decoding["value"] + if isinstance(out, Mapping): + tag = decoding["tag"] if decoding["tag"] is not None else "Any" + out[tag] = decoding["value"] else: - if isinstance(out, Mapping): - out["Any"] = decoding["value"] - elif isinstance(out, Sequence): - out.append(decoding["value"]) + out.append(decoding["value"]) else: raise ValueError("Attempt to decode unsupported TLV tag") diff --git a/src/controller/python/test/unit_tests/test_tlv.py b/src/controller/python/test/unit_tests/test_tlv.py index 7e83f9c26863f2..901197b4ea4742 100644 --- a/src/controller/python/test/unit_tests/test_tlv.py +++ b/src/controller/python/test/unit_tests/test_tlv.py @@ -148,6 +148,18 @@ def test_uint(self): self._read_case([0b00000101, 0xab, 0xaa], tlvUint(0xaaab)) self._read_case([0b00000100, 0xab], tlvUint(0xab)) + def test_structure(self): + test_cases = [ + (b'\x15\x36\x01\x15\x35\x01\x26\x00\xBF\xA2\x55\x16\x37\x01\x24\x02\x00\x24\x03\x28\x24\x04\x00\x18\x24\x02\x01\x18\x18\x18\x18', + {1: [{1: {0: 374710975, 1: [0, 40, 0], 2: 1}}]}), + (b'\x156\x01\x155\x01&\x00\xBF\xA2U\x167\x01$\x02\x00$\x03($\x04\x01\x18,\x02\x18Nordic Semiconductor ASA\x18\x18\x18\x18', + {1: [{1: {0: 374710975, 1: [0, 40, 1], 2: 'Nordic Semiconductor ASA'}}]}), + (b"\0256\001\0255\001&\000\031\346x\2077\001$\002\001$\003\006$\004\000\030(\002\030\030\030\030", + {1: [{1: {0: 2272847385, 1: [1, 6, 0], 2: False}}]}) + ] + for tlv_bytes, answer in test_cases: + self._read_case(tlv_bytes, answer) + if __name__ == '__main__': unittest.main() diff --git a/src/crypto/CHIPCryptoPALTinyCrypt.cpp b/src/crypto/CHIPCryptoPALTinyCrypt.cpp index d0afe4d6b23663..2083728bdd5135 100644 --- a/src/crypto/CHIPCryptoPALTinyCrypt.cpp +++ b/src/crypto/CHIPCryptoPALTinyCrypt.cpp @@ -1327,8 +1327,8 @@ CHIP_ERROR ExtractPubkeyFromX509Cert(const ByteSpan & certificate, Crypto::P256P #if defined(MBEDTLS_X509_CRT_PARSE_C) CHIP_ERROR error = CHIP_NO_ERROR; mbedtls_x509_crt mbed_cert; - mbedtls_ecp_keypair * keypair = nullptr; - size_t pubkey_size = 0; + mbedtls_uecc_keypair * keypair = nullptr; + size_t pubkey_size = 0; mbedtls_x509_crt_init(&mbed_cert); @@ -1338,15 +1338,11 @@ CHIP_ERROR ExtractPubkeyFromX509Cert(const ByteSpan & certificate, Crypto::P256P VerifyOrExit(mbedtls_pk_get_type(&(mbed_cert.CHIP_CRYPTO_PAL_PRIVATE_X509(pk))) == MBEDTLS_PK_ECKEY, error = CHIP_ERROR_INVALID_ARGUMENT); - keypair = mbedtls_pk_ec(mbed_cert.CHIP_CRYPTO_PAL_PRIVATE_X509(pk)); - VerifyOrExit(keypair->CHIP_CRYPTO_PAL_PRIVATE(grp).id == MapECPGroupId(pubkey.Type()), error = CHIP_ERROR_INVALID_ARGUMENT); - // Copy the public key from the cert in raw point format - result = - mbedtls_ecp_point_write_binary(&keypair->CHIP_CRYPTO_PAL_PRIVATE(grp), &keypair->CHIP_CRYPTO_PAL_PRIVATE(Q), - MBEDTLS_ECP_PF_UNCOMPRESSED, &pubkey_size, Uint8::to_uchar(pubkey.Bytes()), pubkey.Length()); + keypair = mbedtls_pk_uecc(mbed_cert.CHIP_CRYPTO_PAL_PRIVATE_X509(pk)); + Uint8::to_uchar(pubkey)[0] = 0x04; // uncompressed type + memcpy(Uint8::to_uchar(pubkey) + 1, keypair->public_key, 2 * NUM_ECC_BYTES); VerifyOrExit(result == 0, error = CHIP_ERROR_INTERNAL); - VerifyOrExit(pubkey_size == pubkey.Length(), error = CHIP_ERROR_INTERNAL); exit: _log_mbedTLS_error(result); diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h index c4dd017228604e..c3f1de4dde19cb 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h +++ b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h @@ -27,7 +27,7 @@ #include #include -#include +#include namespace chip { namespace DeviceLayer { diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.ipp b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.ipp index 5b4c19c0a4279f..68c88de991b12c 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.ipp +++ b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.ipp @@ -35,7 +35,7 @@ #include #include -#include +#include #define DEFAULT_MIN_SLEEP_PERIOD (60 * 60 * 24 * 30) // Month [sec] diff --git a/src/inet/InetInterface.cpp b/src/inet/InetInterface.cpp index e3773321e79da1..88c2176f9bb32c 100644 --- a/src/inet/InetInterface.cpp +++ b/src/inet/InetInterface.cpp @@ -56,7 +56,7 @@ #endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS && CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS #if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF -#include +#include #endif // CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF #if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT diff --git a/src/inet/InetInterface.h b/src/inet/InetInterface.h index f2e89fe4697919..8a182294476a6e 100644 --- a/src/inet/InetInterface.h +++ b/src/inet/InetInterface.h @@ -42,7 +42,7 @@ struct ifaddrs; #endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS #if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF -#include +#include struct net_if; struct net_if_ipv4; diff --git a/src/messaging/ExchangeContext.h b/src/messaging/ExchangeContext.h index 4631cb0e0b81ad..6d6c9e58acf148 100644 --- a/src/messaging/ExchangeContext.h +++ b/src/messaging/ExchangeContext.h @@ -183,6 +183,10 @@ class DLL_EXPORT ExchangeContext : public ReliableMessageContext, // Set the response timeout for the exchange context, regardless of the underlying session type. Using // UseSuggestedResponseTimeout to set a timeout based on the type of the session and the application processing time instead of // using this function is recommended. + // + // If a timeout of 0 is provided, it implies no response is expected. Consequently, ExchangeDelegate::OnResponseTimeout will not + // be called. + // void SetResponseTimeout(Timeout timeout); // This API is used by commands that need to shut down all existing diff --git a/src/messaging/README.md b/src/messaging/README.md index f85a2767b1c8c6..bab614e85360ae 100644 --- a/src/messaging/README.md +++ b/src/messaging/README.md @@ -21,7 +21,7 @@ Unless specified, numerical values are represented in decimal notation. | Field | Description | | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -| exchange_id | Exchange ID + IsInitiator flag from message header ('i' if initiator, 'r' if responder') | +| exchange_id | Exchange ID + `IsInitiator` flag from message header ('i' if initiator, 'r' if responder') | | msg_id | Message counter | | ack_msg_id | If present, the ACK message counter. Otherwise, this entire field is omitted from display | | msg_category | U: Un-secure Unicast, S: Secure Unicast, G: Secure Groupcast | diff --git a/src/platform/EFR32/BLEManagerImpl.cpp b/src/platform/EFR32/BLEManagerImpl.cpp index 344d6c58a7d362..91de55f6698473 100644 --- a/src/platform/EFR32/BLEManagerImpl.cpp +++ b/src/platform/EFR32/BLEManagerImpl.cpp @@ -32,6 +32,9 @@ #include "FreeRTOS.h" #include "rail.h" +extern "C" { +#include "sl_bluetooth.h" +} #include "sl_bt_api.h" #include "sl_bt_stack_config.h" #include "sl_bt_stack_init.h" @@ -41,7 +44,7 @@ #include #include #include -#include +#include #if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING #include @@ -95,10 +98,6 @@ namespace { TimerHandle_t sbleAdvTimeoutTimer; // FreeRTOS sw timer. -StackType_t bluetoothEventStack[CHIP_DEVICE_CONFIG_BLE_APP_TASK_STACK_SIZE / sizeof(StackType_t)]; -StaticTask_t bluetoothEventTaskStruct; -static TaskHandle_t BluetoothEventTaskHandle; - const uint8_t UUID_CHIPoBLEService[] = { 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xF6, 0xFF, 0x00, 0x00 }; const uint8_t ShortUUID_CHIPoBLEService[] = { 0xF6, 0xFF }; @@ -111,32 +110,9 @@ const ChipBleUUID ChipUUID_CHIPoBLEChar_TX = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0 BLEManagerImpl BLEManagerImpl::sInstance; -/***************************************************************************/ -/** - * Setup the bluetooth init function. - * - * @return none - * - * All bluetooth specific initialization - * code should be here like sl_bt_init_stack(), - * sl_bt_init_multiprotocol() and so on. - ******************************************************************************/ -extern "C" sl_status_t initialize_bluetooth() -{ -#if !defined(SL_CATALOG_KERNEL_PRESENT) - NVIC_ClearPendingIRQ(PendSV_IRQn); - NVIC_EnableIRQ(PendSV_IRQn); -#endif - sl_status_t err = sl_bt_stack_init(); - EFM_ASSERT(err == SL_STATUS_OK); - - return err; -} - CHIP_ERROR BLEManagerImpl::_Init() { CHIP_ERROR err; - sl_status_t ret; // Initialize the CHIP BleLayer. err = BleLayer::Init(this, this, &DeviceLayer::SystemLayer()); @@ -146,22 +122,6 @@ CHIP_ERROR BLEManagerImpl::_Init() memset(mIndConfId, kUnusedIndex, sizeof(mIndConfId)); mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled; - // Start Bluetooth Link Layer and stack tasks - ret = - bluetooth_start(CHIP_DEVICE_CONFIG_BLE_LL_TASK_PRIORITY, CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY, initialize_bluetooth); - - VerifyOrExit(ret == SL_STATUS_OK, err = MapBLEError(ret)); - - // Create the Bluetooth Application task - BluetoothEventTaskHandle = - xTaskCreateStatic(bluetoothStackEventHandler, /* Function that implements the task. */ - CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME, /* Text name for the task. */ - ArraySize(bluetoothEventStack), /* Number of indexes in the xStack array. */ - this, /* Parameter passed into the task. */ - CHIP_DEVICE_CONFIG_BLE_APP_TASK_PRIORITY, /* Priority at which the task is created. */ - bluetoothEventStack, /* Pointer to task heap */ - &bluetoothEventTaskStruct); /* Variable that holds the task struct */ - // Create FreeRTOS sw timer for BLE timeouts and interval change. sbleAdvTimeoutTimer = xTimerCreate("BleAdvTimer", // Just a text name, not used by the RTOS kernel 1, // == default timer period (mS) @@ -192,129 +152,6 @@ uint16_t BLEManagerImpl::_NumConnections(void) return numCons; } -void BLEManagerImpl::bluetoothStackEventHandler(void * p_arg) -{ - EventBits_t flags = 0; - - while (1) - { - // wait for Bluetooth stack events, do not consume set flag - flags = xEventGroupWaitBits(bluetooth_event_flags, /* The event group being tested. */ - BLUETOOTH_EVENT_FLAG_EVT_WAITING, /* The bits within the event group to wait for. */ - pdFALSE, /* Dont clear flags before returning */ - pdFALSE, /* Any flag will do, dont wait for all flags to be set */ - portMAX_DELAY); /* Wait for maximum duration for bit to be set */ - - if (flags & BLUETOOTH_EVENT_FLAG_EVT_WAITING) - { - flags &= ~BLUETOOTH_EVENT_FLAG_EVT_WAITING; - xEventGroupClearBits(bluetooth_event_flags, BLUETOOTH_EVENT_FLAG_EVT_WAITING); - - // As this is running in a separate thread, we need to block CHIP from operating, - // until the events are handled. - PlatformMgr().LockChipStack(); - - // handle bluetooth events - switch (SL_BT_MSG_ID(bluetooth_evt->header)) - { - case sl_bt_evt_system_boot_id: { - ChipLogProgress(DeviceLayer, "Bluetooth stack booted: v%d.%d.%d-b%d", bluetooth_evt->data.evt_system_boot.major, - bluetooth_evt->data.evt_system_boot.minor, bluetooth_evt->data.evt_system_boot.patch, - bluetooth_evt->data.evt_system_boot.build); - sInstance.HandleBootEvent(); - - RAIL_Version_t railVer; - RAIL_GetVersion(&railVer, true); - ChipLogProgress(DeviceLayer, "RAIL version:, v%d.%d.%d-b%d", railVer.major, railVer.minor, railVer.rev, - railVer.build); - sl_bt_connection_set_default_parameters(BLE_CONFIG_MIN_INTERVAL, BLE_CONFIG_MAX_INTERVAL, BLE_CONFIG_LATENCY, - BLE_CONFIG_TIMEOUT, BLE_CONFIG_MIN_CE_LENGTH, BLE_CONFIG_MAX_CE_LENGTH); - } - break; - - case sl_bt_evt_connection_opened_id: { - sInstance.HandleConnectEvent(bluetooth_evt); - } - break; - case sl_bt_evt_connection_parameters_id: { - // ChipLogProgress(DeviceLayer, "Connection parameter ID received"); - } - break; - case sl_bt_evt_connection_phy_status_id: { - // ChipLogProgress(DeviceLayer, "PHY update procedure is completed"); - } - break; - case sl_bt_evt_connection_closed_id: { - sInstance.HandleConnectionCloseEvent(bluetooth_evt); - } - break; - - /* This event indicates that a remote GATT client is attempting to write a value of an - * attribute in to the local GATT database, where the attribute was defined in the GATT - * XML firmware configuration file to have type="user". */ - case sl_bt_evt_gatt_server_attribute_value_id: { - sInstance.HandleWriteEvent(bluetooth_evt); - } - break; - - case sl_bt_evt_gatt_mtu_exchanged_id: { - sInstance.UpdateMtu(bluetooth_evt); - } - break; - - // confirmation of indication received from remote GATT client - case sl_bt_evt_gatt_server_characteristic_status_id: { - sl_bt_gatt_server_characteristic_status_flag_t StatusFlags; - - StatusFlags = (sl_bt_gatt_server_characteristic_status_flag_t) - bluetooth_evt->data.evt_gatt_server_characteristic_status.status_flags; - - if (sl_bt_gatt_server_confirmation == StatusFlags) - { - sInstance.HandleTxConfirmationEvent(bluetooth_evt->data.evt_gatt_server_characteristic_status.connection); - } - else if ((bluetooth_evt->data.evt_gatt_server_characteristic_status.characteristic == gattdb_CHIPoBLEChar_Tx) && - (bluetooth_evt->data.evt_gatt_server_characteristic_status.status_flags == gatt_server_client_config)) - { - sInstance.HandleTXCharCCCDWrite(bluetooth_evt); - } - } - break; - - /* Software Timer event */ - case sl_bt_evt_system_soft_timer_id: { - sInstance.HandleSoftTimerEvent(bluetooth_evt); - } - break; - - case sl_bt_evt_gatt_server_user_read_request_id: { - ChipLogProgress(DeviceLayer, "GATT server user_read_request"); -#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING - if (bluetooth_evt->data.evt_gatt_server_user_read_request.characteristic == gattdb_CHIPoBLEChar_C3) - { - HandleC3ReadRequest(bluetooth_evt); - } -#endif // CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING - } - break; - - case sl_bt_evt_connection_remote_used_features_id: { - // ChipLogProgress(DeviceLayer, "link layer features supported by the remote device"); - } - break; - - default: - ChipLogProgress(DeviceLayer, "evt_UNKNOWN id = %08" PRIx32, SL_BT_MSG_ID(bluetooth_evt->header)); - break; - } - } - - PlatformMgr().UnlockChipStack(); - - vRaiseEventFlagBasedOnContext(bluetooth_event_flags, BLUETOOTH_EVENT_FLAG_EVT_HANDLED); - } -} - CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -531,6 +368,8 @@ CHIP_ERROR BLEManagerImpl::MapBLEError(int bleErr) return CHIP_ERROR_INVALID_ARGUMENT; case SL_STATUS_INVALID_STATE: return CHIP_ERROR_INCORRECT_STATE; + case SL_STATUS_NOT_SUPPORTED: + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; default: return CHIP_ERROR(ChipError::Range::kPlatform, bleErr + CHIP_DEVICE_CONFIG_EFR32_BLE_ERROR_MIN); } @@ -638,12 +477,14 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) ChipLogError(DeviceLayer, "sl_bt_advertiser_create_set() failed: %s", ErrorStr(err)); ExitNow(); } - ret = sl_bt_advertiser_set_data(advertising_set_handle, CHIP_ADV_DATA, index, (uint8_t *) advData); + + ret = sl_bt_legacy_advertiser_set_data(advertising_set_handle, sl_bt_advertiser_advertising_data_packet, index, + (uint8_t *) advData); if (ret != SL_STATUS_OK) { err = MapBLEError(ret); - ChipLogError(DeviceLayer, "sl_bt_advertiser_set_data() failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "sl_bt_legacy_advertiser_set_data() - Advertising Data failed: %s", ErrorStr(err)); ExitNow(); } @@ -659,12 +500,13 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) memcpy(&responseData[index], mDeviceName, mDeviceNameLength); // AD value index += mDeviceNameLength; - ret = sl_bt_advertiser_set_data(advertising_set_handle, CHIP_ADV_SCAN_RESPONSE_DATA, index, (uint8_t *) responseData); + ret = sl_bt_legacy_advertiser_set_data(advertising_set_handle, sl_bt_advertiser_scan_response_packet, index, + (uint8_t *) responseData); if (ret != SL_STATUS_OK) { err = MapBLEError(ret); - ChipLogError(DeviceLayer, "sl_bt_advertiser_set_data() failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "sl_bt_legacy_advertiser_set_data() - Scan Response failed: %s", ErrorStr(err)); ExitNow(); } @@ -719,8 +561,8 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) err = MapBLEError(ret); SuccessOrExit(err); - sl_bt_advertiser_set_configuration(advertising_set_handle, 1); - ret = sl_bt_advertiser_start(advertising_set_handle, sl_bt_advertiser_user_data, connectableAdv); + sl_bt_advertiser_configure(advertising_set_handle, 1); + ret = sl_bt_legacy_advertiser_start(advertising_set_handle, connectableAdv); if (SL_STATUS_OK == ret) { @@ -1146,4 +988,106 @@ void BLEManagerImpl::DriveBLEState(intptr_t arg) } // namespace Internal } // namespace DeviceLayer } // namespace chip + +extern "C" void sl_bt_on_event(sl_bt_msg_t * evt) +{ + // As this is running in a separate thread, we need to block CHIP from operating, + // until the events are handled. + chip::DeviceLayer::PlatformMgr().LockChipStack(); + + // handle bluetooth events + switch (SL_BT_MSG_ID(evt->header)) + { + case sl_bt_evt_system_boot_id: { + ChipLogProgress(DeviceLayer, "Bluetooth stack booted: v%d.%d.%d-b%d", evt->data.evt_system_boot.major, + evt->data.evt_system_boot.minor, evt->data.evt_system_boot.patch, evt->data.evt_system_boot.build); + chip::DeviceLayer::Internal::BLEMgrImpl().HandleBootEvent(); + + RAIL_Version_t railVer; + RAIL_GetVersion(&railVer, true); + ChipLogProgress(DeviceLayer, "RAIL version:, v%d.%d.%d-b%d", railVer.major, railVer.minor, railVer.rev, railVer.build); + sl_bt_connection_set_default_parameters(BLE_CONFIG_MIN_INTERVAL, BLE_CONFIG_MAX_INTERVAL, BLE_CONFIG_LATENCY, + BLE_CONFIG_TIMEOUT, BLE_CONFIG_MIN_CE_LENGTH, BLE_CONFIG_MAX_CE_LENGTH); + } + break; + + case sl_bt_evt_connection_opened_id: { + chip::DeviceLayer::Internal::BLEMgrImpl().HandleConnectEvent(evt); + } + break; + case sl_bt_evt_connection_parameters_id: { + // ChipLogProgress(DeviceLayer, "Connection parameter ID received"); + } + break; + case sl_bt_evt_connection_phy_status_id: { + // ChipLogProgress(DeviceLayer, "PHY update procedure is completed"); + } + break; + case sl_bt_evt_connection_closed_id: { + chip::DeviceLayer::Internal::BLEMgrImpl().HandleConnectionCloseEvent(evt); + } + break; + + /* This event indicates that a remote GATT client is attempting to write a value of an + * attribute in to the local GATT database, where the attribute was defined in the GATT + * XML firmware configuration file to have type="user". */ + case sl_bt_evt_gatt_server_attribute_value_id: { + chip::DeviceLayer::Internal::BLEMgrImpl().HandleWriteEvent(evt); + } + break; + + case sl_bt_evt_gatt_mtu_exchanged_id: { + chip::DeviceLayer::Internal::BLEMgrImpl().UpdateMtu(evt); + } + break; + + // confirmation of indication received from remote GATT client + case sl_bt_evt_gatt_server_characteristic_status_id: { + sl_bt_gatt_server_characteristic_status_flag_t StatusFlags; + + StatusFlags = (sl_bt_gatt_server_characteristic_status_flag_t) evt->data.evt_gatt_server_characteristic_status.status_flags; + + if (sl_bt_gatt_server_confirmation == StatusFlags) + { + chip::DeviceLayer::Internal::BLEMgrImpl().HandleTxConfirmationEvent( + evt->data.evt_gatt_server_characteristic_status.connection); + } + else if ((evt->data.evt_gatt_server_characteristic_status.characteristic == gattdb_CHIPoBLEChar_Tx) && + (evt->data.evt_gatt_server_characteristic_status.status_flags == gatt_server_client_config)) + { + chip::DeviceLayer::Internal::BLEMgrImpl().HandleTXCharCCCDWrite(evt); + } + } + break; + + /* Software Timer event */ + case sl_bt_evt_system_soft_timer_id: { + chip::DeviceLayer::Internal::BLEMgrImpl().HandleSoftTimerEvent(evt); + } + break; + + case sl_bt_evt_gatt_server_user_read_request_id: { + ChipLogProgress(DeviceLayer, "GATT server user_read_request"); +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + if (evt->data.evt_gatt_server_user_read_request.characteristic == gattdb_CHIPoBLEChar_C3) + { + chip::DeviceLayer::Internal::BLEMgrImpl().HandleC3ReadRequest(evt); + } +#endif // CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + } + break; + + case sl_bt_evt_connection_remote_used_features_id: { + // ChipLogProgress(DeviceLayer, "link layer features supported by the remote device"); + } + break; + + default: + ChipLogProgress(DeviceLayer, "evt_UNKNOWN id = %08" PRIx32, SL_BT_MSG_ID(evt->header)); + break; + } + + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); +} + #endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/EFR32/BLEManagerImpl.h b/src/platform/EFR32/BLEManagerImpl.h index 1d557d134f252b..0f1d478f179b61 100644 --- a/src/platform/EFR32/BLEManagerImpl.h +++ b/src/platform/EFR32/BLEManagerImpl.h @@ -42,6 +42,22 @@ using namespace chip::Ble; */ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePlatformDelegate, private BleApplicationDelegate { + +public: + void HandleBootEvent(void); + void HandleConnectEvent(volatile sl_bt_msg_t * evt); + void HandleConnectionCloseEvent(volatile sl_bt_msg_t * evt); + void HandleWriteEvent(volatile sl_bt_msg_t * evt); + void UpdateMtu(volatile sl_bt_msg_t * evt); + void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId); + void HandleTXCharCCCDWrite(volatile sl_bt_msg_t * evt); + void HandleSoftTimerEvent(volatile sl_bt_msg_t * evt); + +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + static void HandleC3ReadRequest(volatile sl_bt_msg_t * evt); +#endif + +private: // Allow the BLEManager interface class to delegate method calls to // the implementation methods provided by this class. friend BLEManager; @@ -137,28 +153,15 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla #if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING CHIP_ERROR EncodeAdditionalDataTlv(); #endif - void UpdateMtu(volatile sl_bt_msg_t * evt); - void HandleBootEvent(void); - void HandleConnectEvent(volatile sl_bt_msg_t * evt); - void HandleConnectionCloseEvent(volatile sl_bt_msg_t * evt); - void HandleWriteEvent(volatile sl_bt_msg_t * evt); - void HandleTXCharCCCDWrite(volatile sl_bt_msg_t * evt); void HandleRXCharWrite(volatile sl_bt_msg_t * evt); - void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId); - void HandleSoftTimerEvent(volatile sl_bt_msg_t * evt); bool RemoveConnection(uint8_t connectionHandle); void AddConnection(uint8_t connectionHandle, uint8_t bondingHandle); void StartBleAdvTimeoutTimer(uint32_t aTimeoutInMs); void CancelBleAdvTimeoutTimer(void); CHIPoBLEConState * GetConnectionState(uint8_t conId, bool allocate = false); static void DriveBLEState(intptr_t arg); - static void bluetoothStackEventHandler(void * p_arg); static void BleAdvTimeoutHandler(TimerHandle_t xTimer); uint8_t GetTimerHandle(uint8_t connectionHandle, bool allocate); - -#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING - static void HandleC3ReadRequest(volatile sl_bt_msg_t * evt); -#endif }; /** diff --git a/src/platform/EFR32/BUILD.gn b/src/platform/EFR32/BUILD.gn index 1b5d6c45bbe3ba..7e82963582d72e 100644 --- a/src/platform/EFR32/BUILD.gn +++ b/src/platform/EFR32/BUILD.gn @@ -57,10 +57,6 @@ static_library("EFR32") { "PlatformManagerImpl.cpp", "PlatformManagerImpl.h", "SystemPlatformConfig.h", - "freertos_bluetooth.c", - "freertos_bluetooth.h", - "gatt_db.c", - "gatt_db.h", ] if (chip_enable_ota_requestor) { diff --git a/src/platform/EFR32/Logging.cpp b/src/platform/EFR32/Logging.cpp index ad0711fe930961..0a3d5025bfa4b9 100644 --- a/src/platform/EFR32/Logging.cpp +++ b/src/platform/EFR32/Logging.cpp @@ -11,6 +11,7 @@ #include #endif +#include "AppConfig.h" #include #include #include @@ -394,4 +395,87 @@ extern "C" __attribute__((naked)) void HardFault_Handler(void) "debugHardfault_address: .word debugHardfault \n"); } +extern "C" void vApplicationMallocFailedHook(void) +{ + /* Called if a call to pvPortMalloc() fails because there is insufficient + free memory available in the FreeRTOS heap. pvPortMalloc() is called + internally by FreeRTOS API functions that create tasks, queues, software + timers, and semaphores. The size of the FreeRTOS heap is set by the + configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */ + + EFR32_LOG("Failed do a malloc on HEAP. Is it too small ?"); + + /* Force an assert. */ + configASSERT((volatile void *) NULL); +} +/*-----------------------------------------------------------*/ + +extern "C" void vApplicationStackOverflowHook(TaskHandle_t pxTask, char * pcTaskName) +{ + //(void) pcTaskName; + (void) pxTask; + + /* Run time stack overflow checking is performed if + configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook + function is called if a stack overflow is detected. */ + EFR32_LOG("TASK OVERFLOW"); + EFR32_LOG(pcTaskName); + /* Force an assert. */ + configASSERT((volatile void *) NULL); +} + +extern "C" void vApplicationTickHook(void) {} + +/*-----------------------------------------------------------*/ + +/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an +implementation of vApplicationGetIdleTaskMemory() to provide the memory that is +used by the Idle task. */ +extern "C" void vApplicationGetIdleTaskMemory(StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, + uint32_t * pulIdleTaskStackSize) +{ + /* If the buffers to be provided to the Idle task are declared inside this + function then they must be declared static - otherwise they will be allocated on + the stack and so not exists after this function exits. */ + static StaticTask_t xIdleTaskTCB; + static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE]; + + /* Pass out a pointer to the StaticTask_t structure in which the Idle task's + state will be stored. */ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + + /* Pass out the array that will be used as the Idle task's stack. */ + *ppxIdleTaskStackBuffer = uxIdleTaskStack; + + /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. + Note that, as the array is necessarily of type StackType_t, + configMINIMAL_STACK_SIZE is specified in words, not bytes. */ + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; +} +/*-----------------------------------------------------------*/ + +/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the +application must provide an implementation of vApplicationGetTimerTaskMemory() +to provide the memory that is used by the Timer service task. */ +extern "C" void vApplicationGetTimerTaskMemory(StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, + uint32_t * pulTimerTaskStackSize) +{ + /* If the buffers to be provided to the Timer task are declared inside this + function then they must be declared static - otherwise they will be allocated on + the stack and so not exists after this function exits. */ + static StaticTask_t xTimerTaskTCB; + static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH]; + + /* Pass out a pointer to the StaticTask_t structure in which the Timer + task's state will be stored. */ + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + + /* Pass out the array that will be used as the Timer task's stack. */ + *ppxTimerTaskStackBuffer = uxTimerTaskStack; + + /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. + Note that, as the array is necessarily of type StackType_t, + configMINIMAL_STACK_SIZE is specified in words, not bytes. */ + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; +} #endif // HARD_FAULT_LOG_ENABLE && EFR32_LOG_ENABLED diff --git a/src/platform/EFR32/btconf/gatt_configuration.btconf b/src/platform/EFR32/btconf/gatt_configuration.btconf deleted file mode 100644 index 060af956d3893b..00000000000000 --- a/src/platform/EFR32/btconf/gatt_configuration.btconf +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - Abstract: The generic_access service contains generic information about the device. All available Characteristics are readonly. - - - - - Empty Example - - - - - - - - - Abstract: The external appearance of this device. The values are composed of a category (10-bits) and sub-categories (6-bits). - 0000 - - - - - - - - - Abstract: The Device Information Service exposes manufacturer and/or vendor information about a device. Summary: This service exposes manufacturer information about a device. The Device Information Service is instantiated as a Primary Service. Only one instance of the Device Information Service is exposed on a device. - - - - Abstract: The value of this characteristic is a UTF-8 string representing the name of the manufacturer of the device. - Silicon Labs - - - - - - - - Abstract: The value of this characteristic is a UTF-8 string representing the model number assigned by the device vendor. - Blue Gecko - - - - - - - - Abstract: The SYSTEM ID characteristic consists of a structure with two fields. The first field are the LSOs and the second field contains the MSOs. This is a 64-bit structure which consists of a 40-bit manufacturer-defined identifier concatenated with a 24 bit unique Organizationally Unique Identifier (OUI). The OUI is issued by the IEEE Registration Authority (http://standards.ieee.org/regauth/index.html) and is required to be used in accordance with IEEE Standard 802-2001.6 while the least significant 40 bits are manufacturer defined. If System ID generated based on a Bluetooth Device Address, it is required to be done as follows. System ID and the Bluetooth Device Address have a very similar structure: a Bluetooth Device Address is 48 bits in length and consists of a 24 bit Company Assigned Identifier (manufacturer defined identifier) concatenated with a 24 bit Company Identifier (OUI). In order to encapsulate a Bluetooth Device Address as System ID, the Company Identifier is concatenated with 0xFFFE followed by the Company Assigned Identifier of the Bluetooth Address. For more guidelines related to EUI-64, refer to http://standards.ieee.org/develop/regauth/tut/eui64.pdf. Examples: If the system ID is based of a Bluetooth Device Address with a Company Identifier (OUI) is 0x123456 and the Company Assigned Identifier is 0x9ABCDE, then the System Identifier is required to be 0x123456FFFE9ABCDE. - 000102030405 - - - - - - - - - Custom service - - - - Custom characteristic - 00 - - - - - - - - - Custom characteristic - 00 - - - - - - - - - - - Custom characteristic (Additional commissioning- related data) - - - - - - - diff --git a/src/platform/EFR32/btconf/in_place_ota_dfu.xml b/src/platform/EFR32/btconf/in_place_ota_dfu.xml deleted file mode 100644 index 28ca5930597228..00000000000000 --- a/src/platform/EFR32/btconf/in_place_ota_dfu.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - Abstract: The Silicon Labs OTA Service enables in-place over-the-air firmware update of the device. - - Abstract: Silicon Labs OTA Control. - - - - - - - \ No newline at end of file diff --git a/src/platform/EFR32/freertos_bluetooth.c b/src/platform/EFR32/freertos_bluetooth.c deleted file mode 100644 index 79562021149448..00000000000000 --- a/src/platform/EFR32/freertos_bluetooth.c +++ /dev/null @@ -1,366 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Google LLC. - * 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. - */ - -#include "AppConfig.h" -#include -#include -#include -#include - -#include "sl_bt_api.h" -#include "sl_bt_ncp_host.h" -#include "sl_status.h" - -#ifdef CONFIGURATION_HEADER -#include CONFIGURATION_HEADER -#endif // CONFIGURATION_HEADER - -void BluetoothUpdate(); -static sl_bt_msg_t ble_evt; -volatile sl_bt_msg_t * bluetooth_evt = &ble_evt; -SemaphoreHandle_t BluetoothMutex = NULL; - -static volatile uint32_t command_header; -static volatile void * command_data; -static volatile sl_bgapi_handler command_handler_func = NULL; - -// Bluetooth task -#ifndef BLUETOOTH_STACK_SIZE -#define BLUETOOTH_STACK_SIZE (1024) -#endif -static void BluetoothTask(void * p_arg); -static TaskHandle_t BluetoothTaskHandle = NULL; - -StackType_t bluetoothStack[BLUETOOTH_STACK_SIZE / sizeof(StackType_t)]; -StaticTask_t bluetoothTaskStruct; - -void sli_bt_cmd_handler_rtos_delegate(uint32_t header, sl_bgapi_handler handler, const void * payload); -extern void sli_bgapi_cmd_handler_delegate(uint32_t header, sl_bgapi_handler, const void *); -extern uint32_t sli_bt_can_sleep_ticks(); - -// Linklayer task -#ifndef LINKLAYER_STACK_SIZE -#define LINKLAYER_STACK_SIZE (1024) -#endif -static void LinklayerTask(void * p_arg); -static TaskHandle_t LinklayerTaskHandle = NULL; -StackType_t linkLayerStack[LINKLAYER_STACK_SIZE / sizeof(StackType_t)]; -StaticTask_t linkLayerTaskStruct; -StaticSemaphore_t bluetoothMutexStruct; -// -#define RTOS_TICK_HZ 1024 -#define BLUETOOTH_TICK_HZ 32768 -#define BLUETOOTH_TO_RTOS_TICK (BLUETOOTH_TICK_HZ / RTOS_TICK_HZ) - -EventGroupHandle_t bluetooth_event_flags; - -sl_status_t bluetooth_start(UBaseType_t ll_priority, UBaseType_t stack_priority, - bluetooth_stack_init_func initialize_bluetooth_stack) -{ - sl_status_t err; - bluetooth_event_flags = xEventGroupCreate(); - configASSERT(bluetooth_event_flags); - - BluetoothMutex = xSemaphoreCreateMutexStatic(&bluetoothMutexStruct); - - err = initialize_bluetooth_stack(); - - if (err == SL_STATUS_OK) - { - // create tasks for Bluetooth host stack - BluetoothTaskHandle = - xTaskCreateStatic(BluetoothTask, /* Function that implements the task. */ - BLE_STACK_TASK_NAME, /* Text name for the task. */ - BLUETOOTH_STACK_SIZE / sizeof(StackType_t), /* Number of indexes in the xStack array. */ - NULL, /* Parameter passed into the task. */ - stack_priority, /* Priority at which the task is created. */ - bluetoothStack, /* Pointer to task heap */ - &bluetoothTaskStruct); /* Variable that holds the task struct */ - - // create tasks for Linklayer - LinklayerTaskHandle = - xTaskCreateStatic(LinklayerTask, /* Function that implements the task. */ - BLE_LINK_TASK_NAME, /* Text name for the task. */ - LINKLAYER_STACK_SIZE / sizeof(StackType_t), /* Number of indexes in the xStack array. */ - NULL, /* Parameter passed into the task. */ - ll_priority, /* Priority at which the task is created. */ - linkLayerStack, /* Pointer to task heap */ - &linkLayerTaskStruct); /* Variable that holds the task struct */ - - if (BluetoothTaskHandle == NULL || LinklayerTaskHandle == NULL) - { - err = SL_STATUS_FAIL; - } - } - - return err; -} - -void BluetoothLLCallback() -{ - vRaiseEventFlagBasedOnContext(bluetooth_event_flags, BLUETOOTH_EVENT_FLAG_LL); -} - -void BluetoothUpdate() -{ - vRaiseEventFlagBasedOnContext(bluetooth_event_flags, BLUETOOTH_EVENT_FLAG_STACK); -} -// Bluetooth task, it waits for events from bluetooth and handles them -void BluetoothTask(void * p) -{ - EventBits_t flags = BLUETOOTH_EVENT_FLAG_EVT_HANDLED | BLUETOOTH_EVENT_FLAG_STACK; - TickType_t xTicksToWait; - - sli_bgapi_set_cmd_handler_delegate(sli_bt_cmd_handler_rtos_delegate); - - while (1) - { - // Command needs to be sent to Bluetooth stack - if (flags & BLUETOOTH_EVENT_FLAG_CMD_WAITING) - { - uint32_t header = command_header; - sl_bgapi_handler cmd_handler = command_handler_func; - sli_bgapi_cmd_handler_delegate(header, cmd_handler, (void *) command_data); - command_handler_func = NULL; - flags &= ~BLUETOOTH_EVENT_FLAG_CMD_WAITING; - vRaiseEventFlagBasedOnContext(bluetooth_event_flags, BLUETOOTH_EVENT_FLAG_RSP_WAITING); - } - - // Run Bluetooth stack. Pop the next event for application - sl_bt_run(); - // Bluetooth stack needs updating, and evt can be used - if (sl_bt_event_pending() && (flags & BLUETOOTH_EVENT_FLAG_EVT_HANDLED)) - { // update bluetooth & read event - sl_status_t status = sl_bt_pop_event((sl_bt_msg_t *) bluetooth_evt); - if (SL_STATUS_OK != status) - { - continue; - } - flags &= ~BLUETOOTH_EVENT_FLAG_EVT_HANDLED; - vRaiseEventFlagBasedOnContext(bluetooth_event_flags, BLUETOOTH_EVENT_FLAG_EVT_WAITING); - } - - xTicksToWait = sli_bt_can_sleep_ticks(); - if (xTicksToWait == 0 && (flags & BLUETOOTH_EVENT_FLAG_EVT_HANDLED)) - { - flags |= BLUETOOTH_EVENT_FLAG_STACK; - continue; - } - flags |= xEventGroupWaitBits(bluetooth_event_flags, /* The event group being tested. */ - (BLUETOOTH_EVENT_FLAG_STACK + BLUETOOTH_EVENT_FLAG_EVT_HANDLED + - BLUETOOTH_EVENT_FLAG_CMD_WAITING), /* The bits within the event group to wait for. */ - pdTRUE, /* BLUETOOTH_EVENT_FLAG_LL should be cleared before returning. */ - pdFALSE, /* Wait for all the bits to be set, not needed for single bit. */ - portMAX_DELAY); /* Wait for maximum duration for bit to be set. With 1 ms tick, - portMAX_DELAY will result in wait of 50 days*/ - if (((flags & BLUETOOTH_EVENT_FLAG_STACK) == 0) && ((flags & BLUETOOTH_EVENT_FLAG_EVT_HANDLED) == 0) && - ((flags & BLUETOOTH_EVENT_FLAG_CMD_WAITING) == 0)) - { - // timeout occurred, set the flag to update the Bluetooth stack - flags |= BLUETOOTH_EVENT_FLAG_STACK; - } - } -} - -static void LinklayerTask(void * p_arg) -{ - (void) p_arg; - - while (1) - { - EventBits_t uxBits; - - uxBits = xEventGroupWaitBits(bluetooth_event_flags, /* The event group being tested. */ - BLUETOOTH_EVENT_FLAG_LL, /* The bits within the event group to wait for. */ - pdTRUE, /* BLUETOOTH_EVENT_FLAG_LL should be cleared before returning. */ - pdTRUE, /* Wait for all the bits to be set, not needed for single bit. */ - portMAX_DELAY); /* Wait for maximum duration for bit to be set. With 1 ms tick, - portMAX_DELAY will result in wait of 50 days*/ - - if (uxBits & BLUETOOTH_EVENT_FLAG_LL) - { - sl_bt_priority_handle(); - } - } -} - -// hooks for API -// called from tasks using BGAPI -void sli_bt_cmd_handler_rtos_delegate(uint32_t header, sl_bgapi_handler handler, const void * payload) -{ - EventBits_t uxBits; - - command_header = header; - command_handler_func = handler; - command_data = (void *) payload; - // Command structure is filled, notify the stack - vRaiseEventFlagBasedOnContext(bluetooth_event_flags, BLUETOOTH_EVENT_FLAG_CMD_WAITING); - - // wait for response - uxBits = xEventGroupWaitBits(bluetooth_event_flags, /* The event group being tested. */ - BLUETOOTH_EVENT_FLAG_RSP_WAITING, /* The bits within the event group to wait for. */ - pdTRUE, /* BLUETOOTH_EVENT_FLAG_LL should be cleared before returning. */ - pdTRUE, /* Wait for all the bits to be set, not needed for single bit. */ - portMAX_DELAY); /* Wait for maximum duration for bit to be set. With 1 ms tick, - portMAX_DELAY will result in wait of 50 days*/ - (void) uxBits; -} - -void BluetoothPend(void) -{ - xSemaphoreTake(BluetoothMutex, portMAX_DELAY); -} -void BluetoothPost(void) -{ - xSemaphoreGive(BluetoothMutex); -} - -void vApplicationMallocFailedHook(void) -{ - /* Called if a call to pvPortMalloc() fails because there is insufficient - free memory available in the FreeRTOS heap. pvPortMalloc() is called - internally by FreeRTOS API functions that create tasks, queues, software - timers, and semaphores. The size of the FreeRTOS heap is set by the - configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */ - - EFR32_LOG("Failed do a malloc on HEAP. Is it too small ?"); - - /* Force an assert. */ - configASSERT((volatile void *) NULL); -} -/*-----------------------------------------------------------*/ - -void vApplicationStackOverflowHook(TaskHandle_t pxTask, char * pcTaskName) -{ - //(void) pcTaskName; - (void) pxTask; - - /* Run time stack overflow checking is performed if - configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook - function is called if a stack overflow is detected. */ - EFR32_LOG("TASK OVERFLOW"); - EFR32_LOG(pcTaskName); - /* Force an assert. */ - configASSERT((volatile void *) NULL); -} - -void vApplicationTickHook(void) {} - -/*-----------------------------------------------------------*/ - -/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an -implementation of vApplicationGetIdleTaskMemory() to provide the memory that is -used by the Idle task. */ -void vApplicationGetIdleTaskMemory(StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, - uint32_t * pulIdleTaskStackSize) -{ - /* If the buffers to be provided to the Idle task are declared inside this - function then they must be declared static - otherwise they will be allocated on - the stack and so not exists after this function exits. */ - static StaticTask_t xIdleTaskTCB; - static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE]; - - /* Pass out a pointer to the StaticTask_t structure in which the Idle task's - state will be stored. */ - *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; - - /* Pass out the array that will be used as the Idle task's stack. */ - *ppxIdleTaskStackBuffer = uxIdleTaskStack; - - /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. - Note that, as the array is necessarily of type StackType_t, - configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; -} -/*-----------------------------------------------------------*/ - -/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the -application must provide an implementation of vApplicationGetTimerTaskMemory() -to provide the memory that is used by the Timer service task. */ -void vApplicationGetTimerTaskMemory(StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, - uint32_t * pulTimerTaskStackSize) -{ - /* If the buffers to be provided to the Timer task are declared inside this - function then they must be declared static - otherwise they will be allocated on - the stack and so not exists after this function exits. */ - static StaticTask_t xTimerTaskTCB; - static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH]; - - /* Pass out a pointer to the StaticTask_t structure in which the Timer - task's state will be stored. */ - *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; - - /* Pass out the array that will be used as the Timer task's stack. */ - *ppxTimerTaskStackBuffer = uxTimerTaskStack; - - /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. - Note that, as the array is necessarily of type StackType_t, - configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; -} - -void vRaiseEventFlagBasedOnContext(EventGroupHandle_t xEventGroup, EventBits_t uxBitsToWaitFor) -{ - EventBits_t eventBits; - BaseType_t eventBitsFromISRStatus; - BaseType_t higherPrioTaskWoken = pdFALSE; - - if (xPortIsInsideInterrupt()) - { - eventBitsFromISRStatus = xEventGroupSetBitsFromISR(xEventGroup, uxBitsToWaitFor, &higherPrioTaskWoken); - if (eventBitsFromISRStatus != pdFAIL) - { -#ifdef portYIELD_FROM_ISR - portYIELD_FROM_ISR(higherPrioTaskWoken); -#elif portEND_SWITCHING_ISR // portYIELD_FROM_ISR or portEND_SWITCHING_ISR - portEND_SWITCHING_ISR(higherPrioTaskWoken); -#else // portYIELD_FROM_ISR or portEND_SWITCHING_ISR -#error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR" -#endif // portYIELD_FROM_ISR or portEND_SWITCHING_ISR - } - } - else - { - eventBits = xEventGroupSetBits(xEventGroup, uxBitsToWaitFor); - (void) eventBits; - } -} - -BaseType_t vSendToQueueBasedOnContext(QueueHandle_t xQueue, void * xItemToQueue, TickType_t xTicksToWait, - BaseType_t * pxHigherPriorityTaskWoken) -{ - BaseType_t status; - BaseType_t higherPrioTaskWoken = pdFALSE; - - if (xPortIsInsideInterrupt()) - { - status = xQueueSendFromISR(xQueue, xItemToQueue, &higherPrioTaskWoken); - } - else - { - status = xQueueSend(xQueue, xItemToQueue, xTicksToWait); - } - - if (pxHigherPriorityTaskWoken != NULL) - { - *pxHigherPriorityTaskWoken = higherPrioTaskWoken; - } - - return status; -} diff --git a/src/platform/EFR32/freertos_bluetooth.h b/src/platform/EFR32/freertos_bluetooth.h deleted file mode 100644 index 862b71550ec9f8..00000000000000 --- a/src/platform/EFR32/freertos_bluetooth.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Google LLC. - * 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. - */ - -#pragma once - -#if __cplusplus -extern "C" { -#endif - -#include "FreeRTOS.h" -#include "event_groups.h" -#include "semphr.h" -#include "task.h" -#include "timers.h" - -#include "sl_bt_api.h" - -#define BLE_STACK_TASK_NAME "BLE_STACK" -#define BLE_LINK_TASK_NAME "BLE_LINK" - -// Bluetooth event flag group -extern EventGroupHandle_t bluetooth_event_flags; -// Bluetooth event flag definitions -#define BLUETOOTH_EVENT_FLAG_STACK (0x01u) // Bluetooth task needs an update -#define BLUETOOTH_EVENT_FLAG_LL (0x02u) // Linklayer task needs an update -#define BLUETOOTH_EVENT_FLAG_CMD_WAITING (0x04u) // BGAPI command is waiting to be processed -#define BLUETOOTH_EVENT_FLAG_RSP_WAITING (0x08u) // BGAPI response is waiting to be processed -#define BLUETOOTH_EVENT_FLAG_EVT_WAITING (0x10u) // BGAPI event is waiting to be processed -#define BLUETOOTH_EVENT_FLAG_EVT_HANDLED (0x20u) // BGAPI event is handled - -// Bluetooth event data pointer -extern volatile sl_bt_msg_t * bluetooth_evt; - -// Function prototype for initializing Bluetooth stack. -typedef sl_status_t (*bluetooth_stack_init_func)(); - -/** - * Start Bluetooth tasks. The given Bluetooth stack initialization function - * will be called at a proper time. Application should not initialize - * Bluetooth stack anywhere else. - * - * @param ll_priority link layer task priority - * @param stack_priority Bluetooth stack task priority - * @param initialize_bluetooth_stack The function for initializing Bluetooth stack - */ -sl_status_t bluetooth_start(UBaseType_t ll_priority, UBaseType_t stack_priority, - bluetooth_stack_init_func initialize_bluetooth_stack); - -// Set the callback for wakeup, Bluetooth task will call this when it has a new event -// It must only used to wake up application task, for example by posting task semaphore -typedef void (*wakeupCallback)(void); -void BluetoothSetWakeupCallback(wakeupCallback cb); -// Bluetooth stack needs an update -extern void BluetoothUpdate(void); -// Linklayer is updated -extern void BluetoothLLCallback(void); - -// Mutex functions for using Bluetooth from multiple tasks -void BluetoothPend(void); -void BluetoothPost(void); - -void vRaiseEventFlagBasedOnContext(EventGroupHandle_t xEventGroup, EventBits_t uxBitsToWaitFor); -BaseType_t vSendToQueueBasedOnContext(QueueHandle_t xQueue, void * xItemToQueue, TickType_t xTicksToWait, - BaseType_t * pxHigherPriorityTaskWoken); - -#if __cplusplus -} -#endif diff --git a/src/platform/EFR32/gatt_db.c b/src/platform/EFR32/gatt_db.c deleted file mode 100644 index 110b069e2c23d7..00000000000000 --- a/src/platform/EFR32/gatt_db.c +++ /dev/null @@ -1,410 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Google LLC. - * - * 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. - */ - -/******************************************************************** - * Autogenerated file, do not edit. - *******************************************************************/ - -#include "sli_bt_gattdb_def.h" -#include - -#define GATT_HEADER(F) F -#define GATT_DATA(F) F -GATT_DATA(const uint16_t gattdb_uuidtable_16_map[]) = { - 0x2800, 0x2801, 0x2803, 0x2a00, 0x2a01, 0x2a29, 0x2a24, 0x2a23, 0x2a05, 0x2b2a, 0x2b29, 0x2902, -}; - -GATT_DATA(const uint8_t gattdb_uuidtable_128_map[]) = { - 0x11, 0x9d, 0x9f, 0x42, 0x9c, 0x4f, 0x9f, 0x95, 0x59, 0x45, 0x3d, 0x26, 0xf5, 0x2e, 0xee, 0x18, - 0x12, 0x9d, 0x9f, 0x42, 0x9c, 0x4f, 0x9f, 0x95, 0x59, 0x45, 0x3d, 0x26, 0xf5, 0x2e, 0xee, 0x18, - 0x04, 0x8f, 0x21, 0x83, 0x8a, 0x74, 0x7d, 0xb8, 0xf2, 0x45, 0x72, 0x87, 0x38, 0x02, 0x63, 0x64, - 0x63, 0x60, 0x32, 0xe0, 0x37, 0x5e, 0xa4, 0x88, 0x53, 0x4e, 0x6d, 0xfb, 0x64, 0x35, 0xbf, 0xf7, -}; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_28) = { .len = 16, - .data = { - 0xf0, - 0x19, - 0x21, - 0xb4, - 0x47, - 0x8f, - 0xa4, - 0xbf, - 0xa1, - 0x4f, - 0x63, - 0xfd, - 0xee, - 0xd6, - 0x14, - 0x1d, - } }; -GATT_DATA(sli_bt_gattdb_attribute_chrvalue_t - gattdb_attribute_field_24) = { .properties = 0x2e, - .max_len = 247, - .len = 1, - .data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - } }; -GATT_DATA(sli_bt_gattdb_attribute_chrvalue_t - gattdb_attribute_field_22) = { .properties = 0x0a, - .max_len = 247, - .len = 1, - .data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - } }; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_20) = { .len = 2, - .data = { - 0xf6, - 0xff, - } }; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_19) = { .len = 6, - .data = { - 0x00, - 0x01, - 0x02, - 0x03, - 0x04, - 0x05, - } }; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_17) = { .len = 10, - .data = { - 0x42, - 0x6c, - 0x75, - 0x65, - 0x20, - 0x47, - 0x65, - 0x63, - 0x6b, - 0x6f, - } }; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_15) = { .len = 12, - .data = { - 0x53, - 0x69, - 0x6c, - 0x69, - 0x63, - 0x6f, - 0x6e, - 0x20, - 0x4c, - 0x61, - 0x62, - 0x73, - } }; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_13) = { .len = 2, - .data = { - 0x0a, - 0x18, - } }; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_12) = { .len = 2, - .data = { - 0x00, - 0x00, - } }; -GATT_DATA(sli_bt_gattdb_attribute_chrvalue_t gattdb_attribute_field_10) = { - .properties = 0x0a, - .max_len = 13, - .data = { 0x45, 0x6d, 0x70, 0x74, 0x79, 0x20, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, }, -}; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_8) = { .len = 2, - .data = { - 0x00, - 0x18, - } }; -GATT_DATA(sli_bt_gattdb_attribute_chrvalue_t gattdb_attribute_field_7) = { - .properties = 0x0a, - .max_len = 1, - .data = { 0x00, }, -}; -GATT_DATA(sli_bt_gattdb_attribute_chrvalue_t gattdb_attribute_field_5) = { - .properties = 0x02, - .max_len = 16, - .data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, -}; -GATT_DATA(sli_bt_gattdb_attribute_chrvalue_t gattdb_attribute_field_2) = { - .properties = 0x20, - .max_len = 4, - .data = { 0x00, 0x00, 0x00, 0x00, }, -}; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_0) = { .len = 2, - .data = { - 0x01, - 0x18, - } }; - -GATT_DATA(const sli_bt_gattdb_attribute_t gattdb_attributes_map[]) = { - { .handle = 0x01, - .uuid = 0x0000, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_0 }, - { .handle = 0x02, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x20, .char_uuid = 0x0008 } }, - { .handle = 0x03, - .uuid = 0x0008, - .permissions = 0x800, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x01, - .dynamicdata = &gattdb_attribute_field_2 }, - { .handle = 0x04, - .uuid = 0x000b, - .permissions = 0x803, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x03, - .configdata = { .flags = 0x02, .clientconfig_index = 0x00 } }, - { .handle = 0x05, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x02, .char_uuid = 0x0009 } }, - { .handle = 0x06, - .uuid = 0x0009, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x01, - .dynamicdata = &gattdb_attribute_field_5 }, - { .handle = 0x07, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x0a, .char_uuid = 0x000a } }, - { .handle = 0x08, - .uuid = 0x000a, - .permissions = 0x803, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x01, - .dynamicdata = &gattdb_attribute_field_7 }, - { .handle = 0x09, - .uuid = 0x0000, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_8 }, - { .handle = 0x0a, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x0a, .char_uuid = 0x0003 } }, - { .handle = 0x0b, - .uuid = 0x0003, - .permissions = 0x803, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x01, - .dynamicdata = &gattdb_attribute_field_10 }, - { .handle = 0x0c, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x02, .char_uuid = 0x0004 } }, - { .handle = 0x0d, - .uuid = 0x0004, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_12 }, - { .handle = 0x0e, - .uuid = 0x0000, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_13 }, - { .handle = 0x0f, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x02, .char_uuid = 0x0005 } }, - { .handle = 0x10, - .uuid = 0x0005, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_15 }, - { .handle = 0x11, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x02, .char_uuid = 0x0006 } }, - { .handle = 0x12, - .uuid = 0x0006, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_17 }, - { .handle = 0x13, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x02, .char_uuid = 0x0007 } }, - { .handle = 0x14, - .uuid = 0x0007, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_19 }, - { .handle = 0x15, - .uuid = 0x0000, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_20 }, - { .handle = 0x16, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x0a, .char_uuid = 0x8000 } }, - { .handle = 0x17, - .uuid = 0x8000, - .permissions = 0x803, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x02, - .dynamicdata = &gattdb_attribute_field_22 }, - { .handle = 0x18, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x2e, .char_uuid = 0x8001 } }, - { .handle = 0x19, - .uuid = 0x8001, - .permissions = 0x807, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x02, - .dynamicdata = &gattdb_attribute_field_24 }, - { .handle = 0x1a, - .uuid = 0x000b, - .permissions = 0x803, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x03, - .configdata = { .flags = 0x02, .clientconfig_index = 0x01 } }, - { .handle = 0x1b, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x02, .char_uuid = 0x8002 } }, - { .handle = 0x1c, .uuid = 0x8002, .permissions = 0x801, .caps = 0xffff, .state = 0x00, .datatype = 0x07, .dynamicdata = NULL }, - { .handle = 0x1d, - .uuid = 0x0000, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_28 }, - { .handle = 0x1e, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x08, .char_uuid = 0x8003 } }, - { .handle = 0x1f, .uuid = 0x8003, .permissions = 0x802, .caps = 0xffff, .state = 0x00, .datatype = 0x07, .dynamicdata = NULL }, -}; - -GATT_HEADER(const sli_bt_gattdb_t gattdb) = { - .attributes = gattdb_attributes_map, - .attribute_table_size = 31, - .attribute_num = 31, - .uuid16 = gattdb_uuidtable_16_map, - .uuid16_table_size = 12, - .uuid16_num = 12, - .uuid128 = gattdb_uuidtable_128_map, - .uuid128_table_size = 4, - .uuid128_num = 4, - .num_ccfg = 2, - .caps_mask = 0xffff, - .enabled_caps = 0xffff, -}; -const sli_bt_gattdb_t * static_gattdb = &gattdb; diff --git a/src/platform/EFR32/gatt_db.h b/src/platform/EFR32/gatt_db.h deleted file mode 100644 index e059feda15f0ed..00000000000000 --- a/src/platform/EFR32/gatt_db.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Google LLC. - * - * 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. - */ - -/******************************************************************** - * Autogenerated file, do not edit. - *******************************************************************/ - -#ifndef __GATT_DB_H -#define __GATT_DB_H - -#if __cplusplus -extern "C" { -#endif - -#include "sli_bt_gattdb_def.h" - -extern const sli_bt_gattdb_t gattdb; - -#define gattdb_generic_attribute 1 -#define gattdb_service_changed_char 3 -#define gattdb_database_hash 6 -#define gattdb_client_support_features 8 -#define gattdb_device_name 11 -#define gattdb_CHIPoBLEChar_Rx 23 -#define gattdb_CHIPoBLEChar_Tx 25 -#define gattdb_CHIPoBLEChar_C3 28 -#define gattdb_ota 29 -#define gattdb_ota_control 31 - -#if __cplusplus -} -#endif - -#endif // __GATT_DB_H diff --git a/src/platform/ESP32/DiagnosticDataProviderImpl.cpp b/src/platform/ESP32/DiagnosticDataProviderImpl.cpp index a80999f5f03ad1..6dc68280c6dd71 100644 --- a/src/platform/ESP32/DiagnosticDataProviderImpl.cpp +++ b/src/platform/ESP32/DiagnosticDataProviderImpl.cpp @@ -34,7 +34,11 @@ #include "esp_heap_caps_init.h" #include "esp_log.h" #include "esp_netif.h" +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) +#include "spi_flash_mmap.h" +#else #include "esp_spi_flash.h" +#endif #include "esp_system.h" #include "esp_wifi.h" diff --git a/src/platform/ESP32/PlatformManagerImpl.cpp b/src/platform/ESP32/PlatformManagerImpl.cpp index 10f9554477bf13..074750654c2360 100644 --- a/src/platform/ESP32/PlatformManagerImpl.cpp +++ b/src/platform/ESP32/PlatformManagerImpl.cpp @@ -37,7 +37,11 @@ #include "esp_heap_caps_init.h" #include "esp_log.h" #include "esp_netif.h" +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) +#include "spi_flash_mmap.h" +#else #include "esp_spi_flash.h" +#endif #include "esp_system.h" #include "esp_wifi.h" diff --git a/src/platform/ESP32/nimble/BLEManagerImpl.cpp b/src/platform/ESP32/nimble/BLEManagerImpl.cpp index fe3c707685b1ca..ea4f5c1de99d32 100644 --- a/src/platform/ESP32/nimble/BLEManagerImpl.cpp +++ b/src/platform/ESP32/nimble/BLEManagerImpl.cpp @@ -140,6 +140,22 @@ const struct ble_gatt_svc_def BLEManagerImpl::CHIPoBLEGATTAttrs[] = { CHIP_ERROR BLEManagerImpl::_Init() { +#if CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + if (ConnectivityMgr().IsThreadProvisioned()) + { + ESP_LOGI(TAG, "Thread credentials already provisioned, not initializing BLE"); + return CHIP_NO_ERROR; + } +#else + if (ConnectivityMgr().IsWiFiStationProvisioned()) + { + ESP_LOGI(TAG, "WiFi station already provisioned, not initializing BLE"); + return CHIP_NO_ERROR; + } +#endif /* CHIP_DEVICE_CONFIG_ENABLE_THREAD */ +#endif /* CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING */ + CHIP_ERROR err; // Initialize the Chip BleLayer. @@ -1177,8 +1193,8 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) adv_params.itvl_max = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX; } - ChipLogProgress(DeviceLayer, "Configuring CHIPoBLE advertising (interval %" PRIu32 " ms, %sconnectable, device name %s)", - (((uint32_t) adv_params.itvl_min) * 10) / 16, (connectable) ? "" : "non-", mDeviceName); + ChipLogProgress(DeviceLayer, "Configuring CHIPoBLE advertising (interval %" PRIu32 " ms, %sconnectable)", + (((uint32_t) adv_params.itvl_min) * 10) / 16, (connectable) ? "" : "non-"); { if (ble_gap_adv_active()) diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index ee522b39c795a7..449527de2ee611 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -1549,6 +1549,14 @@ bool ConnectivityManagerImpl::_GetBssInfo(const gchar * bssPath, NetworkCommissi std::unique_ptr ssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "SSID")); std::unique_ptr bssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "BSSID")); + // Network scan is performed in the background, so the BSS + // may be gone when we try to get the properties. + if (ssid == nullptr || bssid == nullptr) + { + ChipLogDetail(DeviceLayer, "wpa_supplicant: BSS not found: %s", bssPath); + return false; + } + const guchar * ssidStr = nullptr; const guchar * bssidBuf = nullptr; char bssidStr[2 * 6 + 5 + 1] = { 0 }; diff --git a/src/platform/Linux/bluez/Helper.cpp b/src/platform/Linux/bluez/Helper.cpp index 1337c4e69a1003..f65dbde49862f8 100644 --- a/src/platform/Linux/bluez/Helper.cpp +++ b/src/platform/Linux/bluez/Helper.cpp @@ -401,7 +401,17 @@ static gboolean BluezCharacteristicWriteFD(GIOChannel * aChannel, GIOCondition a isSuccess = true; exit: - return isSuccess ? TRUE : FALSE; + if (!isSuccess && (conn != nullptr)) + { + // Returning G_SOURCE_REMOVE from the source callback removes the source object + // from the context. Unset self source ID tag, so we will not call g_source_remove() + // in BluezOTConnectionDestroy() on already removed source. + // + // TODO: Investigate whether there is a batter way to handle this. + conn->mC1Channel.mWatch = 0; + } + + return isSuccess ? G_SOURCE_CONTINUE : G_SOURCE_REMOVE; } static void Bluez_gatt_characteristic1_complete_acquire_write_with_fd(GDBusMethodInvocation * invocation, int fd, guint16 mtu) @@ -417,6 +427,13 @@ static void Bluez_gatt_characteristic1_complete_acquire_write_with_fd(GDBusMetho static gboolean bluezCharacteristicDestroyFD(GIOChannel * aChannel, GIOCondition aCond, gpointer apClosure) { + BluezConnection * conn = static_cast(apClosure); + // Returning G_SOURCE_REMOVE from the source callback removes the source object + // from the context. Unset self source ID tag, so we will not call g_source_remove() + // in BluezOTConnectionDestroy() on already removed source. + // + // TODO: Investigate whether there is a batter way to handle this. + conn->mC2Channel.mWatch = 0; return G_SOURCE_REMOVE; } diff --git a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp index 6fac30482f6251..1eb24394f27be7 100644 --- a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp @@ -28,13 +28,13 @@ #include #include -#include -#include +#include +#include #if CHIP_DEVICE_LAYER_TARGET_NRFCONNECT #include #elif defined(CONFIG_MCUBOOT_IMG_MANAGER) -#include +#include #endif #include diff --git a/src/platform/Zephyr/KeyValueStoreManagerImpl.cpp b/src/platform/Zephyr/KeyValueStoreManagerImpl.cpp index da254e615263bc..d99239b20c726c 100644 --- a/src/platform/Zephyr/KeyValueStoreManagerImpl.cpp +++ b/src/platform/Zephyr/KeyValueStoreManagerImpl.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include namespace chip { namespace DeviceLayer { diff --git a/src/platform/Zephyr/KeyValueStoreManagerImpl.h b/src/platform/Zephyr/KeyValueStoreManagerImpl.h index daaba1144b497a..1d4ee7d1f10fbf 100644 --- a/src/platform/Zephyr/KeyValueStoreManagerImpl.h +++ b/src/platform/Zephyr/KeyValueStoreManagerImpl.h @@ -24,7 +24,7 @@ #pragma once -#include +#include namespace chip { namespace DeviceLayer { diff --git a/src/platform/Zephyr/Logging.cpp b/src/platform/Zephyr/Logging.cpp index f65a5bbf472d33..f8e2015d415367 100644 --- a/src/platform/Zephyr/Logging.cpp +++ b/src/platform/Zephyr/Logging.cpp @@ -6,9 +6,9 @@ #include #include -#include -#include -#include +#include +#include +#include // If CONFIG_LOG_MODE_MINIMAL the timestamp is NOT added automatically by the Zephyr logger #ifdef CONFIG_LOG_MODE_MINIMAL diff --git a/src/platform/Zephyr/PlatformManagerImpl.cpp b/src/platform/Zephyr/PlatformManagerImpl.cpp index 53053b5eae74f7..6cd42773227ed2 100644 --- a/src/platform/Zephyr/PlatformManagerImpl.cpp +++ b/src/platform/Zephyr/PlatformManagerImpl.cpp @@ -32,8 +32,8 @@ #include #include -#include #include +#include namespace chip { namespace DeviceLayer { diff --git a/src/platform/Zephyr/SystemTimeSupport.cpp b/src/platform/Zephyr/SystemTimeSupport.cpp index 08d8408bd8aa38..90b63aded60b08 100644 --- a/src/platform/Zephyr/SystemTimeSupport.cpp +++ b/src/platform/Zephyr/SystemTimeSupport.cpp @@ -26,7 +26,7 @@ #include -#include +#include #if !CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS diff --git a/src/platform/Zephyr/ThreadStackManagerImpl.h b/src/platform/Zephyr/ThreadStackManagerImpl.h index 19e5d7ecc643dc..6600554a1966bd 100644 --- a/src/platform/Zephyr/ThreadStackManagerImpl.h +++ b/src/platform/Zephyr/ThreadStackManagerImpl.h @@ -25,8 +25,8 @@ #include -#include -#include +#include +#include #include #if !CONFIG_SOC_SERIES_RISCV_TELINK_B91 diff --git a/src/platform/Zephyr/ZephyrConfig.cpp b/src/platform/Zephyr/ZephyrConfig.cpp index 60a17788a3cff0..f548e95bca09a7 100644 --- a/src/platform/Zephyr/ZephyrConfig.cpp +++ b/src/platform/Zephyr/ZephyrConfig.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include namespace chip { namespace DeviceLayer { diff --git a/src/platform/nxp/k32w/common/RamStorage.cpp b/src/platform/nxp/k32w/common/RamStorage.cpp new file mode 100644 index 00000000000000..716fc8dbec20b0 --- /dev/null +++ b/src/platform/nxp/k32w/common/RamStorage.cpp @@ -0,0 +1,102 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +#include + +#include + +namespace chip::DeviceLayer::Internal { + +RamStorage::Buffer RamStorage::sBuffer = nullptr; + +CHIP_ERROR RamStorage::Init(uint16_t aNvmId, uint16_t aInitialSize) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + sBuffer = getRamBuffer(aNvmId, aInitialSize); + if (!sBuffer) + { + err = CHIP_ERROR_NO_MEMORY; + } + + return err; +} + +void RamStorage::FreeBuffer() +{ + if (sBuffer) + { + free(sBuffer); + sBuffer = nullptr; + } +} + +CHIP_ERROR RamStorage::Read(uint16_t aKey, int aIndex, uint8_t * aValue, uint16_t * aValueLength) +{ + CHIP_ERROR err; + rsError status; + + status = ramStorageGet(sBuffer, aKey, aIndex, aValue, aValueLength); + SuccessOrExit(err = MapStatusToChipError(status)); + +exit: + return err; +} + +CHIP_ERROR RamStorage::Write(uint16_t aKey, const uint8_t * aValue, uint16_t aValueLength) +{ + CHIP_ERROR err; + rsError status = RS_ERROR_NONE; + + // Delete all occurrences of "key" and resize buffer if needed + // before scheduling writing of new value. + ramStorageDelete(sBuffer, aKey, -1); + status = ramStorageResize(&sBuffer, aKey, aValue, aValueLength); + SuccessOrExit(err = MapStatusToChipError(status)); + status = ramStorageSet(sBuffer, aKey, aValue, aValueLength); + SuccessOrExit(err = MapStatusToChipError(status)); + +exit: + return err; +} + +CHIP_ERROR RamStorage::Delete(uint16_t aKey, int aIndex) +{ + rsError status = ramStorageDelete(sBuffer, aKey, aIndex); + return MapStatusToChipError(status); +} + +CHIP_ERROR RamStorage::MapStatusToChipError(rsError rsStatus) +{ + CHIP_ERROR err; + + switch (rsStatus) + { + case RS_ERROR_NONE: + err = CHIP_NO_ERROR; + break; + case RS_ERROR_NOT_FOUND: + err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; + break; + default: + err = CHIP_ERROR_BUFFER_TOO_SMALL; + break; + } + + return err; +} + +} // namespace chip::DeviceLayer::Internal diff --git a/src/platform/nxp/k32w/common/RamStorage.h b/src/platform/nxp/k32w/common/RamStorage.h new file mode 100644 index 00000000000000..414db35d61d878 --- /dev/null +++ b/src/platform/nxp/k32w/common/RamStorage.h @@ -0,0 +1,54 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +#pragma once + +#include + +#include "pdm_ram_storage_glue.h" +#include "ram_storage.h" + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +/** + * + * All ram storage operations should be managed by this class. + */ +class RamStorage +{ +public: + using Buffer = ramBufferDescriptor *; + + static CHIP_ERROR Init(uint16_t aNvmId, uint16_t aInitialSize); + static void FreeBuffer(); + static Buffer GetBuffer() { return sBuffer; } + + static CHIP_ERROR Read(uint16_t aKey, int aIndex, uint8_t * aValue, uint16_t * aValueLength); + static CHIP_ERROR Write(uint16_t aKey, const uint8_t * aValue, uint16_t aValueLength); + static CHIP_ERROR Delete(uint16_t aKey, int aIndex); + +private: + static CHIP_ERROR MapStatusToChipError(rsError rsStatus); + + static Buffer sBuffer; +}; + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/BLEManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/BLEManagerImpl.cpp index 7ef69ae8b36947..e0728be466351b 100644 --- a/src/platform/nxp/k32w/k32w0/BLEManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/BLEManagerImpl.cpp @@ -835,7 +835,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) advInterval = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX; } - adv_params.minInterval = adv_params.maxInterval = advInterval; + adv_params.minInterval = adv_params.maxInterval = (uint16_t)(advInterval / 0.625F); adv_params.advertisingType = gAdvConnectableUndirected_c; adv_params.ownAddressType = gBleAddrTypePublic_c; adv_params.peerAddressType = gBleAddrTypePublic_c; @@ -846,11 +846,11 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) err = blekw_start_advertising(&adv_params, &adv, &scanRsp); if (err == BLE_OK) { - ChipLogProgress(DeviceLayer, "Started Advertising."); + ChipLogProgress(DeviceLayer, "Started Advertising at %d ms", advInterval); } else { - ChipLogProgress(DeviceLayer, "Advertising error!"); + ChipLogProgress(DeviceLayer, "Advertising error 0x%x!", err); return CHIP_ERROR_INCORRECT_STATE; } @@ -964,8 +964,6 @@ void BLEManagerImpl::bleAppTask(void * p_arg) { xEventGroupWaitBits(bleAppTaskLoopEvent, LOOP_EV_BLE, true, false, portMAX_DELAY); - PlatformMgr().LockChipStack(); - if (MSG_Pending(&blekw_msg_list)) { /* There is message from the BLE tasks to solve */ @@ -975,7 +973,16 @@ void BLEManagerImpl::bleAppTask(void * p_arg) if (msg->type == BLE_KW_MSG_ERROR) { - ChipLogProgress(DeviceLayer, "BLE Error: %d.\n", msg->data.u8); + if (msg->data.u8 == BLE_KW_MSG_2M_UPGRADE_ERROR) + { + ChipLogProgress(DeviceLayer, + "Warning. BLE is using 1Mbps. Couldn't upgrade to 2Mbps, " + "maybe the peer is missing 2Mbps support."); + } + else + { + ChipLogProgress(DeviceLayer, "BLE Error: %d.\n", msg->data.u8); + } } else if (msg->type == BLE_KW_MSG_CONNECTED) { @@ -1009,7 +1016,6 @@ void BLEManagerImpl::bleAppTask(void * p_arg) /* Freed the message from the queue */ MSG_Free(msg); } - PlatformMgr().UnlockChipStack(); } } @@ -1181,7 +1187,15 @@ void BLEManagerImpl::blekw_generic_cb(gapGenericEvent_t * pGenericEvent) ChipLogProgress(DeviceLayer, "BLE Internal Error: Code 0x%04X, Source 0x%08X, HCI OpCode %d.\n", pGenericEvent->eventData.internalError.errorCode, pGenericEvent->eventData.internalError.errorSource, pGenericEvent->eventData.internalError.hciCommandOpcode); - (void) blekw_msg_add_u8(BLE_KW_MSG_ERROR, BLE_INTERNAL_ERROR); + if ((gHciUnsupportedRemoteFeature_c == pGenericEvent->eventData.internalError.errorCode) && + (gLeSetPhy_c == pGenericEvent->eventData.internalError.errorSource)) + { + (void) blekw_msg_add_u8(BLE_KW_MSG_ERROR, BLE_KW_MSG_2M_UPGRADE_ERROR); + } + else + { + (void) blekw_msg_add_u8(BLE_KW_MSG_ERROR, BLE_INTERNAL_ERROR); + } break; case gAdvertisingSetupFailed_c: @@ -1241,10 +1255,12 @@ void BLEManagerImpl::blekw_gap_connection_cb(deviceId_t deviceId, gapConnectionE if (pConnectionEvent->eventType == gConnEvtConnected_c) { +#if CHIP_DEVICE_CONFIG_BLE_SET_PHY_2M_REQ ChipLogProgress(DeviceLayer, "BLE K32W: Trying to set the PHY to 2M"); (void) Gap_LeSetPhy(FALSE, deviceId, 0, gConnPhyUpdateReqTxPhySettings_c, gConnPhyUpdateReqRxPhySettings_c, (uint16_t) gConnPhyUpdateReqPhyOptions_c); +#endif /* Notify App Task that the BLE is connected now */ (void) blekw_msg_add_u8(BLE_KW_MSG_CONNECTED, (uint8_t) deviceId); diff --git a/src/platform/nxp/k32w/k32w0/BLEManagerImpl.h b/src/platform/nxp/k32w/k32w0/BLEManagerImpl.h index b3b473337bf253..f6b5a0df6e07d9 100644 --- a/src/platform/nxp/k32w/k32w0/BLEManagerImpl.h +++ b/src/platform/nxp/k32w/k32w0/BLEManagerImpl.h @@ -119,7 +119,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla enum { kMaxConnections = BLE_LAYER_NUM_BLE_ENDPOINTS, - kMaxDeviceNameLength = 16, + kMaxDeviceNameLength = 32, kUnusedIndex = 0xFF, }; @@ -165,6 +165,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla BLE_E_FAIL, BLE_E_START_ADV_FAILED, BLE_INTERNAL_ERROR, + BLE_KW_MSG_2M_UPGRADE_ERROR, } ble_err_t; typedef struct ble_att_written_data_s diff --git a/src/platform/nxp/k32w/k32w0/BUILD.gn b/src/platform/nxp/k32w/k32w0/BUILD.gn index e813d8253c48bd..35228093e77f0a 100644 --- a/src/platform/nxp/k32w/k32w0/BUILD.gn +++ b/src/platform/nxp/k32w/k32w0/BUILD.gn @@ -13,8 +13,10 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/k32w0_sdk.gni") import("${chip_root}/src/platform/device.gni") +import("${k32w0_sdk_build_root}/k32w0_sdk.gni") assert(chip_device_platform == "k32w0") @@ -24,8 +26,9 @@ if (chip_enable_openthread) { static_library("k32w0") { sources = [ - "../../../FreeRTOS/SystemTimeSupport.cpp", "../../../SingletonConfigurationManager.cpp", + "../common/RamStorage.cpp", + "../common/RamStorage.h", "BLEManagerImpl.cpp", "BLEManagerImpl.h", "CHIPDevicePlatformConfig.h", @@ -34,12 +37,16 @@ static_library("k32w0") { "ConfigurationManagerImpl.h", "ConnectivityManagerImpl.cpp", "ConnectivityManagerImpl.h", + "DefaultTestEventTriggerDelegate.cpp", + "DefaultTestEventTriggerDelegate.h", "DeviceNetworkProvisioningDelegateImpl.cpp", "DeviceNetworkProvisioningDelegateImpl.h", "DiagnosticDataProviderImpl.cpp", "DiagnosticDataProviderImpl.h", "K32W0Config.cpp", "K32W0Config.h", + "K32W0FactoryDataProvider.cpp", + "K32W0FactoryDataProvider.h", "KeyValueStoreManagerImpl.cpp", "KeyValueStoreManagerImpl.h", "Logging.cpp", @@ -47,9 +54,21 @@ static_library("k32w0") { "NFCManagerImpl.h", "PlatformManagerImpl.cpp", "PlatformManagerImpl.h", + "SystemTimeSupport.cpp", "ble_function_mux.c", ] + public = [ + "${chip_root}/src/credentials/DeviceAttestationCredsProvider.h", + "${chip_root}/src/credentials/examples/DeviceAttestationCredsExample.h", + "${chip_root}/src/credentials/examples/ExampleDACs.h", + "${chip_root}/src/credentials/examples/ExamplePAI.h", + ] + + if (chip_with_low_power != 0) { + sources += [ "LowPowerHooks.cpp" ] + } + if (chip_enable_ota_requestor) { sources += [ "OTAImageProcessorImpl.cpp", diff --git a/src/platform/nxp/k32w/k32w0/CHIPDevicePlatformConfig.h b/src/platform/nxp/k32w/k32w0/CHIPDevicePlatformConfig.h index 3529d47b4435e6..c5cc9287e5c97e 100644 --- a/src/platform/nxp/k32w/k32w0/CHIPDevicePlatformConfig.h +++ b/src/platform/nxp/k32w/k32w0/CHIPDevicePlatformConfig.h @@ -64,9 +64,79 @@ #define CHIP_DEVICE_LAYER_BLE_CONN_CFG_TAG 1 #endif // CHIP_DEVICE_LAYER_BLE_CONN_CFG_TAG +#ifndef CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION +//-> format_version = 1 +//-> vendor_id = 0xFFF1 +//-> product_id_array = [ 0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007, 0x8008, 0x8009, 0x800A, 0x800B, +// 0x800C, 0x800D, 0x800E, 0x800F, 0x8010, 0x8011, 0x8012, 0x8013, 0x8014, 0x8015, 0x8016, 0x8017, 0x8018, 0x8019, 0x801A, +// 0x801B, 0x801C, 0x801D, 0x801E, 0x801F, 0x8020, 0x8021, 0x8022, 0x8023, 0x8024, 0x8025, 0x8026, 0x8027, 0x8028, 0x8029, +// 0x802A, 0x802B, 0x802C, 0x802D, 0x802E, 0x802F, 0x8030, 0x8031, 0x8032, 0x8033, 0x8034, 0x8035, 0x8036, 0x8037, 0x8038, +// 0x8039, 0x803A, 0x803B, 0x803C, 0x803D, 0x803E, 0x803F, 0x8040, 0x8041, 0x8042, 0x8043, 0x8044, 0x8045, 0x8046, 0x8047, +// 0x8048, 0x8049, 0x804A, 0x804B, 0x804C, 0x804D, 0x804E, 0x804F, 0x8050, 0x8051, 0x8052, 0x8053, 0x8054, 0x8055, 0x8056, +// 0x8057, 0x8058, 0x8059, 0x805A, 0x805B, 0x805C, 0x805D, 0x805E, 0x805F, 0x8060, 0x8061, 0x8062, 0x8063 ] +//-> device_type_id = 0x0016 +//-> certificate_id = "ZIG20142ZB330003-24" +//-> security_level = 0 +//-> security_information = 0 +//-> version_number = 0x2694 +//-> certification_type = 0 +//-> dac_origin_vendor_id is not present +//-> dac_origin_product_id is not present +#define CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION \ + { \ + 0x30, 0x82, 0x02, 0x19, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0, 0x82, 0x02, 0x0a, 0x30, \ + 0x82, 0x02, 0x06, 0x02, 0x01, 0x03, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, \ + 0x02, 0x01, 0x30, 0x82, 0x01, 0x71, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x82, \ + 0x01, 0x62, 0x04, 0x82, 0x01, 0x5e, 0x15, 0x24, 0x00, 0x01, 0x25, 0x01, 0xe1, 0xee, 0x36, 0x02, 0x05, 0x00, 0x80, \ + 0x05, 0x01, 0x80, 0x05, 0x02, 0x80, 0x05, 0x03, 0x80, 0x05, 0x04, 0x80, 0x05, 0x05, 0x80, 0x05, 0x06, 0x80, 0x05, \ + 0x07, 0x80, 0x05, 0x08, 0x80, 0x05, 0x09, 0x80, 0x05, 0x0a, 0x80, 0x05, 0x0b, 0x80, 0x05, 0x0c, 0x80, 0x05, 0x0d, \ + 0x80, 0x05, 0x0e, 0x80, 0x05, 0x0f, 0x80, 0x05, 0x10, 0x80, 0x05, 0x11, 0x80, 0x05, 0x12, 0x80, 0x05, 0x13, 0x80, \ + 0x05, 0x14, 0x80, 0x05, 0x15, 0x80, 0x05, 0x16, 0x80, 0x05, 0x17, 0x80, 0x05, 0x18, 0x80, 0x05, 0x19, 0x80, 0x20, \ + 0x05, 0x1a, 0x80, 0x05, 0x1b, 0x80, 0x05, 0x1c, 0x80, 0x05, 0x1d, 0x80, 0x05, 0x1e, 0x80, 0x05, 0x1f, 0x80, 0x05, \ + 0x80, 0x05, 0x21, 0x80, 0x05, 0x22, 0x80, 0x05, 0x23, 0x80, 0x05, 0x24, 0x80, 0x05, 0x25, 0x80, 0x05, 0x26, 0x80, \ + 0x05, 0x27, 0x80, 0x05, 0x28, 0x80, 0x05, 0x29, 0x80, 0x05, 0x2a, 0x80, 0x05, 0x2b, 0x80, 0x05, 0x2c, 0x80, 0x05, \ + 0x2d, 0x80, 0x05, 0x2e, 0x80, 0x05, 0x2f, 0x80, 0x05, 0x30, 0x80, 0x05, 0x31, 0x80, 0x05, 0x32, 0x80, 0x05, 0x33, \ + 0x80, 0x05, 0x34, 0x80, 0x05, 0x35, 0x80, 0x05, 0x36, 0x80, 0x05, 0x37, 0x80, 0x05, 0x38, 0x80, 0x05, 0x39, 0x80, \ + 0x05, 0x3a, 0x80, 0x05, 0x3b, 0x80, 0x05, 0x3c, 0x80, 0x05, 0x3d, 0x80, 0x05, 0x3e, 0x80, 0x05, 0x3f, 0x80, 0x05, \ + 0x40, 0x80, 0x05, 0x41, 0x80, 0x05, 0x42, 0x80, 0x05, 0x43, 0x80, 0x05, 0x44, 0x80, 0x05, 0x45, 0x80, 0x05, 0x46, \ + 0x80, 0x05, 0x47, 0x80, 0x05, 0x48, 0x80, 0x05, 0x49, 0x80, 0x05, 0x4a, 0x80, 0x05, 0x4b, 0x80, 0x05, 0x4c, 0x80, \ + 0x05, 0x4d, 0x80, 0x05, 0x4e, 0x80, 0x05, 0x4f, 0x80, 0x05, 0x50, 0x80, 0x05, 0x51, 0x80, 0x05, 0x52, 0x80, 0x05, \ + 0x53, 0x80, 0x05, 0x54, 0x80, 0x05, 0x55, 0x80, 0x05, 0x56, 0x80, 0x05, 0x57, 0x80, 0x05, 0x58, 0x80, 0x05, 0x59, \ + 0x80, 0x05, 0x5a, 0x80, 0x05, 0x5b, 0x80, 0x05, 0x5c, 0x80, 0x05, 0x5d, 0x80, 0x05, 0x5e, 0x80, 0x05, 0x5f, 0x80, \ + 0x05, 0x60, 0x80, 0x05, 0x61, 0x80, 0x05, 0x62, 0x80, 0x05, 0x63, 0x80, 0x18, 0x24, 0x03, 0x16, 0x2c, 0x04, 0x13, \ + 0x5a, 0x49, 0x47, 0x32, 0x30, 0x31, 0x34, 0x32, 0x5a, 0x42, 0x33, 0x33, 0x30, 0x30, 0x30, 0x33, 0x2d, 0x32, 0x34, \ + 0x24, 0x05, 0x00, 0x24, 0x06, 0x00, 0x25, 0x07, 0x94, 0x26, 0x24, 0x08, 0x00, 0x18, 0x31, 0x7d, 0x30, 0x7b, 0x02, \ + 0x01, 0x03, 0x80, 0x14, 0x62, 0xfa, 0x82, 0x33, 0x59, 0xac, 0xfa, 0xa9, 0x96, 0x3e, 0x1c, 0xfa, 0x14, 0x0a, 0xdd, \ + 0xf5, 0x04, 0xf3, 0x71, 0x60, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, \ + 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x04, 0x47, 0x30, 0x45, 0x02, 0x20, 0x24, 0xe5, \ + 0xd1, 0xf4, 0x7a, 0x7d, 0x7b, 0x0d, 0x20, 0x6a, 0x26, 0xef, 0x69, 0x9b, 0x7c, 0x97, 0x57, 0xb7, 0x2d, 0x46, 0x90, \ + 0x89, 0xde, 0x31, 0x92, 0xe6, 0x78, 0xc7, 0x45, 0xe7, 0xf6, 0x0c, 0x02, 0x21, 0x00, 0xf8, 0xaa, 0x2f, 0xa7, 0x11, \ + 0xfc, 0xb7, 0x9b, 0x97, 0xe3, 0x97, 0xce, 0xda, 0x66, 0x7b, 0xae, 0x46, 0x4e, 0x2b, 0xd3, 0xff, 0xdf, 0xc3, 0xcc, \ + 0xed, 0x7a, 0xa8, 0xca, 0x5f, 0x4c, 0x1a, 0x7c \ + } +#endif + +/** + * @def CHIP_DEVICE_LAYER_OTA_REBOOT_DELAY + * + * The delay before rebooting after an OTA process was finished. + */ +#ifndef CHIP_DEVICE_LAYER_OTA_REBOOT_DELAY +#define CHIP_DEVICE_LAYER_OTA_REBOOT_DELAY 3000 +#endif // CHIP_DEVICE_LAYER_OTA_REBOOT_DELAY + +/** + * @def CHIP_DEVICE_LAYER_ENABLE_PDM_LOGS + * + * Flag to enable PDM events logging. Disabled by default. + */ +#ifndef CHIP_DEVICE_LAYER_ENABLE_PDM_LOGS +#define CHIP_DEVICE_LAYER_ENABLE_PDM_LOGS 0 +#endif // CHIP_DEVICE_LAYER_ENABLE_PDM_LOGS + // ========== Platform-specific Configuration Overrides ========= #ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE -#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE (5 * 1024) +#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE (6 * 1024) #endif // CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE #ifndef CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE @@ -80,6 +150,16 @@ #define CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME "BLE App Task" #endif // CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME +/** + * @def CHIP_DEVICE_CONFIG_BLE_SET_PHY_2M_REQ + * + * Enables/disables the Gap_LeSetPhy request to switch to 2M; enabled by default. + * May be disabled on applications for interoperability reasons. + */ +#ifndef CHIP_DEVICE_CONFIG_BLE_SET_PHY_2M_REQ +#define CHIP_DEVICE_CONFIG_BLE_SET_PHY_2M_REQ 1 +#endif // CHIP_DEVICE_CONFIG_BLE_SET_PHY_2M_REQ + #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0 diff --git a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp index 451536e8deedbd..c236c05d1fa618 100644 --- a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp @@ -52,13 +52,6 @@ CHIP_ERROR ConfigurationManagerImpl::Init() CHIP_ERROR err; uint32_t rebootCount = 0; - // Save out software version on first boot - if (!K32WConfig::ConfigValueExists(K32WConfig::kConfigKey_SoftwareVersion)) - { - err = StoreSoftwareVersion(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - SuccessOrExit(err); - } - if (K32WConfig::ConfigValueExists(K32WConfig::kCounterKey_RebootCount)) { err = GetRebootCount(rebootCount); @@ -70,7 +63,7 @@ CHIP_ERROR ConfigurationManagerImpl::Init() else { // The first boot after factory reset of the Node. - err = StoreRebootCount(1); + err = StoreRebootCount(0); SuccessOrExit(err); } @@ -118,16 +111,6 @@ CHIP_ERROR ConfigurationManagerImpl::StoreTotalOperationalHours(uint32_t totalOp return WriteConfigValue(K32WConfig::kCounterKey_TotalOperationalHours, totalOperationalHours); } -CHIP_ERROR ConfigurationManagerImpl::GetSoftwareVersion(uint32_t & softwareVer) -{ - return ReadConfigValue(K32WConfig::kConfigKey_SoftwareVersion, softwareVer); -} - -CHIP_ERROR ConfigurationManagerImpl::StoreSoftwareVersion(uint32_t softwareVer) -{ - return WriteConfigValue(K32WConfig::kConfigKey_SoftwareVersion, softwareVer); -} - CHIP_ERROR ConfigurationManagerImpl::GetBootReason(uint32_t & bootReason) { bootReason = to_underlying(BootReasonType::kUnspecified); diff --git a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h index 689dc8d9732d0c..32a8f315f8f85d 100644 --- a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h +++ b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h @@ -51,8 +51,6 @@ class ConfigurationManagerImpl final : public Internal::GenericConfigurationMana CHIP_ERROR WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value) override; CHIP_ERROR GetRebootCount(uint32_t & rebootCount) override; CHIP_ERROR StoreRebootCount(uint32_t rebootCount) override; - CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer) override; - CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer) override; CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours) override; CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours) override; CHIP_ERROR GetBootReason(uint32_t & bootReasons) override; diff --git a/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp new file mode 100644 index 00000000000000..1a01acfdb69385 --- /dev/null +++ b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp @@ -0,0 +1,42 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * 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. + */ + +#include "DefaultTestEventTriggerDelegate.h" + +#include +#include + +namespace chip { + +bool DefaultTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const +{ + return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); +} + +CHIP_ERROR DefaultTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger) +{ + if (eventTrigger == kQueryTrigger) + { + ChipLogProgress(DeviceLayer, "DefaultTestEventTriggerDelegate: event triggered"); + return CHIP_NO_ERROR; + } + + return CHIP_ERROR_INVALID_ARGUMENT; +} + +} // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h new file mode 100644 index 00000000000000..cf71fb37d96470 --- /dev/null +++ b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h @@ -0,0 +1,39 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * 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. + */ + +#pragma once + +#include + +namespace chip { + +class DefaultTestEventTriggerDelegate : public TestEventTriggerDelegate +{ +public: + static constexpr uint64_t kQueryTrigger = 1234; + + explicit DefaultTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {} + + bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; + CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; + +private: + ByteSpan mEnableKey; +}; + +} // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.cpp b/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.cpp index 0eefc9063c2209..bb16488e6e4c7d 100644 --- a/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.cpp @@ -31,8 +31,14 @@ #include #endif +extern "C" void xPortResetHeapMinimumEverFreeHeapSize(void); + #include +#include + +using namespace ::chip::app::Clusters::GeneralDiagnostics; + namespace chip { namespace DeviceLayer { @@ -72,6 +78,71 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapHighWatermark(uint64_t & cu return CHIP_NO_ERROR; } +CHIP_ERROR DiagnosticDataProviderImpl::ResetWatermarks() +{ + // If implemented, the server SHALL set the value of the CurrentHeapHighWatermark attribute to the + // value of the CurrentHeapUsed. + + xPortResetHeapMinimumEverFreeHeapSize(); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetThreadMetrics(ThreadMetrics ** threadMetricsOut) +{ + /* Obtain all available task information */ + TaskStatus_t * taskStatusArray; + ThreadMetrics * head = nullptr; + unsigned long arraySize, x, dummy; + + arraySize = uxTaskGetNumberOfTasks(); + + taskStatusArray = (TaskStatus_t *) pvPortMalloc(arraySize * sizeof(TaskStatus_t)); + + if (taskStatusArray != NULL) + { + /* Generate raw status information about each task. */ + arraySize = uxTaskGetSystemState(taskStatusArray, arraySize, &dummy); + /* For each populated position in the taskStatusArray array, + format the raw data as human readable ASCII data. */ + + for (x = 0; x < arraySize; x++) + { + ThreadMetrics * thread = (ThreadMetrics *) pvPortMalloc(sizeof(ThreadMetrics)); + + strncpy(thread->NameBuf, taskStatusArray[x].pcTaskName, kMaxThreadNameLength - 1); + thread->NameBuf[kMaxThreadNameLength] = '\0'; + thread->name.Emplace(CharSpan::fromCharString(thread->NameBuf)); + thread->id = taskStatusArray[x].xTaskNumber; + + thread->stackFreeMinimum.Emplace(taskStatusArray[x].usStackHighWaterMark); + + /* Unsupported metrics */ + // thread->stackSize; + // thread->stackFreeCurrent; + + thread->Next = head; + head = thread; + } + + *threadMetricsOut = head; + /* The array is no longer needed, free the memory it consumes. */ + vPortFree(taskStatusArray); + } + + return CHIP_NO_ERROR; +} + +void DiagnosticDataProviderImpl::ReleaseThreadMetrics(ThreadMetrics * threadMetrics) +{ + while (threadMetrics) + { + ThreadMetrics * del = threadMetrics; + threadMetrics = threadMetrics->Next; + vPortFree(del); + } +} + CHIP_ERROR DiagnosticDataProviderImpl::GetRebootCount(uint16_t & rebootCount) { uint32_t count = 0; @@ -139,5 +210,22 @@ DiagnosticDataProvider & GetDiagnosticDataProviderImpl() return DiagnosticDataProviderImpl::GetDefaultInstance(); } +CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** netifpp) +{ + NetworkInterface * ifp = new NetworkInterface(); + + const char * threadNetworkName = otThreadGetNetworkName(ThreadStackMgrImpl().OTInstance()); + ifp->name = Span(threadNetworkName, strlen(threadNetworkName)); + ifp->isOperational = true; + ifp->offPremiseServicesReachableIPv4.SetNull(); + ifp->offPremiseServicesReachableIPv6.SetNull(); + ifp->type = InterfaceType::EMBER_ZCL_INTERFACE_TYPE_THREAD; + uint8_t macBuffer[ConfigurationManager::kPrimaryMACAddressLength]; + ConfigurationMgr().GetPrimary802154MACAddress(macBuffer); + ifp->hardwareAddress = ByteSpan(macBuffer, ConfigurationManager::kPrimaryMACAddressLength); + *netifpp = ifp; + return CHIP_NO_ERROR; +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.h b/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.h index 390ce75bb31f4a..05be335999482b 100644 --- a/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.h +++ b/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.h @@ -30,7 +30,7 @@ namespace chip { namespace DeviceLayer { /** - * Concrete implementation of the PlatformManager singleton object for Linux platforms. + * Concrete implementation of the PlatformManager singleton object for K32W0 platforms. */ class DiagnosticDataProviderImpl : public DiagnosticDataProvider { @@ -39,14 +39,19 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider // ===== Methods that implement the PlatformManager abstract interface. + bool SupportsWatermarks() override { return true; } CHIP_ERROR GetCurrentHeapFree(uint64_t & currentHeapFree) override; CHIP_ERROR GetCurrentHeapUsed(uint64_t & currentHeapUsed) override; CHIP_ERROR GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark) override; + CHIP_ERROR ResetWatermarks() override; + CHIP_ERROR GetThreadMetrics(ThreadMetrics ** threadMetricsOut) override; + void ReleaseThreadMetrics(ThreadMetrics * threadMetrics) override; CHIP_ERROR GetRebootCount(uint16_t & rebootCount) override; CHIP_ERROR GetUpTime(uint64_t & upTime) override; CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours) override; CHIP_ERROR GetBootReason(BootReasonType & bootReason) override; + CHIP_ERROR GetNetworkInterfaces(NetworkInterface ** netifpp) override; }; /** diff --git a/src/platform/nxp/k32w/k32w0/K32W0Config.cpp b/src/platform/nxp/k32w/k32w0/K32W0Config.cpp index c22f4c5a862312..e98045b619c027 100644 --- a/src/platform/nxp/k32w/k32w0/K32W0Config.cpp +++ b/src/platform/nxp/k32w/k32w0/K32W0Config.cpp @@ -37,27 +37,33 @@ namespace DeviceLayer { namespace Internal { osaMutexId_t K32WConfig::pdmMutexHandle = NULL; -static ramBufferDescriptor * ramDescr = NULL; -constexpr uint16_t kNvmIdChipConfigData = 0x5000; -constexpr uint16_t kRamBufferInitialSize = 3072; +#if CHIP_DEVICE_LAYER_ENABLE_PDM_LOGS +static void PDM_SystemCallback(uint32_t number, PDM_eSystemEventCode code) +{ + uint8_t capacity = PDM_u8GetSegmentCapacity(); + uint8_t occupancy = PDM_u8GetSegmentOccupancy(); + ChipLogProgress(DeviceLayer, "[PDM]Event (number, code): (%lu, %d)", number, code); + ChipLogProgress(DeviceLayer, "[PDM]Capacity: %hhu", capacity); + ChipLogProgress(DeviceLayer, "[PDM]Occupancy: %hhu", occupancy); +} +#endif CHIP_ERROR K32WConfig::Init() { CHIP_ERROR err = CHIP_NO_ERROR; - int pdmStatus; + int status; /* Initialise the Persistent Data Manager */ pdmMutexHandle = OSA_MutexCreate(); VerifyOrExit((NULL != pdmMutexHandle), err = CHIP_ERROR_NO_MEMORY); - pdmStatus = PDM_Init(); - SuccessOrExit(err = MapPdmInitStatus(pdmStatus)); + status = PDM_Init(); + SuccessOrExit(err = MapPdmInitStatusToChipError(status)); +#if CHIP_DEVICE_LAYER_ENABLE_PDM_LOGS + PDM_vRegisterSystemCallback(PDM_SystemCallback); +#endif - ramDescr = getRamBuffer(kNvmIdChipConfigData, kRamBufferInitialSize); - if (!ramDescr) - { - err = CHIP_ERROR_NO_MEMORY; - } + err = RamStorage::Init(kNvmIdChipConfigData, kRamBufferInitialSize); exit: if (err != CHIP_NO_ERROR) @@ -66,10 +72,8 @@ CHIP_ERROR K32WConfig::Init() { OSA_MutexDestroy(pdmMutexHandle); } - if (ramDescr) - { - free(ramDescr); - } + + RamStorage::FreeBuffer(); } return err; } @@ -92,65 +96,15 @@ void K32WConfig::MutexUnlock(osaMutexId_t mutexId) } } -CHIP_ERROR K32WConfig::ReadConfigValue(Key key, bool & val) -{ - CHIP_ERROR err; - bool tempVal; - rsError status; - uint16_t sizeToRead = sizeof(tempVal); - - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageGet(ramDescr, key, 0, (uint8_t *) &tempVal, &sizeToRead); - SuccessOrExit(err = MapRamStorageStatus(status)); - val = tempVal; - -exit: - return err; -} - -CHIP_ERROR K32WConfig::ReadConfigValue(Key key, uint32_t & val) -{ - CHIP_ERROR err; - uint32_t tempVal; - rsError status; - uint16_t sizeToRead = sizeof(tempVal); - - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageGet(ramDescr, key, 0, (uint8_t *) &tempVal, &sizeToRead); - SuccessOrExit(err = MapRamStorageStatus(status)); - val = tempVal; - -exit: - return err; -} - -CHIP_ERROR K32WConfig::ReadConfigValue(Key key, uint64_t & val) -{ - CHIP_ERROR err; - uint32_t tempVal; - rsError status; - uint16_t sizeToRead = sizeof(tempVal); - - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageGet(ramDescr, key, 0, (uint8_t *) &tempVal, &sizeToRead); - SuccessOrExit(err = MapRamStorageStatus(status)); - val = tempVal; - -exit: - return err; -} - CHIP_ERROR K32WConfig::ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen) { CHIP_ERROR err; - rsError status; uint16_t sizeToRead = bufSize; - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. + VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); + err = RamStorage::Read(key, 0, (uint8_t *) buf, &sizeToRead); + SuccessOrExit(err); - // We can call ramStorageGet with null pointer to only retrieve the size - status = ramStorageGet(ramDescr, key, 0, (uint8_t *) buf, &sizeToRead); - SuccessOrExit(err = MapRamStorageStatus(status)); outLen = sizeToRead; exit: @@ -168,125 +122,6 @@ CHIP_ERROR K32WConfig::ReadConfigValueCounter(uint8_t counterIdx, uint32_t & val return ReadConfigValue(key, val); } -CHIP_ERROR K32WConfig::WriteConfigValue(Key key, bool val) -{ - CHIP_ERROR err; - PDM_teStatus pdmStatus; - rsError ramStatus = RS_ERROR_NONE; - - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - MutexLock(pdmMutexHandle, osaWaitForever_c); - - /* first delete all occurrences of "key" */ - ramStorageDelete(ramDescr, key, -1); - - /* resize RAM Buffer if needed */ - ramStatus = ramStorageResize(&ramDescr, key, (uint8_t *) &val, sizeof(bool)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* add to RAM buffer */ - ramStatus = ramStorageSet(ramDescr, key, (uint8_t *) &val, sizeof(bool)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* schedule flash writing */ - pdmStatus = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, ramDescr, ramDescr->ramBufferLen + kRamDescHeaderSize); - SuccessOrExit(err = MapPdmStatus(pdmStatus)); - -exit: - MutexUnlock(pdmMutexHandle); - return err; -} - -CHIP_ERROR K32WConfig::WriteConfigValueSync(Key key, bool val) -{ - CHIP_ERROR err; - PDM_teStatus pdmStatus; - rsError ramStatus = RS_ERROR_NONE; - - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - MutexLock(pdmMutexHandle, osaWaitForever_c); - - /* first delete all occurrences of "key" */ - ramStorageDelete(ramDescr, key, -1); - - /* resize RAM Buffer if needed */ - ramStatus = ramStorageResize(&ramDescr, key, (uint8_t *) &val, sizeof(bool)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* add to RAM buffer */ - ramStatus = ramStorageSet(ramDescr, key, (uint8_t *) &val, sizeof(bool)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - // Interrupts are disabled to ensure there is no context switch during the actual - // writing, thus avoiding race conditions. - OSA_InterruptDisable(); - pdmStatus = PDM_eSaveRecordData(kNvmIdChipConfigData, ramDescr, ramDescr->ramBufferLen + kRamDescHeaderSize); - OSA_InterruptEnable(); - SuccessOrExit(err = MapPdmStatus(pdmStatus)); - -exit: - MutexUnlock(pdmMutexHandle); - return err; -} - -CHIP_ERROR K32WConfig::WriteConfigValue(Key key, uint32_t val) -{ - CHIP_ERROR err; - PDM_teStatus pdmStatus; - rsError ramStatus = RS_ERROR_NONE; - - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - MutexLock(pdmMutexHandle, osaWaitForever_c); - - /* first delete all occurrences of "key" */ - ramStorageDelete(ramDescr, key, -1); - - /* resize RAM Buffer if needed */ - ramStatus = ramStorageResize(&ramDescr, key, (uint8_t *) &val, sizeof(uint32_t)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* add to RAM buffer */ - ramStatus = ramStorageSet(ramDescr, key, (uint8_t *) &val, sizeof(uint32_t)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* schedule flash writing */ - pdmStatus = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, ramDescr, ramDescr->ramBufferLen + kRamDescHeaderSize); - SuccessOrExit(err = MapPdmStatus(pdmStatus)); - -exit: - MutexUnlock(pdmMutexHandle); - return err; -} - -CHIP_ERROR K32WConfig::WriteConfigValue(Key key, uint64_t val) -{ - CHIP_ERROR err; - PDM_teStatus pdmStatus; - rsError ramStatus = RS_ERROR_NONE; - - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - MutexLock(pdmMutexHandle, osaWaitForever_c); - - /* first delete all occurrences of "key" */ - ramStorageDelete(ramDescr, key, -1); - - /* resize RAM Buffer if needed */ - ramStatus = ramStorageResize(&ramDescr, key, (uint8_t *) &val, sizeof(uint64_t)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* add to RAM buffer */ - ramStatus = ramStorageSet(ramDescr, key, (uint8_t *) &val, sizeof(uint64_t)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* schedule flash writing */ - pdmStatus = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, ramDescr, ramDescr->ramBufferLen + kRamDescHeaderSize); - SuccessOrExit(err = MapPdmStatus(pdmStatus)); - -exit: - MutexUnlock(pdmMutexHandle); - return err; -} - CHIP_ERROR K32WConfig::WriteConfigValueStr(Key key, const char * str) { return WriteConfigValueStr(key, str, (str != NULL) ? strlen(str) : 0); @@ -295,32 +130,22 @@ CHIP_ERROR K32WConfig::WriteConfigValueStr(Key key, const char * str) CHIP_ERROR K32WConfig::WriteConfigValueStr(Key key, const char * str, size_t strLen) { CHIP_ERROR err; - PDM_teStatus pdmStatus; - rsError ramStatus = RS_ERROR_NONE; + PDM_teStatus status; + RamStorage::Buffer buffer; - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. MutexLock(pdmMutexHandle, osaWaitForever_c); + VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); if (!str) { - ramStatus = ramStorageDelete(ramDescr, key, -1); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); + err = RamStorage::Delete(key, -1); } else { - /* first delete all occurrences of "key" */ - ramStorageDelete(ramDescr, key, -1); - - /* resize RAM Buffer if needed */ - ramStatus = ramStorageResize(&ramDescr, key, (uint8_t *) str, strLen); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* add to RAM buffer */ - ramStatus = ramStorageSet(ramDescr, key, (uint8_t *) str, strLen); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* schedule flash writing */ - pdmStatus = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, ramDescr, ramDescr->ramBufferLen + kRamDescHeaderSize); + err = RamStorage::Write(key, (uint8_t *) str, strLen); + SuccessOrExit(err); + buffer = RamStorage::GetBuffer(); + status = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, buffer, buffer->ramBufferLen + kRamDescHeaderSize); } exit: @@ -342,16 +167,17 @@ CHIP_ERROR K32WConfig::WriteConfigValueCounter(uint8_t counterIdx, uint32_t val) CHIP_ERROR K32WConfig::ClearConfigValue(Key key) { CHIP_ERROR err = CHIP_NO_ERROR; - rsError status; - PDM_teStatus pdmStatus; + PDM_teStatus status; + RamStorage::Buffer buffer; - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. MutexLock(pdmMutexHandle, osaWaitForever_c); - status = ramStorageDelete(ramDescr, key, -1); - SuccessOrExit(err = MapRamStorageStatus(status)); + VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. + err = RamStorage::Delete(key, -1); + SuccessOrExit(err); - pdmStatus = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, ramDescr, ramDescr->ramBufferLen + kRamDescHeaderSize); - SuccessOrExit(err = MapPdmStatus(pdmStatus)); + buffer = RamStorage::GetBuffer(); + status = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, buffer, buffer->ramBufferLen + kRamDescHeaderSize); + SuccessOrExit(err = MapPdmStatusToChipError(status)); exit: MutexUnlock(pdmMutexHandle); @@ -360,34 +186,37 @@ CHIP_ERROR K32WConfig::ClearConfigValue(Key key) bool K32WConfig::ConfigValueExists(Key key) { - rsError status; + CHIP_ERROR err; uint16_t sizeToRead; bool found = false; if (ValidConfigKey(key)) { - status = ramStorageGet(ramDescr, key, 0, NULL, &sizeToRead); - found = (status == RS_ERROR_NONE && sizeToRead != 0); + err = RamStorage::Read(key, 0, NULL, &sizeToRead); + found = (err == CHIP_NO_ERROR && sizeToRead != 0); } + return found; } CHIP_ERROR K32WConfig::FactoryResetConfig(void) { CHIP_ERROR err = CHIP_NO_ERROR; - PDM_teStatus pdmStatus; + PDM_teStatus status; + RamStorage::Buffer buffer; MutexLock(pdmMutexHandle, osaWaitForever_c); + FactoryResetConfigInternal(kMinConfigKey_ChipCounter, kMaxConfigKey_ChipCounter); FactoryResetConfigInternal(kMinConfigKey_ChipConfig, kMaxConfigKey_ChipConfig); FactoryResetConfigInternal(kMinConfigKey_KVSKey, kMaxConfigKey_KVSKey); FactoryResetConfigInternal(kMinConfigKey_KVSValue, kMaxConfigKey_KVSValue); - pdmStatus = PDM_eSaveRecordData(kNvmIdChipConfigData, ramDescr, ramDescr->ramBufferLen + kRamDescHeaderSize); - SuccessOrExit(err = MapPdmStatus(pdmStatus)); + buffer = RamStorage::GetBuffer(); + status = PDM_eSaveRecordData(kNvmIdChipConfigData, buffer, buffer->ramBufferLen + kRamDescHeaderSize); + SuccessOrExit(err = MapPdmStatusToChipError(status)); exit: - free((void *) ramDescr); - ramDescr = NULL; + RamStorage::FreeBuffer(); MutexUnlock(pdmMutexHandle); return err; } @@ -396,50 +225,30 @@ void K32WConfig::FactoryResetConfigInternal(Key firstKey, Key lastKey) { for (Key key = firstKey; key <= lastKey; key++) { - ramStorageDelete(ramDescr, key, -1); + RamStorage::Delete(key, -1); } } -CHIP_ERROR K32WConfig::MapPdmStatus(PDM_teStatus pdmStatus) +CHIP_ERROR K32WConfig::MapPdmStatusToChipError(PDM_teStatus status) { CHIP_ERROR err; - switch (pdmStatus) + switch (status) { case PDM_E_STATUS_OK: err = CHIP_NO_ERROR; break; default: - err = CHIP_ERROR(ChipError::Range::kPlatform, pdmStatus); - break; - } - - return err; -} - -CHIP_ERROR K32WConfig::MapRamStorageStatus(rsError rsStatus) -{ - CHIP_ERROR err; - - switch (rsStatus) - { - case RS_ERROR_NONE: - err = CHIP_NO_ERROR; - break; - case RS_ERROR_NOT_FOUND: - err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; - break; - default: - err = CHIP_ERROR_BUFFER_TOO_SMALL; + err = CHIP_ERROR(ChipError::Range::kPlatform, status); break; } return err; } -CHIP_ERROR K32WConfig::MapPdmInitStatus(int pdmStatus) +CHIP_ERROR K32WConfig::MapPdmInitStatusToChipError(int status) { - return (pdmStatus == 0) ? CHIP_NO_ERROR : CHIP_ERROR(ChipError::Range::kPlatform, pdmStatus); + return (status == 0) ? CHIP_NO_ERROR : CHIP_ERROR(ChipError::Range::kPlatform, status); } bool K32WConfig::ValidConfigKey(Key key) diff --git a/src/platform/nxp/k32w/k32w0/K32W0Config.h b/src/platform/nxp/k32w/k32w0/K32W0Config.h index cc8919cf21ebb9..26ff2a41b3adc9 100644 --- a/src/platform/nxp/k32w/k32w0/K32W0Config.h +++ b/src/platform/nxp/k32w/k32w0/K32W0Config.h @@ -16,12 +16,6 @@ * limitations under the License. */ -/** - * @file - * Utilities for accessing persisted device configuration on - * platforms based on the NXP K32W SDK. - */ - #pragma once #include @@ -32,11 +26,15 @@ #include "fsl_os_abstraction.h" #include "pdm_ram_storage_glue.h" #include "ram_storage.h" +#include namespace chip { namespace DeviceLayer { namespace Internal { +constexpr uint16_t kNvmIdChipConfigData = 0x5000; +constexpr uint16_t kRamBufferInitialSize = 3072; + constexpr inline uint16_t K32WConfigKey(uint8_t chipId, uint8_t pdmId) { return static_cast(chipId) << 8 | pdmId; @@ -117,16 +115,16 @@ class K32WConfig static CHIP_ERROR Init(void); // Configuration methods used by the GenericConfigurationManagerImpl<> template. - static CHIP_ERROR ReadConfigValue(Key key, bool & val); - static CHIP_ERROR ReadConfigValue(Key key, uint32_t & val); - static CHIP_ERROR ReadConfigValue(Key key, uint64_t & val); + template + static CHIP_ERROR ReadConfigValue(Key key, TValue & val); + template + static CHIP_ERROR WriteConfigValue(Key key, TValue val); + template + static CHIP_ERROR WriteConfigValueSync(Key key, TValue val); + static CHIP_ERROR ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen); static CHIP_ERROR ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen); static CHIP_ERROR ReadConfigValueCounter(uint8_t counterIdx, uint32_t & val); - static CHIP_ERROR WriteConfigValue(Key key, bool val); - static CHIP_ERROR WriteConfigValueSync(Key key, bool val); - static CHIP_ERROR WriteConfigValue(Key key, uint32_t val); - static CHIP_ERROR WriteConfigValue(Key key, uint64_t val); static CHIP_ERROR WriteConfigValueStr(Key key, const char * str); static CHIP_ERROR WriteConfigValueStr(Key key, const char * str, size_t strLen); static CHIP_ERROR WriteConfigValueBin(Key key, const uint8_t * data, size_t dataLen); @@ -149,9 +147,8 @@ class K32WConfig static constexpr uint8_t GetRecordKey(uint32_t key); private: - static CHIP_ERROR MapPdmStatus(PDM_teStatus pdmStatus); - static CHIP_ERROR MapRamStorageStatus(rsError rsStatus); - static CHIP_ERROR MapPdmInitStatus(int pdmStatus); + static CHIP_ERROR MapPdmStatusToChipError(PDM_teStatus status); + static CHIP_ERROR MapPdmInitStatusToChipError(int status); static void FactoryResetConfigInternal(Key firstKey, Key lastKey); }; @@ -171,6 +168,65 @@ inline constexpr uint8_t K32WConfig::GetRecordKey(Key key) return static_cast(key); } +template +CHIP_ERROR K32WConfig::ReadConfigValue(Key key, TValue & val) +{ + CHIP_ERROR err; + uint16_t valLen = sizeof(val); + + VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); + err = RamStorage::Read(key, 0, (uint8_t *) &val, &valLen); + SuccessOrExit(err); + +exit: + return err; +} + +template +CHIP_ERROR K32WConfig::WriteConfigValue(Key key, TValue val) +{ + CHIP_ERROR err; + PDM_teStatus status; + RamStorage::Buffer buffer; + + MutexLock(pdmMutexHandle, osaWaitForever_c); + VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); + err = RamStorage::Write(key, (uint8_t *) &val, sizeof(TValue)); + SuccessOrExit(err); + + buffer = RamStorage::GetBuffer(); + status = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, buffer, buffer->ramBufferLen + kRamDescHeaderSize); + SuccessOrExit(err = MapPdmStatusToChipError(status)); + +exit: + MutexUnlock(pdmMutexHandle); + return err; +} + +template +CHIP_ERROR K32WConfig::WriteConfigValueSync(Key key, TValue val) +{ + CHIP_ERROR err; + PDM_teStatus status; + RamStorage::Buffer buffer; + + MutexLock(pdmMutexHandle, osaWaitForever_c); + VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); + err = RamStorage::Write(key, (uint8_t *) &val, sizeof(TValue)); + SuccessOrExit(err); + // Interrupts are disabled to ensure there is no context switch during the actual + // writing, thus avoiding race conditions. + OSA_InterruptDisable(); + buffer = RamStorage::GetBuffer(); + status = PDM_eSaveRecordData(kNvmIdChipConfigData, buffer, buffer->ramBufferLen + kRamDescHeaderSize); + OSA_InterruptEnable(); + SuccessOrExit(err = MapPdmStatusToChipError(status)); + +exit: + MutexUnlock(pdmMutexHandle); + return err; +} + } // namespace Internal } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/K32W0FactoryDataProvider.cpp b/src/platform/nxp/k32w/k32w0/K32W0FactoryDataProvider.cpp new file mode 100644 index 00000000000000..33491c1873dd17 --- /dev/null +++ b/src/platform/nxp/k32w/k32w0/K32W0FactoryDataProvider.cpp @@ -0,0 +1,326 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +#if (!CONFIG_CHIP_K32W0_REAL_FACTORY_DATA || !(defined CONFIG_CHIP_K32W0_REAL_FACTORY_DATA)) +#include +#include +#include +#endif + +#include "OtaUtils.h" +#include "fsl_flash.h" +#include +#include +#include +#include +#include + +#include "K32W0FactoryDataProvider.h" + +/* Grab symbol for the base address from the linker file. */ +extern uint32_t __FACTORY_DATA_START[]; +extern uint32_t __FACTORY_DATA_SIZE[]; + +namespace chip { +namespace { + +CHIP_ERROR LoadKeypairFromRaw(ByteSpan privateKey, ByteSpan publicKey, Crypto::P256Keypair & keypair) +{ + Crypto::P256SerializedKeypair serialized_keypair; + ReturnErrorOnFailure(serialized_keypair.SetLength(privateKey.size() + publicKey.size())); + memcpy(serialized_keypair.Bytes(), publicKey.data(), publicKey.size()); + memcpy(serialized_keypair.Bytes() + publicKey.size(), privateKey.data(), privateKey.size()); + return keypair.Deserialize(serialized_keypair); +} +} // namespace + +namespace DeviceLayer { + +K32W0FactoryDataProvider & K32W0FactoryDataProvider::GetDefaultInstance() +{ + static K32W0FactoryDataProvider sInstance; + return sInstance; +} + +static constexpr size_t kSpake2pSerializedVerifier_MaxBase64Len = + BASE64_ENCODED_LEN(chip::Crypto::kSpake2p_VerifierSerialized_Length) + 1; +static constexpr size_t kSpake2pSalt_MaxBase64Len = BASE64_ENCODED_LEN(chip::Crypto::kSpake2p_Max_PBKDF_Salt_Length) + 1; +static constexpr size_t kMaxCertLen = 600; +static constexpr size_t kMaxKeyLen = 32; + +static constexpr size_t kVerifierId = 1; +static constexpr size_t kSaltId = 2; +static constexpr size_t kIcId = 3; +static constexpr size_t kDacPrivateKeyId = 4; +static constexpr size_t kDacCertificateId = 5; +static constexpr size_t kPaiCertificateId = 6; +static constexpr size_t kDiscriminatorId = 7; + +static constexpr size_t kMaxId = kDiscriminatorId; + +static uint16_t maxLengths[kMaxId + 1]; +static uint32_t factoryDataActualSize = 0; + +typedef otaUtilsResult_t (*OtaUtils_EEPROM_ReadData)(uint16_t nbBytes, uint32_t address, uint8_t * pInbuf); + +static uint8_t ReadDataMemCpy(uint16_t num, uint32_t src, uint8_t * dst) +{ + memcpy(dst, (void *) (src), num); + return 0; +} + +CHIP_ERROR SearchForId(uint8_t searchedType, uint8_t * pBuf, size_t bufLength, uint16_t & length) +{ + CHIP_ERROR err = CHIP_ERROR_NOT_FOUND; + uint32_t factoryDataStartAddress = (uint32_t) __FACTORY_DATA_START; + uint32_t addr = factoryDataStartAddress; + OtaUtils_EEPROM_ReadData pFunctionEepromRead = (OtaUtils_EEPROM_ReadData) ReadDataMemCpy; + uint8_t type = 0; + + while (addr < (factoryDataStartAddress + (uint32_t) __FACTORY_DATA_SIZE)) + { + if (gOtaUtilsSuccess_c != OtaUtils_ReadFromInternalFlash((uint16_t) sizeof(type), addr, &type, NULL, pFunctionEepromRead) || + gOtaUtilsSuccess_c != + OtaUtils_ReadFromInternalFlash((uint16_t) sizeof(length), addr + 1, (uint8_t *) &length, NULL, pFunctionEepromRead)) + break; + + if ((type > kMaxId) || (length > maxLengths[type])) + { + break; + } + + if (searchedType == type) + { + if (bufLength < length) + { + err = CHIP_ERROR_BUFFER_TOO_SMALL; + } + else + { + if (gOtaUtilsSuccess_c != OtaUtils_ReadFromInternalFlash(length, addr + 3, pBuf, NULL, pFunctionEepromRead)) + break; + + err = CHIP_NO_ERROR; + } + break; + } + else + { + /* Jump past 2 bytes of length and then use length to jump to next data */ + addr = addr + 3 + length; + } + } + + return err; +} + +CHIP_ERROR K32W0FactoryDataProvider::Init() +{ + + maxLengths[kVerifierId] = kSpake2pSerializedVerifier_MaxBase64Len; + maxLengths[kSaltId] = kSpake2pSalt_MaxBase64Len; + maxLengths[kIcId] = 4; + maxLengths[kDacPrivateKeyId] = kMaxKeyLen; + maxLengths[kDacCertificateId] = kMaxCertLen; + maxLengths[kPaiCertificateId] = kMaxCertLen; + maxLengths[kDiscriminatorId] = 4; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetCertificationDeclaration(MutableByteSpan & outBuffer) +{ + constexpr uint8_t kCdForAllExamples[] = CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION; + + return CopySpanToMutableSpan(ByteSpan{ kCdForAllExamples }, outBuffer); +} + +CHIP_ERROR K32W0FactoryDataProvider::GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) +{ + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetDeviceAttestationCert(MutableByteSpan & outBuffer) +{ + uint16_t certificateSize = 0; + ReturnErrorOnFailure(SearchForId(kDacCertificateId, outBuffer.data(), outBuffer.size(), certificateSize)); + outBuffer.reduce_size(certificateSize); + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetProductAttestationIntermediateCert(MutableByteSpan & outBuffer) +{ + uint16_t certificateSize = 0; + ReturnErrorOnFailure(SearchForId(kPaiCertificateId, outBuffer.data(), outBuffer.size(), certificateSize)); + outBuffer.reduce_size(certificateSize); + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::SignWithDeviceAttestationKey(const ByteSpan & messageToSign, MutableByteSpan & outSignBuffer) +{ + Crypto::P256ECDSASignature signature; + Crypto::P256Keypair keypair; + VerifyOrReturnError(IsSpanUsable(outSignBuffer), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(IsSpanUsable(messageToSign), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(outSignBuffer.size() >= signature.Capacity(), CHIP_ERROR_BUFFER_TOO_SMALL); + + // In a non-exemplary implementation, the public key is not needed here. It is used here merely because + // Crypto::P256Keypair is only (currently) constructable from raw keys if both private/public keys are present. + Crypto::P256PublicKey dacPublicKey; + uint8_t certBuf[kMaxCertLen]; + MutableByteSpan dacCertSpan(certBuf); + uint16_t certificateSize = 0; + CHIP_ERROR err = CHIP_NO_ERROR; + + err = SearchForId(kDacCertificateId, dacCertSpan.data(), dacCertSpan.size(), certificateSize); + ReturnErrorOnFailure(err); + dacCertSpan.reduce_size(certificateSize); + /* Extract Public Key of DAC certificate from itself */ + err = Crypto::ExtractPubkeyFromX509Cert(dacCertSpan, dacPublicKey); + ReturnErrorOnFailure(err); + + /* Get private key of DAC certificate from reserved section */ + uint8_t keyBuf[kMaxKeyLen]; + MutableByteSpan dacPrivateKeySpan(keyBuf); + uint16_t keySize = 0; + ReturnErrorOnFailure(SearchForId(kDacPrivateKeyId, dacPrivateKeySpan.data(), dacPrivateKeySpan.size(), keySize)); + dacPrivateKeySpan.reduce_size(keySize); + + ReturnErrorOnFailure(LoadKeypairFromRaw(ByteSpan(dacPrivateKeySpan.data(), dacPrivateKeySpan.size()), + ByteSpan(dacPublicKey.Bytes(), dacPublicKey.Length()), keypair)); + ReturnErrorOnFailure(keypair.ECDSA_sign_msg(messageToSign.data(), messageToSign.size(), signature)); + + return CopySpanToMutableSpan(ByteSpan{ signature.ConstBytes(), signature.Length() }, outSignBuffer); +} + +CHIP_ERROR K32W0FactoryDataProvider::GetSetupDiscriminator(uint16_t & setupDiscriminator) +{ + uint32_t discriminator = 0; + uint16_t temp = 0; + + ReturnErrorOnFailure(SearchForId(kDiscriminatorId, (uint8_t *) &discriminator, sizeof(discriminator), temp)); + setupDiscriminator = (uint16_t)(discriminator & 0x0000FFFF); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::SetSetupDiscriminator(uint16_t setupDiscriminator) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetSpake2pIterationCount(uint32_t & iterationCount) +{ + uint16_t temp = 0; + + return SearchForId(kIcId, (uint8_t *) &iterationCount, sizeof(iterationCount), temp); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetSpake2pSalt(MutableByteSpan & saltBuf) +{ + char saltB64[kSpake2pSalt_MaxBase64Len] = { 0 }; + uint16_t saltB64Len = 0; + + ReturnErrorOnFailure(SearchForId(kSaltId, (uint8_t *) (&saltB64[0]), sizeof(saltB64), saltB64Len)); + size_t saltLen = chip::Base64Decode32(saltB64, saltB64Len, reinterpret_cast(saltB64)); + + ReturnErrorCodeIf(saltLen > saltBuf.size(), CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(saltBuf.data(), saltB64, saltLen); + saltBuf.reduce_size(saltLen); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & verifierLen) +{ + char verifierB64[kSpake2pSerializedVerifier_MaxBase64Len] = { 0 }; + uint16_t verifierB64Len = 0; + ReturnErrorOnFailure(SearchForId(kVerifierId, (uint8_t *) &verifierB64[0], sizeof(verifierB64), verifierB64Len)); + + verifierLen = chip::Base64Decode32(verifierB64, verifierB64Len, reinterpret_cast(verifierB64)); + ReturnErrorCodeIf(verifierLen > verifierBuf.size(), CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(verifierBuf.data(), verifierB64, verifierLen); + verifierBuf.reduce_size(verifierLen); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetSetupPasscode(uint32_t & setupPasscode) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::SetSetupPasscode(uint32_t setupPasscode) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +#if CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER +CHIP_ERROR K32W0FactoryDataProvider::GetVendorName(char * buf, size_t bufSize) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetVendorId(uint16_t & vendorId) +{ + vendorId = static_cast(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID); + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetProductName(char * buf, size_t bufSize) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetProductId(uint16_t & productId) +{ + productId = static_cast(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID); + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetSerialNumber(char * buf, size_t bufSize) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetHardwareVersion(uint16_t & hardwareVersion) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetHardwareVersionString(char * buf, size_t bufSize) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) +{ +#if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID) +#endif + + return CHIP_ERROR_NOT_IMPLEMENTED; +} +#endif /* CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER */ +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/K32W0FactoryDataProvider.h b/src/platform/nxp/k32w/k32w0/K32W0FactoryDataProvider.h new file mode 100644 index 00000000000000..2b50b1e08b3aa7 --- /dev/null +++ b/src/platform/nxp/k32w/k32w0/K32W0FactoryDataProvider.h @@ -0,0 +1,79 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ +#pragma once + +#include +#include +#include + +#include "CHIPPlatformConfig.h" + +namespace chip { +namespace DeviceLayer { + +/** + * @brief This class provides Commissionable data, Device Attestation Credentials, + * and Device Instance Info. + */ + +class K32W0FactoryDataProvider : public CommissionableDataProvider, + public Credentials::DeviceAttestationCredentialsProvider +#if CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER + , + public DeviceInstanceInfoProvider +#endif // CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER +{ +public: + static K32W0FactoryDataProvider & GetDefaultInstance(); + + K32W0FactoryDataProvider() {} + + CHIP_ERROR Init(); + + // ===== Members functions that implement the CommissionableDataProvider + CHIP_ERROR GetSetupDiscriminator(uint16_t & setupDiscriminator) override; + CHIP_ERROR SetSetupDiscriminator(uint16_t setupDiscriminator) override; + CHIP_ERROR GetSpake2pIterationCount(uint32_t & iterationCount) override; + CHIP_ERROR GetSpake2pSalt(MutableByteSpan & saltBuf) override; + CHIP_ERROR GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & verifierLen) override; + CHIP_ERROR GetSetupPasscode(uint32_t & setupPasscode) override; + CHIP_ERROR SetSetupPasscode(uint32_t setupPasscode) override; + + // ===== Members functions that implement the DeviceAttestationCredentialsProvider + CHIP_ERROR GetCertificationDeclaration(MutableByteSpan & outBuffer) override; + CHIP_ERROR GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) override; + CHIP_ERROR GetDeviceAttestationCert(MutableByteSpan & outBuffer) override; + CHIP_ERROR GetProductAttestationIntermediateCert(MutableByteSpan & outBuffer) override; + CHIP_ERROR SignWithDeviceAttestationKey(const ByteSpan & messageToSign, MutableByteSpan & outSignBuffer) override; + +#if CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER + // ===== Members functions that implement the GenericDeviceInstanceInfoProvider + CHIP_ERROR GetVendorName(char * buf, size_t bufSize) override; + CHIP_ERROR GetVendorId(uint16_t & vendorId) override; + CHIP_ERROR GetProductName(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductId(uint16_t & productId) override; + CHIP_ERROR GetHardwareVersionString(char * buf, size_t bufSize) override; + CHIP_ERROR GetSerialNumber(char * buf, size_t bufSize) override; + CHIP_ERROR GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day) override; + CHIP_ERROR GetHardwareVersion(uint16_t & hardwareVersion) override; + + CHIP_ERROR GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) override; +#endif // CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/KeyValueStoreManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/KeyValueStoreManagerImpl.cpp index f2fbd071bc3654..29a06f4ee917fd 100644 --- a/src/platform/nxp/k32w/k32w0/KeyValueStoreManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/KeyValueStoreManagerImpl.cpp @@ -99,8 +99,7 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t } else { - ChipLogProgress(DeviceLayer, "KVS, error in getting the value of Matter key [%s]. Key not found in persistent storage.", - key); + ChipLogProgress(DeviceLayer, "KVS, Matter key [%s] not found in persistent storage.", key); } exit: diff --git a/src/platform/nxp/k32w/k32w0/Logging.cpp b/src/platform/nxp/k32w/k32w0/Logging.cpp index da545b6c7aff85..b00366999023ee 100644 --- a/src/platform/nxp/k32w/k32w0/Logging.cpp +++ b/src/platform/nxp/k32w/k32w0/Logging.cpp @@ -161,12 +161,15 @@ void ENFORCE_FORMAT(3, 0) LogV(const char * module, uint8_t category, const char */ extern "C" void ENFORCE_FORMAT(1, 2) LwIPLog(const char * msg, ...) { + +#if K32W_LOG_ENABLED va_list v; const char * module = "LWIP"; va_start(v, msg); GenericLog(msg, v, module, chip::Logging::kLogCategory_None); va_end(v); +#endif } #endif // CHIP_SYSTEM_CONFIG_USE_LWIP @@ -177,6 +180,8 @@ extern "C" void ENFORCE_FORMAT(1, 2) LwIPLog(const char * msg, ...) extern "C" void ENFORCE_FORMAT(3, 4) otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char * aFormat, ...) { + +#if K32W_LOG_ENABLED va_list v; const char * module = "OT"; @@ -186,6 +191,7 @@ extern "C" void ENFORCE_FORMAT(3, 4) otPlatLog(otLogLevel aLogLevel, otLogRegion va_start(v, aFormat); GenericLog(aFormat, v, module, chip::Logging::kLogCategory_None); va_end(v); +#endif } #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD diff --git a/src/platform/nxp/k32w/k32w0/LowPowerHooks.cpp b/src/platform/nxp/k32w/k32w0/LowPowerHooks.cpp new file mode 100644 index 00000000000000..1946feff8ad41f --- /dev/null +++ b/src/platform/nxp/k32w/k32w0/LowPowerHooks.cpp @@ -0,0 +1,321 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +/** + * @file + * Provides a glue layer between Matter and NXP-SDK Low Power + */ + +#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) + +#include +#include + +#include "Keyboard.h" +#include "MacSched.h" +#include "OtaSupport.h" +#include "PWR_Configuration.h" +#include "PWR_Interface.h" +#include "RNG_Interface.h" +#include "app_dual_mode_low_power.h" +#include "app_dual_mode_switch.h" +#include "k32w0-chip-mbedtls-config.h" +#include // nogncheck + +#include "app_config.h" +#include "fsl_gpio.h" +#include "fsl_iocon.h" +#include "gpio_pins.h" + +using namespace ::chip; +using namespace ::chip::Inet; +using namespace ::chip::DeviceLayer; + +extern "C" void InitLowPower(); + +extern "C" void vMMAC_IntHandlerBbc(); +extern "C" void vMMAC_IntHandlerPhy(); +extern "C" void BOARD_SetClockForPowerMode(void); +extern "C" void stopM2(); +extern "C" void sched_enable(); +extern "C" uint64_t otPlatTimeGet(void); + +static void dm_switch_wakeupCallBack(void); +static void dm_switch_preSleepCallBack(void); +static void ThreadExitSleep(); +static void BOARD_SetClockForWakeup(void); + +typedef struct +{ + bool_t bleAppRunning; + bool_t bleAppStopInprogress; + bool_t threadInitialized; + uint32_t threadWarmBootInitTime; +} sDualModeAppStates; + +typedef void * appCallbackParam_t; +typedef void (*appCallbackHandler_t)(appCallbackParam_t param); + +static sDualModeAppStates dualModeStates; +/* 15.4 warm time must be > 0, so this value will be + * updated when 15.4 is initialized for the first time + */ +constexpr uint16_t kThreadWarmNotInitializedValue = 0; + +extern "C" void otTaskletsSignalPending(otInstance * p_instance); + +#define ENABLE_LOW_POWER_LOGS 0 + +void InitLowPower() +{ + PWR_Init(); + + /* Internal - MATTER-303: keep in retention the entire RAM1 for the moment */ + PWR_vAddRamRetention((uint32_t) 0x4020000, 0x10000); + + PWR_RegisterLowPowerExitCallback(dm_switch_wakeupCallBack); + PWR_RegisterLowPowerEnterCallback(dm_switch_preSleepCallBack); + + dualModeStates.threadWarmBootInitTime = kThreadWarmNotInitializedValue; + + dm_lp_init(); +} + +extern "C" void setThreadInitialized(bool isInitialized) +{ + dualModeStates.threadInitialized = isInitialized; +} + +extern "C" bool isThreadInitialized() +{ + return dualModeStates.threadInitialized; +} + +uint32_t dm_switch_get15_4InitWakeUpTime(void) +{ + return dualModeStates.threadWarmBootInitTime; +} + +extern "C" bleResult_t App_PostCallbackMessage(appCallbackHandler_t handler, appCallbackParam_t param) +{ + AppEvent event; + event.Type = AppEvent::kEventType_Lp; + event.Handler = handler; + event.param = param; + +#if ENABLE_LOW_POWER_LOGS + K32W_LOG("App_PostCallbackMessage %d", (uint32_t) param); +#endif + + GetAppTask().PostEvent(&event); + + return gBleSuccess_c; +} + +static void dm_switch_wakeupCallBack(void) +{ + BOARD_SetClockForWakeup(); + SHA_ClkInit(SHA_INSTANCE); + CLOCK_EnableClock(kCLOCK_Aes); + +#if ENABLE_LOW_POWER_LOGS + K32W_LOG("dm_switch_wakeupCallBack"); + K32W_LOG("Warm up time actual value: %d", dualModeStates.threadWarmBootInitTime); +#endif + + RNG_Init(); + SecLib_Init(); + OTA_InitExternalMemory(); + + KBD_PrepareExitLowPower(); + + PWR_WakeupReason_t wakeReason = PWR_GetWakeupReason(); + if (wakeReason.Bits.FromBLE_LLTimer == 1) + { +#if ENABLE_LOW_POWER_LOGS + K32W_LOG("woken up from LL"); +#endif + } + else if (wakeReason.Bits.FromKeyBoard == 1) + { +#if ENABLE_LOW_POWER_LOGS + K32W_LOG("woken up from FromKeyBoard"); +#endif + } + else if (wakeReason.Bits.FromTMR == 1) + { +#if ENABLE_LOW_POWER_LOGS + K32W_LOG("woken up from TMR"); +#endif + } + dm_lp_wakeup(); +} + +void vOptimizeConsumption(uint32_t u32PIOvalue, uint32_t u32SkipIO) +{ + uint8_t u8KeepFro32k, u8KeepIOclk, u8KeepXtal32M; + + u8KeepFro32k = u32SkipIO >> 31; + u8KeepIOclk = (u32SkipIO >> 30) & 0x1; + u8KeepXtal32M = (u32SkipIO >> 29) & 0x1; + const gpio_pin_config_t pin_config = { .pinDirection = kGPIO_DigitalInput, .outputLogic = 1U }; + + if (u32PIOvalue != 0) + { + for (int i = 0; i < 22; i++) + { + + if (((u32SkipIO >> i) & 0x1) != 1) + { + /* configure GPIOs to Input mode */ + GPIO_PinInit(GPIO, 0, i, &pin_config); + IOCON_PinMuxSet(IOCON, 0, i, u32PIOvalue); + } + } + } + + if (u8KeepIOclk == 0) + { + CLOCK_DisableClock(kCLOCK_Iocon); + CLOCK_DisableClock(kCLOCK_InputMux); + CLOCK_DisableClock(kCLOCK_Gpio0); + } + + if (u8KeepXtal32M == 0) + { + CLOCK_DisableClock(kCLOCK_Xtal32M); // Crystal 32MHz + } + + // Keep the 32K clock + if (u8KeepFro32k == 0) + { + CLOCK_DisableClock(kCLOCK_Fro32k); + } +} + +static void dm_switch_preSleepCallBack(void) +{ +#if ENABLE_LOW_POWER_LOGS + K32W_LOG("dm_switch_preSleepCallBack"); +#endif + + if (dualModeStates.threadInitialized) + { + /* stop the internal MAC Scheduler timer */ + stopM2(); + /* disable the MAC scheduler */ + sched_disable(); + otPlatRadioDisable(NULL); + setThreadInitialized(FALSE); + } + /* Inform the low power dual mode module that we will sleep */ + dm_lp_preSleep(); + + EEPROM_DeInit(); + /* BUTTON2 change contact, BUTTON4 start adv/factoryreset */ + vOptimizeConsumption((IOCON_FUNC0 | (0x2 << 3) | IOCON_ANALOG_EN), + (1 << IOCON_USER_BUTTON1_PIN) | (1 << IOCON_USER_BUTTON2_PIN)); + + /* disable SHA clock */ + SHA_ClkDeinit(SHA_INSTANCE); + + /* disable the AES clock */ + CLOCK_DisableClock(kCLOCK_Aes); + + /* configure pins for power down mode */ + BOARD_SetPinsForPowerMode(); + /* DeInitialize application support for drivers */ + BOARD_DeInitAdc(); + /* DeInit the necessary clocks */ + BOARD_SetClockForPowerMode(); +} + +extern "C" void vDynStopAll(void) +{ + vDynRequestState(E_DYN_SLAVE, E_DYN_STATE_OFF); + vDynRequestState(E_DYN_MASTER, E_DYN_STATE_OFF); +} + +void dm_switch_init15_4AfterWakeUp(void) +{ + uint64_t tick1 = 0; + + if (dualModeStates.threadWarmBootInitTime == kThreadWarmNotInitializedValue) + { + /* Get a 32K tick */ + PWR_Start32kCounter(); + tick1 = otPlatTimeGet(); + } + + if (!dualModeStates.threadInitialized && ConnectivityMgr().IsThreadEnabled()) + { + OSA_InstallIntHandler(ZIGBEE_MAC_IRQn, vMMAC_IntHandlerBbc); + OSA_InstallIntHandler(ZIGBEE_MODEM_IRQn, vMMAC_IntHandlerPhy); + + /* Radio must be re-enabled after waking up from sleep. + * The module is completely disabled in power down mode */ + otPlatRadioEnable(NULL); + sched_enable(); + + if (dualModeStates.threadWarmBootInitTime == kThreadWarmNotInitializedValue) + { + dualModeStates.threadWarmBootInitTime = (uint32_t)(otPlatTimeGet() - tick1); + + /* Add a margin of 1 ms */ + dualModeStates.threadWarmBootInitTime += 1000; + +#if ENABLE_LOW_POWER_LOGS + K32W_LOG("Calibration: %d", dualModeStates.threadWarmBootInitTime); +#endif + } + + setThreadInitialized(TRUE); + + /* wake up the Thread stack and check if any processing needs to be done */ + otTaskletsSignalPending(NULL); + } +} + +extern "C" void App_NotifyWakeup(void) +{ + if ((!dualModeStates.threadInitialized)) + { + + /* Notify the dual mode low power mode */ + (void) App_PostCallbackMessage(dm_lp_processEvent, (void *) e15_4WakeUpEnded); + } +} + +extern "C" void App_AllowDeviceToSleep() +{ + PWR_PreventEnterLowPower(false); +} + +extern "C" void App_DisallowDeviceToSleep() +{ + PWR_PreventEnterLowPower(true); +} + +static void BOARD_SetClockForWakeup(void) +{ + /* Enables the clock for the I/O controller block. 0: Disable. 1: Enable.: 0x01u */ + CLOCK_EnableClock(kCLOCK_Iocon); + /* Enables the clock for the GPIO0 module */ + CLOCK_EnableClock(kCLOCK_Gpio0); +} + +#endif diff --git a/src/platform/nxp/k32w/k32w0/OTAImageProcessorImpl.cpp b/src/platform/nxp/k32w/k32w0/OTAImageProcessorImpl.cpp index a44d0cb1dfec6e..79dc3ff663fdc7 100644 --- a/src/platform/nxp/k32w/k32w0/OTAImageProcessorImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/OTAImageProcessorImpl.cpp @@ -17,6 +17,7 @@ */ #include +#include #include #include @@ -282,11 +283,13 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) { if (CHIP_NO_ERROR == K32WConfig::WriteConfigValueSync(K32WConfig::kConfigKey_FirstRunOfOTAImage, firstRun)) { - /* Set the necessary information to inform the SSBL that a new image is available */ - DeviceLayer::ConfigurationMgr().StoreSoftwareVersion(imageProcessor->mSoftwareVersion); - OTA_SetNewImageFlag(); ChipLogProgress(SoftwareUpdate, "OTA image authentication success. Device will reboot with the new image!"); - ResetMCU(); + // Set the necessary information to inform the SSBL that a new image is available + // and trigger the actual device reboot after some time, to take into account + // queued actions, e.g. sending events to a subscription + SystemLayer().StartTimer( + chip::System::Clock::Milliseconds32(CHIP_DEVICE_LAYER_OTA_REBOOT_DELAY), + [](chip::System::Layer *, void *) { OTA_SetNewImageFlag(); }, nullptr); } else { diff --git a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp index 5f00b346bddcde..8ac58946b3c21d 100644 --- a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp @@ -43,6 +43,7 @@ #include "MemManager.h" #include "RNG_Interface.h" +#include "SecLib.h" #include "TimersManager.h" #include "fsl_sha.h" #include "k32w0-chip-mbedtls-config.h" @@ -52,6 +53,10 @@ namespace DeviceLayer { PlatformManagerImpl PlatformManagerImpl::sInstance; +#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) +extern "C" void InitLowPower(); +#endif + #if defined(MBEDTLS_USE_TINYCRYPT) osaMutexId_t PlatformManagerImpl::rngMutexHandle = NULL; #endif @@ -78,11 +83,18 @@ CHIP_ERROR PlatformManagerImpl::InitBoardFwk(void) } RNG_SetPseudoRandomNoSeed(NULL); + SecLib_Init(); + TMR_Init(); /* Used for OT initializations */ otSysInit(1, argv); +#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) + /* Low Power Init */ + InitLowPower(); +#endif + exit: return err; } @@ -130,6 +142,8 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) goto exit; } + SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); + mStartTime = System::SystemClock().GetMonotonicTimestamp(); #if CHIP_SYSTEM_CONFIG_USE_LWIP diff --git a/src/platform/nxp/k32w/k32w0/RamStorage.cpp b/src/platform/nxp/k32w/k32w0/RamStorage.cpp deleted file mode 100644 index 4d23aa7024ad64..00000000000000 --- a/src/platform/nxp/k32w/k32w0/RamStorage.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * 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. - */ - -/** - * @file - * NVM Writes are time-consuming so instead of blocking the main tasks (e.g.: Matter) - * buffer the writes in a RAM buffer that gets to be written in the Idle Task - */ -#include -#include -#include - -#include "FunctionLib.h" -#include "RamStorage.h" - -#ifndef RAM_STORAGE_LOG -#define RAM_STORAGE_LOG 0 -#endif - -#include - -#if RAM_STORAGE_LOG -#include "fsl_debug_console.h" -#define RAM_STORAGE_PRINTF(...) \ - PRINTF("[%s] ", __FUNCTION__); \ - PRINTF(__VA_ARGS__); \ - PRINTF("\n\r"); -#else -#define RAM_STORAGE_PRINTF(...) -#endif - -/* increment size for dynamic memory re-allocation in case the - * initial RAM buffer size gets insufficient - */ -constexpr size_t kRamBufferReallocSize = 512; -constexpr size_t kRamBufferMaxAllocSize = 10240; - -ramBufferDescriptor * getRamBuffer(uint16_t nvmId, uint16_t initialSize) -{ - ramBufferDescriptor * ramDescr = NULL; - bool bLoadDataFromNvm = false; - uint16_t bytesRead = 0; - uint16_t recordSize = 0; - uint16_t allocSize = initialSize; - - /* Check if dataset is present and get its size */ - if (PDM_bDoesDataExist(nvmId, &recordSize)) - { - bLoadDataFromNvm = true; - while (recordSize > allocSize) - { - // increase size until NVM data fits - allocSize += kRamBufferReallocSize; - } - } - - if (allocSize <= kRamBufferMaxAllocSize) - { - ramDescr = (ramBufferDescriptor *) malloc(allocSize); - if (ramDescr) - { - ramDescr->ramBufferLen = 0; - ramDescr->ramBufferMaxLen = allocSize - kRamDescHeaderSize; - - if (bLoadDataFromNvm) - { - /* Try to load the dataset in RAM */ - if (PDM_E_STATUS_OK != PDM_eReadDataFromRecord(nvmId, ramDescr, recordSize, &bytesRead)) - { - memset(ramDescr, 0, allocSize); - } - } - } - } - - return ramDescr; -} - -static rsError ramStorageAdd(ramBufferDescriptor * pBuffer, uint16_t aKey, const uint8_t * aValue, uint16_t aValueLength) -{ - rsError error = RS_ERROR_NONE; - struct settingsBlock currentBlock = { 0 }; - const uint16_t newBlockLength = sizeof(settingsBlock) + aValueLength; - - if (pBuffer->ramBufferLen + newBlockLength <= pBuffer->ramBufferMaxLen) - { - currentBlock.key = aKey; - currentBlock.length = aValueLength; - - memcpy(&pBuffer->pRamBuffer[pBuffer->ramBufferLen], ¤tBlock, sizeof(settingsBlock)); - memcpy(&pBuffer->pRamBuffer[pBuffer->ramBufferLen + sizeof(settingsBlock)], aValue, aValueLength); - pBuffer->ramBufferLen += newBlockLength; - - error = RS_ERROR_NONE; - } - else - { - error = RS_ERROR_NO_BUFS; - } - - RAM_STORAGE_PRINTF("key = %d lengthWriten = %d err = %d", aKey, aValueLength, error); - - return error; -} - -rsError ramStorageGet(const ramBufferDescriptor * pBuffer, uint16_t aKey, int aIndex, uint8_t * aValue, uint16_t * aValueLength) -{ - uint16_t i = 0; - uint16_t valueLength = 0; - uint16_t readLength = 0; - int currentIndex = 0; - struct settingsBlock currentBlock = { 0 }; - rsError error = RS_ERROR_NOT_FOUND; - - while (i < pBuffer->ramBufferLen) - { - memcpy(¤tBlock, &pBuffer->pRamBuffer[i], sizeof(settingsBlock)); - - if (aKey == currentBlock.key) - { - if (currentIndex == aIndex) - { - readLength = currentBlock.length; - - // Perform read only if an input buffer was passed in - if (aValue != NULL && aValueLength != NULL) - { - // Adjust read length if input buffer size is smaller - if (readLength > *aValueLength) - { - readLength = *aValueLength; - } - - memcpy(aValue, &pBuffer->pRamBuffer[i + sizeof(settingsBlock)], readLength); - } - - valueLength = currentBlock.length; - error = RS_ERROR_NONE; - break; - } - - currentIndex++; - } - - i += sizeof(settingsBlock) + currentBlock.length; - } - - if (aValueLength != NULL) - { - *aValueLength = valueLength; - } - - RAM_STORAGE_PRINTF("key = %d err = %d", aKey, error); - - return error; -} - -static rsError ramStorageSetInternal(ramBufferDescriptor * pBuffer, uint16_t aKey, const uint8_t * aValue, uint16_t aValueLength) -{ - uint16_t i = 0; - uint16_t currentBlockLength = 0; - uint16_t nextBlockStart = 0; - struct settingsBlock currentBlock = { 0 }; - - // Delete all entries of aKey - while (i < pBuffer->ramBufferLen) - { - memcpy(¤tBlock, &pBuffer->pRamBuffer[i], sizeof(settingsBlock)); - currentBlockLength = sizeof(settingsBlock) + currentBlock.length; - - if (aKey == currentBlock.key) - { - nextBlockStart = i + currentBlockLength; - - if (nextBlockStart < pBuffer->ramBufferLen) - { - memmove(&pBuffer->pRamBuffer[i], &pBuffer->pRamBuffer[nextBlockStart], pBuffer->ramBufferLen - nextBlockStart); - } - - VerifyOrDie(pBuffer->ramBufferLen >= currentBlockLength); - pBuffer->ramBufferLen -= currentBlockLength; - } - else - { - i += currentBlockLength; - } - } - - return ramStorageAdd(pBuffer, aKey, aValue, aValueLength); -} - -rsError ramStorageSet(ramBufferDescriptor ** pBuffer, uint16_t aKey, const uint8_t * aValue, uint16_t aValueLength) -{ - rsError err = RS_ERROR_NONE; - uint16_t allocSize = (*pBuffer)->ramBufferMaxLen; - ramBufferDescriptor * ptr = NULL; - - if (allocSize <= (*pBuffer)->ramBufferLen + aValueLength) - { - while ((allocSize < (*pBuffer)->ramBufferLen + aValueLength)) - { - /* Need to realocate the memory buffer, increase size by kRamBufferReallocSize until NVM data fits */ - allocSize += kRamBufferReallocSize; - } - - allocSize += kRamDescHeaderSize; - - if (kRamBufferMaxAllocSize <= kRamBufferMaxAllocSize) - { - ptr = (ramBufferDescriptor *) realloc((void *) (*pBuffer), allocSize); - VerifyOrExit((NULL != ptr), err = RS_ERROR_NO_BUFS); - *pBuffer = ptr; - (*pBuffer)->ramBufferMaxLen = allocSize; - } - else - { - err = RS_ERROR_NO_BUFS; - } - } - - err = ramStorageSetInternal(*pBuffer, aKey, aValue, aValueLength); - -exit: - return err; -} - -rsError ramStorageDelete(ramBufferDescriptor * pBuffer, uint16_t aKey, int aIndex) -{ - uint16_t i = 0; - int currentIndex = 0; - uint16_t nextBlockStart = 0; - uint16_t currentBlockLength = 0; - struct settingsBlock currentBlock = { 0 }; - rsError error = RS_ERROR_NOT_FOUND; - - while (i < pBuffer->ramBufferLen) - { - memcpy(¤tBlock, &pBuffer->pRamBuffer[i], sizeof(settingsBlock)); - currentBlockLength = sizeof(settingsBlock) + currentBlock.length; - - if (aKey == currentBlock.key) - { - if (currentIndex == aIndex) - { - nextBlockStart = i + currentBlockLength; - - if (nextBlockStart < pBuffer->ramBufferLen) - { - memmove(&pBuffer->pRamBuffer[i], &pBuffer->pRamBuffer[nextBlockStart], pBuffer->ramBufferLen - nextBlockStart); - } - - VerifyOrDie(pBuffer->ramBufferLen >= currentBlockLength); - pBuffer->ramBufferLen -= currentBlockLength; - - error = RS_ERROR_NONE; - break; - } - else - { - currentIndex++; - } - } - - i += currentBlockLength; - } - RAM_STORAGE_PRINTF("key = %d err = %d", aKey, error); - return error; -} diff --git a/src/platform/nxp/k32w/k32w0/RamStorage.h b/src/platform/nxp/k32w/k32w0/RamStorage.h deleted file mode 100644 index b1bc0ea3ad2ad6..00000000000000 --- a/src/platform/nxp/k32w/k32w0/RamStorage.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * 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. - */ - -#pragma once - -typedef enum -{ - RS_ERROR_NONE, - RS_ERROR_NOT_FOUND, - RS_ERROR_NO_BUFS -} rsError; - -/* the structure used for keeping the records has the same structure both in RAM and in NVM: - * ramBufferLen | ramBufferMaxLen | settingsBlock | .... | settingsBlock - * - * ramBufferLen shows how much of the RAM buffer is currently occupied with settingsBlock structures - * ramBufferMaxLen shows the total malloc'ed size. Dynamic re-allocation is possible - */ -typedef struct -{ - uint16_t ramBufferLen; - uint16_t ramBufferMaxLen; - uint8_t pRamBuffer[1]; -} ramBufferDescriptor; - -struct settingsBlock -{ - uint16_t key; - uint16_t length; -} __attribute__((packed)); - -#define member_size(type, member) sizeof(((type *) 0)->member) - -constexpr size_t kRamDescHeaderSize = - member_size(ramBufferDescriptor, ramBufferLen) + member_size(ramBufferDescriptor, ramBufferMaxLen); - -/* Return a RAM buffer with initialSize and populated with the contents of NVM ID - if found in flash */ -ramBufferDescriptor * getRamBuffer(uint16_t nvmId, uint16_t initialSize); - -/* search pBuffer for aKey and return its value in aValue. aValueLength will contain the length of aValueLength */ -rsError ramStorageGet(const ramBufferDescriptor * pBuffer, uint16_t aKey, int aIndex, uint8_t * aValue, uint16_t * aValueLength); - -/* search pBuffer for aKey and set its value to aValue (having aValueLength length) */ -rsError ramStorageSet(ramBufferDescriptor ** pBuffer, uint16_t aKey, const uint8_t * aValue, uint16_t aValueLength); - -/* search pBuffer for aKey and delete it */ -rsError ramStorageDelete(ramBufferDescriptor * pBuffer, uint16_t aKey, int aIndex); diff --git a/src/platform/nxp/k32w/k32w0/SystemPlatformConfig.h b/src/platform/nxp/k32w/k32w0/SystemPlatformConfig.h index 084b759158d5f0..bda39157039697 100644 --- a/src/platform/nxp/k32w/k32w0/SystemPlatformConfig.h +++ b/src/platform/nxp/k32w/k32w0/SystemPlatformConfig.h @@ -37,6 +37,6 @@ struct ChipDeviceEvent; // ==================== Platform Adaptations ==================== #define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 1 #define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent * -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 7 +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 0 // ========== Platform-specific Configuration Overrides ========= diff --git a/src/platform/nxp/k32w/k32w0/SystemTimeSupport.cpp b/src/platform/nxp/k32w/k32w0/SystemTimeSupport.cpp new file mode 100644 index 00000000000000..48de1e30389b17 --- /dev/null +++ b/src/platform/nxp/k32w/k32w0/SystemTimeSupport.cpp @@ -0,0 +1,123 @@ +/* + * + * 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. + */ + +/** + * @file + * Provides implementations of the CHIP System Layer platform + * time/clock functions that are suitable for use on the K32W0 platform. + */ +/* this file behaves like a config.h, comes first */ +#include + +extern "C" uint64_t otPlatTimeGet(void); +extern "C" uint32_t otPlatAlarmMilliGetNow(void); + +namespace chip { +namespace System { +namespace Clock { + +namespace Internal { +ClockImpl gClockImpl; +} // namespace Internal + +namespace { + +uint64_t sBootTimeUS = 0; + +} // unnamed namespace + +Microseconds64 ClockImpl::GetMonotonicMicroseconds64(void) +{ + return Clock::Microseconds64(otPlatTimeGet()); +} + +Milliseconds64 ClockImpl::GetMonotonicMilliseconds64(void) +{ + return std::chrono::duration_cast(GetMonotonicMicroseconds64()); +} + +uint64_t GetClock_Monotonic(void) +{ + return otPlatTimeGet(); +} + +uint64_t GetClock_MonotonicMS(void) +{ + return (otPlatTimeGet() / 1000); +} + +uint64_t GetClock_MonotonicHiRes(void) +{ + return GetClock_Monotonic(); +} + +CHIP_ERROR ClockImpl::GetClock_RealTime(Clock::Microseconds64 & aCurTime) +{ + // TODO(19081): This platform does not properly error out if wall clock has + // not been set. For now, short circuit this. + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +#if 0 + if (sBootTimeUS == 0) + { + return CHIP_ERROR_REAL_TIME_NOT_SYNCED; + } + aCurTime = Clock::Microseconds64(sBootTimeUS + GetClock_Monotonic()); + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR ClockImpl::GetClock_RealTimeMS(Clock::Milliseconds64 & aCurTime) +{ + if (sBootTimeUS == 0) + { + return CHIP_ERROR_REAL_TIME_NOT_SYNCED; + } + aCurTime = Clock::Milliseconds64((sBootTimeUS + GetClock_Monotonic()) / 1000); + return CHIP_NO_ERROR; +} + +CHIP_ERROR ClockImpl::SetClock_RealTime(Clock::Microseconds64 aNewCurTime) +{ + uint64_t timeSinceBootUS = GetClock_Monotonic(); + if (aNewCurTime.count() > timeSinceBootUS) + { + sBootTimeUS = aNewCurTime.count() - timeSinceBootUS; + } + else + { + sBootTimeUS = 0; + } + return CHIP_NO_ERROR; +} + +CHIP_ERROR InitClock_RealTime() +{ + Clock::Microseconds64 curTime = + Clock::Microseconds64((static_cast(CHIP_SYSTEM_CONFIG_VALID_REAL_TIME_THRESHOLD) * UINT64_C(1000000))); + // Use CHIP_SYSTEM_CONFIG_VALID_REAL_TIME_THRESHOLD as the initial value of RealTime. + // Then the RealTime obtained from GetClock_RealTime will be always valid. + // + // TODO(19081): This is broken because it causes the platform to report + // that it does have wall clock time when it actually doesn't. + return System::SystemClock().SetClock_RealTime(curTime); +} + +} // namespace Clock +} // namespace System +} // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.cpp index 78ccc1b9b0abf3..af2d7421646739 100644 --- a/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.cpp @@ -36,6 +36,10 @@ #include +#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) +extern "C" bool isThreadInitialized(); +#endif + namespace chip { namespace DeviceLayer { @@ -62,6 +66,18 @@ CHIP_ERROR ThreadStackManagerImpl::InitThreadStack(otInstance * otInst) return err; } +void ThreadStackManagerImpl::ProcessThreadActivity() +{ + +#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) + if (isThreadInitialized()) +#endif + { + otTaskletsProcess(OTInstance()); + otSysProcessDrivers(OTInstance()); + } +} + bool ThreadStackManagerImpl::IsInitialized() { return sInstance.mThreadStackLock != NULL; diff --git a/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.h b/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.h index 5e68b31524d81b..5f7adcefec6cb1 100644 --- a/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.h +++ b/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.h @@ -72,6 +72,9 @@ class ThreadStackManagerImpl final : public ThreadStackManager, using ThreadStackManager::InitThreadStack; CHIP_ERROR InitThreadStack(otInstance * otInst); + using ThreadStackManager::ProcessThreadActivity; + void ProcessThreadActivity(); + private: // ===== Methods that implement the ThreadStackManager abstract interface. diff --git a/src/platform/nxp/k32w/k32w0/args.gni b/src/platform/nxp/k32w/k32w0/args.gni index 9aba65644b4394..0364287bd8196c 100644 --- a/src/platform/nxp/k32w/k32w0/args.gni +++ b/src/platform/nxp/k32w/k32w0/args.gni @@ -28,9 +28,15 @@ chip_build_tests = false chip_mdns = "platform" -# Trying to fit into the available flash by disabling optional logging for now -chip_detail_logging = false -chip_progress_logging = true +# Logs are enabled by default, but can be disabled by setting +# chip_logging=false in the build command. +# Alternatively, a user can overwrite the value for different logging levels +# by uncommenting the lines below and setting the corresponding value. +# A user can disable some logging levels to decrease flash usage. +#chip_detail_logging = true +#chip_progress_logging = true +#chip_automation_logging = true +#chip_error_logging = true chip_system_config_use_open_thread_inet_endpoints = true chip_with_lwip = false diff --git a/src/platform/nxp/k32w/k32w0/crypto/ksdk_mbedtls.c b/src/platform/nxp/k32w/k32w0/crypto/ksdk_mbedtls.c new file mode 100644 index 00000000000000..14f1070097393d --- /dev/null +++ b/src/platform/nxp/k32w/k32w0/crypto/ksdk_mbedtls.c @@ -0,0 +1,4324 @@ +/* + * Copyright 2015-2016, Freescale Semiconductor, Inc. + * Copyright 2017 NXP + * All rights reserved. + * + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "SecLib.h" + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "fsl_common.h" + +#if defined(FSL_FEATURE_SOC_LTC_COUNT) && (FSL_FEATURE_SOC_LTC_COUNT > 0) +#include "fsl_ltc.h" +#endif +#if defined(FSL_FEATURE_SOC_CAAM_COUNT) && (FSL_FEATURE_SOC_CAAM_COUNT > 0) +#include "fsl_caam.h" +#endif +#if defined(FSL_FEATURE_SOC_CAU3_COUNT) && (FSL_FEATURE_SOC_CAU3_COUNT > 0) +#include "fsl_cau3.h" +#endif +#if defined(FSL_FEATURE_SOC_DCP_COUNT) && (FSL_FEATURE_SOC_DCP_COUNT > 0) +#include "fsl_dcp.h" +#endif +#if defined(FSL_FEATURE_SOC_HASHCRYPT_COUNT) && (FSL_FEATURE_SOC_HASHCRYPT_COUNT > 0) +#include "fsl_hashcrypt.h" +#endif +#if defined(FSL_FEATURE_SOC_TRNG_COUNT) && (FSL_FEATURE_SOC_TRNG_COUNT > 0) +#if defined CPU_JN518X +#include "fsl_rng.h" +#else +#include "fsl_trng.h" +#endif +#elif defined(FSL_FEATURE_SOC_RNG_COUNT) && (FSL_FEATURE_SOC_RNG_COUNT > 0) +#include "fsl_rnga.h" +#elif defined(FSL_FEATURE_SOC_LPC_RNG1_COUNT) && (FSL_FEATURE_SOC_LPC_RNG1_COUNT > 0) +#include "fsl_rng.h" +#endif + +#define CLEAN_RETURN(value) \ + { \ + ret = value; \ + goto cleanup; \ + } + +/******************************************************************************/ +/*************************** CAAM *********************************************/ +/******************************************************************************/ +#if defined(FSL_FEATURE_SOC_CAAM_COUNT) && (FSL_FEATURE_SOC_CAAM_COUNT > 0) && defined(CRYPTO_USE_DRIVER_CAAM) +static caam_handle_t s_caamHandle = { .jobRing = kCAAM_JobRing0 }; +#endif + +/******************************************************************************/ +/*************************** CAU3 *********************************************/ +/******************************************************************************/ +#if defined(FSL_FEATURE_SOC_CAU3_COUNT) && (FSL_FEATURE_SOC_CAU3_COUNT > 0) +static cau3_handle_t s_cau3Handle = { .taskDone = MBEDTLS_CAU3_COMPLETION_SIGNAL, .keySlot = kCAU3_KeySlot0 }; +#endif + +/******************************************************************************/ +/**************************** DCP *********************************************/ +/******************************************************************************/ +#if defined(FSL_FEATURE_SOC_DCP_COUNT) && (FSL_FEATURE_SOC_DCP_COUNT > 0) +static dcp_handle_t s_dcpHandle = { .channel = kDCP_Channel0, .keySlot = kDCP_KeySlot0, .swapConfig = kDCP_NoSwap }; +#endif + +/******************************************************************************/ +/************************* Key slot management ********************************/ +/******************************************************************************/ +#if (defined(FSL_FEATURE_SOC_CAU3_COUNT) && (FSL_FEATURE_SOC_CAU3_COUNT > 0)) || (defined(MBEDTLS_FREESCALE_DCP_AES)) +static const void * s_mbedtlsCtx[4] = { 0 }; + +static void crypto_attach_ctx_to_key_slot(const void * ctx, uint8_t keySlot) +{ + s_mbedtlsCtx[keySlot] = ctx; +} + +static void crypto_detach_ctx_from_key_slot(const void * ctx) +{ + for (int i = 0; i < 4; i++) + { + if (ctx == s_mbedtlsCtx[i]) + { + s_mbedtlsCtx[i] = NULL; + break; + } + } +} + +static bool crypto_key_is_loaded(const void * ctx) +{ + bool ret = false; + for (int i = 0; i < 4; i++) + { + if (ctx == s_mbedtlsCtx[i]) + { + ret = true; + break; + } + } + return ret; +} +#endif + +#if defined(MBEDTLS_SHA1_ALT) || defined(MBEDTLS_SHA256_ALT) +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize(void * v, size_t n) +{ + volatile unsigned char * p = v; + while (n--) + *p++ = 0; +} +#endif /* MBEDTLS_SHA1_ALT || MBEDTLS_SHA256_ALT */ + +/******************************************************************************/ +/******************** CRYPTO_InitHardware **************************************/ +/******************************************************************************/ +/*! + * @brief Application init for various Crypto blocks. + * + * This function is provided to be called by MCUXpresso SDK applications. + * It calls basic init for Crypto Hw acceleration and Hw entropy modules. + */ +void CRYPTO_InitHardware(void) +{ +#if defined(FSL_FEATURE_SOC_LTC_COUNT) && (FSL_FEATURE_SOC_LTC_COUNT > 0) + /* Initialize LTC driver. + * This enables clocking and resets the module to a known state. */ + LTC_Init(LTC0); +#endif +#if defined(FSL_FEATURE_SOC_CAAM_COUNT) && (FSL_FEATURE_SOC_CAAM_COUNT > 0) && defined(CRYPTO_USE_DRIVER_CAAM) + /* Initialize CAAM driver. */ + caam_config_t caamConfig; + + CAAM_GetDefaultConfig(&caamConfig); + caamConfig.jobRingInterface[0] = &s_jrif0; + caamConfig.jobRingInterface[1] = &s_jrif1; + CAAM_Init(CAAM, &caamConfig); +#endif +#if defined(FSL_FEATURE_SOC_CAU3_COUNT) && (FSL_FEATURE_SOC_CAU3_COUNT > 0) + /* Initialize CAU3 */ + CAU3_Init(CAU3); +#endif +#if defined(FSL_FEATURE_SOC_DCP_COUNT) && (FSL_FEATURE_SOC_DCP_COUNT > 0) + /* Initialize DCP */ + dcp_config_t dcpConfig; + + DCP_GetDefaultConfig(&dcpConfig); + DCP_Init(DCP, &dcpConfig); +#endif +#if defined(FSL_FEATURE_SOC_CASPER_COUNT) && (FSL_FEATURE_SOC_CASPER_COUNT > 0) + /* Initialize CASPER */ + CASPER_Init(CASPER); +#endif +#if defined(FSL_FEATURE_SOC_HASHCRYPT_COUNT) && (FSL_FEATURE_SOC_HASHCRYPT_COUNT > 0) + /* Initialize HASHCRYPT */ + HASHCRYPT_Init(HASHCRYPT); +#endif + { /* Init RNG module.*/ +#if defined(FSL_FEATURE_SOC_TRNG_COUNT) && (FSL_FEATURE_SOC_TRNG_COUNT > 0) +#if defined CPU_JN518X +#if defined(RNG) +#define TRNG0 RNG +#endif +#else +#if defined(TRNG) +#define TRNG0 TRNG +#endif +#endif + trng_config_t trngConfig; + + TRNG_GetDefaultConfig(&trngConfig); + /* Set sample mode of the TRNG ring oscillator to Von Neumann, for better random data.*/ + /* Initialize TRNG */ + TRNG_Init(TRNG0, &trngConfig); +#elif defined(FSL_FEATURE_SOC_RNG_COUNT) && (FSL_FEATURE_SOC_RNG_COUNT > 0) + RNGA_Init(RNG); + RNGA_Seed(RNG, SIM->UIDL); +#endif + } +} + +/******************************************************************************/ +/*************************** DES **********************************************/ +/******************************************************************************/ + +#if defined(MBEDTLS_DES_C) + +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_MMCAU_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) || \ + defined(MBEDTLS_FREESCALE_CAU3_DES) + +#include "mbedtls/des.h" + +#if defined(MBEDTLS_FREESCALE_MMCAU_DES) +const unsigned char parityLookup[128] = { 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, + 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, + 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, + 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, + 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }; +#endif + +#if defined(MBEDTLS_FREESCALE_MMCAU_DES) || defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) +/* + * DES key schedule (56-bit, encryption) + */ +int mbedtls_des_setkey_enc(mbedtls_des_context * ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE]) +{ +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) + memcpy(ctx->sk, key, MBEDTLS_DES_KEY_SIZE); +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + int i; + unsigned char * sk_b = (unsigned char *) ctx->sk; + + /* fix key parity, if needed */ + for (i = 0; i < MBEDTLS_DES_KEY_SIZE; i++) + { + sk_b[i] = ((key[i] & 0xFE) | parityLookup[key[i] >> 1]); + } +#endif + ctx->mode = MBEDTLS_DES_ENCRYPT; + + return (0); +} + +/* + * DES key schedule (56-bit, decryption) + */ +int mbedtls_des_setkey_dec(mbedtls_des_context * ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE]) +{ +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) + memcpy(ctx->sk, key, MBEDTLS_DES_KEY_SIZE); +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + int i; + unsigned char * sk_b = (unsigned char *) ctx->sk; + + /* fix key parity, if needed */ + for (i = 0; i < MBEDTLS_DES_KEY_SIZE; i++) + { + sk_b[i] = ((key[i] & 0xFE) | parityLookup[key[i] >> 1]); + } +#endif + ctx->mode = MBEDTLS_DES_DECRYPT; + + return (0); +} +#endif /* MBEDTLS_FREESCALE_MMCAU_DES || MBEDTLS_FREESCALE_LTC_DES || MBEDTLS_FREESCALE_CAAM_DES */ + +/* + * Triple-DES key schedule (112-bit, encryption) + */ +int mbedtls_des3_set2key_enc(mbedtls_des3_context * ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2]) +{ +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) || defined(MBEDTLS_FREESCALE_CAU3_DES) + memcpy(ctx->sk, key, MBEDTLS_DES_KEY_SIZE * 2); + memcpy(&ctx->sk[4], key, MBEDTLS_DES_KEY_SIZE); /* K3 = K1 */ +#if defined(MBEDTLS_FREESCALE_CAU3_DES) + crypto_detach_ctx_from_key_slot(ctx); +#endif +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + int i; + unsigned char * sk_b = (unsigned char *) ctx->sk; + + /* fix key parity, if needed */ + for (i = 0; i < MBEDTLS_DES_KEY_SIZE * 2; i++) + { + sk_b[i] = ((key[i] & 0xFE) | parityLookup[key[i] >> 1]); + } + for (i = MBEDTLS_DES_KEY_SIZE * 2; i < MBEDTLS_DES_KEY_SIZE * 3; i++) + { + sk_b[i] = ((key[i - MBEDTLS_DES_KEY_SIZE * 2] & 0xFE) | parityLookup[key[i - MBEDTLS_DES_KEY_SIZE * 2] >> 1]); + } +#endif + ctx->mode = MBEDTLS_DES_ENCRYPT; + + return (0); +} + +/* + * Triple-DES key schedule (112-bit, decryption) + */ +int mbedtls_des3_set2key_dec(mbedtls_des3_context * ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2]) +{ +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) || defined(MBEDTLS_FREESCALE_CAU3_DES) + memcpy(ctx->sk, key, MBEDTLS_DES_KEY_SIZE * 2); + memcpy(&ctx->sk[4], key, MBEDTLS_DES_KEY_SIZE); /* K3 = K1 */ +#if defined(MBEDTLS_FREESCALE_CAU3_DES) + crypto_detach_ctx_from_key_slot(ctx); +#endif +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + int i; + unsigned char * sk_b = (unsigned char *) ctx->sk; + + /* fix key parity, if needed */ + for (i = 0; i < MBEDTLS_DES_KEY_SIZE * 2; i++) + { + sk_b[i] = ((key[i] & 0xFE) | parityLookup[key[i] >> 1]); + } + for (i = MBEDTLS_DES_KEY_SIZE * 2; i < MBEDTLS_DES_KEY_SIZE * 3; i++) + { + sk_b[i] = ((key[i - MBEDTLS_DES_KEY_SIZE * 2] & 0xFE) | parityLookup[key[i - MBEDTLS_DES_KEY_SIZE * 2] >> 1]); + } +#endif + ctx->mode = MBEDTLS_DES_DECRYPT; + + return (0); +} + +/* + * Triple-DES key schedule (168-bit, encryption) + */ +int mbedtls_des3_set3key_enc(mbedtls_des3_context * ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3]) +{ +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) || defined(MBEDTLS_FREESCALE_CAU3_DES) + memcpy(ctx->sk, key, MBEDTLS_DES_KEY_SIZE * 3); +#if defined(MBEDTLS_FREESCALE_CAU3_DES) + crypto_detach_ctx_from_key_slot(ctx); +#endif +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + int i; + unsigned char * sk_b = (unsigned char *) ctx->sk; + + /* fix key parity, if needed */ + for (i = 0; i < MBEDTLS_DES_KEY_SIZE * 3; i++) + { + sk_b[i] = ((key[i] & 0xFE) | parityLookup[key[i] >> 1]); + } +#endif + ctx->mode = MBEDTLS_DES_ENCRYPT; + + return (0); +} + +/* + * Triple-DES key schedule (168-bit, decryption) + */ +int mbedtls_des3_set3key_dec(mbedtls_des3_context * ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3]) +{ +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) || defined(MBEDTLS_FREESCALE_CAU3_DES) + memcpy(ctx->sk, key, MBEDTLS_DES_KEY_SIZE * 3); +#if defined(MBEDTLS_FREESCALE_CAU3_DES) + crypto_detach_ctx_from_key_slot(ctx); +#endif +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + int i; + unsigned char * sk_b = (unsigned char *) ctx->sk; + + /* fix key parity, if needed */ + for (i = 0; i < MBEDTLS_DES_KEY_SIZE * 3; i++) + { + sk_b[i] = ((key[i] & 0xFE) | parityLookup[key[i] >> 1]); + } +#endif + ctx->mode = MBEDTLS_DES_DECRYPT; + return (0); +} + +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_MMCAU_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) +/* + * DES-ECB block encryption/decryption + */ +int mbedtls_des_crypt_ecb(mbedtls_des_context * ctx, const unsigned char input[8], unsigned char output[8]) +{ + uint8_t * key = (uint8_t *) ctx->sk; +#if defined(MBEDTLS_FREESCALE_LTC_DES) + if (ctx->mode == MBEDTLS_DES_ENCRYPT) + { + LTC_DES_EncryptEcb(LTC_INSTANCE, input, output, 8, key); + } + else + { + LTC_DES_DecryptEcb(LTC_INSTANCE, input, output, 8, key); + } +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + if (ctx->mode == MBEDTLS_DES_ENCRYPT) + { + MMCAU_DES_EncryptEcb(input, key, output); + } + else + { + MMCAU_DES_DecryptEcb(input, key, output); + } +#elif defined(MBEDTLS_FREESCALE_CAAM_DES) + if (ctx->mode == MBEDTLS_DES_ENCRYPT) + { + CAAM_DES_EncryptEcb(CAAM_INSTANCE, &s_caamHandle, input, output, 8, key); + } + else + { + CAAM_DES_DecryptEcb(CAAM_INSTANCE, &s_caamHandle, input, output, 8, key); + } +#endif + return (0); +} +#endif /* MBEDTLS_FREESCALE_LTC_DES || MBEDTLS_FREESCALE_MMCAU_DES || MBEDTLS_FREESCALE_CAAM_DES */ + +/* + * 3DES-ECB block encryption/decryption + */ +int mbedtls_des3_crypt_ecb(mbedtls_des3_context * ctx, const unsigned char input[8], unsigned char output[8]) +{ + uint8_t * key = (uint8_t *) ctx->sk; +#if defined(MBEDTLS_FREESCALE_LTC_DES) + if (ctx->mode == MBEDTLS_DES_ENCRYPT) + { + LTC_DES3_EncryptEcb(LTC_INSTANCE, input, output, 8, key, key + 8, key + 16); + } + else + { + LTC_DES3_DecryptEcb(LTC_INSTANCE, input, output, 8, key, key + 8, key + 16); + } +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + if (ctx->mode == MBEDTLS_DES_ENCRYPT) + { + MMCAU_DES_EncryptEcb(input, key, output); + MMCAU_DES_DecryptEcb(output, key + 8, output); + MMCAU_DES_EncryptEcb(output, key + 16, output); + } + else + { + MMCAU_DES_DecryptEcb(input, key + 16, output); + MMCAU_DES_EncryptEcb(output, key + 8, output); + MMCAU_DES_DecryptEcb(output, key, output); + } +#elif defined(MBEDTLS_FREESCALE_CAAM_DES) + if (ctx->mode == MBEDTLS_DES_ENCRYPT) + { + CAAM_DES3_EncryptEcb(CAAM_INSTANCE, &s_caamHandle, input, output, 8, key, key + 8, key + 16); + } + else + { + CAAM_DES3_DecryptEcb(CAAM_INSTANCE, &s_caamHandle, input, output, 8, key, key + 8, key + 16); + } +#elif defined(MBEDTLS_FREESCALE_CAU3_DES) + if (!crypto_key_is_loaded(ctx)) + { + CAU3_TDES_SetKey(CAU3, &s_cau3Handle, key, 24); + crypto_attach_ctx_to_key_slot(ctx, s_cau3Handle.keySlot); + } + + if (ctx->mode == MBEDTLS_DES_ENCRYPT) + { + CAU3_TDES_Encrypt(CAU3, &s_cau3Handle, input, output); + } + else + { + CAU3_TDES_Decrypt(CAU3, &s_cau3Handle, input, output); + } +#endif + return (0); +} + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/* + * DES-CBC buffer encryption/decryption + */ +#if defined(MBEDTLS_FREESCALE_LTC_DES) +int mbedtls_des_crypt_cbc(mbedtls_des_context * ctx, int mode, size_t length, unsigned char iv[8], const unsigned char * input, + unsigned char * output) +{ + unsigned char temp[8]; + uint8_t * key = (uint8_t *) ctx->sk; + + if (length % 8) + return (MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH); + + if (mode == MBEDTLS_DES_ENCRYPT) + { + LTC_DES_EncryptCbc(LTC_INSTANCE, input, output, length, iv, key); + memcpy(iv, output + length - 8, 8); + } + else /* MBEDTLS_DES_DECRYPT */ + { + memcpy(temp, input + length - 8, 8); + LTC_DES_DecryptCbc(LTC_INSTANCE, input, output, length, iv, key); + memcpy(iv, temp, 8); + } + return (0); +} + +/* + * 3DES-CBC buffer encryption/decryption + */ +int mbedtls_des3_crypt_cbc(mbedtls_des3_context * ctx, int mode, size_t length, unsigned char iv[8], const unsigned char * input, + unsigned char * output) +{ + unsigned char temp[8]; + uint8_t * key = (uint8_t *) ctx->sk; + + if (length % 8) + return (MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH); + + if (mode == MBEDTLS_DES_ENCRYPT) + { + LTC_DES3_EncryptCbc(LTC_INSTANCE, input, output, length, iv, key, key + 8, key + 16); + memcpy(iv, output + length - 8, 8); + } + else /* MBEDTLS_DES_DECRYPT */ + { + memcpy(temp, input + length - 8, 8); + LTC_DES3_DecryptCbc(LTC_INSTANCE, input, output, length, iv, key, key + 8, key + 16); + memcpy(iv, temp, 8); + } + + return (0); +} +#elif defined(MBEDTLS_FREESCALE_CAAM_DES) +int mbedtls_des_crypt_cbc(mbedtls_des_context * ctx, int mode, size_t length, unsigned char iv[8], const unsigned char * input, + unsigned char * output) +{ + unsigned char temp[8]; + uint8_t * key = (uint8_t *) ctx->sk; + + if (length % 8) + return (MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH); + + if (mode == MBEDTLS_DES_ENCRYPT) + { + CAAM_DES_EncryptCbc(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, key); + memcpy(iv, output + length - 8, 8); + } + else /* MBEDTLS_DES_DECRYPT */ + { + memcpy(temp, input + length - 8, 8); + CAAM_DES_DecryptCbc(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, key); + memcpy(iv, temp, 8); + } + return (0); +} + +/* + * 3DES-CBC buffer encryption/decryption + */ +int mbedtls_des3_crypt_cbc(mbedtls_des3_context * ctx, int mode, size_t length, unsigned char iv[8], const unsigned char * input, + unsigned char * output) +{ + unsigned char temp[8]; + uint8_t * key = (uint8_t *) ctx->sk; + + if (length % 8) + return (MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH); + + if (mode == MBEDTLS_DES_ENCRYPT) + { + CAAM_DES3_EncryptCbc(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, key, key + 8, key + 16); + memcpy(iv, output + length - 8, 8); + } + else /* MBEDTLS_DES_DECRYPT */ + { + memcpy(temp, input + length - 8, 8); + CAAM_DES3_DecryptCbc(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, key, key + 8, key + 16); + memcpy(iv, temp, 8); + } + + return (0); +} + +#endif /* MBEDTLS_FREESCALE_LTC_DES */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#endif /*MBEDTLS_FREESCALE_LTC_DES || MBEDTLS_FREESCALE_MMCAU_DES || MBEDTLS_FREESCALE_CAAM_DES*/ + +#endif /* MBEDTLS_DES_C */ + +/******************************************************************************/ +/*************************** AES **********************************************/ +/******************************************************************************/ + +#if defined(MBEDTLS_AES_C) + +#if defined(MBEDTLS_FREESCALE_LTC_AES) || defined(MBEDTLS_FREESCALE_MMCAU_AES) || defined(MBEDTLS_FREESCALE_LPC_AES) || \ + defined(MBEDTLS_FREESCALE_CAU3_AES) || defined(MBEDTLS_FREESCALE_CAAM_AES) || defined(MBEDTLS_FREESCALE_DCP_AES) + +#include "mbedtls/aes.h" + +/* + * AES key schedule (encryption) + */ +int mbedtls_aes_setkey_enc(mbedtls_aes_context * ctx, const unsigned char * key, unsigned int keybits) +{ + uint32_t * RK; + +#ifdef MBEDTLS_AES_ALT_NO_192 + if (keybits == 192u) + { + return (MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE); + } +#endif + +#ifdef MBEDTLS_AES_ALT_NO_256 + if (keybits == 256u) + { + return (MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE); + } +#endif + +#if defined(MBEDTLS_FREESCALE_LTC_AES) || defined(MBEDTLS_FREESCALE_LPC_AES) || defined(MBEDTLS_FREESCALE_CAU3_AES) || \ + defined(MBEDTLS_FREESCALE_CAAM_AES) || defined(MBEDTLS_FREESCALE_DCP_AES) + const unsigned char * key_tmp = key; + ctx->rk = RK = ctx->buf; + memcpy(RK, key_tmp, keybits / 8); + +#if defined(MBEDTLS_FREESCALE_CAU3_AES) || defined(MBEDTLS_FREESCALE_DCP_AES) + crypto_detach_ctx_from_key_slot(ctx); +#endif /* MBEDTLS_FREESCALE_CAU3_AES || MBEDTLS_FREESCALE_DCP_AES */ + + switch (keybits) + { /* Set keysize in bytes.*/ + case 128: + ctx->nr = 16; + break; + case 192: + ctx->nr = 24; + break; + case 256: + ctx->nr = 32; + break; + default: + return (MBEDTLS_ERR_AES_INVALID_KEY_LENGTH); + } +#elif defined(MBEDTLS_FREESCALE_MMCAU_AES) + ctx->rk = RK = ctx->buf; + + switch (keybits) + { + case 128: + ctx->nr = 10; + break; + case 192: + ctx->nr = 12; + break; + case 256: + ctx->nr = 14; + break; + default: + return (MBEDTLS_ERR_AES_INVALID_KEY_LENGTH); + } + + MMCAU_AES_SetKey(key, keybits / 8, (uint8_t *) RK); +#endif + + return (0); +} + +/* + * AES key schedule (decryption) + */ +int mbedtls_aes_setkey_dec(mbedtls_aes_context * ctx, const unsigned char * key, unsigned int keybits) +{ + uint32_t * RK; + +#ifdef MBEDTLS_AES_ALT_NO_192 + if (keybits == 192u) + { + return (MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE); + } +#endif + +#ifdef MBEDTLS_AES_ALT_NO_256 + if (keybits == 256u) + { + return (MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE); + } +#endif + + ctx->rk = RK = ctx->buf; + +#if defined(MBEDTLS_FREESCALE_LTC_AES) || defined(MBEDTLS_FREESCALE_LPC_AES) || defined(MBEDTLS_FREESCALE_CAU3_AES) || \ + defined(MBEDTLS_FREESCALE_CAAM_AES) || defined(MBEDTLS_FREESCALE_DCP_AES) + const unsigned char * key_tmp = key; + memcpy(RK, key_tmp, keybits / 8); + +#if defined(MBEDTLS_FREESCALE_CAU3_AES) || defined(MBEDTLS_FREESCALE_DCP_AES) + crypto_detach_ctx_from_key_slot(ctx); +#endif /* MBEDTLS_FREESCALE_CAU3_AES || MBEDTLS_FREESCALE_DCP_AES */ + + switch (keybits) + { + case 128: + ctx->nr = 16; + break; + case 192: + ctx->nr = 24; + break; + case 256: + ctx->nr = 32; + break; + default: + return (MBEDTLS_ERR_AES_INVALID_KEY_LENGTH); + } +#elif defined(MBEDTLS_FREESCALE_MMCAU_AES) + ctx->rk = RK = ctx->buf; + + switch (keybits) + { + case 128: + ctx->nr = 10; + break; + case 192: + ctx->nr = 12; + break; + case 256: + ctx->nr = 14; + break; + default: + return (MBEDTLS_ERR_AES_INVALID_KEY_LENGTH); + } + + MMCAU_AES_SetKey(key, keybits / 8, (uint8_t *) RK); +#endif + + return 0; +} + +/* + * AES-ECB block encryption + */ +int mbedtls_internal_aes_encrypt(mbedtls_aes_context * ctx, const unsigned char input[16], unsigned char output[16]) +{ + uint8_t * key; + + key = (uint8_t *) ctx->rk; +#if defined(MBEDTLS_FREESCALE_LTC_AES) + LTC_AES_EncryptEcb(LTC_INSTANCE, input, output, 16, key, ctx->nr); +#elif defined(MBEDTLS_FREESCALE_MMCAU_AES) + MMCAU_AES_EncryptEcb(input, key, ctx->nr, output); +#elif defined(MBEDTLS_FREESCALE_CAU3_AES) + if (!crypto_key_is_loaded(ctx)) + { + CAU3_AES_SetKey(CAU3, &s_cau3Handle, key, ctx->nr); + crypto_attach_ctx_to_key_slot(ctx, s_cau3Handle.keySlot); + } + CAU3_AES_Encrypt(CAU3, &s_cau3Handle, input, output); +#elif defined(MBEDTLS_FREESCALE_LPC_AES) + AES_128_Encrypt(input, key, output); +#elif defined(MBEDTLS_FREESCALE_CAAM_AES) + CAAM_AES_EncryptEcb(CAAM_INSTANCE, &s_caamHandle, input, output, 16, key, ctx->nr); +#elif defined(MBEDTLS_FREESCALE_DCP_AES) + if (!crypto_key_is_loaded(ctx)) + { + DCP_AES_SetKey(DCP, &s_dcpHandle, key, ctx->nr); + crypto_attach_ctx_to_key_slot(ctx, s_dcpHandle.keySlot); + } + DCP_AES_EncryptEcb(DCP, &s_dcpHandle, input, output, 16); +#endif + + return (0); +} + +/* + * AES-ECB block decryption + */ +int mbedtls_internal_aes_decrypt(mbedtls_aes_context * ctx, const unsigned char input[16], unsigned char output[16]) +{ + uint8_t * key; + + key = (uint8_t *) ctx->rk; +#if defined(MBEDTLS_FREESCALE_LTC_AES) + LTC_AES_DecryptEcb(LTC_INSTANCE, input, output, 16, key, ctx->nr, kLTC_EncryptKey); +#elif defined(MBEDTLS_FREESCALE_MMCAU_AES) + MMCAU_AES_DecryptEcb(input, key, ctx->nr, output); +#elif defined(MBEDTLS_FREESCALE_CAU3_AES) + if (!crypto_key_is_loaded(ctx)) + { + CAU3_AES_SetKey(CAU3, &s_cau3Handle, key, ctx->nr); + crypto_attach_ctx_to_key_slot(ctx, s_cau3Handle.keySlot); + } + CAU3_AES_Decrypt(CAU3, &s_cau3Handle, input, output); +#elif defined(MBEDTLS_FREESCALE_LPC_AES) + AES_128_Decrypt(input, key, output); +#elif defined(MBEDTLS_FREESCALE_CAAM_AES) + CAAM_AES_DecryptEcb(CAAM_INSTANCE, &s_caamHandle, input, output, 16, key, ctx->nr); +#elif defined(MBEDTLS_FREESCALE_DCP_AES) + if (!crypto_key_is_loaded(ctx)) + { + DCP_AES_SetKey(DCP, &s_dcpHandle, key, ctx->nr); + crypto_attach_ctx_to_key_slot(ctx, s_dcpHandle.keySlot); + } + DCP_AES_DecryptEcb(DCP, &s_dcpHandle, input, output, 16); +#endif + + return (0); +} + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/* + * AES-CBC buffer encryption/decryption + */ +#if defined(MBEDTLS_FREESCALE_LTC_AES) +int mbedtls_aes_crypt_cbc(mbedtls_aes_context * ctx, int mode, size_t length, unsigned char iv[16], const unsigned char * input, + unsigned char * output) +{ + uint8_t * key = (uint8_t *) ctx->rk; + uint32_t keySize = ctx->nr; + + if (length % 16) + return (MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH); + + if (mode == MBEDTLS_AES_DECRYPT) + { + uint8_t tmp[16]; + memcpy(tmp, input + length - 16, 16); + LTC_AES_DecryptCbc(LTC_INSTANCE, input, output, length, iv, key, keySize, kLTC_EncryptKey); + memcpy(iv, tmp, 16); + } + else + { + LTC_AES_EncryptCbc(LTC_INSTANCE, input, output, length, iv, key, keySize); + memcpy(iv, output + length - 16, 16); + } + + return (0); +} +#elif defined(MBEDTLS_FREESCALE_LPC_AES) +int mbedtls_aes_crypt_cbc(mbedtls_aes_context * ctx, int mode, size_t length, unsigned char iv[16], const unsigned char * input, + unsigned char * output) +{ + uint8_t * key; + size_t keySize; + + if (length % 16) + return (MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH); + + key = (uint8_t *) ctx->rk; + keySize = (size_t) ctx->nr; + + if (mode == MBEDTLS_AES_DECRYPT) + { + uint8_t tmp[16]; + memcpy(tmp, input + length - 16, 16); + AES_128_CBC_Decrypt_And_Depad(tmp, length, iv, key, output); + memcpy(iv, tmp, 16); + } + else + { + AES_128_CBC_Encrypt(input, length, iv, key, output); + memcpy(iv, output + length - 16, 16); + } + + return (0); +} +#elif defined(MBEDTLS_FREESCALE_CAAM_AES) +int mbedtls_aes_crypt_cbc(mbedtls_aes_context * ctx, int mode, size_t length, unsigned char iv[16], const unsigned char * input, + unsigned char * output) +{ + uint8_t * key = (uint8_t *) ctx->rk; + uint32_t keySize = ctx->nr; + + if (length % 16) + return (MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH); + + if (mode == MBEDTLS_AES_DECRYPT) + { + uint8_t tmp[16]; + memcpy(tmp, input + length - 16, 16); + CAAM_AES_DecryptCbc(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, key, keySize); + memcpy(iv, tmp, 16); + } + else + { + CAAM_AES_EncryptCbc(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, key, keySize); + memcpy(iv, output + length - 16, 16); + } + + return (0); +} +#elif defined(MBEDTLS_FREESCALE_DCP_AES) +int mbedtls_aes_crypt_cbc(mbedtls_aes_context * ctx, int mode, size_t length, unsigned char iv[16], const unsigned char * input, + unsigned char * output) +{ + uint8_t * key; + + if (length % 16) + return (MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH); + + key = (uint8_t *) ctx->rk; + if (!crypto_key_is_loaded(ctx)) + { + DCP_AES_SetKey(DCP, &s_dcpHandle, key, ctx->nr); + crypto_attach_ctx_to_key_slot(ctx, s_dcpHandle.keySlot); + } + + if (mode == MBEDTLS_AES_DECRYPT) + { + uint8_t tmp[16]; + memcpy(tmp, input + length - 16, 16); + DCP_AES_DecryptCbc(DCP, &s_dcpHandle, input, output, length, iv); + memcpy(iv, tmp, 16); + } + else + { + DCP_AES_EncryptCbc(DCP, &s_dcpHandle, input, output, length, iv); + memcpy(iv, output + length - 16, 16); + } + + return (0); +} +#endif +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +#if defined(MBEDTLS_FREESCALE_LPC_AES) +/* + * AES-CFB128 buffer encryption/decryption + */ +int mbedtls_aes_crypt_cfb128(mbedtls_aes_context * ctx, int mode, size_t length, size_t * iv_off, unsigned char iv[16], + const unsigned char * input, unsigned char * output) +{ + uint8_t * key; + size_t keySize; + + key = (uint8_t *) ctx->rk; + keySize = (size_t) ctx->nr; + AES_SetKey(AES_INSTANCE, key, keySize); + + if (mode == MBEDTLS_AES_DECRYPT) + { + AES_DecryptCfb(AES_INSTANCE, input, output, length, iv); + } + else + { + AES_EncryptCfb(AES_INSTANCE, input, output, length, iv); + } + + return (0); +} + +/* + * AES-CFB8 buffer encryption/decryption + */ +int mbedtls_aes_crypt_cfb8(mbedtls_aes_context * ctx, int mode, size_t length, unsigned char iv[16], const unsigned char * input, + unsigned char * output) +{ + int status; + unsigned char c; + unsigned char ov[17]; + + while (length--) + { + memcpy(ov, iv, 16); + status = mbedtls_aes_crypt_ecb(ctx, MBEDTLS_AES_ENCRYPT, iv, iv); + if (status != 0) + { + return status; + } + + if (mode == MBEDTLS_AES_DECRYPT) + ov[16] = *input; + + c = *output++ = (unsigned char) (iv[0] ^ *input++); + + if (mode == MBEDTLS_AES_ENCRYPT) + ov[16] = c; + + memcpy(iv, ov + 1, 16); + } + + return (0); +} +#endif /* MBEDTLS_FREESCALE_LPC_AES */ +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +/* + * AES-CTR buffer encryption/decryption + */ +#if defined(MBEDTLS_FREESCALE_LTC_AES) +int mbedtls_aes_crypt_ctr(mbedtls_aes_context * ctx, size_t length, size_t * nc_off, unsigned char nonce_counter[16], + unsigned char stream_block[16], const unsigned char * input, unsigned char * output) +{ + uint8_t * key; + uint32_t keySize; + + key = (uint8_t *) ctx->rk; + keySize = ctx->nr; + LTC_AES_CryptCtr(LTC_INSTANCE, input, output, length, nonce_counter, key, keySize, stream_block, (uint32_t *) nc_off); + + return (0); +} +#elif defined(MBEDTLS_FREESCALE_LPC_AES) +int mbedtls_aes_crypt_ctr(mbedtls_aes_context * ctx, size_t length, size_t * nc_off, unsigned char nonce_counter[16], + unsigned char stream_block[16], const unsigned char * input, unsigned char * output) +{ + uint8_t * key; + size_t keySize; + + key = (uint8_t *) ctx->rk; + keySize = (size_t) ctx->nr; + + AES_128_CTR(input, length, nonce_counter, key, output); + + return (0); +} +#elif defined(MBEDTLS_FREESCALE_CAAM_AES) +int mbedtls_aes_crypt_ctr(mbedtls_aes_context * ctx, size_t length, size_t * nc_off, unsigned char nonce_counter[16], + unsigned char stream_block[16], const unsigned char * input, unsigned char * output) +{ + uint8_t * key; + uint32_t keySize; + + key = (uint8_t *) ctx->rk; + keySize = ctx->nr; + + CAAM_AES_CryptCtr(CAAM_INSTANCE, &s_caamHandle, input, output, length, nonce_counter, key, keySize, stream_block, nc_off); + + return (0); +} +#endif +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +#if defined(MBEDTLS_CIPHER_CMAC_ALT) && defined(MBEDTLS_CMAC_C) + +#include "mbedtls/cipher.h" +#include "mbedtls/cmac.h" + +#if defined(MBEDTLS_FREESCALE_CAU3_CIPHER_CMAC) +int mbedtls_cipher_cmac(const mbedtls_cipher_info_t * cipher_info, const unsigned char * key, size_t keylen, + const unsigned char * input, size_t ilen, unsigned char * output) +{ + mbedtls_cipher_context_t ctx; + int ret; + + if (cipher_info == NULL || key == NULL || input == NULL || output == NULL) + return (MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA); + + mbedtls_cipher_init(&ctx); + + if ((ret = mbedtls_cipher_setup(&ctx, cipher_info)) != 0) + goto exit; + + ret = mbedtls_cipher_cmac_starts(&ctx, key, keylen); + if (ret != 0) + goto exit; + + /* AES-CMAC-128 is directly supported by CAU3 firmware */ + if (cipher_info->type == MBEDTLS_CIPHER_AES_128_ECB) + { + status_t status; + uint8_t mac[16]; + + status = CAU3_AES_SetKey(CAU3, &s_cau3Handle, key, keylen / 8u); + if (status != kStatus_Success) + { + ret = MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; + goto exit; + } + status = CAU3_AES_Cmac(CAU3, &s_cau3Handle, input, ilen, mac); + if (status != kStatus_Success) + { + ret = MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; + goto exit; + } + memcpy(output, mac, 16); + } +#if defined(MBEDTLS_CIPHER_CMAC_TDES_ENABLED) || defined(MBEDTLS_CIPHER_CMAC_AES_256_ENABLED) + else if (cipher_info->type == MBEDTLS_CIPHER_AES_192_ECB) + { + /* CAU3 initial firmware does not support AES 192 */ + ret = MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; + goto exit; + } + else + { + /* AES-CMAC-256 and TDES-CMAC. + * If both MBEDTLS_DES_C and MBEDTLS_CIPHER_CMAC_WANTS_AES_256 are undefined, + * this does not compile + */ + ret = mbedtls_cipher_cmac_update(&ctx, input, ilen); + if (ret != 0) + goto exit; + + ret = mbedtls_cipher_cmac_finish(&ctx, output); + } +#else + else + { + ret = MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; + goto exit; + } +#endif /* MBEDTLS_CIPHER_CMAC_TDES_ENABLED || MBEDTLS_CIPHER_CMAC_AES_256_ENABLED */ + +exit: + mbedtls_cipher_free(&ctx); + + return (ret); +} +#endif /* MBEDTLS_FREESCALE_CAU3_CIPHER_CMAC */ +#endif /* MBEDTLS_CIPHER_CMAC_ALT && MBEDTLS_CMAC_C */ + +#if defined(MBEDTLS_CCM_C) + +#include "mbedtls/ccm.h" + +#define CCM_ENCRYPT 0 +#define CCM_DECRYPT 1 + +/* + * Authenticated encryption or decryption + */ +#if defined(MBEDTLS_FREESCALE_LTC_AES) +static int ccm_auth_crypt(mbedtls_ccm_context * ctx, int mode, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * input, unsigned char * output, + unsigned char * tag, size_t tag_len) +{ + status_t status; + const uint8_t * key; + uint8_t keySize; + mbedtls_aes_context * aes_ctx; + + aes_ctx = (mbedtls_aes_context *) ctx->cipher_ctx.cipher_ctx; + key = (uint8_t *) aes_ctx->rk; + keySize = aes_ctx->nr; + if (mode == CCM_ENCRYPT) + { + status = LTC_AES_EncryptTagCcm(LTC_INSTANCE, input, output, length, iv, iv_len, add, add_len, key, keySize, tag, tag_len); + } + else + { + status = LTC_AES_DecryptTagCcm(LTC_INSTANCE, input, output, length, iv, iv_len, add, add_len, key, keySize, tag, tag_len); + } + + if (status == kStatus_InvalidArgument) + { + return MBEDTLS_ERR_CCM_BAD_INPUT; + } + else if (status != kStatus_Success) + { + return MBEDTLS_ERR_CCM_AUTH_FAILED; + } + + return (0); +} +#elif defined(MBEDTLS_FREESCALE_CAAM_AES) +static int ccm_auth_crypt(mbedtls_ccm_context * ctx, int mode, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * input, unsigned char * output, + unsigned char * tag, size_t tag_len) +{ + status_t status; + const uint8_t * key; + uint8_t keySize; + mbedtls_aes_context * aes_ctx; + + aes_ctx = (mbedtls_aes_context *) ctx->cipher_ctx.cipher_ctx; + key = (uint8_t *) aes_ctx->rk; + keySize = aes_ctx->nr; + if (mode == CCM_ENCRYPT) + { + status = CAAM_AES_EncryptTagCcm(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, iv_len, add, add_len, key, keySize, + tag, tag_len); + } + else + { + status = CAAM_AES_DecryptTagCcm(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, iv_len, add, add_len, key, keySize, + tag, tag_len); + } + + if (status == kStatus_InvalidArgument) + { + return MBEDTLS_ERR_CCM_BAD_INPUT; + } + else if (status != kStatus_Success) + { + return MBEDTLS_ERR_CCM_AUTH_FAILED; + } + + return (0); +} +#endif /* MBEDTLS_FREESCALE_LTC_AES */ + +#if defined(MBEDTLS_FREESCALE_LTC_AES) || defined(MBEDTLS_FREESCALE_CAAM_AES) +/* + * Authenticated encryption + */ +int mbedtls_ccm_encrypt_and_tag(mbedtls_ccm_context * ctx, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * input, unsigned char * output, + unsigned char * tag, size_t tag_len) +{ + return (ccm_auth_crypt(ctx, CCM_ENCRYPT, length, iv, iv_len, add, add_len, input, output, tag, tag_len)); +} + +/* + * Authenticated decryption + */ +int mbedtls_ccm_auth_decrypt(mbedtls_ccm_context * ctx, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * input, unsigned char * output, + const unsigned char * tag, size_t tag_len) +{ + unsigned char tagCopy[16]; + unsigned char * actTag = NULL; + if (tag) + { + memcpy(tagCopy, tag, tag_len); + actTag = tagCopy; + } + return (ccm_auth_crypt(ctx, CCM_DECRYPT, length, iv, iv_len, add, add_len, input, output, actTag, tag_len)); +} +#endif /* MBEDTLS_FREESCALE_LTC_AES || MBEDTLS_FREESCALE_CAAM_AES */ +#endif /* MBEDTLS_CCM_C */ + +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_FREESCALE_LTC_AES_GCM) + +#include "mbedtls/gcm.h" + +int mbedtls_gcm_crypt_and_tag(mbedtls_gcm_context * ctx, int mode, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * input, unsigned char * output, + size_t tag_len, unsigned char * tag) +{ + status_t status; + uint8_t * key; + uint32_t keySize; + mbedtls_aes_context * aes_ctx; + + ctx->len = length; + ctx->add_len = add_len; + aes_ctx = (mbedtls_aes_context *) ctx->cipher_ctx.cipher_ctx; + key = (uint8_t *) aes_ctx->rk; + keySize = aes_ctx->nr; + if (mode == MBEDTLS_GCM_ENCRYPT) + { + status = LTC_AES_EncryptTagGcm(LTC_INSTANCE, input, output, length, iv, iv_len, add, add_len, key, keySize, tag, tag_len); + } + else + { + status = LTC_AES_DecryptTagGcm(LTC_INSTANCE, input, output, length, iv, iv_len, add, add_len, key, keySize, tag, tag_len); + } + + if (status == kStatus_InvalidArgument) + { + return MBEDTLS_ERR_GCM_BAD_INPUT; + } + else if (status != kStatus_Success) + { + return MBEDTLS_ERR_GCM_AUTH_FAILED; + } + + return 0; +} + +int mbedtls_gcm_auth_decrypt(mbedtls_gcm_context * ctx, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * tag, size_t tag_len, + const unsigned char * input, unsigned char * output) +{ + unsigned char tag_copy[16]; + unsigned char * actTag = NULL; + if (tag) + { + memcpy(tag_copy, tag, tag_len); + actTag = tag_copy; + } + return (mbedtls_gcm_crypt_and_tag(ctx, MBEDTLS_GCM_DECRYPT, length, iv, iv_len, add, add_len, input, output, tag_len, actTag)); +} + +#elif defined(MBEDTLS_FREESCALE_LPC_AES_GCM) + +#include "mbedtls/gcm.h" + +int mbedtls_gcm_crypt_and_tag(mbedtls_gcm_context * ctx, int mode, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * input, unsigned char * output, + size_t tag_len, unsigned char * tag) +{ + status_t status; + uint8_t * key; + size_t keySize; + mbedtls_aes_context * aes_ctx; + + ctx->len = length; + ctx->add_len = add_len; + aes_ctx = (mbedtls_aes_context *) ctx->cipher_ctx.cipher_ctx; + key = (uint8_t *) aes_ctx->rk; + keySize = (size_t) aes_ctx->nr; + + status = AES_SetKey(AES_INSTANCE, key, keySize); + if (status != kStatus_Success) + { + return MBEDTLS_ERR_GCM_BAD_INPUT; + } + + if (mode == MBEDTLS_GCM_ENCRYPT) + { + status = AES_EncryptTagGcm(AES_INSTANCE, input, output, length, iv, iv_len, add, add_len, tag, tag_len); + } + else + { + status = AES_DecryptTagGcm(AES_INSTANCE, input, output, length, iv, iv_len, add, add_len, tag, tag_len); + } + + if (status == kStatus_InvalidArgument) + { + return MBEDTLS_ERR_GCM_BAD_INPUT; + } + else if (status != kStatus_Success) + { + return MBEDTLS_ERR_GCM_AUTH_FAILED; + } + + return 0; +} + +int mbedtls_gcm_auth_decrypt(mbedtls_gcm_context * ctx, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * tag, size_t tag_len, + const unsigned char * input, unsigned char * output) +{ + unsigned char tag_copy[16]; + + memcpy(tag_copy, tag, tag_len); + return ( + mbedtls_gcm_crypt_and_tag(ctx, MBEDTLS_GCM_DECRYPT, length, iv, iv_len, add, add_len, input, output, tag_len, tag_copy)); +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_AES_GCM) + +#include "mbedtls/gcm.h" + +int mbedtls_gcm_crypt_and_tag(mbedtls_gcm_context * ctx, int mode, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * input, unsigned char * output, + size_t tag_len, unsigned char * tag) +{ + status_t status; + uint8_t * key; + uint32_t keySize; + mbedtls_aes_context * aes_ctx; + + ctx->len = length; + ctx->add_len = add_len; + aes_ctx = (mbedtls_aes_context *) ctx->cipher_ctx.cipher_ctx; + key = (uint8_t *) aes_ctx->rk; + keySize = aes_ctx->nr; + if (mode == MBEDTLS_GCM_ENCRYPT) + { + status = CAAM_AES_EncryptTagGcm(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, iv_len, add, add_len, key, keySize, + tag, tag_len); + } + else + { + status = CAAM_AES_DecryptTagGcm(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, iv_len, add, add_len, key, keySize, + tag, tag_len); + } + + if (status == kStatus_InvalidArgument) + { + return MBEDTLS_ERR_GCM_BAD_INPUT; + } + else if (status != kStatus_Success) + { + return MBEDTLS_ERR_GCM_AUTH_FAILED; + } + + return 0; +} + +int mbedtls_gcm_auth_decrypt(mbedtls_gcm_context * ctx, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * tag, size_t tag_len, + const unsigned char * input, unsigned char * output) +{ + unsigned char tag_copy[16]; + unsigned char * actTag = NULL; + if (tag) + { + memcpy(tag_copy, tag, tag_len); + actTag = tag_copy; + } + return (mbedtls_gcm_crypt_and_tag(ctx, MBEDTLS_GCM_DECRYPT, length, iv, iv_len, add, add_len, input, output, tag_len, actTag)); +} +#endif +#endif /* MBEDTLS_GCM_C */ + +#endif /* MBEDTLS_FREESCALE_LTC_AES || MBEDTLS_FREESCALE_MMCAU_AES || MBEDTLS_FREESCALE_LPC_AES */ + +#endif /* MBEDTLS_AES_C */ + +/******************************************************************************/ +/*************************** PKHA *********************************************/ +/******************************************************************************/ + +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) || defined(MBEDTLS_FREESCALE_CAAM_PKHA) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +static void ltc_reverse_array(uint8_t * src, size_t src_len) +{ + int i; + + for (i = 0; i < src_len / 2; i++) + { + uint8_t tmp; + + tmp = src[i]; + src[i] = src[src_len - 1 - i]; + src[src_len - 1 - i] = tmp; + } +} + +#if defined(MBEDTLS_BIGNUM_C) + +#include "mbedtls/bignum.h" + +#if defined(MBEDTLS_FREESCALE_CAU3_PKHA) +#define LTC_PKHA_ModAdd CAU3_PKHA_ModAdd +#define LTC_PKHA_ModSub1 CAU3_PKHA_ModSub1 +#define LTC_PKHA_ModMul CAU3_PKHA_ModMul +#define LTC_PKHA_ModRed CAU3_PKHA_ModRed +#define LTC_PKHA_ModExp CAU3_PKHA_ModExp +#define LTC_PKHA_GCD CAU3_PKHA_ModGcd +#define LTC_PKHA_ModInv CAU3_PKHA_ModInv +#define LTC_PKHA_PrimalityTest CAU3_PKHA_PrimalityTest +#define LTC_INSTANCE ((CAU3_Type *) CAU3_BASE) + +#define kLTC_PKHA_IntegerArith kCAU3_PKHA_IntegerArith +#define kLTC_PKHA_NormalValue kCAU3_PKHA_NormalValue +#define kLTC_PKHA_TimingEqualized kCAU3_PKHA_TimingEqualized + +#define cau3_reverse_array ltc_reverse_array +#define cau3_get_from_mbedtls_mpi ltc_get_from_mbedtls_mpi +#endif + +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) +typedef uint16_t pkha_size_t; +#else +typedef size_t pkha_size_t; +#endif + +#if defined(MBEDTLS_MPI_ADD_ABS_ALT) + +/* Access to original version of mbedtls_mpi_add_abs function. */ +int mbedtls_mpi_add_abs_orig(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B); + +/* + * Unsigned addition: X = |A| + |B| (HAC 14.7) + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_add_abs(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + pkha_size_t sizeN = FREESCALE_PKHA_INT_MAX_BYTES; + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + /* + * Perform HW acceleration only if the size in bytes is less than maximum. + * Since modular add is used below, the result would be wrong + * if the real sum of operands exceeded LTC maximum number value. + */ + if ((sizeA < sizeN) && (sizeB < sizeN)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * N = mbedtls_calloc(4, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrA = N + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == N) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + memset(N, 0xFF, sizeN); + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + ltc_reverse_array(ptrA, sizeA); + + mbedtls_mpi_write_binary(B, ptrB, sizeB); + ltc_reverse_array(ptrB, sizeB); + + ret = (int) LTC_PKHA_ModAdd(LTC_INSTANCE, ptrA, sizeA, ptrB, sizeB, N, sizeN, ptrC, &sizeC, kLTC_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + ltc_reverse_array(ptrC, sizeC); + mbedtls_mpi_read_binary(X, ptrC, sizeC); + X->s = 1; + cleanup: + if (N) + { + mbedtls_free(N); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_add_abs_orig(X, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_add_abs(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + pkha_size_t sizeN = FREESCALE_PKHA_INT_MAX_BYTES; + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + /* + * Perform HW acceleration only if the size in bytes is less than maximum. + * Since modular add is used below, the result would be wrong + * if the real sum of operands exceeded CAAM maximum number value. + */ + if ((sizeA < sizeN) && (sizeB < sizeN)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * N = mbedtls_calloc(4, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrA = N + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == N) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + memset(N, 0xFF, sizeN); + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + mbedtls_mpi_write_binary(B, ptrB, sizeB); + + ret = (int) CAAM_PKHA_ModAdd(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrB, sizeB, N, sizeN, ptrC, &sizeC, + kCAAM_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + mbedtls_mpi_read_binary(X, ptrC, sizeC); + X->s = 1; + cleanup: + if (N) + { + mbedtls_free(N); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_add_abs_orig(X, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_ADD_ABS_ALT */ + +#if defined(MBEDTLS_MPI_SUB_ABS_ALT) + +/* Access to original version of mbedtls_mpi_sub_abs function. */ +int mbedtls_mpi_sub_abs_orig(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B); + +/* + * Unsigned subtraction: X = |A| - |B| (HAC 14.9) + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_sub_abs(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + pkha_size_t sizeN = FREESCALE_PKHA_INT_MAX_BYTES; + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + /* + * Perform HW acceleration only if |A| >= |B|. Since modular subtraction is used below, + * the result would be wrong if the real sum of operands exceeded maximum. + */ + if ((sizeA <= sizeN) && (sizeB <= sizeN) && (mbedtls_mpi_cmp_abs(A, B) >= 0)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * N = mbedtls_calloc(4, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrA = N + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == N) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + memset(N, 0xFF, sizeN); + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + ltc_reverse_array(ptrA, sizeA); + + mbedtls_mpi_write_binary(B, ptrB, sizeB); + ltc_reverse_array(ptrB, sizeB); + + ret = (int) LTC_PKHA_ModSub1(LTC_INSTANCE, ptrA, sizeA, ptrB, sizeB, N, sizeN, ptrC, &sizeC); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + ltc_reverse_array(ptrC, sizeC); + mbedtls_mpi_read_binary(X, ptrC, sizeC); + X->s = 1; + cleanup: + if (N) + { + mbedtls_free(N); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_sub_abs_orig(X, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_sub_abs(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + pkha_size_t sizeN = FREESCALE_PKHA_INT_MAX_BYTES; + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + /* + * Perform HW acceleration only if |A| >= |B|. Since modular subtraction is used below, + * the result would be wrong if the real sum of operands exceeded maximum. + */ + if ((sizeA <= sizeN) && (sizeB <= sizeN) && (mbedtls_mpi_cmp_abs(A, B) >= 0)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * N = mbedtls_calloc(4, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrA = N + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == N) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + memset(N, 0xFF, sizeN); + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + mbedtls_mpi_write_binary(B, ptrB, sizeB); + + ret = (int) CAAM_PKHA_ModSub1(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrB, sizeB, N, sizeN, ptrC, &sizeC); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + mbedtls_mpi_read_binary(X, ptrC, sizeC); + X->s = 1; + cleanup: + if (N) + { + mbedtls_free(N); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_sub_abs_orig(X, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_SUB_ABS_ALT */ + +#if defined(MBEDTLS_MPI_MUL_MPI_ALT) + +/* Access to original version of mbedtls_mpi_mul_mpi function. */ +int mbedtls_mpi_mul_mpi_orig(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B); + +/* + * Baseline multiplication: X = A * B (HAC 14.12) + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_mul_mpi(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + pkha_size_t sizeN = FREESCALE_PKHA_INT_MAX_BYTES; + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + /* + * Should be "if ((sizeA + sizeB) <= sizeN)", but if the multiplication result + * would be maximum LTC number (the same value as the modulus N below), + * zero would be returned instead, which is wrong value. + */ + if ((sizeA + sizeB) < sizeN) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + int sign = A->s * B->s; + + uint8_t * N = mbedtls_calloc(4, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrA = N + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == N) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + memset(N, 0xFF, sizeN); + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + ltc_reverse_array(ptrA, sizeA); + + mbedtls_mpi_write_binary(B, ptrB, sizeB); + ltc_reverse_array(ptrB, sizeB); + + /* + * Modular multiplication operation is used here. Since the modulus N is larger + * than the expected result of A * B, the effect is normal multiplication. + * TODO use PKHA MUL_IM_OM instead. + */ + ret = (int) LTC_PKHA_ModMul(LTC_INSTANCE, ptrA, sizeA, ptrB, sizeB, N, sizeN, ptrC, &sizeC, kLTC_PKHA_IntegerArith, + kLTC_PKHA_NormalValue, kLTC_PKHA_NormalValue, kLTC_PKHA_TimingEqualized); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + ltc_reverse_array(ptrC, sizeC); + mbedtls_mpi_read_binary(X, ptrC, sizeC); + X->s = sign; + cleanup: + if (N) + { + mbedtls_free(N); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_mul_mpi_orig(X, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_mul_mpi(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + pkha_size_t sizeN = FREESCALE_PKHA_INT_MAX_BYTES; + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + /* + * Should be "if ((sizeA + sizeB) <= sizeN)", but if the multiplication result + * would be maximum CAAM number (the same value as the modulus N below), + * zero would be returned instead, which is wrong value. + */ + if ((sizeA + sizeB) < sizeN) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + int sign = A->s * B->s; + + uint8_t * N = mbedtls_calloc(4, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrA = N + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == N) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + memset(N, 0xFF, sizeN); + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + mbedtls_mpi_write_binary(B, ptrB, sizeB); + + /* + * Modular multiplication operation is used here. Since the modulus N is larger + * than the expected result of A * B, the effect is normal multiplication. + * TODO use PKHA MUL_IM_OM instead. + */ + ret = (int) CAAM_PKHA_ModMul(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrB, sizeB, N, sizeN, ptrC, &sizeC, + kCAAM_PKHA_IntegerArith, kCAAM_PKHA_NormalValue, kCAAM_PKHA_NormalValue, + kCAAM_PKHA_TimingEqualized); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + mbedtls_mpi_read_binary(X, ptrC, sizeC); + X->s = sign; + cleanup: + if (N) + { + mbedtls_free(N); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_mul_mpi_orig(X, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_MUL_MPI_ALT */ + +#if defined(MBEDTLS_MPI_MOD_MPI_ALT) + +/* Access to original version of mbedtls_mpi_mod_mpi function. */ +int mbedtls_mpi_mod_mpi_orig(mbedtls_mpi * R, const mbedtls_mpi * A, const mbedtls_mpi * B); + +/* + * Modulo: R = A mod B + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_mod_mpi(mbedtls_mpi * R, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeA <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeB <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + int sign = A->s; + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + ltc_reverse_array(ptrA, sizeA); + + mbedtls_mpi_write_binary(B, ptrB, sizeB); + ltc_reverse_array(ptrB, sizeB); + + ret = (int) LTC_PKHA_ModRed(LTC_INSTANCE, ptrA, sizeA, ptrB, sizeB, ptrC, &sizeC, kLTC_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + ltc_reverse_array(ptrC, sizeC); + mbedtls_mpi_read_binary(R, ptrC, sizeC); + R->s = sign; + + while (mbedtls_mpi_cmp_int(R, 0) < 0) + mbedtls_mpi_add_mpi(R, R, B); /* MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( R, R, B ) ); */ + + while (mbedtls_mpi_cmp_mpi(R, B) >= 0) + mbedtls_mpi_sub_mpi(R, R, B); /* MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( R, R, B ) ); cleanup:*/ + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_mod_mpi_orig(R, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_mod_mpi(mbedtls_mpi * R, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeA <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeB <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + int sign = A->s; + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + mbedtls_mpi_write_binary(B, ptrB, sizeB); + + ret = (int) CAAM_PKHA_ModRed(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrB, sizeB, ptrC, &sizeC, kCAAM_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + mbedtls_mpi_read_binary(R, ptrC, sizeC); + R->s = sign; + + while (mbedtls_mpi_cmp_int(R, 0) < 0) + mbedtls_mpi_add_mpi(R, R, B); /* MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( R, R, B ) ); */ + + while (mbedtls_mpi_cmp_mpi(R, B) >= 0) + mbedtls_mpi_sub_mpi(R, R, B); /* MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( R, R, B ) ); cleanup:*/ + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_mod_mpi_orig(R, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_MOD_MPI_ALT */ + +#if defined(MBEDTLS_MPI_EXP_MOD_ALT) + +/* Access to original version of mbedtls_mpi_exp_mod function. */ +int mbedtls_mpi_exp_mod_orig(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * E, const mbedtls_mpi * N, + mbedtls_mpi * _RR); + +/* + * Sliding-window exponentiation: X = A^E mod N (HAC 14.85) + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_exp_mod(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * E, const mbedtls_mpi * N, mbedtls_mpi * _RR) +{ + int ret; + pkha_size_t sizeE = mbedtls_mpi_size(E); + pkha_size_t sizeN = mbedtls_mpi_size(N); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeE <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeN <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + mbedtls_mpi * AA; // TODO rename etc. + + /* + * If number is greater than modulus, we must first reduce it due to LTC requirement + * on modular exponentiaton that it needs number less than modulus. + * We can take advantage of modular arithmetic rule that: A^B mod C = ( (A mod C)^B ) mod C. + * So we do (A mod N) first and if the size of A in bytes fits into LTC, it will be done in LTC + * (here LTC does not give size requirement on A versus N), otherwise it will be done in SW + * and since the size of N fits into LTC, the result of (A mod N) will also fit into LTC. + * Then we can do modular exponentiation in LTC. + */ + if (mbedtls_mpi_cmp_mpi(A, N) >= 0) + { + /* A >= N, perform X = (A mod N). */ + ret = mbedtls_mpi_mod_mpi(X, A, N); + + if (ret != kStatus_Success) + return (MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + /* Exponenciation will be performed with X. */ + AA = X; + } + else + { + /* Exponentiation will be performed with original A. */ + AA = (mbedtls_mpi *) A; + } + + pkha_size_t sizeA = mbedtls_mpi_size(AA); + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrE = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrN = ptrE + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(AA, ptrA, sizeA); + ltc_reverse_array(ptrA, sizeA); + + mbedtls_mpi_write_binary(E, ptrE, sizeE); + ltc_reverse_array(ptrE, sizeE); + + mbedtls_mpi_write_binary(N, ptrN, sizeN); + ltc_reverse_array(ptrN, sizeN); + + ret = (int) LTC_PKHA_ModExp(LTC_INSTANCE, ptrA, sizeA, ptrN, sizeN, ptrE, sizeE, ptrN, &sizeN, kLTC_PKHA_IntegerArith, + kLTC_PKHA_NormalValue, kLTC_PKHA_TimingEqualized); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + ltc_reverse_array(ptrN, sizeN); + mbedtls_mpi_read_binary(X, ptrN, sizeN); + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_exp_mod_orig(X, A, E, N, _RR); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_exp_mod(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * E, const mbedtls_mpi * N, mbedtls_mpi * _RR) +{ + int ret; + pkha_size_t sizeE = mbedtls_mpi_size(E); + pkha_size_t sizeN = mbedtls_mpi_size(N); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeE <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeN <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + mbedtls_mpi * AA; // TODO rename etc. + + /* + * If number is greater than modulus, we must first reduce it due to CAAM requirement + * on modular exponentiaton that it needs number less than modulus. + * We can take advantage of modular arithmetic rule that: A^B mod C = ( (A mod C)^B ) mod C. + * So we do (A mod N) first and if the size of A in bytes fits into CAAM, it will be done in CAAM + * (here CAAM does not give size requirement on A versus N), otherwise it will be done in SW + * and since the size of N fits into CAAM, the result of (A mod N) will also fit into CAAM. + * Then we can do modular exponentiation in CAAM. + */ + if (mbedtls_mpi_cmp_mpi(A, N) >= 0) + { + /* A >= N, perform X = (A mod N). */ + ret = mbedtls_mpi_mod_mpi(X, A, N); + + if (ret != kStatus_Success) + return (MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + /* Exponenciation will be performed with X. */ + AA = X; + } + else + { + /* Exponentiation will be performed with original A. */ + AA = (mbedtls_mpi *) A; + } + + pkha_size_t sizeA = mbedtls_mpi_size(AA); + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrE = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrN = ptrE + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(AA, ptrA, sizeA); + mbedtls_mpi_write_binary(E, ptrE, sizeE); + mbedtls_mpi_write_binary(N, ptrN, sizeN); + + ret = (int) CAAM_PKHA_ModExp(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrN, sizeN, ptrE, sizeE, ptrN, &sizeN, + kCAAM_PKHA_IntegerArith, kCAAM_PKHA_NormalValue, kCAAM_PKHA_TimingEqualized); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + mbedtls_mpi_read_binary(X, ptrN, sizeN); + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_exp_mod_orig(X, A, E, N, _RR); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_EXP_MOD_ALT */ + +#if defined(MBEDTLS_MPI_GCD_ALT) + +/* Access to original version of mbedtls_mpi_gcd function. */ +int mbedtls_mpi_gcd_orig(mbedtls_mpi * G, const mbedtls_mpi * A, const mbedtls_mpi * B); + +/* + * Greatest common divisor: G = gcd(A, B) (HAC 14.54) + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_gcd(mbedtls_mpi * G, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeA <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeB <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + ltc_reverse_array(ptrA, sizeA); + + mbedtls_mpi_write_binary(B, ptrB, sizeB); + ltc_reverse_array(ptrB, sizeB); + + if (mbedtls_mpi_cmp_mpi(A, B) >= 0) + { + ret = (int) LTC_PKHA_ModRed(LTC_INSTANCE, ptrA, sizeA, ptrB, sizeB, ptrA, &sizeA, kLTC_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + + ret = (int) LTC_PKHA_GCD(LTC_INSTANCE, ptrA, sizeA, ptrB, sizeB, ptrC, &sizeC, kLTC_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + ltc_reverse_array(ptrC, sizeC); + mbedtls_mpi_read_binary(G, ptrC, sizeC); + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_gcd_orig(G, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_gcd(mbedtls_mpi * G, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeA <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeB <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + mbedtls_mpi_write_binary(B, ptrB, sizeB); + + if (mbedtls_mpi_cmp_mpi(A, B) >= 0) + { + ret = (int) CAAM_PKHA_ModRed(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrB, sizeB, ptrA, &sizeA, + kCAAM_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + + ret = (int) CAAM_PKHA_ModGcd(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrB, sizeB, ptrC, &sizeC, kCAAM_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + mbedtls_mpi_read_binary(G, ptrC, sizeC); + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_gcd_orig(G, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_GCD_ALT */ + +#if defined(MBEDTLS_MPI_INV_MOD_ALT) + +/* Access to original version of mbedtls_mpi_inv_mod function. */ +int mbedtls_mpi_inv_mod_orig(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * N); + +/* + * Modular inverse: X = A^-1 mod N (HAC 14.61 / 14.64) + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_inv_mod(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * N) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeN = mbedtls_mpi_size(N); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeA <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeN <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrN = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrN + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + /* N cannot be negative */ + if (N->s < 0 || mbedtls_mpi_cmp_int(N, 0) == 0) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_BAD_INPUT_DATA); + } + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + ltc_reverse_array(ptrA, sizeA); + + mbedtls_mpi_write_binary(N, ptrN, sizeN); + ltc_reverse_array(ptrN, sizeN); + + if (mbedtls_mpi_cmp_mpi(A, N) >= 0) + { + ret = (int) LTC_PKHA_ModRed(LTC_INSTANCE, ptrA, sizeA, ptrN, sizeN, ptrA, &sizeA, kLTC_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + + ret = (int) LTC_PKHA_ModInv(LTC_INSTANCE, ptrA, sizeA, ptrN, sizeN, ptrC, &sizeC, kLTC_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + ltc_reverse_array(ptrC, sizeC); + mbedtls_mpi_read_binary(X, ptrC, sizeC); + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_inv_mod_orig(X, A, N); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_inv_mod(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * N) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeN = mbedtls_mpi_size(N); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeA <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeN <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrN = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrN + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + /* N cannot be negative */ + if (N->s < 0 || mbedtls_mpi_cmp_int(N, 0) == 0) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_BAD_INPUT_DATA); + } + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + mbedtls_mpi_write_binary(N, ptrN, sizeN); + + if (mbedtls_mpi_cmp_mpi(A, N) >= 0) + { + ret = (int) CAAM_PKHA_ModRed(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrN, sizeN, ptrA, &sizeA, + kCAAM_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + + ret = (int) CAAM_PKHA_ModInv(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrN, sizeN, ptrC, &sizeC, kCAAM_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + mbedtls_mpi_read_binary(X, ptrC, sizeC); + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_inv_mod_orig(X, A, N); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_INV_MOD_ALT */ + +#if defined(MBEDTLS_MPI_IS_PRIME_ALT) + +/* Access to original version of mbedtls_mpi_is_prime function. */ +int mbedtls_mpi_is_prime_orig(const mbedtls_mpi * X, int (*f_rng)(void *, unsigned char *, size_t), void * p_rng); + +/* + * Pseudo-primality test: small factors, then Miller-Rabin + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_is_prime(const mbedtls_mpi * X, int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) +{ + pkha_size_t sizeX = mbedtls_mpi_size(X); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if (sizeX <= FREESCALE_PKHA_INT_MAX_BYTES) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + int random; + bool result = false; + uint8_t * ptrX = mbedtls_calloc(1, FREESCALE_PKHA_INT_MAX_BYTES); + if (NULL == ptrX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(X, ptrX, FREESCALE_PKHA_INT_MAX_BYTES); + ltc_reverse_array(ptrX, FREESCALE_PKHA_INT_MAX_BYTES); + + // Get the random seed number + f_rng(p_rng, (unsigned char *) (&random), sizeof(random)); + + ret = (int) LTC_PKHA_PrimalityTest(LTC_INSTANCE, (unsigned char *) &random, sizeof(random), (const uint8_t *) "1", 1u, ptrX, + sizeX, &result); + + if (ret != kStatus_Success) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + + if (result == false) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + cleanup: + if (ptrX) + { + mbedtls_free(ptrX); + } + return ret; +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_is_prime_orig(X, f_rng, p_rng); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_is_prime(const mbedtls_mpi * X, int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) +{ + pkha_size_t sizeX = mbedtls_mpi_size(X); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if (sizeX <= FREESCALE_PKHA_INT_MAX_BYTES) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + int random; + bool result = false; + uint8_t * ptrX = mbedtls_calloc(1, FREESCALE_PKHA_INT_MAX_BYTES); + if (NULL == ptrX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(X, ptrX, FREESCALE_PKHA_INT_MAX_BYTES); + + // Get the random seed number + f_rng(p_rng, (unsigned char *) (&random), sizeof(random)); + + ret = (int) CAAM_PKHA_PrimalityTest(CAAM_INSTANCE, &s_caamHandle, (unsigned char *) &random, sizeof(random), + (const uint8_t *) "1", 1u, ptrX, sizeX, &result); + + if (ret != kStatus_Success) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + + if (result == false) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + cleanup: + if (ptrX) + { + mbedtls_free(ptrX); + } + return ret; +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_is_prime_orig(X, f_rng, p_rng); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_IS_PRIME_ALT */ + +#endif /* MBEDTLS_BIGNUM_C */ + +#if defined(MBEDTLS_ECP_C) + +#include "mbedtls/ecp.h" + +#define LTC_MAX_ECC (512) +#define CAAM_MAX_ECC (528) +#define CAU3_MAX_ECC (512) + +typedef enum +{ + kBigEndian = 0U, + kLittleEndian = 1U +} endian_t; + +/* convert from mbedtls_mpi to LTC or CAAM integer, as array of bytes of size sz. + * if mbedtls_mpi has less bytes than sz, add zero bytes at most significant byte positions. + * This is when for example modulus is 32 bytes (P-256 curve) + * and mbedtls_mpi has only 31 bytes, we add leading zeroes + * so that result array has 32 bytes, same as modulus (sz). + */ +#if defined(MBEDTLS_ECP_MUL_COMB_ALT) || defined(MBEDTLS_ECP_ADD_ALT) +static int get_and_extend_mbedtls_mpi(uint8_t * dst, const mbedtls_mpi * a, size_t sz, endian_t endian) +{ + size_t szbin; + int offset; + int ret; + + /* check how many bytes are in the mbedtls_mpi */ + szbin = mbedtls_mpi_size(a); + + /* compute offset from dst */ + offset = sz - szbin; + if (offset < 0) + offset = 0; + if (offset > sz) + offset = sz; + + /* add leading zeroes */ + if (offset) + memset(dst, 0, offset); + + /* convert mbedtls_mpi to array of bytes */ + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(a, dst + offset, szbin)); + + /* reverse array for LTC direct use */ + if (endian == kLittleEndian) + ltc_reverse_array(dst, sz); +cleanup: + return (ret); +} + +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +static int ltc_get_from_mbedtls_mpi(uint8_t * dst, const mbedtls_mpi * a, size_t sz) +{ + return get_and_extend_mbedtls_mpi(dst, a, sz, kLittleEndian); +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +static int caam_get_from_mbedtls_mpi(uint8_t * dst, const mbedtls_mpi * a, size_t sz) +{ + return get_and_extend_mbedtls_mpi(dst, a, sz, kBigEndian); +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA */ +#endif /* MBEDTLS_ECP_MUL_COMB_ALT || MBEDTLS_ECP_ADD_ALT */ + +/* + * Multiplication using the comb method, + * for curves in short Weierstrass form + */ +#if defined(MBEDTLS_ECP_MUL_COMB_ALT) +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) +int ecp_mul_comb(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, + int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) +{ + int ret; + bool is_inf; + size_t size; + size_t size_bin; + int sign = m->s; + + ltc_pkha_ecc_point_t A; + ltc_pkha_ecc_point_t result; + + /* Allocate 7 elements with size of (LTC_MAX_ECC / 8) plus ptrE with size of FREESCALE_PKHA_INT_MAX_BYTES */ + uint8_t * ptrAX = mbedtls_calloc((7 * (LTC_MAX_ECC / 8)) + FREESCALE_PKHA_INT_MAX_BYTES, 1); + uint8_t * ptrAY = ptrAX + (LTC_MAX_ECC / 8); + uint8_t * ptrRX = ptrAY + (LTC_MAX_ECC / 8); + uint8_t * ptrRY = ptrRX + (LTC_MAX_ECC / 8); + uint8_t * ptrN = ptrRY + (LTC_MAX_ECC / 8); + uint8_t * ptrParamA = ptrN + (LTC_MAX_ECC / 8); + uint8_t * ptrParamB = ptrParamA + (LTC_MAX_ECC / 8); + uint8_t * ptrE = ptrParamB + (LTC_MAX_ECC / 8); + if (NULL == ptrAX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + A.X = ptrAX; + A.Y = ptrAY; + result.X = ptrRX; + result.Y = ptrRY; + size = mbedtls_mpi_size(&grp->P); + if (mbedtls_mpi_size(&P->X) > (LTC_MAX_ECC / 8) || (mbedtls_mpi_get_bit(&grp->N, 0) != 1)) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert multi precision integers to arrays */ + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(A.X, &P->X, size)); + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(A.Y, &P->Y, size)); + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(ptrParamA, &grp->A, size)); + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(ptrParamB, &grp->B, size)); + + /* scalar multiplier integer of any size */ + size_bin = mbedtls_mpi_size(m); + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(m, ptrE, size_bin)); + ltc_reverse_array(ptrE, size_bin); + + /* modulus */ + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&grp->P, ptrN, size)); + ltc_reverse_array(ptrN, size); + + /* Multiply */ + LTC_PKHA_ECC_PointMul(LTC_INSTANCE, &A, ptrE, size_bin, ptrN, NULL, ptrParamA, ptrParamB, size, kLTC_PKHA_TimingEqualized, + kLTC_PKHA_IntegerArith, &result, &is_inf); + /* Convert result */ + ltc_reverse_array(ptrRX, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->X, ptrRX, size)); + ltc_reverse_array(ptrRY, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->Y, ptrRY, size)); + /* if the integer multiplier is negative, the computation happens with abs() value + * and the result (x,y) is changed to (x, -y) + */ + R->Y.s = sign; + MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); + +cleanup: + if (ptrAX) + { + mbedtls_free(ptrAX); + } + return (ret); +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int ecp_mul_comb(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, + int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) +{ + int ret; + size_t size; + size_t size_bin; + int sign = m->s; + + caam_pkha_ecc_point_t A; + caam_pkha_ecc_point_t result; + + /* Allocate 7 elements with size of (CAAM_MAX_ECC / 8) plus ptrE with size of FREESCALE_PKHA_INT_MAX_BYTES */ + uint8_t * ptrAX = mbedtls_calloc((7 * (CAAM_MAX_ECC / 8)) + FREESCALE_PKHA_INT_MAX_BYTES, 1); + uint8_t * ptrAY = ptrAX + (CAAM_MAX_ECC / 8); + uint8_t * ptrRX = ptrAY + (CAAM_MAX_ECC / 8); + uint8_t * ptrRY = ptrRX + (CAAM_MAX_ECC / 8); + uint8_t * ptrN = ptrRY + (CAAM_MAX_ECC / 8); + uint8_t * ptrParamA = ptrN + (CAAM_MAX_ECC / 8); + uint8_t * ptrParamB = ptrParamA + (CAAM_MAX_ECC / 8); + uint8_t * ptrE = ptrParamB + (CAAM_MAX_ECC / 8); + if (NULL == ptrAX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + A.X = ptrAX; + A.Y = ptrAY; + result.X = ptrRX; + result.Y = ptrRY; + size = mbedtls_mpi_size(&grp->P); + if (mbedtls_mpi_size(&P->X) > (CAAM_MAX_ECC / 8) || (mbedtls_mpi_get_bit(&grp->N, 0) != 1)) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert multi precision integers to arrays */ + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(A.X, &P->X, size)); + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(A.Y, &P->Y, size)); + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(ptrParamA, &grp->A, size)); + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(ptrParamB, &grp->B, size)); + + /* scalar multiplier integer of any size */ + size_bin = mbedtls_mpi_size(m); + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(m, ptrE, size_bin)); + + /* modulus */ + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&grp->P, ptrN, size)); + + /* Multiply */ + CAAM_PKHA_ECC_PointMul(CAAM_INSTANCE, &s_caamHandle, &A, ptrE, size_bin, ptrN, NULL, ptrParamA, ptrParamB, size, + kCAAM_PKHA_TimingEqualized, kCAAM_PKHA_IntegerArith, &result); + /* Convert result */ + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->X, ptrRX, size)); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->Y, ptrRY, size)); + /* if the integer multiplier is negative, the computation happens with abs() value + * and the result (x,y) is changed to (x, -y) + */ + R->Y.s = sign; + MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); + +cleanup: + if (ptrAX) + { + mbedtls_free(ptrAX); + } + return (ret); +} + +#elif defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int ecp_mul_comb(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, + int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) +{ + int ret; + status_t status; + size_t size; + size_t size_bin; + int sign = m->s; + + cau3_pkha_ecc_point_t A; + cau3_pkha_ecc_point_t result; + + /* Allocate 7 elements with size of (CAU3_MAX_ECC / 8) plus ptrE with size of FREESCALE_PKHA_INT_MAX_BYTES */ + uint8_t * ptrAX = mbedtls_calloc((7 * (CAU3_MAX_ECC / 8)) + FREESCALE_PKHA_INT_MAX_BYTES, 1); + uint8_t * ptrAY = ptrAX + (CAU3_MAX_ECC / 8); + uint8_t * ptrRX = ptrAY + (CAU3_MAX_ECC / 8); + uint8_t * ptrRY = ptrRX + (CAU3_MAX_ECC / 8); + uint8_t * ptrN = ptrRY + (CAU3_MAX_ECC / 8); + uint8_t * ptrParamA = ptrN + (CAU3_MAX_ECC / 8); + uint8_t * ptrParamB = ptrParamA + (CAU3_MAX_ECC / 8); + uint8_t * ptrE = ptrParamB + (CAU3_MAX_ECC / 8); + if (NULL == ptrAX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + A.X = ptrAX; + A.Y = ptrAY; + result.X = ptrRX; + result.Y = ptrRY; + size = mbedtls_mpi_size(&grp->P); + if (mbedtls_mpi_size(&P->X) > (CAU3_MAX_ECC / 8) || (mbedtls_mpi_get_bit(&grp->N, 0) != 1)) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert multi precision integers to arrays */ + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(A.X, &P->X, size)); + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(A.Y, &P->Y, size)); + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(ptrParamA, &grp->A, size)); + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(ptrParamB, &grp->B, size)); + + /* scalar multiplier integer of any size */ + size_bin = mbedtls_mpi_size(m); + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(m, ptrE, size_bin)); + cau3_reverse_array(ptrE, size_bin); + + /* modulus */ + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&grp->P, ptrN, size)); + cau3_reverse_array(ptrN, size); + + /* Multiply */ + status = CAU3_PKHA_ECC_PointMul(CAU3, &A, ptrE, size_bin, ptrN, NULL, ptrParamA, ptrParamB, size, kCAU3_PKHA_TimingEqualized, + kCAU3_PKHA_IntegerArith, &result); + + if (status != kStatus_Success) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert result */ + cau3_reverse_array(ptrRX, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->X, ptrRX, size)); + cau3_reverse_array(ptrRY, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->Y, ptrRY, size)); + /* if the integer multiplier is negative, the computation happens with abs() value + * and the result (x,y) is changed to (x, -y) + */ + R->Y.s = sign; + MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); + +cleanup: + if (ptrAX) + { + mbedtls_free(ptrAX); + } + return (ret); +} + +#endif /* MBEDTLS_FREESCALE_LTC_PKHA */ +#endif /* MBEDTLS_ECP_MUL_COMB_ALT */ + +/* + * Curve types: internal for now, might be exposed later + */ +typedef enum +{ + ECP_TYPE_NONE = 0, + ECP_TYPE_SHORT_WEIERSTRASS, /* y^2 = x^3 + a x + b */ + ECP_TYPE_MONTGOMERY, /* y^2 = x^3 + a x^2 + x */ +} ecp_curve_type; +/* + * Get the type of a curve + */ +static inline ecp_curve_type ecp_get_type(const mbedtls_ecp_group * grp) +{ + if (grp->G.X.p == NULL) + return (ECP_TYPE_NONE); + + if (grp->G.Y.p == NULL) + return (ECP_TYPE_MONTGOMERY); + else + return (ECP_TYPE_SHORT_WEIERSTRASS); +} + +/* + * Addition: R = P + Q, result's coordinates normalized + */ +#if defined(MBEDTLS_ECP_ADD_ALT) +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) +int ecp_add(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_ecp_point * P, const mbedtls_ecp_point * Q) +{ + int ret; + size_t size; + ltc_pkha_ecc_point_t A; + ltc_pkha_ecc_point_t B; + ltc_pkha_ecc_point_t result; + + uint8_t * ptrAX = mbedtls_calloc(9, (LTC_MAX_ECC / 8)); + uint8_t * ptrAY = ptrAX + (LTC_MAX_ECC / 8); + uint8_t * ptrBX = ptrAY + (LTC_MAX_ECC / 8); + uint8_t * ptrBY = ptrBX + (LTC_MAX_ECC / 8); + uint8_t * ptrRX = ptrBY + (LTC_MAX_ECC / 8); + uint8_t * ptrRY = ptrRX + (LTC_MAX_ECC / 8); + uint8_t * ptrN = ptrRY + (LTC_MAX_ECC / 8); + uint8_t * ptrParamA = ptrN + (LTC_MAX_ECC / 8); + uint8_t * ptrParamB = ptrParamA + (LTC_MAX_ECC / 8); + if (NULL == ptrAX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + if (ecp_get_type(grp) != ECP_TYPE_SHORT_WEIERSTRASS) + CLEAN_RETURN(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); + + A.X = ptrAX; + A.Y = ptrAY; + B.X = ptrBX; + B.Y = ptrBY; + result.X = ptrRX; + result.Y = ptrRY; + size = mbedtls_mpi_size(&grp->P); + if (mbedtls_mpi_size(&P->X) > (LTC_MAX_ECC / 8) || (mbedtls_mpi_get_bit(&grp->P, 0) != 1)) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert multi precision integers to arrays */ + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(A.X, &P->X, size)); + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(A.Y, &P->Y, size)); + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(B.X, &Q->X, size)); + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(B.Y, &Q->Y, size)); + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&grp->P, ptrN, size)); + ltc_reverse_array(ptrN, size); + /* Multiply */ + LTC_PKHA_ECC_PointAdd(LTC_INSTANCE, &A, &B, ptrN, NULL, ptrParamA, ptrParamB, size, kLTC_PKHA_IntegerArith, &result); + /* Convert result */ + ltc_reverse_array(ptrRX, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->X, ptrRX, size)); + ltc_reverse_array(ptrRY, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->Y, ptrRY, size)); + R->X.s = P->X.s; + R->Y.s = P->Y.s; + MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); + +cleanup: + if (ptrAX) + { + mbedtls_free(ptrAX); + } + return (ret); +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int ecp_add(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_ecp_point * P, const mbedtls_ecp_point * Q) +{ + int ret; + size_t size; + caam_pkha_ecc_point_t A; + caam_pkha_ecc_point_t B; + caam_pkha_ecc_point_t result; + + uint8_t * ptrAX = mbedtls_calloc(9, (CAAM_MAX_ECC / 8)); + uint8_t * ptrAY = ptrAX + (CAAM_MAX_ECC / 8); + uint8_t * ptrBX = ptrAY + (CAAM_MAX_ECC / 8); + uint8_t * ptrBY = ptrBX + (CAAM_MAX_ECC / 8); + uint8_t * ptrRX = ptrBY + (CAAM_MAX_ECC / 8); + uint8_t * ptrRY = ptrRX + (CAAM_MAX_ECC / 8); + uint8_t * ptrN = ptrRY + (CAAM_MAX_ECC / 8); + uint8_t * ptrParamA = ptrN + (CAAM_MAX_ECC / 8); + uint8_t * ptrParamB = ptrParamA + (CAAM_MAX_ECC / 8); + if (NULL == ptrAX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + if (ecp_get_type(grp) != ECP_TYPE_SHORT_WEIERSTRASS) + CLEAN_RETURN(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); + + A.X = ptrAX; + A.Y = ptrAY; + B.X = ptrBX; + B.Y = ptrBY; + result.X = ptrRX; + result.Y = ptrRY; + size = mbedtls_mpi_size(&grp->P); + if (mbedtls_mpi_size(&P->X) > (CAAM_MAX_ECC / 8) || (mbedtls_mpi_get_bit(&grp->P, 0) != 1)) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert multi precision integers to arrays */ + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(A.X, &P->X, size)); + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(A.Y, &P->Y, size)); + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(B.X, &Q->X, size)); + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(B.Y, &Q->Y, size)); + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&grp->P, ptrN, size)); + + /* Multiply */ + CAAM_PKHA_ECC_PointAdd(CAAM_INSTANCE, &s_caamHandle, &A, &B, ptrN, NULL, ptrParamA, ptrParamB, size, kCAAM_PKHA_IntegerArith, + &result); + /* Convert result */ + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->X, ptrRX, size)); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->Y, ptrRY, size)); + R->X.s = P->X.s; + R->Y.s = P->Y.s; + MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); + +cleanup: + if (ptrAX) + { + mbedtls_free(ptrAX); + } + return (ret); +} + +#elif defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int ecp_add(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_ecp_point * P, const mbedtls_ecp_point * Q) +{ + int ret; + status_t status; + size_t size; + cau3_pkha_ecc_point_t A; + cau3_pkha_ecc_point_t B; + cau3_pkha_ecc_point_t result; + + uint8_t * ptrAX = mbedtls_calloc(9, (CAU3_MAX_ECC / 8)); + uint8_t * ptrAY = ptrAX + (CAU3_MAX_ECC / 8); + uint8_t * ptrBX = ptrAY + (CAU3_MAX_ECC / 8); + uint8_t * ptrBY = ptrBX + (CAU3_MAX_ECC / 8); + uint8_t * ptrRX = ptrBY + (CAU3_MAX_ECC / 8); + uint8_t * ptrRY = ptrRX + (CAU3_MAX_ECC / 8); + uint8_t * ptrN = ptrRY + (CAU3_MAX_ECC / 8); + uint8_t * ptrParamA = ptrN + (CAU3_MAX_ECC / 8); + uint8_t * ptrParamB = ptrParamA + (CAU3_MAX_ECC / 8); + if (NULL == ptrAX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + if (ecp_get_type(grp) != ECP_TYPE_SHORT_WEIERSTRASS) + CLEAN_RETURN(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); + + A.X = ptrAX; + A.Y = ptrAY; + B.X = ptrBX; + B.Y = ptrBY; + result.X = ptrRX; + result.Y = ptrRY; + size = mbedtls_mpi_size(&grp->P); + if (mbedtls_mpi_size(&P->X) > (CAU3_MAX_ECC / 8) || (mbedtls_mpi_get_bit(&grp->P, 0) != 1)) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert multi precision integers to arrays */ + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(A.X, &P->X, size)); + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(A.Y, &P->Y, size)); + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(B.X, &Q->X, size)); + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(B.Y, &Q->Y, size)); + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&grp->P, ptrN, size)); + cau3_reverse_array(ptrN, size); + /* Multiply */ + status = CAU3_PKHA_ECC_PointAdd(CAU3, &A, &B, ptrN, NULL, ptrParamA, ptrParamB, size, kCAU3_PKHA_IntegerArith, &result); + + if (status != kStatus_Success) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert result */ + cau3_reverse_array(ptrRX, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->X, ptrRX, size)); + cau3_reverse_array(ptrRY, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->Y, ptrRY, size)); + R->X.s = P->X.s; + R->Y.s = P->Y.s; + MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); + +cleanup: + if (ptrAX) + { + mbedtls_free(ptrAX); + } + return (ret); +} + +#endif /* MBEDTLS_FREESCALE_LTC_PKHA */ + +#endif /* MBEDTLS_ECP_ADD_ALT */ + +#if defined(MBEDTLS_ECP_MUL_MXZ_ALT) +#if defined(MBEDTLS_FREESCALE_CAU3_PKHA) + +/* curve25519 params - in little endian for CAU3 */ +static const uint8_t s_curve25519_A24[] = { 0x42, 0xdb, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uint8_t s_curve25519_N[] = { 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f }; + +static const uint8_t s_curve25519_R2modN[] = { 0xa4, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +int ecp_mul_mxz(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, + int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) +{ + int ret; + status_t status; + size_t size; + size_t size_bin; + + cau3_pkha_ecc_point_t A; + cau3_pkha_ecc_point_t result; + + /* Allocate 2 elements with size of (CAU3_MAX_ECC / 8) plus ptrE with size of FREESCALE_PKHA_INT_MAX_BYTES */ + uint8_t * ptrAX = mbedtls_calloc((2 * (CAU3_MAX_ECC / 8)) + FREESCALE_PKHA_INT_MAX_BYTES, 1); + uint8_t * ptrRX = ptrAX + (CAU3_MAX_ECC / 8); + uint8_t * ptrE = ptrRX + (CAU3_MAX_ECC / 8); + if (NULL == ptrAX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + A.X = ptrAX; + result.X = ptrRX; + size = mbedtls_mpi_size(&grp->P); + if (mbedtls_mpi_size(&P->X) > (CAAM_MAX_ECC / 8)) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert multi precision integers to arrays */ + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(A.X, &P->X, size)); + + /* scalar multiplier integer of any size */ + size_bin = mbedtls_mpi_size(m); + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(m, ptrE, size_bin)); + cau3_reverse_array(ptrE, size_bin); + + /* Multiply */ + status = CAU3_PKHA_ECM_PointMul(CAU3, ptrE, size_bin, A.X, s_curve25519_A24, s_curve25519_N, s_curve25519_R2modN, size, + kCAU3_PKHA_TimingEqualized, result.X); + + if (status != kStatus_Success) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert result */ + cau3_reverse_array(ptrRX, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->X, ptrRX, size)); + MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); + +cleanup: + if (ptrAX) + { + mbedtls_free(ptrAX); + } + return (ret); +} + +#endif /* MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_ECP_MUL_MXZ_ALT */ + +#endif /* MBEDTLS_ECP_C */ + +#endif /* MBEDTLS_FREESCALE_LTC_PKHA */ + +#if defined(MBEDTLS_RSA_PUBLIC_ALT) +#if defined(MBEDTLS_FREESCALE_CASPER_PKHA) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#include "mbedtls/bignum.h" +#include "mbedtls/rsa.h" + +static void reverse_array(uint8_t * src, size_t src_len) +{ + int i; + + for (i = 0; i < src_len / 2; i++) + { + uint8_t tmp; + + tmp = src[i]; + src[i] = src[src_len - 1 - i]; + src[src_len - 1 - i] = tmp; + } +} +/* + * Do an RSA public key operation + */ +static int mbedtls_mpi_exp_mod_shim(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * E, + const mbedtls_mpi * N /*, mbedtls_mpi *_RR */) +{ + int ret = MBEDTLS_ERR_MPI_ALLOC_FAILED; + size_t sizeA = mbedtls_mpi_size(A); + size_t sizeN = mbedtls_mpi_size(N); + uint8_t * ptrX = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrA = ptrX + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrN = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + + if (NULL == ptrX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(A, ptrA, sizeA)); + reverse_array(ptrA, sizeA); + + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(N, ptrN, sizeN)); + reverse_array(ptrN, sizeN); + + CASPER_ModExp(CASPER, ptrA, ptrN, sizeN / 4, E->p[0], ptrX); + + reverse_array(ptrX, sizeN); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(X, ptrX, sizeN)); +cleanup: + if (ptrX != NULL) + { + mbedtls_free(ptrX); + } + + return ret; +} + +int mbedtls_rsa_public(mbedtls_rsa_context * ctx, const unsigned char * input, unsigned char * output) +{ + int ret; + size_t olen; + mbedtls_mpi T; + + mbedtls_mpi_init(&T); + +#if defined(MBEDTLS_THREADING_C) + if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) + return (ret); +#endif + + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&T, input, ctx->len)); + + if (mbedtls_mpi_cmp_mpi(&T, &ctx->N) >= 0) + { + ret = MBEDTLS_ERR_MPI_BAD_INPUT_DATA; + goto cleanup; + } + + olen = ctx->len; + + MBEDTLS_MPI_CHK(mbedtls_mpi_exp_mod_shim(&T, &T, &ctx->E, &ctx->N /*, &ctx->RN */)); + + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&T, output, olen)); + +cleanup: +#if defined(MBEDTLS_THREADING_C) + if (mbedtls_mutex_unlock(&ctx->mutex) != 0) + return (MBEDTLS_ERR_THREADING_MUTEX_ERROR); +#endif + + mbedtls_mpi_free(&T); + + if (ret != 0) + return (MBEDTLS_ERR_RSA_PUBLIC_FAILED + ret); + + return (0); +} + +#endif /* MBEDTLS_FREESCALE_CASPER_PKHA */ +#endif /* MBEDTLS_RSA_PUBLIC_ALT */ + +/******************************************************************************/ +/*************************** MD5 **********************************************/ +/******************************************************************************/ + +#if defined(MBEDTLS_MD5_C) + +#if defined(MBEDTLS_FREESCALE_MMCAU_MD5) + +#include "mbedtls/md5.h" + +int mbedtls_internal_md5_process(mbedtls_md5_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = MMCAU_MD5_HashN(data, 1, ctx->state); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_MD5_HW_ACCEL_FAILED; + } + return 0; +} + +#endif /* MBEDTLS_FREESCALE_MMCAU_MD5 */ + +#endif /* MBEDTLS_MD5_C */ + +/******************************************************************************/ +/*************************** SHA1 *********************************************/ +/******************************************************************************/ + +#if defined(MBEDTLS_SHA1_C) + +#if defined(MBEDTLS_FREESCALE_LTC_SHA1) +#include "mbedtls/sha1.h" + +void mbedtls_sha1_init(mbedtls_sha1_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_free(mbedtls_sha1_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_clone(mbedtls_sha1_context * dst, const mbedtls_sha1_context * src) +{ + memcpy(dst, src, sizeof(mbedtls_sha1_context)); +} + +/* + * SHA-1 context setup + */ +int mbedtls_sha1_starts_ret(mbedtls_sha1_context * ctx) +{ + status_t ret = kStatus_Fail; + ret = LTC_HASH_Init(LTC_INSTANCE, ctx, kLTC_Sha1, NULL, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = LTC_HASH_Update(ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 process buffer + */ +int mbedtls_sha1_update_ret(mbedtls_sha1_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = LTC_HASH_Update(ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 final digest + */ +int mbedtls_sha1_finish_ret(mbedtls_sha1_context * ctx, unsigned char output[20]) +{ + status_t ret = kStatus_Fail; + ret = LTC_HASH_Finish(ctx, output, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_MMCAU_SHA1) + +#include "mbedtls/sha1.h" + +int mbedtls_internal_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = MMCAU_SHA1_HashN(data, 1, ctx->state); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_LPC_SHA1) +#include "mbedtls/sha1.h" + +void mbedtls_sha1_init(mbedtls_sha1_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_free(mbedtls_sha1_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_clone(mbedtls_sha1_context * dst, const mbedtls_sha1_context * src) +{ + memcpy(dst, src, sizeof(mbedtls_sha1_context)); +} + +/* + * SHA-1 context setup + */ +int mbedtls_sha1_starts_ret(mbedtls_sha1_context * ctx) +{ + status_t ret = kStatus_Fail; + ret = SHA_Init(SHA_INSTANCE, ctx, kSHA_Sha1); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = SHA_Update(SHA_INSTANCE, ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 process buffer + */ +int mbedtls_sha1_update_ret(mbedtls_sha1_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = SHA_Update(SHA_INSTANCE, ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 final digest + */ +int mbedtls_sha1_finish_ret(mbedtls_sha1_context * ctx, unsigned char output[20]) +{ + size_t outputSize = 20u; + status_t ret = kStatus_Fail; + ret = SHA_Finish(SHA_INSTANCE, ctx, output, &outputSize); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} +#elif defined(MBEDTLS_FREESCALE_CAAM_SHA1) +#include "mbedtls/sha1.h" + +void mbedtls_sha1_init(mbedtls_sha1_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_free(mbedtls_sha1_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_clone(mbedtls_sha1_context * dst, const mbedtls_sha1_context * src) +{ + memcpy(dst, src, sizeof(mbedtls_sha1_context)); +} + +/* + * SHA-1 context setup + */ +int mbedtls_sha1_starts_ret(mbedtls_sha1_context * ctx) +{ + status_t ret = kStatus_Fail; + ret = CAAM_HASH_Init(CAAM_INSTANCE, &s_caamHandle, ctx, kCAAM_Sha1, NULL, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = CAAM_HASH_Update(ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 process buffer + */ +int mbedtls_sha1_update_ret(mbedtls_sha1_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = CAAM_HASH_Update(ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 final digest + */ +int mbedtls_sha1_finish_ret(mbedtls_sha1_context * ctx, unsigned char output[20]) +{ + status_t ret = kStatus_Fail; + ret = CAAM_HASH_Finish(ctx, output, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_CAU3_SHA1) +#include "mbedtls/sha1.h" + +void mbedtls_sha1_init(mbedtls_sha1_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_free(mbedtls_sha1_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_clone(mbedtls_sha1_context * dst, const mbedtls_sha1_context * src) +{ + memcpy(dst, src, sizeof(mbedtls_sha1_context)); +} + +/* + * SHA-1 context setup + */ +int mbedtls_sha1_starts_ret(mbedtls_sha1_context * ctx) +{ + status_t ret = kStatus_Fail; + ret = CAU3_HASH_Init(CAU3, ctx, kCAU3_Sha1); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = CAU3_HASH_Update(CAU3, ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 process buffer + */ +int mbedtls_sha1_update_ret(mbedtls_sha1_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = CAU3_HASH_Update(CAU3, ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 final digest + */ +int mbedtls_sha1_finish_ret(mbedtls_sha1_context * ctx, unsigned char output[20]) +{ + status_t ret = kStatus_Fail; + ret = CAU3_HASH_Finish(CAU3, ctx, output, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_DCP_SHA1) +#include "mbedtls/sha1.h" + +void mbedtls_sha1_init(mbedtls_sha1_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_free(mbedtls_sha1_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_clone(mbedtls_sha1_context * dst, const mbedtls_sha1_context * src) +{ + memcpy(dst, src, sizeof(mbedtls_sha1_context)); +} + +/* + * SHA-1 context setup + */ +int mbedtls_sha1_starts_ret(mbedtls_sha1_context * ctx) +{ + status_t ret = kStatus_Fail; + ret = DCP_HASH_Init(DCP, &s_dcpHandle, ctx, kDCP_Sha1); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = DCP_HASH_Update(DCP, ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 process buffer + */ +int mbedtls_sha1_update_ret(mbedtls_sha1_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = DCP_HASH_Update(DCP, ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 final digest + */ +int mbedtls_sha1_finish_ret(mbedtls_sha1_context * ctx, unsigned char output[20]) +{ + status_t ret = kStatus_Fail; + ret = DCP_HASH_Finish(DCP, ctx, output, NULL); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_HASHCRYPT_SHA1) +#include "mbedtls/sha1.h" + +void mbedtls_sha1_init(mbedtls_sha1_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_free(mbedtls_sha1_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_clone(mbedtls_sha1_context * dst, const mbedtls_sha1_context * src) +{ + memcpy(dst, src, sizeof(mbedtls_sha1_context)); +} + +/* + * SHA-1 context setup + */ +int mbedtls_sha1_starts_ret(mbedtls_sha1_context * ctx) +{ + status_t ret = kStatus_Fail; + ret = HASHCRYPT_SHA_Init(HASHCRYPT, ctx, kHASHCRYPT_Sha1); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = HASHCRYPT_SHA_Update(HASHCRYPT, ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 process buffer + */ +int mbedtls_sha1_update_ret(mbedtls_sha1_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = HASHCRYPT_SHA_Update(HASHCRYPT, ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 final digest + */ +int mbedtls_sha1_finish_ret(mbedtls_sha1_context * ctx, unsigned char output[20]) +{ + status_t ret = kStatus_Fail; + size_t outputSize = 20; + ret = HASHCRYPT_SHA_Finish(HASHCRYPT, ctx, output, &outputSize); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} +#endif /* MBEDTLS_FREESCALE_LPC_SHA1 */ +#if !defined(MBEDTLS_DEPRECATED_REMOVED) && defined(MBEDTLS_SHA1_ALT) +#include "mbedtls/sha1.h" + +void mbedtls_sha1_starts(mbedtls_sha1_context * ctx) +{ + mbedtls_sha1_starts_ret(ctx); +} + +void mbedtls_sha1_update(mbedtls_sha1_context * ctx, const unsigned char * input, size_t ilen) +{ + mbedtls_sha1_update_ret(ctx, input, ilen); +} + +void mbedtls_sha1_finish(mbedtls_sha1_context * ctx, unsigned char output[20]) +{ + mbedtls_sha1_finish_ret(ctx, output); +} + +void mbedtls_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + mbedtls_internal_sha1_process(ctx, data); +} +#endif /* MBEDTLS_DEPRECATED_REMOVED */ +#endif /* MBEDTLS_SHA1_C */ + +/******************************************************************************/ +/*************************** SHA256********************************************/ +/******************************************************************************/ + +#if defined(MBEDTLS_SHA256_C) + +#if defined(MBEDTLS_FREESCALE_LTC_SHA256) +#include "mbedtls/sha256.h" + +void mbedtls_sha256_init(mbedtls_sha256_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_free(mbedtls_sha256_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_clone(mbedtls_sha256_context * dst, const mbedtls_sha256_context * src) +{ + memcpy(dst, src, sizeof(*dst)); +} + +/* + * SHA-256 context setup + */ +int mbedtls_sha256_starts_ret(mbedtls_sha256_context * ctx, int is224) +{ + status_t ret = kStatus_Fail; + if (is224) + { + ret = LTC_HASH_Init(LTC_INSTANCE, ctx, kLTC_Sha224, NULL, 0); + } + else + { + ret = LTC_HASH_Init(LTC_INSTANCE, ctx, kLTC_Sha256, NULL, 0); + } + + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = LTC_HASH_Update(ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 process buffer + */ +int mbedtls_sha256_update_ret(mbedtls_sha256_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = LTC_HASH_Update(ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 final digest + */ +int mbedtls_sha256_finish_ret(mbedtls_sha256_context * ctx, unsigned char output[32]) +{ + status_t ret = kStatus_Fail; + ret = LTC_HASH_Finish(ctx, output, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_MMCAU_SHA256) + +#include "mbedtls/sha256.h" + +int mbedtls_internal_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = MMCAU_SHA256_HashN(data, 1, ctx->state); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_CAU3_SHA256) + +#include "mbedtls/sha256.h" + +void mbedtls_sha256_init(mbedtls_sha256_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_free(mbedtls_sha256_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_clone(mbedtls_sha256_context * dst, const mbedtls_sha256_context * src) +{ + memcpy(dst, src, sizeof(*dst)); +} + +/* + * SHA-256 context setup + */ +int mbedtls_sha256_starts_ret(mbedtls_sha256_context * ctx, int is224) +{ + status_t ret = kStatus_Fail; + if (!is224) /* SHA-224 not supported at the moment */ + { + ret = CAU3_HASH_Init(CAU3, ctx, kCAU3_Sha256); + } + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = CAU3_HASH_Update(CAU3, ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 process buffer + */ +int mbedtls_sha256_update_ret(mbedtls_sha256_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = CAU3_HASH_Update(CAU3, ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 final digest + */ +int mbedtls_sha256_finish_ret(mbedtls_sha256_context * ctx, unsigned char output[32]) +{ + status_t ret = kStatus_Fail; + ret = CAU3_HASH_Finish(CAU3, ctx, output, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_LPC_SHA256) +#include "mbedtls/sha256.h" + +void mbedtls_sha256_init(mbedtls_sha256_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_free(mbedtls_sha256_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_clone(mbedtls_sha256_context * dst, const mbedtls_sha256_context * src) +{ + memcpy(dst, src, sizeof(*dst)); +} + +/* + * SHA-256 context setup + */ +int mbedtls_sha256_starts_ret(mbedtls_sha256_context * ctx, int is224) +{ + int status = MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + if (!is224) /* SHA-224 not supported */ + { + SHA256_Init(ctx); + status = 0; + } + return status; +} + +int mbedtls_internal_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + SHA256_HashUpdate(ctx, data, 64); + return 0; +} + +/* + * SHA-256 process buffer + */ +int mbedtls_sha256_update_ret(mbedtls_sha256_context * ctx, const unsigned char * input, size_t ilen) +{ + SHA256_HashUpdate(ctx, input, ilen); + + return 0; +} + +/* + * SHA-256 final digest + */ +int mbedtls_sha256_finish_ret(mbedtls_sha256_context * ctx, unsigned char output[32]) +{ + SHA256_HashFinish(ctx, output); + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_SHA256) +#include "mbedtls/sha256.h" + +void mbedtls_sha256_init(mbedtls_sha256_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_free(mbedtls_sha256_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_clone(mbedtls_sha256_context * dst, const mbedtls_sha256_context * src) +{ + memcpy(dst, src, sizeof(*dst)); +} + +/* + * SHA-256 context setup + */ +int mbedtls_sha256_starts_ret(mbedtls_sha256_context * ctx, int is224) +{ + status_t ret = kStatus_Fail; + if (is224) + { + ret = CAAM_HASH_Init(CAAM_INSTANCE, &s_caamHandle, ctx, kCAAM_Sha224, NULL, 0); + } + else + { + ret = CAAM_HASH_Init(CAAM_INSTANCE, &s_caamHandle, ctx, kCAAM_Sha256, NULL, 0); + } + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = CAAM_HASH_Update(ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 process buffer + */ +int mbedtls_sha256_update_ret(mbedtls_sha256_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = CAAM_HASH_Update(ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 final digest + */ +int mbedtls_sha256_finish_ret(mbedtls_sha256_context * ctx, unsigned char output[32]) +{ + status_t ret = kStatus_Fail; + ret = CAAM_HASH_Finish(ctx, output, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_DCP_SHA256) +#include "mbedtls/sha256.h" + +void mbedtls_sha256_init(mbedtls_sha256_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_free(mbedtls_sha256_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_clone(mbedtls_sha256_context * dst, const mbedtls_sha256_context * src) +{ + memcpy(dst, src, sizeof(*dst)); +} + +/* + * SHA-256 context setup + */ +int mbedtls_sha256_starts_ret(mbedtls_sha256_context * ctx, int is224) +{ + status_t ret = kStatus_Fail; + if (!is224) + { + ret = DCP_HASH_Init(DCP, &s_dcpHandle, ctx, kDCP_Sha256); + } + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = DCP_HASH_Update(DCP, ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 process buffer + */ +int mbedtls_sha256_update_ret(mbedtls_sha256_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = DCP_HASH_Update(DCP, ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 final digest + */ +int mbedtls_sha256_finish_ret(mbedtls_sha256_context * ctx, unsigned char output[32]) +{ + status_t ret = kStatus_Fail; + ret = DCP_HASH_Finish(DCP, ctx, output, NULL); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_HASHCRYPT_SHA256) +#include "mbedtls/sha256.h" + +void mbedtls_sha256_init(mbedtls_sha256_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_free(mbedtls_sha256_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_clone(mbedtls_sha256_context * dst, const mbedtls_sha256_context * src) +{ + memcpy(dst, src, sizeof(*dst)); +} + +/* + * SHA-256 context setup + */ +int mbedtls_sha256_starts_ret(mbedtls_sha256_context * ctx, int is224) +{ + status_t ret = kStatus_Fail; + if (!is224) /* SHA-224 not supported */ + { + ret = HASHCRYPT_SHA_Init(HASHCRYPT, ctx, kHASHCRYPT_Sha256); + } + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = HASHCRYPT_SHA_Update(HASHCRYPT, ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 process buffer + */ +int mbedtls_sha256_update_ret(mbedtls_sha256_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = HASHCRYPT_SHA_Update(HASHCRYPT, ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 final digest + */ +int mbedtls_sha256_finish_ret(mbedtls_sha256_context * ctx, unsigned char output[32]) +{ + status_t ret = kStatus_Fail; + size_t outputSize = 32; + ret = HASHCRYPT_SHA_Finish(HASHCRYPT, ctx, output, &outputSize); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} +#endif /* MBEDTLS_FREESCALE_LTC_SHA256 */ +#if !defined(MBEDTLS_DEPRECATED_REMOVED) && defined(MBEDTLS_SHA256_ALT) +#include "mbedtls/sha256.h" + +void mbedtls_sha256_starts(mbedtls_sha256_context * ctx, int is224) +{ + mbedtls_sha256_starts_ret(ctx, is224); +} + +void mbedtls_sha256_update(mbedtls_sha256_context * ctx, const unsigned char * input, size_t ilen) +{ + mbedtls_sha256_update_ret(ctx, input, ilen); +} + +void mbedtls_sha256_finish(mbedtls_sha256_context * ctx, unsigned char output[32]) +{ + mbedtls_sha256_finish_ret(ctx, output); +} + +void mbedtls_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + mbedtls_internal_sha256_process(ctx, data); +} +#endif /* MBEDTLS_DEPRECATED_REMOVED */ +#endif /* MBEDTLS_SHA256_C */ + +/* Entropy poll callback for a hardware source */ +#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) + +#if defined(FSL_FEATURE_SOC_TRNG_COUNT) && (FSL_FEATURE_SOC_TRNG_COUNT > 0) +#if defined CPU_JN518X +#include "fsl_rng.h" +#else +#include "fsl_trng.h" +#endif +#elif defined(FSL_FEATURE_SOC_RNG_COUNT) && (FSL_FEATURE_SOC_RNG_COUNT > 0) +#include "fsl_rnga.h" +#elif defined(FSL_FEATURE_SOC_LPC_RNG_COUNT) && (FSL_FEATURE_SOC_LPC_RNG_COUNT > 0) +#include "fsl_rng.h" +#elif defined(FSL_FEATURE_SOC_LPC_RNG1_COUNT) && (FSL_FEATURE_SOC_LPC_RNG1_COUNT > 0) +#include "fsl_rng.h" +#endif + +int mbedtls_hardware_poll(void * data, unsigned char * output, size_t len, size_t * olen) +{ + status_t result = kStatus_Success; + +#if defined(FSL_FEATURE_SOC_TRNG_COUNT) && (FSL_FEATURE_SOC_TRNG_COUNT > 0) +#if defined CPU_JN518X +#ifndef TRNG0 +#define TRNG0 RNG +#endif +#else +#ifndef TRNG0 +#define TRNG0 TRNG +#endif +#endif + result = TRNG_GetRandomData(TRNG0, output, len); +#elif defined(FSL_FEATURE_SOC_RNG_COUNT) && (FSL_FEATURE_SOC_RNG_COUNT > 0) + result = RNGA_GetRandomData(RNG, (void *) output, len); +#elif defined(FSL_FEATURE_SOC_CAAM_COUNT) && (FSL_FEATURE_SOC_CAAM_COUNT > 0) && defined(CRYPTO_USE_DRIVER_CAAM) + result = CAAM_RNG_GetRandomData(CAAM_INSTANCE, &s_caamHandle, kCAAM_RngStateHandle0, output, len, kCAAM_RngDataAny, NULL); +#elif defined(FSL_FEATURE_SOC_LPC_RNG_COUNT) && (FSL_FEATURE_SOC_LPC_RNG_COUNT > 0) + uint32_t rn; + size_t length; + int i; + + length = len; + + while (length > 0) + { + rn = RNG_GetRandomData(); + + if (length >= sizeof(uint32_t)) + { + memcpy(output, &rn, sizeof(uint32_t)); + length -= sizeof(uint32_t); + output += sizeof(uint32_t); + } + else + { + memcpy(output, &rn, length); + output += length; + len = 0U; + } + + /* Discard next 32 random words for better entropy */ + for (i = 0; i < 32; i++) + { + RNG_GetRandomData(); + } + } + + result = kStatus_Success; +#elif defined(FSL_FEATURE_SOC_LPC_RNG1_COUNT) && (FSL_FEATURE_SOC_LPC_RNG1_COUNT > 0) + status_t status = kStatus_Fail; + + while (status != kStatus_Success) + { + status = RNG_GetRandomData(RNG, output, len); + + if (status == kStatus_Fail) + { + RNG_Init(RNG); + } + } + + result = status; +#endif + if (result == kStatus_Success) + { + *olen = len; + return 0; + } + else + { + return result; + } +} + +#endif + +/******************************************************************************/ +/*************************** FreeRTOS ********************************************/ +/******************************************************************************/ +#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) && defined(MBEDTLS_FREESCALE_FREERTOS_CALLOC_ALT) +#include "FreeRTOS.h" +#include "task.h" +#include + +/*---------HEAP_3 calloc --------------------------------------------------*/ + +void * pvPortCalloc(size_t num, size_t size) +{ + void * pvReturn; + + vTaskSuspendAll(); + { + pvReturn = calloc(num, size); + traceMALLOC(pvReturn, xWantedSize); + } + (void) xTaskResumeAll(); + +#if (configUSE_MALLOC_FAILED_HOOK == 1) + { + if (pvReturn == NULL) + { + extern void vApplicationMallocFailedHook(void); + vApplicationMallocFailedHook(); + } + } +#endif + + return pvReturn; +} +#endif /* USE_RTOS && defined(FSL_RTOS_FREE_RTOS) && defined(MBEDTLS_FREESCALE_FREERTOS_CALLOC_ALT) */ diff --git a/src/platform/qpg/BUILD.gn b/src/platform/qpg/BUILD.gn index 6abc13b4513754..3e786aacceafdb 100644 --- a/src/platform/qpg/BUILD.gn +++ b/src/platform/qpg/BUILD.gn @@ -40,6 +40,8 @@ static_library("qpg") { "DeviceNetworkProvisioningDelegateImpl.h", "DiagnosticDataProviderImpl.cpp", "DiagnosticDataProviderImpl.h", + "FactoryDataProvider.cpp", + "FactoryDataProvider.h", "InetPlatformConfig.h", "Logging.cpp", "OTAImageProcessorImpl.cpp", @@ -52,6 +54,8 @@ static_library("qpg") { deps = [] + public = [ "${chip_root}/src/credentials/DeviceAttestationCredsProvider.h" ] + public_deps = [ "${chip_root}/src/platform:platform_base" ] public_configs = [] diff --git a/src/platform/qpg/FactoryDataProvider.cpp b/src/platform/qpg/FactoryDataProvider.cpp new file mode 100644 index 00000000000000..4adadd3688acf3 --- /dev/null +++ b/src/platform/qpg/FactoryDataProvider.cpp @@ -0,0 +1,360 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +#include "FactoryDataProvider.h" +#include "CHIPDevicePlatformConfig.h" +#include +#include +#include +#include +#include + +#include "qvCHIP.h" + +namespace chip { +namespace { + +CHIP_ERROR LoadKeypairFromRaw(ByteSpan privateKey, ByteSpan publicKey, Crypto::P256Keypair & keypair) +{ + Crypto::P256SerializedKeypair serializedKeypair; + ReturnErrorOnFailure(serializedKeypair.SetLength(privateKey.size() + publicKey.size())); + memcpy(serializedKeypair.Bytes(), publicKey.data(), publicKey.size()); + memcpy(serializedKeypair.Bytes() + publicKey.size(), privateKey.data(), privateKey.size()); + return keypair.Deserialize(serializedKeypair); +} + +} // namespace + +namespace DeviceLayer { + +CHIP_ERROR FactoryDataProvider::Init() +{ + return CHIP_NO_ERROR; +} + +CHIP_ERROR FactoryDataProvider::MapQorvoError(qvStatus_t qStatus) +{ + switch (qStatus) + { + case QV_STATUS_NO_ERROR: + return CHIP_NO_ERROR; + case QV_STATUS_BUFFER_TOO_SMALL: + return CHIP_ERROR_BUFFER_TOO_SMALL; + case QV_STATUS_INVALID_ARGUMENT: + return CHIP_ERROR_INVALID_ARGUMENT; + case QV_STATUS_INVALID_DATA: + return CHIP_ERROR_INVALID_DATA_LIST; + default: + break; + } + return CHIP_ERROR_INTERNAL; +} + +CHIP_ERROR FactoryDataProvider::GetCertificationDeclaration(MutableByteSpan & outBuffer) +{ + qvStatus_t status; + uint32_t dataLength; + + status = qvCHIP_FactoryDataGetValue(TAG_ID_CERTIFICATION_DECLARATION, outBuffer.data(), outBuffer.size(), &dataLength); + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength <= CERTIFICATION_DECLARATION_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + outBuffer.reduce_size(dataLength); + } + + return MapQorvoError(status); +} + +CHIP_ERROR FactoryDataProvider::GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) +{ + out_firmware_info_buffer.reduce_size(0); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR FactoryDataProvider::GetDeviceAttestationCert(MutableByteSpan & outBuffer) +{ + qvStatus_t status; + uint32_t dataLength; + + status = qvCHIP_FactoryDataGetValue(TAG_ID_DEVICE_ATTESTATION_CERTIFICATE, outBuffer.data(), outBuffer.size(), &dataLength); + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength <= DEVICE_ATTESTATION_CERTIFICATE_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + outBuffer.reduce_size(dataLength); + } + + return MapQorvoError(status); +} + +CHIP_ERROR FactoryDataProvider::GetProductAttestationIntermediateCert(MutableByteSpan & outBuffer) +{ + qvStatus_t status; + uint32_t dataLength; + + status = qvCHIP_FactoryDataGetValue(TAG_ID_PRODUCT_ATTESTATION_INTERMEDIATE_CERTIFICATE, outBuffer.data(), outBuffer.size(), + &dataLength); + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength <= PRODUCT_ATTESTATION_INTERMEDIATE_CERTIFICATE_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + outBuffer.reduce_size(dataLength); + } + + return MapQorvoError(status); +} + +CHIP_ERROR FactoryDataProvider::SignWithDeviceAttestationKey(const ByteSpan & messageToSign, MutableByteSpan & outSignBuffer) +{ + Crypto::P256ECDSASignature signature; + Crypto::P256Keypair keypair; + + VerifyOrReturnError(IsSpanUsable(outSignBuffer), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(IsSpanUsable(messageToSign), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(outSignBuffer.size() >= signature.Capacity(), CHIP_ERROR_BUFFER_TOO_SMALL); + + uint8_t qorvoDacPrivKeyBuffer[DEVICE_ATTESTATION_PRIVATE_KEY_LEN]; + uint8_t qorvoDacPubKeyBuffer[DEVICE_ATTESTATION_PUBLIC_KEY_LEN]; + MutableByteSpan qorvoDacPrivateKey(qorvoDacPrivKeyBuffer, DEVICE_ATTESTATION_PRIVATE_KEY_LEN); + MutableByteSpan qorvoDacPublicKey(qorvoDacPubKeyBuffer, DEVICE_ATTESTATION_PUBLIC_KEY_LEN); + qvStatus_t status; + uint32_t dataLength; + status = qvCHIP_FactoryDataGetValue(TAG_ID_DEVICE_ATTESTATION_PRIVATE_KEY, qorvoDacPrivateKey.data(), qorvoDacPrivateKey.size(), + &dataLength); + ; + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength <= DEVICE_ATTESTATION_PRIVATE_KEY_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + qorvoDacPrivateKey.reduce_size(dataLength); + } + ReturnErrorOnFailure(MapQorvoError(status)); + + status = qvCHIP_FactoryDataGetValue(TAG_ID_DEVICE_ATTESTATION_PUBLIC_KEY, qorvoDacPublicKey.data(), qorvoDacPublicKey.size(), + &dataLength); + ; + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength <= DEVICE_ATTESTATION_PUBLIC_KEY_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + qorvoDacPublicKey.reduce_size(dataLength); + } + ReturnErrorOnFailure(MapQorvoError(status)); + + // In a non-exemplary implementation, the public key is not needed here. It is used here merely because + // Crypto::P256Keypair is only (currently) constructable from raw keys if both private/public keys are present. + ReturnErrorOnFailure(LoadKeypairFromRaw(qorvoDacPrivateKey, qorvoDacPublicKey, keypair)); + ReturnErrorOnFailure(keypair.ECDSA_sign_msg(messageToSign.data(), messageToSign.size(), signature)); + + return CopySpanToMutableSpan(ByteSpan{ signature.ConstBytes(), signature.Length() }, outSignBuffer); +} + +CHIP_ERROR FactoryDataProvider::GetSetupDiscriminator(uint16_t & setupDiscriminator) +{ + qvStatus_t status; + uint32_t dataLength; + + status = qvCHIP_FactoryDataGetValue(TAG_ID_SETUP_DISCRIMINATOR, (uint8_t *) &setupDiscriminator, SETUP_DISCRIMINATOR_LEN, + &dataLength); + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength == SETUP_DISCRIMINATOR_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + } + + return MapQorvoError(status); +} + +CHIP_ERROR FactoryDataProvider::SetSetupDiscriminator(uint16_t setupDiscriminator) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR FactoryDataProvider::GetSpake2pIterationCount(uint32_t & iterationCount) +{ + qvStatus_t status; + uint32_t dataLength; + + status = qvCHIP_FactoryDataGetValue(TAG_ID_SPAKE2_ITERATION_COUNT, (uint8_t *) &iterationCount, SPAKE2_ITERATION_COUNT_LEN, + &dataLength); + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength == SPAKE2_ITERATION_COUNT_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + } + + return MapQorvoError(status); +} + +CHIP_ERROR FactoryDataProvider::GetSpake2pSalt(MutableByteSpan & saltBuf) +{ + qvStatus_t status; + uint32_t dataLength; + + status = qvCHIP_FactoryDataGetValue(TAG_ID_SPAKE2_SALT, saltBuf.data(), saltBuf.size(), &dataLength); + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength <= SPAKE2_SALT_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + saltBuf.reduce_size(dataLength); + } + + return MapQorvoError(status); +} + +CHIP_ERROR FactoryDataProvider::GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & verifierLen) +{ + qvStatus_t status; + + status = qvCHIP_FactoryDataGetValue(TAG_ID_SPAKE2_VERIFIER, verifierBuf.data(), verifierBuf.size(), (uint32_t *) &verifierLen); + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(verifierLen <= SPAKE2_VERIFIER_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + verifierBuf.reduce_size(verifierLen); + } + + return MapQorvoError(status); +} + +CHIP_ERROR FactoryDataProvider::GetSetupPasscode(uint32_t & setupPasscode) +{ + qvStatus_t status; + uint32_t dataLength; + + status = qvCHIP_FactoryDataGetValue(TAG_ID_SPAKE2_SETUP_PASSCODE, (uint8_t *) &setupPasscode, SETUP_PASSCODE_LEN, &dataLength); + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength == SETUP_PASSCODE_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + } + + return MapQorvoError(status); +} + +CHIP_ERROR FactoryDataProvider::SetSetupPasscode(uint32_t setupPasscode) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR FactoryDataProvider::GetVendorName(char * buf, size_t bufSize) +{ + return MapQorvoError(qvCHIP_FactoryDataGetValue(TAG_ID_VENDOR_NAME, (uint8_t *) buf, bufSize, NULL)); +} + +CHIP_ERROR FactoryDataProvider::GetVendorId(uint16_t & vendorId) +{ + qvStatus_t status; + uint32_t dataLength; + + status = qvCHIP_FactoryDataGetValue(TAG_ID_VENDOR_ID, (uint8_t *) &vendorId, VENDOR_ID_LEN, &dataLength); + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength == VENDOR_ID_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + } + + return MapQorvoError(status); +} + +CHIP_ERROR FactoryDataProvider::GetProductName(char * buf, size_t bufSize) +{ + return MapQorvoError(qvCHIP_FactoryDataGetValue(TAG_ID_PRODUCT_NAME, (uint8_t *) buf, bufSize, NULL)); +} + +CHIP_ERROR FactoryDataProvider::GetProductId(uint16_t & productId) +{ + qvStatus_t status; + uint32_t dataLength; + + status = qvCHIP_FactoryDataGetValue(TAG_ID_PRODUCT_ID, (uint8_t *) &productId, PRODUCT_ID_LEN, &dataLength); + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength == PRODUCT_ID_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + } + + return MapQorvoError(status); +} + +CHIP_ERROR FactoryDataProvider::GetSerialNumber(char * buf, size_t bufSize) +{ + return MapQorvoError(qvCHIP_FactoryDataGetValue(TAG_ID_SERIAL_NUMBER, (uint8_t *) buf, bufSize, NULL)); +} + +CHIP_ERROR FactoryDataProvider::GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day) +{ + uint8_t buf[MANUFACTURING_DATE_LEN]; + qvStatus_t status; + uint32_t dataLength; + + status = qvCHIP_FactoryDataGetValue(TAG_ID_MANUFACTURING_DATE, buf, MANUFACTURING_DATE_LEN, &dataLength); + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength == MANUFACTURING_DATE_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + uint8_t * ptr = buf; + year = *(uint16_t *) ptr; + ptr += 2; + month = *ptr; + ptr += 1; + day = *ptr; + } + + return MapQorvoError(status); +} + +CHIP_ERROR FactoryDataProvider::GetHardwareVersion(uint16_t & hardwareVersion) +{ + qvStatus_t status; + uint32_t dataLength; + + status = qvCHIP_FactoryDataGetValue(TAG_ID_HARDWARE_VERSION, (uint8_t *) &hardwareVersion, HARDWARE_VERSION_LEN, &dataLength); + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength == HARDWARE_VERSION_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + } + + return MapQorvoError(status); +} + +CHIP_ERROR FactoryDataProvider::GetHardwareVersionString(char * buf, size_t bufSize) +{ + return MapQorvoError(qvCHIP_FactoryDataGetValue(TAG_ID_HARDWARE_VERSION_STRING, (uint8_t *) buf, bufSize, NULL)); +} + +CHIP_ERROR FactoryDataProvider::GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) +{ + qvStatus_t status; + uint32_t dataLength; + + status = qvCHIP_FactoryDataGetValue(TAG_ID_ROTATING_DEVICE_ID, uniqueIdSpan.data(), uniqueIdSpan.size(), &dataLength); + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength <= ROTATING_DEVICE_ID_UNIQUE_ID_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + uniqueIdSpan.reduce_size(dataLength); + } + + return MapQorvoError(status); +} + +CHIP_ERROR FactoryDataProvider::GetEnableKey(MutableByteSpan & enableKey) +{ + qvStatus_t status; + uint32_t dataLength; + + status = qvCHIP_FactoryDataGetValue(TAG_ID_ENABLE_KEY, enableKey.data(), enableKey.size(), &dataLength); + if (status == QV_STATUS_NO_ERROR) + { + VerifyOrReturnError(dataLength <= ENABLE_KEY_LEN, CHIP_ERROR_INVALID_LIST_LENGTH); + enableKey.reduce_size(dataLength); + } + + return MapQorvoError(status); +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qpg/FactoryDataProvider.h b/src/platform/qpg/FactoryDataProvider.h new file mode 100644 index 00000000000000..0c8ab970ae3dcf --- /dev/null +++ b/src/platform/qpg/FactoryDataProvider.h @@ -0,0 +1,71 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +#pragma once + +#include +#include +#include + +#include "qvCHIP.h" + +namespace chip { +namespace DeviceLayer { + +class FactoryDataProvider : public chip::Credentials::DeviceAttestationCredentialsProvider, + public CommissionableDataProvider, + public DeviceInstanceInfoProvider +{ +public: + CHIP_ERROR Init(); + + // ===== Members functions that implement the DeviceAttestationCredentialsProvider + CHIP_ERROR GetCertificationDeclaration(MutableByteSpan & outBuffer) override; + CHIP_ERROR GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) override; + CHIP_ERROR GetDeviceAttestationCert(MutableByteSpan & outBuffer) override; + CHIP_ERROR GetProductAttestationIntermediateCert(MutableByteSpan & outBuffer) override; + CHIP_ERROR SignWithDeviceAttestationKey(const ByteSpan & messageToSign, MutableByteSpan & outSignBuffer) override; + + // ===== Members functions that implement the CommissionableDataProvider + CHIP_ERROR GetSetupDiscriminator(uint16_t & setupDiscriminator) override; + CHIP_ERROR SetSetupDiscriminator(uint16_t setupDiscriminator) override; + CHIP_ERROR GetSpake2pIterationCount(uint32_t & iterationCount) override; + CHIP_ERROR GetSpake2pSalt(MutableByteSpan & saltBuf) override; + CHIP_ERROR GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & verifierLen) override; + CHIP_ERROR GetSetupPasscode(uint32_t & setupPasscode) override; + CHIP_ERROR SetSetupPasscode(uint32_t setupPasscode) override; + + // ===== Members functions that implement the DeviceInstanceInfoProvider + CHIP_ERROR GetVendorName(char * buf, size_t bufSize) override; + CHIP_ERROR GetVendorId(uint16_t & vendorId) override; + CHIP_ERROR GetProductName(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductId(uint16_t & productId) override; + CHIP_ERROR GetSerialNumber(char * buf, size_t bufSize) override; + CHIP_ERROR GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day) override; + CHIP_ERROR GetHardwareVersion(uint16_t & hardwareVersion) override; + CHIP_ERROR GetHardwareVersionString(char * buf, size_t bufSize) override; + CHIP_ERROR GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) override; + + // ===== Members functions that are platform-specific + CHIP_ERROR GetEnableKey(MutableByteSpan & enableKey); + +protected: + static CHIP_ERROR MapQorvoError(qvStatus_t aStatus); +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/telink/BLEManagerImpl.cpp b/src/platform/telink/BLEManagerImpl.cpp index eaacb0250338a2..d8f838142b245e 100644 --- a/src/platform/telink/BLEManagerImpl.cpp +++ b/src/platform/telink/BLEManagerImpl.cpp @@ -35,7 +35,7 @@ /*Includes for ieee802154 switchings */ #define DT_DRV_COMPAT telink_b91_zb #include -#include +#include /* Telink headers */ #include "drivers.h" @@ -319,11 +319,11 @@ CHIP_ERROR BLEManagerImpl::_InitStack(void) SuccessOrExit(err); /* Resetup stimer interrupt to handle BLE stack */ - ret = irq_connect_dynamic(STIMER_IRQ_NUM, 2, stimer_irq_handler, NULL, 0); + ret = irq_connect_dynamic(STIMER_IRQ_NUM + CONFIG_2ND_LVL_ISR_TBL_OFFSET, 2, stimer_irq_handler, NULL, 0); ChipLogDetail(DeviceLayer, "Stimer IRQ assigned vector %d", ret); /* Resetup rf interrupt to handle BLE stack */ - ret = irq_connect_dynamic(RF_IRQ_NUM, 2, rf_irq_handler, NULL, 0); + ret = irq_connect_dynamic(RF_IRQ_NUM + CONFIG_2ND_LVL_ISR_TBL_OFFSET, 2, rf_irq_handler, NULL, 0); ChipLogDetail(DeviceLayer, "RF IRQ assigned vector %d", ret); exit: @@ -577,7 +577,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) /* @todo: move to RadioSwitch module*/ const struct device * radio_dev = device_get_binding(CONFIG_NET_CONFIG_IEEE802154_DEV_NAME); __ASSERT(radio_dev != NULL, "Fail to get radio device"); - b91_ieee802154_deinit(radio_dev); + b91_deinit(radio_dev); /* It is time to init BLE stack */ err = _InitStack(); @@ -837,7 +837,7 @@ void BLEManagerImpl::SwitchToIeee802154(void) __ASSERT(radio_dev != NULL, "Fail to get radio device"); /* Init IEEE802154 */ - result = b91_ieee802154_init(radio_dev); + result = b91_init(radio_dev); __ASSERT(result == 0, "Fail to init IEEE802154 radio. Error: %d", result); } diff --git a/src/platform/telink/BUILD.gn b/src/platform/telink/BUILD.gn index 96f663d9a8b4d8..d0b799c187b44b 100644 --- a/src/platform/telink/BUILD.gn +++ b/src/platform/telink/BUILD.gn @@ -46,30 +46,11 @@ static_library("telink") { "KeyValueStoreManagerImpl.h", "PlatformManagerImpl.h", "SystemPlatformConfig.h", - - # B91 HW crypto unit - "crypto/internal/common.h", - "crypto/internal/compatibility/aes_alt.c", - "crypto/internal/compatibility/aesni.h", - "crypto/internal/compatibility/bn_mul.h", - "crypto/internal/compatibility/ecp_alt.c", - "crypto/internal/compatibility/ecp_curves_alt.c", - "crypto/internal/compatibility/ecp_internal_alt.h", - "crypto/internal/compatibility/ecp_invasive.h", - "crypto/internal/compatibility/padlock.h", - "crypto/internal/ecp_alt_b91_backend.c", - "crypto/internal/ecp_alt_b91_backend_test.c", - "crypto/internal/entropy_poll_alt.c", - "crypto/internal/multithread.c", - "crypto/internal/multithread.h", - "crypto/internal/test_utils.c", - "crypto/internal/test_utils.h", ] deps = [] public_deps = [ - "${chip_root}/src/crypto", "${chip_root}/src/platform:platform_base", "${telink_sdk_build_root}", ] @@ -93,6 +74,4 @@ static_library("telink") { "OTAImageProcessorImpl.h", ] } - - public_deps += [ "${chip_root}/src/crypto" ] } diff --git a/src/platform/telink/CHIPDevicePlatformEvent.h b/src/platform/telink/CHIPDevicePlatformEvent.h index f7772579432c18..b04059508c1bf6 100644 --- a/src/platform/telink/CHIPDevicePlatformEvent.h +++ b/src/platform/telink/CHIPDevicePlatformEvent.h @@ -26,7 +26,7 @@ #include -#include +#include namespace chip { namespace DeviceLayer { diff --git a/src/platform/telink/OTAImageProcessorImpl.cpp b/src/platform/telink/OTAImageProcessorImpl.cpp index 0adc3f3947273e..f0c3c4de5cdd35 100644 --- a/src/platform/telink/OTAImageProcessorImpl.cpp +++ b/src/platform/telink/OTAImageProcessorImpl.cpp @@ -21,10 +21,10 @@ #include #include -#include -#include +#include #include #include +#include static struct stream_flash_ctx stream; diff --git a/src/platform/telink/crypto/aes_alt.h b/src/platform/telink/crypto/aes_alt.h deleted file mode 100644 index c8560e894b676c..00000000000000 --- a/src/platform/telink/crypto/aes_alt.h +++ /dev/null @@ -1,56 +0,0 @@ -/* aes_alt.h */ -/* - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -#ifndef AES_ALT_H -#define AES_ALT_H - -#if defined(MBEDTLS_AES_ALT) -// Regular implementation -// - -/** - * \brief The AES context-type definition. - */ -typedef struct mbedtls_aes_context -{ - int MBEDTLS_PRIVATE(nr); /*!< The number of rounds. */ - uint32_t * MBEDTLS_PRIVATE(rk); /*!< AES round keys. */ - uint32_t MBEDTLS_PRIVATE(buf)[68]; /*!< Unaligned data buffer. This buffer can - hold 32 extra Bytes, which can be used for - one of the following purposes: -
  • Alignment if VIA padlock is used.
  • -
  • Simplifying key expansion in the 256-bit - case by generating an extra round key. -
*/ -} mbedtls_aes_context; - -#if defined(MBEDTLS_CIPHER_MODE_XTS) -/** - * \brief The AES XTS context-type definition. - */ -typedef struct mbedtls_aes_xts_context -{ - mbedtls_aes_context MBEDTLS_PRIVATE(crypt); /*!< The AES context to use for AES block encryption or decryption. */ - mbedtls_aes_context MBEDTLS_PRIVATE(tweak); /*!< The AES context used for tweak computation. */ -} mbedtls_aes_xts_context; - -#endif /* MBEDTLS_CIPHER_MODE_XTS */ - -#endif /* MBEDTLS_AES_ALT */ - -#endif /* aes_alt.h */ diff --git a/src/platform/telink/crypto/ecp_alt.h b/src/platform/telink/crypto/ecp_alt.h deleted file mode 100644 index 920774c88c305f..00000000000000 --- a/src/platform/telink/crypto/ecp_alt.h +++ /dev/null @@ -1,105 +0,0 @@ -/** - * \file ecp_alt.h - * - * \brief Utility macros for internal use in the library - */ -/* - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -#ifndef ECP_ALT_H -#define ECP_ALT_H - -#if defined(MBEDTLS_ECP_ALT) - -typedef struct mbedtls_ecp_group -{ - mbedtls_ecp_group_id id; /*!< An internal group identifier. */ - mbedtls_mpi P; /*!< The prime modulus of the base field. */ - mbedtls_mpi A; /*!< For Short Weierstrass: \p A in the equation. For - Montgomery curves: (A + 2) / 4. */ - mbedtls_mpi B; /*!< For Short Weierstrass: \p B in the equation. - For Montgomery curves: unused. */ - mbedtls_ecp_point G; /*!< The generator of the subgroup used. */ - mbedtls_mpi N; /*!< The order of \p G. */ - size_t pbits; /*!< The number of bits in \p P.*/ - size_t nbits; /*!< For Short Weierstrass: The number of bits in \p P. - For Montgomery curves: the number of bits in the - private keys. */ - /* End of public fields */ - - unsigned int MBEDTLS_PRIVATE(h); /*!< \internal 1 if the constants are static. */ - int (*MBEDTLS_PRIVATE(modp))(mbedtls_mpi *); /*!< The function for fast pseudo-reduction mod \p P (see above).*/ - int (*MBEDTLS_PRIVATE(t_pre))(mbedtls_ecp_point *, void *); /*!< Unused. */ - int (*MBEDTLS_PRIVATE(t_post))(mbedtls_ecp_point *, void *); /*!< Unused. */ - void * MBEDTLS_PRIVATE(t_data); /*!< Unused. */ - mbedtls_ecp_point * MBEDTLS_PRIVATE(T); /*!< Pre-computed points for ecp_mul_comb(). */ - size_t MBEDTLS_PRIVATE(T_size); /*!< The number of dynamic allocated pre-computed points. */ -} mbedtls_ecp_group; - -/** - * \name SECTION: Module settings - * - * The configuration options you can set for this module are in this section. - * Either change them in mbedtls_config.h, or define them using the compiler command line. - * \{ - */ - -#if !defined(MBEDTLS_ECP_WINDOW_SIZE) -/* - * Maximum "window" size used for point multiplication. - * Default: a point where higher memory usage yields disminishing performance - * returns. - * Minimum value: 2. Maximum value: 7. - * - * Result is an array of at most ( 1 << ( MBEDTLS_ECP_WINDOW_SIZE - 1 ) ) - * points used for point multiplication. This value is directly tied to EC - * peak memory usage, so decreasing it by one should roughly cut memory usage - * by two (if large curves are in use). - * - * Reduction in size may reduce speed, but larger curves are impacted first. - * Sample performances (in ECDHE handshakes/s, with FIXED_POINT_OPTIM = 1): - * w-size: 6 5 4 3 2 - * 521 145 141 135 120 97 - * 384 214 209 198 177 146 - * 256 320 320 303 262 226 - * 224 475 475 453 398 342 - * 192 640 640 633 587 476 - */ -#define MBEDTLS_ECP_WINDOW_SIZE 4 /**< The maximum window size used. */ -#endif /* MBEDTLS_ECP_WINDOW_SIZE */ - -#if !defined(MBEDTLS_ECP_FIXED_POINT_OPTIM) -/* - * Trade code size for speed on fixed-point multiplication. - * - * This speeds up repeated multiplication of the generator (that is, the - * multiplication in ECDSA signatures, and half of the multiplications in - * ECDSA verification and ECDHE) by a factor roughly 3 to 4. - * - * For each n-bit Short Weierstrass curve that is enabled, this adds 4n bytes - * of code size if n < 384 and 8n otherwise. - * - * Change this value to 0 to reduce code size. - */ -#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up. */ -#endif /* MBEDTLS_ECP_FIXED_POINT_OPTIM */ - -/* \} name SECTION: Module settings */ - -#endif /* MBEDTLS_ECP_ALT */ - -#endif /* ecp_alt.h */ diff --git a/src/platform/telink/crypto/internal/common.h b/src/platform/telink/crypto/internal/common.h deleted file mode 100644 index a2c8a1e72690b4..00000000000000 --- a/src/platform/telink/crypto/internal/common.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * \file common.h - * - * \brief Utility macros for internal use in the library - */ -/* - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -#ifndef MBEDTLS_LIBRARY_COMMON_H -#define MBEDTLS_LIBRARY_COMMON_H - -#include "mbedtls/build_info.h" - -/** Helper to define a function as static except when building invasive tests. - * - * If a function is only used inside its own source file and should be - * declared `static` to allow the compiler to optimize for code size, - * but that function has unit tests, define it with - * ``` - * MBEDTLS_STATIC_TESTABLE int mbedtls_foo(...) { ... } - * ``` - * and declare it in a header in the `library/` directory with - * ``` - * #if defined(MBEDTLS_TEST_HOOKS) - * int mbedtls_foo(...); - * #endif - * ``` - */ -#if defined(MBEDTLS_TEST_HOOKS) -#define MBEDTLS_STATIC_TESTABLE -#else -#define MBEDTLS_STATIC_TESTABLE static -#endif - -/** Allow library to access its structs' private members. - * - * Although structs defined in header files are publicly available, - * their members are private and should not be accessed by the user. - */ -#define MBEDTLS_ALLOW_PRIVATE_ACCESS - -#endif /* MBEDTLS_LIBRARY_COMMON_H */ diff --git a/src/platform/telink/crypto/internal/compatibility/aes_alt.c b/src/platform/telink/crypto/internal/compatibility/aes_alt.c deleted file mode 100644 index 31cf5a5323cc13..00000000000000 --- a/src/platform/telink/crypto/internal/compatibility/aes_alt.c +++ /dev/null @@ -1,2042 +0,0 @@ -/* - * FIPS-197 compliant AES implementation - * - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ -/* - * The AES block cipher was designed by Vincent Rijmen and Joan Daemen. - * - * http://csrc.nist.gov/encryption/aes/rijndael/Rijndael.pdf - * http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf - */ - -#include "../common.h" - -#if defined(MBEDTLS_AES_C) - -#include - -#include "mbedtls/aes.h" -#include "mbedtls/error.h" -#include "mbedtls/platform.h" -#include "mbedtls/platform_util.h" -#if defined(MBEDTLS_PADLOCK_C) -#include "padlock.h" -#endif -#if defined(MBEDTLS_AESNI_C) -#include "aesni.h" -#endif - -#if defined(MBEDTLS_SELF_TEST) -#if defined(MBEDTLS_PLATFORM_C) -#include "mbedtls/platform.h" -#else -#include -#define mbedtls_printf printf -#endif /* MBEDTLS_PLATFORM_C */ -#endif /* MBEDTLS_SELF_TEST */ - -#if defined(MBEDTLS_AES_ALT) - -#include "../multithread.h" -#include "aes.h" - -/* Parameter validation macros based on platform_util.h */ -#define AES_VALIDATE_RET(cond) MBEDTLS_INTERNAL_VALIDATE_RET(cond, MBEDTLS_ERR_AES_BAD_INPUT_DATA) -#define AES_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE(cond) - -/* - * 32-bit integer manipulation macros (little endian) - */ -#ifndef GET_UINT32_LE -#define GET_UINT32_LE(n, b, i) \ - { \ - (n) = ((uint32_t)(b)[(i)]) | ((uint32_t)(b)[(i) + 1] << 8) | ((uint32_t)(b)[(i) + 2] << 16) | \ - ((uint32_t)(b)[(i) + 3] << 24); \ - } -#endif - -#ifndef PUT_UINT32_LE -#define PUT_UINT32_LE(n, b, i) \ - { \ - (b)[(i)] = (unsigned char) (((n)) & 0xFF); \ - (b)[(i) + 1] = (unsigned char) (((n) >> 8) & 0xFF); \ - (b)[(i) + 2] = (unsigned char) (((n) >> 16) & 0xFF); \ - (b)[(i) + 3] = (unsigned char) (((n) >> 24) & 0xFF); \ - } -#endif - -#if defined(MBEDTLS_PADLOCK_C) && (defined(MBEDTLS_HAVE_X86) || defined(MBEDTLS_PADLOCK_ALIGN16)) -static int aes_padlock_ace = -1; -#endif - -#if defined(MBEDTLS_AES_ROM_TABLES) -/* - * Forward S-box - */ -static const unsigned char FSb[256] = { - 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, - 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, - 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, - 0xEB, 0x27, 0xB2, 0x75, 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84, - 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF, 0xD0, 0xEF, 0xAA, 0xFB, - 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8, 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, - 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2, 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, - 0x64, 0x5D, 0x19, 0x73, 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB, - 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79, 0xE7, 0xC8, 0x37, 0x6D, - 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08, 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, - 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A, 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, - 0x86, 0xC1, 0x1D, 0x9E, 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF, - 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16 -}; - -/* - * Forward tables - */ -#define FT \ - \ - V(A5, 63, 63, C6), V(84, 7C, 7C, F8), V(99, 77, 77, EE), V(8D, 7B, 7B, F6), V(0D, F2, F2, FF), V(BD, 6B, 6B, D6), \ - V(B1, 6F, 6F, DE), V(54, C5, C5, 91), V(50, 30, 30, 60), V(03, 01, 01, 02), V(A9, 67, 67, CE), V(7D, 2B, 2B, 56), \ - V(19, FE, FE, E7), V(62, D7, D7, B5), V(E6, AB, AB, 4D), V(9A, 76, 76, EC), V(45, CA, CA, 8F), V(9D, 82, 82, 1F), \ - V(40, C9, C9, 89), V(87, 7D, 7D, FA), V(15, FA, FA, EF), V(EB, 59, 59, B2), V(C9, 47, 47, 8E), V(0B, F0, F0, FB), \ - V(EC, AD, AD, 41), V(67, D4, D4, B3), V(FD, A2, A2, 5F), V(EA, AF, AF, 45), V(BF, 9C, 9C, 23), V(F7, A4, A4, 53), \ - V(96, 72, 72, E4), V(5B, C0, C0, 9B), V(C2, B7, B7, 75), V(1C, FD, FD, E1), V(AE, 93, 93, 3D), V(6A, 26, 26, 4C), \ - V(5A, 36, 36, 6C), V(41, 3F, 3F, 7E), V(02, F7, F7, F5), V(4F, CC, CC, 83), V(5C, 34, 34, 68), V(F4, A5, A5, 51), \ - V(34, E5, E5, D1), V(08, F1, F1, F9), V(93, 71, 71, E2), V(73, D8, D8, AB), V(53, 31, 31, 62), V(3F, 15, 15, 2A), \ - V(0C, 04, 04, 08), V(52, C7, C7, 95), V(65, 23, 23, 46), V(5E, C3, C3, 9D), V(28, 18, 18, 30), V(A1, 96, 96, 37), \ - V(0F, 05, 05, 0A), V(B5, 9A, 9A, 2F), V(09, 07, 07, 0E), V(36, 12, 12, 24), V(9B, 80, 80, 1B), V(3D, E2, E2, DF), \ - V(26, EB, EB, CD), V(69, 27, 27, 4E), V(CD, B2, B2, 7F), V(9F, 75, 75, EA), V(1B, 09, 09, 12), V(9E, 83, 83, 1D), \ - V(74, 2C, 2C, 58), V(2E, 1A, 1A, 34), V(2D, 1B, 1B, 36), V(B2, 6E, 6E, DC), V(EE, 5A, 5A, B4), V(FB, A0, A0, 5B), \ - V(F6, 52, 52, A4), V(4D, 3B, 3B, 76), V(61, D6, D6, B7), V(CE, B3, B3, 7D), V(7B, 29, 29, 52), V(3E, E3, E3, DD), \ - V(71, 2F, 2F, 5E), V(97, 84, 84, 13), V(F5, 53, 53, A6), V(68, D1, D1, B9), V(00, 00, 00, 00), V(2C, ED, ED, C1), \ - V(60, 20, 20, 40), V(1F, FC, FC, E3), V(C8, B1, B1, 79), V(ED, 5B, 5B, B6), V(BE, 6A, 6A, D4), V(46, CB, CB, 8D), \ - V(D9, BE, BE, 67), V(4B, 39, 39, 72), V(DE, 4A, 4A, 94), V(D4, 4C, 4C, 98), V(E8, 58, 58, B0), V(4A, CF, CF, 85), \ - V(6B, D0, D0, BB), V(2A, EF, EF, C5), V(E5, AA, AA, 4F), V(16, FB, FB, ED), V(C5, 43, 43, 86), V(D7, 4D, 4D, 9A), \ - V(55, 33, 33, 66), V(94, 85, 85, 11), V(CF, 45, 45, 8A), V(10, F9, F9, E9), V(06, 02, 02, 04), V(81, 7F, 7F, FE), \ - V(F0, 50, 50, A0), V(44, 3C, 3C, 78), V(BA, 9F, 9F, 25), V(E3, A8, A8, 4B), V(F3, 51, 51, A2), V(FE, A3, A3, 5D), \ - V(C0, 40, 40, 80), V(8A, 8F, 8F, 05), V(AD, 92, 92, 3F), V(BC, 9D, 9D, 21), V(48, 38, 38, 70), V(04, F5, F5, F1), \ - V(DF, BC, BC, 63), V(C1, B6, B6, 77), V(75, DA, DA, AF), V(63, 21, 21, 42), V(30, 10, 10, 20), V(1A, FF, FF, E5), \ - V(0E, F3, F3, FD), V(6D, D2, D2, BF), V(4C, CD, CD, 81), V(14, 0C, 0C, 18), V(35, 13, 13, 26), V(2F, EC, EC, C3), \ - V(E1, 5F, 5F, BE), V(A2, 97, 97, 35), V(CC, 44, 44, 88), V(39, 17, 17, 2E), V(57, C4, C4, 93), V(F2, A7, A7, 55), \ - V(82, 7E, 7E, FC), V(47, 3D, 3D, 7A), V(AC, 64, 64, C8), V(E7, 5D, 5D, BA), V(2B, 19, 19, 32), V(95, 73, 73, E6), \ - V(A0, 60, 60, C0), V(98, 81, 81, 19), V(D1, 4F, 4F, 9E), V(7F, DC, DC, A3), V(66, 22, 22, 44), V(7E, 2A, 2A, 54), \ - V(AB, 90, 90, 3B), V(83, 88, 88, 0B), V(CA, 46, 46, 8C), V(29, EE, EE, C7), V(D3, B8, B8, 6B), V(3C, 14, 14, 28), \ - V(79, DE, DE, A7), V(E2, 5E, 5E, BC), V(1D, 0B, 0B, 16), V(76, DB, DB, AD), V(3B, E0, E0, DB), V(56, 32, 32, 64), \ - V(4E, 3A, 3A, 74), V(1E, 0A, 0A, 14), V(DB, 49, 49, 92), V(0A, 06, 06, 0C), V(6C, 24, 24, 48), V(E4, 5C, 5C, B8), \ - V(5D, C2, C2, 9F), V(6E, D3, D3, BD), V(EF, AC, AC, 43), V(A6, 62, 62, C4), V(A8, 91, 91, 39), V(A4, 95, 95, 31), \ - V(37, E4, E4, D3), V(8B, 79, 79, F2), V(32, E7, E7, D5), V(43, C8, C8, 8B), V(59, 37, 37, 6E), V(B7, 6D, 6D, DA), \ - V(8C, 8D, 8D, 01), V(64, D5, D5, B1), V(D2, 4E, 4E, 9C), V(E0, A9, A9, 49), V(B4, 6C, 6C, D8), V(FA, 56, 56, AC), \ - V(07, F4, F4, F3), V(25, EA, EA, CF), V(AF, 65, 65, CA), V(8E, 7A, 7A, F4), V(E9, AE, AE, 47), V(18, 08, 08, 10), \ - V(D5, BA, BA, 6F), V(88, 78, 78, F0), V(6F, 25, 25, 4A), V(72, 2E, 2E, 5C), V(24, 1C, 1C, 38), V(F1, A6, A6, 57), \ - V(C7, B4, B4, 73), V(51, C6, C6, 97), V(23, E8, E8, CB), V(7C, DD, DD, A1), V(9C, 74, 74, E8), V(21, 1F, 1F, 3E), \ - V(DD, 4B, 4B, 96), V(DC, BD, BD, 61), V(86, 8B, 8B, 0D), V(85, 8A, 8A, 0F), V(90, 70, 70, E0), V(42, 3E, 3E, 7C), \ - V(C4, B5, B5, 71), V(AA, 66, 66, CC), V(D8, 48, 48, 90), V(05, 03, 03, 06), V(01, F6, F6, F7), V(12, 0E, 0E, 1C), \ - V(A3, 61, 61, C2), V(5F, 35, 35, 6A), V(F9, 57, 57, AE), V(D0, B9, B9, 69), V(91, 86, 86, 17), V(58, C1, C1, 99), \ - V(27, 1D, 1D, 3A), V(B9, 9E, 9E, 27), V(38, E1, E1, D9), V(13, F8, F8, EB), V(B3, 98, 98, 2B), V(33, 11, 11, 22), \ - V(BB, 69, 69, D2), V(70, D9, D9, A9), V(89, 8E, 8E, 07), V(A7, 94, 94, 33), V(B6, 9B, 9B, 2D), V(22, 1E, 1E, 3C), \ - V(92, 87, 87, 15), V(20, E9, E9, C9), V(49, CE, CE, 87), V(FF, 55, 55, AA), V(78, 28, 28, 50), V(7A, DF, DF, A5), \ - V(8F, 8C, 8C, 03), V(F8, A1, A1, 59), V(80, 89, 89, 09), V(17, 0D, 0D, 1A), V(DA, BF, BF, 65), V(31, E6, E6, D7), \ - V(C6, 42, 42, 84), V(B8, 68, 68, D0), V(C3, 41, 41, 82), V(B0, 99, 99, 29), V(77, 2D, 2D, 5A), V(11, 0F, 0F, 1E), \ - V(CB, B0, B0, 7B), V(FC, 54, 54, A8), V(D6, BB, BB, 6D), V(3A, 16, 16, 2C) - -#define V(a, b, c, d) 0x##a##b##c##d -static const uint32_t FT0[256] = { FT }; -#undef V - -#if !defined(MBEDTLS_AES_FEWER_TABLES) - -#define V(a, b, c, d) 0x##b##c##d##a -static const uint32_t FT1[256] = { FT }; -#undef V - -#define V(a, b, c, d) 0x##c##d##a##b -static const uint32_t FT2[256] = { FT }; -#undef V - -#define V(a, b, c, d) 0x##d##a##b##c -static const uint32_t FT3[256] = { FT }; -#undef V - -#endif /* !MBEDTLS_AES_FEWER_TABLES */ - -#undef FT - -/* - * Reverse S-box - */ -static const unsigned char RSb[256] = { - 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB, 0x7C, 0xE3, 0x39, 0x82, - 0x9B, 0x2F, 0xFF, 0x87, 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, - 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E, 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, 0x76, 0x5B, 0xA2, 0x49, - 0x6D, 0x8B, 0xD1, 0x25, 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92, - 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA, 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84, 0x90, 0xD8, 0xAB, 0x00, - 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06, 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, - 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B, 0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, - 0xF0, 0xB4, 0xE6, 0x73, 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E, - 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B, 0xFC, 0x56, 0x3E, 0x4B, - 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4, 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, - 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F, 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, - 0x93, 0xC9, 0x9C, 0xEF, 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61, - 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D -}; - -/* - * Reverse tables - */ -#define RT \ - \ - V(50, A7, F4, 51), V(53, 65, 41, 7E), V(C3, A4, 17, 1A), V(96, 5E, 27, 3A), V(CB, 6B, AB, 3B), V(F1, 45, 9D, 1F), \ - V(AB, 58, FA, AC), V(93, 03, E3, 4B), V(55, FA, 30, 20), V(F6, 6D, 76, AD), V(91, 76, CC, 88), V(25, 4C, 02, F5), \ - V(FC, D7, E5, 4F), V(D7, CB, 2A, C5), V(80, 44, 35, 26), V(8F, A3, 62, B5), V(49, 5A, B1, DE), V(67, 1B, BA, 25), \ - V(98, 0E, EA, 45), V(E1, C0, FE, 5D), V(02, 75, 2F, C3), V(12, F0, 4C, 81), V(A3, 97, 46, 8D), V(C6, F9, D3, 6B), \ - V(E7, 5F, 8F, 03), V(95, 9C, 92, 15), V(EB, 7A, 6D, BF), V(DA, 59, 52, 95), V(2D, 83, BE, D4), V(D3, 21, 74, 58), \ - V(29, 69, E0, 49), V(44, C8, C9, 8E), V(6A, 89, C2, 75), V(78, 79, 8E, F4), V(6B, 3E, 58, 99), V(DD, 71, B9, 27), \ - V(B6, 4F, E1, BE), V(17, AD, 88, F0), V(66, AC, 20, C9), V(B4, 3A, CE, 7D), V(18, 4A, DF, 63), V(82, 31, 1A, E5), \ - V(60, 33, 51, 97), V(45, 7F, 53, 62), V(E0, 77, 64, B1), V(84, AE, 6B, BB), V(1C, A0, 81, FE), V(94, 2B, 08, F9), \ - V(58, 68, 48, 70), V(19, FD, 45, 8F), V(87, 6C, DE, 94), V(B7, F8, 7B, 52), V(23, D3, 73, AB), V(E2, 02, 4B, 72), \ - V(57, 8F, 1F, E3), V(2A, AB, 55, 66), V(07, 28, EB, B2), V(03, C2, B5, 2F), V(9A, 7B, C5, 86), V(A5, 08, 37, D3), \ - V(F2, 87, 28, 30), V(B2, A5, BF, 23), V(BA, 6A, 03, 02), V(5C, 82, 16, ED), V(2B, 1C, CF, 8A), V(92, B4, 79, A7), \ - V(F0, F2, 07, F3), V(A1, E2, 69, 4E), V(CD, F4, DA, 65), V(D5, BE, 05, 06), V(1F, 62, 34, D1), V(8A, FE, A6, C4), \ - V(9D, 53, 2E, 34), V(A0, 55, F3, A2), V(32, E1, 8A, 05), V(75, EB, F6, A4), V(39, EC, 83, 0B), V(AA, EF, 60, 40), \ - V(06, 9F, 71, 5E), V(51, 10, 6E, BD), V(F9, 8A, 21, 3E), V(3D, 06, DD, 96), V(AE, 05, 3E, DD), V(46, BD, E6, 4D), \ - V(B5, 8D, 54, 91), V(05, 5D, C4, 71), V(6F, D4, 06, 04), V(FF, 15, 50, 60), V(24, FB, 98, 19), V(97, E9, BD, D6), \ - V(CC, 43, 40, 89), V(77, 9E, D9, 67), V(BD, 42, E8, B0), V(88, 8B, 89, 07), V(38, 5B, 19, E7), V(DB, EE, C8, 79), \ - V(47, 0A, 7C, A1), V(E9, 0F, 42, 7C), V(C9, 1E, 84, F8), V(00, 00, 00, 00), V(83, 86, 80, 09), V(48, ED, 2B, 32), \ - V(AC, 70, 11, 1E), V(4E, 72, 5A, 6C), V(FB, FF, 0E, FD), V(56, 38, 85, 0F), V(1E, D5, AE, 3D), V(27, 39, 2D, 36), \ - V(64, D9, 0F, 0A), V(21, A6, 5C, 68), V(D1, 54, 5B, 9B), V(3A, 2E, 36, 24), V(B1, 67, 0A, 0C), V(0F, E7, 57, 93), \ - V(D2, 96, EE, B4), V(9E, 91, 9B, 1B), V(4F, C5, C0, 80), V(A2, 20, DC, 61), V(69, 4B, 77, 5A), V(16, 1A, 12, 1C), \ - V(0A, BA, 93, E2), V(E5, 2A, A0, C0), V(43, E0, 22, 3C), V(1D, 17, 1B, 12), V(0B, 0D, 09, 0E), V(AD, C7, 8B, F2), \ - V(B9, A8, B6, 2D), V(C8, A9, 1E, 14), V(85, 19, F1, 57), V(4C, 07, 75, AF), V(BB, DD, 99, EE), V(FD, 60, 7F, A3), \ - V(9F, 26, 01, F7), V(BC, F5, 72, 5C), V(C5, 3B, 66, 44), V(34, 7E, FB, 5B), V(76, 29, 43, 8B), V(DC, C6, 23, CB), \ - V(68, FC, ED, B6), V(63, F1, E4, B8), V(CA, DC, 31, D7), V(10, 85, 63, 42), V(40, 22, 97, 13), V(20, 11, C6, 84), \ - V(7D, 24, 4A, 85), V(F8, 3D, BB, D2), V(11, 32, F9, AE), V(6D, A1, 29, C7), V(4B, 2F, 9E, 1D), V(F3, 30, B2, DC), \ - V(EC, 52, 86, 0D), V(D0, E3, C1, 77), V(6C, 16, B3, 2B), V(99, B9, 70, A9), V(FA, 48, 94, 11), V(22, 64, E9, 47), \ - V(C4, 8C, FC, A8), V(1A, 3F, F0, A0), V(D8, 2C, 7D, 56), V(EF, 90, 33, 22), V(C7, 4E, 49, 87), V(C1, D1, 38, D9), \ - V(FE, A2, CA, 8C), V(36, 0B, D4, 98), V(CF, 81, F5, A6), V(28, DE, 7A, A5), V(26, 8E, B7, DA), V(A4, BF, AD, 3F), \ - V(E4, 9D, 3A, 2C), V(0D, 92, 78, 50), V(9B, CC, 5F, 6A), V(62, 46, 7E, 54), V(C2, 13, 8D, F6), V(E8, B8, D8, 90), \ - V(5E, F7, 39, 2E), V(F5, AF, C3, 82), V(BE, 80, 5D, 9F), V(7C, 93, D0, 69), V(A9, 2D, D5, 6F), V(B3, 12, 25, CF), \ - V(3B, 99, AC, C8), V(A7, 7D, 18, 10), V(6E, 63, 9C, E8), V(7B, BB, 3B, DB), V(09, 78, 26, CD), V(F4, 18, 59, 6E), \ - V(01, B7, 9A, EC), V(A8, 9A, 4F, 83), V(65, 6E, 95, E6), V(7E, E6, FF, AA), V(08, CF, BC, 21), V(E6, E8, 15, EF), \ - V(D9, 9B, E7, BA), V(CE, 36, 6F, 4A), V(D4, 09, 9F, EA), V(D6, 7C, B0, 29), V(AF, B2, A4, 31), V(31, 23, 3F, 2A), \ - V(30, 94, A5, C6), V(C0, 66, A2, 35), V(37, BC, 4E, 74), V(A6, CA, 82, FC), V(B0, D0, 90, E0), V(15, D8, A7, 33), \ - V(4A, 98, 04, F1), V(F7, DA, EC, 41), V(0E, 50, CD, 7F), V(2F, F6, 91, 17), V(8D, D6, 4D, 76), V(4D, B0, EF, 43), \ - V(54, 4D, AA, CC), V(DF, 04, 96, E4), V(E3, B5, D1, 9E), V(1B, 88, 6A, 4C), V(B8, 1F, 2C, C1), V(7F, 51, 65, 46), \ - V(04, EA, 5E, 9D), V(5D, 35, 8C, 01), V(73, 74, 87, FA), V(2E, 41, 0B, FB), V(5A, 1D, 67, B3), V(52, D2, DB, 92), \ - V(33, 56, 10, E9), V(13, 47, D6, 6D), V(8C, 61, D7, 9A), V(7A, 0C, A1, 37), V(8E, 14, F8, 59), V(89, 3C, 13, EB), \ - V(EE, 27, A9, CE), V(35, C9, 61, B7), V(ED, E5, 1C, E1), V(3C, B1, 47, 7A), V(59, DF, D2, 9C), V(3F, 73, F2, 55), \ - V(79, CE, 14, 18), V(BF, 37, C7, 73), V(EA, CD, F7, 53), V(5B, AA, FD, 5F), V(14, 6F, 3D, DF), V(86, DB, 44, 78), \ - V(81, F3, AF, CA), V(3E, C4, 68, B9), V(2C, 34, 24, 38), V(5F, 40, A3, C2), V(72, C3, 1D, 16), V(0C, 25, E2, BC), \ - V(8B, 49, 3C, 28), V(41, 95, 0D, FF), V(71, 01, A8, 39), V(DE, B3, 0C, 08), V(9C, E4, B4, D8), V(90, C1, 56, 64), \ - V(61, 84, CB, 7B), V(70, B6, 32, D5), V(74, 5C, 6C, 48), V(42, 57, B8, D0) - -#define V(a, b, c, d) 0x##a##b##c##d -static const uint32_t RT0[256] = { RT }; -#undef V - -#if !defined(MBEDTLS_AES_FEWER_TABLES) - -#define V(a, b, c, d) 0x##b##c##d##a -static const uint32_t RT1[256] = { RT }; -#undef V - -#define V(a, b, c, d) 0x##c##d##a##b -static const uint32_t RT2[256] = { RT }; -#undef V - -#define V(a, b, c, d) 0x##d##a##b##c -static const uint32_t RT3[256] = { RT }; -#undef V - -#endif /* !MBEDTLS_AES_FEWER_TABLES */ - -#undef RT - -/* - * Round constants - */ -static const uint32_t RCON[10] = { 0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010, - 0x00000020, 0x00000040, 0x00000080, 0x0000001B, 0x00000036 }; - -#else /* MBEDTLS_AES_ROM_TABLES */ - -/* - * Forward S-box & tables - */ -static unsigned char FSb[256]; -static uint32_t FT0[256]; -#if !defined(MBEDTLS_AES_FEWER_TABLES) -static uint32_t FT1[256]; -static uint32_t FT2[256]; -static uint32_t FT3[256]; -#endif /* !MBEDTLS_AES_FEWER_TABLES */ - -/* - * Reverse S-box & tables - */ -static unsigned char RSb[256]; -static uint32_t RT0[256]; -#if !defined(MBEDTLS_AES_FEWER_TABLES) -static uint32_t RT1[256]; -static uint32_t RT2[256]; -static uint32_t RT3[256]; -#endif /* !MBEDTLS_AES_FEWER_TABLES */ - -/* - * Round constants - */ -static uint32_t RCON[10]; - -/* - * Tables generation code - */ -#define ROTL8(x) (((x) << 8) & 0xFFFFFFFF) | ((x) >> 24) -#define XTIME(x) (((x) << 1) ^ (((x) &0x80) ? 0x1B : 0x00)) -#define MUL(x, y) (((x) && (y)) ? pow[(log[(x)] + log[(y)]) % 255] : 0) - -static int aes_init_done = 0; - -static void aes_gen_tables(void) -{ - int i, x, y, z; - int pow[256]; - int log[256]; - - /* - * compute pow and log tables over GF(2^8) - */ - for (i = 0, x = 1; i < 256; i++) - { - pow[i] = x; - log[x] = i; - x = (x ^ XTIME(x)) & 0xFF; - } - - /* - * calculate the round constants - */ - for (i = 0, x = 1; i < 10; i++) - { - RCON[i] = (uint32_t) x; - x = XTIME(x) & 0xFF; - } - - /* - * generate the forward and reverse S-boxes - */ - FSb[0x00] = 0x63; - RSb[0x63] = 0x00; - - for (i = 1; i < 256; i++) - { - x = pow[255 - log[i]]; - - y = x; - y = ((y << 1) | (y >> 7)) & 0xFF; - x ^= y; - y = ((y << 1) | (y >> 7)) & 0xFF; - x ^= y; - y = ((y << 1) | (y >> 7)) & 0xFF; - x ^= y; - y = ((y << 1) | (y >> 7)) & 0xFF; - x ^= y ^ 0x63; - - FSb[i] = (unsigned char) x; - RSb[x] = (unsigned char) i; - } - - /* - * generate the forward and reverse tables - */ - for (i = 0; i < 256; i++) - { - x = FSb[i]; - y = XTIME(x) & 0xFF; - z = (y ^ x) & 0xFF; - - FT0[i] = ((uint32_t) y) ^ ((uint32_t) x << 8) ^ ((uint32_t) x << 16) ^ ((uint32_t) z << 24); - -#if !defined(MBEDTLS_AES_FEWER_TABLES) - FT1[i] = ROTL8(FT0[i]); - FT2[i] = ROTL8(FT1[i]); - FT3[i] = ROTL8(FT2[i]); -#endif /* !MBEDTLS_AES_FEWER_TABLES */ - - x = RSb[i]; - - RT0[i] = ((uint32_t) MUL(0x0E, x)) ^ ((uint32_t) MUL(0x09, x) << 8) ^ ((uint32_t) MUL(0x0D, x) << 16) ^ - ((uint32_t) MUL(0x0B, x) << 24); - -#if !defined(MBEDTLS_AES_FEWER_TABLES) - RT1[i] = ROTL8(RT0[i]); - RT2[i] = ROTL8(RT1[i]); - RT3[i] = ROTL8(RT2[i]); -#endif /* !MBEDTLS_AES_FEWER_TABLES */ - } -} - -#undef ROTL8 - -#endif /* MBEDTLS_AES_ROM_TABLES */ - -#if defined(MBEDTLS_AES_FEWER_TABLES) - -#define ROTL8(x) ((uint32_t)((x) << 8) + (uint32_t)((x) >> 24)) -#define ROTL16(x) ((uint32_t)((x) << 16) + (uint32_t)((x) >> 16)) -#define ROTL24(x) ((uint32_t)((x) << 24) + (uint32_t)((x) >> 8)) - -#define AES_RT0(idx) RT0[idx] -#define AES_RT1(idx) ROTL8(RT0[idx]) -#define AES_RT2(idx) ROTL16(RT0[idx]) -#define AES_RT3(idx) ROTL24(RT0[idx]) - -#define AES_FT0(idx) FT0[idx] -#define AES_FT1(idx) ROTL8(FT0[idx]) -#define AES_FT2(idx) ROTL16(FT0[idx]) -#define AES_FT3(idx) ROTL24(FT0[idx]) - -#else /* MBEDTLS_AES_FEWER_TABLES */ - -#define AES_RT0(idx) RT0[idx] -#define AES_RT1(idx) RT1[idx] -#define AES_RT2(idx) RT2[idx] -#define AES_RT3(idx) RT3[idx] - -#define AES_FT0(idx) FT0[idx] -#define AES_FT1(idx) FT1[idx] -#define AES_FT2(idx) FT2[idx] -#define AES_FT3(idx) FT3[idx] - -#endif /* MBEDTLS_AES_FEWER_TABLES */ - -void mbedtls_aes_init(mbedtls_aes_context * ctx) -{ - AES_VALIDATE(ctx != NULL); - - memset(ctx, 0, sizeof(mbedtls_aes_context)); -} - -void mbedtls_aes_free(mbedtls_aes_context * ctx) -{ - if (ctx == NULL) - return; - - mbedtls_platform_zeroize(ctx, sizeof(mbedtls_aes_context)); -} - -#if defined(MBEDTLS_CIPHER_MODE_XTS) -void mbedtls_aes_xts_init(mbedtls_aes_xts_context * ctx) -{ - AES_VALIDATE(ctx != NULL); - - mbedtls_aes_init(&ctx->crypt); - mbedtls_aes_init(&ctx->tweak); -} - -void mbedtls_aes_xts_free(mbedtls_aes_xts_context * ctx) -{ - if (ctx == NULL) - return; - - mbedtls_aes_free(&ctx->crypt); - mbedtls_aes_free(&ctx->tweak); -} -#endif /* MBEDTLS_CIPHER_MODE_XTS */ - -/* - * AES key schedule (encryption) - */ -#if !defined(MBEDTLS_AES_SETKEY_ENC_ALT) -int mbedtls_aes_setkey_enc(mbedtls_aes_context * ctx, const unsigned char * key, unsigned int keybits) -{ - unsigned int i; - uint32_t * RK; - - AES_VALIDATE_RET(ctx != NULL); - AES_VALIDATE_RET(key != NULL); - - if (keybits == 128) - { - ctx->nr = 10; - memcpy(ctx->buf, key, 16); - return 0; - } - - switch (keybits) - { - case 128: - ctx->nr = 10; - break; - case 192: - ctx->nr = 12; - break; - case 256: - ctx->nr = 14; - break; - default: - return (MBEDTLS_ERR_AES_INVALID_KEY_LENGTH); - } - -#if !defined(MBEDTLS_AES_ROM_TABLES) - if (aes_init_done == 0) - { - aes_gen_tables(); - aes_init_done = 1; - } -#endif - -#if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_PADLOCK_ALIGN16) - if (aes_padlock_ace == -1) - aes_padlock_ace = mbedtls_padlock_has_support(MBEDTLS_PADLOCK_ACE); - - if (aes_padlock_ace) - ctx->rk = RK = MBEDTLS_PADLOCK_ALIGN16(ctx->buf); - else -#endif - ctx->rk = RK = ctx->buf; - -#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64) - if (mbedtls_aesni_has_support(MBEDTLS_AESNI_AES)) - return (mbedtls_aesni_setkey_enc((unsigned char *) ctx->rk, key, keybits)); -#endif - - for (i = 0; i < (keybits >> 5); i++) - { - GET_UINT32_LE(RK[i], key, i << 2); - } - - switch (ctx->nr) - { - case 10: - - for (i = 0; i < 10; i++, RK += 4) - { - RK[4] = RK[0] ^ RCON[i] ^ ((uint32_t) FSb[(RK[3] >> 8) & 0xFF]) ^ ((uint32_t) FSb[(RK[3] >> 16) & 0xFF] << 8) ^ - ((uint32_t) FSb[(RK[3] >> 24) & 0xFF] << 16) ^ ((uint32_t) FSb[(RK[3]) & 0xFF] << 24); - - RK[5] = RK[1] ^ RK[4]; - RK[6] = RK[2] ^ RK[5]; - RK[7] = RK[3] ^ RK[6]; - } - break; - - case 12: - - for (i = 0; i < 8; i++, RK += 6) - { - RK[6] = RK[0] ^ RCON[i] ^ ((uint32_t) FSb[(RK[5] >> 8) & 0xFF]) ^ ((uint32_t) FSb[(RK[5] >> 16) & 0xFF] << 8) ^ - ((uint32_t) FSb[(RK[5] >> 24) & 0xFF] << 16) ^ ((uint32_t) FSb[(RK[5]) & 0xFF] << 24); - - RK[7] = RK[1] ^ RK[6]; - RK[8] = RK[2] ^ RK[7]; - RK[9] = RK[3] ^ RK[8]; - RK[10] = RK[4] ^ RK[9]; - RK[11] = RK[5] ^ RK[10]; - } - break; - - case 14: - - for (i = 0; i < 7; i++, RK += 8) - { - RK[8] = RK[0] ^ RCON[i] ^ ((uint32_t) FSb[(RK[7] >> 8) & 0xFF]) ^ ((uint32_t) FSb[(RK[7] >> 16) & 0xFF] << 8) ^ - ((uint32_t) FSb[(RK[7] >> 24) & 0xFF] << 16) ^ ((uint32_t) FSb[(RK[7]) & 0xFF] << 24); - - RK[9] = RK[1] ^ RK[8]; - RK[10] = RK[2] ^ RK[9]; - RK[11] = RK[3] ^ RK[10]; - - RK[12] = RK[4] ^ ((uint32_t) FSb[(RK[11]) & 0xFF]) ^ ((uint32_t) FSb[(RK[11] >> 8) & 0xFF] << 8) ^ - ((uint32_t) FSb[(RK[11] >> 16) & 0xFF] << 16) ^ ((uint32_t) FSb[(RK[11] >> 24) & 0xFF] << 24); - - RK[13] = RK[5] ^ RK[12]; - RK[14] = RK[6] ^ RK[13]; - RK[15] = RK[7] ^ RK[14]; - } - break; - } - - return (0); -} -#endif /* !MBEDTLS_AES_SETKEY_ENC_ALT */ - -/* - * AES key schedule (decryption) - */ -#if !defined(MBEDTLS_AES_SETKEY_DEC_ALT) -int mbedtls_aes_setkey_dec(mbedtls_aes_context * ctx, const unsigned char * key, unsigned int keybits) -{ - int i, j, ret; - mbedtls_aes_context cty; - uint32_t * RK; - uint32_t * SK; - - AES_VALIDATE_RET(ctx != NULL); - AES_VALIDATE_RET(key != NULL); - - if (keybits == 128) - { - ctx->nr = 10; - memcpy(ctx->buf, key, 16); - return 0; - } - - mbedtls_aes_init(&cty); - -#if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_PADLOCK_ALIGN16) - if (aes_padlock_ace == -1) - aes_padlock_ace = mbedtls_padlock_has_support(MBEDTLS_PADLOCK_ACE); - - if (aes_padlock_ace) - ctx->rk = RK = MBEDTLS_PADLOCK_ALIGN16(ctx->buf); - else -#endif - ctx->rk = RK = ctx->buf; - - /* Also checks keybits */ - if ((ret = mbedtls_aes_setkey_enc(&cty, key, keybits)) != 0) - goto exit; - - ctx->nr = cty.nr; - -#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64) - if (mbedtls_aesni_has_support(MBEDTLS_AESNI_AES)) - { - mbedtls_aesni_inverse_key((unsigned char *) ctx->rk, (const unsigned char *) cty.rk, ctx->nr); - goto exit; - } -#endif - - SK = cty.rk + cty.nr * 4; - - *RK++ = *SK++; - *RK++ = *SK++; - *RK++ = *SK++; - *RK++ = *SK++; - - for (i = ctx->nr - 1, SK -= 8; i > 0; i--, SK -= 8) - { - for (j = 0; j < 4; j++, SK++) - { - *RK++ = AES_RT0(FSb[(*SK) & 0xFF]) ^ AES_RT1(FSb[(*SK >> 8) & 0xFF]) ^ AES_RT2(FSb[(*SK >> 16) & 0xFF]) ^ - AES_RT3(FSb[(*SK >> 24) & 0xFF]); - } - } - - *RK++ = *SK++; - *RK++ = *SK++; - *RK++ = *SK++; - *RK++ = *SK++; - -exit: - mbedtls_aes_free(&cty); - - return (ret); -} -#endif /* !MBEDTLS_AES_SETKEY_DEC_ALT */ - -#if defined(MBEDTLS_CIPHER_MODE_XTS) -static int mbedtls_aes_xts_decode_keys(const unsigned char * key, unsigned int keybits, const unsigned char ** key1, - unsigned int * key1bits, const unsigned char ** key2, unsigned int * key2bits) -{ - const unsigned int half_keybits = keybits / 2; - const unsigned int half_keybytes = half_keybits / 8; - - switch (keybits) - { - case 256: - break; - case 512: - break; - default: - return (MBEDTLS_ERR_AES_INVALID_KEY_LENGTH); - } - - *key1bits = half_keybits; - *key2bits = half_keybits; - *key1 = &key[0]; - *key2 = &key[half_keybytes]; - - return 0; -} - -int mbedtls_aes_xts_setkey_enc(mbedtls_aes_xts_context * ctx, const unsigned char * key, unsigned int keybits) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - const unsigned char *key1, *key2; - unsigned int key1bits, key2bits; - - AES_VALIDATE_RET(ctx != NULL); - AES_VALIDATE_RET(key != NULL); - - ret = mbedtls_aes_xts_decode_keys(key, keybits, &key1, &key1bits, &key2, &key2bits); - if (ret != 0) - return (ret); - - /* Set the tweak key. Always set tweak key for the encryption mode. */ - ret = mbedtls_aes_setkey_enc(&ctx->tweak, key2, key2bits); - if (ret != 0) - return (ret); - - /* Set crypt key for encryption. */ - return mbedtls_aes_setkey_enc(&ctx->crypt, key1, key1bits); -} - -int mbedtls_aes_xts_setkey_dec(mbedtls_aes_xts_context * ctx, const unsigned char * key, unsigned int keybits) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - const unsigned char *key1, *key2; - unsigned int key1bits, key2bits; - - AES_VALIDATE_RET(ctx != NULL); - AES_VALIDATE_RET(key != NULL); - - ret = mbedtls_aes_xts_decode_keys(key, keybits, &key1, &key1bits, &key2, &key2bits); - if (ret != 0) - return (ret); - - /* Set the tweak key. Always set tweak key for encryption. */ - ret = mbedtls_aes_setkey_enc(&ctx->tweak, key2, key2bits); - if (ret != 0) - return (ret); - - /* Set crypt key for decryption. */ - return mbedtls_aes_setkey_dec(&ctx->crypt, key1, key1bits); -} -#endif /* MBEDTLS_CIPHER_MODE_XTS */ - -#define AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3) \ - do \ - { \ - (X0) = *RK++ ^ AES_FT0(((Y0)) & 0xFF) ^ AES_FT1(((Y1) >> 8) & 0xFF) ^ AES_FT2(((Y2) >> 16) & 0xFF) ^ \ - AES_FT3(((Y3) >> 24) & 0xFF); \ - \ - (X1) = *RK++ ^ AES_FT0(((Y1)) & 0xFF) ^ AES_FT1(((Y2) >> 8) & 0xFF) ^ AES_FT2(((Y3) >> 16) & 0xFF) ^ \ - AES_FT3(((Y0) >> 24) & 0xFF); \ - \ - (X2) = *RK++ ^ AES_FT0(((Y2)) & 0xFF) ^ AES_FT1(((Y3) >> 8) & 0xFF) ^ AES_FT2(((Y0) >> 16) & 0xFF) ^ \ - AES_FT3(((Y1) >> 24) & 0xFF); \ - \ - (X3) = *RK++ ^ AES_FT0(((Y3)) & 0xFF) ^ AES_FT1(((Y0) >> 8) & 0xFF) ^ AES_FT2(((Y1) >> 16) & 0xFF) ^ \ - AES_FT3(((Y2) >> 24) & 0xFF); \ - } while (0) - -#define AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3) \ - do \ - { \ - (X0) = *RK++ ^ AES_RT0(((Y0)) & 0xFF) ^ AES_RT1(((Y3) >> 8) & 0xFF) ^ AES_RT2(((Y2) >> 16) & 0xFF) ^ \ - AES_RT3(((Y1) >> 24) & 0xFF); \ - \ - (X1) = *RK++ ^ AES_RT0(((Y1)) & 0xFF) ^ AES_RT1(((Y0) >> 8) & 0xFF) ^ AES_RT2(((Y3) >> 16) & 0xFF) ^ \ - AES_RT3(((Y2) >> 24) & 0xFF); \ - \ - (X2) = *RK++ ^ AES_RT0(((Y2)) & 0xFF) ^ AES_RT1(((Y1) >> 8) & 0xFF) ^ AES_RT2(((Y0) >> 16) & 0xFF) ^ \ - AES_RT3(((Y3) >> 24) & 0xFF); \ - \ - (X3) = *RK++ ^ AES_RT0(((Y3)) & 0xFF) ^ AES_RT1(((Y2) >> 8) & 0xFF) ^ AES_RT2(((Y1) >> 16) & 0xFF) ^ \ - AES_RT3(((Y0) >> 24) & 0xFF); \ - } while (0) - -/* - * AES-ECB block encryption - */ -#if !defined(MBEDTLS_AES_ENCRYPT_ALT) -int mbedtls_internal_aes_encrypt(mbedtls_aes_context * ctx, const unsigned char input[16], unsigned char output[16]) -{ - if (ctx->nr == 10) - { - mbedtls_aes_lock(); - (void) aes_encrypt((unsigned char *) ctx->buf, (unsigned char *) input, output); - mbedtls_aes_unlock(); - return 0; - } - - int i; - uint32_t * RK = ctx->rk; - struct - { - uint32_t X[4]; - uint32_t Y[4]; - } t; - - GET_UINT32_LE(t.X[0], input, 0); - t.X[0] ^= *RK++; - GET_UINT32_LE(t.X[1], input, 4); - t.X[1] ^= *RK++; - GET_UINT32_LE(t.X[2], input, 8); - t.X[2] ^= *RK++; - GET_UINT32_LE(t.X[3], input, 12); - t.X[3] ^= *RK++; - - for (i = (ctx->nr >> 1) - 1; i > 0; i--) - { - AES_FROUND(t.Y[0], t.Y[1], t.Y[2], t.Y[3], t.X[0], t.X[1], t.X[2], t.X[3]); - AES_FROUND(t.X[0], t.X[1], t.X[2], t.X[3], t.Y[0], t.Y[1], t.Y[2], t.Y[3]); - } - - AES_FROUND(t.Y[0], t.Y[1], t.Y[2], t.Y[3], t.X[0], t.X[1], t.X[2], t.X[3]); - - t.X[0] = *RK++ ^ ((uint32_t) FSb[(t.Y[0]) & 0xFF]) ^ ((uint32_t) FSb[(t.Y[1] >> 8) & 0xFF] << 8) ^ - ((uint32_t) FSb[(t.Y[2] >> 16) & 0xFF] << 16) ^ ((uint32_t) FSb[(t.Y[3] >> 24) & 0xFF] << 24); - - t.X[1] = *RK++ ^ ((uint32_t) FSb[(t.Y[1]) & 0xFF]) ^ ((uint32_t) FSb[(t.Y[2] >> 8) & 0xFF] << 8) ^ - ((uint32_t) FSb[(t.Y[3] >> 16) & 0xFF] << 16) ^ ((uint32_t) FSb[(t.Y[0] >> 24) & 0xFF] << 24); - - t.X[2] = *RK++ ^ ((uint32_t) FSb[(t.Y[2]) & 0xFF]) ^ ((uint32_t) FSb[(t.Y[3] >> 8) & 0xFF] << 8) ^ - ((uint32_t) FSb[(t.Y[0] >> 16) & 0xFF] << 16) ^ ((uint32_t) FSb[(t.Y[1] >> 24) & 0xFF] << 24); - - t.X[3] = *RK++ ^ ((uint32_t) FSb[(t.Y[3]) & 0xFF]) ^ ((uint32_t) FSb[(t.Y[0] >> 8) & 0xFF] << 8) ^ - ((uint32_t) FSb[(t.Y[1] >> 16) & 0xFF] << 16) ^ ((uint32_t) FSb[(t.Y[2] >> 24) & 0xFF] << 24); - - PUT_UINT32_LE(t.X[0], output, 0); - PUT_UINT32_LE(t.X[1], output, 4); - PUT_UINT32_LE(t.X[2], output, 8); - PUT_UINT32_LE(t.X[3], output, 12); - - mbedtls_platform_zeroize(&t, sizeof(t)); - - return (0); -} -#endif /* !MBEDTLS_AES_ENCRYPT_ALT */ - -/* - * AES-ECB block decryption - */ -#if !defined(MBEDTLS_AES_DECRYPT_ALT) -int mbedtls_internal_aes_decrypt(mbedtls_aes_context * ctx, const unsigned char input[16], unsigned char output[16]) -{ - if (ctx->nr == 10) - { - mbedtls_aes_lock(); - (void) aes_decrypt((unsigned char *) ctx->buf, (unsigned char *) input, output); - mbedtls_aes_unlock(); - return 0; - } - - int i; - uint32_t * RK = ctx->rk; - struct - { - uint32_t X[4]; - uint32_t Y[4]; - } t; - - GET_UINT32_LE(t.X[0], input, 0); - t.X[0] ^= *RK++; - GET_UINT32_LE(t.X[1], input, 4); - t.X[1] ^= *RK++; - GET_UINT32_LE(t.X[2], input, 8); - t.X[2] ^= *RK++; - GET_UINT32_LE(t.X[3], input, 12); - t.X[3] ^= *RK++; - - for (i = (ctx->nr >> 1) - 1; i > 0; i--) - { - AES_RROUND(t.Y[0], t.Y[1], t.Y[2], t.Y[3], t.X[0], t.X[1], t.X[2], t.X[3]); - AES_RROUND(t.X[0], t.X[1], t.X[2], t.X[3], t.Y[0], t.Y[1], t.Y[2], t.Y[3]); - } - - AES_RROUND(t.Y[0], t.Y[1], t.Y[2], t.Y[3], t.X[0], t.X[1], t.X[2], t.X[3]); - - t.X[0] = *RK++ ^ ((uint32_t) RSb[(t.Y[0]) & 0xFF]) ^ ((uint32_t) RSb[(t.Y[3] >> 8) & 0xFF] << 8) ^ - ((uint32_t) RSb[(t.Y[2] >> 16) & 0xFF] << 16) ^ ((uint32_t) RSb[(t.Y[1] >> 24) & 0xFF] << 24); - - t.X[1] = *RK++ ^ ((uint32_t) RSb[(t.Y[1]) & 0xFF]) ^ ((uint32_t) RSb[(t.Y[0] >> 8) & 0xFF] << 8) ^ - ((uint32_t) RSb[(t.Y[3] >> 16) & 0xFF] << 16) ^ ((uint32_t) RSb[(t.Y[2] >> 24) & 0xFF] << 24); - - t.X[2] = *RK++ ^ ((uint32_t) RSb[(t.Y[2]) & 0xFF]) ^ ((uint32_t) RSb[(t.Y[1] >> 8) & 0xFF] << 8) ^ - ((uint32_t) RSb[(t.Y[0] >> 16) & 0xFF] << 16) ^ ((uint32_t) RSb[(t.Y[3] >> 24) & 0xFF] << 24); - - t.X[3] = *RK++ ^ ((uint32_t) RSb[(t.Y[3]) & 0xFF]) ^ ((uint32_t) RSb[(t.Y[2] >> 8) & 0xFF] << 8) ^ - ((uint32_t) RSb[(t.Y[1] >> 16) & 0xFF] << 16) ^ ((uint32_t) RSb[(t.Y[0] >> 24) & 0xFF] << 24); - - PUT_UINT32_LE(t.X[0], output, 0); - PUT_UINT32_LE(t.X[1], output, 4); - PUT_UINT32_LE(t.X[2], output, 8); - PUT_UINT32_LE(t.X[3], output, 12); - - mbedtls_platform_zeroize(&t, sizeof(t)); - - return (0); -} -#endif /* !MBEDTLS_AES_DECRYPT_ALT */ - -/* - * AES-ECB block encryption/decryption - */ -int mbedtls_aes_crypt_ecb(mbedtls_aes_context * ctx, int mode, const unsigned char input[16], unsigned char output[16]) -{ - AES_VALIDATE_RET(ctx != NULL); - AES_VALIDATE_RET(input != NULL); - AES_VALIDATE_RET(output != NULL); - AES_VALIDATE_RET(mode == MBEDTLS_AES_ENCRYPT || mode == MBEDTLS_AES_DECRYPT); - -#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64) - if (mbedtls_aesni_has_support(MBEDTLS_AESNI_AES)) - return (mbedtls_aesni_crypt_ecb(ctx, mode, input, output)); -#endif - -#if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_HAVE_X86) - if (aes_padlock_ace > 0) - { - if (mbedtls_padlock_xcryptecb(ctx, mode, input, output) == 0) - return (0); - - // If padlock data misaligned, we just fall back to - // unaccelerated mode - // - } -#endif - - if (mode == MBEDTLS_AES_ENCRYPT) - return (mbedtls_internal_aes_encrypt(ctx, input, output)); - else - return (mbedtls_internal_aes_decrypt(ctx, input, output)); -} - -#if defined(MBEDTLS_CIPHER_MODE_CBC) -/* - * AES-CBC buffer encryption/decryption - */ -int mbedtls_aes_crypt_cbc(mbedtls_aes_context * ctx, int mode, size_t length, unsigned char iv[16], const unsigned char * input, - unsigned char * output) -{ - int i; - unsigned char temp[16]; - - AES_VALIDATE_RET(ctx != NULL); - AES_VALIDATE_RET(mode == MBEDTLS_AES_ENCRYPT || mode == MBEDTLS_AES_DECRYPT); - AES_VALIDATE_RET(iv != NULL); - AES_VALIDATE_RET(input != NULL); - AES_VALIDATE_RET(output != NULL); - - if (length % 16) - return (MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH); - -#if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_HAVE_X86) - if (aes_padlock_ace > 0) - { - if (mbedtls_padlock_xcryptcbc(ctx, mode, length, iv, input, output) == 0) - return (0); - - // If padlock data misaligned, we just fall back to - // unaccelerated mode - // - } -#endif - - if (mode == MBEDTLS_AES_DECRYPT) - { - while (length > 0) - { - memcpy(temp, input, 16); - mbedtls_aes_crypt_ecb(ctx, mode, input, output); - - for (i = 0; i < 16; i++) - output[i] = (unsigned char) (output[i] ^ iv[i]); - - memcpy(iv, temp, 16); - - input += 16; - output += 16; - length -= 16; - } - } - else - { - while (length > 0) - { - for (i = 0; i < 16; i++) - output[i] = (unsigned char) (input[i] ^ iv[i]); - - mbedtls_aes_crypt_ecb(ctx, mode, output, output); - memcpy(iv, output, 16); - - input += 16; - output += 16; - length -= 16; - } - } - - return (0); -} -#endif /* MBEDTLS_CIPHER_MODE_CBC */ - -#if defined(MBEDTLS_CIPHER_MODE_XTS) - -/* Endianess with 64 bits values */ -#ifndef GET_UINT64_LE -#define GET_UINT64_LE(n, b, i) \ - { \ - (n) = ((uint64_t)(b)[(i) + 7] << 56) | ((uint64_t)(b)[(i) + 6] << 48) | ((uint64_t)(b)[(i) + 5] << 40) | \ - ((uint64_t)(b)[(i) + 4] << 32) | ((uint64_t)(b)[(i) + 3] << 24) | ((uint64_t)(b)[(i) + 2] << 16) | \ - ((uint64_t)(b)[(i) + 1] << 8) | ((uint64_t)(b)[(i)]); \ - } -#endif - -#ifndef PUT_UINT64_LE -#define PUT_UINT64_LE(n, b, i) \ - { \ - (b)[(i) + 7] = (unsigned char) ((n) >> 56); \ - (b)[(i) + 6] = (unsigned char) ((n) >> 48); \ - (b)[(i) + 5] = (unsigned char) ((n) >> 40); \ - (b)[(i) + 4] = (unsigned char) ((n) >> 32); \ - (b)[(i) + 3] = (unsigned char) ((n) >> 24); \ - (b)[(i) + 2] = (unsigned char) ((n) >> 16); \ - (b)[(i) + 1] = (unsigned char) ((n) >> 8); \ - (b)[(i)] = (unsigned char) ((n)); \ - } -#endif - -typedef unsigned char mbedtls_be128[16]; - -/* - * GF(2^128) multiplication function - * - * This function multiplies a field element by x in the polynomial field - * representation. It uses 64-bit word operations to gain speed but compensates - * for machine endianess and hence works correctly on both big and little - * endian machines. - */ -static void mbedtls_gf128mul_x_ble(unsigned char r[16], const unsigned char x[16]) -{ - uint64_t a, b, ra, rb; - - GET_UINT64_LE(a, x, 0); - GET_UINT64_LE(b, x, 8); - - ra = (a << 1) ^ 0x0087 >> (8 - ((b >> 63) << 3)); - rb = (a >> 63) | (b << 1); - - PUT_UINT64_LE(ra, r, 0); - PUT_UINT64_LE(rb, r, 8); -} - -/* - * AES-XTS buffer encryption/decryption - */ -int mbedtls_aes_crypt_xts(mbedtls_aes_xts_context * ctx, int mode, size_t length, const unsigned char data_unit[16], - const unsigned char * input, unsigned char * output) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - size_t blocks = length / 16; - size_t leftover = length % 16; - unsigned char tweak[16]; - unsigned char prev_tweak[16]; - unsigned char tmp[16]; - - AES_VALIDATE_RET(ctx != NULL); - AES_VALIDATE_RET(mode == MBEDTLS_AES_ENCRYPT || mode == MBEDTLS_AES_DECRYPT); - AES_VALIDATE_RET(data_unit != NULL); - AES_VALIDATE_RET(input != NULL); - AES_VALIDATE_RET(output != NULL); - - /* Data units must be at least 16 bytes long. */ - if (length < 16) - return MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH; - - /* NIST SP 800-38E disallows data units larger than 2**20 blocks. */ - if (length > (1 << 20) * 16) - return MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH; - - /* Compute the tweak. */ - ret = mbedtls_aes_crypt_ecb(&ctx->tweak, MBEDTLS_AES_ENCRYPT, data_unit, tweak); - if (ret != 0) - return (ret); - - while (blocks--) - { - size_t i; - - if (leftover && (mode == MBEDTLS_AES_DECRYPT) && blocks == 0) - { - /* We are on the last block in a decrypt operation that has - * leftover bytes, so we need to use the next tweak for this block, - * and this tweak for the lefover bytes. Save the current tweak for - * the leftovers and then update the current tweak for use on this, - * the last full block. */ - memcpy(prev_tweak, tweak, sizeof(tweak)); - mbedtls_gf128mul_x_ble(tweak, tweak); - } - - for (i = 0; i < 16; i++) - tmp[i] = input[i] ^ tweak[i]; - - ret = mbedtls_aes_crypt_ecb(&ctx->crypt, mode, tmp, tmp); - if (ret != 0) - return (ret); - - for (i = 0; i < 16; i++) - output[i] = tmp[i] ^ tweak[i]; - - /* Update the tweak for the next block. */ - mbedtls_gf128mul_x_ble(tweak, tweak); - - output += 16; - input += 16; - } - - if (leftover) - { - /* If we are on the leftover bytes in a decrypt operation, we need to - * use the previous tweak for these bytes (as saved in prev_tweak). */ - unsigned char * t = mode == MBEDTLS_AES_DECRYPT ? prev_tweak : tweak; - - /* We are now on the final part of the data unit, which doesn't divide - * evenly by 16. It's time for ciphertext stealing. */ - size_t i; - unsigned char * prev_output = output - 16; - - /* Copy ciphertext bytes from the previous block to our output for each - * byte of cyphertext we won't steal. At the same time, copy the - * remainder of the input for this final round (since the loop bounds - * are the same). */ - for (i = 0; i < leftover; i++) - { - output[i] = prev_output[i]; - tmp[i] = input[i] ^ t[i]; - } - - /* Copy ciphertext bytes from the previous block for input in this - * round. */ - for (; i < 16; i++) - tmp[i] = prev_output[i] ^ t[i]; - - ret = mbedtls_aes_crypt_ecb(&ctx->crypt, mode, tmp, tmp); - if (ret != 0) - return ret; - - /* Write the result back to the previous block, overriding the previous - * output we copied. */ - for (i = 0; i < 16; i++) - prev_output[i] = tmp[i] ^ t[i]; - } - - return (0); -} -#endif /* MBEDTLS_CIPHER_MODE_XTS */ - -#if defined(MBEDTLS_CIPHER_MODE_CFB) -/* - * AES-CFB128 buffer encryption/decryption - */ -int mbedtls_aes_crypt_cfb128(mbedtls_aes_context * ctx, int mode, size_t length, size_t * iv_off, unsigned char iv[16], - const unsigned char * input, unsigned char * output) -{ - int c; - size_t n; - - AES_VALIDATE_RET(ctx != NULL); - AES_VALIDATE_RET(mode == MBEDTLS_AES_ENCRYPT || mode == MBEDTLS_AES_DECRYPT); - AES_VALIDATE_RET(iv_off != NULL); - AES_VALIDATE_RET(iv != NULL); - AES_VALIDATE_RET(input != NULL); - AES_VALIDATE_RET(output != NULL); - - n = *iv_off; - - if (n > 15) - return (MBEDTLS_ERR_AES_BAD_INPUT_DATA); - - if (mode == MBEDTLS_AES_DECRYPT) - { - while (length--) - { - if (n == 0) - mbedtls_aes_crypt_ecb(ctx, MBEDTLS_AES_ENCRYPT, iv, iv); - - c = *input++; - *output++ = (unsigned char) (c ^ iv[n]); - iv[n] = (unsigned char) c; - - n = (n + 1) & 0x0F; - } - } - else - { - while (length--) - { - if (n == 0) - mbedtls_aes_crypt_ecb(ctx, MBEDTLS_AES_ENCRYPT, iv, iv); - - iv[n] = *output++ = (unsigned char) (iv[n] ^ *input++); - - n = (n + 1) & 0x0F; - } - } - - *iv_off = n; - - return (0); -} - -/* - * AES-CFB8 buffer encryption/decryption - */ -int mbedtls_aes_crypt_cfb8(mbedtls_aes_context * ctx, int mode, size_t length, unsigned char iv[16], const unsigned char * input, - unsigned char * output) -{ - unsigned char c; - unsigned char ov[17]; - - AES_VALIDATE_RET(ctx != NULL); - AES_VALIDATE_RET(mode == MBEDTLS_AES_ENCRYPT || mode == MBEDTLS_AES_DECRYPT); - AES_VALIDATE_RET(iv != NULL); - AES_VALIDATE_RET(input != NULL); - AES_VALIDATE_RET(output != NULL); - while (length--) - { - memcpy(ov, iv, 16); - mbedtls_aes_crypt_ecb(ctx, MBEDTLS_AES_ENCRYPT, iv, iv); - - if (mode == MBEDTLS_AES_DECRYPT) - ov[16] = *input; - - c = *output++ = (unsigned char) (iv[0] ^ *input++); - - if (mode == MBEDTLS_AES_ENCRYPT) - ov[16] = c; - - memcpy(iv, ov + 1, 16); - } - - return (0); -} -#endif /* MBEDTLS_CIPHER_MODE_CFB */ - -#if defined(MBEDTLS_CIPHER_MODE_OFB) -/* - * AES-OFB (Output Feedback Mode) buffer encryption/decryption - */ -int mbedtls_aes_crypt_ofb(mbedtls_aes_context * ctx, size_t length, size_t * iv_off, unsigned char iv[16], - const unsigned char * input, unsigned char * output) -{ - int ret = 0; - size_t n; - - AES_VALIDATE_RET(ctx != NULL); - AES_VALIDATE_RET(iv_off != NULL); - AES_VALIDATE_RET(iv != NULL); - AES_VALIDATE_RET(input != NULL); - AES_VALIDATE_RET(output != NULL); - - n = *iv_off; - - if (n > 15) - return (MBEDTLS_ERR_AES_BAD_INPUT_DATA); - - while (length--) - { - if (n == 0) - { - ret = mbedtls_aes_crypt_ecb(ctx, MBEDTLS_AES_ENCRYPT, iv, iv); - if (ret != 0) - goto exit; - } - *output++ = *input++ ^ iv[n]; - - n = (n + 1) & 0x0F; - } - - *iv_off = n; - -exit: - return (ret); -} -#endif /* MBEDTLS_CIPHER_MODE_OFB */ - -#if defined(MBEDTLS_CIPHER_MODE_CTR) -/* - * AES-CTR buffer encryption/decryption - */ -int mbedtls_aes_crypt_ctr(mbedtls_aes_context * ctx, size_t length, size_t * nc_off, unsigned char nonce_counter[16], - unsigned char stream_block[16], const unsigned char * input, unsigned char * output) -{ - int c, i; - size_t n; - - AES_VALIDATE_RET(ctx != NULL); - AES_VALIDATE_RET(nc_off != NULL); - AES_VALIDATE_RET(nonce_counter != NULL); - AES_VALIDATE_RET(stream_block != NULL); - AES_VALIDATE_RET(input != NULL); - AES_VALIDATE_RET(output != NULL); - - n = *nc_off; - - if (n > 0x0F) - return (MBEDTLS_ERR_AES_BAD_INPUT_DATA); - - while (length--) - { - if (n == 0) - { - mbedtls_aes_crypt_ecb(ctx, MBEDTLS_AES_ENCRYPT, nonce_counter, stream_block); - - for (i = 16; i > 0; i--) - if (++nonce_counter[i - 1] != 0) - break; - } - c = *input++; - *output++ = (unsigned char) (c ^ stream_block[n]); - - n = (n + 1) & 0x0F; - } - - *nc_off = n; - - return (0); -} -#endif /* MBEDTLS_CIPHER_MODE_CTR */ - -#endif /* MBEDTLS_AES_ALT */ - -#if 0 /* use (MBEDTLS_SELF_TEST) from library */ -/* - * AES test vectors from: - * - * http://csrc.nist.gov/archive/aes/rijndael/rijndael-vals.zip - */ -static const unsigned char aes_test_ecb_dec[3][16] = -{ - { 0x44, 0x41, 0x6A, 0xC2, 0xD1, 0xF5, 0x3C, 0x58, - 0x33, 0x03, 0x91, 0x7E, 0x6B, 0xE9, 0xEB, 0xE0 }, - { 0x48, 0xE3, 0x1E, 0x9E, 0x25, 0x67, 0x18, 0xF2, - 0x92, 0x29, 0x31, 0x9C, 0x19, 0xF1, 0x5B, 0xA4 }, - { 0x05, 0x8C, 0xCF, 0xFD, 0xBB, 0xCB, 0x38, 0x2D, - 0x1F, 0x6F, 0x56, 0x58, 0x5D, 0x8A, 0x4A, 0xDE } -}; - -static const unsigned char aes_test_ecb_enc[3][16] = -{ - { 0xC3, 0x4C, 0x05, 0x2C, 0xC0, 0xDA, 0x8D, 0x73, - 0x45, 0x1A, 0xFE, 0x5F, 0x03, 0xBE, 0x29, 0x7F }, - { 0xF3, 0xF6, 0x75, 0x2A, 0xE8, 0xD7, 0x83, 0x11, - 0x38, 0xF0, 0x41, 0x56, 0x06, 0x31, 0xB1, 0x14 }, - { 0x8B, 0x79, 0xEE, 0xCC, 0x93, 0xA0, 0xEE, 0x5D, - 0xFF, 0x30, 0xB4, 0xEA, 0x21, 0x63, 0x6D, 0xA4 } -}; - -#if defined(MBEDTLS_CIPHER_MODE_CBC) -static const unsigned char aes_test_cbc_dec[3][16] = -{ - { 0xFA, 0xCA, 0x37, 0xE0, 0xB0, 0xC8, 0x53, 0x73, - 0xDF, 0x70, 0x6E, 0x73, 0xF7, 0xC9, 0xAF, 0x86 }, - { 0x5D, 0xF6, 0x78, 0xDD, 0x17, 0xBA, 0x4E, 0x75, - 0xB6, 0x17, 0x68, 0xC6, 0xAD, 0xEF, 0x7C, 0x7B }, - { 0x48, 0x04, 0xE1, 0x81, 0x8F, 0xE6, 0x29, 0x75, - 0x19, 0xA3, 0xE8, 0x8C, 0x57, 0x31, 0x04, 0x13 } -}; - -static const unsigned char aes_test_cbc_enc[3][16] = -{ - { 0x8A, 0x05, 0xFC, 0x5E, 0x09, 0x5A, 0xF4, 0x84, - 0x8A, 0x08, 0xD3, 0x28, 0xD3, 0x68, 0x8E, 0x3D }, - { 0x7B, 0xD9, 0x66, 0xD5, 0x3A, 0xD8, 0xC1, 0xBB, - 0x85, 0xD2, 0xAD, 0xFA, 0xE8, 0x7B, 0xB1, 0x04 }, - { 0xFE, 0x3C, 0x53, 0x65, 0x3E, 0x2F, 0x45, 0xB5, - 0x6F, 0xCD, 0x88, 0xB2, 0xCC, 0x89, 0x8F, 0xF0 } -}; -#endif /* MBEDTLS_CIPHER_MODE_CBC */ - -#if defined(MBEDTLS_CIPHER_MODE_CFB) -/* - * AES-CFB128 test vectors from: - * - * http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf - */ -static const unsigned char aes_test_cfb128_key[3][32] = -{ - { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, - 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C }, - { 0x8E, 0x73, 0xB0, 0xF7, 0xDA, 0x0E, 0x64, 0x52, - 0xC8, 0x10, 0xF3, 0x2B, 0x80, 0x90, 0x79, 0xE5, - 0x62, 0xF8, 0xEA, 0xD2, 0x52, 0x2C, 0x6B, 0x7B }, - { 0x60, 0x3D, 0xEB, 0x10, 0x15, 0xCA, 0x71, 0xBE, - 0x2B, 0x73, 0xAE, 0xF0, 0x85, 0x7D, 0x77, 0x81, - 0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7, - 0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4 } -}; - -static const unsigned char aes_test_cfb128_iv[16] = -{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F -}; - -static const unsigned char aes_test_cfb128_pt[64] = -{ - 0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96, - 0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A, - 0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C, - 0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51, - 0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11, - 0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF, - 0xF6, 0x9F, 0x24, 0x45, 0xDF, 0x4F, 0x9B, 0x17, - 0xAD, 0x2B, 0x41, 0x7B, 0xE6, 0x6C, 0x37, 0x10 -}; - -static const unsigned char aes_test_cfb128_ct[3][64] = -{ - { 0x3B, 0x3F, 0xD9, 0x2E, 0xB7, 0x2D, 0xAD, 0x20, - 0x33, 0x34, 0x49, 0xF8, 0xE8, 0x3C, 0xFB, 0x4A, - 0xC8, 0xA6, 0x45, 0x37, 0xA0, 0xB3, 0xA9, 0x3F, - 0xCD, 0xE3, 0xCD, 0xAD, 0x9F, 0x1C, 0xE5, 0x8B, - 0x26, 0x75, 0x1F, 0x67, 0xA3, 0xCB, 0xB1, 0x40, - 0xB1, 0x80, 0x8C, 0xF1, 0x87, 0xA4, 0xF4, 0xDF, - 0xC0, 0x4B, 0x05, 0x35, 0x7C, 0x5D, 0x1C, 0x0E, - 0xEA, 0xC4, 0xC6, 0x6F, 0x9F, 0xF7, 0xF2, 0xE6 }, - { 0xCD, 0xC8, 0x0D, 0x6F, 0xDD, 0xF1, 0x8C, 0xAB, - 0x34, 0xC2, 0x59, 0x09, 0xC9, 0x9A, 0x41, 0x74, - 0x67, 0xCE, 0x7F, 0x7F, 0x81, 0x17, 0x36, 0x21, - 0x96, 0x1A, 0x2B, 0x70, 0x17, 0x1D, 0x3D, 0x7A, - 0x2E, 0x1E, 0x8A, 0x1D, 0xD5, 0x9B, 0x88, 0xB1, - 0xC8, 0xE6, 0x0F, 0xED, 0x1E, 0xFA, 0xC4, 0xC9, - 0xC0, 0x5F, 0x9F, 0x9C, 0xA9, 0x83, 0x4F, 0xA0, - 0x42, 0xAE, 0x8F, 0xBA, 0x58, 0x4B, 0x09, 0xFF }, - { 0xDC, 0x7E, 0x84, 0xBF, 0xDA, 0x79, 0x16, 0x4B, - 0x7E, 0xCD, 0x84, 0x86, 0x98, 0x5D, 0x38, 0x60, - 0x39, 0xFF, 0xED, 0x14, 0x3B, 0x28, 0xB1, 0xC8, - 0x32, 0x11, 0x3C, 0x63, 0x31, 0xE5, 0x40, 0x7B, - 0xDF, 0x10, 0x13, 0x24, 0x15, 0xE5, 0x4B, 0x92, - 0xA1, 0x3E, 0xD0, 0xA8, 0x26, 0x7A, 0xE2, 0xF9, - 0x75, 0xA3, 0x85, 0x74, 0x1A, 0xB9, 0xCE, 0xF8, - 0x20, 0x31, 0x62, 0x3D, 0x55, 0xB1, 0xE4, 0x71 } -}; -#endif /* MBEDTLS_CIPHER_MODE_CFB */ - -#if defined(MBEDTLS_CIPHER_MODE_OFB) -/* - * AES-OFB test vectors from: - * - * https://csrc.nist.gov/publications/detail/sp/800-38a/final - */ -static const unsigned char aes_test_ofb_key[3][32] = -{ - { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, - 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C }, - { 0x8E, 0x73, 0xB0, 0xF7, 0xDA, 0x0E, 0x64, 0x52, - 0xC8, 0x10, 0xF3, 0x2B, 0x80, 0x90, 0x79, 0xE5, - 0x62, 0xF8, 0xEA, 0xD2, 0x52, 0x2C, 0x6B, 0x7B }, - { 0x60, 0x3D, 0xEB, 0x10, 0x15, 0xCA, 0x71, 0xBE, - 0x2B, 0x73, 0xAE, 0xF0, 0x85, 0x7D, 0x77, 0x81, - 0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7, - 0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4 } -}; - -static const unsigned char aes_test_ofb_iv[16] = -{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F -}; - -static const unsigned char aes_test_ofb_pt[64] = -{ - 0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96, - 0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A, - 0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C, - 0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51, - 0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11, - 0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF, - 0xF6, 0x9F, 0x24, 0x45, 0xDF, 0x4F, 0x9B, 0x17, - 0xAD, 0x2B, 0x41, 0x7B, 0xE6, 0x6C, 0x37, 0x10 -}; - -static const unsigned char aes_test_ofb_ct[3][64] = -{ - { 0x3B, 0x3F, 0xD9, 0x2E, 0xB7, 0x2D, 0xAD, 0x20, - 0x33, 0x34, 0x49, 0xF8, 0xE8, 0x3C, 0xFB, 0x4A, - 0x77, 0x89, 0x50, 0x8d, 0x16, 0x91, 0x8f, 0x03, - 0xf5, 0x3c, 0x52, 0xda, 0xc5, 0x4e, 0xd8, 0x25, - 0x97, 0x40, 0x05, 0x1e, 0x9c, 0x5f, 0xec, 0xf6, - 0x43, 0x44, 0xf7, 0xa8, 0x22, 0x60, 0xed, 0xcc, - 0x30, 0x4c, 0x65, 0x28, 0xf6, 0x59, 0xc7, 0x78, - 0x66, 0xa5, 0x10, 0xd9, 0xc1, 0xd6, 0xae, 0x5e }, - { 0xCD, 0xC8, 0x0D, 0x6F, 0xDD, 0xF1, 0x8C, 0xAB, - 0x34, 0xC2, 0x59, 0x09, 0xC9, 0x9A, 0x41, 0x74, - 0xfc, 0xc2, 0x8b, 0x8d, 0x4c, 0x63, 0x83, 0x7c, - 0x09, 0xe8, 0x17, 0x00, 0xc1, 0x10, 0x04, 0x01, - 0x8d, 0x9a, 0x9a, 0xea, 0xc0, 0xf6, 0x59, 0x6f, - 0x55, 0x9c, 0x6d, 0x4d, 0xaf, 0x59, 0xa5, 0xf2, - 0x6d, 0x9f, 0x20, 0x08, 0x57, 0xca, 0x6c, 0x3e, - 0x9c, 0xac, 0x52, 0x4b, 0xd9, 0xac, 0xc9, 0x2a }, - { 0xDC, 0x7E, 0x84, 0xBF, 0xDA, 0x79, 0x16, 0x4B, - 0x7E, 0xCD, 0x84, 0x86, 0x98, 0x5D, 0x38, 0x60, - 0x4f, 0xeb, 0xdc, 0x67, 0x40, 0xd2, 0x0b, 0x3a, - 0xc8, 0x8f, 0x6a, 0xd8, 0x2a, 0x4f, 0xb0, 0x8d, - 0x71, 0xab, 0x47, 0xa0, 0x86, 0xe8, 0x6e, 0xed, - 0xf3, 0x9d, 0x1c, 0x5b, 0xba, 0x97, 0xc4, 0x08, - 0x01, 0x26, 0x14, 0x1d, 0x67, 0xf3, 0x7b, 0xe8, - 0x53, 0x8f, 0x5a, 0x8b, 0xe7, 0x40, 0xe4, 0x84 } -}; -#endif /* MBEDTLS_CIPHER_MODE_OFB */ - -#if defined(MBEDTLS_CIPHER_MODE_CTR) -/* - * AES-CTR test vectors from: - * - * http://www.faqs.org/rfcs/rfc3686.html - */ - -static const unsigned char aes_test_ctr_key[3][16] = -{ - { 0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC, - 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E }, - { 0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7, - 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63 }, - { 0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8, - 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC } -}; - -static const unsigned char aes_test_ctr_nonce_counter[3][16] = -{ - { 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }, - { 0x00, 0x6C, 0xB6, 0xDB, 0xC0, 0x54, 0x3B, 0x59, - 0xDA, 0x48, 0xD9, 0x0B, 0x00, 0x00, 0x00, 0x01 }, - { 0x00, 0xE0, 0x01, 0x7B, 0x27, 0x77, 0x7F, 0x3F, - 0x4A, 0x17, 0x86, 0xF0, 0x00, 0x00, 0x00, 0x01 } -}; - -static const unsigned char aes_test_ctr_pt[3][48] = -{ - { 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, - 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67 }, - - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, - - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23 } -}; - -static const unsigned char aes_test_ctr_ct[3][48] = -{ - { 0xE4, 0x09, 0x5D, 0x4F, 0xB7, 0xA7, 0xB3, 0x79, - 0x2D, 0x61, 0x75, 0xA3, 0x26, 0x13, 0x11, 0xB8 }, - { 0x51, 0x04, 0xA1, 0x06, 0x16, 0x8A, 0x72, 0xD9, - 0x79, 0x0D, 0x41, 0xEE, 0x8E, 0xDA, 0xD3, 0x88, - 0xEB, 0x2E, 0x1E, 0xFC, 0x46, 0xDA, 0x57, 0xC8, - 0xFC, 0xE6, 0x30, 0xDF, 0x91, 0x41, 0xBE, 0x28 }, - { 0xC1, 0xCF, 0x48, 0xA8, 0x9F, 0x2F, 0xFD, 0xD9, - 0xCF, 0x46, 0x52, 0xE9, 0xEF, 0xDB, 0x72, 0xD7, - 0x45, 0x40, 0xA4, 0x2B, 0xDE, 0x6D, 0x78, 0x36, - 0xD5, 0x9A, 0x5C, 0xEA, 0xAE, 0xF3, 0x10, 0x53, - 0x25, 0xB2, 0x07, 0x2F } -}; - -static const int aes_test_ctr_len[3] = - { 16, 32, 36 }; -#endif /* MBEDTLS_CIPHER_MODE_CTR */ - -#if defined(MBEDTLS_CIPHER_MODE_XTS) -/* - * AES-XTS test vectors from: - * - * IEEE P1619/D16 Annex B - * https://web.archive.org/web/20150629024421/http://grouper.ieee.org/groups/1619/email/pdf00086.pdf - * (Archived from original at http://grouper.ieee.org/groups/1619/email/pdf00086.pdf) - */ -static const unsigned char aes_test_xts_key[][32] = -{ - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 }, - { 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, - 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 }, -}; - -static const unsigned char aes_test_xts_pt32[][32] = -{ - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }, - { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }, -}; - -static const unsigned char aes_test_xts_ct32[][32] = -{ - { 0x91, 0x7c, 0xf6, 0x9e, 0xbd, 0x68, 0xb2, 0xec, - 0x9b, 0x9f, 0xe9, 0xa3, 0xea, 0xdd, 0xa6, 0x92, - 0xcd, 0x43, 0xd2, 0xf5, 0x95, 0x98, 0xed, 0x85, - 0x8c, 0x02, 0xc2, 0x65, 0x2f, 0xbf, 0x92, 0x2e }, - { 0xc4, 0x54, 0x18, 0x5e, 0x6a, 0x16, 0x93, 0x6e, - 0x39, 0x33, 0x40, 0x38, 0xac, 0xef, 0x83, 0x8b, - 0xfb, 0x18, 0x6f, 0xff, 0x74, 0x80, 0xad, 0xc4, - 0x28, 0x93, 0x82, 0xec, 0xd6, 0xd3, 0x94, 0xf0 }, - { 0xaf, 0x85, 0x33, 0x6b, 0x59, 0x7a, 0xfc, 0x1a, - 0x90, 0x0b, 0x2e, 0xb2, 0x1e, 0xc9, 0x49, 0xd2, - 0x92, 0xdf, 0x4c, 0x04, 0x7e, 0x0b, 0x21, 0x53, - 0x21, 0x86, 0xa5, 0x97, 0x1a, 0x22, 0x7a, 0x89 }, -}; - -static const unsigned char aes_test_xts_data_unit[][16] = -{ - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, -}; - -#endif /* MBEDTLS_CIPHER_MODE_XTS */ - -/* - * Checkup routine - */ -int mbedtls_aes_self_test( int verbose ) -{ - int ret = 0, i, j, u, mode; - unsigned int keybits; - unsigned char key[32]; - unsigned char buf[64]; - const unsigned char *aes_tests; -#if defined(MBEDTLS_CIPHER_MODE_CBC) || defined(MBEDTLS_CIPHER_MODE_CFB) - unsigned char iv[16]; -#endif -#if defined(MBEDTLS_CIPHER_MODE_CBC) - unsigned char prv[16]; -#endif -#if defined(MBEDTLS_CIPHER_MODE_CTR) || defined(MBEDTLS_CIPHER_MODE_CFB) || defined(MBEDTLS_CIPHER_MODE_OFB) - size_t offset; -#endif -#if defined(MBEDTLS_CIPHER_MODE_CTR) || defined(MBEDTLS_CIPHER_MODE_XTS) - int len; -#endif -#if defined(MBEDTLS_CIPHER_MODE_CTR) - unsigned char nonce_counter[16]; - unsigned char stream_block[16]; -#endif - mbedtls_aes_context ctx; - - memset( key, 0, 32 ); - mbedtls_aes_init( &ctx ); - - /* - * ECB mode - */ - for( i = 0; i < 6; i++ ) - { - u = i >> 1; - keybits = 128 + u * 64; - mode = i & 1; - - if( verbose != 0 ) - mbedtls_printf( " AES-ECB-%3u (%s): ", keybits, - ( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" ); - - memset( buf, 0, 16 ); - - if( mode == MBEDTLS_AES_DECRYPT ) - { - ret = mbedtls_aes_setkey_dec( &ctx, key, keybits ); - aes_tests = aes_test_ecb_dec[u]; - } - else - { - ret = mbedtls_aes_setkey_enc( &ctx, key, keybits ); - aes_tests = aes_test_ecb_enc[u]; - } - - /* - * AES-192 is an optional feature that may be unavailable when - * there is an alternative underlying implementation i.e. when - * MBEDTLS_AES_ALT is defined. - */ - if( ret == MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED && keybits == 192 ) - { - mbedtls_printf( "skipped\n" ); - continue; - } - else if( ret != 0 ) - { - goto exit; - } - - for( j = 0; j < 10000; j++ ) - { - ret = mbedtls_aes_crypt_ecb( &ctx, mode, buf, buf ); - if( ret != 0 ) - goto exit; - } - - if( memcmp( buf, aes_tests, 16 ) != 0 ) - { - ret = 1; - goto exit; - } - - if( verbose != 0 ) - mbedtls_printf( "passed\n" ); - } - - if( verbose != 0 ) - mbedtls_printf( "\n" ); - -#if defined(MBEDTLS_CIPHER_MODE_CBC) - /* - * CBC mode - */ - for( i = 0; i < 6; i++ ) - { - u = i >> 1; - keybits = 128 + u * 64; - mode = i & 1; - - if( verbose != 0 ) - mbedtls_printf( " AES-CBC-%3u (%s): ", keybits, - ( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" ); - - memset( iv , 0, 16 ); - memset( prv, 0, 16 ); - memset( buf, 0, 16 ); - - if( mode == MBEDTLS_AES_DECRYPT ) - { - ret = mbedtls_aes_setkey_dec( &ctx, key, keybits ); - aes_tests = aes_test_cbc_dec[u]; - } - else - { - ret = mbedtls_aes_setkey_enc( &ctx, key, keybits ); - aes_tests = aes_test_cbc_enc[u]; - } - - /* - * AES-192 is an optional feature that may be unavailable when - * there is an alternative underlying implementation i.e. when - * MBEDTLS_AES_ALT is defined. - */ - if( ret == MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED && keybits == 192 ) - { - mbedtls_printf( "skipped\n" ); - continue; - } - else if( ret != 0 ) - { - goto exit; - } - - for( j = 0; j < 10000; j++ ) - { - if( mode == MBEDTLS_AES_ENCRYPT ) - { - unsigned char tmp[16]; - - memcpy( tmp, prv, 16 ); - memcpy( prv, buf, 16 ); - memcpy( buf, tmp, 16 ); - } - - ret = mbedtls_aes_crypt_cbc( &ctx, mode, 16, iv, buf, buf ); - if( ret != 0 ) - goto exit; - - } - - if( memcmp( buf, aes_tests, 16 ) != 0 ) - { - ret = 1; - goto exit; - } - - if( verbose != 0 ) - mbedtls_printf( "passed\n" ); - } - - if( verbose != 0 ) - mbedtls_printf( "\n" ); -#endif /* MBEDTLS_CIPHER_MODE_CBC */ - -#if defined(MBEDTLS_CIPHER_MODE_CFB) - /* - * CFB128 mode - */ - for( i = 0; i < 6; i++ ) - { - u = i >> 1; - keybits = 128 + u * 64; - mode = i & 1; - - if( verbose != 0 ) - mbedtls_printf( " AES-CFB128-%3u (%s): ", keybits, - ( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" ); - - memcpy( iv, aes_test_cfb128_iv, 16 ); - memcpy( key, aes_test_cfb128_key[u], keybits / 8 ); - - offset = 0; - ret = mbedtls_aes_setkey_enc( &ctx, key, keybits ); - /* - * AES-192 is an optional feature that may be unavailable when - * there is an alternative underlying implementation i.e. when - * MBEDTLS_AES_ALT is defined. - */ - if( ret == MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED && keybits == 192 ) - { - mbedtls_printf( "skipped\n" ); - continue; - } - else if( ret != 0 ) - { - goto exit; - } - - if( mode == MBEDTLS_AES_DECRYPT ) - { - memcpy( buf, aes_test_cfb128_ct[u], 64 ); - aes_tests = aes_test_cfb128_pt; - } - else - { - memcpy( buf, aes_test_cfb128_pt, 64 ); - aes_tests = aes_test_cfb128_ct[u]; - } - - ret = mbedtls_aes_crypt_cfb128( &ctx, mode, 64, &offset, iv, buf, buf ); - if( ret != 0 ) - goto exit; - - if( memcmp( buf, aes_tests, 64 ) != 0 ) - { - ret = 1; - goto exit; - } - - if( verbose != 0 ) - mbedtls_printf( "passed\n" ); - } - - if( verbose != 0 ) - mbedtls_printf( "\n" ); -#endif /* MBEDTLS_CIPHER_MODE_CFB */ - -#if defined(MBEDTLS_CIPHER_MODE_OFB) - /* - * OFB mode - */ - for( i = 0; i < 6; i++ ) - { - u = i >> 1; - keybits = 128 + u * 64; - mode = i & 1; - - if( verbose != 0 ) - mbedtls_printf( " AES-OFB-%3u (%s): ", keybits, - ( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" ); - - memcpy( iv, aes_test_ofb_iv, 16 ); - memcpy( key, aes_test_ofb_key[u], keybits / 8 ); - - offset = 0; - ret = mbedtls_aes_setkey_enc( &ctx, key, keybits ); - /* - * AES-192 is an optional feature that may be unavailable when - * there is an alternative underlying implementation i.e. when - * MBEDTLS_AES_ALT is defined. - */ - if( ret == MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED && keybits == 192 ) - { - mbedtls_printf( "skipped\n" ); - continue; - } - else if( ret != 0 ) - { - goto exit; - } - - if( mode == MBEDTLS_AES_DECRYPT ) - { - memcpy( buf, aes_test_ofb_ct[u], 64 ); - aes_tests = aes_test_ofb_pt; - } - else - { - memcpy( buf, aes_test_ofb_pt, 64 ); - aes_tests = aes_test_ofb_ct[u]; - } - - ret = mbedtls_aes_crypt_ofb( &ctx, 64, &offset, iv, buf, buf ); - if( ret != 0 ) - goto exit; - - if( memcmp( buf, aes_tests, 64 ) != 0 ) - { - ret = 1; - goto exit; - } - - if( verbose != 0 ) - mbedtls_printf( "passed\n" ); - } - - if( verbose != 0 ) - mbedtls_printf( "\n" ); -#endif /* MBEDTLS_CIPHER_MODE_OFB */ - -#if defined(MBEDTLS_CIPHER_MODE_CTR) - /* - * CTR mode - */ - for( i = 0; i < 6; i++ ) - { - u = i >> 1; - mode = i & 1; - - if( verbose != 0 ) - mbedtls_printf( " AES-CTR-128 (%s): ", - ( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" ); - - memcpy( nonce_counter, aes_test_ctr_nonce_counter[u], 16 ); - memcpy( key, aes_test_ctr_key[u], 16 ); - - offset = 0; - if( ( ret = mbedtls_aes_setkey_enc( &ctx, key, 128 ) ) != 0 ) - goto exit; - - len = aes_test_ctr_len[u]; - - if( mode == MBEDTLS_AES_DECRYPT ) - { - memcpy( buf, aes_test_ctr_ct[u], len ); - aes_tests = aes_test_ctr_pt[u]; - } - else - { - memcpy( buf, aes_test_ctr_pt[u], len ); - aes_tests = aes_test_ctr_ct[u]; - } - - ret = mbedtls_aes_crypt_ctr( &ctx, len, &offset, nonce_counter, - stream_block, buf, buf ); - if( ret != 0 ) - goto exit; - - if( memcmp( buf, aes_tests, len ) != 0 ) - { - ret = 1; - goto exit; - } - - if( verbose != 0 ) - mbedtls_printf( "passed\n" ); - } - - if( verbose != 0 ) - mbedtls_printf( "\n" ); -#endif /* MBEDTLS_CIPHER_MODE_CTR */ - -#if defined(MBEDTLS_CIPHER_MODE_XTS) - { - static const int num_tests = - sizeof(aes_test_xts_key) / sizeof(*aes_test_xts_key); - mbedtls_aes_xts_context ctx_xts; - - /* - * XTS mode - */ - mbedtls_aes_xts_init( &ctx_xts ); - - for( i = 0; i < num_tests << 1; i++ ) - { - const unsigned char *data_unit; - u = i >> 1; - mode = i & 1; - - if( verbose != 0 ) - mbedtls_printf( " AES-XTS-128 (%s): ", - ( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" ); - - memset( key, 0, sizeof( key ) ); - memcpy( key, aes_test_xts_key[u], 32 ); - data_unit = aes_test_xts_data_unit[u]; - - len = sizeof( *aes_test_xts_ct32 ); - - if( mode == MBEDTLS_AES_DECRYPT ) - { - ret = mbedtls_aes_xts_setkey_dec( &ctx_xts, key, 256 ); - if( ret != 0) - goto exit; - memcpy( buf, aes_test_xts_ct32[u], len ); - aes_tests = aes_test_xts_pt32[u]; - } - else - { - ret = mbedtls_aes_xts_setkey_enc( &ctx_xts, key, 256 ); - if( ret != 0) - goto exit; - memcpy( buf, aes_test_xts_pt32[u], len ); - aes_tests = aes_test_xts_ct32[u]; - } - - - ret = mbedtls_aes_crypt_xts( &ctx_xts, mode, len, data_unit, - buf, buf ); - if( ret != 0 ) - goto exit; - - if( memcmp( buf, aes_tests, len ) != 0 ) - { - ret = 1; - goto exit; - } - - if( verbose != 0 ) - mbedtls_printf( "passed\n" ); - } - - if( verbose != 0 ) - mbedtls_printf( "\n" ); - - mbedtls_aes_xts_free( &ctx_xts ); - } -#endif /* MBEDTLS_CIPHER_MODE_XTS */ - - ret = 0; - -exit: - if( ret != 0 && verbose != 0 ) - mbedtls_printf( "failed\n" ); - - mbedtls_aes_free( &ctx ); - - return( ret ); -} - -#endif /* MBEDTLS_SELF_TEST */ - -#endif /* MBEDTLS_AES_C */ diff --git a/src/platform/telink/crypto/internal/compatibility/aesni.h b/src/platform/telink/crypto/internal/compatibility/aesni.h deleted file mode 100644 index c53ff3f02783e3..00000000000000 --- a/src/platform/telink/crypto/internal/compatibility/aesni.h +++ /dev/null @@ -1,121 +0,0 @@ -/** - * \file aesni.h - * - * \brief AES-NI for hardware AES acceleration on some Intel processors - * - * \warning These functions are only for internal use by other library - * functions; you must not call them directly. - */ -/* - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ -#ifndef MBEDTLS_AESNI_H -#define MBEDTLS_AESNI_H - -#include "mbedtls/build_info.h" - -#include "mbedtls/aes.h" - -#define MBEDTLS_AESNI_AES 0x02000000u -#define MBEDTLS_AESNI_CLMUL 0x00000002u - -#if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && (defined(__amd64__) || defined(__x86_64__)) && !defined(MBEDTLS_HAVE_X86_64) -#define MBEDTLS_HAVE_X86_64 -#endif - -#if defined(MBEDTLS_HAVE_X86_64) - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Internal function to detect the AES-NI feature in CPUs. - * - * \note This function is only for internal use by other library - * functions; you must not call it directly. - * - * \param what The feature to detect - * (MBEDTLS_AESNI_AES or MBEDTLS_AESNI_CLMUL) - * - * \return 1 if CPU has support for the feature, 0 otherwise - */ -int mbedtls_aesni_has_support(unsigned int what); - -/** - * \brief Internal AES-NI AES-ECB block encryption and decryption - * - * \note This function is only for internal use by other library - * functions; you must not call it directly. - * - * \param ctx AES context - * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT - * \param input 16-byte input block - * \param output 16-byte output block - * - * \return 0 on success (cannot fail) - */ -int mbedtls_aesni_crypt_ecb(mbedtls_aes_context * ctx, int mode, const unsigned char input[16], unsigned char output[16]); - -/** - * \brief Internal GCM multiplication: c = a * b in GF(2^128) - * - * \note This function is only for internal use by other library - * functions; you must not call it directly. - * - * \param c Result - * \param a First operand - * \param b Second operand - * - * \note Both operands and result are bit strings interpreted as - * elements of GF(2^128) as per the GCM spec. - */ -void mbedtls_aesni_gcm_mult(unsigned char c[16], const unsigned char a[16], const unsigned char b[16]); - -/** - * \brief Internal round key inversion. This function computes - * decryption round keys from the encryption round keys. - * - * \note This function is only for internal use by other library - * functions; you must not call it directly. - * - * \param invkey Round keys for the equivalent inverse cipher - * \param fwdkey Original round keys (for encryption) - * \param nr Number of rounds (that is, number of round keys minus one) - */ -void mbedtls_aesni_inverse_key(unsigned char * invkey, const unsigned char * fwdkey, int nr); - -/** - * \brief Internal key expansion for encryption - * - * \note This function is only for internal use by other library - * functions; you must not call it directly. - * - * \param rk Destination buffer where the round keys are written - * \param key Encryption key - * \param bits Key size in bits (must be 128, 192 or 256) - * - * \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH - */ -int mbedtls_aesni_setkey_enc(unsigned char * rk, const unsigned char * key, size_t bits); - -#ifdef __cplusplus -} -#endif - -#endif /* MBEDTLS_HAVE_X86_64 */ - -#endif /* MBEDTLS_AESNI_H */ diff --git a/src/platform/telink/crypto/internal/compatibility/bn_mul.h b/src/platform/telink/crypto/internal/compatibility/bn_mul.h deleted file mode 100644 index 3de9f264cf8b74..00000000000000 --- a/src/platform/telink/crypto/internal/compatibility/bn_mul.h +++ /dev/null @@ -1,891 +0,0 @@ -/** - * \file bn_mul.h - * - * \brief Multi-precision integer library - */ -/* - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ -/* - * Multiply source vector [s] with b, add result - * to destination vector [d] and set carry c. - * - * Currently supports: - * - * . IA-32 (386+) . AMD64 / EM64T - * . IA-32 (SSE2) . Motorola 68000 - * . PowerPC, 32-bit . MicroBlaze - * . PowerPC, 64-bit . TriCore - * . SPARC v8 . ARM v3+ - * . Alpha . MIPS32 - * . C, longlong . C, generic - */ -#ifndef MBEDTLS_BN_MUL_H -#define MBEDTLS_BN_MUL_H - -#include "mbedtls/build_info.h" - -#include "mbedtls/bignum.h" - -/* - * Conversion macros for embedded constants: - * build lists of mbedtls_mpi_uint's from lists of unsigned char's grouped by 8, 4 or 2 - */ -#if defined(MBEDTLS_HAVE_INT32) - -#define MBEDTLS_BYTES_TO_T_UINT_4(a, b, c, d) \ - ((mbedtls_mpi_uint)(a) << 0) | ((mbedtls_mpi_uint)(b) << 8) | ((mbedtls_mpi_uint)(c) << 16) | ((mbedtls_mpi_uint)(d) << 24) - -#define MBEDTLS_BYTES_TO_T_UINT_2(a, b) MBEDTLS_BYTES_TO_T_UINT_4(a, b, 0, 0) - -#define MBEDTLS_BYTES_TO_T_UINT_8(a, b, c, d, e, f, g, h) \ - MBEDTLS_BYTES_TO_T_UINT_4(a, b, c, d), MBEDTLS_BYTES_TO_T_UINT_4(e, f, g, h) - -#else /* 64-bits */ - -#define MBEDTLS_BYTES_TO_T_UINT_8(a, b, c, d, e, f, g, h) \ - ((mbedtls_mpi_uint)(a) << 0) | ((mbedtls_mpi_uint)(b) << 8) | ((mbedtls_mpi_uint)(c) << 16) | ((mbedtls_mpi_uint)(d) << 24) | \ - ((mbedtls_mpi_uint)(e) << 32) | ((mbedtls_mpi_uint)(f) << 40) | ((mbedtls_mpi_uint)(g) << 48) | \ - ((mbedtls_mpi_uint)(h) << 56) - -#define MBEDTLS_BYTES_TO_T_UINT_4(a, b, c, d) MBEDTLS_BYTES_TO_T_UINT_8(a, b, c, d, 0, 0, 0, 0) - -#define MBEDTLS_BYTES_TO_T_UINT_2(a, b) MBEDTLS_BYTES_TO_T_UINT_8(a, b, 0, 0, 0, 0, 0, 0) - -#endif /* bits in mbedtls_mpi_uint */ - -#if defined(MBEDTLS_HAVE_ASM) - -#ifndef asm -#define asm __asm -#endif - -/* armcc5 --gnu defines __GNUC__ but doesn't support GNU's extended asm */ -#if defined(__GNUC__) && (!defined(__ARMCC_VERSION) || __ARMCC_VERSION >= 6000000) - -/* - * Disable use of the i386 assembly code below if option -O0, to disable all - * compiler optimisations, is passed, detected with __OPTIMIZE__ - * This is done as the number of registers used in the assembly code doesn't - * work with the -O0 option. - */ -#if defined(__i386__) && defined(__OPTIMIZE__) - -#define MULADDC_INIT \ - asm( \ - "movl %%ebx, %0 \n\t" \ - "movl %5, %%esi \n\t" \ - "movl %6, %%edi \n\t" \ - "movl %7, %%ecx \n\t" \ - "movl %8, %%ebx \n\t" - -#define MULADDC_CORE \ - "lodsl \n\t" \ - "mull %%ebx \n\t" \ - "addl %%ecx, %%eax \n\t" \ - "adcl $0, %%edx \n\t" \ - "addl (%%edi), %%eax \n\t" \ - "adcl $0, %%edx \n\t" \ - "movl %%edx, %%ecx \n\t" \ - "stosl \n\t" - -#if defined(MBEDTLS_HAVE_SSE2) - -#define MULADDC_HUIT \ - "movd %%ecx, %%mm1 \n\t" \ - "movd %%ebx, %%mm0 \n\t" \ - "movd (%%edi), %%mm3 \n\t" \ - "paddq %%mm3, %%mm1 \n\t" \ - "movd (%%esi), %%mm2 \n\t" \ - "pmuludq %%mm0, %%mm2 \n\t" \ - "movd 4(%%esi), %%mm4 \n\t" \ - "pmuludq %%mm0, %%mm4 \n\t" \ - "movd 8(%%esi), %%mm6 \n\t" \ - "pmuludq %%mm0, %%mm6 \n\t" \ - "movd 12(%%esi), %%mm7 \n\t" \ - "pmuludq %%mm0, %%mm7 \n\t" \ - "paddq %%mm2, %%mm1 \n\t" \ - "movd 4(%%edi), %%mm3 \n\t" \ - "paddq %%mm4, %%mm3 \n\t" \ - "movd 8(%%edi), %%mm5 \n\t" \ - "paddq %%mm6, %%mm5 \n\t" \ - "movd 12(%%edi), %%mm4 \n\t" \ - "paddq %%mm4, %%mm7 \n\t" \ - "movd %%mm1, (%%edi) \n\t" \ - "movd 16(%%esi), %%mm2 \n\t" \ - "pmuludq %%mm0, %%mm2 \n\t" \ - "psrlq $32, %%mm1 \n\t" \ - "movd 20(%%esi), %%mm4 \n\t" \ - "pmuludq %%mm0, %%mm4 \n\t" \ - "paddq %%mm3, %%mm1 \n\t" \ - "movd 24(%%esi), %%mm6 \n\t" \ - "pmuludq %%mm0, %%mm6 \n\t" \ - "movd %%mm1, 4(%%edi) \n\t" \ - "psrlq $32, %%mm1 \n\t" \ - "movd 28(%%esi), %%mm3 \n\t" \ - "pmuludq %%mm0, %%mm3 \n\t" \ - "paddq %%mm5, %%mm1 \n\t" \ - "movd 16(%%edi), %%mm5 \n\t" \ - "paddq %%mm5, %%mm2 \n\t" \ - "movd %%mm1, 8(%%edi) \n\t" \ - "psrlq $32, %%mm1 \n\t" \ - "paddq %%mm7, %%mm1 \n\t" \ - "movd 20(%%edi), %%mm5 \n\t" \ - "paddq %%mm5, %%mm4 \n\t" \ - "movd %%mm1, 12(%%edi) \n\t" \ - "psrlq $32, %%mm1 \n\t" \ - "paddq %%mm2, %%mm1 \n\t" \ - "movd 24(%%edi), %%mm5 \n\t" \ - "paddq %%mm5, %%mm6 \n\t" \ - "movd %%mm1, 16(%%edi) \n\t" \ - "psrlq $32, %%mm1 \n\t" \ - "paddq %%mm4, %%mm1 \n\t" \ - "movd 28(%%edi), %%mm5 \n\t" \ - "paddq %%mm5, %%mm3 \n\t" \ - "movd %%mm1, 20(%%edi) \n\t" \ - "psrlq $32, %%mm1 \n\t" \ - "paddq %%mm6, %%mm1 \n\t" \ - "movd %%mm1, 24(%%edi) \n\t" \ - "psrlq $32, %%mm1 \n\t" \ - "paddq %%mm3, %%mm1 \n\t" \ - "movd %%mm1, 28(%%edi) \n\t" \ - "addl $32, %%edi \n\t" \ - "addl $32, %%esi \n\t" \ - "psrlq $32, %%mm1 \n\t" \ - "movd %%mm1, %%ecx \n\t" - -#define MULADDC_STOP \ - "emms \n\t" \ - "movl %4, %%ebx \n\t" \ - "movl %%ecx, %1 \n\t" \ - "movl %%edi, %2 \n\t" \ - "movl %%esi, %3 \n\t" \ - : "=m" (t), "=m" (c), "=m" (d), "=m" (s) \ - : "m" (t), "m" (s), "m" (d), "m" (c), "m" (b) \ - : "eax", "ebx", "ecx", "edx", "esi", "edi" \ - ); - -#else - -#define MULADDC_STOP \ - "movl %4, %%ebx \n\t" \ - "movl %%ecx, %1 \n\t" \ - "movl %%edi, %2 \n\t" \ - "movl %%esi, %3 \n\t" \ - : "=m" (t), "=m" (c), "=m" (d), "=m" (s) \ - : "m" (t), "m" (s), "m" (d), "m" (c), "m" (b) \ - : "eax", "ebx", "ecx", "edx", "esi", "edi" \ - ); -#endif /* SSE2 */ -#endif /* i386 */ - -#if defined(__amd64__) || defined(__x86_64__) - -#define MULADDC_INIT \ - asm( \ - "xorq %%r8, %%r8\n" - -#define MULADDC_CORE \ - "movq (%%rsi), %%rax\n" \ - "mulq %%rbx\n" \ - "addq $8, %%rsi\n" \ - "addq %%rcx, %%rax\n" \ - "movq %%r8, %%rcx\n" \ - "adcq $0, %%rdx\n" \ - "nop \n" \ - "addq %%rax, (%%rdi)\n" \ - "adcq %%rdx, %%rcx\n" \ - "addq $8, %%rdi\n" - -#define MULADDC_STOP \ - : "+c" (c), "+D" (d), "+S" (s) \ - : "b" (b) \ - : "rax", "rdx", "r8" \ - ); - -#endif /* AMD64 */ - -#if defined(__aarch64__) - -#define MULADDC_INIT \ - asm( - -#define MULADDC_CORE \ - "ldr x4, [%2], #8 \n\t" \ - "ldr x5, [%1] \n\t" \ - "mul x6, x4, %3 \n\t" \ - "umulh x7, x4, %3 \n\t" \ - "adds x5, x5, x6 \n\t" \ - "adc x7, x7, xzr \n\t" \ - "adds x5, x5, %0 \n\t" \ - "adc %0, x7, xzr \n\t" \ - "str x5, [%1], #8 \n\t" - -#define MULADDC_STOP \ - : "+r" (c), "+r" (d), "+r" (s) \ - : "r" (b) \ - : "x4", "x5", "x6", "x7", "cc" \ - ); - -#endif /* Aarch64 */ - -#if defined(__mc68020__) || defined(__mcpu32__) - -#define MULADDC_INIT \ - asm( \ - "movl %3, %%a2 \n\t" \ - "movl %4, %%a3 \n\t" \ - "movl %5, %%d3 \n\t" \ - "movl %6, %%d2 \n\t" \ - "moveq #0, %%d0 \n\t" - -#define MULADDC_CORE \ - "movel %%a2@+, %%d1 \n\t" \ - "mulul %%d2, %%d4:%%d1 \n\t" \ - "addl %%d3, %%d1 \n\t" \ - "addxl %%d0, %%d4 \n\t" \ - "moveq #0, %%d3 \n\t" \ - "addl %%d1, %%a3@+ \n\t" \ - "addxl %%d4, %%d3 \n\t" - -#define MULADDC_STOP \ - "movl %%d3, %0 \n\t" \ - "movl %%a3, %1 \n\t" \ - "movl %%a2, %2 \n\t" \ - : "=m" (c), "=m" (d), "=m" (s) \ - : "m" (s), "m" (d), "m" (c), "m" (b) \ - : "d0", "d1", "d2", "d3", "d4", "a2", "a3" \ - ); - -#define MULADDC_HUIT \ - "movel %%a2@+, %%d1 \n\t" \ - "mulul %%d2, %%d4:%%d1 \n\t" \ - "addxl %%d3, %%d1 \n\t" \ - "addxl %%d0, %%d4 \n\t" \ - "addl %%d1, %%a3@+ \n\t" \ - "movel %%a2@+, %%d1 \n\t" \ - "mulul %%d2, %%d3:%%d1 \n\t" \ - "addxl %%d4, %%d1 \n\t" \ - "addxl %%d0, %%d3 \n\t" \ - "addl %%d1, %%a3@+ \n\t" \ - "movel %%a2@+, %%d1 \n\t" \ - "mulul %%d2, %%d4:%%d1 \n\t" \ - "addxl %%d3, %%d1 \n\t" \ - "addxl %%d0, %%d4 \n\t" \ - "addl %%d1, %%a3@+ \n\t" \ - "movel %%a2@+, %%d1 \n\t" \ - "mulul %%d2, %%d3:%%d1 \n\t" \ - "addxl %%d4, %%d1 \n\t" \ - "addxl %%d0, %%d3 \n\t" \ - "addl %%d1, %%a3@+ \n\t" \ - "movel %%a2@+, %%d1 \n\t" \ - "mulul %%d2, %%d4:%%d1 \n\t" \ - "addxl %%d3, %%d1 \n\t" \ - "addxl %%d0, %%d4 \n\t" \ - "addl %%d1, %%a3@+ \n\t" \ - "movel %%a2@+, %%d1 \n\t" \ - "mulul %%d2, %%d3:%%d1 \n\t" \ - "addxl %%d4, %%d1 \n\t" \ - "addxl %%d0, %%d3 \n\t" \ - "addl %%d1, %%a3@+ \n\t" \ - "movel %%a2@+, %%d1 \n\t" \ - "mulul %%d2, %%d4:%%d1 \n\t" \ - "addxl %%d3, %%d1 \n\t" \ - "addxl %%d0, %%d4 \n\t" \ - "addl %%d1, %%a3@+ \n\t" \ - "movel %%a2@+, %%d1 \n\t" \ - "mulul %%d2, %%d3:%%d1 \n\t" \ - "addxl %%d4, %%d1 \n\t" \ - "addxl %%d0, %%d3 \n\t" \ - "addl %%d1, %%a3@+ \n\t" \ - "addxl %%d0, %%d3 \n\t" - -#endif /* MC68000 */ - -#if defined(__powerpc64__) || defined(__ppc64__) - -#if defined(__MACH__) && defined(__APPLE__) - -#define MULADDC_INIT \ - asm( \ - "ld r3, %3 \n\t" \ - "ld r4, %4 \n\t" \ - "ld r5, %5 \n\t" \ - "ld r6, %6 \n\t" \ - "addi r3, r3, -8 \n\t" \ - "addi r4, r4, -8 \n\t" \ - "addic r5, r5, 0 \n\t" - -#define MULADDC_CORE \ - "ldu r7, 8(r3) \n\t" \ - "mulld r8, r7, r6 \n\t" \ - "mulhdu r9, r7, r6 \n\t" \ - "adde r8, r8, r5 \n\t" \ - "ld r7, 8(r4) \n\t" \ - "addze r5, r9 \n\t" \ - "addc r8, r8, r7 \n\t" \ - "stdu r8, 8(r4) \n\t" - -#define MULADDC_STOP \ - "addze r5, r5 \n\t" \ - "addi r4, r4, 8 \n\t" \ - "addi r3, r3, 8 \n\t" \ - "std r5, %0 \n\t" \ - "std r4, %1 \n\t" \ - "std r3, %2 \n\t" \ - : "=m" (c), "=m" (d), "=m" (s) \ - : "m" (s), "m" (d), "m" (c), "m" (b) \ - : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ - ); - -#else /* __MACH__ && __APPLE__ */ - -#define MULADDC_INIT \ - asm( \ - "ld %%r3, %3 \n\t" \ - "ld %%r4, %4 \n\t" \ - "ld %%r5, %5 \n\t" \ - "ld %%r6, %6 \n\t" \ - "addi %%r3, %%r3, -8 \n\t" \ - "addi %%r4, %%r4, -8 \n\t" \ - "addic %%r5, %%r5, 0 \n\t" - -#define MULADDC_CORE \ - "ldu %%r7, 8(%%r3) \n\t" \ - "mulld %%r8, %%r7, %%r6 \n\t" \ - "mulhdu %%r9, %%r7, %%r6 \n\t" \ - "adde %%r8, %%r8, %%r5 \n\t" \ - "ld %%r7, 8(%%r4) \n\t" \ - "addze %%r5, %%r9 \n\t" \ - "addc %%r8, %%r8, %%r7 \n\t" \ - "stdu %%r8, 8(%%r4) \n\t" - -#define MULADDC_STOP \ - "addze %%r5, %%r5 \n\t" \ - "addi %%r4, %%r4, 8 \n\t" \ - "addi %%r3, %%r3, 8 \n\t" \ - "std %%r5, %0 \n\t" \ - "std %%r4, %1 \n\t" \ - "std %%r3, %2 \n\t" \ - : "=m" (c), "=m" (d), "=m" (s) \ - : "m" (s), "m" (d), "m" (c), "m" (b) \ - : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ - ); - -#endif /* __MACH__ && __APPLE__ */ - -#elif defined(__powerpc__) || defined(__ppc__) /* end PPC64/begin PPC32 */ - -#if defined(__MACH__) && defined(__APPLE__) - -#define MULADDC_INIT \ - asm( \ - "lwz r3, %3 \n\t" \ - "lwz r4, %4 \n\t" \ - "lwz r5, %5 \n\t" \ - "lwz r6, %6 \n\t" \ - "addi r3, r3, -4 \n\t" \ - "addi r4, r4, -4 \n\t" \ - "addic r5, r5, 0 \n\t" - -#define MULADDC_CORE \ - "lwzu r7, 4(r3) \n\t" \ - "mullw r8, r7, r6 \n\t" \ - "mulhwu r9, r7, r6 \n\t" \ - "adde r8, r8, r5 \n\t" \ - "lwz r7, 4(r4) \n\t" \ - "addze r5, r9 \n\t" \ - "addc r8, r8, r7 \n\t" \ - "stwu r8, 4(r4) \n\t" - -#define MULADDC_STOP \ - "addze r5, r5 \n\t" \ - "addi r4, r4, 4 \n\t" \ - "addi r3, r3, 4 \n\t" \ - "stw r5, %0 \n\t" \ - "stw r4, %1 \n\t" \ - "stw r3, %2 \n\t" \ - : "=m" (c), "=m" (d), "=m" (s) \ - : "m" (s), "m" (d), "m" (c), "m" (b) \ - : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ - ); - -#else /* __MACH__ && __APPLE__ */ - -#define MULADDC_INIT \ - asm( \ - "lwz %%r3, %3 \n\t" \ - "lwz %%r4, %4 \n\t" \ - "lwz %%r5, %5 \n\t" \ - "lwz %%r6, %6 \n\t" \ - "addi %%r3, %%r3, -4 \n\t" \ - "addi %%r4, %%r4, -4 \n\t" \ - "addic %%r5, %%r5, 0 \n\t" - -#define MULADDC_CORE \ - "lwzu %%r7, 4(%%r3) \n\t" \ - "mullw %%r8, %%r7, %%r6 \n\t" \ - "mulhwu %%r9, %%r7, %%r6 \n\t" \ - "adde %%r8, %%r8, %%r5 \n\t" \ - "lwz %%r7, 4(%%r4) \n\t" \ - "addze %%r5, %%r9 \n\t" \ - "addc %%r8, %%r8, %%r7 \n\t" \ - "stwu %%r8, 4(%%r4) \n\t" - -#define MULADDC_STOP \ - "addze %%r5, %%r5 \n\t" \ - "addi %%r4, %%r4, 4 \n\t" \ - "addi %%r3, %%r3, 4 \n\t" \ - "stw %%r5, %0 \n\t" \ - "stw %%r4, %1 \n\t" \ - "stw %%r3, %2 \n\t" \ - : "=m" (c), "=m" (d), "=m" (s) \ - : "m" (s), "m" (d), "m" (c), "m" (b) \ - : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ - ); - -#endif /* __MACH__ && __APPLE__ */ - -#endif /* PPC32 */ - -/* - * The Sparc(64) assembly is reported to be broken. - * Disable it for now, until we're able to fix it. - */ -#if 0 && defined(__sparc__) -#if defined(__sparc64__) - -#define MULADDC_INIT \ - asm( \ - "ldx %3, %%o0 \n\t" \ - "ldx %4, %%o1 \n\t" \ - "ld %5, %%o2 \n\t" \ - "ld %6, %%o3 \n\t" - -#define MULADDC_CORE \ - "ld [%%o0], %%o4 \n\t" \ - "inc 4, %%o0 \n\t" \ - "ld [%%o1], %%o5 \n\t" \ - "umul %%o3, %%o4, %%o4 \n\t" \ - "addcc %%o4, %%o2, %%o4 \n\t" \ - "rd %%y, %%g1 \n\t" \ - "addx %%g1, 0, %%g1 \n\t" \ - "addcc %%o4, %%o5, %%o4 \n\t" \ - "st %%o4, [%%o1] \n\t" \ - "addx %%g1, 0, %%o2 \n\t" \ - "inc 4, %%o1 \n\t" - -#define MULADDC_STOP \ - "st %%o2, %0 \n\t" \ - "stx %%o1, %1 \n\t" \ - "stx %%o0, %2 \n\t" \ - : "=m" (c), "=m" (d), "=m" (s) \ - : "m" (s), "m" (d), "m" (c), "m" (b) \ - : "g1", "o0", "o1", "o2", "o3", "o4", \ - "o5" \ - ); - -#else /* __sparc64__ */ - -#define MULADDC_INIT \ - asm( \ - "ld %3, %%o0 \n\t" \ - "ld %4, %%o1 \n\t" \ - "ld %5, %%o2 \n\t" \ - "ld %6, %%o3 \n\t" - -#define MULADDC_CORE \ - "ld [%%o0], %%o4 \n\t" \ - "inc 4, %%o0 \n\t" \ - "ld [%%o1], %%o5 \n\t" \ - "umul %%o3, %%o4, %%o4 \n\t" \ - "addcc %%o4, %%o2, %%o4 \n\t" \ - "rd %%y, %%g1 \n\t" \ - "addx %%g1, 0, %%g1 \n\t" \ - "addcc %%o4, %%o5, %%o4 \n\t" \ - "st %%o4, [%%o1] \n\t" \ - "addx %%g1, 0, %%o2 \n\t" \ - "inc 4, %%o1 \n\t" - -#define MULADDC_STOP \ - "st %%o2, %0 \n\t" \ - "st %%o1, %1 \n\t" \ - "st %%o0, %2 \n\t" \ - : "=m" (c), "=m" (d), "=m" (s) \ - : "m" (s), "m" (d), "m" (c), "m" (b) \ - : "g1", "o0", "o1", "o2", "o3", "o4", \ - "o5" \ - ); - -#endif /* __sparc64__ */ -#endif /* __sparc__ */ - -#if defined(__microblaze__) || defined(microblaze) - -#define MULADDC_INIT \ - asm( \ - "lwi r3, %3 \n\t" \ - "lwi r4, %4 \n\t" \ - "lwi r5, %5 \n\t" \ - "lwi r6, %6 \n\t" \ - "andi r7, r6, 0xffff \n\t" \ - "bsrli r6, r6, 16 \n\t" - -#define MULADDC_CORE \ - "lhui r8, r3, 0 \n\t" \ - "addi r3, r3, 2 \n\t" \ - "lhui r9, r3, 0 \n\t" \ - "addi r3, r3, 2 \n\t" \ - "mul r10, r9, r6 \n\t" \ - "mul r11, r8, r7 \n\t" \ - "mul r12, r9, r7 \n\t" \ - "mul r13, r8, r6 \n\t" \ - "bsrli r8, r10, 16 \n\t" \ - "bsrli r9, r11, 16 \n\t" \ - "add r13, r13, r8 \n\t" \ - "add r13, r13, r9 \n\t" \ - "bslli r10, r10, 16 \n\t" \ - "bslli r11, r11, 16 \n\t" \ - "add r12, r12, r10 \n\t" \ - "addc r13, r13, r0 \n\t" \ - "add r12, r12, r11 \n\t" \ - "addc r13, r13, r0 \n\t" \ - "lwi r10, r4, 0 \n\t" \ - "add r12, r12, r10 \n\t" \ - "addc r13, r13, r0 \n\t" \ - "add r12, r12, r5 \n\t" \ - "addc r5, r13, r0 \n\t" \ - "swi r12, r4, 0 \n\t" \ - "addi r4, r4, 4 \n\t" - -#define MULADDC_STOP \ - "swi r5, %0 \n\t" \ - "swi r4, %1 \n\t" \ - "swi r3, %2 \n\t" \ - : "=m" (c), "=m" (d), "=m" (s) \ - : "m" (s), "m" (d), "m" (c), "m" (b) \ - : "r3", "r4", "r5", "r6", "r7", "r8", \ - "r9", "r10", "r11", "r12", "r13" \ - ); - -#endif /* MicroBlaze */ - -#if defined(__tricore__) - -#define MULADDC_INIT \ - asm( \ - "ld.a %%a2, %3 \n\t" \ - "ld.a %%a3, %4 \n\t" \ - "ld.w %%d4, %5 \n\t" \ - "ld.w %%d1, %6 \n\t" \ - "xor %%d5, %%d5 \n\t" - -#define MULADDC_CORE \ - "ld.w %%d0, [%%a2+] \n\t" \ - "madd.u %%e2, %%e4, %%d0, %%d1 \n\t" \ - "ld.w %%d0, [%%a3] \n\t" \ - "addx %%d2, %%d2, %%d0 \n\t" \ - "addc %%d3, %%d3, 0 \n\t" \ - "mov %%d4, %%d3 \n\t" \ - "st.w [%%a3+], %%d2 \n\t" - -#define MULADDC_STOP \ - "st.w %0, %%d4 \n\t" \ - "st.a %1, %%a3 \n\t" \ - "st.a %2, %%a2 \n\t" \ - : "=m" (c), "=m" (d), "=m" (s) \ - : "m" (s), "m" (d), "m" (c), "m" (b) \ - : "d0", "d1", "e2", "d4", "a2", "a3" \ - ); - -#endif /* TriCore */ - -/* - * Note, gcc -O0 by default uses r7 for the frame pointer, so it complains about - * our use of r7 below, unless -fomit-frame-pointer is passed. - * - * On the other hand, -fomit-frame-pointer is implied by any -Ox options with - * x !=0, which we can detect using __OPTIMIZE__ (which is also defined by - * clang and armcc5 under the same conditions). - * - * So, only use the optimized assembly below for optimized build, which avoids - * the build error and is pretty reasonable anyway. - */ -#if defined(__GNUC__) && !defined(__OPTIMIZE__) -#define MULADDC_CANNOT_USE_R7 -#endif - -#if defined(__arm__) && !defined(MULADDC_CANNOT_USE_R7) - -#if defined(__thumb__) && !defined(__thumb2__) - -#define MULADDC_INIT \ - asm( \ - "ldr r0, %3 \n\t" \ - "ldr r1, %4 \n\t" \ - "ldr r2, %5 \n\t" \ - "ldr r3, %6 \n\t" \ - "lsr r7, r3, #16 \n\t" \ - "mov r9, r7 \n\t" \ - "lsl r7, r3, #16 \n\t" \ - "lsr r7, r7, #16 \n\t" \ - "mov r8, r7 \n\t" - -#define MULADDC_CORE \ - "ldmia r0!, {r6} \n\t" \ - "lsr r7, r6, #16 \n\t" \ - "lsl r6, r6, #16 \n\t" \ - "lsr r6, r6, #16 \n\t" \ - "mov r4, r8 \n\t" \ - "mul r4, r6 \n\t" \ - "mov r3, r9 \n\t" \ - "mul r6, r3 \n\t" \ - "mov r5, r9 \n\t" \ - "mul r5, r7 \n\t" \ - "mov r3, r8 \n\t" \ - "mul r7, r3 \n\t" \ - "lsr r3, r6, #16 \n\t" \ - "add r5, r5, r3 \n\t" \ - "lsr r3, r7, #16 \n\t" \ - "add r5, r5, r3 \n\t" \ - "add r4, r4, r2 \n\t" \ - "mov r2, #0 \n\t" \ - "adc r5, r2 \n\t" \ - "lsl r3, r6, #16 \n\t" \ - "add r4, r4, r3 \n\t" \ - "adc r5, r2 \n\t" \ - "lsl r3, r7, #16 \n\t" \ - "add r4, r4, r3 \n\t" \ - "adc r5, r2 \n\t" \ - "ldr r3, [r1] \n\t" \ - "add r4, r4, r3 \n\t" \ - "adc r2, r5 \n\t" \ - "stmia r1!, {r4} \n\t" - -#define MULADDC_STOP \ - "str r2, %0 \n\t" \ - "str r1, %1 \n\t" \ - "str r0, %2 \n\t" \ - : "=m" (c), "=m" (d), "=m" (s) \ - : "m" (s), "m" (d), "m" (c), "m" (b) \ - : "r0", "r1", "r2", "r3", "r4", "r5", \ - "r6", "r7", "r8", "r9", "cc" \ - ); - -#elif (__ARM_ARCH >= 6) && defined(__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1) - -#define MULADDC_INIT \ - asm( - -#define MULADDC_CORE \ - "ldr r0, [%0], #4 \n\t" \ - "ldr r1, [%1] \n\t" \ - "umaal r1, %2, %3, r0 \n\t" \ - "str r1, [%1], #4 \n\t" - -#define MULADDC_STOP \ - : "=r" (s), "=r" (d), "=r" (c) \ - : "r" (b), "0" (s), "1" (d), "2" (c) \ - : "r0", "r1", "memory" \ - ); - -#else - -#define MULADDC_INIT \ - asm( \ - "ldr r0, %3 \n\t" \ - "ldr r1, %4 \n\t" \ - "ldr r2, %5 \n\t" \ - "ldr r3, %6 \n\t" - -#define MULADDC_CORE \ - "ldr r4, [r0], #4 \n\t" \ - "mov r5, #0 \n\t" \ - "ldr r6, [r1] \n\t" \ - "umlal r2, r5, r3, r4 \n\t" \ - "adds r7, r6, r2 \n\t" \ - "adc r2, r5, #0 \n\t" \ - "str r7, [r1], #4 \n\t" - -#define MULADDC_STOP \ - "str r2, %0 \n\t" \ - "str r1, %1 \n\t" \ - "str r0, %2 \n\t" \ - : "=m" (c), "=m" (d), "=m" (s) \ - : "m" (s), "m" (d), "m" (c), "m" (b) \ - : "r0", "r1", "r2", "r3", "r4", "r5", \ - "r6", "r7", "cc" \ - ); - -#endif /* Thumb */ - -#endif /* ARMv3 */ - -#if defined(__alpha__) - -#define MULADDC_INIT \ - asm( \ - "ldq $1, %3 \n\t" \ - "ldq $2, %4 \n\t" \ - "ldq $3, %5 \n\t" \ - "ldq $4, %6 \n\t" - -#define MULADDC_CORE \ - "ldq $6, 0($1) \n\t" \ - "addq $1, 8, $1 \n\t" \ - "mulq $6, $4, $7 \n\t" \ - "umulh $6, $4, $6 \n\t" \ - "addq $7, $3, $7 \n\t" \ - "cmpult $7, $3, $3 \n\t" \ - "ldq $5, 0($2) \n\t" \ - "addq $7, $5, $7 \n\t" \ - "cmpult $7, $5, $5 \n\t" \ - "stq $7, 0($2) \n\t" \ - "addq $2, 8, $2 \n\t" \ - "addq $6, $3, $3 \n\t" \ - "addq $5, $3, $3 \n\t" - -#define MULADDC_STOP \ - "stq $3, %0 \n\t" \ - "stq $2, %1 \n\t" \ - "stq $1, %2 \n\t" \ - : "=m" (c), "=m" (d), "=m" (s) \ - : "m" (s), "m" (d), "m" (c), "m" (b) \ - : "$1", "$2", "$3", "$4", "$5", "$6", "$7" \ - ); -#endif /* Alpha */ - -#if defined(__mips__) && !defined(__mips64) - -#define MULADDC_INIT \ - asm( \ - "lw $10, %3 \n\t" \ - "lw $11, %4 \n\t" \ - "lw $12, %5 \n\t" \ - "lw $13, %6 \n\t" - -#define MULADDC_CORE \ - "lw $14, 0($10) \n\t" \ - "multu $13, $14 \n\t" \ - "addi $10, $10, 4 \n\t" \ - "mflo $14 \n\t" \ - "mfhi $9 \n\t" \ - "addu $14, $12, $14 \n\t" \ - "lw $15, 0($11) \n\t" \ - "sltu $12, $14, $12 \n\t" \ - "addu $15, $14, $15 \n\t" \ - "sltu $14, $15, $14 \n\t" \ - "addu $12, $12, $9 \n\t" \ - "sw $15, 0($11) \n\t" \ - "addu $12, $12, $14 \n\t" \ - "addi $11, $11, 4 \n\t" - -#define MULADDC_STOP \ - "sw $12, %0 \n\t" \ - "sw $11, %1 \n\t" \ - "sw $10, %2 \n\t" \ - : "=m" (c), "=m" (d), "=m" (s) \ - : "m" (s), "m" (d), "m" (c), "m" (b) \ - : "$9", "$10", "$11", "$12", "$13", "$14", "$15", "lo", "hi" \ - ); - -#endif /* MIPS */ -#endif /* GNUC */ - -#if (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) - -#define MULADDC_INIT __asm mov esi, s __asm mov edi, d __asm mov ecx, c __asm mov ebx, b - -#define MULADDC_CORE \ - __asm lodsd __asm mul ebx __asm add eax, ecx __asm adc edx, 0 __asm add eax, [ edi ] __asm adc edx, 0 __asm mov ecx, \ - edx __asm stosd - -#if defined(MBEDTLS_HAVE_SSE2) - -#define EMIT __asm _emit - -#define MULADDC_HUIT \ - EMIT 0x0F EMIT 0x6E EMIT 0xC9 EMIT 0x0F EMIT 0x6E EMIT 0xC3 EMIT 0x0F EMIT 0x6E EMIT 0x1F EMIT 0x0F EMIT 0xD4 EMIT 0xCB EMIT 0x0F EMIT 0x6E EMIT 0x16 EMIT 0x0F EMIT 0xF4 EMIT 0xD0 EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x04 EMIT 0x0F EMIT 0xF4 EMIT 0xE0 EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x08 EMIT 0x0F EMIT 0xF4 EMIT 0xF0 EMIT 0x0F EMIT 0x6E EMIT 0x7E EMIT 0x0C EMIT 0x0F EMIT 0xF4 EMIT 0xF8 EMIT 0x0F EMIT 0xD4 EMIT 0xCA EMIT 0x0F EMIT 0x6E EMIT 0x5F EMIT 0x04 EMIT 0x0F EMIT 0xD4 EMIT 0xDC EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x08 EMIT 0x0F EMIT 0xD4 EMIT 0xEE EMIT 0x0F EMIT 0x6E EMIT 0x67 EMIT 0x0C EMIT 0x0F EMIT 0xD4 EMIT 0xFC EMIT 0x0F EMIT 0x7E EMIT 0x0F EMIT 0x0F EMIT 0x6E EMIT 0x56 EMIT 0x10 EMIT 0x0F EMIT 0xF4 EMIT 0xD0 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x14 EMIT 0x0F EMIT 0xF4 EMIT 0xE0 EMIT 0x0F EMIT 0xD4 EMIT 0xCB EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x18 EMIT 0x0F EMIT 0xF4 EMIT 0xF0 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x04 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 EMIT 0x0F EMIT 0x6E EMIT 0x5E EMIT 0x1C EMIT 0x0F EMIT 0xF4 EMIT 0xD8 EMIT 0x0F EMIT 0xD4 EMIT 0xCD EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x10 EMIT 0x0F EMIT 0xD4 EMIT 0xD5 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x08 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 EMIT 0x0F EMIT 0xD4 EMIT 0xCF EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x14 EMIT 0x0F EMIT 0xD4 EMIT 0xE5 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x0C EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 EMIT 0x0F EMIT 0xD4 EMIT 0xCA EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x18 EMIT 0x0F EMIT 0xD4 EMIT 0xF5 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x10 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 EMIT 0x0F EMIT 0xD4 EMIT 0xCC EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x1C EMIT 0x0F EMIT 0xD4 EMIT 0xDD EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x14 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 EMIT 0x0F EMIT 0xD4 EMIT 0xCE EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x18 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 EMIT 0x0F EMIT 0xD4 EMIT 0xCB EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x1C EMIT 0x83 EMIT 0xC7 EMIT 0x20 EMIT 0x83 EMIT 0xC6 EMIT 0x20 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 EMIT 0x0F EMIT 0x7E EMIT 0xC9 - -#define MULADDC_STOP EMIT 0x0F EMIT 0x77 __asm mov c, ecx __asm mov d, edi __asm mov s, esi - -#else - -#define MULADDC_STOP __asm mov c, ecx __asm mov d, edi __asm mov s, esi - -#endif /* SSE2 */ -#endif /* MSVC */ - -#endif /* MBEDTLS_HAVE_ASM */ - -#if !defined(MULADDC_CORE) -#if defined(MBEDTLS_HAVE_UDBL) - -#define MULADDC_INIT \ - { \ - mbedtls_t_udbl r; \ - mbedtls_mpi_uint r0, r1; - -#define MULADDC_CORE \ - r = *(s++) * (mbedtls_t_udbl) b; \ - r0 = (mbedtls_mpi_uint) r; \ - r1 = (mbedtls_mpi_uint)(r >> biL); \ - r0 += c; \ - r1 += (r0 < c); \ - r0 += *d; \ - r1 += (r0 < *d); \ - c = r1; \ - *(d++) = r0; - -#define MULADDC_STOP } - -#else -#define MULADDC_INIT \ - { \ - mbedtls_mpi_uint s0, s1, b0, b1; \ - mbedtls_mpi_uint r0, r1, rx, ry; \ - b0 = (b << biH) >> biH; \ - b1 = (b >> biH); - -#define MULADDC_CORE \ - s0 = (*s << biH) >> biH; \ - s1 = (*s >> biH); \ - s++; \ - rx = s0 * b1; \ - r0 = s0 * b0; \ - ry = s1 * b0; \ - r1 = s1 * b1; \ - r1 += (rx >> biH); \ - r1 += (ry >> biH); \ - rx <<= biH; \ - ry <<= biH; \ - r0 += rx; \ - r1 += (r0 < rx); \ - r0 += ry; \ - r1 += (r0 < ry); \ - r0 += c; \ - r1 += (r0 < c); \ - r0 += *d; \ - r1 += (r0 < *d); \ - c = r1; \ - *(d++) = r0; - -#define MULADDC_STOP } - -#endif /* C (generic) */ -#endif /* C (longlong) */ - -#endif /* bn_mul.h */ diff --git a/src/platform/telink/crypto/internal/compatibility/ecp_alt.c b/src/platform/telink/crypto/internal/compatibility/ecp_alt.c deleted file mode 100644 index d77374658d8b03..00000000000000 --- a/src/platform/telink/crypto/internal/compatibility/ecp_alt.c +++ /dev/null @@ -1,3363 +0,0 @@ -/* - * Elliptic curves over GF(p): generic functions - * - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -/* - * References: - * - * SEC1 http://www.secg.org/index.php?action=secg,docs_secg - * GECC = Guide to Elliptic Curve Cryptography - Hankerson, Menezes, Vanstone - * FIPS 186-3 http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf - * RFC 4492 for the related TLS structures and constants - * RFC 7748 for the Curve448 and Curve25519 curve definitions - * - * [Curve25519] http://cr.yp.to/ecdh/curve25519-20060209.pdf - * - * [2] CORON, Jean-S'ebastien. Resistance against differential power analysis - * for elliptic curve cryptosystems. In : Cryptographic Hardware and - * Embedded Systems. Springer Berlin Heidelberg, 1999. p. 292-302. - * - * - * [3] HEDABOU, Mustapha, PINEL, Pierre, et B'EN'ETEAU, Lucien. A comb method to - * render ECC resistant against Side Channel Attacks. IACR Cryptology - * ePrint Archive, 2004, vol. 2004, p. 342. - * - */ - -#include "../common.h" - -/** - * \brief Function level alternative implementation. - * - * The MBEDTLS_ECP_INTERNAL_ALT macro enables alternative implementations to - * replace certain functions in this module. The alternative implementations are - * typically hardware accelerators and need to activate the hardware before the - * computation starts and deactivate it after it finishes. The - * mbedtls_internal_ecp_init() and mbedtls_internal_ecp_free() functions serve - * this purpose. - * - * To preserve the correct functionality the following conditions must hold: - * - * - The alternative implementation must be activated by - * mbedtls_internal_ecp_init() before any of the replaceable functions is - * called. - * - mbedtls_internal_ecp_free() must \b only be called when the alternative - * implementation is activated. - * - mbedtls_internal_ecp_init() must \b not be called when the alternative - * implementation is activated. - * - Public functions must not return while the alternative implementation is - * activated. - * - Replaceable functions are guarded by \c MBEDTLS_ECP_XXX_ALT macros and - * before calling them an \code if( mbedtls_internal_ecp_grp_capable( grp ) ) - * \endcode ensures that the alternative implementation supports the current - * group. - */ -#if defined(MBEDTLS_ECP_INTERNAL_ALT) -#endif - -#if defined(MBEDTLS_ECP_C) - -#include "mbedtls/ecp.h" -#include "mbedtls/error.h" -#include "mbedtls/platform_util.h" -#include "mbedtls/threading.h" - -#include "bn_mul.h" -#include "ecp_invasive.h" - -#include - -#if defined(MBEDTLS_ECP_ALT) - -#include "pke.h" - -/* HW accelerator functionality */ -extern int ecp_alt_b91_backend_check_pubkey(const mbedtls_ecp_group * grp, const mbedtls_ecp_point * pt); -extern int ecp_alt_b91_backend_mul(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, - const mbedtls_ecp_point * P); -extern int ecp_alt_b91_backend_muladd(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, - const mbedtls_ecp_point * P, const mbedtls_mpi * n, const mbedtls_ecp_point * Q); -/* self test functionality */ -#if defined(MBEDTLS_SELF_TEST) -extern const int __ecp_alt_b91_skip_internal_self_tests; -extern int ecp_alt_b91_backend_test(int verbose); -#endif /* MBEDTLS_SELF_TEST */ - -/* Parameter validation macros based on platform_util.h */ -#define ECP_VALIDATE_RET(cond) MBEDTLS_INTERNAL_VALIDATE_RET(cond, MBEDTLS_ERR_ECP_BAD_INPUT_DATA) -#define ECP_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE(cond) - -#if defined(MBEDTLS_PLATFORM_C) -#include "mbedtls/platform.h" -#else -#include -#include -#define mbedtls_printf printf -#define mbedtls_calloc calloc -#define mbedtls_free free -#endif - -#include "ecp_internal_alt.h" - -#if (defined(__ARMCC_VERSION) || defined(_MSC_VER)) && !defined(inline) && !defined(__cplusplus) -#define inline __inline -#endif - -#if defined(MBEDTLS_SELF_TEST) -/* - * Counts of point addition and doubling, and field multiplications. - * Used to test resistance of point multiplication to simple timing attacks. - */ -static unsigned long add_count, dbl_count, mul_count; -#endif - -#if defined(MBEDTLS_ECP_RESTARTABLE) -/* - * Maximum number of "basic operations" to be done in a row. - * - * Default value 0 means that ECC operations will not yield. - * Note that regardless of the value of ecp_max_ops, always at - * least one step is performed before yielding. - * - * Setting ecp_max_ops=1 can be suitable for testing purposes - * as it will interrupt computation at all possible points. - */ -static unsigned ecp_max_ops = 0; - -/* - * Set ecp_max_ops - */ -void mbedtls_ecp_set_max_ops(unsigned max_ops) -{ - ecp_max_ops = max_ops; -} - -/* - * Check if restart is enabled - */ -int mbedtls_ecp_restart_is_enabled(void) -{ - return (ecp_max_ops != 0); -} - -/* - * Restart sub-context for ecp_mul_comb() - */ -struct mbedtls_ecp_restart_mul -{ - mbedtls_ecp_point R; /* current intermediate result */ - size_t i; /* current index in various loops, 0 outside */ - mbedtls_ecp_point * T; /* table for precomputed points */ - unsigned char T_size; /* number of points in table T */ - enum - { /* what were we doing last time we returned? */ - ecp_rsm_init = 0, /* nothing so far, dummy initial state */ - ecp_rsm_pre_dbl, /* precompute 2^n multiples */ - ecp_rsm_pre_norm_dbl, /* normalize precomputed 2^n multiples */ - ecp_rsm_pre_add, /* precompute remaining points by adding */ - ecp_rsm_pre_norm_add, /* normalize all precomputed points */ - ecp_rsm_comb_core, /* ecp_mul_comb_core() */ - ecp_rsm_final_norm, /* do the final normalization */ - } state; -}; - -/* - * Init restart_mul sub-context - */ -static void ecp_restart_rsm_init(mbedtls_ecp_restart_mul_ctx * ctx) -{ - mbedtls_ecp_point_init(&ctx->R); - ctx->i = 0; - ctx->T = NULL; - ctx->T_size = 0; - ctx->state = ecp_rsm_init; -} - -/* - * Free the components of a restart_mul sub-context - */ -static void ecp_restart_rsm_free(mbedtls_ecp_restart_mul_ctx * ctx) -{ - unsigned char i; - - if (ctx == NULL) - return; - - mbedtls_ecp_point_free(&ctx->R); - - if (ctx->T != NULL) - { - for (i = 0; i < ctx->T_size; i++) - mbedtls_ecp_point_free(ctx->T + i); - mbedtls_free(ctx->T); - } - - ecp_restart_rsm_init(ctx); -} - -/* - * Restart context for ecp_muladd() - */ -struct mbedtls_ecp_restart_muladd -{ - mbedtls_ecp_point mP; /* mP value */ - mbedtls_ecp_point R; /* R intermediate result */ - enum - { /* what should we do next? */ - ecp_rsma_mul1 = 0, /* first multiplication */ - ecp_rsma_mul2, /* second multiplication */ - ecp_rsma_add, /* addition */ - ecp_rsma_norm, /* normalization */ - } state; -}; - -/* - * Init restart_muladd sub-context - */ -static void ecp_restart_ma_init(mbedtls_ecp_restart_muladd_ctx * ctx) -{ - mbedtls_ecp_point_init(&ctx->mP); - mbedtls_ecp_point_init(&ctx->R); - ctx->state = ecp_rsma_mul1; -} - -/* - * Free the components of a restart_muladd sub-context - */ -static void ecp_restart_ma_free(mbedtls_ecp_restart_muladd_ctx * ctx) -{ - if (ctx == NULL) - return; - - mbedtls_ecp_point_free(&ctx->mP); - mbedtls_ecp_point_free(&ctx->R); - - ecp_restart_ma_init(ctx); -} - -/* - * Initialize a restart context - */ -void mbedtls_ecp_restart_init(mbedtls_ecp_restart_ctx * ctx) -{ - ECP_VALIDATE(ctx != NULL); - ctx->ops_done = 0; - ctx->depth = 0; - ctx->rsm = NULL; - ctx->ma = NULL; -} - -/* - * Free the components of a restart context - */ -void mbedtls_ecp_restart_free(mbedtls_ecp_restart_ctx * ctx) -{ - if (ctx == NULL) - return; - - ecp_restart_rsm_free(ctx->rsm); - mbedtls_free(ctx->rsm); - - ecp_restart_ma_free(ctx->ma); - mbedtls_free(ctx->ma); - - mbedtls_ecp_restart_init(ctx); -} - -/* - * Check if we can do the next step - */ -int mbedtls_ecp_check_budget(const mbedtls_ecp_group * grp, mbedtls_ecp_restart_ctx * rs_ctx, unsigned ops) -{ - ECP_VALIDATE_RET(grp != NULL); - - if (rs_ctx != NULL && ecp_max_ops != 0) - { - /* scale depending on curve size: the chosen reference is 256-bit, - * and multiplication is quadratic. Round to the closest integer. */ - if (grp->pbits >= 512) - ops *= 4; - else if (grp->pbits >= 384) - ops *= 2; - - /* Avoid infinite loops: always allow first step. - * Because of that, however, it's not generally true - * that ops_done <= ecp_max_ops, so the check - * ops_done > ecp_max_ops below is mandatory. */ - if ((rs_ctx->ops_done != 0) && (rs_ctx->ops_done > ecp_max_ops || ops > ecp_max_ops - rs_ctx->ops_done)) - { - return (MBEDTLS_ERR_ECP_IN_PROGRESS); - } - - /* update running count */ - rs_ctx->ops_done += ops; - } - - return (0); -} - -/* Call this when entering a function that needs its own sub-context */ -#define ECP_RS_ENTER(SUB) \ - do \ - { \ - /* reset ops count for this call if top-level */ \ - if (rs_ctx != NULL && rs_ctx->depth++ == 0) \ - rs_ctx->ops_done = 0; \ - \ - /* set up our own sub-context if needed */ \ - if (mbedtls_ecp_restart_is_enabled() && rs_ctx != NULL && rs_ctx->SUB == NULL) \ - { \ - rs_ctx->SUB = mbedtls_calloc(1, sizeof(*rs_ctx->SUB)); \ - if (rs_ctx->SUB == NULL) \ - return (MBEDTLS_ERR_ECP_ALLOC_FAILED); \ - \ - ecp_restart_##SUB##_init(rs_ctx->SUB); \ - } \ - } while (0) - -/* Call this when leaving a function that needs its own sub-context */ -#define ECP_RS_LEAVE(SUB) \ - do \ - { \ - /* clear our sub-context when not in progress (done or error) */ \ - if (rs_ctx != NULL && rs_ctx->SUB != NULL && ret != MBEDTLS_ERR_ECP_IN_PROGRESS) \ - { \ - ecp_restart_##SUB##_free(rs_ctx->SUB); \ - mbedtls_free(rs_ctx->SUB); \ - rs_ctx->SUB = NULL; \ - } \ - \ - if (rs_ctx != NULL) \ - rs_ctx->depth--; \ - } while (0) - -#else /* MBEDTLS_ECP_RESTARTABLE */ - -#define ECP_RS_ENTER(sub) (void) rs_ctx; -#define ECP_RS_LEAVE(sub) (void) rs_ctx; - -#endif /* MBEDTLS_ECP_RESTARTABLE */ - -/* - * List of supported curves: - * - internal ID - * - TLS NamedCurve ID (RFC 4492 sec. 5.1.1, RFC 7071 sec. 2, RFC 8446 sec. 4.2.7) - * - size in bits - * - readable name - * - * Curves are listed in order: largest curves first, and for a given size, - * fastest curves first. - * - * Reminder: update profiles in x509_crt.c and ssl_tls.c when adding a new curve! - */ -static const mbedtls_ecp_curve_info ecp_supported_curves[] = { -#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) - { MBEDTLS_ECP_DP_SECP521R1, 25, 521, "secp521r1" }, -#endif -#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) - { MBEDTLS_ECP_DP_BP512R1, 28, 512, "brainpoolP512r1" }, -#endif -#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) - { MBEDTLS_ECP_DP_SECP384R1, 24, 384, "secp384r1" }, -#endif -#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) - { MBEDTLS_ECP_DP_BP384R1, 27, 384, "brainpoolP384r1" }, -#endif -#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) - { MBEDTLS_ECP_DP_SECP256R1, 23, 256, "secp256r1" }, -#endif -#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) - { MBEDTLS_ECP_DP_SECP256K1, 22, 256, "secp256k1" }, -#endif -#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) - { MBEDTLS_ECP_DP_BP256R1, 26, 256, "brainpoolP256r1" }, -#endif -#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) - { MBEDTLS_ECP_DP_SECP224R1, 21, 224, "secp224r1" }, -#endif -#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) - { MBEDTLS_ECP_DP_SECP224K1, 20, 224, "secp224k1" }, -#endif -#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) - { MBEDTLS_ECP_DP_SECP192R1, 19, 192, "secp192r1" }, -#endif -#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) - { MBEDTLS_ECP_DP_SECP192K1, 18, 192, "secp192k1" }, -#endif -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) - { MBEDTLS_ECP_DP_CURVE25519, 29, 256, "x25519" }, -#endif -#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) - { MBEDTLS_ECP_DP_CURVE448, 30, 448, "x448" }, -#endif - { MBEDTLS_ECP_DP_NONE, 0, 0, NULL }, -}; - -#define ECP_NB_CURVES sizeof(ecp_supported_curves) / sizeof(ecp_supported_curves[0]) - -static mbedtls_ecp_group_id ecp_supported_grp_id[ECP_NB_CURVES]; - -/* - * List of supported curves and associated info - */ -const mbedtls_ecp_curve_info * mbedtls_ecp_curve_list(void) -{ - return (ecp_supported_curves); -} - -/* - * List of supported curves, group ID only - */ -const mbedtls_ecp_group_id * mbedtls_ecp_grp_id_list(void) -{ - static int init_done = 0; - - if (!init_done) - { - size_t i = 0; - const mbedtls_ecp_curve_info * curve_info; - - for (curve_info = mbedtls_ecp_curve_list(); curve_info->grp_id != MBEDTLS_ECP_DP_NONE; curve_info++) - { - ecp_supported_grp_id[i++] = curve_info->grp_id; - } - ecp_supported_grp_id[i] = MBEDTLS_ECP_DP_NONE; - - init_done = 1; - } - - return (ecp_supported_grp_id); -} - -/* - * Get the curve info for the internal identifier - */ -const mbedtls_ecp_curve_info * mbedtls_ecp_curve_info_from_grp_id(mbedtls_ecp_group_id grp_id) -{ - const mbedtls_ecp_curve_info * curve_info; - - for (curve_info = mbedtls_ecp_curve_list(); curve_info->grp_id != MBEDTLS_ECP_DP_NONE; curve_info++) - { - if (curve_info->grp_id == grp_id) - return (curve_info); - } - - return (NULL); -} - -/* - * Get the curve info from the TLS identifier - */ -const mbedtls_ecp_curve_info * mbedtls_ecp_curve_info_from_tls_id(uint16_t tls_id) -{ - const mbedtls_ecp_curve_info * curve_info; - - for (curve_info = mbedtls_ecp_curve_list(); curve_info->grp_id != MBEDTLS_ECP_DP_NONE; curve_info++) - { - if (curve_info->tls_id == tls_id) - return (curve_info); - } - - return (NULL); -} - -/* - * Get the curve info from the name - */ -const mbedtls_ecp_curve_info * mbedtls_ecp_curve_info_from_name(const char * name) -{ - const mbedtls_ecp_curve_info * curve_info; - - if (name == NULL) - return (NULL); - - for (curve_info = mbedtls_ecp_curve_list(); curve_info->grp_id != MBEDTLS_ECP_DP_NONE; curve_info++) - { - if (strcmp(curve_info->name, name) == 0) - return (curve_info); - } - - return (NULL); -} - -/* - * Get the type of a curve - */ -mbedtls_ecp_curve_type mbedtls_ecp_get_type(const mbedtls_ecp_group * grp) -{ - if (grp->G.X.p == NULL) - return (MBEDTLS_ECP_TYPE_NONE); - - if (grp->G.Y.p == NULL) - return (MBEDTLS_ECP_TYPE_MONTGOMERY); - else - return (MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS); -} - -/* - * Initialize (the components of) a point - */ -void mbedtls_ecp_point_init(mbedtls_ecp_point * pt) -{ - ECP_VALIDATE(pt != NULL); - - mbedtls_mpi_init(&pt->X); - mbedtls_mpi_init(&pt->Y); - mbedtls_mpi_init(&pt->Z); -} - -/* - * Initialize (the components of) a group - */ -void mbedtls_ecp_group_init(mbedtls_ecp_group * grp) -{ - ECP_VALIDATE(grp != NULL); - - grp->id = MBEDTLS_ECP_DP_NONE; - mbedtls_mpi_init(&grp->P); - mbedtls_mpi_init(&grp->A); - mbedtls_mpi_init(&grp->B); - mbedtls_ecp_point_init(&grp->G); - mbedtls_mpi_init(&grp->N); - grp->pbits = 0; - grp->nbits = 0; - grp->h = 0; - grp->modp = NULL; - grp->t_pre = NULL; - grp->t_post = NULL; - grp->t_data = NULL; - grp->T = NULL; - grp->T_size = 0; -} - -/* - * Initialize (the components of) a key pair - */ -void mbedtls_ecp_keypair_init(mbedtls_ecp_keypair * key) -{ - ECP_VALIDATE(key != NULL); - - mbedtls_ecp_group_init(&key->grp); - mbedtls_mpi_init(&key->d); - mbedtls_ecp_point_init(&key->Q); -} - -/* - * Unallocate (the components of) a point - */ -void mbedtls_ecp_point_free(mbedtls_ecp_point * pt) -{ - if (pt == NULL) - return; - - mbedtls_mpi_free(&(pt->X)); - mbedtls_mpi_free(&(pt->Y)); - mbedtls_mpi_free(&(pt->Z)); -} - -/* - * Check that the comb table (grp->T) is static initialized. - */ -static int ecp_group_is_static_comb_table(const mbedtls_ecp_group * grp) -{ -#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 - return grp->T != NULL && grp->T_size == 0; -#else - (void) grp; - return 0; -#endif -} - -/* - * Unallocate (the components of) a group - */ -void mbedtls_ecp_group_free(mbedtls_ecp_group * grp) -{ - size_t i; - - if (grp == NULL) - return; - - if (grp->h != 1) - { - mbedtls_mpi_free(&grp->P); - mbedtls_mpi_free(&grp->A); - mbedtls_mpi_free(&grp->B); - mbedtls_ecp_point_free(&grp->G); - mbedtls_mpi_free(&grp->N); - } - - if (!ecp_group_is_static_comb_table(grp) && grp->T != NULL) - { - for (i = 0; i < grp->T_size; i++) - mbedtls_ecp_point_free(&grp->T[i]); - mbedtls_free(grp->T); - } - - mbedtls_platform_zeroize(grp, sizeof(mbedtls_ecp_group)); -} - -/* - * Unallocate (the components of) a key pair - */ -void mbedtls_ecp_keypair_free(mbedtls_ecp_keypair * key) -{ - if (key == NULL) - return; - - mbedtls_ecp_group_free(&key->grp); - mbedtls_mpi_free(&key->d); - mbedtls_ecp_point_free(&key->Q); -} - -/* - * Copy the contents of a point - */ -int mbedtls_ecp_copy(mbedtls_ecp_point * P, const mbedtls_ecp_point * Q) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - ECP_VALIDATE_RET(P != NULL); - ECP_VALIDATE_RET(Q != NULL); - - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&P->X, &Q->X)); - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&P->Y, &Q->Y)); - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&P->Z, &Q->Z)); - -cleanup: - return (ret); -} - -/* - * Copy the contents of a group object - */ -int mbedtls_ecp_group_copy(mbedtls_ecp_group * dst, const mbedtls_ecp_group * src) -{ - ECP_VALIDATE_RET(dst != NULL); - ECP_VALIDATE_RET(src != NULL); - - return (mbedtls_ecp_group_load(dst, src->id)); -} - -/* - * Set point to zero - */ -int mbedtls_ecp_set_zero(mbedtls_ecp_point * pt) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - ECP_VALIDATE_RET(pt != NULL); - - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&pt->X, 1)); - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&pt->Y, 1)); - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&pt->Z, 0)); - -cleanup: - return (ret); -} - -/* - * Tell if a point is zero - */ -int mbedtls_ecp_is_zero(mbedtls_ecp_point * pt) -{ - ECP_VALIDATE_RET(pt != NULL); - - return (mbedtls_mpi_cmp_int(&pt->Z, 0) == 0); -} - -/* - * Compare two points lazily - */ -int mbedtls_ecp_point_cmp(const mbedtls_ecp_point * P, const mbedtls_ecp_point * Q) -{ - ECP_VALIDATE_RET(P != NULL); - ECP_VALIDATE_RET(Q != NULL); - - if (mbedtls_mpi_cmp_mpi(&P->X, &Q->X) == 0 && mbedtls_mpi_cmp_mpi(&P->Y, &Q->Y) == 0 && mbedtls_mpi_cmp_mpi(&P->Z, &Q->Z) == 0) - { - return (0); - } - - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); -} - -/* - * Import a non-zero point from ASCII strings - */ -int mbedtls_ecp_point_read_string(mbedtls_ecp_point * P, int radix, const char * x, const char * y) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - ECP_VALIDATE_RET(P != NULL); - ECP_VALIDATE_RET(x != NULL); - ECP_VALIDATE_RET(y != NULL); - - MBEDTLS_MPI_CHK(mbedtls_mpi_read_string(&P->X, radix, x)); - MBEDTLS_MPI_CHK(mbedtls_mpi_read_string(&P->Y, radix, y)); - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&P->Z, 1)); - -cleanup: - return (ret); -} - -/* - * Export a point into unsigned binary data (SEC1 2.3.3 and RFC7748) - */ -int mbedtls_ecp_point_write_binary(const mbedtls_ecp_group * grp, const mbedtls_ecp_point * P, int format, size_t * olen, - unsigned char * buf, size_t buflen) -{ - int ret = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE; - size_t plen; - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(P != NULL); - ECP_VALIDATE_RET(olen != NULL); - ECP_VALIDATE_RET(buf != NULL); - ECP_VALIDATE_RET(format == MBEDTLS_ECP_PF_UNCOMPRESSED || format == MBEDTLS_ECP_PF_COMPRESSED); - - plen = mbedtls_mpi_size(&grp->P); - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) - (void) format; /* Montgomery curves always use the same point format */ - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_MONTGOMERY) - { - *olen = plen; - if (buflen < *olen) - return (MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL); - - MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary_le(&P->X, buf, plen)); - } -#endif -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS) - { - /* - * Common case: P == 0 - */ - if (mbedtls_mpi_cmp_int(&P->Z, 0) == 0) - { - if (buflen < 1) - return (MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL); - - buf[0] = 0x00; - *olen = 1; - - return (0); - } - - if (format == MBEDTLS_ECP_PF_UNCOMPRESSED) - { - *olen = 2 * plen + 1; - - if (buflen < *olen) - return (MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL); - - buf[0] = 0x04; - MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&P->X, buf + 1, plen)); - MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&P->Y, buf + 1 + plen, plen)); - } - else if (format == MBEDTLS_ECP_PF_COMPRESSED) - { - *olen = plen + 1; - - if (buflen < *olen) - return (MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL); - - buf[0] = 0x02 + mbedtls_mpi_get_bit(&P->Y, 0); - MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&P->X, buf + 1, plen)); - } - } -#endif - -cleanup: - return (ret); -} - -/* - * Import a point from unsigned binary data (SEC1 2.3.4 and RFC7748) - */ -int mbedtls_ecp_point_read_binary(const mbedtls_ecp_group * grp, mbedtls_ecp_point * pt, const unsigned char * buf, size_t ilen) -{ - int ret = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE; - size_t plen; - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(pt != NULL); - ECP_VALIDATE_RET(buf != NULL); - - if (ilen < 1) - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - - plen = mbedtls_mpi_size(&grp->P); - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_MONTGOMERY) - { - if (plen != ilen) - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - - MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary_le(&pt->X, buf, plen)); - mbedtls_mpi_free(&pt->Y); - - if (grp->id == MBEDTLS_ECP_DP_CURVE25519) - /* Set most significant bit to 0 as prescribed in RFC7748 §5 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(&pt->X, plen * 8 - 1, 0)); - - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&pt->Z, 1)); - } -#endif -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS) - { - if (buf[0] == 0x00) - { - if (ilen == 1) - return (mbedtls_ecp_set_zero(pt)); - else - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - } - - if (buf[0] != 0x04) - return (MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); - - if (ilen != 2 * plen + 1) - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - - MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&pt->X, buf + 1, plen)); - MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&pt->Y, buf + 1 + plen, plen)); - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&pt->Z, 1)); - } -#endif - -cleanup: - return (ret); -} - -/* - * Import a point from a TLS ECPoint record (RFC 4492) - * struct { - * opaque point <1..2^8-1>; - * } ECPoint; - */ -int mbedtls_ecp_tls_read_point(const mbedtls_ecp_group * grp, mbedtls_ecp_point * pt, const unsigned char ** buf, size_t buf_len) -{ - unsigned char data_len; - const unsigned char * buf_start; - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(pt != NULL); - ECP_VALIDATE_RET(buf != NULL); - ECP_VALIDATE_RET(*buf != NULL); - - /* - * We must have at least two bytes (1 for length, at least one for data) - */ - if (buf_len < 2) - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - - data_len = *(*buf)++; - if (data_len < 1 || data_len > buf_len - 1) - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - - /* - * Save buffer start for read_binary and update buf - */ - buf_start = *buf; - *buf += data_len; - - return (mbedtls_ecp_point_read_binary(grp, pt, buf_start, data_len)); -} - -/* - * Export a point as a TLS ECPoint record (RFC 4492) - * struct { - * opaque point <1..2^8-1>; - * } ECPoint; - */ -int mbedtls_ecp_tls_write_point(const mbedtls_ecp_group * grp, const mbedtls_ecp_point * pt, int format, size_t * olen, - unsigned char * buf, size_t blen) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(pt != NULL); - ECP_VALIDATE_RET(olen != NULL); - ECP_VALIDATE_RET(buf != NULL); - ECP_VALIDATE_RET(format == MBEDTLS_ECP_PF_UNCOMPRESSED || format == MBEDTLS_ECP_PF_COMPRESSED); - - /* - * buffer length must be at least one, for our length byte - */ - if (blen < 1) - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - - if ((ret = mbedtls_ecp_point_write_binary(grp, pt, format, olen, buf + 1, blen - 1)) != 0) - return (ret); - - /* - * write length to the first byte and update total length - */ - buf[0] = (unsigned char) *olen; - ++*olen; - - return (0); -} - -/* - * Set a group from an ECParameters record (RFC 4492) - */ -int mbedtls_ecp_tls_read_group(mbedtls_ecp_group * grp, const unsigned char ** buf, size_t len) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_ecp_group_id grp_id; - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(buf != NULL); - ECP_VALIDATE_RET(*buf != NULL); - - if ((ret = mbedtls_ecp_tls_read_group_id(&grp_id, buf, len)) != 0) - return (ret); - - return (mbedtls_ecp_group_load(grp, grp_id)); -} - -/* - * Read a group id from an ECParameters record (RFC 4492) and convert it to - * mbedtls_ecp_group_id. - */ -int mbedtls_ecp_tls_read_group_id(mbedtls_ecp_group_id * grp, const unsigned char ** buf, size_t len) -{ - uint16_t tls_id; - const mbedtls_ecp_curve_info * curve_info; - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(buf != NULL); - ECP_VALIDATE_RET(*buf != NULL); - - /* - * We expect at least three bytes (see below) - */ - if (len < 3) - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - - /* - * First byte is curve_type; only named_curve is handled - */ - if (*(*buf)++ != MBEDTLS_ECP_TLS_NAMED_CURVE) - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - - /* - * Next two bytes are the namedcurve value - */ - tls_id = *(*buf)++; - tls_id <<= 8; - tls_id |= *(*buf)++; - - if ((curve_info = mbedtls_ecp_curve_info_from_tls_id(tls_id)) == NULL) - return (MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); - - *grp = curve_info->grp_id; - - return (0); -} - -/* - * Write the ECParameters record corresponding to a group (RFC 4492) - */ -int mbedtls_ecp_tls_write_group(const mbedtls_ecp_group * grp, size_t * olen, unsigned char * buf, size_t blen) -{ - const mbedtls_ecp_curve_info * curve_info; - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(buf != NULL); - ECP_VALIDATE_RET(olen != NULL); - - if ((curve_info = mbedtls_ecp_curve_info_from_grp_id(grp->id)) == NULL) - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - - /* - * We are going to write 3 bytes (see below) - */ - *olen = 3; - if (blen < *olen) - return (MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL); - - /* - * First byte is curve_type, always named_curve - */ - *buf++ = MBEDTLS_ECP_TLS_NAMED_CURVE; - - /* - * Next two bytes are the namedcurve value - */ - buf[0] = curve_info->tls_id >> 8; - buf[1] = curve_info->tls_id & 0xFF; - - return (0); -} - -/* - * Wrapper around fast quasi-modp functions, with fall-back to mbedtls_mpi_mod_mpi. - * See the documentation of struct mbedtls_ecp_group. - * - * This function is in the critial loop for mbedtls_ecp_mul, so pay attention to perf. - */ -static int ecp_modp(mbedtls_mpi * N, const mbedtls_ecp_group * grp) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - - if (grp->modp == NULL) - return (mbedtls_mpi_mod_mpi(N, N, &grp->P)); - - /* N->s < 0 is a much faster test, which fails only if N is 0 */ - if ((N->s < 0 && mbedtls_mpi_cmp_int(N, 0) != 0) || mbedtls_mpi_bitlen(N) > 2 * grp->pbits) - { - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - } - - MBEDTLS_MPI_CHK(grp->modp(N)); - - /* N->s < 0 is a much faster test, which fails only if N is 0 */ - while (N->s < 0 && mbedtls_mpi_cmp_int(N, 0) != 0) - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mpi(N, N, &grp->P)); - - while (mbedtls_mpi_cmp_mpi(N, &grp->P) >= 0) - /* we known P, N and the result are positive */ - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_abs(N, N, &grp->P)); - -cleanup: - return (ret); -} - -/* - * Fast mod-p functions expect their argument to be in the 0..p^2 range. - * - * In order to guarantee that, we need to ensure that operands of - * mbedtls_mpi_mul_mpi are in the 0..p range. So, after each operation we will - * bring the result back to this range. - * - * The following macros are shortcuts for doing that. - */ - -/* - * Reduce a mbedtls_mpi mod p in-place, general case, to use after mbedtls_mpi_mul_mpi - */ -#if defined(MBEDTLS_SELF_TEST) -#define INC_MUL_COUNT mul_count++; -#else -#define INC_MUL_COUNT -#endif - -#define MOD_MUL(N) \ - do \ - { \ - MBEDTLS_MPI_CHK(ecp_modp(&(N), grp)); \ - INC_MUL_COUNT \ - } while (0) - -static inline int mbedtls_mpi_mul_mod(const mbedtls_ecp_group * grp, mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mpi(X, A, B)); - MOD_MUL(*X); -cleanup: - return (ret); -} - -/* - * Reduce a mbedtls_mpi mod p in-place, to use after mbedtls_mpi_sub_mpi - * N->s < 0 is a very fast test, which fails only if N is 0 - */ -#define MOD_SUB(N) \ - while ((N).s < 0 && mbedtls_mpi_cmp_int(&(N), 0) != 0) \ - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mpi(&(N), &(N), &grp->P)) - -#if (defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) && \ - !(defined(MBEDTLS_ECP_NO_FALLBACK) && defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) && defined(MBEDTLS_ECP_ADD_MIXED_ALT))) || \ - (defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) && !(defined(MBEDTLS_ECP_NO_FALLBACK) && defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT))) -static inline int mbedtls_mpi_sub_mod(const mbedtls_ecp_group * grp, mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(X, A, B)); - MOD_SUB(*X); -cleanup: - return (ret); -} -#endif /* All functions referencing mbedtls_mpi_sub_mod() are alt-implemented without fallback */ - -/* - * Reduce a mbedtls_mpi mod p in-place, to use after mbedtls_mpi_add_mpi and mbedtls_mpi_mul_int. - * We known P, N and the result are positive, so sub_abs is correct, and - * a bit faster. - */ -#define MOD_ADD(N) \ - while (mbedtls_mpi_cmp_mpi(&(N), &grp->P) >= 0) \ - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_abs(&(N), &(N), &grp->P)) - -static inline int mbedtls_mpi_add_mod(const mbedtls_ecp_group * grp, mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mpi(X, A, B)); - MOD_ADD(*X); -cleanup: - return (ret); -} - -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) && \ - !(defined(MBEDTLS_ECP_NO_FALLBACK) && defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) && defined(MBEDTLS_ECP_ADD_MIXED_ALT)) -static inline int mbedtls_mpi_shift_l_mod(const mbedtls_ecp_group * grp, mbedtls_mpi * X, size_t count) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_l(X, count)); - MOD_ADD(*X); -cleanup: - return (ret); -} -#endif /* All functions referencing mbedtls_mpi_shift_l_mod() are alt-implemented without fallback */ - -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) -/* - * For curves in short Weierstrass form, we do all the internal operations in - * Jacobian coordinates. - * - * For multiplication, we'll use a comb method with coutermeasueres against - * SPA, hence timing attacks. - */ - -/* - * Normalize jacobian coordinates so that Z == 0 || Z == 1 (GECC 3.2.1) - * Cost: 1N := 1I + 3M + 1S - */ -static int ecp_normalize_jac(const mbedtls_ecp_group * grp, mbedtls_ecp_point * pt) -{ - if (mbedtls_mpi_cmp_int(&pt->Z, 0) == 0) - return (0); - -#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) - if (mbedtls_internal_ecp_grp_capable(grp)) - return (mbedtls_internal_ecp_normalize_jac(grp, pt)); -#endif /* MBEDTLS_ECP_NORMALIZE_JAC_ALT */ - -#if defined(MBEDTLS_ECP_NO_FALLBACK) && defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) - return (MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); -#else - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_mpi Zi, ZZi; - mbedtls_mpi_init(&Zi); - mbedtls_mpi_init(&ZZi); - - /* - * X = X / Z^2 mod p - */ - MBEDTLS_MPI_CHK(mbedtls_mpi_inv_mod(&Zi, &pt->Z, &grp->P)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &ZZi, &Zi, &Zi)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &pt->X, &pt->X, &ZZi)); - - /* - * Y = Y / Z^3 mod p - */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &pt->Y, &pt->Y, &ZZi)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &pt->Y, &pt->Y, &Zi)); - - /* - * Z = 1 - */ - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&pt->Z, 1)); - -cleanup: - - mbedtls_mpi_free(&Zi); - mbedtls_mpi_free(&ZZi); - - return (ret); -#endif /* !defined(MBEDTLS_ECP_NO_FALLBACK) || !defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) */ -} - -/* - * Normalize jacobian coordinates of an array of (pointers to) points, - * using Montgomery's trick to perform only one inversion mod P. - * (See for example Cohen's "A Course in Computational Algebraic Number - * Theory", Algorithm 10.3.4.) - * - * Warning: fails (returning an error) if one of the points is zero! - * This should never happen, see choice of w in ecp_mul_comb(). - * - * Cost: 1N(t) := 1I + (6t - 3)M + 1S - */ -static int ecp_normalize_jac_many(const mbedtls_ecp_group * grp, mbedtls_ecp_point * T[], size_t T_size) -{ - if (T_size < 2) - return (ecp_normalize_jac(grp, *T)); - -#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) - if (mbedtls_internal_ecp_grp_capable(grp)) - return (mbedtls_internal_ecp_normalize_jac_many(grp, T, T_size)); -#endif - -#if defined(MBEDTLS_ECP_NO_FALLBACK) && defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) - return (MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); -#else - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - size_t i; - mbedtls_mpi *c, u, Zi, ZZi; - - if ((c = mbedtls_calloc(T_size, sizeof(mbedtls_mpi))) == NULL) - return (MBEDTLS_ERR_ECP_ALLOC_FAILED); - - for (i = 0; i < T_size; i++) - mbedtls_mpi_init(&c[i]); - - mbedtls_mpi_init(&u); - mbedtls_mpi_init(&Zi); - mbedtls_mpi_init(&ZZi); - - /* - * c[i] = Z_0 * ... * Z_i - */ - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&c[0], &T[0]->Z)); - for (i = 1; i < T_size; i++) - { - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &c[i], &c[i - 1], &T[i]->Z)); - } - - /* - * u = 1 / (Z_0 * ... * Z_n) mod P - */ - MBEDTLS_MPI_CHK(mbedtls_mpi_inv_mod(&u, &c[T_size - 1], &grp->P)); - - for (i = T_size - 1;; i--) - { - /* - * Zi = 1 / Z_i mod p - * u = 1 / (Z_0 * ... * Z_i) mod P - */ - if (i == 0) - { - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&Zi, &u)); - } - else - { - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &Zi, &u, &c[i - 1])); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &u, &u, &T[i]->Z)); - } - - /* - * proceed as in normalize() - */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &ZZi, &Zi, &Zi)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T[i]->X, &T[i]->X, &ZZi)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T[i]->Y, &T[i]->Y, &ZZi)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T[i]->Y, &T[i]->Y, &Zi)); - - /* - * Post-precessing: reclaim some memory by shrinking coordinates - * - not storing Z (always 1) - * - shrinking other coordinates, but still keeping the same number of - * limbs as P, as otherwise it will too likely be regrown too fast. - */ - MBEDTLS_MPI_CHK(mbedtls_mpi_shrink(&T[i]->X, grp->P.n)); - MBEDTLS_MPI_CHK(mbedtls_mpi_shrink(&T[i]->Y, grp->P.n)); - mbedtls_mpi_free(&T[i]->Z); - - if (i == 0) - break; - } - -cleanup: - - mbedtls_mpi_free(&u); - mbedtls_mpi_free(&Zi); - mbedtls_mpi_free(&ZZi); - for (i = 0; i < T_size; i++) - mbedtls_mpi_free(&c[i]); - mbedtls_free(c); - - return (ret); -#endif /* !defined(MBEDTLS_ECP_NO_FALLBACK) || !defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) */ -} - -/* - * Conditional point inversion: Q -> -Q = (Q.X, -Q.Y, Q.Z) without leak. - * "inv" must be 0 (don't invert) or 1 (invert) or the result will be invalid - */ -static int ecp_safe_invert_jac(const mbedtls_ecp_group * grp, mbedtls_ecp_point * Q, unsigned char inv) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - unsigned char nonzero; - mbedtls_mpi mQY; - - mbedtls_mpi_init(&mQY); - - /* Use the fact that -Q.Y mod P = P - Q.Y unless Q.Y == 0 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(&mQY, &grp->P, &Q->Y)); - nonzero = mbedtls_mpi_cmp_int(&Q->Y, 0) != 0; - MBEDTLS_MPI_CHK(mbedtls_mpi_safe_cond_assign(&Q->Y, &mQY, inv & nonzero)); - -cleanup: - mbedtls_mpi_free(&mQY); - - return (ret); -} - -/* - * Point doubling R = 2 P, Jacobian coordinates - * - * Based on http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian.html#doubling-dbl-1998-cmo-2 . - * - * We follow the variable naming fairly closely. The formula variations that trade a MUL for a SQR - * (plus a few ADDs) aren't useful as our bignum implementation doesn't distinguish squaring. - * - * Standard optimizations are applied when curve parameter A is one of { 0, -3 }. - * - * Cost: 1D := 3M + 4S (A == 0) - * 4M + 4S (A == -3) - * 3M + 6S + 1a otherwise - */ -static int ecp_double_jac(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_ecp_point * P) -{ -#if defined(MBEDTLS_SELF_TEST) - dbl_count++; -#endif - -#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) - if (mbedtls_internal_ecp_grp_capable(grp)) - return (mbedtls_internal_ecp_double_jac(grp, R, P)); -#endif /* MBEDTLS_ECP_DOUBLE_JAC_ALT */ - -#if defined(MBEDTLS_ECP_NO_FALLBACK) && defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) - return (MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); -#else - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_mpi M, S, T, U; - - mbedtls_mpi_init(&M); - mbedtls_mpi_init(&S); - mbedtls_mpi_init(&T); - mbedtls_mpi_init(&U); - - /* Special case for A = -3 */ - if (grp->A.p == NULL) - { - /* M = 3(X + Z^2)(X - Z^2) */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &S, &P->Z, &P->Z)); - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mod(grp, &T, &P->X, &S)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &U, &P->X, &S)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &S, &T, &U)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_int(&M, &S, 3)); - MOD_ADD(M); - } - else - { - /* M = 3.X^2 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &S, &P->X, &P->X)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_int(&M, &S, 3)); - MOD_ADD(M); - - /* Optimize away for "koblitz" curves with A = 0 */ - if (mbedtls_mpi_cmp_int(&grp->A, 0) != 0) - { - /* M += A.Z^4 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &S, &P->Z, &P->Z)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T, &S, &S)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &S, &T, &grp->A)); - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mod(grp, &M, &M, &S)); - } - } - - /* S = 4.X.Y^2 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T, &P->Y, &P->Y)); - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_l_mod(grp, &T, 1)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &S, &P->X, &T)); - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_l_mod(grp, &S, 1)); - - /* U = 8.Y^4 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &U, &T, &T)); - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_l_mod(grp, &U, 1)); - - /* T = M^2 - 2.S */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T, &M, &M)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &T, &T, &S)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &T, &T, &S)); - - /* S = M(S - T) - U */ - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &S, &S, &T)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &S, &S, &M)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &S, &S, &U)); - - /* U = 2.Y.Z */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &U, &P->Y, &P->Z)); - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_l_mod(grp, &U, 1)); - - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&R->X, &T)); - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&R->Y, &S)); - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&R->Z, &U)); - -cleanup: - mbedtls_mpi_free(&M); - mbedtls_mpi_free(&S); - mbedtls_mpi_free(&T); - mbedtls_mpi_free(&U); - - return (ret); -#endif /* !defined(MBEDTLS_ECP_NO_FALLBACK) || !defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) */ -} - -/* - * Addition: R = P + Q, mixed affine-Jacobian coordinates (GECC 3.22) - * - * The coordinates of Q must be normalized (= affine), - * but those of P don't need to. R is not normalized. - * - * Special cases: (1) P or Q is zero, (2) R is zero, (3) P == Q. - * None of these cases can happen as intermediate step in ecp_mul_comb(): - * - at each step, P, Q and R are multiples of the base point, the factor - * being less than its order, so none of them is zero; - * - Q is an odd multiple of the base point, P an even multiple, - * due to the choice of precomputed points in the modified comb method. - * So branches for these cases do not leak secret information. - * - * We accept Q->Z being unset (saving memory in tables) as meaning 1. - * - * Cost: 1A := 8M + 3S - */ -static int ecp_add_mixed(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_ecp_point * P, - const mbedtls_ecp_point * Q) -{ -#if defined(MBEDTLS_SELF_TEST) - add_count++; -#endif - -#if defined(MBEDTLS_ECP_ADD_MIXED_ALT) - if (mbedtls_internal_ecp_grp_capable(grp)) - return (mbedtls_internal_ecp_add_mixed(grp, R, P, Q)); -#endif /* MBEDTLS_ECP_ADD_MIXED_ALT */ - -#if defined(MBEDTLS_ECP_NO_FALLBACK) && defined(MBEDTLS_ECP_ADD_MIXED_ALT) - return (MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); -#else - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_mpi T1, T2, T3, T4, X, Y, Z; - - /* - * Trivial cases: P == 0 or Q == 0 (case 1) - */ - if (mbedtls_mpi_cmp_int(&P->Z, 0) == 0) - return (mbedtls_ecp_copy(R, Q)); - - if (Q->Z.p != NULL && mbedtls_mpi_cmp_int(&Q->Z, 0) == 0) - return (mbedtls_ecp_copy(R, P)); - - /* - * Make sure Q coordinates are normalized - */ - if (Q->Z.p != NULL && mbedtls_mpi_cmp_int(&Q->Z, 1) != 0) - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - - mbedtls_mpi_init(&T1); - mbedtls_mpi_init(&T2); - mbedtls_mpi_init(&T3); - mbedtls_mpi_init(&T4); - mbedtls_mpi_init(&X); - mbedtls_mpi_init(&Y); - mbedtls_mpi_init(&Z); - - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T1, &P->Z, &P->Z)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T2, &T1, &P->Z)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T1, &T1, &Q->X)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T2, &T2, &Q->Y)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &T1, &T1, &P->X)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &T2, &T2, &P->Y)); - - /* Special cases (2) and (3) */ - if (mbedtls_mpi_cmp_int(&T1, 0) == 0) - { - if (mbedtls_mpi_cmp_int(&T2, 0) == 0) - { - ret = ecp_double_jac(grp, R, P); - goto cleanup; - } - else - { - ret = mbedtls_ecp_set_zero(R); - goto cleanup; - } - } - - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &Z, &P->Z, &T1)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T3, &T1, &T1)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T4, &T3, &T1)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T3, &T3, &P->X)); - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&T1, &T3)); - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_l_mod(grp, &T1, 1)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &X, &T2, &T2)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &X, &X, &T1)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &X, &X, &T4)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &T3, &T3, &X)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T3, &T3, &T2)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &T4, &T4, &P->Y)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &Y, &T3, &T4)); - - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&R->X, &X)); - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&R->Y, &Y)); - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&R->Z, &Z)); - -cleanup: - - mbedtls_mpi_free(&T1); - mbedtls_mpi_free(&T2); - mbedtls_mpi_free(&T3); - mbedtls_mpi_free(&T4); - mbedtls_mpi_free(&X); - mbedtls_mpi_free(&Y); - mbedtls_mpi_free(&Z); - - return (ret); -#endif /* !defined(MBEDTLS_ECP_NO_FALLBACK) || !defined(MBEDTLS_ECP_ADD_MIXED_ALT) */ -} - -/* - * Randomize jacobian coordinates: - * (X, Y, Z) -> (l^2 X, l^3 Y, l Z) for random l - * This is sort of the reverse operation of ecp_normalize_jac(). - * - * This countermeasure was first suggested in [2]. - */ -static int ecp_randomize_jac(const mbedtls_ecp_group * grp, mbedtls_ecp_point * pt, int (*f_rng)(void *, unsigned char *, size_t), - void * p_rng) -{ -#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) - if (mbedtls_internal_ecp_grp_capable(grp)) - return (mbedtls_internal_ecp_randomize_jac(grp, pt, f_rng, p_rng)); -#endif /* MBEDTLS_ECP_RANDOMIZE_JAC_ALT */ - -#if defined(MBEDTLS_ECP_NO_FALLBACK) && defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) - return (MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); -#else - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_mpi l, ll; - - mbedtls_mpi_init(&l); - mbedtls_mpi_init(&ll); - - /* Generate l such that 1 < l < p */ - MBEDTLS_MPI_CHK(mbedtls_mpi_random(&l, 2, &grp->P, f_rng, p_rng)); - - /* Z = l * Z */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &pt->Z, &pt->Z, &l)); - - /* X = l^2 * X */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &ll, &l, &l)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &pt->X, &pt->X, &ll)); - - /* Y = l^3 * Y */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &ll, &ll, &l)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &pt->Y, &pt->Y, &ll)); - -cleanup: - mbedtls_mpi_free(&l); - mbedtls_mpi_free(&ll); - - if (ret == MBEDTLS_ERR_MPI_NOT_ACCEPTABLE) - ret = MBEDTLS_ERR_ECP_RANDOM_FAILED; - return (ret); -#endif /* !defined(MBEDTLS_ECP_NO_FALLBACK) || !defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) */ -} - -/* - * Check and define parameters used by the comb method (see below for details) - */ -#if MBEDTLS_ECP_WINDOW_SIZE < 2 || MBEDTLS_ECP_WINDOW_SIZE > 7 -#error "MBEDTLS_ECP_WINDOW_SIZE out of bounds" -#endif - -/* d = ceil( n / w ) */ -#define COMB_MAX_D (MBEDTLS_ECP_MAX_BITS + 1) / 2 - -/* number of precomputed points */ -#define COMB_MAX_PRE (1 << (MBEDTLS_ECP_WINDOW_SIZE - 1)) - -/* - * Compute the representation of m that will be used with our comb method. - * - * The basic comb method is described in GECC 3.44 for example. We use a - * modified version that provides resistance to SPA by avoiding zero - * digits in the representation as in [3]. We modify the method further by - * requiring that all K_i be odd, which has the small cost that our - * representation uses one more K_i, due to carries, but saves on the size of - * the precomputed table. - * - * Summary of the comb method and its modifications: - * - * - The goal is to compute m*P for some w*d-bit integer m. - * - * - The basic comb method splits m into the w-bit integers - * x[0] .. x[d-1] where x[i] consists of the bits in m whose - * index has residue i modulo d, and computes m * P as - * S[x[0]] + 2 * S[x[1]] + .. + 2^(d-1) S[x[d-1]], where - * S[i_{w-1} .. i_0] := i_{w-1} 2^{(w-1)d} P + ... + i_1 2^d P + i_0 P. - * - * - If it happens that, say, x[i+1]=0 (=> S[x[i+1]]=0), one can replace the sum by - * .. + 2^{i-1} S[x[i-1]] - 2^i S[x[i]] + 2^{i+1} S[x[i]] + 2^{i+2} S[x[i+2]] .., - * thereby successively converting it into a form where all summands - * are nonzero, at the cost of negative summands. This is the basic idea of [3]. - * - * - More generally, even if x[i+1] != 0, we can first transform the sum as - * .. - 2^i S[x[i]] + 2^{i+1} ( S[x[i]] + S[x[i+1]] ) + 2^{i+2} S[x[i+2]] .., - * and then replace S[x[i]] + S[x[i+1]] = S[x[i] ^ x[i+1]] + 2 S[x[i] & x[i+1]]. - * Performing and iterating this procedure for those x[i] that are even - * (keeping track of carry), we can transform the original sum into one of the form - * S[x'[0]] +- 2 S[x'[1]] +- .. +- 2^{d-1} S[x'[d-1]] + 2^d S[x'[d]] - * with all x'[i] odd. It is therefore only necessary to know S at odd indices, - * which is why we are only computing half of it in the first place in - * ecp_precompute_comb and accessing it with index abs(i) / 2 in ecp_select_comb. - * - * - For the sake of compactness, only the seven low-order bits of x[i] - * are used to represent its absolute value (K_i in the paper), and the msb - * of x[i] encodes the sign (s_i in the paper): it is set if and only if - * if s_i == -1; - * - * Calling conventions: - * - x is an array of size d + 1 - * - w is the size, ie number of teeth, of the comb, and must be between - * 2 and 7 (in practice, between 2 and MBEDTLS_ECP_WINDOW_SIZE) - * - m is the MPI, expected to be odd and such that bitlength(m) <= w * d - * (the result will be incorrect if these assumptions are not satisfied) - */ -static void ecp_comb_recode_core(unsigned char x[], size_t d, unsigned char w, const mbedtls_mpi * m) -{ - size_t i, j; - unsigned char c, cc, adjust; - - memset(x, 0, d + 1); - - /* First get the classical comb values (except for x_d = 0) */ - for (i = 0; i < d; i++) - for (j = 0; j < w; j++) - x[i] |= mbedtls_mpi_get_bit(m, i + d * j) << j; - - /* Now make sure x_1 .. x_d are odd */ - c = 0; - for (i = 1; i <= d; i++) - { - /* Add carry and update it */ - cc = x[i] & c; - x[i] = x[i] ^ c; - c = cc; - - /* Adjust if needed, avoiding branches */ - adjust = 1 - (x[i] & 0x01); - c |= x[i] & (x[i - 1] * adjust); - x[i] = x[i] ^ (x[i - 1] * adjust); - x[i - 1] |= adjust << 7; - } -} - -/* - * Precompute points for the adapted comb method - * - * Assumption: T must be able to hold 2^{w - 1} elements. - * - * Operation: If i = i_{w-1} ... i_1 is the binary representation of i, - * sets T[i] = i_{w-1} 2^{(w-1)d} P + ... + i_1 2^d P + P. - * - * Cost: d(w-1) D + (2^{w-1} - 1) A + 1 N(w-1) + 1 N(2^{w-1} - 1) - * - * Note: Even comb values (those where P would be omitted from the - * sum defining T[i] above) are not needed in our adaption - * the comb method. See ecp_comb_recode_core(). - * - * This function currently works in four steps: - * (1) [dbl] Computation of intermediate T[i] for 2-power values of i - * (2) [norm_dbl] Normalization of coordinates of these T[i] - * (3) [add] Computation of all T[i] - * (4) [norm_add] Normalization of all T[i] - * - * Step 1 can be interrupted but not the others; together with the final - * coordinate normalization they are the largest steps done at once, depending - * on the window size. Here are operation counts for P-256: - * - * step (2) (3) (4) - * w = 5 142 165 208 - * w = 4 136 77 160 - * w = 3 130 33 136 - * w = 2 124 11 124 - * - * So if ECC operations are blocking for too long even with a low max_ops - * value, it's useful to set MBEDTLS_ECP_WINDOW_SIZE to a lower value in order - * to minimize maximum blocking time. - */ -static int ecp_precompute_comb(const mbedtls_ecp_group * grp, mbedtls_ecp_point T[], const mbedtls_ecp_point * P, unsigned char w, - size_t d, mbedtls_ecp_restart_ctx * rs_ctx) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - unsigned char i; - size_t j = 0; - const unsigned char T_size = 1U << (w - 1); - mbedtls_ecp_point *cur, *TT[COMB_MAX_PRE - 1]; - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->rsm != NULL) - { - if (rs_ctx->rsm->state == ecp_rsm_pre_dbl) - goto dbl; - if (rs_ctx->rsm->state == ecp_rsm_pre_norm_dbl) - goto norm_dbl; - if (rs_ctx->rsm->state == ecp_rsm_pre_add) - goto add; - if (rs_ctx->rsm->state == ecp_rsm_pre_norm_add) - goto norm_add; - } -#else - (void) rs_ctx; -#endif - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->rsm != NULL) - { - rs_ctx->rsm->state = ecp_rsm_pre_dbl; - - /* initial state for the loop */ - rs_ctx->rsm->i = 0; - } - -dbl: -#endif - /* - * Set T[0] = P and - * T[2^{l-1}] = 2^{dl} P for l = 1 .. w-1 (this is not the final value) - */ - MBEDTLS_MPI_CHK(mbedtls_ecp_copy(&T[0], P)); - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->rsm != NULL && rs_ctx->rsm->i != 0) - j = rs_ctx->rsm->i; - else -#endif - j = 0; - - for (; j < d * (w - 1); j++) - { - MBEDTLS_ECP_BUDGET(MBEDTLS_ECP_OPS_DBL); - - i = 1U << (j / d); - cur = T + i; - - if (j % d == 0) - MBEDTLS_MPI_CHK(mbedtls_ecp_copy(cur, T + (i >> 1))); - - MBEDTLS_MPI_CHK(ecp_double_jac(grp, cur, cur)); - } - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->rsm != NULL) - rs_ctx->rsm->state = ecp_rsm_pre_norm_dbl; - -norm_dbl: -#endif - /* - * Normalize current elements in T. As T has holes, - * use an auxiliary array of pointers to elements in T. - */ - j = 0; - for (i = 1; i < T_size; i <<= 1) - TT[j++] = T + i; - - MBEDTLS_ECP_BUDGET(MBEDTLS_ECP_OPS_INV + 6 * j - 2); - - MBEDTLS_MPI_CHK(ecp_normalize_jac_many(grp, TT, j)); - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->rsm != NULL) - rs_ctx->rsm->state = ecp_rsm_pre_add; - -add: -#endif - /* - * Compute the remaining ones using the minimal number of additions - * Be careful to update T[2^l] only after using it! - */ - MBEDTLS_ECP_BUDGET((T_size - 1) * MBEDTLS_ECP_OPS_ADD); - - for (i = 1; i < T_size; i <<= 1) - { - j = i; - while (j--) - MBEDTLS_MPI_CHK(ecp_add_mixed(grp, &T[i + j], &T[j], &T[i])); - } - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->rsm != NULL) - rs_ctx->rsm->state = ecp_rsm_pre_norm_add; - -norm_add: -#endif - /* - * Normalize final elements in T. Even though there are no holes now, we - * still need the auxiliary array for homogeneity with the previous - * call. Also, skip T[0] which is already normalised, being a copy of P. - */ - for (j = 0; j + 1 < T_size; j++) - TT[j] = T + j + 1; - - MBEDTLS_ECP_BUDGET(MBEDTLS_ECP_OPS_INV + 6 * j - 2); - - MBEDTLS_MPI_CHK(ecp_normalize_jac_many(grp, TT, j)); - -cleanup: -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->rsm != NULL && ret == MBEDTLS_ERR_ECP_IN_PROGRESS) - { - if (rs_ctx->rsm->state == ecp_rsm_pre_dbl) - rs_ctx->rsm->i = j; - } -#endif - - return (ret); -} - -/* - * Select precomputed point: R = sign(i) * T[ abs(i) / 2 ] - * - * See ecp_comb_recode_core() for background - */ -static int ecp_select_comb(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_ecp_point T[], unsigned char T_size, - unsigned char i) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - unsigned char ii, j; - - /* Ignore the "sign" bit and scale down */ - ii = (i & 0x7Fu) >> 1; - - /* Read the whole table to thwart cache-based timing attacks */ - for (j = 0; j < T_size; j++) - { - MBEDTLS_MPI_CHK(mbedtls_mpi_safe_cond_assign(&R->X, &T[j].X, j == ii)); - MBEDTLS_MPI_CHK(mbedtls_mpi_safe_cond_assign(&R->Y, &T[j].Y, j == ii)); - } - - /* Safely invert result if i is "negative" */ - MBEDTLS_MPI_CHK(ecp_safe_invert_jac(grp, R, i >> 7)); - -cleanup: - return (ret); -} - -/* - * Core multiplication algorithm for the (modified) comb method. - * This part is actually common with the basic comb method (GECC 3.44) - * - * Cost: d A + d D + 1 R - */ -static int ecp_mul_comb_core(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_ecp_point T[], - unsigned char T_size, const unsigned char x[], size_t d, int (*f_rng)(void *, unsigned char *, size_t), - void * p_rng, mbedtls_ecp_restart_ctx * rs_ctx) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_ecp_point Txi; - size_t i; - - mbedtls_ecp_point_init(&Txi); - -#if !defined(MBEDTLS_ECP_RESTARTABLE) - (void) rs_ctx; -#endif - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->rsm != NULL && rs_ctx->rsm->state != ecp_rsm_comb_core) - { - rs_ctx->rsm->i = 0; - rs_ctx->rsm->state = ecp_rsm_comb_core; - } - - /* new 'if' instead of nested for the sake of the 'else' branch */ - if (rs_ctx != NULL && rs_ctx->rsm != NULL && rs_ctx->rsm->i != 0) - { - /* restore current index (R already pointing to rs_ctx->rsm->R) */ - i = rs_ctx->rsm->i; - } - else -#endif - { - /* Start with a non-zero point and randomize its coordinates */ - i = d; - MBEDTLS_MPI_CHK(ecp_select_comb(grp, R, T, T_size, x[i])); - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); - if (f_rng != 0) - MBEDTLS_MPI_CHK(ecp_randomize_jac(grp, R, f_rng, p_rng)); - } - - while (i != 0) - { - MBEDTLS_ECP_BUDGET(MBEDTLS_ECP_OPS_DBL + MBEDTLS_ECP_OPS_ADD); - --i; - - MBEDTLS_MPI_CHK(ecp_double_jac(grp, R, R)); - MBEDTLS_MPI_CHK(ecp_select_comb(grp, &Txi, T, T_size, x[i])); - MBEDTLS_MPI_CHK(ecp_add_mixed(grp, R, R, &Txi)); - } - -cleanup: - - mbedtls_ecp_point_free(&Txi); - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->rsm != NULL && ret == MBEDTLS_ERR_ECP_IN_PROGRESS) - { - rs_ctx->rsm->i = i; - /* no need to save R, already pointing to rs_ctx->rsm->R */ - } -#endif - - return (ret); -} - -/* - * Recode the scalar to get constant-time comb multiplication - * - * As the actual scalar recoding needs an odd scalar as a starting point, - * this wrapper ensures that by replacing m by N - m if necessary, and - * informs the caller that the result of multiplication will be negated. - * - * This works because we only support large prime order for Short Weierstrass - * curves, so N is always odd hence either m or N - m is. - * - * See ecp_comb_recode_core() for background. - */ -static int ecp_comb_recode_scalar(const mbedtls_ecp_group * grp, const mbedtls_mpi * m, unsigned char k[COMB_MAX_D + 1], size_t d, - unsigned char w, unsigned char * parity_trick) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_mpi M, mm; - - mbedtls_mpi_init(&M); - mbedtls_mpi_init(&mm); - - /* N is always odd (see above), just make extra sure */ - if (mbedtls_mpi_get_bit(&grp->N, 0) != 1) - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - - /* do we need the parity trick? */ - *parity_trick = (mbedtls_mpi_get_bit(m, 0) == 0); - - /* execute parity fix in constant time */ - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&M, m)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(&mm, &grp->N, m)); - MBEDTLS_MPI_CHK(mbedtls_mpi_safe_cond_assign(&M, &mm, *parity_trick)); - - /* actual scalar recoding */ - ecp_comb_recode_core(k, d, w, &M); - -cleanup: - mbedtls_mpi_free(&mm); - mbedtls_mpi_free(&M); - - return (ret); -} - -/* - * Perform comb multiplication (for short Weierstrass curves) - * once the auxiliary table has been pre-computed. - * - * Scalar recoding may use a parity trick that makes us compute -m * P, - * if that is the case we'll need to recover m * P at the end. - */ -static int ecp_mul_comb_after_precomp(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, - const mbedtls_ecp_point * T, unsigned char T_size, unsigned char w, size_t d, - int (*f_rng)(void *, unsigned char *, size_t), void * p_rng, mbedtls_ecp_restart_ctx * rs_ctx) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - unsigned char parity_trick; - unsigned char k[COMB_MAX_D + 1]; - mbedtls_ecp_point * RR = R; - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->rsm != NULL) - { - RR = &rs_ctx->rsm->R; - - if (rs_ctx->rsm->state == ecp_rsm_final_norm) - goto final_norm; - } -#endif - - MBEDTLS_MPI_CHK(ecp_comb_recode_scalar(grp, m, k, d, w, &parity_trick)); - MBEDTLS_MPI_CHK(ecp_mul_comb_core(grp, RR, T, T_size, k, d, f_rng, p_rng, rs_ctx)); - MBEDTLS_MPI_CHK(ecp_safe_invert_jac(grp, RR, parity_trick)); - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->rsm != NULL) - rs_ctx->rsm->state = ecp_rsm_final_norm; - -final_norm: - MBEDTLS_ECP_BUDGET(MBEDTLS_ECP_OPS_INV); -#endif - /* - * Knowledge of the jacobian coordinates may leak the last few bits of the - * scalar [1], and since our MPI implementation isn't constant-flow, - * inversion (used for coordinate normalization) may leak the full value - * of its input via side-channels [2]. - * - * [1] https://eprint.iacr.org/2003/191 - * [2] https://eprint.iacr.org/2020/055 - * - * Avoid the leak by randomizing coordinates before we normalize them. - */ - if (f_rng != 0) - MBEDTLS_MPI_CHK(ecp_randomize_jac(grp, RR, f_rng, p_rng)); - - MBEDTLS_MPI_CHK(ecp_normalize_jac(grp, RR)); - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->rsm != NULL) - MBEDTLS_MPI_CHK(mbedtls_ecp_copy(R, RR)); -#endif - -cleanup: - return (ret); -} - -/* - * Pick window size based on curve size and whether we optimize for base point - */ -static unsigned char ecp_pick_window_size(const mbedtls_ecp_group * grp, unsigned char p_eq_g) -{ - unsigned char w; - - /* - * Minimize the number of multiplications, that is minimize - * 10 * d * w + 18 * 2^(w-1) + 11 * d + 7 * w, with d = ceil( nbits / w ) - * (see costs of the various parts, with 1S = 1M) - */ - w = grp->nbits >= 384 ? 5 : 4; - - /* - * If P == G, pre-compute a bit more, since this may be re-used later. - * Just adding one avoids upping the cost of the first mul too much, - * and the memory cost too. - */ - if (p_eq_g) - w++; - - /* - * If static comb table may not be used (!p_eq_g) or static comb table does - * not exists, make sure w is within bounds. - * (The last test is useful only for very small curves in the test suite.) - * - * The user reduces MBEDTLS_ECP_WINDOW_SIZE does not changes the size of - * static comb table, because the size of static comb table is fixed when - * it is generated. - */ -#if (MBEDTLS_ECP_WINDOW_SIZE < 6) - if ((!p_eq_g || !ecp_group_is_static_comb_table(grp)) && w > MBEDTLS_ECP_WINDOW_SIZE) - w = MBEDTLS_ECP_WINDOW_SIZE; -#endif - if (w >= grp->nbits) - w = 2; - - return (w); -} - -/* - * Multiplication using the comb method - for curves in short Weierstrass form - * - * This function is mainly responsible for administrative work: - * - managing the restart context if enabled - * - managing the table of precomputed points (passed between the below two - * functions): allocation, computation, ownership tranfer, freeing. - * - * It delegates the actual arithmetic work to: - * ecp_precompute_comb() and ecp_mul_comb_with_precomp() - * - * See comments on ecp_comb_recode_core() regarding the computation strategy. - */ -static int ecp_mul_comb(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, - int (*f_rng)(void *, unsigned char *, size_t), void * p_rng, mbedtls_ecp_restart_ctx * rs_ctx) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - unsigned char w, p_eq_g, i; - size_t d; - unsigned char T_size = 0, T_ok = 0; - mbedtls_ecp_point * T = NULL; - - ECP_RS_ENTER(rsm); - - /* Is P the base point ? */ -#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 - p_eq_g = (mbedtls_mpi_cmp_mpi(&P->Y, &grp->G.Y) == 0 && mbedtls_mpi_cmp_mpi(&P->X, &grp->G.X) == 0); -#else - p_eq_g = 0; -#endif - - /* Pick window size and deduce related sizes */ - w = ecp_pick_window_size(grp, p_eq_g); - T_size = 1U << (w - 1); - d = (grp->nbits + w - 1) / w; - - /* Pre-computed table: do we have it already for the base point? */ - if (p_eq_g && grp->T != NULL) - { - /* second pointer to the same table, will be deleted on exit */ - T = grp->T; - T_ok = 1; - } - else -#if defined(MBEDTLS_ECP_RESTARTABLE) - /* Pre-computed table: do we have one in progress? complete? */ - if (rs_ctx != NULL && rs_ctx->rsm != NULL && rs_ctx->rsm->T != NULL) - { - /* transfer ownership of T from rsm to local function */ - T = rs_ctx->rsm->T; - rs_ctx->rsm->T = NULL; - rs_ctx->rsm->T_size = 0; - - /* This effectively jumps to the call to mul_comb_after_precomp() */ - T_ok = rs_ctx->rsm->state >= ecp_rsm_comb_core; - } - else -#endif - /* Allocate table if we didn't have any */ - { - T = mbedtls_calloc(T_size, sizeof(mbedtls_ecp_point)); - if (T == NULL) - { - ret = MBEDTLS_ERR_ECP_ALLOC_FAILED; - goto cleanup; - } - - for (i = 0; i < T_size; i++) - mbedtls_ecp_point_init(&T[i]); - - T_ok = 0; - } - - /* Compute table (or finish computing it) if not done already */ - if (!T_ok) - { - MBEDTLS_MPI_CHK(ecp_precompute_comb(grp, T, P, w, d, rs_ctx)); - - if (p_eq_g) - { - /* almost transfer ownership of T to the group, but keep a copy of - * the pointer to use for calling the next function more easily */ - grp->T = T; - grp->T_size = T_size; - } - } - - /* Actual comb multiplication using precomputed points */ - MBEDTLS_MPI_CHK(ecp_mul_comb_after_precomp(grp, R, m, T, T_size, w, d, f_rng, p_rng, rs_ctx)); - -cleanup: - - /* does T belong to the group? */ - if (T == grp->T) - T = NULL; - - /* does T belong to the restart context? */ -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->rsm != NULL && ret == MBEDTLS_ERR_ECP_IN_PROGRESS && T != NULL) - { - /* transfer ownership of T from local function to rsm */ - rs_ctx->rsm->T_size = T_size; - rs_ctx->rsm->T = T; - T = NULL; - } -#endif - - /* did T belong to us? then let's destroy it! */ - if (T != NULL) - { - for (i = 0; i < T_size; i++) - mbedtls_ecp_point_free(&T[i]); - mbedtls_free(T); - } - - /* don't free R while in progress in case R == P */ -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (ret != MBEDTLS_ERR_ECP_IN_PROGRESS) -#endif - /* prevent caller from using invalid value */ - if (ret != 0) - mbedtls_ecp_point_free(R); - - ECP_RS_LEAVE(rsm); - - return (ret); -} - -#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) -/* - * For Montgomery curves, we do all the internal arithmetic in projective - * coordinates. Import/export of points uses only the x coordinates, which is - * internaly represented as X / Z. - * - * For scalar multiplication, we'll use a Montgomery ladder. - */ - -/* - * Normalize Montgomery x/z coordinates: X = X/Z, Z = 1 - * Cost: 1M + 1I - */ -static int ecp_normalize_mxz(const mbedtls_ecp_group * grp, mbedtls_ecp_point * P) -{ -#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) - if (mbedtls_internal_ecp_grp_capable(grp)) - return (mbedtls_internal_ecp_normalize_mxz(grp, P)); -#endif /* MBEDTLS_ECP_NORMALIZE_MXZ_ALT */ - -#if defined(MBEDTLS_ECP_NO_FALLBACK) && defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) - return (MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); -#else - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - MBEDTLS_MPI_CHK(mbedtls_mpi_inv_mod(&P->Z, &P->Z, &grp->P)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &P->X, &P->X, &P->Z)); - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&P->Z, 1)); - -cleanup: - return (ret); -#endif /* !defined(MBEDTLS_ECP_NO_FALLBACK) || !defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) */ -} - -/* - * Randomize projective x/z coordinates: - * (X, Z) -> (l X, l Z) for random l - * This is sort of the reverse operation of ecp_normalize_mxz(). - * - * This countermeasure was first suggested in [2]. - * Cost: 2M - */ -static int ecp_randomize_mxz(const mbedtls_ecp_group * grp, mbedtls_ecp_point * P, int (*f_rng)(void *, unsigned char *, size_t), - void * p_rng) -{ -#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) - if (mbedtls_internal_ecp_grp_capable(grp)) - return (mbedtls_internal_ecp_randomize_mxz(grp, P, f_rng, p_rng)); -#endif /* MBEDTLS_ECP_RANDOMIZE_MXZ_ALT */ - -#if defined(MBEDTLS_ECP_NO_FALLBACK) && defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) - return (MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); -#else - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_mpi l; - mbedtls_mpi_init(&l); - - /* Generate l such that 1 < l < p */ - MBEDTLS_MPI_CHK(mbedtls_mpi_random(&l, 2, &grp->P, f_rng, p_rng)); - - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &P->X, &P->X, &l)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &P->Z, &P->Z, &l)); - -cleanup: - mbedtls_mpi_free(&l); - - if (ret == MBEDTLS_ERR_MPI_NOT_ACCEPTABLE) - ret = MBEDTLS_ERR_ECP_RANDOM_FAILED; - return (ret); -#endif /* !defined(MBEDTLS_ECP_NO_FALLBACK) || !defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) */ -} - -/* - * Double-and-add: R = 2P, S = P + Q, with d = X(P - Q), - * for Montgomery curves in x/z coordinates. - * - * http://www.hyperelliptic.org/EFD/g1p/auto-code/montgom/xz/ladder/mladd-1987-m.op3 - * with - * d = X1 - * P = (X2, Z2) - * Q = (X3, Z3) - * R = (X4, Z4) - * S = (X5, Z5) - * and eliminating temporary variables tO, ..., t4. - * - * Cost: 5M + 4S - */ -static int ecp_double_add_mxz(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, mbedtls_ecp_point * S, - const mbedtls_ecp_point * P, const mbedtls_ecp_point * Q, const mbedtls_mpi * d) -{ -#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) - if (mbedtls_internal_ecp_grp_capable(grp)) - return (mbedtls_internal_ecp_double_add_mxz(grp, R, S, P, Q, d)); -#endif /* MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT */ - -#if defined(MBEDTLS_ECP_NO_FALLBACK) && defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) - return (MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); -#else - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_mpi A, AA, B, BB, E, C, D, DA, CB; - - mbedtls_mpi_init(&A); - mbedtls_mpi_init(&AA); - mbedtls_mpi_init(&B); - mbedtls_mpi_init(&BB); - mbedtls_mpi_init(&E); - mbedtls_mpi_init(&C); - mbedtls_mpi_init(&D); - mbedtls_mpi_init(&DA); - mbedtls_mpi_init(&CB); - - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mod(grp, &A, &P->X, &P->Z)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &AA, &A, &A)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &B, &P->X, &P->Z)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &BB, &B, &B)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &E, &AA, &BB)); - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mod(grp, &C, &Q->X, &Q->Z)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &D, &Q->X, &Q->Z)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &DA, &D, &A)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &CB, &C, &B)); - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mod(grp, &S->X, &DA, &CB)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &S->X, &S->X, &S->X)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mod(grp, &S->Z, &DA, &CB)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &S->Z, &S->Z, &S->Z)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &S->Z, d, &S->Z)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &R->X, &AA, &BB)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &R->Z, &grp->A, &E)); - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mod(grp, &R->Z, &BB, &R->Z)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &R->Z, &E, &R->Z)); - -cleanup: - mbedtls_mpi_free(&A); - mbedtls_mpi_free(&AA); - mbedtls_mpi_free(&B); - mbedtls_mpi_free(&BB); - mbedtls_mpi_free(&E); - mbedtls_mpi_free(&C); - mbedtls_mpi_free(&D); - mbedtls_mpi_free(&DA); - mbedtls_mpi_free(&CB); - - return (ret); -#endif /* !defined(MBEDTLS_ECP_NO_FALLBACK) || !defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) */ -} - -/* - * Multiplication with Montgomery ladder in x/z coordinates, - * for curves in Montgomery form - */ -static int ecp_mul_mxz(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, - int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - size_t i; - unsigned char b; - mbedtls_ecp_point RP; - mbedtls_mpi PX; - mbedtls_ecp_point_init(&RP); - mbedtls_mpi_init(&PX); - - if (f_rng == NULL) - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - - /* Save PX and read from P before writing to R, in case P == R */ - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&PX, &P->X)); - MBEDTLS_MPI_CHK(mbedtls_ecp_copy(&RP, P)); - - /* Set R to zero in modified x/z coordinates */ - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->X, 1)); - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 0)); - mbedtls_mpi_free(&R->Y); - - /* RP.X might be sligtly larger than P, so reduce it */ - MOD_ADD(RP.X); - - /* Randomize coordinates of the starting point */ - MBEDTLS_MPI_CHK(ecp_randomize_mxz(grp, &RP, f_rng, p_rng)); - - /* Loop invariant: R = result so far, RP = R + P */ - i = mbedtls_mpi_bitlen(m); /* one past the (zero-based) most significant bit */ - while (i-- > 0) - { - b = mbedtls_mpi_get_bit(m, i); - /* - * if (b) R = 2R + P else R = 2R, - * which is: - * if (b) double_add( RP, R, RP, R ) - * else double_add( R, RP, R, RP ) - * but using safe conditional swaps to avoid leaks - */ - MBEDTLS_MPI_CHK(mbedtls_mpi_safe_cond_swap(&R->X, &RP.X, b)); - MBEDTLS_MPI_CHK(mbedtls_mpi_safe_cond_swap(&R->Z, &RP.Z, b)); - MBEDTLS_MPI_CHK(ecp_double_add_mxz(grp, R, &RP, R, &RP, &PX)); - MBEDTLS_MPI_CHK(mbedtls_mpi_safe_cond_swap(&R->X, &RP.X, b)); - MBEDTLS_MPI_CHK(mbedtls_mpi_safe_cond_swap(&R->Z, &RP.Z, b)); - } - - /* - * Knowledge of the projective coordinates may leak the last few bits of the - * scalar [1], and since our MPI implementation isn't constant-flow, - * inversion (used for coordinate normalization) may leak the full value - * of its input via side-channels [2]. - * - * [1] https://eprint.iacr.org/2003/191 - * [2] https://eprint.iacr.org/2020/055 - * - * Avoid the leak by randomizing coordinates before we normalize them. - */ - MBEDTLS_MPI_CHK(ecp_randomize_mxz(grp, R, f_rng, p_rng)); - MBEDTLS_MPI_CHK(ecp_normalize_mxz(grp, R)); - -cleanup: - mbedtls_ecp_point_free(&RP); - mbedtls_mpi_free(&PX); - - return (ret); -} - -#endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */ - -/* - * Restartable multiplication R = m * P - * - * This internal function can be called without an RNG in case where we know - * the inputs are not sensitive. - */ -static int ecp_mul_restartable_internal(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, - const mbedtls_ecp_point * P, int (*f_rng)(void *, unsigned char *, size_t), void * p_rng, - mbedtls_ecp_restart_ctx * rs_ctx) -{ - int ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; -#if defined(MBEDTLS_ECP_INTERNAL_ALT) - char is_grp_capable = 0; -#endif - -#if defined(MBEDTLS_ECP_RESTARTABLE) - /* reset ops count for this call if top-level */ - if (rs_ctx != NULL && rs_ctx->depth++ == 0) - rs_ctx->ops_done = 0; -#else - (void) rs_ctx; -#endif - -#if defined(MBEDTLS_ECP_INTERNAL_ALT) - if ((is_grp_capable = mbedtls_internal_ecp_grp_capable(grp))) - MBEDTLS_MPI_CHK(mbedtls_internal_ecp_init(grp)); -#endif /* MBEDTLS_ECP_INTERNAL_ALT */ - -#if defined(MBEDTLS_ECP_RESTARTABLE) - /* skip argument check when restarting */ - if (rs_ctx == NULL || rs_ctx->rsm == NULL) -#endif - { - /* check_privkey is free */ - MBEDTLS_ECP_BUDGET(MBEDTLS_ECP_OPS_CHK); - - /* Common sanity checks */ - MBEDTLS_MPI_CHK(mbedtls_ecp_check_privkey(grp, m)); - MBEDTLS_MPI_CHK(mbedtls_ecp_check_pubkey(grp, P)); - } - - ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_MONTGOMERY) - MBEDTLS_MPI_CHK(ecp_mul_mxz(grp, R, m, P, f_rng, p_rng)); -#endif -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS) - MBEDTLS_MPI_CHK(ecp_mul_comb(grp, R, m, P, f_rng, p_rng, rs_ctx)); -#endif - -cleanup: - -#if defined(MBEDTLS_ECP_INTERNAL_ALT) - if (is_grp_capable) - mbedtls_internal_ecp_free(grp); -#endif /* MBEDTLS_ECP_INTERNAL_ALT */ - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL) - rs_ctx->depth--; -#endif - - return (ret); -} - -/* - * Restartable multiplication R = m * P - */ -int mbedtls_ecp_mul_restartable(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, - int (*f_rng)(void *, unsigned char *, size_t), void * p_rng, mbedtls_ecp_restart_ctx * rs_ctx) -{ - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(R != NULL); - ECP_VALIDATE_RET(m != NULL); - ECP_VALIDATE_RET(P != NULL); - - if (f_rng == NULL) - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - - if (GET_WORD_LEN(grp->pbits) <= PKE_OPERAND_MAX_WORD_LEN) - return (ecp_alt_b91_backend_mul(grp, R, m, P)); - - return (ecp_mul_restartable_internal(grp, R, m, P, f_rng, p_rng, rs_ctx)); -} - -/* - * Multiplication R = m * P - */ -int mbedtls_ecp_mul(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, - int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) -{ - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(R != NULL); - ECP_VALIDATE_RET(m != NULL); - ECP_VALIDATE_RET(P != NULL); - return (mbedtls_ecp_mul_restartable(grp, R, m, P, f_rng, p_rng, NULL)); -} - -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) -/* - * Check that an affine point is valid as a public key, - * short weierstrass curves (SEC1 3.2.3.1) - */ -static int ecp_check_pubkey_sw(const mbedtls_ecp_group * grp, const mbedtls_ecp_point * pt) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_mpi YY, RHS; - - /* pt coordinates must be normalized for our checks */ - if (mbedtls_mpi_cmp_int(&pt->X, 0) < 0 || mbedtls_mpi_cmp_int(&pt->Y, 0) < 0 || mbedtls_mpi_cmp_mpi(&pt->X, &grp->P) >= 0 || - mbedtls_mpi_cmp_mpi(&pt->Y, &grp->P) >= 0) - return (MBEDTLS_ERR_ECP_INVALID_KEY); - - mbedtls_mpi_init(&YY); - mbedtls_mpi_init(&RHS); - - /* - * YY = Y^2 - * RHS = X (X^2 + A) + B = X^3 + A X + B - */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &YY, &pt->Y, &pt->Y)); - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &RHS, &pt->X, &pt->X)); - - /* Special case for A = -3 */ - if (grp->A.p == NULL) - { - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_int(&RHS, &RHS, 3)); - MOD_SUB(RHS); - } - else - { - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mod(grp, &RHS, &RHS, &grp->A)); - } - - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mod(grp, &RHS, &RHS, &pt->X)); - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mod(grp, &RHS, &RHS, &grp->B)); - - if (mbedtls_mpi_cmp_mpi(&YY, &RHS) != 0) - ret = MBEDTLS_ERR_ECP_INVALID_KEY; - -cleanup: - - mbedtls_mpi_free(&YY); - mbedtls_mpi_free(&RHS); - - return (ret); -} -#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ - -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) -/* - * R = m * P with shortcuts for m == 0, m == 1 and m == -1 - * NOT constant-time - ONLY for short Weierstrass! - */ -static int mbedtls_ecp_mul_shortcuts(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, - const mbedtls_ecp_point * P, mbedtls_ecp_restart_ctx * rs_ctx) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - - if (mbedtls_mpi_cmp_int(m, 0) == 0) - { - MBEDTLS_MPI_CHK(mbedtls_ecp_set_zero(R)); - } - else if (mbedtls_mpi_cmp_int(m, 1) == 0) - { - MBEDTLS_MPI_CHK(mbedtls_ecp_copy(R, P)); - } - else if (mbedtls_mpi_cmp_int(m, -1) == 0) - { - MBEDTLS_MPI_CHK(mbedtls_ecp_copy(R, P)); - if (mbedtls_mpi_cmp_int(&R->Y, 0) != 0) - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(&R->Y, &grp->P, &R->Y)); - } - else - { - MBEDTLS_MPI_CHK(ecp_mul_restartable_internal(grp, R, m, P, NULL, NULL, rs_ctx)); - } - -cleanup: - return (ret); -} - -/* - * Restartable linear combination - * NOT constant-time - */ -int mbedtls_ecp_muladd_restartable(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, - const mbedtls_ecp_point * P, const mbedtls_mpi * n, const mbedtls_ecp_point * Q, - mbedtls_ecp_restart_ctx * rs_ctx) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_ecp_point mP; - mbedtls_ecp_point * pmP = &mP; - mbedtls_ecp_point * pR = R; -#if defined(MBEDTLS_ECP_INTERNAL_ALT) - char is_grp_capable = 0; -#endif - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(R != NULL); - ECP_VALIDATE_RET(m != NULL); - ECP_VALIDATE_RET(P != NULL); - ECP_VALIDATE_RET(n != NULL); - ECP_VALIDATE_RET(Q != NULL); - - if (mbedtls_ecp_get_type(grp) != MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS) - return (MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); - - if (GET_WORD_LEN(grp->pbits) <= PKE_OPERAND_MAX_WORD_LEN) - return (ecp_alt_b91_backend_muladd(grp, R, m, P, n, Q)); - - mbedtls_ecp_point_init(&mP); - - ECP_RS_ENTER(ma); - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->ma != NULL) - { - /* redirect intermediate results to restart context */ - pmP = &rs_ctx->ma->mP; - pR = &rs_ctx->ma->R; - - /* jump to next operation */ - if (rs_ctx->ma->state == ecp_rsma_mul2) - goto mul2; - if (rs_ctx->ma->state == ecp_rsma_add) - goto add; - if (rs_ctx->ma->state == ecp_rsma_norm) - goto norm; - } -#endif /* MBEDTLS_ECP_RESTARTABLE */ - - MBEDTLS_MPI_CHK(mbedtls_ecp_mul_shortcuts(grp, pmP, m, P, rs_ctx)); -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->ma != NULL) - rs_ctx->ma->state = ecp_rsma_mul2; - -mul2: -#endif - MBEDTLS_MPI_CHK(mbedtls_ecp_mul_shortcuts(grp, pR, n, Q, rs_ctx)); - -#if defined(MBEDTLS_ECP_INTERNAL_ALT) - if ((is_grp_capable = mbedtls_internal_ecp_grp_capable(grp))) - MBEDTLS_MPI_CHK(mbedtls_internal_ecp_init(grp)); -#endif /* MBEDTLS_ECP_INTERNAL_ALT */ - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->ma != NULL) - rs_ctx->ma->state = ecp_rsma_add; - -add: -#endif - MBEDTLS_ECP_BUDGET(MBEDTLS_ECP_OPS_ADD); - MBEDTLS_MPI_CHK(ecp_add_mixed(grp, pR, pmP, pR)); -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->ma != NULL) - rs_ctx->ma->state = ecp_rsma_norm; - -norm: -#endif - MBEDTLS_ECP_BUDGET(MBEDTLS_ECP_OPS_INV); - MBEDTLS_MPI_CHK(ecp_normalize_jac(grp, pR)); - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if (rs_ctx != NULL && rs_ctx->ma != NULL) - MBEDTLS_MPI_CHK(mbedtls_ecp_copy(R, pR)); -#endif - -cleanup: -#if defined(MBEDTLS_ECP_INTERNAL_ALT) - if (is_grp_capable) - mbedtls_internal_ecp_free(grp); -#endif /* MBEDTLS_ECP_INTERNAL_ALT */ - - mbedtls_ecp_point_free(&mP); - - ECP_RS_LEAVE(ma); - - return (ret); -} - -/* - * Linear combination - * NOT constant-time - */ -int mbedtls_ecp_muladd(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, - const mbedtls_mpi * n, const mbedtls_ecp_point * Q) -{ - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(R != NULL); - ECP_VALIDATE_RET(m != NULL); - ECP_VALIDATE_RET(P != NULL); - ECP_VALIDATE_RET(n != NULL); - ECP_VALIDATE_RET(Q != NULL); - return (mbedtls_ecp_muladd_restartable(grp, R, m, P, n, Q, NULL)); -} -#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) -#define ECP_MPI_INIT(s, n, p) \ - { \ - s, (n), (mbedtls_mpi_uint *) (p) \ - } -#define ECP_MPI_INIT_ARRAY(x) ECP_MPI_INIT(1, sizeof(x) / sizeof(mbedtls_mpi_uint), x) -/* - * Constants for the two points other than 0, 1, -1 (mod p) in - * https://cr.yp.to/ecdh.html#validate - * See ecp_check_pubkey_x25519(). - */ -static const mbedtls_mpi_uint x25519_bad_point_1[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xe0, 0xeb, 0x7a, 0x7c, 0x3b, 0x41, 0xb8, 0xae), - MBEDTLS_BYTES_TO_T_UINT_8(0x16, 0x56, 0xe3, 0xfa, 0xf1, 0x9f, 0xc4, 0x6a), - MBEDTLS_BYTES_TO_T_UINT_8(0xda, 0x09, 0x8d, 0xeb, 0x9c, 0x32, 0xb1, 0xfd), - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0x62, 0x05, 0x16, 0x5f, 0x49, 0xb8, 0x00), -}; -static const mbedtls_mpi_uint x25519_bad_point_2[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x5f, 0x9c, 0x95, 0xbc, 0xa3, 0x50, 0x8c, 0x24), - MBEDTLS_BYTES_TO_T_UINT_8(0xb1, 0xd0, 0xb1, 0x55, 0x9c, 0x83, 0xef, 0x5b), - MBEDTLS_BYTES_TO_T_UINT_8(0x04, 0x44, 0x5c, 0xc4, 0x58, 0x1c, 0x8e, 0x86), - MBEDTLS_BYTES_TO_T_UINT_8(0xd8, 0x22, 0x4e, 0xdd, 0xd0, 0x9f, 0x11, 0x57), -}; -static const mbedtls_mpi ecp_x25519_bad_point_1 = ECP_MPI_INIT_ARRAY(x25519_bad_point_1); -static const mbedtls_mpi ecp_x25519_bad_point_2 = ECP_MPI_INIT_ARRAY(x25519_bad_point_2); -#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ - -/* - * Check that the input point is not one of the low-order points. - * This is recommended by the "May the Fourth" paper: - * https://eprint.iacr.org/2017/806.pdf - * Those points are never sent by an honest peer. - */ -static int ecp_check_bad_points_mx(const mbedtls_mpi * X, const mbedtls_mpi * P, const mbedtls_ecp_group_id grp_id) -{ - int ret; - mbedtls_mpi XmP; - - mbedtls_mpi_init(&XmP); - - /* Reduce X mod P so that we only need to check values less than P. - * We know X < 2^256 so we can proceed by subtraction. */ - MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&XmP, X)); - while (mbedtls_mpi_cmp_mpi(&XmP, P) >= 0) - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(&XmP, &XmP, P)); - - /* Check against the known bad values that are less than P. For Curve448 - * these are 0, 1 and -1. For Curve25519 we check the values less than P - * from the following list: https://cr.yp.to/ecdh.html#validate */ - if (mbedtls_mpi_cmp_int(&XmP, 1) <= 0) /* takes care of 0 and 1 */ - { - ret = MBEDTLS_ERR_ECP_INVALID_KEY; - goto cleanup; - } - -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) - if (grp_id == MBEDTLS_ECP_DP_CURVE25519) - { - if (mbedtls_mpi_cmp_mpi(&XmP, &ecp_x25519_bad_point_1) == 0) - { - ret = MBEDTLS_ERR_ECP_INVALID_KEY; - goto cleanup; - } - - if (mbedtls_mpi_cmp_mpi(&XmP, &ecp_x25519_bad_point_2) == 0) - { - ret = MBEDTLS_ERR_ECP_INVALID_KEY; - goto cleanup; - } - } -#else - (void) grp_id; -#endif - - /* Final check: check if XmP + 1 is P (final because it changes XmP!) */ - MBEDTLS_MPI_CHK(mbedtls_mpi_add_int(&XmP, &XmP, 1)); - if (mbedtls_mpi_cmp_mpi(&XmP, P) == 0) - { - ret = MBEDTLS_ERR_ECP_INVALID_KEY; - goto cleanup; - } - - ret = 0; - -cleanup: - mbedtls_mpi_free(&XmP); - - return (ret); -} - -/* - * Check validity of a public key for Montgomery curves with x-only schemes - */ -static int ecp_check_pubkey_mx(const mbedtls_ecp_group * grp, const mbedtls_ecp_point * pt) -{ - /* [Curve25519 p. 5] Just check X is the correct number of bytes */ - /* Allow any public value, if it's too big then we'll just reduce it mod p - * (RFC 7748 sec. 5 para. 3). */ - if (mbedtls_mpi_size(&pt->X) > (grp->nbits + 7) / 8) - return (MBEDTLS_ERR_ECP_INVALID_KEY); - - /* Implicit in all standards (as they don't consider negative numbers): - * X must be non-negative. This is normally ensured by the way it's - * encoded for transmission, but let's be extra sure. */ - if (mbedtls_mpi_cmp_int(&pt->X, 0) < 0) - return (MBEDTLS_ERR_ECP_INVALID_KEY); - - return (ecp_check_bad_points_mx(&pt->X, &grp->P, grp->id)); -} -#endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */ - -/* - * Check that a point is valid as a public key - */ -int mbedtls_ecp_check_pubkey(const mbedtls_ecp_group * grp, const mbedtls_ecp_point * pt) -{ - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(pt != NULL); - - /* Must use affine coordinates */ - if (mbedtls_mpi_cmp_int(&pt->Z, 1) != 0) - return (MBEDTLS_ERR_ECP_INVALID_KEY); - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_MONTGOMERY) - return (ecp_check_pubkey_mx(grp, pt)); -#endif -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) - if (GET_WORD_LEN(grp->pbits) <= PKE_OPERAND_MAX_WORD_LEN) - { - } - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS) - { - if (GET_WORD_LEN(grp->pbits) <= PKE_OPERAND_MAX_WORD_LEN) - return (ecp_alt_b91_backend_check_pubkey(grp, pt)); - else - return (ecp_check_pubkey_sw(grp, pt)); - } -#endif - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); -} - -/* - * Check that an mbedtls_mpi is valid as a private key - */ -int mbedtls_ecp_check_privkey(const mbedtls_ecp_group * grp, const mbedtls_mpi * d) -{ - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(d != NULL); - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_MONTGOMERY) - { - /* see RFC 7748 sec. 5 para. 5 */ - if (mbedtls_mpi_get_bit(d, 0) != 0 || mbedtls_mpi_get_bit(d, 1) != 0 || - mbedtls_mpi_bitlen(d) - 1 != grp->nbits) /* mbedtls_mpi_bitlen is one-based! */ - return (MBEDTLS_ERR_ECP_INVALID_KEY); - - /* see [Curve25519] page 5 */ - if (grp->nbits == 254 && mbedtls_mpi_get_bit(d, 2) != 0) - return (MBEDTLS_ERR_ECP_INVALID_KEY); - - return (0); - } -#endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */ -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS) - { - /* see SEC1 3.2 */ - if (mbedtls_mpi_cmp_int(d, 1) < 0 || mbedtls_mpi_cmp_mpi(d, &grp->N) >= 0) - return (MBEDTLS_ERR_ECP_INVALID_KEY); - else - return (0); - } -#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ - - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); -} - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) -MBEDTLS_STATIC_TESTABLE -int mbedtls_ecp_gen_privkey_mx(size_t high_bit, mbedtls_mpi * d, int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) -{ - int ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; - size_t n_random_bytes = high_bit / 8 + 1; - - /* [Curve25519] page 5 */ - /* Generate a (high_bit+1)-bit random number by generating just enough - * random bytes, then shifting out extra bits from the top (necessary - * when (high_bit+1) is not a multiple of 8). */ - MBEDTLS_MPI_CHK(mbedtls_mpi_fill_random(d, n_random_bytes, f_rng, p_rng)); - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_r(d, 8 * n_random_bytes - high_bit - 1)); - - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(d, high_bit, 1)); - - /* Make sure the last two bits are unset for Curve448, three bits for - Curve25519 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(d, 0, 0)); - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(d, 1, 0)); - if (high_bit == 254) - { - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(d, 2, 0)); - } - -cleanup: - return (ret); -} -#endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */ - -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) -static int mbedtls_ecp_gen_privkey_sw(const mbedtls_mpi * N, mbedtls_mpi * d, int (*f_rng)(void *, unsigned char *, size_t), - void * p_rng) -{ - int ret = mbedtls_mpi_random(d, 1, N, f_rng, p_rng); - switch (ret) - { - case MBEDTLS_ERR_MPI_NOT_ACCEPTABLE: - return (MBEDTLS_ERR_ECP_RANDOM_FAILED); - default: - return (ret); - } -} -#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ - -/* - * Generate a private key - */ -int mbedtls_ecp_gen_privkey(const mbedtls_ecp_group * grp, mbedtls_mpi * d, int (*f_rng)(void *, unsigned char *, size_t), - void * p_rng) -{ - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(d != NULL); - ECP_VALIDATE_RET(f_rng != NULL); - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_MONTGOMERY) - return (mbedtls_ecp_gen_privkey_mx(grp->nbits, d, f_rng, p_rng)); -#endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */ - -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS) - return (mbedtls_ecp_gen_privkey_sw(&grp->N, d, f_rng, p_rng)); -#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ - - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); -} - -/* - * Generate a keypair with configurable base point - */ -int mbedtls_ecp_gen_keypair_base(mbedtls_ecp_group * grp, const mbedtls_ecp_point * G, mbedtls_mpi * d, mbedtls_ecp_point * Q, - int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(d != NULL); - ECP_VALIDATE_RET(G != NULL); - ECP_VALIDATE_RET(Q != NULL); - ECP_VALIDATE_RET(f_rng != NULL); - - MBEDTLS_MPI_CHK(mbedtls_ecp_gen_privkey(grp, d, f_rng, p_rng)); - MBEDTLS_MPI_CHK(mbedtls_ecp_mul(grp, Q, d, G, f_rng, p_rng)); - -cleanup: - return (ret); -} - -/* - * Generate key pair, wrapper for conventional base point - */ -int mbedtls_ecp_gen_keypair(mbedtls_ecp_group * grp, mbedtls_mpi * d, mbedtls_ecp_point * Q, - int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) -{ - ECP_VALIDATE_RET(grp != NULL); - ECP_VALIDATE_RET(d != NULL); - ECP_VALIDATE_RET(Q != NULL); - ECP_VALIDATE_RET(f_rng != NULL); - - return (mbedtls_ecp_gen_keypair_base(grp, &grp->G, d, Q, f_rng, p_rng)); -} - -/* - * Generate a keypair, prettier wrapper - */ -int mbedtls_ecp_gen_key(mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair * key, int (*f_rng)(void *, unsigned char *, size_t), - void * p_rng) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - ECP_VALIDATE_RET(key != NULL); - ECP_VALIDATE_RET(f_rng != NULL); - - if ((ret = mbedtls_ecp_group_load(&key->grp, grp_id)) != 0) - return (ret); - - return (mbedtls_ecp_gen_keypair(&key->grp, &key->d, &key->Q, f_rng, p_rng)); -} - -#define ECP_CURVE25519_KEY_SIZE 32 -/* - * Read a private key. - */ -int mbedtls_ecp_read_key(mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair * key, const unsigned char * buf, size_t buflen) -{ - int ret = 0; - - ECP_VALIDATE_RET(key != NULL); - ECP_VALIDATE_RET(buf != NULL); - - if ((ret = mbedtls_ecp_group_load(&key->grp, grp_id)) != 0) - return (ret); - - ret = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE; - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) - if (mbedtls_ecp_get_type(&key->grp) == MBEDTLS_ECP_TYPE_MONTGOMERY) - { - /* - * If it is Curve25519 curve then mask the key as mandated by RFC7748 - */ - if (grp_id == MBEDTLS_ECP_DP_CURVE25519) - { - if (buflen != ECP_CURVE25519_KEY_SIZE) - return MBEDTLS_ERR_ECP_INVALID_KEY; - - MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary_le(&key->d, buf, buflen)); - - /* Set the three least significant bits to 0 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(&key->d, 0, 0)); - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(&key->d, 1, 0)); - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(&key->d, 2, 0)); - - /* Set the most significant bit to 0 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(&key->d, ECP_CURVE25519_KEY_SIZE * 8 - 1, 0)); - - /* Set the second most significant bit to 1 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(&key->d, ECP_CURVE25519_KEY_SIZE * 8 - 2, 1)); - } - else - ret = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE; - } - -#endif -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) - if (mbedtls_ecp_get_type(&key->grp) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS) - { - MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&key->d, buf, buflen)); - - MBEDTLS_MPI_CHK(mbedtls_ecp_check_privkey(&key->grp, &key->d)); - } - -#endif -cleanup: - - if (ret != 0) - mbedtls_mpi_free(&key->d); - - return (ret); -} - -/* - * Write a private key. - */ -int mbedtls_ecp_write_key(mbedtls_ecp_keypair * key, unsigned char * buf, size_t buflen) -{ - int ret = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE; - - ECP_VALIDATE_RET(key != NULL); - ECP_VALIDATE_RET(buf != NULL); - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) - if (mbedtls_ecp_get_type(&key->grp) == MBEDTLS_ECP_TYPE_MONTGOMERY) - { - if (key->grp.id == MBEDTLS_ECP_DP_CURVE25519) - { - if (buflen < ECP_CURVE25519_KEY_SIZE) - return MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL; - - MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary_le(&key->d, buf, buflen)); - } - else - ret = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE; - } - -#endif -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) - if (mbedtls_ecp_get_type(&key->grp) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS) - { - MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&key->d, buf, buflen)); - } - -#endif -cleanup: - - return (ret); -} - -/* - * Check a public-private key pair - */ -int mbedtls_ecp_check_pub_priv(const mbedtls_ecp_keypair * pub, const mbedtls_ecp_keypair * prv, - int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_ecp_point Q; - mbedtls_ecp_group grp; - ECP_VALIDATE_RET(pub != NULL); - ECP_VALIDATE_RET(prv != NULL); - - if (pub->grp.id == MBEDTLS_ECP_DP_NONE || pub->grp.id != prv->grp.id || mbedtls_mpi_cmp_mpi(&pub->Q.X, &prv->Q.X) || - mbedtls_mpi_cmp_mpi(&pub->Q.Y, &prv->Q.Y) || mbedtls_mpi_cmp_mpi(&pub->Q.Z, &prv->Q.Z)) - { - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - } - - mbedtls_ecp_point_init(&Q); - mbedtls_ecp_group_init(&grp); - - /* mbedtls_ecp_mul() needs a non-const group... */ - mbedtls_ecp_group_copy(&grp, &prv->grp); - - /* Also checks d is valid */ - MBEDTLS_MPI_CHK(mbedtls_ecp_mul(&grp, &Q, &prv->d, &prv->grp.G, f_rng, p_rng)); - - if (mbedtls_mpi_cmp_mpi(&Q.X, &prv->Q.X) || mbedtls_mpi_cmp_mpi(&Q.Y, &prv->Q.Y) || mbedtls_mpi_cmp_mpi(&Q.Z, &prv->Q.Z)) - { - ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; - goto cleanup; - } - -cleanup: - mbedtls_ecp_point_free(&Q); - mbedtls_ecp_group_free(&grp); - - return (ret); -} - -#if defined(MBEDTLS_SELF_TEST) - -/* - * PRNG for test - !!!INSECURE NEVER USE IN PRODUCTION!!! - * - * This is the linear congruential generator from numerical recipes, - * except we only use the low byte as the output. See - * https://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use - */ -static int self_test_rng(void * ctx, unsigned char * out, size_t len) -{ - static uint32_t state = 42; - - (void) ctx; - - for (size_t i = 0; i < len; i++) - { - state = state * 1664525u + 1013904223u; - out[i] = (unsigned char) state; - } - - return (0); -} - -/* Adjust the exponent to be a valid private point for the specified curve. - * This is sometimes necessary because we use a single set of exponents - * for all curves but the validity of values depends on the curve. */ -static int self_test_adjust_exponent(const mbedtls_ecp_group * grp, mbedtls_mpi * m) -{ - int ret = 0; - switch (grp->id) - { - /* If Curve25519 is available, then that's what we use for the - * Montgomery test, so we don't need the adjustment code. */ -#if !defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) -#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) - case MBEDTLS_ECP_DP_CURVE448: - /* Move highest bit from 254 to N-1. Setting bit N-1 is - * necessary to enforce the highest-bit-set constraint. */ - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(m, 254, 0)); - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(m, grp->nbits, 1)); - /* Copy second-highest bit from 253 to N-2. This is not - * necessary but improves the test variety a bit. */ - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(m, grp->nbits - 1, mbedtls_mpi_get_bit(m, 253))); - break; -#endif -#endif /* ! defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) */ - default: - /* Non-Montgomery curves and Curve25519 need no adjustment. */ - (void) grp; - (void) m; - goto cleanup; - } -cleanup: - return (ret); -} - -/* Calculate R = m.P for each m in exponents. Check that the number of - * basic operations doesn't depend on the value of m. */ -static int self_test_point(int verbose, mbedtls_ecp_group * grp, mbedtls_ecp_point * R, mbedtls_mpi * m, - const mbedtls_ecp_point * P, const char * const * exponents, size_t n_exponents) -{ - int ret = 0; - size_t i = 0; - unsigned long add_c_prev, dbl_c_prev, mul_c_prev; - add_count = 0; - dbl_count = 0; - mul_count = 0; - - MBEDTLS_MPI_CHK(mbedtls_mpi_read_string(m, 16, exponents[0])); - MBEDTLS_MPI_CHK(self_test_adjust_exponent(grp, m)); - MBEDTLS_MPI_CHK(mbedtls_ecp_mul(grp, R, m, P, self_test_rng, NULL)); - - for (i = 1; i < n_exponents; i++) - { - add_c_prev = add_count; - dbl_c_prev = dbl_count; - mul_c_prev = mul_count; - add_count = 0; - dbl_count = 0; - mul_count = 0; - - MBEDTLS_MPI_CHK(mbedtls_mpi_read_string(m, 16, exponents[i])); - MBEDTLS_MPI_CHK(self_test_adjust_exponent(grp, m)); - MBEDTLS_MPI_CHK(mbedtls_ecp_mul(grp, R, m, P, self_test_rng, NULL)); - - if (add_count != add_c_prev || dbl_count != dbl_c_prev || mul_count != mul_c_prev) - { - ret = 1; - break; - } - } - -cleanup: - if (verbose != 0) - { - if (ret != 0) - mbedtls_printf("failed (%u)\n", (unsigned int) i); - else - mbedtls_printf("passed\n"); - } - return (ret); -} - -/* - * Checkup routine - */ -int mbedtls_ecp_self_test(int verbose) -{ - if (__ecp_alt_b91_skip_internal_self_tests) - return ecp_alt_b91_backend_test(verbose); - - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_ecp_group grp; - mbedtls_ecp_point R, P; - mbedtls_mpi m; - -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) - /* Exponents especially adapted for secp192k1, which has the lowest - * order n of all supported curves (secp192r1 is in a slightly larger - * field but the order of its base point is slightly smaller). */ - const char * sw_exponents[] = { - "000000000000000000000000000000000000000000000001", /* one */ - "FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8C", /* n - 1 */ - "5EA6F389A38B8BC81E767753B15AA5569E1782E30ABE7D25", /* random */ - "400000000000000000000000000000000000000000000000", /* one and zeros */ - "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", /* all ones */ - "555555555555555555555555555555555555555555555555", /* 101010... */ - }; -#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) - const char * m_exponents[] = { - /* Valid private values for Curve25519. In a build with Curve448 - * but not Curve25519, they will be adjusted in - * self_test_adjust_exponent(). */ - "4000000000000000000000000000000000000000000000000000000000000000", - "5C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C30", - "5715ECCE24583F7A7023C24164390586842E816D7280A49EF6DF4EAE6B280BF8", - "41A2B017516F6D254E1F002BCCBADD54BE30F8CEC737A0E912B4963B6BA74460", - "5555555555555555555555555555555555555555555555555555555555555550", - "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8", - }; -#endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */ - - mbedtls_ecp_group_init(&grp); - mbedtls_ecp_point_init(&R); - mbedtls_ecp_point_init(&P); - mbedtls_mpi_init(&m); - -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) - /* Use secp192r1 if available, or any available curve */ -#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) - MBEDTLS_MPI_CHK(mbedtls_ecp_group_load(&grp, MBEDTLS_ECP_DP_SECP192R1)); -#else - MBEDTLS_MPI_CHK(mbedtls_ecp_group_load(&grp, mbedtls_ecp_curve_list()->grp_id)); -#endif - - if (verbose != 0) - mbedtls_printf(" ECP SW test #1 (constant op_count, base point G): "); - /* Do a dummy multiplication first to trigger precomputation */ - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&m, 2)); - MBEDTLS_MPI_CHK(mbedtls_ecp_mul(&grp, &P, &m, &grp.G, self_test_rng, NULL)); - ret = self_test_point(verbose, &grp, &R, &m, &grp.G, sw_exponents, sizeof(sw_exponents) / sizeof(sw_exponents[0])); - if (ret != 0) - goto cleanup; - - if (verbose != 0) - mbedtls_printf(" ECP SW test #2 (constant op_count, other point): "); - /* We computed P = 2G last time, use it */ - ret = self_test_point(verbose, &grp, &R, &m, &P, sw_exponents, sizeof(sw_exponents) / sizeof(sw_exponents[0])); - if (ret != 0) - goto cleanup; - - mbedtls_ecp_group_free(&grp); - mbedtls_ecp_point_free(&R); -#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) - if (verbose != 0) - mbedtls_printf(" ECP Montgomery test (constant op_count): "); -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) - MBEDTLS_MPI_CHK(mbedtls_ecp_group_load(&grp, MBEDTLS_ECP_DP_CURVE25519)); -#elif defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) - MBEDTLS_MPI_CHK(mbedtls_ecp_group_load(&grp, MBEDTLS_ECP_DP_CURVE448)); -#else -#error "MBEDTLS_ECP_MONTGOMERY_ENABLED is defined, but no curve is supported for self-test" -#endif - ret = self_test_point(verbose, &grp, &R, &m, &grp.G, m_exponents, sizeof(m_exponents) / sizeof(m_exponents[0])); - if (ret != 0) - goto cleanup; -#endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */ - -cleanup: - - if (ret < 0 && verbose != 0) - mbedtls_printf("Unexpected error, return code = %08X\n", (unsigned int) ret); - - mbedtls_ecp_group_free(&grp); - mbedtls_ecp_point_free(&R); - mbedtls_ecp_point_free(&P); - mbedtls_mpi_free(&m); - - if (verbose != 0) - mbedtls_printf("\n"); - - return (ret); -} - -#endif /* MBEDTLS_SELF_TEST */ - -#endif /* !MBEDTLS_ECP_ALT */ - -#endif /* MBEDTLS_ECP_C */ diff --git a/src/platform/telink/crypto/internal/compatibility/ecp_curves_alt.c b/src/platform/telink/crypto/internal/compatibility/ecp_curves_alt.c deleted file mode 100644 index eee2275b019de5..00000000000000 --- a/src/platform/telink/crypto/internal/compatibility/ecp_curves_alt.c +++ /dev/null @@ -1,5490 +0,0 @@ -/* - * Elliptic curves over GF(p): curve-specific data and functions - * - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -#include "../common.h" - -#if defined(MBEDTLS_ECP_C) - -#include "mbedtls/ecp.h" -#include "mbedtls/error.h" -#include "mbedtls/platform_util.h" - -#include "bn_mul.h" -#include "ecp_invasive.h" - -#include - -#if defined(MBEDTLS_ECP_ALT) - -/* Parameter validation macros based on platform_util.h */ -#define ECP_VALIDATE_RET(cond) MBEDTLS_INTERNAL_VALIDATE_RET(cond, MBEDTLS_ERR_ECP_BAD_INPUT_DATA) -#define ECP_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE(cond) - -#if (defined(__ARMCC_VERSION) || defined(_MSC_VER)) && !defined(inline) && !defined(__cplusplus) -#define inline __inline -#endif - -#define ECP_MPI_INIT(s, n, p) \ - { \ - s, (n), (mbedtls_mpi_uint *) (p) \ - } - -#define ECP_MPI_INIT_ARRAY(x) ECP_MPI_INIT(1, sizeof(x) / sizeof(mbedtls_mpi_uint), x) - -#define ECP_POINT_INIT_XY_Z0(x, y) \ - { \ - ECP_MPI_INIT_ARRAY(x), ECP_MPI_INIT_ARRAY(y), ECP_MPI_INIT(1, 0, NULL) \ - } -#define ECP_POINT_INIT_XY_Z1(x, y) \ - { \ - ECP_MPI_INIT_ARRAY(x), ECP_MPI_INIT_ARRAY(y), ECP_MPI_INIT(1, 1, mpi_one) \ - } - -#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) || defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) || \ - defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) || \ - defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) || defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) || \ - defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) || defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) || \ - defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) || defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) || \ - defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) -/* For these curves, we build the group parameters dynamically. */ -#define ECP_LOAD_GROUP -static mbedtls_mpi_uint mpi_one[] = { 1 }; -#endif - -/* - * Note: the constants are in little-endian order - * to be directly usable in MPIs - */ - -/* - * Domain parameters for secp192r1 - */ -#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) -static const mbedtls_mpi_uint secp192r1_p[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), -}; -static const mbedtls_mpi_uint secp192r1_b[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB1, 0xB9, 0x46, 0xC1, 0xEC, 0xDE, 0xB8, 0xFE), - MBEDTLS_BYTES_TO_T_UINT_8(0x49, 0x30, 0x24, 0x72, 0xAB, 0xE9, 0xA7, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0xE7, 0x80, 0x9C, 0xE5, 0x19, 0x05, 0x21, 0x64), -}; -static const mbedtls_mpi_uint secp192r1_gx[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x12, 0x10, 0xFF, 0x82, 0xFD, 0x0A, 0xFF, 0xF4), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x88, 0xA1, 0x43, 0xEB, 0x20, 0xBF, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0xF6, 0x90, 0x30, 0xB0, 0x0E, 0xA8, 0x8D, 0x18), -}; -static const mbedtls_mpi_uint secp192r1_gy[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0x48, 0x79, 0x1E, 0xA1, 0x77, 0xF9, 0x73), - MBEDTLS_BYTES_TO_T_UINT_8(0xD5, 0xCD, 0x24, 0x6B, 0xED, 0x11, 0x10, 0x63), - MBEDTLS_BYTES_TO_T_UINT_8(0x78, 0xDA, 0xC8, 0xFF, 0x95, 0x2B, 0x19, 0x07), -}; -static const mbedtls_mpi_uint secp192r1_n[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x31, 0x28, 0xD2, 0xB4, 0xB1, 0xC9, 0x6B, 0x14), - MBEDTLS_BYTES_TO_T_UINT_8(0x36, 0xF8, 0xDE, 0x99, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), -}; -#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 -static const mbedtls_mpi_uint secp192r1_T_0_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x12, 0x10, 0xFF, 0x82, 0xFD, 0x0A, 0xFF, 0xF4), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x88, 0xA1, 0x43, 0xEB, 0x20, 0xBF, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0xF6, 0x90, 0x30, 0xB0, 0x0E, 0xA8, 0x8D, 0x18), -}; -static const mbedtls_mpi_uint secp192r1_T_0_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0x48, 0x79, 0x1E, 0xA1, 0x77, 0xF9, 0x73), - MBEDTLS_BYTES_TO_T_UINT_8(0xD5, 0xCD, 0x24, 0x6B, 0xED, 0x11, 0x10, 0x63), - MBEDTLS_BYTES_TO_T_UINT_8(0x78, 0xDA, 0xC8, 0xFF, 0x95, 0x2B, 0x19, 0x07), -}; -static const mbedtls_mpi_uint secp192r1_T_1_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x97, 0x9E, 0xE3, 0x60, 0x59, 0xD1, 0xC4, 0xC2), - MBEDTLS_BYTES_TO_T_UINT_8(0x91, 0xBD, 0x22, 0xD7, 0x2D, 0x07, 0xBD, 0xB6), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0x2A, 0xCF, 0x33, 0xF0, 0xBE, 0xD1, 0xED), -}; -static const mbedtls_mpi_uint secp192r1_T_1_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x88, 0x71, 0x4B, 0xA8, 0xED, 0x7E, 0xC9, 0x1A), - MBEDTLS_BYTES_TO_T_UINT_8(0x8E, 0x2A, 0xF6, 0xDF, 0x0E, 0xE8, 0x4C, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0xC5, 0x35, 0xF7, 0x8A, 0xC3, 0xEC, 0xDE, 0x1E), -}; -static const mbedtls_mpi_uint secp192r1_T_2_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x67, 0xC2, 0x1D, 0x32, 0x8F, 0x10, 0xFB), - MBEDTLS_BYTES_TO_T_UINT_8(0xBB, 0x2D, 0x17, 0xF3, 0xE4, 0xFE, 0xD8, 0x13), - MBEDTLS_BYTES_TO_T_UINT_8(0x55, 0x45, 0x10, 0x70, 0x2C, 0x3E, 0x52, 0x3E), -}; -static const mbedtls_mpi_uint secp192r1_T_2_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0xF1, 0x04, 0x5D, 0xEE, 0xD4, 0x56, 0xE6), - MBEDTLS_BYTES_TO_T_UINT_8(0x78, 0xB7, 0x38, 0x27, 0x61, 0xAA, 0x81, 0x87), - MBEDTLS_BYTES_TO_T_UINT_8(0x71, 0x37, 0xD7, 0x0E, 0x29, 0x0E, 0x11, 0x14), -}; -static const mbedtls_mpi_uint secp192r1_T_3_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0x35, 0x52, 0xC6, 0x31, 0xB7, 0x27, 0xF5), - MBEDTLS_BYTES_TO_T_UINT_8(0x3D, 0xD4, 0x15, 0x98, 0x0F, 0xE7, 0xF3, 0x6A), - MBEDTLS_BYTES_TO_T_UINT_8(0xD3, 0x31, 0x70, 0x35, 0x09, 0xA0, 0x2B, 0xC2), -}; -static const mbedtls_mpi_uint secp192r1_T_3_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0x75, 0xA7, 0x4C, 0x88, 0xCF, 0x5B, 0xE4), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0x17, 0x48, 0x8D, 0xF2, 0xF0, 0x86, 0xED), - MBEDTLS_BYTES_TO_T_UINT_8(0x49, 0xCF, 0xFE, 0x6B, 0xB0, 0xA5, 0x06, 0xAB), -}; -static const mbedtls_mpi_uint secp192r1_T_4_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x18, 0x6A, 0xDC, 0x9A, 0x6D, 0x7B, 0x47, 0x2E), - MBEDTLS_BYTES_TO_T_UINT_8(0x12, 0xFC, 0x51, 0x12, 0x62, 0x66, 0x0B, 0x59), - MBEDTLS_BYTES_TO_T_UINT_8(0xCD, 0x40, 0x93, 0xA0, 0xB5, 0x5A, 0x58, 0xD7), -}; -static const mbedtls_mpi_uint secp192r1_T_4_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xEF, 0xCB, 0xAF, 0xDC, 0x0B, 0xA1, 0x26, 0xFB), - MBEDTLS_BYTES_TO_T_UINT_8(0xDA, 0x36, 0x9D, 0xA3, 0xD7, 0x3B, 0xAD, 0x39), - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0x3B, 0x05, 0x9A, 0xA8, 0xAA, 0x69, 0xB2), -}; -static const mbedtls_mpi_uint secp192r1_T_5_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0xD9, 0xD1, 0x4D, 0x4A, 0x6E, 0x96, 0x1E), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0x66, 0x32, 0x39, 0xC6, 0x57, 0x7D, 0xE6), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0xA0, 0x36, 0xC2, 0x45, 0xF9, 0x00, 0x62), -}; -static const mbedtls_mpi_uint secp192r1_T_5_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0xEF, 0x59, 0x46, 0xDC, 0x60, 0xD9, 0x8F), - MBEDTLS_BYTES_TO_T_UINT_8(0x24, 0xB0, 0xE9, 0x41, 0xA4, 0x87, 0x76, 0x89), - MBEDTLS_BYTES_TO_T_UINT_8(0x13, 0xD4, 0x0E, 0xB2, 0xFA, 0x16, 0x56, 0xDC), -}; -static const mbedtls_mpi_uint secp192r1_T_6_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x0A, 0x62, 0xD2, 0xB1, 0x34, 0xB2, 0xF1, 0x06), - MBEDTLS_BYTES_TO_T_UINT_8(0xB2, 0xED, 0x55, 0xC5, 0x47, 0xB5, 0x07, 0x15), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0xF6, 0x2F, 0x94, 0xC3, 0xDD, 0x54, 0x2F), -}; -static const mbedtls_mpi_uint secp192r1_T_6_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFD, 0xA6, 0xD4, 0x8C, 0xA9, 0xCE, 0x4D, 0x2E), - MBEDTLS_BYTES_TO_T_UINT_8(0xB9, 0x4B, 0x46, 0xCC, 0xB2, 0x55, 0xC8, 0xB2), - MBEDTLS_BYTES_TO_T_UINT_8(0x3A, 0xAE, 0x31, 0xED, 0x89, 0x65, 0x59, 0x55), -}; -static const mbedtls_mpi_uint secp192r1_T_7_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCC, 0x0A, 0xD1, 0x1A, 0xC5, 0xF6, 0xEA, 0x43), - MBEDTLS_BYTES_TO_T_UINT_8(0x0C, 0xFC, 0x0C, 0x1A, 0xFB, 0xA0, 0xC8, 0x70), - MBEDTLS_BYTES_TO_T_UINT_8(0xEA, 0xFD, 0x53, 0x6F, 0x6D, 0xBF, 0xBA, 0xAF), -}; -static const mbedtls_mpi_uint secp192r1_T_7_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x2D, 0xB0, 0x7D, 0x83, 0x96, 0xE3, 0xCB, 0x9D), - MBEDTLS_BYTES_TO_T_UINT_8(0x6F, 0x6E, 0x55, 0x2C, 0x20, 0x53, 0x2F, 0x46), - MBEDTLS_BYTES_TO_T_UINT_8(0xA6, 0x66, 0x00, 0x17, 0x08, 0xFE, 0xAC, 0x31), -}; -static const mbedtls_mpi_uint secp192r1_T_8_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x09, 0x12, 0x97, 0x3A, 0xC7, 0x57, 0x45, 0xCD), - MBEDTLS_BYTES_TO_T_UINT_8(0x38, 0x25, 0x99, 0x00, 0xF6, 0x97, 0xB4, 0x64), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0x74, 0xE6, 0xE6, 0xA3, 0xDF, 0x9C, 0xCC), -}; -static const mbedtls_mpi_uint secp192r1_T_8_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x32, 0xF4, 0x76, 0xD5, 0x5F, 0x2A, 0xFD, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0x62, 0x80, 0x7E, 0x3E, 0xE5, 0xE8, 0xD6, 0x63), - MBEDTLS_BYTES_TO_T_UINT_8(0xE2, 0xAD, 0x1E, 0x70, 0x79, 0x3E, 0x3D, 0x83), -}; -static const mbedtls_mpi_uint secp192r1_T_9_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x8E, 0x15, 0xBB, 0xB3, 0x42, 0x6A, 0xA1, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0x58, 0xCB, 0x43, 0x25, 0x00, 0x14, 0x68), - MBEDTLS_BYTES_TO_T_UINT_8(0x06, 0x4E, 0x93, 0x11, 0xE0, 0x32, 0x54, 0x98), -}; -static const mbedtls_mpi_uint secp192r1_T_9_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0x52, 0xA2, 0xB4, 0x57, 0x32, 0xB9, 0x11), - MBEDTLS_BYTES_TO_T_UINT_8(0x7D, 0x43, 0xA1, 0xB1, 0xFB, 0x01, 0xE1, 0xE7), - MBEDTLS_BYTES_TO_T_UINT_8(0xA6, 0xFB, 0x5A, 0x11, 0xB8, 0xC2, 0x03, 0xE5), -}; -static const mbedtls_mpi_uint secp192r1_T_10_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0x2B, 0x71, 0x26, 0x4E, 0x7C, 0xC5, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0x1F, 0xF5, 0xD3, 0xA8, 0xE4, 0x95, 0x48, 0x65), - MBEDTLS_BYTES_TO_T_UINT_8(0x55, 0xAE, 0xD9, 0x5D, 0x9F, 0x6A, 0x22, 0xAD), -}; -static const mbedtls_mpi_uint secp192r1_T_10_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0xCC, 0xA3, 0x4D, 0xA0, 0x1C, 0x34, 0xEF), - MBEDTLS_BYTES_TO_T_UINT_8(0xA3, 0x3C, 0x62, 0xF8, 0x5E, 0xA6, 0x58, 0x7D), - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0x6E, 0x66, 0x8A, 0x3D, 0x17, 0xFF, 0x0F), -}; -static const mbedtls_mpi_uint secp192r1_T_11_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF7, 0xCD, 0xA8, 0xDD, 0xD1, 0x20, 0x5C, 0xEA), - MBEDTLS_BYTES_TO_T_UINT_8(0xBF, 0xFE, 0x17, 0xE2, 0xCF, 0xEA, 0x63, 0xDE), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0x51, 0xC9, 0x16, 0xDE, 0xB4, 0xB2, 0xDD), -}; -static const mbedtls_mpi_uint secp192r1_T_11_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0xBE, 0x12, 0xD7, 0xA3, 0x0A, 0x50, 0x33), - MBEDTLS_BYTES_TO_T_UINT_8(0x53, 0x87, 0xC5, 0x8A, 0x76, 0x57, 0x07, 0x60), - MBEDTLS_BYTES_TO_T_UINT_8(0xE5, 0x1F, 0xC6, 0x1B, 0x66, 0xC4, 0x3D, 0x8A), -}; -static const mbedtls_mpi_uint secp192r1_T_12_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0xA4, 0x85, 0x13, 0x8F, 0xA7, 0x35, 0x19), - MBEDTLS_BYTES_TO_T_UINT_8(0x58, 0x0D, 0xFD, 0xFF, 0x1B, 0xD1, 0xD6, 0xEF), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0x7A, 0xD0, 0xC3, 0xB4, 0xEF, 0x39, 0x66), -}; -static const mbedtls_mpi_uint secp192r1_T_12_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x3A, 0xFE, 0xA5, 0x9C, 0x34, 0x30, 0x49, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0xDE, 0xC5, 0x39, 0x26, 0x06, 0xE3, 0x01, 0x17), - MBEDTLS_BYTES_TO_T_UINT_8(0xE2, 0x2B, 0x66, 0xFC, 0x95, 0x5F, 0x35, 0xF7), -}; -static const mbedtls_mpi_uint secp192r1_T_13_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x58, 0xCF, 0x54, 0x63, 0x99, 0x57, 0x05, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0x71, 0x6F, 0x00, 0x5F, 0x65, 0x08, 0x47, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0x62, 0x2A, 0x90, 0x6D, 0x67, 0xC6, 0xBC, 0x45), -}; -static const mbedtls_mpi_uint secp192r1_T_13_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x8A, 0x4D, 0x88, 0x0A, 0x35, 0x9E, 0x33, 0x9C), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0x17, 0x0C, 0xF8, 0xE1, 0x7A, 0x49, 0x02), - MBEDTLS_BYTES_TO_T_UINT_8(0xA4, 0x44, 0x06, 0x8F, 0x0B, 0x70, 0x2F, 0x71), -}; -static const mbedtls_mpi_uint secp192r1_T_14_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x85, 0x4B, 0xCB, 0xF9, 0x8E, 0x6A, 0xDA, 0x1B), - MBEDTLS_BYTES_TO_T_UINT_8(0x29, 0x43, 0xA1, 0x3F, 0xCE, 0x17, 0xD2, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0x0D, 0xD2, 0x6C, 0x82, 0x37, 0xE5, 0xFC), -}; -static const mbedtls_mpi_uint secp192r1_T_14_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x4A, 0x3C, 0xF4, 0x92, 0xB4, 0x8A, 0x95, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0x85, 0x96, 0xF1, 0x0A, 0x34, 0x2F, 0x74, 0x7E), - MBEDTLS_BYTES_TO_T_UINT_8(0x7B, 0xA1, 0xAA, 0xBA, 0x86, 0x77, 0x4F, 0xA2), -}; -static const mbedtls_mpi_uint secp192r1_T_15_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xE5, 0x7F, 0xEF, 0x60, 0x50, 0x80, 0xD7, 0xD4), - MBEDTLS_BYTES_TO_T_UINT_8(0x31, 0xAC, 0xC9, 0xFE, 0xEC, 0x0A, 0x1A, 0x9F), - MBEDTLS_BYTES_TO_T_UINT_8(0x6B, 0x2F, 0xBE, 0x91, 0xD7, 0xB7, 0x38, 0x48), -}; -static const mbedtls_mpi_uint secp192r1_T_15_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB1, 0xAE, 0x85, 0x98, 0xFE, 0x05, 0x7F, 0x9F), - MBEDTLS_BYTES_TO_T_UINT_8(0x91, 0xBE, 0xFD, 0x11, 0x31, 0x3D, 0x14, 0x13), - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0x75, 0xE8, 0x30, 0x01, 0xCB, 0x9B, 0x1C), -}; -static const mbedtls_ecp_point secp192r1_T[16] = { - ECP_POINT_INIT_XY_Z1(secp192r1_T_0_X, secp192r1_T_0_Y), ECP_POINT_INIT_XY_Z0(secp192r1_T_1_X, secp192r1_T_1_Y), - ECP_POINT_INIT_XY_Z0(secp192r1_T_2_X, secp192r1_T_2_Y), ECP_POINT_INIT_XY_Z0(secp192r1_T_3_X, secp192r1_T_3_Y), - ECP_POINT_INIT_XY_Z0(secp192r1_T_4_X, secp192r1_T_4_Y), ECP_POINT_INIT_XY_Z0(secp192r1_T_5_X, secp192r1_T_5_Y), - ECP_POINT_INIT_XY_Z0(secp192r1_T_6_X, secp192r1_T_6_Y), ECP_POINT_INIT_XY_Z0(secp192r1_T_7_X, secp192r1_T_7_Y), - ECP_POINT_INIT_XY_Z0(secp192r1_T_8_X, secp192r1_T_8_Y), ECP_POINT_INIT_XY_Z0(secp192r1_T_9_X, secp192r1_T_9_Y), - ECP_POINT_INIT_XY_Z0(secp192r1_T_10_X, secp192r1_T_10_Y), ECP_POINT_INIT_XY_Z0(secp192r1_T_11_X, secp192r1_T_11_Y), - ECP_POINT_INIT_XY_Z0(secp192r1_T_12_X, secp192r1_T_12_Y), ECP_POINT_INIT_XY_Z0(secp192r1_T_13_X, secp192r1_T_13_Y), - ECP_POINT_INIT_XY_Z0(secp192r1_T_14_X, secp192r1_T_14_Y), ECP_POINT_INIT_XY_Z0(secp192r1_T_15_X, secp192r1_T_15_Y), -}; -#else -#define secp192r1_T NULL -#endif -#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ - -/* - * Domain parameters for secp224r1 - */ -#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) -static const mbedtls_mpi_uint secp224r1_p[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_b[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0xFF, 0x55, 0x23, 0x43, 0x39, 0x0B, 0x27), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0xD8, 0xBF, 0xD7, 0xB7, 0xB0, 0x44, 0x50), - MBEDTLS_BYTES_TO_T_UINT_8(0x56, 0x32, 0x41, 0xF5, 0xAB, 0xB3, 0x04, 0x0C), - MBEDTLS_BYTES_TO_T_UINT_4(0x85, 0x0A, 0x05, 0xB4), -}; -static const mbedtls_mpi_uint secp224r1_gx[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0x1D, 0x5C, 0x11, 0xD6, 0x80, 0x32, 0x34), - MBEDTLS_BYTES_TO_T_UINT_8(0x22, 0x11, 0xC2, 0x56, 0xD3, 0xC1, 0x03, 0x4A), - MBEDTLS_BYTES_TO_T_UINT_8(0xB9, 0x90, 0x13, 0x32, 0x7F, 0xBF, 0xB4, 0x6B), - MBEDTLS_BYTES_TO_T_UINT_4(0xBD, 0x0C, 0x0E, 0xB7), -}; -static const mbedtls_mpi_uint secp224r1_gy[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0x7E, 0x00, 0x85, 0x99, 0x81, 0xD5, 0x44), - MBEDTLS_BYTES_TO_T_UINT_8(0x64, 0x47, 0x07, 0x5A, 0xA0, 0x75, 0x43, 0xCD), - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0xDF, 0x22, 0x4C, 0xFB, 0x23, 0xF7, 0xB5), - MBEDTLS_BYTES_TO_T_UINT_4(0x88, 0x63, 0x37, 0xBD), -}; -static const mbedtls_mpi_uint secp224r1_n[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x3D, 0x2A, 0x5C, 0x5C, 0x45, 0x29, 0xDD, 0x13), - MBEDTLS_BYTES_TO_T_UINT_8(0x3E, 0xF0, 0xB8, 0xE0, 0xA2, 0x16, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_4(0xFF, 0xFF, 0xFF, 0xFF), -}; -#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 -static const mbedtls_mpi_uint secp224r1_T_0_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0x1D, 0x5C, 0x11, 0xD6, 0x80, 0x32, 0x34), - MBEDTLS_BYTES_TO_T_UINT_8(0x22, 0x11, 0xC2, 0x56, 0xD3, 0xC1, 0x03, 0x4A), - MBEDTLS_BYTES_TO_T_UINT_8(0xB9, 0x90, 0x13, 0x32, 0x7F, 0xBF, 0xB4, 0x6B), - MBEDTLS_BYTES_TO_T_UINT_8(0xBD, 0x0C, 0x0E, 0xB7, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_0_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0x7E, 0x00, 0x85, 0x99, 0x81, 0xD5, 0x44), - MBEDTLS_BYTES_TO_T_UINT_8(0x64, 0x47, 0x07, 0x5A, 0xA0, 0x75, 0x43, 0xCD), - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0xDF, 0x22, 0x4C, 0xFB, 0x23, 0xF7, 0xB5), - MBEDTLS_BYTES_TO_T_UINT_8(0x88, 0x63, 0x37, 0xBD, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_1_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xE0, 0xF9, 0xB8, 0xD0, 0x3D, 0xD2, 0xD3, 0xFA), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0xFD, 0x99, 0x26, 0x19, 0xFE, 0x13, 0x6E), - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0x0E, 0x4C, 0x48, 0x7C, 0xA2, 0x17, 0x01), - MBEDTLS_BYTES_TO_T_UINT_8(0x3D, 0xA3, 0x13, 0x57, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_1_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x9F, 0x16, 0x5C, 0x8F, 0xAA, 0xED, 0x0F, 0x58), - MBEDTLS_BYTES_TO_T_UINT_8(0xBF, 0xC5, 0x43, 0x34, 0x93, 0x05, 0x2A, 0x4C), - MBEDTLS_BYTES_TO_T_UINT_8(0xE4, 0xE3, 0x6C, 0xCA, 0xC6, 0x14, 0xC2, 0x25), - MBEDTLS_BYTES_TO_T_UINT_8(0xD3, 0x43, 0x6C, 0xD7, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_2_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC3, 0x5A, 0x98, 0x1E, 0xC8, 0xA5, 0x42, 0xA3), - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0x49, 0x56, 0x78, 0xF8, 0xEF, 0xED, 0x65), - MBEDTLS_BYTES_TO_T_UINT_8(0x1B, 0xBB, 0x64, 0xB6, 0x4C, 0x54, 0x5F, 0xD1), - MBEDTLS_BYTES_TO_T_UINT_8(0x2F, 0x0C, 0x33, 0xCC, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_2_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0x79, 0xCB, 0x2E, 0x08, 0xFF, 0xD8, 0xE6), - MBEDTLS_BYTES_TO_T_UINT_8(0x2E, 0x1F, 0xD4, 0xD7, 0x57, 0xE9, 0x39, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0xD8, 0xD6, 0x3B, 0x0A, 0x1C, 0x87, 0xB7, 0x6A), - MBEDTLS_BYTES_TO_T_UINT_8(0xEB, 0x30, 0xD8, 0x05, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_3_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0x79, 0x74, 0x9A, 0xE6, 0xBB, 0xC2, 0xC2), - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0x5B, 0xA6, 0x67, 0xC1, 0x91, 0xE7, 0x64), - MBEDTLS_BYTES_TO_T_UINT_8(0xF0, 0xDF, 0x38, 0x82, 0x19, 0x2C, 0x4C, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0xD1, 0x2E, 0x39, 0xC5, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_3_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0x36, 0x78, 0x4E, 0xAE, 0x5B, 0x02, 0x76), - MBEDTLS_BYTES_TO_T_UINT_8(0x14, 0xF6, 0x8B, 0xF8, 0xF4, 0x92, 0x6B, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0x4D, 0x71, 0x35, 0xE7, 0x0C, 0x2C, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0xA5, 0x1F, 0xAE, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_4_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xAF, 0x1C, 0x4B, 0xDF, 0x5B, 0xF2, 0x51, 0xB7), - MBEDTLS_BYTES_TO_T_UINT_8(0x05, 0x74, 0xB1, 0x5A, 0xC6, 0x0F, 0x0E, 0x61), - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0x24, 0x09, 0x62, 0xAF, 0xFC, 0xDB, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0x43, 0xE1, 0x80, 0x55, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_4_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x3C, 0x82, 0xFE, 0xAD, 0xC3, 0xE5, 0xCF, 0xD8), - MBEDTLS_BYTES_TO_T_UINT_8(0x24, 0xA2, 0x62, 0x17, 0x76, 0xF0, 0x5A, 0xFA), - MBEDTLS_BYTES_TO_T_UINT_8(0x3E, 0xB8, 0xE5, 0xAC, 0xB7, 0x66, 0x38, 0xAA), - MBEDTLS_BYTES_TO_T_UINT_8(0x97, 0xFD, 0x86, 0x05, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_5_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0xD3, 0x0C, 0x3C, 0xD1, 0x66, 0xB0, 0xF1), - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0x59, 0xB4, 0x8D, 0x90, 0x10, 0xB7, 0xA2), - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0x47, 0x9B, 0xE6, 0x55, 0x8A, 0xE4, 0xEE), - MBEDTLS_BYTES_TO_T_UINT_8(0xB1, 0x49, 0xDB, 0x78, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_5_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x41, 0x97, 0xED, 0xDE, 0xFF, 0xB3, 0xDF, 0x48), - MBEDTLS_BYTES_TO_T_UINT_8(0x10, 0xB9, 0x83, 0xB7, 0xEB, 0xBE, 0x40, 0x8D), - MBEDTLS_BYTES_TO_T_UINT_8(0xAF, 0xD3, 0xD3, 0xCD, 0x0E, 0x82, 0x79, 0x3D), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0x83, 0x1B, 0xF0, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_6_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x3F, 0x22, 0xBB, 0x54, 0xD3, 0x31, 0x56, 0xFC), - MBEDTLS_BYTES_TO_T_UINT_8(0x80, 0x36, 0xE5, 0xE0, 0x89, 0x96, 0x8E, 0x71), - MBEDTLS_BYTES_TO_T_UINT_8(0xE1, 0xEF, 0x0A, 0xED, 0xD0, 0x11, 0x4A, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x00, 0x57, 0x27, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_6_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x13, 0xCA, 0x3D, 0xF7, 0x64, 0x9B, 0x6E, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0x90, 0xE3, 0x70, 0x6B, 0x41, 0xD7, 0xED, 0x8F), - MBEDTLS_BYTES_TO_T_UINT_8(0x02, 0x44, 0x44, 0x80, 0xCE, 0x13, 0x37, 0x92), - MBEDTLS_BYTES_TO_T_UINT_8(0x94, 0x73, 0x80, 0x79, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_7_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0x4D, 0x70, 0x7D, 0x31, 0x0F, 0x1C, 0x58), - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0x35, 0x88, 0x47, 0xC4, 0x24, 0x78, 0x3F), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0xF0, 0xCD, 0x91, 0x81, 0xB3, 0xDE, 0xB6), - MBEDTLS_BYTES_TO_T_UINT_8(0x04, 0xCE, 0xC6, 0xF7, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_7_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xE9, 0x9C, 0x2D, 0xE8, 0xD2, 0x00, 0x8F, 0x10), - MBEDTLS_BYTES_TO_T_UINT_8(0xD5, 0x5E, 0x7C, 0x0E, 0x0C, 0x6E, 0x58, 0x02), - MBEDTLS_BYTES_TO_T_UINT_8(0xAE, 0x81, 0x21, 0xCE, 0x43, 0xF4, 0x24, 0x3D), - MBEDTLS_BYTES_TO_T_UINT_8(0x9E, 0xBC, 0xF0, 0xF4, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_8_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0x10, 0xC2, 0x74, 0x4A, 0x8F, 0x8A, 0xCF), - MBEDTLS_BYTES_TO_T_UINT_8(0x89, 0x67, 0xF4, 0x2B, 0x38, 0x2B, 0x35, 0x17), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0xE7, 0x0C, 0xA9, 0xFA, 0x77, 0x5C, 0xBD), - MBEDTLS_BYTES_TO_T_UINT_8(0xE0, 0x33, 0x19, 0x2B, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_8_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xE7, 0x3E, 0x96, 0x22, 0x53, 0xE1, 0xE9, 0xBE), - MBEDTLS_BYTES_TO_T_UINT_8(0xE0, 0x13, 0xBC, 0xA1, 0x16, 0xEC, 0x01, 0x1A), - MBEDTLS_BYTES_TO_T_UINT_8(0x9A, 0x00, 0xC9, 0x7A, 0xC3, 0x73, 0xA5, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0xE1, 0xF4, 0x5E, 0xC1, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_9_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA8, 0x95, 0xD6, 0xD9, 0x32, 0x30, 0x2B, 0xD0), - MBEDTLS_BYTES_TO_T_UINT_8(0x77, 0x42, 0x09, 0x05, 0x61, 0x2A, 0x7E, 0x82), - MBEDTLS_BYTES_TO_T_UINT_8(0x73, 0x84, 0xA2, 0x05, 0x88, 0x64, 0x65, 0xF9), - MBEDTLS_BYTES_TO_T_UINT_8(0x03, 0x2D, 0x90, 0xB3, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_9_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x0A, 0xE7, 0x2E, 0x85, 0x55, 0x80, 0x7C, 0x79), - MBEDTLS_BYTES_TO_T_UINT_8(0x0F, 0xC1, 0xAC, 0x78, 0xB4, 0xAF, 0xFB, 0x6E), - MBEDTLS_BYTES_TO_T_UINT_8(0xD3, 0xC3, 0x28, 0x8E, 0x79, 0x18, 0x1F, 0x58), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0x46, 0xCF, 0x49, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_10_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x63, 0x5F, 0xA8, 0x6C, 0x46, 0x83, 0x43, 0xFA), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0xA9, 0x93, 0x11, 0xB6, 0x07, 0x57, 0x74), - MBEDTLS_BYTES_TO_T_UINT_8(0x77, 0x2A, 0x9D, 0x03, 0x89, 0x7E, 0xD7, 0x3C), - MBEDTLS_BYTES_TO_T_UINT_8(0x7B, 0x8C, 0x62, 0xCF, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_10_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x44, 0x2C, 0x13, 0x59, 0xCC, 0xFA, 0x84, 0x9E), - MBEDTLS_BYTES_TO_T_UINT_8(0x51, 0xB9, 0x48, 0xBC, 0x57, 0xC7, 0xB3, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0x0A, 0x38, 0x24, 0x2E, 0x3A, 0x28, 0x25), - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0x0A, 0x43, 0xB8, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_11_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0x25, 0xAB, 0xC1, 0xEE, 0x70, 0x3C, 0xE1), - MBEDTLS_BYTES_TO_T_UINT_8(0xF3, 0xDB, 0x45, 0x1D, 0x4A, 0x80, 0x75, 0x35), - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0x1F, 0x4D, 0x2D, 0x9A, 0x05, 0xF4, 0xCB), - MBEDTLS_BYTES_TO_T_UINT_8(0x6B, 0x10, 0xF0, 0x5A, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_11_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x35, 0x95, 0xE1, 0xDC, 0x15, 0x86, 0xC3, 0x7B), - MBEDTLS_BYTES_TO_T_UINT_8(0xEC, 0xDC, 0x27, 0xD1, 0x56, 0xA1, 0x14, 0x0D), - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0x0B, 0xD6, 0x77, 0x4E, 0x44, 0xA2, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0x94, 0x42, 0x71, 0x1F, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_12_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x30, 0x86, 0xB2, 0xB0, 0xC8, 0x2F, 0x7B, 0xFE), - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0xEF, 0xCB, 0xDB, 0xBC, 0x9E, 0x3B, 0xC5), - MBEDTLS_BYTES_TO_T_UINT_8(0x1B, 0x03, 0x86, 0xDD, 0x5B, 0xF5, 0x8D, 0x46), - MBEDTLS_BYTES_TO_T_UINT_8(0x58, 0x95, 0x79, 0xD6, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_12_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x84, 0x32, 0x14, 0xDA, 0x9B, 0x4F, 0x07, 0x39), - MBEDTLS_BYTES_TO_T_UINT_8(0xB5, 0x3E, 0xFB, 0x06, 0xEE, 0xA7, 0x40, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0x76, 0x1F, 0xDF, 0x71, 0x61, 0xFD, 0x8B, 0xBE), - MBEDTLS_BYTES_TO_T_UINT_8(0x80, 0x8B, 0xAB, 0x8B, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_13_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x34, 0xB3, 0xB4, 0xBC, 0x9F, 0xB0, 0x5E), - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0x58, 0x48, 0xA8, 0x77, 0xBB, 0x13, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0x41, 0xC6, 0xF7, 0x34, 0xCC, 0x89, 0x21, 0x0A), - MBEDTLS_BYTES_TO_T_UINT_8(0xCA, 0x33, 0xDD, 0x1F, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_13_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCC, 0x81, 0xEF, 0xA4, 0xF2, 0x10, 0x0B, 0xCD), - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0xF7, 0x6E, 0x72, 0x4A, 0xDF, 0xDD, 0xE8), - MBEDTLS_BYTES_TO_T_UINT_8(0x67, 0x23, 0x0A, 0x53, 0x03, 0x16, 0x62, 0xD2), - MBEDTLS_BYTES_TO_T_UINT_8(0x0B, 0x76, 0xFD, 0x3C, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_14_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCB, 0x14, 0xA1, 0xFA, 0xA0, 0x18, 0xBE, 0x07), - MBEDTLS_BYTES_TO_T_UINT_8(0x03, 0x2A, 0xE1, 0xD7, 0xB0, 0x6C, 0xA0, 0xDE), - MBEDTLS_BYTES_TO_T_UINT_8(0xD1, 0xC0, 0xB0, 0xC6, 0x63, 0x24, 0xCD, 0x4E), - MBEDTLS_BYTES_TO_T_UINT_8(0x33, 0x38, 0x2C, 0xB1, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_14_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xEE, 0xCD, 0x7D, 0x20, 0x0C, 0xFE, 0xAC, 0xC3), - MBEDTLS_BYTES_TO_T_UINT_8(0x09, 0x97, 0x9F, 0xA2, 0xB6, 0x45, 0xF7, 0x7B), - MBEDTLS_BYTES_TO_T_UINT_8(0xCA, 0x99, 0xF3, 0xD2, 0x20, 0x02, 0xEB, 0x04), - MBEDTLS_BYTES_TO_T_UINT_8(0x43, 0x18, 0x5B, 0x7B, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_15_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x2B, 0xDD, 0x77, 0x91, 0x60, 0xEA, 0xFD, 0xD3), - MBEDTLS_BYTES_TO_T_UINT_8(0x7D, 0xD3, 0xB5, 0xD6, 0x90, 0x17, 0x0E, 0x1A), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0xF4, 0x28, 0xC1, 0xF2, 0x53, 0xF6, 0x63), - MBEDTLS_BYTES_TO_T_UINT_8(0x49, 0x58, 0xDC, 0x61, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224r1_T_15_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA8, 0x20, 0x01, 0xFB, 0xF1, 0xBD, 0x5F, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0xD0, 0x7F, 0x06, 0xDA, 0x11, 0xCB, 0xBA, 0xA6), - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0x41, 0x00, 0xA4, 0x1B, 0x30, 0x33, 0x79), - MBEDTLS_BYTES_TO_T_UINT_8(0xF4, 0xFF, 0x27, 0xCA, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_ecp_point secp224r1_T[16] = { - ECP_POINT_INIT_XY_Z1(secp224r1_T_0_X, secp224r1_T_0_Y), ECP_POINT_INIT_XY_Z0(secp224r1_T_1_X, secp224r1_T_1_Y), - ECP_POINT_INIT_XY_Z0(secp224r1_T_2_X, secp224r1_T_2_Y), ECP_POINT_INIT_XY_Z0(secp224r1_T_3_X, secp224r1_T_3_Y), - ECP_POINT_INIT_XY_Z0(secp224r1_T_4_X, secp224r1_T_4_Y), ECP_POINT_INIT_XY_Z0(secp224r1_T_5_X, secp224r1_T_5_Y), - ECP_POINT_INIT_XY_Z0(secp224r1_T_6_X, secp224r1_T_6_Y), ECP_POINT_INIT_XY_Z0(secp224r1_T_7_X, secp224r1_T_7_Y), - ECP_POINT_INIT_XY_Z0(secp224r1_T_8_X, secp224r1_T_8_Y), ECP_POINT_INIT_XY_Z0(secp224r1_T_9_X, secp224r1_T_9_Y), - ECP_POINT_INIT_XY_Z0(secp224r1_T_10_X, secp224r1_T_10_Y), ECP_POINT_INIT_XY_Z0(secp224r1_T_11_X, secp224r1_T_11_Y), - ECP_POINT_INIT_XY_Z0(secp224r1_T_12_X, secp224r1_T_12_Y), ECP_POINT_INIT_XY_Z0(secp224r1_T_13_X, secp224r1_T_13_Y), - ECP_POINT_INIT_XY_Z0(secp224r1_T_14_X, secp224r1_T_14_Y), ECP_POINT_INIT_XY_Z0(secp224r1_T_15_X, secp224r1_T_15_Y), -}; -#else -#define secp224r1_T NULL -#endif -#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ - -/* - * Domain parameters for secp256r1 - */ -#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) -static const mbedtls_mpi_uint secp256r1_p[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), - MBEDTLS_BYTES_TO_T_UINT_8(0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF), -}; -static const mbedtls_mpi_uint secp256r1_b[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x4B, 0x60, 0xD2, 0x27, 0x3E, 0x3C, 0xCE, 0x3B), - MBEDTLS_BYTES_TO_T_UINT_8(0xF6, 0xB0, 0x53, 0xCC, 0xB0, 0x06, 0x1D, 0x65), - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0x86, 0x98, 0x76, 0x55, 0xBD, 0xEB, 0xB3), - MBEDTLS_BYTES_TO_T_UINT_8(0xE7, 0x93, 0x3A, 0xAA, 0xD8, 0x35, 0xC6, 0x5A), -}; -static const mbedtls_mpi_uint secp256r1_gx[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0xC2, 0x98, 0xD8, 0x45, 0x39, 0xA1, 0xF4), - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0x33, 0xEB, 0x2D, 0x81, 0x7D, 0x03, 0x77), - MBEDTLS_BYTES_TO_T_UINT_8(0xF2, 0x40, 0xA4, 0x63, 0xE5, 0xE6, 0xBC, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0x47, 0x42, 0x2C, 0xE1, 0xF2, 0xD1, 0x17, 0x6B), -}; -static const mbedtls_mpi_uint secp256r1_gy[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0x51, 0xBF, 0x37, 0x68, 0x40, 0xB6, 0xCB), - MBEDTLS_BYTES_TO_T_UINT_8(0xCE, 0x5E, 0x31, 0x6B, 0x57, 0x33, 0xCE, 0x2B), - MBEDTLS_BYTES_TO_T_UINT_8(0x16, 0x9E, 0x0F, 0x7C, 0x4A, 0xEB, 0xE7, 0x8E), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0x7F, 0x1A, 0xFE, 0xE2, 0x42, 0xE3, 0x4F), -}; -static const mbedtls_mpi_uint secp256r1_n[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x51, 0x25, 0x63, 0xFC, 0xC2, 0xCA, 0xB9, 0xF3), - MBEDTLS_BYTES_TO_T_UINT_8(0x84, 0x9E, 0x17, 0xA7, 0xAD, 0xFA, 0xE6, 0xBC), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF), -}; -#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 -static const mbedtls_mpi_uint secp256r1_T_0_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0xC2, 0x98, 0xD8, 0x45, 0x39, 0xA1, 0xF4), - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0x33, 0xEB, 0x2D, 0x81, 0x7D, 0x03, 0x77), - MBEDTLS_BYTES_TO_T_UINT_8(0xF2, 0x40, 0xA4, 0x63, 0xE5, 0xE6, 0xBC, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0x47, 0x42, 0x2C, 0xE1, 0xF2, 0xD1, 0x17, 0x6B), -}; -static const mbedtls_mpi_uint secp256r1_T_0_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0x51, 0xBF, 0x37, 0x68, 0x40, 0xB6, 0xCB), - MBEDTLS_BYTES_TO_T_UINT_8(0xCE, 0x5E, 0x31, 0x6B, 0x57, 0x33, 0xCE, 0x2B), - MBEDTLS_BYTES_TO_T_UINT_8(0x16, 0x9E, 0x0F, 0x7C, 0x4A, 0xEB, 0xE7, 0x8E), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0x7F, 0x1A, 0xFE, 0xE2, 0x42, 0xE3, 0x4F), -}; -static const mbedtls_mpi_uint secp256r1_T_1_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0xC8, 0xBA, 0x04, 0xB7, 0x4B, 0xD2, 0xF7), - MBEDTLS_BYTES_TO_T_UINT_8(0xAB, 0xC6, 0x23, 0x3A, 0xA0, 0x09, 0x3A, 0x59), - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0x9D, 0x4C, 0xF9, 0x58, 0x23, 0xCC, 0xDF), - MBEDTLS_BYTES_TO_T_UINT_8(0x02, 0xED, 0x7B, 0x29, 0x87, 0x0F, 0xFA, 0x3C), -}; -static const mbedtls_mpi_uint secp256r1_T_1_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x40, 0x69, 0xF2, 0x40, 0x0B, 0xA3, 0x98, 0xCE), - MBEDTLS_BYTES_TO_T_UINT_8(0xAF, 0xA8, 0x48, 0x02, 0x0D, 0x1C, 0x12, 0x62), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0xAF, 0x09, 0x83, 0x80, 0xAA, 0x58, 0xA7), - MBEDTLS_BYTES_TO_T_UINT_8(0xC6, 0x12, 0xBE, 0x70, 0x94, 0x76, 0xE3, 0xE4), -}; -static const mbedtls_mpi_uint secp256r1_T_2_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x7D, 0x7D, 0xEF, 0x86, 0xFF, 0xE3, 0x37, 0xDD), - MBEDTLS_BYTES_TO_T_UINT_8(0xDB, 0x86, 0x8B, 0x08, 0x27, 0x7C, 0xD7, 0xF6), - MBEDTLS_BYTES_TO_T_UINT_8(0x91, 0x54, 0x4C, 0x25, 0x4F, 0x9A, 0xFE, 0x28), - MBEDTLS_BYTES_TO_T_UINT_8(0x5E, 0xFD, 0xF0, 0x6D, 0x37, 0x03, 0x69, 0xD6), -}; -static const mbedtls_mpi_uint secp256r1_T_2_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0xD5, 0xDA, 0xAD, 0x92, 0x49, 0xF0, 0x9F), - MBEDTLS_BYTES_TO_T_UINT_8(0xF9, 0x73, 0x43, 0x9E, 0xAF, 0xA7, 0xD1, 0xF3), - MBEDTLS_BYTES_TO_T_UINT_8(0x67, 0x41, 0x07, 0xDF, 0x78, 0x95, 0x3E, 0xA1), - MBEDTLS_BYTES_TO_T_UINT_8(0x22, 0x3D, 0xD1, 0xE6, 0x3C, 0xA5, 0xE2, 0x20), -}; -static const mbedtls_mpi_uint secp256r1_T_3_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xBF, 0x6A, 0x5D, 0x52, 0x35, 0xD7, 0xBF, 0xAE), - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0xA2, 0xBE, 0x96, 0xF4, 0xF8, 0x02, 0xC3), - MBEDTLS_BYTES_TO_T_UINT_8(0xA4, 0x20, 0x49, 0x54, 0xEA, 0xB3, 0x82, 0xDB), - MBEDTLS_BYTES_TO_T_UINT_8(0x2E, 0xDB, 0xEA, 0x02, 0xD1, 0x75, 0x1C, 0x62), -}; -static const mbedtls_mpi_uint secp256r1_T_3_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF0, 0x85, 0xF4, 0x9E, 0x4C, 0xDC, 0x39, 0x89), - MBEDTLS_BYTES_TO_T_UINT_8(0x63, 0x6D, 0xC4, 0x57, 0xD8, 0x03, 0x5D, 0x22), - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0x7F, 0x2D, 0x52, 0x6F, 0xC9, 0xDA, 0x4F), - MBEDTLS_BYTES_TO_T_UINT_8(0x9D, 0x64, 0xFA, 0xB4, 0xFE, 0xA4, 0xC4, 0xD7), -}; -static const mbedtls_mpi_uint secp256r1_T_4_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0x37, 0xB9, 0xC0, 0xAA, 0x59, 0xC6, 0x8B), - MBEDTLS_BYTES_TO_T_UINT_8(0x3F, 0x58, 0xD9, 0xED, 0x58, 0x99, 0x65, 0xF7), - MBEDTLS_BYTES_TO_T_UINT_8(0x88, 0x7D, 0x26, 0x8C, 0x4A, 0xF9, 0x05, 0x9F), - MBEDTLS_BYTES_TO_T_UINT_8(0x9D, 0x73, 0x9A, 0xC9, 0xE7, 0x46, 0xDC, 0x00), -}; -static const mbedtls_mpi_uint secp256r1_T_4_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF2, 0xD0, 0x55, 0xDF, 0x00, 0x0A, 0xF5, 0x4A), - MBEDTLS_BYTES_TO_T_UINT_8(0x6A, 0xBF, 0x56, 0x81, 0x2D, 0x20, 0xEB, 0xB5), - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0xC1, 0x28, 0x52, 0xAB, 0xE3, 0xD1, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0x24, 0x34, 0x79, 0x45, 0x57, 0xA5, 0x12, 0x03), -}; -static const mbedtls_mpi_uint secp256r1_T_5_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xEE, 0xCF, 0xB8, 0x7E, 0xF7, 0x92, 0x96, 0x8D), - MBEDTLS_BYTES_TO_T_UINT_8(0x3D, 0x01, 0x8C, 0x0D, 0x23, 0xF2, 0xE3, 0x05), - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0x2E, 0xE3, 0x84, 0x52, 0x7A, 0x34, 0x76), - MBEDTLS_BYTES_TO_T_UINT_8(0xE5, 0xA1, 0xB0, 0x15, 0x90, 0xE2, 0x53, 0x3C), -}; -static const mbedtls_mpi_uint secp256r1_T_5_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xD4, 0x98, 0xE7, 0xFA, 0xA5, 0x7D, 0x8B, 0x53), - MBEDTLS_BYTES_TO_T_UINT_8(0x91, 0x35, 0xD2, 0x00, 0xD1, 0x1B, 0x9F, 0x1B), - MBEDTLS_BYTES_TO_T_UINT_8(0x3F, 0x69, 0x08, 0x9A, 0x72, 0xF0, 0xA9, 0x11), - MBEDTLS_BYTES_TO_T_UINT_8(0xB3, 0xFE, 0x0E, 0x14, 0xDA, 0x7C, 0x0E, 0xD3), -}; -static const mbedtls_mpi_uint secp256r1_T_6_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0xF6, 0xE8, 0xF8, 0x87, 0xF7, 0xFC, 0x6D), - MBEDTLS_BYTES_TO_T_UINT_8(0x90, 0xBE, 0x7F, 0x3F, 0x7A, 0x2B, 0xD7, 0x13), - MBEDTLS_BYTES_TO_T_UINT_8(0xCF, 0x32, 0xF2, 0x2D, 0x94, 0x6D, 0x42, 0xFD), - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0x9A, 0xE3, 0x5F, 0x42, 0xBB, 0x84, 0xED), -}; -static const mbedtls_mpi_uint secp256r1_T_6_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0x95, 0x29, 0x73, 0xA1, 0x67, 0x3E, 0x02), - MBEDTLS_BYTES_TO_T_UINT_8(0xE3, 0x30, 0x54, 0x35, 0x8E, 0x0A, 0xDD, 0x67), - MBEDTLS_BYTES_TO_T_UINT_8(0x03, 0xD7, 0xA1, 0x97, 0x61, 0x3B, 0xF8, 0x0C), - MBEDTLS_BYTES_TO_T_UINT_8(0xF2, 0x33, 0x3C, 0x58, 0x55, 0x34, 0x23, 0xA3), -}; -static const mbedtls_mpi_uint secp256r1_T_7_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0x5D, 0x16, 0x5F, 0x7B, 0xBC, 0xBB, 0xCE), - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0xEE, 0x4E, 0x8A, 0xC1, 0x51, 0xCC, 0x50), - MBEDTLS_BYTES_TO_T_UINT_8(0x1F, 0x0D, 0x4D, 0x1B, 0x53, 0x23, 0x1D, 0xB3), - MBEDTLS_BYTES_TO_T_UINT_8(0xDA, 0x2A, 0x38, 0x66, 0x52, 0x84, 0xE1, 0x95), -}; -static const mbedtls_mpi_uint secp256r1_T_7_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x5B, 0x9B, 0x83, 0x0A, 0x81, 0x4F, 0xAD, 0xAC), - MBEDTLS_BYTES_TO_T_UINT_8(0x0F, 0xFF, 0x42, 0x41, 0x6E, 0xA9, 0xA2, 0xA0), - MBEDTLS_BYTES_TO_T_UINT_8(0x2F, 0xA1, 0x4F, 0x1F, 0x89, 0x82, 0xAA, 0x3E), - MBEDTLS_BYTES_TO_T_UINT_8(0xF3, 0xB8, 0x0F, 0x6B, 0x8F, 0x8C, 0xD6, 0x68), -}; -static const mbedtls_mpi_uint secp256r1_T_8_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF1, 0xB3, 0xBB, 0x51, 0x69, 0xA2, 0x11, 0x93), - MBEDTLS_BYTES_TO_T_UINT_8(0x65, 0x4F, 0x0F, 0x8D, 0xBD, 0x26, 0x0F, 0xE8), - MBEDTLS_BYTES_TO_T_UINT_8(0xB9, 0xCB, 0xEC, 0x6B, 0x34, 0xC3, 0x3D, 0x9D), - MBEDTLS_BYTES_TO_T_UINT_8(0xE4, 0x5D, 0x1E, 0x10, 0xD5, 0x44, 0xE2, 0x54), -}; -static const mbedtls_mpi_uint secp256r1_T_8_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0x9E, 0xB1, 0xF1, 0x6E, 0x4C, 0xAD, 0xB3), - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0xE3, 0xC2, 0x58, 0xC0, 0xFB, 0x34, 0x43), - MBEDTLS_BYTES_TO_T_UINT_8(0x25, 0x9C, 0xDF, 0x35, 0x07, 0x41, 0xBD, 0x19), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x6E, 0x10, 0xEC, 0x0E, 0xEC, 0xBB, 0xD6), -}; -static const mbedtls_mpi_uint secp256r1_T_9_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC8, 0xCF, 0xEF, 0x3F, 0x83, 0x1A, 0x88, 0xE8), - MBEDTLS_BYTES_TO_T_UINT_8(0x0B, 0x29, 0xB5, 0xB9, 0xE0, 0xC9, 0xA3, 0xAE), - MBEDTLS_BYTES_TO_T_UINT_8(0x88, 0x46, 0x1E, 0x77, 0xCD, 0x7E, 0xB3, 0x10), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x21, 0xD0, 0xD4, 0xA3, 0x16, 0x08, 0xEE), -}; -static const mbedtls_mpi_uint secp256r1_T_9_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA1, 0xCA, 0xA8, 0xB3, 0xBF, 0x29, 0x99, 0x8E), - MBEDTLS_BYTES_TO_T_UINT_8(0xD1, 0xF2, 0x05, 0xC1, 0xCF, 0x5D, 0x91, 0x48), - MBEDTLS_BYTES_TO_T_UINT_8(0x9F, 0x01, 0x49, 0xDB, 0x82, 0xDF, 0x5F, 0x3A), - MBEDTLS_BYTES_TO_T_UINT_8(0xE1, 0x06, 0x90, 0xAD, 0xE3, 0x38, 0xA4, 0xC4), -}; -static const mbedtls_mpi_uint secp256r1_T_10_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0xD2, 0x3A, 0xE8, 0x03, 0xC5, 0x6D, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0xBE, 0x35, 0xD0, 0xAE, 0x1D, 0x7A, 0x9F, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0x33, 0x1E, 0xD2, 0xCB, 0xAC, 0x88, 0x27, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0xF0, 0xB9, 0x9C, 0xE0, 0x31, 0xDD, 0x99, 0x86), -}; -static const mbedtls_mpi_uint secp256r1_T_10_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0xF9, 0x9B, 0x32, 0x96, 0x41, 0x58, 0x38), - MBEDTLS_BYTES_TO_T_UINT_8(0xF9, 0x5A, 0x2A, 0xB8, 0x96, 0x0E, 0xB2, 0x4C), - MBEDTLS_BYTES_TO_T_UINT_8(0xC1, 0x78, 0x2C, 0xC7, 0x08, 0x99, 0x19, 0x24), - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0x59, 0x28, 0xE9, 0x84, 0x54, 0xE6, 0x16), -}; -static const mbedtls_mpi_uint secp256r1_T_11_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xDD, 0x38, 0x30, 0xDB, 0x70, 0x2C, 0x0A, 0xA2), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0x5C, 0x9D, 0xE9, 0xD5, 0x46, 0x0B, 0x5F), - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0x0B, 0x60, 0x4B, 0x37, 0x7D, 0xB9, 0xC9), - MBEDTLS_BYTES_TO_T_UINT_8(0x5E, 0x24, 0xF3, 0x3D, 0x79, 0x7F, 0x6C, 0x18), -}; -static const mbedtls_mpi_uint secp256r1_T_11_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x7F, 0xE5, 0x1C, 0x4F, 0x60, 0x24, 0xF7, 0x2A), - MBEDTLS_BYTES_TO_T_UINT_8(0xED, 0xD8, 0xE2, 0x91, 0x7F, 0x89, 0x49, 0x92), - MBEDTLS_BYTES_TO_T_UINT_8(0x97, 0xA7, 0x2E, 0x8D, 0x6A, 0xB3, 0x39, 0x81), - MBEDTLS_BYTES_TO_T_UINT_8(0x13, 0x89, 0xB5, 0x9A, 0xB8, 0x8D, 0x42, 0x9C), -}; -static const mbedtls_mpi_uint secp256r1_T_12_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x8D, 0x45, 0xE6, 0x4B, 0x3F, 0x4F, 0x1E, 0x1F), - MBEDTLS_BYTES_TO_T_UINT_8(0x47, 0x65, 0x5E, 0x59, 0x22, 0xCC, 0x72, 0x5F), - MBEDTLS_BYTES_TO_T_UINT_8(0xF1, 0x93, 0x1A, 0x27, 0x1E, 0x34, 0xC5, 0x5B), - MBEDTLS_BYTES_TO_T_UINT_8(0x63, 0xF2, 0xA5, 0x58, 0x5C, 0x15, 0x2E, 0xC6), -}; -static const mbedtls_mpi_uint secp256r1_T_12_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF4, 0x7F, 0xBA, 0x58, 0x5A, 0x84, 0x6F, 0x5F), - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0xA6, 0x36, 0x7E, 0xDC, 0xF7, 0xE1, 0x67), - MBEDTLS_BYTES_TO_T_UINT_8(0x04, 0x4D, 0xAA, 0xEE, 0x57, 0x76, 0x3A, 0xD3), - MBEDTLS_BYTES_TO_T_UINT_8(0x4E, 0x7E, 0x26, 0x18, 0x22, 0x23, 0x9F, 0xFF), -}; -static const mbedtls_mpi_uint secp256r1_T_13_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0x4C, 0x64, 0xC7, 0x55, 0x02, 0x3F, 0xE3), - MBEDTLS_BYTES_TO_T_UINT_8(0xD8, 0x02, 0x90, 0xBB, 0xC3, 0xEC, 0x30, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0x9F, 0x6F, 0x64, 0xF4, 0x16, 0x69, 0x48, 0xA4), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0x44, 0x9C, 0x95, 0x0C, 0x7D, 0x67, 0x5E), -}; -static const mbedtls_mpi_uint secp256r1_T_13_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x44, 0x91, 0x8B, 0xD8, 0xD0, 0xD7, 0xE7, 0xE2), - MBEDTLS_BYTES_TO_T_UINT_8(0x1F, 0xF9, 0x48, 0x62, 0x6F, 0xA8, 0x93, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0xEA, 0x3A, 0x99, 0x02, 0xD5, 0x0B, 0x3D, 0xE3), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0xD3, 0x00, 0x31, 0xE6, 0x0C, 0x9F, 0x44), -}; -static const mbedtls_mpi_uint secp256r1_T_14_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x56, 0xB2, 0xAA, 0xFD, 0x88, 0x15, 0xDF, 0x52), - MBEDTLS_BYTES_TO_T_UINT_8(0x4C, 0x35, 0x27, 0x31, 0x44, 0xCD, 0xC0, 0x68), - MBEDTLS_BYTES_TO_T_UINT_8(0x53, 0xF8, 0x91, 0xA5, 0x71, 0x94, 0x84, 0x2A), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0xCB, 0xD0, 0x93, 0xE9, 0x88, 0xDA, 0xE4), -}; -static const mbedtls_mpi_uint secp256r1_T_14_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x24, 0xC6, 0x39, 0x16, 0x5D, 0xA3, 0x1E, 0x6D), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0x07, 0x37, 0x26, 0x36, 0x2A, 0xFE, 0x60), - MBEDTLS_BYTES_TO_T_UINT_8(0x51, 0xBC, 0xF3, 0xD0, 0xDE, 0x50, 0xFC, 0x97), - MBEDTLS_BYTES_TO_T_UINT_8(0x80, 0x2E, 0x06, 0x10, 0x15, 0x4D, 0xFA, 0xF7), -}; -static const mbedtls_mpi_uint secp256r1_T_15_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x27, 0x65, 0x69, 0x5B, 0x66, 0xA2, 0x75, 0x2E), - MBEDTLS_BYTES_TO_T_UINT_8(0x9C, 0x16, 0x00, 0x5A, 0xB0, 0x30, 0x25, 0x1A), - MBEDTLS_BYTES_TO_T_UINT_8(0x42, 0xFB, 0x86, 0x42, 0x80, 0xC1, 0xC4, 0x76), - MBEDTLS_BYTES_TO_T_UINT_8(0x5B, 0x1D, 0x83, 0x8E, 0x94, 0x01, 0x5F, 0x82), -}; -static const mbedtls_mpi_uint secp256r1_T_15_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x39, 0x37, 0x70, 0xEF, 0x1F, 0xA1, 0xF0, 0xDB), - MBEDTLS_BYTES_TO_T_UINT_8(0x6A, 0x10, 0x5B, 0xCE, 0xC4, 0x9B, 0x6F, 0x10), - MBEDTLS_BYTES_TO_T_UINT_8(0x50, 0x11, 0x11, 0x24, 0x4F, 0x4C, 0x79, 0x61), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0x3A, 0x72, 0xBC, 0xFE, 0x72, 0x58, 0x43), -}; -static const mbedtls_ecp_point secp256r1_T[16] = { - ECP_POINT_INIT_XY_Z1(secp256r1_T_0_X, secp256r1_T_0_Y), ECP_POINT_INIT_XY_Z0(secp256r1_T_1_X, secp256r1_T_1_Y), - ECP_POINT_INIT_XY_Z0(secp256r1_T_2_X, secp256r1_T_2_Y), ECP_POINT_INIT_XY_Z0(secp256r1_T_3_X, secp256r1_T_3_Y), - ECP_POINT_INIT_XY_Z0(secp256r1_T_4_X, secp256r1_T_4_Y), ECP_POINT_INIT_XY_Z0(secp256r1_T_5_X, secp256r1_T_5_Y), - ECP_POINT_INIT_XY_Z0(secp256r1_T_6_X, secp256r1_T_6_Y), ECP_POINT_INIT_XY_Z0(secp256r1_T_7_X, secp256r1_T_7_Y), - ECP_POINT_INIT_XY_Z0(secp256r1_T_8_X, secp256r1_T_8_Y), ECP_POINT_INIT_XY_Z0(secp256r1_T_9_X, secp256r1_T_9_Y), - ECP_POINT_INIT_XY_Z0(secp256r1_T_10_X, secp256r1_T_10_Y), ECP_POINT_INIT_XY_Z0(secp256r1_T_11_X, secp256r1_T_11_Y), - ECP_POINT_INIT_XY_Z0(secp256r1_T_12_X, secp256r1_T_12_Y), ECP_POINT_INIT_XY_Z0(secp256r1_T_13_X, secp256r1_T_13_Y), - ECP_POINT_INIT_XY_Z0(secp256r1_T_14_X, secp256r1_T_14_Y), ECP_POINT_INIT_XY_Z0(secp256r1_T_15_X, secp256r1_T_15_Y), -}; -#else -#define secp256r1_T NULL -#endif - -#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ - -/* - * Domain parameters for secp384r1 - */ -#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) -static const mbedtls_mpi_uint secp384r1_p[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), -}; -static const mbedtls_mpi_uint secp384r1_b[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xEF, 0x2A, 0xEC, 0xD3, 0xED, 0xC8, 0x85, 0x2A), - MBEDTLS_BYTES_TO_T_UINT_8(0x9D, 0xD1, 0x2E, 0x8A, 0x8D, 0x39, 0x56, 0xC6), - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0x87, 0x13, 0x50, 0x8F, 0x08, 0x14, 0x03), - MBEDTLS_BYTES_TO_T_UINT_8(0x12, 0x41, 0x81, 0xFE, 0x6E, 0x9C, 0x1D, 0x18), - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0x2D, 0xF8, 0xE3, 0x6B, 0x05, 0x8E, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0xE4, 0xE7, 0x3E, 0xE2, 0xA7, 0x2F, 0x31, 0xB3), -}; -static const mbedtls_mpi_uint secp384r1_gx[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0x0A, 0x76, 0x72, 0x38, 0x5E, 0x54, 0x3A), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x29, 0x55, 0xBF, 0x5D, 0xF2, 0x02, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0x38, 0x2A, 0x54, 0x82, 0xE0, 0x41, 0xF7, 0x59), - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0x9B, 0xA7, 0x8B, 0x62, 0x3B, 0x1D, 0x6E), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0xAD, 0x20, 0xF3, 0x1E, 0xC7, 0xB1, 0x8E), - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0x05, 0x8B, 0xBE, 0x22, 0xCA, 0x87, 0xAA), -}; -static const mbedtls_mpi_uint secp384r1_gy[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x5F, 0x0E, 0xEA, 0x90, 0x7C, 0x1D, 0x43, 0x7A), - MBEDTLS_BYTES_TO_T_UINT_8(0x9D, 0x81, 0x7E, 0x1D, 0xCE, 0xB1, 0x60, 0x0A), - MBEDTLS_BYTES_TO_T_UINT_8(0xC0, 0xB8, 0xF0, 0xB5, 0x13, 0x31, 0xDA, 0xE9), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0x14, 0x9A, 0x28, 0xBD, 0x1D, 0xF4, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0x29, 0xDC, 0x92, 0x92, 0xBF, 0x98, 0x9E, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0x6F, 0x2C, 0x26, 0x96, 0x4A, 0xDE, 0x17, 0x36), -}; -static const mbedtls_mpi_uint secp384r1_n[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x73, 0x29, 0xC5, 0xCC, 0x6A, 0x19, 0xEC, 0xEC), - MBEDTLS_BYTES_TO_T_UINT_8(0x7A, 0xA7, 0xB0, 0x48, 0xB2, 0x0D, 0x1A, 0x58), - MBEDTLS_BYTES_TO_T_UINT_8(0xDF, 0x2D, 0x37, 0xF4, 0x81, 0x4D, 0x63, 0xC7), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), -}; -#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 -static const mbedtls_mpi_uint secp384r1_T_0_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0x0A, 0x76, 0x72, 0x38, 0x5E, 0x54, 0x3A), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x29, 0x55, 0xBF, 0x5D, 0xF2, 0x02, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0x38, 0x2A, 0x54, 0x82, 0xE0, 0x41, 0xF7, 0x59), - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0x9B, 0xA7, 0x8B, 0x62, 0x3B, 0x1D, 0x6E), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0xAD, 0x20, 0xF3, 0x1E, 0xC7, 0xB1, 0x8E), - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0x05, 0x8B, 0xBE, 0x22, 0xCA, 0x87, 0xAA), -}; -static const mbedtls_mpi_uint secp384r1_T_0_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x5F, 0x0E, 0xEA, 0x90, 0x7C, 0x1D, 0x43, 0x7A), - MBEDTLS_BYTES_TO_T_UINT_8(0x9D, 0x81, 0x7E, 0x1D, 0xCE, 0xB1, 0x60, 0x0A), - MBEDTLS_BYTES_TO_T_UINT_8(0xC0, 0xB8, 0xF0, 0xB5, 0x13, 0x31, 0xDA, 0xE9), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0x14, 0x9A, 0x28, 0xBD, 0x1D, 0xF4, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0x29, 0xDC, 0x92, 0x92, 0xBF, 0x98, 0x9E, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0x6F, 0x2C, 0x26, 0x96, 0x4A, 0xDE, 0x17, 0x36), -}; -static const mbedtls_mpi_uint secp384r1_T_1_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x46, 0x92, 0x00, 0x2C, 0x78, 0xDB, 0x1F, 0x37), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0xF3, 0xEB, 0xB7, 0x06, 0xF7, 0xB6, 0xBC), - MBEDTLS_BYTES_TO_T_UINT_8(0x3D, 0xBC, 0x2C, 0xCF, 0xD8, 0xED, 0x53, 0xE7), - MBEDTLS_BYTES_TO_T_UINT_8(0x52, 0x75, 0x7B, 0xA3, 0xAB, 0xC3, 0x2C, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0xE5, 0x9D, 0x78, 0x41, 0xF6, 0x76, 0x84, 0xAC), - MBEDTLS_BYTES_TO_T_UINT_8(0x54, 0x56, 0xE8, 0x52, 0xB3, 0xCB, 0xA8, 0xBD), -}; -static const mbedtls_mpi_uint secp384r1_T_1_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0xF2, 0xAE, 0xA4, 0xB6, 0x89, 0x1B, 0xDA), - MBEDTLS_BYTES_TO_T_UINT_8(0x01, 0x0F, 0xCE, 0x1C, 0x7C, 0xF6, 0x50, 0x4C), - MBEDTLS_BYTES_TO_T_UINT_8(0x4C, 0xEB, 0x90, 0xE6, 0x4D, 0xC7, 0xD4, 0x7A), - MBEDTLS_BYTES_TO_T_UINT_8(0xD1, 0x49, 0x2D, 0x8A, 0x01, 0x99, 0x60, 0x94), - MBEDTLS_BYTES_TO_T_UINT_8(0x5F, 0x80, 0x9B, 0x9B, 0x6A, 0xB0, 0x07, 0xD9), - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0xA2, 0xEE, 0x59, 0xBE, 0x95, 0xBC, 0x23), -}; -static const mbedtls_mpi_uint secp384r1_T_2_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0x9D, 0x56, 0xAE, 0x59, 0xFB, 0x1F, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0xCF, 0xAC, 0x91, 0x80, 0x87, 0xA8, 0x6E, 0x58), - MBEDTLS_BYTES_TO_T_UINT_8(0x30, 0x08, 0xA7, 0x08, 0x94, 0x32, 0xFC, 0x67), - MBEDTLS_BYTES_TO_T_UINT_8(0x9F, 0x29, 0x9E, 0x84, 0xF4, 0xE5, 0x6E, 0x7E), - MBEDTLS_BYTES_TO_T_UINT_8(0x55, 0x21, 0xB9, 0x50, 0x24, 0xF8, 0x9C, 0xC7), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0x04, 0x01, 0xC2, 0xFB, 0x77, 0x3E, 0xDE), -}; -static const mbedtls_mpi_uint secp384r1_T_2_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x38, 0xEE, 0xE3, 0xC7, 0x9D, 0xEC, 0xA6), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x88, 0xCF, 0x43, 0xFA, 0x92, 0x5E, 0x8E), - MBEDTLS_BYTES_TO_T_UINT_8(0xE9, 0xCA, 0x43, 0xF8, 0x3B, 0x49, 0x7E, 0x75), - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0xE7, 0xEB, 0x17, 0x45, 0x86, 0xC2, 0xE1), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0x69, 0x57, 0x32, 0xE0, 0x9C, 0xD1, 0x00), - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0x10, 0xB8, 0x4D, 0xB8, 0xF4, 0x0D, 0xE3), -}; -static const mbedtls_mpi_uint secp384r1_T_3_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x60, 0xDC, 0x9A, 0xB2, 0x79, 0x39, 0x27, 0x16), - MBEDTLS_BYTES_TO_T_UINT_8(0x4F, 0x71, 0xE4, 0x3B, 0x4D, 0x60, 0x0C, 0xA3), - MBEDTLS_BYTES_TO_T_UINT_8(0x55, 0xBD, 0x19, 0x40, 0xFA, 0x19, 0x2A, 0x5A), - MBEDTLS_BYTES_TO_T_UINT_8(0x4D, 0xF8, 0x1E, 0x43, 0xA1, 0x50, 0x8D, 0xEF), - MBEDTLS_BYTES_TO_T_UINT_8(0xA3, 0x18, 0x7C, 0x41, 0xFA, 0x7C, 0x1B, 0x58), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x59, 0x24, 0xC4, 0xE9, 0xB7, 0xD3, 0xAD), -}; -static const mbedtls_mpi_uint secp384r1_T_3_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xBB, 0x01, 0x3D, 0x63, 0x54, 0x45, 0x6F, 0xB7), - MBEDTLS_BYTES_TO_T_UINT_8(0x7B, 0xB2, 0x19, 0xA3, 0x86, 0x1D, 0x42, 0x34), - MBEDTLS_BYTES_TO_T_UINT_8(0x84, 0x02, 0x87, 0x18, 0x92, 0x52, 0x1A, 0x71), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x18, 0xB1, 0x5D, 0x18, 0x1B, 0x37, 0xFE), - MBEDTLS_BYTES_TO_T_UINT_8(0xF4, 0x74, 0x61, 0xBA, 0x18, 0xAF, 0x40, 0x30), - MBEDTLS_BYTES_TO_T_UINT_8(0xDA, 0x7D, 0x3C, 0x52, 0x0F, 0x07, 0xB0, 0x6F), -}; -static const mbedtls_mpi_uint secp384r1_T_4_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x09, 0x39, 0x13, 0xAA, 0x60, 0x15, 0x99, 0x30), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0x00, 0xCB, 0xC6, 0xB1, 0xDB, 0x97, 0x90), - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0xFA, 0x60, 0xB8, 0x24, 0xE4, 0x7D, 0xD3), - MBEDTLS_BYTES_TO_T_UINT_8(0xDD, 0x75, 0xB3, 0x70, 0xB2, 0x83, 0xB1, 0x9B), - MBEDTLS_BYTES_TO_T_UINT_8(0xA3, 0xE3, 0x6C, 0xCD, 0x33, 0x62, 0x7A, 0x56), - MBEDTLS_BYTES_TO_T_UINT_8(0x88, 0x30, 0xDC, 0x0F, 0x9F, 0xBB, 0xB8, 0xAA), -}; -static const mbedtls_mpi_uint secp384r1_T_4_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA6, 0xD5, 0x0A, 0x60, 0x81, 0xB9, 0xC5, 0x16), - MBEDTLS_BYTES_TO_T_UINT_8(0x44, 0xAA, 0x2F, 0xD6, 0xF2, 0x73, 0xDF, 0xEB), - MBEDTLS_BYTES_TO_T_UINT_8(0xF3, 0x7B, 0x74, 0xC9, 0xB3, 0x5B, 0x95, 0x6D), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0x04, 0xEB, 0x15, 0xC8, 0x5F, 0x00, 0xF6), - MBEDTLS_BYTES_TO_T_UINT_8(0xB5, 0x50, 0x20, 0x28, 0xD1, 0x01, 0xAF, 0xF0), - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0x6D, 0x4F, 0x31, 0x81, 0x2F, 0x94, 0x48), -}; -static const mbedtls_mpi_uint secp384r1_T_5_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x46, 0x2F, 0xD8, 0xB6, 0x63, 0x7C, 0xE9, 0x50), - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0x8C, 0xB9, 0x14, 0xD9, 0x37, 0x63, 0xDE), - MBEDTLS_BYTES_TO_T_UINT_8(0x10, 0x02, 0xB8, 0x46, 0xAD, 0xCE, 0x7B, 0x38), - MBEDTLS_BYTES_TO_T_UINT_8(0x82, 0x47, 0x2D, 0x66, 0xA7, 0xE9, 0x33, 0x23), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0xF9, 0x93, 0x94, 0xA8, 0x48, 0xB3, 0x4F), - MBEDTLS_BYTES_TO_T_UINT_8(0xE9, 0x4A, 0xAC, 0x51, 0x08, 0x72, 0x2F, 0x1A), -}; -static const mbedtls_mpi_uint secp384r1_T_5_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xDA, 0xAD, 0xA0, 0xF9, 0x81, 0xE1, 0x78, 0x97), - MBEDTLS_BYTES_TO_T_UINT_8(0x3A, 0x9A, 0x63, 0xD8, 0xBA, 0x79, 0x1A, 0x17), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0x31, 0x7B, 0x7A, 0x5A, 0x5D, 0x7D, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0x96, 0x12, 0x4B, 0x19, 0x09, 0xE0, 0xB7), - MBEDTLS_BYTES_TO_T_UINT_8(0x55, 0x8A, 0x57, 0xEE, 0x4E, 0x6E, 0x7E, 0xEC), - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0x9D, 0x69, 0xDC, 0xB3, 0xDA, 0xD8, 0x08), -}; -static const mbedtls_mpi_uint secp384r1_T_6_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x68, 0x49, 0x03, 0x03, 0x33, 0x6F, 0x28, 0x4A), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0xDB, 0xA7, 0x05, 0x8C, 0xF3, 0x4D, 0xFB), - MBEDTLS_BYTES_TO_T_UINT_8(0x8E, 0x92, 0xB1, 0xA8, 0xEC, 0x0D, 0x64, 0x3B), - MBEDTLS_BYTES_TO_T_UINT_8(0x4E, 0xFC, 0xFD, 0xD0, 0x4B, 0x88, 0x1B, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0x9C, 0x51, 0x69, 0xCE, 0x71, 0x73, 0xF5), - MBEDTLS_BYTES_TO_T_UINT_8(0xB8, 0x5A, 0x14, 0x23, 0x1A, 0x46, 0x63, 0x5F), -}; -static const mbedtls_mpi_uint secp384r1_T_6_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0x4C, 0x70, 0x44, 0x18, 0xCD, 0xEF, 0xED), - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0x49, 0xDD, 0x64, 0x7E, 0x7E, 0x4D, 0x92), - MBEDTLS_BYTES_TO_T_UINT_8(0xA2, 0x32, 0x7C, 0x09, 0xD0, 0x3F, 0xD6, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0xE0, 0x4F, 0x65, 0x0C, 0x7A, 0x54, 0x3E), - MBEDTLS_BYTES_TO_T_UINT_8(0x16, 0xFA, 0xFB, 0x4A, 0xB4, 0x79, 0x5A, 0x8C), - MBEDTLS_BYTES_TO_T_UINT_8(0x04, 0x5D, 0x1B, 0x2B, 0xDA, 0xBC, 0x9A, 0x74), -}; -static const mbedtls_mpi_uint secp384r1_T_7_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x51, 0xAC, 0x56, 0xF7, 0x5F, 0x51, 0x68, 0x0B), - MBEDTLS_BYTES_TO_T_UINT_8(0xC6, 0xE0, 0x1D, 0xBC, 0x13, 0x4E, 0xAC, 0x03), - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0xF5, 0xC5, 0xE6, 0xD2, 0x88, 0xBA, 0xCB), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0x0E, 0x28, 0x23, 0x58, 0x67, 0xFA, 0xEE), - MBEDTLS_BYTES_TO_T_UINT_8(0x9E, 0x80, 0x4B, 0xD8, 0xC4, 0xDF, 0x15, 0xE4), - MBEDTLS_BYTES_TO_T_UINT_8(0xF1, 0x0E, 0x58, 0xE6, 0x2C, 0x59, 0xC2, 0x03), -}; -static const mbedtls_mpi_uint secp384r1_T_7_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0x26, 0x27, 0x99, 0x16, 0x2B, 0x22, 0x0B), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0xF3, 0x8F, 0xC3, 0x2A, 0x9B, 0xFC, 0x38), - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0x2E, 0x83, 0x3D, 0xFE, 0x9E, 0x3C, 0x1B), - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0x57, 0xCD, 0x2D, 0xC1, 0x49, 0x38, 0xB5), - MBEDTLS_BYTES_TO_T_UINT_8(0x95, 0x42, 0x8B, 0x33, 0x89, 0x1F, 0xEA, 0x01), - MBEDTLS_BYTES_TO_T_UINT_8(0xAA, 0x1D, 0x13, 0xD7, 0x50, 0xBB, 0x3E, 0xEB), -}; -static const mbedtls_mpi_uint secp384r1_T_8_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xD2, 0x9A, 0x52, 0xD2, 0x54, 0x7C, 0x97, 0xF2), - MBEDTLS_BYTES_TO_T_UINT_8(0xE0, 0x33, 0x6E, 0xED, 0xD9, 0x87, 0x50, 0xC5), - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0x35, 0x7E, 0x16, 0x40, 0x15, 0x83, 0xB8), - MBEDTLS_BYTES_TO_T_UINT_8(0x33, 0x2B, 0xA4, 0xAB, 0x03, 0x91, 0xEA, 0xFE), - MBEDTLS_BYTES_TO_T_UINT_8(0xC1, 0x47, 0x39, 0xEF, 0x05, 0x59, 0xD0, 0x90), - MBEDTLS_BYTES_TO_T_UINT_8(0xBF, 0x24, 0x0D, 0x76, 0x11, 0x53, 0x08, 0xAF), -}; -static const mbedtls_mpi_uint secp384r1_T_8_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1F, 0x2F, 0xDD, 0xBD, 0x50, 0x48, 0xB1, 0xE5), - MBEDTLS_BYTES_TO_T_UINT_8(0x80, 0x1C, 0x84, 0x55, 0x78, 0x14, 0xEB, 0xF6), - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0x5E, 0x3E, 0xA6, 0xAF, 0xF6, 0xC7, 0x04), - MBEDTLS_BYTES_TO_T_UINT_8(0xE7, 0x11, 0xE2, 0x65, 0xCA, 0x41, 0x95, 0x3B), - MBEDTLS_BYTES_TO_T_UINT_8(0xAE, 0x83, 0xD8, 0xE6, 0x4D, 0x22, 0x06, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0x7F, 0x25, 0x2A, 0xAA, 0x28, 0x46, 0x97), -}; -static const mbedtls_mpi_uint secp384r1_T_9_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x79, 0xDB, 0x15, 0x56, 0x84, 0xCB, 0xC0, 0x56), - MBEDTLS_BYTES_TO_T_UINT_8(0x56, 0xDB, 0x0E, 0x08, 0xC9, 0xF5, 0xD4, 0x9E), - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0x62, 0xD0, 0x1A, 0x7C, 0x13, 0xD5, 0x07), - MBEDTLS_BYTES_TO_T_UINT_8(0x7D, 0xAD, 0x53, 0xE0, 0x32, 0x21, 0xA0, 0xC0), - MBEDTLS_BYTES_TO_T_UINT_8(0xC5, 0x38, 0x81, 0x21, 0x23, 0x0E, 0xD2, 0xBB), - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0x51, 0x05, 0xD0, 0x1E, 0x82, 0xA9, 0x71), -}; -static const mbedtls_mpi_uint secp384r1_T_9_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0xC3, 0x27, 0xBF, 0xC6, 0xAA, 0xB7, 0xB9), - MBEDTLS_BYTES_TO_T_UINT_8(0xCB, 0x65, 0x45, 0xDF, 0xB9, 0x46, 0x17, 0x46), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0x38, 0x3F, 0xB2, 0xB1, 0x5D, 0xCA, 0x1C), - MBEDTLS_BYTES_TO_T_UINT_8(0x88, 0x29, 0x6C, 0x63, 0xE9, 0xD7, 0x48, 0xB8), - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0xF1, 0xD7, 0x99, 0x8C, 0xC2, 0x05, 0x99), - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0xE6, 0x5E, 0x82, 0x6D, 0xE5, 0x7E, 0xD5), -}; -static const mbedtls_mpi_uint secp384r1_T_10_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x7B, 0x61, 0xFA, 0x7D, 0x01, 0xDB, 0xB6, 0x63), - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0xC6, 0x58, 0x39, 0xF4, 0xC6, 0x82, 0x23), - MBEDTLS_BYTES_TO_T_UINT_8(0x47, 0x5A, 0x7A, 0x80, 0x08, 0xCD, 0xAA, 0xD8), - MBEDTLS_BYTES_TO_T_UINT_8(0xDA, 0x8C, 0xC6, 0x3F, 0x3C, 0xA5, 0x68, 0xF4), - MBEDTLS_BYTES_TO_T_UINT_8(0xBB, 0xF5, 0xD5, 0x17, 0xAE, 0x36, 0xD8, 0x8A), - MBEDTLS_BYTES_TO_T_UINT_8(0xC7, 0xAD, 0x92, 0xC5, 0x57, 0x6C, 0xDA, 0x91), -}; -static const mbedtls_mpi_uint secp384r1_T_10_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0x67, 0x17, 0xC0, 0x40, 0x78, 0x8C, 0x84), - MBEDTLS_BYTES_TO_T_UINT_8(0x7E, 0x9F, 0xF4, 0xAA, 0xDA, 0x5C, 0x7E, 0xB2), - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0xDB, 0x42, 0x3E, 0x72, 0x64, 0xA0, 0x67), - MBEDTLS_BYTES_TO_T_UINT_8(0x27, 0xF9, 0x41, 0x17, 0x43, 0xE3, 0xE8, 0xA8), - MBEDTLS_BYTES_TO_T_UINT_8(0x66, 0xDD, 0xCC, 0x43, 0x7E, 0x16, 0x05, 0x03), - MBEDTLS_BYTES_TO_T_UINT_8(0x36, 0x4B, 0xCF, 0x48, 0x8F, 0x41, 0x90, 0xE5), -}; -static const mbedtls_mpi_uint secp384r1_T_11_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0x0C, 0x6B, 0x9D, 0x22, 0x04, 0xBC, 0x5C), - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0x63, 0x79, 0x2F, 0x6A, 0x0E, 0x8A, 0xDE), - MBEDTLS_BYTES_TO_T_UINT_8(0x29, 0x67, 0x3F, 0x02, 0xB8, 0x91, 0x7F, 0x74), - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0x14, 0x64, 0xA0, 0x33, 0xF4, 0x6B, 0x50), - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0x44, 0x71, 0x87, 0xB8, 0x88, 0x3F, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0x1B, 0x2B, 0x85, 0x05, 0xC5, 0x44, 0x53, 0x15), -}; -static const mbedtls_mpi_uint secp384r1_T_11_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x3E, 0x2B, 0xFE, 0xD1, 0x1C, 0x73, 0xE3, 0x2E), - MBEDTLS_BYTES_TO_T_UINT_8(0x66, 0x33, 0xA1, 0xD3, 0x69, 0x1C, 0x9D, 0xD2), - MBEDTLS_BYTES_TO_T_UINT_8(0xE0, 0x5A, 0xBA, 0xB6, 0xAE, 0x1B, 0x94, 0x04), - MBEDTLS_BYTES_TO_T_UINT_8(0xAF, 0x74, 0x90, 0x5C, 0x57, 0xB0, 0x3A, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0xDD, 0x2F, 0x93, 0x20, 0x24, 0x54, 0x1D, 0x8D), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0x78, 0x9D, 0x71, 0x67, 0x5D, 0x49, 0x98), -}; -static const mbedtls_mpi_uint secp384r1_T_12_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x12, 0xC8, 0x0E, 0x11, 0x8D, 0xE0, 0x8F, 0x69), - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0x7F, 0x79, 0x6C, 0x5F, 0xB7, 0xBC, 0xB1), - MBEDTLS_BYTES_TO_T_UINT_8(0x88, 0xE1, 0x83, 0x3C, 0x12, 0xBB, 0xEE, 0x96), - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0xC2, 0xC4, 0x1B, 0x41, 0x71, 0xB9, 0x17), - MBEDTLS_BYTES_TO_T_UINT_8(0xB0, 0xEE, 0xBB, 0x1D, 0x89, 0x50, 0x88, 0xF2), - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0x1C, 0x55, 0x74, 0xEB, 0xDE, 0x92, 0x3F), -}; -static const mbedtls_mpi_uint secp384r1_T_12_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x9C, 0x38, 0x92, 0x06, 0x19, 0xD0, 0xB3, 0xB2), - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0x99, 0x26, 0xA3, 0x5F, 0xE2, 0xC1, 0x81), - MBEDTLS_BYTES_TO_T_UINT_8(0x75, 0xFC, 0xFD, 0xC3, 0xB6, 0x26, 0x24, 0x8F), - MBEDTLS_BYTES_TO_T_UINT_8(0xAF, 0xAD, 0xE7, 0x49, 0xB7, 0x64, 0x4B, 0x96), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x4E, 0x95, 0xAD, 0x07, 0xFE, 0xB6, 0x30), - MBEDTLS_BYTES_TO_T_UINT_8(0x4F, 0x15, 0xE7, 0x2D, 0x19, 0xA9, 0x08, 0x10), -}; -static const mbedtls_mpi_uint secp384r1_T_13_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xBE, 0xBD, 0xAC, 0x0A, 0x3F, 0x6B, 0xFF, 0xFA), - MBEDTLS_BYTES_TO_T_UINT_8(0xE0, 0xE4, 0x74, 0x14, 0xD9, 0x70, 0x1D, 0x71), - MBEDTLS_BYTES_TO_T_UINT_8(0xF2, 0xB0, 0x71, 0xBB, 0xD8, 0x18, 0x96, 0x2B), - MBEDTLS_BYTES_TO_T_UINT_8(0xDA, 0xB8, 0x19, 0x90, 0x80, 0xB5, 0xEE, 0x01), - MBEDTLS_BYTES_TO_T_UINT_8(0x91, 0x21, 0x20, 0xA6, 0x17, 0x48, 0x03, 0x6F), - MBEDTLS_BYTES_TO_T_UINT_8(0xE3, 0x1D, 0xBB, 0x6D, 0x94, 0x20, 0x34, 0xF1), -}; -static const mbedtls_mpi_uint secp384r1_T_13_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0x82, 0x67, 0x4B, 0x8E, 0x4E, 0xBE, 0xE2), - MBEDTLS_BYTES_TO_T_UINT_8(0xBE, 0xDA, 0x77, 0xF8, 0x23, 0x55, 0x2B, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0x5C, 0x02, 0xDE, 0x25, 0x35, 0x2D, 0x74, 0x51), - MBEDTLS_BYTES_TO_T_UINT_8(0xD0, 0x0C, 0xB8, 0x0B, 0x39, 0xBA, 0xAD, 0x04), - MBEDTLS_BYTES_TO_T_UINT_8(0xA6, 0x0E, 0x28, 0x4D, 0xE1, 0x3D, 0xE4, 0x1B), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0xEC, 0x0A, 0xD4, 0xB8, 0xC4, 0x8D, 0xB0), -}; -static const mbedtls_mpi_uint secp384r1_T_14_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x3E, 0x68, 0xCE, 0xC2, 0x55, 0x4D, 0x0C, 0x6D), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0x20, 0x93, 0x32, 0x90, 0xD6, 0xAE, 0x47), - MBEDTLS_BYTES_TO_T_UINT_8(0xDD, 0x78, 0xAB, 0x43, 0x9E, 0xEB, 0x73, 0xAE), - MBEDTLS_BYTES_TO_T_UINT_8(0xED, 0x97, 0xC3, 0x83, 0xA6, 0x3C, 0xF1, 0xBF), - MBEDTLS_BYTES_TO_T_UINT_8(0x0F, 0x25, 0x25, 0x66, 0x08, 0x26, 0xFA, 0x4B), - MBEDTLS_BYTES_TO_T_UINT_8(0x41, 0xFB, 0x44, 0x5D, 0x82, 0xEC, 0x3B, 0xAC), -}; -static const mbedtls_mpi_uint secp384r1_T_14_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x58, 0x90, 0xEA, 0xB5, 0x04, 0x99, 0xD0, 0x69), - MBEDTLS_BYTES_TO_T_UINT_8(0x4A, 0xF2, 0x22, 0xA0, 0xEB, 0xFD, 0x45, 0x87), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0xA4, 0x81, 0x32, 0xFC, 0xFA, 0xEE, 0x5B), - MBEDTLS_BYTES_TO_T_UINT_8(0x27, 0xBB, 0xA4, 0x6A, 0x77, 0x41, 0x5C, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0xA1, 0x1E, 0xAA, 0x4F, 0xF0, 0x10, 0xB3, 0x50), - MBEDTLS_BYTES_TO_T_UINT_8(0x09, 0x74, 0x13, 0x14, 0x9E, 0x90, 0xD7, 0xE6), -}; -static const mbedtls_mpi_uint secp384r1_T_15_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xDB, 0xBD, 0x70, 0x4F, 0xA8, 0xD1, 0x06, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0x4E, 0x2E, 0x68, 0xFC, 0x35, 0xFA, 0x50), - MBEDTLS_BYTES_TO_T_UINT_8(0x60, 0x53, 0x75, 0xED, 0xF2, 0x5F, 0xC2, 0xEB), - MBEDTLS_BYTES_TO_T_UINT_8(0x39, 0x87, 0x6B, 0x9F, 0x05, 0xE2, 0x22, 0x93), - MBEDTLS_BYTES_TO_T_UINT_8(0x4F, 0x1A, 0xA8, 0xB7, 0x03, 0x9E, 0x6D, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0xCB, 0xD0, 0x69, 0x88, 0xA8, 0x39, 0x9E, 0x3A), -}; -static const mbedtls_mpi_uint secp384r1_T_15_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF8, 0xEF, 0x68, 0xFE, 0xEC, 0x24, 0x08, 0x15), - MBEDTLS_BYTES_TO_T_UINT_8(0xA1, 0x06, 0x4B, 0x92, 0x0D, 0xB7, 0x34, 0x74), - MBEDTLS_BYTES_TO_T_UINT_8(0x3E, 0xF4, 0xDD, 0x1A, 0xA0, 0x4A, 0xE4, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0xC3, 0x63, 0x4F, 0x4F, 0xCE, 0xBB, 0xD6, 0xD3), - MBEDTLS_BYTES_TO_T_UINT_8(0xCD, 0xEE, 0x8D, 0xDF, 0x3F, 0x73, 0xB7, 0xAC), - MBEDTLS_BYTES_TO_T_UINT_8(0xDF, 0x06, 0xB6, 0x80, 0x4D, 0x81, 0xD9, 0x53), -}; -static const mbedtls_mpi_uint secp384r1_T_16_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0xF5, 0x13, 0xDF, 0x13, 0x19, 0x97, 0x94), - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0xF9, 0xB3, 0x33, 0x66, 0x82, 0x21, 0xFE), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0xFC, 0x39, 0x16, 0x23, 0x43, 0x76, 0x0E), - MBEDTLS_BYTES_TO_T_UINT_8(0x09, 0x48, 0x25, 0xA1, 0x64, 0x95, 0x1C, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0x43, 0xAC, 0x15, 0x57, 0xD9, 0xDE, 0xA0, 0x28), - MBEDTLS_BYTES_TO_T_UINT_8(0x16, 0x5F, 0xB8, 0x3D, 0x48, 0x91, 0x24, 0xCC), -}; -static const mbedtls_mpi_uint secp384r1_T_16_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x2D, 0xF2, 0xC8, 0x54, 0xD1, 0x32, 0xBD, 0xC4), - MBEDTLS_BYTES_TO_T_UINT_8(0x8A, 0x3B, 0xF0, 0xAA, 0x9D, 0xD8, 0xF4, 0x20), - MBEDTLS_BYTES_TO_T_UINT_8(0x4F, 0xC3, 0xBB, 0x6C, 0x66, 0xAC, 0x25, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0x6F, 0x25, 0x10, 0xB2, 0xE1, 0x41, 0xDE, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0x3C, 0xE8, 0x30, 0xB8, 0x37, 0xBC, 0x2A, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0x57, 0x01, 0x4A, 0x1E, 0x78, 0x9F, 0x85), -}; -static const mbedtls_mpi_uint secp384r1_T_17_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xBD, 0x19, 0xCD, 0x12, 0x0B, 0x51, 0x4F, 0x56), - MBEDTLS_BYTES_TO_T_UINT_8(0x30, 0x4B, 0x3D, 0x24, 0xA4, 0x16, 0x59, 0x05), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0xEB, 0xD3, 0x59, 0x2E, 0x75, 0x7C, 0x01), - MBEDTLS_BYTES_TO_T_UINT_8(0x8C, 0xB9, 0xB4, 0xA5, 0xD9, 0x2E, 0x29, 0x4C), - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0x16, 0x05, 0x75, 0x02, 0xB3, 0x06, 0xEE), - MBEDTLS_BYTES_TO_T_UINT_8(0xAB, 0x7C, 0x9F, 0x79, 0x91, 0xF1, 0x4F, 0x23), -}; -static const mbedtls_mpi_uint secp384r1_T_17_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x65, 0x98, 0x7C, 0x84, 0xE1, 0xFF, 0x30, 0x77), - MBEDTLS_BYTES_TO_T_UINT_8(0x71, 0xE2, 0xC2, 0x5F, 0x55, 0x40, 0xBD, 0xCD), - MBEDTLS_BYTES_TO_T_UINT_8(0x69, 0x65, 0x87, 0x3F, 0xC4, 0xC2, 0x24, 0x57), - MBEDTLS_BYTES_TO_T_UINT_8(0x0E, 0x30, 0x0A, 0x60, 0x15, 0xD1, 0x24, 0x48), - MBEDTLS_BYTES_TO_T_UINT_8(0x57, 0x99, 0xD9, 0xB6, 0xAE, 0xB1, 0xAF, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0x80, 0xEE, 0xA2, 0x0F, 0x74, 0xB9, 0xF3), -}; -static const mbedtls_mpi_uint secp384r1_T_18_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x03, 0xE6, 0x0F, 0x37, 0xC1, 0x10, 0x99, 0x1E), - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0xAD, 0x9D, 0x5D, 0x80, 0x01, 0xA6, 0xFE), - MBEDTLS_BYTES_TO_T_UINT_8(0xB0, 0x0F, 0x10, 0x2A, 0x9D, 0x20, 0x38, 0xEB), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x60, 0xCB, 0xCE, 0x5A, 0xA0, 0xA7, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0xCF, 0x14, 0xDF, 0xBF, 0xE5, 0x74, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0xB5, 0x12, 0x1A, 0xDD, 0x59, 0x02, 0x5D, 0xC6), -}; -static const mbedtls_mpi_uint secp384r1_T_18_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC8, 0xC9, 0xF8, 0xF5, 0xB6, 0x13, 0x4D, 0x7B), - MBEDTLS_BYTES_TO_T_UINT_8(0xED, 0x45, 0xB1, 0x93, 0xB3, 0xA2, 0x79, 0xDC), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0xF6, 0xCF, 0xF7, 0xE6, 0x29, 0x9C, 0xCC), - MBEDTLS_BYTES_TO_T_UINT_8(0x87, 0x50, 0x65, 0x80, 0xBC, 0x59, 0x0A, 0x59), - MBEDTLS_BYTES_TO_T_UINT_8(0x0E, 0xF0, 0x24, 0x35, 0xA2, 0x46, 0xF0, 0x0C), - MBEDTLS_BYTES_TO_T_UINT_8(0xBD, 0x26, 0xC0, 0x9D, 0x61, 0x56, 0x62, 0x67), -}; -static const mbedtls_mpi_uint secp384r1_T_19_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x10, 0xBB, 0xC2, 0x24, 0x43, 0x2E, 0x37, 0x54), - MBEDTLS_BYTES_TO_T_UINT_8(0x8A, 0xF7, 0xCE, 0x35, 0xFC, 0x77, 0xF3, 0x3F), - MBEDTLS_BYTES_TO_T_UINT_8(0x75, 0x34, 0x96, 0xD5, 0x4A, 0x76, 0x9D, 0x6B), - MBEDTLS_BYTES_TO_T_UINT_8(0xB8, 0x3B, 0x0F, 0xEA, 0xA8, 0x12, 0x0B, 0x22), - MBEDTLS_BYTES_TO_T_UINT_8(0x66, 0x3F, 0x5D, 0x2D, 0x1C, 0xD4, 0x9E, 0xFB), - MBEDTLS_BYTES_TO_T_UINT_8(0x7D, 0x2E, 0xDD, 0xC7, 0x6E, 0xAB, 0xAF, 0xDC), -}; -static const mbedtls_mpi_uint secp384r1_T_19_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x8C, 0xB2, 0x7B, 0x0C, 0x9A, 0x83, 0x8E, 0x59), - MBEDTLS_BYTES_TO_T_UINT_8(0x30, 0x51, 0x90, 0x92, 0x79, 0x32, 0x19, 0xC3), - MBEDTLS_BYTES_TO_T_UINT_8(0xEE, 0x89, 0xF9, 0xD0, 0xCF, 0x2C, 0xA5, 0x8F), - MBEDTLS_BYTES_TO_T_UINT_8(0x7B, 0x50, 0x21, 0xDE, 0x50, 0x41, 0x9D, 0x81), - MBEDTLS_BYTES_TO_T_UINT_8(0xE0, 0x7D, 0x2B, 0x9E, 0x9D, 0x95, 0xA8, 0xE3), - MBEDTLS_BYTES_TO_T_UINT_8(0xD8, 0xA5, 0x20, 0x87, 0x88, 0x97, 0x5F, 0xAA), -}; -static const mbedtls_mpi_uint secp384r1_T_20_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x64, 0x59, 0xB4, 0x66, 0x7E, 0xE8, 0x5A, 0x60), - MBEDTLS_BYTES_TO_T_UINT_8(0xA5, 0x5C, 0x7E, 0xB2, 0xAD, 0xD9, 0xC9, 0xDA), - MBEDTLS_BYTES_TO_T_UINT_8(0x82, 0x97, 0x49, 0xA3, 0x13, 0x83, 0x07, 0x2E), - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0x26, 0xC7, 0x13, 0x35, 0x0D, 0xB0, 0x6B), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0x60, 0xAB, 0xFA, 0x4B, 0x93, 0x18, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0x54, 0x2D, 0x1C, 0x31, 0x4C, 0xE4, 0x61, 0xAE), -}; -static const mbedtls_mpi_uint secp384r1_T_20_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xDE, 0x4D, 0x1E, 0x51, 0x59, 0x6E, 0x91, 0xC5), - MBEDTLS_BYTES_TO_T_UINT_8(0x38, 0x54, 0x4D, 0x51, 0xED, 0x36, 0xCC, 0x60), - MBEDTLS_BYTES_TO_T_UINT_8(0x18, 0xA8, 0x56, 0xC7, 0x78, 0x27, 0x33, 0xC5), - MBEDTLS_BYTES_TO_T_UINT_8(0x42, 0xB7, 0x95, 0xC9, 0x8B, 0xC8, 0x6A, 0xBC), - MBEDTLS_BYTES_TO_T_UINT_8(0x5E, 0xE9, 0x13, 0x96, 0xB3, 0xE1, 0xF9, 0xEE), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0x46, 0xB0, 0x5E, 0xC3, 0x94, 0x03, 0x05), -}; -static const mbedtls_mpi_uint secp384r1_T_21_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0x5B, 0x29, 0x30, 0x41, 0x1A, 0x9E, 0xB6), - MBEDTLS_BYTES_TO_T_UINT_8(0x76, 0xCA, 0x83, 0x31, 0x5B, 0xA7, 0xCB, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0x41, 0x50, 0x44, 0x4D, 0x64, 0x31, 0x89), - MBEDTLS_BYTES_TO_T_UINT_8(0xCF, 0x84, 0xC2, 0x5D, 0x97, 0xA5, 0x3C, 0x18), - MBEDTLS_BYTES_TO_T_UINT_8(0xF0, 0x0F, 0xA5, 0xFD, 0x8E, 0x5A, 0x47, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0x58, 0x02, 0x2D, 0x40, 0xB1, 0x0B, 0xBA), -}; -static const mbedtls_mpi_uint secp384r1_T_21_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xDA, 0x33, 0x8C, 0x67, 0xCE, 0x23, 0x43, 0x99), - MBEDTLS_BYTES_TO_T_UINT_8(0x84, 0x53, 0x47, 0x72, 0x44, 0x1F, 0x5B, 0x2A), - MBEDTLS_BYTES_TO_T_UINT_8(0xAE, 0xC1, 0xD9, 0xA4, 0x50, 0x88, 0x63, 0x18), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0xF2, 0x75, 0x69, 0x73, 0x00, 0xC4, 0x31), - MBEDTLS_BYTES_TO_T_UINT_8(0x4B, 0x90, 0x1D, 0xDF, 0x1A, 0x00, 0xD8, 0x69), - MBEDTLS_BYTES_TO_T_UINT_8(0x05, 0xB1, 0x89, 0x48, 0xA8, 0x70, 0x62, 0xEF), -}; -static const mbedtls_mpi_uint secp384r1_T_22_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x7E, 0x8A, 0x55, 0x50, 0x7B, 0xEF, 0x8A, 0x3C), - MBEDTLS_BYTES_TO_T_UINT_8(0xFE, 0x1B, 0x23, 0x48, 0x23, 0x63, 0x91, 0xB6), - MBEDTLS_BYTES_TO_T_UINT_8(0x0D, 0x04, 0x54, 0x3C, 0x24, 0x9B, 0xC7, 0x9A), - MBEDTLS_BYTES_TO_T_UINT_8(0x25, 0x38, 0xC3, 0x84, 0xFB, 0xFF, 0x9F, 0x49), - MBEDTLS_BYTES_TO_T_UINT_8(0x66, 0x2A, 0xE0, 0x6D, 0x68, 0x8A, 0x5C, 0xCB), - MBEDTLS_BYTES_TO_T_UINT_8(0xC4, 0x93, 0x53, 0x85, 0xA1, 0x0D, 0xAF, 0x63), -}; -static const mbedtls_mpi_uint secp384r1_T_22_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1B, 0x88, 0x95, 0x4C, 0x0B, 0xD0, 0x06, 0x51), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0xAF, 0x8D, 0x49, 0xA2, 0xC8, 0xB4, 0xE0), - MBEDTLS_BYTES_TO_T_UINT_8(0x75, 0x76, 0x53, 0x09, 0x88, 0x43, 0x87, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0x90, 0xA4, 0x77, 0x3F, 0x5E, 0x21, 0xB4, 0x0A), - MBEDTLS_BYTES_TO_T_UINT_8(0x35, 0x9E, 0x86, 0x64, 0xCC, 0x91, 0xC1, 0x77), - MBEDTLS_BYTES_TO_T_UINT_8(0xC1, 0x17, 0x56, 0xCB, 0xC3, 0x7D, 0x5B, 0xB1), -}; -static const mbedtls_mpi_uint secp384r1_T_23_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x64, 0x74, 0x9F, 0xB5, 0x91, 0x21, 0xB1, 0x1C), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0xED, 0xE1, 0x11, 0xEF, 0x45, 0xAF, 0xC1), - MBEDTLS_BYTES_TO_T_UINT_8(0xE0, 0x31, 0xBE, 0xB2, 0xBC, 0x72, 0x65, 0x1F), - MBEDTLS_BYTES_TO_T_UINT_8(0xB1, 0x4B, 0x8C, 0x77, 0xCE, 0x1E, 0x42, 0xB5), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xC9, 0xAA, 0xB9, 0xD9, 0x86, 0x99, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0x65, 0x23, 0x80, 0xC6, 0x4E, 0x35, 0x0B, 0x6D), -}; -static const mbedtls_mpi_uint secp384r1_T_23_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x47, 0xD8, 0xA2, 0x0A, 0x39, 0x32, 0x1D, 0x23), - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0xC8, 0x86, 0xF1, 0x12, 0x9A, 0x4A, 0x05), - MBEDTLS_BYTES_TO_T_UINT_8(0x8D, 0xF1, 0x7C, 0xAA, 0x70, 0x8E, 0xBC, 0x01), - MBEDTLS_BYTES_TO_T_UINT_8(0x62, 0x01, 0x47, 0x8F, 0xDD, 0x8B, 0xA5, 0xC8), - MBEDTLS_BYTES_TO_T_UINT_8(0xDB, 0x08, 0x21, 0xF4, 0xAB, 0xC7, 0xF5, 0x96), - MBEDTLS_BYTES_TO_T_UINT_8(0x0A, 0x76, 0xA5, 0x95, 0xC4, 0x0F, 0x88, 0x1D), -}; -static const mbedtls_mpi_uint secp384r1_T_24_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x3F, 0x42, 0x2A, 0x52, 0xCD, 0x75, 0x51, 0x49), - MBEDTLS_BYTES_TO_T_UINT_8(0x90, 0x36, 0xE5, 0x04, 0x2B, 0x44, 0xC6, 0xEF), - MBEDTLS_BYTES_TO_T_UINT_8(0x5C, 0xEE, 0x16, 0x13, 0x07, 0x83, 0xB5, 0x30), - MBEDTLS_BYTES_TO_T_UINT_8(0x76, 0x59, 0xC6, 0xA2, 0x19, 0x05, 0xD3, 0xC6), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x8B, 0xA8, 0x16, 0x09, 0xB7, 0xEA, 0xD6), - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0xEE, 0x14, 0xAF, 0xB5, 0xFD, 0xD0, 0xEF), -}; -static const mbedtls_mpi_uint secp384r1_T_24_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x18, 0x7C, 0xCA, 0x71, 0x3E, 0x6E, 0x66, 0x75), - MBEDTLS_BYTES_TO_T_UINT_8(0xBE, 0x31, 0x0E, 0x3F, 0xE5, 0x91, 0xC4, 0x7F), - MBEDTLS_BYTES_TO_T_UINT_8(0x8E, 0x3D, 0xC2, 0x3E, 0x95, 0x37, 0x58, 0x2B), - MBEDTLS_BYTES_TO_T_UINT_8(0x01, 0x1F, 0x02, 0x03, 0xF3, 0xEF, 0xEE, 0x66), - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0x5B, 0x1A, 0xFC, 0x38, 0xCD, 0xE8, 0x24), - MBEDTLS_BYTES_TO_T_UINT_8(0x12, 0x57, 0x42, 0x85, 0xC6, 0x21, 0x68, 0x71), -}; -static const mbedtls_mpi_uint secp384r1_T_25_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x8D, 0xA2, 0x4A, 0x66, 0xB1, 0x0A, 0xE6, 0xC0), - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0x0C, 0x94, 0x9D, 0x5E, 0x99, 0xB2, 0xCE), - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0x03, 0x40, 0xCA, 0xB2, 0xB3, 0x30, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0x78, 0x48, 0x27, 0x34, 0x1E, 0xE2, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0xAE, 0x72, 0x5B, 0xAC, 0xC1, 0x6D, 0xE3, 0x82), - MBEDTLS_BYTES_TO_T_UINT_8(0x57, 0xAB, 0x46, 0xCB, 0xEA, 0x5E, 0x4B, 0x0B), -}; -static const mbedtls_mpi_uint secp384r1_T_25_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0x08, 0xAD, 0x4E, 0x51, 0x9F, 0x2A, 0x52), - MBEDTLS_BYTES_TO_T_UINT_8(0x68, 0x5C, 0x7D, 0x4C, 0xD6, 0xCF, 0xDD, 0x02), - MBEDTLS_BYTES_TO_T_UINT_8(0xD8, 0x76, 0x26, 0xE0, 0x8B, 0x10, 0xD9, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0x30, 0xA7, 0x23, 0x4E, 0x5F, 0xD2, 0x42, 0x17), - MBEDTLS_BYTES_TO_T_UINT_8(0xD1, 0xE5, 0xA4, 0xEC, 0x77, 0x21, 0x34, 0x28), - MBEDTLS_BYTES_TO_T_UINT_8(0x5C, 0x14, 0x65, 0xEA, 0x4A, 0x85, 0xC3, 0x2F), -}; -static const mbedtls_mpi_uint secp384r1_T_26_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0xD8, 0x40, 0x27, 0x73, 0x15, 0x7E, 0x65), - MBEDTLS_BYTES_TO_T_UINT_8(0xF6, 0xBB, 0x53, 0x7E, 0x0F, 0x40, 0xC8, 0xD4), - MBEDTLS_BYTES_TO_T_UINT_8(0xEA, 0x37, 0x19, 0x73, 0xEF, 0x5A, 0x5E, 0x04), - MBEDTLS_BYTES_TO_T_UINT_8(0x9C, 0x73, 0x2B, 0x49, 0x7E, 0xAC, 0x97, 0x5C), - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0xB2, 0xC3, 0x1E, 0x0E, 0xE7, 0xD2, 0x21), - MBEDTLS_BYTES_TO_T_UINT_8(0x8A, 0x08, 0xD6, 0xDD, 0xAC, 0x21, 0xD6, 0x3E), -}; -static const mbedtls_mpi_uint secp384r1_T_26_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA9, 0x26, 0xBE, 0x6D, 0x6D, 0xF2, 0x38, 0x3F), - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0x6C, 0x31, 0xA7, 0x49, 0x50, 0x3A, 0x89), - MBEDTLS_BYTES_TO_T_UINT_8(0xC3, 0x99, 0xC6, 0xF5, 0xD2, 0xC2, 0x30, 0x5A), - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0xE4, 0xF6, 0x8B, 0x8B, 0x97, 0xE9, 0xB2), - MBEDTLS_BYTES_TO_T_UINT_8(0xDD, 0x21, 0xB7, 0x0D, 0xFC, 0x15, 0x54, 0x0B), - MBEDTLS_BYTES_TO_T_UINT_8(0x65, 0x83, 0x1C, 0xA4, 0xCD, 0x6B, 0x9D, 0xF2), -}; -static const mbedtls_mpi_uint secp384r1_T_27_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0xE8, 0x4C, 0x48, 0xE4, 0xAA, 0x69, 0x93), - MBEDTLS_BYTES_TO_T_UINT_8(0x27, 0x7A, 0x27, 0xFC, 0x37, 0x96, 0x1A, 0x7B), - MBEDTLS_BYTES_TO_T_UINT_8(0x6F, 0xE7, 0x30, 0xA5, 0xCF, 0x13, 0x46, 0x5C), - MBEDTLS_BYTES_TO_T_UINT_8(0x8C, 0xD8, 0xAF, 0x74, 0x23, 0x4D, 0x56, 0x84), - MBEDTLS_BYTES_TO_T_UINT_8(0x32, 0x3D, 0x44, 0x14, 0x1B, 0x97, 0x83, 0xF0), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0x47, 0xD7, 0x5F, 0xFD, 0x98, 0x38, 0xF7), -}; -static const mbedtls_mpi_uint secp384r1_T_27_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA3, 0x73, 0x64, 0x36, 0xFD, 0x7B, 0xC1, 0x15), - MBEDTLS_BYTES_TO_T_UINT_8(0xEA, 0x5D, 0x32, 0xD2, 0x47, 0x94, 0x89, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0x51, 0xE9, 0x30, 0xAC, 0x06, 0xC8, 0x65, 0x04), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0x6C, 0xB9, 0x1B, 0xF7, 0x61, 0x49, 0x53), - MBEDTLS_BYTES_TO_T_UINT_8(0xD7, 0xFF, 0x32, 0x43, 0x80, 0xDA, 0xA6, 0xB1), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0xF8, 0x04, 0x01, 0x95, 0x35, 0xCE, 0x21), -}; -static const mbedtls_mpi_uint secp384r1_T_28_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0x06, 0x46, 0x0D, 0x51, 0xE2, 0xD8, 0xAC), - MBEDTLS_BYTES_TO_T_UINT_8(0x14, 0x57, 0x1D, 0x6F, 0x79, 0xA0, 0xCD, 0xA6), - MBEDTLS_BYTES_TO_T_UINT_8(0xDF, 0xFB, 0x36, 0xCA, 0xAD, 0xF5, 0x9E, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0x6F, 0x7A, 0x1D, 0x9E, 0x1D, 0x95, 0x48, 0xDC), - MBEDTLS_BYTES_TO_T_UINT_8(0x81, 0x26, 0xA5, 0xB7, 0x15, 0x2C, 0xC2, 0xC6), - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0x42, 0x72, 0xAA, 0x11, 0xDC, 0xC9, 0xB6), -}; -static const mbedtls_mpi_uint secp384r1_T_28_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x3F, 0x6C, 0x64, 0xA7, 0x62, 0x3C, 0xAB, 0xD4), - MBEDTLS_BYTES_TO_T_UINT_8(0x48, 0x6A, 0x44, 0xD8, 0x60, 0xC0, 0xA8, 0x80), - MBEDTLS_BYTES_TO_T_UINT_8(0x82, 0x76, 0x58, 0x12, 0x57, 0x3C, 0x89, 0x46), - MBEDTLS_BYTES_TO_T_UINT_8(0x82, 0x4F, 0x83, 0xCE, 0xCB, 0xB8, 0xD0, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0x9A, 0x84, 0x04, 0xB0, 0xAD, 0xEB, 0xFA, 0xDF), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0xA4, 0xC3, 0x41, 0x44, 0x4E, 0x65, 0x3E), -}; -static const mbedtls_mpi_uint secp384r1_T_29_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x16, 0xA9, 0x1C, 0xE7, 0x65, 0x20, 0xC1), - MBEDTLS_BYTES_TO_T_UINT_8(0x58, 0x53, 0x32, 0xF8, 0xC0, 0xA6, 0xBD, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0xF0, 0xE6, 0x57, 0x31, 0xCC, 0x26, 0x6F), - MBEDTLS_BYTES_TO_T_UINT_8(0x27, 0xE3, 0x54, 0x1C, 0x34, 0xD3, 0x17, 0xBC), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0xAE, 0xED, 0xFB, 0xCD, 0xE7, 0x1E, 0x9F), - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0x16, 0x1C, 0x34, 0x40, 0x00, 0x1F, 0xB6), -}; -static const mbedtls_mpi_uint secp384r1_T_29_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x6A, 0x32, 0x00, 0xC2, 0xD4, 0x3B, 0x1A, 0x09), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0xE0, 0x99, 0x8F, 0x0C, 0x4A, 0x16, 0x44), - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0x73, 0x18, 0x1B, 0xD4, 0x94, 0x29, 0x62), - MBEDTLS_BYTES_TO_T_UINT_8(0x29, 0xA4, 0x2D, 0xB1, 0x9D, 0x74, 0x32, 0x67), - MBEDTLS_BYTES_TO_T_UINT_8(0xBF, 0xF4, 0xB1, 0x0C, 0x37, 0x62, 0x8B, 0x66), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0xFF, 0xDA, 0xE2, 0x35, 0xA3, 0xB6, 0x42), -}; -static const mbedtls_mpi_uint secp384r1_T_30_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x91, 0x49, 0x99, 0x65, 0xC5, 0xED, 0x16, 0xEF), - MBEDTLS_BYTES_TO_T_UINT_8(0x79, 0x42, 0x9A, 0xF3, 0xA7, 0x4E, 0x6F, 0x2B), - MBEDTLS_BYTES_TO_T_UINT_8(0x7B, 0x0A, 0x7E, 0xC0, 0xD7, 0x4E, 0x07, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0x7A, 0x31, 0x69, 0xA6, 0xB9, 0x15, 0x34), - MBEDTLS_BYTES_TO_T_UINT_8(0xA8, 0xE0, 0x72, 0xA4, 0x3F, 0xB9, 0xF8, 0x0C), - MBEDTLS_BYTES_TO_T_UINT_8(0x2B, 0x75, 0x32, 0x85, 0xA2, 0xDE, 0x37, 0x12), -}; -static const mbedtls_mpi_uint secp384r1_T_30_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0xC0, 0x0D, 0xCF, 0x25, 0x41, 0xA4, 0xF4), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0xFC, 0xB2, 0x48, 0xC3, 0x85, 0x83, 0x4B), - MBEDTLS_BYTES_TO_T_UINT_8(0x2B, 0xBE, 0x0B, 0x58, 0x2D, 0x7A, 0x9A, 0x62), - MBEDTLS_BYTES_TO_T_UINT_8(0xC5, 0xF3, 0x81, 0x18, 0x1B, 0x74, 0x4F, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0xE2, 0x43, 0xA3, 0x0A, 0x16, 0x8B, 0xA3, 0x1E), - MBEDTLS_BYTES_TO_T_UINT_8(0x4A, 0x18, 0x81, 0x7B, 0x8D, 0xA2, 0x35, 0x77), -}; -static const mbedtls_mpi_uint secp384r1_T_31_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0xC4, 0x3F, 0x2C, 0xE7, 0x5F, 0x99, 0x03), - MBEDTLS_BYTES_TO_T_UINT_8(0xF0, 0x2B, 0xB7, 0xB6, 0xAD, 0x5A, 0x56, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0x04, 0x00, 0xA4, 0x48, 0xC8, 0xE8, 0xBA, 0xBF), - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0xA1, 0xB5, 0x13, 0x5A, 0xCD, 0x99, 0x9C), - MBEDTLS_BYTES_TO_T_UINT_8(0xB0, 0x95, 0xAD, 0xFC, 0xE2, 0x7E, 0xE7, 0xFE), - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0x6B, 0xD1, 0x34, 0x99, 0x53, 0x63, 0x0B), -}; -static const mbedtls_mpi_uint secp384r1_T_31_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0x8A, 0x77, 0x5D, 0x2B, 0xAB, 0x01, 0x28), - MBEDTLS_BYTES_TO_T_UINT_8(0x4E, 0x85, 0xD0, 0xD5, 0x49, 0x83, 0x4D, 0x60), - MBEDTLS_BYTES_TO_T_UINT_8(0x81, 0xC6, 0x91, 0x30, 0x3B, 0x00, 0xAF, 0x7A), - MBEDTLS_BYTES_TO_T_UINT_8(0x3A, 0xAE, 0x61, 0x07, 0xE1, 0xB6, 0xE2, 0xC9), - MBEDTLS_BYTES_TO_T_UINT_8(0x95, 0x43, 0x41, 0xFE, 0x9B, 0xB6, 0xF0, 0xA5), - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0x97, 0xAE, 0xAD, 0x89, 0x88, 0x9E, 0x41), -}; -static const mbedtls_ecp_point secp384r1_T[32] = { - ECP_POINT_INIT_XY_Z1(secp384r1_T_0_X, secp384r1_T_0_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_1_X, secp384r1_T_1_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_2_X, secp384r1_T_2_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_3_X, secp384r1_T_3_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_4_X, secp384r1_T_4_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_5_X, secp384r1_T_5_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_6_X, secp384r1_T_6_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_7_X, secp384r1_T_7_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_8_X, secp384r1_T_8_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_9_X, secp384r1_T_9_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_10_X, secp384r1_T_10_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_11_X, secp384r1_T_11_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_12_X, secp384r1_T_12_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_13_X, secp384r1_T_13_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_14_X, secp384r1_T_14_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_15_X, secp384r1_T_15_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_16_X, secp384r1_T_16_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_17_X, secp384r1_T_17_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_18_X, secp384r1_T_18_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_19_X, secp384r1_T_19_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_20_X, secp384r1_T_20_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_21_X, secp384r1_T_21_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_22_X, secp384r1_T_22_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_23_X, secp384r1_T_23_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_24_X, secp384r1_T_24_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_25_X, secp384r1_T_25_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_26_X, secp384r1_T_26_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_27_X, secp384r1_T_27_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_28_X, secp384r1_T_28_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_29_X, secp384r1_T_29_Y), - ECP_POINT_INIT_XY_Z0(secp384r1_T_30_X, secp384r1_T_30_Y), ECP_POINT_INIT_XY_Z0(secp384r1_T_31_X, secp384r1_T_31_Y), -}; -#else -#define secp384r1_T NULL -#endif - -#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */ - -/* - * Domain parameters for secp521r1 - */ -#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) -static const mbedtls_mpi_uint secp521r1_p[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_2(0xFF, 0x01), -}; -static const mbedtls_mpi_uint secp521r1_b[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x3F, 0x50, 0x6B, 0xD4, 0x1F, 0x45, 0xEF), - MBEDTLS_BYTES_TO_T_UINT_8(0xF1, 0x34, 0x2C, 0x3D, 0x88, 0xDF, 0x73, 0x35), - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0xBF, 0xB1, 0x3B, 0xBD, 0xC0, 0x52, 0x16), - MBEDTLS_BYTES_TO_T_UINT_8(0x7B, 0x93, 0x7E, 0xEC, 0x51, 0x39, 0x19, 0x56), - MBEDTLS_BYTES_TO_T_UINT_8(0xE1, 0x09, 0xF1, 0x8E, 0x91, 0x89, 0xB4, 0xB8), - MBEDTLS_BYTES_TO_T_UINT_8(0xF3, 0x15, 0xB3, 0x99, 0x5B, 0x72, 0xDA, 0xA2), - MBEDTLS_BYTES_TO_T_UINT_8(0xEE, 0x40, 0x85, 0xB6, 0xA0, 0x21, 0x9A, 0x92), - MBEDTLS_BYTES_TO_T_UINT_8(0x1F, 0x9A, 0x1C, 0x8E, 0x61, 0xB9, 0x3E, 0x95), - MBEDTLS_BYTES_TO_T_UINT_2(0x51, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_gx[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x66, 0xBD, 0xE5, 0xC2, 0x31, 0x7E, 0x7E, 0xF9), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0x42, 0x6A, 0x85, 0xC1, 0xB3, 0x48, 0x33), - MBEDTLS_BYTES_TO_T_UINT_8(0xDE, 0xA8, 0xFF, 0xA2, 0x27, 0xC1, 0x1D, 0xFE), - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0x59, 0xE7, 0xEF, 0x77, 0x5E, 0x4B, 0xA1), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0x3D, 0x4D, 0x6B, 0x60, 0xAF, 0x28, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0xB5, 0x3F, 0x05, 0x39, 0x81, 0x64, 0x9C), - MBEDTLS_BYTES_TO_T_UINT_8(0x42, 0xB4, 0x95, 0x23, 0x66, 0xCB, 0x3E, 0x9E), - MBEDTLS_BYTES_TO_T_UINT_8(0xCD, 0xE9, 0x04, 0x04, 0xB7, 0x06, 0x8E, 0x85), - MBEDTLS_BYTES_TO_T_UINT_2(0xC6, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_gy[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x50, 0x66, 0xD1, 0x9F, 0x76, 0x94, 0xBE, 0x88), - MBEDTLS_BYTES_TO_T_UINT_8(0x40, 0xC2, 0x72, 0xA2, 0x86, 0x70, 0x3C, 0x35), - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0x07, 0xAD, 0x3F, 0x01, 0xB9, 0x50, 0xC5), - MBEDTLS_BYTES_TO_T_UINT_8(0x40, 0x26, 0xF4, 0x5E, 0x99, 0x72, 0xEE, 0x97), - MBEDTLS_BYTES_TO_T_UINT_8(0x2C, 0x66, 0x3E, 0x27, 0x17, 0xBD, 0xAF, 0x17), - MBEDTLS_BYTES_TO_T_UINT_8(0x68, 0x44, 0x9B, 0x57, 0x49, 0x44, 0xF5, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0x1B, 0x7D, 0x2C, 0xB4, 0x5F, 0x8A, 0x5C), - MBEDTLS_BYTES_TO_T_UINT_8(0x04, 0xC0, 0x3B, 0x9A, 0x78, 0x6A, 0x29, 0x39), - MBEDTLS_BYTES_TO_T_UINT_2(0x18, 0x01), -}; -static const mbedtls_mpi_uint secp521r1_n[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x09, 0x64, 0x38, 0x91, 0x1E, 0xB7, 0x6F, 0xBB), - MBEDTLS_BYTES_TO_T_UINT_8(0xAE, 0x47, 0x9C, 0x89, 0xB8, 0xC9, 0xB5, 0x3B), - MBEDTLS_BYTES_TO_T_UINT_8(0xD0, 0xA5, 0x09, 0xF7, 0x48, 0x01, 0xCC, 0x7F), - MBEDTLS_BYTES_TO_T_UINT_8(0x6B, 0x96, 0x2F, 0xBF, 0x83, 0x87, 0x86, 0x51), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_2(0xFF, 0x01), -}; -#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 -static const mbedtls_mpi_uint secp521r1_T_0_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x66, 0xBD, 0xE5, 0xC2, 0x31, 0x7E, 0x7E, 0xF9), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0x42, 0x6A, 0x85, 0xC1, 0xB3, 0x48, 0x33), - MBEDTLS_BYTES_TO_T_UINT_8(0xDE, 0xA8, 0xFF, 0xA2, 0x27, 0xC1, 0x1D, 0xFE), - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0x59, 0xE7, 0xEF, 0x77, 0x5E, 0x4B, 0xA1), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0x3D, 0x4D, 0x6B, 0x60, 0xAF, 0x28, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0xB5, 0x3F, 0x05, 0x39, 0x81, 0x64, 0x9C), - MBEDTLS_BYTES_TO_T_UINT_8(0x42, 0xB4, 0x95, 0x23, 0x66, 0xCB, 0x3E, 0x9E), - MBEDTLS_BYTES_TO_T_UINT_8(0xCD, 0xE9, 0x04, 0x04, 0xB7, 0x06, 0x8E, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_0_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x50, 0x66, 0xD1, 0x9F, 0x76, 0x94, 0xBE, 0x88), - MBEDTLS_BYTES_TO_T_UINT_8(0x40, 0xC2, 0x72, 0xA2, 0x86, 0x70, 0x3C, 0x35), - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0x07, 0xAD, 0x3F, 0x01, 0xB9, 0x50, 0xC5), - MBEDTLS_BYTES_TO_T_UINT_8(0x40, 0x26, 0xF4, 0x5E, 0x99, 0x72, 0xEE, 0x97), - MBEDTLS_BYTES_TO_T_UINT_8(0x2C, 0x66, 0x3E, 0x27, 0x17, 0xBD, 0xAF, 0x17), - MBEDTLS_BYTES_TO_T_UINT_8(0x68, 0x44, 0x9B, 0x57, 0x49, 0x44, 0xF5, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0x1B, 0x7D, 0x2C, 0xB4, 0x5F, 0x8A, 0x5C), - MBEDTLS_BYTES_TO_T_UINT_8(0x04, 0xC0, 0x3B, 0x9A, 0x78, 0x6A, 0x29, 0x39), - MBEDTLS_BYTES_TO_T_UINT_8(0x18, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_1_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x2F, 0xB1, 0x2D, 0xEB, 0x27, 0x2F, 0xE8, 0xDA), - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0x4B, 0x44, 0x25, 0xDB, 0x5C, 0x5F, 0x67), - MBEDTLS_BYTES_TO_T_UINT_8(0x13, 0x85, 0x28, 0x78, 0x2E, 0x75, 0x34, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0x69, 0x57, 0x0F, 0x73, 0x78, 0x7A, 0xE3, 0x53), - MBEDTLS_BYTES_TO_T_UINT_8(0x8D, 0xD8, 0xEC, 0xDC, 0xDA, 0x04, 0xAD, 0xAB), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0x8A, 0x09, 0xF3, 0x58, 0x79, 0xD8, 0x29), - MBEDTLS_BYTES_TO_T_UINT_8(0x63, 0x03, 0xCB, 0x50, 0x1A, 0x7F, 0x56, 0x00), - MBEDTLS_BYTES_TO_T_UINT_8(0xF6, 0xA6, 0x78, 0x38, 0x85, 0x67, 0x0B, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_1_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x8A, 0xD5, 0xD2, 0x22, 0xC4, 0x00, 0x3B, 0xBA), - MBEDTLS_BYTES_TO_T_UINT_8(0xD5, 0x93, 0x0E, 0x7B, 0x85, 0x51, 0xC3, 0x06), - MBEDTLS_BYTES_TO_T_UINT_8(0x3D, 0xA6, 0x5F, 0x54, 0x49, 0x02, 0x81, 0x78), - MBEDTLS_BYTES_TO_T_UINT_8(0x22, 0xE9, 0x6B, 0x3A, 0x92, 0xE7, 0x72, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0x6F, 0x5F, 0x28, 0x9E, 0x91, 0x27, 0x88, 0xE3), - MBEDTLS_BYTES_TO_T_UINT_8(0xEF, 0x28, 0x31, 0xB3, 0x84, 0xCA, 0x12, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0x3D, 0xF9, 0xAC, 0x22, 0x10, 0x0A, 0x64, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0xE9, 0xC6, 0x33, 0x1F, 0x69, 0x19, 0x18, 0xBF), - MBEDTLS_BYTES_TO_T_UINT_8(0xBE, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_2_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0x48, 0xB8, 0xC7, 0x37, 0x5A, 0x00, 0x36), - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0xCC, 0x32, 0xE0, 0xEE, 0x03, 0xC2, 0xBA), - MBEDTLS_BYTES_TO_T_UINT_8(0xC4, 0x29, 0xC2, 0xE4, 0x6E, 0x24, 0x20, 0x8D), - MBEDTLS_BYTES_TO_T_UINT_8(0x06, 0x6B, 0x7F, 0x7B, 0xF9, 0xB0, 0xB8, 0x13), - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0x7B, 0x3C, 0xE1, 0x19, 0xA1, 0x23, 0x02), - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0xE3, 0xC2, 0x53, 0xC0, 0x07, 0x13, 0xA9), - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0xFE, 0x36, 0x35, 0x9F, 0x5E, 0x59, 0xCE), - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0x55, 0x89, 0x84, 0xBC, 0xEF, 0xA2, 0xC2), - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_2_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFD, 0x1A, 0x08, 0x67, 0xB4, 0xE7, 0x22, 0xED), - MBEDTLS_BYTES_TO_T_UINT_8(0x76, 0x26, 0xDF, 0x81, 0x3C, 0x5F, 0x1C, 0xDA), - MBEDTLS_BYTES_TO_T_UINT_8(0xE0, 0x4D, 0xD0, 0x0A, 0x48, 0x06, 0xF4, 0x48), - MBEDTLS_BYTES_TO_T_UINT_8(0x73, 0x18, 0x39, 0xF7, 0xD1, 0x20, 0x77, 0x8D), - MBEDTLS_BYTES_TO_T_UINT_8(0x78, 0x8F, 0x44, 0x13, 0xCB, 0x78, 0x11, 0x11), - MBEDTLS_BYTES_TO_T_UINT_8(0x33, 0xE2, 0x49, 0xEA, 0x43, 0x79, 0x08, 0x39), - MBEDTLS_BYTES_TO_T_UINT_8(0x01, 0xD1, 0xD8, 0x73, 0x2C, 0x71, 0x2F, 0x69), - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0xE5, 0xE7, 0xF4, 0x46, 0xAB, 0x20, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_3_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x8C, 0x0B, 0xB9, 0x71, 0x1A, 0x27, 0xB7, 0xA7), - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0xA2, 0x2C, 0xD1, 0xDA, 0xBC, 0xC1, 0xBD), - MBEDTLS_BYTES_TO_T_UINT_8(0x10, 0xA3, 0x10, 0x1F, 0x90, 0xF2, 0xA5, 0x52), - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0xFB, 0x20, 0xF4, 0xC0, 0x70, 0xC0, 0xF5), - MBEDTLS_BYTES_TO_T_UINT_8(0x8F, 0xA7, 0x99, 0xF0, 0xA5, 0xD3, 0x09, 0xDD), - MBEDTLS_BYTES_TO_T_UINT_8(0x26, 0xE8, 0x14, 0x39, 0xBE, 0xCB, 0x60, 0xAF), - MBEDTLS_BYTES_TO_T_UINT_8(0x9F, 0xD6, 0x14, 0xA9, 0xC9, 0x20, 0xC3, 0xEA), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0xA8, 0x5B, 0xFD, 0x2D, 0x96, 0xBC, 0x78), - MBEDTLS_BYTES_TO_T_UINT_8(0xC0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_3_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x9D, 0x04, 0x45, 0xBE, 0xCE, 0x75, 0x95, 0xF6), - MBEDTLS_BYTES_TO_T_UINT_8(0xCC, 0xDA, 0x58, 0x49, 0x35, 0x09, 0x8D, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0x76, 0xF0, 0xC0, 0x36, 0xF2, 0xA6, 0x2D, 0x14), - MBEDTLS_BYTES_TO_T_UINT_8(0xE7, 0xFC, 0x3D, 0xA8, 0xFB, 0x3C, 0xD2, 0x51), - MBEDTLS_BYTES_TO_T_UINT_8(0x01, 0x4D, 0x71, 0x09, 0x18, 0x42, 0xF0, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0x8D, 0xC1, 0xCE, 0x9E, 0x6A, 0x49, 0x60, 0x12), - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0xB1, 0x00, 0xF7, 0xA1, 0x7A, 0x31, 0xB4), - MBEDTLS_BYTES_TO_T_UINT_8(0x41, 0xC3, 0x86, 0xCD, 0x20, 0x4A, 0x17, 0x86), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_4_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0xAB, 0x8B, 0x47, 0x8D, 0xAA, 0xA6, 0x5B), - MBEDTLS_BYTES_TO_T_UINT_8(0xC4, 0x97, 0xF0, 0xBC, 0x2D, 0xDC, 0x9D, 0x84), - MBEDTLS_BYTES_TO_T_UINT_8(0x01, 0x86, 0xB0, 0x74, 0xB2, 0xF4, 0xF6, 0x67), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0xBD, 0xAC, 0xE3, 0x8F, 0x43, 0x5C, 0xB1), - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0xC3, 0xE2, 0x6E, 0x25, 0x49, 0xCD, 0x0B), - MBEDTLS_BYTES_TO_T_UINT_8(0x64, 0x5E, 0x08, 0xB3, 0xB9, 0xAC, 0x5F, 0xD1), - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0xB7, 0xD1, 0xF4, 0xDC, 0x19, 0xE9, 0xC8), - MBEDTLS_BYTES_TO_T_UINT_8(0x49, 0xE4, 0xFA, 0xE1, 0x36, 0x3E, 0xED, 0x6E), - MBEDTLS_BYTES_TO_T_UINT_8(0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_4_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x67, 0x92, 0x84, 0x6E, 0x48, 0x03, 0x51), - MBEDTLS_BYTES_TO_T_UINT_8(0x9E, 0x95, 0xEF, 0x8F, 0xB2, 0x82, 0x6B, 0x1C), - MBEDTLS_BYTES_TO_T_UINT_8(0x8D, 0xFA, 0xB9, 0x55, 0x23, 0xFE, 0x09, 0xB3), - MBEDTLS_BYTES_TO_T_UINT_8(0xEF, 0x79, 0x85, 0x4B, 0x0E, 0xD4, 0x35, 0xDB), - MBEDTLS_BYTES_TO_T_UINT_8(0x9A, 0x27, 0x45, 0x81, 0xE0, 0x88, 0x52, 0xAD), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0x63, 0xA2, 0x4B, 0xBC, 0x5D, 0xB1, 0x92), - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0x8C, 0x83, 0xD9, 0x3E, 0xD3, 0x42, 0xDA), - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0x03, 0x3A, 0x31, 0xBA, 0xE9, 0x3A, 0xD1), - MBEDTLS_BYTES_TO_T_UINT_8(0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_5_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x35, 0x10, 0xCD, 0x2D, 0x00, 0xFE, 0x32, 0xA7), - MBEDTLS_BYTES_TO_T_UINT_8(0xE4, 0x6E, 0x1F, 0xDA, 0xF8, 0x6F, 0x4D, 0x03), - MBEDTLS_BYTES_TO_T_UINT_8(0x09, 0x79, 0x7D, 0x09, 0xE5, 0xD3, 0x03, 0x21), - MBEDTLS_BYTES_TO_T_UINT_8(0x58, 0xC3, 0xBE, 0xDF, 0x07, 0x65, 0x49, 0xCC), - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0x57, 0x33, 0xEF, 0xAE, 0x4F, 0x04, 0x27), - MBEDTLS_BYTES_TO_T_UINT_8(0x9A, 0xE9, 0x9B, 0xFE, 0xBF, 0xE6, 0x85, 0xF6), - MBEDTLS_BYTES_TO_T_UINT_8(0xBD, 0xBA, 0xAA, 0x06, 0xC4, 0xC6, 0xB8, 0x57), - MBEDTLS_BYTES_TO_T_UINT_8(0x0C, 0x83, 0x01, 0xA9, 0xF6, 0x51, 0xE7, 0xB8), - MBEDTLS_BYTES_TO_T_UINT_8(0x1B, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_5_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB9, 0xA6, 0x15, 0x8E, 0xAB, 0x1F, 0x10, 0x87), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0x08, 0x27, 0x1A, 0xA1, 0x21, 0xAD, 0xF5), - MBEDTLS_BYTES_TO_T_UINT_8(0x02, 0x09, 0x90, 0x6E, 0x50, 0x90, 0x9A, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0x9A, 0xFE, 0xD7, 0xA1, 0xF5, 0xA2, 0x15), - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0x7D, 0xE3, 0xDC, 0x21, 0xFB, 0xA4, 0x7B), - MBEDTLS_BYTES_TO_T_UINT_8(0xB9, 0xBF, 0x07, 0xFF, 0x45, 0xDF, 0x51, 0x77), - MBEDTLS_BYTES_TO_T_UINT_8(0x0B, 0x5C, 0x34, 0x02, 0x62, 0x9B, 0x08, 0x12), - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0xCE, 0x9A, 0x6A, 0xEC, 0x75, 0xF6, 0x46), - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_6_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0x59, 0xF4, 0x78, 0x3C, 0x60, 0xB1, 0x4A), - MBEDTLS_BYTES_TO_T_UINT_8(0x3E, 0x37, 0x84, 0x6A, 0xDC, 0xF2, 0x9A, 0x7D), - MBEDTLS_BYTES_TO_T_UINT_8(0x40, 0x9A, 0x9A, 0x15, 0x36, 0xE0, 0x2B, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0xEC, 0x38, 0x9C, 0x50, 0x3D, 0x1E, 0x37, 0x82), - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0x79, 0xF0, 0x92, 0xF2, 0x8B, 0x18, 0x82), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0xE0, 0x82, 0x1E, 0x80, 0x82, 0x4B, 0xD7), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0xBB, 0x59, 0x6B, 0x8A, 0x77, 0x41, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0xF9, 0xD4, 0xB8, 0x4A, 0x82, 0xCF, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_6_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0x8C, 0xC8, 0x9B, 0x72, 0x9E, 0xF7, 0xF9), - MBEDTLS_BYTES_TO_T_UINT_8(0xB8, 0xCE, 0xE9, 0x77, 0x0A, 0x19, 0x59, 0x84), - MBEDTLS_BYTES_TO_T_UINT_8(0x9D, 0xA1, 0x41, 0x6A, 0x72, 0x4B, 0xB4, 0xDC), - MBEDTLS_BYTES_TO_T_UINT_8(0x0B, 0x35, 0x43, 0xE2, 0x8C, 0xBE, 0x0D, 0xE3), - MBEDTLS_BYTES_TO_T_UINT_8(0xC1, 0xEB, 0xAD, 0xF3, 0xA9, 0xA6, 0x68, 0xA1), - MBEDTLS_BYTES_TO_T_UINT_8(0x81, 0x2F, 0xE2, 0x48, 0x0C, 0xDB, 0x1F, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0xD1, 0x1E, 0x60, 0x9B, 0x2A, 0xD2, 0xC1, 0x3C), - MBEDTLS_BYTES_TO_T_UINT_8(0xC0, 0x64, 0xB5, 0xD2, 0xF6, 0xF6, 0x6E, 0x22), - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_7_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC6, 0x3D, 0x30, 0x78, 0x10, 0x18, 0x41, 0x51), - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0x1D, 0x1C, 0xE0, 0x6D, 0x83, 0xD1, 0x93), - MBEDTLS_BYTES_TO_T_UINT_8(0x7B, 0x03, 0x0B, 0xF5, 0x2F, 0x6C, 0x04, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x3E, 0xD5, 0xFC, 0x31, 0x5B, 0x3A, 0xEB), - MBEDTLS_BYTES_TO_T_UINT_8(0x50, 0x82, 0x2F, 0xFB, 0xFE, 0xF8, 0x76, 0x39), - MBEDTLS_BYTES_TO_T_UINT_8(0x85, 0x26, 0xDA, 0x9C, 0x36, 0xF5, 0x93, 0xD1), - MBEDTLS_BYTES_TO_T_UINT_8(0x4C, 0xE7, 0x6E, 0xD2, 0x7D, 0x81, 0x09, 0xC6), - MBEDTLS_BYTES_TO_T_UINT_8(0xD3, 0x03, 0xF9, 0x58, 0x48, 0x24, 0xA2, 0xEE), - MBEDTLS_BYTES_TO_T_UINT_8(0xE9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_7_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1B, 0x79, 0x0C, 0x8E, 0x6B, 0x95, 0xF3, 0xC4), - MBEDTLS_BYTES_TO_T_UINT_8(0xF4, 0x10, 0x5C, 0x87, 0x03, 0x39, 0xCF, 0x68), - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0xF0, 0xF7, 0xC1, 0x07, 0xA4, 0xF4, 0x3F), - MBEDTLS_BYTES_TO_T_UINT_8(0x32, 0xE8, 0x02, 0x89, 0x65, 0xC4, 0x72, 0x36), - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0x88, 0xEA, 0x96, 0x67, 0x0B, 0x5D, 0xDF), - MBEDTLS_BYTES_TO_T_UINT_8(0xA8, 0x75, 0x60, 0xA8, 0xBD, 0x74, 0xDF, 0x68), - MBEDTLS_BYTES_TO_T_UINT_8(0x6E, 0xE5, 0x71, 0x50, 0x67, 0xD0, 0xD2, 0xE6), - MBEDTLS_BYTES_TO_T_UINT_8(0xD5, 0xFC, 0xE5, 0xC7, 0x77, 0xB0, 0x7F, 0x8C), - MBEDTLS_BYTES_TO_T_UINT_8(0xF1, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_8_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x97, 0x86, 0x69, 0xCD, 0x0D, 0x9A, 0xBD, 0x66), - MBEDTLS_BYTES_TO_T_UINT_8(0x58, 0x17, 0xBC, 0xBB, 0x59, 0x85, 0x7D, 0x0E), - MBEDTLS_BYTES_TO_T_UINT_8(0x8D, 0xA8, 0x76, 0xAC, 0x80, 0xA9, 0x72, 0xE0), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0x78, 0xC1, 0xE2, 0x4D, 0xAF, 0xF9, 0x3C), - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0x97, 0x8E, 0x74, 0xC4, 0x4B, 0xB2, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0xEA, 0xD8, 0xF6, 0xF3, 0xAF, 0x2F, 0x52, 0xE5), - MBEDTLS_BYTES_TO_T_UINT_8(0x95, 0x57, 0xF4, 0xCE, 0xEE, 0x43, 0xED, 0x60), - MBEDTLS_BYTES_TO_T_UINT_8(0x7D, 0x46, 0x38, 0xDE, 0x20, 0xFD, 0x59, 0x18), - MBEDTLS_BYTES_TO_T_UINT_8(0xD7, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_8_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0x18, 0xE8, 0x58, 0xB9, 0x76, 0x2C, 0xE6), - MBEDTLS_BYTES_TO_T_UINT_8(0xED, 0x54, 0xE4, 0xFE, 0xC7, 0xBC, 0x31, 0x37), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0xF8, 0x89, 0xEE, 0x70, 0xB5, 0xB0, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0x22, 0x26, 0x9A, 0x53, 0xB9, 0x38, 0x0A), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0xA7, 0x19, 0x8C, 0x74, 0x7E, 0x88, 0x46), - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0xDA, 0x0A, 0xE8, 0xDA, 0xA5, 0xBE, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0x90, 0x5C, 0xF7, 0xB1, 0x0C, 0x72, 0xFB, 0x09), - MBEDTLS_BYTES_TO_T_UINT_8(0x78, 0xE2, 0x23, 0xE7, 0x46, 0xB7, 0xE0, 0x91), - MBEDTLS_BYTES_TO_T_UINT_8(0xC5, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_9_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x3A, 0x36, 0xBC, 0xBD, 0x48, 0x11, 0x8E, 0x72), - MBEDTLS_BYTES_TO_T_UINT_8(0xAB, 0xBB, 0xA1, 0xF7, 0x0B, 0x9E, 0xBF, 0xDF), - MBEDTLS_BYTES_TO_T_UINT_8(0x68, 0x28, 0xE1, 0xA2, 0x8F, 0xFC, 0xFC, 0xD6), - MBEDTLS_BYTES_TO_T_UINT_8(0x81, 0xFE, 0x19, 0x0A, 0xE5, 0xE7, 0x69, 0x39), - MBEDTLS_BYTES_TO_T_UINT_8(0x5E, 0xCD, 0x12, 0xF5, 0xBE, 0xD3, 0x04, 0xF1), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0xA8, 0x0D, 0x81, 0x59, 0xC4, 0x79, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0xA3, 0xF3, 0x4B, 0x92, 0x65, 0xC3, 0x31, 0xAD), - MBEDTLS_BYTES_TO_T_UINT_8(0x75, 0xB5, 0x4F, 0x4D, 0x91, 0xD4, 0xE2, 0xB2), - MBEDTLS_BYTES_TO_T_UINT_8(0x51, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_9_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x72, 0x09, 0x41, 0x79, 0x1D, 0x4D, 0x0D, 0x33), - MBEDTLS_BYTES_TO_T_UINT_8(0xBB, 0x31, 0x18, 0xBA, 0xA0, 0xF2, 0x6E, 0x7E), - MBEDTLS_BYTES_TO_T_UINT_8(0x93, 0x5B, 0x4D, 0x4F, 0xAF, 0xC9, 0x8C, 0xA1), - MBEDTLS_BYTES_TO_T_UINT_8(0x48, 0x99, 0x9C, 0x06, 0x68, 0xDE, 0xD8, 0x29), - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0x04, 0xE1, 0xB5, 0x9D, 0x00, 0xBC, 0xB8), - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0x95, 0x92, 0x8D, 0x72, 0xD3, 0x37, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0xAB, 0x4B, 0x27, 0xA2, 0xE8, 0xA4, 0x26, 0xA1), - MBEDTLS_BYTES_TO_T_UINT_8(0x4F, 0x45, 0x9C, 0xA9, 0xCB, 0x9F, 0xBA, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0xCB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_10_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0x7E, 0x1B, 0x64, 0xF4, 0xE8, 0xA5, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0xF7, 0x20, 0xA9, 0xCA, 0xF3, 0x89, 0xE5, 0xE1), - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0xED, 0xFC, 0xAB, 0xD9, 0x0A, 0xB9, 0x07), - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0x6F, 0x46, 0x7C, 0xCD, 0x78, 0xFF, 0x05), - MBEDTLS_BYTES_TO_T_UINT_8(0x69, 0xAB, 0x71, 0x5A, 0x94, 0xAB, 0x20, 0x20), - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0x2E, 0xEE, 0x87, 0x57, 0x1F, 0xAD, 0xD3), - MBEDTLS_BYTES_TO_T_UINT_8(0x91, 0x4C, 0x3D, 0xFB, 0x7E, 0xA1, 0x8B, 0x07), - MBEDTLS_BYTES_TO_T_UINT_8(0x69, 0xCF, 0x07, 0x86, 0xBA, 0x53, 0x37, 0xCF), - MBEDTLS_BYTES_TO_T_UINT_8(0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_10_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x26, 0xB2, 0xB9, 0xE2, 0x91, 0xE3, 0xB5), - MBEDTLS_BYTES_TO_T_UINT_8(0x79, 0xC9, 0x54, 0x84, 0x08, 0x3D, 0x0B, 0xD2), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0xA8, 0x77, 0x2F, 0x64, 0x45, 0x99, 0x4C), - MBEDTLS_BYTES_TO_T_UINT_8(0x87, 0x96, 0x16, 0x1F, 0xDB, 0x96, 0x28, 0x97), - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0x2B, 0x8D, 0xFF, 0xA2, 0x4F, 0x55, 0xD3), - MBEDTLS_BYTES_TO_T_UINT_8(0x71, 0xE6, 0x48, 0xBD, 0x99, 0x3D, 0x12, 0x57), - MBEDTLS_BYTES_TO_T_UINT_8(0x3F, 0x84, 0x59, 0xDA, 0xB9, 0xB6, 0x66, 0x12), - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0x78, 0x41, 0x92, 0xDF, 0xF4, 0x3F, 0x63), - MBEDTLS_BYTES_TO_T_UINT_8(0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_11_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x7E, 0x86, 0x6F, 0x4F, 0xBF, 0x67, 0xDF, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0xF2, 0x2B, 0x1E, 0x5F, 0x00, 0xEA, 0xF6, 0x56), - MBEDTLS_BYTES_TO_T_UINT_8(0x90, 0xB9, 0x6A, 0x89, 0xD8, 0xC0, 0xD7, 0xA7), - MBEDTLS_BYTES_TO_T_UINT_8(0xCB, 0x9A, 0x32, 0x23, 0xA0, 0x02, 0x91, 0x58), - MBEDTLS_BYTES_TO_T_UINT_8(0x42, 0x7F, 0x6A, 0x15, 0x64, 0x6A, 0x8B, 0xBB), - MBEDTLS_BYTES_TO_T_UINT_8(0x8A, 0x57, 0x82, 0x58, 0xA9, 0x56, 0xB5, 0xFB), - MBEDTLS_BYTES_TO_T_UINT_8(0xDD, 0x50, 0x92, 0x60, 0xCC, 0x81, 0x24, 0xA8), - MBEDTLS_BYTES_TO_T_UINT_8(0x36, 0x3D, 0xAD, 0xDA, 0xD9, 0x51, 0x3E, 0x57), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_11_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xEC, 0xFE, 0x8F, 0xB0, 0x0B, 0xDE, 0x2E, 0x7E), - MBEDTLS_BYTES_TO_T_UINT_8(0x79, 0xD2, 0xBE, 0xEF, 0xAC, 0x76, 0x71, 0xA3), - MBEDTLS_BYTES_TO_T_UINT_8(0x55, 0xE8, 0x72, 0x0B, 0xAC, 0xFE, 0xCA, 0x5A), - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0x5B, 0xC7, 0xFC, 0xE3, 0x3C, 0x7C, 0x4C), - MBEDTLS_BYTES_TO_T_UINT_8(0xA1, 0x04, 0xA7, 0xB9, 0x9B, 0x93, 0xC0, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0x41, 0x48, 0x4B, 0x8E, 0x32, 0xC5, 0xF0, 0x6B), - MBEDTLS_BYTES_TO_T_UINT_8(0xB0, 0x42, 0x07, 0xC1, 0xF2, 0xF1, 0x72, 0x5B), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0x37, 0x54, 0x9C, 0x88, 0xD2, 0x62, 0xAA), - MBEDTLS_BYTES_TO_T_UINT_8(0xC1, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_12_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0x19, 0x8A, 0x89, 0x58, 0xA2, 0x0F, 0xDB), - MBEDTLS_BYTES_TO_T_UINT_8(0x01, 0xCC, 0x4C, 0x97, 0x30, 0x66, 0x34, 0x26), - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0x6A, 0x1E, 0x1F, 0xDB, 0xC9, 0x5E, 0x13), - MBEDTLS_BYTES_TO_T_UINT_8(0x1B, 0x4D, 0x49, 0xFF, 0x9B, 0x9C, 0xAC, 0x9B), - MBEDTLS_BYTES_TO_T_UINT_8(0xD7, 0xE4, 0x4B, 0xF2, 0xD4, 0x1A, 0xD2, 0x78), - MBEDTLS_BYTES_TO_T_UINT_8(0xCD, 0xDA, 0xE8, 0x61, 0x9F, 0xC8, 0x49, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0x51, 0xCB, 0xF2, 0x2D, 0x85, 0xF6, 0x8D, 0x52), - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0xC5, 0xCD, 0x2C, 0x79, 0xC6, 0x0E, 0x4F), - MBEDTLS_BYTES_TO_T_UINT_8(0xDB, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_12_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x73, 0x1D, 0x55, 0x0F, 0xF8, 0x22, 0x9F, 0x78), - MBEDTLS_BYTES_TO_T_UINT_8(0x76, 0x56, 0xBA, 0xE7, 0x57, 0x32, 0xEC, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0x65, 0x9A, 0xC6, 0x4C, 0x09, 0xC4, 0x52, 0x3F), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x1E, 0x6F, 0xF4, 0x7D, 0x27, 0xDD, 0xAF), - MBEDTLS_BYTES_TO_T_UINT_8(0x94, 0x11, 0x16, 0xEC, 0x79, 0x83, 0xAD, 0xAE), - MBEDTLS_BYTES_TO_T_UINT_8(0x46, 0x4E, 0x92, 0x1F, 0x19, 0x7D, 0x65, 0xDC), - MBEDTLS_BYTES_TO_T_UINT_8(0x09, 0xFF, 0x78, 0x15, 0x45, 0x63, 0x32, 0xE4), - MBEDTLS_BYTES_TO_T_UINT_8(0xBF, 0x91, 0xD0, 0x78, 0x58, 0xDA, 0x50, 0x47), - MBEDTLS_BYTES_TO_T_UINT_8(0x73, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_13_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x23, 0xDE, 0x40, 0xF6, 0x41, 0xB4, 0x3B, 0x95), - MBEDTLS_BYTES_TO_T_UINT_8(0xC6, 0x8D, 0xE0, 0xE1, 0xA9, 0xF0, 0x35, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0xD4, 0xBA, 0x7B, 0xCC, 0x1B, 0x3A, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0xD0, 0x5A, 0x2E, 0x74, 0x47, 0x14, 0xC3, 0x4D), - MBEDTLS_BYTES_TO_T_UINT_8(0x7D, 0xF0, 0x8B, 0x06, 0x15, 0x8E, 0x0E, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0xB5, 0xD2, 0xEB, 0x97, 0x50, 0x7D, 0x31, 0xFC), - MBEDTLS_BYTES_TO_T_UINT_8(0x42, 0x93, 0x4C, 0xDB, 0x97, 0x79, 0x44, 0xF5), - MBEDTLS_BYTES_TO_T_UINT_8(0x9C, 0xA2, 0xA0, 0x0B, 0xC8, 0x3A, 0x8A, 0xF9), - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_13_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x79, 0x50, 0x92, 0x9E, 0x24, 0x1F, 0xCB, 0x4C), - MBEDTLS_BYTES_TO_T_UINT_8(0xD3, 0x16, 0xC9, 0xC5, 0x3D, 0x5A, 0xAF, 0x97), - MBEDTLS_BYTES_TO_T_UINT_8(0x18, 0xE3, 0x97, 0xE4, 0xA8, 0x50, 0xF6, 0x7E), - MBEDTLS_BYTES_TO_T_UINT_8(0x45, 0x57, 0x97, 0x42, 0x78, 0x92, 0x49, 0x0D), - MBEDTLS_BYTES_TO_T_UINT_8(0xA5, 0xEB, 0x62, 0x24, 0xFB, 0x8F, 0x32, 0xCF), - MBEDTLS_BYTES_TO_T_UINT_8(0xF3, 0x0C, 0x36, 0x6E, 0x8F, 0xE8, 0xE8, 0x8E), - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0xD3, 0x7C, 0xC7, 0x8D, 0x3F, 0x5C, 0xE1), - MBEDTLS_BYTES_TO_T_UINT_8(0x6A, 0x64, 0x6A, 0x73, 0x10, 0x79, 0xB8, 0x5A), - MBEDTLS_BYTES_TO_T_UINT_8(0xCB, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_14_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x51, 0xF9, 0xEF, 0xA5, 0x20, 0x4A, 0x5C, 0xA1), - MBEDTLS_BYTES_TO_T_UINT_8(0x2F, 0xF3, 0xF4, 0x49, 0x5B, 0x73, 0xAA, 0x1B), - MBEDTLS_BYTES_TO_T_UINT_8(0xC6, 0xF2, 0xEA, 0x0F, 0x00, 0xAD, 0x53, 0xAB), - MBEDTLS_BYTES_TO_T_UINT_8(0x03, 0xB8, 0x66, 0xED, 0xC4, 0x2B, 0x4C, 0x35), - MBEDTLS_BYTES_TO_T_UINT_8(0x3A, 0x2F, 0xC1, 0x9A, 0x37, 0xD2, 0x7F, 0x58), - MBEDTLS_BYTES_TO_T_UINT_8(0x29, 0xA7, 0x81, 0x38, 0x64, 0xC9, 0x37, 0x38), - MBEDTLS_BYTES_TO_T_UINT_8(0xBE, 0x3B, 0x6C, 0x9F, 0x5B, 0xD9, 0x8B, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x14, 0xD9, 0x08, 0xD8, 0xD2, 0x7E, 0x23), - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_14_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x71, 0xE6, 0x3D, 0xD1, 0xB0, 0xE7, 0xCD), - MBEDTLS_BYTES_TO_T_UINT_8(0x5B, 0x81, 0x23, 0xEC, 0x2D, 0x42, 0x45, 0xE6), - MBEDTLS_BYTES_TO_T_UINT_8(0x51, 0x5B, 0x44, 0x6B, 0x89, 0x03, 0x67, 0x28), - MBEDTLS_BYTES_TO_T_UINT_8(0x84, 0x27, 0xAE, 0x80, 0x5A, 0x33, 0xBE, 0x11), - MBEDTLS_BYTES_TO_T_UINT_8(0xE3, 0xB6, 0x64, 0x1A, 0xDF, 0xD3, 0x85, 0x91), - MBEDTLS_BYTES_TO_T_UINT_8(0x67, 0x8C, 0x22, 0xBA, 0xD0, 0xBD, 0xCC, 0xA0), - MBEDTLS_BYTES_TO_T_UINT_8(0xF7, 0x3C, 0x01, 0x3A, 0xFF, 0x9D, 0xC7, 0x6B), - MBEDTLS_BYTES_TO_T_UINT_8(0x0C, 0xC7, 0x64, 0xB4, 0x59, 0x4E, 0x9F, 0x22), - MBEDTLS_BYTES_TO_T_UINT_8(0x85, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_15_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA1, 0x34, 0x0A, 0x41, 0x94, 0xA8, 0xF2, 0xB7), - MBEDTLS_BYTES_TO_T_UINT_8(0xF6, 0xD4, 0xE4, 0xF0, 0x97, 0x45, 0x6D, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0x8F, 0x1F, 0x4D, 0x6D, 0xFE, 0xA0, 0xC4, 0x84), - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0x28, 0x5C, 0x40, 0xBB, 0x65, 0xD4, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0xA8, 0x87, 0x35, 0x20, 0x3A, 0x89, 0x44), - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0xFD, 0x4F, 0xAB, 0x2D, 0xD1, 0xD0, 0xC0), - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0xE8, 0x00, 0xFC, 0x69, 0x52, 0xF8, 0xD5), - MBEDTLS_BYTES_TO_T_UINT_8(0xE1, 0x9A, 0x99, 0xE1, 0xDC, 0x9C, 0x3F, 0xD9), - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_15_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x12, 0x08, 0x98, 0xD9, 0xCA, 0x73, 0xD5, 0xA9), - MBEDTLS_BYTES_TO_T_UINT_8(0xB9, 0x2C, 0xE0, 0xA7, 0x3E, 0x91, 0xD7, 0x87), - MBEDTLS_BYTES_TO_T_UINT_8(0x68, 0x04, 0xB0, 0x54, 0x09, 0xF4, 0x72, 0xB7), - MBEDTLS_BYTES_TO_T_UINT_8(0xC8, 0xEE, 0x28, 0xCC, 0xE8, 0x50, 0x78, 0x20), - MBEDTLS_BYTES_TO_T_UINT_8(0x0D, 0x91, 0x03, 0x76, 0xDB, 0x68, 0x24, 0x77), - MBEDTLS_BYTES_TO_T_UINT_8(0x7A, 0xE0, 0x56, 0xB2, 0x5D, 0x12, 0xD3, 0xB5), - MBEDTLS_BYTES_TO_T_UINT_8(0x0D, 0x42, 0x59, 0x8B, 0xDF, 0x67, 0xB5, 0xBE), - MBEDTLS_BYTES_TO_T_UINT_8(0xD1, 0xCC, 0xE5, 0x31, 0x53, 0x7A, 0x46, 0xB3), - MBEDTLS_BYTES_TO_T_UINT_8(0xDA, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_16_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCC, 0x8D, 0x59, 0xB5, 0x1B, 0x0F, 0xF4, 0xAF), - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0x2F, 0xD1, 0x2C, 0xE0, 0xD8, 0x04, 0xEF), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0xF4, 0xD7, 0xBA, 0xB0, 0xA3, 0x7E, 0xC9), - MBEDTLS_BYTES_TO_T_UINT_8(0xCD, 0x08, 0x51, 0x56, 0xA6, 0x76, 0x67, 0x33), - MBEDTLS_BYTES_TO_T_UINT_8(0x8C, 0x17, 0x63, 0xFE, 0x56, 0xD0, 0xD9, 0x71), - MBEDTLS_BYTES_TO_T_UINT_8(0xAA, 0xF6, 0xC3, 0x14, 0x47, 0xC5, 0xA7, 0x31), - MBEDTLS_BYTES_TO_T_UINT_8(0x72, 0x4C, 0x80, 0xF6, 0xA2, 0x57, 0xA7, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0xB3, 0x7B, 0xF8, 0x2F, 0xE1, 0x3E, 0x7B), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_16_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x26, 0xF4, 0xF9, 0x6B, 0x7B, 0x90, 0xDF, 0x30), - MBEDTLS_BYTES_TO_T_UINT_8(0x1F, 0x82, 0xEF, 0x62, 0xA1, 0x4C, 0x53, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0x99, 0x76, 0x01, 0xBA, 0x8D, 0x0F, 0x54), - MBEDTLS_BYTES_TO_T_UINT_8(0xAF, 0xF4, 0x58, 0x73, 0x56, 0xFE, 0xDD, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0xF6, 0xCE, 0xF9, 0xE8, 0xA1, 0x34, 0xC3, 0x5B), - MBEDTLS_BYTES_TO_T_UINT_8(0x09, 0x5F, 0xDC, 0x6A, 0x3D, 0xD8, 0x7F, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0xF4, 0x51, 0xB8, 0xB8, 0xC1, 0xD7, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0xAE, 0x7D, 0x58, 0xD1, 0xD4, 0x1B, 0x4D, 0x23), - MBEDTLS_BYTES_TO_T_UINT_8(0xD3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_17_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB9, 0x95, 0xDF, 0x00, 0xD8, 0x21, 0xDE, 0x94), - MBEDTLS_BYTES_TO_T_UINT_8(0xF7, 0x47, 0x3C, 0xC3, 0xB2, 0x01, 0x53, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0x17, 0x43, 0x23, 0xBD, 0xCA, 0x71, 0xF2), - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0xBA, 0x0F, 0x4F, 0xDC, 0x41, 0x54, 0xBE), - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0x39, 0x26, 0x70, 0x53, 0x32, 0x18, 0x11), - MBEDTLS_BYTES_TO_T_UINT_8(0x32, 0x46, 0x07, 0x97, 0x3A, 0x57, 0xE0, 0x01), - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0x92, 0x4F, 0xCE, 0xDF, 0x25, 0x80, 0x26), - MBEDTLS_BYTES_TO_T_UINT_8(0x5B, 0x6F, 0x9A, 0x03, 0x05, 0x4B, 0xD1, 0x47), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_17_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x25, 0x01, 0x72, 0x30, 0x90, 0x17, 0x51, 0x20), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0xFB, 0x41, 0x65, 0x5C, 0xB4, 0x2D, 0xEE), - MBEDTLS_BYTES_TO_T_UINT_8(0x66, 0xCD, 0xCD, 0xAA, 0x41, 0xCC, 0xBB, 0x07), - MBEDTLS_BYTES_TO_T_UINT_8(0xD4, 0xCE, 0x08, 0x0A, 0x63, 0xE9, 0xA2, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0x3D, 0xA8, 0x21, 0x7F, 0x7A, 0x5B, 0x9B, 0x81), - MBEDTLS_BYTES_TO_T_UINT_8(0x10, 0x6B, 0x89, 0x44, 0x0A, 0x7F, 0x85, 0x5F), - MBEDTLS_BYTES_TO_T_UINT_8(0x7D, 0xDE, 0x7C, 0x19, 0x5C, 0x65, 0x26, 0x61), - MBEDTLS_BYTES_TO_T_UINT_8(0xD7, 0xAC, 0x62, 0x29, 0x4A, 0xF1, 0xD0, 0x81), - MBEDTLS_BYTES_TO_T_UINT_8(0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_18_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x32, 0x00, 0x40, 0x87, 0xEB, 0xA9, 0x58, 0x56), - MBEDTLS_BYTES_TO_T_UINT_8(0xAF, 0x51, 0x0B, 0xFF, 0x56, 0x35, 0x51, 0xB3), - MBEDTLS_BYTES_TO_T_UINT_8(0x7B, 0xAC, 0x08, 0x94, 0x71, 0xDA, 0xEC, 0x99), - MBEDTLS_BYTES_TO_T_UINT_8(0x5F, 0x4D, 0xC5, 0x7B, 0x31, 0x8B, 0x8D, 0x5E), - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x05, 0xF1, 0x3E, 0x9E, 0x8F, 0x17, 0x8F), - MBEDTLS_BYTES_TO_T_UINT_8(0xF0, 0x9C, 0x4B, 0x62, 0x94, 0xAD, 0x49, 0xFC), - MBEDTLS_BYTES_TO_T_UINT_8(0x0F, 0xC9, 0xC6, 0x8F, 0xFD, 0x33, 0x44, 0x34), - MBEDTLS_BYTES_TO_T_UINT_8(0x5F, 0x96, 0x17, 0x7F, 0x42, 0xBE, 0xF7, 0x0D), - MBEDTLS_BYTES_TO_T_UINT_8(0xD4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_18_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFB, 0x29, 0x39, 0x13, 0x08, 0x8D, 0x91, 0x47), - MBEDTLS_BYTES_TO_T_UINT_8(0xF6, 0x79, 0xF9, 0x2F, 0xA9, 0x0A, 0xCF, 0xD6), - MBEDTLS_BYTES_TO_T_UINT_8(0xAB, 0x87, 0x7A, 0xA3, 0x19, 0xAB, 0x55, 0xAD), - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0x0B, 0x01, 0xC5, 0x56, 0x19, 0x9D, 0x9E), - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0xDE, 0x82, 0x3B, 0xEA, 0xD3, 0x0B, 0x8C), - MBEDTLS_BYTES_TO_T_UINT_8(0x65, 0x6B, 0xC7, 0xF3, 0x0F, 0x82, 0x87, 0x6C), - MBEDTLS_BYTES_TO_T_UINT_8(0xD8, 0x2E, 0x23, 0xF2, 0x39, 0x9D, 0x49, 0x70), - MBEDTLS_BYTES_TO_T_UINT_8(0x31, 0xDE, 0xAF, 0x7A, 0xEE, 0xB0, 0xDA, 0x70), - MBEDTLS_BYTES_TO_T_UINT_8(0x63, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_19_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x76, 0x4E, 0x2A, 0x50, 0xFD, 0x8E, 0xC0, 0xEB), - MBEDTLS_BYTES_TO_T_UINT_8(0x52, 0x0F, 0x7C, 0x76, 0x63, 0xD8, 0x89, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0xEC, 0x2D, 0xB9, 0x4E, 0xF4, 0xEE, 0x85, 0xCF), - MBEDTLS_BYTES_TO_T_UINT_8(0xC1, 0x95, 0x5C, 0x96, 0x5D, 0xAA, 0x59, 0x0B), - MBEDTLS_BYTES_TO_T_UINT_8(0xCA, 0xDB, 0xD2, 0x68, 0x8E, 0x5A, 0x94, 0x60), - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0x02, 0xBF, 0x77, 0x9F, 0xB9, 0x4C, 0xC9), - MBEDTLS_BYTES_TO_T_UINT_8(0x2D, 0xDC, 0xC0, 0xCF, 0x81, 0x1E, 0xC4, 0x6C), - MBEDTLS_BYTES_TO_T_UINT_8(0x2B, 0xCC, 0x37, 0x86, 0xDC, 0xE2, 0x64, 0x72), - MBEDTLS_BYTES_TO_T_UINT_8(0xD5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_19_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x2C, 0x30, 0xB1, 0x59, 0x20, 0x9D, 0x98, 0x28), - MBEDTLS_BYTES_TO_T_UINT_8(0x77, 0x0C, 0x9D, 0xF8, 0x20, 0xDC, 0x90, 0xBA), - MBEDTLS_BYTES_TO_T_UINT_8(0xB1, 0xA0, 0xF4, 0xE7, 0x3E, 0x9C, 0x9E, 0xA2), - MBEDTLS_BYTES_TO_T_UINT_8(0xB5, 0x25, 0xA2, 0xB0, 0x54, 0xCD, 0x2E, 0x33), - MBEDTLS_BYTES_TO_T_UINT_8(0xEA, 0xD9, 0x42, 0xB0, 0x80, 0xB0, 0xA3, 0x38), - MBEDTLS_BYTES_TO_T_UINT_8(0x9F, 0xFE, 0x9D, 0x8D, 0x40, 0xFF, 0x27, 0x6D), - MBEDTLS_BYTES_TO_T_UINT_8(0x3A, 0x9D, 0xA6, 0x88, 0x3A, 0x8B, 0x6F, 0x14), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x39, 0xEE, 0x1F, 0x3F, 0xB1, 0x4F, 0x63), - MBEDTLS_BYTES_TO_T_UINT_8(0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_20_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0xD7, 0x9E, 0xFF, 0xD2, 0x35, 0x67, 0x03), - MBEDTLS_BYTES_TO_T_UINT_8(0xCA, 0x4F, 0x15, 0x5D, 0xE3, 0xE8, 0x53, 0x86), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0xF7, 0x24, 0x98, 0xA2, 0xCB, 0x11, 0x68), - MBEDTLS_BYTES_TO_T_UINT_8(0x06, 0x2E, 0x25, 0xE1, 0x94, 0xC5, 0xA3, 0x96), - MBEDTLS_BYTES_TO_T_UINT_8(0xE0, 0x82, 0x6E, 0xBA, 0xE7, 0x43, 0x25, 0xB0), - MBEDTLS_BYTES_TO_T_UINT_8(0x18, 0x65, 0xB4, 0x49, 0x73, 0x18, 0x35, 0x54), - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0x5B, 0xBC, 0x62, 0x86, 0x4C, 0xC1, 0xB7), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0xF2, 0x95, 0xA2, 0xBB, 0xA2, 0x35, 0x65), - MBEDTLS_BYTES_TO_T_UINT_8(0xBF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_20_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x72, 0x59, 0x62, 0xB0, 0x4B, 0x1E, 0xB4, 0xD8), - MBEDTLS_BYTES_TO_T_UINT_8(0x0D, 0x55, 0xCE, 0xB0, 0x69, 0xBA, 0x63, 0x10), - MBEDTLS_BYTES_TO_T_UINT_8(0x6E, 0x69, 0x86, 0xDB, 0x34, 0x7D, 0x68, 0x64), - MBEDTLS_BYTES_TO_T_UINT_8(0xDA, 0x06, 0xCA, 0x55, 0x44, 0x36, 0x2B, 0xBA), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0xD4, 0xC4, 0x3D, 0xCD, 0x9E, 0x69, 0xA4), - MBEDTLS_BYTES_TO_T_UINT_8(0x3F, 0x44, 0xE4, 0xBF, 0x31, 0xE6, 0x40, 0x9F), - MBEDTLS_BYTES_TO_T_UINT_8(0x7E, 0x4F, 0xFA, 0x75, 0xE3, 0xFB, 0x97, 0x0E), - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0xC0, 0xBD, 0x1C, 0x48, 0xB0, 0x26, 0xD0), - MBEDTLS_BYTES_TO_T_UINT_8(0xD2, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_21_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0x7B, 0x32, 0xFA, 0xF2, 0x6D, 0x84, 0x8E), - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0x21, 0x03, 0x1D, 0x0D, 0x22, 0x55, 0x67), - MBEDTLS_BYTES_TO_T_UINT_8(0x18, 0xF9, 0x42, 0x03, 0x9C, 0xC2, 0xCB, 0xBA), - MBEDTLS_BYTES_TO_T_UINT_8(0xF8, 0xA1, 0x96, 0xD9, 0x9D, 0x11, 0x6F, 0xBE), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0x40, 0x57, 0xEB, 0x40, 0x2D, 0xC0, 0x11), - MBEDTLS_BYTES_TO_T_UINT_8(0x2F, 0x96, 0xBB, 0x4F, 0x2F, 0x23, 0xA8, 0x28), - MBEDTLS_BYTES_TO_T_UINT_8(0x3A, 0x29, 0x85, 0x21, 0xA5, 0x50, 0x62, 0x06), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x7D, 0x92, 0xCF, 0x87, 0x0C, 0x22, 0xF9), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_21_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0x0E, 0xA5, 0x32, 0x5B, 0xDF, 0x9C, 0xD5), - MBEDTLS_BYTES_TO_T_UINT_8(0x27, 0x96, 0x37, 0x2C, 0x88, 0x35, 0x30, 0xA1), - MBEDTLS_BYTES_TO_T_UINT_8(0x40, 0xB4, 0x69, 0xFF, 0xEB, 0xC6, 0x94, 0x08), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x55, 0x60, 0xAD, 0xAA, 0x58, 0x14, 0x88), - MBEDTLS_BYTES_TO_T_UINT_8(0x3C, 0xFF, 0xF2, 0xB2, 0xD5, 0xA7, 0xD9, 0x27), - MBEDTLS_BYTES_TO_T_UINT_8(0x2D, 0xAE, 0x54, 0xD2, 0x60, 0x31, 0xF3, 0x15), - MBEDTLS_BYTES_TO_T_UINT_8(0xBB, 0x92, 0x83, 0xE3, 0xF1, 0x42, 0x83, 0x6E), - MBEDTLS_BYTES_TO_T_UINT_8(0x49, 0xD2, 0xC8, 0xB7, 0x76, 0x45, 0x7F, 0x7D), - MBEDTLS_BYTES_TO_T_UINT_8(0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_22_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x4A, 0x11, 0xA4, 0xFB, 0x7A, 0x01, 0xBC, 0xC8), - MBEDTLS_BYTES_TO_T_UINT_8(0xCD, 0x27, 0x73, 0x8D, 0x02, 0x91, 0x27, 0x8E), - MBEDTLS_BYTES_TO_T_UINT_8(0xA4, 0x62, 0xF6, 0xDD, 0x6B, 0xFA, 0x5B, 0xB9), - MBEDTLS_BYTES_TO_T_UINT_8(0xEF, 0xCA, 0xA2, 0x44, 0x2C, 0xF0, 0x28, 0xD8), - MBEDTLS_BYTES_TO_T_UINT_8(0x3C, 0xF1, 0x7A, 0xA2, 0x42, 0x4C, 0x50, 0xC6), - MBEDTLS_BYTES_TO_T_UINT_8(0x2D, 0x83, 0x3E, 0x50, 0xAB, 0x9C, 0xF7, 0x67), - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0xED, 0x78, 0xCB, 0x76, 0x69, 0xDA, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0xDB, 0x01, 0x1E, 0x43, 0x27, 0x47, 0x6E, 0xDA), - MBEDTLS_BYTES_TO_T_UINT_8(0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_22_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xD3, 0x4F, 0x54, 0xB9, 0x3E, 0xBD, 0xD5, 0x44), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x35, 0x40, 0x69, 0x7F, 0x74, 0x9D, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0x06, 0x6F, 0x67, 0x68, 0x2B, 0x4D, 0x10), - MBEDTLS_BYTES_TO_T_UINT_8(0xC6, 0x65, 0x41, 0xFC, 0x7C, 0x1E, 0xE8, 0xC8), - MBEDTLS_BYTES_TO_T_UINT_8(0xF2, 0x79, 0x37, 0xAF, 0xFD, 0xD2, 0xDA, 0x4C), - MBEDTLS_BYTES_TO_T_UINT_8(0x33, 0xA8, 0x69, 0x56, 0x62, 0xA4, 0xE4, 0xA3), - MBEDTLS_BYTES_TO_T_UINT_8(0x42, 0x71, 0x73, 0x21, 0x8A, 0x17, 0x81, 0xA2), - MBEDTLS_BYTES_TO_T_UINT_8(0x14, 0x55, 0x8F, 0x7B, 0xB8, 0xAF, 0xF7, 0x86), - MBEDTLS_BYTES_TO_T_UINT_8(0xAA, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_23_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x4B, 0xD1, 0xBD, 0xBE, 0x8C, 0xBC, 0x60, 0x6E), - MBEDTLS_BYTES_TO_T_UINT_8(0x62, 0xA6, 0x57, 0x8C, 0xAE, 0x5C, 0x19, 0xFE), - MBEDTLS_BYTES_TO_T_UINT_8(0x7A, 0x43, 0xE4, 0xD9, 0xD8, 0x7B, 0xE7, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0xED, 0xB9, 0xE4, 0x85, 0x7C, 0x2E, 0xFC, 0x20), - MBEDTLS_BYTES_TO_T_UINT_8(0x02, 0x2E, 0x01, 0x2A, 0x6D, 0x56, 0xBE, 0x97), - MBEDTLS_BYTES_TO_T_UINT_8(0x6A, 0x0C, 0x25, 0x9B, 0xAE, 0x86, 0x37, 0x43), - MBEDTLS_BYTES_TO_T_UINT_8(0x4A, 0x22, 0xB3, 0xCB, 0x99, 0x66, 0xB7, 0x9E), - MBEDTLS_BYTES_TO_T_UINT_8(0x56, 0xF7, 0x90, 0xF0, 0x1B, 0x09, 0x27, 0xF7), - MBEDTLS_BYTES_TO_T_UINT_8(0xC8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_23_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0x16, 0x08, 0xEF, 0x39, 0x64, 0x49, 0x31), - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0xA0, 0xE3, 0x97, 0xA9, 0x07, 0x54, 0x26), - MBEDTLS_BYTES_TO_T_UINT_8(0xCD, 0xFF, 0xE2, 0x00, 0x07, 0x21, 0x88, 0x20), - MBEDTLS_BYTES_TO_T_UINT_8(0x16, 0xFD, 0x59, 0x53, 0x05, 0x6C, 0x42, 0x27), - MBEDTLS_BYTES_TO_T_UINT_8(0x8F, 0xF7, 0x39, 0x5C, 0x82, 0x36, 0xE8, 0x03), - MBEDTLS_BYTES_TO_T_UINT_8(0x2E, 0x83, 0xA8, 0xE2, 0xA8, 0x43, 0x07, 0x38), - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0xAF, 0x2B, 0x79, 0xED, 0xD8, 0x39, 0x87), - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x20, 0x91, 0x7A, 0xC4, 0x07, 0xEF, 0x6C), - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_24_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x6A, 0x10, 0x2F, 0xAA, 0x0C, 0x94, 0x0E, 0x5A), - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0x81, 0x87, 0x41, 0x23, 0xEB, 0x55, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0xB8, 0x53, 0xCC, 0x79, 0xB6, 0xEB, 0x6C, 0xCC), - MBEDTLS_BYTES_TO_T_UINT_8(0xF4, 0x77, 0x73, 0x9D, 0xFC, 0x64, 0x6F, 0x7F), - MBEDTLS_BYTES_TO_T_UINT_8(0x3C, 0x40, 0xE3, 0x6D, 0x1C, 0x16, 0x71, 0x15), - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0xF4, 0x1B, 0xFF, 0x1C, 0x2F, 0xA5, 0xD7), - MBEDTLS_BYTES_TO_T_UINT_8(0x06, 0x0E, 0x0B, 0x11, 0xF4, 0x8D, 0x93, 0xAF), - MBEDTLS_BYTES_TO_T_UINT_8(0x58, 0xC5, 0x64, 0x6F, 0x24, 0x19, 0xF2, 0x9B), - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_24_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x52, 0xB3, 0xAF, 0xA5, 0x0E, 0x4F, 0x5E, 0xE1), - MBEDTLS_BYTES_TO_T_UINT_8(0x0F, 0x77, 0xCA, 0xF2, 0x6D, 0xC5, 0xF6, 0x9F), - MBEDTLS_BYTES_TO_T_UINT_8(0x90, 0x18, 0x8E, 0x33, 0x68, 0x6C, 0xE8, 0xE0), - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0x8B, 0x80, 0x90, 0x19, 0x7F, 0x90, 0x96), - MBEDTLS_BYTES_TO_T_UINT_8(0x5B, 0x80, 0x6B, 0x68, 0xE2, 0x7D, 0xD4, 0xD0), - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0xC1, 0x67, 0xB3, 0x72, 0xCB, 0xBF, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0x4F, 0xD5, 0xD3, 0x1D, 0x14, 0x58, 0x0A, 0x80), - MBEDTLS_BYTES_TO_T_UINT_8(0x79, 0x7A, 0x65, 0x98, 0xB3, 0x07, 0x4B, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0xF3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_25_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0x87, 0x0F, 0x5F, 0xCF, 0xA2, 0x01, 0x08), - MBEDTLS_BYTES_TO_T_UINT_8(0x0C, 0xC9, 0xC8, 0x6E, 0x35, 0x87, 0xA5, 0x67), - MBEDTLS_BYTES_TO_T_UINT_8(0x94, 0x3E, 0x91, 0xA0, 0xAB, 0x24, 0x1E, 0xF2), - MBEDTLS_BYTES_TO_T_UINT_8(0xB9, 0xBC, 0x02, 0x35, 0x70, 0xC1, 0x5F, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0x26, 0x59, 0xA0, 0x50, 0x04, 0x80, 0x52, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0xF8, 0x56, 0x6E, 0x42, 0x8F, 0x8C, 0x91, 0x65), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0xA2, 0xCB, 0xA5, 0xDE, 0x14, 0x24, 0x38), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0xCB, 0x74, 0x28, 0xE6, 0xA7, 0xE7, 0xC3), - MBEDTLS_BYTES_TO_T_UINT_8(0x5F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_25_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x35, 0x73, 0xA8, 0x8F, 0x9E, 0x0E, 0x63, 0x96), - MBEDTLS_BYTES_TO_T_UINT_8(0xC8, 0x1B, 0x77, 0xC7, 0xC1, 0x38, 0xF9, 0xDC), - MBEDTLS_BYTES_TO_T_UINT_8(0xD8, 0x3C, 0xCF, 0xA8, 0x7A, 0xD7, 0xF3, 0xC4), - MBEDTLS_BYTES_TO_T_UINT_8(0xDD, 0x5F, 0x9A, 0xC9, 0xAD, 0xE9, 0x1A, 0x93), - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0xCF, 0x2B, 0x5E, 0xD5, 0x81, 0x95, 0xA8), - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0x88, 0x75, 0x29, 0x1F, 0xC7, 0xC7, 0xD0), - MBEDTLS_BYTES_TO_T_UINT_8(0xD8, 0xA9, 0x5A, 0x4D, 0x63, 0x95, 0xF9, 0x4E), - MBEDTLS_BYTES_TO_T_UINT_8(0xEB, 0xCD, 0x04, 0x8F, 0xCD, 0x91, 0xDE, 0xC6), - MBEDTLS_BYTES_TO_T_UINT_8(0x71, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_26_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x88, 0xD4, 0xFD, 0x25, 0x11, 0x99, 0x6E, 0xEA), - MBEDTLS_BYTES_TO_T_UINT_8(0xB0, 0x83, 0x01, 0x3D, 0xFB, 0x56, 0xA5, 0x4E), - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0x3A, 0xDC, 0x74, 0xC2, 0xD7, 0xCF, 0xE8), - MBEDTLS_BYTES_TO_T_UINT_8(0x8F, 0xBD, 0xF1, 0xDD, 0xA3, 0x07, 0x03, 0xE2), - MBEDTLS_BYTES_TO_T_UINT_8(0x7B, 0xBE, 0xE9, 0x2E, 0x58, 0x84, 0x66, 0xFC), - MBEDTLS_BYTES_TO_T_UINT_8(0x71, 0x20, 0x78, 0x37, 0x79, 0x0B, 0xA6, 0x64), - MBEDTLS_BYTES_TO_T_UINT_8(0xE3, 0xF2, 0xAC, 0x65, 0xC8, 0xC9, 0x2F, 0x61), - MBEDTLS_BYTES_TO_T_UINT_8(0x26, 0x93, 0xE5, 0x0D, 0x0C, 0xC6, 0xB8, 0xCB), - MBEDTLS_BYTES_TO_T_UINT_8(0x9C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_26_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x69, 0xAD, 0x5C, 0x19, 0x12, 0x61, 0x0E, 0x25), - MBEDTLS_BYTES_TO_T_UINT_8(0x39, 0x4F, 0x0B, 0x1F, 0x49, 0x7E, 0xCD, 0x81), - MBEDTLS_BYTES_TO_T_UINT_8(0x46, 0x2E, 0x30, 0x61, 0xDB, 0x08, 0x68, 0x9B), - MBEDTLS_BYTES_TO_T_UINT_8(0x41, 0x78, 0xAF, 0xB3, 0x08, 0xC1, 0x69, 0xE5), - MBEDTLS_BYTES_TO_T_UINT_8(0xC4, 0x5F, 0x5D, 0xC1, 0x57, 0x6F, 0xD8, 0x34), - MBEDTLS_BYTES_TO_T_UINT_8(0x38, 0xD3, 0x6A, 0xF7, 0xFD, 0x86, 0xE5, 0xB3), - MBEDTLS_BYTES_TO_T_UINT_8(0xA8, 0x63, 0xBD, 0x70, 0x7B, 0x47, 0xE8, 0x6D), - MBEDTLS_BYTES_TO_T_UINT_8(0x18, 0x62, 0xC8, 0x7E, 0x9D, 0x11, 0x2B, 0xA5), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_27_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xE2, 0x84, 0xFD, 0xD5, 0x9A, 0x56, 0x7F, 0x5C), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0xBB, 0xA4, 0x6F, 0x12, 0x6E, 0x4D, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0x08, 0xA1, 0x82, 0x9C, 0x62, 0x74, 0x7B), - MBEDTLS_BYTES_TO_T_UINT_8(0x9E, 0x58, 0x22, 0x05, 0x1D, 0x15, 0x35, 0x79), - MBEDTLS_BYTES_TO_T_UINT_8(0x9A, 0x88, 0xCF, 0x5C, 0x05, 0x78, 0xFB, 0x94), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0x6B, 0x2F, 0x79, 0x09, 0x73, 0x67, 0xEC), - MBEDTLS_BYTES_TO_T_UINT_8(0xD8, 0xA0, 0x80, 0xD8, 0xE8, 0xEC, 0xFB, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0xE7, 0x0B, 0xB7, 0x81, 0x48, 0x7B, 0xD9), - MBEDTLS_BYTES_TO_T_UINT_8(0xE3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_27_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0x53, 0xA9, 0xED, 0x61, 0x92, 0xD7, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0x26, 0x49, 0xD9, 0x5D, 0x9B, 0x4E, 0x89, 0x35), - MBEDTLS_BYTES_TO_T_UINT_8(0xB8, 0x12, 0xEB, 0x9A, 0xC9, 0xCB, 0xC1, 0x95), - MBEDTLS_BYTES_TO_T_UINT_8(0x35, 0xDC, 0x95, 0x16, 0xFE, 0x29, 0x70, 0x01), - MBEDTLS_BYTES_TO_T_UINT_8(0x64, 0x33, 0xB1, 0xD6, 0x78, 0xB9, 0xE2, 0x36), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0xCE, 0x88, 0xC3, 0xFD, 0x7A, 0x6B, 0xB8), - MBEDTLS_BYTES_TO_T_UINT_8(0x40, 0x1E, 0x50, 0x1E, 0xAF, 0xB1, 0x25, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0xC1, 0xE7, 0xD7, 0xD5, 0xBD, 0x7A, 0x12, 0xF9), - MBEDTLS_BYTES_TO_T_UINT_8(0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_28_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x22, 0xAA, 0xA2, 0x80, 0x5D, 0x8F, 0xCD, 0xC8), - MBEDTLS_BYTES_TO_T_UINT_8(0x48, 0x39, 0x79, 0x64, 0xA1, 0x67, 0x3C, 0xB7), - MBEDTLS_BYTES_TO_T_UINT_8(0x3D, 0xC7, 0x49, 0xFF, 0x7F, 0xAC, 0xAB, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0x81, 0x54, 0x3E, 0x83, 0xF0, 0x3D, 0xBC, 0xB5), - MBEDTLS_BYTES_TO_T_UINT_8(0x87, 0x92, 0x4A, 0x38, 0x42, 0x8A, 0xAB, 0xF6), - MBEDTLS_BYTES_TO_T_UINT_8(0xE7, 0x0B, 0x4F, 0xEE, 0x9E, 0x92, 0xA5, 0xBE), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0xDD, 0x19, 0x96, 0xF2, 0xF0, 0x6B, 0x2E), - MBEDTLS_BYTES_TO_T_UINT_8(0xBE, 0xFC, 0xDD, 0xB2, 0x8A, 0xE5, 0x4C, 0x22), - MBEDTLS_BYTES_TO_T_UINT_8(0xD4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_28_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0x06, 0x49, 0xAC, 0x99, 0x7E, 0xF8, 0x12), - MBEDTLS_BYTES_TO_T_UINT_8(0x76, 0xC8, 0x01, 0x51, 0xEA, 0xF6, 0x52, 0xE7), - MBEDTLS_BYTES_TO_T_UINT_8(0x43, 0x89, 0x66, 0x2B, 0x1F, 0x9B, 0x2A, 0xA3), - MBEDTLS_BYTES_TO_T_UINT_8(0xDF, 0x0F, 0x95, 0x07, 0x2B, 0x6C, 0x6E, 0x9E), - MBEDTLS_BYTES_TO_T_UINT_8(0x24, 0xC3, 0xB4, 0xBB, 0x91, 0x1F, 0xA3, 0x72), - MBEDTLS_BYTES_TO_T_UINT_8(0x5F, 0x6E, 0x54, 0x28, 0x7B, 0x9C, 0x79, 0x2E), - MBEDTLS_BYTES_TO_T_UINT_8(0x03, 0x45, 0xFF, 0xA6, 0xDA, 0xA2, 0x83, 0x71), - MBEDTLS_BYTES_TO_T_UINT_8(0xEB, 0xDE, 0x8F, 0x17, 0x37, 0x82, 0xCB, 0xE2), - MBEDTLS_BYTES_TO_T_UINT_8(0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_29_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xD8, 0x94, 0x3F, 0x26, 0xC9, 0x1D, 0xD9, 0xAE), - MBEDTLS_BYTES_TO_T_UINT_8(0x09, 0x97, 0x28, 0x20, 0xCD, 0xC1, 0xF3, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0x95, 0xC9, 0xB5, 0x60, 0x9B, 0x1E, 0xDC, 0x74), - MBEDTLS_BYTES_TO_T_UINT_8(0x5B, 0xB9, 0x5B, 0x7D, 0xA0, 0xB2, 0x8C, 0xF0), - MBEDTLS_BYTES_TO_T_UINT_8(0x33, 0xD1, 0x42, 0xE6, 0x39, 0x33, 0x6D, 0xBB), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0xC0, 0xFC, 0xD2, 0x14, 0x5D, 0x3E, 0x3C), - MBEDTLS_BYTES_TO_T_UINT_8(0x78, 0x4A, 0x3E, 0x40, 0x16, 0x93, 0x15, 0xCF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0x24, 0xC1, 0x27, 0x27, 0xE5, 0x4B, 0xD8), - MBEDTLS_BYTES_TO_T_UINT_8(0xD4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_29_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0x50, 0xD8, 0xBC, 0xC1, 0x46, 0x22, 0xBB), - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0x0E, 0x60, 0xA1, 0xB3, 0x50, 0xD4, 0x86), - MBEDTLS_BYTES_TO_T_UINT_8(0x80, 0xB1, 0x26, 0xB6, 0x6D, 0x47, 0x5A, 0x6F), - MBEDTLS_BYTES_TO_T_UINT_8(0x45, 0xAC, 0x11, 0x35, 0x3E, 0xB9, 0xF4, 0x01), - MBEDTLS_BYTES_TO_T_UINT_8(0x58, 0x97, 0xFA, 0xBB, 0x6B, 0x39, 0x13, 0xD8), - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x7B, 0x34, 0x12, 0x75, 0x8E, 0x9B, 0xC6), - MBEDTLS_BYTES_TO_T_UINT_8(0x2C, 0x9E, 0xCD, 0x29, 0xB6, 0xEF, 0x8D, 0x10), - MBEDTLS_BYTES_TO_T_UINT_8(0x47, 0xAC, 0xE9, 0x25, 0x27, 0xBB, 0x78, 0x47), - MBEDTLS_BYTES_TO_T_UINT_8(0x2F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_30_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x30, 0x7A, 0xA8, 0xD3, 0xE3, 0x66, 0xE5, 0x66), - MBEDTLS_BYTES_TO_T_UINT_8(0x2F, 0x4C, 0xC4, 0x2C, 0x76, 0x81, 0x50, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0xEE, 0x71, 0x08, 0xB8, 0x52, 0x7C, 0xAF, 0xDC), - MBEDTLS_BYTES_TO_T_UINT_8(0x45, 0x59, 0x24, 0xDD, 0xFB, 0x2F, 0xD0, 0xDA), - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0xCD, 0x56, 0xE9, 0xAC, 0x91, 0xE6, 0xB9), - MBEDTLS_BYTES_TO_T_UINT_8(0xE5, 0x64, 0x20, 0xC6, 0x9F, 0xE4, 0xEF, 0xDF), - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0x2C, 0x8F, 0x8C, 0x97, 0xF6, 0x22, 0xC3), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0xF4, 0x88, 0xAA, 0xA8, 0xD7, 0xA5, 0x68), - MBEDTLS_BYTES_TO_T_UINT_8(0xDE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_30_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0x6C, 0xAE, 0x83, 0xB1, 0x55, 0x55, 0xEE), - MBEDTLS_BYTES_TO_T_UINT_8(0xB0, 0x67, 0x84, 0x47, 0x7C, 0x83, 0x5C, 0x89), - MBEDTLS_BYTES_TO_T_UINT_8(0x5B, 0x10, 0x4D, 0xDD, 0x30, 0x60, 0xB0, 0xE6), - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0xA7, 0x36, 0x76, 0x24, 0x32, 0x9F, 0x9D), - MBEDTLS_BYTES_TO_T_UINT_8(0xDD, 0x42, 0x81, 0xFB, 0xA4, 0x2E, 0x13, 0x68), - MBEDTLS_BYTES_TO_T_UINT_8(0x87, 0x94, 0x91, 0xFF, 0x99, 0xA0, 0x09, 0x61), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0x83, 0xA1, 0x76, 0xAF, 0x37, 0x5C, 0x77), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0xA8, 0x04, 0x86, 0xC4, 0xA9, 0x79, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_31_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x8C, 0xC2, 0x34, 0xFB, 0x83, 0x28, 0x27), - MBEDTLS_BYTES_TO_T_UINT_8(0xA4, 0x03, 0x7D, 0x5E, 0x9E, 0x0E, 0xB0, 0x22), - MBEDTLS_BYTES_TO_T_UINT_8(0xA2, 0x02, 0x46, 0x7F, 0xB9, 0xAC, 0xBB, 0x23), - MBEDTLS_BYTES_TO_T_UINT_8(0x06, 0xED, 0x48, 0xC2, 0x96, 0x4D, 0x56, 0x27), - MBEDTLS_BYTES_TO_T_UINT_8(0x44, 0xB5, 0xC5, 0xD1, 0xE6, 0x1C, 0x7E, 0x9B), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0x2E, 0x18, 0x71, 0x2D, 0x7B, 0xD7, 0xB3), - MBEDTLS_BYTES_TO_T_UINT_8(0xAB, 0x46, 0x9D, 0xDE, 0xAA, 0x78, 0x8E, 0xB1), - MBEDTLS_BYTES_TO_T_UINT_8(0x4D, 0xD7, 0x69, 0x2E, 0xE1, 0xD9, 0x48, 0xDE), - MBEDTLS_BYTES_TO_T_UINT_8(0xFB, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp521r1_T_31_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xAF, 0xFF, 0x9E, 0x09, 0x22, 0x22, 0xE6, 0x8D), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x14, 0x28, 0x13, 0x1B, 0x62, 0x12, 0x22), - MBEDTLS_BYTES_TO_T_UINT_8(0xCC, 0x7F, 0x67, 0x03, 0xB0, 0xC0, 0xF3, 0x05), - MBEDTLS_BYTES_TO_T_UINT_8(0xC0, 0xC3, 0x0F, 0xFB, 0x25, 0x48, 0x3E, 0xF4), - MBEDTLS_BYTES_TO_T_UINT_8(0x0B, 0x6E, 0x53, 0x98, 0x36, 0xB3, 0xD3, 0x94), - MBEDTLS_BYTES_TO_T_UINT_8(0xEB, 0x81, 0x54, 0x22, 0xA4, 0xCC, 0xC1, 0x22), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0xBA, 0xFC, 0xA9, 0xDF, 0x68, 0x86, 0x2B), - MBEDTLS_BYTES_TO_T_UINT_8(0x71, 0x92, 0x0E, 0xC3, 0xF2, 0x58, 0xE8, 0x51), - MBEDTLS_BYTES_TO_T_UINT_8(0xE9, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_ecp_point secp521r1_T[32] = { - ECP_POINT_INIT_XY_Z1(secp521r1_T_0_X, secp521r1_T_0_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_1_X, secp521r1_T_1_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_2_X, secp521r1_T_2_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_3_X, secp521r1_T_3_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_4_X, secp521r1_T_4_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_5_X, secp521r1_T_5_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_6_X, secp521r1_T_6_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_7_X, secp521r1_T_7_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_8_X, secp521r1_T_8_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_9_X, secp521r1_T_9_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_10_X, secp521r1_T_10_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_11_X, secp521r1_T_11_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_12_X, secp521r1_T_12_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_13_X, secp521r1_T_13_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_14_X, secp521r1_T_14_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_15_X, secp521r1_T_15_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_16_X, secp521r1_T_16_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_17_X, secp521r1_T_17_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_18_X, secp521r1_T_18_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_19_X, secp521r1_T_19_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_20_X, secp521r1_T_20_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_21_X, secp521r1_T_21_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_22_X, secp521r1_T_22_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_23_X, secp521r1_T_23_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_24_X, secp521r1_T_24_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_25_X, secp521r1_T_25_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_26_X, secp521r1_T_26_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_27_X, secp521r1_T_27_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_28_X, secp521r1_T_28_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_29_X, secp521r1_T_29_Y), - ECP_POINT_INIT_XY_Z0(secp521r1_T_30_X, secp521r1_T_30_Y), ECP_POINT_INIT_XY_Z0(secp521r1_T_31_X, secp521r1_T_31_Y), -}; -#else -#define secp521r1_T NULL -#endif -#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) -static const mbedtls_mpi_uint secp192k1_p[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0xEE, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), -}; -static const mbedtls_mpi_uint secp192k1_a[] = { - MBEDTLS_BYTES_TO_T_UINT_2(0x00, 0x00), -}; -static const mbedtls_mpi_uint secp192k1_b[] = { - MBEDTLS_BYTES_TO_T_UINT_2(0x03, 0x00), -}; -static const mbedtls_mpi_uint secp192k1_gx[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x7D, 0x6C, 0xE0, 0xEA, 0xB1, 0xD1, 0xA5, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0xF4, 0xB7, 0x80, 0x02, 0x7D, 0xB0, 0x26), - MBEDTLS_BYTES_TO_T_UINT_8(0xAE, 0xE9, 0x57, 0xC0, 0x0E, 0xF1, 0x4F, 0xDB), -}; -static const mbedtls_mpi_uint secp192k1_gy[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x9D, 0x2F, 0x5E, 0xD9, 0x88, 0xAA, 0x82, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0x86, 0xBE, 0x15, 0xD0, 0x63, 0x41, 0x84), - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0x28, 0x56, 0x9C, 0x6D, 0x2F, 0x2F, 0x9B), -}; -static const mbedtls_mpi_uint secp192k1_n[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x8D, 0xFD, 0xDE, 0x74, 0x6A, 0x46, 0x69, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0xFC, 0xF2, 0x26, 0xFE, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), -}; - -#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 -static const mbedtls_mpi_uint secp192k1_T_0_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x7D, 0x6C, 0xE0, 0xEA, 0xB1, 0xD1, 0xA5, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0xF4, 0xB7, 0x80, 0x02, 0x7D, 0xB0, 0x26), - MBEDTLS_BYTES_TO_T_UINT_8(0xAE, 0xE9, 0x57, 0xC0, 0x0E, 0xF1, 0x4F, 0xDB), -}; -static const mbedtls_mpi_uint secp192k1_T_0_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x9D, 0x2F, 0x5E, 0xD9, 0x88, 0xAA, 0x82, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0x86, 0xBE, 0x15, 0xD0, 0x63, 0x41, 0x84), - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0x28, 0x56, 0x9C, 0x6D, 0x2F, 0x2F, 0x9B), -}; -static const mbedtls_mpi_uint secp192k1_T_1_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x6F, 0x77, 0x3D, 0x0D, 0x85, 0x48, 0xA8, 0xA9), - MBEDTLS_BYTES_TO_T_UINT_8(0x62, 0x07, 0xDF, 0x1D, 0xB3, 0xB3, 0x01, 0x54), - MBEDTLS_BYTES_TO_T_UINT_8(0x05, 0x86, 0xF6, 0xAF, 0x19, 0x2A, 0x88, 0x2E), -}; -static const mbedtls_mpi_uint secp192k1_T_1_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x33, 0x90, 0xB6, 0x2F, 0x48, 0x36, 0x4C, 0x5B), - MBEDTLS_BYTES_TO_T_UINT_8(0xDB, 0x11, 0x14, 0xA6, 0xCB, 0xBA, 0x15, 0xD9), - MBEDTLS_BYTES_TO_T_UINT_8(0x7E, 0xB0, 0xF2, 0xD4, 0xC9, 0xDA, 0xBA, 0xD7), -}; -static const mbedtls_mpi_uint secp192k1_T_2_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xE4, 0xC1, 0x9C, 0xE6, 0xBB, 0xFB, 0xCF, 0x23), - MBEDTLS_BYTES_TO_T_UINT_8(0x93, 0x19, 0xAC, 0x5A, 0xC9, 0x8A, 0x1C, 0x75), - MBEDTLS_BYTES_TO_T_UINT_8(0xC1, 0xF6, 0x76, 0x86, 0x89, 0x27, 0x8D, 0x28), -}; -static const mbedtls_mpi_uint secp192k1_T_2_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x4B, 0xE0, 0x6F, 0x34, 0xBA, 0x5E, 0xD3, 0x96), - MBEDTLS_BYTES_TO_T_UINT_8(0x6A, 0xDC, 0xA6, 0x87, 0xC9, 0x9D, 0xC0, 0x82), - MBEDTLS_BYTES_TO_T_UINT_8(0x09, 0x11, 0x7E, 0xD6, 0xF7, 0x33, 0xFC, 0xE4), -}; -static const mbedtls_mpi_uint secp192k1_T_3_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0x37, 0x3E, 0xC0, 0x7F, 0x62, 0xE7, 0x54), - MBEDTLS_BYTES_TO_T_UINT_8(0xA5, 0x3B, 0x69, 0x9D, 0x44, 0xBC, 0x82, 0x99), - MBEDTLS_BYTES_TO_T_UINT_8(0xD4, 0x84, 0xB3, 0x5F, 0x2B, 0xA5, 0x9E, 0x2C), -}; -static const mbedtls_mpi_uint secp192k1_T_3_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0x95, 0xEB, 0x4C, 0x04, 0xB4, 0xF4, 0x75), - MBEDTLS_BYTES_TO_T_UINT_8(0x55, 0xAD, 0x4B, 0xD5, 0x9A, 0xEB, 0xC4, 0x4E), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0xB1, 0xC5, 0x59, 0xE3, 0xD5, 0x16, 0x2A), -}; -static const mbedtls_mpi_uint secp192k1_T_4_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x48, 0x2A, 0xCC, 0xAC, 0xD0, 0xEE, 0x50, 0xEC), - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0x83, 0xE0, 0x5B, 0x14, 0x44, 0x52, 0x20), - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0x15, 0x2D, 0x78, 0xF6, 0x51, 0x32, 0xCF), -}; -static const mbedtls_mpi_uint secp192k1_T_4_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0x36, 0x9B, 0xDD, 0xF8, 0xDD, 0xEF, 0xB2), - MBEDTLS_BYTES_TO_T_UINT_8(0x0B, 0xB1, 0x6A, 0x2B, 0xAF, 0xEB, 0x2B, 0xB1), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x87, 0x7A, 0x66, 0x5D, 0x5B, 0xDF, 0x8F), -}; -static const mbedtls_mpi_uint secp192k1_T_5_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x62, 0x45, 0xE5, 0x81, 0x9B, 0xEB, 0x37, 0x23), - MBEDTLS_BYTES_TO_T_UINT_8(0xB3, 0x29, 0xE2, 0x20, 0x64, 0x23, 0x6B, 0x6E), - MBEDTLS_BYTES_TO_T_UINT_8(0xFE, 0x1D, 0x41, 0xE1, 0x9B, 0x61, 0x7B, 0xD9), -}; -static const mbedtls_mpi_uint secp192k1_T_5_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x75, 0x57, 0xA3, 0x0A, 0x13, 0xE4, 0x59, 0x15), - MBEDTLS_BYTES_TO_T_UINT_8(0x79, 0x6E, 0x4A, 0x48, 0x84, 0x90, 0xAC, 0xC7), - MBEDTLS_BYTES_TO_T_UINT_8(0x9C, 0xB8, 0xF5, 0xF3, 0xDE, 0xA0, 0xA1, 0x1D), -}; -static const mbedtls_mpi_uint secp192k1_T_6_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA3, 0x32, 0x81, 0xA9, 0x91, 0x5A, 0x4E, 0x33), - MBEDTLS_BYTES_TO_T_UINT_8(0xCB, 0xA8, 0x90, 0xBE, 0x0F, 0xEC, 0xC0, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0x80, 0x30, 0xD7, 0x08, 0xAE, 0xC4, 0x3A, 0xA5), -}; -static const mbedtls_mpi_uint secp192k1_T_6_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0x55, 0xE3, 0x76, 0xB3, 0x64, 0x74, 0x9F), - MBEDTLS_BYTES_TO_T_UINT_8(0x3F, 0x75, 0xD4, 0xDB, 0x98, 0xD7, 0x39, 0xAE), - MBEDTLS_BYTES_TO_T_UINT_8(0xD4, 0xEB, 0x8A, 0xAB, 0x16, 0xD9, 0xD4, 0x0B), -}; -static const mbedtls_mpi_uint secp192k1_T_7_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x41, 0xBE, 0xF9, 0xC7, 0xC7, 0xBA, 0xF3, 0xA1), - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0x85, 0x59, 0xF3, 0x60, 0x41, 0x02, 0xD2), - MBEDTLS_BYTES_TO_T_UINT_8(0x46, 0x1C, 0x4A, 0xA4, 0xC7, 0xED, 0x66, 0xBC), -}; -static const mbedtls_mpi_uint secp192k1_T_7_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC3, 0x9C, 0x2E, 0x46, 0x52, 0x18, 0x87, 0x14), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0x35, 0x5A, 0x75, 0xAC, 0x4D, 0x75, 0x91), - MBEDTLS_BYTES_TO_T_UINT_8(0xCE, 0x2F, 0xAC, 0xFC, 0xBC, 0xE6, 0x93, 0x5E), -}; -static const mbedtls_mpi_uint secp192k1_T_8_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x87, 0x4D, 0xC9, 0x18, 0xE9, 0x00, 0xEB, 0x33), - MBEDTLS_BYTES_TO_T_UINT_8(0x1A, 0x69, 0x72, 0x07, 0x5A, 0x59, 0xA8, 0x26), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x65, 0x83, 0x20, 0x10, 0xF9, 0x69, 0x82), -}; -static const mbedtls_mpi_uint secp192k1_T_8_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x8B, 0x56, 0x7F, 0x9F, 0xBF, 0x46, 0x0C, 0x7E), - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0xCF, 0xF0, 0xDC, 0xDF, 0x2D, 0xE6, 0xE5), - MBEDTLS_BYTES_TO_T_UINT_8(0x09, 0xF0, 0x72, 0x3A, 0x7A, 0x03, 0xE5, 0x22), -}; -static const mbedtls_mpi_uint secp192k1_T_9_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x3E, 0xAA, 0x57, 0x13, 0x37, 0xA7, 0x2C, 0xD4), - MBEDTLS_BYTES_TO_T_UINT_8(0xA3, 0xAC, 0xA2, 0x23, 0xF9, 0x84, 0x60, 0xD3), - MBEDTLS_BYTES_TO_T_UINT_8(0x32, 0xEB, 0x51, 0x70, 0x64, 0x78, 0xCA, 0x05), -}; -static const mbedtls_mpi_uint secp192k1_T_9_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x91, 0xCC, 0x30, 0x62, 0x93, 0x46, 0x13, 0xE9), - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0x26, 0xCC, 0x6C, 0x3D, 0x5C, 0xDA, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0xD5, 0xAA, 0xB8, 0x03, 0xA4, 0x1A, 0x00, 0x96), -}; -static const mbedtls_mpi_uint secp192k1_T_10_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF9, 0x9D, 0xE6, 0xCC, 0x4E, 0x2E, 0xC2, 0xD5), - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0xC3, 0x8A, 0xAE, 0x6F, 0x40, 0x05, 0xEB), - MBEDTLS_BYTES_TO_T_UINT_8(0x9D, 0x8F, 0x4A, 0x4D, 0x35, 0xD3, 0x50, 0x9D), -}; -static const mbedtls_mpi_uint secp192k1_T_10_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1F, 0xFD, 0x98, 0xAB, 0xC7, 0x03, 0xB4, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0x40, 0x40, 0xD2, 0x9F, 0xCA, 0xD0, 0x53, 0x00), - MBEDTLS_BYTES_TO_T_UINT_8(0x1A, 0x84, 0x00, 0x6F, 0xC8, 0xAD, 0xED, 0x8D), -}; -static const mbedtls_mpi_uint secp192k1_T_11_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCE, 0xD3, 0x57, 0xD7, 0xC3, 0x07, 0xBD, 0xD7), - MBEDTLS_BYTES_TO_T_UINT_8(0x67, 0xBA, 0x47, 0x1D, 0x3D, 0xEF, 0x98, 0x6C), - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0xC0, 0x6C, 0x7F, 0x12, 0xEE, 0x9F, 0x67), -}; -static const mbedtls_mpi_uint secp192k1_T_11_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCA, 0x02, 0xDA, 0x79, 0xAA, 0xC9, 0x27, 0xC4), - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0x79, 0xC7, 0x71, 0x84, 0xCB, 0xE5, 0x5A), - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x37, 0x06, 0xBA, 0xB5, 0xD5, 0x18, 0x4C), -}; -static const mbedtls_mpi_uint secp192k1_T_12_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA1, 0x65, 0x72, 0x6C, 0xF2, 0x63, 0x27, 0x6A), - MBEDTLS_BYTES_TO_T_UINT_8(0x69, 0xBC, 0x71, 0xDF, 0x75, 0xF8, 0x98, 0x4D), - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0x70, 0x9B, 0xDC, 0xE7, 0x18, 0x71, 0xFF), -}; -static const mbedtls_mpi_uint secp192k1_T_12_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x5B, 0x9F, 0x00, 0x5A, 0xB6, 0x80, 0x7A), - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0xE0, 0xBB, 0xFC, 0x5E, 0x78, 0x9C, 0x89), - MBEDTLS_BYTES_TO_T_UINT_8(0x60, 0x03, 0x68, 0x83, 0x3D, 0x2E, 0x4C, 0xDD), -}; -static const mbedtls_mpi_uint secp192k1_T_13_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x3B, 0x49, 0x23, 0xA8, 0xCB, 0x3B, 0x1A, 0xF6), - MBEDTLS_BYTES_TO_T_UINT_8(0x8B, 0x3D, 0xA7, 0x46, 0xCF, 0x75, 0xB6, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0xFD, 0x30, 0x01, 0xB6, 0xEF, 0xF9, 0xE8), -}; -static const mbedtls_mpi_uint secp192k1_T_13_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xDC, 0xFA, 0xDA, 0xB8, 0x29, 0x42, 0xC9, 0xC7), - MBEDTLS_BYTES_TO_T_UINT_8(0x06, 0xD7, 0xA0, 0xE6, 0x6B, 0x86, 0x61, 0x39), - MBEDTLS_BYTES_TO_T_UINT_8(0xDB, 0xE9, 0xD3, 0x37, 0xD8, 0xE7, 0x35, 0xA9), -}; -static const mbedtls_mpi_uint secp192k1_T_14_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFD, 0xC8, 0x8E, 0xB1, 0xCB, 0xB1, 0xB5, 0x4D), - MBEDTLS_BYTES_TO_T_UINT_8(0x16, 0xD7, 0x46, 0x7D, 0xAF, 0xE2, 0xDC, 0xBB), - MBEDTLS_BYTES_TO_T_UINT_8(0xD0, 0x46, 0xE7, 0xD8, 0x76, 0x31, 0x90, 0x76), -}; -static const mbedtls_mpi_uint secp192k1_T_14_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xEB, 0xD3, 0xF4, 0x74, 0xE1, 0x67, 0xD8, 0x66), - MBEDTLS_BYTES_TO_T_UINT_8(0xE7, 0x70, 0x3C, 0xC8, 0xAF, 0x5F, 0xF4, 0x58), - MBEDTLS_BYTES_TO_T_UINT_8(0x24, 0x4E, 0xED, 0x5C, 0x43, 0xB3, 0x16, 0x35), -}; -static const mbedtls_mpi_uint secp192k1_T_15_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x57, 0xAE, 0xD1, 0xDD, 0x31, 0x14, 0xD3, 0xF0), - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0x14, 0x06, 0x13, 0x12, 0x1C, 0x81, 0xF5), - MBEDTLS_BYTES_TO_T_UINT_8(0xA6, 0xF9, 0x0C, 0x91, 0xF7, 0x67, 0x59, 0x63), -}; -static const mbedtls_mpi_uint secp192k1_T_15_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xAB, 0x91, 0xE2, 0xF4, 0x9D, 0xEB, 0x88, 0x87), - MBEDTLS_BYTES_TO_T_UINT_8(0xDB, 0x82, 0x30, 0x9C, 0xAE, 0x18, 0x4D, 0xB7), - MBEDTLS_BYTES_TO_T_UINT_8(0x3C, 0x79, 0xCF, 0x17, 0xA5, 0x1E, 0xE8, 0xC8), -}; -static const mbedtls_ecp_point secp192k1_T[16] = { - ECP_POINT_INIT_XY_Z1(secp192k1_T_0_X, secp192k1_T_0_Y), ECP_POINT_INIT_XY_Z0(secp192k1_T_1_X, secp192k1_T_1_Y), - ECP_POINT_INIT_XY_Z0(secp192k1_T_2_X, secp192k1_T_2_Y), ECP_POINT_INIT_XY_Z0(secp192k1_T_3_X, secp192k1_T_3_Y), - ECP_POINT_INIT_XY_Z0(secp192k1_T_4_X, secp192k1_T_4_Y), ECP_POINT_INIT_XY_Z0(secp192k1_T_5_X, secp192k1_T_5_Y), - ECP_POINT_INIT_XY_Z0(secp192k1_T_6_X, secp192k1_T_6_Y), ECP_POINT_INIT_XY_Z0(secp192k1_T_7_X, secp192k1_T_7_Y), - ECP_POINT_INIT_XY_Z0(secp192k1_T_8_X, secp192k1_T_8_Y), ECP_POINT_INIT_XY_Z0(secp192k1_T_9_X, secp192k1_T_9_Y), - ECP_POINT_INIT_XY_Z0(secp192k1_T_10_X, secp192k1_T_10_Y), ECP_POINT_INIT_XY_Z0(secp192k1_T_11_X, secp192k1_T_11_Y), - ECP_POINT_INIT_XY_Z0(secp192k1_T_12_X, secp192k1_T_12_Y), ECP_POINT_INIT_XY_Z0(secp192k1_T_13_X, secp192k1_T_13_Y), - ECP_POINT_INIT_XY_Z0(secp192k1_T_14_X, secp192k1_T_14_Y), ECP_POINT_INIT_XY_Z0(secp192k1_T_15_X, secp192k1_T_15_Y), -}; -#else -#define secp192k1_T NULL -#endif - -#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) -static const mbedtls_mpi_uint secp224k1_p[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0xE5, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_4(0xFF, 0xFF, 0xFF, 0xFF), -}; -static const mbedtls_mpi_uint secp224k1_a[] = { - MBEDTLS_BYTES_TO_T_UINT_2(0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_b[] = { - MBEDTLS_BYTES_TO_T_UINT_2(0x05, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_gx[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x5C, 0xA4, 0xB7, 0xB6, 0x0E, 0x65, 0x7E, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0xA9, 0x75, 0x70, 0xE4, 0xE9, 0x67, 0xA4, 0x69), - MBEDTLS_BYTES_TO_T_UINT_8(0xA1, 0x28, 0xFC, 0x30, 0xDF, 0x99, 0xF0, 0x4D), - MBEDTLS_BYTES_TO_T_UINT_4(0x33, 0x5B, 0x45, 0xA1), -}; -static const mbedtls_mpi_uint secp224k1_gy[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA5, 0x61, 0x6D, 0x55, 0xDB, 0x4B, 0xCA, 0xE2), - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0xBD, 0xB0, 0xC0, 0xF7, 0x19, 0xE3, 0xF7), - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0xFB, 0xCA, 0x82, 0x42, 0x34, 0xBA, 0x7F), - MBEDTLS_BYTES_TO_T_UINT_4(0xED, 0x9F, 0x08, 0x7E), -}; -static const mbedtls_mpi_uint secp224k1_n[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF7, 0xB1, 0x9F, 0x76, 0x71, 0xA9, 0xF0, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0x84, 0x61, 0xEC, 0xD2, 0xE8, 0xDC, 0x01, 0x00), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00), -}; - -#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 -static const mbedtls_mpi_uint secp224k1_T_0_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x5C, 0xA4, 0xB7, 0xB6, 0x0E, 0x65, 0x7E, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0xA9, 0x75, 0x70, 0xE4, 0xE9, 0x67, 0xA4, 0x69), - MBEDTLS_BYTES_TO_T_UINT_8(0xA1, 0x28, 0xFC, 0x30, 0xDF, 0x99, 0xF0, 0x4D), - MBEDTLS_BYTES_TO_T_UINT_8(0x33, 0x5B, 0x45, 0xA1, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_0_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA5, 0x61, 0x6D, 0x55, 0xDB, 0x4B, 0xCA, 0xE2), - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0xBD, 0xB0, 0xC0, 0xF7, 0x19, 0xE3, 0xF7), - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0xFB, 0xCA, 0x82, 0x42, 0x34, 0xBA, 0x7F), - MBEDTLS_BYTES_TO_T_UINT_8(0xED, 0x9F, 0x08, 0x7E, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_1_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0x6C, 0x22, 0x22, 0x40, 0x89, 0xAE, 0x7A), - MBEDTLS_BYTES_TO_T_UINT_8(0x2F, 0x92, 0xE1, 0x87, 0x56, 0x35, 0xAF, 0x9B), - MBEDTLS_BYTES_TO_T_UINT_8(0x88, 0xAF, 0x08, 0x35, 0x27, 0xEA, 0x04, 0xED), - MBEDTLS_BYTES_TO_T_UINT_8(0xF0, 0x53, 0xFD, 0xCF, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_1_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC1, 0xD0, 0x9F, 0x8D, 0xF3, 0x63, 0x54, 0x30), - MBEDTLS_BYTES_TO_T_UINT_8(0x39, 0xDB, 0x0F, 0x61, 0x54, 0x26, 0xD1, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0x21, 0xF7, 0x1B, 0xB5, 0x1D, 0xF6, 0x7E), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0x05, 0xDA, 0x8F, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_2_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x10, 0x26, 0x73, 0xBC, 0xE4, 0x29, 0x62, 0x56), - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0x95, 0x17, 0x8B, 0xC3, 0x9B, 0xAC, 0xCC), - MBEDTLS_BYTES_TO_T_UINT_8(0xB1, 0xDB, 0x77, 0xDF, 0xDD, 0x13, 0x04, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0x02, 0xFC, 0x22, 0x93, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_2_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0x65, 0xF1, 0x5A, 0x37, 0xEF, 0x79, 0xAD), - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0x01, 0x37, 0xAC, 0x9A, 0x5B, 0x51, 0x65), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0x75, 0x13, 0xA9, 0x4A, 0xAD, 0xFE, 0x9B), - MBEDTLS_BYTES_TO_T_UINT_8(0x32, 0x82, 0x6F, 0x66, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_3_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x4D, 0x5E, 0xF0, 0x40, 0xC3, 0xA6, 0xE2, 0x1E), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0x9A, 0x6F, 0xCF, 0x11, 0x26, 0x66, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0x79, 0x73, 0xA8, 0xCF, 0x2B, 0x12, 0x36, 0x37), - MBEDTLS_BYTES_TO_T_UINT_8(0xB9, 0xB3, 0x0A, 0x58, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_3_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xD3, 0x79, 0x00, 0x55, 0x04, 0x34, 0x90, 0x1A), - MBEDTLS_BYTES_TO_T_UINT_8(0x0A, 0x54, 0x1C, 0xC2, 0x45, 0x0C, 0x1B, 0x23), - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0x19, 0xAB, 0xA8, 0xFC, 0x73, 0xDC, 0xEE), - MBEDTLS_BYTES_TO_T_UINT_8(0x72, 0xFB, 0x93, 0xCE, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_4_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF8, 0x75, 0xD0, 0x66, 0x95, 0x86, 0xCA, 0x66), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0xEA, 0x29, 0x16, 0x6A, 0x38, 0xDF, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0xD8, 0xA2, 0x36, 0x2F, 0xDC, 0xBB, 0x5E, 0xF7), - MBEDTLS_BYTES_TO_T_UINT_8(0xD4, 0x89, 0x59, 0x49, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_4_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCA, 0xA3, 0x99, 0x9D, 0xB8, 0x77, 0x9D, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0x0A, 0x93, 0x43, 0x47, 0xC6, 0x5C, 0xF9, 0xFD), - MBEDTLS_BYTES_TO_T_UINT_8(0xAA, 0x00, 0x79, 0x42, 0x64, 0xB8, 0x25, 0x3E), - MBEDTLS_BYTES_TO_T_UINT_8(0x29, 0x54, 0xB4, 0x33, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_5_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0x0C, 0x42, 0x90, 0x83, 0x0B, 0x31, 0x5F), - MBEDTLS_BYTES_TO_T_UINT_8(0x54, 0x2E, 0xAE, 0xC8, 0xC7, 0x5F, 0xD2, 0x70), - MBEDTLS_BYTES_TO_T_UINT_8(0xA9, 0xBC, 0xAD, 0x41, 0xE7, 0x32, 0x3A, 0x81), - MBEDTLS_BYTES_TO_T_UINT_8(0x8A, 0x97, 0x52, 0x83, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_5_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1A, 0x13, 0x7A, 0xBD, 0xAE, 0x94, 0x60, 0xFD), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0x9B, 0x95, 0xB4, 0x6E, 0x68, 0xB2, 0x1F), - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x49, 0xBE, 0x51, 0xFE, 0x66, 0x15, 0x74), - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0x37, 0xE4, 0xFE, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_6_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF6, 0x9B, 0xEE, 0x64, 0xC9, 0x1B, 0xBD, 0x77), - MBEDTLS_BYTES_TO_T_UINT_8(0xDA, 0x5F, 0x34, 0xA9, 0x0B, 0xB7, 0x25, 0x52), - MBEDTLS_BYTES_TO_T_UINT_8(0x90, 0x13, 0xB1, 0x38, 0xFB, 0x9D, 0x78, 0xED), - MBEDTLS_BYTES_TO_T_UINT_8(0x39, 0xE7, 0x1B, 0xFA, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_6_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFB, 0xB3, 0xB7, 0x44, 0x92, 0x6B, 0x00, 0x82), - MBEDTLS_BYTES_TO_T_UINT_8(0x97, 0x82, 0x44, 0x3E, 0x18, 0x1A, 0x58, 0x6A), - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0xF8, 0xC0, 0xE4, 0xEE, 0xC1, 0xBF, 0x44), - MBEDTLS_BYTES_TO_T_UINT_8(0x7E, 0x32, 0x27, 0xB2, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_7_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF4, 0x9A, 0x42, 0x62, 0x8B, 0x26, 0x54, 0x21), - MBEDTLS_BYTES_TO_T_UINT_8(0x24, 0x85, 0x74, 0xA0, 0x79, 0xA8, 0xEE, 0xBE), - MBEDTLS_BYTES_TO_T_UINT_8(0x80, 0x36, 0x60, 0xB3, 0x28, 0x4D, 0x55, 0xBE), - MBEDTLS_BYTES_TO_T_UINT_8(0x32, 0x27, 0x82, 0x29, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_7_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x0D, 0xFC, 0x73, 0x77, 0xAF, 0x5C, 0xAC, 0x78), - MBEDTLS_BYTES_TO_T_UINT_8(0xCC, 0xED, 0xE5, 0xF6, 0x1D, 0xA8, 0x67, 0x43), - MBEDTLS_BYTES_TO_T_UINT_8(0xF8, 0xDE, 0x33, 0x1C, 0xF1, 0x80, 0x73, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0xE2, 0xDE, 0x3C, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_8_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x57, 0x3E, 0x6B, 0xFE, 0xF0, 0x04, 0x28, 0x01), - MBEDTLS_BYTES_TO_T_UINT_8(0xBB, 0xB2, 0x14, 0x9D, 0x18, 0x11, 0x7D, 0x9D), - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0xC4, 0xD6, 0x2E, 0x6E, 0x57, 0x4D, 0xE1), - MBEDTLS_BYTES_TO_T_UINT_8(0xEA, 0x55, 0x1B, 0xDE, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_8_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0xF7, 0x17, 0xBC, 0x45, 0xAB, 0x16, 0xAB), - MBEDTLS_BYTES_TO_T_UINT_8(0xCD, 0xB0, 0xEF, 0x61, 0xE3, 0x20, 0x7C, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x85, 0x41, 0x4D, 0xF1, 0x7E, 0x4D, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0xC2, 0x9B, 0x5E, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_9_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0x2E, 0x49, 0x3D, 0x3E, 0x4B, 0xD3, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0xC8, 0x2B, 0x9D, 0xD5, 0x27, 0xFA, 0xCA, 0xE0), - MBEDTLS_BYTES_TO_T_UINT_8(0xB3, 0xB3, 0x6A, 0xE0, 0x79, 0x14, 0x28, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x1E, 0xDC, 0xF5, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_9_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCA, 0x44, 0x56, 0xCD, 0xFC, 0x9F, 0x09, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0x5C, 0x8C, 0x59, 0xA4, 0x64, 0x2A, 0x3A, 0xED), - MBEDTLS_BYTES_TO_T_UINT_8(0x40, 0xA0, 0xB5, 0x86, 0x4E, 0x69, 0xDA, 0x06), - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0x8B, 0x11, 0x38, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_10_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0x17, 0x16, 0x12, 0x17, 0xDC, 0x00, 0x7E), - MBEDTLS_BYTES_TO_T_UINT_8(0xE7, 0x76, 0x24, 0x6C, 0x97, 0x2C, 0xB5, 0xF9), - MBEDTLS_BYTES_TO_T_UINT_8(0x82, 0x71, 0xE3, 0xB0, 0xBB, 0x4E, 0x50, 0x52), - MBEDTLS_BYTES_TO_T_UINT_8(0x6E, 0x48, 0x26, 0xD5, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_10_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x06, 0x5F, 0x28, 0xF6, 0x01, 0x5A, 0x60, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0xAE, 0x95, 0xFE, 0xD0, 0xAD, 0x15, 0xD4, 0xD9), - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0x5B, 0x7A, 0xFD, 0x80, 0xF7, 0x9F, 0x64), - MBEDTLS_BYTES_TO_T_UINT_8(0x32, 0xBC, 0x1B, 0xDF, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_11_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xBB, 0xE6, 0xDF, 0x14, 0x29, 0xF4, 0xD4, 0x14), - MBEDTLS_BYTES_TO_T_UINT_8(0xE5, 0x12, 0xDD, 0xEC, 0x5B, 0x8A, 0x59, 0xE5), - MBEDTLS_BYTES_TO_T_UINT_8(0x26, 0x92, 0x3E, 0x35, 0x08, 0xE9, 0xCF, 0x0E), - MBEDTLS_BYTES_TO_T_UINT_8(0xE0, 0x35, 0x29, 0x97, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_11_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0xDB, 0xD6, 0x6A, 0xC5, 0x43, 0xA4, 0xA1), - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0x33, 0x50, 0x61, 0x70, 0xA1, 0xE9, 0xCE), - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x15, 0x6E, 0x5F, 0x01, 0x0C, 0x8C, 0xFA), - MBEDTLS_BYTES_TO_T_UINT_8(0x85, 0xA1, 0x9A, 0x9D, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_12_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x6E, 0xC6, 0xF7, 0xE2, 0x4A, 0xCD, 0x9B, 0x61), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0x4D, 0x5A, 0xB8, 0xE2, 0x6D, 0xA6, 0x50), - MBEDTLS_BYTES_TO_T_UINT_8(0x32, 0x3F, 0xB6, 0x17, 0xE3, 0x2C, 0x6F, 0x65), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0xA4, 0x59, 0x51, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_12_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x77, 0x4F, 0x7C, 0x49, 0xCD, 0x6E, 0xEB, 0x3C), - MBEDTLS_BYTES_TO_T_UINT_8(0x05, 0xC9, 0x1F, 0xB7, 0x4D, 0x98, 0xC7, 0x67), - MBEDTLS_BYTES_TO_T_UINT_8(0x4C, 0xFD, 0x98, 0x20, 0x95, 0xBB, 0x20, 0x3A), - MBEDTLS_BYTES_TO_T_UINT_8(0xE0, 0xF2, 0x73, 0x92, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_13_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xE2, 0xEF, 0xFB, 0x30, 0xFA, 0x12, 0x1A, 0xB0), - MBEDTLS_BYTES_TO_T_UINT_8(0x7A, 0x4C, 0x24, 0xB4, 0x5B, 0xC9, 0x4C, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0x7A, 0xDD, 0x5E, 0x84, 0x95, 0x4D, 0x26, 0xED), - MBEDTLS_BYTES_TO_T_UINT_8(0xE3, 0xFA, 0xF9, 0x3A, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_13_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x6A, 0xA3, 0x2E, 0x7A, 0xDC, 0xA7, 0x53, 0xA9), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0x9F, 0x81, 0x84, 0xB2, 0x0D, 0xFE, 0x31), - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0x89, 0x1B, 0x77, 0x0C, 0x89, 0x71, 0xEC), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0xFF, 0x7F, 0xB2, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_14_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0xE9, 0x2C, 0x79, 0xA6, 0x3C, 0xAD, 0x93), - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0xE0, 0x23, 0x02, 0x86, 0x0F, 0x77, 0x2A), - MBEDTLS_BYTES_TO_T_UINT_8(0x13, 0x93, 0x6D, 0xE9, 0xF9, 0x3C, 0xBE, 0xB9), - MBEDTLS_BYTES_TO_T_UINT_8(0x04, 0xE7, 0x24, 0x92, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_14_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xBB, 0x3C, 0x5B, 0x4B, 0x1B, 0x25, 0x37, 0xD6), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0xE8, 0x38, 0x1B, 0xA1, 0x5A, 0x2E, 0x68), - MBEDTLS_BYTES_TO_T_UINT_8(0x03, 0x19, 0xFD, 0xF4, 0x78, 0x01, 0x6B, 0x44), - MBEDTLS_BYTES_TO_T_UINT_8(0x0F, 0x69, 0x37, 0x4F, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_15_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1A, 0xE2, 0xBF, 0xD3, 0xEC, 0x95, 0x9C, 0x03), - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0x7B, 0xFC, 0xD5, 0xD3, 0x25, 0x5E, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0x39, 0x55, 0x09, 0xA2, 0x58, 0x6A, 0xC9, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0x80, 0xCC, 0x3B, 0xD9, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_mpi_uint secp224k1_T_15_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x8F, 0x08, 0x65, 0x5E, 0xCB, 0xAB, 0x48, 0xC8), - MBEDTLS_BYTES_TO_T_UINT_8(0xEE, 0x79, 0x8B, 0xC0, 0x11, 0xC0, 0x69, 0x38), - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0xE8, 0x8C, 0x4C, 0xC5, 0x28, 0xE4, 0xAE), - MBEDTLS_BYTES_TO_T_UINT_8(0xA5, 0x1F, 0x34, 0x5C, 0x00, 0x00, 0x00, 0x00), -}; -static const mbedtls_ecp_point secp224k1_T[16] = { - ECP_POINT_INIT_XY_Z1(secp224k1_T_0_X, secp224k1_T_0_Y), ECP_POINT_INIT_XY_Z0(secp224k1_T_1_X, secp224k1_T_1_Y), - ECP_POINT_INIT_XY_Z0(secp224k1_T_2_X, secp224k1_T_2_Y), ECP_POINT_INIT_XY_Z0(secp224k1_T_3_X, secp224k1_T_3_Y), - ECP_POINT_INIT_XY_Z0(secp224k1_T_4_X, secp224k1_T_4_Y), ECP_POINT_INIT_XY_Z0(secp224k1_T_5_X, secp224k1_T_5_Y), - ECP_POINT_INIT_XY_Z0(secp224k1_T_6_X, secp224k1_T_6_Y), ECP_POINT_INIT_XY_Z0(secp224k1_T_7_X, secp224k1_T_7_Y), - ECP_POINT_INIT_XY_Z0(secp224k1_T_8_X, secp224k1_T_8_Y), ECP_POINT_INIT_XY_Z0(secp224k1_T_9_X, secp224k1_T_9_Y), - ECP_POINT_INIT_XY_Z0(secp224k1_T_10_X, secp224k1_T_10_Y), ECP_POINT_INIT_XY_Z0(secp224k1_T_11_X, secp224k1_T_11_Y), - ECP_POINT_INIT_XY_Z0(secp224k1_T_12_X, secp224k1_T_12_Y), ECP_POINT_INIT_XY_Z0(secp224k1_T_13_X, secp224k1_T_13_Y), - ECP_POINT_INIT_XY_Z0(secp224k1_T_14_X, secp224k1_T_14_Y), ECP_POINT_INIT_XY_Z0(secp224k1_T_15_X, secp224k1_T_15_Y), -}; -#else -#define secp224k1_T NULL -#endif -#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) -static const mbedtls_mpi_uint secp256k1_p[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x2F, 0xFC, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), -}; -static const mbedtls_mpi_uint secp256k1_a[] = { - MBEDTLS_BYTES_TO_T_UINT_2(0x00, 0x00), -}; -static const mbedtls_mpi_uint secp256k1_b[] = { - MBEDTLS_BYTES_TO_T_UINT_2(0x07, 0x00), -}; -static const mbedtls_mpi_uint secp256k1_gx[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0x17, 0xF8, 0x16, 0x5B, 0x81, 0xF2, 0x59), - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0x28, 0xCE, 0x2D, 0xDB, 0xFC, 0x9B, 0x02), - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0x0B, 0x87, 0xCE, 0x95, 0x62, 0xA0, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0xBB, 0xDC, 0xF9, 0x7E, 0x66, 0xBE, 0x79), -}; -static const mbedtls_mpi_uint secp256k1_gy[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB8, 0xD4, 0x10, 0xFB, 0x8F, 0xD0, 0x47, 0x9C), - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0x54, 0x85, 0xA6, 0x48, 0xB4, 0x17, 0xFD), - MBEDTLS_BYTES_TO_T_UINT_8(0xA8, 0x08, 0x11, 0x0E, 0xFC, 0xFB, 0xA4, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0x65, 0xC4, 0xA3, 0x26, 0x77, 0xDA, 0x3A, 0x48), -}; -static const mbedtls_mpi_uint secp256k1_n[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x41, 0x41, 0x36, 0xD0, 0x8C, 0x5E, 0xD2, 0xBF), - MBEDTLS_BYTES_TO_T_UINT_8(0x3B, 0xA0, 0x48, 0xAF, 0xE6, 0xDC, 0xAE, 0xBA), - MBEDTLS_BYTES_TO_T_UINT_8(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), -}; - -#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 -static const mbedtls_mpi_uint secp256k1_T_0_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0x17, 0xF8, 0x16, 0x5B, 0x81, 0xF2, 0x59), - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0x28, 0xCE, 0x2D, 0xDB, 0xFC, 0x9B, 0x02), - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0x0B, 0x87, 0xCE, 0x95, 0x62, 0xA0, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0xBB, 0xDC, 0xF9, 0x7E, 0x66, 0xBE, 0x79), -}; -static const mbedtls_mpi_uint secp256k1_T_0_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB8, 0xD4, 0x10, 0xFB, 0x8F, 0xD0, 0x47, 0x9C), - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0x54, 0x85, 0xA6, 0x48, 0xB4, 0x17, 0xFD), - MBEDTLS_BYTES_TO_T_UINT_8(0xA8, 0x08, 0x11, 0x0E, 0xFC, 0xFB, 0xA4, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0x65, 0xC4, 0xA3, 0x26, 0x77, 0xDA, 0x3A, 0x48), -}; -static const mbedtls_mpi_uint secp256k1_T_1_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xE7, 0xEE, 0xD7, 0x1E, 0x67, 0x86, 0x32, 0x74), - MBEDTLS_BYTES_TO_T_UINT_8(0x23, 0x73, 0xB1, 0xA9, 0xD5, 0xCC, 0x27, 0x78), - MBEDTLS_BYTES_TO_T_UINT_8(0x1F, 0x0E, 0x11, 0x01, 0x71, 0xFE, 0x92, 0x73), - MBEDTLS_BYTES_TO_T_UINT_8(0xC6, 0x28, 0x63, 0x6D, 0x72, 0x09, 0xA6, 0xC0), -}; -static const mbedtls_mpi_uint secp256k1_T_1_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCE, 0xE1, 0x69, 0xDC, 0x3E, 0x2C, 0x75, 0xC3), - MBEDTLS_BYTES_TO_T_UINT_8(0xE5, 0xB7, 0x3F, 0x30, 0x26, 0x3C, 0xDF, 0x8E), - MBEDTLS_BYTES_TO_T_UINT_8(0x3D, 0xBE, 0xB9, 0x5D, 0x0E, 0xE8, 0x5E, 0x14), - MBEDTLS_BYTES_TO_T_UINT_8(0x01, 0xC3, 0x05, 0xD6, 0xB7, 0xD5, 0x24, 0xFC), -}; -static const mbedtls_mpi_uint secp256k1_T_2_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x13, 0xCF, 0x7B, 0xDC, 0xCD, 0xC3, 0x39, 0x9D), - MBEDTLS_BYTES_TO_T_UINT_8(0x42, 0xDA, 0xB9, 0xE5, 0x64, 0xA7, 0x47, 0x91), - MBEDTLS_BYTES_TO_T_UINT_8(0x76, 0x46, 0xA8, 0x61, 0xF6, 0x23, 0xEB, 0x58), - MBEDTLS_BYTES_TO_T_UINT_8(0x5C, 0xC1, 0xFF, 0xE4, 0x55, 0xD5, 0xC2, 0xBF), -}; -static const mbedtls_mpi_uint secp256k1_T_2_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0xBE, 0xB9, 0x59, 0x24, 0x13, 0x4A, 0x2A), - MBEDTLS_BYTES_TO_T_UINT_8(0x64, 0x45, 0x12, 0xDE, 0xBA, 0x4F, 0xEF, 0x56), - MBEDTLS_BYTES_TO_T_UINT_8(0xBE, 0x08, 0xBF, 0xC1, 0x66, 0xAA, 0x0A, 0xBC), - MBEDTLS_BYTES_TO_T_UINT_8(0x36, 0xFE, 0x30, 0x55, 0x31, 0x86, 0xA7, 0xB4), -}; -static const mbedtls_mpi_uint secp256k1_T_3_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0xBF, 0x18, 0x81, 0x67, 0x27, 0x42, 0xBD), - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0x05, 0x83, 0xA4, 0xDD, 0x57, 0xD3, 0x50), - MBEDTLS_BYTES_TO_T_UINT_8(0x20, 0x63, 0xAB, 0xE4, 0x90, 0x70, 0xD0, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0x71, 0x5D, 0xFD, 0xA0, 0xEF, 0xCF, 0x1C, 0x54), -}; -static const mbedtls_mpi_uint secp256k1_T_3_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x13, 0x80, 0xE4, 0xF6, 0x09, 0xBC, 0x57, 0x90), - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0x9F, 0x6E, 0x88, 0x54, 0x6E, 0x51, 0xF2), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0x5F, 0x85, 0xFB, 0x84, 0x3E, 0x4A, 0xAA), - MBEDTLS_BYTES_TO_T_UINT_8(0xA8, 0x19, 0xF5, 0x55, 0xC9, 0x07, 0xD8, 0xCE), -}; -static const mbedtls_mpi_uint secp256k1_T_4_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1A, 0xB4, 0xC3, 0xD9, 0x5C, 0xA0, 0xD4, 0x90), - MBEDTLS_BYTES_TO_T_UINT_8(0x0D, 0x30, 0xAF, 0x59, 0x9B, 0xF8, 0x04, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0x4D, 0xA6, 0xFD, 0x66, 0x7B, 0xC3, 0x39, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0xE0, 0xBF, 0xF0, 0xC2, 0xE9, 0x71, 0xA4, 0x9E), -}; -static const mbedtls_mpi_uint secp256k1_T_4_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x14, 0x2D, 0xB9, 0x88, 0x28, 0xF1, 0xBE, 0x78), - MBEDTLS_BYTES_TO_T_UINT_8(0x14, 0xF3, 0x1A, 0x0E, 0xB9, 0x01, 0x66, 0x34), - MBEDTLS_BYTES_TO_T_UINT_8(0x77, 0xA7, 0xA4, 0xF4, 0x05, 0xD0, 0xAA, 0x53), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x39, 0x1E, 0x47, 0xE5, 0x68, 0xC8, 0xC0), -}; -static const mbedtls_mpi_uint secp256k1_T_5_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xDD, 0xB9, 0xFC, 0xE0, 0x33, 0x8A, 0x7D, 0x96), - MBEDTLS_BYTES_TO_T_UINT_8(0x4F, 0x93, 0xA5, 0x53, 0x55, 0x16, 0xB4, 0x6E), - MBEDTLS_BYTES_TO_T_UINT_8(0xE9, 0x5F, 0xEA, 0x9B, 0x29, 0x52, 0x71, 0xDA), - MBEDTLS_BYTES_TO_T_UINT_8(0xB2, 0xF0, 0x24, 0xB8, 0x7D, 0xB7, 0xA0, 0x9B), -}; -static const mbedtls_mpi_uint secp256k1_T_5_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0x00, 0x27, 0xB2, 0xDF, 0x73, 0xA2, 0xE0), - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0x2E, 0x4D, 0x7C, 0xDE, 0x7A, 0x23, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0x65, 0x60, 0xC7, 0x97, 0x1E, 0xA4, 0x22), - MBEDTLS_BYTES_TO_T_UINT_8(0xCD, 0x13, 0x5B, 0x77, 0x59, 0xCB, 0x36, 0xE1), -}; -static const mbedtls_mpi_uint secp256k1_T_6_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0xBC, 0x9F, 0x9E, 0x2D, 0x53, 0x2A, 0xA8), - MBEDTLS_BYTES_TO_T_UINT_8(0x87, 0x5F, 0x64, 0x9F, 0x1A, 0x19, 0xE6, 0x77), - MBEDTLS_BYTES_TO_T_UINT_8(0x9E, 0x7B, 0x39, 0xD2, 0xDB, 0x85, 0x84, 0xD5), - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0xC7, 0x0D, 0x58, 0x6E, 0x3F, 0x52, 0x15), -}; -static const mbedtls_mpi_uint secp256k1_T_6_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0x68, 0x19, 0x0B, 0x68, 0xC9, 0x1E, 0xFB), - MBEDTLS_BYTES_TO_T_UINT_8(0xD2, 0x4E, 0x21, 0x49, 0x3D, 0x55, 0xCC, 0x25), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0xF9, 0x25, 0x45, 0x54, 0x45, 0xB1, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0xA9, 0xB3, 0xF7, 0xCD, 0x80, 0xA4, 0x04, 0x05), -}; -static const mbedtls_mpi_uint secp256k1_T_7_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xD4, 0x1E, 0x88, 0xC4, 0xAA, 0x18, 0x7E, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0x4B, 0xAC, 0xD9, 0xB2, 0xA1, 0xC0, 0x71, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0xA9, 0xA2, 0xF1, 0x15, 0xA6, 0x5F, 0x6C, 0x86), - MBEDTLS_BYTES_TO_T_UINT_8(0x4F, 0x5B, 0x05, 0xBC, 0xB7, 0xC6, 0x4E, 0x72), -}; -static const mbedtls_mpi_uint secp256k1_T_7_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0x80, 0xF8, 0x5C, 0x20, 0x2A, 0xE1, 0xE2), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0x48, 0x2E, 0x68, 0x82, 0x7F, 0xEB, 0x5F), - MBEDTLS_BYTES_TO_T_UINT_8(0xA2, 0x3B, 0x25, 0xDB, 0x32, 0x4D, 0x88, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0xEE, 0x6E, 0xA6, 0xB6, 0x6D, 0x62, 0x78, 0x22), -}; -static const mbedtls_mpi_uint secp256k1_T_8_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1F, 0x4D, 0x3E, 0x86, 0x58, 0xC3, 0xEB, 0xBA), - MBEDTLS_BYTES_TO_T_UINT_8(0x1A, 0x89, 0x33, 0x18, 0x21, 0x1D, 0x9B, 0xE7), - MBEDTLS_BYTES_TO_T_UINT_8(0x0B, 0x9D, 0xFF, 0xC3, 0x79, 0xC1, 0x88, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0xD4, 0x48, 0x53, 0xE8, 0xAD, 0x21, 0x16), -}; -static const mbedtls_mpi_uint secp256k1_T_8_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0x7B, 0xDE, 0xCB, 0xD8, 0x39, 0x17, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0xD3, 0xF3, 0x03, 0xF2, 0x5C, 0xBC, 0xC8, 0x8A), - MBEDTLS_BYTES_TO_T_UINT_8(0x27, 0xAE, 0x4C, 0xB0, 0x16, 0xA4, 0x93, 0x86), - MBEDTLS_BYTES_TO_T_UINT_8(0x71, 0x8B, 0x6B, 0xDC, 0xD7, 0x9A, 0x3E, 0x7E), -}; -static const mbedtls_mpi_uint secp256k1_T_9_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0x2D, 0x7A, 0xD2, 0x59, 0x05, 0xA2, 0x82), - MBEDTLS_BYTES_TO_T_UINT_8(0x57, 0x56, 0x09, 0x32, 0xF1, 0xE8, 0xE3, 0x72), - MBEDTLS_BYTES_TO_T_UINT_8(0x03, 0xCA, 0xE5, 0x2E, 0xF0, 0xFB, 0x18, 0x19), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0x85, 0xA9, 0x23, 0x15, 0x31, 0x1F, 0x0E), -}; -static const mbedtls_mpi_uint secp256k1_T_9_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x76, 0xE5, 0xB1, 0x86, 0xB9, 0x6E, 0x8D, 0xD3), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x77, 0xFC, 0xC9, 0xA3, 0x3F, 0x89, 0xD2), - MBEDTLS_BYTES_TO_T_UINT_8(0xDB, 0x6A, 0xDC, 0x25, 0xB0, 0xC7, 0x41, 0x54), - MBEDTLS_BYTES_TO_T_UINT_8(0x02, 0x11, 0x6B, 0xA6, 0x11, 0x62, 0xD4, 0x2D), -}; -static const mbedtls_mpi_uint secp256k1_T_10_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0x7D, 0x34, 0xB3, 0x20, 0x7F, 0x37, 0xAA), - MBEDTLS_BYTES_TO_T_UINT_8(0xBD, 0xD4, 0x45, 0xE8, 0xC2, 0xE9, 0xC5, 0xEA), - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0x32, 0x3B, 0x25, 0x7E, 0x79, 0xAF, 0xE7), - MBEDTLS_BYTES_TO_T_UINT_8(0x3F, 0xE4, 0x54, 0x71, 0xBE, 0x35, 0x4E, 0xD0), -}; -static const mbedtls_mpi_uint secp256k1_T_10_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB0, 0x94, 0xDD, 0x8F, 0xB5, 0xC2, 0xDD, 0x75), - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0x49, 0xE9, 0x1C, 0x2F, 0x08, 0x49, 0xC6), - MBEDTLS_BYTES_TO_T_UINT_8(0x77, 0xB6, 0x03, 0x88, 0x6F, 0xB8, 0x15, 0x67), - MBEDTLS_BYTES_TO_T_UINT_8(0xA4, 0xD3, 0x1C, 0xF3, 0xA5, 0xEB, 0x79, 0x01), -}; -static const mbedtls_mpi_uint secp256k1_T_11_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x25, 0xF9, 0x43, 0x88, 0x89, 0x0D, 0x06, 0xEA), - MBEDTLS_BYTES_TO_T_UINT_8(0x02, 0x2D, 0xF5, 0x98, 0x32, 0xF6, 0xB1, 0x05), - MBEDTLS_BYTES_TO_T_UINT_8(0x23, 0x73, 0x8F, 0x2B, 0x50, 0x27, 0x0A, 0xE7), - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0xE3, 0xBD, 0x16, 0x05, 0xC8, 0x93, 0x12), -}; -static const mbedtls_mpi_uint secp256k1_T_11_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x0A, 0x6A, 0xF7, 0xE3, 0x3D, 0xDE, 0x5F, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0x47, 0xA3, 0x9C, 0x22, 0x3C, 0x33, 0x36, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0x20, 0x24, 0x4C, 0x69, 0x45, 0x78, 0x14, 0xAE), - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0xF8, 0xD4, 0xBF, 0xB8, 0xC0, 0xA1, 0x25), -}; -static const mbedtls_mpi_uint secp256k1_T_12_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x7E, 0x88, 0xE1, 0x91, 0x03, 0xEB, 0xB3, 0x2B), - MBEDTLS_BYTES_TO_T_UINT_8(0x5C, 0x11, 0xA1, 0xEF, 0x14, 0x0D, 0xC4, 0x7D), - MBEDTLS_BYTES_TO_T_UINT_8(0xFE, 0xD4, 0x0D, 0x1D, 0x96, 0x33, 0x5C, 0x19), - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0x45, 0x2A, 0x1A, 0xE6, 0x57, 0x04, 0x9B), -}; -static const mbedtls_mpi_uint secp256k1_T_12_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0xB5, 0xA7, 0x80, 0xE9, 0x93, 0x97, 0x8D), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0xB9, 0x7C, 0xA0, 0xC9, 0x57, 0x26, 0x43), - MBEDTLS_BYTES_TO_T_UINT_8(0x9E, 0xEF, 0x56, 0xDA, 0x66, 0xF6, 0x1B, 0x9A), - MBEDTLS_BYTES_TO_T_UINT_8(0x1F, 0x89, 0x6B, 0x91, 0xE0, 0xA9, 0x65, 0x2B), -}; -static const mbedtls_mpi_uint secp256k1_T_13_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x91, 0x98, 0x96, 0x9B, 0x06, 0x7D, 0x5E, 0x5A), - MBEDTLS_BYTES_TO_T_UINT_8(0x0A, 0xFA, 0xC1, 0x5F, 0x19, 0x37, 0x94, 0x9D), - MBEDTLS_BYTES_TO_T_UINT_8(0xCF, 0xBE, 0x6B, 0x1A, 0x05, 0xE4, 0xBF, 0x9F), - MBEDTLS_BYTES_TO_T_UINT_8(0x84, 0xCD, 0x5D, 0x35, 0xB4, 0x51, 0xF7, 0x64), -}; -static const mbedtls_mpi_uint secp256k1_T_13_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0xEF, 0x96, 0xDB, 0xF2, 0x61, 0x63, 0x59), - MBEDTLS_BYTES_TO_T_UINT_8(0xCB, 0x04, 0x88, 0xC9, 0x9F, 0x1B, 0x94, 0xB9), - MBEDTLS_BYTES_TO_T_UINT_8(0xDB, 0x30, 0x79, 0x7E, 0x24, 0xE7, 0x5F, 0xB8), - MBEDTLS_BYTES_TO_T_UINT_8(0x3F, 0xB8, 0x90, 0xB7, 0x94, 0x25, 0xBB, 0x0F), -}; -static const mbedtls_mpi_uint secp256k1_T_14_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x62, 0x79, 0xEA, 0xAD, 0xC0, 0x6D, 0x18, 0x57), - MBEDTLS_BYTES_TO_T_UINT_8(0xE9, 0xA4, 0x58, 0x2A, 0x8D, 0x95, 0xB3, 0xE6), - MBEDTLS_BYTES_TO_T_UINT_8(0xC8, 0xC4, 0xC2, 0x12, 0x0D, 0x79, 0xE2, 0x2B), - MBEDTLS_BYTES_TO_T_UINT_8(0x02, 0x6F, 0xBE, 0x97, 0x4D, 0xA4, 0x20, 0x07), -}; -static const mbedtls_mpi_uint secp256k1_T_14_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCA, 0x31, 0x71, 0xC6, 0xA6, 0x91, 0xEB, 0x1F), - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0x9B, 0xA8, 0x4A, 0xE7, 0x77, 0xE1, 0xAA), - MBEDTLS_BYTES_TO_T_UINT_8(0xA9, 0x06, 0xD3, 0x3D, 0x94, 0x30, 0xEF, 0x8C), - MBEDTLS_BYTES_TO_T_UINT_8(0xE7, 0xDF, 0xCA, 0xFA, 0xF5, 0x28, 0xF8, 0xC9), -}; -static const mbedtls_mpi_uint secp256k1_T_15_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCC, 0xE1, 0x32, 0xFD, 0x3E, 0x81, 0xF8, 0x11), - MBEDTLS_BYTES_TO_T_UINT_8(0xCD, 0xF2, 0x4B, 0x1D, 0x19, 0xC9, 0x0F, 0xCC), - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0xB1, 0x8A, 0x22, 0x8B, 0x05, 0x6B, 0x56), - MBEDTLS_BYTES_TO_T_UINT_8(0x35, 0x21, 0xEF, 0x30, 0xEC, 0x09, 0x2A, 0x89), -}; -static const mbedtls_mpi_uint secp256k1_T_15_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x84, 0x4A, 0x46, 0x07, 0x6C, 0x3C, 0x4C), - MBEDTLS_BYTES_TO_T_UINT_8(0xDD, 0x18, 0x3A, 0xF4, 0xCC, 0xF5, 0xB2, 0xF2), - MBEDTLS_BYTES_TO_T_UINT_8(0x4F, 0x8F, 0xCD, 0x0A, 0x9C, 0xF4, 0xBD, 0x95), - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0x89, 0x7F, 0x8A, 0xB1, 0x52, 0x3A, 0xAB), -}; -static const mbedtls_ecp_point secp256k1_T[16] = { - ECP_POINT_INIT_XY_Z1(secp256k1_T_0_X, secp256k1_T_0_Y), ECP_POINT_INIT_XY_Z0(secp256k1_T_1_X, secp256k1_T_1_Y), - ECP_POINT_INIT_XY_Z0(secp256k1_T_2_X, secp256k1_T_2_Y), ECP_POINT_INIT_XY_Z0(secp256k1_T_3_X, secp256k1_T_3_Y), - ECP_POINT_INIT_XY_Z0(secp256k1_T_4_X, secp256k1_T_4_Y), ECP_POINT_INIT_XY_Z0(secp256k1_T_5_X, secp256k1_T_5_Y), - ECP_POINT_INIT_XY_Z0(secp256k1_T_6_X, secp256k1_T_6_Y), ECP_POINT_INIT_XY_Z0(secp256k1_T_7_X, secp256k1_T_7_Y), - ECP_POINT_INIT_XY_Z0(secp256k1_T_8_X, secp256k1_T_8_Y), ECP_POINT_INIT_XY_Z0(secp256k1_T_9_X, secp256k1_T_9_Y), - ECP_POINT_INIT_XY_Z0(secp256k1_T_10_X, secp256k1_T_10_Y), ECP_POINT_INIT_XY_Z0(secp256k1_T_11_X, secp256k1_T_11_Y), - ECP_POINT_INIT_XY_Z0(secp256k1_T_12_X, secp256k1_T_12_Y), ECP_POINT_INIT_XY_Z0(secp256k1_T_13_X, secp256k1_T_13_Y), - ECP_POINT_INIT_XY_Z0(secp256k1_T_14_X, secp256k1_T_14_Y), ECP_POINT_INIT_XY_Z0(secp256k1_T_15_X, secp256k1_T_15_Y), -}; -#else -#define secp256k1_T NULL -#endif -#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ - -/* - * Domain parameters for brainpoolP256r1 (RFC 5639 3.4) - */ -#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) -static const mbedtls_mpi_uint brainpoolP256r1_p[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x77, 0x53, 0x6E, 0x1F, 0x1D, 0x48, 0x13, 0x20), - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0x20, 0x26, 0xD5, 0x23, 0xF6, 0x3B, 0x6E), - MBEDTLS_BYTES_TO_T_UINT_8(0x72, 0x8D, 0x83, 0x9D, 0x90, 0x0A, 0x66, 0x3E), - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0xA9, 0xEE, 0xA1, 0xDB, 0x57, 0xFB, 0xA9), -}; -static const mbedtls_mpi_uint brainpoolP256r1_a[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0xB5, 0x30, 0xF3, 0x44, 0x4B, 0x4A, 0xE9), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x5C, 0xDC, 0x26, 0xC1, 0x55, 0x80, 0xFB), - MBEDTLS_BYTES_TO_T_UINT_8(0xE7, 0xFF, 0x7A, 0x41, 0x30, 0x75, 0xF6, 0xEE), - MBEDTLS_BYTES_TO_T_UINT_8(0x57, 0x30, 0x2C, 0xFC, 0x75, 0x09, 0x5A, 0x7D), -}; -static const mbedtls_mpi_uint brainpoolP256r1_b[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x07, 0x8C, 0xFF, 0x18, 0xDC, 0xCC, 0x6B), - MBEDTLS_BYTES_TO_T_UINT_8(0xCE, 0xE1, 0xF7, 0x5C, 0x29, 0x16, 0x84, 0x95), - MBEDTLS_BYTES_TO_T_UINT_8(0xBF, 0x7C, 0xD7, 0xBB, 0xD9, 0xB5, 0x30, 0xF3), - MBEDTLS_BYTES_TO_T_UINT_8(0x44, 0x4B, 0x4A, 0xE9, 0x6C, 0x5C, 0xDC, 0x26), -}; -static const mbedtls_mpi_uint brainpoolP256r1_gx[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x62, 0x32, 0xCE, 0x9A, 0xBD, 0x53, 0x44, 0x3A), - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0x23, 0xBD, 0xE3, 0xE1, 0x27, 0xDE, 0xB9), - MBEDTLS_BYTES_TO_T_UINT_8(0xAF, 0xB7, 0x81, 0xFC, 0x2F, 0x48, 0x4B, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0xCB, 0x57, 0x7E, 0xCB, 0xB9, 0xAE, 0xD2, 0x8B), -}; -static const mbedtls_mpi_uint brainpoolP256r1_gy[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x97, 0x69, 0x04, 0x2F, 0xC7, 0x54, 0x1D, 0x5C), - MBEDTLS_BYTES_TO_T_UINT_8(0x54, 0x8E, 0xED, 0x2D, 0x13, 0x45, 0x77, 0xC2), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x1D, 0x61, 0x14, 0x1A, 0x46, 0xF8, 0x97), - MBEDTLS_BYTES_TO_T_UINT_8(0xFD, 0xC4, 0xDA, 0xC3, 0x35, 0xF8, 0x7E, 0x54), -}; -static const mbedtls_mpi_uint brainpoolP256r1_n[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0x56, 0x48, 0x97, 0x82, 0x0E, 0x1E, 0x90), - MBEDTLS_BYTES_TO_T_UINT_8(0xF7, 0xA6, 0x61, 0xB5, 0xA3, 0x7A, 0x39, 0x8C), - MBEDTLS_BYTES_TO_T_UINT_8(0x71, 0x8D, 0x83, 0x9D, 0x90, 0x0A, 0x66, 0x3E), - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0xA9, 0xEE, 0xA1, 0xDB, 0x57, 0xFB, 0xA9), -}; - -#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 -static const mbedtls_mpi_uint brainpoolP256r1_T_0_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x62, 0x32, 0xCE, 0x9A, 0xBD, 0x53, 0x44, 0x3A), - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0x23, 0xBD, 0xE3, 0xE1, 0x27, 0xDE, 0xB9), - MBEDTLS_BYTES_TO_T_UINT_8(0xAF, 0xB7, 0x81, 0xFC, 0x2F, 0x48, 0x4B, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0xCB, 0x57, 0x7E, 0xCB, 0xB9, 0xAE, 0xD2, 0x8B), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_0_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x97, 0x69, 0x04, 0x2F, 0xC7, 0x54, 0x1D, 0x5C), - MBEDTLS_BYTES_TO_T_UINT_8(0x54, 0x8E, 0xED, 0x2D, 0x13, 0x45, 0x77, 0xC2), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x1D, 0x61, 0x14, 0x1A, 0x46, 0xF8, 0x97), - MBEDTLS_BYTES_TO_T_UINT_8(0xFD, 0xC4, 0xDA, 0xC3, 0x35, 0xF8, 0x7E, 0x54), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_1_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x3C, 0xA2, 0xED, 0x52, 0xC9, 0x8C, 0xE3, 0xA5), - MBEDTLS_BYTES_TO_T_UINT_8(0x72, 0xC9, 0xC4, 0x87, 0x3F, 0x93, 0x7A, 0xD1), - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0x12, 0x53, 0x61, 0x3E, 0x76, 0x08, 0xCB), - MBEDTLS_BYTES_TO_T_UINT_8(0x09, 0x8C, 0x74, 0xF4, 0x08, 0xC3, 0x76, 0x80), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_1_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x05, 0xDD, 0x09, 0xA6, 0xED, 0xEE, 0xC4, 0x38), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0xD9, 0xBE, 0x4B, 0xA5, 0xB7, 0x2B, 0x6E), - MBEDTLS_BYTES_TO_T_UINT_8(0x42, 0x20, 0x12, 0xCA, 0x0A, 0x38, 0x24, 0xAB), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x72, 0x71, 0x90, 0x7A, 0x2E, 0xB7, 0x23), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_2_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x2C, 0x66, 0xA1, 0x93, 0x10, 0x2A, 0x51, 0x17), - MBEDTLS_BYTES_TO_T_UINT_8(0x88, 0x10, 0x11, 0x12, 0xBC, 0xB0, 0xB6, 0x93), - MBEDTLS_BYTES_TO_T_UINT_8(0x3C, 0x58, 0xD7, 0x0A, 0x84, 0x05, 0xA3, 0x9C), - MBEDTLS_BYTES_TO_T_UINT_8(0xF7, 0x8E, 0x95, 0x61, 0xD3, 0x0B, 0xDF, 0x36), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_2_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF9, 0x92, 0x12, 0x0F, 0x5E, 0x87, 0x70, 0x1B), - MBEDTLS_BYTES_TO_T_UINT_8(0x38, 0xE9, 0x9B, 0xEB, 0x3A, 0xFB, 0xCF, 0xC4), - MBEDTLS_BYTES_TO_T_UINT_8(0xDC, 0x92, 0xB9, 0xF7, 0x45, 0xD3, 0x06, 0xB6), - MBEDTLS_BYTES_TO_T_UINT_8(0x82, 0x28, 0x65, 0xE1, 0xC5, 0x6C, 0x57, 0x18), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_3_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0x0E, 0x77, 0x01, 0x81, 0x9E, 0x38, 0x5C), - MBEDTLS_BYTES_TO_T_UINT_8(0x71, 0xF0, 0xD5, 0xA5, 0x91, 0x2B, 0xDF, 0xC0), - MBEDTLS_BYTES_TO_T_UINT_8(0xD8, 0xEE, 0xB6, 0x25, 0xD6, 0x98, 0xDE, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0x7B, 0xA1, 0x55, 0x63, 0x39, 0xEB, 0xB5, 0x47), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_3_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0xD6, 0xB8, 0xE3, 0x13, 0xED, 0x7F, 0xA3), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0xE8, 0xAE, 0x36, 0xB8, 0xCD, 0x19, 0x02), - MBEDTLS_BYTES_TO_T_UINT_8(0xF9, 0x82, 0x83, 0x7A, 0x7B, 0x46, 0x56, 0xE8), - MBEDTLS_BYTES_TO_T_UINT_8(0x4E, 0x60, 0x46, 0x15, 0x5A, 0xAC, 0x99, 0x30), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_4_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xBF, 0x61, 0x50, 0xC6, 0xFF, 0x10, 0x7D, 0x04), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0x51, 0xDF, 0xA9, 0x7D, 0x78, 0x26, 0x74), - MBEDTLS_BYTES_TO_T_UINT_8(0x56, 0x15, 0x9A, 0xF7, 0x01, 0xC1, 0xBB, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0x26, 0x0F, 0xE6, 0x2A, 0xBD, 0x4A, 0x9E, 0x87), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_4_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x57, 0xF8, 0xD1, 0x77, 0xD2, 0x49, 0xB3, 0xDD), - MBEDTLS_BYTES_TO_T_UINT_8(0x36, 0x86, 0xFB, 0x9E, 0x1F, 0x5A, 0x60, 0x47), - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0xC4, 0x8D, 0xCD, 0x86, 0x61, 0x2F, 0xF9), - MBEDTLS_BYTES_TO_T_UINT_8(0x41, 0xF6, 0xB9, 0xAC, 0x37, 0x9D, 0xE9, 0x28), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_5_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0x77, 0xAA, 0x97, 0x9C, 0x0B, 0x04, 0x20), - MBEDTLS_BYTES_TO_T_UINT_8(0x80, 0xA6, 0x60, 0x81, 0xCE, 0x25, 0x13, 0x3E), - MBEDTLS_BYTES_TO_T_UINT_8(0x24, 0x00, 0xF3, 0xBB, 0x82, 0x99, 0x95, 0xB7), - MBEDTLS_BYTES_TO_T_UINT_8(0x47, 0x5A, 0xCE, 0x90, 0x71, 0x38, 0x2F, 0x10), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_5_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0x1A, 0xC0, 0x84, 0x27, 0xD6, 0x9D, 0xB7), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0x37, 0x52, 0x16, 0x13, 0x0E, 0xCE, 0x92), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0xBF, 0x5A, 0xDB, 0xDB, 0x6E, 0x1E, 0x69), - MBEDTLS_BYTES_TO_T_UINT_8(0x3E, 0xB7, 0x5E, 0xF9, 0x86, 0xDD, 0x8A, 0x5C), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_6_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x3D, 0xAB, 0x5C, 0x8D, 0x1D, 0xF2, 0x2D, 0x1E), - MBEDTLS_BYTES_TO_T_UINT_8(0x65, 0xC5, 0xF8, 0xF7, 0x1D, 0x96, 0x0B, 0x4D), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0x4C, 0xA7, 0x45, 0x20, 0x6A, 0x1E, 0x5B), - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0x5D, 0xEF, 0xDE, 0xEE, 0x39, 0x44, 0x19), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_6_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x4B, 0x2F, 0x6D, 0x52, 0xC9, 0x58, 0x60, 0xE8), - MBEDTLS_BYTES_TO_T_UINT_8(0xC3, 0xC9, 0x62, 0xCB, 0x38, 0x3C, 0x55, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xA5, 0x09, 0x10, 0x88, 0xDB, 0xE3, 0xBD), - MBEDTLS_BYTES_TO_T_UINT_8(0x52, 0xE0, 0x3C, 0xCE, 0x06, 0x0B, 0x4B, 0x5D), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_7_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB1, 0x1D, 0xB4, 0x10, 0x76, 0x8F, 0xBA, 0x09), - MBEDTLS_BYTES_TO_T_UINT_8(0x57, 0x70, 0x5A, 0x07, 0xF5, 0x1A, 0x74, 0xC7), - MBEDTLS_BYTES_TO_T_UINT_8(0x0B, 0xE9, 0x94, 0xA8, 0xC0, 0xD5, 0x4A, 0x4A), - MBEDTLS_BYTES_TO_T_UINT_8(0x3E, 0x6D, 0xD4, 0xE8, 0x9B, 0xE9, 0x6D, 0x0E), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_7_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x65, 0x00, 0x32, 0x41, 0x57, 0x84, 0x89, 0x52), - MBEDTLS_BYTES_TO_T_UINT_8(0xEE, 0xC7, 0x14, 0xEC, 0xE9, 0x27, 0xFF, 0xF3), - MBEDTLS_BYTES_TO_T_UINT_8(0x9A, 0x67, 0x9E, 0xFB, 0xB6, 0xB8, 0x96, 0xF3), - MBEDTLS_BYTES_TO_T_UINT_8(0xE5, 0x4A, 0xE3, 0x97, 0x4B, 0x58, 0xDE, 0x30), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_8_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA6, 0x1E, 0x5C, 0xF5, 0x7F, 0xD5, 0xD4, 0xAA), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0x08, 0x7A, 0xF1, 0xBD, 0x89, 0xC7, 0x1E), - MBEDTLS_BYTES_TO_T_UINT_8(0x3A, 0xF9, 0x11, 0x1B, 0xF5, 0x3C, 0x6D, 0x8C), - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0x50, 0xE5, 0x69, 0x1D, 0x59, 0xFC, 0x0C), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_8_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF1, 0x2F, 0xF8, 0x3F, 0xEC, 0x55, 0x99, 0x57), - MBEDTLS_BYTES_TO_T_UINT_8(0x41, 0xA7, 0x29, 0x90, 0x43, 0x81, 0x31, 0x4C), - MBEDTLS_BYTES_TO_T_UINT_8(0xC3, 0x18, 0x44, 0x50, 0x5D, 0x76, 0xCB, 0xDD), - MBEDTLS_BYTES_TO_T_UINT_8(0xF0, 0xC5, 0x5B, 0x9A, 0x03, 0xE6, 0x17, 0x39), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_9_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0x89, 0xFC, 0x55, 0x94, 0x91, 0x6A, 0xA2), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0x46, 0x35, 0xF2, 0x3A, 0x42, 0x08, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0xD3, 0xD2, 0x76, 0x49, 0x42, 0x87, 0xD3, 0x7F), - MBEDTLS_BYTES_TO_T_UINT_8(0x90, 0xEA, 0xA0, 0x52, 0xF1, 0x6A, 0x30, 0x57), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_9_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0xB2, 0x57, 0xA3, 0x8A, 0x4D, 0x1B, 0x3C), - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0xA3, 0x99, 0x94, 0xB5, 0x3D, 0x64, 0x09), - MBEDTLS_BYTES_TO_T_UINT_8(0x35, 0xC3, 0xD7, 0x53, 0xF6, 0x49, 0x1C, 0x60), - MBEDTLS_BYTES_TO_T_UINT_8(0x27, 0x23, 0x41, 0x4D, 0xFB, 0x7A, 0x5C, 0x53), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_10_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCA, 0xB8, 0x15, 0x65, 0x5C, 0x85, 0x94, 0xD7), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0x37, 0xC7, 0xF8, 0x7E, 0xAE, 0x6C, 0x10), - MBEDTLS_BYTES_TO_T_UINT_8(0x53, 0xD8, 0x11, 0x54, 0x98, 0x44, 0xE3, 0xF1), - MBEDTLS_BYTES_TO_T_UINT_8(0xE4, 0x4D, 0xA6, 0x4B, 0x28, 0xF2, 0x57, 0x9E), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_10_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF6, 0xD0, 0xEB, 0x1E, 0xAA, 0x30, 0xD3, 0x6A), - MBEDTLS_BYTES_TO_T_UINT_8(0x58, 0x9B, 0x4D, 0xA7, 0x73, 0x6E, 0xB6, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0x47, 0xF6, 0xED, 0x37, 0xEF, 0x71, 0x4D), - MBEDTLS_BYTES_TO_T_UINT_8(0xA8, 0xB5, 0x49, 0x61, 0x5E, 0x45, 0xF6, 0x4A), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_11_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xEF, 0x0E, 0xB3, 0x84, 0x3A, 0x63, 0x72, 0x84), - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0x53, 0x5C, 0xA7, 0xC6, 0x2E, 0xAB, 0x9E), - MBEDTLS_BYTES_TO_T_UINT_8(0xEB, 0x0F, 0x8F, 0x87, 0x50, 0x28, 0xB4, 0xAE), - MBEDTLS_BYTES_TO_T_UINT_8(0x5C, 0x98, 0x4A, 0x98, 0x31, 0x86, 0xCA, 0x51), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_11_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xBE, 0xC9, 0xE2, 0xFD, 0x5D, 0x1F, 0xE8, 0xC2), - MBEDTLS_BYTES_TO_T_UINT_8(0xD5, 0x90, 0x91, 0xC4, 0x84, 0xF0, 0xBA, 0xC5), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x5A, 0xB3, 0x4E, 0xFB, 0xE0, 0x57, 0xE8), - MBEDTLS_BYTES_TO_T_UINT_8(0x6B, 0x0B, 0x90, 0xA6, 0xFD, 0x9D, 0x8E, 0x02), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_12_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF8, 0x41, 0x8F, 0x31, 0xFA, 0x5A, 0xF6, 0x33), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0xE9, 0xE3, 0xF6, 0xE0, 0x4A, 0xE7, 0xD2), - MBEDTLS_BYTES_TO_T_UINT_8(0x84, 0x4E, 0xCD, 0xA2, 0x22, 0x14, 0xD4, 0x12), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0xED, 0x21, 0xB7, 0x0F, 0x53, 0x10, 0x17), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_12_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x05, 0x06, 0x24, 0x2C, 0x4E, 0xD1, 0x1E, 0x9F), - MBEDTLS_BYTES_TO_T_UINT_8(0xD7, 0x3F, 0xC1, 0x9F, 0xAB, 0xF0, 0x37, 0x95), - MBEDTLS_BYTES_TO_T_UINT_8(0x03, 0x5E, 0x12, 0xCE, 0x83, 0x1B, 0x2A, 0x18), - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0x65, 0xCF, 0xE8, 0x5C, 0xA5, 0xA2, 0x70), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_13_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB8, 0x86, 0x76, 0x3A, 0x94, 0xF6, 0x1D, 0xC1), - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0xDA, 0xC9, 0xA6, 0x29, 0x93, 0x15, 0x10), - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0x61, 0x6A, 0x7D, 0xC7, 0xA9, 0xF3, 0x76), - MBEDTLS_BYTES_TO_T_UINT_8(0x4A, 0x03, 0x71, 0xA2, 0x15, 0xCE, 0x50, 0x72), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_13_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0xD0, 0xA8, 0x1E, 0x91, 0xC4, 0x4F, 0x24), - MBEDTLS_BYTES_TO_T_UINT_8(0x2D, 0x4B, 0x7E, 0xD7, 0x71, 0x58, 0x7E, 0x1E), - MBEDTLS_BYTES_TO_T_UINT_8(0x93, 0x45, 0xAF, 0x2A, 0x18, 0x93, 0x95, 0x3B), - MBEDTLS_BYTES_TO_T_UINT_8(0x1B, 0x8F, 0xC7, 0xFA, 0x4C, 0x7A, 0x86, 0x54), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_14_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x97, 0xAF, 0x68, 0x3A, 0x23, 0xC1, 0x2E, 0xBF), - MBEDTLS_BYTES_TO_T_UINT_8(0x89, 0x50, 0x11, 0x67, 0x39, 0xB9, 0xAF, 0x48), - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0x86, 0xAA, 0x1E, 0x88, 0x21, 0x29, 0x8B), - MBEDTLS_BYTES_TO_T_UINT_8(0xCD, 0x28, 0xA4, 0x9D, 0x89, 0xA9, 0x9A, 0x10), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_14_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x91, 0xBA, 0x04, 0x67, 0xB7, 0x01, 0x40, 0x38), - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0xE9, 0x09, 0xA3, 0xCA, 0xA6, 0x37, 0xF6), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x97, 0xA8, 0xB6, 0x3C, 0xEE, 0x90, 0x3D), - MBEDTLS_BYTES_TO_T_UINT_8(0xDC, 0xED, 0xC4, 0xF7, 0xC3, 0x95, 0xEC, 0x85), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_15_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0x84, 0xBD, 0xEB, 0xD5, 0x64, 0xBB, 0x9D), - MBEDTLS_BYTES_TO_T_UINT_8(0xDB, 0x9B, 0xE2, 0x28, 0x50, 0xC2, 0x72, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0x39, 0xF2, 0x74, 0xD1, 0x26, 0xBF, 0x32, 0x68), - MBEDTLS_BYTES_TO_T_UINT_8(0x36, 0xCB, 0xAF, 0x72, 0xDB, 0x6D, 0x30, 0x98), -}; -static const mbedtls_mpi_uint brainpoolP256r1_T_15_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB3, 0x50, 0x85, 0xF4, 0x2B, 0x48, 0xC1, 0xAD), - MBEDTLS_BYTES_TO_T_UINT_8(0xC0, 0x28, 0xBB, 0x11, 0xBA, 0x5B, 0x22, 0x6C), - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0xA1, 0xE5, 0x5C, 0xC9, 0x1D, 0x44, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0xD4, 0xE8, 0xE6, 0x6F, 0xBB, 0xC1, 0x81, 0x7F), -}; -static const mbedtls_ecp_point brainpoolP256r1_T[16] = { - ECP_POINT_INIT_XY_Z1(brainpoolP256r1_T_0_X, brainpoolP256r1_T_0_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_1_X, brainpoolP256r1_T_1_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_2_X, brainpoolP256r1_T_2_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_3_X, brainpoolP256r1_T_3_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_4_X, brainpoolP256r1_T_4_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_5_X, brainpoolP256r1_T_5_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_6_X, brainpoolP256r1_T_6_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_7_X, brainpoolP256r1_T_7_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_8_X, brainpoolP256r1_T_8_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_9_X, brainpoolP256r1_T_9_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_10_X, brainpoolP256r1_T_10_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_11_X, brainpoolP256r1_T_11_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_12_X, brainpoolP256r1_T_12_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_13_X, brainpoolP256r1_T_13_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_14_X, brainpoolP256r1_T_14_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP256r1_T_15_X, brainpoolP256r1_T_15_Y), -}; -#else -#define brainpoolP256r1_T NULL -#endif - -#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */ - -/* - * Domain parameters for brainpoolP384r1 (RFC 5639 3.6) - */ -#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) -static const mbedtls_mpi_uint brainpoolP384r1_p[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x53, 0xEC, 0x07, 0x31, 0x13, 0x00, 0x47, 0x87), - MBEDTLS_BYTES_TO_T_UINT_8(0x71, 0x1A, 0x1D, 0x90, 0x29, 0xA7, 0xD3, 0xAC), - MBEDTLS_BYTES_TO_T_UINT_8(0x23, 0x11, 0xB7, 0x7F, 0x19, 0xDA, 0xB1, 0x12), - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0x56, 0x54, 0xED, 0x09, 0x71, 0x2F, 0x15), - MBEDTLS_BYTES_TO_T_UINT_8(0xDF, 0x41, 0xE6, 0x50, 0x7E, 0x6F, 0x5D, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0x6D, 0x38, 0xA3, 0x82, 0x1E, 0xB9, 0x8C), -}; -static const mbedtls_mpi_uint brainpoolP384r1_a[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x26, 0x28, 0xCE, 0x22, 0xDD, 0xC7, 0xA8, 0x04), - MBEDTLS_BYTES_TO_T_UINT_8(0xEB, 0xD4, 0x3A, 0x50, 0x4A, 0x81, 0xA5, 0x8A), - MBEDTLS_BYTES_TO_T_UINT_8(0x0F, 0xF9, 0x91, 0xBA, 0xEF, 0x65, 0x91, 0x13), - MBEDTLS_BYTES_TO_T_UINT_8(0x87, 0x27, 0xB2, 0x4F, 0x8E, 0xA2, 0xBE, 0xC2), - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0xAF, 0x05, 0xCE, 0x0A, 0x08, 0x72, 0x3C), - MBEDTLS_BYTES_TO_T_UINT_8(0x0C, 0x15, 0x8C, 0x3D, 0xC6, 0x82, 0xC3, 0x7B), -}; -static const mbedtls_mpi_uint brainpoolP384r1_b[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0x4C, 0x50, 0xFA, 0x96, 0x86, 0xB7, 0x3A), - MBEDTLS_BYTES_TO_T_UINT_8(0x94, 0xC9, 0xDB, 0x95, 0x02, 0x39, 0xB4, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0xD5, 0x62, 0xEB, 0x3E, 0xA5, 0x0E, 0x88, 0x2E), - MBEDTLS_BYTES_TO_T_UINT_8(0xA6, 0xD2, 0xDC, 0x07, 0xE1, 0x7D, 0xB7, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0x44, 0xF0, 0x16, 0x54, 0xB5, 0x39, 0x8B), - MBEDTLS_BYTES_TO_T_UINT_8(0x26, 0x28, 0xCE, 0x22, 0xDD, 0xC7, 0xA8, 0x04), -}; -static const mbedtls_mpi_uint brainpoolP384r1_gx[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0xAF, 0xD4, 0x47, 0xE2, 0xB2, 0x87, 0xEF), - MBEDTLS_BYTES_TO_T_UINT_8(0xAA, 0x46, 0xD6, 0x36, 0x34, 0xE0, 0x26, 0xE8), - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0x10, 0xBD, 0x0C, 0xFE, 0xCA, 0x7F, 0xDB), - MBEDTLS_BYTES_TO_T_UINT_8(0xE3, 0x4F, 0xF1, 0x7E, 0xE7, 0xA3, 0x47, 0x88), - MBEDTLS_BYTES_TO_T_UINT_8(0x6B, 0x3F, 0xC1, 0xB7, 0x81, 0x3A, 0xA6, 0xA2), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0x45, 0xCF, 0x68, 0xF0, 0x64, 0x1C, 0x1D), -}; -static const mbedtls_mpi_uint brainpoolP384r1_gy[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x53, 0x3C, 0x26, 0x41, 0x03, 0x82, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0x81, 0x91, 0x77, 0x21, 0x46, 0x46, 0x0E), - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0x29, 0x91, 0xF9, 0x4F, 0x05, 0x9C, 0xE1), - MBEDTLS_BYTES_TO_T_UINT_8(0x64, 0x58, 0xEC, 0xFE, 0x29, 0x0B, 0xB7, 0x62), - MBEDTLS_BYTES_TO_T_UINT_8(0x52, 0xD5, 0xCF, 0x95, 0x8E, 0xEB, 0xB1, 0x5C), - MBEDTLS_BYTES_TO_T_UINT_8(0xA4, 0xC2, 0xF9, 0x20, 0x75, 0x1D, 0xBE, 0x8A), -}; -static const mbedtls_mpi_uint brainpoolP384r1_n[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x65, 0x65, 0x04, 0xE9, 0x02, 0x32, 0x88, 0x3B), - MBEDTLS_BYTES_TO_T_UINT_8(0x10, 0xC3, 0x7F, 0x6B, 0xAF, 0xB6, 0x3A, 0xCF), - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0x25, 0x04, 0xAC, 0x6C, 0x6E, 0x16, 0x1F), - MBEDTLS_BYTES_TO_T_UINT_8(0xB3, 0x56, 0x54, 0xED, 0x09, 0x71, 0x2F, 0x15), - MBEDTLS_BYTES_TO_T_UINT_8(0xDF, 0x41, 0xE6, 0x50, 0x7E, 0x6F, 0x5D, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0x6D, 0x38, 0xA3, 0x82, 0x1E, 0xB9, 0x8C), -}; - -#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 -static const mbedtls_mpi_uint brainpoolP384r1_T_0_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0xAF, 0xD4, 0x47, 0xE2, 0xB2, 0x87, 0xEF), - MBEDTLS_BYTES_TO_T_UINT_8(0xAA, 0x46, 0xD6, 0x36, 0x34, 0xE0, 0x26, 0xE8), - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0x10, 0xBD, 0x0C, 0xFE, 0xCA, 0x7F, 0xDB), - MBEDTLS_BYTES_TO_T_UINT_8(0xE3, 0x4F, 0xF1, 0x7E, 0xE7, 0xA3, 0x47, 0x88), - MBEDTLS_BYTES_TO_T_UINT_8(0x6B, 0x3F, 0xC1, 0xB7, 0x81, 0x3A, 0xA6, 0xA2), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0x45, 0xCF, 0x68, 0xF0, 0x64, 0x1C, 0x1D), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_0_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x53, 0x3C, 0x26, 0x41, 0x03, 0x82, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0x81, 0x91, 0x77, 0x21, 0x46, 0x46, 0x0E), - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0x29, 0x91, 0xF9, 0x4F, 0x05, 0x9C, 0xE1), - MBEDTLS_BYTES_TO_T_UINT_8(0x64, 0x58, 0xEC, 0xFE, 0x29, 0x0B, 0xB7, 0x62), - MBEDTLS_BYTES_TO_T_UINT_8(0x52, 0xD5, 0xCF, 0x95, 0x8E, 0xEB, 0xB1, 0x5C), - MBEDTLS_BYTES_TO_T_UINT_8(0xA4, 0xC2, 0xF9, 0x20, 0x75, 0x1D, 0xBE, 0x8A), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_1_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x93, 0xD8, 0x8A, 0x54, 0x41, 0xD6, 0x6B, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0xE2, 0x3B, 0xF1, 0x22, 0xFD, 0x2D, 0x4B, 0x03), - MBEDTLS_BYTES_TO_T_UINT_8(0x01, 0x55, 0xE3, 0x33, 0xF0, 0x73, 0x52, 0x5A), - MBEDTLS_BYTES_TO_T_UINT_8(0xC1, 0x3F, 0x30, 0x26, 0xCA, 0x7F, 0x52, 0xA3), - MBEDTLS_BYTES_TO_T_UINT_8(0xD3, 0x6E, 0x17, 0x9B, 0xD5, 0x2A, 0x4A, 0x31), - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0xDA, 0x6B, 0xE5, 0x03, 0x07, 0x1D, 0x2E), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_1_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x51, 0x7A, 0xAF, 0x98, 0xE3, 0xA4, 0xF6, 0x19), - MBEDTLS_BYTES_TO_T_UINT_8(0xEC, 0x7D, 0xFE, 0x51, 0x40, 0x3B, 0x47, 0xD2), - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0x88, 0xEC, 0xC4, 0xE2, 0x8F, 0xCB, 0xA4), - MBEDTLS_BYTES_TO_T_UINT_8(0x30, 0xE2, 0x88, 0x2D, 0x4E, 0x50, 0xEB, 0x9A), - MBEDTLS_BYTES_TO_T_UINT_8(0x13, 0x54, 0x94, 0x5E, 0xF4, 0x7F, 0x3A, 0x04), - MBEDTLS_BYTES_TO_T_UINT_8(0xCD, 0x07, 0x1C, 0xE1, 0xBD, 0x0F, 0xF8, 0x63), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_2_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x94, 0x92, 0x28, 0x2E, 0x32, 0x04, 0xB1, 0x4D), - MBEDTLS_BYTES_TO_T_UINT_8(0x25, 0x82, 0x44, 0x43, 0x76, 0x0D, 0x55, 0xBF), - MBEDTLS_BYTES_TO_T_UINT_8(0x5B, 0xE3, 0xFF, 0x89, 0x46, 0xDE, 0x4E, 0xFE), - MBEDTLS_BYTES_TO_T_UINT_8(0x5B, 0x22, 0xBB, 0x67, 0x1A, 0x81, 0xEE, 0x27), - MBEDTLS_BYTES_TO_T_UINT_8(0xC8, 0x54, 0xE2, 0x7A, 0xAE, 0xDA, 0x2C, 0xD0), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0x9A, 0x90, 0xAA, 0x6E, 0x8B, 0xCC, 0x5F), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_2_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x16, 0x40, 0xAC, 0xED, 0x7D, 0x37, 0x87, 0xAC), - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0xF8, 0xB1, 0x80, 0x4C, 0x8C, 0x04, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0x98, 0x2C, 0xAD, 0x30, 0x69, 0x35, 0xC0), - MBEDTLS_BYTES_TO_T_UINT_8(0x32, 0x2E, 0x00, 0x2F, 0x44, 0x8C, 0xF0, 0xC0), - MBEDTLS_BYTES_TO_T_UINT_8(0x16, 0x58, 0x07, 0xD7, 0xCD, 0x60, 0xA1, 0x5B), - MBEDTLS_BYTES_TO_T_UINT_8(0xAF, 0xFB, 0x7B, 0x03, 0x05, 0x5E, 0x79, 0x73), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_3_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC8, 0x17, 0xCE, 0x38, 0x4B, 0x5E, 0x5B, 0xC8), - MBEDTLS_BYTES_TO_T_UINT_8(0x60, 0x0E, 0x0A, 0x61, 0x9D, 0x7C, 0x62, 0x08), - MBEDTLS_BYTES_TO_T_UINT_8(0x25, 0xF0, 0x98, 0x71, 0x7F, 0x17, 0x26, 0xD7), - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0xD3, 0xFA, 0x3C, 0xF0, 0x70, 0x07, 0x82), - MBEDTLS_BYTES_TO_T_UINT_8(0x29, 0x47, 0x5C, 0x09, 0x43, 0xB7, 0x65, 0x15), - MBEDTLS_BYTES_TO_T_UINT_8(0x0E, 0xA9, 0xA7, 0x3E, 0xFA, 0xF3, 0xEC, 0x22), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_3_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xDA, 0x78, 0x22, 0x2B, 0x58, 0x71, 0xFA, 0xAA), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x30, 0xCE, 0x6A, 0xB3, 0xB0, 0x4F, 0x83), - MBEDTLS_BYTES_TO_T_UINT_8(0xCF, 0x95, 0x20, 0xA9, 0x23, 0xC2, 0x65, 0xE7), - MBEDTLS_BYTES_TO_T_UINT_8(0x55, 0xCF, 0x03, 0x5B, 0x8A, 0x80, 0x44, 0xBB), - MBEDTLS_BYTES_TO_T_UINT_8(0x5C, 0xF8, 0x91, 0xF7, 0xD5, 0xED, 0xEA, 0x81), - MBEDTLS_BYTES_TO_T_UINT_8(0x40, 0x5B, 0x16, 0x10, 0x25, 0xAC, 0x2A, 0x17), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_4_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF2, 0xEC, 0xDC, 0xC4, 0x7B, 0x8C, 0x6B, 0xE9), - MBEDTLS_BYTES_TO_T_UINT_8(0x2B, 0xBB, 0x1C, 0xD3, 0x5A, 0xEE, 0xD9, 0x97), - MBEDTLS_BYTES_TO_T_UINT_8(0x64, 0x5D, 0x30, 0x5E, 0xF7, 0xB2, 0x41, 0x9D), - MBEDTLS_BYTES_TO_T_UINT_8(0xED, 0xCE, 0x0F, 0x1A, 0xC6, 0x41, 0x64, 0x62), - MBEDTLS_BYTES_TO_T_UINT_8(0xF2, 0x18, 0xE1, 0xE3, 0x82, 0x15, 0x66, 0x4B), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0xE2, 0x24, 0x04, 0x72, 0x39, 0xA0, 0x7C), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_4_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x2B, 0x51, 0xA2, 0x58, 0x88, 0x62, 0xE1, 0x02), - MBEDTLS_BYTES_TO_T_UINT_8(0x58, 0xD2, 0x65, 0x14, 0xE9, 0x4C, 0x82, 0x30), - MBEDTLS_BYTES_TO_T_UINT_8(0xDC, 0xE1, 0xAC, 0x87, 0xAE, 0x31, 0x1A, 0x7A), - MBEDTLS_BYTES_TO_T_UINT_8(0x85, 0x4F, 0x96, 0x1E, 0x85, 0x7A, 0xC3, 0x2B), - MBEDTLS_BYTES_TO_T_UINT_8(0xF0, 0x86, 0xBB, 0xF0, 0xC0, 0x9D, 0x08, 0x7B), - MBEDTLS_BYTES_TO_T_UINT_8(0xBD, 0x53, 0x03, 0x09, 0x80, 0x91, 0xEF, 0x68), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_5_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x2D, 0xD7, 0xAF, 0x6F, 0x69, 0x7B, 0x88, 0xA1), - MBEDTLS_BYTES_TO_T_UINT_8(0xAF, 0x13, 0xE4, 0x30, 0xA2, 0x47, 0xB5, 0xC1), - MBEDTLS_BYTES_TO_T_UINT_8(0x0F, 0xD2, 0xC0, 0xDD, 0x8A, 0x1C, 0x3C, 0xF2), - MBEDTLS_BYTES_TO_T_UINT_8(0xF9, 0x8C, 0xB3, 0x4C, 0xBA, 0x8B, 0x6D, 0xCF), - MBEDTLS_BYTES_TO_T_UINT_8(0x6B, 0xC7, 0xA1, 0xA8, 0x6E, 0x3C, 0x4F, 0xF1), - MBEDTLS_BYTES_TO_T_UINT_8(0x94, 0x4A, 0x97, 0xC8, 0x03, 0x6F, 0x01, 0x82), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_5_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0x18, 0x12, 0xA9, 0x39, 0xD5, 0x22, 0x26), - MBEDTLS_BYTES_TO_T_UINT_8(0x47, 0xA7, 0xC0, 0xBD, 0x9D, 0x8D, 0x78, 0x38), - MBEDTLS_BYTES_TO_T_UINT_8(0xA9, 0xB3, 0xD0, 0x7F, 0xDF, 0xD0, 0x30, 0xDE), - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0x25, 0x73, 0x96, 0xEC, 0xA8, 0x1D, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0x91, 0xD1, 0x65, 0x66, 0xDC, 0xD9, 0xCF, 0xDF), - MBEDTLS_BYTES_TO_T_UINT_8(0x95, 0xED, 0x7B, 0x37, 0xAD, 0xE2, 0xBE, 0x2D), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_6_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x50, 0x79, 0x42, 0x6A, 0x07, 0x66, 0xB1, 0xBD), - MBEDTLS_BYTES_TO_T_UINT_8(0x45, 0x53, 0x62, 0x65, 0x92, 0x09, 0x4C, 0xA1), - MBEDTLS_BYTES_TO_T_UINT_8(0x06, 0xAF, 0xC3, 0x03, 0xF6, 0xF4, 0x2D, 0x9B), - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0xCA, 0x41, 0xD9, 0xA2, 0x69, 0x9B, 0xC9), - MBEDTLS_BYTES_TO_T_UINT_8(0x4B, 0xB2, 0xA6, 0x8D, 0xE1, 0xAA, 0x61, 0x76), - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0xBA, 0x4D, 0x12, 0xB6, 0xBE, 0xF3, 0x7E), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_6_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCA, 0xD9, 0x92, 0x22, 0x07, 0xCE, 0xC9, 0x26), - MBEDTLS_BYTES_TO_T_UINT_8(0x62, 0xA1, 0x7C, 0x91, 0xDB, 0x32, 0xF7, 0xE5), - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0x49, 0x4B, 0x6D, 0xFB, 0xD9, 0x70, 0x3B), - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0xFB, 0x4E, 0x4C, 0x5E, 0x66, 0x81, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0xA5, 0xB3, 0xE1, 0x00, 0xB7, 0xD9, 0xCC, 0x58), - MBEDTLS_BYTES_TO_T_UINT_8(0xF3, 0x36, 0x8B, 0xC4, 0x39, 0x20, 0xFD, 0x30), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_7_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x94, 0x1F, 0x60, 0x03, 0xBB, 0xD7, 0x60, 0x57), - MBEDTLS_BYTES_TO_T_UINT_8(0x72, 0x3C, 0x62, 0xDD, 0x71, 0x95, 0xE9, 0x61), - MBEDTLS_BYTES_TO_T_UINT_8(0xB0, 0x5B, 0x7A, 0x5F, 0x68, 0x81, 0xC5, 0x90), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0xAF, 0xB5, 0xB9, 0x98, 0x42, 0x28, 0xA5), - MBEDTLS_BYTES_TO_T_UINT_8(0x0C, 0x29, 0x8E, 0x11, 0x49, 0xB4, 0xD7, 0x20), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0x3E, 0xD2, 0x30, 0xA1, 0xBA, 0xCA, 0x03), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_7_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x29, 0x37, 0x64, 0x44, 0x2F, 0x03, 0xE5, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0x4A, 0x42, 0xBC, 0xFF, 0xA2, 0x1A, 0x5F, 0x06), - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0x04, 0xAB, 0x04, 0xE0, 0x24, 0xAD, 0x2A), - MBEDTLS_BYTES_TO_T_UINT_8(0x3D, 0x45, 0x17, 0x67, 0x1F, 0x3E, 0x53, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0xED, 0x0F, 0xB3, 0x1B, 0x57, 0x54, 0xC2, 0x03), - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0xD3, 0xF8, 0xC4, 0x1B, 0x9B, 0xFA, 0x30), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_8_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0x90, 0xFD, 0xFB, 0xCA, 0x49, 0x38, 0x4E), - MBEDTLS_BYTES_TO_T_UINT_8(0xC3, 0xCF, 0xC6, 0xDD, 0xF0, 0xFF, 0x8C, 0x11), - MBEDTLS_BYTES_TO_T_UINT_8(0xD7, 0x69, 0x9D, 0xBD, 0x5F, 0x33, 0xE9, 0xB4), - MBEDTLS_BYTES_TO_T_UINT_8(0x47, 0x19, 0x82, 0x3D, 0xAC, 0x1C, 0x40, 0x23), - MBEDTLS_BYTES_TO_T_UINT_8(0x40, 0xC7, 0x02, 0x46, 0x14, 0x77, 0x00, 0xBE), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x05, 0xF2, 0x77, 0x3A, 0x66, 0x5C, 0x39), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_8_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0xE6, 0x17, 0xDE, 0xB2, 0xA1, 0xE5, 0xB8), - MBEDTLS_BYTES_TO_T_UINT_8(0xC7, 0x71, 0xEC, 0x9D, 0xD8, 0xF5, 0xD4, 0x66), - MBEDTLS_BYTES_TO_T_UINT_8(0xAA, 0xC6, 0x42, 0x5E, 0xE7, 0x18, 0xBA, 0xD0), - MBEDTLS_BYTES_TO_T_UINT_8(0xC5, 0x21, 0x68, 0x5A, 0x26, 0xFB, 0xD7, 0x17), - MBEDTLS_BYTES_TO_T_UINT_8(0x26, 0x00, 0x5C, 0xBA, 0x8A, 0x34, 0xEC, 0x75), - MBEDTLS_BYTES_TO_T_UINT_8(0xC3, 0x9C, 0x3C, 0xAF, 0x53, 0xE8, 0x65, 0x35), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_9_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xBE, 0xEF, 0x28, 0xDC, 0x67, 0x05, 0xC8, 0xDF), - MBEDTLS_BYTES_TO_T_UINT_8(0x0B, 0x78, 0xC3, 0x85, 0x49, 0xA0, 0xBC, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0x10, 0x3E, 0x2D, 0xA0, 0xCF, 0xD4, 0x7A, 0xF5), - MBEDTLS_BYTES_TO_T_UINT_8(0x36, 0x93, 0xFE, 0x60, 0xB3, 0x6E, 0x99, 0xE2), - MBEDTLS_BYTES_TO_T_UINT_8(0x62, 0xAD, 0x04, 0xE7, 0x49, 0xAF, 0x5E, 0xE3), - MBEDTLS_BYTES_TO_T_UINT_8(0x54, 0x7A, 0xED, 0xA6, 0x9E, 0x18, 0x09, 0x31), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_9_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0x05, 0x94, 0x44, 0xDC, 0xB8, 0x85, 0x94), - MBEDTLS_BYTES_TO_T_UINT_8(0x14, 0xB7, 0x37, 0xC2, 0x50, 0x75, 0x15, 0xDA), - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0xC6, 0x0F, 0xB2, 0xA9, 0x91, 0x3E, 0xE8), - MBEDTLS_BYTES_TO_T_UINT_8(0xB9, 0x81, 0xAD, 0x25, 0xA1, 0x26, 0x73, 0x15), - MBEDTLS_BYTES_TO_T_UINT_8(0xFD, 0xF1, 0xD1, 0x61, 0x7C, 0x76, 0x8F, 0x13), - MBEDTLS_BYTES_TO_T_UINT_8(0x06, 0xDB, 0x4A, 0xFF, 0x14, 0xA7, 0x48, 0x0B), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_10_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0x73, 0xC6, 0xC2, 0xCC, 0xF1, 0x57, 0x04), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0xED, 0x73, 0x27, 0x70, 0x82, 0xB6, 0x5E), - MBEDTLS_BYTES_TO_T_UINT_8(0x0B, 0xBA, 0xAC, 0x3A, 0xCF, 0xF4, 0xEA, 0xA6), - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0xD6, 0xB1, 0x8F, 0x0E, 0x08, 0x2C, 0x5E), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0xE3, 0x8F, 0x2F, 0x0E, 0xA1, 0xF3, 0x07), - MBEDTLS_BYTES_TO_T_UINT_8(0x1A, 0xF5, 0x7C, 0x9B, 0x29, 0x0A, 0xF6, 0x28), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_10_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xBD, 0xEE, 0x17, 0x47, 0x34, 0x15, 0xA3, 0xAF), - MBEDTLS_BYTES_TO_T_UINT_8(0xFB, 0xBE, 0x88, 0x48, 0xE7, 0xA2, 0xBB, 0xDE), - MBEDTLS_BYTES_TO_T_UINT_8(0xC5, 0xAD, 0xDC, 0x65, 0x61, 0x37, 0x0F, 0xC1), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0x67, 0xAD, 0xA2, 0x3A, 0x1C, 0x91, 0x78), - MBEDTLS_BYTES_TO_T_UINT_8(0x55, 0x07, 0x0C, 0x3A, 0x41, 0x6E, 0x13, 0x28), - MBEDTLS_BYTES_TO_T_UINT_8(0x73, 0xBD, 0x7E, 0xED, 0xAA, 0x14, 0xDD, 0x61), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_11_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC3, 0xDC, 0x20, 0x01, 0x72, 0x11, 0x48, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0xC4, 0x7B, 0xF8, 0x62, 0x3D, 0xF0, 0x9F), - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0xC2, 0x3D, 0x2E, 0x52, 0xA3, 0x4A, 0x89), - MBEDTLS_BYTES_TO_T_UINT_8(0xCE, 0xE2, 0x53, 0x46, 0x5E, 0x21, 0xF8, 0xCE), - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0xC7, 0x8F, 0xA9, 0x26, 0x42, 0x32, 0x3A), - MBEDTLS_BYTES_TO_T_UINT_8(0xFB, 0xA6, 0xA0, 0x8D, 0x4B, 0x9A, 0x19, 0x03), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_11_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xEA, 0xAB, 0x6D, 0x1E, 0xFB, 0xEE, 0x60, 0x0C), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x56, 0x3C, 0xC5, 0x5D, 0x10, 0x79, 0x1C), - MBEDTLS_BYTES_TO_T_UINT_8(0x25, 0xBC, 0x41, 0x9F, 0x71, 0xEF, 0x02, 0xF9), - MBEDTLS_BYTES_TO_T_UINT_8(0xA2, 0x36, 0xC4, 0xD0, 0x88, 0x9B, 0x32, 0xFC), - MBEDTLS_BYTES_TO_T_UINT_8(0x9C, 0xD4, 0x5D, 0x17, 0x39, 0xE6, 0x22, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0x7B, 0x26, 0x01, 0xCE, 0xBE, 0x4A, 0x9C, 0x27), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_12_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xEF, 0x6D, 0x11, 0xCA, 0x6C, 0x5A, 0x93, 0x0C), - MBEDTLS_BYTES_TO_T_UINT_8(0xEB, 0x96, 0x26, 0xAF, 0x2F, 0xE4, 0x30, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0x35, 0xC1, 0x4C, 0xC6, 0x30, 0x1F, 0x5C, 0x04), - MBEDTLS_BYTES_TO_T_UINT_8(0x59, 0xB3, 0xE8, 0xFC, 0x35, 0xEB, 0x63, 0x6C), - MBEDTLS_BYTES_TO_T_UINT_8(0x9C, 0x1D, 0xCA, 0xFC, 0x50, 0x36, 0x4B, 0x96), - MBEDTLS_BYTES_TO_T_UINT_8(0xE4, 0x0E, 0x23, 0x5B, 0xAF, 0xEB, 0x2D, 0x31), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_12_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC6, 0x88, 0xB6, 0xD7, 0x74, 0x4A, 0x23, 0xB6), - MBEDTLS_BYTES_TO_T_UINT_8(0xEF, 0x66, 0xE2, 0xBB, 0x29, 0xA6, 0x4F, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0xE9, 0x6F, 0x7E, 0x68, 0x6E, 0xA0, 0x14, 0x94), - MBEDTLS_BYTES_TO_T_UINT_8(0x3B, 0x73, 0xD4, 0xE8, 0xAB, 0x5B, 0xF6, 0x0D), - MBEDTLS_BYTES_TO_T_UINT_8(0x46, 0xE0, 0x3C, 0x24, 0x00, 0x95, 0xE9, 0xAD), - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0x0D, 0x4F, 0x81, 0xD0, 0xF2, 0x3F, 0x00), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_13_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0x1D, 0xCD, 0x78, 0x39, 0xC4, 0x6B, 0xD9), - MBEDTLS_BYTES_TO_T_UINT_8(0x81, 0x45, 0xC7, 0xB8, 0x2F, 0xAA, 0x5D, 0xE3), - MBEDTLS_BYTES_TO_T_UINT_8(0x33, 0x8C, 0x6E, 0xA3, 0x24, 0xB2, 0xDB, 0x4B), - MBEDTLS_BYTES_TO_T_UINT_8(0x69, 0x2D, 0xD9, 0xF1, 0xC7, 0x9B, 0x8A, 0xAF), - MBEDTLS_BYTES_TO_T_UINT_8(0x67, 0xE1, 0x2C, 0xB9, 0x40, 0x37, 0x91, 0x75), - MBEDTLS_BYTES_TO_T_UINT_8(0x81, 0x2C, 0xB5, 0x23, 0x03, 0x2B, 0xAF, 0x2F), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_13_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x2F, 0x9D, 0x5A, 0x20, 0x10, 0xA9, 0x84, 0xDA), - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0x30, 0x89, 0x20, 0x13, 0xE9, 0xB2, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x6E, 0x52, 0xEB, 0x03, 0x18, 0x1F, 0xA6), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x9E, 0x1C, 0x35, 0x87, 0x92, 0x69, 0xC7), - MBEDTLS_BYTES_TO_T_UINT_8(0xA1, 0xC9, 0x88, 0xAF, 0xC6, 0x6C, 0x83, 0x72), - MBEDTLS_BYTES_TO_T_UINT_8(0xCB, 0xD5, 0x7A, 0x54, 0x34, 0x99, 0xB6, 0x6F), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_14_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xDF, 0xAD, 0x45, 0x9B, 0x4B, 0x41, 0x4D, 0x50), - MBEDTLS_BYTES_TO_T_UINT_8(0x1B, 0x5D, 0xAB, 0x7F, 0x35, 0x34, 0xE9, 0x29), - MBEDTLS_BYTES_TO_T_UINT_8(0x73, 0xBE, 0x78, 0x34, 0x44, 0xF3, 0x4A, 0x87), - MBEDTLS_BYTES_TO_T_UINT_8(0xFB, 0xDE, 0xE3, 0xC4, 0xEE, 0x0B, 0xF9, 0xEB), - MBEDTLS_BYTES_TO_T_UINT_8(0x5E, 0x86, 0x16, 0x48, 0x32, 0xB8, 0x74, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0xF2, 0xEE, 0x7C, 0xBA, 0xBD, 0x81, 0xE3, 0x55), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_14_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF8, 0x6A, 0xFA, 0x84, 0xDA, 0xB8, 0xD5, 0x14), - MBEDTLS_BYTES_TO_T_UINT_8(0xB2, 0x9F, 0x8A, 0xD5, 0x1B, 0x2E, 0x1A, 0x0B), - MBEDTLS_BYTES_TO_T_UINT_8(0x5F, 0x0C, 0x61, 0xE2, 0xFF, 0x5B, 0xE6, 0xD5), - MBEDTLS_BYTES_TO_T_UINT_8(0x0E, 0x62, 0xC1, 0x87, 0x53, 0x1B, 0x92, 0xA3), - MBEDTLS_BYTES_TO_T_UINT_8(0x54, 0x90, 0x00, 0xD1, 0x6A, 0x0C, 0x0E, 0x28), - MBEDTLS_BYTES_TO_T_UINT_8(0x8B, 0x2E, 0xB5, 0x3B, 0x44, 0xB5, 0xA0, 0x78), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_15_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB8, 0x5D, 0x02, 0x58, 0xB5, 0xBE, 0x45, 0x14), - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0xEF, 0x8E, 0x90, 0x4D, 0x2A, 0x32, 0xAC), - MBEDTLS_BYTES_TO_T_UINT_8(0x48, 0x99, 0x75, 0x5C, 0x0A, 0x33, 0x8F, 0x36), - MBEDTLS_BYTES_TO_T_UINT_8(0xC8, 0x6C, 0x95, 0xD4, 0x1F, 0xF3, 0xEB, 0xDA), - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0xE4, 0x4C, 0x91, 0x20, 0xF3, 0x25, 0xEB), - MBEDTLS_BYTES_TO_T_UINT_8(0xF1, 0x95, 0xEB, 0x29, 0x6F, 0x20, 0x34, 0x81), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_15_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x2D, 0x15, 0xE5, 0x13, 0x7E, 0x64, 0x8B, 0xAD), - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0xBC, 0x0D, 0x18, 0x7E, 0x37, 0x9E, 0xFA), - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0x82, 0x20, 0xF7, 0x2D, 0x7A, 0x77, 0x52), - MBEDTLS_BYTES_TO_T_UINT_8(0xCB, 0x29, 0xA2, 0xDB, 0x7A, 0xE6, 0x6F, 0xA5), - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0xC6, 0x50, 0x5C, 0xBC, 0xE6, 0x4F, 0xBD), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0x9F, 0xD5, 0xE8, 0xC5, 0x3D, 0xB7, 0x30), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_16_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x45, 0x03, 0x55, 0x10, 0xDB, 0xA6, 0x8B, 0x22), - MBEDTLS_BYTES_TO_T_UINT_8(0x4E, 0x17, 0xAE, 0x78, 0xC9, 0x1D, 0x43, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0x4E, 0x35, 0x49, 0xD4, 0x47, 0x84, 0x8D, 0x20), - MBEDTLS_BYTES_TO_T_UINT_8(0xF3, 0x95, 0x2F, 0xEA, 0xBC, 0xB4, 0x18, 0xB3), - MBEDTLS_BYTES_TO_T_UINT_8(0xD4, 0x48, 0xAE, 0x89, 0xF5, 0x65, 0x3D, 0x89), - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0xF2, 0x2B, 0x20, 0xD1, 0x75, 0x50, 0x63), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_16_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0xE6, 0x5C, 0x2C, 0xE0, 0x7D, 0xDF, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0x3E, 0x07, 0x3E, 0xCE, 0x9F, 0x18, 0xB6, 0x05), - MBEDTLS_BYTES_TO_T_UINT_8(0x9A, 0xF8, 0xF0, 0xD5, 0xFA, 0x42, 0x1D, 0x6D), - MBEDTLS_BYTES_TO_T_UINT_8(0x41, 0x6C, 0x1D, 0x03, 0xC9, 0x0E, 0x2B, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0x43, 0x18, 0x52, 0xA5, 0xB4, 0x63, 0xE1, 0x06), - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0x0A, 0xD9, 0xC4, 0xFD, 0x16, 0x60, 0x54), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_17_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x43, 0x7D, 0xDE, 0xDF, 0x4B, 0x4A, 0xB0, 0xCB), - MBEDTLS_BYTES_TO_T_UINT_8(0xB0, 0x4E, 0x8C, 0x94, 0xC1, 0xE2, 0x85, 0xDF), - MBEDTLS_BYTES_TO_T_UINT_8(0x4F, 0xF0, 0xEA, 0xB5, 0x9B, 0x70, 0xEF, 0x10), - MBEDTLS_BYTES_TO_T_UINT_8(0x56, 0xC2, 0x39, 0x5D, 0xF3, 0x2C, 0xD9, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0x0D, 0x1C, 0x2E, 0xCC, 0x2F, 0x54, 0x87, 0x80), - MBEDTLS_BYTES_TO_T_UINT_8(0xB0, 0x72, 0xC7, 0xB5, 0x50, 0xA3, 0x84, 0x77), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_17_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0xD1, 0xAF, 0xA9, 0xB4, 0x8B, 0x5D, 0xFA), - MBEDTLS_BYTES_TO_T_UINT_8(0xC8, 0xF6, 0x52, 0x8A, 0xC3, 0x56, 0xA5, 0x5E), - MBEDTLS_BYTES_TO_T_UINT_8(0x3B, 0x52, 0xFF, 0xEA, 0x05, 0x42, 0x77, 0x83), - MBEDTLS_BYTES_TO_T_UINT_8(0x29, 0x08, 0x90, 0x72, 0x86, 0xC4, 0xC3, 0xB8), - MBEDTLS_BYTES_TO_T_UINT_8(0x4D, 0x15, 0xF8, 0xF1, 0x16, 0x67, 0xC6, 0xD5), - MBEDTLS_BYTES_TO_T_UINT_8(0x75, 0x87, 0xAC, 0x8F, 0x71, 0xEC, 0x83, 0x81), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_18_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x91, 0xE1, 0xE6, 0x2D, 0x0E, 0x11, 0xA1, 0x62), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0xE2, 0xA8, 0x32, 0xE6, 0xE3, 0x83, 0xD1), - MBEDTLS_BYTES_TO_T_UINT_8(0x50, 0x56, 0xE5, 0xCD, 0xB7, 0x2B, 0x67, 0x6F), - MBEDTLS_BYTES_TO_T_UINT_8(0xE5, 0xED, 0xC9, 0x65, 0x6D, 0x87, 0xE1, 0x8E), - MBEDTLS_BYTES_TO_T_UINT_8(0x50, 0x8E, 0xFD, 0x9A, 0x53, 0x0E, 0xFA, 0xA3), - MBEDTLS_BYTES_TO_T_UINT_8(0x49, 0x4C, 0x4A, 0xE2, 0x23, 0x84, 0xFA, 0x01), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_18_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0xFE, 0x49, 0x81, 0xD1, 0x3E, 0xF4, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0x45, 0x72, 0xE0, 0xEF, 0x0D, 0xB8, 0x3E, 0x6F), - MBEDTLS_BYTES_TO_T_UINT_8(0x3C, 0x00, 0x0F, 0x5F, 0xCE, 0x60, 0x72, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0xCC, 0xD8, 0x03, 0x07, 0x6E, 0x5A, 0xCD), - MBEDTLS_BYTES_TO_T_UINT_8(0x27, 0x3A, 0x35, 0x50, 0x4E, 0x1F, 0xCA, 0x5F), - MBEDTLS_BYTES_TO_T_UINT_8(0x58, 0xEA, 0x88, 0x55, 0xBD, 0x6E, 0x05, 0x7F), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_19_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB1, 0x6D, 0xF1, 0x97, 0xA6, 0x69, 0x39, 0x24), - MBEDTLS_BYTES_TO_T_UINT_8(0x0B, 0x41, 0x99, 0xFF, 0x3B, 0xA1, 0x26, 0xEC), - MBEDTLS_BYTES_TO_T_UINT_8(0x95, 0x2F, 0x95, 0x80, 0x12, 0x4A, 0x1B, 0xCB), - MBEDTLS_BYTES_TO_T_UINT_8(0xEA, 0xBF, 0x51, 0xAA, 0xAE, 0x2D, 0xDA, 0xCF), - MBEDTLS_BYTES_TO_T_UINT_8(0x0C, 0x1C, 0xB3, 0x52, 0x36, 0x49, 0xD4, 0x86), - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0xC1, 0x1F, 0x3A, 0xD3, 0x3E, 0x5C, 0x1A), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_19_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x73, 0x51, 0xF7, 0x2B, 0xC8, 0xA9, 0xA7, 0x15), - MBEDTLS_BYTES_TO_T_UINT_8(0x12, 0x4E, 0x7F, 0x98, 0x41, 0x66, 0xB0, 0x03), - MBEDTLS_BYTES_TO_T_UINT_8(0x91, 0x1D, 0xC0, 0x42, 0xCD, 0xF8, 0xC3, 0x2B), - MBEDTLS_BYTES_TO_T_UINT_8(0xCC, 0x41, 0x91, 0x7D, 0xCC, 0x8B, 0xCC, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0xAE, 0x76, 0xED, 0x56, 0x18, 0xC5, 0xAB), - MBEDTLS_BYTES_TO_T_UINT_8(0xAB, 0x6A, 0x06, 0xA3, 0x7F, 0x65, 0x10, 0x1F), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_20_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x0C, 0xEC, 0x3C, 0x05, 0x05, 0xCA, 0xF6, 0xED), - MBEDTLS_BYTES_TO_T_UINT_8(0x48, 0xCD, 0x02, 0x51, 0x12, 0x16, 0x3C, 0x63), - MBEDTLS_BYTES_TO_T_UINT_8(0xA8, 0xEB, 0xB3, 0x43, 0x7B, 0xDD, 0xB2, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x59, 0x90, 0x41, 0xDB, 0xE4, 0xF5, 0x91), - MBEDTLS_BYTES_TO_T_UINT_8(0xD0, 0x0E, 0x18, 0x2A, 0x5A, 0x83, 0x7C, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0xE1, 0x37, 0xA1, 0x0D, 0xF1, 0x2F, 0x63, 0x79), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_20_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0xC0, 0xFA, 0x6F, 0x1F, 0x67, 0xCF, 0xEC), - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0x34, 0x45, 0xBB, 0xF4, 0xF9, 0x9B, 0x89), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0x69, 0xFE, 0x67, 0x1D, 0x64, 0x8F, 0xB9), - MBEDTLS_BYTES_TO_T_UINT_8(0xDB, 0x39, 0xBF, 0xD8, 0xB3, 0xC7, 0xAD, 0x8A), - MBEDTLS_BYTES_TO_T_UINT_8(0x8C, 0x93, 0xFF, 0xF3, 0x28, 0xFA, 0x39, 0xF6), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0xF9, 0xC3, 0x85, 0x26, 0x7A, 0x88, 0x89), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_21_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x4D, 0xD5, 0x79, 0xD8, 0x11, 0xDE, 0xEB, 0x4E), - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0x46, 0xA4, 0x6A, 0xDA, 0x74, 0x34, 0xA8), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0xBD, 0xD3, 0xF5, 0x14, 0xEE, 0xFE, 0xAE), - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0x4C, 0xA3, 0x71, 0x43, 0x65, 0xF8, 0x94), - MBEDTLS_BYTES_TO_T_UINT_8(0x72, 0x6C, 0x35, 0xFA, 0x90, 0x25, 0xD8, 0xE2), - MBEDTLS_BYTES_TO_T_UINT_8(0xBB, 0x34, 0x84, 0x96, 0xA1, 0x43, 0x03, 0x4D), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_21_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF1, 0x3B, 0x3B, 0x2F, 0xCA, 0x59, 0xF2, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0xCD, 0x48, 0x24, 0x74, 0xD8, 0x72, 0x90, 0xA3), - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0x42, 0x74, 0x8C, 0x6F, 0x52, 0x19, 0x3D), - MBEDTLS_BYTES_TO_T_UINT_8(0x40, 0x9E, 0x41, 0x63, 0x68, 0x78, 0x4C, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0x53, 0x94, 0xB6, 0x6B, 0x38, 0x52, 0xA8, 0x9F), - MBEDTLS_BYTES_TO_T_UINT_8(0x81, 0x30, 0x25, 0x93, 0xA1, 0x6F, 0x6E, 0x68), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_22_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0x2F, 0x4B, 0x64, 0x79, 0x50, 0xFF, 0x01), - MBEDTLS_BYTES_TO_T_UINT_8(0xD4, 0x36, 0xED, 0x57, 0x39, 0x3B, 0xE7, 0xF3), - MBEDTLS_BYTES_TO_T_UINT_8(0xF1, 0x85, 0xEA, 0x35, 0xD6, 0xC0, 0xA0, 0x52), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0x89, 0x3A, 0xCC, 0x22, 0x1C, 0x46, 0x02), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x7A, 0xB0, 0xA1, 0x1B, 0x69, 0x62, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0x57, 0xB8, 0x8A, 0x6C, 0x18, 0x85, 0x0D, 0x88), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_22_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFD, 0xB6, 0x50, 0xE9, 0x4E, 0x7F, 0xE8, 0x07), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0x5B, 0x5C, 0xD1, 0x4B, 0x11, 0x9A, 0xD8), - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0x25, 0x56, 0x74, 0x51, 0x9C, 0xEC, 0x9C), - MBEDTLS_BYTES_TO_T_UINT_8(0x55, 0x7F, 0xB6, 0x8A, 0xCB, 0x3A, 0x10, 0x6A), - MBEDTLS_BYTES_TO_T_UINT_8(0x60, 0x33, 0x07, 0x01, 0xE9, 0x49, 0x59, 0xE6), - MBEDTLS_BYTES_TO_T_UINT_8(0xC6, 0xA5, 0x2E, 0xF2, 0xBA, 0x32, 0x63, 0x44), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_23_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF8, 0x06, 0x0B, 0xA5, 0x44, 0x27, 0x7F, 0x22), - MBEDTLS_BYTES_TO_T_UINT_8(0x30, 0x74, 0xAC, 0x0F, 0xCC, 0x4F, 0x13, 0x61), - MBEDTLS_BYTES_TO_T_UINT_8(0xFD, 0xB1, 0xBF, 0x97, 0x49, 0xA5, 0x1C, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0x8A, 0x64, 0x68, 0x7B, 0x0F, 0xCC, 0x77, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0xBB, 0x39, 0xF9, 0x4E, 0x84, 0x9C, 0xF6, 0x96), - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0xCF, 0x6D, 0xE2, 0xA1, 0x2D, 0xF9, 0x2B), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_23_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x95, 0xC4, 0x90, 0x57, 0x31, 0x01, 0x05, 0x5E), - MBEDTLS_BYTES_TO_T_UINT_8(0xCC, 0x1E, 0xBB, 0xBF, 0x98, 0xA4, 0x7C, 0xE3), - MBEDTLS_BYTES_TO_T_UINT_8(0x89, 0xE3, 0xA0, 0xB2, 0xCD, 0x39, 0x9A, 0x3F), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0x34, 0x60, 0x7A, 0x89, 0x98, 0xB5, 0x52), - MBEDTLS_BYTES_TO_T_UINT_8(0x8D, 0x20, 0x3D, 0x3A, 0x04, 0x8F, 0x5A, 0xAC), - MBEDTLS_BYTES_TO_T_UINT_8(0xA3, 0x26, 0xB6, 0x49, 0x09, 0x9C, 0x0F, 0x59), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_24_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x72, 0x66, 0xD2, 0x38, 0x2A, 0x62, 0x81, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0xC5, 0xC8, 0x20, 0x5E, 0x28, 0xA3, 0x81, 0xA7), - MBEDTLS_BYTES_TO_T_UINT_8(0x20, 0x31, 0xA4, 0xF1, 0xEA, 0x7D, 0x87, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0x8F, 0x2C, 0x99, 0x09, 0x6F, 0x63, 0xEB, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0x73, 0x76, 0xDA, 0x1A, 0x06, 0xBE, 0xDE, 0xA2), - MBEDTLS_BYTES_TO_T_UINT_8(0x29, 0x09, 0x2E, 0x75, 0x39, 0x30, 0x2D, 0x42), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_24_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x41, 0x9B, 0xC1, 0x5A, 0x17, 0xC3, 0x8C, 0x31), - MBEDTLS_BYTES_TO_T_UINT_8(0x58, 0x8D, 0x94, 0x4D, 0x3D, 0xAB, 0x60, 0xD4), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFD, 0x1E, 0x0F, 0x43, 0xAE, 0x9D, 0x62), - MBEDTLS_BYTES_TO_T_UINT_8(0x8E, 0xF2, 0xF3, 0x20, 0x1B, 0xAA, 0xB7, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0x9D, 0x5B, 0xA4, 0xF4, 0x90, 0x3B, 0xE3, 0x71), - MBEDTLS_BYTES_TO_T_UINT_8(0xF7, 0x78, 0x72, 0xBD, 0x65, 0x09, 0x0B, 0x01), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_25_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCA, 0x37, 0x2A, 0x6C, 0x16, 0x4F, 0x64, 0x59), - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0xCE, 0xA3, 0x90, 0xB4, 0x9A, 0xBC, 0xF7), - MBEDTLS_BYTES_TO_T_UINT_8(0x27, 0x38, 0x55, 0x63, 0x1D, 0x3A, 0x6E, 0x18), - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0xB4, 0xAA, 0x99, 0x22, 0x45, 0x89, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0x7C, 0x8C, 0xA6, 0x3D, 0xA7, 0x3E, 0xE8), - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0x06, 0x42, 0xDC, 0xA6, 0xE3, 0xC6, 0x12), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_25_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x55, 0x8C, 0x3D, 0x5D, 0x47, 0x31, 0x7C, 0xEB), - MBEDTLS_BYTES_TO_T_UINT_8(0x46, 0x85, 0xEE, 0x46, 0x7E, 0x13, 0x04, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0x9E, 0x3C, 0x8B, 0x43, 0x2E, 0x74, 0xF5, 0xF6), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0x88, 0x8E, 0x07, 0x29, 0x08, 0x03, 0x26), - MBEDTLS_BYTES_TO_T_UINT_8(0xEA, 0x9B, 0x89, 0xEB, 0x08, 0xE8, 0x43, 0xB5), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0x07, 0x67, 0xFD, 0xD9, 0x73, 0x6F, 0x18), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_26_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x29, 0xEB, 0x21, 0x8D, 0x98, 0x43, 0x74, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0x88, 0xCC, 0x14, 0xD8, 0x08, 0xBB, 0xA6, 0xE3), - MBEDTLS_BYTES_TO_T_UINT_8(0xC4, 0x98, 0xF2, 0x6A, 0x18, 0xC3, 0xDD, 0x9E), - MBEDTLS_BYTES_TO_T_UINT_8(0xC7, 0x38, 0x91, 0xA0, 0x03, 0xF2, 0x04, 0x62), - MBEDTLS_BYTES_TO_T_UINT_8(0x7A, 0xAF, 0xE8, 0xFD, 0xFB, 0x13, 0x70, 0x74), - MBEDTLS_BYTES_TO_T_UINT_8(0xD0, 0x93, 0x87, 0x98, 0x4A, 0xE0, 0x00, 0x12), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_26_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x97, 0x2E, 0x69, 0x9C, 0xA2, 0x2D, 0x03, 0x3F), - MBEDTLS_BYTES_TO_T_UINT_8(0x79, 0xFE, 0xF3, 0xB9, 0xC1, 0x85, 0x2A, 0xEE), - MBEDTLS_BYTES_TO_T_UINT_8(0xCE, 0xFD, 0x86, 0xB1, 0xCD, 0xBF, 0x41, 0xB7), - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0xD8, 0x9A, 0x21, 0xF3, 0xFE, 0xCB, 0xF1), - MBEDTLS_BYTES_TO_T_UINT_8(0x95, 0x78, 0x04, 0x60, 0xB7, 0xA9, 0xA2, 0x84), - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0x1E, 0x66, 0x2A, 0x54, 0x51, 0xBD, 0x8B), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_27_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x8E, 0x16, 0x36, 0xEF, 0x61, 0x2D, 0xEE, 0x3B), - MBEDTLS_BYTES_TO_T_UINT_8(0x45, 0x5F, 0x88, 0xA0, 0x13, 0x12, 0xF7, 0x23), - MBEDTLS_BYTES_TO_T_UINT_8(0xA9, 0xC6, 0xAD, 0x4A, 0x4A, 0x07, 0x01, 0x5B), - MBEDTLS_BYTES_TO_T_UINT_8(0xB8, 0x74, 0xB1, 0x4F, 0xEB, 0xBD, 0xD5, 0x6B), - MBEDTLS_BYTES_TO_T_UINT_8(0x57, 0xF9, 0x71, 0xA2, 0x06, 0x4F, 0xD7, 0xBC), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0x8B, 0x4D, 0x48, 0xE0, 0x98, 0xFB, 0x6A), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_27_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC4, 0xBA, 0x10, 0xA3, 0x0D, 0x52, 0xAC, 0x3A), - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0xD0, 0xE0, 0x36, 0xE6, 0x07, 0x3A, 0x30), - MBEDTLS_BYTES_TO_T_UINT_8(0x7E, 0x80, 0xF0, 0xAA, 0x49, 0x22, 0x4B, 0xDD), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xC7, 0xAB, 0x1C, 0x89, 0xCD, 0x24, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0x82, 0x2A, 0xFC, 0xB3, 0x6D, 0x45, 0x96, 0x49), - MBEDTLS_BYTES_TO_T_UINT_8(0x63, 0xE4, 0xDB, 0x52, 0x3F, 0xC4, 0xB4, 0x19), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_28_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x5B, 0xCC, 0xC8, 0x7F, 0xBB, 0x6B, 0x87, 0x47), - MBEDTLS_BYTES_TO_T_UINT_8(0xC0, 0x21, 0x3C, 0x69, 0x7D, 0x38, 0x57, 0x50), - MBEDTLS_BYTES_TO_T_UINT_8(0x52, 0x4C, 0x18, 0x3C, 0x53, 0xA5, 0x48, 0x6D), - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0xC3, 0x64, 0x45, 0xDB, 0xC4, 0x6D, 0x15), - MBEDTLS_BYTES_TO_T_UINT_8(0x49, 0xCC, 0xD1, 0xBB, 0x17, 0xB8, 0x34, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x69, 0x71, 0xFA, 0xA0, 0x28, 0x4A, 0x3D), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_28_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xED, 0xE8, 0x9E, 0x39, 0xEA, 0x8D, 0x38, 0xDB), - MBEDTLS_BYTES_TO_T_UINT_8(0xCC, 0x9C, 0xBB, 0xCD, 0x80, 0x1A, 0xEE, 0xB7), - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0xA0, 0x45, 0xBF, 0xD9, 0x22, 0x11, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0xDA, 0x7C, 0x5C, 0xD9, 0xC0, 0x9F, 0x69, 0xF5), - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0x8A, 0xA6, 0x79, 0x4E, 0x35, 0xB9, 0xD5), - MBEDTLS_BYTES_TO_T_UINT_8(0xCC, 0x8B, 0x9A, 0x3E, 0xA1, 0xB8, 0x28, 0x10), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_29_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x55, 0x2F, 0xEF, 0xBB, 0xA9, 0x72, 0x7F, 0xEA), - MBEDTLS_BYTES_TO_T_UINT_8(0xB5, 0x34, 0xB7, 0x12, 0xB9, 0xE7, 0xC3, 0x2A), - MBEDTLS_BYTES_TO_T_UINT_8(0xF8, 0x1D, 0xD9, 0x42, 0x77, 0x0C, 0x71, 0x6E), - MBEDTLS_BYTES_TO_T_UINT_8(0xEC, 0x01, 0x59, 0xA7, 0x56, 0x03, 0x91, 0x8D), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x91, 0x99, 0x33, 0x30, 0x3E, 0xEF, 0x13), - MBEDTLS_BYTES_TO_T_UINT_8(0x87, 0xC9, 0x5A, 0x9A, 0x54, 0x66, 0xF1, 0x70), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_29_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x64, 0x2C, 0xB7, 0x6E, 0x71, 0x7D, 0x35, 0x30), - MBEDTLS_BYTES_TO_T_UINT_8(0x1A, 0x0D, 0xEF, 0xD1, 0x2D, 0x99, 0x63, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0xE4, 0x31, 0xAF, 0x2D, 0xC9, 0xC6, 0xC2, 0xAE), - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0xC0, 0xDF, 0x80, 0x54, 0xC4, 0xAC, 0xF3), - MBEDTLS_BYTES_TO_T_UINT_8(0xE3, 0x6B, 0xA0, 0x84, 0x96, 0xF7, 0x31, 0xC8), - MBEDTLS_BYTES_TO_T_UINT_8(0x93, 0xE2, 0x7C, 0x7A, 0x41, 0x45, 0x75, 0x6A), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_30_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xAE, 0xEE, 0x58, 0x31, 0xE8, 0x68, 0xD6, 0x76), - MBEDTLS_BYTES_TO_T_UINT_8(0xD2, 0x2E, 0x48, 0xB7, 0x09, 0x9F, 0xD4, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0xA9, 0x5C, 0xE7, 0x64, 0x43, 0x5D, 0xC9), - MBEDTLS_BYTES_TO_T_UINT_8(0x9E, 0x58, 0x9F, 0x50, 0xAB, 0x68, 0xFF, 0x6D), - MBEDTLS_BYTES_TO_T_UINT_8(0x87, 0x88, 0x2D, 0xBA, 0x12, 0xBF, 0x8D, 0x7D), - MBEDTLS_BYTES_TO_T_UINT_8(0xD4, 0xDF, 0x6F, 0xB3, 0x75, 0xA4, 0x55, 0x73), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_30_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0x17, 0x92, 0x39, 0xB7, 0x13, 0x37, 0x6F), - MBEDTLS_BYTES_TO_T_UINT_8(0x5E, 0x43, 0x71, 0xA7, 0xCA, 0x17, 0x1B, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0xE7, 0xB9, 0xB0, 0x78, 0xEF, 0xA0, 0xDA, 0x83), - MBEDTLS_BYTES_TO_T_UINT_8(0x9A, 0x84, 0xF2, 0x0F, 0x85, 0xA2, 0xB6, 0x1F), - MBEDTLS_BYTES_TO_T_UINT_8(0x72, 0x65, 0x2E, 0x6E, 0x45, 0xB9, 0x4C, 0x3C), - MBEDTLS_BYTES_TO_T_UINT_8(0xFE, 0x6A, 0x8C, 0x2B, 0x77, 0x96, 0x36, 0x22), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_31_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x68, 0x7A, 0x13, 0x4A, 0x97, 0x63, 0x02, 0x10), - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0x1E, 0x06, 0x03, 0x8F, 0xB9, 0xEE, 0x64), - MBEDTLS_BYTES_TO_T_UINT_8(0x68, 0xEE, 0x8B, 0x89, 0xA9, 0x70, 0xDB, 0xCE), - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x7B, 0x81, 0xC9, 0x70, 0x8D, 0x62, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0x75, 0xDA, 0x46, 0xF8, 0xF9, 0x3A, 0xBE, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0x9F, 0x9C, 0x7A, 0x97, 0x62, 0xEB, 0xFA, 0x0F), -}; -static const mbedtls_mpi_uint brainpoolP384r1_T_31_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB2, 0x03, 0x3D, 0x3C, 0x46, 0x27, 0x9E, 0x65), - MBEDTLS_BYTES_TO_T_UINT_8(0xA4, 0x08, 0x1C, 0xD5, 0x25, 0xAF, 0xE9, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0xFE, 0x69, 0xDC, 0x59, 0xF4, 0x8A, 0x7C, 0x1F), - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0x9A, 0x7A, 0x99, 0x21, 0x0C, 0x4E, 0xE3), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0xCE, 0x85, 0x5F, 0xAC, 0xAA, 0x82, 0x10), - MBEDTLS_BYTES_TO_T_UINT_8(0x83, 0x57, 0x69, 0x90, 0x76, 0xF3, 0x53, 0x3F), -}; -static const mbedtls_ecp_point brainpoolP384r1_T[32] = { - ECP_POINT_INIT_XY_Z1(brainpoolP384r1_T_0_X, brainpoolP384r1_T_0_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_1_X, brainpoolP384r1_T_1_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_2_X, brainpoolP384r1_T_2_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_3_X, brainpoolP384r1_T_3_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_4_X, brainpoolP384r1_T_4_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_5_X, brainpoolP384r1_T_5_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_6_X, brainpoolP384r1_T_6_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_7_X, brainpoolP384r1_T_7_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_8_X, brainpoolP384r1_T_8_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_9_X, brainpoolP384r1_T_9_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_10_X, brainpoolP384r1_T_10_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_11_X, brainpoolP384r1_T_11_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_12_X, brainpoolP384r1_T_12_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_13_X, brainpoolP384r1_T_13_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_14_X, brainpoolP384r1_T_14_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_15_X, brainpoolP384r1_T_15_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_16_X, brainpoolP384r1_T_16_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_17_X, brainpoolP384r1_T_17_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_18_X, brainpoolP384r1_T_18_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_19_X, brainpoolP384r1_T_19_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_20_X, brainpoolP384r1_T_20_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_21_X, brainpoolP384r1_T_21_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_22_X, brainpoolP384r1_T_22_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_23_X, brainpoolP384r1_T_23_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_24_X, brainpoolP384r1_T_24_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_25_X, brainpoolP384r1_T_25_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_26_X, brainpoolP384r1_T_26_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_27_X, brainpoolP384r1_T_27_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_28_X, brainpoolP384r1_T_28_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_29_X, brainpoolP384r1_T_29_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_30_X, brainpoolP384r1_T_30_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP384r1_T_31_X, brainpoolP384r1_T_31_Y), -}; -#else -#define brainpoolP384r1_T NULL -#endif - -#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */ - -/* - * Domain parameters for brainpoolP512r1 (RFC 5639 3.7) - */ -#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) -static const mbedtls_mpi_uint brainpoolP512r1_p[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF3, 0x48, 0x3A, 0x58, 0x56, 0x60, 0xAA, 0x28), - MBEDTLS_BYTES_TO_T_UINT_8(0x85, 0xC6, 0x82, 0x2D, 0x2F, 0xFF, 0x81, 0x28), - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0x80, 0xA3, 0xE6, 0x2A, 0xA1, 0xCD, 0xAE), - MBEDTLS_BYTES_TO_T_UINT_8(0x42, 0x68, 0xC6, 0x9B, 0x00, 0x9B, 0x4D, 0x7D), - MBEDTLS_BYTES_TO_T_UINT_8(0x71, 0x08, 0x33, 0x70, 0xCA, 0x9C, 0x63, 0xD6), - MBEDTLS_BYTES_TO_T_UINT_8(0x0E, 0xD2, 0xC9, 0xB3, 0xB3, 0x8D, 0x30, 0xCB), - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0xFC, 0xC9, 0x33, 0xAE, 0xE6, 0xD4, 0x3F), - MBEDTLS_BYTES_TO_T_UINT_8(0x8B, 0xC4, 0xE9, 0xDB, 0xB8, 0x9D, 0xDD, 0xAA), -}; -static const mbedtls_mpi_uint brainpoolP512r1_a[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xCA, 0x94, 0xFC, 0x77, 0x4D, 0xAC, 0xC1, 0xE7), - MBEDTLS_BYTES_TO_T_UINT_8(0xB9, 0xC7, 0xF2, 0x2B, 0xA7, 0x17, 0x11, 0x7F), - MBEDTLS_BYTES_TO_T_UINT_8(0xB5, 0xC8, 0x9A, 0x8B, 0xC9, 0xF1, 0x2E, 0x0A), - MBEDTLS_BYTES_TO_T_UINT_8(0xA1, 0x3A, 0x25, 0xA8, 0x5A, 0x5D, 0xED, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0x63, 0x98, 0xEA, 0xCA, 0x41, 0x34, 0xA8), - MBEDTLS_BYTES_TO_T_UINT_8(0x10, 0x16, 0xF9, 0x3D, 0x8D, 0xDD, 0xCB, 0x94), - MBEDTLS_BYTES_TO_T_UINT_8(0xC5, 0x4C, 0x23, 0xAC, 0x45, 0x71, 0x32, 0xE2), - MBEDTLS_BYTES_TO_T_UINT_8(0x89, 0x3B, 0x60, 0x8B, 0x31, 0xA3, 0x30, 0x78), -}; -static const mbedtls_mpi_uint brainpoolP512r1_b[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x23, 0xF7, 0x16, 0x80, 0x63, 0xBD, 0x09, 0x28), - MBEDTLS_BYTES_TO_T_UINT_8(0xDD, 0xE5, 0xBA, 0x5E, 0xB7, 0x50, 0x40, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0x67, 0x3E, 0x08, 0xDC, 0xCA, 0x94, 0xFC, 0x77), - MBEDTLS_BYTES_TO_T_UINT_8(0x4D, 0xAC, 0xC1, 0xE7, 0xB9, 0xC7, 0xF2, 0x2B), - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0x17, 0x11, 0x7F, 0xB5, 0xC8, 0x9A, 0x8B), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0xF1, 0x2E, 0x0A, 0xA1, 0x3A, 0x25, 0xA8), - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0x5D, 0xED, 0x2D, 0xBC, 0x63, 0x98, 0xEA), - MBEDTLS_BYTES_TO_T_UINT_8(0xCA, 0x41, 0x34, 0xA8, 0x10, 0x16, 0xF9, 0x3D), -}; -static const mbedtls_mpi_uint brainpoolP512r1_gx[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x22, 0xF8, 0xB9, 0xBC, 0x09, 0x22, 0x35, 0x8B), - MBEDTLS_BYTES_TO_T_UINT_8(0x68, 0x5E, 0x6A, 0x40, 0x47, 0x50, 0x6D, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0x5F, 0x7D, 0xB9, 0x93, 0x7B, 0x68, 0xD1, 0x50), - MBEDTLS_BYTES_TO_T_UINT_8(0x8D, 0xD4, 0xD0, 0xE2, 0x78, 0x1F, 0x3B, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0x8E, 0x09, 0xD0, 0xF4, 0xEE, 0x62, 0x3B, 0xB4), - MBEDTLS_BYTES_TO_T_UINT_8(0xC1, 0x16, 0xD9, 0xB5, 0x70, 0x9F, 0xED, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0x93, 0x6A, 0x4C, 0x9C, 0x2E, 0x32, 0x21, 0x5A), - MBEDTLS_BYTES_TO_T_UINT_8(0x64, 0xD9, 0x2E, 0xD8, 0xBD, 0xE4, 0xAE, 0x81), -}; -static const mbedtls_mpi_uint brainpoolP512r1_gy[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0x08, 0xD8, 0x3A, 0x0F, 0x1E, 0xCD, 0x78), - MBEDTLS_BYTES_TO_T_UINT_8(0x06, 0x54, 0xF0, 0xA8, 0x2F, 0x2B, 0xCA, 0xD1), - MBEDTLS_BYTES_TO_T_UINT_8(0xAE, 0x63, 0x27, 0x8A, 0xD8, 0x4B, 0xCA, 0x5B), - MBEDTLS_BYTES_TO_T_UINT_8(0x5E, 0x48, 0x5F, 0x4A, 0x49, 0xDE, 0xDC, 0xB2), - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0x81, 0x1F, 0x88, 0x5B, 0xC5, 0x00, 0xA0), - MBEDTLS_BYTES_TO_T_UINT_8(0x1A, 0x7B, 0xA5, 0x24, 0x00, 0xF7, 0x09, 0xF2), - MBEDTLS_BYTES_TO_T_UINT_8(0xFD, 0x22, 0x78, 0xCF, 0xA9, 0xBF, 0xEA, 0xC0), - MBEDTLS_BYTES_TO_T_UINT_8(0xEC, 0x32, 0x63, 0x56, 0x5D, 0x38, 0xDE, 0x7D), -}; -static const mbedtls_mpi_uint brainpoolP512r1_n[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x69, 0x00, 0xA9, 0x9C, 0x82, 0x96, 0x87, 0xB5), - MBEDTLS_BYTES_TO_T_UINT_8(0xDD, 0xDA, 0x5D, 0x08, 0x81, 0xD3, 0xB1, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0x47, 0x10, 0xAC, 0x7F, 0x19, 0x61, 0x86, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0x26, 0xA9, 0x4C, 0x41, 0x5C, 0x3E, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0x08, 0x33, 0x70, 0xCA, 0x9C, 0x63, 0xD6), - MBEDTLS_BYTES_TO_T_UINT_8(0x0E, 0xD2, 0xC9, 0xB3, 0xB3, 0x8D, 0x30, 0xCB), - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0xFC, 0xC9, 0x33, 0xAE, 0xE6, 0xD4, 0x3F), - MBEDTLS_BYTES_TO_T_UINT_8(0x8B, 0xC4, 0xE9, 0xDB, 0xB8, 0x9D, 0xDD, 0xAA), -}; - -#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 -static const mbedtls_mpi_uint brainpoolP512r1_T_0_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x22, 0xF8, 0xB9, 0xBC, 0x09, 0x22, 0x35, 0x8B), - MBEDTLS_BYTES_TO_T_UINT_8(0x68, 0x5E, 0x6A, 0x40, 0x47, 0x50, 0x6D, 0x7C), - MBEDTLS_BYTES_TO_T_UINT_8(0x5F, 0x7D, 0xB9, 0x93, 0x7B, 0x68, 0xD1, 0x50), - MBEDTLS_BYTES_TO_T_UINT_8(0x8D, 0xD4, 0xD0, 0xE2, 0x78, 0x1F, 0x3B, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0x8E, 0x09, 0xD0, 0xF4, 0xEE, 0x62, 0x3B, 0xB4), - MBEDTLS_BYTES_TO_T_UINT_8(0xC1, 0x16, 0xD9, 0xB5, 0x70, 0x9F, 0xED, 0x85), - MBEDTLS_BYTES_TO_T_UINT_8(0x93, 0x6A, 0x4C, 0x9C, 0x2E, 0x32, 0x21, 0x5A), - MBEDTLS_BYTES_TO_T_UINT_8(0x64, 0xD9, 0x2E, 0xD8, 0xBD, 0xE4, 0xAE, 0x81), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_0_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0x08, 0xD8, 0x3A, 0x0F, 0x1E, 0xCD, 0x78), - MBEDTLS_BYTES_TO_T_UINT_8(0x06, 0x54, 0xF0, 0xA8, 0x2F, 0x2B, 0xCA, 0xD1), - MBEDTLS_BYTES_TO_T_UINT_8(0xAE, 0x63, 0x27, 0x8A, 0xD8, 0x4B, 0xCA, 0x5B), - MBEDTLS_BYTES_TO_T_UINT_8(0x5E, 0x48, 0x5F, 0x4A, 0x49, 0xDE, 0xDC, 0xB2), - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0x81, 0x1F, 0x88, 0x5B, 0xC5, 0x00, 0xA0), - MBEDTLS_BYTES_TO_T_UINT_8(0x1A, 0x7B, 0xA5, 0x24, 0x00, 0xF7, 0x09, 0xF2), - MBEDTLS_BYTES_TO_T_UINT_8(0xFD, 0x22, 0x78, 0xCF, 0xA9, 0xBF, 0xEA, 0xC0), - MBEDTLS_BYTES_TO_T_UINT_8(0xEC, 0x32, 0x63, 0x56, 0x5D, 0x38, 0xDE, 0x7D), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_1_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xEA, 0xE9, 0x6B, 0x8C, 0x6F, 0x9D, 0x88, 0x43), - MBEDTLS_BYTES_TO_T_UINT_8(0xBB, 0x4F, 0x86, 0x96, 0xA7, 0x56, 0xD1, 0x37), - MBEDTLS_BYTES_TO_T_UINT_8(0x9D, 0xAB, 0xFA, 0xEE, 0xA7, 0xF5, 0x0E, 0xA6), - MBEDTLS_BYTES_TO_T_UINT_8(0xE3, 0x40, 0xEF, 0x9E, 0x6D, 0xD6, 0x32, 0x33), - MBEDTLS_BYTES_TO_T_UINT_8(0xE3, 0xED, 0x56, 0x14, 0x57, 0x1A, 0x8D, 0x69), - MBEDTLS_BYTES_TO_T_UINT_8(0xA4, 0xED, 0x4D, 0x3A, 0xFA, 0x71, 0x75, 0x6B), - MBEDTLS_BYTES_TO_T_UINT_8(0x66, 0xC5, 0x76, 0x1C, 0x14, 0xBE, 0xB5, 0xCD), - MBEDTLS_BYTES_TO_T_UINT_8(0xE1, 0x5A, 0xCB, 0xE7, 0x36, 0x1D, 0x52, 0x1C), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_1_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x6B, 0x8D, 0x7A, 0xEB, 0xA3, 0x8B, 0xD5, 0xB0), - MBEDTLS_BYTES_TO_T_UINT_8(0x1F, 0xA3, 0x41, 0xF8, 0xAC, 0x9E, 0xAB, 0x74), - MBEDTLS_BYTES_TO_T_UINT_8(0x12, 0xE3, 0x65, 0x0D, 0x1C, 0xFE, 0x09, 0x2B), - MBEDTLS_BYTES_TO_T_UINT_8(0x3F, 0xCA, 0x13, 0x3F, 0xC5, 0xF9, 0x7E, 0xEC), - MBEDTLS_BYTES_TO_T_UINT_8(0x2C, 0x5D, 0x63, 0x28, 0xA6, 0x89, 0xD3, 0x91), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x95, 0x3F, 0x7A, 0x82, 0xD4, 0x77, 0xE3), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0xBB, 0x92, 0x32, 0x00, 0xF4, 0x66, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0x58, 0x31, 0xD1, 0x17, 0x9F, 0x2A, 0x22), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_2_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x52, 0x36, 0xA9, 0xCD, 0x80, 0xA5, 0x2D, 0x78), - MBEDTLS_BYTES_TO_T_UINT_8(0x91, 0x44, 0xAB, 0xCE, 0x71, 0xFF, 0x0C, 0x9B), - MBEDTLS_BYTES_TO_T_UINT_8(0x18, 0x24, 0x58, 0x35, 0x5A, 0x21, 0x32, 0x93), - MBEDTLS_BYTES_TO_T_UINT_8(0x1B, 0xA6, 0x28, 0xF8, 0x7A, 0x97, 0xAE, 0x8B), - MBEDTLS_BYTES_TO_T_UINT_8(0x84, 0xE7, 0x08, 0xFA, 0x47, 0xC9, 0x55, 0x09), - MBEDTLS_BYTES_TO_T_UINT_8(0x8D, 0xAC, 0x2E, 0x84, 0xA4, 0xF5, 0x52, 0xC4), - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0x58, 0x05, 0x9D, 0xA7, 0xC8, 0x71, 0xBF), - MBEDTLS_BYTES_TO_T_UINT_8(0xB3, 0x92, 0xB4, 0x92, 0xC1, 0x92, 0xEC, 0x6B), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_2_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x4A, 0x48, 0x2D, 0x79, 0x5E, 0x58, 0xE5, 0x69), - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0x85, 0x26, 0xEC, 0xE9, 0x6E, 0xD4, 0x06), - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0x68, 0x26, 0x87, 0x38, 0xA2, 0xD2, 0x0B), - MBEDTLS_BYTES_TO_T_UINT_8(0xF7, 0x17, 0x60, 0xCE, 0x75, 0xF8, 0xA5, 0x6F), - MBEDTLS_BYTES_TO_T_UINT_8(0x20, 0x51, 0xDB, 0xA9, 0xAE, 0x87, 0xF1, 0x15), - MBEDTLS_BYTES_TO_T_UINT_8(0xDD, 0x49, 0x92, 0x3B, 0x19, 0x96, 0xF5, 0xB0), - MBEDTLS_BYTES_TO_T_UINT_8(0xC4, 0xD5, 0x52, 0x52, 0x8C, 0xCE, 0xFD, 0xFA), - MBEDTLS_BYTES_TO_T_UINT_8(0x24, 0x18, 0x0A, 0xE6, 0xF6, 0xAE, 0x08, 0x41), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_3_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x7E, 0x2B, 0xD8, 0x54, 0xCE, 0xB0, 0x57, 0xFE), - MBEDTLS_BYTES_TO_T_UINT_8(0x8A, 0xB0, 0xF8, 0x9E, 0x03, 0x03, 0x3C, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0x93, 0x0E, 0x29, 0x29, 0x00, 0xF3, 0x70, 0xBF), - MBEDTLS_BYTES_TO_T_UINT_8(0x54, 0x33, 0x99, 0x0E, 0x00, 0x5D, 0xFE, 0x4B), - MBEDTLS_BYTES_TO_T_UINT_8(0x46, 0x2D, 0xF2, 0x59, 0x32, 0xCF, 0x03, 0xF4), - MBEDTLS_BYTES_TO_T_UINT_8(0x3B, 0xC9, 0x72, 0xAE, 0x0C, 0xEF, 0xD1, 0x5B), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x5A, 0x27, 0xBF, 0x2F, 0x45, 0xF9, 0x51), - MBEDTLS_BYTES_TO_T_UINT_8(0xD4, 0xBE, 0xE5, 0x2C, 0xFF, 0x5B, 0x1E, 0x88), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_3_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xAA, 0xAC, 0xBB, 0xD8, 0x83, 0xC2, 0x46, 0xF6), - MBEDTLS_BYTES_TO_T_UINT_8(0xCF, 0xDC, 0xCE, 0x15, 0xB4, 0xEF, 0xCF, 0x46), - MBEDTLS_BYTES_TO_T_UINT_8(0x46, 0xDB, 0x5E, 0x94, 0x31, 0x0B, 0xB2, 0x7A), - MBEDTLS_BYTES_TO_T_UINT_8(0x3C, 0xB9, 0xE3, 0xE3, 0x11, 0x71, 0x41, 0x1E), - MBEDTLS_BYTES_TO_T_UINT_8(0x36, 0xE3, 0x01, 0xB7, 0x7D, 0xBC, 0x65, 0xBE), - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0x07, 0x65, 0x87, 0xA7, 0xE8, 0x48, 0xE3), - MBEDTLS_BYTES_TO_T_UINT_8(0x66, 0x48, 0x8F, 0xD4, 0x30, 0x8E, 0xB4, 0x6C), - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0xE0, 0x73, 0xBE, 0x1E, 0xBF, 0x56, 0x36), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_4_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xFE, 0x0E, 0x5E, 0x87, 0xC5, 0xAB, 0x0E, 0x3C), - MBEDTLS_BYTES_TO_T_UINT_8(0xB9, 0xF9, 0x5F, 0x80, 0x24, 0x4C, 0x2A, 0xF1), - MBEDTLS_BYTES_TO_T_UINT_8(0xDE, 0x15, 0x21, 0x54, 0x92, 0x84, 0x8D, 0x6A), - MBEDTLS_BYTES_TO_T_UINT_8(0xA8, 0x8A, 0x47, 0x74, 0xDC, 0x42, 0xB1, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0x81, 0xF7, 0x30, 0xFD, 0xC1, 0x9B, 0x0C, 0x5B), - MBEDTLS_BYTES_TO_T_UINT_8(0x4E, 0x6C, 0xCC, 0xDF, 0xC5, 0xE3, 0xA9, 0xD5), - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0x67, 0x59, 0x10, 0x5C, 0x51, 0x54, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0x37, 0xFB, 0x6E, 0xB0, 0x78, 0x63, 0x8E), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_4_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA5, 0xEF, 0xC4, 0x39, 0x20, 0xF1, 0x46, 0x66), - MBEDTLS_BYTES_TO_T_UINT_8(0xE2, 0x62, 0xAE, 0xFF, 0x10, 0xE4, 0xE2, 0xE9), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0x5C, 0xF5, 0x2E, 0x22, 0x89, 0xE5, 0x82), - MBEDTLS_BYTES_TO_T_UINT_8(0x89, 0x0C, 0x29, 0xA8, 0x62, 0xAE, 0xDB, 0x65), - MBEDTLS_BYTES_TO_T_UINT_8(0xD7, 0x9E, 0x0F, 0xCA, 0x87, 0x2A, 0x6F, 0x7B), - MBEDTLS_BYTES_TO_T_UINT_8(0xCE, 0xDC, 0x9B, 0x9F, 0x65, 0xD4, 0xAD, 0x27), - MBEDTLS_BYTES_TO_T_UINT_8(0xED, 0xC3, 0x08, 0x0F, 0xCF, 0x67, 0xE9, 0xF4), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0x5C, 0xD7, 0xFF, 0x41, 0x9C, 0xCB, 0x26), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_5_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0x25, 0x05, 0x12, 0xAD, 0x73, 0x63, 0x90), - MBEDTLS_BYTES_TO_T_UINT_8(0xC7, 0x99, 0x07, 0x86, 0x57, 0xE7, 0x94, 0xB1), - MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x4B, 0xA5, 0xBF, 0x18, 0xA9, 0xEF, 0x6A), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0x4C, 0xC4, 0x09, 0xF2, 0x2F, 0x0C, 0xAA), - MBEDTLS_BYTES_TO_T_UINT_8(0x8C, 0x3A, 0x04, 0xEA, 0x89, 0x6C, 0x91, 0xB9), - MBEDTLS_BYTES_TO_T_UINT_8(0x7D, 0x6C, 0x3A, 0xE7, 0xA3, 0xEC, 0x24, 0x7B), - MBEDTLS_BYTES_TO_T_UINT_8(0x16, 0xA1, 0x26, 0x21, 0x04, 0xE3, 0xB9, 0x40), - MBEDTLS_BYTES_TO_T_UINT_8(0x53, 0x71, 0x4B, 0x7B, 0xC2, 0x89, 0xCD, 0xA2), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_5_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB7, 0xB9, 0xA8, 0x9D, 0xFD, 0x00, 0x3A, 0x1F), - MBEDTLS_BYTES_TO_T_UINT_8(0x63, 0x41, 0x6C, 0xBB, 0x5A, 0xCA, 0x1F, 0x74), - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0xD7, 0xE2, 0x6C, 0x6B, 0xA7, 0x48, 0xC9), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0x19, 0xAD, 0xA7, 0xC1, 0x7E, 0x4F, 0x6E), - MBEDTLS_BYTES_TO_T_UINT_8(0xD1, 0xF7, 0x19, 0x3C, 0x06, 0x74, 0x2C, 0x3A), - MBEDTLS_BYTES_TO_T_UINT_8(0xC5, 0x23, 0x4F, 0x0C, 0x09, 0xB0, 0x80, 0x4A), - MBEDTLS_BYTES_TO_T_UINT_8(0x4E, 0x74, 0x34, 0x08, 0x44, 0x7E, 0xA3, 0xDD), - MBEDTLS_BYTES_TO_T_UINT_8(0xFB, 0xCC, 0x8D, 0x12, 0x6E, 0xE1, 0x3D, 0x0B), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_6_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x38, 0x18, 0xB1, 0x71, 0x02, 0x93, 0xC2, 0xA4), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x89, 0x40, 0xE2, 0x1F, 0xE7, 0x5E, 0x68), - MBEDTLS_BYTES_TO_T_UINT_8(0x50, 0x8E, 0xAE, 0x89, 0x01, 0xD4, 0x0C, 0xEB), - MBEDTLS_BYTES_TO_T_UINT_8(0xAE, 0xDA, 0x58, 0x70, 0x24, 0xF2, 0xE4, 0x5F), - MBEDTLS_BYTES_TO_T_UINT_8(0x6F, 0xC7, 0x1D, 0xD6, 0x4A, 0x6F, 0x66, 0x4F), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0x1D, 0x7E, 0x4A, 0x2C, 0xCA, 0xEC, 0x3B), - MBEDTLS_BYTES_TO_T_UINT_8(0xA1, 0x06, 0x7F, 0xA8, 0x99, 0xE4, 0xD3, 0x4E), - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0x1D, 0x5A, 0xDF, 0x5E, 0x58, 0x36, 0x49), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_6_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x9C, 0xB9, 0x32, 0x69, 0x1F, 0x72, 0x2A, 0xB3), - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0x73, 0xE2, 0x03, 0x39, 0x35, 0xAA, 0xA8), - MBEDTLS_BYTES_TO_T_UINT_8(0xEB, 0x5E, 0x5D, 0x48, 0xEF, 0xAE, 0x30, 0xF5), - MBEDTLS_BYTES_TO_T_UINT_8(0x77, 0x7F, 0x60, 0x19, 0xAF, 0xEC, 0x9D, 0xFC), - MBEDTLS_BYTES_TO_T_UINT_8(0xCA, 0xD9, 0x19, 0xE4, 0x1B, 0x56, 0x15, 0x5F), - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0xD7, 0x33, 0x59, 0x1F, 0x43, 0x59, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0xC6, 0xCE, 0xEE, 0xCA, 0xA4, 0x7F, 0x63, 0xD4), - MBEDTLS_BYTES_TO_T_UINT_8(0xBD, 0x40, 0xC0, 0xF6, 0x19, 0x89, 0x43, 0x20), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_7_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xEB, 0x92, 0xEA, 0x07, 0x65, 0x79, 0x86, 0xD3), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xB7, 0x13, 0x75, 0xD3, 0xC5, 0x0A, 0xC9), - MBEDTLS_BYTES_TO_T_UINT_8(0x26, 0x9E, 0xFA, 0xE1, 0x1F, 0x0C, 0xF9, 0x74), - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0x8C, 0xED, 0x5C, 0x21, 0xE9, 0x09, 0xDD), - MBEDTLS_BYTES_TO_T_UINT_8(0xF4, 0x4D, 0xD8, 0x18, 0xC4, 0xF6, 0x36, 0x39), - MBEDTLS_BYTES_TO_T_UINT_8(0xC7, 0xC9, 0xAC, 0x5C, 0xFA, 0x69, 0xA4, 0xA0), - MBEDTLS_BYTES_TO_T_UINT_8(0x6B, 0x8C, 0x94, 0x1C, 0x7B, 0x71, 0x36, 0x58), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0xBD, 0x46, 0xCE, 0xB7, 0x1D, 0x9C, 0x5E), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_7_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xEA, 0xD6, 0x96, 0x4B, 0xA6, 0x47, 0xEB, 0xE5), - MBEDTLS_BYTES_TO_T_UINT_8(0x5F, 0xF1, 0x5F, 0x15, 0xDE, 0x99, 0x6F, 0x66), - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0xBD, 0xE5, 0x04, 0xB8, 0xE6, 0xC0, 0x0B), - MBEDTLS_BYTES_TO_T_UINT_8(0x49, 0xD3, 0xF0, 0x04, 0x00, 0xE4, 0x05, 0xDB), - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0xF3, 0x06, 0xA3, 0x1A, 0xFF, 0xEA, 0x73), - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0x32, 0xAA, 0x99, 0x33, 0x09, 0xB6, 0x34), - MBEDTLS_BYTES_TO_T_UINT_8(0x6E, 0xEF, 0xFC, 0x61, 0x10, 0x42, 0x31, 0x94), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0xF1, 0xF4, 0x33, 0xCF, 0x28, 0x90, 0x9C), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_8_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x10, 0xDE, 0xF9, 0x88, 0x87, 0x7B, 0xEB, 0xC9), - MBEDTLS_BYTES_TO_T_UINT_8(0x66, 0xB8, 0xDA, 0xFA, 0xDA, 0x3D, 0xA6, 0x17), - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0xF0, 0x62, 0x82, 0x53, 0x32, 0x55, 0x03), - MBEDTLS_BYTES_TO_T_UINT_8(0x2F, 0xA5, 0x32, 0x4A, 0x19, 0x11, 0x9C, 0x10), - MBEDTLS_BYTES_TO_T_UINT_8(0x16, 0xB3, 0x27, 0xE9, 0x75, 0x90, 0x05, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0x63, 0x1C, 0x90, 0x48, 0x77, 0x01, 0x85, 0x1B), - MBEDTLS_BYTES_TO_T_UINT_8(0xC7, 0xD6, 0x9B, 0x84, 0xA8, 0xD7, 0xC5, 0x28), - MBEDTLS_BYTES_TO_T_UINT_8(0xE1, 0x7A, 0xCB, 0xB3, 0x11, 0x46, 0xD7, 0x99), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_8_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x8B, 0x23, 0xBF, 0x75, 0x75, 0xA1, 0x95, 0x90), - MBEDTLS_BYTES_TO_T_UINT_8(0x4B, 0x66, 0x5D, 0x34, 0x13, 0xA9, 0x03, 0xBE), - MBEDTLS_BYTES_TO_T_UINT_8(0x29, 0x80, 0x9D, 0x5F, 0xD2, 0x44, 0xE1, 0x62), - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0x5D, 0xBD, 0xA8, 0xBF, 0xB4, 0x25, 0x1F), - MBEDTLS_BYTES_TO_T_UINT_8(0x6A, 0x99, 0x1F, 0x53, 0xF1, 0x57, 0xDB, 0xE7), - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0x7C, 0xE5, 0xC5, 0x51, 0x0B, 0x4C, 0x9B), - MBEDTLS_BYTES_TO_T_UINT_8(0x6B, 0xB0, 0x1A, 0x9C, 0x16, 0xB0, 0x32, 0x1F), - MBEDTLS_BYTES_TO_T_UINT_8(0xF4, 0xE3, 0xCF, 0xDD, 0x48, 0xB4, 0x7B, 0x33), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_9_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC0, 0xDD, 0x9E, 0x3C, 0x98, 0x0E, 0x77, 0x65), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0xAB, 0x01, 0xD3, 0x87, 0x74, 0x25, 0x4A), - MBEDTLS_BYTES_TO_T_UINT_8(0x87, 0xA3, 0xE3, 0x76, 0x43, 0x87, 0x12, 0xBD), - MBEDTLS_BYTES_TO_T_UINT_8(0x54, 0xB1, 0x3B, 0x60, 0x66, 0xEB, 0x98, 0x54), - MBEDTLS_BYTES_TO_T_UINT_8(0xD2, 0x78, 0xC8, 0xD7, 0x4E, 0x75, 0xCA, 0x69), - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0xDF, 0x71, 0x19, 0xE7, 0x07, 0x36, 0xB5), - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0xC9, 0xA8, 0x5F, 0x91, 0xBF, 0x47, 0xB2), - MBEDTLS_BYTES_TO_T_UINT_8(0x80, 0x96, 0x58, 0x96, 0x18, 0xB6, 0xFA, 0x01), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_9_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xD0, 0x2D, 0xA9, 0x9B, 0x86, 0xDB, 0x0C, 0x4C), - MBEDTLS_BYTES_TO_T_UINT_8(0xE4, 0x0B, 0x2D, 0x56, 0x4A, 0xD3, 0x93, 0x8A), - MBEDTLS_BYTES_TO_T_UINT_8(0xB5, 0x15, 0xE2, 0x65, 0x12, 0x86, 0x0E, 0xB2), - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0x41, 0x4D, 0xC1, 0xCB, 0xE4, 0xC3, 0xD7), - MBEDTLS_BYTES_TO_T_UINT_8(0x6A, 0x53, 0x10, 0xCA, 0xA3, 0xAC, 0x83, 0x26), - MBEDTLS_BYTES_TO_T_UINT_8(0x3E, 0x01, 0x22, 0x96, 0x10, 0xAD, 0x69, 0xDB), - MBEDTLS_BYTES_TO_T_UINT_8(0x42, 0x46, 0x4E, 0xD8, 0xEA, 0xD6, 0x9D, 0xF3), - MBEDTLS_BYTES_TO_T_UINT_8(0x43, 0x2F, 0x7F, 0x62, 0x62, 0x80, 0xD0, 0x14), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_10_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB2, 0xDA, 0x00, 0x63, 0x09, 0xBD, 0x6A, 0x83), - MBEDTLS_BYTES_TO_T_UINT_8(0x0F, 0xD4, 0x6E, 0x48, 0x05, 0xB7, 0xF7, 0x17), - MBEDTLS_BYTES_TO_T_UINT_8(0x14, 0x4D, 0xD7, 0x00, 0x4A, 0x15, 0x27, 0x7A), - MBEDTLS_BYTES_TO_T_UINT_8(0x3A, 0x15, 0xAA, 0x37, 0x27, 0x34, 0x18, 0x24), - MBEDTLS_BYTES_TO_T_UINT_8(0x3A, 0x20, 0x2C, 0x84, 0x1B, 0x88, 0xBA, 0x05), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0x09, 0xD6, 0x04, 0xA2, 0x60, 0x84, 0x72), - MBEDTLS_BYTES_TO_T_UINT_8(0xC8, 0x04, 0x94, 0x08, 0xD4, 0xED, 0x47, 0xDB), - MBEDTLS_BYTES_TO_T_UINT_8(0x8B, 0xF3, 0xE4, 0x3E, 0xB9, 0x5B, 0x35, 0x42), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_10_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x5F, 0xD8, 0xB6, 0x80, 0xD6, 0xF1, 0x30, 0xDD), - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0x14, 0xA6, 0x85, 0xEE, 0xA7, 0xD8, 0x61), - MBEDTLS_BYTES_TO_T_UINT_8(0xE4, 0x49, 0x2A, 0x1E, 0x7C, 0xE9, 0x2D, 0xEC), - MBEDTLS_BYTES_TO_T_UINT_8(0x3A, 0x87, 0x56, 0x91, 0x03, 0x77, 0x4D, 0x55), - MBEDTLS_BYTES_TO_T_UINT_8(0x0E, 0x52, 0xD4, 0xAA, 0xF7, 0xFA, 0xB0, 0xC5), - MBEDTLS_BYTES_TO_T_UINT_8(0x04, 0x5D, 0x11, 0x39, 0xB1, 0xE7, 0x76, 0xAD), - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0x13, 0xBC, 0x37, 0x5D, 0x74, 0xCD, 0xC2), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x48, 0x14, 0x23, 0x30, 0xF8, 0x46, 0x37), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_11_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0x27, 0xB0, 0xD9, 0xB2, 0x74, 0xB4, 0xC0), - MBEDTLS_BYTES_TO_T_UINT_8(0xEA, 0xA6, 0xB9, 0x6F, 0x9F, 0x64, 0x36, 0x92), - MBEDTLS_BYTES_TO_T_UINT_8(0x2E, 0x2B, 0x78, 0x40, 0x05, 0x2B, 0x7B, 0xA9), - MBEDTLS_BYTES_TO_T_UINT_8(0xB3, 0x68, 0x3A, 0xB6, 0x4A, 0xE2, 0xDB, 0xB8), - MBEDTLS_BYTES_TO_T_UINT_8(0x1E, 0x33, 0xD7, 0x34, 0x8B, 0x25, 0x45, 0xEF), - MBEDTLS_BYTES_TO_T_UINT_8(0x89, 0xCE, 0xA8, 0xC9, 0x01, 0xFB, 0x0E, 0x7B), - MBEDTLS_BYTES_TO_T_UINT_8(0xE2, 0xF9, 0x51, 0x4C, 0x12, 0x9F, 0x60, 0xE4), - MBEDTLS_BYTES_TO_T_UINT_8(0x67, 0x85, 0xBD, 0x30, 0x37, 0x84, 0x39, 0x44), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_11_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x26, 0x33, 0xAF, 0x2E, 0xB8, 0x2E, 0xCC, 0x3C), - MBEDTLS_BYTES_TO_T_UINT_8(0xA4, 0xB1, 0x73, 0x59, 0x4E, 0x0C, 0x09, 0x4A), - MBEDTLS_BYTES_TO_T_UINT_8(0x8A, 0x24, 0x89, 0x81, 0x12, 0xFF, 0xBB, 0x6E), - MBEDTLS_BYTES_TO_T_UINT_8(0x71, 0x37, 0x1A, 0x66, 0xEE, 0xED, 0xB6, 0x9B), - MBEDTLS_BYTES_TO_T_UINT_8(0x16, 0xBD, 0x04, 0x20, 0x5D, 0xFB, 0xBF, 0x95), - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0xF8, 0x34, 0xA3, 0xFF, 0x45, 0xDE, 0x92), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0x18, 0x73, 0xF1, 0x32, 0x25, 0x58, 0xEB), - MBEDTLS_BYTES_TO_T_UINT_8(0x63, 0xC1, 0x14, 0xE3, 0x9E, 0x40, 0x0F, 0x12), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_12_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0x07, 0x9D, 0x9C, 0x00, 0xF7, 0x56, 0x19), - MBEDTLS_BYTES_TO_T_UINT_8(0xFB, 0xBA, 0x87, 0xF9, 0x15, 0x0C, 0x66, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0x7E, 0x1F, 0xC1, 0x28, 0xB0, 0x47, 0x0D, 0xF5), - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0xCA, 0x27, 0xEE, 0x4B, 0x23, 0x2B, 0x89), - MBEDTLS_BYTES_TO_T_UINT_8(0x7E, 0xB5, 0x68, 0xC8, 0x17, 0x5D, 0xC3, 0xAA), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0x02, 0x08, 0xEE, 0x20, 0x9D, 0xEA, 0x64), - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0x14, 0x50, 0xD4, 0x7D, 0x5F, 0xCF, 0xA0), - MBEDTLS_BYTES_TO_T_UINT_8(0xD5, 0xFA, 0xF8, 0xA7, 0xC6, 0xDC, 0x14, 0x8C), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_12_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x76, 0xBD, 0x0A, 0x1A, 0x18, 0x98, 0xDC, 0xB0), - MBEDTLS_BYTES_TO_T_UINT_8(0x63, 0x63, 0x02, 0xB7, 0xD5, 0x5B, 0x5A, 0xC6), - MBEDTLS_BYTES_TO_T_UINT_8(0x51, 0xB1, 0xD7, 0x4B, 0x15, 0x39, 0x61, 0x5D), - MBEDTLS_BYTES_TO_T_UINT_8(0x5C, 0x32, 0xE1, 0x9E, 0x70, 0x1B, 0xCE, 0x51), - MBEDTLS_BYTES_TO_T_UINT_8(0x64, 0xD8, 0x18, 0x83, 0x52, 0x9B, 0x6D, 0xA2), - MBEDTLS_BYTES_TO_T_UINT_8(0xA4, 0x55, 0x56, 0x19, 0x34, 0xA4, 0xEA, 0xFC), - MBEDTLS_BYTES_TO_T_UINT_8(0x30, 0xA9, 0x55, 0x80, 0xE3, 0x15, 0x36, 0x8B), - MBEDTLS_BYTES_TO_T_UINT_8(0xBB, 0x06, 0xC8, 0x1D, 0x17, 0x0D, 0xAD, 0x16), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_13_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x20, 0xD6, 0xF0, 0xCC, 0xF3, 0x63, 0x53, 0xD2), - MBEDTLS_BYTES_TO_T_UINT_8(0x27, 0x5A, 0xDC, 0x46, 0xBD, 0x0D, 0xAD, 0x96), - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0x2F, 0x11, 0x60, 0x15, 0x51, 0x4A, 0xEA), - MBEDTLS_BYTES_TO_T_UINT_8(0x33, 0xE3, 0x93, 0x38, 0xD5, 0x83, 0xAA, 0x0D), - MBEDTLS_BYTES_TO_T_UINT_8(0x90, 0xA6, 0xCC, 0xB1, 0xFD, 0xBB, 0x1A, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0x3B, 0x54, 0xC8, 0x54, 0x6F, 0x79, 0x1A, 0x59), - MBEDTLS_BYTES_TO_T_UINT_8(0x3F, 0x4A, 0xDA, 0x28, 0x92, 0x97, 0x9D, 0x7F), - MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0x4B, 0xDB, 0xC7, 0x52, 0xC5, 0x66, 0x34), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_13_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x05, 0x7E, 0x92, 0x53, 0x30, 0x93, 0xFD, 0xFF), - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0x16, 0x6A, 0xB1, 0x91, 0x0A, 0xB4, 0x52), - MBEDTLS_BYTES_TO_T_UINT_8(0x6D, 0x9D, 0x40, 0x3F, 0xE3, 0xF1, 0x01, 0x46), - MBEDTLS_BYTES_TO_T_UINT_8(0x13, 0x0E, 0xD8, 0xED, 0x11, 0x8E, 0x4C, 0xED), - MBEDTLS_BYTES_TO_T_UINT_8(0x86, 0x4A, 0x1B, 0x88, 0xDF, 0x8D, 0x29, 0xE7), - MBEDTLS_BYTES_TO_T_UINT_8(0x97, 0x23, 0x21, 0x11, 0xAB, 0x77, 0x81, 0x62), - MBEDTLS_BYTES_TO_T_UINT_8(0x0B, 0xAF, 0x11, 0xFA, 0xBA, 0x40, 0x63, 0xE7), - MBEDTLS_BYTES_TO_T_UINT_8(0x2B, 0x6F, 0x8D, 0x80, 0xDF, 0x67, 0xF5, 0x44), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_14_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB2, 0x8B, 0xB7, 0x08, 0xF4, 0xD7, 0x2D, 0xA8), - MBEDTLS_BYTES_TO_T_UINT_8(0xC7, 0x2B, 0x30, 0x02, 0x45, 0x71, 0x08, 0x49), - MBEDTLS_BYTES_TO_T_UINT_8(0x97, 0x3A, 0xCA, 0x50, 0xF6, 0xC2, 0x19, 0x8C), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0xB9, 0x9B, 0x3E, 0x73, 0x95, 0x1D, 0x49), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x60, 0x59, 0x48, 0xCB, 0xD8, 0xD6, 0xAA), - MBEDTLS_BYTES_TO_T_UINT_8(0xF0, 0xB9, 0x6C, 0x89, 0xAB, 0x99, 0xA8, 0xF8), - MBEDTLS_BYTES_TO_T_UINT_8(0xEF, 0xA1, 0x8B, 0x4E, 0x06, 0x19, 0xEC, 0x99), - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0x95, 0x04, 0xCF, 0xD5, 0x94, 0xB3, 0x02), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_14_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x29, 0x35, 0x93, 0x7C, 0xB3, 0xB8, 0x9E, 0x1B), - MBEDTLS_BYTES_TO_T_UINT_8(0xC4, 0x45, 0x5C, 0x7E, 0xBF, 0x75, 0x81, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0xDC, 0xE8, 0x24, 0xDF, 0xEC, 0x2F, 0x7D, 0xB9), - MBEDTLS_BYTES_TO_T_UINT_8(0xF2, 0x8B, 0xD5, 0x6A, 0x9B, 0xA0, 0xE0, 0x4F), - MBEDTLS_BYTES_TO_T_UINT_8(0x32, 0xE3, 0x27, 0x82, 0xDE, 0xDD, 0xCA, 0x4B), - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0x57, 0x56, 0x46, 0x05, 0x06, 0x01, 0x2E), - MBEDTLS_BYTES_TO_T_UINT_8(0x74, 0x35, 0xA7, 0x47, 0xE2, 0x6B, 0x2C, 0x4F), - MBEDTLS_BYTES_TO_T_UINT_8(0x38, 0x9D, 0x4C, 0xEC, 0x1F, 0x11, 0x75, 0x2B), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_15_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0xAA, 0x41, 0xC1, 0xE9, 0x0E, 0xE9, 0xAA), - MBEDTLS_BYTES_TO_T_UINT_8(0x0A, 0xCF, 0x9C, 0x4B, 0xE8, 0xED, 0x0A, 0x49), - MBEDTLS_BYTES_TO_T_UINT_8(0x3D, 0x73, 0xCA, 0x0C, 0x46, 0x0A, 0x9C, 0xE4), - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0xE1, 0x9E, 0xBC, 0xFE, 0x44, 0x63, 0x6D), - MBEDTLS_BYTES_TO_T_UINT_8(0x31, 0x43, 0x71, 0xEE, 0xF8, 0xC1, 0x8C, 0x5C), - MBEDTLS_BYTES_TO_T_UINT_8(0x6A, 0x4B, 0xF0, 0x69, 0x25, 0xBD, 0x71, 0x1A), - MBEDTLS_BYTES_TO_T_UINT_8(0xFD, 0x9A, 0xFE, 0x82, 0xE7, 0xC1, 0xC1, 0xEE), - MBEDTLS_BYTES_TO_T_UINT_8(0xFC, 0x5A, 0x6E, 0x5E, 0x97, 0x6A, 0x35, 0x8D), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_15_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA2, 0x18, 0x6C, 0x7E, 0xB8, 0x9E, 0x57, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0x35, 0xB9, 0xC1, 0xD0, 0xFE, 0x78, 0xFB, 0x32), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0x08, 0xAE, 0x46, 0x34, 0xEA, 0x7A, 0x7F), - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0x1C, 0x56, 0xA9, 0x18, 0x37, 0xD4, 0x9E), - MBEDTLS_BYTES_TO_T_UINT_8(0x28, 0x63, 0xE9, 0x0A, 0xB6, 0x38, 0x3C, 0xC1), - MBEDTLS_BYTES_TO_T_UINT_8(0x3E, 0x4F, 0xA4, 0x6E, 0x85, 0x31, 0x23, 0x52), - MBEDTLS_BYTES_TO_T_UINT_8(0x0D, 0xAD, 0xC4, 0xC3, 0xB1, 0x4B, 0x1C, 0x82), - MBEDTLS_BYTES_TO_T_UINT_8(0x30, 0x56, 0x4A, 0x38, 0xB3, 0x6B, 0x6F, 0x2C), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_16_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x67, 0xC7, 0x19, 0xDE, 0x21, 0xED, 0x89, 0xD0), - MBEDTLS_BYTES_TO_T_UINT_8(0x2F, 0xBE, 0xA6, 0xAE, 0xEB, 0x9D, 0xA7, 0x2A), - MBEDTLS_BYTES_TO_T_UINT_8(0x04, 0x0E, 0x13, 0x1E, 0x86, 0x57, 0xC3, 0x3B), - MBEDTLS_BYTES_TO_T_UINT_8(0x1F, 0x4B, 0x30, 0x46, 0x52, 0xC1, 0xEC, 0x52), - MBEDTLS_BYTES_TO_T_UINT_8(0x6E, 0xD5, 0x44, 0x31, 0x96, 0x3B, 0x26, 0x27), - MBEDTLS_BYTES_TO_T_UINT_8(0x77, 0x68, 0xA8, 0x67, 0x78, 0x39, 0xE8, 0x68), - MBEDTLS_BYTES_TO_T_UINT_8(0x8E, 0x78, 0xB7, 0xDD, 0xF2, 0x58, 0xB6, 0x3D), - MBEDTLS_BYTES_TO_T_UINT_8(0x81, 0x3C, 0xB3, 0x26, 0xC4, 0x2C, 0x8C, 0xA5), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_16_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB9, 0x24, 0xE5, 0x73, 0xEE, 0x9A, 0x02, 0xA9), - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0x6A, 0x65, 0x60, 0xF3, 0x62, 0xE3, 0xE9), - MBEDTLS_BYTES_TO_T_UINT_8(0xFB, 0x07, 0x84, 0xE6, 0x3B, 0x46, 0x65, 0x9F), - MBEDTLS_BYTES_TO_T_UINT_8(0xE1, 0x8F, 0x0C, 0xB0, 0xE1, 0x04, 0x82, 0x9D), - MBEDTLS_BYTES_TO_T_UINT_8(0xEB, 0x13, 0xBF, 0x3D, 0xA0, 0x48, 0xA2, 0x74), - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0x26, 0x76, 0x74, 0xAB, 0x0B, 0x29, 0xE8), - MBEDTLS_BYTES_TO_T_UINT_8(0x30, 0x6E, 0x5F, 0x03, 0x34, 0x7C, 0x38, 0xCE), - MBEDTLS_BYTES_TO_T_UINT_8(0x4D, 0x72, 0xF9, 0x3B, 0x3C, 0xA4, 0xBC, 0x7C), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_17_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x5C, 0xCE, 0x18, 0x80, 0xB8, 0x24, 0x45, 0x81), - MBEDTLS_BYTES_TO_T_UINT_8(0xF1, 0x09, 0x03, 0xB8, 0x06, 0x64, 0xF7, 0xEC), - MBEDTLS_BYTES_TO_T_UINT_8(0xF1, 0x26, 0xB1, 0x10, 0x6D, 0x71, 0x12, 0x2E), - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0x12, 0xC6, 0x6E, 0x1E, 0x6A, 0xC3, 0x80), - MBEDTLS_BYTES_TO_T_UINT_8(0xE5, 0xD3, 0x0A, 0xDE, 0xD8, 0x6B, 0x04, 0x5C), - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0x87, 0x5B, 0xAE, 0xDB, 0x3C, 0xC0, 0xC5), - MBEDTLS_BYTES_TO_T_UINT_8(0x8E, 0xF5, 0xF9, 0xC1, 0x9A, 0x89, 0xBB, 0x7E), - MBEDTLS_BYTES_TO_T_UINT_8(0xED, 0x69, 0x72, 0x8B, 0xAE, 0x32, 0x13, 0x11), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_17_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF9, 0x16, 0x07, 0x50, 0xFA, 0x4C, 0xCF, 0xE8), - MBEDTLS_BYTES_TO_T_UINT_8(0xF8, 0x50, 0x21, 0xE9, 0xDE, 0xEC, 0x7E, 0xDF), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0x2F, 0xE8, 0x83, 0x30, 0x0B, 0x65, 0x0E), - MBEDTLS_BYTES_TO_T_UINT_8(0xA5, 0x0B, 0x99, 0xAC, 0xC9, 0xBA, 0x6C, 0x2A), - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0x59, 0x5A, 0x0D, 0x7B, 0x9E, 0x08, 0xAD), - MBEDTLS_BYTES_TO_T_UINT_8(0x34, 0x91, 0xB2, 0xDC, 0x90, 0xCE, 0x67, 0xED), - MBEDTLS_BYTES_TO_T_UINT_8(0xE3, 0x93, 0x60, 0x0C, 0xD7, 0x1F, 0x2F, 0x17), - MBEDTLS_BYTES_TO_T_UINT_8(0x19, 0x7F, 0x9D, 0x40, 0xF8, 0x78, 0x7A, 0x54), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_18_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x13, 0x22, 0x95, 0xE8, 0xEF, 0x31, 0x57, 0x35), - MBEDTLS_BYTES_TO_T_UINT_8(0x2D, 0x88, 0x53, 0xFE, 0xAF, 0x7C, 0x47, 0x14), - MBEDTLS_BYTES_TO_T_UINT_8(0x0E, 0xCE, 0xCC, 0x79, 0xE8, 0x9F, 0x8C, 0xC4), - MBEDTLS_BYTES_TO_T_UINT_8(0xDB, 0x16, 0xDD, 0x77, 0x6E, 0x8A, 0x73, 0x97), - MBEDTLS_BYTES_TO_T_UINT_8(0xC0, 0x07, 0x97, 0x21, 0x3B, 0xF8, 0x5F, 0xA8), - MBEDTLS_BYTES_TO_T_UINT_8(0xC6, 0xB5, 0xD2, 0x81, 0x84, 0xF0, 0xE7, 0x9F), - MBEDTLS_BYTES_TO_T_UINT_8(0xCB, 0x8F, 0x75, 0x09, 0x6A, 0x0E, 0x53, 0xAD), - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0x4F, 0x70, 0x97, 0xC7, 0xAC, 0x7D, 0x3F), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_18_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF9, 0x3C, 0x6A, 0xB4, 0x10, 0xA9, 0xC8, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0xEE, 0xC5, 0xD6, 0x69, 0x16, 0xB8, 0xAC, 0x25), - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0x44, 0xDC, 0xEB, 0x48, 0x54, 0x5D, 0x5F), - MBEDTLS_BYTES_TO_T_UINT_8(0x6F, 0x48, 0x9B, 0xD7, 0x72, 0x69, 0xA4, 0x8A), - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0x0D, 0x36, 0x9A, 0x66, 0x0B, 0xEC, 0x24), - MBEDTLS_BYTES_TO_T_UINT_8(0xBE, 0xC6, 0xD4, 0xB6, 0x60, 0xE5, 0xC3, 0x3A), - MBEDTLS_BYTES_TO_T_UINT_8(0xBA, 0x29, 0x42, 0xE0, 0x9D, 0xFD, 0x7C, 0x3E), - MBEDTLS_BYTES_TO_T_UINT_8(0x43, 0x10, 0xBA, 0x55, 0xBC, 0x3B, 0x38, 0x5D), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_19_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x25, 0x66, 0xFA, 0x05, 0x73, 0x03, 0x1B, 0x69), - MBEDTLS_BYTES_TO_T_UINT_8(0x11, 0xA4, 0x66, 0x12, 0x96, 0x7B, 0x02, 0x4C), - MBEDTLS_BYTES_TO_T_UINT_8(0x44, 0xB5, 0xDE, 0x6D, 0x98, 0xD1, 0xD5, 0xA8), - MBEDTLS_BYTES_TO_T_UINT_8(0xE2, 0xF5, 0x44, 0xB8, 0x8E, 0xF6, 0x8C, 0x05), - MBEDTLS_BYTES_TO_T_UINT_8(0x68, 0x15, 0x2B, 0x72, 0xBC, 0x49, 0xE5, 0xDF), - MBEDTLS_BYTES_TO_T_UINT_8(0x6C, 0x44, 0xD7, 0xDF, 0x8F, 0xEB, 0x8D, 0x80), - MBEDTLS_BYTES_TO_T_UINT_8(0x05, 0x64, 0x88, 0xAA, 0xB7, 0xE4, 0x70, 0x1D), - MBEDTLS_BYTES_TO_T_UINT_8(0x9C, 0x14, 0xBB, 0xE9, 0x9B, 0xB9, 0x65, 0x5D), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_19_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x66, 0x8E, 0x88, 0xF5, 0xF1, 0xC1, 0x89, 0xA2), - MBEDTLS_BYTES_TO_T_UINT_8(0x16, 0x30, 0x53, 0xE6, 0xFB, 0x2D, 0x82, 0xB4), - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0xE4, 0xFF, 0xBA, 0x31, 0x79, 0xAB, 0xC2), - MBEDTLS_BYTES_TO_T_UINT_8(0x45, 0x09, 0xF7, 0xB7, 0x09, 0x78, 0x4C, 0x90), - MBEDTLS_BYTES_TO_T_UINT_8(0x10, 0xAE, 0xC2, 0x44, 0xDC, 0x17, 0x78, 0x47), - MBEDTLS_BYTES_TO_T_UINT_8(0xC7, 0xD4, 0x17, 0x43, 0x19, 0x74, 0x9E, 0x23), - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x64, 0x3B, 0x73, 0xA2, 0x99, 0x27, 0x76), - MBEDTLS_BYTES_TO_T_UINT_8(0x05, 0x74, 0x36, 0x5F, 0xD3, 0x14, 0xB1, 0x31), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_20_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xAC, 0x07, 0xAB, 0xFD, 0x9B, 0x03, 0xC5, 0xD5), - MBEDTLS_BYTES_TO_T_UINT_8(0xC7, 0xBE, 0xB0, 0x1D, 0xF2, 0x0C, 0x73, 0x73), - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0xE7, 0x7B, 0x87, 0xD3, 0x34, 0xFD, 0xE2), - MBEDTLS_BYTES_TO_T_UINT_8(0x9A, 0x25, 0x3D, 0xC7, 0x36, 0x83, 0x53, 0xDC), - MBEDTLS_BYTES_TO_T_UINT_8(0x22, 0x7C, 0xCF, 0x63, 0x55, 0x12, 0x11, 0xB0), - MBEDTLS_BYTES_TO_T_UINT_8(0xC0, 0x34, 0x4D, 0x27, 0x92, 0xAC, 0x18, 0x16), - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0x42, 0x61, 0x9D, 0x2E, 0xFF, 0x13, 0x16), - MBEDTLS_BYTES_TO_T_UINT_8(0xF4, 0xDE, 0x92, 0x65, 0x57, 0x0D, 0xBC, 0x0A), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_20_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xEF, 0x7B, 0x6E, 0xC6, 0x2A, 0x21, 0x74, 0x0A), - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0xA7, 0x53, 0x4D, 0x29, 0x36, 0xEF, 0xE5), - MBEDTLS_BYTES_TO_T_UINT_8(0xE1, 0xD6, 0x41, 0xC7, 0x99, 0xAD, 0x50, 0x53), - MBEDTLS_BYTES_TO_T_UINT_8(0x99, 0xAC, 0x41, 0x9F, 0xFB, 0x4C, 0x86, 0xF1), - MBEDTLS_BYTES_TO_T_UINT_8(0x8B, 0xBB, 0xE6, 0x25, 0x28, 0xAA, 0xEB, 0x1E), - MBEDTLS_BYTES_TO_T_UINT_8(0x92, 0x04, 0xA2, 0xC3, 0xAA, 0x08, 0x8A, 0xCC), - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0x2B, 0x5B, 0xE2, 0x8D, 0x76, 0xEA, 0x34), - MBEDTLS_BYTES_TO_T_UINT_8(0xB3, 0x33, 0xD2, 0x21, 0x4D, 0x62, 0xE3, 0x8E), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_21_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xF6, 0x06, 0x8B, 0x2B, 0xC2, 0xC4, 0xB1, 0xD2), - MBEDTLS_BYTES_TO_T_UINT_8(0xFA, 0xF5, 0xA1, 0xC0, 0x03, 0x6A, 0x29, 0x12), - MBEDTLS_BYTES_TO_T_UINT_8(0xF5, 0xA9, 0xEF, 0x55, 0xB6, 0x1A, 0x9F, 0x6B), - MBEDTLS_BYTES_TO_T_UINT_8(0x9B, 0x54, 0x32, 0xBE, 0x06, 0x43, 0xB5, 0xFD), - MBEDTLS_BYTES_TO_T_UINT_8(0xF7, 0xD6, 0xD9, 0x20, 0x89, 0xBE, 0xD4, 0x1B), - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0x26, 0x95, 0x10, 0xCE, 0xB4, 0x88, 0x79), - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0xA6, 0x27, 0xAC, 0x32, 0xBA, 0xBD, 0xC7), - MBEDTLS_BYTES_TO_T_UINT_8(0xA3, 0xA6, 0xAE, 0x9C, 0x7B, 0xBE, 0xA1, 0x63), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_21_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x8B, 0xCD, 0x4D, 0x3D, 0xDF, 0x96, 0xBB, 0x7D), - MBEDTLS_BYTES_TO_T_UINT_8(0x77, 0xA7, 0x11, 0x06, 0xCC, 0x0E, 0x31, 0x81), - MBEDTLS_BYTES_TO_T_UINT_8(0x20, 0xE4, 0xF4, 0xAD, 0x7B, 0x5F, 0xF1, 0xEF), - MBEDTLS_BYTES_TO_T_UINT_8(0xE4, 0x54, 0xBE, 0xF4, 0x8A, 0x03, 0x47, 0xDF), - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0x53, 0x00, 0x7F, 0xB0, 0x8A, 0x68, 0xA6), - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0x16, 0xB1, 0x73, 0x6F, 0x5B, 0x0E, 0xC3), - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0x32, 0xE3, 0x43, 0x64, 0x75, 0xFB, 0xFB), - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0x18, 0x55, 0x8A, 0x4E, 0x6E, 0x35, 0x54), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_22_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x80, 0x97, 0x15, 0x1E, 0xCB, 0xF2, 0x9C, 0xA5), - MBEDTLS_BYTES_TO_T_UINT_8(0x2B, 0xD1, 0xBB, 0xF3, 0x70, 0xAD, 0x13, 0xAD), - MBEDTLS_BYTES_TO_T_UINT_8(0xD8, 0x96, 0xA4, 0xC5, 0x5E, 0xDA, 0xD5, 0x57), - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0x81, 0xE9, 0x65, 0x66, 0x76, 0x47, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x35, 0x87, 0x06, 0x73, 0xCF, 0x34, 0xD2), - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0x81, 0x15, 0x42, 0xA2, 0x79, 0x5B, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0x08, 0xA2, 0x7D, 0x09, 0x14, 0x64, 0xC6, 0xAE), - MBEDTLS_BYTES_TO_T_UINT_8(0x5E, 0x6D, 0xC4, 0xED, 0xF1, 0xD6, 0xE9, 0x24), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_22_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xB4, 0xD5, 0xBB, 0x25, 0xA3, 0xDD, 0xA3, 0x88), - MBEDTLS_BYTES_TO_T_UINT_8(0x46, 0xF2, 0x68, 0x67, 0x39, 0x8F, 0x73, 0x93), - MBEDTLS_BYTES_TO_T_UINT_8(0xF0, 0x76, 0x28, 0x89, 0xAD, 0x32, 0xE0, 0xDF), - MBEDTLS_BYTES_TO_T_UINT_8(0xF8, 0x90, 0xCC, 0x57, 0x58, 0xAA, 0xC9, 0x75), - MBEDTLS_BYTES_TO_T_UINT_8(0x5E, 0xD7, 0x43, 0xD2, 0xCE, 0x5E, 0xA0, 0x08), - MBEDTLS_BYTES_TO_T_UINT_8(0x33, 0xB0, 0xB8, 0xA4, 0x9E, 0x96, 0x26, 0x86), - MBEDTLS_BYTES_TO_T_UINT_8(0x94, 0x61, 0x1D, 0xF3, 0x65, 0x5E, 0x60, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0xC7, 0x1E, 0x65, 0xED, 0xCF, 0x07, 0x60, 0x20), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_23_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA4, 0x30, 0x17, 0x8A, 0x91, 0x88, 0x0A, 0xA4), - MBEDTLS_BYTES_TO_T_UINT_8(0x05, 0x7D, 0x18, 0xA4, 0xAC, 0x59, 0xFC, 0x5F), - MBEDTLS_BYTES_TO_T_UINT_8(0xA4, 0x31, 0x8B, 0x25, 0x65, 0x39, 0x9A, 0xDC), - MBEDTLS_BYTES_TO_T_UINT_8(0x15, 0x16, 0x4B, 0x68, 0xBA, 0x59, 0x13, 0x2F), - MBEDTLS_BYTES_TO_T_UINT_8(0x8D, 0xFD, 0xD3, 0xC5, 0x56, 0xC9, 0x8C, 0x5E), - MBEDTLS_BYTES_TO_T_UINT_8(0xBC, 0xC6, 0x9F, 0xF4, 0xE6, 0xF7, 0xB4, 0x01), - MBEDTLS_BYTES_TO_T_UINT_8(0x2D, 0x7C, 0x03, 0x00, 0x26, 0x9F, 0xD8, 0x7B), - MBEDTLS_BYTES_TO_T_UINT_8(0x24, 0x1D, 0x6E, 0x00, 0xB9, 0x00, 0x6E, 0x93), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_23_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x75, 0x63, 0xDA, 0x03, 0x2B, 0xD5, 0x0B, 0xFE), - MBEDTLS_BYTES_TO_T_UINT_8(0x46, 0xFC, 0xE2, 0xC8, 0x47, 0xF0, 0xAE, 0xF2), - MBEDTLS_BYTES_TO_T_UINT_8(0x51, 0x4C, 0xF7, 0x50, 0x0C, 0x48, 0x06, 0x2A), - MBEDTLS_BYTES_TO_T_UINT_8(0xDF, 0x2B, 0x32, 0x98, 0x0E, 0x7E, 0x61, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0x02, 0x27, 0xFE, 0x75, 0x86, 0xDF, 0x24), - MBEDTLS_BYTES_TO_T_UINT_8(0x2B, 0x30, 0xB1, 0x22, 0x32, 0x1B, 0xFE, 0x24), - MBEDTLS_BYTES_TO_T_UINT_8(0xC2, 0x27, 0xF7, 0x78, 0x6F, 0xD7, 0xFD, 0xE4), - MBEDTLS_BYTES_TO_T_UINT_8(0xA0, 0x78, 0xCC, 0xEA, 0xC0, 0x50, 0x24, 0x44), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_24_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0x2B, 0x4F, 0x7F, 0x58, 0xE6, 0xC2, 0x70), - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0x43, 0xD5, 0xA7, 0x35, 0x3C, 0x80, 0xB8), - MBEDTLS_BYTES_TO_T_UINT_8(0x1A, 0x6D, 0x4B, 0x12, 0x00, 0x7B, 0xE6, 0xA6), - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0x15, 0xBD, 0xD0, 0x9B, 0xCA, 0xAA, 0x81), - MBEDTLS_BYTES_TO_T_UINT_8(0xCF, 0xCE, 0x9C, 0xE3, 0x8B, 0x60, 0x7A, 0x53), - MBEDTLS_BYTES_TO_T_UINT_8(0x0C, 0xDA, 0x4B, 0x03, 0xA7, 0x8D, 0x43, 0x22), - MBEDTLS_BYTES_TO_T_UINT_8(0x57, 0xAF, 0x00, 0x2B, 0x32, 0xF0, 0x22, 0x68), - MBEDTLS_BYTES_TO_T_UINT_8(0xDC, 0xD9, 0x99, 0x99, 0xBE, 0x43, 0x99, 0x3E), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_24_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x1F, 0x71, 0x41, 0xF4, 0xB5, 0xFD, 0xDD, 0x36), - MBEDTLS_BYTES_TO_T_UINT_8(0x9D, 0xE2, 0x20, 0x4C, 0xD1, 0x2E, 0x1F, 0x06), - MBEDTLS_BYTES_TO_T_UINT_8(0x96, 0x43, 0x48, 0x76, 0x8A, 0x49, 0xAC, 0x87), - MBEDTLS_BYTES_TO_T_UINT_8(0x0C, 0x1A, 0x55, 0xA8, 0xA3, 0xD4, 0x57, 0x75), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0xA6, 0x84, 0x39, 0xC9, 0x13, 0xBB, 0x60), - MBEDTLS_BYTES_TO_T_UINT_8(0xD9, 0xFA, 0xA9, 0x70, 0xDE, 0x83, 0xDD, 0xC9), - MBEDTLS_BYTES_TO_T_UINT_8(0xEC, 0xC9, 0xD9, 0x3E, 0x44, 0x91, 0x68, 0x7B), - MBEDTLS_BYTES_TO_T_UINT_8(0xB6, 0x9F, 0x85, 0x6D, 0xF7, 0x54, 0x36, 0x82), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_25_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x68, 0x6B, 0xA6, 0xA3, 0xE5, 0xD4, 0x46, 0xDB), - MBEDTLS_BYTES_TO_T_UINT_8(0x23, 0x3E, 0xDC, 0x84, 0x7C, 0x7B, 0x24, 0x34), - MBEDTLS_BYTES_TO_T_UINT_8(0x14, 0xED, 0x7F, 0x86, 0x07, 0x6C, 0x57, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0x95, 0x06, 0xFE, 0x52, 0x12, 0x79, 0x69, 0x56), - MBEDTLS_BYTES_TO_T_UINT_8(0x84, 0xD1, 0x44, 0x5F, 0x21, 0x3A, 0xC3, 0x84), - MBEDTLS_BYTES_TO_T_UINT_8(0x5E, 0xD9, 0x4A, 0xC0, 0x75, 0xAB, 0x17, 0xAC), - MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0x81, 0x94, 0xB6, 0x80, 0x6B, 0x6F, 0xC3), - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0xBE, 0x8E, 0xA5, 0xAA, 0xBC, 0x1E, 0x3E), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_25_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x89, 0xC7, 0x85, 0xA6, 0x59, 0x9B, 0xB1, 0x52), - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0xCE, 0x40, 0xD1, 0xFB, 0xDF, 0x94, 0xF7), - MBEDTLS_BYTES_TO_T_UINT_8(0x18, 0xB8, 0x5E, 0xBF, 0x45, 0xA8, 0x2D, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0x98, 0x9C, 0x06, 0x1B, 0xA9, 0x57, 0xB9, 0x79), - MBEDTLS_BYTES_TO_T_UINT_8(0x53, 0xE9, 0xCE, 0xA2, 0xD3, 0x74, 0xA1, 0x3C), - MBEDTLS_BYTES_TO_T_UINT_8(0xAA, 0x5F, 0x34, 0x78, 0xDB, 0xAE, 0x3A, 0x14), - MBEDTLS_BYTES_TO_T_UINT_8(0x7D, 0x32, 0x84, 0x3E, 0x68, 0x6A, 0x43, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0x8C, 0xBC, 0x39, 0x36, 0xA4, 0xC5, 0xBB, 0x11), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_26_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x8C, 0x07, 0xA2, 0xB5, 0xC9, 0x0F, 0x4D, 0x0F), - MBEDTLS_BYTES_TO_T_UINT_8(0xE3, 0x1D, 0x67, 0xE6, 0xF1, 0x46, 0xEB, 0x71), - MBEDTLS_BYTES_TO_T_UINT_8(0xD7, 0x41, 0x23, 0x95, 0xE7, 0xE0, 0x10, 0xDD), - MBEDTLS_BYTES_TO_T_UINT_8(0xBE, 0x69, 0xFE, 0x68, 0x8C, 0xC6, 0x5F, 0xB6), - MBEDTLS_BYTES_TO_T_UINT_8(0xE3, 0xB9, 0x2B, 0x3D, 0xD2, 0x4F, 0xD8, 0x1A), - MBEDTLS_BYTES_TO_T_UINT_8(0xA3, 0x09, 0xF5, 0x5F, 0xCF, 0xF6, 0x91, 0x57), - MBEDTLS_BYTES_TO_T_UINT_8(0x65, 0x15, 0x42, 0x6B, 0x6D, 0xB5, 0xF3, 0xB6), - MBEDTLS_BYTES_TO_T_UINT_8(0xBF, 0x56, 0x9D, 0xC5, 0xFF, 0xCA, 0x13, 0x9B), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_26_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x4D, 0x38, 0xE6, 0x23, 0x63, 0x48, 0x3C, 0xCA), - MBEDTLS_BYTES_TO_T_UINT_8(0xD2, 0x68, 0x3C, 0xD1, 0x3B, 0xE9, 0x3B, 0x82), - MBEDTLS_BYTES_TO_T_UINT_8(0xB5, 0x08, 0x54, 0x49, 0xD1, 0x46, 0x45, 0x13), - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0x70, 0x52, 0x6E, 0x79, 0xC4, 0x5E, 0x95), - MBEDTLS_BYTES_TO_T_UINT_8(0x36, 0xDF, 0xE8, 0x5A, 0x32, 0x81, 0xDA, 0xD3), - MBEDTLS_BYTES_TO_T_UINT_8(0x3C, 0x2D, 0x94, 0x5B, 0xB5, 0x35, 0x9F, 0x0A), - MBEDTLS_BYTES_TO_T_UINT_8(0x2A, 0x12, 0x8D, 0xC3, 0x36, 0x36, 0xB2, 0x2A), - MBEDTLS_BYTES_TO_T_UINT_8(0x39, 0x2F, 0x22, 0x38, 0x5B, 0x18, 0x4C, 0x35), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_27_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x10, 0xC1, 0x22, 0x0E, 0xF0, 0x73, 0x11, 0x05), - MBEDTLS_BYTES_TO_T_UINT_8(0xB2, 0xAE, 0xA4, 0x56, 0x18, 0x61, 0x66, 0x12), - MBEDTLS_BYTES_TO_T_UINT_8(0x79, 0xFB, 0x72, 0x08, 0x84, 0x38, 0x51, 0xB0), - MBEDTLS_BYTES_TO_T_UINT_8(0xDA, 0x86, 0xA8, 0xB9, 0x31, 0x99, 0x29, 0xC3), - MBEDTLS_BYTES_TO_T_UINT_8(0x8A, 0xFB, 0xC3, 0x42, 0xB3, 0xC7, 0x6F, 0x3A), - MBEDTLS_BYTES_TO_T_UINT_8(0xD8, 0xF8, 0xE1, 0x09, 0xBE, 0x75, 0xB0, 0x22), - MBEDTLS_BYTES_TO_T_UINT_8(0x5A, 0x7D, 0xFF, 0xF4, 0x99, 0xFC, 0x13, 0xAB), - MBEDTLS_BYTES_TO_T_UINT_8(0xE6, 0x1B, 0x84, 0x81, 0x42, 0x22, 0xC6, 0x3D), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_27_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x21, 0xE0, 0x37, 0xA4, 0xA0, 0x2F, 0x38, 0x7F), - MBEDTLS_BYTES_TO_T_UINT_8(0xD0, 0x3D, 0xB7, 0x40, 0x2F, 0x39, 0x3C, 0x7A), - MBEDTLS_BYTES_TO_T_UINT_8(0x7A, 0x3B, 0x8A, 0x51, 0xAE, 0x40, 0x49, 0x7A), - MBEDTLS_BYTES_TO_T_UINT_8(0x36, 0x20, 0x9F, 0xDD, 0xA9, 0xD0, 0x77, 0xC7), - MBEDTLS_BYTES_TO_T_UINT_8(0x78, 0x1D, 0x64, 0xDA, 0xA0, 0x53, 0xC7, 0x7D), - MBEDTLS_BYTES_TO_T_UINT_8(0x37, 0x7B, 0x66, 0x55, 0x94, 0xD1, 0x51, 0x44), - MBEDTLS_BYTES_TO_T_UINT_8(0x0E, 0xA9, 0xB5, 0x5B, 0x38, 0x35, 0x40, 0xC0), - MBEDTLS_BYTES_TO_T_UINT_8(0xC8, 0xC9, 0x0F, 0xF0, 0x73, 0x79, 0x43, 0x61), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_28_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x10, 0x47, 0x45, 0x69, 0x80, 0x72, 0x72, 0x42), - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0x11, 0x99, 0x59, 0xDB, 0x48, 0x80, 0x39), - MBEDTLS_BYTES_TO_T_UINT_8(0x75, 0x6E, 0x3D, 0xFC, 0x37, 0x15, 0xF4, 0xBF), - MBEDTLS_BYTES_TO_T_UINT_8(0x17, 0xBB, 0x5B, 0xA6, 0x35, 0x8D, 0x28, 0x20), - MBEDTLS_BYTES_TO_T_UINT_8(0xAB, 0x1A, 0x3B, 0x2C, 0x8F, 0xD3, 0xAA, 0x2D), - MBEDTLS_BYTES_TO_T_UINT_8(0x55, 0x1C, 0x1A, 0xF8, 0x02, 0xD9, 0x7B, 0x41), - MBEDTLS_BYTES_TO_T_UINT_8(0xAF, 0x69, 0xAC, 0xF8, 0x54, 0x31, 0x14, 0xA1), - MBEDTLS_BYTES_TO_T_UINT_8(0x41, 0x8A, 0xE6, 0xDE, 0x58, 0xB9, 0xC4, 0x7A), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_28_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x57, 0x83, 0x52, 0xFE, 0xF9, 0x7B, 0xE9, 0x1F), - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0xA2, 0x55, 0x46, 0x15, 0x49, 0xC1, 0x3A), - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0xBC, 0x5C, 0x91, 0xBD, 0xB9, 0x9C, 0xF4), - MBEDTLS_BYTES_TO_T_UINT_8(0xBB, 0xFD, 0xB1, 0x4E, 0x5F, 0x74, 0xEE, 0x53), - MBEDTLS_BYTES_TO_T_UINT_8(0xB1, 0x8B, 0xD8, 0x8B, 0x17, 0x73, 0x1B, 0x96), - MBEDTLS_BYTES_TO_T_UINT_8(0x22, 0x92, 0xD7, 0x67, 0x06, 0xAD, 0x25, 0xCD), - MBEDTLS_BYTES_TO_T_UINT_8(0x01, 0x0F, 0x80, 0x24, 0xE2, 0x27, 0x5F, 0x8B), - MBEDTLS_BYTES_TO_T_UINT_8(0x61, 0x1C, 0xCE, 0xD0, 0x67, 0xCA, 0xD4, 0x0B), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_29_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x87, 0xF1, 0xDD, 0x33, 0x66, 0xF9, 0x05, 0xD6), - MBEDTLS_BYTES_TO_T_UINT_8(0x1D, 0xE5, 0x6B, 0x79, 0xBD, 0x48, 0x42, 0xAA), - MBEDTLS_BYTES_TO_T_UINT_8(0xD1, 0x14, 0x52, 0xE3, 0x53, 0xB4, 0x50, 0xD4), - MBEDTLS_BYTES_TO_T_UINT_8(0x32, 0x84, 0x6C, 0xCF, 0xDA, 0xB2, 0x20, 0x0A), - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0xD6, 0x1A, 0xE5, 0xE2, 0x29, 0x70, 0xCE), - MBEDTLS_BYTES_TO_T_UINT_8(0xD5, 0x61, 0xFE, 0xBB, 0x21, 0x82, 0xD1, 0xFE), - MBEDTLS_BYTES_TO_T_UINT_8(0x2C, 0xF0, 0x9C, 0x8B, 0x1A, 0x42, 0x30, 0x06), - MBEDTLS_BYTES_TO_T_UINT_8(0x43, 0xD6, 0x49, 0x81, 0x92, 0xF1, 0xD0, 0x90), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_29_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x91, 0x93, 0x6A, 0xA6, 0x22, 0xE9, 0xD6), - MBEDTLS_BYTES_TO_T_UINT_8(0x09, 0xDC, 0xC3, 0x69, 0x11, 0x95, 0x7D, 0xEC), - MBEDTLS_BYTES_TO_T_UINT_8(0x1C, 0xA3, 0x9D, 0x87, 0x5E, 0x64, 0x41, 0xA2), - MBEDTLS_BYTES_TO_T_UINT_8(0xBE, 0x87, 0x5A, 0x15, 0xBD, 0x6E, 0x3C, 0x8D), - MBEDTLS_BYTES_TO_T_UINT_8(0xD0, 0x8D, 0x50, 0xCC, 0xCF, 0xB7, 0x8F, 0x0B), - MBEDTLS_BYTES_TO_T_UINT_8(0x38, 0x65, 0xCD, 0x31, 0x30, 0xF1, 0x68, 0x13), - MBEDTLS_BYTES_TO_T_UINT_8(0x10, 0x5C, 0x66, 0x67, 0x92, 0x30, 0x57, 0x95), - MBEDTLS_BYTES_TO_T_UINT_8(0x23, 0x9B, 0x01, 0x3D, 0x20, 0x8B, 0xD1, 0x0D), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_30_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xAB, 0xC0, 0xE6, 0x4F, 0xDE, 0x62, 0xAB, 0xB3), - MBEDTLS_BYTES_TO_T_UINT_8(0xA4, 0x48, 0xB3, 0x1C, 0x0F, 0x16, 0x93, 0x45), - MBEDTLS_BYTES_TO_T_UINT_8(0x77, 0x63, 0xBD, 0x1F, 0x16, 0x50, 0x56, 0x98), - MBEDTLS_BYTES_TO_T_UINT_8(0x5D, 0x06, 0xBC, 0xE9, 0x27, 0x1C, 0x9A, 0x7B), - MBEDTLS_BYTES_TO_T_UINT_8(0xF8, 0xFE, 0x21, 0xC5, 0x39, 0x55, 0xE1, 0xFD), - MBEDTLS_BYTES_TO_T_UINT_8(0xF6, 0xA8, 0xD0, 0x96, 0x0E, 0xB5, 0xB2, 0x84), - MBEDTLS_BYTES_TO_T_UINT_8(0x3D, 0xE7, 0x4B, 0xF3, 0x11, 0x0C, 0xC9, 0x5B), - MBEDTLS_BYTES_TO_T_UINT_8(0x43, 0x3A, 0xC4, 0x87, 0x71, 0xEE, 0xFA, 0x18), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_30_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xA7, 0x77, 0xEE, 0x81, 0x5E, 0x96, 0xEA, 0x4B), - MBEDTLS_BYTES_TO_T_UINT_8(0xEE, 0xDF, 0xA9, 0xF4, 0x4F, 0x7C, 0xB2, 0x43), - MBEDTLS_BYTES_TO_T_UINT_8(0x9F, 0xD4, 0xDF, 0x35, 0x63, 0x47, 0x25, 0x8A), - MBEDTLS_BYTES_TO_T_UINT_8(0xA5, 0x3D, 0xFF, 0xA4, 0x02, 0xC3, 0x95, 0x11), - MBEDTLS_BYTES_TO_T_UINT_8(0xD5, 0x10, 0x78, 0xD1, 0x2B, 0xB7, 0xBE, 0x0E), - MBEDTLS_BYTES_TO_T_UINT_8(0x0A, 0xE9, 0x57, 0xF9, 0xE0, 0xD8, 0xFC, 0xBC), - MBEDTLS_BYTES_TO_T_UINT_8(0xF3, 0xC4, 0x01, 0xD6, 0xB4, 0xE7, 0x78, 0xE2), - MBEDTLS_BYTES_TO_T_UINT_8(0x02, 0x6C, 0xB9, 0x13, 0xA4, 0xE8, 0x6D, 0x6F), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_31_X[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0xE8, 0xB0, 0xC9, 0xCD, 0xBF, 0xA2, 0x1E, 0x63), - MBEDTLS_BYTES_TO_T_UINT_8(0xDD, 0x4F, 0x86, 0x22, 0x9B, 0xEA, 0xE8, 0xBB), - MBEDTLS_BYTES_TO_T_UINT_8(0x50, 0x46, 0xDF, 0x43, 0xB9, 0x82, 0x2D, 0x0A), - MBEDTLS_BYTES_TO_T_UINT_8(0x07, 0x32, 0xF1, 0x4E, 0x95, 0x41, 0xAE, 0x8E), - MBEDTLS_BYTES_TO_T_UINT_8(0x52, 0x93, 0x26, 0xFC, 0xD3, 0x90, 0xDC, 0xEB), - MBEDTLS_BYTES_TO_T_UINT_8(0x04, 0x05, 0x45, 0xCA, 0xF9, 0x5A, 0x89, 0x93), - MBEDTLS_BYTES_TO_T_UINT_8(0xC5, 0x82, 0x63, 0x4E, 0x55, 0x1D, 0x3A, 0x08), - MBEDTLS_BYTES_TO_T_UINT_8(0x7C, 0x69, 0x52, 0x49, 0xE9, 0xED, 0x57, 0x34), -}; -static const mbedtls_mpi_uint brainpoolP512r1_T_31_Y[] = { - MBEDTLS_BYTES_TO_T_UINT_8(0x70, 0x64, 0xE9, 0xAC, 0x4C, 0x4A, 0xEA, 0x25), - MBEDTLS_BYTES_TO_T_UINT_8(0xE9, 0xE9, 0x0B, 0x99, 0xE7, 0xF9, 0xA9, 0x2C), - MBEDTLS_BYTES_TO_T_UINT_8(0x24, 0x0C, 0xC1, 0xF4, 0x8D, 0x07, 0xB6, 0xB1), - MBEDTLS_BYTES_TO_T_UINT_8(0xAD, 0x68, 0xFA, 0x35, 0xE4, 0x9E, 0xAE, 0xD9), - MBEDTLS_BYTES_TO_T_UINT_8(0xF0, 0x2D, 0x1A, 0x13, 0x8E, 0x02, 0xE2, 0x63), - MBEDTLS_BYTES_TO_T_UINT_8(0x27, 0x38, 0x28, 0x86, 0x46, 0x7B, 0x3A, 0xE1), - MBEDTLS_BYTES_TO_T_UINT_8(0x3F, 0x4C, 0x64, 0x59, 0x0A, 0xF9, 0x02, 0xC4), - MBEDTLS_BYTES_TO_T_UINT_8(0x41, 0x4F, 0x23, 0xA2, 0xC3, 0xD5, 0xEF, 0x42), -}; -static const mbedtls_ecp_point brainpoolP512r1_T[32] = { - ECP_POINT_INIT_XY_Z1(brainpoolP512r1_T_0_X, brainpoolP512r1_T_0_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_1_X, brainpoolP512r1_T_1_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_2_X, brainpoolP512r1_T_2_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_3_X, brainpoolP512r1_T_3_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_4_X, brainpoolP512r1_T_4_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_5_X, brainpoolP512r1_T_5_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_6_X, brainpoolP512r1_T_6_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_7_X, brainpoolP512r1_T_7_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_8_X, brainpoolP512r1_T_8_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_9_X, brainpoolP512r1_T_9_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_10_X, brainpoolP512r1_T_10_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_11_X, brainpoolP512r1_T_11_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_12_X, brainpoolP512r1_T_12_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_13_X, brainpoolP512r1_T_13_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_14_X, brainpoolP512r1_T_14_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_15_X, brainpoolP512r1_T_15_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_16_X, brainpoolP512r1_T_16_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_17_X, brainpoolP512r1_T_17_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_18_X, brainpoolP512r1_T_18_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_19_X, brainpoolP512r1_T_19_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_20_X, brainpoolP512r1_T_20_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_21_X, brainpoolP512r1_T_21_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_22_X, brainpoolP512r1_T_22_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_23_X, brainpoolP512r1_T_23_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_24_X, brainpoolP512r1_T_24_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_25_X, brainpoolP512r1_T_25_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_26_X, brainpoolP512r1_T_26_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_27_X, brainpoolP512r1_T_27_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_28_X, brainpoolP512r1_T_28_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_29_X, brainpoolP512r1_T_29_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_30_X, brainpoolP512r1_T_30_Y), - ECP_POINT_INIT_XY_Z0(brainpoolP512r1_T_31_X, brainpoolP512r1_T_31_Y), -}; -#else -#define brainpoolP512r1_T NULL -#endif -#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */ - -#if defined(ECP_LOAD_GROUP) -/* - * Create an MPI from embedded constants - * (assumes len is an exact multiple of sizeof mbedtls_mpi_uint) - */ -static inline void ecp_mpi_load(mbedtls_mpi * X, const mbedtls_mpi_uint * p, size_t len) -{ - X->s = 1; - X->n = len / sizeof(mbedtls_mpi_uint); - X->p = (mbedtls_mpi_uint *) p; -} - -/* - * Set an MPI to static value 1 - */ -static inline void ecp_mpi_set1(mbedtls_mpi * X) -{ - X->s = 1; - X->n = 1; - X->p = mpi_one; -} - -/* - * Make group available from embedded constants - */ -static int ecp_group_load(mbedtls_ecp_group * grp, const mbedtls_mpi_uint * p, size_t plen, const mbedtls_mpi_uint * a, size_t alen, - const mbedtls_mpi_uint * b, size_t blen, const mbedtls_mpi_uint * gx, size_t gxlen, - const mbedtls_mpi_uint * gy, size_t gylen, const mbedtls_mpi_uint * n, size_t nlen, - const mbedtls_ecp_point * T) -{ - ecp_mpi_load(&grp->P, p, plen); - if (a != NULL) - ecp_mpi_load(&grp->A, a, alen); - ecp_mpi_load(&grp->B, b, blen); - ecp_mpi_load(&grp->N, n, nlen); - - ecp_mpi_load(&grp->G.X, gx, gxlen); - ecp_mpi_load(&grp->G.Y, gy, gylen); - ecp_mpi_set1(&grp->G.Z); - - grp->pbits = mbedtls_mpi_bitlen(&grp->P); - grp->nbits = mbedtls_mpi_bitlen(&grp->N); - - grp->h = 1; - - grp->T = (mbedtls_ecp_point *) T; - /* - * Set T_size to 0 to prevent T free by mbedtls_ecp_group_free. - */ - grp->T_size = 0; - - return (0); -} -#endif /* ECP_LOAD_GROUP */ - -#if defined(MBEDTLS_ECP_NIST_OPTIM) -/* Forward declarations */ -#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) -static int ecp_mod_p192(mbedtls_mpi *); -#endif -#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) -static int ecp_mod_p224(mbedtls_mpi *); -#endif -#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) -static int ecp_mod_p256(mbedtls_mpi *); -#endif -#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) -static int ecp_mod_p384(mbedtls_mpi *); -#endif -#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) -static int ecp_mod_p521(mbedtls_mpi *); -#endif - -#define NIST_MODP(P) grp->modp = ecp_mod_##P; -#else -#define NIST_MODP(P) -#endif /* MBEDTLS_ECP_NIST_OPTIM */ - -/* Additional forward declarations */ -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) -static int ecp_mod_p255(mbedtls_mpi *); -#endif -#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) -static int ecp_mod_p448(mbedtls_mpi *); -#endif -#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) -static int ecp_mod_p192k1(mbedtls_mpi *); -#endif -#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) -static int ecp_mod_p224k1(mbedtls_mpi *); -#endif -#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) -static int ecp_mod_p256k1(mbedtls_mpi *); -#endif - -#if defined(ECP_LOAD_GROUP) -#define LOAD_GROUP_A(G) \ - ecp_group_load(grp, G##_p, sizeof(G##_p), G##_a, sizeof(G##_a), G##_b, sizeof(G##_b), G##_gx, sizeof(G##_gx), G##_gy, \ - sizeof(G##_gy), G##_n, sizeof(G##_n), G##_T) - -#define LOAD_GROUP(G) \ - ecp_group_load(grp, G##_p, sizeof(G##_p), NULL, 0, G##_b, sizeof(G##_b), G##_gx, sizeof(G##_gx), G##_gy, sizeof(G##_gy), \ - G##_n, sizeof(G##_n), G##_T) -#endif /* ECP_LOAD_GROUP */ - -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) -/* Constants used by ecp_use_curve25519() */ -static const mbedtls_mpi_sint curve25519_a24 = 0x01DB42; -static const unsigned char curve25519_part_of_n[] = { - 0x14, 0xDE, 0xF9, 0xDE, 0xA2, 0xF7, 0x9C, 0xD6, 0x58, 0x12, 0x63, 0x1A, 0x5C, 0xF5, 0xD3, 0xED, -}; - -/* - * Specialized function for creating the Curve25519 group - */ -static int ecp_use_curve25519(mbedtls_ecp_group * grp) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - - /* Actually ( A + 2 ) / 4 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&grp->A, curve25519_a24)); - - /* P = 2^255 - 19 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&grp->P, 1)); - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_l(&grp->P, 255)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_int(&grp->P, &grp->P, 19)); - grp->pbits = mbedtls_mpi_bitlen(&grp->P); - - /* N = 2^252 + 27742317777372353535851937790883648493 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&grp->N, curve25519_part_of_n, sizeof(curve25519_part_of_n))); - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(&grp->N, 252, 1)); - - /* Y intentionally not set, since we use x/z coordinates. - * This is used as a marker to identify Montgomery curves! */ - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&grp->G.X, 9)); - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&grp->G.Z, 1)); - mbedtls_mpi_free(&grp->G.Y); - - /* Actually, the required msb for private keys */ - grp->nbits = 254; - -cleanup: - if (ret != 0) - mbedtls_ecp_group_free(grp); - - return (ret); -} -#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) -/* Constants used by ecp_use_curve448() */ -static const mbedtls_mpi_sint curve448_a24 = 0x98AA; -static const unsigned char curve448_part_of_n[] = { - 0x83, 0x35, 0xDC, 0x16, 0x3B, 0xB1, 0x24, 0xB6, 0x51, 0x29, 0xC9, 0x6F, 0xDE, 0x93, - 0x3D, 0x8D, 0x72, 0x3A, 0x70, 0xAA, 0xDC, 0x87, 0x3D, 0x6D, 0x54, 0xA7, 0xBB, 0x0D, -}; - -/* - * Specialized function for creating the Curve448 group - */ -static int ecp_use_curve448(mbedtls_ecp_group * grp) -{ - mbedtls_mpi Ns; - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - - mbedtls_mpi_init(&Ns); - - /* Actually ( A + 2 ) / 4 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&grp->A, curve448_a24)); - - /* P = 2^448 - 2^224 - 1 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&grp->P, 1)); - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_l(&grp->P, 224)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_int(&grp->P, &grp->P, 1)); - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_l(&grp->P, 224)); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_int(&grp->P, &grp->P, 1)); - grp->pbits = mbedtls_mpi_bitlen(&grp->P); - - /* Y intentionally not set, since we use x/z coordinates. - * This is used as a marker to identify Montgomery curves! */ - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&grp->G.X, 5)); - MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&grp->G.Z, 1)); - mbedtls_mpi_free(&grp->G.Y); - - /* N = 2^446 - 13818066809895115352007386748515426880336692474882178609894547503885 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(&grp->N, 446, 1)); - MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&Ns, curve448_part_of_n, sizeof(curve448_part_of_n))); - MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(&grp->N, &grp->N, &Ns)); - - /* Actually, the required msb for private keys */ - grp->nbits = 447; - -cleanup: - mbedtls_mpi_free(&Ns); - if (ret != 0) - mbedtls_ecp_group_free(grp); - - return (ret); -} -#endif /* MBEDTLS_ECP_DP_CURVE448_ENABLED */ - -/* - * Set a group using well-known domain parameters - */ -int mbedtls_ecp_group_load(mbedtls_ecp_group * grp, mbedtls_ecp_group_id id) -{ - ECP_VALIDATE_RET(grp != NULL); - mbedtls_ecp_group_free(grp); - - grp->id = id; - - switch (id) - { -#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) - case MBEDTLS_ECP_DP_SECP192R1: - NIST_MODP(p192); - return (LOAD_GROUP(secp192r1)); -#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) - case MBEDTLS_ECP_DP_SECP224R1: - NIST_MODP(p224); - return (LOAD_GROUP(secp224r1)); -#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) - case MBEDTLS_ECP_DP_SECP256R1: - NIST_MODP(p256); - return (LOAD_GROUP(secp256r1)); -#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) - case MBEDTLS_ECP_DP_SECP384R1: - NIST_MODP(p384); - return (LOAD_GROUP(secp384r1)); -#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) - case MBEDTLS_ECP_DP_SECP521R1: - NIST_MODP(p521); - return (LOAD_GROUP(secp521r1)); -#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) - case MBEDTLS_ECP_DP_SECP192K1: - grp->modp = ecp_mod_p192k1; - return (LOAD_GROUP_A(secp192k1)); -#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) - case MBEDTLS_ECP_DP_SECP224K1: - grp->modp = ecp_mod_p224k1; - return (LOAD_GROUP_A(secp224k1)); -#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) - case MBEDTLS_ECP_DP_SECP256K1: - grp->modp = ecp_mod_p256k1; - return (LOAD_GROUP_A(secp256k1)); -#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) - case MBEDTLS_ECP_DP_BP256R1: - return (LOAD_GROUP_A(brainpoolP256r1)); -#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) - case MBEDTLS_ECP_DP_BP384R1: - return (LOAD_GROUP_A(brainpoolP384r1)); -#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) - case MBEDTLS_ECP_DP_BP512R1: - return (LOAD_GROUP_A(brainpoolP512r1)); -#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) - case MBEDTLS_ECP_DP_CURVE25519: - grp->modp = ecp_mod_p255; - return (ecp_use_curve25519(grp)); -#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) - case MBEDTLS_ECP_DP_CURVE448: - grp->modp = ecp_mod_p448; - return (ecp_use_curve448(grp)); -#endif /* MBEDTLS_ECP_DP_CURVE448_ENABLED */ - - default: - grp->id = MBEDTLS_ECP_DP_NONE; - return (MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); - } -} - -#if defined(MBEDTLS_ECP_NIST_OPTIM) -/* - * Fast reduction modulo the primes used by the NIST curves. - * - * These functions are critical for speed, but not needed for correct - * operations. So, we make the choice to heavily rely on the internals of our - * bignum library, which creates a tight coupling between these functions and - * our MPI implementation. However, the coupling between the ECP module and - * MPI remains loose, since these functions can be deactivated at will. - */ - -#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) -/* - * Compared to the way things are presented in FIPS 186-3 D.2, - * we proceed in columns, from right (least significant chunk) to left, - * adding chunks to N in place, and keeping a carry for the next chunk. - * This avoids moving things around in memory, and uselessly adding zeros, - * compared to the more straightforward, line-oriented approach. - * - * For this prime we need to handle data in chunks of 64 bits. - * Since this is always a multiple of our basic mbedtls_mpi_uint, we can - * use a mbedtls_mpi_uint * to designate such a chunk, and small loops to handle it. - */ - -/* Add 64-bit chunks (dst += src) and update carry */ -static inline void add64(mbedtls_mpi_uint * dst, mbedtls_mpi_uint * src, mbedtls_mpi_uint * carry) -{ - unsigned char i; - mbedtls_mpi_uint c = 0; - for (i = 0; i < 8 / sizeof(mbedtls_mpi_uint); i++, dst++, src++) - { - *dst += c; - c = (*dst < c); - *dst += *src; - c += (*dst < *src); - } - *carry += c; -} - -/* Add carry to a 64-bit chunk and update carry */ -static inline void carry64(mbedtls_mpi_uint * dst, mbedtls_mpi_uint * carry) -{ - unsigned char i; - for (i = 0; i < 8 / sizeof(mbedtls_mpi_uint); i++, dst++) - { - *dst += *carry; - *carry = (*dst < *carry); - } -} - -#define WIDTH 8 / sizeof(mbedtls_mpi_uint) -#define A(i) N->p + (i) *WIDTH -#define ADD(i) add64(p, A(i), &c) -#define NEXT \ - p += WIDTH; \ - carry64(p, &c) -#define LAST \ - p += WIDTH; \ - *p = c; \ - while (++p < end) \ - *p = 0 - -/* - * Fast quasi-reduction modulo p192 (FIPS 186-3 D.2.1) - */ -static int ecp_mod_p192(mbedtls_mpi * N) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_mpi_uint c = 0; - mbedtls_mpi_uint *p, *end; - - /* Make sure we have enough blocks so that A(5) is legal */ - MBEDTLS_MPI_CHK(mbedtls_mpi_grow(N, 6 * WIDTH)); - - p = N->p; - end = p + N->n; - - ADD(3); - ADD(5); - NEXT; // A0 += A3 + A5 - ADD(3); - ADD(4); - ADD(5); - NEXT; // A1 += A3 + A4 + A5 - ADD(4); - ADD(5); - LAST; // A2 += A4 + A5 - -cleanup: - return (ret); -} - -#undef WIDTH -#undef A -#undef ADD -#undef NEXT -#undef LAST -#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) || defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \ - defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) -/* - * The reader is advised to first understand ecp_mod_p192() since the same - * general structure is used here, but with additional complications: - * (1) chunks of 32 bits, and (2) subtractions. - */ - -/* - * For these primes, we need to handle data in chunks of 32 bits. - * This makes it more complicated if we use 64 bits limbs in MPI, - * which prevents us from using a uniform access method as for p192. - * - * So, we define a mini abstraction layer to access 32 bit chunks, - * load them in 'cur' for work, and store them back from 'cur' when done. - * - * While at it, also define the size of N in terms of 32-bit chunks. - */ -#define LOAD32 cur = A(i); - -#if defined(MBEDTLS_HAVE_INT32) /* 32 bit */ - -#define MAX32 N->n -#define A(j) N->p[j] -#define STORE32 N->p[i] = cur; - -#else /* 64-bit */ - -#define MAX32 N->n * 2 -#define A(j) (j) % 2 ? (uint32_t)(N->p[(j) / 2] >> 32) : (uint32_t)(N->p[(j) / 2]) -#define STORE32 \ - if (i % 2) \ - { \ - N->p[i / 2] &= 0x00000000FFFFFFFF; \ - N->p[i / 2] |= ((mbedtls_mpi_uint) cur) << 32; \ - } \ - else \ - { \ - N->p[i / 2] &= 0xFFFFFFFF00000000; \ - N->p[i / 2] |= (mbedtls_mpi_uint) cur; \ - } - -#endif /* sizeof( mbedtls_mpi_uint ) */ - -/* - * Helpers for addition and subtraction of chunks, with signed carry. - */ -static inline void add32(uint32_t * dst, uint32_t src, signed char * carry) -{ - *dst += src; - *carry += (*dst < src); -} - -static inline void sub32(uint32_t * dst, uint32_t src, signed char * carry) -{ - *carry -= (*dst < src); - *dst -= src; -} - -#define ADD(j) add32(&cur, A(j), &c); -#define SUB(j) sub32(&cur, A(j), &c); - -#define ciL (sizeof(mbedtls_mpi_uint)) /* chars in limb */ -#define biL (ciL << 3) /* bits in limb */ - -/* - * Helpers for the main 'loop' - */ -#define INIT(b) \ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; \ - signed char c = 0, cc; \ - uint32_t cur; \ - size_t i = 0, bits = (b); \ - /* N is the size of the product of two b-bit numbers, plus one */ \ - /* limb for fix_negative */ \ - MBEDTLS_MPI_CHK(mbedtls_mpi_grow(N, (b) *2 / biL + 1)); \ - LOAD32; - -#define NEXT \ - STORE32; \ - i++; \ - LOAD32; \ - cc = c; \ - c = 0; \ - if (cc < 0) \ - sub32(&cur, -cc, &c); \ - else \ - add32(&cur, cc, &c); - -#define LAST \ - STORE32; \ - i++; \ - cur = c > 0 ? c : 0; \ - STORE32; \ - cur = 0; \ - while (++i < MAX32) \ - { \ - STORE32; \ - } \ - if (c < 0) \ - mbedtls_ecp_fix_negative(N, c, bits); - -/* - * If the result is negative, we get it in the form - * c * 2^bits + N, with c negative and N positive shorter than 'bits' - */ -MBEDTLS_STATIC_TESTABLE -void mbedtls_ecp_fix_negative(mbedtls_mpi * N, signed char c, size_t bits) -{ - size_t i; - - /* Set N := 2^bits - 1 - N. We know that 0 <= N < 2^bits, so - * set the absolute value to 0xfff...fff - N. There is no carry - * since we're subtracting from all-bits-one. */ - for (i = 0; i <= bits / 8 / sizeof(mbedtls_mpi_uint); i++) - { - N->p[i] = ~(mbedtls_mpi_uint) 0 - N->p[i]; - } - /* Add 1, taking care of the carry. */ - i = 0; - do - ++N->p[i]; - while (N->p[i++] == 0 && i <= bits / 8 / sizeof(mbedtls_mpi_uint)); - /* Invert the sign. - * Now N = N0 - 2^bits where N0 is the initial value of N. */ - N->s = -1; - - /* Add |c| * 2^bits to the absolute value. Since c and N are - * negative, this adds c * 2^bits. */ - mbedtls_mpi_uint msw = (mbedtls_mpi_uint) -c; -#if defined(MBEDTLS_HAVE_INT64) - if (bits == 224) - msw <<= 32; -#endif - N->p[bits / 8 / sizeof(mbedtls_mpi_uint)] += msw; -} - -#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) -/* - * Fast quasi-reduction modulo p224 (FIPS 186-3 D.2.2) - */ -static int ecp_mod_p224(mbedtls_mpi * N) -{ - INIT(224); - - SUB(7); - SUB(11); - NEXT; // A0 += -A7 - A11 - SUB(8); - SUB(12); - NEXT; // A1 += -A8 - A12 - SUB(9); - SUB(13); - NEXT; // A2 += -A9 - A13 - SUB(10); - ADD(7); - ADD(11); - NEXT; // A3 += -A10 + A7 + A11 - SUB(11); - ADD(8); - ADD(12); - NEXT; // A4 += -A11 + A8 + A12 - SUB(12); - ADD(9); - ADD(13); - NEXT; // A5 += -A12 + A9 + A13 - SUB(13); - ADD(10); - LAST; // A6 += -A13 + A10 - -cleanup: - return (ret); -} -#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) -/* - * Fast quasi-reduction modulo p256 (FIPS 186-3 D.2.3) - */ -static int ecp_mod_p256(mbedtls_mpi * N) -{ - INIT(256); - - ADD(8); - ADD(9); - SUB(11); - SUB(12); - SUB(13); - SUB(14); - NEXT; // A0 - - ADD(9); - ADD(10); - SUB(12); - SUB(13); - SUB(14); - SUB(15); - NEXT; // A1 - - ADD(10); - ADD(11); - SUB(13); - SUB(14); - SUB(15); - NEXT; // A2 - - ADD(11); - ADD(11); - ADD(12); - ADD(12); - ADD(13); - SUB(15); - SUB(8); - SUB(9); - NEXT; // A3 - - ADD(12); - ADD(12); - ADD(13); - ADD(13); - ADD(14); - SUB(9); - SUB(10); - NEXT; // A4 - - ADD(13); - ADD(13); - ADD(14); - ADD(14); - ADD(15); - SUB(10); - SUB(11); - NEXT; // A5 - - ADD(14); - ADD(14); - ADD(15); - ADD(15); - ADD(14); - ADD(13); - SUB(8); - SUB(9); - NEXT; // A6 - - ADD(15); - ADD(15); - ADD(15); - ADD(8); - SUB(10); - SUB(11); - SUB(12); - SUB(13); - LAST; // A7 - -cleanup: - return (ret); -} -#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) -/* - * Fast quasi-reduction modulo p384 (FIPS 186-3 D.2.4) - */ -static int ecp_mod_p384(mbedtls_mpi * N) -{ - INIT(384); - - ADD(12); - ADD(21); - ADD(20); - SUB(23); - NEXT; // A0 - - ADD(13); - ADD(22); - ADD(23); - SUB(12); - SUB(20); - NEXT; // A2 - - ADD(14); - ADD(23); - SUB(13); - SUB(21); - NEXT; // A2 - - ADD(15); - ADD(12); - ADD(20); - ADD(21); - SUB(14); - SUB(22); - SUB(23); - NEXT; // A3 - - ADD(21); - ADD(21); - ADD(16); - ADD(13); - ADD(12); - ADD(20); - ADD(22); - SUB(15); - SUB(23); - SUB(23); - NEXT; // A4 - - ADD(22); - ADD(22); - ADD(17); - ADD(14); - ADD(13); - ADD(21); - ADD(23); - SUB(16); - NEXT; // A5 - - ADD(23); - ADD(23); - ADD(18); - ADD(15); - ADD(14); - ADD(22); - SUB(17); - NEXT; // A6 - - ADD(19); - ADD(16); - ADD(15); - ADD(23); - SUB(18); - NEXT; // A7 - - ADD(20); - ADD(17); - ADD(16); - SUB(19); - NEXT; // A8 - - ADD(21); - ADD(18); - ADD(17); - SUB(20); - NEXT; // A9 - - ADD(22); - ADD(19); - ADD(18); - SUB(21); - NEXT; // A10 - - ADD(23); - ADD(20); - ADD(19); - SUB(22); - LAST; // A11 - -cleanup: - return (ret); -} -#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */ - -#undef A -#undef LOAD32 -#undef STORE32 -#undef MAX32 -#undef INIT -#undef NEXT -#undef LAST - -#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED || \ - MBEDTLS_ECP_DP_SECP256R1_ENABLED || \ - MBEDTLS_ECP_DP_SECP384R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) -/* - * Here we have an actual Mersenne prime, so things are more straightforward. - * However, chunks are aligned on a 'weird' boundary (521 bits). - */ - -/* Size of p521 in terms of mbedtls_mpi_uint */ -#define P521_WIDTH (521 / 8 / sizeof(mbedtls_mpi_uint) + 1) - -/* Bits to keep in the most significant mbedtls_mpi_uint */ -#define P521_MASK 0x01FF - -/* - * Fast quasi-reduction modulo p521 (FIPS 186-3 D.2.5) - * Write N as A1 + 2^521 A0, return A0 + A1 - */ -static int ecp_mod_p521(mbedtls_mpi * N) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - size_t i; - mbedtls_mpi M; - mbedtls_mpi_uint Mp[P521_WIDTH + 1]; - /* Worst case for the size of M is when mbedtls_mpi_uint is 16 bits: - * we need to hold bits 513 to 1056, which is 34 limbs, that is - * P521_WIDTH + 1. Otherwise P521_WIDTH is enough. */ - - if (N->n < P521_WIDTH) - return (0); - - /* M = A1 */ - M.s = 1; - M.n = N->n - (P521_WIDTH - 1); - if (M.n > P521_WIDTH + 1) - M.n = P521_WIDTH + 1; - M.p = Mp; - memcpy(Mp, N->p + P521_WIDTH - 1, M.n * sizeof(mbedtls_mpi_uint)); - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_r(&M, 521 % (8 * sizeof(mbedtls_mpi_uint)))); - - /* N = A0 */ - N->p[P521_WIDTH - 1] &= P521_MASK; - for (i = P521_WIDTH; i < N->n; i++) - N->p[i] = 0; - - /* N = A0 + A1 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_add_abs(N, N, &M)); - -cleanup: - return (ret); -} - -#undef P521_WIDTH -#undef P521_MASK -#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */ - -#endif /* MBEDTLS_ECP_NIST_OPTIM */ - -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) - -/* Size of p255 in terms of mbedtls_mpi_uint */ -#define P255_WIDTH (255 / 8 / sizeof(mbedtls_mpi_uint) + 1) - -/* - * Fast quasi-reduction modulo p255 = 2^255 - 19 - * Write N as A0 + 2^255 A1, return A0 + 19 * A1 - */ -static int ecp_mod_p255(mbedtls_mpi * N) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - size_t i; - mbedtls_mpi M; - mbedtls_mpi_uint Mp[P255_WIDTH + 2]; - - if (N->n < P255_WIDTH) - return (0); - - /* M = A1 */ - M.s = 1; - M.n = N->n - (P255_WIDTH - 1); - if (M.n > P255_WIDTH + 1) - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - M.p = Mp; - memset(Mp, 0, sizeof Mp); - memcpy(Mp, N->p + P255_WIDTH - 1, M.n * sizeof(mbedtls_mpi_uint)); - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_r(&M, 255 % (8 * sizeof(mbedtls_mpi_uint)))); - M.n++; /* Make room for multiplication by 19 */ - - /* N = A0 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(N, 255, 0)); - for (i = P255_WIDTH; i < N->n; i++) - N->p[i] = 0; - - /* N = A0 + 19 * A1 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_int(&M, &M, 19)); - MBEDTLS_MPI_CHK(mbedtls_mpi_add_abs(N, N, &M)); - -cleanup: - return (ret); -} -#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) - -/* Size of p448 in terms of mbedtls_mpi_uint */ -#define P448_WIDTH (448 / 8 / sizeof(mbedtls_mpi_uint)) - -/* Number of limbs fully occupied by 2^224 (max), and limbs used by it (min) */ -#define DIV_ROUND_UP(X, Y) (((X) + (Y) -1) / (Y)) -#define P224_WIDTH_MIN (28 / sizeof(mbedtls_mpi_uint)) -#define P224_WIDTH_MAX DIV_ROUND_UP(28, sizeof(mbedtls_mpi_uint)) -#define P224_UNUSED_BITS ((P224_WIDTH_MAX * sizeof(mbedtls_mpi_uint) * 8) - 224) - -/* - * Fast quasi-reduction modulo p448 = 2^448 - 2^224 - 1 - * Write N as A0 + 2^448 A1 and A1 as B0 + 2^224 B1, and return - * A0 + A1 + B1 + (B0 + B1) * 2^224. This is different to the reference - * implementation of Curve448, which uses its own special 56-bit limbs rather - * than a generic bignum library. We could squeeze some extra speed out on - * 32-bit machines by splitting N up into 32-bit limbs and doing the - * arithmetic using the limbs directly as we do for the NIST primes above, - * but for 64-bit targets it should use half the number of operations if we do - * the reduction with 224-bit limbs, since mpi_add_mpi will then use 64-bit adds. - */ -static int ecp_mod_p448(mbedtls_mpi * N) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - size_t i; - mbedtls_mpi M, Q; - mbedtls_mpi_uint Mp[P448_WIDTH + 1], Qp[P448_WIDTH]; - - if (N->n <= P448_WIDTH) - return (0); - - /* M = A1 */ - M.s = 1; - M.n = N->n - (P448_WIDTH); - if (M.n > P448_WIDTH) - /* Shouldn't be called with N larger than 2^896! */ - return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA); - M.p = Mp; - memset(Mp, 0, sizeof(Mp)); - memcpy(Mp, N->p + P448_WIDTH, M.n * sizeof(mbedtls_mpi_uint)); - - /* N = A0 */ - for (i = P448_WIDTH; i < N->n; i++) - N->p[i] = 0; - - /* N += A1 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mpi(N, N, &M)); - - /* Q = B1, N += B1 */ - Q = M; - Q.p = Qp; - memcpy(Qp, Mp, sizeof(Qp)); - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_r(&Q, 224)); - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mpi(N, N, &Q)); - - /* M = (B0 + B1) * 2^224, N += M */ - if (sizeof(mbedtls_mpi_uint) > 4) - Mp[P224_WIDTH_MIN] &= ((mbedtls_mpi_uint) -1) >> (P224_UNUSED_BITS); - for (i = P224_WIDTH_MAX; i < M.n; ++i) - Mp[i] = 0; - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mpi(&M, &M, &Q)); - M.n = P448_WIDTH + 1; /* Make room for shifted carry bit from the addition */ - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_l(&M, 224)); - MBEDTLS_MPI_CHK(mbedtls_mpi_add_mpi(N, N, &M)); - -cleanup: - return (ret); -} -#endif /* MBEDTLS_ECP_DP_CURVE448_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) || defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) || \ - defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) -/* - * Fast quasi-reduction modulo P = 2^s - R, - * with R about 33 bits, used by the Koblitz curves. - * - * Write N as A0 + 2^224 A1, return A0 + R * A1. - * Actually do two passes, since R is big. - */ -#define P_KOBLITZ_MAX (256 / 8 / sizeof(mbedtls_mpi_uint)) // Max limbs in P -#define P_KOBLITZ_R (8 / sizeof(mbedtls_mpi_uint)) // Limbs in R -static inline int ecp_mod_koblitz(mbedtls_mpi * N, mbedtls_mpi_uint * Rp, size_t p_limbs, size_t adjust, size_t shift, - mbedtls_mpi_uint mask) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - size_t i; - mbedtls_mpi M, R; - mbedtls_mpi_uint Mp[P_KOBLITZ_MAX + P_KOBLITZ_R + 1]; - - if (N->n < p_limbs) - return (0); - - /* Init R */ - R.s = 1; - R.p = Rp; - R.n = P_KOBLITZ_R; - - /* Common setup for M */ - M.s = 1; - M.p = Mp; - - /* M = A1 */ - M.n = N->n - (p_limbs - adjust); - if (M.n > p_limbs + adjust) - M.n = p_limbs + adjust; - memset(Mp, 0, sizeof Mp); - memcpy(Mp, N->p + p_limbs - adjust, M.n * sizeof(mbedtls_mpi_uint)); - if (shift != 0) - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_r(&M, shift)); - M.n += R.n; /* Make room for multiplication by R */ - - /* N = A0 */ - if (mask != 0) - N->p[p_limbs - 1] &= mask; - for (i = p_limbs; i < N->n; i++) - N->p[i] = 0; - - /* N = A0 + R * A1 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mpi(&M, &M, &R)); - MBEDTLS_MPI_CHK(mbedtls_mpi_add_abs(N, N, &M)); - - /* Second pass */ - - /* M = A1 */ - M.n = N->n - (p_limbs - adjust); - if (M.n > p_limbs + adjust) - M.n = p_limbs + adjust; - memset(Mp, 0, sizeof Mp); - memcpy(Mp, N->p + p_limbs - adjust, M.n * sizeof(mbedtls_mpi_uint)); - if (shift != 0) - MBEDTLS_MPI_CHK(mbedtls_mpi_shift_r(&M, shift)); - M.n += R.n; /* Make room for multiplication by R */ - - /* N = A0 */ - if (mask != 0) - N->p[p_limbs - 1] &= mask; - for (i = p_limbs; i < N->n; i++) - N->p[i] = 0; - - /* N = A0 + R * A1 */ - MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mpi(&M, &M, &R)); - MBEDTLS_MPI_CHK(mbedtls_mpi_add_abs(N, N, &M)); - -cleanup: - return (ret); -} -#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED) || \ - MBEDTLS_ECP_DP_SECP224K1_ENABLED) || \ - MBEDTLS_ECP_DP_SECP256K1_ENABLED) */ - -#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) -/* - * Fast quasi-reduction modulo p192k1 = 2^192 - R, - * with R = 2^32 + 2^12 + 2^8 + 2^7 + 2^6 + 2^3 + 1 = 0x0100001119 - */ -static int ecp_mod_p192k1(mbedtls_mpi * N) -{ - static mbedtls_mpi_uint Rp[] = { MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x11, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00) }; - - return (ecp_mod_koblitz(N, Rp, 192 / 8 / sizeof(mbedtls_mpi_uint), 0, 0, 0)); -} -#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) -/* - * Fast quasi-reduction modulo p224k1 = 2^224 - R, - * with R = 2^32 + 2^12 + 2^11 + 2^9 + 2^7 + 2^4 + 2 + 1 = 0x0100001A93 - */ -static int ecp_mod_p224k1(mbedtls_mpi * N) -{ - static mbedtls_mpi_uint Rp[] = { MBEDTLS_BYTES_TO_T_UINT_8(0x93, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00) }; - -#if defined(MBEDTLS_HAVE_INT64) - return (ecp_mod_koblitz(N, Rp, 4, 1, 32, 0xFFFFFFFF)); -#else - return (ecp_mod_koblitz(N, Rp, 224 / 8 / sizeof(mbedtls_mpi_uint), 0, 0, 0)); -#endif -} - -#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) -/* - * Fast quasi-reduction modulo p256k1 = 2^256 - R, - * with R = 2^32 + 2^9 + 2^8 + 2^7 + 2^6 + 2^4 + 1 = 0x01000003D1 - */ -static int ecp_mod_p256k1(mbedtls_mpi * N) -{ - static mbedtls_mpi_uint Rp[] = { MBEDTLS_BYTES_TO_T_UINT_8(0xD1, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00) }; - return (ecp_mod_koblitz(N, Rp, 256 / 8 / sizeof(mbedtls_mpi_uint), 0, 0, 0)); -} -#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ - -#endif /* !MBEDTLS_ECP_ALT */ - -#endif /* MBEDTLS_ECP_C */ diff --git a/src/platform/telink/crypto/internal/compatibility/ecp_internal_alt.h b/src/platform/telink/crypto/internal/compatibility/ecp_internal_alt.h deleted file mode 100644 index b9afb4a8dd176a..00000000000000 --- a/src/platform/telink/crypto/internal/compatibility/ecp_internal_alt.h +++ /dev/null @@ -1,284 +0,0 @@ -/** - * \file ecp_internal_alt.h - * - * \brief Function declarations for alternative implementation of elliptic curve - * point arithmetic. - */ -/* - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -/* - * References: - * - * [1] BERNSTEIN, Daniel J. Curve25519: new Diffie-Hellman speed records. - * - * - * [2] CORON, Jean-S'ebastien. Resistance against differential power analysis - * for elliptic curve cryptosystems. In : Cryptographic Hardware and - * Embedded Systems. Springer Berlin Heidelberg, 1999. p. 292-302. - * - * - * [3] HEDABOU, Mustapha, PINEL, Pierre, et B'EN'ETEAU, Lucien. A comb method to - * render ECC resistant against Side Channel Attacks. IACR Cryptology - * ePrint Archive, 2004, vol. 2004, p. 342. - * - * - * [4] Certicom Research. SEC 2: Recommended Elliptic Curve Domain Parameters. - * - * - * [5] HANKERSON, Darrel, MENEZES, Alfred J., VANSTONE, Scott. Guide to Elliptic - * Curve Cryptography. - * - * [6] Digital Signature Standard (DSS), FIPS 186-4. - * - * - * [7] Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer - * Security (TLS), RFC 4492. - * - * - * [8] - * - * [9] COHEN, Henri. A Course in Computational Algebraic Number Theory. - * Springer Science & Business Media, 1 Aug 2000 - */ - -#ifndef MBEDTLS_ECP_INTERNAL_H -#define MBEDTLS_ECP_INTERNAL_H - -#include "mbedtls/build_info.h" - -#if defined(MBEDTLS_ECP_INTERNAL_ALT) - -/** - * \brief Indicate if the Elliptic Curve Point module extension can - * handle the group. - * - * \param grp The pointer to the elliptic curve group that will be the - * basis of the cryptographic computations. - * - * \return Non-zero if successful. - */ -unsigned char mbedtls_internal_ecp_grp_capable(const mbedtls_ecp_group * grp); - -/** - * \brief Initialise the Elliptic Curve Point module extension. - * - * If mbedtls_internal_ecp_grp_capable returns true for a - * group, this function has to be able to initialise the - * module for it. - * - * This module can be a driver to a crypto hardware - * accelerator, for which this could be an initialise function. - * - * \param grp The pointer to the group the module needs to be - * initialised for. - * - * \return 0 if successful. - */ -int mbedtls_internal_ecp_init(const mbedtls_ecp_group * grp); - -/** - * \brief Frees and deallocates the Elliptic Curve Point module - * extension. - * - * \param grp The pointer to the group the module was initialised for. - */ -void mbedtls_internal_ecp_free(const mbedtls_ecp_group * grp); - -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) - -#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) -/** - * \brief Randomize jacobian coordinates: - * (X, Y, Z) -> (l^2 X, l^3 Y, l Z) for random l. - * - * \param grp Pointer to the group representing the curve. - * - * \param pt The point on the curve to be randomised, given with Jacobian - * coordinates. - * - * \param f_rng A function pointer to the random number generator. - * - * \param p_rng A pointer to the random number generator state. - * - * \return 0 if successful. - */ -int mbedtls_internal_ecp_randomize_jac(const mbedtls_ecp_group * grp, mbedtls_ecp_point * pt, - int (*f_rng)(void *, unsigned char *, size_t), void * p_rng); -#endif - -#if defined(MBEDTLS_ECP_ADD_MIXED_ALT) -/** - * \brief Addition: R = P + Q, mixed affine-Jacobian coordinates. - * - * The coordinates of Q must be normalized (= affine), - * but those of P don't need to. R is not normalized. - * - * This function is used only as a subrutine of - * ecp_mul_comb(). - * - * Special cases: (1) P or Q is zero, (2) R is zero, - * (3) P == Q. - * None of these cases can happen as intermediate step in - * ecp_mul_comb(): - * - at each step, P, Q and R are multiples of the base - * point, the factor being less than its order, so none of - * them is zero; - * - Q is an odd multiple of the base point, P an even - * multiple, due to the choice of precomputed points in the - * modified comb method. - * So branches for these cases do not leak secret information. - * - * We accept Q->Z being unset (saving memory in tables) as - * meaning 1. - * - * Cost in field operations if done by [5] 3.22: - * 1A := 8M + 3S - * - * \param grp Pointer to the group representing the curve. - * - * \param R Pointer to a point structure to hold the result. - * - * \param P Pointer to the first summand, given with Jacobian - * coordinates - * - * \param Q Pointer to the second summand, given with affine - * coordinates. - * - * \return 0 if successful. - */ -int mbedtls_internal_ecp_add_mixed(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_ecp_point * P, - const mbedtls_ecp_point * Q); -#endif - -/** - * \brief Point doubling R = 2 P, Jacobian coordinates. - * - * Cost: 1D := 3M + 4S (A == 0) - * 4M + 4S (A == -3) - * 3M + 6S + 1a otherwise - * when the implementation is based on the "dbl-1998-cmo-2" - * doubling formulas in [8] and standard optimizations are - * applied when curve parameter A is one of { 0, -3 }. - * - * \param grp Pointer to the group representing the curve. - * - * \param R Pointer to a point structure to hold the result. - * - * \param P Pointer to the point that has to be doubled, given with - * Jacobian coordinates. - * - * \return 0 if successful. - */ -#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) -int mbedtls_internal_ecp_double_jac(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_ecp_point * P); -#endif - -/** - * \brief Normalize jacobian coordinates of an array of (pointers to) - * points. - * - * Using Montgomery's trick to perform only one inversion mod P - * the cost is: - * 1N(t) := 1I + (6t - 3)M + 1S - * (See for example Algorithm 10.3.4. in [9]) - * - * This function is used only as a subrutine of - * ecp_mul_comb(). - * - * Warning: fails (returning an error) if one of the points is - * zero! - * This should never happen, see choice of w in ecp_mul_comb(). - * - * \param grp Pointer to the group representing the curve. - * - * \param T Array of pointers to the points to normalise. - * - * \param t_len Number of elements in the array. - * - * \return 0 if successful, - * an error if one of the points is zero. - */ -#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) -int mbedtls_internal_ecp_normalize_jac_many(const mbedtls_ecp_group * grp, mbedtls_ecp_point * T[], size_t t_len); -#endif - -/** - * \brief Normalize jacobian coordinates so that Z == 0 || Z == 1. - * - * Cost in field operations if done by [5] 3.2.1: - * 1N := 1I + 3M + 1S - * - * \param grp Pointer to the group representing the curve. - * - * \param pt pointer to the point to be normalised. This is an - * input/output parameter. - * - * \return 0 if successful. - */ -#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) -int mbedtls_internal_ecp_normalize_jac(const mbedtls_ecp_group * grp, mbedtls_ecp_point * pt); -#endif - -#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) - -#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) -int mbedtls_internal_ecp_double_add_mxz(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, mbedtls_ecp_point * S, - const mbedtls_ecp_point * P, const mbedtls_ecp_point * Q, const mbedtls_mpi * d); -#endif - -/** - * \brief Randomize projective x/z coordinates: - * (X, Z) -> (l X, l Z) for random l - * - * \param grp pointer to the group representing the curve - * - * \param P the point on the curve to be randomised given with - * projective coordinates. This is an input/output parameter. - * - * \param f_rng a function pointer to the random number generator - * - * \param p_rng a pointer to the random number generator state - * - * \return 0 if successful - */ -#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) -int mbedtls_internal_ecp_randomize_mxz(const mbedtls_ecp_group * grp, mbedtls_ecp_point * P, - int (*f_rng)(void *, unsigned char *, size_t), void * p_rng); -#endif - -/** - * \brief Normalize Montgomery x/z coordinates: X = X/Z, Z = 1. - * - * \param grp pointer to the group representing the curve - * - * \param P pointer to the point to be normalised. This is an - * input/output parameter. - * - * \return 0 if successful - */ -#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) -int mbedtls_internal_ecp_normalize_mxz(const mbedtls_ecp_group * grp, mbedtls_ecp_point * P); -#endif - -#endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */ - -#endif /* MBEDTLS_ECP_INTERNAL_ALT */ - -#endif /* ecp_internal_alt.h */ diff --git a/src/platform/telink/crypto/internal/compatibility/ecp_invasive.h b/src/platform/telink/crypto/internal/compatibility/ecp_invasive.h deleted file mode 100644 index ce1ff6f0681730..00000000000000 --- a/src/platform/telink/crypto/internal/compatibility/ecp_invasive.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * \file ecp_invasive.h - * - * \brief ECP module: interfaces for invasive testing only. - * - * The interfaces in this file are intended for testing purposes only. - * They SHOULD NOT be made available in library integrations except when - * building the library for testing. - */ -/* - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ -#ifndef MBEDTLS_ECP_INVASIVE_H -#define MBEDTLS_ECP_INVASIVE_H - -#include "../common.h" -#include "mbedtls/bignum.h" -#include "mbedtls/ecp.h" - -#if defined(MBEDTLS_TEST_HOOKS) && defined(MBEDTLS_ECP_C) - -#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) || defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \ - defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) -/* Preconditions: - * - bits is a multiple of 64 or is 224 - * - c is -1 or -2 - * - 0 <= N < 2^bits - * - N has room for bits plus one limb - * - * Behavior: - * Set N to c * 2^bits + old_value_of_N. - */ -void mbedtls_ecp_fix_negative(mbedtls_mpi * N, signed char c, size_t bits); -#endif - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) -/** Generate a private key on a Montgomery curve (Curve25519 or Curve448). - * - * This function implements key generation for the set of secret keys - * specified in [Curve25519] p. 5 and in [Curve448]. The resulting value - * has the lower bits masked but is not necessarily canonical. - * - * \note - [Curve25519] http://cr.yp.to/ecdh/curve25519-20060209.pdf - * - [RFC7748] https://tools.ietf.org/html/rfc7748 - * - * \p high_bit The position of the high-order bit of the key to generate. - * This is the bit-size of the key minus 1: - * 254 for Curve25519 or 447 for Curve448. - * \param d The randomly generated key. This is a number of size - * exactly \p n_bits + 1 bits, with the least significant bits - * masked as specified in [Curve25519] and in [RFC7748] §5. - * \param f_rng The RNG function. - * \param p_rng The RNG context to be passed to \p f_rng. - * - * \return \c 0 on success. - * \return \c MBEDTLS_ERR_ECP_xxx or MBEDTLS_ERR_MPI_xxx on failure. - */ -int mbedtls_ecp_gen_privkey_mx(size_t n_bits, mbedtls_mpi * d, int (*f_rng)(void *, unsigned char *, size_t), void * p_rng); - -#endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */ - -#endif /* MBEDTLS_TEST_HOOKS && MBEDTLS_ECP_C */ - -#endif /* MBEDTLS_ECP_INVASIVE_H */ diff --git a/src/platform/telink/crypto/internal/compatibility/padlock.h b/src/platform/telink/crypto/internal/compatibility/padlock.h deleted file mode 100644 index 6435a208f1d85c..00000000000000 --- a/src/platform/telink/crypto/internal/compatibility/padlock.h +++ /dev/null @@ -1,112 +0,0 @@ -/** - * \file padlock.h - * - * \brief VIA PadLock ACE for HW encryption/decryption supported by some - * processors - * - * \warning These functions are only for internal use by other library - * functions; you must not call them directly. - */ -/* - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ -#ifndef MBEDTLS_PADLOCK_H -#define MBEDTLS_PADLOCK_H - -#include "mbedtls/build_info.h" - -#include "mbedtls/aes.h" - -#define MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED -0x0030 /**< Input data should be aligned. */ - -#if defined(__has_feature) -#if __has_feature(address_sanitizer) -#define MBEDTLS_HAVE_ASAN -#endif -#endif - -/* Some versions of ASan result in errors about not enough registers */ -#if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && defined(__i386__) && !defined(MBEDTLS_HAVE_ASAN) - -#ifndef MBEDTLS_HAVE_X86 -#define MBEDTLS_HAVE_X86 -#endif - -#include - -#define MBEDTLS_PADLOCK_RNG 0x000C -#define MBEDTLS_PADLOCK_ACE 0x00C0 -#define MBEDTLS_PADLOCK_PHE 0x0C00 -#define MBEDTLS_PADLOCK_PMM 0x3000 - -#define MBEDTLS_PADLOCK_ALIGN16(x) (uint32_t *) (16 + ((int32_t)(x) & ~15)) - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Internal PadLock detection routine - * - * \note This function is only for internal use by other library - * functions; you must not call it directly. - * - * \param feature The feature to detect - * - * \return non-zero if CPU has support for the feature, 0 otherwise - */ -int mbedtls_padlock_has_support(int feature); - -/** - * \brief Internal PadLock AES-ECB block en(de)cryption - * - * \note This function is only for internal use by other library - * functions; you must not call it directly. - * - * \param ctx AES context - * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT - * \param input 16-byte input block - * \param output 16-byte output block - * - * \return 0 if success, 1 if operation failed - */ -int mbedtls_padlock_xcryptecb(mbedtls_aes_context * ctx, int mode, const unsigned char input[16], unsigned char output[16]); - -/** - * \brief Internal PadLock AES-CBC buffer en(de)cryption - * - * \note This function is only for internal use by other library - * functions; you must not call it directly. - * - * \param ctx AES context - * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT - * \param length length of the input data - * \param iv initialization vector (updated after use) - * \param input buffer holding the input data - * \param output buffer holding the output data - * - * \return 0 if success, 1 if operation failed - */ -int mbedtls_padlock_xcryptcbc(mbedtls_aes_context * ctx, int mode, size_t length, unsigned char iv[16], const unsigned char * input, - unsigned char * output); - -#ifdef __cplusplus -} -#endif - -#endif /* HAVE_X86 */ - -#endif /* padlock.h */ diff --git a/src/platform/telink/crypto/internal/ecp_alt_b91_backend.c b/src/platform/telink/crypto/internal/ecp_alt_b91_backend.c deleted file mode 100644 index d28f0bbbcb6f81..00000000000000 --- a/src/platform/telink/crypto/internal/ecp_alt_b91_backend.c +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Elliptic curves over GF(p): generic functions - * - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -/* - * References: - * - * SEC1 http://www.secg.org/index.php?action=secg,docs_secg - * GECC = Guide to Elliptic Curve Cryptography - Hankerson, Menezes, Vanstone - * FIPS 186-3 http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf - * RFC 4492 for the related TLS structures and constants - * RFC 7748 for the Curve448 and Curve25519 curve definitions - * - * [Curve25519] http://cr.yp.to/ecdh/curve25519-20060209.pdf - * - * [2] CORON, Jean-S'ebastien. Resistance against differential power analysis - * for elliptic curve cryptosystems. In : Cryptographic Hardware and - * Embedded Systems. Springer Berlin Heidelberg, 1999. p. 292-302. - * - * - * [3] HEDABOU, Mustapha, PINEL, Pierre, et B'EN'ETEAU, Lucien. A comb method to - * render ECC resistant against Side Channel Attacks. IACR Cryptology - * ePrint Archive, 2004, vol. 2004, p. 342. - * - */ - -#include "common.h" - -#if defined(MBEDTLS_ECP_C) - -#include "mbedtls/ecp.h" -#include "mbedtls/error.h" -#include "multithread.h" -#include "pke.h" -#include - -#if defined(MBEDTLS_ECP_ALT) - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Woverride-init" -#pragma GCC diagnostic ignored "-Wvla" -#pragma GCC diagnostic ignored "-Wstack-usage=" - -/**************************************************************** - * HW unit curve data constants definition - ****************************************************************/ - -#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) -static eccp_curve_t secp256r1 = { - .eccp_p_bitLen = 256, - .eccp_p = (unsigned int[]){ 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0xffffffff }, - .eccp_p_h = (unsigned int[]){ 0x00000003, 0x00000000, 0xffffffff, 0xfffffffb, 0xfffffffe, 0xffffffff, 0xfffffffd, 0x00000004 }, - .eccp_p_h = (unsigned int[]){ 0x00000001 }, - .eccp_a = (unsigned int[]){ 0xfffffffc, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0xffffffff }, - .eccp_b = (unsigned int[]){ 0x27d2604b, 0x3bce3c3e, 0xcc53b0f6, 0x651d06b0, 0x769886bc, 0xb3ebbd55, 0xaa3a93e7, 0x5ac635d8 } -}; -#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) -static eccp_curve_t secp256k1 = { - .eccp_p_bitLen = 256, - .eccp_p = (unsigned int[]){ 0xfffffc2f, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }, - .eccp_p_h = (unsigned int[]){ 0x000e90a1, 0x000007a2, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, - .eccp_p_h = (unsigned int[]){ 0xd2253531 }, - .eccp_a = (unsigned int[]){ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, - .eccp_b = (unsigned int[]){ 0x00000007, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } -}; -#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) -static eccp_curve_t BP256r1 = { - .eccp_p_bitLen = 256, - .eccp_p = (unsigned int[]){ 0x1f6e5377, 0x2013481d, 0xd5262028, 0x6e3bf623, 0x9d838d72, 0x3e660a90, 0xa1eea9bc, 0xa9fb57db }, - .eccp_p_h = (unsigned int[]){ 0xa6465b6c, 0x8cfedf7b, 0x614d4f4d, 0x5cce4c26, 0x6b1ac807, 0xa1ecdacd, 0xe5957fa8, 0x4717aa21 }, - .eccp_p_h = (unsigned int[]){ 0xcefd89b9 }, - .eccp_a = (unsigned int[]){ 0xf330b5d9, 0xe94a4b44, 0x26dc5c6c, 0xfb8055c1, 0x417affe7, 0xeef67530, 0xfc2c3057, 0x7d5a0975 }, - .eccp_b = (unsigned int[]){ 0xff8c07b6, 0x6bccdc18, 0x5cf7e1ce, 0x95841629, 0xbbd77cbf, 0xf330b5d9, 0xe94a4b44, 0x26dc5c6c } -}; -#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) -static eccp_curve_t secp224r1 = { - .eccp_p_bitLen = 224, - .eccp_p = (unsigned int[]){ 0x00000001, 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }, - .eccp_p_h = (unsigned int[]){ 0x00000001, 0x00000000, 0x00000000, 0xfffffffe, 0xffffffff, 0xffffffff, 0x00000000 }, - .eccp_p_h = (unsigned int[]){ 0xffffffff }, - .eccp_a = (unsigned int[]){ 0xfffffffe, 0xffffffff, 0xffffffff, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff }, - .eccp_b = (unsigned int[]){ 0x2355ffb4, 0x270b3943, 0xd7bfd8ba, 0x5044b0b7, 0xf5413256, 0x0c04b3ab, 0xb4050a85 } -}; -#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) -static eccp_curve_t secp224k1 = { - .eccp_p_bitLen = 224, - .eccp_p = (unsigned int[]){ 0xffffe56d, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }, - .eccp_p_h = (unsigned int[]){ 0x02c23069, 0x00003526, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, - .eccp_p_h = (unsigned int[]){ 0x198d139b }, - .eccp_a = (unsigned int[]){ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, - .eccp_b = (unsigned int[]){ 0x00000005, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } -}; -#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) -static eccp_curve_t secp192r1 = { - .eccp_p_bitLen = 192, - .eccp_p = (unsigned int[]){ 0xffffffff, 0xffffffff, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff }, - .eccp_p_h = (unsigned int[]){ 0x00000001, 0x00000000, 0x00000002, 0x00000000, 0x00000001, 0x00000000 }, - .eccp_p_h = (unsigned int[]){ 0x00000001 }, - .eccp_a = (unsigned int[]){ 0xfffffffc, 0xffffffff, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff }, - .eccp_b = (unsigned int[]){ 0xc146b9b1, 0xfeb8deec, 0x72243049, 0x0fa7e9ab, 0xe59c80e7, 0x64210519 } -}; -#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) -static eccp_curve_t secp192k1 = { - .eccp_p_bitLen = 192, - .eccp_p = (unsigned int[]){ 0xffffee37, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }, - .eccp_p_h = (unsigned int[]){ 0x013c4fd1, 0x00002392, 0x00000001, 0x00000000, 0x00000000, 0x00000000 }, - .eccp_p_h = (unsigned int[]){ 0x7446d879 }, - .eccp_a = (unsigned int[]){ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, - .eccp_b = (unsigned int[]){ 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } -}; -#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ - -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) -static mont_curve_t x25519 = { - .mont_p_bitLen = 255, - .mont_p = (unsigned int[]){ 0xffffffed, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff }, - .mont_p_h = (unsigned int[]){ 0x000005a4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, - .mont_p_n1 = (unsigned int[]){ 0x286bca1b }, - .mont_a24 = (unsigned int[]){ 0x0001db41, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } -}; -#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ - -/**************************************************************** - * Linking mbedtls to HW unit curve data - ****************************************************************/ - -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) -static const struct -{ - mbedtls_ecp_group_id group; - eccp_curve_t * curve_dat; -} eccp_curve_linking[] = { -#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) - { .group = MBEDTLS_ECP_DP_SECP256R1, .curve_dat = &secp256r1 }, -#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) - { .group = MBEDTLS_ECP_DP_SECP256K1, .curve_dat = &secp256k1 }, -#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) - { .group = MBEDTLS_ECP_DP_BP256R1, .curve_dat = &BP256r1 }, -#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) - { .group = MBEDTLS_ECP_DP_SECP224R1, .curve_dat = &secp224r1 }, -#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) - { .group = MBEDTLS_ECP_DP_SECP224K1, .curve_dat = &secp224k1 }, -#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) - { .group = MBEDTLS_ECP_DP_SECP192R1, .curve_dat = &secp192r1 }, -#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) - { .group = MBEDTLS_ECP_DP_SECP192K1, .curve_dat = &secp192k1 } -#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ -}; -#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) -static const struct -{ - mbedtls_ecp_group_id group; - mont_curve_t * curve_dat; -} mont_curve_linking[] = { -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) - { .group = MBEDTLS_ECP_DP_CURVE25519, .curve_dat = &x25519 } -#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ -}; -#endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */ - -/**************************************************************** - * Private functions declaration - ****************************************************************/ - -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) -static eccp_curve_t * eccp_curve_get(const mbedtls_ecp_group * grp) -{ - eccp_curve_t * eccp_curve = NULL; - - for (size_t i = 0; i < sizeof(eccp_curve_linking) / sizeof(eccp_curve_linking[0]); i++) - { - if (eccp_curve_linking[i].group == grp->id) - { - eccp_curve = eccp_curve_linking[i].curve_dat; - break; - } - } - - return eccp_curve; -} -#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ - -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) -static mont_curve_t * mont_curve_get(const mbedtls_ecp_group * grp) -{ - mont_curve_t * mont_curve = NULL; - - for (size_t i = 0; i < sizeof(mont_curve_linking) / sizeof(mont_curve_linking[0]); i++) - { - if (mont_curve_linking[i].group == grp->id) - { - mont_curve = mont_curve_linking[i].curve_dat; - break; - } - } - - return mont_curve; -} -#endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */ - -/**************************************************************** - * Public functions declaration - ****************************************************************/ - -int ecp_alt_b91_backend_check_pubkey(const mbedtls_ecp_group * grp, const mbedtls_ecp_point * pt) -{ - int result = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; - - if (grp != NULL && pt != NULL) - { - result = MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED; - const unsigned int word_len = GET_WORD_LEN(grp->pbits); - - if (word_len <= PKE_OPERAND_MAX_WORD_LEN) - { - unsigned int Qx[word_len], Qy[word_len]; - -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS) - { - eccp_curve_t * eccp_curve = eccp_curve_get(grp); - if (eccp_curve != NULL) - { - (void) mbedtls_mpi_write_binary_le(&pt->X, (unsigned char *) Qx, sizeof(Qx)); - (void) mbedtls_mpi_write_binary_le(&pt->Y, (unsigned char *) Qy, sizeof(Qy)); - - mbedtls_ecp_lock(); - if (pke_eccp_point_verify(eccp_curve, Qx, Qy) == PKE_SUCCESS) - result = 0; - else - result = MBEDTLS_ERR_ECP_INVALID_KEY; - mbedtls_ecp_unlock(); - } - } -#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ - - memset(Qx, 0, sizeof(Qx)); - memset(Qy, 0, sizeof(Qy)); - } - } - return result; -} - -int ecp_alt_b91_backend_mul(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P) -{ - int result = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; - - if (grp != NULL && R != NULL && m != NULL && P != NULL) - { - - result = MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED; - const unsigned int word_len = GET_WORD_LEN(grp->pbits); - - if (word_len <= PKE_OPERAND_MAX_WORD_LEN) - { - unsigned int ms[word_len], Qx[word_len], Qy[word_len]; - -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS) - { - eccp_curve_t * eccp_curve = eccp_curve_get(grp); - if (eccp_curve != NULL) - { - (void) mbedtls_mpi_write_binary_le(m, (unsigned char *) ms, sizeof(ms)); - (void) mbedtls_mpi_write_binary_le(&P->X, (unsigned char *) Qx, sizeof(Qx)); - (void) mbedtls_mpi_write_binary_le(&P->Y, (unsigned char *) Qy, sizeof(Qy)); - - mbedtls_ecp_lock(); - if (pke_eccp_point_mul(eccp_curve, ms, Qx, Qy, Qx, Qy) == PKE_SUCCESS) - { - (void) mbedtls_mpi_read_binary_le(&R->X, (const unsigned char *) Qx, sizeof(Qx)); - (void) mbedtls_mpi_read_binary_le(&R->Y, (const unsigned char *) Qy, sizeof(Qy)); - (void) mbedtls_mpi_lset(&R->Z, 1); - result = 0; - } - else - result = MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED; - mbedtls_ecp_unlock(); - } - } -#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ -#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_MONTGOMERY) - { - mont_curve_t * mont_curve = mont_curve_get(grp); - if (mont_curve != NULL) - { - (void) mbedtls_mpi_write_binary_le(m, (unsigned char *) ms, sizeof(ms)); - (void) mbedtls_mpi_write_binary_le(&P->X, (unsigned char *) Qx, sizeof(Qx)); - - mbedtls_ecp_lock(); - if (pke_x25519_point_mul(mont_curve, ms, Qx, Qx) == PKE_SUCCESS) - { - (void) mbedtls_mpi_read_binary_le(&R->X, (const unsigned char *) Qx, sizeof(Qx)); - (void) mbedtls_mpi_lset(&R->Y, 0); - (void) mbedtls_mpi_lset(&R->Z, 1); - result = 0; - } - else - result = MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED; - mbedtls_ecp_unlock(); - } - } -#endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */ - - memset(ms, 0, sizeof(ms)); - memset(Qx, 0, sizeof(Qx)); - memset(Qy, 0, sizeof(Qy)); - } - } - return result; -} - -int ecp_alt_b91_backend_muladd(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, - const mbedtls_mpi * n, const mbedtls_ecp_point * Q) -{ - - int result = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; - - if (grp != NULL && R != NULL && m != NULL && P != NULL && n != NULL && Q != NULL) - { - - result = MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED; - const unsigned int word_len = GET_WORD_LEN(grp->pbits); - - if (word_len <= PKE_OPERAND_MAX_WORD_LEN) - { - unsigned int ms[word_len], Q1x[word_len], Q1y[word_len], Q2x[word_len], Q2y[word_len]; - -#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED) - if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS) - { - eccp_curve_t * eccp_curve = eccp_curve_get(grp); - if (eccp_curve != NULL) - { - (void) mbedtls_mpi_write_binary_le(&P->X, (unsigned char *) Q1x, sizeof(Q1x)); - (void) mbedtls_mpi_write_binary_le(&P->Y, (unsigned char *) Q1y, sizeof(Q1y)); - (void) mbedtls_mpi_write_binary_le(&Q->X, (unsigned char *) Q2x, sizeof(Q2x)); - (void) mbedtls_mpi_write_binary_le(&Q->Y, (unsigned char *) Q2y, sizeof(Q2y)); - - result = MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED; - - mbedtls_ecp_lock(); - - do - { - (void) mbedtls_mpi_write_binary_le(m, (unsigned char *) ms, sizeof(ms)); - if (pke_eccp_point_mul(eccp_curve, ms, Q1x, Q1y, Q1x, Q1y) != PKE_SUCCESS) - break; - - (void) mbedtls_mpi_write_binary_le(n, (unsigned char *) ms, sizeof(ms)); - if (pke_eccp_point_mul(eccp_curve, ms, Q2x, Q2y, Q2x, Q2y) != PKE_SUCCESS) - break; - - if (pke_eccp_point_add(eccp_curve, Q1x, Q1y, Q2x, Q2y, Q1x, Q1y) != PKE_SUCCESS) - break; - - (void) mbedtls_mpi_read_binary_le(&R->X, (const unsigned char *) Q1x, sizeof(Q1x)); - (void) mbedtls_mpi_read_binary_le(&R->Y, (const unsigned char *) Q1y, sizeof(Q1y)); - (void) mbedtls_mpi_lset(&R->Z, 1); - result = 0; - - } while (0); - - mbedtls_ecp_unlock(); - } - } -#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ - - memset(ms, 0, sizeof(ms)); - memset(Q1x, 0, sizeof(Q1x)); - memset(Q1y, 0, sizeof(Q1y)); - memset(Q2x, 0, sizeof(Q2x)); - memset(Q2y, 0, sizeof(Q2y)); - } - } - return result; -} - -#pragma GCC diagnostic pop - -#endif /* MBEDTLS_ECP_ALT */ - -#endif /* MBEDTLS_ECP_C */ diff --git a/src/platform/telink/crypto/internal/ecp_alt_b91_backend_test.c b/src/platform/telink/crypto/internal/ecp_alt_b91_backend_test.c deleted file mode 100644 index 0e9936d688e932..00000000000000 --- a/src/platform/telink/crypto/internal/ecp_alt_b91_backend_test.c +++ /dev/null @@ -1,479 +0,0 @@ -/* - * Elliptic curves over GF(p): generic functions - * - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -#include "common.h" - -#if defined(MBEDTLS_ECP_C) - -#include "mbedtls/ctr_drbg.h" -#include "mbedtls/ecp.h" -#include "mbedtls/entropy.h" -#include "mbedtls/error.h" -#include "mbedtls/platform.h" -#include "test_utils.h" - -#if defined(MBEDTLS_ECP_ALT) - -#if defined(MBEDTLS_SELF_TEST) - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Woverride-init" -#pragma GCC diagnostic ignored "-Wvla" -#pragma GCC diagnostic ignored "-Wstack-usage=" - -/**************************************************************** - * Test vectors - ****************************************************************/ - -static const struct -{ - mbedtls_ecp_group_id ecp_group_id; - const unsigned char * sk; - const size_t sk_len; - const unsigned char * pk; - const size_t pk_len; - const unsigned char * sum; -} ecp_test_cases[] = { -#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) - { .ecp_group_id = MBEDTLS_ECP_DP_SECP521R1, - .sk = (const unsigned char[]){ 0x01, 0xeb, 0x60, 0x88, 0x03, 0x15, 0x7b, 0x13, 0xb1, 0xc3, 0x5b, 0xa8, 0x7b, 0x09, - 0xa4, 0x2e, 0xa6, 0x0f, 0xc7, 0x06, 0x66, 0x55, 0x22, 0x57, 0x0c, 0x08, 0x5a, 0x50, - 0xa4, 0x44, 0x5f, 0xea, 0x85, 0xed, 0x7f, 0xf3, 0xcf, 0x0c, 0x01, 0xd9, 0x4a, 0x87, - 0x9e, 0xcc, 0xa4, 0x60, 0x1b, 0x3d, 0x08, 0xfb, 0x37, 0x8d, 0x51, 0x07, 0x76, 0xcc, - 0xf1, 0x32, 0x0d, 0x8d, 0x12, 0x41, 0x2b, 0xa4, 0x5d, 0x8d }, - .sk_len = 66, - .pk = (const unsigned char[]){ 0x04, 0x00, 0xef, 0xa5, 0x11, 0x33, 0x8b, 0x71, 0xba, 0x23, 0x9a, 0x37, 0xed, 0xad, 0xfa, - 0xf6, 0x94, 0x3f, 0xac, 0x7e, 0x23, 0x63, 0x4f, 0xcd, 0xad, 0x45, 0x70, 0xa9, 0x0b, 0x26, - 0xee, 0x96, 0x4f, 0x7e, 0x46, 0xce, 0xa7, 0xe5, 0x1f, 0xa3, 0xcc, 0xa5, 0xe1, 0x64, 0x57, - 0x92, 0x1a, 0x29, 0xa4, 0x1a, 0x0c, 0x82, 0xd4, 0x40, 0x59, 0x20, 0x20, 0x99, 0x87, 0xf3, - 0x46, 0x04, 0x9e, 0x25, 0x1a, 0x6d, 0x21, 0x01, 0x2a, 0xd3, 0x86, 0x7a, 0x8c, 0xcc, 0xfa, - 0x68, 0x99, 0x1f, 0xc5, 0x60, 0x35, 0x7b, 0x34, 0x8f, 0xf1, 0xfd, 0xa3, 0x5a, 0xac, 0x9b, - 0x09, 0xdf, 0xa5, 0x44, 0x45, 0xd8, 0xc9, 0x49, 0xa9, 0x05, 0xa5, 0x45, 0xba, 0xfc, 0x3b, - 0xb4, 0xe0, 0xda, 0x9d, 0x67, 0x3d, 0xb4, 0x05, 0xa7, 0x39, 0x57, 0xa2, 0x7d, 0x12, 0x6f, - 0x5c, 0x34, 0xab, 0xc1, 0x8d, 0xef, 0xe0, 0xec, 0x9a, 0xed, 0xad, 0x1b, 0x71 }, - .pk_len = 133, - .sum = (const unsigned char[]){ 0x04, 0x01, 0x68, 0x45, 0x34, 0x25, 0x5b, 0xad, 0x67, 0x54, 0x6b, 0x7c, 0x45, 0xe7, 0x60, - 0x7b, 0xe7, 0x2f, 0xe4, 0x94, 0xf6, 0x28, 0x06, 0x74, 0x0d, 0x85, 0xe4, 0xba, 0xcb, 0xec, - 0x51, 0xed, 0x37, 0xda, 0xbb, 0xf0, 0xb5, 0xa9, 0x07, 0xe4, 0xca, 0xed, 0x79, 0xb1, 0x2d, - 0xce, 0xf8, 0x4d, 0x7a, 0xee, 0x85, 0x41, 0x48, 0xac, 0x16, 0x51, 0x20, 0x88, 0x1e, 0x49, - 0x03, 0xc5, 0x1f, 0x99, 0x3f, 0x8a, 0x7d, 0x00, 0x10, 0xe1, 0xb7, 0xf9, 0x28, 0x76, 0xe4, - 0xf5, 0x36, 0xc0, 0x57, 0xd5, 0xf9, 0xba, 0xab, 0x49, 0x32, 0xf9, 0x84, 0xa9, 0x53, 0x14, - 0x73, 0xfe, 0xfe, 0xf3, 0xe9, 0xa2, 0xf4, 0x0d, 0xa6, 0x3c, 0xd7, 0x3a, 0x3b, 0xfc, 0x30, - 0xaa, 0xff, 0x2c, 0x86, 0x7a, 0xa7, 0xf0, 0x0b, 0x83, 0xb7, 0x3a, 0x98, 0x52, 0xac, 0x66, - 0x0c, 0x4c, 0x4b, 0x49, 0x9f, 0xea, 0xfa, 0x2b, 0xa6, 0x32, 0xe4, 0x87, 0xbf } }, -#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) - { .ecp_group_id = MBEDTLS_ECP_DP_BP512R1, - .sk = - (const unsigned char[]){ 0x64, 0x35, 0x05, 0x6c, 0x1d, 0x98, 0xc8, 0xe1, 0x30, 0x5e, 0xf4, 0x11, 0x2c, 0x05, 0x68, 0x98, - 0x31, 0xf4, 0xba, 0x16, 0xf4, 0x67, 0x9a, 0x78, 0x6a, 0x8f, 0x7c, 0x18, 0x36, 0xca, 0x3f, 0xd4, - 0xc1, 0x4a, 0x9b, 0xfd, 0x32, 0x70, 0x68, 0x76, 0xb1, 0xc8, 0x1d, 0x9a, 0xae, 0x8a, 0x24, 0x01, - 0xad, 0xf7, 0x45, 0x36, 0x18, 0x23, 0x9e, 0x3e, 0x1e, 0xf2, 0xfa, 0x03, 0x35, 0xd1, 0xad, 0x92 }, - .sk_len = 64, - .pk = (const unsigned char[]){ 0x04, 0x47, 0x6a, 0x9d, 0x4e, 0xb4, 0xb9, 0x1c, 0x82, 0x11, 0xa4, 0xff, 0x40, 0x60, 0xf1, - 0x34, 0xd8, 0x29, 0x26, 0xa8, 0xd8, 0xcc, 0x08, 0x38, 0x5d, 0xe4, 0x93, 0xc0, 0xfc, 0xb2, - 0xe5, 0x60, 0x39, 0x1f, 0x7c, 0x37, 0x60, 0x77, 0xc6, 0x1d, 0x4b, 0x4d, 0x3c, 0x61, 0xcf, - 0x6e, 0x38, 0x44, 0x37, 0x7c, 0x7f, 0x42, 0x7b, 0xbf, 0x8e, 0x45, 0x79, 0x53, 0x8a, 0x94, - 0x4d, 0xef, 0x08, 0xb0, 0x99, 0x92, 0xce, 0xa2, 0xa7, 0x87, 0xda, 0x2c, 0x92, 0x2a, 0x59, - 0x58, 0xc4, 0xa2, 0x05, 0x77, 0x8a, 0x31, 0x68, 0x36, 0xf4, 0x4d, 0x61, 0xb3, 0x27, 0x97, - 0xc5, 0x98, 0x24, 0xed, 0x6c, 0x28, 0x8c, 0xee, 0xd8, 0x2c, 0xc3, 0x90, 0xf1, 0x36, 0xc6, - 0x62, 0xca, 0x3c, 0xb9, 0xa4, 0x4f, 0x27, 0x92, 0x7f, 0x8b, 0x43, 0x36, 0x43, 0x04, 0x82, - 0xb7, 0x4b, 0x52, 0x9a, 0x02, 0xc9, 0x2a, 0x08, 0x36 }, - .pk_len = 129, - .sum = (const unsigned char[]){ 0x04, 0x1d, 0x10, 0xaa, 0xb7, 0x2b, 0x6b, 0x1c, 0x8e, 0xde, 0x85, 0x9b, 0xf3, 0x8c, 0xaf, - 0xbb, 0x86, 0xdd, 0xc9, 0x0b, 0xc0, 0xdc, 0x28, 0x1c, 0xf4, 0x1e, 0x81, 0x9d, 0x8a, 0x93, - 0x43, 0xcf, 0xf9, 0xfe, 0x30, 0xb2, 0x04, 0x50, 0x08, 0x96, 0x1c, 0x61, 0xc7, 0x5c, 0xea, - 0x28, 0xef, 0x9e, 0x9a, 0x34, 0xaf, 0x77, 0x2b, 0x89, 0x63, 0x6d, 0x81, 0x72, 0x6a, 0x72, - 0x3d, 0xca, 0x10, 0x1f, 0xfc, 0x9d, 0xe5, 0x89, 0xd7, 0x82, 0x46, 0xe2, 0x59, 0x88, 0xa8, - 0x4d, 0x2c, 0x91, 0x28, 0x5d, 0x40, 0x8d, 0xc0, 0xe9, 0x4f, 0xb1, 0x70, 0xcf, 0xf3, 0x05, - 0xb6, 0xb8, 0xf9, 0xd7, 0x24, 0x7e, 0xf5, 0x9d, 0x65, 0x4f, 0xb6, 0xb8, 0x7f, 0x44, 0xae, - 0x38, 0x21, 0xbc, 0x32, 0xef, 0x6f, 0xf7, 0x8a, 0xd5, 0xa5, 0xe7, 0xee, 0xa3, 0x76, 0xc5, - 0xee, 0x1f, 0x4f, 0x7c, 0xfc, 0x8e, 0x39, 0x7b, 0xe7 } }, -#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) - { .ecp_group_id = MBEDTLS_ECP_DP_SECP384R1, - .sk = - (const unsigned char[]){ 0x35, 0x05, 0x64, 0x07, 0xb0, 0xfd, 0x3e, 0x09, 0xe3, 0x07, 0x41, 0xdc, 0x8a, 0xd3, 0xef, 0xc7, - 0xad, 0x29, 0xc5, 0x97, 0x8a, 0xbb, 0x15, 0x10, 0xac, 0xd2, 0x47, 0xac, 0xdc, 0xa7, 0x45, 0xf0, - 0x27, 0x17, 0x8f, 0x4a, 0x7a, 0xd1, 0xcc, 0xd2, 0x17, 0xc2, 0x22, 0x6a, 0x99, 0xf1, 0x8b, 0xc0 }, - .sk_len = 48, - .pk = (const unsigned char[]){ 0x04, 0xc8, 0x2d, 0xaa, 0x27, 0xd0, 0x91, 0x1f, 0x3d, 0x41, 0xf5, 0xe7, 0xa6, 0x46, - 0xae, 0xf8, 0xca, 0x74, 0x31, 0x63, 0xe2, 0x1f, 0x38, 0x25, 0x05, 0x5f, 0xa0, 0xfa, - 0x49, 0x51, 0x71, 0xea, 0x4f, 0xb6, 0x1a, 0xc3, 0xfd, 0xf3, 0x8e, 0x95, 0xe6, 0xfe, - 0x7b, 0xff, 0x65, 0x26, 0xd4, 0xf0, 0x8e, 0x06, 0x70, 0x03, 0x10, 0xba, 0xd8, 0x7c, - 0x54, 0x55, 0x23, 0x18, 0x57, 0x27, 0x6d, 0xe2, 0xc4, 0x4e, 0x30, 0xb7, 0x36, 0xdc, - 0x15, 0xb6, 0xdf, 0xaf, 0xb0, 0xe4, 0x78, 0xbb, 0xad, 0x1d, 0xf0, 0x50, 0x00, 0xbd, - 0x90, 0xfa, 0x4c, 0xb3, 0x3d, 0xbc, 0xf9, 0x54, 0xf6, 0x61, 0xaf, 0xcb, 0xfc }, - .pk_len = 97, - .sum = (const unsigned char[]){ 0x04, 0xf5, 0xf1, 0x09, 0xb7, 0x3d, 0x7e, 0x05, 0x13, 0xc7, 0x6a, 0x99, 0x17, 0xcf, - 0x3b, 0x5a, 0x5a, 0x04, 0x1a, 0x6e, 0xa4, 0x23, 0x9d, 0x47, 0xab, 0x04, 0x5e, 0xe4, - 0x83, 0xa3, 0x0b, 0xac, 0x16, 0x2d, 0x6e, 0x5d, 0x87, 0x23, 0xcd, 0xbc, 0x3b, 0xdb, - 0xb7, 0x21, 0xc1, 0x18, 0x19, 0x8d, 0x3b, 0x80, 0x6f, 0x93, 0xa6, 0xbd, 0xa0, 0x72, - 0x7d, 0x58, 0x90, 0xa4, 0x87, 0x8a, 0xe4, 0x6d, 0x1c, 0xf5, 0xeb, 0x3b, 0x8b, 0x38, - 0x97, 0x42, 0x33, 0x3c, 0x9e, 0x43, 0x4d, 0x63, 0x7a, 0x21, 0x9e, 0x02, 0x7a, 0x0d, - 0x19, 0x26, 0x45, 0xa8, 0x74, 0x29, 0x7c, 0x24, 0x8e, 0x71, 0x95, 0xcf, 0x9d } }, -#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) - { .ecp_group_id = MBEDTLS_ECP_DP_BP384R1, - .sk = - (const unsigned char[]){ 0x50, 0xff, 0xbb, 0xab, 0x9c, 0x62, 0x8c, 0x3e, 0xc4, 0x1d, 0xb9, 0x00, 0x5e, 0x1a, 0xf0, 0x8d, - 0x64, 0x58, 0x44, 0x97, 0x2c, 0xf5, 0x2f, 0xcf, 0x7d, 0xb8, 0x36, 0xcc, 0x3a, 0x33, 0x46, 0x85, - 0x4c, 0xf5, 0x6f, 0x89, 0xfc, 0xd9, 0xc4, 0x98, 0xc5, 0x12, 0x8a, 0x59, 0xcb, 0xff, 0x91, 0xc7 }, - .sk_len = 48, - .pk = (const unsigned char[]){ 0x04, 0x3a, 0xef, 0x56, 0x8a, 0x8b, 0x51, 0x2b, 0xb7, 0x49, 0x3c, 0x92, 0xc4, 0x6a, - 0x12, 0xd5, 0x84, 0x2f, 0x53, 0x89, 0x8c, 0x38, 0x29, 0x3f, 0xe0, 0xbc, 0x94, 0x47, - 0x5e, 0xd1, 0x74, 0x04, 0x50, 0x31, 0x6a, 0x80, 0xc3, 0xe3, 0x69, 0x02, 0xac, 0xe7, - 0xcd, 0x21, 0x65, 0x6c, 0x1d, 0x8a, 0x1a, 0x74, 0xf8, 0x79, 0x88, 0x75, 0x42, 0xe1, - 0x7c, 0xb1, 0x7d, 0xa7, 0xf8, 0xda, 0x57, 0xdc, 0x00, 0x1f, 0xd6, 0x07, 0xa6, 0xc6, - 0x85, 0xc5, 0x8d, 0xc3, 0xaa, 0x4c, 0xd1, 0x4f, 0xf9, 0x65, 0xf0, 0x56, 0xce, 0x0f, - 0x48, 0x54, 0x9a, 0xf4, 0xe2, 0x15, 0x08, 0x05, 0x9e, 0xbc, 0xb8, 0x17, 0x03 }, - .pk_len = 97, - .sum = (const unsigned char[]){ 0x04, 0x7c, 0x9b, 0xab, 0x7c, 0x51, 0xc0, 0x36, 0x5c, 0xdd, 0x22, 0xf7, 0x10, 0xb7, - 0x39, 0x14, 0x50, 0xf9, 0xe1, 0x05, 0x09, 0x74, 0x5b, 0x1a, 0x5c, 0x21, 0xcc, 0x10, - 0xca, 0x9a, 0xf4, 0x3a, 0x72, 0x57, 0x43, 0xfb, 0x52, 0x9e, 0x6d, 0x20, 0x77, 0x4a, - 0xcd, 0x6a, 0xd8, 0xa1, 0x39, 0x94, 0x7e, 0x7e, 0x08, 0x49, 0x91, 0x98, 0x86, 0x76, - 0xb7, 0xca, 0xb8, 0xbe, 0x15, 0xd6, 0x50, 0x64, 0xb2, 0x0c, 0x07, 0x6c, 0x07, 0x0f, - 0x48, 0xd4, 0xd9, 0x95, 0x2f, 0xf0, 0xb0, 0x21, 0xd0, 0x39, 0xe0, 0x43, 0xbd, 0x40, - 0x0a, 0xa7, 0x8d, 0xaf, 0x4b, 0xc3, 0xff, 0xf6, 0x76, 0xd4, 0x19, 0x2f, 0x7f } }, -#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) - { .ecp_group_id = MBEDTLS_ECP_DP_SECP256R1, - .sk = - (const unsigned char[]){ 0x3d, 0x1d, 0x83, 0xfa, 0xf6, 0xbb, 0x86, 0xe9, 0xf8, 0x9e, 0x45, 0x6a, 0xa8, 0x29, 0x6f, 0x52, - 0x04, 0x79, 0xff, 0xc4, 0x94, 0xd8, 0xe0, 0xe7, 0xcd, 0xe8, 0xe0, 0x83, 0xab, 0xcf, 0x63, 0x0b }, - .sk_len = 32, - .pk = (const unsigned char[]){ 0x04, 0xd3, 0x48, 0xb6, 0x80, 0x35, 0x49, 0x67, 0x97, 0xc9, 0x28, 0xc4, 0xfe, - 0xa6, 0x13, 0xe1, 0xb3, 0xee, 0x51, 0x95, 0xfd, 0x20, 0x7f, 0xe7, 0xdc, 0x7d, - 0xc0, 0x6b, 0x4e, 0xa6, 0x5d, 0x6f, 0x42, 0x61, 0xc4, 0xeb, 0x3b, 0x95, 0x5e, - 0xea, 0x57, 0xe1, 0x21, 0xcc, 0x11, 0xd6, 0x79, 0x7c, 0x5f, 0xf7, 0x52, 0xea, - 0x17, 0x07, 0x81, 0xb5, 0x53, 0x7e, 0xbb, 0x4f, 0xba, 0xdd, 0xbf, 0xd4, 0x08 }, - .pk_len = 65, - .sum = (const unsigned char[]){ 0x04, 0xd4, 0x87, 0x27, 0x27, 0xbf, 0xaf, 0x6a, 0xea, 0xb7, 0x84, 0xa8, 0x1a, - 0xd8, 0x29, 0x9e, 0x2b, 0xa7, 0x87, 0x4f, 0xa9, 0xb5, 0x7a, 0x66, 0x5f, 0xbe, - 0x5c, 0xef, 0x83, 0x49, 0x89, 0xd1, 0x34, 0x46, 0x2a, 0x54, 0xe6, 0x92, 0x56, - 0xde, 0xcd, 0x44, 0xe9, 0x99, 0x2a, 0x80, 0xad, 0x78, 0xe6, 0x29, 0xcc, 0x77, - 0xdd, 0x1c, 0x93, 0x03, 0xe2, 0xe9, 0x99, 0x58, 0x86, 0x8f, 0xea, 0xac, 0x3d } }, -#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) - { .ecp_group_id = MBEDTLS_ECP_DP_SECP256K1, - .sk = - (const unsigned char[]){ 0x38, 0x4c, 0x12, 0x83, 0xf8, 0x4d, 0xba, 0x47, 0xcf, 0x6b, 0x71, 0xff, 0xc3, 0x7c, 0x8d, 0x08, - 0x65, 0xee, 0xed, 0x5b, 0x2b, 0x48, 0xf3, 0x79, 0xdf, 0x52, 0x53, 0xff, 0x10, 0xf9, 0x22, 0x7c }, - .sk_len = 32, - .pk = (const unsigned char[]){ 0x04, 0x73, 0x06, 0x4b, 0x4b, 0x3e, 0x38, 0x2f, 0xa0, 0x89, 0x1f, 0x61, 0xfc, - 0x85, 0xf9, 0x51, 0xbe, 0xe4, 0x3d, 0x2c, 0xe9, 0x3e, 0xb0, 0x79, 0x77, 0xaf, - 0x9f, 0xd7, 0xd9, 0x71, 0x68, 0x31, 0x22, 0xc4, 0x9a, 0x25, 0x0c, 0x81, 0x64, - 0x0a, 0xc7, 0xd5, 0x40, 0xb3, 0xe8, 0x9f, 0xb5, 0xb3, 0xc4, 0xc9, 0x6a, 0x13, - 0x3e, 0xf8, 0x3e, 0x8d, 0xa2, 0xfe, 0x1d, 0xd0, 0x47, 0x64, 0x88, 0x8e, 0x7a }, - .pk_len = 65, - .sum = (const unsigned char[]){ 0x04, 0x50, 0x81, 0x70, 0xde, 0x4b, 0x36, 0x41, 0xe8, 0x1a, 0x41, 0xf0, 0x5b, - 0x88, 0x1e, 0x4e, 0xed, 0xed, 0x46, 0x0c, 0xf3, 0xd5, 0xfb, 0xe6, 0x8a, 0x13, - 0xa1, 0xf5, 0x57, 0x69, 0x0a, 0x3d, 0x33, 0x0f, 0x6f, 0xb5, 0x99, 0x80, 0x58, - 0x12, 0xc2, 0x12, 0x62, 0xfc, 0xd2, 0x5b, 0x2e, 0xa2, 0x27, 0xe7, 0x99, 0xab, - 0x91, 0x51, 0x41, 0x0f, 0x06, 0x1e, 0x3d, 0xfd, 0x06, 0xa1, 0x8a, 0xc7, 0xf2 } }, -#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) - { .ecp_group_id = MBEDTLS_ECP_DP_BP256R1, - .sk = - (const unsigned char[]){ 0xa6, 0xb5, 0x48, 0x3f, 0x74, 0xd9, 0x94, 0x9f, 0x09, 0xcd, 0x56, 0x29, 0x19, 0xde, 0xfc, 0x41, - 0x3a, 0x83, 0xf1, 0x2a, 0xda, 0x4f, 0x5f, 0xf4, 0x8e, 0xb5, 0x20, 0x59, 0x11, 0x8e, 0xe6, 0x03 }, - .sk_len = 32, - .pk = (const unsigned char[]){ 0x04, 0x95, 0x44, 0xdb, 0xb4, 0xdc, 0x6f, 0x39, 0x23, 0xb1, 0x3b, 0x13, 0xb6, - 0xcc, 0xcc, 0xde, 0xfb, 0xc0, 0x10, 0xfa, 0x8a, 0x06, 0x30, 0xb9, 0x10, 0x22, - 0xc8, 0x84, 0x7c, 0xf3, 0xba, 0xbd, 0x3a, 0x67, 0xb4, 0x48, 0x68, 0x59, 0x54, - 0x68, 0xab, 0x2d, 0x2d, 0x6f, 0xa7, 0xbf, 0x61, 0x92, 0x2b, 0x07, 0xc0, 0x8c, - 0xb9, 0x3f, 0x88, 0x02, 0x09, 0xfe, 0xfa, 0x72, 0x87, 0x19, 0xaa, 0x19, 0xcc }, - .pk_len = 65, - .sum = (const unsigned char[]){ 0x04, 0x7d, 0x88, 0xb4, 0x73, 0xa0, 0x7d, 0x66, 0x5c, 0xc2, 0x9b, 0x7a, 0xbc, - 0x0c, 0xab, 0x04, 0xc9, 0x79, 0x3e, 0x9a, 0x4e, 0xd3, 0x27, 0x75, 0x1e, 0x4d, - 0x07, 0x7b, 0x5c, 0xbc, 0xce, 0x15, 0xdb, 0x01, 0xb3, 0xd0, 0xcd, 0x27, 0x1b, - 0xe1, 0x57, 0x58, 0x07, 0x88, 0xfd, 0xfd, 0x89, 0xd7, 0x71, 0xcf, 0xbb, 0xa2, - 0xcb, 0x03, 0xd4, 0x34, 0xb1, 0x9e, 0x34, 0x21, 0x31, 0x07, 0x51, 0x6a, 0x0e } }, -#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) - { .ecp_group_id = MBEDTLS_ECP_DP_SECP224R1, - .sk = (const unsigned char[]){ 0x34, 0xac, 0xe1, 0x1f, 0xfa, 0x5e, 0x25, 0xac, 0xee, 0x68, 0xa8, 0xc1, 0x47, 0x64, - 0xa2, 0xa4, 0x69, 0xd5, 0x2c, 0x99, 0x3c, 0x77, 0xf9, 0xc2, 0x38, 0x42, 0x79, 0x93 }, - .sk_len = 28, - .pk = (const unsigned char[]){ 0x04, 0x37, 0x84, 0x05, 0x01, 0xf4, 0x98, 0x12, 0x37, 0x5e, 0xf7, 0x13, 0xcb, 0x29, 0x6a, - 0x43, 0xf4, 0x47, 0xd2, 0xe4, 0x14, 0x3c, 0x10, 0xef, 0x9c, 0x00, 0x59, 0xb6, 0x01, 0x69, - 0x71, 0x76, 0x46, 0x9e, 0x85, 0xa7, 0xc6, 0x39, 0x23, 0x59, 0xf7, 0xfd, 0x41, 0xfe, 0xa8, - 0x3e, 0x6b, 0x97, 0x68, 0xe4, 0x5b, 0x1d, 0xea, 0xcd, 0x85, 0x15, 0xa3 }, - .pk_len = 57, - .sum = (const unsigned char[]){ 0x04, 0x7d, 0x26, 0x1b, 0xf6, 0xb4, 0xa9, 0x45, 0xf8, 0x0f, 0x93, 0xef, 0x05, 0x43, 0x98, - 0x1b, 0x48, 0xf5, 0xea, 0x5c, 0x07, 0x7d, 0xe9, 0x42, 0xc6, 0x9a, 0x11, 0x27, 0x62, 0x00, - 0xef, 0x24, 0x13, 0x53, 0xe0, 0x6b, 0x9b, 0xf5, 0xdd, 0x76, 0xfe, 0xa9, 0xd0, 0x0e, 0xdc, - 0x1f, 0x3d, 0xec, 0x15, 0x36, 0x5e, 0x53, 0xe1, 0x30, 0xb7, 0x25, 0x26 } }, -#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) - { .ecp_group_id = MBEDTLS_ECP_DP_SECP224K1, - .sk = (const unsigned char[]){ 0xba, 0xc8, 0xa0, 0x42, 0xe1, 0x0c, 0xa2, 0xf3, 0xf0, 0x76, 0x04, 0x74, 0xb7, 0x1a, - 0x8f, 0x42, 0xc3, 0x25, 0xeb, 0x57, 0xcd, 0x8d, 0xb0, 0xf9, 0x73, 0x1a, 0x18, 0x26 }, - .sk_len = 28, - .pk = (const unsigned char[]){ 0x04, 0x7f, 0x07, 0xbe, 0xb0, 0x26, 0xd8, 0x6c, 0xe4, 0x09, 0xe8, 0xa6, 0x21, 0x70, 0x37, - 0x52, 0xd6, 0x14, 0x58, 0x4c, 0x99, 0xc8, 0x62, 0x28, 0x6c, 0xeb, 0x3f, 0xf8, 0x30, 0xbb, - 0x82, 0x4c, 0x8a, 0x88, 0xb4, 0x7f, 0x14, 0x17, 0xd0, 0xf5, 0xba, 0xd0, 0x0f, 0xf6, 0xb8, - 0x8c, 0xbb, 0x11, 0x3e, 0x7d, 0x73, 0xc5, 0xf4, 0x4d, 0x22, 0x78, 0x0f }, - .pk_len = 57, - .sum = (const unsigned char[]){ 0x04, 0xb2, 0xbe, 0x4b, 0xc0, 0x62, 0xf2, 0xf6, 0x0e, 0x7f, 0x48, 0x25, 0x50, 0x81, 0xed, - 0xac, 0x14, 0xaa, 0x42, 0x5f, 0x0d, 0x12, 0x52, 0x6d, 0xe0, 0xbc, 0x08, 0x0b, 0x9f, 0xc9, - 0x82, 0x19, 0x07, 0xbf, 0x19, 0x1a, 0x1c, 0xdc, 0x75, 0xbc, 0xe4, 0x5d, 0xcb, 0x4b, 0x9f, - 0x2a, 0xbf, 0x1c, 0xd2, 0xa3, 0x63, 0x33, 0x3f, 0x32, 0xd0, 0xcf, 0x33 } }, -#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) - { .ecp_group_id = MBEDTLS_ECP_DP_SECP192R1, - .sk = (const unsigned char[]){ 0x52, 0x9f, 0x95, 0xf5, 0x4e, 0x73, 0xb6, 0x75, 0x14, 0xcc, 0x92, 0x0c, - 0xcc, 0x07, 0x84, 0x06, 0x01, 0xf3, 0xde, 0x42, 0xad, 0x79, 0x6c, 0x82 }, - .sk_len = 24, - .pk = (const unsigned char[]){ 0x04, 0x61, 0xe9, 0x8d, 0x7e, 0x8e, 0x40, 0x31, 0x20, 0x27, 0xfb, 0x3f, 0x45, - 0x4b, 0x65, 0x0e, 0xfc, 0x41, 0x56, 0x49, 0x20, 0xe6, 0x5c, 0xd4, 0xaa, 0x40, - 0xfe, 0xbc, 0x03, 0xc1, 0xfc, 0x0d, 0x5e, 0x4f, 0xe9, 0x55, 0x08, 0x8c, 0x90, - 0x04, 0xeb, 0xdc, 0x63, 0x89, 0xb2, 0x58, 0x28, 0xfa, 0x28 }, - .pk_len = 49, - .sum = (const unsigned char[]){ 0x04, 0x0a, 0xe7, 0xc5, 0x9e, 0x3b, 0x36, 0xb9, 0x38, 0xdd, 0x75, 0x41, 0x7c, - 0x2d, 0x90, 0xaf, 0x2d, 0x62, 0xf5, 0x5a, 0x86, 0xfe, 0xa0, 0x5f, 0x22, 0xdb, - 0xf3, 0xba, 0x49, 0x47, 0x7d, 0x74, 0x59, 0x02, 0xb3, 0x6c, 0xf2, 0x1e, 0x18, - 0x5b, 0xea, 0x1a, 0xcb, 0xb0, 0x1d, 0x4b, 0x68, 0xec, 0xab - - } }, -#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ -#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) - { .ecp_group_id = MBEDTLS_ECP_DP_SECP192K1, - .sk = (const unsigned char[]){ 0xf2, 0x58, 0xcf, 0xba, 0xb6, 0xb0, 0xb4, 0x03, 0x9e, 0xb2, 0x74, 0xfc, - 0x70, 0xfc, 0x99, 0x0c, 0xcc, 0xed, 0xf4, 0x5f, 0x32, 0x72, 0x22, 0x94 }, - .sk_len = 24, - .pk = (const unsigned char[]){ 0x04, 0xac, 0xe4, 0x74, 0xd8, 0x67, 0x26, 0x60, 0xff, 0x35, 0x10, 0x74, 0xa1, - 0x4e, 0x46, 0xed, 0x2b, 0x94, 0x10, 0x13, 0x01, 0x51, 0x8f, 0xe7, 0xf1, 0xe8, - 0x3d, 0x4a, 0x32, 0x87, 0xe7, 0x4f, 0x39, 0x87, 0xa5, 0x86, 0xef, 0xd1, 0xc8, - 0x12, 0xc8, 0x9b, 0xcd, 0xc6, 0x3d, 0x8d, 0x7a, 0x1b, 0x70 }, - .pk_len = 49, - .sum = (const unsigned char[]){ 0x04, 0x7c, 0xe5, 0xe9, 0x57, 0x0c, 0x36, 0x88, 0x8f, 0xaf, 0xe5, 0x4a, 0xac, - 0xf2, 0x2d, 0xf9, 0xba, 0xf9, 0xb5, 0xa2, 0x64, 0xa2, 0x0b, 0x9f, 0x69, 0xfb, - 0xc7, 0xe1, 0x88, 0xd1, 0xf5, 0x56, 0x6c, 0x6b, 0xc7, 0x64, 0x94, 0xd4, 0x86, - 0xf3, 0x6a, 0xe3, 0x5d, 0x33, 0xda, 0x48, 0x62, 0x18, 0x33 } }, -#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ -#ifdef MBEDTLS_ECP_DP_CURVE25519_ENABLED - { .ecp_group_id = MBEDTLS_ECP_DP_CURVE25519, - .sk = - (const unsigned char[]){ 0x60, 0xc6, 0x2b, 0x85, 0x21, 0x87, 0xf7, 0xd5, 0xdb, 0x8a, 0xa0, 0x3c, 0xe1, 0x73, 0x66, 0xe6, - 0xcf, 0x57, 0xcd, 0xa2, 0x5a, 0xd0, 0xb1, 0xb8, 0xdd, 0xf1, 0x2f, 0x6e, 0x5f, 0xcd, 0x50, 0x30 }, - .sk_len = 32, - .pk = - (const unsigned char[]){ 0x36, 0xce, 0xe3, 0x98, 0x09, 0xe1, 0x72, 0xca, 0xcd, 0x26, 0x79, 0xa9, 0xbf, 0xc4, 0xda, 0xd9, - 0x65, 0x4a, 0x53, 0x23, 0xf4, 0x02, 0x75, 0x7c, 0xe2, 0xc6, 0x4a, 0x7c, 0x1c, 0xd2, 0xf6, 0x4d }, - .pk_len = 32, - .sum = NULL }, -#endif -#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) - { .ecp_group_id = MBEDTLS_ECP_DP_CURVE448, - .sk = (const unsigned char[]){ 0xf5, 0x73, 0x0e, 0x50, 0xb2, 0xd3, 0x3b, 0x01, 0x28, 0x29, 0xa0, 0xa1, 0x43, 0x92, - 0x2f, 0x05, 0x40, 0xc3, 0x5f, 0xcf, 0xc1, 0x53, 0x49, 0xc2, 0x0c, 0xf4, 0x49, 0x99, - 0xdb, 0xb9, 0x64, 0x10, 0x25, 0x18, 0x82, 0x24, 0x2c, 0xdf, 0x25, 0xb6, 0xac, 0xb1, - 0xe6, 0x11, 0x26, 0xa9, 0x96, 0x16, 0x16, 0x6c, 0x7b, 0xdd, 0x7c, 0x55, 0x5f, 0xf0 }, - .sk_len = 56, - .pk = (const unsigned char[]){ 0x4f, 0xf4, 0xd0, 0x42, 0x1a, 0xa6, 0xfc, 0x2d, 0xba, 0x7b, 0x45, 0x9e, 0xed, 0xd0, - 0xf1, 0x8c, 0xec, 0xeb, 0xae, 0x29, 0x27, 0x9f, 0xc7, 0xe8, 0x8a, 0xc7, 0xeb, 0x3c, - 0x18, 0xb8, 0x7f, 0x66, 0x2f, 0x8b, 0x0d, 0x68, 0xe8, 0x2e, 0x60, 0x91, 0x27, 0xa2, - 0x8c, 0x91, 0x2c, 0xf4, 0xa1, 0x58, 0x74, 0xc9, 0x40, 0xfe, 0x50, 0x06, 0x1b, 0xe7 }, - .pk_len = 56, - .sum = NULL }, -#endif /* MBEDTLS_ECP_DP_CURVE448_ENABLED */ -}; - -/**************************************************************** - * Dummy variable to skip mbedtls_ecp_self_test sw functionality - ****************************************************************/ -const int __ecp_alt_b91_skip_internal_self_tests = 1; - -/**************************************************************** - * Public functions declaration - ****************************************************************/ - -int ecp_alt_b91_backend_test(int verbose) -{ - int result = 0; - if (verbose) - mbedtls_printf("test started\n"); - - mbedtls_ctr_drbg_context ctr_drbg; - mbedtls_entropy_context entropy; - - mbedtls_ctr_drbg_init(&ctr_drbg); - mbedtls_entropy_init(&entropy); - - if ((result = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0)) == 0) - { - - for (size_t i = 0; result == 0 && i < sizeof(ecp_test_cases) / sizeof(ecp_test_cases[0]); i++) - { - - const mbedtls_ecp_curve_info * ecp_curve_info = mbedtls_ecp_curve_info_from_grp_id(ecp_test_cases[i].ecp_group_id); - if (verbose) - mbedtls_printf("\tcurve: %s\n", ecp_curve_info->name); - - mbedtls_ecp_group ecp_group; - mbedtls_mpi sk; - mbedtls_ecp_point pk; - mbedtls_ecp_point pk_ref; - mbedtls_ecp_point sum; - mbedtls_ecp_point sum_ref; - - mbedtls_ecp_group_init(&ecp_group); - mbedtls_mpi_init(&sk); - mbedtls_ecp_point_init(&pk); - mbedtls_ecp_point_init(&pk_ref); - mbedtls_ecp_point_init(&sum); - mbedtls_ecp_point_init(&sum_ref); - - do - { - if ((result = mbedtls_ecp_group_load(&ecp_group, ecp_test_cases[i].ecp_group_id)) != 0) - { - if (verbose) - mbedtls_printf("mbedtls_ecp_group_load failed\n"); - break; - } - - if ((result = mbedtls_mpi_read_binary(&sk, ecp_test_cases[i].sk, ecp_test_cases[i].sk_len)) != 0) - { - if (verbose) - mbedtls_printf("mbedtls_mpi_read_binary (secret key) failed\n"); - break; - } - - if ((result = mbedtls_ecp_check_privkey(&ecp_group, &sk)) != 0) - { - if (verbose) - mbedtls_printf("mbedtls_ecp_check_privkey failed\n"); - break; - } - - if ((result = mbedtls_ecp_mul(&ecp_group, &pk, &sk, &ecp_group.G, mbedtls_ctr_drbg_random, &ctr_drbg)) != 0) - { - if (verbose) - mbedtls_printf("mbedtls_ecp_mul failed\n"); - break; - } - - if ((result = mbedtls_ecp_point_read_binary(&ecp_group, &pk_ref, ecp_test_cases[i].pk, ecp_test_cases[i].pk_len)) != - 0) - { - if (verbose) - mbedtls_printf("mbedtls_ecp_point_read_binary (reference public key) failed\n"); - break; - } - - if ((result = mbedtls_ecp_point_cmp(&pk, &pk_ref)) != 0) - { - if (verbose) - { - mbedtls_printf("mbedtls_ecp_point_cmp (public key) failed\n"); - mbedtls_printbuf("sk :", ecp_test_cases[i].sk, ecp_test_cases[i].sk_len); - mbedtls_printbuf("pk ref:", ecp_test_cases[i].pk, ecp_test_cases[i].pk_len); - unsigned char buf[ecp_test_cases[i].pk_len]; - size_t buf_len; - if (mbedtls_ecp_point_write_binary(&ecp_group, &pk, MBEDTLS_ECP_PF_UNCOMPRESSED, &buf_len, buf, - sizeof(buf)) == 0) - mbedtls_printbuf("pk :", buf, buf_len); - } - break; - } - - if ((result = mbedtls_ecp_check_pubkey(&ecp_group, &pk)) != 0) - { - if (verbose) - mbedtls_printf("mbedtls_ecp_check_pubkey failed\n"); - break; - } - - if (mbedtls_ecp_get_type(&ecp_group) != MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS) - continue; - - if ((result = mbedtls_ecp_muladd(&ecp_group, &sum, &sk, &ecp_group.G, &sk, &pk)) != 0) - { - if (verbose) - mbedtls_printf("mbedtls_ecp_muladd failed\n"); - break; - } - - if ((result = - mbedtls_ecp_point_read_binary(&ecp_group, &sum_ref, ecp_test_cases[i].sum, ecp_test_cases[i].pk_len)) != 0) - { - if (verbose) - mbedtls_printf("mbedtls_ecp_point_read_binary (reference sum) failed\n"); - break; - } - - if ((result = mbedtls_ecp_point_cmp(&sum, &sum_ref)) != 0) - { - if (verbose) - { - mbedtls_printf("mbedtls_ecp_point_cmp (sum) failed\n"); - mbedtls_printbuf("sk :", ecp_test_cases[i].sk, ecp_test_cases[i].sk_len); - mbedtls_printbuf("pk ref :", ecp_test_cases[i].pk, ecp_test_cases[i].pk_len); - mbedtls_printbuf("sum ref:", ecp_test_cases[i].pk, ecp_test_cases[i].pk_len); - unsigned char buf[ecp_test_cases[i].pk_len]; - size_t buf_len; - if (mbedtls_ecp_point_write_binary(&ecp_group, &sum, MBEDTLS_ECP_PF_UNCOMPRESSED, &buf_len, buf, - sizeof(buf)) == 0) - mbedtls_printbuf("sum :", buf, buf_len); - } - break; - } - - } while (0); - - mbedtls_ecp_point_free(&sum_ref); - mbedtls_ecp_point_free(&sum); - mbedtls_ecp_point_free(&pk_ref); - mbedtls_ecp_point_free(&pk); - mbedtls_mpi_free(&sk); - mbedtls_ecp_group_free(&ecp_group); - } - } - else /* mbedtls_ctr_drbg_seed failed */ - { - if (verbose) - mbedtls_printf("random failed\n"); - } - - mbedtls_ctr_drbg_free(&ctr_drbg); - mbedtls_entropy_free(&entropy); - - if (verbose) - { - if (result == 0) - mbedtls_printf("test successfully finished\n"); - else - { - char buf[512]; - mbedtls_strerror(result, buf, sizeof(buf)); - mbedtls_printf("test failed: %s\n", buf); - } - } - return result; -} - -#pragma GCC diagnostic pop - -#endif /* MBEDTLS_SELF_TEST */ - -#endif /* MBEDTLS_ECP_ALT */ - -#endif /* MBEDTLS_ECP_C */ diff --git a/src/platform/telink/crypto/internal/entropy_poll_alt.c b/src/platform/telink/crypto/internal/entropy_poll_alt.c deleted file mode 100644 index 2de3d619b858ad..00000000000000 --- a/src/platform/telink/crypto/internal/entropy_poll_alt.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Hardware entropy - * - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -#include "common.h" - -#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) - -#include "multithread.h" -#include "trng.h" -#include - -int mbedtls_hardware_poll(void * data, unsigned char * output, size_t len, size_t * olen) -{ - (void) data; - - if (output != NULL && len != 0 && olen != NULL) - { - mbedtls_entropy_lock(); - *olen = 0; - extern unsigned int g_rnd_m_w; - while (len / sizeof(g_rnd_m_w) != 0) - { - trng_init(); - *((unsigned int *) output) = g_rnd_m_w; - output += sizeof(g_rnd_m_w); - len -= sizeof(g_rnd_m_w); - *olen += sizeof(g_rnd_m_w); - } - if (len != 0) - { - trng_init(); - memcpy(output, &g_rnd_m_w, len); - *olen += len; - } - mbedtls_entropy_unlock(); - } - return 0; -} - -#endif /* MBEDTLS_ENTROPY_HARDWARE_ALT */ diff --git a/src/platform/telink/crypto/internal/multithread.c b/src/platform/telink/crypto/internal/multithread.c deleted file mode 100644 index 91f51047f80143..00000000000000 --- a/src/platform/telink/crypto/internal/multithread.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Multithread support for mbedTLS HW unit - * - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -#include "multithread.h" -#include "common.h" - -/**************************************************************** - * If RTOS is used and cryptography stuffs are used - * from more than one thread implement exclusive access - * for HW crypto units depending on used operation system. - * See documentation for your RTOS. - ****************************************************************/ - -#include - -K_MUTEX_DEFINE(mbedtls_entropy_mutex); -K_MUTEX_DEFINE(mbedtls_ecp_mutex); -K_MUTEX_DEFINE(mbedtls_aes_mutex); - -void mbedtls_entropy_lock(void) -{ - - if (k_mutex_lock(&mbedtls_entropy_mutex, K_FOREVER) != 0) - { - printk("mbedtls_entropy_lock fail\n"); - } -} - -void mbedtls_entropy_unlock(void) -{ - - if (k_mutex_unlock(&mbedtls_entropy_mutex) != 0) - { - printk("mbedtls_entropy_unlock fail\n"); - } -} - -void mbedtls_ecp_lock(void) -{ - - if (k_mutex_lock(&mbedtls_ecp_mutex, K_FOREVER) != 0) - { - printk("mbedtls_ecp_lock fail\n"); - } -} - -void mbedtls_ecp_unlock(void) -{ - - if (k_mutex_unlock(&mbedtls_ecp_mutex) != 0) - { - printk("mbedtls_ecp_unlock fail\n"); - } -} - -void mbedtls_aes_lock(void) -{ - - if (k_mutex_lock(&mbedtls_aes_mutex, K_FOREVER) != 0) - { - printk("mbedtls_aes_lock fail\n"); - } -} - -void mbedtls_aes_unlock(void) -{ - - if (k_mutex_unlock(&mbedtls_aes_mutex) != 0) - { - printk("mbedtls_aes_unlock fail\n"); - } -} diff --git a/src/platform/telink/crypto/internal/multithread.h b/src/platform/telink/crypto/internal/multithread.h deleted file mode 100644 index 5588b7adcf8f92..00000000000000 --- a/src/platform/telink/crypto/internal/multithread.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * \file multithread.h - * - * \brief Utility macros for internal use in the library - */ -/* - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -#ifndef MBEDTLS_TEST_UTILS_H -#define MBEDTLS_TEST_UTILS_H - -#ifdef __cplusplus -extern "C" { -#endif - -void mbedtls_entropy_lock(void); -void mbedtls_entropy_unlock(void); -void mbedtls_ecp_lock(void); -void mbedtls_ecp_unlock(void); -void mbedtls_aes_lock(void); -void mbedtls_aes_unlock(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/platform/telink/crypto/internal/test_utils.c b/src/platform/telink/crypto/internal/test_utils.c deleted file mode 100644 index 0fcdabf4f70563..00000000000000 --- a/src/platform/telink/crypto/internal/test_utils.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Test utilites - * - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -#include "test_utils.h" -#include "common.h" -#include "mbedtls/platform.h" - -void mbedtls_printbuf(const char * comment, const void * buf, size_t len) -{ - mbedtls_printf("%s [%u]:", comment, (unsigned int) len); - for (size_t i = 0; i < len; i++) - { - mbedtls_printf(" %02x", ((unsigned char *) buf)[i]); - } - mbedtls_printf("\n"); -} - -void mbedtls_printbuf_c(const char * comment, const void * buf, size_t len) -{ - - mbedtls_printf("%s [%u]: ", comment, (unsigned int) len); - for (size_t i = 0; len && i < len - 1; i++) - { - mbedtls_printf("0x%02x, ", ((unsigned char *) buf)[i]); - } - if (len) - { - mbedtls_printf("0x%02x\n", ((unsigned char *) buf)[len - 1]); - } - else - { - mbedtls_printf("\n"); - } -} diff --git a/src/platform/telink/crypto/internal/test_utils.h b/src/platform/telink/crypto/internal/test_utils.h deleted file mode 100644 index 422986ee5382f6..00000000000000 --- a/src/platform/telink/crypto/internal/test_utils.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * \file test_utils.h - * - * \brief Utility macros for internal use in the library - */ -/* - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -#ifndef MBEDTLS_TEST_UTILS_H -#define MBEDTLS_TEST_UTILS_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -void mbedtls_printbuf(const char * comment, const void * buf, size_t len); -void mbedtls_printbuf_c(const char * comment, const void * buf, size_t len); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/platform/telink/crypto/telink-mbedtls-config.h b/src/platform/telink/crypto/telink-mbedtls-config.h deleted file mode 100644 index 7ed6f7a973ea77..00000000000000 --- a/src/platform/telink/crypto/telink-mbedtls-config.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * 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. - */ - -/** - * @file - * Platform-specific configuration for mbedtls * - */ - -#include - -#pragma once - -#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf - -#define MBEDTLS_CIPHER_MODE_CTR -#define MBEDTLS_SHA512_C -#define MBEDTLS_ECDH_C -#define MBEDTLS_SHA1_C -#define MBEDTLS_HKDF_C -#define MBEDTLS_CHACHAPOLY_C -#define MBEDTLS_POLY1305_C -#define MBEDTLS_CHACHA20_C -#define MBEDTLS_SSL_KEEP_PEER_CERTIFICATE -#define MBEDTLS_ECP_DP_CURVE25519_ENABLED -#define MBEDTLS_AES_C -#define MBEDTLS_AES_ROM_TABLES -#define MBEDTLS_ASN1_PARSE_C -#define MBEDTLS_ASN1_WRITE_C -#define MBEDTLS_BIGNUM_C -#define MBEDTLS_CCM_C -#define MBEDTLS_CIPHER_C -#define MBEDTLS_CMAC_C -#define MBEDTLS_CTR_DRBG_C -#define MBEDTLS_ECJPAKE_C -#define MBEDTLS_ECP_C -#define MBEDTLS_ECP_DP_SECP256R1_ENABLED -#define MBEDTLS_ECP_NIST_OPTIM -#define MBEDTLS_ENTROPY_C -#define MBEDTLS_HAVE_ASM -#define MBEDTLS_HMAC_DRBG_C -#define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED -#define MBEDTLS_MD_C -#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES -#define MBEDTLS_NO_PLATFORM_ENTROPY -#define MBEDTLS_PK_C -#define MBEDTLS_PK_PARSE_C -#define MBEDTLS_PK_WRITE_C -#define MBEDTLS_PKCS5_C -#define MBEDTLS_PLATFORM_C -#define MBEDTLS_PLATFORM_MEMORY -#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS -#define MBEDTLS_SHA256_C -#define MBEDTLS_SHA256_SMALLER -#define MBEDTLS_SSL_CLI_C -#define MBEDTLS_SSL_DTLS_ANTI_REPLAY -#define MBEDTLS_SSL_DTLS_HELLO_VERIFY -#define MBEDTLS_SSL_EXPORT_KEYS -#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH -#define MBEDTLS_SSL_PROTO_TLS1_2 -#define MBEDTLS_SSL_PROTO_DTLS -#define MBEDTLS_SSL_TLS_C -#define MBEDTLS_SSL_COOKIE_C -#define MBEDTLS_SSL_SRV_C -#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED -#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED -#define MBEDTLS_BASE64_C -#define MBEDTLS_ECDH_C -#define MBEDTLS_ECDSA_C -#define MBEDTLS_OID_C -#define MBEDTLS_PEM_PARSE_C -#define MBEDTLS_X509_USE_C -#define MBEDTLS_X509_CRT_PARSE_C -#define MBEDTLS_X509_CREATE_C -#define MBEDTLS_X509_CSR_WRITE_C -#define MBEDTLS_ECDSA_DETERMINISTIC - -#if OPENTHREAD_CONFIG_ECDSA_ENABLE -#define MBEDTLS_BASE64_C -#define MBEDTLS_ECDH_C -#define MBEDTLS_ECDSA_C -#define MBEDTLS_OID_C -#define MBEDTLS_PEM_PARSE_C -#endif - -#define MBEDTLS_MPI_WINDOW_SIZE 1 /**< Maximum windows size used. */ -#define MBEDTLS_MPI_MAX_SIZE 32 /**< Maximum number of bytes for usable MPIs. */ -#define MBEDTLS_ECP_MAX_BITS 256 /**< Maximum bit size of groups */ -#define MBEDTLS_ECP_WINDOW_SIZE 2 /**< Maximum window size used */ -#define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 /**< Enable fixed-point speed-up */ -#define MBEDTLS_ENTROPY_MAX_SOURCES 1 /**< Maximum number of sources supported */ - -#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE -#define MBEDTLS_PLATFORM_STD_CALLOC otPlatCAlloc /**< Default allocator to use, can be undefined */ -#define MBEDTLS_PLATFORM_STD_FREE otPlatFree /**< Default free to use, can be undefined */ -#else -#define MBEDTLS_MEMORY_BUFFER_ALLOC_C -#endif - -#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 -#define MBEDTLS_DEBUG_C - -#define MBEDTLS_ECP_ALT -#define MBEDTLS_AES_ALT diff --git a/src/platform/telink/telink-mbedtls-config.h b/src/platform/telink/telink-mbedtls-config.h new file mode 100644 index 00000000000000..d0de1d19734a4f --- /dev/null +++ b/src/platform/telink/telink-mbedtls-config.h @@ -0,0 +1,29 @@ +/****************************************************************************** + * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") + * 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. + * + *****************************************************************************/ + +#ifndef MBEDTLS_TSLR9_CONF_H +#define MBEDTLS_TSLR9_CONF_H + +#define MBEDTLS_HKDF_C +#define MBEDTLS_X509_CREATE_C +#define MBEDTLS_X509_CSR_WRITE_C + +#define MBEDTLS_AES_ALT +#define MBEDTLS_ECP_ALT + +#endif /* MBEDTLS_TSLR9_CONF_H */ diff --git a/src/platform/webos/ConnectivityManagerImpl.cpp b/src/platform/webos/ConnectivityManagerImpl.cpp index ed43cd38f7d710..627fa14366ce1f 100644 --- a/src/platform/webos/ConnectivityManagerImpl.cpp +++ b/src/platform/webos/ConnectivityManagerImpl.cpp @@ -1518,6 +1518,14 @@ bool ConnectivityManagerImpl::_GetBssInfo(const gchar * bssPath, NetworkCommissi std::unique_ptr ssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "SSID")); std::unique_ptr bssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "BSSID")); + // Network scan is performed in the background, so the BSS + // may be gone when we try to get the properties. + if (ssid == nullptr || bssid == nullptr) + { + ChipLogDetail(DeviceLayer, "wpa_supplicant: BSS not found: %s", bssPath); + return false; + } + const guchar * ssidStr = nullptr; const guchar * bssidBuf = nullptr; char bssidStr[2 * 6 + 5 + 1] = { 0 }; diff --git a/third_party/nxp/k32w0_sdk/BUILD.gn b/third_party/nxp/k32w0_sdk/BUILD.gn index 79d2e2a6ee1a6a..c6cff80b87c915 100644 --- a/third_party/nxp/k32w0_sdk/BUILD.gn +++ b/third_party/nxp/k32w0_sdk/BUILD.gn @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") import("//build_overrides/k32w0_sdk.gni") import("//build_overrides/mbedtls.gni") @@ -60,6 +61,13 @@ config("mbedtls_k32w0_config") { ] } + if (chip_with_factory_data == 1) { + defines += [ + "MBEDTLS_X509_CRT_PARSE_C", + "MBEDTLS_X509_USE_C", + ] + } + if (chip_crypto == "tinycrypt") { defines += [ "MBEDTLS_USE_TINYCRYPT", @@ -76,8 +84,8 @@ config("mbedtls_k32w0_config") { mbedtls_target("mbedtls") { sources = [ + "${chip_root}/src/platform/nxp/k32w/k32w0/crypto/ksdk_mbedtls.c", "${k32w0_sdk_root}/middleware/mbedtls/port/ksdk/aes_alt.c", - "${k32w0_sdk_root}/middleware/mbedtls/port/ksdk/ksdk_mbedtls.c", ] if (chip_crypto == "tinycrypt") { diff --git a/third_party/nxp/k32w0_sdk/k32w0_sdk.gni b/third_party/nxp/k32w0_sdk/k32w0_sdk.gni index d0aa619d6a6968..0f48c70daffeaf 100644 --- a/third_party/nxp/k32w0_sdk/k32w0_sdk.gni +++ b/third_party/nxp/k32w0_sdk/k32w0_sdk.gni @@ -37,6 +37,7 @@ declare_args() { board = "k32w061dk6" chip_with_ntag = 1 chip_with_high_power = 0 + chip_with_factory_data = 0 } assert(k32w0_sdk_root != "", "k32w0_sdk_root must be specified") @@ -64,6 +65,13 @@ template("k32w0_sdk") { chip_with_ot_cli == 0 && chip_with_se05x == 0), "Please disable low power if expansion board, openthread CLI or SE is needed!") + assert(chip_with_low_power == 0 || + (invoker.chip_detail_logging == false && + invoker.chip_progress_logging == false && + invoker.chip_automation_logging == false && + invoker.chip_error_logging == false), + "Please disable all logs when low power is enabled!") + if (build_for_k32w041am == 1 || build_for_k32w041a == 1 || build_for_k32w041 == 1) { build_for_k32w061 = 0 @@ -75,7 +83,7 @@ template("k32w0_sdk") { "Please build for only one platform") device = "K32W061" board = "k32w061dk6" - chip_with_ntag = 1 + chip_with_ntag = 0 chip_with_high_power = 0 } if (build_for_k32w041am == 1) { @@ -221,8 +229,7 @@ template("k32w0_sdk") { "USE_SDK_OSA=0", "gSerialManagerMaxInterfaces_c=2", "FSL_RTOS_FREE_RTOS=1", - "gTotalHeapSize_c=0xC8BC", - "gUartDebugConsole_d=1", + "gTotalHeapSize_c=0x10000", "DEBUG_SERIAL_INTERFACE_INSTANCE=0", "APP_SERIAL_INTERFACE_INSTANCE=1", "gOTA_externalFlash_d=1", @@ -238,7 +245,6 @@ template("k32w0_sdk") { "ENABLE_RAM_VECTOR_TABLE=1", "gTMR_Enabled_d=1", "gTimestamp_Enabled_d=0", - "K32W_LOG_ENABLED=1", "CHIP_ENABLE_OPENTHREAD=1", "gOtaMemPoolId_c=1", "PoolsDetails_c=_block_size_ 32 _number_of_blocks_ 6 _pool_id_(0) _eol_ _block_size_ 256 _number_of_blocks_ 3 _pool_id_(0) _eol_ _block_size_ 512 _number_of_blocks_ 2 _pool_id_(0) _eol_ _block_size_ 768 _number_of_blocks_ 1 _pool_id_(0) _eol_ _block_size_ 268 _number_of_blocks_ 8 _pool_id_(gOtaMemPoolId_c) _eol_", @@ -295,7 +301,7 @@ template("k32w0_sdk") { } else { defines += [ "gKeyBoardSupported_d=1", - "gKBD_KeysCount_c=1", + "gKBD_KeysCount_c=2", ] } @@ -322,11 +328,15 @@ template("k32w0_sdk") { "mAppUseTickLessMode_c=1", "App_SuppressTickInStopMode=0", "cPWR_DiscardRunningTimerForPowerDown=1", + "K32W_LOG_ENABLED=0", + "gUartDebugConsole_d=0", ] } else { defines += [ "cPWR_UsePowerDownMode=0", "cPWR_FullPowerDownMode=0", + "K32W_LOG_ENABLED=1", + "gUartDebugConsole_d=1", ] } @@ -358,6 +368,10 @@ template("k32w0_sdk") { ] } + if (chip_with_factory_data == 1) { + defines += [ "CONFIG_CHIP_K32W0_REAL_FACTORY_DATA=1" ] + } + if (defined(invoker.defines)) { defines += invoker.defines } diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/Eeprom_MX25R8035F_c.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/Eeprom_MX25R8035F_c.patch deleted file mode 100644 index c017836bfa83aa..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/Eeprom_MX25R8035F_c.patch +++ /dev/null @@ -1,112 +0,0 @@ ---- a/Eeprom_MX25R8035F.c -+++ b//Eeprom_MX25R8035F.c -@@ -146,7 +146,7 @@ static uint32_t EEPROM_ReadStatusReq(void); - static uint32_t EEPROM_ReadIDReq(void); - static uint32_t EEPROM_ReadResReq(void); - -- -+static uint8_t EEPROM_isBusyPrivate(void); - - #define MX25_SR_WIP_POS 0 /* Write In Progress */ - #define MX25_SR_WEL_POS 1 /* Write Enable Latch */ -@@ -316,7 +316,7 @@ ee_err_t EEPROM_Init(void) - { - initialized = 1; - } -- while (EEPROM_isBusy()); -+ while (EEPROM_isBusyPrivate()); - } - - return status; -@@ -366,7 +366,7 @@ ee_err_t EEPROM_ChipErase(void) - - /* Wait for idle state : check before operation in order to let previous - * operation terminate rather than blocking */ -- while (EEPROM_isBusy()); -+ while (EEPROM_isBusyPrivate()); - - /* Enable write */ - EEPROM_WriteEnable(); -@@ -410,7 +410,7 @@ ee_err_t EEPROM_EraseBlock(uint32_t Addr, uint32_t block_size) - - OSA_SemaphoreWait(mExtEepromSemaphoreId, osaWaitForever_c); - -- while (EEPROM_isBusy()); -+ while (EEPROM_isBusyPrivate()); - - EEPROM_WriteEnable(); - -@@ -485,7 +485,7 @@ ee_err_t EEPROM_EraseArea(uint32_t *Addr, int32_t *size, bool non_blocking) - { - OSA_SemaphoreWait(mExtEepromSemaphoreId, osaWaitForever_c); - -- if (non_blocking && EEPROM_isBusy()) -+ if (non_blocking && EEPROM_isBusyPrivate()) - { - status = ee_busy; - OSA_SemaphorePost(mExtEepromSemaphoreId); -@@ -679,7 +679,7 @@ void EEPROM_SetRead(void) - - OSA_SemaphoreWait(mExtEepromSemaphoreId, osaWaitForever_c); - -- while (EEPROM_isBusy()); -+ while (EEPROM_isBusyPrivate()); - - /* Set start address */ - SPIFI_SetCommandAddress(SPIFI, FSL_FEATURE_SPIFI_START_ADDR ); -@@ -714,7 +714,7 @@ ee_err_t EEPROM_ReadData(uint16_t NoOfBytes, uint32_t Addr, uint8_t *inbuf) - - OSA_SemaphoreWait(mExtEepromSemaphoreId, osaWaitForever_c); - -- while (EEPROM_isBusy()); -+ while (EEPROM_isBusyPrivate()); - - /* Set start address */ - SPIFI_SetCommandAddress(SPIFI, FSL_FEATURE_SPIFI_START_ADDR + Addr); -@@ -750,7 +750,12 @@ ee_err_t EEPROM_ReadData(uint16_t NoOfBytes, uint32_t Addr, uint8_t *inbuf) - ********************************************************************************** */ - uint8_t EEPROM_isBusy(void) - { -- return (EEPROM_ReadStatusReq() & EEPROM_BUSY_FLAG_MASK) == EEPROM_BUSY_FLAG_MASK; -+ uint8_t res = 0; -+ -+ OSA_SemaphoreWait(mExtEepromSemaphoreId, osaWaitForever_c); -+ res = EEPROM_isBusyPrivate(); -+ OSA_SemaphorePost(mExtEepromSemaphoreId); -+ return res; - } - - /*! ********************************************************************************* -@@ -759,6 +764,11 @@ uint8_t EEPROM_isBusy(void) - ************************************************************************************* - ********************************************************************************** */ - -+static uint8_t EEPROM_isBusyPrivate(void) -+{ -+ return (EEPROM_ReadStatusReq() & EEPROM_BUSY_FLAG_MASK) == EEPROM_BUSY_FLAG_MASK; -+} -+ - /*! ********************************************************************************* - * \brief Read the memory controller status register - * -@@ -882,6 +892,7 @@ void EepromWritePage(uint32_t NoOfBytes, uint32_t Addr, uint8_t *Outbuf) - #endif /* gFlashBlockBitmap_d */ - - OSA_SemaphoreWait(mExtEepromSemaphoreId, osaWaitForever_c); -+ while (EEPROM_isBusyPrivate()); - - EEPROM_WriteEnable(); - SPIFI_SetCommandAddress(SPIFI, Addr + FSL_FEATURE_SPIFI_START_ADDR); -@@ -917,12 +928,6 @@ static ee_err_t EEPROM_WritePage(uint32_t NoOfBytes, uint32_t Addr, uint8_t *Out - - if (NoOfBytes > 0) - { -- OSA_SemaphoreWait(mExtEepromSemaphoreId, osaWaitForever_c); -- -- while (EEPROM_isBusy()); -- -- OSA_SemaphorePost(mExtEepromSemaphoreId); -- - EepromWritePage(NoOfBytes, Addr, Outbuf); - } - diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/MemManager_h.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/MemManager_h.patch deleted file mode 100644 index 49ed7e803738cd..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/MemManager_h.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/MemManager.h -+++ b/MemManager.h -@@ -24,6 +24,9 @@ - #include "EmbeddedTypes.h" - #include "GenericList.h" - -+#ifdef __cplusplus -+extern "C" { -+#endif - - /*! ********************************************************************************* - ************************************************************************************* -@@ -220,4 +223,8 @@ extern __attribute__((weak)) uint32_t MEM_GetTimeStamp(void); - - #endif /*MEM_TRACKING*/ - -+#ifdef __cplusplus -+} -+#endif -+ - #endif /* _MEM_MANAGER_H_ */ - diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/OtaSupport_c.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/OtaSupport_c.patch deleted file mode 100644 index 0ff1c9ec118651..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/OtaSupport_c.patch +++ /dev/null @@ -1,144 +0,0 @@ ---- a/OtaSupport.c -+++ b/OtaSupport.c -@@ -116,10 +116,9 @@ typedef bool (*efuse_AESKeyPresent_t)(void); - typedef int (*efuse_LoadUniqueKey_t)(void); - typedef uint32_t (*aesLoadKeyFromOTP_t)(AES_KEY_SIZE_T keySize); - --const static efuse_LoadUniqueKey_t efuse_LoadUniqueKey = (efuse_LoadUniqueKey_t)ROM_API_efuse_LoadUniqueKey; --const static aesLoadKeyFromOTP_t aesLoadKeyFromOTP = (aesLoadKeyFromOTP_t)ROM_API_aesLoadKeyFromOTP; --const static efuse_AESKeyPresent_t efuse_AESKeyPresent = (efuse_AESKeyPresent_t)ROM_API_efuse_AESKeyPresent; -- -+static const efuse_LoadUniqueKey_t efuse_LoadUniqueKey = (efuse_LoadUniqueKey_t)ROM_API_efuse_LoadUniqueKey; -+static const aesLoadKeyFromOTP_t aesLoadKeyFromOTP = (aesLoadKeyFromOTP_t)ROM_API_aesLoadKeyFromOTP; -+static const efuse_AESKeyPresent_t efuse_AESKeyPresent = (efuse_AESKeyPresent_t)ROM_API_efuse_AESKeyPresent; - - #if gUsePasswordCiphering_d - const static uint32_t (*aesLoadKeyFromSW)(AES_KEY_SIZE_T keySize, -@@ -187,6 +186,7 @@ typedef struct { - int max_cnt_idle; - int q_sz; - int q_max; -+ osaMutexId_t msgQueueMutex; - #endif - eEncryptionKeyType ciphered_mode; - #if gExternalFlashIsCiphered_d -@@ -207,6 +207,7 @@ typedef struct { - #if ( gEepromParams_bufferedWrite_c == 1) - bool_t gOtaInvalidateHeader; - #endif -+ bool_t isInitialized; - } OtaFlashTaskContext_t; - - /****************************************************************************** -@@ -287,6 +288,7 @@ static OtaFlashTaskContext_t mHandle = { - #if ( gEepromParams_bufferedWrite_c == 1) - .gOtaInvalidateHeader = FALSE, - #endif -+ .isInitialized = FALSE, - }; - - -@@ -460,6 +462,11 @@ otaResult_t OTA_StartImageWithMaxSize(uint32_t length, uint32_t maxAllowedArchSi - int OTA_TransactionResume(void) - { - int nb_treated = 0; -+ -+ if (mHandle.isInitialized) -+ { -+ OSA_MutexLock(mHandle.msgQueueMutex, osaWaitForever_c); -+ - while ( OTA_IsTransactionPending() /* There are queued flash operations pending in queue */ - && (nb_treated < MAX_CONSECUTIVE_TRANSACTIONS)) /* ... but do not schedule too many in a same pass */ - { -@@ -553,6 +560,9 @@ int OTA_TransactionResume(void) - /* There were transactions pending but we consumed some */ - mHandle.cnt_idle_op = 0; - -+ OSA_MutexUnlock(mHandle.msgQueueMutex); -+ } -+ - return nb_treated; - } - /***************************************************************************** -@@ -578,7 +588,11 @@ void OTA_WritePendingData(void) - - while (EEPROM_isBusy()); - /* Always take head of queue : we just queued something so we know it is not empty */ -- OTA_TransactionResume(); -+ while (OTA_IsTransactionPending()) -+ { -+ OTA_TransactionResume(); -+ } -+ - while (EEPROM_isBusy()); - - } while (0); -@@ -877,7 +891,14 @@ otaResult_t OTA_PushImageChunk(uint8_t* pData, uint16_t length, uint32_t* pImage - OTA_MsgQueue(pMsg); - - OTA_DBG_LOG("Submitted page Addr=%x", pMsg->flash_addr); -- mHandle.cur_transaction = NULL; -+ if (mHandle.cur_transaction != NULL) -+ { -+ mHandle.cur_transaction = NULL; -+ } -+ else -+ { -+ Addr += PROGRAM_PAGE_SZ; -+ } - } - else - { -@@ -1229,6 +1250,9 @@ otaResult_t OTA_ClientInit(void) - OTA_DEBUG_TRACE("%s\r\n", __FUNCTION__); - otaResult_t res = gOtaSuccess_c; - -+ if (!mHandle.isInitialized) -+ { -+ - mHandle.LoadOtaImageInEepromInProgress = FALSE; - mHandle.OtaImageTotalLength = 0; - mHandle.OtaImageCurrentLength = 0; -@@ -1255,6 +1279,7 @@ otaResult_t OTA_ClientInit(void) - - #if gOtaEepromPostedOperations_d - MSG_InitQueue(&mHandle.op_queue); -+ mHandle.msgQueueMutex = OSA_MutexCreate(); - #endif - #if gExternalFlashIsCiphered_d - mHandle.ciphered_mode = (efuse_AESKeyPresent()) ? eEfuseKey : eSoftwareKey; -@@ -1262,6 +1287,9 @@ otaResult_t OTA_ClientInit(void) - mHandle.ciphered_mode = eCipherKeyNone; - #endif - res = OTA_InitExternalMemory(); -+ -+ mHandle.isInitialized = TRUE; -+ } - return res; - } - -@@ -1645,7 +1673,7 @@ static uint32_t OTA_GetMaxAllowedArchSize(void) - return gFlashMaxStatedSize*2 - current_app_stated_size; - #else - /* Read the value from the psector img directory */ -- uint32_t allowedSize = 0; -+ uint32_t maxImgPages = 0; - uint8_t i; - psector_page_data_t * mPage0Hdl = psector_GetPage0Handle(); - if (mPage0Hdl != NULL) -@@ -1653,12 +1681,12 @@ static uint32_t OTA_GetMaxAllowedArchSize(void) - image_directory_entry_t * currentEntry = mPage0Hdl->page0_v3.img_directory; - for (i=0; iimg_nb_pages > allowedSize) -- allowedSize = currentEntry->img_nb_pages*512; -+ if (currentEntry->img_nb_pages > maxImgPages) -+ maxImgPages = currentEntry->img_nb_pages; - currentEntry++; - } - } -- return allowedSize; -+ return maxImgPages*512; /* 512 corresponding to the size of one page in the internal flash */ - #endif - - } diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/OtaUtils_c.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/OtaUtils_c.patch deleted file mode 100644 index 1814f74bb15502..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/OtaUtils_c.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/OtaUtils.c -+++ b/OtaUtils.c -@@ -92,11 +92,11 @@ typedef uint32_t (*flash_GetDmaccStatus_t)(uint8_t *address); - ************************************************************************************* - ************************************************************************************/ - --const static efuse_LoadUniqueKey_t efuse_LoadUniqueKey = (efuse_LoadUniqueKey_t) ROM_API_efuse_LoadUniqueKey; --const static aesLoadKeyFromOTP_t aesLoadKeyFromOTP = (aesLoadKeyFromOTP_t) ROM_API_aesLoadKeyFromOTP; --const static crc_update_t crc_update = (crc_update_t)ROM_API_crc_update; --const static boot_CheckVectorSum_t boot_CheckVectorSum = (boot_CheckVectorSum_t)ROM_API_boot_CheckVectorSum; --const static flash_GetDmaccStatus_t flash_GetDmaccStatus = (flash_GetDmaccStatus_t) ROM_API_flash_GetDmaccStatus; -+static const efuse_LoadUniqueKey_t efuse_LoadUniqueKey = (efuse_LoadUniqueKey_t) ROM_API_efuse_LoadUniqueKey; -+static const aesLoadKeyFromOTP_t aesLoadKeyFromOTP = (aesLoadKeyFromOTP_t) ROM_API_aesLoadKeyFromOTP; -+static const crc_update_t crc_update = (crc_update_t)ROM_API_crc_update; -+static const boot_CheckVectorSum_t boot_CheckVectorSum = (boot_CheckVectorSum_t)ROM_API_boot_CheckVectorSum; -+static const flash_GetDmaccStatus_t flash_GetDmaccStatus = (flash_GetDmaccStatus_t) ROM_API_flash_GetDmaccStatus; - - /****************************************************************************** - ******************************************************************************* diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/OtaUtils_h.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/OtaUtils_h.patch new file mode 100644 index 00000000000000..35e998bc6e68ca --- /dev/null +++ b/third_party/nxp/k32w0_sdk/sdk_fixes/OtaUtils_h.patch @@ -0,0 +1,24 @@ +--- a/OtaUtils.h ++++ b/OtaUtils.h +@@ -77,6 +77,10 @@ typedef otaUtilsResult_t (*OtaUtils_ReadBytes)(uint16_t nbBytes, + ************************************************************************************* + ********************************************************************************** */ + ++#ifdef __cplusplus ++extern "C" { ++#endif ++ + /*! ********************************************************************************* + * \brief Allows to read bytes from the Internal Flash + * +@@ -185,6 +189,8 @@ uint32_t OtaUtils_ValidateImage(OtaUtils_ReadBytes pFunctionRead, + ********************************************************************************** */ + otaUtilsResult_t OtaUtils_ReconstructRootCert(IMAGE_CERT_T *pCert, const psector_page_data_t* pPage0, const psector_page_data_t* pFlashPage); + +- ++#ifdef __cplusplus ++} ++#endif + + #endif /* _OTA_UTILS_H_ */ +\ No newline at end of file diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/SecLib_h.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/SecLib_h.patch deleted file mode 100644 index a65b5c6537271e..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/SecLib_h.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/SecLib.h -+++ b/SecLib.h -@@ -174,6 +174,10 @@ typedef void(*secLibCallback_t)(computeDhKeyParam_t* pData); - ************************************************************************************* - ************************************************************************************/ - -+#ifdef __cplusplus -+extern "C" { -+#endif -+ - /*! ********************************************************************************* - * \brief This function performs initialization of the cryptographic HW acceleration. - * -@@ -999,5 +1003,10 @@ uint32_t u32Reverse(uint32_t u32InWord); - void vSwipeEndian( AESSW_Block_u *puBlock, - tsReg128 *psReg, - bool_t bBlockToReg ); -+ -+#ifdef __cplusplus -+} -+#endif -+ - #endif /* _SEC_LIB_H_ */ - diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_low_power_h.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_low_power_h.patch deleted file mode 100644 index 54a6eb7190697b..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_low_power_h.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/app_dual_mode_low_power.h -+++ b/app_dual_mode_low_power.h -@@ -43,6 +43,9 @@ typedef enum - * Public prototypes - ************************************************************************************* - ********************************************************************************** */ -+#ifdef __cplusplus -+extern "C" { -+#endif - - void dm_lp_init(void); - -@@ -50,6 +53,10 @@ void dm_lp_preSleep(void); - - void dm_lp_wakeup(void); - --void dm_lp_processEvent(void *pParam); -+void dm_lp_processEvent(void * pParam); -+ -+#ifdef __cplusplus -+} -+#endif - - #endif /* _APP_DUAL_MODE_LOW_POWER_H_ */ diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_switch_h.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_switch_h.patch deleted file mode 100644 index 8ec94c488ea5d9..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_switch_h.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/app_dual_mode_switch.h -+++ b/app_dual_mode_switch.h -@@ -61,6 +61,9 @@ typedef enum { - ************************************************************************************* - ********************************************************************************** */ - -+#ifdef __cplusplus -+extern "C" { -+#endif - /*! ********************************************************************************* - * \brief Runs the dual mode switch Idle Task - * -@@ -91,4 +94,8 @@ uint32_t dm_switch_get15_4InitWakeUpTime(void); - ********************************************************************************** */ - void dm_switch_init15_4AfterWakeUp(void); - -+#ifdef __cplusplus -+} -+#endif -+ - #endif /* _APP_DUAL_MODE_SWITCH_H_ */ diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/ble_utils_h.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/ble_utils_h.patch deleted file mode 100644 index a3fff72f0f33ce..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/ble_utils_h.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/ble_utils.h 2022-01-07 16:41:34.017433835 +0000 -+++ b/ble_utils.h 2022-01-07 16:42:09.797788620 +0000 -@@ -73,11 +73,6 @@ - #define ALIGN_64BIT #pragma pack(8) - #endif - --/*! Marks that this variable is in the interface. */ --#ifndef global --#define global --#endif -- - /*! Marks a function that never returns. */ - #if !defined(__IAR_SYSTEMS_ICC__) - #ifndef __noreturn diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/fsl_os_abstraction_free_rtos_c.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/fsl_os_abstraction_free_rtos_c.patch new file mode 100644 index 00000000000000..2221c979f07b72 --- /dev/null +++ b/third_party/nxp/k32w0_sdk/sdk_fixes/fsl_os_abstraction_free_rtos_c.patch @@ -0,0 +1,54 @@ +--- a/fsl_os_abstraction_free_rtos.c ++++ b/fsl_os_abstraction_free_rtos.c +@@ -344,6 +344,12 @@ osaStatus_t OSA_SemaphoreWait(osaSemaphoreId_t semId, uint32_t millisec) + { + #if osNumberOfSemaphores + uint32_t timeoutTicks; ++ ++ if (xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED) ++ { ++ return osaStatus_Success; ++ } ++ + if(semId == NULL) + { + return osaStatus_Error; +@@ -388,6 +394,12 @@ osaStatus_t OSA_SemaphorePost(osaSemaphoreId_t semId) + { + #if osNumberOfSemaphores + osaStatus_t status = osaStatus_Error; ++ ++ if (xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED) ++ { ++ return osaStatus_Success; ++ } ++ + if(semId) + { + semaphore_t sem = (semaphore_t)semId; +@@ -461,6 +473,12 @@ osaStatus_t OSA_MutexLock(osaMutexId_t mutexId, uint32_t millisec) + #if osNumberOfMutexes + uint32_t timeoutTicks; + mutex_t mutex = (mutex_t)mutexId; ++ ++ if (xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED) ++ { ++ return osaStatus_Success; ++ } ++ + if(mutexId == NULL) + { + return osaStatus_Error; +@@ -506,6 +524,12 @@ osaStatus_t OSA_MutexUnlock(osaMutexId_t mutexId) + { + #if osNumberOfMutexes + mutex_t mutex = (mutex_t)mutexId; ++ ++ if (xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED) ++ { ++ return osaStatus_Success; ++ } ++ + if(mutexId == NULL) + { + return osaStatus_Error; diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/gpio_pins_h.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/gpio_pins_h.patch deleted file mode 100644 index 7dd6f75fa8bdc7..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/gpio_pins_h.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/gpio_pins.h -+++ b/gpio_pins.h -@@ -76,6 +76,11 @@ - #define BOARD_USER_BUTTON3_GPIO_PIN 4U - #define IOCON_USER_BUTTON3_PIN BOARD_USER_BUTTON3_GPIO_PIN - -+#define BOARD_USER_BUTTON4_GPIO GPIO -+#define BOARD_USER_BUTTON4_GPIO_PORT 0U -+#define BOARD_USER_BUTTON4_GPIO_PIN 1U -+#define IOCON_USER_BUTTON4_PIN BOARD_USER_BUTTON4_GPIO_PIN -+ - #endif /* OM15082 */ - - #define IOCON_USER_BUTTON_MODE_FUNC (0U) diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh b/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh index 1ae747ee5dcf23..5d2a66bae9283d 100755 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh +++ b/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh @@ -15,5 +15,11 @@ convert_to_dos() { SOURCE=${BASH_SOURCE[0]} SOURCE_DIR=$(cd "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd) -echo "SDK 2.6.6 doesn't need any patching!" +convert_to_dos "$NXP_K32W0_SDK_ROOT"/middleware/wireless/framework/OSAbstraction/Source/fsl_os_abstraction_free_rtos.c +convert_to_dos "$NXP_K32W0_SDK_ROOT"/middleware/wireless/framework/OtaSupport/Interface/OtaUtils.h + +patch -N --binary -d "$NXP_K32W0_SDK_ROOT"/middleware/wireless/framework/OSAbstraction/Source/ -p1 <"$SOURCE_DIR/fsl_os_abstraction_free_rtos_c.patch" +patch -N --binary -d "$NXP_K32W0_SDK_ROOT"/middleware/wireless/framework/OtaSupport/Interface/ -p1 <"$SOURCE_DIR/OtaUtils_h.patch" + +echo "K32W SDK 2.6.7 was patched!" exit 0 diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/settings_k32w_c.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/settings_k32w_c.patch deleted file mode 100644 index 08571a4d66b795..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/settings_k32w_c.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/settings_k32w.c -+++ b/settings_k32w.c -@@ -52,7 +52,7 @@ - #define NVM_START_ID 0x4F00 - - /* WARNING - the defines below must be in sync with OT NVM datasets from Settings.hpp */ --#define NVM_MAX_ID 7 -+#define NVM_MAX_ID 20 - - static uint8_t sPdmBuffer[pdmBufferSize] __attribute__((aligned(4))) = {0}; - diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/sign_images_sh.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/sign_images_sh.patch deleted file mode 100644 index 43ebc1ed8023b1..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/sign_images_sh.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/sign_images.sh -+++ b/sign_images.sh -@@ -56,7 +56,14 @@ if [ "$#" -gt 0 ]; then - MIME_SET="$(file -ib $FILENAME)" - - if [[ $MIME_SET == *"$MIME_PATTERN"* ]]; then -- python3 $SIGNING_TOOL $FILENAME -+ OTA_ENABLED=0 -+ APP_START=`arm-none-eabi-nm $FILENAME | grep -i m_app_start | cut -d " " -f 1` -+ -+ if [ "$APP_START" -gt 0 ]; then -+ OTA_ENABLED=1 -+ fi -+ -+ python3 $SIGNING_TOOL -i="$OTA_ENABLED" $FILENAME - arm-none-eabi-objcopy -O binary $FILENAME $FILENAME.bin - fi - done diff --git a/third_party/openthread/ot-nxp b/third_party/openthread/ot-nxp index 611561714fed15..24bf5d185d039e 160000 --- a/third_party/openthread/ot-nxp +++ b/third_party/openthread/ot-nxp @@ -1 +1 @@ -Subproject commit 611561714fed15d8046c30933f3d3b84b6a9908c +Subproject commit 24bf5d185d039e89f651310c7f690f3cc72a55ff diff --git a/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn b/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn index c6946d3d1d06ab..1edf9ab9e960c4 100644 --- a/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn +++ b/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn @@ -37,6 +37,8 @@ config("openthread_k32w0_config") { defines = [ "OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1", "OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1", + "PDM_SAVE_IDLE=1", + "K32W0_RADIO_NUM_OF_RX_BUFS=16", ] } diff --git a/third_party/qpg_sdk/repo b/third_party/qpg_sdk/repo index e92a7eb78f7f8a..8aadeb12092272 160000 --- a/third_party/qpg_sdk/repo +++ b/third_party/qpg_sdk/repo @@ -1 +1 @@ -Subproject commit e92a7eb78f7f8aa4de774cdd973272767eab2e8a +Subproject commit 8aadeb120922720aba2bf0be8d5230d979856a4e diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 22fa2d0aac59b9..bd7876d48ebb2c 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -80,6 +80,7 @@ template("efr32_sdk") { _include_dirs = [ "${efr32_sdk_root}", "${efr32_sdk_root}/hardware/kit/common/bsp", + "${efr32_sdk_root}/app/common/util/app_assert/", "${efr32_sdk_root}/hardware/board/inc", "${efr32_sdk_root}/hardware/driver/memlcd/inc", "${efr32_sdk_root}/hardware/driver/memlcd/src/ls013b7dh03", @@ -134,6 +135,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/base/hal/plugin/psstore", "${efr32_sdk_root}/platform/base/hal/plugin/antenna", "${efr32_sdk_root}/protocol/bluetooth/inc/", + "${efr32_sdk_root}/app/bluetooth/common/in_place_ota_dfu/", "${efr32_sdk_root}/util/plugin/plugin-common/fem-control", "${efr32_sdk_root}/util/silicon_labs/silabs_core/graphics", "${efr32_sdk_root}/util/silicon_labs/silabs_core/memory_manager", @@ -385,6 +387,7 @@ template("efr32_sdk") { source_set(sdk_target_name) { sources = [ "${chip_root}/third_party/mbedtls/repo/include/mbedtls/platform.h", + "${efr32_sdk_root}/app/bluetooth/common/in_place_ota_dfu/sl_bt_in_place_ota_dfu.c", "${efr32_sdk_root}/hardware/board/src/sl_board_control_gpio.c", "${efr32_sdk_root}/hardware/board/src/sl_board_init.c", "${efr32_sdk_root}/platform/CMSIS/RTOS2/Source/os_systick.c", @@ -438,6 +441,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/service/udelay/src/sl_udelay.c", "${efr32_sdk_root}/platform/service/udelay/src/sl_udelay_armv6m_gcc.S", "${efr32_sdk_root}/protocol/bluetooth/src/sl_bt_mbedtls_context.c", + "${efr32_sdk_root}/protocol/bluetooth/src/sl_bt_rtos_adaptation.c", "${efr32_sdk_root}/protocol/bluetooth/src/sl_bt_stack_init.c", "${efr32_sdk_root}/protocol/bluetooth/src/sli_bt_advertiser_config.c", "${efr32_sdk_root}/protocol/bluetooth/src/sli_bt_connection_config.c", @@ -553,6 +557,8 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/freertos/kernel/stream_buffer.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/tasks.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/timers.c", + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/gatt_db.c", + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_bluetooth.c", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_board_default_init.c", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_device_init_clocks.c", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_event_handler.c", @@ -639,6 +645,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_emu_s1.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_hfxo_s1.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_lfxo_s1.c", + "${efr32_sdk_root}/protocol/bluetooth/src/sl_apploader_util_s1.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/GCC/ARM_CM4F/port.c", ] } else if (silabs_family == "efr32mg21") { @@ -686,11 +693,11 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG24/Source/system_efr32mg24.c", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions/pa_curves_efr32.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_dcdc_s2.c", - "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_dpll_s2.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_emu_s2.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_hfxo_s2.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_lfxo_s2.c", "${efr32_sdk_root}/platform/service/hfxo_manager/src/sl_hfxo_manager_hal_s2.c", + "${efr32_sdk_root}/protocol/bluetooth/src/sl_apploader_util_s2.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_attestation.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_cipher.c", @@ -730,6 +737,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_hfxo_mgm24.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_lfxo_s2.c", "${efr32_sdk_root}/platform/service/hfxo_manager/src/sl_hfxo_manager_hal_s2.c", + "${efr32_sdk_root}/protocol/bluetooth/src/sl_apploader_util_s2.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_attestation.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_cipher.c", @@ -761,6 +769,11 @@ template("efr32_sdk") { ] } + if (silabs_board == "BRD4186A" || silabs_board == "BRD4186C" || + silabs_board == "BRD4187A" || silabs_board == "BRD4187C") { + sources += [ "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_dpll_s2.c" ] + } + public_deps = [ ":efr32_mbedtls_config", "${segger_rtt_root}:segger_rtt", diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 48483a67a123a4..d9f3fb767d7b4a 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 48483a67a123a4ecd72bbd4f4a201e49ad18e8fd +Subproject commit d9f3fb767d7b4a79d664b0c635ffe6d777a812f2 diff --git a/zzz_generated/lighting-app/nxp/zap-generated/CHIPClientCallbacks.h b/zzz_generated/lighting-app/nxp/zap-generated/CHIPClientCallbacks.h new file mode 100644 index 00000000000000..4458f51745a59b --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/CHIPClientCallbacks.h @@ -0,0 +1,32 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// List specific responses diff --git a/zzz_generated/lighting-app/nxp/zap-generated/CHIPClusters.h b/zzz_generated/lighting-app/nxp/zap-generated/CHIPClusters.h new file mode 100644 index 00000000000000..fffb265ae9c797 --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/CHIPClusters.h @@ -0,0 +1,44 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +// Prevent multiple inclusion +#pragma once + +#include +#include + +#include +#include +#include + +namespace chip { +namespace Controller { + +class DLL_EXPORT OtaSoftwareUpdateProviderCluster : public ClusterBase +{ +public: + OtaSoftwareUpdateProviderCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, + EndpointId endpoint) : + ClusterBase(exchangeManager, session, app::Clusters::OtaSoftwareUpdateProvider::Id, endpoint) + {} + ~OtaSoftwareUpdateProviderCluster() {} +}; + +} // namespace Controller +} // namespace chip diff --git a/zzz_generated/lighting-app/nxp/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/lighting-app/nxp/zap-generated/IMClusterCommandHandler.cpp new file mode 100644 index 00000000000000..ca173e1ae470bc --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/IMClusterCommandHandler.cpp @@ -0,0 +1,905 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Currently we need some work to keep compatible with ember lib. +#include + +namespace chip { +namespace app { + +// Cluster specific command parsing + +namespace Clusters { + +namespace AdministratorCommissioning { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::OpenCommissioningWindow::Id: { + Commands::OpenCommissioningWindow::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfAdministratorCommissioningClusterOpenCommissioningWindowCallback(apCommandObj, aCommandPath, + commandData); + } + break; + } + case Commands::RevokeCommissioning::Id: { + Commands::RevokeCommissioning::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfAdministratorCommissioningClusterRevokeCommissioningCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace AdministratorCommissioning + +namespace GeneralCommissioning { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::ArmFailSafe::Id: { + Commands::ArmFailSafe::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGeneralCommissioningClusterArmFailSafeCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::SetRegulatoryConfig::Id: { + Commands::SetRegulatoryConfig::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::CommissioningComplete::Id: { + Commands::CommissioningComplete::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfGeneralCommissioningClusterCommissioningCompleteCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace GeneralCommissioning + +namespace GeneralDiagnostics { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::TestEventTrigger::Id: { + Commands::TestEventTrigger::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGeneralDiagnosticsClusterTestEventTriggerCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace GeneralDiagnostics + +namespace GroupKeyManagement { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::KeySetWrite::Id: { + Commands::KeySetWrite::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupKeyManagementClusterKeySetWriteCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::KeySetRead::Id: { + Commands::KeySetRead::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupKeyManagementClusterKeySetReadCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::KeySetRemove::Id: { + Commands::KeySetRemove::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupKeyManagementClusterKeySetRemoveCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::KeySetReadAllIndices::Id: { + Commands::KeySetReadAllIndices::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupKeyManagementClusterKeySetReadAllIndicesCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace GroupKeyManagement + +namespace Groups { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::AddGroup::Id: { + Commands::AddGroup::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupsClusterAddGroupCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::ViewGroup::Id: { + Commands::ViewGroup::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupsClusterViewGroupCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::GetGroupMembership::Id: { + Commands::GetGroupMembership::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupsClusterGetGroupMembershipCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::RemoveGroup::Id: { + Commands::RemoveGroup::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupsClusterRemoveGroupCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::RemoveAllGroups::Id: { + Commands::RemoveAllGroups::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupsClusterRemoveAllGroupsCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::AddGroupIfIdentifying::Id: { + Commands::AddGroupIfIdentifying::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupsClusterAddGroupIfIdentifyingCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace Groups + +namespace Identify { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::Identify::Id: { + Commands::Identify::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfIdentifyClusterIdentifyCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::TriggerEffect::Id: { + Commands::TriggerEffect::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfIdentifyClusterTriggerEffectCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace Identify + +namespace LevelControl { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::MoveToLevel::Id: { + Commands::MoveToLevel::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterMoveToLevelCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::Move::Id: { + Commands::Move::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterMoveCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::Step::Id: { + Commands::Step::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterStepCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::Stop::Id: { + Commands::Stop::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterStopCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::MoveToLevelWithOnOff::Id: { + Commands::MoveToLevelWithOnOff::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterMoveToLevelWithOnOffCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::MoveWithOnOff::Id: { + Commands::MoveWithOnOff::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterMoveWithOnOffCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::StepWithOnOff::Id: { + Commands::StepWithOnOff::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterStepWithOnOffCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::StopWithOnOff::Id: { + Commands::StopWithOnOff::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterStopWithOnOffCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace LevelControl + +namespace NetworkCommissioning { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::ScanNetworks::Id: { + Commands::ScanNetworks::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfNetworkCommissioningClusterScanNetworksCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::AddOrUpdateThreadNetwork::Id: { + Commands::AddOrUpdateThreadNetwork::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfNetworkCommissioningClusterAddOrUpdateThreadNetworkCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::RemoveNetwork::Id: { + Commands::RemoveNetwork::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfNetworkCommissioningClusterRemoveNetworkCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::ConnectNetwork::Id: { + Commands::ConnectNetwork::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfNetworkCommissioningClusterConnectNetworkCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::ReorderNetwork::Id: { + Commands::ReorderNetwork::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfNetworkCommissioningClusterReorderNetworkCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace NetworkCommissioning + +namespace OtaSoftwareUpdateRequestor { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::AnnounceOtaProvider::Id: { + Commands::AnnounceOtaProvider::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfOtaSoftwareUpdateRequestorClusterAnnounceOtaProviderCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace OtaSoftwareUpdateRequestor + +namespace OnOff { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::Off::Id: { + Commands::Off::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOffCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::On::Id: { + Commands::On::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOnCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::Toggle::Id: { + Commands::Toggle::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterToggleCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::OffWithEffect::Id: { + Commands::OffWithEffect::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOffWithEffectCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::OnWithRecallGlobalScene::Id: { + Commands::OnWithRecallGlobalScene::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOnWithRecallGlobalSceneCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::OnWithTimedOff::Id: { + Commands::OnWithTimedOff::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOnWithTimedOffCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace OnOff + +namespace OperationalCredentials { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::AttestationRequest::Id: { + Commands::AttestationRequest::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfOperationalCredentialsClusterAttestationRequestCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::CertificateChainRequest::Id: { + Commands::CertificateChainRequest::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfOperationalCredentialsClusterCertificateChainRequestCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::CSRRequest::Id: { + Commands::CSRRequest::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOperationalCredentialsClusterCSRRequestCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::AddNOC::Id: { + Commands::AddNOC::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOperationalCredentialsClusterAddNOCCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::UpdateNOC::Id: { + Commands::UpdateNOC::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOperationalCredentialsClusterUpdateNOCCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::UpdateFabricLabel::Id: { + Commands::UpdateFabricLabel::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOperationalCredentialsClusterUpdateFabricLabelCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::RemoveFabric::Id: { + Commands::RemoveFabric::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOperationalCredentialsClusterRemoveFabricCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::AddTrustedRootCertificate::Id: { + Commands::AddTrustedRootCertificate::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace OperationalCredentials + +namespace SoftwareDiagnostics { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::ResetWatermarks::Id: { + Commands::ResetWatermarks::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfSoftwareDiagnosticsClusterResetWatermarksCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace SoftwareDiagnostics + +namespace ThreadNetworkDiagnostics { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::ResetCounts::Id: { + Commands::ResetCounts::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfThreadNetworkDiagnosticsClusterResetCountsCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace ThreadNetworkDiagnostics + +} // namespace Clusters + +void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) +{ + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); + + switch (aCommandPath.mClusterId) + { + case Clusters::AdministratorCommissioning::Id: + Clusters::AdministratorCommissioning::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::GeneralCommissioning::Id: + Clusters::GeneralCommissioning::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::GeneralDiagnostics::Id: + Clusters::GeneralDiagnostics::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::GroupKeyManagement::Id: + Clusters::GroupKeyManagement::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::Groups::Id: + Clusters::Groups::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::Identify::Id: + Clusters::Identify::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::LevelControl::Id: + Clusters::LevelControl::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::NetworkCommissioning::Id: + Clusters::NetworkCommissioning::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::OtaSoftwareUpdateRequestor::Id: + Clusters::OtaSoftwareUpdateRequestor::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::OnOff::Id: + Clusters::OnOff::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::OperationalCredentials::Id: + Clusters::OperationalCredentials::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::SoftwareDiagnostics::Id: + Clusters::SoftwareDiagnostics::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::ThreadNetworkDiagnostics::Id: + Clusters::ThreadNetworkDiagnostics::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + default: + ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); + break; + } + + Compatibility::ResetEmberAfObjects(); +} + +} // namespace app +} // namespace chip diff --git a/zzz_generated/lighting-app/nxp/zap-generated/PluginApplicationCallbacks.h b/zzz_generated/lighting-app/nxp/zap-generated/PluginApplicationCallbacks.h new file mode 100644 index 00000000000000..0cfb01937c9d9f --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/PluginApplicationCallbacks.h @@ -0,0 +1,41 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +#pragma once + +#include + +#define MATTER_PLUGINS_INIT \ + MatterIdentifyPluginServerInitCallback(); \ + MatterGroupsPluginServerInitCallback(); \ + MatterOnOffPluginServerInitCallback(); \ + MatterLevelControlPluginServerInitCallback(); \ + MatterDescriptorPluginServerInitCallback(); \ + MatterAccessControlPluginServerInitCallback(); \ + MatterBasicPluginServerInitCallback(); \ + MatterOtaSoftwareUpdateProviderPluginClientInitCallback(); \ + MatterOtaSoftwareUpdateRequestorPluginServerInitCallback(); \ + MatterGeneralCommissioningPluginServerInitCallback(); \ + MatterNetworkCommissioningPluginServerInitCallback(); \ + MatterGeneralDiagnosticsPluginServerInitCallback(); \ + MatterSoftwareDiagnosticsPluginServerInitCallback(); \ + MatterThreadNetworkDiagnosticsPluginServerInitCallback(); \ + MatterAdministratorCommissioningPluginServerInitCallback(); \ + MatterOperationalCredentialsPluginServerInitCallback(); \ + MatterGroupKeyManagementPluginServerInitCallback(); diff --git a/zzz_generated/lighting-app/nxp/zap-generated/access.h b/zzz_generated/lighting-app/nxp/zap-generated/access.h new file mode 100644 index 00000000000000..b1932aec7b2088 --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/access.h @@ -0,0 +1,254 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +// Prevent multiple inclusion +#pragma once + +#include + +// Prevent changing generated format +// clang-format off + +//////////////////////////////////////////////////////////////////////////////// + +// Parallel array data (*cluster*, attribute, privilege) for read attribute +#define GENERATED_ACCESS_READ_ATTRIBUTE__CLUSTER { \ + /* Cluster: On/Off, Attribute: StartUpOnOff, Privilege: view */ \ + /* Cluster: Level Control, Attribute: StartUpCurrentLevel, Privilege: view */ \ + 31, /* Cluster: Access Control, Attribute: ACL, Privilege: administer */ \ + /* Cluster: Access Control, Attribute: SubjectsPerAccessControlEntry, Privilege: view */ \ + /* Cluster: Access Control, Attribute: TargetsPerAccessControlEntry, Privilege: view */ \ + /* Cluster: Access Control, Attribute: AccessControlEntriesPerFabric, Privilege: view */ \ + /* Cluster: Basic, Attribute: NodeLabel, Privilege: view */ \ + /* Cluster: Basic, Attribute: Location, Privilege: view */ \ + /* Cluster: General Commissioning, Attribute: Breadcrumb, Privilege: view */ \ + 49, /* Cluster: Network Commissioning, Attribute: MaxNetworks, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Attribute: Networks, Privilege: administer */ \ + /* Cluster: Network Commissioning, Attribute: InterfaceEnabled, Privilege: view */ \ + 49, /* Cluster: Network Commissioning, Attribute: LastNetworkingStatus, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Attribute: LastNetworkID, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Attribute: LastConnectErrorValue, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Attribute: NOCs, Privilege: administer */ \ + /* Cluster: Group Key Management, Attribute: GroupKeyMap, Privilege: view */ \ +} + +// Parallel array data (cluster, *attribute*, privilege) for read attribute +#define GENERATED_ACCESS_READ_ATTRIBUTE__ATTRIBUTE { \ + /* Cluster: On/Off, Attribute: StartUpOnOff, Privilege: view */ \ + /* Cluster: Level Control, Attribute: StartUpCurrentLevel, Privilege: view */ \ + 0, /* Cluster: Access Control, Attribute: ACL, Privilege: administer */ \ + /* Cluster: Access Control, Attribute: SubjectsPerAccessControlEntry, Privilege: view */ \ + /* Cluster: Access Control, Attribute: TargetsPerAccessControlEntry, Privilege: view */ \ + /* Cluster: Access Control, Attribute: AccessControlEntriesPerFabric, Privilege: view */ \ + /* Cluster: Basic, Attribute: NodeLabel, Privilege: view */ \ + /* Cluster: Basic, Attribute: Location, Privilege: view */ \ + /* Cluster: General Commissioning, Attribute: Breadcrumb, Privilege: view */ \ + 0, /* Cluster: Network Commissioning, Attribute: MaxNetworks, Privilege: administer */ \ + 1, /* Cluster: Network Commissioning, Attribute: Networks, Privilege: administer */ \ + /* Cluster: Network Commissioning, Attribute: InterfaceEnabled, Privilege: view */ \ + 5, /* Cluster: Network Commissioning, Attribute: LastNetworkingStatus, Privilege: administer */ \ + 6, /* Cluster: Network Commissioning, Attribute: LastNetworkID, Privilege: administer */ \ + 7, /* Cluster: Network Commissioning, Attribute: LastConnectErrorValue, Privilege: administer */ \ + 0, /* Cluster: Operational Credentials, Attribute: NOCs, Privilege: administer */ \ + /* Cluster: Group Key Management, Attribute: GroupKeyMap, Privilege: view */ \ +} + +// Parallel array data (cluster, attribute, *privilege*) for read attribute +#define GENERATED_ACCESS_READ_ATTRIBUTE__PRIVILEGE { \ + /* Cluster: On/Off, Attribute: StartUpOnOff, Privilege: view */ \ + /* Cluster: Level Control, Attribute: StartUpCurrentLevel, Privilege: view */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Access Control, Attribute: ACL, Privilege: administer */ \ + /* Cluster: Access Control, Attribute: SubjectsPerAccessControlEntry, Privilege: view */ \ + /* Cluster: Access Control, Attribute: TargetsPerAccessControlEntry, Privilege: view */ \ + /* Cluster: Access Control, Attribute: AccessControlEntriesPerFabric, Privilege: view */ \ + /* Cluster: Basic, Attribute: NodeLabel, Privilege: view */ \ + /* Cluster: Basic, Attribute: Location, Privilege: view */ \ + /* Cluster: General Commissioning, Attribute: Breadcrumb, Privilege: view */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Attribute: MaxNetworks, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Attribute: Networks, Privilege: administer */ \ + /* Cluster: Network Commissioning, Attribute: InterfaceEnabled, Privilege: view */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Attribute: LastNetworkingStatus, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Attribute: LastNetworkID, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Attribute: LastConnectErrorValue, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Attribute: NOCs, Privilege: administer */ \ + /* Cluster: Group Key Management, Attribute: GroupKeyMap, Privilege: view */ \ +} + +//////////////////////////////////////////////////////////////////////////////// + +// Parallel array data (*cluster*, attribute, privilege) for write attribute +#define GENERATED_ACCESS_WRITE_ATTRIBUTE__CLUSTER { \ + 6, /* Cluster: On/Off, Attribute: StartUpOnOff, Privilege: manage */ \ + 8, /* Cluster: Level Control, Attribute: StartUpCurrentLevel, Privilege: manage */ \ + 31, /* Cluster: Access Control, Attribute: ACL, Privilege: administer */ \ + 40, /* Cluster: Basic, Attribute: NodeLabel, Privilege: manage */ \ + 40, /* Cluster: Basic, Attribute: Location, Privilege: administer */ \ + 48, /* Cluster: General Commissioning, Attribute: Breadcrumb, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Attribute: InterfaceEnabled, Privilege: administer */ \ + 63, /* Cluster: Group Key Management, Attribute: GroupKeyMap, Privilege: manage */ \ +} + +// Parallel array data (cluster, *attribute*, privilege) for write attribute +#define GENERATED_ACCESS_WRITE_ATTRIBUTE__ATTRIBUTE { \ + 16387, /* Cluster: On/Off, Attribute: StartUpOnOff, Privilege: manage */ \ + 16384, /* Cluster: Level Control, Attribute: StartUpCurrentLevel, Privilege: manage */ \ + 0, /* Cluster: Access Control, Attribute: ACL, Privilege: administer */ \ + 5, /* Cluster: Basic, Attribute: NodeLabel, Privilege: manage */ \ + 6, /* Cluster: Basic, Attribute: Location, Privilege: administer */ \ + 0, /* Cluster: General Commissioning, Attribute: Breadcrumb, Privilege: administer */ \ + 4, /* Cluster: Network Commissioning, Attribute: InterfaceEnabled, Privilege: administer */ \ + 0, /* Cluster: Group Key Management, Attribute: GroupKeyMap, Privilege: manage */ \ +} + +// Parallel array data (cluster, attribute, *privilege*) for write attribute +#define GENERATED_ACCESS_WRITE_ATTRIBUTE__PRIVILEGE { \ + kMatterAccessPrivilegeManage, /* Cluster: On/Off, Attribute: StartUpOnOff, Privilege: manage */ \ + kMatterAccessPrivilegeManage, /* Cluster: Level Control, Attribute: StartUpCurrentLevel, Privilege: manage */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Access Control, Attribute: ACL, Privilege: administer */ \ + kMatterAccessPrivilegeManage, /* Cluster: Basic, Attribute: NodeLabel, Privilege: manage */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Basic, Attribute: Location, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: General Commissioning, Attribute: Breadcrumb, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Attribute: InterfaceEnabled, Privilege: administer */ \ + kMatterAccessPrivilegeManage, /* Cluster: Group Key Management, Attribute: GroupKeyMap, Privilege: manage */ \ +} + +//////////////////////////////////////////////////////////////////////////////// + +// Parallel array data (*cluster*, command, privilege) for invoke command +#define GENERATED_ACCESS_INVOKE_COMMAND__CLUSTER { \ + 3, /* Cluster: Identify, Command: Identify, Privilege: manage */ \ + 3, /* Cluster: Identify, Command: TriggerEffect, Privilege: manage */ \ + 4, /* Cluster: Groups, Command: AddGroup, Privilege: manage */ \ + 4, /* Cluster: Groups, Command: RemoveGroup, Privilege: manage */ \ + 4, /* Cluster: Groups, Command: RemoveAllGroups, Privilege: manage */ \ + 4, /* Cluster: Groups, Command: AddGroupIfIdentifying, Privilege: manage */ \ + 48, /* Cluster: General Commissioning, Command: ArmFailSafe, Privilege: administer */ \ + 48, /* Cluster: General Commissioning, Command: SetRegulatoryConfig, Privilege: administer */ \ + 48, /* Cluster: General Commissioning, Command: CommissioningComplete, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Command: ScanNetworks, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Command: AddOrUpdateThreadNetwork, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Command: RemoveNetwork, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Command: ConnectNetwork, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Command: ReorderNetwork, Privilege: administer */ \ + 51, /* Cluster: General Diagnostics, Command: TestEventTrigger, Privilege: manage */ \ + 60, /* Cluster: AdministratorCommissioning, Command: OpenCommissioningWindow, Privilege: administer */ \ + 60, /* Cluster: AdministratorCommissioning, Command: RevokeCommissioning, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: AttestationRequest, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: CertificateChainRequest, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: CSRRequest, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: AddNOC, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: UpdateNOC, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: UpdateFabricLabel, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: RemoveFabric, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: AddTrustedRootCertificate, Privilege: administer */ \ + 63, /* Cluster: Group Key Management, Command: KeySetWrite, Privilege: administer */ \ + 63, /* Cluster: Group Key Management, Command: KeySetRead, Privilege: administer */ \ + 63, /* Cluster: Group Key Management, Command: KeySetRemove, Privilege: administer */ \ + 63, /* Cluster: Group Key Management, Command: KeySetReadAllIndices, Privilege: administer */ \ +} + +// Parallel array data (cluster, *command*, privilege) for invoke command +#define GENERATED_ACCESS_INVOKE_COMMAND__COMMAND { \ + 0, /* Cluster: Identify, Command: Identify, Privilege: manage */ \ + 64, /* Cluster: Identify, Command: TriggerEffect, Privilege: manage */ \ + 0, /* Cluster: Groups, Command: AddGroup, Privilege: manage */ \ + 3, /* Cluster: Groups, Command: RemoveGroup, Privilege: manage */ \ + 4, /* Cluster: Groups, Command: RemoveAllGroups, Privilege: manage */ \ + 5, /* Cluster: Groups, Command: AddGroupIfIdentifying, Privilege: manage */ \ + 0, /* Cluster: General Commissioning, Command: ArmFailSafe, Privilege: administer */ \ + 2, /* Cluster: General Commissioning, Command: SetRegulatoryConfig, Privilege: administer */ \ + 4, /* Cluster: General Commissioning, Command: CommissioningComplete, Privilege: administer */ \ + 0, /* Cluster: Network Commissioning, Command: ScanNetworks, Privilege: administer */ \ + 3, /* Cluster: Network Commissioning, Command: AddOrUpdateThreadNetwork, Privilege: administer */ \ + 4, /* Cluster: Network Commissioning, Command: RemoveNetwork, Privilege: administer */ \ + 6, /* Cluster: Network Commissioning, Command: ConnectNetwork, Privilege: administer */ \ + 8, /* Cluster: Network Commissioning, Command: ReorderNetwork, Privilege: administer */ \ + 0, /* Cluster: General Diagnostics, Command: TestEventTrigger, Privilege: manage */ \ + 0, /* Cluster: AdministratorCommissioning, Command: OpenCommissioningWindow, Privilege: administer */ \ + 2, /* Cluster: AdministratorCommissioning, Command: RevokeCommissioning, Privilege: administer */ \ + 0, /* Cluster: Operational Credentials, Command: AttestationRequest, Privilege: administer */ \ + 2, /* Cluster: Operational Credentials, Command: CertificateChainRequest, Privilege: administer */ \ + 4, /* Cluster: Operational Credentials, Command: CSRRequest, Privilege: administer */ \ + 6, /* Cluster: Operational Credentials, Command: AddNOC, Privilege: administer */ \ + 7, /* Cluster: Operational Credentials, Command: UpdateNOC, Privilege: administer */ \ + 9, /* Cluster: Operational Credentials, Command: UpdateFabricLabel, Privilege: administer */ \ + 10, /* Cluster: Operational Credentials, Command: RemoveFabric, Privilege: administer */ \ + 11, /* Cluster: Operational Credentials, Command: AddTrustedRootCertificate, Privilege: administer */ \ + 0, /* Cluster: Group Key Management, Command: KeySetWrite, Privilege: administer */ \ + 1, /* Cluster: Group Key Management, Command: KeySetRead, Privilege: administer */ \ + 3, /* Cluster: Group Key Management, Command: KeySetRemove, Privilege: administer */ \ + 4, /* Cluster: Group Key Management, Command: KeySetReadAllIndices, Privilege: administer */ \ +} + +// Parallel array data (cluster, command, *privilege*) for invoke command +#define GENERATED_ACCESS_INVOKE_COMMAND__PRIVILEGE { \ + kMatterAccessPrivilegeManage, /* Cluster: Identify, Command: Identify, Privilege: manage */ \ + kMatterAccessPrivilegeManage, /* Cluster: Identify, Command: TriggerEffect, Privilege: manage */ \ + kMatterAccessPrivilegeManage, /* Cluster: Groups, Command: AddGroup, Privilege: manage */ \ + kMatterAccessPrivilegeManage, /* Cluster: Groups, Command: RemoveGroup, Privilege: manage */ \ + kMatterAccessPrivilegeManage, /* Cluster: Groups, Command: RemoveAllGroups, Privilege: manage */ \ + kMatterAccessPrivilegeManage, /* Cluster: Groups, Command: AddGroupIfIdentifying, Privilege: manage */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: General Commissioning, Command: ArmFailSafe, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: General Commissioning, Command: SetRegulatoryConfig, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: General Commissioning, Command: CommissioningComplete, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Command: ScanNetworks, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Command: AddOrUpdateThreadNetwork, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Command: RemoveNetwork, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Command: ConnectNetwork, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Command: ReorderNetwork, Privilege: administer */ \ + kMatterAccessPrivilegeManage, /* Cluster: General Diagnostics, Command: TestEventTrigger, Privilege: manage */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: AdministratorCommissioning, Command: OpenCommissioningWindow, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: AdministratorCommissioning, Command: RevokeCommissioning, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: AttestationRequest, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: CertificateChainRequest, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: CSRRequest, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: AddNOC, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: UpdateNOC, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: UpdateFabricLabel, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: RemoveFabric, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: AddTrustedRootCertificate, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Group Key Management, Command: KeySetWrite, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Group Key Management, Command: KeySetRead, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Group Key Management, Command: KeySetRemove, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Group Key Management, Command: KeySetReadAllIndices, Privilege: administer */ \ +} + +//////////////////////////////////////////////////////////////////////////////// + +// Parallel array data (*cluster*, event, privilege) for read event +#define GENERATED_ACCESS_READ_EVENT__CLUSTER { \ + 31, /* Cluster: Access Control, Event: AccessControlEntryChanged, Privilege: administer */ \ + 31, /* Cluster: Access Control, Event: AccessControlExtensionChanged, Privilege: administer */ \ +} + +// Parallel array data (cluster, *event*, privilege) for read event +#define GENERATED_ACCESS_READ_EVENT__EVENT { \ + 0, /* Cluster: Access Control, Event: AccessControlEntryChanged, Privilege: administer */ \ + 1, /* Cluster: Access Control, Event: AccessControlExtensionChanged, Privilege: administer */ \ +} + +// Parallel array data (cluster, event, *privilege*) for read event +#define GENERATED_ACCESS_READ_EVENT__PRIVILEGE { \ + kMatterAccessPrivilegeAdminister, /* Cluster: Access Control, Event: AccessControlEntryChanged, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Access Control, Event: AccessControlExtensionChanged, Privilege: administer */ \ +} + +//////////////////////////////////////////////////////////////////////////////// + +// clang-format on diff --git a/zzz_generated/lighting-app/nxp/zap-generated/af-gen-event.h b/zzz_generated/lighting-app/nxp/zap-generated/af-gen-event.h new file mode 100644 index 00000000000000..814d4aab6b8bec --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/af-gen-event.h @@ -0,0 +1,39 @@ +/** + * + * Copyright (c) 2020 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +/** + * + * Copyright (c) 2020 Silicon Labs + * + * 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. + */ + +// Enclosing macro to prevent multiple inclusion +#ifndef __AF_GEN_EVENT__ +#define __AF_GEN_EVENT__ + +#endif // __AF_GEN_EVENT__ diff --git a/zzz_generated/lighting-app/nxp/zap-generated/callback-stub.cpp b/zzz_generated/lighting-app/nxp/zap-generated/callback-stub.cpp new file mode 100644 index 00000000000000..b809a1f1b65cb6 --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/callback-stub.cpp @@ -0,0 +1,263 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +#include +#include +#include +#include + +using namespace chip; + +// Cluster Init Functions +void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) +{ + switch (clusterId) + { + case ZCL_ACCESS_CONTROL_CLUSTER_ID: + emberAfAccessControlClusterInitCallback(endpoint); + break; + case ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_ID: + emberAfAdministratorCommissioningClusterInitCallback(endpoint); + break; + case ZCL_BASIC_CLUSTER_ID: + emberAfBasicClusterInitCallback(endpoint); + break; + case ZCL_DESCRIPTOR_CLUSTER_ID: + emberAfDescriptorClusterInitCallback(endpoint); + break; + case ZCL_GENERAL_COMMISSIONING_CLUSTER_ID: + emberAfGeneralCommissioningClusterInitCallback(endpoint); + break; + case ZCL_GENERAL_DIAGNOSTICS_CLUSTER_ID: + emberAfGeneralDiagnosticsClusterInitCallback(endpoint); + break; + case ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID: + emberAfGroupKeyManagementClusterInitCallback(endpoint); + break; + case ZCL_GROUPS_CLUSTER_ID: + emberAfGroupsClusterInitCallback(endpoint); + break; + case ZCL_IDENTIFY_CLUSTER_ID: + emberAfIdentifyClusterInitCallback(endpoint); + break; + case ZCL_LEVEL_CONTROL_CLUSTER_ID: + emberAfLevelControlClusterInitCallback(endpoint); + break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + emberAfNetworkCommissioningClusterInitCallback(endpoint); + break; + case ZCL_OTA_PROVIDER_CLUSTER_ID: + emberAfOtaSoftwareUpdateProviderClusterInitCallback(endpoint); + break; + case ZCL_OTA_REQUESTOR_CLUSTER_ID: + emberAfOtaSoftwareUpdateRequestorClusterInitCallback(endpoint); + break; + case ZCL_ON_OFF_CLUSTER_ID: + emberAfOnOffClusterInitCallback(endpoint); + break; + case ZCL_OPERATIONAL_CREDENTIALS_CLUSTER_ID: + emberAfOperationalCredentialsClusterInitCallback(endpoint); + break; + case ZCL_SOFTWARE_DIAGNOSTICS_CLUSTER_ID: + emberAfSoftwareDiagnosticsClusterInitCallback(endpoint); + break; + case ZCL_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_ID: + emberAfThreadNetworkDiagnosticsClusterInitCallback(endpoint); + break; + default: + // Unrecognized cluster ID + break; + } +} + +void __attribute__((weak)) emberAfAccessControlClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfAdministratorCommissioningClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfBasicClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfDescriptorClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfGeneralCommissioningClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfGeneralDiagnosticsClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfGroupKeyManagementClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfGroupsClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfIdentifyClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfLevelControlClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfNetworkCommissioningClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfOtaSoftwareUpdateProviderClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfOtaSoftwareUpdateRequestorClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfOperationalCredentialsClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfSoftwareDiagnosticsClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfThreadNetworkDiagnosticsClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} + +// +// Non-Cluster Related Callbacks +// + +void __attribute__((weak)) emberAfAddToCurrentAppTasksCallback(EmberAfApplicationTask tasks) {} + +void __attribute__((weak)) emberAfRemoveFromCurrentAppTasksCallback(EmberAfApplicationTask tasks) {} + +EmberAfAttributeWritePermission __attribute__((weak)) +emberAfAllowNetworkWriteAttributeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t * value, + uint8_t type) +{ + return EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL; // Default +} + +bool __attribute__((weak)) emberAfAttributeReadAccessCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId) +{ + return true; +} + +bool __attribute__((weak)) emberAfAttributeWriteAccessCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId) +{ + return true; +} + +bool __attribute__((weak)) emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, EmberAfStatus status) +{ + return false; +} + +bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberStatus * status) +{ + return false; +} + +bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status) +{ + return false; +} + +EmberAfStatus __attribute__((weak)) +emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer, uint16_t maxReadLength) +{ + return EMBER_ZCL_STATUS_FAILURE; +} + +EmberAfStatus __attribute__((weak)) +emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer) +{ + return EMBER_ZCL_STATUS_FAILURE; +} + +uint32_t __attribute__((weak)) emberAfGetCurrentTimeCallback() +{ + return 0; +} + +bool __attribute__((weak)) +emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex, EmberAfEndpointInfoStruct * returnEndpointInfo) +{ + return false; +} + +void __attribute__((weak)) emberAfRegistrationAbortCallback() {} + +EmberStatus __attribute__((weak)) +emberAfInterpanSendMessageCallback(EmberAfInterpanHeader * header, uint16_t messageLength, uint8_t * message) +{ + return EMBER_LIBRARY_NOT_PRESENT; +} + +bool __attribute__((weak)) emberAfStartMoveCallback() +{ + return false; +} + +chip::Protocols::InteractionModel::Status __attribute__((weak)) +MatterPreAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, + uint8_t * value) +{ + return chip::Protocols::InteractionModel::Status::Success; +} + +void __attribute__((weak)) MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, + uint16_t size, uint8_t * value) +{} diff --git a/zzz_generated/lighting-app/nxp/zap-generated/endpoint_config.h b/zzz_generated/lighting-app/nxp/zap-generated/endpoint_config.h new file mode 100644 index 00000000000000..7caf9b7ee0ce99 --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/endpoint_config.h @@ -0,0 +1,779 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +// Prevent multiple inclusion +#pragma once + +#include + +// Default values for the attributes longer than a pointer, +// in a form of a binary blob +// Separate block is generated for big-endian and little-endian cases. +#if BIGENDIAN_CPU +#define GENERATED_DEFAULTS \ + { \ + \ + /* Endpoint: 0, Cluster: General Commissioning (server), big-endian */ \ + \ + /* 0 - Breadcrumb, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + } + +#else // !BIGENDIAN_CPU +#define GENERATED_DEFAULTS \ + { \ + \ + /* Endpoint: 0, Cluster: General Commissioning (server), little-endian */ \ + \ + /* 0 - Breadcrumb, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + } + +#endif // BIGENDIAN_CPU + +#define GENERATED_DEFAULTS_COUNT (1) + +#define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE +#define ZAP_LONG_DEFAULTS_INDEX(index) \ + { \ + &generatedDefaults[index] \ + } +#define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ + { \ + &minMaxDefaults[index] \ + } +#define ZAP_EMPTY_DEFAULT() \ + { \ + (uint32_t) 0 \ + } +#define ZAP_SIMPLE_DEFAULT(x) \ + { \ + (uint32_t) x \ + } + +// This is an array of EmberAfAttributeMinMaxValue structures. +#define GENERATED_MIN_MAX_DEFAULT_COUNT 2 +#define GENERATED_MIN_MAX_DEFAULTS \ + { \ + \ + /* Endpoint: 1, Cluster: On/Off (server) */ \ + { (uint16_t) 0xFF, (uint16_t) 0x0, (uint16_t) 0x2 }, /* StartUpOnOff */ \ + \ + /* Endpoint: 1, Cluster: Level Control (server) */ { (uint16_t) 0x0, (uint16_t) 0x0, (uint16_t) 0x3 } /* Options */ \ + } + +#define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask +// This is an array of EmberAfAttributeMetadata structures. +#define GENERATED_ATTRIBUTE_COUNT 170 +#define GENERATED_ATTRIBUTES \ + { \ + \ + /* Endpoint: 0, Cluster: Descriptor (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* DeviceTypeList */ \ + { 0x00000001, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ServerList */ \ + { 0x00000002, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ClientList */ \ + { 0x00000003, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* PartsList */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: Access Control (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_EMPTY_DEFAULT() }, /* ACL */ \ + { 0x00000002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* SubjectsPerAccessControlEntry */ \ + { 0x00000003, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TargetsPerAccessControlEntry */ \ + { 0x00000004, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* AccessControlEntriesPerFabric */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: Basic (server) */ \ + { 0x00000000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* DataModelRevision */ \ + { 0x00000001, ZAP_TYPE(CHAR_STRING), 33, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* VendorName */ \ + { 0x00000002, ZAP_TYPE(VENDOR_ID), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* VendorID */ \ + { 0x00000003, ZAP_TYPE(CHAR_STRING), 33, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* ProductName */ \ + { 0x00000004, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* ProductID */ \ + { 0x00000005, ZAP_TYPE(CHAR_STRING), 33, \ + ZAP_ATTRIBUTE_MASK(TOKENIZE) | ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_EMPTY_DEFAULT() }, /* NodeLabel */ \ + { 0x00000006, ZAP_TYPE(CHAR_STRING), 3, \ + ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_EMPTY_DEFAULT() }, /* Location */ \ + { 0x00000007, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* HardwareVersion */ \ + { 0x00000008, ZAP_TYPE(CHAR_STRING), 65, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* HardwareVersionString */ \ + { 0x00000009, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* SoftwareVersion */ \ + { 0x0000000A, ZAP_TYPE(CHAR_STRING), 65, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* SoftwareVersionString */ \ + { 0x00000013, ZAP_TYPE(STRUCT), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* CapabilityMinima */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: OTA Software Update Requestor (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_EMPTY_DEFAULT() }, /* DefaultOtaProviders */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(1) }, /* UpdatePossible */ \ + { 0x00000002, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0) }, /* UpdateState */ \ + { 0x00000003, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0) }, /* UpdateStateProgress */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: General Commissioning (server) */ \ + { 0x00000000, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_LONG_DEFAULTS_INDEX(0) }, /* Breadcrumb */ \ + { 0x00000001, ZAP_TYPE(STRUCT), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* BasicCommissioningInfo */ \ + { 0x00000002, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RegulatoryConfig */ \ + { 0x00000003, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* LocationCapability */ \ + { 0x00000004, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* SupportsConcurrentConnection */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: Network Commissioning (server) */ \ + { 0x00000000, ZAP_TYPE(INT8U), 1, 0, ZAP_EMPTY_DEFAULT() }, /* MaxNetworks */ \ + { 0x00000001, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* Networks */ \ + { 0x00000002, ZAP_TYPE(INT8U), 1, 0, ZAP_EMPTY_DEFAULT() }, /* ScanMaxTimeSeconds */ \ + { 0x00000003, ZAP_TYPE(INT8U), 1, 0, ZAP_EMPTY_DEFAULT() }, /* ConnectMaxTimeSeconds */ \ + { 0x00000004, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_EMPTY_DEFAULT() }, /* InterfaceEnabled */ \ + { 0x00000005, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* LastNetworkingStatus */ \ + { 0x00000006, ZAP_TYPE(OCTET_STRING), 33, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* LastNetworkID */ \ + { 0x00000007, ZAP_TYPE(INT32S), 4, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* LastConnectErrorValue */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(2) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: General Diagnostics (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* NetworkInterfaces */ \ + { 0x00000001, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RebootCount */ \ + { 0x00000008, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TestEventTriggersEnabled */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: Software Diagnostics (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ThreadMetrics */ \ + { 0x00000001, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* CurrentHeapFree */ \ + { 0x00000002, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* CurrentHeapUsed */ \ + { 0x00000003, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* CurrentHeapHighWatermark */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(1) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: Thread Network Diagnostics (server) */ \ + { 0x00000000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* channel */ \ + { 0x00000001, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* RoutingRole */ \ + { 0x00000002, ZAP_TYPE(CHAR_STRING), 17, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* NetworkName */ \ + { 0x00000003, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* PanId */ \ + { 0x00000004, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* ExtendedPanId */ \ + { 0x00000005, ZAP_TYPE(OCTET_STRING), 18, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* MeshLocalPrefix */ \ + { 0x00000006, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* OverrunCount */ \ + { 0x00000007, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* NeighborTableList */ \ + { 0x00000008, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RouteTableList */ \ + { 0x00000009, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* PartitionId */ \ + { 0x0000000A, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* weighting */ \ + { 0x0000000B, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* DataVersion */ \ + { 0x0000000C, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* StableDataVersion */ \ + { 0x0000000D, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* LeaderRouterId */ \ + { 0x0000000E, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* DetachedRoleCount */ \ + { 0x0000000F, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ChildRoleCount */ \ + { 0x00000010, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RouterRoleCount */ \ + { 0x00000011, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* LeaderRoleCount */ \ + { 0x00000012, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* AttachAttemptCount */ \ + { 0x00000013, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* PartitionIdChangeCount */ \ + { 0x00000014, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* BetterPartitionAttachAttemptCount */ \ + { 0x00000015, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* ParentChangeCount */ \ + { 0x00000016, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxTotalCount */ \ + { 0x00000017, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxUnicastCount */ \ + { 0x00000018, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxBroadcastCount */ \ + { 0x00000019, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TxAckRequestedCount */ \ + { 0x0000001A, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxAckedCount */ \ + { 0x0000001B, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TxNoAckRequestedCount */ \ + { 0x0000001C, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxDataCount */ \ + { 0x0000001D, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxDataPollCount */ \ + { 0x0000001E, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxBeaconCount */ \ + { 0x0000001F, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TxBeaconRequestCount */ \ + { 0x00000020, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxOtherCount */ \ + { 0x00000021, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxRetryCount */ \ + { 0x00000022, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TxDirectMaxRetryExpiryCount */ \ + { 0x00000023, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TxIndirectMaxRetryExpiryCount */ \ + { 0x00000024, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxErrCcaCount */ \ + { 0x00000025, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxErrAbortCount */ \ + { 0x00000026, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TxErrBusyChannelCount */ \ + { 0x00000027, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxTotalCount */ \ + { 0x00000028, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxUnicastCount */ \ + { 0x00000029, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxBroadcastCount */ \ + { 0x0000002A, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxDataCount */ \ + { 0x0000002B, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxDataPollCount */ \ + { 0x0000002C, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxBeaconCount */ \ + { 0x0000002D, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* RxBeaconRequestCount */ \ + { 0x0000002E, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxOtherCount */ \ + { 0x0000002F, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* RxAddressFilteredCount */ \ + { 0x00000030, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* RxDestAddrFilteredCount */ \ + { 0x00000031, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* RxDuplicatedCount */ \ + { 0x00000032, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* RxErrNoFrameCount */ \ + { 0x00000033, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* RxErrUnknownNeighborCount */ \ + { 0x00000034, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* RxErrInvalidSrcAddrCount */ \ + { 0x00000035, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxErrSecCount */ \ + { 0x00000036, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxErrFcsCount */ \ + { 0x00000037, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxErrOtherCount */ \ + { 0x0000003B, ZAP_TYPE(STRUCT), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* SecurityPolicy */ \ + { 0x0000003C, ZAP_TYPE(OCTET_STRING), 5, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* ChannelPage0Mask */ \ + { 0x0000003D, ZAP_TYPE(STRUCT), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* OperationalDatasetComponents */ \ + { 0x0000003E, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* ActiveNetworkFaultsList */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0x000F) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ + { 0x00000000, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* WindowStatus */ \ + { 0x00000001, ZAP_TYPE(FABRIC_IDX), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* AdminFabricIndex */ \ + { 0x00000002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* AdminVendorId */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* NOCs */ \ + { 0x00000001, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* Fabrics */ \ + { 0x00000002, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* SupportedFabrics */ \ + { 0x00000003, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* CommissionedFabrics */ \ + { 0x00000004, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TrustedRootCertificates */ \ + { 0x00000005, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* CurrentFabricIndex */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: Group Key Management (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_EMPTY_DEFAULT() }, /* GroupKeyMap */ \ + { 0x00000001, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* GroupTable */ \ + { 0x00000002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* MaxGroupsPerFabric */ \ + { 0x00000003, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* MaxGroupKeysPerFabric */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 1, Cluster: Identify (server) */ \ + { 0x00000000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* identify time */ \ + { 0x00000001, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0x0) }, /* identify type */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(4) }, /* ClusterRevision */ \ + \ + /* Endpoint: 1, Cluster: Groups (server) */ \ + { 0x00000000, ZAP_TYPE(BITMAP8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* name support */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(4) }, /* ClusterRevision */ \ + \ + /* Endpoint: 1, Cluster: On/Off (server) */ \ + { 0x00000000, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(TOKENIZE), ZAP_SIMPLE_DEFAULT(0x00) }, /* OnOff */ \ + { 0x00004000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* GlobalSceneControl */ \ + { 0x00004001, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* OnTime */ \ + { 0x00004002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* OffWaitTime */ \ + { 0x00004003, ZAP_TYPE(ENUM8), 1, \ + ZAP_ATTRIBUTE_MASK(MIN_MAX) | ZAP_ATTRIBUTE_MASK(TOKENIZE) | ZAP_ATTRIBUTE_MASK(WRITABLE) | \ + ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_MIN_MAX_DEFAULTS_INDEX(0) }, /* StartUpOnOff */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(1) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(4) }, /* ClusterRevision */ \ + \ + /* Endpoint: 1, Cluster: Level Control (server) */ \ + { 0x00000000, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(TOKENIZE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_SIMPLE_DEFAULT(0x01) }, /* CurrentLevel */ \ + { 0x00000001, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0000) }, /* RemainingTime */ \ + { 0x00000002, ZAP_TYPE(INT8U), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* MinLevel */ \ + { 0x00000003, ZAP_TYPE(INT8U), 1, 0, ZAP_SIMPLE_DEFAULT(0xFE) }, /* MaxLevel */ \ + { 0x0000000F, ZAP_TYPE(BITMAP8), 1, ZAP_ATTRIBUTE_MASK(MIN_MAX) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_MIN_MAX_DEFAULTS_INDEX(1) }, /* Options */ \ + { 0x00000011, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(WRITABLE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_SIMPLE_DEFAULT(0xFF) }, /* OnLevel */ \ + { 0x00004000, ZAP_TYPE(INT8U), 1, \ + ZAP_ATTRIBUTE_MASK(TOKENIZE) | ZAP_ATTRIBUTE_MASK(WRITABLE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_SIMPLE_DEFAULT(254) }, /* StartUpCurrentLevel */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(3) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(5) }, /* ClusterRevision */ \ + \ + /* Endpoint: 1, Cluster: Descriptor (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* DeviceTypeList */ \ + { 0x00000001, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ServerList */ \ + { 0x00000002, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ClientList */ \ + { 0x00000003, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* PartsList */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ClusterRevision */ \ + } + +// This is an array of EmberAfCluster structures. +#define ZAP_ATTRIBUTE_INDEX(index) (&generatedAttributes[index]) + +#define ZAP_GENERATED_COMMANDS_INDEX(index) ((chip::CommandId *) (&generatedCommands[index])) + +// Cluster function static arrays +#define GENERATED_FUNCTION_ARRAYS \ + const EmberAfGenericClusterFunction chipFuncArrayBasicServer[] = { \ + (EmberAfGenericClusterFunction) emberAfBasicClusterServerInitCallback, \ + }; \ + const EmberAfGenericClusterFunction chipFuncArrayIdentifyServer[] = { \ + (EmberAfGenericClusterFunction) emberAfIdentifyClusterServerInitCallback, \ + (EmberAfGenericClusterFunction) MatterIdentifyClusterServerAttributeChangedCallback, \ + }; \ + const EmberAfGenericClusterFunction chipFuncArrayGroupsServer[] = { \ + (EmberAfGenericClusterFunction) emberAfGroupsClusterServerInitCallback, \ + }; \ + const EmberAfGenericClusterFunction chipFuncArrayOnOffServer[] = { \ + (EmberAfGenericClusterFunction) emberAfOnOffClusterServerInitCallback, \ + }; \ + const EmberAfGenericClusterFunction chipFuncArrayLevelControlServer[] = { \ + (EmberAfGenericClusterFunction) emberAfLevelControlClusterServerInitCallback, \ + }; + +// clang-format off +#define GENERATED_COMMANDS { \ + /* Endpoint: 0, Cluster: OTA Software Update Requestor (server) */\ + /* AcceptedCommandList (index=0) */ \ + 0x00000000 /* AnnounceOtaProvider */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: General Commissioning (server) */\ + /* AcceptedCommandList (index=2) */ \ + 0x00000000 /* ArmFailSafe */, \ + 0x00000002 /* SetRegulatoryConfig */, \ + 0x00000004 /* CommissioningComplete */, \ + chip::kInvalidCommandId /* end of list */, \ + /* GeneratedCommandList (index=6)*/ \ + 0x00000001 /* ArmFailSafeResponse */, \ + 0x00000003 /* SetRegulatoryConfigResponse */, \ + 0x00000005 /* CommissioningCompleteResponse */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: Network Commissioning (server) */\ + /* AcceptedCommandList (index=10) */ \ + 0x00000000 /* ScanNetworks */, \ + 0x00000003 /* AddOrUpdateThreadNetwork */, \ + 0x00000004 /* RemoveNetwork */, \ + 0x00000006 /* ConnectNetwork */, \ + 0x00000008 /* ReorderNetwork */, \ + chip::kInvalidCommandId /* end of list */, \ + /* GeneratedCommandList (index=16)*/ \ + 0x00000001 /* ScanNetworksResponse */, \ + 0x00000005 /* NetworkConfigResponse */, \ + 0x00000007 /* ConnectNetworkResponse */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: General Diagnostics (server) */\ + /* AcceptedCommandList (index=20) */ \ + 0x00000000 /* TestEventTrigger */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: Software Diagnostics (server) */\ + /* AcceptedCommandList (index=22) */ \ + 0x00000000 /* ResetWatermarks */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: Thread Network Diagnostics (server) */\ + /* AcceptedCommandList (index=24) */ \ + 0x00000000 /* ResetCounts */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */\ + /* AcceptedCommandList (index=26) */ \ + 0x00000000 /* OpenCommissioningWindow */, \ + 0x00000002 /* RevokeCommissioning */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: Operational Credentials (server) */\ + /* AcceptedCommandList (index=29) */ \ + 0x00000000 /* AttestationRequest */, \ + 0x00000002 /* CertificateChainRequest */, \ + 0x00000004 /* CSRRequest */, \ + 0x00000006 /* AddNOC */, \ + 0x00000007 /* UpdateNOC */, \ + 0x00000009 /* UpdateFabricLabel */, \ + 0x0000000A /* RemoveFabric */, \ + 0x0000000B /* AddTrustedRootCertificate */, \ + chip::kInvalidCommandId /* end of list */, \ + /* GeneratedCommandList (index=38)*/ \ + 0x00000001 /* AttestationResponse */, \ + 0x00000003 /* CertificateChainResponse */, \ + 0x00000005 /* CSRResponse */, \ + 0x00000008 /* NOCResponse */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: Group Key Management (server) */\ + /* AcceptedCommandList (index=43) */ \ + 0x00000000 /* KeySetWrite */, \ + 0x00000001 /* KeySetRead */, \ + 0x00000003 /* KeySetRemove */, \ + 0x00000004 /* KeySetReadAllIndices */, \ + chip::kInvalidCommandId /* end of list */, \ + /* GeneratedCommandList (index=48)*/ \ + 0x00000002 /* KeySetReadResponse */, \ + 0x00000005 /* KeySetReadAllIndicesResponse */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 1, Cluster: Identify (server) */\ + /* AcceptedCommandList (index=51) */ \ + 0x00000000 /* Identify */, \ + 0x00000040 /* TriggerEffect */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 1, Cluster: Groups (server) */\ + /* AcceptedCommandList (index=54) */ \ + 0x00000000 /* AddGroup */, \ + 0x00000001 /* ViewGroup */, \ + 0x00000002 /* GetGroupMembership */, \ + 0x00000003 /* RemoveGroup */, \ + 0x00000004 /* RemoveAllGroups */, \ + 0x00000005 /* AddGroupIfIdentifying */, \ + chip::kInvalidCommandId /* end of list */, \ + /* GeneratedCommandList (index=61)*/ \ + 0x00000000 /* AddGroupResponse */, \ + 0x00000001 /* ViewGroupResponse */, \ + 0x00000002 /* GetGroupMembershipResponse */, \ + 0x00000003 /* RemoveGroupResponse */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 1, Cluster: On/Off (server) */\ + /* AcceptedCommandList (index=66) */ \ + 0x00000000 /* Off */, \ + 0x00000001 /* On */, \ + 0x00000002 /* Toggle */, \ + 0x00000040 /* OffWithEffect */, \ + 0x00000041 /* OnWithRecallGlobalScene */, \ + 0x00000042 /* OnWithTimedOff */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 1, Cluster: Level Control (server) */\ + /* AcceptedCommandList (index=73) */ \ + 0x00000000 /* MoveToLevel */, \ + 0x00000001 /* Move */, \ + 0x00000002 /* Step */, \ + 0x00000003 /* Stop */, \ + 0x00000004 /* MoveToLevelWithOnOff */, \ + 0x00000005 /* MoveWithOnOff */, \ + 0x00000006 /* StepWithOnOff */, \ + 0x00000007 /* StopWithOnOff */, \ + chip::kInvalidCommandId /* end of list */, \ +} + +// clang-format on + +#define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask +#define GENERATED_CLUSTER_COUNT 18 + +// clang-format off +#define GENERATED_CLUSTERS { \ + { \ + /* Endpoint: 0, Cluster: Descriptor (server) */ \ + .clusterId = 0x0000001D, \ + .attributes = ZAP_ATTRIBUTE_INDEX(0), \ + .attributeCount = 6, \ + .clusterSize = 4, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = nullptr ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: Access Control (server) */ \ + .clusterId = 0x0000001F, \ + .attributes = ZAP_ATTRIBUTE_INDEX(6), \ + .attributeCount = 6, \ + .clusterSize = 6, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = nullptr ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: Basic (server) */ \ + .clusterId = 0x00000028, \ + .attributes = ZAP_ATTRIBUTE_INDEX(12), \ + .attributeCount = 14, \ + .clusterSize = 39, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + .functions = chipFuncArrayBasicServer, \ + .acceptedCommandList = nullptr ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: OTA Software Update Provider (client) */ \ + .clusterId = 0x00000029, \ + .attributes = ZAP_ATTRIBUTE_INDEX(26), \ + .attributeCount = 0, \ + .clusterSize = 0, \ + .mask = ZAP_CLUSTER_MASK(CLIENT), \ + .functions = NULL, \ + .acceptedCommandList = nullptr ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: OTA Software Update Requestor (server) */ \ + .clusterId = 0x0000002A, \ + .attributes = ZAP_ATTRIBUTE_INDEX(26), \ + .attributeCount = 6, \ + .clusterSize = 9, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 0 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: General Commissioning (server) */ \ + .clusterId = 0x00000030, \ + .attributes = ZAP_ATTRIBUTE_INDEX(32), \ + .attributeCount = 7, \ + .clusterSize = 14, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 2 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 6 ) ,\ + },\ + { \ + /* Endpoint: 0, Cluster: Network Commissioning (server) */ \ + .clusterId = 0x00000031, \ + .attributes = ZAP_ATTRIBUTE_INDEX(39), \ + .attributeCount = 10, \ + .clusterSize = 48, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 10 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 16 ) ,\ + },\ + { \ + /* Endpoint: 0, Cluster: General Diagnostics (server) */ \ + .clusterId = 0x00000033, \ + .attributes = ZAP_ATTRIBUTE_INDEX(49), \ + .attributeCount = 5, \ + .clusterSize = 6, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 20 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: Software Diagnostics (server) */ \ + .clusterId = 0x00000034, \ + .attributes = ZAP_ATTRIBUTE_INDEX(54), \ + .attributeCount = 6, \ + .clusterSize = 6, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 22 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: Thread Network Diagnostics (server) */ \ + .clusterId = 0x00000035, \ + .attributes = ZAP_ATTRIBUTE_INDEX(60), \ + .attributeCount = 62, \ + .clusterSize = 6, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 24 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ + .clusterId = 0x0000003C, \ + .attributes = ZAP_ATTRIBUTE_INDEX(122), \ + .attributeCount = 5, \ + .clusterSize = 6, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 26 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ + .clusterId = 0x0000003E, \ + .attributes = ZAP_ATTRIBUTE_INDEX(127), \ + .attributeCount = 8, \ + .clusterSize = 6, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 29 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 38 ) ,\ + },\ + { \ + /* Endpoint: 0, Cluster: Group Key Management (server) */ \ + .clusterId = 0x0000003F, \ + .attributes = ZAP_ATTRIBUTE_INDEX(135), \ + .attributeCount = 6, \ + .clusterSize = 6, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 43 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 48 ) ,\ + },\ + { \ + /* Endpoint: 1, Cluster: Identify (server) */ \ + .clusterId = 0x00000003, \ + .attributes = ZAP_ATTRIBUTE_INDEX(141), \ + .attributeCount = 4, \ + .clusterSize = 9, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ + .functions = chipFuncArrayIdentifyServer, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 51 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 1, Cluster: Groups (server) */ \ + .clusterId = 0x00000004, \ + .attributes = ZAP_ATTRIBUTE_INDEX(145), \ + .attributeCount = 3, \ + .clusterSize = 7, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + .functions = chipFuncArrayGroupsServer, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 54 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 61 ) ,\ + },\ + { \ + /* Endpoint: 1, Cluster: On/Off (server) */ \ + .clusterId = 0x00000006, \ + .attributes = ZAP_ATTRIBUTE_INDEX(148), \ + .attributeCount = 7, \ + .clusterSize = 13, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + .functions = chipFuncArrayOnOffServer, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 66 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 1, Cluster: Level Control (server) */ \ + .clusterId = 0x00000008, \ + .attributes = ZAP_ATTRIBUTE_INDEX(155), \ + .attributeCount = 9, \ + .clusterSize = 14, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + .functions = chipFuncArrayLevelControlServer, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 73 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 1, Cluster: Descriptor (server) */ \ + .clusterId = 0x0000001D, \ + .attributes = ZAP_ATTRIBUTE_INDEX(164), \ + .attributeCount = 6, \ + .clusterSize = 4, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = nullptr ,\ + .generatedCommandList = nullptr ,\ + },\ +} + +// clang-format on + +#define ZAP_CLUSTER_INDEX(index) (&generatedClusters[index]) + +#define ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT 17 + +// This is an array of EmberAfEndpointType structures. +#define GENERATED_ENDPOINT_TYPES \ + { \ + { ZAP_CLUSTER_INDEX(0), 13, 156 }, { ZAP_CLUSTER_INDEX(13), 5, 47 }, \ + } + +// Largest attribute size is needed for various buffers +#define ATTRIBUTE_LARGEST (66) + +static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, "ATTRIBUTE_LARGEST larger than expected"); + +// Total size of singleton attributes +#define ATTRIBUTE_SINGLETONS_SIZE (35) + +// Total size of attribute storage +#define ATTRIBUTE_MAX_SIZE (203) + +// Number of fixed endpoints +#define FIXED_ENDPOINT_COUNT (2) + +// Array of endpoints that are supported, the data inside +// the array is the endpoint number. +#define FIXED_ENDPOINT_ARRAY \ + { \ + 0x0000, 0x0001 \ + } + +// Array of profile ids +#define FIXED_PROFILE_IDS \ + { \ + 0x0103, 0x0103 \ + } + +// Array of device types +#define FIXED_DEVICE_TYPES \ + { \ + { 0x0016, 1 }, { 0x0100, 1 } \ + } + +// Array of device type offsets +#define FIXED_DEVICE_TYPE_OFFSETS \ + { \ + 0, 1 \ + } + +// Array of device type lengths +#define FIXED_DEVICE_TYPE_LENGTHS \ + { \ + 1, 1 \ + } + +// Array of endpoint types supported on each endpoint +#define FIXED_ENDPOINT_TYPES \ + { \ + 0, 1 \ + } + +// Array of networks supported on each endpoint +#define FIXED_NETWORKS \ + { \ + 0, 0 \ + } diff --git a/zzz_generated/lighting-app/nxp/zap-generated/gen_config.h b/zzz_generated/lighting-app/nxp/zap-generated/gen_config.h new file mode 100644 index 00000000000000..f6c553a605b857 --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/gen_config.h @@ -0,0 +1,138 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +// Prevent multiple inclusion +#pragma once + +// User options for plugin Binding Table Library +#define EMBER_BINDING_TABLE_SIZE 10 + +/**** Network Section ****/ +#define EMBER_SUPPORTED_NETWORKS (1) + +#define EMBER_APS_UNICAST_MESSAGE_COUNT 10 + +/**** Cluster endpoint counts ****/ +#define EMBER_AF_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_GROUPS_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_DESCRIPTOR_CLUSTER_SERVER_ENDPOINT_COUNT (2) +#define EMBER_AF_ACCESS_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_OTA_PROVIDER_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_OTA_REQUESTOR_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_GENERAL_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_NETWORK_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_GENERAL_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_SOFTWARE_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_ADMINISTRATOR_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_OPERATIONAL_CREDENTIALS_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_GROUP_KEY_MANAGEMENT_CLUSTER_SERVER_ENDPOINT_COUNT (1) + +/**** Cluster Plugins ****/ + +// Use this macro to check if the server side of the Identify cluster is included +#define ZCL_USING_IDENTIFY_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_IDENTIFY_SERVER +#define EMBER_AF_PLUGIN_IDENTIFY + +// Use this macro to check if the server side of the Groups cluster is included +#define ZCL_USING_GROUPS_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_GROUPS_SERVER +#define EMBER_AF_PLUGIN_GROUPS + +// Use this macro to check if the server side of the On/Off cluster is included +#define ZCL_USING_ON_OFF_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_ON_OFF_SERVER +#define EMBER_AF_PLUGIN_ON_OFF + +// Use this macro to check if the server side of the Level Control cluster is included +#define ZCL_USING_LEVEL_CONTROL_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_LEVEL_CONTROL_SERVER +#define EMBER_AF_PLUGIN_LEVEL_CONTROL +// User options for server plugin Level Control +#define EMBER_AF_PLUGIN_LEVEL_CONTROL_MAXIMUM_LEVEL 254 +#define EMBER_AF_PLUGIN_LEVEL_CONTROL_MINIMUM_LEVEL 0 +#define EMBER_AF_PLUGIN_LEVEL_CONTROL_RATE 0 + +// Use this macro to check if the server side of the Descriptor cluster is included +#define ZCL_USING_DESCRIPTOR_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_DESCRIPTOR_SERVER +#define EMBER_AF_PLUGIN_DESCRIPTOR + +// Use this macro to check if the server side of the Access Control cluster is included +#define ZCL_USING_ACCESS_CONTROL_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_ACCESS_CONTROL_SERVER +#define EMBER_AF_PLUGIN_ACCESS_CONTROL + +// Use this macro to check if the server side of the Basic cluster is included +#define ZCL_USING_BASIC_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_BASIC_SERVER +#define EMBER_AF_PLUGIN_BASIC + +// Use this macro to check if the client side of the OTA Software Update Provider cluster is included +#define ZCL_USING_OTA_PROVIDER_CLUSTER_CLIENT +#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_PROVIDER_CLIENT + +// Use this macro to check if the server side of the OTA Software Update Requestor cluster is included +#define ZCL_USING_OTA_REQUESTOR_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_REQUESTOR_SERVER +#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_REQUESTOR + +// Use this macro to check if the server side of the General Commissioning cluster is included +#define ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_GENERAL_COMMISSIONING_SERVER +#define EMBER_AF_PLUGIN_GENERAL_COMMISSIONING + +// Use this macro to check if the server side of the Network Commissioning cluster is included +#define ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING_SERVER +#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING + +// Use this macro to check if the server side of the General Diagnostics cluster is included +#define ZCL_USING_GENERAL_DIAGNOSTICS_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_GENERAL_DIAGNOSTICS_SERVER +#define EMBER_AF_PLUGIN_GENERAL_DIAGNOSTICS + +// Use this macro to check if the server side of the Software Diagnostics cluster is included +#define ZCL_USING_SOFTWARE_DIAGNOSTICS_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_SOFTWARE_DIAGNOSTICS_SERVER +#define EMBER_AF_PLUGIN_SOFTWARE_DIAGNOSTICS + +// Use this macro to check if the server side of the Thread Network Diagnostics cluster is included +#define ZCL_USING_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_THREAD_NETWORK_DIAGNOSTICS_SERVER +#define EMBER_AF_PLUGIN_THREAD_NETWORK_DIAGNOSTICS + +// Use this macro to check if the server side of the AdministratorCommissioning cluster is included +#define ZCL_USING_ADMINISTRATOR_COMMISSIONING_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_ADMINISTRATOR_COMMISSIONING_SERVER +#define EMBER_AF_PLUGIN_ADMINISTRATOR_COMMISSIONING + +// Use this macro to check if the server side of the Operational Credentials cluster is included +#define ZCL_USING_OPERATIONAL_CREDENTIALS_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_OPERATIONAL_CREDENTIALS_SERVER +#define EMBER_AF_PLUGIN_OPERATIONAL_CREDENTIALS + +// Use this macro to check if the server side of the Group Key Management cluster is included +#define ZCL_USING_GROUP_KEY_MANAGEMENT_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_GROUP_KEY_MANAGEMENT_SERVER +#define EMBER_AF_PLUGIN_GROUP_KEY_MANAGEMENT diff --git a/zzz_generated/lighting-app/nxp/zap-generated/gen_tokens.h b/zzz_generated/lighting-app/nxp/zap-generated/gen_tokens.h new file mode 100644 index 00000000000000..dcc229f5b2c306 --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/gen_tokens.h @@ -0,0 +1,45 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +// Prevent multiple inclusion +#pragma once + +// This file contains the tokens for attributes stored in flash + +// Identifier tags for tokens + +// Types for the tokens +#ifdef DEFINETYPES +#endif // DEFINETYPES + +// Actual token definitions +#ifdef DEFINETOKENS +#endif // DEFINETOKENS + +// Macro snippet that loads all the attributes from tokens +#define GENERATED_TOKEN_LOADER(endpoint) \ + do \ + { \ + } while (false) + +// Macro snippet that saves the attribute to token +#define GENERATED_TOKEN_SAVER \ + do \ + { \ + } while (false) diff --git a/zzz_generated/lock-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/lock-app/zap-generated/IMClusterCommandHandler.cpp index 1469e552ae8d61..e885cb4b8bfd10 100644 --- a/zzz_generated/lock-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/lock-app/zap-generated/IMClusterCommandHandler.cpp @@ -520,88 +520,6 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } // namespace GroupKeyManagement -namespace Groups { - -void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - CHIP_ERROR TLVError = CHIP_NO_ERROR; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::AddGroup::Id: { - Commands::AddGroup::DecodableType commandData; - TLVError = DataModel::Decode(aDataTlv, commandData); - if (TLVError == CHIP_NO_ERROR) - { - wasHandled = emberAfGroupsClusterAddGroupCallback(apCommandObj, aCommandPath, commandData); - } - break; - } - case Commands::ViewGroup::Id: { - Commands::ViewGroup::DecodableType commandData; - TLVError = DataModel::Decode(aDataTlv, commandData); - if (TLVError == CHIP_NO_ERROR) - { - wasHandled = emberAfGroupsClusterViewGroupCallback(apCommandObj, aCommandPath, commandData); - } - break; - } - case Commands::GetGroupMembership::Id: { - Commands::GetGroupMembership::DecodableType commandData; - TLVError = DataModel::Decode(aDataTlv, commandData); - if (TLVError == CHIP_NO_ERROR) - { - wasHandled = emberAfGroupsClusterGetGroupMembershipCallback(apCommandObj, aCommandPath, commandData); - } - break; - } - case Commands::RemoveGroup::Id: { - Commands::RemoveGroup::DecodableType commandData; - TLVError = DataModel::Decode(aDataTlv, commandData); - if (TLVError == CHIP_NO_ERROR) - { - wasHandled = emberAfGroupsClusterRemoveGroupCallback(apCommandObj, aCommandPath, commandData); - } - break; - } - case Commands::RemoveAllGroups::Id: { - Commands::RemoveAllGroups::DecodableType commandData; - TLVError = DataModel::Decode(aDataTlv, commandData); - if (TLVError == CHIP_NO_ERROR) - { - wasHandled = emberAfGroupsClusterRemoveAllGroupsCallback(apCommandObj, aCommandPath, commandData); - } - break; - } - case Commands::AddGroupIfIdentifying::Id: { - Commands::AddGroupIfIdentifying::DecodableType commandData; - TLVError = DataModel::Decode(aDataTlv, commandData); - if (TLVError == CHIP_NO_ERROR) - { - wasHandled = emberAfGroupsClusterAddGroupIfIdentifyingCallback(apCommandObj, aCommandPath, commandData); - } - break; - } - default: { - // Unrecognized command ID, error status will apply. - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, - ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || !wasHandled) - { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); - ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); - } -} - -} // namespace Groups - namespace Identify { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) @@ -1059,9 +977,6 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: case Clusters::GroupKeyManagement::Id: Clusters::GroupKeyManagement::DispatchServerCommand(apCommandObj, aCommandPath, aReader); break; - case Clusters::Groups::Id: - Clusters::Groups::DispatchServerCommand(apCommandObj, aCommandPath, aReader); - break; case Clusters::Identify::Id: Clusters::Identify::DispatchServerCommand(apCommandObj, aCommandPath, aReader); break; diff --git a/zzz_generated/lock-app/zap-generated/PluginApplicationCallbacks.h b/zzz_generated/lock-app/zap-generated/PluginApplicationCallbacks.h index 7e699f07dd1ac4..529bd99d404d59 100644 --- a/zzz_generated/lock-app/zap-generated/PluginApplicationCallbacks.h +++ b/zzz_generated/lock-app/zap-generated/PluginApplicationCallbacks.h @@ -23,7 +23,6 @@ #define MATTER_PLUGINS_INIT \ MatterIdentifyPluginServerInitCallback(); \ - MatterGroupsPluginServerInitCallback(); \ MatterOnOffPluginServerInitCallback(); \ MatterDescriptorPluginServerInitCallback(); \ MatterAccessControlPluginServerInitCallback(); \ diff --git a/zzz_generated/lock-app/zap-generated/access.h b/zzz_generated/lock-app/zap-generated/access.h index 46ef8d9aed90b6..01fb394cf11677 100644 --- a/zzz_generated/lock-app/zap-generated/access.h +++ b/zzz_generated/lock-app/zap-generated/access.h @@ -199,10 +199,6 @@ // Parallel array data (*cluster*, command, privilege) for invoke command #define GENERATED_ACCESS_INVOKE_COMMAND__CLUSTER { \ 3, /* Cluster: Identify, Command: Identify, Privilege: manage */ \ - 4, /* Cluster: Groups, Command: AddGroup, Privilege: manage */ \ - 4, /* Cluster: Groups, Command: RemoveGroup, Privilege: manage */ \ - 4, /* Cluster: Groups, Command: RemoveAllGroups, Privilege: manage */ \ - 4, /* Cluster: Groups, Command: AddGroupIfIdentifying, Privilege: manage */ \ 48, /* Cluster: General Commissioning, Command: ArmFailSafe, Privilege: administer */ \ 48, /* Cluster: General Commissioning, Command: SetRegulatoryConfig, Privilege: administer */ \ 48, /* Cluster: General Commissioning, Command: CommissioningComplete, Privilege: administer */ \ @@ -248,10 +244,6 @@ // Parallel array data (cluster, *command*, privilege) for invoke command #define GENERATED_ACCESS_INVOKE_COMMAND__COMMAND { \ 0, /* Cluster: Identify, Command: Identify, Privilege: manage */ \ - 0, /* Cluster: Groups, Command: AddGroup, Privilege: manage */ \ - 3, /* Cluster: Groups, Command: RemoveGroup, Privilege: manage */ \ - 4, /* Cluster: Groups, Command: RemoveAllGroups, Privilege: manage */ \ - 5, /* Cluster: Groups, Command: AddGroupIfIdentifying, Privilege: manage */ \ 0, /* Cluster: General Commissioning, Command: ArmFailSafe, Privilege: administer */ \ 2, /* Cluster: General Commissioning, Command: SetRegulatoryConfig, Privilege: administer */ \ 4, /* Cluster: General Commissioning, Command: CommissioningComplete, Privilege: administer */ \ @@ -297,10 +289,6 @@ // Parallel array data (cluster, command, *privilege*) for invoke command #define GENERATED_ACCESS_INVOKE_COMMAND__PRIVILEGE { \ kMatterAccessPrivilegeManage, /* Cluster: Identify, Command: Identify, Privilege: manage */ \ - kMatterAccessPrivilegeManage, /* Cluster: Groups, Command: AddGroup, Privilege: manage */ \ - kMatterAccessPrivilegeManage, /* Cluster: Groups, Command: RemoveGroup, Privilege: manage */ \ - kMatterAccessPrivilegeManage, /* Cluster: Groups, Command: RemoveAllGroups, Privilege: manage */ \ - kMatterAccessPrivilegeManage, /* Cluster: Groups, Command: AddGroupIfIdentifying, Privilege: manage */ \ kMatterAccessPrivilegeAdminister, /* Cluster: General Commissioning, Command: ArmFailSafe, Privilege: administer */ \ kMatterAccessPrivilegeAdminister, /* Cluster: General Commissioning, Command: SetRegulatoryConfig, Privilege: administer */ \ kMatterAccessPrivilegeAdminister, /* Cluster: General Commissioning, Command: CommissioningComplete, Privilege: administer */ \ diff --git a/zzz_generated/lock-app/zap-generated/callback-stub.cpp b/zzz_generated/lock-app/zap-generated/callback-stub.cpp index 974f74079e8887..40b8a2a845ac46 100644 --- a/zzz_generated/lock-app/zap-generated/callback-stub.cpp +++ b/zzz_generated/lock-app/zap-generated/callback-stub.cpp @@ -62,9 +62,6 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) case ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID: emberAfGroupKeyManagementClusterInitCallback(endpoint); break; - case ZCL_GROUPS_CLUSTER_ID: - emberAfGroupsClusterInitCallback(endpoint); - break; case ZCL_IDENTIFY_CLUSTER_ID: emberAfIdentifyClusterInitCallback(endpoint); break; @@ -168,11 +165,6 @@ void __attribute__((weak)) emberAfGroupKeyManagementClusterInitCallback(Endpoint // To prevent warning (void) endpoint; } -void __attribute__((weak)) emberAfGroupsClusterInitCallback(EndpointId endpoint) -{ - // To prevent warning - (void) endpoint; -} void __attribute__((weak)) emberAfIdentifyClusterInitCallback(EndpointId endpoint) { // To prevent warning diff --git a/zzz_generated/lock-app/zap-generated/endpoint_config.h b/zzz_generated/lock-app/zap-generated/endpoint_config.h index 02393bb099e0ef..f8de7c74545e53 100644 --- a/zzz_generated/lock-app/zap-generated/endpoint_config.h +++ b/zzz_generated/lock-app/zap-generated/endpoint_config.h @@ -129,7 +129,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 268 +#define GENERATED_ATTRIBUTE_COUNT 265 #define GENERATED_ATTRIBUTES \ { \ \ @@ -493,11 +493,6 @@ { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(4) }, /* ClusterRevision */ \ \ - /* Endpoint: 1, Cluster: Groups (server) */ \ - { 0x00000000, ZAP_TYPE(BITMAP8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* name support */ \ - { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ - { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(4) }, /* ClusterRevision */ \ - \ /* Endpoint: 1, Cluster: On/Off (server) */ \ { 0x00000000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* OnOff */ \ { 0x00004000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(1) }, /* GlobalSceneControl */ \ @@ -589,9 +584,6 @@ (EmberAfGenericClusterFunction) emberAfIdentifyClusterServerInitCallback, \ (EmberAfGenericClusterFunction) MatterIdentifyClusterServerAttributeChangedCallback, \ }; \ - const EmberAfGenericClusterFunction chipFuncArrayGroupsServer[] = { \ - (EmberAfGenericClusterFunction) emberAfGroupsClusterServerInitCallback, \ - }; \ const EmberAfGenericClusterFunction chipFuncArrayOnOffServer[] = { \ (EmberAfGenericClusterFunction) emberAfOnOffClusterServerInitCallback, \ }; \ @@ -696,29 +688,14 @@ /* AcceptedCommandList (index=61) */ \ 0x00000000 /* Identify */, \ chip::kInvalidCommandId /* end of list */, \ - /* Endpoint: 1, Cluster: Groups (server) */\ - /* AcceptedCommandList (index=63) */ \ - 0x00000000 /* AddGroup */, \ - 0x00000001 /* ViewGroup */, \ - 0x00000002 /* GetGroupMembership */, \ - 0x00000003 /* RemoveGroup */, \ - 0x00000004 /* RemoveAllGroups */, \ - 0x00000005 /* AddGroupIfIdentifying */, \ - chip::kInvalidCommandId /* end of list */, \ - /* GeneratedCommandList (index=70)*/ \ - 0x00000000 /* AddGroupResponse */, \ - 0x00000001 /* ViewGroupResponse */, \ - 0x00000002 /* GetGroupMembershipResponse */, \ - 0x00000003 /* RemoveGroupResponse */, \ - chip::kInvalidCommandId /* end of list */, \ /* Endpoint: 1, Cluster: On/Off (server) */\ - /* AcceptedCommandList (index=75) */ \ + /* AcceptedCommandList (index=63) */ \ 0x00000000 /* Off */, \ 0x00000001 /* On */, \ 0x00000002 /* Toggle */, \ chip::kInvalidCommandId /* end of list */, \ /* Endpoint: 1, Cluster: Door Lock (server) */\ - /* AcceptedCommandList (index=79) */ \ + /* AcceptedCommandList (index=67) */ \ 0x00000000 /* LockDoor */, \ 0x00000001 /* UnlockDoor */, \ 0x00000003 /* UnlockWithTimeout */, \ @@ -738,7 +715,7 @@ 0x00000024 /* GetCredentialStatus */, \ 0x00000026 /* ClearCredential */, \ chip::kInvalidCommandId /* end of list */, \ - /* GeneratedCommandList (index=98)*/ \ + /* GeneratedCommandList (index=86)*/ \ 0x0000000C /* GetWeekDayScheduleResponse */, \ 0x0000000F /* GetYearDayScheduleResponse */, \ 0x00000012 /* GetHolidayScheduleResponse */, \ @@ -751,7 +728,7 @@ // clang-format on #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 28 +#define GENERATED_CLUSTER_COUNT 27 // clang-format off #define GENERATED_CLUSTERS { \ @@ -1008,32 +985,21 @@ .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 61 ) ,\ .generatedCommandList = nullptr ,\ },\ - { \ - /* Endpoint: 1, Cluster: Groups (server) */ \ - .clusterId = 0x00000004, \ - .attributes = ZAP_ATTRIBUTE_INDEX(215), \ - .attributeCount = 3, \ - .clusterSize = 7, \ - .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ - .functions = chipFuncArrayGroupsServer, \ - .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 63 ) ,\ - .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 70 ) ,\ - },\ { \ /* Endpoint: 1, Cluster: On/Off (server) */ \ .clusterId = 0x00000006, \ - .attributes = ZAP_ATTRIBUTE_INDEX(218), \ + .attributes = ZAP_ATTRIBUTE_INDEX(215), \ .attributeCount = 7, \ .clusterSize = 13, \ .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ .functions = chipFuncArrayOnOffServer, \ - .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 75 ) ,\ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 63 ) ,\ .generatedCommandList = nullptr ,\ },\ { \ /* Endpoint: 1, Cluster: Descriptor (server) */ \ .clusterId = 0x0000001D, \ - .attributes = ZAP_ATTRIBUTE_INDEX(225), \ + .attributes = ZAP_ATTRIBUTE_INDEX(222), \ .attributeCount = 6, \ .clusterSize = 4, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ @@ -1044,7 +1010,7 @@ { \ /* Endpoint: 1, Cluster: Power Source (server) */ \ .clusterId = 0x0000002F, \ - .attributes = ZAP_ATTRIBUTE_INDEX(231), \ + .attributes = ZAP_ATTRIBUTE_INDEX(228), \ .attributeCount = 9, \ .clusterSize = 133, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ @@ -1055,13 +1021,13 @@ { \ /* Endpoint: 1, Cluster: Door Lock (server) */ \ .clusterId = 0x00000101, \ - .attributes = ZAP_ATTRIBUTE_INDEX(240), \ + .attributes = ZAP_ATTRIBUTE_INDEX(237), \ .attributeCount = 28, \ .clusterSize = 42, \ .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION) | ZAP_CLUSTER_MASK(PRE_ATTRIBUTE_CHANGED_FUNCTION), \ .functions = chipFuncArrayDoorLockServer, \ - .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 79 ) ,\ - .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 98 ) ,\ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 67 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 86 ) ,\ },\ } @@ -1069,12 +1035,12 @@ #define ZAP_CLUSTER_INDEX(index) (&generatedClusters[index]) -#define ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT 27 +#define ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT 26 // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 22, 317 }, { ZAP_CLUSTER_INDEX(22), 6, 208 }, \ + { ZAP_CLUSTER_INDEX(0), 22, 317 }, { ZAP_CLUSTER_INDEX(22), 5, 201 }, \ } // Largest attribute size is needed for various buffers @@ -1086,7 +1052,7 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, #define ATTRIBUTE_SINGLETONS_SIZE (37) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (525) +#define ATTRIBUTE_MAX_SIZE (518) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (2) diff --git a/zzz_generated/lock-app/zap-generated/gen_config.h b/zzz_generated/lock-app/zap-generated/gen_config.h index 863d9878319a0b..b03704c9359648 100644 --- a/zzz_generated/lock-app/zap-generated/gen_config.h +++ b/zzz_generated/lock-app/zap-generated/gen_config.h @@ -30,7 +30,6 @@ /**** Cluster endpoint counts ****/ #define EMBER_AF_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT (1) -#define EMBER_AF_GROUPS_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_DESCRIPTOR_CLUSTER_SERVER_ENDPOINT_COUNT (2) #define EMBER_AF_ACCESS_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1) @@ -63,11 +62,6 @@ #define EMBER_AF_PLUGIN_IDENTIFY_SERVER #define EMBER_AF_PLUGIN_IDENTIFY -// Use this macro to check if the server side of the Groups cluster is included -#define ZCL_USING_GROUPS_CLUSTER_SERVER -#define EMBER_AF_PLUGIN_GROUPS_SERVER -#define EMBER_AF_PLUGIN_GROUPS - // Use this macro to check if the server side of the On/Off cluster is included #define ZCL_USING_ON_OFF_CLUSTER_SERVER #define EMBER_AF_PLUGIN_ON_OFF_SERVER