diff --git a/.github/workflows/cyrus-sasl.yml b/.github/workflows/cyrus-sasl.yml index 9cd572aea0..8938bb0db4 100644 --- a/.github/workflows/cyrus-sasl.yml +++ b/.github/workflows/cyrus-sasl.yml @@ -88,4 +88,11 @@ jobs: working-directory: sasl run: | make -j -C utils testsuite saslpasswd2 - $GITHUB_WORKSPACE/osp/cyrus-sasl/${{ matrix.ref }}/run-tests.sh + # Retry up to five times + for i in {1..5}; do + TEST_RES=0 + $GITHUB_WORKSPACE/osp/cyrus-sasl/${{ matrix.ref }}/run-tests.sh || TEST_RES=$? + if [ "$TEST_RES" -eq "0" ]; then + break + fi + done diff --git a/.github/workflows/mosquitto.yml b/.github/workflows/mosquitto.yml new file mode 100644 index 0000000000..bedd1e4195 --- /dev/null +++ b/.github/workflows/mosquitto.yml @@ -0,0 +1,93 @@ +name: mosquitto Tests + +# START OF COMMON SECTION +on: + push: + branches: [ 'master', 'main', 'release/**' ] + pull_request: + branches: [ '*' ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +# END OF COMMON SECTION + +jobs: + build_wolfssl: + name: Build wolfSSL + # Just to keep it the same as the testing target + runs-on: ubuntu-latest + # This should be a safe limit for the tests to run. + timeout-minutes: 4 + steps: + - name: Build wolfSSL + uses: wolfSSL/actions-build-autotools-project@v1 + with: + path: wolfssl + configure: --enable-mosquitto CFLAGS="-DALLOW_INVALID_CERTSIGN" + install: true + + - name: Upload built lib + uses: actions/upload-artifact@v4 + with: + name: wolf-install-mosquitto + path: build-dir + retention-days: 5 + + mosquitto_check: + strategy: + fail-fast: false + matrix: + ref: [ 2.0.18 ] + name: ${{ matrix.ref }} + runs-on: ubuntu-latest + # This should be a safe limit for the tests to run. + timeout-minutes: 4 + needs: build_wolfssl + steps: + - name: Download lib + uses: actions/download-artifact@v4 + with: + name: wolf-install-mosquitto + path: build-dir + + - name: Checkout OSP + uses: actions/checkout@v4 + with: + repository: wolfssl/osp + path: osp + + - name: Install dependencies + run: | + export DEBIAN_FRONTEND=noninteractive + sudo apt-get update + sudo apt-get install -y build-essential libev-dev libssl-dev automake python3-docutils libcunit1 libcunit1-doc libcunit1-dev pkg-config make + sudo pip install --upgrade psutil + + - name: Checkout mosquitto + uses: actions/checkout@v4 + with: + repository: eclipse/mosquitto + ref: v${{ matrix.ref }} + path: mosquitto + + - name: Configure and build mosquitto + run: | + cd $GITHUB_WORKSPACE/mosquitto/ + patch -p1 < $GITHUB_WORKSPACE/osp/mosquitto/${{ matrix.ref }}.patch + make WITH_TLS=wolfssl WITH_CJSON=no WITH_DOCS=no WOLFSSLDIR=$GITHUB_WORKSPACE/build-dir + + - name: Run mosquitto tests + working-directory: ./mosquitto + run: | + # Retry up to five times + for i in {1..5}; do + TEST_RES=0 + make WITH_TLS=wolfssl WITH_CJSON=no WITH_DOCS=no WOLFSSLDIR=$GITHUB_WORKSPACE/build-dir ptest || TEST_RES=$? + if [ "$TEST_RES" -eq "0" ]; then + break + fi + done + if [ "$TEST_RES" -ne "0" ]; then + exit $TEST_RES + fi diff --git a/.github/workflows/ntp.yml b/.github/workflows/ntp.yml new file mode 100644 index 0000000000..04eedd8e94 --- /dev/null +++ b/.github/workflows/ntp.yml @@ -0,0 +1,87 @@ +name: ntp Tests + +# START OF COMMON SECTION +on: + push: + branches: [ 'master', 'main', 'release/**' ] + pull_request: + branches: [ '*' ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +# END OF COMMON SECTION + +jobs: + build_wolfssl: + name: Build wolfSSL + # Just to keep it the same as the testing target + runs-on: ubuntu-latest + # This should be a safe limit for the tests to run. + timeout-minutes: 4 + steps: + - name: Build wolfSSL + uses: wolfSSL/actions-build-autotools-project@v1 + with: + path: wolfssl + configure: --enable-all + install: true + check: false + + - name: Upload built lib + uses: actions/upload-artifact@v4 + with: + name: wolf-install-ntp + path: build-dir + retention-days: 5 + + ntp_check: + strategy: + fail-fast: false + matrix: + # List of releases to test + ref: [ 4.2.8p15 ] + name: ${{ matrix.ref }} + runs-on: ubuntu-latest + # This should be a safe limit for the tests to run. + timeout-minutes: 10 + needs: build_wolfssl + steps: + - name: Download lib + uses: actions/download-artifact@v4 + with: + name: wolf-install-ntp + path: build-dir + + - name: Checkout OSP + uses: actions/checkout@v4 + with: + repository: wolfssl/osp + path: osp + + # Avoid DoS'ing ntp site so cache the tar.gz + - name: Check if we have ntp + uses: actions/cache@v4 + id: cache + with: + path: ntp-${{ matrix.ref }}.tar.gz + key: ntp-${{ matrix.ref }}.tar.gz + + - name: Download ntp + if: steps.cache.outputs.cache-hit != 'true' + run: | + wget https://downloads.nwtime.org/ntp/4.2.8/ntp-${{ matrix.ref }}.tar.gz + + - name: Extract ntp + run: | + tar -xf ntp-${{ matrix.ref }}.tar.gz + + - name: Build and test ntp + working-directory: ntp-${{ matrix.ref }} + run: | + patch -p1 < $GITHUB_WORKSPACE/osp/ntp/${{ matrix.ref }}/ntp-${{ matrix.ref }}.patch + ./bootstrap + ./configure --with-wolfssl=$GITHUB_WORKSPACE/build-dir + make -j + make -j check + \ No newline at end of file diff --git a/.github/workflows/rng-tools.yml b/.github/workflows/rng-tools.yml new file mode 100644 index 0000000000..a2297bb806 --- /dev/null +++ b/.github/workflows/rng-tools.yml @@ -0,0 +1,109 @@ +name: rng-tools Tests + +# START OF COMMON SECTION +on: + push: + branches: [ 'master', 'main', 'release/**' ] + pull_request: + branches: [ '*' ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +# END OF COMMON SECTION + +jobs: + build_wolfssl: + name: Build wolfSSL + # Just to keep it the same as the testing target + runs-on: ubuntu-latest + # This should be a safe limit for the tests to run. + timeout-minutes: 4 + steps: + - name: Build wolfSSL + uses: wolfSSL/actions-build-autotools-project@v1 + with: + path: wolfssl + configure: --enable-all + install: true + check: false + + - name: Upload built lib + uses: actions/upload-artifact@v4 + with: + name: wolf-install-rng-tools + path: build-dir + retention-days: 5 + + rng-tools_check: + strategy: + fail-fast: false + matrix: + # List of releases to test + ref: [ 6.16 ] + name: ${{ matrix.ref }} + runs-on: ubuntu-latest + # This should be a safe limit for the tests to run. + timeout-minutes: 4 + needs: build_wolfssl + steps: + - name: Install dependencies + run: | + # Don't prompt for anything + export DEBIAN_FRONTEND=noninteractive + sudo apt-get update + sudo apt-get install -y libcurl4-openssl-dev libjansson-dev libp11-dev librtlsdr-dev libcap-dev + + - name: Download lib + uses: actions/download-artifact@v4 + with: + name: wolf-install-rng-tools + path: build-dir + + - name: Checkout OSP + uses: actions/checkout@v4 + with: + repository: wolfssl/osp + path: osp + + - name: Checkout jitterentropy-library + uses: actions/checkout@v4 + with: + repository: smuellerDD/jitterentropy-library + path: jitterentropy-library + ref: v3.5.0 + + - name: Build jitterentropy-library + working-directory: jitterentropy-library + run: make -j + + - name: Build rng-tools + uses: wolfSSL/actions-build-autotools-project@v1 + with: + repository: nhorman/rng-tools + ref: v${{ matrix.ref }} + path: rng-tools + patch-file: $GITHUB_WORKSPACE/osp/rng-tools/${{ matrix.ref }}.patch + configure: --without-pkcs11 --enable-jitterentropy=$GITHUB_WORKSPACE/jitterentropy-library --with-wolfssl=$GITHUB_WORKSPACE/build-dir + check: false + + - name: Testing rng-tools + id: testing + working-directory: rng-tools + run: | + # Retry up to five times + for i in {1..5}; do + TEST_RES=0 + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/build-dir/lib make check || TEST_RES=$? + if [ "$TEST_RES" -eq "0" ]; then + break + fi + done + if [ "$TEST_RES" -ne "0" ]; then + exit $TEST_RES + fi + + - name: Print logs + if: ${{ failure() && steps.testing.outcome == 'failure' }} + working-directory: rng-tools/tests + run: cat test-suite.log diff --git a/IDE/ARDUINO/Arduino_README_prepend.md b/IDE/ARDUINO/Arduino_README_prepend.md index 594a067847..c11b35dbb9 100644 --- a/IDE/ARDUINO/Arduino_README_prepend.md +++ b/IDE/ARDUINO/Arduino_README_prepend.md @@ -10,4 +10,6 @@ See the [Arduino-wolfSSL logs](https://downloads.arduino.cc/libraries/logs/githu The first Official wolfSSL Arduino Library is `5.6.6-Arduino.1`: a slightly modified, post [release 5.6.6](https://github.com/wolfSSL/wolfssl/releases/tag/v5.6.6-stable) version update. +The next Official wolfSSL Arduino Library is [5.7.0](https://github.com/wolfSSL/wolfssl/releases/tag/v5.7.0-stable) + See other [wolfSSL releases versions](https://github.com/wolfSSL/wolfssl/releases). The `./wolfssl-arduino.sh INSTALL` [script](https://github.com/wolfSSL/wolfssl/tree/master/IDE/ARDUINO) can be used to install specific GitHub versions as needed. diff --git a/IDE/ARDUINO/sketches/wolfssl_client/wolfssl_client.ino b/IDE/ARDUINO/sketches/wolfssl_client/wolfssl_client.ino index 21a84deb00..e4727dce1a 100644 --- a/IDE/ARDUINO/sketches/wolfssl_client/wolfssl_client.ino +++ b/IDE/ARDUINO/sketches/wolfssl_client/wolfssl_client.ino @@ -1,6 +1,6 @@ /* wolfssl_client.ino * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ARDUINO/sketches/wolfssl_server/wolfssl_server.ino b/IDE/ARDUINO/sketches/wolfssl_server/wolfssl_server.ino index 3a894323e4..387052ca6b 100644 --- a/IDE/ARDUINO/sketches/wolfssl_server/wolfssl_server.ino +++ b/IDE/ARDUINO/sketches/wolfssl_server/wolfssl_server.ino @@ -1,6 +1,6 @@ /* wolfssl_server.ino * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ARDUINO/wolfssl-arduino.sh b/IDE/ARDUINO/wolfssl-arduino.sh index d48b416626..59fd238dfd 100755 --- a/IDE/ARDUINO/wolfssl-arduino.sh +++ b/IDE/ARDUINO/wolfssl-arduino.sh @@ -29,7 +29,7 @@ ROOT_DIR="/wolfssl" # The Arduino Version will initially have a suffix appended during fine tuning stage. -WOLFSSL_VERSION_ARUINO_SUFFIX="-Arduino.3" +WOLFSSL_VERSION_ARUINO_SUFFIX="" # For verbose copy, set CP_CMD="-v", otherwise clear it: CP_CMD="cp" # Do not set to empty string, as copy will fail with this: CP_CMD="" @@ -65,6 +65,11 @@ if ! [ "$CP_CMD" = "cp " ]; then fi fi +if [ "$ROOT_DIR" = "" ]; then + echo "ERROR: ROOT_DIR cannot be blank" + exit 1 +fi + # Check environment if [ -n "$WSL_DISTRO_NAME" ]; then # we found a non-blank WSL environment distro name @@ -84,6 +89,11 @@ if [ $# -gt 0 ]; then if [ "$THIS_OPERATION" = "INSTALL" ]; then THIS_INSTALL_DIR=$2 + if [ "$THIS_INSTALL_DIR" = "/" ]; then + echo "ERROR: THIS_INSTALL_DIR cannot be /" + exit 1 + fi + echo "Install is active." if [ "$THIS_INSTALL_DIR" = "" ]; then @@ -300,20 +310,22 @@ echo "" # Note we should have exited above if a problem was encountered, # as we'll never want to install a bad library. if [ "$THIS_OPERATION" = "INSTALL" ]; then + echo "Config:" + echo "cp ../../examples/configs/user_settings_arduino.h ".${ROOT_SRC_DIR}"/user_settings.h" + # Nearly an ordinary copy, but we remove any lines with ">>" (typically edit with caution warning in comments) + grep -v '>>' ../../examples/configs/user_settings_arduino.h > ".${ROOT_SRC_DIR}"/user_settings.h || exit 1 + + # Show the user_settings.h revision string: + grep "WOLFSSL_USER_SETTINGS_ID" ."${ROOT_SRC_DIR}/user_settings.h" + echo "" + if [ "$THIS_INSTALL_IS_GITHUB" = "true" ]; then echo "Installing to GitHub directory: $THIS_INSTALL_DIR" cp -r ."$ROOT_DIR"/* "$THIS_INSTALL_DIR" || exit 1 + echo "Removing workspace library directory: .$ROOT_DIR" + rm -rf ".$ROOT_DIR" else - echo "Config:" - echo "cp ../../examples/configs/user_settings_arduino.h ".${ROOT_SRC_DIR}"/user_settings.h" - # Nearly an ordinary copy, but we remove any lines with ">>" (typically edit with caution warning in comments) - grep -v '>>' ../../examples/configs/user_settings_arduino.h > ".${ROOT_SRC_DIR}"/user_settings.h || exit 1 - - # Show the user_settings.h revision string: - grep "WOLFSSL_USER_SETTINGS_ID" ."${ROOT_SRC_DIR}/user_settings.h" - echo "" - - echo "Install:" + echo "Installing to local directory:" echo "mv .$ROOT_DIR $ARDUINO_ROOT" mv ."$ROOT_DIR" "$ARDUINO_ROOT" || exit 1 diff --git a/IDE/AURIX/Cpu0_Main.c b/IDE/AURIX/Cpu0_Main.c index 536ddbb10c..687511c68f 100644 --- a/IDE/AURIX/Cpu0_Main.c +++ b/IDE/AURIX/Cpu0_Main.c @@ -1,6 +1,6 @@ /* Cpu0_Main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/AURIX/user_settings.h b/IDE/AURIX/user_settings.h index 4b41446b9e..d041a99862 100644 --- a/IDE/AURIX/user_settings.h +++ b/IDE/AURIX/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/AURIX/wolf_main.c b/IDE/AURIX/wolf_main.c index 9f90038985..f88140339b 100644 --- a/IDE/AURIX/wolf_main.c +++ b/IDE/AURIX/wolf_main.c @@ -1,6 +1,6 @@ /* wolf_main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/CRYPTOCELL/main.c b/IDE/CRYPTOCELL/main.c index 7938d0dfae..8cd8a20284 100644 --- a/IDE/CRYPTOCELL/main.c +++ b/IDE/CRYPTOCELL/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/CRYPTOCELL/user_settings.h b/IDE/CRYPTOCELL/user_settings.h index dc9822f5cf..3f1866e90e 100644 --- a/IDE/CRYPTOCELL/user_settings.h +++ b/IDE/CRYPTOCELL/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ECLIPSE/DEOS/deos_malloc.c b/IDE/ECLIPSE/DEOS/deos_malloc.c index b944e3bf05..9dcc7a473d 100644 --- a/IDE/ECLIPSE/DEOS/deos_malloc.c +++ b/IDE/ECLIPSE/DEOS/deos_malloc.c @@ -1,6 +1,6 @@ /* deos_malloc.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ECLIPSE/DEOS/tls_wolfssl.c b/IDE/ECLIPSE/DEOS/tls_wolfssl.c index 41149aa442..d74cc436ed 100644 --- a/IDE/ECLIPSE/DEOS/tls_wolfssl.c +++ b/IDE/ECLIPSE/DEOS/tls_wolfssl.c @@ -1,6 +1,6 @@ /* tls_wolfssl.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ECLIPSE/DEOS/tls_wolfssl.h b/IDE/ECLIPSE/DEOS/tls_wolfssl.h index 02a0e53161..427eef6388 100644 --- a/IDE/ECLIPSE/DEOS/tls_wolfssl.h +++ b/IDE/ECLIPSE/DEOS/tls_wolfssl.h @@ -1,6 +1,6 @@ /* tls_wolfssl.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ECLIPSE/DEOS/user_settings.h b/IDE/ECLIPSE/DEOS/user_settings.h index ca68a2a909..16dc09ee74 100644 --- a/IDE/ECLIPSE/DEOS/user_settings.h +++ b/IDE/ECLIPSE/DEOS/user_settings.h @@ -1,6 +1,6 @@ /* user_setting.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ECLIPSE/MICRIUM/client_wolfssl.c b/IDE/ECLIPSE/MICRIUM/client_wolfssl.c index 43d2e9be86..2c9b296417 100644 --- a/IDE/ECLIPSE/MICRIUM/client_wolfssl.c +++ b/IDE/ECLIPSE/MICRIUM/client_wolfssl.c @@ -1,6 +1,6 @@ /* client_wolfssl.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ECLIPSE/MICRIUM/client_wolfssl.h b/IDE/ECLIPSE/MICRIUM/client_wolfssl.h index f86cc98d51..edf6559f84 100644 --- a/IDE/ECLIPSE/MICRIUM/client_wolfssl.h +++ b/IDE/ECLIPSE/MICRIUM/client_wolfssl.h @@ -1,6 +1,6 @@ /* client_wolfssl.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ECLIPSE/MICRIUM/server_wolfssl.c b/IDE/ECLIPSE/MICRIUM/server_wolfssl.c index 225aaa2eef..e31f4ca615 100644 --- a/IDE/ECLIPSE/MICRIUM/server_wolfssl.c +++ b/IDE/ECLIPSE/MICRIUM/server_wolfssl.c @@ -1,6 +1,6 @@ /* server_wolfssl.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ECLIPSE/MICRIUM/server_wolfssl.h b/IDE/ECLIPSE/MICRIUM/server_wolfssl.h index 715e17b07c..b94e1fe6e2 100644 --- a/IDE/ECLIPSE/MICRIUM/server_wolfssl.h +++ b/IDE/ECLIPSE/MICRIUM/server_wolfssl.h @@ -1,6 +1,6 @@ /* server_wolfssl.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ECLIPSE/MICRIUM/user_settings.h b/IDE/ECLIPSE/MICRIUM/user_settings.h index b6b93fce84..27f8e08e25 100644 --- a/IDE/ECLIPSE/MICRIUM/user_settings.h +++ b/IDE/ECLIPSE/MICRIUM/user_settings.h @@ -1,6 +1,6 @@ /* user_setting.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ECLIPSE/MICRIUM/wolfsslRunTests.c b/IDE/ECLIPSE/MICRIUM/wolfsslRunTests.c index 99a9212e42..e7553c3d77 100644 --- a/IDE/ECLIPSE/MICRIUM/wolfsslRunTests.c +++ b/IDE/ECLIPSE/MICRIUM/wolfsslRunTests.c @@ -1,6 +1,6 @@ /* wolfsslRunTests.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ECLIPSE/RTTHREAD/user_settings.h b/IDE/ECLIPSE/RTTHREAD/user_settings.h index 28157c2026..5e5ec18b43 100644 --- a/IDE/ECLIPSE/RTTHREAD/user_settings.h +++ b/IDE/ECLIPSE/RTTHREAD/user_settings.h @@ -1,6 +1,6 @@ /* user_setting.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ECLIPSE/RTTHREAD/wolfssl_test.c b/IDE/ECLIPSE/RTTHREAD/wolfssl_test.c index 84d7f460a3..511801209c 100644 --- a/IDE/ECLIPSE/RTTHREAD/wolfssl_test.c +++ b/IDE/ECLIPSE/RTTHREAD/wolfssl_test.c @@ -1,6 +1,6 @@ /* wolfsslRunTests.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Espressif/ESP-IDF/dummy_config_h b/IDE/Espressif/ESP-IDF/dummy_config_h index 9d13eb2844..258ffd3f3d 100644 --- a/IDE/Espressif/ESP-IDF/dummy_config_h +++ b/IDE/Espressif/ESP-IDF/dummy_config_h @@ -1,6 +1,6 @@ /* config.h - dummy * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/CMakeLists.txt index 1aea2577f8..18e513b983 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/CMakeLists.txt @@ -1,21 +1,21 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # -# This file is part of wolfSSL. +# This file is part of wolfSSL. # -# wolfSSL is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. # -# wolfSSL is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA # # cmake for wolfssl Espressif projects # diff --git a/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/include/user_settings.h b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/include/user_settings.h index e0e0d61495..1a13d10fe8 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/include/user_settings.h +++ b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/include/user_settings.h @@ -584,7 +584,7 @@ Turn on timer debugging (used when CPU cycles not available) #define WOLFSSL_BASE16 #else #if defined(USE_CERT_BUFFERS_2048) - /* Be sure to include in app when using example certs: */ + /* Be sure to include in app when using example certs: */ /* #include */ #define CTX_CA_CERT ca_cert_der_2048 #define CTX_CA_CERT_SIZE sizeof_ca_cert_der_2048 @@ -605,7 +605,7 @@ Turn on timer debugging (used when CPU cycles not available) #define CTX_CLIENT_KEY_TYPE WOLFSSL_FILETYPE_ASN1 #elif defined(USE_CERT_BUFFERS_1024) - /* Be sure to include in app when using example certs: */ + /* Be sure to include in app when using example certs: */ /* #include */ #define CTX_CA_CERT ca_cert_der_1024 #define CTX_CA_CERT_SIZE sizeof_ca_cert_der_1024 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/CMakeLists.txt index 29f679b78f..f0bef7fc31 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/CMakeLists.txt @@ -1,21 +1,21 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # -# This file is part of wolfSSL. +# This file is part of wolfSSL. # -# wolfSSL is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. # -# wolfSSL is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA # # cmake for wolfssl Espressif projects # diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/include/user_settings.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/include/user_settings.h index 5862894ee4..1c30597da9 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/include/user_settings.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/include/user_settings.h @@ -705,7 +705,7 @@ Turn on timer debugging (used when CPU cycles not available) #define WOLFSSL_BASE16 #else #if defined(USE_CERT_BUFFERS_2048) - /* Be sure to include in app when using example certs: */ + /* Be sure to include in app when using example certs: */ /* #include */ #define CTX_CA_CERT ca_cert_der_2048 #define CTX_CA_CERT_SIZE sizeof_ca_cert_der_2048 @@ -726,7 +726,7 @@ Turn on timer debugging (used when CPU cycles not available) #define CTX_CLIENT_KEY_TYPE WOLFSSL_FILETYPE_ASN1 #elif defined(USE_CERT_BUFFERS_1024) - /* Be sure to include in app when using example certs: */ + /* Be sure to include in app when using example certs: */ /* #include */ #define CTX_CA_CERT ca_cert_der_1024 #define CTX_CA_CERT_SIZE sizeof_ca_cert_der_1024 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/CMakeLists.txt index 35b5cf88a8..c3c09ca532 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/CMakeLists.txt @@ -1,21 +1,21 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # -# This file is part of wolfSSL. +# This file is part of wolfSSL. # -# wolfSSL is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. # -# wolfSSL is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA # # cmake for wolfssl Espressif projects # diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/CMakeLists.txt index 60297155f5..b809a17142 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/CMakeLists.txt @@ -1,21 +1,21 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # -# This file is part of wolfSSL. +# This file is part of wolfSSL. # -# wolfSSL is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. # -# wolfSSL is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA # # cmake for wolfssl Espressif projects # diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/include/user_settings.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/include/user_settings.h index 9109e6f706..380da3e691 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/include/user_settings.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/include/user_settings.h @@ -132,7 +132,7 @@ #define WOLFSSL_SHA384 #if defined(CONFIG_IDF_TARGET_ESP8266) - /* Some known low-memory devices have features not enabled by default. */ + /* Some known low-memory devices have features not enabled by default. */ #else /* when you want to use SHA512 */ #define WOLFSSL_SHA512 @@ -140,7 +140,7 @@ /* when you want to use SHA3 */ #define WOLFSSL_SHA3 - /* ED25519 requires SHA512 */ + /* ED25519 requires SHA512 */ #define HAVE_ED25519 #define HAVE_ECC diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/CMakeLists.txt index b0be1c2dd0..5f42ad3452 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/CMakeLists.txt @@ -1,21 +1,21 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # -# This file is part of wolfSSL. +# This file is part of wolfSSL. # -# wolfSSL is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. # -# wolfSSL is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA # # cmake for wolfssl Espressif projects # diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/include/user_settings.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/include/user_settings.h index 59709233f2..9cf87e8fdb 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/include/user_settings.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/include/user_settings.h @@ -705,7 +705,7 @@ Turn on timer debugging (used when CPU cycles not available) #define WOLFSSL_BASE16 #else #if defined(USE_CERT_BUFFERS_2048) - /* Be sure to include in app when using example certs: */ + /* Be sure to include in app when using example certs: */ /* #include */ #define CTX_CA_CERT ca_cert_der_2048 #define CTX_CA_CERT_SIZE sizeof_ca_cert_der_2048 @@ -726,7 +726,7 @@ Turn on timer debugging (used when CPU cycles not available) #define CTX_CLIENT_KEY_TYPE WOLFSSL_FILETYPE_ASN1 #elif defined(USE_CERT_BUFFERS_1024) - /* Be sure to include in app when using example certs: */ + /* Be sure to include in app when using example certs: */ /* #include */ #define CTX_CA_CERT ca_cert_der_1024 #define CTX_CA_CERT_SIZE sizeof_ca_cert_der_1024 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/main_wip.c.ex b/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/main_wip.c.ex index b301e65201..a1a18d9812 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/main_wip.c.ex +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/main_wip.c.ex @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Espressif/ESP-IDF/libs/CMakeLists.txt b/IDE/Espressif/ESP-IDF/libs/CMakeLists.txt index b63775e143..a0ec798a2b 100644 --- a/IDE/Espressif/ESP-IDF/libs/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/libs/CMakeLists.txt @@ -1,21 +1,21 @@ # -# Copyright (C) 2006-2022 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # -# This file is part of wolfSSL. +# This file is part of wolfSSL. # -# wolfSSL is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. # -# wolfSSL is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA # # cmake for wolfssl # diff --git a/IDE/Espressif/ESP-IDF/libs/component.mk b/IDE/Espressif/ESP-IDF/libs/component.mk index ac239e538e..047bb83ea0 100644 --- a/IDE/Espressif/ESP-IDF/libs/component.mk +++ b/IDE/Espressif/ESP-IDF/libs/component.mk @@ -16,6 +16,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +#/ # # # Component Makefile diff --git a/IDE/GCC-ARM/Header/user_settings.h b/IDE/GCC-ARM/Header/user_settings.h index f1f8fd6d11..e3a0922997 100644 --- a/IDE/GCC-ARM/Header/user_settings.h +++ b/IDE/GCC-ARM/Header/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -250,10 +250,10 @@ extern "C" { /* AES */ #undef NO_AES #if 1 - #undef HAVE_AES_CBC - #define HAVE_AES_CBC + #undef HAVE_AES_CBC + #define HAVE_AES_CBC - #undef HAVE_AESGCM + #undef HAVE_AESGCM #define HAVE_AESGCM /* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */ diff --git a/IDE/GCC-ARM/Source/armtarget.c b/IDE/GCC-ARM/Source/armtarget.c index 4780be1f1d..8b62a6b756 100644 --- a/IDE/GCC-ARM/Source/armtarget.c +++ b/IDE/GCC-ARM/Source/armtarget.c @@ -1,6 +1,6 @@ /* armtarget.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/GCC-ARM/Source/benchmark_main.c b/IDE/GCC-ARM/Source/benchmark_main.c index e113c86ef6..1151bbc32c 100644 --- a/IDE/GCC-ARM/Source/benchmark_main.c +++ b/IDE/GCC-ARM/Source/benchmark_main.c @@ -1,6 +1,6 @@ /* benchmark_main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/GCC-ARM/Source/test_main.c b/IDE/GCC-ARM/Source/test_main.c index bf7216b116..c63246368b 100644 --- a/IDE/GCC-ARM/Source/test_main.c +++ b/IDE/GCC-ARM/Source/test_main.c @@ -1,6 +1,6 @@ /* test_main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/GCC-ARM/Source/tls_client.c b/IDE/GCC-ARM/Source/tls_client.c index 00afe6ef95..927b854d3d 100644 --- a/IDE/GCC-ARM/Source/tls_client.c +++ b/IDE/GCC-ARM/Source/tls_client.c @@ -1,6 +1,6 @@ /* tls_client.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/GCC-ARM/Source/tls_server.c b/IDE/GCC-ARM/Source/tls_server.c index 50e93d1a1e..1a19b4e53c 100644 --- a/IDE/GCC-ARM/Source/tls_server.c +++ b/IDE/GCC-ARM/Source/tls_server.c @@ -1,6 +1,6 @@ /* tls_server.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/GCC-ARM/Source/wolf_main.c b/IDE/GCC-ARM/Source/wolf_main.c index 3c705d2451..0956773b6e 100644 --- a/IDE/GCC-ARM/Source/wolf_main.c +++ b/IDE/GCC-ARM/Source/wolf_main.c @@ -1,6 +1,6 @@ /* wolf_main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/HEXAGON/DSP/Makefile b/IDE/HEXAGON/DSP/Makefile index 5b73cef4db..361873ee8c 100644 --- a/IDE/HEXAGON/DSP/Makefile +++ b/IDE/HEXAGON/DSP/Makefile @@ -1,6 +1,6 @@ # Makefile # -# Copyright (C) 2006-2023 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # # This file is part of wolfSSL. # diff --git a/IDE/HEXAGON/Makefile b/IDE/HEXAGON/Makefile index cdf6a1c59e..cf7252c866 100644 --- a/IDE/HEXAGON/Makefile +++ b/IDE/HEXAGON/Makefile @@ -1,6 +1,6 @@ # Makefile # -# Copyright (C) 2006-2023 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # # This file is part of wolfSSL. # diff --git a/IDE/HEXAGON/ecc-verify-benchmark.c b/IDE/HEXAGON/ecc-verify-benchmark.c index 24f9125702..d000925a5e 100644 --- a/IDE/HEXAGON/ecc-verify-benchmark.c +++ b/IDE/HEXAGON/ecc-verify-benchmark.c @@ -1,6 +1,6 @@ /* ecc-verify-benchmark.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/HEXAGON/ecc-verify.c b/IDE/HEXAGON/ecc-verify.c index ccbc18d81b..1e2d9510fb 100644 --- a/IDE/HEXAGON/ecc-verify.c +++ b/IDE/HEXAGON/ecc-verify.c @@ -1,6 +1,6 @@ /* ecc-verify.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/HEXAGON/user_settings.h b/IDE/HEXAGON/user_settings.h index 1897e883c4..5643e759db 100644 --- a/IDE/HEXAGON/user_settings.h +++ b/IDE/HEXAGON/user_settings.h @@ -13,25 +13,25 @@ #define USE_FAST_MATH #define TFM_TIMING_RESISTANT #ifdef HAVE_ECC - #define ECC_TIMING_RESISTANT + #define ECC_TIMING_RESISTANT #endif #ifndef NO_RSA - #define WC_RSA_BLINDING + #define WC_RSA_BLINDING #endif #if 1 - #define WOLFSSL_HAVE_SP_RSA - #define WOLFSSL_HAVE_SP_ECC - #define WOLFSSL_SP_MATH + #define WOLFSSL_HAVE_SP_RSA + #define WOLFSSL_HAVE_SP_ECC + #define WOLFSSL_SP_MATH - #if 1 - /* ARM NEON instructions */ - #define WOLFSSL_SP_ARM64_ASM - #endif - #if 1 - /* Use DSP */ - #define WOLFSSL_DSP - #endif + #if 1 + /* ARM NEON instructions */ + #define WOLFSSL_SP_ARM64_ASM + #endif + #if 1 + /* Use DSP */ + #define WOLFSSL_DSP + #endif #endif #endif diff --git a/IDE/IAR-EWARM/Projects/benchmark/benchmark-main.c b/IDE/IAR-EWARM/Projects/benchmark/benchmark-main.c index f5e51cd977..76d4470c75 100644 --- a/IDE/IAR-EWARM/Projects/benchmark/benchmark-main.c +++ b/IDE/IAR-EWARM/Projects/benchmark/benchmark-main.c @@ -1,6 +1,6 @@ /* benchmark-main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/IAR-EWARM/Projects/benchmark/current_time.c b/IDE/IAR-EWARM/Projects/benchmark/current_time.c index 0e8d402687..cf0f57ac68 100644 --- a/IDE/IAR-EWARM/Projects/benchmark/current_time.c +++ b/IDE/IAR-EWARM/Projects/benchmark/current_time.c @@ -1,6 +1,6 @@ /* current-time.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/IAR-EWARM/Projects/common/minimum-startup.c b/IDE/IAR-EWARM/Projects/common/minimum-startup.c index ec79e29a4f..4463b158d2 100644 --- a/IDE/IAR-EWARM/Projects/common/minimum-startup.c +++ b/IDE/IAR-EWARM/Projects/common/minimum-startup.c @@ -1,6 +1,6 @@ /* minimum-startup.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/IAR-EWARM/Projects/test/test-main.c b/IDE/IAR-EWARM/Projects/test/test-main.c index d472d5d1e1..13d1308d55 100644 --- a/IDE/IAR-EWARM/Projects/test/test-main.c +++ b/IDE/IAR-EWARM/Projects/test/test-main.c @@ -1,6 +1,6 @@ /* test-main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/IAR-MSP430/main.c b/IDE/IAR-MSP430/main.c index e89afb6280..c99cb0075a 100644 --- a/IDE/IAR-MSP430/main.c +++ b/IDE/IAR-MSP430/main.c @@ -1,6 +1,6 @@ /* MSP430 example main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/IAR-MSP430/user_settings.h b/IDE/IAR-MSP430/user_settings.h index 1e4caea9d3..fc8f6ba621 100644 --- a/IDE/IAR-MSP430/user_settings.h +++ b/IDE/IAR-MSP430/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/LPCXPRESSO/lib_wolfssl/lpc_18xx_port.c b/IDE/LPCXPRESSO/lib_wolfssl/lpc_18xx_port.c index dd27de2665..1bd3c8ecd2 100644 --- a/IDE/LPCXPRESSO/lib_wolfssl/lpc_18xx_port.c +++ b/IDE/LPCXPRESSO/lib_wolfssl/lpc_18xx_port.c @@ -1,6 +1,6 @@ /* lpc_18xx_port.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/LPCXPRESSO/wolf_example/src/lpc_18xx_startup.c b/IDE/LPCXPRESSO/wolf_example/src/lpc_18xx_startup.c index 8f67b1c33e..f5ffe3fe6c 100644 --- a/IDE/LPCXPRESSO/wolf_example/src/lpc_18xx_startup.c +++ b/IDE/LPCXPRESSO/wolf_example/src/lpc_18xx_startup.c @@ -1,6 +1,6 @@ /* lpc_18xx_startup.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/M68K/README.md b/IDE/M68K/README.md index 2fe43b67ac..64eaad8b5d 100644 --- a/IDE/M68K/README.md +++ b/IDE/M68K/README.md @@ -34,7 +34,7 @@ BUILD_C RSA 2048 public 7.619 ops/sec RSA 2048 private 0.276 ops/sec -###Building testwolfcryt/benchmark +###Building testwolfcrypt/benchmark To build either testwolfcrypt or benchmark first build wolfssl.a, place it in $(NBROOT)/lib and then cd into the respective directory. Running "make" will then create a .s19 application that can be ran on the board. diff --git a/IDE/M68K/benchmark/main.cpp b/IDE/M68K/benchmark/main.cpp index a7a76fb2d5..263b9289a2 100644 --- a/IDE/M68K/benchmark/main.cpp +++ b/IDE/M68K/benchmark/main.cpp @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/M68K/testwolfcrypt/main.cpp b/IDE/M68K/testwolfcrypt/main.cpp index 8b31c9e893..3df8ebd37c 100644 --- a/IDE/M68K/testwolfcrypt/main.cpp +++ b/IDE/M68K/testwolfcrypt/main.cpp @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MCUEXPRESSO/RT1170/user_settings.h b/IDE/MCUEXPRESSO/RT1170/user_settings.h index f620b1cc9f..f89e398664 100644 --- a/IDE/MCUEXPRESSO/RT1170/user_settings.h +++ b/IDE/MCUEXPRESSO/RT1170/user_settings.h @@ -53,7 +53,7 @@ /* using the RTC */ //#define NO_ASN_TIME #ifndef NO_ASN_TIME - #define FREESCALE_SNVS_RTC + #define FREESCALE_SNVS_RTC #endif #define NO_CRYPT_TEST @@ -64,19 +64,19 @@ #include static void myPrintf(const char* fmt, ...) { - int ret; - char line[150]; - va_list ap; + int ret; + char line[150]; + va_list ap; - va_start(ap, fmt); - ret = vsnprintf(line, sizeof(line), fmt, ap); - line[sizeof(line)-1] = '\0'; + va_start(ap, fmt); + ret = vsnprintf(line, sizeof(line), fmt, ap); + line[sizeof(line)-1] = '\0'; - DbgConsole_Printf("%s", line); + DbgConsole_Printf("%s", line); - /* add CR on newlines */ - if (ret > 0 && line[ret-1] == '\n') { - DbgConsole_Printf("\r"); + /* add CR on newlines */ + if (ret > 0 && line[ret-1] == '\n') { + DbgConsole_Printf("\r"); } } #define XPRINTF myPrintf diff --git a/IDE/MCUEXPRESSO/benchmark/source/run_benchmark.c b/IDE/MCUEXPRESSO/benchmark/source/run_benchmark.c index c413251325..bf092fce9c 100644 --- a/IDE/MCUEXPRESSO/benchmark/source/run_benchmark.c +++ b/IDE/MCUEXPRESSO/benchmark/source/run_benchmark.c @@ -1,6 +1,6 @@ /* run_benchmark.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MCUEXPRESSO/user_settings.h b/IDE/MCUEXPRESSO/user_settings.h index 77e137852f..d9fd0766c2 100644 --- a/IDE/MCUEXPRESSO/user_settings.h +++ b/IDE/MCUEXPRESSO/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -40,19 +40,19 @@ #include static void myPrintf(const char* fmt, ...) { - int ret; - char line[150]; - va_list ap; + int ret; + char line[150]; + va_list ap; - va_start(ap, fmt); - ret = vsnprintf(line, sizeof(line), fmt, ap); - line[sizeof(line)-1] = '\0'; + va_start(ap, fmt); + ret = vsnprintf(line, sizeof(line), fmt, ap); + line[sizeof(line)-1] = '\0'; - DbgConsole_Printf("%s", line); + DbgConsole_Printf("%s", line); - /* add CR on newlines */ - if (ret > 0 && line[ret-1] == '\n') { - DbgConsole_Printf("\r"); + /* add CR on newlines */ + if (ret > 0 && line[ret-1] == '\n') { + DbgConsole_Printf("\r"); } } #define XPRINTF myPrintf @@ -70,9 +70,9 @@ #define USE_FAST_MATH #ifdef USE_FAST_MATH /* big enough for even 4096 bit RSA key */ - #define FP_MAX_BITS 8192 - #define TFM_TIMING_RESISTANT - #define ECC_TIMING_RESISTANT + #define FP_MAX_BITS 8192 + #define TFM_TIMING_RESISTANT + #define ECC_TIMING_RESISTANT #define ALT_ECC_SIZE #endif diff --git a/IDE/MCUEXPRESSO/wolfcrypt_test.c b/IDE/MCUEXPRESSO/wolfcrypt_test.c index 08a0d432e8..8d8993dda2 100644 --- a/IDE/MCUEXPRESSO/wolfcrypt_test.c +++ b/IDE/MCUEXPRESSO/wolfcrypt_test.c @@ -1,6 +1,6 @@ /* wolfcrypt_test.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/LPC43xx/time-LCP43xx.c b/IDE/MDK-ARM/LPC43xx/time-LCP43xx.c index 1e7fba4f12..04d4802165 100644 --- a/IDE/MDK-ARM/LPC43xx/time-LCP43xx.c +++ b/IDE/MDK-ARM/LPC43xx/time-LCP43xx.c @@ -1,6 +1,6 @@ /* time.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/cert_data.c b/IDE/MDK-ARM/MDK-ARM/wolfSSL/cert_data.c index 3f2af99c99..0f57692e27 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/cert_data.c +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/cert_data.c @@ -1,6 +1,6 @@ /* certs_test.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-BARE-METAL.h b/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-BARE-METAL.h index ca36781692..04373c97ab 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-BARE-METAL.h +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-BARE-METAL.h @@ -1,6 +1,6 @@ /* config-BEREFOOT.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-FS.h b/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-FS.h index 45b8c1b329..85e02db34c 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-FS.h +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-FS.h @@ -1,6 +1,6 @@ /* config-FS.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-RTX-TCP-FS.h b/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-RTX-TCP-FS.h index a96e5d7862..eb93fa931a 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-RTX-TCP-FS.h +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-RTX-TCP-FS.h @@ -1,6 +1,6 @@ /* config-RTX-TCP-FS.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/config.h b/IDE/MDK-ARM/MDK-ARM/wolfSSL/config.h index 98562cd164..d6fe1aa16d 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/config.h +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/config.h @@ -1,6 +1,6 @@ /* config.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/main.c b/IDE/MDK-ARM/MDK-ARM/wolfSSL/main.c index de71e9941e..84d3bc4ba0 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/main.c +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/shell.c b/IDE/MDK-ARM/MDK-ARM/wolfSSL/shell.c index 63e2cdc2f1..1ce952e037 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/shell.c +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/shell.c @@ -1,6 +1,6 @@ /*shell.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/time-CortexM3-4.c b/IDE/MDK-ARM/MDK-ARM/wolfSSL/time-CortexM3-4.c index 024943bd3d..f7cb61f0df 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/time-CortexM3-4.c +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/time-CortexM3-4.c @@ -1,6 +1,6 @@ /* time-STM32F2.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/time-dummy.c b/IDE/MDK-ARM/MDK-ARM/wolfSSL/time-dummy.c index bd7d515026..f41a948137 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/time-dummy.c +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/time-dummy.c @@ -1,6 +1,6 @@ /* time-dummy.c.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/wolfssl_MDK_ARM.c b/IDE/MDK-ARM/MDK-ARM/wolfSSL/wolfssl_MDK_ARM.c index 9b68ab8158..7908dfec68 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/wolfssl_MDK_ARM.c +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/wolfssl_MDK_ARM.c @@ -1,6 +1,6 @@ /* wolfssl_KEIL_RL.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/wolfssl_MDK_ARM.h b/IDE/MDK-ARM/MDK-ARM/wolfSSL/wolfssl_MDK_ARM.h index 6e3464ba6e..b52c547fde 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/wolfssl_MDK_ARM.h +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/wolfssl_MDK_ARM.h @@ -1,6 +1,6 @@ /* wolfssl_KEIL_RL.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -78,7 +78,7 @@ typedef int socklen_t ; #define tcp_listen wolfssl_tcp_listen #define tcp_select wolfssl_tcp_select -extern int wolfssl_connect(int sd, const struct sockaddr* sa, int sz) ; +extern int wolfssl_connect(int sd, const struct sockaddr* sa, int sz) ; extern int wolfssl_accept(int sd, struct sockaddr*addr, socklen_t *addrlen); extern int wolfssl_recv(int sd, void *buf, size_t len, int flags); extern int wolfssl_send(int sd, const void *buf, size_t len, int flags); diff --git a/IDE/MDK-ARM/STM32F2xx_StdPeriph_Lib/time-STM32F2xx.c b/IDE/MDK-ARM/STM32F2xx_StdPeriph_Lib/time-STM32F2xx.c index 08dcbdf8f3..3a30349cac 100644 --- a/IDE/MDK-ARM/STM32F2xx_StdPeriph_Lib/time-STM32F2xx.c +++ b/IDE/MDK-ARM/STM32F2xx_StdPeriph_Lib/time-STM32F2xx.c @@ -1,6 +1,6 @@ /* time-STM32F2xx.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK5-ARM/Conf/user_settings.h b/IDE/MDK5-ARM/Conf/user_settings.h index c58b5fb6a9..089712b852 100644 --- a/IDE/MDK5-ARM/Conf/user_settings.h +++ b/IDE/MDK5-ARM/Conf/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK5-ARM/Inc/wolfssl_MDK_ARM.h b/IDE/MDK5-ARM/Inc/wolfssl_MDK_ARM.h index e6d314a771..66623a9441 100644 --- a/IDE/MDK5-ARM/Inc/wolfssl_MDK_ARM.h +++ b/IDE/MDK5-ARM/Inc/wolfssl_MDK_ARM.h @@ -1,6 +1,6 @@ /* wolfssl_MDK_ARM.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK5-ARM/Projects/CryptBenchmark/main.c b/IDE/MDK5-ARM/Projects/CryptBenchmark/main.c index 1b055e7fa0..a9b0bc0add 100644 --- a/IDE/MDK5-ARM/Projects/CryptBenchmark/main.c +++ b/IDE/MDK5-ARM/Projects/CryptBenchmark/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK5-ARM/Projects/CryptTest/main.c b/IDE/MDK5-ARM/Projects/CryptTest/main.c index 6425e654e5..826a8ade2b 100644 --- a/IDE/MDK5-ARM/Projects/CryptTest/main.c +++ b/IDE/MDK5-ARM/Projects/CryptTest/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK5-ARM/Projects/EchoClient/main.c b/IDE/MDK5-ARM/Projects/EchoClient/main.c index 22f27cb153..0e40a7249e 100644 --- a/IDE/MDK5-ARM/Projects/EchoClient/main.c +++ b/IDE/MDK5-ARM/Projects/EchoClient/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK5-ARM/Projects/EchoServer/main.c b/IDE/MDK5-ARM/Projects/EchoServer/main.c index 53a27bec00..a99244f63c 100644 --- a/IDE/MDK5-ARM/Projects/EchoServer/main.c +++ b/IDE/MDK5-ARM/Projects/EchoServer/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK5-ARM/Projects/SimpleClient/main.c b/IDE/MDK5-ARM/Projects/SimpleClient/main.c index 0461547014..686cda6b6a 100644 --- a/IDE/MDK5-ARM/Projects/SimpleClient/main.c +++ b/IDE/MDK5-ARM/Projects/SimpleClient/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK5-ARM/Projects/SimpleServer/main.c b/IDE/MDK5-ARM/Projects/SimpleServer/main.c index 973fdbbe1d..22e6a9b056 100644 --- a/IDE/MDK5-ARM/Projects/SimpleServer/main.c +++ b/IDE/MDK5-ARM/Projects/SimpleServer/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK5-ARM/Projects/wolfSSL-Full/main.c b/IDE/MDK5-ARM/Projects/wolfSSL-Full/main.c index 9eab03cc69..db26c5b262 100644 --- a/IDE/MDK5-ARM/Projects/wolfSSL-Full/main.c +++ b/IDE/MDK5-ARM/Projects/wolfSSL-Full/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK5-ARM/Projects/wolfSSL-Full/shell.c b/IDE/MDK5-ARM/Projects/wolfSSL-Full/shell.c index 3958f4a23e..06f39b0e86 100644 --- a/IDE/MDK5-ARM/Projects/wolfSSL-Full/shell.c +++ b/IDE/MDK5-ARM/Projects/wolfSSL-Full/shell.c @@ -1,6 +1,6 @@ /*shell.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK5-ARM/Projects/wolfSSL-Full/time-CortexM3-4.c b/IDE/MDK5-ARM/Projects/wolfSSL-Full/time-CortexM3-4.c index 8b1de0aa51..a4ce55fc60 100644 --- a/IDE/MDK5-ARM/Projects/wolfSSL-Full/time-CortexM3-4.c +++ b/IDE/MDK5-ARM/Projects/wolfSSL-Full/time-CortexM3-4.c @@ -1,6 +1,6 @@ /* time-STM32F2.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK5-ARM/Src/ssl-dummy.c b/IDE/MDK5-ARM/Src/ssl-dummy.c index 7cfd82ec69..734b126ce0 100644 --- a/IDE/MDK5-ARM/Src/ssl-dummy.c +++ b/IDE/MDK5-ARM/Src/ssl-dummy.c @@ -1,6 +1,6 @@ /* ssl-dummy.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MQX/client-tls.c b/IDE/MQX/client-tls.c index 9834251c0d..70ef3b4eaa 100644 --- a/IDE/MQX/client-tls.c +++ b/IDE/MQX/client-tls.c @@ -1,6 +1,6 @@ /* client-tls.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MQX/server-tls.c b/IDE/MQX/server-tls.c index e7e1a48529..ae2c7ae947 100644 --- a/IDE/MQX/server-tls.c +++ b/IDE/MQX/server-tls.c @@ -1,6 +1,6 @@ /* server-tls.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MSVS-2019-AZSPHERE/client/client.c b/IDE/MSVS-2019-AZSPHERE/client/client.c index 6756c89a57..d758a39fd1 100644 --- a/IDE/MSVS-2019-AZSPHERE/client/client.c +++ b/IDE/MSVS-2019-AZSPHERE/client/client.c @@ -1,6 +1,6 @@ /* client.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MSVS-2019-AZSPHERE/client/client.h b/IDE/MSVS-2019-AZSPHERE/client/client.h index f10c0db94f..edef19afc3 100644 --- a/IDE/MSVS-2019-AZSPHERE/client/client.h +++ b/IDE/MSVS-2019-AZSPHERE/client/client.h @@ -1,6 +1,6 @@ /* client.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MSVS-2019-AZSPHERE/server/server.c b/IDE/MSVS-2019-AZSPHERE/server/server.c index 7c4528a06d..dbf49efedf 100644 --- a/IDE/MSVS-2019-AZSPHERE/server/server.c +++ b/IDE/MSVS-2019-AZSPHERE/server/server.c @@ -1,6 +1,6 @@ /* server.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MSVS-2019-AZSPHERE/server/server.h b/IDE/MSVS-2019-AZSPHERE/server/server.h index e4d5edfeaf..e3a53b5e3a 100644 --- a/IDE/MSVS-2019-AZSPHERE/server/server.h +++ b/IDE/MSVS-2019-AZSPHERE/server/server.h @@ -1,6 +1,6 @@ /* server.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MSVS-2019-AZSPHERE/shared/util.h b/IDE/MSVS-2019-AZSPHERE/shared/util.h index fc54a709ae..0cab4bf60e 100644 --- a/IDE/MSVS-2019-AZSPHERE/shared/util.h +++ b/IDE/MSVS-2019-AZSPHERE/shared/util.h @@ -1,6 +1,6 @@ /* util.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MSVS-2019-AZSPHERE/user_settings.h b/IDE/MSVS-2019-AZSPHERE/user_settings.h index 0dc2354b50..ea18de895f 100644 --- a/IDE/MSVS-2019-AZSPHERE/user_settings.h +++ b/IDE/MSVS-2019-AZSPHERE/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -31,9 +31,9 @@ #ifndef SERVER_IP #define SERVER_IP "192.168.1.200" /* Local Test Server IP */ #endif - #ifndef DEFAULT_PORT - #define DEFAULT_PORT 11111 - #endif + #ifndef DEFAULT_PORT + #define DEFAULT_PORT 11111 + #endif #define CERT ca_cert_der_2048 #define SIZEOF_CERT sizeof_ca_cert_der_2048 static const char msg[] = "Are you listening wolfSSL Server?"; @@ -41,9 +41,9 @@ #ifndef SERVER_IP #define SERVER_IP "www.wolfssl.com" #endif - #ifndef DEFAULT_PORT - #define DEFAULT_PORT 443 - #endif + #ifndef DEFAULT_PORT + #define DEFAULT_PORT 443 + #endif #define CERT wolfssl_website_root_ca #define SIZEOF_CERT sizeof_wolfssl_website_root_ca static const char msg[] = "GET /index.html HTTP/1.1\r\n\r\n"; diff --git a/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/HardwareDefinitions/avnet_mt3620_sk/inc/hw/template_appliance.h b/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/HardwareDefinitions/avnet_mt3620_sk/inc/hw/template_appliance.h index 2837ac3c2d..cb3721ec43 100644 --- a/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/HardwareDefinitions/avnet_mt3620_sk/inc/hw/template_appliance.h +++ b/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/HardwareDefinitions/avnet_mt3620_sk/inc/hw/template_appliance.h @@ -1,6 +1,6 @@ /* template_appliance.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/HardwareDefinitions/mt3620_rdb/inc/hw/template_appliance.h b/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/HardwareDefinitions/mt3620_rdb/inc/hw/template_appliance.h index 05ed1790f6..974d2d8e10 100644 --- a/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/HardwareDefinitions/mt3620_rdb/inc/hw/template_appliance.h +++ b/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/HardwareDefinitions/mt3620_rdb/inc/hw/template_appliance.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2006-2022 wolfSSL Inc. +/ * Copyright (C) 2006-2024 wolfSSL Inc. + * * This file is part of wolfSSL. * * wolfSSL is free software; you can redistribute it and/or modify diff --git a/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/HardwareDefinitions/seeed_mt3620_mdb/inc/hw/template_appliance.h b/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/HardwareDefinitions/seeed_mt3620_mdb/inc/hw/template_appliance.h index 051b6ac03b..ad9cab58bf 100644 --- a/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/HardwareDefinitions/seeed_mt3620_mdb/inc/hw/template_appliance.h +++ b/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/HardwareDefinitions/seeed_mt3620_mdb/inc/hw/template_appliance.h @@ -1,6 +1,6 @@ /* template_appliance.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/main.c b/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/main.c index ca8e80577c..acd8668264 100644 --- a/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/main.c +++ b/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MYSQL/CMakeLists_wolfCrypt.txt b/IDE/MYSQL/CMakeLists_wolfCrypt.txt index 566b7d8b80..ba6d98116a 100644 --- a/IDE/MYSQL/CMakeLists_wolfCrypt.txt +++ b/IDE/MYSQL/CMakeLists_wolfCrypt.txt @@ -1,6 +1,6 @@ # CMakeLists.txt # -# Copyright (C) 2006-2023 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # # This file is part of wolfSSL. # diff --git a/IDE/MYSQL/CMakeLists_wolfSSL.txt b/IDE/MYSQL/CMakeLists_wolfSSL.txt index e95c929103..7bfaa88c90 100644 --- a/IDE/MYSQL/CMakeLists_wolfSSL.txt +++ b/IDE/MYSQL/CMakeLists_wolfSSL.txt @@ -1,6 +1,6 @@ # CMakeLists.txt # -# Copyright (C) 2006-2023 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # # This file is part of wolfSSL. # diff --git a/IDE/NETOS/user_settings.h b/IDE/NETOS/user_settings.h index ceb70ec663..957cf82b01 100644 --- a/IDE/NETOS/user_settings.h +++ b/IDE/NETOS/user_settings.h @@ -1,23 +1,23 @@ /* user_settings.h * -* Copyright (C) 2006-2021 wolfSSL Inc. -* -* This file is part of wolfSSL. -* -* wolfSSL is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* wolfSSL is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA -*/ + * Copyright (C) 2006-2024 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ /* Custom wolfSSL user settings for GCC ARM */ diff --git a/IDE/NETOS/wolfssl_netos_custom.c b/IDE/NETOS/wolfssl_netos_custom.c index 8617eee66b..db4b518aa0 100644 --- a/IDE/NETOS/wolfssl_netos_custom.c +++ b/IDE/NETOS/wolfssl_netos_custom.c @@ -1,6 +1,6 @@ /* wolfssl_netos_custom.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/PlatformIO/examples/wolfssl_benchmark/platformio.ini b/IDE/PlatformIO/examples/wolfssl_benchmark/platformio.ini index c9e32235c5..a83ae32410 100644 --- a/IDE/PlatformIO/examples/wolfssl_benchmark/platformio.ini +++ b/IDE/PlatformIO/examples/wolfssl_benchmark/platformio.ini @@ -17,4 +17,4 @@ monitor_port = COM19 monitor_speed = 115200 build_flags = -DWOLFSSL_USER_SETTINGS, -DWOLFSSL_ESP32 monitor_filters = direct -lib_deps = wolfssl/wolfSSL@^5.7.0-rev.3b +lib_deps = wolfssl/wolfSSL@^5.7.2 diff --git a/IDE/PlatformIO/examples/wolfssl_test/platformio.ini b/IDE/PlatformIO/examples/wolfssl_test/platformio.ini index 79356a165c..5382576311 100644 --- a/IDE/PlatformIO/examples/wolfssl_test/platformio.ini +++ b/IDE/PlatformIO/examples/wolfssl_test/platformio.ini @@ -39,4 +39,4 @@ monitor_port = COM19 monitor_speed = 115200 build_flags = -DWOLFSSL_USER_SETTINGS, -DWOLFSSL_ESP32 monitor_filters = direct -lib_deps = wolfssl/wolfssl@^5.7.0-rev.3d +lib_deps = wolfssl/wolfssl@^5.7.2 diff --git a/IDE/QNX/example-client/client-tls.c b/IDE/QNX/example-client/client-tls.c index 27e56e3438..9c9b6e4b0c 100644 --- a/IDE/QNX/example-client/client-tls.c +++ b/IDE/QNX/example-client/client-tls.c @@ -1,6 +1,6 @@ /* client-tls.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/QNX/example-cmac/cmac-test.c b/IDE/QNX/example-cmac/cmac-test.c index f72277e9d9..64d5ccacd4 100644 --- a/IDE/QNX/example-cmac/cmac-test.c +++ b/IDE/QNX/example-cmac/cmac-test.c @@ -1,6 +1,6 @@ /* cmac-test.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/QNX/example-server/server-tls.c b/IDE/QNX/example-server/server-tls.c index 6c2a9f1f4e..1257e3b331 100644 --- a/IDE/QNX/example-server/server-tls.c +++ b/IDE/QNX/example-server/server-tls.c @@ -1,6 +1,6 @@ /* server-tls.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/RISCV/SIFIVE-HIFIVE1/main.c b/IDE/RISCV/SIFIVE-HIFIVE1/main.c index ff0488956b..3431232af8 100644 --- a/IDE/RISCV/SIFIVE-HIFIVE1/main.c +++ b/IDE/RISCV/SIFIVE-HIFIVE1/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h b/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h index e0a4a9077c..d3f3de9444 100644 --- a/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h +++ b/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ROWLEY-CROSSWORKS-ARM/arm_startup.c b/IDE/ROWLEY-CROSSWORKS-ARM/arm_startup.c index 2e1d7707bc..085fa4109a 100644 --- a/IDE/ROWLEY-CROSSWORKS-ARM/arm_startup.c +++ b/IDE/ROWLEY-CROSSWORKS-ARM/arm_startup.c @@ -1,6 +1,6 @@ /* arm_startup.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ROWLEY-CROSSWORKS-ARM/benchmark_main.c b/IDE/ROWLEY-CROSSWORKS-ARM/benchmark_main.c index e95059e9ef..94f55bfb52 100644 --- a/IDE/ROWLEY-CROSSWORKS-ARM/benchmark_main.c +++ b/IDE/ROWLEY-CROSSWORKS-ARM/benchmark_main.c @@ -1,6 +1,6 @@ /* benchmark_main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ROWLEY-CROSSWORKS-ARM/kinetis_hw.c b/IDE/ROWLEY-CROSSWORKS-ARM/kinetis_hw.c index 5626126920..ffe76bf1b8 100644 --- a/IDE/ROWLEY-CROSSWORKS-ARM/kinetis_hw.c +++ b/IDE/ROWLEY-CROSSWORKS-ARM/kinetis_hw.c @@ -1,6 +1,6 @@ /* kinetis_hw.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ROWLEY-CROSSWORKS-ARM/retarget.c b/IDE/ROWLEY-CROSSWORKS-ARM/retarget.c index bfd53ff703..752ec6e663 100644 --- a/IDE/ROWLEY-CROSSWORKS-ARM/retarget.c +++ b/IDE/ROWLEY-CROSSWORKS-ARM/retarget.c @@ -1,6 +1,6 @@ /* retarget.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ROWLEY-CROSSWORKS-ARM/test_main.c b/IDE/ROWLEY-CROSSWORKS-ARM/test_main.c index 1f6339d908..062c0982b7 100644 --- a/IDE/ROWLEY-CROSSWORKS-ARM/test_main.c +++ b/IDE/ROWLEY-CROSSWORKS-ARM/test_main.c @@ -1,6 +1,6 @@ /* test_main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/cs+/Projects/common/strings.h b/IDE/Renesas/cs+/Projects/common/strings.h index 030e4ffad0..a66c8bbbf8 100644 --- a/IDE/Renesas/cs+/Projects/common/strings.h +++ b/IDE/Renesas/cs+/Projects/common/strings.h @@ -1,6 +1,6 @@ /* strings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/cs+/Projects/common/unistd.h b/IDE/Renesas/cs+/Projects/common/unistd.h index d288552e6c..12f9374948 100644 --- a/IDE/Renesas/cs+/Projects/common/unistd.h +++ b/IDE/Renesas/cs+/Projects/common/unistd.h @@ -1,6 +1,6 @@ /* unistd.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/cs+/Projects/common/user_settings.h b/IDE/Renesas/cs+/Projects/common/user_settings.h index 5e0d375360..b03faa7681 100644 --- a/IDE/Renesas/cs+/Projects/common/user_settings.h +++ b/IDE/Renesas/cs+/Projects/common/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/cs+/Projects/common/wolfssl_dummy.c b/IDE/Renesas/cs+/Projects/common/wolfssl_dummy.c index 8feffe8f31..3c425b357b 100644 --- a/IDE/Renesas/cs+/Projects/common/wolfssl_dummy.c +++ b/IDE/Renesas/cs+/Projects/common/wolfssl_dummy.c @@ -1,6 +1,6 @@ /* wolfssl_dummy.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/cs+/Projects/t4_demo/wolf_client.c b/IDE/Renesas/cs+/Projects/t4_demo/wolf_client.c index c556f647af..e25b038c9e 100644 --- a/IDE/Renesas/cs+/Projects/t4_demo/wolf_client.c +++ b/IDE/Renesas/cs+/Projects/t4_demo/wolf_client.c @@ -1,6 +1,6 @@ /* wolf_client.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/cs+/Projects/t4_demo/wolf_main.c b/IDE/Renesas/cs+/Projects/t4_demo/wolf_main.c index 3cffc7191c..cd7f74b855 100644 --- a/IDE/Renesas/cs+/Projects/t4_demo/wolf_main.c +++ b/IDE/Renesas/cs+/Projects/t4_demo/wolf_main.c @@ -1,6 +1,6 @@ /* wolf_main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/cs+/Projects/t4_demo/wolf_server.c b/IDE/Renesas/cs+/Projects/t4_demo/wolf_server.c index a86ff18c81..858347170f 100644 --- a/IDE/Renesas/cs+/Projects/t4_demo/wolf_server.c +++ b/IDE/Renesas/cs+/Projects/t4_demo/wolf_server.c @@ -1,6 +1,6 @@ /* wolf_server.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/cs+/Projects/test/test_main.c b/IDE/Renesas/cs+/Projects/test/test_main.c index a1e00ef0af..dcb490acde 100644 --- a/IDE/Renesas/cs+/Projects/test/test_main.c +++ b/IDE/Renesas/cs+/Projects/test/test_main.c @@ -1,6 +1,6 @@ /* test_main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/DK-S7G2/benchmark-template/src/app_entry.c b/IDE/Renesas/e2studio/DK-S7G2/benchmark-template/src/app_entry.c index 705b53fc46..353f906dc0 100644 --- a/IDE/Renesas/e2studio/DK-S7G2/benchmark-template/src/app_entry.c +++ b/IDE/Renesas/e2studio/DK-S7G2/benchmark-template/src/app_entry.c @@ -1,6 +1,6 @@ /* app_entry.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/DK-S7G2/example_server-template/src/app_entry.c b/IDE/Renesas/e2studio/DK-S7G2/example_server-template/src/app_entry.c index ea15ee4f12..c52f8aaf3c 100644 --- a/IDE/Renesas/e2studio/DK-S7G2/example_server-template/src/app_entry.c +++ b/IDE/Renesas/e2studio/DK-S7G2/example_server-template/src/app_entry.c @@ -1,6 +1,6 @@ /* app_entry.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/DK-S7G2/wolfcrypttest-template/src/app_entry.c b/IDE/Renesas/e2studio/DK-S7G2/wolfcrypttest-template/src/app_entry.c index a056213313..9edf7ff84e 100644 --- a/IDE/Renesas/e2studio/DK-S7G2/wolfcrypttest-template/src/app_entry.c +++ b/IDE/Renesas/e2studio/DK-S7G2/wolfcrypttest-template/src/app_entry.c @@ -1,6 +1,6 @@ /* app_entry.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/Projects/common/strings.h b/IDE/Renesas/e2studio/Projects/common/strings.h index 030e4ffad0..a66c8bbbf8 100644 --- a/IDE/Renesas/e2studio/Projects/common/strings.h +++ b/IDE/Renesas/e2studio/Projects/common/strings.h @@ -1,6 +1,6 @@ /* strings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/Projects/common/unistd.h b/IDE/Renesas/e2studio/Projects/common/unistd.h index d288552e6c..12f9374948 100644 --- a/IDE/Renesas/e2studio/Projects/common/unistd.h +++ b/IDE/Renesas/e2studio/Projects/common/unistd.h @@ -1,6 +1,6 @@ /* unistd.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/Projects/common/user_settings.h b/IDE/Renesas/e2studio/Projects/common/user_settings.h index a9cc84ac76..15ebd73b36 100644 --- a/IDE/Renesas/e2studio/Projects/common/user_settings.h +++ b/IDE/Renesas/e2studio/Projects/common/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/Projects/common/wolfssl_dummy.c b/IDE/Renesas/e2studio/Projects/common/wolfssl_dummy.c index b6b21e85bb..bf2006d491 100644 --- a/IDE/Renesas/e2studio/Projects/common/wolfssl_dummy.c +++ b/IDE/Renesas/e2studio/Projects/common/wolfssl_dummy.c @@ -1,6 +1,6 @@ /* wolfssl_dummy.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/Projects/test/src/key_data.c b/IDE/Renesas/e2studio/Projects/test/src/key_data.c index 8d06ccc1dd..d3e7a04164 100644 --- a/IDE/Renesas/e2studio/Projects/test/src/key_data.c +++ b/IDE/Renesas/e2studio/Projects/test/src/key_data.c @@ -1,6 +1,6 @@ /* key_data.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/Projects/test/src/key_data.h b/IDE/Renesas/e2studio/Projects/test/src/key_data.h index 5c58e35298..c9be7039d7 100644 --- a/IDE/Renesas/e2studio/Projects/test/src/key_data.h +++ b/IDE/Renesas/e2studio/Projects/test/src/key_data.h @@ -1,6 +1,6 @@ /* key_data.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/Projects/test/src/test_main.c b/IDE/Renesas/e2studio/Projects/test/src/test_main.c index 5264faef29..3e59160275 100644 --- a/IDE/Renesas/e2studio/Projects/test/src/test_main.c +++ b/IDE/Renesas/e2studio/Projects/test/src/test_main.c @@ -1,6 +1,6 @@ /* test_main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/Projects/test/src/wolf_client.c b/IDE/Renesas/e2studio/Projects/test/src/wolf_client.c index 314243d0ed..7ebbe29234 100644 --- a/IDE/Renesas/e2studio/Projects/test/src/wolf_client.c +++ b/IDE/Renesas/e2studio/Projects/test/src/wolf_client.c @@ -1,6 +1,6 @@ /* wolf_client.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/Projects/test/src/wolf_server.c b/IDE/Renesas/e2studio/Projects/test/src/wolf_server.c index 6454017771..206e91d778 100644 --- a/IDE/Renesas/e2studio/Projects/test/src/wolf_server.c +++ b/IDE/Renesas/e2studio/Projects/test/src/wolf_server.c @@ -1,6 +1,6 @@ /* wolf_server.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/Projects/test/src/wolfssl_demo.h b/IDE/Renesas/e2studio/Projects/test/src/wolfssl_demo.h index 385a5d7bd4..2168ad0a05 100644 --- a/IDE/Renesas/e2studio/Projects/test/src/wolfssl_demo.h +++ b/IDE/Renesas/e2studio/Projects/test/src/wolfssl_demo.h @@ -1,6 +1,6 @@ /* wolfssl_demo.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M3/benchmark-wolfcrypt/src/wolfssl_thread_entry.c b/IDE/Renesas/e2studio/RA6M3/benchmark-wolfcrypt/src/wolfssl_thread_entry.c index 0a850be473..cf7f270612 100644 --- a/IDE/Renesas/e2studio/RA6M3/benchmark-wolfcrypt/src/wolfssl_thread_entry.c +++ b/IDE/Renesas/e2studio/RA6M3/benchmark-wolfcrypt/src/wolfssl_thread_entry.c @@ -1,6 +1,6 @@ /* wolfssl_thread_entry.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M3/client-wolfssl/src/wolfssl_thread_entry.c b/IDE/Renesas/e2studio/RA6M3/client-wolfssl/src/wolfssl_thread_entry.c index 5bc8e55ece..5ba72ce492 100644 --- a/IDE/Renesas/e2studio/RA6M3/client-wolfssl/src/wolfssl_thread_entry.c +++ b/IDE/Renesas/e2studio/RA6M3/client-wolfssl/src/wolfssl_thread_entry.c @@ -1,6 +1,6 @@ /* wolfssl_thread_entry.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M3/client-wolfssl/wolfssl_thread_entry.h b/IDE/Renesas/e2studio/RA6M3/client-wolfssl/wolfssl_thread_entry.h index 701e4bd4bb..d1f7e0f8cc 100644 --- a/IDE/Renesas/e2studio/RA6M3/client-wolfssl/wolfssl_thread_entry.h +++ b/IDE/Renesas/e2studio/RA6M3/client-wolfssl/wolfssl_thread_entry.h @@ -1,6 +1,6 @@ /* wolfssl_thread_entry.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M3/common/src/freertos_tcp_port.c b/IDE/Renesas/e2studio/RA6M3/common/src/freertos_tcp_port.c index c45d550417..faf154dc13 100644 --- a/IDE/Renesas/e2studio/RA6M3/common/src/freertos_tcp_port.c +++ b/IDE/Renesas/e2studio/RA6M3/common/src/freertos_tcp_port.c @@ -1,6 +1,6 @@ /* freertos_tcp_port.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M3/common/user_settings.h b/IDE/Renesas/e2studio/RA6M3/common/user_settings.h index 78f7cf86a8..f0d66117f2 100644 --- a/IDE/Renesas/e2studio/RA6M3/common/user_settings.h +++ b/IDE/Renesas/e2studio/RA6M3/common/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M3/common/util.h b/IDE/Renesas/e2studio/RA6M3/common/util.h index 036d4627d0..57eaf767b7 100644 --- a/IDE/Renesas/e2studio/RA6M3/common/util.h +++ b/IDE/Renesas/e2studio/RA6M3/common/util.h @@ -1,6 +1,6 @@ /* util.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M3/server-wolfssl/src/wolfssl_thread_entry.c b/IDE/Renesas/e2studio/RA6M3/server-wolfssl/src/wolfssl_thread_entry.c index 03179846ba..47808cb423 100644 --- a/IDE/Renesas/e2studio/RA6M3/server-wolfssl/src/wolfssl_thread_entry.c +++ b/IDE/Renesas/e2studio/RA6M3/server-wolfssl/src/wolfssl_thread_entry.c @@ -1,6 +1,6 @@ /* wolfssl_thread_entry.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M3/server-wolfssl/wolfssl_thread_entry.h b/IDE/Renesas/e2studio/RA6M3/server-wolfssl/wolfssl_thread_entry.h index 0907433e6d..7720180f1b 100644 --- a/IDE/Renesas/e2studio/RA6M3/server-wolfssl/wolfssl_thread_entry.h +++ b/IDE/Renesas/e2studio/RA6M3/server-wolfssl/wolfssl_thread_entry.h @@ -1,6 +1,6 @@ /* wolfssl_thread_entry.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M3/test-wolfcrypt/src/wolfssl_thread_entry.c b/IDE/Renesas/e2studio/RA6M3/test-wolfcrypt/src/wolfssl_thread_entry.c index e7e4cb6ffe..454f5744a5 100644 --- a/IDE/Renesas/e2studio/RA6M3/test-wolfcrypt/src/wolfssl_thread_entry.c +++ b/IDE/Renesas/e2studio/RA6M3/test-wolfcrypt/src/wolfssl_thread_entry.c @@ -1,6 +1,6 @@ /* wolfssl_thread_entry.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M4/common/user_settings.h b/IDE/Renesas/e2studio/RA6M4/common/user_settings.h index 485415317c..6f40f37f22 100644 --- a/IDE/Renesas/e2studio/RA6M4/common/user_settings.h +++ b/IDE/Renesas/e2studio/RA6M4/common/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M4/common/wolfssl_demo.h b/IDE/Renesas/e2studio/RA6M4/common/wolfssl_demo.h index dd56fc1e7f..cbe535b2ab 100644 --- a/IDE/Renesas/e2studio/RA6M4/common/wolfssl_demo.h +++ b/IDE/Renesas/e2studio/RA6M4/common/wolfssl_demo.h @@ -1,6 +1,6 @@ /* wolfssl_demo.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M4/test/key_data/key_data_sce.c b/IDE/Renesas/e2studio/RA6M4/test/key_data/key_data_sce.c index 41fb29c07a..aec582f1ac 100644 --- a/IDE/Renesas/e2studio/RA6M4/test/key_data/key_data_sce.c +++ b/IDE/Renesas/e2studio/RA6M4/test/key_data/key_data_sce.c @@ -1,6 +1,6 @@ /* key_data.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M4/test/src/SEGGER_RTT/myprint.c b/IDE/Renesas/e2studio/RA6M4/test/src/SEGGER_RTT/myprint.c index 4ff71d1548..eb025be711 100644 --- a/IDE/Renesas/e2studio/RA6M4/test/src/SEGGER_RTT/myprint.c +++ b/IDE/Renesas/e2studio/RA6M4/test/src/SEGGER_RTT/myprint.c @@ -1,6 +1,6 @@ /* myprintf.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M4/test/src/test_main.c b/IDE/Renesas/e2studio/RA6M4/test/src/test_main.c index e6dca444c7..172e484c4c 100644 --- a/IDE/Renesas/e2studio/RA6M4/test/src/test_main.c +++ b/IDE/Renesas/e2studio/RA6M4/test/src/test_main.c @@ -1,6 +1,6 @@ /* test_main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M4/test/src/wolf_client.c b/IDE/Renesas/e2studio/RA6M4/test/src/wolf_client.c index 5a920a250e..10f3a31cb6 100644 --- a/IDE/Renesas/e2studio/RA6M4/test/src/wolf_client.c +++ b/IDE/Renesas/e2studio/RA6M4/test/src/wolf_client.c @@ -1,6 +1,6 @@ /* wolf_client.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M4/test/src/wolfssl_sce_unit_test.c b/IDE/Renesas/e2studio/RA6M4/test/src/wolfssl_sce_unit_test.c index f3cef8ffc7..cf62b19dfa 100644 --- a/IDE/Renesas/e2studio/RA6M4/test/src/wolfssl_sce_unit_test.c +++ b/IDE/Renesas/e2studio/RA6M4/test/src/wolfssl_sce_unit_test.c @@ -1,6 +1,6 @@ /* wolfssl_sce_unit_test.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/strings.h b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/strings.h index 030e4ffad0..a66c8bbbf8 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/strings.h +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/strings.h @@ -1,6 +1,6 @@ /* strings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/unistd.h b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/unistd.h index d288552e6c..12f9374948 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/unistd.h +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/unistd.h @@ -1,6 +1,6 @@ /* unistd.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h index fa80de8404..043c031933 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c index 251d6481b6..db2911cf3a 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c @@ -1,6 +1,6 @@ /* wolfssl_dummy.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/key_data.c b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/key_data.c index dcc59aac32..951e76e921 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/key_data.c +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/key_data.c @@ -1,6 +1,6 @@ /* key_data.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/key_data.h b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/key_data.h index 2d6bead068..80df72cb31 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/key_data.h +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/key_data.h @@ -1,6 +1,6 @@ /* key_data.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/test_main.c b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/test_main.c index 733da69714..8c79e8d409 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/test_main.c +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/test_main.c @@ -1,6 +1,6 @@ /* test_main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_client.c b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_client.c index 437ce74775..4506a6d4bc 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_client.c +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_client.c @@ -1,6 +1,6 @@ /* wolf_client.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_server.c b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_server.c index 52ad49bba5..2e7e357955 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_server.c +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_server.c @@ -1,6 +1,6 @@ /* wolf_server.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolfssl_demo.h b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolfssl_demo.h index 5f0a537d30..9558d8f12b 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolfssl_demo.h +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolfssl_demo.h @@ -1,6 +1,6 @@ /* wolfssl_demo.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/key_data.c b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/key_data.c index 29d0adcbd5..4d176ccaa7 100644 --- a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/key_data.c +++ b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/key_data.c @@ -1,6 +1,6 @@ /* key_data.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/key_data.h b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/key_data.h index 2d6bead068..80df72cb31 100644 --- a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/key_data.h +++ b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/key_data.h @@ -1,6 +1,6 @@ /* key_data.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/user_settings.h b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/user_settings.h index f856d4e5e6..174826f0ee 100644 --- a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/user_settings.h +++ b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.c b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.c index 5614f3f1f2..010c38137a 100644 --- a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.c +++ b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.c @@ -1,6 +1,6 @@ /* wolfssl_demo.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.h b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.h index 6eb3b9641a..cb916e6536 100644 --- a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.h +++ b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.h @@ -1,6 +1,6 @@ /* wolfssl_demo.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/common/wolfssl_dummy.c b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/common/wolfssl_dummy.c index 2c48ed510c..3e4c1e56ea 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/common/wolfssl_dummy.c +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/common/wolfssl_dummy.c @@ -1,6 +1,6 @@ /* wolfssl_dummy.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -21,8 +21,8 @@ #include -#define YEAR 2023 -#define MON 5 +#define YEAR 2024 +#define MON 7 static int tick = 0; diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/client/simple_tcp_client.c b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/client/simple_tcp_client.c index eaeb627405..b45157faa0 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/client/simple_tcp_client.c +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/client/simple_tcp_client.c @@ -1,6 +1,6 @@ /* simple_tcp_client.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/client/simple_tls_tsip_client.c b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/client/simple_tls_tsip_client.c index 452d0ac747..62c426ca08 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/client/simple_tls_tsip_client.c +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/client/simple_tls_tsip_client.c @@ -1,6 +1,6 @@ /* simpel_tls_tsip_client.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -31,7 +31,7 @@ #include #endif -#define SIMPLE_TLSSEVER_IP "192.168.11.9" +#define SIMPLE_TLSSEVER_IP "192.168.11.5" #define SIMPLE_TLSSERVER_PORT "11111" ER t4_tcp_callback(ID cepid, FN fncd , VP p_parblk); @@ -198,7 +198,7 @@ void wolfSSL_TLS_client( ) { ID cepid = 1; ER ercd; - int ret; + int ret = 0; WOLFSSL_CTX *ctx = (WOLFSSL_CTX *)client_ctx; WOLFSSL *ssl = NULL; @@ -231,44 +231,95 @@ void wolfSSL_TLS_client( ) } #ifdef SIMPLE_TLS_TSIP_CLIENT - tsip_set_callback_ctx(ssl, &userContext); + ret = tsip_set_callback_ctx(ssl, &userContext); #endif /* set client private key data */ -#if defined(WOLFSSL_TLS13) && defined(SIMPLE_TLS_TSIP_CLIENT) - #if defined(USE_ECC_CERT) - if (tsip_use_PrivateKey_buffer_TLS(ssl, - (const char*)g_key_block_data.encrypted_user_ecc256_private_key, +#ifdef USE_ECC_CERT + + #ifdef WOLFSSL_RENESAS_TSIP_TLS + + /* TSIP specific ECC private key */ + if (ret == 0){ + ret = tsip_use_PrivateKey_buffer_TLS(ssl, + (const char*)g_key_block_data.encrypted_user_ecc256_private_key, sizeof(g_key_block_data.encrypted_user_ecc256_private_key), - TSIP_ECCP256) != 0) { - printf("ERROR: can't load client-private key\n"); - return; + TSIP_ECCP256); + if (ret != 0) { + printf("ERROR tsip_use_PrivateKey_buffer_TLS\n"); + } + } + # if defined(WOLFSSL_CHECK_SIG_FAULTS) + if (ret == 0){ + ret = tsip_use_PublicKey_buffer_TLS(ssl, + (const char*)g_key_block_data.encrypted_user_ecc256_public_key, + sizeof(g_key_block_data.encrypted_user_ecc256_public_key), + TSIP_ECCP256); + if (ret != 0) { + printf("ERROR tsip_use_PublicKey_buffer_TLS\n"); } + } + #endif /* WOLFSSL_CHECK_SIG_FAULTS */ + #else - if (tsip_use_PrivateKey_buffer_TLS(ssl, + + /* DER format ECC private key */ + if (ret == 0) { + ret = wolfSSL_use_PrivateKey_buffer(ssl, + ecc_clikey_der_256, + sizeof_ecc_clikey_der_256, + WOLFSSL_FILETYPE_ASN1); + if (ret != SSL_SUCCESS) { + printf("ERROR wolfSSL_use_PrivateKey_buffer: %d\n", + wolfSSL_get_error(ssl, 0)); + ret = -1; + } + } + + #endif /* WOLFSSL_RENESAS_TSIP_TLS */ + +#else + + #if defined(WOLFSSL_RENESAS_TSIP_TLS) + + /* Note: TSIP asks RSA client key pair for client authentication. */ + + /* TSIP specific RSA private key */ + if (ret == 0) { + ret = tsip_use_PrivateKey_buffer_TLS(ssl, (const char*)g_key_block_data.encrypted_user_rsa2048_private_key, sizeof(g_key_block_data.encrypted_user_rsa2048_private_key), - TSIP_RSA2048) != 0) { - printf("ERROR: can't load client-private key\n"); - return; + TSIP_RSA2048); + if (ret != 0) { + printf("ERROR tsip_use_PrivateKey_buffer_TLS :%d\n", ret); } + } + if (ret == 0) { ret = tsip_use_PublicKey_buffer_TLS(ssl, (const char*)g_key_block_data.encrypted_user_rsa2048_public_key, - sizeof(g_key_block_data.encrypted_user_rsa2048_public_key), TSIP_RSA2048); + sizeof(g_key_block_data.encrypted_user_rsa2048_public_key), + TSIP_RSA2048); if (ret != 0) { - printf("ERROR tsip_use_PublicKey_buffer: %d\n", ret); - return; + printf("ERROR tsip_use_PublicKey_buffer_TLS: %d\n", ret); } - #endif -#else - if (wolfSSL_use_PrivateKey_buffer(ssl, - ecc_clikey_der_256, - sizeof_ecc_clikey_der_256, - SSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) { - printf("ERROR: can't load private-key data.\n"); - return; } -#endif /* WOLFSSL_TLS13 */ + + #else + + if (ret == 0) { + err = wolfSSL_use_PrivateKey_buffer(ssl, client_key_der_2048, + sizeof_client_key_der_2048, WOLFSSL_FILETYPE_ASN1); + + if (err != SSL_SUCCESS) { + printf("ERROR wolfSSL_use_PrivateKey_buffer: %d\n", + wolfSSL_get_error(ssl, 0)); + ret = -1; + } + } + + #endif /* WOLFSSL_RENESAS_TSIP_TLS */ + +#endif /* USE_ECC_CERT */ /* set callback context */ wolfSSL_SetIOReadCtx(ssl, (void *)&cepid); diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/server/simple_tcp_server.c b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/server/simple_tcp_server.c index dfa4858916..1a096d37f6 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/server/simple_tcp_server.c +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/server/simple_tcp_server.c @@ -1,6 +1,6 @@ /* simple_tcp_server.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/server/simple_tls_server.c b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/server/simple_tls_server.c index d5138b0ea6..55892f491e 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/server/simple_tls_server.c +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/server/simple_tls_server.c @@ -1,6 +1,6 @@ /* simple_tls_server.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/test_main.c b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/test_main.c index 42d62359ff..2fb3d2489c 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/test_main.c +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/test_main.c @@ -1,6 +1,6 @@ /* test_main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/wolfssl_simple_demo.h b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/wolfssl_simple_demo.h index c62cd4a38d..d8e035d8df 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/wolfssl_simple_demo.h +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/wolfssl_simple_demo.h @@ -1,6 +1,6 @@ /* wolfssl_simple_demo.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/key_data.c b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/key_data.c index fe3aaaaf01..8ee29ee301 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/key_data.c +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/key_data.c @@ -1,6 +1,6 @@ /* key_data.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -31,43 +31,43 @@ const st_key_block_data_t g_key_block_data = { /* uint8_t encrypted_provisioning_key[R_TSIP_AES_CBC_IV_BYTE_SIZE * 2]; */ { - 0xDF, 0x78, 0x49, 0x28, 0xA9, 0x4C, 0x36, 0xD6, 0xC9, 0x89, 0x98, 0xDF, - 0xFF, 0xB1, 0xCB, 0xBC, 0x9F, 0xF4, 0x34, 0xCD, 0x81, 0x53, 0x67, 0xB3, - 0xFC, 0x85, 0xC6, 0x0B, 0xA2, 0xC8, 0xF4, 0x83 + 0x68, 0x03, 0xA1, 0x95, 0x3B, 0x93, 0x12, 0xCC, 0x86, 0x5A, 0x3E, 0x24, + 0xF7, 0xDD, 0x22, 0x31, 0xEC, 0xAB, 0x42, 0x8B, 0x90, 0xC2, 0x8E, 0xDF, + 0x56, 0xB3, 0xAE, 0x3A, 0x99, 0x05, 0x34, 0xCD }, /* uint8_t iv[R_TSIP_AES_CBC_IV_BYTE_SIZE]; */ { - 0xF6, 0xA9, 0x83, 0x5A, 0xA1, 0x65, 0x1D, 0x28, 0xC8, 0x1A, 0xA6, 0x9D, - 0x34, 0xB2, 0x4D, 0x92 + 0x01, 0x23, 0x45, 0x67, 0x89, 0x01, 0x23, 0x45, 0x67, 0x89, 0x01, 0x23, + 0x45, 0x67, 0x89, 0x01 }, - /* uint8_t + /* uint8_t * encrypted_user_rsa2048_ne_key[R_TSIP_RSA2048_NE_KEY_BYTE_SIZE + 16]; */ { - 0xC8, 0x12, 0x94, 0x44, 0x43, 0x35, 0x82, 0x09, 0xF2, 0x54, 0x69, 0xB6, - 0x9B, 0x8E, 0x6F, 0x92, 0xE3, 0x3A, 0xB2, 0x55, 0x63, 0x8D, 0xDB, 0x47, - 0x75, 0x8D, 0x9D, 0x56, 0xD7, 0x7F, 0x42, 0x3A, 0x04, 0x4C, 0xAA, 0xF1, - 0x94, 0x9C, 0x8C, 0x97, 0xAF, 0x5C, 0xBA, 0x0E, 0xBD, 0x8A, 0xE3, 0x67, - 0x3E, 0xF8, 0x4C, 0x8E, 0xB7, 0x71, 0xB0, 0xCE, 0x09, 0x3C, 0xEC, 0x9C, - 0xCC, 0x81, 0x9D, 0x37, 0x9E, 0x34, 0x39, 0x6D, 0xF0, 0x7D, 0x1A, 0x4A, - 0xEB, 0xF5, 0x99, 0x91, 0xE1, 0xB0, 0x99, 0x72, 0xB3, 0xF3, 0x2B, 0xE1, - 0x6F, 0x5B, 0xD4, 0xA3, 0xB9, 0x9C, 0xEB, 0x95, 0xC3, 0xB2, 0x8F, 0x5C, - 0x58, 0xD5, 0x0A, 0xAA, 0x02, 0x01, 0xBF, 0xE1, 0xE9, 0x23, 0xFB, 0x03, - 0xCF, 0x54, 0x6D, 0x29, 0xE7, 0x5E, 0x96, 0x51, 0x68, 0x6B, 0xDD, 0x06, - 0x67, 0x5E, 0x84, 0x50, 0x21, 0x50, 0x78, 0x89, 0x80, 0xF8, 0x61, 0x9C, - 0xBE, 0xDA, 0x75, 0x55, 0x1A, 0xE6, 0x3C, 0xA5, 0x1C, 0xE4, 0x5A, 0x5C, - 0x68, 0x7C, 0x48, 0xC7, 0x6A, 0xC9, 0x80, 0x54, 0x31, 0xE7, 0x65, 0x8A, - 0x13, 0xF3, 0x6D, 0x0F, 0xB3, 0x62, 0x8D, 0x1B, 0xEA, 0x71, 0x12, 0x86, - 0x50, 0x98, 0xA3, 0x8E, 0x64, 0x1D, 0x3E, 0xA4, 0x5A, 0x99, 0xB3, 0xBD, - 0x3E, 0x3D, 0xF5, 0x0F, 0x41, 0x09, 0xFB, 0x04, 0x7B, 0x8D, 0xA1, 0xCF, - 0xBA, 0x71, 0x85, 0x86, 0x3C, 0x04, 0xDD, 0x74, 0x8D, 0xE3, 0x3C, 0x8E, - 0x52, 0x3C, 0x05, 0x7A, 0xBE, 0xCC, 0xEA, 0x9D, 0x57, 0x2C, 0x40, 0x05, - 0xEE, 0x49, 0x1D, 0xD2, 0xA3, 0x5A, 0xFA, 0x25, 0x1D, 0x1F, 0xDD, 0xB5, - 0x36, 0x7D, 0x25, 0xD3, 0x34, 0x39, 0xC2, 0x59, 0x57, 0xAD, 0x3C, 0x9D, - 0xC9, 0xBF, 0x09, 0x8D, 0xA0, 0x40, 0x5A, 0x14, 0x7B, 0xCF, 0xFE, 0x05, - 0x3E, 0xF3, 0xD1, 0x7D, 0xBB, 0x33, 0x96, 0x40, 0x79, 0xC2, 0x7B, 0x15, - 0x2E, 0xEE, 0xE3, 0x5B, 0x9C, 0x06, 0x72, 0x95, 0xFF, 0xCB, 0xC9, 0xE4, - 0x96, 0x97, 0x18, 0x0D, 0xE7, 0x78, 0xCD, 0xE9, 0xA7, 0xEA, 0xE9, 0xDF + 0x8F, 0xCE, 0xBA, 0x0C, 0xF6, 0x6F, 0x65, 0x7F, 0xF7, 0xB7, 0x31, 0x11, + 0x20, 0x17, 0x7D, 0x8F, 0x5B, 0xA4, 0x43, 0x4F, 0x0A, 0x7C, 0x64, 0x24, + 0x57, 0x03, 0xEB, 0xBB, 0xDD, 0xF4, 0x60, 0x1E, 0x30, 0x97, 0xB1, 0xC7, + 0xFA, 0xEF, 0x5D, 0x16, 0x93, 0x16, 0xD6, 0x24, 0xA8, 0xC3, 0xCA, 0x7C, + 0xF4, 0x00, 0x77, 0x0E, 0x62, 0xB1, 0x7E, 0x8E, 0x57, 0x19, 0x91, 0xEC, + 0x47, 0xE1, 0x81, 0x6F, 0x79, 0x43, 0x51, 0xB9, 0x0A, 0x3F, 0x6B, 0x38, + 0x9A, 0xB6, 0x2F, 0x97, 0x59, 0xA2, 0x7C, 0x6B, 0xBD, 0x8A, 0xCC, 0x52, + 0x37, 0x2A, 0x22, 0xC9, 0x60, 0xB8, 0x99, 0x17, 0x2D, 0x94, 0x8B, 0x02, + 0x51, 0xAB, 0xD2, 0x09, 0xEE, 0x08, 0x92, 0x19, 0x68, 0x0F, 0xBB, 0xEE, + 0x0F, 0xFF, 0xAF, 0x7F, 0x08, 0x55, 0x81, 0xE6, 0x12, 0x34, 0x12, 0xBD, + 0x2C, 0x8E, 0x8E, 0x9D, 0xC3, 0x34, 0x47, 0xF0, 0xF6, 0x01, 0x24, 0x05, + 0x3D, 0x2E, 0x2E, 0x3E, 0x9C, 0x19, 0x8C, 0x99, 0x19, 0x06, 0x93, 0xD0, + 0x14, 0x78, 0x89, 0x37, 0x2B, 0xA2, 0xD0, 0xBE, 0x67, 0x7C, 0xC6, 0xB3, + 0x61, 0x85, 0xF9, 0x4E, 0xC7, 0x33, 0x00, 0x45, 0x34, 0x1B, 0x3F, 0xD9, + 0xF1, 0xA4, 0x4B, 0x82, 0x34, 0x69, 0xF0, 0xE5, 0x4D, 0xCF, 0xC7, 0xAD, + 0xD9, 0xF7, 0x86, 0x84, 0x1A, 0x5B, 0x7D, 0xBA, 0x7B, 0xC1, 0xF8, 0xB0, + 0xE4, 0xAB, 0xA3, 0x05, 0xE0, 0xF0, 0x14, 0xDE, 0x8D, 0x7A, 0x98, 0xCA, + 0x02, 0xDE, 0x02, 0xB6, 0xCC, 0xE4, 0xF9, 0x84, 0x1A, 0x1D, 0x5E, 0x00, + 0x64, 0x80, 0x4F, 0x65, 0xDE, 0x48, 0x5D, 0x5C, 0x5C, 0x4B, 0x00, 0xD3, + 0x03, 0xF0, 0x77, 0xB2, 0x8F, 0x2A, 0xFE, 0x38, 0x73, 0x2D, 0xFE, 0xDC, + 0x18, 0xE0, 0x9A, 0xAC, 0x1D, 0x09, 0x41, 0x38, 0x99, 0x4C, 0xA6, 0x0E, + 0x0F, 0xB4, 0xC0, 0x59, 0x38, 0x31, 0xC7, 0x69, 0x8A, 0x6A, 0x94, 0x8E, + 0xEE, 0x38, 0x63, 0x2C, 0x4C, 0x0C, 0x65, 0x3F, 0xC6, 0xA2, 0x91, 0x48, + 0x0A, 0xE2, 0x09, 0x50, 0x8F, 0x9E, 0x91, 0xF8, 0xAC, 0x3B, 0xDA, 0xBA }, /* uint8_t encrypted_user_update_key[R_TSIP_AES256_KEY_BYTE_SIZE + 16]; */ { @@ -77,100 +77,100 @@ const st_key_block_data_t g_key_block_data = * encrypted_user_rsa2048_public_key[R_TSIP_RSA2048_NE_KEY_BYTE_SIZE + 16] */ { - 0xAF, 0x8C, 0x78, 0xE3, 0x6C, 0x9E, 0xC6, 0x76, 0xE5, 0x86, 0x84, 0xBE, - 0xF5, 0x6C, 0xD7, 0x2B, 0x46, 0x24, 0x35, 0x99, 0xA5, 0x64, 0xDD, 0xFA, - 0x35, 0x22, 0x5A, 0xB8, 0x5F, 0xD8, 0x1E, 0xCF, 0xCC, 0x73, 0x10, 0xD6, - 0x13, 0x69, 0x8F, 0x36, 0xA9, 0x8E, 0x09, 0xDF, 0x83, 0x20, 0x85, 0xBE, - 0x81, 0x69, 0x51, 0x75, 0xCB, 0xA5, 0x90, 0x8C, 0xC1, 0x75, 0xBE, 0x0F, - 0x8C, 0xB6, 0xFE, 0x73, 0x03, 0x37, 0x03, 0x41, 0xC0, 0x98, 0xC2, 0xEE, - 0x2D, 0x1B, 0xDA, 0x10, 0x8B, 0xF6, 0xB6, 0x67, 0xE9, 0x29, 0xCD, 0xEC, - 0x4C, 0x4D, 0x84, 0x28, 0x61, 0x3A, 0xF5, 0x6D, 0xEE, 0x78, 0x45, 0xF3, - 0x17, 0xC9, 0x77, 0xAB, 0x56, 0x2C, 0x68, 0xCB, 0x14, 0x9F, 0x5A, 0xE7, - 0x11, 0xC7, 0x13, 0x4B, 0xDC, 0x31, 0x60, 0x77, 0xDA, 0x56, 0x0C, 0x15, - 0xB2, 0xA9, 0x73, 0x4C, 0xD3, 0x46, 0x29, 0x18, 0x1C, 0x8C, 0xFD, 0xCF, - 0xAC, 0x4B, 0x55, 0x30, 0x96, 0xDC, 0xE9, 0xC0, 0x6A, 0x74, 0x68, 0x1D, - 0x6B, 0x25, 0xB0, 0x8F, 0x0C, 0xD7, 0xDD, 0xFC, 0xA8, 0x15, 0x87, 0x3E, - 0xA3, 0x91, 0x46, 0x25, 0x6C, 0x6F, 0xC4, 0xB2, 0xE1, 0xB8, 0x5F, 0xF3, - 0x6A, 0x0D, 0x9C, 0x29, 0x08, 0x6F, 0x5E, 0xFF, 0xA0, 0x81, 0x34, 0xA5, - 0x2B, 0x2B, 0x47, 0xE0, 0x6D, 0x56, 0xD2, 0x52, 0xC7, 0x19, 0x63, 0x72, - 0x84, 0x96, 0x64, 0xA5, 0xF2, 0x92, 0x3C, 0x38, 0x37, 0x9F, 0x6A, 0x2D, - 0x58, 0x33, 0x8C, 0x5C, 0x27, 0x05, 0xCB, 0x4F, 0x62, 0x2F, 0x40, 0xE9, - 0x55, 0x2C, 0x75, 0x4B, 0x02, 0xB3, 0x61, 0xAD, 0x34, 0x14, 0x49, 0x26, - 0x94, 0x45, 0x9B, 0xB8, 0xDB, 0x1F, 0xCE, 0xE9, 0xB1, 0xBF, 0x47, 0xF3, - 0xD4, 0xAD, 0xEB, 0xBC, 0x4F, 0x61, 0xAD, 0x66, 0xAF, 0x10, 0x94, 0x5D, - 0x25, 0x5B, 0x52, 0xF3, 0xBC, 0xCE, 0x10, 0x77, 0x76, 0xE4, 0x5C, 0xCF, - 0xC3, 0xA4, 0xCC, 0x11, 0xD3, 0x1E, 0x02, 0x98, 0x33, 0xA5, 0xF7, 0xD9, - 0x43, 0xAB, 0x45, 0x9A, 0x97, 0x0D, 0x08, 0x03, 0xBD, 0xB2, 0xAB, 0x50 - }, - /* uint8_t + 0x7B, 0x9E, 0xC9, 0x21, 0x70, 0xDF, 0xC0, 0x9E, 0x06, 0x57, 0xB8, 0x44, + 0xD0, 0x95, 0x21, 0xD0, 0x37, 0xDC, 0xAE, 0x3A, 0xAF, 0xCD, 0x56, 0x51, + 0x3C, 0xEC, 0x82, 0xB1, 0xFE, 0xBF, 0x6E, 0x12, 0xE7, 0x79, 0x92, 0xF0, + 0x3F, 0x56, 0x8A, 0x46, 0x0E, 0x4D, 0x9D, 0xC9, 0x7D, 0xC9, 0x2D, 0xE9, + 0x07, 0x1C, 0x9A, 0x11, 0x2F, 0x92, 0x26, 0x40, 0xD7, 0x73, 0xC8, 0xB9, + 0xD0, 0xB8, 0x46, 0x42, 0x53, 0x23, 0x79, 0xBB, 0x3B, 0x97, 0x91, 0x11, + 0x70, 0x66, 0xB6, 0xF4, 0x7B, 0x2F, 0x65, 0x3C, 0xA0, 0xD0, 0x70, 0x58, + 0x3C, 0xA8, 0xD9, 0x79, 0x79, 0x14, 0x55, 0xA4, 0x73, 0xE3, 0x40, 0xBB, + 0xC7, 0x57, 0x5C, 0x30, 0x9C, 0xC5, 0xB5, 0x9D, 0x87, 0xFB, 0x6E, 0x66, + 0x9C, 0x77, 0xF8, 0x41, 0x75, 0x80, 0x30, 0x62, 0xD5, 0x20, 0xBA, 0xB4, + 0x5D, 0x33, 0x8F, 0xC1, 0x5F, 0x22, 0xF1, 0xD8, 0x09, 0x62, 0xA6, 0xE1, + 0x73, 0x50, 0x5B, 0x9B, 0xD7, 0x21, 0x8F, 0x38, 0x31, 0x5B, 0x79, 0x1D, + 0xF8, 0x50, 0xE0, 0x87, 0xC1, 0x6B, 0xC4, 0x4D, 0x25, 0x6C, 0xB2, 0x0B, + 0x88, 0x51, 0xB9, 0xB0, 0xDF, 0xC2, 0x6C, 0xC6, 0x52, 0xB8, 0x88, 0xC0, + 0x25, 0x31, 0x99, 0x61, 0xCA, 0x0F, 0xCB, 0x63, 0x9A, 0x90, 0xE3, 0xB3, + 0x11, 0xFD, 0xAB, 0x1F, 0x4C, 0x6B, 0xC5, 0x5C, 0x86, 0x29, 0x4C, 0x84, + 0xC8, 0xE9, 0x5A, 0xCE, 0xE6, 0x3F, 0x79, 0xD2, 0xDC, 0x6A, 0xDD, 0x5F, + 0x42, 0x45, 0x62, 0xB9, 0xE7, 0x64, 0x88, 0x2F, 0x70, 0x45, 0x1E, 0x9E, + 0xCF, 0x9A, 0x4C, 0x2A, 0x3D, 0x1C, 0x6C, 0x2F, 0x94, 0x27, 0xD4, 0x2A, + 0xE5, 0x55, 0xA5, 0x73, 0xB8, 0x74, 0x29, 0x74, 0xD6, 0xF4, 0x6C, 0xB7, + 0x6C, 0x9D, 0x26, 0x6D, 0x2E, 0xBF, 0x99, 0xCA, 0xDD, 0xEB, 0x48, 0xAD, + 0x71, 0xB1, 0x1B, 0x1E, 0xFB, 0xDE, 0x19, 0xB8, 0x11, 0x61, 0x09, 0xA2, + 0x89, 0x66, 0xE3, 0xA6, 0x3D, 0x7F, 0xFE, 0xFF, 0xE8, 0x1B, 0xD3, 0x2D, + 0xEA, 0xA5, 0x86, 0xCF, 0x96, 0xDE, 0xDE, 0xC1, 0x17, 0x96, 0x77, 0x41 + }, + /* uint8_t * encrypted_user_rsa2048_private_key[R_TSIP_RSA2048_ND_KEY_BYTE_SIZE + 16] */ { - 0xAF, 0x8C, 0x78, 0xE3, 0x6C, 0x9E, 0xC6, 0x76, 0xE5, 0x86, 0x84, 0xBE, - 0xF5, 0x6C, 0xD7, 0x2B, 0x46, 0x24, 0x35, 0x99, 0xA5, 0x64, 0xDD, 0xFA, - 0x35, 0x22, 0x5A, 0xB8, 0x5F, 0xD8, 0x1E, 0xCF, 0xCC, 0x73, 0x10, 0xD6, - 0x13, 0x69, 0x8F, 0x36, 0xA9, 0x8E, 0x09, 0xDF, 0x83, 0x20, 0x85, 0xBE, - 0x81, 0x69, 0x51, 0x75, 0xCB, 0xA5, 0x90, 0x8C, 0xC1, 0x75, 0xBE, 0x0F, - 0x8C, 0xB6, 0xFE, 0x73, 0x03, 0x37, 0x03, 0x41, 0xC0, 0x98, 0xC2, 0xEE, - 0x2D, 0x1B, 0xDA, 0x10, 0x8B, 0xF6, 0xB6, 0x67, 0xE9, 0x29, 0xCD, 0xEC, - 0x4C, 0x4D, 0x84, 0x28, 0x61, 0x3A, 0xF5, 0x6D, 0xEE, 0x78, 0x45, 0xF3, - 0x17, 0xC9, 0x77, 0xAB, 0x56, 0x2C, 0x68, 0xCB, 0x14, 0x9F, 0x5A, 0xE7, - 0x11, 0xC7, 0x13, 0x4B, 0xDC, 0x31, 0x60, 0x77, 0xDA, 0x56, 0x0C, 0x15, - 0xB2, 0xA9, 0x73, 0x4C, 0xD3, 0x46, 0x29, 0x18, 0x1C, 0x8C, 0xFD, 0xCF, - 0xAC, 0x4B, 0x55, 0x30, 0x96, 0xDC, 0xE9, 0xC0, 0x6A, 0x74, 0x68, 0x1D, - 0x6B, 0x25, 0xB0, 0x8F, 0x0C, 0xD7, 0xDD, 0xFC, 0xA8, 0x15, 0x87, 0x3E, - 0xA3, 0x91, 0x46, 0x25, 0x6C, 0x6F, 0xC4, 0xB2, 0xE1, 0xB8, 0x5F, 0xF3, - 0x6A, 0x0D, 0x9C, 0x29, 0x08, 0x6F, 0x5E, 0xFF, 0xA0, 0x81, 0x34, 0xA5, - 0x2B, 0x2B, 0x47, 0xE0, 0x6D, 0x56, 0xD2, 0x52, 0xC7, 0x19, 0x63, 0x72, - 0x84, 0x96, 0x64, 0xA5, 0xF2, 0x92, 0x3C, 0x38, 0x37, 0x9F, 0x6A, 0x2D, - 0x58, 0x33, 0x8C, 0x5C, 0x27, 0x05, 0xCB, 0x4F, 0x62, 0x2F, 0x40, 0xE9, - 0x55, 0x2C, 0x75, 0x4B, 0x02, 0xB3, 0x61, 0xAD, 0x34, 0x14, 0x49, 0x26, - 0x94, 0x45, 0x9B, 0xB8, 0xDB, 0x1F, 0xCE, 0xE9, 0xB1, 0xBF, 0x47, 0xF3, - 0xD4, 0xAD, 0xEB, 0xBC, 0x4F, 0x61, 0xAD, 0x66, 0xAF, 0x10, 0x94, 0x5D, - 0x25, 0x5B, 0x52, 0xF3, 0x44, 0xBA, 0x28, 0xF8, 0xF2, 0x01, 0x41, 0x61, - 0xF3, 0xE5, 0x91, 0x44, 0xF9, 0xA3, 0x56, 0xD8, 0xE9, 0x43, 0x0F, 0x78, - 0x7E, 0x1C, 0x01, 0xA6, 0xD7, 0x47, 0x87, 0x7C, 0xC5, 0xAF, 0x2A, 0xD3, - 0x71, 0x3A, 0x3E, 0x96, 0xF5, 0x8E, 0xA8, 0x1A, 0x89, 0x17, 0xCD, 0x52, - 0x7E, 0x98, 0x70, 0xB3, 0x57, 0x22, 0x59, 0x1C, 0xB7, 0x61, 0xD3, 0x32, - 0xE5, 0x2E, 0x6B, 0x6F, 0x2B, 0xD2, 0xAB, 0x27, 0x62, 0x65, 0xBE, 0x0B, - 0x8B, 0xFC, 0x9D, 0xB7, 0x3B, 0x4F, 0xA7, 0x35, 0xA6, 0xB3, 0x10, 0x98, - 0x6D, 0x47, 0x12, 0x16, 0x89, 0x33, 0x9A, 0x87, 0x85, 0x50, 0x21, 0x2B, - 0x03, 0xD0, 0x0C, 0x25, 0x52, 0xC1, 0xA4, 0xD9, 0x50, 0x57, 0x0A, 0x88, - 0x67, 0xE9, 0x55, 0x78, 0xFF, 0x23, 0xC0, 0xD1, 0xB6, 0xF4, 0xBD, 0x64, - 0x38, 0x9A, 0x59, 0xD8, 0x0C, 0xCA, 0x3C, 0x44, 0xBB, 0x31, 0x40, 0xF3, - 0x3F, 0x84, 0x74, 0x1A, 0x1B, 0xFB, 0x81, 0x22, 0x20, 0x0E, 0x68, 0x48, - 0x7F, 0xBF, 0xBB, 0xE2, 0xF7, 0xEA, 0x1C, 0xDD, 0x63, 0xAA, 0x3E, 0xFE, - 0x7A, 0xBD, 0x6C, 0x2A, 0x2C, 0x6C, 0x8E, 0x3C, 0xB6, 0x42, 0x2F, 0x42, - 0xF2, 0x17, 0x07, 0x2F, 0x4F, 0xAA, 0x4B, 0xA0, 0xE7, 0x98, 0xAE, 0x95, - 0x21, 0x2A, 0xF8, 0x1C, 0x33, 0x81, 0xC2, 0x64, 0xEC, 0xF3, 0xD7, 0x75, - 0x81, 0x61, 0x8C, 0xDF, 0x7F, 0x76, 0x6B, 0x44, 0x22, 0x36, 0xD3, 0x7F, - 0x17, 0x40, 0x84, 0xF8, 0xA8, 0x4B, 0xD5, 0xD4, 0x4E, 0xA1, 0x86, 0xDB, - 0x9B, 0xCD, 0xB6, 0x6C, 0xDF, 0x35, 0x0C, 0x0D, 0x7E, 0x0F, 0x01, 0x9C, - 0xF7, 0x6E, 0x89, 0xE6, 0x2F, 0x0E, 0xC5, 0xF3, 0xEA, 0x69, 0x8C, 0xA5, - 0xD5, 0x48, 0xEE, 0x5B, 0x77, 0x04, 0xFE, 0xC7, 0x56, 0x87, 0x27, 0xD4, - 0xF9, 0xCC, 0xB4, 0xB4, 0xB7, 0x1A, 0x85, 0x38, 0x0B, 0x93, 0xD2, 0x1D, - 0xD3, 0xDE, 0x7E, 0x45, 0xAF, 0x82, 0x46, 0x65, 0xFE, 0x59, 0x55, 0x83 + 0x7B, 0x9E, 0xC9, 0x21, 0x70, 0xDF, 0xC0, 0x9E, 0x06, 0x57, 0xB8, 0x44, + 0xD0, 0x95, 0x21, 0xD0, 0x37, 0xDC, 0xAE, 0x3A, 0xAF, 0xCD, 0x56, 0x51, + 0x3C, 0xEC, 0x82, 0xB1, 0xFE, 0xBF, 0x6E, 0x12, 0xE7, 0x79, 0x92, 0xF0, + 0x3F, 0x56, 0x8A, 0x46, 0x0E, 0x4D, 0x9D, 0xC9, 0x7D, 0xC9, 0x2D, 0xE9, + 0x07, 0x1C, 0x9A, 0x11, 0x2F, 0x92, 0x26, 0x40, 0xD7, 0x73, 0xC8, 0xB9, + 0xD0, 0xB8, 0x46, 0x42, 0x53, 0x23, 0x79, 0xBB, 0x3B, 0x97, 0x91, 0x11, + 0x70, 0x66, 0xB6, 0xF4, 0x7B, 0x2F, 0x65, 0x3C, 0xA0, 0xD0, 0x70, 0x58, + 0x3C, 0xA8, 0xD9, 0x79, 0x79, 0x14, 0x55, 0xA4, 0x73, 0xE3, 0x40, 0xBB, + 0xC7, 0x57, 0x5C, 0x30, 0x9C, 0xC5, 0xB5, 0x9D, 0x87, 0xFB, 0x6E, 0x66, + 0x9C, 0x77, 0xF8, 0x41, 0x75, 0x80, 0x30, 0x62, 0xD5, 0x20, 0xBA, 0xB4, + 0x5D, 0x33, 0x8F, 0xC1, 0x5F, 0x22, 0xF1, 0xD8, 0x09, 0x62, 0xA6, 0xE1, + 0x73, 0x50, 0x5B, 0x9B, 0xD7, 0x21, 0x8F, 0x38, 0x31, 0x5B, 0x79, 0x1D, + 0xF8, 0x50, 0xE0, 0x87, 0xC1, 0x6B, 0xC4, 0x4D, 0x25, 0x6C, 0xB2, 0x0B, + 0x88, 0x51, 0xB9, 0xB0, 0xDF, 0xC2, 0x6C, 0xC6, 0x52, 0xB8, 0x88, 0xC0, + 0x25, 0x31, 0x99, 0x61, 0xCA, 0x0F, 0xCB, 0x63, 0x9A, 0x90, 0xE3, 0xB3, + 0x11, 0xFD, 0xAB, 0x1F, 0x4C, 0x6B, 0xC5, 0x5C, 0x86, 0x29, 0x4C, 0x84, + 0xC8, 0xE9, 0x5A, 0xCE, 0xE6, 0x3F, 0x79, 0xD2, 0xDC, 0x6A, 0xDD, 0x5F, + 0x42, 0x45, 0x62, 0xB9, 0xE7, 0x64, 0x88, 0x2F, 0x70, 0x45, 0x1E, 0x9E, + 0xCF, 0x9A, 0x4C, 0x2A, 0x3D, 0x1C, 0x6C, 0x2F, 0x94, 0x27, 0xD4, 0x2A, + 0xE5, 0x55, 0xA5, 0x73, 0xB8, 0x74, 0x29, 0x74, 0xD6, 0xF4, 0x6C, 0xB7, + 0x6C, 0x9D, 0x26, 0x6D, 0x2E, 0xBF, 0x99, 0xCA, 0xDD, 0xEB, 0x48, 0xAD, + 0x71, 0xB1, 0x1B, 0x1E, 0x45, 0xE8, 0xE9, 0xF1, 0x1F, 0x8D, 0x7B, 0x7B, + 0xD5, 0xDE, 0xE0, 0x8B, 0x67, 0x64, 0x4D, 0x9F, 0x6E, 0xC5, 0xB3, 0x03, + 0xC6, 0x35, 0x93, 0xE9, 0xE1, 0xA5, 0xC4, 0x6B, 0xD9, 0x29, 0xA6, 0x86, + 0xBB, 0x4B, 0xD9, 0xA4, 0x82, 0x68, 0xAF, 0x1E, 0x57, 0x30, 0x8C, 0xC6, + 0x94, 0xCA, 0xE5, 0xAB, 0x9E, 0x11, 0x51, 0x22, 0xEC, 0x28, 0x63, 0xBD, + 0xAA, 0xE8, 0xE5, 0x27, 0x7B, 0x68, 0x6C, 0x94, 0x42, 0xBA, 0x05, 0xEA, + 0x68, 0x5F, 0x18, 0xE9, 0x64, 0x23, 0x07, 0x11, 0xE4, 0x7B, 0x37, 0x77, + 0xFC, 0x35, 0xBC, 0xFC, 0x06, 0x2E, 0x7F, 0x15, 0xB8, 0xE1, 0x07, 0x42, + 0x04, 0xD2, 0x4A, 0xD5, 0x43, 0xE1, 0x49, 0x7C, 0x43, 0x49, 0x80, 0x3A, + 0x86, 0xE0, 0x10, 0x98, 0x77, 0xF2, 0x55, 0xC9, 0x21, 0x24, 0x6D, 0x01, + 0x36, 0xC5, 0x1F, 0xB8, 0x2D, 0x5B, 0x62, 0x99, 0x15, 0x74, 0x19, 0x44, + 0x82, 0xC1, 0x09, 0x16, 0x1B, 0xF1, 0x7E, 0xFD, 0xC5, 0xFD, 0x6C, 0x20, + 0xC3, 0x35, 0x8D, 0x46, 0xE3, 0x98, 0xCF, 0xE7, 0x6F, 0xC7, 0xD7, 0x71, + 0xCC, 0x95, 0x23, 0x60, 0xE7, 0x9E, 0x19, 0xD1, 0xA1, 0x0F, 0xDD, 0xFF, + 0x6B, 0x79, 0x12, 0x06, 0xB6, 0x12, 0x28, 0x42, 0x20, 0x16, 0x1C, 0xA4, + 0x0B, 0x94, 0x7D, 0xF5, 0xE3, 0x73, 0x62, 0x7B, 0x3B, 0x6B, 0xB7, 0xEC, + 0xCF, 0xAF, 0xF9, 0x8E, 0x09, 0x84, 0x50, 0x25, 0xF6, 0x2C, 0x1F, 0x7E, + 0x58, 0xE2, 0x5F, 0x06, 0x6D, 0xBB, 0x49, 0x9F, 0x29, 0x0A, 0x77, 0x95, + 0xF2, 0x02, 0xA6, 0x10, 0xC6, 0x3C, 0x12, 0xC5, 0xD3, 0xA2, 0x73, 0x0A, + 0x88, 0x86, 0x1D, 0xD7, 0x12, 0xF7, 0x49, 0x25, 0xFC, 0x81, 0x9F, 0xF6, + 0x2D, 0xF8, 0xB4, 0xE9, 0xE7, 0xC5, 0x3D, 0x40, 0x73, 0x6C, 0xFD, 0xE7, + 0xDA, 0x42, 0x34, 0xDB, 0x88, 0x72, 0x9E, 0xAE, 0x22, 0x68, 0x5B, 0xB1, + 0x68, 0xF7, 0xF7, 0x2A, 0xD6, 0x6A, 0x02, 0x07, 0x5F, 0x8F, 0xD7, 0xE9 }, /* uint8_t * encrypted_user_ecc256_public_key[R_TSIP_ECC_PUBLIC_KEY_BYTE_SIZE + 16]; */ { - 0xAD, 0x59, 0x2A, 0x12, 0xAA, 0xA8, 0x34, 0x30, 0xD4, 0xC9, 0xA1, 0x5A, - 0xD2, 0xD8, 0xF8, 0x99, 0xA0, 0x26, 0x87, 0x27, 0x90, 0x39, 0x00, 0xEA, - 0x64, 0x8F, 0x70, 0xF8, 0x1A, 0xA7, 0x44, 0xC8, 0xE6, 0x66, 0xCB, 0xF6, - 0x8B, 0x00, 0xC7, 0x86, 0x2B, 0x14, 0x98, 0xDB, 0x03, 0xE8, 0xD5, 0x02, - 0xB8, 0x02, 0x6D, 0x73, 0x66, 0x19, 0x94, 0x83, 0xC4, 0xB9, 0x57, 0x3D, - 0xFE, 0xA7, 0x19, 0xAC, 0xBC, 0xE3, 0x75, 0x40, 0xC2, 0x48, 0x5E, 0xEF, - 0x1E, 0x9E, 0xCC, 0xE2, 0xAC, 0xE6, 0xC8, 0x08 + 0xF2, 0x01, 0x30, 0xFE, 0x9F, 0xC6, 0x8F, 0x18, 0x81, 0xD9, 0xFF, 0xB9, + 0x8F, 0xF3, 0x93, 0x7E, 0xBA, 0x5C, 0x12, 0xA1, 0x7F, 0x39, 0x85, 0x3E, + 0xB0, 0xE7, 0x3E, 0xC7, 0xEF, 0x48, 0xA7, 0x75, 0x7B, 0x24, 0x16, 0x63, + 0x7B, 0x8D, 0x13, 0x5B, 0xCA, 0xC9, 0xF7, 0xB1, 0xC7, 0x46, 0xCE, 0xBB, + 0xB9, 0xEE, 0x89, 0xAE, 0x90, 0xDF, 0x74, 0xF1, 0x2B, 0x61, 0x41, 0x2B, + 0xF9, 0x5D, 0x41, 0x14, 0x92, 0x9E, 0xBC, 0x9D, 0xFE, 0x0D, 0x9A, 0x72, + 0x5A, 0x52, 0x3F, 0xE1, 0xFA, 0xED, 0x40, 0x47 }, /* uint8_t * encrypted_user_ecc256_private_key[R_TSIP_ECC_PRIVATE_KEY_BYTE_SIZE + 16]; */ { - 0xE6, 0x6C, 0xB8, 0x7C, 0xDB, 0x85, 0x50, 0x51, 0x4A, 0x75, 0x38, 0xA4, - 0x74, 0x7A, 0x8C, 0x7C, 0x07, 0x71, 0x0E, 0x52, 0xC3, 0x19, 0xD1, 0xE6, - 0xF8, 0x36, 0xD2, 0xD3, 0x53, 0xF8, 0xA7, 0xCE, 0xBC, 0xBE, 0xAE, 0x62, - 0x7F, 0x00, 0x54, 0xB1, 0x01, 0x11, 0xCA, 0xE3, 0x77, 0x3E, 0x2E, 0x21 + 0x49, 0x3E, 0xC8, 0x9B, 0xB0, 0x04, 0xAE, 0x16, 0x98, 0xB2, 0x57, 0x70, + 0x8D, 0x40, 0x6B, 0xAC, 0x59, 0xDD, 0x09, 0xB8, 0xCC, 0x10, 0xDE, 0xBE, + 0x4F, 0xD4, 0x9E, 0x6B, 0xB4, 0x03, 0x85, 0x95, 0x73, 0xA7, 0x48, 0x6D, + 0x08, 0xD8, 0x71, 0xD7, 0xDA, 0x50, 0x2F, 0x18, 0x48, 0x3D, 0xBF, 0x02 }, }; @@ -186,87 +186,95 @@ const uint32_t encrypted_user_key_type = const unsigned char ca_ecc_cert_der_sig[] = { - 0xc0, 0x3c, 0x28, 0xef, 0x6c, 0xd5, 0x6c, 0x36, 0xc5, 0xe5, 0xb0, 0xaa, - 0xd0, 0x6a, 0x33, 0x1d, 0x7b, 0x28, 0x9f, 0xb2, 0x12, 0x8c, 0x0c, 0x5c, - 0x30, 0xdf, 0x8f, 0x3f, 0x2e, 0x72, 0x0f, 0x3d, 0x8d, 0x4a, 0x1d, 0xa6, - 0xc5, 0x1f, 0xb4, 0xf2, 0x18, 0xf1, 0x65, 0x40, 0x8e, 0xf2, 0x06, 0x0a, - 0xda, 0xa4, 0xd6, 0x3d, 0x87, 0x61, 0x00, 0xd6, 0x89, 0x4e, 0x77, 0xbd, - 0x57, 0xd7, 0x5f, 0x04, 0xe9, 0x0c, 0x96, 0x68, 0xa9, 0x72, 0xa2, 0xba, - 0x46, 0x3f, 0x35, 0xeb, 0xf9, 0x4f, 0x10, 0xfd, 0x51, 0x39, 0x7c, 0x44, - 0xa8, 0xa8, 0xd3, 0x62, 0x81, 0x2f, 0x82, 0x90, 0x3e, 0xea, 0xe9, 0xbc, - 0x2e, 0xd1, 0x19, 0xc0, 0xb6, 0xd7, 0xc0, 0x22, 0x7c, 0xc1, 0x64, 0x61, - 0xd2, 0x79, 0x01, 0x2d, 0x19, 0x7a, 0xf0, 0x34, 0x68, 0x78, 0x01, 0x35, - 0x7f, 0xe2, 0xbe, 0x11, 0x8f, 0x0d, 0x04, 0xa8, 0xa4, 0x7b, 0x4e, 0x7a, - 0x9c, 0xa0, 0x91, 0x3f, 0x7d, 0xdf, 0xe4, 0x69, 0x2f, 0x9b, 0x73, 0xc6, - 0x1d, 0x4b, 0x3e, 0xcd, 0xa8, 0x2d, 0xf1, 0xfc, 0x35, 0x5c, 0xae, 0x7e, - 0xef, 0xd9, 0x91, 0x7c, 0x32, 0xc3, 0x5a, 0xcb, 0x5f, 0xd9, 0x99, 0x1b, - 0xb3, 0x6d, 0xa1, 0xaf, 0x69, 0x45, 0x41, 0xca, 0x92, 0x01, 0x93, 0x18, - 0xb7, 0x4c, 0x35, 0xe0, 0x11, 0x16, 0xc7, 0xf2, 0xf9, 0xf1, 0x9e, 0xa5, - 0xda, 0x60, 0x41, 0x78, 0x67, 0xef, 0x2f, 0x85, 0x08, 0xfe, 0x21, 0x1f, - 0xdd, 0x31, 0xce, 0x70, 0xf2, 0xe2, 0x6f, 0xc1, 0x5f, 0xce, 0xa7, 0x4c, - 0x3a, 0x1a, 0x81, 0x5d, 0xec, 0x35, 0xad, 0xf3, 0xb4, 0x46, 0x83, 0x9b, - 0x95, 0x98, 0xcc, 0xa5, 0x46, 0x74, 0xdf, 0xca, 0xf9, 0x2e, 0x86, 0xe8, - 0x04, 0x18, 0x33, 0x91, 0x94, 0xb7, 0xca, 0x98, 0xf7, 0xc2, 0xfe, 0x99, - 0xc0, 0x73, 0x11, 0x1e + 0x85, 0x76, 0x96, 0x7D, 0xB5, 0x14, 0xD9, 0x4F, 0x3E, 0xCF, + 0xF3, 0xD3, 0xAB, 0x76, 0x77, 0xBA, 0xDB, 0xB8, 0x87, 0xD2, + 0x2E, 0xB5, 0x87, 0x69, 0x79, 0x8C, 0x34, 0x1A, 0x06, 0xB9, + 0xD5, 0x0D, 0xA8, 0x4B, 0x05, 0x6A, 0xF4, 0x26, 0x86, 0xB6, + 0x91, 0x0F, 0x27, 0x6F, 0xA7, 0xF1, 0x3C, 0xEC, 0x3D, 0x34, + 0xE7, 0x82, 0xEB, 0x10, 0xE6, 0xFA, 0x04, 0x11, 0x78, 0xCD, + 0xEB, 0xA0, 0xB4, 0x6C, 0xBC, 0x7C, 0x8C, 0x83, 0xD3, 0x68, + 0xC2, 0x72, 0x17, 0xE0, 0x41, 0xA3, 0xE3, 0x5A, 0xB6, 0x2D, + 0x52, 0xA4, 0x4A, 0x4E, 0x9B, 0x3E, 0x98, 0xD7, 0xBB, 0x17, + 0xF5, 0x19, 0xAB, 0x30, 0xBF, 0xE2, 0x8B, 0xD7, 0x47, 0x7B, + 0x99, 0x7B, 0x97, 0x46, 0x53, 0x34, 0xCA, 0x74, 0x00, 0x39, + 0x04, 0x6F, 0x0B, 0xC0, 0x42, 0x73, 0x65, 0xCA, 0x3F, 0xE2, + 0x58, 0x1E, 0x26, 0xE5, 0xA2, 0x86, 0x63, 0xF3, 0x41, 0x89, + 0x0E, 0x6B, 0x74, 0xF4, 0x73, 0x4D, 0x8E, 0x04, 0x1E, 0x64, + 0x7E, 0x9C, 0x37, 0x3A, 0xF2, 0x4E, 0x5B, 0xF2, 0x67, 0x9A, + 0x48, 0xFB, 0x70, 0xDD, 0x70, 0x8C, 0xC0, 0x8F, 0xE9, 0x77, + 0x7B, 0xC0, 0x1F, 0xB7, 0xE2, 0xB8, 0xC2, 0x67, 0xF0, 0x1D, + 0x13, 0xFB, 0x8D, 0xEB, 0x69, 0xE8, 0xC0, 0x31, 0xAC, 0xB9, + 0x0C, 0x2D, 0x89, 0x77, 0x81, 0xC5, 0x87, 0xDD, 0x28, 0x7C, + 0x03, 0x34, 0xFA, 0xD8, 0xE5, 0x20, 0x4A, 0x88, 0x42, 0x6B, + 0x16, 0x55, 0x33, 0x16, 0x57, 0x19, 0x6B, 0x5A, 0x0C, 0xAC, + 0x12, 0xF4, 0x72, 0x7B, 0x1C, 0x8E, 0x85, 0xCE, 0x2D, 0xE7, + 0x94, 0xAD, 0xFC, 0xA8, 0x92, 0x70, 0xE0, 0xFA, 0x19, 0xB3, + 0xB4, 0x97, 0x25, 0x10, 0xCB, 0x27, 0x74, 0x57, 0x5D, 0x22, + 0xDB, 0x1D, 0x2F, 0xB4, 0x27, 0x52, 0xDE, 0x56, 0x77, 0xFB, + 0xBA, 0x75, 0x5F, 0xC3, 0x84, 0xA6 }; const int sizeof_ca_ecc_cert_sig = sizeof(ca_ecc_cert_der_sig); /* ./ca-cert.der.sign, */ const unsigned char ca_cert_der_sig[] = { - 0x97, 0x8f, 0x90, 0x03, 0x0b, 0xca, 0xdf, 0x8f, 0xe8, 0x51, 0x23, 0xba, - 0x14, 0xfb, 0x28, 0xb8, 0x5c, 0x58, 0x0d, 0x6e, 0x8b, 0x97, 0x0f, 0x89, - 0x63, 0xc2, 0xd6, 0xb3, 0xf0, 0x16, 0x35, 0x74, 0x9d, 0xb9, 0xd7, 0x18, - 0x14, 0x86, 0x91, 0xe0, 0xcd, 0xb3, 0x28, 0x63, 0x16, 0xf4, 0x6c, 0xb1, - 0xd3, 0x93, 0xb6, 0x6e, 0xd9, 0x66, 0xcd, 0x65, 0x39, 0x7b, 0x1b, 0x74, - 0x5c, 0xde, 0x20, 0xd4, 0x46, 0x60, 0x2f, 0xc0, 0x10, 0xf5, 0x49, 0x4a, - 0x8d, 0x31, 0x29, 0x9b, 0x8a, 0xea, 0xf4, 0x8a, 0xaf, 0xc4, 0x84, 0xd7, - 0x42, 0xef, 0xaf, 0x14, 0x17, 0x44, 0xed, 0x6e, 0x2b, 0xd9, 0x70, 0xed, - 0x3e, 0x40, 0xf0, 0xef, 0x75, 0x4c, 0x05, 0x1f, 0xc3, 0x37, 0xec, 0xc2, - 0xcd, 0xcc, 0xce, 0x39, 0x61, 0xa0, 0xea, 0x16, 0x84, 0x6d, 0xde, 0xe7, - 0xf4, 0x0d, 0x8c, 0xf7, 0x69, 0x81, 0x64, 0x09, 0x16, 0xa7, 0x5b, 0x34, - 0x83, 0xe5, 0x73, 0xcf, 0x02, 0xf4, 0x37, 0x96, 0x93, 0x27, 0x72, 0x47, - 0x71, 0xca, 0x56, 0xcd, 0xd2, 0x85, 0x48, 0xe5, 0x9e, 0x1f, 0x39, 0x52, - 0xc1, 0xc3, 0x9c, 0x6b, 0x98, 0x41, 0xc2, 0x0a, 0x77, 0x94, 0xe5, 0x84, - 0x44, 0xe7, 0x94, 0xee, 0x5f, 0x05, 0x62, 0xad, 0xe5, 0xe5, 0xc9, 0x7e, - 0x02, 0x31, 0x85, 0xca, 0x28, 0x2d, 0x0d, 0x7f, 0x30, 0x5d, 0xb5, 0xaa, - 0x12, 0x81, 0x25, 0x37, 0x4a, 0xf2, 0x95, 0x81, 0xda, 0x76, 0xb4, 0x89, - 0x76, 0x8a, 0x0c, 0x8d, 0xdf, 0xed, 0xd5, 0x48, 0xa8, 0xc8, 0x6d, 0xf4, - 0xbf, 0x98, 0xa3, 0xc5, 0x42, 0x7d, 0xd2, 0x21, 0x2c, 0x8d, 0x57, 0xd0, - 0x91, 0x16, 0xee, 0x83, 0xd0, 0xa1, 0x8f, 0x05, 0x50, 0x2b, 0x6e, 0xe8, - 0x52, 0xf7, 0xbe, 0x96, 0x89, 0x40, 0xca, 0x9c, 0x19, 0x5a, 0xfc, 0xae, - 0x1d, 0xdb, 0x57, 0xb8 + 0x3C, 0x99, 0x92, 0x6F, 0x0A, 0xE7, 0xC1, 0x31, 0x1F, 0xC2, + 0x60, 0xFD, 0x26, 0x54, 0x2F, 0xEA, 0xA4, 0xB6, 0x99, 0x8F, + 0xCF, 0x01, 0x6F, 0x37, 0x7A, 0xF5, 0xB7, 0xD1, 0xCC, 0x51, + 0x0B, 0x34, 0xF1, 0xF4, 0xF0, 0x48, 0xCF, 0x53, 0xD3, 0xE1, + 0xF1, 0x08, 0xD1, 0x3F, 0x2B, 0x9A, 0x0E, 0x5A, 0x15, 0xB7, + 0xAD, 0x14, 0x27, 0x24, 0x70, 0xE8, 0x02, 0x68, 0x21, 0xA2, + 0xA2, 0x9D, 0x63, 0x41, 0x6A, 0xE3, 0xD2, 0xC9, 0x48, 0x7B, + 0xF2, 0x6E, 0x7A, 0x80, 0xB8, 0xA9, 0x28, 0x61, 0x7B, 0x93, + 0x93, 0x18, 0x68, 0x19, 0x6A, 0x6F, 0x78, 0x53, 0x32, 0xBF, + 0xAB, 0x28, 0x10, 0x44, 0xAC, 0xB9, 0x15, 0xFD, 0x51, 0xFE, + 0x5E, 0x47, 0x07, 0xCD, 0xAF, 0x94, 0x69, 0x7A, 0x66, 0x31, + 0x3E, 0xED, 0x1B, 0x93, 0x97, 0x1A, 0x83, 0xA2, 0xC7, 0x5B, + 0xD3, 0x34, 0xAE, 0x24, 0xC8, 0xE9, 0xA9, 0x9E, 0x64, 0xEA, + 0x57, 0xA8, 0xA8, 0xD8, 0xA2, 0x74, 0x5F, 0xDB, 0x70, 0xCC, + 0x07, 0x1D, 0xD0, 0xA7, 0x91, 0x61, 0xD6, 0x9F, 0x6F, 0x77, + 0x80, 0xE9, 0x6C, 0x2F, 0x90, 0xF1, 0xBE, 0x25, 0x3F, 0x1C, + 0x76, 0xB6, 0xAC, 0xD7, 0xD1, 0x1E, 0x97, 0x15, 0x94, 0x96, + 0xD6, 0xF6, 0xBF, 0x39, 0x6D, 0xC7, 0xF5, 0x13, 0xE0, 0xBB, + 0xC4, 0xDC, 0x18, 0x13, 0x65, 0x2B, 0x80, 0x23, 0x9A, 0x6A, + 0x70, 0x30, 0x9A, 0xB3, 0xE5, 0x2D, 0xC1, 0xCB, 0xBF, 0x5A, + 0xC2, 0xEE, 0xF6, 0x65, 0x50, 0xD4, 0xF2, 0xA3, 0xD5, 0xF9, + 0xF8, 0x16, 0xD3, 0x05, 0xAC, 0xE9, 0x8B, 0x5A, 0x75, 0xD7, + 0xF9, 0xB9, 0x05, 0xF3, 0x9C, 0xD0, 0xCE, 0x39, 0xA5, 0x7D, + 0xB6, 0xC6, 0x78, 0x6A, 0x31, 0x6C, 0xD2, 0xBB, 0x6F, 0x8E, + 0x11, 0xD4, 0x84, 0x8B, 0x21, 0x65, 0xFC, 0x2D, 0xD3, 0x51, + 0xC6, 0x31, 0x80, 0xCD, 0xE9, 0x5F }; const int sizeof_ca_cert_sig = sizeof(ca_cert_der_sig); /* ./client-cert.der.sign, */ const unsigned char client_cert_der_sign[] = { - 0x5D, 0x1F, 0x89, 0x41, 0xEC, 0x47, 0xC8, 0x90, 0x61, 0x79, - 0x8A, 0x16, 0x1F, 0x31, 0x96, 0x67, 0xD9, 0x3C, 0xEC, 0x6B, - 0x58, 0xC6, 0x5A, 0xED, 0x99, 0xB3, 0xEF, 0x27, 0x6F, 0x04, - 0x8C, 0xD9, 0x68, 0xB1, 0xD6, 0x23, 0x15, 0x84, 0x00, 0xE1, - 0x27, 0xD1, 0x1F, 0x68, 0xB7, 0x3F, 0x13, 0x53, 0x8A, 0x95, - 0x5A, 0x20, 0x7C, 0xB2, 0x76, 0x5B, 0xDC, 0xE0, 0xA6, 0x21, - 0x7C, 0x49, 0xCF, 0x93, 0xBA, 0xD5, 0x12, 0x9F, 0xEE, 0x90, - 0x5B, 0x3F, 0xA3, 0x9D, 0x13, 0x72, 0xAC, 0x72, 0x16, 0xFE, - 0x1D, 0xBE, 0xEB, 0x8E, 0xC7, 0xDC, 0xC4, 0xF8, 0x1A, 0xD8, - 0xA0, 0xA4, 0xF6, 0x04, 0x30, 0xF6, 0x7E, 0xB6, 0xC8, 0xE1, - 0xAB, 0x88, 0x37, 0x08, 0x63, 0x72, 0xAA, 0x46, 0xCC, 0xCA, - 0xF0, 0x9E, 0x02, 0x1E, 0x65, 0x67, 0xFF, 0x2C, 0x9D, 0x81, - 0x6C, 0x1E, 0xF1, 0x54, 0x05, 0x68, 0x68, 0x18, 0x72, 0x26, - 0x55, 0xB6, 0x2C, 0x95, 0xC0, 0xC9, 0xB2, 0xA7, 0x0B, 0x60, - 0xD7, 0xEB, 0x1D, 0x08, 0x1A, 0xA2, 0x54, 0x15, 0x89, 0xCB, - 0x83, 0x21, 0x5D, 0x15, 0x9B, 0x38, 0xAC, 0x89, 0x63, 0xD5, - 0x4B, 0xF4, 0x8B, 0x47, 0x93, 0x78, 0x43, 0xCB, 0x9B, 0x71, - 0xBF, 0x94, 0x76, 0xB5, 0xCE, 0x35, 0xA9, 0x1A, 0xD5, 0xA5, - 0xD8, 0x19, 0xA6, 0x04, 0x39, 0xB1, 0x09, 0x8C, 0x65, 0x02, - 0x58, 0x3A, 0x95, 0xEF, 0xA2, 0xC3, 0x85, 0x18, 0x61, 0x23, - 0x2D, 0xC5, 0xCD, 0x62, 0xC1, 0x19, 0x31, 0xE5, 0x36, 0x95, - 0x22, 0xDB, 0x3E, 0x1A, 0x3C, 0xE8, 0xC6, 0x2E, 0xDF, 0xD9, - 0x2F, 0x84, 0xC1, 0xF0, 0x38, 0x2B, 0xE5, 0x73, 0x35, 0x4F, - 0x05, 0xE2, 0xA5, 0x60, 0x79, 0xB0, 0x23, 0xDC, 0x56, 0x4C, - 0xE7, 0xD9, 0x1F, 0xCF, 0x6A, 0xFC, 0x55, 0xEB, 0xAA, 0x48, - 0x3E, 0x95, 0x2A, 0x10, 0x01, 0x05 + 0x58, 0x04, 0xD2, 0xCA, 0x82, 0x7F, 0x7C, 0xB3, 0x93, 0x8A, + 0x81, 0x5F, 0x48, 0x91, 0xA4, 0x04, 0x13, 0x55, 0x20, 0x02, + 0x1A, 0xCC, 0xD6, 0x09, 0x56, 0x89, 0x37, 0xBD, 0x3F, 0x88, + 0x10, 0x3E, 0x8D, 0x2E, 0x30, 0x0E, 0x97, 0xA8, 0x68, 0xE1, + 0xAE, 0x00, 0x9A, 0x42, 0xA0, 0xAF, 0x3E, 0xAE, 0xFF, 0xFF, + 0xA7, 0xF3, 0x9C, 0xA7, 0x59, 0xB1, 0xA9, 0x67, 0x2D, 0xCE, + 0xAE, 0x27, 0x0D, 0x9F, 0x22, 0x99, 0x43, 0x49, 0xC3, 0xC7, + 0x50, 0x11, 0xDB, 0xD4, 0xE8, 0xA4, 0x6B, 0x30, 0x95, 0x6C, + 0x66, 0x69, 0xF2, 0x2D, 0xE4, 0x41, 0x7D, 0x45, 0x73, 0xD5, + 0xE7, 0x3D, 0x15, 0x34, 0x99, 0xB7, 0x27, 0xAC, 0xFB, 0x6D, + 0xDC, 0xFF, 0x1F, 0x17, 0xF3, 0x37, 0x92, 0x44, 0x58, 0x57, + 0x50, 0xA6, 0x3A, 0xB4, 0xB2, 0xB9, 0xAE, 0x8E, 0x4E, 0x63, + 0x42, 0xBD, 0xDD, 0xAA, 0xC8, 0x26, 0x0D, 0xE8, 0x57, 0xCF, + 0xBD, 0x75, 0xAB, 0xDD, 0x92, 0x53, 0x1F, 0x7A, 0x9F, 0x4D, + 0x0E, 0xB0, 0xF5, 0x7F, 0xCE, 0x92, 0xD4, 0xEC, 0x3E, 0x44, + 0x99, 0x27, 0x32, 0x42, 0xFA, 0x68, 0xCE, 0x2E, 0x75, 0x31, + 0xEE, 0x74, 0xDA, 0xB4, 0x42, 0x8C, 0x30, 0xF8, 0xB7, 0xB6, + 0xF4, 0x29, 0x5C, 0x18, 0x59, 0xE8, 0x39, 0x06, 0xF2, 0xDB, + 0x50, 0xC4, 0x75, 0x3A, 0xD2, 0xDA, 0x9B, 0xEA, 0xBF, 0x80, + 0x42, 0x97, 0x01, 0x7B, 0xBA, 0x5D, 0xA0, 0x29, 0x40, 0xAE, + 0x3C, 0x4D, 0x75, 0x98, 0xEB, 0xCE, 0x5E, 0x67, 0xDC, 0xE3, + 0xC5, 0x70, 0x8F, 0x22, 0x15, 0xCB, 0x31, 0x39, 0x8F, 0x6E, + 0x8B, 0xA9, 0x22, 0x09, 0x18, 0xDC, 0x19, 0xD5, 0x65, 0x5E, + 0xD5, 0x59, 0xAE, 0xD9, 0xAD, 0xF7, 0x9C, 0x2C, 0xD5, 0x79, + 0x15, 0x62, 0xF8, 0xAE, 0xBA, 0x11, 0x24, 0x98, 0xC8, 0xB6, + 0xF5, 0xDE, 0x32, 0x10, 0x03, 0x07 }; const int sizeof_client_cert_der_sign = sizeof(client_cert_der_sign); diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/key_data.h b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/key_data.h index 2d6bead068..80df72cb31 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/key_data.h +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/key_data.h @@ -1,6 +1,6 @@ /* key_data.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/user_settings.h b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/user_settings.h index 6e8d165b3e..5d4c2f341f 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/user_settings.h +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -246,7 +246,6 @@ #define WOLFSSL_RENESAS_TSIP_TLS #if !defined(NO_RENESAS_TSIP_CRYPT) - #define WOLFSSL_RENESAS_TSIP_CRYPTONLY #define HAVE_PK_CALLBACKS #define WOLF_CRYPTO_CB #if defined(WOLFSSL_RENESAS_TSIP_TLS) diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_demo.c b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_demo.c index 5d1f913677..56f07cf90c 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_demo.c +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_demo.c @@ -1,6 +1,6 @@ /* wolfssl_demo.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_demo.h b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_demo.h index c11e59c830..4aa90b5d5a 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_demo.h +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_demo.h @@ -1,6 +1,6 @@ /* wolfssl_demo.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_tsip_unit_test.c b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_tsip_unit_test.c index f89b48cf15..048add2c62 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_tsip_unit_test.c +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_tsip_unit_test.c @@ -1,6 +1,6 @@ /* wolfssl_tsip_unit_test.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -107,7 +107,6 @@ typedef struct tagInfo void Clr_CallbackCtx(TsipUserCtx *g) { - if (g->rsa1024pri_keyIdx != NULL) XFREE(g->rsa1024pri_keyIdx, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -139,7 +138,7 @@ static int tsip_aes_cbc_test(int prnt, tsip_aes_key_index_t* aes_key) byte plain[AES_BLOCK_SIZE]; int ret = 0; - WOLFSSL_SMALL_STACK_STATIC const byte msg[] = { + WOLFSSL_SMALL_STACK_STATIC const byte msg[] = { /* "Now is the time for all " w/o trailing 0 */ 0x6e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74, 0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20, @@ -154,7 +153,7 @@ static int tsip_aes_cbc_test(int prnt, tsip_aes_key_index_t* aes_key) if (prnt) { printf(" tsip_aes_cbc_test() "); } - + ret = wc_AesInit(aes, NULL, INVALID_DEVID); if (ret == 0) { ret = wc_AesSetKey(aes, key, AES_BLOCK_SIZE, iv, AES_ENCRYPTION); @@ -196,7 +195,7 @@ static int tsip_aes_cbc_test(int prnt, tsip_aes_key_index_t* aes_key) if (prnt) { RESULT_STR(ret) } - + return ret; } @@ -205,7 +204,7 @@ static void tskAes128_Cbc_Test(void *pvParam) { int ret = 0; Info *p = (Info*)pvParam; - + while (exit_loop == false) { ret = tsip_aes_cbc_test(0, &p->aes_key); vTaskDelay(10/portTICK_PERIOD_MS); @@ -257,7 +256,7 @@ static int tsip_aes256_test(int prnt, tsip_aes_key_index_t* aes_key) if (prnt) printf(" tsip_aes256_test() "); - + if (wc_AesInit(enc, NULL, INVALID_DEVID) != 0) { ret = -1; goto out; @@ -315,7 +314,7 @@ static int tsip_aes256_test(int prnt, tsip_aes_key_index_t* aes_key) if (prnt) { RESULT_STR(ret) } - + return ret; } #ifdef FREERTOS @@ -323,7 +322,7 @@ static void tskAes256_Cbc_Test(void *pvParam) { int ret = 0; Info *p = (Info*)pvParam; - + while (exit_loop == false) { ret = tsip_aes256_test(0, &p->aes_key); vTaskDelay(10/portTICK_PERIOD_MS); @@ -345,8 +344,8 @@ static int tsip_aesgcm256_test(int prnt, tsip_aes_key_index_t* aes256_key) Aes enc[1]; Aes dec[1]; TsipUserCtx userContext; - - + + /* * This is Test Case 16 from the document Galois/ * Counter Mode of Operation (GCM) by McGrew and @@ -416,7 +415,7 @@ static int tsip_aesgcm256_test(int prnt, tsip_aes_key_index_t* aes256_key) if (prnt) { printf(" tsip_aes256_gcm_test() "); } - + ForceZero(resultT, sizeof(resultT)); ForceZero(resultC, sizeof(resultC)); ForceZero(resultP, sizeof(resultP)); @@ -443,8 +442,8 @@ static int tsip_aesgcm256_test(int prnt, tsip_aes_key_index_t* aes256_key) } /* AES-GCM encrypt and decrypt both use AES encrypt internally */ - result = wc_tsip_AesGcmEncrypt(enc, resultC, p, sizeof(p), - (byte*)iv1, sizeof(iv1), resultT, sizeof(resultT), + result = wc_tsip_AesGcmEncrypt(enc, resultC, p, sizeof(p), + (byte*)iv1, sizeof(iv1), resultT, sizeof(resultT), a, sizeof(a), &userContext); if (result != 0) { @@ -461,7 +460,7 @@ static int tsip_aesgcm256_test(int prnt, tsip_aes_key_index_t* aes256_key) } result = wc_tsip_AesGcmDecrypt(dec, resultP, resultC, sizeof(c1), - iv1, sizeof(iv1), resultT, sizeof(resultT), + iv1, sizeof(iv1), resultT, sizeof(resultT), a, sizeof(a), &userContext); if (result != 0){ ret = -8; @@ -479,7 +478,7 @@ static int tsip_aesgcm256_test(int prnt, tsip_aes_key_index_t* aes256_key) wc_AesGcmSetKey(enc, k1, sizeof(k1)); /* AES-GCM encrypt and decrypt both use AES encrypt internally */ result = wc_tsip_AesGcmEncrypt(enc, resultC, p, sizeof(p), iv1, sizeof(iv1), - resultT + 1, sizeof(resultT) - 1, + resultT + 1, sizeof(resultT) - 1, a, sizeof(a), &userContext); if (result != 0) { ret = -10; @@ -487,7 +486,7 @@ static int tsip_aesgcm256_test(int prnt, tsip_aes_key_index_t* aes256_key) } result = wc_tsip_AesGcmDecrypt(enc, resultP, resultC, sizeof(p), - iv1, sizeof(iv1), resultT + 1, sizeof(resultT) - 1, + iv1, sizeof(iv1), resultT + 1, sizeof(resultT) - 1, a, sizeof(a), &userContext); if (result != 0) { @@ -504,11 +503,11 @@ static int tsip_aesgcm256_test(int prnt, tsip_aes_key_index_t* aes256_key) out: wc_AesFree(enc); wc_AesFree(dec); - + if (prnt) { RESULT_STR(ret) } - + return ret; } #ifdef FREERTOS @@ -516,7 +515,7 @@ static void tskAes256_Gcm_Test(void *pvParam) { int ret = 0; Info *p = (Info*)pvParam; - + while (exit_loop == false) { ret = tsip_aesgcm256_test(0, &p->aes_key); vTaskDelay(10/portTICK_PERIOD_MS); @@ -616,16 +615,16 @@ static int tsip_aesgcm128_test(int prnt, tsip_aes_key_index_t* aes128_key) enc->ctx.keySize = enc->keylen; } /* AES-GCM encrypt and decrypt both use AES encrypt internally */ - result = wc_tsip_AesGcmEncrypt(enc, resultC, p3, sizeof(p3), + result = wc_tsip_AesGcmEncrypt(enc, resultC, p3, sizeof(p3), iv3, sizeof(iv3), - resultT, sizeof(t3), + resultT, sizeof(t3), a3, sizeof(a3), &userContext); if (result != 0) { ret = -4; goto out; } result = wc_tsip_AesGcmDecrypt(enc, resultP, resultC, sizeof(c3), - iv3, sizeof(iv3), resultT, sizeof(resultT), + iv3, sizeof(iv3), resultT, sizeof(resultT), a3, sizeof(a3), &userContext); if (result != 0) { ret = -5; @@ -641,11 +640,11 @@ static int tsip_aesgcm128_test(int prnt, tsip_aes_key_index_t* aes128_key) out: wc_AesFree(enc); wc_AesFree(dec); - + if (prnt) { RESULT_STR(ret) } - + return ret; } #ifdef FREERTOS @@ -812,7 +811,7 @@ int tsip_crypt_sha_multitest() int num = 0; int i; BaseType_t xRet; - + #ifndef NO_SHA num++; #endif @@ -825,14 +824,14 @@ int tsip_crypt_sha_multitest() exit_semaph = xSemaphoreCreateCounting(num, 0); xRet = pdPASS; - + #ifndef NO_SHA - xRet = xTaskCreate(tskSha_Test, "sha_test", + xRet = xTaskCreate(tskSha_Test, "sha_test", SMALL_STACK_SIZE, NULL, 3, NULL); #endif #ifndef NO_SHA256 if (xRet == pdPASS) - xRet = xTaskCreate(tskSha256_Test, "sha256_test", + xRet = xTaskCreate(tskSha256_Test, "sha256_test", SMALL_STACK_SIZE, NULL, 3, NULL); #endif @@ -849,15 +848,15 @@ int tsip_crypt_sha_multitest() } } } - + vSemaphoreDelete(exit_semaph); - + if ((xRet == pdPASS) && (sha_multTst_rslt == 0 && sha256_multTst_rslt == 0)) ret = 0; else ret = -1; - + RESULT_STR(ret) return ret; @@ -874,7 +873,7 @@ int tsip_crypt_AesCbc_multitest() Info info_aes256_1; Info info_aes256_2; BaseType_t xRet; - + #if defined(HAVE_AES_CBC) && defined(WOLFSSL_AES_128) num+=2; #endif @@ -887,7 +886,7 @@ int tsip_crypt_AesCbc_multitest() exit_semaph = xSemaphoreCreateCounting(num, 0); xRet = pdPASS; - + #if defined(HAVE_AES_CBC) && defined(WOLFSSL_AES_128) XMEMCPY(&info_aes1.aes_key, &g_user_aes128_key_index1, sizeof(tsip_aes_key_index_t)); @@ -916,7 +915,7 @@ int tsip_crypt_AesCbc_multitest() xRet = xTaskCreate(tskAes256_Cbc_Test, "aes256_cbc_test2", SMALL_STACK_SIZE, &info_aes256_2, 3, NULL); #endif - + if (xRet == pdPASS) { printf(" Waiting for completing tasks ..."); vTaskDelay(10000/portTICK_PERIOD_MS); @@ -930,7 +929,7 @@ int tsip_crypt_AesCbc_multitest() } } } - + vSemaphoreDelete(exit_semaph); if ((xRet == pdPASS) && @@ -955,7 +954,7 @@ int tsip_crypt_AesGcm_multitest() Info info_aes256_1; Info info_aes256_2; BaseType_t xRet; - + #if defined(WOLFSSL_AES_128) num+=2; #endif @@ -1010,7 +1009,7 @@ int tsip_crypt_AesGcm_multitest() } } } - + vSemaphoreDelete(exit_semaph); if ((xRet == pdPASS) && @@ -1032,7 +1031,7 @@ int tsip_crypt_Sha_AesCbcGcm_multitest() Info info_aes256cbc; Info info_aes256gcm; BaseType_t xRet; - + #ifndef NO_SHA num++; #endif @@ -1051,7 +1050,7 @@ int tsip_crypt_Sha_AesCbcGcm_multitest() exit_semaph = xSemaphoreCreateCounting(num, 0); xRet = pdPASS; - + #ifndef NO_SHA xRet = xTaskCreate(tskSha_Test, "sha_test", SMALL_STACK_SIZE, NULL, 3, NULL); @@ -1069,7 +1068,7 @@ int tsip_crypt_Sha_AesCbcGcm_multitest() XMEMCPY(&info_aes256gcm.aes_key, &g_user_aes256_key_index2, sizeof(tsip_aes_key_index_t)); if (xRet == pdPASS) - xRet = xTaskCreate(tskAes256_Gcm_Test, "aes256_gcm_test2", + xRet = xTaskCreate(tskAes256_Gcm_Test, "aes256_gcm_test2", STACK_SIZE, &info_aes256gcm, 3, NULL); #endif @@ -1086,9 +1085,9 @@ int tsip_crypt_Sha_AesCbcGcm_multitest() } } } - + vSemaphoreDelete(exit_semaph); - + if (xRet == pdPASS && sha_multTst_rslt == 0 && (Aes256_Cbc_multTst_rslt == 0 && Aes256_Gcm_multTst_rslt == 0)) { ret = 0; @@ -1096,7 +1095,7 @@ int tsip_crypt_Sha_AesCbcGcm_multitest() else { ret = -1; } - + RESULT_STR(ret) return ret; @@ -1158,11 +1157,10 @@ int tsip_crypt_test() ret = tsip_aesgcm256_test(1, &g_user_aes256_key_index1); } - #if defined(WOLFSSL_KEY_GEN)&& \ + #if defined(WOLFSSL_KEY_GEN) && \ defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) if (ret == 0) { - Clr_CallbackCtx(&userContext); ret = wc_CryptoCb_CryptInitRenesasCmn(NULL, &userContext); @@ -1172,11 +1170,10 @@ int tsip_crypt_test() } if (ret == 0) { - printf(" tsip_rsa_SignVerify_test(1024)"); userContext.wrappedKeyType = TSIP_KEY_TYPE_RSA1024; - userContext.sing_hash_type = sha256_mac; + userContext.sign_hash_type = sha256_mac; userContext.keyflgs_crypt.bits.message_type = 0; ret = tsip_rsa_SignVerify_test(1, 1024); @@ -1189,7 +1186,7 @@ int tsip_crypt_test() printf(" tsip_rsa_SignVerify_test(2048)"); userContext.wrappedKeyType = TSIP_KEY_TYPE_RSA2048; - userContext.sing_hash_type = sha256_mac; + userContext.sign_hash_type = sha256_mac; userContext.keyflgs_crypt.bits.message_type = 0; ret = tsip_rsa_SignVerify_test(1, 2048); diff --git a/IDE/Renesas/e2studio/RZN2L/common/user_settings.h b/IDE/Renesas/e2studio/RZN2L/common/user_settings.h index 48e4522493..beb89aae6f 100644 --- a/IDE/Renesas/e2studio/RZN2L/common/user_settings.h +++ b/IDE/Renesas/e2studio/RZN2L/common/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RZN2L/common/wolfssl_demo.h b/IDE/Renesas/e2studio/RZN2L/common/wolfssl_demo.h index 9f5a8cd0ae..6357c0b640 100644 --- a/IDE/Renesas/e2studio/RZN2L/common/wolfssl_demo.h +++ b/IDE/Renesas/e2studio/RZN2L/common/wolfssl_demo.h @@ -1,6 +1,6 @@ /* wolfssl_demo.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RZN2L/test/src/rzn2l_tst_thread_entry.c b/IDE/Renesas/e2studio/RZN2L/test/src/rzn2l_tst_thread_entry.c index 0e4c459ed0..cb9b3b7a0e 100644 --- a/IDE/Renesas/e2studio/RZN2L/test/src/rzn2l_tst_thread_entry.c +++ b/IDE/Renesas/e2studio/RZN2L/test/src/rzn2l_tst_thread_entry.c @@ -1,6 +1,6 @@ /* rzn2l_tst_thread_entry.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RZN2L/test/src/test/wolf_client.c b/IDE/Renesas/e2studio/RZN2L/test/src/test/wolf_client.c index f2d610da1f..227d75f488 100644 --- a/IDE/Renesas/e2studio/RZN2L/test/src/test/wolf_client.c +++ b/IDE/Renesas/e2studio/RZN2L/test/src/test/wolf_client.c @@ -1,6 +1,6 @@ /* wolf_client.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RZN2L/test/src/test/wolf_server.c b/IDE/Renesas/e2studio/RZN2L/test/src/test/wolf_server.c index b4ce624c99..fc3d9706c8 100644 --- a/IDE/Renesas/e2studio/RZN2L/test/src/test/wolf_server.c +++ b/IDE/Renesas/e2studio/RZN2L/test/src/test/wolf_server.c @@ -1,6 +1,6 @@ /* wolf_server.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RZN2L/test/src/test/wolfssl_rsip_unit_test.c b/IDE/Renesas/e2studio/RZN2L/test/src/test/wolfssl_rsip_unit_test.c index 4f437bc7df..1176faa4c6 100644 --- a/IDE/Renesas/e2studio/RZN2L/test/src/test/wolfssl_rsip_unit_test.c +++ b/IDE/Renesas/e2studio/RZN2L/test/src/test/wolfssl_rsip_unit_test.c @@ -1,6 +1,6 @@ /* wolfssl_sce_unit_test.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RZN2L/test/src/wolfssl_dummy.c b/IDE/Renesas/e2studio/RZN2L/test/src/wolfssl_dummy.c index 2b9642c0c5..94cdc9bbcf 100644 --- a/IDE/Renesas/e2studio/RZN2L/test/src/wolfssl_dummy.c +++ b/IDE/Renesas/e2studio/RZN2L/test/src/wolfssl_dummy.c @@ -1,6 +1,6 @@ /* wolfssl_dummy.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/STARCORE/starcore_test.c b/IDE/STARCORE/starcore_test.c index 72c3613f11..966b4b69f3 100644 --- a/IDE/STARCORE/starcore_test.c +++ b/IDE/STARCORE/starcore_test.c @@ -1,6 +1,6 @@ /* starcore_test.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/STARCORE/user_settings.h b/IDE/STARCORE/user_settings.h index e62f12d67a..8706865706 100644 --- a/IDE/STARCORE/user_settings.h +++ b/IDE/STARCORE/user_settings.h @@ -1,23 +1,23 @@ /* user_settings.h * -* Copyright (C) 2006-2023 wolfSSL Inc. -* -* This file is part of wolfSSL. -* -* wolfSSL is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* wolfSSL is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA -*/ + * Copyright (C) 2006-2024 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ /* Custom wolfSSL user settings for Vortec Scheduler, * VxWorks 6.9 and VxWorks 7.0 */ diff --git a/IDE/STM32Cube/default_conf.ftl b/IDE/STM32Cube/default_conf.ftl index 5e92dc1ddf..d7a68aac42 100644 --- a/IDE/STM32Cube/default_conf.ftl +++ b/IDE/STM32Cube/default_conf.ftl @@ -148,11 +148,11 @@ extern ${variable.value} ${variable.name}; #define HAL_CONSOLE_UART huart2 #define NO_STM32_RNG #define WOLFSSL_GENSEED_FORTEST /* no HW RNG is available use test seed */ -#elif defined(STM32U575xx) || defined(STM32U585xx) +#elif defined(STM32U575xx) || defined(STM32U585xx) || defined(STM32U5A9xx) #define HAL_CONSOLE_UART huart1 #define WOLFSSL_STM32U5 #define STM32_HAL_V2 - #ifdef STM32U585xx + #if defined(STM32U585xx) || defined(STM32U5A9xx) #undef NO_STM32_HASH #undef NO_STM32_CRYPTO #define WOLFSSL_STM32_PKA diff --git a/IDE/STM32Cube/main.c b/IDE/STM32Cube/main.c index f056c8cd6a..ddf81cbd3e 100644 --- a/IDE/STM32Cube/main.c +++ b/IDE/STM32Cube/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/STM32Cube/wolfssl_example.c b/IDE/STM32Cube/wolfssl_example.c index fc813483f1..ce67b0806d 100644 --- a/IDE/STM32Cube/wolfssl_example.c +++ b/IDE/STM32Cube/wolfssl_example.c @@ -1,6 +1,6 @@ /* wolfssl_example.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -284,7 +284,7 @@ typedef struct { typedef struct { int ret; - osThreadId threadId; + osThreadId_t threadId; #ifdef CMSIS_OS2_H_ osSemaphoreId_t mutex; #else diff --git a/IDE/STM32Cube/wolfssl_example.h b/IDE/STM32Cube/wolfssl_example.h index 5720511f30..792c7d9844 100644 --- a/IDE/STM32Cube/wolfssl_example.h +++ b/IDE/STM32Cube/wolfssl_example.h @@ -1,6 +1,6 @@ /* wolfssl_example.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -27,7 +27,7 @@ #endif #ifndef WOLFSSL_USER_SETTINGS - #include + #include #endif #include #include diff --git a/IDE/SimplicityStudio/test_wolf.c b/IDE/SimplicityStudio/test_wolf.c index e52266ac40..f05ee30476 100644 --- a/IDE/SimplicityStudio/test_wolf.c +++ b/IDE/SimplicityStudio/test_wolf.c @@ -1,6 +1,6 @@ /* test_wolf.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/SimplicityStudio/user_settings.h b/IDE/SimplicityStudio/user_settings.h index cfe138a695..a02cbd54d7 100644 --- a/IDE/SimplicityStudio/user_settings.h +++ b/IDE/SimplicityStudio/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/VS-AZURE-SPHERE/client/client.c b/IDE/VS-AZURE-SPHERE/client/client.c index 9a326e0695..920b8b7b6a 100644 --- a/IDE/VS-AZURE-SPHERE/client/client.c +++ b/IDE/VS-AZURE-SPHERE/client/client.c @@ -1,6 +1,6 @@ /* client.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/VS-AZURE-SPHERE/client/client.h b/IDE/VS-AZURE-SPHERE/client/client.h index f2d6fd805f..72a3f7b970 100644 --- a/IDE/VS-AZURE-SPHERE/client/client.h +++ b/IDE/VS-AZURE-SPHERE/client/client.h @@ -1,6 +1,6 @@ /* client.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/VS-AZURE-SPHERE/server/server.c b/IDE/VS-AZURE-SPHERE/server/server.c index aad4ef7235..39938a9c95 100644 --- a/IDE/VS-AZURE-SPHERE/server/server.c +++ b/IDE/VS-AZURE-SPHERE/server/server.c @@ -1,6 +1,6 @@ /* server.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/VS-AZURE-SPHERE/server/server.h b/IDE/VS-AZURE-SPHERE/server/server.h index 497a3c41ca..f43231682b 100644 --- a/IDE/VS-AZURE-SPHERE/server/server.h +++ b/IDE/VS-AZURE-SPHERE/server/server.h @@ -1,6 +1,6 @@ /* server.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/VS-AZURE-SPHERE/user_settings.h b/IDE/VS-AZURE-SPHERE/user_settings.h index 91de4d2513..a55c0b0915 100644 --- a/IDE/VS-AZURE-SPHERE/user_settings.h +++ b/IDE/VS-AZURE-SPHERE/user_settings.h @@ -7,9 +7,9 @@ #ifndef SERVER_IP #define SERVER_IP "192.168.1.200" /* Local Test Server IP */ #endif - #ifndef DEFAULT_PORT - #define DEFAULT_PORT 11111 - #endif + #ifndef DEFAULT_PORT + #define DEFAULT_PORT 11111 + #endif #define CERT ca_cert_der_2048 #define SIZEOF_CERT sizeof_ca_cert_der_2048 static const char msg[] = "Are you listening wolfSSL Server?"; @@ -17,9 +17,9 @@ #ifndef SERVER_IP #define SERVER_IP "www.wolfssl.com" #endif - #ifndef DEFAULT_PORT - #define DEFAULT_PORT 443 - #endif + #ifndef DEFAULT_PORT + #define DEFAULT_PORT 443 + #endif #define CERT wolfssl_website_root_ca #define SIZEOF_CERT sizeof_wolfssl_website_root_ca static const char msg[] = "GET /index.html HTTP/1.1\r\n\r\n"; diff --git a/IDE/VisualDSP/user_settings.h b/IDE/VisualDSP/user_settings.h index 2ce8e1eba0..40790b7e06 100644 --- a/IDE/VisualDSP/user_settings.h +++ b/IDE/VisualDSP/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/VisualDSP/wolf_tasks.c b/IDE/VisualDSP/wolf_tasks.c index 5d38879f4a..4fd316aa2a 100644 --- a/IDE/VisualDSP/wolf_tasks.c +++ b/IDE/VisualDSP/wolf_tasks.c @@ -1,6 +1,6 @@ /* wolf-tasks.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/WICED-STUDIO/user_settings.h b/IDE/WICED-STUDIO/user_settings.h index 70ce019d6e..927e7091f6 100644 --- a/IDE/WICED-STUDIO/user_settings.h +++ b/IDE/WICED-STUDIO/user_settings.h @@ -1,4 +1,4 @@ - /* Copyright (C) 2006-2018 wolfSSL Inc. + / * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/WINCE/user_settings.h b/IDE/WINCE/user_settings.h index 228ed9b739..02157f2a54 100644 --- a/IDE/WINCE/user_settings.h +++ b/IDE/WINCE/user_settings.h @@ -829,4 +829,4 @@ extern "C" { #endif -#endif /* WOLFSSL_USER_SETTINGS_H */ \ No newline at end of file +#endif /* WOLFSSL_USER_SETTINGS_H */ diff --git a/IDE/XCODE-FIPSv2/macOS-C++/Intel/user_settings.h b/IDE/XCODE-FIPSv2/macOS-C++/Intel/user_settings.h index 28df853cbf..615c8beb6e 100644 --- a/IDE/XCODE-FIPSv2/macOS-C++/Intel/user_settings.h +++ b/IDE/XCODE-FIPSv2/macOS-C++/Intel/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/XCODE-FIPSv2/macOS-C++/M1/user_settings.h b/IDE/XCODE-FIPSv2/macOS-C++/M1/user_settings.h index f7c5693cc9..494348d1b6 100644 --- a/IDE/XCODE-FIPSv2/macOS-C++/M1/user_settings.h +++ b/IDE/XCODE-FIPSv2/macOS-C++/M1/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/XCODE-FIPSv2/user_settings.h b/IDE/XCODE-FIPSv2/user_settings.h index 031f54b52b..030cd5807d 100644 --- a/IDE/XCODE-FIPSv2/user_settings.h +++ b/IDE/XCODE-FIPSv2/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/XCODE/Benchmark/wolfBench/AppDelegate.h b/IDE/XCODE/Benchmark/wolfBench/AppDelegate.h index 2feebb2112..f6a3eeee78 100644 --- a/IDE/XCODE/Benchmark/wolfBench/AppDelegate.h +++ b/IDE/XCODE/Benchmark/wolfBench/AppDelegate.h @@ -1,6 +1,6 @@ /* AppDelegate.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/XCODE/Benchmark/wolfBench/AppDelegate.m b/IDE/XCODE/Benchmark/wolfBench/AppDelegate.m index cfb4bd57f4..eb6a1d88ca 100644 --- a/IDE/XCODE/Benchmark/wolfBench/AppDelegate.m +++ b/IDE/XCODE/Benchmark/wolfBench/AppDelegate.m @@ -1,6 +1,6 @@ /* AppDelegate.m * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/XCODE/Benchmark/wolfBench/ViewController.h b/IDE/XCODE/Benchmark/wolfBench/ViewController.h index 2dc6e90fd6..d8f1a9a3e6 100644 --- a/IDE/XCODE/Benchmark/wolfBench/ViewController.h +++ b/IDE/XCODE/Benchmark/wolfBench/ViewController.h @@ -1,6 +1,6 @@ /* ViewController.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/XCODE/Benchmark/wolfBench/ViewController.m b/IDE/XCODE/Benchmark/wolfBench/ViewController.m index cf4f036925..94c3f63822 100644 --- a/IDE/XCODE/Benchmark/wolfBench/ViewController.m +++ b/IDE/XCODE/Benchmark/wolfBench/ViewController.m @@ -1,6 +1,6 @@ /* ViewController.m * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/XCODE/Benchmark/wolfBench/main.m b/IDE/XCODE/Benchmark/wolfBench/main.m index 8966a562db..bee606d429 100644 --- a/IDE/XCODE/Benchmark/wolfBench/main.m +++ b/IDE/XCODE/Benchmark/wolfBench/main.m @@ -1,6 +1,6 @@ /* main.m * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/XilinxSDK/user_settings.h b/IDE/XilinxSDK/user_settings.h index 1b0c324c41..39bb710bcc 100644 --- a/IDE/XilinxSDK/user_settings.h +++ b/IDE/XilinxSDK/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/XilinxSDK/wolfssl_example.c b/IDE/XilinxSDK/wolfssl_example.c index d111d2580b..ee11846825 100644 --- a/IDE/XilinxSDK/wolfssl_example.c +++ b/IDE/XilinxSDK/wolfssl_example.c @@ -1,6 +1,6 @@ /* wolfssl_example.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/apple-universal/build-wolfssl-framework.sh b/IDE/apple-universal/build-wolfssl-framework.sh index a3ff12a6cc..85763e281b 100755 --- a/IDE/apple-universal/build-wolfssl-framework.sh +++ b/IDE/apple-universal/build-wolfssl-framework.sh @@ -2,7 +2,7 @@ # build-wolfssl-framework.sh # -# Copyright (C) 2006-2023 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # # This file is part of wolfSSL. # diff --git a/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/ContentView.swift b/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/ContentView.swift index 6e452c5029..29ca2b4099 100644 --- a/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/ContentView.swift +++ b/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/ContentView.swift @@ -1,6 +1,6 @@ /* ContentView.swift * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/simple_client_example.c b/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/simple_client_example.c index b18d058da1..d97bf559f0 100644 --- a/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/simple_client_example.c +++ b/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/simple_client_example.c @@ -1,6 +1,6 @@ /* simple_client_example.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/simple_client_example.h b/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/simple_client_example.h index ce88958216..915f7cc2e5 100644 --- a/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/simple_client_example.h +++ b/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/simple_client_example.h @@ -1,6 +1,6 @@ /* simple_client_example.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl-multiplatform-Bridging-Header.h b/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl-multiplatform-Bridging-Header.h index f232f13bd0..e156376bb1 100644 --- a/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl-multiplatform-Bridging-Header.h +++ b/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl-multiplatform-Bridging-Header.h @@ -1,6 +1,6 @@ /* wolfssl-multiplatform-Bridging-Header.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl_multiplatformApp.swift b/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl_multiplatformApp.swift index acf2a03aac..6627afb345 100644 --- a/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl_multiplatformApp.swift +++ b/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl_multiplatformApp.swift @@ -1,6 +1,6 @@ /* wolfssl_multiplatformApp.swift * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl_test_driver.c b/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl_test_driver.c index 50655c834e..20f605ff7d 100644 --- a/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl_test_driver.c +++ b/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl_test_driver.c @@ -1,6 +1,6 @@ /* wolfssl_test_driver.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl_test_driver.h b/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl_test_driver.h index a3104e64ef..768518554e 100644 --- a/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl_test_driver.h +++ b/IDE/apple-universal/wolfssl-multiplatform/wolfssl-multiplatform/wolfssl_test_driver.h @@ -1,6 +1,6 @@ /* wolfssl_test_driver.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/iotsafe-raspberrypi/client-tls13.c b/IDE/iotsafe-raspberrypi/client-tls13.c index 91383d5d06..0bcad0b774 100644 --- a/IDE/iotsafe-raspberrypi/client-tls13.c +++ b/IDE/iotsafe-raspberrypi/client-tls13.c @@ -1,6 +1,6 @@ /* client-tls13.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/iotsafe-raspberrypi/main.c b/IDE/iotsafe-raspberrypi/main.c index f8cb3c51e8..aaa4129306 100644 --- a/IDE/iotsafe-raspberrypi/main.c +++ b/IDE/iotsafe-raspberrypi/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/iotsafe/ca-cert.c b/IDE/iotsafe/ca-cert.c index f8d75623c0..7b99b25cc1 100644 --- a/IDE/iotsafe/ca-cert.c +++ b/IDE/iotsafe/ca-cert.c @@ -1,6 +1,6 @@ /* ca-cert.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/iotsafe/devices.c b/IDE/iotsafe/devices.c index 59b739cf5d..83c6b58871 100644 --- a/IDE/iotsafe/devices.c +++ b/IDE/iotsafe/devices.c @@ -1,6 +1,6 @@ /* devices.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/iotsafe/devices.h b/IDE/iotsafe/devices.h index f19ae3b8ad..5752fb550e 100644 --- a/IDE/iotsafe/devices.h +++ b/IDE/iotsafe/devices.h @@ -1,6 +1,6 @@ /* devices.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -95,8 +95,8 @@ #define FLASH_ACR_LATENCY_MASK (0x03) /* RCC: Periph enable flags */ -#define USART1_APB2_CLOCK_ER_VAL (1 << 14) -#define USART2_APB1_CLOCK_ER_VAL (1 << 17) +#define USART1_APB2_CLOCK_ER_VAL (1 << 14) +#define USART2_APB1_CLOCK_ER_VAL (1 << 17) #define PWR_APB1_CLOCK_ER_VAL (1 << 28) #define GPIOA_AHB2_CLOCK_ER_VAL (1 << 0) #define GPIOB_AHB2_CLOCK_ER_VAL (1 << 1) @@ -208,11 +208,11 @@ #define SYSTICK_CALIB (*(volatile uint32_t *)(SYSTICK_BASE + 0x0C)) -/* STMod+ connector pinout +/* STMod+ connector pinout * * Connector STM32L4 * pins pins - * + * * 1 11 PG11 PH2 * 2 12 PB6 PB2 * 3 13 PG10 PA4 @@ -243,7 +243,7 @@ void stmod_modem_disable(void); /* inline functions for GPIO */ static inline void gpio_set(uint32_t port, uint32_t pin) { - GPIO_BSSR(port) |= (1 << pin); + GPIO_BSSR(port) |= (1 << pin); } static inline void gpio_clear(uint32_t port, uint32_t pin) diff --git a/IDE/iotsafe/main.c b/IDE/iotsafe/main.c index 90aa08da6e..df065551c0 100644 --- a/IDE/iotsafe/main.c +++ b/IDE/iotsafe/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/iotsafe/memory-tls.c b/IDE/iotsafe/memory-tls.c index 96d9216865..3d4bf088fb 100644 --- a/IDE/iotsafe/memory-tls.c +++ b/IDE/iotsafe/memory-tls.c @@ -1,6 +1,6 @@ /* memory-tls.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/iotsafe/startup.c b/IDE/iotsafe/startup.c index a5418b1ab6..2b0123a30a 100644 --- a/IDE/iotsafe/startup.c +++ b/IDE/iotsafe/startup.c @@ -1,6 +1,6 @@ /* startup.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/iotsafe/target.ld b/IDE/iotsafe/target.ld index df0f2272bc..0afe8a75ab 100644 --- a/IDE/iotsafe/target.ld +++ b/IDE/iotsafe/target.ld @@ -1,6 +1,6 @@ /* target.ld * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/iotsafe/user_settings.h b/IDE/iotsafe/user_settings.h index 3852464e82..368a76ed43 100644 --- a/IDE/iotsafe/user_settings.h +++ b/IDE/iotsafe/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/mynewt/apps.wolfcrypttest.pkg.yml b/IDE/mynewt/apps.wolfcrypttest.pkg.yml index c072dd50a2..f3392e93df 100644 --- a/IDE/mynewt/apps.wolfcrypttest.pkg.yml +++ b/IDE/mynewt/apps.wolfcrypttest.pkg.yml @@ -1,4 +1,4 @@ -# Copyright (C) 2006-2023 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # # This file is part of wolfSSL. # diff --git a/IDE/mynewt/crypto.wolfssl.pkg.yml b/IDE/mynewt/crypto.wolfssl.pkg.yml index ebb4bfaeb4..aa1b924bee 100644 --- a/IDE/mynewt/crypto.wolfssl.pkg.yml +++ b/IDE/mynewt/crypto.wolfssl.pkg.yml @@ -1,4 +1,4 @@ -# Copyright (C) 2006-2023 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # # This file is part of wolfSSL. # diff --git a/Makefile.am b/Makefile.am index 50a072c314..1d4f26c6b4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -207,7 +207,8 @@ if BUILD_LINUXKM SUBDIRS_OPT += linuxkm DIST_SUBDIRS_OPT += linuxkm - export KERNEL_ROOT KERNEL_ARCH KERNEL_EXTRA_CFLAGS \ + export build_triplet host_triplet CC AS LD \ + KERNEL_ROOT KERNEL_ARCH KERNEL_EXTRA_CFLAGS \ EXTRA_CFLAGS EXTRA_CPPFLAGS EXTRA_CCASFLAGS EXTRA_LDFLAGS \ AM_CPPFLAGS CPPFLAGS AM_CFLAGS CFLAGS \ AM_CCASFLAGS CCASFLAGS \ diff --git a/RTOS/nuttx/wolfssl/Make.defs b/RTOS/nuttx/wolfssl/Make.defs index 78ff34afe2..95e85e06b3 100644 --- a/RTOS/nuttx/wolfssl/Make.defs +++ b/RTOS/nuttx/wolfssl/Make.defs @@ -1,9 +1,9 @@ ############################################################################ # apps/crypto/wolfssl/Make.defs # -# Copyright (C) 2006-2023 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # -# This file is part of wolfSSL. (formerly known as CyaSSL) +# This file is part of wolfSSL. # # wolfSSL is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA # ############################################################################ diff --git a/RTOS/nuttx/wolfssl/Makefile b/RTOS/nuttx/wolfssl/Makefile index 0f2b7cfd4e..b9dd8c7793 100644 --- a/RTOS/nuttx/wolfssl/Makefile +++ b/RTOS/nuttx/wolfssl/Makefile @@ -1,9 +1,9 @@ ############################################################################ # apps/crypto/wolfssl/Makefile # -# Copyright (C) 2006-2023 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # -# This file is part of wolfSSL. (formerly known as CyaSSL) +# This file is part of wolfSSL. # # wolfSSL is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA # ############################################################################ diff --git a/certs/ecc/ca-secp256k1-cert.pem b/certs/ecc/ca-secp256k1-cert.pem new file mode 100644 index 0000000000..419d027346 --- /dev/null +++ b/certs/ecc/ca-secp256k1-cert.pem @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIICkTCCAjagAwIBAgIUcmBIdEUi0WtpofKM3r46Llhv86IwCgYIKoZIzj0EAwIw +gZYxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRAwDgYDVQQHDAdT +ZWF0dGxlMREwDwYDVQQKDAhFbGxpcHRpYzESMBAGA1UECwwJU0VDUDI1NksxMRgw +FgYDVQQDDA93d3cud29sZnNzbC5jb20xHzAdBgkqhkiG9w0BCQEWEGluZm9Ad29s +ZnNzbC5jb20wHhcNMjQwNzEyMDIxODUwWhcNNDQwNzA3MDIxODUwWjCBljELMAkG +A1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUx +ETAPBgNVBAoMCEVsbGlwdGljMRIwEAYDVQQLDAlTRUNQMjU2SzExGDAWBgNVBAMM +D3d3dy53b2xmc3NsLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNv +bTBWMBAGByqGSM49AgEGBSuBBAAKA0IABORg5kLTHlkHvjnrRKUTmBXLdhxkdsIC +s0ybo6r3oD6qGjX33FsBHp9nwos93gT7CECrexVlEUrH4wbfMN42+46jYzBhMB0G +A1UdDgQWBBRzL8o6Lcvi46LBqy81zGRTZIwGLTAfBgNVHSMEGDAWgBRzL8o6Lcvi +46LBqy81zGRTZIwGLTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAK +BggqhkjOPQQDAgNJADBGAiEA0dfMbQlfjY+VhKuDfluyBtoAsQA1BqJnV+XBayBx +HYYCIQCJr2YrYRwW4OvtP0yIqUH2fViOq12aqf1ByStksuL3mg== +-----END CERTIFICATE----- diff --git a/certs/ecc/ca-secp256k1-key.pem b/certs/ecc/ca-secp256k1-key.pem new file mode 100644 index 0000000000..1c2e0bc546 --- /dev/null +++ b/certs/ecc/ca-secp256k1-key.pem @@ -0,0 +1,5 @@ +-----BEGIN PRIVATE KEY----- +MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgoiOQsNn1L/vT3mU0e+Rz +LMlaDEIuKp6RHZhKrPnOJOShRANCAATkYOZC0x5ZB74560SlE5gVy3YcZHbCArNM +m6Oq96A+qho199xbAR6fZ8KLPd4E+whAq3sVZRFKx+MG3zDeNvuO +-----END PRIVATE KEY----- diff --git a/certs/ecc/genecc.sh b/certs/ecc/genecc.sh index f90c5cbe93..d068d0d028 100755 --- a/certs/ecc/genecc.sh +++ b/certs/ecc/genecc.sh @@ -140,6 +140,13 @@ openssl x509 -req -in ./certs/ecc/client-bp256r1-req.pem -days 3650 -extfile ./c openssl x509 -inform pem -in ./certs/ecc/client-bp256r1-cert.pem -outform der -out ./certs/ecc/client-bp256r1-cert.der rm ./certs/ecc/client-bp256r1-req.pem +# Create self-signed ECC secp256k1 (Koblitz) certificate +openssl req -config ./certs/ecc/wolfssl.cnf -extensions v3_ca -x509 -nodes -newkey ec:certs/ecc/secp256k1-param.pem -keyout ./certs/ecc/ca-secp256k1-key.pem -out ./certs/ecc/ca-secp256k1-cert.pem -sha256 -days 7300 -batch -subj "/C=US/ST=Washington/L=Seattle/O=Elliptic/OU=SECP256K1/CN=www.wolfssl.com/emailAddress=info@wolfssl.com" +# Create server ECC secp256k1 (Koblitz) certificate +openssl req -config ./certs/ecc/wolfssl.cnf -sha256 -new -key ./certs/ecc/secp256k1-privkey.pem -out ./certs/ecc/server2-secp256k1-req.pem -subj "/C=US/ST=Washington/L=Seattle/O=Elliptic/OU=SECP256K1-SVR/CN=www.wolfssl.com/emailAddress=info@wolfssl.com/" +openssl x509 -req -in ./certs/ecc/server2-secp256k1-req.pem -days 3650 -extfile ./certs/ecc/wolfssl.cnf -extensions server_cert -CAkey ./certs/ecc/ca-secp256k1-key.pem -CA ./certs/ecc/ca-secp256k1-cert.pem -text -out ./certs/ecc/server2-secp256k1-cert.pem +openssl x509 -inform pem -in ./certs/ecc/server2-secp256k1-cert.pem -outform der -out ./certs/ecc/server2-secp256k1-cert.der +rm ./certs/ecc/server2-secp256k1-req.pem # update bad certificate with last byte in signature changed cp ./certs/server-ecc.der ./certs/test/server-cert-ecc-badsig.der diff --git a/certs/ecc/include.am b/certs/ecc/include.am index c5a4f858aa..3408449acf 100644 --- a/certs/ecc/include.am +++ b/certs/ecc/include.am @@ -16,6 +16,13 @@ EXTRA_DIST += \ certs/ecc/server-secp256k1-cert.der \ certs/ecc/server-secp256k1-cert.pem +EXTRA_DIST += \ + certs/ecc/ca-secp256k1-cert.pem \ + certs/ecc/ca-secp256k1-key.pem \ + certs/ecc/secp256k1-param.pem \ + certs/ecc/secp256k1-privkey.pem \ + certs/ecc/server2-secp256k1-cert.pem + # Brainpool Curves EXTRA_DIST += \ certs/ecc/bp256r1-key.der \ diff --git a/certs/ecc/secp256k1-param.pem b/certs/ecc/secp256k1-param.pem new file mode 100644 index 0000000000..32d952ea91 --- /dev/null +++ b/certs/ecc/secp256k1-param.pem @@ -0,0 +1,3 @@ +-----BEGIN EC PARAMETERS----- +BgUrgQQACg== +-----END EC PARAMETERS----- diff --git a/certs/ecc/secp256k1-privkey.der b/certs/ecc/secp256k1-privkey.der new file mode 100644 index 0000000000..74e151bc51 Binary files /dev/null and b/certs/ecc/secp256k1-privkey.der differ diff --git a/certs/ecc/secp256k1-privkey.pem b/certs/ecc/secp256k1-privkey.pem new file mode 100644 index 0000000000..c229ff83cf --- /dev/null +++ b/certs/ecc/secp256k1-privkey.pem @@ -0,0 +1,5 @@ +-----BEGIN PRIVATE KEY----- +MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgwdc3WnnD2eX1ti0IbCT5 +POy/xb1WDV8/7BgQd37MsWGhRANCAARvf9jvkv6kKKkzhWmk6OM3Rjmivo8mMVkg +itdbdHrKAV5UT9zS0qXbHo7mlPZOOejEsodSk9yvzjAAnHnSSASY +-----END PRIVATE KEY----- diff --git a/certs/ecc/server2-secp256k1-cert.der b/certs/ecc/server2-secp256k1-cert.der new file mode 100644 index 0000000000..d3c0c1cff4 Binary files /dev/null and b/certs/ecc/server2-secp256k1-cert.der differ diff --git a/certs/ecc/server2-secp256k1-cert.pem b/certs/ecc/server2-secp256k1-cert.pem new file mode 100644 index 0000000000..08a8ee9b52 --- /dev/null +++ b/certs/ecc/server2-secp256k1-cert.pem @@ -0,0 +1,63 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + 23:8d:e3:d0:5a:a6:1f:e6:d3:b6:4c:e0:a2:a1:dd:2f:ee:35:b2:bb + Signature Algorithm: ecdsa-with-SHA256 + Issuer: C=US, ST=Washington, L=Seattle, O=Elliptic, OU=SECP256K1, CN=www.wolfssl.com, emailAddress=info@wolfssl.com + Validity + Not Before: Jul 15 05:41:52 2024 GMT + Not After : Jul 13 05:41:52 2034 GMT + Subject: C=US, ST=Washington, L=Seattle, O=Elliptic, OU=SECP256K1-SVR, CN=www.wolfssl.com, emailAddress=info@wolfssl.com + Subject Public Key Info: + Public Key Algorithm: id-ecPublicKey + Public-Key: (256 bit) + pub: + 04:6f:7f:d8:ef:92:fe:a4:28:a9:33:85:69:a4:e8: + e3:37:46:39:a2:be:8f:26:31:59:20:8a:d7:5b:74: + 7a:ca:01:5e:54:4f:dc:d2:d2:a5:db:1e:8e:e6:94: + f6:4e:39:e8:c4:b2:87:52:93:dc:af:ce:30:00:9c: + 79:d2:48:04:98 + ASN1 OID: secp256k1 + X509v3 extensions: + X509v3 Basic Constraints: + CA:FALSE + Netscape Cert Type: + SSL Server + X509v3 Subject Key Identifier: + F4:A3:FD:34:57:E6:51:1F:0A:96:2F:F0:87:A9:7C:C7:EB:6B:34:8F + X509v3 Authority Key Identifier: + keyid:73:2F:CA:3A:2D:CB:E2:E3:A2:C1:AB:2F:35:CC:64:53:64:8C:06:2D + DirName:/C=US/ST=Washington/L=Seattle/O=Elliptic/OU=SECP256K1/CN=www.wolfssl.com/emailAddress=info@wolfssl.com + serial:72:60:48:74:45:22:D1:6B:69:A1:F2:8C:DE:BE:3A:2E:58:6F:F3:A2 + X509v3 Key Usage: critical + Digital Signature, Key Encipherment, Key Agreement + X509v3 Extended Key Usage: + TLS Web Server Authentication + Signature Algorithm: ecdsa-with-SHA256 + Signature Value: + 30:44:02:20:3d:12:5a:0c:7a:1b:ff:b5:a6:70:8a:70:33:03: + 6c:d9:9c:98:8b:80:1b:70:3b:15:3a:85:7e:23:8a:85:f0:76: + 02:20:02:ca:71:2c:cc:5a:c2:a8:e2:c5:24:62:06:62:a0:53: + 41:2a:bb:2e:88:9f:f0:b4:bd:dc:23:1c:06:4c:18:a2 +-----BEGIN CERTIFICATE----- +MIIDcTCCAxigAwIBAgIUI43j0FqmH+bTtkzgoqHdL+41srswCgYIKoZIzj0EAwIw +gZYxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRAwDgYDVQQHDAdT +ZWF0dGxlMREwDwYDVQQKDAhFbGxpcHRpYzESMBAGA1UECwwJU0VDUDI1NksxMRgw +FgYDVQQDDA93d3cud29sZnNzbC5jb20xHzAdBgkqhkiG9w0BCQEWEGluZm9Ad29s +ZnNzbC5jb20wHhcNMjQwNzE1MDU0MTUyWhcNMzQwNzEzMDU0MTUyWjCBmjELMAkG +A1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUx +ETAPBgNVBAoMCEVsbGlwdGljMRYwFAYDVQQLDA1TRUNQMjU2SzEtU1ZSMRgwFgYD +VQQDDA93d3cud29sZnNzbC5jb20xHzAdBgkqhkiG9w0BCQEWEGluZm9Ad29sZnNz +bC5jb20wVjAQBgcqhkjOPQIBBgUrgQQACgNCAARvf9jvkv6kKKkzhWmk6OM3Rjmi +vo8mMVkgitdbdHrKAV5UT9zS0qXbHo7mlPZOOejEsodSk9yvzjAAnHnSSASYo4IB +PzCCATswCQYDVR0TBAIwADARBglghkgBhvhCAQEEBAMCBkAwHQYDVR0OBBYEFPSj +/TRX5lEfCpYv8IepfMfrazSPMIHWBgNVHSMEgc4wgcuAFHMvyjoty+LjosGrLzXM +ZFNkjAYtoYGcpIGZMIGWMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2FzaGluZ3Rv +bjEQMA4GA1UEBwwHU2VhdHRsZTERMA8GA1UECgwIRWxsaXB0aWMxEjAQBgNVBAsM +CVNFQ1AyNTZLMTEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29tMR8wHQYJKoZIhvcN +AQkBFhBpbmZvQHdvbGZzc2wuY29tghRyYEh0RSLRa2mh8ozevjouWG/zojAOBgNV +HQ8BAf8EBAMCA6gwEwYDVR0lBAwwCgYIKwYBBQUHAwEwCgYIKoZIzj0EAwIDRwAw +RAIgPRJaDHob/7WmcIpwMwNs2ZyYi4AbcDsVOoV+I4qF8HYCIALKcSzMWsKo4sUk +YgZioFNBKrsuiJ/wtL3cIxwGTBii +-----END CERTIFICATE----- diff --git a/certs/test/cert-over-max-altnames.cfg b/certs/test/cert-over-max-altnames.cfg index 472fa20f32..5aa44eb751 100644 --- a/certs/test/cert-over-max-altnames.cfg +++ b/certs/test/cert-over-max-altnames.cfg @@ -146,5 +146,925 @@ DNS.127 = example127.com DNS.128 = example128.com DNS.129 = example129.com DNS.130 = example130.com +DNS.131 = example131.com +DNS.132 = example132.com +DNS.133 = example133.com +DNS.134 = example134.com +DNS.135 = example135.com +DNS.136 = example136.com +DNS.137 = example137.com +DNS.138 = example138.com +DNS.139 = example139.com +DNS.140 = example140.com +DNS.141 = example141.com +DNS.142 = example142.com +DNS.143 = example143.com +DNS.144 = example144.com +DNS.145 = example145.com +DNS.146 = example146.com +DNS.147 = example147.com +DNS.148 = example148.com +DNS.149 = example149.com +DNS.150 = example150.com +DNS.151 = example151.com +DNS.152 = example152.com +DNS.153 = example153.com +DNS.154 = example154.com +DNS.155 = example155.com +DNS.156 = example156.com +DNS.157 = example157.com +DNS.158 = example158.com +DNS.159 = example159.com +DNS.160 = example160.com +DNS.161 = example161.com +DNS.162 = example162.com +DNS.163 = example163.com +DNS.164 = example164.com +DNS.165 = example165.com +DNS.166 = example166.com +DNS.167 = example167.com +DNS.168 = example168.com +DNS.169 = example169.com +DNS.170 = example170.com +DNS.171 = example171.com +DNS.172 = example172.com +DNS.173 = example173.com +DNS.174 = example174.com +DNS.175 = example175.com +DNS.176 = example176.com +DNS.177 = example177.com +DNS.178 = example178.com +DNS.179 = example179.com +DNS.180 = example180.com +DNS.181 = example181.com +DNS.182 = example182.com +DNS.183 = example183.com +DNS.184 = example184.com +DNS.185 = example185.com +DNS.186 = example186.com +DNS.187 = example187.com +DNS.188 = example188.com +DNS.189 = example189.com +DNS.190 = example190.com +DNS.191 = example191.com +DNS.192 = example192.com +DNS.193 = example193.com +DNS.194 = example194.com +DNS.195 = example195.com +DNS.196 = example196.com +DNS.197 = example197.com +DNS.198 = example198.com +DNS.199 = example199.com +DNS.200 = example200.com +DNS.201 = example201.com +DNS.202 = example202.com +DNS.203 = example203.com +DNS.204 = example204.com +DNS.205 = example205.com +DNS.206 = example206.com +DNS.207 = example207.com +DNS.208 = example208.com +DNS.209 = example209.com +DNS.210 = example210.com +DNS.211 = example211.com +DNS.212 = example212.com +DNS.213 = example213.com +DNS.214 = example214.com +DNS.215 = example215.com +DNS.216 = example216.com +DNS.217 = example217.com +DNS.218 = example218.com +DNS.219 = example219.com +DNS.220 = example220.com +DNS.221 = example221.com +DNS.222 = example222.com +DNS.223 = example223.com +DNS.224 = example224.com +DNS.225 = example225.com +DNS.226 = example226.com +DNS.227 = example227.com +DNS.228 = example228.com +DNS.229 = example229.com +DNS.230 = example230.com +DNS.231 = example231.com +DNS.232 = example232.com +DNS.233 = example233.com +DNS.234 = example234.com +DNS.235 = example235.com +DNS.236 = example236.com +DNS.237 = example237.com +DNS.238 = example238.com +DNS.239 = example239.com +DNS.240 = example240.com +DNS.241 = example241.com +DNS.242 = example242.com +DNS.243 = example243.com +DNS.244 = example244.com +DNS.245 = example245.com +DNS.246 = example246.com +DNS.247 = example247.com +DNS.248 = example248.com +DNS.249 = example249.com +DNS.250 = example250.com +DNS.251 = example251.com +DNS.252 = example252.com +DNS.253 = example253.com +DNS.254 = example254.com +DNS.255 = example255.com +DNS.256 = example256.com +DNS.257 = example257.com +DNS.258 = example258.com +DNS.259 = example259.com +DNS.260 = example260.com +DNS.261 = example261.com +DNS.262 = example262.com +DNS.263 = example263.com +DNS.264 = example264.com +DNS.265 = example265.com +DNS.266 = example266.com +DNS.267 = example267.com +DNS.268 = example268.com +DNS.269 = example269.com +DNS.270 = example270.com +DNS.271 = example271.com +DNS.272 = example272.com +DNS.273 = example273.com +DNS.274 = example274.com +DNS.275 = example275.com +DNS.276 = example276.com +DNS.277 = example277.com +DNS.278 = example278.com +DNS.279 = example279.com +DNS.280 = example280.com +DNS.281 = example281.com +DNS.282 = example282.com +DNS.283 = example283.com +DNS.284 = example284.com +DNS.285 = example285.com +DNS.286 = example286.com +DNS.287 = example287.com +DNS.288 = example288.com +DNS.289 = example289.com +DNS.290 = example290.com +DNS.291 = example291.com +DNS.292 = example292.com +DNS.293 = example293.com +DNS.294 = example294.com +DNS.295 = example295.com +DNS.296 = example296.com +DNS.297 = example297.com +DNS.298 = example298.com +DNS.299 = example299.com +DNS.300 = example300.com +DNS.301 = example301.com +DNS.302 = example302.com +DNS.303 = example303.com +DNS.304 = example304.com +DNS.305 = example305.com +DNS.306 = example306.com +DNS.307 = example307.com +DNS.308 = example308.com +DNS.309 = example309.com +DNS.310 = example310.com +DNS.311 = example311.com +DNS.312 = example312.com +DNS.313 = example313.com +DNS.314 = example314.com +DNS.315 = example315.com +DNS.316 = example316.com +DNS.317 = example317.com +DNS.318 = example318.com +DNS.319 = example319.com +DNS.320 = example320.com +DNS.321 = example321.com +DNS.322 = example322.com +DNS.323 = example323.com +DNS.324 = example324.com +DNS.325 = example325.com +DNS.326 = example326.com +DNS.327 = example327.com +DNS.328 = example328.com +DNS.329 = example329.com +DNS.330 = example330.com +DNS.331 = example331.com +DNS.332 = example332.com +DNS.333 = example333.com +DNS.334 = example334.com +DNS.335 = example335.com +DNS.336 = example336.com +DNS.337 = example337.com +DNS.338 = example338.com +DNS.339 = example339.com +DNS.340 = example340.com +DNS.341 = example341.com +DNS.342 = example342.com +DNS.343 = example343.com +DNS.344 = example344.com +DNS.345 = example345.com +DNS.346 = example346.com +DNS.347 = example347.com +DNS.348 = example348.com +DNS.349 = example349.com +DNS.350 = example350.com +DNS.351 = example351.com +DNS.352 = example352.com +DNS.353 = example353.com +DNS.354 = example354.com +DNS.355 = example355.com +DNS.356 = example356.com +DNS.357 = example357.com +DNS.358 = example358.com +DNS.359 = example359.com +DNS.360 = example360.com +DNS.361 = example361.com +DNS.362 = example362.com +DNS.363 = example363.com +DNS.364 = example364.com +DNS.365 = example365.com +DNS.366 = example366.com +DNS.367 = example367.com +DNS.368 = example368.com +DNS.369 = example369.com +DNS.370 = example370.com +DNS.371 = example371.com +DNS.372 = example372.com +DNS.373 = example373.com +DNS.374 = example374.com +DNS.375 = example375.com +DNS.376 = example376.com +DNS.377 = example377.com +DNS.378 = example378.com +DNS.379 = example379.com +DNS.380 = example380.com +DNS.381 = example381.com +DNS.382 = example382.com +DNS.383 = example383.com +DNS.384 = example384.com +DNS.385 = example385.com +DNS.386 = example386.com +DNS.387 = example387.com +DNS.388 = example388.com +DNS.389 = example389.com +DNS.390 = example390.com +DNS.391 = example391.com +DNS.392 = example392.com +DNS.393 = example393.com +DNS.394 = example394.com +DNS.395 = example395.com +DNS.396 = example396.com +DNS.397 = example397.com +DNS.398 = example398.com +DNS.399 = example399.com +DNS.400 = example400.com +DNS.401 = example401.com +DNS.402 = example402.com +DNS.403 = example403.com +DNS.404 = example404.com +DNS.405 = example405.com +DNS.406 = example406.com +DNS.407 = example407.com +DNS.408 = example408.com +DNS.409 = example409.com +DNS.410 = example410.com +DNS.411 = example411.com +DNS.412 = example412.com +DNS.413 = example413.com +DNS.414 = example414.com +DNS.415 = example415.com +DNS.416 = example416.com +DNS.417 = example417.com +DNS.418 = example418.com +DNS.419 = example419.com +DNS.420 = example420.com +DNS.421 = example421.com +DNS.422 = example422.com +DNS.423 = example423.com +DNS.424 = example424.com +DNS.425 = example425.com +DNS.426 = example426.com +DNS.427 = example427.com +DNS.428 = example428.com +DNS.429 = example429.com +DNS.430 = example430.com +DNS.431 = example431.com +DNS.432 = example432.com +DNS.433 = example433.com +DNS.434 = example434.com +DNS.435 = example435.com +DNS.436 = example436.com +DNS.437 = example437.com +DNS.438 = example438.com +DNS.439 = example439.com +DNS.440 = example440.com +DNS.441 = example441.com +DNS.442 = example442.com +DNS.443 = example443.com +DNS.444 = example444.com +DNS.445 = example445.com +DNS.446 = example446.com +DNS.447 = example447.com +DNS.448 = example448.com +DNS.449 = example449.com +DNS.450 = example450.com +DNS.451 = example451.com +DNS.452 = example452.com +DNS.453 = example453.com +DNS.454 = example454.com +DNS.455 = example455.com +DNS.456 = example456.com +DNS.457 = example457.com +DNS.458 = example458.com +DNS.459 = example459.com +DNS.460 = example460.com +DNS.461 = example461.com +DNS.462 = example462.com +DNS.463 = example463.com +DNS.464 = example464.com +DNS.465 = example465.com +DNS.466 = example466.com +DNS.467 = example467.com +DNS.468 = example468.com +DNS.469 = example469.com +DNS.470 = example470.com +DNS.471 = example471.com +DNS.472 = example472.com +DNS.473 = example473.com +DNS.474 = example474.com +DNS.475 = example475.com +DNS.476 = example476.com +DNS.477 = example477.com +DNS.478 = example478.com +DNS.479 = example479.com +DNS.480 = example480.com +DNS.481 = example481.com +DNS.482 = example482.com +DNS.483 = example483.com +DNS.484 = example484.com +DNS.485 = example485.com +DNS.486 = example486.com +DNS.487 = example487.com +DNS.488 = example488.com +DNS.489 = example489.com +DNS.490 = example490.com +DNS.491 = example491.com +DNS.492 = example492.com +DNS.493 = example493.com +DNS.494 = example494.com +DNS.495 = example495.com +DNS.496 = example496.com +DNS.497 = example497.com +DNS.498 = example498.com +DNS.499 = example499.com +DNS.500 = example500.com +DNS.501 = example501.com +DNS.502 = example502.com +DNS.503 = example503.com +DNS.504 = example504.com +DNS.505 = example505.com +DNS.506 = example506.com +DNS.507 = example507.com +DNS.508 = example508.com +DNS.509 = example509.com +DNS.510 = example510.com +DNS.511 = example511.com +DNS.512 = example512.com +DNS.513 = example513.com +DNS.514 = example514.com +DNS.515 = example515.com +DNS.516 = example516.com +DNS.517 = example517.com +DNS.518 = example518.com +DNS.519 = example519.com +DNS.520 = example520.com +DNS.521 = example521.com +DNS.522 = example522.com +DNS.523 = example523.com +DNS.524 = example524.com +DNS.525 = example525.com +DNS.526 = example526.com +DNS.527 = example527.com +DNS.528 = example528.com +DNS.529 = example529.com +DNS.530 = example530.com +DNS.531 = example531.com +DNS.532 = example532.com +DNS.533 = example533.com +DNS.534 = example534.com +DNS.535 = example535.com +DNS.536 = example536.com +DNS.537 = example537.com +DNS.538 = example538.com +DNS.539 = example539.com +DNS.540 = example540.com +DNS.541 = example541.com +DNS.542 = example542.com +DNS.543 = example543.com +DNS.544 = example544.com +DNS.545 = example545.com +DNS.546 = example546.com +DNS.547 = example547.com +DNS.548 = example548.com +DNS.549 = example549.com +DNS.550 = example550.com +DNS.551 = example551.com +DNS.552 = example552.com +DNS.553 = example553.com +DNS.554 = example554.com +DNS.555 = example555.com +DNS.556 = example556.com +DNS.557 = example557.com +DNS.558 = example558.com +DNS.559 = example559.com +DNS.560 = example560.com +DNS.561 = example561.com +DNS.562 = example562.com +DNS.563 = example563.com +DNS.564 = example564.com +DNS.565 = example565.com +DNS.566 = example566.com +DNS.567 = example567.com +DNS.568 = example568.com +DNS.569 = example569.com +DNS.570 = example570.com +DNS.571 = example571.com +DNS.572 = example572.com +DNS.573 = example573.com +DNS.574 = example574.com +DNS.575 = example575.com +DNS.576 = example576.com +DNS.577 = example577.com +DNS.578 = example578.com +DNS.579 = example579.com +DNS.580 = example580.com +DNS.581 = example581.com +DNS.582 = example582.com +DNS.583 = example583.com +DNS.584 = example584.com +DNS.585 = example585.com +DNS.586 = example586.com +DNS.587 = example587.com +DNS.588 = example588.com +DNS.589 = example589.com +DNS.590 = example590.com +DNS.591 = example591.com +DNS.592 = example592.com +DNS.593 = example593.com +DNS.594 = example594.com +DNS.595 = example595.com +DNS.596 = example596.com +DNS.597 = example597.com +DNS.598 = example598.com +DNS.599 = example599.com +DNS.600 = example600.com +DNS.601 = example601.com +DNS.602 = example602.com +DNS.603 = example603.com +DNS.604 = example604.com +DNS.605 = example605.com +DNS.606 = example606.com +DNS.607 = example607.com +DNS.608 = example608.com +DNS.609 = example609.com +DNS.610 = example610.com +DNS.611 = example611.com +DNS.612 = example612.com +DNS.613 = example613.com +DNS.614 = example614.com +DNS.615 = example615.com +DNS.616 = example616.com +DNS.617 = example617.com +DNS.618 = example618.com +DNS.619 = example619.com +DNS.620 = example620.com +DNS.621 = example621.com +DNS.622 = example622.com +DNS.623 = example623.com +DNS.624 = example624.com +DNS.625 = example625.com +DNS.626 = example626.com +DNS.627 = example627.com +DNS.628 = example628.com +DNS.629 = example629.com +DNS.630 = example630.com +DNS.631 = example631.com +DNS.632 = example632.com +DNS.633 = example633.com +DNS.634 = example634.com +DNS.635 = example635.com +DNS.636 = example636.com +DNS.637 = example637.com +DNS.638 = example638.com +DNS.639 = example639.com +DNS.640 = example640.com +DNS.641 = example641.com +DNS.642 = example642.com +DNS.643 = example643.com +DNS.644 = example644.com +DNS.645 = example645.com +DNS.646 = example646.com +DNS.647 = example647.com +DNS.648 = example648.com +DNS.649 = example649.com +DNS.650 = example650.com +DNS.651 = example651.com +DNS.652 = example652.com +DNS.653 = example653.com +DNS.654 = example654.com +DNS.655 = example655.com +DNS.656 = example656.com +DNS.657 = example657.com +DNS.658 = example658.com +DNS.659 = example659.com +DNS.660 = example660.com +DNS.661 = example661.com +DNS.662 = example662.com +DNS.663 = example663.com +DNS.664 = example664.com +DNS.665 = example665.com +DNS.666 = example666.com +DNS.667 = example667.com +DNS.668 = example668.com +DNS.669 = example669.com +DNS.670 = example670.com +DNS.671 = example671.com +DNS.672 = example672.com +DNS.673 = example673.com +DNS.674 = example674.com +DNS.675 = example675.com +DNS.676 = example676.com +DNS.677 = example677.com +DNS.678 = example678.com +DNS.679 = example679.com +DNS.680 = example680.com +DNS.681 = example681.com +DNS.682 = example682.com +DNS.683 = example683.com +DNS.684 = example684.com +DNS.685 = example685.com +DNS.686 = example686.com +DNS.687 = example687.com +DNS.688 = example688.com +DNS.689 = example689.com +DNS.690 = example690.com +DNS.691 = example691.com +DNS.692 = example692.com +DNS.693 = example693.com +DNS.694 = example694.com +DNS.695 = example695.com +DNS.696 = example696.com +DNS.697 = example697.com +DNS.698 = example698.com +DNS.699 = example699.com +DNS.700 = example700.com +DNS.701 = example701.com +DNS.702 = example702.com +DNS.703 = example703.com +DNS.704 = example704.com +DNS.705 = example705.com +DNS.706 = example706.com +DNS.707 = example707.com +DNS.708 = example708.com +DNS.709 = example709.com +DNS.710 = example710.com +DNS.711 = example711.com +DNS.712 = example712.com +DNS.713 = example713.com +DNS.714 = example714.com +DNS.715 = example715.com +DNS.716 = example716.com +DNS.717 = example717.com +DNS.718 = example718.com +DNS.719 = example719.com +DNS.720 = example720.com +DNS.721 = example721.com +DNS.722 = example722.com +DNS.723 = example723.com +DNS.724 = example724.com +DNS.725 = example725.com +DNS.726 = example726.com +DNS.727 = example727.com +DNS.728 = example728.com +DNS.729 = example729.com +DNS.730 = example730.com +DNS.731 = example731.com +DNS.732 = example732.com +DNS.733 = example733.com +DNS.734 = example734.com +DNS.735 = example735.com +DNS.736 = example736.com +DNS.737 = example737.com +DNS.738 = example738.com +DNS.739 = example739.com +DNS.740 = example740.com +DNS.741 = example741.com +DNS.742 = example742.com +DNS.743 = example743.com +DNS.744 = example744.com +DNS.745 = example745.com +DNS.746 = example746.com +DNS.747 = example747.com +DNS.748 = example748.com +DNS.749 = example749.com +DNS.750 = example750.com +DNS.751 = example751.com +DNS.752 = example752.com +DNS.753 = example753.com +DNS.754 = example754.com +DNS.755 = example755.com +DNS.756 = example756.com +DNS.757 = example757.com +DNS.758 = example758.com +DNS.759 = example759.com +DNS.760 = example760.com +DNS.761 = example761.com +DNS.762 = example762.com +DNS.763 = example763.com +DNS.764 = example764.com +DNS.765 = example765.com +DNS.766 = example766.com +DNS.767 = example767.com +DNS.768 = example768.com +DNS.769 = example769.com +DNS.770 = example770.com +DNS.771 = example771.com +DNS.772 = example772.com +DNS.773 = example773.com +DNS.774 = example774.com +DNS.775 = example775.com +DNS.776 = example776.com +DNS.777 = example777.com +DNS.778 = example778.com +DNS.779 = example779.com +DNS.780 = example780.com +DNS.781 = example781.com +DNS.782 = example782.com +DNS.783 = example783.com +DNS.784 = example784.com +DNS.785 = example785.com +DNS.786 = example786.com +DNS.787 = example787.com +DNS.788 = example788.com +DNS.789 = example789.com +DNS.790 = example790.com +DNS.791 = example791.com +DNS.792 = example792.com +DNS.793 = example793.com +DNS.794 = example794.com +DNS.795 = example795.com +DNS.796 = example796.com +DNS.797 = example797.com +DNS.798 = example798.com +DNS.799 = example799.com +DNS.800 = example800.com +DNS.801 = example801.com +DNS.802 = example802.com +DNS.803 = example803.com +DNS.804 = example804.com +DNS.805 = example805.com +DNS.806 = example806.com +DNS.807 = example807.com +DNS.808 = example808.com +DNS.809 = example809.com +DNS.810 = example810.com +DNS.811 = example811.com +DNS.812 = example812.com +DNS.813 = example813.com +DNS.814 = example814.com +DNS.815 = example815.com +DNS.816 = example816.com +DNS.817 = example817.com +DNS.818 = example818.com +DNS.819 = example819.com +DNS.820 = example820.com +DNS.821 = example821.com +DNS.822 = example822.com +DNS.823 = example823.com +DNS.824 = example824.com +DNS.825 = example825.com +DNS.826 = example826.com +DNS.827 = example827.com +DNS.828 = example828.com +DNS.829 = example829.com +DNS.830 = example830.com +DNS.831 = example831.com +DNS.832 = example832.com +DNS.833 = example833.com +DNS.834 = example834.com +DNS.835 = example835.com +DNS.836 = example836.com +DNS.837 = example837.com +DNS.838 = example838.com +DNS.839 = example839.com +DNS.840 = example840.com +DNS.841 = example841.com +DNS.842 = example842.com +DNS.843 = example843.com +DNS.844 = example844.com +DNS.845 = example845.com +DNS.846 = example846.com +DNS.847 = example847.com +DNS.848 = example848.com +DNS.849 = example849.com +DNS.850 = example850.com +DNS.851 = example851.com +DNS.852 = example852.com +DNS.853 = example853.com +DNS.854 = example854.com +DNS.855 = example855.com +DNS.856 = example856.com +DNS.857 = example857.com +DNS.858 = example858.com +DNS.859 = example859.com +DNS.860 = example860.com +DNS.861 = example861.com +DNS.862 = example862.com +DNS.863 = example863.com +DNS.864 = example864.com +DNS.865 = example865.com +DNS.866 = example866.com +DNS.867 = example867.com +DNS.868 = example868.com +DNS.869 = example869.com +DNS.870 = example870.com +DNS.871 = example871.com +DNS.872 = example872.com +DNS.873 = example873.com +DNS.874 = example874.com +DNS.875 = example875.com +DNS.876 = example876.com +DNS.877 = example877.com +DNS.878 = example878.com +DNS.879 = example879.com +DNS.880 = example880.com +DNS.881 = example881.com +DNS.882 = example882.com +DNS.883 = example883.com +DNS.884 = example884.com +DNS.885 = example885.com +DNS.886 = example886.com +DNS.887 = example887.com +DNS.888 = example888.com +DNS.889 = example889.com +DNS.890 = example890.com +DNS.891 = example891.com +DNS.892 = example892.com +DNS.893 = example893.com +DNS.894 = example894.com +DNS.895 = example895.com +DNS.896 = example896.com +DNS.897 = example897.com +DNS.898 = example898.com +DNS.899 = example899.com +DNS.900 = example900.com +DNS.901 = example901.com +DNS.902 = example902.com +DNS.903 = example903.com +DNS.904 = example904.com +DNS.905 = example905.com +DNS.906 = example906.com +DNS.907 = example907.com +DNS.908 = example908.com +DNS.909 = example909.com +DNS.910 = example910.com +DNS.911 = example911.com +DNS.912 = example912.com +DNS.913 = example913.com +DNS.914 = example914.com +DNS.915 = example915.com +DNS.916 = example916.com +DNS.917 = example917.com +DNS.918 = example918.com +DNS.919 = example919.com +DNS.920 = example920.com +DNS.921 = example921.com +DNS.922 = example922.com +DNS.923 = example923.com +DNS.924 = example924.com +DNS.925 = example925.com +DNS.926 = example926.com +DNS.927 = example927.com +DNS.928 = example928.com +DNS.929 = example929.com +DNS.930 = example930.com +DNS.931 = example931.com +DNS.932 = example932.com +DNS.933 = example933.com +DNS.934 = example934.com +DNS.935 = example935.com +DNS.936 = example936.com +DNS.937 = example937.com +DNS.938 = example938.com +DNS.939 = example939.com +DNS.940 = example940.com +DNS.941 = example941.com +DNS.942 = example942.com +DNS.943 = example943.com +DNS.944 = example944.com +DNS.945 = example945.com +DNS.946 = example946.com +DNS.947 = example947.com +DNS.948 = example948.com +DNS.949 = example949.com +DNS.950 = example950.com +DNS.951 = example951.com +DNS.952 = example952.com +DNS.953 = example953.com +DNS.954 = example954.com +DNS.955 = example955.com +DNS.956 = example956.com +DNS.957 = example957.com +DNS.958 = example958.com +DNS.959 = example959.com +DNS.960 = example960.com +DNS.961 = example961.com +DNS.962 = example962.com +DNS.963 = example963.com +DNS.964 = example964.com +DNS.965 = example965.com +DNS.966 = example966.com +DNS.967 = example967.com +DNS.968 = example968.com +DNS.969 = example969.com +DNS.970 = example970.com +DNS.971 = example971.com +DNS.972 = example972.com +DNS.973 = example973.com +DNS.974 = example974.com +DNS.975 = example975.com +DNS.976 = example976.com +DNS.977 = example977.com +DNS.978 = example978.com +DNS.979 = example979.com +DNS.980 = example980.com +DNS.981 = example981.com +DNS.982 = example982.com +DNS.983 = example983.com +DNS.984 = example984.com +DNS.985 = example985.com +DNS.986 = example986.com +DNS.987 = example987.com +DNS.988 = example988.com +DNS.989 = example989.com +DNS.990 = example990.com +DNS.991 = example991.com +DNS.992 = example992.com +DNS.993 = example993.com +DNS.994 = example994.com +DNS.995 = example995.com +DNS.996 = example996.com +DNS.997 = example997.com +DNS.998 = example998.com +DNS.999 = example999.com +DNS.1000 = example1000.com +DNS.1001 = example1001.com +DNS.1002 = example1002.com +DNS.1003 = example1003.com +DNS.1004 = example1004.com +DNS.1005 = example1005.com +DNS.1006 = example1006.com +DNS.1007 = example1007.com +DNS.1008 = example1008.com +DNS.1009 = example1009.com +DNS.1010 = example1010.com +DNS.1011 = example1011.com +DNS.1012 = example1012.com +DNS.1013 = example1013.com +DNS.1014 = example1014.com +DNS.1015 = example1015.com +DNS.1016 = example1016.com +DNS.1017 = example1017.com +DNS.1018 = example1018.com +DNS.1019 = example1019.com +DNS.1020 = example1020.com +DNS.1021 = example1021.com +DNS.1022 = example1022.com +DNS.1023 = example1023.com +DNS.1024 = example1024.com +DNS.1025 = example1025.com +DNS.1026 = example1026.com +DNS.1027 = example1027.com +DNS.1028 = example1028.com +DNS.1029 = example1029.com +DNS.1030 = example1030.com +DNS.1031 = example1031.com +DNS.1032 = example1032.com +DNS.1033 = example1033.com +DNS.1034 = example1034.com +DNS.1035 = example1035.com +DNS.1036 = example1036.com +DNS.1037 = example1037.com +DNS.1038 = example1038.com +DNS.1039 = example1039.com +DNS.1040 = example1040.com +DNS.1041 = example1041.com +DNS.1042 = example1042.com +DNS.1043 = example1043.com +DNS.1044 = example1044.com +DNS.1045 = example1045.com +DNS.1046 = example1046.com +DNS.1047 = example1047.com +DNS.1048 = example1048.com +DNS.1049 = example1049.com +DNS.1050 = example1050.com diff --git a/certs/test/cert-over-max-altnames.der b/certs/test/cert-over-max-altnames.der index d1b5cc935d..244eec0eb7 100644 Binary files a/certs/test/cert-over-max-altnames.der and b/certs/test/cert-over-max-altnames.der differ diff --git a/certs/test/cert-over-max-altnames.pem b/certs/test/cert-over-max-altnames.pem index cd1a1b7a8e..f7f3fde3e8 100644 --- a/certs/test/cert-over-max-altnames.pem +++ b/certs/test/cert-over-max-altnames.pem @@ -1,9 +1,9 @@ -----BEGIN CERTIFICATE----- -MIILRzCCCi+gAwIBAgIUEwPXUbqtHk1KaT4zyVtCBdtnA14wDQYJKoZIhvcNAQEL +MIJFGTCCRAGgAwIBAgIUF5nmfrjmbW0wm+StvWrMOmpvGaUwDQYJKoZIhvcNAQEL BQAwdzELMAkGA1UEBhMCVVMxEDAOBgNVBAgMB01vbnRhbmExEDAOBgNVBAcMB0Jv emVtYW4xFDASBgNVBAoMC3dvbGZTU0wgSW5jMRQwEgYDVQQLDAtFbmdpbmVlcmlu -ZzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29tMB4XDTI0MDcwODA2MzQwNFoXDTI3 -MDQwNDA2MzQwNFowdzELMAkGA1UEBhMCVVMxEDAOBgNVBAgMB01vbnRhbmExEDAO +ZzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29tMB4XDTI0MDcxODE4MDUxMVoXDTI3 +MDQxNDE4MDUxMVowdzELMAkGA1UEBhMCVVMxEDAOBgNVBAgMB01vbnRhbmExEDAO BgNVBAcMB0JvemVtYW4xFDASBgNVBAoMC3dvbGZTU0wgSW5jMRQwEgYDVQQLDAtF bmdpbmVlcmluZzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29tMIIBIjANBgkqhkiG 9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvwzKLRSyHoRCW804H0ryTXUQ8bY1n9/KfQOY @@ -11,8 +11,8 @@ bmdpbmVlcmluZzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29tMIIBIjANBgkqhkiG YlYb72dvpBBBla0Km+OlwLDScHZQMFuo6AgsfO2nonqNOCkcrMft8nyVsJWCfUlc OM13Je+9gHVTlDw9ymNbnxW10x0TLxnRPNt2Osy4fcnlwtfaQG/YIdxzG0ItU5z+ Gvx9q3o2P5jehHwFZ85qFDiHqfGMtWjLaH9xICv1oGP1Vi+jJtK3b7FaF9c4mQj+ -k1hv/sMTSQgWC6dNZwBSMWcjTpjtUUUduQTZC+zYKLNLve02eQIDAQABo4IHyTCC -B8UwggfBBgNVHREEgge4MIIHtIIMZXhhbXBsZTEuY29tggxleGFtcGxlMi5jb22C +k1hv/sMTSQgWC6dNZwBSMWcjTpjtUUUduQTZC+zYKLNLve02eQIDAQABo4JBmzCC +QZcwgkF0BgNVHREEgkFrMIJBZ4IMZXhhbXBsZTEuY29tggxleGFtcGxlMi5jb22C DGV4YW1wbGUzLmNvbYIMZXhhbXBsZTQuY29tggxleGFtcGxlNS5jb22CDGV4YW1w bGU2LmNvbYIMZXhhbXBsZTcuY29tggxleGFtcGxlOC5jb22CDGV4YW1wbGU5LmNv bYINZXhhbXBsZTEwLmNvbYINZXhhbXBsZTExLmNvbYINZXhhbXBsZTEyLmNvbYIN @@ -53,11 +53,319 @@ MTE3LmNvbYIOZXhhbXBsZTExOC5jb22CDmV4YW1wbGUxMTkuY29tgg5leGFtcGxl MTIwLmNvbYIOZXhhbXBsZTEyMS5jb22CDmV4YW1wbGUxMjIuY29tgg5leGFtcGxl MTIzLmNvbYIOZXhhbXBsZTEyNC5jb22CDmV4YW1wbGUxMjUuY29tgg5leGFtcGxl MTI2LmNvbYIOZXhhbXBsZTEyNy5jb22CDmV4YW1wbGUxMjguY29tgg5leGFtcGxl -MTI5LmNvbYIOZXhhbXBsZTEzMC5jb20wDQYJKoZIhvcNAQELBQADggEBAJXFayJD -s6QYItL6tiYYwUiLt7wtXySzAP4oOG/xEQbJ4MbQUk2epIahsd1kC2rej2DRi35P -6PoQ8D5o8PwvtH0XzEMjr5QixRLBje0mIRr6vcqrM64ILj3v6BepwnaNY7RcuvC4 -P4kdM6fTUwK1lTaQavQymbcLkmUYHZroMZYDoLAm88pKJHzuCQng2j0qSH8h/egZ -NPLchgV15I7Yesc0EOgrUMhkvkTmumZgv3HAmhLwqi+kv9PDsId88xzJaEcF2yO/ -uK44HCis+45Zp1FiePrpk1c27z21q/NgvfGkn21+lf9a27iWCIGHde2myf7RE1M6 -avQ7b3uyhvQ590A= +MTI5LmNvbYIOZXhhbXBsZTEzMC5jb22CDmV4YW1wbGUxMzEuY29tgg5leGFtcGxl +MTMyLmNvbYIOZXhhbXBsZTEzMy5jb22CDmV4YW1wbGUxMzQuY29tgg5leGFtcGxl +MTM1LmNvbYIOZXhhbXBsZTEzNi5jb22CDmV4YW1wbGUxMzcuY29tgg5leGFtcGxl +MTM4LmNvbYIOZXhhbXBsZTEzOS5jb22CDmV4YW1wbGUxNDAuY29tgg5leGFtcGxl +MTQxLmNvbYIOZXhhbXBsZTE0Mi5jb22CDmV4YW1wbGUxNDMuY29tgg5leGFtcGxl +MTQ0LmNvbYIOZXhhbXBsZTE0NS5jb22CDmV4YW1wbGUxNDYuY29tgg5leGFtcGxl +MTQ3LmNvbYIOZXhhbXBsZTE0OC5jb22CDmV4YW1wbGUxNDkuY29tgg5leGFtcGxl +MTUwLmNvbYIOZXhhbXBsZTE1MS5jb22CDmV4YW1wbGUxNTIuY29tgg5leGFtcGxl +MTUzLmNvbYIOZXhhbXBsZTE1NC5jb22CDmV4YW1wbGUxNTUuY29tgg5leGFtcGxl +MTU2LmNvbYIOZXhhbXBsZTE1Ny5jb22CDmV4YW1wbGUxNTguY29tgg5leGFtcGxl +MTU5LmNvbYIOZXhhbXBsZTE2MC5jb22CDmV4YW1wbGUxNjEuY29tgg5leGFtcGxl +MTYyLmNvbYIOZXhhbXBsZTE2My5jb22CDmV4YW1wbGUxNjQuY29tgg5leGFtcGxl +MTY1LmNvbYIOZXhhbXBsZTE2Ni5jb22CDmV4YW1wbGUxNjcuY29tgg5leGFtcGxl +MTY4LmNvbYIOZXhhbXBsZTE2OS5jb22CDmV4YW1wbGUxNzAuY29tgg5leGFtcGxl +MTcxLmNvbYIOZXhhbXBsZTE3Mi5jb22CDmV4YW1wbGUxNzMuY29tgg5leGFtcGxl +MTc0LmNvbYIOZXhhbXBsZTE3NS5jb22CDmV4YW1wbGUxNzYuY29tgg5leGFtcGxl +MTc3LmNvbYIOZXhhbXBsZTE3OC5jb22CDmV4YW1wbGUxNzkuY29tgg5leGFtcGxl +MTgwLmNvbYIOZXhhbXBsZTE4MS5jb22CDmV4YW1wbGUxODIuY29tgg5leGFtcGxl +MTgzLmNvbYIOZXhhbXBsZTE4NC5jb22CDmV4YW1wbGUxODUuY29tgg5leGFtcGxl +MTg2LmNvbYIOZXhhbXBsZTE4Ny5jb22CDmV4YW1wbGUxODguY29tgg5leGFtcGxl +MTg5LmNvbYIOZXhhbXBsZTE5MC5jb22CDmV4YW1wbGUxOTEuY29tgg5leGFtcGxl +MTkyLmNvbYIOZXhhbXBsZTE5My5jb22CDmV4YW1wbGUxOTQuY29tgg5leGFtcGxl +MTk1LmNvbYIOZXhhbXBsZTE5Ni5jb22CDmV4YW1wbGUxOTcuY29tgg5leGFtcGxl +MTk4LmNvbYIOZXhhbXBsZTE5OS5jb22CDmV4YW1wbGUyMDAuY29tgg5leGFtcGxl +MjAxLmNvbYIOZXhhbXBsZTIwMi5jb22CDmV4YW1wbGUyMDMuY29tgg5leGFtcGxl +MjA0LmNvbYIOZXhhbXBsZTIwNS5jb22CDmV4YW1wbGUyMDYuY29tgg5leGFtcGxl +MjA3LmNvbYIOZXhhbXBsZTIwOC5jb22CDmV4YW1wbGUyMDkuY29tgg5leGFtcGxl +MjEwLmNvbYIOZXhhbXBsZTIxMS5jb22CDmV4YW1wbGUyMTIuY29tgg5leGFtcGxl +MjEzLmNvbYIOZXhhbXBsZTIxNC5jb22CDmV4YW1wbGUyMTUuY29tgg5leGFtcGxl +MjE2LmNvbYIOZXhhbXBsZTIxNy5jb22CDmV4YW1wbGUyMTguY29tgg5leGFtcGxl +MjE5LmNvbYIOZXhhbXBsZTIyMC5jb22CDmV4YW1wbGUyMjEuY29tgg5leGFtcGxl +MjIyLmNvbYIOZXhhbXBsZTIyMy5jb22CDmV4YW1wbGUyMjQuY29tgg5leGFtcGxl +MjI1LmNvbYIOZXhhbXBsZTIyNi5jb22CDmV4YW1wbGUyMjcuY29tgg5leGFtcGxl +MjI4LmNvbYIOZXhhbXBsZTIyOS5jb22CDmV4YW1wbGUyMzAuY29tgg5leGFtcGxl +MjMxLmNvbYIOZXhhbXBsZTIzMi5jb22CDmV4YW1wbGUyMzMuY29tgg5leGFtcGxl +MjM0LmNvbYIOZXhhbXBsZTIzNS5jb22CDmV4YW1wbGUyMzYuY29tgg5leGFtcGxl +MjM3LmNvbYIOZXhhbXBsZTIzOC5jb22CDmV4YW1wbGUyMzkuY29tgg5leGFtcGxl +MjQwLmNvbYIOZXhhbXBsZTI0MS5jb22CDmV4YW1wbGUyNDIuY29tgg5leGFtcGxl +MjQzLmNvbYIOZXhhbXBsZTI0NC5jb22CDmV4YW1wbGUyNDUuY29tgg5leGFtcGxl +MjQ2LmNvbYIOZXhhbXBsZTI0Ny5jb22CDmV4YW1wbGUyNDguY29tgg5leGFtcGxl +MjQ5LmNvbYIOZXhhbXBsZTI1MC5jb22CDmV4YW1wbGUyNTEuY29tgg5leGFtcGxl +MjUyLmNvbYIOZXhhbXBsZTI1My5jb22CDmV4YW1wbGUyNTQuY29tgg5leGFtcGxl +MjU1LmNvbYIOZXhhbXBsZTI1Ni5jb22CDmV4YW1wbGUyNTcuY29tgg5leGFtcGxl +MjU4LmNvbYIOZXhhbXBsZTI1OS5jb22CDmV4YW1wbGUyNjAuY29tgg5leGFtcGxl +MjYxLmNvbYIOZXhhbXBsZTI2Mi5jb22CDmV4YW1wbGUyNjMuY29tgg5leGFtcGxl +MjY0LmNvbYIOZXhhbXBsZTI2NS5jb22CDmV4YW1wbGUyNjYuY29tgg5leGFtcGxl +MjY3LmNvbYIOZXhhbXBsZTI2OC5jb22CDmV4YW1wbGUyNjkuY29tgg5leGFtcGxl +MjcwLmNvbYIOZXhhbXBsZTI3MS5jb22CDmV4YW1wbGUyNzIuY29tgg5leGFtcGxl +MjczLmNvbYIOZXhhbXBsZTI3NC5jb22CDmV4YW1wbGUyNzUuY29tgg5leGFtcGxl +Mjc2LmNvbYIOZXhhbXBsZTI3Ny5jb22CDmV4YW1wbGUyNzguY29tgg5leGFtcGxl +Mjc5LmNvbYIOZXhhbXBsZTI4MC5jb22CDmV4YW1wbGUyODEuY29tgg5leGFtcGxl +MjgyLmNvbYIOZXhhbXBsZTI4My5jb22CDmV4YW1wbGUyODQuY29tgg5leGFtcGxl +Mjg1LmNvbYIOZXhhbXBsZTI4Ni5jb22CDmV4YW1wbGUyODcuY29tgg5leGFtcGxl +Mjg4LmNvbYIOZXhhbXBsZTI4OS5jb22CDmV4YW1wbGUyOTAuY29tgg5leGFtcGxl +MjkxLmNvbYIOZXhhbXBsZTI5Mi5jb22CDmV4YW1wbGUyOTMuY29tgg5leGFtcGxl +Mjk0LmNvbYIOZXhhbXBsZTI5NS5jb22CDmV4YW1wbGUyOTYuY29tgg5leGFtcGxl +Mjk3LmNvbYIOZXhhbXBsZTI5OC5jb22CDmV4YW1wbGUyOTkuY29tgg5leGFtcGxl +MzAwLmNvbYIOZXhhbXBsZTMwMS5jb22CDmV4YW1wbGUzMDIuY29tgg5leGFtcGxl +MzAzLmNvbYIOZXhhbXBsZTMwNC5jb22CDmV4YW1wbGUzMDUuY29tgg5leGFtcGxl +MzA2LmNvbYIOZXhhbXBsZTMwNy5jb22CDmV4YW1wbGUzMDguY29tgg5leGFtcGxl +MzA5LmNvbYIOZXhhbXBsZTMxMC5jb22CDmV4YW1wbGUzMTEuY29tgg5leGFtcGxl +MzEyLmNvbYIOZXhhbXBsZTMxMy5jb22CDmV4YW1wbGUzMTQuY29tgg5leGFtcGxl +MzE1LmNvbYIOZXhhbXBsZTMxNi5jb22CDmV4YW1wbGUzMTcuY29tgg5leGFtcGxl +MzE4LmNvbYIOZXhhbXBsZTMxOS5jb22CDmV4YW1wbGUzMjAuY29tgg5leGFtcGxl +MzIxLmNvbYIOZXhhbXBsZTMyMi5jb22CDmV4YW1wbGUzMjMuY29tgg5leGFtcGxl +MzI0LmNvbYIOZXhhbXBsZTMyNS5jb22CDmV4YW1wbGUzMjYuY29tgg5leGFtcGxl +MzI3LmNvbYIOZXhhbXBsZTMyOC5jb22CDmV4YW1wbGUzMjkuY29tgg5leGFtcGxl +MzMwLmNvbYIOZXhhbXBsZTMzMS5jb22CDmV4YW1wbGUzMzIuY29tgg5leGFtcGxl +MzMzLmNvbYIOZXhhbXBsZTMzNC5jb22CDmV4YW1wbGUzMzUuY29tgg5leGFtcGxl +MzM2LmNvbYIOZXhhbXBsZTMzNy5jb22CDmV4YW1wbGUzMzguY29tgg5leGFtcGxl +MzM5LmNvbYIOZXhhbXBsZTM0MC5jb22CDmV4YW1wbGUzNDEuY29tgg5leGFtcGxl +MzQyLmNvbYIOZXhhbXBsZTM0My5jb22CDmV4YW1wbGUzNDQuY29tgg5leGFtcGxl +MzQ1LmNvbYIOZXhhbXBsZTM0Ni5jb22CDmV4YW1wbGUzNDcuY29tgg5leGFtcGxl +MzQ4LmNvbYIOZXhhbXBsZTM0OS5jb22CDmV4YW1wbGUzNTAuY29tgg5leGFtcGxl +MzUxLmNvbYIOZXhhbXBsZTM1Mi5jb22CDmV4YW1wbGUzNTMuY29tgg5leGFtcGxl +MzU0LmNvbYIOZXhhbXBsZTM1NS5jb22CDmV4YW1wbGUzNTYuY29tgg5leGFtcGxl +MzU3LmNvbYIOZXhhbXBsZTM1OC5jb22CDmV4YW1wbGUzNTkuY29tgg5leGFtcGxl +MzYwLmNvbYIOZXhhbXBsZTM2MS5jb22CDmV4YW1wbGUzNjIuY29tgg5leGFtcGxl +MzYzLmNvbYIOZXhhbXBsZTM2NC5jb22CDmV4YW1wbGUzNjUuY29tgg5leGFtcGxl +MzY2LmNvbYIOZXhhbXBsZTM2Ny5jb22CDmV4YW1wbGUzNjguY29tgg5leGFtcGxl +MzY5LmNvbYIOZXhhbXBsZTM3MC5jb22CDmV4YW1wbGUzNzEuY29tgg5leGFtcGxl +MzcyLmNvbYIOZXhhbXBsZTM3My5jb22CDmV4YW1wbGUzNzQuY29tgg5leGFtcGxl +Mzc1LmNvbYIOZXhhbXBsZTM3Ni5jb22CDmV4YW1wbGUzNzcuY29tgg5leGFtcGxl +Mzc4LmNvbYIOZXhhbXBsZTM3OS5jb22CDmV4YW1wbGUzODAuY29tgg5leGFtcGxl +MzgxLmNvbYIOZXhhbXBsZTM4Mi5jb22CDmV4YW1wbGUzODMuY29tgg5leGFtcGxl +Mzg0LmNvbYIOZXhhbXBsZTM4NS5jb22CDmV4YW1wbGUzODYuY29tgg5leGFtcGxl +Mzg3LmNvbYIOZXhhbXBsZTM4OC5jb22CDmV4YW1wbGUzODkuY29tgg5leGFtcGxl +MzkwLmNvbYIOZXhhbXBsZTM5MS5jb22CDmV4YW1wbGUzOTIuY29tgg5leGFtcGxl +MzkzLmNvbYIOZXhhbXBsZTM5NC5jb22CDmV4YW1wbGUzOTUuY29tgg5leGFtcGxl +Mzk2LmNvbYIOZXhhbXBsZTM5Ny5jb22CDmV4YW1wbGUzOTguY29tgg5leGFtcGxl +Mzk5LmNvbYIOZXhhbXBsZTQwMC5jb22CDmV4YW1wbGU0MDEuY29tgg5leGFtcGxl +NDAyLmNvbYIOZXhhbXBsZTQwMy5jb22CDmV4YW1wbGU0MDQuY29tgg5leGFtcGxl +NDA1LmNvbYIOZXhhbXBsZTQwNi5jb22CDmV4YW1wbGU0MDcuY29tgg5leGFtcGxl +NDA4LmNvbYIOZXhhbXBsZTQwOS5jb22CDmV4YW1wbGU0MTAuY29tgg5leGFtcGxl +NDExLmNvbYIOZXhhbXBsZTQxMi5jb22CDmV4YW1wbGU0MTMuY29tgg5leGFtcGxl +NDE0LmNvbYIOZXhhbXBsZTQxNS5jb22CDmV4YW1wbGU0MTYuY29tgg5leGFtcGxl +NDE3LmNvbYIOZXhhbXBsZTQxOC5jb22CDmV4YW1wbGU0MTkuY29tgg5leGFtcGxl +NDIwLmNvbYIOZXhhbXBsZTQyMS5jb22CDmV4YW1wbGU0MjIuY29tgg5leGFtcGxl +NDIzLmNvbYIOZXhhbXBsZTQyNC5jb22CDmV4YW1wbGU0MjUuY29tgg5leGFtcGxl +NDI2LmNvbYIOZXhhbXBsZTQyNy5jb22CDmV4YW1wbGU0MjguY29tgg5leGFtcGxl +NDI5LmNvbYIOZXhhbXBsZTQzMC5jb22CDmV4YW1wbGU0MzEuY29tgg5leGFtcGxl +NDMyLmNvbYIOZXhhbXBsZTQzMy5jb22CDmV4YW1wbGU0MzQuY29tgg5leGFtcGxl +NDM1LmNvbYIOZXhhbXBsZTQzNi5jb22CDmV4YW1wbGU0MzcuY29tgg5leGFtcGxl +NDM4LmNvbYIOZXhhbXBsZTQzOS5jb22CDmV4YW1wbGU0NDAuY29tgg5leGFtcGxl +NDQxLmNvbYIOZXhhbXBsZTQ0Mi5jb22CDmV4YW1wbGU0NDMuY29tgg5leGFtcGxl +NDQ0LmNvbYIOZXhhbXBsZTQ0NS5jb22CDmV4YW1wbGU0NDYuY29tgg5leGFtcGxl +NDQ3LmNvbYIOZXhhbXBsZTQ0OC5jb22CDmV4YW1wbGU0NDkuY29tgg5leGFtcGxl +NDUwLmNvbYIOZXhhbXBsZTQ1MS5jb22CDmV4YW1wbGU0NTIuY29tgg5leGFtcGxl +NDUzLmNvbYIOZXhhbXBsZTQ1NC5jb22CDmV4YW1wbGU0NTUuY29tgg5leGFtcGxl +NDU2LmNvbYIOZXhhbXBsZTQ1Ny5jb22CDmV4YW1wbGU0NTguY29tgg5leGFtcGxl +NDU5LmNvbYIOZXhhbXBsZTQ2MC5jb22CDmV4YW1wbGU0NjEuY29tgg5leGFtcGxl +NDYyLmNvbYIOZXhhbXBsZTQ2My5jb22CDmV4YW1wbGU0NjQuY29tgg5leGFtcGxl +NDY1LmNvbYIOZXhhbXBsZTQ2Ni5jb22CDmV4YW1wbGU0NjcuY29tgg5leGFtcGxl +NDY4LmNvbYIOZXhhbXBsZTQ2OS5jb22CDmV4YW1wbGU0NzAuY29tgg5leGFtcGxl +NDcxLmNvbYIOZXhhbXBsZTQ3Mi5jb22CDmV4YW1wbGU0NzMuY29tgg5leGFtcGxl +NDc0LmNvbYIOZXhhbXBsZTQ3NS5jb22CDmV4YW1wbGU0NzYuY29tgg5leGFtcGxl +NDc3LmNvbYIOZXhhbXBsZTQ3OC5jb22CDmV4YW1wbGU0NzkuY29tgg5leGFtcGxl +NDgwLmNvbYIOZXhhbXBsZTQ4MS5jb22CDmV4YW1wbGU0ODIuY29tgg5leGFtcGxl +NDgzLmNvbYIOZXhhbXBsZTQ4NC5jb22CDmV4YW1wbGU0ODUuY29tgg5leGFtcGxl +NDg2LmNvbYIOZXhhbXBsZTQ4Ny5jb22CDmV4YW1wbGU0ODguY29tgg5leGFtcGxl +NDg5LmNvbYIOZXhhbXBsZTQ5MC5jb22CDmV4YW1wbGU0OTEuY29tgg5leGFtcGxl +NDkyLmNvbYIOZXhhbXBsZTQ5My5jb22CDmV4YW1wbGU0OTQuY29tgg5leGFtcGxl +NDk1LmNvbYIOZXhhbXBsZTQ5Ni5jb22CDmV4YW1wbGU0OTcuY29tgg5leGFtcGxl +NDk4LmNvbYIOZXhhbXBsZTQ5OS5jb22CDmV4YW1wbGU1MDAuY29tgg5leGFtcGxl +NTAxLmNvbYIOZXhhbXBsZTUwMi5jb22CDmV4YW1wbGU1MDMuY29tgg5leGFtcGxl +NTA0LmNvbYIOZXhhbXBsZTUwNS5jb22CDmV4YW1wbGU1MDYuY29tgg5leGFtcGxl +NTA3LmNvbYIOZXhhbXBsZTUwOC5jb22CDmV4YW1wbGU1MDkuY29tgg5leGFtcGxl +NTEwLmNvbYIOZXhhbXBsZTUxMS5jb22CDmV4YW1wbGU1MTIuY29tgg5leGFtcGxl +NTEzLmNvbYIOZXhhbXBsZTUxNC5jb22CDmV4YW1wbGU1MTUuY29tgg5leGFtcGxl +NTE2LmNvbYIOZXhhbXBsZTUxNy5jb22CDmV4YW1wbGU1MTguY29tgg5leGFtcGxl +NTE5LmNvbYIOZXhhbXBsZTUyMC5jb22CDmV4YW1wbGU1MjEuY29tgg5leGFtcGxl +NTIyLmNvbYIOZXhhbXBsZTUyMy5jb22CDmV4YW1wbGU1MjQuY29tgg5leGFtcGxl +NTI1LmNvbYIOZXhhbXBsZTUyNi5jb22CDmV4YW1wbGU1MjcuY29tgg5leGFtcGxl +NTI4LmNvbYIOZXhhbXBsZTUyOS5jb22CDmV4YW1wbGU1MzAuY29tgg5leGFtcGxl +NTMxLmNvbYIOZXhhbXBsZTUzMi5jb22CDmV4YW1wbGU1MzMuY29tgg5leGFtcGxl +NTM0LmNvbYIOZXhhbXBsZTUzNS5jb22CDmV4YW1wbGU1MzYuY29tgg5leGFtcGxl +NTM3LmNvbYIOZXhhbXBsZTUzOC5jb22CDmV4YW1wbGU1MzkuY29tgg5leGFtcGxl +NTQwLmNvbYIOZXhhbXBsZTU0MS5jb22CDmV4YW1wbGU1NDIuY29tgg5leGFtcGxl +NTQzLmNvbYIOZXhhbXBsZTU0NC5jb22CDmV4YW1wbGU1NDUuY29tgg5leGFtcGxl +NTQ2LmNvbYIOZXhhbXBsZTU0Ny5jb22CDmV4YW1wbGU1NDguY29tgg5leGFtcGxl +NTQ5LmNvbYIOZXhhbXBsZTU1MC5jb22CDmV4YW1wbGU1NTEuY29tgg5leGFtcGxl +NTUyLmNvbYIOZXhhbXBsZTU1My5jb22CDmV4YW1wbGU1NTQuY29tgg5leGFtcGxl +NTU1LmNvbYIOZXhhbXBsZTU1Ni5jb22CDmV4YW1wbGU1NTcuY29tgg5leGFtcGxl +NTU4LmNvbYIOZXhhbXBsZTU1OS5jb22CDmV4YW1wbGU1NjAuY29tgg5leGFtcGxl +NTYxLmNvbYIOZXhhbXBsZTU2Mi5jb22CDmV4YW1wbGU1NjMuY29tgg5leGFtcGxl +NTY0LmNvbYIOZXhhbXBsZTU2NS5jb22CDmV4YW1wbGU1NjYuY29tgg5leGFtcGxl +NTY3LmNvbYIOZXhhbXBsZTU2OC5jb22CDmV4YW1wbGU1NjkuY29tgg5leGFtcGxl +NTcwLmNvbYIOZXhhbXBsZTU3MS5jb22CDmV4YW1wbGU1NzIuY29tgg5leGFtcGxl +NTczLmNvbYIOZXhhbXBsZTU3NC5jb22CDmV4YW1wbGU1NzUuY29tgg5leGFtcGxl +NTc2LmNvbYIOZXhhbXBsZTU3Ny5jb22CDmV4YW1wbGU1NzguY29tgg5leGFtcGxl +NTc5LmNvbYIOZXhhbXBsZTU4MC5jb22CDmV4YW1wbGU1ODEuY29tgg5leGFtcGxl +NTgyLmNvbYIOZXhhbXBsZTU4My5jb22CDmV4YW1wbGU1ODQuY29tgg5leGFtcGxl +NTg1LmNvbYIOZXhhbXBsZTU4Ni5jb22CDmV4YW1wbGU1ODcuY29tgg5leGFtcGxl +NTg4LmNvbYIOZXhhbXBsZTU4OS5jb22CDmV4YW1wbGU1OTAuY29tgg5leGFtcGxl +NTkxLmNvbYIOZXhhbXBsZTU5Mi5jb22CDmV4YW1wbGU1OTMuY29tgg5leGFtcGxl +NTk0LmNvbYIOZXhhbXBsZTU5NS5jb22CDmV4YW1wbGU1OTYuY29tgg5leGFtcGxl +NTk3LmNvbYIOZXhhbXBsZTU5OC5jb22CDmV4YW1wbGU1OTkuY29tgg5leGFtcGxl +NjAwLmNvbYIOZXhhbXBsZTYwMS5jb22CDmV4YW1wbGU2MDIuY29tgg5leGFtcGxl +NjAzLmNvbYIOZXhhbXBsZTYwNC5jb22CDmV4YW1wbGU2MDUuY29tgg5leGFtcGxl +NjA2LmNvbYIOZXhhbXBsZTYwNy5jb22CDmV4YW1wbGU2MDguY29tgg5leGFtcGxl +NjA5LmNvbYIOZXhhbXBsZTYxMC5jb22CDmV4YW1wbGU2MTEuY29tgg5leGFtcGxl +NjEyLmNvbYIOZXhhbXBsZTYxMy5jb22CDmV4YW1wbGU2MTQuY29tgg5leGFtcGxl +NjE1LmNvbYIOZXhhbXBsZTYxNi5jb22CDmV4YW1wbGU2MTcuY29tgg5leGFtcGxl +NjE4LmNvbYIOZXhhbXBsZTYxOS5jb22CDmV4YW1wbGU2MjAuY29tgg5leGFtcGxl +NjIxLmNvbYIOZXhhbXBsZTYyMi5jb22CDmV4YW1wbGU2MjMuY29tgg5leGFtcGxl +NjI0LmNvbYIOZXhhbXBsZTYyNS5jb22CDmV4YW1wbGU2MjYuY29tgg5leGFtcGxl +NjI3LmNvbYIOZXhhbXBsZTYyOC5jb22CDmV4YW1wbGU2MjkuY29tgg5leGFtcGxl +NjMwLmNvbYIOZXhhbXBsZTYzMS5jb22CDmV4YW1wbGU2MzIuY29tgg5leGFtcGxl +NjMzLmNvbYIOZXhhbXBsZTYzNC5jb22CDmV4YW1wbGU2MzUuY29tgg5leGFtcGxl +NjM2LmNvbYIOZXhhbXBsZTYzNy5jb22CDmV4YW1wbGU2MzguY29tgg5leGFtcGxl +NjM5LmNvbYIOZXhhbXBsZTY0MC5jb22CDmV4YW1wbGU2NDEuY29tgg5leGFtcGxl +NjQyLmNvbYIOZXhhbXBsZTY0My5jb22CDmV4YW1wbGU2NDQuY29tgg5leGFtcGxl +NjQ1LmNvbYIOZXhhbXBsZTY0Ni5jb22CDmV4YW1wbGU2NDcuY29tgg5leGFtcGxl +NjQ4LmNvbYIOZXhhbXBsZTY0OS5jb22CDmV4YW1wbGU2NTAuY29tgg5leGFtcGxl +NjUxLmNvbYIOZXhhbXBsZTY1Mi5jb22CDmV4YW1wbGU2NTMuY29tgg5leGFtcGxl +NjU0LmNvbYIOZXhhbXBsZTY1NS5jb22CDmV4YW1wbGU2NTYuY29tgg5leGFtcGxl +NjU3LmNvbYIOZXhhbXBsZTY1OC5jb22CDmV4YW1wbGU2NTkuY29tgg5leGFtcGxl +NjYwLmNvbYIOZXhhbXBsZTY2MS5jb22CDmV4YW1wbGU2NjIuY29tgg5leGFtcGxl +NjYzLmNvbYIOZXhhbXBsZTY2NC5jb22CDmV4YW1wbGU2NjUuY29tgg5leGFtcGxl +NjY2LmNvbYIOZXhhbXBsZTY2Ny5jb22CDmV4YW1wbGU2NjguY29tgg5leGFtcGxl +NjY5LmNvbYIOZXhhbXBsZTY3MC5jb22CDmV4YW1wbGU2NzEuY29tgg5leGFtcGxl +NjcyLmNvbYIOZXhhbXBsZTY3My5jb22CDmV4YW1wbGU2NzQuY29tgg5leGFtcGxl +Njc1LmNvbYIOZXhhbXBsZTY3Ni5jb22CDmV4YW1wbGU2NzcuY29tgg5leGFtcGxl +Njc4LmNvbYIOZXhhbXBsZTY3OS5jb22CDmV4YW1wbGU2ODAuY29tgg5leGFtcGxl +NjgxLmNvbYIOZXhhbXBsZTY4Mi5jb22CDmV4YW1wbGU2ODMuY29tgg5leGFtcGxl +Njg0LmNvbYIOZXhhbXBsZTY4NS5jb22CDmV4YW1wbGU2ODYuY29tgg5leGFtcGxl +Njg3LmNvbYIOZXhhbXBsZTY4OC5jb22CDmV4YW1wbGU2ODkuY29tgg5leGFtcGxl +NjkwLmNvbYIOZXhhbXBsZTY5MS5jb22CDmV4YW1wbGU2OTIuY29tgg5leGFtcGxl +NjkzLmNvbYIOZXhhbXBsZTY5NC5jb22CDmV4YW1wbGU2OTUuY29tgg5leGFtcGxl +Njk2LmNvbYIOZXhhbXBsZTY5Ny5jb22CDmV4YW1wbGU2OTguY29tgg5leGFtcGxl +Njk5LmNvbYIOZXhhbXBsZTcwMC5jb22CDmV4YW1wbGU3MDEuY29tgg5leGFtcGxl +NzAyLmNvbYIOZXhhbXBsZTcwMy5jb22CDmV4YW1wbGU3MDQuY29tgg5leGFtcGxl +NzA1LmNvbYIOZXhhbXBsZTcwNi5jb22CDmV4YW1wbGU3MDcuY29tgg5leGFtcGxl +NzA4LmNvbYIOZXhhbXBsZTcwOS5jb22CDmV4YW1wbGU3MTAuY29tgg5leGFtcGxl +NzExLmNvbYIOZXhhbXBsZTcxMi5jb22CDmV4YW1wbGU3MTMuY29tgg5leGFtcGxl +NzE0LmNvbYIOZXhhbXBsZTcxNS5jb22CDmV4YW1wbGU3MTYuY29tgg5leGFtcGxl +NzE3LmNvbYIOZXhhbXBsZTcxOC5jb22CDmV4YW1wbGU3MTkuY29tgg5leGFtcGxl +NzIwLmNvbYIOZXhhbXBsZTcyMS5jb22CDmV4YW1wbGU3MjIuY29tgg5leGFtcGxl +NzIzLmNvbYIOZXhhbXBsZTcyNC5jb22CDmV4YW1wbGU3MjUuY29tgg5leGFtcGxl +NzI2LmNvbYIOZXhhbXBsZTcyNy5jb22CDmV4YW1wbGU3MjguY29tgg5leGFtcGxl +NzI5LmNvbYIOZXhhbXBsZTczMC5jb22CDmV4YW1wbGU3MzEuY29tgg5leGFtcGxl +NzMyLmNvbYIOZXhhbXBsZTczMy5jb22CDmV4YW1wbGU3MzQuY29tgg5leGFtcGxl +NzM1LmNvbYIOZXhhbXBsZTczNi5jb22CDmV4YW1wbGU3MzcuY29tgg5leGFtcGxl +NzM4LmNvbYIOZXhhbXBsZTczOS5jb22CDmV4YW1wbGU3NDAuY29tgg5leGFtcGxl +NzQxLmNvbYIOZXhhbXBsZTc0Mi5jb22CDmV4YW1wbGU3NDMuY29tgg5leGFtcGxl +NzQ0LmNvbYIOZXhhbXBsZTc0NS5jb22CDmV4YW1wbGU3NDYuY29tgg5leGFtcGxl +NzQ3LmNvbYIOZXhhbXBsZTc0OC5jb22CDmV4YW1wbGU3NDkuY29tgg5leGFtcGxl +NzUwLmNvbYIOZXhhbXBsZTc1MS5jb22CDmV4YW1wbGU3NTIuY29tgg5leGFtcGxl +NzUzLmNvbYIOZXhhbXBsZTc1NC5jb22CDmV4YW1wbGU3NTUuY29tgg5leGFtcGxl +NzU2LmNvbYIOZXhhbXBsZTc1Ny5jb22CDmV4YW1wbGU3NTguY29tgg5leGFtcGxl +NzU5LmNvbYIOZXhhbXBsZTc2MC5jb22CDmV4YW1wbGU3NjEuY29tgg5leGFtcGxl +NzYyLmNvbYIOZXhhbXBsZTc2My5jb22CDmV4YW1wbGU3NjQuY29tgg5leGFtcGxl +NzY1LmNvbYIOZXhhbXBsZTc2Ni5jb22CDmV4YW1wbGU3NjcuY29tgg5leGFtcGxl +NzY4LmNvbYIOZXhhbXBsZTc2OS5jb22CDmV4YW1wbGU3NzAuY29tgg5leGFtcGxl +NzcxLmNvbYIOZXhhbXBsZTc3Mi5jb22CDmV4YW1wbGU3NzMuY29tgg5leGFtcGxl +Nzc0LmNvbYIOZXhhbXBsZTc3NS5jb22CDmV4YW1wbGU3NzYuY29tgg5leGFtcGxl +Nzc3LmNvbYIOZXhhbXBsZTc3OC5jb22CDmV4YW1wbGU3NzkuY29tgg5leGFtcGxl +NzgwLmNvbYIOZXhhbXBsZTc4MS5jb22CDmV4YW1wbGU3ODIuY29tgg5leGFtcGxl +NzgzLmNvbYIOZXhhbXBsZTc4NC5jb22CDmV4YW1wbGU3ODUuY29tgg5leGFtcGxl +Nzg2LmNvbYIOZXhhbXBsZTc4Ny5jb22CDmV4YW1wbGU3ODguY29tgg5leGFtcGxl +Nzg5LmNvbYIOZXhhbXBsZTc5MC5jb22CDmV4YW1wbGU3OTEuY29tgg5leGFtcGxl +NzkyLmNvbYIOZXhhbXBsZTc5My5jb22CDmV4YW1wbGU3OTQuY29tgg5leGFtcGxl +Nzk1LmNvbYIOZXhhbXBsZTc5Ni5jb22CDmV4YW1wbGU3OTcuY29tgg5leGFtcGxl +Nzk4LmNvbYIOZXhhbXBsZTc5OS5jb22CDmV4YW1wbGU4MDAuY29tgg5leGFtcGxl +ODAxLmNvbYIOZXhhbXBsZTgwMi5jb22CDmV4YW1wbGU4MDMuY29tgg5leGFtcGxl +ODA0LmNvbYIOZXhhbXBsZTgwNS5jb22CDmV4YW1wbGU4MDYuY29tgg5leGFtcGxl +ODA3LmNvbYIOZXhhbXBsZTgwOC5jb22CDmV4YW1wbGU4MDkuY29tgg5leGFtcGxl +ODEwLmNvbYIOZXhhbXBsZTgxMS5jb22CDmV4YW1wbGU4MTIuY29tgg5leGFtcGxl +ODEzLmNvbYIOZXhhbXBsZTgxNC5jb22CDmV4YW1wbGU4MTUuY29tgg5leGFtcGxl +ODE2LmNvbYIOZXhhbXBsZTgxNy5jb22CDmV4YW1wbGU4MTguY29tgg5leGFtcGxl +ODE5LmNvbYIOZXhhbXBsZTgyMC5jb22CDmV4YW1wbGU4MjEuY29tgg5leGFtcGxl +ODIyLmNvbYIOZXhhbXBsZTgyMy5jb22CDmV4YW1wbGU4MjQuY29tgg5leGFtcGxl +ODI1LmNvbYIOZXhhbXBsZTgyNi5jb22CDmV4YW1wbGU4MjcuY29tgg5leGFtcGxl +ODI4LmNvbYIOZXhhbXBsZTgyOS5jb22CDmV4YW1wbGU4MzAuY29tgg5leGFtcGxl +ODMxLmNvbYIOZXhhbXBsZTgzMi5jb22CDmV4YW1wbGU4MzMuY29tgg5leGFtcGxl +ODM0LmNvbYIOZXhhbXBsZTgzNS5jb22CDmV4YW1wbGU4MzYuY29tgg5leGFtcGxl +ODM3LmNvbYIOZXhhbXBsZTgzOC5jb22CDmV4YW1wbGU4MzkuY29tgg5leGFtcGxl +ODQwLmNvbYIOZXhhbXBsZTg0MS5jb22CDmV4YW1wbGU4NDIuY29tgg5leGFtcGxl +ODQzLmNvbYIOZXhhbXBsZTg0NC5jb22CDmV4YW1wbGU4NDUuY29tgg5leGFtcGxl +ODQ2LmNvbYIOZXhhbXBsZTg0Ny5jb22CDmV4YW1wbGU4NDguY29tgg5leGFtcGxl +ODQ5LmNvbYIOZXhhbXBsZTg1MC5jb22CDmV4YW1wbGU4NTEuY29tgg5leGFtcGxl +ODUyLmNvbYIOZXhhbXBsZTg1My5jb22CDmV4YW1wbGU4NTQuY29tgg5leGFtcGxl +ODU1LmNvbYIOZXhhbXBsZTg1Ni5jb22CDmV4YW1wbGU4NTcuY29tgg5leGFtcGxl +ODU4LmNvbYIOZXhhbXBsZTg1OS5jb22CDmV4YW1wbGU4NjAuY29tgg5leGFtcGxl +ODYxLmNvbYIOZXhhbXBsZTg2Mi5jb22CDmV4YW1wbGU4NjMuY29tgg5leGFtcGxl +ODY0LmNvbYIOZXhhbXBsZTg2NS5jb22CDmV4YW1wbGU4NjYuY29tgg5leGFtcGxl +ODY3LmNvbYIOZXhhbXBsZTg2OC5jb22CDmV4YW1wbGU4NjkuY29tgg5leGFtcGxl +ODcwLmNvbYIOZXhhbXBsZTg3MS5jb22CDmV4YW1wbGU4NzIuY29tgg5leGFtcGxl +ODczLmNvbYIOZXhhbXBsZTg3NC5jb22CDmV4YW1wbGU4NzUuY29tgg5leGFtcGxl +ODc2LmNvbYIOZXhhbXBsZTg3Ny5jb22CDmV4YW1wbGU4NzguY29tgg5leGFtcGxl +ODc5LmNvbYIOZXhhbXBsZTg4MC5jb22CDmV4YW1wbGU4ODEuY29tgg5leGFtcGxl +ODgyLmNvbYIOZXhhbXBsZTg4My5jb22CDmV4YW1wbGU4ODQuY29tgg5leGFtcGxl +ODg1LmNvbYIOZXhhbXBsZTg4Ni5jb22CDmV4YW1wbGU4ODcuY29tgg5leGFtcGxl +ODg4LmNvbYIOZXhhbXBsZTg4OS5jb22CDmV4YW1wbGU4OTAuY29tgg5leGFtcGxl +ODkxLmNvbYIOZXhhbXBsZTg5Mi5jb22CDmV4YW1wbGU4OTMuY29tgg5leGFtcGxl +ODk0LmNvbYIOZXhhbXBsZTg5NS5jb22CDmV4YW1wbGU4OTYuY29tgg5leGFtcGxl +ODk3LmNvbYIOZXhhbXBsZTg5OC5jb22CDmV4YW1wbGU4OTkuY29tgg5leGFtcGxl +OTAwLmNvbYIOZXhhbXBsZTkwMS5jb22CDmV4YW1wbGU5MDIuY29tgg5leGFtcGxl +OTAzLmNvbYIOZXhhbXBsZTkwNC5jb22CDmV4YW1wbGU5MDUuY29tgg5leGFtcGxl +OTA2LmNvbYIOZXhhbXBsZTkwNy5jb22CDmV4YW1wbGU5MDguY29tgg5leGFtcGxl +OTA5LmNvbYIOZXhhbXBsZTkxMC5jb22CDmV4YW1wbGU5MTEuY29tgg5leGFtcGxl +OTEyLmNvbYIOZXhhbXBsZTkxMy5jb22CDmV4YW1wbGU5MTQuY29tgg5leGFtcGxl +OTE1LmNvbYIOZXhhbXBsZTkxNi5jb22CDmV4YW1wbGU5MTcuY29tgg5leGFtcGxl +OTE4LmNvbYIOZXhhbXBsZTkxOS5jb22CDmV4YW1wbGU5MjAuY29tgg5leGFtcGxl +OTIxLmNvbYIOZXhhbXBsZTkyMi5jb22CDmV4YW1wbGU5MjMuY29tgg5leGFtcGxl +OTI0LmNvbYIOZXhhbXBsZTkyNS5jb22CDmV4YW1wbGU5MjYuY29tgg5leGFtcGxl +OTI3LmNvbYIOZXhhbXBsZTkyOC5jb22CDmV4YW1wbGU5MjkuY29tgg5leGFtcGxl +OTMwLmNvbYIOZXhhbXBsZTkzMS5jb22CDmV4YW1wbGU5MzIuY29tgg5leGFtcGxl +OTMzLmNvbYIOZXhhbXBsZTkzNC5jb22CDmV4YW1wbGU5MzUuY29tgg5leGFtcGxl +OTM2LmNvbYIOZXhhbXBsZTkzNy5jb22CDmV4YW1wbGU5MzguY29tgg5leGFtcGxl +OTM5LmNvbYIOZXhhbXBsZTk0MC5jb22CDmV4YW1wbGU5NDEuY29tgg5leGFtcGxl +OTQyLmNvbYIOZXhhbXBsZTk0My5jb22CDmV4YW1wbGU5NDQuY29tgg5leGFtcGxl +OTQ1LmNvbYIOZXhhbXBsZTk0Ni5jb22CDmV4YW1wbGU5NDcuY29tgg5leGFtcGxl +OTQ4LmNvbYIOZXhhbXBsZTk0OS5jb22CDmV4YW1wbGU5NTAuY29tgg5leGFtcGxl +OTUxLmNvbYIOZXhhbXBsZTk1Mi5jb22CDmV4YW1wbGU5NTMuY29tgg5leGFtcGxl +OTU0LmNvbYIOZXhhbXBsZTk1NS5jb22CDmV4YW1wbGU5NTYuY29tgg5leGFtcGxl +OTU3LmNvbYIOZXhhbXBsZTk1OC5jb22CDmV4YW1wbGU5NTkuY29tgg5leGFtcGxl +OTYwLmNvbYIOZXhhbXBsZTk2MS5jb22CDmV4YW1wbGU5NjIuY29tgg5leGFtcGxl +OTYzLmNvbYIOZXhhbXBsZTk2NC5jb22CDmV4YW1wbGU5NjUuY29tgg5leGFtcGxl +OTY2LmNvbYIOZXhhbXBsZTk2Ny5jb22CDmV4YW1wbGU5NjguY29tgg5leGFtcGxl +OTY5LmNvbYIOZXhhbXBsZTk3MC5jb22CDmV4YW1wbGU5NzEuY29tgg5leGFtcGxl +OTcyLmNvbYIOZXhhbXBsZTk3My5jb22CDmV4YW1wbGU5NzQuY29tgg5leGFtcGxl +OTc1LmNvbYIOZXhhbXBsZTk3Ni5jb22CDmV4YW1wbGU5NzcuY29tgg5leGFtcGxl +OTc4LmNvbYIOZXhhbXBsZTk3OS5jb22CDmV4YW1wbGU5ODAuY29tgg5leGFtcGxl +OTgxLmNvbYIOZXhhbXBsZTk4Mi5jb22CDmV4YW1wbGU5ODMuY29tgg5leGFtcGxl +OTg0LmNvbYIOZXhhbXBsZTk4NS5jb22CDmV4YW1wbGU5ODYuY29tgg5leGFtcGxl +OTg3LmNvbYIOZXhhbXBsZTk4OC5jb22CDmV4YW1wbGU5ODkuY29tgg5leGFtcGxl +OTkwLmNvbYIOZXhhbXBsZTk5MS5jb22CDmV4YW1wbGU5OTIuY29tgg5leGFtcGxl +OTkzLmNvbYIOZXhhbXBsZTk5NC5jb22CDmV4YW1wbGU5OTUuY29tgg5leGFtcGxl +OTk2LmNvbYIOZXhhbXBsZTk5Ny5jb22CDmV4YW1wbGU5OTguY29tgg5leGFtcGxl +OTk5LmNvbYIPZXhhbXBsZTEwMDAuY29tgg9leGFtcGxlMTAwMS5jb22CD2V4YW1w +bGUxMDAyLmNvbYIPZXhhbXBsZTEwMDMuY29tgg9leGFtcGxlMTAwNC5jb22CD2V4 +YW1wbGUxMDA1LmNvbYIPZXhhbXBsZTEwMDYuY29tgg9leGFtcGxlMTAwNy5jb22C +D2V4YW1wbGUxMDA4LmNvbYIPZXhhbXBsZTEwMDkuY29tgg9leGFtcGxlMTAxMC5j +b22CD2V4YW1wbGUxMDExLmNvbYIPZXhhbXBsZTEwMTIuY29tgg9leGFtcGxlMTAx +My5jb22CD2V4YW1wbGUxMDE0LmNvbYIPZXhhbXBsZTEwMTUuY29tgg9leGFtcGxl +MTAxNi5jb22CD2V4YW1wbGUxMDE3LmNvbYIPZXhhbXBsZTEwMTguY29tgg9leGFt +cGxlMTAxOS5jb22CD2V4YW1wbGUxMDIwLmNvbYIPZXhhbXBsZTEwMjEuY29tgg9l +eGFtcGxlMTAyMi5jb22CD2V4YW1wbGUxMDIzLmNvbYIPZXhhbXBsZTEwMjQuY29t +gg9leGFtcGxlMTAyNS5jb22CD2V4YW1wbGUxMDI2LmNvbYIPZXhhbXBsZTEwMjcu +Y29tgg9leGFtcGxlMTAyOC5jb22CD2V4YW1wbGUxMDI5LmNvbYIPZXhhbXBsZTEw +MzAuY29tgg9leGFtcGxlMTAzMS5jb22CD2V4YW1wbGUxMDMyLmNvbYIPZXhhbXBs +ZTEwMzMuY29tgg9leGFtcGxlMTAzNC5jb22CD2V4YW1wbGUxMDM1LmNvbYIPZXhh +bXBsZTEwMzYuY29tgg9leGFtcGxlMTAzNy5jb22CD2V4YW1wbGUxMDM4LmNvbYIP +ZXhhbXBsZTEwMzkuY29tgg9leGFtcGxlMTA0MC5jb22CD2V4YW1wbGUxMDQxLmNv +bYIPZXhhbXBsZTEwNDIuY29tgg9leGFtcGxlMTA0My5jb22CD2V4YW1wbGUxMDQ0 +LmNvbYIPZXhhbXBsZTEwNDUuY29tgg9leGFtcGxlMTA0Ni5jb22CD2V4YW1wbGUx +MDQ3LmNvbYIPZXhhbXBsZTEwNDguY29tgg9leGFtcGxlMTA0OS5jb22CD2V4YW1w +bGUxMDUwLmNvbTAdBgNVHQ4EFgQUJ45nEXTDJh0/7TNjs6TYHTDl6NUwDQYJKoZI +hvcNAQELBQADggEBAAafsXELXxtWZERkGxkH1a6sXrqD9xdMUIu/Bf8QAKePLOLX +VbJeGNW9UHCKA5jntP4BKP86/b+43KF3g8qMyphS9DBTvOZ+rbRe8z3K6ouTi4Cv +4jxL0ej4QINeIEbNAC5GqVkSHnVB0ul5drsIXHEAHi72BTkSlFHOU0umlL99O8UG +R++z7qkXJWjrHkUA7zVIS4pRne80AtDVd3WB3lCmG/hs9p8Dj7igUGfaQYF1T6uK +zkgpT2PCjvVfXadTG9FTqe+MEkjOwpUqClJ0SS1Et7KF56Q++FdFx7msammI2SC+ +XrBKQPqYZviTlK1YepjwtXe1SxasL7tjabJuIyU= -----END CERTIFICATE----- diff --git a/certs/test/gen-ext-certs.sh b/certs/test/gen-ext-certs.sh index 27696fb079..65e8caca5c 100755 --- a/certs/test/gen-ext-certs.sh +++ b/certs/test/gen-ext-certs.sh @@ -531,6 +531,927 @@ DNS.127 = example127.com DNS.128 = example128.com DNS.129 = example129.com DNS.130 = example130.com +DNS.131 = example131.com +DNS.132 = example132.com +DNS.133 = example133.com +DNS.134 = example134.com +DNS.135 = example135.com +DNS.136 = example136.com +DNS.137 = example137.com +DNS.138 = example138.com +DNS.139 = example139.com +DNS.140 = example140.com +DNS.141 = example141.com +DNS.142 = example142.com +DNS.143 = example143.com +DNS.144 = example144.com +DNS.145 = example145.com +DNS.146 = example146.com +DNS.147 = example147.com +DNS.148 = example148.com +DNS.149 = example149.com +DNS.150 = example150.com +DNS.151 = example151.com +DNS.152 = example152.com +DNS.153 = example153.com +DNS.154 = example154.com +DNS.155 = example155.com +DNS.156 = example156.com +DNS.157 = example157.com +DNS.158 = example158.com +DNS.159 = example159.com +DNS.160 = example160.com +DNS.161 = example161.com +DNS.162 = example162.com +DNS.163 = example163.com +DNS.164 = example164.com +DNS.165 = example165.com +DNS.166 = example166.com +DNS.167 = example167.com +DNS.168 = example168.com +DNS.169 = example169.com +DNS.170 = example170.com +DNS.171 = example171.com +DNS.172 = example172.com +DNS.173 = example173.com +DNS.174 = example174.com +DNS.175 = example175.com +DNS.176 = example176.com +DNS.177 = example177.com +DNS.178 = example178.com +DNS.179 = example179.com +DNS.180 = example180.com +DNS.181 = example181.com +DNS.182 = example182.com +DNS.183 = example183.com +DNS.184 = example184.com +DNS.185 = example185.com +DNS.186 = example186.com +DNS.187 = example187.com +DNS.188 = example188.com +DNS.189 = example189.com +DNS.190 = example190.com +DNS.191 = example191.com +DNS.192 = example192.com +DNS.193 = example193.com +DNS.194 = example194.com +DNS.195 = example195.com +DNS.196 = example196.com +DNS.197 = example197.com +DNS.198 = example198.com +DNS.199 = example199.com +DNS.200 = example200.com +DNS.201 = example201.com +DNS.202 = example202.com +DNS.203 = example203.com +DNS.204 = example204.com +DNS.205 = example205.com +DNS.206 = example206.com +DNS.207 = example207.com +DNS.208 = example208.com +DNS.209 = example209.com +DNS.210 = example210.com +DNS.211 = example211.com +DNS.212 = example212.com +DNS.213 = example213.com +DNS.214 = example214.com +DNS.215 = example215.com +DNS.216 = example216.com +DNS.217 = example217.com +DNS.218 = example218.com +DNS.219 = example219.com +DNS.220 = example220.com +DNS.221 = example221.com +DNS.222 = example222.com +DNS.223 = example223.com +DNS.224 = example224.com +DNS.225 = example225.com +DNS.226 = example226.com +DNS.227 = example227.com +DNS.228 = example228.com +DNS.229 = example229.com +DNS.230 = example230.com +DNS.231 = example231.com +DNS.232 = example232.com +DNS.233 = example233.com +DNS.234 = example234.com +DNS.235 = example235.com +DNS.236 = example236.com +DNS.237 = example237.com +DNS.238 = example238.com +DNS.239 = example239.com +DNS.240 = example240.com +DNS.241 = example241.com +DNS.242 = example242.com +DNS.243 = example243.com +DNS.244 = example244.com +DNS.245 = example245.com +DNS.246 = example246.com +DNS.247 = example247.com +DNS.248 = example248.com +DNS.249 = example249.com +DNS.250 = example250.com +DNS.251 = example251.com +DNS.252 = example252.com +DNS.253 = example253.com +DNS.254 = example254.com +DNS.255 = example255.com +DNS.256 = example256.com +DNS.257 = example257.com +DNS.258 = example258.com +DNS.259 = example259.com +DNS.260 = example260.com +DNS.261 = example261.com +DNS.262 = example262.com +DNS.263 = example263.com +DNS.264 = example264.com +DNS.265 = example265.com +DNS.266 = example266.com +DNS.267 = example267.com +DNS.268 = example268.com +DNS.269 = example269.com +DNS.270 = example270.com +DNS.271 = example271.com +DNS.272 = example272.com +DNS.273 = example273.com +DNS.274 = example274.com +DNS.275 = example275.com +DNS.276 = example276.com +DNS.277 = example277.com +DNS.278 = example278.com +DNS.279 = example279.com +DNS.280 = example280.com +DNS.281 = example281.com +DNS.282 = example282.com +DNS.283 = example283.com +DNS.284 = example284.com +DNS.285 = example285.com +DNS.286 = example286.com +DNS.287 = example287.com +DNS.288 = example288.com +DNS.289 = example289.com +DNS.290 = example290.com +DNS.291 = example291.com +DNS.292 = example292.com +DNS.293 = example293.com +DNS.294 = example294.com +DNS.295 = example295.com +DNS.296 = example296.com +DNS.297 = example297.com +DNS.298 = example298.com +DNS.299 = example299.com +DNS.300 = example300.com +DNS.301 = example301.com +DNS.302 = example302.com +DNS.303 = example303.com +DNS.304 = example304.com +DNS.305 = example305.com +DNS.306 = example306.com +DNS.307 = example307.com +DNS.308 = example308.com +DNS.309 = example309.com +DNS.310 = example310.com +DNS.311 = example311.com +DNS.312 = example312.com +DNS.313 = example313.com +DNS.314 = example314.com +DNS.315 = example315.com +DNS.316 = example316.com +DNS.317 = example317.com +DNS.318 = example318.com +DNS.319 = example319.com +DNS.320 = example320.com +DNS.321 = example321.com +DNS.322 = example322.com +DNS.323 = example323.com +DNS.324 = example324.com +DNS.325 = example325.com +DNS.326 = example326.com +DNS.327 = example327.com +DNS.328 = example328.com +DNS.329 = example329.com +DNS.330 = example330.com +DNS.331 = example331.com +DNS.332 = example332.com +DNS.333 = example333.com +DNS.334 = example334.com +DNS.335 = example335.com +DNS.336 = example336.com +DNS.337 = example337.com +DNS.338 = example338.com +DNS.339 = example339.com +DNS.340 = example340.com +DNS.341 = example341.com +DNS.342 = example342.com +DNS.343 = example343.com +DNS.344 = example344.com +DNS.345 = example345.com +DNS.346 = example346.com +DNS.347 = example347.com +DNS.348 = example348.com +DNS.349 = example349.com +DNS.350 = example350.com +DNS.351 = example351.com +DNS.352 = example352.com +DNS.353 = example353.com +DNS.354 = example354.com +DNS.355 = example355.com +DNS.356 = example356.com +DNS.357 = example357.com +DNS.358 = example358.com +DNS.359 = example359.com +DNS.360 = example360.com +DNS.361 = example361.com +DNS.362 = example362.com +DNS.363 = example363.com +DNS.364 = example364.com +DNS.365 = example365.com +DNS.366 = example366.com +DNS.367 = example367.com +DNS.368 = example368.com +DNS.369 = example369.com +DNS.370 = example370.com +DNS.371 = example371.com +DNS.372 = example372.com +DNS.373 = example373.com +DNS.374 = example374.com +DNS.375 = example375.com +DNS.376 = example376.com +DNS.377 = example377.com +DNS.378 = example378.com +DNS.379 = example379.com +DNS.380 = example380.com +DNS.381 = example381.com +DNS.382 = example382.com +DNS.383 = example383.com +DNS.384 = example384.com +DNS.385 = example385.com +DNS.386 = example386.com +DNS.387 = example387.com +DNS.388 = example388.com +DNS.389 = example389.com +DNS.390 = example390.com +DNS.391 = example391.com +DNS.392 = example392.com +DNS.393 = example393.com +DNS.394 = example394.com +DNS.395 = example395.com +DNS.396 = example396.com +DNS.397 = example397.com +DNS.398 = example398.com +DNS.399 = example399.com +DNS.400 = example400.com +DNS.401 = example401.com +DNS.402 = example402.com +DNS.403 = example403.com +DNS.404 = example404.com +DNS.405 = example405.com +DNS.406 = example406.com +DNS.407 = example407.com +DNS.408 = example408.com +DNS.409 = example409.com +DNS.410 = example410.com +DNS.411 = example411.com +DNS.412 = example412.com +DNS.413 = example413.com +DNS.414 = example414.com +DNS.415 = example415.com +DNS.416 = example416.com +DNS.417 = example417.com +DNS.418 = example418.com +DNS.419 = example419.com +DNS.420 = example420.com +DNS.421 = example421.com +DNS.422 = example422.com +DNS.423 = example423.com +DNS.424 = example424.com +DNS.425 = example425.com +DNS.426 = example426.com +DNS.427 = example427.com +DNS.428 = example428.com +DNS.429 = example429.com +DNS.430 = example430.com +DNS.431 = example431.com +DNS.432 = example432.com +DNS.433 = example433.com +DNS.434 = example434.com +DNS.435 = example435.com +DNS.436 = example436.com +DNS.437 = example437.com +DNS.438 = example438.com +DNS.439 = example439.com +DNS.440 = example440.com +DNS.441 = example441.com +DNS.442 = example442.com +DNS.443 = example443.com +DNS.444 = example444.com +DNS.445 = example445.com +DNS.446 = example446.com +DNS.447 = example447.com +DNS.448 = example448.com +DNS.449 = example449.com +DNS.450 = example450.com +DNS.451 = example451.com +DNS.452 = example452.com +DNS.453 = example453.com +DNS.454 = example454.com +DNS.455 = example455.com +DNS.456 = example456.com +DNS.457 = example457.com +DNS.458 = example458.com +DNS.459 = example459.com +DNS.460 = example460.com +DNS.461 = example461.com +DNS.462 = example462.com +DNS.463 = example463.com +DNS.464 = example464.com +DNS.465 = example465.com +DNS.466 = example466.com +DNS.467 = example467.com +DNS.468 = example468.com +DNS.469 = example469.com +DNS.470 = example470.com +DNS.471 = example471.com +DNS.472 = example472.com +DNS.473 = example473.com +DNS.474 = example474.com +DNS.475 = example475.com +DNS.476 = example476.com +DNS.477 = example477.com +DNS.478 = example478.com +DNS.479 = example479.com +DNS.480 = example480.com +DNS.481 = example481.com +DNS.482 = example482.com +DNS.483 = example483.com +DNS.484 = example484.com +DNS.485 = example485.com +DNS.486 = example486.com +DNS.487 = example487.com +DNS.488 = example488.com +DNS.489 = example489.com +DNS.490 = example490.com +DNS.491 = example491.com +DNS.492 = example492.com +DNS.493 = example493.com +DNS.494 = example494.com +DNS.495 = example495.com +DNS.496 = example496.com +DNS.497 = example497.com +DNS.498 = example498.com +DNS.499 = example499.com +DNS.500 = example500.com +DNS.501 = example501.com +DNS.502 = example502.com +DNS.503 = example503.com +DNS.504 = example504.com +DNS.505 = example505.com +DNS.506 = example506.com +DNS.507 = example507.com +DNS.508 = example508.com +DNS.509 = example509.com +DNS.510 = example510.com +DNS.511 = example511.com +DNS.512 = example512.com +DNS.513 = example513.com +DNS.514 = example514.com +DNS.515 = example515.com +DNS.516 = example516.com +DNS.517 = example517.com +DNS.518 = example518.com +DNS.519 = example519.com +DNS.520 = example520.com +DNS.521 = example521.com +DNS.522 = example522.com +DNS.523 = example523.com +DNS.524 = example524.com +DNS.525 = example525.com +DNS.526 = example526.com +DNS.527 = example527.com +DNS.528 = example528.com +DNS.529 = example529.com +DNS.530 = example530.com +DNS.531 = example531.com +DNS.532 = example532.com +DNS.533 = example533.com +DNS.534 = example534.com +DNS.535 = example535.com +DNS.536 = example536.com +DNS.537 = example537.com +DNS.538 = example538.com +DNS.539 = example539.com +DNS.540 = example540.com +DNS.541 = example541.com +DNS.542 = example542.com +DNS.543 = example543.com +DNS.544 = example544.com +DNS.545 = example545.com +DNS.546 = example546.com +DNS.547 = example547.com +DNS.548 = example548.com +DNS.549 = example549.com +DNS.550 = example550.com +DNS.551 = example551.com +DNS.552 = example552.com +DNS.553 = example553.com +DNS.554 = example554.com +DNS.555 = example555.com +DNS.556 = example556.com +DNS.557 = example557.com +DNS.558 = example558.com +DNS.559 = example559.com +DNS.560 = example560.com +DNS.561 = example561.com +DNS.562 = example562.com +DNS.563 = example563.com +DNS.564 = example564.com +DNS.565 = example565.com +DNS.566 = example566.com +DNS.567 = example567.com +DNS.568 = example568.com +DNS.569 = example569.com +DNS.570 = example570.com +DNS.571 = example571.com +DNS.572 = example572.com +DNS.573 = example573.com +DNS.574 = example574.com +DNS.575 = example575.com +DNS.576 = example576.com +DNS.577 = example577.com +DNS.578 = example578.com +DNS.579 = example579.com +DNS.580 = example580.com +DNS.581 = example581.com +DNS.582 = example582.com +DNS.583 = example583.com +DNS.584 = example584.com +DNS.585 = example585.com +DNS.586 = example586.com +DNS.587 = example587.com +DNS.588 = example588.com +DNS.589 = example589.com +DNS.590 = example590.com +DNS.591 = example591.com +DNS.592 = example592.com +DNS.593 = example593.com +DNS.594 = example594.com +DNS.595 = example595.com +DNS.596 = example596.com +DNS.597 = example597.com +DNS.598 = example598.com +DNS.599 = example599.com +DNS.600 = example600.com +DNS.601 = example601.com +DNS.602 = example602.com +DNS.603 = example603.com +DNS.604 = example604.com +DNS.605 = example605.com +DNS.606 = example606.com +DNS.607 = example607.com +DNS.608 = example608.com +DNS.609 = example609.com +DNS.610 = example610.com +DNS.611 = example611.com +DNS.612 = example612.com +DNS.613 = example613.com +DNS.614 = example614.com +DNS.615 = example615.com +DNS.616 = example616.com +DNS.617 = example617.com +DNS.618 = example618.com +DNS.619 = example619.com +DNS.620 = example620.com +DNS.621 = example621.com +DNS.622 = example622.com +DNS.623 = example623.com +DNS.624 = example624.com +DNS.625 = example625.com +DNS.626 = example626.com +DNS.627 = example627.com +DNS.628 = example628.com +DNS.629 = example629.com +DNS.630 = example630.com +DNS.631 = example631.com +DNS.632 = example632.com +DNS.633 = example633.com +DNS.634 = example634.com +DNS.635 = example635.com +DNS.636 = example636.com +DNS.637 = example637.com +DNS.638 = example638.com +DNS.639 = example639.com +DNS.640 = example640.com +DNS.641 = example641.com +DNS.642 = example642.com +DNS.643 = example643.com +DNS.644 = example644.com +DNS.645 = example645.com +DNS.646 = example646.com +DNS.647 = example647.com +DNS.648 = example648.com +DNS.649 = example649.com +DNS.650 = example650.com +DNS.651 = example651.com +DNS.652 = example652.com +DNS.653 = example653.com +DNS.654 = example654.com +DNS.655 = example655.com +DNS.656 = example656.com +DNS.657 = example657.com +DNS.658 = example658.com +DNS.659 = example659.com +DNS.660 = example660.com +DNS.661 = example661.com +DNS.662 = example662.com +DNS.663 = example663.com +DNS.664 = example664.com +DNS.665 = example665.com +DNS.666 = example666.com +DNS.667 = example667.com +DNS.668 = example668.com +DNS.669 = example669.com +DNS.670 = example670.com +DNS.671 = example671.com +DNS.672 = example672.com +DNS.673 = example673.com +DNS.674 = example674.com +DNS.675 = example675.com +DNS.676 = example676.com +DNS.677 = example677.com +DNS.678 = example678.com +DNS.679 = example679.com +DNS.680 = example680.com +DNS.681 = example681.com +DNS.682 = example682.com +DNS.683 = example683.com +DNS.684 = example684.com +DNS.685 = example685.com +DNS.686 = example686.com +DNS.687 = example687.com +DNS.688 = example688.com +DNS.689 = example689.com +DNS.690 = example690.com +DNS.691 = example691.com +DNS.692 = example692.com +DNS.693 = example693.com +DNS.694 = example694.com +DNS.695 = example695.com +DNS.696 = example696.com +DNS.697 = example697.com +DNS.698 = example698.com +DNS.699 = example699.com +DNS.700 = example700.com +DNS.701 = example701.com +DNS.702 = example702.com +DNS.703 = example703.com +DNS.704 = example704.com +DNS.705 = example705.com +DNS.706 = example706.com +DNS.707 = example707.com +DNS.708 = example708.com +DNS.709 = example709.com +DNS.710 = example710.com +DNS.711 = example711.com +DNS.712 = example712.com +DNS.713 = example713.com +DNS.714 = example714.com +DNS.715 = example715.com +DNS.716 = example716.com +DNS.717 = example717.com +DNS.718 = example718.com +DNS.719 = example719.com +DNS.720 = example720.com +DNS.721 = example721.com +DNS.722 = example722.com +DNS.723 = example723.com +DNS.724 = example724.com +DNS.725 = example725.com +DNS.726 = example726.com +DNS.727 = example727.com +DNS.728 = example728.com +DNS.729 = example729.com +DNS.730 = example730.com +DNS.731 = example731.com +DNS.732 = example732.com +DNS.733 = example733.com +DNS.734 = example734.com +DNS.735 = example735.com +DNS.736 = example736.com +DNS.737 = example737.com +DNS.738 = example738.com +DNS.739 = example739.com +DNS.740 = example740.com +DNS.741 = example741.com +DNS.742 = example742.com +DNS.743 = example743.com +DNS.744 = example744.com +DNS.745 = example745.com +DNS.746 = example746.com +DNS.747 = example747.com +DNS.748 = example748.com +DNS.749 = example749.com +DNS.750 = example750.com +DNS.751 = example751.com +DNS.752 = example752.com +DNS.753 = example753.com +DNS.754 = example754.com +DNS.755 = example755.com +DNS.756 = example756.com +DNS.757 = example757.com +DNS.758 = example758.com +DNS.759 = example759.com +DNS.760 = example760.com +DNS.761 = example761.com +DNS.762 = example762.com +DNS.763 = example763.com +DNS.764 = example764.com +DNS.765 = example765.com +DNS.766 = example766.com +DNS.767 = example767.com +DNS.768 = example768.com +DNS.769 = example769.com +DNS.770 = example770.com +DNS.771 = example771.com +DNS.772 = example772.com +DNS.773 = example773.com +DNS.774 = example774.com +DNS.775 = example775.com +DNS.776 = example776.com +DNS.777 = example777.com +DNS.778 = example778.com +DNS.779 = example779.com +DNS.780 = example780.com +DNS.781 = example781.com +DNS.782 = example782.com +DNS.783 = example783.com +DNS.784 = example784.com +DNS.785 = example785.com +DNS.786 = example786.com +DNS.787 = example787.com +DNS.788 = example788.com +DNS.789 = example789.com +DNS.790 = example790.com +DNS.791 = example791.com +DNS.792 = example792.com +DNS.793 = example793.com +DNS.794 = example794.com +DNS.795 = example795.com +DNS.796 = example796.com +DNS.797 = example797.com +DNS.798 = example798.com +DNS.799 = example799.com +DNS.800 = example800.com +DNS.801 = example801.com +DNS.802 = example802.com +DNS.803 = example803.com +DNS.804 = example804.com +DNS.805 = example805.com +DNS.806 = example806.com +DNS.807 = example807.com +DNS.808 = example808.com +DNS.809 = example809.com +DNS.810 = example810.com +DNS.811 = example811.com +DNS.812 = example812.com +DNS.813 = example813.com +DNS.814 = example814.com +DNS.815 = example815.com +DNS.816 = example816.com +DNS.817 = example817.com +DNS.818 = example818.com +DNS.819 = example819.com +DNS.820 = example820.com +DNS.821 = example821.com +DNS.822 = example822.com +DNS.823 = example823.com +DNS.824 = example824.com +DNS.825 = example825.com +DNS.826 = example826.com +DNS.827 = example827.com +DNS.828 = example828.com +DNS.829 = example829.com +DNS.830 = example830.com +DNS.831 = example831.com +DNS.832 = example832.com +DNS.833 = example833.com +DNS.834 = example834.com +DNS.835 = example835.com +DNS.836 = example836.com +DNS.837 = example837.com +DNS.838 = example838.com +DNS.839 = example839.com +DNS.840 = example840.com +DNS.841 = example841.com +DNS.842 = example842.com +DNS.843 = example843.com +DNS.844 = example844.com +DNS.845 = example845.com +DNS.846 = example846.com +DNS.847 = example847.com +DNS.848 = example848.com +DNS.849 = example849.com +DNS.850 = example850.com +DNS.851 = example851.com +DNS.852 = example852.com +DNS.853 = example853.com +DNS.854 = example854.com +DNS.855 = example855.com +DNS.856 = example856.com +DNS.857 = example857.com +DNS.858 = example858.com +DNS.859 = example859.com +DNS.860 = example860.com +DNS.861 = example861.com +DNS.862 = example862.com +DNS.863 = example863.com +DNS.864 = example864.com +DNS.865 = example865.com +DNS.866 = example866.com +DNS.867 = example867.com +DNS.868 = example868.com +DNS.869 = example869.com +DNS.870 = example870.com +DNS.871 = example871.com +DNS.872 = example872.com +DNS.873 = example873.com +DNS.874 = example874.com +DNS.875 = example875.com +DNS.876 = example876.com +DNS.877 = example877.com +DNS.878 = example878.com +DNS.879 = example879.com +DNS.880 = example880.com +DNS.881 = example881.com +DNS.882 = example882.com +DNS.883 = example883.com +DNS.884 = example884.com +DNS.885 = example885.com +DNS.886 = example886.com +DNS.887 = example887.com +DNS.888 = example888.com +DNS.889 = example889.com +DNS.890 = example890.com +DNS.891 = example891.com +DNS.892 = example892.com +DNS.893 = example893.com +DNS.894 = example894.com +DNS.895 = example895.com +DNS.896 = example896.com +DNS.897 = example897.com +DNS.898 = example898.com +DNS.899 = example899.com +DNS.900 = example900.com +DNS.901 = example901.com +DNS.902 = example902.com +DNS.903 = example903.com +DNS.904 = example904.com +DNS.905 = example905.com +DNS.906 = example906.com +DNS.907 = example907.com +DNS.908 = example908.com +DNS.909 = example909.com +DNS.910 = example910.com +DNS.911 = example911.com +DNS.912 = example912.com +DNS.913 = example913.com +DNS.914 = example914.com +DNS.915 = example915.com +DNS.916 = example916.com +DNS.917 = example917.com +DNS.918 = example918.com +DNS.919 = example919.com +DNS.920 = example920.com +DNS.921 = example921.com +DNS.922 = example922.com +DNS.923 = example923.com +DNS.924 = example924.com +DNS.925 = example925.com +DNS.926 = example926.com +DNS.927 = example927.com +DNS.928 = example928.com +DNS.929 = example929.com +DNS.930 = example930.com +DNS.931 = example931.com +DNS.932 = example932.com +DNS.933 = example933.com +DNS.934 = example934.com +DNS.935 = example935.com +DNS.936 = example936.com +DNS.937 = example937.com +DNS.938 = example938.com +DNS.939 = example939.com +DNS.940 = example940.com +DNS.941 = example941.com +DNS.942 = example942.com +DNS.943 = example943.com +DNS.944 = example944.com +DNS.945 = example945.com +DNS.946 = example946.com +DNS.947 = example947.com +DNS.948 = example948.com +DNS.949 = example949.com +DNS.950 = example950.com +DNS.951 = example951.com +DNS.952 = example952.com +DNS.953 = example953.com +DNS.954 = example954.com +DNS.955 = example955.com +DNS.956 = example956.com +DNS.957 = example957.com +DNS.958 = example958.com +DNS.959 = example959.com +DNS.960 = example960.com +DNS.961 = example961.com +DNS.962 = example962.com +DNS.963 = example963.com +DNS.964 = example964.com +DNS.965 = example965.com +DNS.966 = example966.com +DNS.967 = example967.com +DNS.968 = example968.com +DNS.969 = example969.com +DNS.970 = example970.com +DNS.971 = example971.com +DNS.972 = example972.com +DNS.973 = example973.com +DNS.974 = example974.com +DNS.975 = example975.com +DNS.976 = example976.com +DNS.977 = example977.com +DNS.978 = example978.com +DNS.979 = example979.com +DNS.980 = example980.com +DNS.981 = example981.com +DNS.982 = example982.com +DNS.983 = example983.com +DNS.984 = example984.com +DNS.985 = example985.com +DNS.986 = example986.com +DNS.987 = example987.com +DNS.988 = example988.com +DNS.989 = example989.com +DNS.990 = example990.com +DNS.991 = example991.com +DNS.992 = example992.com +DNS.993 = example993.com +DNS.994 = example994.com +DNS.995 = example995.com +DNS.996 = example996.com +DNS.997 = example997.com +DNS.998 = example998.com +DNS.999 = example999.com +DNS.1000 = example1000.com +DNS.1001 = example1001.com +DNS.1002 = example1002.com +DNS.1003 = example1003.com +DNS.1004 = example1004.com +DNS.1005 = example1005.com +DNS.1006 = example1006.com +DNS.1007 = example1007.com +DNS.1008 = example1008.com +DNS.1009 = example1009.com +DNS.1010 = example1010.com +DNS.1011 = example1011.com +DNS.1012 = example1012.com +DNS.1013 = example1013.com +DNS.1014 = example1014.com +DNS.1015 = example1015.com +DNS.1016 = example1016.com +DNS.1017 = example1017.com +DNS.1018 = example1018.com +DNS.1019 = example1019.com +DNS.1020 = example1020.com +DNS.1021 = example1021.com +DNS.1022 = example1022.com +DNS.1023 = example1023.com +DNS.1024 = example1024.com +DNS.1025 = example1025.com +DNS.1026 = example1026.com +DNS.1027 = example1027.com +DNS.1028 = example1028.com +DNS.1029 = example1029.com +DNS.1030 = example1030.com +DNS.1031 = example1031.com +DNS.1032 = example1032.com +DNS.1033 = example1033.com +DNS.1034 = example1034.com +DNS.1035 = example1035.com +DNS.1036 = example1036.com +DNS.1037 = example1037.com +DNS.1038 = example1038.com +DNS.1039 = example1039.com +DNS.1040 = example1040.com +DNS.1041 = example1041.com +DNS.1042 = example1042.com +DNS.1043 = example1043.com +DNS.1044 = example1044.com +DNS.1045 = example1045.com +DNS.1046 = example1046.com +DNS.1047 = example1047.com +DNS.1048 = example1048.com +DNS.1049 = example1049.com +DNS.1050 = example1050.com + EOF gen_cert diff --git a/cmake/functions.cmake b/cmake/functions.cmake index ebba36948b..3c8832c2c3 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -78,10 +78,10 @@ function(generate_build_flags) if(WOLFSSL_AESCCM OR WOLFSSL_USER_SETTINGS) set(BUILD_AESCCM "yes" PARENT_SCOPE) endif() - set(BUILD_ARM_ASM ${WOLFSSL_ARM_ASM} PARENT_SCOPE) + set(BUILD_ARMASM ${WOLFSSL_ARM_ASM} PARENT_SCOPE) set(BUILD_XILINX ${WOLFSSL_XILINX} PARENT_SCOPE) set(BUILD_AESNI ${WOLFSSL_AESNI} PARENT_SCOPE) - set(BUILD_INTEL_ASM ${WOLFSSL_INTEL_ASM} PARENT_SCOPE) + set(BUILD_INTELASM ${WOLFSSL_INTEL_ASM} PARENT_SCOPE) set(BUILD_AFALG ${WOLFSSL_AFALG} PARENT_SCOPE) set(BUILD_DEVCRYPTO ${WOLFSSL_DEVCRYPTO} PARENT_SCOPE) if(WOLFSSL_CAMELLIA OR WOLFSSL_USER_SETTINGS) @@ -198,6 +198,9 @@ function(generate_build_flags) if(WOLFSSL_XCHACHA OR WOLFSSL_USER_SETTINGS) set(BUILD_XCHACHA "yes" PARENT_SCOPE) endif() + if(WOLFSSL_KYBER OR WOLFSSL_USER_SETTINGS) + set(BUILD_WC_KYBER "yes" PARENT_SCOPE) + endif() if(WOLFSSL_OQS OR WOLFSSL_USER_SETTINGS) set(BUILD_FALCON "yes" PARENT_SCOPE) set(BUILD_SPHINCS "yes" PARENT_SCOPE) @@ -396,6 +399,10 @@ function(generate_lib_src_list LIB_SOURCES) if(BUILD_SHA3) list(APPEND LIB_SOURCES wolfcrypt/src/sha3.c) + + if(BUILD_INTELASM) + list(APPEND LIB_SOURCES wolfcrypt/src/sha3_asm.S) + endif() endif() if(BUILD_DH) @@ -579,6 +586,10 @@ function(generate_lib_src_list LIB_SOURCES) if(NOT BUILD_FIPS_V2 AND BUILD_SHA3) list(APPEND LIB_SOURCES wolfcrypt/src/sha3.c) + + if(BUILD_INTELASM) + list(APPEND LIB_SOURCES wolfcrypt/src/sha3_asm.S) + endif() endif() endif() @@ -794,6 +805,15 @@ function(generate_lib_src_list LIB_SOURCES) list(APPEND LIB_SOURCES wolfcrypt/src/dilithium.c) endif() + if(BUILD_WC_KYBER) + list(APPEND LIB_SOURCES wolfcrypt/src/wc_kyber.c) + list(APPEND LIB_SOURCES wolfcrypt/src/wc_kyber_poly.c) + + if(BUILD_INTELASM) + list(APPEND LIB_SOURCES wolfcrypt/src/wc_kyber_asm.S) + endif() + endif() + if(BUILD_EXT_KYBER) list(APPEND LIB_SOURCES wolfcrypt/src/ext_kyber.c) endif() diff --git a/configure.ac b/configure.ac index 1d8eb993b2..970cc50810 100644 --- a/configure.ac +++ b/configure.ac @@ -333,7 +333,7 @@ then test -z "$enable_all_crypto" && enable_all_crypto=yes test -z "$enable_opensslcoexist" && enable_opensslcoexist=yes test -z "$enable_sha" && enable_sha=yes - test -z "$enable_eccminsz" && enable_eccminsz=192 + test -z "$with_eccminsz" && with_eccminsz=192 test -z "$with_max_ecc_bits" && with_max_ecc_bits=1024 AM_CFLAGS="$AM_CFLAGS -DWC_RSA_NO_PADDING -DWOLFSSL_PUBLIC_MP -DHAVE_PUBLIC_FFDHE -DHAVE_FFDHE_6144 -DHAVE_FFDHE_8192 -DWOLFSSL_PSS_LONG_SALT -DWOLFSSL_PSS_SALT_LEN_DISCOVER" fi @@ -345,6 +345,11 @@ AC_ARG_ENABLE([engine], [ ENABLED_WOLFENGINE=no ] ) +if test "x$ENABLED_WOLFENGINE" != "xno" +then + test -z "$with_eccminsz" && with_eccminsz=192 +fi + AS_CASE([$ENABLED_WOLFENGINE], [no],[ ENABLED_WOLFENGINE="no" @@ -889,7 +894,6 @@ then test "$enable_blake2s" = "" && enable_blake2s=yes test "$enable_md2" = "" && enable_md2=yes test "$enable_md4" = "" && enable_md4=yes - test "$enable_cryptocb" = "" && enable_cryptocb=yes test "$enable_anon" = "" && enable_anon=yes test "$enable_ssh" = "" && test "$enable_hmac" != "no" && enable_ssh=yes @@ -955,6 +959,7 @@ then if test "$ENABLED_FIPS" = "no" then + test "$enable_cryptocb" = "" && enable_cryptocb=yes test "$enable_pkcallbacks" = "" && enable_pkcallbacks=yes test "$enable_xchacha" = "" && test "$enable_chacha" != "no" && enable_xchacha=yes test "$enable_scep" = "" && enable_scep=yes @@ -1080,7 +1085,6 @@ then test "$enable_blake2s" = "" && enable_blake2s=yes test "$enable_md2" = "" && enable_md2=yes test "$enable_md4" = "" && enable_md4=yes - test "$enable_cryptocb" = "" && enable_cryptocb=yes test "$enable_anon" = "" && enable_anon=yes test "$enable_ssh" = "" && test "$enable_hmac" != "no" && enable_ssh=yes test "$enable_srtp_kdf" = "" && enable_srtp_kdf=yes @@ -1102,6 +1106,7 @@ then if test "$ENABLED_FIPS" = "no" then + test "$enable_cryptocb" = "" && enable_cryptocb=yes test "$enable_pkcallbacks" = "" && enable_pkcallbacks=yes test "$enable_xchacha" = "" && test "$enable_chacha" != "no" && enable_xchacha=yes test "$enable_pkcs7" = "" && enable_pkcs7=yes @@ -1817,6 +1822,7 @@ AC_ARG_ENABLE([mcast], # OpenLDAP (--enable-openldap) # hitch (--enable-hitch) # memcached (--enable-memcached) +# Mosquitto (--enable-mosquitto) HAVE_MOSQUITTO # Bind DNS compatibility Build AC_ARG_ENABLE([bind], @@ -1880,12 +1886,25 @@ AC_ARG_ENABLE([openldap], [ ENABLED_OPENLDAP=no ] ) +# Mosquitto support +AC_ARG_ENABLE([mosquitto], + [AS_HELP_STRING([--enable-mosquitto],[Enable Mosquitto support (default: disabled)])], + [ ENABLED_MOSQUITTO=$enableval ], + [ ENABLED_MOSQUITTO=no ] + ) + +if test "x$ENABLED_MOSQUITTO" = "xyes" +then + AM_CFLAGS="$AM_CFLAGS -DHAVE_MOSQUITTO" +fi + # lighty Support AC_ARG_ENABLE([lighty], [AS_HELP_STRING([--enable-lighty],[Enable lighttpd/lighty (default: disabled)])], [ ENABLED_LIGHTY=$enableval ], [ ENABLED_LIGHTY=no ] ) + # rsyslog Support AC_ARG_ENABLE([rsyslog], [AS_HELP_STRING([--enable-rsyslog],[Enable rsyslog (default: disabled)])], @@ -1973,7 +1992,7 @@ AC_ARG_ENABLE([ffmpeg], ) -#IP alternative name Support +# IP alternative name Support AC_ARG_ENABLE([ip-alt-name], [AS_HELP_STRING([--enable-ip-alt-name],[Enable IP subject alternative name (default: disabled)])], [ ENABLE_IP_ALT_NAME=$enableval ], @@ -1985,7 +2004,7 @@ then AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_IP_ALT_NAME" fi -#Qt Support +# QT Support AC_ARG_ENABLE([qt], [AS_HELP_STRING([--enable-qt],[Enable qt (default: disabled)])], [ ENABLED_QT=$enableval ], @@ -2145,7 +2164,7 @@ if test "$ENABLED_LIBWEBSOCKETS" = "yes" || test "$ENABLED_OPENVPN" = "yes" || \ test "$ENABLED_OPENRESTY" = "yes" || test "$ENABLED_RSYSLOG" = "yes" || \ test "$ENABLED_KRB" = "yes" || test "$ENABLED_CHRONY" = "yes" || \ test "$ENABLED_FFMPEG" = "yes" || test "$ENABLED_STRONGSWAN" = "yes" || \ - test "$ENABLED_OPENLDAP" = "yes" || test "$ENABLED_HITCH" = "yes" + test "$ENABLED_OPENLDAP" = "yes" || test "x$ENABLED_MOSQUITTO" = "xyes" || test "$ENABLED_HITCH" = "yes" then ENABLED_OPENSSLALL="yes" fi @@ -3058,10 +3077,14 @@ do AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_RISCV_CARRYLESS" ;; zkn|zkned) - # AES encrypt/decrpyt + # AES encrypt/decrpyt, SHA-2 ENABLED_RISCV_ASM=yes AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_RISCV_SCALAR_CRYPTO_ASM" ;; + zv) + ENABLED_RISCV_ASM=yes + AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_RISCV_VECTOR" + ;; zvkg) # VGMUL, VHHSH ENABLED_RISCV_ASM=yes @@ -3078,12 +3101,12 @@ do AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_RISCV_VECTOR_BASE_BIT_MANIPULATION" ;; zvkned) - # Vector AES + # Vector AES, SHA-2 ENABLED_RISCV_ASM=yes AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_RISCV_VECTOR_CRYPTO_ASM" ;; *) - AC_MSG_ERROR([Invalid RISC-V option [yes,zbkb,zbb,zbc,zbkc,zkn,zkned,zvkg,zvbc,zvbb,zvkb,zvkned]: $ENABLED_RISCV_ASM.]) + AC_MSG_ERROR([Invalid RISC-V option [yes,zbkb,zbb,zbc,zbkc,zkn,zkned,zv,zvkg,zvbc,zvbb,zvkb,zvkned]: $ENABLED_RISCV_ASM.]) break ;; esac @@ -3551,11 +3574,6 @@ AC_ARG_ENABLE([nullcipher], [ ENABLED_NULL_CIPHER=no ] ) -if test "$ENABLED_OPENSSH" = "yes" -then - ENABLED_NULL_CIPHER="yes" -fi - if test "$ENABLED_NULL_CIPHER" = "yes" then AM_CFLAGS="$AM_CFLAGS -DHAVE_NULL_CIPHER" @@ -3742,7 +3760,7 @@ AC_ARG_ENABLE([sessioncerts], if test "x$ENABLED_NGINX" = "xyes" || test "x$ENABLED_OPENVPN" = "xyes" || \ test "x$ENABLED_LIGHTY" = "xyes" || test "x$ENABLED_NETSNMP" = "xyes" || \ - test "x$ENABLED_STRONGSWAN" = "xyes" || test "x$ENABLED_HITCH" = "xyes" + test "x$ENABLED_STRONGSWAN" = "xyes" || test "x$ENABLED_HITCH" = "xyes" || test "x$ENABLED_MOSQUITTO" = "xyes" then ENABLED_SESSIONCERTS=yes fi @@ -4226,6 +4244,11 @@ AC_ARG_ENABLE([psk], [ ENABLED_PSK=no ] ) +if test "x$ENABLED_MOSQUITTO" = "xyes" +then + ENABLED_PSK=yes +fi + # Single PSK identity AC_ARG_ENABLE([psk-one-id], [AS_HELP_STRING([--enable-psk-one-id],[Enable PSK (default: disabled)])], @@ -4720,43 +4743,52 @@ fi # ASN + # turn off asn, which means no certs, no rsa, no dsa, no ecc, # and no big int (unless dh is on) + +# turn off ASN if leanpsk on +if test "$ENABLED_LEANPSK" = "yes" +then + enable_asn=no +fi + AC_ARG_ENABLE([asn], [AS_HELP_STRING([--enable-asn],[Enable ASN (default: enabled)])], [ ENABLED_ASN=$enableval ], [ ENABLED_ASN=yes ] ) -if test "$ENABLED_ASN" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_ASN -DNO_ASN_CRYPT" - enable_pwdbased=no -else - if test "$ENABLED_ASN" = "template"; then - ENABLED_ASN="yes" - fi - if test "$ENABLED_ASN" = "yes"; then +for v in `echo $ENABLED_ASN | tr "," " "` +do + case $v in + all) + # Enable all ASN features + AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ASN_ALL" + ENABLED_ASN=yes + ;; + template | yes) AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ASN_TEMPLATE" - else - if test "$ENABLED_ASN" != "original"; then - AC_MSG_ERROR([Invalid asn option. Valid are: template or original. Seen: $ENABLED_ASN.]) - fi - fi - - # turn off ASN if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_ASN -DNO_BIG_INT" + ENABLED_ASN=yes + ;; + original) + AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ASN_ORIGINAL" + ENABLED_ASN=yes + ;; + nocrypt) + AM_CFLAGS="$AM_CFLAGS -DNO_ASN_CRYPT" + enable_pwdbased=no + ;; + no) + AM_CFLAGS="$AM_CFLAGS -DNO_ASN -DNO_ASN_CRYPT" + enable_pwdbased=no ENABLED_ASN=no - else - if test "$ENABLED_ASN" = "nocrypt" - then - AM_CFLAGS="$AM_CFLAGS -DNO_ASN_CRYPT" - enable_pwdbased=no - fi - fi -fi + ;; + *) + AC_MSG_ERROR([Invalid asn option. Valid are: all, template/yes, original, nocrypt or no. Seen: $ENABLED_ASN.]) + break;; +esac +done if test "$ENABLED_RSA" = "yes" && test "$ENABLED_RSAVFY" = "no" && \ test "$ENABLED_ASN" = "no" && test "$ENABLED_LOWRESOURCE" = "no" @@ -4769,11 +4801,6 @@ then AC_MSG_ERROR([please disable dsa if disabling asn.]) fi -if test "x$ENABLED_ECC" != "xno" && test "x$ENABLED_ASN" = "xno" -then - AC_MSG_ERROR([please disable ecc if disabling asn.]) -fi - # No Big Int (ASN, DSA, RSA, DH, ECC and compatibility layer need bigint) if test "$ENABLED_ASN" = "no" && test "$ENABLED_DSA" = "no" && \ test "$ENABLED_DH" = "no" && test "$ENABLED_ECC" = "no" && \ @@ -5851,7 +5878,8 @@ fi # OCSP -if test "x$ENABLED_OPENSSLALL" = "xyes" || test "x$ENABLED_NGINX" = "xyes" || test "x$ENABLED_LIGHTY" = "xyes" +if test "x$ENABLED_OPENSSLALL" = "xyes" || test "x$ENABLED_NGINX" = "xyes" || \ + test "x$ENABLED_LIGHTY" = "xyes" || test "x$ENABLED_MOSQUITTO" = "xyes" then test "$enable_ocsp" = "" && enable_ocsp=yes fi @@ -5883,7 +5911,9 @@ AC_ARG_ENABLE([ocspstapling], [ ENABLED_CERTIFICATE_STATUS_REQUEST=no ] ) -if test "x$ENABLED_NGINX" = "xyes" || test "x$ENABLED_WPAS" = "xyes" || test "x$ENABLED_HAPROXY" = "xyes" || test "x$ENABLED_LIGHTY" = "xyes" +if test "x$ENABLED_NGINX" = "xyes" || test "x$ENABLED_WPAS" = "xyes" || \ + test "x$ENABLED_HAPROXY" = "xyes" || test "x$ENABLED_LIGHTY" = "xyes" || \ + test "x$ENABLED_MOSQUITTO" = "xyes" then ENABLED_CERTIFICATE_STATUS_REQUEST="yes" fi @@ -5931,9 +5961,11 @@ AC_ARG_ENABLE([crl], [ ENABLED_CRL=no ] ) -if test "x$ENABLED_NGINX" = "xyes" || test "x$ENABLED_HAPROXY" = "xyes" || test "x$ENABLED_OPENVPN" = "xyes" || \ - test "x$ENABLED_WPAS" != "xno" || test "x$ENABLED_LIGHTY" = "xyes" || test "x$ENABLED_NETSNMP" = "xyes" || \ - test "x$ENABLED_KRB" = "xyes" || test "x$ENABLED_STRONGSWAN" = "xyes" +if test "x$ENABLED_NGINX" = "xyes" || test "x$ENABLED_HAPROXY" = "xyes" || \ + test "x$ENABLED_OPENVPN" = "xyes" || test "x$ENABLED_WPAS" != "xno" || \ + test "x$ENABLED_LIGHTY" = "xyes" || test "x$ENABLED_NETSNMP" = "xyes" || \ + test "x$ENABLED_KRB" = "xyes" || test "x$ENABLED_STRONGSWAN" = "xyes" || \ + test "x$ENABLED_MOSQUITTO" = "xyes" then ENABLED_CRL=yes fi @@ -8947,7 +8979,7 @@ if test "$ENABLED_OPENSSH" = "yes" || test "$ENABLED_NGINX" = "yes" || \ test "$ENABLED_LIBWEBSOCKETS" = "yes" || \ test "x$ENABLED_LIGHTY" = "xyes" || test "$ENABLED_LIBSSH2" = "yes" || \ test "x$ENABLED_NTP" = "xyes" || test "$ENABLED_RSYSLOG" = "yes" || \ - test "$ENABLED_OPENLDAP" = "yes" || test "$ENABLED_HITCH" = "yes" + test "$ENABLED_OPENLDAP" = "yes" || test "$ENABLED_HITCH" = "yes" || test "x$ENABLED_MOSQUITTO" = "xyes" then ENABLED_OPENSSLEXTRA="yes" fi @@ -9139,6 +9171,8 @@ AS_IF([test "x$ENABLED_STRONGSWAN" = "xyes"], AS_IF([test "x$ENABLED_OPENLDAP" = "xyes"], [AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SIGNER_DER_CERT"]) +AS_IF([test "x$ENABLED_MOSQUITTO" = "xyes"], [AM_CFLAGS="$AM_CFLAGS -DHAVE_EX_DATA"]) + if test "$ENABLED_ED25519_STREAM" != "no" && test "$ENABLED_SE050" != "yes" then AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ED25519_STREAMING_VERIFY" @@ -9321,7 +9355,6 @@ then AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_AES_DIRECT" AM_CFLAGS="$AM_CFLAGS -DWC_RSA_NO_PADDING" AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_PUBLIC_MP" - AM_CFLAGS="$AM_CFLAGS -DECC_MIN_KEY_SZ=192" fi if test "$ENABLED_WOLFENGINE" = "yes" && test "$ENABLED_FIPS" != "no" @@ -10181,6 +10214,7 @@ echo " * strongSwan: $ENABLED_STRONGSWAN" echo " * OpenLDAP: $ENABLED_OPENLDAP" echo " * hitch: $ENABLED_HITCH" echo " * memcached: $ENABLED_MEMCACHED" +echo " * Mosquitto $ENABLED_MOSQUITTO" echo " * ERROR_STRINGS: $ENABLED_ERROR_STRINGS" echo " * DTLS: $ENABLED_DTLS" echo " * DTLS v1.3: $ENABLED_DTLS13" diff --git a/examples/asn1/asn1.c b/examples/asn1/asn1.c index 4cf1d5b928..92a0a19528 100644 --- a/examples/asn1/asn1.c +++ b/examples/asn1/asn1.c @@ -1,6 +1,6 @@ /* asn1.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/async/async_client.c b/examples/async/async_client.c index a0df6a1465..27d66df9ce 100644 --- a/examples/async/async_client.c +++ b/examples/async/async_client.c @@ -1,8 +1,8 @@ /* async_client.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * - * This file is part of wolfSSL. (formerly known as CyaSSL) + * This file is part of wolfSSL. * * wolfSSL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ /* TLS client demonstrating asynchronous cryptography features and optionally diff --git a/examples/async/async_server.c b/examples/async/async_server.c index 41eaae86ec..6740c0b37c 100644 --- a/examples/async/async_server.c +++ b/examples/async/async_server.c @@ -1,8 +1,8 @@ /* async_server.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * - * This file is part of wolfSSL. (formerly known as CyaSSL) + * This file is part of wolfSSL. * * wolfSSL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ /* TLS server demonstrating asynchronous cryptography features and optionally diff --git a/examples/async/async_tls.c b/examples/async/async_tls.c index 1d4f68d530..4ab9de003c 100644 --- a/examples/async/async_tls.c +++ b/examples/async/async_tls.c @@ -1,8 +1,8 @@ /* async-tls.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * - * This file is part of wolfSSL. (formerly known as CyaSSL) + * This file is part of wolfSSL. * * wolfSSL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ #ifndef WOLFSSL_USER_SETTINGS diff --git a/examples/async/async_tls.h b/examples/async/async_tls.h index d5403e24f2..43b249021c 100644 --- a/examples/async/async_tls.h +++ b/examples/async/async_tls.h @@ -1,6 +1,6 @@ /* async-tls.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/benchmark/tls_bench.c b/examples/benchmark/tls_bench.c index 24901b7a22..585fa7b2d0 100644 --- a/examples/benchmark/tls_bench.c +++ b/examples/benchmark/tls_bench.c @@ -1,6 +1,6 @@ /* tls_bench.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/benchmark/tls_bench.h b/examples/benchmark/tls_bench.h index 6ed021b63d..67599cb1c5 100644 --- a/examples/benchmark/tls_bench.h +++ b/examples/benchmark/tls_bench.h @@ -1,6 +1,6 @@ /* tls_bench.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/client/client.c b/examples/client/client.c index cd0394f13d..3a63ff74c0 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -1,6 +1,6 @@ /* client.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -3585,8 +3585,11 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args) #endif #endif #if defined(WOLFSSL_TLS13) && defined(WOLFSSL_POST_HANDSHAKE_AUTH) - if (postHandAuth) - wolfSSL_CTX_allow_post_handshake_auth(ctx); + if (postHandAuth) { + if (wolfSSL_CTX_allow_post_handshake_auth(ctx) != 0) { + err_sys("unable to support post handshake auth"); + } + } #endif if (benchmark) { diff --git a/examples/client/client.h b/examples/client/client.h index 3317670e59..09581fcac7 100644 --- a/examples/client/client.h +++ b/examples/client/client.h @@ -1,6 +1,6 @@ /* client.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/configs/user_settings_EBSnet.h b/examples/configs/user_settings_EBSnet.h index 3d1486998b..dacd02af0d 100644 --- a/examples/configs/user_settings_EBSnet.h +++ b/examples/configs/user_settings_EBSnet.h @@ -1,6 +1,6 @@ /* user_settings_EBSnet.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/configs/user_settings_all.h b/examples/configs/user_settings_all.h index c484b90bef..6020423b27 100644 --- a/examples/configs/user_settings_all.h +++ b/examples/configs/user_settings_all.h @@ -1,6 +1,6 @@ /* user_settings_all.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/configs/user_settings_arduino.h b/examples/configs/user_settings_arduino.h index cf64c75d77..178511ed0f 100644 --- a/examples/configs/user_settings_arduino.h +++ b/examples/configs/user_settings_arduino.h @@ -1,6 +1,6 @@ /* examples/configs/user_settings_arduino.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/configs/user_settings_fipsv2.h b/examples/configs/user_settings_fipsv2.h index f6096341e4..b15b1283b2 100644 --- a/examples/configs/user_settings_fipsv2.h +++ b/examples/configs/user_settings_fipsv2.h @@ -1,6 +1,6 @@ /* user_settings_fipsv2.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/configs/user_settings_fipsv5.h b/examples/configs/user_settings_fipsv5.h index 9f6bbfd463..afc4b63c9b 100644 --- a/examples/configs/user_settings_fipsv5.h +++ b/examples/configs/user_settings_fipsv5.h @@ -1,6 +1,6 @@ /* user_settings_fipsv5.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/configs/user_settings_min_ecc.h b/examples/configs/user_settings_min_ecc.h index f052500331..e43fb08418 100644 --- a/examples/configs/user_settings_min_ecc.h +++ b/examples/configs/user_settings_min_ecc.h @@ -1,6 +1,6 @@ /* user_settings_min_ecc.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/configs/user_settings_stm32.h b/examples/configs/user_settings_stm32.h index 9f02cf2bf5..20f0d5cfa7 100644 --- a/examples/configs/user_settings_stm32.h +++ b/examples/configs/user_settings_stm32.h @@ -1,7 +1,7 @@ /* wolfSSL_conf.h (example of generated wolfSSL.I-CUBE-wolfSSL_conf.h using * default_conf.ftl and STM32CubeIDE or STM32CubeMX tool) * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/configs/user_settings_template.h b/examples/configs/user_settings_template.h index f8673fab34..b7c0700b6e 100644 --- a/examples/configs/user_settings_template.h +++ b/examples/configs/user_settings_template.h @@ -1,6 +1,6 @@ /* user_settings_template.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/configs/user_settings_wolfboot_keytools.h b/examples/configs/user_settings_wolfboot_keytools.h index f10482d3e0..31ff456e1c 100644 --- a/examples/configs/user_settings_wolfboot_keytools.h +++ b/examples/configs/user_settings_wolfboot_keytools.h @@ -4,7 +4,7 @@ * Enabled via WOLFSSL_USER_SETTINGS. * * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/configs/user_settings_wolftpm.h b/examples/configs/user_settings_wolftpm.h index 20da890b30..960536cb30 100644 --- a/examples/configs/user_settings_wolftpm.h +++ b/examples/configs/user_settings_wolftpm.h @@ -1,6 +1,6 @@ /* user_settings_wolftpm.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/echoclient/echoclient.c b/examples/echoclient/echoclient.c index e2c04af620..89a8d6ba96 100644 --- a/examples/echoclient/echoclient.c +++ b/examples/echoclient/echoclient.c @@ -1,6 +1,6 @@ /* echoclient.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/echoclient/echoclient.h b/examples/echoclient/echoclient.h index 23c4597c3d..90fb387be7 100644 --- a/examples/echoclient/echoclient.h +++ b/examples/echoclient/echoclient.h @@ -1,6 +1,6 @@ /* echoclient.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/echoserver/echoserver.c b/examples/echoserver/echoserver.c index a00049f8dc..68a86bce48 100644 --- a/examples/echoserver/echoserver.c +++ b/examples/echoserver/echoserver.c @@ -1,6 +1,6 @@ /* echoserver.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/echoserver/echoserver.h b/examples/echoserver/echoserver.h index a73c549ea3..29ab5a9f1b 100644 --- a/examples/echoserver/echoserver.h +++ b/examples/echoserver/echoserver.h @@ -1,6 +1,6 @@ /* echoserver.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/pem/pem.c b/examples/pem/pem.c index a61637946f..3d32e8472c 100644 --- a/examples/pem/pem.c +++ b/examples/pem/pem.c @@ -1,6 +1,6 @@ /* pem.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/sctp/sctp-client-dtls.c b/examples/sctp/sctp-client-dtls.c index d38f5579af..36be1aed41 100644 --- a/examples/sctp/sctp-client-dtls.c +++ b/examples/sctp/sctp-client-dtls.c @@ -1,6 +1,6 @@ /* sctp-client-dtls.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/sctp/sctp-client.c b/examples/sctp/sctp-client.c index fdabe43c4a..b76639f484 100644 --- a/examples/sctp/sctp-client.c +++ b/examples/sctp/sctp-client.c @@ -1,6 +1,6 @@ /* sctp-client.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/sctp/sctp-server-dtls.c b/examples/sctp/sctp-server-dtls.c index c02522f209..530a4b65b5 100644 --- a/examples/sctp/sctp-server-dtls.c +++ b/examples/sctp/sctp-server-dtls.c @@ -1,6 +1,6 @@ /* sctp-server-dtls.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/sctp/sctp-server.c b/examples/sctp/sctp-server.c index 3f8f6d803e..71143e8057 100644 --- a/examples/sctp/sctp-server.c +++ b/examples/sctp/sctp-server.c @@ -1,6 +1,6 @@ /* sctp-server.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/examples/server/server.c b/examples/server/server.c index cca853a14d..6649569080 100644 --- a/examples/server/server.c +++ b/examples/server/server.c @@ -1,6 +1,6 @@ /* server.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -3713,8 +3713,12 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args) ((usePskPlus) ? WOLFSSL_VERIFY_FAIL_EXCEPT_PSK : WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT), 0); - wolfSSL_request_certificate(ssl); - + if (wolfSSL_request_certificate(ssl) != WOLFSSL_SUCCESS) { + LOG_ERROR("Request for post-hs certificate failed\n"); + } + else { + LOG_ERROR("Successfully requested post-hs certificate\n"); + } } #endif diff --git a/examples/server/server.h b/examples/server/server.h index e0c8ad7bab..0750f4ca99 100644 --- a/examples/server/server.h +++ b/examples/server/server.h @@ -1,6 +1,6 @@ /* server.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/linuxkm/Kbuild b/linuxkm/Kbuild index e294e45288..f29690481e 100644 --- a/linuxkm/Kbuild +++ b/linuxkm/Kbuild @@ -1,6 +1,6 @@ # Linux kernel-native Makefile ("Kbuild") for libwolfssl.ko # -# Copyright (C) 2006-2023 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # # This file is part of wolfSSL. # @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA -SHELL=/bin/bash +SHELL=bash ifeq "$(WOLFSSL_OBJ_FILES)" "" $(error $$WOLFSSL_OBJ_FILES is unset.) @@ -48,9 +48,17 @@ endif $(obj)/linuxkm/module_exports.o: $(WOLFSSL_OBJ_TARGETS) +ifndef KERNEL_THREAD_STACK_SIZE + ifdef CROSS_COMPILE + KERNEL_THREAD_STACK_SIZE=16384 + endif +endif + # this mechanism only works in kernel 5.x+ (fallback to hardcoded value) -hostprogs := linuxkm/get_thread_size -always-y := $(hostprogs) +ifndef KERNEL_THREAD_STACK_SIZE + hostprogs := linuxkm/get_thread_size + always-y := $(hostprogs) +endif HOST_EXTRACFLAGS += $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CFLAGS) -static -fno-omit-frame-pointer @@ -63,8 +71,10 @@ endif # this rule is needed to get build to succeed in 4.x (get_thread_size still doesn't get built) $(obj)/linuxkm/get_thread_size: $(src)/linuxkm/get_thread_size.c -$(WOLFSSL_OBJ_TARGETS): | $(obj)/linuxkm/get_thread_size -KERNEL_THREAD_STACK_SIZE=$(shell test -x $(obj)/linuxkm/get_thread_size && $(obj)/linuxkm/get_thread_size || echo 16384) +ifndef KERNEL_THREAD_STACK_SIZE + $(WOLFSSL_OBJ_TARGETS): | $(obj)/linuxkm/get_thread_size + KERNEL_THREAD_STACK_SIZE=$(shell test -x $(obj)/linuxkm/get_thread_size && $(obj)/linuxkm/get_thread_size || echo 16384) +endif MAX_STACK_FRAME_SIZE=$(shell echo $$(( $(KERNEL_THREAD_STACK_SIZE) / 4))) libwolfssl-y := $(WOLFSSL_OBJ_FILES) linuxkm/module_hooks.o linuxkm/module_exports.o @@ -181,8 +191,8 @@ endif # exclude symbols that don't match wc_* or wolf*. $(obj)/linuxkm/module_exports.c: $(src)/module_exports.c.template $(WOLFSSL_OBJ_TARGETS) @cp $< $@ - @readelf --symbols --wide $(WOLFSSL_OBJ_TARGETS) | \ - awk '/^ *[0-9]+: / { \ + @$(READELF) --symbols --wide $(WOLFSSL_OBJ_TARGETS) | \ + $(AWK) '/^ *[0-9]+: / { \ if ($$8 !~ /^(wc_|wolf|WOLF|TLSX_)/){next;} \ if (($$4 == "FUNC") && ($$5 == "GLOBAL") && ($$6 == "DEFAULT")) { \ print "EXPORT_SYMBOL_NS_GPL(" $$8 ", WOLFSSL);"; \ diff --git a/linuxkm/Makefile b/linuxkm/Makefile index ccd5137e16..a4adad90da 100644 --- a/linuxkm/Makefile +++ b/linuxkm/Makefile @@ -1,6 +1,6 @@ # libwolfssl Linux kernel module Makefile (wraps Kbuild-native makefile) # -# Copyright (C) 2006-2023 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # # This file is part of wolfSSL. # @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA -SHELL=/bin/bash +SHELL=bash all: libwolfssl.ko libwolfssl.ko.signed @@ -58,20 +58,41 @@ endif export WOLFSSL_CFLAGS WOLFSSL_ASFLAGS WOLFSSL_OBJ_FILES WOLFCRYPT_PIE_FILES +ifneq "$(host_triplet)" "$(build_triplet)" + CROSS_COMPILE := 'CROSS_COMPILE=$(host_triplet)-' +endif + +OVERRIDE_PATHS := + +ifdef CC + ifneq "$(CC)" "cc" + OVERRIDE_PATHS := $(OVERRIDE_PATHS) 'CC=$(CC)' + endif +endif +ifdef AS + ifneq "$(AS)" "as" + OVERRIDE_PATHS := $(OVERRIDE_PATHS) 'AS=$(AS)' + endif +endif +ifdef LD + ifneq "$(LD)" "ld" + OVERRIDE_PATHS := $(OVERRIDE_PATHS) 'LD=$(LD)' + endif +endif + libwolfssl.ko: - @if test -z "$(KERNEL_ROOT)"; then echo '$$KERNEL_ROOT is unset' >&2; exit 1; fi - @if test -z "$(AM_CFLAGS)$(CFLAGS)"; then echo '$$AM_CFLAGS and $$CFLAGS are both unset.' >&2; exit 1; fi - @if test -z "$(src_libwolfssl_la_OBJECTS)"; then echo '$$src_libwolfssl_la_OBJECTS is unset.' >&2; exit 1; fi - @if test ! -h $(SRC_TOP)/Kbuild; then ln -s $(MODULE_TOP)/Kbuild $(SRC_TOP)/Kbuild; fi + @if test -z '$(KERNEL_ROOT)'; then echo '$$KERNEL_ROOT is unset' >&2; exit 1; fi + @if test -z '$(AM_CFLAGS)$(CFLAGS)'; then echo '$$AM_CFLAGS and $$CFLAGS are both unset.' >&2; exit 1; fi + @if test -z '$(src_libwolfssl_la_OBJECTS)'; then echo '$$src_libwolfssl_la_OBJECTS is unset.' >&2; exit 1; fi # after commit 9a0ebe5011 (6.10), sources must be in $(obj). work around this by making links to all needed sources: - @mkdir -p linuxkm - @cp --no-dereference --symbolic-link --no-clobber '$(MODULE_TOP)'/*.[ch] '$(MODULE_TOP)'/linuxkm/ - @cp --no-dereference --symbolic-link --no-clobber --recursive '$(SRC_TOP)'/wolfcrypt '$(MODULE_TOP)'/ - @cp --no-dereference --symbolic-link --no-clobber --recursive '$(SRC_TOP)'/src '$(MODULE_TOP)'/ + @mkdir -p '$(MODULE_TOP)/linuxkm' + @test '$(MODULE_TOP)/module_hooks.c' -ef '$(MODULE_TOP)/linuxkm/module_hooks.c' || cp --no-dereference --symbolic-link --no-clobber '$(MODULE_TOP)'/*.[ch] '$(MODULE_TOP)/linuxkm/' + @test '$(SRC_TOP)/wolfcrypt/src/wc_port.c' -ef '$(MODULE_TOP)/wolfcrypt/src/wc_port.c' || cp --no-dereference --symbolic-link --no-clobber --recursive '$(SRC_TOP)/wolfcrypt' '$(MODULE_TOP)/' + @test '$(SRC_TOP)/src/wolfio.c' -ef '$(MODULE_TOP)/src/wolfio.c' || cp --no-dereference --symbolic-link --no-clobber --recursive '$(SRC_TOP)/src' '$(MODULE_TOP)/' ifeq "$(ENABLED_LINUXKM_PIE)" "yes" - +$(MAKE) -C $(KERNEL_ROOT) M=$(MODULE_TOP) $(KBUILD_EXTRA_FLAGS) CC_FLAGS_FTRACE= + +$(MAKE) ARCH='$(KERNEL_ARCH)' $(OVERRIDE_PATHS) $(CROSS_COMPILE) -C '$(KERNEL_ROOT)' M='$(MODULE_TOP)' $(KBUILD_EXTRA_FLAGS) CC_FLAGS_FTRACE= else - +$(MAKE) -C $(KERNEL_ROOT) M=$(MODULE_TOP) $(KBUILD_EXTRA_FLAGS) + +$(MAKE) ARCH='$(KERNEL_ARCH)' $(OVERRIDE_PATHS) $(CROSS_COMPILE) -C '$(KERNEL_ROOT)' M='$(MODULE_TOP)' $(KBUILD_EXTRA_FLAGS) endif libwolfssl.ko.signed: libwolfssl.ko @@ -114,6 +135,9 @@ install modules_install: # note, must supply $(MODULE_TOP) as the src value for clean so that Kbuild is included, else # the top Makefile (which is not for the kernel build) would be included here. clean: + $(RM) -rf '$(MODULE_TOP)/linuxkm' + $(RM) -rf '$(MODULE_TOP)/wolfcrypt' + $(RM) -rf '$(MODULE_TOP)/src' +$(MAKE) -C $(KERNEL_ROOT) M=$(MODULE_TOP) src=$(MODULE_TOP) clean .PHONY: check diff --git a/linuxkm/get_thread_size.c b/linuxkm/get_thread_size.c index ed273864e3..cf6172db5f 100644 --- a/linuxkm/get_thread_size.c +++ b/linuxkm/get_thread_size.c @@ -1,7 +1,7 @@ /* get_thread_size.c -- trivial program to determine stack frame size * for a Linux kernel thread, given a configured source tree. * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/linuxkm/linuxkm_memory.c b/linuxkm/linuxkm_memory.c index 584998779f..e2c4a0476e 100644 --- a/linuxkm/linuxkm_memory.c +++ b/linuxkm/linuxkm_memory.c @@ -1,6 +1,6 @@ /* linuxkm_memory.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/linuxkm/linuxkm_wc_port.h b/linuxkm/linuxkm_wc_port.h index dce26dc37f..189a26e348 100644 --- a/linuxkm/linuxkm_wc_port.h +++ b/linuxkm/linuxkm_wc_port.h @@ -1,6 +1,6 @@ /* linuxkm_wc_port.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -533,7 +533,13 @@ const unsigned char *_ctype; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 10, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0) + typeof(kmalloc_noprof) *kmalloc_noprof; + typeof(krealloc_noprof) *krealloc_noprof; + typeof(kzalloc_noprof) *kzalloc_noprof; + typeof(__kvmalloc_node_noprof) *__kvmalloc_node_noprof; + typeof(__kmalloc_cache_noprof) *__kmalloc_cache_noprof; +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(6, 10, 0) typeof(kmalloc_noprof) *kmalloc_noprof; typeof(krealloc_noprof) *krealloc_noprof; typeof(kzalloc_noprof) *kzalloc_noprof; @@ -685,7 +691,14 @@ #define _ctype (wolfssl_linuxkm_get_pie_redirect_table()->_ctype) -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 10, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0) + /* see include/linux/alloc_tag.h and include/linux/slab.h */ + #define kmalloc_noprof (wolfssl_linuxkm_get_pie_redirect_table()->kmalloc_noprof) + #define krealloc_noprof (wolfssl_linuxkm_get_pie_redirect_table()->krealloc_noprof) + #define kzalloc_noprof (wolfssl_linuxkm_get_pie_redirect_table()->kzalloc_noprof) + #define __kvmalloc_node_noprof (wolfssl_linuxkm_get_pie_redirect_table()->__kvmalloc_node_noprof) + #define __kmalloc_cache_noprof (wolfssl_linuxkm_get_pie_redirect_table()->__kmalloc_cache_noprof) +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(6, 10, 0) /* see include/linux/alloc_tag.h and include/linux/slab.h */ #define kmalloc_noprof (wolfssl_linuxkm_get_pie_redirect_table()->kmalloc_noprof) #define krealloc_noprof (wolfssl_linuxkm_get_pie_redirect_table()->krealloc_noprof) diff --git a/linuxkm/module_exports.c.template b/linuxkm/module_exports.c.template index 5efa3e0c9f..4dff197e9c 100644 --- a/linuxkm/module_exports.c.template +++ b/linuxkm/module_exports.c.template @@ -1,7 +1,7 @@ /* module_exports.c.template -- static preamble for dynamically generated * module_exports.c (see Kbuild) * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/linuxkm/module_hooks.c b/linuxkm/module_hooks.c index 3382d2c798..574e2ad6f8 100644 --- a/linuxkm/module_hooks.c +++ b/linuxkm/module_hooks.c @@ -1,6 +1,6 @@ /* module_hooks.c -- module load/unload hooks for libwolfssl.ko * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -459,7 +459,13 @@ static int set_up_wolfssl_linuxkm_pie_redirect_table(void) { wolfssl_linuxkm_pie_redirect_table._ctype = _ctype; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 10, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0) + wolfssl_linuxkm_pie_redirect_table.kmalloc_noprof = kmalloc_noprof; + wolfssl_linuxkm_pie_redirect_table.krealloc_noprof = krealloc_noprof; + wolfssl_linuxkm_pie_redirect_table.kzalloc_noprof = kzalloc_noprof; + wolfssl_linuxkm_pie_redirect_table.__kvmalloc_node_noprof = __kvmalloc_node_noprof; + wolfssl_linuxkm_pie_redirect_table.__kmalloc_cache_noprof = __kmalloc_cache_noprof; +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(6, 10, 0) wolfssl_linuxkm_pie_redirect_table.kmalloc_noprof = kmalloc_noprof; wolfssl_linuxkm_pie_redirect_table.krealloc_noprof = krealloc_noprof; wolfssl_linuxkm_pie_redirect_table.kzalloc_noprof = kzalloc_noprof; diff --git a/linuxkm/pie_first.c b/linuxkm/pie_first.c index aa2117bc6c..0bf1b1ae4f 100644 --- a/linuxkm/pie_first.c +++ b/linuxkm/pie_first.c @@ -1,6 +1,6 @@ /* linuxkm/pie_first.c -- memory fenceposts for checking binary image stability * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/linuxkm/pie_last.c b/linuxkm/pie_last.c index 35de6fc473..8d687f14cc 100644 --- a/linuxkm/pie_last.c +++ b/linuxkm/pie_last.c @@ -1,6 +1,6 @@ /* linuxkm/pie_last.c -- memory fenceposts for checking binary image stability * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/linuxkm/pie_redirect_table.c b/linuxkm/pie_redirect_table.c index c624b9efc8..9142ef49e2 100644 --- a/linuxkm/pie_redirect_table.c +++ b/linuxkm/pie_redirect_table.c @@ -1,6 +1,6 @@ /* pie_redirect_table.c -- module load/unload hooks for libwolfssl.ko * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/m4/ax_linuxkm.m4 b/m4/ax_linuxkm.m4 index aebc2a6036..a3ba5ccaf1 100644 --- a/m4/ax_linuxkm.m4 +++ b/m4/ax_linuxkm.m4 @@ -1,6 +1,6 @@ # ax_linuxkm.m4 -- macros for getting attributes of default configured kernel # -# Copyright (C) 2006-2023 wolfSSL Inc. +# Copyright (C) 2006-2024 wolfSSL Inc. # # This file is part of wolfSSL. # diff --git a/mcapi/crypto.c b/mcapi/crypto.c index abfe65f783..aa5e430199 100644 --- a/mcapi/crypto.c +++ b/mcapi/crypto.c @@ -1,6 +1,6 @@ /* crypto.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/mcapi/crypto.h b/mcapi/crypto.h index 4511193076..dd95c1ca93 100644 --- a/mcapi/crypto.h +++ b/mcapi/crypto.h @@ -1,6 +1,6 @@ /* crypto.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/mcapi/mcapi_test.c b/mcapi/mcapi_test.c index 7e5acbc08f..64aee92639 100644 --- a/mcapi/mcapi_test.c +++ b/mcapi/mcapi_test.c @@ -1,6 +1,6 @@ /* mcapi_test.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/mplabx/benchmark_main.c b/mplabx/benchmark_main.c index ef4c82a914..8a9cf81427 100644 --- a/mplabx/benchmark_main.c +++ b/mplabx/benchmark_main.c @@ -1,6 +1,6 @@ /* benchmark_main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/mplabx/test_main.c b/mplabx/test_main.c index e072c08db5..64f3556a16 100644 --- a/mplabx/test_main.c +++ b/mplabx/test_main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/mqx/wolfssl_client/Sources/main.h b/mqx/wolfssl_client/Sources/main.h index 1740ddcb49..beb1fdfa9e 100644 --- a/mqx/wolfssl_client/Sources/main.h +++ b/mqx/wolfssl_client/Sources/main.h @@ -15,7 +15,7 @@ #include -#define MAIN_TASK 1 +#define MAIN_TASK 1 extern void Main_task(uint32_t); extern void setup_ethernet(void); @@ -34,10 +34,10 @@ static inline void err_sys(const char* msg) _mqx_exit(1); } -/* PPP device must be set manually and +/* PPP device must be set manually and * must be different from the default IO channel (BSP_DEFAULT_IO_CHANNEL) */ -#define PPP_DEVICE "ittyb:" +#define PPP_DEVICE "ittyb:" /* * Define PPP_DEVICE_DUN only when using PPP to communicate @@ -54,7 +54,7 @@ static inline void err_sys(const char* msg) #define ENET_IPMASK IPADDR(255,255,255,0) #endif -#define GATE_IPADDR IPADDR(192,168,1,1) +#define GATE_IPADDR IPADDR(192,168,1,1) #endif /* __main_h_ */ diff --git a/scripts/google.test b/scripts/google.test index 6eacc4d4fe..ab640d3590 100755 --- a/scripts/google.test +++ b/scripts/google.test @@ -6,6 +6,11 @@ server=www.google.com [ ! -x ./examples/client/client ] && echo -e "\n\nClient doesn't exist" && exit 1 +if ! test -n "$WOLFSSL_EXTERNAL_TEST"; then + echo "WOLFSSL_EXTERNAL_TEST not set, won't run" + exit 77 +fi + if ! ./examples/client/client -V | grep -q 3; then echo 'skipping google.test because TLS1.2 is not available.' 1>&2 exit 77 diff --git a/src/bio.c b/src/bio.c index 340cbfdac9..43492126df 100644 --- a/src/bio.c +++ b/src/bio.c @@ -1,6 +1,6 @@ /* bio.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -161,7 +161,7 @@ static int wolfSSL_BIO_MEMORY_read(WOLFSSL_BIO* bio, void* buf, int len) bio->wrSz = 0; bio->mem_buf->length = 0; } - bio->ptr = bio->mem_buf->data; + bio->ptr.mem_buf_data = (byte *)bio->mem_buf->data; } else if (bio->rdIdx >= WOLFSSL_BIO_RESIZE_THRESHOLD && !(bio->flags & BIO_FLAGS_MEM_RDONLY)) { @@ -180,7 +180,7 @@ static int wolfSSL_BIO_MEMORY_read(WOLFSSL_BIO* bio, void* buf, int len) return WOLFSSL_BIO_ERROR; } bio->mem_buf->length = (size_t)bio->wrSz; - bio->ptr = bio->mem_buf->data; + bio->ptr.mem_buf_data = (byte *)bio->mem_buf->data; } } else { @@ -217,11 +217,11 @@ static int wolfSSL_BIO_SSL_read(WOLFSSL_BIO* bio, void* buf, return WOLFSSL_FATAL_ERROR; bio->flags &= ~(WOLFSSL_BIO_FLAG_RETRY); /* default no retry */ - ret = wolfSSL_read((WOLFSSL*)bio->ptr, buf, len); + ret = wolfSSL_read(bio->ptr.ssl, buf, len); if (ret == 0) front->eof = 1; else if (ret < 0) { - int err = wolfSSL_get_error((WOLFSSL*)bio->ptr, 0); + int err = wolfSSL_get_error(bio->ptr.ssl, 0); if ( !(err == WOLFSSL_ERROR_WANT_READ || err == WOLFSSL_ERROR_WANT_WRITE) ) { front->eof = 1; } @@ -235,15 +235,15 @@ static int wolfSSL_BIO_SSL_read(WOLFSSL_BIO* bio, void* buf, static int wolfSSL_BIO_MD_read(WOLFSSL_BIO* bio, void* buf, int sz) { - if (wolfSSL_EVP_MD_CTX_type((WOLFSSL_EVP_MD_CTX*)bio->ptr) == NID_hmac) { - if (wolfSSL_EVP_DigestSignUpdate((WOLFSSL_EVP_MD_CTX*)bio->ptr, buf, + if (wolfSSL_EVP_MD_CTX_type(bio->ptr.md_ctx) == NID_hmac) { + if (wolfSSL_EVP_DigestSignUpdate(bio->ptr.md_ctx, buf, (unsigned int)sz) != WOLFSSL_SUCCESS) { return WOLFSSL_FATAL_ERROR; } } else { - if (wolfSSL_EVP_DigestUpdate((WOLFSSL_EVP_MD_CTX*)bio->ptr, buf, (size_t)sz) + if (wolfSSL_EVP_DigestUpdate(bio->ptr.md_ctx, buf, (size_t)sz) != WOLFSSL_SUCCESS) { return WOLFSSL_FATAL_ERROR; } @@ -290,6 +290,9 @@ int wolfSSL_BIO_read(WOLFSSL_BIO* bio, void* buf, int len) } while (bio != NULL && ret >= 0) { +#ifdef WOLFSSL_BIO_HAVE_FLOW_STATS + int inhibit_flow_increment = 0; +#endif /* check for custom read */ if (bio->method && bio->method->readCb) { ret = bio->method->readCb(bio, (char*)buf, len); @@ -302,19 +305,22 @@ int wolfSSL_BIO_read(WOLFSSL_BIO* bio, void* buf, int len) break; case WOLFSSL_BIO_BIO: /* read BIOs */ ret = wolfSSL_BIO_BIO_read(bio, buf, len); +#ifdef WOLFSSL_BIO_HAVE_FLOW_STATS + inhibit_flow_increment = 1; +#endif break; case WOLFSSL_BIO_MEMORY: ret = wolfSSL_BIO_MEMORY_read(bio, buf, len); break; case WOLFSSL_BIO_FILE: #ifndef NO_FILESYSTEM - if (bio->ptr) { - ret = (int)XFREAD(buf, 1, (size_t)len, (XFILE)bio->ptr); + if (bio->ptr.fh) { + ret = (int)XFREAD(buf, 1, (size_t)len, bio->ptr.fh); } else { #if defined(XREAD) && !defined(NO_WOLFSSL_DIR) && \ !defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2) - ret = (int)XREAD(bio->num, buf, (size_t)len); + ret = (int)XREAD(bio->num.fd, buf, (size_t)len); #else WOLFSSL_MSG("No file pointer and XREAD not enabled"); ret = NOT_COMPILED_IN; @@ -345,14 +351,52 @@ int wolfSSL_BIO_read(WOLFSSL_BIO* bio, void* buf, int len) #ifdef USE_WOLFSSL_IO /* BIO requires built-in socket support * (cannot be used with WOLFSSL_USER_IO) */ - ret = wolfIO_Recv(bio->num, (char*)buf, len, 0); + bio->flags &= ~WOLFSSL_BIO_FLAG_RETRY; + ret = wolfIO_Recv(bio->num.fd, (char*)buf, len, 0); + if (ret == WOLFSSL_CBIO_ERR_WANT_READ) { + bio->flags |= WOLFSSL_BIO_FLAG_RETRY; + } + if (ret < 0) { + ret = WOLFSSL_BIO_ERROR; + } + #else + ret = NOT_COMPILED_IN; + #endif + break; + + case WOLFSSL_BIO_DGRAM: + #if defined(WOLFSSL_HAVE_BIO_ADDR) && defined(WOLFSSL_DTLS) && \ + defined(USE_WOLFSSL_IO) + /* BIO requires built-in socket support + * (cannot be used with WOLFSSL_USER_IO) */ + bio->flags &= ~WOLFSSL_BIO_FLAG_RETRY; + if (bio->connected) + ret = wolfIO_Recv(bio->num.fd, (char*)buf, len, 0); + else { + wolfSSL_BIO_ADDR_clear(&bio->peer_addr); + ret = wolfIO_RecvFrom(bio->num.fd, &bio->peer_addr, + (char*)buf, len, 0); + } + if (ret == WOLFSSL_CBIO_ERR_WANT_READ) { + bio->flags |= WOLFSSL_BIO_FLAG_RETRY; + } + if (ret < 0) { + ret = WOLFSSL_BIO_ERROR; + } #else ret = NOT_COMPILED_IN; #endif break; + } /* switch */ } +#ifdef WOLFSSL_BIO_HAVE_FLOW_STATS + if ((ret > 0) && (!inhibit_flow_increment)) { + bio->bytes_read += (word32)ret; + } +#endif + /* case where front of list is done */ if (bio == front) { break; /* at front of list so be done */ @@ -468,16 +512,16 @@ static int wolfSSL_BIO_SSL_write(WOLFSSL_BIO* bio, const void* data, WOLFSSL_ENTER("wolfSSL_BIO_SSL_write"); - if (bio->ptr == NULL) { + if (bio->ptr.ssl == NULL) { return BAD_FUNC_ARG; } bio->flags &= ~(WOLFSSL_BIO_FLAG_RETRY); /* default no retry */ - ret = wolfSSL_write((WOLFSSL*)bio->ptr, data, len); + ret = wolfSSL_write(bio->ptr.ssl, data, len); if (ret == 0) front->eof = 1; else if (ret < 0) { - int err = wolfSSL_get_error((WOLFSSL*)bio->ptr, 0); + int err = wolfSSL_get_error(bio->ptr.ssl, 0); if ( !(err == WOLFSSL_ERROR_WANT_READ || err == WOLFSSL_ERROR_WANT_WRITE) ) { front->eof = 1; } @@ -576,8 +620,8 @@ static int wolfSSL_BIO_MEMORY_write(WOLFSSL_BIO* bio, const void* data, } XMEMCPY(bio->mem_buf->data + bio->wrSz, data, len); - bio->ptr = bio->mem_buf->data; - bio->num = (int)bio->mem_buf->max; + bio->ptr.mem_buf_data = (byte *)bio->mem_buf->data; + bio->num.length = bio->mem_buf->max; bio->wrSz += len; bio->wrIdx += len; @@ -598,14 +642,14 @@ static int wolfSSL_BIO_MD_write(WOLFSSL_BIO* bio, const void* data, int len) return BAD_FUNC_ARG; } - if (wolfSSL_EVP_MD_CTX_type((WOLFSSL_EVP_MD_CTX*)bio->ptr) == NID_hmac) { - if (wolfSSL_EVP_DigestSignUpdate((WOLFSSL_EVP_MD_CTX*)bio->ptr, data, + if (wolfSSL_EVP_MD_CTX_type(bio->ptr.md_ctx) == NID_hmac) { + if (wolfSSL_EVP_DigestSignUpdate(bio->ptr.md_ctx, data, (unsigned int)len) != WOLFSSL_SUCCESS) { ret = WOLFSSL_BIO_ERROR; } } else { - if (wolfSSL_EVP_DigestUpdate((WOLFSSL_EVP_MD_CTX*)bio->ptr, data, (size_t)len) + if (wolfSSL_EVP_DigestUpdate(bio->ptr.md_ctx, data, (size_t)len) != WOLFSSL_SUCCESS) { ret = WOLFSSL_BIO_ERROR; } @@ -647,6 +691,9 @@ int wolfSSL_BIO_write(WOLFSSL_BIO* bio, const void* data, int len) } while (bio != NULL && ret >= 0) { +#ifdef WOLFSSL_BIO_HAVE_FLOW_STATS + int inhibit_flow_increment = 0; +#endif /* check for custom write */ if (bio->method && bio->method->writeCb) { ret = bio->method->writeCb(bio, (const char*)data, len); @@ -672,19 +719,22 @@ int wolfSSL_BIO_write(WOLFSSL_BIO* bio, const void* data, int len) } case WOLFSSL_BIO_BIO: /* write bios */ ret = wolfSSL_BIO_BIO_write(bio, data, len); +#ifdef WOLFSSL_BIO_HAVE_FLOW_STATS + inhibit_flow_increment = 1; +#endif break; case WOLFSSL_BIO_MEMORY: ret = wolfSSL_BIO_MEMORY_write(bio, data, len); break; case WOLFSSL_BIO_FILE: #ifndef NO_FILESYSTEM - if (bio->ptr) { - ret = (int)XFWRITE(data, 1, (size_t)len, (XFILE)bio->ptr); + if (bio->ptr.fh) { + ret = (int)XFWRITE(data, 1, (size_t)len, bio->ptr.fh); } else { #if defined(XWRITE) && !defined(NO_WOLFSSL_DIR) && \ !defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2) - ret = (int)XWRITE(bio->num, data, (size_t)len); + ret = (int)XWRITE(bio->num.fd, data, (size_t)len); #else WOLFSSL_MSG("No file pointer and XWRITE not enabled"); ret = NOT_COMPILED_IN; @@ -725,14 +775,50 @@ int wolfSSL_BIO_write(WOLFSSL_BIO* bio, const void* data, int len) #ifdef USE_WOLFSSL_IO /* BIO requires built-in socket support * (cannot be used with WOLFSSL_USER_IO) */ - ret = wolfIO_Send(bio->num, (char*)data, len, 0); + bio->flags &= ~WOLFSSL_BIO_FLAG_RETRY; + ret = wolfIO_Send(bio->num.fd, (char*)data, len, 0); + if (ret == WOLFSSL_CBIO_ERR_WANT_WRITE) { + bio->flags |= WOLFSSL_BIO_FLAG_RETRY; + } + if (ret < 0) { + ret = WOLFSSL_BIO_ERROR; + } + #else + ret = NOT_COMPILED_IN; + #endif + break; + + case WOLFSSL_BIO_DGRAM: + #if defined(WOLFSSL_HAVE_BIO_ADDR) && defined(WOLFSSL_DTLS) && \ + defined(USE_WOLFSSL_IO) + /* BIO requires built-in socket support + * (cannot be used with WOLFSSL_USER_IO) */ + bio->flags &= ~WOLFSSL_BIO_FLAG_RETRY; + if (bio->connected) + ret = wolfIO_Send(bio->num.fd, (char*)data, len, 0); + else if (bio->peer_addr.sa.sa_family == AF_UNSPEC) + ret = SOCKET_ERROR_E; + else + ret = wolfIO_SendTo(bio->num.fd, &bio->peer_addr, (char*)data, len, 0); + if (ret == WOLFSSL_CBIO_ERR_WANT_WRITE) { + bio->flags |= WOLFSSL_BIO_FLAG_RETRY; + } + if (ret < 0) { + ret = WOLFSSL_BIO_ERROR; + } #else ret = NOT_COMPILED_IN; #endif break; + } /* switch */ } +#ifdef WOLFSSL_BIO_HAVE_FLOW_STATS + if ((ret > 0) && (! inhibit_flow_increment)) + bio->bytes_written += (word32)ret; +#endif + /* advance to the next bio in list */ bio = bio->next; } @@ -793,6 +879,49 @@ long wolfSSL_BIO_ctrl(WOLFSSL_BIO *bio, int cmd, long larg, void *parg) case BIO_CTRL_RESET: ret = (long)wolfSSL_BIO_reset(bio); break; + +#ifdef WOLFSSL_HAVE_BIO_ADDR + case BIO_CTRL_DGRAM_CONNECT: + case BIO_CTRL_DGRAM_SET_PEER: + { + socklen_t addr_size; + if (parg == NULL) { + ret = WOLFSSL_FAILURE; + break; + } + addr_size = wolfSSL_BIO_ADDR_size((WOLFSSL_BIO_ADDR *)parg); + if (addr_size == 0) { + ret = WOLFSSL_FAILURE; + break; + } + XMEMCPY(&bio->peer_addr, parg, addr_size); + ret = WOLFSSL_SUCCESS; + break; + } + + case BIO_CTRL_DGRAM_SET_CONNECTED: + if (parg == NULL) { + wolfSSL_BIO_ADDR_clear(&bio->peer_addr); + bio->connected = 0; + } + else { + socklen_t addr_size = wolfSSL_BIO_ADDR_size((WOLFSSL_BIO_ADDR *)parg); + if (addr_size == 0) { + ret = WOLFSSL_FAILURE; + break; + } + XMEMCPY(&bio->peer_addr, parg, addr_size); + bio->connected = 1; + } + ret = WOLFSSL_SUCCESS; + break; + + case BIO_CTRL_DGRAM_QUERY_MTU: + ret = 0; /* not implemented */ + break; + +#endif /* WOLFSSL_HAVE_BIO_ADDR */ + default: WOLFSSL_MSG("CMD not yet implemented"); ret = WOLFSSL_FAILURE; @@ -826,8 +955,51 @@ int wolfSSL_BIO_up_ref(WOLFSSL_BIO* bio) return WOLFSSL_FAILURE; } + +#ifdef WOLFSSL_HAVE_BIO_ADDR +WOLFSSL_BIO_ADDR *wolfSSL_BIO_ADDR_new(void) { + WOLFSSL_BIO_ADDR *addr = + (WOLFSSL_BIO_ADDR *)XMALLOC(sizeof(*addr), NULL, DYNAMIC_TYPE_BIO); + if (addr) + addr->sa.sa_family = AF_UNSPEC; + return addr; +} + +void wolfSSL_BIO_ADDR_free(WOLFSSL_BIO_ADDR *addr) { + XFREE(addr, NULL, DYNAMIC_TYPE_BIO); +} + +void wolfSSL_BIO_ADDR_clear(WOLFSSL_BIO_ADDR *addr) { + if (addr == NULL) + return; + XMEMSET(addr, 0, sizeof(*addr)); + addr->sa.sa_family = AF_UNSPEC; +} + +socklen_t wolfSSL_BIO_ADDR_size(const WOLFSSL_BIO_ADDR *addr) { + switch (addr->sa.sa_family) { +#ifndef WOLFSSL_NO_BIO_ADDR_IN + case AF_INET: + return sizeof(addr->sa_in); +#endif +#ifdef WOLFSSL_IPV6 + case AF_INET6: + return sizeof(addr->sa_in6); #endif +#if defined(HAVE_SYS_UN_H) && !defined(WOLFSSL_NO_SOCKADDR_UN) + case AF_UNIX: + return sizeof(addr->sa_un); +#endif + default: + /* must return zero if length can't be determined, to avoid buffer + * overruns in callers. + */ + return 0; + } +} +#endif /* WOLFSSL_HAVE_BIO_ADDR */ +#endif /* OPENSSL_ALL || OPENSSL_EXTRA */ /* helper function for wolfSSL_BIO_gets * size till a newline is hit @@ -888,15 +1060,15 @@ int wolfSSL_BIO_gets(WOLFSSL_BIO* bio, char* buf, int sz) switch (bio->type) { #ifndef NO_FILESYSTEM case WOLFSSL_BIO_FILE: - if (((XFILE)bio->ptr) == XBADFILE) { + if (bio->ptr.fh == XBADFILE) { return WOLFSSL_BIO_ERROR; } #if defined(MICRIUM) || defined(LSR_FS) || defined(EBSNET) WOLFSSL_MSG("XFGETS not ported for this system yet"); - ret = XFGETS(buf, sz, (XFILE)bio->ptr); + ret = XFGETS(buf, sz, bio->ptr.fh); #else - if (XFGETS(buf, sz, (XFILE)bio->ptr) != NULL) { + if (XFGETS(buf, sz, bio->ptr.fh) != NULL) { ret = (int)XSTRLEN(buf); } else { @@ -972,13 +1144,13 @@ int wolfSSL_BIO_gets(WOLFSSL_BIO* bio, char* buf, int sz) #ifndef WOLFCRYPT_ONLY /* call final on hash */ case WOLFSSL_BIO_MD: - if (wolfSSL_EVP_MD_CTX_size((WOLFSSL_EVP_MD_CTX*)bio->ptr) > sz) { + if (wolfSSL_EVP_MD_CTX_size(bio->ptr.md_ctx) > sz) { WOLFSSL_MSG("Output buffer was too small for digest"); ret = WOLFSSL_FAILURE; } else { unsigned int szOut = 0; - ret = wolfSSL_EVP_DigestFinal((WOLFSSL_EVP_MD_CTX*)bio->ptr, + ret = wolfSSL_EVP_DigestFinal(bio->ptr.md_ctx, (unsigned char*)buf, &szOut); if (ret == WOLFSSL_SUCCESS) { ret = (int)szOut; @@ -1133,8 +1305,8 @@ size_t wolfSSL_BIO_ctrl_pending(WOLFSSL_BIO *bio) } #ifndef WOLFCRYPT_ONLY - if (bio->type == WOLFSSL_BIO_SSL && bio->ptr != NULL) { - return (long)wolfSSL_pending((WOLFSSL*)bio->ptr); + if (bio->type == WOLFSSL_BIO_SSL && bio->ptr.ssl != NULL) { + return (long)wolfSSL_pending(bio->ptr.ssl); } #endif @@ -1208,8 +1380,8 @@ long wolfSSL_BIO_get_mem_ptr(WOLFSSL_BIO *bio, WOLFSSL_BUF_MEM **ptr) bio->wrSz = (int)bio->mem_buf->length; bio->wrSzReset = bio->wrSz; - bio->num = (int)bio->mem_buf->max; - bio->ptr = bio->mem_buf->data; + bio->num.length = bio->mem_buf->max; + bio->ptr.mem_buf_data = (byte *)bio->mem_buf->data; bio->wrIdx = 0; bio->rdIdx = 0; @@ -1242,15 +1414,16 @@ int wolfSSL_BIO_set_write_buf_size(WOLFSSL_BIO *bio, long size) return WOLFSSL_FAILURE; } - if (bio->ptr != NULL) { - XFREE(bio->ptr, bio->heap, DYNAMIC_TYPE_OPENSSL); + if (bio->ptr.mem_buf_data != NULL) { + XFREE(bio->ptr.mem_buf_data, bio->heap, DYNAMIC_TYPE_OPENSSL); } - bio->ptr = (byte*)XMALLOC(size, bio->heap, DYNAMIC_TYPE_OPENSSL); - if (bio->ptr == NULL) { + bio->ptr.mem_buf_data = (byte*)XMALLOC(size, bio->heap, + DYNAMIC_TYPE_OPENSSL); + if (bio->ptr.mem_buf_data == NULL) { WOLFSSL_MSG("Memory allocation error"); bio->wrSz = 0; - bio->num = 0; + bio->num.length = 0; bio->wrIdx = 0; bio->rdIdx = 0; if (bio->mem_buf != NULL) { @@ -1261,13 +1434,13 @@ int wolfSSL_BIO_set_write_buf_size(WOLFSSL_BIO *bio, long size) return WOLFSSL_FAILURE; } bio->wrSz = (int)size; - bio->num = (int)size; + bio->num.length = size; bio->wrIdx = 0; bio->rdIdx = 0; if (bio->mem_buf != NULL) { - bio->mem_buf->data = (char*)bio->ptr; - bio->mem_buf->length = (size_t)bio->num; - bio->mem_buf->max = (size_t)bio->num; + bio->mem_buf->data = (char*)bio->ptr.mem_buf_data; + bio->mem_buf->length = bio->num.length; + bio->mem_buf->max = bio->num.length; } return WOLFSSL_SUCCESS; @@ -1295,12 +1468,12 @@ int wolfSSL_BIO_make_bio_pair(WOLFSSL_BIO *b1, WOLFSSL_BIO *b2) } /* set default write size if not already set */ - if (b1->ptr == NULL && wolfSSL_BIO_set_write_buf_size(b1, + if (b1->ptr.mem_buf_data == NULL && wolfSSL_BIO_set_write_buf_size(b1, WOLFSSL_BIO_SIZE) != WOLFSSL_SUCCESS) { return WOLFSSL_FAILURE; } - if (b2->ptr == NULL && wolfSSL_BIO_set_write_buf_size(b2, + if (b2->ptr.mem_buf_data == NULL && wolfSSL_BIO_set_write_buf_size(b2, WOLFSSL_BIO_SIZE) != WOLFSSL_SUCCESS) { return WOLFSSL_FAILURE; } @@ -1341,7 +1514,7 @@ int wolfSSL_BIO_nread0(WOLFSSL_BIO *bio, char **buf) WOLFSSL_BIO* pair = bio->pair; /* case where have wrapped around write buffer */ - *buf = (char*)pair->ptr + pair->rdIdx; + *buf = (char*)pair->ptr.mem_buf_data + pair->rdIdx; if (pair->wrIdx > 0 && pair->rdIdx >= pair->wrIdx) { return pair->wrSz - pair->rdIdx; } @@ -1373,7 +1546,7 @@ int wolfSSL_BIO_nread(WOLFSSL_BIO *bio, char **buf, int num) if (bio->pair != NULL) { /* special case if asking to read 0 bytes */ if (num == 0) { - *buf = (char*)bio->pair->ptr + bio->pair->rdIdx; + *buf = (char*)bio->pair->ptr.mem_buf_data + bio->pair->rdIdx; return 0; } @@ -1387,6 +1560,9 @@ int wolfSSL_BIO_nread(WOLFSSL_BIO *bio, char **buf, int num) sz = num; } bio->pair->rdIdx += sz; +#ifdef WOLFSSL_BIO_HAVE_FLOW_STATS + bio->pair->bytes_read += (word32)sz; +#endif /* check if have read to the end of the buffer and need to reset */ if (bio->pair->rdIdx == bio->pair->wrSz) { @@ -1424,7 +1600,7 @@ int wolfSSL_BIO_nwrite(WOLFSSL_BIO *bio, char **buf, int num) if (bio->pair != NULL) { if (num == 0) { - *buf = (char*)bio->ptr + bio->wrIdx; + *buf = (char*)bio->ptr.mem_buf_data + bio->wrIdx; return 0; } @@ -1463,8 +1639,11 @@ int wolfSSL_BIO_nwrite(WOLFSSL_BIO *bio, char **buf, int num) if (num < sz) { sz = num; } - *buf = (char*)bio->ptr + bio->wrIdx; + *buf = (char*)bio->ptr.mem_buf_data + bio->wrIdx; bio->wrIdx += sz; +#ifdef WOLFSSL_BIO_HAVE_FLOW_STATS + bio->bytes_written += (word32)sz; +#endif /* if at the end of the buffer and space for wrap around then set * write index back to 0 */ @@ -1476,6 +1655,37 @@ int wolfSSL_BIO_nwrite(WOLFSSL_BIO *bio, char **buf, int num) return sz; } +#ifdef WOLFSSL_BIO_HAVE_FLOW_STATS +word64 wolfSSL_BIO_number_read(WOLFSSL_BIO *bio) +{ + word64 ret = 0; + if (bio == NULL) { + WOLFSSL_MSG("NULL argument passed in"); + return 0; + } + while (bio) { + ret += bio->bytes_read; + bio = bio->next; + } + + return ret; +} + +word64 wolfSSL_BIO_number_written(WOLFSSL_BIO *bio) +{ + word64 ret = 0; + if (bio == NULL) { + WOLFSSL_MSG("NULL argument passed in"); + return 0; + } + while (bio) { + ret += bio->bytes_written; + bio = bio->next; + } + + return ret; +} +#endif /* WOLFSSL_BIO_HAVE_FLOW_STATS */ /* Reset BIO to initial state */ int wolfSSL_BIO_reset(WOLFSSL_BIO *bio) @@ -1491,7 +1701,7 @@ int wolfSSL_BIO_reset(WOLFSSL_BIO *bio) switch (bio->type) { #ifndef NO_FILESYSTEM case WOLFSSL_BIO_FILE: - if (XFSEEK((XFILE)bio->ptr, 0, XSEEK_SET) != 0) + if (XFSEEK(bio->ptr.fh, 0, XSEEK_SET) != 0) return WOLFSSL_BIO_ERROR; else return 0; @@ -1510,9 +1720,9 @@ int wolfSSL_BIO_reset(WOLFSSL_BIO *bio) } else { bio->wrSz = 0; - XFREE(bio->ptr, bio->heap, DYNAMIC_TYPE_OPENSSL); - bio->ptr = NULL; - bio->num = 0; + XFREE(bio->ptr.mem_buf_data, bio->heap, DYNAMIC_TYPE_OPENSSL); + bio->ptr.mem_buf_data = NULL; + bio->num.length = 0; if (bio->mem_buf != NULL) { bio->mem_buf->data = NULL; bio->mem_buf->length = 0; @@ -1523,12 +1733,12 @@ int wolfSSL_BIO_reset(WOLFSSL_BIO *bio) #ifndef WOLFCRYPT_ONLY case WOLFSSL_BIO_MD: - if (bio->ptr != NULL) { + if (bio->ptr.md_ctx != NULL) { const WOLFSSL_EVP_MD* md = - wolfSSL_EVP_MD_CTX_md((WOLFSSL_EVP_MD_CTX*)bio->ptr); - wolfSSL_EVP_MD_CTX_cleanup((WOLFSSL_EVP_MD_CTX*)bio->ptr); - wolfSSL_EVP_MD_CTX_init((WOLFSSL_EVP_MD_CTX*)bio->ptr); - wolfSSL_EVP_DigestInit((WOLFSSL_EVP_MD_CTX*)bio->ptr, md); + wolfSSL_EVP_MD_CTX_md(bio->ptr.md_ctx); + wolfSSL_EVP_MD_CTX_cleanup(bio->ptr.md_ctx); + wolfSSL_EVP_MD_CTX_init(bio->ptr.md_ctx); + wolfSSL_EVP_DigestInit(bio->ptr.md_ctx, md); } return 0; #endif /* WOLFCRYPT_ONLY */ @@ -1580,7 +1790,7 @@ long wolfSSL_BIO_set_fp(WOLFSSL_BIO *bio, XFILE fp, int c) } bio->shutdown = (byte)c; - bio->ptr = (XFILE)fp; + bio->ptr.fh = fp; return WOLFSSL_SUCCESS; } @@ -1598,7 +1808,7 @@ long wolfSSL_BIO_get_fp(WOLFSSL_BIO *bio, XFILE* fp) return WOLFSSL_FAILURE; } - *fp = (XFILE)bio->ptr; + *fp = bio->ptr.fh; return WOLFSSL_SUCCESS; } @@ -1613,8 +1823,8 @@ int wolfSSL_BIO_write_filename(WOLFSSL_BIO *bio, char *name) } if (bio->type == WOLFSSL_BIO_FILE) { - if (((XFILE)bio->ptr) != XBADFILE && bio->shutdown == BIO_CLOSE) { - XFCLOSE((XFILE)bio->ptr); + if (bio->ptr.fh != XBADFILE && bio->shutdown == BIO_CLOSE) { + XFCLOSE(bio->ptr.fh); } /* 'b' flag is ignored on POSIX targets, but on Windows it assures @@ -1622,8 +1832,8 @@ int wolfSSL_BIO_write_filename(WOLFSSL_BIO *bio, char *name) * between the size and contents of the representation in memory and on * disk. */ - bio->ptr = XFOPEN(name, "wb"); - if (((XFILE)bio->ptr) == XBADFILE) { + bio->ptr.fh = XFOPEN(name, "wb"); + if (bio->ptr.fh == XBADFILE) { return WOLFSSL_FAILURE; } bio->shutdown = BIO_CLOSE; @@ -1645,7 +1855,7 @@ int wolfSSL_BIO_seek(WOLFSSL_BIO *bio, int ofs) /* offset ofs from beginning of file */ if (bio->type == WOLFSSL_BIO_FILE && - XFSEEK((XFILE)bio->ptr, ofs, SEEK_SET) < 0) { + XFSEEK(bio->ptr.fh, ofs, SEEK_SET) < 0) { return -1; } @@ -1670,7 +1880,7 @@ int wolfSSL_BIO_tell(WOLFSSL_BIO* bio) return 0; } - pos = (int)XFTELL((XFILE)bio->ptr); + pos = (int)XFTELL(bio->ptr.fh); if (pos < 0) return -1; else @@ -1799,15 +2009,16 @@ long wolfSSL_BIO_set_nbio(WOLFSSL_BIO* bio, long on) if (bio) { switch (bio->type) { case WOLFSSL_BIO_SOCKET: + case WOLFSSL_BIO_DGRAM: #ifdef XFCNTL { int ret; - int flag = XFCNTL(bio->num, F_GETFL, 0); + int flag = XFCNTL(bio->num.fd, F_GETFL, 0); if (on) { - ret = XFCNTL(bio->num, F_SETFL, flag | O_NONBLOCK); + ret = XFCNTL(bio->num.fd, F_SETFL, flag | O_NONBLOCK); } else { - ret = XFCNTL(bio->num, F_SETFL, flag & ~O_NONBLOCK); + ret = XFCNTL(bio->num.fd, F_SETFL, flag & ~O_NONBLOCK); } if (ret == -1) { @@ -1818,7 +2029,7 @@ long wolfSSL_BIO_set_nbio(WOLFSSL_BIO* bio, long on) break; case WOLFSSL_BIO_SSL: #ifdef WOLFSSL_DTLS - wolfSSL_dtls_set_using_nonblock((WOLFSSL*)bio->ptr, (int)on); + wolfSSL_dtls_set_using_nonblock(bio->ptr.ssl, (int)on); #endif break; @@ -1966,7 +2177,7 @@ int wolfSSL_BIO_get_mem_data(WOLFSSL_BIO* bio, void* p) } if (p) { - *(byte**)p = (byte*)mem_bio->ptr + mem_bio->rdIdx; + *(byte**)p = mem_bio->ptr.mem_buf_data + mem_bio->rdIdx; } return mem_bio->wrSz - mem_bio->rdIdx; @@ -1991,7 +2202,7 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) } else if (bio->type == WOLFSSL_BIO_FILE) { #if !defined(NO_FILESYSTEM) && defined(XFFLUSH) - if (XFFLUSH((FILE *)bio->ptr) != 0) + if (XFFLUSH(bio->ptr.fh) != 0) return WOLFSSL_FAILURE; #endif /* !NO_FILESYSTEM && XFFLUSH */ @@ -2018,7 +2229,7 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) int ret = WOLFSSL_FAILURE; if ((bio != NULL) && (mdcp != NULL)) { - *mdcp = (WOLFSSL_EVP_MD_CTX*)bio->ptr; + *mdcp = bio->ptr.md_ctx; ret = WOLFSSL_SUCCESS; } @@ -2110,11 +2321,39 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) if (bio) { bio->type = WOLFSSL_BIO_SOCKET; bio->shutdown = (byte)closeF; - bio->num = sfd; + bio->num.fd = (SOCKET_T)sfd; } return bio; } + +#if defined(WOLFSSL_HAVE_BIO_ADDR) && defined(WOLFSSL_DTLS) + WOLFSSL_BIO_METHOD *wolfSSL_BIO_s_datagram(void) + { + static WOLFSSL_BIO_METHOD meth = + WOLFSSL_BIO_METHOD_INIT(WOLFSSL_BIO_DGRAM); + + WOLFSSL_ENTER("wolfSSL_BIO_s_datagram"); + + return &meth; + } + + + WOLFSSL_BIO* wolfSSL_BIO_new_dgram(int fd, int closeF) + { + WOLFSSL_BIO* bio = wolfSSL_BIO_new(wolfSSL_BIO_s_datagram()); + + WOLFSSL_ENTER("wolfSSL_BIO_new_dgram"); + if (bio) { + bio->type = WOLFSSL_BIO_DGRAM; + bio->shutdown = (byte)closeF; + bio->num.fd = (SOCKET_T)fd; + } + return bio; + } +#endif + + /** * Create new socket BIO object. This is a pure TCP connection with * no SSL or TLS protection. @@ -2231,7 +2470,7 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) return WOLFSSL_FAILURE; } - b->num = (int)sfd; + b->num.fd = sfd; b->shutdown = BIO_CLOSE; return WOLFSSL_SUCCESS; } @@ -2255,17 +2494,17 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) return WOLFSSL_FAILURE; } - if (b->num == WOLFSSL_BIO_ERROR) { + if (b->num.fd == SOCKET_INVALID) { if (wolfIO_TcpBind(&sfd, b->port) < 0) { WOLFSSL_MSG("wolfIO_TcpBind error"); return WOLFSSL_FAILURE; } - b->num = (int)sfd; + b->num.fd = sfd; b->shutdown = BIO_CLOSE; } else { WOLFSSL_BIO* new_bio; - int newfd = wolfIO_TcpAccept(b->num, NULL, NULL); + int newfd = wolfIO_TcpAccept(b->num.fd, NULL, NULL); if (newfd < 0) { WOLFSSL_MSG("wolfIO_TcpBind error"); return WOLFSSL_FAILURE; @@ -2322,8 +2561,8 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) WOLFSSL_MSG("Bad parameter"); return WOLFSSL_FAILURE; } - if (b->type == WOLFSSL_BIO_SSL && b->ptr != NULL) { - return wolfSSL_negotiate((WOLFSSL*)b->ptr); + if (b->type == WOLFSSL_BIO_SSL && b->ptr.ssl != NULL) { + return wolfSSL_negotiate(b->ptr.ssl); } else { WOLFSSL_MSG("Not SSL BIO or no SSL object set"); @@ -2348,12 +2587,12 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) return; } - if (b->ptr != NULL) { - int rc = wolfSSL_shutdown((WOLFSSL*)b->ptr); + if (b->ptr.ssl != NULL) { + int rc = wolfSSL_shutdown(b->ptr.ssl); if (rc == SSL_SHUTDOWN_NOT_DONE) { /* In this case, call again to give us a chance to read the * close notify alert from the other end. */ - wolfSSL_shutdown((WOLFSSL*)b->ptr); + wolfSSL_shutdown(b->ptr.ssl); } } else { @@ -2368,7 +2607,7 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) WOLFSSL_ENTER("wolfSSL_BIO_set_ssl"); if (b != NULL) { - b->ptr = ssl; + b->ptr.ssl = ssl; b->shutdown = (byte)closeF; if (b->next != NULL) wolfSSL_set_bio(ssl, b->next, b->next); @@ -2396,7 +2635,7 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) return WOLFSSL_FAILURE; } - *ssl = (WOLFSSL*)bio->ptr; + *ssl = bio->ptr.ssl; return WOLFSSL_SUCCESS; } @@ -2540,7 +2779,7 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) WOLFSSL_ENTER("wolfSSL_BIO_set_fd"); if (b != NULL) { - b->num = fd; + b->num.fd = (SOCKET_T)fd; b->shutdown = (byte)closeF; } @@ -2584,7 +2823,14 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) bio->method = method; #endif bio->shutdown = BIO_CLOSE; /* default to close things */ - bio->num = WOLFSSL_BIO_ERROR; + + if ((bio->type == WOLFSSL_BIO_SOCKET) || + (bio->type == WOLFSSL_BIO_DGRAM)) + { + bio->num.fd = SOCKET_INVALID; + } else { + bio->num.length = 0; + } bio->init = 1; #if defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA) @@ -2616,8 +2862,8 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) } if (method->type == WOLFSSL_BIO_MD) { - bio->ptr = wolfSSL_EVP_MD_CTX_new(); - if (bio->ptr == NULL) { + bio->ptr.md_ctx = wolfSSL_EVP_MD_CTX_new(); + if (bio->ptr.md_ctx == NULL) { WOLFSSL_MSG("Memory error"); wolfSSL_BIO_free(bio); return NULL; @@ -2656,11 +2902,11 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) return NULL; } - bio->num = (int)bio->mem_buf->max; + bio->num.length = bio->mem_buf->max; bio->wrSz = len; - bio->ptr = bio->mem_buf->data; - if (len > 0 && bio->ptr != NULL) { - XMEMCPY(bio->ptr, buf, len); + bio->ptr.mem_buf_data = (byte *)bio->mem_buf->data; + if (len > 0 && bio->ptr.mem_buf_data != NULL) { + XMEMCPY(bio->ptr.mem_buf_data, buf, len); bio->flags |= BIO_FLAGS_MEM_RDONLY; bio->wrSzReset = bio->wrSz; } @@ -2728,39 +2974,48 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) } if (bio->shutdown) { - if (bio->type == WOLFSSL_BIO_SSL && bio->ptr) - wolfSSL_free((WOLFSSL*)bio->ptr); + if (bio->type == WOLFSSL_BIO_SSL && bio->ptr.ssl) + wolfSSL_free(bio->ptr.ssl); #ifdef CloseSocket - if ((bio->type == WOLFSSL_BIO_SOCKET) && (bio->num > 0)) - CloseSocket(bio->num); + if (((bio->type == WOLFSSL_BIO_SOCKET) || + (bio->type == WOLFSSL_BIO_DGRAM)) && + (bio->num.fd != SOCKET_INVALID)) + { + CloseSocket(bio->num.fd); + } #endif } #ifndef NO_FILESYSTEM if (bio->type == WOLFSSL_BIO_FILE && bio->shutdown == BIO_CLOSE) { - if (bio->ptr) { - XFCLOSE((XFILE)bio->ptr); + if (bio->ptr.fh) { + XFCLOSE(bio->ptr.fh); } #if !defined(USE_WINDOWS_API) && !defined(NO_WOLFSSL_DIR)\ && !defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2) - else if (bio->num != WOLFSSL_BIO_ERROR) { - XCLOSE(bio->num); + else if (bio->num.fd != SOCKET_INVALID) { + XCLOSE(bio->num.fd); } #endif } #endif if (bio->shutdown != BIO_NOCLOSE) { - if (bio->type == WOLFSSL_BIO_MEMORY && bio->ptr != NULL) { + if (bio->type == WOLFSSL_BIO_MEMORY && + bio->ptr.mem_buf_data != NULL) + { if (bio->mem_buf != NULL) { - if (bio->mem_buf->data != (char*)bio->ptr) { - XFREE(bio->ptr, bio->heap, DYNAMIC_TYPE_OPENSSL); - bio->ptr = NULL; + if ((byte *)bio->mem_buf->data != bio->ptr.mem_buf_data) + { + XFREE(bio->ptr.mem_buf_data, bio->heap, + DYNAMIC_TYPE_OPENSSL); + bio->ptr.mem_buf_data = NULL; } } else { - XFREE(bio->ptr, bio->heap, DYNAMIC_TYPE_OPENSSL); - bio->ptr = NULL; + XFREE(bio->ptr.mem_buf_data, bio->heap, + DYNAMIC_TYPE_OPENSSL); + bio->ptr.mem_buf_data = NULL; } } if (bio->mem_buf != NULL) { @@ -2770,7 +3025,7 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) } if (bio->type == WOLFSSL_BIO_MD) { - wolfSSL_EVP_MD_CTX_free((WOLFSSL_EVP_MD_CTX*)bio->ptr); + wolfSSL_EVP_MD_CTX_free(bio->ptr.md_ctx); } XFREE(bio, 0, DYNAMIC_TYPE_OPENSSL); @@ -2809,8 +3064,8 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) } /* SSL BIO's should use the next object in the chain for IO */ - if (top->type == WOLFSSL_BIO_SSL && top->ptr) - wolfSSL_set_bio((WOLFSSL*)top->ptr, append, append); + if (top->type == WOLFSSL_BIO_SSL && top->ptr.ssl) + wolfSSL_set_bio(top->ptr.ssl, append, append); return top; } @@ -2914,9 +3169,11 @@ int wolfSSL_BIO_get_fd(WOLFSSL_BIO *bio, int* fd) WOLFSSL_ENTER("wolfSSL_BIO_get_fd"); if (bio != NULL) { + if (bio->num.fd == SOCKET_INVALID) + return WOLFSSL_BIO_ERROR; if (fd != NULL) - *fd = bio->num; - return bio->num; + *fd = (int)bio->num.fd; + return (int)bio->num.fd; } return WOLFSSL_BIO_ERROR; @@ -2991,10 +3248,10 @@ int wolfSSL_BIO_vprintf(WOLFSSL_BIO* bio, const char* format, va_list args) switch (bio->type) { #if !defined(NO_FILESYSTEM) case WOLFSSL_BIO_FILE: - if (bio->ptr == NULL) { + if (bio->ptr.fh == XBADFILE) { return -1; } - ret = XVFPRINTF((XFILE)bio->ptr, format, args); + ret = XVFPRINTF(bio->ptr.fh, format, args); break; #endif @@ -3088,21 +3345,22 @@ int wolfSSL_BIO_dump(WOLFSSL_BIO *bio, const char *buf, int length) return wolfSSL_BIO_write(bio, "\tNULL", 5); } - XSPRINTF(line, "%04x - ", lineOffset); + (void)XSNPRINTF(line, sizeof(line), "%04x - ", lineOffset); o = 7; for (i = 0; i < BIO_DUMP_LINE_LEN; i++) { if (i < length) - XSPRINTF(line + o,"%02x ", (unsigned char)buf[i]); + (void)XSNPRINTF(line + o, (int)sizeof(line) - o, + "%02x ", (unsigned char)buf[i]); else - XSPRINTF(line + o, " "); + (void)XSNPRINTF(line + o, (int)sizeof(line) - o, " "); if (i == 7) - XSPRINTF(line + o + 2, "-"); + (void)XSNPRINTF(line + o + 2, (int)sizeof(line) - (o + 2), "-"); o += 3; } - XSPRINTF(line + o, " "); + (void)XSNPRINTF(line + o, (int)sizeof(line) - o, " "); o += 2; for (i = 0; (i < BIO_DUMP_LINE_LEN) && (i < length); i++) { - XSPRINTF(line + o, "%c", + (void)XSNPRINTF(line + o, (int)sizeof(line) - o, "%c", ((31 < buf[i]) && (buf[i] < 127)) ? buf[i] : '.'); o++; } diff --git a/src/conf.c b/src/conf.c index d177da5c71..cc650ad5a2 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1,6 +1,6 @@ /* conf.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/src/crl.c b/src/crl.c index 706c1f6489..10c83afb02 100644 --- a/src/crl.c +++ b/src/crl.c @@ -1,6 +1,6 @@ /* crl.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -426,7 +426,7 @@ static int CheckCertCRLList(WOLFSSL_CRL* crl, byte* issuerHash, byte* serial, #endif { #if !defined(NO_ASN_TIME) && !defined(WOLFSSL_NO_CRL_DATE_CHECK) - if (!XVALIDATE_DATE(crle->nextDate,crle->nextDateFormat, AFTER)) { + if (!XVALIDATE_DATE(crle->nextDate,crle->nextDateFormat, ASN_AFTER)) { WOLFSSL_MSG("CRL next date is no longer valid"); nextDateValid = 0; } diff --git a/src/dtls.c b/src/dtls.c index 52ace7ec24..ae4cc7e2cb 100644 --- a/src/dtls.c +++ b/src/dtls.c @@ -1,6 +1,6 @@ /* dtls.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/src/dtls13.c b/src/dtls13.c index 0284ffe92c..0577715474 100644 --- a/src/dtls13.c +++ b/src/dtls13.c @@ -1,6 +1,6 @@ /* dtls13.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/src/include.am b/src/include.am index 1679e3b567..4d96fd2ebe 100644 --- a/src/include.am +++ b/src/include.am @@ -229,6 +229,10 @@ endif !BUILD_X86_ASM endif !BUILD_ARMASM endif !BUILD_ARMASM_NEON +if BUILD_RISCV_ASM +src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/riscv/riscv-64-sha256.c +endif BUILD_RISCV_ASM + if BUILD_SHA512 if BUILD_ARMASM_NEON src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/armv8-sha512.c @@ -384,6 +388,10 @@ endif BUILD_INTELASM endif !BUILD_ARMASM endif !BUILD_ARMASM_NEON +if BUILD_RISCV_ASM +src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/riscv/riscv-64-sha256.c +endif BUILD_RISCV_ASM + if BUILD_SHA512 if BUILD_ARMASM_NEON src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/armv8-sha512.c @@ -595,6 +603,11 @@ endif BUILD_INTELASM endif !BUILD_X86_ASM endif !BUILD_ARMASM endif !BUILD_ARMASM_NEON + +if BUILD_RISCV_ASM +src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/riscv/riscv-64-sha256.c +endif BUILD_RISCV_ASM + endif !BUILD_FIPS_CURRENT if BUILD_AFALG @@ -958,17 +971,21 @@ if BUILD_CHACHA if BUILD_ARMASM_NEON src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/armv8-chacha.c else +if BUILD_RISCV_ASM +src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/riscv/riscv-64-chacha.c +else src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/chacha.c +endif !BUILD_RISCV_ASM if !BUILD_X86_ASM if BUILD_INTELASM src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/chacha_asm.S -endif -endif -endif +endif BUILD_INTELASM +endif !BUILD_X86_ASM +endif !BUILD_ARMASM_NEON if BUILD_POLY1305 src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/chacha20_poly1305.c -endif -endif +endif BUILD_POLY1305 +endif BUILD_CHACHA if !BUILD_INLINE src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/misc.c @@ -995,7 +1012,6 @@ if BUILD_SAKKE src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/sakke.c endif -if !BUILD_FIPS_CURRENT if BUILD_WC_KYBER src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_kyber.c src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_kyber_poly.c @@ -1005,7 +1021,6 @@ src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_kyber_asm.S endif endif endif -endif if BUILD_DILITHIUM src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/dilithium.c diff --git a/src/internal.c b/src/internal.c index 7a2690ed84..6395f0a23d 100644 --- a/src/internal.c +++ b/src/internal.c @@ -1,6 +1,6 @@ /* internal.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -344,7 +344,7 @@ void wolfssl_priv_der_unblind(DerBuffer* key, DerBuffer* mask) { wolfSSL_CTX_keylog_cb_func logCb = NULL; int msSz; - int hasVal; + int invalidCount; int i; const char* label = SSC_CR; int labelSz = sizeof(SSC_CR); @@ -355,32 +355,34 @@ void wolfssl_priv_der_unblind(DerBuffer* key, DerBuffer* mask) int ret; (void)ctx; - if (ssl == NULL || secret == NULL || *secretSz == 0) + if (ssl == NULL || secret == NULL || secretSz == NULL || *secretSz == 0) return BAD_FUNC_ARG; if (ssl->arrays == NULL) return BAD_FUNC_ARG; - /* get the user-callback func from CTX*/ + /* get the user-callback func from CTX */ logCb = ssl->ctx->keyLogCb; - if (logCb == NULL) - return 0; + if (logCb == NULL) { + return 0; /* no logging callback */ + } - /* need to make sure the given master-secret has a meaningful value */ + /* make sure the given master-secret has a meaningful value */ msSz = *secretSz; - hasVal = 0; + invalidCount = 0; for (i = 0; i < msSz; i++) { - if (*((byte*)secret) != 0) { - hasVal = 1; - break; + if (((byte*)secret)[i] == 0) { + invalidCount++; } } - if (hasVal == 0) - return 0; /* master-secret looks invalid */ + if (invalidCount == *secretSz) { + WOLFSSL_MSG("master-secret is not valid"); + return 0; /* ignore error */ + } /* build up a hex-decoded keylog string - "CLIENT_RANDOM " - note that each keylog string does not have CR/LF. - */ + * "CLIENT_RANDOM " + * note that each keylog string does not have CR/LF. + */ buffSz = labelSz + (RAN_LEN * 2) + 1 + ((*secretSz) * 2) + 1; log = XMALLOC(buffSz, ssl->heap, DYNAMIC_TYPE_SECRET); if (log == NULL) @@ -410,8 +412,9 @@ void wolfssl_priv_der_unblind(DerBuffer* key, DerBuffer* mask) ret = 0; } } - else - ret = MEMORY_E; + else { + ret = BUFFER_E; + } } /* Zero out Base16 encoded secret and other data. */ ForceZero(log, buffSz); @@ -4643,11 +4646,20 @@ void FreeX509(WOLFSSL_X509* x509) x509->altNames = NULL; } -#ifdef WOLFSSL_DUAL_ALG_CERTS - XFREE(x509->sapkiDer, x509->heap, DYNAMIC_TYPE_X509_EXT); - XFREE(x509->altSigAlgDer, x509->heap, DYNAMIC_TYPE_X509_EXT); - XFREE(x509->altSigValDer, x509->heap, DYNAMIC_TYPE_X509_EXT); -#endif /* WOLFSSL_DUAL_ALG_CERTS */ + #ifdef WOLFSSL_DUAL_ALG_CERTS + if (x509->sapkiDer) { + XFREE(x509->sapkiDer, x509->heap, DYNAMIC_TYPE_X509_EXT); + x509->sapkiDer = NULL; + } + if (x509->altSigAlgDer) { + XFREE(x509->altSigAlgDer, x509->heap, DYNAMIC_TYPE_X509_EXT); + x509->altSigAlgDer = NULL; + } + if (x509->altSigValDer) { + XFREE(x509->altSigValDer, x509->heap, DYNAMIC_TYPE_X509_EXT); + x509->altSigValDer= NULL; + } + #endif /* WOLFSSL_DUAL_ALG_CERTS */ #if defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL) wolfSSL_RefFree(&x509->ref); @@ -11472,7 +11484,7 @@ static int GetRecordHeader(WOLFSSL* ssl, word32* inOutIdx, } #endif /* WOLFSSL_DTLS13 */ /* Don't care about protocol version being lower than expected on alerts - * sent back before version negotitation. */ + * sent back before version negotiation. */ else if (!(ssl->options.side == WOLFSSL_CLIENT_END && ssl->options.connectState == CLIENT_HELLO_SENT && rh->type == alert && @@ -12531,13 +12543,13 @@ int CheckForAltNames(DecodedCert* dCert, const char* domain, word32 domainLen, while (altName) { WOLFSSL_MSG("\tindividual AltName check"); -#if defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME) +#ifdef WOLFSSL_IP_ALT_NAME if (altName->type == ASN_IP_TYPE) { buf = altName->ipString; len = (word32)XSTRLEN(buf); } else -#endif /* OPENSSL_ALL || WOLFSSL_IP_ALT_NAME */ +#endif /* WOLFSSL_IP_ALT_NAME */ { buf = altName->name; len = (word32)altName->len; @@ -12636,7 +12648,7 @@ void CopyDecodedName(WOLFSSL_X509_NAME* name, DecodedCert* dCert, int nameType) name->dynamicName = 0; } - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { XSTRNCPY(name->name, dCert->subject, ASN_NAME_MAX); name->name[ASN_NAME_MAX - 1] = '\0'; name->sz = (int)XSTRLEN(name->name) + 1; @@ -12808,6 +12820,7 @@ static int CopyREQAttributes(WOLFSSL_X509* x509, DecodedCert* dCert) int CopyDecodedToX509(WOLFSSL_X509* x509, DecodedCert* dCert) { int ret = 0; + int minSz; if (x509 == NULL || dCert == NULL || dCert->subjectCNLen < 0) @@ -12821,7 +12834,7 @@ int CopyDecodedToX509(WOLFSSL_X509* x509, DecodedCert* dCert) x509->version = dCert->version + 1; - CopyDecodedName(&x509->issuer, dCert, ISSUER); + CopyDecodedName(&x509->issuer, dCert, ASN_ISSUER); #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) if (dCert->issuerName != NULL) { wolfSSL_X509_set_issuer_name(x509, @@ -12829,7 +12842,7 @@ int CopyDecodedToX509(WOLFSSL_X509* x509, DecodedCert* dCert) x509->issuer.x509 = x509; } #endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */ - CopyDecodedName(&x509->subject, dCert, SUBJECT); + CopyDecodedName(&x509->subject, dCert, ASN_SUBJECT); #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) if (dCert->subjectName != NULL) { wolfSSL_X509_set_subject_name(x509, @@ -12857,49 +12870,45 @@ int CopyDecodedToX509(WOLFSSL_X509* x509, DecodedCert* dCert) #endif /* WOLFSSL_CERT_REQ */ #ifdef WOLFSSL_SEP - { - int minSz = min(dCert->deviceTypeSz, EXTERNAL_SERIAL_SIZE); - if (minSz > 0) { - x509->deviceTypeSz = minSz; - XMEMCPY(x509->deviceType, dCert->deviceType, minSz); - } - else - x509->deviceTypeSz = 0; - minSz = min(dCert->hwTypeSz, EXTERNAL_SERIAL_SIZE); - if (minSz > 0) { - x509->hwTypeSz = minSz; - XMEMCPY(x509->hwType, dCert->hwType, minSz); - } - else - x509->hwTypeSz = 0; - minSz = min(dCert->hwSerialNumSz, EXTERNAL_SERIAL_SIZE); - if (minSz > 0) { - x509->hwSerialNumSz = minSz; - XMEMCPY(x509->hwSerialNum, dCert->hwSerialNum, minSz); - } - else - x509->hwSerialNumSz = 0; + minSz = min(dCert->deviceTypeSz, EXTERNAL_SERIAL_SIZE); + if (minSz > 0) { + x509->deviceTypeSz = minSz; + XMEMCPY(x509->deviceType, dCert->deviceType, minSz); + } + else + x509->deviceTypeSz = 0; + minSz = min(dCert->hwTypeSz, EXTERNAL_SERIAL_SIZE); + if (minSz > 0) { + x509->hwTypeSz = minSz; + XMEMCPY(x509->hwType, dCert->hwType, minSz); } + else + x509->hwTypeSz = 0; + minSz = min(dCert->hwSerialNumSz, EXTERNAL_SERIAL_SIZE); + if (minSz > 0) { + x509->hwSerialNumSz = minSz; + XMEMCPY(x509->hwSerialNum, dCert->hwSerialNum, minSz); + } + else + x509->hwSerialNumSz = 0; #endif /* WOLFSSL_SEP */ - { - int minSz; - if (dCert->beforeDateLen > 0) { - minSz = (int)min(dCert->beforeDate[1], MAX_DATE_SZ); - x509->notBefore.type = dCert->beforeDate[0]; - x509->notBefore.length = minSz; - XMEMCPY(x509->notBefore.data, &dCert->beforeDate[2], minSz); - } - else - x509->notBefore.length = 0; - if (dCert->afterDateLen > 0) { - minSz = (int)min(dCert->afterDate[1], MAX_DATE_SZ); - x509->notAfter.type = dCert->afterDate[0]; - x509->notAfter.length = minSz; - XMEMCPY(x509->notAfter.data, &dCert->afterDate[2], minSz); - } - else - x509->notAfter.length = 0; + + if (dCert->beforeDateLen > 0) { + minSz = (int)min(dCert->beforeDate[1], MAX_DATE_SZ); + x509->notBefore.type = dCert->beforeDate[0]; + x509->notBefore.length = minSz; + XMEMCPY(x509->notBefore.data, &dCert->beforeDate[2], minSz); + } + else + x509->notBefore.length = 0; + if (dCert->afterDateLen > 0) { + minSz = (int)min(dCert->afterDate[1], MAX_DATE_SZ); + x509->notAfter.type = dCert->afterDate[0]; + x509->notAfter.length = minSz; + XMEMCPY(x509->notAfter.data, &dCert->afterDate[2], minSz); } + else + x509->notAfter.length = 0; if (dCert->publicKey != NULL && dCert->pubKeySize != 0) { x509->pubKey.buffer = (byte*)XMALLOC( @@ -13038,7 +13047,7 @@ int CopyDecodedToX509(WOLFSSL_X509* x509, DecodedCert* dCert) ret = MEMORY_E; } } - #if defined(OPENSSL_ALL) || defined(WOLFSSL_QT) + #ifdef WOLFSSL_ASN_CA_ISSUER if (dCert->extAuthInfoCaIssuer != NULL && dCert->extAuthInfoCaIssuerSz > 0) { x509->authInfoCaIssuer = (byte*)XMALLOC(dCert->extAuthInfoCaIssuerSz, x509->heap, DYNAMIC_TYPE_X509_EXT); @@ -13124,10 +13133,10 @@ int CopyDecodedToX509(WOLFSSL_X509* x509, DecodedCert* dCert) #ifndef IGNORE_NETSCAPE_CERT_TYPE x509->nsCertType = dCert->nsCertType; #endif - #if defined(WOLFSSL_SEP) || defined(WOLFSSL_QT) + #ifdef WOLFSSL_SEP x509->certPolicySet = dCert->extCertPolicySet; x509->certPolicyCrit = dCert->extCertPolicyCrit; - #endif /* WOLFSSL_SEP || WOLFSSL_QT */ + #endif #ifdef WOLFSSL_CERT_EXT { int i; @@ -23301,13 +23310,17 @@ int SendFinished(WOLFSSL* ssl) * Returns 0 on success */ static int CreateOcspRequest(WOLFSSL* ssl, OcspRequest* request, - DecodedCert* cert, byte* certData, word32 length) + DecodedCert* cert, byte* certData, word32 length, + byte *ctxOwnsRequest) { int ret; if (request != NULL) XMEMSET(request, 0, sizeof(OcspRequest)); + if (ctxOwnsRequest!= NULL) + *ctxOwnsRequest = 0; + InitDecodedCert(cert, certData, length, ssl->heap); /* TODO: Setup async support here */ ret = ParseCertRelative(cert, CERT_TYPE, VERIFY, SSL_CM(ssl), NULL); @@ -23321,8 +23334,11 @@ static int CreateOcspRequest(WOLFSSL* ssl, OcspRequest* request, if (!ssl->buffers.weOwnCert) { wolfSSL_Mutex* ocspLock = &SSL_CM(ssl)->ocsp_stapling->ocspLock; if (wc_LockMutex(ocspLock) == 0) { - if (ssl->ctx->certOcspRequest == NULL) + if (ssl->ctx->certOcspRequest == NULL) { ssl->ctx->certOcspRequest = request; + if (ctxOwnsRequest!= NULL) + *ctxOwnsRequest = 1; + } wc_UnLockMutex(ocspLock); } } @@ -23351,6 +23367,7 @@ int CreateOcspResponse(WOLFSSL* ssl, OcspRequest** ocspRequest, int ret = 0; OcspRequest* request = NULL; byte createdRequest = 0; + byte ctxOwnsRequest = 0; if (ssl == NULL || ocspRequest == NULL || response == NULL) return BAD_FUNC_ARG; @@ -23388,7 +23405,7 @@ int CreateOcspResponse(WOLFSSL* ssl, OcspRequest** ocspRequest, createdRequest = 1; if (ret == 0) { ret = CreateOcspRequest(ssl, request, cert, der->buffer, - der->length); + der->length, &ctxOwnsRequest); } if (ret != 0) { @@ -23415,7 +23432,7 @@ int CreateOcspResponse(WOLFSSL* ssl, OcspRequest** ocspRequest, } /* free request up if error case found otherwise return it */ - if (ret != 0 && createdRequest) { + if (ret != 0 && createdRequest && !ctxOwnsRequest) { FreeOcspRequest(request); XFREE(request, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST); } @@ -24110,6 +24127,7 @@ int SendCertificateStatus(WOLFSSL* ssl) { OcspRequest* request = ssl->ctx->certOcspRequest; buffer responses[1 + MAX_CHAIN_DEPTH]; + byte ctxOwnsRequest = 0; int i = 0; XMEMSET(responses, 0, sizeof(responses)); @@ -24168,7 +24186,7 @@ int SendCertificateStatus(WOLFSSL* ssl) break; ret = CreateOcspRequest(ssl, request, cert, der.buffer, - der.length); + der.length, &ctxOwnsRequest); if (ret == 0) { request->ssl = ssl; ret = CheckOcspRequest(SSL_CM(ssl)->ocsp_stapling, @@ -24183,12 +24201,13 @@ int SendCertificateStatus(WOLFSSL* ssl) i++; - FreeOcspRequest(request); + if (!ctxOwnsRequest) + FreeOcspRequest(request); } } } - - XFREE(request, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST); + if (!ctxOwnsRequest) + XFREE(request, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST); #ifdef WOLFSSL_SMALL_STACK XFREE(cert, ssl->heap, DYNAMIC_TYPE_DCERT); #endif @@ -30286,7 +30305,7 @@ static int HashSkeData(WOLFSSL* ssl, enum wc_HashType hashType, InitDecodedCert(cert, input + *inOutIdx, dnSz, ssl->heap); - ret = GetName(cert, SUBJECT, dnSz); + ret = GetName(cert, ASN_SUBJECT, dnSz); if (ret == 0) { if ((name = wolfSSL_X509_NAME_new_ex(cert->heap)) == NULL) @@ -30294,7 +30313,7 @@ static int HashSkeData(WOLFSSL* ssl, enum wc_HashType hashType, } if (ret == 0) { - CopyDecodedName(name, cert, SUBJECT); + CopyDecodedName(name, cert, ASN_SUBJECT); } if (ret == 0) { @@ -37910,7 +37929,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx, itHash = HashObject((byte*)it, sizeof(*it), &error); if (error == 0) { ret = ssl->ctx->ticketEncCb(ssl, et->key_name, et->iv, et->mac, - 1, et->enc_ticket, sizeof(InternalTicket), &encLen, + 1, et->enc_ticket, WOLFSSL_INTERNAL_TICKET_LEN, &encLen, SSL_TICKET_CTX(ssl)); } else { @@ -37925,7 +37944,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx, #endif goto error; } - if (encLen < (int)sizeof(InternalTicket) || + if (encLen < (int)WOLFSSL_INTERNAL_TICKET_LEN || encLen > (int)WOLFSSL_TICKET_ENC_SZ) { WOLFSSL_MSG("Bad user ticket encrypt size"); ret = BAD_TICKET_KEY_CB_SZ; @@ -38001,7 +38020,8 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx, WOLFSSL_ENTER("DoDecryptTicket"); if (len > SESSION_TICKET_LEN || - len < (word32)(sizeof(InternalTicket) + WOLFSSL_TICKET_FIXED_SZ)) { + len < (word32)(WOLFSSL_INTERNAL_TICKET_LEN + + WOLFSSL_TICKET_FIXED_SZ)) { WOLFSSL_ERROR_VERBOSE(BAD_TICKET_MSG_SZ); return WOLFSSL_TICKET_RET_REJECT; } @@ -38049,7 +38069,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx, return WOLFSSL_TICKET_RET_REJECT; } } - if (outLen > (int)inLen || outLen < (int)sizeof(InternalTicket)) { + if (outLen > (int)inLen || outLen < (int)WOLFSSL_INTERNAL_TICKET_LEN) { WOLFSSL_MSG("Bad user ticket decrypt len"); WOLFSSL_ERROR_VERBOSE(BAD_TICKET_KEY_CB_SZ); return BAD_TICKET_KEY_CB_SZ; @@ -38743,7 +38763,123 @@ static void TicketEncCbCtx_Free(TicketEncCbCtx* keyCtx) wc_FreeRng(&keyCtx->rng); } -#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305) && \ +#ifdef WOLFSSL_TICKET_ENC_CBC_HMAC +/* Ticket encryption/decryption implementation. + * + * @param [in] key Key for encryption/decryption and HMAC. + * @param [in] keyLen Length of key in bytes. + * @param [in] iv IV/Nonce for encryption/decryption. + * @param [in] aad Additional authentication data. + * @param [in] aadSz Length of additional authentication data. + * @param [in] in Data to encrypt/decrypt. + * @param [in] inLen Length of encrypted data. + * @param [out] out Resulting data from encrypt/decrypt. + * @param [out] outLen Size of resulting data. + * @param [in] tag Authentication tag for encrypted data. + * @param [in] heap Dynamic memory allocation data hint. + * @param [in] enc 1 when encrypting, 0 when decrypting. + * @return 0 on success. + * @return Other value when encryption/decryption fails. + */ +static int TicketEncDec(byte* key, int keyLen, byte* iv, byte* aad, int aadSz, + byte* in, int inLen, byte* out, int* outLen, byte* tag, + void* heap, int enc) +{ + int ret; +#ifdef WOLFSSL_SMALL_STACK + Aes* aes; + Hmac* hmac; +#else + Aes aes[1]; + Hmac hmac[1]; +#endif + + (void)heap; + +#ifdef WOLFSSL_SMALL_STACK + aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_TMP_BUFFER); + if (aes == NULL) + return MEMORY_E; + hmac = (Hmac*)XMALLOC(sizeof(Hmac), heap, DYNAMIC_TYPE_TMP_BUFFER); + if (hmac == NULL) { + XFREE(aes, heap, DYNAMIC_TYPE_TMP_BUFFER); + return MEMORY_E; + } +#endif + + XMEMSET(aes, 0, sizeof(Aes)); + XMEMSET(hmac, 0, sizeof(Hmac)); + + ret = wc_HmacInit(hmac, heap, DYNAMIC_TYPE_TMP_BUFFER); + if (ret == 0) { + ret = wc_HmacSetKey(hmac, WOLFSSL_TICKET_ENC_HMAC, key + keyLen - + WOLFSSL_TICKET_HMAC_KEY_SZ, WOLFSSL_TICKET_HMAC_KEY_SZ); + } + if (ret == 0) { + ret = wc_HmacUpdate(hmac, aad, aadSz); + } + + if (ret == 0) { + if (enc) { + ret = wc_AesInit(aes, NULL, INVALID_DEVID); + if (ret == 0) { + ret = wc_AesSetKey(aes, key, + keyLen - WOLFSSL_TICKET_HMAC_KEY_SZ, iv, AES_ENCRYPTION); + } + if (ret == 0) { + ret = wc_HmacUpdate(hmac, in, inLen); + } + if (ret == 0) { + ret = wc_AesCbcEncrypt(aes, in, out, inLen); + } + if (ret == 0) { + XMEMSET(tag, 0, WOLFSSL_TICKET_MAC_SZ); + ret = wc_HmacFinal(hmac, tag); + } + wc_AesFree(aes); + } + else { + unsigned char calcTag[WOLFSSL_TICKET_MAC_SZ]; + + ret = wc_AesInit(aes, NULL, INVALID_DEVID); + if (ret == 0) { + ret = wc_AesSetKey(aes, key, + keyLen - WOLFSSL_TICKET_HMAC_KEY_SZ, iv, AES_DECRYPTION); + } + if (ret == 0) { + ret = wc_AesCbcDecrypt(aes, in, out, inLen); + } + if (ret == 0) { + ret = wc_HmacUpdate(hmac, out, inLen); + } + if (ret == 0) { + XMEMSET(calcTag, 0, WOLFSSL_TICKET_MAC_SZ); + ret = wc_HmacFinal(hmac, calcTag); + } + if (ret == 0) { + int i; + calcTag[0] ^= tag[0]; + for (i = 1; i < WOLFSSL_TICKET_MAC_SZ; i++) { + calcTag[0] |= calcTag[i] ^ tag[i]; + } + /* Return a negative value when no match. */ + ret = -calcTag[0]; + } + wc_AesFree(aes); + } + } + wc_HmacFree(hmac); + +#ifdef WOLFSSL_SMALL_STACK + XFREE(hmac, heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(aes, heap, DYNAMIC_TYPE_TMP_BUFFER); +#endif + + *outLen = inLen; + + return ret; +} +#elif defined(HAVE_CHACHA) && defined(HAVE_POLY1305) && \ !defined(WOLFSSL_TICKET_ENC_AES128_GCM) && \ !defined(WOLFSSL_TICKET_ENC_AES256_GCM) /* Ticket encryption/decryption implementation. @@ -39038,7 +39174,7 @@ static int DefTicketEncCb(WOLFSSL* ssl, byte key_name[WOLFSSL_TICKET_NAME_SZ], WOLFSSL_ENTER("DefTicketEncCb"); - if ((!enc) && (inLen != sizeof(InternalTicket))) { + if ((!enc) && (inLen != WOLFSSL_INTERNAL_TICKET_LEN)) { return BUFFER_E; } diff --git a/src/keys.c b/src/keys.c index f9f9e856b1..38b1f88d1b 100644 --- a/src/keys.c +++ b/src/keys.c @@ -1,6 +1,6 @@ /* keys.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/src/ocsp.c b/src/ocsp.c index 4760c50989..70f6bf6f87 100644 --- a/src/ocsp.c +++ b/src/ocsp.c @@ -1,6 +1,6 @@ /* ocsp.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -251,10 +251,10 @@ static int GetOcspStatus(WOLFSSL_OCSP* ocsp, OcspRequest* request, else if (*status) { #ifndef NO_ASN_TIME if (XVALIDATE_DATE((*status)->thisDate, - (*status)->thisDateFormat, BEFORE) + (*status)->thisDateFormat, ASN_BEFORE) && ((*status)->nextDate[0] != 0) && XVALIDATE_DATE((*status)->nextDate, - (*status)->nextDateFormat, AFTER)) + (*status)->nextDateFormat, ASN_AFTER)) #endif { ret = xstat2err((*status)->status); @@ -284,7 +284,7 @@ static int GetOcspStatus(WOLFSSL_OCSP* ocsp, OcspRequest* request, * ocsp Context object for OCSP status. * response OCSP response message data. * responseSz Length of OCSP response message data. - * reponseBuffer Buffer object to return the response with. + * responseBuffer Buffer object to return the response with. * status The certificate status object. * entry The OCSP entry for this certificate. * ocspRequest Request corresponding to response. @@ -668,8 +668,9 @@ int CheckOcspResponder(OcspResponse *bs, DecodedCert *cert, void* vp) return ret; } -#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) || \ - defined(WOLFSSL_APACHE_HTTPD) || defined(HAVE_LIGHTY) + +/* compatibility layer OCSP functions */ +#ifdef OPENSSL_EXTRA int wolfSSL_OCSP_resp_find_status(WOLFSSL_OCSP_BASICRESP *bs, WOLFSSL_OCSP_CERTID* id, int* status, int* reason, WOLFSSL_ASN1_TIME** revtime, WOLFSSL_ASN1_TIME** thisupd, @@ -695,10 +696,17 @@ int wolfSSL_OCSP_resp_find_status(WOLFSSL_OCSP_BASICRESP *bs, if (status != NULL) *status = single->status->status; +#ifdef WOLFSSL_OCSP_PARSE_STATUS if (thisupd != NULL) *thisupd = &single->status->thisDateParsed; if (nextupd != NULL) *nextupd = &single->status->nextDateParsed; +#else + if (thisupd != NULL) + *thisupd = NULL; + if (nextupd != NULL) + *nextupd = NULL; +#endif /* TODO: Not needed for Nginx or httpd */ if (reason != NULL) @@ -872,10 +880,8 @@ int wolfSSL_OCSP_basic_verify(WOLFSSL_OCSP_BASICRESP *bs, return WOLFSSL_FAILURE; #endif -#ifdef OPENSSL_EXTRA if (bs->verifyError != OCSP_VERIFY_ERROR_NONE) goto out; -#endif if (flags & OCSP_TRUSTOTHER) { for (idx = 0; idx < wolfSSL_sk_X509_num(certs); idx++) { @@ -952,18 +958,18 @@ OcspResponse* wolfSSL_d2i_OCSP_RESPONSE_bio(WOLFSSL_BIO* bio, long fcur; long flen; - if (bio->ptr == NULL) + if (bio->ptr.fh == NULL) return NULL; - fcur = XFTELL((XFILE)bio->ptr); + fcur = XFTELL(bio->ptr.fh); if (fcur < 0) return NULL; - if(XFSEEK((XFILE)bio->ptr, 0, SEEK_END) != 0) + if(XFSEEK(bio->ptr.fh, 0, SEEK_END) != 0) return NULL; - flen = XFTELL((XFILE)bio->ptr); + flen = XFTELL(bio->ptr.fh); if (flen < 0) return NULL; - if (XFSEEK((XFILE)bio->ptr, fcur, SEEK_SET) != 0) + if (XFSEEK(bio->ptr.fh, fcur, SEEK_SET) != 0) return NULL; /* check calculated length */ @@ -1191,9 +1197,7 @@ WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_CERTID_dup(WOLFSSL_OCSP_CERTID* id) } return certId; } -#endif -#if defined(OPENSSL_ALL) || defined(APACHE_HTTPD) || defined(WOLFSSL_HAPROXY) #ifndef NO_BIO int wolfSSL_i2d_OCSP_REQUEST_bio(WOLFSSL_BIO* out, WOLFSSL_OCSP_REQUEST *req) @@ -1295,7 +1299,8 @@ WOLFSSL_OCSP_CERTID* wolfSSL_d2i_OCSP_CERTID(WOLFSSL_OCSP_CERTID** cidOut, return NULL; } -const WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_SINGLERESP_get0_id(const WOLFSSL_OCSP_SINGLERESP *single) +const WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_SINGLERESP_get0_id( + const WOLFSSL_OCSP_SINGLERESP *single) { return single; } @@ -1343,11 +1348,17 @@ int wolfSSL_OCSP_single_get0_status(WOLFSSL_OCSP_SINGLERESP *single, if (single == NULL) return WOLFSSL_FAILURE; +#ifdef WOLFSSL_OCSP_PARSE_STATUS if (thisupd != NULL) *thisupd = &single->status->thisDateParsed; if (nextupd != NULL) *nextupd = &single->status->nextDateParsed; - +#else + if (thisupd != NULL) + *thisupd = NULL; + if (nextupd != NULL) + *nextupd = NULL; +#endif if (reason != NULL) *reason = 0; if (revtime != NULL) @@ -1392,9 +1403,6 @@ WOLFSSL_OCSP_SINGLERESP* wolfSSL_OCSP_resp_get0(WOLFSSL_OCSP_BASICRESP *bs, int return single; } -#endif /* OPENSSL_ALL || APACHE_HTTPD || WOLFSSL_HAPROXY */ - -#ifdef OPENSSL_EXTRA #ifndef NO_WOLFSSL_STUB int wolfSSL_OCSP_REQUEST_add_ext(OcspRequest* req, WOLFSSL_X509_EXTENSION* ext, int idx) @@ -1467,12 +1475,14 @@ int wolfSSL_OCSP_id_get0_info(WOLFSSL_ASN1_STRING **name, #if defined(WOLFSSL_QT) || defined(WOLFSSL_HAPROXY) /* Serial number starts at 0 index of ser->data */ - XMEMCPY(&ser->data[i], cid->status->serial, (size_t)cid->status->serialSz); + XMEMCPY(&ser->data[i], cid->status->serial, + (size_t)cid->status->serialSz); ser->length = cid->status->serialSz; #else ser->data[i++] = ASN_INTEGER; i += SetLength(cid->status->serialSz, ser->data + i); - XMEMCPY(&ser->data[i], cid->status->serial, (size_t)cid->status->serialSz); + XMEMCPY(&ser->data[i], cid->status->serial, + (size_t)cid->status->serialSz); ser->length = i + cid->status->serialSz; #endif diff --git a/src/pk.c b/src/pk.c index 1ec9a00ce0..2c06eca20e 100644 --- a/src/pk.c +++ b/src/pk.c @@ -1,6 +1,6 @@ /* pk.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -7283,7 +7283,7 @@ WOLFSSL_BIGNUM* wolfSSL_DH_8192_prime(WOLFSSL_BIGNUM* bn) #ifndef NO_CERTS -/* Load the DER encoded DH parameters/key into DH key. +/* Load the DER encoded DH parameters into DH key. * * @param [in, out] dh DH key to load parameters into. * @param [in] der Buffer holding DER encoded parameters data. @@ -7294,7 +7294,7 @@ WOLFSSL_BIGNUM* wolfSSL_DH_8192_prime(WOLFSSL_BIGNUM* bn) * @return 0 on success. * @return 1 when decoding DER or setting the external key fails. */ -static int wolfssl_dh_load_key(WOLFSSL_DH* dh, const unsigned char* der, +static int wolfssl_dh_load_params(WOLFSSL_DH* dh, const unsigned char* der, word32* idx, word32 derSz) { int err = 0; @@ -7407,7 +7407,7 @@ WOLFSSL_DH *wolfSSL_d2i_DHparams(WOLFSSL_DH** dh, const unsigned char** pp, WOLFSSL_ERROR_MSG("wolfSSL_DH_new() failed"); err = 1; } - if ((!err) && (wolfssl_dh_load_key(newDh, *pp, &idx, + if ((!err) && (wolfssl_dh_load_params(newDh, *pp, &idx, (word32)length) != 0)) { WOLFSSL_ERROR_MSG("Loading DH parameters failed"); err = 1; @@ -7567,7 +7567,7 @@ int wolfSSL_DH_LoadDer(WOLFSSL_DH* dh, const unsigned char* derBuf, int derSz) ret = -1; } - if ((ret == 1) && (wolfssl_dh_load_key(dh, derBuf, &idx, + if ((ret == 1) && (wolfssl_dh_load_params(dh, derBuf, &idx, (word32)derSz) != 0)) { WOLFSSL_ERROR_MSG("DH key decode failed"); ret = -1; diff --git a/src/quic.c b/src/quic.c index 117bb4373d..d28abe5a02 100644 --- a/src/quic.c +++ b/src/quic.c @@ -1,6 +1,6 @@ /* quic.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/src/sniffer.c b/src/sniffer.c index 94b2a9fcc1..8c5b4cf275 100644 --- a/src/sniffer.c +++ b/src/sniffer.c @@ -1,6 +1,6 @@ /* sniffer.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/src/ssl.c b/src/ssl.c index 9ba891d629..13450e8ce7 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -1,6 +1,6 @@ /* ssl.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -1954,6 +1954,15 @@ int wolfSSL_dtls_set_mtu(WOLFSSL* ssl, word16 newMtu) return WOLFSSL_SUCCESS; } +#if defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA) +int wolfSSL_set_mtu_compat(WOLFSSL* ssl, unsigned short mtu) { + if (wolfSSL_dtls_set_mtu(ssl, mtu) == 0) + return SSL_SUCCESS; + else + return SSL_FAILURE; +} +#endif /* OPENSSL_ALL || OPENSSL_EXTRA */ + #endif /* WOLFSSL_DTLS && (WOLFSSL_SCTP || WOLFSSL_DTLS_MTU) */ #ifdef WOLFSSL_SRTP @@ -5349,6 +5358,13 @@ int AddCA(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int type, int verify) #endif InitDecodedCert(cert, der->buffer, der->length, cm->heap); + +#ifdef WC_ASN_UNKNOWN_EXT_CB + if (cm->unknownExtCallback != NULL) { + wc_SetUnknownExtCallback(cert, cm->unknownExtCallback); + } +#endif + ret = ParseCert(cert, CA_TYPE, verify, cm); WOLFSSL_MSG("\tParsed new CA"); @@ -10315,6 +10331,25 @@ int wolfSSL_check_domain_name(WOLFSSL* ssl, const char* dn) } } +#if defined(SESSION_CERTS) && defined(OPENSSL_EXTRA) +const char *wolfSSL_get0_peername(WOLFSSL *ssl) { + if (ssl == NULL) { + return NULL; + } + + if (ssl->buffers.domainName.buffer) + return (const char *)ssl->buffers.domainName.buffer; + else if (ssl->session && ssl->session->peer) + return ssl->session->peer->subjectCN; + else if (ssl->peerCert.subjectCN[0]) + return ssl->peerCert.subjectCN; + else { + ssl->error = NO_PEER_CERT; + return NULL; + } +} + +#endif /* SESSION_CERTS && OPENSSL_EXTRA */ /* turn on wolfSSL zlib compression returns WOLFSSL_SUCCESS for success, else error (not built in) @@ -10930,7 +10965,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) #ifdef OPENSSL_EXTRA #ifndef NO_BIO - void wolfSSL_set_bio(WOLFSSL* ssl, WOLFSSL_BIO* rd, WOLFSSL_BIO* wr) + static void ssl_set_bio(WOLFSSL* ssl, WOLFSSL_BIO* rd, WOLFSSL_BIO* wr, int flags) { WOLFSSL_ENTER("wolfSSL_set_bio"); @@ -10941,8 +10976,8 @@ int wolfSSL_set_compression(WOLFSSL* ssl) /* free any existing WOLFSSL_BIOs in use but don't free those in * a chain */ - if (ssl->biord != NULL) { - if (ssl->biord != ssl->biowr) { + if ((flags & WOLFSSL_BIO_FLAG_READ) && (ssl->biord != NULL)) { + if ((flags & WOLFSSL_BIO_FLAG_WRITE) && (ssl->biord != ssl->biowr)) { if (ssl->biowr != NULL && ssl->biowr->prev != NULL) wolfSSL_BIO_free(ssl->biowr); ssl->biowr = NULL; @@ -10951,20 +10986,32 @@ int wolfSSL_set_compression(WOLFSSL* ssl) wolfSSL_BIO_free(ssl->biord); ssl->biord = NULL; } + else if ((flags & WOLFSSL_BIO_FLAG_WRITE) && (ssl->biowr != NULL)) { + if (ssl->biowr->prev != NULL) + wolfSSL_BIO_free(ssl->biowr); + ssl->biowr = NULL; + } + /* set flag obviously */ if (rd && !(rd->flags & WOLFSSL_BIO_FLAG_READ)) rd->flags |= WOLFSSL_BIO_FLAG_READ; if (wr && !(wr->flags & WOLFSSL_BIO_FLAG_WRITE)) wr->flags |= WOLFSSL_BIO_FLAG_WRITE; - ssl->biord = rd; - ssl->biowr = wr; + if (flags & WOLFSSL_BIO_FLAG_READ) + ssl->biord = rd; + if (flags & WOLFSSL_BIO_FLAG_WRITE) + ssl->biowr = wr; /* set SSL to use BIO callbacks instead */ - if (((ssl->cbioFlag & WOLFSSL_CBIO_RECV) == 0)) { + if ((flags & WOLFSSL_BIO_FLAG_READ) && + (((ssl->cbioFlag & WOLFSSL_CBIO_RECV) == 0))) + { ssl->CBIORecv = BioReceive; } - if (((ssl->cbioFlag & WOLFSSL_CBIO_SEND) == 0)) { + if ((flags & WOLFSSL_BIO_FLAG_WRITE) && + (((ssl->cbioFlag & WOLFSSL_CBIO_SEND) == 0))) + { ssl->CBIOSend = BioSend; } @@ -10978,6 +11025,22 @@ int wolfSSL_set_compression(WOLFSSL* ssl) BIO_set_retry_read(wr); } } + + void wolfSSL_set_bio(WOLFSSL* ssl, WOLFSSL_BIO* rd, WOLFSSL_BIO* wr) + { + ssl_set_bio(ssl, rd, wr, WOLFSSL_BIO_FLAG_READ | WOLFSSL_BIO_FLAG_WRITE); + } + + void wolfSSL_set_rbio(WOLFSSL* ssl, WOLFSSL_BIO* rd) + { + ssl_set_bio(ssl, rd, NULL, WOLFSSL_BIO_FLAG_READ); + } + + void wolfSSL_set_wbio(WOLFSSL* ssl, WOLFSSL_BIO* wr) + { + ssl_set_bio(ssl, NULL, wr, WOLFSSL_BIO_FLAG_WRITE); + } + #endif /* !NO_BIO */ #endif /* OPENSSL_EXTRA */ @@ -14915,17 +14978,13 @@ WOLFSSL_COMP_METHOD* wolfSSL_COMP_zlib(void) WOLFSSL_STUB("COMP_zlib"); return 0; } -#endif -#ifndef NO_WOLFSSL_STUB WOLFSSL_COMP_METHOD* wolfSSL_COMP_rle(void) { WOLFSSL_STUB("COMP_rle"); return 0; } -#endif -#ifndef NO_WOLFSSL_STUB int wolfSSL_COMP_add_compression_method(int method, void* data) { (void)method; @@ -14933,10 +14992,18 @@ int wolfSSL_COMP_add_compression_method(int method, void* data) WOLFSSL_STUB("COMP_add_compression_method"); return 0; } -#endif -#ifndef NO_WOLFSSL_STUB -const char* wolfSSL_COMP_get_name(const void* comp) +const WOLFSSL_COMP_METHOD* wolfSSL_get_current_compression(const WOLFSSL *ssl) { + (void)ssl; + return NULL; +} + +const WOLFSSL_COMP_METHOD* wolfSSL_get_current_expansion(const WOLFSSL *ssl) { + (void)ssl; + return NULL; +} + +const char* wolfSSL_COMP_get_name(const WOLFSSL_COMP_METHOD *comp) { static const char ret[] = "not supported"; @@ -20168,7 +20235,7 @@ VerifyCallback wolfSSL_CTX_get_verify_callback(WOLFSSL_CTX* ctx) } #ifdef HAVE_SNI -/* this is a compatibily function, consider using +/* this is a compatibility function, consider using * wolfSSL_CTX_set_servername_callback */ int wolfSSL_CTX_set_tlsext_servername_callback(WOLFSSL_CTX* ctx, CallbackSniRecv cb) @@ -22663,7 +22730,7 @@ void wolfSSL_ERR_remove_state(unsigned long id) } } -#endif /* OPENSSL_EXTRA */ +#endif /* OPENSSL_EXTRA */ #ifdef OPENSSL_ALL @@ -23240,6 +23307,18 @@ int wolfSSL_CTX_set_ecdh_auto(WOLFSSL_CTX* ctx, int onoff) return WOLFSSL_SUCCESS; } +/* wolfSSL_CTX_set_dh_auto is provided as compatible API with + * SSL_CTX_set_dh_auto to enable auto dh selection functionality. + * Since this functionality is enabled by default in wolfSSL, + * this API exists as a stub. + */ +int wolfSSL_CTX_set_dh_auto(WOLFSSL_CTX* ctx, int onoff) +{ + (void)ctx; + (void)onoff; + return WOLFSSL_SUCCESS; +} + /** * set security level (wolfSSL doesn't support security level) * @param ctx a pointer to WOLFSSL_EVP_PKEY_CTX structure @@ -23273,7 +23352,7 @@ void wolfSSL_CTX_set_keylog_callback(WOLFSSL_CTX* ctx, wolfSSL_CTX_keylog_cb_func cb) { WOLFSSL_ENTER("wolfSSL_CTX_set_keylog_callback"); - /* stores the callback into WOLFSSL_CTX */ + /* stores the callback into WOLFSSL_CTX */ if (ctx != NULL) { ctx->keyLogCb = cb; } @@ -23284,8 +23363,7 @@ wolfSSL_CTX_keylog_cb_func wolfSSL_CTX_get_keylog_callback( WOLFSSL_ENTER("wolfSSL_CTX_get_keylog_callback"); if (ctx != NULL) return ctx->keyLogCb; - else - return NULL; + return NULL; } #endif /* OPENSSL_EXTRA && HAVE_SECRET_CALLBACK */ diff --git a/src/ssl_asn1.c b/src/ssl_asn1.c index b93d8d5b0b..0cae277dc8 100644 --- a/src/ssl_asn1.c +++ b/src/ssl_asn1.c @@ -1,6 +1,6 @@ /* ssl_asn1.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/src/ssl_bn.c b/src/ssl_bn.c index c025755f99..d4ecee4f22 100644 --- a/src/ssl_bn.c +++ b/src/ssl_bn.c @@ -1,6 +1,6 @@ /* ssl_bn.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/src/ssl_certman.c b/src/ssl_certman.c index e666059352..f9d87450ec 100644 --- a/src/ssl_certman.c +++ b/src/ssl_certman.c @@ -1,6 +1,6 @@ /* ssl_certman.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -609,8 +609,7 @@ void wolfSSL_CertManagerSetVerify(WOLFSSL_CERT_MANAGER* cm, VerifyCallback vc) } #endif /* NO_WOLFSSL_CM_VERIFY */ -#if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) \ - && defined(HAVE_OID_DECODING) +#ifdef WC_ASN_UNKNOWN_EXT_CB void wolfSSL_CertManagerSetUnknownExtCallback(WOLFSSL_CERT_MANAGER* cm, wc_UnknownExtCallback cb) { @@ -620,7 +619,7 @@ void wolfSSL_CertManagerSetUnknownExtCallback(WOLFSSL_CERT_MANAGER* cm, } } -#endif /* WOLFSSL_CUSTOM_OID && WOLFSSL_ASN_TEMPLATE && HAVE_OID_DECODING */ +#endif /* WC_ASN_UNKNOWN_EXT_CB */ #if !defined(NO_WOLFSSL_CLIENT) || !defined(WOLFSSL_NO_CLIENT_AUTH) /* Verify the certificate. @@ -690,8 +689,7 @@ int CM_VerifyBuffer_ex(WOLFSSL_CERT_MANAGER* cm, const unsigned char* buff, /* Create a decoded certificate with DER buffer. */ InitDecodedCert(cert, buff, (word32)sz, cm->heap); -#if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) \ - && defined(HAVE_OID_DECODING) +#ifdef WC_ASN_UNKNOWN_EXT_CB if (cm->unknownExtCallback != NULL) wc_SetUnknownExtCallback(cert, cm->unknownExtCallback); #endif diff --git a/src/ssl_crypto.c b/src/ssl_crypto.c index 5a05324c31..296e74a14f 100644 --- a/src/ssl_crypto.c +++ b/src/ssl_crypto.c @@ -1,6 +1,6 @@ /* ssl_crypto.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/src/ssl_load.c b/src/ssl_load.c index 60eb72167d..da4279e39e 100644 --- a/src/ssl_load.c +++ b/src/ssl_load.c @@ -1,6 +1,6 @@ /* ssl_load.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -142,21 +142,10 @@ static int DataToDerBuffer(const unsigned char* buff, word32 len, int format, } /* Data in buffer is ASN.1 format - get first SEQ or OCT into der. */ else { - int length; - word32 inOutIdx = 0; - /* Get length of SEQ including header. */ if ((info->consumed = wolfssl_der_length(buff, (int)len)) > 0) { ret = 0; } - /* Private keys may be wrapped in OCT when PKCS#8 wrapper removed. - * TODO: is this really needed? */ - else if ((type == PRIVATEKEY_TYPE) && - (GetOctetString(buff, &inOutIdx, &length, len) >= 0)) { - /* Include octet string DER header. */ - info->consumed = length + inOutIdx; - ret = 0; - } else { ret = ASN_PARSE_E; } @@ -302,22 +291,11 @@ static int ProcessUserChain(WOLFSSL_CTX* ctx, WOLFSSL* ssl, WOLFSSL_ENTER("ProcessUserChain"); - /* Validate parameters. */ - if ((type == CA_TYPE) && (ctx == NULL)) { - WOLFSSL_MSG("Need context for CA load"); - ret = BAD_FUNC_ARG; - } - - /* Ignore non-certificate types. */ - if ((ret == 0) && (type != CERT_TYPE) && (type != CHAIN_CERT_TYPE) && - (type != CA_TYPE)) { - WOLFSSL_MSG("File type not a certificate"); - } /* Check we haven't consumed all the data. */ - else if ((ret == 0) && (info->consumed >= sz)) { + if (info->consumed >= sz) { WOLFSSL_MSG("Already consumed data"); } - else if (ret == 0) { + else { #ifndef WOLFSSL_SMALL_STACK byte stackBuffer[FILE_BUFFER_SIZE]; #endif @@ -884,17 +862,17 @@ static int ProcessBufferTryDecodeFalcon(WOLFSSL_CTX* ctx, WOLFSSL* ssl, ret = wc_falcon_init(key); if (ret == 0) { /* Set up key to parse the format specified. */ - if (*keyFormat == FALCON_LEVEL1k) { + if ((*keyFormat == FALCON_LEVEL1k) || ((*keyFormat == 0) && + ((der->length == FALCON_LEVEL1_KEY_SIZE) || + (der->length == FALCON_LEVEL1_PRV_KEY_SIZE)))) { ret = wc_falcon_set_level(key, 1); } - else if (*keyFormat == FALCON_LEVEL5k) { + else if ((*keyFormat == FALCON_LEVEL5k) || ((*keyFormat == 0) && + ((der->length == FALCON_LEVEL5_KEY_SIZE) || + (der->length == FALCON_LEVEL5_PRV_KEY_SIZE)))) { ret = wc_falcon_set_level(key, 5); } else { - /* What if *keyformat is 0? We might want to do something more - * graceful here. */ - /* TODO: get the size of the private key for different formats and - * compare with DER length. */ wc_falcon_free(key); ret = ALGO_ID_E; } @@ -935,6 +913,11 @@ static int ProcessBufferTryDecodeFalcon(WOLFSSL_CTX* ctx, WOLFSSL* ssl, /* Free dynamically allocated data in key. */ wc_falcon_free(key); } + else if ((ret == ALGO_ID_E) && (*keyFormat == 0)) { + WOLFSSL_MSG("Not a Falcon key"); + /* Format unknown so keep trying. */ + ret = 0; + } /* Dispose of allocated key. */ XFREE(key, heap, DYNAMIC_TYPE_FALCON); @@ -977,20 +960,22 @@ static int ProcessBufferTryDecodeDilithium(WOLFSSL_CTX* ctx, WOLFSSL* ssl, ret = wc_dilithium_init(key); if (ret == 0) { /* Set up key to parse the format specified. */ - if (*keyFormat == DILITHIUM_LEVEL2k) { + if ((*keyFormat == DILITHIUM_LEVEL2k) || ((*keyFormat == 0) && + ((der->length == DILITHIUM_LEVEL2_KEY_SIZE) || + (der->length == DILITHIUM_LEVEL2_PRV_KEY_SIZE)))) { ret = wc_dilithium_set_level(key, 2); } - else if (*keyFormat == DILITHIUM_LEVEL3k) { + else if ((*keyFormat == DILITHIUM_LEVEL3k) || ((*keyFormat == 0) && + ((der->length == DILITHIUM_LEVEL3_KEY_SIZE) || + (der->length == DILITHIUM_LEVEL3_PRV_KEY_SIZE)))) { ret = wc_dilithium_set_level(key, 3); } - else if (*keyFormat == DILITHIUM_LEVEL5k) { + else if ((*keyFormat == DILITHIUM_LEVEL5k) || ((*keyFormat == 0) && + ((der->length == DILITHIUM_LEVEL5_KEY_SIZE) || + (der->length == DILITHIUM_LEVEL5_PRV_KEY_SIZE)))) { ret = wc_dilithium_set_level(key, 5); } else { - /* What if *keyformat is 0? We might want to do something more - * graceful here. */ - /* TODO: get the size of the private key for different formats and - * compare with DER length. */ wc_dilithium_free(key); ret = ALGO_ID_E; } @@ -1036,6 +1021,11 @@ static int ProcessBufferTryDecodeDilithium(WOLFSSL_CTX* ctx, WOLFSSL* ssl, /* Free dynamically allocated data in key. */ wc_dilithium_free(key); } + else if ((ret == ALGO_ID_E) && (*keyFormat == 0)) { + WOLFSSL_MSG("Not a Dilithium key"); + /* Format unknown so keep trying. */ + ret = 0; + } /* Dispose of allocated key. */ XFREE(key, heap, DYNAMIC_TYPE_DILITHIUM); @@ -1353,24 +1343,10 @@ static int ProcessBufferPrivateKey(WOLFSSL_CTX* ctx, WOLFSSL* ssl, int algId) { int ret; -#if (defined(WOLFSSL_ENCRYPTED_KEYS) && !defined(NO_PWDBASED)) || \ - defined(HAVE_PKCS8) - word32 p8AlgId = 0; -#endif (void)info; (void)format; -#ifdef HAVE_PKCS8 - /* Try and remove PKCS8 header and get algorithm id. */ - ret = ToTraditional_ex(der->buffer, der->length, &p8AlgId); - if (ret > 0) { - /* Header stripped inline. */ - der->length = (word32)ret; - algId = p8AlgId; - } -#endif - /* Put the data into the SSL or SSL context object. */ ret = ProcessBufferPrivKeyHandleDer(ctx, ssl, &der, type); if (ret == 0) { @@ -2880,6 +2856,41 @@ int wolfSSL_CTX_load_verify_locations(WOLFSSL_CTX* ctx, const char* file, return WS_RETURN_CODE(ret, 0); } +/* Load a file and/or files in path, with OpenSSL-compatible semantics. + * + * No c_rehash. + * + * @param [in, out] ctx SSL context object. + * @param [in] file Name of file to load. May be NULL. + * @param [in] path Path to directory containing PEM CA files. + * May be NULL. + * @return 1 on success. + * @return 0 on failure. + */ +int wolfSSL_CTX_load_verify_locations_compat(WOLFSSL_CTX* ctx, const char* file, + const char* path) +{ + /* We want to keep trying to load more CA certs even if one cert in the + * directory is bad and can't be used (e.g. if one is expired), and we + * want to return success if any were successfully loaded (mimicking + * OpenSSL SSL_CTX_load_verify_locations() semantics), so we use + * WOLFSSL_LOAD_FLAG_IGNORE_ERR. OpenSSL (as of v3.3.2) actually + * returns success even if no certs are loaded (e.g. because the + * supplied "path" doesn't exist or access is prohibited), and only + * returns failure if the "file" is non-null and fails to load. + * + * Note that if a file is supplied and can't be successfully loaded, the + * overall call fails and the path is never even evaluated. This is + * consistent with OpenSSL behavior. + */ + + int ret = wolfSSL_CTX_load_verify_locations_ex(ctx, file, path, + WOLFSSL_LOAD_VERIFY_DEFAULT_FLAGS | WOLFSSL_LOAD_FLAG_IGNORE_ERR); + + /* Return 1 on success or 0 on failure. */ + return WS_RETURN_CODE(ret, 0); +} + #ifdef WOLFSSL_SYS_CA_CERTS #ifdef USE_WINDOWS_API @@ -4825,8 +4836,7 @@ int wolfSSL_add0_chain_cert(WOLFSSL* ssl, WOLFSSL_X509* x509) WOLFSSL_ENTER("wolfSSL_add0_chain_cert"); /* Validate parameters. */ - if ((ssl == NULL) || (ssl->ctx == NULL) || (x509 == NULL) || - (x509->derCert == NULL)) { + if ((ssl == NULL) || (x509 == NULL) || (x509->derCert == NULL)) { ret = 0; } @@ -4889,8 +4899,7 @@ int wolfSSL_add1_chain_cert(WOLFSSL* ssl, WOLFSSL_X509* x509) WOLFSSL_ENTER("wolfSSL_add1_chain_cert"); /* Validate parameters. */ - if ((ssl == NULL) || (ssl->ctx == NULL) || (x509 == NULL) || - (x509->derCert == NULL)) { + if ((ssl == NULL) || (x509 == NULL) || (x509->derCert == NULL)) { ret = 0; } @@ -5086,9 +5095,9 @@ int wolfSSL_CTX_set_default_verify_paths(WOLFSSL_CTX* ctx) { int ret; #ifdef XGETENV - char* certDir; - char* certFile; - word32 flags; + char* certDir = NULL; + char* certFile = NULL; + word32 flags = 0; #elif !defined(WOLFSSL_SYS_CA_CERTS) (void)ctx; #endif @@ -5096,8 +5105,8 @@ int wolfSSL_CTX_set_default_verify_paths(WOLFSSL_CTX* ctx) WOLFSSL_ENTER("wolfSSL_CTX_set_default_verify_paths"); #ifdef XGETENV - certDir = XGETENV("SSL_CERT_DIR"); - certFile = XGETENV("SSL_CERT_FILE"); + certDir = wc_strdup_ex(XGETENV("SSL_CERT_DIR"), DYNAMIC_TYPE_TMP_BUFFER); + certFile = wc_strdup_ex(XGETENV("SSL_CERT_FILE"), DYNAMIC_TYPE_TMP_BUFFER); flags = WOLFSSL_LOAD_FLAG_PEM_CA_ONLY; if ((certDir != NULL) || (certFile != NULL)) { @@ -5143,6 +5152,10 @@ int wolfSSL_CTX_set_default_verify_paths(WOLFSSL_CTX* ctx) #endif } +#ifdef XGETENV + XFREE(certFile, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(certDir, NULL, DYNAMIC_TYPE_TMP_BUFFER); +#endif WOLFSSL_LEAVE("wolfSSL_CTX_set_default_verify_paths", ret); return ret; @@ -5258,6 +5271,7 @@ int wolfSSL_SetTmpDH(WOLFSSL* ssl, const unsigned char* p, int pSz, pAlloc = (byte*)XMALLOC(pSz, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); gAlloc = (byte*)XMALLOC(gSz, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); if ((pAlloc == NULL) || (gAlloc == NULL)) { + /* Memory will be freed below in the (ret != 1) block */ ret = MEMORY_E; } } @@ -5416,10 +5430,6 @@ int wolfSSL_CTX_SetTmpDH(WOLFSSL_CTX* ctx, const unsigned char* p, int pSz, pAlloc = (byte*)XMALLOC(pSz, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY); gAlloc = (byte*)XMALLOC(gSz, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY); if ((pAlloc == NULL) || (gAlloc == NULL)) { - XFREE(pAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY); - pAlloc = NULL; - XFREE(gAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY); - gAlloc = NULL; ret = MEMORY_E; } } @@ -5432,12 +5442,10 @@ int wolfSSL_CTX_SetTmpDH(WOLFSSL_CTX* ctx, const unsigned char* p, int pSz, ret = wolfssl_ctx_set_tmp_dh(ctx, pAlloc, pSz, gAlloc, gSz); } - if (ret != 1) { + if ((ret != 1) && (ctx != NULL)) { /* Free the allocated buffers if not assigned into SSL context. */ - if (pAlloc) - XFREE(pAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY); - if (gAlloc) - XFREE(gAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY); + XFREE(pAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY); + XFREE(gAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY); } return ret; } @@ -5470,7 +5478,7 @@ long wolfSSL_set_tmp_dh(WOLFSSL *ssl, WOLFSSL_DH *dh) } if (ret == 1) { - /* Get needed size for p and g. */ + /* Get sizes of p and g. */ pSz = wolfSSL_BN_bn2bin(dh->p, NULL); gSz = wolfSSL_BN_bn2bin(dh->g, NULL); /* Validate p and g size. */ @@ -5501,7 +5509,7 @@ long wolfSSL_set_tmp_dh(WOLFSSL *ssl, WOLFSSL_DH *dh) ret = wolfssl_set_tmp_dh(ssl, p, pSz, g, gSz); } - if (ret != 1 && ssl != NULL) { + if ((ret != 1) && (ssl != NULL)) { /* Free the allocated buffers if not assigned into SSL. */ XFREE(p, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); XFREE(g, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); @@ -5536,7 +5544,7 @@ long wolfSSL_CTX_set_tmp_dh(WOLFSSL_CTX* ctx, WOLFSSL_DH* dh) } if (ret == 1) { - /* Get needed size for p and g. */ + /* Get sizes of p and g. */ pSz = wolfSSL_BN_bn2bin(dh->p, NULL); gSz = wolfSSL_BN_bn2bin(dh->g, NULL); /* Validate p and g size. */ diff --git a/src/ssl_misc.c b/src/ssl_misc.c index d52c2cd4a1..38fa511467 100644 --- a/src/ssl_misc.c +++ b/src/ssl_misc.c @@ -1,6 +1,6 @@ /* ssl_misc.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/src/ssl_sess.c b/src/ssl_sess.c index 43ce1f54a7..90b09b7363 100644 --- a/src/ssl_sess.c +++ b/src/ssl_sess.c @@ -1413,7 +1413,7 @@ int wolfSSL_GetSessionFromCache(WOLFSSL* ssl, WOLFSSL_SESSION* output) output->ticketLen = 0; } if (error == WOLFSSL_SUCCESS) { - XMEMCPY(output->ticket, tmpTicket, output->ticketLen); + XMEMCPY(output->ticket, tmpTicket, output->ticketLen); /* cppcheck-suppress uninitvar */ } } #ifdef WOLFSSL_SMALL_STACK diff --git a/src/tls.c b/src/tls.c index 65292169e0..472c6519f3 100644 --- a/src/tls.c +++ b/src/tls.c @@ -1,6 +1,6 @@ /* tls.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -1056,7 +1056,7 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in, hashBlock[j] = b; } - ret = Hmac_HashUpdate(hmac, hashBlock, (word32)blockSz); + ret = Hmac_HashUpdate(hmac, hashBlock, (word32)blockSz); /* cppcheck-suppress uninitvar */ if (ret != 0) return ret; ret = Hmac_HashFinalRaw(hmac, hashBlock); @@ -6907,14 +6907,14 @@ static int TLSX_CA_Names_Parse(WOLFSSL *ssl, const byte* input, InitDecodedCert(cert, input + idx, extLen, ssl->heap); didInit = TRUE; idx += extLen; - ret = GetName(cert, SUBJECT, extLen); + ret = GetName(cert, ASN_SUBJECT, extLen); } if (ret == 0 && (name = wolfSSL_X509_NAME_new()) == NULL) ret = MEMORY_ERROR; if (ret == 0) { - CopyDecodedName(name, cert, SUBJECT); + CopyDecodedName(name, cert, ASN_SUBJECT); if (wolfSSL_sk_X509_NAME_push(ssl->client_ca_names, name) == WOLFSSL_FAILURE) ret = MEMORY_ERROR; @@ -8705,7 +8705,7 @@ static int TLSX_KeyShare_ProcessPqc(WOLFSSL* ssl, KeyShareEntry* keyShareEntry) (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION != 2))) && \ !defined(HAVE_SELFTEST) if (ret == 0) { - ret = wc_ecc_set_rng(keyShareEntry->key, ssl->rng); + ret = wc_ecc_set_rng((ecc_key *)keyShareEntry->key, ssl->rng); if (ret != 0) { WOLFSSL_MSG("Failure to set the ECC private key RNG."); } @@ -8714,8 +8714,8 @@ static int TLSX_KeyShare_ProcessPqc(WOLFSSL* ssl, KeyShareEntry* keyShareEntry) if (ret == 0) { PRIVATE_KEY_UNLOCK(); - ret = wc_ecc_shared_secret(keyShareEntry->key, &eccpubkey, - sharedSecret, &outlen); + ret = wc_ecc_shared_secret((ecc_key *)keyShareEntry->key, + &eccpubkey, sharedSecret, &outlen); PRIVATE_KEY_LOCK(); if (outlen != sharedSecretLen - ssSz) { WOLFSSL_MSG("ECC shared secret derivation error."); @@ -9193,14 +9193,14 @@ static int server_generate_pqc_ciphertext(WOLFSSL* ssl, (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION != 2))) && \ !defined(HAVE_SELFTEST) if (ret == 0) { - ret = wc_ecc_set_rng(ecc_kse->key, ssl->rng); + ret = wc_ecc_set_rng((ecc_key *)ecc_kse->key, ssl->rng); } #endif if (ret == 0) { outlen = ecc_kse->keyLen; PRIVATE_KEY_UNLOCK(); - ret = wc_ecc_shared_secret(ecc_kse->key, &eccpubkey, + ret = wc_ecc_shared_secret((ecc_key *)ecc_kse->key, &eccpubkey, sharedSecret, &outlen); PRIVATE_KEY_LOCK(); diff --git a/src/tls13.c b/src/tls13.c index ef37c29ab2..aa2ab160de 100644 --- a/src/tls13.c +++ b/src/tls13.c @@ -1,6 +1,6 @@ /* tls13.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -8918,7 +8918,7 @@ static int SendTls13CertificateVerify(WOLFSSL* ssl) if (ssl->buffers.key == NULL) { #ifdef HAVE_PK_CALLBACKS if (wolfSSL_CTX_IsPrivatePkSet(ssl->ctx)) - args->length = (word16)GetPrivateKeySigSize(ssl); + args->sigLen = (word16)GetPrivateKeySigSize(ssl); else #endif ERROR_OUT(NO_PRIVATE_KEY, exit_scv); diff --git a/src/wolfio.c b/src/wolfio.c index 70e0cd8e90..90c4ff271a 100644 --- a/src/wolfio.c +++ b/src/wolfio.c @@ -1,6 +1,6 @@ /* wolfio.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -136,70 +136,65 @@ Possible IO enable options: #if defined(USE_WOLFSSL_IO) || defined(HAVE_HTTP_CLIENT) -/* Translates return codes returned from - * send() and recv() if need be. - */ -static WC_INLINE int TranslateReturnCode(int old, int sd) +static WC_INLINE int wolfSSL_LastError(int err, SOCKET_T sd) { (void)sd; -#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) - if (old == 0) { - errno = SOCKET_EWOULDBLOCK; - return -1; /* convert to BSD style wouldblock as error */ - } - - if (old < 0) { - errno = RTCS_geterror(sd); - if (errno == RTCSERR_TCP_CONN_CLOSING) - return 0; /* convert to BSD style closing */ - if (errno == RTCSERR_TCP_CONN_RLSD) - errno = SOCKET_ECONNRESET; - if (errno == RTCSERR_TCP_TIMED_OUT) - errno = SOCKET_EAGAIN; - } -#elif defined(WOLFSSL_EMNET) - if (old < 0) { /* SOCKET_ERROR */ - /* Get the real socket error */ - IP_SOCK_getsockopt(sd, SOL_SOCKET, SO_ERROR, &old, (int)sizeof(old)); - } -#endif - - return old; -} - -static WC_INLINE int wolfSSL_LastError(int err) -{ - (void)err; /* Suppress unused arg */ + if (err > 0) + return 0; #ifdef USE_WINDOWS_API return WSAGetLastError(); #elif defined(EBSNET) return xn_getlasterror(); #elif defined(WOLFSSL_LINUXKM) || defined(WOLFSSL_EMNET) - return err; /* Return provided error value */ + return -err; /* Return provided error value with corrected sign. */ #elif defined(FUSION_RTOS) #include return FCL_GET_ERRNO; #elif defined(NUCLEUS_PLUS_2_3) return Nucleus_Net_Errno; +#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) + if ((err == 0) || (err == -SOCKET_EWOULDBLOCK)) { + return SOCKET_EWOULDBLOCK; /* convert to BSD style wouldblock */ + } else { + err = RTCS_geterror(sd); + if ((err == RTCSERR_TCP_CONN_CLOSING) || + (err == RTCSERR_TCP_CONN_RLSD)) + { + err = SOCKET_ECONNRESET; + } + return err; + } +#elif defined(WOLFSSL_EMNET) + /* Get the real socket error */ + IP_SOCK_getsockopt(sd, SOL_SOCKET, SO_ERROR, &err, (int)sizeof(old)); + return err; #else return errno; #endif } -static int TranslateIoError(int err) +/* Translates return codes returned from + * send(), recv(), and other network I/O calls. + */ +static int TranslateIoReturnCode(int err, SOCKET_T sd, int direction) { #ifdef _WIN32 size_t errstr_offset; char errstr[WOLFSSL_STRERROR_BUFFER_SIZE]; #endif /* _WIN32 */ - +#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) if (err > 0) return err; +#else + if (err >= 0) + return err; +#endif + + err = wolfSSL_LastError(err, sd); - err = wolfSSL_LastError(err); #if SOCKET_EWOULDBLOCK != SOCKET_EAGAIN if ((err == SOCKET_EWOULDBLOCK) || (err == SOCKET_EAGAIN)) #else @@ -207,8 +202,26 @@ static int TranslateIoError(int err) #endif { WOLFSSL_MSG("\tWould block"); - return WOLFSSL_CBIO_ERR_WANT_READ; + if (direction == SOCKET_SENDING) + return WOLFSSL_CBIO_ERR_WANT_WRITE; + else if (direction == SOCKET_RECEIVING) + return WOLFSSL_CBIO_ERR_WANT_READ; + else + return WOLFSSL_CBIO_ERR_GENERAL; + } + +#ifdef SOCKET_ETIMEDOUT + else if (err == SOCKET_ETIMEDOUT) { + WOLFSSL_MSG("\tTimed out"); + if (direction == SOCKET_SENDING) + return WOLFSSL_CBIO_ERR_WANT_WRITE; + else if (direction == SOCKET_RECEIVING) + return WOLFSSL_CBIO_ERR_WANT_READ; + else + return WOLFSSL_CBIO_ERR_TIMEOUT; } +#endif + else if (err == SOCKET_ECONNRESET) { WOLFSSL_MSG("\tConnection reset"); return WOLFSSL_CBIO_ERR_CONN_RST; @@ -288,7 +301,8 @@ int BioReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx) return WOLFSSL_CBIO_ERR_CONN_CLOSE; } #ifdef USE_WOLFSSL_IO - recvd = TranslateIoError(recvd); + recvd = TranslateIoReturnCode(recvd, ssl->biord->num.fd, + SOCKET_RECEIVING); #endif return recvd; } @@ -333,7 +347,8 @@ int BioSend(WOLFSSL* ssl, char *buf, int sz, void *ctx) if (sent <= 0) { if (ssl->biowr->type == WOLFSSL_BIO_SOCKET) { #ifdef USE_WOLFSSL_IO - sent = TranslateIoError(sent); + sent = TranslateIoReturnCode(sent, ssl->biowr->num.fd, + SOCKET_SENDING); #endif return sent; } @@ -377,7 +392,6 @@ int EmbedReceive(WOLFSSL *ssl, char *buf, int sz, void *ctx) recvd = wolfIO_Recv(sd, buf, sz, ssl->rflags); if (recvd < 0) { WOLFSSL_MSG("Embed Receive error"); - return TranslateIoError(recvd); } else if (recvd == 0) { WOLFSSL_MSG("Embed receive connection closed"); @@ -407,7 +421,6 @@ int EmbedSend(WOLFSSL* ssl, char *buf, int sz, void *ctx) sent = wolfIO_Send(sd, buf, sz, ssl->wflags); if (sent < 0) { WOLFSSL_MSG("Embed Send error"); - return TranslateIoError(sent); } return sent; @@ -746,11 +759,10 @@ int EmbedReceiveFrom(WOLFSSL *ssl, char *buf, int sz, void *ctx) peerSz = (XSOCKLENT)dtlsCtx->peer.bufSz; } - recvd = TranslateReturnCode(recvd, sd); + recvd = TranslateIoReturnCode(recvd, sd, SOCKET_RECEIVING); if (recvd < 0) { WOLFSSL_MSG("Embed Receive From error"); - recvd = TranslateIoError(recvd); if (recvd == WOLFSSL_CBIO_ERR_WANT_READ && !wolfSSL_dtls_get_using_nonblock(ssl)) { recvd = WOLFSSL_CBIO_ERR_TIMEOUT; @@ -835,11 +847,10 @@ int EmbedSendTo(WOLFSSL* ssl, char *buf, int sz, void *ctx) sent = (int)DTLS_SENDTO_FUNCTION(sd, buf, (size_t)sz, ssl->wflags, (const SOCKADDR*)peer, peerSz); - sent = TranslateReturnCode(sent, sd); + sent = TranslateIoReturnCode(sent, sd, SOCKET_SENDING); if (sent < 0) { WOLFSSL_MSG("Embed Send To error"); - return TranslateIoError(sent); } return sent; @@ -861,16 +872,14 @@ int EmbedReceiveFromMcast(WOLFSSL *ssl, char *buf, int sz, void *ctx) recvd = (int)DTLS_RECVFROM_FUNCTION(sd, buf, (size_t)sz, ssl->rflags, NULL, NULL); - recvd = TranslateReturnCode(recvd, sd); + recvd = TranslateIoReturnCode(recvd, sd, SOCKET_RECEIVING); if (recvd < 0) { WOLFSSL_MSG("Embed Receive From error"); - recvd = TranslateIoError(recvd); if (recvd == WOLFSSL_CBIO_ERR_WANT_READ && !wolfSSL_dtls_get_using_nonblock(ssl)) { recvd = WOLFSSL_CBIO_ERR_TIMEOUT; } - return recvd; } return recvd; @@ -1098,7 +1107,7 @@ int wolfIO_Recv(SOCKET_T sd, char *buf, int sz, int rdFlags) int recvd; recvd = (int)RECV_FUNCTION(sd, buf, (size_t)sz, rdFlags); - recvd = TranslateReturnCode(recvd, (int)sd); + recvd = TranslateIoReturnCode(recvd, sd, SOCKET_RECEIVING); return recvd; } @@ -1108,11 +1117,41 @@ int wolfIO_Send(SOCKET_T sd, char *buf, int sz, int wrFlags) int sent; sent = (int)SEND_FUNCTION(sd, buf, (size_t)sz, wrFlags); - sent = TranslateReturnCode(sent, (int)sd); + sent = TranslateIoReturnCode(sent, sd, SOCKET_SENDING); + + return sent; +} + +#if defined(WOLFSSL_HAVE_BIO_ADDR) && defined(WOLFSSL_DTLS) && defined(OPENSSL_EXTRA) + +int wolfIO_RecvFrom(SOCKET_T sd, WOLFSSL_BIO_ADDR *addr, char *buf, int sz, int rdFlags) +{ + int recvd; + socklen_t addr_len = (socklen_t)sizeof(*addr); + + recvd = (int)DTLS_RECVFROM_FUNCTION(sd, buf, (size_t)sz, rdFlags, + addr ? &addr->sa : NULL, + addr ? &addr_len : 0); + recvd = TranslateIoReturnCode(recvd, sd, SOCKET_RECEIVING); + + return recvd; +} + +int wolfIO_SendTo(SOCKET_T sd, WOLFSSL_BIO_ADDR *addr, char *buf, int sz, int wrFlags) +{ + int sent; + socklen_t addr_len = addr ? wolfSSL_BIO_ADDR_size(addr) : 0; + + sent = (int)DTLS_SENDTO_FUNCTION(sd, buf, (size_t)sz, wrFlags, + addr ? &addr->sa : NULL, + addr_len); + sent = TranslateIoReturnCode(sent, sd, SOCKET_SENDING); return sent; } +#endif /* WOLFSSL_HAVE_BIO_ADDR && WOLFSSL_DTLS && OPENSSL_EXTRA */ + #endif /* USE_WOLFSSL_IO */ @@ -1424,7 +1463,8 @@ int wolfIO_TcpConnect(SOCKET_T* sockfd, const char* ip, word16 port, int to_sec) #ifdef HAVE_IO_TIMEOUT if ((ret != 0) && (to_sec > 0)) { #ifdef USE_WINDOWS_API - if ((ret == SOCKET_ERROR) && (wolfSSL_LastError(ret) == WSAEWOULDBLOCK)) + if ((ret == SOCKET_ERROR) && + (wolfSSL_LastError(ret, *sockfd) == SOCKET_EWOULDBLOCK)) #else if (errno == EINPROGRESS) #endif @@ -1735,9 +1775,7 @@ int wolfIO_HttpProcessResponse(int sfd, const char** appStrList, start[len] = 0; } else { - result = TranslateReturnCode(result, sfd); - result = wolfSSL_LastError(result); - if (result == SOCKET_EWOULDBLOCK || result == SOCKET_EAGAIN) { + if (result == WOLFSSL_CBIO_ERR_WANT_READ) { return OCSP_WANT_READ; } diff --git a/src/x509.c b/src/x509.c index 72a4f37ece..cbe3b92421 100644 --- a/src/x509.c +++ b/src/x509.c @@ -1,6 +1,6 @@ /* x509.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -1067,7 +1067,9 @@ WOLFSSL_X509_EXTENSION* wolfSSL_X509_set_ext(WOLFSSL_X509* x509, int loc) case CERT_POLICY_OID: if (!isSet) break; + #ifdef WOLFSSL_SEP ext->crit = x509->certPolicyCrit; + #endif break; case KEY_USAGE_OID: @@ -1424,6 +1426,11 @@ int wolfSSL_X509_add_ext(WOLFSSL_X509 *x509, WOLFSSL_X509_EXTENSION *ext, int lo break; default: #ifdef WOLFSSL_CUSTOM_OID + { + char *oid = NULL; + byte *val = NULL; + int err = 0; + if ((ext->obj == NULL) || (ext->value.length == 0)) { WOLFSSL_MSG("Extension has insufficient information."); return WOLFSSL_FAILURE; @@ -1436,12 +1443,10 @@ int wolfSSL_X509_add_ext(WOLFSSL_X509 *x509, WOLFSSL_X509_EXTENSION *ext, int lo } /* This is a viable custom extension. */ - char *oid = XMALLOC(MAX_OID_STRING_SZ, x509->heap, - DYNAMIC_TYPE_X509_EXT); - byte *val = XMALLOC(ext->value.length, x509->heap, - DYNAMIC_TYPE_X509_EXT); - int err = 0; - + oid = (char*)XMALLOC(MAX_OID_STRING_SZ, x509->heap, + DYNAMIC_TYPE_X509_EXT); + val = (byte*)XMALLOC(ext->value.length, x509->heap, + DYNAMIC_TYPE_X509_EXT); if ((oid == NULL) || (val == NULL)) { WOLFSSL_MSG("Memory allocation failure.\n"); err = 1; @@ -1466,12 +1471,13 @@ int wolfSSL_X509_add_ext(WOLFSSL_X509 *x509, WOLFSSL_X509_EXTENSION *ext, int lo x509->custom_exts[x509->customExtCount].val = val; x509->custom_exts[x509->customExtCount].valSz = ext->value.length; x509->customExtCount++; + break; + } #else WOLFSSL_MSG("Unsupported extension to add"); return WOLFSSL_FAILURE; #endif /* WOLFSSL_CUSTOM_OID */ - break; - } + } /* switch (nid) */ return WOLFSSL_SUCCESS; } @@ -2504,7 +2510,8 @@ void* wolfSSL_X509_get_ext_d2i(const WOLFSSL_X509* x509, int nid, int* c, else { WOLFSSL_MSG("No Cert Policy set"); } - #elif defined(WOLFSSL_SEP) + #endif /* WOLFSSL_CERT_EXT */ + #ifdef WOLFSSL_SEP if (x509->certPolicySet) { if (c != NULL) { *c = x509->certPolicyCrit; @@ -2520,8 +2527,6 @@ void* wolfSSL_X509_get_ext_d2i(const WOLFSSL_X509* x509, int nid, int* c, else { WOLFSSL_MSG("No Cert Policy set"); } - #else - WOLFSSL_MSG("wolfSSL not built with WOLFSSL_SEP or WOLFSSL_CERT_EXT"); #endif break; } @@ -3550,7 +3555,7 @@ char* wolfSSL_X509_get_name_oneline(WOLFSSL_X509_NAME* name, char* in, int sz) } } - XMEMCPY(in, tmpBuf, totalLen); + XMEMCPY(in, tmpBuf, totalLen); /* cppcheck-suppress uninitvar */ in[totalLen] = '\0'; return in; @@ -3711,7 +3716,7 @@ char* wolfSSL_X509_get_next_altname(WOLFSSL_X509* cert) } ret = cert->altNamesNext->name; -#if defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME) +#ifdef WOLFSSL_IP_ALT_NAME /* return the IP address as a string */ if (cert->altNamesNext->type == ASN_IP_TYPE) { ret = cert->altNamesNext->ipString; @@ -5668,9 +5673,9 @@ int wolfSSL_X509_cmp(const WOLFSSL_X509 *a, const WOLFSSL_X509 *b) case NID_key_usage: crit = x509->keyUsageCrit; break; case NID_crl_distribution_points: crit= x509->CRLdistCrit; break; case NID_ext_key_usage: crit= x509->extKeyUsageCrit; break; - #if defined(WOLFSSL_SEP) || defined(WOLFSSL_QT) - case NID_certificate_policies: crit = x509->certPolicyCrit; break; - #endif /* WOLFSSL_SEP || WOLFSSL_QT */ + #ifdef WOLFSSL_SEP + case NID_certificate_policies: crit = x509->certPolicyCrit; break; + #endif /* WOLFSSL_SEP */ } } @@ -5873,7 +5878,7 @@ static int X509PrintSubjAltName(WOLFSSL_BIO* bio, WOLFSSL_X509* x509, break; } } - #if defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME) + #ifdef WOLFSSL_IP_ALT_NAME else if (entry->type == ASN_IP_TYPE) { len = XSNPRINTF(scratch, MAX_WIDTH, "IP Address:%s", entry->ipString); @@ -7040,7 +7045,6 @@ int wolfSSL_X509_signature_print(WOLFSSL_BIO *bp, for (i = 0; i < length; ++i) { char hex_digits[4]; -#ifdef XSNPRINTF if (XSNPRINTF(hex_digits, sizeof(hex_digits), "%c%02X", i>0 ? ':' : ' ', (unsigned int)sigalg->algorithm->obj[idx+i]) >= (int)sizeof(hex_digits)) @@ -7048,10 +7052,6 @@ int wolfSSL_X509_signature_print(WOLFSSL_BIO *bp, WOLFSSL_MSG("buffer overrun"); return WOLFSSL_FAILURE; } -#else - XSPRINTF(hex_digits, "%c%02X", i>0 ? ':' : ' ', - (unsigned int)sigalg->algorithm->obj[idx+i]); -#endif if (wolfSSL_BIO_puts(bp, hex_digits) <= 0) return WOLFSSL_FAILURE; } @@ -7526,20 +7526,12 @@ int wolfSSL_i2d_X509(WOLFSSL_X509* x509, unsigned char** out) int wc_GeneratePreTBS(DecodedCert* cert, byte *der, int derSz) { int ret = 0; WOLFSSL_X509 *x = NULL; - byte certOwnsAltNames = 0; byte certIsCSR = 0; if ((cert == NULL) || (der == NULL) || (derSz <= 0)) { return BAD_FUNC_ARG; } - /* The call to CopyDecodedToX509() transfers ownership of the altNames in - * the DecodedCert to the temporary X509 object, causing the list to be - * freed in wolfSSL_X509_free(). As this is an unintended side-effect, we - * have to save the ownerFlag here and transfer ownership back to the - * DecodedCert prior to freeing the X509 object. */ - certOwnsAltNames = cert->weOwnAltNames; - #ifdef WOLFSSL_CERT_REQ certIsCSR = cert->isCSR; #endif @@ -7552,9 +7544,6 @@ int wc_GeneratePreTBS(DecodedCert* cert, byte *der, int derSz) { ret = CopyDecodedToX509(x, cert); } - /* CopyDecodedToX509() clears cert->weOwnAltNames. Restore it. */ - cert->weOwnAltNames = certOwnsAltNames; - if (ret == 0) { /* Remove the altsigval extension. */ XFREE(x->altSigValDer, x->heap, DYNAMIC_TYPE_X509_EXT); @@ -7570,9 +7559,6 @@ int wc_GeneratePreTBS(DecodedCert* cert, byte *der, int derSz) { } if (x != NULL) { - /* Safe the altNames list from being freed unitentionally. */ - x->altNames = NULL; - wolfSSL_X509_free(x); } @@ -8769,6 +8755,41 @@ int wolfSSL_X509_VERIFY_PARAM_clear_flags(WOLFSSL_X509_VERIFY_PARAM *param, return ret; } +/* note WOLFSSL_X509_VERIFY_PARAM does not record purpose, trust, depth, or + * auth_level. + */ +static const WOLFSSL_X509_VERIFY_PARAM x509_verify_param_builtins[] = { + { + "ssl_client", /* name */ + 0, /* check_time */ + 0, /* inherit_flags */ + 0, /* flags */ + "", /* hostname */ + 0, /* hostFlags */ + "" /* ipasc */ + }, + { + "ssl_server", /* name */ + 0, /* check_time */ + 0, /* inherit_flags */ + 0, /* flags */ + "", /* hostname */ + 0, /* hostFlags */ + "" /* ipasc */ + } +}; + +const WOLFSSL_X509_VERIFY_PARAM *wolfSSL_X509_VERIFY_PARAM_lookup(const char *name) +{ + const WOLFSSL_X509_VERIFY_PARAM *param = &x509_verify_param_builtins[0], + *param_end = &x509_verify_param_builtins[XELEM_CNT(x509_verify_param_builtins)]; + while (param < param_end) { + if (XSTRCMP(name, param->name) == 0) + return param; + ++param; + } + return NULL; +} /* inherits properties of param "to" to param "from" * @@ -8779,7 +8800,7 @@ int wolfSSL_X509_VERIFY_PARAM_clear_flags(WOLFSSL_X509_VERIFY_PARAM *param, * WOLFSSL_VPARAM_LOCKED don't copy any values * WOLFSSL_VPARAM_ONCE the current inherit_flags is zerroed */ -static int wolfSSL_X509_VERIFY_PARAM_inherit(WOLFSSL_X509_VERIFY_PARAM *to, +int wolfSSL_X509_VERIFY_PARAM_inherit(WOLFSSL_X509_VERIFY_PARAM *to, const WOLFSSL_X509_VERIFY_PARAM *from) { int ret = WOLFSSL_FAILURE; @@ -8970,14 +8991,13 @@ int wolfSSL_X509_VERIFY_PARAM_set1_ip(WOLFSSL_X509_VERIFY_PARAM* param, if (iplen == 4) { /* ipv4 www.xxx.yyy.zzz max 15 length + Null termination */ buf = (char*)XMALLOC(16, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (!buf) { WOLFSSL_MSG("failed malloc"); return ret; } - XSPRINTF(buf, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); - buf[15] = '\0'; + (void)XSNPRINTF(buf, 16, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); + buf[15] = '\0'; /* null terminate */ } else if (iplen == 16) { /* ipv6 normal address scheme @@ -9006,47 +9026,46 @@ int wolfSSL_X509_VERIFY_PARAM_set1_ip(WOLFSSL_X509_VERIFY_PARAM* param, * to re-construct IP address in ascii. */ buf = (char*)XMALLOC(max_ipv6_len, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (!buf) { WOLFSSL_MSG("failed malloc"); return ret; } p = buf; for (i = 0; i < 16; i += 2) { - val = (((word32)(ip[i]<<8)) | (ip[i+1])) & 0xFFFF; - if (val == 0){ - if (!write_zero) { + val = (((word32)(ip[i]<<8)) | (ip[i+1])) & 0xFFFF; + if (val == 0){ + if (!write_zero) { *p = ':'; - } - p++; - *p = '\0'; - write_zero = 1; - } - else { - if (i != 0) - *p++ = ':'; - XSPRINTF(p, "%x", val); - } - /* sanity check */ - if (XSTRLEN(buf) > max_ipv6_len) { - WOLFSSL_MSG("The target ip address exceeds buffer length(40)"); - XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - buf = NULL; - break; - } - /* move the pointer to the last */ - /* XSTRLEN includes NULL because of XSPRINTF use */ - p = buf + (XSTRLEN(buf)); + } + p++; + *p = '\0'; + write_zero = 1; + } + else { + if (i != 0) { + *p++ = ':'; + } + (void)XSNPRINTF(p, max_ipv6_len - (size_t)(p - buf), "%x", val); + } + /* sanity check */ + if (XSTRLEN(buf) > max_ipv6_len) { + WOLFSSL_MSG("The target ip address exceeds buffer length(40)"); + XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); + buf = NULL; + break; + } + /* move the pointer to the last */ + /* XSTRLEN includes NULL because of XSPRINTF use */ + p = buf + (XSTRLEN(buf)); } /* termination */ - if(i == 16 && buf) { + if (i == 16 && buf) { p--; if ((*p) == ':') { - /* when the last character is :, the following segments are zero - * Therefore, adding : and null termination - */ - p++; - *p++ = ':'; + /* when the last character is :, the following segments are zero + * Therefore, adding : and null termination */ + p++; + *p++ = ':'; *p = '\0'; } } @@ -9057,7 +9076,7 @@ int wolfSSL_X509_VERIFY_PARAM_set1_ip(WOLFSSL_X509_VERIFY_PARAM* param, } if (buf) { - /* set address to ip asc */ + /* set address to ip asc */ ret = wolfSSL_X509_VERIFY_PARAM_set1_ip_asc(param, buf); XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); } @@ -9557,6 +9576,17 @@ int wolfSSL_X509_PUBKEY_set(WOLFSSL_X509_PUBKEY **x, WOLFSSL_EVP_PKEY *key) #endif /* OPENSSL_ALL || WOLFSSL_APACHE_HTTPD || WOLFSSL_HAPROXY || WOLFSSL_WPAS */ +#if !defined(NO_CERTS) && !defined(NO_ASN) && !defined(NO_PWDBASED) + +int wolfSSL_i2d_X509_PUBKEY(WOLFSSL_X509_PUBKEY* x509_PubKey, unsigned char** der) +{ + if (x509_PubKey == NULL) + return WOLFSSL_FATAL_ERROR; + return wolfSSL_i2d_PublicKey(x509_PubKey->pkey, der); +} + +#endif /* !NO_CERTS && !NO_ASN && !NO_PWDBASED */ + #endif /* OPENSSL_EXTRA */ #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL) @@ -11113,7 +11143,7 @@ int wolfSSL_i2d_X509_NAME(WOLFSSL_X509_NAME* name, unsigned char** out) InitDecodedCert(cert, *in, (word32)length, NULL); /* Parse the X509 subject name */ - if (GetName(cert, SUBJECT, (int)length) != 0) { + if (GetName(cert, ASN_SUBJECT, (int)length) != 0) { WOLFSSL_MSG("WOLFSSL_X509_NAME parse error"); goto cleanup; } @@ -13384,11 +13414,15 @@ int wolfSSL_X509_check_host(WOLFSSL_X509 *x, const char *chk, size_t chklen, return WOLFSSL_FAILURE; } - if (flags == WOLFSSL_NO_WILDCARDS) { + if (flags & WOLFSSL_NO_WILDCARDS) { WOLFSSL_MSG("X509_CHECK_FLAG_NO_WILDCARDS not yet implemented"); return WOLFSSL_FAILURE; } - if (flags == WOLFSSL_NO_PARTIAL_WILDCARDS) { + if (flags & WOLFSSL_NO_PARTIAL_WILDCARDS) { + WOLFSSL_MSG("X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS not yet implemented"); + return WOLFSSL_FAILURE; + } + if (flags & WOLFSSL_MULTI_LABEL_WILDCARDS) { WOLFSSL_MSG("X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS not yet implemented"); return WOLFSSL_FAILURE; } @@ -14467,11 +14501,12 @@ int wolfSSL_X509_REQ_add1_attr_by_NID(WOLFSSL_X509 *req, req->reqAttributes->type = STACK_TYPE_X509_REQ_ATTR; } } - ret = wolfSSL_sk_push(req->reqAttributes, attr); - if ((ret != WOLFSSL_SUCCESS) || (req->reqAttributes->type == STACK_TYPE_CIPHER)) { - /* CIPHER type makes a copy */ + if (req->reqAttributes->type == STACK_TYPE_X509_REQ_ATTR) + ret = wolfSSL_sk_push(req->reqAttributes, attr); + else + ret = WOLFSSL_FAILURE; + if (ret != WOLFSSL_SUCCESS) wolfSSL_X509_ATTRIBUTE_free(attr); - } } return ret; diff --git a/src/x509_str.c b/src/x509_str.c index f5c5c2ae1d..bfdaf413dc 100644 --- a/src/x509_str.c +++ b/src/x509_str.c @@ -1,6 +1,6 @@ /* x509_str.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -281,11 +281,11 @@ int wolfSSL_X509_verify_cert(WOLFSSL_X509_STORE_CTX* ctx) byte *beforeDate = ctx->current_cert->notBefore.data; if (XVALIDATE_DATE(afterDate, - (byte)ctx->current_cert->notAfter.type, AFTER) < 1) { + (byte)ctx->current_cert->notAfter.type, ASN_AFTER) < 1) { ret = ASN_AFTER_DATE_E; } else if (XVALIDATE_DATE(beforeDate, - (byte)ctx->current_cert->notBefore.type, BEFORE) < 1) { + (byte)ctx->current_cert->notBefore.type, ASN_BEFORE) < 1) { ret = ASN_BEFORE_DATE_E; } SetupStoreCtxError(ctx, ret); diff --git a/sslSniffer/sslSnifferTest/snifftest.c b/sslSniffer/sslSnifferTest/snifftest.c index 64053ec9e4..d39020a08e 100644 --- a/sslSniffer/sslSnifferTest/snifftest.c +++ b/sslSniffer/sslSnifferTest/snifftest.c @@ -1,6 +1,6 @@ /* snifftest.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/tests/api.c b/tests/api.c index eafa8bbcc1..e59c8c2bed 100644 --- a/tests/api.c +++ b/tests/api.c @@ -1,6 +1,6 @@ /* api.c API unit tests * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -36,107 +36,17 @@ #include #undef TEST_OPENSSL_COEXIST /* can't use this option with this example */ -#ifndef FOURK_BUF - #define FOURK_BUF 4096 -#endif -#ifndef TWOK_BUF - #define TWOK_BUF 2048 -#endif -#ifndef ONEK_BUF - #define ONEK_BUF 1024 -#endif +#include +#include + #if defined(WOLFSSL_STATIC_MEMORY) #include - -#if defined(WOLFSSL_STATIC_MEMORY) && !defined(WOLFCRYPT_ONLY) - #if (defined(HAVE_ECC) && !defined(ALT_ECC_SIZE)) || \ - defined(SESSION_CERTS) - #ifdef OPENSSL_EXTRA - #define TEST_TLS_STATIC_MEMSZ (400000) - #else - #define TEST_TLS_STATIC_MEMSZ (320000) - #endif - #else - #define TEST_TLS_STATIC_MEMSZ (80000) - #endif #endif - -#endif /* WOLFSSL_STATIC_MEMORY */ -#ifndef HEAP_HINT - #define HEAP_HINT NULL -#endif /* WOLFSSL_STAIC_MEMORY */ #ifdef WOLFSSL_ASNC_CRYPT #include #endif #ifdef HAVE_ECC #include /* wc_ecc_fp_free */ - #ifndef ECC_ASN963_MAX_BUF_SZ - #define ECC_ASN963_MAX_BUF_SZ 133 - #endif - #ifndef ECC_PRIV_KEY_BUF - #define ECC_PRIV_KEY_BUF 66 /* For non user defined curves. */ - #endif - /* ecc key sizes: 14, 16, 20, 24, 28, 30, 32, 40, 48, 64 */ - /* logic to choose right key ECC size */ - #if (defined(HAVE_ECC112) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 112 - #define KEY14 14 - #else - #define KEY14 32 - #endif - #if (defined(HAVE_ECC128) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 128 - #define KEY16 16 - #else - #define KEY16 32 - #endif - #if (defined(HAVE_ECC160) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 160 - #define KEY20 20 - #else - #define KEY20 32 - #endif - #if (defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 192 - #define KEY24 24 - #else - #define KEY24 32 - #endif - #if defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES) - #define KEY28 28 - #else - #define KEY28 32 - #endif - #if defined(HAVE_ECC239) || defined(HAVE_ALL_CURVES) - #define KEY30 30 - #else - #define KEY30 32 - #endif - #define KEY32 32 - #if defined(HAVE_ECC320) || defined(HAVE_ALL_CURVES) - #define KEY40 40 - #else - #define KEY40 32 - #endif - #if defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES) - #define KEY48 48 - #else - #define KEY48 32 - #endif - #if defined(HAVE_ECC512) || defined(HAVE_ALL_CURVES) - #define KEY64 64 - #else - #define KEY64 32 - #endif - - #if !defined(HAVE_COMP_KEY) - #if !defined(NOCOMP) - #define NOCOMP 0 - #endif - #else - #if !defined(COMP) - #define COMP 1 - #endif - #endif - #if !defined(DER_SZ) - #define DER_SZ(ks) ((ks) * 2 + 1) - #endif #ifdef WOLFSSL_SM2 #include #endif @@ -144,14 +54,17 @@ #ifndef NO_ASN #include #endif -#include #include #include /* compatibility layer */ +#include + #include #include +#include + +/* for testing compatibility layer callbacks */ #include "examples/server/server.h" - /* for testing compatibility layer callbacks */ #ifndef NO_MD5 #include @@ -168,18 +81,12 @@ #ifdef WOLFSSL_SHA384 #include #endif - #ifdef WOLFSSL_SHA3 #include - #ifndef HEAP_HINT - #define HEAP_HINT NULL - #endif #endif - #ifdef WOLFSSL_SM3 #include #endif - #ifndef NO_AES #include #ifdef HAVE_AES_DECRYPT @@ -228,19 +135,14 @@ #include #endif -#include #ifndef NO_RSA #include - - #define FOURK_BUF 4096 - #define GEN_BUF 294 #endif #ifndef NO_SIG_WRAPPER #include #endif - #ifdef HAVE_AESCCM #include #endif @@ -249,7 +151,7 @@ #include #include #ifdef HAVE_LIBZ - #include + #include #endif #endif @@ -259,21 +161,6 @@ #ifndef NO_DSA #include - #ifndef ONEK_BUF - #define ONEK_BUF 1024 - #endif - #ifndef TWOK_BUF - #define TWOK_BUF 2048 - #endif - #ifndef FOURK_BUF - #define FOURK_BUF 4096 - #endif - #ifndef DSA_SIG_SIZE - #define DSA_SIG_SIZE 40 - #endif - #ifndef MAX_DSA_PARAM_SIZE - #define MAX_DSA_PARAM_SIZE 256 - #endif #endif #ifdef WOLFSSL_CMAC @@ -307,9 +194,8 @@ #include #endif -#include - -#if (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) || defined(OPENSSL_ALL)) +#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) || \ + defined(OPENSSL_ALL) #include #ifndef NO_ASN /* for ASN_COMMON_NAME DN_tags enum */ @@ -372,8 +258,8 @@ #endif #endif /* OPENSSL_EXTRA */ -#if defined(OPENSSL_EXTRA) && defined(WOLFCRYPT_HAVE_SRP) \ - && !defined(NO_SHA256) && !defined(RC_NO_RNG) +#if defined(OPENSSL_EXTRA) && defined(WOLFCRYPT_HAVE_SRP) && \ + !defined(NO_SHA256) && !defined(RC_NO_RNG) #include #endif @@ -386,7 +272,7 @@ /* for testing SSL_get_peer_cert_chain, or SESSION_TICKET_HINT_DEFAULT, * for setting authKeyIdSrc in WOLFSSL_X509, or testing DTLS sequence * number tracking */ -#include "wolfssl/internal.h" + #include "wolfssl/internal.h" #endif /* force enable test buffers */ @@ -398,8 +284,6 @@ #endif #include -#include "tests/utils.h" - /* include misc.c here regardless of NO_INLINE, because misc.c implementations * have default (hidden) visibility, and in the absence of visibility, it's * benign to mask out the library implementation. @@ -407,12 +291,144 @@ #define WOLFSSL_MISC_INCLUDED #include + + +#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ + !defined(NO_RSA) && !defined(SINGLE_THREADED) && \ + !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) + #define HAVE_IO_TESTS_DEPENDENCIES +#endif + +#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) && \ + !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) && \ + !defined(WOLFSSL_TIRTOS) + #define HAVE_SSL_MEMIO_TESTS_DEPENDENCIES +#endif + +#if !defined(NO_RSA) && !defined(NO_SHA) && !defined(NO_FILESYSTEM) && \ + !defined(NO_CERTS) && (!defined(NO_WOLFSSL_CLIENT) || \ + !defined(WOLFSSL_NO_CLIENT_AUTH)) + #define HAVE_CERT_CHAIN_VALIDATION +#endif + #ifndef WOLFSSL_HAVE_ECC_KEY_GET_PRIV /* FIPS build has replaced ecc.h. */ #define wc_ecc_key_get_priv(key) (&((key)->k)) #define WOLFSSL_HAVE_ECC_KEY_GET_PRIV #endif +#if defined(WOLFSSL_STATIC_MEMORY) && !defined(WOLFCRYPT_ONLY) + #if (defined(HAVE_ECC) && !defined(ALT_ECC_SIZE)) || defined(SESSION_CERTS) + #ifdef OPENSSL_EXTRA + #define TEST_TLS_STATIC_MEMSZ (400000) + #else + #define TEST_TLS_STATIC_MEMSZ (320000) + #endif + #else + #define TEST_TLS_STATIC_MEMSZ (80000) + #endif +#endif + +#ifdef HAVE_ECC + #ifndef ECC_ASN963_MAX_BUF_SZ + #define ECC_ASN963_MAX_BUF_SZ 133 + #endif + #ifndef ECC_PRIV_KEY_BUF + #define ECC_PRIV_KEY_BUF 66 /* For non user defined curves. */ + #endif + /* ecc key sizes: 14, 16, 20, 24, 28, 30, 32, 40, 48, 64 */ + /* logic to choose right key ECC size */ + #if (defined(HAVE_ECC112) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 112 + #define KEY14 14 + #else + #define KEY14 32 + #endif + #if (defined(HAVE_ECC128) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 128 + #define KEY16 16 + #else + #define KEY16 32 + #endif + #if (defined(HAVE_ECC160) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 160 + #define KEY20 20 + #else + #define KEY20 32 + #endif + #if (defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 192 + #define KEY24 24 + #else + #define KEY24 32 + #endif + #if defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES) + #define KEY28 28 + #else + #define KEY28 32 + #endif + #if defined(HAVE_ECC239) || defined(HAVE_ALL_CURVES) + #define KEY30 30 + #else + #define KEY30 32 + #endif + #define KEY32 32 + #if defined(HAVE_ECC320) || defined(HAVE_ALL_CURVES) + #define KEY40 40 + #else + #define KEY40 32 + #endif + #if defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES) + #define KEY48 48 + #else + #define KEY48 32 + #endif + #if defined(HAVE_ECC512) || defined(HAVE_ALL_CURVES) + #define KEY64 64 + #else + #define KEY64 32 + #endif + + #if !defined(HAVE_COMP_KEY) + #if !defined(NOCOMP) + #define NOCOMP 0 + #endif + #else + #if !defined(COMP) + #define COMP 1 + #endif + #endif + #if !defined(DER_SZ) + #define DER_SZ(ks) ((ks) * 2 + 1) + #endif +#endif /* HAVE_ECC */ + +#ifndef NO_DSA + #ifndef DSA_SIG_SIZE + #define DSA_SIG_SIZE 40 + #endif + #ifndef MAX_DSA_PARAM_SIZE + #define MAX_DSA_PARAM_SIZE 256 + #endif +#endif + +#ifndef NO_RSA + #define GEN_BUF 294 +#endif + +#ifndef ONEK_BUF + #define ONEK_BUF 1024 +#endif +#ifndef TWOK_BUF + #define TWOK_BUF 2048 +#endif +#ifndef FOURK_BUF + #define FOURK_BUF 4096 +#endif + +#ifndef HEAP_HINT + #define HEAP_HINT NULL +#endif + + + + typedef struct testVector { const char* input; const char* output; @@ -580,17 +596,6 @@ static int testDevId = WOLFSSL_CAAM_DEVID; static int testDevId = INVALID_DEVID; #endif -#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ - !defined(NO_RSA) && !defined(SINGLE_THREADED) && \ - !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) -#define HAVE_IO_TESTS_DEPENDENCIES -#endif - -#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) && \ - !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) && \ - !defined(WOLFSSL_TIRTOS) -#define HAVE_SSL_MEMIO_TESTS_DEPENDENCIES -#endif /*----------------------------------------------------------------------------* | BIO with fixed read/write size @@ -601,14 +606,14 @@ static int testDevId = INVALID_DEVID; static int wolfssl_bio_s_fixed_mem_write(WOLFSSL_BIO* bio, const char* data, int len) { - if ((bio == NULL) || (bio->ptr == NULL) || (data == NULL)) { + if ((bio == NULL) || (bio->ptr.mem_buf_data == NULL) || (data == NULL)) { len = 0; } else { if (bio->wrSz - bio->wrIdx < len) { len = bio->wrSz - bio->wrIdx; } - XMEMCPY((char*)bio->ptr + bio->wrIdx, data, len); + XMEMCPY(bio->ptr.mem_buf_data + bio->wrIdx, data, len); bio->wrIdx += len; } @@ -617,14 +622,14 @@ static int wolfssl_bio_s_fixed_mem_write(WOLFSSL_BIO* bio, const char* data, static int wolfssl_bio_s_fixed_mem_read(WOLFSSL_BIO* bio, char* data, int len) { - if ((bio == NULL) || (bio->ptr == NULL) || (data == NULL)) { + if ((bio == NULL) || (bio->ptr.mem_buf_data == NULL) || (data == NULL)) { len = 0; } else { if (bio->wrSz - bio->rdIdx < len) { len = bio->wrSz - bio->rdIdx; } - XMEMCPY(data, (char*)bio->ptr + bio->rdIdx, len); + XMEMCPY(data, bio->ptr.mem_buf_data + bio->rdIdx, len); bio->rdIdx += len; } @@ -1179,8 +1184,6 @@ static int do_dual_alg_server_certgen(byte **out, char *caKeyFile, newCert.sigType = CTC_SHA256wRSA; newCert.isCA = 0; ExpectIntEQ(wc_SetIssuerBuffer(&newCert, caCertBuf, caCertSz), 0); - ExpectIntEQ(wc_SetCustomExtension(&newCert, 0, "1.2.3.4.5", - (const byte *)"This is NOT a critical extension", 32), 0); ExpectIntEQ(wc_SetCustomExtension(&newCert, 0, "2.5.29.72", sapkiBuf, sapkiSz), 0); ExpectIntEQ(wc_SetCustomExtension(&newCert, 0, "2.5.29.73", altSigAlgBuf, @@ -1246,21 +1249,6 @@ static int do_dual_alg_tls13_connection(byte *caCert, word32 caCertSz, return EXPECT_RESULT(); } -static int extCount = 0; -static int myUnknownExtCallback(const word16* oid, word32 oidSz, int crit, - const unsigned char* der, word32 derSz) -{ - (void) oid; - (void) oidSz; - (void) crit; - (void) der; - (void) derSz; - extCount ++; - /* Accept all extensions. This is only a test. Normally we would be much more - * careful about critical extensions. */ - return 1; -} - static int test_dual_alg_support(void) { EXPECT_DECLS; @@ -1276,7 +1264,6 @@ static int test_dual_alg_support(void) int rootSz = 0; byte *server = NULL; int serverSz = 0; - WOLFSSL_CERT_MANAGER* cm = NULL; ExpectIntEQ(load_file(keyFile, &serverKey, &serverKeySz), 0); @@ -1305,7 +1292,7 @@ static int test_dual_alg_support(void) * the alternative signature and then set negative_test to true for the * call to do_dual_alg_tls13_connection(). Its expecting a failed connection * because the signature won't verify. The exception is if - * WOLFSSL_TRUST_PEER_CERT is defined. In that case, no verfication happens + * WOLFSSL_TRUST_PEER_CERT is defined. In that case, no verification happens * and this is no longer a negative test. */ if (EXPECT_SUCCESS()) { rootSz = do_dual_alg_root_certgen(&root, keyFile, sapkiFile, @@ -1329,19 +1316,6 @@ static int test_dual_alg_support(void) TEST_SUCCESS); #endif - /* Lets see if CertManager can find the new extensions */ - extCount = 0; - ExpectNotNull(cm = wolfSSL_CertManagerNew()); - wolfSSL_CertManagerSetUnknownExtCallback(cm, myUnknownExtCallback); - ExpectIntEQ(wolfSSL_CertManagerLoadCABuffer(cm, root, rootSz, - SSL_FILETYPE_ASN1), WOLFSSL_SUCCESS); - ExpectIntEQ(wolfSSL_CertManagerVerifyBuffer(cm, server, serverSz, - SSL_FILETYPE_ASN1), WOLFSSL_SUCCESS); - /* There is only 1 unknown extension (1.2.3.4.5). The other ones are known - * because they are for the dual alg extensions. */ - ExpectIntEQ(extCount, 1); - wolfSSL_CertManagerFree(cm); - XFREE(root, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(server, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -1731,6 +1705,39 @@ static int test_wolfSSL_CTX_set_cipher_list_bytes(void) } +static int test_wolfSSL_CTX_use_certificate(void) +{ + EXPECT_DECLS; +#if defined(OPENSSL_EXTRA) || defined(HAVE_LIGHTY) || \ + defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(HAVE_STUNNEL) || \ + defined(WOLFSSL_NGINX) || defined(HAVE_POCO_LIB) || \ + defined(WOLFSSL_HAPROXY) +#if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) + WOLFSSL_CTX* ctx = NULL; + X509* x509 = NULL; + +#ifndef NO_WOLFSSL_SERVER + ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); +#else + ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method())); +#endif + + ExpectNotNull(x509 = wolfSSL_X509_new()); + + /* Negative tests. */ + ExpectIntEQ(SSL_CTX_use_certificate(NULL, NULL), 0); + ExpectIntEQ(SSL_CTX_use_certificate(ctx, NULL), 0); + ExpectIntEQ(SSL_CTX_use_certificate(NULL, x509), 0); + /* Empty certificate */ + ExpectIntEQ(SSL_CTX_use_certificate(ctx, x509), 0); + + wolfSSL_X509_free(x509); + wolfSSL_CTX_free(ctx); +#endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ +#endif + return EXPECT_RESULT(); +} + static int test_wolfSSL_CTX_use_certificate_file(void) { EXPECT_DECLS; @@ -1773,6 +1780,16 @@ static int test_wolfSSL_CTX_use_certificate_ASN1(void) ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); + /* Failure cases. */ + ExpectIntEQ(SSL_CTX_use_certificate_ASN1(NULL, 0, NULL ), + WOLFSSL_FAILURE); + ExpectIntEQ(SSL_CTX_use_certificate_ASN1(ctx , 0, NULL ), + WOLFSSL_FAILURE); + ExpectIntEQ(SSL_CTX_use_certificate_ASN1(NULL, 0, server_cert_der_2048), + WOLFSSL_FAILURE); + ExpectIntEQ(SSL_CTX_use_certificate_ASN1(ctx , 0, server_cert_der_2048), + WOLFSSL_FAILURE); + ExpectIntEQ(SSL_CTX_use_certificate_ASN1(ctx, sizeof_server_cert_der_2048, server_cert_der_2048), WOLFSSL_SUCCESS); @@ -1793,11 +1810,20 @@ static int test_wolfSSL_CTX_use_certificate_buffer(void) #if !defined(NO_CERTS) && defined(USE_CERT_BUFFERS_2048) && \ !defined(NO_RSA) && !defined(NO_WOLFSSL_SERVER) WOLFSSL_CTX* ctx = NULL; - int ret; ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); - ExpectIntEQ(ret = wolfSSL_CTX_use_certificate_buffer(ctx, + /* Invalid parameters. */ + ExpectIntEQ(wolfSSL_CTX_use_certificate_buffer(NULL, NULL, 0, + WOLFSSL_FILETYPE_ASN1), BAD_FUNC_ARG); + ExpectIntEQ(wolfSSL_CTX_use_certificate_buffer(ctx, NULL, 0, + WOLFSSL_FILETYPE_ASN1), ASN_PARSE_E); + ExpectIntEQ(wolfSSL_CTX_use_certificate_buffer(NULL, server_cert_der_2048, + 0, WOLFSSL_FILETYPE_ASN1), BAD_FUNC_ARG); + ExpectIntEQ(wolfSSL_CTX_use_certificate_buffer(ctx, server_cert_der_2048, 0, + WOLFSSL_FILETYPE_ASN1), ASN_PARSE_E); + + ExpectIntEQ(wolfSSL_CTX_use_certificate_buffer(ctx, server_cert_der_2048, sizeof_server_cert_der_2048, WOLFSSL_FILETYPE_ASN1), WOLFSSL_SUCCESS); @@ -1807,6 +1833,37 @@ static int test_wolfSSL_CTX_use_certificate_buffer(void) } /* END test_wolfSSL_CTX_use_certificate_buffer */ +static int test_wolfSSL_use_certificate_buffer(void) +{ + EXPECT_DECLS; +#if !defined(NO_CERTS) && defined(USE_CERT_BUFFERS_2048) && \ + !defined(NO_RSA) && !defined(NO_WOLFSSL_CLIENT) + WOLFSSL_CTX* ctx = NULL; + WOLFSSL* ssl = NULL; + + ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method())); + ExpectNotNull(ssl = wolfSSL_new(ctx)); + + /* Invalid parameters. */ + ExpectIntEQ(wolfSSL_use_certificate_buffer(NULL, NULL, 0, + WOLFSSL_FILETYPE_ASN1), BAD_FUNC_ARG); + ExpectIntEQ(wolfSSL_use_certificate_buffer(ssl, NULL, 0, + WOLFSSL_FILETYPE_ASN1), ASN_PARSE_E); + ExpectIntEQ(wolfSSL_use_certificate_buffer(NULL, client_cert_der_2048, 0, + WOLFSSL_FILETYPE_ASN1), BAD_FUNC_ARG); + ExpectIntEQ(wolfSSL_use_certificate_buffer(ssl, client_cert_der_2048, 0, + WOLFSSL_FILETYPE_ASN1), ASN_PARSE_E); + + ExpectIntEQ(wolfSSL_use_certificate_buffer(ssl, + client_cert_der_2048, sizeof_client_cert_der_2048, + WOLFSSL_FILETYPE_ASN1), WOLFSSL_SUCCESS); + + wolfSSL_free(ssl); + wolfSSL_CTX_free(ctx); +#endif + return EXPECT_RESULT(); +} + static int test_wolfSSL_CTX_use_PrivateKey_file(void) { EXPECT_DECLS; @@ -1837,10 +1894,162 @@ static int test_wolfSSL_CTX_use_PrivateKey_file(void) wolfSSL_CTX_free(ctx); #endif + return EXPECT_RESULT(); +} + +static int test_wolfSSL_CTX_use_RSAPrivateKey_file(void) +{ + EXPECT_DECLS; +#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ + !defined(NO_WOLFSSL_SERVER) && defined(OPENSSL_EXTRA) + WOLFSSL_CTX *ctx = NULL; + ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); + + /* invalid context */ + ExpectIntEQ(wolfSSL_CTX_use_RSAPrivateKey_file(NULL, svrKeyFile, + WOLFSSL_FILETYPE_PEM), WOLFSSL_FAILURE); + /* invalid key file */ + ExpectIntEQ(wolfSSL_CTX_use_RSAPrivateKey_file(ctx, bogusFile, + WOLFSSL_FILETYPE_PEM), WOLFSSL_FAILURE); + /* invalid key type */ + ExpectIntEQ(wolfSSL_CTX_use_RSAPrivateKey_file(ctx, svrKeyFile, 9999), + WOLFSSL_FAILURE); + + /* success */ +#ifdef NO_RSA + /* rsa needed */ + ExpectIntEQ(wolfSSL_CTX_use_RSAPrivateKey_file(ctx, svrKeyFile, + WOLFSSL_FILETYPE_PEM), WOLFSSL_FAILURE); +#else + /* success */ + ExpectIntEQ(wolfSSL_CTX_use_RSAPrivateKey_file(ctx, svrKeyFile, + WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS); +#endif + + wolfSSL_CTX_free(ctx); +#endif + return EXPECT_RESULT(); +} + +static int test_wolfSSL_use_RSAPrivateKey_file(void) +{ + EXPECT_DECLS; +#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ + !defined(NO_WOLFSSL_CLIENT) && defined(OPENSSL_EXTRA) + WOLFSSL_CTX* ctx = NULL; + WOLFSSL* ssl = NULL; + + ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method())); + ExpectNotNull(ssl = SSL_new(ctx)); + + /* invalid context */ + ExpectIntEQ(wolfSSL_use_RSAPrivateKey_file(NULL, svrKeyFile, + WOLFSSL_FILETYPE_PEM), BAD_FUNC_ARG); + /* invalid key file */ + ExpectIntEQ(wolfSSL_use_RSAPrivateKey_file(ssl, bogusFile, + WOLFSSL_FILETYPE_PEM), WOLFSSL_FAILURE); + /* invalid key type */ + ExpectIntEQ(wolfSSL_use_RSAPrivateKey_file(ssl, svrKeyFile, 9999), + WOLFSSL_FAILURE); + + /* success */ +#ifdef NO_RSA + /* rsa needed */ + ExpectIntEQ(wolfSSL_use_RSAPrivateKey_file(ssl, svrKeyFile, + WOLFSSL_FILETYPE_PEM), WOLFSSL_FAILURE); +#else + /* success */ + ExpectIntEQ(wolfSSL_use_RSAPrivateKey_file(ssl, svrKeyFile, + WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS); +#endif + + wolfSSL_free(ssl); + wolfSSL_CTX_free(ctx); +#endif return EXPECT_RESULT(); } +static int test_wolfSSL_CTX_use_PrivateKey(void) +{ + EXPECT_DECLS; +#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ + !defined(NO_WOLFSSL_SERVER) && defined(OPENSSL_EXTRA) + WOLFSSL_CTX *ctx = NULL; + WOLFSSL_EVP_PKEY* pkey = NULL; + const unsigned char* p; + + (void)p; + + ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); + + ExpectNotNull(pkey = wolfSSL_EVP_PKEY_new()); + ExpectIntEQ(wolfSSL_CTX_use_PrivateKey(NULL, NULL), WOLFSSL_FAILURE); + ExpectIntEQ(wolfSSL_CTX_use_PrivateKey(ctx, NULL), WOLFSSL_FAILURE); + ExpectIntEQ(wolfSSL_CTX_use_PrivateKey(NULL, pkey), WOLFSSL_FAILURE); + /* No data. */ + ExpectIntEQ(wolfSSL_CTX_use_PrivateKey(ctx, pkey), WOLFSSL_FAILURE); + wolfSSL_EVP_PKEY_free(pkey); + pkey = NULL; + +#if defined(USE_CERT_BUFFERS_2048) +#if !defined(NO_RSA) + p = client_key_der_2048; + ExpectNotNull(pkey = d2i_PrivateKey(EVP_PKEY_RSA, NULL, &p, + sizeof_client_key_der_2048)); +#if defined(WOLFSSL_KEY_GEN) + ExpectIntEQ(wolfSSL_CTX_use_PrivateKey(ctx, pkey), WOLFSSL_SUCCESS); +#else + ExpectIntEQ(wolfSSL_CTX_use_PrivateKey(ctx, pkey), WOLFSSL_FAILURE); +#endif + wolfSSL_EVP_PKEY_free(pkey); + pkey = NULL; +#endif +#if defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || defined(WOLFSSL_OPENSSH) +#ifndef NO_DSA + p = dsa_key_der_2048; + ExpectNotNull(pkey = d2i_PrivateKey(EVP_PKEY_DSA, NULL, &p, + sizeof_dsa_key_der_2048)); +#if !defined(HAVE_SELFTEST) && (defined(WOLFSSL_KEY_GEN) || \ + defined(WOLFSSL_CERT_GEN)) + /* Not supported in ProcessBuffer. */ + ExpectIntEQ(wolfSSL_CTX_use_PrivateKey(ctx, pkey), WOLFSSL_BAD_FILE); +#else + ExpectIntEQ(wolfSSL_CTX_use_PrivateKey(ctx, pkey), WOLFSSL_FAILURE); +#endif + wolfSSL_EVP_PKEY_free(pkey); + pkey = NULL; +#endif +#endif /* WOLFSSL_QT || OPENSSL_ALL || WOLFSSL_OPENSSH */ +#if !defined(NO_DH) && defined(OPENSSL_ALL) && \ + (!defined(HAVE_FIPS) || FIPS_VERSION_GT(2,0)) + p = dh_ffdhe_statickey_der_2048; + ExpectNotNull(pkey = d2i_PrivateKey(EVP_PKEY_DH, NULL, &p, + sizeof_dh_ffdhe_statickey_der_2048)); + /* Not supported. */ + ExpectIntEQ(wolfSSL_CTX_use_PrivateKey(ctx, pkey), WOLFSSL_FAILURE); + wolfSSL_EVP_PKEY_free(pkey); + pkey = NULL; +#endif +#endif /* USE_CERT_BUFFERS_2048 */ +#if defined(HAVE_ECC) && defined(USE_CERT_BUFFERS_256) + p = ecc_clikey_der_256; + ExpectNotNull(pkey = d2i_PrivateKey(EVP_PKEY_EC, NULL, &p, + sizeof_ecc_clikey_der_256)); + ExpectIntEQ(wolfSSL_CTX_use_PrivateKey(ctx, pkey), WOLFSSL_SUCCESS); + wolfSSL_EVP_PKEY_free(pkey); + pkey = NULL; +#endif + ExpectNotNull(pkey = wolfSSL_EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, + (unsigned char*)"01234567012345670123456701234567", 32)); + ExpectIntEQ(wolfSSL_CTX_use_PrivateKey(ctx, pkey), WOLFSSL_FAILURE); + wolfSSL_EVP_PKEY_free(pkey); + pkey = NULL; + + wolfSSL_CTX_free(ctx); +#endif + return EXPECT_RESULT(); +} /* test both file and buffer versions along with unloading trusted peer certs */ static int test_wolfSSL_CTX_trust_peer_cert(void) @@ -3709,6 +3918,7 @@ static int test_wolfSSL_CertManagerCRL(void) wolfSSL_CertManagerLoadCRL(cm, crl2, WOLFSSL_FILETYPE_PEM, 0)); wolfSSL_CertManagerFreeCRL(cm); +#ifndef WOLFSSL_CRL_ALLOW_MISSING_CDP ExpectIntEQ(WOLFSSL_SUCCESS, wolfSSL_CertManagerLoadCRL(cm, crl1, WOLFSSL_FILETYPE_PEM, 0)); ExpectIntEQ(WOLFSSL_SUCCESS, @@ -3717,6 +3927,7 @@ static int test_wolfSSL_CertManagerCRL(void) sizeof_server_cert_der_2048), CRL_MISSING); ExpectIntEQ(wolfSSL_CertManagerVerifyBuffer(cm, server_cert_der_2048, sizeof_server_cert_der_2048, WOLFSSL_FILETYPE_ASN1), CRL_MISSING); +#endif /* !WOLFSSL_CRL_ALLOW_MISSING_CDP */ ExpectIntEQ(wolfSSL_CertManagerLoadCRLBuffer(cm, crl_buff, sizeof(crl_buff), WOLFSSL_FILETYPE_ASN1), 1); @@ -4062,8 +4273,8 @@ static int test_wolfSSL_CertManagerCheckOCSPResponse(void) static int test_wolfSSL_CheckOCSPResponse(void) { EXPECT_DECLS; -#if defined(HAVE_OCSP) && !defined(NO_RSA) && !defined(NO_SHA) && \ - defined(OPENSSL_ALL) +#if defined(HAVE_OCSP) && defined(OPENSSL_EXTRA) && \ + !defined(NO_RSA) && !defined(NO_SHA) const char* responseFile = "./certs/ocsp/test-response.der"; const char* responseMultiFile = "./certs/ocsp/test-multi-response.der"; const char* responseNoInternFile = @@ -4302,6 +4513,7 @@ static int test_wolfSSL_OtherName(void) return EXPECT_RESULT(); } +#ifdef HAVE_CERT_CHAIN_VALIDATION static int test_wolfSSL_CertRsaPss(void) { EXPECT_DECLS; @@ -4359,6 +4571,7 @@ static int test_wolfSSL_CertRsaPss(void) return EXPECT_RESULT(); } +#endif static int test_wolfSSL_CTX_load_verify_locations_ex(void) { @@ -4396,8 +4609,7 @@ static int test_wolfSSL_CTX_load_verify_locations_ex(void) static int test_wolfSSL_CTX_load_verify_buffer_ex(void) { EXPECT_DECLS; -#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) && \ - defined(USE_CERT_BUFFERS_2048) +#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) WOLFSSL_CTX* ctx; const char* ca_expired_cert_file = "./certs/test/expired/expired-ca.der"; @@ -4412,11 +4624,13 @@ static int test_wolfSSL_CTX_load_verify_buffer_ex(void) #endif ExpectNotNull(ctx); +#if defined(USE_CERT_BUFFERS_2048) /* test good CA */ ExpectTrue(WOLFSSL_SUCCESS == wolfSSL_CTX_load_verify_buffer_ex(ctx, ca_cert_der_2048, sizeof_ca_cert_der_2048, WOLFSSL_FILETYPE_ASN1, 0, WOLFSSL_LOAD_FLAG_NONE)); +#endif /* load expired CA */ XMEMSET(ca_expired_cert, 0, sizeof(ca_expired_cert)); @@ -4443,6 +4657,16 @@ static int test_wolfSSL_CTX_load_verify_buffer_ex(void) sizeof_ca_expired_cert, WOLFSSL_FILETYPE_ASN1, 0, WOLFSSL_LOAD_FLAG_DATE_ERR_OKAY), WOLFSSL_SUCCESS); + /* Fail when ctx is NULL. */ + ExpectIntEQ(wolfSSL_CTX_load_verify_buffer_ex(NULL, ca_expired_cert, + sizeof_ca_expired_cert, WOLFSSL_FILETYPE_ASN1, 0, + WOLFSSL_LOAD_FLAG_DATE_ERR_OKAY), BAD_FUNC_ARG); + /* Load as modified cert - bad initial length. */ + ca_expired_cert[2] = 0x7f; + ExpectIntEQ(wolfSSL_CTX_load_verify_buffer_ex(ctx, ca_expired_cert, + sizeof_ca_expired_cert, WOLFSSL_FILETYPE_ASN1, 1, + WOLFSSL_LOAD_FLAG_DATE_ERR_OKAY), ASN_PARSE_E); + wolfSSL_CTX_free(ctx); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif @@ -4454,7 +4678,7 @@ static int test_wolfSSL_CTX_load_verify_chain_buffer_format(void) { EXPECT_DECLS; #if !defined(NO_CERTS) && !defined(NO_RSA) && defined(OPENSSL_EXTRA) && \ - defined(WOLFSSL_CERT_GEN) && defined(USE_CERT_BUFFERS_2048) && \ + defined(USE_CERT_BUFFERS_2048) && (WOLFSSL_MIN_RSA_BITS <= 1024) && \ (!defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER)) WOLFSSL_CTX* ctx = NULL; @@ -4464,9 +4688,10 @@ static int test_wolfSSL_CTX_load_verify_chain_buffer_format(void) ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); #endif - ExpectTrue(WOLFSSL_SUCCESS == wolfSSL_CTX_load_verify_chain_buffer_format( - ctx, ca_cert_chain_der, sizeof_ca_cert_chain_der, - WOLFSSL_FILETYPE_ASN1)); + /* Public key 140 bytes??? */ + ExpectIntEQ(wolfSSL_CTX_load_verify_chain_buffer_format(ctx, + ca_cert_chain_der, sizeof_ca_cert_chain_der, WOLFSSL_FILETYPE_ASN1), + WOLFSSL_SUCCESS); wolfSSL_CTX_free(ctx); #endif @@ -4495,9 +4720,29 @@ static int test_wolfSSL_CTX_add1_chain_cert(void) ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method())); ExpectNotNull(ssl = wolfSSL_new(ctx)); + ExpectNotNull(x509 = wolfSSL_X509_new()); + ExpectIntEQ(SSL_CTX_add1_chain_cert(ctx, x509), 0); + ExpectIntEQ(SSL_CTX_add0_chain_cert(ctx, x509), 0); + ExpectIntEQ(SSL_add1_chain_cert(ssl, x509), 0); + ExpectIntEQ(SSL_add0_chain_cert(ssl, x509), 0); + wolfSSL_X509_free(x509); + x509 = NULL; + for (cert = certChain; EXPECT_SUCCESS() && *cert != NULL; cert++) { ExpectNotNull(x509 = wolfSSL_X509_load_certificate_file(*cert, WOLFSSL_FILETYPE_PEM)); + + /* Do negative tests once */ + if (cert == certChain) { + /* Negative tests. */ + ExpectIntEQ(SSL_CTX_add1_chain_cert(NULL, NULL), 0); + ExpectIntEQ(SSL_CTX_add1_chain_cert(ctx, NULL), 0); + ExpectIntEQ(SSL_CTX_add1_chain_cert(NULL, x509), 0); + ExpectIntEQ(SSL_CTX_add0_chain_cert(NULL, NULL), 0); + ExpectIntEQ(SSL_CTX_add0_chain_cert(ctx, NULL), 0); + ExpectIntEQ(SSL_CTX_add0_chain_cert(NULL, x509), 0); + } + ExpectIntEQ(SSL_CTX_add1_chain_cert(ctx, x509), 1); X509_free(x509); x509 = NULL; @@ -4505,6 +4750,18 @@ static int test_wolfSSL_CTX_add1_chain_cert(void) for (cert = certChain; EXPECT_SUCCESS() && *cert != NULL; cert++) { ExpectNotNull(x509 = wolfSSL_X509_load_certificate_file(*cert, WOLFSSL_FILETYPE_PEM)); + + /* Do negative tests once */ + if (cert == certChain) { + /* Negative tests. */ + ExpectIntEQ(SSL_add1_chain_cert(NULL, NULL), 0); + ExpectIntEQ(SSL_add1_chain_cert(ssl, NULL), 0); + ExpectIntEQ(SSL_add1_chain_cert(NULL, x509), 0); + ExpectIntEQ(SSL_add0_chain_cert(NULL, NULL), 0); + ExpectIntEQ(SSL_add0_chain_cert(ssl, NULL), 0); + ExpectIntEQ(SSL_add0_chain_cert(NULL, x509), 0); + } + ExpectIntEQ(SSL_add1_chain_cert(ssl, x509), 1); X509_free(x509); x509 = NULL; @@ -4521,6 +4778,69 @@ static int test_wolfSSL_CTX_add1_chain_cert(void) return EXPECT_RESULT(); } +static int test_wolfSSL_CTX_use_certificate_chain_buffer_format(void) +{ + EXPECT_DECLS; +#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) && \ + !defined(NO_WOLFSSL_CLIENT) && defined(USE_CERT_BUFFERS_2048) + WOLFSSL_CTX* ctx = NULL; + WOLFSSL* ssl = NULL; + const char* cert = "./certs/server-cert.pem"; + unsigned char* buf = NULL; + size_t len; + + ExpectIntEQ(load_file(cert, &buf, &len), 0); + + ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method())); + ExpectNotNull(ssl = wolfSSL_new(ctx)); + + /* Invalid parameters. */ + ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer_format(NULL, + NULL, 0, WOLFSSL_FILETYPE_ASN1), BAD_FUNC_ARG); + ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer_format(ctx, + NULL, 0, WOLFSSL_FILETYPE_ASN1), ASN_PARSE_E); + ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer_format(NULL, + server_cert_der_2048, sizeof_server_cert_der_2048, + WOLFSSL_FILETYPE_ASN1), BAD_FUNC_ARG); + ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer(NULL, NULL, 0), + BAD_FUNC_ARG); + ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer(ctx, NULL, 0), + ASN_NO_PEM_HEADER); + ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer(NULL, buf, (long)len), + BAD_FUNC_ARG); + ExpectIntEQ(wolfSSL_use_certificate_chain_buffer(NULL, NULL, 0), + BAD_FUNC_ARG); + ExpectIntEQ(wolfSSL_use_certificate_chain_buffer(ssl, NULL, 0), + ASN_NO_PEM_HEADER); + ExpectIntEQ(wolfSSL_use_certificate_chain_buffer(NULL, buf, (long)len), + BAD_FUNC_ARG); + + ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer_format(ctx, + server_cert_der_2048, sizeof_server_cert_der_2048, + WOLFSSL_FILETYPE_ASN1), WOLFSSL_SUCCESS); + + ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer_format(ctx, buf, + (long)len, WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS); + + ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer(ctx, buf, (long)len), + WOLFSSL_SUCCESS); + ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer(ctx, + server_cert_der_2048, sizeof_server_cert_der_2048), ASN_NO_PEM_HEADER); + + ExpectIntEQ(wolfSSL_use_certificate_chain_buffer(ssl, buf, (long)len), + WOLFSSL_SUCCESS); + ExpectIntEQ(wolfSSL_use_certificate_chain_buffer(ssl, server_cert_der_2048, + sizeof_server_cert_der_2048), ASN_NO_PEM_HEADER); + + wolfSSL_free(ssl); + wolfSSL_CTX_free(ctx); + if (buf != NULL) { + free(buf); + } +#endif + return EXPECT_RESULT(); +} + static int test_wolfSSL_CTX_use_certificate_chain_file_format(void) { EXPECT_DECLS; @@ -4528,18 +4848,17 @@ static int test_wolfSSL_CTX_use_certificate_chain_file_format(void) (!defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER)) const char* server_chain_der = "./certs/server-cert-chain.der"; const char* client_single_pem = "./certs/client-cert.pem"; - WOLFSSL_CTX* ctx; + WOLFSSL_CTX* ctx = NULL; (void)server_chain_der; (void)client_single_pem; (void)ctx; #ifndef NO_WOLFSSL_CLIENT - ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); + ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method())); #else - ctx = wolfSSL_CTX_new(wolfSSLv23_server_method()); + ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); #endif - ExpectNotNull(ctx); ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_file_format(ctx, server_chain_der, WOLFSSL_FILETYPE_ASN1), WOLFSSL_SUCCESS); @@ -4551,12 +4870,58 @@ static int test_wolfSSL_CTX_use_certificate_chain_file_format(void) return EXPECT_RESULT(); } +static int test_wolfSSL_use_certificate_chain_file(void) +{ + EXPECT_DECLS; +#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) && \ + !defined(NO_WOLFSSL_CLIENT) + const char* server_chain_der = "./certs/server-cert-chain.der"; + const char* client_single_pem = "./certs/client-cert.pem"; + WOLFSSL_CTX* ctx = NULL; + WOLFSSL* ssl = NULL; + + (void)server_chain_der; + (void)client_single_pem; + + ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method())); + ExpectNotNull(ssl = wolfSSL_new(ctx)); + + /* Invalid parameters. */ + ExpectIntEQ(wolfSSL_use_certificate_chain_file_format(NULL, NULL, + WOLFSSL_FILETYPE_ASN1), BAD_FUNC_ARG); + ExpectIntEQ(wolfSSL_use_certificate_chain_file_format(ssl, NULL, + WOLFSSL_FILETYPE_ASN1), WOLFSSL_FAILURE); + ExpectIntEQ(wolfSSL_use_certificate_chain_file_format(NULL, + server_chain_der, WOLFSSL_FILETYPE_ASN1), BAD_FUNC_ARG); + ExpectIntEQ(wolfSSL_use_certificate_chain_file(NULL, NULL), BAD_FUNC_ARG); + ExpectIntEQ(wolfSSL_use_certificate_chain_file(ssl, NULL), WOLFSSL_FAILURE); + ExpectIntEQ(wolfSSL_use_certificate_chain_file(NULL, client_single_pem), + BAD_FUNC_ARG); + ExpectIntEQ(wolfSSL_use_certificate_chain_file(ssl, server_chain_der), + WOLFSSL_FAILURE); + + ExpectIntEQ(wolfSSL_use_certificate_chain_file_format(ssl, + server_chain_der, WOLFSSL_FILETYPE_ASN1), WOLFSSL_SUCCESS); + ExpectIntEQ(wolfSSL_use_certificate_chain_file_format(ssl, + client_single_pem, WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS); + ExpectIntEQ(wolfSSL_use_certificate_chain_file(ssl, client_single_pem), + WOLFSSL_SUCCESS); + + wolfSSL_free(ssl); + wolfSSL_CTX_free(ctx); +#endif + return EXPECT_RESULT(); +} + static int test_wolfSSL_CTX_SetTmpDH_file(void) { EXPECT_DECLS; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_DH) && \ (!defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER)) WOLFSSL_CTX *ctx = NULL; +#if defined(WOLFSSL_WPAS) && !defined(NO_DSA) + const char* dsaParamFile = "./certs/dsaparams.pem"; +#endif (void)ctx; @@ -4580,6 +4945,10 @@ static int test_wolfSSL_CTX_SetTmpDH_file(void) /* success */ ExpectIntEQ(WOLFSSL_SUCCESS, wolfSSL_CTX_SetTmpDH_file(ctx, dhParamFile, WOLFSSL_FILETYPE_PEM)); +#if defined(WOLFSSL_WPAS) && !defined(NO_DSA) + ExpectIntEQ(WOLFSSL_SUCCESS, wolfSSL_CTX_SetTmpDH_file(ctx, dsaParamFile, + WOLFSSL_FILETYPE_PEM)); +#endif wolfSSL_CTX_free(ctx); #endif @@ -4607,11 +4976,17 @@ static int test_wolfSSL_CTX_SetTmpDH_buffer(void) /* invalid dhParamFile file */ ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_CTX_SetTmpDH_buffer(NULL, NULL, 0, WOLFSSL_FILETYPE_ASN1)); + ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_CTX_SetTmpDH_buffer(ctx, NULL, + 0, WOLFSSL_FILETYPE_ASN1)); ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_CTX_SetTmpDH_buffer(ctx, dsa_key_der_2048, sizeof_dsa_key_der_2048, WOLFSSL_FILETYPE_ASN1)); + /* invalid file format */ + ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_CTX_SetTmpDH_buffer(ctx, + dh_key_der_2048, sizeof_dh_key_der_2048, -1)); + /* success */ ExpectIntEQ(WOLFSSL_SUCCESS, wolfSSL_CTX_SetTmpDH_buffer(ctx, dh_key_der_2048, sizeof_dh_key_der_2048, @@ -4972,6 +5347,10 @@ static int test_wolfSSL_SetTmpDH_file(void) !defined(NO_WOLFSSL_SERVER) WOLFSSL_CTX *ctx = NULL; WOLFSSL *ssl = NULL; + const char* dhX942ParamFile = "./certs/x942dh2048.pem"; +#if defined(WOLFSSL_WPAS) && !defined(NO_DSA) + const char* dsaParamFile = "./certs/dsaparams.pem"; +#endif ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); #ifndef NO_RSA @@ -5010,6 +5389,12 @@ static int test_wolfSSL_SetTmpDH_file(void) /* success */ ExpectIntEQ(WOLFSSL_SUCCESS, wolfSSL_SetTmpDH_file(ssl, dhParamFile, WOLFSSL_FILETYPE_PEM)); + ExpectIntEQ(WOLFSSL_SUCCESS, wolfSSL_SetTmpDH_file(ssl, dhX942ParamFile, + WOLFSSL_FILETYPE_PEM)); +#if defined(WOLFSSL_WPAS) && !defined(NO_DSA) + ExpectIntEQ(WOLFSSL_SUCCESS, wolfSSL_CTX_SetTmpDH_file(ctx, dsaParamFile, + WOLFSSL_FILETYPE_PEM)); +#endif wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); @@ -5039,6 +5424,8 @@ static int test_wolfSSL_SetTmpDH_buffer(void) /* invalid dhParamFile file */ ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_SetTmpDH_buffer(NULL, NULL, 0, WOLFSSL_FILETYPE_ASN1)); + ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_SetTmpDH_buffer(ssl, NULL, 0, + WOLFSSL_FILETYPE_ASN1)); ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_SetTmpDH_buffer(ssl, dsa_key_der_2048, sizeof_dsa_key_der_2048, WOLFSSL_FILETYPE_ASN1)); @@ -23338,7 +23725,11 @@ static int test_wc_Ed25519PublicKeyToDer(void) ExpectIntEQ(wc_ed25519_init(&key), 0); ExpectIntEQ(wc_InitRng(&rng), 0); ExpectIntEQ(wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key), 0); - ExpectIntGT(wc_Ed25519PublicKeyToDer(&key, derBuf, 1024, 1), 0); + /* length only */ + ExpectIntGT(wc_Ed25519PublicKeyToDer(&key, NULL, 0, 0), 0); + ExpectIntGT(wc_Ed25519PublicKeyToDer(&key, NULL, 0, 1), 0); + ExpectIntGT(wc_Ed25519PublicKeyToDer(&key, derBuf, + (word32)sizeof(derBuf), 1), 0); DoExpectIntEQ(wc_FreeRng(&rng), 0); wc_ed25519_free(&key); @@ -24231,8 +24622,11 @@ static int test_wc_Ed448PublicKeyToDer(void) ExpectIntEQ(wc_ed448_init(&key), 0); ExpectIntEQ(wc_InitRng(&rng), 0); ExpectIntEQ(wc_ed448_make_key(&rng, ED448_KEY_SIZE, &key), 0); - - ExpectIntGT(wc_Ed448PublicKeyToDer(&key, derBuf, 1024, 1), 0); + /* length only */ + ExpectIntGT(wc_Ed448PublicKeyToDer(&key, NULL, 0, 0), 0); + ExpectIntGT(wc_Ed448PublicKeyToDer(&key, NULL, 0, 1), 0); + ExpectIntGT(wc_Ed448PublicKeyToDer(&key, derBuf, + (word32)sizeof(derBuf), 1), 0); DoExpectIntEQ(wc_FreeRng(&rng), 0); wc_ed448_free(&key); @@ -26858,9 +27252,10 @@ static int test_wc_Ed25519KeyToDer(void) /* Bad Cases */ ExpectIntEQ(wc_Ed25519KeyToDer(NULL, NULL, 0), BAD_FUNC_ARG); ExpectIntEQ(wc_Ed25519KeyToDer(NULL, output, inLen), BAD_FUNC_ARG); - ExpectIntEQ(wc_Ed25519KeyToDer(&ed25519Key, output, 0), BAD_FUNC_ARG); + ExpectIntEQ(wc_Ed25519KeyToDer(&ed25519Key, output, 0), BUFFER_E); /* Good Cases */ /* length only */ + ExpectIntGT(wc_Ed25519KeyToDer(&ed25519Key, NULL, 0), 0); ExpectIntGT(wc_Ed25519KeyToDer(&ed25519Key, NULL, inLen), 0); ExpectIntGT(wc_Ed25519KeyToDer(&ed25519Key, output, inLen), 0); @@ -26896,10 +27291,10 @@ static int test_wc_Ed25519PrivateKeyToDer(void) ExpectIntEQ(wc_Ed25519PrivateKeyToDer(NULL, NULL, 0), BAD_FUNC_ARG); ExpectIntEQ(wc_Ed25519PrivateKeyToDer(NULL, output, inLen), BAD_FUNC_ARG); ExpectIntEQ(wc_Ed25519PrivateKeyToDer(&ed25519PrivKey, output, 0), - BAD_FUNC_ARG); + BUFFER_E); /* Good Cases */ /* length only */ - ExpectIntGT(wc_Ed25519PrivateKeyToDer(&ed25519PrivKey, NULL, inLen), 0); + ExpectIntGT(wc_Ed25519PrivateKeyToDer(&ed25519PrivKey, NULL, 0), 0); ExpectIntGT(wc_Ed25519PrivateKeyToDer(&ed25519PrivKey, output, inLen), 0); DoExpectIntEQ(wc_FreeRng(&rng), 0); @@ -26932,10 +27327,10 @@ static int test_wc_Ed448KeyToDer(void) /* Bad Cases */ ExpectIntEQ(wc_Ed448KeyToDer(NULL, NULL, 0), BAD_FUNC_ARG); ExpectIntEQ(wc_Ed448KeyToDer(NULL, output, inLen), BAD_FUNC_ARG); - ExpectIntEQ(wc_Ed448KeyToDer(&ed448Key, output, 0), BAD_FUNC_ARG); + ExpectIntEQ(wc_Ed448KeyToDer(&ed448Key, output, 0), BUFFER_E); /* Good Cases */ /* length only */ - ExpectIntGT(wc_Ed448KeyToDer(&ed448Key, NULL, inLen), 0); + ExpectIntGT(wc_Ed448KeyToDer(&ed448Key, NULL, 0), 0); ExpectIntGT(wc_Ed448KeyToDer(&ed448Key, output, inLen), 0); DoExpectIntEQ(wc_FreeRng(&rng), 0); @@ -26970,10 +27365,10 @@ static int test_wc_Ed448PrivateKeyToDer(void) ExpectIntEQ(wc_Ed448PrivateKeyToDer(NULL, NULL, 0), BAD_FUNC_ARG); ExpectIntEQ(wc_Ed448PrivateKeyToDer(NULL, output, inLen), BAD_FUNC_ARG); ExpectIntEQ(wc_Ed448PrivateKeyToDer(&ed448PrivKey, output, 0), - BAD_FUNC_ARG); + BUFFER_E); /* Good cases */ /* length only */ - ExpectIntGT(wc_Ed448PrivateKeyToDer(&ed448PrivKey, NULL, inLen), 0); + ExpectIntGT(wc_Ed448PrivateKeyToDer(&ed448PrivKey, NULL, 0), 0); ExpectIntGT(wc_Ed448PrivateKeyToDer(&ed448PrivKey, output, inLen), 0); DoExpectIntEQ(wc_FreeRng(&rng), 0); @@ -27008,10 +27403,10 @@ static int test_wc_Curve448PrivateKeyToDer(void) ExpectIntEQ(wc_Curve448PrivateKeyToDer(NULL, NULL, 0), BAD_FUNC_ARG); ExpectIntEQ(wc_Curve448PrivateKeyToDer(NULL, output, inLen), BAD_FUNC_ARG); ExpectIntEQ(wc_Curve448PrivateKeyToDer(&curve448PrivKey, output, 0), - BAD_FUNC_ARG); + BUFFER_E); /* Good cases */ /* length only */ - ExpectIntGT(wc_Curve448PrivateKeyToDer(&curve448PrivKey, NULL, inLen), 0); + ExpectIntGT(wc_Curve448PrivateKeyToDer(&curve448PrivKey, NULL, 0), 0); ExpectIntGT(wc_Curve448PrivateKeyToDer(&curve448PrivKey, output, inLen), 0); /* Bad Cases */ @@ -27023,8 +27418,8 @@ static int test_wc_Curve448PrivateKeyToDer(void) BUFFER_E); /* Good cases */ /* length only */ - ExpectIntGT(wc_Curve448PublicKeyToDer(&curve448PrivKey, NULL, inLen, 0), 0); - ExpectIntGT(wc_Curve448PublicKeyToDer(&curve448PrivKey, NULL, inLen, 1), 0); + ExpectIntGT(wc_Curve448PublicKeyToDer(&curve448PrivKey, NULL, 0, 0), 0); + ExpectIntGT(wc_Curve448PublicKeyToDer(&curve448PrivKey, NULL, 0, 1), 0); ExpectIntGT(wc_Curve448PublicKeyToDer(&curve448PrivKey, output, inLen, 0), 0); ExpectIntGT(wc_Curve448PublicKeyToDer(&curve448PrivKey, output, inLen, 1), 0); @@ -32134,6 +32529,789 @@ static int test_wc_dilithium_check_key(void) return EXPECT_RESULT(); } +#if defined(HAVE_DILITHIUM) && defined(WOLFSSL_WC_DILITHIUM) && \ + defined(WOLFSSL_DILITHIUM_PUBLIC_KEY) +static const unsigned char dilithium_public_der[] = { +#ifndef WOLFSSL_NO_ML_DSA_44 + 0x30, 0x82, 0x05, 0x34, 0x30, 0x0d, 0x06, 0x0b, + 0x2b, 0x06, 0x01, 0x04, 0x01, 0x02, 0x82, 0x0b, + 0x0c, 0x04, 0x04, 0x03, 0x82, 0x05, 0x21, 0x00, + 0x0a, 0xf7, 0xc8, 0xa4, 0x96, 0x01, 0xa7, 0xb2, + 0x2e, 0x4d, 0xc9, 0xd9, 0x1c, 0xa1, 0x86, 0x09, + 0xce, 0x14, 0x6f, 0xe8, 0x33, 0x3c, 0x7b, 0xdb, + 0x19, 0x9c, 0x56, 0x39, 0x6a, 0x6c, 0x5d, 0x1f, + 0xe4, 0x26, 0xcb, 0x16, 0x91, 0x4d, 0xeb, 0x5a, + 0x36, 0x22, 0xee, 0xda, 0xdf, 0x46, 0x3e, 0xa1, + 0x4f, 0x9a, 0x30, 0xb5, 0x3f, 0x60, 0xf7, 0x75, + 0x47, 0xdc, 0x55, 0xf1, 0xbe, 0xbc, 0x87, 0x6c, + 0x50, 0x7c, 0x21, 0x55, 0x35, 0xad, 0xa7, 0xf9, + 0x1c, 0xf8, 0xa1, 0x92, 0x79, 0x10, 0x52, 0x7a, + 0xc3, 0xba, 0xd3, 0x9d, 0xc6, 0x9b, 0xf4, 0xcb, + 0x1b, 0xa2, 0xde, 0x83, 0x86, 0xa6, 0x35, 0xea, + 0xf2, 0x8c, 0xdc, 0xba, 0x3e, 0xef, 0x9c, 0xf5, + 0x8e, 0xc3, 0xb0, 0xc0, 0x5b, 0xcc, 0x35, 0x6a, + 0x81, 0xe5, 0x17, 0xb3, 0x9a, 0x57, 0xa6, 0x4a, + 0x87, 0xb1, 0xa7, 0xf5, 0xa2, 0x96, 0x40, 0x8b, + 0xc1, 0x62, 0xb2, 0xd9, 0x76, 0xe8, 0x51, 0x33, + 0x44, 0x3d, 0xeb, 0x14, 0x86, 0x88, 0x2c, 0xc1, + 0x47, 0xba, 0x2b, 0x85, 0x3b, 0x72, 0xcb, 0x9f, + 0x40, 0xba, 0x19, 0x58, 0xa4, 0x34, 0x0a, 0xd2, + 0x8c, 0x97, 0xbd, 0x3d, 0x09, 0xb0, 0x4a, 0xeb, + 0xaa, 0xee, 0x58, 0x1e, 0xc1, 0x19, 0x26, 0x70, + 0x15, 0xa5, 0x17, 0x7e, 0xd0, 0xa1, 0x08, 0xf9, + 0x6d, 0xcf, 0x20, 0x62, 0x95, 0x8e, 0x61, 0xf4, + 0x29, 0x96, 0x6f, 0x38, 0x1c, 0x67, 0xd5, 0xa6, + 0x4c, 0xf5, 0x1f, 0xda, 0x12, 0x22, 0x24, 0x6b, + 0x0d, 0xb7, 0x6a, 0xe5, 0xaf, 0x6c, 0x89, 0x52, + 0xc2, 0x85, 0x85, 0x5f, 0x16, 0x33, 0x0c, 0xc6, + 0x7a, 0xe0, 0xa8, 0xed, 0x13, 0x58, 0xf3, 0xa0, + 0x80, 0x42, 0x3c, 0xe3, 0x57, 0xd1, 0xe2, 0x66, + 0xc4, 0xe0, 0x3d, 0x49, 0x32, 0x21, 0xd9, 0xa1, + 0x3c, 0x93, 0x0a, 0xf7, 0x5f, 0x34, 0x65, 0xa4, + 0x30, 0xf9, 0xe7, 0x8a, 0x96, 0x04, 0xdb, 0xc5, + 0x16, 0x15, 0x10, 0x74, 0x4f, 0xc9, 0x6b, 0x4b, + 0x66, 0x29, 0xb0, 0xd1, 0x3b, 0xdd, 0x41, 0x0a, + 0xfe, 0xdf, 0x5f, 0x72, 0x91, 0xbc, 0x99, 0x2f, + 0x8d, 0x72, 0x3a, 0x4a, 0xde, 0x11, 0x3a, 0x20, + 0xb2, 0x56, 0xb5, 0x73, 0x89, 0xb4, 0x63, 0x37, + 0x86, 0xbd, 0x99, 0x8b, 0x03, 0x56, 0x50, 0x21, + 0x11, 0x78, 0x8c, 0xd5, 0xc1, 0x92, 0x33, 0x72, + 0x6e, 0x8d, 0x88, 0x2d, 0x10, 0x8f, 0x31, 0xd3, + 0x23, 0xe5, 0xaa, 0x1f, 0xe1, 0x37, 0xec, 0x34, + 0x42, 0x30, 0x75, 0xff, 0xb2, 0x1a, 0x8e, 0x29, + 0x03, 0x4c, 0xfd, 0xdf, 0x53, 0xf2, 0x0b, 0x2d, + 0xf9, 0x1c, 0x9e, 0xb6, 0x5a, 0x6c, 0x5e, 0x88, + 0x48, 0x29, 0x89, 0x42, 0xfc, 0x97, 0xfb, 0x27, + 0x1c, 0x99, 0x2a, 0xbf, 0x7f, 0x04, 0xb2, 0xcd, + 0xc9, 0x3a, 0x39, 0xfe, 0x4f, 0x47, 0x92, 0x0b, + 0x85, 0xfc, 0x92, 0x57, 0xc5, 0x0b, 0x23, 0x1f, + 0x0b, 0x72, 0xb4, 0xde, 0xfe, 0xbe, 0xb7, 0x39, + 0xb3, 0xd7, 0x48, 0x03, 0xed, 0x76, 0xac, 0x63, + 0xf7, 0x2a, 0x58, 0xef, 0xdb, 0x63, 0x5a, 0x56, + 0x68, 0xcc, 0xb2, 0x8b, 0x22, 0xac, 0xdf, 0xc4, + 0xad, 0x6f, 0xad, 0x24, 0xfd, 0x30, 0xfb, 0xed, + 0x6e, 0xde, 0x65, 0x2b, 0xb4, 0x57, 0x35, 0x49, + 0xc1, 0xc9, 0x82, 0xf4, 0x72, 0x69, 0xef, 0x34, + 0xc0, 0x37, 0x8b, 0x8b, 0xd3, 0xd3, 0x25, 0xcc, + 0xe5, 0xf5, 0xf6, 0x9c, 0xa3, 0xe7, 0x88, 0xd7, + 0x55, 0x73, 0x31, 0x4c, 0xb1, 0x7b, 0x64, 0xb3, + 0x38, 0xde, 0x47, 0x9a, 0xfc, 0xf1, 0xfa, 0xf8, + 0x6e, 0xc5, 0x95, 0xb9, 0xaf, 0x6a, 0x7a, 0x94, + 0x80, 0x0d, 0x29, 0x62, 0x99, 0x0a, 0x34, 0xa2, + 0x8f, 0xa1, 0x5e, 0x98, 0x7c, 0x4e, 0x18, 0xcd, + 0x63, 0x68, 0x0e, 0xfa, 0x6f, 0x49, 0x01, 0x02, + 0xcd, 0xf1, 0xc1, 0x09, 0x57, 0xa3, 0x03, 0xec, + 0x94, 0x36, 0xab, 0xc6, 0x1c, 0xc0, 0x98, 0x22, + 0x15, 0x5b, 0x5b, 0x61, 0x3c, 0xc2, 0x5b, 0x6f, + 0x1c, 0x82, 0x41, 0x39, 0x87, 0xde, 0x92, 0xa9, + 0xe4, 0x12, 0x74, 0x3b, 0x31, 0x36, 0xac, 0x92, + 0xb0, 0x23, 0x26, 0xfa, 0xd8, 0xa3, 0xe8, 0x84, + 0xfc, 0x52, 0xc5, 0x7b, 0xd1, 0x4b, 0xe2, 0x1a, + 0x33, 0xdd, 0x3c, 0xdf, 0x27, 0x50, 0x6f, 0x12, + 0xd3, 0x17, 0x66, 0xd7, 0x54, 0x33, 0x30, 0x2b, + 0xe8, 0xd1, 0x1f, 0x2d, 0xf3, 0x37, 0x81, 0xa0, + 0x3c, 0x21, 0x8c, 0xea, 0x95, 0xa5, 0x5b, 0x3a, + 0x24, 0xed, 0xf7, 0x67, 0x7b, 0x72, 0x3a, 0xda, + 0x31, 0xbd, 0xa7, 0x63, 0xa6, 0x6f, 0xf9, 0xdf, + 0x06, 0x36, 0xb4, 0xe2, 0x35, 0x4b, 0xa5, 0x8e, + 0x29, 0x8e, 0x6c, 0x02, 0xc5, 0x06, 0x9b, 0x98, + 0x6e, 0x5e, 0x00, 0x6a, 0x42, 0x09, 0x4b, 0xc3, + 0x09, 0x37, 0x67, 0x19, 0x58, 0x6d, 0x40, 0x50, + 0xb0, 0x62, 0x5b, 0xd6, 0x63, 0x7f, 0xed, 0xb0, + 0x97, 0x80, 0x9e, 0x91, 0x3f, 0x82, 0xfd, 0x83, + 0x36, 0xce, 0x06, 0xc4, 0xdc, 0xa4, 0x1e, 0x70, + 0xd4, 0x94, 0xfc, 0x6e, 0x46, 0xa3, 0xc8, 0xed, + 0x34, 0x0a, 0xb1, 0x9a, 0x66, 0x5d, 0xc0, 0xce, + 0x73, 0xd3, 0x65, 0xcb, 0xfb, 0x79, 0xdd, 0xf6, + 0x19, 0xf6, 0xd8, 0xa9, 0xe6, 0x34, 0x15, 0x86, + 0x7a, 0x30, 0x79, 0xde, 0x2b, 0x06, 0xa4, 0xc0, + 0xc8, 0xa2, 0xc1, 0x41, 0xb3, 0x4c, 0xf6, 0xdb, + 0x16, 0xcd, 0xd2, 0x8b, 0xf1, 0x18, 0x5a, 0xc8, + 0x3e, 0xd9, 0x54, 0x40, 0xd4, 0xce, 0x88, 0xbb, + 0x66, 0xf1, 0x74, 0x20, 0xa2, 0x3c, 0x31, 0x09, + 0xba, 0xac, 0x61, 0x15, 0x9f, 0x73, 0x5f, 0xa7, + 0xe5, 0x0d, 0xb3, 0xab, 0xa2, 0x72, 0x25, 0xc9, + 0x87, 0x9b, 0x18, 0xdb, 0xff, 0xfb, 0x39, 0x84, + 0x8d, 0xf8, 0x97, 0x47, 0xab, 0xc4, 0xfb, 0xc2, + 0xd8, 0xe8, 0xce, 0x6e, 0x65, 0x76, 0x88, 0x4a, + 0x22, 0x2f, 0xdd, 0x43, 0xa7, 0xc4, 0x8d, 0x32, + 0x12, 0x75, 0x0b, 0x72, 0xd6, 0xb7, 0x43, 0x84, + 0xc8, 0x59, 0xa8, 0xb7, 0x8b, 0x84, 0x33, 0x92, + 0x8f, 0x94, 0xe8, 0xd0, 0xaf, 0x11, 0x35, 0xde, + 0xb7, 0x63, 0xb8, 0x91, 0x4c, 0x96, 0x4e, 0x9c, + 0x62, 0x28, 0xa2, 0xbc, 0x0b, 0x90, 0xae, 0x94, + 0x90, 0xe9, 0x32, 0xeb, 0xe3, 0x77, 0x60, 0x5f, + 0x87, 0x48, 0x4b, 0xb0, 0x78, 0x0e, 0xe2, 0x85, + 0x47, 0x06, 0xa4, 0xc9, 0x26, 0xac, 0x8f, 0xe7, + 0xc2, 0xc7, 0xce, 0xf5, 0xd1, 0x20, 0xa8, 0x56, + 0xe1, 0x4f, 0x50, 0x90, 0xb3, 0xc1, 0x03, 0x57, + 0xd3, 0x62, 0x0e, 0x2a, 0xe8, 0x86, 0xf4, 0x94, + 0x0e, 0xa5, 0x8b, 0x4e, 0x73, 0xa2, 0x76, 0xac, + 0x00, 0x29, 0xe5, 0x80, 0x26, 0x02, 0x13, 0xd1, + 0xb2, 0x68, 0x72, 0x23, 0x38, 0x55, 0xfc, 0x4d, + 0x05, 0x60, 0x49, 0x7b, 0xfb, 0xaa, 0x17, 0x8f, + 0x26, 0x0a, 0x08, 0x33, 0x8d, 0x7f, 0x4e, 0xe5, + 0x6e, 0xf8, 0x84, 0x9b, 0x9f, 0xcb, 0xa2, 0x2b, + 0xfb, 0xaf, 0xad, 0x21, 0xe2, 0x4f, 0x6f, 0x55, + 0xc1, 0x78, 0x46, 0xe3, 0xb5, 0x63, 0x06, 0x9b, + 0x93, 0x7d, 0xac, 0xd4, 0xe0, 0x64, 0x01, 0x8d, + 0xac, 0x30, 0x8b, 0x8b, 0x55, 0xb7, 0x8a, 0x16, + 0x3f, 0xc9, 0x82, 0x7f, 0xb5, 0x3b, 0x0d, 0xc0, + 0x46, 0x89, 0x5c, 0x6c, 0x45, 0x21, 0x78, 0xda, + 0x84, 0x1f, 0xc8, 0xcf, 0xf1, 0x1e, 0x79, 0x71, + 0x3b, 0xc8, 0xe2, 0x8b, 0x41, 0xfe, 0xaf, 0x2f, + 0x3b, 0x23, 0x13, 0xc5, 0x46, 0x87, 0xc6, 0x24, + 0x37, 0x21, 0x68, 0x8a, 0x3e, 0x45, 0x61, 0xf4, + 0xad, 0xf5, 0x1c, 0x23, 0x45, 0xa3, 0x42, 0xf2, + 0xa9, 0xac, 0x94, 0x50, 0xc9, 0x3d, 0x5e, 0x70, + 0x33, 0x2b, 0x78, 0xd1, 0x5c, 0x13, 0x35, 0xe6, + 0x13, 0x80, 0x5e, 0x55, 0xa7, 0xcc, 0x67, 0xb0, + 0x6c, 0xfe, 0xa2, 0x24, 0x02, 0x6d, 0xb3, 0xcb, + 0x9e, 0x94, 0xb3, 0xc6, 0x01, 0xf3, 0x01, 0x3a, + 0xe4, 0xa7, 0xa3, 0xdf, 0x56, 0x4c, 0x30, 0xce, + 0xb1, 0xd5, 0x1b, 0x68, 0x9b, 0x75, 0xae, 0xf4, + 0xb9, 0x2a, 0xe5, 0x8b, 0x7b, 0xe5, 0x99, 0x46, + 0x5f, 0x29, 0xf6, 0x82, 0xd0, 0x42, 0xb1, 0x45, + 0x09, 0x16, 0x5b, 0x32, 0x11, 0xca, 0x48, 0xea, + 0x51, 0x12, 0x0a, 0x9f, 0x6e, 0x3f, 0x74, 0xe6, + 0xe0, 0xfe, 0xf8, 0xa5, 0xc0, 0xfd, 0x15, 0x6e, + 0x2b, 0x4a, 0xd5, 0x76, 0xa8, 0x3d, 0xe3, 0x0d, + 0xfe, 0x44, 0x11, 0x5e, 0x7a, 0xde, 0x12, 0x29, + 0x5a, 0x5a, 0x25, 0xc0, 0x8e, 0x98, 0xd1, 0x11, + 0xc8, 0x00, 0x65, 0xb2, 0xf4, 0xd7, 0x56, 0x32, + 0x46, 0x2b, 0x4f, 0x7e, 0xc3, 0x4e, 0xf1, 0x17, + 0xff, 0x03, 0x32, 0xae, 0xe3, 0xbe, 0x0b, 0xab, + 0xfb, 0x43, 0x0f, 0x6d, 0xa5, 0xc6, 0x44, 0xba, + 0xc9, 0xe3, 0x3d, 0x40, 0xe7, 0x6c, 0xe8, 0x21, + 0xb2, 0x46, 0x7b, 0x3b, 0x3d, 0xde, 0x80, 0xc8, + 0xea, 0xf4, 0x6b, 0xf3, 0x53, 0xca, 0x51, 0x84, + 0xcf, 0xad, 0x7e, 0xce, 0xce, 0xc2, 0x65, 0xfc, + 0x03, 0x8c, 0xcb, 0xfa, 0xcb, 0x37, 0x89, 0x82, + 0x59, 0x5e, 0x36, 0x52, 0xe4, 0xbc, 0x8d, 0x47, + 0x7c, 0xb8, 0x3f, 0x63, 0x59, 0xdc, 0xd3, 0x74, + 0x11, 0x33, 0xb4, 0x69, 0x74, 0x40, 0x0d, 0x42, + 0x63, 0x1d, 0xe6, 0x5c, 0x1b, 0xca, 0x41, 0xff, + 0x23, 0x4e, 0xe8, 0x3d, 0x14, 0xa8, 0x17, 0x18, + 0xd0, 0x78, 0x08, 0x87, 0x7d, 0x5e, 0xdc, 0x3a, + 0x07, 0xba, 0x12, 0x8e, 0x8e, 0x56, 0x0a, 0xcb, + 0x37, 0xf6, 0x54, 0xeb, 0x55, 0x16, 0x8f, 0x06, + 0x15, 0x28, 0x6b, 0xfb, 0xed, 0x38, 0x9e, 0x9b, + 0x98, 0x5b, 0xdc, 0x67, 0x33, 0x0e, 0x02, 0x36, + 0x1b, 0x7a, 0x9a, 0x43, 0xcd, 0xf2, 0x65, 0xef, + 0x37, 0x19, 0x24, 0x6f, 0x4b, 0xb9, 0x4d, 0x3e, + 0x0b, 0x47, 0xd1, 0x67, 0x50, 0x6a, 0x7f, 0x07 +#elif !defined(WOLFSSL_NO_ML_DSA_65) + 0x30, 0x82, 0x07, 0xb4, 0x30, 0x0d, 0x06, 0x0b, + 0x2b, 0x06, 0x01, 0x04, 0x01, 0x02, 0x82, 0x0b, + 0x0c, 0x06, 0x05, 0x03, 0x82, 0x07, 0xa1, 0x00, + 0xff, 0x89, 0xee, 0xad, 0x20, 0x8f, 0x61, 0xa4, + 0x07, 0x1c, 0x54, 0x98, 0x8c, 0xf4, 0x2e, 0xd9, + 0xe6, 0x0f, 0xcb, 0x0e, 0xab, 0xa1, 0x37, 0x4d, + 0xc0, 0x48, 0x24, 0x78, 0xd6, 0x2d, 0x9b, 0x6f, + 0x0f, 0x17, 0x08, 0x71, 0xc3, 0xd1, 0xc8, 0x7a, + 0xe7, 0x32, 0xcb, 0xcd, 0xd6, 0xb5, 0x90, 0x08, + 0xe1, 0xda, 0xaa, 0x89, 0x3e, 0x4a, 0x62, 0x98, + 0x3d, 0xc6, 0x71, 0x30, 0xb4, 0x63, 0xa5, 0x3b, + 0xb3, 0x69, 0x75, 0x10, 0xaf, 0x5e, 0x72, 0x78, + 0xa2, 0xef, 0x63, 0x63, 0x21, 0xe7, 0xf4, 0xa7, + 0x9c, 0x50, 0x74, 0x14, 0x3e, 0xdd, 0x73, 0x9e, + 0x97, 0x65, 0xdd, 0xdf, 0x3c, 0x40, 0x4d, 0x03, + 0x49, 0xe4, 0xbf, 0x65, 0xe7, 0x44, 0x8f, 0x59, + 0x00, 0xe2, 0x98, 0xb5, 0x66, 0xa3, 0x3b, 0x11, + 0x9f, 0xc7, 0xc2, 0x16, 0x61, 0xf0, 0x1e, 0x89, + 0xc8, 0x96, 0x8d, 0x18, 0xac, 0x86, 0xa0, 0xe2, + 0xd9, 0x8c, 0xef, 0x53, 0x6d, 0x4e, 0x74, 0xc9, + 0x66, 0x28, 0x16, 0xf3, 0x62, 0xc4, 0x6f, 0x2b, + 0x6e, 0x36, 0x03, 0xad, 0xc5, 0xe4, 0x8f, 0x0b, + 0x90, 0x8c, 0x8f, 0xff, 0x5d, 0xdf, 0x7a, 0xe6, + 0xaf, 0x9a, 0x43, 0xbc, 0xd4, 0x73, 0x22, 0xdc, + 0x5f, 0x08, 0xa1, 0x17, 0x97, 0x89, 0x79, 0xf5, + 0xdc, 0xed, 0x4f, 0x85, 0x8e, 0x0c, 0x23, 0x35, + 0x3c, 0x34, 0x19, 0x65, 0xf5, 0xd6, 0xc9, 0x2d, + 0x7a, 0x2e, 0x67, 0xd5, 0xf1, 0x82, 0x97, 0xaa, + 0x05, 0x26, 0x84, 0x25, 0x47, 0x58, 0x2c, 0xe6, + 0x59, 0xc7, 0x98, 0x7a, 0xdb, 0x40, 0x45, 0x1c, + 0x71, 0x55, 0x2e, 0xea, 0x3f, 0x6e, 0x7c, 0x82, + 0x52, 0x6a, 0x19, 0x3a, 0xd3, 0xa1, 0x3c, 0xce, + 0x00, 0x06, 0xec, 0xed, 0x97, 0xce, 0xd8, 0xdf, + 0xde, 0xa3, 0xed, 0xe7, 0x81, 0x62, 0x02, 0x9c, + 0x1b, 0x51, 0xa1, 0xf4, 0x9d, 0x1b, 0x28, 0x76, + 0x93, 0x96, 0x20, 0x55, 0x60, 0x1f, 0xaf, 0x52, + 0xc3, 0xce, 0xb9, 0x12, 0x66, 0xf5, 0x64, 0x22, + 0x87, 0x86, 0x29, 0x80, 0x8f, 0x18, 0x33, 0xba, + 0x48, 0x71, 0x1d, 0x00, 0xfe, 0xa5, 0xfc, 0xc6, + 0x87, 0xbe, 0x44, 0x3c, 0xc9, 0x49, 0xfb, 0x68, + 0x3c, 0xdf, 0xca, 0xef, 0xa7, 0xdc, 0x67, 0xb8, + 0x28, 0xd6, 0xad, 0x18, 0xaf, 0xad, 0x1f, 0x4c, + 0x85, 0xa3, 0x64, 0xac, 0x3f, 0xa9, 0x39, 0x28, + 0xef, 0x8a, 0x45, 0x7e, 0xb0, 0xf4, 0x89, 0x72, + 0xf7, 0xb1, 0xef, 0x9d, 0x1c, 0x3c, 0x93, 0xcb, + 0xa0, 0xfb, 0x2a, 0x90, 0xe2, 0x1d, 0x49, 0x8e, + 0x36, 0xb8, 0x07, 0xf4, 0xb3, 0x09, 0xf0, 0x6f, + 0x3c, 0xd9, 0x37, 0x19, 0x57, 0xd4, 0x1e, 0x2a, + 0xa2, 0xa7, 0x2e, 0xc1, 0xcd, 0x8d, 0x48, 0x47, + 0xb5, 0x8a, 0x12, 0x93, 0x34, 0xb8, 0xec, 0x32, + 0x07, 0x49, 0xb6, 0x8d, 0x73, 0xd4, 0x2c, 0x6a, + 0xa0, 0x33, 0x29, 0x21, 0x5d, 0x37, 0xa9, 0x39, + 0x40, 0xbe, 0x71, 0x29, 0xbe, 0xd1, 0x4b, 0xbc, + 0x9a, 0x17, 0x93, 0x52, 0xb8, 0x81, 0xee, 0xc5, + 0xff, 0x25, 0x78, 0x2f, 0x52, 0x0a, 0x8f, 0xb2, + 0xef, 0xf3, 0x1d, 0x68, 0x56, 0x31, 0x29, 0x84, + 0x55, 0x47, 0x32, 0x34, 0x0f, 0x60, 0x07, 0xd6, + 0x2b, 0xb9, 0x29, 0xaf, 0x0f, 0xcd, 0x1c, 0xc0, + 0x77, 0x4c, 0xc6, 0x31, 0xdb, 0xf4, 0x17, 0xbe, + 0x3d, 0xf8, 0x8c, 0xf1, 0x02, 0x7c, 0x6b, 0xd4, + 0xaf, 0x03, 0xb2, 0xf4, 0x78, 0x8d, 0xd3, 0x4e, + 0x5c, 0x04, 0xb9, 0x01, 0xe3, 0x73, 0xb4, 0x67, + 0xe9, 0xa8, 0x77, 0x6f, 0x87, 0x2b, 0xe2, 0x00, + 0x98, 0x5f, 0x02, 0x43, 0x85, 0x03, 0x4c, 0x71, + 0xd2, 0xe7, 0x61, 0x03, 0x22, 0x9e, 0xe5, 0xc2, + 0xa7, 0x66, 0x42, 0x7c, 0x9f, 0xf4, 0xb8, 0x6b, + 0x2d, 0xe4, 0xaa, 0x51, 0xda, 0x08, 0x73, 0x75, + 0x26, 0x45, 0xdc, 0xa6, 0x20, 0xd7, 0xcb, 0x00, + 0xfc, 0xe4, 0xdb, 0x28, 0x92, 0xf8, 0xb0, 0xc7, + 0xf0, 0x4b, 0x6d, 0xe8, 0xc1, 0x84, 0x38, 0xed, + 0x1a, 0xd4, 0x66, 0x69, 0xc4, 0x96, 0x40, 0xc4, + 0x7d, 0xfa, 0x58, 0x70, 0x7e, 0x70, 0x40, 0xba, + 0xfc, 0x95, 0xb6, 0x4c, 0x7c, 0x58, 0xbc, 0xb3, + 0x59, 0x08, 0x14, 0x03, 0x35, 0xf3, 0xf1, 0xaa, + 0xd5, 0xa2, 0x57, 0x70, 0xb6, 0x20, 0x75, 0x0a, + 0x58, 0x66, 0x74, 0xf7, 0x1c, 0xfd, 0x99, 0x7c, + 0x20, 0xda, 0xe7, 0x76, 0xcb, 0xf4, 0xa3, 0x9b, + 0xbc, 0x8f, 0x74, 0xef, 0xe2, 0x46, 0x5a, 0x72, + 0x33, 0x06, 0x32, 0x1e, 0xbd, 0x4e, 0x4c, 0xf6, + 0x16, 0x43, 0xa5, 0xa5, 0xa5, 0x6c, 0x76, 0x33, + 0x35, 0x63, 0xdc, 0xe4, 0xec, 0x7f, 0x8a, 0xfa, + 0xc3, 0x53, 0x69, 0x28, 0xf7, 0xd6, 0x97, 0xb9, + 0x3a, 0xf4, 0x15, 0x90, 0x50, 0xd3, 0xdf, 0xf5, + 0xd3, 0xcf, 0x15, 0x76, 0xe3, 0x3d, 0x24, 0x14, + 0xfd, 0xd3, 0x01, 0x25, 0x82, 0xb4, 0xe3, 0xd8, + 0x68, 0x89, 0x86, 0xa8, 0x26, 0x02, 0x5f, 0xc6, + 0xf4, 0x99, 0x3b, 0x97, 0xa8, 0x65, 0xed, 0x18, + 0xbb, 0x3c, 0x43, 0x4a, 0x6e, 0xaa, 0xbc, 0x83, + 0x85, 0x19, 0x9f, 0x9b, 0xb8, 0xa4, 0xa3, 0xb2, + 0xb7, 0x56, 0x07, 0x6c, 0xbf, 0x7d, 0xff, 0x5d, + 0xb5, 0x1e, 0x83, 0xc8, 0x74, 0x70, 0x98, 0x17, + 0x40, 0xe0, 0x2d, 0xad, 0x31, 0x00, 0x8e, 0x42, + 0xd5, 0xb2, 0x25, 0xaa, 0x82, 0xaf, 0x33, 0xd8, + 0x5b, 0xe2, 0x07, 0xed, 0xda, 0x84, 0xe9, 0xa2, + 0xff, 0xbb, 0xa5, 0x47, 0x95, 0x6e, 0xa1, 0x8d, + 0x59, 0x52, 0xeb, 0xf3, 0x3c, 0x18, 0x29, 0x92, + 0x72, 0x27, 0x18, 0xfc, 0x95, 0xb9, 0xde, 0x46, + 0xda, 0xcc, 0x4c, 0x31, 0x1d, 0x78, 0x86, 0xd2, + 0x8c, 0x38, 0x9c, 0x32, 0xab, 0xf7, 0xca, 0x73, + 0x85, 0xa5, 0xf1, 0xe0, 0x25, 0x06, 0xf9, 0x18, + 0x14, 0xab, 0x3b, 0x73, 0x26, 0xee, 0xa0, 0xfd, + 0x15, 0xac, 0xd6, 0x4e, 0x6b, 0xdb, 0x01, 0xa1, + 0xdc, 0xd1, 0x2f, 0xd2, 0xb7, 0x5e, 0x12, 0x4f, + 0x4b, 0x59, 0xd8, 0x03, 0x12, 0x60, 0xc9, 0x81, + 0xb7, 0x06, 0x23, 0x09, 0xc4, 0xd9, 0xa8, 0x93, + 0x6e, 0x96, 0xf4, 0x93, 0x53, 0xf0, 0x3d, 0xde, + 0x10, 0x88, 0xb1, 0xd0, 0xcc, 0xad, 0x2c, 0xbf, + 0x88, 0x98, 0x8f, 0x25, 0x76, 0xd7, 0x65, 0x77, + 0xcc, 0x36, 0x1d, 0x1b, 0x6b, 0x60, 0x58, 0xc4, + 0xfe, 0xe6, 0xca, 0xa8, 0x29, 0x33, 0x69, 0x36, + 0xb8, 0x12, 0x95, 0x38, 0xd9, 0xd4, 0x16, 0xe9, + 0x3e, 0x40, 0x8c, 0xc7, 0xae, 0x04, 0x11, 0xdf, + 0x51, 0xd3, 0xdd, 0xbf, 0xa9, 0x41, 0x43, 0x4c, + 0xff, 0x87, 0x2f, 0xea, 0x0f, 0x13, 0x66, 0x2a, + 0x2b, 0x18, 0xe8, 0xc4, 0xff, 0xa0, 0x1c, 0x78, + 0x79, 0x21, 0xf8, 0xaa, 0x8a, 0xf8, 0x92, 0xdf, + 0x7b, 0x5f, 0x6a, 0x71, 0x60, 0x67, 0x5d, 0x94, + 0xf6, 0xbb, 0x1d, 0x90, 0x7c, 0x51, 0x70, 0x1d, + 0x87, 0xde, 0xf8, 0x91, 0xcb, 0x42, 0x9f, 0xc7, + 0x4b, 0xa0, 0x16, 0xee, 0xb4, 0x73, 0xe8, 0xe0, + 0x0b, 0xa5, 0xd3, 0x26, 0x9e, 0x52, 0xda, 0x4a, + 0x1f, 0xae, 0x76, 0xbf, 0xbb, 0x4d, 0x74, 0x98, + 0xa6, 0xae, 0xc0, 0x60, 0x96, 0xc5, 0xad, 0x9b, + 0x91, 0x31, 0xb9, 0x50, 0x3d, 0x9a, 0x0f, 0xe1, + 0x93, 0xef, 0x08, 0x72, 0xb2, 0x66, 0xe5, 0x5d, + 0xe4, 0x15, 0x53, 0x8e, 0xb0, 0xb3, 0xf8, 0x78, + 0xfc, 0x5d, 0x44, 0xc5, 0xbf, 0xf5, 0x01, 0x54, + 0xc5, 0x45, 0xa9, 0x30, 0xa4, 0xf1, 0x49, 0x79, + 0x4e, 0xab, 0xfc, 0xb2, 0x93, 0xe7, 0x3a, 0xe1, + 0x7f, 0x1f, 0x2f, 0x45, 0x3a, 0x53, 0x2b, 0x68, + 0xb3, 0xa4, 0xac, 0x23, 0x54, 0xb7, 0x5d, 0x25, + 0xa3, 0xe3, 0x90, 0x8a, 0xb0, 0x02, 0xfb, 0x7f, + 0x2d, 0xeb, 0x80, 0xc2, 0x5c, 0x62, 0xe1, 0x36, + 0x5a, 0x82, 0x8f, 0x4e, 0x74, 0xeb, 0x7d, 0x70, + 0xaf, 0x23, 0x92, 0x65, 0x3a, 0x11, 0xc0, 0x29, + 0xdb, 0xf7, 0x9a, 0xdc, 0x81, 0x45, 0x25, 0x0c, + 0x2e, 0x4f, 0x88, 0x41, 0x34, 0x53, 0xc6, 0x08, + 0x21, 0x77, 0xc1, 0xbb, 0x61, 0x48, 0x20, 0x69, + 0x1a, 0xbb, 0x71, 0x1b, 0x56, 0x18, 0x79, 0x75, + 0x16, 0x9a, 0xb3, 0x79, 0x31, 0x11, 0xa2, 0x89, + 0x8d, 0xea, 0x10, 0xb0, 0x04, 0x7f, 0xf8, 0x6e, + 0xdc, 0x08, 0x9b, 0x51, 0xa7, 0x64, 0xbd, 0x8d, + 0xd4, 0xd0, 0x1e, 0x38, 0x50, 0x1a, 0xa8, 0x7e, + 0x20, 0xae, 0xee, 0x8c, 0xa7, 0x72, 0x94, 0xc9, + 0xba, 0xf0, 0x67, 0xbd, 0x25, 0x1a, 0x3a, 0xdf, + 0x75, 0x39, 0xb7, 0xd3, 0x83, 0x3b, 0x89, 0xdf, + 0xb5, 0x2d, 0xd3, 0x12, 0x24, 0x21, 0x7c, 0x9e, + 0x92, 0x1c, 0x19, 0xae, 0x28, 0xcb, 0x2e, 0x2e, + 0x3c, 0xa9, 0x9b, 0xbd, 0xf9, 0x33, 0x30, 0xb2, + 0xbd, 0x8b, 0xbf, 0xc1, 0x8b, 0x32, 0xf1, 0x20, + 0xa1, 0x00, 0xfd, 0x11, 0x7d, 0x9a, 0xa8, 0x14, + 0x2c, 0xce, 0x16, 0x16, 0x4b, 0xdd, 0x56, 0x91, + 0x15, 0x36, 0x83, 0xcb, 0x01, 0x58, 0x35, 0xe1, + 0xdc, 0x22, 0x3d, 0xf8, 0xc2, 0x06, 0x54, 0x68, + 0x77, 0xd1, 0x47, 0x28, 0xdc, 0x09, 0x2a, 0x86, + 0x13, 0x80, 0xa6, 0xe9, 0xd0, 0xb4, 0xa3, 0x41, + 0x47, 0xf4, 0x71, 0x24, 0x10, 0x4c, 0x9f, 0xb7, + 0x57, 0x34, 0x48, 0x1b, 0xb4, 0xed, 0x0e, 0x89, + 0x4c, 0xf1, 0x73, 0x44, 0xff, 0x35, 0xb6, 0xe0, + 0x8f, 0x02, 0xa3, 0xa3, 0x81, 0x55, 0x38, 0xb5, + 0xc1, 0x99, 0xb3, 0x88, 0x84, 0x0d, 0xd9, 0x73, + 0x77, 0x65, 0x0b, 0xd7, 0xf8, 0x03, 0x88, 0xcb, + 0xdf, 0x25, 0xaf, 0xc6, 0xf1, 0xfa, 0x5c, 0x4d, + 0xfa, 0xc3, 0x7b, 0x8f, 0xb8, 0x38, 0x5d, 0x29, + 0xbb, 0x3d, 0x3e, 0x62, 0x1c, 0xdd, 0xe6, 0x97, + 0xe6, 0xe9, 0xbe, 0x6e, 0xd2, 0xb7, 0x7a, 0x9a, + 0x8e, 0xaf, 0xb3, 0xc8, 0x9e, 0x19, 0xee, 0x3d, + 0x5b, 0x1f, 0xec, 0x34, 0x3a, 0x1c, 0x27, 0x90, + 0xbd, 0x1e, 0x49, 0x72, 0x25, 0x2e, 0x38, 0x48, + 0x7d, 0xe1, 0x85, 0x46, 0xa7, 0x1b, 0x4a, 0xd5, + 0x23, 0x75, 0x6d, 0x8b, 0xc3, 0xf1, 0x87, 0xec, + 0x8b, 0x45, 0xf0, 0x9b, 0xb2, 0x14, 0x7a, 0x7c, + 0x8d, 0x78, 0x9c, 0x82, 0x64, 0x14, 0xfe, 0x01, + 0xfa, 0x04, 0x33, 0x96, 0xdd, 0x5f, 0x56, 0xbc, + 0xb2, 0x03, 0xe3, 0x0c, 0xa1, 0x09, 0x66, 0xa0, + 0x5e, 0x44, 0xde, 0x21, 0xae, 0x7d, 0x7a, 0x0e, + 0x81, 0x27, 0xd2, 0xfb, 0x85, 0xed, 0x27, 0x27, + 0xac, 0x11, 0x1c, 0xa1, 0x6d, 0xe9, 0xc1, 0xca, + 0xf6, 0x40, 0x7c, 0x95, 0x01, 0xb7, 0xa8, 0x29, + 0x9a, 0xd2, 0xcc, 0x62, 0x70, 0x1c, 0x7d, 0x0e, + 0xe5, 0x60, 0xcb, 0x79, 0xa3, 0xd7, 0x5d, 0x48, + 0x4b, 0x3c, 0xf8, 0x12, 0xe8, 0x7a, 0x7e, 0x83, + 0xab, 0x24, 0x33, 0x0f, 0x7b, 0x0a, 0x38, 0xae, + 0xb1, 0xfc, 0xc3, 0x50, 0x5c, 0x83, 0x53, 0xfd, + 0x15, 0xd6, 0x49, 0x54, 0xb6, 0x40, 0xe5, 0xe8, + 0x55, 0xba, 0x08, 0x2f, 0x21, 0xd7, 0x0e, 0x71, + 0x8a, 0xb2, 0xe1, 0x6b, 0xc6, 0x7e, 0x0f, 0x1c, + 0x4d, 0x41, 0x9f, 0x38, 0xc2, 0xce, 0x41, 0x41, + 0x48, 0xcd, 0xec, 0x16, 0x1d, 0x23, 0x8e, 0x41, + 0xcd, 0x5e, 0xf9, 0x5f, 0x01, 0x5e, 0x73, 0xa2, + 0xa1, 0xef, 0xe9, 0x57, 0xe0, 0xba, 0xe6, 0xbb, + 0x2b, 0xff, 0x3e, 0xb8, 0xad, 0xd5, 0x12, 0xc1, + 0x54, 0x49, 0xca, 0x93, 0xb0, 0x7d, 0x7b, 0xcf, + 0xf0, 0xc5, 0x94, 0x43, 0x30, 0x94, 0x11, 0x8d, + 0x15, 0x79, 0x2e, 0x57, 0xb8, 0x24, 0xcd, 0x2e, + 0xc2, 0x49, 0x3d, 0x92, 0x44, 0x23, 0x0c, 0x3e, + 0xa0, 0xf9, 0xa5, 0xad, 0x2a, 0x56, 0xec, 0xf4, + 0x6d, 0x0f, 0x5b, 0xb5, 0xd4, 0x2a, 0x3f, 0x2b, + 0x17, 0x9f, 0x5d, 0x33, 0x97, 0x42, 0xd4, 0x1e, + 0x14, 0x49, 0x01, 0xfb, 0xb6, 0x72, 0xbc, 0x14, + 0x5b, 0x79, 0xf4, 0x0a, 0xc5, 0x49, 0xe1, 0x76, + 0x44, 0x78, 0x87, 0xd1, 0x8e, 0x5b, 0xd5, 0x95, + 0xad, 0x19, 0x7c, 0x0d, 0x39, 0x7f, 0x41, 0x2e, + 0xd7, 0x9e, 0xbc, 0xfd, 0x2c, 0xde, 0xfa, 0x01, + 0x7d, 0x2b, 0x04, 0xef, 0x4d, 0xf9, 0xf4, 0x5b, + 0xed, 0x05, 0x9a, 0x50, 0x35, 0xe7, 0xb0, 0xba, + 0x24, 0xea, 0x16, 0x51, 0xe1, 0x6f, 0x32, 0x08, + 0x94, 0xd6, 0x19, 0x9d, 0x0e, 0x4c, 0xc1, 0xbb, + 0x01, 0x87, 0xa5, 0x90, 0x5f, 0x6f, 0xc4, 0xed, + 0xa1, 0x4c, 0x06, 0x4d, 0x2c, 0x47, 0x24, 0xda, + 0xae, 0xd2, 0x41, 0x92, 0x1f, 0x46, 0xce, 0xec, + 0xb1, 0xcc, 0x80, 0x1e, 0xb2, 0xcb, 0x66, 0x48, + 0x22, 0xec, 0x0e, 0x47, 0xfc, 0xad, 0x17, 0xfe, + 0x7b, 0xc5, 0x4d, 0x34, 0x95, 0x40, 0xd0, 0x02, + 0x7e, 0x90, 0xaa, 0x92, 0xaf, 0x48, 0x64, 0xc5, + 0xc1, 0x56, 0xd8, 0x9b, 0x6c, 0x5f, 0x2e, 0xfa, + 0xd7, 0x84, 0xdc, 0x71, 0x65, 0x1b, 0xfb, 0xbc, + 0x21, 0xc7, 0x57, 0xf4, 0x71, 0x2e, 0x6f, 0x34, + 0x85, 0x99, 0xa8, 0x5c, 0x6f, 0x34, 0x22, 0x44, + 0x89, 0x01, 0xf9, 0x48, 0xd2, 0xe2, 0xe4, 0x71, + 0x9d, 0x48, 0x07, 0x97, 0xd4, 0x66, 0xe4, 0x4d, + 0x48, 0xa3, 0x08, 0x7f, 0x6e, 0xaa, 0x7b, 0xe9, + 0x93, 0x81, 0x03, 0x0c, 0xd2, 0x48, 0xcf, 0x3f, + 0x5f, 0xbe, 0x03, 0xfb, 0x0f, 0xad, 0xc3, 0x81, + 0xd9, 0xce, 0x88, 0x0b, 0xfa, 0xed, 0x29, 0x7e, + 0x0b, 0xa1, 0x6f, 0x4c, 0x7d, 0xe4, 0x36, 0xff, + 0xdf, 0x94, 0x1a, 0x24, 0xb3, 0x7b, 0xca, 0x24, + 0x7e, 0x3a, 0x19, 0x53, 0x13, 0x4a, 0x17, 0x58, + 0xe7, 0x16, 0x9b, 0x50, 0xd8, 0xda, 0xcc, 0x6e, + 0x05, 0x25, 0xfe, 0x16, 0xcb, 0x5b, 0xd5, 0x35, + 0x76, 0x40, 0x44, 0x96, 0x23, 0x97, 0xe2, 0x4a, + 0x72, 0x0c, 0x54, 0x43, 0xc0, 0x09, 0x85, 0x8e, + 0x15, 0x85, 0xaf, 0x3c, 0x5e, 0x5f, 0x3c, 0x2d, + 0x21, 0x42, 0x75, 0xb7, 0xe4, 0x50, 0xf9, 0x00, + 0xa3, 0x4f, 0xb1, 0x7c, 0xfe, 0x62, 0xd0, 0xe9, + 0x6d, 0x51, 0xcc, 0x83, 0xc1, 0xdc, 0x37, 0x10, + 0x90, 0x0a, 0x15, 0xd8, 0xd5, 0x02, 0xf7, 0x74, + 0xb8, 0x46, 0x84, 0xc3, 0x61, 0x17, 0x26, 0x0f, + 0xe4, 0xde, 0x1a, 0xcf, 0x42, 0x53, 0x63, 0x2f, + 0x8d, 0xf7, 0x06, 0x07, 0xc3, 0x33, 0x39, 0x59, + 0xe9, 0x17, 0xc8, 0x05, 0xd2, 0xa2, 0xae, 0x53, + 0x2c, 0x7e, 0xd0, 0x9d, 0x5c, 0xb5, 0x42, 0x9f, + 0x84, 0xd7, 0xfe, 0x93, 0x74, 0xfb, 0xbb, 0xd2, + 0x1e, 0x57, 0x4e, 0x7f, 0x79, 0xaf, 0xd2, 0xf9, + 0x5e, 0x41, 0x9e, 0x63, 0x54, 0x61, 0x47, 0x0c, + 0x92, 0x4c, 0xc9, 0xfe, 0x4f, 0xcb, 0xe5, 0x8e, + 0x65, 0xb3, 0x97, 0x1b, 0xd8, 0xd1, 0x62, 0xfd +#else + 0x30, 0x82, 0x0a, 0x34, 0x30, 0x0d, 0x06, 0x0b, + 0x2b, 0x06, 0x01, 0x04, 0x01, 0x02, 0x82, 0x0b, + 0x0c, 0x08, 0x07, 0x03, 0x82, 0x0a, 0x21, 0x00, + 0x7f, 0x5f, 0x63, 0x81, 0x6f, 0x04, 0x4c, 0xec, + 0xa8, 0xaf, 0x7b, 0x99, 0x41, 0xc6, 0xff, 0xdf, + 0x77, 0x66, 0x28, 0xc0, 0xe2, 0x58, 0xea, 0x9c, + 0x60, 0xbb, 0x03, 0x3e, 0xca, 0xa8, 0x38, 0x64, + 0xfb, 0xf7, 0x1b, 0x3f, 0xec, 0xfd, 0x0f, 0xf1, + 0x9c, 0xe4, 0xfd, 0xad, 0x83, 0xf7, 0x03, 0x66, + 0x6e, 0x7f, 0x4d, 0x42, 0xab, 0x6b, 0x73, 0x26, + 0xde, 0x6f, 0x8c, 0xc4, 0xca, 0x21, 0x66, 0x31, + 0x79, 0x57, 0x88, 0xcb, 0x1e, 0xab, 0xda, 0x1d, + 0x56, 0x70, 0xd9, 0x83, 0xa1, 0xb4, 0x83, 0xce, + 0xcc, 0x0f, 0xeb, 0xd6, 0x63, 0xbd, 0xf6, 0x02, + 0x5d, 0x5b, 0x0c, 0x17, 0x3c, 0x3e, 0x15, 0x02, + 0x22, 0xa1, 0x5d, 0xb5, 0xc5, 0x81, 0x28, 0x95, + 0x0b, 0x34, 0x2b, 0x96, 0x0a, 0xae, 0x6a, 0xa8, + 0xb5, 0x1d, 0x56, 0xbb, 0x7d, 0x83, 0x9a, 0x15, + 0xad, 0x63, 0x9e, 0x86, 0x8c, 0x6e, 0x6a, 0xa8, + 0xde, 0x55, 0xd0, 0xce, 0xc0, 0x2e, 0x05, 0xfe, + 0x1f, 0x4d, 0xd7, 0x12, 0xa4, 0x5a, 0xe9, 0x04, + 0x0d, 0x20, 0x84, 0x90, 0xb9, 0xca, 0x64, 0xe4, + 0xad, 0x2e, 0x74, 0x4b, 0x1d, 0x2f, 0xcc, 0xac, + 0xd8, 0x1a, 0x5e, 0xb2, 0x78, 0xbe, 0x61, 0xf7, + 0x36, 0xa3, 0xd1, 0x93, 0x86, 0xb5, 0x15, 0xf1, + 0x74, 0xf8, 0x9f, 0x6d, 0x6a, 0x8f, 0x6d, 0x86, + 0x8b, 0x36, 0x61, 0x10, 0xc9, 0x1a, 0x31, 0x39, + 0x09, 0xe6, 0x15, 0xa0, 0xb1, 0xfa, 0x69, 0xd4, + 0xc2, 0xb2, 0x56, 0x4c, 0x06, 0x33, 0x13, 0xc4, + 0x78, 0x53, 0x16, 0xfc, 0x52, 0x99, 0xe6, 0x27, + 0xc9, 0x3b, 0x24, 0x5c, 0x3e, 0x85, 0x73, 0x76, + 0x61, 0xa3, 0x61, 0xf0, 0x95, 0xd5, 0xb2, 0xf5, + 0x21, 0xe7, 0x09, 0xc3, 0x0c, 0x5c, 0xb0, 0x36, + 0xce, 0x45, 0x68, 0x41, 0x45, 0xcb, 0x1c, 0x36, + 0x2f, 0x3a, 0x00, 0x07, 0x56, 0xbe, 0x61, 0xd2, + 0x77, 0x37, 0x63, 0xa4, 0xdb, 0xfa, 0xa9, 0x6b, + 0x37, 0x90, 0x35, 0xd1, 0x1e, 0x27, 0x5b, 0x3e, + 0xc0, 0x0a, 0x02, 0x64, 0xe4, 0x58, 0x49, 0xab, + 0x2d, 0xc1, 0x38, 0x29, 0x3d, 0x44, 0xf9, 0xac, + 0xb7, 0x65, 0xd1, 0x5f, 0xf8, 0xce, 0x52, 0x76, + 0x22, 0x15, 0x61, 0x02, 0x1f, 0xa7, 0xcd, 0xff, + 0xeb, 0xa6, 0x7f, 0x6b, 0xba, 0x75, 0xe3, 0x09, + 0x01, 0x06, 0x41, 0x20, 0x88, 0x75, 0x64, 0x6b, + 0x97, 0x38, 0x13, 0xab, 0x4c, 0x0a, 0xd4, 0x7e, + 0xd2, 0xfa, 0x78, 0xe8, 0x9f, 0x5d, 0xf9, 0x53, + 0x30, 0x17, 0xf1, 0x10, 0x9e, 0x4a, 0x32, 0x17, + 0x3a, 0x9b, 0xb9, 0x25, 0x8e, 0xeb, 0xd9, 0x41, + 0x01, 0xa2, 0xc6, 0x58, 0x4a, 0x9f, 0xc3, 0x73, + 0xfd, 0xe2, 0xe4, 0x2c, 0x92, 0xb4, 0xa2, 0x3d, + 0x0f, 0x1f, 0x37, 0x64, 0xf1, 0x17, 0x2a, 0x8c, + 0xc6, 0xb5, 0xb0, 0x69, 0x7d, 0xfe, 0x08, 0xe0, + 0x8e, 0xaa, 0xe0, 0x08, 0xd5, 0x28, 0x92, 0x51, + 0x73, 0x8a, 0x2f, 0x7a, 0x4a, 0xbf, 0x52, 0x8d, + 0x3e, 0x9b, 0x36, 0x6a, 0xfb, 0x19, 0xf0, 0xea, + 0xfe, 0x05, 0xbd, 0x2d, 0xa9, 0x58, 0x48, 0x02, + 0xa8, 0x20, 0x9e, 0xdc, 0x04, 0x57, 0xc2, 0x0c, + 0xae, 0xc1, 0x03, 0xe7, 0x17, 0x48, 0x80, 0x00, + 0x8d, 0x1b, 0xd0, 0xc5, 0xdc, 0x2a, 0x02, 0x6e, + 0x8e, 0x54, 0xf3, 0x79, 0x31, 0x02, 0x93, 0xc5, + 0xf2, 0x55, 0xea, 0x61, 0xd0, 0xb2, 0x8e, 0xc9, + 0x74, 0x17, 0x0d, 0x38, 0xf8, 0xab, 0xf4, 0x42, + 0xd4, 0xc2, 0xdc, 0xf7, 0x1b, 0xdb, 0x65, 0x36, + 0x9f, 0x56, 0xe2, 0xeb, 0xf7, 0xe5, 0x2d, 0x45, + 0xae, 0xc0, 0x95, 0xbc, 0xe4, 0x1f, 0x22, 0xdc, + 0x0f, 0x54, 0xed, 0x14, 0xb8, 0xf1, 0x2f, 0x5d, + 0xd1, 0x79, 0xa0, 0x81, 0x17, 0x71, 0xa1, 0xd6, + 0xf0, 0x88, 0x9c, 0x1c, 0xc7, 0x95, 0x07, 0xb0, + 0xea, 0xf7, 0xd3, 0xa2, 0x55, 0xfe, 0x85, 0x65, + 0x42, 0x06, 0xec, 0xd2, 0xbe, 0x03, 0x8f, 0x63, + 0x84, 0x4b, 0xb1, 0x47, 0x48, 0x20, 0x71, 0xd2, + 0xdf, 0xc9, 0x59, 0xb0, 0x24, 0x8a, 0x6e, 0xf9, + 0x4a, 0xa1, 0x7b, 0xed, 0x11, 0xb6, 0xf9, 0x9b, + 0xf7, 0x93, 0x0e, 0xcb, 0x7a, 0x32, 0x22, 0x23, + 0x4e, 0x86, 0xce, 0xad, 0x9d, 0x1b, 0x84, 0x57, + 0xaf, 0xa5, 0x04, 0x03, 0x0a, 0xc9, 0x04, 0x97, + 0xd0, 0xce, 0x8e, 0x2a, 0x9a, 0x00, 0x15, 0xeb, + 0xac, 0x96, 0x57, 0xde, 0xe6, 0xc1, 0x2d, 0xbd, + 0xfc, 0xd6, 0x95, 0x0f, 0x5f, 0x19, 0xac, 0xaf, + 0x6c, 0xd8, 0xa6, 0x1e, 0xd8, 0xdb, 0x14, 0xfd, + 0xba, 0x0f, 0xd0, 0x3f, 0x61, 0xe3, 0x76, 0xfc, + 0x47, 0x61, 0x07, 0x24, 0x49, 0x17, 0xca, 0x24, + 0x31, 0x16, 0x26, 0x4f, 0xdc, 0x2b, 0x39, 0xae, + 0x5f, 0xfa, 0x4f, 0x82, 0xef, 0xe1, 0x41, 0x8c, + 0x3e, 0x8e, 0xa7, 0x6c, 0xf2, 0x51, 0xf7, 0x85, + 0x35, 0x6c, 0xad, 0xea, 0x32, 0x35, 0xf3, 0xc0, + 0x14, 0x17, 0xe2, 0x98, 0x27, 0x36, 0x7e, 0x60, + 0x2f, 0x01, 0x60, 0x3e, 0x18, 0xf4, 0x4e, 0xe0, + 0xf5, 0x14, 0x21, 0x81, 0x05, 0x78, 0x1c, 0x5f, + 0x4e, 0x89, 0xbb, 0x23, 0x60, 0xb1, 0x8f, 0x07, + 0x53, 0x16, 0x6e, 0xfb, 0x86, 0x07, 0x90, 0xff, + 0xa6, 0x27, 0x60, 0xe6, 0x3e, 0x92, 0x2a, 0x3c, + 0xa3, 0x57, 0xec, 0x97, 0x23, 0xaf, 0xd2, 0x44, + 0xac, 0x09, 0x87, 0xb0, 0x54, 0xe9, 0x5b, 0x50, + 0x37, 0xfa, 0x12, 0xa4, 0xcb, 0x6f, 0xed, 0x9f, + 0x29, 0x73, 0xa7, 0x09, 0x29, 0x91, 0x93, 0x5c, + 0x54, 0xf4, 0x44, 0xc2, 0x04, 0x64, 0xfc, 0xd2, + 0xf2, 0x0a, 0x0b, 0x45, 0x1f, 0xc5, 0x18, 0xf0, + 0xff, 0x10, 0x1f, 0x3a, 0x97, 0xf8, 0xb1, 0x83, + 0x0e, 0x08, 0xe2, 0x55, 0x75, 0x6a, 0x45, 0x96, + 0xf8, 0x1b, 0xdc, 0xb6, 0x57, 0x83, 0x8c, 0x28, + 0xc0, 0x4a, 0x57, 0xc6, 0xfb, 0x27, 0x3d, 0xfa, + 0x5a, 0x0d, 0x69, 0x56, 0x23, 0x66, 0x02, 0x78, + 0xca, 0xf1, 0xfa, 0xcb, 0xc1, 0xf6, 0x92, 0x1c, + 0xa0, 0xe3, 0x09, 0x7d, 0x48, 0x5e, 0x86, 0xa0, + 0x82, 0xa8, 0xf1, 0x1e, 0xe1, 0xfe, 0xc6, 0x9d, + 0x4f, 0x2e, 0xf4, 0xfc, 0xc6, 0x48, 0x1d, 0xc1, + 0x2a, 0x6a, 0xb7, 0xea, 0x46, 0x89, 0x04, 0xe9, + 0xbd, 0xf1, 0xed, 0x16, 0x76, 0xd8, 0x4b, 0x42, + 0xd5, 0x43, 0xa4, 0xfb, 0x02, 0x01, 0x54, 0x00, + 0xaf, 0x55, 0x52, 0x27, 0xff, 0x00, 0xe2, 0xbb, + 0x4a, 0xf2, 0x69, 0xb4, 0x4e, 0x6c, 0x6b, 0xa3, + 0x96, 0x4f, 0xf4, 0x65, 0x90, 0x2d, 0xc8, 0x57, + 0x1f, 0xb2, 0xf0, 0x86, 0x7b, 0x93, 0x09, 0x49, + 0x31, 0xc4, 0xf4, 0x8f, 0xc8, 0x2d, 0xac, 0x1d, + 0xfc, 0xba, 0xa4, 0xa5, 0x41, 0x90, 0x76, 0x7d, + 0x9e, 0x47, 0xdc, 0x10, 0xe6, 0x0c, 0xf7, 0x0f, + 0xa4, 0xba, 0x4f, 0xe2, 0x46, 0x38, 0x4c, 0x28, + 0xa0, 0x57, 0xb5, 0x3c, 0xb3, 0x4b, 0x8f, 0x03, + 0x04, 0xff, 0xf6, 0xec, 0x60, 0x90, 0x62, 0xfe, + 0x74, 0x76, 0x48, 0xb3, 0xf4, 0x0a, 0x6a, 0x5a, + 0x5b, 0xad, 0xc8, 0x54, 0x62, 0x11, 0x52, 0xd9, + 0x84, 0x1a, 0x09, 0x4b, 0xca, 0x66, 0xaa, 0x3c, + 0x36, 0x08, 0x9d, 0x58, 0xd0, 0x4a, 0x3a, 0x8b, + 0x24, 0xe0, 0x80, 0x9f, 0xe3, 0x76, 0xb6, 0x07, + 0xb1, 0xbc, 0x00, 0x98, 0xb0, 0xc1, 0xe0, 0xf6, + 0x1f, 0x4d, 0xa8, 0xd1, 0x69, 0x44, 0x9c, 0x33, + 0xb0, 0x0f, 0x9c, 0xc9, 0x0c, 0x8c, 0xbc, 0x03, + 0x58, 0x81, 0x76, 0xab, 0x0d, 0xef, 0x25, 0x5a, + 0xf6, 0xab, 0x3b, 0xf1, 0x1f, 0x97, 0x12, 0x8e, + 0x7f, 0x28, 0x77, 0x26, 0x18, 0xc4, 0xc4, 0xda, + 0x2c, 0x43, 0x57, 0xd2, 0x1f, 0x67, 0x95, 0x40, + 0x2c, 0x94, 0x41, 0x69, 0x22, 0x8a, 0x24, 0xd9, + 0xc7, 0xfc, 0xea, 0x49, 0x83, 0x8f, 0x5d, 0x2e, + 0x9d, 0xac, 0x17, 0xb6, 0xe0, 0xc4, 0xe7, 0xe6, + 0xd5, 0xc2, 0x73, 0xa1, 0x8f, 0x33, 0x14, 0x02, + 0xae, 0x01, 0x9f, 0x6f, 0x40, 0x92, 0x4e, 0x03, + 0xc2, 0xa9, 0xf1, 0x36, 0x78, 0xe4, 0xde, 0x39, + 0x4d, 0x29, 0x2e, 0xc2, 0x00, 0x93, 0x79, 0xe4, + 0xb2, 0x29, 0x4b, 0x81, 0x5c, 0x06, 0x06, 0xbc, + 0xc1, 0x01, 0x1c, 0xa7, 0x08, 0xf7, 0x47, 0x1f, + 0x52, 0x4f, 0xdf, 0x94, 0x1e, 0xe6, 0x89, 0xe6, + 0x26, 0x71, 0x2e, 0xa2, 0xd2, 0xfe, 0x04, 0xf2, + 0x12, 0x4c, 0x06, 0x78, 0x34, 0xc0, 0xb9, 0x76, + 0x62, 0x3b, 0x72, 0x25, 0x8c, 0x0d, 0x73, 0x24, + 0xcf, 0x4b, 0x4c, 0x47, 0x20, 0x9d, 0x04, 0x7f, + 0x86, 0x2c, 0x45, 0xb8, 0xfe, 0xb2, 0xaa, 0x36, + 0xf8, 0xe0, 0x24, 0x25, 0x05, 0x23, 0x12, 0x16, + 0xbf, 0x64, 0x10, 0xdd, 0xe4, 0xc0, 0xb0, 0x85, + 0xa7, 0xd3, 0xd1, 0x18, 0x1b, 0x81, 0x6b, 0x94, + 0xfd, 0x07, 0x43, 0xdd, 0x12, 0x37, 0x78, 0x69, + 0xec, 0x8c, 0xd0, 0x41, 0x2c, 0x42, 0x94, 0x3e, + 0x9f, 0xe3, 0x49, 0xb3, 0xb8, 0x45, 0x0b, 0x1d, + 0xc1, 0x9b, 0x4d, 0x21, 0x85, 0x62, 0xea, 0xd1, + 0xc9, 0x12, 0x30, 0x8c, 0x4b, 0x63, 0xeb, 0x7d, + 0x02, 0x52, 0x15, 0xa1, 0x95, 0x48, 0x9f, 0xc2, + 0xce, 0xf3, 0x4b, 0xff, 0x5a, 0xb6, 0x8f, 0xce, + 0xcd, 0x42, 0x21, 0x40, 0x82, 0xad, 0x08, 0x99, + 0x4d, 0x24, 0x58, 0x25, 0xf3, 0x7e, 0x42, 0x86, + 0x06, 0x33, 0x1f, 0x53, 0xbb, 0x07, 0x33, 0xca, + 0xc0, 0x02, 0x18, 0x30, 0x3c, 0xc5, 0x67, 0x1c, + 0x32, 0x3f, 0x2d, 0x58, 0x4c, 0x24, 0x6e, 0x60, + 0x96, 0x1a, 0xf4, 0xd0, 0x55, 0xb8, 0x84, 0xf0, + 0xb9, 0x83, 0xbf, 0x3d, 0x37, 0xe4, 0xa6, 0x06, + 0x1c, 0xd1, 0xd7, 0x91, 0x24, 0xdc, 0x3f, 0xcc, + 0x71, 0xf3, 0x0c, 0x90, 0x2c, 0x1d, 0x2f, 0x90, + 0xc8, 0x3c, 0x6f, 0x2c, 0x5d, 0xad, 0x8c, 0xdf, + 0xbb, 0x0d, 0x2a, 0x7f, 0x4a, 0x34, 0x5a, 0xd9, + 0x83, 0xfd, 0x61, 0x36, 0xe0, 0x0a, 0xb3, 0xf6, + 0x69, 0xb1, 0xaf, 0x81, 0x22, 0xd6, 0x9e, 0x9a, + 0xf8, 0xa6, 0x24, 0x8e, 0x0c, 0xcb, 0x25, 0xc2, + 0xfc, 0xc5, 0x94, 0xbd, 0x23, 0x9c, 0xa9, 0xbd, + 0x76, 0x28, 0xa4, 0x55, 0x92, 0x7c, 0xe6, 0x76, + 0xf7, 0x30, 0xf8, 0x7d, 0xdc, 0x0a, 0x93, 0x9e, + 0x7c, 0x39, 0x0a, 0x70, 0xa0, 0xb2, 0x77, 0xe0, + 0x7a, 0x89, 0x50, 0xce, 0x75, 0xca, 0x2f, 0xa4, + 0x12, 0x0e, 0xcb, 0x75, 0x1f, 0x0a, 0x83, 0xe8, + 0x14, 0x80, 0xa7, 0xb0, 0xe8, 0x11, 0xca, 0x12, + 0x5e, 0xf7, 0x31, 0x65, 0xbd, 0x20, 0x3d, 0x8c, + 0xa6, 0x89, 0x83, 0x68, 0x66, 0x03, 0x28, 0x49, + 0x17, 0xc4, 0x3f, 0x43, 0x02, 0x9b, 0xf8, 0xed, + 0xae, 0x8e, 0x68, 0xbc, 0x8e, 0x39, 0xe7, 0x15, + 0x32, 0x45, 0x66, 0x2c, 0x1f, 0xce, 0x56, 0xc7, + 0xc0, 0x15, 0x52, 0x19, 0x40, 0xcf, 0x87, 0x20, + 0xcd, 0x3d, 0xec, 0x90, 0x8d, 0x04, 0x01, 0x31, + 0x0b, 0x74, 0x80, 0x6e, 0x61, 0xa7, 0xf3, 0x4c, + 0xb2, 0x16, 0x00, 0xd5, 0xdb, 0xcc, 0xbb, 0x2c, + 0x9f, 0xb6, 0x02, 0x4a, 0xcf, 0x71, 0x06, 0xfd, + 0x60, 0xe0, 0x00, 0xbe, 0x22, 0xba, 0x39, 0x36, + 0xa8, 0x7e, 0xe5, 0xcb, 0xea, 0x87, 0xb1, 0xee, + 0xa2, 0x6c, 0x85, 0x94, 0x18, 0x6c, 0xab, 0x9a, + 0x93, 0xa7, 0xab, 0x4e, 0x3b, 0x85, 0xf3, 0xef, + 0x8f, 0x15, 0x74, 0x21, 0x9f, 0x5d, 0x9c, 0x22, + 0x32, 0x71, 0xb5, 0x4d, 0x7f, 0xaa, 0x85, 0xe0, + 0x05, 0x2a, 0x53, 0xbb, 0x3c, 0xab, 0xc3, 0xd2, + 0x73, 0x6e, 0x97, 0xa3, 0xfd, 0x05, 0x58, 0xaa, + 0x49, 0xc8, 0x69, 0xa9, 0x0b, 0x73, 0xd4, 0xe9, + 0x1d, 0x84, 0x60, 0x34, 0x2a, 0x09, 0xb3, 0x0f, + 0x08, 0x13, 0x67, 0x77, 0xb3, 0x24, 0xdf, 0xad, + 0xbf, 0x51, 0x71, 0x2b, 0xbe, 0x4f, 0x5d, 0xf4, + 0xe7, 0x25, 0x4c, 0x24, 0xa2, 0x4a, 0x22, 0xec, + 0xcc, 0x7c, 0x6c, 0x62, 0xee, 0x47, 0x12, 0x43, + 0x88, 0xe4, 0x71, 0xaa, 0x63, 0xaa, 0x2b, 0xed, + 0x70, 0xbf, 0x26, 0x37, 0xcc, 0xa4, 0xff, 0xe9, + 0xb6, 0x65, 0x31, 0x4d, 0x0d, 0x32, 0xd6, 0x84, + 0xb8, 0xab, 0x98, 0xa7, 0x10, 0x44, 0x77, 0xc7, + 0x2a, 0x60, 0xf0, 0xf5, 0xd5, 0xd4, 0x3a, 0x73, + 0x11, 0xa5, 0x1b, 0x18, 0x3c, 0x13, 0xfb, 0xda, + 0x76, 0x9d, 0xeb, 0x3e, 0xb9, 0x7a, 0xce, 0x02, + 0xa7, 0x5e, 0x25, 0x96, 0xd2, 0xbc, 0x85, 0x1a, + 0xd1, 0xa4, 0xe2, 0x02, 0x15, 0x08, 0x49, 0x16, + 0x7c, 0xaf, 0xc6, 0x38, 0x7b, 0x95, 0xf9, 0x37, + 0xc0, 0x87, 0x73, 0x6f, 0x01, 0xcd, 0x2b, 0xf1, + 0xe7, 0x6e, 0x47, 0x18, 0x30, 0xb8, 0x16, 0x87, + 0x1d, 0x23, 0x62, 0x22, 0x85, 0x92, 0x69, 0x46, + 0x9c, 0x65, 0xd8, 0xf1, 0x27, 0x32, 0xe4, 0x16, + 0x7f, 0x9a, 0xba, 0x46, 0x61, 0x60, 0x34, 0xe5, + 0xc0, 0x14, 0xb5, 0xde, 0x4d, 0xd1, 0x71, 0x39, + 0x26, 0xdc, 0x0c, 0x0a, 0x53, 0x9e, 0x31, 0x10, + 0x45, 0x7a, 0xf9, 0xc8, 0xfa, 0x1d, 0x69, 0x5e, + 0x25, 0xc1, 0xe2, 0x00, 0xbf, 0x94, 0xa3, 0xa2, + 0x97, 0xca, 0xb4, 0x6a, 0x89, 0x68, 0xdd, 0xed, + 0x6b, 0x99, 0x5a, 0x87, 0x9e, 0xe9, 0x68, 0xe4, + 0xf2, 0xc2, 0x7e, 0x37, 0x02, 0xdf, 0x96, 0x1a, + 0x5b, 0xed, 0xa1, 0xe8, 0xdf, 0x3c, 0xf7, 0xd2, + 0x25, 0xac, 0xf7, 0x4a, 0x7f, 0x10, 0x27, 0x2b, + 0x02, 0xc7, 0x95, 0x10, 0x5a, 0xb5, 0xb0, 0xcd, + 0xa9, 0xe1, 0x36, 0xe2, 0x1c, 0x87, 0x99, 0x0e, + 0x0a, 0x44, 0xec, 0x97, 0x75, 0xa7, 0x03, 0x27, + 0x38, 0x3b, 0x16, 0x30, 0x00, 0x98, 0xbe, 0x77, + 0xfe, 0x3a, 0xac, 0x6f, 0x8f, 0x4d, 0xe1, 0xa9, + 0x9c, 0xba, 0x39, 0x52, 0xe8, 0xf7, 0xe4, 0xe6, + 0xf9, 0xe9, 0xb3, 0x57, 0x82, 0xb2, 0x23, 0xd6, + 0xa5, 0x14, 0xc0, 0x78, 0xb4, 0xa0, 0xf9, 0x96, + 0xe4, 0x03, 0xe8, 0x6c, 0x27, 0xd8, 0x37, 0x7c, + 0x8f, 0xf4, 0x80, 0x09, 0x09, 0xc9, 0x32, 0x15, + 0xe0, 0x3f, 0x37, 0xa7, 0x1a, 0x5f, 0x8c, 0xfb, + 0xdd, 0xfe, 0x6b, 0x34, 0x28, 0x53, 0x03, 0x4b, + 0x39, 0x91, 0xf2, 0x48, 0x4c, 0x2a, 0x45, 0xfe, + 0x66, 0xf7, 0x23, 0x74, 0xb8, 0x30, 0x70, 0xb4, + 0x0c, 0x2c, 0x65, 0xb1, 0x4e, 0x32, 0x0f, 0x50, + 0xbb, 0x46, 0x9b, 0x03, 0x34, 0x38, 0xfb, 0xe4, + 0x25, 0x37, 0x8d, 0x0f, 0xa1, 0x41, 0x50, 0x85, + 0x92, 0x07, 0x71, 0xff, 0x3c, 0xe6, 0xd9, 0x1d, + 0x55, 0xb7, 0x10, 0x9c, 0xea, 0x70, 0x5f, 0xa3, + 0xba, 0x84, 0x99, 0x91, 0x30, 0x3d, 0x4c, 0x98, + 0x0b, 0x1f, 0x1f, 0xcc, 0x17, 0x94, 0xdd, 0x78, + 0x7d, 0x50, 0xe5, 0xf5, 0x21, 0x88, 0x5a, 0x52, + 0x76, 0x5a, 0x97, 0xbe, 0xba, 0xa9, 0xfe, 0x82, + 0x8a, 0xb5, 0x46, 0xcf, 0x9c, 0xbe, 0xe8, 0x2f, + 0x01, 0x2f, 0x6a, 0x03, 0x8a, 0xfa, 0x4b, 0x0b, + 0xdc, 0x78, 0x79, 0x9c, 0x49, 0xc4, 0x01, 0x26, + 0x16, 0x58, 0xc6, 0xb8, 0xee, 0x6c, 0xc9, 0xa9, + 0x38, 0x7c, 0xcf, 0xf3, 0xf8, 0xd0, 0x6b, 0x99, + 0x43, 0x13, 0xe0, 0x43, 0x8e, 0xfb, 0xb2, 0xdb, + 0x61, 0x67, 0xf4, 0xfc, 0x01, 0x21, 0xd9, 0xb1, + 0x1e, 0x6c, 0x6f, 0x2a, 0x9a, 0x4b, 0x86, 0x3c, + 0x62, 0x03, 0x53, 0x83, 0x11, 0x18, 0x1a, 0x59, + 0x9e, 0x25, 0xfe, 0xdb, 0x85, 0xd0, 0xee, 0x7c, + 0x97, 0x72, 0xca, 0xf3, 0x0d, 0xd4, 0x19, 0x66, + 0x14, 0xaf, 0x46, 0x68, 0x75, 0xdb, 0x8f, 0x5f, + 0x77, 0x7f, 0xfe, 0xa9, 0xe6, 0xa1, 0x9e, 0x46, + 0x5e, 0x92, 0xda, 0xea, 0xdd, 0x89, 0x01, 0xd9, + 0xab, 0x25, 0x7d, 0xb4, 0x64, 0x50, 0x8f, 0xa3, + 0xbe, 0xe2, 0x03, 0xd5, 0xc6, 0x9c, 0xc2, 0xf8, + 0xac, 0xa4, 0x36, 0xa9, 0x37, 0x10, 0x59, 0x00, + 0x45, 0xbb, 0x55, 0x33, 0xb9, 0x6f, 0xbc, 0xa2, + 0x02, 0x9e, 0xa3, 0x1d, 0xf4, 0x17, 0x78, 0x9b, + 0xbc, 0x42, 0x4e, 0x21, 0xc3, 0xde, 0xb5, 0x70, + 0x4a, 0x23, 0x1e, 0xd4, 0x36, 0x5d, 0x7a, 0x08, + 0x37, 0x55, 0x98, 0x07, 0xa0, 0x16, 0xa3, 0x4e, + 0xa1, 0x2b, 0x96, 0x8b, 0x51, 0x63, 0x48, 0xab, + 0xc9, 0x19, 0x6f, 0x5f, 0x25, 0x9d, 0xe7, 0x25, + 0x63, 0xf0, 0x8e, 0xdb, 0x06, 0x2d, 0x42, 0x31, + 0xfd, 0x14, 0x2b, 0x7a, 0x31, 0x43, 0x04, 0xd5, + 0xe2, 0x89, 0x2e, 0xa8, 0xe4, 0x6e, 0xd5, 0xa5, + 0x21, 0x67, 0x9b, 0x92, 0x61, 0x79, 0xdd, 0xe5, + 0x44, 0x43, 0x45, 0x57, 0x13, 0xec, 0x04, 0xc1, + 0x41, 0xa3, 0x14, 0x70, 0x86, 0xda, 0x76, 0x5d, + 0xe8, 0x61, 0xd2, 0xfb, 0x7b, 0xe4, 0x71, 0x46, + 0xa3, 0x52, 0xbf, 0xf2, 0xa0, 0x3c, 0xc1, 0x90, + 0x0c, 0x2e, 0xeb, 0xb3, 0x38, 0xae, 0x13, 0x27, + 0x84, 0xe9, 0x7a, 0xd6, 0x02, 0x40, 0x84, 0xff, + 0x87, 0x1f, 0x37, 0x44, 0xd8, 0x2e, 0x93, 0xf7, + 0x0a, 0xff, 0x5b, 0x4d, 0x07, 0x82, 0xfd, 0x6e, + 0x44, 0xcc, 0x19, 0xc3, 0x7d, 0x7c, 0x31, 0xf9, + 0x0e, 0xa8, 0x1c, 0x0d, 0xcb, 0x8e, 0xe8, 0x33, + 0xb2, 0xff, 0x9e, 0x1d, 0x99, 0x7c, 0x46, 0x5b, + 0xc7, 0x28, 0xec, 0x01, 0x62, 0x82, 0xfe, 0x2a, + 0x22, 0xa3, 0x86, 0x4e, 0x47, 0xe2, 0x57, 0xf1, + 0xb4, 0x58, 0x94, 0x89, 0xe5, 0xf1, 0xcd, 0x4d, + 0x90, 0xd1, 0xa4, 0x4c, 0x34, 0x5d, 0xde, 0xdc, + 0x39, 0x63, 0x8b, 0x85, 0xfd, 0x02, 0x21, 0xf1, + 0x12, 0xa3, 0x6d, 0x65, 0x0f, 0x8d, 0xe5, 0xcd, + 0x70, 0xd5, 0x1d, 0xf8, 0x65, 0x99, 0xfb, 0xe8, + 0xb5, 0x5a, 0x09, 0x39, 0x9e, 0x09, 0x45, 0x62, + 0x22, 0x1d, 0xa2, 0x46, 0xbf, 0x75, 0x20, 0xd1, + 0xe7, 0xb0, 0x06, 0x68, 0xc3, 0x50, 0x48, 0xfc, + 0xf8, 0x5c, 0x67, 0x69, 0x68, 0x66, 0xb6, 0x81, + 0x95, 0x91, 0x81, 0x3d, 0xf6, 0x34, 0xd9, 0x4b, + 0x06, 0x35, 0x17, 0x59, 0x89, 0x18, 0x74, 0x32, + 0x50, 0xcf, 0x81, 0x16, 0x8e, 0x53, 0x9d, 0x1c, + 0xad, 0x2d, 0x8e, 0x16, 0x41, 0xda, 0xca, 0xab, + 0x78, 0x0d, 0xc9, 0x49, 0x61, 0xaa, 0x18, 0xf4, + 0x56, 0x48, 0x29, 0x8c, 0xe3, 0x9a, 0x7d, 0x58, + 0xf8, 0x99, 0x72, 0xf1, 0x78, 0xa8, 0x5a, 0x97, + 0xe3, 0x2a, 0xc6, 0xa9, 0x59, 0xde, 0xcc, 0x62, + 0xfb, 0xab, 0xc5, 0x9a, 0x0b, 0xc7, 0x16, 0x8f, + 0x18, 0x20, 0x6e, 0x01, 0x7e, 0x04, 0xef, 0x72, + 0x83, 0x61, 0xb8, 0x1a, 0x77, 0x0f, 0xd1, 0xa9, + 0x75, 0xe0, 0x4a, 0x11, 0x69, 0x9d, 0xb6, 0xc9, + 0x2e, 0xd3, 0xbf, 0xe2, 0x5b, 0x24, 0x77, 0x30, + 0x85, 0x91, 0xef, 0xa8, 0x93, 0x4e, 0xad, 0x99, + 0xad, 0xcb, 0x6d, 0x9d, 0x8f, 0xd8, 0x0f, 0xe5, + 0x41, 0xd9, 0x9e, 0x0b, 0xce, 0x33, 0xd9, 0xbb, + 0x87, 0x66, 0x2c, 0xa3, 0x0b, 0x68, 0x1b, 0xb0, + 0x71, 0x30, 0xfa, 0x15, 0x2e, 0xe8, 0xc1, 0x99, + 0x71, 0x01, 0xcc, 0xdb, 0x6f, 0x9f, 0x8a, 0xfd, + 0xb4, 0x0f, 0x35, 0xa1, 0x36, 0xf4, 0x3a, 0xc4, + 0x17, 0x77, 0x43, 0x60, 0x10, 0x18, 0xb4, 0xc2, + 0xe5, 0xc0, 0x64, 0xd8, 0x38, 0x7c, 0x05, 0x9a, + 0xfb, 0x2b, 0xb3, 0x9b, 0x9e, 0x34, 0x6b, 0x4b, + 0xc8, 0x3b, 0x77, 0xe0, 0x6f, 0x08, 0xa1, 0x7b, + 0x66, 0x69, 0x2f, 0xdb, 0x34, 0x9e, 0x98, 0x90, + 0x5b, 0x4d, 0x7b, 0xa2, 0x32, 0x8e, 0x64, 0xe6, + 0x0d, 0x75, 0xc9, 0x96, 0xe3, 0x57, 0xba, 0xad, + 0x3e, 0x3b, 0x23, 0xfb, 0x9e, 0x7f, 0xc0, 0x3c, + 0xd5, 0x41, 0x9c, 0xfb, 0xbc, 0xb3, 0x52, 0x49 +#endif +}; +#endif + +static int test_wc_dilithium_public_der_decode(void) +{ + EXPECT_DECLS; +#if defined(HAVE_DILITHIUM) && defined(WOLFSSL_WC_DILITHIUM) && \ + defined(WOLFSSL_DILITHIUM_PUBLIC_KEY) + dilithium_key* key; + word32 idx = 0; + + key = (dilithium_key*)XMALLOC(sizeof(*key), NULL, DYNAMIC_TYPE_TMP_BUFFER); + ExpectNotNull(key); + + if (key != NULL) { + XMEMSET(key, 0, sizeof(*key)); + } + + ExpectIntEQ(wc_dilithium_init(key), 0); +#ifndef WOLFSSL_NO_ML_DSA_44 + ExpectIntEQ(wc_dilithium_set_level(key, WC_ML_DSA_44), 0); +#elif !defined(WOLFSSL_NO_ML_DSA_65) + ExpectIntEQ(wc_dilithium_set_level(key, WC_ML_DSA_65), 0); +#else + ExpectIntEQ(wc_dilithium_set_level(key, WC_ML_DSA_87), 0); +#endif + ExpectIntEQ(wc_Dilithium_PublicKeyDecode(dilithium_public_der, &idx, key, + (word32)sizeof(dilithium_public_der)), 0); + + wc_dilithium_free(key); + XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER); +#endif + return EXPECT_RESULT(); +} + static int test_wc_dilithium_der(void) { EXPECT_DECLS; @@ -32217,7 +33395,7 @@ static int test_wc_dilithium_der(void) ExpectIntEQ(wc_Dilithium_PublicKeyToDer(NULL, der , DILITHIUM_MAX_DER_SIZE, 0), BAD_FUNC_ARG); ExpectIntEQ(wc_Dilithium_PublicKeyToDer(key , der , 0 , - 0), BUFFER_E); + 0), BUFFER_E ); /* Get length only. */ ExpectIntEQ(wc_Dilithium_PublicKeyToDer(key , NULL, 0 , 0), pubLen); @@ -32230,8 +33408,8 @@ static int test_wc_dilithium_der(void) ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(NULL, NULL, 0 ), BAD_FUNC_ARG); - ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(key , NULL, - 0 ), BAD_FUNC_ARG); + ExpectIntGT(wc_Dilithium_PrivateKeyToDer(key , NULL, + 0 ), 0); ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(NULL, der , 0 ), BAD_FUNC_ARG); ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(NULL, NULL, @@ -32239,15 +33417,15 @@ static int test_wc_dilithium_der(void) ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(NULL, der , DILITHIUM_MAX_DER_SIZE), BAD_FUNC_ARG); ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(key , der , - 0 ), BAD_FUNC_ARG); + 0 ), BUFFER_E); /* Get length only. */ ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(key , NULL, DILITHIUM_MAX_DER_SIZE), privDerLen); ExpectIntEQ(wc_Dilithium_KeyToDer(NULL, NULL, 0 ), BAD_FUNC_ARG); - ExpectIntEQ(wc_Dilithium_KeyToDer(key , NULL, 0 ), - BAD_FUNC_ARG); + ExpectIntGT(wc_Dilithium_KeyToDer(key , NULL, 0 ), + 0 ); ExpectIntEQ(wc_Dilithium_KeyToDer(NULL, der , 0 ), BAD_FUNC_ARG); ExpectIntEQ(wc_Dilithium_KeyToDer(NULL, NULL, DILITHIUM_MAX_DER_SIZE), @@ -32255,7 +33433,7 @@ static int test_wc_dilithium_der(void) ExpectIntEQ(wc_Dilithium_KeyToDer(NULL, der , DILITHIUM_MAX_DER_SIZE), BAD_FUNC_ARG); ExpectIntEQ(wc_Dilithium_KeyToDer(key , der , 0 ), - BAD_FUNC_ARG); + BUFFER_E ); /* Get length only. */ ExpectIntEQ(wc_Dilithium_KeyToDer(key , NULL, DILITHIUM_MAX_DER_SIZE), keyDerLen); @@ -32305,6 +33483,15 @@ static int test_wc_dilithium_der(void) ExpectIntEQ(len = wc_Dilithium_PublicKeyToDer(key, der, DILITHIUM_MAX_DER_SIZE, 1), pubDerLen); idx = 0; +{ + fprintf(stderr, "\n"); + for (int ii = 0; ii < pubDerLen; ii++) { + if ((ii % 8) == 0) fprintf(stderr, " "); + fprintf(stderr, "0x%02x,", der[ii]); + if ((ii % 8) == 7) fprintf(stderr, "\n"); + else fprintf(stderr, " "); + } +} ExpectIntEQ(wc_Dilithium_PublicKeyDecode(der, &idx, key, len), 0); ExpectIntEQ(len = wc_Dilithium_PrivateKeyToDer(key, der, @@ -41850,7 +43037,7 @@ static int test_wolfSSL_ASN1_STRING_to_UTF8(void) ExpectNotNull(file = fopen("./certs/server-cert.pem", "rb")); ExpectNotNull(x509 = wolfSSL_PEM_read_X509(file, NULL, NULL, NULL)); - if (file != NULL) + if (file != XBADFILE) fclose(file); /* wolfSSL_ASN1_STRING_to_UTF8(): NID_commonName */ @@ -44192,8 +45379,8 @@ static int test_wolfSSL_certs(void) #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_FILESYSTEM) && \ !defined(NO_RSA) X509* x509ext = NULL; -#ifdef OPENSSL_ALL X509* x509 = NULL; +#ifdef OPENSSL_ALL WOLFSSL_X509_EXTENSION* ext = NULL; ASN1_OBJECT* obj = NULL; #endif @@ -44222,6 +45409,14 @@ static int test_wolfSSL_certs(void) #endif ExpectNotNull(ssl = SSL_new(ctx)); + /* Invalid parameters. */ + ExpectIntEQ(SSL_use_certificate_file(NULL, NULL, WOLFSSL_FILETYPE_PEM), + BAD_FUNC_ARG); + ExpectIntEQ(SSL_use_certificate_file(ssl, NULL, WOLFSSL_FILETYPE_PEM), + WOLFSSL_FAILURE); + ExpectIntEQ(SSL_use_certificate_file(NULL, "./certs/server-cert.pem", + WOLFSSL_FILETYPE_PEM), BAD_FUNC_ARG); + #if !defined(NO_CHECK_PRIVATE_KEY) ExpectIntEQ(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS); #endif @@ -44230,6 +45425,16 @@ static int test_wolfSSL_certs(void) ExpectIntEQ((int)SSL_set_tlsext_debug_arg(ssl, NULL), WOLFSSL_SUCCESS); #endif /* HAVE_PK_CALLBACKS */ + /* Invalid parameters. */ + ExpectNotNull(x509 = wolfSSL_X509_new()); + ExpectIntEQ(SSL_use_certificate(NULL, NULL), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_use_certificate(ssl, NULL), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_use_certificate(NULL, x509), WOLFSSL_FAILURE); + /* No data in certificate. */ + ExpectIntEQ(SSL_use_certificate(ssl, x509), WOLFSSL_FAILURE); + wolfSSL_X509_free(x509); + x509 = NULL; + /* create and use x509 */ #ifdef OPENSSL_ALL ExpectNotNull(x509 = wolfSSL_X509_load_certificate_file(cliCertFile, @@ -44246,6 +45451,15 @@ static int test_wolfSSL_certs(void) #if defined(USE_CERT_BUFFERS_2048) + /* Invalid parameters. */ + ExpectIntEQ(SSL_use_certificate_ASN1(NULL, NULL, 0), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_use_certificate_ASN1(ssl, NULL, 0), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_use_certificate_ASN1(NULL, + (unsigned char*)server_cert_der_2048, 0), WOLFSSL_FAILURE); + /* No data. */ + ExpectIntEQ(SSL_use_certificate_ASN1(ssl, + (unsigned char*)server_cert_der_2048, 0), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_use_certificate_ASN1(ssl, (unsigned char*)server_cert_der_2048, sizeof_server_cert_der_2048), WOLFSSL_SUCCESS); @@ -44497,13 +45711,15 @@ static int test_wolfSSL_private_keys(void) #else ExpectNotNull(ctx = SSL_CTX_new(wolfSSLv23_client_method())); #endif - ExpectTrue(SSL_CTX_use_PrivateKey_file(ctx, svrKeyFile, WOLFSSL_FILETYPE_PEM)); + ExpectTrue(SSL_CTX_use_PrivateKey_file(ctx, svrKeyFile, + WOLFSSL_FILETYPE_PEM)); /* Have to load a cert before you can check the private key against that * certificates public key! */ #if !defined(NO_CHECK_PRIVATE_KEY) ExpectIntEQ(wolfSSL_CTX_check_private_key(ctx), WOLFSSL_FAILURE); #endif - ExpectTrue(SSL_CTX_use_certificate_file(ctx, svrCertFile, WOLFSSL_FILETYPE_PEM)); + ExpectTrue(SSL_CTX_use_certificate_file(ctx, svrCertFile, + WOLFSSL_FILETYPE_PEM)); #if !defined(NO_CHECK_PRIVATE_KEY) ExpectIntEQ(wolfSSL_CTX_check_private_key(ctx), WOLFSSL_SUCCESS); #endif @@ -44513,12 +45729,34 @@ static int test_wolfSSL_private_keys(void) ExpectIntEQ(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS); #endif + /* Invalid parameters. */ + ExpectIntEQ(SSL_use_PrivateKey_file(NULL, NULL, WOLFSSL_FILETYPE_PEM), + BAD_FUNC_ARG); + ExpectIntEQ(SSL_use_PrivateKey_file(NULL, svrKeyFile, WOLFSSL_FILETYPE_PEM), + BAD_FUNC_ARG); + ExpectIntEQ(SSL_use_PrivateKey_file(ssl, NULL, WOLFSSL_FILETYPE_PEM), + WOLFSSL_FAILURE); + #ifdef USE_CERT_BUFFERS_2048 { const unsigned char* server_key = (const unsigned char*)server_key_der_2048; unsigned char buf[FOURK_BUF]; word32 bufSz; + /* Invalid parameters. */ + ExpectIntEQ(SSL_use_RSAPrivateKey_ASN1(NULL, NULL, 0), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_use_RSAPrivateKey_ASN1(ssl, NULL, 0), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_use_RSAPrivateKey_ASN1(NULL, + (unsigned char*)client_key_der_2048, 0), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_use_PrivateKey_ASN1(0, NULL, NULL, 0), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_use_PrivateKey_ASN1(0, ssl, NULL, 0), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_use_PrivateKey_ASN1(0, NULL, (unsigned char*)server_key, 0), + WOLFSSL_FAILURE); + ExpectIntEQ(SSL_CTX_use_PrivateKey_ASN1(0, NULL, NULL, 0), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_CTX_use_PrivateKey_ASN1(0, ctx, NULL, 0), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_CTX_use_PrivateKey_ASN1(0, NULL, (unsigned char*)server_key, + 0), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_use_RSAPrivateKey_ASN1(ssl, (unsigned char*)client_key_der_2048, sizeof_client_key_der_2048), WOLFSSL_SUCCESS); @@ -44553,8 +45791,15 @@ static int test_wolfSSL_private_keys(void) ExpectIntEQ(wolfSSL_CTX_check_private_key(ctx), WOLFSSL_SUCCESS); #endif - /* pkey not set yet, expecting to fail */ - ExpectIntEQ(SSL_use_PrivateKey(ssl, pkey), WOLFSSL_FAILURE); + /* Invalid parameters. */ + ExpectNotNull(pkey = wolfSSL_EVP_PKEY_new()); + ExpectIntEQ(SSL_use_PrivateKey(NULL, NULL), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_use_PrivateKey(ssl, NULL), WOLFSSL_FAILURE); + ExpectIntEQ(SSL_use_PrivateKey(NULL, pkey), WOLFSSL_FAILURE); + /* pkey is empty - no key data to use. */ + ExpectIntEQ(SSL_use_PrivateKey(ssl, pkey), ASN_PARSE_E); + wolfSSL_EVP_PKEY_free(pkey); + pkey = NULL; /* set PKEY and test again */ ExpectNotNull(wolfSSL_d2i_PrivateKey(EVP_PKEY_RSA, &pkey, @@ -45087,7 +46332,7 @@ static int test_wolfSSL_PEM_PrivateKey_ecc(void) ExpectIntEQ(PEM_write_bio_PrivateKey(bio, pkey, NULL, NULL, 0, NULL, NULL), WOLFSSL_SUCCESS); ExpectIntGT(BIO_pending(bio), 0); - /* No parmeters. */ + /* No parameters. */ ExpectIntEQ(BIO_pending(bio), 227); /* Check if the pubkey API writes only the public key */ #ifdef WOLFSSL_KEY_GEN @@ -45925,33 +47170,127 @@ static int test_wolfSSL_tmp_dh(void) { EXPECT_DECLS; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_FILESYSTEM) && \ - !defined(NO_DSA) && !defined(NO_RSA) && !defined(NO_DH) && !defined(NO_BIO) + !defined(NO_RSA) && !defined(NO_DH) && !defined(NO_BIO) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) byte buff[6000]; + static const unsigned char p[] = { + 0xb0, 0xa1, 0x08, 0x06, 0x9c, 0x08, 0x13, 0xba, + 0x59, 0x06, 0x3c, 0xbc, 0x30, 0xd5, 0xf5, 0x00, + 0xc1, 0x4f, 0x44, 0xa7, 0xd6, 0xef, 0x4a, 0xc6, + 0x25, 0x27, 0x1c, 0xe8, 0xd2, 0x96, 0x53, 0x0a, + 0x5c, 0x91, 0xdd, 0xa2, 0xc2, 0x94, 0x84, 0xbf, + 0x7d, 0xb2, 0x44, 0x9f, 0x9b, 0xd2, 0xc1, 0x8a, + 0xc5, 0xbe, 0x72, 0x5c, 0xa7, 0xe7, 0x91, 0xe6, + 0xd4, 0x9f, 0x73, 0x07, 0x85, 0x5b, 0x66, 0x48, + 0xc7, 0x70, 0xfa, 0xb4, 0xee, 0x02, 0xc9, 0x3d, + 0x9a, 0x4a, 0xda, 0x3d, 0xc1, 0x46, 0x3e, 0x19, + 0x69, 0xd1, 0x17, 0x46, 0x07, 0xa3, 0x4d, 0x9f, + 0x2b, 0x96, 0x17, 0x39, 0x6d, 0x30, 0x8d, 0x2a, + 0xf3, 0x94, 0xd3, 0x75, 0xcf, 0xa0, 0x75, 0xe6, + 0xf2, 0x92, 0x1f, 0x1a, 0x70, 0x05, 0xaa, 0x04, + 0x83, 0x57, 0x30, 0xfb, 0xda, 0x76, 0x93, 0x38, + 0x50, 0xe8, 0x27, 0xfd, 0x63, 0xee, 0x3c, 0xe5, + 0xb7, 0xc8, 0x09, 0xae, 0x6f, 0x50, 0x35, 0x8e, + 0x84, 0xce, 0x4a, 0x00, 0xe9, 0x12, 0x7e, 0x5a, + 0x31, 0xd7, 0x33, 0xfc, 0x21, 0x13, 0x76, 0xcc, + 0x16, 0x30, 0xdb, 0x0c, 0xfc, 0xc5, 0x62, 0xa7, + 0x35, 0xb8, 0xef, 0xb7, 0xb0, 0xac, 0xc0, 0x36, + 0xf6, 0xd9, 0xc9, 0x46, 0x48, 0xf9, 0x40, 0x90, + 0x00, 0x2b, 0x1b, 0xaa, 0x6c, 0xe3, 0x1a, 0xc3, + 0x0b, 0x03, 0x9e, 0x1b, 0xc2, 0x46, 0xe4, 0x48, + 0x4e, 0x22, 0x73, 0x6f, 0xc3, 0x5f, 0xd4, 0x9a, + 0xd6, 0x30, 0x07, 0x48, 0xd6, 0x8c, 0x90, 0xab, + 0xd4, 0xf6, 0xf1, 0xe3, 0x48, 0xd3, 0x58, 0x4b, + 0xa6, 0xb9, 0xcd, 0x29, 0xbf, 0x68, 0x1f, 0x08, + 0x4b, 0x63, 0x86, 0x2f, 0x5c, 0x6b, 0xd6, 0xb6, + 0x06, 0x65, 0xf7, 0xa6, 0xdc, 0x00, 0x67, 0x6b, + 0xbb, 0xc3, 0xa9, 0x41, 0x83, 0xfb, 0xc7, 0xfa, + 0xc8, 0xe2, 0x1e, 0x7e, 0xaf, 0x00, 0x3f, 0x93 + }; + int pSz = (int)sizeof(p); +#if !defined(WOLFSSL_OLD_PRIME_CHECK) && !defined(HAVE_FIPS) && \ + !defined(HAVE_SELFTEST) + static const unsigned char bad_p[] = { + 0xb0, 0xa1, 0x08, 0x06, 0x9c, 0x08, 0x13, 0xba, + 0x59, 0x06, 0x3c, 0xbc, 0x30, 0xd5, 0xf5, 0x00, + 0xc1, 0x4f, 0x44, 0xa7, 0xd6, 0xef, 0x4a, 0xc6, + 0x25, 0x27, 0x1c, 0xe8, 0xd2, 0x96, 0x53, 0x0a, + 0x5c, 0x91, 0xdd, 0xa2, 0xc2, 0x94, 0x84, 0xbf, + 0x7d, 0xb2, 0x44, 0x9f, 0x9b, 0xd2, 0xc1, 0x8a, + 0xc5, 0xbe, 0x72, 0x5c, 0xa7, 0xe7, 0x91, 0xe6, + 0xd4, 0x9f, 0x73, 0x07, 0x85, 0x5b, 0x66, 0x48, + 0xc7, 0x70, 0xfa, 0xb4, 0xee, 0x02, 0xc9, 0x3d, + 0x9a, 0x4a, 0xda, 0x3d, 0xc1, 0x46, 0x3e, 0x19, + 0x69, 0xd1, 0x17, 0x46, 0x07, 0xa3, 0x4d, 0x9f, + 0x2b, 0x96, 0x17, 0x39, 0x6d, 0x30, 0x8d, 0x2a, + 0xf3, 0x94, 0xd3, 0x75, 0xcf, 0xa0, 0x75, 0xe6, + 0xf2, 0x92, 0x1f, 0x1a, 0x70, 0x05, 0xaa, 0x04, + 0x83, 0x57, 0x30, 0xfb, 0xda, 0x76, 0x93, 0x38, + 0x50, 0xe8, 0x27, 0xfd, 0x63, 0xee, 0x3c, 0xe5, + 0xb7, 0xc8, 0x09, 0xae, 0x6f, 0x50, 0x35, 0x8e, + 0x84, 0xce, 0x4a, 0x00, 0xe9, 0x12, 0x7e, 0x5a, + 0x31, 0xd7, 0x33, 0xfc, 0x21, 0x13, 0x76, 0xcc, + 0x16, 0x30, 0xdb, 0x0c, 0xfc, 0xc5, 0x62, 0xa7, + 0x35, 0xb8, 0xef, 0xb7, 0xb0, 0xac, 0xc0, 0x36, + 0xf6, 0xd9, 0xc9, 0x46, 0x48, 0xf9, 0x40, 0x90, + 0x00, 0x2b, 0x1b, 0xaa, 0x6c, 0xe3, 0x1a, 0xc3, + 0x0b, 0x03, 0x9e, 0x1b, 0xc2, 0x46, 0xe4, 0x48, + 0x4e, 0x22, 0x73, 0x6f, 0xc3, 0x5f, 0xd4, 0x9a, + 0xd6, 0x30, 0x07, 0x48, 0xd6, 0x8c, 0x90, 0xab, + 0xd4, 0xf6, 0xf1, 0xe3, 0x48, 0xd3, 0x58, 0x4b, + 0xa6, 0xb9, 0xcd, 0x29, 0xbf, 0x68, 0x1f, 0x08, + 0x4b, 0x63, 0x86, 0x2f, 0x5c, 0x6b, 0xd6, 0xb6, + 0x06, 0x65, 0xf7, 0xa6, 0xdc, 0x00, 0x67, 0x6b, + 0xbb, 0xc3, 0xa9, 0x41, 0x83, 0xfb, 0xc7, 0xfa, + 0xc8, 0xe2, 0x1e, 0x7e, 0xaf, 0x00, 0x3f, 0x91 + }; +#endif + static const unsigned char g[] = { 0x02 }; + int gSz = (int)sizeof(g); +#if !defined(NO_DSA) char file[] = "./certs/dsaparams.pem"; + DSA* dsa = NULL; +#else + char file[] = "./certs/dh2048.pem"; +#endif XFILE f = XBADFILE; int bytes = 0; - DSA* dsa = NULL; DH* dh = NULL; -#if defined(WOLFSSL_DH_EXTRA) && \ - (defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || defined(WOLFSSL_OPENSSH)) DH* dh2 = NULL; -#endif BIO* bio = NULL; SSL* ssl = NULL; SSL_CTX* ctx = NULL; +#ifndef NO_WOLFSSL_CLIENT + SSL* ssl_c = NULL; + SSL_CTX* ctx_c = NULL; +#endif #ifndef NO_WOLFSSL_SERVER ExpectNotNull(ctx = SSL_CTX_new(wolfSSLv23_server_method())); -#else - ExpectNotNull(ctx = SSL_CTX_new(wolfSSLv23_client_method())); +#endif +#ifndef NO_WOLFSSL_CLIENT + ExpectNotNull(ctx_c = SSL_CTX_new(wolfSSLv23_client_method())); +#ifdef NO_WOLFSSL_SERVER + ctx = ctx_c; +#endif #endif ExpectTrue(SSL_CTX_use_certificate_file(ctx, svrCertFile, WOLFSSL_FILETYPE_PEM)); ExpectTrue(SSL_CTX_use_PrivateKey_file(ctx, svrKeyFile, WOLFSSL_FILETYPE_PEM)); ExpectNotNull(ssl = SSL_new(ctx)); +#ifndef NO_WOLFSSL_CLIENT + ExpectTrue(SSL_CTX_use_certificate_file(ctx_c, svrCertFile, + WOLFSSL_FILETYPE_PEM)); + ExpectTrue(SSL_CTX_use_PrivateKey_file(ctx_c, svrKeyFile, + WOLFSSL_FILETYPE_PEM)); + ExpectNotNull(ssl_c = SSL_new(ctx_c)); +#ifdef NO_WOLFSSL_SERVER + ssl = ssl_c; +#endif +#endif + XMEMSET(buff, 0, sizeof(buff)); ExpectTrue((f = XFOPEN(file, "rb")) != XBADFILE); ExpectIntGT(bytes = (int)XFREAD(buff, 1, sizeof(buff), f), 0); if (f != XBADFILE) @@ -45959,16 +47298,91 @@ static int test_wolfSSL_tmp_dh(void) ExpectNotNull(bio = BIO_new_mem_buf((void*)buff, bytes)); +#if !defined(NO_DSA) dsa = wolfSSL_PEM_read_bio_DSAparams(bio, NULL, NULL, NULL); ExpectNotNull(dsa); dh = wolfSSL_DSA_dup_DH(dsa); +#else + dh = wolfSSL_PEM_read_bio_DHparams(bio, NULL, NULL, NULL); +#endif ExpectNotNull(dh); #if defined(WOLFSSL_DH_EXTRA) && \ (defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || defined(WOLFSSL_OPENSSH)) ExpectNotNull(dh2 = wolfSSL_DH_dup(dh)); + DH_free(dh2); + dh2 = NULL; #endif + /* Failure cases */ + ExpectIntEQ((int)wolfSSL_CTX_SetTmpDH(NULL, NULL, 0, NULL, 0), + BAD_FUNC_ARG); + ExpectIntEQ((int)wolfSSL_CTX_SetTmpDH(ctx , NULL, 0, NULL, 0), + BAD_FUNC_ARG); + ExpectIntEQ((int)wolfSSL_CTX_SetTmpDH(NULL, p , 0, NULL, 0), + BAD_FUNC_ARG); + ExpectIntEQ((int)wolfSSL_CTX_SetTmpDH(NULL, NULL, 0, g , 0), + BAD_FUNC_ARG); + ExpectIntEQ((int)wolfSSL_CTX_SetTmpDH(ctx , p , 0, NULL, 0), + BAD_FUNC_ARG); + ExpectIntEQ((int)wolfSSL_CTX_SetTmpDH(ctx , NULL, 0, g , 0), + BAD_FUNC_ARG); + ExpectIntEQ((int)wolfSSL_CTX_SetTmpDH(NULL, p , 0, g , 0), + BAD_FUNC_ARG); + ExpectIntEQ((int)wolfSSL_CTX_SetTmpDH(ctx , p , 1, g , 1), + DH_KEY_SIZE_E); + ExpectIntEQ((int)wolfSSL_CTX_SetTmpDH(ctx , buff, 6000, g , 1), + DH_KEY_SIZE_E); +#if !defined(WOLFSSL_OLD_PRIME_CHECK) && !defined(HAVE_FIPS) && \ + !defined(HAVE_SELFTEST) + ExpectIntEQ((int)wolfSSL_CTX_SetTmpDH(ctx, bad_p, pSz, g, gSz), + DH_CHECK_PUB_E); +#endif + ExpectIntEQ((int)wolfSSL_SetTmpDH(NULL, NULL, 0, NULL, 0), + WOLFSSL_FAILURE); + ExpectIntEQ((int)wolfSSL_SetTmpDH(ssl , NULL, 0, NULL, 0), + WOLFSSL_FAILURE); + ExpectIntEQ((int)wolfSSL_SetTmpDH(NULL, p , 0, NULL, 0), + WOLFSSL_FAILURE); + ExpectIntEQ((int)wolfSSL_SetTmpDH(NULL, NULL, 0, g , 0), + WOLFSSL_FAILURE); + ExpectIntEQ((int)wolfSSL_SetTmpDH(ssl , p , 0, NULL, 0), + WOLFSSL_FAILURE); + ExpectIntEQ((int)wolfSSL_SetTmpDH(ssl , NULL, 0, g , 0), + WOLFSSL_FAILURE); + ExpectIntEQ((int)wolfSSL_SetTmpDH(NULL, p , 0, g , 0), + WOLFSSL_FAILURE); + ExpectIntEQ((int)wolfSSL_SetTmpDH(ssl , p , 1, g , 1), + DH_KEY_SIZE_E); + ExpectIntEQ((int)wolfSSL_SetTmpDH(ssl , buff, 6000, g , 1), + DH_KEY_SIZE_E); +#if !defined(WOLFSSL_OLD_PRIME_CHECK) && !defined(HAVE_FIPS) && \ + !defined(HAVE_SELFTEST) +#ifndef NO_WOLFSSL_SERVER + /* Parameters will be tested later so it passes now. */ + ExpectIntEQ((int)wolfSSL_SetTmpDH(ssl, bad_p, pSz, g, gSz), + WOLFSSL_SUCCESS); +#endif +#endif +#ifndef NO_WOLFSSL_CLIENT + ExpectIntEQ((int)wolfSSL_SetTmpDH(ssl_c, p, pSz, g, gSz), + SIDE_ERROR); +#endif + ExpectIntEQ((int)SSL_CTX_set_tmp_dh(NULL, NULL), BAD_FUNC_ARG); + ExpectIntEQ((int)SSL_CTX_set_tmp_dh(ctx , NULL), BAD_FUNC_ARG); + ExpectIntEQ((int)SSL_CTX_set_tmp_dh(NULL, dh ), BAD_FUNC_ARG); + ExpectIntEQ((int)SSL_set_tmp_dh(NULL, NULL), BAD_FUNC_ARG); + ExpectIntEQ((int)SSL_set_tmp_dh(ssl , NULL), BAD_FUNC_ARG); + ExpectIntEQ((int)SSL_set_tmp_dh(NULL, dh ), BAD_FUNC_ARG); + /* No p/g to use. */ + dh2 = wolfSSL_DH_new(); + ExpectIntEQ((int)SSL_CTX_set_tmp_dh(ctx , dh2 ), WOLFSSL_FATAL_ERROR); + ExpectIntEQ((int)SSL_set_tmp_dh(ssl , dh2 ), WOLFSSL_FATAL_ERROR); + DH_free(dh2); + dh2 = NULL; + + ExpectIntEQ((int)wolfSSL_CTX_SetTmpDH(ctx, p, pSz, g, gSz), + WOLFSSL_SUCCESS); ExpectIntEQ((int)SSL_CTX_set_tmp_dh(ctx, dh), WOLFSSL_SUCCESS); #ifndef NO_WOLFSSL_SERVER ExpectIntEQ((int)SSL_set_tmp_dh(ssl, dh), WOLFSSL_SUCCESS); @@ -45977,15 +47391,22 @@ static int test_wolfSSL_tmp_dh(void) #endif BIO_free(bio); +#if !defined(NO_DSA) DSA_free(dsa); +#endif DH_free(dh); dh = NULL; -#if defined(WOLFSSL_DH_EXTRA) && \ - (defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || defined(WOLFSSL_OPENSSH)) - DH_free(dh2); - dh2 = NULL; +#ifndef NO_WOLFSSL_CLIENT + if (ssl != ssl_c) { + SSL_free(ssl_c); + } #endif SSL_free(ssl); +#ifndef NO_WOLFSSL_CLIENT + if (ctx != ctx_c) { + SSL_CTX_free(ctx_c); + } +#endif SSL_CTX_free(ctx); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif @@ -46773,8 +48194,20 @@ static int test_wolfSSL_CTX_add_extra_chain_cert(void) ExpectNotNull(x509 = wolfSSL_X509_load_certificate_file(caFile, WOLFSSL_FILETYPE_PEM)); + + /* Negative tests. */ + ExpectIntEQ((int)SSL_CTX_add_extra_chain_cert(NULL, NULL), WOLFSSL_FAILURE); + ExpectIntEQ((int)SSL_CTX_add_extra_chain_cert(ctx, NULL), WOLFSSL_FAILURE); + ExpectIntEQ((int)SSL_CTX_add_extra_chain_cert(NULL, x509), WOLFSSL_FAILURE); + ExpectIntEQ((int)SSL_CTX_add_extra_chain_cert(ctx, x509), WOLFSSL_SUCCESS); + ExpectNotNull(x509 = wolfSSL_X509_new()); + /* Empty certificate. */ + ExpectIntEQ((int)SSL_CTX_add_extra_chain_cert(ctx, x509), WOLFSSL_FAILURE); + wolfSSL_X509_free(x509); + x509 = NULL; + ExpectNotNull(x509 = wolfSSL_X509_load_certificate_file(clientFile, WOLFSSL_FILETYPE_PEM)); @@ -46863,7 +48296,6 @@ static int test_wolfSSL_CTX_add_extra_chain_cert(void) return EXPECT_RESULT(); } - #if !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) static int test_wolfSSL_ERR_peek_last_error_line(void) { @@ -48145,20 +49577,19 @@ static THREAD_RETURN WOLFSSL_THREAD server_task_ech(void* args) #endif /* HAVE_ECH && WOLFSSL_TLS13 */ #if defined(OPENSSL_EXTRA) && defined(HAVE_SECRET_CALLBACK) -static void keyLog_callback(const WOLFSSL* ssl, const char* line ) +static void keyLog_callback(const WOLFSSL* ssl, const char* line) { + XFILE fp; + const byte lf = '\n'; AssertNotNull(ssl); AssertNotNull(line); - XFILE fp; - const byte lf = '\n'; fp = XFOPEN("./MyKeyLog.txt", "a"); - XFWRITE( line, 1, strlen(line),fp); - XFWRITE( (void*)&lf,1,1,fp); + XFWRITE(line, 1, XSTRLEN(line), fp); + XFWRITE((void*)&lf, 1, 1, fp); XFFLUSH(fp); XFCLOSE(fp); - } #endif /* OPENSSL_EXTRA && HAVE_SECRET_CALLBACK */ static int test_wolfSSL_CTX_set_keylog_callback(void) @@ -48206,12 +49637,14 @@ static int test_wolfSSL_Tls12_Key_Logging_test(void) { EXPECT_DECLS; #if defined(OPENSSL_EXTRA) && defined(HAVE_SECRET_CALLBACK) -/* This test is intended for checking whether keylog callback is called - * in client during TLS handshake between the client and a server. - */ + /* This test is intended for checking whether keylog callback is called + * in client during TLS handshake between the client and a server. + */ test_ssl_cbf server_cbf; test_ssl_cbf client_cbf; XFILE fp = XBADFILE; + char buff[500]; + int found = 0; XMEMSET(&server_cbf, 0, sizeof(test_ssl_cbf)); XMEMSET(&client_cbf, 0, sizeof(test_ssl_cbf)); @@ -48228,16 +49661,12 @@ static int test_wolfSSL_Tls12_Key_Logging_test(void) ExpectIntEQ(test_wolfSSL_client_server_nofail_memio(&client_cbf, &server_cbf, NULL), TEST_SUCCESS); - XSLEEP_MS(100); /* check if the keylog file exists */ - - char buff[300] = {0}; - int found = 0; - ExpectTrue((fp = XFOPEN("./MyKeyLog.txt", "r")) != XBADFILE); XFFLUSH(fp); /* Just to make sure any buffers get flushed */ + XMEMSET(buff, 0, sizeof(buff)); while (EXPECT_SUCCESS() && XFGETS(buff, (int)sizeof(buff), fp) != NULL) { if (0 == strncmp(buff,"CLIENT_RANDOM ", sizeof("CLIENT_RANDOM ")-1)) { found = 1; @@ -48722,13 +50151,15 @@ static int test_wolfSSL_X509_STORE(void) #ifdef HAVE_CRL X509_STORE_CTX *storeCtx = NULL; - X509_CRL *crl = NULL; X509 *ca = NULL; X509 *cert = NULL; - const char crlPem[] = "./certs/crl/crl.revoked"; const char srvCert[] = "./certs/server-revoked-cert.pem"; const char caCert[] = "./certs/ca-cert.pem"; +#ifndef WOLFSSL_CRL_ALLOW_MISSING_CDP + X509_CRL *crl = NULL; + const char crlPem[] = "./certs/crl/crl.revoked"; XFILE fp = XBADFILE; +#endif /* !WOLFSSL_CRL_ALLOW_MISSING_CDP */ ExpectNotNull(store = (X509_STORE *)X509_STORE_new()); ExpectNotNull((ca = wolfSSL_X509_load_certificate_file(caCert, @@ -48748,6 +50179,7 @@ static int test_wolfSSL_X509_STORE(void) X509_free(ca); ca = NULL; +#ifndef WOLFSSL_CRL_ALLOW_MISSING_CDP /* should fail to verify now after adding in CRL */ ExpectNotNull(store = (X509_STORE *)X509_STORE_new()); ExpectNotNull((ca = wolfSSL_X509_load_certificate_file(caCert, @@ -48777,6 +50209,7 @@ static int test_wolfSSL_X509_STORE(void) cert = NULL; X509_free(ca); ca = NULL; +#endif /* !WOLFSSL_CRL_ALLOW_MISSING_CDP */ #endif /* HAVE_CRL */ @@ -51497,7 +52930,7 @@ static int test_wolfSSL_X509_max_altnames(void) #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) /* Only test if max alt names has not been modified */ -#if WOLFSSL_MAX_ALT_NAMES == 128 +#if WOLFSSL_MAX_ALT_NAMES <= 1024 WOLFSSL_CTX* ctx = NULL; /* File contains a certificate encoded with 130 subject alternative names */ @@ -51911,7 +53344,7 @@ static int test_wolfSSL_X509_sign(void) ExpectIntEQ(wolfSSL_X509_add_altname(x509, "Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch", ASN_DNS_TYPE), SSL_SUCCESS); -#if defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME) +#ifdef WOLFSSL_IP_ALT_NAME { unsigned char ip4_type[] = {127,128,0,255}; unsigned char ip6_type[] = {0xdd, 0xcc, 0xba, 0xab, @@ -51944,7 +53377,7 @@ static int test_wolfSSL_X509_sign(void) #if defined(OPENSSL_ALL) && defined(WOLFSSL_ALT_NAMES) ExpectIntEQ(X509_get_ext_count(x509), 1); #endif -#if defined(WOLFSSL_ALT_NAMES) && (defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME)) +#if defined(WOLFSSL_ALT_NAMES) && defined(WOLFSSL_IP_ALT_NAME) ExpectIntEQ(wolfSSL_X509_check_ip_asc(x509, "127.128.0.255", 0), 1); ExpectIntEQ(wolfSSL_X509_check_ip_asc(x509, "DDCC:BAAB:FFEE:9988:7766:5544:0033:2211", 0), 1); #endif @@ -51960,7 +53393,7 @@ static int test_wolfSSL_X509_sign(void) #ifndef WOLFSSL_ALT_NAMES /* Valid case - size should be 781-786 with 16 byte serial number */ ExpectTrue((781 + snSz <= ret) && (ret <= 781 + 5 + snSz)); -#elif defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME) +#elif defined(WOLFSSL_IP_ALT_NAME) /* Valid case - size should be 955-960 with 16 byte serial number */ ExpectTrue((939 + snSz <= ret) && (ret <= 939 + 5 + snSz)); #else @@ -56058,8 +57491,8 @@ static int test_GENERAL_NAME_set0_othername(void) { ExpectIntGT(X509_sign(x509, priv, EVP_sha256()), 0); sk_GENERAL_NAME_pop_free(gns, GENERAL_NAME_free); gns = NULL; - ExpectNotNull(gns = X509_get_ext_d2i(x509, NID_subject_alt_name, NULL, - NULL)); + ExpectNotNull(gns = (GENERAL_NAMES*)X509_get_ext_d2i(x509, + NID_subject_alt_name, NULL, NULL)); ExpectIntEQ(sk_GENERAL_NAME_num(gns), 3); @@ -56222,8 +57655,8 @@ static int test_othername_and_SID_ext(void) { 0); /* Cleanup */ - ExpectNotNull(gns = X509_get_ext_d2i(x509, NID_subject_alt_name, NULL, - NULL)); + ExpectNotNull(gns = (GENERAL_NAMES*)X509_get_ext_d2i(x509, + NID_subject_alt_name, NULL, NULL)); ExpectIntEQ(sk_GENERAL_NAME_num(gns), 1); ExpectNotNull(gn = sk_GENERAL_NAME_value(gns, 0)); ExpectIntEQ(gn->type, 0); @@ -56849,7 +58282,7 @@ static int test_wolfSSL_BIO_connect(void) server_args.signal = &ready; start_thread(test_server_nofail, &server_args, &serverThread); wait_tcp_ready(&server_args); - ExpectIntGT(XSPRINTF(buff, "%d", ready.port), 0); + ExpectIntGT(XSNPRINTF(buff, sizeof(buff), "%d", ready.port), 0); /* Start the test proper */ /* Setup the TCP BIO */ @@ -56896,7 +58329,7 @@ static int test_wolfSSL_BIO_connect(void) server_args.signal = &ready; start_thread(test_server_nofail, &server_args, &serverThread); wait_tcp_ready(&server_args); - ExpectIntGT(XSPRINTF(buff, "%d", ready.port), 0); + ExpectIntGT(XSNPRINTF(buff, sizeof(buff), "%d", ready.port), 0); ExpectNotNull(sslBio = BIO_new_ssl_connect(ctx)); ExpectIntEQ(BIO_set_conn_hostname(sslBio, (char*)wolfSSLIP), 1); @@ -56967,6 +58400,182 @@ static int test_wolfSSL_BIO_tls(void) return EXPECT_RESULT(); } + +static int test_wolfSSL_BIO_datagram(void) +{ + EXPECT_DECLS; +#if !defined(NO_BIO) && defined(WOLFSSL_DTLS) && defined(WOLFSSL_HAVE_BIO_ADDR) && defined(OPENSSL_EXTRA) + int ret; + SOCKET_T fd1 = SOCKET_INVALID, fd2 = SOCKET_INVALID; + WOLFSSL_BIO *bio1 = NULL, *bio2 = NULL; + WOLFSSL_BIO_ADDR *bio_addr1 = NULL, *bio_addr2 = NULL; + SOCKADDR_IN sin1, sin2; + socklen_t slen; + static const char test_msg[] = "I am a datagram, short and stout."; + char test_msg_recvd[sizeof(test_msg) + 10]; +#ifdef USE_WINDOWS_API + static const DWORD timeout = 250; /* ms */ +#else + static const struct timeval timeout = { 0, 250000 }; +#endif + + StartTCP(); + + if (EXPECT_SUCCESS()) { + fd1 = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + ExpectIntNE(fd1, SOCKET_INVALID); + } + if (EXPECT_SUCCESS()) { + fd2 = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + ExpectIntNE(fd2, SOCKET_INVALID); + } + + if (EXPECT_SUCCESS()) { + bio1 = wolfSSL_BIO_new_dgram(fd1, 1 /* closeF */); + ExpectNotNull(bio1); + } + + if (EXPECT_SUCCESS()) { + bio2 = wolfSSL_BIO_new_dgram(fd2, 1 /* closeF */); + ExpectNotNull(bio2); + } + + if (EXPECT_SUCCESS()) { + sin1.sin_family = AF_INET; + sin1.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + sin1.sin_port = 0; + slen = (socklen_t)sizeof(sin1); + ExpectIntEQ(bind(fd1, (const struct sockaddr *)&sin1, slen), 0); + ExpectIntEQ(setsockopt(fd1, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, sizeof(timeout)), 0); + ExpectIntEQ(getsockname(fd1, (struct sockaddr *)&sin1, &slen), 0); + } + + if (EXPECT_SUCCESS()) { + sin2.sin_family = AF_INET; + sin2.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + sin2.sin_port = 0; + slen = (socklen_t)sizeof(sin2); + ExpectIntEQ(bind(fd2, (const struct sockaddr *)&sin2, slen), 0); + ExpectIntEQ(setsockopt(fd2, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, sizeof(timeout)), 0); + ExpectIntEQ(getsockname(fd2, (struct sockaddr *)&sin2, &slen), 0); + } + + if (EXPECT_SUCCESS()) { + bio_addr1 = wolfSSL_BIO_ADDR_new(); + ExpectNotNull(bio_addr1); + } + + if (EXPECT_SUCCESS()) { + bio_addr2 = wolfSSL_BIO_ADDR_new(); + ExpectNotNull(bio_addr2); + } + + if (EXPECT_SUCCESS()) { + /* for OpenSSL compatibility, direct copying of sockaddrs into BIO_ADDRs must work right. */ + XMEMCPY(&bio_addr2->sa_in, &sin2, sizeof(sin2)); + ExpectIntEQ((int)wolfSSL_BIO_ctrl(bio1, BIO_CTRL_DGRAM_SET_PEER, 0, bio_addr2), WOLFSSL_SUCCESS); + wolfSSL_BIO_ADDR_clear(bio_addr2); + } + + test_msg_recvd[0] = 0; + ExpectIntEQ(wolfSSL_BIO_write(bio1, test_msg, sizeof(test_msg)), (int)sizeof(test_msg)); + ExpectIntEQ(wolfSSL_BIO_read(bio2, test_msg_recvd, sizeof(test_msg_recvd)), (int)sizeof(test_msg)); + ExpectIntEQ(XMEMCMP(test_msg_recvd, test_msg, sizeof(test_msg)), 0); + +#ifdef WOLFSSL_BIO_HAVE_FLOW_STATS + ExpectIntEQ(wolfSSL_BIO_number_written(bio1), sizeof(test_msg)); + ExpectIntEQ(wolfSSL_BIO_number_read(bio2), sizeof(test_msg)); +#endif + + /* bio2 should now have bio1's addr stored as its peer_addr, because the + * BIOs aren't "connected" yet. use it to send a reply. + */ + + test_msg_recvd[0] = 0; + ExpectIntEQ(wolfSSL_BIO_write(bio2, test_msg, sizeof(test_msg)), (int)sizeof(test_msg)); + ExpectIntEQ(wolfSSL_BIO_read(bio1, test_msg_recvd, sizeof(test_msg_recvd)), (int)sizeof(test_msg)); + ExpectIntEQ(XMEMCMP(test_msg_recvd, test_msg, sizeof(test_msg)), 0); + + ExpectIntEQ(wolfSSL_BIO_read(bio1, test_msg_recvd, sizeof(test_msg_recvd)), WOLFSSL_BIO_ERROR); + ExpectIntNE(BIO_should_retry(bio1), 0); + + ExpectIntEQ(wolfSSL_BIO_read(bio2, test_msg_recvd, sizeof(test_msg_recvd)), WOLFSSL_BIO_ERROR); + ExpectIntNE(BIO_should_retry(bio2), 0); + + /* now "connect" the sockets. */ + + ExpectIntEQ(connect(fd1, (const struct sockaddr *)&sin2, (socklen_t)sizeof(sin2)), 0); + ExpectIntEQ(connect(fd2, (const struct sockaddr *)&sin1, (socklen_t)sizeof(sin1)), 0); + + if (EXPECT_SUCCESS()) { + XMEMCPY(&bio_addr2->sa_in, &sin2, sizeof(sin2)); + ExpectIntEQ((int)wolfSSL_BIO_ctrl(bio1, BIO_CTRL_DGRAM_SET_CONNECTED, 0, bio_addr2), WOLFSSL_SUCCESS); + wolfSSL_BIO_ADDR_clear(bio_addr2); + } + + if (EXPECT_SUCCESS()) { + XMEMCPY(&bio_addr1->sa_in, &sin1, sizeof(sin1)); + ExpectIntEQ((int)wolfSSL_BIO_ctrl(bio2, BIO_CTRL_DGRAM_SET_CONNECTED, 0, bio_addr1), WOLFSSL_SUCCESS); + wolfSSL_BIO_ADDR_clear(bio_addr1); + } + + test_msg_recvd[0] = 0; + ExpectIntEQ(wolfSSL_BIO_write(bio2, test_msg, sizeof(test_msg)), (int)sizeof(test_msg)); + ExpectIntEQ(wolfSSL_BIO_read(bio1, test_msg_recvd, sizeof(test_msg_recvd)), (int)sizeof(test_msg)); + ExpectIntEQ(XMEMCMP(test_msg_recvd, test_msg, sizeof(test_msg)), 0); + + test_msg_recvd[0] = 0; + ExpectIntEQ(wolfSSL_BIO_write(bio1, test_msg, sizeof(test_msg)), (int)sizeof(test_msg)); + ExpectIntEQ(wolfSSL_BIO_read(bio2, test_msg_recvd, sizeof(test_msg_recvd)), (int)sizeof(test_msg)); + ExpectIntEQ(XMEMCMP(test_msg_recvd, test_msg, sizeof(test_msg)), 0); + +#ifdef __linux__ + /* now "disconnect" the sockets and attempt transmits expected to fail. */ + + sin1.sin_family = AF_UNSPEC; + ExpectIntEQ(connect(fd1, (const struct sockaddr *)&sin1, (socklen_t)sizeof(sin1)), 0); + ExpectIntEQ(connect(fd2, (const struct sockaddr *)&sin1, (socklen_t)sizeof(sin1)), 0); + sin1.sin_family = AF_INET; + + ExpectIntEQ((int)wolfSSL_BIO_ctrl(bio1, BIO_CTRL_DGRAM_SET_CONNECTED, 0, NULL), WOLFSSL_SUCCESS); + ExpectIntEQ((int)wolfSSL_BIO_ctrl(bio2, BIO_CTRL_DGRAM_SET_CONNECTED, 0, NULL), WOLFSSL_SUCCESS); + + if (EXPECT_SUCCESS()) { + sin2.sin_addr.s_addr = htonl(0xc0a8c0a8); /* 192.168.192.168 -- invalid for loopback interface. */ + XMEMCPY(&bio_addr2->sa_in, &sin2, sizeof(sin2)); + ExpectIntEQ((int)wolfSSL_BIO_ctrl(bio1, BIO_CTRL_DGRAM_SET_PEER, 0, bio_addr2), WOLFSSL_SUCCESS); + wolfSSL_BIO_ADDR_clear(bio_addr2); + } + + test_msg_recvd[0] = 0; + errno = 0; + ExpectIntEQ(wolfSSL_BIO_write(bio1, test_msg, sizeof(test_msg)), -1); + ExpectTrue((errno == EINVAL) || (errno == ENETUNREACH)); + +#endif /* __linux__ */ + + + if (bio1) { + ret = wolfSSL_BIO_free(bio1); + ExpectIntEQ(ret, WOLFSSL_SUCCESS); + } else if (fd1 != SOCKET_INVALID) + CloseSocket(fd1); + if (bio2) { + ret = wolfSSL_BIO_free(bio2); + ExpectIntEQ(ret, WOLFSSL_SUCCESS); + } else if (fd2 != SOCKET_INVALID) + CloseSocket(fd2); + if (bio_addr1) + wolfSSL_BIO_ADDR_free(bio_addr1); + if (bio_addr2) + wolfSSL_BIO_ADDR_free(bio_addr2); + +#endif /* !NO_BIO && WOLFSSL_DTLS && WOLFSSL_HAVE_BIO_ADDR && OPENSSL_EXTRA */ + + return EXPECT_RESULT(); +} + + #if defined(OPENSSL_ALL) && defined(HAVE_IO_TESTS_DEPENDENCIES) && \ defined(HAVE_HTTP_CLIENT) static THREAD_RETURN WOLFSSL_THREAD test_wolfSSL_BIO_accept_client(void* args) @@ -58402,7 +60011,10 @@ static int test_wolfSSL_d2i_PrivateKeys_bio(void) ExpectNull(d2i_RSAPrivateKey_bio(NULL, NULL)); /* RSA not set yet, expecting to fail*/ - ExpectIntEQ(SSL_CTX_use_RSAPrivateKey(ctx, rsa), BAD_FUNC_ARG); + rsa = wolfSSL_RSA_new(); + ExpectIntEQ(SSL_CTX_use_RSAPrivateKey(ctx, rsa), WOLFSSL_FAILURE); + wolfSSL_RSA_free(rsa); + rsa = NULL; #if defined(USE_CERT_BUFFERS_2048) && defined(WOLFSSL_KEY_GEN) /* set RSA using bio*/ @@ -58411,6 +60023,11 @@ static int test_wolfSSL_d2i_PrivateKeys_bio(void) ExpectNotNull(d2i_RSAPrivateKey_bio(bio, &rsa)); ExpectNotNull(rsa); + /* Tests bad parameters */ + ExpectIntEQ(SSL_CTX_use_RSAPrivateKey(NULL, NULL), BAD_FUNC_ARG); + ExpectIntEQ(SSL_CTX_use_RSAPrivateKey(ctx, NULL), BAD_FUNC_ARG); + ExpectIntEQ(SSL_CTX_use_RSAPrivateKey(NULL, rsa), BAD_FUNC_ARG); + ExpectIntEQ(SSL_CTX_use_RSAPrivateKey(ctx, rsa), WOLFSSL_SUCCESS); /* i2d RSAprivate key tests */ @@ -62833,7 +64450,7 @@ static int test_wolfSSL_OCSP_id_cmp(void) static int test_wolfSSL_OCSP_SINGLERESP_get0_id(void) { EXPECT_DECLS; -#if defined(OPENSSL_ALL) && defined(HAVE_OCSP) +#if defined(HAVE_OCSP) && defined(OPENSSL_EXTRA) WOLFSSL_OCSP_SINGLERESP single; const WOLFSSL_OCSP_CERTID* certId; @@ -62850,7 +64467,8 @@ static int test_wolfSSL_OCSP_SINGLERESP_get0_id(void) static int test_wolfSSL_OCSP_single_get0_status(void) { EXPECT_DECLS; -#if defined(OPENSSL_ALL) && defined(HAVE_OCSP) +#if defined(HAVE_OCSP) && defined(OPENSSL_EXTRA) && \ + defined(WOLFSSL_OCSP_PARSE_STATUS) WOLFSSL_OCSP_SINGLERESP single; CertStatus certStatus; WOLFSSL_ASN1_TIME* thisDate; @@ -62885,7 +64503,7 @@ static int test_wolfSSL_OCSP_single_get0_status(void) static int test_wolfSSL_OCSP_resp_count(void) { EXPECT_DECLS; -#if defined(OPENSSL_ALL) && defined(HAVE_OCSP) +#if defined(HAVE_OCSP) && defined(OPENSSL_EXTRA) WOLFSSL_OCSP_BASICRESP basicResp; WOLFSSL_OCSP_SINGLERESP singleRespOne; WOLFSSL_OCSP_SINGLERESP singleRespTwo; @@ -62906,7 +64524,7 @@ static int test_wolfSSL_OCSP_resp_count(void) static int test_wolfSSL_OCSP_resp_get0(void) { EXPECT_DECLS; -#if defined(OPENSSL_ALL) && defined(HAVE_OCSP) +#if defined(HAVE_OCSP) && defined(OPENSSL_EXTRA) WOLFSSL_OCSP_BASICRESP basicResp; WOLFSSL_OCSP_SINGLERESP singleRespOne; WOLFSSL_OCSP_SINGLERESP singleRespTwo; @@ -63110,7 +64728,8 @@ static int test_wc_CreateEncryptedPKCS8Key(void) { EXPECT_DECLS; #if defined(HAVE_PKCS8) && !defined(NO_PWDBASED) && defined(WOLFSSL_AES_256) \ - && !defined(NO_AES_CBC) && !defined(NO_RSA) && !defined(NO_SHA) + && !defined(NO_AES_CBC) && !defined(NO_RSA) && !defined(NO_SHA) && \ + !defined(NO_ASN_CRYPT) WC_RNG rng; byte* encKey = NULL; word32 encKeySz = 0; @@ -65635,6 +67254,10 @@ static int test_RsaSigFailure_cm(void) #if defined(NO_WOLFSSL_CLIENT) && defined(NO_WOLFSSL_SERVER) ExpectIntEQ(verify_sig_cm(ca_cert, cert_buf, cert_sz, TESTING_RSA), WOLFSSL_FATAL_ERROR); +#elif defined(NO_ASN_CRYPT) + /* RSA verify is not called when ASN crypt support is disabled */ + ExpectIntEQ(verify_sig_cm(ca_cert, cert_buf, cert_sz, TESTING_RSA), + WOLFSSL_SUCCESS); #else ExpectIntEQ(verify_sig_cm(ca_cert, cert_buf, cert_sz, TESTING_RSA), ASN_SIG_CONFIRM_E); @@ -65668,6 +67291,10 @@ static int test_EccSigFailure_cm(void) #if defined(NO_WOLFSSL_CLIENT) && defined(NO_WOLFSSL_SERVER) ExpectIntEQ(verify_sig_cm(ca_cert, cert_buf, cert_sz, TESTING_ECC), WOLFSSL_FATAL_ERROR); +#elif defined(NO_ASN_CRYPT) + /* ECC verify is not called when ASN crypt support is disabled */ + ExpectIntEQ(verify_sig_cm(ca_cert, cert_buf, cert_sz, TESTING_ECC), + WOLFSSL_SUCCESS); #else ExpectIntEQ(verify_sig_cm(ca_cert, cert_buf, cert_sz, TESTING_ECC), ASN_SIG_CONFIRM_E); @@ -66996,7 +68623,8 @@ static int test_wolfSSL_X509_load_crl_file(void) { EXPECT_DECLS; #if defined(OPENSSL_EXTRA) && defined(HAVE_CRL) && !defined(NO_FILESYSTEM) && \ - !defined(NO_STDIO_FILESYSTEM) && !defined(NO_RSA) && !defined(NO_BIO) + !defined(NO_STDIO_FILESYSTEM) && !defined(NO_RSA) && !defined(NO_BIO) && \ + !defined(WOLFSSL_CRL_ALLOW_MISSING_CDP) int i; char pem[][100] = { "./certs/crl/crl.pem", @@ -73527,15 +75155,15 @@ static int test_stubs_are_stubs(void) CHECKZERO_RET(wolfSSL_CTX_sess_misses, ctx, ctxN); CHECKZERO_RET(wolfSSL_CTX_sess_timeouts, ctx, ctxN); - /* when implemented this should take WOLFSSL object insted, right now + /* when implemented this should take WOLFSSL object instead, right now * always returns 0 */ - ExpectIntEQ(SSL_get_current_expansion(NULL), 0); + ExpectPtrEq(SSL_get_current_expansion(NULL), NULL); wolfSSL_CTX_free(ctx); ctx = NULL; ExpectStrEQ(SSL_COMP_get_name(NULL), "not supported"); - ExpectIntEQ(SSL_get_current_expansion(), 0); + ExpectPtrEq(SSL_get_current_expansion(NULL), NULL); #endif /* OPENSSL_EXTRA && !NO_WOLFSSL_STUB && (!NO_WOLFSSL_CLIENT || * !NO_WOLFSSL_SERVER) */ return EXPECT_RESULT(); @@ -73682,7 +75310,8 @@ static int test_wolfSSL_CTX_LoadCRL(void) return EXPECT_RESULT(); } -#if defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES) && defined(HAVE_CRL) +#if defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES) && defined(HAVE_CRL) && \ + !defined(WOLFSSL_CRL_ALLOW_MISSING_CDP) static int test_multiple_crls_same_issuer_ctx_ready(WOLFSSL_CTX* ctx) { EXPECT_DECLS; @@ -73696,7 +75325,8 @@ static int test_multiple_crls_same_issuer_ctx_ready(WOLFSSL_CTX* ctx) static int test_multiple_crls_same_issuer(void) { EXPECT_DECLS; -#if defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES) && defined(HAVE_CRL) +#if defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES) && defined(HAVE_CRL) && \ + !defined(WOLFSSL_CRL_ALLOW_MISSING_CDP) test_ssl_cbf client_cbs, server_cbs; struct { const char* server_cert; @@ -74773,9 +76403,7 @@ static int test_wolfSSL_dtls_stateless(void) #endif /* WOLFSSL_DTLS13 && WOLFSSL_SEND_HRR_COOKIE && * HAVE_IO_TESTS_DEPENDENCIES && !SINGLE_THREADED */ -#if !defined(NO_RSA) && !defined(NO_SHA) && !defined(NO_FILESYSTEM) && \ - !defined(NO_CERTS) && (!defined(NO_WOLFSSL_CLIENT) || \ - !defined(WOLFSSL_NO_CLIENT_AUTH)) +#ifdef HAVE_CERT_CHAIN_VALIDATION static int load_ca_into_cm(WOLFSSL_CERT_MANAGER* cm, char* certA) { int ret; @@ -81299,7 +82927,8 @@ static int test_certreq_sighash_algos(void) return EXPECT_RESULT(); } -#if defined(HAVE_CRL) && defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES) +#if defined(HAVE_CRL) && defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES) && \ + !defined(WOLFSSL_CRL_ALLOW_MISSING_CDP) static int test_revoked_loaded_int_cert_ctx_ready1(WOLFSSL_CTX* ctx) { EXPECT_DECLS; @@ -81349,7 +82978,8 @@ static int test_revoked_loaded_int_cert_ctx_ready2(WOLFSSL_CTX* ctx) static int test_revoked_loaded_int_cert(void) { EXPECT_DECLS; -#if defined(HAVE_CRL) && defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES) +#if defined(HAVE_CRL) && defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES) && \ + !defined(WOLFSSL_CRL_ALLOW_MISSING_CDP) test_ssl_cbf client_cbf; test_ssl_cbf server_cbf; struct { @@ -81389,7 +83019,6 @@ static int test_revoked_loaded_int_cert(void) break; printf("\t%s passed\n", test_params[i].certPemFile); } - #endif return EXPECT_RESULT(); } @@ -82702,6 +84331,60 @@ static int test_wolfSSL_SendUserCanceled(void) #endif return EXPECT_RESULT(); } +#if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES) && \ + defined(HAVE_OCSP) && \ + defined(HAVE_CERTIFICATE_STATUS_REQUEST) && \ + !defined(WOLFSSL_NO_TLS12) +static int test_ocsp_callback_fails_cb(void* ctx, const char* url, int urlSz, + byte* ocspReqBuf, int ocspReqSz, byte** ocspRespBuf) +{ + (void)ctx; + (void)url; + (void)urlSz; + (void)ocspReqBuf; + (void)ocspReqSz; + (void)ocspRespBuf; + return -1; +} +static int test_ocsp_callback_fails(void) +{ + WOLFSSL_CTX *ctx_c = NULL; + WOLFSSL_CTX *ctx_s = NULL; + WOLFSSL *ssl_c = NULL; + WOLFSSL *ssl_s = NULL; + struct test_memio_ctx test_ctx; + EXPECT_DECLS; + + XMEMSET(&test_ctx, 0, sizeof(test_ctx)); + ExpectIntEQ(test_memio_setup(&test_ctx, &ctx_c, &ctx_s, &ssl_c, &ssl_s, + wolfTLSv1_2_client_method, wolfTLSv1_2_server_method), 0); + ExpectIntEQ(wolfSSL_CTX_EnableOCSPStapling(ctx_c), WOLFSSL_SUCCESS); + ExpectIntEQ(wolfSSL_CTX_EnableOCSPStapling(ctx_s), WOLFSSL_SUCCESS); + ExpectIntEQ(wolfSSL_UseOCSPStapling(ssl_c, WOLFSSL_CSR_OCSP,0), WOLFSSL_SUCCESS); + /* override URL to avoid exing from SendCertificateStatus because of no AuthInfo on the certificate */ + ExpectIntEQ(wolfSSL_CTX_SetOCSP_OverrideURL(ctx_s, "http://dummy.test"), WOLFSSL_SUCCESS); + ExpectIntEQ(wolfSSL_CTX_EnableOCSP(ctx_s, WOLFSSL_OCSP_NO_NONCE | WOLFSSL_OCSP_URL_OVERRIDE), WOLFSSL_SUCCESS); + ExpectIntEQ(wolfSSL_CTX_load_verify_locations(ctx_s, caCertFile, 0), WOLFSSL_SUCCESS); + ExpectIntEQ(wolfSSL_SetOCSP_Cb(ssl_s, test_ocsp_callback_fails_cb, NULL, NULL), WOLFSSL_SUCCESS); + ExpectIntEQ(test_memio_do_handshake(ssl_c, ssl_s, 10, NULL), -1); + ExpectIntEQ(wolfSSL_get_error(ssl_s, -1), OCSP_INVALID_STATUS); + + wolfSSL_free(ssl_c); + wolfSSL_free(ssl_s); + wolfSSL_CTX_free(ctx_c); + wolfSSL_CTX_free(ctx_s); + + return EXPECT_RESULT(); +} +#else +static int test_ocsp_callback_fails(void) +{ + return TEST_SKIPPED; +} +#endif /* defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES) && \ + defined(HAVE_OCSP) && \ + defined(HAVE_CERTIFICATE_STATUS_REQUEST) */ + /*----------------------------------------------------------------------------* | Main @@ -83075,6 +84758,7 @@ TEST_CASE testCases[] = { TEST_DECL(test_wc_dilithium_sign), TEST_DECL(test_wc_dilithium_verify), TEST_DECL(test_wc_dilithium_check_key), + TEST_DECL(test_wc_dilithium_public_der_decode), TEST_DECL(test_wc_dilithium_der), TEST_DECL(test_wc_dilithium_make_key_from_seed), TEST_DECL(test_wc_dilithium_verify_kats), @@ -83739,9 +85423,7 @@ TEST_CASE testCases[] = { TEST_DECL(test_wolfSSL_CertManagerCRL), TEST_DECL(test_wolfSSL_CertManagerCheckOCSPResponse), TEST_DECL(test_wolfSSL_CheckOCSPResponse), -#if !defined(NO_RSA) && !defined(NO_SHA) && !defined(NO_FILESYSTEM) && \ - !defined(NO_CERTS) && (!defined(NO_WOLFSSL_CLIENT) || \ - !defined(WOLFSSL_NO_CLIENT_AUTH)) +#ifdef HAVE_CERT_CHAIN_VALIDATION TEST_DECL(test_various_pathlen_chains), #endif @@ -83819,19 +85501,28 @@ TEST_CASE testCases[] = { TEST_DECL(test_SSL_CIPHER_get_xxx), TEST_DECL(test_wolfSSL_ERR_strings), TEST_DECL(test_wolfSSL_CTX_set_cipher_list_bytes), + TEST_DECL(test_wolfSSL_CTX_use_certificate), TEST_DECL(test_wolfSSL_CTX_use_certificate_file), TEST_DECL(test_wolfSSL_CTX_use_certificate_buffer), + TEST_DECL(test_wolfSSL_use_certificate_buffer), TEST_DECL(test_wolfSSL_CTX_use_PrivateKey_file), + TEST_DECL(test_wolfSSL_CTX_use_RSAPrivateKey_file), + TEST_DECL(test_wolfSSL_use_RSAPrivateKey_file), + TEST_DECL(test_wolfSSL_CTX_use_PrivateKey), TEST_DECL(test_wolfSSL_CTX_load_verify_locations), /* Large number of memory allocations. */ TEST_DECL(test_wolfSSL_CTX_load_system_CA_certs), +#ifdef HAVE_CERT_CHAIN_VALIDATION TEST_DECL(test_wolfSSL_CertRsaPss), +#endif TEST_DECL(test_wolfSSL_CTX_load_verify_locations_ex), TEST_DECL(test_wolfSSL_CTX_load_verify_buffer_ex), TEST_DECL(test_wolfSSL_CTX_load_verify_chain_buffer_format), TEST_DECL(test_wolfSSL_CTX_add1_chain_cert), + TEST_DECL(test_wolfSSL_CTX_use_certificate_chain_buffer_format), TEST_DECL(test_wolfSSL_CTX_use_certificate_chain_file_format), + TEST_DECL(test_wolfSSL_use_certificate_chain_file), TEST_DECL(test_wolfSSL_CTX_trust_peer_cert), TEST_DECL(test_wolfSSL_CTX_LoadCRL), TEST_DECL(test_multiple_crls_same_issuer), @@ -83934,6 +85625,7 @@ TEST_CASE testCases[] = { TEST_DECL(test_wolfSSL_UseOCSPStapling), TEST_DECL(test_wolfSSL_UseOCSPStaplingV2), TEST_DECL(test_self_signed_stapling), + TEST_DECL(test_ocsp_callback_fails), /* Multicast */ TEST_DECL(test_wolfSSL_mcast), @@ -83961,6 +85653,7 @@ TEST_CASE testCases[] = { /* Can't memory test as server Asserts in thread. */ TEST_DECL(test_wolfSSL_BIO_accept), TEST_DECL(test_wolfSSL_BIO_tls), + TEST_DECL(test_wolfSSL_BIO_datagram), #endif #if defined(HAVE_PK_CALLBACKS) && !defined(WOLFSSL_NO_TLS12) diff --git a/tests/hash.c b/tests/hash.c index a2ecf58b5e..1ebbc61998 100644 --- a/tests/hash.c +++ b/tests/hash.c @@ -1,6 +1,6 @@ /* hash.c has unit tests * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/tests/quic.c b/tests/quic.c index 4c5de68bda..bc93c4a7d9 100644 --- a/tests/quic.c +++ b/tests/quic.c @@ -1,6 +1,6 @@ /* quic.c QUIC unit tests * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -848,7 +848,7 @@ static void check_crypto_records(QuicTestContext *from, OutputBuffer *out, int i rec_name = "Finished"; break; default: - sprintf(lbuffer, "%d", rec_type); + (void)XSNPRINTF(lbuffer, sizeof(lbuffer), "%d", rec_type); rec_name = lbuffer; break; } diff --git a/tests/srp.c b/tests/srp.c index a890f3cc1b..0a41361ced 100644 --- a/tests/srp.c +++ b/tests/srp.c @@ -1,6 +1,6 @@ /* srp.c SRP unit tests * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/tests/suites.c b/tests/suites.c index 7e26c3e6bc..5c367fe9c9 100644 --- a/tests/suites.c +++ b/tests/suites.c @@ -1,6 +1,6 @@ /* suites.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -1060,7 +1060,9 @@ int SuiteTest(int argc, char** argv) #if defined(HAVE_ECC) && !defined(NO_SHA256) && defined(WOLFSSL_CUSTOM_CURVES) && \ defined(HAVE_ECC_KOBLITZ) && defined(HAVE_ECC_BRAINPOOL) && \ /* Intel QuickAssist and Cavium Nitrox do not support custom curves */ \ - !defined(HAVE_INTEL_QA) && !defined(HAVE_CAVIUM_V) + !defined(HAVE_INTEL_QA) && !defined(HAVE_CAVIUM_V) && \ + /* only supported with newer ASN template code */ \ + defined(WOLFSSL_ASN_TEMPLATE) /* TLS non-NIST curves (Koblitz / Brainpool) */ XSTRLCPY(argv0[1], "tests/test-ecc-cust-curves.conf", sizeof(argv0[1])); diff --git a/tests/test-ecc-cust-curves.conf b/tests/test-ecc-cust-curves.conf index 697d96796e..6f24783e86 100644 --- a/tests/test-ecc-cust-curves.conf +++ b/tests/test-ecc-cust-curves.conf @@ -179,3 +179,19 @@ -k ./certs/ecc/bp256r1-key.pem -A ./certs/ecc/server-bp256r1-cert.pem -C + +# -- SECP256K1 without OID inside PKCS#8 -- +# server TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 +-v 3 +-l ECDHE-ECDSA-AES128-GCM-SHA256 +-c ./certs/ecc/server2-secp256k1-cert.pem +-k ./certs/ecc/secp256k1-privkey.pem +-d + +# client TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 +-v 3 +-l ECDHE-ECDSA-AES128-GCM-SHA256 +-A ./certs/ecc/ca-secp256k1-cert.pem +-x +-C + diff --git a/tests/unit.c b/tests/unit.c index 2296c9fff4..870be9875c 100644 --- a/tests/unit.c +++ b/tests/unit.c @@ -1,6 +1,6 @@ /* unit.c API unit tests driver * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -251,16 +251,14 @@ int unit_test(int argc, char** argv) SrpTest(); } -#ifndef NO_WOLFSSL_CIPHER_SUITE_TEST -#if !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) -#ifndef SINGLE_THREADED +#if !defined(NO_WOLFSSL_CIPHER_SUITE_TEST) && \ + !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) && \ + !defined(SINGLE_THREADED) if ((ret = SuiteTest(argc, argv)) != 0) { fprintf(stderr, "suite test failed with %d\n", ret); goto exit; } #endif -#endif -#endif /* NO_WOLFSSL_CIPHER_SUITE_TEST */ exit: #ifdef HAVE_WNR diff --git a/tests/unit.h b/tests/unit.h index 061e84d830..f63c4bd636 100644 --- a/tests/unit.h +++ b/tests/unit.h @@ -1,6 +1,6 @@ /* unit.c API unit tests driver * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -127,7 +127,7 @@ #define EXPECT_RESULT() \ _ret #define EXPECT_SUCCESS() \ - (_ret == TEST_SUCCESS) + ((_ret == TEST_SUCCESS) || (_ret == TEST_SKIPPED)) #define EXPECT_FAIL() \ (_ret == TEST_FAIL) diff --git a/tests/utils.h b/tests/utils.h index 7c715f49ab..ecc634e6ca 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -1,6 +1,6 @@ /* utils.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/tests/w64wrapper.c b/tests/w64wrapper.c index 926de49d14..ffaa57cad8 100644 --- a/tests/w64wrapper.c +++ b/tests/w64wrapper.c @@ -1,6 +1,6 @@ /* w64wrapper.c w64wrapper unit tests * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/testsuite/testsuite.c b/testsuite/testsuite.c index b51f5ab4c2..3e0986e155 100644 --- a/testsuite/testsuite.c +++ b/testsuite/testsuite.c @@ -1,6 +1,6 @@ /* testsuite.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -300,7 +300,7 @@ static int test_crl_monitor(void) printf("\nRunning CRL monitor test\n"); - sprintf(rounds, "%d", CRL_MONITOR_TEST_ROUNDS); + (void)XSNPRINTF(rounds, sizeof(rounds), "%d", CRL_MONITOR_TEST_ROUNDS); XMEMSET(&server_args, 0, sizeof(func_args)); XMEMSET(&client_args, 0, sizeof(func_args)); @@ -320,18 +320,19 @@ static int test_crl_monitor(void) InitTcpReady(&ready); start_thread(server_test, &server_args, &serverThread); wait_tcp_ready(&server_args); - sprintf(portNum, "%d", server_args.signal->port); + (void)XSNPRINTF(portNum, sizeof(portNum), "%d", server_args.signal->port); for (i = 0; i < CRL_MONITOR_TEST_ROUNDS; i++) { int expectFail; if (i % 2 == 0) { + /* succeed on even rounds */ - sprintf(buf, "%s/%s", tmpDir, "crl.pem"); + (void)XSNPRINTF(buf, sizeof(buf), "%s/%s", tmpDir, "crl.pem"); if (STAGE_FILE("certs/crl/crl.pem", buf) != 0) { fprintf(stderr, "[%d] Failed to copy file to %s\n", i, buf); goto cleanup; } - sprintf(buf, "%s/%s", tmpDir, "crl.revoked"); + (void)XSNPRINTF(buf, sizeof(buf), "%s/%s", tmpDir, "crl.revoked"); /* The monitor can be holding the file handle and this will cause * the remove call to fail. Let's give the monitor a some time to * finish up. */ @@ -349,12 +350,12 @@ static int test_crl_monitor(void) } else { /* fail on odd rounds */ - sprintf(buf, "%s/%s", tmpDir, "crl.revoked"); + (void)XSNPRINTF(buf, sizeof(buf), "%s/%s", tmpDir, "crl.revoked"); if (STAGE_FILE("certs/crl/crl.revoked", buf) != 0) { fprintf(stderr, "[%d] Failed to copy file to %s\n", i, buf); goto cleanup; } - sprintf(buf, "%s/%s", tmpDir, "crl.pem"); + (void)XSNPRINTF(buf, sizeof(buf), "%s/%s", tmpDir, "crl.pem"); /* The monitor can be holding the file handle and this will cause * the remove call to fail. Let's give the monitor a some time to * finish up. */ @@ -395,9 +396,9 @@ static int test_crl_monitor(void) cleanup: if (ret != 0 && i >= 0) fprintf(stderr, "test_crl_monitor failed on iteration %d\n", i); - sprintf(buf, "%s/%s", tmpDir, "crl.pem"); + (void)XSNPRINTF(buf, sizeof(buf), "%s/%s", tmpDir, "crl.pem"); rem_file(buf); - sprintf(buf, "%s/%s", tmpDir, "crl.revoked"); + (void)XSNPRINTF(buf, sizeof(buf), "%s/%s", tmpDir, "crl.revoked"); rem_file(buf); (void)rem_dir(tmpDir); return ret; diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 95291d1d95..7f0e23d5f6 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -1977,7 +1977,9 @@ static int numBlocks = NUM_BLOCKS; static word32 bench_size = BENCH_SIZE; static int base2 = 1; static int digest_stream = 1; +#ifdef HAVE_CHACHA static int encrypt_only = 0; +#endif #ifdef HAVE_AES_CBC static int cipher_same_buffer = 0; #endif @@ -9586,7 +9588,7 @@ static int lms_read_key_mem(byte* priv, word32 privSz, void* context) } static byte lms_priv[HSS_MAX_PRIVATE_KEY_LEN]; -static void bench_lms_keygen(int parm, byte* pub) +static void bench_lms_keygen(enum wc_LmsParm parm, byte* pub) { WC_RNG rng; LmsKey key; @@ -9698,7 +9700,7 @@ static void bench_lms_keygen(int parm, byte* pub) wc_FreeRng(&rng); } -static void bench_lms_sign_verify(int parm, byte* pub) +static void bench_lms_sign_verify(enum wc_LmsParm parm, byte* pub) { LmsKey key; int ret = 0; @@ -9762,6 +9764,31 @@ static void bench_lms_sign_verify(int parm, byte* pub) case WC_LMS_PARM_L1_H15_W4: case WC_LMS_PARM_L2_H10_W8: case WC_LMS_PARM_L3_H5_W2: + case WC_LMS_PARM_L1_H5_W1: + case WC_LMS_PARM_L1_H5_W2: + case WC_LMS_PARM_L1_H5_W4: + case WC_LMS_PARM_L1_H5_W8: + case WC_LMS_PARM_L1_H10_W2: + case WC_LMS_PARM_L1_H10_W4: + case WC_LMS_PARM_L1_H10_W8: + case WC_LMS_PARM_L1_H15_W8: + case WC_LMS_PARM_L1_H20_W2: + case WC_LMS_PARM_L1_H20_W4: + case WC_LMS_PARM_L1_H20_W8: + case WC_LMS_PARM_L2_H5_W2: + case WC_LMS_PARM_L2_H5_W4: + case WC_LMS_PARM_L2_H5_W8: + case WC_LMS_PARM_L2_H15_W2: + case WC_LMS_PARM_L2_H15_W4: + case WC_LMS_PARM_L2_H15_W8: + case WC_LMS_PARM_L2_H20_W2: + case WC_LMS_PARM_L2_H20_W4: + case WC_LMS_PARM_L2_H20_W8: + case WC_LMS_PARM_L3_H10_W8: + case WC_LMS_PARM_L4_H5_W2: + case WC_LMS_PARM_L4_H5_W4: + case WC_LMS_PARM_L4_H10_W4: + case WC_LMS_PARM_L4_H10_W8: default: XMEMCPY(key.pub, pub, HSS_MAX_PUBLIC_KEY_LEN); break; @@ -9853,7 +9880,7 @@ static void bench_lms_sign_verify(int parm, byte* pub) loaded = 1; - sig = XMALLOC(sigSz, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + sig = (byte *)XMALLOC(sigSz, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); if (sig == NULL) { printf("bench_lms_sign_verify malloc failed\n"); goto exit_lms_sign_verify; @@ -10638,11 +10665,15 @@ void bench_ecc(int useDeviceID, int curveId) BENCH_MAX_PENDING, MAX_ECC_BYTES, HEAP_HINT); #endif +#if !defined(NO_ASN) && defined(HAVE_ECC_SIGN) /* old scan-build misfires -Wmaybe-uninitialized on these. */ XMEMSET(sig, 0, sizeof(sig)); XMEMSET(digest, 0, sizeof(digest)); - XMEMSET(shared, 0, sizeof(shared)); +#endif +#ifdef HAVE_ECC_DHE + XMEMSET(shared, 0, sizeof(shared)); +#endif WC_CALLOC_ARRAY(genKey, ecc_key, BENCH_MAX_PENDING, sizeof(ecc_key), HEAP_HINT); @@ -14696,8 +14727,10 @@ int wolfcrypt_benchmark_main(int argc, char** argv) #endif else if (string_matches(argv[1], "-dgst_full")) digest_stream = 0; +#ifdef HAVE_CHACHA else if (string_matches(argv[1], "-enc_only")) encrypt_only = 1; +#endif #ifndef NO_RSA else if (string_matches(argv[1], "-rsa_sign")) rsa_sign_verify = 1; diff --git a/wolfcrypt/benchmark/benchmark.h b/wolfcrypt/benchmark/benchmark.h index b814a94763..5116dbe3dd 100644 --- a/wolfcrypt/benchmark/benchmark.h +++ b/wolfcrypt/benchmark/benchmark.h @@ -1,6 +1,6 @@ /* wolfcrypt/benchmark/benchmark.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index 8418fb0799..747c22c70e 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -1,6 +1,6 @@ /* aes.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -8308,7 +8308,10 @@ int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz, int ret; /* argument checks */ - if (aes == NULL || authTagSz > AES_BLOCK_SIZE || ivSz == 0) { + if (aes == NULL || authTagSz > AES_BLOCK_SIZE || ivSz == 0 || + ((authTagSz > 0) && (authTag == NULL)) || + ((authInSz > 0) && (authIn == NULL))) + { return BAD_FUNC_ARG; } @@ -8437,8 +8440,8 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz, * in and out are don't cares, as this is is the GMAC case. */ if (aes == NULL || iv == NULL || (sz != 0 && (in == NULL || out == NULL)) || authTag == NULL || authTagSz > AES_BLOCK_SIZE || authTagSz == 0 || - ivSz == 0) { - + ivSz == 0 || ((authInSz > 0) && (authIn == NULL))) + { return BAD_FUNC_ARG; } diff --git a/wolfcrypt/src/aes_asm.S b/wolfcrypt/src/aes_asm.S index f961a7975f..c8d3ca703f 100644 --- a/wolfcrypt/src/aes_asm.S +++ b/wolfcrypt/src/aes_asm.S @@ -1,6 +1,6 @@ /* aes_asm.S * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/aes_asm.asm b/wolfcrypt/src/aes_asm.asm index ef4e4b9cf2..c0cb58c636 100644 --- a/wolfcrypt/src/aes_asm.asm +++ b/wolfcrypt/src/aes_asm.asm @@ -1,6 +1,6 @@ ; /* aes_asm.asm ; * -; * Copyright (C) 2006-2023 wolfSSL Inc. +; * Copyright (C) 2006-2024 wolfSSL Inc. ; * ; * This file is part of wolfSSL. ; * diff --git a/wolfcrypt/src/aes_gcm_asm.S b/wolfcrypt/src/aes_gcm_asm.S index 4175888f12..156354c406 100644 --- a/wolfcrypt/src/aes_gcm_asm.S +++ b/wolfcrypt/src/aes_gcm_asm.S @@ -1,6 +1,6 @@ /* aes_gcm_asm.S */ /* - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/aes_gcm_asm.asm b/wolfcrypt/src/aes_gcm_asm.asm index 5b3fc7f636..38d3a9872a 100644 --- a/wolfcrypt/src/aes_gcm_asm.asm +++ b/wolfcrypt/src/aes_gcm_asm.asm @@ -1,6 +1,6 @@ ; /* aes_gcm_asm.asm */ ; /* -; * Copyright (C) 2006-2024 wolfSSL Inc. +; * Copyright (C) 2006-2024 wolfSSL Inc. ; * ; * This file is part of wolfSSL. ; * diff --git a/wolfcrypt/src/aes_gcm_x86_asm.S b/wolfcrypt/src/aes_gcm_x86_asm.S index 0559a206dd..8a384996ee 100644 --- a/wolfcrypt/src/aes_gcm_x86_asm.S +++ b/wolfcrypt/src/aes_gcm_x86_asm.S @@ -1,6 +1,6 @@ /* aes_gcm_x86_asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/aes_xts_asm.asm b/wolfcrypt/src/aes_xts_asm.asm index 7194a06b87..aea341fe76 100644 --- a/wolfcrypt/src/aes_xts_asm.asm +++ b/wolfcrypt/src/aes_xts_asm.asm @@ -1,6 +1,6 @@ ; /* aes_xts_asm.asm */ ; /* -; * Copyright (C) 2006-2024 wolfSSL Inc. +; * Copyright (C) 2006-2024 wolfSSL Inc. ; * ; * This file is part of wolfSSL. ; * diff --git a/wolfcrypt/src/arc4.c b/wolfcrypt/src/arc4.c index af298a0d2d..649d52fa3c 100644 --- a/wolfcrypt/src/arc4.c +++ b/wolfcrypt/src/arc4.c @@ -1,6 +1,6 @@ /* arc4.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/asm.c b/wolfcrypt/src/asm.c index c735ebfe48..c360990675 100644 --- a/wolfcrypt/src/asm.c +++ b/wolfcrypt/src/asm.c @@ -1,6 +1,6 @@ /* asm.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 1ee055fc9c..de916c5150 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -1,6 +1,6 @@ /* asn.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -1210,7 +1210,7 @@ static int GetASN_ObjectId(const byte* input, word32 idx, int length) /* Last octet of a sub-identifier has bit 8 clear. Last octet must be last * of a subidentifier. Ensure last octet hasn't got top bit set. */ - else if ((input[(int)idx + length - 1] & 0x80) != 0x00) { + else if ((input[(int)idx + length - 1] & 0x80) == 0x80) { WOLFSSL_MSG("OID last octet has top bit set"); ret = ASN_PARSE_E; } @@ -2430,6 +2430,19 @@ static int GetASNHeader_ex(const byte* input, byte tag, word32* inOutIdx, if ((ret == 0) && (GetLength_ex(input, &idx, &length, maxIdx, check) < 0)) { ret = ASN_PARSE_E; } + if (ret == 0 && tag == ASN_OBJECT_ID) { + if (length < 3) { + /* OID data must be at least 3 bytes. */ + WOLFSSL_MSG("OID length less than 3"); + ret = ASN_PARSE_E; + } + else if ((input[(int)idx + length - 1] & 0x80) == 0x80) { + /* Last octet of a sub-identifier has bit 8 clear. Last octet must be + * last of a subidentifier. Ensure last octet hasn't got top bit set. */ + WOLFSSL_MSG("OID last octet has top bit set"); + ret = ASN_PARSE_E; + } + } if (ret == 0) { /* Return the length of data and index after header. */ *len = length; @@ -2691,14 +2704,15 @@ int GetASNInt(const byte* input, word32* inOutIdx, int* len, return ret; if (*len > 0) { - #ifndef WOLFSSL_ASN_INT_LEAD_0_ANY /* check for invalid padding on negative integer. * c.f. X.690 (ISO/IEC 8825-2:2003 (E)) 10.4.6; RFC 5280 4.1 */ if (*len > 1) { - if ((input[*inOutIdx] == 0xff) && (input[*inOutIdx + 1] & 0x80)) - return ASN_PARSE_E; + if ((input[*inOutIdx] == 0xff) && (input[*inOutIdx + 1] & 0x80)) { + WOLFSSL_MSG("Bad INTEGER encoding of negative"); + return ASN_EXPECT_0_E; + } } #endif @@ -2708,8 +2722,10 @@ int GetASNInt(const byte* input, word32* inOutIdx, int* len, (*len)--; #ifndef WOLFSSL_ASN_INT_LEAD_0_ANY - if (*len > 0 && (input[*inOutIdx] & 0x80) == 0) - return ASN_PARSE_E; + if (*len > 0 && (input[*inOutIdx] & 0x80) == 0) { + WOLFSSL_MSG("INTEGER is negative"); + return ASN_EXPECT_0_E; + } #endif } } @@ -3474,7 +3490,7 @@ int CheckBitString(const byte* input, word32* inOutIdx, int* len, } b = input[idx]; - if (zeroBits && b != 0x00) + if (zeroBits && (b != 0x00)) return ASN_EXPECT_0_E; if (b >= 0x08) return ASN_PARSE_E; @@ -3644,7 +3660,7 @@ int StreamOctetString(const byte* inBuf, word32 inBufSz, byte* out, word32* outS /* Convert BER to DER */ -/* Pull informtation from the ASN.1 BER encoded item header */ +/* Pull information from the ASN.1 BER encoded item header */ static int GetBerHeader(const byte* data, word32* idx, word32 maxIdx, byte* pTag, word32* pLen, int* indef) { @@ -5690,8 +5706,7 @@ int EncodeObjectId(const word16* in, word32 inSz, byte* out, word32* outSz) } #endif /* HAVE_OID_ENCODING */ -#if defined(HAVE_OID_DECODING) || defined(WOLFSSL_ASN_PRINT) || \ - defined(OPENSSL_ALL) +#if defined(HAVE_OID_DECODING) || defined(WOLFSSL_ASN_PRINT) /* Encode dotted form of OID into byte array version. * * @param [in] in Byte array containing OID. @@ -5738,7 +5753,7 @@ int DecodeObjectId(const byte* in, word32 inSz, word16* out, word32* outSz) return 0; } -#endif /* HAVE_OID_DECODING || WOLFSSL_ASN_PRINT || OPENSSL_ALL */ +#endif /* HAVE_OID_DECODING || WOLFSSL_ASN_PRINT */ /* Decode the header of a BER/DER encoded OBJECT ID. * @@ -6211,7 +6226,8 @@ static int RsaPssHashOidToMgf1(word32 oid, int* mgf) return ret; } -#ifndef NO_CERTS +#if !defined(NO_CERTS) && !defined(NO_ASN_CRYPT) + /* Convert a hash OID to a fake signature OID. * * @param [in] oid Hash OID. @@ -6262,7 +6278,7 @@ static int RsaPssHashOidToSigOid(word32 oid, word32* sigOid) #endif #ifdef WOLFSSL_ASN_TEMPLATE -/* ASN tag for hashAlgorigthm. */ +/* ASN tag for hashAlgorithm. */ #define ASN_TAG_RSA_PSS_HASH (ASN_CONTEXT_SPECIFIC | 0) /* ASN tag for maskGenAlgorithm. */ #define ASN_TAG_RSA_PSS_MGF (ASN_CONTEXT_SPECIFIC | 1) @@ -6310,7 +6326,7 @@ enum { /* Number of items in ASN.1 template for an algorithm identifier. */ #define rsaPssParamsASN_Length (sizeof(rsaPssParamsASN) / sizeof(ASNItem)) #else -/* ASN tag for hashAlgorigthm. */ +/* ASN tag for hashAlgorithm. */ #define ASN_TAG_RSA_PSS_HASH (ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED | 0) /* ASN tag for maskGenAlgorithm. */ #define ASN_TAG_RSA_PSS_MGF (ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED | 1) @@ -6858,6 +6874,7 @@ enum { * On out, start of encoded key. * @param [in] sz Size of data in buffer. * @param [out] algId Key's algorithm id from PKCS #8 header. + * @param [out] eccOid ECC curve OID. * @return Length of key data on success. * @return BAD_FUNC_ARG when input or inOutIdx is NULL. * @return ASN_PARSE_E when BER encoded data does not match ASN.1 items or @@ -6867,8 +6884,8 @@ enum { * @return ASN_EXPECT_0_E when the INTEGER has the MSB set or NULL has a * non-zero length. */ -int ToTraditionalInline_ex(const byte* input, word32* inOutIdx, word32 sz, - word32* algId) +int ToTraditionalInline_ex2(const byte* input, word32* inOutIdx, word32 sz, + word32* algId, word32* eccOid) { #ifndef WOLFSSL_ASN_TEMPLATE word32 idx; @@ -6918,8 +6935,14 @@ int ToTraditionalInline_ex(const byte* input, word32* inOutIdx, word32 sz, #endif /* WC_RSA_PSS && !NO_RSA */ if (tag == ASN_OBJECT_ID) { - if (SkipObjectId(input, &idx, sz) < 0) - return ASN_PARSE_E; + if ((*algId == ECDSAk) && (eccOid != NULL)) { + if (GetObjectId(input, &idx, eccOid, oidCurveType, sz) < 0) + return ASN_PARSE_E; + } + else { + if (SkipObjectId(input, &idx, sz) < 0) + return ASN_PARSE_E; + } } ret = GetOctetString(input, &idx, &length, sz); @@ -6940,6 +6963,8 @@ int ToTraditionalInline_ex(const byte* input, word32* inOutIdx, word32 sz, byte version = 0; word32 idx; + (void)eccOid; + /* Check validity of parameters. */ if (input == NULL || inOutIdx == NULL) { return BAD_FUNC_ARG; @@ -7013,6 +7038,11 @@ int ToTraditionalInline_ex(const byte* input, word32* inOutIdx, word32 sz, if (dataASN[PKCS8KEYASN_IDX_PKEY_ALGO_NULL].tag != 0) { ret = ASN_PARSE_E; } + if (eccOid != NULL) { + ASNGetData* oidCurve = + &dataASN[PKCS8KEYASN_IDX_PKEY_ALGO_OID_CURVE]; + *eccOid = oidCurve->data.oid.sum; + } break; #endif #ifdef HAVE_ED25519 @@ -7072,6 +7102,29 @@ int ToTraditionalInline_ex(const byte* input, word32* inOutIdx, word32 sz, #endif } +/* Remove PKCS #8 header around an RSA, ECDSA, Ed25519, or Ed448. + * + * @param [in] input Buffer holding BER data. + * @param [in, out] inOutIdx On in, start of PKCS #8 encoding. + * On out, start of encoded key. + * @param [in] sz Size of data in buffer. + * @param [out] algId Key's algorithm id from PKCS #8 header. + * @return Length of key data on success. + * @return BAD_FUNC_ARG when input or inOutIdx is NULL. + * @return ASN_PARSE_E when BER encoded data does not match ASN.1 items or + * is invalid. + * @return BUFFER_E when data in buffer is too small. + * @return ASN_OBJECT_ID_E when the expected OBJECT_ID tag is not found. + * @return ASN_EXPECT_0_E when the INTEGER has the MSB set or NULL has a + * non-zero length. + */ +int ToTraditionalInline_ex(const byte* input, word32* inOutIdx, word32 sz, + word32* algId) +{ + return ToTraditionalInline_ex2(input, inOutIdx, sz, algId, NULL); +} + + /* TODO: test case */ int ToTraditionalInline(const byte* input, word32* inOutIdx, word32 sz) { @@ -9124,7 +9177,7 @@ int EncryptContent(byte* input, word32 inputSz, byte* out, word32* outSz, word32 seqSz; word32 innerSz; int ret; - int version, id, blockSz = 0; + int version, id = PBE_NONE, blockSz = 0; #ifdef WOLFSSL_SMALL_STACK byte* saltTmp = NULL; byte* cbcIv = NULL; @@ -11374,10 +11427,10 @@ void FreeAltNames(DNS_entry* altNames, void* heap) DNS_entry* tmp = altNames->next; XFREE(altNames->name, heap, DYNAMIC_TYPE_ALTNAME); - #if defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME) + #ifdef WOLFSSL_IP_ALT_NAME XFREE(altNames->ipString, heap, DYNAMIC_TYPE_ALTNAME); #endif - #if defined(OPENSSL_ALL) + #ifdef WOLFSSL_RID_ALT_NAME XFREE(altNames->ridString, heap, DYNAMIC_TYPE_ALTNAME); #endif XFREE(altNames, heap, DYNAMIC_TYPE_ALTNAME); @@ -11412,17 +11465,17 @@ DNS_entry* AltNameDup(DNS_entry* from, void* heap) ret->name = CopyString(from->name, from->len, heap, DYNAMIC_TYPE_ALTNAME); -#if defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME) +#ifdef WOLFSSL_IP_ALT_NAME ret->ipString = CopyString(from->ipString, 0, heap, DYNAMIC_TYPE_ALTNAME); #endif -#ifdef OPENSSL_ALL +#ifdef WOLFSSL_RID_ALT_NAME ret->ridString = CopyString(from->ridString, 0, heap, DYNAMIC_TYPE_ALTNAME); #endif if (ret->name == NULL -#if defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME) +#ifdef WOLFSSL_IP_ALT_NAME || (from->ipString != NULL && ret->ipString == NULL) #endif -#ifdef OPENSSL_ALL +#ifdef WOLFSSL_RID_ALT_NAME || (from->ridString != NULL && ret->ridString == NULL) #endif ) { @@ -11535,9 +11588,11 @@ static int GetCertHeader(DecodedCert* cert) cert->sigIndex) < 0) return ASN_PARSE_E; - if (wc_GetSerialNumber(cert->source, &cert->srcIdx, cert->serial, - &cert->serialSz, cert->sigIndex) < 0) - return ASN_PARSE_E; + ret = wc_GetSerialNumber(cert->source, &cert->srcIdx, cert->serial, + &cert->serialSz, cert->sigIndex); + if (ret < 0) { + return ret; + } return ret; } @@ -11957,9 +12012,13 @@ int SetAsymKeyDerPublic(const byte* pubKey, word32 pubKeyLen, DECL_ASNSETDATA(dataASN, edPubKeyASN_Length); #endif - if (pubKey == NULL) { + /* validate parameters */ + if (pubKey == NULL){ return BAD_FUNC_ARG; } + if (output != NULL && outLen == 0) { + return BUFFER_E; + } #ifndef WOLFSSL_ASN_TEMPLATE /* calculate size */ @@ -13265,7 +13324,7 @@ static const byte rdnChoice[] = { }; #endif -#if defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME) +#ifdef WOLFSSL_IP_ALT_NAME /* used to set the human readable string for the IP address with a ASN_IP_TYPE * DNS entry * return 0 on success @@ -13329,9 +13388,9 @@ static int GenerateDNSEntryIPString(DNS_entry* entry, void* heap) return ret; } -#endif /* OPENSSL_ALL || WOLFSSL_IP_ALT_NAME */ +#endif /* WOLFSSL_IP_ALT_NAME */ -#if defined(OPENSSL_ALL) +#ifdef WOLFSSL_RID_ALT_NAME /* used to set the human readable string for the registeredID with an * ASN_RID_TYPE DNS entry * return 0 on success @@ -13340,7 +13399,9 @@ static int GenerateDNSEntryRIDString(DNS_entry* entry, void* heap) { int i, j, ret = 0; int nameSz = 0; +#if !defined(WOLFCRYPT_ONLY) && defined(OPENSSL_EXTRA) int nid = 0; +#endif int tmpSize = MAX_OID_SZ; word32 oid = 0; word32 idx = 0; @@ -13360,40 +13421,46 @@ static int GenerateDNSEntryRIDString(DNS_entry* entry, void* heap) ret = GetOID((const byte*)entry->name, &idx, &oid, oidIgnoreType, entry->len); + if (ret == 0) { + #if !defined(WOLFCRYPT_ONLY) && defined(OPENSSL_EXTRA) + if ((nid = oid2nid(oid, oidCsrAttrType)) > 0) { + /* OID has known string value */ + finalName = (char*)wolfSSL_OBJ_nid2ln(nid); + } + else + #endif + { + /* Decode OBJECT_ID into dotted form array. */ + ret = DecodeObjectId((const byte*)(entry->name),(word32)entry->len, + tmpName, (word32*)&tmpSize); - if (ret == 0 && (nid = oid2nid(oid, oidCsrAttrType)) > 0) { - /* OID has known string value */ - finalName = (char*)wolfSSL_OBJ_nid2ln(nid); - } - else { - /* Decode OBJECT_ID into dotted form array. */ - ret = DecodeObjectId((const byte*)(entry->name),(word32)entry->len, - tmpName, (word32*)&tmpSize); - - if (ret == 0) { - j = 0; - /* Append each number of dotted form. */ - for (i = 0; i < tmpSize; i++) { - if (j >= MAX_OID_SZ) { - return BUFFER_E; - } + if (ret == 0) { + j = 0; + /* Append each number of dotted form. */ + for (i = 0; i < tmpSize; i++) { + if (j >= MAX_OID_SZ) { + return BUFFER_E; + } - if (i < tmpSize - 1) { - ret = XSNPRINTF(oidName + j, MAX_OID_SZ - j, "%d.", tmpName[i]); - } - else { - ret = XSNPRINTF(oidName + j, MAX_OID_SZ - j, "%d", tmpName[i]); - } + if (i < tmpSize - 1) { + ret = XSNPRINTF(oidName + j, MAX_OID_SZ - j, "%d.", + tmpName[i]); + } + else { + ret = XSNPRINTF(oidName + j, MAX_OID_SZ - j, "%d", + tmpName[i]); + } - if (ret >= 0) { - j += ret; - } - else { - return BUFFER_E; + if (ret >= 0) { + j += ret; + } + else { + return BUFFER_E; + } } + ret = 0; + finalName = oidName; } - ret = 0; - finalName = oidName; } } @@ -13414,7 +13481,7 @@ static int GenerateDNSEntryRIDString(DNS_entry* entry, void* heap) return ret; } -#endif /* OPENSSL_ALL && WOLFSSL_ASN_TEMPLATE */ +#endif /* WOLFSSL_RID_ALT_NAME */ #ifdef WOLFSSL_ASN_TEMPLATE @@ -13483,7 +13550,6 @@ static int SetDNSEntry(DecodedCert* cert, const char* str, int strLen, dnsEntry->name = (char*)XMALLOC((size_t)strLen + 1, cert->heap, DYNAMIC_TYPE_ALTNAME); if (dnsEntry->name == NULL) { - XFREE(dnsEntry, cert->heap, DYNAMIC_TYPE_ALTNAME); ret = MEMORY_E; } } @@ -13494,29 +13560,29 @@ static int SetDNSEntry(DecodedCert* cert, const char* str, int strLen, XMEMCPY(dnsEntry->name, str, (size_t)strLen); dnsEntry->name[strLen] = '\0'; -#if defined(OPENSSL_ALL) +#ifdef WOLFSSL_RID_ALT_NAME /* store registeredID as a string */ if (type == ASN_RID_TYPE) { - if ((ret = GenerateDNSEntryRIDString(dnsEntry, cert->heap)) != 0) { - XFREE(dnsEntry->name, cert->heap, DYNAMIC_TYPE_ALTNAME); - XFREE(dnsEntry, cert->heap, DYNAMIC_TYPE_ALTNAME); - } + ret = GenerateDNSEntryRIDString(dnsEntry, cert->heap); } #endif -#if defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME) +#ifdef WOLFSSL_IP_ALT_NAME /* store IP addresses as a string */ if (type == ASN_IP_TYPE) { - if ((ret = GenerateDNSEntryIPString(dnsEntry, cert->heap)) != 0) { - XFREE(dnsEntry->name, cert->heap, DYNAMIC_TYPE_ALTNAME); - XFREE(dnsEntry, cert->heap, DYNAMIC_TYPE_ALTNAME); - } + ret = GenerateDNSEntryIPString(dnsEntry, cert->heap); } +#endif } if (ret == 0) { -#endif ret = AddDNSEntryToList(entries, dnsEntry); } + /* failure cleanup */ + if (ret != 0 && dnsEntry != NULL) { + XFREE(dnsEntry->name, cert->heap, DYNAMIC_TYPE_ALTNAME); + XFREE(dnsEntry, cert->heap, DYNAMIC_TYPE_ALTNAME); + } + return ret; } #endif @@ -13775,7 +13841,7 @@ static int GetRDN(DecodedCert* cert, char* full, word32* idx, int* nid, * @param [in, out] cert Decoded certificate object. * @param [out] full Buffer to hold full name as a string. * @param [out] hash Buffer to hold hash of name. - * @param [in] nameType ISSUER or SUBJECT. + * @param [in] nameType ASN_ISSUER or ASN_SUBJECT. * @param [in] input Buffer holding certificate name. * @param [in, out] inOutIdx On in, start of certificate name. * On out, start of ASN.1 item after cert name. @@ -13830,13 +13896,13 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, #if defined(HAVE_PKCS7) || defined(WOLFSSL_CERT_EXT) /* store pointer to raw issuer */ - if (nameType == ISSUER) { + if (nameType == ASN_ISSUER) { cert->issuerRaw = &input[srcIdx]; cert->issuerRawLen = length; } #endif #if !defined(IGNORE_NAME_CONSTRAINTS) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectRaw = &input[srcIdx]; cert->subjectRawLen = length; } @@ -13917,14 +13983,14 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, #endif if (id == ASN_COMMON_NAME) { - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectCN = (char *)&input[srcIdx]; cert->subjectCNLen = strLen; cert->subjectCNEnc = (char)b; } #if (defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT)) && \ defined(WOLFSSL_HAVE_ISSUER_NAMES) - else if (nameType == ISSUER) { + else if (nameType == ASN_ISSUER) { cert->issuerCN = (char*)&input[srcIdx]; cert->issuerCNLen = strLen; cert->issuerCNEnc = (char)b; @@ -13943,7 +14009,7 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_NAME; copyLen = sizeof(WOLFSSL_NAME) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectN = (char*)&input[srcIdx]; cert->subjectNLen = strLen; cert->subjectNEnc = b; @@ -13959,7 +14025,7 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_INITIALS; copyLen = sizeof(WOLFSSL_INITIALS) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectI = (char*)&input[srcIdx]; cert->subjectILen = strLen; cert->subjectIEnc = b; @@ -13975,7 +14041,7 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_GIVEN_NAME; copyLen = sizeof(WOLFSSL_GIVEN_NAME) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectGN = (char*)&input[srcIdx]; cert->subjectGNLen = strLen; cert->subjectGNEnc = b; @@ -13991,7 +14057,7 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_DNQUALIFIER; copyLen = sizeof(WOLFSSL_DNQUALIFIER) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectDNQ = (char*)&input[srcIdx]; cert->subjectDNQLen = strLen; cert->subjectDNQEnc = b; @@ -14008,13 +14074,13 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_SUR_NAME; copyLen = sizeof(WOLFSSL_SUR_NAME) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectSN = (char*)&input[srcIdx]; cert->subjectSNLen = strLen; cert->subjectSNEnc = (char)b; } #if defined(WOLFSSL_HAVE_ISSUER_NAMES) - else if (nameType == ISSUER) { + else if (nameType == ASN_ISSUER) { cert->issuerSN = (char*)&input[srcIdx]; cert->issuerSNLen = strLen; cert->issuerSNEnc = (char)b; @@ -14031,13 +14097,13 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_COUNTRY_NAME; copyLen = sizeof(WOLFSSL_COUNTRY_NAME) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectC = (char*)&input[srcIdx]; cert->subjectCLen = strLen; cert->subjectCEnc = (char)b; } #if defined(WOLFSSL_HAVE_ISSUER_NAMES) - else if (nameType == ISSUER) { + else if (nameType == ASN_ISSUER) { cert->issuerC = (char*)&input[srcIdx]; cert->issuerCLen = strLen; cert->issuerCEnc = (char)b; @@ -14054,13 +14120,13 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_LOCALITY_NAME; copyLen = sizeof(WOLFSSL_LOCALITY_NAME) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectL = (char*)&input[srcIdx]; cert->subjectLLen = strLen; cert->subjectLEnc = (char)b; } #if defined(WOLFSSL_HAVE_ISSUER_NAMES) - else if (nameType == ISSUER) { + else if (nameType == ASN_ISSUER) { cert->issuerL = (char*)&input[srcIdx]; cert->issuerLLen = strLen; cert->issuerLEnc = (char)b; @@ -14077,13 +14143,13 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_STATE_NAME; copyLen = sizeof(WOLFSSL_STATE_NAME) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectST = (char*)&input[srcIdx]; cert->subjectSTLen = strLen; cert->subjectSTEnc = (char)b; } #if defined(WOLFSSL_HAVE_ISSUER_NAMES) - else if (nameType == ISSUER) { + else if (nameType == ASN_ISSUER) { cert->issuerST = (char*)&input[srcIdx]; cert->issuerSTLen = strLen; cert->issuerSTEnc = (char)b; @@ -14100,13 +14166,13 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_ORG_NAME; copyLen = sizeof(WOLFSSL_ORG_NAME) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectO = (char*)&input[srcIdx]; cert->subjectOLen = strLen; cert->subjectOEnc = (char)b; } #if defined(WOLFSSL_HAVE_ISSUER_NAMES) - else if (nameType == ISSUER) { + else if (nameType == ASN_ISSUER) { cert->issuerO = (char*)&input[srcIdx]; cert->issuerOLen = strLen; cert->issuerOEnc = (char)b; @@ -14123,13 +14189,13 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_ORGUNIT_NAME; copyLen = sizeof(WOLFSSL_ORGUNIT_NAME) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectOU = (char*)&input[srcIdx]; cert->subjectOULen = strLen; cert->subjectOUEnc = (char)b; } #if defined(WOLFSSL_HAVE_ISSUER_NAMES) - else if (nameType == ISSUER) { + else if (nameType == ASN_ISSUER) { cert->issuerOU = (char*)&input[srcIdx]; cert->issuerOULen = strLen; cert->issuerOUEnc = (char)b; @@ -14146,13 +14212,13 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_SERIAL_NUMBER; copyLen = sizeof(WOLFSSL_SERIAL_NUMBER) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectSND = (char*)&input[srcIdx]; cert->subjectSNDLen = strLen; cert->subjectSNDEnc = (char)b; } #if defined(WOLFSSL_HAVE_ISSUER_NAMES) - else if (nameType == ISSUER) { + else if (nameType == ASN_ISSUER) { cert->issuerSND = (char*)&input[srcIdx]; cert->issuerSNDLen = strLen; cert->issuerSNDEnc = (char)b; @@ -14169,7 +14235,7 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_USER_ID; copyLen = sizeof(WOLFSSL_USER_ID) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectUID = (char*)&input[srcIdx]; cert->subjectUIDLen = strLen; cert->subjectUIDEnc = (char)b; @@ -14186,7 +14252,7 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_STREET_ADDR_NAME; copyLen = sizeof(WOLFSSL_STREET_ADDR_NAME) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectStreet = (char*)&input[srcIdx]; cert->subjectStreetLen = strLen; cert->subjectStreetEnc = (char)b; @@ -14202,7 +14268,7 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_BUS_CAT; copyLen = sizeof(WOLFSSL_BUS_CAT) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectBC = (char*)&input[srcIdx]; cert->subjectBCLen = strLen; cert->subjectBCEnc = (char)b; @@ -14217,7 +14283,7 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_POSTAL_NAME; copyLen = sizeof(WOLFSSL_POSTAL_NAME) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectPC = (char*)&input[srcIdx]; cert->subjectPCLen = strLen; cert->subjectPCEnc = (char)b; @@ -14256,7 +14322,7 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_JOI_C; copyLen = sizeof(WOLFSSL_JOI_C) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectJC = (char*)&input[srcIdx]; cert->subjectJCLen = strLen; cert->subjectJCEnc = (char)b; @@ -14274,7 +14340,7 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, copy = WOLFSSL_JOI_ST; copyLen = sizeof(WOLFSSL_JOI_ST) - 1; #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectJS = (char*)&input[srcIdx]; cert->subjectJSLen = strLen; cert->subjectJSEnc = (char)b; @@ -14338,13 +14404,13 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, #if !defined(IGNORE_NAME_CONSTRAINTS) || \ defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectEmail = (char*)&input[srcIdx]; cert->subjectEmailLen = strLen; } #if defined(WOLFSSL_HAVE_ISSUER_NAMES) && \ (defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT)) - else if (nameType == ISSUER) { + else if (nameType == ASN_ISSUER) { cert->issuerEmail = (char*)&input[srcIdx]; cert->issuerEmailLen = strLen; } @@ -14446,8 +14512,8 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, #if (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)) && \ !defined(WOLFCRYPT_ONLY) - if (nameType == ISSUER) { -#if (defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(HAVE_LIGHTY)) && \ + if (nameType == ASN_ISSUER) { +#if (defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(HAVE_LIGHTY)) &&\ (defined(HAVE_PKCS7) || defined(WOLFSSL_CERT_EXT)) dName->rawLen = min(cert->issuerRawLen, WC_ASN_NAME_MAX); XMEMCPY(dName->raw, cert->issuerRaw, dName->rawLen); @@ -14505,14 +14571,14 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, if (ret == 0) { #if defined(HAVE_PKCS7) || defined(WOLFSSL_CERT_EXT) /* Store pointer and length to raw issuer. */ - if (nameType == ISSUER) { + if (nameType == ASN_ISSUER) { cert->issuerRaw = &input[srcIdx]; cert->issuerRawLen = len; } #endif #if !defined(IGNORE_NAME_CONSTRAINTS) || defined(WOLFSSL_CERT_EXT) /* Store pointer and length to raw subject. */ - if (nameType == SUBJECT) { + if (nameType == ASN_SUBJECT) { cert->subjectRaw = &input[srcIdx]; cert->subjectRawLen = len; } @@ -14531,7 +14597,7 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, &srcIdx, maxIdx); if (ret == 0) { /* Put RDN data into certificate. */ - ret = GetRDN(cert, full, &idx, &nid, nameType == SUBJECT, + ret = GetRDN(cert, full, &idx, &nid, nameType == ASN_SUBJECT, dataASN); } #ifdef WOLFSSL_X509_NAME_AVAILABLE @@ -14589,7 +14655,7 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, #ifdef WOLFSSL_X509_NAME_AVAILABLE /* Store X509_NAME in certificate. */ - if (nameType == ISSUER) { + if (nameType == ASN_ISSUER) { #if (defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || \ defined(HAVE_LIGHTY)) && \ (defined(HAVE_PKCS7) || defined(WOLFSSL_CERT_EXT)) @@ -14639,7 +14705,7 @@ enum { * Either the issuer or subject name. * * @param [in, out] cert Decoded certificate object. - * @param [in] nameType Type of name being decoded: ISSUER or SUBJECT. + * @param [in] nameType Type being decoded: ASN_ISSUER or ASN_SUBJECT. * @param [in] maxIdx Index of next item after certificate name. * @return 0 on success. * @return ASN_PARSE_E when BER encoded data does not match ASN.1 items or @@ -14660,7 +14726,7 @@ int GetName(DecodedCert* cert, int nameType, int maxIdx) WOLFSSL_MSG("Getting Name"); - if (nameType == ISSUER) { + if (nameType == ASN_ISSUER) { full = cert->issuer; hash = cert->issuerHash; } @@ -14718,7 +14784,7 @@ int GetName(DecodedCert* cert, int nameType, int maxIdx) cert->srcIdx = dataASN[CERTNAMEASN_IDX_NAME].offset; /* Get fields to fill in based on name type. */ - if (nameType == ISSUER) { + if (nameType == ASN_ISSUER) { full = cert->issuer; hash = cert->issuerHash; } @@ -14775,18 +14841,23 @@ static WC_INLINE int GetTime_Long(long* value, const byte* date, int* idx) } #endif +/* Extract certTime from date string parameter. + * Reminder: idx is incremented in each call to GetTime() + * Return 0 on failure, 1 for success. */ int ExtractDate(const unsigned char* date, unsigned char format, - struct tm* certTime, int* idx) + struct tm* certTime, int* idx) { XMEMSET(certTime, 0, sizeof(struct tm)); + /* Get the first two bytes of the year (century) */ if (format == ASN_UTC_TIME) { if (btoi(date[*idx]) >= 5) certTime->tm_year = 1900; else certTime->tm_year = 2000; } - else { /* format == GENERALIZED_TIME */ + else { + /* format == GENERALIZED_TIME */ #ifdef WOLFSSL_LINUXKM if (GetTime_Long(&certTime->tm_year, date, idx) != 0) return 0; #else @@ -14806,11 +14877,7 @@ int ExtractDate(const unsigned char* date, unsigned char format, int tm_min = certTime->tm_min; int tm_sec = certTime->tm_sec; -#ifdef WOLFSSL_LINUXKM - if (GetTime_Long(&tm_year, date, idx) != 0) return 0; -#else if (GetTime(&tm_year, date, idx) != 0) return 0; -#endif if (GetTime(&tm_mon , date, idx) != 0) return 0; if (GetTime(&tm_mday, date, idx) != 0) return 0; if (GetTime(&tm_hour, date, idx) != 0) return 0; @@ -14824,28 +14891,30 @@ int ExtractDate(const unsigned char* date, unsigned char format, certTime->tm_hour = tm_hour; certTime->tm_min = tm_min; certTime->tm_sec = tm_sec; -#else - /* adjust tm_year, tm_mon */ -#ifdef WOLFSSL_LINUXKM - if (GetTime_Long(&certTime->tm_year, date, idx) != 0) return 0; -#else - if (GetTime(&certTime->tm_year, date, idx) != 0) return 0; -#endif +#else /* !AVR */ + /* Get the next two bytes of the year. */ + #ifdef WOLFSSL_LINUXKM + if (GetTime_Long(&certTime->tm_year, date, idx) != 0) return 0; + #else + if (GetTime(&certTime->tm_year, date, idx) != 0) return 0; + #endif certTime->tm_year -= 1900; + + /* The next fields are expected in specific order in [date] string: */ if (GetTime(&certTime->tm_mon , date, idx) != 0) return 0; certTime->tm_mon -= 1; if (GetTime(&certTime->tm_mday, date, idx) != 0) return 0; if (GetTime(&certTime->tm_hour, date, idx) != 0) return 0; if (GetTime(&certTime->tm_min , date, idx) != 0) return 0; if (GetTime(&certTime->tm_sec , date, idx) != 0) return 0; -#endif + +#endif /* !AVR */ return 1; } -#if defined(OPENSSL_ALL) || defined(WOLFSSL_MYSQL_COMPATIBLE) || \ - defined(OPENSSL_EXTRA) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) +#ifdef WOLFSSL_ASN_TIME_STRING int GetTimeString(byte* date, int format, char* buf, int len) { struct tm t; @@ -14891,7 +14960,7 @@ int GetTimeString(byte* date, int format, char* buf, int len) return 1; } -#endif /* OPENSSL_ALL || WOLFSSL_MYSQL_COMPATIBLE || WOLFSSL_NGINX || WOLFSSL_HAPROXY */ +#endif /* WOLFSSL_ASN_TIME_STRING */ /* Check time struct for valid values. Returns 0 for success */ static int ValidateGmtime(struct tm* inTime) @@ -15007,19 +15076,13 @@ int GetFormattedTime(void* currTime, byte* buf, word32 len) hour = ts->tm_hour; mini = ts->tm_min; sec = ts->tm_sec; - #if defined(WOLF_C89) if (len < ASN_UTC_TIME_SIZE) { WOLFSSL_MSG("buffer for GetFormattedTime is too short."); return BUFFER_E; } - ret = XSPRINTF((char*)buf, - "%02d%02d%02d%02d%02d%02dZ", year, mon, day, - hour, mini, sec); - #else ret = XSNPRINTF((char*)buf, len, "%02d%02d%02d%02d%02d%02dZ", year, mon, day, hour, mini, sec); - #endif } else { /* GeneralizedTime */ @@ -15029,19 +15092,13 @@ int GetFormattedTime(void* currTime, byte* buf, word32 len) hour = ts->tm_hour; mini = ts->tm_min; sec = ts->tm_sec; - #if defined(WOLF_C89) if (len < ASN_GENERALIZED_TIME_SIZE) { WOLFSSL_MSG("buffer for GetFormattedTime is too short."); return BUFFER_E; } - ret = XSPRINTF((char*)buf, - "%4d%02d%02d%02d%02d%02dZ", year, mon, day, - hour, mini, sec); - #else ret = XSNPRINTF((char*)buf, len, "%4d%02d%02d%02d%02d%02dZ", year, mon, day, hour, mini, sec); - #endif } return ret; @@ -15092,7 +15149,7 @@ static WC_INLINE int DateLessThan(const struct tm* a, const struct tm* b) /* Make sure before and after dates are valid */ /* date = ASN.1 raw */ /* format = ASN_UTC_TIME or ASN_GENERALIZED_TIME */ -/* dateType = AFTER or BEFORE */ +/* dateType = ASN_AFTER or ASN_BEFORE */ int wc_ValidateDate(const byte* date, byte format, int dateType) { time_t ltime; @@ -15122,14 +15179,14 @@ int wc_ValidateDate(const byte* date, byte format, int dateType) #endif #ifdef WOLFSSL_BEFORE_DATE_CLOCK_SKEW - if (dateType == BEFORE) { + if (dateType == ASN_BEFORE) { WOLFSSL_MSG("Skewing local time for before date check"); ltime += WOLFSSL_BEFORE_DATE_CLOCK_SKEW; } #endif #ifdef WOLFSSL_AFTER_DATE_CLOCK_SKEW - if (dateType == AFTER) { + if (dateType == ASN_AFTER) { WOLFSSL_MSG("Skewing local time for after date check"); ltime -= WOLFSSL_AFTER_DATE_CLOCK_SKEW; } @@ -15163,13 +15220,13 @@ int wc_ValidateDate(const byte* date, byte format, int dateType) return 0; } - if (dateType == BEFORE) { + if (dateType == ASN_BEFORE) { if (DateLessThan(localTime, &certTime)) { WOLFSSL_MSG("Date BEFORE check failed"); return 0; } } - else { /* dateType == AFTER */ + else { /* dateType == ASN_AFTER */ if (DateGreaterThan(localTime, &certTime)) { WOLFSSL_MSG("Date AFTER check failed"); return 0; @@ -15335,7 +15392,7 @@ static int GetDate(DecodedCert* cert, int dateType, int verify, int maxIdx) byte format; word32 startIdx = 0; - if (dateType == BEFORE) + if (dateType == ASN_BEFORE) cert->beforeDate = &cert->source[cert->srcIdx]; else cert->afterDate = &cert->source[cert->srcIdx]; @@ -15349,7 +15406,7 @@ static int GetDate(DecodedCert* cert, int dateType, int verify, int maxIdx) XMEMSET(date, 0, MAX_DATE_SIZE); XMEMCPY(date, datePtr, (size_t)length); - if (dateType == BEFORE) + if (dateType == ASN_BEFORE) cert->beforeDateLen = (int)(cert->srcIdx - startIdx); else cert->afterDateLen = (int)(cert->srcIdx - startIdx); @@ -15357,7 +15414,7 @@ static int GetDate(DecodedCert* cert, int dateType, int verify, int maxIdx) #ifndef NO_ASN_TIME_CHECK if (verify != NO_VERIFY && verify != VERIFY_SKIP_DATE && !XVALIDATE_DATE(date, format, dateType)) { - if (dateType == BEFORE) { + if (dateType == ASN_BEFORE) { WOLFSSL_ERROR_VERBOSE(ASN_BEFORE_DATE_E); return ASN_BEFORE_DATE_E; } @@ -15383,10 +15440,10 @@ static int GetValidity(DecodedCert* cert, int verify, int maxIdx) maxIdx = (int)cert->srcIdx + length; - if (GetDate(cert, BEFORE, verify, maxIdx) < 0) + if (GetDate(cert, ASN_BEFORE, verify, maxIdx) < 0) badDate = ASN_BEFORE_DATE_E; /* continue parsing */ - if (GetDate(cert, AFTER, verify, maxIdx) < 0) + if (GetDate(cert, ASN_AFTER, verify, maxIdx) < 0) return ASN_AFTER_DATE_E; if (badDate != 0) @@ -15586,7 +15643,7 @@ int wc_GetPubX509(DecodedCert* cert, int verify, int* badDate) WOLFSSL_MSG("Got Algo ID"); - if ( (ret = GetName(cert, ISSUER, (int)cert->sigIndex)) < 0) + if ( (ret = GetName(cert, ASN_ISSUER, (int)cert->sigIndex)) < 0) return ret; if ( (ret = GetValidity(cert, verify, (int)cert->sigIndex)) < 0) @@ -15595,7 +15652,7 @@ int wc_GetPubX509(DecodedCert* cert, int verify, int* badDate) } #endif - if ( (ret = GetName(cert, SUBJECT, (int)cert->sigIndex)) < 0) + if ( (ret = GetName(cert, ASN_SUBJECT, (int)cert->sigIndex)) < 0) return ret; WOLFSSL_MSG("Got Subject Name"); @@ -15622,8 +15679,8 @@ int wc_GetPubX509(DecodedCert* cert, int verify, int* badDate) * @return 0 on success. * @return ASN_TIME_E when date BER tag is nor UTC or GENERALIZED time. * @return ASN_DATE_SZ_E when time data is not supported. - * @return ASN_BEFORE_DATE_E when BEFORE date is invalid. - * @return ASN_AFTER_DATE_E when AFTER date is invalid. + * @return ASN_BEFORE_DATE_E when ASN_BEFORE date is invalid. + * @return ASN_AFTER_DATE_E when ASN_AFTER date is invalid. * @return ASN_PARSE_E when BER encoded data does not match ASN.1 items or * is invalid. * @return BUFFER_E when data in buffer is too small. @@ -16554,7 +16611,7 @@ static int ConfirmSignature(SignatureCtx* sigCtx, const byte* sigParams, word32 sigParamsSz, byte* rsaKeyIdx) { - int ret = 0; + int ret = ASN_SIG_CONFIRM_E; /* default to failure */ #if defined(WOLFSSL_RENESAS_TSIP_TLS) || defined(WOLFSSL_RENESAS_FSPSM_TLS) CertAttribute* certatt = NULL; #endif @@ -17690,6 +17747,9 @@ static int ConfirmSignature(SignatureCtx* sigCtx, exit_cs: +#else + /* For NO_ASN_CRYPT return "not compiled in" */ + ret = NOT_COMPILED_IN; #endif /* !NO_ASN_CRYPT */ (void)keyOID; @@ -17988,7 +18048,9 @@ static int ConfirmNameConstraints(Signer* signer, DecodedCert* cert) #ifndef WOLFSSL_ASN_TEMPLATE static void AddAltName(DecodedCert* cert, DNS_entry* dnsEntry) { -#if defined(OPENSSL_EXTRA) && !defined(WOLFSSL_ALT_NAMES_NO_REV) +#if (defined(WOLFSSL_ASN_ALL) || defined(OPENSSL_EXTRA)) && \ + !defined(WOLFSSL_ALT_NAMES_NO_REV) + /* logic to add alt name to end of list */ dnsEntry->next = NULL; if (cert->altNames == NULL) { /* First on list */ @@ -18283,8 +18345,7 @@ static int DecodeGeneralName(const byte* input, word32* inOutIdx, byte tag, idx += (word32)len; } } - #if defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || \ - defined(WOLFSSL_IP_ALT_NAME) + #ifdef WOLFSSL_IP_ALT_NAME /* GeneralName choice: iPAddress */ else if (tag == (ASN_CONTEXT_SPECIFIC | ASN_IP_TYPE)) { ret = SetDNSEntry(cert, (const char*)(input + idx), len, ASN_IP_TYPE, @@ -18293,9 +18354,8 @@ static int DecodeGeneralName(const byte* input, word32* inOutIdx, byte tag, idx += (word32)len; } } - #endif /* WOLFSSL_QT || OPENSSL_ALL */ - - #ifdef OPENSSL_ALL + #endif /* WOLFSSL_IP_ALT_NAME */ + #ifdef WOLFSSL_RID_ALT_NAME /* GeneralName choice: registeredID */ else if (tag == (ASN_CONTEXT_SPECIFIC | ASN_RID_TYPE)) { ret = SetDNSEntry(cert, (const char*)(input + idx), len, @@ -18304,7 +18364,7 @@ static int DecodeGeneralName(const byte* input, word32* inOutIdx, byte tag, idx += (word32)len; } } - #endif + #endif /* WOLFSSL_RID_ALT_NAME */ #endif /* IGNORE_NAME_CONSTRAINTS */ #if defined(WOLFSSL_SEP) || defined(WOLFSSL_FPKI) /* GeneralName choice: otherName */ @@ -18548,6 +18608,7 @@ static int DecodeAltNames(const byte* input, word32 sz, DecodedCert* cert) #ifndef WOLFSSL_ASN_TEMPLATE word32 idx = 0; int length = 0; + word32 numNames = 0; WOLFSSL_ENTER("DecodeAltNames"); @@ -18580,8 +18641,13 @@ static int DecodeAltNames(const byte* input, word32 sz, DecodedCert* cert) return BUFFER_E; } - current_byte = input[idx++]; + numNames++; + if (numNames > WOLFSSL_MAX_ALT_NAMES) { + WOLFSSL_MSG("\tToo many subject alternative names"); + return ASN_ALT_NAME_E; + } + current_byte = input[idx++]; length--; /* Save DNS Type names in the altNames list. */ @@ -18775,7 +18841,7 @@ static int DecodeAltNames(const byte* input, word32 sz, DecodedCert* cert) length -= strLen; idx += (word32)strLen; } -#if defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME) +#ifdef WOLFSSL_IP_ALT_NAME else if (current_byte == (ASN_CONTEXT_SPECIFIC | ASN_IP_TYPE)) { DNS_entry* ipAddr; int strLen; @@ -18810,21 +18876,19 @@ static int DecodeAltNames(const byte* input, word32 sz, DecodedCert* cert) XMEMCPY(ipAddr->name, &input[idx], strLen); ipAddr->name[strLen] = '\0'; - #if defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME) if (GenerateDNSEntryIPString(ipAddr, cert->heap) != 0) { WOLFSSL_MSG("\tOut of Memory for IP string"); XFREE(ipAddr->name, cert->heap, DYNAMIC_TYPE_ALTNAME); XFREE(ipAddr, cert->heap, DYNAMIC_TYPE_ALTNAME); return MEMORY_E; } - #endif /* OPENSSL_ALL || WOLFSSL_IP_ALT_NAME */ AddAltName(cert, ipAddr); length -= strLen; idx += (word32)strLen; } -#endif /* WOLFSSL_QT || OPENSSL_ALL || WOLFSSL_IP_ALT_NAME */ -#if defined(OPENSSL_ALL) +#endif /* WOLFSSL_IP_ALT_NAME */ +#ifdef WOLFSSL_RID_ALT_NAME else if (current_byte == (ASN_CONTEXT_SPECIFIC | ASN_RID_TYPE)) { DNS_entry* rid; int strLen; @@ -18871,7 +18935,7 @@ static int DecodeAltNames(const byte* input, word32 sz, DecodedCert* cert) length -= strLen; idx += (word32)strLen; } -#endif /* OPENSSL_ALL */ +#endif /* WOLFSSL_RID_ALT_NAME */ #endif /* IGNORE_NAME_CONSTRAINTS */ else if (current_byte == (ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED | ASN_OTHER_TYPE)) { @@ -19473,15 +19537,11 @@ static int DecodeAuthInfo(const byte* input, word32 sz, DecodedCert* cert) /* Set ocsp entry */ if (b == GENERALNAME_URI && oid == AIA_OCSP_OID && - cert->extAuthInfo == NULL) - { + cert->extAuthInfo == NULL) { cert->extAuthInfoSz = length; cert->extAuthInfo = input + idx; - #if !defined(OPENSSL_ALL) && !defined(WOLFSSL_QT) - break; - #endif } - #if defined(OPENSSL_ALL) || defined(WOLFSSL_QT) + #ifdef WOLFSSL_ASN_CA_ISSUER /* Set CaIssuers entry */ else if ((b == GENERALNAME_URI) && oid == AIA_CA_ISSUER_OID && cert->extAuthInfoCaIssuer == NULL) @@ -19489,7 +19549,7 @@ static int DecodeAuthInfo(const byte* input, word32 sz, DecodedCert* cert) cert->extAuthInfoCaIssuerSz = length; cert->extAuthInfoCaIssuer = input + idx; } - #endif + #endif idx += (word32)length; } @@ -19527,11 +19587,8 @@ static int DecodeAuthInfo(const byte* input, word32 sz, DecodedCert* cert) GetASN_GetConstRef(&dataASN[ACCESSDESCASN_IDX_LOC], &cert->extAuthInfo, &sz32); cert->extAuthInfoSz = (int)sz32; - #if !defined(OPENSSL_ALL) && !defined(WOLFSSL_QT) - break; - #endif } - #if defined(OPENSSL_ALL) || defined(WOLFSSL_QT) + #ifdef WOLFSSL_ASN_CA_ISSUER /* Check we have CA Issuer and URI. */ else if ((dataASN[ACCESSDESCASN_IDX_METH].data.oid.sum == AIA_CA_ISSUER_OID) && @@ -19542,7 +19599,7 @@ static int DecodeAuthInfo(const byte* input, word32 sz, DecodedCert* cert) &cert->extAuthInfoCaIssuer, &sz32); cert->extAuthInfoCaIssuerSz = (int)sz32; } - #endif + #endif /* Otherwise skip. */ } } @@ -20111,6 +20168,7 @@ static int DecodeSubtree(const byte* input, word32 sz, Base_entry** head, #ifndef WOLFSSL_ASN_TEMPLATE word32 idx = 0; int ret = 0; + word32 cnt = 0; (void)heap; @@ -20119,6 +20177,14 @@ static int DecodeSubtree(const byte* input, word32 sz, Base_entry** head, word32 nameIdx; byte b, bType; + if (limit > 0) { + cnt++; + if (cnt > limit) { + WOLFSSL_MSG("too many name constraints"); + return ASN_NAME_INVALID_E; + } + } + if (GetSequence(input, &idx, &seqLength, sz) < 0) { WOLFSSL_MSG("\tfail: should be a SEQUENCE"); return ASN_PARSE_E; @@ -20349,7 +20415,7 @@ static int DecodeNameConstraints(const byte* input, word32 sz, } #endif /* IGNORE_NAME_CONSTRAINTS */ -#if (defined(WOLFSSL_CERT_EXT) && !defined(WOLFSSL_SEP)) || \ +#if defined(WOLFSSL_CERT_EXT) || \ defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) /* Decode ITU-T X.690 OID format to a string representation @@ -20402,10 +20468,10 @@ int DecodePolicyOID(char *out, word32 outSz, const byte *in, word32 inSz) exit: return w; } -#endif /* WOLFSSL_CERT_EXT && !WOLFSSL_SEP */ +#endif /* WOLFSSL_CERT_EXT || OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */ -#if defined(WOLFSSL_SEP) || defined(WOLFSSL_CERT_EXT) || defined(WOLFSSL_QT) - #ifdef WOLFSSL_ASN_TEMPLATE +#if defined(WOLFSSL_SEP) || defined(WOLFSSL_CERT_EXT) +#ifdef WOLFSSL_ASN_TEMPLATE /* ASN.1 template for PolicyInformation. * X.509: RFC 5280, 4.2.1.4 - Certificate Policies. */ @@ -20424,230 +20490,221 @@ int DecodePolicyOID(char *out, word32 outSz, const byte *in, word32 inSz) /* Number of items in ASN.1 template for PolicyInformation. */ #define policyInfoASN_Length (sizeof(policyInfoASN) / sizeof(ASNItem)) - #endif +#endif - /* Reference: https://tools.ietf.org/html/rfc5280#section-4.2.1.4 */ - static int DecodeCertPolicy(const byte* input, word32 sz, DecodedCert* cert) - { - #ifndef WOLFSSL_ASN_TEMPLATE - word32 idx = 0; - word32 oldIdx; - int policy_length = 0; - int ret; - int total_length = 0; - #if !defined(WOLFSSL_SEP) && defined(WOLFSSL_CERT_EXT) && \ - !defined(WOLFSSL_DUP_CERTPOL) - int i; - #endif +/* Reference: https://tools.ietf.org/html/rfc5280#section-4.2.1.4 */ +static int DecodeCertPolicy(const byte* input, word32 sz, DecodedCert* cert) +{ +#ifndef WOLFSSL_ASN_TEMPLATE + word32 idx = 0; + word32 oldIdx; + int policy_length = 0; + int ret; + int total_length = 0; +#if defined(WOLFSSL_CERT_EXT) && !defined(WOLFSSL_DUP_CERTPOL) + int i; +#endif - WOLFSSL_ENTER("DecodeCertPolicy"); + WOLFSSL_ENTER("DecodeCertPolicy"); - #if defined(WOLFSSL_SEP) || defined(WOLFSSL_CERT_EXT) - /* Check if cert is null before dereferencing below */ - if (cert == NULL) - return BAD_FUNC_ARG; - #else - (void)cert; - #endif + /* Check if cert is null before dereferencing below */ + if (cert == NULL) + return BAD_FUNC_ARG; - #if defined(WOLFSSL_CERT_EXT) - cert->extCertPoliciesNb = 0; - #endif +#if defined(WOLFSSL_CERT_EXT) + cert->extCertPoliciesNb = 0; +#endif - if (GetSequence(input, &idx, &total_length, sz) < 0) { - WOLFSSL_MSG("\tGet CertPolicy total seq failed"); - return ASN_PARSE_E; - } + if (GetSequence(input, &idx, &total_length, sz) < 0) { + WOLFSSL_MSG("\tGet CertPolicy total seq failed"); + return ASN_PARSE_E; + } + + /* Validate total length */ + if (total_length > (int)(sz - idx)) { + WOLFSSL_MSG("\tCertPolicy length mismatch"); + return ASN_PARSE_E; + } + + /* Unwrap certificatePolicies */ + do { + int length = 0; - /* Validate total length */ - if (total_length > (int)(sz - idx)) { - WOLFSSL_MSG("\tCertPolicy length mismatch"); + if (GetSequence(input, &idx, &policy_length, sz) < 0) { + WOLFSSL_MSG("\tGet CertPolicy seq failed"); return ASN_PARSE_E; } - /* Unwrap certificatePolicies */ - do { - int length = 0; + oldIdx = idx; + ret = GetASNObjectId(input, &idx, &length, sz); + if (ret != 0) + return ret; + policy_length -= (int)(idx - oldIdx); - if (GetSequence(input, &idx, &policy_length, sz) < 0) { - WOLFSSL_MSG("\tGet CertPolicy seq failed"); + if (length > 0) { + /* Verify length won't overrun buffer */ + if (length > (int)(sz - idx)) { + WOLFSSL_MSG("\tCertPolicy length exceeds input buffer"); return ASN_PARSE_E; } - oldIdx = idx; - ret = GetASNObjectId(input, &idx, &length, sz); - if (ret != 0) - return ret; - policy_length -= (int)(idx - oldIdx); - - if (length > 0) { - /* Verify length won't overrun buffer */ - if (length > (int)(sz - idx)) { - WOLFSSL_MSG("\tCertPolicy length exceeds input buffer"); - return ASN_PARSE_E; - } - - #if defined(WOLFSSL_SEP) + #ifdef WOLFSSL_SEP + if (cert->deviceType == NULL) { cert->deviceType = (byte*)XMALLOC((size_t)length, cert->heap, - DYNAMIC_TYPE_X509_EXT); + DYNAMIC_TYPE_X509_EXT); if (cert->deviceType == NULL) { WOLFSSL_MSG("\tCouldn't alloc memory for deviceType"); return MEMORY_E; } cert->deviceTypeSz = length; XMEMCPY(cert->deviceType, input + idx, (size_t)length); - break; - #elif defined(WOLFSSL_CERT_EXT) - /* decode cert policy */ - if (DecodePolicyOID(cert->extCertPolicies[ - cert->extCertPoliciesNb], MAX_CERTPOL_SZ, - input + idx, length) <= 0) { - WOLFSSL_MSG("\tCouldn't decode CertPolicy"); - WOLFSSL_ERROR_VERBOSE(ASN_PARSE_E); - return ASN_PARSE_E; - } - #ifndef WOLFSSL_DUP_CERTPOL - /* From RFC 5280 section 4.2.1.4 "A certificate policy OID MUST - * NOT appear more than once in a certificate policies - * extension". This is a sanity check for duplicates. - * extCertPolicies should only have OID values, additional - * qualifiers need to be stored in a separate array. */ - for (i = 0; i < cert->extCertPoliciesNb; i++) { - if (XMEMCMP(cert->extCertPolicies[i], + } + #endif + + #ifdef WOLFSSL_CERT_EXT + /* decode cert policy */ + if (DecodePolicyOID(cert->extCertPolicies[ + cert->extCertPoliciesNb], MAX_CERTPOL_SZ, + input + idx, length) <= 0) { + WOLFSSL_MSG("\tCouldn't decode CertPolicy"); + WOLFSSL_ERROR_VERBOSE(ASN_PARSE_E); + return ASN_PARSE_E; + } + #ifndef WOLFSSL_DUP_CERTPOL + /* From RFC 5280 section 4.2.1.4 "A certificate policy OID MUST + * NOT appear more than once in a certificate policies + * extension". This is a sanity check for duplicates. + * extCertPolicies should only have OID values, additional + * qualifiers need to be stored in a separate array. */ + for (i = 0; i < cert->extCertPoliciesNb; i++) { + if (XMEMCMP(cert->extCertPolicies[i], cert->extCertPolicies[cert->extCertPoliciesNb], MAX_CERTPOL_SZ) == 0) { - WOLFSSL_MSG("Duplicate policy OIDs not allowed"); - WOLFSSL_MSG("Use WOLFSSL_DUP_CERTPOL if wanted"); - WOLFSSL_ERROR_VERBOSE(CERTPOLICIES_E); - return CERTPOLICIES_E; - } + WOLFSSL_MSG("Duplicate policy OIDs not allowed"); + WOLFSSL_MSG("Use WOLFSSL_DUP_CERTPOL if wanted"); + WOLFSSL_ERROR_VERBOSE(CERTPOLICIES_E); + return CERTPOLICIES_E; } - #endif /* !WOLFSSL_DUP_CERTPOL */ - cert->extCertPoliciesNb++; - #else - WOLFSSL_LEAVE("DecodeCertPolicy : unsupported mode", 0); - return 0; - #endif } - idx += (word32)policy_length; - } while((int)idx < total_length - #if defined(WOLFSSL_CERT_EXT) - && cert->extCertPoliciesNb < MAX_CERTPOL_NB + #endif /* !WOLFSSL_DUP_CERTPOL */ + cert->extCertPoliciesNb++; #endif - ); - - WOLFSSL_LEAVE("DecodeCertPolicy", 0); - return 0; - #else /* WOLFSSL_ASN_TEMPLATE */ - word32 idx = 0; - int ret = 0; - int total_length = 0; - #if !defined(WOLFSSL_SEP) && defined(WOLFSSL_CERT_EXT) && \ - !defined(WOLFSSL_DUP_CERTPOL) - int i; + } + idx += (word32)policy_length; + } while((int)idx < total_length + #ifdef WOLFSSL_CERT_EXT + && cert->extCertPoliciesNb < MAX_CERTPOL_NB #endif + ); - WOLFSSL_ENTER("DecodeCertPolicy"); - #if defined(WOLFSSL_SEP) || defined(WOLFSSL_CERT_EXT) - /* Check if cert is null before dereferencing below */ - if (cert == NULL) - ret = BAD_FUNC_ARG; - #endif + WOLFSSL_LEAVE("DecodeCertPolicy", 0); + return 0; +#else /* WOLFSSL_ASN_TEMPLATE */ + word32 idx = 0; + int ret = 0; + int total_length = 0; +#if defined(WOLFSSL_CERT_EXT) && !defined(WOLFSSL_DUP_CERTPOL) + int i; +#endif - if (ret == 0) { - #if defined(WOLFSSL_CERT_EXT) - cert->extCertPoliciesNb = 0; - #endif + WOLFSSL_ENTER("DecodeCertPolicy"); - /* Strip SEQUENCE OF and check using all data. */ - if (GetASN_Sequence(input, &idx, &total_length, (word32)sz, 1) < 0) - { - ret = ASN_PARSE_E; - } + /* Check if cert is null before dereferencing below */ + if (cert == NULL) { + ret = BAD_FUNC_ARG; + } + + if (ret == 0) { + #if defined(WOLFSSL_CERT_EXT) + cert->extCertPoliciesNb = 0; + #endif + + /* Strip SEQUENCE OF and check using all data. */ + if (GetASN_Sequence(input, &idx, &total_length, (word32)sz, 1) < 0) + { + ret = ASN_PARSE_E; } + } - /* Unwrap certificatePolicies */ - while ((ret == 0) && ((int)idx < total_length) - #if defined(WOLFSSL_CERT_EXT) - && (cert->extCertPoliciesNb < MAX_CERTPOL_NB) - #endif - ) { - ASNGetData dataASN[policyInfoASN_Length]; - byte* data = NULL; - word32 length = 0; + /* Unwrap certificatePolicies */ + while ((ret == 0) && ((int)idx < total_length) + #if defined(WOLFSSL_CERT_EXT) + && (cert->extCertPoliciesNb < MAX_CERTPOL_NB) + #endif + ) { + ASNGetData dataASN[policyInfoASN_Length]; + byte* data = NULL; + word32 length = 0; - /* Clear dynamic data and check OID is a cert policy type. */ - XMEMSET(dataASN, 0, sizeof(dataASN)); - GetASN_OID(&dataASN[POLICYINFOASN_IDX_ID], oidCertPolicyType); - ret = GetASN_Items(policyInfoASN, dataASN, policyInfoASN_Length, 1, - input, &idx, (word32)sz); - if (ret == 0) { - /* Get the OID. */ - GetASN_OIDData(&dataASN[POLICYINFOASN_IDX_ID], &data, &length); - if (length == 0) { - ret = ASN_PARSE_E; - } - } - #if defined(WOLFSSL_SEP) - /* Store OID in device type. */ - if (ret == 0) { - cert->deviceType = (byte*)XMALLOC(length, cert->heap, - DYNAMIC_TYPE_X509_EXT); - if (cert->deviceType == NULL) { - WOLFSSL_MSG("\tCouldn't alloc memory for deviceType"); - ret = MEMORY_E; - } + /* Clear dynamic data and check OID is a cert policy type. */ + XMEMSET(dataASN, 0, sizeof(dataASN)); + GetASN_OID(&dataASN[POLICYINFOASN_IDX_ID], oidCertPolicyType); + ret = GetASN_Items(policyInfoASN, dataASN, policyInfoASN_Length, 1, + input, &idx, (word32)sz); + if (ret == 0) { + /* Get the OID. */ + GetASN_OIDData(&dataASN[POLICYINFOASN_IDX_ID], &data, &length); + if (length == 0) { + ret = ASN_PARSE_E; } - if (ret == 0) { + } + #ifdef WOLFSSL_SEP + /* Store OID in device type. */ + if (ret == 0 && cert->deviceType == NULL) { + cert->deviceType = (byte*)XMALLOC(length, cert->heap, + DYNAMIC_TYPE_X509_EXT); + if (cert->deviceType != NULL) { /* Store device type data and length. */ cert->deviceTypeSz = (int)length; XMEMCPY(cert->deviceType, data, length); - break; } - #elif defined(WOLFSSL_CERT_EXT) - if (ret == 0) { - /* Decode cert policy. */ - if (DecodePolicyOID( - cert->extCertPolicies[cert->extCertPoliciesNb], - MAX_CERTPOL_SZ, data, length) <= 0) { - WOLFSSL_MSG("\tCouldn't decode CertPolicy"); - WOLFSSL_ERROR_VERBOSE(ASN_PARSE_E); - ret = ASN_PARSE_E; - } + else { + WOLFSSL_MSG("\tCouldn't alloc memory for deviceType"); + ret = MEMORY_E; } - #ifndef WOLFSSL_DUP_CERTPOL - /* From RFC 5280 section 4.2.1.4 "A certificate policy OID MUST - * NOT appear more than once in a certificate policies - * extension". This is a sanity check for duplicates. - * extCertPolicies should only have OID values, additional - * qualifiers need to be stored in a separate array. */ - for (i = 0; (ret == 0) && (i < cert->extCertPoliciesNb); i++) { - if (XMEMCMP(cert->extCertPolicies[i], - cert->extCertPolicies[cert->extCertPoliciesNb], - MAX_CERTPOL_SZ) == 0) { - WOLFSSL_MSG("Duplicate policy OIDs not allowed"); - WOLFSSL_MSG("Use WOLFSSL_DUP_CERTPOL if wanted"); - WOLFSSL_ERROR_VERBOSE(CERTPOLICIES_E); - ret = CERTPOLICIES_E; - } + } + #endif /* WOLFSSL_SEP */ + + #ifdef WOLFSSL_CERT_EXT + if (ret == 0) { + /* Decode cert policy. */ + if (DecodePolicyOID( + cert->extCertPolicies[cert->extCertPoliciesNb], + MAX_CERTPOL_SZ, data, length) <= 0) { + WOLFSSL_MSG("\tCouldn't decode CertPolicy"); + WOLFSSL_ERROR_VERBOSE(ASN_PARSE_E); + ret = ASN_PARSE_E; } - #endif /* !defined(WOLFSSL_DUP_CERTPOL) */ - if (ret == 0) { - /* Keep count of policies seen. */ - cert->extCertPoliciesNb++; + } + #ifndef WOLFSSL_DUP_CERTPOL + /* From RFC 5280 section 4.2.1.4 "A certificate policy OID MUST + * NOT appear more than once in a certificate policies + * extension". This is a sanity check for duplicates. + * extCertPolicies should only have OID values, additional + * qualifiers need to be stored in a separate array. */ + for (i = 0; (ret == 0) && (i < cert->extCertPoliciesNb); i++) { + if (XMEMCMP(cert->extCertPolicies[i], + cert->extCertPolicies[cert->extCertPoliciesNb], + MAX_CERTPOL_SZ) == 0) { + WOLFSSL_MSG("Duplicate policy OIDs not allowed"); + WOLFSSL_MSG("Use WOLFSSL_DUP_CERTPOL if wanted"); + WOLFSSL_ERROR_VERBOSE(CERTPOLICIES_E); + ret = CERTPOLICIES_E; } - #else - (void)data; - WOLFSSL_LEAVE("DecodeCertPolicy : unsupported mode", 0); - break; - #endif } - - WOLFSSL_LEAVE("DecodeCertPolicy", 0); - return ret; - #endif /* WOLFSSL_ASN_TEMPLATE */ + #endif /* !WOLFSSL_DUP_CERTPOL */ + if (ret == 0) { + /* Keep count of policies seen. */ + cert->extCertPoliciesNb++; + } + #endif /* WOLFSSL_CERT_EXT */ } -#endif /* WOLFSSL_SEP */ + + WOLFSSL_LEAVE("DecodeCertPolicy", 0); + return ret; +#endif /* WOLFSSL_ASN_TEMPLATE */ +} +#endif /* WOLFSSL_SEP || WOLFSSL_CERT_EXT */ #ifdef WOLFSSL_SUBJ_DIR_ATTR #ifdef WOLFSSL_ASN_TEMPLATE @@ -21177,15 +21234,11 @@ static int DecodeExtensionType(const byte* input, word32 length, word32 oid, /* Certificate policies. */ case CERT_POLICY_OID: - #if defined(WOLFSSL_SEP) || defined(WOLFSSL_QT) + #ifdef WOLFSSL_SEP VERIFY_AND_SET_OID(cert->extCertPolicySet); - #if defined(OPENSSL_EXTRA) || \ - defined(OPENSSL_EXTRA_X509_SMALL) - cert->extCertPolicyCrit = critical ? 1 : 0; - #endif + cert->extCertPolicyCrit = critical ? 1 : 0; #endif - #if defined(WOLFSSL_SEP) || defined(WOLFSSL_CERT_EXT) || \ - defined(WOLFSSL_QT) + #if defined(WOLFSSL_SEP) || defined(WOLFSSL_CERT_EXT) if (DecodeCertPolicy(input, length, cert) < 0) { ret = ASN_PARSE_E; } @@ -21357,8 +21410,7 @@ enum { #define certExtASN_Length (sizeof(certExtASN) / sizeof(ASNItem)) #endif -#if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) \ - && defined(HAVE_OID_DECODING) +#ifdef WC_ASN_UNKNOWN_EXT_CB int wc_SetUnknownExtCallback(DecodedCert* cert, wc_UnknownExtCallback cb) { if (cert == NULL) { @@ -21368,7 +21420,18 @@ int wc_SetUnknownExtCallback(DecodedCert* cert, cert->unknownExtCallback = cb; return 0; } -#endif + +int wc_SetUnknownExtCallbackEx(DecodedCert* cert, + wc_UnknownExtCallbackEx cb, void *ctx) { + if (cert == NULL) { + return BAD_FUNC_ARG; + } + + cert->unknownExtCallbackEx = cb; + cert->unknownExtCallbackExCtx = ctx; + return 0; +} +#endif /* WC_ASN_UNKNOWN_EXT_CB */ /* * Processing the Certificate Extensions. This does not modify the current @@ -21522,8 +21585,9 @@ static int DecodeCertExtensions(DecodedCert* cert) /* Decode the extension by type. */ ret = DecodeExtensionType(input + idx, length, oid, critical, cert, &isUnknownExt); -#if defined(WOLFSSL_CUSTOM_OID) && defined(HAVE_OID_DECODING) - if (isUnknownExt && (cert->unknownExtCallback != NULL)) { +#ifdef WC_ASN_UNKNOWN_EXT_CB + if (isUnknownExt && (cert->unknownExtCallback != NULL || + cert->unknownExtCallbackEx != NULL)) { word16 decOid[MAX_OID_SZ]; word32 decOidSz = sizeof(decOid); ret = DecodeObjectId( @@ -21537,12 +21601,22 @@ static int DecodeCertExtensions(DecodedCert* cert) WOLFSSL_ERROR(ret); } - ret = cert->unknownExtCallback(decOid, decOidSz, critical, - dataASN[CERTEXTASN_IDX_VAL].data.buffer.data, - dataASN[CERTEXTASN_IDX_VAL].length); + if ((ret == 0) && (cert->unknownExtCallback != NULL)) { + ret = cert->unknownExtCallback(decOid, decOidSz, critical, + dataASN[CERTEXTASN_IDX_VAL].data.buffer.data, + dataASN[CERTEXTASN_IDX_VAL].length); + } + + if ((ret == 0) && (cert->unknownExtCallbackEx != NULL)) { + ret = cert->unknownExtCallbackEx(decOid, decOidSz, critical, + dataASN[CERTEXTASN_IDX_VAL].data.buffer.data, + dataASN[CERTEXTASN_IDX_VAL].length, + cert->unknownExtCallbackExCtx); + } } -#endif +#else (void)isUnknownExt; +#endif /* Move index on to next extension. */ idx += length; @@ -21725,12 +21799,12 @@ enum { /* Check the data data. * * @param [in] dataASN ASN template dynamic data item. - * @param [in] dataType BEFORE or AFTER date. + * @param [in] dataType ASN_BEFORE or ASN_AFTER date. * @return 0 on success. * @return ASN_TIME_E when BER tag is nor UTC or GENERALIZED time. * @return ASN_DATE_SZ_E when time data is not supported. - * @return ASN_BEFORE_DATE_E when BEFORE date is invalid. - * @return ASN_AFTER_DATE_E when AFTER date is invalid. + * @return ASN_BEFORE_DATE_E when ASN_BEFORE date is invalid. + * @return ASN_AFTER_DATE_E when ASN_AFTER date is invalid. */ static int CheckDate(ASNGetData *dataASN, int dateType) { @@ -21748,14 +21822,18 @@ static int CheckDate(ASNGetData *dataASN, int dateType) } #ifndef NO_ASN_TIME_CHECK - /* Check date is a valid string and BEFORE or AFTER now. */ - if ((ret == 0) && - (!XVALIDATE_DATE(dataASN->data.ref.data, dataASN->tag, dateType))) { - if (dateType == BEFORE) { - ret = ASN_BEFORE_DATE_E; - } - else { - ret = ASN_AFTER_DATE_E; + /* Check date is a valid string and ASN_BEFORE or ASN_AFTER now. */ + if (ret == 0) { + if (!XVALIDATE_DATE(dataASN->data.ref.data, dataASN->tag, dateType)) { + if (dateType == ASN_BEFORE) { + ret = ASN_BEFORE_DATE_E; + } + else if (dateType == ASN_AFTER) { + ret = ASN_AFTER_DATE_E; + } + else { + ret = ASN_TIME_E; + } } } #endif @@ -21776,8 +21854,8 @@ static int CheckDate(ASNGetData *dataASN, int dateType) * @return ASN_CRIT_EXT_E when a critical extension was not recognized. * @return ASN_TIME_E when date BER tag is nor UTC or GENERALIZED time. * @return ASN_DATE_SZ_E when time data is not supported. - * @return ASN_BEFORE_DATE_E when BEFORE date is invalid. - * @return ASN_AFTER_DATE_E when AFTER date is invalid. + * @return ASN_BEFORE_DATE_E when ASN_BEFORE date is invalid. + * @return ASN_AFTER_DATE_E when ASN_AFTER date is invalid. * @return ASN_PARSE_E when BER encoded data does not match ASN.1 items or * is invalid. * @return BUFFER_E when data in buffer is too small. @@ -21898,27 +21976,27 @@ static int DecodeCertInternal(DecodedCert* cert, int verify, int* criticalExt, /* No bad date error - don't always care. */ badDate = 0; - /* Find the item with the BEFORE date and check it. */ + /* Find the item with the ASN_BEFORE date and check it. */ i = (dataASN[X509CERTASN_IDX_TBS_VALIDITY_NOTB_UTC].tag != 0) ? X509CERTASN_IDX_TBS_VALIDITY_NOTB_UTC : X509CERTASN_IDX_TBS_VALIDITY_NOTB_GT; - if ((CheckDate(&dataASN[i], BEFORE) < 0) && (verify != NO_VERIFY) && + if ((CheckDate(&dataASN[i], ASN_BEFORE) < 0) && (verify != NO_VERIFY) && (verify != VERIFY_SKIP_DATE)) { badDate = ASN_BEFORE_DATE_E; } - /* Store reference to BEFOREdate. */ + /* Store reference to ASN_BEFORE date. */ cert->beforeDate = GetASNItem_Addr(dataASN[i], cert->source); cert->beforeDateLen = (int)GetASNItem_Length(dataASN[i], cert->source); - /* Find the item with the AFTER date and check it. */ + /* Find the item with the ASN_AFTER date and check it. */ i = (dataASN[X509CERTASN_IDX_TBS_VALIDITY_NOTA_UTC].tag != 0) ? X509CERTASN_IDX_TBS_VALIDITY_NOTA_UTC : X509CERTASN_IDX_TBS_VALIDITY_NOTA_GT; - if ((CheckDate(&dataASN[i], AFTER) < 0) && (verify != NO_VERIFY) && + if ((CheckDate(&dataASN[i], ASN_AFTER) < 0) && (verify != NO_VERIFY) && (verify != VERIFY_SKIP_DATE)) { badDate = ASN_AFTER_DATE_E; } - /* Store reference to AFTER date. */ + /* Store reference to ASN_AFTER date. */ cert->afterDate = GetASNItem_Addr(dataASN[i], cert->source); cert->afterDateLen = (int)GetASNItem_Length(dataASN[i], cert->source); @@ -22049,13 +22127,13 @@ static int DecodeCertInternal(DecodedCert* cert, int verify, int* criticalExt, if ((ret == 0) && (issuer != NULL)) { idx = 0; /* Put issuer into cert and calculate hash. */ - ret = GetCertName(cert, cert->issuer, cert->issuerHash, ISSUER, issuer, + ret = GetCertName(cert, cert->issuer, cert->issuerHash, ASN_ISSUER, issuer, &idx, issuerSz); } if ((ret == 0) && (subject != NULL)) { idx = 0; /* Put subject into cert and calculate hash. */ - ret = GetCertName(cert, cert->subject, cert->subjectHash, SUBJECT, + ret = GetCertName(cert, cert->subject, cert->subjectHash, ASN_SUBJECT, subject, &idx, subjectSz); } if (ret == 0) { @@ -22117,8 +22195,8 @@ static int DecodeCertInternal(DecodedCert* cert, int verify, int* criticalExt, * @return ASN_CRIT_EXT_E when a critical extension was not recognized. * @return ASN_TIME_E when date BER tag is nor UTC or GENERALIZED time. * @return ASN_DATE_SZ_E when time data is not supported. - * @return ASN_BEFORE_DATE_E when BEFORE date is invalid. - * @return ASN_AFTER_DATE_E when AFTER date is invalid. + * @return ASN_BEFORE_DATE_E when ASN_BEFORE date is invalid. + * @return ASN_AFTER_DATE_E when ASN_AFTER date is invalid. * @return ASN_PARSE_E when BER encoded data does not match ASN.1 items or * is invalid. * @return BUFFER_E when data in buffer is too small. @@ -22463,7 +22541,7 @@ static int DecodeCertReq(DecodedCert* cert, int* criticalExt) /* Parse the subject name. */ idx = dataASN[CERTREQASN_IDX_INFO_SUBJ_SEQ].offset; - ret = GetCertName(cert, cert->subject, cert->subjectHash, SUBJECT, + ret = GetCertName(cert, cert->subject, cert->subjectHash, ASN_SUBJECT, cert->source, &idx, dataASN[CERTREQASN_IDX_INFO_SPUBKEYINFO_SEQ].offset); } @@ -24026,8 +24104,10 @@ int ParseCertRelative(DecodedCert* cert, int type, int verify, void* cm, Signer else { /* no signer */ WOLFSSL_MSG("No CA signer to verify with"); + /* If you end up here with error -188, + * consider using WOLFSSL_ALT_CERT_CHAINS. */ #if defined(OPENSSL_ALL) || defined(WOLFSSL_QT) - /* ret needs to be self-signer error for Qt compat */ + /* ret needs to be self-signer error for openssl compatibility */ if (cert->selfSigned) { WOLFSSL_ERROR_VERBOSE(ASN_SELF_SIGNED_E); return ASN_SELF_SIGNED_E; @@ -24515,6 +24595,10 @@ wcchar END_ENC_PRIV_KEY = "-----END ENCRYPTED PRIVATE KEY-----"; wcchar END_EC_PARAM = "-----END EC PARAMETERS-----"; #endif #endif +#ifdef HAVE_PKCS7 +wcchar BEGIN_PKCS7 = "-----BEGIN PKCS7-----"; +wcchar END_PKCS7 = "-----END PKCS7-----"; +#endif #if defined(HAVE_ECC) || defined(HAVE_ED25519) || defined(HAVE_ED448) || \ !defined(NO_DSA) wcchar BEGIN_DSA_PRIV = "-----BEGIN DSA PRIVATE KEY-----"; @@ -24622,6 +24706,13 @@ int wc_PemGetHeaderFooter(int type, const char** header, const char** footer) ret = 0; break; #endif + #ifdef HAVE_PKCS7 + case PKCS7_TYPE: + if (header) *header = BEGIN_PKCS7; + if (footer) *footer = END_PKCS7; + ret = 0; + break; + #endif #ifndef NO_DSA case DSA_TYPE: case DSA_PRIVATEKEY_TYPE: @@ -25659,7 +25750,7 @@ int wc_CertPemToDer(const unsigned char* pem, int pemSz, } if (type != CERT_TYPE && type != CHAIN_CERT_TYPE && type != CA_TYPE && - type != CERTREQ_TYPE) { + type != CERTREQ_TYPE && type != PKCS7_TYPE) { WOLFSSL_MSG("Bad cert type"); return BAD_FUNC_ARG; } @@ -28035,8 +28126,7 @@ int wc_EncodeNameCanonical(EncodedName* name, const char* nameStr, } #endif /* WOLFSSL_CERT_GEN || OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */ -#if (defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_EXT)) || \ - (defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA)) +#ifdef WOLFSSL_ASN_PARSE_KEYUSAGE /* Convert key usage string (comma delimited, null terminated) to word16 * Returns 0 on success, negative on error */ @@ -28159,7 +28249,7 @@ int ParseExtKeyUsageStr(const char* value, byte* extKeyUsage, void* heap) return ret; } -#endif /* (CERT_GEN && CERT_EXT) || (OPENSSL_ALL || OPENSSL_EXTRA) */ +#endif /* WOLFSSL_ASN_PARSE_KEYUSAGE */ #ifdef WOLFSSL_CERT_GEN /* Encodes one attribute of the name (issuer/subject) @@ -33661,9 +33751,9 @@ static int EccSpecifiedECDomainDecode(const byte* input, word32 inSz, #else if (ret == 0) { /* Base X-ordinate */ - DataToHexString(base + 1, curve->size, curve->Gx); + DataToHexString(base + 1, (word32)curve->size, curve->Gx); /* Base Y-ordinate */ - DataToHexString(base + 1 + curve->size, curve->size, curve->Gy); + DataToHexString(base + 1 + curve->size, (word32)curve->size, curve->Gy); /* Prime */ DataToHexString(dataASN[ECCSPECIFIEDASN_IDX_PRIME_P].data.ref.data, dataASN[ECCSPECIFIEDASN_IDX_PRIME_P].data.ref.length, @@ -33888,6 +33978,7 @@ int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key, int curve_id = ECC_CURVE_DEF; #if defined(HAVE_PKCS8) || defined(HAVE_PKCS12) || defined(SM2) word32 algId = 0; + word32 eccOid = 0; #endif /* Validate parameters. */ @@ -33897,11 +33988,11 @@ int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key, #if defined(HAVE_PKCS8) || defined(HAVE_PKCS12) || defined(SM2) /* if has pkcs8 header skip it */ - if (ToTraditionalInline_ex(input, inOutIdx, inSz, &algId) < 0) { + if (ToTraditionalInline_ex2(input, inOutIdx, inSz, &algId, &eccOid) < 0) { /* ignore error, did not have pkcs8 header */ } else { - curve_id = wc_ecc_get_oid(algId, NULL, NULL); + curve_id = wc_ecc_get_oid(eccOid, NULL, NULL); } #endif @@ -34394,7 +34485,7 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx, #endif /* WOLFSSL_ASN_TEMPLATE */ } -#if defined(HAVE_ECC_KEY_EXPORT) && !defined(NO_ASN_CRYPT) +#ifdef HAVE_ECC_KEY_EXPORT /* build DER formatted ECC key, include optional public key if requested, * return length on success, negative on error */ int wc_BuildEccKeyDer(ecc_key* key, byte* output, word32 *inLen, @@ -34825,7 +34916,7 @@ int wc_EccKeyToPKCS8(ecc_key* key, byte* output, return eccToPKCS8(key, output, outLen, 1); } #endif /* HAVE_PKCS8 */ -#endif /* HAVE_ECC_KEY_EXPORT && !NO_ASN_CRYPT */ +#endif /* HAVE_ECC_KEY_EXPORT */ #endif /* HAVE_ECC */ #ifdef WC_ENABLE_ASYM_KEY_IMPORT @@ -35256,10 +35347,13 @@ int SetAsymKeyDer(const byte* privKey, word32 privKeyLen, int sz; #endif - /* Validate parameters. */ - if (privKey == NULL || outLen == 0) { + /* validate parameters */ + if (privKey == NULL) { return BAD_FUNC_ARG; } + if (output != NULL && outLen == 0) { + return BUFFER_E; + } #ifndef WOLFSSL_ASN_TEMPLATE /* calculate size */ @@ -35417,7 +35511,7 @@ int wc_Curve25519PublicKeyToDer(curve25519_key* key, byte* output, word32 inLen, byte pubKey[CURVE25519_PUB_KEY_SIZE]; word32 pubKeyLen = (word32)sizeof(pubKey); - if (key == NULL || output == NULL) { + if (key == NULL) { return BAD_FUNC_ARG; } @@ -35790,7 +35884,7 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size, if (idx >= size) return BUFFER_E; -#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) +#ifdef WOLFSSL_OCSP_PARSE_STATUS single->status->thisDateAsn = source + idx; localIdx = 0; if (GetDateInfo(single->status->thisDateAsn, &localIdx, NULL, @@ -35811,7 +35905,7 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size, #ifndef NO_ASN_TIME_CHECK #ifndef WOLFSSL_NO_OCSP_DATE_CHECK - if (!XVALIDATE_DATE(single->status->thisDate, single->status->thisDateFormat, BEFORE)) + if (!XVALIDATE_DATE(single->status->thisDate, single->status->thisDateFormat, ASN_BEFORE)) return ASN_BEFORE_DATE_E; #endif #endif @@ -35826,7 +35920,7 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size, idx++; if (GetLength(source, &idx, &length, size) < 0) return ASN_PARSE_E; -#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) +#ifdef WOLFSSL_OCSP_PARSE_STATUS single->status->nextDateAsn = source + idx; localIdx = 0; if (GetDateInfo(single->status->nextDateAsn, &localIdx, NULL, @@ -35847,7 +35941,7 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size, #ifndef NO_ASN_TIME_CHECK #ifndef WOLFSSL_NO_OCSP_DATE_CHECK - if (!XVALIDATE_DATE(single->status->nextDate, single->status->nextDateFormat, AFTER)) + if (!XVALIDATE_DATE(single->status->nextDate, single->status->nextDateFormat, ASN_AFTER)) return ASN_AFTER_DATE_E; #endif #endif @@ -35955,15 +36049,14 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size, /* Store the thisDate format - only one possible. */ cs->thisDateFormat = ASN_GENERALIZED_TIME; #if !defined(NO_ASN_TIME_CHECK) && !defined(WOLFSSL_NO_OCSP_DATE_CHECK) - /* Check date is a valid string and BEFORE now. */ - if (!XVALIDATE_DATE(cs->thisDate, ASN_GENERALIZED_TIME, BEFORE)) { + /* Check date is a valid string and ASN_BEFORE now. */ + if (!XVALIDATE_DATE(cs->thisDate, ASN_GENERALIZED_TIME, ASN_BEFORE)) { ret = ASN_BEFORE_DATE_E; } } if (ret == 0) { #endif - #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || \ - defined(WOLFSSL_HAPROXY) || defined(HAVE_LIGHTY) + #ifdef WOLFSSL_OCSP_PARSE_STATUS /* Store ASN.1 version of thisDate. */ cs->thisDateAsn = GetASNItem_Addr( dataASN[SINGLERESPONSEASN_IDX_THISUPDATE_GT], source); @@ -35978,16 +36071,15 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size, /* Store the nextDate format - only one possible. */ cs->nextDateFormat = ASN_GENERALIZED_TIME; #if !defined(NO_ASN_TIME_CHECK) && !defined(WOLFSSL_NO_OCSP_DATE_CHECK) - /* Check date is a valid string and AFTER now. */ - if (!XVALIDATE_DATE(cs->nextDate, ASN_GENERALIZED_TIME, AFTER)) { + /* Check date is a valid string and ASN_AFTER now. */ + if (!XVALIDATE_DATE(cs->nextDate, ASN_GENERALIZED_TIME, ASN_AFTER)) { ret = ASN_AFTER_DATE_E; } } if ((ret == 0) && (dataASN[SINGLERESPONSEASN_IDX_NEXTUPDATE_GT].tag != 0)) { #endif - #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || \ - defined(WOLFSSL_HAPROXY) || defined(HAVE_LIGHTY) + #ifdef WOLFSSL_OCSP_PARSE_STATUS /* Store ASN.1 version of thisDate. */ cs->nextDateAsn = GetASNItem_Addr( dataASN[SINGLERESPONSEASN_IDX_NEXTUPDATE_GT], source); @@ -37412,9 +37504,7 @@ void FreeOcspRequest(OcspRequest* req) XFREE(req->url, req->heap, DYNAMIC_TYPE_OCSP_REQUEST); req->url = NULL; -#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || \ - defined(WOLFSSL_HAPROXY) || defined(WOLFSSL_APACHE_HTTPD) || \ - defined(HAVE_LIGHTY) +#ifdef OPENSSL_EXTRA if (req->cid != NULL) wolfSSL_OCSP_CERTID_free((WOLFSSL_OCSP_CERTID*)req->cid); req->cid = NULL; @@ -38011,7 +38101,7 @@ static int ParseCRL_CertList(RevokedCert* rcert, DecodedCRL* dcrl, { #if !defined(NO_ASN_TIME) && !defined(WOLFSSL_NO_CRL_DATE_CHECK) if (verify != NO_VERIFY && - !XVALIDATE_DATE(dcrl->nextDate, dcrl->nextDateFormat, AFTER)) { + !XVALIDATE_DATE(dcrl->nextDate, dcrl->nextDateFormat, ASN_AFTER)) { WOLFSSL_MSG("CRL after date is no longer valid"); WOLFSSL_ERROR_VERBOSE(CRL_CERT_DATE_ERR); return CRL_CERT_DATE_ERR; @@ -38627,7 +38717,7 @@ int ParseCRL(RevokedCert* rcert, DecodedCRL* dcrl, const byte* buff, word32 sz, if (dcrl->nextDateFormat != 0) { /* Next date was set, so validate it. */ if (verify != NO_VERIFY && - !XVALIDATE_DATE(dcrl->nextDate, dcrl->nextDateFormat, AFTER)) { + !XVALIDATE_DATE(dcrl->nextDate, dcrl->nextDateFormat, ASN_AFTER)) { WOLFSSL_MSG("CRL after date is no longer valid"); ret = CRL_CERT_DATE_ERR; WOLFSSL_ERROR_VERBOSE(ret); diff --git a/wolfcrypt/src/blake2b.c b/wolfcrypt/src/blake2b.c index adc6034040..bce74b305d 100644 --- a/wolfcrypt/src/blake2b.c +++ b/wolfcrypt/src/blake2b.c @@ -12,7 +12,7 @@ */ /* blake2b.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/blake2s.c b/wolfcrypt/src/blake2s.c index 9efa84f3b8..7e36d6ee11 100644 --- a/wolfcrypt/src/blake2s.c +++ b/wolfcrypt/src/blake2s.c @@ -12,7 +12,7 @@ */ /* blake2s.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/camellia.c b/wolfcrypt/src/camellia.c index 9f2897f281..3425177e56 100644 --- a/wolfcrypt/src/camellia.c +++ b/wolfcrypt/src/camellia.c @@ -27,7 +27,7 @@ /* camellia.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/chacha.c b/wolfcrypt/src/chacha.c index f4975604c7..b87418a724 100644 --- a/wolfcrypt/src/chacha.c +++ b/wolfcrypt/src/chacha.c @@ -1,6 +1,6 @@ /* chacha.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -38,6 +38,9 @@ Public domain. #if defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_ARMASM_NO_NEON) /* implementation is located in wolfcrypt/src/port/arm/armv8-chacha.c */ +#elif defined(WOLFSSL_RISCV_ASM) + /* implementation located in wolfcrypt/src/port/rsicv/riscv-64-chacha.c */ + #else #if defined(HAVE_CHACHA) diff --git a/wolfcrypt/src/chacha20_poly1305.c b/wolfcrypt/src/chacha20_poly1305.c index df4147c879..a29a18f25d 100644 --- a/wolfcrypt/src/chacha20_poly1305.c +++ b/wolfcrypt/src/chacha20_poly1305.c @@ -1,6 +1,6 @@ /* chacha.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/chacha_asm.asm b/wolfcrypt/src/chacha_asm.asm index 78de305818..43b4ee16ed 100644 --- a/wolfcrypt/src/chacha_asm.asm +++ b/wolfcrypt/src/chacha_asm.asm @@ -1,6 +1,6 @@ ; /* chacha_asm.asm */ ; /* -; * Copyright (C) 2006-2024 wolfSSL Inc. +; * Copyright (C) 2006-2024 wolfSSL Inc. ; * ; * This file is part of wolfSSL. ; * diff --git a/wolfcrypt/src/cmac.c b/wolfcrypt/src/cmac.c index b77cc33ffe..5e0faecec5 100644 --- a/wolfcrypt/src/cmac.c +++ b/wolfcrypt/src/cmac.c @@ -1,6 +1,6 @@ /* cmac.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/coding.c b/wolfcrypt/src/coding.c index 250994821e..27cf988187 100644 --- a/wolfcrypt/src/coding.c +++ b/wolfcrypt/src/coding.c @@ -1,6 +1,6 @@ /* coding.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/compress.c b/wolfcrypt/src/compress.c index 58c154c596..6496ad436c 100644 --- a/wolfcrypt/src/compress.c +++ b/wolfcrypt/src/compress.c @@ -1,6 +1,6 @@ /* compress.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/cpuid.c b/wolfcrypt/src/cpuid.c index fa7ee43675..67223860c8 100644 --- a/wolfcrypt/src/cpuid.c +++ b/wolfcrypt/src/cpuid.c @@ -1,6 +1,6 @@ /* cpuid.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/cryptocb.c b/wolfcrypt/src/cryptocb.c index 06b9ebe5bc..e3c62a86fc 100644 --- a/wolfcrypt/src/cryptocb.c +++ b/wolfcrypt/src/cryptocb.c @@ -1,6 +1,6 @@ /* cryptocb.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/curve25519.c b/wolfcrypt/src/curve25519.c index 4cd29c4acd..e24034222f 100644 --- a/wolfcrypt/src/curve25519.c +++ b/wolfcrypt/src/curve25519.c @@ -1,6 +1,6 @@ /* curve25519.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/curve448.c b/wolfcrypt/src/curve448.c index dd320a8cc0..3cbf577c0b 100644 --- a/wolfcrypt/src/curve448.c +++ b/wolfcrypt/src/curve448.c @@ -1,6 +1,6 @@ /* curve448.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/des3.c b/wolfcrypt/src/des3.c index e66a33d1f2..87502ab073 100644 --- a/wolfcrypt/src/des3.c +++ b/wolfcrypt/src/des3.c @@ -1,6 +1,6 @@ /* des3.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/dh.c b/wolfcrypt/src/dh.c index 28ed1978d7..1a76ca6dec 100644 --- a/wolfcrypt/src/dh.c +++ b/wolfcrypt/src/dh.c @@ -1,6 +1,6 @@ /* dh.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -1153,7 +1153,7 @@ static int GeneratePrivateDh186(DhKey* key, WC_RNG* rng, byte* priv, } #ifdef WOLFSSL_CHECK_MEM_ZERO - wc_MemZero_Add("GeneratePrivateDh186 cBuf", cBuf, cSz); + wc_MemZero_Add("GeneratePrivateDh186 cBuf", cBuf, cSz); /* cppcheck-suppress uninitvar */ mp_memzero_add("GeneratePrivateDh186 tmpX", tmpX); #endif do { diff --git a/wolfcrypt/src/dilithium.c b/wolfcrypt/src/dilithium.c index 007a9b35ee..521353c608 100644 --- a/wolfcrypt/src/dilithium.c +++ b/wolfcrypt/src/dilithium.c @@ -1,6 +1,6 @@ /* dilithium.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -58,6 +58,19 @@ * WOLFSSL_DILITHIUM_SIGN_SMALL_MEM Default: OFF * Compiles signature implementation that uses smaller amounts of memory but * is considerably slower. + * WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC Default: OFF + * Compiles signature implementation that uses smaller amounts of memory but + * is considerably slower. Allocates vectors and decodes private key data + * into them upfront. + * WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A Default: OFF + * Compiles signature implementation that uses smaller amounts of memory but + * is slower. Allocates matrix A and calculates it upfront. + * WOLFSSL_DILITHIUM_MAKE_KEY_SMALL_MEM Default: OFF + * Compiles key generation implementation that uses smaller amounts of memory + * but is slower. + * WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 Default: OFF + * Compiles the small memory implementations to use a 64-bit polynomial. + * Uses 2KB of memory but is slighlty quicker (2.75-7%). * * WOLFSSL_DILITHIUM_ALIGNMENT Default: 8 * Use to indicate whether loading and storing of words needs to be aligned. @@ -79,6 +92,10 @@ * Enable caching of public key vectors on import. * Enables WC_DILITHIUM_CACHE_MATRIX_A. * Less work is required in sign operations. + * WC_DILITHIUM_FIXED_ARRAY Default: OFF + * Make the matrix and vectors of cached data fixed arrays that have + * maximumal sizes for the configured parameters. + * Useful in low dynamic memory situations. * * WOLFSSL_DILITHIUM_SIGN_CHECK_Y Default: OFF * Check vector y is in required range as an early check on valid vector z. @@ -138,6 +155,18 @@ #include #endif +#if defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC) && \ + !defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM) + #define WOLFSSL_DILITHIUM_SIGN_SMALL_MEM +#endif +#if defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A) && \ + !defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM) + #define WOLFSSL_DILITHIUM_SIGN_SMALL_MEM + #ifdef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC + #error "PRECALC and PRECALC_A is equivalent to non small mem" + #endif +#endif + #ifdef WOLFSSL_WC_DILITHIUM #ifdef DEBUG_DILITHIUM @@ -1674,43 +1703,24 @@ static void dilithium_vec_encode_w1(const sword32* w1, byte k, sword32 gamma2, * @param [in, out] shake128 SHAKE-128 object. * @param [in] seed Seed to hash to generate values. * @param [out] a Polynomial. + * @param [in] h Buffer to hold hashes. * @return 0 on success. - * @return MEMORY_E when dynamic memory allocation fails. * @return Negative on hash error. */ -static int dilithium_rej_ntt_poly(wc_Shake* shake128, byte* seed, sword32* a, - byte* key_h) +static int dilithium_rej_ntt_poly_ex(wc_Shake* shake128, byte* seed, sword32* a, + byte* h) { -#ifdef WOLFSSL_DILITHIUM_SMALL int ret = 0; +#ifdef WOLFSSL_DILITHIUM_SMALL int j = 0; -#if defined(WOLFSSL_SMALL_STACK) || defined(WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC) - byte* h = NULL; -#else - byte h[DILITHIUM_REJ_NTT_POLY_H_SIZE]; -#endif - (void)key_h; - -#ifdef WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC - h = key_h; -#elif defined(WOLFSSL_SMALL_STACK) - h = (byte*)XMALLOC(DILITHIUM_REJ_NTT_POLY_H_SIZE, NULL, - DYNAMIC_TYPE_DILITHIUM); - if (h == NULL) { - ret = MEMORY_E; - } -#endif /* WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC */ - - if (ret == 0) { - #if defined(LITTLE_ENDIAN_ORDER) && (WOLFSSL_DILITHIUM_ALIGNMENT == 0) - /* Reading 4 bytes for 3 so need to set 1 past for last read. */ - h[DILITHIUM_GEN_A_BLOCK_BYTES] = 0; - #endif +#if defined(LITTLE_ENDIAN_ORDER) && (WOLFSSL_DILITHIUM_ALIGNMENT == 0) + /* Reading 4 bytes for 3 so need to set 1 past for last read. */ + h[DILITHIUM_GEN_A_BLOCK_BYTES] = 0; +#endif - /* Initialize SHAKE-128 object for new hash. */ - ret = wc_InitShake128(shake128, NULL, INVALID_DEVID); - } + /* Initialize SHAKE-128 object for new hash. */ + ret = wc_InitShake128(shake128, NULL, INVALID_DEVID); if (ret == 0) { /* Absorb the seed. */ ret = wc_Shake128_Absorb(shake128, seed, DILITHIUM_GEN_A_SEED_SZ); @@ -1746,39 +1756,14 @@ static int dilithium_rej_ntt_poly(wc_Shake* shake128, byte* seed, sword32* a, } } } - -#if !defined(WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC) && defined(WOLFSSL_SMALL_STACK) - XFREE(h, NULL, DYNAMIC_TYPE_DILITHIUM); -#endif - return ret; #else - int ret = 0; unsigned int j = 0; unsigned int c; -#if defined(WOLFSSL_SMALL_STACK) || defined(WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC) - byte* h = NULL; -#else - byte h[DILITHIUM_REJ_NTT_POLY_H_SIZE]; -#endif - - (void)key_h; - -#ifdef WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC - h = key_h; -#elif defined(WOLFSSL_SMALL_STACK) - h = (byte*)XMALLOC(DILITHIUM_REJ_NTT_POLY_H_SIZE, NULL, - DYNAMIC_TYPE_DILITHIUM); - if (h == NULL) { - ret = MEMORY_E; - } -#endif /* WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC */ - if (ret == 0) { - /* Generate enough SHAKE-128 output blocks to give high probability of - * being able to get 256 valid 3-byte, 23-bit values from it. */ - ret = dilithium_squeeze128(shake128, seed, DILITHIUM_GEN_A_SEED_SZ, h, - DILITHIUM_GEN_A_NBLOCKS); - } + /* Generate enough SHAKE-128 output blocks to give high probability of + * being able to get 256 valid 3-byte, 23-bit values from it. */ + ret = dilithium_squeeze128(shake128, seed, DILITHIUM_GEN_A_SEED_SZ, h, + DILITHIUM_GEN_A_NBLOCKS); if (ret == 0) { #if defined(LITTLE_ENDIAN_ORDER) && (WOLFSSL_DILITHIUM_ALIGNMENT == 0) /* Reading 4 bytes for 3 so need to set 1 past for last read. */ @@ -1786,7 +1771,7 @@ static int dilithium_rej_ntt_poly(wc_Shake* shake128, byte* seed, sword32* a, #endif /* Use the first 256 triplets and know we won't exceed required. */ -#ifdef WOLFSSL_DILITHIUM_NO_LARGE_CODE + #ifdef WOLFSSL_DILITHIUM_NO_LARGE_CODE for (c = 0; c < (DILITHIUM_N - 1) * 3; c += 3) { #if defined(LITTLE_ENDIAN_ORDER) && (WOLFSSL_DILITHIUM_ALIGNMENT == 0) /* Load 32-bit value and mask out 23 bits. */ @@ -1822,7 +1807,7 @@ static int dilithium_rej_ntt_poly(wc_Shake* shake128, byte* seed, sword32* a, } } } -#else + #else /* Do 15 bytes at a time: 255 * 3 / 15 = 51 */ for (c = 0; c < DILITHIUM_N * 3; c += 24) { #if defined(LITTLE_ENDIAN_ORDER) && (WOLFSSL_DILITHIUM_ALIGNMENT == 0) @@ -1919,7 +1904,7 @@ static int dilithium_rej_ntt_poly(wc_Shake* shake128, byte* seed, sword32* a, } } } -#endif + #endif /* Keep generating more blocks and using triplets until we have enough. */ while (j < DILITHIUM_N) { @@ -1952,15 +1937,60 @@ static int dilithium_rej_ntt_poly(wc_Shake* shake128, byte* seed, sword32* a, } } } - -#if !defined(WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC) && defined(WOLFSSL_SMALL_STACK) - XFREE(h, NULL, DYNAMIC_TYPE_DILITHIUM); #endif + return ret; +} + +#if (!defined(WOLFSSL_DILITHIUM_NO_MAKE_KEY) && \ + !defined(WOLFSSL_DILITHIUM_MAKE_KEY_SMALL_MEM)) || \ + defined(WOLFSSL_DILITHIUM_CHECK_KEY) || \ + (!defined(WOLFSSL_DILITHIUM_NO_SIGN) && \ + !defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM)) || \ + (!defined(WOLFSSL_DILITHIUM_NO_VERIFY) && \ + !defined(WOLFSSL_DILITHIUM_VERIFY_SMALL_MEM)) +/* Generate a random polynomial by rejection. + * + * @param [in, out] shake128 SHAKE-128 object. + * @param [in] seed Seed to hash to generate values. + * @param [out] a Polynomial. + * @param [in] heap Dynamic memory hint. + * @return 0 on success. + * @return MEMORY_E when dynamic memory allocation fails. + * @return Negative on hash error. + */ +static int dilithium_rej_ntt_poly(wc_Shake* shake128, byte* seed, sword32* a, + void* heap) +{ + int ret; +#if defined(WOLFSSL_SMALL_STACK) + byte* h = NULL; +#else + byte h[DILITHIUM_REJ_NTT_POLY_H_SIZE]; #endif + + (void)heap; + +#if defined(WOLFSSL_SMALL_STACK) + h = (byte*)XMALLOC(DILITHIUM_REJ_NTT_POLY_H_SIZE, heap, + DYNAMIC_TYPE_DILITHIUM); + if (h == NULL) { + ret = MEMORY_E; + } +#endif + + ret = dilithium_rej_ntt_poly_ex(shake128, seed, a, h); + +#if defined(WOLFSSL_SMALL_STACK) + XFREE(h, heap, DYNAMIC_TYPE_DILITHIUM); +#endif + + return ret; } +#endif -#if !defined(WOLFSSL_DILITHIUM_NO_MAKE_KEY) || \ +#if (!defined(WOLFSSL_DILITHIUM_NO_MAKE_KEY) && \ + !defined(WOLFSSL_DILITHIUM_MAKE_KEY_SMALL_MEM)) || \ defined(WOLFSSL_DILITHIUM_CHECK_KEY) || \ (!defined(WOLFSSL_DILITHIUM_NO_VERIFY) && \ !defined(WOLFSSL_DILITHIUM_VERIFY_SMALL_MEM)) || \ @@ -1983,11 +2013,12 @@ static int dilithium_rej_ntt_poly(wc_Shake* shake128, byte* seed, sword32* a, * @param [in] k First dimension of matrix a. * @param [in] l Second dimension of matrix a. * @param [out] a Matrix of polynomials. + * @param [in] heap Dynamic memory hint. * @return 0 on success. * @return Negative on hash error. */ static int dilithium_expand_a(wc_Shake* shake128, const byte* pub_seed, byte k, - byte l, sword32* a) + byte l, sword32* a, void* heap) { int ret = 0; byte r; @@ -2005,7 +2036,7 @@ static int dilithium_expand_a(wc_Shake* shake128, const byte* pub_seed, byte k, /* Put s into buffer to be hashed. */ seed[DILITHIUM_PUB_SEED_SZ + 0] = s; /* Step 3: Create polynomial from hashing seed. */ - ret = dilithium_rej_ntt_poly(shake128, seed, a, NULL); + ret = dilithium_rej_ntt_poly(shake128, seed, a, heap); /* Next polynomial. */ a += DILITHIUM_N; } @@ -2031,7 +2062,7 @@ static int dilithium_expand_a(wc_Shake* shake128, const byte* pub_seed, byte k, #define DILITHIUM_COEFF_S_VALID_ETA2(b) \ ((b) < DILITHIUM_ETA_2_MOD) -static const byte dilithium_coeff_eta2[] = { +static const char dilithium_coeff_eta2[] = { 2, 1, 0, -1, -2, 2, 1, 0, -1, -2, 2, 1, 0, -1, -2 @@ -2514,6 +2545,7 @@ static int dilithium_vec_expand_mask(wc_Shake* shake256, byte* seed, #endif #if !defined(WOLFSSL_DILITHIUM_NO_SIGN) || !defined(WOLFSSL_DILITHIUM_NO_VERIFY) + /* Expand commit to a polynomial. * * FIPS 204. 8.3: Algorithm 23 SampleInBall(rho) @@ -2530,41 +2562,23 @@ static int dilithium_vec_expand_mask(wc_Shake* shake256, byte* seed, * 11: end for * 12: return c * - * @param [in] shake256 SHAKE-256 object. - * @param [in] seed Buffer containing seed to expand. - * @param [in] tau Number of +/- 1s in polynomial. - * @param [out] c Commit polynomial. - * @param [in] key_block Memory to use for block from key. + * @param [in] shake256 SHAKE-256 object. + * @param [in] seed Buffer containing seed to expand. + * @param [in] tau Number of +/- 1s in polynomial. + * @param [out] c Commit polynomial. + * @param [in] block Memory to use for block from key. * @return 0 on success. - * @return MEMORY_E when dynamic memory allocation fails. * @return Negative on hash error. */ -static int dilithium_sample_in_ball(wc_Shake* shake256, const byte* seed, - byte tau, sword32* c, byte* key_block) +static int dilithium_sample_in_ball_ex(wc_Shake* shake256, const byte* seed, + byte tau, sword32* c, byte* block) { int ret = 0; unsigned int k; unsigned int i; unsigned int s; -#if defined(WOLFSSL_SMALL_STACK) || defined(WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC) - byte* block = NULL; -#else - byte block[DILITHIUM_GEN_C_BLOCK_BYTES]; -#endif byte signs[DILITHIUM_SIGN_BYTES]; - (void)key_block; - -#ifdef WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC - block = key_block; -#elif defined(WOLFSSL_SMALL_STACK) - block = (byte*)XMALLOC(DILITHIUM_GEN_C_BLOCK_BYTES, NULL, - DYNAMIC_TYPE_DILITHIUM); - if (block == NULL) { - ret = MEMORY_E; - } -#endif - if (ret == 0) { /* Set polynomial to all zeros. */ XMEMSET(c, 0, DILITHIUM_POLY_SIZE); @@ -2609,13 +2623,57 @@ static int dilithium_sample_in_ball(wc_Shake* shake256, const byte* seed, s++; } -#if !defined(WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC) && defined(WOLFSSL_SMALL_STACK) - XFREE(block, NULL, DYNAMIC_TYPE_DILITHIUM); + return ret; +} + +#if (!defined(WOLFSSL_DILITHIUM_NO_SIGN) && \ + !defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM)) || \ + (!defined(WOLFSSL_DILITHIUM_NO_VERIFY) && \ + !defined(WOLFSSL_DILITHIUM_VERIFY_SMALL_MEM)) +/* Expand commit to a polynomial. + * + * @param [in] shake256 SHAKE-256 object. + * @param [in] seed Buffer containing seed to expand. + * @param [in] tau Number of +/- 1s in polynomial. + * @param [out] c Commit polynomial. + * @param [in] heap Dynamic memory hint. + * @return 0 on success. + * @return MEMORY_E when dynamic memory allocation fails. + * @return Negative on hash error. + */ +static int dilithium_sample_in_ball(wc_Shake* shake256, const byte* seed, + byte tau, sword32* c, void* heap) +{ + int ret = 0; +#if defined(WOLFSSL_SMALL_STACK) + byte* block = NULL; +#else + byte block[DILITHIUM_GEN_C_BLOCK_BYTES]; +#endif + + (void)heap; + +#if defined(WOLFSSL_SMALL_STACK) + block = (byte*)XMALLOC(DILITHIUM_GEN_C_BLOCK_BYTES, heap, + DYNAMIC_TYPE_DILITHIUM); + if (block == NULL) { + ret = MEMORY_E; + } +#endif + + if (ret == 0) { + ret = dilithium_sample_in_ball_ex(shake256, seed, tau, c, block); + } + +#if defined(WOLFSSL_SMALL_STACK) + XFREE(block, heap, DYNAMIC_TYPE_DILITHIUM); #endif return ret; } #endif +#endif + /****************************************************************************** * Decompose operations ******************************************************************************/ @@ -2734,7 +2792,8 @@ static void dilithium_decompose_q32(sword32 r, sword32* r0, sword32* r1) #ifndef WOLFSSL_DILITHIUM_NO_SIGN -#ifndef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM +#if !defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM) || \ + defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A) /* Decompose vector of polynomials into high and low based on GAMMA2. * * @param [in] r Vector of polynomials to decompose. @@ -5201,6 +5260,7 @@ static void dilithium_vec_make_pos(sword32* a, byte l) */ static int dilithium_make_key_from_seed(dilithium_key* key, const byte* seed) { +#ifndef WOLFSSL_DILITHIUM_MAKE_KEY_SMALL_MEM int ret = 0; const wc_dilithium_params* params = key->params; sword32* a = NULL; @@ -5211,19 +5271,24 @@ static int dilithium_make_key_from_seed(dilithium_key* key, const byte* seed) /* Allocate memory for large intermediates. */ #ifdef WC_DILITHIUM_CACHE_MATRIX_A +#ifndef WC_DILITHIUM_FIXED_ARRAY if (key->a == NULL) { - key->a = (sword32*)XMALLOC(params->aSz, NULL, DYNAMIC_TYPE_DILITHIUM); + key->a = (sword32*)XMALLOC(params->aSz, key->heap, + DYNAMIC_TYPE_DILITHIUM); if (key->a == NULL) { ret = MEMORY_E; } } +#endif if (ret == 0) { a = key->a; } #endif #ifdef WC_DILITHIUM_CACHE_PRIV_VECTORS +#ifndef WC_DILITHIUM_FIXED_ARRAY if ((ret == 0) && (key->s1 == NULL)) { - key->s1 = (sword32*)XMALLOC(params->aSz, NULL, DYNAMIC_TYPE_DILITHIUM); + key->s1 = (sword32*)XMALLOC(params->aSz, key->heap, + DYNAMIC_TYPE_DILITHIUM); if (key->s1 == NULL) { ret = MEMORY_E; } @@ -5232,6 +5297,7 @@ static int dilithium_make_key_from_seed(dilithium_key* key, const byte* seed) key->t0 = key->s2 + params->s2Sz / sizeof(*s2); } } +#endif if (ret == 0) { s1 = key->s1; s2 = key->s2; @@ -5247,7 +5313,7 @@ static int dilithium_make_key_from_seed(dilithium_key* key, const byte* seed) #endif /* s1, s2, t, a */ - s1 = (sword32*)XMALLOC(allocSz, NULL, DYNAMIC_TYPE_DILITHIUM); + s1 = (sword32*)XMALLOC(allocSz, key->heap, DYNAMIC_TYPE_DILITHIUM); if (s1 == NULL) { ret = MEMORY_E; } @@ -5255,7 +5321,7 @@ static int dilithium_make_key_from_seed(dilithium_key* key, const byte* seed) s2 = s1 + params->s1Sz / sizeof(*s1); t = s2 + params->s2Sz / sizeof(*s2); #ifndef WC_DILITHIUM_CACHE_MATRIX_A - a = t + params->s2Sz / sizeof(*s2); + a = t + params->s2Sz / sizeof(*t); #endif } } @@ -5273,7 +5339,7 @@ static int dilithium_make_key_from_seed(dilithium_key* key, const byte* seed) /* Step 3: Expand public seed into a matrix of polynomials. */ ret = dilithium_expand_a(&key->shake, pub_seed, params->k, params->l, - a); + a, key->heap); } if (ret == 0) { byte* priv_seed = key->k + DILITHIUM_PUB_SEED_SZ; @@ -5332,9 +5398,213 @@ static int dilithium_make_key_from_seed(dilithium_key* key, const byte* seed) } #ifndef WC_DILITHIUM_CACHE_PRIV_VECTORS - XFREE(s1, NULL, DYNAMIC_TYPE_DILITHIUM); + XFREE(s1, key->heap, DYNAMIC_TYPE_DILITHIUM); #endif return ret; +#else + int ret = 0; + const wc_dilithium_params* params = key->params; + sword32* a = NULL; + sword32* s1 = NULL; + sword32* s2 = NULL; + sword32* t = NULL; +#ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + sword64* t64 = NULL; +#endif + byte* h = NULL; + byte* pub_seed = key->k; + unsigned int r; + unsigned int s; + + /* Allocate memory for large intermediates. */ + if (ret == 0) { + unsigned int allocSz; + + /* s1-l, s2-k, t-k, a-1 */ + allocSz = params->s1Sz + params->s2Sz + params->s2Sz + + DILITHIUM_REJ_NTT_POLY_H_SIZE + DILITHIUM_POLY_SIZE; + #ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + /* t64 */ + allocSz += DILITHIUM_POLY_SIZE * 2; + #endif + s1 = (sword32*)XMALLOC(allocSz, key->heap, DYNAMIC_TYPE_DILITHIUM); + if (s1 == NULL) { + ret = MEMORY_E; + } + else { + s2 = s1 + params->s1Sz / sizeof(*s1); + t = s2 + params->s2Sz / sizeof(*s2); + h = (byte*)(t + params->s2Sz / sizeof(*t)); + a = (sword32*)(h + DILITHIUM_REJ_NTT_POLY_H_SIZE); + #ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + t64 = (sword64*)(a + DILITHIUM_N); + #endif + } + } + + if (ret == 0) { + /* Step 2: Create public seed, private seed and K from seed. + * Step 9; Alg 18, Step 1: Public seed is placed into private key. */ + ret = dilithium_shake256(&key->shake, seed, DILITHIUM_SEED_SZ, pub_seed, + DILITHIUM_SEEDS_SZ); + } + if (ret == 0) { + byte* priv_seed = key->k + DILITHIUM_PUB_SEED_SZ; + + /* Step 7; Alg 16 Step 1: Copy public seed into public key. */ + XMEMCPY(key->p, pub_seed, DILITHIUM_PUB_SEED_SZ); + + /* Step 4: Expand private seed into to vectors of polynomials. */ + ret = dilithium_expand_s(&key->shake, priv_seed, params->eta, s1, + params->l, s2, params->k); + } + if (ret == 0) { + byte* k = pub_seed + DILITHIUM_PUB_SEED_SZ; + byte* tr = k + DILITHIUM_K_SZ; + byte* s1p = tr + DILITHIUM_TR_SZ; + byte* s2p = s1p + params->s1EncSz; + byte* t0 = s2p + params->s2EncSz; + byte* t1 = key->p + DILITHIUM_PUB_SEED_SZ; + byte aseed[DILITHIUM_GEN_A_SEED_SZ]; + sword32* s2t = s2; + sword32* tt = t; + + /* Step 9: Move k down to after public seed. */ + XMEMCPY(k, k + DILITHIUM_PRIV_SEED_SZ, DILITHIUM_K_SZ); + /* Step 9. Alg 18 Steps 2-4: Encode s1 into private key. */ + dilthium_vec_encode_eta_bits(s1, params->l, params->eta, s1p); + /* Step 9. Alg 18 Steps 5-7: Encode s2 into private key. */ + dilthium_vec_encode_eta_bits(s2, params->k, params->eta, s2p); + + /* Step 5: NTT(s1) */ + dilithium_vec_ntt_small(s1, params->l); + /* Step 5: t <- NTT-1(A_circum o NTT(s1)) + s2 */ + XMEMCPY(aseed, pub_seed, DILITHIUM_PUB_SEED_SZ); + for (r = 0; (ret == 0) && (r < params->k); r++) { + sword32* s1t = s1; + unsigned int e; + + /* Put r/i into buffer to be hashed. */ + aseed[DILITHIUM_PUB_SEED_SZ + 1] = r; + for (s = 0; (ret == 0) && (s < params->l); s++) { + + /* Put s into buffer to be hashed. */ + aseed[DILITHIUM_PUB_SEED_SZ + 0] = s; + /* Step 3: Expand public seed into a matrix of polynomials. */ + ret = dilithium_rej_ntt_poly_ex(&key->shake, aseed, a, h); + if (ret != 0) { + break; + } + /* Matrix multiply. */ + #ifndef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + if (s == 0) { + #ifdef WOLFSSL_DILITHIUM_SMALL + for (e = 0; e < DILITHIUM_N; e++) { + tt[e] = dilithium_mont_red((sword64)a[e] * s1t[e]); + } + #else + for (e = 0; e < DILITHIUM_N; e += 8) { + tt[e+0] = dilithium_mont_red((sword64)a[e+0]*s1t[e+0]); + tt[e+1] = dilithium_mont_red((sword64)a[e+1]*s1t[e+1]); + tt[e+2] = dilithium_mont_red((sword64)a[e+2]*s1t[e+2]); + tt[e+3] = dilithium_mont_red((sword64)a[e+3]*s1t[e+3]); + tt[e+4] = dilithium_mont_red((sword64)a[e+4]*s1t[e+4]); + tt[e+5] = dilithium_mont_red((sword64)a[e+5]*s1t[e+5]); + tt[e+6] = dilithium_mont_red((sword64)a[e+6]*s1t[e+6]); + tt[e+7] = dilithium_mont_red((sword64)a[e+7]*s1t[e+7]); + } + #endif + } + else { + #ifdef WOLFSSL_DILITHIUM_SMALL + for (e = 0; e < DILITHIUM_N; e++) { + tt[e] += dilithium_mont_red((sword64)a[e] * s1t[e]); + } + #else + for (e = 0; e < DILITHIUM_N; e += 8) { + tt[e+0] += dilithium_mont_red((sword64)a[e+0]*s1t[e+0]); + tt[e+1] += dilithium_mont_red((sword64)a[e+1]*s1t[e+1]); + tt[e+2] += dilithium_mont_red((sword64)a[e+2]*s1t[e+2]); + tt[e+3] += dilithium_mont_red((sword64)a[e+3]*s1t[e+3]); + tt[e+4] += dilithium_mont_red((sword64)a[e+4]*s1t[e+4]); + tt[e+5] += dilithium_mont_red((sword64)a[e+5]*s1t[e+5]); + tt[e+6] += dilithium_mont_red((sword64)a[e+6]*s1t[e+6]); + tt[e+7] += dilithium_mont_red((sword64)a[e+7]*s1t[e+7]); + } + #endif + } + #else + if (s == 0) { + #ifdef WOLFSSL_DILITHIUM_SMALL + for (e = 0; e < DILITHIUM_N; e++) { + t64[e] = (sword64)a[e] * s1t[e]; + } + #else + for (e = 0; e < DILITHIUM_N; e += 8) { + t64[e+0] = (sword64)a[e+0] * s1t[e+0]; + t64[e+1] = (sword64)a[e+1] * s1t[e+1]; + t64[e+2] = (sword64)a[e+2] * s1t[e+2]; + t64[e+3] = (sword64)a[e+3] * s1t[e+3]; + t64[e+4] = (sword64)a[e+4] * s1t[e+4]; + t64[e+5] = (sword64)a[e+5] * s1t[e+5]; + t64[e+6] = (sword64)a[e+6] * s1t[e+6]; + t64[e+7] = (sword64)a[e+7] * s1t[e+7]; + } + #endif + } + else { + #ifdef WOLFSSL_DILITHIUM_SMALL + for (e = 0; e < DILITHIUM_N; e++) { + t64[e] += (sword64)a[e] * s1t[e]; + } + #else + for (e = 0; e < DILITHIUM_N; e += 8) { + t64[e+0] += (sword64)a[e+0] * s1t[e+0]; + t64[e+1] += (sword64)a[e+1] * s1t[e+1]; + t64[e+2] += (sword64)a[e+2] * s1t[e+2]; + t64[e+3] += (sword64)a[e+3] * s1t[e+3]; + t64[e+4] += (sword64)a[e+4] * s1t[e+4]; + t64[e+5] += (sword64)a[e+5] * s1t[e+5]; + t64[e+6] += (sword64)a[e+6] * s1t[e+6]; + t64[e+7] += (sword64)a[e+7] * s1t[e+7]; + } + #endif + } + #endif + /* Next polynomial. */ + s1t += DILITHIUM_N; + } + #ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + for (e = 0; e < DILITHIUM_N; e++) { + tt[e] = dilithium_mont_red(t64[e]); + } + #endif + dilithium_invntt(tt); + dilithium_add(tt, s2t); + /* Make positive for decomposing. */ + dilithium_make_pos(tt); + + tt += DILITHIUM_N; + s2t += DILITHIUM_N; + } + + /* Step 6, Step 7, Step 9. Alg 16 Steps 2-4, Alg 18 Steps 8-10. + * Decompose t in t0 and t1 and encode into public and private key. + */ + dilithium_vec_encode_t0_t1(t, params->k, t0, t1); + /* Step 8. Alg 18, Step 1: Hash public key into private key. */ + ret = dilithium_shake256(&key->shake, key->p, params->pkSz, tr, + DILITHIUM_TR_SZ); + } + if (ret == 0) { + /* Public key and private key are available. */ + key->prvKeySet = 1; + key->pubKeySet = 1; + } + + XFREE(s1, key->heap, DYNAMIC_TYPE_DILITHIUM); + return ret; +#endif } /* Make a key from a random seed. @@ -5368,6 +5638,7 @@ static int dilithium_make_key(dilithium_key* key, WC_RNG* rng) #ifndef WOLFSSL_DILITHIUM_NO_SIGN #if !defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM) || \ + defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC) || \ defined(WC_DILITHIUM_CACHE_PRIV_VECTORS) /* Decode, from private key, and NTT private key vectors s1, s2, and t0. * @@ -5470,9 +5741,9 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, #ifndef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM int ret = 0; const wc_dilithium_params* params = key->params; - byte* pub_seed = key->k; - byte* k = pub_seed + DILITHIUM_PUB_SEED_SZ; - byte* tr = k + DILITHIUM_K_SZ; + const byte* pub_seed = key->k; + const byte* k = pub_seed + DILITHIUM_PUB_SEED_SZ; + const byte* tr = k + DILITHIUM_K_SZ; sword32* a = NULL; sword32* s1 = NULL; sword32* s2 = NULL; @@ -5499,19 +5770,22 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, /* Allocate memory for large intermediates. */ #ifdef WC_DILITHIUM_CACHE_MATRIX_A +#ifndef WC_DILITHIUM_FIXED_ARRAY if ((ret == 0) && (key->a == NULL)) { - a = (sword32*)XMALLOC(params->aSz, NULL, DYNAMIC_TYPE_DILITHIUM); + a = (sword32*)XMALLOC(params->aSz, key->heap, DYNAMIC_TYPE_DILITHIUM); if (a == NULL) { ret = MEMORY_E; } } +#endif if (ret == 0) { a = key->a; } #endif #ifdef WC_DILITHIUM_CACHE_PRIV_VECTORS +#ifndef WC_DILITHIUM_FIXED_ARRAY if ((ret == 0) && (key->s1 == NULL)) { - key->s1 = (sword32*)XMALLOC(params->aSz, NULL, DYNAMIC_TYPE_DILITHIUM); + key->s1 = (sword32*)XMALLOC(params->aSz, key->heap, DYNAMIC_TYPE_DILITHIUM); if (key->s1 == NULL) { ret = MEMORY_E; } @@ -5520,6 +5794,7 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, key->t0 = key->s2 + params->s2Sz / sizeof(*s2); } } +#endif if (ret == 0) { s1 = key->s1; s2 = key->s2; @@ -5540,7 +5815,7 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, /* A */ allocSz += params->aSz; #endif - y = (sword32*)XMALLOC(allocSz, NULL, DYNAMIC_TYPE_DILITHIUM); + y = (sword32*)XMALLOC(allocSz, key->heap, DYNAMIC_TYPE_DILITHIUM); if (y == NULL) { ret = MEMORY_E; } @@ -5578,7 +5853,7 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, { /* Step 5: Create the matrix A from the public seed. */ ret = dilithium_expand_a(&key->shake, pub_seed, params->k, - params->l, a); + params->l, a, key->heap); #ifdef WC_DILITHIUM_CACHE_MATRIX_A key->aSet = (ret == 0); #endif @@ -5643,7 +5918,7 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, if (ret == 0) { /* Step 17: Compute c from first 256 bits of commit. */ ret = dilithium_sample_in_ball(&key->shake, commit, - params->tau, c, NULL); + params->tau, c, key->heap); } if (ret == 0) { sword32 hi; @@ -5713,14 +5988,14 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, dilithium_vec_encode_gamma1(z, params->l, params->gamma1_bits, ze); } - XFREE(y, NULL, DYNAMIC_TYPE_DILITHIUM); + XFREE(y, key->heap, DYNAMIC_TYPE_DILITHIUM); return ret; #else int ret = 0; const wc_dilithium_params* params = key->params; - byte* pub_seed = key->k; - byte* k = pub_seed + DILITHIUM_PUB_SEED_SZ; - byte* tr = k + DILITHIUM_K_SZ; + const byte* pub_seed = key->k; + const byte* k = pub_seed + DILITHIUM_PUB_SEED_SZ; + const byte* tr = k + DILITHIUM_K_SZ; const byte* s1p = tr + DILITHIUM_TR_SZ; const byte* s2p = s1p + params->s1EncSz; const byte* t0p = s2p + params->s2EncSz; @@ -5735,10 +6010,18 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, sword32* c = NULL; sword32* z = NULL; sword32* ct0 = NULL; +#ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + sword64* t64 = NULL; +#endif + byte* blocks = NULL; byte data[DILITHIUM_RND_SZ + DILITHIUM_MU_SZ]; byte* mu = data + DILITHIUM_RND_SZ; byte priv_rand_seed[DILITHIUM_Y_SEED_SZ]; byte* h = sig + params->lambda * 2 + params->zEncSz; +#ifdef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A + byte maxK = (byte)min(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A, + params->k); +#endif /* Check the signature buffer isn't too small. */ if ((ret == 0) && (*sigLen < params->sigSz)) { @@ -5753,24 +6036,55 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, if (ret == 0) { unsigned int allocSz; - /* y-l, w0-k, w1-k, c-1, s1-1, A-1 */ - allocSz = params->s1Sz + params->s2Sz + params->s2Sz + + /* y-l, w0-k, w1-k, blocks, c-1, z-1, A-1 */ + allocSz = params->s1Sz + params->s2Sz + params->s2Sz + + DILITHIUM_REJ_NTT_POLY_H_SIZE + DILITHIUM_POLY_SIZE + DILITHIUM_POLY_SIZE + DILITHIUM_POLY_SIZE; - y = (sword32*)XMALLOC(allocSz, NULL, DYNAMIC_TYPE_DILITHIUM); + #ifdef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC + allocSz += params->s1Sz + params->s2Sz + params->s2Sz; + #elif defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A) + allocSz += maxK * params->l * DILITHIUM_POLY_SIZE; + #endif + #ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + allocSz += DILITHIUM_POLY_SIZE * 2; + #endif + y = (sword32*)XMALLOC(allocSz, key->heap, DYNAMIC_TYPE_DILITHIUM); if (y == NULL) { ret = MEMORY_E; } else { - w0 = y + params->s1Sz / sizeof(*y_ntt); - w1 = w0 + params->s2Sz / sizeof(*w0); - c = w1 + params->s2Sz / sizeof(*w1); - s1 = c + DILITHIUM_N; - a = s1 + DILITHIUM_N; - s2 = s1; - t0 = s1; - ct0 = s1; - z = s1; - y_ntt = s1; + w0 = y + params->s1Sz / sizeof(*y_ntt); + w1 = w0 + params->s2Sz / sizeof(*w0); + blocks = (byte*)(w1 + params->s2Sz / sizeof(*w1)); + c = (sword32*)(blocks + DILITHIUM_REJ_NTT_POLY_H_SIZE); + z = c + DILITHIUM_N; + a = z + DILITHIUM_N; + ct0 = z; + #if defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A) + y_ntt = w0; + s1 = z; + s2 = z; + t0 = z; + #ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + t64 = (sword64*)(a + (1 + maxK * params->l) * DILITHIUM_N); + #endif + #elif defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC) + y_ntt = z; + s1 = a + DILITHIUM_N; + s2 = s1 + params->s1Sz / sizeof(*s1); + t0 = s2 + params->s2Sz / sizeof(*s2); + #ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + t64 = (sword64*)(t0 + params->s2Sz / sizeof(*t0)); + #endif + #else + y_ntt = z; + s1 = z; + s2 = z; + t0 = z; + #ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + t64 = (sword64*)(a + DILITHIUM_N); + #endif + #endif } } @@ -5788,23 +6102,43 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, DILITHIUM_RND_SZ + DILITHIUM_MU_SZ, priv_rand_seed, DILITHIUM_PRIV_RAND_SEED_SZ); } +#ifdef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC + if (ret == 0) { + dilithium_make_priv_vecs(key, s1, s2, t0); + } +#endif +#ifdef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A + if (ret == 0) { + /* Step 5: Create the matrix A from the public seed. */ + ret = dilithium_expand_a(&key->shake, pub_seed, maxK, params->l, a, + key->heap); + } +#endif if (ret == 0) { word16 kappa = 0; int valid; /* Step 11: Start rejection sampling loop */ do { + byte aseed[DILITHIUM_GEN_A_SEED_SZ]; byte w1e[DILITHIUM_MAX_W1_ENC_SZ]; sword32* w = w1; byte* commit = sig; byte r; byte s; - byte aseed[DILITHIUM_GEN_A_SEED_SZ]; sword32 hi; - sword32* at = a; sword32* wt = w; sword32* w0t = w0; sword32* w1t = w1; + sword32* at = a; + + #ifdef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A + w0t += WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A * DILITHIUM_N; + w1t += WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A * DILITHIUM_N; + wt += WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A * DILITHIUM_N; + at += WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A * params->l * + DILITHIUM_N; + #endif valid = 1; /* Step 12: Compute vector y from private random seed and kappa. */ @@ -5815,13 +6149,33 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, (1 << params->gamma1_bits) - params->beta); #endif + #ifdef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A + /* Step 13: NTT-1(A o NTT(y)) */ + XMEMCPY(y_ntt, y, params->s1Sz); + dilithium_vec_ntt(y_ntt, params->l); + dilithium_matrix_mul(w, a, y_ntt, maxK, params->l); + dilithium_vec_invntt(w, maxK); + /* Step 14, Step 22: Make values positive and decompose. */ + dilithium_vec_make_pos(w, maxK); + dilithium_vec_decompose(w, maxK, params->gamma2, w0, w1); + #endif /* Step 5: Create the matrix A from the public seed. */ /* Copy the seed into a buffer that has space for s and r. */ XMEMCPY(aseed, pub_seed, DILITHIUM_PUB_SEED_SZ); + #ifdef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A + r = WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A; + #else + r = 0; + #endif /* Alg 26. Step 1: Loop over first dimension of matrix. */ - for (r = 0; (ret == 0) && valid && (r < params->k); r++) { + for (; (ret == 0) && valid && (r < params->k); r++) { unsigned int e; sword32* yt = y; + #ifdef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A + sword32* y_ntt_t = z; + #else + sword32* y_ntt_t = y_ntt; + #endif /* Put r/i into buffer to be hashed. */ aseed[DILITHIUM_PUB_SEED_SZ + 1] = r; @@ -5830,29 +6184,115 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, /* Put s into buffer to be hashed. */ aseed[DILITHIUM_PUB_SEED_SZ + 0] = s; /* Alg 26. Step 3: Create polynomial from hashing seed. */ - ret = dilithium_rej_ntt_poly(&key->shake, aseed, at, - NULL); + ret = dilithium_rej_ntt_poly_ex(&key->shake, aseed, at, + blocks); if (ret != 0) { break; } - XMEMCPY(y_ntt, yt, DILITHIUM_POLY_SIZE); - dilithium_ntt(y_ntt); + XMEMCPY(y_ntt_t, yt, DILITHIUM_POLY_SIZE); + dilithium_ntt(y_ntt_t); /* Matrix multiply. */ + #ifndef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 if (s == 0) { + #ifdef WOLFSSL_DILITHIUM_SMALL for (e = 0; e < DILITHIUM_N; e++) { wt[e] = dilithium_mont_red((sword64)at[e] * - y_ntt[e]); + y_ntt_t[e]); + } + #else + for (e = 0; e < DILITHIUM_N; e += 8) { + wt[e + 0] = dilithium_mont_red((sword64)at[e + 0] * + y_ntt_t[e + 0]); + wt[e + 1] = dilithium_mont_red((sword64)at[e + 1] * + y_ntt_t[e + 1]); + wt[e + 2] = dilithium_mont_red((sword64)at[e + 2] * + y_ntt_t[e + 2]); + wt[e + 3] = dilithium_mont_red((sword64)at[e + 3] * + y_ntt_t[e + 3]); + wt[e + 4] = dilithium_mont_red((sword64)at[e + 4] * + y_ntt_t[e + 4]); + wt[e + 5] = dilithium_mont_red((sword64)at[e + 5] * + y_ntt_t[e + 5]); + wt[e + 6] = dilithium_mont_red((sword64)at[e + 6] * + y_ntt_t[e + 6]); + wt[e + 7] = dilithium_mont_red((sword64)at[e + 7] * + y_ntt_t[e + 7]); } + #endif } else { + #ifdef WOLFSSL_DILITHIUM_SMALL for (e = 0; e < DILITHIUM_N; e++) { wt[e] += dilithium_mont_red((sword64)at[e] * - y_ntt[e]); + y_ntt_t[e]); + } + #else + for (e = 0; e < DILITHIUM_N; e += 8) { + wt[e + 0] += dilithium_mont_red((sword64)at[e + 0] * + y_ntt_t[e + 0]); + wt[e + 1] += dilithium_mont_red((sword64)at[e + 1] * + y_ntt_t[e + 1]); + wt[e + 2] += dilithium_mont_red((sword64)at[e + 2] * + y_ntt_t[e + 2]); + wt[e + 3] += dilithium_mont_red((sword64)at[e + 3] * + y_ntt_t[e + 3]); + wt[e + 4] += dilithium_mont_red((sword64)at[e + 4] * + y_ntt_t[e + 4]); + wt[e + 5] += dilithium_mont_red((sword64)at[e + 5] * + y_ntt_t[e + 5]); + wt[e + 6] += dilithium_mont_red((sword64)at[e + 6] * + y_ntt_t[e + 6]); + wt[e + 7] += dilithium_mont_red((sword64)at[e + 7] * + y_ntt_t[e + 7]); } + #endif + } + #else + if (s == 0) { + #ifdef WOLFSSL_DILITHIUM_SMALL + for (e = 0; e < DILITHIUM_N; e++) { + t64[e] = (sword64)at[e] * y_ntt_t[e]; + } + #else + for (e = 0; e < DILITHIUM_N; e += 8) { + t64[e+0] = (sword64)at[e+0] * y_ntt_t[e+0]; + t64[e+1] = (sword64)at[e+1] * y_ntt_t[e+1]; + t64[e+2] = (sword64)at[e+2] * y_ntt_t[e+2]; + t64[e+3] = (sword64)at[e+3] * y_ntt_t[e+3]; + t64[e+4] = (sword64)at[e+4] * y_ntt_t[e+4]; + t64[e+5] = (sword64)at[e+5] * y_ntt_t[e+5]; + t64[e+6] = (sword64)at[e+6] * y_ntt_t[e+6]; + t64[e+7] = (sword64)at[e+7] * y_ntt_t[e+7]; + } + #endif } + else { + #ifdef WOLFSSL_DILITHIUM_SMALL + for (e = 0; e < DILITHIUM_N; e++) { + t64[e] += (sword64)at[e] * y_ntt_t[e]; + } + #else + for (e = 0; e < DILITHIUM_N; e += 8) { + t64[e+0] += (sword64)at[e+0] * y_ntt_t[e+0]; + t64[e+1] += (sword64)at[e+1] * y_ntt_t[e+1]; + t64[e+2] += (sword64)at[e+2] * y_ntt_t[e+2]; + t64[e+3] += (sword64)at[e+3] * y_ntt_t[e+3]; + t64[e+4] += (sword64)at[e+4] * y_ntt_t[e+4]; + t64[e+5] += (sword64)at[e+5] * y_ntt_t[e+5]; + t64[e+6] += (sword64)at[e+6] * y_ntt_t[e+6]; + t64[e+7] += (sword64)at[e+7] * y_ntt_t[e+7]; + } + #endif + } + #endif /* Next polynomial. */ yt += DILITHIUM_N; } + #ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + for (e = 0; e < DILITHIUM_N; e++) { + wt[e] = dilithium_mont_red(t64[e]); + } + #endif dilithium_invntt(wt); /* Step 14, Step 22: Make values positive and decompose. */ dilithium_make_pos(wt); @@ -5884,7 +6324,9 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, } if ((ret == 0) && valid) { sword32* yt = y; + #ifndef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC const byte* s1pt = s1p; + #endif byte* ze = sig + params->lambda * 2; /* Step 15: Encode w1. */ @@ -5895,8 +6337,8 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, w1e, params->w1EncSz, commit, 2 * params->lambda); if (ret == 0) { /* Step 17: Compute c from first 256 bits of commit. */ - ret = dilithium_sample_in_ball(&key->shake, commit, - params->tau, c, NULL); + ret = dilithium_sample_in_ball_ex(&key->shake, commit, + params->tau, c, blocks); } if (ret == 0) { /* Step 18: NTT(c). */ @@ -5904,6 +6346,7 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, } for (s = 0; (ret == 0) && valid && (s < params->l); s++) { + #ifndef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC #if !defined(WOLFSSL_NO_ML_DSA_44) || \ !defined(WOLFSSL_NO_ML_DSA_87) /* -2..2 */ @@ -5921,6 +6364,9 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, #endif dilithium_ntt_small(s1); dilithium_mul(z, c, s1); + #else + dilithium_mul(z, c, s1 + s * DILITHIUM_N); + #endif /* Step 19: cs1 = NTT-1(c o s1) */ dilithium_invntt(z); /* Step 21: z = y + cs1 */ @@ -5957,13 +6403,16 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, } if ((ret == 0) && valid) { const byte* t0pt = t0p; + #ifndef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC const byte* s2pt = s2p; + #endif sword32* cs2 = ct0; w0t = w0; w1t = w1; byte idx = 0; for (r = 0; valid && (r < params->k); r++) { + #ifndef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC #if !defined(WOLFSSL_NO_ML_DSA_44) || \ !defined(WOLFSSL_NO_ML_DSA_87) /* -2..2 */ @@ -5978,10 +6427,14 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, dilithium_decode_eta_4_bits(s2pt, s2); s2pt += DILITHIUM_N / 2; } - #endif + #endif dilithium_ntt_small(s2); /* Step 20: cs2 = NTT-1(c o s2) */ dilithium_mul(cs2, c, s2); + #else + /* Step 20: cs2 = NTT-1(c o s2) */ + dilithium_mul(cs2, c, s2 + r * DILITHIUM_N); + #endif dilithium_invntt(cs2); /* Step 22: w0 - cs2 */ dilithium_sub(w0t, cs2); @@ -5990,11 +6443,16 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, hi = params->gamma2 - params->beta; valid = dilithium_check_low(w0t, hi); if (valid) { + #ifndef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC dilithium_decode_t0(t0pt, t0); dilithium_ntt(t0); /* Step 25: ct0 = NTT-1(c o t0) */ dilithium_mul(ct0, c, t0); + #else + /* Step 25: ct0 = NTT-1(c o t0) */ + dilithium_mul(ct0, c, t0 + r * DILITHIUM_N); + #endif dilithium_invntt(ct0); /* Step 27: Check ct0 has low enough values. */ valid = dilithium_check_low(ct0, params->gamma2); @@ -6052,7 +6510,7 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed, while ((ret == 0) && (!valid)); } - XFREE(y, NULL, DYNAMIC_TYPE_DILITHIUM); + XFREE(y, key->heap, DYNAMIC_TYPE_DILITHIUM); return ret; #endif } @@ -6104,7 +6562,8 @@ static int dilithium_sign_msg(dilithium_key* key, WC_RNG* rng, const byte* msg, #ifndef WOLFSSL_DILITHIUM_NO_VERIFY -#ifndef WOLFSSL_DILITHIUM_VERIFY_SMALL_MEM +#if !defined(WOLFSSL_DILITHIUM_VERIFY_SMALL_MEM) || \ + defined(WC_DILITHIUM_CACHE_PUB_VECTORS) static void dilithium_make_pub_vec(dilithium_key* key, sword32* t1) { const wc_dilithium_params* params = key->params; @@ -6184,23 +6643,29 @@ static int dilithium_verify_msg(dilithium_key* key, const byte* msg, /* Allocate memory for large intermediates. */ #ifdef WC_DILITHIUM_CACHE_MATRIX_A +#ifndef WC_DILITHIUM_FIXED_ARRAY if ((ret == 0) && (key->a == NULL)) { - key->a = (sword32*)XMALLOC(params->aSz, NULL, DYNAMIC_TYPE_DILITHIUM); + key->a = (sword32*)XMALLOC(params->aSz, key->heap, + DYNAMIC_TYPE_DILITHIUM); if (key->a == NULL) { ret = MEMORY_E; } } +#endif if (ret == 0) { a = key->a; } #endif #ifdef WC_DILITHIUM_CACHE_PUB_VECTORS +#ifndef WC_DILITHIUM_FIXED_ARRAY if ((ret == 0) && (key->t1 == NULL)) { - key->t1 = (sword32*)XMALLOC(params->s2Sz, NULL, DYNAMIC_TYPE_DILITHIUM); + key->t1 = (sword32*)XMALLOC(params->s2Sz, key->heap, + DYNAMIC_TYPE_DILITHIUM); if (key->t1 == NULL) { ret = MEMORY_E; } } +#endif if (ret == 0) { t1 = key->t1; } @@ -6216,7 +6681,7 @@ static int dilithium_verify_msg(dilithium_key* key, const byte* msg, allocSz += params->aSz; #endif - z = (sword32*)XMALLOC(allocSz, NULL, DYNAMIC_TYPE_DILITHIUM); + z = (sword32*)XMALLOC(allocSz, key->heap, DYNAMIC_TYPE_DILITHIUM); if (z == NULL) { ret = MEMORY_E; } @@ -6260,7 +6725,7 @@ static int dilithium_verify_msg(dilithium_key* key, const byte* msg, { /* Step 5: Expand pub seed to compute matrix A. */ ret = dilithium_expand_a(&key->shake, pub_seed, params->k, - params->l, a); + params->l, a, key->heap); #ifdef WC_DILITHIUM_CACHE_MATRIX_A /* Whether we have cached A is dependent on success of operation. */ key->aSet = (ret == 0); @@ -6278,9 +6743,9 @@ static int dilithium_verify_msg(dilithium_key* key, const byte* msg, mu, DILITHIUM_MU_SZ); } if ((ret == 0) && valid) { - /* Step 9: Compute c from first 256 bits of commit. */ - ret = dilithium_sample_in_ball(&key->shake, commit, params->tau, c, - NULL); + /* Step 9: Compute c from first 256 bits of commit. */ + ret = dilithium_sample_in_ball(&key->shake, commit, params->tau, c, + key->heap); } if ((ret == 0) && valid) { /* Step 10: w = NTT-1(A o NTT(z) - NTT(c) o NTT(t1)) */ @@ -6304,7 +6769,7 @@ static int dilithium_verify_msg(dilithium_key* key, const byte* msg, } *res = valid; - XFREE(z, NULL, DYNAMIC_TYPE_DILITHIUM); + XFREE(z, key->heap, DYNAMIC_TYPE_DILITHIUM); return ret; #else int ret = 0; @@ -6319,14 +6784,19 @@ static int dilithium_verify_msg(dilithium_key* key, const byte* msg, sword32* c = NULL; sword32* z = NULL; sword32* w = NULL; +#ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + sword64* t64 = NULL; +#endif +#ifndef WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC + byte* block = NULL; +#endif byte tr[DILITHIUM_TR_SZ]; byte* mu = tr; byte* w1e = NULL; byte* commit_calc = tr; int valid = 0; sword32 hi; - byte i; - unsigned int j; + unsigned int r; byte o; byte* encW1; byte* seed = tr; @@ -6344,17 +6814,27 @@ static int dilithium_verify_msg(dilithium_key* key, const byte* msg, /* Allocate memory for large intermediates. */ if (ret == 0) { /* z, c, w, t1, w1e. */ - z = (sword32*)XMALLOC(params->s1Sz + 3 * DILITHIUM_POLY_SIZE + - DILITHIUM_MAX_W1_ENC_SZ, NULL, DYNAMIC_TYPE_DILITHIUM); + unsigned int allocSz; + + allocSz = params->s1Sz + 3 * DILITHIUM_POLY_SIZE + + DILITHIUM_REJ_NTT_POLY_H_SIZE + params->w1EncSz; + #ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + allocSz += DILITHIUM_POLY_SIZE * 2; + #endif + z = (sword32*)XMALLOC(allocSz, key->heap, DYNAMIC_TYPE_DILITHIUM); if (z == NULL) { ret = MEMORY_E; } else { - c = z + params->s1Sz / sizeof(*t1); - w = c + DILITHIUM_N; - t1 = w + DILITHIUM_N; - w1e = (byte*)(t1 + DILITHIUM_N); - a = t1; + c = z + params->s1Sz / sizeof(*t1); + w = c + DILITHIUM_N; + t1 = w + DILITHIUM_N; + block = (byte*)(t1 + DILITHIUM_N); + w1e = block + DILITHIUM_REJ_NTT_POLY_H_SIZE; + a = t1; + #ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + t64 = (sword64*)(w1e + params->w1EncSz); + #endif } } #else @@ -6365,6 +6845,9 @@ static int dilithium_verify_msg(dilithium_key* key, const byte* msg, t1 = key->t1; w1e = key->w1e; a = t1; + #ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + t64 = key->t64; + #endif } #endif @@ -6381,11 +6864,11 @@ static int dilithium_verify_msg(dilithium_key* key, const byte* msg, /* Step 9: Compute c from first 256 bits of commit. */ #ifdef WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC - ret = dilithium_sample_in_ball(&key->shake, commit, params->tau, c, + ret = dilithium_sample_in_ball_ex(&key->shake, commit, params->tau, c, key->block); #else - ret = dilithium_sample_in_ball(&key->shake, commit, params->tau, c, - NULL); + ret = dilithium_sample_in_ball_ex(&key->shake, commit, params->tau, c, + block); #endif } if ((ret == 0) && valid) { @@ -6397,8 +6880,9 @@ static int dilithium_verify_msg(dilithium_key* key, const byte* msg, /* Copy the seed into a buffer that has space for s and r. */ XMEMCPY(seed, pub_seed, DILITHIUM_PUB_SEED_SZ); /* Step 1: Loop over first dimension of matrix. */ - for (i = 0; (ret == 0) && (i < params->k); i++) { - byte s; + for (r = 0; (ret == 0) && (r < params->k); r++) { + unsigned int s; + unsigned int e; const sword32* zt = z; /* Step 1: Decode and NTT vector t1. */ @@ -6408,80 +6892,123 @@ static int dilithium_verify_msg(dilithium_key* key, const byte* msg, /* Step 10: - NTT(c) o NTT(t1)) */ dilithium_ntt(w); -#ifdef WOLFSSL_DILITHIUM_SMALL - for (j = 0; j < DILITHIUM_N; j++) { - w[j] = -dilithium_mont_red((sword64)c[j] * w[j]); + #ifndef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + #ifdef WOLFSSL_DILITHIUM_SMALL + for (e = 0; e < DILITHIUM_N; e++) { + w[e] = -dilithium_mont_red((sword64)c[e] * w[e]); } -#else - for (j = 0; j < DILITHIUM_N; j += 8) { - w[j+0] = -dilithium_mont_red((sword64)c[j+0] * w[j+0]); - w[j+1] = -dilithium_mont_red((sword64)c[j+1] * w[j+1]); - w[j+2] = -dilithium_mont_red((sword64)c[j+2] * w[j+2]); - w[j+3] = -dilithium_mont_red((sword64)c[j+3] * w[j+3]); - w[j+4] = -dilithium_mont_red((sword64)c[j+4] * w[j+4]); - w[j+5] = -dilithium_mont_red((sword64)c[j+5] * w[j+5]); - w[j+6] = -dilithium_mont_red((sword64)c[j+6] * w[j+6]); - w[j+7] = -dilithium_mont_red((sword64)c[j+7] * w[j+7]); + #else + for (e = 0; e < DILITHIUM_N; e += 8) { + w[e+0] = -dilithium_mont_red((sword64)c[e+0] * w[e+0]); + w[e+1] = -dilithium_mont_red((sword64)c[e+1] * w[e+1]); + w[e+2] = -dilithium_mont_red((sword64)c[e+2] * w[e+2]); + w[e+3] = -dilithium_mont_red((sword64)c[e+3] * w[e+3]); + w[e+4] = -dilithium_mont_red((sword64)c[e+4] * w[e+4]); + w[e+5] = -dilithium_mont_red((sword64)c[e+5] * w[e+5]); + w[e+6] = -dilithium_mont_red((sword64)c[e+6] * w[e+6]); + w[e+7] = -dilithium_mont_red((sword64)c[e+7] * w[e+7]); } -#endif + #endif + #else + #ifdef WOLFSSL_DILITHIUM_SMALL + for (e = 0; e < DILITHIUM_N; e++) { + t64[e] = -(sword64)c[e] * w[e]; + } + #else + for (e = 0; e < DILITHIUM_N; e += 8) { + t64[e+0] = -(sword64)c[e+0] * w[e+0]; + t64[e+1] = -(sword64)c[e+1] * w[e+1]; + t64[e+2] = -(sword64)c[e+2] * w[e+2]; + t64[e+3] = -(sword64)c[e+3] * w[e+3]; + t64[e+4] = -(sword64)c[e+4] * w[e+4]; + t64[e+5] = -(sword64)c[e+5] * w[e+5]; + t64[e+6] = -(sword64)c[e+6] * w[e+6]; + t64[e+7] = -(sword64)c[e+7] * w[e+7]; + } + #endif + #endif /* Step 5: Expand pub seed to compute matrix A. */ /* Put r into buffer to be hashed. */ - seed[DILITHIUM_PUB_SEED_SZ + 1] = i; + seed[DILITHIUM_PUB_SEED_SZ + 1] = r; for (s = 0; (ret == 0) && (s < params->l); s++) { /* Put s into buffer to be hashed. */ seed[DILITHIUM_PUB_SEED_SZ + 0] = s; /* Step 3: Create polynomial from hashing seed. */ #ifdef WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC - ret = dilithium_rej_ntt_poly(&key->shake, seed, a, key->h); + ret = dilithium_rej_ntt_poly_ex(&key->shake, seed, a, key->h); #else - ret = dilithium_rej_ntt_poly(&key->shake, seed, a, NULL); + ret = dilithium_rej_ntt_poly_ex(&key->shake, seed, a, block); #endif /* Step 10: w = A o NTT(z) - NTT(c) o NTT(t1) */ -#ifdef WOLFSSL_DILITHIUM_SMALL - for (j = 0; j < DILITHIUM_N; j++) { - w[j] += dilithium_mont_red((sword64)a[j] * zt[j]); + #ifndef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + #ifdef WOLFSSL_DILITHIUM_SMALL + for (e = 0; e < DILITHIUM_N; e++) { + w[e] += dilithium_mont_red((sword64)a[e] * zt[e]); } -#else - for (j = 0; j < DILITHIUM_N; j += 8) { - w[j+0] += dilithium_mont_red((sword64)a[j+0] * zt[j+0]); - w[j+1] += dilithium_mont_red((sword64)a[j+1] * zt[j+1]); - w[j+2] += dilithium_mont_red((sword64)a[j+2] * zt[j+2]); - w[j+3] += dilithium_mont_red((sword64)a[j+3] * zt[j+3]); - w[j+4] += dilithium_mont_red((sword64)a[j+4] * zt[j+4]); - w[j+5] += dilithium_mont_red((sword64)a[j+5] * zt[j+5]); - w[j+6] += dilithium_mont_red((sword64)a[j+6] * zt[j+6]); - w[j+7] += dilithium_mont_red((sword64)a[j+7] * zt[j+7]); + #else + for (e = 0; e < DILITHIUM_N; e += 8) { + w[e+0] += dilithium_mont_red((sword64)a[e+0] * zt[e+0]); + w[e+1] += dilithium_mont_red((sword64)a[e+1] * zt[e+1]); + w[e+2] += dilithium_mont_red((sword64)a[e+2] * zt[e+2]); + w[e+3] += dilithium_mont_red((sword64)a[e+3] * zt[e+3]); + w[e+4] += dilithium_mont_red((sword64)a[e+4] * zt[e+4]); + w[e+5] += dilithium_mont_red((sword64)a[e+5] * zt[e+5]); + w[e+6] += dilithium_mont_red((sword64)a[e+6] * zt[e+6]); + w[e+7] += dilithium_mont_red((sword64)a[e+7] * zt[e+7]); } -#endif + #endif + #else + #ifdef WOLFSSL_DILITHIUM_SMALL + for (e = 0; e < DILITHIUM_N; e++) { + t64[e] += (sword64)a[e] * zt[e]; + } + #else + for (e = 0; e < DILITHIUM_N; e += 8) { + t64[e+0] += (sword64)a[e+0] * zt[e+0]; + t64[e+1] += (sword64)a[e+1] * zt[e+1]; + t64[e+2] += (sword64)a[e+2] * zt[e+2]; + t64[e+3] += (sword64)a[e+3] * zt[e+3]; + t64[e+4] += (sword64)a[e+4] * zt[e+4]; + t64[e+5] += (sword64)a[e+5] * zt[e+5]; + t64[e+6] += (sword64)a[e+6] * zt[e+6]; + t64[e+7] += (sword64)a[e+7] * zt[e+7]; + } + #endif + #endif /* Next polynomial. */ zt += DILITHIUM_N; } + #ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + for (e = 0; e < DILITHIUM_N; e++) { + w[e] = dilithium_mont_red(t64[e]); + } + #endif /* Step 10: w = NTT-1(A o NTT(z) - NTT(c) o NTT(t1)) */ dilithium_invntt(w); -#ifndef WOLFSSL_NO_ML_DSA_44 + #ifndef WOLFSSL_NO_ML_DSA_44 if (params->gamma2 == DILITHIUM_Q_LOW_88) { /* Step 11: Use hint to give full w1. */ - dilithium_use_hint_88(w, h, i, &o); + dilithium_use_hint_88(w, h, r, &o); /* Step 12: Encode w1. */ dilithium_encode_w1_88(w, encW1); encW1 += DILITHIUM_Q_HI_88_ENC_BITS * 2 * DILITHIUM_N / 16; } else -#endif -#if !defined(WOLFSSL_NO_ML_DSA_65) || !defined(WOLFSSL_NO_ML_DSA_87) + #endif + #if !defined(WOLFSSL_NO_ML_DSA_65) || !defined(WOLFSSL_NO_ML_DSA_87) if (params->gamma2 == DILITHIUM_Q_LOW_32) { /* Step 11: Use hint to give full w1. */ - dilithium_use_hint_32(w, h, params->omega, i, &o); + dilithium_use_hint_32(w, h, params->omega, r, &o); /* Step 12: Encode w1. */ dilithium_encode_w1_32(w, encW1); encW1 += DILITHIUM_Q_HI_32_ENC_BITS * 2 * DILITHIUM_N / 16; } else -#endif + #endif { } } @@ -6508,7 +7035,7 @@ static int dilithium_verify_msg(dilithium_key* key, const byte* msg, *res = valid; #ifndef WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC - XFREE(z, NULL, DYNAMIC_TYPE_DILITHIUM); + XFREE(z, key->heap, DYNAMIC_TYPE_DILITHIUM); #endif return ret; #endif /* !WOLFSSL_DILITHIUM_VERIFY_SMALL_MEM */ @@ -6524,13 +7051,13 @@ static int oqs_dilithium_make_key(dilithium_key* key, WC_RNG* rng) int ret = 0; OQS_SIG *oqssig = NULL; - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { oqssig = OQS_SIG_new(OQS_SIG_alg_ml_dsa_44_ipd); } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { oqssig = OQS_SIG_new(OQS_SIG_alg_ml_dsa_65_ipd); } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { oqssig = OQS_SIG_new(OQS_SIG_alg_ml_dsa_87_ipd); } else { @@ -6572,13 +7099,13 @@ static int oqs_dilithium_sign_msg(const byte* msg, word32 msgLen, byte* sig, } if (ret == 0) { - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { oqssig = OQS_SIG_new(OQS_SIG_alg_ml_dsa_44_ipd); } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { oqssig = OQS_SIG_new(OQS_SIG_alg_ml_dsa_65_ipd); } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { oqssig = OQS_SIG_new(OQS_SIG_alg_ml_dsa_87_ipd); } else { @@ -6592,15 +7119,18 @@ static int oqs_dilithium_sign_msg(const byte* msg, word32 msgLen, byte* sig, /* check and set up out length */ if (ret == 0) { - if ((key->level == 2) && (*sigLen < DILITHIUM_LEVEL2_SIG_SIZE)) { + if ((key->level == WC_ML_DSA_44) && + (*sigLen < DILITHIUM_LEVEL2_SIG_SIZE)) { *sigLen = DILITHIUM_LEVEL2_SIG_SIZE; ret = BUFFER_E; } - else if ((key->level == 3) && (*sigLen < DILITHIUM_LEVEL3_SIG_SIZE)) { + else if ((key->level == WC_ML_DSA_65) && + (*sigLen < DILITHIUM_LEVEL3_SIG_SIZE)) { *sigLen = DILITHIUM_LEVEL3_SIG_SIZE; ret = BUFFER_E; } - else if ((key->level == 5) && (*sigLen < DILITHIUM_LEVEL5_SIG_SIZE)) { + else if ((key->level == WC_ML_DSA_87) && + (*sigLen < DILITHIUM_LEVEL5_SIG_SIZE)) { *sigLen = DILITHIUM_LEVEL5_SIG_SIZE; ret = BUFFER_E; } @@ -6642,13 +7172,13 @@ static int oqs_dilithium_verify_msg(const byte* sig, word32 sigLen, } if (ret == 0) { - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { oqssig = OQS_SIG_new(OQS_SIG_alg_ml_dsa_44_ipd); } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { oqssig = OQS_SIG_new(OQS_SIG_alg_ml_dsa_65_ipd); } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { oqssig = OQS_SIG_new(OQS_SIG_alg_ml_dsa_87_ipd); } else { @@ -6916,7 +7446,6 @@ int wc_dilithium_init_ex(dilithium_key* key, void* heap, int devId) { int ret = 0; - (void)heap; (void)devId; /* Validate parameters. */ @@ -6936,6 +7465,7 @@ int wc_dilithium_init_ex(dilithium_key* key, void* heap, int devId) key->idLen = 0; key->labelLen = 0; #endif + key->heap = heap; } return ret; @@ -6963,7 +7493,7 @@ int wc_dilithium_init_id(dilithium_key* key, const unsigned char* id, int len, } /* Set the maximum level here */ - wc_dilithium_set_level(key, 5); + wc_dilithium_set_level(key, WC_ML_DSA_87); return ret; } @@ -6993,7 +7523,7 @@ int wc_dilithium_init_label(dilithium_key* key, const char* label, void* heap, } /* Set the maximum level here */ - wc_dilithium_set_level(key, 5); + wc_dilithium_set_level(key, WC_ML_DSA_87); return ret; } @@ -7013,7 +7543,8 @@ int wc_dilithium_set_level(dilithium_key* key, byte level) if (key == NULL) { ret = BAD_FUNC_ARG; } - if ((ret == 0) && (level != 2) && (level != 3) && (level != 5)) { + if ((ret == 0) && (level != WC_ML_DSA_44) && (level != WC_ML_DSA_65) && + (level != WC_ML_DSA_87)) { ret = BAD_FUNC_ARG; } @@ -7024,23 +7555,25 @@ int wc_dilithium_set_level(dilithium_key* key, byte level) } if (ret == 0) { /* Clear any cached items. */ +#ifndef WC_DILITHIUM_FIXED_ARRAY #ifdef WC_DILITHIUM_CACHE_MATRIX_A - XFREE(key->a, NULL, WOLFSSL_WC_DILITHIUM); + XFREE(key->a, key->heap, DYNAMIC_TYPE_DILITHIUM); key->a = NULL; key->aSet = 0; #endif #ifdef WC_DILITHIUM_CACHE_PRIV_VECTORS - XFREE(key->s1, NULL, WOLFSSL_WC_DILITHIUM); + XFREE(key->s1, key->heap, DYNAMIC_TYPE_DILITHIUM); key->s1 = NULL; key->s2 = NULL; key->t0 = NULL; key->privVecsSet = 0; #endif #ifdef WC_DILITHIUM_CACHE_PUB_VECTORS - XFREE(key->t1, NULL, WOLFSSL_WC_DILITHIUM); + XFREE(key->t1, key->heap, DYNAMIC_TYPE_DILITHIUM); key->t1 = NULL; key->pubVecSet = 0; #endif +#endif #endif /* WOLFSSL_WC_DILITHIUM */ /* Store level and indicate public and private key are not set. */ @@ -7066,8 +7599,8 @@ int wc_dilithium_get_level(dilithium_key* key, byte* level) if ((key == NULL) || (level == NULL)) { ret = BAD_FUNC_ARG; } - if ((ret == 0) && (key->level != 2) && (key->level != 3) && - (key->level != 5)) { + if ((ret == 0) && (key->level != WC_ML_DSA_44) && + (key->level != WC_ML_DSA_65) && (key->level != WC_ML_DSA_87)) { ret = BAD_FUNC_ARG; } @@ -7087,16 +7620,18 @@ void wc_dilithium_free(dilithium_key* key) { if (key != NULL) { #ifdef WOLFSSL_WC_DILITHIUM +#ifndef WC_DILITHIUM_FIXED_ARRAY /* Dispose of cached items. */ #ifdef WC_DILITHIUM_CACHE_PUB_VECTORS - XFREE(key->t1, NULL, WOLFSSL_WC_DILITHIUM); + XFREE(key->t1, key->heap, DYNAMIC_TYPE_DILITHIUM); #endif #ifdef WC_DILITHIUM_CACHE_PRIV_VECTORS - XFREE(key->s1, NULL, WOLFSSL_WC_DILITHIUM); + XFREE(key->s1, key->heap, DYNAMIC_TYPE_DILITHIUM); #endif #ifdef WC_DILITHIUM_CACHE_MATRIX_A - XFREE(key->a, NULL, WOLFSSL_WC_DILITHIUM); + XFREE(key->a, key->heap, DYNAMIC_TYPE_DILITHIUM); #endif +#endif /* Free the SHAKE-128/256 object. */ wc_Shake256_Free(&key->shake); #endif @@ -7117,13 +7652,13 @@ int wc_dilithium_size(dilithium_key* key) int ret = BAD_FUNC_ARG; if (key != NULL) { - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { ret = DILITHIUM_LEVEL2_KEY_SIZE; } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { ret = DILITHIUM_LEVEL3_KEY_SIZE; } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { ret = DILITHIUM_LEVEL5_KEY_SIZE; } } @@ -7143,13 +7678,13 @@ int wc_dilithium_priv_size(dilithium_key* key) int ret = BAD_FUNC_ARG; if (key != NULL) { - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { ret = DILITHIUM_LEVEL2_PRV_KEY_SIZE; } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { ret = DILITHIUM_LEVEL3_PRV_KEY_SIZE; } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { ret = DILITHIUM_LEVEL5_PRV_KEY_SIZE; } } @@ -7190,13 +7725,13 @@ int wc_dilithium_pub_size(dilithium_key* key) int ret = BAD_FUNC_ARG; if (key != NULL) { - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { ret = DILITHIUM_LEVEL2_PUB_KEY_SIZE; } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { ret = DILITHIUM_LEVEL3_PUB_KEY_SIZE; } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { ret = DILITHIUM_LEVEL5_PUB_KEY_SIZE; } } @@ -7236,13 +7771,13 @@ int wc_dilithium_sig_size(dilithium_key* key) int ret = BAD_FUNC_ARG; if (key != NULL) { - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { ret = DILITHIUM_LEVEL2_SIG_SIZE; } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { ret = DILITHIUM_LEVEL3_SIG_SIZE; } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { ret = DILITHIUM_LEVEL5_SIG_SIZE; } } @@ -7320,7 +7855,7 @@ int wc_dilithium_check_key(dilithium_key* key) #endif /* Allocate memory for large intermediates. */ - s1 = (sword32*)XMALLOC(allocSz, NULL, DYNAMIC_TYPE_DILITHIUM); + s1 = (sword32*)XMALLOC(allocSz, key->heap, DYNAMIC_TYPE_DILITHIUM); if (s1 == NULL) { ret = MEMORY_E; } @@ -7346,7 +7881,7 @@ int wc_dilithium_check_key(dilithium_key* key) const byte* pub_seed = key->p; ret = dilithium_expand_a(&key->shake, pub_seed, params->k, - params->l, a); + params->l, a, key->heap); #ifdef WC_DILITHIUM_CACHE_MATRIX_A key->aSet = (ret == 0); #endif @@ -7400,7 +7935,9 @@ int wc_dilithium_check_key(dilithium_key* key) } /* Dispose of allocated memory. */ - XFREE(s1, NULL, DYNAMIC_TYPE_DILITHIUM); + if (s1 != NULL) { + XFREE(s1, key->heap, DYNAMIC_TYPE_DILITHIUM); + } #else /* Validate parameter. */ if (key == NULL) { @@ -7455,7 +7992,7 @@ int wc_dilithium_export_public(dilithium_key* key, byte* out, word32* outLen) if (ret == 0) { /* Get length passed in for checking. */ inLen = *outLen; - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { /* Set out length. */ *outLen = DILITHIUM_LEVEL2_PUB_KEY_SIZE; /* Validate length passed in. */ @@ -7463,7 +8000,7 @@ int wc_dilithium_export_public(dilithium_key* key, byte* out, word32* outLen) ret = BUFFER_E; } } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { /* Set out length. */ *outLen = DILITHIUM_LEVEL3_PUB_KEY_SIZE; /* Validate length passed in. */ @@ -7471,7 +8008,7 @@ int wc_dilithium_export_public(dilithium_key* key, byte* out, word32* outLen) ret = BUFFER_E; } } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { /* Set out length. */ *outLen = DILITHIUM_LEVEL5_PUB_KEY_SIZE; /* Validate length passed in. */ @@ -7517,19 +8054,19 @@ int wc_dilithium_import_public(const byte* in, word32 inLen, dilithium_key* key) ret = BAD_FUNC_ARG; } if (ret == 0) { - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { /* Check length. */ if (inLen != DILITHIUM_LEVEL2_PUB_KEY_SIZE) { ret = BAD_FUNC_ARG; } } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { /* Check length. */ if (inLen != DILITHIUM_LEVEL3_PUB_KEY_SIZE) { ret = BAD_FUNC_ARG; } } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { /* Check length. */ if (inLen != DILITHIUM_LEVEL5_PUB_KEY_SIZE) { ret = BAD_FUNC_ARG; @@ -7549,40 +8086,44 @@ int wc_dilithium_import_public(const byte* in, word32 inLen, dilithium_key* key) key->p = in; #endif - #ifdef WC_DILITHIUM_CACHE_PUB_VECTORS +#ifdef WC_DILITHIUM_CACHE_PUB_VECTORS + #ifndef WC_DILITHIUM_FIXED_ARRAY /* Allocate t1 if required. */ if (key->t1 == NULL) { - key->t1 = (sword32*)XMALLOC(key->params->s2Sz, NULL, + key->t1 = (sword32*)XMALLOC(key->params->s2Sz, key->heap, DYNAMIC_TYPE_DILITHIUM); if (key->t1 == NULL) { ret = MEMORY_E; } } + #endif } if (ret == 0) { /* Compute t1 from public key data. */ dilithium_make_pub_vec(key, key->t1); - #endif - #ifdef WC_DILITHIUM_CACHE_MATRIX_A +#endif +#ifdef WC_DILITHIUM_CACHE_MATRIX_A + #ifndef WC_DILITHIUM_FIXED_ARRAY /* Allocate matrix a if required. */ if (key->a == NULL) { - key->a = (sword32*)XMALLOC(key->params->aSz, NULL, + key->a = (sword32*)XMALLOC(key->params->aSz, key->heap, DYNAMIC_TYPE_DILITHIUM); if (key->a == NULL) { ret = MEMORY_E; } } + #endif } if (ret == 0) { /* Compute matrix a from public key data. */ ret = dilithium_expand_a(&key->shake, key->p, key->params->k, - key->params->l, key->a); + key->params->l, key->a, key->heap); if (ret == 0) { key->aSet = 1; } } if (ret == 0) { - #endif +#endif /* Public key is set. */ key->pubKeySet = 1; } @@ -7630,39 +8171,44 @@ static int dilithium_set_priv_key(const byte* priv, word32 privSz, /* Allocate and create cached values. */ #ifdef WC_DILITHIUM_CACHE_MATRIX_A +#ifndef WC_DILITHIUM_FIXED_ARRAY if (ret == 0) { /* Allocate matrix a if required. */ if (key->a == NULL) { - key->a = (sword32*)XMALLOC(params->aSz, NULL, + key->a = (sword32*)XMALLOC(params->aSz, key->heap, DYNAMIC_TYPE_DILITHIUM); if (key->a == NULL) { ret = MEMORY_E; } } } +#endif if (ret == 0) { /* Compute matrix a from private key data. */ ret = dilithium_expand_a(&key->shake, key->k, params->k, params->l, - key->a); + key->a, key->heap); if (ret == 0) { key->aSet = 1; } } #endif #ifdef WC_DILITHIUM_CACHE_PRIV_VECTORS +#ifndef WC_DILITHIUM_FIXED_ARRAY if ((ret == 0) && (key->s1 == NULL)) { /* Allocate L vector s1, K vector s2 and K vector t0 if required. */ key->s1 = (sword32*)XMALLOC(params->s1Sz + params->s2Sz + params->s2Sz, - NULL, DYNAMIC_TYPE_DILITHIUM); - if (key->s1 == NULL) { + key->heap, DYNAMIC_TYPE_DILITHIUM); + if (key->s1 == NULL) { ret = MEMORY_E; } + if (ret == 0) { + /* Set pointers into allocated memory. */ + key->s2 = key->s1 + params->s1Sz / sizeof(*key->s1); + key->t0 = key->s2 + params->s2Sz / sizeof(*key->s2); + } } +#endif if (ret == 0) { - /* Set pointers into allocated memory. */ - key->s2 = key->s1 + params->s1Sz / sizeof(*key->s1); - key->t0 = key->s2 + params->s2Sz / sizeof(*key->s2); - /* Compute vectors from private key. */ dilithium_make_priv_vecs(key, key->s1, key->s2, key->t0); } @@ -7693,8 +8239,8 @@ int wc_dilithium_import_private(const byte* priv, word32 privSz, if ((priv == NULL) || (key == NULL)) { ret = BAD_FUNC_ARG; } - if ((ret == 0) && (key->level != 2) && (key->level != 3) && - (key->level != 5)) { + if ((ret == 0) && (key->level != WC_ML_DSA_44) && + (key->level != WC_ML_DSA_65) && (key->level != WC_ML_DSA_87)) { ret = BAD_FUNC_ARG; } @@ -7730,8 +8276,8 @@ int wc_dilithium_import_key(const byte* priv, word32 privSz, if ((pub == NULL) && (pubSz != 0)) { ret = BAD_FUNC_ARG; } - if ((ret == 0) && (key->level != 2) && (key->level != 3) && - (key->level != 5)) { + if ((ret == 0) && (key->level != WC_ML_DSA_44) && + (key->level != WC_ML_DSA_65) && (key->level != WC_ML_DSA_87)) { ret = BAD_FUNC_ARG; } @@ -7776,13 +8322,13 @@ int wc_dilithium_export_private(dilithium_key* key, byte* out, if (ret == 0) { inLen = *outLen; /* check and set up out length */ - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { *outLen = DILITHIUM_LEVEL2_KEY_SIZE; } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { *outLen = DILITHIUM_LEVEL3_KEY_SIZE; } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { *outLen = DILITHIUM_LEVEL5_KEY_SIZE; } else { @@ -7869,13 +8415,13 @@ int wc_Dilithium_PrivateKeyDecode(const byte* input, word32* inOutIdx, if (ret == 0) { /* Get OID sum for level. */ - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { keytype = DILITHIUM_LEVEL2k; } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { keytype = DILITHIUM_LEVEL3k; } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { keytype = DILITHIUM_LEVEL5k; } else { @@ -7891,19 +8437,19 @@ int wc_Dilithium_PrivateKeyDecode(const byte* input, word32* inOutIdx, } if ((ret == 0) && (pubKey == NULL) && (pubKeyLen == 0)) { /* Check if the public key is included in the private key. */ - if ((key->level == 2) && + if ((key->level == WC_ML_DSA_44) && (privKeyLen == DILITHIUM_LEVEL2_PRV_KEY_SIZE)) { pubKey = privKey + DILITHIUM_LEVEL2_KEY_SIZE; pubKeyLen = DILITHIUM_LEVEL2_PUB_KEY_SIZE; privKeyLen -= DILITHIUM_LEVEL2_PUB_KEY_SIZE; } - else if ((key->level == 3) && + else if ((key->level == WC_ML_DSA_65) && (privKeyLen == DILITHIUM_LEVEL3_PRV_KEY_SIZE)) { pubKey = privKey + DILITHIUM_LEVEL3_KEY_SIZE; pubKeyLen = DILITHIUM_LEVEL3_PUB_KEY_SIZE; privKeyLen -= DILITHIUM_LEVEL3_PUB_KEY_SIZE; } - else if ((key->level == 5) && + else if ((key->level == WC_ML_DSA_87) && (privKeyLen == DILITHIUM_LEVEL5_PRV_KEY_SIZE)) { pubKey = privKey + DILITHIUM_LEVEL5_KEY_SIZE; pubKeyLen = DILITHIUM_LEVEL5_PUB_KEY_SIZE; @@ -7937,8 +8483,103 @@ int wc_Dilithium_PrivateKeyDecode(const byte* input, word32* inOutIdx, #endif /* WOLFSSL_DILITHIUM_PRIVATE_KEY */ +#endif /* WOLFSSL_DILITHIUM_NO_ASN1 */ + #ifdef WOLFSSL_DILITHIUM_PUBLIC_KEY +#if defined(WOLFSSL_DILITHIUM_NO_ASN1) +#ifndef WOLFSSL_NO_ML_DSA_44 +static unsigned char dilithium_oid_44[] = { + 0x2b, 0x06, 0x01, 0x04, 0x01, 0x02, 0x82, 0x0b, + 0x0c, 0x04, 0x04 +}; +#endif +#ifndef WOLFSSL_NO_ML_DSA_65 +static unsigned char dilithium_oid_65[] = { + 0x2b, 0x06, 0x01, 0x04, 0x01, 0x02, 0x82, 0x0b, + 0x0c, 0x06, 0x05 +}; +#endif +#ifndef WOLFSSL_NO_ML_DSA_87 +static unsigned char dilithium_oid_87[] = { + 0x2b, 0x06, 0x01, 0x04, 0x01, 0x02, 0x82, 0x0b, + 0x0c, 0x08, 0x07 +}; +#endif + +static int dilitihium_get_der_length(const byte* input, word32* inOutIdx, + int *length, word32 inSz) +{ + int ret = 0; + word32 idx = *inOutIdx; + word32 len = 0; + + if (idx >= inSz) { + ret = ASN_PARSE_E; + } + else if (input[idx] < 0x80) { + len = input[idx]; + idx++; + } + else if ((input[idx] == 0x80) || (input[idx] >= 0x83)) { + ret = ASN_PARSE_E; + } + else if (input[idx] == 0x81) { + if (idx + 1 >= inSz) { + ret = ASN_PARSE_E; + } + else if (input[idx + 1] < 0x80) { + ret = ASN_PARSE_E; + } + else { + len = input[idx + 1]; + idx += 2; + } + } + else if (input[idx] == 0x82) { + if (idx + 2 >= inSz) { + ret = ASN_PARSE_E; + } + else { + len = ((word16)input[idx + 1] << 8) + input[idx + 2]; + idx += 3; + if (len < 0x100) { + ret = ASN_PARSE_E; + } + } + } + + if ((ret == 0) && ((idx + len) > inSz)) { + ret = ASN_PARSE_E; + } + + *length = (int)len; + *inOutIdx = idx; + return ret; +} + +static int dilithium_check_type(const byte* input, word32* inOutIdx, byte type, + word32 inSz) +{ + int ret = 0; + word32 idx = *inOutIdx; + + if (idx >= inSz) { + ret = ASN_PARSE_E; + } + else if (input[idx] != type){ + ret = ASN_PARSE_E; + } + else { + idx++; + } + + *inOutIdx = idx; + return ret; +} + +#endif /* WOLFSSL_DILITHIUM_NO_ASN1 */ + /* Decode the DER encoded Dilithium public key. * * @param [in] input Array holding DER encoded data. @@ -7957,7 +8598,6 @@ int wc_Dilithium_PublicKeyDecode(const byte* input, word32* inOutIdx, int ret = 0; const byte* pubKey; word32 pubKeyLen = 0; - int keytype = 0; /* Validate parameters. */ if ((input == NULL) || (inOutIdx == NULL) || (key == NULL) || (inSz == 0)) { @@ -7968,17 +8608,27 @@ int wc_Dilithium_PublicKeyDecode(const byte* input, word32* inOutIdx, /* Try to import the key directly. */ ret = wc_dilithium_import_public(input, inSz, key); if (ret != 0) { + #if !defined(WOLFSSL_DILITHIUM_NO_ASN1) + int keytype = 0; + #else + int length; + unsigned char* oid; + int oidLen; + word32 idx = 0; + #endif + /* Start again. */ ret = 0; + #if !defined(WOLFSSL_DILITHIUM_NO_ASN1) /* Get OID sum for level. */ - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { keytype = DILITHIUM_LEVEL2k; } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { keytype = DILITHIUM_LEVEL3k; } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { keytype = DILITHIUM_LEVEL5k; } else { @@ -7990,6 +8640,77 @@ int wc_Dilithium_PublicKeyDecode(const byte* input, word32* inOutIdx, ret = DecodeAsymKeyPublic_Assign(input, inOutIdx, inSz, &pubKey, &pubKeyLen, keytype); } + #else + /* Get OID sum for level. */ + #ifndef WOLFSSL_NO_ML_DSA_44 + if (key->level == WC_ML_DSA_44) { + oid = dilithium_oid_44; + oidLen = (int)sizeof(dilithium_oid_44); + } + else + #endif + #ifndef WOLFSSL_NO_ML_DSA_65 + if (key->level == WC_ML_DSA_65) { + oid = dilithium_oid_65; + oidLen = (int)sizeof(dilithium_oid_65); + } + else + #endif + #ifndef WOLFSSL_NO_ML_DSA_87 + if (key->level == WC_ML_DSA_87) { + oid = dilithium_oid_87; + oidLen = (int)sizeof(dilithium_oid_87); + } + else + #endif + { + /* Level not set. */ + ret = BAD_FUNC_ARG; + } + if (ret == 0) { + ret = dilithium_check_type(input, &idx, 0x30, inSz); + } + if (ret == 0) { + ret = dilitihium_get_der_length(input, &idx, &length, inSz); + } + if (ret == 0) { + ret = dilithium_check_type(input, &idx, 0x30, inSz); + } + if (ret == 0) { + ret = dilitihium_get_der_length(input, &idx, &length, inSz); + } + if (ret == 0) { + ret = dilithium_check_type(input, &idx, 0x06, inSz); + } + if (ret == 0) { + ret = dilitihium_get_der_length(input, &idx, &length, inSz); + } + if (ret == 0) { + if ((length != oidLen) || + (XMEMCMP(input + idx, oid, oidLen) != 0)) { + ret = ASN_PARSE_E; + } + idx += oidLen; + } + if (ret == 0) { + ret = dilithium_check_type(input, &idx, 0x03, inSz); + } + if (ret == 0) { + ret = dilitihium_get_der_length(input, &idx, &length, inSz); + } + if (ret == 0) { + if (input[idx] != 0) { + ret = ASN_PARSE_E; + } + idx++; + length--; + } + if (ret == 0) { + /* This is the raw point data compressed or uncompressed. */ + pubKeyLen = (word32)length; + pubKey = input + idx; + } + #endif if (ret == 0) { /* Import public key data. */ ret = wc_dilithium_import_public(pubKey, pubKeyLen, key); @@ -7999,6 +8720,8 @@ int wc_Dilithium_PublicKeyDecode(const byte* input, word32* inOutIdx, return ret; } +#ifndef WOLFSSL_DILITHIUM_NO_ASN1 + #ifdef WC_ENABLE_ASYM_KEY_EXPORT /* Encode the public part of a Dilithium key in DER. * @@ -8030,15 +8753,15 @@ int wc_Dilithium_PublicKeyToDer(dilithium_key* key, byte* output, word32 len, if (ret == 0) { /* Get OID and length for level. */ - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { keytype = DILITHIUM_LEVEL2k; pubKeyLen = DILITHIUM_LEVEL2_PUB_KEY_SIZE; } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { keytype = DILITHIUM_LEVEL3k; pubKeyLen = DILITHIUM_LEVEL3_PUB_KEY_SIZE; } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { keytype = DILITHIUM_LEVEL5k; pubKeyLen = DILITHIUM_LEVEL5_PUB_KEY_SIZE; } @@ -8057,10 +8780,14 @@ int wc_Dilithium_PublicKeyToDer(dilithium_key* key, byte* output, word32 len, } #endif /* WC_ENABLE_ASYM_KEY_EXPORT */ +#endif /* !WOLFSSL_DILITHIUM_NO_ASN1 */ + #endif /* WOLFSSL_DILITHIUM_PUBLIC_KEY */ #ifdef WOLFSSL_DILITHIUM_PRIVATE_KEY +#ifndef WOLFSSL_DILITHIUM_NO_ASN1 + #ifdef WOLFSSL_DILITHIUM_PUBLIC_KEY /* Encode the private and public data of a Dilithium key in DER. * @@ -8080,15 +8807,15 @@ int wc_Dilithium_KeyToDer(dilithium_key* key, byte* output, word32 len) /* Validate parameters and check public and private key set. */ if ((key != NULL) && key->prvKeySet && key->pubKeySet) { /* Create DER for level. */ - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { ret = SetAsymKeyDer(key->k, DILITHIUM_LEVEL2_KEY_SIZE, key->p, DILITHIUM_LEVEL2_PUB_KEY_SIZE, output, len, DILITHIUM_LEVEL2k); } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { ret = SetAsymKeyDer(key->k, DILITHIUM_LEVEL3_KEY_SIZE, key->p, DILITHIUM_LEVEL3_PUB_KEY_SIZE, output, len, DILITHIUM_LEVEL3k); } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { ret = SetAsymKeyDer(key->k, DILITHIUM_LEVEL5_KEY_SIZE, key->p, DILITHIUM_LEVEL5_PUB_KEY_SIZE, output, len, DILITHIUM_LEVEL5k); } @@ -8116,15 +8843,15 @@ int wc_Dilithium_PrivateKeyToDer(dilithium_key* key, byte* output, word32 len) /* Validate parameters and check private key set. */ if ((key != NULL) && key->prvKeySet) { /* Create DER for level. */ - if (key->level == 2) { + if (key->level == WC_ML_DSA_44) { ret = SetAsymKeyDer(key->k, DILITHIUM_LEVEL2_KEY_SIZE, NULL, 0, output, len, DILITHIUM_LEVEL2k); } - else if (key->level == 3) { + else if (key->level == WC_ML_DSA_65) { ret = SetAsymKeyDer(key->k, DILITHIUM_LEVEL3_KEY_SIZE, NULL, 0, output, len, DILITHIUM_LEVEL3k); } - else if (key->level == 5) { + else if (key->level == WC_ML_DSA_87) { ret = SetAsymKeyDer(key->k, DILITHIUM_LEVEL5_KEY_SIZE, NULL, 0, output, len, DILITHIUM_LEVEL5k); } @@ -8133,8 +8860,8 @@ int wc_Dilithium_PrivateKeyToDer(dilithium_key* key, byte* output, word32 len) return ret; } -#endif /* WOLFSSL_DILITHIUM_PRIVATE_KEY */ - #endif /* WOLFSSL_DILITHIUM_NO_ASN1 */ +#endif /* WOLFSSL_DILITHIUM_PRIVATE_KEY */ + #endif /* HAVE_DILITHIUM */ diff --git a/wolfcrypt/src/dsa.c b/wolfcrypt/src/dsa.c index c1606b3d1d..520c100408 100644 --- a/wolfcrypt/src/dsa.c +++ b/wolfcrypt/src/dsa.c @@ -1,6 +1,6 @@ /* dsa.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index ee1e7b7dbb..1d5e8135c4 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -1,6 +1,6 @@ /* ecc.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -6395,9 +6395,6 @@ static int wc_ecc_get_curve_order_bit_count(const ecc_set_type* dp) #ifdef HAVE_ECC_SIGN -#ifndef NO_ASN - - #if defined(WOLFSSL_ATECC508A) || defined(WOLFSSL_ATECC608A) || \ defined(PLUTON_CRYPTO_ECC) || defined(WOLFSSL_CRYPTOCELL) || \ defined(WOLFSSL_SILABS_SE_ACCEL) || defined(WOLFSSL_KCAPI_ECC) || \ @@ -6722,6 +6719,9 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen, DECL_MP_INT_SIZE_DYN(r, ECC_KEY_MAX_BITS(key), MAX_ECC_BITS_USE); DECL_MP_INT_SIZE_DYN(s, ECC_KEY_MAX_BITS(key), MAX_ECC_BITS_USE); #endif +#ifdef NO_ASN + word32 keySz; +#endif if (in == NULL || out == NULL || outlen == NULL || key == NULL) { return ECC_BAD_ARG_E; @@ -6758,17 +6758,17 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen, #else NEW_MP_INT_SIZE(r, ECC_KEY_MAX_BITS_NONULLCHECK(key), key->heap, DYNAMIC_TYPE_ECC); -#ifdef MP_INT_SIZE_CHECK_NULL + #ifdef MP_INT_SIZE_CHECK_NULL if (r == NULL) return MEMORY_E; -#endif + #endif NEW_MP_INT_SIZE(s, ECC_KEY_MAX_BITS_NONULLCHECK(key), key->heap, DYNAMIC_TYPE_ECC); -#ifdef MP_INT_SIZE_CHECK_NULL + #ifdef MP_INT_SIZE_CHECK_NULL if (s == NULL) { FREE_MP_INT_SIZE(r, key->heap, DYNAMIC_TYPE_ECC); return MEMORY_E; } -#endif + #endif err = INIT_MP_INT_SIZE(r, ECC_KEY_MAX_BITS_NONULLCHECK(key)); if (err != 0) { @@ -6800,8 +6800,26 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen, return err; } +#ifndef NO_ASN /* encoded with DSA header */ err = StoreECC_DSA_Sig(out, outlen, r, s); +#else + /* No support for DSA ASN.1 header. + * Signature will be r+s directly. */ + keySz = 0; + if (key->dp != NULL) { + keySz = (word32)key->dp->size; + } + if (keySz <= 0) { + WOLFSSL_MSG("Error: ECDSA sign raw signature size"); + return WC_NO_ERR_TRACE(ECC_BAD_ARG_E); + } + *outlen = keySz * 2; + + /* Export signature into r,s */ + mp_to_unsigned_bin_len(r, out, keySz); + mp_to_unsigned_bin_len(s, out + keySz, keySz); +#endif /* !NO_ASN */ /* cleanup */ mp_clear(r); @@ -6813,7 +6831,6 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen, return err; #endif /* !WOLF_CRYPTO_CB_ONLY_ECC */ } -#endif /* !NO_ASN */ #if defined(WOLFSSL_ECDSA_DETERMINISTIC_K) || \ defined(WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT) @@ -6837,13 +6854,17 @@ static int deterministic_sign_helper(const byte* in, word32 inlen, ecc_key* key) if (key->sign_k == NULL) { key->sign_k = (mp_int*)XMALLOC(sizeof(mp_int), key->heap, DYNAMIC_TYPE_ECC); + if (key->sign_k != NULL) { + err = mp_init(key->sign_k); + if (err != MP_OKAY) { + XFREE(key->sign_k, key->heap, DYNAMIC_TYPE_ECC); + key->sign_k = NULL; + } + } } - if (key->sign_k != NULL) { - /* currently limiting to SHA256 for auto create */ - if (mp_init(key->sign_k) != MP_OKAY || - wc_ecc_gen_deterministic_k(in, inlen, - WC_HASH_TYPE_SHA256, ecc_get_k(key), key->sign_k, + if (wc_ecc_gen_deterministic_k(in, inlen, + key->hashType, ecc_get_k(key), key->sign_k, curve->order, key->heap) != 0) { mp_free(key->sign_k); XFREE(key->sign_k, key->heap, DYNAMIC_TYPE_ECC); @@ -6861,8 +6882,7 @@ static int deterministic_sign_helper(const byte* in, word32 inlen, ecc_key* key) } #else key->sign_k_set = 0; - /* currently limiting to SHA256 for auto create */ - if (wc_ecc_gen_deterministic_k(in, inlen, WC_HASH_TYPE_SHA256, + if (wc_ecc_gen_deterministic_k(in, inlen, key->hashType, ecc_get_k(key), key->sign_k, curve->order, key->heap) != 0) { err = ECC_PRIV_KEY_E; } @@ -7479,7 +7499,7 @@ static int _HMAC_K(byte* K, word32 KSz, byte* V, word32 VSz, Hmac hmac; int ret, init; - ret = init = wc_HmacInit(&hmac, heap, 0); + ret = init = wc_HmacInit(&hmac, heap, INVALID_DEVID); if (ret == 0) ret = wc_HmacSetKey(&hmac, hashType, K, KSz); @@ -7519,7 +7539,7 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz, enum wc_HashType hashType, mp_int* priv, mp_int* k, mp_int* order, void* heap) { - int ret = 0, qbits = 0; + int ret = 0; #ifndef WOLFSSL_SMALL_STACK byte h1[MAX_ECC_BYTES]; byte V[WC_MAX_DIGEST_SIZE]; @@ -7535,6 +7555,7 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz, #endif word32 xSz, VSz, KSz, h1len, qLen; byte intOct; + int qbits = 0; if (hash == NULL || k == NULL || order == NULL) { return BAD_FUNC_ARG; @@ -7545,9 +7566,20 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz, return BAD_FUNC_ARG; } - if (hashSz != WC_SHA256_DIGEST_SIZE) { - WOLFSSL_MSG("Currently only SHA256 digest is supported"); - return BAD_FUNC_ARG; + /* if none is provided then detect has type based on hash size */ + if (hashType == WC_HASH_TYPE_NONE) { + if (hashSz == 64) { + hashType = WC_HASH_TYPE_SHA512; + } + else if (hashSz == 48) { + hashType = WC_HASH_TYPE_SHA384; + } + else if (hashSz == 32) { + hashType = WC_HASH_TYPE_SHA256; + } + else { + return BAD_FUNC_ARG; + } } if (mp_unsigned_bin_size(priv) > MAX_ECC_BYTES) { @@ -7615,6 +7647,16 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz, wc_MemZero_Add("wc_ecc_gen_deterministic_k x", x, qLen); #endif qbits = mp_count_bits(order); + if (qbits < 0) + ret = MP_VAL; + } + + if (ret == 0) { + /* hash truncate if too long */ + if (((WOLFSSL_BIT_SIZE) * hashSz) > (word32)qbits) { + /* calculate truncated hash size using bits rounded up byte */ + hashSz = ((word32)qbits + (WOLFSSL_BIT_SIZE - 1)) / WOLFSSL_BIT_SIZE; + } ret = mp_read_unsigned_bin(z1, hash, hashSz); } @@ -7636,7 +7678,7 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz, ret = BUFFER_E; } else { - ret = mp_to_unsigned_bin_len(z1, h1, h1len); + ret = mp_to_unsigned_bin_len(z1, h1, (int)h1len); } } else @@ -7705,7 +7747,7 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz, ret = mp_read_unsigned_bin(k, x, xSz); } - if ((ret == 0) && ((int)(xSz * WOLFSSL_BIT_SIZE) != qbits)) { + if ((ret == 0) && ((xSz * WOLFSSL_BIT_SIZE) != (word32)qbits)) { /* handle odd case where shift of 'k' is needed with RFC 6979 * k = bits2int(T) in section 3.2 h.3 */ mp_rshb(k, ((int)xSz * WOLFSSL_BIT_SIZE) - qbits); @@ -7758,15 +7800,23 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz, /* Sets the deterministic flag for 'k' generation with sign. * returns 0 on success */ -int wc_ecc_set_deterministic(ecc_key* key, byte flag) +int wc_ecc_set_deterministic_ex(ecc_key* key, byte flag, + enum wc_HashType hashType) { if (key == NULL) { return BAD_FUNC_ARG; } key->deterministic = flag ? 1 : 0; + key->hashType = hashType; return 0; } + +int wc_ecc_set_deterministic(ecc_key* key, byte flag) +{ + return wc_ecc_set_deterministic_ex(key, flag, WC_HASH_TYPE_NONE); +} + #endif /* end sign_ex and deterministic sign */ @@ -7859,7 +7909,9 @@ int wc_ecc_free(ecc_key* key) return 0; } -#if defined(WOLFSSL_ECDSA_SET_K) || defined(WOLFSSL_ECDSA_SET_K_ONE_LOOP) +#if defined(WOLFSSL_ECDSA_SET_K) || defined(WOLFSSL_ECDSA_SET_K_ONE_LOOP) || \ + defined(WOLFSSL_ECDSA_DETERMINISTIC_K) || \ + defined(WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT) #ifndef WOLFSSL_NO_MALLOC if (key->sign_k != NULL) #endif @@ -8423,7 +8475,6 @@ int ecc_mul2add(ecc_point* A, mp_int* kA, #ifdef HAVE_ECC_VERIFY -#ifndef NO_ASN /* verify * * w = s^-1 mod n @@ -8461,6 +8512,9 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash, #ifdef WOLFSSL_ASYNC_CRYPT int isPrivateKeyOnly = 0; #endif +#ifdef NO_ASN + word32 keySz; +#endif if (sig == NULL || hash == NULL || res == NULL || key == NULL) { return ECC_BAD_ARG_E; @@ -8493,18 +8547,20 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash, r = key->r; s = key->s; #else - NEW_MP_INT_SIZE(r, ECC_KEY_MAX_BITS_NONULLCHECK(key), key->heap, DYNAMIC_TYPE_ECC); -#ifdef MP_INT_SIZE_CHECK_NULL + NEW_MP_INT_SIZE(r, ECC_KEY_MAX_BITS_NONULLCHECK(key), key->heap, + DYNAMIC_TYPE_ECC); + #ifdef MP_INT_SIZE_CHECK_NULL if (r == NULL) return MEMORY_E; -#endif - NEW_MP_INT_SIZE(s, ECC_KEY_MAX_BITS_NONULLCHECK(key), key->heap, DYNAMIC_TYPE_ECC); -#ifdef MP_INT_SIZE_CHECK_NULL + #endif + NEW_MP_INT_SIZE(s, ECC_KEY_MAX_BITS_NONULLCHECK(key), key->heap, + DYNAMIC_TYPE_ECC); + #ifdef MP_INT_SIZE_CHECK_NULL if (s == NULL) { FREE_MP_INT_SIZE(r, key->heap, DYNAMIC_TYPE_ECC); return MEMORY_E; } -#endif + #endif err = INIT_MP_INT_SIZE(r, ECC_KEY_MAX_BITS_NONULLCHECK(key)); if (err != 0) { FREE_MP_INT_SIZE(s, key->heap, DYNAMIC_TYPE_ECC); @@ -8527,6 +8583,7 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash, /* default to invalid signature */ *res = 0; + #ifndef NO_ASN /* Decode ASN.1 ECDSA signature. */ #if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC) /* Note, DecodeECC_DSA_Sig() calls mp_init() on r and s. @@ -8541,6 +8598,24 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash, if (err < 0) { break; } + #else + /* No support for DSA ASN.1 header. + * Signature must be r+s directly. */ + keySz = 0; + if (key->dp != NULL) { + keySz = (word32)key->dp->size; + } + if (siglen != keySz * 2) { + WOLFSSL_MSG("Error: ECDSA Verify raw signature size"); + return WC_NO_ERR_TRACE(ECC_BAD_ARG_E); + } + + /* Import signature into r,s */ + mp_init(r); + mp_init(s); + mp_read_unsigned_bin(r, sig, keySz); + mp_read_unsigned_bin(s, sig + keySz, keySz); + #endif /* !NO_ASN */ FALL_THROUGH; case ECC_STATE_VERIFY_DO: @@ -8600,7 +8675,6 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash, return err; #endif /* !WOLF_CRYPTO_CB_ONLY_ECC */ } -#endif /* !NO_ASN */ #ifndef WOLF_CRYPTO_CB_ONLY_ECC @@ -9089,7 +9163,7 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash, keySz = (word32)key->dp->size; #if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC) && \ - defined(WOLFSSL_ASYNC_CRYPT_SW) + defined(WOLFSSL_ASYNC_CRYPT_SW) if (key->asyncDev.marker == WOLFSSL_ASYNC_MARKER_ECC) { if (wc_AsyncSwInit(&key->asyncDev, ASYNC_SW_ECC_VERIFY)) { WC_ASYNC_SW* sw = &key->asyncDev.sw; @@ -15363,9 +15437,8 @@ int wc_ecc_get_oid(word32 oidSum, const byte** oid, word32* oidSz) /* find matching OID sum (based on encoded value) */ for (x = 0; ecc_sets[x].size != 0; x++) { if (ecc_sets[x].oidSum == oidSum) { - int ret; #ifdef HAVE_OID_ENCODING - ret = 0; + int ret = 0; /* check cache */ oid_cache_t* o = &ecc_oid_cache[x]; if (o->oidSz == 0) { @@ -15383,6 +15456,7 @@ int wc_ecc_get_oid(word32 oidSum, const byte** oid, word32* oidSz) if (ret == 0) { ret = ecc_sets[x].id; } + return ret; #else if (oidSz) { *oidSz = ecc_sets[x].oidSz; @@ -15390,9 +15464,8 @@ int wc_ecc_get_oid(word32 oidSum, const byte** oid, word32* oidSz) if (oid) { *oid = ecc_sets[x].oid; } - ret = ecc_sets[x].id; + return ecc_sets[x].id; #endif - return ret; } } diff --git a/wolfcrypt/src/eccsi.c b/wolfcrypt/src/eccsi.c index 69d999b355..157c5ba7a9 100644 --- a/wolfcrypt/src/eccsi.c +++ b/wolfcrypt/src/eccsi.c @@ -1,6 +1,6 @@ /* eccsi.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/ed25519.c b/wolfcrypt/src/ed25519.c index 381b911596..86f594dd79 100644 --- a/wolfcrypt/src/ed25519.c +++ b/wolfcrypt/src/ed25519.c @@ -1,6 +1,6 @@ /* ed25519.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/ed448.c b/wolfcrypt/src/ed448.c index e9e865ce67..1598c9c98d 100644 --- a/wolfcrypt/src/ed448.c +++ b/wolfcrypt/src/ed448.c @@ -1,6 +1,6 @@ /* ed448.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/error.c b/wolfcrypt/src/error.c index 2e25b60f7d..3a1ae2151d 100644 --- a/wolfcrypt/src/error.c +++ b/wolfcrypt/src/error.c @@ -1,6 +1,6 @@ /* error.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/evp.c b/wolfcrypt/src/evp.c index 42949fc432..b53d6eca97 100644 --- a/wolfcrypt/src/evp.c +++ b/wolfcrypt/src/evp.c @@ -1,6 +1,6 @@ /* evp.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/ext_kyber.c b/wolfcrypt/src/ext_kyber.c index 77ab430de9..4f1a754df7 100644 --- a/wolfcrypt/src/ext_kyber.c +++ b/wolfcrypt/src/ext_kyber.c @@ -1,6 +1,6 @@ /* ext_kyber.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -27,7 +27,7 @@ #include #include -#ifdef WOLFSSL_HAVE_KYBER +#if defined(WOLFSSL_HAVE_KYBER) && !defined(WOLFSSL_WC_KYBER) #include #ifdef NO_INLINE @@ -750,4 +750,4 @@ int wc_KyberKey_EncodePublicKey(KyberKey* key, unsigned char* out, word32 len) return ret; } -#endif /* WOLFSSL_HAVE_KYBER */ +#endif /* WOLFSSL_HAVE_KYBER && !WOLFSSL_WC_KYBER */ diff --git a/wolfcrypt/src/ext_lms.c b/wolfcrypt/src/ext_lms.c index 7a59576672..a991129ec5 100644 --- a/wolfcrypt/src/ext_lms.c +++ b/wolfcrypt/src/ext_lms.c @@ -1,6 +1,6 @@ /* ext_lms.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/ext_xmss.c b/wolfcrypt/src/ext_xmss.c index 9ce012e255..14e3f71c97 100644 --- a/wolfcrypt/src/ext_xmss.c +++ b/wolfcrypt/src/ext_xmss.c @@ -1,6 +1,6 @@ /* ext_xmss.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/falcon.c b/wolfcrypt/src/falcon.c index 04309dbecb..b1aabb13b2 100644 --- a/wolfcrypt/src/falcon.c +++ b/wolfcrypt/src/falcon.c @@ -1,6 +1,6 @@ /* falcon.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fe_448.c b/wolfcrypt/src/fe_448.c index 36c6096945..ede162a5e2 100644 --- a/wolfcrypt/src/fe_448.c +++ b/wolfcrypt/src/fe_448.c @@ -1,6 +1,6 @@ /* fe_448.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fe_low_mem.c b/wolfcrypt/src/fe_low_mem.c index 3556639600..ad10a0e944 100644 --- a/wolfcrypt/src/fe_low_mem.c +++ b/wolfcrypt/src/fe_low_mem.c @@ -1,6 +1,6 @@ /* fe_low_mem.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fe_operations.c b/wolfcrypt/src/fe_operations.c index 704b455c34..2910151dfb 100644 --- a/wolfcrypt/src/fe_operations.c +++ b/wolfcrypt/src/fe_operations.c @@ -1,6 +1,6 @@ /* fe_operations.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mont_small.i b/wolfcrypt/src/fp_mont_small.i index c0f9092487..c75547b6a3 100644 --- a/wolfcrypt/src/fp_mont_small.i +++ b/wolfcrypt/src/fp_mont_small.i @@ -1,6 +1,6 @@ /* fp_mont_small.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_12.i b/wolfcrypt/src/fp_mul_comba_12.i index b5840a5d7f..153b02c4eb 100644 --- a/wolfcrypt/src/fp_mul_comba_12.i +++ b/wolfcrypt/src/fp_mul_comba_12.i @@ -1,6 +1,6 @@ /* fp_mul_comba_12.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_17.i b/wolfcrypt/src/fp_mul_comba_17.i index 8092e4549e..6e2487cd61 100644 --- a/wolfcrypt/src/fp_mul_comba_17.i +++ b/wolfcrypt/src/fp_mul_comba_17.i @@ -1,6 +1,6 @@ /* fp_mul_comba_17.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_20.i b/wolfcrypt/src/fp_mul_comba_20.i index cec9e46e8b..b2994324fc 100644 --- a/wolfcrypt/src/fp_mul_comba_20.i +++ b/wolfcrypt/src/fp_mul_comba_20.i @@ -1,6 +1,6 @@ /* fp_mul_comba_20.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_24.i b/wolfcrypt/src/fp_mul_comba_24.i index 299ebc41db..cc1463e2de 100644 --- a/wolfcrypt/src/fp_mul_comba_24.i +++ b/wolfcrypt/src/fp_mul_comba_24.i @@ -1,6 +1,6 @@ /* fp_mul_comba_24.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_28.i b/wolfcrypt/src/fp_mul_comba_28.i index 13af28df84..5d079164fb 100644 --- a/wolfcrypt/src/fp_mul_comba_28.i +++ b/wolfcrypt/src/fp_mul_comba_28.i @@ -1,6 +1,6 @@ /* fp_mul_comba_28.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_3.i b/wolfcrypt/src/fp_mul_comba_3.i index 1ac5622e26..4318b8e0c5 100644 --- a/wolfcrypt/src/fp_mul_comba_3.i +++ b/wolfcrypt/src/fp_mul_comba_3.i @@ -1,6 +1,6 @@ /* fp_mul_comba_3.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_32.i b/wolfcrypt/src/fp_mul_comba_32.i index c8d3b6c0cd..e381d73596 100644 --- a/wolfcrypt/src/fp_mul_comba_32.i +++ b/wolfcrypt/src/fp_mul_comba_32.i @@ -1,6 +1,6 @@ /* fp_mul_comba_32.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_4.i b/wolfcrypt/src/fp_mul_comba_4.i index d4e400224e..0f404ff895 100644 --- a/wolfcrypt/src/fp_mul_comba_4.i +++ b/wolfcrypt/src/fp_mul_comba_4.i @@ -1,6 +1,6 @@ /* fp_mul_comba_4.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_48.i b/wolfcrypt/src/fp_mul_comba_48.i index a81cec53ad..2189b601bc 100644 --- a/wolfcrypt/src/fp_mul_comba_48.i +++ b/wolfcrypt/src/fp_mul_comba_48.i @@ -1,6 +1,6 @@ /* fp_mul_comba_48.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_6.i b/wolfcrypt/src/fp_mul_comba_6.i index 67ee873777..f5c33d2fc0 100644 --- a/wolfcrypt/src/fp_mul_comba_6.i +++ b/wolfcrypt/src/fp_mul_comba_6.i @@ -1,6 +1,6 @@ /* fp_mul_comba_6.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_64.i b/wolfcrypt/src/fp_mul_comba_64.i index 8f75cddafd..dba74829ef 100644 --- a/wolfcrypt/src/fp_mul_comba_64.i +++ b/wolfcrypt/src/fp_mul_comba_64.i @@ -1,6 +1,6 @@ /* fp_mul_comba_64.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_7.i b/wolfcrypt/src/fp_mul_comba_7.i index a50d30d866..ffb8a322e9 100644 --- a/wolfcrypt/src/fp_mul_comba_7.i +++ b/wolfcrypt/src/fp_mul_comba_7.i @@ -1,6 +1,6 @@ /* fp_mul_comba_7.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_8.i b/wolfcrypt/src/fp_mul_comba_8.i index a0a4d38fcb..044a731fb3 100644 --- a/wolfcrypt/src/fp_mul_comba_8.i +++ b/wolfcrypt/src/fp_mul_comba_8.i @@ -1,6 +1,6 @@ /* fp_mul_comba_8.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_9.i b/wolfcrypt/src/fp_mul_comba_9.i index cf63f82cab..4ebc103499 100644 --- a/wolfcrypt/src/fp_mul_comba_9.i +++ b/wolfcrypt/src/fp_mul_comba_9.i @@ -1,6 +1,6 @@ /* fp_mul_comba_9.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_mul_comba_small_set.i b/wolfcrypt/src/fp_mul_comba_small_set.i index 1ece3cc465..7b6277917d 100644 --- a/wolfcrypt/src/fp_mul_comba_small_set.i +++ b/wolfcrypt/src/fp_mul_comba_small_set.i @@ -1,6 +1,6 @@ /* fp_mul_comba_small_set.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_12.i b/wolfcrypt/src/fp_sqr_comba_12.i index f542b9129f..87deca00a8 100644 --- a/wolfcrypt/src/fp_sqr_comba_12.i +++ b/wolfcrypt/src/fp_sqr_comba_12.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_12.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_17.i b/wolfcrypt/src/fp_sqr_comba_17.i index 6987c5757a..b6c589a9fb 100644 --- a/wolfcrypt/src/fp_sqr_comba_17.i +++ b/wolfcrypt/src/fp_sqr_comba_17.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_17.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_20.i b/wolfcrypt/src/fp_sqr_comba_20.i index bd388d5fde..f8776d59eb 100644 --- a/wolfcrypt/src/fp_sqr_comba_20.i +++ b/wolfcrypt/src/fp_sqr_comba_20.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_20.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_24.i b/wolfcrypt/src/fp_sqr_comba_24.i index e57148a3c2..25178e3713 100644 --- a/wolfcrypt/src/fp_sqr_comba_24.i +++ b/wolfcrypt/src/fp_sqr_comba_24.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_24.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_28.i b/wolfcrypt/src/fp_sqr_comba_28.i index 78fb8e0164..1e639ffb70 100644 --- a/wolfcrypt/src/fp_sqr_comba_28.i +++ b/wolfcrypt/src/fp_sqr_comba_28.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_28.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_3.i b/wolfcrypt/src/fp_sqr_comba_3.i index bab8996dd9..b16412c920 100644 --- a/wolfcrypt/src/fp_sqr_comba_3.i +++ b/wolfcrypt/src/fp_sqr_comba_3.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_3.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_32.i b/wolfcrypt/src/fp_sqr_comba_32.i index 9ee96c52f1..359a47e41c 100644 --- a/wolfcrypt/src/fp_sqr_comba_32.i +++ b/wolfcrypt/src/fp_sqr_comba_32.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_32.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_4.i b/wolfcrypt/src/fp_sqr_comba_4.i index d0bae98021..92e38b5d6a 100644 --- a/wolfcrypt/src/fp_sqr_comba_4.i +++ b/wolfcrypt/src/fp_sqr_comba_4.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_4.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_48.i b/wolfcrypt/src/fp_sqr_comba_48.i index a9fa4f8e10..d6568f95e7 100644 --- a/wolfcrypt/src/fp_sqr_comba_48.i +++ b/wolfcrypt/src/fp_sqr_comba_48.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_48.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_6.i b/wolfcrypt/src/fp_sqr_comba_6.i index 2e91e69b15..a92eb1032a 100644 --- a/wolfcrypt/src/fp_sqr_comba_6.i +++ b/wolfcrypt/src/fp_sqr_comba_6.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_6.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_64.i b/wolfcrypt/src/fp_sqr_comba_64.i index a072269cb5..41da933311 100644 --- a/wolfcrypt/src/fp_sqr_comba_64.i +++ b/wolfcrypt/src/fp_sqr_comba_64.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_64.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_7.i b/wolfcrypt/src/fp_sqr_comba_7.i index 9ae37801df..2b2f1d8fb1 100644 --- a/wolfcrypt/src/fp_sqr_comba_7.i +++ b/wolfcrypt/src/fp_sqr_comba_7.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_7.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_8.i b/wolfcrypt/src/fp_sqr_comba_8.i index c0be97bb52..13b728366c 100644 --- a/wolfcrypt/src/fp_sqr_comba_8.i +++ b/wolfcrypt/src/fp_sqr_comba_8.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_8.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_9.i b/wolfcrypt/src/fp_sqr_comba_9.i index 92369de40c..aa04a22dfb 100644 --- a/wolfcrypt/src/fp_sqr_comba_9.i +++ b/wolfcrypt/src/fp_sqr_comba_9.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_9.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fp_sqr_comba_small_set.i b/wolfcrypt/src/fp_sqr_comba_small_set.i index f8e0a4dc15..a47ca8c2dc 100644 --- a/wolfcrypt/src/fp_sqr_comba_small_set.i +++ b/wolfcrypt/src/fp_sqr_comba_small_set.i @@ -1,6 +1,6 @@ /* fp_sqr_comba_small_set.i * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/ge_448.c b/wolfcrypt/src/ge_448.c index d2033af9a8..fbb600eaf2 100644 --- a/wolfcrypt/src/ge_448.c +++ b/wolfcrypt/src/ge_448.c @@ -1,6 +1,6 @@ /* ge_448.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/ge_low_mem.c b/wolfcrypt/src/ge_low_mem.c index abe6ea697a..df747a126c 100644 --- a/wolfcrypt/src/ge_low_mem.c +++ b/wolfcrypt/src/ge_low_mem.c @@ -1,6 +1,6 @@ /* ge_low_mem.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/ge_operations.c b/wolfcrypt/src/ge_operations.c index 57a838cda7..6a82d50dcd 100644 --- a/wolfcrypt/src/ge_operations.c +++ b/wolfcrypt/src/ge_operations.c @@ -1,6 +1,6 @@ /* ge_operations.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/hash.c b/wolfcrypt/src/hash.c index bc69c3b482..db3a047998 100644 --- a/wolfcrypt/src/hash.c +++ b/wolfcrypt/src/hash.c @@ -1,6 +1,6 @@ /* hash.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/hmac.c b/wolfcrypt/src/hmac.c index fb71bf3abd..47f8f13824 100644 --- a/wolfcrypt/src/hmac.c +++ b/wolfcrypt/src/hmac.c @@ -1,6 +1,6 @@ /* hmac.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/hpke.c b/wolfcrypt/src/hpke.c index 15e8d85698..450ee73173 100644 --- a/wolfcrypt/src/hpke.c +++ b/wolfcrypt/src/hpke.c @@ -1,6 +1,6 @@ /* hpke.c * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index dadfeb4eef..3deeaeb82e 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -1,6 +1,6 @@ /* integer.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/kdf.c b/wolfcrypt/src/kdf.c index 9edf3a5747..fa0e096ca3 100644 --- a/wolfcrypt/src/kdf.c +++ b/wolfcrypt/src/kdf.c @@ -1,6 +1,6 @@ /* kdf.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/logging.c b/wolfcrypt/src/logging.c index de87dbf8d8..f28a71ef7b 100644 --- a/wolfcrypt/src/logging.c +++ b/wolfcrypt/src/logging.c @@ -1,6 +1,6 @@ /* logging.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/md2.c b/wolfcrypt/src/md2.c index 789704e675..c28a049d4f 100644 --- a/wolfcrypt/src/md2.c +++ b/wolfcrypt/src/md2.c @@ -1,6 +1,6 @@ /* md2.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -123,7 +123,7 @@ void wc_Md2Final(Md2* md2, byte* hash) for (i = 0; i < padLen; i++) padding[i] = (byte)padLen; - wc_Md2Update(md2, padding, padLen); + wc_Md2Update(md2, padding, padLen); /* cppcheck-suppress uninitvar */ wc_Md2Update(md2, md2->C, MD2_BLOCK_SIZE); XMEMCPY(hash, md2->X, MD2_DIGEST_SIZE); diff --git a/wolfcrypt/src/md4.c b/wolfcrypt/src/md4.c index 68eab5fb2b..65b4dc23f6 100644 --- a/wolfcrypt/src/md4.c +++ b/wolfcrypt/src/md4.c @@ -1,6 +1,6 @@ /* md4.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/md5.c b/wolfcrypt/src/md5.c index daab9c9ecf..f6ca240be9 100644 --- a/wolfcrypt/src/md5.c +++ b/wolfcrypt/src/md5.c @@ -1,6 +1,6 @@ /* md5.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/memory.c b/wolfcrypt/src/memory.c index 3e8d4ada58..164dc95717 100644 --- a/wolfcrypt/src/memory.c +++ b/wolfcrypt/src/memory.c @@ -1,6 +1,6 @@ /* memory.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/misc.c b/wolfcrypt/src/misc.c index 10f733bd02..e69ad655ba 100644 --- a/wolfcrypt/src/misc.c +++ b/wolfcrypt/src/misc.c @@ -1,6 +1,6 @@ /* misc.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/pkcs12.c b/wolfcrypt/src/pkcs12.c index ef111a6dfb..d6cf526221 100644 --- a/wolfcrypt/src/pkcs12.c +++ b/wolfcrypt/src/pkcs12.c @@ -1,6 +1,6 @@ /* pkcs12.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/pkcs7.c b/wolfcrypt/src/pkcs7.c index acf7ef8f22..d07f1f7889 100644 --- a/wolfcrypt/src/pkcs7.c +++ b/wolfcrypt/src/pkcs7.c @@ -1,6 +1,6 @@ /* pkcs7.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -830,6 +830,14 @@ int wc_PKCS7_Init(PKCS7* pkcs7, void* heap, int devId) return 0; } +#ifdef WC_ASN_UNKNOWN_EXT_CB +void wc_PKCS7_SetUnknownExtCallback(PKCS7* pkcs7, wc_UnknownExtCallback cb) +{ + if (pkcs7 != NULL) { + pkcs7->unknownExtCallback = cb; + } +} +#endif /* Certificate structure holding der pointer, size, and pointer to next * Pkcs7Cert struct. Used when creating SignedData types with multiple @@ -1074,6 +1082,9 @@ int wc_PKCS7_InitWithCert(PKCS7* pkcs7, byte* derCert, word32 derCertSz) int devId; Pkcs7Cert* cert; Pkcs7Cert* lastCert; +#ifdef WC_ASN_UNKNOWN_EXT_CB + wc_UnknownExtCallback cb; +#endif if (pkcs7 == NULL || (derCert == NULL && derCertSz != 0)) { return BAD_FUNC_ARG; @@ -1082,9 +1093,16 @@ int wc_PKCS7_InitWithCert(PKCS7* pkcs7, byte* derCert, word32 derCertSz) heap = pkcs7->heap; devId = pkcs7->devId; cert = pkcs7->certList; +#ifdef WC_ASN_UNKNOWN_EXT_CB + cb = pkcs7->unknownExtCallback; /* save / restore callback */ +#endif ret = wc_PKCS7_Init(pkcs7, heap, devId); if (ret != 0) return ret; + +#ifdef WC_ASN_UNKNOWN_EXT_CB + pkcs7->unknownExtCallback = cb; +#endif pkcs7->certList = cert; if (derCert != NULL && derCertSz > 0) { @@ -1133,6 +1151,10 @@ int wc_PKCS7_InitWithCert(PKCS7* pkcs7, byte* derCert, word32 derCertSz) } InitDecodedCert(dCert, derCert, derCertSz, pkcs7->heap); +#ifdef WC_ASN_UNKNOWN_EXT_CB + if (pkcs7->unknownExtCallback != NULL) + wc_SetUnknownExtCallback(dCert, pkcs7->unknownExtCallback); +#endif ret = ParseCert(dCert, CA_TYPE, NO_VERIFY, 0); if (ret < 0) { FreeDecodedCert(dCert); diff --git a/wolfcrypt/src/poly1305.c b/wolfcrypt/src/poly1305.c index cde754752a..730a5c2afa 100644 --- a/wolfcrypt/src/poly1305.c +++ b/wolfcrypt/src/poly1305.c @@ -1,6 +1,6 @@ /* poly1305.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/poly1305_asm.asm b/wolfcrypt/src/poly1305_asm.asm index 972a62c63e..1182da509b 100644 --- a/wolfcrypt/src/poly1305_asm.asm +++ b/wolfcrypt/src/poly1305_asm.asm @@ -1,6 +1,6 @@ ; /* poly1305_asm.asm */ ; /* -; * Copyright (C) 2006-2024 wolfSSL Inc. +; * Copyright (C) 2006-2024 wolfSSL Inc. ; * ; * This file is part of wolfSSL. ; * diff --git a/wolfcrypt/src/port/Renesas/renesas_common.c b/wolfcrypt/src/port/Renesas/renesas_common.c index 4ccc075b15..a55a01ad01 100644 --- a/wolfcrypt/src/port/Renesas/renesas_common.c +++ b/wolfcrypt/src/port/Renesas/renesas_common.c @@ -1,6 +1,6 @@ /* renesas_common.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -21,37 +21,44 @@ #include -#if defined(WOLFSSL_RENESAS_FSPSM_TLS) \ - || defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) \ - || defined(WOLFSSL_RENESAS_TSIP_TLS) \ - || defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) +#if defined(WOLFSSL_RENESAS_FSPSM_TLS) || \ + defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) || \ + defined(WOLFSSL_RENESAS_TSIP_TLS) || \ + defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) #if defined(WOLFSSL_RENESAS_FSPSM_TLS) || \ defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) - #include - #define cmn_hw_lock wc_fspsm_hw_lock - #define cmn_hw_unlock wc_fspsm_hw_unlock + + #include + #define cmn_hw_lock wc_fspsm_hw_lock + #define cmn_hw_unlock wc_fspsm_hw_unlock + #elif defined(WOLFSSL_RENESAS_TSIP_TLS) || \ - defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) - #include - #define cmn_hw_lock tsip_hw_lock - #define cmn_hw_unlock tsip_hw_unlock + defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) + + #include + #define cmn_hw_lock tsip_hw_lock + #define cmn_hw_unlock tsip_hw_unlock - #define FSPSM_ST TsipUserCtx; - #define MAX_FSPSM_CBINDEX 5 + #define FSPSM_ST TsipUserCtx; + #define MAX_FSPSM_CBINDEX 5 #endif #include #include #include +#ifndef WOLFSSL_RENESAS_TSIP_CRYPTONLY #include +#endif #include #include #include -#include +#include + +#define INITIAL_DEVID 7890 uint32_t g_CAscm_Idx = (uint32_t)-1; /* index of CM table */ -static int gdevId = 7890; /* initial dev Id for Crypt Callback */ +static int gdevId = INITIAL_DEVID; /* initial dev Id for Crypt Callback */ #ifdef WOLF_CRYPTO_CB /* store callback ctx by devId */ @@ -59,7 +66,7 @@ static int gdevId = 7890; /* initial dev Id for Crypt Callback */ defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) FSPSM_ST *gCbCtx[MAX_FSPSM_CBINDEX]; #elif defined(WOLFSSL_RENESAS_TSIP_TLS) || \ - defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) + defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) #define FSPSM_ST TsipUserCtx; #define MAX_FSPSM_CBINDEX 5 TsipUserCtx *gCbCtx[MAX_FSPSM_CBINDEX]; @@ -68,7 +75,7 @@ TsipUserCtx *gCbCtx[MAX_FSPSM_CBINDEX]; #include -WOLFSSL_LOCAL int Renesas_cmn_Cleanup(WOLFSSL* ssl) +WOLFSSL_LOCAL int Renesas_cmn_Cleanup(struct WOLFSSL* ssl) { int ret = 0; WOLFSSL_ENTER("Renesas_cmn_Cleanup"); @@ -111,11 +118,9 @@ WOLFSSL_LOCAL int Renesas_cmn_RsaSignCheckCb(WOLFSSL* ssl, int ret = WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE); WOLFSSL_ENTER("Renesas_cmn_RsaSignCheckCb"); - #if defined(WOLFSSL_RENESAS_TSIP) - - return tsip_VerifyRsaPkcsCb(ssl, sig, sigSz, out, keyDer, keySz, ctx); - - #endif /* WOLFSSL_RENESAS_TSIP */ +#if defined(WOLFSSL_RENESAS_TSIP) + ret = tsip_VerifyRsaPkcsCb(ssl, sig, sigSz, out, keyDer, keySz, ctx); +#endif /* WOLFSSL_RENESAS_TSIP */ WOLFSSL_LEAVE("Renesas_cmn_RsaSignCheckCb", ret); return ret; @@ -151,29 +156,31 @@ static int Renesas_cmn_CryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx) WOLFSSL_ENTER("Renesas_cmn_CryptoDevCb"); -#if defined(WOLFSSL_RENESAS_TSIP_TLS) \ - || defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) - TsipUserCtx* cbInfo = (TsipUserCtx*)ctx; +#if defined(WOLFSSL_RENESAS_TSIP_TLS) || \ + defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) + TsipUserCtx* cbInfo = (TsipUserCtx*)ctx; #elif defined(WOLFSSL_RENESAS_FSPSM_TLS) || \ - defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) + defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) FSPSM_ST* cbInfo = (FSPSM_ST*)ctx; #endif if (info == NULL || ctx == NULL) return BAD_FUNC_ARG; -#ifdef DEBUG_WOLFSSL +#if defined(DEBUG_WOLFSSL) printf("CryptoDevCb: Algo Type %d session key set: %d\n", info->algo_type, cbInfo->session_key_set); #endif +#if defined(DEBUG_CRYPTOCB) + wc_CryptoCb_InfoString(info); +#endif -#if defined(WOLFSSL_RENESAS_TSIP) \ - || defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) +#if defined(WOLFSSL_RENESAS_TSIP) || \ + defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) ret = CRYPTOCB_UNAVAILABLE; if (info->algo_type == WC_ALGO_TYPE_CIPHER) { - - #if !defined(NO_AES) || !defined(NO_DES3) + #if !defined(NO_AES) #ifdef HAVE_AESGCM if (info->cipher.type == WC_CIPHER_AES_GCM #ifdef WOLFSSL_RENESAS_TSIP_TLS @@ -236,44 +243,51 @@ static int Renesas_cmn_CryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx) } } #endif /* HAVE_AES_CBC */ - #endif /* !NO_AES || !NO_DES3 */ - } - #if defined(WOLFSSL_KEY_GEN) - if (info->pk.type == WC_PK_TYPE_RSA_KEYGEN && - (info->pk.rsakg.size == 1024 || - info->pk.rsakg.size == 2048)) { - ret = wc_tsip_MakeRsaKey(info->pk.rsakg.size, (void*)ctx); + #endif /* !NO_AES */ } - #endif - /* Is called for signing - * Can handle only RSA PkCS#1v1.5 padding scheme here. - */ if (info->algo_type == WC_ALGO_TYPE_PK) { - #if !defined(NO_RSA) - if (info->pk.type == WC_PK_TYPE_RSA) { - if (info->pk.rsa.type == RSA_PRIVATE_ENCRYPT) { - ret = tsip_SignRsaPkcs(info, ctx); - } - #if defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) - else if (info->pk.rsa.type == RSA_PUBLIC_DECRYPT /* verify */) { - ret = wc_tsip_RsaVerifyPkcs(info, ctx); - } - #endif + #if !defined(NO_RSA) + #if defined(WOLFSSL_KEY_GEN) + if (info->pk.type == WC_PK_TYPE_RSA_KEYGEN && + (info->pk.rsakg.size == 1024 || info->pk.rsakg.size == 2048)) { + ret = wc_tsip_MakeRsaKey(info->pk.rsakg.size, (void*)ctx); } - #endif /* NO_RSA */ - #if defined(HAVE_ECC) && defined(WOLFSSL_RENESAS_TSIP_TLS) - else if (info->pk.type == WC_PK_TYPE_ECDSA_SIGN) { - ret = tsip_SignEcdsa(info, ctx); + #endif + + /* RSA Signing + * Can handle only RSA PkCS#1v1.5 padding scheme here. + */ + if (info->pk.rsa.type == RSA_PRIVATE_ENCRYPT) { + ret = tsip_SignRsaPkcs(info, cbInfo); + } + #if defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) + /* RSA Verify */ + if (info->pk.rsa.type == RSA_PUBLIC_DECRYPT) { + ret = wc_tsip_RsaVerifyPkcs(info, cbInfo); + } + #endif + #endif /* !NO_RSA */ + + #if defined(HAVE_ECC) + #if defined(WOLFSSL_RENESAS_TSIP_TLS) + if (info->pk.type == WC_PK_TYPE_ECDSA_SIGN) { + ret = tsip_SignEcdsa(info, cbInfo); } - #endif /* HAVE_ECC */ + #endif + #if defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) + if (info->pk.type == WC_PK_TYPE_ECDSA_VERIFY) { + ret = tsip_VerifyEcdsa(info, cbInfo); + } + #endif + #endif /* HAVE_ECC */ } -#elif defined(WOLFSSL_RENESAS_FSPSM_TLS) ||\ - defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) - if (info->algo_type == WC_ALGO_TYPE_CIPHER) { +#elif defined(WOLFSSL_RENESAS_FSPSM_TLS) || \ + defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) - #if !defined(NO_AES) || !defined(NO_DES3) + if (info->algo_type == WC_ALGO_TYPE_CIPHER) { + #if !defined(NO_AES) #ifdef HAVE_AESGCM if (info->cipher.type == WC_CIPHER_AES_GCM) { @@ -342,20 +356,19 @@ static int Renesas_cmn_CryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx) } } #endif /* HAVE_AES_CBC */ - #endif /* !NO_AES || !NO_DES3 */ + #endif /* !NO_AES */ } - #if !defined(NO_RSA) && defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) - else if (info->algo_type == WC_ALGO_TYPE_PK) { - #if !defined(NO_RSA) - #if defined(WOLFSSL_KEY_GEN) +#if !defined(NO_RSA) && defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) + else if (info->algo_type == WC_ALGO_TYPE_PK) { + #if defined(WOLFSSL_KEY_GEN) if (info->pk.type == WC_PK_TYPE_RSA_KEYGEN && (info->pk.rsakg.size == 1024 || info->pk.rsakg.size == 2048)) { ret = wc_fspsm_MakeRsaKey(info->pk.rsakg.key, info->pk.rsakg.size, (void*)ctx); } - #endif + #endif if (info->pk.type == WC_PK_TYPE_RSA) { /* to perform RSA on SCE, wrapped keys should be installed * in advance. SCE supports 1024 or 2048 bits key size. @@ -406,9 +419,8 @@ static int Renesas_cmn_CryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx) "RSA operation falls through to SW operation."); } } - #endif /* NO_RSA && WOLFSSL_RENESAS_FSPSM_CRYPTONLY */ } - #endif /* NO_RSA */ + #endif /* !NO_RSA */ #endif /* TSIP or SCE */ (void)devIdArg; @@ -424,17 +436,20 @@ static int Renesas_cmn_CryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx) * session_key_generated : if session key has been generated * return 1 for usable, 0 for unusable */ -int Renesas_cmn_usable(const WOLFSSL* ssl, byte session_key_generated) +int Renesas_cmn_usable(const struct WOLFSSL* ssl, byte session_key_generated) { - int ret; + int ret = 0; #if defined(WOLFSSL_RENESAS_TSIP_TLS) ret = tsip_usable(ssl, session_key_generated); #elif defined(WOLFSSL_RENESAS_FSPSM_TLS) ||\ - defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) + defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) ret = wc_fspsm_usable(ssl, session_key_generated); #endif + (void)ssl; + (void)session_key_generated; + return ret; } @@ -447,8 +462,8 @@ int Renesas_cmn_usable(const WOLFSSL* ssl, byte session_key_generated) */ WOLFSSL_LOCAL void *Renesas_cmn_GetCbCtxBydevId(int devId) { - if (devId >= 7890 && devId <= (MAX_FSPSM_CBINDEX + 7890)) - return gCbCtx[devId - 7890]; + if (devId >= INITIAL_DEVID && devId <= (MAX_FSPSM_CBINDEX + INITIAL_DEVID)) + return gCbCtx[devId - INITIAL_DEVID]; else return NULL; } @@ -462,13 +477,13 @@ WOLFSSL_LOCAL void *Renesas_cmn_GetCbCtxBydevId(int devId) * device Id starts from 7890, and increases + 1 its number * when the method is successfully called. */ -int wc_CryptoCb_CryptInitRenesasCmn(WOLFSSL* ssl, void* ctx) +int wc_CryptoCb_CryptInitRenesasCmn(struct WOLFSSL* ssl, void* ctx) { (void)ssl; (void)ctx; - #if defined(WOLFSSL_RENESAS_TSIP_TLS) \ - || defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) + #if defined(WOLFSSL_RENESAS_TSIP_TLS) || \ + defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) TsipUserCtx* cbInfo = (TsipUserCtx*)ctx; #elif defined(WOLFSSL_RENESAS_FSPSM_TLS) || \ defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) @@ -476,18 +491,21 @@ int wc_CryptoCb_CryptInitRenesasCmn(WOLFSSL* ssl, void* ctx) #endif if (cbInfo == NULL - #if (!defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) &&\ + #if (!defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) && \ !defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY)) && \ - !defined(HAVE_RENESAS_SYNC) - || ssl == NULL) { - #else - ) { + !defined(HAVE_RENESAS_SYNC) + || ssl == NULL #endif - printf("Invalid devId\n"); + ) { + WOLFSSL_MSG("Invalid devId\n"); return INVALID_DEVID; } /* need exclusive control because of static variable */ if ((cmn_hw_lock()) == 0) { + /* sanity check for overflow */ + if (gdevId < 0) { + gdevId = INITIAL_DEVID; + } cbInfo->devId = gdevId++; cmn_hw_unlock(); } @@ -509,12 +527,8 @@ int wc_CryptoCb_CryptInitRenesasCmn(WOLFSSL* ssl, void* ctx) if (ssl) wolfSSL_SetDevId(ssl, cbInfo->devId); #endif - /* sanity check for overflow */ - if (gdevId < 0) { - gdevId = 7890; - } - gCbCtx[cbInfo->devId - 7890] = (void*)cbInfo; + gCbCtx[cbInfo->devId - INITIAL_DEVID] = (void*)cbInfo; return cbInfo->devId; } @@ -532,8 +546,8 @@ void wc_CryptoCb_CleanupRenesasCmn(int* id) } #endif /* WOLF_CRYPTO_CB */ -#endif /* WOLFSSL_RENESAS_FSPSM_TLS|| WOLFSSL_RENESAS_FSPSM_CRYPTONLY - WOLFSSL_RENESAS_TSIP_TLS || WOLFSSL_RENESAS_TSIP_CRYPTONLY */ +#endif /* WOLFSSL_RENESAS_FSPSM_TLS || WOLFSSL_RENESAS_FSPSM_CRYPTONLY + WOLFSSL_RENESAS_TSIP_TLS || WOLFSSL_RENESAS_TSIP_CRYPTONLY */ #if defined(WOLFSSL_RENESAS_FSPSM_TLS) || defined(WOLFSSL_RENESAS_TSIP_TLS) @@ -805,7 +819,7 @@ WOLFSSL_LOCAL int Renesas_cmn_generateSessionKey(WOLFSSL* ssl, void* ctx) WOLFSSL_ENTER("Renesas_cmn_generateSessionKey"); if (Renesas_cmn_usable(ssl, 0)) { #if defined(WOLFSSL_RENESAS_TSIP_TLS) - ret = wc_tsip_generateSessionKey(ssl, (TsipUserCtx*)ctx, cbInfo->devId); + ret = wc_tsip_generateSessionKey(ssl, cbInfo, cbInfo->devId); #elif defined(WOLFSSL_RENESAS_FSPSM_TLS) ret = wc_fspsm_generateSessionKey(ssl, ctx, cbInfo->devId); #endif diff --git a/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c b/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c index 37a2bedeaf..0028786c57 100644 --- a/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c +++ b/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c @@ -1,6 +1,6 @@ /* renesas_fspsm_aes.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/Renesas/renesas_fspsm_sha.c b/wolfcrypt/src/port/Renesas/renesas_fspsm_sha.c index bba843ed02..9820f28d95 100644 --- a/wolfcrypt/src/port/Renesas/renesas_fspsm_sha.c +++ b/wolfcrypt/src/port/Renesas/renesas_fspsm_sha.c @@ -1,6 +1,6 @@ /* renesas_fspsm_sha.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c b/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c index f0d19e758e..c955b571c6 100644 --- a/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c +++ b/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c @@ -1,6 +1,6 @@ /* renesas_fspsm_util.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/Renesas/renesas_rx64_hw_sha.c b/wolfcrypt/src/port/Renesas/renesas_rx64_hw_sha.c index 170ebb5e42..8cbd192c72 100644 --- a/wolfcrypt/src/port/Renesas/renesas_rx64_hw_sha.c +++ b/wolfcrypt/src/port/Renesas/renesas_rx64_hw_sha.c @@ -2,7 +2,7 @@ * * Contributed by Johnson Controls Tyco IP Holdings LLP. * - * Use of this Software is subject to the GPLv2 License + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -13,7 +13,7 @@ * * wolfSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License diff --git a/wolfcrypt/src/port/Renesas/renesas_rx64_hw_util.c b/wolfcrypt/src/port/Renesas/renesas_rx64_hw_util.c index 2d995d99f4..72505868e2 100644 --- a/wolfcrypt/src/port/Renesas/renesas_rx64_hw_util.c +++ b/wolfcrypt/src/port/Renesas/renesas_rx64_hw_util.c @@ -2,7 +2,7 @@ * * Contributed by Johnson Controls Tyco IP Holdings LLP. * - * Use of this Software is subject to the GPLv2 License + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -13,7 +13,7 @@ * * wolfSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License diff --git a/wolfcrypt/src/port/Renesas/renesas_tsip_aes.c b/wolfcrypt/src/port/Renesas/renesas_tsip_aes.c index ecdf977e57..dc9bcd5f30 100644 --- a/wolfcrypt/src/port/Renesas/renesas_tsip_aes.c +++ b/wolfcrypt/src/port/Renesas/renesas_tsip_aes.c @@ -1,6 +1,6 @@ /* renesas_tsip_aes.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/Renesas/renesas_tsip_rsa.c b/wolfcrypt/src/port/Renesas/renesas_tsip_rsa.c index 1da7869ebc..22664f836d 100644 --- a/wolfcrypt/src/port/Renesas/renesas_tsip_rsa.c +++ b/wolfcrypt/src/port/Renesas/renesas_tsip_rsa.c @@ -1,6 +1,6 @@ /* renesas_sce_rsa.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -40,7 +40,7 @@ #include #ifdef WOLFSSL_RENESAS_TSIP_CRYPTONLY -/* Make Rsa key for TSIP and set it to callback ctx +/* Make RSA key for TSIP and set it to callback ctx * Assumes to be called by Crypt Callback * * size desired keylenth, in bits. supports 1024 or 2048 bits @@ -59,6 +59,11 @@ WOLFSSL_LOCAL int wc_tsip_MakeRsaKey(int size, void* ctx) if (ctx == NULL) return BAD_FUNC_ARG; + if (size != 1024 && size != 2048) { + WOLFSSL_MSG("Failed to generate key pair by TSIP"); + return CRYPTOCB_UNAVAILABLE; + } + if ((ret = tsip_hw_lock()) == 0) { if (size == 1024) { tsip_pair1024_key = @@ -80,8 +85,6 @@ WOLFSSL_LOCAL int wc_tsip_MakeRsaKey(int size, void* ctx) ret = R_TSIP_GenerateRsa2048RandomKeyIndex(tsip_pair2048_key); } - else - return CRYPTOCB_UNAVAILABLE; if (ret == TSIP_SUCCESS) { if (size == 1024) { @@ -90,8 +93,7 @@ WOLFSSL_LOCAL int wc_tsip_MakeRsaKey(int size, void* ctx) DYNAMIC_TYPE_RSA_BUFFER); } if (info->rsa1024pub_keyIdx != NULL) { - XFREE(info->rsa1024pub_keyIdx, NULL, - DYNAMIC_TYPE_RSA_BUFFER); + XFREE(info->rsa1024pub_keyIdx, NULL, DYNAMIC_TYPE_RSA_BUFFER); } info->rsa1024pri_keyIdx = (tsip_rsa1024_private_key_index_t*)XMALLOC( @@ -99,7 +101,7 @@ WOLFSSL_LOCAL int wc_tsip_MakeRsaKey(int size, void* ctx) DYNAMIC_TYPE_RSA_BUFFER); if (info->rsa1024pri_keyIdx == NULL) { - XFREE(tsip_pair1024_key, 0, DYNAMIC_TYPE_RSA_BUFFER); + XFREE(tsip_pair1024_key, NULL, DYNAMIC_TYPE_RSA_BUFFER); return MEMORY_E; } @@ -109,9 +111,8 @@ WOLFSSL_LOCAL int wc_tsip_MakeRsaKey(int size, void* ctx) DYNAMIC_TYPE_RSA_BUFFER); if (info->rsa1024pub_keyIdx == NULL) { - XFREE(tsip_pair1024_key, 0, DYNAMIC_TYPE_RSA_BUFFER); - XFREE(info->rsa1024pri_keyIdx, 0, - DYNAMIC_TYPE_RSA_BUFFER); + XFREE(tsip_pair1024_key, NULL, DYNAMIC_TYPE_RSA_BUFFER); + XFREE(info->rsa1024pri_keyIdx, NULL, DYNAMIC_TYPE_RSA_BUFFER); return MEMORY_E; } /* copy generated key pair and free malloced key */ @@ -121,7 +122,7 @@ WOLFSSL_LOCAL int wc_tsip_MakeRsaKey(int size, void* ctx) XMEMCPY(info->rsa1024pub_keyIdx, &tsip_pair1024_key->public, sizeof(tsip_rsa1024_public_key_index_t)); - XFREE(tsip_pair1024_key, 0, DYNAMIC_TYPE_RSA_BUFFER); + XFREE(tsip_pair1024_key, NULL, DYNAMIC_TYPE_RSA_BUFFER); info->keyflgs_crypt.bits.rsapri1024_key_set = 1; info->keyflgs_crypt.bits.rsapub1024_key_set = 1; @@ -141,7 +142,7 @@ WOLFSSL_LOCAL int wc_tsip_MakeRsaKey(int size, void* ctx) DYNAMIC_TYPE_RSA_BUFFER); if (info->rsa2048pri_keyIdx == NULL) { - XFREE(tsip_pair2048_key, 0, DYNAMIC_TYPE_RSA_BUFFER); + XFREE(tsip_pair2048_key, NULL, DYNAMIC_TYPE_RSA_BUFFER); return MEMORY_E; } @@ -151,11 +152,12 @@ WOLFSSL_LOCAL int wc_tsip_MakeRsaKey(int size, void* ctx) DYNAMIC_TYPE_RSA_BUFFER); if (info->rsa2048pub_keyIdx == NULL) { - XFREE(tsip_pair2048_key, 0, DYNAMIC_TYPE_RSA_BUFFER); - XFREE(info->rsa2048pri_keyIdx, 0, + XFREE(tsip_pair2048_key, NULL, DYNAMIC_TYPE_RSA_BUFFER); + XFREE(info->rsa2048pri_keyIdx, NULL, DYNAMIC_TYPE_RSA_BUFFER); return MEMORY_E; } + /* copy generated key pair and free malloced key */ XMEMCPY(info->rsa2048pri_keyIdx, &tsip_pair2048_key->private, @@ -163,21 +165,17 @@ WOLFSSL_LOCAL int wc_tsip_MakeRsaKey(int size, void* ctx) XMEMCPY(info->rsa2048pub_keyIdx, &tsip_pair2048_key->public, sizeof(tsip_rsa2048_public_key_index_t)); - XFREE(tsip_pair2048_key, 0, DYNAMIC_TYPE_RSA_BUFFER); + XFREE(tsip_pair2048_key, NULL, DYNAMIC_TYPE_RSA_BUFFER); info->keyflgs_crypt.bits.rsapri2048_key_set = 1; info->keyflgs_crypt.bits.rsapub2048_key_set = 1; - } } - else { - WOLFSSL_MSG("Failed to generate key pair by TSIP"); - return CRYPTOCB_UNAVAILABLE; - } tsip_hw_unlock(); } + return 0; } @@ -199,21 +197,19 @@ WOLFSSL_LOCAL int wc_tsip_RsaVerifyPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc) int ret = 0; e_tsip_err_t err = TSIP_SUCCESS; tsip_rsa_byte_data_t hashData, sigData; - uint8_t tsip_hash_type; - /* sanity check */ if (info == NULL || tuc == NULL){ return BAD_FUNC_ARG; } if (ret == 0) { - if (tuc->sing_hash_type == md5_mac) + if (tuc->sign_hash_type == md5_mac) tsip_hash_type = R_TSIP_RSA_HASH_MD5; - else if (tuc->sing_hash_type == sha_mac) + else if (tuc->sign_hash_type == sha_mac) tsip_hash_type = R_TSIP_RSA_HASH_SHA1; - else if (tuc->sing_hash_type == sha256_mac) + else if (tuc->sign_hash_type == sha256_mac) tsip_hash_type = R_TSIP_RSA_HASH_SHA256; else ret = CRYPTOCB_UNAVAILABLE; @@ -221,8 +217,7 @@ WOLFSSL_LOCAL int wc_tsip_RsaVerifyPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc) switch (tuc->wrappedKeyType) { case TSIP_KEY_TYPE_RSA1024: - if (tuc->keyflgs_crypt.bits.rsapub1024_key_set != 1) - { + if (tuc->keyflgs_crypt.bits.rsapub1024_key_set != 1) { ret = tsipImportPublicKey(tuc, tuc->wrappedKeyType); WOLFSSL_MSG("tsip rsa private key 1024 not set"); @@ -232,11 +227,10 @@ WOLFSSL_LOCAL int wc_tsip_RsaVerifyPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc) } break; case TSIP_KEY_TYPE_RSA2048: - if (tuc->keyflgs_crypt.bits.rsapub2048_key_set != 1) - { + if (tuc->keyflgs_crypt.bits.rsapub2048_key_set != 1) { ret = tsipImportPublicKey(tuc, tuc->wrappedKeyType); - WOLFSSL_MSG("tsip rsa private key 1024 not set"); + WOLFSSL_MSG("tsip rsa private key 2048 not set"); if (ret != 0) ret = CRYPTOCB_UNAVAILABLE; } diff --git a/wolfcrypt/src/port/Renesas/renesas_tsip_sha.c b/wolfcrypt/src/port/Renesas/renesas_tsip_sha.c index 38ddd7b3e1..d4303839d6 100644 --- a/wolfcrypt/src/port/Renesas/renesas_tsip_sha.c +++ b/wolfcrypt/src/port/Renesas/renesas_tsip_sha.c @@ -1,6 +1,6 @@ /* renesas_tsip_sha.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/Renesas/renesas_tsip_util.c b/wolfcrypt/src/port/Renesas/renesas_tsip_util.c index 842ffb2bda..6097eb0e16 100644 --- a/wolfcrypt/src/port/Renesas/renesas_tsip_util.c +++ b/wolfcrypt/src/port/Renesas/renesas_tsip_util.c @@ -1,6 +1,6 @@ /* renesas_tsip_util.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -34,11 +34,15 @@ #define WOLFSSL_MISC_INCLUDED #include #endif -#include -#include -#include + +#ifndef WOLFSSL_RENESAS_TSIP_CRYPTONLY + #include + #include + #include +#endif #include #include + #include #define TSIP_SIGNING_DATA_PREFIX_SZ 64 @@ -171,6 +175,7 @@ WOLFSSL_API int tsip_use_PrivateKey_buffer_TLS(struct WOLFSSL* ssl, return ret; } #endif /* WOLFSSL_RENESAS_TSIP_TLS */ + #if defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) /* Set client encrypted public key data. @@ -189,8 +194,7 @@ WOLFSSL_API int tsip_use_PublicKey_buffer_crypt(TsipUserCtx *uc, WOLFSSL_ENTER("tsip_use_PublicKey_buffer_crypt"); - if (uc == NULL - || keyBuf == NULL || keyBufLen == 0) { + if (uc == NULL || keyBuf == NULL || keyBufLen == 0) { ret = BAD_FUNC_ARG; } @@ -412,20 +416,20 @@ WOLFSSL_LOCAL int tsip_Tls13GenEccKeyPair(WOLFSSL* ssl, KeyShareEntry* kse) } } - if (ret != 0) { - if (kse->key != NULL) + if ((ret != 0) && (ret != CRYPTOCB_UNAVAILABLE)) { + if (kse->key != NULL) { XFREE(kse->key, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); - if (kse->pubKey != NULL) + kse->key = NULL; + } + if (kse->pubKey != NULL) { XFREE(kse->pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); + kse->pubKey = NULL; + } } WOLFSSL_LEAVE("tsip_Tls13GenEccKeyPair", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ - - -#if defined(WOLFSSL_TLS13) /* generate shared secret(pre-master secret) * get peer's raw ECDHE public key from KeyShareEntry. * The pre-master secret generated by TSIP is stored into @@ -514,11 +518,7 @@ WOLFSSL_LOCAL int tsip_Tls13GenSharedSecret(struct WOLFSSL* ssl, WOLFSSL_LEAVE("tsip_Tls13GenSharedSecret", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ - - -#if defined(WOLFSSL_TLS13) WOLFSSL_LOCAL int tsip_Tls13DeriveEarlySecret(struct WOLFSSL* ssl) { int ret = 0; @@ -543,11 +543,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveEarlySecret(struct WOLFSSL* ssl) WOLFSSL_LEAVE("tsip_Tls13DeriveEarlySecret", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ - - -#if defined(WOLFSSL_TLS13) /* derive handshake secret. * get pre-master secret stored in TsipUserCtx.sharedSecret13Idx. * Derived handshake secret is stored into TsipUserCtx.handshakeSecret13Idx @@ -621,11 +617,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveHandshakeSecret(struct WOLFSSL* ssl) WOLFSSL_LEAVE("tsip_Tls13DeriveHandshakeSecret", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ - - -#if defined(WOLFSSL_TLS13) static int tsipTls13DeriveClientHandshakeKeys(struct WOLFSSL* ssl) { int ret = 0; @@ -705,11 +697,7 @@ static int tsipTls13DeriveClientHandshakeKeys(struct WOLFSSL* ssl) WOLFSSL_LEAVE("tsipTls13DeriveClientHandshakeKeys", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ - - -#if defined(WOLFSSL_TLS13) static int tsipTls13DeriveServerHandshakeKeys(struct WOLFSSL* ssl) { int ret = 0; @@ -789,11 +777,7 @@ static int tsipTls13DeriveServerHandshakeKeys(struct WOLFSSL* ssl) WOLFSSL_LEAVE("tsipTls13DeriveServerHandshakeKeys", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ - - -#if defined(WOLFSSL_TLS13) static int tsipTls13DeriveTrafficKeys(struct WOLFSSL* ssl) { int ret = 0; @@ -881,11 +865,7 @@ static int tsipTls13DeriveTrafficKeys(struct WOLFSSL* ssl) WOLFSSL_LEAVE("tsipTls13DeriveTrafficKeys", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ - - -#if defined(WOLFSSL_TLS13) static int tsipTls13UpdateClientTrafficKeys(struct WOLFSSL* ssl) { int ret = 0; @@ -953,11 +933,7 @@ static int tsipTls13UpdateClientTrafficKeys(struct WOLFSSL* ssl) WOLFSSL_LEAVE("tsipTls13UpdateClientTrafficKeys", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ - - -#if defined(WOLFSSL_TLS13) static int tsipTls13UpdateServerTrafficKeys(struct WOLFSSL* ssl) { int ret = 0; @@ -1025,11 +1001,7 @@ static int tsipTls13UpdateServerTrafficKeys(struct WOLFSSL* ssl) WOLFSSL_LEAVE("tsipTls13UpdateServerTrafficKeys", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ - - -#if defined(WOLFSSL_TLS13) /* Derive the keys for TLS v1.3. * * ssl The WOLFSSL object. @@ -1124,11 +1096,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveKeys(struct WOLFSSL* ssl, WOLFSSL_LEAVE("tsip_Tls13DeriveKeys", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ - - -#if defined(WOLFSSL_TLS13) WOLFSSL_LOCAL int tsip_Tls13DeriveMasterSecret(struct WOLFSSL* ssl) { int ret = 0; @@ -1198,11 +1166,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveMasterSecret(struct WOLFSSL* ssl) WOLFSSL_LEAVE("tsip_Tls13DeriveMasterSecret", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ - - -#if defined(WOLFSSL_TLS13) /* verify handshake * ssl WOLFSSL object * hash buffer holding decrypted finished message content from server. @@ -1288,11 +1252,7 @@ static int tsipTls13VerifyHandshake(struct WOLFSSL* ssl, WOLFSSL_LEAVE("tsipTls13VerifyHandshake", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ - - -#if defined(WOLFSSL_TLS13) /* handles finished message from server. * verify hmac in the message. Also output verify data to * TsipUserCtx.verifyDataIdx, which is used for deriving master secret. @@ -1334,11 +1294,7 @@ WOLFSSL_LOCAL int tsip_Tls13HandleFinished( WOLFSSL_LEAVE("tsip_Tls13HandleFinished", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ - - -#if defined(WOLFSSL_TLS13) /* Build TLS v1.3 Message and make it encrypted with AEAD algorithm. * TSIP supports AES-GCM and AES-CCM. * ssl The WOLFSSL object. @@ -1434,11 +1390,7 @@ WOLFSSL_LOCAL int tsip_Tls13BuildMessage(struct WOLFSSL* ssl, WOLFSSL_LEAVE("tsip_Tls13BuildMessage", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ - - -#if defined(WOLFSSL_TLS13) /* Send finished message to the server. * * ssl WOLFSSL object @@ -1501,9 +1453,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendFinished( WOLFSSL_LEAVE("tsip_Tls13SendFinished", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ -#if defined(WOLFSSL_TLS13) /* Parse and handle a TLS v1.3 CertificateVerify message sent from a server. * * ssl WOLFSSL object @@ -1644,9 +1594,7 @@ WOLFSSL_LOCAL int tsip_Tls13CertificateVerify(struct WOLFSSL* ssl, WOLFSSL_LEAVE("tsip_Tls13CertificateVerify", ret); return ret; } -#endif /* WOLFSSL_TLS13 */ -#if defined(WOLFSSL_TLS13) /* Send the TLS v1.3 CertificateVerify message. A part of the message is * processed by TSIP for acceleration. * @@ -1740,7 +1688,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl) } } else { - if (!tuc->ClientEccP256PrivKey_set) { + if (!tuc->ClientEccPrivKey_set) { ret = NO_PRIVATE_KEY; } } @@ -1781,7 +1729,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl) } else { err = R_TSIP_Tls13CertificateVerifyGenerate( - (uint32_t*)&(tuc->EcdsaP256PrivateKeyIdx), + (uint32_t*)&(tuc->EcdsaPrivateKeyIdx), TSIP_TLS13_SIGNATURE_SCHEME_ECDSA_SECP256R1_SHA256, hash, message + HANDSHAKE_HEADER_SZ, @@ -1817,7 +1765,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl) } else { #if defined(WOLFSSL_CHECK_SIG_FAULTS) - if (!tuc->ClientEccP256PubKey_set) { + if (!tuc->ClientEccPubKey_set) { ret = NO_PRIVATE_KEY; } #endif /* WOLFSSL_CHECK_SIG_FAULTS */ @@ -1886,7 +1834,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl) err = R_TSIP_EcdsaP256SignatureVerification( &ecdsa_sig, &ecdsa_hash, - &tuc->EcdsaP256PublicKeyIdx); + &tuc->EcdsaPublicKeyIdx); WOLFSSL_MSG("Perform self-verify for ecc signature"); #endif /* WOLFSSL_CHECK_SIG_FAULTS */ } @@ -1927,6 +1875,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl) #endif /* WOLFSSL_TLS13 */ #endif /* WOLFSSL_RENESAS_TSIP_TLS */ + #if defined(WOLFSSL_RENESAS_TSIP_TLS) && (WOLFSSL_RENESAS_TSIP_VER >=109) static uint32_t GetTsipCipherSuite( @@ -2072,7 +2021,7 @@ static int tsip_ServerKeyExVerify( WOLFSSL_MSG("Failed to lock tsip hw"); } - XFREE(peerkey, 0, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(peerkey, NULL, DYNAMIC_TYPE_TMP_BUFFER); WOLFSSL_LEAVE("tsip_ServerKeyExVerify", ret); return ret; @@ -2145,7 +2094,7 @@ int wc_tsip_EccVerify( return CRYPTOCB_UNAVAILABLE; } - /* concatenate r and s parts of the signature so that TSIP can handle it*/ + /* concatenate r and s parts of the signature so that TSIP can handle it */ /* r */ if (sig[offset] == 0x20) { XMEMCPY(sigforSCE, &sig[offset+1], rs_size); @@ -2346,8 +2295,10 @@ static byte _tls2tsipdef(byte cipher) * The target key should be set with tsip_use_PrivateKey_buffer in advance. * Acceptable key types are: * TSIP_KEY_TYPE_RSA2048 rsa 2048 bit key - * TSIP_KEY_TYPE_RSA4096 rsa 4096 bit key(Not supported as of now) + * TSIP_KEY_TYPE_RSA3072 rsa 3072 bit key + * TSIP_KEY_TYPE_RSA4096 rsa 4096 bit key * TSIP_KEY_TYPE_ECDSAP256 ecdsa p256r1 key + * TSIP_KEY_TYPE_ECDSAP384 ecdsa p384r1 key */ static int tsipImportPrivateKey(TsipUserCtx* tuc, int keyType) { @@ -2403,12 +2354,12 @@ static int tsipImportPrivateKey(TsipUserCtx* tuc, int keyType) #if defined(HAVE_ECC) case TSIP_KEY_TYPE_ECDSAP256: - tuc->ClientEccP256PrivKey_set = 0; + tuc->ClientEccPrivKey_set = 0; err = R_TSIP_GenerateEccP256PrivateKeyIndex( provisioning_key, iv, (uint8_t*)encPrivKey, - &(tuc->EcdsaP256PrivateKeyIdx)); + &(tuc->EcdsaPrivateKeyIdx)); if (err == TSIP_SUCCESS) { - tuc->ClientEccP256PrivKey_set = 1; + tuc->ClientEccPrivKey_set = 1; } else { ret = WC_HW_E; @@ -2436,8 +2387,10 @@ static int tsipImportPrivateKey(TsipUserCtx* tuc, int keyType) * The target key should be set with tsip_use_PublicKey_buffer in advance. * Acceptable key types are: * TSIP_KEY_TYPE_RSA2048 rsa 2048 bit key - * TSIP_KEY_TYPE_RSA4096 rsa 4096 bit key(Not supported as of now) + * TSIP_KEY_TYPE_RSA3072 rsa 3072 bit key + * TSIP_KEY_TYPE_RSA4096 rsa 4096 bit key * TSIP_KEY_TYPE_ECDSAP256 ecdsa p256r1 key + * TSIP_KEY_TYPE_ECDSAP384 ecdsa p384r1 key */ WOLFSSL_LOCAL int tsipImportPublicKey(TsipUserCtx* tuc, int keyType) { @@ -2468,7 +2421,7 @@ WOLFSSL_LOCAL int tsipImportPublicKey(TsipUserCtx* tuc, int keyType) } if ((ret = tsip_hw_lock()) == 0) { - switch(keyType) { + switch (keyType) { #if !defined(NO_RSA) case TSIP_KEY_TYPE_RSA2048: @@ -2479,11 +2432,11 @@ WOLFSSL_LOCAL int tsipImportPublicKey(TsipUserCtx* tuc, int keyType) XFREE(tuc->rsa2048pub_keyIdx, NULL, DYNAMIC_TYPE_RSA_BUFFER); } - + tuc->keyflgs_crypt.bits.rsapub2048_key_set = 0; tuc->rsa2048pub_keyIdx = - (tsip_rsa2048_public_key_index_t*)XMALLOC( - sizeof(tsip_rsa2048_public_key_index_t), NULL, - DYNAMIC_TYPE_RSA_BUFFER); + (tsip_rsa2048_public_key_index_t*)XMALLOC( + sizeof(tsip_rsa2048_public_key_index_t), NULL, + DYNAMIC_TYPE_RSA_BUFFER); if (tuc->rsa2048pub_keyIdx == NULL) { return MEMORY_E; } @@ -2507,25 +2460,47 @@ WOLFSSL_LOCAL int tsipImportPublicKey(TsipUserCtx* tuc, int keyType) ret = WC_HW_E; } break; - #endif - #if !defined(NO_RSA) case TSIP_KEY_TYPE_RSA4096: /* not supported as of TSIPv1.15 */ ret = CRYPTOCB_UNAVAILABLE; break; - #endif + #endif /* !NO_RSA */ - #if defined(HAVE_ECC) && \ - defined(WOLFSSL_RENESAS_TSIP_TLS) + #if defined(HAVE_ECC) case TSIP_KEY_TYPE_ECDSAP256: - - tuc->ClientEccP256PubKey_set = 0; - err = R_TSIP_GenerateEccP256PublicKeyIndex( + case TSIP_KEY_TYPE_ECDSAP384: + #if defined(WOLFSSL_RENESAS_TSIP_TLS) + tuc->ClientEccPubKey_set = 0; + #elif defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) + tuc->keyflgs_crypt.bits.eccpub_key_set = 0; + #endif + if (keyType == TSIP_KEY_TYPE_ECDSAP256) { + err = R_TSIP_GenerateEccP256PublicKeyIndex( + provisioning_key, iv, (uint8_t*)encPubKey, + #if defined(WOLFSSL_RENESAS_TSIP_TLS) + &(tuc->EcdsaPublicKeyIdx) + #elif defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) + &tuc->eccpub_keyIdx + #endif + ); + } + else if (keyType == TSIP_KEY_TYPE_ECDSAP384) { + err = R_TSIP_GenerateEccP384PublicKeyIndex( provisioning_key, iv, (uint8_t*)encPubKey, - &(tuc->EcdsaP256PublicKeyIdx)); + #if defined(WOLFSSL_RENESAS_TSIP_TLS) + &(tuc->EcdsaPublicKeyIdx) + #elif defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) + &tuc->eccpub_keyIdx + #endif + ); + } if (err == TSIP_SUCCESS) { - tuc->ClientEccP256PubKey_set = 1; + #if defined(WOLFSSL_RENESAS_TSIP_TLS) + tuc->ClientEccPubKey_set = 1; + #elif defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) + tuc->keyflgs_crypt.bits.eccpub_key_set = 1; + #endif } else { ret = WC_HW_E; @@ -2545,41 +2520,7 @@ WOLFSSL_LOCAL int tsipImportPublicKey(TsipUserCtx* tuc, int keyType) WOLFSSL_LEAVE("tsipImportPublicKey", ret); return ret; } -/* -* lock hw engine. -* this should be called before using engine. -*/ -WOLFSSL_LOCAL int tsip_hw_lock(void) -{ - int ret = 0; - - if (tsip_CryptHwMutexInit_ == 0) { - - ret = tsip_CryptHwMutexInit(&tsip_mutex); - - if (ret == 0) { - tsip_CryptHwMutexInit_ = 1; - } - else { - WOLFSSL_MSG(" mutex initialization failed."); - return -1; - } - } - if (tsip_CryptHwMutexLock(&tsip_mutex) != 0) { - /* this should not happens */ - return -1; - } - - return ret; -} -/* -* release hw engine -*/ -WOLFSSL_LOCAL void tsip_hw_unlock(void) -{ - tsip_CryptHwMutexUnLock(&tsip_mutex); -} #if defined(WOLFSSL_RENESAS_TSIP_TLS) /* check if tsip tls functions can be used for the cipher */ /* return :1 when tsip can be used , 0 not be used. */ @@ -2678,6 +2619,41 @@ int tsip_usable(const WOLFSSL *ssl, uint8_t session_key_generated) } #endif /* WOLFSSL_RENESAS_TSIP_TLS */ +/* +* lock hw engine. +* this should be called before using engine. +*/ +WOLFSSL_LOCAL int tsip_hw_lock(void) +{ + int ret = 0; + + if (tsip_CryptHwMutexInit_ == 0) { + + ret = tsip_CryptHwMutexInit(&tsip_mutex); + + if (ret == 0) { + tsip_CryptHwMutexInit_ = 1; + } + else { + WOLFSSL_MSG(" mutex initialization failed."); + return -1; + } + } + if (tsip_CryptHwMutexLock(&tsip_mutex) != 0) { + /* this should not happens */ + return -1; + } + + return ret; +} + +/* +* release hw engine +*/ +WOLFSSL_LOCAL void tsip_hw_unlock(void) +{ + tsip_CryptHwMutexUnLock(&tsip_mutex); +} /* open TSIP driver * return 0 on success. @@ -2696,6 +2672,7 @@ WOLFSSL_LOCAL int tsip_Open(void) if (ret != TSIP_SUCCESS) { WOLFSSL_MSG("RENESAS TSIP Open failed"); } + #if defined(WOLFSSL_RENESAS_TSIP_TLS) if (ret == TSIP_SUCCESS && g_user_key_info.encrypted_user_tls_key) { @@ -2722,11 +2699,13 @@ WOLFSSL_LOCAL int tsip_Open(void) if (ret != TSIP_SUCCESS) { WOLFSSL_MSG("R_TSIP_(Re)Open: NG"); } - /* init vars */ + + /* init vars */ g_CAscm_Idx = (uint32_t)-1; } } #endif + #elif defined(WOLFSSL_RENESAS_TSIP) && (WOLFSSL_RENESAS_TSIP_VER>=106) ret = R_TSIP_Open((uint32_t*)s_flash, s_inst1, s_inst2); @@ -2756,7 +2735,8 @@ WOLFSSL_LOCAL int tsip_Open(void) if (ret != TSIP_SUCCESS) { WOLFSSL_MSG("R_TSIP_(Re)Open failed"); } - /* init vars */ + + /* init vars */ g_CAscm_Idx = (uint32_t)-1; } } @@ -2832,7 +2812,8 @@ void tsip_inform_user_keys_ex( word32 encrypted_user_tls_key_type) { WOLFSSL_ENTER("tsip_inform_user_keys_ex"); - ForceZero(&g_user_key_info, sizeof(g_user_key_info)); + + XMEMSET(&g_user_key_info, 0, sizeof(g_user_key_info)); g_user_key_info.encrypted_provisioning_key = NULL; g_user_key_info.iv = NULL; @@ -3690,7 +3671,6 @@ WOLFSSL_LOCAL int tsip_SignRsaPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc) ret = tsipImportPrivateKey(tuc, tuc->wrappedKeyType); } - if (ret == 0) { if (ssl->options.hashAlgo == md5_mac) tsip_hash_type = R_TSIP_RSA_HASH_MD5; @@ -3705,11 +3685,11 @@ WOLFSSL_LOCAL int tsip_SignRsaPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc) (void)ssl; if (ret == 0) { - if (tuc->sing_hash_type == md5_mac) + if (tuc->sign_hash_type == md5_mac) tsip_hash_type = R_TSIP_RSA_HASH_MD5; - else if (tuc->sing_hash_type == sha_mac) + else if (tuc->sign_hash_type == sha_mac) tsip_hash_type = R_TSIP_RSA_HASH_SHA1; - else if (tuc->sing_hash_type == sha256_mac) + else if (tuc->sign_hash_type == sha256_mac) tsip_hash_type = R_TSIP_RSA_HASH_SHA256; else ret = CRYPTOCB_UNAVAILABLE; @@ -3717,15 +3697,13 @@ WOLFSSL_LOCAL int tsip_SignRsaPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc) switch (tuc->wrappedKeyType) { case TSIP_KEY_TYPE_RSA1024: - if (tuc->keyflgs_crypt.bits.rsapri1024_key_set != 1) - { - WOLFSSL_MSG("tsip rsa private key 2048 not set"); + if (tuc->keyflgs_crypt.bits.rsapri1024_key_set != 1) { + WOLFSSL_MSG("tsip rsa private key 1024 not set"); ret = CRYPTOCB_UNAVAILABLE; } break; case TSIP_KEY_TYPE_RSA2048: - if (tuc->keyflgs_crypt.bits.rsapri2048_key_set != 1) - { + if (tuc->keyflgs_crypt.bits.rsapri2048_key_set != 1) { WOLFSSL_MSG("tsip rsa private key 2048 not set"); ret = CRYPTOCB_UNAVAILABLE; } @@ -3735,7 +3713,6 @@ WOLFSSL_LOCAL int tsip_SignRsaPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc) ret = CRYPTOCB_UNAVAILABLE; break; } - #endif if (ret == 0) { @@ -3902,7 +3879,8 @@ WOLFSSL_LOCAL int tsip_VerifyRsaPkcsCb( } #endif /* !NO_RSA && TSIP_TLS */ -#if defined(HAVE_ECC) && defined(WOLFSSL_RENESAS_TSIP_TLS) +#if defined(HAVE_ECC) +#if defined(WOLFSSL_RENESAS_TSIP_TLS) /* Perform signing with the client's ECC private key on hash value of messages * exchanged with server. * @@ -3922,7 +3900,7 @@ WOLFSSL_LOCAL int tsip_SignEcdsa(wc_CryptoInfo* info, TsipUserCtx* tuc) { int ret = 0; e_tsip_err_t err = TSIP_SUCCESS; - tsip_rsa_byte_data_t hashData, sigData; + tsip_ecdsa_byte_data_t hashData, sigData; byte offsetForWork; byte* out = NULL; byte* sig = NULL; @@ -3961,7 +3939,7 @@ WOLFSSL_LOCAL int tsip_SignEcdsa(wc_CryptoInfo* info, TsipUserCtx* tuc) if ((ret = tsip_hw_lock()) == 0) { switch (tuc->wrappedKeyType) { - #if defined(HAVE_ECC) + #if !defined(NO_ECC256) case TSIP_KEY_TYPE_ECDSAP256: offsetForWork = R_TSIP_ECDSA_DATA_BYTE_SIZE + 32; if (*(info->pk.eccsign.outlen) < @@ -3974,7 +3952,7 @@ WOLFSSL_LOCAL int tsip_SignEcdsa(wc_CryptoInfo* info, TsipUserCtx* tuc) offsetForWork; err = R_TSIP_EcdsaP256SignatureGenerate( &hashData, &sigData, - &tuc->EcdsaP256PrivateKeyIdx); + &tuc->EcdsaPrivateKeyIdx); if (err != TSIP_SUCCESS) { ret = WC_HW_E; break; @@ -4012,16 +3990,6 @@ WOLFSSL_LOCAL int tsip_SignEcdsa(wc_CryptoInfo* info, TsipUserCtx* tuc) break; #endif - #if defined(HAVE_ECC192) - case TSIP_KEY_TYPE_ECDSAP192: - ret = CRYPTOCB_UNAVAILABLE; - break; - #endif - #if defined(HAVE_ECC224) - case TSIP_KEY_TYPE_ECDSAP224: - ret = CRYPTOCB_UNAVAILABLE; - break; - #endif #if defined(HAVE_ECC384) case TSIP_KEY_TYPE_ECDSAP384: ret = CRYPTOCB_UNAVAILABLE; @@ -4042,7 +4010,114 @@ WOLFSSL_LOCAL int tsip_SignEcdsa(wc_CryptoInfo* info, TsipUserCtx* tuc) WOLFSSL_LEAVE("tsip_SignEcdsa", ret); return ret; } -#endif /* HAVE_ECC && TSIP_TLS */ +#endif /* WOLFSSL_RENESAS_TSIP_TLS */ + +#if defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) +/* zero pad or truncate hash */ +static int tsip_HashPad(int curveSz, uint8_t* hash, + const uint8_t* hashIn, int hashSz) +{ + if (hashSz > curveSz) + hashSz = curveSz; + XMEMCPY(hash + (curveSz - hashSz), hashIn, hashSz); + return curveSz; +} + +/* Perform verify with the wrapped public key, provided hash and signature r+s + * + * parameters + * info->pk.eccverify.in : the buffer holding hash value of messages + * info->pk.eccverify.inlen : hash data size + * info->pk.eccverify.out : the buffer where the signature data is output to + * info->pk.eccverify.outlen: the length of the buffer pk.eccsign.out + * tuc: the pointer to the TsipUserCtx structure + * returns + * 0 on success, CRYPTOCB_UNAVAILABLE on unsupported key type specified. + */ +WOLFSSL_LOCAL int tsip_VerifyEcdsa(wc_CryptoInfo* info, TsipUserCtx* tuc) +{ + int ret = 0; + e_tsip_err_t err = TSIP_SUCCESS; + tsip_ecdsa_byte_data_t hashData, sigData; + /* hard coding largest digest size, since WC_MAX_DIGEST_SZ could be 32 + * if using SHA2-256 with ECDSA SECP384R1 */ + uint8_t hash[TSIP_MAX_ECC_BYTES]; + + WOLFSSL_ENTER("tsip_VerifyEcdsa"); + + if (info == NULL || tuc == NULL) { + ret = CRYPTOCB_UNAVAILABLE; + } + + XMEMSET(hash, 0, sizeof(hash)); + + if (ret == 0) { + /* import public key_index from wrapped key */ + ret = tsipImportPublicKey(tuc, tuc->wrappedKeyType); + } + + if (ret == 0) { + int curveSz = info->pk.eccverify.key->dp->size; + hashData.pdata = (uint8_t*)hash; + hashData.data_type = tuc->keyflgs_crypt.bits.message_type; + sigData.pdata = (uint8_t*)info->pk.eccverify.sig; + sigData.data_length = info->pk.eccverify.siglen; + + if ((ret = tsip_hw_lock()) == 0) { + switch (tuc->wrappedKeyType) { + #if !defined(NO_ECC256) + case TSIP_KEY_TYPE_ECDSAP256: + /* zero pad or truncate */ + hashData.data_length = tsip_HashPad(curveSz, + hash, info->pk.eccverify.hash, + info->pk.eccverify.hashlen); + + err = R_TSIP_EcdsaP256SignatureVerification(&sigData, + &hashData, &tuc->eccpub_keyIdx); + if (err == TSIP_SUCCESS) { + *info->pk.eccverify.res = 1; /* success */ + } + else { + ret = WC_HW_E; + } + break; + break; + #endif + + #if defined(HAVE_ECC384) + case TSIP_KEY_TYPE_ECDSAP384: + /* zero pad or truncate */ + hashData.data_length = tsip_HashPad(curveSz, + hash, info->pk.eccverify.hash, + info->pk.eccverify.hashlen); + + err = R_TSIP_EcdsaP384SignatureVerification(&sigData, + &hashData, &tuc->eccpub_keyIdx); + if (err == TSIP_SUCCESS) { + *info->pk.eccverify.res = 1; /* success */ + } + else { + ret = WC_HW_E; + } + break; + #endif + + default: + WOLFSSL_MSG("ECDSA public key size not available"); + ret = CRYPTOCB_UNAVAILABLE; + break; + } + tsip_hw_unlock(); + } + else { + WOLFSSL_MSG("mutex locking error"); + } + } + WOLFSSL_LEAVE("tsip_VerifyEcdsa", ret); + return ret; +} +#endif /* WOLFSSL_RENESAS_TSIP_CRYPTONLY */ +#endif /* HAVE_ECC */ #ifdef WOLFSSL_RENESAS_TSIP_CRYPT_DEBUG diff --git a/wolfcrypt/src/port/af_alg/afalg_aes.c b/wolfcrypt/src/port/af_alg/afalg_aes.c index 27ee88f610..3fd9023604 100644 --- a/wolfcrypt/src/port/af_alg/afalg_aes.c +++ b/wolfcrypt/src/port/af_alg/afalg_aes.c @@ -1,6 +1,6 @@ /* afalg_aes.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/af_alg/afalg_hash.c b/wolfcrypt/src/port/af_alg/afalg_hash.c index ee5599480f..33a7ad3efb 100644 --- a/wolfcrypt/src/port/af_alg/afalg_hash.c +++ b/wolfcrypt/src/port/af_alg/afalg_hash.c @@ -1,6 +1,6 @@ /* afalg_hash.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/af_alg/wc_afalg.c b/wolfcrypt/src/port/af_alg/wc_afalg.c index b6671f7b85..b278d1f7d3 100644 --- a/wolfcrypt/src/port/af_alg/wc_afalg.c +++ b/wolfcrypt/src/port/af_alg/wc_afalg.c @@ -1,6 +1,6 @@ /* wc_afalg.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/aria/aria-crypt.c b/wolfcrypt/src/port/aria/aria-crypt.c index d310c6eb1b..0dd20b0c87 100644 --- a/wolfcrypt/src/port/aria/aria-crypt.c +++ b/wolfcrypt/src/port/aria/aria-crypt.c @@ -1,6 +1,6 @@ /* aria-crypt.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/aria/aria-cryptocb.c b/wolfcrypt/src/port/aria/aria-cryptocb.c index 906a07a739..cd9ed74376 100644 --- a/wolfcrypt/src/port/aria/aria-cryptocb.c +++ b/wolfcrypt/src/port/aria/aria-cryptocb.c @@ -1,6 +1,6 @@ /* aria-cryptocb.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-32-aes-asm.S b/wolfcrypt/src/port/arm/armv8-32-aes-asm.S index 99812b3dbf..345f19408e 100644 --- a/wolfcrypt/src/port/arm/armv8-32-aes-asm.S +++ b/wolfcrypt/src/port/arm/armv8-32-aes-asm.S @@ -1,6 +1,6 @@ /* armv8-32-aes-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-32-aes-asm_c.c b/wolfcrypt/src/port/arm/armv8-32-aes-asm_c.c index daaf1235d6..f8ba89ac09 100644 --- a/wolfcrypt/src/port/arm/armv8-32-aes-asm_c.c +++ b/wolfcrypt/src/port/arm/armv8-32-aes-asm_c.c @@ -1,6 +1,6 @@ /* armv8-32-aes-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-32-curve25519.S b/wolfcrypt/src/port/arm/armv8-32-curve25519.S index a09996238d..69cb22e4e4 100644 --- a/wolfcrypt/src/port/arm/armv8-32-curve25519.S +++ b/wolfcrypt/src/port/arm/armv8-32-curve25519.S @@ -1,6 +1,6 @@ /* armv8-32-curve25519 * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-32-curve25519_c.c b/wolfcrypt/src/port/arm/armv8-32-curve25519_c.c index 2b97581d82..09ef2eb439 100644 --- a/wolfcrypt/src/port/arm/armv8-32-curve25519_c.c +++ b/wolfcrypt/src/port/arm/armv8-32-curve25519_c.c @@ -1,6 +1,6 @@ /* armv8-32-curve25519 * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-32-sha256-asm.S b/wolfcrypt/src/port/arm/armv8-32-sha256-asm.S index 381cd25584..14a1ec48f5 100644 --- a/wolfcrypt/src/port/arm/armv8-32-sha256-asm.S +++ b/wolfcrypt/src/port/arm/armv8-32-sha256-asm.S @@ -1,6 +1,6 @@ /* armv8-32-sha256-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-32-sha256-asm_c.c b/wolfcrypt/src/port/arm/armv8-32-sha256-asm_c.c index a10241f814..391075340e 100644 --- a/wolfcrypt/src/port/arm/armv8-32-sha256-asm_c.c +++ b/wolfcrypt/src/port/arm/armv8-32-sha256-asm_c.c @@ -1,6 +1,6 @@ /* armv8-32-sha256-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-32-sha3-asm.S b/wolfcrypt/src/port/arm/armv8-32-sha3-asm.S index 2ab9f93576..76629726f7 100644 --- a/wolfcrypt/src/port/arm/armv8-32-sha3-asm.S +++ b/wolfcrypt/src/port/arm/armv8-32-sha3-asm.S @@ -1,6 +1,6 @@ /* armv8-32-sha3-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-32-sha3-asm_c.c b/wolfcrypt/src/port/arm/armv8-32-sha3-asm_c.c index 21b968580e..6d2efa1b0b 100644 --- a/wolfcrypt/src/port/arm/armv8-32-sha3-asm_c.c +++ b/wolfcrypt/src/port/arm/armv8-32-sha3-asm_c.c @@ -1,6 +1,6 @@ /* armv8-32-sha3-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-32-sha512-asm.S b/wolfcrypt/src/port/arm/armv8-32-sha512-asm.S index 48e7ec4264..4dbfeafad9 100644 --- a/wolfcrypt/src/port/arm/armv8-32-sha512-asm.S +++ b/wolfcrypt/src/port/arm/armv8-32-sha512-asm.S @@ -1,6 +1,6 @@ /* armv8-32-sha512-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-32-sha512-asm_c.c b/wolfcrypt/src/port/arm/armv8-32-sha512-asm_c.c index cf29ab59ff..b59668d12a 100644 --- a/wolfcrypt/src/port/arm/armv8-32-sha512-asm_c.c +++ b/wolfcrypt/src/port/arm/armv8-32-sha512-asm_c.c @@ -1,6 +1,6 @@ /* armv8-32-sha512-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-aes.c b/wolfcrypt/src/port/arm/armv8-aes.c index b40dd7b558..4a3e3dc24f 100644 --- a/wolfcrypt/src/port/arm/armv8-aes.c +++ b/wolfcrypt/src/port/arm/armv8-aes.c @@ -1,6 +1,6 @@ /* armv8-aes.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-chacha.c b/wolfcrypt/src/port/arm/armv8-chacha.c index 18dd9e596e..c7de0a265b 100644 --- a/wolfcrypt/src/port/arm/armv8-chacha.c +++ b/wolfcrypt/src/port/arm/armv8-chacha.c @@ -1,6 +1,6 @@ /* armv8-chacha.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-curve25519.S b/wolfcrypt/src/port/arm/armv8-curve25519.S index 3f04ce87ad..cf20f60809 100644 --- a/wolfcrypt/src/port/arm/armv8-curve25519.S +++ b/wolfcrypt/src/port/arm/armv8-curve25519.S @@ -1,6 +1,6 @@ /* armv8-curve25519 * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-curve25519_c.c b/wolfcrypt/src/port/arm/armv8-curve25519_c.c index c9a98222e3..6af75a632b 100644 --- a/wolfcrypt/src/port/arm/armv8-curve25519_c.c +++ b/wolfcrypt/src/port/arm/armv8-curve25519_c.c @@ -1,6 +1,6 @@ /* armv8-curve25519 * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-poly1305.c b/wolfcrypt/src/port/arm/armv8-poly1305.c index 07eecf42ec..49eec4d04c 100644 --- a/wolfcrypt/src/port/arm/armv8-poly1305.c +++ b/wolfcrypt/src/port/arm/armv8-poly1305.c @@ -1,6 +1,6 @@ /* armv8-poly1305.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-sha256.c b/wolfcrypt/src/port/arm/armv8-sha256.c index 5555aa8e2a..45d4292a54 100644 --- a/wolfcrypt/src/port/arm/armv8-sha256.c +++ b/wolfcrypt/src/port/arm/armv8-sha256.c @@ -1,6 +1,6 @@ /* armv8-sha256.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-sha3-asm.S b/wolfcrypt/src/port/arm/armv8-sha3-asm.S index 209ee0cf48..1652f41b4c 100644 --- a/wolfcrypt/src/port/arm/armv8-sha3-asm.S +++ b/wolfcrypt/src/port/arm/armv8-sha3-asm.S @@ -1,6 +1,6 @@ /* armv8-sha3-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-sha3-asm_c.c b/wolfcrypt/src/port/arm/armv8-sha3-asm_c.c index 1f2d040849..bb4114d42b 100644 --- a/wolfcrypt/src/port/arm/armv8-sha3-asm_c.c +++ b/wolfcrypt/src/port/arm/armv8-sha3-asm_c.c @@ -1,6 +1,6 @@ /* armv8-sha3-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-sha512-asm.S b/wolfcrypt/src/port/arm/armv8-sha512-asm.S index 3ff015800b..5ff72c37b7 100644 --- a/wolfcrypt/src/port/arm/armv8-sha512-asm.S +++ b/wolfcrypt/src/port/arm/armv8-sha512-asm.S @@ -1,6 +1,6 @@ /* armv8-sha512-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-sha512-asm_c.c b/wolfcrypt/src/port/arm/armv8-sha512-asm_c.c index 027dc8a133..ba7dc82e06 100644 --- a/wolfcrypt/src/port/arm/armv8-sha512-asm_c.c +++ b/wolfcrypt/src/port/arm/armv8-sha512-asm_c.c @@ -1,6 +1,6 @@ /* armv8-sha512-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-sha512.c b/wolfcrypt/src/port/arm/armv8-sha512.c index 3eaefff831..7ac9eb9833 100644 --- a/wolfcrypt/src/port/arm/armv8-sha512.c +++ b/wolfcrypt/src/port/arm/armv8-sha512.c @@ -1,6 +1,6 @@ /* sha512.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/cryptoCell.c b/wolfcrypt/src/port/arm/cryptoCell.c index 1c73349e11..0a9a7cdde5 100644 --- a/wolfcrypt/src/port/arm/cryptoCell.c +++ b/wolfcrypt/src/port/arm/cryptoCell.c @@ -1,6 +1,6 @@ /* cryptoCell.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/cryptoCellHash.c b/wolfcrypt/src/port/arm/cryptoCellHash.c index cf567c2870..bbcd208b05 100644 --- a/wolfcrypt/src/port/arm/cryptoCellHash.c +++ b/wolfcrypt/src/port/arm/cryptoCellHash.c @@ -1,6 +1,6 @@ /* cryptoCellHash.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/thumb2-aes-asm.S b/wolfcrypt/src/port/arm/thumb2-aes-asm.S index 68695a7ea8..34f860884c 100644 --- a/wolfcrypt/src/port/arm/thumb2-aes-asm.S +++ b/wolfcrypt/src/port/arm/thumb2-aes-asm.S @@ -1,6 +1,6 @@ /* thumb2-aes-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -670,7 +670,7 @@ L_AES_invert_key_mix_loop: EOR r8, r8, r9, ROR #24 STR r8, [r0], #4 SUBS r11, r11, #0x1 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_invert_key_mix_loop #else BNE.W L_AES_invert_key_mix_loop @@ -703,13 +703,13 @@ AES_set_encrypt_key: LDR r10, L_AES_Thumb2_te ADR lr, L_AES_Thumb2_rcon CMP r1, #0x80 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_set_encrypt_key_start_128 #else BEQ.W L_AES_set_encrypt_key_start_128 #endif CMP r1, #0xc0 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_set_encrypt_key_start_192 #else BEQ.W L_AES_set_encrypt_key_start_192 @@ -1026,7 +1026,7 @@ L_AES_encrypt_block_nr: EOR r6, r6, r10 EOR r7, r7, r11 SUBS r1, r1, #0x1 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_encrypt_block_nr #else BNE.W L_AES_encrypt_block_nr @@ -1154,13 +1154,13 @@ AES_ECB_encrypt: LDR r12, [sp, #36] PUSH {r3} CMP r12, #0xa -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_ECB_encrypt_start_block_128 #else BEQ.W L_AES_ECB_encrypt_start_block_128 #endif CMP r12, #0xc -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_ECB_encrypt_start_block_192 #else BEQ.W L_AES_ECB_encrypt_start_block_192 @@ -1196,7 +1196,7 @@ L_AES_ECB_encrypt_loop_block_256: SUBS r2, r2, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_ECB_encrypt_loop_block_256 #else BNE.W L_AES_ECB_encrypt_loop_block_256 @@ -1238,7 +1238,7 @@ L_AES_ECB_encrypt_loop_block_192: SUBS r2, r2, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_ECB_encrypt_loop_block_192 #else BNE.W L_AES_ECB_encrypt_loop_block_192 @@ -1280,7 +1280,7 @@ L_AES_ECB_encrypt_loop_block_128: SUBS r2, r2, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_ECB_encrypt_loop_block_128 #else BNE.W L_AES_ECB_encrypt_loop_block_128 @@ -1305,13 +1305,13 @@ AES_CBC_encrypt: LDM r9, {r4, r5, r6, r7} PUSH {r3, r9} CMP r8, #0xa -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_CBC_encrypt_start_block_128 #else BEQ.W L_AES_CBC_encrypt_start_block_128 #endif CMP r8, #0xc -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_CBC_encrypt_start_block_192 #else BEQ.W L_AES_CBC_encrypt_start_block_192 @@ -1351,7 +1351,7 @@ L_AES_CBC_encrypt_loop_block_256: SUBS r2, r2, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_CBC_encrypt_loop_block_256 #else BNE.W L_AES_CBC_encrypt_loop_block_256 @@ -1397,7 +1397,7 @@ L_AES_CBC_encrypt_loop_block_192: SUBS r2, r2, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_CBC_encrypt_loop_block_192 #else BNE.W L_AES_CBC_encrypt_loop_block_192 @@ -1443,7 +1443,7 @@ L_AES_CBC_encrypt_loop_block_128: SUBS r2, r2, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_CBC_encrypt_loop_block_128 #else BNE.W L_AES_CBC_encrypt_loop_block_128 @@ -1474,13 +1474,13 @@ AES_CTR_encrypt: STM r8, {r4, r5, r6, r7} PUSH {r3, r8} CMP r12, #0xa -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_CTR_encrypt_start_block_128 #else BEQ.W L_AES_CTR_encrypt_start_block_128 #endif CMP r12, #0xc -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_CTR_encrypt_start_block_192 #else BEQ.W L_AES_CTR_encrypt_start_block_192 @@ -1524,12 +1524,12 @@ L_AES_CTR_encrypt_loop_block_256: SUBS r2, r2, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_CTR_encrypt_loop_block_256 #else BNE.W L_AES_CTR_encrypt_loop_block_256 #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) B L_AES_CTR_encrypt_end #else B.W L_AES_CTR_encrypt_end @@ -1574,12 +1574,12 @@ L_AES_CTR_encrypt_loop_block_192: SUBS r2, r2, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_CTR_encrypt_loop_block_192 #else BNE.W L_AES_CTR_encrypt_loop_block_192 #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) B L_AES_CTR_encrypt_end #else B.W L_AES_CTR_encrypt_end @@ -1624,7 +1624,7 @@ L_AES_CTR_encrypt_loop_block_128: SUBS r2, r2, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_CTR_encrypt_loop_block_128 #else BNE.W L_AES_CTR_encrypt_loop_block_128 @@ -1750,7 +1750,7 @@ L_AES_decrypt_block_nr: EOR r6, r6, r10 EOR r7, r7, r11 SUBS r1, r1, #0x1 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_decrypt_block_nr #else BNE.W L_AES_decrypt_block_nr @@ -2138,13 +2138,13 @@ AES_ECB_decrypt: MOV r12, r2 ADR r2, L_AES_Thumb2_td4 CMP r8, #0xa -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_ECB_decrypt_start_block_128 #else BEQ.W L_AES_ECB_decrypt_start_block_128 #endif CMP r8, #0xc -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_ECB_decrypt_start_block_192 #else BEQ.W L_AES_ECB_decrypt_start_block_192 @@ -2179,7 +2179,7 @@ L_AES_ECB_decrypt_loop_block_256: SUBS r12, r12, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_ECB_decrypt_loop_block_256 #else BNE.W L_AES_ECB_decrypt_loop_block_256 @@ -2220,7 +2220,7 @@ L_AES_ECB_decrypt_loop_block_192: SUBS r12, r12, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_ECB_decrypt_loop_block_192 #else BNE.W L_AES_ECB_decrypt_loop_block_192 @@ -2261,7 +2261,7 @@ L_AES_ECB_decrypt_loop_block_128: SUBS r12, r12, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_ECB_decrypt_loop_block_128 #else BNE.W L_AES_ECB_decrypt_loop_block_128 @@ -2286,13 +2286,13 @@ AES_CBC_decrypt: ADR r2, L_AES_Thumb2_td4 PUSH {r3, r4} CMP r8, #0xa -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_CBC_decrypt_loop_block_128 #else BEQ.W L_AES_CBC_decrypt_loop_block_128 #endif CMP r8, #0xc -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_CBC_decrypt_loop_block_192 #else BEQ.W L_AES_CBC_decrypt_loop_block_192 @@ -2337,7 +2337,7 @@ L_AES_CBC_decrypt_loop_block_256: SUBS r12, r12, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_CBC_decrypt_end_odd #else BEQ.W L_AES_CBC_decrypt_end_odd @@ -2382,12 +2382,12 @@ L_AES_CBC_decrypt_loop_block_256: SUBS r12, r12, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_CBC_decrypt_loop_block_256 #else BNE.W L_AES_CBC_decrypt_loop_block_256 #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) B L_AES_CBC_decrypt_end #else B.W L_AES_CBC_decrypt_end @@ -2432,7 +2432,7 @@ L_AES_CBC_decrypt_loop_block_192: SUBS r12, r12, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_CBC_decrypt_end_odd #else BEQ.W L_AES_CBC_decrypt_end_odd @@ -2477,12 +2477,12 @@ L_AES_CBC_decrypt_loop_block_192: SUBS r12, r12, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_CBC_decrypt_loop_block_192 #else BNE.W L_AES_CBC_decrypt_loop_block_192 #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) B L_AES_CBC_decrypt_end #else B.W L_AES_CBC_decrypt_end @@ -2527,7 +2527,7 @@ L_AES_CBC_decrypt_loop_block_128: SUBS r12, r12, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_CBC_decrypt_end_odd #else BEQ.W L_AES_CBC_decrypt_end_odd @@ -2572,7 +2572,7 @@ L_AES_CBC_decrypt_loop_block_128: SUBS r12, r12, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_CBC_decrypt_loop_block_128 #else BNE.W L_AES_CBC_decrypt_loop_block_128 @@ -3170,7 +3170,7 @@ L_GCM_gmult_len_start_block: POP {r3} SUBS r3, r3, #0x10 ADD r2, r2, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_GCM_gmult_len_start_block #else BNE.W L_GCM_gmult_len_start_block @@ -3202,13 +3202,13 @@ AES_GCM_encrypt: STM r8, {r4, r5, r6, r7} PUSH {r3, r8} CMP r12, #0xa -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_GCM_encrypt_start_block_128 #else BEQ.W L_AES_GCM_encrypt_start_block_128 #endif CMP r12, #0xc -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BEQ L_AES_GCM_encrypt_start_block_192 #else BEQ.W L_AES_GCM_encrypt_start_block_192 @@ -3249,12 +3249,12 @@ L_AES_GCM_encrypt_loop_block_256: SUBS r2, r2, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_GCM_encrypt_loop_block_256 #else BNE.W L_AES_GCM_encrypt_loop_block_256 #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) B L_AES_GCM_encrypt_end #else B.W L_AES_GCM_encrypt_end @@ -3296,12 +3296,12 @@ L_AES_GCM_encrypt_loop_block_192: SUBS r2, r2, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_GCM_encrypt_loop_block_192 #else BNE.W L_AES_GCM_encrypt_loop_block_192 #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) B L_AES_GCM_encrypt_end #else B.W L_AES_GCM_encrypt_end @@ -3343,7 +3343,7 @@ L_AES_GCM_encrypt_loop_block_128: SUBS r2, r2, #0x10 ADD lr, lr, #0x10 ADD r1, r1, #0x10 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_AES_GCM_encrypt_loop_block_128 #else BNE.W L_AES_GCM_encrypt_loop_block_128 diff --git a/wolfcrypt/src/port/arm/thumb2-aes-asm_c.c b/wolfcrypt/src/port/arm/thumb2-aes-asm_c.c index 399157589e..ddf9d11412 100644 --- a/wolfcrypt/src/port/arm/thumb2-aes-asm_c.c +++ b/wolfcrypt/src/port/arm/thumb2-aes-asm_c.c @@ -1,6 +1,6 @@ /* thumb2-aes-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -211,23 +211,33 @@ void AES_invert_key(unsigned char* ks, word32 rounds) "ADD r10, %[ks], %[rounds], LSL #4\n\t" "MOV r11, %[rounds]\n\t" "\n" - "L_AES_invert_key_loop%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_invert_key_loop:\n\t" +#else + "L_AES_invert_key_loop_%=:\n\t" +#endif "LDM %[ks], {r2, r3, r4, r5}\n\t" "LDM r10, {r6, r7, r8, r9}\n\t" "STM r10, {r2, r3, r4, r5}\n\t" "STM %[ks]!, {r6, r7, r8, r9}\n\t" "SUBS r11, r11, #0x2\n\t" "SUB r10, r10, #0x10\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_AES_invert_key_loop%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_invert_key_loop_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_AES_invert_key_loop\n\t" #else - "BNE.N L_AES_invert_key_loop%=\n\t" + "BNE.N L_AES_invert_key_loop_%=\n\t" #endif "SUB %[ks], %[ks], %[rounds], LSL #3\n\t" "ADD %[ks], %[ks], #0x10\n\t" "SUB r11, %[rounds], #0x1\n\t" "\n" - "L_AES_invert_key_mix_loop%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_invert_key_mix_loop:\n\t" +#else + "L_AES_invert_key_mix_loop_%=:\n\t" +#endif "LDM %[ks], {r2, r3, r4, r5}\n\t" "UBFX r6, r2, #0, #8\n\t" "UBFX r7, r2, #8, #8\n\t" @@ -294,10 +304,12 @@ void AES_invert_key(unsigned char* ks, word32 rounds) "EOR r8, r8, r9, ROR #24\n\t" "STR r8, [%[ks]], #4\n\t" "SUBS r11, r11, #0x1\n\t" -#ifdef __GNUC__ - "BNE L_AES_invert_key_mix_loop%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_invert_key_mix_loop_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_invert_key_mix_loop\n\t" #else - "BNE.W L_AES_invert_key_mix_loop%=\n\t" + "BNE.W L_AES_invert_key_mix_loop_%=\n\t" #endif #ifndef WOLFSSL_NO_VAR_ASSIGN_REG : [ks] "+r" (ks), [rounds] "+r" (rounds), @@ -339,16 +351,20 @@ void AES_set_encrypt_key(const unsigned char* key, word32 len, unsigned char* ks "MOV r10, %[L_AES_Thumb2_te]\n\t" "MOV lr, %[L_AES_Thumb2_rcon]\n\t" "CMP %[len], #0x80\n\t" -#ifdef __GNUC__ - "BEQ L_AES_set_encrypt_key_start_128%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_set_encrypt_key_start_128_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_set_encrypt_key_start_128\n\t" #else - "BEQ.W L_AES_set_encrypt_key_start_128%=\n\t" + "BEQ.W L_AES_set_encrypt_key_start_128_%=\n\t" #endif "CMP %[len], #0xc0\n\t" -#ifdef __GNUC__ - "BEQ L_AES_set_encrypt_key_start_192%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_set_encrypt_key_start_192_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_set_encrypt_key_start_192\n\t" #else - "BEQ.W L_AES_set_encrypt_key_start_192%=\n\t" + "BEQ.W L_AES_set_encrypt_key_start_192_%=\n\t" #endif "LDR r4, [%[key]]\n\t" "LDR r5, [%[key], #4]\n\t" @@ -371,7 +387,11 @@ void AES_set_encrypt_key(const unsigned char* key, word32 len, unsigned char* ks "SUB %[ks], %[ks], #0x10\n\t" "MOV r12, #0x6\n\t" "\n" - "L_AES_set_encrypt_key_loop_256%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_set_encrypt_key_loop_256:\n\t" +#else + "L_AES_set_encrypt_key_loop_256_%=:\n\t" +#endif "UBFX r4, r7, #0, #8\n\t" "UBFX r5, r7, #8, #8\n\t" "UBFX r6, r7, #16, #8\n\t" @@ -414,10 +434,12 @@ void AES_set_encrypt_key(const unsigned char* key, word32 len, unsigned char* ks "STM %[ks], {r4, r5, r6, r7}\n\t" "SUB %[ks], %[ks], #0x10\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_AES_set_encrypt_key_loop_256%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_set_encrypt_key_loop_256_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_AES_set_encrypt_key_loop_256\n\t" #else - "BNE.N L_AES_set_encrypt_key_loop_256%=\n\t" + "BNE.N L_AES_set_encrypt_key_loop_256_%=\n\t" #endif "UBFX r4, r7, #0, #8\n\t" "UBFX r5, r7, #8, #8\n\t" @@ -440,13 +462,19 @@ void AES_set_encrypt_key(const unsigned char* key, word32 len, unsigned char* ks "ADD %[ks], %[ks], #0x10\n\t" "STM %[ks], {r4, r5, r6, r7}\n\t" "SUB %[ks], %[ks], #0x10\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_AES_set_encrypt_key_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_set_encrypt_key_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_AES_set_encrypt_key_end\n\t" #else - "B.N L_AES_set_encrypt_key_end%=\n\t" + "B.N L_AES_set_encrypt_key_end_%=\n\t" #endif "\n" - "L_AES_set_encrypt_key_start_192%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_set_encrypt_key_start_192:\n\t" +#else + "L_AES_set_encrypt_key_start_192_%=:\n\t" +#endif "LDR r4, [%[key]]\n\t" "LDR r5, [%[key], #4]\n\t" "LDR r6, [%[key], #8]\n\t" @@ -464,7 +492,11 @@ void AES_set_encrypt_key(const unsigned char* key, word32 len, unsigned char* ks "MOV r7, r9\n\t" "MOV r12, #0x7\n\t" "\n" - "L_AES_set_encrypt_key_loop_192%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_set_encrypt_key_loop_192:\n\t" +#else + "L_AES_set_encrypt_key_loop_192_%=:\n\t" +#endif "UBFX r4, r9, #0, #8\n\t" "UBFX r5, r9, #8, #8\n\t" "UBFX r6, r9, #16, #8\n\t" @@ -487,10 +519,12 @@ void AES_set_encrypt_key(const unsigned char* key, word32 len, unsigned char* ks "EOR r9, r9, r8\n\t" "STM %[ks], {r4, r5, r6, r7, r8, r9}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_AES_set_encrypt_key_loop_192%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_set_encrypt_key_loop_192_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_AES_set_encrypt_key_loop_192\n\t" #else - "BNE.N L_AES_set_encrypt_key_loop_192%=\n\t" + "BNE.N L_AES_set_encrypt_key_loop_192_%=\n\t" #endif "UBFX r4, r9, #0, #8\n\t" "UBFX r5, r9, #8, #8\n\t" @@ -511,13 +545,19 @@ void AES_set_encrypt_key(const unsigned char* key, word32 len, unsigned char* ks "EOR r6, r6, r5\n\t" "EOR r7, r7, r6\n\t" "STM %[ks], {r4, r5, r6, r7}\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_AES_set_encrypt_key_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_set_encrypt_key_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_AES_set_encrypt_key_end\n\t" #else - "B.N L_AES_set_encrypt_key_end%=\n\t" + "B.N L_AES_set_encrypt_key_end_%=\n\t" #endif "\n" - "L_AES_set_encrypt_key_start_128%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_set_encrypt_key_start_128:\n\t" +#else + "L_AES_set_encrypt_key_start_128_%=:\n\t" +#endif "LDR r4, [%[key]]\n\t" "LDR r5, [%[key], #4]\n\t" "LDR r6, [%[key], #8]\n\t" @@ -529,7 +569,11 @@ void AES_set_encrypt_key(const unsigned char* key, word32 len, unsigned char* ks "STM %[ks], {r4, r5, r6, r7}\n\t" "MOV r12, #0xa\n\t" "\n" - "L_AES_set_encrypt_key_loop_128%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_set_encrypt_key_loop_128:\n\t" +#else + "L_AES_set_encrypt_key_loop_128_%=:\n\t" +#endif "UBFX r4, r7, #0, #8\n\t" "UBFX r5, r7, #8, #8\n\t" "UBFX r6, r7, #16, #8\n\t" @@ -550,13 +594,19 @@ void AES_set_encrypt_key(const unsigned char* key, word32 len, unsigned char* ks "EOR r7, r7, r6\n\t" "STM %[ks], {r4, r5, r6, r7}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_AES_set_encrypt_key_loop_128%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_set_encrypt_key_loop_128_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_AES_set_encrypt_key_loop_128\n\t" #else - "BNE.N L_AES_set_encrypt_key_loop_128%=\n\t" + "BNE.N L_AES_set_encrypt_key_loop_128_%=\n\t" #endif "\n" - "L_AES_set_encrypt_key_end%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_set_encrypt_key_end:\n\t" +#else + "L_AES_set_encrypt_key_end_%=:\n\t" +#endif #ifndef WOLFSSL_NO_VAR_ASSIGN_REG : [key] "+r" (key), [len] "+r" (len), [ks] "+r" (ks), [L_AES_Thumb2_te] "+r" (L_AES_Thumb2_te_c), [L_AES_Thumb2_rcon] "+r" (L_AES_Thumb2_rcon_c) @@ -586,7 +636,11 @@ void AES_encrypt_block(const uint32_t* te, int nr, int len, const uint32_t* ks) __asm__ __volatile__ ( "\n" - "L_AES_encrypt_block_nr%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_encrypt_block_nr:\n\t" +#else + "L_AES_encrypt_block_nr_%=:\n\t" +#endif "UBFX r8, r5, #16, #8\n\t" "LSR r11, r4, #24\n\t" "UBFX lr, r6, #8, #8\n\t" @@ -688,10 +742,12 @@ void AES_encrypt_block(const uint32_t* te, int nr, int len, const uint32_t* ks) "EOR r6, r6, r10\n\t" "EOR r7, r7, r11\n\t" "SUBS %[nr], %[nr], #0x1\n\t" -#ifdef __GNUC__ - "BNE L_AES_encrypt_block_nr%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_encrypt_block_nr_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_encrypt_block_nr\n\t" #else - "BNE.W L_AES_encrypt_block_nr%=\n\t" + "BNE.W L_AES_encrypt_block_nr_%=\n\t" #endif "UBFX r8, r5, #16, #8\n\t" "LSR r11, r4, #24\n\t" @@ -830,19 +886,27 @@ void AES_ECB_encrypt(const unsigned char* in, unsigned char* out, unsigned long #endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */ "PUSH {%[ks]}\n\t" "CMP r12, #0xa\n\t" -#ifdef __GNUC__ - "BEQ L_AES_ECB_encrypt_start_block_128%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_ECB_encrypt_start_block_128_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_ECB_encrypt_start_block_128\n\t" #else - "BEQ.W L_AES_ECB_encrypt_start_block_128%=\n\t" + "BEQ.W L_AES_ECB_encrypt_start_block_128_%=\n\t" #endif "CMP r12, #0xc\n\t" -#ifdef __GNUC__ - "BEQ L_AES_ECB_encrypt_start_block_192%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_ECB_encrypt_start_block_192_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_ECB_encrypt_start_block_192\n\t" #else - "BEQ.W L_AES_ECB_encrypt_start_block_192%=\n\t" + "BEQ.W L_AES_ECB_encrypt_start_block_192_%=\n\t" #endif "\n" - "L_AES_ECB_encrypt_loop_block_256%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_ECB_encrypt_loop_block_256:\n\t" +#else + "L_AES_ECB_encrypt_loop_block_256_%=:\n\t" +#endif "LDR r4, [lr]\n\t" "LDR r5, [lr, #4]\n\t" "LDR r6, [lr, #8]\n\t" @@ -873,20 +937,32 @@ void AES_ECB_encrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS %[len], %[len], #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_ECB_encrypt_loop_block_256%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_ECB_encrypt_loop_block_256_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_ECB_encrypt_loop_block_256\n\t" #else - "BNE.W L_AES_ECB_encrypt_loop_block_256%=\n\t" + "BNE.W L_AES_ECB_encrypt_loop_block_256_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_AES_ECB_encrypt_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_ECB_encrypt_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_AES_ECB_encrypt_end\n\t" #else - "B.N L_AES_ECB_encrypt_end%=\n\t" + "B.N L_AES_ECB_encrypt_end_%=\n\t" #endif "\n" - "L_AES_ECB_encrypt_start_block_192%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_ECB_encrypt_start_block_192:\n\t" +#else + "L_AES_ECB_encrypt_start_block_192_%=:\n\t" +#endif "\n" - "L_AES_ECB_encrypt_loop_block_192%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_ECB_encrypt_loop_block_192:\n\t" +#else + "L_AES_ECB_encrypt_loop_block_192_%=:\n\t" +#endif "LDR r4, [lr]\n\t" "LDR r5, [lr, #4]\n\t" "LDR r6, [lr, #8]\n\t" @@ -917,20 +993,32 @@ void AES_ECB_encrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS %[len], %[len], #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_ECB_encrypt_loop_block_192%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_ECB_encrypt_loop_block_192_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_ECB_encrypt_loop_block_192\n\t" #else - "BNE.W L_AES_ECB_encrypt_loop_block_192%=\n\t" + "BNE.W L_AES_ECB_encrypt_loop_block_192_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_AES_ECB_encrypt_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_ECB_encrypt_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_AES_ECB_encrypt_end\n\t" #else - "B.N L_AES_ECB_encrypt_end%=\n\t" + "B.N L_AES_ECB_encrypt_end_%=\n\t" #endif "\n" - "L_AES_ECB_encrypt_start_block_128%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_ECB_encrypt_start_block_128:\n\t" +#else + "L_AES_ECB_encrypt_start_block_128_%=:\n\t" +#endif "\n" - "L_AES_ECB_encrypt_loop_block_128%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_ECB_encrypt_loop_block_128:\n\t" +#else + "L_AES_ECB_encrypt_loop_block_128_%=:\n\t" +#endif "LDR r4, [lr]\n\t" "LDR r5, [lr, #4]\n\t" "LDR r6, [lr, #8]\n\t" @@ -961,13 +1049,19 @@ void AES_ECB_encrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS %[len], %[len], #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_ECB_encrypt_loop_block_128%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_ECB_encrypt_loop_block_128_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_ECB_encrypt_loop_block_128\n\t" #else - "BNE.W L_AES_ECB_encrypt_loop_block_128%=\n\t" + "BNE.W L_AES_ECB_encrypt_loop_block_128_%=\n\t" #endif "\n" - "L_AES_ECB_encrypt_end%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_ECB_encrypt_end:\n\t" +#else + "L_AES_ECB_encrypt_end_%=:\n\t" +#endif "POP {%[ks]}\n\t" #ifndef WOLFSSL_NO_VAR_ASSIGN_REG : [in] "+r" (in), [out] "+r" (out), [len] "+r" (len), [ks] "+r" (ks), [nr] "+r" (nr), @@ -1021,19 +1115,27 @@ void AES_CBC_encrypt(const unsigned char* in, unsigned char* out, unsigned long "LDM r9, {r4, r5, r6, r7}\n\t" "PUSH {%[ks], r9}\n\t" "CMP r8, #0xa\n\t" -#ifdef __GNUC__ - "BEQ L_AES_CBC_encrypt_start_block_128%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_CBC_encrypt_start_block_128_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_CBC_encrypt_start_block_128\n\t" #else - "BEQ.W L_AES_CBC_encrypt_start_block_128%=\n\t" + "BEQ.W L_AES_CBC_encrypt_start_block_128_%=\n\t" #endif "CMP r8, #0xc\n\t" -#ifdef __GNUC__ - "BEQ L_AES_CBC_encrypt_start_block_192%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_CBC_encrypt_start_block_192_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_CBC_encrypt_start_block_192\n\t" #else - "BEQ.W L_AES_CBC_encrypt_start_block_192%=\n\t" + "BEQ.W L_AES_CBC_encrypt_start_block_192_%=\n\t" #endif "\n" - "L_AES_CBC_encrypt_loop_block_256%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CBC_encrypt_loop_block_256:\n\t" +#else + "L_AES_CBC_encrypt_loop_block_256_%=:\n\t" +#endif "LDR r8, [lr]\n\t" "LDR r9, [lr, #4]\n\t" "LDR r10, [lr, #8]\n\t" @@ -1068,20 +1170,32 @@ void AES_CBC_encrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS %[len], %[len], #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_CBC_encrypt_loop_block_256%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_CBC_encrypt_loop_block_256_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_CBC_encrypt_loop_block_256\n\t" #else - "BNE.W L_AES_CBC_encrypt_loop_block_256%=\n\t" + "BNE.W L_AES_CBC_encrypt_loop_block_256_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_AES_CBC_encrypt_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_CBC_encrypt_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_AES_CBC_encrypt_end\n\t" #else - "B.N L_AES_CBC_encrypt_end%=\n\t" + "B.N L_AES_CBC_encrypt_end_%=\n\t" #endif "\n" - "L_AES_CBC_encrypt_start_block_192%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CBC_encrypt_start_block_192:\n\t" +#else + "L_AES_CBC_encrypt_start_block_192_%=:\n\t" +#endif "\n" - "L_AES_CBC_encrypt_loop_block_192%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CBC_encrypt_loop_block_192:\n\t" +#else + "L_AES_CBC_encrypt_loop_block_192_%=:\n\t" +#endif "LDR r8, [lr]\n\t" "LDR r9, [lr, #4]\n\t" "LDR r10, [lr, #8]\n\t" @@ -1116,20 +1230,32 @@ void AES_CBC_encrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS %[len], %[len], #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_CBC_encrypt_loop_block_192%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_CBC_encrypt_loop_block_192_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_CBC_encrypt_loop_block_192\n\t" #else - "BNE.W L_AES_CBC_encrypt_loop_block_192%=\n\t" + "BNE.W L_AES_CBC_encrypt_loop_block_192_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_AES_CBC_encrypt_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_CBC_encrypt_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_AES_CBC_encrypt_end\n\t" #else - "B.N L_AES_CBC_encrypt_end%=\n\t" + "B.N L_AES_CBC_encrypt_end_%=\n\t" #endif "\n" - "L_AES_CBC_encrypt_start_block_128%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CBC_encrypt_start_block_128:\n\t" +#else + "L_AES_CBC_encrypt_start_block_128_%=:\n\t" +#endif "\n" - "L_AES_CBC_encrypt_loop_block_128%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CBC_encrypt_loop_block_128:\n\t" +#else + "L_AES_CBC_encrypt_loop_block_128_%=:\n\t" +#endif "LDR r8, [lr]\n\t" "LDR r9, [lr, #4]\n\t" "LDR r10, [lr, #8]\n\t" @@ -1164,13 +1290,19 @@ void AES_CBC_encrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS %[len], %[len], #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_CBC_encrypt_loop_block_128%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_CBC_encrypt_loop_block_128_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_CBC_encrypt_loop_block_128\n\t" #else - "BNE.W L_AES_CBC_encrypt_loop_block_128%=\n\t" + "BNE.W L_AES_CBC_encrypt_loop_block_128_%=\n\t" #endif "\n" - "L_AES_CBC_encrypt_end%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CBC_encrypt_end:\n\t" +#else + "L_AES_CBC_encrypt_end_%=:\n\t" +#endif "POP {%[ks], r9}\n\t" "STM r9, {r4, r5, r6, r7}\n\t" #ifndef WOLFSSL_NO_VAR_ASSIGN_REG @@ -1233,19 +1365,27 @@ void AES_CTR_encrypt(const unsigned char* in, unsigned char* out, unsigned long "STM r8, {r4, r5, r6, r7}\n\t" "PUSH {%[ks], r8}\n\t" "CMP r12, #0xa\n\t" -#ifdef __GNUC__ - "BEQ L_AES_CTR_encrypt_start_block_128%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_CTR_encrypt_start_block_128_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_CTR_encrypt_start_block_128\n\t" #else - "BEQ.W L_AES_CTR_encrypt_start_block_128%=\n\t" + "BEQ.W L_AES_CTR_encrypt_start_block_128_%=\n\t" #endif "CMP r12, #0xc\n\t" -#ifdef __GNUC__ - "BEQ L_AES_CTR_encrypt_start_block_192%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_CTR_encrypt_start_block_192_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_CTR_encrypt_start_block_192\n\t" #else - "BEQ.W L_AES_CTR_encrypt_start_block_192%=\n\t" + "BEQ.W L_AES_CTR_encrypt_start_block_192_%=\n\t" #endif "\n" - "L_AES_CTR_encrypt_loop_block_256%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CTR_encrypt_loop_block_256:\n\t" +#else + "L_AES_CTR_encrypt_loop_block_256_%=:\n\t" +#endif "PUSH {r1, %[len], lr}\n\t" "LDR lr, [sp, #16]\n\t" "ADDS r11, r7, #0x1\n\t" @@ -1284,20 +1424,32 @@ void AES_CTR_encrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS %[len], %[len], #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_CTR_encrypt_loop_block_256%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_CTR_encrypt_loop_block_256_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_CTR_encrypt_loop_block_256\n\t" #else - "BNE.W L_AES_CTR_encrypt_loop_block_256%=\n\t" + "BNE.W L_AES_CTR_encrypt_loop_block_256_%=\n\t" #endif -#ifdef __GNUC__ - "B L_AES_CTR_encrypt_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_CTR_encrypt_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.W L_AES_CTR_encrypt_end\n\t" #else - "B.W L_AES_CTR_encrypt_end%=\n\t" + "B.W L_AES_CTR_encrypt_end_%=\n\t" #endif "\n" - "L_AES_CTR_encrypt_start_block_192%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CTR_encrypt_start_block_192:\n\t" +#else + "L_AES_CTR_encrypt_start_block_192_%=:\n\t" +#endif "\n" - "L_AES_CTR_encrypt_loop_block_192%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CTR_encrypt_loop_block_192:\n\t" +#else + "L_AES_CTR_encrypt_loop_block_192_%=:\n\t" +#endif "PUSH {r1, %[len], lr}\n\t" "LDR lr, [sp, #16]\n\t" "ADDS r11, r7, #0x1\n\t" @@ -1336,20 +1488,32 @@ void AES_CTR_encrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS %[len], %[len], #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_CTR_encrypt_loop_block_192%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_CTR_encrypt_loop_block_192_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_CTR_encrypt_loop_block_192\n\t" #else - "BNE.W L_AES_CTR_encrypt_loop_block_192%=\n\t" + "BNE.W L_AES_CTR_encrypt_loop_block_192_%=\n\t" #endif -#ifdef __GNUC__ - "B L_AES_CTR_encrypt_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_CTR_encrypt_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.W L_AES_CTR_encrypt_end\n\t" #else - "B.W L_AES_CTR_encrypt_end%=\n\t" + "B.W L_AES_CTR_encrypt_end_%=\n\t" #endif "\n" - "L_AES_CTR_encrypt_start_block_128%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CTR_encrypt_start_block_128:\n\t" +#else + "L_AES_CTR_encrypt_start_block_128_%=:\n\t" +#endif "\n" - "L_AES_CTR_encrypt_loop_block_128%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CTR_encrypt_loop_block_128:\n\t" +#else + "L_AES_CTR_encrypt_loop_block_128_%=:\n\t" +#endif "PUSH {r1, %[len], lr}\n\t" "LDR lr, [sp, #16]\n\t" "ADDS r11, r7, #0x1\n\t" @@ -1388,13 +1552,19 @@ void AES_CTR_encrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS %[len], %[len], #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_CTR_encrypt_loop_block_128%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_CTR_encrypt_loop_block_128_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_CTR_encrypt_loop_block_128\n\t" #else - "BNE.W L_AES_CTR_encrypt_loop_block_128%=\n\t" + "BNE.W L_AES_CTR_encrypt_loop_block_128_%=\n\t" #endif "\n" - "L_AES_CTR_encrypt_end%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CTR_encrypt_end:\n\t" +#else + "L_AES_CTR_encrypt_end_%=:\n\t" +#endif "POP {%[ks], r8}\n\t" "REV r4, r4\n\t" "REV r5, r5\n\t" @@ -1438,7 +1608,11 @@ void AES_decrypt_block(const uint32_t* td, int nr, const uint8_t* td4) __asm__ __volatile__ ( "\n" - "L_AES_decrypt_block_nr%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_decrypt_block_nr:\n\t" +#else + "L_AES_decrypt_block_nr_%=:\n\t" +#endif "UBFX r8, r7, #16, #8\n\t" "LSR r11, r4, #24\n\t" "UBFX r12, r6, #8, #8\n\t" @@ -1540,10 +1714,12 @@ void AES_decrypt_block(const uint32_t* td, int nr, const uint8_t* td4) "EOR r6, r6, r10\n\t" "EOR r7, r7, r11\n\t" "SUBS %[nr], %[nr], #0x1\n\t" -#ifdef __GNUC__ - "BNE L_AES_decrypt_block_nr%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_decrypt_block_nr_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_decrypt_block_nr\n\t" #else - "BNE.W L_AES_decrypt_block_nr%=\n\t" + "BNE.W L_AES_decrypt_block_nr_%=\n\t" #endif "UBFX r8, r7, #16, #8\n\t" "LSR r11, r4, #24\n\t" @@ -1717,19 +1893,27 @@ void AES_ECB_decrypt(const unsigned char* in, unsigned char* out, unsigned long "MOV r12, %[len]\n\t" "MOV r2, %[L_AES_Thumb2_td4]\n\t" "CMP r8, #0xa\n\t" -#ifdef __GNUC__ - "BEQ L_AES_ECB_decrypt_start_block_128%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_ECB_decrypt_start_block_128_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_ECB_decrypt_start_block_128\n\t" #else - "BEQ.W L_AES_ECB_decrypt_start_block_128%=\n\t" + "BEQ.W L_AES_ECB_decrypt_start_block_128_%=\n\t" #endif "CMP r8, #0xc\n\t" -#ifdef __GNUC__ - "BEQ L_AES_ECB_decrypt_start_block_192%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_ECB_decrypt_start_block_192_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_ECB_decrypt_start_block_192\n\t" #else - "BEQ.W L_AES_ECB_decrypt_start_block_192%=\n\t" + "BEQ.W L_AES_ECB_decrypt_start_block_192_%=\n\t" #endif "\n" - "L_AES_ECB_decrypt_loop_block_256%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_ECB_decrypt_loop_block_256:\n\t" +#else + "L_AES_ECB_decrypt_loop_block_256_%=:\n\t" +#endif "LDR r4, [lr]\n\t" "LDR r5, [lr, #4]\n\t" "LDR r6, [lr, #8]\n\t" @@ -1759,20 +1943,32 @@ void AES_ECB_decrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS r12, r12, #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_ECB_decrypt_loop_block_256%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_ECB_decrypt_loop_block_256_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_ECB_decrypt_loop_block_256\n\t" #else - "BNE.W L_AES_ECB_decrypt_loop_block_256%=\n\t" + "BNE.W L_AES_ECB_decrypt_loop_block_256_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_AES_ECB_decrypt_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_ECB_decrypt_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_AES_ECB_decrypt_end\n\t" #else - "B.N L_AES_ECB_decrypt_end%=\n\t" + "B.N L_AES_ECB_decrypt_end_%=\n\t" #endif "\n" - "L_AES_ECB_decrypt_start_block_192%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_ECB_decrypt_start_block_192:\n\t" +#else + "L_AES_ECB_decrypt_start_block_192_%=:\n\t" +#endif "\n" - "L_AES_ECB_decrypt_loop_block_192%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_ECB_decrypt_loop_block_192:\n\t" +#else + "L_AES_ECB_decrypt_loop_block_192_%=:\n\t" +#endif "LDR r4, [lr]\n\t" "LDR r5, [lr, #4]\n\t" "LDR r6, [lr, #8]\n\t" @@ -1802,20 +1998,32 @@ void AES_ECB_decrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS r12, r12, #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_ECB_decrypt_loop_block_192%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_ECB_decrypt_loop_block_192_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_ECB_decrypt_loop_block_192\n\t" #else - "BNE.W L_AES_ECB_decrypt_loop_block_192%=\n\t" + "BNE.W L_AES_ECB_decrypt_loop_block_192_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_AES_ECB_decrypt_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_ECB_decrypt_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_AES_ECB_decrypt_end\n\t" #else - "B.N L_AES_ECB_decrypt_end%=\n\t" + "B.N L_AES_ECB_decrypt_end_%=\n\t" #endif "\n" - "L_AES_ECB_decrypt_start_block_128%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_ECB_decrypt_start_block_128:\n\t" +#else + "L_AES_ECB_decrypt_start_block_128_%=:\n\t" +#endif "\n" - "L_AES_ECB_decrypt_loop_block_128%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_ECB_decrypt_loop_block_128:\n\t" +#else + "L_AES_ECB_decrypt_loop_block_128_%=:\n\t" +#endif "LDR r4, [lr]\n\t" "LDR r5, [lr, #4]\n\t" "LDR r6, [lr, #8]\n\t" @@ -1845,13 +2053,19 @@ void AES_ECB_decrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS r12, r12, #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_ECB_decrypt_loop_block_128%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_ECB_decrypt_loop_block_128_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_ECB_decrypt_loop_block_128\n\t" #else - "BNE.W L_AES_ECB_decrypt_loop_block_128%=\n\t" + "BNE.W L_AES_ECB_decrypt_loop_block_128_%=\n\t" #endif "\n" - "L_AES_ECB_decrypt_end%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_ECB_decrypt_end:\n\t" +#else + "L_AES_ECB_decrypt_end_%=:\n\t" +#endif #ifndef WOLFSSL_NO_VAR_ASSIGN_REG : [in] "+r" (in), [out] "+r" (out), [len] "+r" (len), [ks] "+r" (ks), [nr] "+r" (nr), [L_AES_Thumb2_td_ecb] "+r" (L_AES_Thumb2_td_ecb_c), [L_AES_Thumb2_td4] "+r" (L_AES_Thumb2_td4_c) @@ -1906,19 +2120,27 @@ void AES_CBC_decrypt(const unsigned char* in, unsigned char* out, unsigned long "MOV r2, %[L_AES_Thumb2_td4]\n\t" "PUSH {%[ks], r4}\n\t" "CMP r8, #0xa\n\t" -#ifdef __GNUC__ - "BEQ L_AES_CBC_decrypt_loop_block_128%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_CBC_decrypt_loop_block_128_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_CBC_decrypt_loop_block_128\n\t" #else - "BEQ.W L_AES_CBC_decrypt_loop_block_128%=\n\t" + "BEQ.W L_AES_CBC_decrypt_loop_block_128_%=\n\t" #endif "CMP r8, #0xc\n\t" -#ifdef __GNUC__ - "BEQ L_AES_CBC_decrypt_loop_block_192%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_CBC_decrypt_loop_block_192_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_CBC_decrypt_loop_block_192\n\t" #else - "BEQ.W L_AES_CBC_decrypt_loop_block_192%=\n\t" + "BEQ.W L_AES_CBC_decrypt_loop_block_192_%=\n\t" #endif "\n" - "L_AES_CBC_decrypt_loop_block_256%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CBC_decrypt_loop_block_256:\n\t" +#else + "L_AES_CBC_decrypt_loop_block_256_%=:\n\t" +#endif "PUSH {r1, r12, lr}\n\t" "LDR r4, [lr]\n\t" "LDR r5, [lr, #4]\n\t" @@ -1958,10 +2180,12 @@ void AES_CBC_decrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS r12, r12, #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BEQ L_AES_CBC_decrypt_end_odd%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_CBC_decrypt_end_odd_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_CBC_decrypt_end_odd\n\t" #else - "BEQ.W L_AES_CBC_decrypt_end_odd%=\n\t" + "BEQ.W L_AES_CBC_decrypt_end_odd_%=\n\t" #endif "PUSH {r1, r12, lr}\n\t" "LDR r4, [lr]\n\t" @@ -2003,18 +2227,26 @@ void AES_CBC_decrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS r12, r12, #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_CBC_decrypt_loop_block_256%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_CBC_decrypt_loop_block_256_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_CBC_decrypt_loop_block_256\n\t" #else - "BNE.W L_AES_CBC_decrypt_loop_block_256%=\n\t" + "BNE.W L_AES_CBC_decrypt_loop_block_256_%=\n\t" #endif -#ifdef __GNUC__ - "B L_AES_CBC_decrypt_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_CBC_decrypt_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.W L_AES_CBC_decrypt_end\n\t" #else - "B.W L_AES_CBC_decrypt_end%=\n\t" + "B.W L_AES_CBC_decrypt_end_%=\n\t" #endif "\n" - "L_AES_CBC_decrypt_loop_block_192%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CBC_decrypt_loop_block_192:\n\t" +#else + "L_AES_CBC_decrypt_loop_block_192_%=:\n\t" +#endif "PUSH {r1, r12, lr}\n\t" "LDR r4, [lr]\n\t" "LDR r5, [lr, #4]\n\t" @@ -2054,10 +2286,12 @@ void AES_CBC_decrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS r12, r12, #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BEQ L_AES_CBC_decrypt_end_odd%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_CBC_decrypt_end_odd_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_CBC_decrypt_end_odd\n\t" #else - "BEQ.W L_AES_CBC_decrypt_end_odd%=\n\t" + "BEQ.W L_AES_CBC_decrypt_end_odd_%=\n\t" #endif "PUSH {r1, r12, lr}\n\t" "LDR r4, [lr]\n\t" @@ -2099,18 +2333,26 @@ void AES_CBC_decrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS r12, r12, #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_CBC_decrypt_loop_block_192%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_CBC_decrypt_loop_block_192_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_CBC_decrypt_loop_block_192\n\t" #else - "BNE.W L_AES_CBC_decrypt_loop_block_192%=\n\t" + "BNE.W L_AES_CBC_decrypt_loop_block_192_%=\n\t" #endif -#ifdef __GNUC__ - "B L_AES_CBC_decrypt_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_CBC_decrypt_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.W L_AES_CBC_decrypt_end\n\t" #else - "B.W L_AES_CBC_decrypt_end%=\n\t" + "B.W L_AES_CBC_decrypt_end_%=\n\t" #endif "\n" - "L_AES_CBC_decrypt_loop_block_128%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CBC_decrypt_loop_block_128:\n\t" +#else + "L_AES_CBC_decrypt_loop_block_128_%=:\n\t" +#endif "PUSH {r1, r12, lr}\n\t" "LDR r4, [lr]\n\t" "LDR r5, [lr, #4]\n\t" @@ -2150,10 +2392,12 @@ void AES_CBC_decrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS r12, r12, #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BEQ L_AES_CBC_decrypt_end_odd%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_CBC_decrypt_end_odd_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_CBC_decrypt_end_odd\n\t" #else - "BEQ.W L_AES_CBC_decrypt_end_odd%=\n\t" + "BEQ.W L_AES_CBC_decrypt_end_odd_%=\n\t" #endif "PUSH {r1, r12, lr}\n\t" "LDR r4, [lr]\n\t" @@ -2195,25 +2439,37 @@ void AES_CBC_decrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS r12, r12, #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_CBC_decrypt_loop_block_128%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_CBC_decrypt_loop_block_128_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_CBC_decrypt_loop_block_128\n\t" #else - "BNE.W L_AES_CBC_decrypt_loop_block_128%=\n\t" + "BNE.W L_AES_CBC_decrypt_loop_block_128_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_AES_CBC_decrypt_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_CBC_decrypt_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_AES_CBC_decrypt_end\n\t" #else - "B.N L_AES_CBC_decrypt_end%=\n\t" + "B.N L_AES_CBC_decrypt_end_%=\n\t" #endif "\n" - "L_AES_CBC_decrypt_end_odd%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CBC_decrypt_end_odd:\n\t" +#else + "L_AES_CBC_decrypt_end_odd_%=:\n\t" +#endif "LDR r4, [sp, #4]\n\t" "LDRD r8, r9, [r4, #16]\n\t" "LDRD r10, r11, [r4, #24]\n\t" "STRD r8, r9, [r4]\n\t" "STRD r10, r11, [r4, #8]\n\t" "\n" - "L_AES_CBC_decrypt_end%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_CBC_decrypt_end:\n\t" +#else + "L_AES_CBC_decrypt_end_%=:\n\t" +#endif "POP {%[ks], r4}\n\t" #ifndef WOLFSSL_NO_VAR_ASSIGN_REG : [in] "+r" (in), [out] "+r" (out), [len] "+r" (len), [ks] "+r" (ks), [nr] "+r" (nr), [iv] "+r" (iv), @@ -2264,7 +2520,11 @@ void GCM_gmult_len(unsigned char* x, const unsigned char** m, const unsigned cha __asm__ __volatile__ ( "MOV lr, %[L_GCM_gmult_len_r]\n\t" "\n" - "L_GCM_gmult_len_start_block%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_GCM_gmult_len_start_block:\n\t" +#else + "L_GCM_gmult_len_start_block_%=:\n\t" +#endif "PUSH {r3}\n\t" "LDR r12, [r0, #12]\n\t" "LDR %[len], [r2, #12]\n\t" @@ -2809,10 +3069,12 @@ void GCM_gmult_len(unsigned char* x, const unsigned char** m, const unsigned cha "POP {r3}\n\t" "SUBS %[len], %[len], #0x10\n\t" "ADD %[data], %[data], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_GCM_gmult_len_start_block%=\n\t" +#if defined(__GNUC__) + "BNE L_GCM_gmult_len_start_block_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_GCM_gmult_len_start_block\n\t" #else - "BNE.W L_GCM_gmult_len_start_block%=\n\t" + "BNE.W L_GCM_gmult_len_start_block_%=\n\t" #endif #ifndef WOLFSSL_NO_VAR_ASSIGN_REG : [x] "+r" (x), [m] "+r" (m), [data] "+r" (data), [len] "+r" (len), @@ -2867,19 +3129,27 @@ void AES_GCM_encrypt(const unsigned char* in, unsigned char* out, unsigned long "STM r8, {r4, r5, r6, r7}\n\t" "PUSH {%[ks], r8}\n\t" "CMP r12, #0xa\n\t" -#ifdef __GNUC__ - "BEQ L_AES_GCM_encrypt_start_block_128%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_GCM_encrypt_start_block_128_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_GCM_encrypt_start_block_128\n\t" #else - "BEQ.W L_AES_GCM_encrypt_start_block_128%=\n\t" + "BEQ.W L_AES_GCM_encrypt_start_block_128_%=\n\t" #endif "CMP r12, #0xc\n\t" -#ifdef __GNUC__ - "BEQ L_AES_GCM_encrypt_start_block_192%=\n\t" +#if defined(__GNUC__) + "BEQ L_AES_GCM_encrypt_start_block_192_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.W L_AES_GCM_encrypt_start_block_192\n\t" #else - "BEQ.W L_AES_GCM_encrypt_start_block_192%=\n\t" + "BEQ.W L_AES_GCM_encrypt_start_block_192_%=\n\t" #endif "\n" - "L_AES_GCM_encrypt_loop_block_256%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_GCM_encrypt_loop_block_256:\n\t" +#else + "L_AES_GCM_encrypt_loop_block_256_%=:\n\t" +#endif "PUSH {r1, %[len], lr}\n\t" "LDR lr, [sp, #16]\n\t" "ADD r7, r7, #0x1\n\t" @@ -2915,20 +3185,32 @@ void AES_GCM_encrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS %[len], %[len], #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_GCM_encrypt_loop_block_256%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_GCM_encrypt_loop_block_256_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_GCM_encrypt_loop_block_256\n\t" #else - "BNE.W L_AES_GCM_encrypt_loop_block_256%=\n\t" + "BNE.W L_AES_GCM_encrypt_loop_block_256_%=\n\t" #endif -#ifdef __GNUC__ - "B L_AES_GCM_encrypt_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_GCM_encrypt_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.W L_AES_GCM_encrypt_end\n\t" #else - "B.W L_AES_GCM_encrypt_end%=\n\t" + "B.W L_AES_GCM_encrypt_end_%=\n\t" #endif "\n" - "L_AES_GCM_encrypt_start_block_192%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_GCM_encrypt_start_block_192:\n\t" +#else + "L_AES_GCM_encrypt_start_block_192_%=:\n\t" +#endif "\n" - "L_AES_GCM_encrypt_loop_block_192%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_GCM_encrypt_loop_block_192:\n\t" +#else + "L_AES_GCM_encrypt_loop_block_192_%=:\n\t" +#endif "PUSH {r1, %[len], lr}\n\t" "LDR lr, [sp, #16]\n\t" "ADD r7, r7, #0x1\n\t" @@ -2964,20 +3246,32 @@ void AES_GCM_encrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS %[len], %[len], #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_GCM_encrypt_loop_block_192%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_GCM_encrypt_loop_block_192_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_GCM_encrypt_loop_block_192\n\t" #else - "BNE.W L_AES_GCM_encrypt_loop_block_192%=\n\t" + "BNE.W L_AES_GCM_encrypt_loop_block_192_%=\n\t" #endif -#ifdef __GNUC__ - "B L_AES_GCM_encrypt_end%=\n\t" +#if defined(__GNUC__) + "B L_AES_GCM_encrypt_end_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.W L_AES_GCM_encrypt_end\n\t" #else - "B.W L_AES_GCM_encrypt_end%=\n\t" + "B.W L_AES_GCM_encrypt_end_%=\n\t" #endif "\n" - "L_AES_GCM_encrypt_start_block_128%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_GCM_encrypt_start_block_128:\n\t" +#else + "L_AES_GCM_encrypt_start_block_128_%=:\n\t" +#endif "\n" - "L_AES_GCM_encrypt_loop_block_128%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_GCM_encrypt_loop_block_128:\n\t" +#else + "L_AES_GCM_encrypt_loop_block_128_%=:\n\t" +#endif "PUSH {r1, %[len], lr}\n\t" "LDR lr, [sp, #16]\n\t" "ADD r7, r7, #0x1\n\t" @@ -3013,13 +3307,19 @@ void AES_GCM_encrypt(const unsigned char* in, unsigned char* out, unsigned long "SUBS %[len], %[len], #0x10\n\t" "ADD lr, lr, #0x10\n\t" "ADD %[out], %[out], #0x10\n\t" -#ifdef __GNUC__ - "BNE L_AES_GCM_encrypt_loop_block_128%=\n\t" +#if defined(__GNUC__) + "BNE L_AES_GCM_encrypt_loop_block_128_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_AES_GCM_encrypt_loop_block_128\n\t" #else - "BNE.W L_AES_GCM_encrypt_loop_block_128%=\n\t" + "BNE.W L_AES_GCM_encrypt_loop_block_128_%=\n\t" #endif "\n" - "L_AES_GCM_encrypt_end%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_AES_GCM_encrypt_end:\n\t" +#else + "L_AES_GCM_encrypt_end_%=:\n\t" +#endif "POP {%[ks], r8}\n\t" "REV r4, r4\n\t" "REV r5, r5\n\t" diff --git a/wolfcrypt/src/port/arm/thumb2-curve25519.S b/wolfcrypt/src/port/arm/thumb2-curve25519.S index e6b5dcf5d2..42da2f45f1 100644 --- a/wolfcrypt/src/port/arm/thumb2-curve25519.S +++ b/wolfcrypt/src/port/arm/thumb2-curve25519.S @@ -1,6 +1,6 @@ /* thumb2-curve25519 * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -2741,7 +2741,7 @@ L_curve25519_bits: LDR r1, [sp, #180] SUBS r1, r1, #0x1 STR r1, [sp, #180] -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BGE L_curve25519_bits #else BGE.W L_curve25519_bits @@ -2750,7 +2750,7 @@ L_curve25519_bits: STR r1, [sp, #180] SUBS r2, r2, #0x4 STR r2, [sp, #176] -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BGE L_curve25519_words #else BGE.W L_curve25519_words diff --git a/wolfcrypt/src/port/arm/thumb2-curve25519_c.c b/wolfcrypt/src/port/arm/thumb2-curve25519_c.c index 884b9089dc..21ad67bac3 100644 --- a/wolfcrypt/src/port/arm/thumb2-curve25519_c.c +++ b/wolfcrypt/src/port/arm/thumb2-curve25519_c.c @@ -1,6 +1,6 @@ /* thumb2-curve25519 * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -2789,9 +2789,17 @@ int curve25519(byte* r, const byte* n, const byte* a) "MOV %[a], #0x1c\n\t" "STR %[a], [sp, #176]\n\t" "\n" - "L_curve25519_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_words:\n\t" +#else + "L_curve25519_words_%=:\n\t" +#endif "\n" - "L_curve25519_bits%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_bits:\n\t" +#else + "L_curve25519_bits_%=:\n\t" +#endif "LDR %[n], [sp, #164]\n\t" "LDR %[a], [%[n], r2]\n\t" "LDR %[n], [sp, #180]\n\t" @@ -2971,19 +2979,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "LDR %[n], [sp, #180]\n\t" "SUBS %[n], %[n], #0x1\n\t" "STR %[n], [sp, #180]\n\t" -#ifdef __GNUC__ - "BGE L_curve25519_bits%=\n\t" +#if defined(__GNUC__) + "BGE L_curve25519_bits_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGE.W L_curve25519_bits\n\t" #else - "BGE.W L_curve25519_bits%=\n\t" + "BGE.W L_curve25519_bits_%=\n\t" #endif "MOV %[n], #0x1f\n\t" "STR %[n], [sp, #180]\n\t" "SUBS %[a], %[a], #0x4\n\t" "STR %[a], [sp, #176]\n\t" -#ifdef __GNUC__ - "BGE L_curve25519_words%=\n\t" +#if defined(__GNUC__) + "BGE L_curve25519_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGE.W L_curve25519_words\n\t" #else - "BGE.W L_curve25519_words%=\n\t" + "BGE.W L_curve25519_words_%=\n\t" #endif /* Invert */ "ADD r1, sp, #0x0\n\t" @@ -3015,17 +3027,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_sq_op\n\t" "MOV r12, #0x4\n\t" "\n" - "L_curve25519_inv_1%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_1:\n\t" +#else + "L_curve25519_inv_1_%=:\n\t" +#endif "ADD r1, sp, #0x60\n\t" "ADD r0, sp, #0x60\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_1%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_1_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_1\n\t" #else - "BNE.N L_curve25519_inv_1%=\n\t" + "BNE.N L_curve25519_inv_1_%=\n\t" #endif "ADD r2, sp, #0x40\n\t" "ADD r1, sp, #0x60\n\t" @@ -3036,17 +3054,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_sq_op\n\t" "MOV r12, #0x9\n\t" "\n" - "L_curve25519_inv_2%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_2:\n\t" +#else + "L_curve25519_inv_2_%=:\n\t" +#endif "ADD r1, sp, #0x60\n\t" "ADD r0, sp, #0x60\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_2%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_2_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_2\n\t" #else - "BNE.N L_curve25519_inv_2%=\n\t" + "BNE.N L_curve25519_inv_2_%=\n\t" #endif "ADD r2, sp, #0x40\n\t" "ADD r1, sp, #0x60\n\t" @@ -3057,17 +3081,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_sq_op\n\t" "MOV r12, #0x13\n\t" "\n" - "L_curve25519_inv_3%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_3:\n\t" +#else + "L_curve25519_inv_3_%=:\n\t" +#endif "ADD r1, sp, #0x80\n\t" "ADD r0, sp, #0x80\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_3%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_3_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_3\n\t" #else - "BNE.N L_curve25519_inv_3%=\n\t" + "BNE.N L_curve25519_inv_3_%=\n\t" #endif "ADD r2, sp, #0x60\n\t" "ADD r1, sp, #0x80\n\t" @@ -3075,17 +3105,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_mul_op\n\t" "MOV r12, #0xa\n\t" "\n" - "L_curve25519_inv_4%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_4:\n\t" +#else + "L_curve25519_inv_4_%=:\n\t" +#endif "ADD r1, sp, #0x60\n\t" "ADD r0, sp, #0x60\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_4%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_4_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_4\n\t" #else - "BNE.N L_curve25519_inv_4%=\n\t" + "BNE.N L_curve25519_inv_4_%=\n\t" #endif "ADD r2, sp, #0x40\n\t" "ADD r1, sp, #0x60\n\t" @@ -3096,17 +3132,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_sq_op\n\t" "MOV r12, #0x31\n\t" "\n" - "L_curve25519_inv_5%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_5:\n\t" +#else + "L_curve25519_inv_5_%=:\n\t" +#endif "ADD r1, sp, #0x60\n\t" "ADD r0, sp, #0x60\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_5%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_5_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_5\n\t" #else - "BNE.N L_curve25519_inv_5%=\n\t" + "BNE.N L_curve25519_inv_5_%=\n\t" #endif "ADD r2, sp, #0x40\n\t" "ADD r1, sp, #0x60\n\t" @@ -3117,17 +3159,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_sq_op\n\t" "MOV r12, #0x63\n\t" "\n" - "L_curve25519_inv_6%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_6:\n\t" +#else + "L_curve25519_inv_6_%=:\n\t" +#endif "ADD r1, sp, #0x80\n\t" "ADD r0, sp, #0x80\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_6%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_6_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_6\n\t" #else - "BNE.N L_curve25519_inv_6%=\n\t" + "BNE.N L_curve25519_inv_6_%=\n\t" #endif "ADD r2, sp, #0x60\n\t" "ADD r1, sp, #0x80\n\t" @@ -3135,17 +3183,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_mul_op\n\t" "MOV r12, #0x32\n\t" "\n" - "L_curve25519_inv_7%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_7:\n\t" +#else + "L_curve25519_inv_7_%=:\n\t" +#endif "ADD r1, sp, #0x60\n\t" "ADD r0, sp, #0x60\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_7%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_7_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_7\n\t" #else - "BNE.N L_curve25519_inv_7%=\n\t" + "BNE.N L_curve25519_inv_7_%=\n\t" #endif "ADD r2, sp, #0x40\n\t" "ADD r1, sp, #0x60\n\t" @@ -3153,17 +3207,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_mul_op\n\t" "MOV r12, #0x5\n\t" "\n" - "L_curve25519_inv_8%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_8:\n\t" +#else + "L_curve25519_inv_8_%=:\n\t" +#endif "ADD r1, sp, #0x40\n\t" "ADD r0, sp, #0x40\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_8%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_8_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_8\n\t" #else - "BNE.N L_curve25519_inv_8%=\n\t" + "BNE.N L_curve25519_inv_8_%=\n\t" #endif "ADD r2, sp, #0x20\n\t" "ADD r1, sp, #0x40\n\t" @@ -3227,7 +3287,11 @@ int curve25519(byte* r, const byte* n, const byte* a) "STM r3, {r4, r5, r6, r7, r8, r9, r10, r11}\n\t" "MOV %[a], #0xfe\n\t" "\n" - "L_curve25519_bits%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_bits:\n\t" +#else + "L_curve25519_bits_%=:\n\t" +#endif "STR %[a], [sp, #168]\n\t" "LDR %[n], [sp, #160]\n\t" "AND r4, %[a], #0x1f\n\t" @@ -3312,10 +3376,12 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_mul_op\n\t" "LDR %[a], [sp, #168]\n\t" "SUBS %[a], %[a], #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGE L_curve25519_bits%=\n\t" +#if defined(__GNUC__) + "BGE L_curve25519_bits_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGE.N L_curve25519_bits\n\t" #else - "BGE.N L_curve25519_bits%=\n\t" + "BGE.N L_curve25519_bits_%=\n\t" #endif /* Cycle Count: 171 */ "LDR %[n], [sp, #184]\n\t" @@ -3352,17 +3418,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_sq_op\n\t" "MOV r12, #0x4\n\t" "\n" - "L_curve25519_inv_1%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_1:\n\t" +#else + "L_curve25519_inv_1_%=:\n\t" +#endif "ADD r1, sp, #0x60\n\t" "ADD r0, sp, #0x60\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_1%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_1_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_1\n\t" #else - "BNE.N L_curve25519_inv_1%=\n\t" + "BNE.N L_curve25519_inv_1_%=\n\t" #endif "ADD r2, sp, #0x40\n\t" "ADD r1, sp, #0x60\n\t" @@ -3373,17 +3445,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_sq_op\n\t" "MOV r12, #0x9\n\t" "\n" - "L_curve25519_inv_2%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_2:\n\t" +#else + "L_curve25519_inv_2_%=:\n\t" +#endif "ADD r1, sp, #0x60\n\t" "ADD r0, sp, #0x60\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_2%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_2_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_2\n\t" #else - "BNE.N L_curve25519_inv_2%=\n\t" + "BNE.N L_curve25519_inv_2_%=\n\t" #endif "ADD r2, sp, #0x40\n\t" "ADD r1, sp, #0x60\n\t" @@ -3394,17 +3472,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_sq_op\n\t" "MOV r12, #0x13\n\t" "\n" - "L_curve25519_inv_3%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_3:\n\t" +#else + "L_curve25519_inv_3_%=:\n\t" +#endif "ADD r1, sp, #0x80\n\t" "ADD r0, sp, #0x80\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_3%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_3_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_3\n\t" #else - "BNE.N L_curve25519_inv_3%=\n\t" + "BNE.N L_curve25519_inv_3_%=\n\t" #endif "ADD r2, sp, #0x60\n\t" "ADD r1, sp, #0x80\n\t" @@ -3412,17 +3496,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_mul_op\n\t" "MOV r12, #0xa\n\t" "\n" - "L_curve25519_inv_4%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_4:\n\t" +#else + "L_curve25519_inv_4_%=:\n\t" +#endif "ADD r1, sp, #0x60\n\t" "ADD r0, sp, #0x60\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_4%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_4_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_4\n\t" #else - "BNE.N L_curve25519_inv_4%=\n\t" + "BNE.N L_curve25519_inv_4_%=\n\t" #endif "ADD r2, sp, #0x40\n\t" "ADD r1, sp, #0x60\n\t" @@ -3433,17 +3523,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_sq_op\n\t" "MOV r12, #0x31\n\t" "\n" - "L_curve25519_inv_5%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_5:\n\t" +#else + "L_curve25519_inv_5_%=:\n\t" +#endif "ADD r1, sp, #0x60\n\t" "ADD r0, sp, #0x60\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_5%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_5_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_5\n\t" #else - "BNE.N L_curve25519_inv_5%=\n\t" + "BNE.N L_curve25519_inv_5_%=\n\t" #endif "ADD r2, sp, #0x40\n\t" "ADD r1, sp, #0x60\n\t" @@ -3454,17 +3550,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_sq_op\n\t" "MOV r12, #0x63\n\t" "\n" - "L_curve25519_inv_6%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_6:\n\t" +#else + "L_curve25519_inv_6_%=:\n\t" +#endif "ADD r1, sp, #0x80\n\t" "ADD r0, sp, #0x80\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_6%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_6_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_6\n\t" #else - "BNE.N L_curve25519_inv_6%=\n\t" + "BNE.N L_curve25519_inv_6_%=\n\t" #endif "ADD r2, sp, #0x60\n\t" "ADD r1, sp, #0x80\n\t" @@ -3472,17 +3574,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_mul_op\n\t" "MOV r12, #0x32\n\t" "\n" - "L_curve25519_inv_7%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_7:\n\t" +#else + "L_curve25519_inv_7_%=:\n\t" +#endif "ADD r1, sp, #0x60\n\t" "ADD r0, sp, #0x60\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_7%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_7_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_7\n\t" #else - "BNE.N L_curve25519_inv_7%=\n\t" + "BNE.N L_curve25519_inv_7_%=\n\t" #endif "ADD r2, sp, #0x40\n\t" "ADD r1, sp, #0x60\n\t" @@ -3490,17 +3598,23 @@ int curve25519(byte* r, const byte* n, const byte* a) "BL fe_mul_op\n\t" "MOV r12, #0x5\n\t" "\n" - "L_curve25519_inv_8%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_curve25519_inv_8:\n\t" +#else + "L_curve25519_inv_8_%=:\n\t" +#endif "ADD r1, sp, #0x40\n\t" "ADD r0, sp, #0x40\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_curve25519_inv_8%=\n\t" +#if defined(__GNUC__) + "BNE L_curve25519_inv_8_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_curve25519_inv_8\n\t" #else - "BNE.N L_curve25519_inv_8%=\n\t" + "BNE.N L_curve25519_inv_8_%=\n\t" #endif "ADD r2, sp, #0x20\n\t" "ADD r1, sp, #0x40\n\t" @@ -3582,17 +3696,23 @@ void fe_invert(fe r, const fe a) "BL fe_sq_op\n\t" "MOV r12, #0x4\n\t" "\n" - "L_fe_invert1%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_invert1:\n\t" +#else + "L_fe_invert1_%=:\n\t" +#endif "ADD r1, sp, #0x40\n\t" "ADD r0, sp, #0x40\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_invert1%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_invert1_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_invert1\n\t" #else - "BNE.N L_fe_invert1%=\n\t" + "BNE.N L_fe_invert1_%=\n\t" #endif "ADD r2, sp, #0x20\n\t" "ADD r1, sp, #0x40\n\t" @@ -3603,17 +3723,23 @@ void fe_invert(fe r, const fe a) "BL fe_sq_op\n\t" "MOV r12, #0x9\n\t" "\n" - "L_fe_invert2%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_invert2:\n\t" +#else + "L_fe_invert2_%=:\n\t" +#endif "ADD r1, sp, #0x40\n\t" "ADD r0, sp, #0x40\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_invert2%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_invert2_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_invert2\n\t" #else - "BNE.N L_fe_invert2%=\n\t" + "BNE.N L_fe_invert2_%=\n\t" #endif "ADD r2, sp, #0x20\n\t" "ADD r1, sp, #0x40\n\t" @@ -3624,17 +3750,23 @@ void fe_invert(fe r, const fe a) "BL fe_sq_op\n\t" "MOV r12, #0x13\n\t" "\n" - "L_fe_invert3%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_invert3:\n\t" +#else + "L_fe_invert3_%=:\n\t" +#endif "ADD r1, sp, #0x60\n\t" "ADD r0, sp, #0x60\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_invert3%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_invert3_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_invert3\n\t" #else - "BNE.N L_fe_invert3%=\n\t" + "BNE.N L_fe_invert3_%=\n\t" #endif "ADD r2, sp, #0x40\n\t" "ADD r1, sp, #0x60\n\t" @@ -3642,17 +3774,23 @@ void fe_invert(fe r, const fe a) "BL fe_mul_op\n\t" "MOV r12, #0xa\n\t" "\n" - "L_fe_invert4%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_invert4:\n\t" +#else + "L_fe_invert4_%=:\n\t" +#endif "ADD r1, sp, #0x40\n\t" "ADD r0, sp, #0x40\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_invert4%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_invert4_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_invert4\n\t" #else - "BNE.N L_fe_invert4%=\n\t" + "BNE.N L_fe_invert4_%=\n\t" #endif "ADD r2, sp, #0x20\n\t" "ADD r1, sp, #0x40\n\t" @@ -3663,17 +3801,23 @@ void fe_invert(fe r, const fe a) "BL fe_sq_op\n\t" "MOV r12, #0x31\n\t" "\n" - "L_fe_invert5%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_invert5:\n\t" +#else + "L_fe_invert5_%=:\n\t" +#endif "ADD r1, sp, #0x40\n\t" "ADD r0, sp, #0x40\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_invert5%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_invert5_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_invert5\n\t" #else - "BNE.N L_fe_invert5%=\n\t" + "BNE.N L_fe_invert5_%=\n\t" #endif "ADD r2, sp, #0x20\n\t" "ADD r1, sp, #0x40\n\t" @@ -3684,17 +3828,23 @@ void fe_invert(fe r, const fe a) "BL fe_sq_op\n\t" "MOV r12, #0x63\n\t" "\n" - "L_fe_invert6%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_invert6:\n\t" +#else + "L_fe_invert6_%=:\n\t" +#endif "ADD r1, sp, #0x60\n\t" "ADD r0, sp, #0x60\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_invert6%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_invert6_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_invert6\n\t" #else - "BNE.N L_fe_invert6%=\n\t" + "BNE.N L_fe_invert6_%=\n\t" #endif "ADD r2, sp, #0x40\n\t" "ADD r1, sp, #0x60\n\t" @@ -3702,17 +3852,23 @@ void fe_invert(fe r, const fe a) "BL fe_mul_op\n\t" "MOV r12, #0x32\n\t" "\n" - "L_fe_invert7%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_invert7:\n\t" +#else + "L_fe_invert7_%=:\n\t" +#endif "ADD r1, sp, #0x40\n\t" "ADD r0, sp, #0x40\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_invert7%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_invert7_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_invert7\n\t" #else - "BNE.N L_fe_invert7%=\n\t" + "BNE.N L_fe_invert7_%=\n\t" #endif "ADD r2, sp, #0x20\n\t" "ADD r1, sp, #0x40\n\t" @@ -3720,17 +3876,23 @@ void fe_invert(fe r, const fe a) "BL fe_mul_op\n\t" "MOV r12, #0x5\n\t" "\n" - "L_fe_invert8%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_invert8:\n\t" +#else + "L_fe_invert8_%=:\n\t" +#endif "ADD r1, sp, #0x20\n\t" "ADD r0, sp, #0x20\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_invert8%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_invert8_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_invert8\n\t" #else - "BNE.N L_fe_invert8%=\n\t" + "BNE.N L_fe_invert8_%=\n\t" #endif "MOV r2, sp\n\t" "ADD r1, sp, #0x20\n\t" @@ -4268,17 +4430,23 @@ void fe_pow22523(fe r, const fe a) "BL fe_sq_op\n\t" "MOV r12, #0x4\n\t" "\n" - "L_fe_pow22523_1%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_pow22523_1:\n\t" +#else + "L_fe_pow22523_1_%=:\n\t" +#endif "ADD r1, sp, #0x20\n\t" "ADD r0, sp, #0x20\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_pow22523_1%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_pow22523_1_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_pow22523_1\n\t" #else - "BNE.N L_fe_pow22523_1%=\n\t" + "BNE.N L_fe_pow22523_1_%=\n\t" #endif "MOV r2, sp\n\t" "ADD r1, sp, #0x20\n\t" @@ -4289,17 +4457,23 @@ void fe_pow22523(fe r, const fe a) "BL fe_sq_op\n\t" "MOV r12, #0x9\n\t" "\n" - "L_fe_pow22523_2%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_pow22523_2:\n\t" +#else + "L_fe_pow22523_2_%=:\n\t" +#endif "ADD r1, sp, #0x20\n\t" "ADD r0, sp, #0x20\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_pow22523_2%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_pow22523_2_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_pow22523_2\n\t" #else - "BNE.N L_fe_pow22523_2%=\n\t" + "BNE.N L_fe_pow22523_2_%=\n\t" #endif "MOV r2, sp\n\t" "ADD r1, sp, #0x20\n\t" @@ -4310,17 +4484,23 @@ void fe_pow22523(fe r, const fe a) "BL fe_sq_op\n\t" "MOV r12, #0x13\n\t" "\n" - "L_fe_pow22523_3%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_pow22523_3:\n\t" +#else + "L_fe_pow22523_3_%=:\n\t" +#endif "ADD r1, sp, #0x40\n\t" "ADD r0, sp, #0x40\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_pow22523_3%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_pow22523_3_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_pow22523_3\n\t" #else - "BNE.N L_fe_pow22523_3%=\n\t" + "BNE.N L_fe_pow22523_3_%=\n\t" #endif "ADD r2, sp, #0x20\n\t" "ADD r1, sp, #0x40\n\t" @@ -4328,17 +4508,23 @@ void fe_pow22523(fe r, const fe a) "BL fe_mul_op\n\t" "MOV r12, #0xa\n\t" "\n" - "L_fe_pow22523_4%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_pow22523_4:\n\t" +#else + "L_fe_pow22523_4_%=:\n\t" +#endif "ADD r1, sp, #0x20\n\t" "ADD r0, sp, #0x20\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_pow22523_4%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_pow22523_4_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_pow22523_4\n\t" #else - "BNE.N L_fe_pow22523_4%=\n\t" + "BNE.N L_fe_pow22523_4_%=\n\t" #endif "MOV r2, sp\n\t" "ADD r1, sp, #0x20\n\t" @@ -4349,17 +4535,23 @@ void fe_pow22523(fe r, const fe a) "BL fe_sq_op\n\t" "MOV r12, #0x31\n\t" "\n" - "L_fe_pow22523_5%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_pow22523_5:\n\t" +#else + "L_fe_pow22523_5_%=:\n\t" +#endif "ADD r1, sp, #0x20\n\t" "ADD r0, sp, #0x20\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_pow22523_5%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_pow22523_5_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_pow22523_5\n\t" #else - "BNE.N L_fe_pow22523_5%=\n\t" + "BNE.N L_fe_pow22523_5_%=\n\t" #endif "MOV r2, sp\n\t" "ADD r1, sp, #0x20\n\t" @@ -4370,17 +4562,23 @@ void fe_pow22523(fe r, const fe a) "BL fe_sq_op\n\t" "MOV r12, #0x63\n\t" "\n" - "L_fe_pow22523_6%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_pow22523_6:\n\t" +#else + "L_fe_pow22523_6_%=:\n\t" +#endif "ADD r1, sp, #0x40\n\t" "ADD r0, sp, #0x40\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_pow22523_6%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_pow22523_6_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_pow22523_6\n\t" #else - "BNE.N L_fe_pow22523_6%=\n\t" + "BNE.N L_fe_pow22523_6_%=\n\t" #endif "ADD r2, sp, #0x20\n\t" "ADD r1, sp, #0x40\n\t" @@ -4388,17 +4586,23 @@ void fe_pow22523(fe r, const fe a) "BL fe_mul_op\n\t" "MOV r12, #0x32\n\t" "\n" - "L_fe_pow22523_7%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_pow22523_7:\n\t" +#else + "L_fe_pow22523_7_%=:\n\t" +#endif "ADD r1, sp, #0x20\n\t" "ADD r0, sp, #0x20\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_pow22523_7%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_pow22523_7_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_pow22523_7\n\t" #else - "BNE.N L_fe_pow22523_7%=\n\t" + "BNE.N L_fe_pow22523_7_%=\n\t" #endif "MOV r2, sp\n\t" "ADD r1, sp, #0x20\n\t" @@ -4406,17 +4610,23 @@ void fe_pow22523(fe r, const fe a) "BL fe_mul_op\n\t" "MOV r12, #0x2\n\t" "\n" - "L_fe_pow22523_8%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_fe_pow22523_8:\n\t" +#else + "L_fe_pow22523_8_%=:\n\t" +#endif "MOV r1, sp\n\t" "MOV r0, sp\n\t" "PUSH {r12}\n\t" "BL fe_sq_op\n\t" "POP {r12}\n\t" "SUBS r12, r12, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_fe_pow22523_8%=\n\t" +#if defined(__GNUC__) + "BNE L_fe_pow22523_8_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_fe_pow22523_8\n\t" #else - "BNE.N L_fe_pow22523_8%=\n\t" + "BNE.N L_fe_pow22523_8_%=\n\t" #endif "LDR r2, [sp, #100]\n\t" "MOV r1, sp\n\t" diff --git a/wolfcrypt/src/port/arm/thumb2-sha256-asm.S b/wolfcrypt/src/port/arm/thumb2-sha256-asm.S index 30d8dc76b5..4809afbc7d 100644 --- a/wolfcrypt/src/port/arm/thumb2-sha256-asm.S +++ b/wolfcrypt/src/port/arm/thumb2-sha256-asm.S @@ -1,6 +1,6 @@ /* thumb2-sha256-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -925,7 +925,7 @@ L_SHA256_transform_len_start: STR r9, [sp, #60] ADD r3, r3, #0x40 SUBS r12, r12, #0x1 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_SHA256_transform_len_start #else BNE.W L_SHA256_transform_len_start @@ -1470,7 +1470,7 @@ L_SHA256_transform_len_start: SUBS r2, r2, #0x40 SUB r3, r3, #0xc0 ADD r1, r1, #0x40 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_SHA256_transform_len_begin #else BNE.W L_SHA256_transform_len_begin diff --git a/wolfcrypt/src/port/arm/thumb2-sha256-asm_c.c b/wolfcrypt/src/port/arm/thumb2-sha256-asm_c.c index ed496b0b5a..903b58e3d0 100644 --- a/wolfcrypt/src/port/arm/thumb2-sha256-asm_c.c +++ b/wolfcrypt/src/port/arm/thumb2-sha256-asm_c.c @@ -1,6 +1,6 @@ /* thumb2-sha256-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -94,7 +94,11 @@ void Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, word32 len) "STRD r10, r11, [sp, #88]\n\t" /* Start of loop processing a block */ "\n" - "L_SHA256_transform_len_begin%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_SHA256_transform_len_begin:\n\t" +#else + "L_SHA256_transform_len_begin_%=:\n\t" +#endif /* Load, Reverse and Store W - 64 bytes */ "LDR r4, [%[data]]\n\t" "LDR r5, [%[data], #4]\n\t" @@ -142,7 +146,11 @@ void Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, word32 len) "MOV r12, #0x3\n\t" /* Start of 16 rounds */ "\n" - "L_SHA256_transform_len_start%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_SHA256_transform_len_start:\n\t" +#else + "L_SHA256_transform_len_start_%=:\n\t" +#endif /* Round 0 */ "LDR r5, [%[sha256], #16]\n\t" "LDR r6, [%[sha256], #20]\n\t" @@ -897,10 +905,12 @@ void Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, word32 len) "STR r9, [sp, #60]\n\t" "ADD r3, r3, #0x40\n\t" "SUBS r12, r12, #0x1\n\t" -#ifdef __GNUC__ - "BNE L_SHA256_transform_len_start%=\n\t" +#if defined(__GNUC__) + "BNE L_SHA256_transform_len_start_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_SHA256_transform_len_start\n\t" #else - "BNE.W L_SHA256_transform_len_start%=\n\t" + "BNE.W L_SHA256_transform_len_start_%=\n\t" #endif /* Round 0 */ "LDR r5, [%[sha256], #16]\n\t" @@ -1442,10 +1452,12 @@ void Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, word32 len) "SUBS %[len], %[len], #0x40\n\t" "SUB r3, r3, #0xc0\n\t" "ADD %[data], %[data], #0x40\n\t" -#ifdef __GNUC__ - "BNE L_SHA256_transform_len_begin%=\n\t" +#if defined(__GNUC__) + "BNE L_SHA256_transform_len_begin_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_SHA256_transform_len_begin\n\t" #else - "BNE.W L_SHA256_transform_len_begin%=\n\t" + "BNE.W L_SHA256_transform_len_begin_%=\n\t" #endif "ADD sp, sp, #0xc0\n\t" #ifndef WOLFSSL_NO_VAR_ASSIGN_REG diff --git a/wolfcrypt/src/port/arm/thumb2-sha3-asm.S b/wolfcrypt/src/port/arm/thumb2-sha3-asm.S index 1069055949..de12f723c0 100644 --- a/wolfcrypt/src/port/arm/thumb2-sha3-asm.S +++ b/wolfcrypt/src/port/arm/thumb2-sha3-asm.S @@ -1,6 +1,6 @@ /* thumb2-sha3-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -1157,7 +1157,7 @@ L_sha3_thumb2_begin: STR lr, [r0, #164] LDR r2, [sp, #200] SUBS r2, r2, #0x1 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_sha3_thumb2_begin #else BNE.W L_sha3_thumb2_begin diff --git a/wolfcrypt/src/port/arm/thumb2-sha3-asm_c.c b/wolfcrypt/src/port/arm/thumb2-sha3-asm_c.c index 53fa09646c..a22b9acc56 100644 --- a/wolfcrypt/src/port/arm/thumb2-sha3-asm_c.c +++ b/wolfcrypt/src/port/arm/thumb2-sha3-asm_c.c @@ -1,6 +1,6 @@ /* thumb2-sha3-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -77,7 +77,11 @@ void BlockSha3(word64* state) "MOV r1, %[L_sha3_thumb2_rt]\n\t" "MOV r2, #0xc\n\t" "\n" - "L_sha3_thumb2_begin%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sha3_thumb2_begin:\n\t" +#else + "L_sha3_thumb2_begin_%=:\n\t" +#endif "STR r2, [sp, #200]\n\t" /* Round even */ /* Calc b[4] */ @@ -1137,10 +1141,12 @@ void BlockSha3(word64* state) "STR lr, [%[state], #164]\n\t" "LDR r2, [sp, #200]\n\t" "SUBS r2, r2, #0x1\n\t" -#ifdef __GNUC__ - "BNE L_sha3_thumb2_begin%=\n\t" +#if defined(__GNUC__) + "BNE L_sha3_thumb2_begin_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_sha3_thumb2_begin\n\t" #else - "BNE.W L_sha3_thumb2_begin%=\n\t" + "BNE.W L_sha3_thumb2_begin_%=\n\t" #endif "ADD sp, sp, #0xcc\n\t" #ifndef WOLFSSL_NO_VAR_ASSIGN_REG diff --git a/wolfcrypt/src/port/arm/thumb2-sha512-asm.S b/wolfcrypt/src/port/arm/thumb2-sha512-asm.S index 4723ad6ac6..9170e9457f 100644 --- a/wolfcrypt/src/port/arm/thumb2-sha512-asm.S +++ b/wolfcrypt/src/port/arm/thumb2-sha512-asm.S @@ -1,6 +1,6 @@ /* thumb2-sha512-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -2319,7 +2319,7 @@ L_SHA512_transform_len_start: STRD r4, r5, [sp, #120] ADD r3, r3, #0x80 SUBS r12, r12, #0x1 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_SHA512_transform_len_start #else BNE.W L_SHA512_transform_len_start @@ -3656,7 +3656,7 @@ L_SHA512_transform_len_start: SUBS r2, r2, #0x80 SUB r3, r3, #0x200 ADD r1, r1, #0x80 -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) BNE L_SHA512_transform_len_begin #else BNE.W L_SHA512_transform_len_begin diff --git a/wolfcrypt/src/port/arm/thumb2-sha512-asm_c.c b/wolfcrypt/src/port/arm/thumb2-sha512-asm_c.c index 35363ba3aa..bd998025ad 100644 --- a/wolfcrypt/src/port/arm/thumb2-sha512-asm_c.c +++ b/wolfcrypt/src/port/arm/thumb2-sha512-asm_c.c @@ -1,6 +1,6 @@ /* thumb2-sha512-asm * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -126,7 +126,11 @@ void Transform_Sha512_Len(wc_Sha512* sha512, const byte* data, word32 len) "STRD r10, r11, [sp, #184]\n\t" /* Start of loop processing a block */ "\n" - "L_SHA512_transform_len_begin%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_SHA512_transform_len_begin:\n\t" +#else + "L_SHA512_transform_len_begin_%=:\n\t" +#endif /* Load, Reverse and Store W */ "LDR r4, [%[data]]\n\t" "LDR r5, [%[data], #4]\n\t" @@ -232,7 +236,11 @@ void Transform_Sha512_Len(wc_Sha512* sha512, const byte* data, word32 len) "MOV r12, #0x4\n\t" /* Start of 16 rounds */ "\n" - "L_SHA512_transform_len_start%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_SHA512_transform_len_start:\n\t" +#else + "L_SHA512_transform_len_start_%=:\n\t" +#endif /* Round 0 */ "LDRD r4, r5, [%[sha512], #32]\n\t" "LSRS r6, r4, #14\n\t" @@ -2219,10 +2227,12 @@ void Transform_Sha512_Len(wc_Sha512* sha512, const byte* data, word32 len) "STRD r4, r5, [sp, #120]\n\t" "ADD r3, r3, #0x80\n\t" "SUBS r12, r12, #0x1\n\t" -#ifdef __GNUC__ - "BNE L_SHA512_transform_len_start%=\n\t" +#if defined(__GNUC__) + "BNE L_SHA512_transform_len_start_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_SHA512_transform_len_start\n\t" #else - "BNE.W L_SHA512_transform_len_start%=\n\t" + "BNE.W L_SHA512_transform_len_start_%=\n\t" #endif /* Round 0 */ "LDRD r4, r5, [%[sha512], #32]\n\t" @@ -3556,10 +3566,12 @@ void Transform_Sha512_Len(wc_Sha512* sha512, const byte* data, word32 len) "SUBS %[len], %[len], #0x80\n\t" "SUB r3, r3, #0x200\n\t" "ADD %[data], %[data], #0x80\n\t" -#ifdef __GNUC__ - "BNE L_SHA512_transform_len_begin%=\n\t" +#if defined(__GNUC__) + "BNE L_SHA512_transform_len_begin_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.W L_SHA512_transform_len_begin\n\t" #else - "BNE.W L_SHA512_transform_len_begin%=\n\t" + "BNE.W L_SHA512_transform_len_begin_%=\n\t" #endif "EOR r0, r0, r0\n\t" "ADD sp, sp, #0xc0\n\t" diff --git a/wolfcrypt/src/port/atmel/atmel.c b/wolfcrypt/src/port/atmel/atmel.c index b3c6b7906c..31ad98fb45 100644 --- a/wolfcrypt/src/port/atmel/atmel.c +++ b/wolfcrypt/src/port/atmel/atmel.c @@ -1,6 +1,6 @@ /* atmel.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/autosar/cryif.c b/wolfcrypt/src/port/autosar/cryif.c index 0bd767b4b2..6fd9cc1a22 100644 --- a/wolfcrypt/src/port/autosar/cryif.c +++ b/wolfcrypt/src/port/autosar/cryif.c @@ -28,13 +28,15 @@ #endif #include + +#ifdef WOLFSSL_AUTOSAR +#ifndef NO_WOLFSSL_AUTOSAR_CRYIF + #include #include #include #include -#ifdef WOLFSSL_AUTOSAR -#ifndef NO_WOLFSSL_AUTOSAR_CRYIF #include diff --git a/wolfcrypt/src/port/autosar/crypto.c b/wolfcrypt/src/port/autosar/crypto.c index f7812f190c..d5a7509f6b 100644 --- a/wolfcrypt/src/port/autosar/crypto.c +++ b/wolfcrypt/src/port/autosar/crypto.c @@ -25,12 +25,12 @@ #endif #include -#include -#include #ifdef WOLFSSL_AUTOSAR #ifndef NO_WOLFSSL_AUTOSAR_CRYPTO +#include +#include #include #include #include diff --git a/wolfcrypt/src/port/autosar/csm.c b/wolfcrypt/src/port/autosar/csm.c index f5df124b9a..8fa6063a71 100644 --- a/wolfcrypt/src/port/autosar/csm.c +++ b/wolfcrypt/src/port/autosar/csm.c @@ -25,14 +25,15 @@ #endif #include + +#ifdef WOLFSSL_AUTOSAR +#ifndef NO_WOLFSSL_AUTOSAR_CSM + #include #include #include #include -#ifdef WOLFSSL_AUTOSAR -#ifndef NO_WOLFSSL_AUTOSAR_CSM - /* AutoSAR 4.4 */ /* basic shim layer to plug in wolfSSL crypto */ diff --git a/wolfcrypt/src/port/autosar/test.c b/wolfcrypt/src/port/autosar/test.c index 4c311f189f..29cd8fc3e2 100644 --- a/wolfcrypt/src/port/autosar/test.c +++ b/wolfcrypt/src/port/autosar/test.c @@ -24,6 +24,9 @@ #endif #include + +#ifdef WOLFSSL_AUTOSAR + #include #include #define BLOCK_SIZE 16 @@ -428,3 +431,5 @@ int main(int argc, char* argv[]) #endif /* REDIRECTION_CONFIG */ return ret; } + +#endif /* WOLFSSL_AUTOSAR */ diff --git a/wolfcrypt/src/port/caam/caam_aes.c b/wolfcrypt/src/port/caam/caam_aes.c index 56efdacf10..b744c12447 100644 --- a/wolfcrypt/src/port/caam/caam_aes.c +++ b/wolfcrypt/src/port/caam/caam_aes.c @@ -1,6 +1,6 @@ /* caam_aes.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/caam_driver.c b/wolfcrypt/src/port/caam/caam_driver.c index e0007c9cb7..c0c212fb91 100644 --- a/wolfcrypt/src/port/caam/caam_driver.c +++ b/wolfcrypt/src/port/caam/caam_driver.c @@ -1,6 +1,6 @@ /* caam_driver.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/caam_error.c b/wolfcrypt/src/port/caam/caam_error.c index 00830520f3..d1ae990614 100644 --- a/wolfcrypt/src/port/caam/caam_error.c +++ b/wolfcrypt/src/port/caam/caam_error.c @@ -1,6 +1,6 @@ /* caam_error.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/caam_integrity.c b/wolfcrypt/src/port/caam/caam_integrity.c index b520d61464..bbe4dcef9f 100644 --- a/wolfcrypt/src/port/caam/caam_integrity.c +++ b/wolfcrypt/src/port/caam/caam_integrity.c @@ -1,6 +1,6 @@ /* caam_integrity.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/caam_qnx.c b/wolfcrypt/src/port/caam/caam_qnx.c index 0c2525743a..0c5e407a6a 100644 --- a/wolfcrypt/src/port/caam/caam_qnx.c +++ b/wolfcrypt/src/port/caam/caam_qnx.c @@ -1,6 +1,6 @@ /* caam_qnx.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/caam_sha.c b/wolfcrypt/src/port/caam/caam_sha.c index 03ef6e0c5e..6964a3c4cb 100644 --- a/wolfcrypt/src/port/caam/caam_sha.c +++ b/wolfcrypt/src/port/caam/caam_sha.c @@ -1,6 +1,6 @@ /* caam_sha.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/wolfcaam_aes.c b/wolfcrypt/src/port/caam/wolfcaam_aes.c index 73b82426d2..02930c64bd 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_aes.c +++ b/wolfcrypt/src/port/caam/wolfcaam_aes.c @@ -1,6 +1,6 @@ /* wolfcaam_aes.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/wolfcaam_cmac.c b/wolfcrypt/src/port/caam/wolfcaam_cmac.c index 737f19da01..28a7e9821b 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_cmac.c +++ b/wolfcrypt/src/port/caam/wolfcaam_cmac.c @@ -1,6 +1,6 @@ /* wolfcaam_cmac.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/wolfcaam_ecdsa.c b/wolfcrypt/src/port/caam/wolfcaam_ecdsa.c index c84b0807af..e9f55f21e7 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_ecdsa.c +++ b/wolfcrypt/src/port/caam/wolfcaam_ecdsa.c @@ -1,6 +1,6 @@ /* wolfcaam_ecdsa.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c b/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c index 848d682598..a9f574559e 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c +++ b/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c @@ -1,6 +1,6 @@ /* wolfcaam_fsl_nxp.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/wolfcaam_hash.c b/wolfcrypt/src/port/caam/wolfcaam_hash.c index f64a29d9ef..c05b40b99d 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_hash.c +++ b/wolfcrypt/src/port/caam/wolfcaam_hash.c @@ -1,6 +1,6 @@ /* wolfcaam_hash.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/wolfcaam_hmac.c b/wolfcrypt/src/port/caam/wolfcaam_hmac.c index 947a742956..95d6a04eae 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_hmac.c +++ b/wolfcrypt/src/port/caam/wolfcaam_hmac.c @@ -1,6 +1,6 @@ /* wolfcaam_hmac.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/wolfcaam_init.c b/wolfcrypt/src/port/caam/wolfcaam_init.c index 94f2aea732..3abb4d9226 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_init.c +++ b/wolfcrypt/src/port/caam/wolfcaam_init.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/wolfcaam_qnx.c b/wolfcrypt/src/port/caam/wolfcaam_qnx.c index 23db33c965..a6bebbc6e2 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_qnx.c +++ b/wolfcrypt/src/port/caam/wolfcaam_qnx.c @@ -1,6 +1,6 @@ /* wolfcaam_qnx.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/wolfcaam_rsa.c b/wolfcrypt/src/port/caam/wolfcaam_rsa.c index f035a0b70b..ac824ecec2 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_rsa.c +++ b/wolfcrypt/src/port/caam/wolfcaam_rsa.c @@ -1,6 +1,6 @@ /* wolfcaam_rsa.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/wolfcaam_seco.c b/wolfcrypt/src/port/caam/wolfcaam_seco.c index 8326f308f2..995826c238 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_seco.c +++ b/wolfcrypt/src/port/caam/wolfcaam_seco.c @@ -1,6 +1,6 @@ /* wolfcaam_seco.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/caam/wolfcaam_x25519.c b/wolfcrypt/src/port/caam/wolfcaam_x25519.c index 6147380250..9ead7b4092 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_x25519.c +++ b/wolfcrypt/src/port/caam/wolfcaam_x25519.c @@ -1,6 +1,6 @@ /* wolfcaam_x25519.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/cavium/cavium_octeon_sync.c b/wolfcrypt/src/port/cavium/cavium_octeon_sync.c index d498022a65..d16768796c 100644 --- a/wolfcrypt/src/port/cavium/cavium_octeon_sync.c +++ b/wolfcrypt/src/port/cavium/cavium_octeon_sync.c @@ -1,6 +1,6 @@ /* cavium_octeon_sync.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/cuda/aes-cuda.cu b/wolfcrypt/src/port/cuda/aes-cuda.cu index 0fec5d35c4..1fc462188c 100644 --- a/wolfcrypt/src/port/cuda/aes-cuda.cu +++ b/wolfcrypt/src/port/cuda/aes-cuda.cu @@ -1,6 +1,6 @@ /* aes.cu * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/cypress/psoc6_crypto.c b/wolfcrypt/src/port/cypress/psoc6_crypto.c index 15f3d207cc..d9fc620305 100644 --- a/wolfcrypt/src/port/cypress/psoc6_crypto.c +++ b/wolfcrypt/src/port/cypress/psoc6_crypto.c @@ -1,6 +1,6 @@ /* psoc6_crypto.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/devcrypto/devcrypto_aes.c b/wolfcrypt/src/port/devcrypto/devcrypto_aes.c index 18f5cd7a34..ba12d2583b 100644 --- a/wolfcrypt/src/port/devcrypto/devcrypto_aes.c +++ b/wolfcrypt/src/port/devcrypto/devcrypto_aes.c @@ -1,6 +1,6 @@ /* devcrypto_aes.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/devcrypto/devcrypto_ecdsa.c b/wolfcrypt/src/port/devcrypto/devcrypto_ecdsa.c index 7a8c1d174e..b2c07a2ddb 100644 --- a/wolfcrypt/src/port/devcrypto/devcrypto_ecdsa.c +++ b/wolfcrypt/src/port/devcrypto/devcrypto_ecdsa.c @@ -1,6 +1,6 @@ /* devcrypto_ecdsa.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/devcrypto/devcrypto_hash.c b/wolfcrypt/src/port/devcrypto/devcrypto_hash.c index e3268a5e6e..6b8f5a86fa 100644 --- a/wolfcrypt/src/port/devcrypto/devcrypto_hash.c +++ b/wolfcrypt/src/port/devcrypto/devcrypto_hash.c @@ -1,6 +1,6 @@ /* devcrypto_hash.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/devcrypto/devcrypto_hmac.c b/wolfcrypt/src/port/devcrypto/devcrypto_hmac.c index 70d428a969..e1044372ec 100644 --- a/wolfcrypt/src/port/devcrypto/devcrypto_hmac.c +++ b/wolfcrypt/src/port/devcrypto/devcrypto_hmac.c @@ -1,6 +1,6 @@ /* devcrypto_hmac.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/devcrypto/devcrypto_rsa.c b/wolfcrypt/src/port/devcrypto/devcrypto_rsa.c index d7221ee69a..0fdfd015e0 100644 --- a/wolfcrypt/src/port/devcrypto/devcrypto_rsa.c +++ b/wolfcrypt/src/port/devcrypto/devcrypto_rsa.c @@ -1,6 +1,6 @@ /* devcrypto_rsa.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/devcrypto/devcrypto_x25519.c b/wolfcrypt/src/port/devcrypto/devcrypto_x25519.c index 66e3bdc398..3e2a525642 100644 --- a/wolfcrypt/src/port/devcrypto/devcrypto_x25519.c +++ b/wolfcrypt/src/port/devcrypto/devcrypto_x25519.c @@ -1,6 +1,6 @@ /* devcrypto_x25519.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/devcrypto/wc_devcrypto.c b/wolfcrypt/src/port/devcrypto/wc_devcrypto.c index 0b3eedbf73..950e6c26c4 100644 --- a/wolfcrypt/src/port/devcrypto/wc_devcrypto.c +++ b/wolfcrypt/src/port/devcrypto/wc_devcrypto.c @@ -1,6 +1,6 @@ /* wc_devcrypto.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/intel/quickassist_sync.c b/wolfcrypt/src/port/intel/quickassist_sync.c index 1a6a33e5b6..c8b5c4191d 100644 --- a/wolfcrypt/src/port/intel/quickassist_sync.c +++ b/wolfcrypt/src/port/intel/quickassist_sync.c @@ -1,6 +1,6 @@ /* quickassist_sync.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/iotsafe/iotsafe.c b/wolfcrypt/src/port/iotsafe/iotsafe.c index 0e7537a1a6..19879cff47 100644 --- a/wolfcrypt/src/port/iotsafe/iotsafe.c +++ b/wolfcrypt/src/port/iotsafe/iotsafe.c @@ -1,6 +1,6 @@ /* iotsafe.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/kcapi/kcapi_aes.c b/wolfcrypt/src/port/kcapi/kcapi_aes.c index 1f1aa03f4c..4ed6f9e3bd 100644 --- a/wolfcrypt/src/port/kcapi/kcapi_aes.c +++ b/wolfcrypt/src/port/kcapi/kcapi_aes.c @@ -1,6 +1,6 @@ /* kcapi_aes.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/kcapi/kcapi_dh.c b/wolfcrypt/src/port/kcapi/kcapi_dh.c index 7989e5f55e..65f592a385 100644 --- a/wolfcrypt/src/port/kcapi/kcapi_dh.c +++ b/wolfcrypt/src/port/kcapi/kcapi_dh.c @@ -1,6 +1,6 @@ /* kcapi_dh.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/kcapi/kcapi_ecc.c b/wolfcrypt/src/port/kcapi/kcapi_ecc.c index 1f66b5222a..3be5b76bbf 100644 --- a/wolfcrypt/src/port/kcapi/kcapi_ecc.c +++ b/wolfcrypt/src/port/kcapi/kcapi_ecc.c @@ -1,6 +1,6 @@ /* kcapi_ecc.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/kcapi/kcapi_hash.c b/wolfcrypt/src/port/kcapi/kcapi_hash.c index f4a3b43c09..1c88f356f3 100644 --- a/wolfcrypt/src/port/kcapi/kcapi_hash.c +++ b/wolfcrypt/src/port/kcapi/kcapi_hash.c @@ -1,6 +1,6 @@ /* kcapi_hash.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/kcapi/kcapi_hmac.c b/wolfcrypt/src/port/kcapi/kcapi_hmac.c index 0a5d467515..7cdba82541 100644 --- a/wolfcrypt/src/port/kcapi/kcapi_hmac.c +++ b/wolfcrypt/src/port/kcapi/kcapi_hmac.c @@ -1,6 +1,6 @@ /* kcapi_hmac.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/kcapi/kcapi_rsa.c b/wolfcrypt/src/port/kcapi/kcapi_rsa.c index cafca14e70..19436aec1e 100644 --- a/wolfcrypt/src/port/kcapi/kcapi_rsa.c +++ b/wolfcrypt/src/port/kcapi/kcapi_rsa.c @@ -1,6 +1,6 @@ /* kcapi_rsa.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/liboqs/liboqs.c b/wolfcrypt/src/port/liboqs/liboqs.c index 19b32cdce7..2b2de87731 100644 --- a/wolfcrypt/src/port/liboqs/liboqs.c +++ b/wolfcrypt/src/port/liboqs/liboqs.c @@ -1,6 +1,6 @@ /* liboqs.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/maxim/maxq10xx.c b/wolfcrypt/src/port/maxim/maxq10xx.c index 47393d07c8..7d69a72331 100644 --- a/wolfcrypt/src/port/maxim/maxq10xx.c +++ b/wolfcrypt/src/port/maxim/maxq10xx.c @@ -1,6 +1,6 @@ /* maxq10xx.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/mynewt/mynewt_port.c b/wolfcrypt/src/port/mynewt/mynewt_port.c index 0467773c4b..06d28ddc9c 100644 --- a/wolfcrypt/src/port/mynewt/mynewt_port.c +++ b/wolfcrypt/src/port/mynewt/mynewt_port.c @@ -1,6 +1,6 @@ /* mynewt_port.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/nrf51.c b/wolfcrypt/src/port/nrf51.c index 1ab5b7dfe9..04da175584 100644 --- a/wolfcrypt/src/port/nrf51.c +++ b/wolfcrypt/src/port/nrf51.c @@ -1,6 +1,6 @@ /* nrf51.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/nxp/dcp_port.c b/wolfcrypt/src/port/nxp/dcp_port.c index f78f1d697c..ac4554ff7c 100644 --- a/wolfcrypt/src/port/nxp/dcp_port.c +++ b/wolfcrypt/src/port/nxp/dcp_port.c @@ -1,6 +1,6 @@ /* dcp_port.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/nxp/ksdk_port.c b/wolfcrypt/src/port/nxp/ksdk_port.c index b63864b0bd..a3bdbaa74f 100644 --- a/wolfcrypt/src/port/nxp/ksdk_port.c +++ b/wolfcrypt/src/port/nxp/ksdk_port.c @@ -1,6 +1,6 @@ /* ksdk_port.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/nxp/se050_port.c b/wolfcrypt/src/port/nxp/se050_port.c index ad526778a5..e54014bfb0 100644 --- a/wolfcrypt/src/port/nxp/se050_port.c +++ b/wolfcrypt/src/port/nxp/se050_port.c @@ -1,6 +1,6 @@ /* se050_port.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/pic32/pic32mz-crypt.c b/wolfcrypt/src/port/pic32/pic32mz-crypt.c index 171fe0aac2..b9cdb7c551 100644 --- a/wolfcrypt/src/port/pic32/pic32mz-crypt.c +++ b/wolfcrypt/src/port/pic32/pic32mz-crypt.c @@ -1,6 +1,6 @@ /* pic32mz-crypt.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/psa/psa.c b/wolfcrypt/src/port/psa/psa.c index 860f5c4891..737083f6af 100644 --- a/wolfcrypt/src/port/psa/psa.c +++ b/wolfcrypt/src/port/psa/psa.c @@ -1,6 +1,6 @@ /* psa.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/psa/psa_aes.c b/wolfcrypt/src/port/psa/psa_aes.c index a0881d4516..37f9952e80 100644 --- a/wolfcrypt/src/port/psa/psa_aes.c +++ b/wolfcrypt/src/port/psa/psa_aes.c @@ -1,6 +1,6 @@ /* psa_aes.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/psa/psa_hash.c b/wolfcrypt/src/port/psa/psa_hash.c index 7de9776fba..c45ccda284 100644 --- a/wolfcrypt/src/port/psa/psa_hash.c +++ b/wolfcrypt/src/port/psa/psa_hash.c @@ -1,6 +1,6 @@ /* psa_hash.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/psa/psa_pkcbs.c b/wolfcrypt/src/port/psa/psa_pkcbs.c index 6a7452cb39..a634b52a01 100644 --- a/wolfcrypt/src/port/psa/psa_pkcbs.c +++ b/wolfcrypt/src/port/psa/psa_pkcbs.c @@ -1,6 +1,6 @@ /* psa_pkcbs.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/riscv/riscv-64-aes.c b/wolfcrypt/src/port/riscv/riscv-64-aes.c index 3a8a2bc742..292c854d18 100644 --- a/wolfcrypt/src/port/riscv/riscv-64-aes.c +++ b/wolfcrypt/src/port/riscv/riscv-64-aes.c @@ -56,24 +56,8 @@ static WC_INLINE void memcpy16(byte* out, const byte* in) out64[1] = in64[1]; } -#ifdef WOLFSSL_RISCV_BASE_BIT_MANIPULATION - -/* Reverse bytes in 64-bit register. */ -#define REV8(rd, rs) \ - ASM_WORD((0b011010111000 << 20) | (0b101 << 12) | \ - (0b0010011 << 0) | \ - (rs << 15) | (rd << 7)) - -#endif /* WOLFSSL_RISCV_BASE_BIT_MANIPULATION */ - #ifdef WOLFSSL_RISCV_BIT_MANIPULATION -/* rd = rs1[0..31] | rs2[0..31]. */ -#define PACK(rd, rs1, rs2) \ - ASM_WORD((0b0000100 << 25) | (0b100 << 12) | \ - (0b0110011 << 0) | \ - (rs2 << 20) | (rs1 << 15) | (rd << 7)) - /* Reverse bits in each byte of 64-bit register. */ #define BREV8(rd, rs) \ ASM_WORD(0b01101000011100000101000000010011 | \ @@ -90,66 +74,6 @@ static WC_INLINE void memcpy16(byte* out, const byte* in) (vs2 << 20) | (vd << 7)) #endif -/* vd = vs2 + [i,] */ -#define VADD_VI(vd, vs2, i) \ - ASM_WORD((0b000000 << 26) | (0b1 << 25) | \ - (0b011 << 12) | (0b1010111 << 0) | \ - (vd << 7) | (i << 15) | (vs2 << 20)) -/* vd = vs1 + vs2 */ -#define VADD_VV(vd, vs1, vs2) \ - ASM_WORD((0b000000 << 26) | (0b1 << 25) | \ - (0b000 << 12) | (0b1010111 << 0) | \ - (vs2 << 20) | (vs1 << 15) | (vd << 7)) -/* vd = vs1 ^ vs2 */ -#define VXOR_VV(vd, vs1, vs2) \ - ASM_WORD((0b001011 << 26) | (0b1 << 25) | \ - (0b000 << 12) | (0b1010111 << 0) | \ - (vd << 7) | (vs1 << 15) | (vs2 << 20)) -/* vd = vs1 & vs2 */ -#define VAND_VV(vd, vs1, vs2) \ - ASM_WORD((0b001001 << 26) | (0b1 << 25) | \ - (0b000 << 12) | (0b1010111 << 0) | \ - (vd << 7) | (vs1 << 15) | (vs2 << 20)) -/* vd = vs1 | vs2 */ -#define VOR_VV(vd, vs1, vs2) \ - ASM_WORD((0b001010 << 26) | (0b1 << 25) | \ - (0b000 << 12) | (0b1010111 << 0) | \ - (vd << 7) | (vs1 << 15) | (vs2 << 20)) - -/* vd = vs2 << uimm */ -#define VSLL_VI(vd, vs2, uimm) \ - ASM_WORD((0b100101 << 26) | (0b1 << 25) | \ - (0b011 << 12) | (0b1010111 << 0) | \ - (vd << 7) | (uimm << 15) | (vs2 << 20)) -/* vd = vs2 >> uimm */ -#define VSRL_VI(vd, vs2, uimm) \ - ASM_WORD((0b101000 << 26) | (0b1 << 25) | \ - (0b011 << 12) | (0b1010111 << 0) | \ - (vd << 7) | (uimm << 15) | (vs2 << 20)) - -/* vd[shift..max] = vs2[0..max-shift] */ -#define VSLIDEUP_VI(vd, vs2, shift) \ - ASM_WORD((0b001110 << 26) | (0b1 << 25) | \ - (0b011 << 12) | (0b1010111 << 0) | \ - (vd << 7) | (shift << 15) | (vs2 << 20)) - -/* vd[0..max-shift] = vs2[shift..max] */ -#define VSLIDEDOWN_VI(vd, vs2, shift) \ - ASM_WORD((0b001111 << 26) | (0b1 << 25) | \ - (0b011 << 12) | (0b1010111 << 0) | \ - (vd << 7) | (shift << 15) | (vs2 << 20)) - -/* vd[i] = vs1[vs2[i] */ -#define VRGATHER_VV(vd, vs1, vs2) \ - ASM_WORD((0b001100 << 26) | (0b1 << 25) | \ - (0b000 << 12) | (0b1010111 << 0) | \ - (vd << 7) | (vs1 << 15) | (vs2 << 20)) - -/* Reverse order of bytes in words of vector regsiter. */ -#define VREV8(vd, vs2) \ - ASM_WORD((0b010010 << 26) | (0b1 << 25) | (0b01001<< 15) | \ - (0b010 << 12) | (0b1010111 << 0) | \ - (vs2 << 20) | (vd << 7)) /* Vector register set if equal: vd[i] = vs1[i] == vs2[i] ? 1 : 0 */ #define VMSEQ_VV(vd, vs1, vs2) \ @@ -169,60 +93,6 @@ static WC_INLINE void memcpy16(byte* out, const byte* in) (0b010 << 12) | (0b1010111 << 0) | \ (vs2 << 20) | (rd << 7)) -/* 64-bit width when loading. */ -#define WIDTH_64 0b111 -/* 32-bit width when loading. */ -#define WIDTH_32 0b110 - -/* Load n Vector registers with width-bit components. */ -#define VLRE_V(vd, rs1, cnt, width) \ - ASM_WORD(0b0000111 | (width << 12) | (0b00101000 << 20) | \ - (0 << 28) | ((cnt - 1) << 29) | (vd << 7) | (rs1 << 15)) -/* Load 1 Vector register with 64-bit components. */ -#define VL1RE64_V(vd, rs1) VLRE_V(vd, rs1, 1, WIDTH_64) -/* Load 1 Vector register with 32-bit components. */ -#define VL1RE32_V(vd, rs1) VLRE_V(vd, rs1, 1, WIDTH_32) -/* Load 2 Vector register with 32-bit components. */ -#define VL2RE32_V(vd, rs1) VLRE_V(vd, rs1, 2, WIDTH_32) -/* Load 4 Vector register with 32-bit components. */ -#define VL4RE32_V(vd, rs1) VLRE_V(vd, rs1, 4, WIDTH_32) -/* Load 8 Vector register with 32-bit components. */ -#define VL8RE32_V(vd, rs1) VLRE_V(vd, rs1, 8, WIDTH_32) - -/* Store n Vector register. */ -#define VSR_V(vs3, rs1, cnt) \ - ASM_WORD(0b0100111 | (0b00101000 << 20) | (0 << 28) | \ - ((cnt-1) << 29) | (vs3 << 7) | (rs1 << 15)) -/* Store 1 Vector register. */ -#define VS1R_V(vs3, rs1) VSR_V(vs3, rs1, 1) -/* Store 2 Vector register. */ -#define VS2R_V(vs3, rs1) VSR_V(vs3, rs1, 2) -/* Store 4 Vector register. */ -#define VS4R_V(vs3, rs1) VSR_V(vs3, rs1, 4) -/* Store 8 Vector register. */ -#define VS8R_V(vs3, rs1) VSR_V(vs3, rs1, 8) - -/* Move from vector register to vector registor. */ -#define VMV_V_V(vd, vs1) \ - ASM_WORD((0b1010111 << 0) | (0b000 << 12) | (0b1 << 25) | \ - (0b010111 << 26) | (vd << 7) | (vs1 << 15)) -/* Splat register to each component of the vector registor. */ -#define VMV_V_X(vd, rs1) \ - ASM_WORD((0b1010111 << 0) | (0b100 << 12) | (0b1 << 25) | \ - (0b010111 << 26) | (vd << 7) | (rs1 << 15)) -/* Move n vector registers to vector registers. */ -#define VMVR_V(vd, vs2, n) \ - ASM_WORD((0b1010111 << 0) | (0b011 << 12) | (0b1 << 25) | \ - (0b100111 << 26) | (vd << 7) | ((n-1) << 15) | \ - (vs2 << 20)) - -/* Set the options of vector instructions. */ -#define VSETIVLI(rd, n, vma, vta, vsew, vlmul) \ - ASM_WORD((0b11 << 30) | (0b111 << 12) | (0b1010111 << 0) | \ - (rd << 7) | (n << 15) | (vma << 27) | \ - (vta << 26) | (vsew << 23) | (vlmul << 20)) - - #if defined(WOLFSSL_RISCV_VECTOR_CRYPTO_ASM) /* diff --git a/wolfcrypt/src/port/riscv/riscv-64-chacha.c b/wolfcrypt/src/port/riscv/riscv-64-chacha.c new file mode 100644 index 0000000000..a1195713d1 --- /dev/null +++ b/wolfcrypt/src/port/riscv/riscv-64-chacha.c @@ -0,0 +1,2374 @@ +/* riscv-64-chacha.c + * + * Copyright (C) 2006-2024 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ + +/* The paper NEON crypto by Daniel J. Bernstein and Peter Schwabe was used to + * optimize for ARM: + * https://cryptojedi.org/papers/veccrypto-20120320.pdf + */ + +#ifdef HAVE_CONFIG_H + #include +#endif + +#include +#include + +#ifdef WOLFSSL_RISCV_ASM +#ifdef HAVE_CHACHA + +#include +#include +#include +#include +#ifdef NO_INLINE + #include +#else + #define WOLFSSL_MISC_INCLUDED + #include +#endif + +#ifdef CHACHA_AEAD_TEST + #include +#endif + +#ifdef CHACHA_TEST + #include +#endif + +/* Number of rounds */ +#define ROUNDS 20 + +#define U32C(v) (v##U) +#define U32V(v) ((word32)(v) & U32C(0xFFFFFFFF)) +#define U8TO32_LITTLE(p) (((word32*)(p))[0]) + +#define PLUS(v,w) (U32V((v) + (w))) +#define PLUSONE(v) (PLUS((v),1)) + +#define ARM_SIMD_LEN_BYTES 16 + +/** + * Set up iv(nonce). Earlier versions used 64 bits instead of 96, this version + * uses the typical AEAD 96 bit nonce and can do record sizes of 256 GB. + */ +int wc_Chacha_SetIV(ChaCha* ctx, const byte* inIv, word32 counter) +{ + word32 temp[CHACHA_IV_WORDS];/* used for alignment of memory */ + + if (ctx == NULL) + return BAD_FUNC_ARG; + + XMEMCPY(temp, inIv, CHACHA_IV_BYTES); + + ctx->left = 0; + ctx->X[CHACHA_IV_BYTES+0] = counter; /* block counter */ + ctx->X[CHACHA_IV_BYTES+1] = temp[0]; /* fixed variable from nonce */ + ctx->X[CHACHA_IV_BYTES+2] = temp[1]; /* counter from nonce */ + ctx->X[CHACHA_IV_BYTES+3] = temp[2]; /* counter from nonce */ + + return 0; +} + +/* "expand 32-byte k" as unsigned 32 byte */ +static const word32 sigma[4] = {0x61707865, 0x3320646e, 0x79622d32, 0x6b206574}; +/* "expand 16-byte k" as unsigned 16 byte */ +static const word32 tau[4] = {0x61707865, 0x3120646e, 0x79622d36, 0x6b206574}; + +/** + * Key setup. 8 word iv (nonce) + */ +int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz) +{ + const word32* constants; + const byte* k; + +#ifdef XSTREAM_ALIGN + word32 alignKey[8]; +#endif + + if (ctx == NULL) + return BAD_FUNC_ARG; + + if (keySz != (CHACHA_MAX_KEY_SZ/2) && keySz != CHACHA_MAX_KEY_SZ) + return BAD_FUNC_ARG; + +#ifdef XSTREAM_ALIGN + if ((wc_ptr_t)key % 4) { + WOLFSSL_MSG("wc_ChachaSetKey unaligned key"); + XMEMCPY(alignKey, key, keySz); + k = (byte*)alignKey; + } + else { + k = key; + } +#else + k = key; +#endif /* XSTREAM_ALIGN */ + + ctx->X[4] = U8TO32_LITTLE(k + 0); + ctx->X[5] = U8TO32_LITTLE(k + 4); + ctx->X[6] = U8TO32_LITTLE(k + 8); + ctx->X[7] = U8TO32_LITTLE(k + 12); + if (keySz == CHACHA_MAX_KEY_SZ) { + k += 16; + constants = sigma; + } + else { + constants = tau; + } + ctx->X[ 8] = U8TO32_LITTLE(k + 0); + ctx->X[ 9] = U8TO32_LITTLE(k + 4); + ctx->X[10] = U8TO32_LITTLE(k + 8); + ctx->X[11] = U8TO32_LITTLE(k + 12); + ctx->X[ 0] = constants[0]; + ctx->X[ 1] = constants[1]; + ctx->X[ 2] = constants[2]; + ctx->X[ 3] = constants[3]; + ctx->left = 0; + + return 0; +} + + +#define CC_A0 "a4" +#define CC_A1 "a5" +#define CC_A2 "a6" +#define CC_A3 "a7" +#define CC_B0 "t3" +#define CC_B1 "t4" +#define CC_B2 "t5" +#define CC_B3 "t6" +#define CC_C0 "s2" +#define CC_C1 "s3" +#define CC_C2 "s4" +#define CC_C3 "s5" +#define CC_D0 "s6" +#define CC_D1 "s7" +#define CC_D2 "s8" +#define CC_D3 "s9" +#define CC_T0 "t0" +#define CC_T1 "t1" +#define CC_T2 "t2" +#define CC_T3 "s1" + +#if defined(WOLFSSL_RISCV_VECTOR) + +static const word32 L_chacha20_vec_inc_first_word[] = { + 0x1, + 0x0, + 0x0, + 0x0, +}; + +#ifndef WOLFSSL_RISCV_VECTOR_BASE_BIT_MANIPULATION + +#define PART_ROUND_ODD_ABD_5(s, sr) \ + VADD_VV(REG_V0, REG_V0, REG_V1) \ + "add " CC_A0 ", " CC_A0 ", " CC_B0 "\n\t" \ + VADD_VV(REG_V4, REG_V4, REG_V5) \ + "add " CC_A1 ", " CC_A1 ", " CC_B1 "\n\t" \ + VADD_VV(REG_V8, REG_V8, REG_V9) \ + "add " CC_A2 ", " CC_A2 ", " CC_B2 "\n\t" \ + VADD_VV(REG_V12, REG_V12, REG_V13) \ + "add " CC_A3 ", " CC_A3 ", " CC_B3 "\n\t" \ + VADD_VV(REG_V16, REG_V16, REG_V17) \ + VXOR_VV(REG_V3, REG_V3, REG_V0) \ + "xor " CC_D0 ", " CC_D0 ", " CC_A0 "\n\t" \ + VXOR_VV(REG_V7, REG_V7, REG_V4) \ + "xor " CC_D1 ", " CC_D1 ", " CC_A1 "\n\t" \ + VXOR_VV(REG_V11, REG_V11, REG_V8) \ + "xor " CC_D2 ", " CC_D2 ", " CC_A2 "\n\t" \ + VXOR_VV(REG_V15, REG_V15, REG_V12) \ + "xor " CC_D3 ", " CC_D3 ", " CC_A3 "\n\t" \ + VXOR_VV(REG_V19, REG_V19, REG_V16) \ + VSLL_VI(REG_V20, REG_V3, s) \ + "slli " CC_T0 ", " CC_D0 ", " #s "\n\t" \ + VSLL_VI(REG_V21, REG_V7, s) \ + "slli " CC_T1 ", " CC_D1 ", " #s "\n\t" \ + VSLL_VI(REG_V22, REG_V11, s) \ + "slli " CC_T2 ", " CC_D2 ", " #s "\n\t" \ + VSLL_VI(REG_V23, REG_V15, s) \ + "slli " CC_T3 ", " CC_D3 ", " #s "\n\t" \ + VSLL_VI(REG_V24, REG_V19, s) \ + VSRL_VI(REG_V3, REG_V3, sr) \ + "srliw " CC_D0 ", " CC_D0 ", " #sr "\n\t" \ + VSRL_VI(REG_V7, REG_V7, sr) \ + "srliw " CC_D1 ", " CC_D1 ", " #sr "\n\t" \ + VSRL_VI(REG_V11, REG_V11, sr) \ + "srliw " CC_D2 ", " CC_D2 ", " #sr "\n\t" \ + VSRL_VI(REG_V15, REG_V15, sr) \ + "srliw " CC_D3 ", " CC_D3 ", " #sr "\n\t" \ + VSRL_VI(REG_V19, REG_V19, sr) \ + VOR_VV(REG_V3, REG_V3, REG_V20) \ + "or " CC_D0 ", " CC_D0 ", " CC_T0 "\n\t" \ + VOR_VV(REG_V7, REG_V7, REG_V21) \ + "or " CC_D1 ", " CC_D1 ", " CC_T1 "\n\t" \ + VOR_VV(REG_V11, REG_V11, REG_V22) \ + "or " CC_D2 ", " CC_D2 ", " CC_T2 "\n\t" \ + VOR_VV(REG_V15, REG_V15, REG_V23) \ + "or " CC_D3 ", " CC_D3 ", " CC_T3 "\n\t" \ + VOR_VV(REG_V19, REG_V19, REG_V24) + +#define PART_ROUND_ODD_CDB_5(s, sr) \ + VADD_VV(REG_V2, REG_V2, REG_V3) \ + "add " CC_C0 ", " CC_C0 ", " CC_D0 "\n\t" \ + VADD_VV(REG_V6, REG_V6, REG_V7) \ + "add " CC_C1 ", " CC_C1 ", " CC_D1 "\n\t" \ + VADD_VV(REG_V10, REG_V10, REG_V11) \ + "add " CC_C2 ", " CC_C2 ", " CC_D2 "\n\t" \ + VADD_VV(REG_V14, REG_V14, REG_V15) \ + "add " CC_C3 ", " CC_C3 ", " CC_D3 "\n\t" \ + VADD_VV(REG_V18, REG_V18, REG_V19) \ + VXOR_VV(REG_V1, REG_V1, REG_V2) \ + "xor " CC_B0 ", " CC_B0 ", " CC_C0 "\n\t" \ + VXOR_VV(REG_V5, REG_V5, REG_V6) \ + "xor " CC_B1 ", " CC_B1 ", " CC_C1 "\n\t" \ + VXOR_VV(REG_V9, REG_V9, REG_V10) \ + "xor " CC_B2 ", " CC_B2 ", " CC_C2 "\n\t" \ + VXOR_VV(REG_V13, REG_V13, REG_V14) \ + "xor " CC_B3 ", " CC_B3 ", " CC_C3 "\n\t" \ + VXOR_VV(REG_V17, REG_V17, REG_V18) \ + VSLL_VI(REG_V20, REG_V1, s) \ + "slli " CC_T0 ", " CC_B0 ", " #s "\n\t" \ + VSLL_VI(REG_V21, REG_V5, s) \ + "slli " CC_T1 ", " CC_B1 ", " #s "\n\t" \ + VSLL_VI(REG_V22, REG_V9, s) \ + "slli " CC_T2 ", " CC_B2 ", " #s "\n\t" \ + VSLL_VI(REG_V23, REG_V13, s) \ + "slli " CC_T3 ", " CC_B3 ", " #s "\n\t" \ + VSLL_VI(REG_V24, REG_V17, s) \ + VSRL_VI(REG_V1, REG_V1, sr) \ + "srliw " CC_B0 ", " CC_B0 ", " #sr "\n\t" \ + VSRL_VI(REG_V5, REG_V5, sr) \ + "srliw " CC_B1 ", " CC_B1 ", " #sr "\n\t" \ + VSRL_VI(REG_V9, REG_V9, sr) \ + "srliw " CC_B2 ", " CC_B2 ", " #sr "\n\t" \ + VSRL_VI(REG_V13, REG_V13, sr) \ + "srliw " CC_B3 ", " CC_B3 ", " #sr "\n\t" \ + VSRL_VI(REG_V17, REG_V17, sr) \ + VOR_VV(REG_V1, REG_V1, REG_V20) \ + "or " CC_B0 ", " CC_B0 ", " CC_T0 "\n\t" \ + VOR_VV(REG_V5, REG_V5, REG_V21) \ + "or " CC_B1 ", " CC_B1 ", " CC_T1 "\n\t" \ + VOR_VV(REG_V9, REG_V9, REG_V22) \ + "or " CC_B2 ", " CC_B2 ", " CC_T2 "\n\t" \ + VOR_VV(REG_V13, REG_V13, REG_V23) \ + "or " CC_B3 ", " CC_B3 ", " CC_T3 "\n\t" \ + VOR_VV(REG_V17, REG_V17, REG_V24) + +#define PART_ROUND_EVEN_ABD_5(s, sr) \ + VADD_VV(REG_V0, REG_V0, REG_V1) \ + "add " CC_A0 ", " CC_A0 ", " CC_B1 "\n\t" \ + VADD_VV(REG_V4, REG_V4, REG_V5) \ + "add " CC_A1 ", " CC_A1 ", " CC_B2 "\n\t" \ + VADD_VV(REG_V8, REG_V8, REG_V9) \ + "add " CC_A2 ", " CC_A2 ", " CC_B3 "\n\t" \ + VADD_VV(REG_V12, REG_V12, REG_V13) \ + "add " CC_A3 ", " CC_A3 ", " CC_B0 "\n\t" \ + VADD_VV(REG_V16, REG_V16, REG_V17) \ + VXOR_VV(REG_V3, REG_V3, REG_V0) \ + "xor " CC_D3 ", " CC_D3 ", " CC_A0 "\n\t" \ + VXOR_VV(REG_V7, REG_V7, REG_V4) \ + "xor " CC_D0 ", " CC_D0 ", " CC_A1 "\n\t" \ + VXOR_VV(REG_V11, REG_V11, REG_V8) \ + "xor " CC_D1 ", " CC_D1 ", " CC_A2 "\n\t" \ + VXOR_VV(REG_V15, REG_V15, REG_V12) \ + "xor " CC_D2 ", " CC_D2 ", " CC_A3 "\n\t" \ + VXOR_VV(REG_V19, REG_V19, REG_V16) \ + VSLL_VI(REG_V20, REG_V3, s) \ + "slli " CC_T0 ", " CC_D3 ", " #s "\n\t" \ + VSLL_VI(REG_V21, REG_V7, s) \ + "slli " CC_T1 ", " CC_D0 ", " #s "\n\t" \ + VSLL_VI(REG_V22, REG_V11, s) \ + "slli " CC_T2 ", " CC_D1 ", " #s "\n\t" \ + VSLL_VI(REG_V23, REG_V15, s) \ + "slli " CC_T3 ", " CC_D2 ", " #s "\n\t" \ + VSLL_VI(REG_V24, REG_V19, s) \ + VSRL_VI(REG_V3, REG_V3, sr) \ + "srliw " CC_D3 ", " CC_D3 ", " #sr "\n\t" \ + VSRL_VI(REG_V7, REG_V7, sr) \ + "srliw " CC_D0 ", " CC_D0 ", " #sr "\n\t" \ + VSRL_VI(REG_V11, REG_V11, sr) \ + "srliw " CC_D1 ", " CC_D1 ", " #sr "\n\t" \ + VSRL_VI(REG_V15, REG_V15, sr) \ + "srliw " CC_D2 ", " CC_D2 ", " #sr "\n\t" \ + VSRL_VI(REG_V19, REG_V19, sr) \ + VOR_VV(REG_V3, REG_V3, REG_V20) \ + "or " CC_D3 ", " CC_D3 ", " CC_T0 "\n\t" \ + VOR_VV(REG_V7, REG_V7, REG_V21) \ + "or " CC_D0 ", " CC_D0 ", " CC_T1 "\n\t" \ + VOR_VV(REG_V11, REG_V11, REG_V22) \ + "or " CC_D1 ", " CC_D1 ", " CC_T2 "\n\t" \ + VOR_VV(REG_V15, REG_V15, REG_V23) \ + "or " CC_D2 ", " CC_D2 ", " CC_T3 "\n\t" \ + VOR_VV(REG_V19, REG_V19, REG_V24) + +#define PART_ROUND_EVEN_CDB_5(s, sr) \ + VADD_VV(REG_V2, REG_V2, REG_V3) \ + "add " CC_C2 ", " CC_C2 ", " CC_D3 "\n\t" \ + VADD_VV(REG_V6, REG_V6, REG_V7) \ + "add " CC_C3 ", " CC_C3 ", " CC_D0 "\n\t" \ + VADD_VV(REG_V10, REG_V10, REG_V11) \ + "add " CC_C0 ", " CC_C0 ", " CC_D1 "\n\t" \ + VADD_VV(REG_V14, REG_V14, REG_V15) \ + "add " CC_C1 ", " CC_C1 ", " CC_D2 "\n\t" \ + VADD_VV(REG_V18, REG_V18, REG_V19) \ + VXOR_VV(REG_V1, REG_V1, REG_V2) \ + "xor " CC_B1 ", " CC_B1 ", " CC_C2 "\n\t" \ + VXOR_VV(REG_V5, REG_V5, REG_V6) \ + "xor " CC_B2 ", " CC_B2 ", " CC_C3 "\n\t" \ + VXOR_VV(REG_V9, REG_V9, REG_V10) \ + "xor " CC_B3 ", " CC_B3 ", " CC_C0 "\n\t" \ + VXOR_VV(REG_V13, REG_V13, REG_V14) \ + "xor " CC_B0 ", " CC_B0 ", " CC_C1 "\n\t" \ + VXOR_VV(REG_V17, REG_V17, REG_V18) \ + VSLL_VI(REG_V20, REG_V1, s) \ + "slli " CC_T0 ", " CC_B1 ", " #s "\n\t" \ + VSLL_VI(REG_V21, REG_V5, s) \ + "slli " CC_T1 ", " CC_B2 ", " #s "\n\t" \ + VSLL_VI(REG_V22, REG_V9, s) \ + "slli " CC_T2 ", " CC_B3 ", " #s "\n\t" \ + VSLL_VI(REG_V23, REG_V13, s) \ + "slli " CC_T3 ", " CC_B0 ", " #s "\n\t" \ + VSLL_VI(REG_V24, REG_V17, s) \ + VSRL_VI(REG_V1, REG_V1, sr) \ + "srliw " CC_B1 ", " CC_B1 ", " #sr "\n\t" \ + VSRL_VI(REG_V5, REG_V5, sr) \ + "srliw " CC_B2 ", " CC_B2 ", " #sr "\n\t" \ + VSRL_VI(REG_V9, REG_V9, sr) \ + "srliw " CC_B3 ", " CC_B3 ", " #sr "\n\t" \ + VSRL_VI(REG_V13, REG_V13, sr) \ + "srliw " CC_B0 ", " CC_B0 ", " #sr "\n\t" \ + VSRL_VI(REG_V17, REG_V17, sr) \ + VOR_VV(REG_V1, REG_V1, REG_V20) \ + "or " CC_B1 ", " CC_B1 ", " CC_T0 "\n\t" \ + VOR_VV(REG_V5, REG_V5, REG_V21) \ + "or " CC_B2 ", " CC_B2 ", " CC_T1 "\n\t" \ + VOR_VV(REG_V9, REG_V9, REG_V22) \ + "or " CC_B3 ", " CC_B3 ", " CC_T2 "\n\t" \ + VOR_VV(REG_V13, REG_V13, REG_V23) \ + "or " CC_B0 ", " CC_B0 ", " CC_T3 "\n\t" \ + VOR_VV(REG_V17, REG_V17, REG_V24) + +#elif !defined(WOLFSSL_RISCV_BASE_BIT_MANIPULATION ) + +#define PART_ROUND_ODD_ABD_5(s, sr) \ + VADD_VV(REG_V0, REG_V0, REG_V1) \ + "add " CC_A0 ", " CC_A0 ", " CC_B0 "\n\t" \ + VADD_VV(REG_V4, REG_V4, REG_V5) \ + "add " CC_A1 ", " CC_A1 ", " CC_B1 "\n\t" \ + VADD_VV(REG_V8, REG_V8, REG_V9) \ + "add " CC_A2 ", " CC_A2 ", " CC_B2 "\n\t" \ + VADD_VV(REG_V12, REG_V12, REG_V13) \ + "add " CC_A3 ", " CC_A3 ", " CC_B3 "\n\t" \ + VADD_VV(REG_V16, REG_V16, REG_V17) \ + "xor " CC_D0 ", " CC_D0 ", " CC_A0 "\n\t" \ + VXOR_VV(REG_V3, REG_V3, REG_V0) \ + "xor " CC_D1 ", " CC_D1 ", " CC_A1 "\n\t" \ + VXOR_VV(REG_V7, REG_V7, REG_V4) \ + "xor " CC_D2 ", " CC_D2 ", " CC_A2 "\n\t" \ + VXOR_VV(REG_V11, REG_V11, REG_V8) \ + "xor " CC_D3 ", " CC_D3 ", " CC_A3 "\n\t" \ + VXOR_VV(REG_V15, REG_V15, REG_V12) \ + "slli " CC_T0 ", " CC_D0 ", " #s "\n\t" \ + VXOR_VV(REG_V19, REG_V19, REG_V16) \ + "slli " CC_T1 ", " CC_D1 ", " #s "\n\t" \ + VROR_VI(REG_V3, sr, REG_V3) \ + "slli " CC_T2 ", " CC_D2 ", " #s "\n\t" \ + VROR_VI(REG_V7, sr, REG_V7) \ + "slli " CC_T3 ", " CC_D3 ", " #s "\n\t" \ + VROR_VI(REG_V11, sr, REG_V11) \ + "srliw " CC_D0 ", " CC_D0 ", " #sr "\n\t" \ + VROR_VI(REG_V15, sr, REG_V15) \ + "srliw " CC_D1 ", " CC_D1 ", " #sr "\n\t" \ + VROR_VI(REG_V19, sr, REG_V19) \ + "srliw " CC_D2 ", " CC_D2 ", " #sr "\n\t" \ + "srliw " CC_D3 ", " CC_D3 ", " #sr "\n\t" \ + "or " CC_D0 ", " CC_D0 ", " CC_T0 "\n\t" \ + "or " CC_D1 ", " CC_D1 ", " CC_T1 "\n\t" \ + "or " CC_D2 ", " CC_D2 ", " CC_T2 "\n\t" \ + "or " CC_D3 ", " CC_D3 ", " CC_T3 "\n\t" + +#define PART_ROUND_ODD_CDB_5(s, sr) \ + VADD_VV(REG_V2, REG_V2, REG_V3) \ + "add " CC_C0 ", " CC_C0 ", " CC_D0 "\n\t" \ + VADD_VV(REG_V6, REG_V6, REG_V7) \ + "add " CC_C1 ", " CC_C1 ", " CC_D1 "\n\t" \ + VADD_VV(REG_V10, REG_V10, REG_V11) \ + "add " CC_C2 ", " CC_C2 ", " CC_D2 "\n\t" \ + VADD_VV(REG_V14, REG_V14, REG_V15) \ + "add " CC_C3 ", " CC_C3 ", " CC_D3 "\n\t" \ + VADD_VV(REG_V18, REG_V18, REG_V19) \ + "xor " CC_B0 ", " CC_B0 ", " CC_C0 "\n\t" \ + VXOR_VV(REG_V1, REG_V1, REG_V2) \ + "xor " CC_B1 ", " CC_B1 ", " CC_C1 "\n\t" \ + VXOR_VV(REG_V5, REG_V5, REG_V6) \ + "xor " CC_B2 ", " CC_B2 ", " CC_C2 "\n\t" \ + VXOR_VV(REG_V9, REG_V9, REG_V10) \ + "xor " CC_B3 ", " CC_B3 ", " CC_C3 "\n\t" \ + VXOR_VV(REG_V13, REG_V13, REG_V14) \ + "slli " CC_T0 ", " CC_B0 ", " #s "\n\t" \ + VXOR_VV(REG_V17, REG_V17, REG_V18) \ + "slli " CC_T1 ", " CC_B1 ", " #s "\n\t" \ + VROR_VI(REG_V1, sr, REG_V1) \ + "slli " CC_T2 ", " CC_B2 ", " #s "\n\t" \ + VROR_VI(REG_V5, sr, REG_V5) \ + "slli " CC_T3 ", " CC_B3 ", " #s "\n\t" \ + VROR_VI(REG_V9, sr, REG_V9) \ + "srliw " CC_B0 ", " CC_B0 ", " #sr "\n\t" \ + VROR_VI(REG_V13, sr, REG_V13) \ + "srliw " CC_B1 ", " CC_B1 ", " #sr "\n\t" \ + VROR_VI(REG_V17, sr, REG_V17) \ + "srliw " CC_B2 ", " CC_B2 ", " #sr "\n\t" \ + "srliw " CC_B3 ", " CC_B3 ", " #sr "\n\t" \ + "or " CC_B0 ", " CC_B0 ", " CC_T0 "\n\t" \ + "or " CC_B1 ", " CC_B1 ", " CC_T1 "\n\t" \ + "or " CC_B2 ", " CC_B2 ", " CC_T2 "\n\t" \ + "or " CC_B3 ", " CC_B3 ", " CC_T3 "\n\t" + +#define PART_ROUND_EVEN_ABD_5(s, sr) \ + VADD_VV(REG_V0, REG_V0, REG_V1) \ + "add " CC_A0 ", " CC_A0 ", " CC_B1 "\n\t" \ + VADD_VV(REG_V4, REG_V4, REG_V5) \ + "add " CC_A1 ", " CC_A1 ", " CC_B2 "\n\t" \ + VADD_VV(REG_V8, REG_V8, REG_V9) \ + "add " CC_A2 ", " CC_A2 ", " CC_B3 "\n\t" \ + VADD_VV(REG_V12, REG_V12, REG_V13) \ + "add " CC_A3 ", " CC_A3 ", " CC_B0 "\n\t" \ + VADD_VV(REG_V16, REG_V16, REG_V17) \ + "xor " CC_D3 ", " CC_D3 ", " CC_A0 "\n\t" \ + VXOR_VV(REG_V3, REG_V3, REG_V0) \ + "xor " CC_D0 ", " CC_D0 ", " CC_A1 "\n\t" \ + VXOR_VV(REG_V7, REG_V7, REG_V4) \ + "xor " CC_D1 ", " CC_D1 ", " CC_A2 "\n\t" \ + VXOR_VV(REG_V11, REG_V11, REG_V8) \ + "xor " CC_D2 ", " CC_D2 ", " CC_A3 "\n\t" \ + VXOR_VV(REG_V15, REG_V15, REG_V12) \ + "slli " CC_T0 ", " CC_D3 ", " #s "\n\t" \ + VXOR_VV(REG_V19, REG_V19, REG_V16) \ + "slli " CC_T1 ", " CC_D0 ", " #s "\n\t" \ + VROR_VI(REG_V3, sr, REG_V3) \ + "slli " CC_T2 ", " CC_D1 ", " #s "\n\t" \ + VROR_VI(REG_V7, sr, REG_V7) \ + "slli " CC_T3 ", " CC_D2 ", " #s "\n\t" \ + VROR_VI(REG_V11, sr, REG_V11) \ + "srliw " CC_D3 ", " CC_D3 ", " #sr "\n\t" \ + VROR_VI(REG_V15, sr, REG_V15) \ + "srliw " CC_D0 ", " CC_D0 ", " #sr "\n\t" \ + VROR_VI(REG_V19, sr, REG_V19) \ + "srliw " CC_D1 ", " CC_D1 ", " #sr "\n\t" \ + "srliw " CC_D2 ", " CC_D2 ", " #sr "\n\t" \ + "or " CC_D3 ", " CC_D3 ", " CC_T0 "\n\t" \ + "or " CC_D0 ", " CC_D0 ", " CC_T1 "\n\t" \ + "or " CC_D1 ", " CC_D1 ", " CC_T2 "\n\t" \ + "or " CC_D2 ", " CC_D2 ", " CC_T3 "\n\t" + +#define PART_ROUND_EVEN_CDB_5(s, sr) \ + VADD_VV(REG_V2, REG_V2, REG_V3) \ + "add " CC_C2 ", " CC_C2 ", " CC_D3 "\n\t" \ + VADD_VV(REG_V6, REG_V6, REG_V7) \ + "add " CC_C3 ", " CC_C3 ", " CC_D0 "\n\t" \ + VADD_VV(REG_V10, REG_V10, REG_V11) \ + "add " CC_C0 ", " CC_C0 ", " CC_D1 "\n\t" \ + VADD_VV(REG_V14, REG_V14, REG_V15) \ + "add " CC_C1 ", " CC_C1 ", " CC_D2 "\n\t" \ + VADD_VV(REG_V18, REG_V18, REG_V19) \ + "xor " CC_B1 ", " CC_B1 ", " CC_C2 "\n\t" \ + VXOR_VV(REG_V1, REG_V1, REG_V2) \ + "xor " CC_B2 ", " CC_B2 ", " CC_C3 "\n\t" \ + VXOR_VV(REG_V5, REG_V5, REG_V6) \ + "xor " CC_B3 ", " CC_B3 ", " CC_C0 "\n\t" \ + VXOR_VV(REG_V9, REG_V9, REG_V10) \ + "xor " CC_B0 ", " CC_B0 ", " CC_C1 "\n\t" \ + VXOR_VV(REG_V13, REG_V13, REG_V14) \ + "slli " CC_T0 ", " CC_B1 ", " #s "\n\t" \ + VXOR_VV(REG_V17, REG_V17, REG_V18) \ + "slli " CC_T1 ", " CC_B2 ", " #s "\n\t" \ + VROR_VI(REG_V1, sr, REG_V1) \ + "slli " CC_T2 ", " CC_B3 ", " #s "\n\t" \ + VROR_VI(REG_V5, sr, REG_V5) \ + "slli " CC_T3 ", " CC_B0 ", " #s "\n\t" \ + VROR_VI(REG_V9, sr, REG_V9) \ + "srliw " CC_B1 ", " CC_B1 ", " #sr "\n\t" \ + VROR_VI(REG_V13, sr, REG_V13) \ + "srliw " CC_B2 ", " CC_B2 ", " #sr "\n\t" \ + VROR_VI(REG_V17, sr, REG_V17) \ + "srliw " CC_B3 ", " CC_B3 ", " #sr "\n\t" \ + "srliw " CC_B0 ", " CC_B0 ", " #sr "\n\t" \ + "or " CC_B1 ", " CC_B1 ", " CC_T0 "\n\t" \ + "or " CC_B2 ", " CC_B2 ", " CC_T1 "\n\t" \ + "or " CC_B3 ", " CC_B3 ", " CC_T2 "\n\t" \ + "or " CC_B0 ", " CC_B0 ", " CC_T3 "\n\t" + +#else + +#define PART_ROUND_ODD_ABD_5(s, sr) \ + VADD_VV(REG_V0, REG_V0, REG_V1) \ + "add " CC_A0 ", " CC_A0 ", " CC_B0 "\n\t" \ + VADD_VV(REG_V4, REG_V4, REG_V5) \ + "add " CC_A1 ", " CC_A1 ", " CC_B1 "\n\t" \ + VADD_VV(REG_V8, REG_V8, REG_V9) \ + "add " CC_A2 ", " CC_A2 ", " CC_B2 "\n\t" \ + VADD_VV(REG_V12, REG_V12, REG_V13) \ + "add " CC_A3 ", " CC_A3 ", " CC_B3 "\n\t" \ + VADD_VV(REG_V16, REG_V16, REG_V17) \ + VXOR_VV(REG_V3, REG_V3, REG_V0) \ + "xor " CC_D0 ", " CC_D0 ", " CC_A0 "\n\t" \ + VXOR_VV(REG_V7, REG_V7, REG_V4) \ + "xor " CC_D1 ", " CC_D1 ", " CC_A1 "\n\t" \ + VXOR_VV(REG_V11, REG_V11, REG_V8) \ + "xor " CC_D2 ", " CC_D2 ", " CC_A2 "\n\t" \ + VXOR_VV(REG_V15, REG_V15, REG_V12) \ + "xor " CC_D3 ", " CC_D3 ", " CC_A3 "\n\t" \ + VXOR_VV(REG_V19, REG_V19, REG_V16) \ + VROR_VI(REG_V3, sr, REG_V3) \ + RORIW(REG_S6, REG_S6, sr) \ + VROR_VI(REG_V7, sr, REG_V7) \ + RORIW(REG_S7, REG_S7, sr) \ + VROR_VI(REG_V11, sr, REG_V11) \ + RORIW(REG_S8, REG_S8, sr) \ + VROR_VI(REG_V15, sr, REG_V15) \ + RORIW(REG_S9, REG_S9, sr) \ + VROR_VI(REG_V19, sr, REG_V19) + +#define PART_ROUND_ODD_CDB_5(s, sr) \ + VADD_VV(REG_V2, REG_V2, REG_V3) \ + "add " CC_C0 ", " CC_C0 ", " CC_D0 "\n\t" \ + VADD_VV(REG_V6, REG_V6, REG_V7) \ + "add " CC_C1 ", " CC_C1 ", " CC_D1 "\n\t" \ + VADD_VV(REG_V10, REG_V10, REG_V11) \ + "add " CC_C2 ", " CC_C2 ", " CC_D2 "\n\t" \ + VADD_VV(REG_V14, REG_V14, REG_V15) \ + "add " CC_C3 ", " CC_C3 ", " CC_D3 "\n\t" \ + VADD_VV(REG_V18, REG_V18, REG_V19) \ + VXOR_VV(REG_V1, REG_V1, REG_V2) \ + "xor " CC_B0 ", " CC_B0 ", " CC_C0 "\n\t" \ + VXOR_VV(REG_V5, REG_V5, REG_V6) \ + "xor " CC_B1 ", " CC_B1 ", " CC_C1 "\n\t" \ + VXOR_VV(REG_V9, REG_V9, REG_V10) \ + "xor " CC_B2 ", " CC_B2 ", " CC_C2 "\n\t" \ + VXOR_VV(REG_V13, REG_V13, REG_V14) \ + "xor " CC_B3 ", " CC_B3 ", " CC_C3 "\n\t" \ + VXOR_VV(REG_V17, REG_V17, REG_V18) \ + VROR_VI(REG_V1, sr, REG_V1) \ + RORIW(REG_T3, REG_T3, sr) \ + VROR_VI(REG_V5, sr, REG_V5) \ + RORIW(REG_T4, REG_T4, sr) \ + VROR_VI(REG_V9, sr, REG_V9) \ + RORIW(REG_T5, REG_T5, sr) \ + VROR_VI(REG_V13, sr, REG_V13) \ + RORIW(REG_T6, REG_T6, sr) \ + VROR_VI(REG_V17, sr, REG_V17) + +#define PART_ROUND_EVEN_ABD_5(s, sr) \ + VADD_VV(REG_V0, REG_V0, REG_V1) \ + "add " CC_A0 ", " CC_A0 ", " CC_B1 "\n\t" \ + VADD_VV(REG_V4, REG_V4, REG_V5) \ + "add " CC_A1 ", " CC_A1 ", " CC_B2 "\n\t" \ + VADD_VV(REG_V8, REG_V8, REG_V9) \ + "add " CC_A2 ", " CC_A2 ", " CC_B3 "\n\t" \ + VADD_VV(REG_V12, REG_V12, REG_V13) \ + "add " CC_A3 ", " CC_A3 ", " CC_B0 "\n\t" \ + VADD_VV(REG_V16, REG_V16, REG_V17) \ + VXOR_VV(REG_V3, REG_V3, REG_V0) \ + "xor " CC_D3 ", " CC_D3 ", " CC_A0 "\n\t" \ + VXOR_VV(REG_V7, REG_V7, REG_V4) \ + "xor " CC_D0 ", " CC_D0 ", " CC_A1 "\n\t" \ + VXOR_VV(REG_V11, REG_V11, REG_V8) \ + "xor " CC_D1 ", " CC_D1 ", " CC_A2 "\n\t" \ + VXOR_VV(REG_V15, REG_V15, REG_V12) \ + "xor " CC_D2 ", " CC_D2 ", " CC_A3 "\n\t" \ + VXOR_VV(REG_V19, REG_V19, REG_V16) \ + VROR_VI(REG_V3, sr, REG_V3) \ + RORIW(REG_S9, REG_S9, sr) \ + VROR_VI(REG_V7, sr, REG_V7) \ + RORIW(REG_S6, REG_S6, sr) \ + VROR_VI(REG_V11, sr, REG_V11) \ + RORIW(REG_S7, REG_S7, sr) \ + VROR_VI(REG_V15, sr, REG_V15) \ + RORIW(REG_S8, REG_S8, sr) \ + VROR_VI(REG_V19, sr, REG_V19) + +#define PART_ROUND_EVEN_CDB_5(s, sr) \ + VADD_VV(REG_V2, REG_V2, REG_V3) \ + "add " CC_C2 ", " CC_C2 ", " CC_D3 "\n\t" \ + VADD_VV(REG_V6, REG_V6, REG_V7) \ + "add " CC_C3 ", " CC_C3 ", " CC_D0 "\n\t" \ + VADD_VV(REG_V10, REG_V10, REG_V11) \ + "add " CC_C0 ", " CC_C0 ", " CC_D1 "\n\t" \ + VADD_VV(REG_V14, REG_V14, REG_V15) \ + "add " CC_C1 ", " CC_C1 ", " CC_D2 "\n\t" \ + VADD_VV(REG_V18, REG_V18, REG_V19) \ + VXOR_VV(REG_V1, REG_V1, REG_V2) \ + "xor " CC_B1 ", " CC_B1 ", " CC_C2 "\n\t" \ + VXOR_VV(REG_V5, REG_V5, REG_V6) \ + "xor " CC_B2 ", " CC_B2 ", " CC_C3 "\n\t" \ + VXOR_VV(REG_V9, REG_V9, REG_V10) \ + "xor " CC_B3 ", " CC_B3 ", " CC_C0 "\n\t" \ + VXOR_VV(REG_V13, REG_V13, REG_V14) \ + "xor " CC_B0 ", " CC_B0 ", " CC_C1 "\n\t" \ + VXOR_VV(REG_V17, REG_V17, REG_V18) \ + VROR_VI(REG_V1, sr, REG_V1) \ + RORIW(REG_T4, REG_T4, sr) \ + VROR_VI(REG_V5, sr, REG_V5) \ + RORIW(REG_T5, REG_T5, sr) \ + VROR_VI(REG_V9, sr, REG_V9) \ + RORIW(REG_T6, REG_T6, sr) \ + VROR_VI(REG_V13, sr, REG_V13) \ + RORIW(REG_T3, REG_T3, sr) \ + VROR_VI(REG_V17, sr, REG_V17) + +#endif + +#define QUARTER_ROUND_ODD_5() \ + /* a += b; d ^= a; d <<<= 16; */ \ + PART_ROUND_ODD_ABD_5(16, 16) \ + /* c += d; b ^= c; b <<<= 12; */ \ + PART_ROUND_ODD_CDB_5(12, 20) \ + /* a += b; d ^= a; d <<<= 8; */ \ + PART_ROUND_ODD_ABD_5( 8, 24) \ + /* c += d; b ^= c; b <<<= 7; */ \ + PART_ROUND_ODD_CDB_5( 7, 25) + +#define QUARTER_ROUND_EVEN_5() \ + /* a += b; d ^= a; d <<<= 16; */ \ + PART_ROUND_EVEN_ABD_5(16, 16) \ + /* c += d; b ^= c; b <<<= 12; */ \ + PART_ROUND_EVEN_CDB_5(12, 20) \ + /* a += b; d ^= a; d <<<= 8; */ \ + PART_ROUND_EVEN_ABD_5( 8, 24) \ + /* c += d; b ^= c; b <<<= 7; */ \ + PART_ROUND_EVEN_CDB_5( 7, 25) + +#define SHUFFLE_5(r, t, i) \ + VRGATHER_VV(t + 0, i, r + 0) \ + VRGATHER_VV(t + 1, i, r + 4) \ + VRGATHER_VV(t + 2, i, r + 8) \ + VRGATHER_VV(t + 3, i, r + 12) \ + VRGATHER_VV(t + 4, i, r + 16) \ + VMV_V_V(r + 0, t + 0) \ + VMV_V_V(r + 4, t + 1) \ + VMV_V_V(r + 8, t + 2) \ + VMV_V_V(r + 12, t + 3) \ + VMV_V_V(r + 16, t + 4) + +#define ODD_SHUFFLE_5() \ + /* a=0,1,2,3; b=4,5,6,7; c=8,9,10,11; d=12,13,14,15 \ + * => a=0,1,2,3; b=5,6,7,4; c=10,11,8,9; d=15,12,13,14 */ \ + SHUFFLE_5(REG_V3, REG_V20, REG_V27) \ + SHUFFLE_5(REG_V1, REG_V20, REG_V25) \ + SHUFFLE_5(REG_V2, REG_V20, REG_V26) + +#define EVEN_SHUFFLE_5() \ + /* a=0,1,2,3; b=5,6,7,4; c=10,11,8,9; d=15,12,13,14 \ + * => a=0,1,2,3; b=4,5,6,7; c=8,9,10,11; d=12,13,14,15 */ \ + SHUFFLE_5(REG_V3, REG_V20, REG_V25) \ + SHUFFLE_5(REG_V1, REG_V20, REG_V27) \ + SHUFFLE_5(REG_V2, REG_V20, REG_V26) + +static WC_INLINE void wc_chacha_encrypt_384(const word32* input, const byte* m, + byte* c, word32 bytes) +{ + word64 bytes64 = (word64)bytes; + + __asm__ __volatile__ ( + VSETIVLI(REG_X0, 4, 1, 1, 0b010, 0b000) + /* The layout of used vector registers is: + * v0-v3 - first block + * v4-v7 - second block + * v8-v11 - third block + * v12-v15 - fourth block + * v16-v19 - fifth block + * v20-v24 - temp/message + * v25-v27 - indeces for rotating words in vector + * v28-v31 - input + * + * v0 0 1 2 3 + * v1 4 5 6 7 + * v2 8 9 10 11 + * v3 12 13 14 15 + * load CHACHA state with indices placed as shown above + */ + + /* Load state to encrypt */ + "mv t2, %[input]\n\t" + VL4RE32_V(REG_V28, REG_T2) + VID_V(REG_V20) + VSLIDEDOWN_VI(REG_V25, REG_V20, 1) + VSLIDEUP_VI(REG_V25, REG_V20, 3) + VSLIDEDOWN_VI(REG_V26, REG_V20, 2) + VSLIDEUP_VI(REG_V26, REG_V20, 2) + VSLIDEDOWN_VI(REG_V27, REG_V20, 3) + VSLIDEUP_VI(REG_V27, REG_V20, 1) + "\n" + "L_chacha20_riscv_384_outer:\n\t" + /* Move state into regular registers */ + "ld a4, 0(%[input])\n\t" + "ld a6, 8(%[input])\n\t" + "ld t3, 16(%[input])\n\t" + "ld t5, 24(%[input])\n\t" + "ld s2, 32(%[input])\n\t" + "ld s4, 40(%[input])\n\t" + "lw s7, 52(%[input])\n\t" + "ld s8, 56(%[input])\n\t" + "srli a5, a4, 32\n\t" + "srli a7, a6, 32\n\t" + "srli t4, t3, 32\n\t" + "srli t6, t5, 32\n\t" + "srli s3, s2, 32\n\t" + "srli s5, s4, 32\n\t" + "srli s9, s8, 32\n\t" + VMV_X_S(REG_S6, REG_V31) + /* Move state into vector registers */ + VMVR_V(REG_V0, REG_V28, 4) + VMVR_V(REG_V4, REG_V28, 4) + VMVR_V(REG_V8, REG_V28, 4) + VMVR_V(REG_V12, REG_V28, 4) + VMVR_V(REG_V16, REG_V28, 4) + /* Set counter word */ + "addi t1, s6, 1\n\t" + VMV_S_X(REG_V7, REG_T1) + "addi t1, s6, 2\n\t" + VMV_S_X(REG_V11, REG_T1) + "addi t1, s6, 3\n\t" + VMV_S_X(REG_V15, REG_T1) + "addi t1, s6, 4\n\t" + VMV_S_X(REG_V19, REG_T1) + "addi s6, s6, 5\n\t" + /* Set number of odd+even rounds to perform */ + "li a3, 10\n\t" + "\n" + "L_chacha20_riscv_384_loop:\n\t" + /* Odd Round */ + QUARTER_ROUND_ODD_5() + ODD_SHUFFLE_5() + /* Even Round */ + QUARTER_ROUND_EVEN_5() + EVEN_SHUFFLE_5() + "addi a3, a3, -1\n\t" + "bnez a3, L_chacha20_riscv_384_loop\n\t" + /* Load message */ + "mv t2, %[m]\n\t" + VL4RE32_V(REG_V20, REG_T2) + "addi %[m], %[m], 64\n\t" + /* Add back state, XOR in message and store (load next block) */ + /* BLOCK 1 */ + VADD_VV(REG_V0, REG_V0, REG_V28) + VADD_VV(REG_V1, REG_V1, REG_V29) + VADD_VV(REG_V2, REG_V2, REG_V30) + VADD_VV(REG_V3, REG_V3, REG_V31) + VXOR_VV(REG_V0, REG_V0, REG_V20) + VXOR_VV(REG_V1, REG_V1, REG_V21) + VXOR_VV(REG_V2, REG_V2, REG_V22) + VXOR_VV(REG_V3, REG_V3, REG_V23) + "mv t2, %[m]\n\t" + VL4RE32_V(REG_V20, REG_T2) + "addi %[m], %[m], 64\n\t" + VMV_X_S(REG_T0, REG_V31) + "mv t2, %[c]\n\t" + VS4R_V(REG_V0, REG_T2) + "addi %[c], %[c], 64\n\t" + /* BLOCK 2 */ + "addi t0, t0, 1\n\t" + VMV_S_X(REG_V31, REG_T0) + VADD_VV(REG_V4, REG_V4, REG_V28) + VADD_VV(REG_V5, REG_V5, REG_V29) + VADD_VV(REG_V6, REG_V6, REG_V30) + VADD_VV(REG_V7, REG_V7, REG_V31) + VXOR_VV(REG_V4, REG_V4, REG_V20) + VXOR_VV(REG_V5, REG_V5, REG_V21) + VXOR_VV(REG_V6, REG_V6, REG_V22) + VXOR_VV(REG_V7, REG_V7, REG_V23) + "mv t2, %[m]\n\t" + VL4RE32_V(REG_V20, REG_T2) + "addi %[m], %[m], 64\n\t" + "mv t2, %[c]\n\t" + VS4R_V(REG_V4, REG_T2) + "addi %[c], %[c], 64\n\t" + /* BLOCK 3 */ + "addi t0, t0, 1\n\t" + VMV_S_X(REG_V31, REG_T0) + VADD_VV(REG_V8, REG_V8, REG_V28) + VADD_VV(REG_V9, REG_V9, REG_V29) + VADD_VV(REG_V10, REG_V10, REG_V30) + VADD_VV(REG_V11, REG_V11, REG_V31) + VXOR_VV(REG_V8, REG_V8, REG_V20) + VXOR_VV(REG_V9, REG_V9, REG_V21) + VXOR_VV(REG_V10, REG_V10, REG_V22) + VXOR_VV(REG_V11, REG_V11, REG_V23) + "mv t2, %[m]\n\t" + VL4RE32_V(REG_V20, REG_T2) + "addi %[m], %[m], 64\n\t" + "mv t2, %[c]\n\t" + VS4R_V(REG_V8, REG_T2) + "addi %[c], %[c], 64\n\t" + /* BLOCK 4 */ + "addi t0, t0, 1\n\t" + VMV_S_X(REG_V31, REG_T0) + VADD_VV(REG_V12, REG_V12, REG_V28) + VADD_VV(REG_V13, REG_V13, REG_V29) + VADD_VV(REG_V14, REG_V14, REG_V30) + VADD_VV(REG_V15, REG_V15, REG_V31) + VXOR_VV(REG_V12, REG_V12, REG_V20) + VXOR_VV(REG_V13, REG_V13, REG_V21) + VXOR_VV(REG_V14, REG_V14, REG_V22) + VXOR_VV(REG_V15, REG_V15, REG_V23) + "mv t2, %[m]\n\t" + VL4RE32_V(REG_V20, REG_T2) + "addi %[m], %[m], 64\n\t" + "mv t2, %[c]\n\t" + VS4R_V(REG_V12, REG_T2) + "addi %[c], %[c], 64\n\t" + /* BLOCK 5 */ + "addi t0, t0, 1\n\t" + VMV_S_X(REG_V31, REG_T0) + VADD_VV(REG_V16, REG_V16, REG_V28) + VADD_VV(REG_V17, REG_V17, REG_V29) + VADD_VV(REG_V18, REG_V18, REG_V30) + VADD_VV(REG_V19, REG_V19, REG_V31) + VXOR_VV(REG_V16, REG_V16, REG_V20) + VXOR_VV(REG_V17, REG_V17, REG_V21) + VXOR_VV(REG_V18, REG_V18, REG_V22) + VXOR_VV(REG_V19, REG_V19, REG_V23) + "mv t2, %[m]\n\t" + VL4RE32_V(REG_V20, REG_T2) + "addi %[m], %[m], 64\n\t" + "mv t2, %[c]\n\t" + VS4R_V(REG_V16, REG_T2) + "addi %[c], %[c], 64\n\t" + /* BLOCK 6 */ + /* Move regular registers into vector registers for adding and xor */ + "addi t0, t0, 1\n\t" + VMV_S_X(REG_V0, REG_A4) + VMV_S_X(REG_V1, REG_T3) + VMV_S_X(REG_V2, REG_S2) + VMV_S_X(REG_V3, REG_S6) + VMV_S_X(REG_V4, REG_A5) + VMV_S_X(REG_V5, REG_T4) + VMV_S_X(REG_V6, REG_S3) + VMV_S_X(REG_V7, REG_S7) + VSLIDEUP_VI(REG_V0, REG_V4, 1) + VSLIDEUP_VI(REG_V1, REG_V5, 1) + VSLIDEUP_VI(REG_V2, REG_V6, 1) + VSLIDEUP_VI(REG_V3, REG_V7, 1) + VMV_S_X(REG_V4, REG_A6) + VMV_S_X(REG_V5, REG_T5) + VMV_S_X(REG_V6, REG_S4) + VMV_S_X(REG_V7, REG_S8) + VSLIDEUP_VI(REG_V0, REG_V4, 2) + VSLIDEUP_VI(REG_V1, REG_V5, 2) + VSLIDEUP_VI(REG_V2, REG_V6, 2) + VSLIDEUP_VI(REG_V3, REG_V7, 2) + VMV_S_X(REG_V4, REG_A7) + VMV_S_X(REG_V5, REG_T6) + VMV_S_X(REG_V6, REG_S5) + VMV_S_X(REG_V7, REG_S9) + VSLIDEUP_VI(REG_V0, REG_V4, 3) + VSLIDEUP_VI(REG_V1, REG_V5, 3) + VSLIDEUP_VI(REG_V2, REG_V6, 3) + VSLIDEUP_VI(REG_V3, REG_V7, 3) + VMV_S_X(REG_V31, REG_T0) + /* Add back state, XOR in message and store */ + VADD_VV(REG_V0, REG_V0, REG_V28) + VADD_VV(REG_V1, REG_V1, REG_V29) + VADD_VV(REG_V2, REG_V2, REG_V30) + VADD_VV(REG_V3, REG_V3, REG_V31) + VXOR_VV(REG_V0, REG_V0, REG_V20) + VXOR_VV(REG_V1, REG_V1, REG_V21) + VXOR_VV(REG_V2, REG_V2, REG_V22) + VXOR_VV(REG_V3, REG_V3, REG_V23) + "mv t2, %[c]\n\t" + VS4R_V(REG_V0, REG_T2) + "addi %[c], %[c], 64\n\t" + "addi %[bytes], %[bytes], -384\n\t" + "addi t0, t0, 1\n\t" + VMV_S_X(REG_V31, REG_T0) + "bnez %[bytes], L_chacha20_riscv_384_outer\n\t" + : [m] "+r" (m), [c] "+r" (c), [bytes] "+r" (bytes64) + : [input] "r" (input) + : "memory", "t0", "t1", "t2", "s1", "a3", + "t3", "t4", "t5", "t6", + "a4", "a5", "a6", "a7", + "s2", "s3", "s4", "s5", + "s6", "s7", "s8", "s9" + ); +} + +#ifndef WOLFSSL_RISCV_VECTOR_BASE_BIT_MANIPULATION + +#define PART_ROUND_ODD_ABD(s, sr) \ + "add " CC_A0 ", " CC_A0 ", " CC_B0 "\n\t" \ + VADD_VV(REG_V0, REG_V0, REG_V1) \ + "add " CC_A1 ", " CC_A1 ", " CC_B1 "\n\t" \ + VADD_VV(REG_V4, REG_V4, REG_V5) \ + "add " CC_A2 ", " CC_A2 ", " CC_B2 "\n\t" \ + VADD_VV(REG_V8, REG_V8, REG_V9) \ + "add " CC_A3 ", " CC_A3 ", " CC_B3 "\n\t" \ + VXOR_VV(REG_V3, REG_V3, REG_V0) \ + "xor " CC_D0 ", " CC_D0 ", " CC_A0 "\n\t" \ + VXOR_VV(REG_V7, REG_V7, REG_V4) \ + "xor " CC_D1 ", " CC_D1 ", " CC_A1 "\n\t" \ + VXOR_VV(REG_V11, REG_V11, REG_V8) \ + "xor " CC_D2 ", " CC_D2 ", " CC_A2 "\n\t" \ + VSLL_VI(REG_V20, REG_V3, s) \ + "xor " CC_D3 ", " CC_D3 ", " CC_A3 "\n\t" \ + VSLL_VI(REG_V21, REG_V7, s) \ + "slli " CC_T0 ", " CC_D0 ", " #s "\n\t" \ + VSLL_VI(REG_V22, REG_V11, s) \ + "slli " CC_T1 ", " CC_D1 ", " #s "\n\t" \ + VSRL_VI(REG_V3, REG_V3, sr) \ + "slli " CC_T2 ", " CC_D2 ", " #s "\n\t" \ + VSRL_VI(REG_V7, REG_V7, sr) \ + "slli " CC_T3 ", " CC_D3 ", " #s "\n\t" \ + VSRL_VI(REG_V11, REG_V11, sr) \ + "srliw " CC_D0 ", " CC_D0 ", " #sr "\n\t" \ + VOR_VV(REG_V3, REG_V3, REG_V20) \ + "srliw " CC_D1 ", " CC_D1 ", " #sr "\n\t" \ + VOR_VV(REG_V7, REG_V7, REG_V21) \ + "srliw " CC_D2 ", " CC_D2 ", " #sr "\n\t" \ + VOR_VV(REG_V11, REG_V11, REG_V22) \ + "srliw " CC_D3 ", " CC_D3 ", " #sr "\n\t" \ + "or " CC_D0 ", " CC_D0 ", " CC_T0 "\n\t" \ + "or " CC_D1 ", " CC_D1 ", " CC_T1 "\n\t" \ + "or " CC_D2 ", " CC_D2 ", " CC_T2 "\n\t" \ + "or " CC_D3 ", " CC_D3 ", " CC_T3 "\n\t" + +#define PART_ROUND_ODD_CDB(s, sr) \ + "add " CC_C0 ", " CC_C0 ", " CC_D0 "\n\t" \ + VADD_VV(REG_V2, REG_V2, REG_V3) \ + "add " CC_C1 ", " CC_C1 ", " CC_D1 "\n\t" \ + VADD_VV(REG_V6, REG_V6, REG_V7) \ + "add " CC_C2 ", " CC_C2 ", " CC_D2 "\n\t" \ + VADD_VV(REG_V10, REG_V10, REG_V11) \ + "add " CC_C3 ", " CC_C3 ", " CC_D3 "\n\t" \ + VXOR_VV(REG_V1, REG_V1, REG_V2) \ + "xor " CC_B0 ", " CC_B0 ", " CC_C0 "\n\t" \ + VXOR_VV(REG_V5, REG_V5, REG_V6) \ + "xor " CC_B1 ", " CC_B1 ", " CC_C1 "\n\t" \ + VXOR_VV(REG_V9, REG_V9, REG_V10) \ + "xor " CC_B2 ", " CC_B2 ", " CC_C2 "\n\t" \ + VSLL_VI(REG_V20, REG_V1, s) \ + "xor " CC_B3 ", " CC_B3 ", " CC_C3 "\n\t" \ + VSLL_VI(REG_V21, REG_V5, s) \ + "slli " CC_T0 ", " CC_B0 ", " #s "\n\t" \ + VSLL_VI(REG_V22, REG_V9, s) \ + "slli " CC_T1 ", " CC_B1 ", " #s "\n\t" \ + VSRL_VI(REG_V1, REG_V1, sr) \ + "slli " CC_T2 ", " CC_B2 ", " #s "\n\t" \ + VSRL_VI(REG_V5, REG_V5, sr) \ + "slli " CC_T3 ", " CC_B3 ", " #s "\n\t" \ + VSRL_VI(REG_V9, REG_V9, sr) \ + "srliw " CC_B0 ", " CC_B0 ", " #sr "\n\t" \ + VOR_VV(REG_V1, REG_V1, REG_V20) \ + "srliw " CC_B1 ", " CC_B1 ", " #sr "\n\t" \ + VOR_VV(REG_V5, REG_V5, REG_V21) \ + "srliw " CC_B2 ", " CC_B2 ", " #sr "\n\t" \ + VOR_VV(REG_V9, REG_V9, REG_V22) \ + "srliw " CC_B3 ", " CC_B3 ", " #sr "\n\t" \ + "or " CC_B0 ", " CC_B0 ", " CC_T0 "\n\t" \ + "or " CC_B1 ", " CC_B1 ", " CC_T1 "\n\t" \ + "or " CC_B2 ", " CC_B2 ", " CC_T2 "\n\t" \ + "or " CC_B3 ", " CC_B3 ", " CC_T3 "\n\t" + +#define PART_ROUND_EVEN_ABD(s, sr) \ + "add " CC_A0 ", " CC_A0 ", " CC_B1 "\n\t" \ + VADD_VV(REG_V0, REG_V0, REG_V1) \ + "add " CC_A1 ", " CC_A1 ", " CC_B2 "\n\t" \ + VADD_VV(REG_V4, REG_V4, REG_V5) \ + "add " CC_A2 ", " CC_A2 ", " CC_B3 "\n\t" \ + VADD_VV(REG_V8, REG_V8, REG_V9) \ + "add " CC_A3 ", " CC_A3 ", " CC_B0 "\n\t" \ + VXOR_VV(REG_V3, REG_V3, REG_V0) \ + "xor " CC_D3 ", " CC_D3 ", " CC_A0 "\n\t" \ + VXOR_VV(REG_V7, REG_V7, REG_V4) \ + "xor " CC_D0 ", " CC_D0 ", " CC_A1 "\n\t" \ + VXOR_VV(REG_V11, REG_V11, REG_V8) \ + "xor " CC_D1 ", " CC_D1 ", " CC_A2 "\n\t" \ + VSLL_VI(REG_V20, REG_V3, s) \ + "xor " CC_D2 ", " CC_D2 ", " CC_A3 "\n\t" \ + VSLL_VI(REG_V21, REG_V7, s) \ + "slli " CC_T0 ", " CC_D3 ", " #s "\n\t" \ + VSLL_VI(REG_V22, REG_V11, s) \ + "slli " CC_T1 ", " CC_D0 ", " #s "\n\t" \ + VSRL_VI(REG_V3, REG_V3, sr) \ + "slli " CC_T2 ", " CC_D1 ", " #s "\n\t" \ + VSRL_VI(REG_V7, REG_V7, sr) \ + "slli " CC_T3 ", " CC_D2 ", " #s "\n\t" \ + VSRL_VI(REG_V11, REG_V11, sr) \ + "srliw " CC_D3 ", " CC_D3 ", " #sr "\n\t" \ + VOR_VV(REG_V3, REG_V3, REG_V20) \ + "srliw " CC_D0 ", " CC_D0 ", " #sr "\n\t" \ + VOR_VV(REG_V7, REG_V7, REG_V21) \ + "srliw " CC_D1 ", " CC_D1 ", " #sr "\n\t" \ + VOR_VV(REG_V11, REG_V11, REG_V22) \ + "srliw " CC_D2 ", " CC_D2 ", " #sr "\n\t" \ + "or " CC_D3 ", " CC_D3 ", " CC_T0 "\n\t" \ + "or " CC_D0 ", " CC_D0 ", " CC_T1 "\n\t" \ + "or " CC_D1 ", " CC_D1 ", " CC_T2 "\n\t" \ + "or " CC_D2 ", " CC_D2 ", " CC_T3 "\n\t" + +#define PART_ROUND_EVEN_CDB(s, sr) \ + "add " CC_C2 ", " CC_C2 ", " CC_D3 "\n\t" \ + VADD_VV(REG_V2, REG_V2, REG_V3) \ + "add " CC_C3 ", " CC_C3 ", " CC_D0 "\n\t" \ + VADD_VV(REG_V6, REG_V6, REG_V7) \ + "add " CC_C0 ", " CC_C0 ", " CC_D1 "\n\t" \ + VADD_VV(REG_V10, REG_V10, REG_V11) \ + "add " CC_C1 ", " CC_C1 ", " CC_D2 "\n\t" \ + VXOR_VV(REG_V1, REG_V1, REG_V2) \ + "xor " CC_B1 ", " CC_B1 ", " CC_C2 "\n\t" \ + VXOR_VV(REG_V5, REG_V5, REG_V6) \ + "xor " CC_B2 ", " CC_B2 ", " CC_C3 "\n\t" \ + VXOR_VV(REG_V9, REG_V9, REG_V10) \ + "xor " CC_B3 ", " CC_B3 ", " CC_C0 "\n\t" \ + VSLL_VI(REG_V20, REG_V1, s) \ + "xor " CC_B0 ", " CC_B0 ", " CC_C1 "\n\t" \ + VSLL_VI(REG_V21, REG_V5, s) \ + "slli " CC_T0 ", " CC_B1 ", " #s "\n\t" \ + VSLL_VI(REG_V22, REG_V9, s) \ + "slli " CC_T1 ", " CC_B2 ", " #s "\n\t" \ + VSRL_VI(REG_V1, REG_V1, sr) \ + "slli " CC_T2 ", " CC_B3 ", " #s "\n\t" \ + VSRL_VI(REG_V5, REG_V5, sr) \ + "slli " CC_T3 ", " CC_B0 ", " #s "\n\t" \ + VSRL_VI(REG_V9, REG_V9, sr) \ + "srliw " CC_B1 ", " CC_B1 ", " #sr "\n\t" \ + VOR_VV(REG_V1, REG_V1, REG_V20) \ + "srliw " CC_B2 ", " CC_B2 ", " #sr "\n\t" \ + VOR_VV(REG_V5, REG_V5, REG_V21) \ + "srliw " CC_B3 ", " CC_B3 ", " #sr "\n\t" \ + VOR_VV(REG_V9, REG_V9, REG_V22) \ + "srliw " CC_B0 ", " CC_B0 ", " #sr "\n\t" \ + "or " CC_B1 ", " CC_B1 ", " CC_T0 "\n\t" \ + "or " CC_B2 ", " CC_B2 ", " CC_T1 "\n\t" \ + "or " CC_B3 ", " CC_B3 ", " CC_T2 "\n\t" \ + "or " CC_B0 ", " CC_B0 ", " CC_T3 "\n\t" + +#elif !defined(WOLFSSL_RISCV_BASE_BIT_MANIPULATION ) + +#define PART_ROUND_ODD_ABD(s, sr) \ + "add " CC_A0 ", " CC_A0 ", " CC_B0 "\n\t" \ + VADD_VV(REG_V0, REG_V0, REG_V1) \ + "add " CC_A1 ", " CC_A1 ", " CC_B1 "\n\t" \ + VADD_VV(REG_V4, REG_V4, REG_V5) \ + "add " CC_A2 ", " CC_A2 ", " CC_B2 "\n\t" \ + VADD_VV(REG_V8, REG_V8, REG_V9) \ + "add " CC_A3 ", " CC_A3 ", " CC_B3 "\n\t" \ + VXOR_VV(REG_V3, REG_V3, REG_V0) \ + "xor " CC_D0 ", " CC_D0 ", " CC_A0 "\n\t" \ + VXOR_VV(REG_V7, REG_V7, REG_V4) \ + "xor " CC_D1 ", " CC_D1 ", " CC_A1 "\n\t" \ + VXOR_VV(REG_V11, REG_V11, REG_V8) \ + "xor " CC_D2 ", " CC_D2 ", " CC_A2 "\n\t" \ + VROR_VI(REG_V3, sr, REG_V3) \ + "xor " CC_D3 ", " CC_D3 ", " CC_A3 "\n\t" \ + VROR_VI(REG_V7, sr, REG_V7) \ + "slli " CC_T0 ", " CC_D0 ", " #s "\n\t" \ + VROR_VI(REG_V11, sr, REG_V11) \ + "slli " CC_T1 ", " CC_D1 ", " #s "\n\t" \ + "slli " CC_T2 ", " CC_D2 ", " #s "\n\t" \ + "slli " CC_T3 ", " CC_D3 ", " #s "\n\t" \ + "srliw " CC_D0 ", " CC_D0 ", " #sr "\n\t" \ + "srliw " CC_D1 ", " CC_D1 ", " #sr "\n\t" \ + "srliw " CC_D2 ", " CC_D2 ", " #sr "\n\t" \ + "srliw " CC_D3 ", " CC_D3 ", " #sr "\n\t" \ + "or " CC_D0 ", " CC_D0 ", " CC_T0 "\n\t" \ + "or " CC_D1 ", " CC_D1 ", " CC_T1 "\n\t" \ + "or " CC_D2 ", " CC_D2 ", " CC_T2 "\n\t" \ + "or " CC_D3 ", " CC_D3 ", " CC_T3 "\n\t" + +#define PART_ROUND_ODD_CDB(s, sr) \ + "add " CC_C0 ", " CC_C0 ", " CC_D0 "\n\t" \ + VADD_VV(REG_V2, REG_V2, REG_V3) \ + "add " CC_C1 ", " CC_C1 ", " CC_D1 "\n\t" \ + VADD_VV(REG_V6, REG_V6, REG_V7) \ + "add " CC_C2 ", " CC_C2 ", " CC_D2 "\n\t" \ + VADD_VV(REG_V10, REG_V10, REG_V11) \ + "add " CC_C3 ", " CC_C3 ", " CC_D3 "\n\t" \ + VXOR_VV(REG_V1, REG_V1, REG_V2) \ + "xor " CC_B0 ", " CC_B0 ", " CC_C0 "\n\t" \ + VXOR_VV(REG_V5, REG_V5, REG_V6) \ + "xor " CC_B1 ", " CC_B1 ", " CC_C1 "\n\t" \ + VXOR_VV(REG_V9, REG_V9, REG_V10) \ + "xor " CC_B2 ", " CC_B2 ", " CC_C2 "\n\t" \ + VROR_VI(REG_V1, sr, REG_V1) \ + "xor " CC_B3 ", " CC_B3 ", " CC_C3 "\n\t" \ + VROR_VI(REG_V5, sr, REG_V5) \ + "slli " CC_T0 ", " CC_B0 ", " #s "\n\t" \ + VROR_VI(REG_V9, sr, REG_V9) \ + "slli " CC_T1 ", " CC_B1 ", " #s "\n\t" \ + "slli " CC_T2 ", " CC_B2 ", " #s "\n\t" \ + "slli " CC_T3 ", " CC_B3 ", " #s "\n\t" \ + "srliw " CC_B0 ", " CC_B0 ", " #sr "\n\t" \ + "srliw " CC_B1 ", " CC_B1 ", " #sr "\n\t" \ + "srliw " CC_B2 ", " CC_B2 ", " #sr "\n\t" \ + "srliw " CC_B3 ", " CC_B3 ", " #sr "\n\t" \ + "or " CC_B0 ", " CC_B0 ", " CC_T0 "\n\t" \ + "or " CC_B1 ", " CC_B1 ", " CC_T1 "\n\t" \ + "or " CC_B2 ", " CC_B2 ", " CC_T2 "\n\t" \ + "or " CC_B3 ", " CC_B3 ", " CC_T3 "\n\t" + +#define PART_ROUND_EVEN_ABD(s, sr) \ + "add " CC_A0 ", " CC_A0 ", " CC_B1 "\n\t" \ + VADD_VV(REG_V0, REG_V0, REG_V1) \ + "add " CC_A1 ", " CC_A1 ", " CC_B2 "\n\t" \ + VADD_VV(REG_V4, REG_V4, REG_V5) \ + "add " CC_A2 ", " CC_A2 ", " CC_B3 "\n\t" \ + VADD_VV(REG_V8, REG_V8, REG_V9) \ + "add " CC_A3 ", " CC_A3 ", " CC_B0 "\n\t" \ + VXOR_VV(REG_V3, REG_V3, REG_V0) \ + "xor " CC_D3 ", " CC_D3 ", " CC_A0 "\n\t" \ + VXOR_VV(REG_V7, REG_V7, REG_V4) \ + "xor " CC_D0 ", " CC_D0 ", " CC_A1 "\n\t" \ + VXOR_VV(REG_V11, REG_V11, REG_V8) \ + "xor " CC_D1 ", " CC_D1 ", " CC_A2 "\n\t" \ + VROR_VI(REG_V3, sr, REG_V3) \ + "xor " CC_D2 ", " CC_D2 ", " CC_A3 "\n\t" \ + VROR_VI(REG_V7, sr, REG_V7) \ + "slli " CC_T0 ", " CC_D3 ", " #s "\n\t" \ + VROR_VI(REG_V11, sr, REG_V11) \ + "slli " CC_T1 ", " CC_D0 ", " #s "\n\t" \ + "slli " CC_T2 ", " CC_D1 ", " #s "\n\t" \ + "slli " CC_T3 ", " CC_D2 ", " #s "\n\t" \ + "srliw " CC_D3 ", " CC_D3 ", " #sr "\n\t" \ + "srliw " CC_D0 ", " CC_D0 ", " #sr "\n\t" \ + "srliw " CC_D1 ", " CC_D1 ", " #sr "\n\t" \ + "srliw " CC_D2 ", " CC_D2 ", " #sr "\n\t" \ + "or " CC_D3 ", " CC_D3 ", " CC_T0 "\n\t" \ + "or " CC_D0 ", " CC_D0 ", " CC_T1 "\n\t" \ + "or " CC_D1 ", " CC_D1 ", " CC_T2 "\n\t" \ + "or " CC_D2 ", " CC_D2 ", " CC_T3 "\n\t" + +#define PART_ROUND_EVEN_CDB(s, sr) \ + "add " CC_C2 ", " CC_C2 ", " CC_D3 "\n\t" \ + VADD_VV(REG_V2, REG_V2, REG_V3) \ + "add " CC_C3 ", " CC_C3 ", " CC_D0 "\n\t" \ + VADD_VV(REG_V6, REG_V6, REG_V7) \ + "add " CC_C0 ", " CC_C0 ", " CC_D1 "\n\t" \ + VADD_VV(REG_V10, REG_V10, REG_V11) \ + "add " CC_C1 ", " CC_C1 ", " CC_D2 "\n\t" \ + VXOR_VV(REG_V1, REG_V1, REG_V2) \ + "xor " CC_B1 ", " CC_B1 ", " CC_C2 "\n\t" \ + VXOR_VV(REG_V5, REG_V5, REG_V6) \ + "xor " CC_B2 ", " CC_B2 ", " CC_C3 "\n\t" \ + VXOR_VV(REG_V9, REG_V9, REG_V10) \ + "xor " CC_B3 ", " CC_B3 ", " CC_C0 "\n\t" \ + VROR_VI(REG_V1, sr, REG_V1) \ + "xor " CC_B0 ", " CC_B0 ", " CC_C1 "\n\t" \ + VROR_VI(REG_V5, sr, REG_V5) \ + "slli " CC_T0 ", " CC_B1 ", " #s "\n\t" \ + VROR_VI(REG_V9, sr, REG_V9) \ + "slli " CC_T1 ", " CC_B2 ", " #s "\n\t" \ + "slli " CC_T2 ", " CC_B3 ", " #s "\n\t" \ + "slli " CC_T3 ", " CC_B0 ", " #s "\n\t" \ + "srliw " CC_B1 ", " CC_B1 ", " #sr "\n\t" \ + "srliw " CC_B2 ", " CC_B2 ", " #sr "\n\t" \ + "srliw " CC_B3 ", " CC_B3 ", " #sr "\n\t" \ + "srliw " CC_B0 ", " CC_B0 ", " #sr "\n\t" \ + "or " CC_B1 ", " CC_B1 ", " CC_T0 "\n\t" \ + "or " CC_B2 ", " CC_B2 ", " CC_T1 "\n\t" \ + "or " CC_B3 ", " CC_B3 ", " CC_T2 "\n\t" \ + "or " CC_B0 ", " CC_B0 ", " CC_T3 "\n\t" + +#else + +#define PART_ROUND_ODD_ABD(s, sr) \ + "add " CC_A0 ", " CC_A0 ", " CC_B0 "\n\t" \ + VADD_VV(REG_V0, REG_V0, REG_V1) \ + "add " CC_A1 ", " CC_A1 ", " CC_B1 "\n\t" \ + VADD_VV(REG_V4, REG_V4, REG_V5) \ + "add " CC_A2 ", " CC_A2 ", " CC_B2 "\n\t" \ + VADD_VV(REG_V8, REG_V8, REG_V9) \ + "add " CC_A3 ", " CC_A3 ", " CC_B3 "\n\t" \ + VXOR_VV(REG_V3, REG_V3, REG_V0) \ + "xor " CC_D0 ", " CC_D0 ", " CC_A0 "\n\t" \ + VXOR_VV(REG_V7, REG_V7, REG_V4) \ + "xor " CC_D1 ", " CC_D1 ", " CC_A1 "\n\t" \ + VXOR_VV(REG_V11, REG_V11, REG_V8) \ + "xor " CC_D2 ", " CC_D2 ", " CC_A2 "\n\t" \ + VROR_VI(REG_V3, sr, REG_V3) \ + "xor " CC_D3 ", " CC_D3 ", " CC_A3 "\n\t" \ + VROR_VI(REG_V7, sr, REG_V7) \ + RORIW(REG_S6, REG_S6, sr) \ + VROR_VI(REG_V11, sr, REG_V11) \ + RORIW(REG_S7, REG_S7, sr) \ + RORIW(REG_S8, REG_S8, sr) \ + RORIW(REG_S9, REG_S9, sr) + +#define PART_ROUND_ODD_CDB(s, sr) \ + "add " CC_C0 ", " CC_C0 ", " CC_D0 "\n\t" \ + VADD_VV(REG_V2, REG_V2, REG_V3) \ + "add " CC_C1 ", " CC_C1 ", " CC_D1 "\n\t" \ + VADD_VV(REG_V6, REG_V6, REG_V7) \ + "add " CC_C2 ", " CC_C2 ", " CC_D2 "\n\t" \ + VADD_VV(REG_V10, REG_V10, REG_V11) \ + "add " CC_C3 ", " CC_C3 ", " CC_D3 "\n\t" \ + VXOR_VV(REG_V1, REG_V1, REG_V2) \ + "xor " CC_B0 ", " CC_B0 ", " CC_C0 "\n\t" \ + VXOR_VV(REG_V5, REG_V5, REG_V6) \ + "xor " CC_B1 ", " CC_B1 ", " CC_C1 "\n\t" \ + VXOR_VV(REG_V9, REG_V9, REG_V10) \ + "xor " CC_B2 ", " CC_B2 ", " CC_C2 "\n\t" \ + VROR_VI(REG_V1, sr, REG_V1) \ + "xor " CC_B3 ", " CC_B3 ", " CC_C3 "\n\t" \ + VROR_VI(REG_V5, sr, REG_V5) \ + RORIW(REG_T3, REG_T3, sr) \ + VROR_VI(REG_V9, sr, REG_V9) \ + RORIW(REG_T4, REG_T4, sr) \ + RORIW(REG_T5, REG_T5, sr) \ + RORIW(REG_T6, REG_T6, sr) + +#define PART_ROUND_EVEN_ABD(s, sr) \ + "add " CC_A0 ", " CC_A0 ", " CC_B1 "\n\t" \ + VADD_VV(REG_V0, REG_V0, REG_V1) \ + "add " CC_A1 ", " CC_A1 ", " CC_B2 "\n\t" \ + VADD_VV(REG_V4, REG_V4, REG_V5) \ + "add " CC_A2 ", " CC_A2 ", " CC_B3 "\n\t" \ + VADD_VV(REG_V8, REG_V8, REG_V9) \ + "add " CC_A3 ", " CC_A3 ", " CC_B0 "\n\t" \ + VXOR_VV(REG_V3, REG_V3, REG_V0) \ + "xor " CC_D3 ", " CC_D3 ", " CC_A0 "\n\t" \ + VXOR_VV(REG_V7, REG_V7, REG_V4) \ + "xor " CC_D0 ", " CC_D0 ", " CC_A1 "\n\t" \ + VXOR_VV(REG_V11, REG_V11, REG_V8) \ + "xor " CC_D1 ", " CC_D1 ", " CC_A2 "\n\t" \ + VROR_VI(REG_V3, sr, REG_V3) \ + "xor " CC_D2 ", " CC_D2 ", " CC_A3 "\n\t" \ + VROR_VI(REG_V7, sr, REG_V7) \ + RORIW(REG_S9, REG_S9, sr) \ + VROR_VI(REG_V11, sr, REG_V11) \ + RORIW(REG_S6, REG_S6, sr) \ + RORIW(REG_S7, REG_S7, sr) \ + RORIW(REG_S8, REG_S8, sr) + +#define PART_ROUND_EVEN_CDB(s, sr) \ + "add " CC_C2 ", " CC_C2 ", " CC_D3 "\n\t" \ + VADD_VV(REG_V2, REG_V2, REG_V3) \ + "add " CC_C3 ", " CC_C3 ", " CC_D0 "\n\t" \ + VADD_VV(REG_V6, REG_V6, REG_V7) \ + "add " CC_C0 ", " CC_C0 ", " CC_D1 "\n\t" \ + VADD_VV(REG_V10, REG_V10, REG_V11) \ + "add " CC_C1 ", " CC_C1 ", " CC_D2 "\n\t" \ + VXOR_VV(REG_V1, REG_V1, REG_V2) \ + "xor " CC_B1 ", " CC_B1 ", " CC_C2 "\n\t" \ + VXOR_VV(REG_V5, REG_V5, REG_V6) \ + "xor " CC_B2 ", " CC_B2 ", " CC_C3 "\n\t" \ + VXOR_VV(REG_V9, REG_V9, REG_V10) \ + "xor " CC_B3 ", " CC_B3 ", " CC_C0 "\n\t" \ + VROR_VI(REG_V1, sr, REG_V1) \ + "xor " CC_B0 ", " CC_B0 ", " CC_C1 "\n\t" \ + VROR_VI(REG_V5, sr, REG_V5) \ + "slli " CC_T0 ", " CC_B1 ", " #s "\n\t" \ + RORIW(REG_T4, REG_T4, sr) \ + VROR_VI(REG_V9, sr, REG_V9) \ + RORIW(REG_T5, REG_T5, sr) \ + RORIW(REG_T6, REG_T6, sr) \ + RORIW(REG_T3, REG_T3, sr) + +#endif + +#define QUARTER_ROUND_ODD_4() \ + /* a += b; d ^= a; d <<<= 16; */ \ + PART_ROUND_ODD_ABD(16, 16) \ + /* c += d; b ^= c; b <<<= 12; */ \ + PART_ROUND_ODD_CDB(12, 20) \ + /* a += b; d ^= a; d <<<= 8; */ \ + PART_ROUND_ODD_ABD( 8, 24) \ + /* c += d; b ^= c; b <<<= 7; */ \ + PART_ROUND_ODD_CDB( 7, 25) + +#define QUARTER_ROUND_EVEN_4() \ + /* a += b; d ^= a; d <<<= 16; */ \ + PART_ROUND_EVEN_ABD(16, 16) \ + /* c += d; b ^= c; b <<<= 12; */ \ + PART_ROUND_EVEN_CDB(12, 20) \ + /* a += b; d ^= a; d <<<= 8; */ \ + PART_ROUND_EVEN_ABD( 8, 24) \ + /* c += d; b ^= c; b <<<= 7; */ \ + PART_ROUND_EVEN_CDB( 7, 25) + +#define SHUFFLE_4(r, t, i) \ + VRGATHER_VV(t + 0, i, r + 0) \ + VRGATHER_VV(t + 1, i, r + 4) \ + VRGATHER_VV(t + 2, i, r + 8) \ + VMV_V_V(r + 0, t + 0) \ + VMV_V_V(r + 4, t + 1) \ + VMV_V_V(r + 8, t + 2) + +#define ODD_SHUFFLE_4() \ + /* a=0,1,2,3; b=4,5,6,7; c=8,9,10,11; d=12,13,14,15 \ + * => a=0,1,2,3; b=5,6,7,4; c=10,11,8,9; d=15,12,13,14 */ \ + SHUFFLE_4(REG_V3, REG_V20, REG_V25) \ + SHUFFLE_4(REG_V1, REG_V20, REG_V23) \ + SHUFFLE_4(REG_V2, REG_V20, REG_V24) + +#define EVEN_SHUFFLE_4() \ + /* a=0,1,2,3; b=5,6,7,4; c=10,11,8,9; d=15,12,13,14 \ + * => a=0,1,2,3; b=4,5,6,7; c=8,9,10,11; d=12,13,14,15 */ \ + SHUFFLE_4(REG_V3, REG_V20, REG_V23) \ + SHUFFLE_4(REG_V1, REG_V20, REG_V25) \ + SHUFFLE_4(REG_V2, REG_V20, REG_V24) + +/** + * Converts word into bytes with rotations having been done. + */ +static WC_INLINE int wc_chacha_encrypt_256(const word32* input, const byte* m, + byte* c) +{ + __asm__ __volatile__ ( + VSETIVLI(REG_X0, 4, 1, 1, 0b010, 0b000) + /* The layout of used vector registers is: + * v0-v3 - first block + * v4-v7 - second block + * v8-v11 - third block + * v12-v15 - message + * v16-v19 - input + * v20-v22 - temp + * v23-v25 - indeces for rotating words in vector + * + * v0 0 1 2 3 + * v1 4 5 6 7 + * v2 8 9 10 11 + * v3 12 13 14 15 + * load CHACHA state with indices placed as shown above + */ + + /* Load state to encrypt */ + "mv t2, %[input]\n\t" + VL4RE32_V(REG_V16, REG_T2) + VID_V(REG_V20) + VSLIDEDOWN_VI(REG_V23, REG_V20, 1) + VSLIDEUP_VI(REG_V23, REG_V20, 3) + VSLIDEDOWN_VI(REG_V24, REG_V20, 2) + VSLIDEUP_VI(REG_V24, REG_V20, 2) + VSLIDEDOWN_VI(REG_V25, REG_V20, 3) + VSLIDEUP_VI(REG_V25, REG_V20, 1) + /* Move state into regular registers */ + "ld a4, 0(%[input])\n\t" + "ld a6, 8(%[input])\n\t" + "ld t3, 16(%[input])\n\t" + "ld t5, 24(%[input])\n\t" + "ld s2, 32(%[input])\n\t" + "ld s4, 40(%[input])\n\t" + "ld s6, 48(%[input])\n\t" + "ld s8, 56(%[input])\n\t" + "srli a5, a4, 32\n\t" + "srli a7, a6, 32\n\t" + "srli t4, t3, 32\n\t" + "srli t6, t5, 32\n\t" + "srli s3, s2, 32\n\t" + "srli s5, s4, 32\n\t" + "srli s7, s6, 32\n\t" + "srli s9, s8, 32\n\t" + /* Move state into vector registers */ + VMVR_V(REG_V0, REG_V16, 4) + "addi t0, s6, 1\n\t" + VMVR_V(REG_V4, REG_V16, 4) + "addi t1, s6, 2\n\t" + VMVR_V(REG_V8, REG_V16, 4) + "addi s6, s6, 3\n\t" + /* Set counter word */ + VMV_S_X(REG_V7, REG_T0) + VMV_S_X(REG_V11, REG_T1) + /* Set number of odd+even rounds to perform */ + "li a3, 10\n\t" + "\n" + "L_chacha20_riscv_256_loop:\n\t" + /* Odd Round */ + QUARTER_ROUND_ODD_4() + ODD_SHUFFLE_4() + "addi a3, a3, -1\n\t" + /* Even Round */ + QUARTER_ROUND_EVEN_4() + EVEN_SHUFFLE_4() + "bnez a3, L_chacha20_riscv_256_loop\n\t" + /* Load message */ + "mv t2, %[m]\n\t" + VL4RE32_V(REG_V12, REG_T2) + "addi %[m], %[m], 64\n\t" + /* Add back state, XOR in message and store (load next block) */ + /* BLOCK 1 */ + VADD_VV(REG_V0, REG_V0, REG_V16) + VADD_VV(REG_V1, REG_V1, REG_V17) + VADD_VV(REG_V2, REG_V2, REG_V18) + VADD_VV(REG_V3, REG_V3, REG_V19) + VXOR_VV(REG_V0, REG_V0, REG_V12) + VXOR_VV(REG_V1, REG_V1, REG_V13) + VXOR_VV(REG_V2, REG_V2, REG_V14) + VXOR_VV(REG_V3, REG_V3, REG_V15) + "mv t2, %[m]\n\t" + VL4RE32_V(REG_V12, REG_T2) + "addi %[m], %[m], 64\n\t" + VMV_X_S(REG_T0, REG_V19) + "mv t2, %[c]\n\t" + VS4R_V(REG_V0, REG_T2) + "addi %[c], %[c], 64\n\t" + /* BLOCK 2 */ + "addi t0, t0, 1\n\t" + VMV_S_X(REG_V19, REG_T0) + VADD_VV(REG_V4, REG_V4, REG_V16) + VADD_VV(REG_V5, REG_V5, REG_V17) + VADD_VV(REG_V6, REG_V6, REG_V18) + VADD_VV(REG_V7, REG_V7, REG_V19) + VXOR_VV(REG_V4, REG_V4, REG_V12) + VXOR_VV(REG_V5, REG_V5, REG_V13) + VXOR_VV(REG_V6, REG_V6, REG_V14) + VXOR_VV(REG_V7, REG_V7, REG_V15) + "mv t2, %[m]\n\t" + VL4RE32_V(REG_V12, REG_T2) + "addi %[m], %[m], 64\n\t" + "mv t2, %[c]\n\t" + VS4R_V(REG_V4, REG_T2) + "addi %[c], %[c], 64\n\t" + /* BLOCK 3 */ + "addi t0, t0, 1\n\t" + VMV_S_X(REG_V19, REG_T0) + VADD_VV(REG_V8, REG_V8, REG_V16) + VADD_VV(REG_V9, REG_V9, REG_V17) + VADD_VV(REG_V10, REG_V10, REG_V18) + VADD_VV(REG_V11, REG_V11, REG_V19) + VXOR_VV(REG_V8, REG_V8, REG_V12) + VXOR_VV(REG_V9, REG_V9, REG_V13) + VXOR_VV(REG_V10, REG_V10, REG_V14) + VXOR_VV(REG_V11, REG_V11, REG_V15) + "mv t2, %[m]\n\t" + VL4RE32_V(REG_V12, REG_T2) + "mv t2, %[c]\n\t" + VS4R_V(REG_V8, REG_T2) + "addi %[c], %[c], 64\n\t" + /* BLOCK 4 */ + /* Move regular registers into vector registers for adding and xor */ + "addi t0, t0, 1\n\t" + VMV_S_X(REG_V0, REG_A4) + VMV_S_X(REG_V1, REG_T3) + VMV_S_X(REG_V2, REG_S2) + VMV_S_X(REG_V3, REG_S6) + VMV_S_X(REG_V4, REG_A5) + VMV_S_X(REG_V5, REG_T4) + VMV_S_X(REG_V6, REG_S3) + VMV_S_X(REG_V7, REG_S7) + VSLIDEUP_VI(REG_V0, REG_V4, 1) + VSLIDEUP_VI(REG_V1, REG_V5, 1) + VSLIDEUP_VI(REG_V2, REG_V6, 1) + VSLIDEUP_VI(REG_V3, REG_V7, 1) + VMV_S_X(REG_V4, REG_A6) + VMV_S_X(REG_V5, REG_T5) + VMV_S_X(REG_V6, REG_S4) + VMV_S_X(REG_V7, REG_S8) + VSLIDEUP_VI(REG_V0, REG_V4, 2) + VSLIDEUP_VI(REG_V1, REG_V5, 2) + VSLIDEUP_VI(REG_V2, REG_V6, 2) + VSLIDEUP_VI(REG_V3, REG_V7, 2) + VMV_S_X(REG_V4, REG_A7) + VMV_S_X(REG_V5, REG_T6) + VMV_S_X(REG_V6, REG_S5) + VMV_S_X(REG_V7, REG_S9) + VSLIDEUP_VI(REG_V0, REG_V4, 3) + VSLIDEUP_VI(REG_V1, REG_V5, 3) + VSLIDEUP_VI(REG_V2, REG_V6, 3) + VSLIDEUP_VI(REG_V3, REG_V7, 3) + VMV_S_X(REG_V19, REG_T0) + /* Add back state, XOR in message and store */ + VADD_VV(REG_V0, REG_V0, REG_V16) + VADD_VV(REG_V1, REG_V1, REG_V17) + VADD_VV(REG_V2, REG_V2, REG_V18) + VADD_VV(REG_V3, REG_V3, REG_V19) + VXOR_VV(REG_V0, REG_V0, REG_V12) + VXOR_VV(REG_V1, REG_V1, REG_V13) + VXOR_VV(REG_V2, REG_V2, REG_V14) + VXOR_VV(REG_V3, REG_V3, REG_V15) + "mv t2, %[c]\n\t" + VS4R_V(REG_V0, REG_T2) + : [m] "+r" (m), [c] "+r" (c) + : [input] "r" (input) + : "memory", "t0", "t1", "t2", "s1", "a3", + "t3", "t4", "t5", "t6", + "a4", "a5", "a6", "a7", + "s2", "s3", "s4", "s5", + "s6", "s7", "s8", "s9" + ); + return CHACHA_CHUNK_BYTES * 4; +} + +#ifndef WOLFSSL_RISCV_VECTOR_BASE_BIT_MANIPULATION + +#define PART_ROUND_2(a, b, d, t, a2, b2, d2, t2, sl, sr) \ + VADD_VV(a, a, b) \ + VADD_VV(a2, a2, b2) \ + VXOR_VV(d, d, a) \ + VXOR_VV(d2, d2, a2) \ + VSLL_VI(t, d, sl) \ + VSLL_VI(t2, d2, sl) \ + VSRL_VI(d, d, sr) \ + VSRL_VI(d2, d2, sr) \ + VOR_VV(d, d, t) \ + VOR_VV(d2, d2, t2) + +#else + +#define PART_ROUND_2(a, b, d, t, a2, b2, d2, t2, sl, sr) \ + VADD_VV(a, a, b) \ + VADD_VV(a2, a2, b2) \ + VXOR_VV(d, d, a) \ + VXOR_VV(d2, d2, a2) \ + VROR_VI(d, sr, d) \ + VROR_VI(d2, sr, d2) + +#endif + +#define QUARTER_ROUND_2(a, b, c, d, t, a2, b2, c2, d2, t2) \ + /* a += b; d ^= a; d <<<= 16; */ \ + PART_ROUND_2(a, b, d, t, a2, b2, d2, t2, 16, 16) \ + /* c += d; b ^= c; b <<<= 12; */ \ + PART_ROUND_2(c, d, b, t, c2, d2, b2, t2, 12, 20) \ + /* a += b; d ^= a; d <<<= 8; */ \ + PART_ROUND_2(a, b, d, t, a2, b2, d2, t2, 8, 24) \ + /* c += d; b ^= c; b <<<= 7; */ \ + PART_ROUND_2(c, d, b, t, c2, d2, b2, t2, 7, 25) + +#define ODD_SHUFFLE_2(b, c, d, t, b2, c2, d2, t2) \ + /* a=0,1,2,3; b=4,5,6,7; c=8,9,10,11; d=12,13,14,15 \ + * => a=0,1,2,3; b=5,6,7,4; c=10,11,8,9; d=15,12,13,14 */ \ + VRGATHER_VV(t, REG_V25, d) \ + VRGATHER_VV(t2, REG_V25, d2) \ + VMV_V_V(d, t) \ + VMV_V_V(d2, t2) \ + VRGATHER_VV(t, REG_V23, b) \ + VRGATHER_VV(t2, REG_V23, b2) \ + VMV_V_V(b, t) \ + VMV_V_V(b2, t2) \ + VRGATHER_VV(t, REG_V24, c) \ + VRGATHER_VV(t2, REG_V24, c2) \ + VMV_V_V(c, t) \ + VMV_V_V(c2, t2) + +#define EVEN_SHUFFLE_2(b, c, d, t, b2, c2, d2, t2) \ + /* a=0,1,2,3; b=5,6,7,4; c=10,11,8,9; d=15,12,13,14 \ + * => a=0,1,2,3; b=4,5,6,7; c=8,9,10,11; d=12,13,14,15 */ \ + VRGATHER_VV(t, REG_V23, d) \ + VRGATHER_VV(t2, REG_V23, d2) \ + VMV_V_V(d, t) \ + VMV_V_V(d2, t2) \ + VRGATHER_VV(t, REG_V25, b) \ + VRGATHER_VV(t2, REG_V25, b2) \ + VMV_V_V(b, t) \ + VMV_V_V(b2, t2) \ + VRGATHER_VV(t, REG_V24, c) \ + VRGATHER_VV(t2, REG_V24, c2) \ + VMV_V_V(c, t) \ + VMV_V_V(c2, t2) + + +static WC_INLINE int wc_chacha_encrypt_128(const word32* input, const byte* m, + byte* c) +{ + __asm__ __volatile__ ( + VSETIVLI(REG_X0, 4, 1, 1, 0b010, 0b000) + /* The layout of used vector registers is: + * v0-v3 - first block + * v4-v7 - second block + * v12-v15 - message + * v16-v19 - input + * v20-v22 - temp + * v23-v25 - indeces for rotating words in vector + * + * v0 0 1 2 3 + * v1 4 5 6 7 + * v2 8 9 10 11 + * v3 12 13 14 15 + * load CHACHA state with indices placed as shown above + */ + + /* Load incrementer register to modify counter */ + "mv t2, %[L_chacha20_vec_inc_first_word]\n\t" + VL1RE32_V(REG_V22, REG_T2) + VID_V(REG_V20) + VSLIDEDOWN_VI(REG_V23, REG_V20, 1) + VSLIDEUP_VI(REG_V23, REG_V20, 3) + VSLIDEDOWN_VI(REG_V24, REG_V20, 2) + VSLIDEUP_VI(REG_V24, REG_V20, 2) + VSLIDEDOWN_VI(REG_V25, REG_V20, 3) + VSLIDEUP_VI(REG_V25, REG_V20, 1) + /* Load state to encrypt */ + "mv t2, %[input]\n\t" + VL4RE32_V(REG_V16, REG_T2) + /* Load message */ + "mv t2, %[m]\n\t" + VL4RE32_V(REG_V12, REG_T2) + "addi %[m], %[m], 64\n\t" + /* Move state into vector registers */ + VMVR_V(REG_V0, REG_V16, 4) + VMVR_V(REG_V4, REG_V16, 4) + /* Add counter word */ + VADD_VV(REG_V7, REG_V7, REG_V22) + /* Set number of odd+even rounds to perform */ + "li t0, 10\n\t" + "\n" + "L_chacha20_riscv_128_loop:\n\t" + QUARTER_ROUND_2(REG_V0, REG_V1, REG_V2, REG_V3, REG_V20, + REG_V4, REG_V5, REG_V6, REG_V7, REG_V21) + ODD_SHUFFLE_2(REG_V1, REG_V2, REG_V3, REG_V20, + REG_V5, REG_V6, REG_V7, REG_V21) + QUARTER_ROUND_2(REG_V0, REG_V1, REG_V2, REG_V3, REG_V20, + REG_V4, REG_V5, REG_V6, REG_V7, REG_V21) + EVEN_SHUFFLE_2(REG_V1, REG_V2, REG_V3, REG_V20, + REG_V5, REG_V6, REG_V7, REG_V21) + "addi t0, t0, -1\n\t" + "bnez t0, L_chacha20_riscv_128_loop\n\t" + /* Add back state, XOR in message and store (load next block) */ + VADD_VV(REG_V0, REG_V0, REG_V16) + VADD_VV(REG_V1, REG_V1, REG_V17) + VADD_VV(REG_V2, REG_V2, REG_V18) + VADD_VV(REG_V3, REG_V3, REG_V19) + VXOR_VV(REG_V0, REG_V0, REG_V12) + VXOR_VV(REG_V1, REG_V1, REG_V13) + VXOR_VV(REG_V2, REG_V2, REG_V14) + VXOR_VV(REG_V3, REG_V3, REG_V15) + "mv t2, %[m]\n\t" + VL4RE32_V(REG_V12, REG_T2) + "mv t2, %[c]\n\t" + VS4R_V(REG_V0, REG_T2) + "addi %[c], %[c], 64\n\t" + VADD_VV(REG_V19, REG_V19, REG_V22) + VADD_VV(REG_V4, REG_V4, REG_V16) + VADD_VV(REG_V5, REG_V5, REG_V17) + VADD_VV(REG_V6, REG_V6, REG_V18) + VADD_VV(REG_V7, REG_V7, REG_V19) + VXOR_VV(REG_V4, REG_V4, REG_V12) + VXOR_VV(REG_V5, REG_V5, REG_V13) + VXOR_VV(REG_V6, REG_V6, REG_V14) + VXOR_VV(REG_V7, REG_V7, REG_V15) + "mv t2, %[c]\n\t" + VS4R_V(REG_V4, REG_T2) + : [m] "+r" (m), [c] "+r" (c) + : [input] "r" (input), + [L_chacha20_vec_inc_first_word] "r" (L_chacha20_vec_inc_first_word) + : "memory", "t0", "t1", "t2" + ); + return CHACHA_CHUNK_BYTES * 2; +} + +#ifndef WOLFSSL_RISCV_VECTOR_BASE_BIT_MANIPULATION + +#define PART_ROUND(a, b, d, t, sl, sr) \ + VADD_VV(a, a, b) \ + VXOR_VV(d, d, a) \ + VSLL_VI(t, d, sl) \ + VSRL_VI(d, d, sr) \ + VOR_VV(d, d, t) + +#else + +#define PART_ROUND(a, b, d, t, sl, sr) \ + VADD_VV(a, a, b) \ + VXOR_VV(d, d, a) \ + VROR_VI(d, sr, d) + +#endif + +#define QUARTER_ROUND(a, b, c, d, t) \ + /* a += b; d ^= a; d <<<= 16; */ \ + PART_ROUND(a, b, d, t, 16, 16) \ + /* c += d; b ^= c; b <<<= 12; */ \ + PART_ROUND(c, d, b, t, 12, 20) \ + /* a += b; d ^= a; d <<<= 8; */ \ + PART_ROUND(a, b, d, t, 8, 24) \ + /* c += d; b ^= c; b <<<= 7; */ \ + PART_ROUND(c, d, b, t, 7, 25) + +#define ODD_SHUFFLE(b, c, d, t) \ + /* a=0,1,2,3; b=4,5,6,7; c=8,9,10,11; d=12,13,14,15 \ + * => a=0,1,2,3; b=5,6,7,4; c=10,11,8,9; d=15,12,13,14 */ \ + VSLIDEDOWN_VI(t, d, 3) \ + VSLIDEUP_VI(t, d, 1) \ + VMV_V_V(d, t) \ + VSLIDEDOWN_VI(t, b, 1) \ + VSLIDEUP_VI(t, b, 3) \ + VMV_V_V(b, t) \ + VSLIDEDOWN_VI(t, c, 2) \ + VSLIDEUP_VI(t, c, 2) \ + VMV_V_V(c, t) + +#define EVEN_SHUFFLE(b, c, d, t) \ + /* a=0,1,2,3; b=5,6,7,4; c=10,11,8,9; d=15,12,13,14 \ + * => a=0,1,2,3; b=4,5,6,7; c=8,9,10,11; d=12,13,14,15 */ \ + VSLIDEDOWN_VI(t, d, 1) \ + VSLIDEUP_VI(t, d, 3) \ + VMV_V_V(d, t) \ + VSLIDEDOWN_VI(t, b, 3) \ + VSLIDEUP_VI(t, b, 1) \ + VMV_V_V(b, t) \ + VSLIDEDOWN_VI(t, c, 2) \ + VSLIDEUP_VI(t, c, 2) \ + VMV_V_V(c, t) + +#define EIGHT_QUARTER_ROUNDS(a, b, c, d, t) \ + /* Odd Round */ \ + QUARTER_ROUND(a, b, c, d, t) \ + ODD_SHUFFLE(b, c, d, t) \ + /* Even Round */ \ + QUARTER_ROUND(a, b, c, d, t) \ + EVEN_SHUFFLE(b, c, d, t) + +static WC_INLINE void wc_chacha_encrypt_64(const word32* input, const byte* m, + byte* c, word32 bytes, byte* over) +{ + word64 bytes64 = (word64)bytes; + + __asm__ __volatile__ ( + VSETIVLI(REG_X0, 4, 1, 1, 0b010, 0b000) + /* The layout of used vector registers is: + * v0-v3 - block + * v4-v7 - message + * v8-v11 - input + * v12 - temp + * + * v0 0 1 2 3 + * v1 4 5 6 7 + * v2 8 9 10 11 + * v3 12 13 14 15 + * load CHACHA state with indices placed as shown above + */ + + /* Load incrementer register to modify counter */ + "mv t2, %[L_chacha20_vec_inc_first_word]\n\t" + VL1RE32_V(REG_V13, REG_T2) + /* Load state to encrypt */ + "mv t2, %[input]\n\t" + VL4RE32_V(REG_V8, REG_T2) + "\n" + "L_chacha20_riscv_64_loop:\n\t" + /* Move state into vector registers */ + VMVR_V(REG_V0, REG_V8, 4) + /* Add counter word */ + /* Odd Round */ + EIGHT_QUARTER_ROUNDS(REG_V0, REG_V1, REG_V2, REG_V3, REG_V12) + EIGHT_QUARTER_ROUNDS(REG_V0, REG_V1, REG_V2, REG_V3, REG_V12) + EIGHT_QUARTER_ROUNDS(REG_V0, REG_V1, REG_V2, REG_V3, REG_V12) + EIGHT_QUARTER_ROUNDS(REG_V0, REG_V1, REG_V2, REG_V3, REG_V12) + EIGHT_QUARTER_ROUNDS(REG_V0, REG_V1, REG_V2, REG_V3, REG_V12) + EIGHT_QUARTER_ROUNDS(REG_V0, REG_V1, REG_V2, REG_V3, REG_V12) + EIGHT_QUARTER_ROUNDS(REG_V0, REG_V1, REG_V2, REG_V3, REG_V12) + EIGHT_QUARTER_ROUNDS(REG_V0, REG_V1, REG_V2, REG_V3, REG_V12) + EIGHT_QUARTER_ROUNDS(REG_V0, REG_V1, REG_V2, REG_V3, REG_V12) + EIGHT_QUARTER_ROUNDS(REG_V0, REG_V1, REG_V2, REG_V3, REG_V12) + "addi t1, %[bytes], -64\n\t" + /* Add back state */ + VADD_VV(REG_V0, REG_V0, REG_V8) + VADD_VV(REG_V1, REG_V1, REG_V9) + VADD_VV(REG_V2, REG_V2, REG_V10) + VADD_VV(REG_V3, REG_V3, REG_V11) + "bltz t1, L_chacha20_riscv_64_lt_64\n\t" + "mv t2, %[m]\n\t" + VL4RE32_V(REG_V4, REG_T2) + VXOR_VV(REG_V4, REG_V4, REG_V0) + VXOR_VV(REG_V5, REG_V5, REG_V1) + VXOR_VV(REG_V6, REG_V6, REG_V2) + VXOR_VV(REG_V7, REG_V7, REG_V3) + "mv t2, %[c]\n\t" + VS4R_V(REG_V4, REG_T2) + "addi %[bytes], %[bytes], -64\n\t" + "addi %[c], %[c], 64\n\t" + "addi %[m], %[m], 64\n\t" + VADD_VV(REG_V11, REG_V11, REG_V13) + "bnez %[bytes], L_chacha20_riscv_64_loop\n\t" + "beqz %[bytes], L_chacha20_riscv_64_done\n\t" + "\n" + "L_chacha20_riscv_64_lt_64:\n\t" + "mv t2, %[over]\n\t" + "addi t1, %[bytes], -32\n\t" + VS4R_V(REG_V0, REG_T2) + + "bltz t1, L_chacha20_riscv_64_lt_32\n\t" + "mv t2, %[m]\n\t" + VL2RE32_V(REG_V4, REG_T2) + VXOR_VV(REG_V4, REG_V4, REG_V0) + VXOR_VV(REG_V5, REG_V5, REG_V1) + "mv t2, %[c]\n\t" + VS2R_V(REG_V4, REG_T2) + "addi %[bytes], %[bytes], -32\n\t" + "addi %[c], %[c], 32\n\t" + "addi %[m], %[m], 32\n\t" + "beqz %[bytes], L_chacha20_riscv_64_done\n\t" + VMVR_V(REG_V0, REG_V2, 2) + "\n" + "L_chacha20_riscv_64_lt_32:\n\t" + "addi t1, %[bytes], -16\n\t" + "bltz t1, L_chacha20_riscv_64_lt_16\n\t" + "mv t2, %[m]\n\t" + VL1RE32_V(REG_V4, REG_T2) + VXOR_VV(REG_V4, REG_V4, REG_V0) + "mv t2, %[c]\n\t" + VS1R_V(REG_V4, REG_T2) + "addi %[bytes], %[bytes], -16\n\t" + "addi %[c], %[c], 16\n\t" + "addi %[m], %[m], 16\n\t" + "beqz %[bytes], L_chacha20_riscv_64_done\n\t" + VMV_V_V(REG_V0, REG_V1) + "\n" + "L_chacha20_riscv_64_lt_16:\n\t" + "addi t1, %[bytes], -8\n\t" + "bltz t1, L_chacha20_riscv_64_lt_8\n\t" + VSETIVLI(REG_X0, 2, 1, 1, 0b011, 0b000) + VMV_X_S(REG_T0, REG_V0) + VSETIVLI(REG_X0, 4, 1, 1, 0b010, 0b000) + "ld t1, (%[m])\n\t" + "xor t1, t1, t0\n\t" + "sd t1, (%[c])\n\t" + "addi %[bytes], %[bytes], -8\n\t" + "addi %[c], %[c], 8\n\t" + "addi %[m], %[m], 8\n\t" + "beqz %[bytes], L_chacha20_riscv_64_done\n\t" + VSLIDEDOWN_VI(REG_V0, REG_V0, 2) + "\n" + "L_chacha20_riscv_64_lt_8:\n\t" + "addi %[bytes], %[bytes], -1\n\t" + VSETIVLI(REG_X0, 2, 1, 1, 0b011, 0b000) + VMV_X_S(REG_T0, REG_V0) + VSETIVLI(REG_X0, 4, 1, 1, 0b010, 0b000) + "\n" + "L_chacha20_riscv_64_loop_lt_8:\n\t" + "addi %[bytes], %[bytes], -1\n\t" + "lb t1, (%[m])\n\t" + "addi %[m], %[m], 1\n\t" + "xor t1, t1, t0\n\t" + "sb t1, (%[c])\n\t" + "addi %[c], %[c], 1\n\t" + "srli t0, t0, 8\n\t" + "bgez %[bytes], L_chacha20_riscv_64_loop_lt_8\n\t" + "\n" + "L_chacha20_riscv_64_done:\n\t" + : [m] "+r" (m), [c] "+r" (c), [bytes] "+r" (bytes64) + : [input] "r" (input), [over] "r" (over), + [L_chacha20_vec_inc_first_word] "r" (L_chacha20_vec_inc_first_word) + : "memory", "t0", "t1", "t2" + ); +} + +/** + * Encrypt a stream of bytes + */ +static void wc_chacha_encrypt_bytes(ChaCha* ctx, const byte* m, byte* c, + word32 bytes) +{ + int processed; + + if (bytes >= CHACHA_CHUNK_BYTES * 6) { + processed = (bytes / (CHACHA_CHUNK_BYTES * 6)) * CHACHA_CHUNK_BYTES * 6; + wc_chacha_encrypt_384(ctx->X, m, c, processed); + + bytes -= processed; + c += processed; + m += processed; + ctx->X[CHACHA_IV_BYTES] = PLUS(ctx->X[CHACHA_IV_BYTES], + processed / CHACHA_CHUNK_BYTES); + } + if (bytes >= CHACHA_CHUNK_BYTES * 4) { + processed = wc_chacha_encrypt_256(ctx->X, m, c); + + bytes -= processed; + c += processed; + m += processed; + ctx->X[CHACHA_IV_BYTES] = PLUS(ctx->X[CHACHA_IV_BYTES], + processed / CHACHA_CHUNK_BYTES); + } + if (bytes >= CHACHA_CHUNK_BYTES * 2) { + processed = wc_chacha_encrypt_128(ctx->X, m, c); + + bytes -= processed; + c += processed; + m += processed; + ctx->X[CHACHA_IV_BYTES] = PLUS(ctx->X[CHACHA_IV_BYTES], + processed / CHACHA_CHUNK_BYTES); + } + if (bytes > 0) { + wc_chacha_encrypt_64(ctx->X, m, c, bytes, (byte*)ctx->over); + if (bytes > CHACHA_CHUNK_BYTES) + ctx->X[CHACHA_IV_BYTES] = PLUSONE(ctx->X[CHACHA_IV_BYTES]); + ctx->left = CHACHA_CHUNK_BYTES - (bytes & (CHACHA_CHUNK_BYTES - 1)); + ctx->left &= CHACHA_CHUNK_BYTES - 1; + ctx->X[CHACHA_IV_BYTES] = PLUSONE(ctx->X[CHACHA_IV_BYTES]); + } +} + +#else + +#if !defined(WOLFSSL_RISCV_BIT_MANIPULATION) + +#define PART_ROUND_ODD_ABD(sl, sr) \ + "add " CC_A0 ", " CC_A0 ", " CC_B0 "\n\t" \ + "add " CC_A1 ", " CC_A1 ", " CC_B1 "\n\t" \ + "add " CC_A2 ", " CC_A2 ", " CC_B2 "\n\t" \ + "add " CC_A3 ", " CC_A3 ", " CC_B3 "\n\t" \ + "xor " CC_D0 ", " CC_D0 ", " CC_A0 "\n\t" \ + "xor " CC_D1 ", " CC_D1 ", " CC_A1 "\n\t" \ + "xor " CC_D2 ", " CC_D2 ", " CC_A2 "\n\t" \ + "xor " CC_D3 ", " CC_D3 ", " CC_A3 "\n\t" \ + "slli " CC_T0 ", " CC_D0 ", " #sl "\n\t" \ + "slli " CC_T1 ", " CC_D1 ", " #sl "\n\t" \ + "slli " CC_T2 ", " CC_D2 ", " #sl "\n\t" \ + "slli " CC_T3 ", " CC_D3 ", " #sl "\n\t" \ + "srliw " CC_D0 ", " CC_D0 ", " #sr "\n\t" \ + "srliw " CC_D1 ", " CC_D1 ", " #sr "\n\t" \ + "srliw " CC_D2 ", " CC_D2 ", " #sr "\n\t" \ + "srliw " CC_D3 ", " CC_D3 ", " #sr "\n\t" \ + "or " CC_D0 ", " CC_D0 ", " CC_T0 "\n\t" \ + "or " CC_D1 ", " CC_D1 ", " CC_T1 "\n\t" \ + "or " CC_D2 ", " CC_D2 ", " CC_T2 "\n\t" \ + "or " CC_D3 ", " CC_D3 ", " CC_T3 "\n\t" + +#define PART_ROUND_ODD_CDB(sl, sr) \ + "add " CC_C0 ", " CC_C0 ", " CC_D0 "\n\t" \ + "add " CC_C1 ", " CC_C1 ", " CC_D1 "\n\t" \ + "add " CC_C2 ", " CC_C2 ", " CC_D2 "\n\t" \ + "add " CC_C3 ", " CC_C3 ", " CC_D3 "\n\t" \ + "xor " CC_B0 ", " CC_B0 ", " CC_C0 "\n\t" \ + "xor " CC_B1 ", " CC_B1 ", " CC_C1 "\n\t" \ + "xor " CC_B2 ", " CC_B2 ", " CC_C2 "\n\t" \ + "xor " CC_B3 ", " CC_B3 ", " CC_C3 "\n\t" \ + "slli " CC_T0 ", " CC_B0 ", " #sl "\n\t" \ + "slli " CC_T1 ", " CC_B1 ", " #sl "\n\t" \ + "slli " CC_T2 ", " CC_B2 ", " #sl "\n\t" \ + "slli " CC_T3 ", " CC_B3 ", " #sl "\n\t" \ + "srliw " CC_B0 ", " CC_B0 ", " #sr "\n\t" \ + "srliw " CC_B1 ", " CC_B1 ", " #sr "\n\t" \ + "srliw " CC_B2 ", " CC_B2 ", " #sr "\n\t" \ + "srliw " CC_B3 ", " CC_B3 ", " #sr "\n\t" \ + "or " CC_B0 ", " CC_B0 ", " CC_T0 "\n\t" \ + "or " CC_B1 ", " CC_B1 ", " CC_T1 "\n\t" \ + "or " CC_B2 ", " CC_B2 ", " CC_T2 "\n\t" \ + "or " CC_B3 ", " CC_B3 ", " CC_T3 "\n\t" + +#define PART_ROUND_EVEN_ABD(sl, sr) \ + "add " CC_A0 ", " CC_A0 ", " CC_B1 "\n\t" \ + "add " CC_A1 ", " CC_A1 ", " CC_B2 "\n\t" \ + "add " CC_A2 ", " CC_A2 ", " CC_B3 "\n\t" \ + "add " CC_A3 ", " CC_A3 ", " CC_B0 "\n\t" \ + "xor " CC_D3 ", " CC_D3 ", " CC_A0 "\n\t" \ + "xor " CC_D0 ", " CC_D0 ", " CC_A1 "\n\t" \ + "xor " CC_D1 ", " CC_D1 ", " CC_A2 "\n\t" \ + "xor " CC_D2 ", " CC_D2 ", " CC_A3 "\n\t" \ + "slli " CC_T0 ", " CC_D3 ", " #sl "\n\t" \ + "slli " CC_T1 ", " CC_D0 ", " #sl "\n\t" \ + "slli " CC_T2 ", " CC_D1 ", " #sl "\n\t" \ + "slli " CC_T3 ", " CC_D2 ", " #sl "\n\t" \ + "srliw " CC_D3 ", " CC_D3 ", " #sr "\n\t" \ + "srliw " CC_D0 ", " CC_D0 ", " #sr "\n\t" \ + "srliw " CC_D1 ", " CC_D1 ", " #sr "\n\t" \ + "srliw " CC_D2 ", " CC_D2 ", " #sr "\n\t" \ + "or " CC_D3 ", " CC_D3 ", " CC_T0 "\n\t" \ + "or " CC_D0 ", " CC_D0 ", " CC_T1 "\n\t" \ + "or " CC_D1 ", " CC_D1 ", " CC_T2 "\n\t" \ + "or " CC_D2 ", " CC_D2 ", " CC_T3 "\n\t" + +#define PART_ROUND_EVEN_CDB(sl, sr) \ + "add " CC_C2 ", " CC_C2 ", " CC_D3 "\n\t" \ + "add " CC_C3 ", " CC_C3 ", " CC_D0 "\n\t" \ + "add " CC_C0 ", " CC_C0 ", " CC_D1 "\n\t" \ + "add " CC_C1 ", " CC_C1 ", " CC_D2 "\n\t" \ + "xor " CC_B1 ", " CC_B1 ", " CC_C2 "\n\t" \ + "xor " CC_B2 ", " CC_B2 ", " CC_C3 "\n\t" \ + "xor " CC_B3 ", " CC_B3 ", " CC_C0 "\n\t" \ + "xor " CC_B0 ", " CC_B0 ", " CC_C1 "\n\t" \ + "slli " CC_T0 ", " CC_B1 ", " #sl "\n\t" \ + "slli " CC_T1 ", " CC_B2 ", " #sl "\n\t" \ + "slli " CC_T2 ", " CC_B3 ", " #sl "\n\t" \ + "slli " CC_T3 ", " CC_B0 ", " #sl "\n\t" \ + "srliw " CC_B1 ", " CC_B1 ", " #sr "\n\t" \ + "srliw " CC_B2 ", " CC_B2 ", " #sr "\n\t" \ + "srliw " CC_B3 ", " CC_B3 ", " #sr "\n\t" \ + "srliw " CC_B0 ", " CC_B0 ", " #sr "\n\t" \ + "or " CC_B1 ", " CC_B1 ", " CC_T0 "\n\t" \ + "or " CC_B2 ", " CC_B2 ", " CC_T1 "\n\t" \ + "or " CC_B3 ", " CC_B3 ", " CC_T2 "\n\t" \ + "or " CC_B0 ", " CC_B0 ", " CC_T3 "\n\t" + +#else + +#define PART_ROUND_ODD_ABD(sl, sr) \ + "add " CC_A0 ", " CC_A0 ", " CC_B0 "\n\t" \ + "add " CC_A1 ", " CC_A1 ", " CC_B1 "\n\t" \ + "add " CC_A2 ", " CC_A2 ", " CC_B2 "\n\t" \ + "add " CC_A3 ", " CC_A3 ", " CC_B3 "\n\t" \ + "xor " CC_D0 ", " CC_D0 ", " CC_A0 "\n\t" \ + "xor " CC_D1 ", " CC_D1 ", " CC_A1 "\n\t" \ + "xor " CC_D2 ", " CC_D2 ", " CC_A2 "\n\t" \ + "xor " CC_D3 ", " CC_D3 ", " CC_A3 "\n\t" \ + RORIW(REG_S6, REG_S6, sr) \ + RORIW(REG_S7, REG_S7, sr) \ + RORIW(REG_S8, REG_S8, sr) \ + RORIW(REG_S9, REG_S9, sr) + +#define PART_ROUND_ODD_CDB(sl, sr) \ + "add " CC_C0 ", " CC_C0 ", " CC_D0 "\n\t" \ + "add " CC_C1 ", " CC_C1 ", " CC_D1 "\n\t" \ + "add " CC_C2 ", " CC_C2 ", " CC_D2 "\n\t" \ + "add " CC_C3 ", " CC_C3 ", " CC_D3 "\n\t" \ + "xor " CC_B0 ", " CC_B0 ", " CC_C0 "\n\t" \ + "xor " CC_B1 ", " CC_B1 ", " CC_C1 "\n\t" \ + "xor " CC_B2 ", " CC_B2 ", " CC_C2 "\n\t" \ + "xor " CC_B3 ", " CC_B3 ", " CC_C3 "\n\t" \ + RORIW(REG_T3, REG_T3, sr) \ + RORIW(REG_T4, REG_T4, sr) \ + RORIW(REG_T5, REG_T5, sr) \ + RORIW(REG_T6, REG_T6, sr) + +#define PART_ROUND_EVEN_ABD(sl, sr) \ + "add " CC_A0 ", " CC_A0 ", " CC_B1 "\n\t" \ + "add " CC_A1 ", " CC_A1 ", " CC_B2 "\n\t" \ + "add " CC_A2 ", " CC_A2 ", " CC_B3 "\n\t" \ + "add " CC_A3 ", " CC_A3 ", " CC_B0 "\n\t" \ + "xor " CC_D3 ", " CC_D3 ", " CC_A0 "\n\t" \ + "xor " CC_D0 ", " CC_D0 ", " CC_A1 "\n\t" \ + "xor " CC_D1 ", " CC_D1 ", " CC_A2 "\n\t" \ + "xor " CC_D2 ", " CC_D2 ", " CC_A3 "\n\t" \ + RORIW(REG_S9, REG_S9, sr) \ + RORIW(REG_S6, REG_S6, sr) \ + RORIW(REG_S7, REG_S7, sr) \ + RORIW(REG_S8, REG_S8, sr) + +#define PART_ROUND_EVEN_CDB(sl, sr) \ + "add " CC_C2 ", " CC_C2 ", " CC_D3 "\n\t" \ + "add " CC_C3 ", " CC_C3 ", " CC_D0 "\n\t" \ + "add " CC_C0 ", " CC_C0 ", " CC_D1 "\n\t" \ + "add " CC_C1 ", " CC_C1 ", " CC_D2 "\n\t" \ + "xor " CC_B1 ", " CC_B1 ", " CC_C2 "\n\t" \ + "xor " CC_B2 ", " CC_B2 ", " CC_C3 "\n\t" \ + "xor " CC_B3 ", " CC_B3 ", " CC_C0 "\n\t" \ + "xor " CC_B0 ", " CC_B0 ", " CC_C1 "\n\t" \ + RORIW(REG_T4, REG_T4, sr) \ + RORIW(REG_T5, REG_T5, sr) \ + RORIW(REG_T6, REG_T6, sr) \ + RORIW(REG_T3, REG_T3, sr) + +#endif + +#define QUARTER_ROUND_ODD() \ + /* a += b; d ^= a; d <<<= 16; */ \ + PART_ROUND_ODD_ABD(16, 16) \ + /* c += d; b ^= c; b <<<= 12; */ \ + PART_ROUND_ODD_CDB(12, 20) \ + /* a += b; d ^= a; d <<<= 8; */ \ + PART_ROUND_ODD_ABD( 8, 24) \ + /* c += d; b ^= c; b <<<= 7; */ \ + PART_ROUND_ODD_CDB( 7, 25) + +#define QUARTER_ROUND_EVEN() \ + /* a += b; d ^= a; d <<<= 16; */ \ + PART_ROUND_EVEN_ABD(16, 16) \ + /* c += d; b ^= c; b <<<= 12; */ \ + PART_ROUND_EVEN_CDB(12, 20) \ + /* a += b; d ^= a; d <<<= 8; */ \ + PART_ROUND_EVEN_ABD( 8, 24) \ + /* c += d; b ^= c; b <<<= 7; */ \ + PART_ROUND_EVEN_CDB( 7, 25) + + +static WC_INLINE void wc_chacha_encrypt(const word32* input, const byte* m, + byte* c, word32 bytes, word32* over) +{ + __asm__ __volatile__ ( + /* Ensure 64-bit bytes has top bits clear. */ + "slli %[bytes], %[bytes], 32\n\t" + "srli %[bytes], %[bytes], 32\n\t" + + "L_chacha20_riscv_outer:\n\t" + /* Move state into regular registers */ + "ld a4, 0(%[input])\n\t" + "ld a6, 8(%[input])\n\t" + "ld t3, 16(%[input])\n\t" + "ld t5, 24(%[input])\n\t" + "ld s2, 32(%[input])\n\t" + "ld s4, 40(%[input])\n\t" + "ld s6, 48(%[input])\n\t" + "ld s8, 56(%[input])\n\t" + "srli a5, a4, 32\n\t" + "srli a7, a6, 32\n\t" + "srli t4, t3, 32\n\t" + "srli t6, t5, 32\n\t" + "srli s3, s2, 32\n\t" + "srli s5, s4, 32\n\t" + "srli s7, s6, 32\n\t" + "srli s9, s8, 32\n\t" + + /* Set number of odd+even rounds to perform */ + "li a3, 10\n\t" + "\n" + "L_chacha20_riscv_loop:\n\t" + /* Odd Round */ + QUARTER_ROUND_ODD() + "addi a3, a3, -1\n\t" + /* Even Round */ + QUARTER_ROUND_EVEN() + "bnez a3, L_chacha20_riscv_loop\n\t" + + "addi %[bytes], %[bytes], -64\n\t" + + "ld t0, 0(%[input])\n\t" + "ld t1, 8(%[input])\n\t" + "ld t2, 16(%[input])\n\t" + "ld s1, 24(%[input])\n\t" + "add a4, a4, t0\n\t" + "add a6, a6, t1\n\t" + "add t3, t3, t2\n\t" + "add t5, t5, s1\n\t" + "srli t0, t0, 32\n\t" + "srli t1, t1, 32\n\t" + "srli t2, t2, 32\n\t" + "srli s1, s1, 32\n\t" + "add a5, a5, t0\n\t" + "add a7, a7, t1\n\t" + "add t4, t4, t2\n\t" + "add t6, t6, s1\n\t" + "ld t0, 32(%[input])\n\t" + "ld t1, 40(%[input])\n\t" + "ld t2, 48(%[input])\n\t" + "ld s1, 56(%[input])\n\t" + "add s2, s2, t0\n\t" + "add s4, s4, t1\n\t" + "add s6, s6, t2\n\t" + "addi t2, t2, 1\n\t" + "add s8, s8, s1\n\t" + "srli t0, t0, 32\n\t" + "srli t1, t1, 32\n\t" + "sw t2, 48(%[input])\n\t" + "srli t2, t2, 32\n\t" + "srli s1, s1, 32\n\t" + "add s3, s3, t0\n\t" + "add s5, s5, t1\n\t" + "add s7, s7, t2\n\t" + "add s9, s9, s1\n\t" + + "bltz %[bytes], L_chacha20_riscv_over\n\t" + +#if !defined(WOLFSSL_RISCV_BIT_MANIPULATION) + "ld t0, 0(%[m])\n\t" + "ld t1, 8(%[m])\n\t" + "ld t2, 16(%[m])\n\t" + "ld s1, 24(%[m])\n\t" + "xor a4, a4, t0\n\t" + "xor a6, a6, t1\n\t" + "xor t3, t3, t2\n\t" + "xor t5, t5, s1\n\t" + "srli t0, t0, 32\n\t" + "srli t1, t1, 32\n\t" + "srli t2, t2, 32\n\t" + "srli s1, s1, 32\n\t" + "xor a5, a5, t0\n\t" + "xor a7, a7, t1\n\t" + "xor t4, t4, t2\n\t" + "xor t6, t6, s1\n\t" + "ld t0, 32(%[m])\n\t" + "ld t1, 40(%[m])\n\t" + "ld t2, 48(%[m])\n\t" + "ld s1, 56(%[m])\n\t" + "xor s2, s2, t0\n\t" + "xor s4, s4, t1\n\t" + "xor s6, s6, t2\n\t" + "xor s8, s8, s1\n\t" + "srli t0, t0, 32\n\t" + "srli t1, t1, 32\n\t" + "srli t2, t2, 32\n\t" + "srli s1, s1, 32\n\t" + "xor s3, s3, t0\n\t" + "xor s5, s5, t1\n\t" + "xor s7, s7, t2\n\t" + "xor s9, s9, s1\n\t" + "sw a4, 0(%[c])\n\t" + "sw a5, 4(%[c])\n\t" + "sw a6, 8(%[c])\n\t" + "sw a7, 12(%[c])\n\t" + "sw t3, 16(%[c])\n\t" + "sw t4, 20(%[c])\n\t" + "sw t5, 24(%[c])\n\t" + "sw t6, 28(%[c])\n\t" + "sw s2, 32(%[c])\n\t" + "sw s3, 36(%[c])\n\t" + "sw s4, 40(%[c])\n\t" + "sw s5, 44(%[c])\n\t" + "sw s6, 48(%[c])\n\t" + "sw s7, 52(%[c])\n\t" + "sw s8, 56(%[c])\n\t" + "sw s9, 60(%[c])\n\t" +#else + PACK(REG_A4, REG_A4, REG_A5) + PACK(REG_A6, REG_A6, REG_A7) + PACK(REG_T3, REG_T3, REG_T4) + PACK(REG_T5, REG_T5, REG_T6) + PACK(REG_S2, REG_S2, REG_S3) + PACK(REG_S4, REG_S4, REG_S5) + PACK(REG_S6, REG_S6, REG_S7) + PACK(REG_S8, REG_S8, REG_S9) + "ld a5, 0(%[m])\n\t" + "ld a7, 8(%[m])\n\t" + "ld t4, 16(%[m])\n\t" + "ld t6, 24(%[m])\n\t" + "ld s3, 32(%[m])\n\t" + "ld s5, 40(%[m])\n\t" + "ld s7, 48(%[m])\n\t" + "ld s9, 56(%[m])\n\t" + "xor a4, a4, a5\n\t" + "xor a6, a6, a7\n\t" + "xor t3, t3, t4\n\t" + "xor t5, t5, t6\n\t" + "xor s2, s2, s3\n\t" + "xor s4, s4, s5\n\t" + "xor s6, s6, s7\n\t" + "xor s8, s8, s9\n\t" + "sd a4, 0(%[c])\n\t" + "sd a6, 8(%[c])\n\t" + "sd t3, 16(%[c])\n\t" + "sd t5, 24(%[c])\n\t" + "sd s2, 32(%[c])\n\t" + "sd s4, 40(%[c])\n\t" + "sd s6, 48(%[c])\n\t" + "sd s8, 56(%[c])\n\t" +#endif + + "addi %[m], %[m], 64\n\t" + "addi %[c], %[c], 64\n\t" + + "bnez %[bytes], L_chacha20_riscv_outer\n\t" + "beqz %[bytes], L_chacha20_riscv_done\n\t" + + "L_chacha20_riscv_over:\n\t" + "addi a3, %[bytes], 64\n\t" + + "sw a4, 0(%[over])\n\t" + "sw a5, 4(%[over])\n\t" + "sw a6, 8(%[over])\n\t" + "sw a7, 12(%[over])\n\t" + "sw t3, 16(%[over])\n\t" + "sw t4, 20(%[over])\n\t" + "sw t5, 24(%[over])\n\t" + "sw t6, 28(%[over])\n\t" + "sw s2, 32(%[over])\n\t" + "sw s3, 36(%[over])\n\t" + "sw s4, 40(%[over])\n\t" + "sw s5, 44(%[over])\n\t" + "sw s6, 48(%[over])\n\t" + "sw s7, 52(%[over])\n\t" + "sw s8, 56(%[over])\n\t" + "sw s9, 60(%[over])\n\t" + + "addi t0, a3, -8\n\t" + "bltz t0, L_chacha20_riscv_32bit\n\t" + "addi a3, a3, -1\n\t" + "L_chacha20_riscv_64bit_loop:\n\t" + "ld t0, (%[m])\n\t" + "ld t1, (%[over])\n\t" + "xor t0, t0, t1\n\t" + "sd t0, (%[c])\n\t" + "addi %[m], %[m], 8\n\t" + "addi %[c], %[c], 8\n\t" + "addi %[over], %[over], 8\n\t" + "addi a3, a3, -8\n\t" + "bgez a3, L_chacha20_riscv_64bit_loop\n\t" + "addi a3, a3, 1\n\t" + + "L_chacha20_riscv_32bit:\n\t" + "addi t0, a3, -4\n\t" + "bltz t0, L_chacha20_riscv_16bit\n\t" + "lw t0, (%[m])\n\t" + "lw t1, (%[over])\n\t" + "xor t0, t0, t1\n\t" + "sw t0, (%[c])\n\t" + "addi %[m], %[m], 4\n\t" + "addi %[c], %[c], 4\n\t" + "addi %[over], %[over], 4\n\t" + + "L_chacha20_riscv_16bit:\n\t" + "addi t0, a3, -2\n\t" + "bltz t0, L_chacha20_riscv_8bit\n\t" + "lh t0, (%[m])\n\t" + "lh t1, (%[over])\n\t" + "xor t0, t0, t1\n\t" + "sh t0, (%[c])\n\t" + "addi %[m], %[m], 2\n\t" + "addi %[c], %[c], 2\n\t" + "addi %[over], %[over], 2\n\t" + + "L_chacha20_riscv_8bit:\n\t" + "addi t0, a3, -1\n\t" + "bltz t0, L_chacha20_riscv_done\n\t\n\t" + "lb t0, (%[m])\n\t" + "lb t1, (%[over])\n\t" + "xor t0, t0, t1\n\t" + "sb t0, (%[c])\n\t" + "bltz %[bytes], L_chacha20_riscv_done\n\t" + + "L_chacha20_riscv_done:\n\t" + : [m] "+r" (m), [c] "+r" (c), [bytes] "+r" (bytes), [over] "+r" (over) + : [input] "r" (input) + : "memory", "t0", "t1", "t2", "s1", "a3", + "t3", "t4", "t5", "t6", + "a4", "a5", "a6", "a7", + "s2", "s3", "s4", "s5", + "s6", "s7", "s8", "s9" + ); +} + +/** + * Encrypt a stream of bytes + */ +static WC_INLINE void wc_chacha_encrypt_bytes(ChaCha* ctx, const byte* m, + byte* c, word32 bytes) +{ + wc_chacha_encrypt(ctx->X, m, c, bytes, ctx->over); + ctx->left = (CHACHA_CHUNK_BYTES - (bytes & (CHACHA_CHUNK_BYTES - 1))) & + (CHACHA_CHUNK_BYTES - 1); +} +#endif + +/** + * API to encrypt/decrypt a message of any size. + */ +int wc_Chacha_Process(ChaCha* ctx, byte* output, const byte* input, + word32 msglen) +{ + int ret = 0; + + if ((ctx == NULL) || (output == NULL) || (input == NULL)) { + ret = BAD_FUNC_ARG; + } + else if (msglen > 0) { + if (ctx->left > 0) { + word32 processed = min(msglen, ctx->left); + byte* out = (byte*)ctx->over + CHACHA_CHUNK_BYTES - ctx->left; + + xorbufout(output, input, out, processed); + + ctx->left -= processed; + msglen -= processed; + output += processed; + input += processed; + } + + if (msglen > 0) { + wc_chacha_encrypt_bytes(ctx, input, output, msglen); + } + } + + return ret; +} + +#endif /* HAVE_CHACHA */ +#endif /* WOLFSSL_ARMASM && !WOLFSSL_ARMASM_NO_NEON */ diff --git a/wolfcrypt/src/port/riscv/riscv-64-sha256.c b/wolfcrypt/src/port/riscv/riscv-64-sha256.c new file mode 100644 index 0000000000..3c546b00d7 --- /dev/null +++ b/wolfcrypt/src/port/riscv/riscv-64-sha256.c @@ -0,0 +1,1431 @@ +/* riscv-sha256.c + * + * Copyright (C) 2006-2024 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ + + +#ifdef HAVE_CONFIG_H + #include +#endif + +#include + +#ifdef WOLFSSL_RISCV_ASM +#if !defined(NO_SHA256) || defined(WOLFSSL_SHA224) + +#if FIPS_VERSION3_LT(6,0,0) && defined(HAVE_FIPS) + #undef HAVE_FIPS +#else + #if defined(HAVE_FIPS) && FIPS_VERSION3_GE(6,0,0) + /* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */ + #define FIPS_NO_WRAPPERS + #endif +#endif + +#include +#if FIPS_VERSION3_GE(6,0,0) + const unsigned int wolfCrypt_FIPS_sha256_ro_sanity[2] = + { 0x1a2b3c4d, 0x00000014 }; + int wolfCrypt_FIPS_SHA256_sanity(void) + { + return 0; + } +#endif +#include +#include + +#include + +#ifdef NO_INLINE + #include +#else + #define WOLFSSL_MISC_INCLUDED + #include +#endif + +/* Constants to add in each round. */ +static const FLASH_QUALIFIER ALIGN32 word32 K[64] = { + 0x428A2F98L, 0x71374491L, 0xB5C0FBCFL, 0xE9B5DBA5L, 0x3956C25BL, + 0x59F111F1L, 0x923F82A4L, 0xAB1C5ED5L, 0xD807AA98L, 0x12835B01L, + 0x243185BEL, 0x550C7DC3L, 0x72BE5D74L, 0x80DEB1FEL, 0x9BDC06A7L, + 0xC19BF174L, 0xE49B69C1L, 0xEFBE4786L, 0x0FC19DC6L, 0x240CA1CCL, + 0x2DE92C6FL, 0x4A7484AAL, 0x5CB0A9DCL, 0x76F988DAL, 0x983E5152L, + 0xA831C66DL, 0xB00327C8L, 0xBF597FC7L, 0xC6E00BF3L, 0xD5A79147L, + 0x06CA6351L, 0x14292967L, 0x27B70A85L, 0x2E1B2138L, 0x4D2C6DFCL, + 0x53380D13L, 0x650A7354L, 0x766A0ABBL, 0x81C2C92EL, 0x92722C85L, + 0xA2BFE8A1L, 0xA81A664BL, 0xC24B8B70L, 0xC76C51A3L, 0xD192E819L, + 0xD6990624L, 0xF40E3585L, 0x106AA070L, 0x19A4C116L, 0x1E376C08L, + 0x2748774CL, 0x34B0BCB5L, 0x391C0CB3L, 0x4ED8AA4AL, 0x5B9CCA4FL, + 0x682E6FF3L, 0x748F82EEL, 0x78A5636FL, 0x84C87814L, 0x8CC70208L, + 0x90BEFFFAL, 0xA4506CEBL, 0xBEF9A3F7L, 0xC67178F2L +}; + +/* Initialze SHA-256 object for hashing. + * + * @param [in, out] sha256 SHA-256 object. + */ +static void InitSha256(wc_Sha256* sha256) +{ + /* Set initial hash values. */ +#ifndef WOLFSSL_RISCV_VECTOR_CRYPTO_ASM + sha256->digest[0] = 0x6A09E667L; + sha256->digest[1] = 0xBB67AE85L; + sha256->digest[2] = 0x3C6EF372L; + sha256->digest[3] = 0xA54FF53AL; + sha256->digest[4] = 0x510E527FL; + sha256->digest[5] = 0x9B05688CL; + sha256->digest[6] = 0x1F83D9ABL; + sha256->digest[7] = 0x5BE0CD19L; +#else + /* f, e, b, a, h, g, d, c */ + sha256->digest[0] = 0x9B05688CL; + sha256->digest[1] = 0x510E527FL; + sha256->digest[2] = 0xBB67AE85L; + sha256->digest[3] = 0x6A09E667L; + sha256->digest[4] = 0x5BE0CD19L; + sha256->digest[5] = 0x1F83D9ABL; + sha256->digest[6] = 0xA54FF53AL; + sha256->digest[7] = 0x3C6EF372L; +#endif + + /* No hashed data. */ + sha256->buffLen = 0; + /* No data hashed. */ + sha256->loLen = 0; + sha256->hiLen = 0; + +#ifdef WOLFSSL_HASH_FLAGS + sha256->flags = 0; +#endif +} + +/* More data hashed, add length to 64-bit cumulative total. + * + * @param [in, out] sha256 SHA-256 object. Assumed not NULL. + * @param [in] len Length to add. + */ +static WC_INLINE void AddLength(wc_Sha256* sha256, word32 len) +{ + word32 tmp = sha256->loLen; + if ((sha256->loLen += len) < tmp) + sha256->hiLen++; /* carry low to high */ +} + +#ifndef WOLFSSL_RISCV_BASE_BIT_MANIPULATION + +/* Load a word with bytes reversed. */ +#define LOAD_WORD_REV(r, o, p, t0, t1, t2) \ + "lbu " #t0 ", " #o "(" #p ")\n\t" \ + "lbu " #t1 ", " #o "+1(" #p ")\n\t" \ + "lbu " #t2 ", " #o "+2(" #p ")\n\t" \ + "lbu " #r ", " #o "+3(" #p ")\n\t" \ + "slli " #t0 ", " #t0 ", 24\n\t" \ + "slli " #t1 ", " #t1 ", 16\n\t" \ + "slli " #t2 ", " #t2 ", 8\n\t" \ + "or " #r ", " #r ", " #t0 "\n\t" \ + "or " #r ", " #r ", " #t1 "\n\t" \ + "or " #r ", " #r ", " #t2 "\n\t" + +/* Load a word with bytes reversed. */ +#define LOAD_DWORD_REV(r, o, p, t0, t1, t2, t3) \ + "lbu " #t0 ", " #o "(" #p ")\n\t" \ + "lbu " #t1 ", " #o "+1(" #p ")\n\t" \ + "lbu " #t2 ", " #o "+2(" #p ")\n\t" \ + "lbu " #r ", " #o "+3(" #p ")\n\t" \ + "slli " #t0 ", " #t0 ", 24\n\t" \ + "slli " #t1 ", " #t1 ", 16\n\t" \ + "slli " #t2 ", " #t2 ", 8\n\t" \ + "or " #r ", " #r ", " #t0 "\n\t" \ + "or " #r ", " #r ", " #t1 "\n\t" \ + "or " #r ", " #r ", " #t2 "\n\t" \ + "lbu " #t0 ", " #o "+4(" #p ")\n\t" \ + "lbu " #t1 ", " #o "+5(" #p ")\n\t" \ + "lbu " #t2 ", " #o "+6(" #p ")\n\t" \ + "lbu " #t3 ", " #o "+7(" #p ")\n\t" \ + "slli " #t0 ", " #t0 ", 56\n\t" \ + "slli " #t1 ", " #t1 ", 48\n\t" \ + "slli " #t2 ", " #t2 ", 40\n\t" \ + "slli " #t3 ", " #t3 ", 32\n\t" \ + "or " #r ", " #r ", " #t0 "\n\t" \ + "or " #r ", " #r ", " #t1 "\n\t" \ + "or " #r ", " #r ", " #t2 "\n\t" \ + "or " #r ", " #r ", " #t3 "\n\t" + +#define PACK_BB(rd, rs1, rs2, rrd, rrs1, rrs2) \ + "slli " #rd ", " #rs1 ", 32\n\t" \ + "slli " #rs2 ", " #rs2 ", 32\n\t" \ + "srli " #rd ", " #rs1 ", 32\n\t" \ + "or " #rd ", " #rd ", " #rs2 "\n\t" + +#else + +#define PACK_BB(rd, rs1, rs2, rrd, rrs1, rrs2) \ + PACK(rrd, rrs1, rrs2) + +#endif + +#ifndef WOLFSSL_RISCV_VECTOR_CRYPTO_ASM + +#ifdef WOLFSSL_RISCV_SCALAR_CRYPTO_ASM + +/* SHA-256 SUM0 operation. */ +#define SHA256SUM0(rd, rs1) \ + ASM_WORD((0b000100000000 << 20) | (0b001 << 12) | 0b0010011 | \ + (rs1 << 15) | (rd << 7)) +/* SHA-256 SUM1 operation. */ +#define SHA256SUM1(rd, rs1) \ + ASM_WORD((0b000100000001 << 20) | (0b001 << 12) | 0b0010011 | \ + (rs1 << 15) | (rd << 7)) +/* SHA-256 SIGMA0 operation. */ +#define SHA256SIG0(rd, rs1) \ + ASM_WORD((0b000100000010 << 20) | (0b001 << 12) | 0b0010011 | \ + (rs1 << 15) | (rd << 7)) +/* SHA-256 SIGMA1 operation. */ +#define SHA256SIG1(rd, rs1) \ + ASM_WORD((0b000100000011 << 20) | (0b001 << 12) | 0b0010011 | \ + (rs1 << 15) | (rd << 7)) + +/* One round of compression. */ +#define RND(a, b, c, d, e, f, g, h, w, k) \ + /* Get e and a */ \ + "mv a4, " #e "\n\t" \ + "mv a5, " #a "\n\t" \ + /* Sigma1(e) */ \ + SHA256SUM1(REG_A4, REG_A4) \ + /* Sigma0(a) */ \ + SHA256SUM0(REG_A5, REG_A5) \ + /* Maj(a, b, c) = t5 */ \ + /* Ch(e, f, g) = t6 */ \ + /* f ^ g */ \ + "xor t6, " #f ", " #g "\n\t" \ + /* a ^ b */ \ + "xor t4, " #a ", " #b "\n\t" \ + /* b ^ c */ \ + "xor t5, " #b ", " #c "\n\t" \ + /* (f ^ g) & e */ \ + "and t6, t6, " #e "\n\t" \ + /* h + sigma1 */ \ + "addw " #h ", " #h ", a4\n\t" \ + /* (a^b) & (b^c) */ \ + "and t5, t5, t4\n\t" \ + /* ((f ^ g) & e) ^ g */ \ + "xor t6, t6, " #g "\n\t" \ + /* K + W */ \ + "addw t4, " #k ", " #w "\n\t" \ + /* ((a^b) & (b^c)) ^ b */ \ + "xor t5, t5, " #b "\n\t" \ + /* h + sigma1 + Ch */ \ + "addw " #h ", " #h ", t6\n\t" \ + /* 't0' = h + sigma1 + Ch + K + W */ \ + "addw " #h ", " #h ", t4\n\t" \ + /* Sigma0(a) + Maj = 't1' */ \ + "addw t5, a5, t5\n\t" \ + /* d += 't0' */ \ + "addw " #d ", " #d ", " #h "\n\t" \ + /* 't0' += 't1' */ \ + "addw " #h ", " #h ", t5\n\t" + +/* Two message schedule updates. */ +#define W_UPDATE_2(w0, w1, w4, w5, w7, reg_w0, reg_w1, reg_w7) \ + /* W[i-15] = W[1] */ \ + "srli t4, " #w0 ", 32\n\t" \ + /* W[i-7] = W[9] */ \ + "srli t6, " #w4 ", 32\n\t" \ + /* Gamma0(W[1]) */ \ + SHA256SIG0(REG_A4, REG_T4) \ + /* Gamma1(W[i-2]) = Gamma1(W[14]) */ \ + SHA256SIG1(REG_A5, reg_w7) \ + /* Gamma1(W[14]) + W[9] */ \ + "addw a5, a5, t6\n\t" \ + /* Gamma0(W[1]) + W[i-16] = Gamma0(W[1]) + W[0] */ \ + "addw " #w0 ", " #w0 ", a4\n\t" \ + /* W[i+1-2] = W[15] */ \ + "srli t5, " #w7 ", 32\n\t" \ + /* W[0] = Gamma1(W[14]) + W[9] + Gamma0(W[1]) + W[0] */ \ + "addw " #w0 ", a5, " #w0 "\n\t" \ + \ + /* W[i+1-16] = W[1] = t4 */ \ + /* Gamma0(W[i+1-15]) = Gamma0(W[2]) */ \ + SHA256SIG0(REG_A6, reg_w1) \ + /* Gamma1(W[i+1-2]) = Gamma1(W[15]) */ \ + SHA256SIG1(REG_A7, REG_T5) \ + /* Gamma1(W[15]) + W[i+1-7] = Gamma1(W[15]) + W[10] */ \ + "addw a7, a7, " #w5 "\n\t" \ + /* Gamma0(W[2]) + W[i+1-16] = Gamma0(W[2]) + W[1] */ \ + "addw t5, a6, t4\n\t" \ + /* Gamma1(W[i-2]) + W[i-7] + Gamma0(W[i-15]) + W[i-16] */ \ + "addw a7, a7, t5\n\t" \ + /* Place in W[i+1-16] = W[1] */ \ + PACK_BB(w0, w0, a7, reg_w0, reg_w0, REG_A7) + +#else + +/* SHA-256 SIGMA1 operation. */ +#define SHA256SIG1(rd, rs1) \ + "slliw t6, " #rs1 ", 15\n\t" \ + "srliw t5, " #rs1 ", 17\n\t" \ + "slliw t4, " #rs1 ", 13\n\t" \ + "srliw " #rd ", " #rs1 ", 19\n\t" \ + "or t6, t6, t5\n\t" \ + "srliw t5, " #rs1 ", 10\n\t" \ + "xor " #rd ", "#rd ", t4\n\t" \ + "xor t6, t6, t5\n\t" \ + "xor " #rd ", " #rd ", t6\n\t" \ + +/* One round of compression. */ +#define RND(a, b, c, d, e, f, g, h, w, k) \ + /* a4 = Sigma1(e) */ \ + "slliw t5, " #e ", 26\n\t" \ + "srliw t4, " #e ", 6\n\t" \ + "slliw t6, " #e ", 21\n\t" \ + "srliw a4, " #e ", 11\n\t" \ + "slliw a5, " #e ", 7\n\t" \ + "or t4, t4, t5\n\t" \ + "xor a4, a4, t6\n\t" \ + "srliw t5, " #e ", 25\n\t" \ + "xor t4, t4, a5\n\t" \ + "xor a4, a4, t5\n\t" \ + /* a5 = Sigma0(a) */ \ + "slliw t5, " #a ", 30\n\t" \ + "xor a4, a4, t4\n\t" \ + "srliw t4, " #a ", 2\n\t" \ + "slliw t6, " #a ", 19\n\t" \ + /* h + sigma1 */ \ + "addw " #h ", " #h ", a4\n\t" \ + "srliw a5, " #a ", 13\n\t" \ + "slliw a4, " #a ", 10\n\t" \ + "or t4, t4, t5\n\t" \ + "xor a5, a5, t6\n\t" \ + "srliw t6, " #a ", 22\n\t" \ + "xor t4, t4, a4\n\t" \ + "xor a5, a5, t6\n\t" \ + /* Maj(a, b, c) = t5 */ \ + /* Ch(e, f, g) = t6 */ \ + /* f ^ g */ \ + "xor t6, " #f ", " #g "\n\t" \ + /* a ^ b */ \ + "xor t5, " #a ", " #b "\n\t" \ + /* b ^ c */ \ + "xor a4, " #b ", " #c "\n\t" \ + "xor a5, a5, t4\n\t" \ + /* (f ^ g) & e */ \ + "and t6, t6, " #e "\n\t" \ + /* (a^b) & (b^c) */ \ + "and t5, t5, a4\n\t" \ + /* ((f ^ g) & e) ^ g */ \ + "xor t6, t6, " #g "\n\t" \ + /* K + W */ \ + "addw a4, " #k ", " #w "\n\t" \ + /* h + sigma1 + Ch */ \ + "addw " #h ", " #h ", t6\n\t" \ + /* ((a^b) & (b^c)) ^ b */ \ + "xor t5, t5, " #b "\n\t" \ + /* 't0' = h + sigma1 + Ch + K + W */ \ + "addw " #h ", " #h ", a4\n\t" \ + /* 't1' = Sigma0(a) + Maj */ \ + "addw t5, a5, t5\n\t" \ + /* d += 't0' */ \ + "addw " #d ", " #d ", " #h "\n\t" \ + /* h = 't0' + 't1' */ \ + "addw " #h ", " #h ", t5\n\t" + +/* Two message schedule updates. */ +#define W_UPDATE_2(w0, w1, w4, w5, w7, reg_w0, reg_w1, reg_w7) \ + /* W[i-15] = W[1] */ \ + "srli a7, " #w0 ", 32\n\t" \ + /* W[i-7] = W[9] */ \ + "srli a6, " #w4 ", 32\n\t" \ + /* Gamma0(W[1]) */ \ + "slliw t4, a7, 25\n\t" \ + "srliw t5, a7, 7\n\t" \ + "slliw t6, a7, 14\n\t" \ + "srliw a4, a7, 18\n\t" \ + "or t4, t4, t5\n\t" \ + "srliw t5, a7, 3\n\t" \ + "xor a4, a4, t6\n\t" \ + "xor t4, t4, t5\n\t" \ + /* Gamma1(W[i-2]) = Gamma1(W[14]) */ \ + "slliw t6, " #w7 ", 15\n\t" \ + "srliw t5, " #w7 ", 17\n\t" \ + "xor a4, a4, t4\n\t" \ + "slliw t4, " #w7 ", 13\n\t" \ + "srliw a5, " #w7 ", 19\n\t" \ + "or t6, t6, t5\n\t" \ + "srliw t5, " #w7 ", 10\n\t" \ + "xor a5, a5, t4\n\t" \ + "xor t6, t6, t5\n\t" \ + "xor a5, a5, t6\n\t" \ + /* Gamma0(W[1]) + W[i-16] = Gamma0(W[1]) + W[0] */ \ + "addw " #w0 ", " #w0 ", a4\n\t" \ + /* Gamma1(W[14]) + W[9] */ \ + "addw a5, a5, a6\n\t" \ + /* W[0] = Gamma1(W[14]) + W[9] + Gamma0(W[1]) + W[0] */ \ + "addw " #w0 ", a5, " #w0 "\n\t" \ + \ + /* W[i+1-16] = W[1] = a7 */ \ + /* W[i+1-2] = W[15] */ \ + "srli a4, " #w7 ", 32\n\t" \ + /* Gamma0(W[i+1-15]) = Gamma0(W[2]) */ \ + "slliw t4, " #w1 ", 25\n\t" \ + "srliw t5, " #w1 ", 7\n\t" \ + "slliw t6, " #w1 ", 14\n\t" \ + "srliw a6, " #w1 ", 18\n\t" \ + "or t4, t4, t5\n\t" \ + "srliw t5, " #w1 ", 3\n\t" \ + "xor a6, a6, t6\n\t" \ + "xor t4, t4, t5\n\t" \ + /* Gamma1(W[i+1-2]) = Gamma1(W[15]) */ \ + "slliw t6, a4, 15\n\t" \ + "srliw t5, a4, 17\n\t" \ + "xor a6, a6, t4\n\t" \ + "slliw t4, a4, 13\n\t" \ + "srliw a5, a4, 19\n\t" \ + "or t6, t6, t5\n\t" \ + "srliw t5, a4, 10\n\t" \ + "xor a5, a5, t4\n\t" \ + "xor t6, t6, t5\n\t" \ + "xor a5, a5, t6\n\t" \ + /* Gamma0(W[2]) + W[i+1-16] = Gamma0(W[2]) + W[1] */ \ + "addw t5, a6, a7\n\t" \ + /* Gamma1(W[15]) + W[i+1-7] = Gamma1(W[15]) + W[10] */ \ + "addw a5, a5, " #w5 "\n\t" \ + /* Gamma1(W[i-2]) + W[i-7] + Gamma0(W[i-15]) + W[i-16] */ \ + "addw a5, a5, t5\n\t" \ + /* Place in W[i+1-16] = W[1] */ \ + PACK_BB(w0, w0, a5, reg_w0, reg_w0, REG_A5) + +#endif /* WOLFSSL_RISCV_SCALAR_CRYPTO_ASM */ + +/* Two rounds of compression. */ +#define RND2(a, b, c, d, e, f, g, h, w, o) \ + /* Get k[i], k[i+1] */ \ + "ld a6, " #o "(%[k])\n\t" \ + RND(a, b, c, d, e, f, g, h, w, a6) \ + /* Move k[i+1] down */ \ + "srli a6, a6, 32\n\t" \ + /* Move W[i] down */ \ + "srli a7, " #w ", 32\n\t" \ + RND(h, a, b, c, d, e, f, g, a7, a6) + +/* Sixteen rounds of compression with message scheduling. */ +#define RND16() \ + RND2(t0, t1, t2, t3, s8, s9, s10, s11, s0, 0) \ + W_UPDATE_2(s0, s1, s4, s5, s7, REG_S0, REG_S1, REG_S7) \ + RND2(s10, s11, t0, t1, t2, t3, s8, s9, s1, 8) \ + W_UPDATE_2(s1, s2, s5, s6, s0, REG_S1, REG_S2, REG_S0) \ + RND2(s8, s9, s10, s11, t0, t1, t2, t3, s2, 16) \ + W_UPDATE_2(s2, s3, s6, s7, s1, REG_S2, REG_S3, REG_S1) \ + RND2(t2, t3, s8, s9, s10, s11, t0, t1, s3, 24) \ + W_UPDATE_2(s3, s4, s7, s0, s2, REG_S3, REG_S4, REG_S2) \ + RND2(t0, t1, t2, t3, s8, s9, s10, s11, s4, 32) \ + W_UPDATE_2(s4, s5, s0, s1, s3, REG_S4, REG_S5, REG_S3) \ + RND2(s10, s11, t0, t1, t2, t3, s8, s9, s5, 40) \ + W_UPDATE_2(s5, s6, s1, s2, s4, REG_S5, REG_S6, REG_S4) \ + RND2(s8, s9, s10, s11, t0, t1, t2, t3, s6, 48) \ + W_UPDATE_2(s6, s7, s2, s3, s5, REG_S6, REG_S7, REG_S5) \ + RND2(t2, t3, s8, s9, s10, s11, t0, t1, s7, 56) \ + W_UPDATE_2(s7, s0, s3, s4, s6, REG_S7, REG_S0, REG_S6) + +/* Sixteen rounds of compression only. */ +#define RND16_LAST() \ + RND2(t0, t1, t2, t3, s8, s9, s10, s11, s0, 0) \ + RND2(s10, s11, t0, t1, t2, t3, s8, s9, s1, 8) \ + RND2(s8, s9, s10, s11, t0, t1, t2, t3, s2, 16) \ + RND2(t2, t3, s8, s9, s10, s11, t0, t1, s3, 24) \ + RND2(t0, t1, t2, t3, s8, s9, s10, s11, s4, 32) \ + RND2(s10, s11, t0, t1, t2, t3, s8, s9, s5, 40) \ + RND2(s8, s9, s10, s11, t0, t1, t2, t3, s6, 48) \ + RND2(t2, t3, s8, s9, s10, s11, t0, t1, s7, 56) + +/* Transform the message data. + * + * @param [in, out] sha256 SHA-256 object. + * @param [in] data Buffer of data to hash. + * @param [in] blocks Number of blocks of data to hash. + */ +static WC_INLINE void Sha256Transform(wc_Sha256* sha256, const byte* data, + word32 blocks) +{ + word32* k = (word32*)K; + + __asm__ __volatile__ ( + /* Load digest. */ + "ld t0, 0(%[digest])\n\t" + "ld t2, 8(%[digest])\n\t" + "ld s8, 16(%[digest])\n\t" + "ld s10, 24(%[digest])\n\t" + "srli t1, t0, 32\n\t" + "srli t3, t2, 32\n\t" + "srli s9, s8, 32\n\t" + "srli s11, s10, 32\n\t" + + /* 4 rounds of 16 per block. */ + "slli %[blocks], %[blocks], 2\n\t" + + "\n1:\n\t" + /* beginning of SHA256 block operation */ + /* Load W */ +#ifndef WOLFSSL_RISCV_BASE_BIT_MANIPULATION + LOAD_DWORD_REV(s0, 0, %[data], a4, a5, a6, a7) + LOAD_DWORD_REV(s1, 8, %[data], a4, a5, a6, a7) + LOAD_DWORD_REV(s2, 16, %[data], a4, a5, a6, a7) + LOAD_DWORD_REV(s3, 24, %[data], a4, a5, a6, a7) + LOAD_DWORD_REV(s4, 32, %[data], a4, a5, a6, a7) + LOAD_DWORD_REV(s5, 40, %[data], a4, a5, a6, a7) + LOAD_DWORD_REV(s6, 48, %[data], a4, a5, a6, a7) + LOAD_DWORD_REV(s7, 56, %[data], a4, a5, a6, a7) +#else + "lwu a4, 0(%[data])\n\t" + "lwu s0, 4(%[data])\n\t" + "lwu a5, 8(%[data])\n\t" + "lwu s1, 12(%[data])\n\t" + "lwu a6, 16(%[data])\n\t" + "lwu s2, 20(%[data])\n\t" + "lwu a7, 24(%[data])\n\t" + "lwu s3, 28(%[data])\n\t" + PACK_BB(s0, s0, a4, REG_S0, REG_S0, REG_A4) + PACK_BB(s1, s1, a5, REG_S1, REG_S1, REG_A5) + PACK_BB(s2, s2, a6, REG_S2, REG_S2, REG_A6) + PACK_BB(s3, s3, a7, REG_S3, REG_S3, REG_A7) + REV8(REG_S0, REG_S0) + REV8(REG_S1, REG_S1) + REV8(REG_S2, REG_S2) + REV8(REG_S3, REG_S3) + "lwu a4, 32(%[data])\n\t" + "lwu s4, 36(%[data])\n\t" + "lwu a5, 40(%[data])\n\t" + "lwu s5, 44(%[data])\n\t" + "lwu a6, 48(%[data])\n\t" + "lwu s6, 52(%[data])\n\t" + "lwu a7, 56(%[data])\n\t" + "lwu s7, 60(%[data])\n\t" + PACK_BB(s4, s4, a4, REG_S4, REG_S4, REG_A4) + PACK_BB(s5, s5, a5, REG_S5, REG_S5, REG_A5) + PACK_BB(s6, s6, a6, REG_S6, REG_S6, REG_A6) + PACK_BB(s7, s7, a7, REG_S7, REG_S7, REG_A7) + REV8(REG_S4, REG_S4) + REV8(REG_S5, REG_S5) + REV8(REG_S6, REG_S6) + REV8(REG_S7, REG_S7) +#endif + + /* Subtract one as there are only 3 loops. */ + "addi %[blocks], %[blocks], -1\n\t" + "\n2:\n\t" + RND16() + "addi %[blocks], %[blocks], -1\n\t" + "add %[k], %[k], 64\n\t" + "andi a4, %[blocks], 3\n\t" + "bnez a4, 2b \n\t" + RND16_LAST() + "addi %[k], %[k], -192\n\t" + + "# Add working vars back into digest state.\n\t" + "ld a4, 0(%[digest])\n\t" + "ld a5, 8(%[digest])\n\t" + "ld a6, 16(%[digest])\n\t" + "ld a7, 24(%[digest])\n\t" + "addw t0, t0, a4\n\t" + "addw t2, t2, a5\n\t" + "addw s8, s8, a6\n\t" + "addw s10, s10, a7\n\t" + "srli a4, a4, 32\n\t" + "srli a5, a5, 32\n\t" + "srli a6, a6, 32\n\t" + "srli a7, a7, 32\n\t" + "addw t1, t1, a4\n\t" + "addw t3, t3, a5\n\t" + "addw s9, s9, a6\n\t" + "addw s11, s11, a7\n\t" + + /* Store digest. */ + "sw t0, 0(%[digest])\n\t" + "sw t1, 4(%[digest])\n\t" + "sw t2, 8(%[digest])\n\t" + "sw t3, 12(%[digest])\n\t" + "sw s8, 16(%[digest])\n\t" + "sw s9, 20(%[digest])\n\t" + "sw s10, 24(%[digest])\n\t" + "sw s11, 28(%[digest])\n\t" + + "add %[data], %[data], 64\n\t" + "bnez %[blocks], 1b \n\t" + + : [blocks] "+r" (blocks), [data] "+r" (data), [k] "+r" (k) + : [digest] "r" (sha256->digest) + : "cc", "memory", "t0", "t1", "t2", "t3", "t4", "t5", "t6", + "a4", "a5", "a6", "a7", + "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", + "s11" + ); +} + +#else + +/* Two rounds of compression using low two 32-bit W values. + * Assumes K has been added into W values. + */ +#define VSHA2CL_VV(vd, vs1, vs2) \ + ASM_WORD((0b101111 << 26) | (0b1 << 25) | \ + (0b010 << 12) | (0b1110111 << 0) | \ + (vd << 7) | (vs1 << 15) | (vs2 << 20)) + +/* Two rounds of compression using upper two 32-bit W values. + * Assumes K has been added into W values. + */ +#define VSHA2CH_VV(vd, vs1, vs2) \ + ASM_WORD((0b101110 << 26) | (0b1 << 25) | \ + (0b010 << 12) | (0b1110111 << 0) | \ + (vd << 7) | (vs1 << 15) | (vs2 << 20)) + +/* Update 4 W values - message scheduling. */ +#define VSHA2MS_VV(vd, vs1, vs2) \ + ASM_WORD((0b101101 << 26) | (0b1 << 25) | \ + (0b010 << 12) | (0b1110111 << 0) | \ + (vd << 7) | (vs1 << 15) | (vs2 << 20)) + +#ifndef WOLFSSL_RISCV_VECTOR_BASE_BIT_MANIPULATION +/* Indecies to use with gather vector instruction to reverse bytes. */ +static const word32 rev_idx[4] = { + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f +}; +#endif /* !WOLFSSL_RISCV_VECTOR_BASE_BIT_MANIPULATION */ + +#define RND4(w0, w1, w2, w3, k) \ + /* Four rounds of compression. */ \ + VADD_VV(REG_V7, w0, k) \ + VMV_X_S(REG_T1, w1) \ + VSHA2CL_VV(REG_V5, REG_V7, REG_V4) \ + VMV_V_V(REG_V6, w2) \ + VSHA2CH_VV(REG_V4, REG_V7, REG_V5) \ + /* Update 4 W values - message schedule. */ \ + VMV_S_X(REG_V6, REG_T1) \ + VSHA2MS_VV(w0, w3, REG_V6) + +#define RND4_LAST(w, k) \ + /* Four rounds of compression. */ \ + VADD_VV(REG_V7, w, k) \ + VSHA2CL_VV(REG_V5, REG_V7, REG_V4) \ + VSHA2CH_VV(REG_V4, REG_V7, REG_V5) + +#define RND16(k) \ + RND4(REG_V0, REG_V1, REG_V2, REG_V3, (k + 0)) \ + RND4(REG_V1, REG_V2, REG_V3, REG_V0, (k + 1)) \ + RND4(REG_V2, REG_V3, REG_V0, REG_V1, (k + 2)) \ + RND4(REG_V3, REG_V0, REG_V1, REG_V2, (k + 3)) + +#define RND16_LAST(k) \ + RND4_LAST(REG_V0, (k + 0)) \ + RND4_LAST(REG_V1, (k + 1)) \ + RND4_LAST(REG_V2, (k + 2)) \ + RND4_LAST(REG_V3, (k + 3)) + +/* Transform the message data. + * + * @param [in, out] sha256 SHA-256 object. + * @param [in] data Buffer of data to hash. + * @param [in] blocks Number of blocks of data to hash. + */ +static void Sha256Transform(wc_Sha256* sha256, const byte* data, + word32 blocks) +{ + word32* k = (word32*)K; + + __asm__ __volatile__ ( + VSETIVLI(REG_ZERO, 4, 1, 1, 0b010, 0b000) + + /* Load: a|b|e|f, c|d|g|h + * 3 2 1 0 3 2 1 0 + */ + "mv t0, %[digest]\n\t" + VL2RE32_V(REG_V4, REG_T0) + + "mv t0, %[k]\n\t" + VL8RE32_V(REG_V8, REG_T0) + "addi t0, %[k], 128\n\t" + VL8RE32_V(REG_V16, REG_T0) + + "\n1:\n\t" + VMV_V_V(REG_V30, REG_V4) + VMV_V_V(REG_V31, REG_V5) + + /* Load 16 W into 4 vectors of 4 32-bit words. */ + "mv t0, %[data]\n\t" + VL4RE32_V(REG_V0, REG_T0) + VREV8(REG_V0, REG_V0) + VREV8(REG_V1, REG_V1) + VREV8(REG_V2, REG_V2) + VREV8(REG_V3, REG_V3) + + RND16(REG_V8) + RND16(REG_V12) + RND16(REG_V16) + RND16_LAST(REG_V20) + + VADD_VV(REG_V4, REG_V4, REG_V30) + VADD_VV(REG_V5, REG_V5, REG_V31) + + "addi %[blocks], %[blocks], -1\n\t" + "add %[data], %[data], 64\n\t" + "bnez %[blocks], 1b \n\t" + + "mv t0, %[digest]\n\t" + VS2R_V(REG_V4, REG_T0) + + : [blocks] "+r" (blocks), [data] "+r" (data), [k] "+r" (k) + : [digest] "r" (sha256->digest) +#ifndef WOLFSSL_RISCV_VECTOR_BASE_BIT_MANIPULATION + , [rev_idx] "r" (rev_idx) +#endif + : "cc", "memory", "t0", "t1" + ); +} + +#endif /* WOLFSSL_RISCV_VECTOR_CRYPTO_ASM */ + +/* Update the hash with data. + * + * @param [in, out] sha256 SHA-256 object. + * @param [in] data Buffer of data to hash. + * @param [in] len Number of bytes in buffer to hash. + * @return 0 on success. + */ +static WC_INLINE int Sha256Update(wc_Sha256* sha256, const byte* data, + word32 len) +{ + word32 add; + word32 blocks; + + /* only perform actions if a buffer is passed in */ + if (len > 0) { + AddLength(sha256, len); + + if (sha256->buffLen > 0) { + /* fill leftover buffer with data */ + add = min(len, WC_SHA256_BLOCK_SIZE - sha256->buffLen); + XMEMCPY((byte*)(sha256->buffer) + sha256->buffLen, data, add); + sha256->buffLen += add; + data += add; + len -= add; + if (sha256->buffLen == WC_SHA256_BLOCK_SIZE) { + Sha256Transform(sha256, (byte*)sha256->buffer, 1); + sha256->buffLen = 0; + } + } + + /* number of blocks in a row to complete */ + blocks = len / WC_SHA256_BLOCK_SIZE; + + if (blocks > 0) { + Sha256Transform(sha256, data, blocks); + data += blocks * WC_SHA256_BLOCK_SIZE; + len -= blocks * WC_SHA256_BLOCK_SIZE; + } + + if (len > 0) { + /* copy over any remaining data leftover */ + XMEMCPY(sha256->buffer, data, len); + sha256->buffLen = len; + } + } + + /* account for possibility of not used if len = 0 */ + (void)add; + (void)blocks; + + return 0; +} + +/* Finalize the hash and put into buffer. + * + * @param [in, out] sha256 SHA-256 object. + * @param [out] hash Buffer to hold hash result. + */ +static WC_INLINE void Sha256Final(wc_Sha256* sha256, byte* hash) +{ + byte* local; + + local = (byte*)sha256->buffer; + local[sha256->buffLen++] = 0x80; /* add 1 */ + + /* pad with zeros */ + if (sha256->buffLen > WC_SHA256_PAD_SIZE) { + XMEMSET(&local[sha256->buffLen], 0, + WC_SHA256_BLOCK_SIZE - sha256->buffLen); + Sha256Transform(sha256, (byte*)sha256->buffer, 1); + sha256->buffLen = 0; + } + XMEMSET(&local[sha256->buffLen], 0, WC_SHA256_PAD_SIZE - sha256->buffLen); + + /* put lengths in bits */ + sha256->hiLen = (sha256->loLen >> (8*sizeof(sha256->loLen) - 3)) + + (sha256->hiLen << 3); + sha256->loLen = sha256->loLen << 3; + + XMEMCPY(&local[WC_SHA256_PAD_SIZE], &sha256->hiLen, sizeof(word32)); + XMEMCPY(&local[WC_SHA256_PAD_SIZE + sizeof(word32)], &sha256->loLen, + sizeof(word32)); + + /* store lengths */ + __asm__ __volatile__ ( + /* Reverse byte order of 32-bit words. */ +#if defined(WOLFSSL_RISCV_BASE_BIT_MANIPULATION) + "ld t1, 56(%[buff])\n\t" + REV8(REG_T1, REG_T1) + "srli t0, t1, 32\n\t" + "sw t0, 56(%[buff])\n\t" + "sw t1, 60(%[buff])\n\t" +#else + LOAD_WORD_REV(t0, 56, %[buff], t2, t3, t4) + LOAD_WORD_REV(t1, 60, %[buff], t2, t3, t4) + "sw t0, 56(%[buff])\n\t" + "sw t1, 60(%[buff])\n\t" +#endif + : + : [buff] "r" (sha256->buffer) + : "cc", "memory", "t0", "t1", "t2", "t3", "t4" + ); + + Sha256Transform(sha256, (byte*)sha256->buffer, 1); + + __asm__ __volatile__ ( + /* Reverse byte order of 32-bit words. */ +#if defined(WOLFSSL_RISCV_VECTOR_CRYPTO_ASM) + VSETIVLI(REG_ZERO, 4, 1, 1, 0b010, 0b000) + "mv t0, %[digest]\n\t" + VL2RE32_V(REG_V8, REG_T0) + VREV8(REG_V8, REG_V8) + VREV8(REG_V9, REG_V9) + /* a|b|e|f, c|d|g|h + * 3 2 1 0 3 2 1 0 */ + VSLIDEDOWN_VI(REG_V0, REG_V8, 3) /* a */ + VSLIDEDOWN_VI(REG_V2, REG_V8, 2) /* b */ + VSLIDEDOWN_VI(REG_V1, REG_V8, 1) /* e */ + VSLIDEDOWN_VI(REG_V3, REG_V9, 3) /* c */ + VSLIDEDOWN_VI(REG_V4, REG_V9, 2) /* d */ + VSLIDEDOWN_VI(REG_V5, REG_V9, 1) /* g */ + /* -|-|-|a, -|-|-|e */ + VSLIDEUP_VI(REG_V0, REG_V2, 1) + /* -|-|b|a, -|-|-|e */ + VSLIDEUP_VI(REG_V0, REG_V3, 2) + /* -|c|b|a, -|-|-|e */ + VSLIDEUP_VI(REG_V0, REG_V4, 3) + /* d|c|b|a, -|-|-|e */ + VSLIDEUP_VI(REG_V1, REG_V8, 1) + /* d|c|b|a, -|-|f|e */ + VSLIDEUP_VI(REG_V1, REG_V5, 2) + /* d|c|b|a, -|g|f|e */ + VSLIDEUP_VI(REG_V1, REG_V9, 3) + /* d|c|b|a, h|g|f|e */ + "mv t0, %[hash]\n\t" + VS2R_V(REG_V0, REG_T0) +#elif defined(WOLFSSL_RISCV_VECTOR_BASE_BIT_MANIPULATION) + VSETIVLI(REG_ZERO, 4, 1, 1, 0b010, 0b000) + "mv t0, %[digest]\n\t" + VL2RE32_V(REG_V0, REG_T0) + VREV8(REG_V0, REG_V0) + VREV8(REG_V1, REG_V1) + "mv t0, %[hash]\n\t" + VS2R_V(REG_V0, REG_T0) +#elif defined(WOLFSSL_RISCV_BASE_BIT_MANIPULATION) + "ld t1, 0(%[digest])\n\t" + "ld t3, 8(%[digest])\n\t" + "ld a5, 16(%[digest])\n\t" + "ld a7, 24(%[digest])\n\t" + REV8(REG_T1, REG_T1) + REV8(REG_T3, REG_T3) + REV8(REG_A5, REG_A5) + REV8(REG_A7, REG_A7) + "srli t0, t1, 32\n\t" + "srli t2, t3, 32\n\t" + "srli a4, a5, 32\n\t" + "srli a6, a7, 32\n\t" + "sw t0, 0(%[hash])\n\t" + "sw t1, 4(%[hash])\n\t" + "sw t2, 8(%[hash])\n\t" + "sw t3, 12(%[hash])\n\t" + "sw a4, 16(%[hash])\n\t" + "sw a5, 20(%[hash])\n\t" + "sw a6, 24(%[hash])\n\t" + "sw a7, 28(%[hash])\n\t" +#else + LOAD_WORD_REV(t0, 0, %[digest], t2, t3, t4) + LOAD_WORD_REV(t1, 4, %[digest], t2, t3, t4) + LOAD_WORD_REV(a4, 8, %[digest], t2, t3, t4) + LOAD_WORD_REV(a5, 12, %[digest], t2, t3, t4) + "sw t0, 0(%[hash])\n\t" + "sw t1, 4(%[hash])\n\t" + "sw a4, 8(%[hash])\n\t" + "sw a5, 12(%[hash])\n\t" + LOAD_WORD_REV(t0, 16, %[digest], t2, t3, t4) + LOAD_WORD_REV(t1, 20, %[digest], t2, t3, t4) + LOAD_WORD_REV(a4, 24, %[digest], t2, t3, t4) + LOAD_WORD_REV(a5, 28, %[digest], t2, t3, t4) + "sw t0, 16(%[hash])\n\t" + "sw t1, 20(%[hash])\n\t" + "sw a4, 24(%[hash])\n\t" + "sw a5, 28(%[hash])\n\t" +#endif + : + : [digest] "r" (sha256->digest), [hash] "r" (hash) +#if defined(WOLFSSL_RISCV_VECTOR_CRYPTO_ASM) && \ + !defined(WOLFSSL_RISCV_VECTOR_BASE_BIT_MANIPULATION) + , [rev_idx] "r" (rev_idx) +#endif + : "cc", "memory", "t0", "t1", "t2", "t3", "t4", "t5", "t6", + "a4", "a5", "a6", "a7" + ); +} + + +#ifndef NO_SHA256 + +/* Initialize SHA-256 object for hashing. + * + * @param [in, out] sha256 SHA-256 object. + * @param [in] heap Dynamic memory hint. + * @param [in] devId Device Id. + * @return 0 on success. + * @return BAD_FUNC_ARG when sha256 is NULL. + */ +int wc_InitSha256_ex(wc_Sha256* sha256, void* heap, int devId) +{ + int ret = 0; + + /* Validate parameters. */ + if (sha256 == NULL) { + ret = BAD_FUNC_ARG; + } + else { + sha256->heap = heap; + #ifdef WOLF_CRYPTO_CB + sha256->devId = devId; + #endif + (void)devId; + + InitSha256(sha256); + } + + return ret; +} + +/* Initialize SHA-256 object for hashing. + * + * @param [in, out] sha256 SHA-256 object. + * @return 0 on success. + * @return BAD_FUNC_ARG when sha256 is NULL. + */ +int wc_InitSha256(wc_Sha256* sha256) +{ + return wc_InitSha256_ex(sha256, NULL, INVALID_DEVID); +} + +/* Free the SHA-256 hash. + * + * @param [in] sha256 SHA-256 object. + */ +void wc_Sha256Free(wc_Sha256* sha256) +{ + /* No dynamic memory allocated. */ + (void)sha256; +} + +/* Update the hash with data. + * + * @param [in, out] sha256 SHA-256 object. + * @param [in] data Buffer of data to hash. + * @param [in] len Number of bytes in buffer to hash. + * @return 0 on success. + * @return BAD_FUNC_ARG when sha256 is NULL. + * @return BAD_FUNC_ARG when data is NULL but len is not 0. + */ +int wc_Sha256Update(wc_Sha256* sha256, const byte* data, word32 len) +{ + int ret; + + /* Validate parameters. */ + if ((sha256 == NULL) || ((data == NULL) && (len != 0))) { + ret = BAD_FUNC_ARG; + } + else { + ret = Sha256Update(sha256, data, len); + } + + return ret; +} + +/* Put the current hash into buffer. + * + * @param [in, out] sha256 SHA-256 object. + * @param [out] hash Buffer to hold hash result. + * @return 0 on success. + * @return BAD_FUNC_ARG when sha256 or hash is NULL. + */ +int wc_Sha256FinalRaw(wc_Sha256* sha256, byte* hash) +{ + int ret = 0; + + /* Validate parameters. */ + if ((sha256 == NULL) || (hash == NULL)) { + ret = BAD_FUNC_ARG; + } + else { + #ifdef LITTLE_ENDIAN_ORDER + word32 digest[WC_SHA256_DIGEST_SIZE / sizeof(word32)]; + + ByteReverseWords((word32*)digest, (word32*)sha256->digest, + WC_SHA256_DIGEST_SIZE); + XMEMCPY(hash, digest, WC_SHA256_DIGEST_SIZE); + #else + XMEMCPY(hash, sha256->digest, WC_SHA256_DIGEST_SIZE); + #endif + } + + return ret; +} + +/* Finalize the hash and put into buffer. + * + * @param [in, out] sha256 SHA-256 object. + * @param [out] hash Buffer to hold hash result. + * @return 0 on success. + * @return BAD_FUNC_ARG when sha256 or hash is NULL. + */ +int wc_Sha256Final(wc_Sha256* sha256, byte* hash) +{ + int ret = 0; + + /* Validate parameters. */ + if ((sha256 == NULL) || (hash == NULL)) { + ret = BAD_FUNC_ARG; + } + else { + /* Finalize hash. */ + Sha256Final(sha256, hash); + /* Restart SHA-256 object for next hash. */ + InitSha256(sha256); + } + + return ret; +} + +/* Finalize the hash and put into buffer but don't modify state. + * + * @param [in, out] sha256 SHA-256 object. + * @param [out] hash Buffer to hold hash result. + * @return 0 on success. + * @return BAD_FUNC_ARG when sha256 or hash is NULL. + */ +int wc_Sha256GetHash(wc_Sha256* sha256, byte* hash) +{ + int ret; + + /* Validate parameters. */ + if ((sha256 == NULL) || (hash == NULL)) { + ret = BAD_FUNC_ARG; + } + else { + wc_Sha256 tmpSha256; + /* Create a copy of the hash to finalize. */ + ret = wc_Sha256Copy(sha256, &tmpSha256); + if (ret == 0) { + /* Finalize copy. */ + Sha256Final(&tmpSha256, hash); + } + } + + return ret; +} + +#ifdef WOLFSSL_HASH_FLAGS +/* Set flags of SHA-256 object. + * + * @param [in, out] sha256 SHA-256 object. + * @param [in] flags Flags to set. + * @return 0 on success. + */ +int wc_Sha256SetFlags(wc_Sha256* sha256, word32 flags) +{ + /* Check we have an object to use. */ + if (sha256 != NULL) { + sha256->flags = flags; + } + return 0; +} +/* Get flags of SHA-256 object. + * + * @param [in] sha256 SHA-256 object. + * @param [out] flags Flags from SHA-256 object. + * @return 0 on success. + */ +int wc_Sha256GetFlags(wc_Sha256* sha256, word32* flags) +{ + /* Check we have an object and return parameter to use. */ + if ((sha256 != NULL) && (flags != NULL)) { + *flags = sha256->flags; + } + return 0; +} +#endif + +/* Deep copy the SHA-256 object. + * + * @param [in] src SHA-256 object to copy. + * @param [out] dst SHA-256 object to fill. + * @return 0 on success. + * @return BAD_FUNC_ARG when src or dst is NULL. + */ +int wc_Sha256Copy(wc_Sha256* src, wc_Sha256* dst) +{ + int ret = 0; + + /* Validate parameters. */ + if ((src == NULL) || (dst == NULL)) { + ret = BAD_FUNC_ARG; + } + else { + XMEMCPY(dst, src, sizeof(wc_Sha256)); + } + + return ret; +} + +#ifdef OPENSSL_EXTRA +/* Update the hash with one block of data. + * + * @param [in, out] sha256 SHA-256 object. + * @param [in] data Buffer of data to hash. + * @return 0 on success. + * @return BAD_FUNC_ARG when sha256 or data is NULL. + */ +int wc_Sha256Transform(wc_Sha256* sha256, const unsigned char* data) +{ + int ret = 0; + + /* Validate parameters. */ + if ((sha256 == NULL) || (data == NULL)) { + ret = BAD_FUNC_ARG; + } + else { + #ifdef LITTLE_ENDIAN_ORDER + ByteReverseWords(sha256->buffer, (word32*)data, WC_SHA256_BLOCK_SIZE); + #else + XMEMCPY(sha256->buffer, data, WC_SHA256_BLOCK_SIZE); + #endif + Sha256Transform(sha256, (byte*)sha256->buffer, 1); + } + + return ret; +} +#endif + +#if defined(WOLFSSL_HAVE_LMS) && !defined(WOLFSSL_LMS_FULL_HASH) +/* Update the hash with one block of data and optionally get hash. + * + * @param [in, out] sha256 SHA-256 object. + * @param [in] data Buffer of data to hash. + * @param [out] hash Buffer to hold hash. May be NULL. + * @return 0 on success. + * @return BAD_FUNC_ARG when sha256 or data is NULL. + */ +int wc_Sha256HashBlock(wc_Sha256* sha256, const unsigned char* data, + unsigned char* hash) +{ + int ret = 0; + + /* Validate parameters. */ + if ((sha256 == NULL) || (data == NULL)) { + ret = BAD_FUNC_ARG; + } + else { + /* Hash block. */ + Sha256Transform(sha256, data, 1); + + if (hash != NULL) { + /* Reverse bytes in digest. */ + #ifdef LITTLE_ENDIAN_ORDER + word32* hash32 = (word32*)hash; + word32* digest = (word32*)sha256->digest; + hash32[0] = ByteReverseWord32(digest[0]); + hash32[1] = ByteReverseWord32(digest[1]); + hash32[2] = ByteReverseWord32(digest[2]); + hash32[3] = ByteReverseWord32(digest[3]); + hash32[4] = ByteReverseWord32(digest[4]); + hash32[5] = ByteReverseWord32(digest[5]); + hash32[6] = ByteReverseWord32(digest[6]); + hash32[7] = ByteReverseWord32(digest[7]); + #else + XMEMCPY(hash, sha256->digest, WC_SHA256_DIGEST_SIZE); + #endif + /* Reset state. */ + #ifndef WOLFSSL_RISCV_VECTOR_CRYPTO_ASM + sha256->digest[0] = 0x6A09E667L; + sha256->digest[1] = 0xBB67AE85L; + sha256->digest[2] = 0x3C6EF372L; + sha256->digest[3] = 0xA54FF53AL; + sha256->digest[4] = 0x510E527FL; + sha256->digest[5] = 0x9B05688CL; + sha256->digest[6] = 0x1F83D9ABL; + sha256->digest[7] = 0x5BE0CD19L; + #else + /* f, e, b, a, h, g, d, c */ + sha256->digest[0] = 0x9B05688CL; + sha256->digest[1] = 0x510E527FL; + sha256->digest[2] = 0xBB67AE85L; + sha256->digest[3] = 0x6A09E667L; + sha256->digest[4] = 0x5BE0CD19L; + sha256->digest[5] = 0x1F83D9ABL; + sha256->digest[6] = 0xA54FF53AL; + sha256->digest[7] = 0x3C6EF372L; + #endif + } + } + + return ret; +} +#endif /* WOLFSSL_HAVE_LMS && !WOLFSSL_LMS_FULL_HASH */ + +#endif /* !NO_SHA256 */ + + +#ifdef WOLFSSL_SHA224 + +/* Initialze SHA-224 object for hashing. + * + * @param [in, out] sha224 SHA-224 object. + */ +static void InitSha224(wc_Sha224* sha224) +{ + /* Set initial hash values. */ +#ifndef WOLFSSL_RISCV_VECTOR_CRYPTO_ASM + sha224->digest[0] = 0xc1059ed8; + sha224->digest[1] = 0x367cd507; + sha224->digest[2] = 0x3070dd17; + sha224->digest[3] = 0xf70e5939; + sha224->digest[4] = 0xffc00b31; + sha224->digest[5] = 0x68581511; + sha224->digest[6] = 0x64f98fa7; + sha224->digest[7] = 0xbefa4fa4; +#else + /* f, e, b, a, h, g, d, c */ + sha224->digest[0] = 0x68581511; + sha224->digest[1] = 0xffc00b31; + sha224->digest[2] = 0x367cd507; + sha224->digest[3] = 0xc1059ed8; + sha224->digest[4] = 0xbefa4fa4; + sha224->digest[5] = 0x64f98fa7; + sha224->digest[6] = 0xf70e5939; + sha224->digest[7] = 0x3070dd17; +#endif + + /* No hashed data. */ + sha224->buffLen = 0; + /* No data hashed. */ + sha224->loLen = 0; + sha224->hiLen = 0; + +#ifdef WOLFSSL_HASH_FLAGS + sha224->flags = 0; +#endif +} + +/* Initialize SHA-224 object for hashing. + * + * @param [in, out] sha224 SHA-224 object. + * @param [in] heap Dynamic memory hint. + * @param [in] devId Device Id. + * @return 0 on success. + * @return BAD_FUNC_ARG when sha224 is NULL. + */ +int wc_InitSha224_ex(wc_Sha224* sha224, void* heap, int devId) +{ + int ret = 0; + + /* Validate parameters. */ + if (sha224 == NULL) { + ret = BAD_FUNC_ARG; + } + else { + sha224->heap = heap; + (void)devId; + + InitSha224(sha224); + } + + return ret; +} + +/* Initialize SHA-224 object for hashing. + * + * @param [in, out] sha224 SHA-224 object. + * @return 0 on success. + * @return BAD_FUNC_ARG when sha224 is NULL. + */ +int wc_InitSha224(wc_Sha224* sha224) +{ + return wc_InitSha224_ex(sha224, NULL, INVALID_DEVID); +} + +/* Update the hash with data. + * + * @param [in, out] sha224 SHA-224 object. + * @param [in] data Buffer of data to hash. + * @param [in] len Number of bytes in buffer to hash. + * @return 0 on success. + * @return BAD_FUNC_ARG when sha224 is NULL. + * @return BAD_FUNC_ARG when data is NULL but len is not 0. + */ +int wc_Sha224Update(wc_Sha224* sha224, const byte* data, word32 len) +{ + int ret; + + /* Validate parameters. */ + if ((sha224 == NULL) || ((data == NULL) && (len > 0))) { + ret = BAD_FUNC_ARG; + } + else { + ret = Sha256Update((wc_Sha256 *)sha224, data, len); + } + + return ret; +} + +/* Finalize the hash and put into buffer. + * + * @param [in, out] sha224 SHA-224 object. + * @param [out] hash Buffer to hold hash result. + * @return 0 on success. + * @return BAD_FUNC_ARG when sha224 or hash is NULL. + */ +int wc_Sha224Final(wc_Sha224* sha224, byte* hash) +{ + int ret = 0; + + /* Validate parameters. */ + if ((sha224 == NULL) || (hash == NULL)) { + ret = BAD_FUNC_ARG; + } + else { + word32 hashTmp[WC_SHA256_DIGEST_SIZE/sizeof(word32)]; + /* Finalize hash. */ + Sha256Final((wc_Sha256*)sha224, (byte*)hashTmp); + /* Return only 224 bits. */ + XMEMCPY(hash, hashTmp, WC_SHA224_DIGEST_SIZE); + /* Restart SHA-256 object for next hash. */ + InitSha224(sha224); + } + + return ret; +} + +/* Free the SHA-224 hash. + * + * @param [in] sha224 SHA-224 object. + */ +void wc_Sha224Free(wc_Sha224* sha224) +{ + /* No dynamic memory allocated. */ + (void)sha224; +} + +/* Finalize the hash and put into buffer but don't modify state. + * + * @param [in, out] sha224 SHA-224 object. + * @param [out] hash Buffer to hold hash result. + * @return 0 on success. + * @return BAD_FUNC_ARG when sha224 or hash is NULL. + */ +int wc_Sha224GetHash(wc_Sha224* sha224, byte* hash) +{ + int ret; + + /* Validate parameters. */ + if ((sha224 == NULL) || (hash == NULL)) { + ret = BAD_FUNC_ARG; + } + else { + wc_Sha224 tmpSha224; + /* Create a copy of the hash to finalize. */ + ret = wc_Sha224Copy(sha224, &tmpSha224); + if (ret == 0) { + /* Finalize copy. */ + ret = wc_Sha224Final(&tmpSha224, hash); + } + } + + return ret; +} + +#ifdef WOLFSSL_HASH_FLAGS +/* Set flags of SHA-224 object. + * + * @param [in, out] sha224 SHA-224 object. + * @param [in] flags Flags to set. + * @return 0 on success. + */ +int wc_Sha224SetFlags(wc_Sha224* sha224, word32 flags) +{ + /* Check we have an object to use. */ + if (sha224 != NULL) { + sha224->flags = flags; + } + return 0; +} +/* Get flags of SHA-224 object. + * + * @param [in] sha224 SHA-224 object. + * @param [out] flags Flags from SHA-224 object. + * @return 0 on success. + */ +int wc_Sha224GetFlags(wc_Sha224* sha224, word32* flags) +{ + /* Check we have an object and return parameter to use. */ + if ((sha224 != NULL) && (flags != NULL)) { + *flags = sha224->flags; + } + return 0; +} +#endif + +/* Deep copy the SHA-224 object. + * + * @param [in] src SHA-224 object to copy. + * @param [out] dst SHA-224 object to fill. + * @return 0 on success. + * @return BAD_FUNC_ARG when src or dst is NULL. + */ +int wc_Sha224Copy(wc_Sha224* src, wc_Sha224* dst) +{ + int ret = 0; + + /* Validate parameters. */ + if ((src == NULL) || (dst == NULL)) { + ret = BAD_FUNC_ARG; + } + else { + XMEMCPY(dst, src, sizeof(wc_Sha224)); + } + + return ret; +} + +#endif /* WOLFSSL_SHA224 */ + +#endif /* !NO_SHA256 || WOLFSSL_SHA224 */ +#endif /* WOLFSSL_RISCV_ASM */ diff --git a/wolfcrypt/src/port/silabs/silabs_aes.c b/wolfcrypt/src/port/silabs/silabs_aes.c index 63e633d73f..db4f0701eb 100644 --- a/wolfcrypt/src/port/silabs/silabs_aes.c +++ b/wolfcrypt/src/port/silabs/silabs_aes.c @@ -1,6 +1,6 @@ /* silabs_aes.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/silabs/silabs_ecc.c b/wolfcrypt/src/port/silabs/silabs_ecc.c index 6dbb28589e..2c59137ceb 100644 --- a/wolfcrypt/src/port/silabs/silabs_ecc.c +++ b/wolfcrypt/src/port/silabs/silabs_ecc.c @@ -1,6 +1,6 @@ /* silabs_ecc.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/silabs/silabs_hash.c b/wolfcrypt/src/port/silabs/silabs_hash.c index f0bb1110a1..093bae9bbb 100644 --- a/wolfcrypt/src/port/silabs/silabs_hash.c +++ b/wolfcrypt/src/port/silabs/silabs_hash.c @@ -1,6 +1,6 @@ /* silabs_hash.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/silabs/silabs_random.c b/wolfcrypt/src/port/silabs/silabs_random.c index c66ef67c39..26bfad6e72 100644 --- a/wolfcrypt/src/port/silabs/silabs_random.c +++ b/wolfcrypt/src/port/silabs/silabs_random.c @@ -1,6 +1,6 @@ /* silabs_random.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/st/stm32.c b/wolfcrypt/src/port/st/stm32.c index 83497af2cc..343e3a7f35 100644 --- a/wolfcrypt/src/port/st/stm32.c +++ b/wolfcrypt/src/port/st/stm32.c @@ -1,6 +1,6 @@ /* stm32.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -303,12 +303,11 @@ int wc_Stm32_Hash_Update(STM32_HASH_Context* stmCtx, word32 algo, int ret = 0; byte* local = (byte*)stmCtx->buffer; int wroteToFifo = 0; - const word32 fifoSz = (STM32_HASH_FIFO_SIZE * STM32_HASH_REG_SIZE); word32 chunkSz; #ifdef DEBUG_STM32_HASH - printf("STM Hash Update: algo %x, len %d, blockSz %d\n", - algo, len, blockSize); + printf("STM Hash Update: algo %x, len %d, buffLen %d, fifoBytes %d\n", + algo, len, stmCtx->buffLen, stmCtx->fifoBytes); #endif (void)blockSize; @@ -323,40 +322,27 @@ int wc_Stm32_Hash_Update(STM32_HASH_Context* stmCtx, word32 algo, /* restore hash context or init as new hash */ wc_Stm32_Hash_RestoreContext(stmCtx, algo); - chunkSz = fifoSz; -#ifdef STM32_HASH_FIFO_WORKAROUND - /* if FIFO already has bytes written then fill remainder first */ - if (stmCtx->fifoBytes > 0) { - chunkSz -= stmCtx->fifoBytes; - stmCtx->fifoBytes = 0; - } -#endif - /* write blocks to FIFO */ while (len) { - word32 add = min(len, chunkSz - stmCtx->buffLen); + word32 add; + + /* fill the FIFO plus one additional to flush the block */ + chunkSz = ((STM32_HASH_FIFO_SIZE + 1) * STM32_HASH_REG_SIZE); + /* account for extra bytes in the FIFO (use mask 0x3F to get remain) */ + chunkSz -= (stmCtx->fifoBytes & + ((STM32_HASH_FIFO_SIZE * STM32_HASH_REG_SIZE)-1)); + + add = min(len, chunkSz - stmCtx->buffLen); XMEMCPY(&local[stmCtx->buffLen], data, add); stmCtx->buffLen += add; data += add; len -= add; - #ifdef STM32_HASH_FIFO_WORKAROUND - /* We cannot leave the FIFO full and do save/restore - * the last must be large enough to flush block from FIFO */ - if (stmCtx->buffLen + len <= fifoSz * 2) { - chunkSz = fifoSz + STM32_HASH_REG_SIZE; - } - #endif - if (stmCtx->buffLen == chunkSz) { wc_Stm32_Hash_Data(stmCtx, stmCtx->buffLen); wroteToFifo = 1; - #ifdef STM32_HASH_FIFO_WORKAROUND - if (chunkSz > fifoSz) - stmCtx->fifoBytes = chunkSz - fifoSz; - chunkSz = fifoSz; - #endif + stmCtx->fifoBytes += chunkSz; } } @@ -380,7 +366,8 @@ int wc_Stm32_Hash_Final(STM32_HASH_Context* stmCtx, word32 algo, int ret = 0; #ifdef DEBUG_STM32_HASH - printf("STM Hash Final: algo %x, digestSz %d\n", algo, digestSize); + printf("STM Hash Final: algo %x, digestSz %d, buffLen %d, fifoBytes %d\n", + algo, digestSize, stmCtx->buffLen, stmCtx->fifoBytes); #endif /* turn on hash clock */ diff --git a/wolfcrypt/src/port/st/stsafe.c b/wolfcrypt/src/port/st/stsafe.c index 518943b208..fad4e8ee5c 100644 --- a/wolfcrypt/src/port/st/stsafe.c +++ b/wolfcrypt/src/port/st/stsafe.c @@ -1,6 +1,6 @@ /* stsafe.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/ti/ti-aes.c b/wolfcrypt/src/port/ti/ti-aes.c index 5f764508e8..8021710487 100644 --- a/wolfcrypt/src/port/ti/ti-aes.c +++ b/wolfcrypt/src/port/ti/ti-aes.c @@ -1,6 +1,6 @@ /* port/ti/ti-aes.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/ti/ti-ccm.c b/wolfcrypt/src/port/ti/ti-ccm.c index 1b4a26590c..a8692e86f4 100644 --- a/wolfcrypt/src/port/ti/ti-ccm.c +++ b/wolfcrypt/src/port/ti/ti-ccm.c @@ -1,6 +1,6 @@ /* port/ti/ti_ccm.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/ti/ti-des3.c b/wolfcrypt/src/port/ti/ti-des3.c index 47ef04a4b1..de343ebce1 100644 --- a/wolfcrypt/src/port/ti/ti-des3.c +++ b/wolfcrypt/src/port/ti/ti-des3.c @@ -1,6 +1,6 @@ /* port/ti/ti-des.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/ti/ti-hash.c b/wolfcrypt/src/port/ti/ti-hash.c index 48270f15a8..16be736384 100644 --- a/wolfcrypt/src/port/ti/ti-hash.c +++ b/wolfcrypt/src/port/ti/ti-hash.c @@ -1,6 +1,6 @@ /* port/ti/ti-hash.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/xilinx/xil-aesgcm.c b/wolfcrypt/src/port/xilinx/xil-aesgcm.c index d92a2cd415..6fdea35459 100644 --- a/wolfcrypt/src/port/xilinx/xil-aesgcm.c +++ b/wolfcrypt/src/port/xilinx/xil-aesgcm.c @@ -1,6 +1,6 @@ /* xil-aesgcm.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/xilinx/xil-sha3.c b/wolfcrypt/src/port/xilinx/xil-sha3.c index 0d440916b2..8c9bbb921f 100644 --- a/wolfcrypt/src/port/xilinx/xil-sha3.c +++ b/wolfcrypt/src/port/xilinx/xil-sha3.c @@ -1,6 +1,6 @@ /* xil-sha3.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/xilinx/xil-versal-glue.c b/wolfcrypt/src/port/xilinx/xil-versal-glue.c index f40c86a077..3ee87e1749 100644 --- a/wolfcrypt/src/port/xilinx/xil-versal-glue.c +++ b/wolfcrypt/src/port/xilinx/xil-versal-glue.c @@ -1,6 +1,6 @@ /* xil-versal-glue.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/xilinx/xil-versal-trng.c b/wolfcrypt/src/port/xilinx/xil-versal-trng.c index 5f546f116b..9aac5bcd81 100644 --- a/wolfcrypt/src/port/xilinx/xil-versal-trng.c +++ b/wolfcrypt/src/port/xilinx/xil-versal-trng.c @@ -1,6 +1,6 @@ /* xil-versal-trng.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/pwdbased.c b/wolfcrypt/src/pwdbased.c index 1aef716bca..022d9f80c2 100644 --- a/wolfcrypt/src/pwdbased.c +++ b/wolfcrypt/src/pwdbased.c @@ -1,6 +1,6 @@ /* pwdbased.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 89c7411c9e..822f069f7f 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -1,6 +1,6 @@ /* random.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -110,7 +110,7 @@ This library contains implementation for the random number generator. #include #include #elif defined(WOLFSSL_XILINX_CRYPT_VERSAL) -#include "wolfssl/wolfcrypt/port/xilinx/xil-versal-trng.h" + #include "wolfssl/wolfcrypt/port/xilinx/xil-versal-trng.h" #elif defined(NO_DEV_RANDOM) #elif defined(CUSTOM_RAND_GENERATE) #elif defined(CUSTOM_RAND_GENERATE_BLOCK) @@ -126,6 +126,9 @@ This library contains implementation for the random number generator. #elif defined(WOLFSSL_PB) #elif defined(WOLFSSL_ZEPHYR) #elif defined(WOLFSSL_TELIT_M2MB) +#elif defined(WOLFSSL_RENESAS_TSIP) + /* for wc_tsip_GenerateRandBlock */ + #include "wolfssl/wolfcrypt/port/Renesas/renesas-tsip-crypt.h" #elif defined(WOLFSSL_SCE) && !defined(WOLFSSL_SCE_NO_TRNG) #elif defined(WOLFSSL_IMXRT1170_CAAM) #elif defined(CY_USING_HAL) && defined(COMPONENT_WOLFSSL) @@ -591,7 +594,7 @@ static WC_INLINE void array_add(byte* d, word32 dLen, const byte* s, word32 sLen dIdx = (int)dLen - 1; for (sIdx = (int)sLen - 1; sIdx >= 0; sIdx--) { - carry += (word16)(d[dIdx] + s[sIdx]); + carry += (word16)((word16)d[dIdx] + (word16)s[sIdx]); d[dIdx] = (byte)carry; carry >>= 8; dIdx--; @@ -3652,6 +3655,14 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) return 0; } +#elif defined(WOLFSSL_RENESAS_TSIP) + + int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) + { + (void)os; + return wc_tsip_GenerateRandBlock(output, sz); + } + #elif defined(WOLFSSL_SCE) && !defined(WOLFSSL_SCE_NO_TRNG) #include "hal_data.h" diff --git a/wolfcrypt/src/rc2.c b/wolfcrypt/src/rc2.c index 3839d4941e..67dc7d68f3 100644 --- a/wolfcrypt/src/rc2.c +++ b/wolfcrypt/src/rc2.c @@ -1,6 +1,6 @@ /* rc2.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/ripemd.c b/wolfcrypt/src/ripemd.c index 9402c70bea..36cca1b3e6 100644 --- a/wolfcrypt/src/ripemd.c +++ b/wolfcrypt/src/ripemd.c @@ -1,6 +1,6 @@ /* ripemd.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/rsa.c b/wolfcrypt/src/rsa.c index 587e47c4b4..71745bcbfd 100644 --- a/wolfcrypt/src/rsa.c +++ b/wolfcrypt/src/rsa.c @@ -1,6 +1,6 @@ /* rsa.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sakke.c b/wolfcrypt/src/sakke.c index c87963acc7..a3407ed737 100644 --- a/wolfcrypt/src/sakke.c +++ b/wolfcrypt/src/sakke.c @@ -1,6 +1,6 @@ /* sakke.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sha.c b/wolfcrypt/src/sha.c index a6f5122d9a..bed2c4c0b6 100644 --- a/wolfcrypt/src/sha.c +++ b/wolfcrypt/src/sha.c @@ -1,6 +1,6 @@ /* sha.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sha256.c b/wolfcrypt/src/sha256.c index f955dff4f7..180a6c044b 100644 --- a/wolfcrypt/src/sha256.c +++ b/wolfcrypt/src/sha256.c @@ -1,6 +1,6 @@ /* sha256.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -63,8 +63,8 @@ on the specific device platform. #endif -#if !defined(NO_SHA256) && (!defined(WOLFSSL_ARMASM) && \ - !defined(WOLFSSL_ARMASM_NO_NEON)) +#if !defined(NO_SHA256) && !(defined(WOLFSSL_ARMASM) || \ + defined(WOLFSSL_ARMASM_NO_NEON)) && !defined(WOLFSSL_RISCV_ASM) #if defined(HAVE_FIPS) && defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) /* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */ @@ -2496,7 +2496,7 @@ int wc_Sha256GetHash(wc_Sha256* sha256, byte* hash) ret = wc_Sha256Copy(sha256, tmpSha256); if (ret == 0) { ret = wc_Sha256Final(tmpSha256, hash); - wc_Sha256Free(tmpSha256); /* TODO move outside brackets? */ + wc_Sha256Free(tmpSha256); } diff --git a/wolfcrypt/src/sha3.c b/wolfcrypt/src/sha3.c index 99f739b029..6346173199 100644 --- a/wolfcrypt/src/sha3.c +++ b/wolfcrypt/src/sha3.c @@ -1,6 +1,6 @@ /* sha3.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sha3_asm.S b/wolfcrypt/src/sha3_asm.S index 07a0b140bf..a67002073e 100644 --- a/wolfcrypt/src/sha3_asm.S +++ b/wolfcrypt/src/sha3_asm.S @@ -1,6 +1,6 @@ /* sha3_asm.S */ /* - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sha512.c b/wolfcrypt/src/sha512.c index 88c38f0625..938798707b 100644 --- a/wolfcrypt/src/sha512.c +++ b/wolfcrypt/src/sha512.c @@ -1,6 +1,6 @@ /* sha512.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sha512_asm.S b/wolfcrypt/src/sha512_asm.S index 47789e83aa..2c6a06b976 100644 --- a/wolfcrypt/src/sha512_asm.S +++ b/wolfcrypt/src/sha512_asm.S @@ -1,6 +1,6 @@ /* sha512_asm.S */ /* - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/signature.c b/wolfcrypt/src/signature.c index 33cec70309..4c4f47ee8a 100644 --- a/wolfcrypt/src/signature.c +++ b/wolfcrypt/src/signature.c @@ -1,6 +1,6 @@ /* signature.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/siphash.c b/wolfcrypt/src/siphash.c index 173b914824..4a219f08c6 100644 --- a/wolfcrypt/src/siphash.c +++ b/wolfcrypt/src/siphash.c @@ -1,6 +1,6 @@ /* siphash.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sm2.c b/wolfcrypt/src/sm2.c index 829d5e5b28..24b8df96f8 100644 --- a/wolfcrypt/src/sm2.c +++ b/wolfcrypt/src/sm2.c @@ -1,6 +1,6 @@ /* sm2.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sm3.c b/wolfcrypt/src/sm3.c index 1339037b75..dfbef2ec9e 100644 --- a/wolfcrypt/src/sm3.c +++ b/wolfcrypt/src/sm3.c @@ -1,6 +1,6 @@ /* sm3.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sm3_asm.S b/wolfcrypt/src/sm3_asm.S index 2c368f1ff3..7c53a6fa68 100644 --- a/wolfcrypt/src/sm3_asm.S +++ b/wolfcrypt/src/sm3_asm.S @@ -1,6 +1,6 @@ /* sm3_asm.S * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sm4.c b/wolfcrypt/src/sm4.c index 1e4f31760c..c29cc2bd29 100644 --- a/wolfcrypt/src/sm4.c +++ b/wolfcrypt/src/sm4.c @@ -1,6 +1,6 @@ /* sm4.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_arm32.c b/wolfcrypt/src/sp_arm32.c index 8529e41926..73f4103d4f 100644 --- a/wolfcrypt/src/sp_arm32.c +++ b/wolfcrypt/src/sp_arm32.c @@ -1,6 +1,6 @@ /* sp.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_arm64.c b/wolfcrypt/src/sp_arm64.c index ea3ce39218..c51a730e04 100644 --- a/wolfcrypt/src/sp_arm64.c +++ b/wolfcrypt/src/sp_arm64.c @@ -1,6 +1,6 @@ /* sp.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_armthumb.c b/wolfcrypt/src/sp_armthumb.c index c7cb418c26..f10b944e13 100644 --- a/wolfcrypt/src/sp_armthumb.c +++ b/wolfcrypt/src/sp_armthumb.c @@ -1,6 +1,6 @@ /* sp.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_c32.c b/wolfcrypt/src/sp_c32.c index 21a9e0efa6..b89c7419cb 100644 --- a/wolfcrypt/src/sp_c32.c +++ b/wolfcrypt/src/sp_c32.c @@ -1,6 +1,6 @@ /* sp.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_c64.c b/wolfcrypt/src/sp_c64.c index 93fd140ba8..c1fadc5b09 100644 --- a/wolfcrypt/src/sp_c64.c +++ b/wolfcrypt/src/sp_c64.c @@ -1,6 +1,6 @@ /* sp.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_cortexm.c b/wolfcrypt/src/sp_cortexm.c index 8ef1a13c92..a9151f483f 100644 --- a/wolfcrypt/src/sp_cortexm.c +++ b/wolfcrypt/src/sp_cortexm.c @@ -1,6 +1,6 @@ /* sp.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -2211,7 +2211,11 @@ static sp_digit sp_2048_add_64(sp_digit* r, const sp_digit* a, const sp_digit* b "MOV r3, #0x0\n\t" "ADD r12, %[a], #0x100\n\t" "\n" - "L_sp_2048_add_64_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_add_64_word:\n\t" +#else + "L_sp_2048_add_64_word_%=:\n\t" +#endif "ADDS r3, r3, #0xffffffff\n\t" "LDM %[a]!, {r4, r5, r6, r7}\n\t" "LDM %[b]!, {r8, r9, r10, r11}\n\t" @@ -2223,10 +2227,12 @@ static sp_digit sp_2048_add_64(sp_digit* r, const sp_digit* a, const sp_digit* b "MOV r4, #0x0\n\t" "ADC r3, r4, #0x0\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_2048_add_64_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_2048_add_64_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_2048_add_64_word\n\t" #else - "BNE.N L_sp_2048_add_64_word%=\n\t" + "BNE.N L_sp_2048_add_64_word_%=\n\t" #endif "MOV %[r], r3\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -2258,7 +2264,11 @@ static sp_digit sp_2048_sub_in_place_64(sp_digit* a, const sp_digit* b) "MOV r10, #0x0\n\t" "ADD r11, %[a], #0x100\n\t" "\n" - "L_sp_2048_sub_in_pkace_64_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_sub_in_pkace_64_word:\n\t" +#else + "L_sp_2048_sub_in_pkace_64_word_%=:\n\t" +#endif "RSBS r10, r10, #0x0\n\t" "LDM %[a], {r2, r3, r4, r5}\n\t" "LDM %[b]!, {r6, r7, r8, r9}\n\t" @@ -2269,10 +2279,12 @@ static sp_digit sp_2048_sub_in_place_64(sp_digit* a, const sp_digit* b) "STM %[a]!, {r2, r3, r4, r5}\n\t" "SBC r10, r10, r10\n\t" "CMP %[a], r11\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_2048_sub_in_pkace_64_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_2048_sub_in_pkace_64_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_2048_sub_in_pkace_64_word\n\t" #else - "BNE.N L_sp_2048_sub_in_pkace_64_word%=\n\t" + "BNE.N L_sp_2048_sub_in_pkace_64_word_%=\n\t" #endif "MOV %[a], r10\n\t" : [a] "+r" (a), [b] "+r" (b) @@ -2312,13 +2324,21 @@ static void sp_2048_mul_64(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_2048_mul_64_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mul_64_outer:\n\t" +#else + "L_sp_2048_mul_64_outer_%=:\n\t" +#endif "SUBS r3, r5, #0xfc\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_2048_mul_64_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mul_64_inner:\n\t" +#else + "L_sp_2048_mul_64_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -2334,15 +2354,19 @@ static void sp_2048_mul_64(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_2048_mul_64_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_2048_mul_64_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_2048_mul_64_inner_done\n\t" #else - "BGT.N L_sp_2048_mul_64_inner_done%=\n\t" + "BGT.N L_sp_2048_mul_64_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_mul_64_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mul_64_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_mul_64_inner\n\t" #else - "BLT.N L_sp_2048_mul_64_inner%=\n\t" + "BLT.N L_sp_2048_mul_64_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r3]\n\t" @@ -2351,17 +2375,23 @@ static void sp_2048_mul_64(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_2048_mul_64_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mul_64_inner_done:\n\t" +#else + "L_sp_2048_mul_64_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x1f4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_2048_mul_64_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_2048_mul_64_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_2048_mul_64_outer\n\t" #else - "BLE.N L_sp_2048_mul_64_outer%=\n\t" + "BLE.N L_sp_2048_mul_64_outer_%=\n\t" #endif "LDR lr, [%[a], #252]\n\t" "LDR r11, [%[b], #252]\n\t" @@ -2370,14 +2400,20 @@ static void sp_2048_mul_64(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_2048_mul_64_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mul_64_store:\n\t" +#else + "L_sp_2048_mul_64_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_2048_mul_64_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_2048_mul_64_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_2048_mul_64_store\n\t" #else - "BGT.N L_sp_2048_mul_64_store%=\n\t" + "BGT.N L_sp_2048_mul_64_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) : @@ -2410,13 +2446,21 @@ static void sp_2048_sqr_64(sp_digit* r, const sp_digit* a) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_2048_sqr_64_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_sqr_64_outer:\n\t" +#else + "L_sp_2048_sqr_64_outer_%=:\n\t" +#endif "SUBS r3, r5, #0xfc\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_2048_sqr_64_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_sqr_64_inner:\n\t" +#else + "L_sp_2048_sqr_64_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[a], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -2429,15 +2473,19 @@ static void sp_2048_sqr_64(sp_digit* r, const sp_digit* a) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_2048_sqr_64_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_2048_sqr_64_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_2048_sqr_64_inner_done\n\t" #else - "BGT.N L_sp_2048_sqr_64_inner_done%=\n\t" + "BGT.N L_sp_2048_sqr_64_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_sqr_64_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_sqr_64_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_sqr_64_inner\n\t" #else - "BLT.N L_sp_2048_sqr_64_inner%=\n\t" + "BLT.N L_sp_2048_sqr_64_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "UMULL r9, r10, lr, lr\n\t" @@ -2445,17 +2493,23 @@ static void sp_2048_sqr_64(sp_digit* r, const sp_digit* a) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_2048_sqr_64_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_sqr_64_inner_done:\n\t" +#else + "L_sp_2048_sqr_64_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x1f4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_2048_sqr_64_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_2048_sqr_64_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_2048_sqr_64_outer\n\t" #else - "BLE.N L_sp_2048_sqr_64_outer%=\n\t" + "BLE.N L_sp_2048_sqr_64_outer_%=\n\t" #endif "LDR lr, [%[a], #252]\n\t" "UMLAL r6, r7, lr, lr\n\t" @@ -2463,14 +2517,20 @@ static void sp_2048_sqr_64(sp_digit* r, const sp_digit* a) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_2048_sqr_64_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_sqr_64_store:\n\t" +#else + "L_sp_2048_sqr_64_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_2048_sqr_64_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_2048_sqr_64_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_2048_sqr_64_store\n\t" #else - "BGT.N L_sp_2048_sqr_64_store%=\n\t" + "BGT.N L_sp_2048_sqr_64_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a) : @@ -2520,7 +2580,11 @@ static sp_digit sp_2048_add_32(sp_digit* r, const sp_digit* a, const sp_digit* b "MOV r3, #0x0\n\t" "ADD r12, %[a], #0x80\n\t" "\n" - "L_sp_2048_add_32_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_add_32_word:\n\t" +#else + "L_sp_2048_add_32_word_%=:\n\t" +#endif "ADDS r3, r3, #0xffffffff\n\t" "LDM %[a]!, {r4, r5, r6, r7}\n\t" "LDM %[b]!, {r8, r9, r10, r11}\n\t" @@ -2532,10 +2596,12 @@ static sp_digit sp_2048_add_32(sp_digit* r, const sp_digit* a, const sp_digit* b "MOV r4, #0x0\n\t" "ADC r3, r4, #0x0\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_2048_add_32_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_2048_add_32_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_2048_add_32_word\n\t" #else - "BNE.N L_sp_2048_add_32_word%=\n\t" + "BNE.N L_sp_2048_add_32_word_%=\n\t" #endif "MOV %[r], r3\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -2567,7 +2633,11 @@ static sp_digit sp_2048_sub_in_place_32(sp_digit* a, const sp_digit* b) "MOV r10, #0x0\n\t" "ADD r11, %[a], #0x80\n\t" "\n" - "L_sp_2048_sub_in_pkace_32_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_sub_in_pkace_32_word:\n\t" +#else + "L_sp_2048_sub_in_pkace_32_word_%=:\n\t" +#endif "RSBS r10, r10, #0x0\n\t" "LDM %[a], {r2, r3, r4, r5}\n\t" "LDM %[b]!, {r6, r7, r8, r9}\n\t" @@ -2578,10 +2648,12 @@ static sp_digit sp_2048_sub_in_place_32(sp_digit* a, const sp_digit* b) "STM %[a]!, {r2, r3, r4, r5}\n\t" "SBC r10, r10, r10\n\t" "CMP %[a], r11\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_2048_sub_in_pkace_32_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_2048_sub_in_pkace_32_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_2048_sub_in_pkace_32_word\n\t" #else - "BNE.N L_sp_2048_sub_in_pkace_32_word%=\n\t" + "BNE.N L_sp_2048_sub_in_pkace_32_word_%=\n\t" #endif "MOV %[a], r10\n\t" : [a] "+r" (a), [b] "+r" (b) @@ -2621,13 +2693,21 @@ static void sp_2048_mul_32(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_2048_mul_32_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mul_32_outer:\n\t" +#else + "L_sp_2048_mul_32_outer_%=:\n\t" +#endif "SUBS r3, r5, #0x7c\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_2048_mul_32_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mul_32_inner:\n\t" +#else + "L_sp_2048_mul_32_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -2643,15 +2723,19 @@ static void sp_2048_mul_32(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_2048_mul_32_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_2048_mul_32_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_2048_mul_32_inner_done\n\t" #else - "BGT.N L_sp_2048_mul_32_inner_done%=\n\t" + "BGT.N L_sp_2048_mul_32_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_mul_32_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mul_32_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_mul_32_inner\n\t" #else - "BLT.N L_sp_2048_mul_32_inner%=\n\t" + "BLT.N L_sp_2048_mul_32_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r3]\n\t" @@ -2660,17 +2744,23 @@ static void sp_2048_mul_32(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_2048_mul_32_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mul_32_inner_done:\n\t" +#else + "L_sp_2048_mul_32_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0xf4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_2048_mul_32_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_2048_mul_32_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_2048_mul_32_outer\n\t" #else - "BLE.N L_sp_2048_mul_32_outer%=\n\t" + "BLE.N L_sp_2048_mul_32_outer_%=\n\t" #endif "LDR lr, [%[a], #124]\n\t" "LDR r11, [%[b], #124]\n\t" @@ -2679,14 +2769,20 @@ static void sp_2048_mul_32(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_2048_mul_32_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mul_32_store:\n\t" +#else + "L_sp_2048_mul_32_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_2048_mul_32_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_2048_mul_32_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_2048_mul_32_store\n\t" #else - "BGT.N L_sp_2048_mul_32_store%=\n\t" + "BGT.N L_sp_2048_mul_32_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) : @@ -2719,13 +2815,21 @@ static void sp_2048_sqr_32(sp_digit* r, const sp_digit* a) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_2048_sqr_32_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_sqr_32_outer:\n\t" +#else + "L_sp_2048_sqr_32_outer_%=:\n\t" +#endif "SUBS r3, r5, #0x7c\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_2048_sqr_32_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_sqr_32_inner:\n\t" +#else + "L_sp_2048_sqr_32_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[a], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -2738,15 +2842,19 @@ static void sp_2048_sqr_32(sp_digit* r, const sp_digit* a) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_2048_sqr_32_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_2048_sqr_32_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_2048_sqr_32_inner_done\n\t" #else - "BGT.N L_sp_2048_sqr_32_inner_done%=\n\t" + "BGT.N L_sp_2048_sqr_32_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_sqr_32_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_sqr_32_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_sqr_32_inner\n\t" #else - "BLT.N L_sp_2048_sqr_32_inner%=\n\t" + "BLT.N L_sp_2048_sqr_32_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "UMULL r9, r10, lr, lr\n\t" @@ -2754,17 +2862,23 @@ static void sp_2048_sqr_32(sp_digit* r, const sp_digit* a) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_2048_sqr_32_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_sqr_32_inner_done:\n\t" +#else + "L_sp_2048_sqr_32_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0xf4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_2048_sqr_32_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_2048_sqr_32_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_2048_sqr_32_outer\n\t" #else - "BLE.N L_sp_2048_sqr_32_outer%=\n\t" + "BLE.N L_sp_2048_sqr_32_outer_%=\n\t" #endif "LDR lr, [%[a], #124]\n\t" "UMLAL r6, r7, lr, lr\n\t" @@ -2772,14 +2886,20 @@ static void sp_2048_sqr_32(sp_digit* r, const sp_digit* a) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_2048_sqr_32_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_sqr_32_store:\n\t" +#else + "L_sp_2048_sqr_32_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_2048_sqr_32_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_2048_sqr_32_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_2048_sqr_32_store\n\t" #else - "BGT.N L_sp_2048_sqr_32_store%=\n\t" + "BGT.N L_sp_2048_sqr_32_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a) : @@ -2838,7 +2958,11 @@ static void sp_2048_mul_d_64(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "MOV r9, #0x4\n\t" "\n" - "L_sp_2048_mul_d_64_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mul_d_64_word:\n\t" +#else + "L_sp_2048_mul_d_64_word_%=:\n\t" +#endif /* A[i] * B */ "LDR r8, [%[a], r9]\n\t" "UMULL r6, r7, %[b], r8\n\t" @@ -2851,10 +2975,12 @@ static void sp_2048_mul_d_64(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "ADD r9, r9, #0x4\n\t" "CMP r9, #0x100\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_mul_d_64_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mul_d_64_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_mul_d_64_word\n\t" #else - "BLT.N L_sp_2048_mul_d_64_word%=\n\t" + "BLT.N L_sp_2048_mul_d_64_word_%=\n\t" #endif "STR r3, [%[r], #256]\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -3252,7 +3378,11 @@ static sp_digit sp_2048_cond_sub_32(sp_digit* r, const sp_digit* a, const sp_dig "MOV r4, #0x0\n\t" "MOV r5, #0x0\n\t" "\n" - "L_sp_2048_cond_sub_32_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_cond_sub_32_words:\n\t" +#else + "L_sp_2048_cond_sub_32_words_%=:\n\t" +#endif "SUBS r4, r8, r4\n\t" "LDR r6, [%[a], r5]\n\t" "LDR r7, [%[b], r5]\n\t" @@ -3262,10 +3392,12 @@ static sp_digit sp_2048_cond_sub_32(sp_digit* r, const sp_digit* a, const sp_dig "STR r6, [%[r], r5]\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x80\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_cond_sub_32_words%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_cond_sub_32_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_cond_sub_32_words\n\t" #else - "BLT.N L_sp_2048_cond_sub_32_words%=\n\t" + "BLT.N L_sp_2048_cond_sub_32_words_%=\n\t" #endif "MOV %[r], r4\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b), [m] "+r" (m) @@ -3448,7 +3580,11 @@ SP_NOINLINE static void sp_2048_mont_reduce_32(sp_digit* a, const sp_digit* m, s "LDR r4, [%[a]]\n\t" "LDR r5, [%[a], #4]\n\t" "\n" - "L_sp_2048_mont_reduce_32_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mont_reduce_32_word:\n\t" +#else + "L_sp_2048_mont_reduce_32_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL r10, %[mp], r4\n\t" /* a[i+0] += m[0] * mu */ @@ -3710,10 +3846,12 @@ SP_NOINLINE static void sp_2048_mont_reduce_32(sp_digit* a, const sp_digit* m, s "ADD r11, r11, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r11, #0x80\n\t" -#ifdef __GNUC__ - "BLT L_sp_2048_mont_reduce_32_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mont_reduce_32_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_2048_mont_reduce_32_word\n\t" #else - "BLT.W L_sp_2048_mont_reduce_32_word%=\n\t" + "BLT.W L_sp_2048_mont_reduce_32_word_%=\n\t" #endif /* Loop Done */ "STR r4, [%[a]]\n\t" @@ -3752,7 +3890,11 @@ SP_NOINLINE static void sp_2048_mont_reduce_32(sp_digit* a, const sp_digit* m, s /* ca = 0 */ "MOV r3, #0x0\n\t" "\n" - "L_sp_2048_mont_reduce_32_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mont_reduce_32_word:\n\t" +#else + "L_sp_2048_mont_reduce_32_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "LDR r10, [%[a]]\n\t" "MUL r8, %[mp], r10\n\t" @@ -3760,7 +3902,11 @@ SP_NOINLINE static void sp_2048_mont_reduce_32(sp_digit* a, const sp_digit* m, s "MOV r12, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_2048_mont_reduce_32_mul%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mont_reduce_32_mul:\n\t" +#else + "L_sp_2048_mont_reduce_32_mul_%=:\n\t" +#endif /* a[i+j+0] += m[j+0] * mu */ "LDR r7, [%[m], r12]\n\t" "LDR r10, [%[a], r12]\n\t" @@ -3802,10 +3948,12 @@ SP_NOINLINE static void sp_2048_mont_reduce_32(sp_digit* a, const sp_digit* m, s /* j += 1 */ "ADD r12, r12, #0x4\n\t" "CMP r12, #0x80\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_mont_reduce_32_mul%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mont_reduce_32_mul_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_mont_reduce_32_mul\n\t" #else - "BLT.N L_sp_2048_mont_reduce_32_mul%=\n\t" + "BLT.N L_sp_2048_mont_reduce_32_mul_%=\n\t" #endif "LDR r10, [%[a], #128]\n\t" "ADDS r4, r4, r3\n\t" @@ -3818,10 +3966,12 @@ SP_NOINLINE static void sp_2048_mont_reduce_32(sp_digit* a, const sp_digit* m, s "ADD r9, r9, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r9, #0x80\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_mont_reduce_32_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mont_reduce_32_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_mont_reduce_32_word\n\t" #else - "BLT.N L_sp_2048_mont_reduce_32_word%=\n\t" + "BLT.N L_sp_2048_mont_reduce_32_word_%=\n\t" #endif /* Loop Done */ "MOV %[mp], r3\n\t" @@ -3863,7 +4013,11 @@ SP_NOINLINE static void sp_2048_mont_reduce_32(sp_digit* a, const sp_digit* m, s "LDR r9, [%[a], #12]\n\t" "LDR r10, [%[a], #16]\n\t" "\n" - "L_sp_2048_mont_reduce_32_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mont_reduce_32_word:\n\t" +#else + "L_sp_2048_mont_reduce_32_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL lr, %[mp], r6\n\t" /* a[i+0] += m[0] * mu */ @@ -4030,10 +4184,12 @@ SP_NOINLINE static void sp_2048_mont_reduce_32(sp_digit* a, const sp_digit* m, s "ADD r4, r4, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r4, #0x80\n\t" -#ifdef __GNUC__ - "BLT L_sp_2048_mont_reduce_32_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mont_reduce_32_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_2048_mont_reduce_32_word\n\t" #else - "BLT.W L_sp_2048_mont_reduce_32_word%=\n\t" + "BLT.W L_sp_2048_mont_reduce_32_word_%=\n\t" #endif /* Loop Done */ "STR r6, [%[a]]\n\t" @@ -4075,7 +4231,11 @@ SP_NOINLINE static void sp_2048_mont_reduce_32(sp_digit* a, const sp_digit* m, s /* ca = 0 */ "MOV r3, #0x0\n\t" "\n" - "L_sp_2048_mont_reduce_32_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mont_reduce_32_word:\n\t" +#else + "L_sp_2048_mont_reduce_32_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "LDR r10, [%[a]]\n\t" "MUL r8, %[mp], r10\n\t" @@ -4083,7 +4243,11 @@ SP_NOINLINE static void sp_2048_mont_reduce_32(sp_digit* a, const sp_digit* m, s "MOV r12, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_2048_mont_reduce_32_mul%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mont_reduce_32_mul:\n\t" +#else + "L_sp_2048_mont_reduce_32_mul_%=:\n\t" +#endif /* a[i+j+0] += m[j+0] * mu */ "LDR r7, [%[m], r12]\n\t" "LDR r10, [%[a], r12]\n\t" @@ -4113,10 +4277,12 @@ SP_NOINLINE static void sp_2048_mont_reduce_32(sp_digit* a, const sp_digit* m, s /* j += 1 */ "ADD r12, r12, #0x4\n\t" "CMP r12, #0x80\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_mont_reduce_32_mul%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mont_reduce_32_mul_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_mont_reduce_32_mul\n\t" #else - "BLT.N L_sp_2048_mont_reduce_32_mul%=\n\t" + "BLT.N L_sp_2048_mont_reduce_32_mul_%=\n\t" #endif "LDR r10, [%[a], #128]\n\t" "ADDS r4, r4, r3\n\t" @@ -4129,10 +4295,12 @@ SP_NOINLINE static void sp_2048_mont_reduce_32(sp_digit* a, const sp_digit* m, s "ADD r9, r9, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r9, #0x80\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_mont_reduce_32_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mont_reduce_32_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_mont_reduce_32_word\n\t" #else - "BLT.N L_sp_2048_mont_reduce_32_word%=\n\t" + "BLT.N L_sp_2048_mont_reduce_32_word_%=\n\t" #endif /* Loop Done */ "MOV %[mp], r3\n\t" @@ -4203,7 +4371,11 @@ static void sp_2048_mul_d_32(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "MOV r9, #0x4\n\t" "\n" - "L_sp_2048_mul_d_32_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mul_d_32_word:\n\t" +#else + "L_sp_2048_mul_d_32_word_%=:\n\t" +#endif /* A[i] * B */ "LDR r8, [%[a], r9]\n\t" "UMULL r6, r7, %[b], r8\n\t" @@ -4216,10 +4388,12 @@ static void sp_2048_mul_d_32(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "ADD r9, r9, #0x4\n\t" "CMP r9, #0x80\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_mul_d_32_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mul_d_32_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_mul_d_32_word\n\t" #else - "BLT.N L_sp_2048_mul_d_32_word%=\n\t" + "BLT.N L_sp_2048_mul_d_32_word_%=\n\t" #endif "STR r3, [%[r], #128]\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -4517,7 +4691,11 @@ SP_NOINLINE static sp_digit div_2048_word_32(sp_digit d1, sp_digit d0, sp_digit /* Next 30 bits */ "MOV r4, #0x1d\n\t" "\n" - "L_div_2048_word_32_bit%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_div_2048_word_32_bit:\n\t" +#else + "L_div_2048_word_32_bit_%=:\n\t" +#endif "LSLS r6, r6, #1\n\t" "ADC r7, r7, r7\n\t" "SUBS r8, r5, r7\n\t" @@ -4527,7 +4705,13 @@ SP_NOINLINE static sp_digit div_2048_word_32(sp_digit d1, sp_digit d0, sp_digit "AND r8, r8, r5\n\t" "SUBS r7, r7, r8\n\t" "SUBS r4, r4, #0x1\n\t" - "bpl L_div_2048_word_32_bit%=\n\t" +#if defined(__GNUC__) + "BPL L_div_2048_word_32_bit_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BPL.N L_div_2048_word_32_bit\n\t" +#else + "BPL.N L_div_2048_word_32_bit_%=\n\t" +#endif "ADD r3, r3, r3\n\t" "ADD r3, r3, #0x1\n\t" "UMULL r6, r7, r3, %[div]\n\t" @@ -4579,7 +4763,11 @@ static sp_int32 sp_2048_cmp_32(const sp_digit* a, const sp_digit* b) #ifdef WOLFSSL_SP_SMALL "MOV r6, #0x7c\n\t" "\n" - "L_sp_2048_cmp_32_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_cmp_32_words:\n\t" +#else + "L_sp_2048_cmp_32_words_%=:\n\t" +#endif "LDR r4, [%[a], r6]\n\t" "LDR r5, [%[b], r6]\n\t" "AND r4, r4, r3\n\t" @@ -4592,7 +4780,7 @@ static sp_int32 sp_2048_cmp_32(const sp_digit* a, const sp_digit* b) "IT ne\n\t" "movne r3, r7\n\t" "SUBS r6, r6, #0x4\n\t" - "bcs L_sp_2048_cmp_32_words%=\n\t" + "bcs L_sp_2048_cmp_32_words\n\t" "EOR r2, r2, r3\n\t" #else "LDR r4, [%[a], #124]\n\t" @@ -5380,7 +5568,11 @@ static sp_digit sp_2048_cond_sub_64(sp_digit* r, const sp_digit* a, const sp_dig "MOV r4, #0x0\n\t" "MOV r5, #0x0\n\t" "\n" - "L_sp_2048_cond_sub_64_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_cond_sub_64_words:\n\t" +#else + "L_sp_2048_cond_sub_64_words_%=:\n\t" +#endif "SUBS r4, r8, r4\n\t" "LDR r6, [%[a], r5]\n\t" "LDR r7, [%[b], r5]\n\t" @@ -5390,10 +5582,12 @@ static sp_digit sp_2048_cond_sub_64(sp_digit* r, const sp_digit* a, const sp_dig "STR r6, [%[r], r5]\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x100\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_cond_sub_64_words%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_cond_sub_64_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_cond_sub_64_words\n\t" #else - "BLT.N L_sp_2048_cond_sub_64_words%=\n\t" + "BLT.N L_sp_2048_cond_sub_64_words_%=\n\t" #endif "MOV %[r], r4\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b), [m] "+r" (m) @@ -5688,7 +5882,11 @@ SP_NOINLINE static void sp_2048_mont_reduce_64(sp_digit* a, const sp_digit* m, s "LDR r4, [%[a]]\n\t" "LDR r5, [%[a], #4]\n\t" "\n" - "L_sp_2048_mont_reduce_64_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mont_reduce_64_word:\n\t" +#else + "L_sp_2048_mont_reduce_64_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL r10, %[mp], r4\n\t" /* a[i+0] += m[0] * mu */ @@ -6206,10 +6404,12 @@ SP_NOINLINE static void sp_2048_mont_reduce_64(sp_digit* a, const sp_digit* m, s "ADD r11, r11, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r11, #0x100\n\t" -#ifdef __GNUC__ - "BLT L_sp_2048_mont_reduce_64_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mont_reduce_64_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_2048_mont_reduce_64_word\n\t" #else - "BLT.W L_sp_2048_mont_reduce_64_word%=\n\t" + "BLT.W L_sp_2048_mont_reduce_64_word_%=\n\t" #endif /* Loop Done */ "STR r4, [%[a]]\n\t" @@ -6248,7 +6448,11 @@ SP_NOINLINE static void sp_2048_mont_reduce_64(sp_digit* a, const sp_digit* m, s /* ca = 0 */ "MOV r3, #0x0\n\t" "\n" - "L_sp_2048_mont_reduce_64_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mont_reduce_64_word:\n\t" +#else + "L_sp_2048_mont_reduce_64_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "LDR r10, [%[a]]\n\t" "MUL r8, %[mp], r10\n\t" @@ -6256,7 +6460,11 @@ SP_NOINLINE static void sp_2048_mont_reduce_64(sp_digit* a, const sp_digit* m, s "MOV r12, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_2048_mont_reduce_64_mul%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mont_reduce_64_mul:\n\t" +#else + "L_sp_2048_mont_reduce_64_mul_%=:\n\t" +#endif /* a[i+j+0] += m[j+0] * mu */ "LDR r7, [%[m], r12]\n\t" "LDR r10, [%[a], r12]\n\t" @@ -6298,10 +6506,12 @@ SP_NOINLINE static void sp_2048_mont_reduce_64(sp_digit* a, const sp_digit* m, s /* j += 1 */ "ADD r12, r12, #0x4\n\t" "CMP r12, #0x100\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_mont_reduce_64_mul%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mont_reduce_64_mul_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_mont_reduce_64_mul\n\t" #else - "BLT.N L_sp_2048_mont_reduce_64_mul%=\n\t" + "BLT.N L_sp_2048_mont_reduce_64_mul_%=\n\t" #endif "LDR r10, [%[a], #256]\n\t" "ADDS r4, r4, r3\n\t" @@ -6314,10 +6524,12 @@ SP_NOINLINE static void sp_2048_mont_reduce_64(sp_digit* a, const sp_digit* m, s "ADD r9, r9, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r9, #0x100\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_mont_reduce_64_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mont_reduce_64_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_mont_reduce_64_word\n\t" #else - "BLT.N L_sp_2048_mont_reduce_64_word%=\n\t" + "BLT.N L_sp_2048_mont_reduce_64_word_%=\n\t" #endif /* Loop Done */ "MOV %[mp], r3\n\t" @@ -6359,7 +6571,11 @@ SP_NOINLINE static void sp_2048_mont_reduce_64(sp_digit* a, const sp_digit* m, s "LDR r9, [%[a], #12]\n\t" "LDR r10, [%[a], #16]\n\t" "\n" - "L_sp_2048_mont_reduce_64_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mont_reduce_64_word:\n\t" +#else + "L_sp_2048_mont_reduce_64_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL lr, %[mp], r6\n\t" /* a[i+0] += m[0] * mu */ @@ -6686,10 +6902,12 @@ SP_NOINLINE static void sp_2048_mont_reduce_64(sp_digit* a, const sp_digit* m, s "ADD r4, r4, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r4, #0x100\n\t" -#ifdef __GNUC__ - "BLT L_sp_2048_mont_reduce_64_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mont_reduce_64_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_2048_mont_reduce_64_word\n\t" #else - "BLT.W L_sp_2048_mont_reduce_64_word%=\n\t" + "BLT.W L_sp_2048_mont_reduce_64_word_%=\n\t" #endif /* Loop Done */ "STR r6, [%[a]]\n\t" @@ -6731,7 +6949,11 @@ SP_NOINLINE static void sp_2048_mont_reduce_64(sp_digit* a, const sp_digit* m, s /* ca = 0 */ "MOV r3, #0x0\n\t" "\n" - "L_sp_2048_mont_reduce_64_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mont_reduce_64_word:\n\t" +#else + "L_sp_2048_mont_reduce_64_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "LDR r10, [%[a]]\n\t" "MUL r8, %[mp], r10\n\t" @@ -6739,7 +6961,11 @@ SP_NOINLINE static void sp_2048_mont_reduce_64(sp_digit* a, const sp_digit* m, s "MOV r12, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_2048_mont_reduce_64_mul%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_mont_reduce_64_mul:\n\t" +#else + "L_sp_2048_mont_reduce_64_mul_%=:\n\t" +#endif /* a[i+j+0] += m[j+0] * mu */ "LDR r7, [%[m], r12]\n\t" "LDR r10, [%[a], r12]\n\t" @@ -6769,10 +6995,12 @@ SP_NOINLINE static void sp_2048_mont_reduce_64(sp_digit* a, const sp_digit* m, s /* j += 1 */ "ADD r12, r12, #0x4\n\t" "CMP r12, #0x100\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_mont_reduce_64_mul%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mont_reduce_64_mul_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_mont_reduce_64_mul\n\t" #else - "BLT.N L_sp_2048_mont_reduce_64_mul%=\n\t" + "BLT.N L_sp_2048_mont_reduce_64_mul_%=\n\t" #endif "LDR r10, [%[a], #256]\n\t" "ADDS r4, r4, r3\n\t" @@ -6785,10 +7013,12 @@ SP_NOINLINE static void sp_2048_mont_reduce_64(sp_digit* a, const sp_digit* m, s "ADD r9, r9, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r9, #0x100\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_mont_reduce_64_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_mont_reduce_64_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_mont_reduce_64_word\n\t" #else - "BLT.N L_sp_2048_mont_reduce_64_word%=\n\t" + "BLT.N L_sp_2048_mont_reduce_64_word_%=\n\t" #endif /* Loop Done */ "MOV %[mp], r3\n\t" @@ -6854,7 +7084,11 @@ static sp_digit sp_2048_sub_64(sp_digit* r, const sp_digit* a, const sp_digit* b "MOV r11, #0x0\n\t" "ADD r12, %[a], #0x100\n\t" "\n" - "L_sp_2048_sub_64_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_sub_64_word:\n\t" +#else + "L_sp_2048_sub_64_word_%=:\n\t" +#endif "RSBS r11, r11, #0x0\n\t" "LDM %[a]!, {r3, r4, r5, r6}\n\t" "LDM %[b]!, {r7, r8, r9, r10}\n\t" @@ -6865,10 +7099,12 @@ static sp_digit sp_2048_sub_64(sp_digit* r, const sp_digit* a, const sp_digit* b "STM %[r]!, {r3, r4, r5, r6}\n\t" "SBC r11, r3, r3\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_2048_sub_64_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_2048_sub_64_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_2048_sub_64_word\n\t" #else - "BNE.N L_sp_2048_sub_64_word%=\n\t" + "BNE.N L_sp_2048_sub_64_word_%=\n\t" #endif "MOV %[r], r11\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -7121,7 +7357,11 @@ SP_NOINLINE static sp_digit div_2048_word_64(sp_digit d1, sp_digit d0, sp_digit /* Next 30 bits */ "MOV r4, #0x1d\n\t" "\n" - "L_div_2048_word_64_bit%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_div_2048_word_64_bit:\n\t" +#else + "L_div_2048_word_64_bit_%=:\n\t" +#endif "LSLS r6, r6, #1\n\t" "ADC r7, r7, r7\n\t" "SUBS r8, r5, r7\n\t" @@ -7131,7 +7371,13 @@ SP_NOINLINE static sp_digit div_2048_word_64(sp_digit d1, sp_digit d0, sp_digit "AND r8, r8, r5\n\t" "SUBS r7, r7, r8\n\t" "SUBS r4, r4, #0x1\n\t" - "bpl L_div_2048_word_64_bit%=\n\t" +#if defined(__GNUC__) + "BPL L_div_2048_word_64_bit_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BPL.N L_div_2048_word_64_bit\n\t" +#else + "BPL.N L_div_2048_word_64_bit_%=\n\t" +#endif "ADD r3, r3, r3\n\t" "ADD r3, r3, #0x1\n\t" "UMULL r6, r7, r3, %[div]\n\t" @@ -7286,7 +7532,11 @@ static sp_int32 sp_2048_cmp_64(const sp_digit* a, const sp_digit* b) #ifdef WOLFSSL_SP_SMALL "MOV r6, #0xfc\n\t" "\n" - "L_sp_2048_cmp_64_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_cmp_64_words:\n\t" +#else + "L_sp_2048_cmp_64_words_%=:\n\t" +#endif "LDR r4, [%[a], r6]\n\t" "LDR r5, [%[b], r6]\n\t" "AND r4, r4, r3\n\t" @@ -7299,7 +7549,7 @@ static sp_int32 sp_2048_cmp_64(const sp_digit* a, const sp_digit* b) "IT ne\n\t" "movne r3, r7\n\t" "SUBS r6, r6, #0x4\n\t" - "bcs L_sp_2048_cmp_64_words%=\n\t" + "bcs L_sp_2048_cmp_64_words\n\t" "EOR r2, r2, r3\n\t" #else "LDR r4, [%[a], #252]\n\t" @@ -8562,7 +8812,11 @@ static sp_digit sp_2048_cond_add_32(sp_digit* r, const sp_digit* a, const sp_dig "MOV r8, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_2048_cond_add_32_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_2048_cond_add_32_words:\n\t" +#else + "L_sp_2048_cond_add_32_words_%=:\n\t" +#endif "ADDS r5, r5, #0xffffffff\n\t" "LDR r6, [%[a], r4]\n\t" "LDR r7, [%[b], r4]\n\t" @@ -8572,10 +8826,12 @@ static sp_digit sp_2048_cond_add_32(sp_digit* r, const sp_digit* a, const sp_dig "STR r6, [%[r], r4]\n\t" "ADD r4, r4, #0x4\n\t" "CMP r4, #0x80\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_2048_cond_add_32_words%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_2048_cond_add_32_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_2048_cond_add_32_words\n\t" #else - "BLT.N L_sp_2048_cond_add_32_words%=\n\t" + "BLT.N L_sp_2048_cond_add_32_words_%=\n\t" #endif "MOV %[r], r5\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b), [m] "+r" (m) @@ -12948,7 +13204,11 @@ static sp_digit sp_3072_add_96(sp_digit* r, const sp_digit* a, const sp_digit* b "MOV r3, #0x0\n\t" "ADD r12, %[a], #0x180\n\t" "\n" - "L_sp_3072_add_96_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_add_96_word:\n\t" +#else + "L_sp_3072_add_96_word_%=:\n\t" +#endif "ADDS r3, r3, #0xffffffff\n\t" "LDM %[a]!, {r4, r5, r6, r7}\n\t" "LDM %[b]!, {r8, r9, r10, r11}\n\t" @@ -12960,10 +13220,12 @@ static sp_digit sp_3072_add_96(sp_digit* r, const sp_digit* a, const sp_digit* b "MOV r4, #0x0\n\t" "ADC r3, r4, #0x0\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_3072_add_96_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_3072_add_96_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_3072_add_96_word\n\t" #else - "BNE.N L_sp_3072_add_96_word%=\n\t" + "BNE.N L_sp_3072_add_96_word_%=\n\t" #endif "MOV %[r], r3\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -12995,7 +13257,11 @@ static sp_digit sp_3072_sub_in_place_96(sp_digit* a, const sp_digit* b) "MOV r10, #0x0\n\t" "ADD r11, %[a], #0x180\n\t" "\n" - "L_sp_3072_sub_in_pkace_96_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_sub_in_pkace_96_word:\n\t" +#else + "L_sp_3072_sub_in_pkace_96_word_%=:\n\t" +#endif "RSBS r10, r10, #0x0\n\t" "LDM %[a], {r2, r3, r4, r5}\n\t" "LDM %[b]!, {r6, r7, r8, r9}\n\t" @@ -13006,10 +13272,12 @@ static sp_digit sp_3072_sub_in_place_96(sp_digit* a, const sp_digit* b) "STM %[a]!, {r2, r3, r4, r5}\n\t" "SBC r10, r10, r10\n\t" "CMP %[a], r11\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_3072_sub_in_pkace_96_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_3072_sub_in_pkace_96_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_3072_sub_in_pkace_96_word\n\t" #else - "BNE.N L_sp_3072_sub_in_pkace_96_word%=\n\t" + "BNE.N L_sp_3072_sub_in_pkace_96_word_%=\n\t" #endif "MOV %[a], r10\n\t" : [a] "+r" (a), [b] "+r" (b) @@ -13049,13 +13317,21 @@ static void sp_3072_mul_96(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_3072_mul_96_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mul_96_outer:\n\t" +#else + "L_sp_3072_mul_96_outer_%=:\n\t" +#endif "SUBS r3, r5, #0x17c\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_3072_mul_96_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mul_96_inner:\n\t" +#else + "L_sp_3072_mul_96_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -13071,15 +13347,19 @@ static void sp_3072_mul_96(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_3072_mul_96_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_3072_mul_96_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_3072_mul_96_inner_done\n\t" #else - "BGT.N L_sp_3072_mul_96_inner_done%=\n\t" + "BGT.N L_sp_3072_mul_96_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_mul_96_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mul_96_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_mul_96_inner\n\t" #else - "BLT.N L_sp_3072_mul_96_inner%=\n\t" + "BLT.N L_sp_3072_mul_96_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r3]\n\t" @@ -13088,17 +13368,23 @@ static void sp_3072_mul_96(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_3072_mul_96_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mul_96_inner_done:\n\t" +#else + "L_sp_3072_mul_96_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x2f4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_3072_mul_96_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_3072_mul_96_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_3072_mul_96_outer\n\t" #else - "BLE.N L_sp_3072_mul_96_outer%=\n\t" + "BLE.N L_sp_3072_mul_96_outer_%=\n\t" #endif "LDR lr, [%[a], #380]\n\t" "LDR r11, [%[b], #380]\n\t" @@ -13107,14 +13393,20 @@ static void sp_3072_mul_96(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_3072_mul_96_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mul_96_store:\n\t" +#else + "L_sp_3072_mul_96_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_3072_mul_96_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_3072_mul_96_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_3072_mul_96_store\n\t" #else - "BGT.N L_sp_3072_mul_96_store%=\n\t" + "BGT.N L_sp_3072_mul_96_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) : @@ -13147,13 +13439,21 @@ static void sp_3072_sqr_96(sp_digit* r, const sp_digit* a) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_3072_sqr_96_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_sqr_96_outer:\n\t" +#else + "L_sp_3072_sqr_96_outer_%=:\n\t" +#endif "SUBS r3, r5, #0x17c\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_3072_sqr_96_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_sqr_96_inner:\n\t" +#else + "L_sp_3072_sqr_96_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[a], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -13166,15 +13466,19 @@ static void sp_3072_sqr_96(sp_digit* r, const sp_digit* a) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_3072_sqr_96_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_3072_sqr_96_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_3072_sqr_96_inner_done\n\t" #else - "BGT.N L_sp_3072_sqr_96_inner_done%=\n\t" + "BGT.N L_sp_3072_sqr_96_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_sqr_96_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_sqr_96_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_sqr_96_inner\n\t" #else - "BLT.N L_sp_3072_sqr_96_inner%=\n\t" + "BLT.N L_sp_3072_sqr_96_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "UMULL r9, r10, lr, lr\n\t" @@ -13182,17 +13486,23 @@ static void sp_3072_sqr_96(sp_digit* r, const sp_digit* a) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_3072_sqr_96_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_sqr_96_inner_done:\n\t" +#else + "L_sp_3072_sqr_96_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x2f4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_3072_sqr_96_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_3072_sqr_96_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_3072_sqr_96_outer\n\t" #else - "BLE.N L_sp_3072_sqr_96_outer%=\n\t" + "BLE.N L_sp_3072_sqr_96_outer_%=\n\t" #endif "LDR lr, [%[a], #380]\n\t" "UMLAL r6, r7, lr, lr\n\t" @@ -13200,14 +13510,20 @@ static void sp_3072_sqr_96(sp_digit* r, const sp_digit* a) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_3072_sqr_96_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_sqr_96_store:\n\t" +#else + "L_sp_3072_sqr_96_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_3072_sqr_96_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_3072_sqr_96_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_3072_sqr_96_store\n\t" #else - "BGT.N L_sp_3072_sqr_96_store%=\n\t" + "BGT.N L_sp_3072_sqr_96_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a) : @@ -13257,7 +13573,11 @@ static sp_digit sp_3072_add_48(sp_digit* r, const sp_digit* a, const sp_digit* b "MOV r3, #0x0\n\t" "ADD r12, %[a], #0xc0\n\t" "\n" - "L_sp_3072_add_48_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_add_48_word:\n\t" +#else + "L_sp_3072_add_48_word_%=:\n\t" +#endif "ADDS r3, r3, #0xffffffff\n\t" "LDM %[a]!, {r4, r5, r6, r7}\n\t" "LDM %[b]!, {r8, r9, r10, r11}\n\t" @@ -13269,10 +13589,12 @@ static sp_digit sp_3072_add_48(sp_digit* r, const sp_digit* a, const sp_digit* b "MOV r4, #0x0\n\t" "ADC r3, r4, #0x0\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_3072_add_48_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_3072_add_48_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_3072_add_48_word\n\t" #else - "BNE.N L_sp_3072_add_48_word%=\n\t" + "BNE.N L_sp_3072_add_48_word_%=\n\t" #endif "MOV %[r], r3\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -13304,7 +13626,11 @@ static sp_digit sp_3072_sub_in_place_48(sp_digit* a, const sp_digit* b) "MOV r10, #0x0\n\t" "ADD r11, %[a], #0xc0\n\t" "\n" - "L_sp_3072_sub_in_pkace_48_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_sub_in_pkace_48_word:\n\t" +#else + "L_sp_3072_sub_in_pkace_48_word_%=:\n\t" +#endif "RSBS r10, r10, #0x0\n\t" "LDM %[a], {r2, r3, r4, r5}\n\t" "LDM %[b]!, {r6, r7, r8, r9}\n\t" @@ -13315,10 +13641,12 @@ static sp_digit sp_3072_sub_in_place_48(sp_digit* a, const sp_digit* b) "STM %[a]!, {r2, r3, r4, r5}\n\t" "SBC r10, r10, r10\n\t" "CMP %[a], r11\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_3072_sub_in_pkace_48_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_3072_sub_in_pkace_48_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_3072_sub_in_pkace_48_word\n\t" #else - "BNE.N L_sp_3072_sub_in_pkace_48_word%=\n\t" + "BNE.N L_sp_3072_sub_in_pkace_48_word_%=\n\t" #endif "MOV %[a], r10\n\t" : [a] "+r" (a), [b] "+r" (b) @@ -13358,13 +13686,21 @@ static void sp_3072_mul_48(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_3072_mul_48_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mul_48_outer:\n\t" +#else + "L_sp_3072_mul_48_outer_%=:\n\t" +#endif "SUBS r3, r5, #0xbc\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_3072_mul_48_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mul_48_inner:\n\t" +#else + "L_sp_3072_mul_48_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -13380,15 +13716,19 @@ static void sp_3072_mul_48(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_3072_mul_48_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_3072_mul_48_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_3072_mul_48_inner_done\n\t" #else - "BGT.N L_sp_3072_mul_48_inner_done%=\n\t" + "BGT.N L_sp_3072_mul_48_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_mul_48_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mul_48_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_mul_48_inner\n\t" #else - "BLT.N L_sp_3072_mul_48_inner%=\n\t" + "BLT.N L_sp_3072_mul_48_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r3]\n\t" @@ -13397,17 +13737,23 @@ static void sp_3072_mul_48(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_3072_mul_48_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mul_48_inner_done:\n\t" +#else + "L_sp_3072_mul_48_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x174\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_3072_mul_48_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_3072_mul_48_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_3072_mul_48_outer\n\t" #else - "BLE.N L_sp_3072_mul_48_outer%=\n\t" + "BLE.N L_sp_3072_mul_48_outer_%=\n\t" #endif "LDR lr, [%[a], #188]\n\t" "LDR r11, [%[b], #188]\n\t" @@ -13416,14 +13762,20 @@ static void sp_3072_mul_48(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_3072_mul_48_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mul_48_store:\n\t" +#else + "L_sp_3072_mul_48_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_3072_mul_48_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_3072_mul_48_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_3072_mul_48_store\n\t" #else - "BGT.N L_sp_3072_mul_48_store%=\n\t" + "BGT.N L_sp_3072_mul_48_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) : @@ -13456,13 +13808,21 @@ static void sp_3072_sqr_48(sp_digit* r, const sp_digit* a) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_3072_sqr_48_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_sqr_48_outer:\n\t" +#else + "L_sp_3072_sqr_48_outer_%=:\n\t" +#endif "SUBS r3, r5, #0xbc\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_3072_sqr_48_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_sqr_48_inner:\n\t" +#else + "L_sp_3072_sqr_48_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[a], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -13475,15 +13835,19 @@ static void sp_3072_sqr_48(sp_digit* r, const sp_digit* a) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_3072_sqr_48_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_3072_sqr_48_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_3072_sqr_48_inner_done\n\t" #else - "BGT.N L_sp_3072_sqr_48_inner_done%=\n\t" + "BGT.N L_sp_3072_sqr_48_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_sqr_48_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_sqr_48_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_sqr_48_inner\n\t" #else - "BLT.N L_sp_3072_sqr_48_inner%=\n\t" + "BLT.N L_sp_3072_sqr_48_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "UMULL r9, r10, lr, lr\n\t" @@ -13491,17 +13855,23 @@ static void sp_3072_sqr_48(sp_digit* r, const sp_digit* a) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_3072_sqr_48_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_sqr_48_inner_done:\n\t" +#else + "L_sp_3072_sqr_48_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x174\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_3072_sqr_48_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_3072_sqr_48_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_3072_sqr_48_outer\n\t" #else - "BLE.N L_sp_3072_sqr_48_outer%=\n\t" + "BLE.N L_sp_3072_sqr_48_outer_%=\n\t" #endif "LDR lr, [%[a], #188]\n\t" "UMLAL r6, r7, lr, lr\n\t" @@ -13509,14 +13879,20 @@ static void sp_3072_sqr_48(sp_digit* r, const sp_digit* a) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_3072_sqr_48_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_sqr_48_store:\n\t" +#else + "L_sp_3072_sqr_48_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_3072_sqr_48_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_3072_sqr_48_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_3072_sqr_48_store\n\t" #else - "BGT.N L_sp_3072_sqr_48_store%=\n\t" + "BGT.N L_sp_3072_sqr_48_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a) : @@ -13575,7 +13951,11 @@ static void sp_3072_mul_d_96(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "MOV r9, #0x4\n\t" "\n" - "L_sp_3072_mul_d_96_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mul_d_96_word:\n\t" +#else + "L_sp_3072_mul_d_96_word_%=:\n\t" +#endif /* A[i] * B */ "LDR r8, [%[a], r9]\n\t" "UMULL r6, r7, %[b], r8\n\t" @@ -13588,10 +13968,12 @@ static void sp_3072_mul_d_96(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "ADD r9, r9, #0x4\n\t" "CMP r9, #0x180\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_mul_d_96_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mul_d_96_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_mul_d_96_word\n\t" #else - "BLT.N L_sp_3072_mul_d_96_word%=\n\t" + "BLT.N L_sp_3072_mul_d_96_word_%=\n\t" #endif "STR r3, [%[r], #384]\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -14149,7 +14531,11 @@ static sp_digit sp_3072_cond_sub_48(sp_digit* r, const sp_digit* a, const sp_dig "MOV r4, #0x0\n\t" "MOV r5, #0x0\n\t" "\n" - "L_sp_3072_cond_sub_48_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_cond_sub_48_words:\n\t" +#else + "L_sp_3072_cond_sub_48_words_%=:\n\t" +#endif "SUBS r4, r8, r4\n\t" "LDR r6, [%[a], r5]\n\t" "LDR r7, [%[b], r5]\n\t" @@ -14159,10 +14545,12 @@ static sp_digit sp_3072_cond_sub_48(sp_digit* r, const sp_digit* a, const sp_dig "STR r6, [%[r], r5]\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0xc0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_cond_sub_48_words%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_cond_sub_48_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_cond_sub_48_words\n\t" #else - "BLT.N L_sp_3072_cond_sub_48_words%=\n\t" + "BLT.N L_sp_3072_cond_sub_48_words_%=\n\t" #endif "MOV %[r], r4\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b), [m] "+r" (m) @@ -14401,7 +14789,11 @@ SP_NOINLINE static void sp_3072_mont_reduce_48(sp_digit* a, const sp_digit* m, s "LDR r4, [%[a]]\n\t" "LDR r5, [%[a], #4]\n\t" "\n" - "L_sp_3072_mont_reduce_48_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mont_reduce_48_word:\n\t" +#else + "L_sp_3072_mont_reduce_48_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL r10, %[mp], r4\n\t" /* a[i+0] += m[0] * mu */ @@ -14791,10 +15183,12 @@ SP_NOINLINE static void sp_3072_mont_reduce_48(sp_digit* a, const sp_digit* m, s "ADD r11, r11, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r11, #0xc0\n\t" -#ifdef __GNUC__ - "BLT L_sp_3072_mont_reduce_48_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mont_reduce_48_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_3072_mont_reduce_48_word\n\t" #else - "BLT.W L_sp_3072_mont_reduce_48_word%=\n\t" + "BLT.W L_sp_3072_mont_reduce_48_word_%=\n\t" #endif /* Loop Done */ "STR r4, [%[a]]\n\t" @@ -14833,7 +15227,11 @@ SP_NOINLINE static void sp_3072_mont_reduce_48(sp_digit* a, const sp_digit* m, s /* ca = 0 */ "MOV r3, #0x0\n\t" "\n" - "L_sp_3072_mont_reduce_48_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mont_reduce_48_word:\n\t" +#else + "L_sp_3072_mont_reduce_48_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "LDR r10, [%[a]]\n\t" "MUL r8, %[mp], r10\n\t" @@ -14841,7 +15239,11 @@ SP_NOINLINE static void sp_3072_mont_reduce_48(sp_digit* a, const sp_digit* m, s "MOV r12, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_3072_mont_reduce_48_mul%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mont_reduce_48_mul:\n\t" +#else + "L_sp_3072_mont_reduce_48_mul_%=:\n\t" +#endif /* a[i+j+0] += m[j+0] * mu */ "LDR r7, [%[m], r12]\n\t" "LDR r10, [%[a], r12]\n\t" @@ -14883,10 +15285,12 @@ SP_NOINLINE static void sp_3072_mont_reduce_48(sp_digit* a, const sp_digit* m, s /* j += 1 */ "ADD r12, r12, #0x4\n\t" "CMP r12, #0xc0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_mont_reduce_48_mul%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mont_reduce_48_mul_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_mont_reduce_48_mul\n\t" #else - "BLT.N L_sp_3072_mont_reduce_48_mul%=\n\t" + "BLT.N L_sp_3072_mont_reduce_48_mul_%=\n\t" #endif "LDR r10, [%[a], #192]\n\t" "ADDS r4, r4, r3\n\t" @@ -14899,10 +15303,12 @@ SP_NOINLINE static void sp_3072_mont_reduce_48(sp_digit* a, const sp_digit* m, s "ADD r9, r9, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r9, #0xc0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_mont_reduce_48_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mont_reduce_48_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_mont_reduce_48_word\n\t" #else - "BLT.N L_sp_3072_mont_reduce_48_word%=\n\t" + "BLT.N L_sp_3072_mont_reduce_48_word_%=\n\t" #endif /* Loop Done */ "MOV %[mp], r3\n\t" @@ -14944,7 +15350,11 @@ SP_NOINLINE static void sp_3072_mont_reduce_48(sp_digit* a, const sp_digit* m, s "LDR r9, [%[a], #12]\n\t" "LDR r10, [%[a], #16]\n\t" "\n" - "L_sp_3072_mont_reduce_48_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mont_reduce_48_word:\n\t" +#else + "L_sp_3072_mont_reduce_48_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL lr, %[mp], r6\n\t" /* a[i+0] += m[0] * mu */ @@ -15191,10 +15601,12 @@ SP_NOINLINE static void sp_3072_mont_reduce_48(sp_digit* a, const sp_digit* m, s "ADD r4, r4, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r4, #0xc0\n\t" -#ifdef __GNUC__ - "BLT L_sp_3072_mont_reduce_48_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mont_reduce_48_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_3072_mont_reduce_48_word\n\t" #else - "BLT.W L_sp_3072_mont_reduce_48_word%=\n\t" + "BLT.W L_sp_3072_mont_reduce_48_word_%=\n\t" #endif /* Loop Done */ "STR r6, [%[a]]\n\t" @@ -15236,7 +15648,11 @@ SP_NOINLINE static void sp_3072_mont_reduce_48(sp_digit* a, const sp_digit* m, s /* ca = 0 */ "MOV r3, #0x0\n\t" "\n" - "L_sp_3072_mont_reduce_48_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mont_reduce_48_word:\n\t" +#else + "L_sp_3072_mont_reduce_48_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "LDR r10, [%[a]]\n\t" "MUL r8, %[mp], r10\n\t" @@ -15244,7 +15660,11 @@ SP_NOINLINE static void sp_3072_mont_reduce_48(sp_digit* a, const sp_digit* m, s "MOV r12, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_3072_mont_reduce_48_mul%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mont_reduce_48_mul:\n\t" +#else + "L_sp_3072_mont_reduce_48_mul_%=:\n\t" +#endif /* a[i+j+0] += m[j+0] * mu */ "LDR r7, [%[m], r12]\n\t" "LDR r10, [%[a], r12]\n\t" @@ -15274,10 +15694,12 @@ SP_NOINLINE static void sp_3072_mont_reduce_48(sp_digit* a, const sp_digit* m, s /* j += 1 */ "ADD r12, r12, #0x4\n\t" "CMP r12, #0xc0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_mont_reduce_48_mul%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mont_reduce_48_mul_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_mont_reduce_48_mul\n\t" #else - "BLT.N L_sp_3072_mont_reduce_48_mul%=\n\t" + "BLT.N L_sp_3072_mont_reduce_48_mul_%=\n\t" #endif "LDR r10, [%[a], #192]\n\t" "ADDS r4, r4, r3\n\t" @@ -15290,10 +15712,12 @@ SP_NOINLINE static void sp_3072_mont_reduce_48(sp_digit* a, const sp_digit* m, s "ADD r9, r9, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r9, #0xc0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_mont_reduce_48_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mont_reduce_48_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_mont_reduce_48_word\n\t" #else - "BLT.N L_sp_3072_mont_reduce_48_word%=\n\t" + "BLT.N L_sp_3072_mont_reduce_48_word_%=\n\t" #endif /* Loop Done */ "MOV %[mp], r3\n\t" @@ -15364,7 +15788,11 @@ static void sp_3072_mul_d_48(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "MOV r9, #0x4\n\t" "\n" - "L_sp_3072_mul_d_48_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mul_d_48_word:\n\t" +#else + "L_sp_3072_mul_d_48_word_%=:\n\t" +#endif /* A[i] * B */ "LDR r8, [%[a], r9]\n\t" "UMULL r6, r7, %[b], r8\n\t" @@ -15377,10 +15805,12 @@ static void sp_3072_mul_d_48(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "ADD r9, r9, #0x4\n\t" "CMP r9, #0xc0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_mul_d_48_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mul_d_48_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_mul_d_48_word\n\t" #else - "BLT.N L_sp_3072_mul_d_48_word%=\n\t" + "BLT.N L_sp_3072_mul_d_48_word_%=\n\t" #endif "STR r3, [%[r], #192]\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -15758,7 +16188,11 @@ SP_NOINLINE static sp_digit div_3072_word_48(sp_digit d1, sp_digit d0, sp_digit /* Next 30 bits */ "MOV r4, #0x1d\n\t" "\n" - "L_div_3072_word_48_bit%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_div_3072_word_48_bit:\n\t" +#else + "L_div_3072_word_48_bit_%=:\n\t" +#endif "LSLS r6, r6, #1\n\t" "ADC r7, r7, r7\n\t" "SUBS r8, r5, r7\n\t" @@ -15768,7 +16202,13 @@ SP_NOINLINE static sp_digit div_3072_word_48(sp_digit d1, sp_digit d0, sp_digit "AND r8, r8, r5\n\t" "SUBS r7, r7, r8\n\t" "SUBS r4, r4, #0x1\n\t" - "bpl L_div_3072_word_48_bit%=\n\t" +#if defined(__GNUC__) + "BPL L_div_3072_word_48_bit_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BPL.N L_div_3072_word_48_bit\n\t" +#else + "BPL.N L_div_3072_word_48_bit_%=\n\t" +#endif "ADD r3, r3, r3\n\t" "ADD r3, r3, #0x1\n\t" "UMULL r6, r7, r3, %[div]\n\t" @@ -15820,7 +16260,11 @@ static sp_int32 sp_3072_cmp_48(const sp_digit* a, const sp_digit* b) #ifdef WOLFSSL_SP_SMALL "MOV r6, #0xbc\n\t" "\n" - "L_sp_3072_cmp_48_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_cmp_48_words:\n\t" +#else + "L_sp_3072_cmp_48_words_%=:\n\t" +#endif "LDR r4, [%[a], r6]\n\t" "LDR r5, [%[b], r6]\n\t" "AND r4, r4, r3\n\t" @@ -15833,7 +16277,7 @@ static sp_int32 sp_3072_cmp_48(const sp_digit* a, const sp_digit* b) "IT ne\n\t" "movne r3, r7\n\t" "SUBS r6, r6, #0x4\n\t" - "bcs L_sp_3072_cmp_48_words%=\n\t" + "bcs L_sp_3072_cmp_48_words\n\t" "EOR r2, r2, r3\n\t" #else "LDR r4, [%[a], #188]\n\t" @@ -16797,7 +17241,11 @@ static sp_digit sp_3072_cond_sub_96(sp_digit* r, const sp_digit* a, const sp_dig "MOV r4, #0x0\n\t" "MOV r5, #0x0\n\t" "\n" - "L_sp_3072_cond_sub_96_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_cond_sub_96_words:\n\t" +#else + "L_sp_3072_cond_sub_96_words_%=:\n\t" +#endif "SUBS r4, r8, r4\n\t" "LDR r6, [%[a], r5]\n\t" "LDR r7, [%[b], r5]\n\t" @@ -16807,10 +17255,12 @@ static sp_digit sp_3072_cond_sub_96(sp_digit* r, const sp_digit* a, const sp_dig "STR r6, [%[r], r5]\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x180\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_cond_sub_96_words%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_cond_sub_96_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_cond_sub_96_words\n\t" #else - "BLT.N L_sp_3072_cond_sub_96_words%=\n\t" + "BLT.N L_sp_3072_cond_sub_96_words_%=\n\t" #endif "MOV %[r], r4\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b), [m] "+r" (m) @@ -17217,7 +17667,11 @@ SP_NOINLINE static void sp_3072_mont_reduce_96(sp_digit* a, const sp_digit* m, s "LDR r4, [%[a]]\n\t" "LDR r5, [%[a], #4]\n\t" "\n" - "L_sp_3072_mont_reduce_96_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mont_reduce_96_word:\n\t" +#else + "L_sp_3072_mont_reduce_96_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL r10, %[mp], r4\n\t" /* a[i+0] += m[0] * mu */ @@ -17991,10 +18445,12 @@ SP_NOINLINE static void sp_3072_mont_reduce_96(sp_digit* a, const sp_digit* m, s "ADD r11, r11, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r11, #0x180\n\t" -#ifdef __GNUC__ - "BLT L_sp_3072_mont_reduce_96_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mont_reduce_96_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_3072_mont_reduce_96_word\n\t" #else - "BLT.W L_sp_3072_mont_reduce_96_word%=\n\t" + "BLT.W L_sp_3072_mont_reduce_96_word_%=\n\t" #endif /* Loop Done */ "STR r4, [%[a]]\n\t" @@ -18033,7 +18489,11 @@ SP_NOINLINE static void sp_3072_mont_reduce_96(sp_digit* a, const sp_digit* m, s /* ca = 0 */ "MOV r3, #0x0\n\t" "\n" - "L_sp_3072_mont_reduce_96_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mont_reduce_96_word:\n\t" +#else + "L_sp_3072_mont_reduce_96_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "LDR r10, [%[a]]\n\t" "MUL r8, %[mp], r10\n\t" @@ -18041,7 +18501,11 @@ SP_NOINLINE static void sp_3072_mont_reduce_96(sp_digit* a, const sp_digit* m, s "MOV r12, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_3072_mont_reduce_96_mul%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mont_reduce_96_mul:\n\t" +#else + "L_sp_3072_mont_reduce_96_mul_%=:\n\t" +#endif /* a[i+j+0] += m[j+0] * mu */ "LDR r7, [%[m], r12]\n\t" "LDR r10, [%[a], r12]\n\t" @@ -18083,10 +18547,12 @@ SP_NOINLINE static void sp_3072_mont_reduce_96(sp_digit* a, const sp_digit* m, s /* j += 1 */ "ADD r12, r12, #0x4\n\t" "CMP r12, #0x180\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_mont_reduce_96_mul%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mont_reduce_96_mul_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_mont_reduce_96_mul\n\t" #else - "BLT.N L_sp_3072_mont_reduce_96_mul%=\n\t" + "BLT.N L_sp_3072_mont_reduce_96_mul_%=\n\t" #endif "LDR r10, [%[a], #384]\n\t" "ADDS r4, r4, r3\n\t" @@ -18099,10 +18565,12 @@ SP_NOINLINE static void sp_3072_mont_reduce_96(sp_digit* a, const sp_digit* m, s "ADD r9, r9, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r9, #0x180\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_mont_reduce_96_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mont_reduce_96_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_mont_reduce_96_word\n\t" #else - "BLT.N L_sp_3072_mont_reduce_96_word%=\n\t" + "BLT.N L_sp_3072_mont_reduce_96_word_%=\n\t" #endif /* Loop Done */ "MOV %[mp], r3\n\t" @@ -18144,7 +18612,11 @@ SP_NOINLINE static void sp_3072_mont_reduce_96(sp_digit* a, const sp_digit* m, s "LDR r9, [%[a], #12]\n\t" "LDR r10, [%[a], #16]\n\t" "\n" - "L_sp_3072_mont_reduce_96_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mont_reduce_96_word:\n\t" +#else + "L_sp_3072_mont_reduce_96_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL lr, %[mp], r6\n\t" /* a[i+0] += m[0] * mu */ @@ -18631,10 +19103,12 @@ SP_NOINLINE static void sp_3072_mont_reduce_96(sp_digit* a, const sp_digit* m, s "ADD r4, r4, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r4, #0x180\n\t" -#ifdef __GNUC__ - "BLT L_sp_3072_mont_reduce_96_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mont_reduce_96_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_3072_mont_reduce_96_word\n\t" #else - "BLT.W L_sp_3072_mont_reduce_96_word%=\n\t" + "BLT.W L_sp_3072_mont_reduce_96_word_%=\n\t" #endif /* Loop Done */ "STR r6, [%[a]]\n\t" @@ -18676,7 +19150,11 @@ SP_NOINLINE static void sp_3072_mont_reduce_96(sp_digit* a, const sp_digit* m, s /* ca = 0 */ "MOV r3, #0x0\n\t" "\n" - "L_sp_3072_mont_reduce_96_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mont_reduce_96_word:\n\t" +#else + "L_sp_3072_mont_reduce_96_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "LDR r10, [%[a]]\n\t" "MUL r8, %[mp], r10\n\t" @@ -18684,7 +19162,11 @@ SP_NOINLINE static void sp_3072_mont_reduce_96(sp_digit* a, const sp_digit* m, s "MOV r12, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_3072_mont_reduce_96_mul%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_mont_reduce_96_mul:\n\t" +#else + "L_sp_3072_mont_reduce_96_mul_%=:\n\t" +#endif /* a[i+j+0] += m[j+0] * mu */ "LDR r7, [%[m], r12]\n\t" "LDR r10, [%[a], r12]\n\t" @@ -18714,10 +19196,12 @@ SP_NOINLINE static void sp_3072_mont_reduce_96(sp_digit* a, const sp_digit* m, s /* j += 1 */ "ADD r12, r12, #0x4\n\t" "CMP r12, #0x180\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_mont_reduce_96_mul%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mont_reduce_96_mul_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_mont_reduce_96_mul\n\t" #else - "BLT.N L_sp_3072_mont_reduce_96_mul%=\n\t" + "BLT.N L_sp_3072_mont_reduce_96_mul_%=\n\t" #endif "LDR r10, [%[a], #384]\n\t" "ADDS r4, r4, r3\n\t" @@ -18730,10 +19214,12 @@ SP_NOINLINE static void sp_3072_mont_reduce_96(sp_digit* a, const sp_digit* m, s "ADD r9, r9, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r9, #0x180\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_mont_reduce_96_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_mont_reduce_96_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_mont_reduce_96_word\n\t" #else - "BLT.N L_sp_3072_mont_reduce_96_word%=\n\t" + "BLT.N L_sp_3072_mont_reduce_96_word_%=\n\t" #endif /* Loop Done */ "MOV %[mp], r3\n\t" @@ -18799,7 +19285,11 @@ static sp_digit sp_3072_sub_96(sp_digit* r, const sp_digit* a, const sp_digit* b "MOV r11, #0x0\n\t" "ADD r12, %[a], #0x180\n\t" "\n" - "L_sp_3072_sub_96_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_sub_96_word:\n\t" +#else + "L_sp_3072_sub_96_word_%=:\n\t" +#endif "RSBS r11, r11, #0x0\n\t" "LDM %[a]!, {r3, r4, r5, r6}\n\t" "LDM %[b]!, {r7, r8, r9, r10}\n\t" @@ -18810,10 +19300,12 @@ static sp_digit sp_3072_sub_96(sp_digit* r, const sp_digit* a, const sp_digit* b "STM %[r]!, {r3, r4, r5, r6}\n\t" "SBC r11, r3, r3\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_3072_sub_96_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_3072_sub_96_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_3072_sub_96_word\n\t" #else - "BNE.N L_sp_3072_sub_96_word%=\n\t" + "BNE.N L_sp_3072_sub_96_word_%=\n\t" #endif "MOV %[r], r11\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -19122,7 +19614,11 @@ SP_NOINLINE static sp_digit div_3072_word_96(sp_digit d1, sp_digit d0, sp_digit /* Next 30 bits */ "MOV r4, #0x1d\n\t" "\n" - "L_div_3072_word_96_bit%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_div_3072_word_96_bit:\n\t" +#else + "L_div_3072_word_96_bit_%=:\n\t" +#endif "LSLS r6, r6, #1\n\t" "ADC r7, r7, r7\n\t" "SUBS r8, r5, r7\n\t" @@ -19132,7 +19628,13 @@ SP_NOINLINE static sp_digit div_3072_word_96(sp_digit d1, sp_digit d0, sp_digit "AND r8, r8, r5\n\t" "SUBS r7, r7, r8\n\t" "SUBS r4, r4, #0x1\n\t" - "bpl L_div_3072_word_96_bit%=\n\t" +#if defined(__GNUC__) + "BPL L_div_3072_word_96_bit_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BPL.N L_div_3072_word_96_bit\n\t" +#else + "BPL.N L_div_3072_word_96_bit_%=\n\t" +#endif "ADD r3, r3, r3\n\t" "ADD r3, r3, #0x1\n\t" "UMULL r6, r7, r3, %[div]\n\t" @@ -19287,7 +19789,11 @@ static sp_int32 sp_3072_cmp_96(const sp_digit* a, const sp_digit* b) #ifdef WOLFSSL_SP_SMALL "MOV r6, #0x17c\n\t" "\n" - "L_sp_3072_cmp_96_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_cmp_96_words:\n\t" +#else + "L_sp_3072_cmp_96_words_%=:\n\t" +#endif "LDR r4, [%[a], r6]\n\t" "LDR r5, [%[b], r6]\n\t" "AND r4, r4, r3\n\t" @@ -19300,7 +19806,7 @@ static sp_int32 sp_3072_cmp_96(const sp_digit* a, const sp_digit* b) "IT ne\n\t" "movne r3, r7\n\t" "SUBS r6, r6, #0x4\n\t" - "bcs L_sp_3072_cmp_96_words%=\n\t" + "bcs L_sp_3072_cmp_96_words\n\t" "EOR r2, r2, r3\n\t" #else "LDR r4, [%[a], #380]\n\t" @@ -20915,7 +21421,11 @@ static sp_digit sp_3072_cond_add_48(sp_digit* r, const sp_digit* a, const sp_dig "MOV r8, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_3072_cond_add_48_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_3072_cond_add_48_words:\n\t" +#else + "L_sp_3072_cond_add_48_words_%=:\n\t" +#endif "ADDS r5, r5, #0xffffffff\n\t" "LDR r6, [%[a], r4]\n\t" "LDR r7, [%[b], r4]\n\t" @@ -20925,10 +21435,12 @@ static sp_digit sp_3072_cond_add_48(sp_digit* r, const sp_digit* a, const sp_dig "STR r6, [%[r], r4]\n\t" "ADD r4, r4, #0x4\n\t" "CMP r4, #0xc0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_3072_cond_add_48_words%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_3072_cond_add_48_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_3072_cond_add_48_words\n\t" #else - "BLT.N L_sp_3072_cond_add_48_words%=\n\t" + "BLT.N L_sp_3072_cond_add_48_words_%=\n\t" #endif "MOV %[r], r5\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b), [m] "+r" (m) @@ -23059,7 +23571,11 @@ static sp_digit sp_4096_add_128(sp_digit* r, const sp_digit* a, const sp_digit* "MOV r3, #0x0\n\t" "ADD r12, %[a], #0x200\n\t" "\n" - "L_sp_4096_add_128_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_add_128_word:\n\t" +#else + "L_sp_4096_add_128_word_%=:\n\t" +#endif "ADDS r3, r3, #0xffffffff\n\t" "LDM %[a]!, {r4, r5, r6, r7}\n\t" "LDM %[b]!, {r8, r9, r10, r11}\n\t" @@ -23071,10 +23587,12 @@ static sp_digit sp_4096_add_128(sp_digit* r, const sp_digit* a, const sp_digit* "MOV r4, #0x0\n\t" "ADC r3, r4, #0x0\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_4096_add_128_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_4096_add_128_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_4096_add_128_word\n\t" #else - "BNE.N L_sp_4096_add_128_word%=\n\t" + "BNE.N L_sp_4096_add_128_word_%=\n\t" #endif "MOV %[r], r3\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -23106,7 +23624,11 @@ static sp_digit sp_4096_sub_in_place_128(sp_digit* a, const sp_digit* b) "MOV r10, #0x0\n\t" "ADD r11, %[a], #0x200\n\t" "\n" - "L_sp_4096_sub_in_pkace_128_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_sub_in_pkace_128_word:\n\t" +#else + "L_sp_4096_sub_in_pkace_128_word_%=:\n\t" +#endif "RSBS r10, r10, #0x0\n\t" "LDM %[a], {r2, r3, r4, r5}\n\t" "LDM %[b]!, {r6, r7, r8, r9}\n\t" @@ -23117,10 +23639,12 @@ static sp_digit sp_4096_sub_in_place_128(sp_digit* a, const sp_digit* b) "STM %[a]!, {r2, r3, r4, r5}\n\t" "SBC r10, r10, r10\n\t" "CMP %[a], r11\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_4096_sub_in_pkace_128_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_4096_sub_in_pkace_128_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_4096_sub_in_pkace_128_word\n\t" #else - "BNE.N L_sp_4096_sub_in_pkace_128_word%=\n\t" + "BNE.N L_sp_4096_sub_in_pkace_128_word_%=\n\t" #endif "MOV %[a], r10\n\t" : [a] "+r" (a), [b] "+r" (b) @@ -23160,13 +23684,21 @@ static void sp_4096_mul_128(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_4096_mul_128_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_mul_128_outer:\n\t" +#else + "L_sp_4096_mul_128_outer_%=:\n\t" +#endif "SUBS r3, r5, #0x1fc\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_4096_mul_128_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_mul_128_inner:\n\t" +#else + "L_sp_4096_mul_128_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -23182,15 +23714,19 @@ static void sp_4096_mul_128(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_4096_mul_128_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_4096_mul_128_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_4096_mul_128_inner_done\n\t" #else - "BGT.N L_sp_4096_mul_128_inner_done%=\n\t" + "BGT.N L_sp_4096_mul_128_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_4096_mul_128_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_4096_mul_128_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_4096_mul_128_inner\n\t" #else - "BLT.N L_sp_4096_mul_128_inner%=\n\t" + "BLT.N L_sp_4096_mul_128_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r3]\n\t" @@ -23199,17 +23735,23 @@ static void sp_4096_mul_128(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_4096_mul_128_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_mul_128_inner_done:\n\t" +#else + "L_sp_4096_mul_128_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x3f4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_4096_mul_128_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_4096_mul_128_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_4096_mul_128_outer\n\t" #else - "BLE.N L_sp_4096_mul_128_outer%=\n\t" + "BLE.N L_sp_4096_mul_128_outer_%=\n\t" #endif "LDR lr, [%[a], #508]\n\t" "LDR r11, [%[b], #508]\n\t" @@ -23218,14 +23760,20 @@ static void sp_4096_mul_128(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_4096_mul_128_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_mul_128_store:\n\t" +#else + "L_sp_4096_mul_128_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_4096_mul_128_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_4096_mul_128_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_4096_mul_128_store\n\t" #else - "BGT.N L_sp_4096_mul_128_store%=\n\t" + "BGT.N L_sp_4096_mul_128_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) : @@ -23258,13 +23806,21 @@ static void sp_4096_sqr_128(sp_digit* r, const sp_digit* a) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_4096_sqr_128_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_sqr_128_outer:\n\t" +#else + "L_sp_4096_sqr_128_outer_%=:\n\t" +#endif "SUBS r3, r5, #0x1fc\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_4096_sqr_128_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_sqr_128_inner:\n\t" +#else + "L_sp_4096_sqr_128_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[a], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -23277,15 +23833,19 @@ static void sp_4096_sqr_128(sp_digit* r, const sp_digit* a) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_4096_sqr_128_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_4096_sqr_128_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_4096_sqr_128_inner_done\n\t" #else - "BGT.N L_sp_4096_sqr_128_inner_done%=\n\t" + "BGT.N L_sp_4096_sqr_128_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_4096_sqr_128_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_4096_sqr_128_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_4096_sqr_128_inner\n\t" #else - "BLT.N L_sp_4096_sqr_128_inner%=\n\t" + "BLT.N L_sp_4096_sqr_128_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "UMULL r9, r10, lr, lr\n\t" @@ -23293,17 +23853,23 @@ static void sp_4096_sqr_128(sp_digit* r, const sp_digit* a) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_4096_sqr_128_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_sqr_128_inner_done:\n\t" +#else + "L_sp_4096_sqr_128_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x3f4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_4096_sqr_128_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_4096_sqr_128_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_4096_sqr_128_outer\n\t" #else - "BLE.N L_sp_4096_sqr_128_outer%=\n\t" + "BLE.N L_sp_4096_sqr_128_outer_%=\n\t" #endif "LDR lr, [%[a], #508]\n\t" "UMLAL r6, r7, lr, lr\n\t" @@ -23311,14 +23877,20 @@ static void sp_4096_sqr_128(sp_digit* r, const sp_digit* a) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_4096_sqr_128_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_sqr_128_store:\n\t" +#else + "L_sp_4096_sqr_128_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_4096_sqr_128_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_4096_sqr_128_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_4096_sqr_128_store\n\t" #else - "BGT.N L_sp_4096_sqr_128_store%=\n\t" + "BGT.N L_sp_4096_sqr_128_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a) : @@ -23375,7 +23947,11 @@ static void sp_4096_mul_d_128(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "MOV r9, #0x4\n\t" "\n" - "L_sp_4096_mul_d_128_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_mul_d_128_word:\n\t" +#else + "L_sp_4096_mul_d_128_word_%=:\n\t" +#endif /* A[i] * B */ "LDR r8, [%[a], r9]\n\t" "UMULL r6, r7, %[b], r8\n\t" @@ -23388,10 +23964,12 @@ static void sp_4096_mul_d_128(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "ADD r9, r9, #0x4\n\t" "CMP r9, #0x200\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_4096_mul_d_128_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_4096_mul_d_128_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_4096_mul_d_128_word\n\t" #else - "BLT.N L_sp_4096_mul_d_128_word%=\n\t" + "BLT.N L_sp_4096_mul_d_128_word_%=\n\t" #endif "STR r3, [%[r], #512]\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -24110,7 +24688,11 @@ static sp_digit sp_4096_cond_sub_128(sp_digit* r, const sp_digit* a, const sp_di "MOV r4, #0x0\n\t" "MOV r5, #0x0\n\t" "\n" - "L_sp_4096_cond_sub_128_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_cond_sub_128_words:\n\t" +#else + "L_sp_4096_cond_sub_128_words_%=:\n\t" +#endif "SUBS r4, r8, r4\n\t" "LDR r6, [%[a], r5]\n\t" "LDR r7, [%[b], r5]\n\t" @@ -24120,10 +24702,12 @@ static sp_digit sp_4096_cond_sub_128(sp_digit* r, const sp_digit* a, const sp_di "STR r6, [%[r], r5]\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x200\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_4096_cond_sub_128_words%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_4096_cond_sub_128_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_4096_cond_sub_128_words\n\t" #else - "BLT.N L_sp_4096_cond_sub_128_words%=\n\t" + "BLT.N L_sp_4096_cond_sub_128_words_%=\n\t" #endif "MOV %[r], r4\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b), [m] "+r" (m) @@ -24642,7 +25226,11 @@ SP_NOINLINE static void sp_4096_mont_reduce_128(sp_digit* a, const sp_digit* m, "LDR r4, [%[a]]\n\t" "LDR r5, [%[a], #4]\n\t" "\n" - "L_sp_4096_mont_reduce_128_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_mont_reduce_128_word:\n\t" +#else + "L_sp_4096_mont_reduce_128_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL r10, %[mp], r4\n\t" /* a[i+0] += m[0] * mu */ @@ -25672,10 +26260,12 @@ SP_NOINLINE static void sp_4096_mont_reduce_128(sp_digit* a, const sp_digit* m, "ADD r11, r11, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r11, #0x200\n\t" -#ifdef __GNUC__ - "BLT L_sp_4096_mont_reduce_128_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_4096_mont_reduce_128_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_4096_mont_reduce_128_word\n\t" #else - "BLT.W L_sp_4096_mont_reduce_128_word%=\n\t" + "BLT.W L_sp_4096_mont_reduce_128_word_%=\n\t" #endif /* Loop Done */ "STR r4, [%[a]]\n\t" @@ -25714,7 +26304,11 @@ SP_NOINLINE static void sp_4096_mont_reduce_128(sp_digit* a, const sp_digit* m, /* ca = 0 */ "MOV r3, #0x0\n\t" "\n" - "L_sp_4096_mont_reduce_128_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_mont_reduce_128_word:\n\t" +#else + "L_sp_4096_mont_reduce_128_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "LDR r10, [%[a]]\n\t" "MUL r8, %[mp], r10\n\t" @@ -25722,7 +26316,11 @@ SP_NOINLINE static void sp_4096_mont_reduce_128(sp_digit* a, const sp_digit* m, "MOV r12, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_4096_mont_reduce_128_mul%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_mont_reduce_128_mul:\n\t" +#else + "L_sp_4096_mont_reduce_128_mul_%=:\n\t" +#endif /* a[i+j+0] += m[j+0] * mu */ "LDR r7, [%[m], r12]\n\t" "LDR r10, [%[a], r12]\n\t" @@ -25764,10 +26362,12 @@ SP_NOINLINE static void sp_4096_mont_reduce_128(sp_digit* a, const sp_digit* m, /* j += 1 */ "ADD r12, r12, #0x4\n\t" "CMP r12, #0x200\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_4096_mont_reduce_128_mul%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_4096_mont_reduce_128_mul_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_4096_mont_reduce_128_mul\n\t" #else - "BLT.N L_sp_4096_mont_reduce_128_mul%=\n\t" + "BLT.N L_sp_4096_mont_reduce_128_mul_%=\n\t" #endif "LDR r10, [%[a], #512]\n\t" "ADDS r4, r4, r3\n\t" @@ -25780,10 +26380,12 @@ SP_NOINLINE static void sp_4096_mont_reduce_128(sp_digit* a, const sp_digit* m, "ADD r9, r9, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r9, #0x200\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_4096_mont_reduce_128_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_4096_mont_reduce_128_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_4096_mont_reduce_128_word\n\t" #else - "BLT.N L_sp_4096_mont_reduce_128_word%=\n\t" + "BLT.N L_sp_4096_mont_reduce_128_word_%=\n\t" #endif /* Loop Done */ "MOV %[mp], r3\n\t" @@ -25825,7 +26427,11 @@ SP_NOINLINE static void sp_4096_mont_reduce_128(sp_digit* a, const sp_digit* m, "LDR r9, [%[a], #12]\n\t" "LDR r10, [%[a], #16]\n\t" "\n" - "L_sp_4096_mont_reduce_128_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_mont_reduce_128_word:\n\t" +#else + "L_sp_4096_mont_reduce_128_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL lr, %[mp], r6\n\t" /* a[i+0] += m[0] * mu */ @@ -26472,10 +27078,12 @@ SP_NOINLINE static void sp_4096_mont_reduce_128(sp_digit* a, const sp_digit* m, "ADD r4, r4, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r4, #0x200\n\t" -#ifdef __GNUC__ - "BLT L_sp_4096_mont_reduce_128_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_4096_mont_reduce_128_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_4096_mont_reduce_128_word\n\t" #else - "BLT.W L_sp_4096_mont_reduce_128_word%=\n\t" + "BLT.W L_sp_4096_mont_reduce_128_word_%=\n\t" #endif /* Loop Done */ "STR r6, [%[a]]\n\t" @@ -26517,7 +27125,11 @@ SP_NOINLINE static void sp_4096_mont_reduce_128(sp_digit* a, const sp_digit* m, /* ca = 0 */ "MOV r3, #0x0\n\t" "\n" - "L_sp_4096_mont_reduce_128_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_mont_reduce_128_word:\n\t" +#else + "L_sp_4096_mont_reduce_128_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "LDR r10, [%[a]]\n\t" "MUL r8, %[mp], r10\n\t" @@ -26525,7 +27137,11 @@ SP_NOINLINE static void sp_4096_mont_reduce_128(sp_digit* a, const sp_digit* m, "MOV r12, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_4096_mont_reduce_128_mul%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_mont_reduce_128_mul:\n\t" +#else + "L_sp_4096_mont_reduce_128_mul_%=:\n\t" +#endif /* a[i+j+0] += m[j+0] * mu */ "LDR r7, [%[m], r12]\n\t" "LDR r10, [%[a], r12]\n\t" @@ -26555,10 +27171,12 @@ SP_NOINLINE static void sp_4096_mont_reduce_128(sp_digit* a, const sp_digit* m, /* j += 1 */ "ADD r12, r12, #0x4\n\t" "CMP r12, #0x200\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_4096_mont_reduce_128_mul%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_4096_mont_reduce_128_mul_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_4096_mont_reduce_128_mul\n\t" #else - "BLT.N L_sp_4096_mont_reduce_128_mul%=\n\t" + "BLT.N L_sp_4096_mont_reduce_128_mul_%=\n\t" #endif "LDR r10, [%[a], #512]\n\t" "ADDS r4, r4, r3\n\t" @@ -26571,10 +27189,12 @@ SP_NOINLINE static void sp_4096_mont_reduce_128(sp_digit* a, const sp_digit* m, "ADD r9, r9, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r9, #0x200\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_4096_mont_reduce_128_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_4096_mont_reduce_128_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_4096_mont_reduce_128_word\n\t" #else - "BLT.N L_sp_4096_mont_reduce_128_word%=\n\t" + "BLT.N L_sp_4096_mont_reduce_128_word_%=\n\t" #endif /* Loop Done */ "MOV %[mp], r3\n\t" @@ -26640,7 +27260,11 @@ static sp_digit sp_4096_sub_128(sp_digit* r, const sp_digit* a, const sp_digit* "MOV r11, #0x0\n\t" "ADD r12, %[a], #0x200\n\t" "\n" - "L_sp_4096_sub_128_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_sub_128_word:\n\t" +#else + "L_sp_4096_sub_128_word_%=:\n\t" +#endif "RSBS r11, r11, #0x0\n\t" "LDM %[a]!, {r3, r4, r5, r6}\n\t" "LDM %[b]!, {r7, r8, r9, r10}\n\t" @@ -26651,10 +27275,12 @@ static sp_digit sp_4096_sub_128(sp_digit* r, const sp_digit* a, const sp_digit* "STM %[r]!, {r3, r4, r5, r6}\n\t" "SBC r11, r3, r3\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_4096_sub_128_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_4096_sub_128_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_4096_sub_128_word\n\t" #else - "BNE.N L_sp_4096_sub_128_word%=\n\t" + "BNE.N L_sp_4096_sub_128_word_%=\n\t" #endif "MOV %[r], r11\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -27019,7 +27645,11 @@ SP_NOINLINE static sp_digit div_4096_word_128(sp_digit d1, sp_digit d0, sp_digit /* Next 30 bits */ "MOV r4, #0x1d\n\t" "\n" - "L_div_4096_word_128_bit%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_div_4096_word_128_bit:\n\t" +#else + "L_div_4096_word_128_bit_%=:\n\t" +#endif "LSLS r6, r6, #1\n\t" "ADC r7, r7, r7\n\t" "SUBS r8, r5, r7\n\t" @@ -27029,7 +27659,13 @@ SP_NOINLINE static sp_digit div_4096_word_128(sp_digit d1, sp_digit d0, sp_digit "AND r8, r8, r5\n\t" "SUBS r7, r7, r8\n\t" "SUBS r4, r4, #0x1\n\t" - "bpl L_div_4096_word_128_bit%=\n\t" +#if defined(__GNUC__) + "BPL L_div_4096_word_128_bit_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BPL.N L_div_4096_word_128_bit\n\t" +#else + "BPL.N L_div_4096_word_128_bit_%=\n\t" +#endif "ADD r3, r3, r3\n\t" "ADD r3, r3, #0x1\n\t" "UMULL r6, r7, r3, %[div]\n\t" @@ -27184,7 +27820,11 @@ static sp_int32 sp_4096_cmp_128(const sp_digit* a, const sp_digit* b) #ifdef WOLFSSL_SP_SMALL "MOV r6, #0x1fc\n\t" "\n" - "L_sp_4096_cmp_128_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_cmp_128_words:\n\t" +#else + "L_sp_4096_cmp_128_words_%=:\n\t" +#endif "LDR r4, [%[a], r6]\n\t" "LDR r5, [%[b], r6]\n\t" "AND r4, r4, r3\n\t" @@ -27197,7 +27837,7 @@ static sp_int32 sp_4096_cmp_128(const sp_digit* a, const sp_digit* b) "IT ne\n\t" "movne r3, r7\n\t" "SUBS r6, r6, #0x4\n\t" - "bcs L_sp_4096_cmp_128_words%=\n\t" + "bcs L_sp_4096_cmp_128_words\n\t" "EOR r2, r2, r3\n\t" #else "LDR r4, [%[a], #508]\n\t" @@ -29164,7 +29804,11 @@ static sp_digit sp_4096_cond_add_64(sp_digit* r, const sp_digit* a, const sp_dig "MOV r8, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_4096_cond_add_64_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_4096_cond_add_64_words:\n\t" +#else + "L_sp_4096_cond_add_64_words_%=:\n\t" +#endif "ADDS r5, r5, #0xffffffff\n\t" "LDR r6, [%[a], r4]\n\t" "LDR r7, [%[b], r4]\n\t" @@ -29174,10 +29818,12 @@ static sp_digit sp_4096_cond_add_64(sp_digit* r, const sp_digit* a, const sp_dig "STR r6, [%[r], r4]\n\t" "ADD r4, r4, #0x4\n\t" "CMP r4, #0x100\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_4096_cond_add_64_words%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_4096_cond_add_64_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_4096_cond_add_64_words\n\t" #else - "BLT.N L_sp_4096_cond_add_64_words%=\n\t" + "BLT.N L_sp_4096_cond_add_64_words_%=\n\t" #endif "MOV %[r], r5\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b), [m] "+r" (m) @@ -30857,13 +31503,21 @@ static void sp_256_mul_8(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_256_mul_8_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_mul_8_outer:\n\t" +#else + "L_sp_256_mul_8_outer_%=:\n\t" +#endif "SUBS r3, r5, #0x1c\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_256_mul_8_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_mul_8_inner:\n\t" +#else + "L_sp_256_mul_8_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -30879,15 +31533,19 @@ static void sp_256_mul_8(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_256_mul_8_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_256_mul_8_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_256_mul_8_inner_done\n\t" #else - "BGT.N L_sp_256_mul_8_inner_done%=\n\t" + "BGT.N L_sp_256_mul_8_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_256_mul_8_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_256_mul_8_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_256_mul_8_inner\n\t" #else - "BLT.N L_sp_256_mul_8_inner%=\n\t" + "BLT.N L_sp_256_mul_8_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r3]\n\t" @@ -30896,17 +31554,23 @@ static void sp_256_mul_8(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_256_mul_8_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_mul_8_inner_done:\n\t" +#else + "L_sp_256_mul_8_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x34\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_256_mul_8_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_256_mul_8_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_256_mul_8_outer\n\t" #else - "BLE.N L_sp_256_mul_8_outer%=\n\t" + "BLE.N L_sp_256_mul_8_outer_%=\n\t" #endif "LDR lr, [%[a], #28]\n\t" "LDR r11, [%[b], #28]\n\t" @@ -30915,14 +31579,20 @@ static void sp_256_mul_8(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_256_mul_8_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_mul_8_store:\n\t" +#else + "L_sp_256_mul_8_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_256_mul_8_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_256_mul_8_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_256_mul_8_store\n\t" #else - "BGT.N L_sp_256_mul_8_store%=\n\t" + "BGT.N L_sp_256_mul_8_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) : @@ -31455,13 +32125,21 @@ static void sp_256_sqr_8(sp_digit* r, const sp_digit* a) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_256_sqr_8_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_sqr_8_outer:\n\t" +#else + "L_sp_256_sqr_8_outer_%=:\n\t" +#endif "SUBS r3, r5, #0x1c\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_256_sqr_8_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_sqr_8_inner:\n\t" +#else + "L_sp_256_sqr_8_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[a], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -31474,15 +32152,19 @@ static void sp_256_sqr_8(sp_digit* r, const sp_digit* a) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_256_sqr_8_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_256_sqr_8_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_256_sqr_8_inner_done\n\t" #else - "BGT.N L_sp_256_sqr_8_inner_done%=\n\t" + "BGT.N L_sp_256_sqr_8_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_256_sqr_8_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_256_sqr_8_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_256_sqr_8_inner\n\t" #else - "BLT.N L_sp_256_sqr_8_inner%=\n\t" + "BLT.N L_sp_256_sqr_8_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "UMULL r9, r10, lr, lr\n\t" @@ -31490,17 +32172,23 @@ static void sp_256_sqr_8(sp_digit* r, const sp_digit* a) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_256_sqr_8_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_sqr_8_inner_done:\n\t" +#else + "L_sp_256_sqr_8_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x34\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_256_sqr_8_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_256_sqr_8_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_256_sqr_8_outer\n\t" #else - "BLE.N L_sp_256_sqr_8_outer%=\n\t" + "BLE.N L_sp_256_sqr_8_outer_%=\n\t" #endif "LDR lr, [%[a], #28]\n\t" "UMLAL r6, r7, lr, lr\n\t" @@ -31508,14 +32196,20 @@ static void sp_256_sqr_8(sp_digit* r, const sp_digit* a) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_256_sqr_8_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_sqr_8_store:\n\t" +#else + "L_sp_256_sqr_8_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_256_sqr_8_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_256_sqr_8_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_256_sqr_8_store\n\t" #else - "BGT.N L_sp_256_sqr_8_store%=\n\t" + "BGT.N L_sp_256_sqr_8_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a) : @@ -31915,7 +32609,11 @@ static sp_digit sp_256_add_8(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r3, #0x0\n\t" "ADD r12, %[a], #0x20\n\t" "\n" - "L_sp_256_add_8_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_add_8_word:\n\t" +#else + "L_sp_256_add_8_word_%=:\n\t" +#endif "ADDS r3, r3, #0xffffffff\n\t" "LDM %[a]!, {r4, r5, r6, r7}\n\t" "LDM %[b]!, {r8, r9, r10, r11}\n\t" @@ -31927,10 +32625,12 @@ static sp_digit sp_256_add_8(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r4, #0x0\n\t" "ADC r3, r4, #0x0\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_256_add_8_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_256_add_8_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_256_add_8_word\n\t" #else - "BNE.N L_sp_256_add_8_word%=\n\t" + "BNE.N L_sp_256_add_8_word_%=\n\t" #endif "MOV %[r], r3\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -33938,7 +34638,11 @@ static sp_int32 sp_256_cmp_8(const sp_digit* a, const sp_digit* b) #ifdef WOLFSSL_SP_SMALL "MOV r6, #0x1c\n\t" "\n" - "L_sp_256_cmp_8_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_cmp_8_words:\n\t" +#else + "L_sp_256_cmp_8_words_%=:\n\t" +#endif "LDR r4, [%[a], r6]\n\t" "LDR r5, [%[b], r6]\n\t" "AND r4, r4, r3\n\t" @@ -33951,7 +34655,7 @@ static sp_int32 sp_256_cmp_8(const sp_digit* a, const sp_digit* b) "IT ne\n\t" "movne r3, r7\n\t" "SUBS r6, r6, #0x4\n\t" - "bcs L_sp_256_cmp_8_words%=\n\t" + "bcs L_sp_256_cmp_8_words\n\t" "EOR r2, r2, r3\n\t" #else "LDR r4, [%[a], #28]\n\t" @@ -34085,7 +34789,11 @@ static sp_digit sp_256_cond_sub_8(sp_digit* r, const sp_digit* a, const sp_digit "MOV r4, #0x0\n\t" "MOV r5, #0x0\n\t" "\n" - "L_sp_256_cond_sub_8_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_cond_sub_8_words:\n\t" +#else + "L_sp_256_cond_sub_8_words_%=:\n\t" +#endif "SUBS r4, r8, r4\n\t" "LDR r6, [%[a], r5]\n\t" "LDR r7, [%[b], r5]\n\t" @@ -34095,10 +34803,12 @@ static sp_digit sp_256_cond_sub_8(sp_digit* r, const sp_digit* a, const sp_digit "STR r6, [%[r], r5]\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_256_cond_sub_8_words%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_256_cond_sub_8_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_256_cond_sub_8_words\n\t" #else - "BLT.N L_sp_256_cond_sub_8_words%=\n\t" + "BLT.N L_sp_256_cond_sub_8_words_%=\n\t" #endif "MOV %[r], r4\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b), [m] "+r" (m) @@ -34199,7 +34909,11 @@ SP_NOINLINE static void sp_256_mont_reduce_8(sp_digit* a, const sp_digit* m, sp_ "LDR r4, [%[a]]\n\t" "LDR r5, [%[a], #4]\n\t" "\n" - "L_sp_256_mont_reduce_8_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_mont_reduce_8_word:\n\t" +#else + "L_sp_256_mont_reduce_8_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL r10, %[mp], r4\n\t" /* a[i+0] += m[0] * mu */ @@ -34269,10 +34983,12 @@ SP_NOINLINE static void sp_256_mont_reduce_8(sp_digit* a, const sp_digit* m, sp_ "ADD r11, r11, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r11, #0x20\n\t" -#ifdef __GNUC__ - "BLT L_sp_256_mont_reduce_8_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_256_mont_reduce_8_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_256_mont_reduce_8_word\n\t" #else - "BLT.W L_sp_256_mont_reduce_8_word%=\n\t" + "BLT.W L_sp_256_mont_reduce_8_word_%=\n\t" #endif /* Loop Done */ "STR r4, [%[a]]\n\t" @@ -34314,7 +35030,11 @@ SP_NOINLINE static void sp_256_mont_reduce_8(sp_digit* a, const sp_digit* m, sp_ "LDR r9, [%[a], #12]\n\t" "LDR r10, [%[a], #16]\n\t" "\n" - "L_sp_256_mont_reduce_8_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_mont_reduce_8_word:\n\t" +#else + "L_sp_256_mont_reduce_8_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL lr, %[mp], r6\n\t" /* a[i+0] += m[0] * mu */ @@ -34361,10 +35081,12 @@ SP_NOINLINE static void sp_256_mont_reduce_8(sp_digit* a, const sp_digit* m, sp_ "ADD r4, r4, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r4, #0x20\n\t" -#ifdef __GNUC__ - "BLT L_sp_256_mont_reduce_8_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_256_mont_reduce_8_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_256_mont_reduce_8_word\n\t" #else - "BLT.W L_sp_256_mont_reduce_8_word%=\n\t" + "BLT.W L_sp_256_mont_reduce_8_word_%=\n\t" #endif /* Loop Done */ "STR r6, [%[a]]\n\t" @@ -34573,7 +35295,11 @@ SP_NOINLINE static void sp_256_mont_reduce_order_8(sp_digit* a, const sp_digit* "LDR r4, [%[a]]\n\t" "LDR r5, [%[a], #4]\n\t" "\n" - "L_sp_256_mont_reduce_order_8_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_mont_reduce_order_8_word:\n\t" +#else + "L_sp_256_mont_reduce_order_8_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL r10, %[mp], r4\n\t" /* a[i+0] += m[0] * mu */ @@ -34643,10 +35369,12 @@ SP_NOINLINE static void sp_256_mont_reduce_order_8(sp_digit* a, const sp_digit* "ADD r11, r11, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r11, #0x20\n\t" -#ifdef __GNUC__ - "BLT L_sp_256_mont_reduce_order_8_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_256_mont_reduce_order_8_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_256_mont_reduce_order_8_word\n\t" #else - "BLT.W L_sp_256_mont_reduce_order_8_word%=\n\t" + "BLT.W L_sp_256_mont_reduce_order_8_word_%=\n\t" #endif /* Loop Done */ "STR r4, [%[a]]\n\t" @@ -34688,7 +35416,11 @@ SP_NOINLINE static void sp_256_mont_reduce_order_8(sp_digit* a, const sp_digit* "LDR r9, [%[a], #12]\n\t" "LDR r10, [%[a], #16]\n\t" "\n" - "L_sp_256_mont_reduce_order_8_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_mont_reduce_order_8_word:\n\t" +#else + "L_sp_256_mont_reduce_order_8_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL lr, %[mp], r6\n\t" /* a[i+0] += m[0] * mu */ @@ -34735,10 +35467,12 @@ SP_NOINLINE static void sp_256_mont_reduce_order_8(sp_digit* a, const sp_digit* "ADD r4, r4, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r4, #0x20\n\t" -#ifdef __GNUC__ - "BLT L_sp_256_mont_reduce_order_8_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_256_mont_reduce_order_8_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_256_mont_reduce_order_8_word\n\t" #else - "BLT.W L_sp_256_mont_reduce_order_8_word%=\n\t" + "BLT.W L_sp_256_mont_reduce_order_8_word_%=\n\t" #endif /* Loop Done */ "STR r6, [%[a]]\n\t" @@ -39075,7 +39809,11 @@ static sp_digit sp_256_sub_in_place_8(sp_digit* a, const sp_digit* b) "MOV r10, #0x0\n\t" "ADD r11, %[a], #0x20\n\t" "\n" - "L_sp_256_sub_in_pkace_8_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_sub_in_pkace_8_word:\n\t" +#else + "L_sp_256_sub_in_pkace_8_word_%=:\n\t" +#endif "RSBS r10, r10, #0x0\n\t" "LDM %[a], {r2, r3, r4, r5}\n\t" "LDM %[b]!, {r6, r7, r8, r9}\n\t" @@ -39086,10 +39824,12 @@ static sp_digit sp_256_sub_in_place_8(sp_digit* a, const sp_digit* b) "STM %[a]!, {r2, r3, r4, r5}\n\t" "SBC r10, r10, r10\n\t" "CMP %[a], r11\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_256_sub_in_pkace_8_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_256_sub_in_pkace_8_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_256_sub_in_pkace_8_word\n\t" #else - "BNE.N L_sp_256_sub_in_pkace_8_word%=\n\t" + "BNE.N L_sp_256_sub_in_pkace_8_word_%=\n\t" #endif "MOV %[a], r10\n\t" : [a] "+r" (a), [b] "+r" (b) @@ -39168,7 +39908,11 @@ static void sp_256_mul_d_8(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "MOV r9, #0x4\n\t" "\n" - "L_sp_256_mul_d_8_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_mul_d_8_word:\n\t" +#else + "L_sp_256_mul_d_8_word_%=:\n\t" +#endif /* A[i] * B */ "LDR r8, [%[a], r9]\n\t" "UMULL r6, r7, %[b], r8\n\t" @@ -39181,10 +39925,12 @@ static void sp_256_mul_d_8(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "ADD r9, r9, #0x4\n\t" "CMP r9, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_256_mul_d_8_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_256_mul_d_8_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_256_mul_d_8_word\n\t" #else - "BLT.N L_sp_256_mul_d_8_word%=\n\t" + "BLT.N L_sp_256_mul_d_8_word_%=\n\t" #endif "STR r3, [%[r], #32]\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -39362,7 +40108,11 @@ SP_NOINLINE static sp_digit div_256_word_8(sp_digit d1, sp_digit d0, sp_digit di /* Next 30 bits */ "MOV r4, #0x1d\n\t" "\n" - "L_div_256_word_8_bit%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_div_256_word_8_bit:\n\t" +#else + "L_div_256_word_8_bit_%=:\n\t" +#endif "LSLS r6, r6, #1\n\t" "ADC r7, r7, r7\n\t" "SUBS r8, r5, r7\n\t" @@ -39372,7 +40122,13 @@ SP_NOINLINE static sp_digit div_256_word_8(sp_digit d1, sp_digit d0, sp_digit di "AND r8, r8, r5\n\t" "SUBS r7, r7, r8\n\t" "SUBS r4, r4, #0x1\n\t" - "bpl L_div_256_word_8_bit%=\n\t" +#if defined(__GNUC__) + "BPL L_div_256_word_8_bit_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BPL.N L_div_256_word_8_bit\n\t" +#else + "BPL.N L_div_256_word_8_bit_%=\n\t" +#endif "ADD r3, r3, r3\n\t" "ADD r3, r3, #0x1\n\t" "UMULL r6, r7, r3, %[div]\n\t" @@ -40066,7 +40822,11 @@ static sp_digit sp_256_sub_8(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r11, #0x0\n\t" "ADD r12, %[a], #0x20\n\t" "\n" - "L_sp_256_sub_8_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_sub_8_word:\n\t" +#else + "L_sp_256_sub_8_word_%=:\n\t" +#endif "RSBS r11, r11, #0x0\n\t" "LDM %[a]!, {r3, r4, r5, r6}\n\t" "LDM %[b]!, {r7, r8, r9, r10}\n\t" @@ -40077,10 +40837,12 @@ static sp_digit sp_256_sub_8(sp_digit* r, const sp_digit* a, const sp_digit* b) "STM %[r]!, {r3, r4, r5, r6}\n\t" "SBC r11, r3, r3\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_256_sub_8_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_256_sub_8_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_256_sub_8_word\n\t" #else - "BNE.N L_sp_256_sub_8_word%=\n\t" + "BNE.N L_sp_256_sub_8_word_%=\n\t" #endif "MOV %[r], r11\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -40199,10 +40961,12 @@ static void sp_256_div2_mod_8(sp_digit* r, const sp_digit* a, const sp_digit* m) "MOV r12, #0x0\n\t" "LDM %[a]!, {r4}\n\t" "ANDS r3, r4, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_256_div2_mod_8_even%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_256_div2_mod_8_even_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_256_div2_mod_8_even\n\t" #else - "BEQ.N L_sp_256_div2_mod_8_even%=\n\t" + "BEQ.N L_sp_256_div2_mod_8_even_%=\n\t" #endif "LDM %[a]!, {r5, r6, r7}\n\t" "LDM %[m]!, {r8, r9, r10, r11}\n\t" @@ -40218,17 +40982,27 @@ static void sp_256_div2_mod_8(sp_digit* r, const sp_digit* a, const sp_digit* m) "ADCS r6, r6, r10\n\t" "ADCS r7, r7, r11\n\t" "ADC r3, r12, r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_256_div2_mod_8_div2%=\n\t" +#if defined(__GNUC__) + "B L_sp_256_div2_mod_8_div2_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_256_div2_mod_8_div2\n\t" #else - "B.N L_sp_256_div2_mod_8_div2%=\n\t" + "B.N L_sp_256_div2_mod_8_div2_%=\n\t" #endif "\n" - "L_sp_256_div2_mod_8_even%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_div2_mod_8_even:\n\t" +#else + "L_sp_256_div2_mod_8_even_%=:\n\t" +#endif "LDRD r4, r5, [%[a], #12]\n\t" "LDRD r6, r7, [%[a], #20]\n\t" "\n" - "L_sp_256_div2_mod_8_div2%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_div2_mod_8_div2:\n\t" +#else + "L_sp_256_div2_mod_8_div2_%=:\n\t" +#endif "LSR r8, r4, #1\n\t" "AND r4, r4, #0x1\n\t" "LSR r9, r5, #1\n\t" @@ -40270,129 +41044,189 @@ static int sp_256_num_bits_8(const sp_digit* a) __asm__ __volatile__ ( "LDR r1, [%[a], #28]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_256_num_bits_8_7%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_256_num_bits_8_7_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_256_num_bits_8_7\n\t" #else - "BEQ.N L_sp_256_num_bits_8_7%=\n\t" + "BEQ.N L_sp_256_num_bits_8_7_%=\n\t" #endif "MOV r2, #0x100\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_256_num_bits_8_9%=\n\t" +#if defined(__GNUC__) + "B L_sp_256_num_bits_8_9_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_256_num_bits_8_9\n\t" #else - "B.N L_sp_256_num_bits_8_9%=\n\t" + "B.N L_sp_256_num_bits_8_9_%=\n\t" #endif "\n" - "L_sp_256_num_bits_8_7%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_num_bits_8_7:\n\t" +#else + "L_sp_256_num_bits_8_7_%=:\n\t" +#endif "LDR r1, [%[a], #24]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_256_num_bits_8_6%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_256_num_bits_8_6_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_256_num_bits_8_6\n\t" #else - "BEQ.N L_sp_256_num_bits_8_6%=\n\t" + "BEQ.N L_sp_256_num_bits_8_6_%=\n\t" #endif "MOV r2, #0xe0\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_256_num_bits_8_9%=\n\t" +#if defined(__GNUC__) + "B L_sp_256_num_bits_8_9_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_256_num_bits_8_9\n\t" #else - "B.N L_sp_256_num_bits_8_9%=\n\t" + "B.N L_sp_256_num_bits_8_9_%=\n\t" #endif "\n" - "L_sp_256_num_bits_8_6%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_num_bits_8_6:\n\t" +#else + "L_sp_256_num_bits_8_6_%=:\n\t" +#endif "LDR r1, [%[a], #20]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_256_num_bits_8_5%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_256_num_bits_8_5_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_256_num_bits_8_5\n\t" #else - "BEQ.N L_sp_256_num_bits_8_5%=\n\t" + "BEQ.N L_sp_256_num_bits_8_5_%=\n\t" #endif "MOV r2, #0xc0\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_256_num_bits_8_9%=\n\t" +#if defined(__GNUC__) + "B L_sp_256_num_bits_8_9_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_256_num_bits_8_9\n\t" #else - "B.N L_sp_256_num_bits_8_9%=\n\t" + "B.N L_sp_256_num_bits_8_9_%=\n\t" #endif "\n" - "L_sp_256_num_bits_8_5%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_num_bits_8_5:\n\t" +#else + "L_sp_256_num_bits_8_5_%=:\n\t" +#endif "LDR r1, [%[a], #16]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_256_num_bits_8_4%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_256_num_bits_8_4_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_256_num_bits_8_4\n\t" #else - "BEQ.N L_sp_256_num_bits_8_4%=\n\t" + "BEQ.N L_sp_256_num_bits_8_4_%=\n\t" #endif "MOV r2, #0xa0\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_256_num_bits_8_9%=\n\t" +#if defined(__GNUC__) + "B L_sp_256_num_bits_8_9_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_256_num_bits_8_9\n\t" #else - "B.N L_sp_256_num_bits_8_9%=\n\t" + "B.N L_sp_256_num_bits_8_9_%=\n\t" #endif "\n" - "L_sp_256_num_bits_8_4%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_num_bits_8_4:\n\t" +#else + "L_sp_256_num_bits_8_4_%=:\n\t" +#endif "LDR r1, [%[a], #12]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_256_num_bits_8_3%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_256_num_bits_8_3_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_256_num_bits_8_3\n\t" #else - "BEQ.N L_sp_256_num_bits_8_3%=\n\t" + "BEQ.N L_sp_256_num_bits_8_3_%=\n\t" #endif "MOV r2, #0x80\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_256_num_bits_8_9%=\n\t" +#if defined(__GNUC__) + "B L_sp_256_num_bits_8_9_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_256_num_bits_8_9\n\t" #else - "B.N L_sp_256_num_bits_8_9%=\n\t" + "B.N L_sp_256_num_bits_8_9_%=\n\t" #endif "\n" - "L_sp_256_num_bits_8_3%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_num_bits_8_3:\n\t" +#else + "L_sp_256_num_bits_8_3_%=:\n\t" +#endif "LDR r1, [%[a], #8]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_256_num_bits_8_2%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_256_num_bits_8_2_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_256_num_bits_8_2\n\t" #else - "BEQ.N L_sp_256_num_bits_8_2%=\n\t" + "BEQ.N L_sp_256_num_bits_8_2_%=\n\t" #endif "MOV r2, #0x60\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_256_num_bits_8_9%=\n\t" +#if defined(__GNUC__) + "B L_sp_256_num_bits_8_9_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_256_num_bits_8_9\n\t" #else - "B.N L_sp_256_num_bits_8_9%=\n\t" + "B.N L_sp_256_num_bits_8_9_%=\n\t" #endif "\n" - "L_sp_256_num_bits_8_2%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_num_bits_8_2:\n\t" +#else + "L_sp_256_num_bits_8_2_%=:\n\t" +#endif "LDR r1, [%[a], #4]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_256_num_bits_8_1%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_256_num_bits_8_1_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_256_num_bits_8_1\n\t" #else - "BEQ.N L_sp_256_num_bits_8_1%=\n\t" + "BEQ.N L_sp_256_num_bits_8_1_%=\n\t" #endif "MOV r2, #0x40\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_256_num_bits_8_9%=\n\t" +#if defined(__GNUC__) + "B L_sp_256_num_bits_8_9_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_256_num_bits_8_9\n\t" #else - "B.N L_sp_256_num_bits_8_9%=\n\t" + "B.N L_sp_256_num_bits_8_9_%=\n\t" #endif "\n" - "L_sp_256_num_bits_8_1%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_num_bits_8_1:\n\t" +#else + "L_sp_256_num_bits_8_1_%=:\n\t" +#endif "LDR r1, [%[a]]\n\t" "MOV r2, #0x20\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" "\n" - "L_sp_256_num_bits_8_9%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_256_num_bits_8_9:\n\t" +#else + "L_sp_256_num_bits_8_9_%=:\n\t" +#endif "MOV %[a], r4\n\t" : [a] "+r" (a) : @@ -41515,13 +42349,21 @@ static void sp_384_mul_12(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_384_mul_12_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_mul_12_outer:\n\t" +#else + "L_sp_384_mul_12_outer_%=:\n\t" +#endif "SUBS r3, r5, #0x2c\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_384_mul_12_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_mul_12_inner:\n\t" +#else + "L_sp_384_mul_12_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -41537,15 +42379,19 @@ static void sp_384_mul_12(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_384_mul_12_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_384_mul_12_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_384_mul_12_inner_done\n\t" #else - "BGT.N L_sp_384_mul_12_inner_done%=\n\t" + "BGT.N L_sp_384_mul_12_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_384_mul_12_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_384_mul_12_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_384_mul_12_inner\n\t" #else - "BLT.N L_sp_384_mul_12_inner%=\n\t" + "BLT.N L_sp_384_mul_12_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r3]\n\t" @@ -41554,17 +42400,23 @@ static void sp_384_mul_12(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_384_mul_12_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_mul_12_inner_done:\n\t" +#else + "L_sp_384_mul_12_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x54\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_384_mul_12_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_384_mul_12_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_384_mul_12_outer\n\t" #else - "BLE.N L_sp_384_mul_12_outer%=\n\t" + "BLE.N L_sp_384_mul_12_outer_%=\n\t" #endif "LDR lr, [%[a], #44]\n\t" "LDR r11, [%[b], #44]\n\t" @@ -41573,14 +42425,20 @@ static void sp_384_mul_12(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_384_mul_12_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_mul_12_store:\n\t" +#else + "L_sp_384_mul_12_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_384_mul_12_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_384_mul_12_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_384_mul_12_store\n\t" #else - "BGT.N L_sp_384_mul_12_store%=\n\t" + "BGT.N L_sp_384_mul_12_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) : @@ -42643,13 +43501,21 @@ static void sp_384_sqr_12(sp_digit* r, const sp_digit* a) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_384_sqr_12_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_sqr_12_outer:\n\t" +#else + "L_sp_384_sqr_12_outer_%=:\n\t" +#endif "SUBS r3, r5, #0x2c\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_384_sqr_12_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_sqr_12_inner:\n\t" +#else + "L_sp_384_sqr_12_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[a], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -42662,15 +43528,19 @@ static void sp_384_sqr_12(sp_digit* r, const sp_digit* a) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_384_sqr_12_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_384_sqr_12_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_384_sqr_12_inner_done\n\t" #else - "BGT.N L_sp_384_sqr_12_inner_done%=\n\t" + "BGT.N L_sp_384_sqr_12_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_384_sqr_12_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_384_sqr_12_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_384_sqr_12_inner\n\t" #else - "BLT.N L_sp_384_sqr_12_inner%=\n\t" + "BLT.N L_sp_384_sqr_12_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "UMULL r9, r10, lr, lr\n\t" @@ -42678,17 +43548,23 @@ static void sp_384_sqr_12(sp_digit* r, const sp_digit* a) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_384_sqr_12_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_sqr_12_inner_done:\n\t" +#else + "L_sp_384_sqr_12_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x54\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_384_sqr_12_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_384_sqr_12_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_384_sqr_12_outer\n\t" #else - "BLE.N L_sp_384_sqr_12_outer%=\n\t" + "BLE.N L_sp_384_sqr_12_outer_%=\n\t" #endif "LDR lr, [%[a], #44]\n\t" "UMLAL r6, r7, lr, lr\n\t" @@ -42696,14 +43572,20 @@ static void sp_384_sqr_12(sp_digit* r, const sp_digit* a) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_384_sqr_12_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_sqr_12_store:\n\t" +#else + "L_sp_384_sqr_12_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_384_sqr_12_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_384_sqr_12_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_384_sqr_12_store\n\t" #else - "BGT.N L_sp_384_sqr_12_store%=\n\t" + "BGT.N L_sp_384_sqr_12_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a) : @@ -43436,7 +44318,11 @@ static sp_digit sp_384_add_12(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r3, #0x0\n\t" "ADD r12, %[a], #0x30\n\t" "\n" - "L_sp_384_add_12_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_add_12_word:\n\t" +#else + "L_sp_384_add_12_word_%=:\n\t" +#endif "ADDS r3, r3, #0xffffffff\n\t" "LDM %[a]!, {r4, r5, r6, r7}\n\t" "LDM %[b]!, {r8, r9, r10, r11}\n\t" @@ -43448,10 +44334,12 @@ static sp_digit sp_384_add_12(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r4, #0x0\n\t" "ADC r3, r4, #0x0\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_384_add_12_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_384_add_12_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_384_add_12_word\n\t" #else - "BNE.N L_sp_384_add_12_word%=\n\t" + "BNE.N L_sp_384_add_12_word_%=\n\t" #endif "MOV %[r], r3\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -43836,7 +44724,11 @@ static sp_digit sp_384_cond_sub_12(sp_digit* r, const sp_digit* a, const sp_digi "MOV r4, #0x0\n\t" "MOV r5, #0x0\n\t" "\n" - "L_sp_384_cond_sub_12_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_cond_sub_12_words:\n\t" +#else + "L_sp_384_cond_sub_12_words_%=:\n\t" +#endif "SUBS r4, r8, r4\n\t" "LDR r6, [%[a], r5]\n\t" "LDR r7, [%[b], r5]\n\t" @@ -43846,10 +44738,12 @@ static sp_digit sp_384_cond_sub_12(sp_digit* r, const sp_digit* a, const sp_digi "STR r6, [%[r], r5]\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x30\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_384_cond_sub_12_words%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_384_cond_sub_12_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_384_cond_sub_12_words\n\t" #else - "BLT.N L_sp_384_cond_sub_12_words%=\n\t" + "BLT.N L_sp_384_cond_sub_12_words_%=\n\t" #endif "MOV %[r], r4\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b), [m] "+r" (m) @@ -43963,7 +44857,11 @@ SP_NOINLINE static void sp_384_mont_reduce_12(sp_digit* a, const sp_digit* m, sp "LDR r4, [%[a]]\n\t" "LDR r5, [%[a], #4]\n\t" "\n" - "L_sp_384_mont_reduce_12_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_mont_reduce_12_word:\n\t" +#else + "L_sp_384_mont_reduce_12_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL r10, %[mp], r4\n\t" /* a[i+0] += m[0] * mu */ @@ -44065,10 +44963,12 @@ SP_NOINLINE static void sp_384_mont_reduce_12(sp_digit* a, const sp_digit* m, sp "ADD r11, r11, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r11, #0x30\n\t" -#ifdef __GNUC__ - "BLT L_sp_384_mont_reduce_12_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_384_mont_reduce_12_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_384_mont_reduce_12_word\n\t" #else - "BLT.W L_sp_384_mont_reduce_12_word%=\n\t" + "BLT.W L_sp_384_mont_reduce_12_word_%=\n\t" #endif /* Loop Done */ "STR r4, [%[a]]\n\t" @@ -44110,7 +45010,11 @@ SP_NOINLINE static void sp_384_mont_reduce_12(sp_digit* a, const sp_digit* m, sp "LDR r9, [%[a], #12]\n\t" "LDR r10, [%[a], #16]\n\t" "\n" - "L_sp_384_mont_reduce_12_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_mont_reduce_12_word:\n\t" +#else + "L_sp_384_mont_reduce_12_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL lr, %[mp], r6\n\t" /* a[i+0] += m[0] * mu */ @@ -44177,10 +45081,12 @@ SP_NOINLINE static void sp_384_mont_reduce_12(sp_digit* a, const sp_digit* m, sp "ADD r4, r4, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r4, #0x30\n\t" -#ifdef __GNUC__ - "BLT L_sp_384_mont_reduce_12_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_384_mont_reduce_12_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_384_mont_reduce_12_word\n\t" #else - "BLT.W L_sp_384_mont_reduce_12_word%=\n\t" + "BLT.W L_sp_384_mont_reduce_12_word_%=\n\t" #endif /* Loop Done */ "STR r6, [%[a]]\n\t" @@ -44365,7 +45271,11 @@ static sp_int32 sp_384_cmp_12(const sp_digit* a, const sp_digit* b) #ifdef WOLFSSL_SP_SMALL "MOV r6, #0x2c\n\t" "\n" - "L_sp_384_cmp_12_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_cmp_12_words:\n\t" +#else + "L_sp_384_cmp_12_words_%=:\n\t" +#endif "LDR r4, [%[a], r6]\n\t" "LDR r5, [%[b], r6]\n\t" "AND r4, r4, r3\n\t" @@ -44378,7 +45288,7 @@ static sp_int32 sp_384_cmp_12(const sp_digit* a, const sp_digit* b) "IT ne\n\t" "movne r3, r7\n\t" "SUBS r6, r6, #0x4\n\t" - "bcs L_sp_384_cmp_12_words%=\n\t" + "bcs L_sp_384_cmp_12_words\n\t" "EOR r2, r2, r3\n\t" #else "LDR r4, [%[a], #44]\n\t" @@ -44668,7 +45578,11 @@ static sp_digit sp_384_sub_12(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r11, #0x0\n\t" "ADD r12, %[a], #0x30\n\t" "\n" - "L_sp_384_sub_12_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_sub_12_word:\n\t" +#else + "L_sp_384_sub_12_word_%=:\n\t" +#endif "RSBS r11, r11, #0x0\n\t" "LDM %[a]!, {r3, r4, r5, r6}\n\t" "LDM %[b]!, {r7, r8, r9, r10}\n\t" @@ -44679,10 +45593,12 @@ static sp_digit sp_384_sub_12(sp_digit* r, const sp_digit* a, const sp_digit* b) "STM %[r]!, {r3, r4, r5, r6}\n\t" "SBC r11, r3, r3\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_384_sub_12_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_384_sub_12_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_384_sub_12_word\n\t" #else - "BNE.N L_sp_384_sub_12_word%=\n\t" + "BNE.N L_sp_384_sub_12_word_%=\n\t" #endif "MOV %[r], r11\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -44769,7 +45685,11 @@ static sp_digit sp_384_cond_add_12(sp_digit* r, const sp_digit* a, const sp_digi "MOV r8, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_384_cond_add_12_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_cond_add_12_words:\n\t" +#else + "L_sp_384_cond_add_12_words_%=:\n\t" +#endif "ADDS r5, r5, #0xffffffff\n\t" "LDR r6, [%[a], r4]\n\t" "LDR r7, [%[b], r4]\n\t" @@ -44779,10 +45699,12 @@ static sp_digit sp_384_cond_add_12(sp_digit* r, const sp_digit* a, const sp_digi "STR r6, [%[r], r4]\n\t" "ADD r4, r4, #0x4\n\t" "CMP r4, #0x30\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_384_cond_add_12_words%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_384_cond_add_12_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_384_cond_add_12_words\n\t" #else - "BLT.N L_sp_384_cond_add_12_words%=\n\t" + "BLT.N L_sp_384_cond_add_12_words_%=\n\t" #endif "MOV %[r], r5\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b), [m] "+r" (m) @@ -48974,7 +49896,11 @@ static sp_digit sp_384_sub_in_place_12(sp_digit* a, const sp_digit* b) "MOV r10, #0x0\n\t" "ADD r11, %[a], #0x30\n\t" "\n" - "L_sp_384_sub_in_pkace_12_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_sub_in_pkace_12_word:\n\t" +#else + "L_sp_384_sub_in_pkace_12_word_%=:\n\t" +#endif "RSBS r10, r10, #0x0\n\t" "LDM %[a], {r2, r3, r4, r5}\n\t" "LDM %[b]!, {r6, r7, r8, r9}\n\t" @@ -48985,10 +49911,12 @@ static sp_digit sp_384_sub_in_place_12(sp_digit* a, const sp_digit* b) "STM %[a]!, {r2, r3, r4, r5}\n\t" "SBC r10, r10, r10\n\t" "CMP %[a], r11\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_384_sub_in_pkace_12_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_384_sub_in_pkace_12_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_384_sub_in_pkace_12_word\n\t" #else - "BNE.N L_sp_384_sub_in_pkace_12_word%=\n\t" + "BNE.N L_sp_384_sub_in_pkace_12_word_%=\n\t" #endif "MOV %[a], r10\n\t" : [a] "+r" (a), [b] "+r" (b) @@ -49074,7 +50002,11 @@ static void sp_384_mul_d_12(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "MOV r9, #0x4\n\t" "\n" - "L_sp_384_mul_d_12_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_mul_d_12_word:\n\t" +#else + "L_sp_384_mul_d_12_word_%=:\n\t" +#endif /* A[i] * B */ "LDR r8, [%[a], r9]\n\t" "UMULL r6, r7, %[b], r8\n\t" @@ -49087,10 +50019,12 @@ static void sp_384_mul_d_12(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "ADD r9, r9, #0x4\n\t" "CMP r9, #0x30\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_384_mul_d_12_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_384_mul_d_12_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_384_mul_d_12_word\n\t" #else - "BLT.N L_sp_384_mul_d_12_word%=\n\t" + "BLT.N L_sp_384_mul_d_12_word_%=\n\t" #endif "STR r3, [%[r], #48]\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -49288,7 +50222,11 @@ SP_NOINLINE static sp_digit div_384_word_12(sp_digit d1, sp_digit d0, sp_digit d /* Next 30 bits */ "MOV r4, #0x1d\n\t" "\n" - "L_div_384_word_12_bit%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_div_384_word_12_bit:\n\t" +#else + "L_div_384_word_12_bit_%=:\n\t" +#endif "LSLS r6, r6, #1\n\t" "ADC r7, r7, r7\n\t" "SUBS r8, r5, r7\n\t" @@ -49298,7 +50236,13 @@ SP_NOINLINE static sp_digit div_384_word_12(sp_digit d1, sp_digit d0, sp_digit d "AND r8, r8, r5\n\t" "SUBS r7, r7, r8\n\t" "SUBS r4, r4, #0x1\n\t" - "bpl L_div_384_word_12_bit%=\n\t" +#if defined(__GNUC__) + "BPL L_div_384_word_12_bit_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BPL.N L_div_384_word_12_bit\n\t" +#else + "BPL.N L_div_384_word_12_bit_%=\n\t" +#endif "ADD r3, r3, r3\n\t" "ADD r3, r3, #0x1\n\t" "UMULL r6, r7, r3, %[div]\n\t" @@ -49961,10 +50905,12 @@ static void sp_384_div2_mod_12(sp_digit* r, const sp_digit* a, const sp_digit* m __asm__ __volatile__ ( "LDM %[a]!, {r4}\n\t" "ANDS r3, r4, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_384_div2_mod_12_even%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_384_div2_mod_12_even_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_384_div2_mod_12_even\n\t" #else - "BEQ.N L_sp_384_div2_mod_12_even%=\n\t" + "BEQ.N L_sp_384_div2_mod_12_even_%=\n\t" #endif "MOV r12, #0x0\n\t" "LDM %[a]!, {r5, r6, r7}\n\t" @@ -49989,13 +50935,19 @@ static void sp_384_div2_mod_12(sp_digit* r, const sp_digit* a, const sp_digit* m "ADCS r7, r7, r11\n\t" "STM %[r]!, {r4, r5, r6, r7}\n\t" "ADC r3, r12, r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_384_div2_mod_12_div2%=\n\t" +#if defined(__GNUC__) + "B L_sp_384_div2_mod_12_div2_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_384_div2_mod_12_div2\n\t" #else - "B.N L_sp_384_div2_mod_12_div2%=\n\t" + "B.N L_sp_384_div2_mod_12_div2_%=\n\t" #endif "\n" - "L_sp_384_div2_mod_12_even%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_div2_mod_12_even:\n\t" +#else + "L_sp_384_div2_mod_12_even_%=:\n\t" +#endif "LDM %[a]!, {r5, r6, r7}\n\t" "STM %[r]!, {r4, r5, r6, r7}\n\t" "LDM %[a]!, {r4, r5, r6, r7}\n\t" @@ -50003,7 +50955,11 @@ static void sp_384_div2_mod_12(sp_digit* r, const sp_digit* a, const sp_digit* m "LDM %[a]!, {r4, r5, r6, r7}\n\t" "STM %[r]!, {r4, r5, r6, r7}\n\t" "\n" - "L_sp_384_div2_mod_12_div2%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_div2_mod_12_div2:\n\t" +#else + "L_sp_384_div2_mod_12_div2_%=:\n\t" +#endif "SUB %[r], %[r], #0x30\n\t" "LDRD r8, r9, [%[r]]\n\t" "LSR r8, r8, #1\n\t" @@ -50071,197 +51027,289 @@ static int sp_384_num_bits_12(const sp_digit* a) __asm__ __volatile__ ( "LDR r1, [%[a], #44]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_384_num_bits_12_11%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_384_num_bits_12_11_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_384_num_bits_12_11\n\t" #else - "BEQ.N L_sp_384_num_bits_12_11%=\n\t" + "BEQ.N L_sp_384_num_bits_12_11_%=\n\t" #endif "MOV r2, #0x180\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_384_num_bits_12_13%=\n\t" +#if defined(__GNUC__) + "B L_sp_384_num_bits_12_13_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_384_num_bits_12_13\n\t" #else - "B.N L_sp_384_num_bits_12_13%=\n\t" + "B.N L_sp_384_num_bits_12_13_%=\n\t" #endif "\n" - "L_sp_384_num_bits_12_11%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_num_bits_12_11:\n\t" +#else + "L_sp_384_num_bits_12_11_%=:\n\t" +#endif "LDR r1, [%[a], #40]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_384_num_bits_12_10%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_384_num_bits_12_10_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_384_num_bits_12_10\n\t" #else - "BEQ.N L_sp_384_num_bits_12_10%=\n\t" + "BEQ.N L_sp_384_num_bits_12_10_%=\n\t" #endif "MOV r2, #0x160\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_384_num_bits_12_13%=\n\t" +#if defined(__GNUC__) + "B L_sp_384_num_bits_12_13_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_384_num_bits_12_13\n\t" #else - "B.N L_sp_384_num_bits_12_13%=\n\t" + "B.N L_sp_384_num_bits_12_13_%=\n\t" #endif "\n" - "L_sp_384_num_bits_12_10%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_num_bits_12_10:\n\t" +#else + "L_sp_384_num_bits_12_10_%=:\n\t" +#endif "LDR r1, [%[a], #36]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_384_num_bits_12_9%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_384_num_bits_12_9_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_384_num_bits_12_9\n\t" #else - "BEQ.N L_sp_384_num_bits_12_9%=\n\t" + "BEQ.N L_sp_384_num_bits_12_9_%=\n\t" #endif "MOV r2, #0x140\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_384_num_bits_12_13%=\n\t" +#if defined(__GNUC__) + "B L_sp_384_num_bits_12_13_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_384_num_bits_12_13\n\t" #else - "B.N L_sp_384_num_bits_12_13%=\n\t" + "B.N L_sp_384_num_bits_12_13_%=\n\t" #endif "\n" - "L_sp_384_num_bits_12_9%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_num_bits_12_9:\n\t" +#else + "L_sp_384_num_bits_12_9_%=:\n\t" +#endif "LDR r1, [%[a], #32]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_384_num_bits_12_8%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_384_num_bits_12_8_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_384_num_bits_12_8\n\t" #else - "BEQ.N L_sp_384_num_bits_12_8%=\n\t" + "BEQ.N L_sp_384_num_bits_12_8_%=\n\t" #endif "MOV r2, #0x120\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_384_num_bits_12_13%=\n\t" +#if defined(__GNUC__) + "B L_sp_384_num_bits_12_13_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_384_num_bits_12_13\n\t" #else - "B.N L_sp_384_num_bits_12_13%=\n\t" + "B.N L_sp_384_num_bits_12_13_%=\n\t" #endif "\n" - "L_sp_384_num_bits_12_8%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_num_bits_12_8:\n\t" +#else + "L_sp_384_num_bits_12_8_%=:\n\t" +#endif "LDR r1, [%[a], #28]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_384_num_bits_12_7%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_384_num_bits_12_7_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_384_num_bits_12_7\n\t" #else - "BEQ.N L_sp_384_num_bits_12_7%=\n\t" + "BEQ.N L_sp_384_num_bits_12_7_%=\n\t" #endif "MOV r2, #0x100\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_384_num_bits_12_13%=\n\t" +#if defined(__GNUC__) + "B L_sp_384_num_bits_12_13_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_384_num_bits_12_13\n\t" #else - "B.N L_sp_384_num_bits_12_13%=\n\t" + "B.N L_sp_384_num_bits_12_13_%=\n\t" #endif "\n" - "L_sp_384_num_bits_12_7%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_num_bits_12_7:\n\t" +#else + "L_sp_384_num_bits_12_7_%=:\n\t" +#endif "LDR r1, [%[a], #24]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_384_num_bits_12_6%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_384_num_bits_12_6_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_384_num_bits_12_6\n\t" #else - "BEQ.N L_sp_384_num_bits_12_6%=\n\t" + "BEQ.N L_sp_384_num_bits_12_6_%=\n\t" #endif "MOV r2, #0xe0\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_384_num_bits_12_13%=\n\t" +#if defined(__GNUC__) + "B L_sp_384_num_bits_12_13_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_384_num_bits_12_13\n\t" #else - "B.N L_sp_384_num_bits_12_13%=\n\t" + "B.N L_sp_384_num_bits_12_13_%=\n\t" #endif "\n" - "L_sp_384_num_bits_12_6%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_num_bits_12_6:\n\t" +#else + "L_sp_384_num_bits_12_6_%=:\n\t" +#endif "LDR r1, [%[a], #20]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_384_num_bits_12_5%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_384_num_bits_12_5_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_384_num_bits_12_5\n\t" #else - "BEQ.N L_sp_384_num_bits_12_5%=\n\t" + "BEQ.N L_sp_384_num_bits_12_5_%=\n\t" #endif "MOV r2, #0xc0\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_384_num_bits_12_13%=\n\t" +#if defined(__GNUC__) + "B L_sp_384_num_bits_12_13_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_384_num_bits_12_13\n\t" #else - "B.N L_sp_384_num_bits_12_13%=\n\t" + "B.N L_sp_384_num_bits_12_13_%=\n\t" #endif "\n" - "L_sp_384_num_bits_12_5%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_num_bits_12_5:\n\t" +#else + "L_sp_384_num_bits_12_5_%=:\n\t" +#endif "LDR r1, [%[a], #16]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_384_num_bits_12_4%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_384_num_bits_12_4_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_384_num_bits_12_4\n\t" #else - "BEQ.N L_sp_384_num_bits_12_4%=\n\t" + "BEQ.N L_sp_384_num_bits_12_4_%=\n\t" #endif "MOV r2, #0xa0\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_384_num_bits_12_13%=\n\t" +#if defined(__GNUC__) + "B L_sp_384_num_bits_12_13_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_384_num_bits_12_13\n\t" #else - "B.N L_sp_384_num_bits_12_13%=\n\t" + "B.N L_sp_384_num_bits_12_13_%=\n\t" #endif "\n" - "L_sp_384_num_bits_12_4%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_num_bits_12_4:\n\t" +#else + "L_sp_384_num_bits_12_4_%=:\n\t" +#endif "LDR r1, [%[a], #12]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_384_num_bits_12_3%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_384_num_bits_12_3_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_384_num_bits_12_3\n\t" #else - "BEQ.N L_sp_384_num_bits_12_3%=\n\t" + "BEQ.N L_sp_384_num_bits_12_3_%=\n\t" #endif "MOV r2, #0x80\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_384_num_bits_12_13%=\n\t" +#if defined(__GNUC__) + "B L_sp_384_num_bits_12_13_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_384_num_bits_12_13\n\t" #else - "B.N L_sp_384_num_bits_12_13%=\n\t" + "B.N L_sp_384_num_bits_12_13_%=\n\t" #endif "\n" - "L_sp_384_num_bits_12_3%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_num_bits_12_3:\n\t" +#else + "L_sp_384_num_bits_12_3_%=:\n\t" +#endif "LDR r1, [%[a], #8]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_384_num_bits_12_2%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_384_num_bits_12_2_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_384_num_bits_12_2\n\t" #else - "BEQ.N L_sp_384_num_bits_12_2%=\n\t" + "BEQ.N L_sp_384_num_bits_12_2_%=\n\t" #endif "MOV r2, #0x60\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_384_num_bits_12_13%=\n\t" +#if defined(__GNUC__) + "B L_sp_384_num_bits_12_13_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_384_num_bits_12_13\n\t" #else - "B.N L_sp_384_num_bits_12_13%=\n\t" + "B.N L_sp_384_num_bits_12_13_%=\n\t" #endif "\n" - "L_sp_384_num_bits_12_2%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_num_bits_12_2:\n\t" +#else + "L_sp_384_num_bits_12_2_%=:\n\t" +#endif "LDR r1, [%[a], #4]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_384_num_bits_12_1%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_384_num_bits_12_1_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_384_num_bits_12_1\n\t" #else - "BEQ.N L_sp_384_num_bits_12_1%=\n\t" + "BEQ.N L_sp_384_num_bits_12_1_%=\n\t" #endif "MOV r2, #0x40\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_384_num_bits_12_13%=\n\t" +#if defined(__GNUC__) + "B L_sp_384_num_bits_12_13_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_384_num_bits_12_13\n\t" #else - "B.N L_sp_384_num_bits_12_13%=\n\t" + "B.N L_sp_384_num_bits_12_13_%=\n\t" #endif "\n" - "L_sp_384_num_bits_12_1%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_num_bits_12_1:\n\t" +#else + "L_sp_384_num_bits_12_1_%=:\n\t" +#endif "LDR r1, [%[a]]\n\t" "MOV r2, #0x20\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" "\n" - "L_sp_384_num_bits_12_13%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_384_num_bits_12_13:\n\t" +#else + "L_sp_384_num_bits_12_13_%=:\n\t" +#endif "MOV %[a], r4\n\t" : [a] "+r" (a) : @@ -51430,13 +52478,21 @@ static void sp_521_mul_17(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_521_mul_17_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_mul_17_outer:\n\t" +#else + "L_sp_521_mul_17_outer_%=:\n\t" +#endif "SUBS r3, r5, #0x40\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_521_mul_17_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_mul_17_inner:\n\t" +#else + "L_sp_521_mul_17_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -51452,15 +52508,19 @@ static void sp_521_mul_17(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_521_mul_17_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_521_mul_17_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_521_mul_17_inner_done\n\t" #else - "BGT.N L_sp_521_mul_17_inner_done%=\n\t" + "BGT.N L_sp_521_mul_17_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_521_mul_17_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_521_mul_17_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_521_mul_17_inner\n\t" #else - "BLT.N L_sp_521_mul_17_inner%=\n\t" + "BLT.N L_sp_521_mul_17_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r3]\n\t" @@ -51469,17 +52529,23 @@ static void sp_521_mul_17(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_521_mul_17_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_mul_17_inner_done:\n\t" +#else + "L_sp_521_mul_17_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x7c\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_521_mul_17_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_521_mul_17_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_521_mul_17_outer\n\t" #else - "BLE.N L_sp_521_mul_17_outer%=\n\t" + "BLE.N L_sp_521_mul_17_outer_%=\n\t" #endif "LDR lr, [%[a], #64]\n\t" "LDR r11, [%[b], #64]\n\t" @@ -51491,14 +52557,20 @@ static void sp_521_mul_17(sp_digit* r, const sp_digit* a, const sp_digit* b) "STM %[r]!, {r6, r7}\n\t" "SUB r5, r5, #0x8\n\t" "\n" - "L_sp_521_mul_17_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_mul_17_store:\n\t" +#else + "L_sp_521_mul_17_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_521_mul_17_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_521_mul_17_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_521_mul_17_store\n\t" #else - "BGT.N L_sp_521_mul_17_store%=\n\t" + "BGT.N L_sp_521_mul_17_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) : @@ -53575,13 +54647,21 @@ static void sp_521_sqr_17(sp_digit* r, const sp_digit* a) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_521_sqr_17_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_sqr_17_outer:\n\t" +#else + "L_sp_521_sqr_17_outer_%=:\n\t" +#endif "SUBS r3, r5, #0x40\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_521_sqr_17_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_sqr_17_inner:\n\t" +#else + "L_sp_521_sqr_17_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[a], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -53594,15 +54674,19 @@ static void sp_521_sqr_17(sp_digit* r, const sp_digit* a) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_521_sqr_17_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_521_sqr_17_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_521_sqr_17_inner_done\n\t" #else - "BGT.N L_sp_521_sqr_17_inner_done%=\n\t" + "BGT.N L_sp_521_sqr_17_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_521_sqr_17_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_521_sqr_17_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_521_sqr_17_inner\n\t" #else - "BLT.N L_sp_521_sqr_17_inner%=\n\t" + "BLT.N L_sp_521_sqr_17_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "UMULL r9, r10, lr, lr\n\t" @@ -53610,17 +54694,23 @@ static void sp_521_sqr_17(sp_digit* r, const sp_digit* a) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_521_sqr_17_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_sqr_17_inner_done:\n\t" +#else + "L_sp_521_sqr_17_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x7c\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_521_sqr_17_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_521_sqr_17_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_521_sqr_17_outer\n\t" #else - "BLE.N L_sp_521_sqr_17_outer%=\n\t" + "BLE.N L_sp_521_sqr_17_outer_%=\n\t" #endif "LDR lr, [%[a], #64]\n\t" "UMLAL r6, r7, lr, lr\n\t" @@ -53631,14 +54721,20 @@ static void sp_521_sqr_17(sp_digit* r, const sp_digit* a) "STM %[r]!, {r6, r7}\n\t" "SUB r5, r5, #0x8\n\t" "\n" - "L_sp_521_sqr_17_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_sqr_17_store:\n\t" +#else + "L_sp_521_sqr_17_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_521_sqr_17_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_521_sqr_17_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_521_sqr_17_store\n\t" #else - "BGT.N L_sp_521_sqr_17_store%=\n\t" + "BGT.N L_sp_521_sqr_17_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a) : @@ -54955,7 +56051,11 @@ static sp_digit sp_521_add_17(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r3, #0x0\n\t" "ADD r12, %[a], #0x40\n\t" "\n" - "L_sp_521_add_17_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_add_17_word:\n\t" +#else + "L_sp_521_add_17_word_%=:\n\t" +#endif "ADDS r3, r3, #0xffffffff\n\t" "LDM %[a]!, {r4, r5, r6, r7}\n\t" "LDM %[b]!, {r8, r9, r10, r11}\n\t" @@ -54967,10 +56067,12 @@ static sp_digit sp_521_add_17(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r4, #0x0\n\t" "ADC r3, r4, #0x0\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_521_add_17_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_521_add_17_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_521_add_17_word\n\t" #else - "BNE.N L_sp_521_add_17_word%=\n\t" + "BNE.N L_sp_521_add_17_word_%=\n\t" #endif "ADDS r3, r3, #0xffffffff\n\t" "LDM %[a], {r4}\n\t" @@ -55288,7 +56390,11 @@ static sp_digit sp_521_cond_sub_17(sp_digit* r, const sp_digit* a, const sp_digi "MOV r4, #0x0\n\t" "MOV r5, #0x0\n\t" "\n" - "L_sp_521_cond_sub_17_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_cond_sub_17_words:\n\t" +#else + "L_sp_521_cond_sub_17_words_%=:\n\t" +#endif "SUBS r4, r8, r4\n\t" "LDR r6, [%[a], r5]\n\t" "LDR r7, [%[b], r5]\n\t" @@ -55298,10 +56404,12 @@ static sp_digit sp_521_cond_sub_17(sp_digit* r, const sp_digit* a, const sp_digi "STR r6, [%[r], r5]\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x44\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_521_cond_sub_17_words%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_521_cond_sub_17_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_521_cond_sub_17_words\n\t" #else - "BLT.N L_sp_521_cond_sub_17_words%=\n\t" + "BLT.N L_sp_521_cond_sub_17_words_%=\n\t" #endif "MOV %[r], r4\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b), [m] "+r" (m) @@ -55568,19 +56676,29 @@ SP_NOINLINE static void sp_521_mont_reduce_order_17(sp_digit* a, const sp_digit* "LDR r4, [%[a]]\n\t" "LDR r5, [%[a], #4]\n\t" "\n" - "L_sp_521_mont_reduce_order_17_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_mont_reduce_order_17_word:\n\t" +#else + "L_sp_521_mont_reduce_order_17_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL r10, %[mp], r4\n\t" "CMP r11, #0x40\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_521_mont_reduce_order_17_nomask%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_521_mont_reduce_order_17_nomask_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_521_mont_reduce_order_17_nomask\n\t" #else - "BNE.N L_sp_521_mont_reduce_order_17_nomask%=\n\t" + "BNE.N L_sp_521_mont_reduce_order_17_nomask_%=\n\t" #endif "MOV r9, #0x1ff\n\t" "AND r10, r10, r9\n\t" "\n" - "L_sp_521_mont_reduce_order_17_nomask%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_mont_reduce_order_17_nomask:\n\t" +#else + "L_sp_521_mont_reduce_order_17_nomask_%=:\n\t" +#endif /* a[i+0] += m[0] * mu */ "MOV r7, #0x0\n\t" "UMLAL r4, r7, r10, lr\n\t" @@ -55721,10 +56839,12 @@ SP_NOINLINE static void sp_521_mont_reduce_order_17(sp_digit* a, const sp_digit* "ADD r11, r11, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r11, #0x44\n\t" -#ifdef __GNUC__ - "BLT L_sp_521_mont_reduce_order_17_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_521_mont_reduce_order_17_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_521_mont_reduce_order_17_word\n\t" #else - "BLT.W L_sp_521_mont_reduce_order_17_word%=\n\t" + "BLT.W L_sp_521_mont_reduce_order_17_word_%=\n\t" #endif /* Loop Done */ "STR r4, [%[a]]\n\t" @@ -55836,19 +56956,29 @@ SP_NOINLINE static void sp_521_mont_reduce_order_17(sp_digit* a, const sp_digit* "LDR r9, [%[a], #12]\n\t" "LDR r10, [%[a], #16]\n\t" "\n" - "L_sp_521_mont_reduce_order_17_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_mont_reduce_order_17_word:\n\t" +#else + "L_sp_521_mont_reduce_order_17_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL lr, %[mp], r6\n\t" "CMP r4, #0x40\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_521_mont_reduce_order_17_nomask%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_521_mont_reduce_order_17_nomask_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_521_mont_reduce_order_17_nomask\n\t" #else - "BNE.N L_sp_521_mont_reduce_order_17_nomask%=\n\t" + "BNE.N L_sp_521_mont_reduce_order_17_nomask_%=\n\t" #endif "MOV r12, #0x1ff\n\t" "AND lr, lr, r12\n\t" "\n" - "L_sp_521_mont_reduce_order_17_nomask%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_mont_reduce_order_17_nomask:\n\t" +#else + "L_sp_521_mont_reduce_order_17_nomask_%=:\n\t" +#endif /* a[i+0] += m[0] * mu */ "LDR r12, [%[m]]\n\t" "MOV r3, #0x0\n\t" @@ -55939,10 +57069,12 @@ SP_NOINLINE static void sp_521_mont_reduce_order_17(sp_digit* a, const sp_digit* "ADD r4, r4, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r4, #0x44\n\t" -#ifdef __GNUC__ - "BLT L_sp_521_mont_reduce_order_17_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_521_mont_reduce_order_17_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_521_mont_reduce_order_17_word\n\t" #else - "BLT.W L_sp_521_mont_reduce_order_17_word%=\n\t" + "BLT.W L_sp_521_mont_reduce_order_17_word_%=\n\t" #endif /* Loop Done */ "STR r6, [%[a]]\n\t" @@ -56194,7 +57326,11 @@ static sp_int32 sp_521_cmp_17(const sp_digit* a, const sp_digit* b) #ifdef WOLFSSL_SP_SMALL "MOV r6, #0x40\n\t" "\n" - "L_sp_521_cmp_17_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_cmp_17_words:\n\t" +#else + "L_sp_521_cmp_17_words_%=:\n\t" +#endif "LDR r4, [%[a], r6]\n\t" "LDR r5, [%[b], r6]\n\t" "AND r4, r4, r3\n\t" @@ -56207,7 +57343,7 @@ static sp_int32 sp_521_cmp_17(const sp_digit* a, const sp_digit* b) "IT ne\n\t" "movne r3, r7\n\t" "SUBS r6, r6, #0x4\n\t" - "bcs L_sp_521_cmp_17_words%=\n\t" + "bcs L_sp_521_cmp_17_words\n\t" "EOR r2, r2, r3\n\t" #else "LDR r4, [%[a], #64]\n\t" @@ -61995,7 +63131,11 @@ static sp_digit sp_521_sub_in_place_17(sp_digit* a, const sp_digit* b) "MOV r10, #0x0\n\t" "ADD r11, %[a], #0x40\n\t" "\n" - "L_sp_521_sub_in_pkace_17_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_sub_in_pkace_17_word:\n\t" +#else + "L_sp_521_sub_in_pkace_17_word_%=:\n\t" +#endif "RSBS r10, r10, #0x0\n\t" "LDM %[a], {r2, r3, r4, r5}\n\t" "LDM %[b]!, {r6, r7, r8, r9}\n\t" @@ -62006,10 +63146,12 @@ static sp_digit sp_521_sub_in_place_17(sp_digit* a, const sp_digit* b) "STM %[a]!, {r2, r3, r4, r5}\n\t" "SBC r10, r10, r10\n\t" "CMP %[a], r11\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_521_sub_in_pkace_17_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_521_sub_in_pkace_17_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_521_sub_in_pkace_17_word\n\t" #else - "BNE.N L_sp_521_sub_in_pkace_17_word%=\n\t" + "BNE.N L_sp_521_sub_in_pkace_17_word_%=\n\t" #endif "RSBS r10, r10, #0x0\n\t" "LDM %[a], {r2}\n\t" @@ -62111,7 +63253,11 @@ static void sp_521_mul_d_17(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "MOV r9, #0x4\n\t" "\n" - "L_sp_521_mul_d_17_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_mul_d_17_word:\n\t" +#else + "L_sp_521_mul_d_17_word_%=:\n\t" +#endif /* A[i] * B */ "LDR r8, [%[a], r9]\n\t" "UMULL r6, r7, %[b], r8\n\t" @@ -62124,10 +63270,12 @@ static void sp_521_mul_d_17(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "ADD r9, r9, #0x4\n\t" "CMP r9, #0x44\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_521_mul_d_17_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_521_mul_d_17_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_521_mul_d_17_word\n\t" #else - "BLT.N L_sp_521_mul_d_17_word%=\n\t" + "BLT.N L_sp_521_mul_d_17_word_%=\n\t" #endif "STR r3, [%[r], #68]\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -62350,7 +63498,11 @@ SP_NOINLINE static sp_digit div_521_word_17(sp_digit d1, sp_digit d0, sp_digit d /* Next 30 bits */ "MOV r4, #0x1d\n\t" "\n" - "L_div_521_word_17_bit%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_div_521_word_17_bit:\n\t" +#else + "L_div_521_word_17_bit_%=:\n\t" +#endif "LSLS r6, r6, #1\n\t" "ADC r7, r7, r7\n\t" "SUBS r8, r5, r7\n\t" @@ -62360,7 +63512,13 @@ SP_NOINLINE static sp_digit div_521_word_17(sp_digit d1, sp_digit d0, sp_digit d "AND r8, r8, r5\n\t" "SUBS r7, r7, r8\n\t" "SUBS r4, r4, #0x1\n\t" - "bpl L_div_521_word_17_bit%=\n\t" +#if defined(__GNUC__) + "BPL L_div_521_word_17_bit_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BPL.N L_div_521_word_17_bit\n\t" +#else + "BPL.N L_div_521_word_17_bit_%=\n\t" +#endif "ADD r3, r3, r3\n\t" "ADD r3, r3, #0x1\n\t" "UMULL r6, r7, r3, %[div]\n\t" @@ -63055,7 +64213,11 @@ static sp_digit sp_521_sub_17(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r11, #0x0\n\t" "ADD r12, %[a], #0x40\n\t" "\n" - "L_sp_521_sub_17_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_sub_17_word:\n\t" +#else + "L_sp_521_sub_17_word_%=:\n\t" +#endif "RSBS r11, r11, #0x0\n\t" "LDM %[a]!, {r3, r4, r5, r6}\n\t" "LDM %[b]!, {r7, r8, r9, r10}\n\t" @@ -63066,10 +64228,12 @@ static sp_digit sp_521_sub_17(sp_digit* r, const sp_digit* a, const sp_digit* b) "STM %[r]!, {r3, r4, r5, r6}\n\t" "SBC r11, r3, r3\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_521_sub_17_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_521_sub_17_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_521_sub_17_word\n\t" #else - "BNE.N L_sp_521_sub_17_word%=\n\t" + "BNE.N L_sp_521_sub_17_word_%=\n\t" #endif "RSBS r11, r11, #0x0\n\t" "LDM %[a]!, {r3}\n\t" @@ -63166,10 +64330,12 @@ static void sp_521_div2_mod_17(sp_digit* r, const sp_digit* a, const sp_digit* m __asm__ __volatile__ ( "LDM %[a]!, {r4}\n\t" "ANDS r3, r4, #0x1\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_div2_mod_17_even%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_div2_mod_17_even_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_div2_mod_17_even\n\t" #else - "BEQ.N L_sp_521_div2_mod_17_even%=\n\t" + "BEQ.N L_sp_521_div2_mod_17_even_%=\n\t" #endif "MOV r12, #0x0\n\t" "LDM %[a]!, {r5, r6, r7}\n\t" @@ -63205,13 +64371,19 @@ static void sp_521_div2_mod_17(sp_digit* r, const sp_digit* a, const sp_digit* m "ADCS r4, r4, r8\n\t" "STM %[r]!, {r4}\n\t" "ADC r3, r12, r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_div2_mod_17_div2%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_div2_mod_17_div2_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_div2_mod_17_div2\n\t" #else - "B.N L_sp_521_div2_mod_17_div2%=\n\t" + "B.N L_sp_521_div2_mod_17_div2_%=\n\t" #endif "\n" - "L_sp_521_div2_mod_17_even%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_div2_mod_17_even:\n\t" +#else + "L_sp_521_div2_mod_17_even_%=:\n\t" +#endif "LDM %[a]!, {r5, r6, r7}\n\t" "STM %[r]!, {r4, r5, r6, r7}\n\t" "LDM %[a]!, {r4, r5, r6, r7}\n\t" @@ -63223,7 +64395,11 @@ static void sp_521_div2_mod_17(sp_digit* r, const sp_digit* a, const sp_digit* m "LDM %[a]!, {r4}\n\t" "STM %[r]!, {r4}\n\t" "\n" - "L_sp_521_div2_mod_17_div2%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_div2_mod_17_div2:\n\t" +#else + "L_sp_521_div2_mod_17_div2_%=:\n\t" +#endif "SUB %[r], %[r], #0x44\n\t" "LDRD r8, r9, [%[r]]\n\t" "LSR r8, r8, #1\n\t" @@ -63311,282 +64487,414 @@ static int sp_521_num_bits_17(const sp_digit* a) __asm__ __volatile__ ( "LDR r1, [%[a], #64]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_16%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_16_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_16\n\t" #else - "BEQ.N L_sp_521_num_bits_17_16%=\n\t" + "BEQ.N L_sp_521_num_bits_17_16_%=\n\t" #endif "MOV r2, #0x220\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_16%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_16:\n\t" +#else + "L_sp_521_num_bits_17_16_%=:\n\t" +#endif "LDR r1, [%[a], #60]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_15%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_15_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_15\n\t" #else - "BEQ.N L_sp_521_num_bits_17_15%=\n\t" + "BEQ.N L_sp_521_num_bits_17_15_%=\n\t" #endif "MOV r2, #0x200\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_15%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_15:\n\t" +#else + "L_sp_521_num_bits_17_15_%=:\n\t" +#endif "LDR r1, [%[a], #56]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_14%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_14_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_14\n\t" #else - "BEQ.N L_sp_521_num_bits_17_14%=\n\t" + "BEQ.N L_sp_521_num_bits_17_14_%=\n\t" #endif "MOV r2, #0x1e0\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_14%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_14:\n\t" +#else + "L_sp_521_num_bits_17_14_%=:\n\t" +#endif "LDR r1, [%[a], #52]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_13%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_13_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_13\n\t" #else - "BEQ.N L_sp_521_num_bits_17_13%=\n\t" + "BEQ.N L_sp_521_num_bits_17_13_%=\n\t" #endif "MOV r2, #0x1c0\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_13%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_13:\n\t" +#else + "L_sp_521_num_bits_17_13_%=:\n\t" +#endif "LDR r1, [%[a], #48]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_12%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_12_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_12\n\t" #else - "BEQ.N L_sp_521_num_bits_17_12%=\n\t" + "BEQ.N L_sp_521_num_bits_17_12_%=\n\t" #endif "MOV r2, #0x1a0\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_12%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_12:\n\t" +#else + "L_sp_521_num_bits_17_12_%=:\n\t" +#endif "LDR r1, [%[a], #44]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_11%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_11_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_11\n\t" #else - "BEQ.N L_sp_521_num_bits_17_11%=\n\t" + "BEQ.N L_sp_521_num_bits_17_11_%=\n\t" #endif "MOV r2, #0x180\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_11%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_11:\n\t" +#else + "L_sp_521_num_bits_17_11_%=:\n\t" +#endif "LDR r1, [%[a], #40]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_10%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_10_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_10\n\t" #else - "BEQ.N L_sp_521_num_bits_17_10%=\n\t" + "BEQ.N L_sp_521_num_bits_17_10_%=\n\t" #endif "MOV r2, #0x160\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_10%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_10:\n\t" +#else + "L_sp_521_num_bits_17_10_%=:\n\t" +#endif "LDR r1, [%[a], #36]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_9%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_9_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_9\n\t" #else - "BEQ.N L_sp_521_num_bits_17_9%=\n\t" + "BEQ.N L_sp_521_num_bits_17_9_%=\n\t" #endif "MOV r2, #0x140\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_9%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_9:\n\t" +#else + "L_sp_521_num_bits_17_9_%=:\n\t" +#endif "LDR r1, [%[a], #32]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_8%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_8_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_8\n\t" #else - "BEQ.N L_sp_521_num_bits_17_8%=\n\t" + "BEQ.N L_sp_521_num_bits_17_8_%=\n\t" #endif "MOV r2, #0x120\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_8%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_8:\n\t" +#else + "L_sp_521_num_bits_17_8_%=:\n\t" +#endif "LDR r1, [%[a], #28]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_7%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_7_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_7\n\t" #else - "BEQ.N L_sp_521_num_bits_17_7%=\n\t" + "BEQ.N L_sp_521_num_bits_17_7_%=\n\t" #endif "MOV r2, #0x100\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_7%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_7:\n\t" +#else + "L_sp_521_num_bits_17_7_%=:\n\t" +#endif "LDR r1, [%[a], #24]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_6%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_6_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_6\n\t" #else - "BEQ.N L_sp_521_num_bits_17_6%=\n\t" + "BEQ.N L_sp_521_num_bits_17_6_%=\n\t" #endif "MOV r2, #0xe0\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_6%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_6:\n\t" +#else + "L_sp_521_num_bits_17_6_%=:\n\t" +#endif "LDR r1, [%[a], #20]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_5%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_5_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_5\n\t" #else - "BEQ.N L_sp_521_num_bits_17_5%=\n\t" + "BEQ.N L_sp_521_num_bits_17_5_%=\n\t" #endif "MOV r2, #0xc0\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_5%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_5:\n\t" +#else + "L_sp_521_num_bits_17_5_%=:\n\t" +#endif "LDR r1, [%[a], #16]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_4%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_4_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_4\n\t" #else - "BEQ.N L_sp_521_num_bits_17_4%=\n\t" + "BEQ.N L_sp_521_num_bits_17_4_%=\n\t" #endif "MOV r2, #0xa0\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_4%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_4:\n\t" +#else + "L_sp_521_num_bits_17_4_%=:\n\t" +#endif "LDR r1, [%[a], #12]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_3%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_3_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_3\n\t" #else - "BEQ.N L_sp_521_num_bits_17_3%=\n\t" + "BEQ.N L_sp_521_num_bits_17_3_%=\n\t" #endif "MOV r2, #0x80\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_3%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_3:\n\t" +#else + "L_sp_521_num_bits_17_3_%=:\n\t" +#endif "LDR r1, [%[a], #8]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_2%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_2_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_2\n\t" #else - "BEQ.N L_sp_521_num_bits_17_2%=\n\t" + "BEQ.N L_sp_521_num_bits_17_2_%=\n\t" #endif "MOV r2, #0x60\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_2%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_2:\n\t" +#else + "L_sp_521_num_bits_17_2_%=:\n\t" +#endif "LDR r1, [%[a], #4]\n\t" "CMP r1, #0x0\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BEQ L_sp_521_num_bits_17_1%=\n\t" +#if defined(__GNUC__) + "BEQ L_sp_521_num_bits_17_1_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BEQ.N L_sp_521_num_bits_17_1\n\t" #else - "BEQ.N L_sp_521_num_bits_17_1%=\n\t" + "BEQ.N L_sp_521_num_bits_17_1_%=\n\t" #endif "MOV r2, #0x40\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "B L_sp_521_num_bits_17_18%=\n\t" +#if defined(__GNUC__) + "B L_sp_521_num_bits_17_18_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "B.N L_sp_521_num_bits_17_18\n\t" #else - "B.N L_sp_521_num_bits_17_18%=\n\t" + "B.N L_sp_521_num_bits_17_18_%=\n\t" #endif "\n" - "L_sp_521_num_bits_17_1%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_1:\n\t" +#else + "L_sp_521_num_bits_17_1_%=:\n\t" +#endif "LDR r1, [%[a]]\n\t" "MOV r2, #0x20\n\t" "CLZ r4, r1\n\t" "SUB r4, r2, r4\n\t" "\n" - "L_sp_521_num_bits_17_18%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_521_num_bits_17_18:\n\t" +#else + "L_sp_521_num_bits_17_18_%=:\n\t" +#endif "MOV %[a], r4\n\t" : [a] "+r" (a) : @@ -67981,13 +69289,21 @@ static void sp_1024_mul_32(sp_digit* r, const sp_digit* a, const sp_digit* b) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_1024_mul_32_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_mul_32_outer:\n\t" +#else + "L_sp_1024_mul_32_outer_%=:\n\t" +#endif "SUBS r3, r5, #0x7c\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_1024_mul_32_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_mul_32_inner:\n\t" +#else + "L_sp_1024_mul_32_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -68003,15 +69319,19 @@ static void sp_1024_mul_32(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_1024_mul_32_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_1024_mul_32_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_1024_mul_32_inner_done\n\t" #else - "BGT.N L_sp_1024_mul_32_inner_done%=\n\t" + "BGT.N L_sp_1024_mul_32_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_1024_mul_32_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_1024_mul_32_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_1024_mul_32_inner\n\t" #else - "BLT.N L_sp_1024_mul_32_inner%=\n\t" + "BLT.N L_sp_1024_mul_32_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[b], r3]\n\t" @@ -68020,17 +69340,23 @@ static void sp_1024_mul_32(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_1024_mul_32_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_mul_32_inner_done:\n\t" +#else + "L_sp_1024_mul_32_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0xf4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_1024_mul_32_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_1024_mul_32_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_1024_mul_32_outer\n\t" #else - "BLE.N L_sp_1024_mul_32_outer%=\n\t" + "BLE.N L_sp_1024_mul_32_outer_%=\n\t" #endif "LDR lr, [%[a], #124]\n\t" "LDR r11, [%[b], #124]\n\t" @@ -68039,14 +69365,20 @@ static void sp_1024_mul_32(sp_digit* r, const sp_digit* a, const sp_digit* b) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_1024_mul_32_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_mul_32_store:\n\t" +#else + "L_sp_1024_mul_32_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_1024_mul_32_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_1024_mul_32_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_1024_mul_32_store\n\t" #else - "BGT.N L_sp_1024_mul_32_store%=\n\t" + "BGT.N L_sp_1024_mul_32_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) : @@ -68079,13 +69411,21 @@ static void sp_1024_sqr_32(sp_digit* r, const sp_digit* a) "MOV r8, #0x0\n\t" "MOV r5, #0x4\n\t" "\n" - "L_sp_1024_sqr_32_outer%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_sqr_32_outer:\n\t" +#else + "L_sp_1024_sqr_32_outer_%=:\n\t" +#endif "SUBS r3, r5, #0x7c\n\t" "IT cc\n\t" "MOVCC r3, #0x0\n\t" "SUB r4, r5, r3\n\t" "\n" - "L_sp_1024_sqr_32_inner%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_sqr_32_inner:\n\t" +#else + "L_sp_1024_sqr_32_inner_%=:\n\t" +#endif "LDR lr, [%[a], r3]\n\t" "LDR r11, [%[a], r4]\n\t" "UMULL r9, r10, lr, r11\n\t" @@ -68098,15 +69438,19 @@ static void sp_1024_sqr_32(sp_digit* r, const sp_digit* a) "ADD r3, r3, #0x4\n\t" "SUB r4, r4, #0x4\n\t" "CMP r3, r4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_1024_sqr_32_inner_done%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_1024_sqr_32_inner_done_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_1024_sqr_32_inner_done\n\t" #else - "BGT.N L_sp_1024_sqr_32_inner_done%=\n\t" + "BGT.N L_sp_1024_sqr_32_inner_done_%=\n\t" #endif -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_1024_sqr_32_inner%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_1024_sqr_32_inner_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_1024_sqr_32_inner\n\t" #else - "BLT.N L_sp_1024_sqr_32_inner%=\n\t" + "BLT.N L_sp_1024_sqr_32_inner_%=\n\t" #endif "LDR lr, [%[a], r3]\n\t" "UMULL r9, r10, lr, lr\n\t" @@ -68114,17 +69458,23 @@ static void sp_1024_sqr_32(sp_digit* r, const sp_digit* a) "ADCS r7, r7, r10\n\t" "ADC r8, r8, #0x0\n\t" "\n" - "L_sp_1024_sqr_32_inner_done%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_sqr_32_inner_done:\n\t" +#else + "L_sp_1024_sqr_32_inner_done_%=:\n\t" +#endif "STR r6, [sp, r5]\n\t" "MOV r6, r7\n\t" "MOV r7, r8\n\t" "MOV r8, #0x0\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0xf4\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLE L_sp_1024_sqr_32_outer%=\n\t" +#if defined(__GNUC__) + "BLE L_sp_1024_sqr_32_outer_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLE.N L_sp_1024_sqr_32_outer\n\t" #else - "BLE.N L_sp_1024_sqr_32_outer%=\n\t" + "BLE.N L_sp_1024_sqr_32_outer_%=\n\t" #endif "LDR lr, [%[a], #124]\n\t" "UMLAL r6, r7, lr, lr\n\t" @@ -68132,14 +69482,20 @@ static void sp_1024_sqr_32(sp_digit* r, const sp_digit* a) "ADD r5, r5, #0x4\n\t" "STR r7, [sp, r5]\n\t" "\n" - "L_sp_1024_sqr_32_store%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_sqr_32_store:\n\t" +#else + "L_sp_1024_sqr_32_store_%=:\n\t" +#endif "LDM sp!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "STM %[r]!, {r3, r4, r6, r7, r8, r9, r10, r11}\n\t" "SUBS r5, r5, #0x20\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BGT L_sp_1024_sqr_32_store%=\n\t" +#if defined(__GNUC__) + "BGT L_sp_1024_sqr_32_store_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BGT.N L_sp_1024_sqr_32_store\n\t" #else - "BGT.N L_sp_1024_sqr_32_store%=\n\t" + "BGT.N L_sp_1024_sqr_32_store_%=\n\t" #endif : [r] "+r" (r), [a] "+r" (a) : @@ -68254,7 +69610,11 @@ static sp_digit sp_1024_sub_in_place_32(sp_digit* a, const sp_digit* b) "MOV r10, #0x0\n\t" "ADD r11, %[a], #0x80\n\t" "\n" - "L_sp_1024_sub_in_pkace_32_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_sub_in_pkace_32_word:\n\t" +#else + "L_sp_1024_sub_in_pkace_32_word_%=:\n\t" +#endif "RSBS r10, r10, #0x0\n\t" "LDM %[a], {r2, r3, r4, r5}\n\t" "LDM %[b]!, {r6, r7, r8, r9}\n\t" @@ -68265,10 +69625,12 @@ static sp_digit sp_1024_sub_in_place_32(sp_digit* a, const sp_digit* b) "STM %[a]!, {r2, r3, r4, r5}\n\t" "SBC r10, r10, r10\n\t" "CMP %[a], r11\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_1024_sub_in_pkace_32_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_1024_sub_in_pkace_32_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_1024_sub_in_pkace_32_word\n\t" #else - "BNE.N L_sp_1024_sub_in_pkace_32_word%=\n\t" + "BNE.N L_sp_1024_sub_in_pkace_32_word_%=\n\t" #endif "MOV %[a], r10\n\t" : [a] "+r" (a), [b] "+r" (b) @@ -68306,7 +69668,11 @@ static sp_digit sp_1024_cond_sub_32(sp_digit* r, const sp_digit* a, const sp_dig "MOV r4, #0x0\n\t" "MOV r5, #0x0\n\t" "\n" - "L_sp_1024_cond_sub_32_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_cond_sub_32_words:\n\t" +#else + "L_sp_1024_cond_sub_32_words_%=:\n\t" +#endif "SUBS r4, r8, r4\n\t" "LDR r6, [%[a], r5]\n\t" "LDR r7, [%[b], r5]\n\t" @@ -68316,10 +69682,12 @@ static sp_digit sp_1024_cond_sub_32(sp_digit* r, const sp_digit* a, const sp_dig "STR r6, [%[r], r5]\n\t" "ADD r5, r5, #0x4\n\t" "CMP r5, #0x80\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_1024_cond_sub_32_words%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_1024_cond_sub_32_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_1024_cond_sub_32_words\n\t" #else - "BLT.N L_sp_1024_cond_sub_32_words%=\n\t" + "BLT.N L_sp_1024_cond_sub_32_words_%=\n\t" #endif "MOV %[r], r4\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b), [m] "+r" (m) @@ -68497,7 +69865,11 @@ static sp_digit sp_1024_add_32(sp_digit* r, const sp_digit* a, const sp_digit* b "MOV r3, #0x0\n\t" "ADD r12, %[a], #0x80\n\t" "\n" - "L_sp_1024_add_32_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_add_32_word:\n\t" +#else + "L_sp_1024_add_32_word_%=:\n\t" +#endif "ADDS r3, r3, #0xffffffff\n\t" "LDM %[a]!, {r4, r5, r6, r7}\n\t" "LDM %[b]!, {r8, r9, r10, r11}\n\t" @@ -68509,10 +69881,12 @@ static sp_digit sp_1024_add_32(sp_digit* r, const sp_digit* a, const sp_digit* b "MOV r4, #0x0\n\t" "ADC r3, r4, #0x0\n\t" "CMP %[a], r12\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BNE L_sp_1024_add_32_word%=\n\t" +#if defined(__GNUC__) + "BNE L_sp_1024_add_32_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BNE.N L_sp_1024_add_32_word\n\t" #else - "BNE.N L_sp_1024_add_32_word%=\n\t" + "BNE.N L_sp_1024_add_32_word_%=\n\t" #endif "MOV %[r], r3\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -68551,7 +69925,11 @@ static void sp_1024_mul_d_32(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "MOV r9, #0x4\n\t" "\n" - "L_sp_1024_mul_d_32_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_mul_d_32_word:\n\t" +#else + "L_sp_1024_mul_d_32_word_%=:\n\t" +#endif /* A[i] * B */ "LDR r8, [%[a], r9]\n\t" "UMULL r6, r7, %[b], r8\n\t" @@ -68564,10 +69942,12 @@ static void sp_1024_mul_d_32(sp_digit* r, const sp_digit* a, sp_digit b) "MOV r5, #0x0\n\t" "ADD r9, r9, #0x4\n\t" "CMP r9, #0x80\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_1024_mul_d_32_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_1024_mul_d_32_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_1024_mul_d_32_word\n\t" #else - "BLT.N L_sp_1024_mul_d_32_word%=\n\t" + "BLT.N L_sp_1024_mul_d_32_word_%=\n\t" #endif "STR r3, [%[r], #128]\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b) @@ -68865,7 +70245,11 @@ SP_NOINLINE static sp_digit div_1024_word_32(sp_digit d1, sp_digit d0, sp_digit /* Next 30 bits */ "MOV r4, #0x1d\n\t" "\n" - "L_div_1024_word_32_bit%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_div_1024_word_32_bit:\n\t" +#else + "L_div_1024_word_32_bit_%=:\n\t" +#endif "LSLS r6, r6, #1\n\t" "ADC r7, r7, r7\n\t" "SUBS r8, r5, r7\n\t" @@ -68875,7 +70259,13 @@ SP_NOINLINE static sp_digit div_1024_word_32(sp_digit d1, sp_digit d0, sp_digit "AND r8, r8, r5\n\t" "SUBS r7, r7, r8\n\t" "SUBS r4, r4, #0x1\n\t" - "bpl L_div_1024_word_32_bit%=\n\t" +#if defined(__GNUC__) + "BPL L_div_1024_word_32_bit_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BPL.N L_div_1024_word_32_bit\n\t" +#else + "BPL.N L_div_1024_word_32_bit_%=\n\t" +#endif "ADD r3, r3, r3\n\t" "ADD r3, r3, #0x1\n\t" "UMULL r6, r7, r3, %[div]\n\t" @@ -68957,7 +70347,11 @@ static sp_int32 sp_1024_cmp_32(const sp_digit* a, const sp_digit* b) #ifdef WOLFSSL_SP_SMALL "MOV r6, #0x7c\n\t" "\n" - "L_sp_1024_cmp_32_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_cmp_32_words:\n\t" +#else + "L_sp_1024_cmp_32_words_%=:\n\t" +#endif "LDR r4, [%[a], r6]\n\t" "LDR r5, [%[b], r6]\n\t" "AND r4, r4, r3\n\t" @@ -68970,7 +70364,7 @@ static sp_int32 sp_1024_cmp_32(const sp_digit* a, const sp_digit* b) "IT ne\n\t" "movne r3, r7\n\t" "SUBS r6, r6, #0x4\n\t" - "bcs L_sp_1024_cmp_32_words%=\n\t" + "bcs L_sp_1024_cmp_32_words\n\t" "EOR r2, r2, r3\n\t" #else "LDR r4, [%[a], #124]\n\t" @@ -69690,7 +71084,11 @@ SP_NOINLINE static void sp_1024_mont_reduce_32(sp_digit* a, const sp_digit* m, s "LDR r4, [%[a]]\n\t" "LDR r5, [%[a], #4]\n\t" "\n" - "L_sp_1024_mont_reduce_32_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_mont_reduce_32_word:\n\t" +#else + "L_sp_1024_mont_reduce_32_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL r10, %[mp], r4\n\t" /* a[i+0] += m[0] * mu */ @@ -69952,10 +71350,12 @@ SP_NOINLINE static void sp_1024_mont_reduce_32(sp_digit* a, const sp_digit* m, s "ADD r11, r11, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r11, #0x80\n\t" -#ifdef __GNUC__ - "BLT L_sp_1024_mont_reduce_32_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_1024_mont_reduce_32_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_1024_mont_reduce_32_word\n\t" #else - "BLT.W L_sp_1024_mont_reduce_32_word%=\n\t" + "BLT.W L_sp_1024_mont_reduce_32_word_%=\n\t" #endif /* Loop Done */ "STR r4, [%[a]]\n\t" @@ -70002,7 +71402,11 @@ SP_NOINLINE static void sp_1024_mont_reduce_32(sp_digit* a, const sp_digit* m, s "LDR r9, [%[a], #12]\n\t" "LDR r10, [%[a], #16]\n\t" "\n" - "L_sp_1024_mont_reduce_32_word%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_mont_reduce_32_word:\n\t" +#else + "L_sp_1024_mont_reduce_32_word_%=:\n\t" +#endif /* mu = a[i] * mp */ "MUL lr, %[mp], r6\n\t" /* a[i+0] += m[0] * mu */ @@ -70169,10 +71573,12 @@ SP_NOINLINE static void sp_1024_mont_reduce_32(sp_digit* a, const sp_digit* m, s "ADD r4, r4, #0x4\n\t" "ADD %[a], %[a], #0x4\n\t" "CMP r4, #0x80\n\t" -#ifdef __GNUC__ - "BLT L_sp_1024_mont_reduce_32_word%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_1024_mont_reduce_32_word_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.W L_sp_1024_mont_reduce_32_word\n\t" #else - "BLT.W L_sp_1024_mont_reduce_32_word%=\n\t" + "BLT.W L_sp_1024_mont_reduce_32_word_%=\n\t" #endif /* Loop Done */ "STR r6, [%[a]]\n\t" @@ -71187,7 +72593,11 @@ static sp_digit sp_1024_cond_add_32(sp_digit* r, const sp_digit* a, const sp_dig "MOV r8, #0x0\n\t" "MOV r4, #0x0\n\t" "\n" - "L_sp_1024_cond_add_32_words%=:\n\t" +#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "L_sp_1024_cond_add_32_words:\n\t" +#else + "L_sp_1024_cond_add_32_words_%=:\n\t" +#endif "ADDS r5, r5, #0xffffffff\n\t" "LDR r6, [%[a], r4]\n\t" "LDR r7, [%[b], r4]\n\t" @@ -71197,10 +72607,12 @@ static sp_digit sp_1024_cond_add_32(sp_digit* r, const sp_digit* a, const sp_dig "STR r6, [%[r], r4]\n\t" "ADD r4, r4, #0x4\n\t" "CMP r4, #0x80\n\t" -#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__) - "BLT L_sp_1024_cond_add_32_words%=\n\t" +#if defined(__GNUC__) + "BLT L_sp_1024_cond_add_32_words_%=\n\t" +#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000) + "BLT.N L_sp_1024_cond_add_32_words\n\t" #else - "BLT.N L_sp_1024_cond_add_32_words%=\n\t" + "BLT.N L_sp_1024_cond_add_32_words_%=\n\t" #endif "MOV %[r], r5\n\t" : [r] "+r" (r), [a] "+r" (a), [b] "+r" (b), [m] "+r" (m) diff --git a/wolfcrypt/src/sp_dsp32.c b/wolfcrypt/src/sp_dsp32.c index d3b1745df5..8522fdaeab 100644 --- a/wolfcrypt/src/sp_dsp32.c +++ b/wolfcrypt/src/sp_dsp32.c @@ -1,6 +1,6 @@ /* sp_cdsp_signed.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index 3a6884a337..b1d18d5549 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -1,6 +1,6 @@ /* sp_int.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -210,9 +210,10 @@ This library provides single precision (SP) integer math functions. /* Declare a variable that will be assigned a value on XMALLOC. */ -#define DECL_DYN_SP_INT_ARRAY(n, s, c) \ - sp_int* n##d = NULL; \ - sp_int* (n)[c] = { NULL, } +#define DECL_DYN_SP_INT_ARRAY(n, s, c) \ + sp_int* n##d = NULL; \ + sp_int* (n)[c]; \ + void *n ## _dummy_var = XMEMSET(n, 0, sizeof(n)) /* DECL_SP_INT_ARRAY: Declare array of 'sp_int'. */ #if (defined(WOLFSSL_SMALL_STACK) || defined(SP_ALLOC)) && \ @@ -240,6 +241,7 @@ This library provides single precision (SP) integer math functions. */ #define ALLOC_DYN_SP_INT_ARRAY(n, s, c, err, h) \ do { \ + (void)n ## _dummy_var; \ if (((err) == MP_OKAY) && ((s) > SP_INT_DIGITS)) { \ (err) = MP_VAL; \ } \ diff --git a/wolfcrypt/src/sp_sm2_arm32.c b/wolfcrypt/src/sp_sm2_arm32.c index 211b143920..4dc5377509 100644 --- a/wolfcrypt/src/sp_sm2_arm32.c +++ b/wolfcrypt/src/sp_sm2_arm32.c @@ -1,6 +1,6 @@ /* sp_sm2_arm32.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_sm2_arm64.c b/wolfcrypt/src/sp_sm2_arm64.c index 5c84948a01..8f87711903 100644 --- a/wolfcrypt/src/sp_sm2_arm64.c +++ b/wolfcrypt/src/sp_sm2_arm64.c @@ -1,6 +1,6 @@ /* sp_sm2_arm64.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_sm2_armthumb.c b/wolfcrypt/src/sp_sm2_armthumb.c index 5d26e27be9..0be6685723 100644 --- a/wolfcrypt/src/sp_sm2_armthumb.c +++ b/wolfcrypt/src/sp_sm2_armthumb.c @@ -1,6 +1,6 @@ /* sp_sm2_armthumb.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_sm2_c32.c b/wolfcrypt/src/sp_sm2_c32.c index 41c40d1ef3..754b80a563 100644 --- a/wolfcrypt/src/sp_sm2_c32.c +++ b/wolfcrypt/src/sp_sm2_c32.c @@ -1,6 +1,6 @@ /* sp_sm2_c32.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_sm2_c64.c b/wolfcrypt/src/sp_sm2_c64.c index ee38016544..861bfe3ed4 100644 --- a/wolfcrypt/src/sp_sm2_c64.c +++ b/wolfcrypt/src/sp_sm2_c64.c @@ -1,6 +1,6 @@ /* sp_sm2_c64.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_sm2_cortexm.c b/wolfcrypt/src/sp_sm2_cortexm.c index 3bda85f026..4b1083fc80 100644 --- a/wolfcrypt/src/sp_sm2_cortexm.c +++ b/wolfcrypt/src/sp_sm2_cortexm.c @@ -1,6 +1,6 @@ /* sp_sm2_cortexm.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_sm2_x86_64.c b/wolfcrypt/src/sp_sm2_x86_64.c index f73e408344..24a5b9e581 100644 --- a/wolfcrypt/src/sp_sm2_x86_64.c +++ b/wolfcrypt/src/sp_sm2_x86_64.c @@ -1,6 +1,6 @@ /* sp_sm2_x86_64.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_sm2_x86_64_asm.S b/wolfcrypt/src/sp_sm2_x86_64_asm.S index 6ddc3c77ec..a725c8ef8a 100644 --- a/wolfcrypt/src/sp_sm2_x86_64_asm.S +++ b/wolfcrypt/src/sp_sm2_x86_64_asm.S @@ -1,6 +1,6 @@ /* sp_sm2_x86_64_asm.S * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_x86_64.c b/wolfcrypt/src/sp_x86_64.c index b57f5a3a30..ea1b9635c0 100644 --- a/wolfcrypt/src/sp_x86_64.c +++ b/wolfcrypt/src/sp_x86_64.c @@ -1,6 +1,6 @@ /* sp.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/sp_x86_64_asm.asm b/wolfcrypt/src/sp_x86_64_asm.asm index 784bf9c5f5..3eabea3f1a 100644 --- a/wolfcrypt/src/sp_x86_64_asm.asm +++ b/wolfcrypt/src/sp_x86_64_asm.asm @@ -1,6 +1,6 @@ ; /* sp_x86_64_asm.asm */ ; /* -; * Copyright (C) 2006-2024 wolfSSL Inc. +; * Copyright (C) 2006-2024 wolfSSL Inc. ; * ; * This file is part of wolfSSL. ; * diff --git a/wolfcrypt/src/sphincs.c b/wolfcrypt/src/sphincs.c index 05ba27feeb..5fc054d882 100644 --- a/wolfcrypt/src/sphincs.c +++ b/wolfcrypt/src/sphincs.c @@ -1,6 +1,6 @@ /* sphincs.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/srp.c b/wolfcrypt/src/srp.c index b914f5811b..5216fecf3f 100644 --- a/wolfcrypt/src/srp.c +++ b/wolfcrypt/src/srp.c @@ -1,6 +1,6 @@ /* srp.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/tfm.c b/wolfcrypt/src/tfm.c index 07cd1fedc1..ccf15a5f43 100644 --- a/wolfcrypt/src/tfm.c +++ b/wolfcrypt/src/tfm.c @@ -1,6 +1,6 @@ /* tfm.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/wc_dsp.c b/wolfcrypt/src/wc_dsp.c index c31c62b15c..c6c76c28c1 100644 --- a/wolfcrypt/src/wc_dsp.c +++ b/wolfcrypt/src/wc_dsp.c @@ -1,6 +1,6 @@ /* wc_dsp.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/wc_encrypt.c b/wolfcrypt/src/wc_encrypt.c index 3b6d87ddac..9393a6974c 100644 --- a/wolfcrypt/src/wc_encrypt.c +++ b/wolfcrypt/src/wc_encrypt.c @@ -1,6 +1,6 @@ /* wc_encrypt.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/wc_kyber.c b/wolfcrypt/src/wc_kyber.c index ffa37d84c1..a99cd6c1e9 100644 --- a/wolfcrypt/src/wc_kyber.c +++ b/wolfcrypt/src/wc_kyber.c @@ -286,7 +286,9 @@ int wc_KyberKey_MakeKeyWithRandom(KyberKey* key, const unsigned char* rand, } /* Free dynamic memory allocated in function. */ - XFREE(a, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + if (a != NULL) { + XFREE(a, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + } return ret; } @@ -890,7 +892,9 @@ int wc_KyberKey_Decapsulate(KyberKey* key, unsigned char* ss, #ifndef USE_INTEL_SPEEDUP /* Dispose of dynamic memory allocated in function. */ - XFREE(cmp, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + if (cmp != NULL) { + XFREE(cmp, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + } #endif return ret; diff --git a/wolfcrypt/src/wc_lms.c b/wolfcrypt/src/wc_lms.c index 0ef0b59a24..cbe9d1f7b2 100644 --- a/wolfcrypt/src/wc_lms.c +++ b/wolfcrypt/src/wc_lms.c @@ -629,7 +629,7 @@ int wc_LmsKey_MakeKey(LmsKey* key, WC_RNG* rng) const LmsParams* params = key->params; /* Allocate memory for the private key data. */ - key->priv_data = XMALLOC(LMS_PRIV_DATA_LEN(params->levels, + key->priv_data = (byte *)XMALLOC(LMS_PRIV_DATA_LEN(params->levels, params->height, params->p, params->rootLevels, params->cacheBits), key->heap, DYNAMIC_TYPE_LMS); /* Check pointer is valid. */ @@ -728,7 +728,7 @@ int wc_LmsKey_Reload(LmsKey* key) const LmsParams* params = key->params; /* Allocate memory for the private key data. */ - key->priv_data = XMALLOC(LMS_PRIV_DATA_LEN(params->levels, + key->priv_data = (byte *)XMALLOC(LMS_PRIV_DATA_LEN(params->levels, params->height, params->p, params->rootLevels, params->cacheBits), key->heap, DYNAMIC_TYPE_LMS); /* Check pointer is valid. */ diff --git a/wolfcrypt/src/wc_pkcs11.c b/wolfcrypt/src/wc_pkcs11.c index 8de82c18a3..a7b00f8ade 100644 --- a/wolfcrypt/src/wc_pkcs11.c +++ b/wolfcrypt/src/wc_pkcs11.c @@ -1,6 +1,6 @@ /* wc_pkcs11.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index 4a435ad6bf..32571585ec 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -1,6 +1,6 @@ /* port.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -1177,6 +1177,23 @@ int wc_strncasecmp(const char *s1, const char *s2, size_t n) } #endif /* USE_WOLF_STRNCASECMP */ +#ifdef USE_WOLF_STRDUP +char* wc_strdup_ex(const char *src, int memType) { + char *ret = NULL; + word32 len = 0; + + if (src) { + len = (word32)XSTRLEN(src); + ret = (char*)XMALLOC(len, NULL, memType); + if (ret != NULL) { + XMEMCPY(ret, src, len); + } + } + + return ret; +} +#endif + #ifdef WOLFSSL_ATOMIC_OPS #ifdef HAVE_C___ATOMIC diff --git a/wolfcrypt/src/wc_xmss.c b/wolfcrypt/src/wc_xmss.c index 0e63722247..5c016dbac2 100644 --- a/wolfcrypt/src/wc_xmss.c +++ b/wolfcrypt/src/wc_xmss.c @@ -1,6 +1,6 @@ /* wc_xmss.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/wc_xmss_impl.c b/wolfcrypt/src/wc_xmss_impl.c index b45bc59ead..80ca9672e5 100644 --- a/wolfcrypt/src/wc_xmss_impl.c +++ b/wolfcrypt/src/wc_xmss_impl.c @@ -1,6 +1,6 @@ /* wc_xmss_impl.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/wolfevent.c b/wolfcrypt/src/wolfevent.c index 4ed7b8f69d..bf155c1293 100644 --- a/wolfcrypt/src/wolfevent.c +++ b/wolfcrypt/src/wolfevent.c @@ -1,6 +1,6 @@ /* wolfevent.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/wolfmath.c b/wolfcrypt/src/wolfmath.c index df5f0f85ff..eb5f5419cf 100644 --- a/wolfcrypt/src/wolfmath.c +++ b/wolfcrypt/src/wolfmath.c @@ -1,6 +1,6 @@ /* wolfmath.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index ab27178757..59d415883e 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -711,9 +711,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t mp_test(void); #if defined(WOLFSSL_PUBLIC_MP) && defined(WOLFSSL_KEY_GEN) WOLFSSL_TEST_SUBROUTINE wc_test_ret_t prime_test(void); #endif -#if defined(ASN_BER_TO_DER) && \ - (defined(WOLFSSL_TEST_CERT) || defined(OPENSSL_EXTRA) || \ - defined(OPENSSL_EXTRA_X509_SMALL)) +#ifdef ASN_BER_TO_DER WOLFSSL_TEST_SUBROUTINE wc_test_ret_t berder_test(void); #endif WOLFSSL_TEST_SUBROUTINE wc_test_ret_t logging_test(void); @@ -1767,10 +1765,12 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\ #endif #if defined(HAVE_HPKE) && defined(HAVE_ECC) && defined(HAVE_AESGCM) + PRIVATE_KEY_UNLOCK(); if ( (ret = hpke_test()) != 0) TEST_FAIL("HPKE test failed!\n", ret); else TEST_PASS("HPKE test passed!\n"); + PRIVATE_KEY_LOCK(); #endif #if defined(WC_SRTP_KDF) @@ -3829,23 +3829,26 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t sha256_test(void) #endif /* NO_LARGE_HASH_TEST */ #if defined(WOLFSSL_HAVE_LMS) && !defined(WOLFSSL_LMS_FULL_HASH) - unsigned char data_hb[WC_SHA256_BLOCK_SIZE] = { - 0x61, 0x62, 0x63, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18 - }; + { + WOLFSSL_SMALL_STACK_STATIC const unsigned char + data_hb[WC_SHA256_BLOCK_SIZE] = { + 0x61, 0x62, 0x63, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18 + }; - ret = wc_Sha256HashBlock(&sha, data_hb, hash); - if (ret != 0) { - ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit); - } - if (XMEMCMP(hash, b.output, WC_SHA256_DIGEST_SIZE) != 0) { - ERROR_OUT(WC_TEST_RET_ENC_NC, exit); + ret = wc_Sha256HashBlock(&sha, data_hb, hash); + if (ret != 0) { + ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit); + } + if (XMEMCMP(hash, b.output, WC_SHA256_DIGEST_SIZE) != 0) { + ERROR_OUT(WC_TEST_RET_ENC_NC, exit); + } } #endif @@ -7784,10 +7787,10 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t chacha_test(void) return WC_TEST_RET_ENC_EC(ret); if (XMEMCMP(plain_big, input_big, CHACHA_BIG_TEST_SIZE)) - return WC_TEST_RET_ENC_NC; + return WC_TEST_RET_ENC_I(i); if (XMEMCMP(cipher_big, cipher_big_result, CHACHA_BIG_TEST_SIZE)) - return WC_TEST_RET_ENC_NC; + return WC_TEST_RET_ENC_I(i); } #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) @@ -18073,7 +18076,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void) #endif static const char* certBadOid = CERT_ROOT "test" CERT_PATH_SEP "cert-bad-oid.der"; -#ifndef WOLFSSL_NO_ASN_STRICT +#if defined(WOLFSSL_ASN_TEMPLATE) && !defined(WOLFSSL_NO_ASN_STRICT) static const char* certBadUtf8 = CERT_ROOT "test" CERT_PATH_SEP "cert-bad-utf8.der"; #endif @@ -18378,7 +18381,7 @@ static wc_test_ret_t cert_bad_asn1_test(void) /* Subject name OID: 55 04 f4. Last byte with top bit set invalid. */ ret = cert_load_bad(certBadOid, tmp, ASN_PARSE_E); } -#ifndef WOLFSSL_NO_ASN_STRICT +#if defined(WOLFSSL_ASN_TEMPLATE) && !defined(WOLFSSL_NO_ASN_STRICT) if (ret == 0) { /* Issuer name UTF8STRING: df 52 4e 44. Top bit of second byte not set. */ @@ -28684,12 +28687,10 @@ typedef struct eccVector { const char* curveName; word32 msgLen; word32 keySize; -#ifndef NO_ASN const byte* r; word32 rSz; const byte* s; word32 sSz; -#endif } eccVector; #if !defined(WOLF_CRYPTO_CB_ONLY_ECC) @@ -28741,13 +28742,14 @@ static wc_test_ret_t ecc_test_vector_item(const eccVector* vector) if (ret != 0) goto done; +#if !defined(NO_ASN) XMEMSET(sig, 0, ECC_SIG_SIZE); sigSz = ECC_SIG_SIZE; ret = wc_ecc_rs_to_sig(vector->R, vector->S, sig, &sigSz); if (ret != 0) goto done; -#if !defined(NO_ASN) && !defined(HAVE_SELFTEST) +#if !defined(HAVE_SELFTEST) XMEMSET(sigRaw, 0, ECC_SIG_SIZE); sigRawSz = ECC_SIG_SIZE; ret = wc_ecc_rs_raw_to_sig(vector->r, vector->rSz, vector->s, vector->sSz, @@ -28767,7 +28769,17 @@ static wc_test_ret_t ecc_test_vector_item(const eccVector* vector) ret = WC_TEST_RET_ENC_NC; goto done; } -#endif +#endif /* !HAVE_SELFTEST */ +#else + /* Signature will be R+S directly */ + /* Make sure and zero pad if r or s is less than key size */ + XMEMSET(sig, 0, ECC_SIG_SIZE); + sigSz = vector->keySize * 2; + XMEMCPY(sig + (vector->keySize - vector->rSz), + vector->r, vector->rSz); + XMEMCPY(sig + vector->keySize + (vector->keySize - vector->sSz), + vector->s, vector->sSz); +#endif /* !NO_ASN */ #ifdef HAVE_ECC_VERIFY do { @@ -28855,14 +28867,12 @@ static wc_test_ret_t ecc_test_vector(int keySize) vec.R = "6994d962bdd0d793ffddf855ec5bf2f91a9698b46258a63e"; vec.S = "02ba6465a234903744ab02bc8521405b73cf5fc00e1a9f41"; vec.curveName = "SECP192R1"; - #ifndef NO_ASN vec.r = (byte*)"\x69\x94\xd9\x62\xbd\xd0\xd7\x93\xff\xdd\xf8\x55" "\xec\x5b\xf2\xf9\x1a\x96\x98\xb4\x62\x58\xa6\x3e"; vec.rSz = 24; vec.s = (byte*)"\x02\xba\x64\x65\xa2\x34\x90\x37\x44\xab\x02\xbc" "\x85\x21\x40\x5b\x73\xcf\x5f\xc0\x0e\x1a\x9f\x41"; vec.sSz = 24; - #endif break; #endif /* HAVE_ECC192 */ @@ -28891,7 +28901,6 @@ static wc_test_ret_t ecc_test_vector(int keySize) vec.R = "147b33758321e722a0360a4719738af848449e2c1d08defebc1671a7"; vec.S = "24fc7ed7f1352ca3872aa0916191289e2e04d454935d50fe6af3ad5b"; vec.curveName = "SECP224R1"; - #ifndef NO_ASN vec.r = (byte*)"\x14\x7b\x33\x75\x83\x21\xe7\x22\xa0\x36\x0a\x47" "\x19\x73\x8a\xf8\x48\x44\x9e\x2c\x1d\x08\xde\xfe" "\xbc\x16\x71\xa7"; @@ -28900,7 +28909,6 @@ static wc_test_ret_t ecc_test_vector(int keySize) "\x61\x91\x28\x9e\x2e\x04\xd4\x54\x93\x5d\x50\xfe" "\x6a\xf3\xad\x5b"; vec.sSz = 28; - #endif break; #endif /* HAVE_ECC224 */ @@ -28933,7 +28941,6 @@ static wc_test_ret_t ecc_test_vector(int keySize) vec.d = "be34baa8d040a3b991f9075b56ba292f755b90e4b6dc10dad36715c33cfdac25"; vec.R = "2b826f5d44e2d0b6de531ad96b51e8f0c56fdfead3c236892e4d84eacfc3b75c"; vec.S = "a2248b62c03db35a7cd63e8a120a3521a89d3d2f61ff99035a2148ae32e3a248"; - #ifndef NO_ASN vec.r = (byte*)"\x2b\x82\x6f\x5d\x44\xe2\xd0\xb6\xde\x53\x1a\xd9" "\x6b\x51\xe8\xf0\xc5\x6f\xdf\xea\xd3\xc2\x36\x89" "\x2e\x4d\x84\xea\xcf\xc3\xb7\x5c"; @@ -28942,7 +28949,6 @@ static wc_test_ret_t ecc_test_vector(int keySize) "\x12\x0a\x35\x21\xa8\x9d\x3d\x2f\x61\xff\x99\x03" "\x5a\x21\x48\xae\x32\xe3\xa2\x48"; vec.sSz = 32; - #endif vec.curveName = "SECP256R1"; break; #endif /* !NO_ECC256 */ @@ -28977,7 +28983,6 @@ static wc_test_ret_t ecc_test_vector(int keySize) vec.R = "6820b8585204648aed63bdff47f6d9acebdea62944774a7d14f0e14aa0b9a5b99545b2daee6b3c74ebf606667a3f39b7"; vec.S = "491af1d0cccd56ddd520b233775d0bc6b40a6255cc55207d8e9356741f23c96c14714221078dbd5c17f4fdd89b32a907"; vec.curveName = "SECP384R1"; - #ifndef NO_ASN vec.r = (byte*)"\x68\x20\xb8\x58\x52\x04\x64\x8a\xed\x63\xbd\xff" "\x47\xf6\xd9\xac\xeb\xde\xa6\x29\x44\x77\x4a\x7d" "\x14\xf0\xe1\x4a\xa0\xb9\xa5\xb9\x95\x45\xb2\xda" @@ -28988,7 +28993,6 @@ static wc_test_ret_t ecc_test_vector(int keySize) "\x8e\x93\x56\x74\x1f\x23\xc9\x6c\x14\x71\x42\x21" "\x07\x8d\xbd\x5c\x17\xf4\xfd\xd8\x9b\x32\xa9\x07"; vec.sSz = 48; - #endif break; #endif /* HAVE_ECC384 */ @@ -29022,7 +29026,6 @@ static wc_test_ret_t ecc_test_vector(int keySize) vec.R = "0bd117b4807710898f9dd7778056485777668f0e78e6ddf5b000356121eb7a220e9493c7f9a57c077947f89ac45d5acb6661bbcd17abb3faea149ba0aa3bb1521be"; vec.S = "019cd2c5c3f9870ecdeb9b323abdf3a98cd5e231d85c6ddc5b71ab190739f7f226e6b134ba1d5889ddeb2751dabd97911dff90c34684cdbe7bb669b6c3d22f2480c"; vec.curveName = "SECP521R1"; - #ifndef NO_ASN vec.r = (byte*)"\xbd\x11\x7b\x48\x07\x71\x08\x98\xf9\xdd\x77\x78" "\x05\x64\x85\x77\x76\x68\xf0\xe7\x8e\x6d\xdf\x5b" "\x00\x03\x56\x12\x1e\xb7\xa2\x20\xe9\x49\x3c\x7f" @@ -29037,7 +29040,6 @@ static wc_test_ret_t ecc_test_vector(int keySize) "\xdf\xf9\x0c\x34\x68\x4c\xdb\xe7\xbb\x66\x9b\x6c" "\x3d\x22\xf2\x48\x0c"; vec.sSz = 65; - #endif break; #endif /* HAVE_ECC521 */ default: @@ -29053,10 +29055,74 @@ static wc_test_ret_t ecc_test_vector(int keySize) } #endif /* WOLF_CRYPTO_CB_ONLY_ECC */ -#if defined(HAVE_ECC_SIGN) && (defined(WOLFSSL_ECDSA_DETERMINISTIC_K) || \ - defined(WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT)) \ - && (!defined(FIPS_VERSION_GE) || FIPS_VERSION_GE(5,3)) -#if defined(HAVE_ECC256) +#if defined(HAVE_ECC_SIGN) && \ + (defined(WOLFSSL_ECDSA_DETERMINISTIC_K) || \ + defined(WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT)) && \ + (!defined(HAVE_FIPS) || FIPS_VERSION_GE(5,3)) +#if (!defined(NO_ECC256) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 256 + +static wc_test_ret_t ecdsa_test_deterministic_k_sig(ecc_key *key, + enum wc_HashType hashType, const char* msg, WC_RNG* rng, const byte* expSig, + size_t expSigSz) +{ + wc_test_ret_t ret; + int verify; + byte sig[ECC_MAX_SIG_SIZE]; + word32 sigSz; + unsigned char hash[WC_MAX_DIGEST_SIZE]; + + ret = wc_Hash(hashType, + (byte*)msg, (word32)XSTRLEN(msg), + hash, sizeof(hash)); + if (ret != 0) { + goto done; + } + + /* Sign test */ + sigSz = sizeof(sig); + do { + #if defined(WOLFSSL_ASYNC_CRYPT) + ret = wc_AsyncWait(ret, &key->asyncDev, WC_ASYNC_FLAG_CALL_AGAIN); + #endif + if (ret == 0) + ret = wc_ecc_sign_hash(hash, wc_HashGetDigestSize(hashType), + sig, &sigSz, rng, key); + } while (ret == WC_PENDING_E); + if (ret != 0) { + goto done; + } + TEST_SLEEP(); + + /* Compare test vector */ + if (sigSz != expSigSz) { + ret = WC_TEST_RET_ENC_NC; + goto done; + } + if (XMEMCMP(sig, expSig, sigSz) != 0) { + ret = WC_TEST_RET_ENC_NC; + goto done; + } + + /* Verificiation */ + verify = 0; + do { + #if defined(WOLFSSL_ASYNC_CRYPT) + ret = wc_AsyncWait(ret, &key->asyncDev, WC_ASYNC_FLAG_CALL_AGAIN); + #endif + if (ret == 0) + ret = wc_ecc_verify_hash(sig, sigSz, + hash, wc_HashGetDigestSize(hashType), &verify, key); + } while (ret == WC_PENDING_E); + if (ret != 0) { + goto done; + } + if (verify != 1) { + ERROR_OUT(WC_TEST_RET_ENC_NC, done); + } +done: + return ret; +} + static wc_test_ret_t ecc_test_deterministic_k(WC_RNG* rng) { wc_test_ret_t ret; @@ -29066,27 +29132,61 @@ static wc_test_ret_t ecc_test_deterministic_k(WC_RNG* rng) ecc_key key[1]; #endif int key_inited = 0; - byte sig[72]; - word32 sigSz; - WOLFSSL_SMALL_STACK_STATIC const unsigned char msg[] = "sample"; - unsigned char hash[32]; + WOLFSSL_SMALL_STACK_STATIC const char* msg = "sample"; WOLFSSL_SMALL_STACK_STATIC const char* dIUT = "C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721"; WOLFSSL_SMALL_STACK_STATIC const char* QIUTx = "60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6"; WOLFSSL_SMALL_STACK_STATIC const char* QIUTy = "7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299"; - WOLFSSL_SMALL_STACK_STATIC const byte expSig[] = { - 0x30, 0x46, 0x02, 0x21, 0x00, 0xEF, 0xD4, 0x8B, - 0x2A, 0xAC, 0xB6, 0xA8, 0xFD, 0x11, 0x40, 0xDD, - 0x9C, 0xD4, 0x5E, 0x81, 0xD6, 0x9D, 0x2C, 0x87, - 0x7B, 0x56, 0xAA, 0xF9, 0x91, 0xC3, 0x4D, 0x0E, - 0xA8, 0x4E, 0xAF, 0x37, 0x16, 0x02, 0x21, 0x00, - 0xF7, 0xCB, 0x1C, 0x94, 0x2D, 0x65, 0x7C, 0x41, - 0xD4, 0x36, 0xC7, 0xA1, 0xB6, 0xE2, 0x9F, 0x65, - 0xF3, 0xE9, 0x00, 0xDB, 0xB9, 0xAF, 0xF4, 0x06, - 0x4D, 0xC4, 0xAB, 0x2F, 0x84, 0x3A, 0xCD, 0xA8 +#ifndef NO_SHA256 + WOLFSSL_SMALL_STACK_STATIC const byte expSig256[] = { + 0x30, 0x46, /* CONSTRUCTED SEQUENCE: (0x20 | 0x10) = 68 bytes */ + 0x02, 0x21, /* ASN_INTEGER = 0x02 (32 bytes) - SIG R */ + 0x00, 0xEF, 0xD4, 0x8B, 0x2A, 0xAC, 0xB6, 0xA8, + 0xFD, 0x11, 0x40, 0xDD, 0x9C, 0xD4, 0x5E, 0x81, + 0xD6, 0x9D, 0x2C, 0x87, 0x7B, 0x56, 0xAA, 0xF9, + 0x91, 0xC3, 0x4D, 0x0E, 0xA8, 0x4E, 0xAF, 0x37, + 0x16, + 0x02, 0x21, /* ASN_INTEGER = 0x02 (32 bytes) - SIG S */ + 0x00, 0xF7, 0xCB, 0x1C, 0x94, 0x2D, 0x65, 0x7C, + 0x41, 0xD4, 0x36, 0xC7, 0xA1, 0xB6, 0xE2, 0x9F, + 0x65, 0xF3, 0xE9, 0x00, 0xDB, 0xB9, 0xAF, 0xF4, + 0x06, 0x4D, 0xC4, 0xAB, 0x2F, 0x84, 0x3A, 0xCD, + 0xA8 }; +#endif +#ifdef WOLFSSL_SHA384 + WOLFSSL_SMALL_STACK_STATIC const byte expSig384[] = { + 0x30, 0x44, /* CONSTRUCTED SEQUENCE: (0x20 | 0x10) = 68 bytes */ + 0x02, 0x20, /* ASN_INTEGER = 0x02 (32 bytes) - SIG R */ + 0x0e, 0xaf, 0xea, 0x03, 0x9b, 0x20, 0xe9, 0xb4, + 0x23, 0x09, 0xfb, 0x1d, 0x89, 0xe2, 0x13, 0x05, + 0x7c, 0xbf, 0x97, 0x3d, 0xc0, 0xcf, 0xc8, 0xf1, + 0x29, 0xed, 0xdd, 0xc8, 0x00, 0xef, 0x77, 0x19, + 0x02, 0x20, /* ASN_INTEGER = 0x02 (32 bytes) - SIG S */ + 0x48, 0x61, 0xf0, 0x49, 0x1e, 0x69, 0x98, 0xb9, + 0x45, 0x51, 0x93, 0xe3, 0x4e, 0x7b, 0x0d, 0x28, + 0x4d, 0xdd, 0x71, 0x49, 0xa7, 0x4b, 0x95, 0xb9, + 0x26, 0x1f, 0x13, 0xab, 0xde, 0x94, 0x09, 0x54 + }; +#endif +#ifdef WOLFSSL_SHA512 + WOLFSSL_SMALL_STACK_STATIC const byte expSig512[] = { + 0x30, 0x45, /* CONSTRUCTED SEQUENCE: (0x20 | 0x10) = 68 bytes */ + 0x02, 0x21, /* ASN_INTEGER = 0x02 (32 bytes) - SIG R */ + 0x00, 0x84, 0x96, 0xa6, 0x0b, 0x5e, 0x9b, 0x47, + 0xc8, 0x25, 0x48, 0x88, 0x27, 0xe0, 0x49, 0x5b, + 0x0e, 0x3f, 0xa1, 0x09, 0xec, 0x45, 0x68, 0xfd, + 0x3f, 0x8d, 0x10, 0x97, 0x67, 0x8e, 0xb9, 0x7f, + 0x00, + 0x02, 0x20, /* ASN_INTEGER = 0x02 (32 bytes) - SIG S */ + 0x23, 0x62, 0xab, 0x1a, 0xdb, 0xe2, 0xb8, 0xad, + 0xf9, 0xcb, 0x9e, 0xda, 0xb7, 0x40, 0xea, 0x60, + 0x49, 0xc0, 0x28, 0x11, 0x4f, 0x24, 0x60, 0xf9, + 0x65, 0x54, 0xf6, 0x1f, 0xae, 0x33, 0x02, 0xfe + }; +#endif #ifdef WOLFSSL_SMALL_STACK key = (ecc_key *)XMALLOC(sizeof(*key), HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); @@ -29104,51 +29204,37 @@ static wc_test_ret_t ecc_test_deterministic_k(WC_RNG* rng) goto done; } - ret = wc_Hash(WC_HASH_TYPE_SHA256, msg, - (word32)XSTRLEN((const char*)msg), hash, sizeof(hash)); - if (ret != 0) { - goto done; - } - ret = wc_ecc_set_deterministic(key, 1); if (ret != 0) { goto done; } - sigSz = sizeof(sig); - do { - #if defined(WOLFSSL_ASYNC_CRYPT) - ret = wc_AsyncWait(ret, key.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN); - #endif - if (ret == 0) - ret = wc_ecc_sign_hash(hash, sizeof(hash), sig, &sigSz, rng, key); - } while (ret == WC_PENDING_E); +#ifndef NO_SHA256 + /* Test for SHA2-256 */ + ret = ecdsa_test_deterministic_k_sig(key, WC_HASH_TYPE_SHA256, msg, rng, + expSig256, sizeof(expSig256)); if (ret != 0) { goto done; } - TEST_SLEEP(); +#endif /* !NO_SHA256 */ - if (sigSz != sizeof(expSig)) { - ret = WC_TEST_RET_ENC_NC; - goto done; - } - if (XMEMCMP(sig, expSig, sigSz) != 0) { - ret = WC_TEST_RET_ENC_NC; +#ifdef WOLFSSL_SHA384 + /* Test for SHA2-384 */ + ret = ecdsa_test_deterministic_k_sig(key, WC_HASH_TYPE_SHA384, msg, rng, + expSig384, sizeof(expSig384)); + if (ret != 0) { goto done; } +#endif /* WOLFSSL_SHA384 */ - sigSz = sizeof(sig); - do { - #if defined(WOLFSSL_ASYNC_CRYPT) - ret = wc_AsyncWait(ret, key.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN); - #endif - if (ret == 0) - ret = wc_ecc_sign_hash(hash, sizeof(hash), sig, &sigSz, rng, key); - } while (ret == WC_PENDING_E); +#ifdef WOLFSSL_SHA512 + /* Test for SHA2-512 */ + ret = ecdsa_test_deterministic_k_sig(key, WC_HASH_TYPE_SHA512, msg, rng, + expSig512, sizeof(expSig512)); if (ret != 0) { goto done; } - TEST_SLEEP(); +#endif /* WOLFSSL_SHA512 */ done: if (key_inited) @@ -29158,10 +29244,59 @@ static wc_test_ret_t ecc_test_deterministic_k(WC_RNG* rng) #endif return ret; } -#endif +#endif /* NO_ECC256 || HAVE_ALL_CURVES */ + #ifdef WOLFSSL_PUBLIC_MP -#if defined(HAVE_ECC384) + +static wc_test_ret_t ecdsa_test_deterministic_k_rs(ecc_key *key, + enum wc_HashType hashType, const char* msg, WC_RNG* rng, + mp_int* r, mp_int* s, + mp_int* expR, mp_int* expS) +{ + wc_test_ret_t ret; + unsigned char hash[WC_MAX_DIGEST_SIZE]; + int verify; + + ret = wc_Hash(hashType, + (byte*)msg, (word32)XSTRLEN(msg), + hash, sizeof(hash)); + if (ret != 0) { + goto done; + } + + ret = wc_ecc_sign_hash_ex(hash, wc_HashGetDigestSize(hashType), rng, key, + r, s); +#if defined(WOLFSSL_ASYNC_CRYPT) + ret = wc_AsyncWait(ret, &key->asyncDev, WC_ASYNC_FLAG_NONE); +#endif + if (ret != 0) { + goto done; + } + TEST_SLEEP(); + + if (mp_cmp(r, expR) != MP_EQ && mp_cmp(s, expS) != MP_EQ) { + ERROR_OUT(WC_TEST_RET_ENC_NC, done); + } + + /* Verificiation */ + verify = 0; + ret = wc_ecc_verify_hash_ex(r, s, hash, wc_HashGetDigestSize(hashType), + &verify, key); +#if defined(WOLFSSL_ASYNC_CRYPT) + ret = wc_AsyncWait(ret, &key->asyncDev, WC_ASYNC_FLAG_NONE); +#endif + if (ret != 0) { + goto done; + } + if (verify != 1) { + ERROR_OUT(WC_TEST_RET_ENC_NC, done); + } +done: + return ret; +} + +#if (defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 384 /* KAT from RFC6979 */ static wc_test_ret_t ecc384_test_deterministic_k(WC_RNG* rng) { @@ -29173,9 +29308,10 @@ static wc_test_ret_t ecc384_test_deterministic_k(WC_RNG* rng) ecc_key key[1]; mp_int r[1], s[1], expR[1], expS[1]; #endif - int key_inited = 0; - WOLFSSL_SMALL_STACK_STATIC const unsigned char msg[] = "sample"; - unsigned char hash[32]; + int key_inited = 0, + tmp_mp_ints_inited = 0; + + WOLFSSL_SMALL_STACK_STATIC const char* msg = "sample"; WOLFSSL_SMALL_STACK_STATIC const char* dIUT = "6B9D3DAD2E1B8C1C05B19875B6659F4DE23C3B667BF297BA9AA47740787137D8" "96D5724E4C70A825F872C9EA60D2EDF5"; @@ -29185,12 +29321,30 @@ static wc_test_ret_t ecc384_test_deterministic_k(WC_RNG* rng) WOLFSSL_SMALL_STACK_STATIC const char* QIUTy = "8015D9B72D7D57244EA8EF9AC0C621896708A59367F9DFB9F54CA84B3F1C9DB1" "288B231C3AE0D4FE7344FD2533264720"; - WOLFSSL_SMALL_STACK_STATIC const char* expRstr = +#ifndef NO_SHA256 + WOLFSSL_SMALL_STACK_STATIC const char* expRstr256 = "21B13D1E013C7FA1392D03C5F99AF8B30C570C6F98D4EA8E354B63A21D3DAA33" "BDE1E888E63355D92FA2B3C36D8FB2CD"; - WOLFSSL_SMALL_STACK_STATIC const char* expSstr = + WOLFSSL_SMALL_STACK_STATIC const char* expSstr256 = "F3AA443FB107745BF4BD77CB3891674632068A10CA67E3D45DB2266FA7D1FEEB" "EFDC63ECCD1AC42EC0CB8668A4FA0AB0"; +#endif +#ifdef WOLFSSL_SHA384 + WOLFSSL_SMALL_STACK_STATIC const char* expRstr384 = + "94EDBB92A5ECB8AAD4736E56C691916B3F88140666CE9FA73D64C4EA95AD133C" + "81A648152E44ACF96E36DD1E80FABE46"; + WOLFSSL_SMALL_STACK_STATIC const char* expSstr384 = + "99EF4AEB15F178CEA1FE40DB2603138F130E740A19624526203B6351D0A3A94F" + "A329C145786E679E7B82C71A38628AC8"; +#endif +#ifdef WOLFSSL_SHA512 + WOLFSSL_SMALL_STACK_STATIC const char* expRstr512 = + "ED0959D5880AB2D869AE7F6C2915C6D60F96507F9CB3E047C0046861DA4A799C" + "FE30F35CC900056D7C99CD7882433709"; + WOLFSSL_SMALL_STACK_STATIC const char* expSstr512 = + "512C8CCEEE3890A84058CE1E22DBC2198F42323CE8ACA9135329F03C068E5112" + "DC7CC3EF3446DEFCEB01A45C2667FDD5"; +#endif #ifdef WOLFSSL_SMALL_STACK key = (ecc_key *)XMALLOC(sizeof(*key), HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); @@ -29214,6 +29368,7 @@ static wc_test_ret_t ecc384_test_deterministic_k(WC_RNG* rng) if (ret != MP_OKAY) { goto done; } + tmp_mp_ints_inited = 1; ret = wc_ecc_init_ex(key, HEAP_HINT, devId); if (ret != 0) { goto done; @@ -29225,38 +29380,53 @@ static wc_test_ret_t ecc384_test_deterministic_k(WC_RNG* rng) goto done; } - ret = wc_Hash(WC_HASH_TYPE_SHA256, msg, - (word32)XSTRLEN((const char*)msg), hash, sizeof(hash)); + ret = wc_ecc_set_deterministic(key, 1); if (ret != 0) { goto done; } - ret = wc_ecc_set_deterministic(key, 1); +#ifndef NO_SHA256 + /* Test for SHA2-256 */ + mp_read_radix(expR, expRstr256, MP_RADIX_HEX); + mp_read_radix(expS, expSstr256, MP_RADIX_HEX); + ret = ecdsa_test_deterministic_k_rs(key, WC_HASH_TYPE_SHA256, msg, rng, + r, s, expR, expS); if (ret != 0) { goto done; } +#endif /* NO_SHA256 */ - do { - #if defined(WOLFSSL_ASYNC_CRYPT) - ret = wc_AsyncWait(ret, key.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN); - #endif - if (ret == 0) - ret = wc_ecc_sign_hash_ex(hash, sizeof(hash), rng, key, r, s); - } while (ret == WC_PENDING_E); +#ifdef WOLFSSL_SHA384 + /* Test for SHA2-384 */ + mp_read_radix(expR, expRstr384, MP_RADIX_HEX); + mp_read_radix(expS, expSstr384, MP_RADIX_HEX); + ret = ecdsa_test_deterministic_k_rs(key, WC_HASH_TYPE_SHA384, msg, rng, + r, s, expR, expS); if (ret != 0) { goto done; } - TEST_SLEEP(); +#endif /* WOLFSSL_SHA384 */ - mp_read_radix(expR, expRstr, MP_RADIX_HEX); - mp_read_radix(expS, expSstr, MP_RADIX_HEX); - if (mp_cmp(r, expR) != MP_EQ) { - ret = WC_TEST_RET_ENC_NC; +#ifdef WOLFSSL_SHA512 + /* Test for SHA2-512 */ + mp_read_radix(expR, expRstr512, MP_RADIX_HEX); + mp_read_radix(expS, expSstr512, MP_RADIX_HEX); + ret = ecdsa_test_deterministic_k_rs(key, WC_HASH_TYPE_SHA512, msg, rng, + r, s, expR, expS); + if (ret != 0) { + goto done; } +#endif /* WOLFSSL_SHA512 */ done: if (key_inited) wc_ecc_free(key); + if (tmp_mp_ints_inited) { + mp_free(r); + mp_free(s); + mp_free(expR); + mp_free(expS); + } #ifdef WOLFSSL_SMALL_STACK if (key != NULL) XFREE(key, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); @@ -29274,7 +29444,7 @@ static wc_test_ret_t ecc384_test_deterministic_k(WC_RNG* rng) } #endif /* HAVE_ECC384 */ -#if defined(HAVE_ECC521) +#if (defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 521 /* KAT from RFC6979 */ static wc_test_ret_t ecc521_test_deterministic_k(WC_RNG* rng) { @@ -29286,10 +29456,9 @@ static wc_test_ret_t ecc521_test_deterministic_k(WC_RNG* rng) ecc_key key[1]; mp_int r[1], s[1], expR[1], expS[1]; #endif - int key_inited = 0; - WOLFSSL_SMALL_STACK_STATIC const unsigned char msg[] = "sample"; - unsigned char hash[32]; - + int key_inited = 0, + tmp_mp_ints_inited = 0; + WOLFSSL_SMALL_STACK_STATIC const char* msg = "sample"; WOLFSSL_SMALL_STACK_STATIC const char* dIUT = "0FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75C" "AA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83" @@ -29302,14 +29471,36 @@ static wc_test_ret_t ecc521_test_deterministic_k(WC_RNG* rng) "0493101C962CD4D2FDDF782285E64584139C2F91B47F87FF82354D6630F746A2" "8A0DB25741B5B34A828008B22ACC23F924FAAFBD4D33F81EA66956DFEAA2BFDF" "CF5"; - WOLFSSL_SMALL_STACK_STATIC const char* expRstr = +#ifndef NO_SHA256 + WOLFSSL_SMALL_STACK_STATIC const char* expRstr256 = "1511BB4D675114FE266FC4372B87682BAECC01D3CC62CF2303C92B3526012659" "D16876E25C7C1E57648F23B73564D67F61C6F14D527D54972810421E7D87589E" "1A7"; - WOLFSSL_SMALL_STACK_STATIC const char* expSstr = + WOLFSSL_SMALL_STACK_STATIC const char* expSstr256 = "04A171143A83163D6DF460AAF61522695F207A58B95C0644D87E52AA1A347916" "E4F7A72930B1BC06DBE22CE3F58264AFD23704CBB63B29B931F7DE6C9D949A7E" "CFC"; +#endif +#ifdef WOLFSSL_SHA384 + WOLFSSL_SMALL_STACK_STATIC const char* expRstr384 = + "1EA842A0E17D2DE4F92C15315C63DDF72685C18195C2BB95E572B9C5136CA4B4" + "B576AD712A52BE9730627D16054BA40CC0B8D3FF035B12AE75168397F5D50C67" + "451"; + WOLFSSL_SMALL_STACK_STATIC const char* expSstr384 = + "1F21A3CEE066E1961025FB048BD5FE2B7924D0CD797BABE0A83B66F1E35EEAF5" + "FDE143FA85DC394A7DEE766523393784484BDF3E00114A1C857CDE1AA203DB65" + "D61"; +#endif +#ifdef WOLFSSL_SHA512 + WOLFSSL_SMALL_STACK_STATIC const char* expRstr512 = + "0C328FAFCBD79DD77850370C46325D987CB525569FB63C5D3BC53950E6D4C5F1" + "74E25A1EE9017B5D450606ADD152B534931D7D4E8455CC91F9B15BF05EC36E37" + "7FA"; + WOLFSSL_SMALL_STACK_STATIC const char* expSstr512 = + "0617CCE7CF5064806C467F678D3B4080D6F1CC50AF26CA209417308281B68AF2" + "82623EAA63E5B5C0723D8B8C37FF0777B1A20F8CCB1DCCC43997F1EE0E44DA4A" + "67A"; +#endif #ifdef WOLFSSL_SMALL_STACK key = (ecc_key *)XMALLOC(sizeof(*key), HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); @@ -29333,6 +29524,7 @@ static wc_test_ret_t ecc521_test_deterministic_k(WC_RNG* rng) if (ret != MP_OKAY) { goto done; } + tmp_mp_ints_inited = 1; ret = wc_ecc_init_ex(key, HEAP_HINT, devId); if (ret != 0) { return WC_TEST_RET_ENC_EC(ret); @@ -29344,38 +29536,53 @@ static wc_test_ret_t ecc521_test_deterministic_k(WC_RNG* rng) goto done; } - ret = wc_Hash(WC_HASH_TYPE_SHA256, msg, - (word32)XSTRLEN((const char*)msg), hash, sizeof(hash)); + ret = wc_ecc_set_deterministic(key, 1); if (ret != 0) { goto done; } - ret = wc_ecc_set_deterministic(key, 1); +#ifndef NO_SHA256 + /* Test for SHA2-256 */ + mp_read_radix(expR, expRstr256, MP_RADIX_HEX); + mp_read_radix(expS, expSstr256, MP_RADIX_HEX); + ret = ecdsa_test_deterministic_k_rs(key, WC_HASH_TYPE_SHA256, msg, rng, + r, s, expR, expS); if (ret != 0) { goto done; } +#endif /* NO_SHA256 */ - do { - #if defined(WOLFSSL_ASYNC_CRYPT) - ret = wc_AsyncWait(ret, key.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN); - #endif - if (ret == 0) - ret = wc_ecc_sign_hash_ex(hash, sizeof(hash), rng, key, r, s); - } while (ret == WC_PENDING_E); +#ifdef WOLFSSL_SHA384 + /* Test for SHA2-384 */ + mp_read_radix(expR, expRstr384, MP_RADIX_HEX); + mp_read_radix(expS, expSstr384, MP_RADIX_HEX); + ret = ecdsa_test_deterministic_k_rs(key, WC_HASH_TYPE_SHA384, msg, rng, + r, s, expR, expS); if (ret != 0) { goto done; } - TEST_SLEEP(); +#endif /* WOLFSSL_SHA384 */ - mp_read_radix(expR, expRstr, MP_RADIX_HEX); - mp_read_radix(expS, expSstr, MP_RADIX_HEX); - if (mp_cmp(r, expR) != MP_EQ) { - ret = WC_TEST_RET_ENC_NC; +#ifdef WOLFSSL_SHA512 + /* Test for SHA2-512 */ + mp_read_radix(expR, expRstr512, MP_RADIX_HEX); + mp_read_radix(expS, expSstr512, MP_RADIX_HEX); + ret = ecdsa_test_deterministic_k_rs(key, WC_HASH_TYPE_SHA512, msg, rng, + r, s, expR, expS); + if (ret != 0) { + goto done; } +#endif /* WOLFSSL_SHA512 */ done: if (key_inited) wc_ecc_free(key); + if (tmp_mp_ints_inited) { + mp_free(r); + mp_free(s); + mp_free(expR); + mp_free(expS); + } #ifdef WOLFSSL_SMALL_STACK if (key != NULL) XFREE(key, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); @@ -29395,7 +29602,7 @@ static wc_test_ret_t ecc521_test_deterministic_k(WC_RNG* rng) #endif /* WOLFSSL_PUBLIC_MP */ #endif /* HAVE_ECC_SIGN && (WOLFSSL_ECDSA_DETERMINISTIC_K || WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT) - && (!FIPS_VERSION_GE || FIPS_VERSION_GE(5,3)) */ + && (!HAVE_FIPS || FIPS_VERSION_GE(5,3)) */ #if defined(HAVE_ECC_SIGN) && defined(WOLFSSL_ECDSA_SET_K) && \ @@ -29630,6 +29837,15 @@ static wc_test_ret_t ecc_test_make_pub(WC_RNG* rng) #ifdef HAVE_ECC_VERIFY int verify = 0; #endif +#ifdef NO_ASN + /* private d for eccKeyDerFile / ecc_key_der_256 */ + const byte keyPriv[] = { + 0x45, 0xB6, 0x69, 0x02, 0x73, 0x9C, 0x6C, 0x85, + 0xA1, 0x38, 0x5B, 0x72, 0xE8, 0xE8, 0xC7, 0xAC, + 0xC4, 0x03, 0x8D, 0x53, 0x35, 0x04, 0xFA, 0x6C, + 0x28, 0xDC, 0x34, 0x8D, 0xE1, 0xA8, 0x09, 0x8C + }; +#endif #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) if ((key == NULL) || @@ -29684,6 +29900,7 @@ static wc_test_ret_t ecc_test_make_pub(WC_RNG* rng) ERROR_OUT(WC_TEST_RET_ENC_NC, done); } +#ifndef NO_ASN x = 0; ret = wc_EccPrivateKeyDecode(tmp, &x, key, tmpSz); if (ret != 0) @@ -29709,6 +29926,10 @@ static wc_test_ret_t ecc_test_make_pub(WC_RNG* rng) } #endif /* HAVE_ECC_KEY_EXPORT */ +#else + /* Load raw private d directly */ + ret = wc_ecc_import_private_key(keyPriv, sizeof(keyPriv), NULL, 0, key); +#endif /* !NO_ASN */ ret = wc_ecc_make_pub(NULL, NULL); if (ret == 0) { @@ -29728,7 +29949,7 @@ static wc_test_ret_t ecc_test_make_pub(WC_RNG* rng) #endif if (ret != 0) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done); -#endif +#endif /* !WOLFSSL_CRYPTOCELL */ TEST_SLEEP(); #ifdef HAVE_ECC_KEY_EXPORT @@ -31188,7 +31409,7 @@ static wc_test_ret_t ecc_def_curve_test(WC_RNG *rng) #else ecc_key key[1]; #endif -#if !defined(NO_ECC_SECP) && \ +#if !defined(NO_ECC_SECP) && !defined(NO_ASN) && \ ((defined(HAVE_ECC_KEY_IMPORT) && defined(HAVE_ECC_KEY_EXPORT)) || \ (defined(HAVE_ECC_KEY_IMPORT) && !defined(WOLFSSL_VALIDATE_ECC_IMPORT))) word32 idx = 0; @@ -31241,7 +31462,7 @@ static wc_test_ret_t ecc_def_curve_test(WC_RNG *rng) (void)rng; #endif /* !WC_NO_RNG */ -#if !defined(NO_ECC_SECP) && \ +#if !defined(NO_ECC_SECP) && !defined(NO_ASN) && \ ((defined(HAVE_ECC_KEY_IMPORT) && defined(HAVE_ECC_KEY_EXPORT)) || \ (defined(HAVE_ECC_KEY_IMPORT) && !defined(WOLFSSL_VALIDATE_ECC_IMPORT))) /* Use test ECC key - ensure real private "d" exists */ @@ -33175,25 +33396,30 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ecc_test(void) } #endif -#if defined(HAVE_ECC_SIGN) && (defined(WOLFSSL_ECDSA_DETERMINISTIC_K) || \ - defined(WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT)) \ - && (!defined(FIPS_VERSION_GE) || FIPS_VERSION_GE(5,3)) - #ifdef HAVE_ECC256 +#if defined(HAVE_ECC_SIGN) && \ + (defined(WOLFSSL_ECDSA_DETERMINISTIC_K) || \ + defined(WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT)) && \ + (!defined(HAVE_FIPS) || FIPS_VERSION_GE(5,3)) + + #if (!defined(NO_ECC256) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 256 ret = ecc_test_deterministic_k(&rng); if (ret != 0) { printf("ecc_test_deterministic_k failed!\n"); goto done; } #endif + #ifdef WOLFSSL_PUBLIC_MP - #if defined(HAVE_ECC384) + #if (defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES)) && \ + ECC_MIN_KEY_SZ <= 384 ret = ecc384_test_deterministic_k(&rng); if (ret != 0) { printf("ecc384_test_deterministic_k failed!\n"); goto done; } #endif - #if defined(HAVE_ECC521) + #if (defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES)) && \ + ECC_MIN_KEY_SZ <= 521 ret = ecc521_test_deterministic_k(&rng); if (ret != 0) { printf("ecc512_test_deterministic_k failed!\n"); @@ -49578,11 +49804,7 @@ static wc_test_ret_t pkcs7signed_run_vectors( #endif for (j = 0, k = 2; j < (int)sizeof(digest); j++, k += 2) { - #if defined(WOLF_C89) - XSPRINTF((char*)&transId[k], "%02x", digest[j]); - #else - (void)XSNPRINTF((char*)&transId[k], 3, "%02x", digest[j]); - #endif + (void)XSNPRINTF((char*)&transId[k], 3, "%02x", digest[j]); } } @@ -50919,6 +51141,9 @@ static wc_test_ret_t mp_test_param(mp_int* a, mp_int* b, mp_int* r, WC_RNG* rng) if (ret != 0) return WC_TEST_RET_ENC_EC(ret); + /* clear buffer to avoid provoking uninitvar errors. */ + XMEMSET(buffer, 0, sizeof(buffer)); + ret = mp_read_unsigned_bin(NULL, NULL, sizeof(buffer)); if (ret != MP_VAL) return WC_TEST_RET_ENC_EC(ret); @@ -53730,9 +53955,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t prime_test(void) #endif /* WOLFSSL_PUBLIC_MP */ -#if defined(ASN_BER_TO_DER) && \ - (defined(WOLFSSL_TEST_CERT) || defined(OPENSSL_EXTRA) || \ - defined(OPENSSL_EXTRA_X509_SMALL)) +#ifdef ASN_BER_TO_DER /* wc_BerToDer is only public facing in the case of test cert or opensslextra */ typedef struct berDerTestData { const byte *in; @@ -53848,7 +54071,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t berder_test(void) return 0; } -#endif +#endif /* ASN_BER_TO_DER */ #ifdef DEBUG_WOLFSSL static THREAD_LS_T int log_cnt = 0; diff --git a/wolfcrypt/test/test.h b/wolfcrypt/test/test.h index b58beca0d4..2584b12277 100644 --- a/wolfcrypt/test/test.h +++ b/wolfcrypt/test/test.h @@ -1,6 +1,6 @@ /* wolfcrypt/test/test.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/test/test_paths.h.in b/wolfcrypt/test/test_paths.h.in index adac40c1a9..38e9124070 100644 --- a/wolfcrypt/test/test_paths.h.in +++ b/wolfcrypt/test/test_paths.h.in @@ -1,6 +1,6 @@ /* wolfcrypt/test/test_paths.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/callbacks.h b/wolfssl/callbacks.h index bf996fad60..1010eca9e2 100644 --- a/wolfssl/callbacks.h +++ b/wolfssl/callbacks.h @@ -1,6 +1,6 @@ /* callbacks.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/crl.h b/wolfssl/crl.h index 4b4dcc2768..5e5205ea2b 100644 --- a/wolfssl/crl.h +++ b/wolfssl/crl.h @@ -1,6 +1,6 @@ /* crl.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/error-ssl.h b/wolfssl/error-ssl.h index 724d7de007..6354f635a8 100644 --- a/wolfssl/error-ssl.h +++ b/wolfssl/error-ssl.h @@ -1,6 +1,6 @@ /* error-ssl.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/internal.h b/wolfssl/internal.h index 390b21b54a..88188bd1d1 100644 --- a/wolfssl/internal.h +++ b/wolfssl/internal.h @@ -1,6 +1,6 @@ /* internal.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -1329,6 +1329,10 @@ enum { #endif #endif +#ifndef MAX_PSK_KEY_LEN + #define MAX_PSK_KEY_LEN 64 +#endif + #ifndef MAX_EARLY_DATA_SZ /* maximum early data size */ #define MAX_EARLY_DATA_SZ 4096 @@ -1421,7 +1425,7 @@ enum { #define ENCRYPT_BASE_BITS (256 * 2) #else /* No secret from public key operation but PSK key plus length used. */ - #define ENCRYPT_BASE_BITS ((MAX_PSK_ID_LEN + 2) * 8) + #define ENCRYPT_BASE_BITS ((MAX_PSK_KEY_LEN + 2) * 8) #endif #ifdef WOLFSSL_DTLS_CID @@ -1561,7 +1565,7 @@ enum Misc { * hybridization with other algs. */ #else #ifndef NO_PSK - ENCRYPT_LEN = (ENCRYPT_BASE_BITS / 8) + MAX_PSK_ID_LEN + 2, + ENCRYPT_LEN = (ENCRYPT_BASE_BITS / 8) + MAX_PSK_KEY_LEN + 2, #else ENCRYPT_LEN = (ENCRYPT_BASE_BITS / 8), #endif @@ -1828,7 +1832,6 @@ enum Misc { DTLS_TIMEOUT_MULTIPLIER = 2, /* default timeout multiplier for DTLS recv */ NULL_TERM_LEN = 1, /* length of null '\0' termination character */ - MAX_PSK_KEY_LEN = 64, /* max psk key supported */ MIN_PSK_ID_LEN = 6, /* min length of identities */ MIN_PSK_BINDERS_LEN = 33, /* min length of binders */ @@ -2647,8 +2650,7 @@ struct WOLFSSL_CERT_MANAGER { #ifdef HAVE_DILITHIUM short minDilithiumKeySz; /* minimum allowed Dilithium key size */ #endif -#if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) \ - && defined(HAVE_OID_DECODING) +#ifdef WC_ASN_UNKNOWN_EXT_CB wc_UnknownExtCallback unknownExtCallback; #endif }; @@ -2743,6 +2745,70 @@ typedef struct WOLFSSL_DTLS_PEERSEQ { #endif } WOLFSSL_DTLS_PEERSEQ; +struct WOLFSSL_BIO { + WOLFSSL_BUF_MEM* mem_buf; + WOLFSSL_BIO_METHOD* method; + WOLFSSL_BIO* prev; /* previous in chain */ + WOLFSSL_BIO* next; /* next in chain */ + WOLFSSL_BIO* pair; /* BIO paired with */ + void* heap; /* user heap hint */ + union { + byte* mem_buf_data; +#ifndef WOLFCRYPT_ONLY + WOLFSSL* ssl; + WOLFSSL_EVP_MD_CTX* md_ctx; +#endif +#ifndef NO_FILESYSTEM + XFILE fh; +#endif + } ptr; + void* usrCtx; /* user set pointer */ + char* ip; /* IP address for wolfIO_TcpConnect */ + word16 port; /* Port for wolfIO_TcpConnect */ + char* infoArg; /* BIO callback argument */ + wolf_bio_info_cb infoCb; /* BIO callback */ + int wrSz; /* write buffer size (mem) */ + int wrSzReset; /* First buffer size (mem) - read ONLY data */ + int wrIdx; /* current index for write buffer */ + int rdIdx; /* current read index */ + int readRq; /* read request */ + union { + SOCKET_T fd; + size_t length; + } num; + int eof; /* eof flag */ + int flags; + byte type; /* method type */ + byte init:1; /* bio has been initialized */ + byte shutdown:1; /* close flag */ + byte connected:1; /* connected state, for datagram BIOs -- as for + * struct WOLFSSL_DTLS_CTX, when set, sendto and + * recvfrom leave the peer_addr unchanged. */ +#ifdef WOLFSSL_HAVE_BIO_ADDR + union WOLFSSL_BIO_ADDR peer_addr; /* for datagram BIOs, the socket address stored + * with BIO_CTRL_DGRAM_CONNECT, + * BIO_CTRL_DGRAM_SET_CONNECTED, or + * BIO_CTRL_DGRAM_SET_PEER, or stored when a + * packet was received on an unconnected BIO. */ +#endif + +#if defined(WORD64_AVAILABLE) && !defined(WOLFSSL_BIO_NO_FLOW_STATS) + #define WOLFSSL_BIO_HAVE_FLOW_STATS + word64 bytes_read; + word64 bytes_written; +#endif + +#ifdef HAVE_EX_DATA + WOLFSSL_CRYPTO_EX_DATA ex_data; +#endif +#if defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA) + wolfSSL_Ref ref; +#endif +}; + +#if defined(WOLFSSL_HAVE_BIO_ADDR) && defined(OPENSSL_EXTRA) +WOLFSSL_LOCAL socklen_t wolfSSL_BIO_ADDR_size(const WOLFSSL_BIO_ADDR *addr); +#endif #define MAX_WRITE_IV_SZ 16 /* max size of client/server write_IV */ @@ -3334,6 +3400,13 @@ typedef struct InternalTicket { #endif /* OPENSSL_EXTRA */ } InternalTicket; +#ifndef WOLFSSL_TICKET_ENC_CBC_HMAC + #define WOLFSSL_INTERNAL_TICKET_LEN sizeof(InternalTicket) +#else + #define WOLFSSL_INTERNAL_TICKET_LEN \ + (((sizeof(InternalTicket) + 15) / 16) * 16) +#endif + #ifndef WOLFSSL_TICKET_EXTRA_PADDING_SZ #define WOLFSSL_TICKET_EXTRA_PADDING_SZ 32 #endif @@ -5102,13 +5175,9 @@ struct WOLFSSL_X509 { byte hwType[EXTERNAL_SERIAL_SIZE]; int hwSerialNumSz; byte hwSerialNum[EXTERNAL_SERIAL_SIZE]; -#endif /* WOLFSSL_SEP */ -#if (defined(WOLFSSL_SEP) || defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || \ - defined (OPENSSL_EXTRA)) && \ - (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)) byte certPolicySet; byte certPolicyCrit; -#endif /* (WOLFSSL_SEP || WOLFSSL_QT) && (OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL) */ +#endif /* WOLFSSL_SEP */ #if defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA) WOLFSSL_STACK* ext_sk; /* Store X509_EXTENSIONS from wolfSSL_X509_get_ext */ WOLFSSL_STACK* ext_sk_full; /* Store X509_EXTENSIONS from wolfSSL_X509_get0_extensions */ diff --git a/wolfssl/ocsp.h b/wolfssl/ocsp.h index 4dff068b9b..b05510cfcf 100644 --- a/wolfssl/ocsp.h +++ b/wolfssl/ocsp.h @@ -1,6 +1,6 @@ /* ocsp.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -67,13 +67,11 @@ WOLFSSL_LOCAL int CheckOcspResponse(WOLFSSL_OCSP *ocsp, byte *response, int resp WOLFSSL_LOCAL int CheckOcspResponder(OcspResponse *bs, DecodedCert *cert, void* vp); -#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) || \ - defined(WOLFSSL_APACHE_HTTPD) || defined(HAVE_LIGHTY) - - WOLFSSL_API int wolfSSL_OCSP_resp_find_status(WOLFSSL_OCSP_BASICRESP *bs, - WOLFSSL_OCSP_CERTID *id, int *status, int *reason, - WOLFSSL_ASN1_TIME **revtime, WOLFSSL_ASN1_TIME **thisupd, - WOLFSSL_ASN1_TIME **nextupd); +#ifdef OPENSSL_EXTRA +WOLFSSL_API int wolfSSL_OCSP_resp_find_status(WOLFSSL_OCSP_BASICRESP *bs, + WOLFSSL_OCSP_CERTID *id, int *status, int *reason, + WOLFSSL_ASN1_TIME **revtime, WOLFSSL_ASN1_TIME **thisupd, + WOLFSSL_ASN1_TIME **nextupd); WOLFSSL_API const char *wolfSSL_OCSP_cert_status_str(long s); WOLFSSL_API int wolfSSL_OCSP_check_validity(WOLFSSL_ASN1_TIME* thisupd, WOLFSSL_ASN1_TIME* nextupd, long sec, long maxsec); @@ -132,8 +130,6 @@ WOLFSSL_API int wolfSSL_OCSP_resp_count(WOLFSSL_OCSP_BASICRESP *bs); WOLFSSL_API WOLFSSL_OCSP_SINGLERESP* wolfSSL_OCSP_resp_get0( WOLFSSL_OCSP_BASICRESP *bs, int idx); -#endif -#ifdef OPENSSL_EXTRA WOLFSSL_API int wolfSSL_OCSP_REQUEST_add_ext(OcspRequest* req, WOLFSSL_X509_EXTENSION* ext, int idx); WOLFSSL_API OcspResponse* wolfSSL_OCSP_response_create(int status, @@ -148,7 +144,7 @@ WOLFSSL_API int wolfSSL_OCSP_request_add1_nonce(OcspRequest* req, unsigned char* val, int sz); WOLFSSL_API int wolfSSL_OCSP_check_nonce(OcspRequest* req, WOLFSSL_OCSP_BASICRESP* bs); -#endif +#endif /* OPENSSL_EXTRA */ #ifdef __cplusplus diff --git a/wolfssl/openssl/aes.h b/wolfssl/openssl/aes.h index 38e71ae5b0..2991ff07ae 100644 --- a/wolfssl/openssl/aes.h +++ b/wolfssl/openssl/aes.h @@ -1,6 +1,6 @@ /* aes.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/asn1.h b/wolfssl/openssl/asn1.h index 12ad369807..2c83b9b8c4 100644 --- a/wolfssl/openssl/asn1.h +++ b/wolfssl/openssl/asn1.h @@ -1,6 +1,6 @@ /* asn1.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/asn1t.h b/wolfssl/openssl/asn1t.h index e7d5affd9a..e74ee26357 100644 --- a/wolfssl/openssl/asn1t.h +++ b/wolfssl/openssl/asn1t.h @@ -1,6 +1,6 @@ /* asn1t.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/bio.h b/wolfssl/openssl/bio.h index 9206b092a9..198ca4ebda 100644 --- a/wolfssl/openssl/bio.h +++ b/wolfssl/openssl/bio.h @@ -1,6 +1,6 @@ /* bio.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -61,6 +61,7 @@ #define BIO_s_file wolfSSL_BIO_s_file #define BIO_s_bio wolfSSL_BIO_s_bio #define BIO_s_socket wolfSSL_BIO_s_socket +#define BIO_s_datagram wolfSSL_BIO_s_datagram #define BIO_s_accept wolfSSL_BIO_s_socket #define BIO_set_fd wolfSSL_BIO_set_fd #define BIO_set_close wolfSSL_BIO_set_close @@ -168,7 +169,10 @@ #define BIO_C_SET_WRITE_BUF_SIZE 136 #define BIO_C_MAKE_BIO_PAIR 138 -#define BIO_CTRL_DGRAM_QUERY_MTU 40 +#define BIO_CTRL_DGRAM_CONNECT 31 +#define BIO_CTRL_DGRAM_SET_CONNECTED 32 +#define BIO_CTRL_DGRAM_QUERY_MTU 40 +#define BIO_CTRL_DGRAM_SET_PEER 44 #define BIO_FP_TEXT 0x00 #define BIO_NOCLOSE 0x00 diff --git a/wolfssl/openssl/bn.h b/wolfssl/openssl/bn.h index d5ad52bbc1..6c0373630a 100644 --- a/wolfssl/openssl/bn.h +++ b/wolfssl/openssl/bn.h @@ -1,6 +1,6 @@ /* bn.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/buffer.h b/wolfssl/openssl/buffer.h index 52a7813ed3..c9f2790203 100644 --- a/wolfssl/openssl/buffer.h +++ b/wolfssl/openssl/buffer.h @@ -1,6 +1,6 @@ /* buffer.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/camellia.h b/wolfssl/openssl/camellia.h index aa830f5348..0cad9c9ee3 100644 --- a/wolfssl/openssl/camellia.h +++ b/wolfssl/openssl/camellia.h @@ -1,6 +1,6 @@ /* camellia.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/cmac.h b/wolfssl/openssl/cmac.h index 5ae013c124..dd08497faa 100644 --- a/wolfssl/openssl/cmac.h +++ b/wolfssl/openssl/cmac.h @@ -1,6 +1,6 @@ /* cmac.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/cms.h b/wolfssl/openssl/cms.h index 5355c61587..7febb6715e 100644 --- a/wolfssl/openssl/cms.h +++ b/wolfssl/openssl/cms.h @@ -1,6 +1,6 @@ /* cms.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/compat_types.h b/wolfssl/openssl/compat_types.h index c1afd62e1d..93a3b12dac 100644 --- a/wolfssl/openssl/compat_types.h +++ b/wolfssl/openssl/compat_types.h @@ -1,6 +1,6 @@ /* compat_types.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/conf.h b/wolfssl/openssl/conf.h index 7c3d721067..4e9115f95f 100644 --- a/wolfssl/openssl/conf.h +++ b/wolfssl/openssl/conf.h @@ -1,6 +1,6 @@ /* conf.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/crypto.h b/wolfssl/openssl/crypto.h index a787da28d1..e436e938c8 100644 --- a/wolfssl/openssl/crypto.h +++ b/wolfssl/openssl/crypto.h @@ -1,6 +1,6 @@ /* crypto.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/des.h b/wolfssl/openssl/des.h index ca0be35908..0f385a6d99 100644 --- a/wolfssl/openssl/des.h +++ b/wolfssl/openssl/des.h @@ -1,6 +1,6 @@ /* des.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/dh.h b/wolfssl/openssl/dh.h index eacd033c90..49f209ce8b 100644 --- a/wolfssl/openssl/dh.h +++ b/wolfssl/openssl/dh.h @@ -1,6 +1,6 @@ /* dh.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/dsa.h b/wolfssl/openssl/dsa.h index 5a8c31c708..76a1252e1f 100644 --- a/wolfssl/openssl/dsa.h +++ b/wolfssl/openssl/dsa.h @@ -1,6 +1,6 @@ /* dsa.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/ec.h b/wolfssl/openssl/ec.h index da988c6a94..319cf3c3bd 100644 --- a/wolfssl/openssl/ec.h +++ b/wolfssl/openssl/ec.h @@ -1,6 +1,6 @@ /* ec.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/ec25519.h b/wolfssl/openssl/ec25519.h index 6090311068..0421ce83ba 100644 --- a/wolfssl/openssl/ec25519.h +++ b/wolfssl/openssl/ec25519.h @@ -1,6 +1,6 @@ /* ec25519.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/ec448.h b/wolfssl/openssl/ec448.h index 06ce1ddfc4..89a9e1cc94 100644 --- a/wolfssl/openssl/ec448.h +++ b/wolfssl/openssl/ec448.h @@ -1,6 +1,6 @@ /* ec448.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/ecdh.h b/wolfssl/openssl/ecdh.h index 9f816b25fe..74b8c910e7 100644 --- a/wolfssl/openssl/ecdh.h +++ b/wolfssl/openssl/ecdh.h @@ -1,6 +1,6 @@ /* ecdh.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/ecdsa.h b/wolfssl/openssl/ecdsa.h index 385e5c06b2..704f56d00f 100644 --- a/wolfssl/openssl/ecdsa.h +++ b/wolfssl/openssl/ecdsa.h @@ -1,6 +1,6 @@ /* ecdsa.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/ed25519.h b/wolfssl/openssl/ed25519.h index a4f2a3ac4e..d4c1b1b913 100644 --- a/wolfssl/openssl/ed25519.h +++ b/wolfssl/openssl/ed25519.h @@ -1,6 +1,6 @@ /* ed25519.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/ed448.h b/wolfssl/openssl/ed448.h index 2d2b4b74eb..3c9786264f 100644 --- a/wolfssl/openssl/ed448.h +++ b/wolfssl/openssl/ed448.h @@ -1,6 +1,6 @@ /* ed448.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/err.h b/wolfssl/openssl/err.h index 178afa5f47..2af6407848 100644 --- a/wolfssl/openssl/err.h +++ b/wolfssl/openssl/err.h @@ -1,6 +1,6 @@ /* err.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/evp.h b/wolfssl/openssl/evp.h index 346cefc65d..f2387478d3 100644 --- a/wolfssl/openssl/evp.h +++ b/wolfssl/openssl/evp.h @@ -1,6 +1,6 @@ /* evp.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/fips_rand.h b/wolfssl/openssl/fips_rand.h index 586a9574cd..58f21b3419 100644 --- a/wolfssl/openssl/fips_rand.h +++ b/wolfssl/openssl/fips_rand.h @@ -1,6 +1,6 @@ /* fips_rand.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/hmac.h b/wolfssl/openssl/hmac.h index 818c8609c1..71a473b4fc 100644 --- a/wolfssl/openssl/hmac.h +++ b/wolfssl/openssl/hmac.h @@ -1,6 +1,6 @@ /* hmac.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/kdf.h b/wolfssl/openssl/kdf.h index 29537df199..08d8327a77 100644 --- a/wolfssl/openssl/kdf.h +++ b/wolfssl/openssl/kdf.h @@ -1,6 +1,6 @@ /* kdf.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/lhash.h b/wolfssl/openssl/lhash.h index 06c62a295e..4c1637a6e2 100644 --- a/wolfssl/openssl/lhash.h +++ b/wolfssl/openssl/lhash.h @@ -1,6 +1,6 @@ /* lhash.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/md4.h b/wolfssl/openssl/md4.h index e1f8b9ee83..d478e9622b 100644 --- a/wolfssl/openssl/md4.h +++ b/wolfssl/openssl/md4.h @@ -1,6 +1,6 @@ /* md4.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/md5.h b/wolfssl/openssl/md5.h index 81b60002e9..62533a9ffc 100644 --- a/wolfssl/openssl/md5.h +++ b/wolfssl/openssl/md5.h @@ -1,6 +1,6 @@ /* md5.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/modes.h b/wolfssl/openssl/modes.h index 3288f50fa5..e6a584c70f 100644 --- a/wolfssl/openssl/modes.h +++ b/wolfssl/openssl/modes.h @@ -1,6 +1,6 @@ /* modes.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/obj_mac.h b/wolfssl/openssl/obj_mac.h index f3fcd859c4..b083f049dc 100644 --- a/wolfssl/openssl/obj_mac.h +++ b/wolfssl/openssl/obj_mac.h @@ -1,6 +1,6 @@ /* obj_mac.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/objects.h b/wolfssl/openssl/objects.h index 5f8d8f7c00..08640fbf67 100644 --- a/wolfssl/openssl/objects.h +++ b/wolfssl/openssl/objects.h @@ -1,6 +1,6 @@ /* objects.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/ocsp.h b/wolfssl/openssl/ocsp.h index 8cd3372325..ac0e44f911 100644 --- a/wolfssl/openssl/ocsp.h +++ b/wolfssl/openssl/ocsp.h @@ -1,6 +1,6 @@ /* ocsp.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/opensslv.h b/wolfssl/openssl/opensslv.h index f68b6cafb3..8d36ea24c7 100644 --- a/wolfssl/openssl/opensslv.h +++ b/wolfssl/openssl/opensslv.h @@ -1,6 +1,6 @@ /* opensslv.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -35,24 +35,26 @@ defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER == 0x10100000L) ||\ defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER == 0x10001040L) /* valid version */ +#elif defined(HAVE_MOSQUITTO) + #define OPENSSL_VERSION_NUMBER 0x10100000L #elif defined(WOLFSSL_APACHE_HTTPD) || defined(HAVE_LIBEST) || \ defined(WOLFSSL_BIND) || defined(WOLFSSL_NGINX) || \ defined(WOLFSSL_RSYSLOG) || defined(WOLFSSL_KRB) || defined(HAVE_STUNNEL) || \ defined(WOLFSSL_OPENSSH) /* For Apache httpd, Use 1.1.0 compatibility */ - #define OPENSSL_VERSION_NUMBER 0x10100003L -#elif defined(WOLFSSL_QT) || defined(WOLFSSL_PYTHON) || defined(WOLFSSL_KRB) + #define OPENSSL_VERSION_NUMBER 0x10100003L +#elif defined(WOLFSSL_QT) || defined(WOLFSSL_PYTHON) /* For Qt and Python 3.8.5 compatibility */ - #define OPENSSL_VERSION_NUMBER 0x10101000L + #define OPENSSL_VERSION_NUMBER 0x10101000L #elif defined(WOLFSSL_HAPROXY) || defined(WOLFSSL_FFMPEG) - #define OPENSSL_VERSION_NUMBER 0x1010000fL + #define OPENSSL_VERSION_NUMBER 0x1010000fL #elif defined(OPENSSL_ALL) || defined(HAVE_LIGHTY) || \ - defined(WOLFSSL_NGINX) || defined(WOLFSSL_OPENVPN) - /* version number can be increased for Lighty after compatibility for ECDH - is added */ - #define OPENSSL_VERSION_NUMBER 0x10001040L + defined(WOLFSSL_NGINX) || defined(WOLFSSL_OPENSSH) || defined(WOLFSSL_OPENVPN) + /* version number can be increased for Lighty after compatibility for ECDH + is added */ + #define OPENSSL_VERSION_NUMBER 0x10001040L #else - #define OPENSSL_VERSION_NUMBER 0x0090810fL + #define OPENSSL_VERSION_NUMBER 0x0090810fL #endif #define OPENSSL_VERSION_TEXT "wolfSSL " LIBWOLFSSL_VERSION_STRING diff --git a/wolfssl/openssl/ossl_typ.h b/wolfssl/openssl/ossl_typ.h index 85b83c3f43..8214fa3c8c 100644 --- a/wolfssl/openssl/ossl_typ.h +++ b/wolfssl/openssl/ossl_typ.h @@ -1,6 +1,6 @@ /* ossl_typ.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/pem.h b/wolfssl/openssl/pem.h index 221e8d6f97..6d9d4418b6 100644 --- a/wolfssl/openssl/pem.h +++ b/wolfssl/openssl/pem.h @@ -1,6 +1,6 @@ /* pem.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/pkcs12.h b/wolfssl/openssl/pkcs12.h index 28a0a37805..d82954da99 100644 --- a/wolfssl/openssl/pkcs12.h +++ b/wolfssl/openssl/pkcs12.h @@ -1,6 +1,6 @@ /* pkcs12.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/pkcs7.h b/wolfssl/openssl/pkcs7.h index 41f890163b..9a53b89a5e 100644 --- a/wolfssl/openssl/pkcs7.h +++ b/wolfssl/openssl/pkcs7.h @@ -1,6 +1,6 @@ /* pkcs7.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/rand.h b/wolfssl/openssl/rand.h index cc0d72ac96..c88cd128f7 100644 --- a/wolfssl/openssl/rand.h +++ b/wolfssl/openssl/rand.h @@ -1,6 +1,6 @@ /* rand.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/rc4.h b/wolfssl/openssl/rc4.h index ca56ac8253..cef9330e38 100644 --- a/wolfssl/openssl/rc4.h +++ b/wolfssl/openssl/rc4.h @@ -1,6 +1,6 @@ /* rc4.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/ripemd.h b/wolfssl/openssl/ripemd.h index 7ba600d9a1..a7c4247931 100644 --- a/wolfssl/openssl/ripemd.h +++ b/wolfssl/openssl/ripemd.h @@ -1,6 +1,6 @@ /* ripemd.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/rsa.h b/wolfssl/openssl/rsa.h index 7284948ad4..4d276cc230 100644 --- a/wolfssl/openssl/rsa.h +++ b/wolfssl/openssl/rsa.h @@ -1,6 +1,6 @@ /* rsa.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/sha.h b/wolfssl/openssl/sha.h index ab38c5c096..f9bc1a5869 100644 --- a/wolfssl/openssl/sha.h +++ b/wolfssl/openssl/sha.h @@ -1,6 +1,6 @@ /* sha.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/sha3.h b/wolfssl/openssl/sha3.h index 4407bca61c..c2f5535c0d 100644 --- a/wolfssl/openssl/sha3.h +++ b/wolfssl/openssl/sha3.h @@ -1,6 +1,6 @@ /* sha3.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/srp.h b/wolfssl/openssl/srp.h index b60981d769..097cf51289 100644 --- a/wolfssl/openssl/srp.h +++ b/wolfssl/openssl/srp.h @@ -1,6 +1,6 @@ /* srp.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/ssl.h b/wolfssl/openssl/ssl.h index 0fbf621b7d..29dbb9a2da 100644 --- a/wolfssl/openssl/ssl.h +++ b/wolfssl/openssl/ssl.h @@ -1,6 +1,6 @@ /* ssl.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -214,6 +214,7 @@ typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; #define SSL_CTX_set_ecdh_auto wolfSSL_CTX_set_ecdh_auto #define i2d_PUBKEY wolfSSL_i2d_PUBKEY +#define i2d_X509_PUBKEY wolfSSL_i2d_X509_PUBKEY #define d2i_PUBKEY wolfSSL_d2i_PUBKEY #define d2i_PUBKEY_bio wolfSSL_d2i_PUBKEY_bio #define d2i_PublicKey wolfSSL_d2i_PublicKey @@ -254,6 +255,8 @@ typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; #define X509_F_X509_CHECK_PRIVATE_KEY 128 #ifdef WOLFSSL_DTLS + #define DTLS_client_method wolfDTLS_client_method + #define DTLS_server_method wolfDTLS_server_method #define DTLSv1_client_method wolfDTLSv1_client_method #define DTLSv1_server_method wolfDTLSv1_server_method #define DTLSv1_2_client_method wolfDTLSv1_2_client_method @@ -265,13 +268,7 @@ typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; #ifndef NO_FILESYSTEM #define SSL_CTX_use_certificate_file wolfSSL_CTX_use_certificate_file #define SSL_CTX_use_PrivateKey_file wolfSSL_CTX_use_PrivateKey_file -#ifdef WOLFSSL_APACHE_HTTPD - #define SSL_CTX_load_verify_locations(ctx,file,path) \ - wolfSSL_CTX_load_verify_locations_ex(ctx,file,path,\ - WOLFSSL_LOAD_FLAG_IGNORE_ERR) -#else - #define SSL_CTX_load_verify_locations wolfSSL_CTX_load_verify_locations -#endif + #define SSL_CTX_load_verify_locations wolfSSL_CTX_load_verify_locations_compat #define SSL_CTX_set_default_verify_paths wolfSSL_CTX_set_default_verify_paths #define SSL_CTX_use_certificate_chain_file wolfSSL_CTX_use_certificate_chain_file #define SSL_CTX_use_RSAPrivateKey_file wolfSSL_CTX_use_RSAPrivateKey_file @@ -647,6 +644,7 @@ typedef WOLFSSL_X509_NAME_ENTRY X509_NAME_ENTRY; #define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT WOLFSSL_ALWAYS_CHECK_SUBJECT #define X509_CHECK_FLAG_NO_WILDCARDS WOLFSSL_NO_WILDCARDS #define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS WOLFSSL_NO_PARTIAL_WILDCARDS +#define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS WOLFSSL_MULTI_LABEL_WILDCARDS #define X509_VP_FLAG_DEFAULT WOLFSSL_VPARAM_DEFAULT #define X509_VP_FLAG_OVERWRITE WOLFSSL_VPARAM_OVERWRITE @@ -712,7 +710,10 @@ wolfSSL_X509_STORE_set_verify_cb((WOLFSSL_X509_STORE *)(s), (WOLFSSL_X509_STORE_ #define X509_VERIFY_PARAM_set1_ip_asc wolfSSL_X509_VERIFY_PARAM_set1_ip_asc #define X509_VERIFY_PARAM_set1_ip wolfSSL_X509_VERIFY_PARAM_set1_ip #define X509_VERIFY_PARAM_set1 wolfSSL_X509_VERIFY_PARAM_set1 +#define X509_VERIFY_PARAM_lookup wolfSSL_X509_VERIFY_PARAM_lookup +#define X509_VERIFY_PARAM_inherit wolfSSL_X509_VERIFY_PARAM_inherit #define X509_STORE_load_locations wolfSSL_X509_STORE_load_locations +#define X509_STORE_get0_param wolfSSL_X509_STORE_get0_param #define X509_LOOKUP_add_dir wolfSSL_X509_LOOKUP_add_dir #define X509_LOOKUP_load_file wolfSSL_X509_LOOKUP_load_file @@ -784,7 +785,9 @@ wolfSSL_X509_STORE_set_verify_cb((WOLFSSL_X509_STORE *)(s), (WOLFSSL_X509_STORE_ #define BIO_pop wolfSSL_BIO_pop #define BIO_flush wolfSSL_BIO_flush #define BIO_pending wolfSSL_BIO_pending - +#define BIO_number_read wolfSSL_BIO_number_read +#define BIO_number_written wolfSSL_BIO_number_written +#define BIO_reset wolfSSL_BIO_reset #define BIO_get_mem_data wolfSSL_BIO_get_mem_data #define BIO_new_mem_buf wolfSSL_BIO_new_mem_buf @@ -792,6 +795,7 @@ wolfSSL_X509_STORE_set_verify_cb((WOLFSSL_X509_STORE *)(s), (WOLFSSL_X509_STORE_ #define BIO_set_write_buffer_size wolfSSL_BIO_set_write_buffer_size #define BIO_f_ssl wolfSSL_BIO_f_ssl #define BIO_new_socket wolfSSL_BIO_new_socket +#define BIO_new_dgram wolfSSL_BIO_new_dgram #define BIO_new_connect wolfSSL_BIO_new_connect #define BIO_new_accept wolfSSL_BIO_new_accept #define BIO_set_conn_port wolfSSL_BIO_set_conn_port @@ -800,6 +804,8 @@ wolfSSL_X509_STORE_set_verify_cb((WOLFSSL_X509_STORE *)(s), (WOLFSSL_X509_STORE_ #define BIO_do_handshake wolfSSL_BIO_do_handshake #define BIO_ssl_shutdown wolfSSL_BIO_ssl_shutdown #define SSL_set_bio wolfSSL_set_bio +#define SSL_set0_rbio wolfSSL_set_rbio +#define SSL_set0_wbio wolfSSL_set_wbio #define BIO_method_type wolfSSL_BIO_method_type #define BIO_set_ssl wolfSSL_BIO_set_ssl #define BIO_get_ssl wolfSSL_BIO_get_ssl @@ -835,10 +841,9 @@ wolfSSL_X509_STORE_set_verify_cb((WOLFSSL_X509_STORE *)(s), (WOLFSSL_X509_STORE_ #define COMP_zlib wolfSSL_COMP_zlib #define COMP_rle wolfSSL_COMP_rle #define SSL_COMP_add_compression_method wolfSSL_COMP_add_compression_method - -#define SSL_get_current_compression(ssl) 0 -#define SSL_get_current_expansion(ssl) 0 #define SSL_COMP_get_name wolfSSL_COMP_get_name +#define SSL_get_current_compression wolfSSL_get_current_compression +#define SSL_get_current_expansion wolfSSL_get_current_expansion #define SSL_get_ex_new_index wolfSSL_get_ex_new_index #define RSA_get_ex_new_index wolfSSL_get_ex_new_index @@ -1149,6 +1154,7 @@ wolfSSL_X509_STORE_set_verify_cb((WOLFSSL_X509_STORE *)(s), (WOLFSSL_X509_STORE_ #define DTLSv1_get_timeout(ssl, timeleft) wolfSSL_DTLSv1_get_timeout((ssl), (WOLFSSL_TIMEVAL*)(timeleft)) #define DTLSv1_handle_timeout wolfSSL_DTLSv1_handle_timeout #define DTLSv1_set_initial_timeout_duration wolfSSL_DTLSv1_set_initial_timeout_duration +#define SSL_set_mtu wolfSSL_set_mtu_compat /* DTLS SRTP */ #ifdef WOLFSSL_SRTP @@ -1201,6 +1207,10 @@ typedef WOLFSSL_SRTP_PROTECTION_PROFILE SRTP_PROTECTION_PROFILE; #define sk_SSL_CIPHER_free wolfSSL_sk_SSL_CIPHER_free #define sk_SSL_CIPHER_find wolfSSL_sk_SSL_CIPHER_find +#if defined(SESSION_CERTS) && defined(OPENSSL_EXTRA) +#define SSL_get0_peername wolfSSL_get0_peername +#endif + #if defined(OPENSSL_ALL) || defined(WOLFSSL_ASIO) || defined(WOLFSSL_HAPROXY) \ || defined(WOLFSSL_NGINX) #include @@ -1209,7 +1219,6 @@ typedef WOLFSSL_SRTP_PROTECTION_PROFILE SRTP_PROTECTION_PROFILE; #define SSL_R_SHORT_READ 10 #define ERR_R_PEM_LIB 9 #define SSL_CTRL_MODE 33 - #define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS 83 #define SSL_CTX_clear_chain_certs(ctx) SSL_CTX_set0_chain(ctx,NULL) @@ -1229,6 +1238,7 @@ typedef WOLFSSL_SRTP_PROTECTION_PROFILE SRTP_PROTECTION_PROFILE; (char *)(arg)) #endif /* OPENSSL_ALL || WOLFSSL_ASIO || WOLFSSL_HAPROXY */ +#define SSL_CTX_set_dh_auto wolfSSL_CTX_set_dh_auto #define SSL_CTX_set_tmp_dh wolfSSL_CTX_set_tmp_dh #define TLSEXT_STATUSTYPE_ocsp 1 diff --git a/wolfssl/openssl/stack.h b/wolfssl/openssl/stack.h index cee7cfc929..fe697c4c63 100644 --- a/wolfssl/openssl/stack.h +++ b/wolfssl/openssl/stack.h @@ -1,6 +1,6 @@ /* stack.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/tls1.h b/wolfssl/openssl/tls1.h index 843696a5c4..933ed5d093 100644 --- a/wolfssl/openssl/tls1.h +++ b/wolfssl/openssl/tls1.h @@ -1,6 +1,6 @@ /* tls1.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/txt_db.h b/wolfssl/openssl/txt_db.h index 511235b2cf..b8aa56f24f 100644 --- a/wolfssl/openssl/txt_db.h +++ b/wolfssl/openssl/txt_db.h @@ -1,6 +1,6 @@ /* txt_db.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/x509.h b/wolfssl/openssl/x509.h index 9afb8e01c1..eb03578e0c 100644 --- a/wolfssl/openssl/x509.h +++ b/wolfssl/openssl/x509.h @@ -1,6 +1,6 @@ /* x509.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/x509_vfy.h b/wolfssl/openssl/x509_vfy.h index 025f52678e..8666a53fee 100644 --- a/wolfssl/openssl/x509_vfy.h +++ b/wolfssl/openssl/x509_vfy.h @@ -1,6 +1,6 @@ /* x509_vfy.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/openssl/x509v3.h b/wolfssl/openssl/x509v3.h index 51b4e65554..f488857b50 100644 --- a/wolfssl/openssl/x509v3.h +++ b/wolfssl/openssl/x509v3.h @@ -1,6 +1,6 @@ /* x509v3.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/options.h.in b/wolfssl/options.h.in index 63919d63e5..aa94f3ec0e 100644 --- a/wolfssl/options.h.in +++ b/wolfssl/options.h.in @@ -1,6 +1,6 @@ /* options.h.in * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/quic.h b/wolfssl/quic.h index d4152423db..70ae61c4a5 100644 --- a/wolfssl/quic.h +++ b/wolfssl/quic.h @@ -1,6 +1,6 @@ /* quic.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/sniffer.h b/wolfssl/sniffer.h index 3b5f2373ed..3eabd42902 100644 --- a/wolfssl/sniffer.h +++ b/wolfssl/sniffer.h @@ -1,6 +1,6 @@ /* sniffer.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/sniffer_error.h b/wolfssl/sniffer_error.h index 841241d974..1794ba8979 100644 --- a/wolfssl/sniffer_error.h +++ b/wolfssl/sniffer_error.h @@ -1,6 +1,6 @@ /* sniffer_error.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/ssl.h b/wolfssl/ssl.h index 50d59a7f52..dde5841377 100644 --- a/wolfssl/ssl.h +++ b/wolfssl/ssl.h @@ -1,6 +1,6 @@ /* ssl.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -67,6 +67,15 @@ #undef OCSP_RESPONSE #endif +#ifdef OPENSSL_ALL + #ifndef WOLFSSL_HAVE_BIO_ADDR + #define WOLFSSL_HAVE_BIO_ADDR + #endif + #if defined(WOLFSSL_DTLS) && !defined(WOLFSSL_DTLS_MTU) + #define WOLFSSL_DTLS_MTU + #endif +#endif + #ifdef OPENSSL_COEXIST /* mode to allow wolfSSL and OpenSSL to exist together */ #ifdef TEST_OPENSSL_COEXIST @@ -474,7 +483,8 @@ enum BIO_TYPE { WOLFSSL_BIO_BIO = 5, WOLFSSL_BIO_FILE = 6, WOLFSSL_BIO_BASE64 = 7, - WOLFSSL_BIO_MD = 8 + WOLFSSL_BIO_MD = 8, + WOLFSSL_BIO_DGRAM = 9 }; enum BIO_FLAGS { @@ -537,38 +547,6 @@ struct WOLFSSL_BIO_METHOD { typedef long (*wolf_bio_info_cb)(WOLFSSL_BIO *bio, int event, const char *parg, int iarg, long larg, long return_value); -struct WOLFSSL_BIO { - WOLFSSL_BUF_MEM* mem_buf; - WOLFSSL_BIO_METHOD* method; - WOLFSSL_BIO* prev; /* previous in chain */ - WOLFSSL_BIO* next; /* next in chain */ - WOLFSSL_BIO* pair; /* BIO paired with */ - void* heap; /* user heap hint */ - void* ptr; /* WOLFSSL, file descriptor, MD, or mem buf */ - void* usrCtx; /* user set pointer */ - char* ip; /* IP address for wolfIO_TcpConnect */ - word16 port; /* Port for wolfIO_TcpConnect */ - char* infoArg; /* BIO callback argument */ - wolf_bio_info_cb infoCb; /* BIO callback */ - int wrSz; /* write buffer size (mem) */ - int wrSzReset; /* First buffer size (mem) - read ONLY data */ - int wrIdx; /* current index for write buffer */ - int rdIdx; /* current read index */ - int readRq; /* read request */ - int num; /* socket num or length */ - int eof; /* eof flag */ - int flags; - byte type; /* method type */ - byte init:1; /* bio has been initialized */ - byte shutdown:1; /* close flag */ -#ifdef HAVE_EX_DATA - WOLFSSL_CRYPTO_EX_DATA ex_data; -#endif -#if defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA) - wolfSSL_Ref ref; -#endif -}; - typedef struct WOLFSSL_COMP_METHOD { int type; /* stunnel dereference */ } WOLFSSL_COMP_METHOD; @@ -623,6 +601,7 @@ struct WOLFSSL_X509_STORE { #define WOLFSSL_ALWAYS_CHECK_SUBJECT 0x1 #define WOLFSSL_NO_WILDCARDS 0x2 #define WOLFSSL_NO_PARTIAL_WILDCARDS 0x4 +#define WOLFSSL_MULTI_LABEL_WILDCARDS 0x8 #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL) #define WOLFSSL_USE_CHECK_TIME 0x2 @@ -640,12 +619,13 @@ struct WOLFSSL_X509_STORE { #endif struct WOLFSSL_X509_VERIFY_PARAM { + const char *name; time_t check_time; unsigned int inherit_flags; unsigned long flags; char hostName[WOLFSSL_HOST_NAME_MAX]; - unsigned int hostFlags; - char ipasc[WOLFSSL_MAX_IPSTR]; + unsigned int hostFlags; + char ipasc[WOLFSSL_MAX_IPSTR]; }; #endif /* OPENSSL_EXTRA || WOLFSSL_WPAS_SMALL */ @@ -1103,6 +1083,8 @@ WOLFSSL_API int wolfSSL_CTX_load_verify_locations_ex( WOLFSSL_CTX* ctx, const char* file, const char* path, word32 flags); WOLFSSL_ABI WOLFSSL_API int wolfSSL_CTX_load_verify_locations( WOLFSSL_CTX* ctx, const char* file, const char* path); +WOLFSSL_API int wolfSSL_CTX_load_verify_locations_compat( + WOLFSSL_CTX* ctx, const char* file, const char* path); #ifndef _WIN32 WOLFSSL_API const char** wolfSSL_get_system_CA_dirs(word32* num); #endif /* !_WIN32 */ @@ -1143,6 +1125,7 @@ WOLFSSL_API int wolfSSL_CTX_up_ref(WOLFSSL_CTX* ctx); #ifdef OPENSSL_EXTRA WOLFSSL_API int wolfSSL_set_ecdh_auto(WOLFSSL* ssl, int onoff); WOLFSSL_API int wolfSSL_CTX_set_ecdh_auto(WOLFSSL_CTX* ctx, int onoff); +WOLFSSL_API int wolfSSL_CTX_set_dh_auto(WOLFSSL_CTX* ctx, int onoff); WOLFSSL_API int wolfSSL_get_signature_nid(WOLFSSL* ssl, int* nid); WOLFSSL_API int wolfSSL_get_signature_type_nid(const WOLFSSL* ssl, int* nid); WOLFSSL_API int wolfSSL_get_peer_signature_nid(WOLFSSL* ssl, int* nid); @@ -1482,10 +1465,18 @@ WOLFSSL_API int wolfSSL_dtls_free_peer(void* addr); WOLFSSL_API int wolfSSL_dtls_set_peer(WOLFSSL* ssl, void* peer, unsigned int peerSz); WOLFSSL_API int wolfSSL_dtls_get_peer(WOLFSSL* ssl, void* peer, unsigned int* peerSz); +#if defined(WOLFSSL_SCTP) && defined(WOLFSSL_DTLS) WOLFSSL_API int wolfSSL_CTX_dtls_set_sctp(WOLFSSL_CTX* ctx); WOLFSSL_API int wolfSSL_dtls_set_sctp(WOLFSSL* ssl); -WOLFSSL_API int wolfSSL_CTX_dtls_set_mtu(WOLFSSL_CTX* ctx, unsigned short); -WOLFSSL_API int wolfSSL_dtls_set_mtu(WOLFSSL* ssl, unsigned short); +#endif +#if (defined(WOLFSSL_SCTP) || defined(WOLFSSL_DTLS_MTU)) && \ + defined(WOLFSSL_DTLS) +WOLFSSL_API int wolfSSL_CTX_dtls_set_mtu(WOLFSSL_CTX* ctx, unsigned short mtu); +WOLFSSL_API int wolfSSL_dtls_set_mtu(WOLFSSL* ssl, unsigned short mtu); +#if defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA) +WOLFSSL_API int wolfSSL_set_mtu_compat(WOLFSSL* ssl, unsigned short mtu); +#endif +#endif #ifdef WOLFSSL_SRTP @@ -1764,6 +1755,7 @@ WOLFSSL_API WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_buffer(void); WOLFSSL_API long wolfSSL_BIO_set_write_buffer_size(WOLFSSL_BIO* bio, long size); WOLFSSL_API WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_ssl(void); WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_new_socket(int sfd, int flag); +WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_new_dgram(int fd, int closeF); WOLFSSL_API int wolfSSL_BIO_eof(WOLFSSL_BIO* b); WOLFSSL_API WOLFSSL_BIO_METHOD* wolfSSL_BIO_s_mem(void); @@ -1812,6 +1804,8 @@ WOLFSSL_API long wolfSSL_BIO_set_fd(WOLFSSL_BIO* b, int fd, int flag); #endif WOLFSSL_API int wolfSSL_BIO_set_close(WOLFSSL_BIO *b, long flag); WOLFSSL_API void wolfSSL_set_bio(WOLFSSL* ssl, WOLFSSL_BIO* rd, WOLFSSL_BIO* wr); +WOLFSSL_API void wolfSSL_set_rbio(WOLFSSL* ssl, WOLFSSL_BIO* rd); +WOLFSSL_API void wolfSSL_set_wbio(WOLFSSL* ssl, WOLFSSL_BIO* wr); WOLFSSL_API int wolfSSL_BIO_method_type(const WOLFSSL_BIO *b); #ifndef NO_FILESYSTEM @@ -1821,6 +1815,7 @@ WOLFSSL_API WOLFSSL_BIO *wolfSSL_BIO_new_fd(int fd, int close_flag); WOLFSSL_API WOLFSSL_BIO_METHOD *wolfSSL_BIO_s_bio(void); WOLFSSL_API WOLFSSL_BIO_METHOD *wolfSSL_BIO_s_socket(void); +WOLFSSL_API WOLFSSL_BIO_METHOD *wolfSSL_BIO_s_datagram(void); WOLFSSL_API WOLFSSL_BIO *wolfSSL_BIO_new_connect(const char *str); WOLFSSL_API WOLFSSL_BIO *wolfSSL_BIO_new_accept(const char *port); @@ -1844,6 +1839,10 @@ WOLFSSL_API int wolfSSL_BIO_ctrl_reset_read_request(WOLFSSL_BIO *b); WOLFSSL_API int wolfSSL_BIO_nread0(WOLFSSL_BIO *bio, char **buf); WOLFSSL_API int wolfSSL_BIO_nread(WOLFSSL_BIO *bio, char **buf, int num); WOLFSSL_API int wolfSSL_BIO_nwrite(WOLFSSL_BIO *bio, char **buf, int num); +#if defined(WORD64_AVAILABLE) && !defined(WOLFSSL_BIO_NO_FLOW_STATS) +WOLFSSL_API word64 wolfSSL_BIO_number_read(WOLFSSL_BIO *bio); +WOLFSSL_API word64 wolfSSL_BIO_number_written(WOLFSSL_BIO *bio); +#endif WOLFSSL_API int wolfSSL_BIO_reset(WOLFSSL_BIO *bio); WOLFSSL_API int wolfSSL_BIO_seek(WOLFSSL_BIO *bio, int ofs); @@ -1856,7 +1855,14 @@ WOLFSSL_API int wolfSSL_BIO_set_mem_buf(WOLFSSL_BIO* bio, WOLFSSL_BUF_MEM* bufMe int closeFlag); #endif WOLFSSL_API int wolfSSL_BIO_get_len(WOLFSSL_BIO *bio); -#endif + +#ifdef WOLFSSL_HAVE_BIO_ADDR +WOLFSSL_API WOLFSSL_BIO_ADDR *wolfSSL_BIO_ADDR_new(void); +WOLFSSL_API void wolfSSL_BIO_ADDR_free(WOLFSSL_BIO_ADDR *addr); +WOLFSSL_API void wolfSSL_BIO_ADDR_clear(WOLFSSL_BIO_ADDR *addr); +#endif /* WOLFSSL_HAVE_BIO_ADDR */ + +#endif /* !NO_BIO */ WOLFSSL_API void wolfSSL_RAND_screen(void); WOLFSSL_API const char* wolfSSL_RAND_file_name(char* fname, unsigned long len); @@ -1868,9 +1874,14 @@ WOLFSSL_API void wolfSSL_RAND_Cleanup(void); WOLFSSL_API void wolfSSL_RAND_add(const void* add, int len, double entropy); WOLFSSL_API int wolfSSL_RAND_poll(void); +#ifndef NO_WOLFSSL_STUB WOLFSSL_API WOLFSSL_COMP_METHOD* wolfSSL_COMP_zlib(void); WOLFSSL_API WOLFSSL_COMP_METHOD* wolfSSL_COMP_rle(void); WOLFSSL_API int wolfSSL_COMP_add_compression_method(int method, void* data); +WOLFSSL_API const char *wolfSSL_COMP_get_name(const WOLFSSL_COMP_METHOD *comp); +WOLFSSL_API const WOLFSSL_COMP_METHOD* wolfSSL_get_current_compression(const WOLFSSL *ssl); +WOLFSSL_API const WOLFSSL_COMP_METHOD* wolfSSL_get_current_expansion(const WOLFSSL *ssl); +#endif /* !NO_WOLFSSL_STUB */ WOLFSSL_API unsigned long wolfSSL_thread_id(void); WOLFSSL_API void wolfSSL_set_id_callback(unsigned long (*f)(void)); @@ -2061,6 +2072,8 @@ WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_d2i_PUBKEY_bio(WOLFSSL_BIO* bio, WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_d2i_PUBKEY(WOLFSSL_EVP_PKEY** key, const unsigned char** in, long inSz); WOLFSSL_API int wolfSSL_i2d_PUBKEY(const WOLFSSL_EVP_PKEY *key, unsigned char **der); +WOLFSSL_API int wolfSSL_i2d_X509_PUBKEY(WOLFSSL_X509_PUBKEY* x509_PubKey, + unsigned char** der); WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_d2i_PublicKey(int type, WOLFSSL_EVP_PKEY** pkey, const unsigned char ** in, long inSz); WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_d2i_PrivateKey(int type, @@ -2113,6 +2126,10 @@ WOLFSSL_API int wolfSSL_X509_VERIFY_PARAM_set1_ip( WOLFSSL_X509_VERIFY_PARAM* param, const unsigned char* ip, size_t iplen); WOLFSSL_API int wolfSSL_X509_VERIFY_PARAM_set1(WOLFSSL_X509_VERIFY_PARAM* to, const WOLFSSL_X509_VERIFY_PARAM* from); +WOLFSSL_API const WOLFSSL_X509_VERIFY_PARAM *wolfSSL_X509_VERIFY_PARAM_lookup( + const char *name); +WOLFSSL_API int wolfSSL_X509_VERIFY_PARAM_inherit(WOLFSSL_X509_VERIFY_PARAM *to, + const WOLFSSL_X509_VERIFY_PARAM *from); WOLFSSL_API int wolfSSL_X509_load_crl_file(WOLFSSL_X509_LOOKUP *ctx, const char *file, int type); WOLFSSL_API int wolfSSL_X509_load_cert_crl_file(WOLFSSL_X509_LOOKUP *ctx, @@ -2871,6 +2888,10 @@ WOLFSSL_API int wolfSSL_CTX_get_ex_new_index(long idx, void* arg, date check and signature check */ WOLFSSL_ABI WOLFSSL_API int wolfSSL_check_domain_name(WOLFSSL* ssl, const char* dn); +#if defined(SESSION_CERTS) && defined(OPENSSL_EXTRA) +WOLFSSL_API const char *wolfSSL_get0_peername(WOLFSSL *ssl); +#endif + /* need to call once to load library (session cache) */ WOLFSSL_ABI WOLFSSL_API int wolfSSL_Init(void); /* call when done to cleanup/free session cache mutex / resources */ @@ -3669,8 +3690,7 @@ WOLFSSL_API void wolfSSL_CTX_SetPerformTlsRecordProcessingCb(WOLFSSL_CTX* ctx, WOLFSSL_API void wolfSSL_CertManagerFree(WOLFSSL_CERT_MANAGER* cm); WOLFSSL_API int wolfSSL_CertManager_up_ref(WOLFSSL_CERT_MANAGER* cm); -#if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) \ - && defined(HAVE_OID_DECODING) +#ifdef WC_ASN_UNKNOWN_EXT_CB WOLFSSL_API void wolfSSL_CertManagerSetUnknownExtCallback( WOLFSSL_CERT_MANAGER* cm, wc_UnknownExtCallback cb); @@ -4142,7 +4162,25 @@ WOLFSSL_API long wolfSSL_SSL_get_secure_renegotiation_support(WOLFSSL* ssl); #ifdef HAVE_SESSION_TICKET #if !defined(WOLFSSL_NO_DEF_TICKET_ENC_CB) && !defined(NO_WOLFSSL_SERVER) - #if defined(HAVE_CHACHA) && defined(HAVE_POLY1305) && \ + #ifdef WOLFSSL_TICKET_ENC_CBC_HMAC + #if defined(WOLFSSL_TICKET_ENC_HMAC_SHA512) + #define WOLFSSL_TICKET_ENC_HMAC WC_HASH_TYPE_SHA512 + #define WOLFSSL_TICKET_HMAC_KEY_SZ 64 + #elif defined(WOLFSSL_TICKET_ENC_HMAC_SHA384) + #define WOLFSSL_TICKET_ENC_HMAC WC_HASH_TYPE_SHA384 + #define WOLFSSL_TICKET_HMAC_KEY_SZ 48 + #else + #define WOLFSSL_TICKET_ENC_HMAC WC_HASH_TYPE_SHA256 + #define WOLFSSL_TICKET_HMAC_KEY_SZ 32 + #endif + #ifdef WOLFSSL_TICKET_ENC_AES256_CBC + #define WOLFSSL_TICKET_KEY_SZ \ + (AES_256_KEY_SIZE + WOLFSSL_TICKET_HMAC_KEY_SZ) + #else + #define WOLFSSL_TICKET_KEY_SZ \ + (AES_128_KEY_SIZE + WOLFSSL_TICKET_HMAC_KEY_SZ) + #endif + #elif defined(HAVE_CHACHA) && defined(HAVE_POLY1305) && \ !defined(WOLFSSL_TICKET_ENC_AES128_GCM) && \ !defined(WOLFSSL_TICKET_ENC_AES256_GCM) #define WOLFSSL_TICKET_KEY_SZ CHACHA20_POLY1305_AEAD_KEYSIZE @@ -4173,7 +4211,11 @@ WOLFSSL_API int wolfSSL_send_SessionTicket(WOLFSSL* ssl); #define WOLFSSL_TICKET_NAME_SZ 16 #define WOLFSSL_TICKET_IV_SZ 16 -#define WOLFSSL_TICKET_MAC_SZ 32 +#ifndef WOLFSSL_TICKET_ENC_CBC_HMAC + #define WOLFSSL_TICKET_MAC_SZ 32 +#else + #define WOLFSSL_TICKET_MAC_SZ WOLFSSL_TICKET_HMAC_KEY_SZ +#endif enum TicketEncRet { WOLFSSL_TICKET_RET_FATAL = -1, /* fatal error, don't use ticket */ @@ -5209,7 +5251,6 @@ WOLFSSL_API int wolfSSL_i2a_ASN1_OBJECT(WOLFSSL_BIO *bp, WOLFSSL_ASN1_OBJECT *a) WOLFSSL_API int wolfSSL_i2d_ASN1_OBJECT(WOLFSSL_ASN1_OBJECT *a, unsigned char **pp); WOLFSSL_API void SSL_CTX_set_tmp_dh_callback(WOLFSSL_CTX *ctx, WOLFSSL_DH *(*dh) (WOLFSSL *ssl, int is_export, int keylength)); WOLFSSL_API WOLF_STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void); -WOLFSSL_API const char* wolfSSL_COMP_get_name(const void* comp); WOLFSSL_API int wolfSSL_X509_STORE_load_locations(WOLFSSL_X509_STORE *str, const char *file, const char *dir); WOLFSSL_API int wolfSSL_X509_STORE_add_crl(WOLFSSL_X509_STORE *ctx, WOLFSSL_X509_CRL *x); WOLFSSL_API int wolfSSL_sk_SSL_CIPHER_num(const WOLF_STACK_OF(WOLFSSL_CIPHER)* p); diff --git a/wolfssl/test.h b/wolfssl/test.h index 4dd6320e74..888d7f1ae4 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -1,6 +1,6 @@ /* test.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -1099,10 +1099,11 @@ static WC_INLINE void ShowX509Ex(WOLFSSL_X509* x509, const char* hdr, char serialMsg[80]; /* testsuite has multiple threads writing to stdout, get output - message ready to write once */ - strLen = sprintf(serialMsg, " %s", words[3]); + * message ready to write once */ + strLen = XSNPRINTF(serialMsg, sizeof(serialMsg), " %s", words[3]); for (i = 0; i < sz; i++) - sprintf(serialMsg + strLen + (i*3), ":%02x ", serial[i]); + strLen = XSNPRINTF(serialMsg + strLen, sizeof(serialMsg) - strLen, + ":%02x ", serial[i]); printf("%s\n", serialMsg); } diff --git a/wolfssl/version.h b/wolfssl/version.h index 2da6e5e80f..01fd1b683e 100644 --- a/wolfssl/version.h +++ b/wolfssl/version.h @@ -1,6 +1,6 @@ /* wolfssl_version.h.in * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/version.h.in b/wolfssl/version.h.in index 158e00b44a..ed48dcef55 100644 --- a/wolfssl/version.h.in +++ b/wolfssl/version.h.in @@ -1,6 +1,6 @@ /* wolfssl_version.h.in * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/aes.h b/wolfssl/wolfcrypt/aes.h index 46687dade9..3038882a7d 100644 --- a/wolfssl/wolfcrypt/aes.h +++ b/wolfssl/wolfcrypt/aes.h @@ -1,6 +1,6 @@ /* aes.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/arc4.h b/wolfssl/wolfcrypt/arc4.h index fe58b10ece..0dc29d3757 100644 --- a/wolfssl/wolfcrypt/arc4.h +++ b/wolfssl/wolfcrypt/arc4.h @@ -1,6 +1,6 @@ /* arc4.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/asn.h b/wolfssl/wolfcrypt/asn.h index 503c985790..acee9e4276 100644 --- a/wolfssl/wolfcrypt/asn.h +++ b/wolfssl/wolfcrypt/asn.h @@ -1,6 +1,6 @@ /* asn.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -76,13 +76,28 @@ that can be serialized and deserialized in a cross-platform way. #endif enum { - ISSUER = 0, - SUBJECT = 1, + ASN_ISSUER = 0, + ASN_SUBJECT = 1, - BEFORE = 0, - AFTER = 1 + ASN_BEFORE = 0, + ASN_AFTER = 1 }; +#ifndef NO_ASN_OLD_TYPE_NAMES + #ifndef ISSUER + #define ISSUER ASN_ISSUER + #endif + #ifndef SUBJECT + #define SUBJECT ASN_SUBJECT + #endif + #ifndef BEFORE + #define BEFORE ASN_BEFORE + #endif + #ifndef AFTER + #define AFTER ASN_AFTER + #endif +#endif + /* ASN Tags */ enum ASN_Tags { ASN_EOC = 0x00, @@ -784,7 +799,7 @@ extern const WOLFSSL_ObjectInfo wolfssl_object_info[]; * Any certificate containing more than this number of subject * alternative names will cause an error when attempting to parse. */ #ifndef WOLFSSL_MAX_ALT_NAMES -#define WOLFSSL_MAX_ALT_NAMES 128 +#define WOLFSSL_MAX_ALT_NAMES 1024 #endif /* Maximum number of allowed name constraints in a certificate. @@ -864,6 +879,10 @@ extern const WOLFSSL_ObjectInfo wolfssl_object_info[]; #define NID_X9_62_prime_field 406 /* 1.2.840.10045.1.1 */ #endif /* OPENSSL_EXTRA */ +#define NID_id_GostR3410_2001 811 +#define NID_id_GostR3410_2012_256 979 +#define NID_id_GostR3410_2012_512 980 + enum ECC_TYPES { ECC_PREFIX_0 = 160, @@ -1399,10 +1418,10 @@ struct DNS_entry { int type; /* i.e. ASN_DNS_TYPE */ int len; /* actual DNS len */ char* name; /* actual DNS name */ -#if defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME) +#ifdef WOLFSSL_IP_ALT_NAME char* ipString; /* human readable form of IP address */ #endif -#if defined(OPENSSL_ALL) +#ifdef WOLFSSL_RID_ALT_NAME char* ridString; /* human readable form of registeredID */ #endif @@ -1641,10 +1660,12 @@ typedef struct TrustedPeerCert TrustedPeerCert; typedef struct SignatureCtx SignatureCtx; typedef struct CertSignCtx CertSignCtx; -#if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) \ - && defined(HAVE_OID_DECODING) +#ifdef WC_ASN_UNKNOWN_EXT_CB typedef int (*wc_UnknownExtCallback)(const word16* oid, word32 oidSz, int crit, const unsigned char* der, word32 derSz); +typedef int (*wc_UnknownExtCallbackEx)(const word16* oid, word32 oidSz, + int crit, const unsigned char* der, + word32 derSz, void *ctx); #endif struct DecodedCert { @@ -1692,7 +1713,7 @@ struct DecodedCert { word32 extensionsIdx; /* if want to go back and parse later */ const byte* extAuthInfo; /* Authority Information Access URI */ int extAuthInfoSz; /* length of the URI */ -#if defined(OPENSSL_ALL) || defined(WOLFSSL_QT) +#ifdef WOLFSSL_ASN_CA_ISSUER const byte* extAuthInfoCaIssuer; /* Authority Info Access caIssuer URI */ int extAuthInfoCaIssuerSz; /* length of the caIssuer URI */ #endif @@ -1782,7 +1803,7 @@ struct DecodedCert { char* subjectSN; int subjectSNLen; char subjectSNEnc; - #ifdef WOLFSSL_CERT_NAME_ALL +#ifdef WOLFSSL_CERT_NAME_ALL char* subjectN; int subjectNLen; char subjectNEnc; @@ -1795,7 +1816,7 @@ struct DecodedCert { char* subjectDNQ; int subjectDNQLen; char subjectDNQEnc; - #endif /*WOLFSSL_CERT_NAME_ALL */ +#endif /* WOLFSSL_CERT_NAME_ALL */ char* subjectC; int subjectCLen; char subjectCEnc; @@ -1860,12 +1881,12 @@ struct DecodedCert { char* issuerEmail; int issuerEmailLen; #endif /* WOLFSSL_HAVE_ISSUER_NAMES */ -#endif /* defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) */ +#endif /* WOLFSSL_CERT_GEN || WOLFSSL_CERT_EXT */ #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) /* WOLFSSL_X509_NAME structures (used void* to avoid including ssl.h) */ void* issuerName; void* subjectName; -#endif /* OPENSSL_EXTRA */ +#endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */ #ifdef WOLFSSL_SEP int deviceTypeSz; byte* deviceType; @@ -1940,7 +1961,7 @@ struct DecodedCert { byte extSubjAltNameSet : 1; byte inhibitAnyOidSet : 1; byte selfSigned : 1; /* Indicates subject and issuer are same */ -#if defined(WOLFSSL_SEP) || defined(WOLFSSL_QT) +#ifdef WOLFSSL_SEP byte extCertPolicySet : 1; #endif byte extCRLdistCrit : 1; @@ -1966,7 +1987,7 @@ struct DecodedCert { byte extAltSigAlgSet : 1; byte extAltSigValSet : 1; #endif /* WOLFSSL_DUAL_ALG_CERTS */ -#if defined(WOLFSSL_SEP) || defined(WOLFSSL_QT) +#ifdef WOLFSSL_SEP byte extCertPolicyCrit : 1; #endif #ifdef WOLFSSL_CERT_REQ @@ -1975,9 +1996,10 @@ struct DecodedCert { #ifdef HAVE_RPK byte isRPK : 1; /* indicate the cert is Raw-Public-Key cert in RFC7250 */ #endif -#if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) \ - && defined(HAVE_OID_DECODING) +#ifdef WC_ASN_UNKNOWN_EXT_CB wc_UnknownExtCallback unknownExtCallback; + wc_UnknownExtCallbackEx unknownExtCallbackEx; + void *unknownExtCallbackExCtx; #endif #ifdef WOLFSSL_DUAL_ALG_CERTS /* Subject Alternative Public Key Info */ @@ -2016,7 +2038,7 @@ struct Signer { #ifndef IGNORE_NAME_CONSTRAINTS Base_entry* permittedNames; Base_entry* excludedNames; -#endif /* IGNORE_NAME_CONSTRAINTS */ +#endif /* !IGNORE_NAME_CONSTRAINTS */ byte subjectNameHash[SIGNER_DIGEST_SIZE]; /* sha hash of names in certificate */ #if defined(HAVE_OCSP) || defined(HAVE_CRL) @@ -2117,15 +2139,16 @@ typedef enum MimeStatus } MimeStatus; #endif /* HAVE_SMIME */ - WOLFSSL_LOCAL int HashIdAlg(word32 oidSum); WOLFSSL_LOCAL int CalcHashId(const byte* data, word32 len, byte* hash); WOLFSSL_LOCAL int CalcHashId_ex(const byte* data, word32 len, byte* hash, int hashAlg); WOLFSSL_LOCAL int GetName(DecodedCert* cert, int nameType, int maxIdx); -WOLFSSL_ASN_API int wc_BerToDer(const byte* ber, word32 berSz, byte* der, +#ifdef ASN_BER_TO_DER +WOLFSSL_API int wc_BerToDer(const byte* ber, word32 berSz, byte* der, word32* derSz); +#endif WOLFSSL_LOCAL int StreamOctetString(const byte* inBuf, word32 inBufSz, byte* out, word32* outSz, word32* idx); @@ -2143,10 +2166,12 @@ WOLFSSL_ASN_API void FreeDecodedCert(DecodedCert* cert); WOLFSSL_ASN_API int ParseCert(DecodedCert* cert, int type, int verify, void* cm); -#if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) \ - && defined(HAVE_OID_DECODING) -WOLFSSL_ASN_API int wc_SetUnknownExtCallback(DecodedCert* cert, +#ifdef WC_ASN_UNKNOWN_EXT_CB +WOLFSSL_API int wc_SetUnknownExtCallback(DecodedCert* cert, wc_UnknownExtCallback cb); +WOLFSSL_API int wc_SetUnknownExtCallbackEx(DecodedCert* cert, + wc_UnknownExtCallbackEx cb, + void *ctx); #endif WOLFSSL_LOCAL int DecodePolicyOID(char *out, word32 outSz, const byte *in, @@ -2158,7 +2183,7 @@ WOLFSSL_LOCAL int CheckCertSignaturePubKey(const byte* cert, word32 certSz, #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_SMALL_CERT_VERIFY) WOLFSSL_API int wc_CheckCertSignature(const byte* cert, word32 certSz, void* heap, void* cm); - /* Depricated public API name kept for backwards build compatibility */ + /* Deprecated public API name kept for backwards build compatibility */ #define CheckCertSignature(cert, certSz, heap, cm) \ wc_CheckCertSignature(cert, certSz, heap, cm) @@ -2216,6 +2241,9 @@ WOLFSSL_LOCAL int ToTraditionalInline(const byte* input, word32* inOutIdx, word32 length); WOLFSSL_LOCAL int ToTraditionalInline_ex(const byte* input, word32* inOutIdx, word32 length, word32* algId); +WOLFSSL_LOCAL int ToTraditionalInline_ex2(const byte* input, word32* inOutIdx, + word32 length, word32* algId, + word32* eccOid); WOLFSSL_LOCAL int ToTraditionalEnc(byte* input, word32 sz, const char* password, int passwordSz, word32* algId); WOLFSSL_ASN_API int UnTraditionalEnc(byte* key, word32 keySz, byte* out, @@ -2233,8 +2261,7 @@ WOLFSSL_LOCAL int wc_GetKeyOID(byte* key, word32 keySz, const byte** curveOID, word32* oidSz, int* algoID, void* heap); typedef struct tm wolfssl_tm; -#if defined(OPENSSL_ALL) || defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(OPENSSL_EXTRA) || \ - defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) +#ifdef WOLFSSL_ASN_TIME_STRING WOLFSSL_LOCAL int GetTimeString(byte* date, int format, char* buf, int len); #endif #if !defined(NO_ASN_TIME) && !defined(USER_TIME) && \ @@ -2401,13 +2428,12 @@ WOLFSSL_LOCAL int AllocCopyDer(DerBuffer** der, const unsigned char* buff, word32 length, int type, void* heap); WOLFSSL_LOCAL void FreeDer(DerBuffer** der); -#if (defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_EXT)) || \ - (defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA)) +#ifdef WOLFSSL_ASN_PARSE_KEYUSAGE WOLFSSL_LOCAL int ParseKeyUsageStr(const char* value, word16* keyUsage, void* heap); WOLFSSL_LOCAL int ParseExtKeyUsageStr(const char* value, byte* extKeyUsage, void* heap); -#endif /* (CERT_GEN && CERT_EXT) || (OPENSSL_ALL || OPENSSL_EXTRA) */ +#endif #endif /* !NO_CERTS */ @@ -2499,8 +2525,7 @@ struct CertStatus { byte nextDate[MAX_DATE_SIZE]; byte thisDateFormat; byte nextDateFormat; -#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || \ - defined(WOLFSSL_HAPROXY) || defined(HAVE_LIGHTY) +#ifdef WOLFSSL_OCSP_PARSE_STATUS WOLFSSL_ASN1_TIME thisDateParsed; WOLFSSL_ASN1_TIME nextDateParsed; byte* thisDateAsn; @@ -2585,10 +2610,6 @@ struct OcspRequest { int serialSz; #ifdef OPENSSL_EXTRA WOLFSSL_ASN1_INTEGER* serialInt; -#endif -#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || \ - defined(WOLFSSL_HAPROXY) || defined(WOLFSSL_APACHE_HTTPD) || \ - defined(HAVE_LIGHTY) void* cid; /* WOLFSSL_OCSP_CERTID kept to free */ #endif byte* url; /* copy of the extAuthInfo in source cert */ @@ -2739,7 +2760,9 @@ enum PBESTypes { PBES2 = 13, /* algo ID */ PBES1_MD5_DES = 3, - PBES1_SHA1_DES = 10 + PBES1_SHA1_DES = 10, + + PBE_NONE = 999 }; enum PKCSTypes { diff --git a/wolfssl/wolfcrypt/asn_public.h b/wolfssl/wolfcrypt/asn_public.h index f233004a36..ae77875774 100644 --- a/wolfssl/wolfcrypt/asn_public.h +++ b/wolfssl/wolfcrypt/asn_public.h @@ -1,6 +1,6 @@ /* asn_public.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -177,7 +177,8 @@ enum CertType { SPHINCS_SMALL_LEVEL3_TYPE, SPHINCS_SMALL_LEVEL5_TYPE, ECC_PARAM_TYPE, - CHAIN_CERT_TYPE + CHAIN_CERT_TYPE, + PKCS7_TYPE }; @@ -360,7 +361,6 @@ typedef struct WOLFSSL_ASN1_INTEGER { #endif #endif /* WOLFSSL_CERT_GEN || WOLFSSL_CERT_EXT */ -#if defined(WOLFSSL_CERT_GEN) || defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) #ifdef WOLFSSL_MULTI_ATTRIB #ifndef CTC_MAX_ATTRIB #define CTC_MAX_ATTRIB 4 @@ -374,7 +374,6 @@ typedef struct NameAttrib { char value[CTC_NAME_SIZE]; /* name */ } NameAttrib; #endif /* WOLFSSL_MULTI_ATTRIB */ -#endif /* WOLFSSL_CERT_GEN || OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */ #ifdef WOLFSSL_CUSTOM_OID typedef struct CertOidField { diff --git a/wolfssl/wolfcrypt/blake2-impl.h b/wolfssl/wolfcrypt/blake2-impl.h index 2cdbf40101..1a0db320e7 100644 --- a/wolfssl/wolfcrypt/blake2-impl.h +++ b/wolfssl/wolfcrypt/blake2-impl.h @@ -12,7 +12,7 @@ */ /* blake2-impl.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/blake2-int.h b/wolfssl/wolfcrypt/blake2-int.h index 0ad625ee67..b048ca5e89 100644 --- a/wolfssl/wolfcrypt/blake2-int.h +++ b/wolfssl/wolfcrypt/blake2-int.h @@ -12,7 +12,7 @@ */ /* blake2-int.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/blake2.h b/wolfssl/wolfcrypt/blake2.h index 1c62e643af..1f4ac77f10 100644 --- a/wolfssl/wolfcrypt/blake2.h +++ b/wolfssl/wolfcrypt/blake2.h @@ -1,6 +1,6 @@ /* blake2.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/camellia.h b/wolfssl/wolfcrypt/camellia.h index 928312354d..bdba23bc90 100644 --- a/wolfssl/wolfcrypt/camellia.h +++ b/wolfssl/wolfcrypt/camellia.h @@ -27,7 +27,7 @@ /* camellia.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/chacha.h b/wolfssl/wolfcrypt/chacha.h index 6c9577b110..c3af0507af 100644 --- a/wolfssl/wolfcrypt/chacha.h +++ b/wolfssl/wolfcrypt/chacha.h @@ -1,6 +1,6 @@ /* chacha.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -82,7 +82,8 @@ typedef struct ChaCha { byte extra[12]; #endif word32 left; /* number of bytes leftover */ -#if defined(USE_INTEL_CHACHA_SPEEDUP) || defined(WOLFSSL_ARMASM) +#if defined(USE_INTEL_CHACHA_SPEEDUP) || defined(WOLFSSL_ARMASM) || \ + defined(WOLFSSL_RISCV_ASM) word32 over[CHACHA_CHUNK_WORDS]; #endif } ChaCha; diff --git a/wolfssl/wolfcrypt/chacha20_poly1305.h b/wolfssl/wolfcrypt/chacha20_poly1305.h index 6c04912a03..929a1a640e 100644 --- a/wolfssl/wolfcrypt/chacha20_poly1305.h +++ b/wolfssl/wolfcrypt/chacha20_poly1305.h @@ -1,6 +1,6 @@ /* chacha20_poly1305.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/cmac.h b/wolfssl/wolfcrypt/cmac.h index a92e83207c..015a9a0a63 100644 --- a/wolfssl/wolfcrypt/cmac.h +++ b/wolfssl/wolfcrypt/cmac.h @@ -1,6 +1,6 @@ /* cmac.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/coding.h b/wolfssl/wolfcrypt/coding.h index e0aecc6282..5aef5b1151 100644 --- a/wolfssl/wolfcrypt/coding.h +++ b/wolfssl/wolfcrypt/coding.h @@ -1,6 +1,6 @@ /* coding.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/compress.h b/wolfssl/wolfcrypt/compress.h index a4efc7809e..2886b2be89 100644 --- a/wolfssl/wolfcrypt/compress.h +++ b/wolfssl/wolfcrypt/compress.h @@ -1,6 +1,6 @@ /* compress.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/cpuid.h b/wolfssl/wolfcrypt/cpuid.h index 9d25dcf327..c91b628b5b 100644 --- a/wolfssl/wolfcrypt/cpuid.h +++ b/wolfssl/wolfcrypt/cpuid.h @@ -1,6 +1,6 @@ /* cpuid.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/cryptocb.h b/wolfssl/wolfcrypt/cryptocb.h index 29580eaa6a..4b53db9d36 100644 --- a/wolfssl/wolfcrypt/cryptocb.h +++ b/wolfssl/wolfcrypt/cryptocb.h @@ -1,6 +1,6 @@ /* cryptocb.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/curve25519.h b/wolfssl/wolfcrypt/curve25519.h index 3b25a9dfa5..4d6d90da45 100644 --- a/wolfssl/wolfcrypt/curve25519.h +++ b/wolfssl/wolfcrypt/curve25519.h @@ -1,6 +1,6 @@ /* curve25519.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/curve448.h b/wolfssl/wolfcrypt/curve448.h index aa00e1021e..75df9e2fb3 100644 --- a/wolfssl/wolfcrypt/curve448.h +++ b/wolfssl/wolfcrypt/curve448.h @@ -1,6 +1,6 @@ /* curve448.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/des3.h b/wolfssl/wolfcrypt/des3.h index d5b1232126..7c46b8e35c 100644 --- a/wolfssl/wolfcrypt/des3.h +++ b/wolfssl/wolfcrypt/des3.h @@ -1,6 +1,6 @@ /* des3.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/dh.h b/wolfssl/wolfcrypt/dh.h index 93e8475367..948c44a63a 100644 --- a/wolfssl/wolfcrypt/dh.h +++ b/wolfssl/wolfcrypt/dh.h @@ -1,6 +1,6 @@ /* dh.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/dilithium.h b/wolfssl/wolfcrypt/dilithium.h index 8b336cf0de..742c8ecb91 100644 --- a/wolfssl/wolfcrypt/dilithium.h +++ b/wolfssl/wolfcrypt/dilithium.h @@ -1,6 +1,6 @@ /* dilithium.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -384,6 +384,9 @@ /* Maximum count of elements of a vector with dimension L. */ #define DILITHIUM_MAX_L_VECTOR_COUNT \ (PARAMS_ML_DSA_87_L * DILITHIUM_N) +/* Maximum count of elements of a matrix with dimension KxL. */ +#define DILITHIUM_MAX_MATRIX_COUNT \ + (PARAMS_ML_DSA_87_K * PARAMS_ML_DSA_87_L * DILITHIUM_N) #elif !defined(WOLFSSL_NO_ML_DSA_65) @@ -398,6 +401,9 @@ /* Maximum count of elements of a vector with dimension L. */ #define DILITHIUM_MAX_L_VECTOR_COUNT \ (PARAMS_ML_DSA_65_L * DILITHIUM_N) +/* Maximum count of elements of a matrix with dimension KxL. */ +#define DILITHIUM_MAX_MATRIX_COUNT \ + (PARAMS_ML_DSA_65_K * PARAMS_ML_DSA_65_L * DILITHIUM_N) #else @@ -412,6 +418,9 @@ /* Maximum count of elements of a vector with dimension L. */ #define DILITHIUM_MAX_L_VECTOR_COUNT \ (PARAMS_ML_DSA_44_L * DILITHIUM_N) +/* Maximum count of elements of a matrix with dimension KxL. */ +#define DILITHIUM_MAX_MATRIX_COUNT \ + (PARAMS_ML_DSA_44_K * PARAMS_ML_DSA_44_L * DILITHIUM_N) #endif @@ -531,6 +540,8 @@ struct dilithium_key { byte prvKeySet; byte level; /* 2,3 or 5 */ + void* heap; /* heap hint */ + #ifdef WOLF_CRYPTO_CB void* devCtx; int devId; @@ -553,6 +564,7 @@ struct dilithium_key { #ifdef WOLFSSL_WC_DILITHIUM const wc_dilithium_params* params; wc_Shake shake; +#ifndef WC_DILITHIUM_FIXED_ARRAY #ifdef WC_DILITHIUM_CACHE_MATRIX_A sword32* a; byte aSet; @@ -567,6 +579,22 @@ struct dilithium_key { sword32* t1; byte pubVecSet; #endif +#else +#ifdef WC_DILITHIUM_CACHE_MATRIX_A + sword32 a[DILITHIUM_MAX_MATRIX_COUNT]; + byte aSet; +#endif +#ifdef WC_DILITHIUM_CACHE_PRIV_VECTORS + sword32 s1[DILITHIUM_MAX_L_VECTOR_COUNT]; + sword32 s2[DILITHIUM_MAX_K_VECTOR_COUNT]; + sword32 t0[DILITHIUM_MAX_K_VECTOR_COUNT]; + byte privVecsSet; +#endif +#ifdef WC_DILITHIUM_CACHE_PUB_VECTORS + sword32 t1[DILITHIUM_MAX_K_VECTOR_COUNT]; + byte pubVecSet; +#endif +#endif #if defined(WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC) && \ defined(WOLFSSL_DILITHIUM_VERIFY_SMALL_MEM) sword32 z[DILITHIUM_MAX_L_VECTOR_COUNT]; @@ -574,6 +602,9 @@ struct dilithium_key { sword32 w[DILITHIUM_N]; sword32 t1[DILITHIUM_N]; byte w1e[DILITHIUM_MAX_W1_ENC_SZ]; +#ifdef WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 + sword64 t64[DILITHIUM_N]; +#endif byte h[DILITHIUM_REJ_NTT_POLY_H_SIZE]; byte block[DILITHIUM_GEN_C_BLOCK_BYTES]; #endif /* WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC && @@ -684,11 +715,13 @@ int wc_dilithium_export_key(dilithium_key* key, byte* priv, word32 *privSz, WOLFSSL_API int wc_Dilithium_PrivateKeyDecode(const byte* input, word32* inOutIdx, dilithium_key* key, word32 inSz); #endif +#endif /* WOLFSSL_DILITHIUM_NO_ASN1 */ #ifdef WOLFSSL_DILITHIUM_PUBLIC_KEY WOLFSSL_API int wc_Dilithium_PublicKeyDecode(const byte* input, word32* inOutIdx, dilithium_key* key, word32 inSz); #endif +#ifndef WOLFSSL_DILITHIUM_NO_ASN1 #ifdef WC_ENABLE_ASYM_KEY_EXPORT WOLFSSL_API int wc_Dilithium_PublicKeyToDer(dilithium_key* key, byte* output, word32 inLen, int withAlg); diff --git a/wolfssl/wolfcrypt/dsa.h b/wolfssl/wolfcrypt/dsa.h index d5ae3a4f82..1e92fd5ed2 100644 --- a/wolfssl/wolfcrypt/dsa.h +++ b/wolfssl/wolfcrypt/dsa.h @@ -1,6 +1,6 @@ /* dsa.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/ecc.h b/wolfssl/wolfcrypt/ecc.h index 4a198a6b0d..e73c10b9bd 100644 --- a/wolfssl/wolfcrypt/ecc.h +++ b/wolfssl/wolfcrypt/ecc.h @@ -1,6 +1,6 @@ /* ecc.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -595,6 +595,7 @@ struct ecc_key { #if defined(WOLFSSL_ECDSA_DETERMINISTIC_K) || \ defined(WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT) byte deterministic:1; + enum wc_HashType hashType; #endif #if defined(WOLFSSL_SMALL_STACK_CACHE) && !defined(WOLFSSL_ECC_NO_SMALL_STACK) @@ -719,6 +720,9 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng, WOLFSSL_API int wc_ecc_set_deterministic(ecc_key* key, byte flag); WOLFSSL_API +int wc_ecc_set_deterministic_ex(ecc_key* key, byte flag, + enum wc_HashType hashType); +WOLFSSL_API int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz, enum wc_HashType hashType, mp_int* priv, mp_int* k, mp_int* order, void* heap); diff --git a/wolfssl/wolfcrypt/eccsi.h b/wolfssl/wolfcrypt/eccsi.h index 8e0124ccad..72f9c70637 100644 --- a/wolfssl/wolfcrypt/eccsi.h +++ b/wolfssl/wolfcrypt/eccsi.h @@ -1,6 +1,6 @@ /* eccsi.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/ed25519.h b/wolfssl/wolfcrypt/ed25519.h index efba65020b..ff3b26cb0c 100644 --- a/wolfssl/wolfcrypt/ed25519.h +++ b/wolfssl/wolfcrypt/ed25519.h @@ -1,6 +1,6 @@ /* ed25519.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/ed448.h b/wolfssl/wolfcrypt/ed448.h index 5884bda131..1d12da87ae 100644 --- a/wolfssl/wolfcrypt/ed448.h +++ b/wolfssl/wolfcrypt/ed448.h @@ -1,6 +1,6 @@ /* ed448.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/error-crypt.h b/wolfssl/wolfcrypt/error-crypt.h index dbe0553e51..8fb71b3c6a 100644 --- a/wolfssl/wolfcrypt/error-crypt.h +++ b/wolfssl/wolfcrypt/error-crypt.h @@ -1,6 +1,6 @@ /* error-crypt.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -300,10 +300,16 @@ WOLFSSL_ABI WOLFSSL_API const char* wc_GetErrorString(int error); #ifdef WOLFSSL_DEBUG_TRACE_ERROR_CODES #define WC_NO_ERR_TRACE(label) (CONST_NUM_ERR_ ## label) #ifndef WC_ERR_TRACE + #ifdef NO_STDIO_FILESYSTEM + #define WC_ERR_TRACE(label) \ + ( printf("ERR TRACE: %s L %d " #label " (%d)\n", \ + __FILE__, __LINE__, label), label) + #else #define WC_ERR_TRACE(label) \ ( fprintf(stderr, \ "ERR TRACE: %s L %d " #label " (%d)\n", \ __FILE__, __LINE__, label), label) + #endif #endif #include #else diff --git a/wolfssl/wolfcrypt/ext_kyber.h b/wolfssl/wolfcrypt/ext_kyber.h index 0ea7108b1b..95b22a1a84 100644 --- a/wolfssl/wolfcrypt/ext_kyber.h +++ b/wolfssl/wolfcrypt/ext_kyber.h @@ -1,6 +1,6 @@ /* ext_kyber.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/ext_lms.h b/wolfssl/wolfcrypt/ext_lms.h index fae812fd1a..8be32bf5f7 100644 --- a/wolfssl/wolfcrypt/ext_lms.h +++ b/wolfssl/wolfcrypt/ext_lms.h @@ -1,6 +1,6 @@ /* ext_lms.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/ext_xmss.h b/wolfssl/wolfcrypt/ext_xmss.h index 5f51bf54dd..927ab6ed46 100644 --- a/wolfssl/wolfcrypt/ext_xmss.h +++ b/wolfssl/wolfcrypt/ext_xmss.h @@ -1,6 +1,6 @@ /* ext_xmss.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/falcon.h b/wolfssl/wolfcrypt/falcon.h index 9d4bff8bef..a103034bc2 100644 --- a/wolfssl/wolfcrypt/falcon.h +++ b/wolfssl/wolfcrypt/falcon.h @@ -1,6 +1,6 @@ /* falcon.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/fe_448.h b/wolfssl/wolfcrypt/fe_448.h index c925d7da42..09ff15025e 100644 --- a/wolfssl/wolfcrypt/fe_448.h +++ b/wolfssl/wolfcrypt/fe_448.h @@ -1,6 +1,6 @@ /* fe448_448.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/fe_operations.h b/wolfssl/wolfcrypt/fe_operations.h index 8a1cab7fe9..23928f26b0 100644 --- a/wolfssl/wolfcrypt/fe_operations.h +++ b/wolfssl/wolfcrypt/fe_operations.h @@ -1,6 +1,6 @@ /* fe_operations.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/fips_test.h b/wolfssl/wolfcrypt/fips_test.h index 487b3e2f6c..6523753497 100644 --- a/wolfssl/wolfcrypt/fips_test.h +++ b/wolfssl/wolfcrypt/fips_test.h @@ -1,6 +1,6 @@ /* fips_test.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/ge_448.h b/wolfssl/wolfcrypt/ge_448.h index 38ac71a2fe..bbdb0674d4 100644 --- a/wolfssl/wolfcrypt/ge_448.h +++ b/wolfssl/wolfcrypt/ge_448.h @@ -1,6 +1,6 @@ /* ge_448.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/ge_operations.h b/wolfssl/wolfcrypt/ge_operations.h index 0c6ce8dd63..dd70d3bb59 100644 --- a/wolfssl/wolfcrypt/ge_operations.h +++ b/wolfssl/wolfcrypt/ge_operations.h @@ -1,6 +1,6 @@ /* ge_operations.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/hash.h b/wolfssl/wolfcrypt/hash.h index 27b1423780..2f7de32d0d 100644 --- a/wolfssl/wolfcrypt/hash.h +++ b/wolfssl/wolfcrypt/hash.h @@ -1,6 +1,6 @@ /* hash.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/hmac.h b/wolfssl/wolfcrypt/hmac.h index 0d0844e1fc..98270ee7ba 100644 --- a/wolfssl/wolfcrypt/hmac.h +++ b/wolfssl/wolfcrypt/hmac.h @@ -1,6 +1,6 @@ /* hmac.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/hpke.h b/wolfssl/wolfcrypt/hpke.h index 432f574da8..6e406ba05d 100644 --- a/wolfssl/wolfcrypt/hpke.h +++ b/wolfssl/wolfcrypt/hpke.h @@ -1,6 +1,6 @@ /* hpke.h * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/integer.h b/wolfssl/wolfcrypt/integer.h index 243d3f0d13..6efb4d8e23 100644 --- a/wolfssl/wolfcrypt/integer.h +++ b/wolfssl/wolfcrypt/integer.h @@ -1,6 +1,6 @@ /* integer.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/kdf.h b/wolfssl/wolfcrypt/kdf.h index ad107e5e52..1e731ebc63 100644 --- a/wolfssl/wolfcrypt/kdf.h +++ b/wolfssl/wolfcrypt/kdf.h @@ -1,6 +1,6 @@ /* kdf.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/kyber.h b/wolfssl/wolfcrypt/kyber.h index 8e9a7b3e49..87b1442a88 100644 --- a/wolfssl/wolfcrypt/kyber.h +++ b/wolfssl/wolfcrypt/kyber.h @@ -1,6 +1,6 @@ /* kyber.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/lms.h b/wolfssl/wolfcrypt/lms.h index fe87388f26..45c64e002b 100644 --- a/wolfssl/wolfcrypt/lms.h +++ b/wolfssl/wolfcrypt/lms.h @@ -1,6 +1,6 @@ /* lms.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/logging.h b/wolfssl/wolfcrypt/logging.h index d17f834c4e..7d349fecea 100644 --- a/wolfssl/wolfcrypt/logging.h +++ b/wolfssl/wolfcrypt/logging.h @@ -1,6 +1,6 @@ /* logging.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/md2.h b/wolfssl/wolfcrypt/md2.h index e326a4d791..fe927561c5 100644 --- a/wolfssl/wolfcrypt/md2.h +++ b/wolfssl/wolfcrypt/md2.h @@ -1,6 +1,6 @@ /* md2.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/md4.h b/wolfssl/wolfcrypt/md4.h index f367cde627..c4bd266a26 100644 --- a/wolfssl/wolfcrypt/md4.h +++ b/wolfssl/wolfcrypt/md4.h @@ -1,6 +1,6 @@ /* md4.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/md5.h b/wolfssl/wolfcrypt/md5.h index 6506be9894..c19f6c15f7 100644 --- a/wolfssl/wolfcrypt/md5.h +++ b/wolfssl/wolfcrypt/md5.h @@ -1,6 +1,6 @@ /* md5.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/mem_track.h b/wolfssl/wolfcrypt/mem_track.h index c6d81633de..b45bf2388a 100644 --- a/wolfssl/wolfcrypt/mem_track.h +++ b/wolfssl/wolfcrypt/mem_track.h @@ -1,6 +1,6 @@ /* mem_track.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/memory.h b/wolfssl/wolfcrypt/memory.h index 31b6a28f5e..481f8aa796 100644 --- a/wolfssl/wolfcrypt/memory.h +++ b/wolfssl/wolfcrypt/memory.h @@ -1,6 +1,6 @@ /* memory.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/misc.h b/wolfssl/wolfcrypt/misc.h index 9761d686a2..533faf2df8 100644 --- a/wolfssl/wolfcrypt/misc.h +++ b/wolfssl/wolfcrypt/misc.h @@ -1,6 +1,6 @@ /* misc.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/mpi_class.h b/wolfssl/wolfcrypt/mpi_class.h index 0736d6f8f3..831fae35ca 100644 --- a/wolfssl/wolfcrypt/mpi_class.h +++ b/wolfssl/wolfcrypt/mpi_class.h @@ -1,6 +1,6 @@ /* mpi_class.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/mpi_superclass.h b/wolfssl/wolfcrypt/mpi_superclass.h index abfac6af5e..f27f61a2a3 100644 --- a/wolfssl/wolfcrypt/mpi_superclass.h +++ b/wolfssl/wolfcrypt/mpi_superclass.h @@ -1,6 +1,6 @@ /* mpi_superclass.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/pkcs11.h b/wolfssl/wolfcrypt/pkcs11.h index c754784022..27758c062f 100644 --- a/wolfssl/wolfcrypt/pkcs11.h +++ b/wolfssl/wolfcrypt/pkcs11.h @@ -1,6 +1,6 @@ /* pkcs11.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -138,14 +138,22 @@ extern "C" { #define CKA_HAS_RESET 0x00000302UL #define CKM_RSA_PKCS_KEY_PAIR_GEN 0x00000000UL +#define CKM_RSA_PKCS 0x00000001UL #define CKM_RSA_X_509 0x00000003UL +#define CKM_RSA_PKCS_OAEP 0x00000009UL +#define CKM_RSA_PKCS_PSS 0x0000000DUL #define CKM_DH_PKCS_KEY_PAIR_GEN 0x00000020UL #define CKM_DH_PKCS_DERIVE 0x00000021UL #define CKM_MD5_HMAC 0x00000211UL +#define CKM_SHA_1 0x00000220UL #define CKM_SHA_1_HMAC 0x00000221UL +#define CKM_SHA256 0x00000250UL #define CKM_SHA256_HMAC 0x00000251UL +#define CKM_SHA224 0x00000255UL #define CKM_SHA224_HMAC 0x00000256UL +#define CKM_SHA384 0x00000260UL #define CKM_SHA384_HMAC 0x00000261UL +#define CKM_SHA512 0x00000270UL #define CKM_SHA512_HMAC 0x00000271UL #define CKM_GENERIC_SECRET_KEY_GEN 0x00000350UL #define CKM_EC_KEY_PAIR_GEN 0x00001040UL @@ -156,12 +164,19 @@ extern "C" { #define CKM_AES_CBC 0x00001082UL #define CKM_AES_GCM 0x00001087UL +#define CKG_MGF1_SHA1 0x00000001UL +#define CKG_MGF1_SHA224 0x00000005UL +#define CKG_MGF1_SHA256 0x00000002UL +#define CKG_MGF1_SHA384 0x00000003UL +#define CKG_MGF1_SHA512 0x00000004UL + + #define CKR_OK 0x00000000UL #define CKR_MECHANISM_INVALID 0x00000070UL #define CKR_SIGNATURE_INVALID 0x000000C0UL #define CKD_NULL 0x00000001UL - +#define CKZ_DATA_SPECIFIED 0x00000001UL typedef unsigned char CK_BYTE; typedef CK_BYTE CK_CHAR; @@ -339,6 +354,26 @@ typedef struct CK_GCM_PARAMS { } CK_GCM_PARAMS; typedef CK_GCM_PARAMS* CK_GCM_PARAMS_PTR; +typedef CK_ULONG CK_RSA_PKCS_MGF_TYPE; + +typedef struct CK_RSA_PKCS_PSS_PARAMS { + CK_MECHANISM_TYPE hashAlg; + CK_RSA_PKCS_MGF_TYPE mgf; + CK_ULONG sLen; +} CK_RSA_PKCS_PSS_PARAMS; +typedef CK_RSA_PKCS_PSS_PARAMS *CK_RSA_PKCS_PSS_PARAMS_PTR; + +typedef CK_ULONG CK_RSA_PKCS_OAEP_SOURCE_TYPE; + +typedef struct CK_RSA_PKCS_OAEP_PARAMS { + CK_MECHANISM_TYPE hashAlg; + CK_RSA_PKCS_MGF_TYPE mgf; + CK_RSA_PKCS_OAEP_SOURCE_TYPE source; + CK_VOID_PTR pSourceData; + CK_ULONG ulSourceDataLen; +} CK_RSA_PKCS_OAEP_PARAMS; +typedef CK_RSA_PKCS_OAEP_PARAMS *CK_RSA_PKCS_OAEP_PARAMS_PTR; + /* Function list types. */ typedef struct CK_FUNCTION_LIST CK_FUNCTION_LIST; typedef CK_FUNCTION_LIST* CK_FUNCTION_LIST_PTR; @@ -538,4 +573,3 @@ struct CK_FUNCTION_LIST { #endif #endif /* _PKCS11_H_ */ - diff --git a/wolfssl/wolfcrypt/pkcs12.h b/wolfssl/wolfcrypt/pkcs12.h index dc06c9df25..d7bf967d8a 100644 --- a/wolfssl/wolfcrypt/pkcs12.h +++ b/wolfssl/wolfcrypt/pkcs12.h @@ -1,6 +1,6 @@ /* pkcs12.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/pkcs7.h b/wolfssl/wolfcrypt/pkcs7.h index 2af117dcb9..59011091b1 100644 --- a/wolfssl/wolfcrypt/pkcs7.h +++ b/wolfssl/wolfcrypt/pkcs7.h @@ -1,6 +1,6 @@ /* pkcs7.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -345,6 +345,10 @@ struct PKCS7 { word32 plainDigestSz; word32 pkcs7DigestSz; +#ifdef WC_ASN_UNKNOWN_EXT_CB + wc_UnknownExtCallback unknownExtCallback; +#endif + #if defined(HAVE_PKCS7_RSA_RAW_SIGN_CALLBACK) && !defined(NO_RSA) CallbackRsaSignRawDigest rsaSignRawDigestCb; #endif @@ -358,6 +362,10 @@ struct PKCS7 { }; WOLFSSL_API PKCS7* wc_PKCS7_New(void* heap, int devId); +#ifdef WC_ASN_UNKNOWN_EXT_CB + WOLFSSL_API void wc_PKCS7_SetUnknownExtCallback(PKCS7* pkcs7, + wc_UnknownExtCallback cb); +#endif WOLFSSL_API int wc_PKCS7_Init(PKCS7* pkcs7, void* heap, int devId); WOLFSSL_API int wc_PKCS7_InitWithCert(PKCS7* pkcs7, byte* der, word32 derSz); WOLFSSL_API int wc_PKCS7_AddCertificate(PKCS7* pkcs7, byte* der, word32 derSz); diff --git a/wolfssl/wolfcrypt/poly1305.h b/wolfssl/wolfcrypt/poly1305.h index 00232ae781..7e598e8595 100644 --- a/wolfssl/wolfcrypt/poly1305.h +++ b/wolfssl/wolfcrypt/poly1305.h @@ -1,6 +1,6 @@ /* poly1305.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/Espressif/esp-sdk-lib.h b/wolfssl/wolfcrypt/port/Espressif/esp-sdk-lib.h index 55ff661883..a7873f203d 100644 --- a/wolfssl/wolfcrypt/port/Espressif/esp-sdk-lib.h +++ b/wolfssl/wolfcrypt/port/Espressif/esp-sdk-lib.h @@ -116,7 +116,7 @@ ** the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid" */ #if defined(CONFIG_ESP_WIFI_SSID) - /* tyically from ESP32 with ESP-IDF v4 ot v5 */ + /* tyically from ESP32 with ESP-IDF v4 or v5 */ #define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID #elif defined(CONFIG_EXAMPLE_WIFI_SSID) /* typically from ESP8266 rtos-sdk/v3.4 */ diff --git a/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt.h b/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt.h index e719b93f59..b4faa7368d 100644 --- a/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt.h +++ b/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt.h @@ -1,6 +1,6 @@ /* renesas-fspsm-crypt.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-types.h b/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-types.h index b110343f1b..33dcbbc8df 100644 --- a/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-types.h +++ b/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-types.h @@ -1,6 +1,6 @@ /* renesas-fsp-crypt.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -31,7 +31,7 @@ #define FSPSM_W_KEYVAR renesas_sce_wrappedkey #define FSPSM_tls_flg_ST sce_keyflgs_tls - #define FSPSM_key_flg_ST sce_keyflgs_cryt + #define FSPSM_key_flg_ST sce_keyflgs_crypt #define FSPSM_tag_ST tagUser_SCEPKCbInfo #define FSPSM_ST User_SCEPKCbInfo #define FSPSM_ST_PKC SCE_PKCbInfo @@ -171,7 +171,7 @@ /* structure, type so on */ #define FSPSM_W_KEYVAR renesas_rsip_wrappedkey #define FSPSM_tls_flg_ST rsip_keyflgs_tls - #define FSPSM_key_flg_ST rsip_keyflgs_cryt + #define FSPSM_key_flg_ST rsip_keyflgs_crypt #define FSPSM_tag_ST tagUser_RSIPPKCbInfo #define FSPSM_ST User_RSIPPKCbInfo #define FSPSM_ST_PKC RSIP_PKCbInfo diff --git a/wolfssl/wolfcrypt/port/Renesas/renesas-rx64-hw-crypt.h b/wolfssl/wolfcrypt/port/Renesas/renesas-rx64-hw-crypt.h index 07d59ac9ac..8d6cfe1720 100644 --- a/wolfssl/wolfcrypt/port/Renesas/renesas-rx64-hw-crypt.h +++ b/wolfssl/wolfcrypt/port/Renesas/renesas-rx64-hw-crypt.h @@ -2,7 +2,7 @@ * * Contributed by Johnson Controls Tyco IP Holdings LLP. * - * Use of this Software is subject to the GPLv2 License + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -13,7 +13,7 @@ * * wolfSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License diff --git a/wolfssl/wolfcrypt/port/Renesas/renesas-tsip-crypt.h b/wolfssl/wolfcrypt/port/Renesas/renesas-tsip-crypt.h index 43030a2cb3..2a0cd1ff54 100644 --- a/wolfssl/wolfcrypt/port/Renesas/renesas-tsip-crypt.h +++ b/wolfssl/wolfcrypt/port/Renesas/renesas-tsip-crypt.h @@ -1,6 +1,6 @@ /* renesas-tsip-crypt.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -36,8 +36,16 @@ #endif +#include +#include #include +#include +#ifndef WOLFSSL_RENESAS_TSIP_CRYPTONLY #include +#endif +#ifdef WOLF_CRYPTO_CB +#include +#endif #ifdef __cplusplus extern "C" { @@ -51,7 +59,7 @@ extern "C" { typedef enum { WOLFSSL_TSIP_NOERROR = 0, WOLFSSL_TSIP_ILLEGAL_CIPHERSUITE = 0xffffffff, -}wolfssl_tsip_error_number; +} wolfssl_tsip_error_number; typedef enum { tsip_Key_SESSION = 1, @@ -84,19 +92,24 @@ enum { TSIP_TLS_VERIFY_DATA_WD_SZ = 8, TSIP_TLS_MAX_SIGDATA_SZ = 130, TSIP_TEMP_WORK_SIZE = 128, + + TSIP_MAX_ECC_BYTES = 48, }; typedef enum { - TSIP_KEY_TYPE_RSA2048 = 0, - TSIP_KEY_TYPE_RSA4096 = 1, - TSIP_KEY_TYPE_ECDSAP256 = 2, #ifdef WOLFSSL_RENESAS_TSIP_CRYPTONLY - TSIP_KEY_TYPE_RSA1024 = 3, + TSIP_KEY_TYPE_RSA1024 = 1, /* TSIP_RSA1024 */ #endif - + TSIP_KEY_TYPE_RSA2048 = 2, /* TSIP_RSA2048 */ + TSIP_KEY_TYPE_RSA3072 = 3, /* TSIP_RSA3072 */ + TSIP_KEY_TYPE_RSA4096 = 4, /* TSIP_RSA4096 */ + TSIP_KEY_TYPE_ECDSAP256 = 5, /* TSIP_ECCP256 */ + TSIP_KEY_TYPE_ECDSAP384 = 6, /* TSIP_ECCP384 */ } wolfssl_TSIP_KEY_TYPE; + struct WOLFSSL; +struct ecc_key; struct KeyShareEntry; /* MsgBag stands for message bag and acts as a buffer for holding plain text @@ -121,26 +134,33 @@ typedef struct MsgBag } MsgBag; #ifdef WOLFSSL_RENESAS_TSIP_CRYPTONLY - - typedef void* renesas_tsip_key; - - /* flags Crypt Only */ - struct tsip_keyflgs_cryt { - uint8_t aes256_key_set:1; - uint8_t aes128_key_set:1; - uint8_t rsapri2048_key_set:1; - uint8_t rsapub2048_key_set:1; - uint8_t rsapri1024_key_set:1; - uint8_t rsapub1024_key_set:1; - uint8_t message_type:1;/*message 0, hashed 1*/ - }; +/* flags Crypt Only */ +struct tsip_keyflgs_crypt { + uint32_t aes256_key_set:1; + uint32_t aes128_key_set:1; + uint32_t rsapri2048_key_set:1; + uint32_t rsapub2048_key_set:1; + uint32_t rsapri1024_key_set:1; + uint32_t rsapub1024_key_set:1; + uint32_t eccpri_key_set:1; + uint32_t eccpub_key_set:1; + uint32_t message_type:1; /*message 0, hashed 1*/ +}; #endif + /* * TsipUserCtx holds mainly keys used for TLS handshake in TSIP specific format. */ typedef struct TsipUserCtx { /* unique number for each session */ int devId; + + /* client key pair wrapped by provisioning key */ + byte* wrappedPrivateKey; + byte* wrappedPublicKey; + + int wrappedKeyType; + #ifdef WOLFSSL_RENESAS_TSIP_TLS /* 0:working as a TLS client, 1: as a server */ byte side; @@ -159,24 +179,17 @@ typedef struct TsipUserCtx { /* handle is used as work area for Tls13 handshake */ tsip_tls13_handle_t handle13; -#endif /* WOLFSSL_RENESAS_TSIP_TLS */ - /* client key pair wrapped by provisioning key */ - byte* wrappedPrivateKey; - byte* wrappedPublicKey; - int wrappedKeyType; -#ifdef WOLFSSL_RENESAS_TSIP_TLS - #if !defined(NO_RSA) +#if !defined(NO_RSA) /* RSA-2048bit private and public key-index for client authentication */ tsip_rsa2048_private_key_index_t Rsa2048PrivateKeyIdx; tsip_rsa2048_public_key_index_t Rsa2048PublicKeyIdx; - #endif /* !NO_RSA */ - - #if defined(HAVE_ECC) - /* ECC P256 private and public key-index for client authentication */ - tsip_ecc_private_key_index_t EcdsaP256PrivateKeyIdx; - tsip_ecc_public_key_index_t EcdsaP256PublicKeyIdx; - #endif /* HAVE_ECC */ +#endif /* !NO_RSA */ +#if defined(HAVE_ECC) + /* ECC private and public key-index for client authentication */ + tsip_ecc_private_key_index_t EcdsaPrivateKeyIdx; + tsip_ecc_public_key_index_t EcdsaPublicKeyIdx; +#endif /* HAVE_ECC */ /* ECDHE private key index for Tls13 handshake */ tsip_tls_p256_ecc_key_index_t EcdhPrivKey13Idx; @@ -226,7 +239,6 @@ typedef struct TsipUserCtx { /* signature data area for TLS1.3 CertificateVerify message */ byte sigDataCertVerify[TSIP_TLS_MAX_SIGDATA_SZ]; - #if (WOLFSSL_RENESAS_TSIP_VER >=109) /* out from R_SCE_TLS_ServerKeyExchangeVerify */ uint32_t encrypted_ephemeral_ecdh_public_key[ENCRYPTED_ECDHE_PUBKEY_SZ]; @@ -248,47 +260,19 @@ typedef struct TsipUserCtx { uint32_t tsip_masterSecret[TSIP_TLS_MASTERSECRET_SIZE/4]; uint8_t tsip_clientRandom[TSIP_TLS_CLIENTRANDOM_SZ]; uint8_t tsip_serverRandom[TSIP_TLS_SERVERRANDOM_SZ]; -#endif /* WOLFSSL_RENESAS_TSIP_TLS */ -/* for tsip crypt only mode */ -#ifdef WOLFSSL_RENESAS_TSIP_CRYPTONLY - - renesas_tsip_key rsa1024pri_keyIdx; - renesas_tsip_key rsa1024pub_keyIdx; - renesas_tsip_key rsa2048pri_keyIdx; - renesas_tsip_key rsa2048pub_keyIdx; - - /* sign/verify hash type : - * md5, sha1 or sha256 - */ - int sing_hash_type; - - /* flags shows status if tsip keys are installed */ - union { - uint8_t chr; - struct tsip_keyflgs_cryt bits; - } keyflgs_crypt; - -#endif - /* installed key handling */ - tsip_aes_key_index_t user_aes256_key_index; - uint8_t user_aes256_key_set:1; - tsip_aes_key_index_t user_aes128_key_index; - uint8_t user_aes128_key_set:1; /* TSIP defined cipher suite number */ uint32_t tsip_cipher; /* flags */ -#ifdef WOLFSSL_RENESAS_TSIP_TLS - #if !defined(NO_RSA) +#if !defined(NO_RSA) uint8_t ClientRsa2048PrivKey_set:1; uint8_t ClientRsa2048PubKey_set:1; - #endif - - #if defined(HAVE_ECC) - uint8_t ClientEccP256PrivKey_set:1; - uint8_t ClientEccP256PubKey_set:1; - #endif +#endif +#if defined(HAVE_ECC) + uint8_t ClientEccPrivKey_set:1; + uint8_t ClientEccPubKey_set:1; +#endif uint8_t HmacInitialized:1; uint8_t RootCAverified:1; @@ -308,6 +292,39 @@ typedef struct TsipUserCtx { uint8_t session_key_set:1; #endif /* WOLFSSL_RENESAS_TSIP_TLS */ + /* installed key handling */ + tsip_aes_key_index_t user_aes256_key_index; + uint8_t user_aes256_key_set:1; + tsip_aes_key_index_t user_aes128_key_index; + uint8_t user_aes128_key_set:1; + +/* for tsip crypt only mode */ +#ifdef WOLFSSL_RENESAS_TSIP_CRYPTONLY +#ifndef NO_RSA + tsip_rsa1024_private_key_index_t* rsa1024pri_keyIdx; + tsip_rsa1024_public_key_index_t* rsa1024pub_keyIdx; + tsip_rsa2048_private_key_index_t* rsa2048pri_keyIdx; + tsip_rsa2048_public_key_index_t* rsa2048pub_keyIdx; +#endif +#ifdef HAVE_ECC + #ifdef HAVE_ECC_SIGN + tsip_ecc_private_key_index_t eccpri_keyIdx; + #endif + tsip_ecc_public_key_index_t eccpub_keyIdx; +#endif + + /* sign/verify hash type : + * md5, sha1 or sha256 + */ + int sign_hash_type; + + /* flags shows status if tsip keys are installed */ + union { + uint32_t chr; + struct tsip_keyflgs_crypt bits; + } keyflgs_crypt; +#endif /* WOLFSSL_RENESAS_TSIP_CRYPTONLY */ + } TsipUserCtx; typedef TsipUserCtx RenesasUserCtx; @@ -372,7 +389,7 @@ WOLFSSL_API int tsip_use_PrivateKey_buffer_TLS(struct WOLFSSL* ssl, #endif #if defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) -WOLFSSL_API int tsip_use_PubicKey_buffer_crypt(TsipUserCtx *uc, +WOLFSSL_API int tsip_use_PublicKey_buffer_crypt(TsipUserCtx *uc, const char* keyBuf, int keyBufLen, int keyType); WOLFSSL_API int tsip_use_PrivateKey_buffer_crypt(TsipUserCtx *uc, const char* keyBuf, int keyBufLen, int keyType); @@ -401,22 +418,29 @@ WOLFSSL_API void tsip_inform_user_keys( /*----------------------------------------------------*/ /* internal use functions */ /*----------------------------------------------------*/ -WOLFSSL_LOCAL int tsip_SignRsaPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc); - +#ifdef HAVE_PK_CALLBACKS WOLFSSL_LOCAL int tsip_VerifyRsaPkcsCb( - WOLFSSL* ssl, + struct WOLFSSL* ssl, unsigned char* sig, unsigned int sigSz, unsigned char** out, const unsigned char* keyDer, unsigned int keySz, void* ctx); -WOLFSSL_LOCAL int tsip_SignEcdsa(wc_CryptoInfo* info, TsipUserCtx* tuc); - +#endif #ifdef WOLF_CRYPTO_CB - struct wc_CryptoInfo; +WOLFSSL_LOCAL int tsip_SignRsaPkcs(struct wc_CryptoInfo* info, + TsipUserCtx* tuc); + +WOLFSSL_LOCAL int wc_tsip_RsaVerifyPkcs(struct wc_CryptoInfo* info, + TsipUserCtx* tuc); + +WOLFSSL_LOCAL int tsip_SignEcdsa(struct wc_CryptoInfo* info, TsipUserCtx* tuc); + +WOLFSSL_LOCAL int tsip_VerifyEcdsa(struct wc_CryptoInfo* info, TsipUserCtx* tuc); + WOLFSSL_LOCAL int tsip_TlsCleanup(struct WOLFSSL* ssl); WOLFSSL_LOCAL int tsip_StoreMessage(struct WOLFSSL* ssl, const byte* data, @@ -505,23 +529,23 @@ WOLFSSL_LOCAL int wc_tsip_generateMasterSecret( WOLFSSL_LOCAL int wc_tsip_storeKeyCtx( - WOLFSSL *ssl, + struct WOLFSSL *ssl, TsipUserCtx *userCtx); WOLFSSL_LOCAL int wc_tsip_generateEncryptPreMasterSecret( - WOLFSSL* ssl, + struct WOLFSSL* ssl, byte* out, word32* outSz); WOLFSSL_LOCAL int wc_tsip_EccSharedSecret( - WOLFSSL* ssl, + struct WOLFSSL* ssl, struct ecc_key* otherKey, unsigned char* pubKeyDer, unsigned int* pubKeySz, unsigned char* out, unsigned int* outlen, int side, void* ctx); WOLFSSL_LOCAL int wc_tsip_RsaVerify( - WOLFSSL* ssl, + struct WOLFSSL* ssl, byte* sig, word32 sigSz, byte** out, @@ -530,7 +554,7 @@ WOLFSSL_LOCAL int wc_tsip_RsaVerify( void* ctx); WOLFSSL_LOCAL int wc_tsip_EccVerify( - WOLFSSL* ssl, + struct WOLFSSL* ssl, const byte* sig, word32 sigSz, const byte* hash, word32 hashSz, const byte* key, word32 keySz, @@ -571,14 +595,14 @@ WOLFSSL_LOCAL int wc_tsip_AesGcmDecrypt( void* ctx); #endif /* NO_AES */ WOLFSSL_LOCAL int wc_tsip_ShaXHmacVerify( - const WOLFSSL *ssl, + const struct WOLFSSL *ssl, const byte* message, word32 messageSz, word32 macSz, word32 content); WOLFSSL_LOCAL int wc_tsip_Sha1HmacGenerate( - const WOLFSSL *ssl, + const struct WOLFSSL *ssl, const byte* myInner, word32 innerSz, const byte* in, @@ -586,7 +610,7 @@ WOLFSSL_LOCAL int wc_tsip_Sha1HmacGenerate( byte* digest); WOLFSSL_LOCAL int wc_tsip_Sha256HmacGenerate( - const WOLFSSL *ssl, + const struct WOLFSSL *ssl, const byte* myInner, word32 innerSz, const byte* in, @@ -601,7 +625,7 @@ WOLFSSL_LOCAL int tsip_hw_lock(); WOLFSSL_LOCAL void tsip_hw_unlock( void ); -WOLFSSL_LOCAL int tsip_usable(const WOLFSSL *ssl, +WOLFSSL_LOCAL int tsip_usable(const struct WOLFSSL *ssl, uint8_t session_key_generated); WOLFSSL_LOCAL void tsip_inform_sflash_signedcacert( @@ -631,13 +655,11 @@ WOLFSSL_LOCAL int wc_tsip_generatePremasterSecret( word32 preSz); WOLFSSL_LOCAL int wc_tsip_generateSessionKey( - WOLFSSL* ssl, + struct WOLFSSL* ssl, TsipUserCtx* ctx, int devId); WOLFSSL_LOCAL int wc_tsip_MakeRsaKey(int size, void* ctx); -WOLFSSL_LOCAL int wc_tsip_RsaVerifyPkcs(wc_CryptoInfo* info, - TsipUserCtx* tuc); WOLFSSL_LOCAL int wc_tsip_GenerateRandBlock(byte* output, word32 size); diff --git a/wolfssl/wolfcrypt/port/Renesas/renesas_cmn.h b/wolfssl/wolfcrypt/port/Renesas/renesas_cmn.h index e269115572..42f1695e93 100644 --- a/wolfssl/wolfcrypt/port/Renesas/renesas_cmn.h +++ b/wolfssl/wolfcrypt/port/Renesas/renesas_cmn.h @@ -1,6 +1,6 @@ /* renesas_cmn.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -21,9 +21,14 @@ #ifndef __RENESAS_CMN_H__ #define __RENESAS_CMN_H__ + + #include + +#ifndef WOLFSSL_RENESAS_TSIP_CRYPTONLY #include + /* Common Callbacks */ WOLFSSL_LOCAL int Renesas_cmn_RsaSignCb(WOLFSSL* ssl, const unsigned char* in, unsigned int inSz, @@ -69,8 +74,6 @@ WOLFSSL_LOCAL int Renesas_cmn_SigPkCbEccVerify(const unsigned char* sig, unsigne /* Common Methods */ WOLFSSL_LOCAL void* Renesas_cmn_GetCbCtxBydevId(int devId); -int wc_CryptoCb_CryptInitRenesasCmn(WOLFSSL* ssl, void* ctx); -void wc_CryptoCb_CleanupRenesasCmn(int* id); int wc_Renesas_cmn_RootCertVerify(const byte* cert, word32 cert_len, word32 key_n_start, word32 key_n_len, word32 key_e_start, word32 key_e_len, word32 cm_row); @@ -80,4 +83,9 @@ WOLFSSL_LOCAL int Renesas_cmn_TlsFinished(WOLFSSL* ssl, const byte *side, const byte *handshake_hash, word32 hashSz, byte *hashes, void* ctx); WOLFSSL_LOCAL int Renesas_cmn_generateSessionKey(WOLFSSL* ssl, void* ctx); +#endif /* WOLFSSL_RENESAS_TSIP_CRYPTONLY */ + +int wc_CryptoCb_CryptInitRenesasCmn(struct WOLFSSL* ssl, void* ctx); +void wc_CryptoCb_CleanupRenesasCmn(int* id); + #endif /* __RENESAS_CMN_H__ */ diff --git a/wolfssl/wolfcrypt/port/Renesas/renesas_sync.h b/wolfssl/wolfcrypt/port/Renesas/renesas_sync.h index 365abf5a38..3b67449144 100644 --- a/wolfssl/wolfcrypt/port/Renesas/renesas_sync.h +++ b/wolfssl/wolfcrypt/port/Renesas/renesas_sync.h @@ -1,6 +1,6 @@ /* renesas_sync.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/Renesas/renesas_tsip_types.h b/wolfssl/wolfcrypt/port/Renesas/renesas_tsip_types.h index d340a1d3f7..2063056b82 100644 --- a/wolfssl/wolfcrypt/port/Renesas/renesas_tsip_types.h +++ b/wolfssl/wolfcrypt/port/Renesas/renesas_tsip_types.h @@ -1,7 +1,7 @@ /* renesas_tsip_types.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -25,6 +25,7 @@ #include +#include #if (!defined(NO_SHA) || !defined(NO_SHA256)) && \ !defined(NO_WOLFSSL_RENESAS_TSIP_CRYPT_HASH) @@ -33,12 +34,6 @@ typedef enum { TSIP_SHA256 = 1, } TSIP_SHA_TYPE; -typedef enum { - TSIP_RSA2048, - TSIP_RSA4096, - TSIP_ECCP256, -} TSIP_KEY_TYPE; - typedef struct { byte* msg; void* heap; @@ -54,16 +49,27 @@ typedef struct { /* RAW hash function APIs are not implemented with TSIP */ #define WOLFSSL_NO_HASH_RAW +#ifndef NO_SHA typedef wolfssl_TSIP_Hash wc_Sha; - -#if !defined(NO_SHA256) +#endif +#ifndef NO_SHA256 typedef wolfssl_TSIP_Hash wc_Sha256; #endif -#endif /* NO_SHA */ +#endif /* !NO_SHA || !NO_SHA256 */ + + +typedef enum { + TSIP_RSA1024 = 1, + TSIP_RSA2048 = 2, + TSIP_RSA3072 = 3, + TSIP_RSA4096 = 4, + TSIP_ECCP256 = 5, + TSIP_ECCP384 = 6, +} TSIP_KEY_TYPE; -#if defined(WOLFSSL_RENESAS_TSIP_TLS_AES_CRYPT) ||\ +#if defined(WOLFSSL_RENESAS_TSIP_TLS_AES_CRYPT) || \ defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) #include "r_tsip_rx_if.h" diff --git a/wolfssl/wolfcrypt/port/af_alg/afalg_hash.h b/wolfssl/wolfcrypt/port/af_alg/afalg_hash.h index bac08c0454..8defcb82f4 100644 --- a/wolfssl/wolfcrypt/port/af_alg/afalg_hash.h +++ b/wolfssl/wolfcrypt/port/af_alg/afalg_hash.h @@ -1,6 +1,6 @@ /* afalg_hash.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/af_alg/wc_afalg.h b/wolfssl/wolfcrypt/port/af_alg/wc_afalg.h index 60571f3739..af9e76827d 100644 --- a/wolfssl/wolfcrypt/port/af_alg/wc_afalg.h +++ b/wolfssl/wolfcrypt/port/af_alg/wc_afalg.h @@ -1,6 +1,6 @@ /* wc_afalg.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/aria/aria-crypt.h b/wolfssl/wolfcrypt/port/aria/aria-crypt.h index 9d49b875a1..a660bdb3a1 100644 --- a/wolfssl/wolfcrypt/port/aria/aria-crypt.h +++ b/wolfssl/wolfcrypt/port/aria/aria-crypt.h @@ -1,6 +1,6 @@ /* aria-crypt.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/aria/aria-cryptocb.h b/wolfssl/wolfcrypt/port/aria/aria-cryptocb.h index 01e18b07d8..68099b1c22 100644 --- a/wolfssl/wolfcrypt/port/aria/aria-cryptocb.h +++ b/wolfssl/wolfcrypt/port/aria/aria-cryptocb.h @@ -1,6 +1,6 @@ /* aria-cryptocb.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/arm/cryptoCell.h b/wolfssl/wolfcrypt/port/arm/cryptoCell.h index 58ba145162..eb9169f300 100644 --- a/wolfssl/wolfcrypt/port/arm/cryptoCell.h +++ b/wolfssl/wolfcrypt/port/arm/cryptoCell.h @@ -1,6 +1,6 @@ /* cryptoCell.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/atmel/atmel.h b/wolfssl/wolfcrypt/port/atmel/atmel.h index 4f92236647..c2f994083d 100644 --- a/wolfssl/wolfcrypt/port/atmel/atmel.h +++ b/wolfssl/wolfcrypt/port/atmel/atmel.h @@ -1,6 +1,6 @@ /* atmel.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/autosar/StandardTypes.h b/wolfssl/wolfcrypt/port/autosar/StandardTypes.h index a3675f2527..99c3698ab6 100644 --- a/wolfssl/wolfcrypt/port/autosar/StandardTypes.h +++ b/wolfssl/wolfcrypt/port/autosar/StandardTypes.h @@ -1,6 +1,6 @@ /* StandardTypes.h * - * Copyright (C) 2006-2019 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/caam/caam_driver.h b/wolfssl/wolfcrypt/port/caam/caam_driver.h index 3f5174ebb1..5b6d791304 100644 --- a/wolfssl/wolfcrypt/port/caam/caam_driver.h +++ b/wolfssl/wolfcrypt/port/caam/caam_driver.h @@ -1,6 +1,6 @@ /* caam_driver.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/caam/caam_error.h b/wolfssl/wolfcrypt/port/caam/caam_error.h index abde9b56b8..cb2e2f2348 100644 --- a/wolfssl/wolfcrypt/port/caam/caam_error.h +++ b/wolfssl/wolfcrypt/port/caam/caam_error.h @@ -1,6 +1,6 @@ /* caam_error.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/caam/caam_qnx.h b/wolfssl/wolfcrypt/port/caam/caam_qnx.h index 55d1fccd37..eb961c491f 100644 --- a/wolfssl/wolfcrypt/port/caam/caam_qnx.h +++ b/wolfssl/wolfcrypt/port/caam/caam_qnx.h @@ -1,6 +1,6 @@ /* caam_qnx.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/caam/wolfcaam.h b/wolfssl/wolfcrypt/port/caam/wolfcaam.h index 1123ecba4b..472e0592d7 100644 --- a/wolfssl/wolfcrypt/port/caam/wolfcaam.h +++ b/wolfssl/wolfcrypt/port/caam/wolfcaam.h @@ -1,6 +1,6 @@ /* wolfcaam.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/caam/wolfcaam_aes.h b/wolfssl/wolfcrypt/port/caam/wolfcaam_aes.h index 5ee9e7aa43..7764f38301 100644 --- a/wolfssl/wolfcrypt/port/caam/wolfcaam_aes.h +++ b/wolfssl/wolfcrypt/port/caam/wolfcaam_aes.h @@ -1,6 +1,6 @@ /* wolfcaam_aes.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/caam/wolfcaam_cmac.h b/wolfssl/wolfcrypt/port/caam/wolfcaam_cmac.h index b07fe19b10..5a2798cb0d 100644 --- a/wolfssl/wolfcrypt/port/caam/wolfcaam_cmac.h +++ b/wolfssl/wolfcrypt/port/caam/wolfcaam_cmac.h @@ -1,6 +1,6 @@ /* wolfcaam_cmac.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/caam/wolfcaam_ecdsa.h b/wolfssl/wolfcrypt/port/caam/wolfcaam_ecdsa.h index 2943d71765..50aa0087c8 100644 --- a/wolfssl/wolfcrypt/port/caam/wolfcaam_ecdsa.h +++ b/wolfssl/wolfcrypt/port/caam/wolfcaam_ecdsa.h @@ -1,6 +1,6 @@ /* wolfcaam_ecdsa.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/caam/wolfcaam_fsl_nxp.h b/wolfssl/wolfcrypt/port/caam/wolfcaam_fsl_nxp.h index c1f1367259..d85ab7e77c 100644 --- a/wolfssl/wolfcrypt/port/caam/wolfcaam_fsl_nxp.h +++ b/wolfssl/wolfcrypt/port/caam/wolfcaam_fsl_nxp.h @@ -1,6 +1,6 @@ /* wolfcaam_fsl_nxp.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/caam/wolfcaam_hash.h b/wolfssl/wolfcrypt/port/caam/wolfcaam_hash.h index 07f176eb51..caa5c27c31 100644 --- a/wolfssl/wolfcrypt/port/caam/wolfcaam_hash.h +++ b/wolfssl/wolfcrypt/port/caam/wolfcaam_hash.h @@ -1,6 +1,6 @@ /* wolfcaam_hash.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/caam/wolfcaam_qnx.h b/wolfssl/wolfcrypt/port/caam/wolfcaam_qnx.h index 6eee6b2c73..6c3440511d 100644 --- a/wolfssl/wolfcrypt/port/caam/wolfcaam_qnx.h +++ b/wolfssl/wolfcrypt/port/caam/wolfcaam_qnx.h @@ -1,6 +1,6 @@ /* wolfcaam_qnx.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/caam/wolfcaam_rsa.h b/wolfssl/wolfcrypt/port/caam/wolfcaam_rsa.h index 032c1e8c40..0653637955 100644 --- a/wolfssl/wolfcrypt/port/caam/wolfcaam_rsa.h +++ b/wolfssl/wolfcrypt/port/caam/wolfcaam_rsa.h @@ -1,6 +1,6 @@ /* wolfcaam_rsa.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/caam/wolfcaam_seco.h b/wolfssl/wolfcrypt/port/caam/wolfcaam_seco.h index d07c05492c..ea1d2914e3 100644 --- a/wolfssl/wolfcrypt/port/caam/wolfcaam_seco.h +++ b/wolfssl/wolfcrypt/port/caam/wolfcaam_seco.h @@ -1,6 +1,6 @@ /* wolfcaam_seco.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h b/wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h index 67aa5aeab8..17dc06e32e 100644 --- a/wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h +++ b/wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h @@ -1,6 +1,6 @@ /* wolfcaam_sha.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/caam/wolfcaam_x25519.h b/wolfssl/wolfcrypt/port/caam/wolfcaam_x25519.h index b10b6c9d55..3354b45e5b 100644 --- a/wolfssl/wolfcrypt/port/caam/wolfcaam_x25519.h +++ b/wolfssl/wolfcrypt/port/caam/wolfcaam_x25519.h @@ -1,6 +1,6 @@ /* wolfcaam_x25519.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/cavium/cavium_octeon_sync.h b/wolfssl/wolfcrypt/port/cavium/cavium_octeon_sync.h index 28fdd297a3..d1f861f921 100644 --- a/wolfssl/wolfcrypt/port/cavium/cavium_octeon_sync.h +++ b/wolfssl/wolfcrypt/port/cavium/cavium_octeon_sync.h @@ -1,6 +1,6 @@ /* cavium_octeon_sync.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/cypress/psoc6_crypto.h b/wolfssl/wolfcrypt/port/cypress/psoc6_crypto.h index c7df1f34f1..59fe2fdc7f 100644 --- a/wolfssl/wolfcrypt/port/cypress/psoc6_crypto.h +++ b/wolfssl/wolfcrypt/port/cypress/psoc6_crypto.h @@ -1,6 +1,6 @@ /* psoc6_crypto.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h b/wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h index d2c73d1422..20d69c98d5 100644 --- a/wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h +++ b/wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h @@ -1,6 +1,6 @@ /* wc_devcrypto.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/intel/quickassist_sync.h b/wolfssl/wolfcrypt/port/intel/quickassist_sync.h index 3e3411a1e6..2db3f3ec46 100644 --- a/wolfssl/wolfcrypt/port/intel/quickassist_sync.h +++ b/wolfssl/wolfcrypt/port/intel/quickassist_sync.h @@ -1,6 +1,6 @@ /* quickassist_sync.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/iotsafe/iotsafe.h b/wolfssl/wolfcrypt/port/iotsafe/iotsafe.h index ba4d3bd7e0..27b3b19da6 100644 --- a/wolfssl/wolfcrypt/port/iotsafe/iotsafe.h +++ b/wolfssl/wolfcrypt/port/iotsafe/iotsafe.h @@ -1,6 +1,6 @@ /* iotsafe.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/kcapi/kcapi_dh.h b/wolfssl/wolfcrypt/port/kcapi/kcapi_dh.h index 7183c149d0..bf646f2ada 100644 --- a/wolfssl/wolfcrypt/port/kcapi/kcapi_dh.h +++ b/wolfssl/wolfcrypt/port/kcapi/kcapi_dh.h @@ -1,6 +1,6 @@ /* kcapi_dh.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/kcapi/kcapi_ecc.h b/wolfssl/wolfcrypt/port/kcapi/kcapi_ecc.h index 31949a0707..a5ccb7c323 100644 --- a/wolfssl/wolfcrypt/port/kcapi/kcapi_ecc.h +++ b/wolfssl/wolfcrypt/port/kcapi/kcapi_ecc.h @@ -1,6 +1,6 @@ /* kcapi_ecc.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/kcapi/kcapi_hash.h b/wolfssl/wolfcrypt/port/kcapi/kcapi_hash.h index 1a4bbf8773..b723ca51d8 100644 --- a/wolfssl/wolfcrypt/port/kcapi/kcapi_hash.h +++ b/wolfssl/wolfcrypt/port/kcapi/kcapi_hash.h @@ -1,6 +1,6 @@ /* kcapi_hash.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/kcapi/kcapi_hmac.h b/wolfssl/wolfcrypt/port/kcapi/kcapi_hmac.h index cfd841fe21..784b47ee0a 100644 --- a/wolfssl/wolfcrypt/port/kcapi/kcapi_hmac.h +++ b/wolfssl/wolfcrypt/port/kcapi/kcapi_hmac.h @@ -1,6 +1,6 @@ /* kcapi_hmac.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/kcapi/kcapi_rsa.h b/wolfssl/wolfcrypt/port/kcapi/kcapi_rsa.h index 18a44576aa..64fcdb66b8 100644 --- a/wolfssl/wolfcrypt/port/kcapi/kcapi_rsa.h +++ b/wolfssl/wolfcrypt/port/kcapi/kcapi_rsa.h @@ -1,6 +1,6 @@ /* kcapi_rsa.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/kcapi/wc_kcapi.h b/wolfssl/wolfcrypt/port/kcapi/wc_kcapi.h index 3e5483c21d..cfbc3e0883 100644 --- a/wolfssl/wolfcrypt/port/kcapi/wc_kcapi.h +++ b/wolfssl/wolfcrypt/port/kcapi/wc_kcapi.h @@ -1,6 +1,6 @@ /* wc_kcapi.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/liboqs/liboqs.h b/wolfssl/wolfcrypt/port/liboqs/liboqs.h index b558f51846..f780164ac1 100644 --- a/wolfssl/wolfcrypt/port/liboqs/liboqs.h +++ b/wolfssl/wolfcrypt/port/liboqs/liboqs.h @@ -1,6 +1,6 @@ /* liboqs.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/maxim/maxq10xx.h b/wolfssl/wolfcrypt/port/maxim/maxq10xx.h index 0d8849f4fc..b50e029784 100644 --- a/wolfssl/wolfcrypt/port/maxim/maxq10xx.h +++ b/wolfssl/wolfcrypt/port/maxim/maxq10xx.h @@ -1,6 +1,6 @@ /* maxq10xx.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/nrf51.h b/wolfssl/wolfcrypt/port/nrf51.h index d93fd0d86c..cb379fdf36 100644 --- a/wolfssl/wolfcrypt/port/nrf51.h +++ b/wolfssl/wolfcrypt/port/nrf51.h @@ -1,6 +1,6 @@ /* nrf51.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/nxp/dcp_port.h b/wolfssl/wolfcrypt/port/nxp/dcp_port.h index 3d4c1fe93e..a09537369c 100644 --- a/wolfssl/wolfcrypt/port/nxp/dcp_port.h +++ b/wolfssl/wolfcrypt/port/nxp/dcp_port.h @@ -1,6 +1,6 @@ /* dcp_port.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/nxp/ksdk_port.h b/wolfssl/wolfcrypt/port/nxp/ksdk_port.h index 98f9ff2002..f5bfe0df10 100644 --- a/wolfssl/wolfcrypt/port/nxp/ksdk_port.h +++ b/wolfssl/wolfcrypt/port/nxp/ksdk_port.h @@ -1,6 +1,6 @@ /* ksdk_port.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/nxp/se050_port.h b/wolfssl/wolfcrypt/port/nxp/se050_port.h index ffda88fc97..cdeda673cd 100644 --- a/wolfssl/wolfcrypt/port/nxp/se050_port.h +++ b/wolfssl/wolfcrypt/port/nxp/se050_port.h @@ -1,6 +1,6 @@ /* se050_port.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h b/wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h index 46f3c04ac2..dbedb067fe 100644 --- a/wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h +++ b/wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h @@ -1,6 +1,6 @@ /* pic32mz-crypt.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/psa/psa.h b/wolfssl/wolfcrypt/port/psa/psa.h index 6bde526c04..87b5fb41a7 100644 --- a/wolfssl/wolfcrypt/port/psa/psa.h +++ b/wolfssl/wolfcrypt/port/psa/psa.h @@ -1,6 +1,6 @@ /* psa.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/riscv/riscv-64-asm.h b/wolfssl/wolfcrypt/port/riscv/riscv-64-asm.h index 25e69b3f08..e9d200f916 100644 --- a/wolfssl/wolfcrypt/port/riscv/riscv-64-asm.h +++ b/wolfssl/wolfcrypt/port/riscv/riscv-64-asm.h @@ -27,6 +27,7 @@ #define ASM_WORD(i) \ ".word " #i "\n\t" + #define REG_X0 0 #define REG_X1 1 #define REG_X2 2 @@ -127,6 +128,209 @@ #define REG_V30 30 #define REG_V31 31 + +#ifdef WOLFSSL_RISCV_BASE_BIT_MANIPULATION + +/* Reverse bytes in 64-bit register. */ +#define REV8(rd, rs) \ + ASM_WORD((0b011010111000 << 20) | (0b101 << 12) | \ + (0b0010011 << 0) | \ + (rs << 15) | (rd << 7)) + +#define RORIW(rd, rs, imm) \ + ASM_WORD((0b0110000 << 25) | (0b101 << 12) | \ + (0b0011011 << 0) | \ + (imm << 20) | (rs << 15) | (rd << 7)) + + +/* rd = rs1[0..31] | rs2[0..31]. */ +#define PACK(rd, rs1, rs2) \ + ASM_WORD((0b0000100 << 25) | (0b100 << 12) | 0b0110011 | \ + (rs2 << 20) | (rs1 << 15) | (rd << 7)) + +#endif /* WOLFSSL_RISCV_BASE_BIT_MANIPULATION */ + +/* + * Load and store + */ + +/* 64-bit width when loading. */ +#define WIDTH_64 0b111 +/* 32-bit width when loading. */ +#define WIDTH_32 0b110 + +/* Load n Vector registers with width-bit components. */ +#define VLRE_V(vd, rs1, cnt, width) \ + ASM_WORD(0b0000111 | (width << 12) | (0b00101000 << 20) | \ + (0 << 28) | ((cnt - 1) << 29) | (vd << 7) | (rs1 << 15)) +/* Load 1 Vector register with 64-bit components. */ +#define VL1RE64_V(vd, rs1) VLRE_V(vd, rs1, 1, WIDTH_64) +/* Load 1 Vector register with 32-bit components. */ +#define VL1RE32_V(vd, rs1) VLRE_V(vd, rs1, 1, WIDTH_32) +/* Load 2 Vector register with 32-bit components. */ +#define VL2RE32_V(vd, rs1) VLRE_V(vd, rs1, 2, WIDTH_32) +/* Load 4 Vector register with 32-bit components. */ +#define VL4RE32_V(vd, rs1) VLRE_V(vd, rs1, 4, WIDTH_32) +/* Load 8 Vector register with 32-bit components. */ +#define VL8RE32_V(vd, rs1) VLRE_V(vd, rs1, 8, WIDTH_32) + +/* Store n Vector register. */ +#define VSR_V(vs3, rs1, cnt) \ + ASM_WORD(0b0100111 | (0b00101000 << 20) | (0 << 28) | \ + ((cnt-1) << 29) | (vs3 << 7) | (rs1 << 15)) +/* Store 1 Vector register. */ +#define VS1R_V(vs3, rs1) VSR_V(vs3, rs1, 1) +/* Store 2 Vector register. */ +#define VS2R_V(vs3, rs1) VSR_V(vs3, rs1, 2) +/* Store 4 Vector register. */ +#define VS4R_V(vs3, rs1) VSR_V(vs3, rs1, 4) +/* Store 8 Vector register. */ +#define VS8R_V(vs3, rs1) VSR_V(vs3, rs1, 8) + +/* Move from vector register to vector registor. */ +#define VMV_V_V(vd, vs1) \ + ASM_WORD((0b1010111 << 0) | (0b000 << 12) | (0b1 << 25) | \ + (0b010111 << 26) | ((vd) << 7) | ((vs1) << 15)) +/* Splat register to each component of the vector registor. */ +#define VMV_V_X(vd, rs1) \ + ASM_WORD((0b1010111 << 0) | (0b100 << 12) | (0b1 << 25) | \ + (0b010111 << 26) | ((vd) << 7) | ((rs1) << 15)) +/* Splat immediate to each component of the vector registor. */ +#define VMV_V_I(vd, imm) \ + ASM_WORD((0b1010111 << 0) | (0b011 << 12) | (0b1 << 25) | \ + (0b010111 << 26) | ((vd) << 7) | ((imm) << 15)) +/* Move n vector registers to vector registers. */ +#define VMVR_V(vd, vs2, n) \ + ASM_WORD((0b1010111 << 0) | (0b011 << 12) | (0b1 << 25) | \ + (0b100111 << 26) | ((vd) << 7) | ((n-1) << 15) | \ + ((vs2) << 20)) + + +/* + * Logic + */ + +/* vd = vs2 << uimm */ +#define VSLL_VI(vd, vs2, uimm) \ + ASM_WORD((0b100101 << 26) | (0b1 << 25) | \ + (0b011 << 12) | (0b1010111 << 0) | \ + (vd << 7) | (uimm << 15) | (vs2 << 20)) +/* vd = vs2 >> uimm */ +#define VSRL_VI(vd, vs2, uimm) \ + ASM_WORD((0b101000 << 26) | (0b1 << 25) | \ + (0b011 << 12) | (0b1010111 << 0) | \ + (vd << 7) | (uimm << 15) | (vs2 << 20)) + + +/* + * Arithmetic + */ + +/* vd = vs2 + [i,] */ +#define VADD_VI(vd, vs2, i) \ + ASM_WORD((0b000000 << 26) | (0b1 << 25) | \ + (0b011 << 12) | (0b1010111 << 0) | \ + (vd << 7) | (i << 15) | (vs2 << 20)) +/* vd = vs1 + vs2 */ +#define VADD_VV(vd, vs1, vs2) \ + ASM_WORD((0b000000 << 26) | (0b1 << 25) | \ + (0b000 << 12) | (0b1010111 << 0) | \ + (vs2 << 20) | (vs1 << 15) | (vd << 7)) +/* vd = vs1 ^ vs2 */ +#define VXOR_VV(vd, vs1, vs2) \ + ASM_WORD((0b001011 << 26) | (0b1 << 25) | \ + (0b000 << 12) | (0b1010111 << 0) | \ + (vd << 7) | (vs1 << 15) | (vs2 << 20)) +/* vd = vs1 & vs2 */ +#define VAND_VV(vd, vs1, vs2) \ + ASM_WORD((0b001001 << 26) | (0b1 << 25) | \ + (0b000 << 12) | (0b1010111 << 0) | \ + (vd << 7) | (vs1 << 15) | (vs2 << 20)) +/* vd = vs1 | vs2 */ +#define VOR_VV(vd, vs1, vs2) \ + ASM_WORD((0b001010 << 26) | (0b1 << 25) | \ + (0b000 << 12) | (0b1010111 << 0) | \ + (vd << 7) | (vs1 << 15) | (vs2 << 20)) + + +/* + * Permute + */ + +/* x[rd] = vs2[0] */ +#define VMV_X_S(rd, vs2) \ + ASM_WORD((0b010000 << 26) | (0b1 << 25) | \ + (0b010 << 12) | (0b1010111 << 0) | \ + ((rd) << 7) | ((vs2) << 20)) + +/* vd[0] = x[rs1] */ +#define VMV_S_X(vd, rs1) \ + ASM_WORD((0b010000 << 26) | (0b1 << 25) | \ + (0b110 << 12) | (0b1010111 << 0) | \ + ((vd) << 7) | ((rs1) << 15)) + +/* vd[shift..max] = vs2[0..max-shift] + * Sliding up doesn't change bottom part of destination. + */ +#define VSLIDEUP_VI(vd, vs2, shift) \ + ASM_WORD((0b001110 << 26) | (0b1 << 25) | \ + (0b011 << 12) | (0b1010111 << 0) | \ + ((vd) << 7) | ((shift) << 15) | ((vs2) << 20)) + +/* vd[0..max-shift] = vs2[shift..max] + * Sliding down change top part of destination. + */ +#define VSLIDEDOWN_VI(vd, vs2, shift) \ + ASM_WORD((0b001111 << 26) | (0b1 << 25) | \ + (0b011 << 12) | (0b1010111 << 0) | \ + ((vd) << 7) | ((shift) << 15) | ((vs2) << 20)) + +/* vd[i] = vs1[vs2[i]] */ +#define VRGATHER_VV(vd, vs1, vs2) \ + ASM_WORD((0b001100 << 26) | (0b1 << 25) | \ + (0b000 << 12) | (0b1010111 << 0) | \ + ((vd) << 7) | ((vs1) << 15) | ((vs2) << 20)) + +#define VID_V(vd) \ + ASM_WORD((0b010100 << 26) | (0b1 << 25) | (0b00000 << 20) | \ + (0b10001 << 15) | (0b010 << 12) | \ + (0b1010111 << 0) | ((vd) << 7)) + + +/* + * Setting options. + */ + +/* Set the options of vector instructions. */ +#define VSETIVLI(rd, n, vma, vta, vsew, vlmul) \ + ASM_WORD((0b11 << 30) | (0b111 << 12) | (0b1010111 << 0) | \ + (rd << 7) | (n << 15) | (vma << 27) | \ + (vta << 26) | (vsew << 23) | (vlmul << 20)) + + +#if defined(WOLFSSL_RISCV_VECTOR_BASE_BIT_MANIPULATION) || \ + defined(WOLFSSL_RISCV_VECTOR_CRYPTO_ASM) + +/* + * Vector Bit Manipulation + */ + +/* Reverse order of bytes in words of vector regsiter. */ +#define VREV8(vd, vs2) \ + ASM_WORD((0b010010 << 26) | (0b1 << 25) | (0b01001<< 15) | \ + (0b010 << 12) | (0b1010111 << 0) | \ + (vs2 << 20) | (vd << 7)) + +/* Reverse order of bytes in words of vector regsiter. */ +#define VROR_VI(vd, imm, vs2) \ + ASM_WORD((0b01010 << 27) | (0b1 << 25) | (0b011 << 12) | \ + (0b1010111 << 0) | ((imm >> 5) << 26) | \ + (vs2 << 20) | ((imm & 0x1f) << 15) | (vd << 7)) + + +#endif /* WOLFSSL_RISCV_VECTOR_BASE_BIT_MANIPULATION || + * WOLFSSL_RISCV_VECTOR_CRYPTO_ASM */ + #endif /* WOLFSSL_RISCV_ASM */ #endif /* WOLF_CRYPT_RISCV_64_ASM_H */ diff --git a/wolfssl/wolfcrypt/port/silabs/silabs_aes.h b/wolfssl/wolfcrypt/port/silabs/silabs_aes.h index a6d39dbbd8..b82b54d24a 100644 --- a/wolfssl/wolfcrypt/port/silabs/silabs_aes.h +++ b/wolfssl/wolfcrypt/port/silabs/silabs_aes.h @@ -1,6 +1,6 @@ /* silabs_aes.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/silabs/silabs_ecc.h b/wolfssl/wolfcrypt/port/silabs/silabs_ecc.h index 43cd0f0979..e8d94ae084 100644 --- a/wolfssl/wolfcrypt/port/silabs/silabs_ecc.h +++ b/wolfssl/wolfcrypt/port/silabs/silabs_ecc.h @@ -1,6 +1,6 @@ /* silabs_ecc.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/silabs/silabs_hash.h b/wolfssl/wolfcrypt/port/silabs/silabs_hash.h index de502a9ba4..e4e7b7d9aa 100644 --- a/wolfssl/wolfcrypt/port/silabs/silabs_hash.h +++ b/wolfssl/wolfcrypt/port/silabs/silabs_hash.h @@ -1,6 +1,6 @@ /* silabs_hash.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/silabs/silabs_random.h b/wolfssl/wolfcrypt/port/silabs/silabs_random.h index 280ef44d5d..c804417e56 100644 --- a/wolfssl/wolfcrypt/port/silabs/silabs_random.h +++ b/wolfssl/wolfcrypt/port/silabs/silabs_random.h @@ -1,6 +1,6 @@ /* silabs_random.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/st/stm32.h b/wolfssl/wolfcrypt/port/st/stm32.h index a7fc25de13..7e9faff672 100644 --- a/wolfssl/wolfcrypt/port/st/stm32.h +++ b/wolfssl/wolfcrypt/port/st/stm32.h @@ -1,6 +1,6 @@ /* stm32.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -71,26 +71,6 @@ #define STM32_HASH_REG_SIZE 4 #define STM32_HASH_FIFO_SIZE 16 /* FIFO is 16 deep 32-bits wide */ -#if (defined(WOLFSSL_STM32U5) || defined(WOLFSSL_STM32H5) || \ - defined(WOLFSSL_STM32H7)) && !defined(NO_STM32_HASH_FIFO_WORKAROUND) - /* workaround for hash FIFO to write one extra to finalize */ - /* RM: Message Data Feeding: Data are entered into the HASH - * one 32-bit word at a time, by writing them into the HASH_DIN register. - * The current contents of the HASH_DIN register are transferred to the - * 16 words input FIFO each time the register is written with new data. - * Hence HASH_DIN and the FIFO form a seventeen 32-bit words length FIFO. */ - #undef STM32_HASH_BUFFER_SIZE - #define STM32_HASH_BUFFER_SIZE 17 - - #undef STM32_HASH_FIFO_WORKAROUND - #define STM32_HASH_FIFO_WORKAROUND -#endif - -#ifndef STM32_HASH_BUFFER_SIZE -#define STM32_HASH_BUFFER_SIZE STM32_HASH_FIFO_SIZE -#endif - - /* STM32 Hash Context */ typedef struct { /* Context switching registers */ @@ -100,13 +80,11 @@ typedef struct { uint32_t HASH_CSR[HASH_CR_SIZE]; /* Hash state / buffers */ - word32 buffer[STM32_HASH_BUFFER_SIZE]; /* partial word buffer */ + word32 buffer[STM32_HASH_FIFO_SIZE+1]; /* partial word buffer */ word32 buffLen; /* partial word remain */ word32 loLen; /* total update bytes (only lsb 6-bits is used for nbr valid bytes in last word) */ -#ifdef STM32_HASH_FIFO_WORKAROUND - int fifoBytes; /* number of currently filled FIFO bytes */ -#endif + word32 fifoBytes; /* number of currently filled FIFO bytes */ } STM32_HASH_Context; diff --git a/wolfssl/wolfcrypt/port/st/stsafe.h b/wolfssl/wolfcrypt/port/st/stsafe.h index d8e11d3516..c5ba072b97 100644 --- a/wolfssl/wolfcrypt/port/st/stsafe.h +++ b/wolfssl/wolfcrypt/port/st/stsafe.h @@ -1,6 +1,6 @@ /* stsafe.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/ti/ti-ccm.h b/wolfssl/wolfcrypt/port/ti/ti-ccm.h index c23790602c..05d1e4e8d4 100644 --- a/wolfssl/wolfcrypt/port/ti/ti-ccm.h +++ b/wolfssl/wolfcrypt/port/ti/ti-ccm.h @@ -1,6 +1,6 @@ /* port/ti/ti_ccm.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/ti/ti-hash.h b/wolfssl/wolfcrypt/port/ti/ti-hash.h index 1395e769d9..65a1ff684e 100644 --- a/wolfssl/wolfcrypt/port/ti/ti-hash.h +++ b/wolfssl/wolfcrypt/port/ti/ti-hash.h @@ -1,6 +1,6 @@ /* port/ti/ti-hash.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/xilinx/xil-sha3.h b/wolfssl/wolfcrypt/port/xilinx/xil-sha3.h index a2d4928ae6..f6c06cd0cc 100644 --- a/wolfssl/wolfcrypt/port/xilinx/xil-sha3.h +++ b/wolfssl/wolfcrypt/port/xilinx/xil-sha3.h @@ -1,6 +1,6 @@ /* xil-sha3.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/xilinx/xil-versal-glue.h b/wolfssl/wolfcrypt/port/xilinx/xil-versal-glue.h index 41203c2b42..718d665f75 100644 --- a/wolfssl/wolfcrypt/port/xilinx/xil-versal-glue.h +++ b/wolfssl/wolfcrypt/port/xilinx/xil-versal-glue.h @@ -1,6 +1,6 @@ /* xil-versal-glue.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/port/xilinx/xil-versal-trng.h b/wolfssl/wolfcrypt/port/xilinx/xil-versal-trng.h index 2015315708..26a9e17d2e 100644 --- a/wolfssl/wolfcrypt/port/xilinx/xil-versal-trng.h +++ b/wolfssl/wolfcrypt/port/xilinx/xil-versal-trng.h @@ -1,6 +1,6 @@ /* xil-versal-trng.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/pwdbased.h b/wolfssl/wolfcrypt/pwdbased.h index bcf09399f6..9535b0ac7e 100644 --- a/wolfssl/wolfcrypt/pwdbased.h +++ b/wolfssl/wolfcrypt/pwdbased.h @@ -1,6 +1,6 @@ /* pwdbased.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/random.h b/wolfssl/wolfcrypt/random.h index 9dd6163289..cc4c797974 100644 --- a/wolfssl/wolfcrypt/random.h +++ b/wolfssl/wolfcrypt/random.h @@ -1,6 +1,6 @@ /* random.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/rc2.h b/wolfssl/wolfcrypt/rc2.h index 2d1950e75b..22b2ad147f 100644 --- a/wolfssl/wolfcrypt/rc2.h +++ b/wolfssl/wolfcrypt/rc2.h @@ -1,6 +1,6 @@ /* rc2.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/ripemd.h b/wolfssl/wolfcrypt/ripemd.h index 3e1d5b41a1..d1a0e6fcde 100644 --- a/wolfssl/wolfcrypt/ripemd.h +++ b/wolfssl/wolfcrypt/ripemd.h @@ -1,6 +1,6 @@ /* ripemd.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/rsa.h b/wolfssl/wolfcrypt/rsa.h index f73974dea7..c944a4cbfa 100644 --- a/wolfssl/wolfcrypt/rsa.h +++ b/wolfssl/wolfcrypt/rsa.h @@ -1,6 +1,6 @@ /* rsa.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/sakke.h b/wolfssl/wolfcrypt/sakke.h index 173c33bb98..68b24c3c63 100644 --- a/wolfssl/wolfcrypt/sakke.h +++ b/wolfssl/wolfcrypt/sakke.h @@ -1,6 +1,6 @@ /* sakke.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/selftest.h b/wolfssl/wolfcrypt/selftest.h index a0c7c0eaea..198013be57 100644 --- a/wolfssl/wolfcrypt/selftest.h +++ b/wolfssl/wolfcrypt/selftest.h @@ -1,6 +1,6 @@ /* selftest.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 3fa0ba5627..25b961479b 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -415,36 +415,31 @@ * --------------------------------------------------------------------------- */ #ifdef WOLFSSL_DUAL_ALG_CERTS + #ifdef NO_RSA + #error "Need RSA or else dual alg cert example will not work." + #endif -#ifndef WOLFSSL_ASN_TEMPLATE - #error "Dual alg cert support requires the ASN.1 template feature." -#endif - -#ifdef NO_RSA - #error "Need RSA or else dual alg cert example will not work." -#endif - -#ifndef HAVE_ECC - #error "Need ECDSA or else dual alg cert example will not work." -#endif + #ifndef HAVE_ECC + #error "Need ECDSA or else dual alg cert example will not work." + #endif -#undef WOLFSSL_CERT_GEN -#define WOLFSSL_CERT_GEN + #undef WOLFSSL_CERT_GEN + #define WOLFSSL_CERT_GEN -#undef WOLFSSL_CUSTOM_OID -#define WOLFSSL_CUSTOM_OID + #undef WOLFSSL_CUSTOM_OID + #define WOLFSSL_CUSTOM_OID -#undef HAVE_OID_ENCODING -#define HAVE_OID_ENCODING + #undef HAVE_OID_ENCODING + #define HAVE_OID_ENCODING -#undef WOLFSSL_CERT_EXT -#define WOLFSSL_CERT_EXT + #undef WOLFSSL_CERT_EXT + #define WOLFSSL_CERT_EXT -#undef OPENSSL_EXTRA -#define OPENSSL_EXTRA + #undef OPENSSL_EXTRA + #define OPENSSL_EXTRA -#undef HAVE_OID_DECODING -#define HAVE_OID_DECODING + #undef HAVE_OID_DECODING + #define HAVE_OID_DECODING #endif /* WOLFSSL_DUAL_ALG_CERTS */ @@ -1648,6 +1643,7 @@ extern void uITRON4_free(void *p) ; #define WOLFSSL_STATIC_PSK /* Server side support to be added at a later date. */ #define NO_WOLFSSL_SERVER + /* Need WOLFSSL_PUBLIC_ASN to use ProcessPeerCert callback. */ #define WOLFSSL_PUBLIC_ASN @@ -2889,6 +2885,158 @@ extern void uITRON4_free(void *p) ; #define WOLFSSL_ASN_TEMPLATE #endif +#if defined(WOLFSSL_DUAL_ALG_CERTS) && !defined(WOLFSSL_ASN_TEMPLATE) + #error "Dual alg cert support requires the ASN.1 template feature." +#endif + +#if defined(OPENSSL_ALL) || defined(WOLFSSL_QT) + #undef WOLFSSL_ASN_ALL + #define WOLFSSL_ASN_ALL +#endif + +/* Enable all parsing features for ASN */ +#ifdef WOLFSSL_ASN_ALL + /* Alternate Names */ + #undef WOLFSSL_ALT_NAMES + #define WOLFSSL_ALT_NAMES + + /* Alternate Name: human readable form of IP address*/ + #undef WOLFSSL_IP_ALT_NAME + #define WOLFSSL_IP_ALT_NAME + + /* Alternate name: human readable form of registered ID */ + #undef WOLFSSL_RID_ALT_NAME + #define WOLFSSL_RID_ALT_NAME + + /* CA Issuer URI */ + #undef WOLFSSL_ASN_CA_ISSUER + #define WOLFSSL_ASN_CA_ISSUER + + /* FPKI (Federal PKI) extensions */ + #undef WOLFSSL_FPKI + #define WOLFSSL_FPKI + + /* Certificate policies */ + #undef WOLFSSL_SEP + #define WOLFSSL_SEP + + /* Support for full AuthorityKeyIdentifier extension. + * Only supports copying full AKID from an existing certificate */ + #undef WOLFSSL_AKID_NAME + #define WOLFSSL_AKID_NAME + + /* Extended ASN.1 parsing support (typically used with cert gen) */ + #undef WOLFSSL_CERT_EXT + #define WOLFSSL_CERT_EXT + + /* Support for SubjectDirectoryAttributes extension */ + #undef WOLFSSL_SUBJ_DIR_ATTR + #define WOLFSSL_SUBJ_DIR_ATTR + + /* Support for SubjectInfoAccess extension */ + #undef WOLFSSL_SUBJ_INFO_ACC + #define WOLFSSL_SUBJ_INFO_ACC + + #undef WOLFSSL_CERT_NAME_ALL + #define WOLFSSL_CERT_NAME_ALL + + /* Store pointers to issuer name components (lengths and encodings) */ + #undef WOLFSSL_HAVE_ISSUER_NAMES + #define WOLFSSL_HAVE_ISSUER_NAMES + + /* Additional ASN.1 encoded name fields. See CTC_MAX_ATTRIB for max limit */ + #undef WOLFSSL_MULTI_ATTRIB + #define WOLFSSL_MULTI_ATTRIB + + /* Parsing of indefinite length encoded ASN.1 + * Optionally used by PKCS7/PKCS12 */ + #undef ASN_BER_TO_DER + #define ASN_BER_TO_DER + + /* Enable custom OID support for subject and request extensions */ + #undef WOLFSSL_CUSTOM_OID + #define WOLFSSL_CUSTOM_OID + + /* Support for full OID (not just sum) encoding */ + #undef HAVE_OID_ENCODING + #define HAVE_OID_ENCODING + + /* Support for full OID (not just sum) decoding */ + #undef HAVE_OID_DECODING + #define HAVE_OID_DECODING + + /* S/MIME - Secure Multipurpose Internet Mail Extension (used with PKCS7) */ + #undef HAVE_SMIME + #define HAVE_SMIME + + /* Enable compatibility layer function for getting time string */ + #undef WOLFSSL_ASN_TIME_STRING + #define WOLFSSL_ASN_TIME_STRING + + /* Support for parsing key usage */ + #undef WOLFSSL_ASN_PARSE_KEYUSAGE + #define WOLFSSL_ASN_PARSE_KEYUSAGE + + /* Support for parsing OCSP status */ + #undef WOLFSSL_OCSP_PARSE_STATUS + #define WOLFSSL_OCSP_PARSE_STATUS + + /* Extended Key Usage */ + #undef WOLFSSL_EKU_OID + #define WOLFSSL_EKU_OID +#endif + +#if defined(OPENSSL_ALL) || defined(WOLFSSL_MYSQL_COMPATIBLE) || \ + defined(OPENSSL_EXTRA) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) + #undef WOLFSSL_ASN_TIME_STRING + #define WOLFSSL_ASN_TIME_STRING +#endif + +#if (defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_EXT)) || \ + (defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA)) + #undef WOLFSSL_ASN_PARSE_KEYUSAGE + #define WOLFSSL_ASN_PARSE_KEYUSAGE +#endif + +#if defined(HAVE_OCSP) && !defined(WOLFCRYPT_ONLY) && \ + (defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || \ + defined(WOLFSSL_HAPROXY) || defined(HAVE_LIGHTY) || \ + defined(WOLFSSL_APACHE_HTTPD)) + #undef WOLFSSL_OCSP_PARSE_STATUS + #define WOLFSSL_OCSP_PARSE_STATUS +#endif + +#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) || \ + defined(WOLFSSL_CERT_GEN) + #undef WOLFSSL_MULTI_ATTRIB + #define WOLFSSL_MULTI_ATTRIB +#endif + +#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) + #undef WOLFSSL_EKU_OID + #define WOLFSSL_EKU_OID +#endif + +/* Disable time checking if no timer */ +#if defined(NO_ASN_TIME) + #define NO_ASN_TIME_CHECK +#endif + +/* ASN Unknown Extension Callback support */ +#if defined(WOLFSSL_CUSTOM_OID) && defined(HAVE_OID_DECODING) && \ + defined(WOLFSSL_ASN_TEMPLATE) + #undef WC_ASN_UNKNOWN_EXT_CB + #define WC_ASN_UNKNOWN_EXT_CB +#else + /* if user supplied build option and not using ASN template, raise error */ + #if defined(WC_ASN_UNKNOWN_EXT_CB) && !defined(WOLFSSL_ASN_TEMPLATE) + #error ASN unknown extension callback is only supported \ + with ASN template + #endif +#endif + + +/* Linux Kernel Module */ #ifdef WOLFSSL_LINUXKM #ifdef HAVE_CONFIG_H #include @@ -3014,30 +3162,15 @@ extern void uITRON4_free(void *p) ; #define WOLFSSL_SESSION_ID_CTX #endif /* OPENSSL_EXTRA && !OPENSSL_COEXIST */ -/* --------------------------------------------------------------------------- - * Special small OpenSSL compat layer for certs - * --------------------------------------------------------------------------- - */ #ifdef OPENSSL_EXTRA_X509_SMALL - #undef WOLFSSL_EKU_OID - #define WOLFSSL_EKU_OID - - #undef WOLFSSL_MULTI_ATTRIB - #define WOLFSSL_MULTI_ATTRIB - #undef WOLFSSL_NO_OPENSSL_RAND_CB #define WOLFSSL_NO_OPENSSL_RAND_CB -#endif /* OPENSSL_EXTRA_X509_SMALL */ +#endif #ifdef HAVE_SNI #define SSL_CTRL_SET_TLSEXT_HOSTNAME 55 #endif -/* Disable time checking if no timer */ -#if defined(NO_ASN_TIME) - #define NO_ASN_TIME_CHECK -#endif - /* both CURVE and ED small math should be enabled */ #ifdef CURVED25519_SMALL #define CURVE25519_SMALL diff --git a/wolfssl/wolfcrypt/sha.h b/wolfssl/wolfcrypt/sha.h index eb599abed4..6ed5950265 100644 --- a/wolfssl/wolfcrypt/sha.h +++ b/wolfssl/wolfcrypt/sha.h @@ -1,6 +1,6 @@ /* sha.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/sha256.h b/wolfssl/wolfcrypt/sha256.h index a6c4ea46a3..aa4632cf3e 100644 --- a/wolfssl/wolfcrypt/sha256.h +++ b/wolfssl/wolfcrypt/sha256.h @@ -1,6 +1,6 @@ /* sha256.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/sha3.h b/wolfssl/wolfcrypt/sha3.h index e1ce33a1bf..0931a95584 100644 --- a/wolfssl/wolfcrypt/sha3.h +++ b/wolfssl/wolfcrypt/sha3.h @@ -1,6 +1,6 @@ /* sha3.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/sha512.h b/wolfssl/wolfcrypt/sha512.h index bf3cff6307..4b2dd2a194 100644 --- a/wolfssl/wolfcrypt/sha512.h +++ b/wolfssl/wolfcrypt/sha512.h @@ -1,6 +1,6 @@ /* sha512.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/signature.h b/wolfssl/wolfcrypt/signature.h index f712c0478a..51c07af529 100644 --- a/wolfssl/wolfcrypt/signature.h +++ b/wolfssl/wolfcrypt/signature.h @@ -1,6 +1,6 @@ /* signature.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/siphash.h b/wolfssl/wolfcrypt/siphash.h index ebb13024ca..6b75a4612f 100644 --- a/wolfssl/wolfcrypt/siphash.h +++ b/wolfssl/wolfcrypt/siphash.h @@ -1,6 +1,6 @@ /* siphash.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/sm2.h b/wolfssl/wolfcrypt/sm2.h index 87167f42e0..ae9885eef2 100644 --- a/wolfssl/wolfcrypt/sm2.h +++ b/wolfssl/wolfcrypt/sm2.h @@ -1,6 +1,6 @@ /* sm2.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/sm3.h b/wolfssl/wolfcrypt/sm3.h index 2b3fc50343..b24fcf4f3f 100644 --- a/wolfssl/wolfcrypt/sm3.h +++ b/wolfssl/wolfcrypt/sm3.h @@ -1,6 +1,6 @@ /* sm3.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/sm4.h b/wolfssl/wolfcrypt/sm4.h index f3e66cb894..84a8166b5f 100644 --- a/wolfssl/wolfcrypt/sm4.h +++ b/wolfssl/wolfcrypt/sm4.h @@ -1,6 +1,6 @@ /* sm4.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/sp.h b/wolfssl/wolfcrypt/sp.h index 88e9a069bf..3ede752c37 100644 --- a/wolfssl/wolfcrypt/sp.h +++ b/wolfssl/wolfcrypt/sp.h @@ -1,6 +1,6 @@ /* sp.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/sp_int.h b/wolfssl/wolfcrypt/sp_int.h index 75e735f62e..26978acfe0 100644 --- a/wolfssl/wolfcrypt/sp_int.h +++ b/wolfssl/wolfcrypt/sp_int.h @@ -1,6 +1,6 @@ /* sp_int.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/sphincs.h b/wolfssl/wolfcrypt/sphincs.h index 84871f538d..6dd3a8e858 100644 --- a/wolfssl/wolfcrypt/sphincs.h +++ b/wolfssl/wolfcrypt/sphincs.h @@ -1,6 +1,6 @@ /* sphincs.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/srp.h b/wolfssl/wolfcrypt/srp.h index 7832113a7b..d1307c7924 100644 --- a/wolfssl/wolfcrypt/srp.h +++ b/wolfssl/wolfcrypt/srp.h @@ -1,6 +1,6 @@ /* srp.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/tfm.h b/wolfssl/wolfcrypt/tfm.h index 915a335951..7d29b1f67e 100644 --- a/wolfssl/wolfcrypt/tfm.h +++ b/wolfssl/wolfcrypt/tfm.h @@ -1,6 +1,6 @@ /* tfm.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -779,6 +779,7 @@ int fp_sqr_comba64(fp_int *a, fp_int *b); #define MP_VAL FP_VAL /* invalid */ #define MP_MEM FP_MEM /* memory error */ #define MP_NOT_INF FP_NOT_INF /* point not at infinity */ +#define MP_RANGE FP_NOT_INF #define MP_OKAY FP_OKAY /* ok result */ #define MP_NO FP_NO /* yes/no result */ #define MP_YES FP_YES /* yes/no result */ diff --git a/wolfssl/wolfcrypt/types.h b/wolfssl/wolfcrypt/types.h index 9dd2f754ed..5292168116 100644 --- a/wolfssl/wolfcrypt/types.h +++ b/wolfssl/wolfcrypt/types.h @@ -1,6 +1,6 @@ /* types.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -831,6 +831,8 @@ typedef struct w64wrapper { #elif defined(WOLF_C89) #include #define XSPRINTF sprintf + /* snprintf not available for C89, so remap using macro */ + #define XSNPRINTF(f, len, ...) sprintf(f, __VA_ARGS__) #else #include #define XSNPRINTF snprintf @@ -873,7 +875,8 @@ typedef struct w64wrapper { #endif /* !XSNPRINTF */ #if defined(WOLFSSL_CERT_EXT) || defined(OPENSSL_EXTRA) || \ - defined(HAVE_ALPN) || defined(WOLFSSL_SNIFFER) + defined(HAVE_ALPN) || defined(WOLFSSL_SNIFFER) || \ + defined(WOLFSSL_ASN_PARSE_KEYUSAGE) /* use only Thread Safe version of strtok */ #if defined(USE_WOLF_STRTOK) #define XSTRTOK(s1,d,ptr) wc_strtok((s1),(d),(ptr)) @@ -917,6 +920,15 @@ typedef struct w64wrapper { WOLFSSL_API int wc_strncasecmp(const char *s1, const char *s2, size_t n); #endif + #if !defined(XSTRDUP) && !defined(USE_WOLF_STRDUP) + #define USE_WOLF_STRDUP + #endif + #ifdef USE_WOLF_STRDUP + WOLFSSL_LOCAL char* wc_strdup_ex(const char *src, int memType); + #define wc_strdup(src) wc_strdup_ex(src, DYNAMIC_TYPE_TMP_BUFFER) + #define XSTRDUP(src) wc_strdup(src) + #endif + #if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM) #ifndef XGETENV #ifdef NO_GETENV @@ -1061,6 +1073,7 @@ typedef struct w64wrapper { DYNAMIC_TYPE_SM4_BUFFER = 99, DYNAMIC_TYPE_DEBUG_TAG = 100, DYNAMIC_TYPE_LMS = 101, + DYNAMIC_TYPE_BIO = 102, DYNAMIC_TYPE_SNIFFER_SERVER = 1000, DYNAMIC_TYPE_SNIFFER_SESSION = 1001, DYNAMIC_TYPE_SNIFFER_PB = 1002, diff --git a/wolfssl/wolfcrypt/visibility.h b/wolfssl/wolfcrypt/visibility.h index 6ee10dfc7a..30a19e2d67 100644 --- a/wolfssl/wolfcrypt/visibility.h +++ b/wolfssl/wolfcrypt/visibility.h @@ -1,6 +1,6 @@ /* visibility.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/wc_encrypt.h b/wolfssl/wolfcrypt/wc_encrypt.h index b6591ffaff..e3cf9ad073 100644 --- a/wolfssl/wolfcrypt/wc_encrypt.h +++ b/wolfssl/wolfcrypt/wc_encrypt.h @@ -1,6 +1,6 @@ /* wc_encrypt.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/wc_pkcs11.h b/wolfssl/wolfcrypt/wc_pkcs11.h index 85717c2404..8cdd87e613 100644 --- a/wolfssl/wolfcrypt/wc_pkcs11.h +++ b/wolfssl/wolfcrypt/wc_pkcs11.h @@ -1,6 +1,6 @@ /* wc_pkcs11.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index 23110b94c7..0cf0eea656 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -1,6 +1,6 @@ /* wc_port.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -147,8 +147,8 @@ #elif defined(WOLFSSL_ZEPHYR) #include #ifndef SINGLE_THREADED - #ifndef CONFIG_PTHREAD_IPC - #error "Need CONFIG_PTHREAD_IPC for threading" + #if !defined(CONFIG_PTHREAD_IPC) && !defined(CONFIG_POSIX_THREADS) + #error "Threading needs CONFIG_PTHREAD_IPC / CONFIG_POSIX_THREADS" #endif #if KERNEL_VERSION_NUMBER >= 0x30100 #include @@ -859,6 +859,25 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void); #define XSPRINTF sprintf #endif +#ifdef USE_WINDOWS_API + #ifndef SOCKET_T + #ifdef __MINGW64__ + typedef size_t SOCKET_T; + #else + typedef unsigned int SOCKET_T; + #endif + #endif + #ifndef SOCKET_INVALID + #define SOCKET_INVALID INVALID_SOCKET + #endif +#else + #ifndef SOCKET_T + typedef int SOCKET_T; + #endif + #ifndef SOCKET_INVALID + #define SOCKET_INVALID (-1) + #endif +#endif /* MIN/MAX MACRO SECTION */ /* Windows API defines its own min() macro. */ diff --git a/wolfssl/wolfcrypt/wc_xmss.h b/wolfssl/wolfcrypt/wc_xmss.h index 9d88fbf71d..21d5fe8ef2 100644 --- a/wolfssl/wolfcrypt/wc_xmss.h +++ b/wolfssl/wolfcrypt/wc_xmss.h @@ -1,6 +1,6 @@ /* wc_xmss.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/wolfevent.h b/wolfssl/wolfcrypt/wolfevent.h index 31cc7c5c4c..cb3cb58de2 100644 --- a/wolfssl/wolfcrypt/wolfevent.h +++ b/wolfssl/wolfcrypt/wolfevent.h @@ -1,6 +1,6 @@ /* wolfevent.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/wolfmath.h b/wolfssl/wolfcrypt/wolfmath.h index 4ed88b81f8..fe01ed5cd8 100644 --- a/wolfssl/wolfcrypt/wolfmath.h +++ b/wolfssl/wolfcrypt/wolfmath.h @@ -1,6 +1,6 @@ /* wolfmath.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfcrypt/xmss.h b/wolfssl/wolfcrypt/xmss.h index 37aab34d00..548700caaf 100644 --- a/wolfssl/wolfcrypt/xmss.h +++ b/wolfssl/wolfcrypt/xmss.h @@ -1,6 +1,6 @@ /* xmss.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfssl/wolfio.h b/wolfssl/wolfio.h index a4a659c4dd..5fdeac4bb5 100644 --- a/wolfssl/wolfio.h +++ b/wolfssl/wolfio.h @@ -1,6 +1,6 @@ /* io.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -201,6 +201,9 @@ #include #endif +#define SOCKET_RECEIVING 1 +#define SOCKET_SENDING 2 + #ifdef USE_WINDOWS_API /* no epipe yet */ #ifndef WSAEPIPE @@ -208,6 +211,7 @@ #endif #define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK #define SOCKET_EAGAIN WSAETIMEDOUT + #define SOCKET_ETIMEDOUT WSAETIMEDOUT #define SOCKET_ECONNRESET WSAECONNRESET #define SOCKET_EINTR WSAEINTR #define SOCKET_EPIPE WSAEPIPE @@ -227,6 +231,7 @@ /* RTCS old I/O doesn't have an EWOULDBLOCK */ #define SOCKET_EWOULDBLOCK EAGAIN #define SOCKET_EAGAIN EAGAIN + #define SOCKET_ETIMEDOUT RTCSERR_TCP_TIMED_OUT #define SOCKET_ECONNRESET RTCSERR_TCP_CONN_RESET #define SOCKET_EINTR EINTR #define SOCKET_EPIPE EPIPE @@ -235,6 +240,7 @@ #else #define SOCKET_EWOULDBLOCK NIO_EWOULDBLOCK #define SOCKET_EAGAIN NIO_EAGAIN + #define SOCKET_ETIMEDOUT NIO_ETIMEDOUT #define SOCKET_ECONNRESET NIO_ECONNRESET #define SOCKET_EINTR NIO_EINTR #define SOCKET_EPIPE NIO_EPIPE @@ -252,6 +258,7 @@ #elif defined(WOLFSSL_PICOTCP) #define SOCKET_EWOULDBLOCK PICO_ERR_EAGAIN #define SOCKET_EAGAIN PICO_ERR_EAGAIN + #define SOCKET_ETIMEDOUT PICO_ERR_ETIMEDOUT #define SOCKET_ECONNRESET PICO_ERR_ECONNRESET #define SOCKET_EINTR PICO_ERR_EINTR #define SOCKET_EPIPE PICO_ERR_EIO @@ -260,6 +267,7 @@ #elif defined(FREERTOS_TCP) #define SOCKET_EWOULDBLOCK FREERTOS_EWOULDBLOCK #define SOCKET_EAGAIN FREERTOS_EWOULDBLOCK + #define SOCKET_ETIMEDOUT (-pdFREERTOS_ERRNO_ETIMEDOUT) #define SOCKET_ECONNRESET FREERTOS_SOCKET_ERROR #define SOCKET_EINTR FREERTOS_SOCKET_ERROR #define SOCKET_EPIPE FREERTOS_SOCKET_ERROR @@ -312,6 +320,7 @@ #elif defined(WOLFSSL_LWIP_NATIVE) #define SOCKET_EWOULDBLOCK ERR_WOULDBLOCK #define SOCKET_EAGAIN ERR_WOULDBLOCK + #define SOCKET_TIMEDOUT ERR_TIMEOUT #define SOCKET_ECONNRESET ERR_RST #define SOCKET_EINTR ERR_CLSD #define SOCKET_EPIPE ERR_CLSD @@ -329,6 +338,7 @@ #else #define SOCKET_EWOULDBLOCK EWOULDBLOCK #define SOCKET_EAGAIN EAGAIN + #define SOCKET_ETIMEDOUT ETIMEDOUT #define SOCKET_ECONNRESET ECONNRESET #define SOCKET_EINTR EINTR #define SOCKET_EPIPE EPIPE @@ -394,22 +404,6 @@ #endif #endif -#ifdef USE_WINDOWS_API - #if defined(__MINGW64__) - typedef size_t SOCKET_T; - #else - typedef unsigned int SOCKET_T; - #endif - #ifndef SOCKET_INVALID - #define SOCKET_INVALID INVALID_SOCKET - #endif -#else - typedef int SOCKET_T; - #ifndef SOCKET_INVALID - #define SOCKET_INVALID (-1) - #endif -#endif - #ifndef WOLFSSL_NO_SOCK #ifndef XSOCKLENT #ifdef USE_WINDOWS_API @@ -439,6 +433,10 @@ #ifdef WOLFSSL_IPV6 typedef struct sockaddr_in6 SOCKADDR_IN6; #endif + #if defined(HAVE_SYS_UN_H) && !defined(WOLFSSL_NO_SOCKADDR_UN) + #include + typedef struct sockaddr_un SOCKADDR_UN; + #endif typedef struct hostent HOSTENT; #endif /* HAVE_SOCKADDR */ @@ -463,6 +461,32 @@ WOLFSSL_API int wolfIO_TcpBind(SOCKET_T* sockfd, word16 port); WOLFSSL_API int wolfIO_Send(SOCKET_T sd, char *buf, int sz, int wrFlags); WOLFSSL_API int wolfIO_Recv(SOCKET_T sd, char *buf, int sz, int rdFlags); +#ifdef WOLFSSL_HAVE_BIO_ADDR + +#ifdef WOLFSSL_NO_SOCK +#error WOLFSSL_HAVE_BIO_ADDR and WOLFSSL_NO_SOCK are mutually incompatible. +#endif + +union WOLFSSL_BIO_ADDR { + SOCKADDR sa; + SOCKADDR_IN sa_in; +#ifdef WOLFSSL_IPV6 + SOCKADDR_IN6 sa_in6; +#endif +#if defined(HAVE_SYS_UN_H) && !defined(WOLFSSL_NO_SOCKADDR_UN) + SOCKADDR_UN sa_un; +#endif +}; + +typedef union WOLFSSL_BIO_ADDR WOLFSSL_BIO_ADDR; + +#if defined(WOLFSSL_DTLS) && defined(OPENSSL_EXTRA) +WOLFSSL_API int wolfIO_SendTo(SOCKET_T sd, WOLFSSL_BIO_ADDR *addr, char *buf, int sz, int wrFlags); +WOLFSSL_API int wolfIO_RecvFrom(SOCKET_T sd, WOLFSSL_BIO_ADDR *addr, char *buf, int sz, int rdFlags); +#endif + +#endif /* WOLFSSL_HAVE_BIO_ADDR */ + #endif /* USE_WOLFSSL_IO || HAVE_HTTP_CLIENT */ #ifndef WOLFSSL_NO_SOCK @@ -484,6 +508,7 @@ WOLFSSL_API int wolfIO_Recv(SOCKET_T sd, char *buf, int sz, int rdFlags); FNS_CLOSE(s, &err); \ } while(0) #endif + #define StartTCP() WC_DO_NOTHING #else #ifndef CloseSocket #define CloseSocket(s) close(s) diff --git a/wrapper/Ada/ada_binding.c b/wrapper/Ada/ada_binding.c index 0becb0e7e0..a1b762846b 100644 --- a/wrapper/Ada/ada_binding.c +++ b/wrapper/Ada/ada_binding.c @@ -1,6 +1,6 @@ /* ada_binding.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wrapper/Ada/user_settings.h b/wrapper/Ada/user_settings.h index b66bb3224d..6218b2c241 100644 --- a/wrapper/Ada/user_settings.h +++ b/wrapper/Ada/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.cs b/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.cs index f1753282b8..f21932c222 100644 --- a/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.cs +++ b/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.cs @@ -1,6 +1,6 @@ /* wolfSSL-DTLS-PSK-Server.cs * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.cs b/wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.cs index 5e10a9a93b..fe9c392ae5 100644 --- a/wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.cs +++ b/wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.cs @@ -1,6 +1,6 @@ /* wolfSSL-DTLS-Server.cs * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wrapper/CSharp/wolfSSL-Example-IOCallbacks/wolfSSL-Example-IOCallbacks.cs b/wrapper/CSharp/wolfSSL-Example-IOCallbacks/wolfSSL-Example-IOCallbacks.cs index 77218fd0a1..4490371fc3 100644 --- a/wrapper/CSharp/wolfSSL-Example-IOCallbacks/wolfSSL-Example-IOCallbacks.cs +++ b/wrapper/CSharp/wolfSSL-Example-IOCallbacks/wolfSSL-Example-IOCallbacks.cs @@ -1,6 +1,6 @@ /* wolfSSL-Example-IOCallbacks.cs * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs b/wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs index 7cf4c71f4c..9e9dbe46ed 100644 --- a/wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs +++ b/wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs @@ -1,6 +1,6 @@ /* wolfSSL-TLS-Client.cs * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wrapper/CSharp/wolfSSL-TLS-PSK-Client/wolfSSL-TLS-PSK-Client.cs b/wrapper/CSharp/wolfSSL-TLS-PSK-Client/wolfSSL-TLS-PSK-Client.cs index 0f70d72d44..a6525112fb 100644 --- a/wrapper/CSharp/wolfSSL-TLS-PSK-Client/wolfSSL-TLS-PSK-Client.cs +++ b/wrapper/CSharp/wolfSSL-TLS-PSK-Client/wolfSSL-TLS-PSK-Client.cs @@ -1,6 +1,6 @@ /* wolfSSL-TLS-PSK-Client.cs * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.cs b/wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.cs index a16bb87325..650d848115 100644 --- a/wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.cs +++ b/wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.cs @@ -1,6 +1,6 @@ /* wolfSSL-TLS-PSK-Server.cs * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs b/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs index 386f9d6e3a..ff184b1e9a 100644 --- a/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs +++ b/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs @@ -1,6 +1,6 @@ /* wolfSSL-TLS-Server.cs * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wrapper/CSharp/wolfSSL-TLS-ServerThreaded/wolfSSL-TLS-ServerThreaded.cs b/wrapper/CSharp/wolfSSL-TLS-ServerThreaded/wolfSSL-TLS-ServerThreaded.cs index 6cd6982dbe..a7c3d88ee0 100644 --- a/wrapper/CSharp/wolfSSL-TLS-ServerThreaded/wolfSSL-TLS-ServerThreaded.cs +++ b/wrapper/CSharp/wolfSSL-TLS-ServerThreaded/wolfSSL-TLS-ServerThreaded.cs @@ -1,6 +1,6 @@ /* wolfSSL-TLS-ServerThreaded.cs * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wrapper/CSharp/wolfSSL_CSharp/wolfSSL.cs b/wrapper/CSharp/wolfSSL_CSharp/wolfSSL.cs index 1458d00081..91d52d01d2 100644 --- a/wrapper/CSharp/wolfSSL_CSharp/wolfSSL.cs +++ b/wrapper/CSharp/wolfSSL_CSharp/wolfSSL.cs @@ -1,6 +1,6 @@ /* wolfSSL.cs * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index ed5900aaec..905f6cf113 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -117,6 +117,8 @@ if(CONFIG_WOLFSSL) zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/tfm.c) zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_dsp.c) zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_encrypt.c) + zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_kyber.c) + zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_kyber_poly.c) zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_pkcs11.c) zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_port.c) zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wolfevent.c) diff --git a/zephyr/README.md b/zephyr/README.md index 098d51c96c..ef0334d117 100644 --- a/zephyr/README.md +++ b/zephyr/README.md @@ -102,3 +102,12 @@ west build -p auto -b qemu_x86 modules/crypto/wolfssl/zephyr/samples/wolfssl_tls west build -t run ``` +## How to setup wolfSSL support for Zephyr TLS Sockets and RNG + +wolfSSL can also be used as the underlying implementation for the default Zephyr TLS socket interface. +With this enabled, all existing applications using the Zephyr TLS sockets will now use wolfSSL inside +for all TLS operations. This will also enable wolfSSL as the default RNG implementation. To enable this +feature, use the patch file and instructions found here: + +https://github.com/wolfSSL/osp/tree/master/zephyr + diff --git a/zephyr/samples/wolfssl_tls_sock/src/tls_sock.c b/zephyr/samples/wolfssl_tls_sock/src/tls_sock.c index c25277820b..90347ceb3d 100644 --- a/zephyr/samples/wolfssl_tls_sock/src/tls_sock.c +++ b/zephyr/samples/wolfssl_tls_sock/src/tls_sock.c @@ -1,6 +1,6 @@ /* tls_sock.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c b/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c index cd7aad9016..99036f2d19 100644 --- a/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c +++ b/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c @@ -1,6 +1,6 @@ /* tls_threaded.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/zephyr/user_settings-no-malloc.h b/zephyr/user_settings-no-malloc.h index 5a5ca131c7..cd7e2fad18 100644 --- a/zephyr/user_settings-no-malloc.h +++ b/zephyr/user_settings-no-malloc.h @@ -1,7 +1,7 @@ /* user_settings-tls-generic.h * generated from configure options * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/zephyr/zephyr_init.c b/zephyr/zephyr_init.c index cd8ae98e6d..927249e528 100644 --- a/zephyr/zephyr_init.c +++ b/zephyr/zephyr_init.c @@ -1,6 +1,6 @@ /* zephyr_init.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. *