diff --git a/.codespellexcludelines b/.codespellexcludelines new file mode 100644 index 000000000..f55aca32c --- /dev/null +++ b/.codespellexcludelines @@ -0,0 +1,18 @@ +############################################################################### +# In this file, you should add the line of the file that needs to be ignored. +# The line should be exactly as it appears in the file. +############################################################################### + 0x0b, 0x45, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x65, /* .Enginee */ + 0x66, 0x6f, 0x40, 0x77, 0x6f, 0x6c, 0x66, 0x73, /* fo@wolfs */ + 0x0a, 0x8b, 0x98, 0xf3, 0xe3, 0xff, 0x4e, 0x44, /* ......ND */ +ot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG79G+dwfCMNYxd\n\ +static const byte plaintext[] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras lacus odio, pretium vel sagittis ac, facilisis quis diam. Vivamus condimentum velit sed dolor consequat interdum. Etiam eleifend ornare felis, eleifend egestas odio vulputate eu. Sed nec orci nunc. Etiam quis mi augue. Donec ullamcorper suscipit lorem, vel luctus augue cursus fermentum. Etiam a porta arcu, in convallis sem. Integer efficitur elementum diam, vel scelerisque felis posuere placerat. Donec vestibulum sit amet leo sit amet tincidunt. Etiam et vehicula turpis. Phasellus quis finibus sapien. Sed et tristique turpis. Nullam vitae sagittis tortor, et aliquet lorem. Cras a leo scelerisque, convallis lacus ut, fermentum urna. Mauris quis urna diam. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam aliquam vehicula orci id pulvinar. Proin mollis, libero sollicitudin tempor ultrices, massa augue tincidunt turpis, sit amet aliquam neque nibh nec dui. Fusce finibus massa quis rutrum suscipit cras amet"; +rsource "Kconfig.tls-generic" + /* Loop over authenticated associated data AD1..ADn */ + /* no easy answer [c'est la vie]. Just division */ + const uint8_t* hashIn, int hashSz) + XMEMCPY(hash + (curveSz - hashSz), hashIn, hashSz); + 0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x77, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x69, /* creen would be i */ +\pagenumbering{alph} + DES3_KEY_SIZE = 24, /* 3 des ede */ +/* functions added to support above needed, removed TOOM and KARATSUBA */ diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index e4199b970..51384aad5 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -6,8 +6,10 @@ body: - type: markdown attributes: value: > - Thanks for reporting an bug. If you would prefer a private method, - please email support@wolfssl.com + Thanks for reporting a bug. If you would prefer a private method, + or if this is a vulnerability report please email support@wolfssl.com + instead. This is publicly viewable and not appropriate for vulnerability + reports. - type: input id: contact attributes: diff --git a/.github/ISSUE_TEMPLATE/other.yaml b/.github/ISSUE_TEMPLATE/other.yaml index 33d2d29e7..a10a56bd9 100644 --- a/.github/ISSUE_TEMPLATE/other.yaml +++ b/.github/ISSUE_TEMPLATE/other.yaml @@ -6,7 +6,9 @@ body: attributes: value: > Thanks for reporting an issue. If you would prefer a private method, - please email support@wolfssl.com + or if this is a vulnerability report please email support@wolfssl.com + instead. This is publicly viewable and not appropriate for vulnerability + reports. - type: input id: version attributes: diff --git a/.github/workflows/ada.yml b/.github/workflows/ada.yml new file mode 100644 index 000000000..59fd34ae2 --- /dev/null +++ b/.github/workflows/ada.yml @@ -0,0 +1,33 @@ +name: WolfSSL Ada Build Tests + +on: + push: + branches: [ 'master', 'main', 'release/**' ] + pull_request: + branches: [ '*' ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@master + + - name: Install gnat + run: | + sudo apt-get update + sudo apt-get install -y gnat gprbuild + + - name: Checkout wolfssl + uses: actions/checkout@master + with: + repository: wolfssl/wolfssl + path: wolfssl + + - name: Build wolfssl Ada + working-directory: ./wolfssl/wrapper/Ada + run: | + mkdir obj + gprbuild default.gpr + gprbuild examples.gpr diff --git a/.github/workflows/async.yml b/.github/workflows/async.yml index e1699c1c5..07a2b5088 100644 --- a/.github/workflows/async.yml +++ b/.github/workflows/async.yml @@ -23,7 +23,8 @@ jobs: '--enable-ocsp CFLAGS="-DTEST_NONBLOCK_CERTS"', ] name: make check - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 6 steps: @@ -36,7 +37,7 @@ jobs: ./configure ${{ matrix.config }} make check - - name: Print errors + - name: Print errors if: ${{ failure() }} run: | if [ -f test-suite.log ] ; then diff --git a/.github/workflows/bind.yml b/.github/workflows/bind.yml new file mode 100644 index 000000000..493db2b47 --- /dev/null +++ b/.github/workflows/bind.yml @@ -0,0 +1,93 @@ +name: bind9 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 + if: github.repository_owner == 'wolfssl' + # Just to keep it the same as the testing target + runs-on: ubuntu-22.04 + # 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: tar build-dir + run: tar -zcf build-dir.tgz build-dir + + - name: Upload built lib + uses: actions/upload-artifact@v4 + with: + name: wolf-install-bind + path: build-dir.tgz + retention-days: 5 + + bind_check: + strategy: + fail-fast: false + matrix: + # List of releases to test + ref: [ 9.18.0, 9.18.28 ] + name: ${{ matrix.ref }} + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + # 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-bind + + - name: untar build-dir + run: tar -xf build-dir.tgz + + - name: Install dependencies + run: | + # Don't prompt for anything + export DEBIAN_FRONTEND=noninteractive + sudo apt-get update + # hostap dependencies + sudo apt-get install -y libuv1-dev libnghttp2-dev libcap-dev libcmocka-dev + + - name: Checkout OSP + uses: actions/checkout@v4 + with: + repository: wolfssl/osp + path: osp + + - name: Checkout bind9 + uses: actions/checkout@v4 + with: + repository: isc-projects/bind9 + path: bind + ref: v${{ matrix.ref }} + + - name: Build and test bind9 + working-directory: bind + run: | + export PKG_CONFIG_PATH=$GITHUB_WORKSPACE/build-dir/lib/pkgconfig + patch -p1 < $GITHUB_WORKSPACE/osp/bind9/${{ matrix.ref }}.patch + autoreconf -ivf + ./configure --with-wolfssl + sed -i 's/SUBDIRS = system//g' bin/tests/Makefile # remove failing tests + make -j V=1 + make -j V=1 check diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 000000000..c97ab6cb3 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,108 @@ +name: WolfSSL CMake Build Tests + +on: + push: + branches: [ 'master', 'main', 'release/**' ] + pull_request: + branches: [ '*' ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: +# pull wolfSSL + - uses: actions/checkout@master + +# install cmake + - name: Install cmake + run: | + sudo apt-get update + sudo apt-get install -y cmake + +# pull wolfssl + - name: Checkout wolfssl + uses: actions/checkout@master + with: + repository: wolfssl/wolfssl + path: wolfssl + +# build wolfssl + - name: Build wolfssl + working-directory: ./wolfssl + run: | + mkdir build + cd build + cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DWOLFSSL_INSTALL=yes -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install" \ + -DWOLFSSL_16BIT:BOOL=no -DWOLFSSL_32BIT:BOOL=no -DWOLFSSL_AES:BOOL=yes \ + -DWOLFSSL_AESCBC:BOOL=yes -DWOLFSSL_AESCCM:BOOL=yes -DWOLFSSL_AESCFB:BOOL=yes \ + -DWOLFSSL_AESCTR:BOOL=yes -DWOLFSSL_AESGCM:STRING=yes -DWOLFSSL_AESKEYWRAP:BOOL=yes \ + -DWOLFSSL_AESOFB:BOOL=yes -DWOLFSSL_AESSIV:BOOL=yes -DWOLFSSL_ALIGN_DATA:BOOL=yes \ + -DWOLFSSL_ALPN:BOOL=ON -DWOLFSSL_ALT_CERT_CHAINS:BOOL=ON -DWOLFSSL_ARC4:BOOL=yes \ + -DWOLFSSL_ARIA:BOOL=no -DWOLFSSL_ASIO:BOOL=no -DWOLFSSL_ASM:BOOL=yes -DWOLFSSL_ASN:BOOL=yes \ + -DWOLFSSL_ASYNC_THREADS:BOOL=no -DWOLFSSL_BASE64_ENCODE:BOOL=yes -DWOLFSSL_CAAM:BOOL=no \ + -DWOLFSSL_CERTEXT:BOOL=yes -DWOLFSSL_CERTGEN:BOOL=yes -DWOLFSSL_CERTGENCACHE:BOOL=no \ + -DWOLFSSL_CERTREQ:BOOL=yes -DWOLFSSL_CHACHA:STRING=yes -DWOLFSSL_CMAC:BOOL=yes \ + -DWOLFSSL_CODING:BOOL=yes -DWOLFSSL_CONFIG_H:BOOL=yes -DWOLFSSL_CRL:STRING=yes \ + -DWOLFSSL_CRYPTOCB:BOOL=yes -DWOLFSSL_CRYPTOCB_NO_SW_TEST:BOOL=no \ + -DWOLFSSL_CRYPT_TESTS:BOOL=yes -DWOLFSSL_CRYPT_TESTS_HELP:BOOL=no \ + -DWOLFSSL_CRYPT_TESTS_LIBS:BOOL=no -DWOLFSSL_CURL:BOOL=yes -DWOLFSSL_CURVE25519:STRING=yes \ + -DWOLFSSL_CURVE448:STRING=yes -DWOLFSSL_DEBUG:BOOL=yes -DWOLFSSL_DES3:BOOL=ON \ + -DWOLFSSL_DES3_TLS_SUITES:BOOL=no -DWOLFSSL_DH:STRING=yes -DWOLFSSL_DH_DEFAULT_PARAMS:BOOL=yes \ + -DWOLFSSL_DSA:BOOL=yes -DWOLFSSL_DTLS:BOOL=ON -DWOLFSSL_DTLS13:BOOL=yes \ + -DWOLFSSL_DTLS_CID:BOOL=yes -DWOLFSSL_ECC:STRING=yes \ + -DWOLFSSL_ECCCUSTCURVES:STRING=all -DWOLFSSL_ECCSHAMIR:BOOL=yes \ + -DWOLFSSL_ECH:BOOL=yes -DWOLFSSL_ED25519:BOOL=yes -DWOLFSSL_ED448:STRING=yes \ + -DWOLFSSL_ENCKEYS:BOOL=yes -DWOLFSSL_ENC_THEN_MAC:BOOL=yes -DWOLFSSL_ERROR_QUEUE:BOOL=yes \ + -DWOLFSSL_ERROR_STRINGS:BOOL=yes -DWOLFSSL_EXAMPLES:BOOL=yes -DWOLFSSL_EXPERIMENTAL:BOOL=yes \ + -DWOLFSSL_EXTENDED_MASTER:BOOL=yes -DWOLFSSL_EX_DATA:BOOL=yes -DWOLFSSL_FAST_MATH:BOOL=no \ + -DWOLFSSL_FILESYSTEM:BOOL=yes -DWOLFSSL_HARDEN:BOOL=yes -DWOLFSSL_HASH_DRBG:BOOL=yes \ + -DWOLFSSL_HKDF:BOOL=yes -DWOLFSSL_HPKE:BOOL=yes -DWOLFSSL_HRR_COOKIE:STRING=yes \ + -DWOLFSSL_INLINE:BOOL=yes -DWOLFSSL_INSTALL:BOOL=yes -DWOLFSSL_IP_ALT_NAME:BOOL=ON \ + -DWOLFSSL_KEYGEN:BOOL=yes -DWOLFSSL_KEYING_MATERIAL:BOOL=ON \ + -DWOLFSSL_MD4:BOOL=ON -DWOLFSSL_MD5:BOOL=yes -DWOLFSSL_MEMORY:BOOL=yes -DWOLFSSL_NO_STUB:BOOL=no \ + -DWOLFSSL_OAEP:BOOL=yes -DWOLFSSL_OCSP:BOOL=yes -DWOLFSSL_OCSPSTAPLING:BOOL=ON \ + -DWOLFSSL_OCSPSTAPLING_V2:BOOL=ON -DWOLFSSL_OLD_NAMES:BOOL=yes -DWOLFSSL_OLD_TLS:BOOL=yes \ + -DWOLFSSL_OPENSSLALL:BOOL=yes -DWOLFSSL_OPENSSLEXTRA:BOOL=ON -DWOLFSSL_OPTFLAGS:BOOL=yes \ + -DWOLFSSL_OQS:BOOL=no -DWOLFSSL_PKCALLBACKS:BOOL=yes -DWOLFSSL_PKCS12:BOOL=yes \ + -DWOLFSSL_PKCS7:BOOL=yes -DWOLFSSL_POLY1305:BOOL=yes -DWOLFSSL_POSTAUTH:BOOL=yes \ + -DWOLFSSL_PWDBASED:BOOL=yes -DWOLFSSL_QUIC:BOOL=yes -DWOLFSSL_REPRODUCIBLE_BUILD:BOOL=no \ + -DWOLFSSL_RNG:BOOL=yes -DWOLFSSL_RSA:BOOL=yes -DWOLFSSL_RSA_PSS:BOOL=yes \ + -DWOLFSSL_SESSION_TICKET:BOOL=ON -DWOLFSSL_SHA:BOOL=yes -DWOLFSSL_SHA224:BOOL=yes \ + -DWOLFSSL_SHA3:STRING=yes -DWOLFSSL_SHA384:BOOL=yes -DWOLFSSL_SHA512:BOOL=yes \ + -DWOLFSSL_SHAKE128:STRING=yes -DWOLFSSL_SHAKE256:STRING=yes -DWOLFSSL_SINGLE_THREADED:BOOL=no \ + -DWOLFSSL_SNI:BOOL=yes -DWOLFSSL_SP_MATH_ALL:BOOL=yes -DWOLFSSL_SRTP:BOOL=yes \ + -DWOLFSSL_STUNNEL:BOOL=yes -DWOLFSSL_SUPPORTED_CURVES:BOOL=yes -DWOLFSSL_SYS_CA_CERTS:BOOL=yes \ + -DWOLFSSL_TICKET_NONCE_MALLOC:BOOL=yes -DWOLFSSL_TLS13:BOOL=yes -DWOLFSSL_TLSV12:BOOL=yes \ + -DWOLFSSL_TLSX:BOOL=yes -DWOLFSSL_TPM:BOOL=yes -DWOLFSSL_CLU:BOOL=yes -DWOLFSSL_USER_SETTINGS:BOOL=no \ + -DWOLFSSL_USER_SETTINGS_ASM:BOOL=no -DWOLFSSL_WOLFSSH:BOOL=ON -DWOLFSSL_X86_64_BUILD_ASM:BOOL=yes \ + -DWOLFSSL_X963KDF:BOOL=yes \ + -DCMAKE_C_FLAGS="-DWOLFSSL_DTLS_CH_FRAG" \ + .. + cmake --build . + ctest -j $(nproc) + cmake --install . + + # clean up + cd .. + rm -rf build + + # Kyber Cmake broken + # -DWOLFSSL_KYBER:BOOL=yes + +# build "lean-tls" wolfssl + - name: Build wolfssl with lean-tls + working-directory: ./wolfssl + run: | + mkdir build + cd build + cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DWOLFSSL_INSTALL=yes -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install" \ + -DWOLFSSL_LEAN_TLS:BOOL=yes \ + .. + cmake --build . + cmake --install . + + # clean up + cd .. + rm -rf build diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 000000000..a0b605ae3 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,30 @@ +name: Codespell test + +on: + push: + branches: [ 'master', 'main', 'release/**' ] + pull_request: + branches: [ '*' ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +# END OF COMMON SECTION + +jobs: + codespell: + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - uses: codespell-project/actions-codespell@v2.1 + with: + check_filenames: true + check_hidden: true + # Add comma separated list of words that occur multiple times that should be ignored (sorted alphabetically, case sensitive) + ignore_words_list: adin,aNULL,brunch,carryIn,chainG,ciph,cLen,cliKs,dout,haveA,inCreated,inOut,inout,larg,LEAPYEAR,Merget,optionA,parm,parms,repid,rIn,userA,ser,siz,te,Te + # The exclude_file contains lines of code that should be ignored. This is useful for individual lines which have non-words that can safely be ignored. + exclude_file: '.codespellexcludelines' + # To skip files entirely from being processed, add it to the following list: + skip: '*.cproject,*.der,*.mtpj,*.pem,*.vcxproj,.git,*.launch,*.scfg,*.revoked' diff --git a/.github/workflows/coverity-scan-fixes.yml b/.github/workflows/coverity-scan-fixes.yml new file mode 100644 index 000000000..9a70e080b --- /dev/null +++ b/.github/workflows/coverity-scan-fixes.yml @@ -0,0 +1,53 @@ +name: Coverity Scan master branch + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * 1-5' + - cron: '0 0 * * 0' + - cron: '0 12 * * 0' + +jobs: + coverity: + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + ref: master + + - name: Configure wolfSSL with enable-all M-F + if: github.event.schedule == '0 0 * * 1-5' + run: | + ./autogen.sh + ./configure --enable-all + + - name: Configure wolfSSL with enable-all enable-smallstack Sun at 00:00 + if: github.event.schedule == '0 0 * * 0' + run: | + ./autogen.sh + ./configure --enable-all --enable-smallstack + + - name: Configure wolfSSL with bigendian Sun at 12:00 + if: github.event.schedule == '0 12 * * 0' + run: | + ./autogen.sh + ./configure --enable-all CFLAGS="-DBIG_ENDIAN_ORDER" + + - name: Check secrets + env: + token_var: ${{ secrets.COVERITY_SCAN_TOKEN }} + email_var: ${{ secrets.COVERITY_SCAN_EMAIL }} + run: | + token_len=${#token_var} + echo "$token_len" + email_len=${#email_var} + echo "$email_len" + + - uses: vapier/coverity-scan-action@v1 + with: + build_language: 'cxx' + project: "wolfSSL/wolfssl" + token: ${{ secrets.COVERITY_SCAN_TOKEN }} + email: ${{ secrets.COVERITY_SCAN_EMAIL }} + command: "make" diff --git a/.github/workflows/curl.yml b/.github/workflows/curl.yml index 156e61b38..19d3dcd49 100644 --- a/.github/workflows/curl.yml +++ b/.github/workflows/curl.yml @@ -15,7 +15,8 @@ concurrency: jobs: build_wolfssl: name: Build wolfSSL - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: @@ -38,7 +39,8 @@ jobs: test_curl: name: ${{ matrix.curl_ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 15 needs: build_wolfssl @@ -50,8 +52,7 @@ jobs: - name: Install test dependencies run: | sudo apt-get update - sudo apt-get install nghttp2 libpsl5 libpsl-dev - sudo pip install impacket + sudo apt-get install nghttp2 libpsl5 libpsl-dev python3-impacket - name: Download lib uses: actions/download-artifact@v4 @@ -72,4 +73,4 @@ jobs: - name: Test curl working-directory: curl - run: make -j test-ci + run: make -j $(nproc) test-ci diff --git a/.github/workflows/cyrus-sasl.yml b/.github/workflows/cyrus-sasl.yml index 9f2aab72c..910c87122 100644 --- a/.github/workflows/cyrus-sasl.yml +++ b/.github/workflows/cyrus-sasl.yml @@ -15,8 +15,9 @@ concurrency: jobs: build_wolfssl: name: Build wolfSSL + if: github.repository_owner == 'wolfssl' # Just to keep it the same as the testing target - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: @@ -46,7 +47,8 @@ jobs: # List of releases to test ref: [ 2.1.28 ] name: ${{ matrix.ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 needs: build_wolfssl diff --git a/.github/workflows/disabled/haproxy.yml b/.github/workflows/disabled/haproxy.yml index 43e197fd5..0a92dac0c 100644 --- a/.github/workflows/disabled/haproxy.yml +++ b/.github/workflows/disabled/haproxy.yml @@ -20,6 +20,7 @@ jobs: # List of refs to test ref: [ master ] name: ${{ matrix.ref }} + if: github.repository_owner == 'wolfssl' runs-on: ubuntu-latest steps: - name: Build wolfSSL @@ -57,4 +58,3 @@ jobs: - name: Test HaProxy working-directory: haproxy run: make reg-tests reg-tests/ssl VTEST_PROGRAM=$GITHUB_WORKSPACE/VTest/vtest - diff --git a/.github/workflows/hitch.yml b/.github/workflows/disabled/hitch.yml similarity index 96% rename from .github/workflows/hitch.yml rename to .github/workflows/disabled/hitch.yml index c11accd58..5f0b58986 100644 --- a/.github/workflows/hitch.yml +++ b/.github/workflows/disabled/hitch.yml @@ -15,6 +15,7 @@ concurrency: jobs: build_wolfssl: name: Build wolfSSL + if: github.repository_owner == '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. @@ -47,6 +48,7 @@ jobs: ignore-tests: >- test13-r82.sh test15-proxy-v2-npn.sh test39-client-cert-proxy.sh name: ${{ matrix.ref }} + if: github.repository_owner == 'wolfssl' runs-on: ubuntu-latest # This should be a safe limit for the tests to run. timeout-minutes: 4 @@ -105,4 +107,4 @@ jobs: working-directory: ./hitch run: | export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/build-dir/lib:$LD_LIBRARY_PATH - make check \ No newline at end of file + make check diff --git a/.github/workflows/disabled/hostap.yml b/.github/workflows/disabled/hostap.yml index aad37cad3..46c413195 100644 --- a/.github/workflows/disabled/hostap.yml +++ b/.github/workflows/disabled/hostap.yml @@ -22,6 +22,7 @@ jobs: - build_id: hostap-build2 wolf_extra_config: --enable-brainpool --enable-wpas-dpp name: Build wolfSSL + if: github.repository_owner == 'wolfssl' # Just to keep it the same as the testing target runs-on: ubuntu-20.04 # This should be a safe limit for the tests to run. @@ -99,6 +100,7 @@ jobs: build_id: hostap-build2 } name: hwsim test + if: github.repository_owner == 'wolfssl' # For openssl 1.1 runs-on: ubuntu-20.04 # This should be a safe limit for the tests to run. @@ -181,7 +183,7 @@ jobs: - name: Checkout hostap uses: actions/checkout@v4 with: - repository: julek-wolfssl/hostap-mirror + repository: julek-wolfssl/hostap-mirror path: hostap ref: ${{ matrix.config.hostap_ref }} # necessary for cherry pick step @@ -210,7 +212,7 @@ jobs: done - if: ${{ matrix.hostapd }} - name: Setup hostapd config file + name: Setup hostapd config file run: | cp wolfssl/.github/workflows/hostap-files/configs/${{ matrix.config.hostap_ref }}/hostapd.config \ hostap/hostapd/.config @@ -220,7 +222,7 @@ jobs: EOF - if: ${{ matrix.wpa_supplicant }} - name: Setup wpa_supplicant config file + name: Setup wpa_supplicant config file run: | cp wolfssl/.github/workflows/hostap-files/configs/${{ matrix.config.hostap_ref }}/wpa_supplicant.config \ hostap/wpa_supplicant/.config diff --git a/.github/workflows/disabled/msys2.yml b/.github/workflows/disabled/msys2.yml new file mode 100644 index 000000000..0641a3104 --- /dev/null +++ b/.github/workflows/disabled/msys2.yml @@ -0,0 +1,41 @@ +name: MSYS2 Build Test + +# 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: + msys2: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + strategy: + fail-fast: false + matrix: + include: + - { sys: ucrt64, compiler: mingw-w64-ucrt-x86_64-gcc } + - { sys: mingw64, compiler: mingw-w64-x86_64-gcc } + - { sys: msys, compiler: gcc } + steps: + - uses: actions/checkout@v3 + - uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.sys }} + update: true + install: git ${{matrix.compiler}} autotools base-devel autoconf netcat + - name: configure wolfSSL + run: ./autogen.sh && ./configure CFLAGS="-DUSE_CERT_BUFFERS_2048 -DUSE_CERT_BUFFERS_256 -DNO_WRITE_TEMP_FILES" + - name: build wolfSSL + run: make check + - name: Display log + if: always() + run: cat test-suite.log diff --git a/.github/workflows/docker-Espressif.yml b/.github/workflows/docker-Espressif.yml index c2b6ff0ba..dda8e9c34 100644 --- a/.github/workflows/docker-Espressif.yml +++ b/.github/workflows/docker-Espressif.yml @@ -14,7 +14,8 @@ concurrency: jobs: espressif_latest: name: latest Docker container - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 12 container: @@ -22,22 +23,24 @@ jobs: steps: - uses: actions/checkout@v4 - name: Initialize Espressif IDE and build examples - run: . /opt/esp/idf/export.sh; IDE/Espressif/ESP-IDF/compileAllExamples.sh + run: cd /opt/esp/idf && . ./export.sh && cd $GITHUB_WORKSPACE; IDE/Espressif/ESP-IDF/compileAllExamples.sh espressif_v4_4: name: v4.4 Docker container - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 container: image: espressif/idf:release-v4.4 steps: - uses: actions/checkout@v4 - name: Initialize Espressif IDE and build examples - run: . /opt/esp/idf/export.sh; IDE/Espressif/ESP-IDF/compileAllExamples.sh + run: cd /opt/esp/idf && . ./export.sh && cd $GITHUB_WORKSPACE; IDE/Espressif/ESP-IDF/compileAllExamples.sh espressif_v5_0: name: v5.0 Docker container - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 container: image: espressif/idf:release-v5.0 steps: - uses: actions/checkout@v4 - name: Initialize Espressif IDE and build examples - run: . /opt/esp/idf/export.sh; IDE/Espressif/ESP-IDF/compileAllExamples.sh + run: cd /opt/esp/idf && . ./export.sh && cd $GITHUB_WORKSPACE; IDE/Espressif/ESP-IDF/compileAllExamples.sh diff --git a/.github/workflows/docker-OpenWrt.yml b/.github/workflows/docker-OpenWrt.yml index 283e3b92e..05890ffae 100644 --- a/.github/workflows/docker-OpenWrt.yml +++ b/.github/workflows/docker-OpenWrt.yml @@ -17,7 +17,8 @@ concurrency: jobs: build_library: name: Compile libwolfssl.so - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 container: @@ -40,7 +41,8 @@ jobs: retention-days: 5 compile_container: name: Compile container - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 2 needs: build_library diff --git a/.github/workflows/gencertbuf.yml b/.github/workflows/gencertbuf.yml new file mode 100644 index 000000000..97cd1a531 --- /dev/null +++ b/.github/workflows/gencertbuf.yml @@ -0,0 +1,41 @@ +name: Test gencertbuf script + +# 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: + gencertbuf: + name: gencertbuf + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-latest + # This should be a safe limit for the tests to run. + timeout-minutes: 6 + steps: + - uses: actions/checkout@v4 + name: Checkout wolfSSL + + - name: Test generate wolfssl/certs_test.h + run: ./gencertbuf.pl + + - name: Test wolfSSL + run: | + ./autogen.sh + ./configure --enable-all --enable-experimental --enable-dilithium --enable-kyber + make + ./wolfcrypt/test/testwolfcrypt + + - name: Print errors + if: ${{ failure() }} + run: | + if [ -f test-suite.log ] ; then + cat test-suite.log + fi diff --git a/.github/workflows/grpc.yml b/.github/workflows/grpc.yml index 4e145cc6c..4259b2a93 100644 --- a/.github/workflows/grpc.yml +++ b/.github/workflows/grpc.yml @@ -15,8 +15,9 @@ concurrency: jobs: build_wolfssl: name: Build wolfSSL + if: github.repository_owner == 'wolfssl' # Just to keep it the same as the testing target - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 10 steps: @@ -50,7 +51,8 @@ jobs: test_core_security_ssl_credentials_test test_cpp_end2end_ssl_credentials_test h2_ssl_cert_test h2_ssl_session_reuse_test name: ${{ matrix.ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 30 needs: build_wolfssl @@ -69,6 +71,11 @@ jobs: with: name: wolf-install-grpc + - name: Setup cmake version + uses: jwlawson/actions-setup-cmake@v2 + with: + cmake-version: '3.25.x' + - name: untar build-dir run: tar -xf build-dir.tgz @@ -92,7 +99,7 @@ jobs: git submodule update --init mkdir cmake/build cd cmake/build - cmake -DgRPC_BUILD_TESTS=ON -DgRPC_SSL_PROVIDER=wolfssl \ + cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.1 -DgRPC_BUILD_TESTS=ON -DgRPC_SSL_PROVIDER=wolfssl \ -DWOLFSSL_INSTALL_DIR=$GITHUB_WORKSPACE/build-dir ../.. make -j $(nproc) ${{ matrix.tests }} diff --git a/.github/workflows/haproxy.yml b/.github/workflows/haproxy.yml new file mode 100644 index 000000000..fa1ac5bef --- /dev/null +++ b/.github/workflows/haproxy.yml @@ -0,0 +1,91 @@ +name: haproxy Test + +# 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 + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + # 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-haproxy + install: true + + - name: tar build-dir + run: tar -zcf build-dir.tgz build-dir + + - name: Upload built lib + uses: actions/upload-artifact@v4 + with: + name: wolf-install-haproxy + path: build-dir.tgz + retention-days: 5 + + test_haproxy: + name: ${{ matrix.haproxy_ref }} + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + # This should be a safe limit for the tests to run. + timeout-minutes: 15 + needs: build_wolfssl + strategy: + fail-fast: false + matrix: + haproxy_ref: [ 'v3.1.0' ] + steps: + - name: Install test dependencies + run: | + sudo apt-get update + sudo apt-get install libpcre2-dev + + - name: Download lib + uses: actions/download-artifact@v4 + with: + name: wolf-install-haproxy + + - name: untar build-dir + run: tar -xf build-dir.tgz + + # check cache for haproxy if not there then download it + - name: Check haproxy cache + uses: actions/cache@v4 + id: cache-haproxy + with: + path: build-dir/haproxy-${{matrix.haproxy_ref}} + key: haproxy-${{matrix.haproxy_ref}} + + - name: Download haproxy if needed + if: steps.cache-haproxy.outputs.cache-hit != 'true' + uses: actions/checkout@v3 + with: + repository: haproxy/haproxy + ref: ${{matrix.haproxy_ref}} + path: build-dir/haproxy-${{matrix.haproxy_ref}} + + - name: Build haproxy + working-directory: build-dir/haproxy-${{matrix.haproxy_ref}} + run: make clean && make TARGET=linux-glibc USE_OPENSSL_WOLFSSL=1 SSL_LIB=$GITHUB_WORKSPACE/build-dir/lib SSL_INC=$GITHUB_WORKSPACE/build-dir/include ADDLIB=-Wl,-rpath,$GITHUB_WORKSPACE/build-dir/lib CFLAGS="-fsanitize=address" LDFLAGS="-fsanitize=address" + + - name: Build haproxy vtest + working-directory: build-dir/haproxy-${{matrix.haproxy_ref}} + run: ./scripts/build-vtest.sh + + - name: Test haproxy + working-directory: build-dir/haproxy-${{matrix.haproxy_ref}} + run: VTEST_PROGRAM=$GITHUB_WORKSPACE/build-dir/vtest/vtest make reg-tests -- --debug reg-tests/ssl/* diff --git a/.github/workflows/hostap-vm.yml b/.github/workflows/hostap-vm.yml index b24680dfe..43f114af3 100644 --- a/.github/workflows/hostap-vm.yml +++ b/.github/workflows/hostap-vm.yml @@ -13,7 +13,7 @@ concurrency: # END OF COMMON SECTION env: - LINUX_REF: v6.6 + LINUX_REF: v6.12 jobs: build_wolfssl: @@ -24,10 +24,11 @@ jobs: wolf_extra_config: --disable-tls13 - build_id: hostap-vm-build2 wolf_extra_config: >- - --enable-wpas-dpp --enable-brainpool --with-eccminsz=192 + --enable-wpas-dpp --enable-brainpool --with-eccminsz=192 --enable-tlsv10 --enable-oldtls name: Build wolfSSL - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 10 steps: @@ -62,33 +63,55 @@ jobs: path: build-dir.tgz retention-days: 5 - build_uml_linux: - name: Build UML (UserMode Linux) - runs-on: ubuntu-latest + checkout_hostap: + name: Checkout hostap repo + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 10 + steps: + - name: Checking if we have hostap in cache + uses: actions/cache@v4 + id: cache + with: + path: hostap + key: hostap-repo + lookup-only: true + + - name: Checkout hostap + run: git clone git://w1.fi/hostap.git hostap + + build_uml_linux: + name: Build UML (UserMode Linux) + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + # This should be a safe limit for the tests to run. + timeout-minutes: 10 + needs: checkout_hostap steps: - name: Checking if we have kernel in cache uses: actions/cache@v4 id: cache with: path: linux/linux - key: ${{ env.LINUX_REF }} + key: hostap-linux-${{ env.LINUX_REF }} lookup-only: true - - name: Checkout hostap + - name: Checking if we have hostap in cache if: steps.cache.outputs.cache-hit != 'true' - uses: actions/checkout@v4 + uses: actions/cache/restore@v4 with: - repository: julek-wolfssl/hostap-mirror path: hostap + key: hostap-repo + fail-on-cache-miss: true - name: Checkout linux if: steps.cache.outputs.cache-hit != 'true' uses: actions/checkout@v4 with: - repository: torvalds/linux + repository: torvalds/linux path: linux + ref: ${{ env.LINUX_REF }} - name: Compile linux if: steps.cache.outputs.cache-hit != 'true' @@ -139,18 +162,18 @@ jobs: build_id: hostap-vm-build2 } name: hwsim test - # For openssl 1.1 - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 45 - needs: [build_wolfssl, build_uml_linux] + needs: [build_wolfssl, build_uml_linux, checkout_hostap] steps: - name: Checking if we have kernel in cache uses: actions/cache/restore@v4 id: cache with: path: linux/linux - key: ${{ env.LINUX_REF }} + key: hostap-linux-${{ env.LINUX_REF }} fail-on-cache-miss: true - name: show file structure @@ -193,15 +216,19 @@ jobs: # hostap dependencies sudo apt-get install -y libpcap0.8 libpcap-dev curl libcurl4-openssl-dev \ libnl-3-dev binutils-dev libssl-dev libiberty-dev libnl-genl-3-dev \ - libnl-route-3-dev libdbus-1-dev bridge-utils tshark - sudo pip3 install pycryptodome + libnl-route-3-dev libdbus-1-dev bridge-utils tshark python3-pycryptodome + sudo pip install pycryptodome - - name: Checkout hostap - uses: actions/checkout@v4 + - name: Checking if we have hostap in cache + uses: actions/cache/restore@v4 with: - repository: julek-wolfssl/hostap-mirror path: hostap - ref: ${{ matrix.config.hostap_ref }} + key: hostap-repo + fail-on-cache-miss: true + + - name: Checkout correct ref + working-directory: hostap + run: git checkout ${{ matrix.config.hostap_ref }} - name: Update certs working-directory: hostap/tests/hwsim/auth_serv @@ -233,7 +260,7 @@ jobs: fi - if: ${{ matrix.hostapd }} - name: Setup hostapd config file + name: Setup hostapd config file run: | cp wolfssl/.github/workflows/hostap-files/configs/${{ matrix.config.hostap_ref }}/hostapd.config \ hostap/hostapd/.config @@ -243,7 +270,7 @@ jobs: EOF - if: ${{ matrix.wpa_supplicant }} - name: Setup wpa_supplicant config file + name: Setup wpa_supplicant config file run: | cp wolfssl/.github/workflows/hostap-files/configs/${{ matrix.config.hostap_ref }}/wpa_supplicant.config \ hostap/wpa_supplicant/.config @@ -286,6 +313,7 @@ jobs: KERNELDIR=$GITHUB_WORKSPACE/linux KVMARGS="-cpu host" EOF + git config --global --add safe.directory $GITHUB_WORKSPACE/hostap # Run tests in increments of 200 to not stall out the parallel-vm script while mapfile -t -n 200 ary && ((${#ary[@]})); do TESTS=$(printf '%s\n' "${ary[@]}" | tr '\n' ' ') diff --git a/.github/workflows/intelasm-c-fallback.yml b/.github/workflows/intelasm-c-fallback.yml new file mode 100644 index 000000000..49d3639bc --- /dev/null +++ b/.github/workflows/intelasm-c-fallback.yml @@ -0,0 +1,52 @@ +name: Dynamic C Fallback 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: + make_check: + strategy: + matrix: + config: [ + # Add new configs here + '--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy CPPFLAGS="-DNO_WOLFSSL_CIPHER_SUITE_TEST -DWC_C_DYNAMIC_FALLBACK -DDEBUG_VECTOR_REGISTER_ACCESS -DDEBUG_VECTOR_REGISTER_ACCESS_FUZZING -DWC_DEBUG_CIPHER_LIFECYCLE"' + ] + name: make check + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + # This should be a safe limit for the tests to run. + timeout-minutes: 6 + steps: + - uses: actions/checkout@v4 + name: Checkout wolfSSL + + - name: Test wolfSSL with WC_C_DYNAMIC_FALLBACK and DEBUG_VECTOR_REGISTER_ACCESS_FUZZING + run: | + ./autogen.sh + randseed=$(head -c 4 /dev/urandom | od -t u4 --address-radix=n) + randseed="${randseed#"${randseed%%[![:space:]]*}"}" + echo "fuzzing seed=${randseed}" + ./configure ${{ matrix.config }} CFLAGS="-DWC_DEBUG_VECTOR_REGISTERS_FUZZING_SEED=$randseed -fsanitize=leak -g -fno-omit-frame-pointer" + make -j 4 + make check + + - name: Print errors + if: ${{ failure() }} + run: | + for file in scripts/*.log + do + if [ -f "$file" ]; then + echo "${file}:" + cat "$file" + echo "========================================================================" + fi + done diff --git a/.github/workflows/ipmitool.yml b/.github/workflows/ipmitool.yml index ef7d072e7..c23b407c5 100644 --- a/.github/workflows/ipmitool.yml +++ b/.github/workflows/ipmitool.yml @@ -17,7 +17,8 @@ jobs: build_wolfssl: name: Build wolfSSL # Just to keep it the same as the testing target - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 + if: github.repository_owner == 'wolfssl' # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: @@ -46,9 +47,12 @@ jobs: matrix: git_ref: [ c3939dac2c060651361fc71516806f9ab8c38901 ] name: ${{ matrix.git_ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 needs: build_wolfssl steps: + - name: Install dependencies + run: export DEBIAN_FRONTEND=noninteractive && sudo apt-get update && sudo apt-get install -y libreadline8 - name: Download lib uses: actions/download-artifact@v4 with: @@ -79,4 +83,3 @@ jobs: run: | ldd src/ipmitool | grep wolfssl ldd src/ipmievd | grep wolfssl - \ No newline at end of file diff --git a/.github/workflows/jwt-cpp.yml b/.github/workflows/jwt-cpp.yml index 13569574f..2dcb209b5 100644 --- a/.github/workflows/jwt-cpp.yml +++ b/.github/workflows/jwt-cpp.yml @@ -16,7 +16,8 @@ jobs: build_wolfssl: name: Build wolfSSL # Just to keep it the same as the testing target - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: @@ -40,12 +41,17 @@ jobs: retention-days: 5 build_pam-ipmi: + if: github.repository_owner == 'wolfssl' strategy: fail-fast: false matrix: - ref: [ 0.6.0 ] - name: ${{ matrix.ref }} - runs-on: ubuntu-latest + config: + - ref: 0.7.0 + runner: ubuntu-22.04 + - ref: 0.6.0 + runner: ubuntu-22.04 + name: ${{ matrix.config.ref }} + runs-on: ${{ matrix.config.runner }} needs: build_wolfssl steps: - name: Install dependencies @@ -60,6 +66,11 @@ jobs: with: name: wolf-install-jwt-cpp + - name: Setup cmake version + uses: jwlawson/actions-setup-cmake@v2 + with: + cmake-version: '3.25.x' + - name: untar build-dir run: tar -xf build-dir.tgz @@ -74,14 +85,14 @@ jobs: with: repository: Thalhammer/jwt-cpp path: jwt-cpp - ref: v${{ matrix.ref }} + ref: v${{ matrix.config.ref }} - name: Build pam-ipmi working-directory: jwt-cpp run: | - patch -p1 < ../osp/jwt-cpp/${{ matrix.ref }}.patch + patch -p1 < ../osp/jwt-cpp/${{ matrix.config.ref }}.patch PKG_CONFIG_PATH=$GITHUB_WORKSPACE/build-dir/lib/pkgconfig \ - cmake -B build -DJWT_SSL_LIBRARY:STRING=wolfSSL -DJWT_BUILD_TESTS=ON . + cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -B build -DJWT_SSL_LIBRARY:STRING=wolfSSL -DJWT_BUILD_TESTS=ON . make -j -C build ldd ./build/tests/jwt-cpp-test | grep wolfssl diff --git a/.github/workflows/krb5.yml b/.github/workflows/krb5.yml index ce96479ce..37c64e299 100644 --- a/.github/workflows/krb5.yml +++ b/.github/workflows/krb5.yml @@ -16,7 +16,8 @@ jobs: build_wolfssl: name: Build wolfSSL # Just to keep it the same as the testing target - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 5 steps: @@ -48,7 +49,8 @@ jobs: # List of releases to test ref: [ 1.21.1 ] name: ${{ matrix.ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 8 needs: build_wolfssl @@ -90,7 +92,7 @@ jobs: # Using rpath because LD_LIBRARY_PATH is overwritten during testing export WOLFSSL_CFLAGS="-I$GITHUB_WORKSPACE/build-dir/include -I$GITHUB_WORKSPACE/build-dir/include/wolfssl -Wl,-rpath=$GITHUB_WORKSPACE/build-dir/lib" export WOLFSSL_LIBS="-lwolfssl -L$GITHUB_WORKSPACE/build-dir/lib -Wl,-rpath=$GITHUB_WORKSPACE/build-dir/lib" - ./configure --with-crypto-impl=wolfssl --with-tls-impl=wolfssl --disable-pkinit \ + ./configure --with-crypto-impl=wolfssl --with-tls-impl=wolfssl --disable-pkinit --with-spake-openssl \ CFLAGS='-fsanitize=address' LDFLAGS='-fsanitize=address' CFLAGS='-fsanitize=address' LDFLAGS='-fsanitize=address' make -j diff --git a/.github/workflows/libspdm.yml b/.github/workflows/libspdm.yml new file mode 100644 index 000000000..49cbf8c52 --- /dev/null +++ b/.github/workflows/libspdm.yml @@ -0,0 +1,91 @@ +name: libspdm 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 + if: github.repository_owner == 'wolfssl' + # Just to keep it the same as the testing target + runs-on: ubuntu-22.04 + # 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 --enable-static CFLAGS='-DRSA_MIN_SIZE=512' + install: true + + - name: tar build-dir + run: tar -zcf build-dir.tgz build-dir + + - name: Upload built lib + uses: actions/upload-artifact@v4 + with: + name: wolf-install-libspdm + path: build-dir.tgz + retention-days: 5 + + libspdm_check: + strategy: + fail-fast: false + matrix: + # List of releases to test + ref: [ 3.3.0 ] + name: ${{ matrix.ref }} + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + # 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-libspdm + + - name: untar build-dir + run: tar -xf build-dir.tgz + + - name: Checkout OSP + uses: actions/checkout@v4 + with: + repository: wolfssl/osp + path: osp + + - name: Checkout libspdm + uses: actions/checkout@v4 + with: + repository: DMTF/libspdm + path: libspdm + ref: ${{ matrix.ref }} + + - name: Build and test libspdm + working-directory: libspdm + run: | + patch -p1 < ../osp/libspdm/${{ matrix.ref }}/libspdm-${{ matrix.ref }}.patch + git submodule update --init --recursive + # Silence cmake version warnings + find -name CMakeLists.txt -exec sed -i 's/cmake_minimum_required.*/cmake_minimum_required(VERSION 3.10)/g' {} \; + mkdir build + cd build + cmake -DARCH=x64 -DTOOLCHAIN=GCC -DTARGET=Debug -DCRYPTO=wolfssl -DENABLE_BINARY_BUILD=1 \ + -DCOMPILED_LIBWOLFSSL_PATH=$GITHUB_WORKSPACE/build-dir/lib/libwolfssl.a \ + -DWOLFSSL_INCDIR=$GITHUB_WORKSPACE/build-dir/include .. + make -j + cd ../unit_test/sample_key + ../../build/bin/test_crypt + ../../build/bin/test_spdm_secured_message + ../../build/bin/test_spdm_crypt diff --git a/.github/workflows/libssh2.yml b/.github/workflows/libssh2.yml index 0f5f24100..e956c7a6f 100644 --- a/.github/workflows/libssh2.yml +++ b/.github/workflows/libssh2.yml @@ -16,7 +16,8 @@ jobs: build_wolfssl: name: Build wolfSSL # Just to keep it the same as the testing target - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-24.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: @@ -43,9 +44,10 @@ jobs: fail-fast: false matrix: # List of releases to test - ref: [ 1.11.0 ] + ref: [ 1.11.1 ] name: ${{ matrix.ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-24.04 # This should be a safe limit for the tests to run. timeout-minutes: 8 needs: build_wolfssl @@ -68,5 +70,8 @@ jobs: check: true - name: Confirm libssh2 built with wolfSSL - working-directory: ./libssh2 - run: ldd src/.libs/libssh2.so | grep wolfssl + run: ldd libssh2/src/.libs/libssh2.so | grep wolfssl + + - name: print server logs + if: ${{ failure() }} + run: tail -n +1 libssh2/tests/*.log diff --git a/.github/workflows/libvncserver.yml b/.github/workflows/libvncserver.yml index cdef79dde..87a772bf9 100644 --- a/.github/workflows/libvncserver.yml +++ b/.github/workflows/libvncserver.yml @@ -16,7 +16,8 @@ jobs: build_wolfssl: name: Build wolfSSL # Just to keep it the same as the testing target - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: @@ -43,9 +44,10 @@ jobs: strategy: fail-fast: false matrix: - ref: [ 0.9.13 ] + ref: [ 0.9.13, 0.9.14 ] name: ${{ matrix.ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 needs: build_wolfssl steps: - name: Download lib @@ -53,6 +55,11 @@ jobs: with: name: wolf-install-libvncserver + - name: Setup cmake version + uses: jwlawson/actions-setup-cmake@v2 + with: + cmake-version: '3.25.x' + - name: untar build-dir run: tar -xf build-dir.tgz @@ -74,7 +81,7 @@ jobs: run: | patch -p1 < ../osp/libvncserver/${{ matrix.ref }}.patch PKG_CONFIG_PATH=$GITHUB_WORKSPACE/build-dir/lib/pkgconfig \ - cmake -B build -DWITH_GNUTLS=OFF -DWITH_OPENSSL=OFF -DWITH_GCRYPT=OFF -DWITH_WOLFSSL=ON . + cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -B build -DWITH_GNUTLS=OFF -DWITH_OPENSSL=OFF -DWITH_GCRYPT=OFF -DWITH_WOLFSSL=ON . make -j -C build VERBOSE=1 ldd build/libvncclient.so | grep wolfssl ldd build/libvncserver.so | grep wolfssl diff --git a/.github/workflows/mbedtls.sh b/.github/workflows/mbedtls.sh new file mode 100644 index 000000000..d199fd2e3 --- /dev/null +++ b/.github/workflows/mbedtls.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +set -e +set -x + +# Basic TLS test +./mbedtls/build/programs/ssl/ssl_server2 > /tmp/server.log 2>&1 & +SERVER_PID=$! +sleep 0.1 +./mbedtls/build/programs/ssl/ssl_client2 # Confirm working with mbed +env -C wolfssl ./examples/client/client -p 4433 -g \ + -A ../mbedtls/framework/data_files/test-ca-sha256.crt \ + -c ../mbedtls/framework/data_files/cli-rsa-sha256.crt \ + -k ../mbedtls/framework/data_files/cli-rsa-sha256.key.pem +kill $SERVER_PID +sleep 0.1 +env -C wolfssl ./examples/server/server -p 4433 -i -g \ + -A ../mbedtls/framework/data_files/test-ca-sha256.crt \ + -c ../mbedtls/framework/data_files/server2-sha256.crt \ + -k ../mbedtls/framework/data_files/server2.key.pem > /tmp/server.log 2>&1 & +SERVER_PID=$! +sleep 0.1 +./mbedtls/build/programs/ssl/ssl_client2 +env -C wolfssl ./examples/client/client -p 4433 -g \ + -A ../mbedtls/framework/data_files/test-ca-sha256.crt \ + -c ../mbedtls/framework/data_files/cli-rsa-sha256.crt \ + -k ../mbedtls/framework/data_files/cli-rsa-sha256.key.pem +kill $SERVER_PID +sleep 0.1 + +# Basic DTLS test +./mbedtls/build/programs/ssl/ssl_server2 dtls=1 > /tmp/server.log 2>&1 & +SERVER_PID=$! +sleep 0.1 +./mbedtls/build/programs/ssl/ssl_client2 dtls=1 # Confirm working with mbed +env -C wolfssl ./examples/client/client -p 4433 -g -u \ + -A ../mbedtls/framework/data_files/test-ca-sha256.crt \ + -c ../mbedtls/framework/data_files/cli-rsa-sha256.crt \ + -k ../mbedtls/framework/data_files/cli-rsa-sha256.key.pem +kill $SERVER_PID +sleep 0.1 +env -C wolfssl ./examples/server/server -p 4433 -i -g -u \ + -A ../mbedtls/framework/data_files/test-ca-sha256.crt \ + -c ../mbedtls/framework/data_files/server2-sha256.crt \ + -k ../mbedtls/framework/data_files/server2.key.pem > /tmp/server.log 2>&1 & +SERVER_PID=$! +sleep 0.1 +env -C wolfssl ./examples/client/client -p 4433 -g -u \ + -A ../mbedtls/framework/data_files/test-ca-sha256.crt \ + -c ../mbedtls/framework/data_files/cli-rsa-sha256.crt \ + -k ../mbedtls/framework/data_files/cli-rsa-sha256.key.pem +./mbedtls/build/programs/ssl/ssl_client2 dtls=1 +kill $SERVER_PID +sleep 0.1 + +# DTLS 1.2 CID test +./mbedtls/build/programs/ssl/ssl_server2 dtls=1 cid=1 cid_val=121212 > /tmp/server.log 2>&1 & +SERVER_PID=$! +sleep 0.1 +./mbedtls/build/programs/ssl/ssl_client2 dtls=1 cid=1 cid_val=232323 # Confirm working with mbed +env -C wolfssl ./examples/client/client -p 4433 -g -u --cid 232323 \ + -A ../mbedtls/framework/data_files/test-ca-sha256.crt \ + -c ../mbedtls/framework/data_files/cli-rsa-sha256.crt \ + -k ../mbedtls/framework/data_files/cli-rsa-sha256.key.pem +kill $SERVER_PID +sleep 0.1 +env -C wolfssl ./examples/server/server -p 4433 -i -g -u --cid 121212 \ + -A ../mbedtls/framework/data_files/test-ca-sha256.crt \ + -c ../mbedtls/framework/data_files/server2-sha256.crt \ + -k ../mbedtls/framework/data_files/server2.key.pem > /tmp/server.log 2>&1 & +SERVER_PID=$! +sleep 0.1 +./mbedtls/build/programs/ssl/ssl_client2 dtls=1 cid_val=232323 +env -C wolfssl ./examples/client/client -p 4433 -g -u --cid 232323 \ + -A ../mbedtls/framework/data_files/test-ca-sha256.crt \ + -c ../mbedtls/framework/data_files/cli-rsa-sha256.crt \ + -k ../mbedtls/framework/data_files/cli-rsa-sha256.key.pem +kill $SERVER_PID +sleep 0.1 diff --git a/.github/workflows/mbedtls.yml b/.github/workflows/mbedtls.yml new file mode 100644 index 000000000..f9830fcf6 --- /dev/null +++ b/.github/workflows/mbedtls.yml @@ -0,0 +1,86 @@ +name: mbedtls interop 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 + +env: + MBED_REF: v3.6.2 + +jobs: + build_mbedtls: + name: Build mbedtls + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-latest + # This should be a safe limit for the tests to run. + timeout-minutes: 10 + steps: + - name: Checking if we have mbed in cache + uses: actions/cache@v4 + id: cache + with: + path: mbedtls + key: mbedtls-${{ env.MBED_REF }} + lookup-only: true + + - name: Checkout mbedtls + if: steps.cache.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + repository: Mbed-TLS/mbedtls + ref: ${{ env.MBED_REF }} + path: mbedtls + + - name: Compile mbedtls + if: steps.cache.outputs.cache-hit != 'true' + working-directory: mbedtls + run: | + git submodule update --init + mkdir build + cd build + cmake .. + make -j + # convert key to pem format + openssl pkey -in framework/data_files/cli-rsa-sha256.key.der -text > framework/data_files/cli-rsa-sha256.key.pem + openssl pkey -in framework/data_files/server2.key.der -text > framework/data_files/server2.key.pem + + mbedtls_test: + name: Test interop with mbedtls + runs-on: ubuntu-latest + needs: build_mbedtls + timeout-minutes: 10 + if: github.repository_owner == 'wolfssl' + steps: + - name: Disable IPv6 (IMPORTANT, OTHERWISE DTLS MBEDTLS CLIENT WON'T CONNECT) + run: echo 1 | sudo tee /proc/sys/net/ipv6/conf/lo/disable_ipv6 + + - name: Checking if we have mbed in cache + uses: actions/cache/restore@v4 + id: cache + with: + path: mbedtls + key: mbedtls-${{ env.MBED_REF }} + fail-on-cache-miss: true + + - name: Build wolfSSL + uses: wolfSSL/actions-build-autotools-project@v1 + with: + path: wolfssl + configure: --enable-dtls --enable-dtlscid + install: false + check: false + + - name: Test interop + run: bash wolfssl/.github/workflows/mbedtls.sh + + - name: print server logs + if: ${{ failure() }} + run: cat /tmp/server.log diff --git a/.github/workflows/memcached.yml b/.github/workflows/memcached.yml index e1cbb3784..bdd0c0593 100644 --- a/.github/workflows/memcached.yml +++ b/.github/workflows/memcached.yml @@ -16,7 +16,8 @@ jobs: build_wolfssl: name: Build wolfSSL # Just to keep it the same as the testing target - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 steps: - name: Build wolfSSL uses: wolfSSL/actions-build-autotools-project@v1 @@ -46,7 +47,8 @@ jobs: include: - ref: 1.6.22 name: ${{ matrix.ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 needs: build_wolfssl steps: - name: Download lib diff --git a/.github/workflows/mosquitto.yml b/.github/workflows/mosquitto.yml index aa9693858..97afaf282 100644 --- a/.github/workflows/mosquitto.yml +++ b/.github/workflows/mosquitto.yml @@ -1,98 +1,105 @@ -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: tar build-dir - run: tar -zcf build-dir.tgz build-dir - - - name: Upload built lib - uses: actions/upload-artifact@v4 - with: - name: wolf-install-mosquitto - path: build-dir.tgz - 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 - - - name: untar build-dir - run: tar -xf build-dir.tgz - - - 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 +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 + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + # 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: tar build-dir + run: tar -zcf build-dir.tgz build-dir + + - name: Upload built lib + uses: actions/upload-artifact@v4 + with: + name: wolf-install-mosquitto + path: build-dir.tgz + retention-days: 5 + + mosquitto_check: + strategy: + fail-fast: false + matrix: + ref: [ 2.0.18 ] + name: ${{ matrix.ref }} + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + # 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 + + - name: untar build-dir + run: tar -xf build-dir.tgz + + - 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 python3-psutil + + - name: Checkout mosquitto + uses: actions/checkout@v4 + with: + repository: eclipse/mosquitto + ref: v${{ matrix.ref }} + path: mosquitto + + - name: Update certs + run: | + cd $GITHUB_WORKSPACE/mosquitto/test/ssl + ./gen.sh + cat all-ca.crt >> server.crt + + - 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/multi-arch.yml b/.github/workflows/multi-arch.yml index f296464f9..729048a6c 100644 --- a/.github/workflows/multi-arch.yml +++ b/.github/workflows/multi-arch.yml @@ -36,7 +36,8 @@ jobs: CFLAGS: -marm -DWOLFSSL_SP_ARM_ARCH=6 ARCH: armel EXTRA_OPTS: --enable-sp-asm - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 10 steps: @@ -51,7 +52,7 @@ jobs: CFLAGS: ${{ matrix.CFLAGS }} QEMU_LD_PREFIX: /usr/${{ matrix.HOST }} run: ./autogen.sh && ./configure --host=${{ matrix.HOST }} --enable-all --disable-examples ${{ matrix.EXTRA_OPTS }} && make - - name: Print errors + - name: Print errors if: ${{ failure() }} run: | if [ -f config.log ] ; then diff --git a/.github/workflows/multi-compiler.yml b/.github/workflows/multi-compiler.yml index 08e1e4e0d..591c5daed 100644 --- a/.github/workflows/multi-compiler.yml +++ b/.github/workflows/multi-compiler.yml @@ -21,35 +21,35 @@ jobs: include: - CC: gcc-9 CXX: g++-9 - OS: ubuntu-latest + OS: ubuntu-24.04 - CC: gcc-10 CXX: g++-10 - OS: ubuntu-latest + OS: ubuntu-24.04 - CC: gcc-11 CXX: g++-11 - OS: ubuntu-latest + OS: ubuntu-24.04 - CC: gcc-12 CXX: g++-12 - OS: ubuntu-latest - - CC: clang-10 - CXX: clang++-10 - OS: ubuntu-20.04 + OS: ubuntu-24.04 - CC: clang-11 CXX: clang++-11 - OS: ubuntu-20.04 + OS: ubuntu-22.04 - CC: clang-12 CXX: clang++-12 - OS: ubuntu-20.04 + OS: ubuntu-22.04 - CC: clang-13 CXX: clang++-13 - OS: ubuntu-latest + OS: ubuntu-22.04 - CC: clang-14 CXX: clang++-14 - OS: ubuntu-latest + OS: ubuntu-24.04 + if: github.repository_owner == 'wolfssl' runs-on: ${{ matrix.OS }} # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: + - name: Install dependencies + run: export DEBIAN_FRONTEND=noninteractive && sudo apt-get update && sudo apt-get install -y ${{ matrix.CC }} - uses: actions/checkout@v4 - name: Build env: diff --git a/.github/workflows/net-snmp.yml b/.github/workflows/net-snmp.yml index e175f487b..7ce030b80 100644 --- a/.github/workflows/net-snmp.yml +++ b/.github/workflows/net-snmp.yml @@ -15,8 +15,9 @@ concurrency: jobs: build_wolfssl: name: Build wolfSSL + if: github.repository_owner == 'wolfssl' # Just to keep it the same as the testing target - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: @@ -46,7 +47,8 @@ jobs: - ref: 5.9.3 test_opts: -e 'agentxperl' name: ${{ matrix.ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 needs: build_wolfssl @@ -58,7 +60,7 @@ jobs: - name: untar build-dir run: tar -xf build-dir.tgz - + - name: Checkout OSP uses: actions/checkout@v4 with: diff --git a/.github/workflows/nginx.yml b/.github/workflows/nginx.yml index 6622e0d2a..868a02aba 100644 --- a/.github/workflows/nginx.yml +++ b/.github/workflows/nginx.yml @@ -15,8 +15,9 @@ concurrency: jobs: build_wolfssl: name: Build wolfSSL + if: github.repository_owner == 'wolfssl' # Just to keep it the same as the testing target - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: @@ -96,7 +97,7 @@ jobs: stream_ssl_preread.t stream_ssl_realip.t stream_ssl_session_reuse.t stream_ssl.t stream_ssl_variables.t stream_ssl_verify_client.t stream_upstream_zone_ssl.t upstream_zone_ssl.t uwsgi_ssl_certificate.t uwsgi_ssl_certificate_vars.t - uwsgi_ssl.t uwsgi_ssl_verify.t + uwsgi_ssl.t uwsgi_ssl_verify.t # Following tests do not pass with sanitizer on (with OpenSSL too) sanitize-not-ok: >- grpc_ssl.t h2_proxy_request_buffering_ssl.t h2_proxy_ssl.t @@ -105,7 +106,8 @@ jobs: stream_proxy_protocol_ssl.t stream_proxy_ssl_conf_command.t stream_proxy_ssl.t stream_proxy_ssl_verify.t name: ${{ matrix.ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 6 needs: build_wolfssl @@ -221,4 +223,4 @@ jobs: LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/build-dir/lib \ TMPDIR=$GITHUB_WORKSPACE TEST_NGINX_BINARY=../nginx/objs/nginx \ prove ${{ matrix.sanitize-ok }} - + diff --git a/.github/workflows/no-malloc.yml b/.github/workflows/no-malloc.yml index 88e5eedd7..25c9c8288 100644 --- a/.github/workflows/no-malloc.yml +++ b/.github/workflows/no-malloc.yml @@ -18,10 +18,11 @@ jobs: matrix: config: [ # Add new configs here - '--enable-rsa --enable-keygen --disable-dh CFLAGS="-DWOLFSSL_NO_MALLOC"', + '--enable-rsa --enable-keygen --disable-dh CFLAGS="-DWOLFSSL_NO_MALLOC -DRSA_MIN_SIZE=1024"', ] name: make check - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 6 steps: @@ -35,7 +36,7 @@ jobs: make ./wolfcrypt/test/testwolfcrypt - - name: Print errors + - name: Print errors if: ${{ failure() }} run: | if [ -f test-suite.log ] ; then diff --git a/.github/workflows/nss.sh b/.github/workflows/nss.sh new file mode 100644 index 000000000..8a78e0fd5 --- /dev/null +++ b/.github/workflows/nss.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e +set -x + +# Setup nss cert db +mkdir nssdb +./dist/Debug/bin/certutil -d nssdb -N --empty-password +./dist/Debug/bin/certutil -d nssdb -A -a -i wolfssl/certs/test/server-localhost.pem \ + -t TCP -n 'wolf localhost' + +# App data for nss +echo Hello from nss > /tmp/in + +# TLS 1.3 test +env -C wolfssl ./examples/server/server -v 4 -p 4433 \ + -c certs/test/server-localhost.pem -d -w > /tmp/server.log 2>&1 & +sleep 0.1 +./dist/Debug/bin/tstclnt -V tls1.3: -h localhost -p 4433 -d nssdb -C -4 -A /tmp/in -v +sleep 0.1 + +# DTLS 1.3 test +env -C wolfssl ./examples/server/server -v 4 -p 4433 -u \ + -c certs/test/server-localhost.pem -d -w > /tmp/server.log 2>&1 & +sleep 0.1 +./dist/Debug/bin/tstclnt -V tls1.3: -P client -h localhost -p 4433 -d nssdb -C -4 -A /tmp/in -v +sleep 0.1 diff --git a/.github/workflows/nss.yml b/.github/workflows/nss.yml new file mode 100644 index 000000000..e7d911bd1 --- /dev/null +++ b/.github/workflows/nss.yml @@ -0,0 +1,89 @@ +name: nss interop Tests + +### TODO uncomment stuff + +# 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 + +env: + NSS_REF: NSS_3_107_RTM + +jobs: + build_nss: + name: Build nss + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + # This should be a safe limit for the tests to run. + timeout-minutes: 30 + steps: + - name: Checking if we have nss in cache + uses: actions/cache@v4 + id: cache + with: + path: dist + key: nss-${{ env.NSS_REF }} + lookup-only: true + + - name: Install dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: | + # Don't prompt for anything + export DEBIAN_FRONTEND=noninteractive + sudo apt-get update + # hostap dependencies + sudo apt-get install -y gyp ninja-build + + - name: Checkout nss + if: steps.cache.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + repository: nss-dev/nss + ref: ${{ env.NSS_REF }} + path: nss + + - name: Compile nss + if: steps.cache.outputs.cache-hit != 'true' + run: | + hg clone https://hg.mozilla.org/projects/nspr + cd nss + ./build.sh + + nss_test: + name: Test interop with nss + runs-on: ubuntu-22.04 + needs: build_nss + timeout-minutes: 10 + if: github.repository_owner == 'wolfssl' + steps: + - name: Checking if we have nss in cache + uses: actions/cache/restore@v4 + id: cache + with: + path: dist + key: nss-${{ env.NSS_REF }} + fail-on-cache-miss: true + + - name: Build wolfSSL + uses: wolfSSL/actions-build-autotools-project@v1 + with: + path: wolfssl + configure: --enable-dtls --enable-dtls13 + install: false + check: false + + - name: Test interop + run: bash wolfssl/.github/workflows/nss.sh + + - name: print server logs + if: ${{ failure() }} + run: | + cat /tmp/server.log diff --git a/.github/workflows/ntp.yml b/.github/workflows/ntp.yml index f4f06bef1..2acd82b22 100644 --- a/.github/workflows/ntp.yml +++ b/.github/workflows/ntp.yml @@ -15,8 +15,9 @@ concurrency: jobs: build_wolfssl: name: Build wolfSSL + if: github.repository_owner == 'wolfssl' # Just to keep it the same as the testing target - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: @@ -43,9 +44,10 @@ jobs: fail-fast: false matrix: # List of releases to test - ref: [ 4.2.8p15 ] + ref: [ 4.2.8p15, 4.2.8p17 ] name: ${{ matrix.ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 10 needs: build_wolfssl @@ -89,4 +91,3 @@ jobs: ./configure --with-wolfssl=$GITHUB_WORKSPACE/build-dir make -j make -j check - \ No newline at end of file diff --git a/.github/workflows/ocsp.yml b/.github/workflows/ocsp.yml index 3937b2e7f..b7c8f8ef5 100644 --- a/.github/workflows/ocsp.yml +++ b/.github/workflows/ocsp.yml @@ -15,7 +15,8 @@ concurrency: jobs: ocsp_stapling: name: ocsp stapling - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 timeout-minutes: 10 steps: - name: Checkout wolfSSL diff --git a/.github/workflows/openldap.yml b/.github/workflows/openldap.yml new file mode 100644 index 000000000..b77dd3ea9 --- /dev/null +++ b/.github/workflows/openldap.yml @@ -0,0 +1,91 @@ +name: openldap 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-22.04 + # 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-openldap CPPFLAGS=-DWOLFSSL_NO_ASN_STRICT + install: true + check: true + + - name: tar build-dir + run: tar -zcf build-dir.tgz build-dir + + - name: Upload built lib + uses: actions/upload-artifact@v4 + with: + name: wolf-install-openldap + path: build-dir.tgz + retention-days: 5 + + openldap_check: + strategy: + fail-fast: false + matrix: + include: + # List of releases to test + - osp_ref: 2.5.13 + git_ref: OPENLDAP_REL_ENG_2_5_13 + - osp_ref: 2.6.7 + git_ref: OPENLDAP_REL_ENG_2_6_7 + name: ${{ matrix.osp_ref }} + runs-on: ubuntu-22.04 + # This should be a safe limit for the tests to run. + timeout-minutes: 20 + needs: build_wolfssl + steps: + - name: Download lib + uses: actions/download-artifact@v4 + with: + name: wolf-install-openldap + + - name: untar build-dir + run: tar -xf build-dir.tgz + + - name: Checkout OSP + uses: actions/checkout@v4 + with: + repository: wolfssl/osp + path: osp + + - name: Checkout openldap + uses: actions/checkout@v4 + with: + repository: openldap/openldap + path: openldap + ref: ${{ matrix.git_ref }} + + - name: Build and test OpenLDAP + working-directory: openldap + run: | + export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/build-dir/lib:$LD_LIBRARY_PATH + patch -p1 < $GITHUB_WORKSPACE/osp/openldap/${{ matrix.osp_ref }}/openldap-${{ matrix.osp_ref }}.patch + rm aclocal.m4 + autoreconf -ivf + ./configure --with-tls=wolfssl --disable-bdb --disable-hdb \ + CFLAGS="-I$GITHUB_WORKSPACE/build-dir/include \ + -I$GITHUB_WORKSPACE/build-dir/include/wolfssl \ + -L$GITHUB_WORKSPACE/build-dir/lib" + make -j depend + make -j + make -j check diff --git a/.github/workflows/openssh.yml b/.github/workflows/openssh.yml index 456ca842c..83b122773 100644 --- a/.github/workflows/openssh.yml +++ b/.github/workflows/openssh.yml @@ -15,8 +15,9 @@ concurrency: jobs: build_wolfssl: name: Build wolfSSL + if: github.repository_owner == 'wolfssl' # Just to keep it the same as the testing target - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: @@ -26,7 +27,7 @@ jobs: path: wolfssl configure: >- --enable-openssh --enable-dsa --with-max-rsa-bits=8192 - --enable-intelasm --enable-sp-asm + --enable-intelasm --enable-sp-asm CFLAGS="-DRSA_MIN_SIZE=1024" install: true - name: tar build-dir @@ -47,7 +48,8 @@ jobs: - git_ref: 'V_9_6_P1' osp_ver: '9.6' name: ${{ matrix.ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 needs: build_wolfssl steps: - name: Download lib @@ -74,7 +76,7 @@ jobs: configure: --with-wolfssl=$GITHUB_WORKSPACE/build-dir --with-rpath=-Wl,-rpath= check: false - # make tests take >20 minutes. Consider limiting? + # make tests take >20 minutes. Consider limiting? - name: Run tests working-directory: ./openssh run: | diff --git a/.github/workflows/opensslcoexist.yml b/.github/workflows/opensslcoexist.yml new file mode 100644 index 000000000..1b59bec85 --- /dev/null +++ b/.github/workflows/opensslcoexist.yml @@ -0,0 +1,50 @@ +name: OPENSSL_COEXIST and TEST_OPENSSL_COEXIST + +# 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: + make_check: + strategy: + matrix: + config: [ + # Add new configs here + '--verbose --enable-all --disable-all-osp --disable-opensslall --enable-opensslcoexist CPPFLAGS="-DNO_WOLFSSL_CIPHER_SUITE_TEST -pedantic"', + '--verbose --enable-all --disable-all-osp --disable-opensslall --enable-opensslcoexist CPPFLAGS="-DNO_WOLFSSL_CIPHER_SUITE_TEST -pedantic -DTEST_OPENSSL_COEXIST"' + ] + name: make check + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + # This should be a safe limit for the tests to run. + timeout-minutes: 6 + steps: + - uses: actions/checkout@v4 + name: Checkout wolfSSL + + - name: Test --enable-opensslcoexist and TEST_OPENSSL_COEXIST + run: | + ./autogen.sh || $(exit 2) + ./configure ${{ matrix.config }} || $(exit 3) + make -j 4 || $(exit 4) + make check + + - name: Print errors + if: ${{ failure() }} + run: | + for file in config.log scripts/*.log + do + if [ -f "$file" ]; then + echo "${file}:" + cat "$file" + echo "========================================================================" + fi + done diff --git a/.github/workflows/openvpn.yml b/.github/workflows/openvpn.yml index a547e8d8f..974630145 100644 --- a/.github/workflows/openvpn.yml +++ b/.github/workflows/openvpn.yml @@ -15,8 +15,9 @@ concurrency: jobs: build_wolfssl: name: Build wolfSSL + if: github.repository_owner == 'wolfssl' # Just to keep it the same as the testing target - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: @@ -42,9 +43,10 @@ jobs: fail-fast: false matrix: # List of refs to test - ref: [ release/2.6, v2.6.0, master ] + ref: [ release/2.6, master ] name: ${{ matrix.ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 10 needs: build_wolfssl diff --git a/.github/workflows/os-check.yml b/.github/workflows/os-check.yml index 68557a31a..190a26b62 100644 --- a/.github/workflows/os-check.yml +++ b/.github/workflows/os-check.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-latest, macos-latest ] + os: [ ubuntu-22.04, macos-latest ] config: [ # Add new configs here '', @@ -25,16 +25,26 @@ jobs: '--enable-all --enable-asn=original', '--enable-harden-tls', '--enable-tls13 --enable-session-ticket --enable-dtls --enable-dtls13 - --enable-opensslextra --enable-sessioncerts - CPPFLAGS=''-DWOLFSSL_DTLS_NO_HVR_ON_RESUME -DHAVE_EXT_CACHE + --enable-opensslextra --enable-sessioncerts + CPPFLAGS=''-DWOLFSSL_DTLS_NO_HVR_ON_RESUME -DHAVE_EXT_CACHE -DWOLFSSL_TICKET_HAVE_ID -DHAVE_EX_DATA -DSESSION_CACHE_DYNAMIC_MEM'' ', '--enable-all --enable-secure-renegotiation', '--enable-all --enable-haproxy --enable-quic', - '--enable-dtls --enable-dtls13 --enable-earlydata - --enable-session-ticket --enable-psk + '--enable-dtls --enable-dtls13 --enable-earlydata + --enable-session-ticket --enable-psk CPPFLAGS=''-DWOLFSSL_DTLS13_NO_HRR_ON_RESUME'' ', + '--enable-experimental --enable-kyber --enable-dtls --enable-dtls13 + --enable-dtls-frag-ch', + '--enable-all --enable-dtls13 --enable-dtls-frag-ch', + '--enable-dtls --enable-dtls13 --enable-dtls-frag-ch + --enable-dtls-mtu', + '--enable-dtls --enable-dtlscid --enable-dtls13 --enable-secure-renegotiation + --enable-psk --enable-aesccm --enable-nullcipher CPPFLAGS=-DWOLFSSL_STATIC_RSA', + '--enable-ascon --enable-experimental', + '--enable-ascon CPPFLAGS=-DWOLFSSL_ASCON_UNROLL --enable-experimental', ] name: make check + if: github.repository_owner == 'wolfssl' runs-on: ${{ matrix.os }} # This should be a safe limit for the tests to run. timeout-minutes: 14 @@ -49,12 +59,13 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-latest, macos-latest ] + os: [ ubuntu-22.04, macos-latest ] user-settings: [ # Add new user_settings.h here 'examples/configs/user_settings_all.h', ] name: make user_setting.h + if: github.repository_owner == 'wolfssl' runs-on: ${{ matrix.os }} # This should be a safe limit for the tests to run. timeout-minutes: 14 @@ -70,9 +81,10 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-latest, macos-latest ] + os: [ ubuntu-22.04, macos-latest ] user-settings: [ # Add new user_settings.h here + 'examples/configs/user_settings_eccnonblock.h', 'examples/configs/user_settings_min_ecc.h', 'examples/configs/user_settings_wolfboot_keytools.h', 'examples/configs/user_settings_wolftpm.h', @@ -80,6 +92,7 @@ jobs: 'examples/configs/user_settings_tls12.h', ] name: make user_setting.h (testwolfcrypt only) + if: github.repository_owner == 'wolfssl' runs-on: ${{ matrix.os }} # This should be a safe limit for the tests to run. timeout-minutes: 14 @@ -99,8 +112,9 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-latest, macos-latest ] + os: [ ubuntu-22.04, macos-latest ] name: make user_setting.h (with sed) + if: github.repository_owner == 'wolfssl' runs-on: ${{ matrix.os }} # This should be a safe limit for the tests to run. timeout-minutes: 14 @@ -119,7 +133,12 @@ jobs: windows_build: name: Windows Build Test + if: github.repository_owner == 'wolfssl' runs-on: windows-latest + strategy: + fail-fast: false + matrix: + arch: [ x64, Win32, ARM64 ] # This should be a safe limit for the tests to run. timeout-minutes: 6 env: @@ -130,7 +149,6 @@ jobs: # You can convert this to a build matrix if you need coverage of multiple configuration types. # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix BUILD_CONFIGURATION: Release - BUILD_PLATFORM: x64 steps: - uses: actions/checkout@v4 @@ -145,8 +163,9 @@ jobs: working-directory: ${{env.GITHUB_WORKSPACE}} # Add additional options to the MSBuild command line here (like platform or verbosity level). # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference - run: msbuild /m /p:PlatformToolset=v142 /p:Platform=${{env.BUILD_PLATFORM}} /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} + run: msbuild /m /p:PlatformToolset=v142 /p:Platform=${{matrix.arch}} /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} - - name: Run Test + - if: ${{ matrix.arch != 'ARM64' }} + name: Run Test working-directory: ${{env.GITHUB_WORKSPACE}} - run: Release/x64/testsuite.exe + run: Release/${{matrix.arch}}/testsuite.exe diff --git a/.github/workflows/packaging.yml b/.github/workflows/packaging.yml index b4657110c..e498e33af 100644 --- a/.github/workflows/packaging.yml +++ b/.github/workflows/packaging.yml @@ -15,7 +15,8 @@ concurrency: jobs: build_wolfssl: name: Package wolfSSL - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 10 steps: @@ -37,8 +38,9 @@ jobs: - name: Build wolfSSL .deb run: make deb-docker - - name: Build wolfSSL .rpm - run: make rpm-docker +# disabled 20240919 -- broken target. +# - name: Build wolfSSL .rpm +# run: make rpm-docker - name: Confirm packages built run: | @@ -47,8 +49,9 @@ jobs: echo Did not find exactly two deb packages!!! exit 1 fi - RPM_COUNT=$(find -name 'wolfssl*.rpm' | wc -l) - if [ "$RPM_COUNT" != "4" ]; then - echo Did not find exactly four rpm packages!!! - exit 1 - fi +# disabled 20240919 -- broken target. +# RPM_COUNT=$(find -name 'wolfssl*.rpm' | wc -l) +# if [ "$RPM_COUNT" != "4" ]; then +# echo Did not find exactly four rpm packages!!! +# exit 1 +# fi diff --git a/.github/workflows/pam-ipmi.yml b/.github/workflows/pam-ipmi.yml index dda320064..22da7d6b6 100644 --- a/.github/workflows/pam-ipmi.yml +++ b/.github/workflows/pam-ipmi.yml @@ -16,8 +16,9 @@ concurrency: jobs: build_wolfssl: name: Build wolfSSL + if: github.repository_owner == 'wolfssl' # Just to keep it the same as the testing target - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: @@ -46,7 +47,8 @@ jobs: matrix: git_ref: [ e4b13e6725abb178f62ee897fe1c0e81b06a9431 ] name: ${{ matrix.git_ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 needs: build_wolfssl steps: - name: Install dependencies @@ -54,8 +56,7 @@ jobs: # Don't prompt for anything export DEBIAN_FRONTEND=noninteractive sudo apt-get update - sudo apt-get install libpam-dev ninja-build - sudo pip3 install meson + sudo apt-get install libpam-dev ninja-build meson - name: Download lib uses: actions/download-artifact@v4 diff --git a/.github/workflows/pq-all.yml b/.github/workflows/pq-all.yml new file mode 100644 index 000000000..233a802e0 --- /dev/null +++ b/.github/workflows/pq-all.yml @@ -0,0 +1,50 @@ +name: Quantum Resistant 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: + make_check: + strategy: + matrix: + config: [ + # Add new configs here + '--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-kyber=yes,original --enable-lms --enable-xmss --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE"', + '--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-kyber=yes,original --enable-lms --enable-xmss --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE" CC=c++' + ] + name: make check + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + # This should be a safe limit for the tests to run. + timeout-minutes: 6 + steps: + - uses: actions/checkout@v4 + name: Checkout wolfSSL + + - name: Test wolfSSL + run: | + ./autogen.sh + ./configure ${{ matrix.config }} + make -j 4 + make check + + - name: Print errors + if: ${{ failure() }} + run: | + for file in scripts/*.log + do + if [ -f "$file" ]; then + echo "${file}:" + cat "$file" + echo "========================================================================" + fi + done diff --git a/.github/workflows/rng-tools.yml b/.github/workflows/rng-tools.yml index 47b7827e2..44d3a20e2 100644 --- a/.github/workflows/rng-tools.yml +++ b/.github/workflows/rng-tools.yml @@ -15,8 +15,9 @@ concurrency: jobs: build_wolfssl: name: Build wolfSSL + if: github.repository_owner == 'wolfssl' # Just to keep it the same as the testing target - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: @@ -45,7 +46,8 @@ jobs: # List of releases to test ref: [ 6.16 ] name: ${{ matrix.ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 needs: build_wolfssl @@ -64,7 +66,7 @@ jobs: - name: untar build-dir run: tar -xf build-dir.tgz - + - name: Checkout OSP uses: actions/checkout@v4 with: diff --git a/.github/workflows/socat.yml b/.github/workflows/socat.yml index fe2c8252a..91417e7a7 100644 --- a/.github/workflows/socat.yml +++ b/.github/workflows/socat.yml @@ -15,7 +15,8 @@ concurrency: jobs: build_wolfssl: name: Build wolfSSL - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 timeout-minutes: 4 steps: - name: Build wolfSSL @@ -37,9 +38,8 @@ jobs: socat_check: - strategy: - fail-fast: false - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 30 needs: build_wolfssl @@ -70,7 +70,7 @@ jobs: run: | patch -p1 < ../osp/socat/1.8.0.0/socat-1.8.0.0.patch autoreconf -vfi - ./configure --with-wolfssl=$GITHUB_WORKSPACE/build-dir + ./configure --with-wolfssl=$GITHUB_WORKSPACE/build-dir --enable-default-ipv=4 make - name: Run socat tests @@ -78,4 +78,4 @@ jobs: run: | export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/build-dir/lib:$LD_LIBRARY_PATH export SHELL=/bin/bash - SOCAT=$GITHUB_WORKSPACE/socat-1.8.0.0/socat ./test.sh -t 0.5 --expect-fail 146,216,309,310,386,399,402,459,460,467,468,478,492,528,530 + SOCAT=$GITHUB_WORKSPACE/socat-1.8.0.0/socat ./test.sh -t 0.5 --expect-fail 36,64,146,214,216,217,309,310,386,399,402,403,459,460,467,468,475,478,492,528,530 diff --git a/.github/workflows/softhsm.yml b/.github/workflows/softhsm.yml new file mode 100644 index 000000000..bb3824d17 --- /dev/null +++ b/.github/workflows/softhsm.yml @@ -0,0 +1,94 @@ +name: SoftHSMv2 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 + if: github.repository_owner == 'wolfssl' + # Just to keep it the same as the testing target + runs-on: ubuntu-22.04 + # This should be a safe limit for the tests to run. + timeout-minutes: 10 + steps: + - name: Build wolfSSL + uses: wolfSSL/actions-build-autotools-project@v1 + with: + path: wolfssl + configure: --enable-all CFLAGS=-DRSA_MIN_SIZE=1024 + install: true + check: false + + - name: tar build-dir + run: tar -zcf build-dir.tgz build-dir + + - name: Upload built lib + uses: actions/upload-artifact@v4 + with: + name: wolf-install-softhsm + path: build-dir.tgz + retention-days: 5 + + softhsm_check: + strategy: + fail-fast: false + matrix: + # List of releases to test + ref: [ 2.6.1 ] + name: ${{ matrix.ref }} + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + # This should be a safe limit for the tests to run. + timeout-minutes: 20 + 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 libcppunit-dev + + - name: Download lib + uses: actions/download-artifact@v4 + with: + name: wolf-install-softhsm + + - name: untar build-dir + run: tar -xf build-dir.tgz + + - name: Checkout OSP + uses: actions/checkout@v4 + with: + repository: wolfssl/osp + path: osp + + - name: Checkout SoftHSMv2 + uses: actions/checkout@v4 + with: + repository: opendnssec/SoftHSMv2 + path: softhsm + ref: ${{ matrix.ref }} + + # Not using wolfSSL/actions-build-autotools-project@v1 because autogen.sh doesn't work + - name: Build softhsm + working-directory: softhsm + run: | + patch -p1 < $GITHUB_WORKSPACE/osp/softhsm/${{ matrix.ref }}.patch + autoreconf -if + ./configure --with-crypto-backend=wolfssl WOLFSSL_INSTALL_DIR=$GITHUB_WORKSPACE/build-dir + make -j + + - name: Test softhsm + working-directory: softhsm + run: make -j check diff --git a/.github/workflows/sssd.yml b/.github/workflows/sssd.yml new file mode 100644 index 000000000..4ef3a7968 --- /dev/null +++ b/.github/workflows/sssd.yml @@ -0,0 +1,99 @@ +name: sssd 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: + if: github.repository_owner == 'wolfssl' + name: Build wolfSSL + # Just to keep it the same as the testing target + runs-on: ubuntu-22.04 + # 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 CFLAGS=-DWOLFSSL_NO_ASN_STRICT + install: true + check: false + + - name: tar build-dir + run: tar -zcf build-dir.tgz build-dir + + - name: Upload built lib + uses: actions/upload-artifact@v4 + with: + name: wolf-install-sssd + path: build-dir.tgz + retention-days: 5 + + sssd_check: + if: github.repository_owner == 'wolfssl' + strategy: + fail-fast: false + matrix: + # List of releases to test + ref: [ 2.9.1 ] + name: ${{ matrix.ref }} + runs-on: ubuntu-22.04 + container: + image: quay.io/sssd/ci-client-devel:ubuntu-latest + env: + LD_LIBRARY_PATH: /usr/local/lib + # This should be a safe limit for the tests to run. + timeout-minutes: 20 + 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 build-essential autoconf libldb-dev libldb2 python3-ldb bc + + - name: Setup env + run: | + ln -s samba-4.0/ldb.h /usr/include/ldb.h + ln -s samba-4.0/ldb_errors.h /usr/include/ldb_errors.h + ln -s samba-4.0/ldb_handlers.h /usr/include/ldb_handlers.h + ln -s samba-4.0/ldb_module.h /usr/include/ldb_module.h + ln -s samba-4.0/ldb_version.h /usr/include/ldb_version.h + + - name: Download lib + uses: actions/download-artifact@v4 + with: + name: wolf-install-sssd + + - name: untar build-dir + run: tar -xf build-dir.tgz + + - name: Checkout OSP + uses: actions/checkout@v4 + with: + repository: wolfssl/osp + path: osp + + - name: Build and test sssd + uses: wolfSSL/actions-build-autotools-project@v1 + with: + repository: SSSD/sssd + ref: ${{ matrix.ref }} + path: sssd + patch-file: $GITHUB_WORKSPACE/osp/sssd/${{ matrix.ref }}.patch + configure: >- + --without-samba --without-nfsv4-idmapd-plugin --with-oidc-child=no + --without-manpages WOLFSSL_INSTALL_DIR=$GITHUB_WORKSPACE/build-dir + check: true + diff --git a/.github/workflows/stunnel.yml b/.github/workflows/stunnel.yml index 7b7b09452..701a4e51b 100644 --- a/.github/workflows/stunnel.yml +++ b/.github/workflows/stunnel.yml @@ -15,8 +15,9 @@ concurrency: jobs: build_wolfssl: name: Build wolfSSL + if: github.repository_owner == 'wolfssl' # Just to keep it the same as the testing target - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 steps: @@ -44,7 +45,8 @@ jobs: # List of releases to test ref: [ 5.67 ] name: ${{ matrix.ref }} - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 4 needs: build_wolfssl @@ -56,7 +58,7 @@ jobs: - name: untar build-dir run: tar -xf build-dir.tgz - + - name: Checkout OSP uses: actions/checkout@v4 with: diff --git a/.github/workflows/watcomc.yml b/.github/workflows/watcomc.yml new file mode 100644 index 000000000..ea1af5704 --- /dev/null +++ b/.github/workflows/watcomc.yml @@ -0,0 +1,84 @@ +name: Build Watcom C + +# 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: + wolfssl_watcomc_windows: + if: github.repository_owner == 'wolfssl' + strategy: + fail-fast: false + matrix: + common: + - cmake: '-G "Watcom WMake" -DCMAKE_VERBOSE_MAKEFILE=TRUE -DWOLFSSL_ASM=no -DWOLFSSL_EXAMPLES=no -DWOLFSSL_CRYPT_TESTS=no' + platform: + - title: 'Windows OW 2.0' + system: 'Windows' + image: 'windows-latest' + owimage: '2.0' + id: 'win32ow20' + cmake: '-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=x86' + - title: 'Linux OW 2.0' + system: 'Linux' + image: 'ubuntu-latest' + owimage: '2.0' + id: 'linuxow20' + cmake: '-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86' + - title: 'OS/2 OW 2.0' + system: 'OS2' + image: 'windows-latest' + owimage: '2.0' + id: 'os2ow20' + cmake: '-DCMAKE_SYSTEM_NAME=OS2 -DCMAKE_SYSTEM_PROCESSOR=x86' + thread: + - id: 'multi' + cmake: '' + owcmake: '-DCMAKE_POLICY_DEFAULT_CMP0136=NEW -DCMAKE_WATCOM_RUNTIME_LIBRARY=MultiThreaded' + - id: 'single' + cmake: '-DWOLFSSL_SINGLE_THREADED=yes' + owcmake: '-DCMAKE_POLICY_DEFAULT_CMP0136=NEW -DCMAKE_WATCOM_RUNTIME_LIBRARY=SingleThreaded' + library: + - id: 'dll' + cmake: '' + owcmake: 'DLL' + - id: 'static' + cmake: '-DBUILD_SHARED_LIBS=no' + owcmake: '' + exclude: + - { platform: { system: 'Linux' }, library: { id: 'dll' } } + runs-on: ${{ matrix.platform.image }} + name: ${{ matrix.platform.title }} (${{ matrix.thread.id }} ${{ matrix.library.id }}) + steps: + - name: Setup Open Watcom ${{ matrix.platform.owimage }} + uses: open-watcom/setup-watcom@v0 + with: + version: ${{ matrix.platform.owimage }} + + - name: Checkout wolfSSL + uses: actions/checkout@v4 + with: + path: wolfssl + + - name: Build wolfSSL + working-directory: wolfssl + shell: bash + run: | + cmake -B build ${{matrix.common.cmake}} ${{ matrix.platform.cmake }} ${{ matrix.thread.cmake }} ${{ matrix.library.cmake }} ${{ matrix.thread.owcmake }}${{ matrix.library.owcmake }} + cmake --build build + + - name: Upload build errors + if: failure() + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.platform.id }}-${{ matrix.thread.id }}-${{ matrix.library.id }} + path: | + build/** diff --git a/.github/workflows/win-csharp-test.yml b/.github/workflows/win-csharp-test.yml new file mode 100644 index 000000000..12b294b6b --- /dev/null +++ b/.github/workflows/win-csharp-test.yml @@ -0,0 +1,58 @@ +name: Windows CSharp Build Test + +on: + push: + branches: [ 'master', 'main', 'release/**' ] + pull_request: + branches: [ '*' ] + +jobs: + build: + + if: github.repository_owner == 'wolfssl' + runs-on: windows-latest + + # This should be a safe limit for the tests to run. + timeout-minutes: 6 + + env: + # Path to the solution file relative to the root of the project. + SOLUTION_FILE_PATH: wolfssl\wrapper\CSharp\wolfSSL_CSharp.sln + + # Configuration type to build. + # You can convert this to a build matrix if you need coverage of multiple configuration types. + # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + BUILD_CONFIGURATION: Debug + BUILD_PLATFORM: x64 + + steps: + - name: Pull wolfssl + uses: actions/checkout@master + with: + repository: wolfssl/wolfssl + path: wolfssl + + - name: Create FIPS stub files (autogen) + working-directory: wolfssl + run: | + echo $null >> wolfcrypt\src\fips.c + echo $null >> wolfcrypt\src\fips_test.c + echo $null >> wolfcrypt\src\wolfcrypt_first.c + echo $null >> wolfcrypt\src\wolfcrypt_last.c + + - name: Add MSBuild to PATH + uses: microsoft/setup-msbuild@v1 + + - name: Build + working-directory: ${{env.GITHUB_WORKSPACE}} + # Add additional options to the MSBuild command line here (like platform or verbosity level). + # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference + run: msbuild /m /p:PlatformToolset=v142 /p:Platform=${{env.BUILD_PLATFORM}} /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} + + - name: Run wolfCrypt test + working-directory: ${{env.GITHUB_WORKSPACE}}wolfssl\wrapper\CSharp\Debug\x64\ + run: ./wolfCrypt-test.exe + + - name: Run wolfSSL client/server example + working-directory: ${{env.GITHUB_WORKSPACE}}wolfssl\wrapper\CSharp\Debug\x64\ + run: ./wolfSSL-TLS-Server.exe && sleep 1 & ./wolfSSL-TLS-Client.exe diff --git a/.github/workflows/wolfCrypt-Wconversion.yml b/.github/workflows/wolfCrypt-Wconversion.yml new file mode 100644 index 000000000..77eac8531 --- /dev/null +++ b/.github/workflows/wolfCrypt-Wconversion.yml @@ -0,0 +1,41 @@ +name: wolfCrypt conversion warnings + +# 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_library: + strategy: + matrix: + config: [ + # Add new configs here + '--disable-asm --enable-cryptonly --enable-all-crypto --disable-examples --disable-benchmark --disable-crypttests CPPFLAGS="-Wconversion -Warith-conversion -Wenum-conversion -Wfloat-conversion -Wsign-conversion"', + '--enable-intelasm --enable-cryptonly --enable-all-crypto --disable-examples --disable-benchmark --disable-crypttests CPPFLAGS="-Wconversion -Warith-conversion -Wenum-conversion -Wfloat-conversion -Wsign-conversion"', + '--enable-smallstack --disable-asm --enable-cryptonly --enable-all-crypto --disable-examples --disable-benchmark --disable-crypttests CPPFLAGS="-Wconversion -Warith-conversion -Wenum-conversion -Wfloat-conversion -Wsign-conversion"', + '--enable-smallstack --enable-intelasm --enable-cryptonly --enable-all-crypto --disable-examples --disable-benchmark --disable-crypttests CPPFLAGS="-Wconversion -Warith-conversion -Wenum-conversion -Wfloat-conversion -Wsign-conversion"', + '--enable-cryptonly --enable-all-crypto --disable-examples --disable-benchmark --disable-crypttests CPPFLAGS="-Wconversion -Warith-conversion -Wenum-conversion -Wfloat-conversion -Wsign-conversion -DNO_INT128"' + ] + name: build library + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 + # This should be a safe limit for the tests to run. + timeout-minutes: 6 + steps: + - uses: actions/checkout@v4 + name: Checkout wolfSSL + + - name: Build wolfCrypt with extra type conversion warnings + run: | + ./autogen.sh || $(exit 2) + echo "running ./configure ${{ matrix.config }}" + ./configure ${{ matrix.config }} || $(exit 3) + make -j 4 || $(exit 4) diff --git a/.github/workflows/zephyr.yml b/.github/workflows/zephyr.yml index 2bb059c29..fb7f0d2b3 100644 --- a/.github/workflows/zephyr.yml +++ b/.github/workflows/zephyr.yml @@ -25,7 +25,8 @@ jobs: zephyr-sdk: 0.16.3 - zephyr-ref: v2.7.4 zephyr-sdk: 0.16.3 - runs-on: ubuntu-latest + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-22.04 # This should be a safe limit for the tests to run. timeout-minutes: 25 steps: @@ -45,9 +46,14 @@ jobs: libglib2.0-dev libgtk2.0-0 liblocale-gettext-perl libncurses5-dev libpcap-dev \ libpopt0 libsdl1.2-dev libsdl2-dev libssl-dev libtool libtool-bin locales make \ net-tools ninja-build openssh-client parallel pkg-config python3-dev python3-pip \ - python3-ply python3-setuptools python-is-python3 qemu rsync socat srecord sudo \ + python3-ply python3-setuptools python-is-python3 qemu-kvm rsync socat srecord sudo \ texinfo unzip wget ovmf xz-utils + - name: Setup cmake version + uses: jwlawson/actions-setup-cmake@v2 + with: + cmake-version: '3.25.x' + - name: Install west run: sudo pip install west diff --git a/.gitignore b/.gitignore index 50c2ff5e7..90c76affa 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ ctaocrypt/src/src/ *.cache .dirstamp *.user +!*-VS2022.vcxproj.user configure config.* !cmake/config.in @@ -245,6 +246,7 @@ linuxkm/libwolfssl.mod.c linuxkm/libwolfssl.lds linuxkm/module_exports.c linuxkm/linuxkm/get_thread_size +*.nds # autotools generated scripts/unit.test @@ -416,11 +418,16 @@ user_settings_asm.h # ESP8266 RTOS SDK has a slightly different sdkconfig filename to exclude: /IDE/Espressif/**/sdkconfig.debug /IDE/Espressif/**/sdkconfig.release +/IDE/Espressif/**/sdkconfig-debug +/IDE/Espressif/**/sdkconfig-release # Always include Espressif makefiles (typically only used for ESP8266) !/IDE/Espressif/**/Makefile !/IDE/Espressif/**/component.mk +# Ignore all the example logs +/IDE/Espressif/ESP-IDF/examples/**/logs/* + # MPLAB /IDE/MPLABX16/wolfssl.X/dist/default/ /IDE/MPLABX16/wolfssl.X/.generated_files @@ -442,6 +449,12 @@ debian/changelog debian/control *.deb +# Ada/Alire files +wrapper/Ada/alire/ +wrapper/Ada/config/ +wrapper/Ada/lib/ +wrapper/Ada/obj/ + # PlatformIO /**/.pio /**/.vscode/.browse.c_cpp.db* @@ -449,3 +462,7 @@ debian/control /**/.vscode/launch.json /**/.vscode/ipch /**/sdkconfig.esp32dev + +# Autogenerated debug trace headers +wolfssl/debug-trace-error-codes.h +wolfssl/debug-untrace-error-codes.h diff --git a/.wolfssl_known_macro_extras b/.wolfssl_known_macro_extras new file mode 100644 index 000000000..9c87962f2 --- /dev/null +++ b/.wolfssl_known_macro_extras @@ -0,0 +1,1017 @@ +AES_GCM_GMULT_NCT +AFX_RESOURCE_DLL +AFX_TARG_ENU +ALLOW_BINARY_MISMATCH_INTROSPECTION +ALLOW_V1_EXTENSIONS +ANDROID +APP_ESP_HTTP_CLIENT +APP_ESP_HTTP_CLIENT_EXAMPLE +APSTUDIO_INVOKED +ARCH_sim +ARDUINO +ARDUINO_ARCH_ESP32 +ARDUINO_ARCH_ESP8266 +ARDUINO_ARCH_MBED +ARDUINO_ARCH_NRF52 +ARDUINO_ARCH_RP2040 +ARDUINO_ARCH_SAMD +ARDUINO_ARCH_STM32 +ARDUINO_SAMD_NANO_33_IOT +ARDUINO_SAM_DUE +ARDUINO_SEEED_XIAO +ARDUINO_TEENSY41 +ASN_DUMP_OID +ASN_TEMPLATE_SKIP_ISCA_CHECK +ATCAPRINTF +ATCA_ENABLE_DEPRECATED +AVR +BASE64_NO_TABLE +BLAKE2B_SELFTEST +BLAKE2S_SELFTEST +BLOCKING +BSP_DEFAULT_IO_CHANNEL_DEFINED +BSP_LED_0 +BSP_LED_1 +BSP_SDCARD_ESDHC_CHANNEL +BSP_SDCARD_SDHC_CHANNEL +BSP_SDCARD_SPI_CHANNEL +CAAM_OUT_INVALIDATE +CERT_REL_PREFIX +CIOCASYMFEAT +CIOCGSESSINFO +CMSIS_OS2_H_ +COMPONENT_WOLFSSL +CONFIG_ARCH_CHIP_STM32F746ZG +CONFIG_ARCH_CHIP_STM32H743ZI +CONFIG_ARCH_CHIP_STM32L552ZE +CONFIG_ARCH_POSIX +CONFIG_ARM +CONFIG_ARM64 +CONFIG_BOARD_NATIVE_POSIX +CONFIG_COMPILER_OPTIMIZATION_DEFAULT +CONFIG_COMPILER_OPTIMIZATION_NONE +CONFIG_COMPILER_OPTIMIZATION_PERF +CONFIG_COMPILER_OPTIMIZATION_SIZE +CONFIG_CRYPTO_FIPS +CONFIG_CRYPTO_MANAGER +CONFIG_CSPRNG_ENABLED +CONFIG_ESP32C2_DEFAULT_CPU_FREQ_MHZ +CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ +CONFIG_ESP32H2_DEFAULT_CPU_FREQ_MHZ +CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ +CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ +CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ +CONFIG_ESP8266_XTAL_FREQ_26 +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_160 +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240 +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_80 +CONFIG_ESP_ENABLE_WOLFSSH +CONFIG_ESP_MAIN_TASK_STACK_SIZE +CONFIG_ESP_TLS_USING_WOLFSSL +CONFIG_ESP_WIFI_PASSWORD +CONFIG_ESP_WIFI_SSID +CONFIG_ESP_WOLFSSL_ENABLE_KYBER +CONFIG_ESP_WOLFSSL_ENABLE_WOLFSSH +CONFIG_ESP_WOLFSSL_NO_ESP32_CRYPT +CONFIG_ESP_WOLFSSL_NO_HW_AES +CONFIG_ESP_WOLFSSL_NO_HW_HASH +CONFIG_ESP_WOLFSSL_NO_HW_RSA_PRI +CONFIG_ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD +CONFIG_ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL +CONFIG_ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD +CONFIG_FREERTOS_HZ +CONFIG_FREERTOS_UNICORE +CONFIG_IDF_TARGET +CONFIG_IDF_TARGET_ARCH_RISCV +CONFIG_IDF_TARGET_ARCH_XTENSA +CONFIG_IDF_TARGET_ESP32 +CONFIG_IDF_TARGET_ESP32C2 +CONFIG_IDF_TARGET_ESP32C3 +CONFIG_IDF_TARGET_ESP32C6 +CONFIG_IDF_TARGET_ESP32H2 +CONFIG_IDF_TARGET_ESP32P4 +CONFIG_IDF_TARGET_ESP32S2 +CONFIG_IDF_TARGET_ESP32S3 +CONFIG_IDF_TARGET_ESP8266 +CONFIG_IDF_TARGET_ESP8684 +CONFIG_MAIN_TASK_STACK_SIZE +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE +CONFIG_MBEDTLS_PSA_CRYPTO_C +CONFIG_MIPS +CONFIG_MODULE_SIG +CONFIG_NET_SOCKETS_SOCKOPT_TLS +CONFIG_NEWLIB_LIBC +CONFIG_NEWLIB_NANO_FORMAT +CONFIG_PICOLIBC +CONFIG_POSIX_API +CONFIG_POSIX_THREADS +CONFIG_PREEMPT_COUNT +CONFIG_PTHREAD_IPC +CONFIG_SMP +CONFIG_SNTP_TIME_SYNC_METHOD_SMOOTH +CONFIG_TIMER_TASK_STACK_DEPTH +CONFIG_TIMER_TASK_STACK_SIZE +CONFIG_TLS_STACK_WOLFSSL +CONFIG_USE_WOLFSSL_ESP_SDK_TIME +CONFIG_USE_WOLFSSL_ESP_SDK_WIFI +CONFIG_WOLFCRYPT_ARMASM +CONFIG_WOLFCRYPT_FIPS +CONFIG_WOLFCRYPT_INTELASM +CONFIG_WOLFSSL +CONFIG_WOLFSSL_ALLOW_TLS13 +CONFIG_WOLFSSL_ALPN +CONFIG_WOLFSSL_ALT_CERT_CHAINS +CONFIG_WOLFSSL_APPLE_HOMEKIT +CONFIG_WOLFSSL_ASN_ALLOW_0_SERIAL +CONFIG_WOLFSSL_CERTIFICATE_BUNDLE +CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE +CONFIG_WOLFSSL_DTLS +CONFIG_WOLFSSL_ENABLE_KYBER +CONFIG_WOLFSSL_EXAMPLE_NAME_ESP32_SSH_SERVER +CONFIG_WOLFSSL_EXAMPLE_NAME_ESP8266_SSH_SERVER +CONFIG_WOLFSSL_EXAMPLE_NAME_NONE +CONFIG_WOLFSSL_EXAMPLE_NAME_TEMPLATE +CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_CLIENT +CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_SERVER +CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFMQTT_AWS_IOT_MQTT +CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFMQTT_TEMPLATE +CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSH_ECHOSERVER +CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSH_TEMPLATE +CONFIG_WOLFSSL_HKDF +CONFIG_WOLFSSL_MAX_FRAGMENT_LEN +CONFIG_WOLFSSL_NO_ASN_STRICT +CONFIG_WOLFSSL_PSK +CONFIG_WOLFSSL_RSA_PSS +CONFIG_WOLFSSL_TARGET_HOST +CONFIG_WOLFSSL_TARGET_PORT +CONFIG_WOLFSSL_TLS13_ENABLED +CONFIG_WOLFSSL_TLS_VERSION_1_2 +CONFIG_WOLFSSL_TLS_VERSION_1_3 +CONFIG_WOLFTPM +CONFIG_WOLFTPM_EXAMPLE_NAME_ESPRESSIF +CONFIG_X86 +CONV_WITH_DIV +CPA_CY_API_VERSION_NUM_MAJOR +CPU_MIMXRT1176DVMAA_cm7 +CPU_MK82FN256VLL15 +CRLDP_VALIDATE_DATA +CRL_REPORT_LOAD_ERRORS +CRL_STATIC_REVOKED_LIST +CRYPTOCELL_KEY_SIZE +CRYP_HEADERWIDTHUNIT_BYTE +CRYP_KEYIVCONFIG_ONCE +CRYP_KEYSIZE_192B +CSM_UNSUPPORTED_ALGS +CTYPE_USER +CURVED448_SMALL +CY_USING_HAL +DCP_USE_DCACHE +DILITHIUM_MUL_11_SLOW +DILITHIUM_MUL_44_SLOW +DILITHIUM_MUL_QINV_SLOW +DILITHIUM_MUL_Q_SLOW +DILITHIUM_MUL_SLOW +DILITHIUM_USE_HINT_CT +DTLS_RECEIVEFROM_NO_TIMEOUT_ON_INVALID_PEER +ECCSI_ORDER_MORE_BITS_THAN_PRIME +ECC_DUMP_OID +ECDHE_SIZE +ENABLE_SECURE_SOCKETS_LOGS +ESP32 +ESP8266 +ESP_ENABLE_WOLFSSH +ESP_IDF_VERSION_MAJOR +ESP_IDF_VERSION_MINOR +ESP_PLATFORM +ESP_TASK_MAIN_STACK +ETHERNET_AVAILABLE +EV_TRIGGER +FP_ECC_CONTROL +FREERTOS_TCP_WINSIM +FREESCALE +FREESCALE_RNGB +FREESCALE_USE_MMCAU_CLASSIC +FSL_FEATURE_HAS_L1CACHE +FSL_FEATURE_LTC_HAS_DES +FSL_FEATURE_LTC_HAS_GCM +FSL_FEATURE_LTC_HAS_PKHA +FSL_FEATURE_LTC_HAS_SHA +FSL_FEATURE_SOC_LTC_COUNT +FSL_FEATURE_SOC_MMCAU_COUNT +FSL_FEATURE_SOC_RNG_COUNT +FSL_FEATURE_SOC_TRNG_COUNT +FUSION_RTOS +GENERATE_MACHINE_PARSEABLE_REPORT +GE_P3_TOBYTES_IMPL +GOAHEAD_WS +HAL_RTC_MODULE_ENABLED +HARDWARE_CACHE_COHERENCY +HASH_AlgoMode_HASH +HASH_BYTE_SWAP +HASH_CR_LKEY +HASH_DIGEST +HASH_DataType_8b +HASH_IMR_DCIE +HASH_IMR_DINIE +HAVE_AESGCM_DECRYPT +HAVE_BYTEREVERSE64 +HAVE_CERTIFICATE_STATUS_V2 +HAVE_COLDFIRE_SEC +HAVE_CRL_UPDATE_CB +HAVE_CSHARP +HAVE_CURL +HAVE_CURVE22519 +HAVE_DANE +HAVE_ECC239 +HAVE_ECC320 +HAVE_ECC512 +HAVE_ECC_CDH_CAST +HAVE_ECC_SM2 +HAVE_ESP_CLK +HAVE_FACON +HAVE_FIPS_VERSION_PORT +HAVE_FUZZER +HAVE_INTEL_MULX +HAVE_INTEL_QAT_SYNC +HAVE_INTEL_SPEEDUP +HAVE_MDK_RTX +HAVE_NETX_BSD +HAVE_PKCS7_RSA_RAW_SIGN_CALLBACK +HAVE_POCO_LIB +HAVE_RTP_SYS +HAVE_SECURE_GETENV +HAVE_STACK_SIZE_VERBOSE_LOG +HAVE_THREADX +HAVE_TM_TYPE +HAVE_VALIDATE_DATE +HAVE_VA_COPY +HAVE_X448 +HONOR_MATH_USED_LENGTH +HSM_KEY_TYPE_HMAC_224 +HSM_KEY_TYPE_HMAC_256 +HSM_KEY_TYPE_HMAC_384 +HSM_KEY_TYPE_HMAC_512 +HSM_OP_KEY_GENERATION_FLAGS_CREATE +HSM_OP_KEY_GENERATION_FLAGS_UPDATE +HSM_SVC_KEY_STORE_FLAGS_UPDATE +HWCAP_ASIMDRDM +IDIRECT_DEV_RANDOM +IDIRECT_DEV_TIME +ID_TRNG +IGNORE_KEY_EXTENSIONS +IGNORE_NETSCAPE_CERT_TYPE +INCLUDE_uxTaskGetStackHighWaterMark +INTEGRITY +INTIMEVER +IOTSAFE_NO_GETDATA +IOTSAFE_SIG_8BIT_LENGTH +KCAPI_USE_XMALLOC +K_SERIES +LIBWOLFSSL_VERSION_GIT_BRANCH +LIBWOLFSSL_VERSION_GIT_HASH +LIBWOLFSSL_VERSION_GIT_HASH_DATE +LIBWOLFSSL_VERSION_GIT_ORIGIN +LIBWOLFSSL_VERSION_GIT_SHORT_HASH +LIBWOLFSSL_VERSION_GIT_TAG +LINUXKM_FPU_STATES_FOLLOW_THREADS +LINUXKM_LKCAPI_PRIORITY_ALLOW_MASKING +LINUX_CYCLE_COUNT +LINUX_RUSAGE_UTIME +LP64 +MAX3266X_AESGCM +MAX3266X_RSA +MAXQ10XX_PRODUCTION_KEY +MAXQ_EXPORT_TLS_KEYS +MAXQ_SHA1 +MAXSEG_64K +MAX_WOLFSSL_FILE_SIZE +MDK_CONF_BARE_METAL +MDK_CONF_FS +MDK_CONF_RTX_TCP_FS +MDK_CONF_TCP_FS +MDK_WOLFLIB +MICRIUM_MALLOC +MICROCHIP_MPLAB_HARMONY +MICROCHIP_MPLAB_HARMONY_3 +MICRO_SESSION_CACHEx +MLKEM_NONDETERMINISTIC +MODULE_SOCK_TCP +MP_31BIT +MP_8BIT +MQX_USE_IO_OLD +MULTI_VALUE_STATISTICS +MUTEX_DURING_INIT +NEED_THREADX_TYPES +NETX_DUO +NET_SECURE_MODULE_EN +NOTE_TRIGGER +NO_AES_DECRYPT +NO_ARDUINO_DEFAULT +NO_ASM +NO_ASN_OLD_TYPE_NAMES +NO_CAMELLIA_CBC +NO_CERT +NO_CIPHER_SUITE_ALIASES +NO_CLIENT_CACHE +NO_CLOCK_SPEEDUP +NO_CURVE25519_KEY_EXPORT +NO_CURVE25519_KEY_IMPORT +NO_CURVE25519_SHARED_SECRET +NO_CURVE448_KEY_EXPORT +NO_CURVE448_KEY_IMPORT +NO_CURVE448_SHARED_SECRET +NO_DEV_URANDOM +NO_ECC384 +NO_ECC521 +NO_ECC_CACHE_CURVE +NO_ECC_CHECK_KEY +NO_ECC_CHECK_PUBKEY_ORDER +NO_ECC_KEY_IMPORT +NO_ECC_MAKE_PUB +NO_ED25519_CLIENT_AUTH +NO_ED25519_KEY_EXPORT +NO_ED25519_KEY_IMPORT +NO_ED25519_MAKE_KEY +NO_ED25519_SIGN +NO_ED25519_VERIFY +NO_ED448_CLIENT_AUTH +NO_ED448_KEY_EXPORT +NO_ED448_KEY_IMPORT +NO_ED448_SIGN +NO_ED448_VERIFY +NO_ESP_MP_MUL_EVEN_ALT_CALC +NO_FORCE_SCR_SAME_SUITE +NO_GCM_ENCRYPT_EXTRA +NO_GETENV +NO_HANDSHAKE_DONE_CB +NO_IMX6_CAAM_AES +NO_IMX6_CAAM_HASH +NO_OLD_NAMES +NO_OLD_POLY1305 +NO_OLD_TIMEVAL_NAME +NO_PBKDF1 +NO_PIC32MZ_CRYPT +NO_PIC32MZ_HASH +NO_PIC32MZ_RNG +NO_PKCS11_AES +NO_PKCS11_AESCBC +NO_PKCS11_AESGCM +NO_PKCS11_ECC +NO_PKCS11_ECDH +NO_PKCS11_EC_KEYGEN +NO_PKCS11_HMAC +NO_PKCS11_RNG +NO_PKCS11_RSA +NO_PKCS11_RSA_PKCS +NO_PKCS7 +NO_PKCS7_COMPRESSED_DATA +NO_PKCS7_ENCRYPTED_DATA +NO_PKCS7_STREAM +NO_POLY1305_ASM +NO_PUBLIC_CCM_SET_NONCE +NO_PUBLIC_GCM_SET_IV +NO_RESUME_SUITE_CHECK +NO_RNG +NO_RNG_MUTEX +NO_SESSION_CACHE_ROW_LOCK +NO_SKID +NO_SKIP_PREVIEW +NO_STDIO_FGETS_REMAP +NO_TKERNEL_MEM_POOL +NO_TLSX_PSKKEM_PLAIN_ANNOUNCE +NO_VERIFY_OID +NO_WC_SSIZE_TYPE +NO_WOLFSSL_ALLOC_ALIGN +NO_WOLFSSL_AUTOSAR_CRYIF +NO_WOLFSSL_AUTOSAR_CRYPTO +NO_WOLFSSL_AUTOSAR_CSM +NO_WOLFSSL_BASE64_DECODE +NO_WOLFSSL_BN_CTX +NO_WOLFSSL_MSG_EX +NO_WOLFSSL_RENESAS_FSPSM_AES +NO_WOLFSSL_RENESAS_FSPSM_HASH +NO_WOLFSSL_RENESAS_TSIP_CRYPT_AES +NO_WOLFSSL_SHA256 +NO_WOLFSSL_SHA256_INTERLEAVE +NO_WOLFSSL_SHA512_INTERLEAVE +NO_WOLFSSL_SKIP_TRAILING_PAD +NO_WOLFSSL_SMALL_STACK_STATIC +NO_WOLFSSL_XILINX_TAG_MALLOC +NRF52 +NRF52_SERIES +NRF_ERROR_MODULE_ALREADY_INITIALIZED +OLD_HELLO_ALLOWED +OPENSSL_EXTRA_BSD +OPENSSL_EXTRA_NO_ASN1 +OPENSSL_EXTRA_NO_BN +OPENSSL_NO_PK +OS_WINDOWS +OTHERBOARD +OTHER_BOARD +PEER_INFO +PKA_ECC_SCALAR_MUL_IN_B_COEFF +PLATFORMIO +PLUTON_CRYPTO_ECC +PRINT_SESSION_STATS +PTHREAD_STACK_MIN +QAT_ENABLE_HASH +QAT_ENABLE_RNG +QAT_USE_POLLING_CHECK +RC_NO_RNG +REDIRECTION_IN3_KEYELMID +REDIRECTION_IN3_KEYID +REDIRECTION_OUT1_KEYELMID +REDIRECTION_OUT1_KEYID +REDIRECTION_OUT2_KEYELMID +REDIRECTION_OUT2_KEYID +RENESAS_T4_USE +RTC_ALARMSUBSECONDMASK_ALL +RTE_CMSIS_RTOS_RTX +RTOS_MODULE_NET_AVAIL +RTPLATFORM +SA_INTERRUPT +SCEKEY_INSTALLED +SHA256_MANY_REGISTERS +SHA3_BY_SPEC +SHOW_CERTS +SHOW_GEN +SHOW_SIZES +SHOW_SSID_AND_PASSWORD +SIM_SCGC3_RNGA_MASK +SIM_SCGC5_PORTC_MASK +SIM_SCGC5_PORTD_MASK +SIM_SCGC5_PORTE_MASK +SIM_SCGC6_RNGA_MASK +SL_SE_KEY_TYPE_ECC_P384 +SL_SE_KEY_TYPE_ECC_P521 +SL_SE_KEY_TYPE_ECC_X25519 +SL_SE_KEY_TYPE_ECC_X448 +SL_SE_PRF_HMAC_SHA1 +SOFTDEVICE_PRESENT +SO_NOSIGPIPE +SO_REUSEPORT +SP_INT_NO_ASM +SP_MATH_NEED_ADD_OFF +SP_USE_DIVTI3 +SQRTMOD_USE_MOD_EXP +SSL_SNIFFER_EXPORTS +SSN_BUILDING_LIBYASSL +STATIC_CHUNKS_ONLY +STM32F107xC +STM32F207xx +STM32F217xx +STM32F401xE +STM32F407xx +STM32F437xx +STM32F756xx +STM32F777xx +STM32G071xx +STM32G491xx +STM32H563xx +STM32H723xx +STM32H725xx +STM32H743xx +STM32H753xx +STM32H7S3xx +STM32L475xx +STM32L4A6xx +STM32L552xx +STM32L562xx +STM32MP135Fxx +STM32U575xx +STM32U585xx +STM32U5A9xx +STM32WB55xx +STM32WBA52xx +STM32WL55xx +STM32_AESGCM_PARTIAL +STM32_HW_CLOCK_AUTO +STM32_NUTTX_RNG +TASK_EXTRA_STACK_SIZE +TCP_NODELAY +TFM_ALREADY_SET +TFM_SMALL_MONT_SET +THREADED_SNIFFTEST +TIF_NEED_FPU_LOAD +TIME_T_NOT_LONG +TI_DUMMY_BUILD +TLS13_RSA_PSS_SIGN_CB_NO_PREHASH +TSIP_RSAES_1024 +TSIP_RSAES_2048 +UNICODE +USER_CA_CB +USER_CUSTOM_SNIFFX +USER_MATH_LIB +USE_ALT_MPRIME +USE_ANY_ADDR +USE_CERT_BUFFERS_25519 +USE_CERT_BUFFERS_3072 +USE_ECDSA_KEYSZ_HASH_ALGO +USE_FULL_ASSERT +USE_HAL_DRIVER +USE_NXP_LTC +USE_NXP_MMCAU +USE_QAE_THREAD_LS +USE_SECRET_CALLBACK +USE_STSAFE_RNG_SEED +USE_STSAFE_VERBOSE +USE_TLSV13 +USE_WOLF_STRNSTR +USS_API +WC_AESXTS_STREAM_NO_REQUEST_ACCOUNTING +WC_AES_BS_WORD_SIZE +WC_AES_GCM_DEC_AUTH_EARLY +WC_ASN_HASH_SHA256 +WC_ASYNC_ENABLE_3DES +WC_ASYNC_ENABLE_AES +WC_ASYNC_ENABLE_ARC4 +WC_ASYNC_ENABLE_DH +WC_ASYNC_ENABLE_ECC +WC_ASYNC_ENABLE_ECC_KEYGEN +WC_ASYNC_ENABLE_HMAC +WC_ASYNC_ENABLE_MD5 +WC_ASYNC_ENABLE_RSA +WC_ASYNC_ENABLE_RSA_KEYGEN +WC_ASYNC_ENABLE_SHA +WC_ASYNC_ENABLE_SHA224 +WC_ASYNC_ENABLE_SHA256 +WC_ASYNC_ENABLE_SHA3 +WC_ASYNC_ENABLE_SHA384 +WC_ASYNC_ENABLE_SHA512 +WC_ASYNC_NO_CRYPT +WC_ASYNC_NO_HASH +WC_CACHE_RESISTANT_BASE64_TABLE +WC_DILITHIUM_CACHE_PRIV_VECTORS +WC_DILITHIUM_CACHE_PUB_VECTORS +WC_DILITHIUM_FIXED_ARRAY +WC_DISABLE_RADIX_ZERO_PAD +WC_ECC_NONBLOCK_ONLY +WC_KDF_NIST_SP_800_56C +WC_LMS_FULL_HASH +WC_NO_RNG_SIMPLE +WC_NO_STATIC_ASSERT +WC_PKCS11_FIND_WITH_ID_ONLY +WC_PROTECT_ENCRYPTED_MEM +WC_RNG_BLOCKING +WC_RSA_DIRECT +WC_RSA_NONBLOCK +WC_RSA_NONBLOCK_TIME +WC_RSA_NO_FERMAT_CHECK +WC_SHA384 +WC_SHA384_DIGEST_SIZE +WC_SHA512 +WC_SSIZE_TYPE +WC_STRICT_SIG +WC_WANT_FLAG_DONT_USE_AESNI +WC_XMSS_FULL_HASH +WIFI_AVAILABLE +WOLFCRYPT_FIPS_CORE_DYNAMIC_HASH_VALUE +WOLFSENTRY_H +WOLFSENTRY_NO_JSON +WOLFSSL_32BIT_MILLI_TIME +WOLFSSL_AARCH64_PRIVILEGE_MODE +WOLFSSL_AESNI_BY4 +WOLFSSL_AESNI_BY6 +WOLFSSL_AES_CTR_EXAMPLE +WOLFSSL_AFTER_DATE_CLOCK_SKEW +WOLFSSL_ALGO_HW_MUTEX +WOLFSSL_ALLOW_CRIT_AIA +WOLFSSL_ALLOW_CRIT_AKID +WOLFSSL_ALLOW_CRIT_SKID +WOLFSSL_ALLOW_ENCODING_CA_FALSE +WOLFSSL_ALLOW_MAX_FRAGMENT_ADJUST +WOLFSSL_ALLOW_NO_CN_IN_SAN +WOLFSSL_ALLOW_NO_SUITES +WOLFSSL_ALLOW_SERVER_SC_EXT +WOLFSSL_ALLOW_TLS_SHA1 +WOLFSSL_ALTERNATIVE_DOWNGRADE +WOLFSSL_ALT_NAMES_NO_REV +WOLFSSL_ARM_ARCH_NEON_64BIT +WOLFSSL_ASCON_UNROLL +WOLFSSL_ASNC_CRYPT +WOLFSSL_ASN_EXTRA +WOLFSSL_ASN_INT_LEAD_0_ANY +WOLFSSL_ASN_TEMPLATE_NEED_SET_INT32 +WOLFSSL_ASN_TEMPLATE_TYPE_CHECK +WOLFSSL_ATECC508 +WOLFSSL_ATECC508A_NOIDLE +WOLFSSL_ATECC508A_NOSOFTECC +WOLFSSL_ATECC508A_TLS +WOLFSSL_ATECC_ECDH_IOENC +WOLFSSL_ATECC_NO_ECDH_ENC +WOLFSSL_ATECC_RNG +WOLFSSL_ATECC_TFLXTLS +WOLFSSL_ATECC_TNGTLS +WOLFSSL_ATMEL +WOLFSSL_ATMEL_TIME +WOLFSSL_BEFORE_DATE_CLOCK_SKEW +WOLFSSL_BIGINT_TYPES +WOLFSSL_BIO_NO_FLOW_STATS +WOLFSSL_BLAKE2B_INIT_EACH_FIELD +WOLFSSL_BLAKE2S_INIT_EACH_FIELD +WOLFSSL_BLIND_PRIVATE_KEY +WOLFSSL_BYTESWAP32_ASM +WOLFSSL_CAAM_BLACK_KEY_AESCCM +WOLFSSL_CAAM_BLACK_KEY_SM +WOLFSSL_CAAM_NO_BLACK_KEY +WOLFSSL_CALLBACKS +WOLFSSL_CHECK_DESKEY +WOLFSSL_CHECK_MEM_ZERO +WOLFSSL_CHIBIOS +WOLFSSL_CLANG_TIDY +WOLFSSL_CLIENT_EXAMPLE +WOLFSSL_COMMERCIAL_LICENSE +WOLFSSL_CONTIKI +WOLFSSL_CRL_ALLOW_MISSING_CDP +WOLFSSL_CURVE25519_BLINDING +WOLFSSL_CUSTOM_CONFIG +WOLFSSL_DILITHIUM_ASSIGN_KEY +WOLFSSL_DILITHIUM_MAKE_KEY_SMALL_MEM +WOLFSSL_DILITHIUM_NO_ASN1 +WOLFSSL_DILITHIUM_NO_CHECK_KEY +WOLFSSL_DILITHIUM_NO_LARGE_CODE +WOLFSSL_DILITHIUM_NO_MAKE +WOLFSSL_DILITHIUM_REVERSE_HASH_OID +WOLFSSL_DILITHIUM_SIGN_CHECK_W0 +WOLFSSL_DILITHIUM_SIGN_CHECK_Y +WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC +WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A +WOLFSSL_DILITHIUM_SMALL_MEM_POLY64 +WOLFSSL_DILITHIUM_VERIFY_NO_MALLOC +WOLFSSL_DILITHIUM_VERIFY_SMALL_MEM +WOLFSSL_DISABLE_EARLY_SANITY_CHECKS +WOLFSSL_DTLS_DISALLOW_FUTURE +WOLFSSL_DTLS_RESEND_ONLY_TIMEOUT +WOLFSSL_DUMP_MEMIO_STREAM +WOLFSSL_DUP_CERTPOL +WOLFSSL_ECC_BLIND_K +WOLFSSL_ECC_GEN_REJECT_SAMPLING +WOLFSSL_ECC_NO_SMALL_STACK +WOLFSSL_ECC_SIGALG_PARAMS_NULL_ALLOWED +WOLFSSL_ECDHX_SHARED_NOT_ZERO +WOLFSSL_ECDSA_MATCH_HASH +WOLFSSL_ECDSA_SET_K_ONE_LOOP +WOLFSSL_EC_POINT_CMP_JACOBIAN +WOLFSSL_EDDSA_CHECK_PRIV_ON_SIGN +WOLFSSL_EMNET +WOLFSSL_ESPWROOM32 +WOLFSSL_EVP_PRINT +WOLFSSL_EXPORT_INT +WOLFSSL_EXPORT_SPC_SZ +WOLFSSL_EXTRA +WOLFSSL_FORCE_OCSP_NONCE_CHECK +WOLFSSL_FRDM_K64 +WOLFSSL_FRDM_K64_JENKINS +WOLFSSL_FUNC_TIME +WOLFSSL_FUNC_TIME_LOG +WOLFSSL_GEN_CERT +WOLFSSL_GETRANDOM +WOLFSSL_GNRC +WOLFSSL_HARDEN_TLS_ALLOW_ALL_CIPHERSUITES +WOLFSSL_HARDEN_TLS_ALLOW_OLD_TLS +WOLFSSL_HARDEN_TLS_ALLOW_TRUNCATED_HMAC +WOLFSSL_HARDEN_TLS_NO_PKEY_CHECK +WOLFSSL_HARDEN_TLS_NO_SCR_CHECK +WOLFSSL_HOSTNAME_VERIFY_ALT_NAME_ONLY +WOLFSSL_I2D_ECDSA_SIG_ALLOC +WOLFSSL_IAR_ARM_TIME +WOLFSSL_IGNORE_BAD_CERT_PATH +WOLFSSL_IMX6 +WOLFSSL_IMX6_CAAM +WOLFSSL_IMX6_CAAM_BLOB +WOLFSSL_IMX6_CAAM_RNG +WOLFSSL_IMXRT_DCP +WOLFSSL_ISOTP +WOLFSSL_KEIL +WOLFSSL_KEIL_NET +WOLFSSL_KYBER_NO_DECAPSULATE +WOLFSSL_KYBER_NO_ENCAPSULATE +WOLFSSL_KYBER_NO_MAKE_KEY +WOLFSSL_LIB +WOLFSSL_LMS_CACHE_BITS +WOLFSSL_LMS_FULL_HASH +WOLFSSL_LMS_LARGE_CACHES +WOLFSSL_LMS_MAX_HEIGHT +WOLFSSL_LMS_MAX_LEVELS +WOLFSSL_LMS_NO_SIG_CACHE +WOLFSSL_LMS_ROOT_LEVELS +WOLFSSL_LPC43xx +WOLFSSL_MAKE_SYSTEM_NAME_LINUX +WOLFSSL_MAKE_SYSTEM_NAME_WSL +WOLFSSL_MDK5 +WOLFSSL_MEM_FAIL_COUNT +WOLFSSL_MLKEM_ENCAPSULATE_SMALL_MEM +WOLFSSL_MLKEM_INVNTT_UNROLL +WOLFSSL_MLKEM_MAKEKEY_SMALL_MEM +WOLFSSL_MLKEM_NO_LARGE_CODE +WOLFSSL_MLKEM_NO_MALLOC +WOLFSSL_MLKEM_NTT_UNROLL +WOLFSSL_MONT_RED_CT +WOLFSSL_MP_COND_COPY +WOLFSSL_MP_INVMOD_CONSTANT_TIME +WOLFSSL_MULTICIRCULATE_ALTNAMELIST +WOLFSSL_NONBLOCK_OCSP +WOLFSSL_NOSHA3_384 +WOLFSSL_NOT_WINDOWS_API +WOLFSSL_NO_BIO_ADDR_IN +WOLFSSL_NO_CLIENT +WOLFSSL_NO_CLIENT_CERT_ERROR +WOLFSSL_NO_COPY_CERT +WOLFSSL_NO_COPY_KEY +WOLFSSL_NO_CRL_DATE_CHECK +WOLFSSL_NO_CRL_NEXT_DATE +WOLFSSL_NO_DECODE_EXTRA +WOLFSSL_NO_DER_TO_PEM +WOLFSSL_NO_DH186 +WOLFSSL_NO_DTLS_SIZE_CHECK +WOLFSSL_NO_ETM_ALERT +WOLFSSL_NO_FENCE +WOLFSSL_NO_FSEEK +WOLFSSL_NO_INIT_CTX_KEY +WOLFSSL_NO_ISSUERHASH_TDPEER +WOLFSSL_NO_KCAPI_AES_CBC +WOLFSSL_NO_KCAPI_HMAC_SHA1 +WOLFSSL_NO_KCAPI_HMAC_SHA224 +WOLFSSL_NO_KCAPI_HMAC_SHA256 +WOLFSSL_NO_KCAPI_HMAC_SHA384 +WOLFSSL_NO_KCAPI_HMAC_SHA512 +WOLFSSL_NO_KCAPI_SHA224 +WOLFSSL_NO_OCSP_DATE_CHECK +WOLFSSL_NO_OCSP_ISSUER_CHAIN_CHECK +WOLFSSL_NO_OCSP_OPTIONAL_CERTS +WOLFSSL_NO_PUBLIC_FFDHE +WOLFSSL_NO_RSA_KEY_CHECK +WOLFSSL_NO_SERVER_GROUPS_EXT +WOLFSSL_NO_SESSION_STATS +WOLFSSL_NO_SIGALG +WOLFSSL_NO_SOCKADDR_UN +WOLFSSL_NO_SPHINCS +WOLFSSL_NO_STRICT_CIPHER_SUITE +WOLFSSL_NO_TICKET_EXPIRE +WOLFSSL_NO_TRUSTED_CERTS_VERIFY +WOLFSSL_NO_XOR_OPS +WOLFSSL_NRF51_AES +WOLFSSL_OLDTLS_AEAD_CIPHERSUITES +WOLFSSL_OLDTLS_SHA2_CIPHERSUITES +WOLFSSL_OLD_SET_CURVES_LIST +WOLFSSL_OLD_TIMINGPADVERIFY +WOLFSSL_OLD_UNSUPPORTED_EXTENSION +WOLFSSL_OPTIONS_IGNORE_SYS +WOLFSSL_PASSTHRU_ERR +WOLFSSL_PB +WOLFSSL_PEER_ADDRESS_CHANGES +WOLFSSL_PKCS11_RW_TOKENS +WOLFSSL_PRCONNECT_PRO +WOLFSSL_PREFIX +WOLFSSL_PSA_NO_AES +WOLFSSL_PSA_NO_HASH +WOLFSSL_PSA_NO_PKCB +WOLFSSL_PSA_NO_PKCBS +WOLFSSL_PSA_NO_RNG +WOLFSSL_PSK_IDENTITY_ALERT +WOLFSSL_PSK_ID_PROTECTION +WOLFSSL_PSK_MULTI_ID_PER_CS +WOLFSSL_PSK_TLS13_CB +WOLFSSL_PSOC6_CRYPTO +WOLFSSL_PYTHON +WOLFSSL_RENESAS_FSPSM_CRYPT_ONLY +WOLFSSL_RENESAS_RA6M3 +WOLFSSL_RENESAS_RA6M3G +WOLFSSL_RENESAS_RSIP +WOLFSSL_RENESAS_RZN2L +WOLFSSL_RENESAS_TLS +WOLFSSL_RENESAS_TSIP_IAREWRX +WOLFSSL_RSA_CHECK_D_ON_DECRYPT +WOLFSSL_RSA_DECRYPT_TO_0_LEN +WOLFSSL_RW_THREADED +WOLFSSL_SAKKE_SMALL +WOLFSSL_SAKKE_SMALL_MODEXP +WOLFSSL_SE050_AUTO_ERASE +WOLFSSL_SE050_CRYPT +WOLFSSL_SE050_HASH +WOLFSSL_SE050_INIT +WOLFSSL_SE050_NO_RSA +WOLFSSL_SE050_NO_TRNG +WOLFSSL_SECURE_RENEGOTIATION_ON_BY_DEFAULT +WOLFSSL_SERVER_EXAMPLE +WOLFSSL_SETTINGS_FILE +WOLFSSL_SH224 +WOLFSSL_SHA256_ALT_CH_MAJ +WOLFSSL_SHUTDOWNONCE +WOLFSSL_SILABS_TRNG +WOLFSSL_SM4_EBC +WOLFSSL_SNIFFER_NO_RECOVERY +WOLFSSL_SP_ARM32_UDIV +WOLFSSL_SP_DH +WOLFSSL_SP_FAST_NCT_EXPTMOD +WOLFSSL_SP_INT_SQR_VOLATILE +WOLFSSL_STACK_CHECK +WOLFSSL_STM32F427_RNG +WOLFSSL_STM32_RNG_NOLIB +WOLFSSL_STRONGEST_HASH_SIG +WOLFSSL_STSAFE_TAKES_SLOT +WOLFSSL_TELIT_M2MB +WOLFSSL_TEMPLATE_EXAMPLE +WOLFSSL_THREADED_CRYPT +WOLFSSL_TICKET_DECRYPT_NO_CREATE +WOLFSSL_TICKET_ENC_AES128_GCM +WOLFSSL_TICKET_ENC_AES256_CBC +WOLFSSL_TICKET_ENC_AES256_GCM +WOLFSSL_TICKET_ENC_CBC_HMAC +WOLFSSL_TICKET_ENC_CHACHA20_POLY1305 +WOLFSSL_TICKET_ENC_HMAC_SHA384 +WOLFSSL_TICKET_ENC_HMAC_SHA512 +WOLFSSL_TI_CURRTIME +WOLFSSL_TLS13_DRAFT +WOLFSSL_TLS13_IGNORE_AEAD_LIMITS +WOLFSSL_TLS13_SHA512 +WOLFSSL_TLS13_TICKET_BEFORE_FINISHED +WOLFSSL_TLSX_PQC_MLKEM_STORE_PRIV_KEY +WOLFSSL_TRACK_MEMORY_FULL +WOLFSSL_TRAP_MALLOC_SZ +WOLFSSL_UNALIGNED_64BIT_ACCESS +WOLFSSL_USER_FILESYSTEM +WOLFSSL_USER_LOG +WOLFSSL_USER_MUTEX +WOLFSSL_USER_THREADING +WOLFSSL_USE_ESP32C3_CRYPT_HASH_HW +WOLFSSL_USE_FLASHMEM +WOLFSSL_USE_OPTIONS_H +WOLFSSL_USE_POPEN_HOST +WOLFSSL_VALIDATE_DH_KEYGEN +WOLFSSL_WC_XMSS_NO_SHA256 +WOLFSSL_WC_XMSS_NO_SHAKE256 +WOLFSSL_WICED_PSEUDO_UNIX_EPOCH_TIME +WOLFSSL_X509_STORE_CERTS +WOLFSSL_X509_TRUSTED_CERTIFICATE_CALLBACK +WOLFSSL_XFREE_NO_NULLNESS_CHECK +WOLFSSL_XILINX_CRYPTO_OLD +WOLFSSL_XILINX_PATCH +WOLFSSL_XIL_MSG_NO_SLEEP +WOLFSSL_XMSS_LARGE_SECRET_KEY +WOLFSSL_ZEPHYR +WOLF_ALLOW_BUILTIN +WOLF_CRYPTO_CB_CMD +WOLF_CRYPTO_CB_FIND +WOLF_CRYPTO_CB_ONLY_ECC +WOLF_CRYPTO_CB_ONLY_RSA +WOLF_CRYPTO_DEV +WOLF_NO_TRAILING_ENUM_COMMAS +XGETPASSWD +XMSS_CALL_PRF_KEYGEN +XPAR_VERSAL_CIPS_0_PSPMC_0_PSV_CORTEXA72_0_TIMESTAMP_CLK_FREQ +XSECURE_CACHE_DISABLE +_ABI64 +_ABIO64 +_ARCH_PPC64 +_COMPILER_VERSION +_INTPTR_T_DECLARED +_LP64 +_MSC_VER +_MSVC_LANG +_M_ARM64 +_M_X64 +_NETOS +_POSIX_C_SOURCE +_SDCC_VERSION_PATCHLEVEL +_SH3 +_SILICON_LABS_SECURITY_FEATURE +_SOCKLEN_T +_SYS_DEVCON_LOCAL_H +_TIME_HELPER_H +_UINTPTR_T_DECLARED +_WIN32 +_WIN32_WCE +_WIN64 +_XOPEN_SOURCE_EXTENDED +__32MZ2048ECH144__ +__32MZ2048ECM144__ +__32MZ2048EFM144__ +__ANDROID__ +__APPLE__ +__ARCH_STRCASECMP_NO_REDIRECT +__ARCH_STRCMP_NO_REDIRECT +__ARCH_STRNCASECMP_NO_REDIRECT +__ARCH_STRNCAT_NO_REDIRECT +__ARCH_STRNCMP_NO_REDIRECT +__ARCH_STRNCPY_NO_REDIRECT +__ARCH_STRSTR_NO_REDIRECT +__ARM_ARCH_7M__ +__ARM_FEATURE_CRYPTO +__ASSEMBLER__ +__ATOMIC_RELAXED +__AVR__ +__BCPLUSPLUS__ +__BIG_ENDIAN__ +__BORLANDC__ +__CCRX__ +__COMPILER_VER__ +__COUNTER__ +__CYGWIN__ +__DATE__ +__DCACHE_PRESENT +__DCC__ +__DECC_VER +__ELF__ +__EMSCRIPTEN__ +__FPU_PRESENT +__FreeBSD__ +__GLIBC__ +__GNUC_MINOR__ +__GNUC__ +__HP_cc +__IAR_SYSTEMS_ICC__ +__ICCARM__ +__ILP32__ +__INCLUDE_NUTTX_CONFIG_H +__INTEGRITY +__INTEL_COMPILER +__KEIL__ +__KEY_DATA_H__ +__LINUX__ +__LP64 +__LP64__ +__MACH__ +__MICROBLAZE__ +__MINGW32__ +__MINGW64_VERSION_MAJOR +__MINGW64__ +__MWERKS__ +__NT__ +__OS2__ +__OpenBSD__ +__PIE__ +__POWERPC__ +__PPC__ +__PPU +__QNXNTO__ +__QNX__ +__ROPI__ +__SAM3A4C__ +__SAM3A8C__ +__SAM3A8H__ +__SAM3X4C__ +__SAM3X4E__ +__SAM3X8C__ +__SAM3X8E__ +__SANITIZE_ADDRESS__ +__SDCC_VERSION_MAJOR +__SDCC_VERSION_MINOR +__SDCC_VERSION_PATCH +__SIZEOF_INT128__ +__SIZEOF_LONG_LONG__ +__STDC_VERSION__ +__STDC__ +__STM32__ +__STRICT_ANSI__ +__SUNPRO_C +__SUNPRO_CC +__SVR4 +__TI_COMPILER_VERSION__ +__TURBOC__ +__UNIX__ +__USE_GNU +__USE_MISC +__USE_XOPEN2K +__WATCOMC__ +__WATCOM_INT64__ +__XC32 +__XTENSA__ +__aarch64__ +__alpha__ +__arch64__ +__arm__ +__clang__ +__clang_major__ +__cplusplus +__ghc__ +__ghs__ +__hpux__ +__i386 +__i386__ +__ia64__ +__linux__ +__llvm__ +__mips +__mips64 +__must_check +__ppc64__ +__ppc__ +__riscv +__riscv_xlen +__s390x__ +__sparc +__sparc64__ +__sun +__svr4__ +__thumb__ +__ti__ +__x86_64__ +byte +configTICK_RATE_HZ +fallthrough +noinline +ssize_t +sun +versal +wc_Tls13_HKDF_Expand_Label diff --git a/CMakeLists.txt b/CMakeLists.txt index 58b7ccea1..cdfe1d256 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") You must delete them, or cmake will refuse to work.") endif() -project(wolfssl VERSION 5.7.2 LANGUAGES C ASM) +project(wolfssl VERSION 5.7.6 LANGUAGES C ASM) # Set WOLFSSL_ROOT if not already defined if ("${WOLFSSL_ROOT}" STREQUAL "") @@ -49,11 +49,11 @@ endif() # shared library versioning # increment if interfaces have been removed or changed -set(WOLFSSL_LIBRARY_VERSION_FIRST 42) +set(WOLFSSL_LIBRARY_VERSION_FIRST 43) # increment if interfaces have been added # set to zero if WOLFSSL_LIBRARY_VERSION_FIRST is incremented -set(WOLFSSL_LIBRARY_VERSION_SECOND 2) +set(WOLFSSL_LIBRARY_VERSION_SECOND 0) # increment if source code has changed # set to zero if WOLFSSL_LIBRARY_VERSION_FIRST is incremented or @@ -125,12 +125,16 @@ check_function_exists("socket" HAVE_SOCKET) check_function_exists("strftime" HAVE_STRFTIME) check_function_exists("__atomic_fetch_add" HAVE_C___ATOMIC) +include(CheckSymbolExists) +check_symbol_exists(isascii "ctype.h" HAVE_ISASCII) + include(CheckTypeSize) check_type_size("__uint128_t" __UINT128_T) check_type_size("long long" SIZEOF_LONG_LONG) check_type_size("long" SIZEOF_LONG) check_type_size("time_t" SIZEOF_TIME_T) +check_type_size("uintptr_t" HAVE_UINTPTR_T) # By default, HAVE___UINT128_T gets defined as TRUE, # but we want it as 1. @@ -152,9 +156,14 @@ endif() # Thread local storage include(CheckCSourceCompiles) -set(TLS_KEYWORDS "__thread" "__declspec(thread)") -foreach(TLS_KEYWORD IN LISTS TLS_KEYWORDS) - set(TLS_CODE "#include +if(CMAKE_C_COMPILER_ID STREQUAL "OpenWatcom") + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_THREAD_LS") + endif() +else() + set(TLS_KEYWORDS "__thread" "__declspec(thread)") + foreach(TLS_KEYWORD IN LISTS TLS_KEYWORDS) + set(TLS_CODE "#include static void foo(void) { static ${TLS_KEYWORD} int bar\; exit(1)\; @@ -163,21 +172,22 @@ foreach(TLS_KEYWORD IN LISTS TLS_KEYWORDS) int main() { return 0\; }" - ) - check_c_source_compiles(${TLS_CODE} THREAD_LS_ON) + ) + check_c_source_compiles(${TLS_CODE} THREAD_LS_ON) - if(THREAD_LS_ON) - list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_THREAD_LS") - break() - else() - # THREAD_LS_ON is cached after each call to - # check_c_source_compiles, and the function - # won't run subsequent times if the variable - # is in the cache. To make it run again, we - # need to remove the variable from the cache. - unset(THREAD_LS_ON CACHE) - endif() -endforeach() + if(THREAD_LS_ON) + list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_THREAD_LS") + break() + else() + # THREAD_LS_ON is cached after each call to + # check_c_source_compiles, and the function + # won't run subsequent times if the variable + # is in the cache. To make it run again, we + # need to remove the variable from the cache. + unset(THREAD_LS_ON CACHE) + endif() + endforeach() +endif() # TODO: AX_PTHREAD does a lot. Need to implement the # rest of its logic. @@ -197,13 +207,20 @@ find_package(Threads) # Example for map file and custom linker script #set(CMAKE_EXE_LINKER_FLAGS " -Xlinker -Map=output.map -T\"${CMAKE_CURRENT_SOURCE_DIR}/linker.ld\"") +message(STATUS "C Compiler ID: ${CMAKE_C_COMPILER_ID}") + if(DEFINED WARNING_C_FLAGS) -set(CMAKE_C_FLAGS "${WARNING_C_FLAGS} ${CMAKE_C_FLAGS}") + set(CMAKE_C_FLAGS "${WARNING_C_FLAGS} ${CMAKE_C_FLAGS}") +endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "OpenWatcom") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -wx -wcd=202") + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_HAVE_MIN -DWOLFSSL_HAVE_MAX -DNO_WRITEV") elseif(WIN32) -# Windows cl.exe does not support the -Wextra, -Wno-unused and -Werror flags. -set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}") + # Windows cl.exe does not support the -Wextra, -Wno-unused and -Werror flags. + set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}") else() -set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused -Werror ${CMAKE_C_FLAGS}") + set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused -Werror ${CMAKE_C_FLAGS}") endif() #################################################### @@ -280,9 +297,7 @@ if(NOT WOLFSSL_SINGLE_THREADED) if(CMAKE_USE_PTHREADS_INIT) list(APPEND WOLFSSL_LINK_LIBS Threads::Threads) set(HAVE_PTHREAD 1) - list(APPEND WOLFSSL_DEFINITIONS - "-DHAVE_PTHREAD" - "-D_POSIX_THREADS") + list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_PTHREAD") endif() else() list(APPEND WOLFSSL_DEFINITIONS "-DSINGLE_THREADED") @@ -419,16 +434,17 @@ if(WOLFSSL_CURL) set(WOLFSSL_MD4 "yes") set(WOLFSSL_DES3 "yes") set(WOLFSSL_ALPN "yes") + set(WOLFSSL_WOLFSSH "yes") set(WOLFSSL_OPENSSLEXTRA "yes") set(WOLFSSL_CRL "yes") set(WOLFSSL_OCSP "yes") set(WOLFSSL_OCSPSTAPLING "yes") set(WOLFSSL_OCSPSTAPLING_V2 "yes") + # Note: OCSP sets requisite HAVE_TLS_EXTENSIONS and HAVE_CERTIFICATE_STATUS_REQUEST(_V2) set(WOLFSSL_SNI "yes") set(WOLFSSL_ALT_CERT_CHAINS "yes") set(WOLFSSL_IP_ALT_NAME "yes") set(WOLFSSL_SESSION_TICKET "yes") - set(WOLFSSL_WOLFSSH "yes") list(APPEND WOLFSSL_DEFINITIONS "-DNO_SESSION_CACHE_REF" "-DWOLFSSL_DES_ECB") endif() @@ -556,9 +572,9 @@ add_option(WOLFSSL_OQS "Enable integration with the OQS (Open Quantum Safe) liboqs library (default: disabled)" "no" "yes;no") -# Kyber -add_option(WOLFSSL_KYBER - "Enable the wolfSSL PQ Kyber library (default: disabled)" +# ML-KEM/Kyber +add_option(WOLFSSL_MMLKEM + "Enable the wolfSSL PQ ML-KEM library (default: disabled)" "no" "yes;no") # Experimental features @@ -607,8 +623,8 @@ if (WOLFSSL_EXPERIMENTAL) set(WOLFSSL_FOUND_EXPERIMENTAL_FEATURE 1) message(STATUS "Automatically set related requirements for Kyber:") - set_wolfssl_definitions("WOLFSSL_HAVE_KYBER" RESUlT) - set_wolfssl_definitions("WOLFSSL_WC_KYBER" RESUlT) + set_wolfssl_definitions("WOLFSSL_HAVE_MLKEM" RESUlT) + set_wolfssl_definitions("WOLFSSL_WC_MLKEM" RESUlT) set_wolfssl_definitions("WOLFSSL_SHA3" RESUlT) set_wolfssl_definitions("WOLFSSL_SHAKE128" RESUlT) set_wolfssl_definitions("WOLFSSL_SHAKE256" RESUlT) @@ -642,6 +658,16 @@ else() endif() endif() +# LMS +add_option(WOLFSSL_LMS + "Enable the wolfSSL LMS implementation (default: disabled)" + "no" "yes;no") + +# XMSS +add_option(WOLFSSL_XMSS + "Enable the wolfSSL XMSS implementation (default: disabled)" + "no" "yes;no") + # TODO: - Lean PSK # - Lean TLS # - Low resource @@ -655,8 +681,6 @@ endif() # - Atomic user record layer # - Public key callbacks # - Microchip/Atmel CryptoAuthLib -# - XMSS -# - LMS # - dual-certs # AES-CBC @@ -731,7 +755,8 @@ add_option("WOLFSSL_AESCTR" if(WOLFSSL_OPENVPN OR WOLFSSL_LIBSSH2 OR - WOLFSSL_AESSIV) + WOLFSSL_AESSIV OR + WOLFSSL_CLU) override_cache(WOLFSSL_AESCTR "yes") endif() @@ -871,7 +896,7 @@ endif() # - SEP add_option("WOLFSSL_KEYGEN" - "Enable key generation (default: disabled)])" + "Enable key generation (default: disabled)" "no" "yes;no") add_option("WOLFSSL_CERTGEN" @@ -945,13 +970,29 @@ if(WOLFSSL_ECC) endif() endif() -# TODO: - ECC custom curves -# - Compressed key +# TODO: - Compressed key # - FP ECC, fixed point cache ECC # - ECC encrypt # - PSK # - Single PSK identity +# ECC custom curves +add_option("WOLFSSL_ECCCUSTCURVES" + "Enable ECC Custom Curves (default: disabled)" + "no" "yes;no;all") + +if(WOLFSSL_ECCCUSTCURVES) + if("${WOLFSSL_ECCCUSTCURVES}" STREQUAL "all") + list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ECC_SECPR2") + list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ECC_SECPR3") + list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ECC_BRAINPOOL") + list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ECC_KOBLITZ") + list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ECC_CDH") + endif() + + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_CUSTOM_CURVES") +endif() + # CURVE25519 set(WOLFSSL_CURVE25519_SMALL "no") add_option("WOLFSSL_CURVE25519" @@ -982,7 +1023,7 @@ add_option("WOLFSSL_ED25519" "Enable ED25519 (default: disabled)" "no" "yes;no") -if(WOLFSSL_OPENSSH) +if(WOLFSSL_OPENSSH OR WOLFSSL_CLU) override_cache(WOLFSSL_ED25519 "yes") endif() @@ -1112,8 +1153,7 @@ if(NOT WOLFSSL_MEMORY) else() # turn off memory cb if leanpsk or leantls on if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS) - # but don't turn on NO_WOLFSSL_MEMORY because using own - override_cache(WOLFSSL_MEMORY "no") + list(APPEND WOLFSSL_DEFINITIONS "-DNO_WOLFSSL_MEMORY") endif() endif() @@ -1658,6 +1698,9 @@ add_option(WOLFSSL_PKCS7 ${WOLFSSL_PKCS7_HELP_STRING} "no" "yes;no") set(WOLFSSL_TPM_HELP_STRING "Enable wolfTPM options (default: disabled)") add_option(WOLFSSL_TPM ${WOLFSSL_TPM_HELP_STRING} "no" "yes;no") +set(WOLFSSL_CLU_HELP_STRING "Enable wolfCLU options (default: disabled)") +add_option(WOLFSSL_CLU ${WOLFSSL_CLU_HELP_STRING} "no" "yes;no") + set(WOLFSSL_AESKEYWRAP_HELP_STRING "Enable AES key wrap support (default: disabled)") add_option(WOLFSSL_AESKEYWRAP ${WOLFSSL_AESKEYWRAP_HELP_STRING} "no" "yes;no") @@ -2002,6 +2045,25 @@ if(WOLFSSL_TPM) override_cache(WOLFSSL_AESCFB "yes") endif() +if(WOLFSSL_CLU) + override_cache(WOLFSSL_CERTGEN "yes") + override_cache(WOLFSSL_CERTREQ "yes") + override_cache(WOLFSSL_CERTEXT "yes") + override_cache(WOLFSSL_MD5 "yes") + override_cache(WOLFSSL_AESCTR "yes") + override_cache(WOLFSSL_KEYGEN "yes") + override_cache(WOLFSSL_OPENSSLALL "yes") + override_cache(WOLFSSL_ED25519 "yes") + override_cache(WOLFSSL_SHA512 "yes") + override_cache(WOLFSSL_DES3 "yes") + override_cache(WOLFSSL_PKCS7 "yes") + list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_OID_ENCODING" "-DWOLFSSL_NO_ASN_STRICT" "-DWOLFSSL_ALT_NAMES") + # Add OPENSSL_ALL definition to ensure OpenSSL compatibility functions are available + list(APPEND WOLFSSL_DEFINITIONS "-DOPENSSL_ALL") + # Remove NO_DES3 from WOLFSSL_DEFINITIONS to ensure DES3 is enabled + list(REMOVE_ITEM WOLFSSL_DEFINITIONS "-DNO_DES3") +endif() + if(WOLFSSL_AESCFB) list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_AES_CFB") endif() @@ -2261,6 +2323,18 @@ if (ENABLE_SCCACHE AND (NOT WOLFSSL_SCCACHE_ALREADY_SET_FLAG)) endif() endif() +add_option("WOLFSSL_KEYLOG_EXPORT" + "Enable insecure export of TLS secrets to an NSS keylog file (default: disabled)" + "no" "yes;no") +if(WOLFSSL_KEYLOG_EXPORT) + message(WARNING "Keylog export enabled -- Sensitive key data will be stored insecurely.") + list(APPEND WOLFSSL_DEFINITIONS + "-DSHOW_SECRETS" + "-DHAVE_SECRET_CALLBACK" + "-DWOLFSSL_SSLKEYLOGFILE" + "-DWOLFSSL_KEYLOG_EXPORT_WARNED") +endif() + file(REMOVE ${OPTION_FILE}) @@ -2391,17 +2465,24 @@ target_include_directories(wolfssl target_link_libraries(wolfssl PUBLIC ${WOLFSSL_LINK_LIBS}) -if(WIN32) - # For Windows link ws2_32 +if(CMAKE_C_COMPILER_ID STREQUAL "OpenWatcom") + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + target_link_libraries(wolfssl PUBLIC ws2_32 crypt32) + endif() +elseif (WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "^MSYS" OR ${CMAKE_SYSTEM_NAME} MATCHES "^MINGW") + # For Windows link required libraries + message("Building on Windows/MSYS/MINGW") target_link_libraries(wolfssl PUBLIC - $<$:ws2_32 crypt32>) + ws2_32 crypt32 advapi32) elseif(APPLE) + message("Building on Apple") if(WOLFSSL_SYS_CA_CERTS) target_link_libraries(wolfssl PUBLIC ${CORE_FOUNDATION_FRAMEWORK} ${SECURITY_FRAMEWORK}) endif() else() + message("Building on Linux (or other)") if(WOLFSSL_DH AND NOT WOLFSSL_DH_CONST) # DH requires math (m) library target_link_libraries(wolfssl @@ -2458,7 +2539,9 @@ if(WOLFSSL_EXAMPLES) add_executable(tls_bench ${CMAKE_CURRENT_SOURCE_DIR}/examples/benchmark/tls_bench.c) target_link_libraries(tls_bench wolfssl) - target_link_libraries(tls_bench Threads::Threads) + if(CMAKE_USE_PTHREADS_INIT) + target_link_libraries(tls_bench Threads::Threads) + endif() set_property(TARGET tls_bench PROPERTY RUNTIME_OUTPUT_DIRECTORY ${WOLFSSL_OUTPUT_BASE}/examples/benchmark) @@ -2467,19 +2550,65 @@ if(WOLFSSL_EXAMPLES) # Build unit tests add_executable(unit_test tests/api.c - tests/hash.c + tests/api/test_md2.c + tests/api/test_md4.c + tests/api/test_md5.c + tests/api/test_sha.c + tests/api/test_sha256.c + tests/api/test_sha512.c + tests/api/test_sha3.c + tests/api/test_blake2.c + tests/api/test_sm3.c + tests/api/test_ripemd.c + tests/api/test_hash.c + tests/api/test_hmac.c + tests/api/test_cmac.c + tests/api/test_des3.c + tests/api/test_chacha.c + tests/api/test_poly1305.c + tests/api/test_chacha20_poly1305.c + tests/api/test_camellia.c + tests/api/test_arc4.c + tests/api/test_rc2.c + tests/api/test_aes.c + tests/api/test_ascon.c + tests/api/test_sm4.c + tests/api/test_wc_encrypt.c + tests/api/test_random.c + tests/api/test_wolfmath.c + tests/api/test_rsa.c + tests/api/test_dsa.c + tests/api/test_dh.c + tests/api/test_ecc.c + tests/api/test_sm2.c + tests/api/test_curve25519.c + tests/api/test_ed25519.c + tests/api/test_curve448.c + tests/api/test_ed448.c + tests/api/test_mlkem.c + tests/api/test_mldsa.c + tests/api/test_signature.c + tests/api/test_dtls.c + tests/api/test_ocsp.c + tests/api/test_evp.c + tests/api/test_tls_ext.c tests/srp.c tests/suites.c tests/w64wrapper.c tests/unit.c tests/quic.c + tests/utils.c + testsuite/utils.c examples/server/server.c - examples/client/client.c) + examples/client/client.c + wolfcrypt/test/test.c) target_include_directories(unit_test PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_compile_options(unit_test PUBLIC "-DNO_MAIN_DRIVER") target_link_libraries(unit_test wolfssl) - target_link_libraries(unit_test Threads::Threads) + if(CMAKE_USE_PTHREADS_INIT) + target_link_libraries(unit_test Threads::Threads) + endif() set_property(TARGET unit_test PROPERTY RUNTIME_OUTPUT_DIRECTORY ${WOLFSSL_OUTPUT_BASE}/tests/) @@ -2729,14 +2858,17 @@ if(WOLFSSL_INSTALL) set(includedir "\${prefix}/include") set(VERSION ${PROJECT_VERSION}) - # Setting libm in Libs.private of wolfssl.pc. - # See "Link Libraries" in above about `m` insertion to LINK_LIBRARIES - get_target_property(_wolfssl_dep_libs wolfssl LINK_LIBRARIES) - list(FIND _wolfssl_dep_libs m _dep_libm) - if ("${_dep_libm}" GREATER -1) - set(LIBM -lm) + if(CMAKE_C_COMPILER_ID STREQUAL "OpenWatcom") else() - set(LIBM) + # Setting libm in Libs.private of wolfssl.pc. + # See "Link Libraries" in above about `m` insertion to LINK_LIBRARIES + get_target_property(_wolfssl_dep_libs wolfssl LINK_LIBRARIES) + list(FIND _wolfssl_dep_libs m _dep_libm) + if ("${_dep_libm}" GREATER -1) + set(LIBM -lm) + else() + set(LIBM) + endif() endif() configure_file(support/wolfssl.pc.in ${CMAKE_CURRENT_BINARY_DIR}/support/wolfssl.pc @ONLY) diff --git a/ChangeLog.md b/ChangeLog.md index 0939a6594..0b32346c6 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,322 @@ +# wolfSSL Release 5.7.6 (Dec 31, 2024) + +Release 5.7.6 has been developed according to wolfSSL's development and QA +process (see link below) and successfully passed the quality criteria. +https://www.wolfssl.com/about/wolfssl-software-development-process-quality-assurance + +NOTE: + * --enable-heapmath is deprecated. + * In this release, the default cipher suite preference is updated to prioritize + TLS_AES_256_GCM_SHA384 over TLS_AES_128_GCM_SHA256 when enabled. + * This release adds a sanity check for including wolfssl/options.h or + user_settings.h. + + +PR stands for Pull Request, and PR references a GitHub pull request + number where the code change was added. + + +## Vulnerabilities +* [Med] An OCSP (non stapling) issue was introduced in wolfSSL version 5.7.4 + when performing OCSP requests for intermediate certificates in a certificate + chain. This affects only TLS 1.3 connections on the server side. It would not + impact other TLS protocol versions or connections that are not using the + traditional OCSP implementation. (Fix in pull request 8115) + + +## New Feature Additions +* Add support for RP2350 and improve RP2040 support, both with RNG optimizations + (PR 8153) +* Add support for STM32MP135F, including STM32CubeIDE support and HAL support + for SHA2/SHA3/AES/RNG/ECC optimizations. (PR 8223, 8231, 8241) +* Implement Renesas TSIP RSA Public Enc/Private support (PR 8122) +* Add support for Fedora/RedHat system-wide crypto-policies (PR 8205) +* Curve25519 generic keyparsing API added with wc_Curve25519KeyToDer and + wc_Curve25519KeyDecode (PR 8129) +* CRL improvements and update callback, added the functions + wolfSSL_CertManagerGetCRLInfo and wolfSSL_CertManagerSetCRLUpdate_Cb (PR 8006) +* For DTLS, add server-side stateless and CID quality-of-life API. (PR 8224) + + +## Enhancements and Optimizations +* Add a CMake dependency check for pthreads when required. (PR 8162) +* Update OS_Seed declarations for legacy compilers and FIPS modules (boundary + not affected). (PR 8170) +* Enable WOLFSSL_ALWAYS_KEEP_SNI by default when using --enable-jni. (PR 8283) +* Change the default cipher suite preference, prioritizing + TLS_AES_256_GCM_SHA384 over TLS_AES_128_GCM_SHA256. (PR 7771) +* Add SRTP-KDF (FIPS module v6.0.0) to checkout script for release bundling + (PR 8215) +* Make library build when no hardware crypto available for Aarch64 (PR 8293) +* Update assembly code to avoid `uint*_t` types for better compatibility with + older C standards. (PR 8133) +* Add initial documentation for writing ASN template code to decode BER/DER. + (PR 8120) +* Perform full reduction in sc_muladd for EdDSA with Curve448 (PR 8276) +* Allow SHA-3 hardware cryptography instructions to be explicitly not used in + MacOS builds (PR 8282) +* Make Kyber and ML-KEM available individually and together. (PR 8143) +* Update configuration options to include Kyber/ML-KEM and fix defines used in + wolfSSL_get_curve_name. (PR 8183) +* Make GetShortInt available with WOLFSSL_ASN_EXTRA (PR 8149) +* Improved test coverage and minor improvements of X509 (PR 8176) +* Add sanity checks for configuration methods, ensuring the inclusion of + wolfssl/options.h or user_settings.h. (PR 8262) +* Enable support for building without TLS (NO_TLS). Provides reduced code size + option for non-TLS users who want features like the certificate manager or + compatibility layer. (PR 8273) +* Exposed get_verify functions with OPENSSL_EXTRA. (PR 8258) +* ML-DSA/Dilithium: obtain security level from DER when decoding (PR 8177) +* Implementation for using PKCS11 to retrieve certificate for SSL CTX (PR 8267) +* Add support for the RFC822 Mailbox attribute (PR 8280) +* Initialize variables and adjust types resolve warnings with Visual Studio in + Windows builds. (PR 8181) +* Refactors and expansion of opensslcoexist build (PR 8132, 8216, 8230) +* Add DTLS 1.3 interoperability, libspdm and DTLS CID interoperability tests + (PR 8261, 8255, 8245) +* Remove trailing error exit code in wolfSSL install setup script (PR 8189) +* Update Arduino files for wolfssl 5.7.4 (PR 8219) +* Improve Espressif SHA HW/SW mutex messages (PR 8225) +* Apply post-5.7.4 release updates for Espressif Managed Component examples + (PR 8251) +* Expansion of c89 conformance (PR 8164) +* Added configure option for additional sanity checks with --enable-faultharden + (PR 8289) +* Aarch64 ASM additions to check CPU features before hardware crypto instruction + use (PR 8314) + + +## Fixes +* Fix a memory issue when using the compatibility layer with + WOLFSSL_GENERAL_NAME and handling registered ID types. (PR 8155) +* Fix a build issue with signature fault hardening when using public key + callbacks (HAVE_PK_CALLBACKS). (PR 8287) +* Fix for handling heap hint pointer properly when managing multiple WOLFSSL_CTX + objects and free’ing one of them (PR 8180) +* Fix potential memory leak in error case with Aria. (PR 8268) +* Fix Set_Verify flag behaviour on Ada wrapper. (PR 8256) +* Fix a compilation error with the NO_WOLFSSL_DIR flag. (PR 8294) +* Resolve a corner case for Poly1305 assembly code on Aarch64. (PR 8275) +* Fix incorrect version setting in CSRs. (PR 8136) +* Correct debugging output for cryptodev. (PR 8202) +* Fix for benchmark application use with /dev/crypto GMAC auth error due to size + of AAD (PR 8210) +* Add missing checks for the initialization of sp_int/mp_int with DSA to free + memory properly in error cases. (PR 8209) +* Fix return value of wolfSSL_CTX_set_tlsext_use_srtp (8252) +* Check Root CA by Renesas TSIP before adding it to ca-table (PR 8101) +* Prevent adding a certificate to the CA cache for Renesas builds if it does not + set CA:TRUE in basic constraints. (PR 8060) +* Fix attribute certificate holder entityName parsing. (PR 8166) +* Resolve build issues for configurations without any wolfSSL/openssl + compatibility layer headers. (PR 8182) +* Fix for building SP RSA small and RSA public only (PR 8235) +* Fix for Renesas RX TSIP RSA Sign/Verify with wolfCrypt only (PR 8206) +* Fix to ensure all files have settings.h included (like wc_lms.c) and guards + for building all `*.c` files (PR 8257 and PR 8140) +* Fix x86 target build issues in Visual Studio for non-Windows operating + systems. (PR 8098) +* Fix wolfSSL_X509_STORE_get0_objects to handle no CA (PR 8226) +* Properly handle reference counting when adding to the X509 store. (PR 8233) +* Fix for various typos and improper size used with FreeRTOS_bind in the Renesas + example. Thanks to Hongbo for the report on example issues. (PR 7537) +* Fix for potential heap use after free with wolfSSL_PEM_read_bio_PrivateKey. + Thanks to Peter for the issue reported. (PR 8139) + + +# wolfSSL Release 5.7.4 (Oct 24, 2024) + +Release 5.7.4 has been developed according to wolfSSL's development and QA +process (see link below) and successfully passed the quality criteria. +https://www.wolfssl.com/about/wolfssl-software-development-process-quality-assurance + +NOTE: * --enable-heapmath is being deprecated and will be removed by end of 2024 + +PR stands for Pull Request, and PR references a GitHub pull request + number where the code change was added. + + +## Vulnerabilities +* [Low] When the OpenSSL compatibility layer is enabled, certificate + verification behaved differently in wolfSSL than OpenSSL, in the + X509_STORE_add_cert() and X509_STORE_load_locations() implementations. + Previously, in cases where an application explicitly loaded an intermediate + certificate, wolfSSL was verifying only up to that intermediate certificate, + rather than verifying up to the root CA. This only affects use cases where the + API is called directly, and does not affect TLS connections. Users that call + the API X509_STORE_add_cert() or X509_STORE_load_locations() directly in their + applications are recommended to update the version of wolfSSL used or to have + additional sanity checks on certificates loaded into the X509_STORE when + verifying a certificate. (https://github.com/wolfSSL/wolfssl/pull/8087) + + +## PQC TLS Experimental Build Fix +* When using TLS with post quantum algorithms enabled, the connection uses a + smaller EC curve than agreed on. Users building with --enable-experimental and + enabling PQC cipher suites with TLS connections are recommended to update the + version of wolfSSL used. Thanks to Daniel Correa for the report. + (https://github.com/wolfSSL/wolfssl/pull/8084) + + +## New Feature Additions +* RISC-V 64 new assembly optimizations added for SHA-256, SHA-512, ChaCha20, + Poly1305, and SHA-3 (PR 7758,7833,7818,7873,7916) +* Implement support for Connection ID (CID) with DTLS 1.2 (PR 7995) +* Add support for (DevkitPro)libnds (PR 7990) +* Add port for Mosquitto OSP (Open Source Project) (PR 6460) +* Add port for init sssd (PR 7781) +* Add port for eXosip2 (PR 7648) +* Add support for STM32G4 (PR 7997) +* Add support for MAX32665 and MAX32666 TPU HW and ARM ASM Crypto Callback + Support (PR 7777) +* Add support for building wolfSSL to be used in libspdm (PR 7869) +* Add port for use with Nucleus Plus 2.3 (PR 7732) +* Initial support for RFC5755 x509 attribute certificates (acerts). Enabled with + --enable-acert (PR 7926) +* PKCS#11 RSA Padding offload allows tokens to perform CKM_RSA_PKCS + (sign/encrypt), CKM_RSA_PKCS_PSS (sign), and CKM_RSA_PKCS_OAEP (encrypt). + (PR 7750) +* Added “new” and “delete” style functions for heap/pool allocation and freeing + of low level crypto structures (PR 3166 and 8089) + + +## Enhancements and Optimizations +* Increase default max alt. names from 128 to 1024 (PR 7762) +* Added new constant time DH agree function wc_DhAgree_ct (PR 7802) +* Expanded compatibility layer with the API EVP_PKEY_is_a (PR 7804) +* Add option to disable cryptocb test software test using + --disable-cryptocb-sw-test (PR 7862) +* Add a call to certificate verify callback before checking certificate dates + (PR 7895) +* Expanded algorithms supported with the wolfCrypt CSharp wrapper. Adding + support for RNG, ECC(ECIES and ECDHE), RSA, ED25519/Curve25519, AES-GCM, and + Hashing (PR 3166) +* Expand MMCAU support for use with DES ECB (PR 7960) +* Update AES SIV to handle multiple associated data inputs (PR 7911) +* Remove HAVE_NULL_CIPHER from --enable-openssh (PR 7811) +* Removed duplicate if(NULL) checks when calling XFREE (macro does) (PR 7839) +* Set RSA_MIN_SIZE default to 2048 bits (PR 7923) +* Added support for wolfSSL to be used as the default TLS in the zephyr kernel + (PR 7731) +* Add enable provider build using --enable-wolfprovider with autotools (PR 7550) +* Renesas RX TSIP ECDSA support (PR 7685) +* Support DTLS1.3 downgrade when the server supports CID (PR 7841) +* Server-side checks OCSP even if it uses v2 multi (PR 7828) +* Add handling of absent hash params in PKCS7 bundle parsing and creation + (PR 7845) +* Add the use of w64wrapper for Poly1305, enabling Poly1305 to be used in + environments that do not have a word64 type (PR 7759) +* Update to the maxq10xx support (PR 7824) +* Add support for parsing over optional PKCS8 attributes (PR 7944) +* Add support for either side method with DTLS 1.3 (PR 8012) +* Added PKCS7 PEM support for parsing PEM data with BEGIN/END PKCS7 (PR 7704) +* Add CMake support for WOLFSSL_CUSTOM_CURVES (PR 7962) +* Add left-most wildcard matching support to X509_check_host() (PR 7966) +* Add option to set custom SKID with PKCS7 bundle creation (PR 7954) +* Building wolfSSL as a library with Ada and corrections to Alire manifest + (PR 7303,7940) +* Renesas RX72N support updated (PR 7849) +* New option WOLFSSL_COPY_KEY added to always copy the key to the SSL object + (PR 8005) +* Add the new option WOLFSSL_COPY_CERT to always copy the cert buffer for each + SSL object (PR 7867) +* Add an option to use AES-CBC with HMAC for default session ticket enc/dec. + Defaults to AES-128-CBC with HMAC-SHA256 (PR 7703) +* Memory usage improvements in wc_PRF, sha256 (for small code when many + registers are available) and sp_int objects (PR 7901) +* Change in the configure script to work around ">>" with no command. In older + /bin/sh it can be ambiguous, as used in OS’s such as FreeBSD 9.2 (PR 7876) +* Don't attempt to include system headers when not required (PR 7813) +* Certificates: DER encoding of ECC signature algorithm parameter is now + allowed to be NULL with a define (PR 7903) +* SP x86_64 asm: check for AVX2 support for VMs (PR 7979) +* Update rx64n support on gr-rose (PR 7889) +* Update FSP version to v5.4.0 for RA6M4 (PR 7994) +* Update TSIP driver version to v1.21 for RX65N RSK (PR 7993) +* Add a new crypto callback for RSA with padding (PR 7907) +* Replaced the use of pqm4 with wolfSSL implementations of Kyber/MLDSA + (PR 7924) +* Modernized memory fence support for C11 and clang (PR 7938) +* Add a CRL error override callback (PR 7986) +* Extend the X509 unknown extension callback for use with a user context + (PR 7730) +* Additional debug error tracing added with TLS (PR 7917) +* Added runtime support for library call stack traces with + –enable-debug-trace-errcodes=backtrace, using libbacktrace (PR 7846) +* Expanded C89 conformance (PR 8077) +* Expanded support for WOLFSSL_NO_MALLOC (PR 8065) +* Added support for cross-compilation of Linux kernel module (PR 7746) +* Updated Linux kernel module with support for kernel 6.11 and 6.12 (PR 7826) +* Introduce WOLFSSL_ASN_ALLOW_0_SERIAL to allow parsing of certificates with a + serial number of 0 (PR 7893) +* Add conditional repository_owner to all wolfSSL GitHub workflows (PR 7871) + +### Espressif / Arduino Updates +* Update wolfcrypt settings.h for Espressif ESP-IDF, template update (PR 7953) +* Update Espressif sha, util, mem, time helpers (PR 7955) +* Espressif _thread_local_start and _thread_local_end fix (PR 8030) +* Improve benchmark for Espressif devices (PR 8037) +* Introduce Espressif common CONFIG_WOLFSSL_EXAMPLE_NAME, Kconfig (PR 7866) +* Add wolfSSL esp-tls and Certificate Bundle Support for Espressif ESP-IDF + (PR 7936) +* Update wolfssl Release for Arduino (PR 7775) + +### Post Quantum Crypto Updates +* Dilithium: support fixed size arrays in dilithium_key (PR 7727) +* Dilithium: add option to use precalc with small sign (PR 7744) +* Allow Kyber to be built with FIPS (PR 7788) +* Allow Kyber asm to be used in the Linux kernel module (PR 7872) +* Dilithium, Kyber: Update to final specification (PR 7877) +* Dilithium: Support FIPS 204 Draft and Final Draft (PR 7909,8016) + +### ARM Assembly Optimizations +* ARM32 assembly optimizations added for ChaCha20 and Poly1305 (PR 8020) +* Poly1305 assembly optimizations improvements for Aarch64 (PR 7859) +* Poly1305 assembly optimizations added for Thumb-2 (PR 7939) +* Adding ARM ASM build option to STM32CubePack (PR 7747) +* Add ARM64 to Visual Studio Project (PR 8010) +* Kyber assembly optimizations for ARM32 and Aarch64 (PR 8040,7998) +* Kyber assembly optimizations for ARMv7E-M/ARMv7-M (PR 7706) + + +## Fixes +* ECC key load: fixes for certificates with parameters that are not default for + size (PR 7751) +* Fixes for building x86 in Visual Studio for non-windows OS (PR 7884) +* Fix for TLS v1.2 secret callback, incorrectly detecting bad master secret + (PR 7812) +* Fixes for PowerPC assembly use with Darwin and SP math all (PR 7931) +* Fix for detecting older versions of Mac OS when trying to link with + libdispatch (PR 7932) +* Fix for DTLS1.3 downgrade to DTLS1.2 when the server sends multiple handshake + packets combined into a single transmission. (PR 7840) +* Fix for OCSP to save the request if it was stored in ssl->ctx->certOcspRequest + (PR 7779) +* Fix to OCSP for searching for CA by key hash instead of ext. key id (PR 7934) +* Fix for staticmemory and singlethreaded build (PR 7737) +* Fix to not allow Shake128/256 with Xilinx AFALG (PR 7708) +* Fix to support PKCS11 without RSA key generation (PR 7738) +* Fix not calling the signing callback when using PK callbacks + TLS 1.3 + (PR 7761) +* Cortex-M/Thumb2 ASM fix label for IAR compiler (PR 7753) +* Fix with PKCS11 to iterate correctly over slotId (PR 7736) +* Stop stripping out the sequence header on the AltSigAlg extension (PR 7710) +* Fix ParseCRL_AuthKeyIdExt with ASN template to set extAuthKeyIdSet value + (PR 7742) +* Use max key length for PSK encrypt buffer size (PR 7707) +* DTLS 1.3 fix for size check to include headers and CID fixes (PR 7912,7951) +* Fix STM32 Hash FIFO and add support for STM32U5A9xx (PR 7787) +* Fix CMake build error for curl builds (PR 8021) +* SP Maths: PowerPC ASM fix to use XOR instead of LI (PR 8038) +* SSL loading of keys/certs: testing and fixes (PR 7789) +* Misc. fixes for Dilithium and Kyber (PR 7721,7765,7803,8027,7904) +* Fixes for building wolfBoot sources for PQ LMS/XMSS (PR 7868) +* Fixes for building with Kyber enabled using CMake and zephyr port (PR 7773) +* Fix for edge cases with session resumption with TLS 1.2 (PR 8097) +* Fix issue with ARM ASM with AES CFB/OFB not initializing the "left" member + (PR 8099) + + # wolfSSL Release 5.7.2 (July 08, 2024) Release 5.7.2 has been developed according to wolfSSL's development and QA @@ -220,7 +539,7 @@ fixed this omission in several PRs for this release. * [Low] CVE-2023-6936: A potential heap overflow read is possible in servers connecting over TLS 1.3 when the optional `WOLFSSL_CALLBACKS` has been defined. The out of bounds read can occur when a server receives a malicious malformed ClientHello. Users should either discontinue use of `WOLFSSL_CALLBACKS` on the server side or update versions of wolfSSL to 5.6.6. Thanks to the tlspuffin fuzzer team for the report which was designed and developed by; Lucca Hirschi (Inria, LORIA), Steve Kremer (Inria, LORIA), and Max Ammann (Trail of Bits). The fix for this issue is located in the following GitHub Pull Request: https://github.com/wolfSSL/wolfssl/pull/6949. -* [Low] A side channel vulnerability with AES T-Tables is possible in a very controlled environment where precision sub-cache-line inspection can happen, such as inside an Intel SGX enclave. This can lead to recovery of the AES key. To prevent this type of attack, wolfSSL added an AES bitsliced implementation which can be enabled with the “`--enable-aes-bitsliced`” configure option. Thanks to Florian Sieck, Zhiyuan Zhang, Sebastian Berndt, Chitchanok Chuengsatiansup, Thomas Eisenbarth, and Yuval Yarom for the report (Universities of Lübeck, Melbourne, Adelaide and Bochum). The fix for this issue is located in the following GitHub Pull Request: https://github.com/wolfSSL/wolfssl/pull/6854. +* [Low] CVE-2024-1543: A side channel vulnerability with AES T-Tables is possible in a very controlled environment where precision sub-cache-line inspection can happen, such as inside an Intel SGX enclave. This can lead to recovery of the AES key. To prevent this type of attack, wolfSSL added an AES bitsliced implementation which can be enabled with the “`--enable-aes-bitsliced`” configure option. Thanks to Florian Sieck, Zhiyuan Zhang, Sebastian Berndt, Chitchanok Chuengsatiansup, Thomas Eisenbarth, and Yuval Yarom for the report (Universities of Lübeck, Melbourne, Adelaide and Bochum). The fix for this issue is located in the following GitHub Pull Request: https://github.com/wolfSSL/wolfssl/pull/6854. * [Low] CVE-2023-6937: wolfSSL prior to 5.6.6 did not check that messages in a single (D)TLS record do not span key boundaries. As a result, it was possible to combine (D)TLS messages using different keys into one (D)TLS record. The most extreme edge case is that, in (D)TLS 1.3, it was possible that an unencrypted (D)TLS 1.3 record from the server containing first a ServerHello message and then the rest of the first server flight would be accepted by a wolfSSL client. In (D)TLS 1.3 the handshake is encrypted after the ServerHello but a wolfSSL client would accept an unencrypted flight from the server. This does not compromise key negotiation and authentication so it is assigned a low severity rating. Thanks to Johannes Wilson for the report (Sectra Communications and Linköping University). The fix for this issue is located in the following GitHub Pull Request: https://github.com/wolfSSL/wolfssl/pull/7029. @@ -874,9 +1193,9 @@ Release 5.5.1 of wolfSSL embedded TLS has bug fixes and new features including: ## Enhancements * DTLSv1.3: Do HRR Cookie exchange by default -* Add wolfSSL_EVP_PKEY_new_CMAC_key to OpenSSL compatible API -* Update ide win10 build files to add missing sp source files -* Improve Workbench docs +* Add wolfSSL_EVP_PKEY_new_CMAC_key to OpenSSL compatible API +* Update ide win10 build files to add missing sp source files +* Improve Workbench docs * Improve EVP support for CHACHA20_POLY1305 * Improve `wc_SetCustomExtension` documentation * RSA-PSS with OCSP and add simple OCSP response DER verify test case @@ -884,23 +1203,23 @@ Release 5.5.1 of wolfSSL embedded TLS has bug fixes and new features including: * Don't over-allocate memory for DTLS fragments * Add WOLFSSL_ATECC_TFLXTLS for Atmel port * SHA-3 performance improvements with x86_64 assembly -* Add code to fallback to S/W if TSIP cannot handle +* Add code to fallback to S/W if TSIP cannot handle * Improves entropy with VxWorks * Make time in milliseconds 64-bits for longer session ticket lives * Support for setting cipher list with bytes * wolfSSL_set1_curves_list(), wolfSSL_CTX_set1_curves_list() improvements * Add to RSAES-OAEP key parsing for pkcs7 * Add missing DN nid to work with PrintName() -* SP int: default to 16 bit word size when NO_64BIT defined +* SP int: default to 16 bit word size when NO_64BIT defined * Limit the amount of fragments we store per a DTLS connection and error out when max limit is reached * Detect when certificate's RSA public key size is too big and fail on loading of certificate ## Fixes * Fix for async with OCSP non-blocking in `ProcessPeerCerts` * Fixes for building with 32-bit and socket size sign/unsigned mismatch -* Fix Windows CMakeList compiler options -* TLS 1.3 Middle-Box compat: fix missing brace -* Configuration consistency fixes for RSA keys and way to force disable of private keys +* Fix Windows CMakeList compiler options +* TLS 1.3 Middle-Box compat: fix missing brace +* Configuration consistency fixes for RSA keys and way to force disable of private keys * Fix for Aarch64 Mac M1 SP use * Fix build errors and warnings for MSVC with DTLS 1.3 * Fix HMAC compat layer function for SHA-1 @@ -908,9 +1227,9 @@ Release 5.5.1 of wolfSSL embedded TLS has bug fixes and new features including: * Check return from call to wc_Time * SP math: fix build configuration with opensslall * Fix for async session tickets -* SP int mp_init_size fixes when SP_WORD_SIZE == 8 +* SP int mp_init_size fixes when SP_WORD_SIZE == 8 * Ed. function to make public key now checks for if the private key flag is set -* Fix HashRaw WC_SHA256_DIGEST_SIZE for wc_Sha256GetHash +* Fix HashRaw WC_SHA256_DIGEST_SIZE for wc_Sha256GetHash * Fix for building with PSK only * Set correct types in wolfSSL_sk_*_new functions * Sanity check that size passed to mp_init_size() is no more than SP_INT_DIGITS @@ -1024,7 +1343,7 @@ CVE-2020-12966 https://www.amd.com/en/corporate/product-security/bulletin/amd-sb * Update SP math all to not use sp_int_word when SQR_MUL_ASM is available ### SP Math Fixes * Fixes for constant time with div function -* Fix casting warnings for Windows builds and assembly changes to support XMM6-15 being non-volatile +* Fix casting warnings for Windows builds and assembly changes to support XMM6-15 being non-volatile * Fix for div_word when not using div function * Fixes for user settings with SP ASM and ED/Curve25519 small * Additional Wycheproof tests ran and fixes @@ -1204,7 +1523,7 @@ Release 5.3.0 of wolfSSL embedded TLS has bug fixes and new features including: ### Math Library Fixes * Sanity check with SP math that ECC points ordinates are not greater than modulus length * Additional sanity checks that _sp_add_d does not error due to overflow -* Wycheproof fixes, testing integration, and fixes for AVX / AArch64 ASM edge case tests +* Wycheproof fixes, testing integration, and fixes for AVX / AArch64 ASM edge case tests * TFM fp_div_2_ct rework to avoid potential overflow ### Misc. @@ -1445,7 +1764,7 @@ Release 5.1.0 of wolfSSL embedded TLS has bug fixes and new features including: ###### PORT Fixes * Building with Android wpa_supplicant and KeyStore * Setting initial value of CA certificate with TSIP enabled -* Cryptocell ECC build fix and fix with RSA disabled +* Cryptocell ECC build fix and fix with RSA disabled * IoT-SAFE improvement for Key/File slot ID size, fix for C++ compile, and fixes for retrieving the public key after key generation ###### Math Library Fixes @@ -1584,7 +1903,7 @@ Release 5.0.0 of wolfSSL embedded TLS has bug fixes and new features including: - SSL_SESSION_has_ticket() - SSL_SESSION_get_ticket_lifetime_hint() - DIST_POINT_new - - DIST_POINT_free + - DIST_POINT_free - DIST_POINTS_free - CRL_DIST_POINTS_free - sk_DIST_POINT_push @@ -1747,7 +2066,7 @@ Release 4.8.0 of wolfSSL embedded TLS has bug fixes and new features including: ### Vulnerabilities * [Low] CVE-2021-37155: OCSP request/response verification issue. In the case that the serial number in the OCSP request differs from the serial number in the OCSP response the error from the comparison was not resulting in a failed verification. We recommend users that have wolfSSL version 4.6.0 and 4.7.0 with OCSP enabled update their version of wolfSSL. Version 4.5.0 and earlier are not affected by this report. Thanks to Rainer Mueller-Amersdorffer, Roee Yankelevsky, Barak Gutman, Hila Cohen and Shoshi Berko (from CYMOTIVE Technologies and CARIAD) for the report. -* [Low] CVE-2021-24116: Side-Channel cache look up vulnerability in base64 PEM decoding for versions of wolfSSL 4.5.0 and earlier. Versions 4.6.0 and up contain a fix and do not need to be updated for this report. If decoding a PEM format private key using version 4.5.0 and older of wolfSSL then we recommend updating the version of wolfSSL used. Thanks to Florian Sieck, Jan Wichelmann, Sebastian Berndt and Thomas Eisenbarth for the report. +* [Low] CVE-2021-24116: Side-Channel cache look up vulnerability in base64 PEM decoding for versions of wolfSSL 4.5.0 and earlier. Versions 4.6.0 and up contain a fix and do not need to be updated for this report. If decoding a PEM format private key using version 4.5.0 and older of wolfSSL then we recommend updating the version of wolfSSL used. Thanks to Florian Sieck, Jan Wichelmann, Sebastian Berndt and Thomas Eisenbarth for the report. ### New Feature Additions ###### New Product diff --git a/Docker/Dockerfile b/Docker/Dockerfile index e6c3cd35d..d2c01b05d 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -10,7 +10,7 @@ ARG DEPS_WOLFSSL="build-essential autoconf libtool clang clang-tools zlib1g-dev ARG DEPS_LIBOQS="astyle cmake gcc ninja-build libssl-dev python3-pytest python3-pytest-xdist unzip xsltproc doxygen graphviz python3-yaml valgrind git" ARG DEPS_UDP_PROXY="wget libevent-dev" ARG DEPS_TESTS="abi-dumper libcurl4-openssl-dev tcpdump libpsl-dev python3-pandas python3-tabulate libnl-genl-3-dev libcap-ng-dev python3-virtualenv curl jq" -ARG DEPS_TOOLS="ccache clang-tidy maven" +ARG DEPS_TOOLS="ccache clang-tidy maven libfile-util-perl android-tools-adb usbutils shellcheck" RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y apt-utils \ && apt install -y ${DEPS_WOLFSSL} ${DEPS_LIBOQS} ${DEPS_UDP_PROXY} ${DEPS_TESTS} ${DEPS_TOOLS} \ && apt clean -y && rm -rf /var/lib/apt/lists/* diff --git a/Docker/wolfCLU/Dockerfile b/Docker/wolfCLU/Dockerfile index da10d73dd..1e9099df4 100644 --- a/Docker/wolfCLU/Dockerfile +++ b/Docker/wolfCLU/Dockerfile @@ -1,5 +1,5 @@ ARG DOCKER_BASE_IMAGE=ubuntu -FROM ubuntu as BUILDER +FROM ubuntu AS builder ARG DEPS_WOLFSSL="build-essential autoconf libtool zlib1g-dev libuv1-dev libpam0g-dev git libpcap-dev libcurl4-openssl-dev bsdmainutils netcat-traditional iputils-ping bubblewrap" RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y apt-utils \ @@ -18,8 +18,8 @@ RUN git clone --depth=1 --single-branch --branch=main http://github.com/wolfssl/ FROM ${DOCKER_BASE_IMAGE} USER root -COPY --from=BUILDER /usr/local/lib/libwolfssl.so /usr/local/lib/ -COPY --from=BUILDER /usr/local/bin/wolfssl* /usr/local/bin/ +COPY --from=builder /usr/local/lib/libwolfssl.so /usr/local/lib/ +COPY --from=builder /usr/local/bin/wolfssl* /usr/local/bin/ RUN ldconfig ENTRYPOINT ["/usr/local/bin/wolfssl"] LABEL org.opencontainers.image.source=https://github.com/wolfssl/wolfssl diff --git a/Docker/wolfCLU/README.md b/Docker/wolfCLU/README.md index 1fc7bc6de..2c271d556 100644 --- a/Docker/wolfCLU/README.md +++ b/Docker/wolfCLU/README.md @@ -1,6 +1,6 @@ This is a small container that has wolfCLU installed for quick access. To build your own run the following: ``` -docker build --pull --build-arg DUMMY=$(date +%s) -t wolfclu . +docker build --pull --build-arg DUMMY=$(date +%s) -t wolfclu . ``` To run the container, you can use: diff --git a/IDE/ARDUINO/Arduino_README_prepend.md b/IDE/ARDUINO/Arduino_README_prepend.md index c11b35dbb..34ab46359 100644 --- a/IDE/ARDUINO/Arduino_README_prepend.md +++ b/IDE/ARDUINO/Arduino_README_prepend.md @@ -4,12 +4,46 @@ This library is restructured from [wolfSSL](https://github.com/wolfSSL/wolfssl/) The Official wolfSSL Arduino Library is found in [The Library Manager index](http://downloads.arduino.cc/libraries/library_index.json). -See the [Arduino-wolfSSL logs](https://downloads.arduino.cc/libraries/logs/github.com/wolfSSL/Arduino-wolfSSL/). +See the [Arduino-wolfSSL logs](https://downloads.arduino.cc/libraries/logs/github.com/wolfSSL/Arduino-wolfSSL/) for publishing status. + +Instructions for installing and using libraries can be found in the [Arduino docs](https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries/). + +## wolfSSL Configuration + +As described in the [Getting Started with wolfSSL on Arduino](https://www.wolfssl.com/getting-started-with-wolfssl-on-arduino/), wolfSSL features are enabled and disabled in the `user_settings.h` file. + +The `user_settings.h` file is found in the `/libraries/wolfssl/src` directory. + +For Windows this is typically `C:\Users\%USERNAME%\Documents\Arduino\libraries\wolfssl\src` + +For Mac: `~/Documents/Arduino/libraries/wolfssl/src` + +For Linux: `~/Arduino/libraries/wolfssl/src` + +Tips for success: + +- The `WOLFSSL_USER_SETTINGS` macro must be defined project-wide. (see [wolfssl.h](https://github.com/wolfSSL/wolfssl/blob/master/IDE/ARDUINO/wolfssl.h)) +- Apply any customizations only to `user_settings.h`; Do not edit wolfSSL `settings.h` or `configh.h` files. +- Do not explicitly include `user_settings.h` in any source file. +- For every source file that uses wolfssl, include `wolfssl/wolfcrypt/settings.h` before any other wolfSSL include, typically via `#include "wolfssl.h"`. +- See the [wolfSSL docs](https://www.wolfssl.com/documentation/manuals/wolfssl/chapter02.html) for details on build configuration macros. + +## wolfSSL Examples + +Additional wolfSSL examples can be found at: + +- https://github.com/wolfSSL/wolfssl/tree/master/IDE/ARDUINO + +- https://github.com/wolfSSL/wolfssl/tree/master/examples + +- https://github.com/wolfSSL/wolfssl-examples/ ## Arduino Releases -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. +This release of wolfSSL is version [5.7.6](https://github.com/wolfSSL/wolfssl/releases/tag/v5.7.6-stable). -The next Official wolfSSL Arduino Library is [5.7.0](https://github.com/wolfSSL/wolfssl/releases/tag/v5.7.0-stable) +See GitHub for [all Arduino wolfSSL releases](https://github.com/wolfSSL/Arduino-wolfSSL/releases). -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. +The first Official wolfSSL Arduino Library was `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 `./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/README.md b/IDE/ARDUINO/README.md index 75c25a20a..8808b0e29 100644 --- a/IDE/ARDUINO/README.md +++ b/IDE/ARDUINO/README.md @@ -2,18 +2,49 @@ See the [example sketches](./sketches/README.md): -- [sketches/wolfssl_server](./sketches/wolfssl_server/README.md) -- [sketches/wolfssl_client](./sketches/wolfssl_client/README.md) +NOTE: Moving; See https://github.com/wolfSSL/wolfssl-examples/pull/499 + +Bare-bones templates: + +- [sketches/wolfssl_version](./sketches/wolfssl_version/README.md) single file. +- [sketches/template](./sketches/template/README.md) multiple file example. + +Functional examples: +- [sketches/wolfssl_AES_CTR](./sketches/wolfssl_AES_CTR/README.md) AES CTR Encrypt / decrypt. +- [sketches/wolfssl_client](./sketches/wolfssl_client/README.md) TLS Client. +- [sketches/wolfssl_server](./sketches/wolfssl_server/README.md) TLS Server. + +Both the `template` and `wolfssl_AES_CTR` examples include VisualGDB project files. When publishing a new version to the Arduino Registry, be sure to edit `WOLFSSL_VERSION_ARUINO_SUFFIX` in the `wolfssl-arduino.sh` script. +## Getting Started + +See [Getting Started with wolfSSL on Arduino](https://www.wolfssl.com/getting-started-with-wolfssl-on-arduino/), wolfSSL features are enabled and disabled in the `user_settings.h` file. + +The `user_settings.h` file is found in the `/libraries/wolfssl/src` directory. + +For Windows this is typically `C:\Users\%USERNAME%\Documents\Arduino\libraries\wolfssl\src` + +For Mac: `~/Documents/Arduino/libraries/wolfssl/src` + +For Linux: `~/Arduino/libraries/wolfssl/src` + +Tips for success: + +- The `WOLFSSL_USER_SETTINGS` macro must be defined project-wide. (see [wolfssl.h](https://github.com/wolfSSL/wolfssl/blob/master/IDE/ARDUINO/wolfssl.h)) +- Apply any customizations only to `user_settings.h`; Do not edit wolfSSL `settings.h` or `configh.h` files. +- Do not explicitly include `user_settings.h` in any source file. +- For every source file that uses wolfssl, include `wolfssl/wolfcrypt/settings.h` before any other wolfSSL include, typically via `#include "wolfssl.h"`. +- See the [wolfSSL docs](https://www.wolfssl.com/documentation/manuals/wolfssl/chapter02.html) for details on build configuration macros. + ## Boards Many of the supported boards are natively built-in to the [Arduino IDE Board Manager](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-board-manager/) and by adding [additional cores](https://docs.arduino.cc/learn/starting-guide/cores/) as needed. STM32 Support can be added by including this link in the "Additional Boards Managers URLs" field -from [stm32duino/Arduino_Core_STM32](https://github.com/stm32duino/Arduino_Core_STM32?tab=readme-ov-file#getting-started) . +from [stm32duino/Arduino_Core_STM32](https://github.com/stm32duino/Arduino_Core_STM32?tab=readme-ov-file#getting-started). ``` https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json @@ -27,7 +58,7 @@ This option will allow wolfSSL to be installed directly using the native Arduino ## Manually Reformatting wolfSSL as a Compatible Arduino Library -Use [this](./wolfssl-arduino.sh) shell script that will re-organize the wolfSSL library to be +Use [this](./wolfssl-arduino.sh) shell script that will re-organize the wolfSSL library to be compatible with [Arduino Library Specification](https://arduino.github.io/arduino-cli/0.35/library-specification/) for projects that use Arduino IDE 1.5.0 or newer. @@ -42,7 +73,7 @@ from within the `wolfssl/IDE/ARDUINO` directory: 1. `./wolfssl-arduino.sh` - Creates an Arduino Library directory structure in the local `wolfSSL` directory of `IDE/ARDUINO`. - - You can add your own `user_settings.h`, or copy/rename the [default](../../examples/configs/user_settings_arduino.h). + - You can add your own `user_settings.h`, or copy/rename the [default](https://github.com/wolfSSL/wolfssl/blob/master/examples/configs/user_settings_arduino.h). 2. `./wolfssl-arduino.sh INSTALL` (The most common option) - Creates an Arduino Library in the local `wolfSSL` directory @@ -55,8 +86,8 @@ from within the `wolfssl/IDE/ARDUINO` directory: 3. `./wolfssl-arduino.sh INSTALL /path/to/repository` (Used to update [arduino-wolfSSL](https://github.com/wolfSSL/arduino-wolfSSL)) - Creates an Arduino Library in `wolfSSL` directory - Copies that directory contents to the specified `/path/to/repository` - - Adds the [default](../../examples/configs/user_settings_arduino.h) as `user_settings.h`. - + - Adds the [default](../../examples/configs/user_settings_arduino.h) as `user_settings.h`. + 4. `./wolfssl-arduino.sh INSTALL /path/to/any/other/directory` - Creates an Arduino Library in `wolfSSL` directory - Copies that directory contents to the specified `/path/to/any/other/directory` diff --git a/IDE/ARDUINO/include.am b/IDE/ARDUINO/include.am index 52491a8b1..cf1695fab 100644 --- a/IDE/ARDUINO/include.am +++ b/IDE/ARDUINO/include.am @@ -2,16 +2,32 @@ # included from Top Level Makefile.am # All paths should be given relative to the root +# Library files: EXTRA_DIST+= IDE/ARDUINO/README.md + +# There's an Arduino-specific Arduino_README_prepend.md that will be prepended to wolfSSL README.md +# Not to be confused with the interim PREPENDED_README.md that is created by script. EXTRA_DIST+= IDE/ARDUINO/Arduino_README_prepend.md + +# Core library files +EXTRA_DIST+= IDE/ARDUINO/wolfssl.h +EXTRA_DIST+= IDE/ARDUINO/wolfssl.h +EXTRA_DIST+= IDE/ARDUINO/wolfssl-arduino.cpp + EXTRA_DIST+= IDE/ARDUINO/keywords.txt EXTRA_DIST+= IDE/ARDUINO/library.properties.template + +# Sketch Examples EXTRA_DIST+= IDE/ARDUINO/sketches/README.md + +# wolfssl_client example sketch EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_client/README.md -EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_client/wolfssl_client.ino + +# wolfssl_server example sketch EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_server/README.md -EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_server/wolfssl_server.ino + +# wolfssl_version example sketch EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_version/README.md -EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_version/wolfssl_version.ino -EXTRA_DIST+= IDE/ARDUINO/wolfssl.h + +# Publishing script, either local install or to github.com/wolfSSL/Arduino-wolfSSL clone directory. EXTRA_DIST+= IDE/ARDUINO/wolfssl-arduino.sh diff --git a/IDE/ARDUINO/sketches/README.md b/IDE/ARDUINO/sketches/README.md index 26a1d1e18..020331da5 100644 --- a/IDE/ARDUINO/sketches/README.md +++ b/IDE/ARDUINO/sketches/README.md @@ -1,12 +1,75 @@ # wolfSSL Arduino Examples -There are currently two example Arduino sketches: +There are currently five example Arduino sketches: -* [wolfssl_client](./wolfssl_client/README.md): Basic TLS listening client. -* [wolfssl_server](./wolfssl_server/README.md): Basic TLS server. +NOTE: Moving; See https://github.com/wolfSSL/wolfssl-examples/pull/499 + +* `template`: Reference template wolfSSL example, including optional VisualGDB project files. +* `wolfssl_AES_CTR`: Basic AES CTR Encryption / Decryption example. +* `wolfssl_client`: Basic TLS listening client. +* `wolfssl_server`: Basic TLS server. +* `wolfssl_version`: Bare-bones wolfSSL example. Examples have been most recently confirmed operational on the [Arduino IDE](https://www.arduino.cc/en/software) 2.2.1. For examples on other platforms, see the [IDE directory](https://github.com/wolfssl/wolfssl/tree/master/IDE). -Additional examples can be found on [wolfSSL/wolfssl-examples](https://github.com/wolfSSL/wolfssl-examples/). +Additional wolfssl examples can be found at [wolfSSL/wolfssl-examples](https://github.com/wolfSSL/wolfssl-examples/). + +## Using wolfSSL + +The typical include will look something like this: + +``` +#include + + /* wolfSSL user_settings.h must be included from settings.h + * Make all configurations changes in user_settings.h + * Do not edit wolfSSL `settings.h` or `config.h` files. + * Do not explicitly include user_settings.h in any source code. + * Each Arduino sketch that uses wolfSSL must have: #include "wolfssl.h" + * C/C++ source files can use: #include + * The wolfSSL "settings.h" must be included in each source file using wolfSSL. + * The wolfSSL "settings.h" must appear before any other wolfSSL include. + */ +#include + +/* settings.h is typically included in wolfssl.h, but here as a reminder: */ +#include + +/* Any other wolfSSL includes follow:* +#include +``` + +## Configuring wolfSSL + +See the `user_settings.h` in the Arduino library `wolfssl/src` directory. For Windows users this is typically: + +``` +C:\Users\%USERNAME%\Documents\Arduino\libraries\wolfssl\src +``` + +WARNING: Changes to the library `user_settings.h` file will be lost when upgrading wolfSSL using the Arduino IDE. + +## Troubleshooting + +If compile problems are encountered, for example: + +``` +ctags: cannot open temporary file : File exists +exit status 1 + +Compilation error: exit status 1 +``` + +Try deleting the Arduino cache directory: + +``` +C:\Users\%USERNAME%\AppData\Local\arduino\sketches +``` + +For VisualGDB users, delete the project `.vs`, `Output`, and `TraceReports` directories. + +## More Information + +For more details, see [IDE/ARDUINO/README.md](https://github.com/wolfSSL/wolfssl/blob/master/IDE/ARDUINO/README.md) diff --git a/IDE/ARDUINO/sketches/wolfssl_client/README.md b/IDE/ARDUINO/sketches/wolfssl_client/README.md index caf83c58e..1f114fcb9 100644 --- a/IDE/ARDUINO/sketches/wolfssl_client/README.md +++ b/IDE/ARDUINO/sketches/wolfssl_client/README.md @@ -1,6 +1,14 @@ # Arduino Basic TLS Listening Client -Open the [wolfssl_client.ino](./wolfssl_client.ino) file in the Arduino IDE. +Open the `wolfssl_client.ino` file in the Arduino IDE. + +NOTE: Moving; See https://github.com/wolfSSL/wolfssl-examples/pull/499 + +If using WiFi, be sure to set `ssid` and `password` values. + +May need "Ethernet by Various" library to be installed. Tested with v2.0.2 and v2.8.1. + +See the `#define WOLFSSL_TLS_SERVER_HOST` to set your own server address. Other IDE products are also supported, such as: diff --git a/IDE/ARDUINO/sketches/wolfssl_client/wolfssl_client.ino b/IDE/ARDUINO/sketches/wolfssl_client/wolfssl_client.ino deleted file mode 100644 index e4727dce1..000000000 --- a/IDE/ARDUINO/sketches/wolfssl_client/wolfssl_client.ino +++ /dev/null @@ -1,894 +0,0 @@ -/* wolfssl_client.ino - * - * 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 - */ - -/* -Tested with: - -1) Intel Galileo acting as the Client, with a laptop acting as a server using - the server example provided in examples/server. - Legacy Arduino v1.86 was used to compile and program the Galileo - -2) Espressif ESP32 WiFi - -3) Arduino Due, Nano33 IoT, Nano RP-2040 -*/ - -/* - * Note to code editors: the Arduino client and server examples are edited in - * parallel for side-by-side comparison between examples. - */ - -/* If you have a private include, define it here, otherwise edit WiFi params */ -#define MY_PRIVATE_CONFIG "/workspace/my_private_config.h" - -/* set REPEAT_CONNECTION to a non-zero value to continually run the example. */ -#define REPEAT_CONNECTION 0 - -/* Edit this with your other TLS host server address to connect to: */ -#define WOLFSSL_TLS_SERVER_HOST "192.168.1.39" - -/* wolfssl TLS examples communicate on port 11111 */ -#define WOLFSSL_PORT 11111 - -/* Choose a monitor serial baud rate: 9600, 14400, 19200, 57600, 74880, etc. */ -#define SERIAL_BAUD 115200 - -/* We'll wait up to 2000 milliseconds to properly shut down connection */ -#define SHUTDOWN_DELAY_MS 2000 - -/* Number of times to retry connection. */ -#define RECONNECT_ATTEMPTS 20 - -/* Optional stress test. Define to consume memory until exhausted: */ -/* #define MEMORY_STRESS_TEST */ - -/* Choose client or server example, not both. */ -#define WOLFSSL_CLIENT_EXAMPLE -/* #define WOLFSSL_SERVER_EXAMPLE */ - -#if defined(MY_PRIVATE_CONFIG) - /* the /workspace directory may contain a private config - * excluded from GitHub with items such as WiFi passwords */ - #include MY_PRIVATE_CONFIG - static const char* ssid PROGMEM = MY_ARDUINO_WIFI_SSID; - static const char* password PROGMEM = MY_ARDUINO_WIFI_PASSWORD; -#else - /* when using WiFi capable boards: */ - static const char* ssid PROGMEM = "your_SSID"; - static const char* password PROGMEM = "your_PASSWORD"; -#endif - -#define BROADCAST_ADDRESS "255.255.255.255" - -/* There's an optional 3rd party NTPClient library by Fabrice Weinberg. - * If it is installed, uncomment define USE_NTP_LIB here: */ -/* #define USE_NTP_LIB */ -#ifdef USE_NTP_LIB - #include -#endif - -#include -/* Important: make sure settings.h appears before any other wolfSSL headers */ -#include -/* Reminder: settings.h includes user_settings.h - * For ALL project wolfSSL settings, see: - * [your path]/Arduino\libraries\wolfSSL\src\user_settings.h */ -#include -#include -#include - -/* Define DEBUG_WOLFSSL in user_settings.h for more verbose logging. */ -#if defined(DEBUG_WOLFSSL) - #define PROGRESS_DOT F("") -#else - #define PROGRESS_DOT F(".") -#endif - -/* Convert a macro to a string */ -#define xstr(x) str(x) -#define str(x) #x - -/* optional board-specific networking includes */ -#if defined(ESP32) - #define USING_WIFI - #include - #include - #ifdef USE_NTP_LIB - WiFiUDP ntpUDP; - #endif - /* Ensure the F() flash macro is defined */ - #ifndef F - #define F - #endif - WiFiClient client; - -#elif defined(ESP8266) - #define USING_WIFI - #include - WiFiClient client; - -#elif defined(ARDUINO_SAM_DUE) - #include - /* There's no WiFi/Ethernet on the Due. Requires Ethernet Shield. - /* Needs "Ethernet by Various" library to be installed. Tested with V2.0.2 */ - #include - EthernetClient client; - -#elif defined(ARDUINO_SAMD_NANO_33_IOT) - #define USING_WIFI - #include - #include /* Needs Arduino WiFiNINA library installed manually */ - WiFiClient client; - -#elif defined(ARDUINO_ARCH_RP2040) - #define USING_WIFI - #include - #include - WiFiClient client; - -#elif defined(USING_WIFI) - #define USING_WIFI - #include - #include - #ifdef USE_NTP_LIB - WiFiUDP ntpUDP; - #endif - WiFiClient client; - -/* TODO -#elif defined(OTHER_BOARD) -*/ -#else - #define USING_WIFI - WiFiClient client; - -#endif - -/* Only for syntax highlighters to show interesting options enabled: */ -#if defined(HAVE_SNI) \ - || defined(HAVE_MAX_FRAGMENT) \ - || defined(HAVE_TRUSTED_CA) \ - || defined(HAVE_TRUNCATED_HMAC) \ - || defined(HAVE_CERTIFICATE_STATUS_REQUEST) \ - || defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2) \ - || defined(HAVE_SUPPORTED_CURVES) \ - || defined(HAVE_ALPN) \ - || defined(HAVE_SESSION_TICKET) \ - || defined(HAVE_SECURE_RENEGOTIATION) \ - || defined(HAVE_SERVER_RENEGOTIATION_INFO) -#endif - -static const char host[] PROGMEM = WOLFSSL_TLS_SERVER_HOST; /* server to connect to */ -static const int port PROGMEM = WOLFSSL_PORT; /* port on server to connect to */ - -static WOLFSSL_CTX* ctx = NULL; -static WOLFSSL* ssl = NULL; -static char* wc_error_message = (char*)malloc(80 + 1); -static char errBuf[80]; - -#if defined(MEMORY_STRESS_TEST) - #define MEMORY_STRESS_ITERATIONS 100 - #define MEMORY_STRESS_BLOCK_SIZE 1024 - #define MEMORY_STRESS_INITIAL (4*1024) - static char* memory_stress[MEMORY_STRESS_ITERATIONS]; /* typically 1K per item */ - static int mem_ctr = 0; -#endif - -static int EthernetSend(WOLFSSL* ssl, char* msg, int sz, void* ctx); -static int EthernetReceive(WOLFSSL* ssl, char* reply, int sz, void* ctx); -static int reconnect = RECONNECT_ATTEMPTS; -static int lng_index PROGMEM = 0; /* 0 = English */ - -#if defined(__arm__) - #include - extern char _end; - extern "C" char *sbrk(int i); - static char *ramstart=(char *)0x20070000; - static char *ramend=(char *)0x20088000; -#endif - -/*****************************************************************************/ -/* fail_wait - in case of unrecoverable error */ -/*****************************************************************************/ -int fail_wait(void) { - show_memory(); - - Serial.println(F("Failed. Halt.")); - while (1) { - delay(1000); - } - return 0; -} - -/*****************************************************************************/ -/* show_memory() to optionally view during debugging. */ -/*****************************************************************************/ -int show_memory(void) -{ -#if defined(__arm__) - struct mallinfo mi = mallinfo(); - - char *heapend=sbrk(0); - register char * stack_ptr asm("sp"); - #if defined(DEBUG_WOLFSSL_VERBOSE) - Serial.print(" arena="); - Serial.println(mi.arena); - Serial.print(" ordblks="); - Serial.println(mi.ordblks); - Serial.print(" uordblks="); - Serial.println(mi.uordblks); - Serial.print(" fordblks="); - Serial.println(mi.fordblks); - Serial.print(" keepcost="); - Serial.println(mi.keepcost); - #endif - - #if defined(DEBUG_WOLFSSL) || defined(MEMORY_STRESS_TEST) - Serial.print("Estimated free memory: "); - Serial.print(stack_ptr - heapend + mi.fordblks); - Serial.println(F(" bytes")); - #endif - - #if (0) - /* Experimental: not supported on all devices: */ - Serial.print("RAM Start %lx\n", (unsigned long)ramstart); - Serial.print("Data/Bss end %lx\n", (unsigned long)&_end); - Serial.print("Heap End %lx\n", (unsigned long)heapend); - Serial.print("Stack Ptr %lx\n",(unsigned long)stack_ptr); - Serial.print("RAM End %lx\n", (unsigned long)ramend); - - Serial.print("Heap RAM Used: ",mi.uordblks); - Serial.print("Program RAM Used ",&_end - ramstart); - Serial.print("Stack RAM Used ",ramend - stack_ptr); - - Serial.print("Estimated Free RAM: %d\n\n",stack_ptr - heapend + mi.fordblks); - #endif -#else - Serial.println(F("show_memory() not implemented for this platform")); -#endif - return 0; -} - -/*****************************************************************************/ -/* EthernetSend() to send a message string. */ -/*****************************************************************************/ -int EthernetSend(WOLFSSL* ssl, char* message, int sz, void* ctx) { - int sent = 0; - (void)ssl; - (void)ctx; - - sent = client.write((byte*)message, sz); - return sent; -} - -/*****************************************************************************/ -/* EthernetReceive() to receive a reply string. */ -/*****************************************************************************/ -int EthernetReceive(WOLFSSL* ssl, char* reply, int sz, void* ctx) { - int ret = 0; - (void)ssl; - (void)ctx; - - while (client.available() > 0 && ret < sz) { - reply[ret++] = client.read(); - } - return ret; -} - -/*****************************************************************************/ -/* Arduino setup_hardware() */ -/*****************************************************************************/ -int setup_hardware(void) { - int ret = 0; - -#if defined(ARDUINO_SAMD_NANO_33_IOT) - Serial.println(F("Detected known tested and working Arduino Nano 33 IoT")); -#elif defined(ARDUINO_ARCH_RP2040) - Serial.println(F("Detected known tested and working Arduino RP-2040")); -#elif defined(__arm__) && defined(ID_TRNG) && defined(TRNG) - /* need to manually turn on random number generator on Arduino Due, etc. */ - pmc_enable_periph_clk(ID_TRNG); - trng_enable(TRNG); - Serial.println(F("Enabled ARM TRNG")); -#endif - - show_memory(); - randomSeed(analogRead(0)); - return ret; -} - -/*****************************************************************************/ -/* Arduino setup_datetime() */ -/* The device needs to have a valid date within the valid range of certs. */ -/*****************************************************************************/ -int setup_datetime(void) { - int ret = 0; - int ntp_tries = 20; - - /* we need a date in the range of cert expiration */ -#ifdef USE_NTP_LIB - #if defined(ESP32) - NTPClient timeClient(ntpUDP, "pool.ntp.org"); - - timeClient.begin(); - timeClient.update(); - delay(1000); - while (!timeClient.isTimeSet() && (ntp_tries > 0)) { - timeClient.forceUpdate(); - Serial.println(F("Waiting for NTP update")); - delay(2000); - ntp_tries--; - } - if (ntp_tries <= 0) { - Serial.println(F("Warning: gave up waiting on NTP")); - } - Serial.println(timeClient.getFormattedTime()); - Serial.println(timeClient.getEpochTime()); - #endif -#endif - -#if defined(ESP32) - /* see esp32-hal-time.c */ - ntp_tries = 5; - /* Replace "pool.ntp.org" with your preferred NTP server */ - configTime(0, 0, "pool.ntp.org"); - - /* Wait for time to be set */ - while ((time(nullptr) <= 100000) && ntp_tries > 0) { - Serial.println(F("Waiting for time to be set...")); - delay(2000); - ntp_tries--; - } -#endif - - return ret; -} /* setup_datetime */ - -/*****************************************************************************/ -/* Arduino setup_network() */ -/*****************************************************************************/ -int setup_network(void) { - int ret = 0; - -#if defined(USING_WIFI) - int status = WL_IDLE_STATUS; - - /* The ESP8266 & ESP32 support both AP and STA. We'll use STA: */ - #if defined(ESP8266) || defined(ESP32) - WiFi.mode(WIFI_STA); - #else - String fv; - if (WiFi.status() == WL_NO_MODULE) { - Serial.println("Communication with WiFi module failed!"); - /* don't continue if no network */ - while (true) ; - } - - fv = WiFi.firmwareVersion(); - if (fv < WIFI_FIRMWARE_LATEST_VERSION) { - Serial.println("Please upgrade the firmware"); - } - #endif - - Serial.print(F("Connecting to WiFi ")); - Serial.print(ssid); - status = WiFi.begin(ssid, password); - while (status != WL_CONNECTED) { - delay(1000); - Serial.print(F(".")); - Serial.print(status); - status = WiFi.status(); - } - - Serial.println(F(" Connected!")); -#else - /* Newer Ethernet shields have a - * MAC address printed on a sticker on the shield */ - byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; - IPAddress ip(192, 168, 1, 42); - IPAddress myDns(192, 168, 1, 1); - Ethernet.init(10); /* Most Arduino shields */ - /* Ethernet.init(5); * MKR ETH Shield */ - /* Ethernet.init(0); * Teensy 2.0 */ - /* Ethernet.init(20); * Teensy++ 2.0 */ - /* Ethernet.init(15); * ESP8266 with Adafruit FeatherWing Ethernet */ - /* Ethernet.init(33); * ESP32 with Adafruit FeatherWing Ethernet */ - Serial.println(F("Initialize Ethernet with DHCP:")); - if (Ethernet.begin(mac) == 0) { - Serial.println(F("Failed to configure Ethernet using DHCP")); - /* Check for Ethernet hardware present */ - if (Ethernet.hardwareStatus() == EthernetNoHardware) { - Serial.println(F("Ethernet shield was not found.")); - while (true) { - delay(1); /* do nothing */ - } - } - if (Ethernet.linkStatus() == LinkOFF) { - Serial.println(F("Ethernet cable is not connected.")); - } - /* try to configure using IP address instead of DHCP : */ - Ethernet.begin(mac, ip, myDns); - } - else { - Serial.print(F(" DHCP assigned IP ")); - Serial.println(Ethernet.localIP()); - } - /* We'll assume the Ethernet connection is ready to go. */ -#endif - - Serial.println(F("********************************************************")); - Serial.print(F(" wolfSSL Example Client IP = ")); -#if defined(USING_WIFI) - Serial.println(WiFi.localIP()); -#else - Serial.println(Ethernet.localIP()); -#endif - Serial.print(F(" Configured Server Host to connect to: ")); - Serial.println(host); - Serial.println(F("********************************************************")); - Serial.println(F("Setup network complete.")); - - return ret; -} - -/*****************************************************************************/ -/* Arduino setup_wolfssl() */ -/*****************************************************************************/ -int setup_wolfssl(void) { - int ret = 0; - WOLFSSL_METHOD* method; - - /* Show a revision of wolfssl user_settings.h file in use when available: */ -#if defined(WOLFSSL_USER_SETTINGS_ID) - Serial.print(F("WOLFSSL_USER_SETTINGS_ID: ")); - Serial.println(F(WOLFSSL_USER_SETTINGS_ID)); -#else - Serial.println(F("No WOLFSSL_USER_SETTINGS_ID found.")); -#endif - -#if defined(NO_WOLFSSL_SERVER) - Serial.println(F("wolfSSL server code disabled to save space.")); -#endif -#if defined(NO_WOLFSSL_CLIENT) - Serial.println(F("wolfSSL client code disabled to save space.")); -#endif - -#if defined(DEBUG_WOLFSSL) - wolfSSL_Debugging_ON(); - Serial.println(F("wolfSSL Debugging is On!")); -#else - Serial.println(F("wolfSSL Debugging is Off! (enable with DEBUG_WOLFSSL)")); -#endif - - /* See ssl.c for TLS cache settings. Larger cache = use more RAM. */ -#if defined(NO_SESSION_CACHE) - Serial.println(F("wolfSSL TLS NO_SESSION_CACHE")); -#elif defined(MICRO_SESSION_CACHEx) - Serial.println(F("wolfSSL TLS MICRO_SESSION_CACHE")); -#elif defined(SMALL_SESSION_CACHE) - Serial.println(F("wolfSSL TLS SMALL_SESSION_CACHE")); -#elif defined(MEDIUM_SESSION_CACHE) - Serial.println(F("wolfSSL TLS MEDIUM_SESSION_CACHE")); -#elif defined(BIG_SESSION_CACHE) - Serial.println(F("wolfSSL TLS BIG_SESSION_CACHE")); -#elif defined(HUGE_SESSION_CACHE) - Serial.println(F("wolfSSL TLS HUGE_SESSION_CACHE")); -#elif defined(HUGE_SESSION_CACHE) - Serial.println(F("wolfSSL TLS HUGE_SESSION_CACHE")); -#else - Serial.println(F("WARNING: Unknown or no TLS session cache setting.")); - /* See wolfssl/src/ssl.c for amount of memory used. - * It is best on embedded devices to choose a TLS session cache size. */ -#endif - - ret = wolfSSL_Init(); - if (ret == WOLFSSL_SUCCESS) { - Serial.println("Successfully called wolfSSL_Init"); - } - else { - Serial.println("ERROR: wolfSSL_Init failed"); - } - - /* See companion server example with wolfSSLv23_server_method here. - * method = wolfSSLv23_client_method()); SSL 3.0 - TLS 1.3. - * method = wolfTLSv1_2_client_method(); only TLS 1.2 - * method = wolfTLSv1_3_client_method(); only TLS 1.3 - * - * see Arduino\libraries\wolfssl\src\user_settings.h */ - - Serial.println("Here we go!"); - - method = wolfSSLv23_client_method(); - if (method == NULL) { - Serial.println(F("unable to get wolfssl client method")); - fail_wait(); - } - ctx = wolfSSL_CTX_new(method); - if (ctx == NULL) { - Serial.println(F("unable to get ctx")); - fail_wait(); - } - - return ret; -} - -/*****************************************************************************/ -/* Arduino setup_certificates() */ -/*****************************************************************************/ -int setup_certificates(void) { - int ret = 0; - - Serial.println(F("Initializing certificates...")); - show_memory(); - - /* Use built-in validation, No verification callback function: */ - wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, 0); - - /* Certificate */ - Serial.println("Initializing certificates..."); - ret = wolfSSL_CTX_use_certificate_buffer(ctx, - CTX_CLIENT_CERT, - CTX_CLIENT_CERT_SIZE, - CTX_CLIENT_CERT_TYPE); - if (ret == WOLFSSL_SUCCESS) { - Serial.print("Success: use certificate: "); - Serial.println(xstr(CTX_SERVER_CERT)); - } - else { - Serial.println(F("Error: wolfSSL_CTX_use_certificate_buffer failed: ")); - wc_ErrorString(ret, wc_error_message); - Serial.println(wc_error_message); - fail_wait(); - } - - /* Setup private client key */ - ret = wolfSSL_CTX_use_PrivateKey_buffer(ctx, - CTX_CLIENT_KEY, - CTX_CLIENT_KEY_SIZE, - CTX_CLIENT_KEY_TYPE); - if (ret == WOLFSSL_SUCCESS) { - Serial.print("Success: use private key buffer: "); - Serial.println(xstr(CTX_SERVER_KEY)); - } - else { - Serial.println(F("Error: wolfSSL_CTX_use_PrivateKey_buffer failed: ")); - wc_ErrorString(ret, wc_error_message); - Serial.println(wc_error_message); - fail_wait(); - } - - ret = wolfSSL_CTX_load_verify_buffer(ctx, - CTX_CA_CERT, - CTX_CA_CERT_SIZE, - CTX_CA_CERT_TYPE); - if (ret == WOLFSSL_SUCCESS) { - Serial.println(F("Success: load_verify CTX_CA_CERT")); - } - else { - Serial.println(F("Error: wolfSSL_CTX_load_verify_buffer failed: ")); - wc_ErrorString(ret, wc_error_message); - Serial.println(wc_error_message); - fail_wait(); - } - - - - return ret; -} /* Arduino setup */ - -/*****************************************************************************/ -/*****************************************************************************/ -/* Arduino setup() */ -/*****************************************************************************/ -/*****************************************************************************/ -void setup(void) { - int i = 0; - Serial.begin(SERIAL_BAUD); - while (!Serial && (i < 10)) { - /* wait for serial port to connect. Needed for native USB port only */ - delay(1000); - i++; - } - Serial.println(F("")); - Serial.println(F("")); - Serial.println(F("wolfSSL TLS Client Example Startup.")); - - /* define DEBUG_WOLFSSL in wolfSSL user_settings.h for diagnostics */ -#if defined(DEBUG_WOLFSSL) - wolfSSL_Debugging_ON(); -#endif - - /* Optionally pre-allocate a large block of memory for testing */ -#if defined(MEMORY_STRESS_TEST) - Serial.println(F("WARNING: Memory Stress Test Active!")); - Serial.print(F("Allocating extra memory: ")); - Serial.print(MEMORY_STRESS_INITIAL); - Serial.println(F(" bytes...")); - memory_stress[mem_ctr] = (char*)malloc(MEMORY_STRESS_INITIAL); - show_memory(); -#endif - - setup_hardware(); - - setup_network(); - - setup_datetime(); - - setup_wolfssl(); - - setup_certificates(); - - /* Initialize wolfSSL using callback functions. */ - wolfSSL_SetIOSend(ctx, EthernetSend); - wolfSSL_SetIORecv(ctx, EthernetReceive); - - Serial.println(F("Completed Arduino setup!")); - /* See companion wolfssl_server.ino code; server begins listening here - * https://github.com/wolfSSL/wolfssl/tree/master/IDE/ARDUINO/sketches/wolfssl_server - * Any other server will work. See also: - * https://github.com/wolfSSL/wolfssl/tree/master/examples/client - */ - /* See companion wolfssl_server.ino code */ - return; -} /* Arduino setup */ - -/*****************************************************************************/ -/* wolfSSL error_check() */ -/*****************************************************************************/ -int error_check(int this_ret, bool halt_on_error, - const __FlashStringHelper* message) { - int ret = 0; - if (this_ret == WOLFSSL_SUCCESS) { - Serial.print(F("Success: ")); - Serial.println(message); - } - else { - Serial.print(F("ERROR: return = ")); - Serial.print(this_ret); - Serial.print(F(": ")); - Serial.println(message); - Serial.println(wc_GetErrorString(this_ret)); - if (halt_on_error) { - fail_wait(); - } - } - show_memory(); - - return ret; -} /* error_check */ - -/*****************************************************************************/ -/* wolfSSL error_check_ssl */ -/* Parameters: */ -/* ssl is the current WOLFSSL object pointer */ -/* halt_on_error set to true to suspend operations for critical error */ -/* message is expected to be a memory-efficient F("") macro string */ -/*****************************************************************************/ -int error_check_ssl(WOLFSSL* ssl, int this_ret, bool halt_on_error, - const __FlashStringHelper* message) { - int err = 0; - - if (ssl == NULL) { - Serial.println(F("ssl is Null; Unable to allocate SSL object?")); -#ifndef DEBUG_WOLFSSL - Serial.println(F("Define DEBUG_WOLFSSL in user_settings.h for more.")); -#else - Serial.println(F("See wolfssl/wolfcrypt/error-crypt.h for codes.")); -#endif - Serial.print(F("ERROR: ")); - Serial.println(message); - show_memory(); - if (halt_on_error) { - fail_wait(); - } - } - else { - err = wolfSSL_get_error(ssl, this_ret); - if (err == WOLFSSL_SUCCESS) { - Serial.print(F("Success m: ")); - Serial.println(message); - } - else { - if (err < 0) { - wolfSSL_ERR_error_string(err, errBuf); - Serial.print(F("WOLFSSL Error: ")); - Serial.print(err); - Serial.print(F("; ")); - Serial.println(errBuf); - } - else { - Serial.println(F("Success: ssl object.")); - } - } - } - - return err; -} - -/*****************************************************************************/ -/*****************************************************************************/ -/* Arduino loop() */ -/*****************************************************************************/ -/*****************************************************************************/ -void loop() { - char reply[80]; - char msg[32] = "hello wolfssl!"; - const char* cipherName; - int retry_shutdown = SHUTDOWN_DELAY_MS; /* max try, once per millisecond */ - int total_input = 0; - int msgSz = 0; - int input = 0; - int ret = 0; - int err = 0; - msgSz = (int)strlen(msg); - Serial.println(F("")); - Serial.println(F("Starting Arduino loop() ...")); - - if (reconnect) { - reconnect--; - /* WiFi client returns true if connection succeeds, false if not. */ - /* Wired client returns int (1,-1,-2,-3,-4) for connection status. */ - Serial.print(F("Connecting to ")); - Serial.print(host); - Serial.print(F(":")); - Serial.println(port); - /* can also use: IPAddress server(192,168,1,37); */ - Serial.println(F("Here we go...")); - ret = client.connect(host, port); - Serial.println(F("Ok, checking...")); - if (ret > 0) { - Serial.println(F("Connected!")); - - /* initialize wolfSSL */ - ret = wolfSSL_Init(); - error_check(ret, false, F("calling wolfSSL_Init") ); - - /* create secure connection object. see setup for ctx certs. */ - Serial.println(F("Calling ssl = wolfSSL_new(ctx)")); - ssl = wolfSSL_new(ctx); - error_check_ssl(ssl, 0, true, F("Create WOLFSSL object from ctx")); - - Serial.print(F("Connecting to wolfSSL TLS Secure Server...")); - do { - err = 0; /* reset error */ - Serial.println(F("wolfSSL_connect ...")); - ret = wolfSSL_connect(ssl); - Serial.print("wolfSSL_connect return result ="); - Serial.println(ret); - if ((ret != WOLFSSL_SUCCESS) && (ret != WC_PENDING_E)) { - Serial.println(F("Failed connection, checking error.")); - err = error_check_ssl(ssl, ret, true, - F("Create WOLFSSL object from ctx")); - Serial.print("err ="); - Serial.println(err); - } - else { - Serial.print(PROGRESS_DOT); - } - } while (err == WC_PENDING_E); - - Serial.println(); - Serial.println(F("Connected!")); - Serial.print(F("SSL version is ")); - Serial.println(wolfSSL_get_version(ssl)); - - cipherName = wolfSSL_get_cipher(ssl); - Serial.print(F("SSL cipher suite is ")); - Serial.println(cipherName); - - /* see test.h - * TODO: test.h needs a little bit of Arduino work for these: - showPeerEx(ssl, lng_index); - showPeerPEM(ssl); - */ - - Serial.print(F("Sending secure message to server: ")); - Serial.println(msg); - ret = wolfSSL_write(ssl, msg, msgSz); - if (ret == msgSz) { - Serial.print(F("Waiting for Server response...")); - - while (!client.available()) { - /* wait for data */ - delay(1); /* 1 ms delay */ - } - - Serial.print(F("Reading response..")); - /* read data */ - do { - ret = wolfSSL_read(ssl, reply, sizeof(reply) - 1); - if (ret < 0) { - error_check_ssl(ssl, ret, false, - F("during TLS Read")); - } - else { - Serial.print(PROGRESS_DOT); - } - } while (err == WC_PENDING_E); - Serial.println(); - - Serial.println(); - Serial.println(reply); /* typically: I hear you fa shizzle! */ - Serial.println(); - - } /* wolfSSL_write message size matched */ - else { - error_check_ssl(ssl, ret, false, - F("during TLS Write")); - } /* any wolfSSL_write message size mismatch is an error */ - - Serial.print(F("Shutting down..")); - do { - delay(1); - Serial.print(PROGRESS_DOT); - retry_shutdown--; - ret = wolfSSL_shutdown(ssl); - } while ( (ret == WOLFSSL_SHUTDOWN_NOT_DONE) - && (retry_shutdown > 0) - ); /* There may be pending data, so wait until done. */ - Serial.println(); - - if (retry_shutdown <= 0) { - /* if wolfSSL_free is called before properly shutting down the - * ssl object, undesired results may occur. */ - Serial.println(F("Warning! Shutdown did not properly complete.")); - } - - wolfSSL_free(ssl); - client.stop(); - Serial.println(F("Connection complete.")); - if (REPEAT_CONNECTION) { - reconnect = RECONNECT_ATTEMPTS; - } - else { - reconnect = 0; - } - } /* client.connect(host, port) */ - else { - Serial.println(F("Problem sending message. Trying to reconnect...")); - } - } - delay(1000); - if ((reconnect > 0) && (REPEAT_CONNECTION)) { - Serial.println(F("Arduino loop repeating...")); - Serial.println(); - } - else { - printf("wow"); - Serial.println(F("Done!")); - while(1) { - /* wait forever */ - } - } - -#if defined(MEMORY_STRESS_TEST) - if (mem_ctr < MEMORY_STRESS_ITERATIONS) { - /* reminder: mem_ctr == 0 is MEMORY_STRESS_INITIAL allocation */ - mem_ctr++; - Serial.print(F("Memory stress increment: ")); - Serial.print(mem_ctr); - Serial.print(F(". Allocating addition memory (bytes): ")); - Serial.println(MEMORY_STRESS_BLOCK_SIZE); - memory_stress[mem_ctr] = (char*)malloc(MEMORY_STRESS_BLOCK_SIZE); - show_memory(); - } -#endif -} /* Arduino loop repeats */ diff --git a/IDE/ARDUINO/sketches/wolfssl_server/README.md b/IDE/ARDUINO/sketches/wolfssl_server/README.md index aee5c6630..ecad3f0c5 100644 --- a/IDE/ARDUINO/sketches/wolfssl_server/README.md +++ b/IDE/ARDUINO/sketches/wolfssl_server/README.md @@ -1,6 +1,14 @@ # Arduino Basic TLS Server -Open the [wolfssl_server.ino](./wolfssl_server.ino) file in the Arduino IDE. +Open the `wolfssl_server.ino` file in the Arduino IDE. + +NOTE: Moving; See https://github.com/wolfSSL/wolfssl-examples/pull/499 + +If using WiFi, be sure to set `ssid` and `password` values. + +May need "Ethernet by Various" library to be installed. Tested with v2.0.2 and v2.8.1. + +See the `#define WOLFSSL_TLS_SERVER_HOST` to set your own server address. Other IDE products are also supported, such as: @@ -13,7 +21,7 @@ Additional examples can be found on [wolfSSL/wolfssl-examples](https://github.co ## Connect with an Arduino Sketch -See the companion [Arduino Sketch Client](../wolfssl_client/wolfssl_client.ino). +See the companion [Arduino Sketch Client](../wolfssl_client/wolfssl_client.ino). ## Connect with Linux Client diff --git a/IDE/ARDUINO/sketches/wolfssl_server/wolfssl_server.ino b/IDE/ARDUINO/sketches/wolfssl_server/wolfssl_server.ino deleted file mode 100644 index 387052ca6..000000000 --- a/IDE/ARDUINO/sketches/wolfssl_server/wolfssl_server.ino +++ /dev/null @@ -1,838 +0,0 @@ -/* wolfssl_server.ino - * - * 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 - */ - -/* -Tested with: - -1) Intel Galileo acting as the Client, with a laptop acting as a server using - the server example provided in examples/server. - Legacy Arduino v1.86 was used to compile and program the Galileo - -2) Espressif ESP32 WiFi - -3) Arduino Due, Nano33 IoT, Nano RP-2040 -*/ - -/* - * Note to code editors: the Arduino client and server examples are edited in - * parallel for side-by-side comparison between examples. - */ - -/* If you have a private include, define it here, otherwise edit WiFi params */ -#define MY_PRIVATE_CONFIG "/workspace/my_private_config.h" - -/* set REPEAT_CONNECTION to a non-zero value to continually run the example. */ -#define REPEAT_CONNECTION 1 - -/* Edit this with your other TLS host server address to connect to: */ -/* #define WOLFSSL_TLS_SERVER_HOST "192.168.1.34" */ - -/* wolfssl TLS examples communicate on port 11111 */ -#define WOLFSSL_PORT 11111 - -/* Choose a monitor serial baud rate: 9600, 14400, 19200, 57600, 74880, etc. */ -#define SERIAL_BAUD 115200 - -/* We'll wait up to 2000 milliseconds to properly shut down connection */ -#define SHUTDOWN_DELAY_MS 2000 - -/* Number of times to retry connection. */ -#define RECONNECT_ATTEMPTS 20 - -/* Optional stress test. Define to consume memory until exhausted: */ -/* #define MEMORY_STRESS_TEST */ - -/* Choose client or server example, not both. */ -/* #define WOLFSSL_CLIENT_EXAMPLE */ -#define WOLFSSL_SERVER_EXAMPLE - -#if defined(MY_PRIVATE_CONFIG) - /* the /workspace directory may contain a private config - * excluded from GitHub with items such as WiFi passwords */ - #include MY_PRIVATE_CONFIG - static const char* ssid PROGMEM = MY_ARDUINO_WIFI_SSID; - static const char* password PROGMEM = MY_ARDUINO_WIFI_PASSWORD; -#else - /* when using WiFi capable boards: */ - static const char* ssid PROGMEM = "your_SSID"; - static const char* password PROGMEM = "your_PASSWORD"; -#endif - -#define BROADCAST_ADDRESS "255.255.255.255" - -/* There's an optional 3rd party NTPClient library by Fabrice Weinberg. - * If it is installed, uncomment define USE_NTP_LIB here: */ -/* #define USE_NTP_LIB */ -#ifdef USE_NTP_LIB - #include -#endif - -#include -/* Important: make sure settings.h appears before any other wolfSSL headers */ -#include -/* Reminder: settings.h includes user_settings.h - * For ALL project wolfSSL settings, see: - * [your path]/Arduino\libraries\wolfSSL\src\user_settings.h */ -#include -#include -#include - -/* Define DEBUG_WOLFSSL in user_settings.h for more verbose logging. */ -#if defined(DEBUG_WOLFSSL) - #define PROGRESS_DOT F("") -#else - #define PROGRESS_DOT F(".") -#endif - -/* Convert a macro to a string */ -#define xstr(x) str(x) -#define str(x) #x - -/* optional board-specific networking includes */ -#if defined(ESP32) - #define USING_WIFI - #include - #include - #ifdef USE_NTP_LIB - WiFiUDP ntpUDP; - #endif - /* Ensure the F() flash macro is defined */ - #ifndef F - #define F - #endif - WiFiClient client; - WiFiServer server(WOLFSSL_PORT); -#elif defined(ESP8266) - #define USING_WIFI - #include - WiFiClient client; - WiFiServer server(WOLFSSL_PORT); -#elif defined(ARDUINO_SAM_DUE) - #include - /* There's no WiFi/Ethernet on the Due. Requires Ethernet Shield. - /* Needs "Ethernet by Various" library to be installed. Tested with V2.0.2 */ - #include - EthernetClient client; - EthernetClient server(WOLFSSL_PORT); -#elif defined(ARDUINO_SAMD_NANO_33_IOT) - #define USING_WIFI - #include - #include /* Needs Arduino WiFiNINA library installed manually */ - WiFiClient client; - WiFiServer server(WOLFSSL_PORT); -#elif defined(ARDUINO_ARCH_RP2040) - #define USING_WIFI - #include - #include - WiFiClient client; - WiFiServer server(WOLFSSL_PORT); -#elif defined(USING_WIFI) - #define USING_WIFI - #include - #include - #ifdef USE_NTP_LIB - WiFiUDP ntpUDP; - #endif - WiFiClient client; - WiFiServer server(WOLFSSL_PORT); -/* TODO -#elif defined(OTHER_BOARD) -*/ -#else - #define USING_WIFI - WiFiClient client; - WiFiServer server(WOLFSSL_PORT); -#endif - -/* Only for syntax highlighters to show interesting options enabled: */ -#if defined(HAVE_SNI) \ - || defined(HAVE_MAX_FRAGMENT) \ - || defined(HAVE_TRUSTED_CA) \ - || defined(HAVE_TRUNCATED_HMAC) \ - || defined(HAVE_CERTIFICATE_STATUS_REQUEST) \ - || defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2) \ - || defined(HAVE_SUPPORTED_CURVES) \ - || defined(HAVE_ALPN) \ - || defined(HAVE_SESSION_TICKET) \ - || defined(HAVE_SECURE_RENEGOTIATION) \ - || defined(HAVE_SERVER_RENEGOTIATION_INFO) -#endif - - -/* we expect our IP address from DHCP */ - -static WOLFSSL_CTX* ctx = NULL; -static WOLFSSL* ssl = NULL; -static char* wc_error_message = (char*)malloc(80 + 1); -static char errBuf[80]; - -#if defined(MEMORY_STRESS_TEST) - #define MEMORY_STRESS_ITERATIONS 100 - #define MEMORY_STRESS_BLOCK_SIZE 1024 - #define MEMORY_STRESS_INITIAL (4*1024) - static char* memory_stress[MEMORY_STRESS_ITERATIONS]; /* typically 1K per item */ - static int mem_ctr = 0; -#endif - -static int EthernetSend(WOLFSSL* ssl, char* msg, int sz, void* ctx); -static int EthernetReceive(WOLFSSL* ssl, char* reply, int sz, void* ctx); -static int reconnect = RECONNECT_ATTEMPTS; -static int lng_index PROGMEM = 0; /* 0 = English */ - -#if defined(__arm__) - #include - extern char _end; - extern "C" char *sbrk(int i); - static char *ramstart=(char *)0x20070000; - static char *ramend=(char *)0x20088000; -#endif - -/*****************************************************************************/ -/* fail_wait - in case of unrecoverable error */ -/*****************************************************************************/ -int fail_wait(void) { - show_memory(); - - Serial.println(F("Failed. Halt.")); - while (1) { - delay(1000); - } - return 0; -} - -/*****************************************************************************/ -/* show_memory() to optionally view during debugging. */ -/*****************************************************************************/ -int show_memory(void) -{ -#if defined(__arm__) - struct mallinfo mi = mallinfo(); - - char *heapend=sbrk(0); - register char * stack_ptr asm("sp"); - #if defined(DEBUG_WOLFSSL_VERBOSE) - Serial.print(" arena="); - Serial.println(mi.arena); - Serial.print(" ordblks="); - Serial.println(mi.ordblks); - Serial.print(" uordblks="); - Serial.println(mi.uordblks); - Serial.print(" fordblks="); - Serial.println(mi.fordblks); - Serial.print(" keepcost="); - Serial.println(mi.keepcost); - #endif - - #if defined(DEBUG_WOLFSSL) || defined(MEMORY_STRESS_TEST) - Serial.print("Estimated free memory: "); - Serial.print(stack_ptr - heapend + mi.fordblks); - Serial.println(F(" bytes")); - #endif - - #if (0) - /* Experimental: not supported on all devices: */ - Serial.print("RAM Start %lx\n", (unsigned long)ramstart); - Serial.print("Data/Bss end %lx\n", (unsigned long)&_end); - Serial.print("Heap End %lx\n", (unsigned long)heapend); - Serial.print("Stack Ptr %lx\n",(unsigned long)stack_ptr); - Serial.print("RAM End %lx\n", (unsigned long)ramend); - - Serial.print("Heap RAM Used: ",mi.uordblks); - Serial.print("Program RAM Used ",&_end - ramstart); - Serial.print("Stack RAM Used ",ramend - stack_ptr); - - Serial.print("Estimated Free RAM: %d\n\n",stack_ptr - heapend + mi.fordblks); - #endif -#else - Serial.println(F("show_memory() not implemented for this platform")); -#endif - return 0; -} - -/*****************************************************************************/ -/* EthernetSend() to send a message string. */ -/*****************************************************************************/ -int EthernetSend(WOLFSSL* ssl, char* message, int sz, void* ctx) { - int sent = 0; - (void)ssl; - (void)ctx; - - sent = client.write((byte*)message, sz); - return sent; -} - -/*****************************************************************************/ -/* EthernetReceive() to receive a reply string. */ -/*****************************************************************************/ -int EthernetReceive(WOLFSSL* ssl, char* reply, int sz, void* ctx) { - int ret = 0; - (void)ssl; - (void)ctx; - - while (client.available() > 0 && ret < sz) { - reply[ret++] = client.read(); - } - return ret; -} - -/*****************************************************************************/ -/* Arduino setup_hardware() */ -/*****************************************************************************/ -int setup_hardware(void) { - int ret = 0; - -#if defined(ARDUINO_SAMD_NANO_33_IOT) - Serial.println(F("Detected known tested and working Arduino Nano 33 IoT")); -#elif defined(ARDUINO_ARCH_RP2040) - Serial.println(F("Detected known tested and working Arduino RP-2040")); -#elif defined(__arm__) && defined(ID_TRNG) && defined(TRNG) - /* need to manually turn on random number generator on Arduino Due, etc. */ - pmc_enable_periph_clk(ID_TRNG); - trng_enable(TRNG); - Serial.println(F("Enabled ARM TRNG")); -#endif - - show_memory(); - randomSeed(analogRead(0)); - return ret; -} - -/*****************************************************************************/ -/* Arduino setup_datetime() */ -/* The device needs to have a valid date within the valid range of certs. */ -/*****************************************************************************/ -int setup_datetime(void) { - int ret = 0; - int ntp_tries = 20; - - /* we need a date in the range of cert expiration */ -#ifdef USE_NTP_LIB - #if defined(ESP32) - NTPClient timeClient(ntpUDP, "pool.ntp.org"); - - timeClient.begin(); - timeClient.update(); - delay(1000); - while (!timeClient.isTimeSet() && (ntp_tries > 0)) { - timeClient.forceUpdate(); - Serial.println(F("Waiting for NTP update")); - delay(2000); - ntp_tries--; - } - if (ntp_tries <= 0) { - Serial.println(F("Warning: gave up waiting on NTP")); - } - Serial.println(timeClient.getFormattedTime()); - Serial.println(timeClient.getEpochTime()); - #endif -#endif - -#if defined(ESP32) - /* see esp32-hal-time.c */ - ntp_tries = 5; - /* Replace "pool.ntp.org" with your preferred NTP server */ - configTime(0, 0, "pool.ntp.org"); - - /* Wait for time to be set */ - while ((time(nullptr) <= 100000) && ntp_tries > 0) { - Serial.println(F("Waiting for time to be set...")); - delay(2000); - ntp_tries--; - } -#endif - - return ret; -} /* setup_datetime */ - -/*****************************************************************************/ -/* Arduino setup_network() */ -/*****************************************************************************/ -int setup_network(void) { - int ret = 0; - -#if defined(USING_WIFI) - int status = WL_IDLE_STATUS; - - /* The ESP8266 & ESP32 support both AP and STA. We'll use STA: */ - #if defined(ESP8266) || defined(ESP32) - WiFi.mode(WIFI_STA); - #else - String fv; - if (WiFi.status() == WL_NO_MODULE) { - Serial.println("Communication with WiFi module failed!"); - /* don't continue if no network */ - while (true) ; - } - - fv = WiFi.firmwareVersion(); - if (fv < WIFI_FIRMWARE_LATEST_VERSION) { - Serial.println("Please upgrade the firmware"); - } - #endif - - Serial.print(F("Connecting to WiFi ")); - Serial.print(ssid); - status = WiFi.begin(ssid, password); - while (status != WL_CONNECTED) { - delay(1000); - Serial.print(F(".")); - Serial.print(status); - status = WiFi.status(); - } - - Serial.println(F(" Connected!")); -#else - /* Newer Ethernet shields have a - * MAC address printed on a sticker on the shield */ - byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; - IPAddress ip(192, 168, 1, 42); - IPAddress myDns(192, 168, 1, 1); - Ethernet.init(10); /* Most Arduino shields */ - /* Ethernet.init(5); * MKR ETH Shield */ - /* Ethernet.init(0); * Teensy 2.0 */ - /* Ethernet.init(20); * Teensy++ 2.0 */ - /* Ethernet.init(15); * ESP8266 with Adafruit FeatherWing Ethernet */ - /* Ethernet.init(33); * ESP32 with Adafruit FeatherWing Ethernet */ - Serial.println(F("Initialize Ethernet with DHCP:")); - if (Ethernet.begin(mac) == 0) { - Serial.println(F("Failed to configure Ethernet using DHCP")); - /* Check for Ethernet hardware present */ - if (Ethernet.hardwareStatus() == EthernetNoHardware) { - Serial.println(F("Ethernet shield was not found.")); - while (true) { - delay(1); /* do nothing */ - } - } - if (Ethernet.linkStatus() == LinkOFF) { - Serial.println(F("Ethernet cable is not connected.")); - } - /* try to configure using IP address instead of DHCP : */ - Ethernet.begin(mac, ip, myDns); - } - else { - Serial.print(F(" DHCP assigned IP ")); - Serial.println(Ethernet.localIP()); - } - /* We'll assume the Ethernet connection is ready to go. */ -#endif - - Serial.println(F("********************************************************")); - Serial.print(F(" wolfSSL Example Server IP = ")); -#if defined(USING_WIFI) - Serial.println(WiFi.localIP()); -#else - Serial.println(Ethernet.localIP()); -#endif - /* In server mode, there's no host definition. */ - /* See companion example: wolfssl_client.ino */ - Serial.println(F("********************************************************")); - Serial.println(F("Setup network complete.")); - - return ret; -} - -/*****************************************************************************/ -/* Arduino setup_wolfssl() */ -/*****************************************************************************/ -int setup_wolfssl(void) { - int ret = 0; - WOLFSSL_METHOD* method; - - /* Show a revision of wolfssl user_settings.h file in use when available: */ -#if defined(WOLFSSL_USER_SETTINGS_ID) - Serial.print(F("WOLFSSL_USER_SETTINGS_ID: ")); - Serial.println(F(WOLFSSL_USER_SETTINGS_ID)); -#else - Serial.println(F("No WOLFSSL_USER_SETTINGS_ID found.")); -#endif - -#if defined(NO_WOLFSSL_SERVER) - Serial.println(F("wolfSSL server code disabled to save space.")); -#endif -#if defined(NO_WOLFSSL_CLIENT) - Serial.println(F("wolfSSL client code disabled to save space.")); -#endif - -#if defined(DEBUG_WOLFSSL) - wolfSSL_Debugging_ON(); - Serial.println(F("wolfSSL Debugging is On!")); -#else - Serial.println(F("wolfSSL Debugging is Off! (enable with DEBUG_WOLFSSL)")); -#endif - - /* See ssl.c for TLS cache settings. Larger cache = use more RAM. */ -#if defined(NO_SESSION_CACHE) - Serial.println(F("wolfSSL TLS NO_SESSION_CACHE")); -#elif defined(MICRO_SESSION_CACHEx) - Serial.println(F("wolfSSL TLS MICRO_SESSION_CACHE")); -#elif defined(SMALL_SESSION_CACHE) - Serial.println(F("wolfSSL TLS SMALL_SESSION_CACHE")); -#elif defined(MEDIUM_SESSION_CACHE) - Serial.println(F("wolfSSL TLS MEDIUM_SESSION_CACHE")); -#elif defined(BIG_SESSION_CACHE) - Serial.println(F("wolfSSL TLS BIG_SESSION_CACHE")); -#elif defined(HUGE_SESSION_CACHE) - Serial.println(F("wolfSSL TLS HUGE_SESSION_CACHE")); -#elif defined(HUGE_SESSION_CACHE) - Serial.println(F("wolfSSL TLS HUGE_SESSION_CACHE")); -#else - Serial.println(F("WARNING: Unknown or no TLS session cache setting.")); - /* See wolfssl/src/ssl.c for amount of memory used. - * It is best on embedded devices to choose a TLS session cache size. */ -#endif - - ret = wolfSSL_Init(); - if (ret == WOLFSSL_SUCCESS) { - Serial.println("Successfully called wolfSSL_Init"); - } - else { - Serial.println("ERROR: wolfSSL_Init failed"); - } - - /* See companion server example with wolfSSLv23_server_method here. - * method = wolfSSLv23_client_method()); SSL 3.0 - TLS 1.3. - * method = wolfTLSv1_2_client_method(); only TLS 1.2 - * method = wolfTLSv1_3_client_method(); only TLS 1.3 - * - * see Arduino\libraries\wolfssl\src\user_settings.h */ - - Serial.println("Here we go!"); - - method = wolfSSLv23_server_method(); - if (method == NULL) { - Serial.println(F("unable to get wolfssl server method")); - fail_wait(); - } - ctx = wolfSSL_CTX_new(method); - if (ctx == NULL) { - Serial.println(F("unable to get ctx")); - fail_wait(); - } - - return ret; -} - -/*****************************************************************************/ -/* Arduino setup_certificates() */ -/*****************************************************************************/ -int setup_certificates(void) { - int ret = 0; - - Serial.println(F("Initializing certificates...")); - show_memory(); - - /* Use built-in validation, No verification callback function: */ - wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0); - - /* Certificate */ - Serial.println("Initializing certificates..."); - ret = wolfSSL_CTX_use_certificate_buffer(ctx, - CTX_SERVER_CERT, - CTX_SERVER_CERT_SIZE, - CTX_CA_CERT_TYPE); - if (ret == WOLFSSL_SUCCESS) { - Serial.print("Success: use certificate: "); - Serial.println(xstr(CTX_SERVER_CERT)); - } - else { - Serial.print("Error: wolfSSL_CTX_use_certificate_buffer failed: "); - wc_ErrorString(ret, wc_error_message); - Serial.println(wc_error_message); - fail_wait(); - } - - /* Setup private server key */ - ret = wolfSSL_CTX_use_PrivateKey_buffer(ctx, - CTX_SERVER_KEY, - CTX_SERVER_KEY_SIZE, - CTX_SERVER_KEY_TYPE); - if (ret == WOLFSSL_SUCCESS) { - Serial.print("Success: use private key buffer: "); - Serial.println(xstr(CTX_SERVER_KEY)); - } - else { - Serial.print("Error: wolfSSL_CTX_use_PrivateKey_buffer failed: "); - wc_ErrorString(ret, wc_error_message); - Serial.println(wc_error_message); - fail_wait(); - } - - return ret; -} /* Arduino setup */ - -/*****************************************************************************/ -/*****************************************************************************/ -/* Arduino setup() */ -/*****************************************************************************/ -/*****************************************************************************/ -void setup(void) { - int i = 0; - Serial.begin(SERIAL_BAUD); - while (!Serial && (i < 10)) { - /* wait for serial port to connect. Needed for native USB port only */ - delay(1000); - i++; - } - - Serial.println(F("")); - Serial.println(F("")); - Serial.println(F("wolfSSL TLS Server Example Startup.")); - - /* define DEBUG_WOLFSSL in wolfSSL user_settings.h for diagnostics */ -#if defined(DEBUG_WOLFSSL) - wolfSSL_Debugging_ON(); -#endif - - /* Optionally pre-allocate a large block of memory for testing */ -#if defined(MEMORY_STRESS_TEST) - Serial.println(F("WARNING: Memory Stress Test Active!")); - Serial.print(F("Allocating extra memory: ")); - Serial.print(MEMORY_STRESS_INITIAL); - Serial.println(F(" bytes...")); - memory_stress[mem_ctr] = (char*)malloc(MEMORY_STRESS_INITIAL); - show_memory(); -#endif - - setup_hardware(); - - setup_network(); - - setup_datetime(); - - setup_wolfssl(); - - setup_certificates(); - - /* Initialize wolfSSL using callback functions. */ - wolfSSL_SetIOSend(ctx, EthernetSend); - wolfSSL_SetIORecv(ctx, EthernetReceive); - -#if defined THIS_USER_SETTINGS_VERSION - Serial.print(F("This user_settings.h version:")) - Serial.println(THIS_USER_SETTINGS_VERSION) -#endif - - /* Start the server - * See https://www.arduino.cc/reference/en/libraries/ethernet/server.begin/ - */ - - Serial.println(F("Completed Arduino setup()")); - - server.begin(); - Serial.println("Begin Server... (waiting for remote client to connect)"); - - /* See companion wolfssl_client.ino code */ - return; -} /* Arduino setup */ - -/*****************************************************************************/ -/* wolfSSL error_check() */ -/*****************************************************************************/ -int error_check(int this_ret, bool halt_on_error, - const __FlashStringHelper* message) { - int ret = 0; - if (this_ret == WOLFSSL_SUCCESS) { - Serial.print(F("Success: ")); - Serial.println(message); - } - else { - Serial.print(F("ERROR: return = ")); - Serial.print(this_ret); - Serial.print(F(": ")); - Serial.println(message); - Serial.println(wc_GetErrorString(this_ret)); - if (halt_on_error) { - fail_wait(); - } - } - show_memory(); - - return ret; -} /* error_check */ - -/*****************************************************************************/ -/* wolfSSL error_check_ssl */ -/* Parameters: */ -/* ssl is the current WOLFSSL object pointer */ -/* halt_on_error set to true to suspend operations for critical error */ -/* message is expected to be a memory-efficient F("") macro string */ -/*****************************************************************************/ -int error_check_ssl(WOLFSSL* ssl, int this_ret, bool halt_on_error, - const __FlashStringHelper* message) { - int err = 0; - - if (ssl == NULL) { - Serial.println(F("ssl is Null; Unable to allocate SSL object?")); -#ifndef DEBUG_WOLFSSL - Serial.println(F("Define DEBUG_WOLFSSL in user_settings.h for more.")); -#else - Serial.println(F("See wolfssl/wolfcrypt/error-crypt.h for codes.")); -#endif - Serial.print(F("ERROR: ")); - Serial.println(message); - show_memory(); - if (halt_on_error) { - fail_wait(); - } - } - else { - err = wolfSSL_get_error(ssl, this_ret); - if (err == WOLFSSL_SUCCESS) { - Serial.print(F("Success m: ")); - Serial.println(message); - } - else { - if (err < 0) { - wolfSSL_ERR_error_string(err, errBuf); - Serial.print(F("WOLFSSL Error: ")); - Serial.print(err); - Serial.print(F("; ")); - Serial.println(errBuf); - } - else { - Serial.println(F("Success: ssl object.")); - } - } - } - - return err; -} - -/*****************************************************************************/ -/*****************************************************************************/ -/* Arduino loop() */ -/*****************************************************************************/ -/*****************************************************************************/ -void loop() { - char errBuf[80] = "(no error"; - char reply[80] = "(no reply)"; - const char msg[] = "I hear you fa shizzle!"; - const char* cipherName; - int input = 0; - int replySz = 0; - int retry_shutdown = SHUTDOWN_DELAY_MS; /* max try, once per millisecond */ - int ret = 0; - IPAddress broadcast_address(255, 255, 255, 255); - - /* Listen for incoming client requests. */ - client = server.available(); - if (client) { - Serial.println("Have Client"); - while (!client.connected()) { - /* wait for the client to actually connect */ - delay(10); - } - Serial.print("Client connected from remote IP: "); - Serial.println(client.remoteIP()); - - ssl = wolfSSL_new(ctx); - if (ssl == NULL) { - Serial.println("Unable to allocate SSL object"); - fail_wait(); - } - - ret = wolfSSL_accept(ssl); - if (ret != WOLFSSL_SUCCESS) { - ret = wolfSSL_get_error(ssl, 0); - wolfSSL_ERR_error_string(ret, errBuf); - Serial.print("TLS Accept Error: "); - Serial.println(errBuf); - } - - cipherName = wolfSSL_get_cipher(ssl); - Serial.print("SSL cipher suite is "); - Serial.println(cipherName); - - Serial.print("Server Read: "); - while (!client.available()) { - /* wait for data */ - } - - /* read data */ - while (wolfSSL_pending(ssl)) { - input = wolfSSL_read(ssl, reply, sizeof(reply) - 1); - if (input < 0) { - ret = wolfSSL_get_error(ssl, 0); - wolfSSL_ERR_error_string(ret, errBuf); - Serial.print("TLS Read Error: "); - Serial.println(errBuf); - break; - } - else if (input > 0) { - replySz = input; - reply[input] = '\0'; - Serial.print(reply); - } - else { - Serial.println(""); - } - } - - /* Write our message into reply buffer to send */ - memset(reply, 0, sizeof(reply)); - memcpy(reply, msg, sizeof(msg)); - replySz = strnlen(reply, sizeof(reply)); - - Serial.println("Sending reply..."); - if ((wolfSSL_write(ssl, reply, replySz)) != replySz) { - ret = wolfSSL_get_error(ssl, 0); - wolfSSL_ERR_error_string(ret, errBuf); - Serial.print("TLS Write Error: "); - Serial.println(errBuf); - } - else { - Serial.println("Reply sent!"); - } - - Serial.println("Shutdown!"); - do { - delay(1); - retry_shutdown--; - ret = wolfSSL_shutdown(ssl); - } while ((ret == WOLFSSL_SHUTDOWN_NOT_DONE) && (retry_shutdown > 0)); - - if (retry_shutdown <= 0) { - /* if wolfSSL_free is called before properly shutting down the - * ssl object, undesired results may occur. */ - Serial.println("Warning! Shutdown did not properly complete."); - } - - wolfSSL_free(ssl); - Serial.println("Connection complete."); - if (REPEAT_CONNECTION) { - Serial.println(); - Serial.println("Waiting for next connection."); - } - else { - client.stop(); - Serial.println("Done!"); - while (1) { - /* wait forever if not repeating */ - delay(100); - } - } - } - else { - /* Serial.println("Client not connected. Trying again..."); */ - } - - delay(100); -} /* Arduino loop repeats */ diff --git a/IDE/ARDUINO/sketches/wolfssl_version/README.md b/IDE/ARDUINO/sketches/wolfssl_version/README.md index 3abfe8299..16230049f 100644 --- a/IDE/ARDUINO/sketches/wolfssl_version/README.md +++ b/IDE/ARDUINO/sketches/wolfssl_version/README.md @@ -1,3 +1,5 @@ # Arduino Basic Hello World This example simply compiles in wolfSSL and shows the current version number. + +NOTE: Moving; See https://github.com/wolfSSL/wolfssl-examples/pull/499 diff --git a/IDE/ARDUINO/sketches/wolfssl_version/wolfssl_version.ino b/IDE/ARDUINO/sketches/wolfssl_version/wolfssl_version.ino deleted file mode 100644 index ba34efbb9..000000000 --- a/IDE/ARDUINO/sketches/wolfssl_version/wolfssl_version.ino +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include - -/* Choose a monitor serial baud rate: 9600, 14400, 19200, 57600, 74880, etc. */ -#define SERIAL_BAUD 115200 - -/* Arduino setup */ -void setup() { - Serial.begin(SERIAL_BAUD); - while (!Serial) { - /* wait for serial port to connect. Needed for native USB port only */ - } - Serial.println(F("")); - Serial.println(F("")); - Serial.println(F("wolfSSL setup complete!")); -} - -/* Arduino main application loop. */ -void loop() { - Serial.print("wolfSSL Version: "); - Serial.println(LIBWOLFSSL_VERSION_STRING); - delay(60000); -} diff --git a/IDE/ARDUINO/wolfssl-arduino.cpp b/IDE/ARDUINO/wolfssl-arduino.cpp new file mode 100644 index 000000000..3d3c78735 --- /dev/null +++ b/IDE/ARDUINO/wolfssl-arduino.cpp @@ -0,0 +1,33 @@ +/* wolfssl-arduino.cpp + * + * Copyright (C) 2006-2025 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 + */ + +#include +#include "wolfssl.h" + +/* Function to allow wolfcrypt to use Arduino Serial.print for debug messages. + * See wolfssl/wolfcrypt/logging.c */ + +int wolfSSL_Arduino_Serial_Print(const char* const s) +{ + /* Reminder: Serial.print is only available in C++ */ + Serial.println(F(s)); + return 0; +}; diff --git a/IDE/ARDUINO/wolfssl-arduino.sh b/IDE/ARDUINO/wolfssl-arduino.sh index 59fd238df..0b9a3f32d 100755 --- a/IDE/ARDUINO/wolfssl-arduino.sh +++ b/IDE/ARDUINO/wolfssl-arduino.sh @@ -20,7 +20,7 @@ # Reminder there's typically no $USER for GitHub actions, but: # ROOT_DIR="/mnt/c/Users/$USER/Documents/Arduino/libraries" # -# The company name is "wolfSSL Inc."; There’s a space, no comma, and a period after "Inc." +# The company name is "wolfSSL Inc."; There's a space, no comma, and a period after "Inc." # The Arduino library name is "wolfssl" (all lower case) # The Arduino library directory name is "wolfssl" (all lower case) # The Arduino library include file is "wolfssl.h" (all lower case) @@ -70,6 +70,9 @@ if [ "$ROOT_DIR" = "" ]; then exit 1 fi + +ARDUINO_ROOT="$HOME/Arduino/libraries" + # Check environment if [ -n "$WSL_DISTRO_NAME" ]; then # we found a non-blank WSL environment distro name @@ -78,8 +81,6 @@ if [ -n "$WSL_DISTRO_NAME" ]; then if echo "$current_path" | grep -Eq "^$pattern"; then # if we are in WSL and shared Windows file system, 'ln' does not work. ARDUINO_ROOT="/mnt/c/Users/$USER/Documents/Arduino/libraries" - else - ARDUINO_ROOT="$HOME/Arduino/libraries" fi fi echo "The Arduino library root is: $ARDUINO_ROOT" @@ -106,21 +107,31 @@ if [ $# -gt 0 ]; then else echo "Installing to $THIS_INSTALL_DIR" if [ -d "$THIS_INSTALL_DIR/.git" ];then - echo "Target is a GitHub repository." + echo "Target is a GitHub root repository." THIS_INSTALL_IS_GITHUB="true" else - echo "Target is NOT a GitHub repository." + echo "Target is NOT a GitHub root directory repository. (e.g. not wolfssl/Arduino-wolfssl)" fi fi else echo "Error: not a valid operation: $THIS_OPERATION" exit 1 fi +else + echo "INSTALL parameter not specified. Installing to ROOT_DIR=$ROOT_DIR" fi ROOT_SRC_DIR="${ROOT_DIR}/src" EXAMPLES_DIR="${ROOT_DIR}/examples" + +if [ -n "$WOLFSSL_EXAMPLES_ROOT" ]; then + EXTRA_EXAMPLES_DIR="${WOLFSSL_EXAMPLES_ROOT}/Arduino" + echo "EXTRA_EXAMPLES_DIR=$EXTRA_EXAMPLES_DIR" +else + echo "There are additional examples at https://github.com/wolfSSL/wolfssl-examples" + echo "Set WOLFSSL_EXAMPLES_ROOT to your local directory to include those examples." +fi WOLFSSL_SRC="${ROOT_SRC_DIR}/src" WOLFSSL_HEADERS="${ROOT_SRC_DIR}/wolfssl" WOLFCRYPT_ROOT="${ROOT_SRC_DIR}/wolfcrypt" @@ -141,8 +152,16 @@ OPENSSL_DIR_TOP="${WOLFSSL_HEADERS_TOP}/openssl" WOLFSSL_VERSION=$(grep -i "LIBWOLFSSL_VERSION_STRING" ${TOP_DIR}/wolfssl/version.h | cut -d '"' -f 2) if [ "$WOLFSSL_VERSION" = "" ]; then - echo "ERROR: Could not find wolfSSL Version in ${TOP_DIR}/wolfssl/version.h" - exit 1 + echo "Current user: [$USER]" + if [ "$USER" = "" ] || [ "$USER" = "runner" ]; then + # Typically when there's no user, it is a GitHub workflow. It is not guaranteed to be "runner" + echo "No USER found, no version.h found. Setting Version text to [GitHub] for assumed workflow." + WOLFSSL_VERSION="GitHub" + else + echo "ERROR: Could not find wolfSSL Version in ${TOP_DIR}/wolfssl/version.h" + echo "Check autogen.sh and configure" + exit 1 + fi else echo "Found wolfSSL version $WOLFSSL_VERSION" echo "# WOLFSSL_VERSION_ARUINO_SUFFIX $WOLFSSL_VERSION_ARUINO_SUFFIX" @@ -235,26 +254,46 @@ if [ "$THIS_DIR" = "ARDUINO" ]; then $CP_CMD "${OPENSSL_DIR_TOP}"/* ."${OPENSSL_DIR}" || exit 1 # Finally, copy the Arduino-specific wolfssl library files into place: [lib]/src - $CP_CMD ./wolfssl.h ".${ROOT_SRC_DIR}"/wolfssl.h + $CP_CMD ./wolfssl.h ".${ROOT_SRC_DIR}"/wolfssl.h || exit 1 + $CP_CMD ./wolfssl-arduino.cpp ".${ROOT_SRC_DIR}"/wolfssl-arduino.cpp || exit 1 + unset NO_ARDUINO_EXAMPLES echo "Copy examples...." # Copy examples mkdir -p ".${ROOT_SRC_DIR}"/examples - echo "Copy wolfssl_client example...." - mkdir -p ".${EXAMPLES_DIR}"/wolfssl_client - $CP_CMD ./sketches/wolfssl_client/wolfssl_client.ino ".${EXAMPLES_DIR}"/wolfssl_client/wolfssl_client.ino || exit 1 - $CP_CMD ./sketches/wolfssl_client/README.md ".${EXAMPLES_DIR}"/wolfssl_client/README.md || exit 1 + if [ -n "$WOLFSSL_EXAMPLES_ROOT" ]; then + echo "Copy template example...." + mkdir -p ".${EXAMPLES_DIR}"/template/wolfssl_library/src + $CP_CMD "$WOLFSSL_EXAMPLES_ROOT"/Arduino/sketches/template/template.ino ".${EXAMPLES_DIR}"/template/template.ino || exit 1 + $CP_CMD "$WOLFSSL_EXAMPLES_ROOT"/Arduino/sketches/template/README.md ".${EXAMPLES_DIR}"/template/README.md || exit 1 + $CP_CMD "$WOLFSSL_EXAMPLES_ROOT"/Arduino/sketches/template/wolfssl_helper.c ".${EXAMPLES_DIR}"/template/wolfssl_helper.c || exit 1 + $CP_CMD "$WOLFSSL_EXAMPLES_ROOT"/Arduino/sketches/template/wolfssl_helper.h ".${EXAMPLES_DIR}"/template/wolfssl_helper.h || exit 1 + $CP_CMD "$WOLFSSL_EXAMPLES_ROOT"/Arduino/sketches/template/wolfssl_library/wolfssl_library.h ".${EXAMPLES_DIR}"/template/wolfssl_library/wolfssl_library.h || exit 1 + $CP_CMD "$WOLFSSL_EXAMPLES_ROOT"/Arduino/sketches/template/wolfssl_library/src/wolfssl_library.cpp ".${EXAMPLES_DIR}"/template/wolfssl_library/src/wolfssl_library.cpp || exit 1 - echo "Copy wolfssl_server example...." - mkdir -p .${EXAMPLES_DIR}/wolfssl_server - $CP_CMD ./sketches/wolfssl_server/wolfssl_server.ino ".${EXAMPLES_DIR}"/wolfssl_server/wolfssl_server.ino || exit 1 - $CP_CMD ./sketches/wolfssl_server/README.md ".${EXAMPLES_DIR}"/wolfssl_server/README.md || exit 1 + echo "Copy wolfssl_AES_CTR example...." + mkdir -p ".${EXAMPLES_DIR}"/wolfssl_AES_CTR + $CP_CMD "$WOLFSSL_EXAMPLES_ROOT"/Arduino/sketches/wolfssl_AES_CTR/wolfssl_AES_CTR.ino ".${EXAMPLES_DIR}"/wolfssl_AES_CTR/wolfssl_AES_CTR.ino || exit 1 + $CP_CMD "$WOLFSSL_EXAMPLES_ROOT"/Arduino/sketches/wolfssl_AES_CTR/README.md ".${EXAMPLES_DIR}"/wolfssl_AES_CTR/README.md || exit 1 - echo "Copy wolfssl_server example...." - mkdir -p .${EXAMPLES_DIR}/wolfssl_version - $CP_CMD ./sketches/wolfssl_version/wolfssl_version.ino ".${EXAMPLES_DIR}"/wolfssl_version/wolfssl_version.ino || exit 1 - $CP_CMD ./sketches/wolfssl_version/README.md ".${EXAMPLES_DIR}"/wolfssl_version/README.md || exit 1 + echo "Copy wolfssl_client example...." + mkdir -p ".${EXAMPLES_DIR}"/wolfssl_client + $CP_CMD "$WOLFSSL_EXAMPLES_ROOT"/Arduino/sketches/wolfssl_client/wolfssl_client.ino ".${EXAMPLES_DIR}"/wolfssl_client/wolfssl_client.ino || exit 1 + $CP_CMD "$WOLFSSL_EXAMPLES_ROOT"/Arduino/sketches/wolfssl_client/README.md ".${EXAMPLES_DIR}"/wolfssl_client/README.md || exit 1 + + echo "Copy wolfssl_server example...." + mkdir -p .${EXAMPLES_DIR}/wolfssl_server + $CP_CMD "$WOLFSSL_EXAMPLES_ROOT"/Arduino/sketches/wolfssl_server/wolfssl_server.ino ".${EXAMPLES_DIR}"/wolfssl_server/wolfssl_server.ino || exit 1 + $CP_CMD "$WOLFSSL_EXAMPLES_ROOT"/Arduino/sketches/wolfssl_server/README.md ".${EXAMPLES_DIR}"/wolfssl_server/README.md || exit 1 + + echo "Copy wolfssl_version example...." + mkdir -p .${EXAMPLES_DIR}/wolfssl_version + $CP_CMD "$WOLFSSL_EXAMPLES_ROOT"/Arduino/sketches/wolfssl_version/wolfssl_version.ino ".${EXAMPLES_DIR}"/wolfssl_version/wolfssl_version.ino || exit 1 + $CP_CMD "$WOLFSSL_EXAMPLES_ROOT"/Arduino/sketches/wolfssl_version/README.md ".${EXAMPLES_DIR}"/wolfssl_version/README.md || exit 1 + else + NO_ARDUINO_EXAMPLES=1 + fi else echo "ERROR: You must be in the IDE/ARDUINO directory to run this script" exit 1 @@ -273,6 +312,8 @@ fi # as an Arduino-specific README.md file. VERSION_PLACEHOLDER="\${WOLFSSL_VERSION}" ARDUINO_VERSION_SUFFIX_PLACEHOLDER="\${WOLFSSL_VERSION_ARUINO_SUFFIX}" + +# This is the SOURCE to prepend. Note the OUTPUT is PREPENDED_README.md later copied to README.md PREPEND_FILE="Arduino_README_prepend.md" PROPERTIES_FILE_TEMPLATE="library.properties.template" sed s/"$VERSION_PLACEHOLDER"/"$WOLFSSL_VERSION"/ "$PREPEND_FILE" > "$PREPEND_FILE.tmp" @@ -325,12 +366,24 @@ if [ "$THIS_OPERATION" = "INSTALL" ]; then echo "Removing workspace library directory: .$ROOT_DIR" rm -rf ".$ROOT_DIR" else - echo "Installing to local directory:" - echo "mv .$ROOT_DIR $ARDUINO_ROOT" - mv ."$ROOT_DIR" "$ARDUINO_ROOT" || exit 1 - echo "Arduino wolfSSL Version: $WOLFSSL_VERSION$WOLFSSL_VERSION_ARUINO_SUFFIX" + echo "Installing to local directory:" + if [ "$THIS_INSTALL_DIR" = "" ]; then + echo "mv .$ROOT_DIR $ARDUINO_ROOT" + mv ."$ROOT_DIR" "$ARDUINO_ROOT" || exit 1 + + echo "Arduino wolfSSL Version: $WOLFSSL_VERSION$WOLFSSL_VERSION_ARUINO_SUFFIX" + else + echo "cp -r .\"$ROOT_DIR\"/* \"$THIS_INSTALL_DIR\"" + mkdir -p "$THIS_INSTALL_DIR" || exit 1 + cp -r ."$ROOT_DIR"/* "$THIS_INSTALL_DIR" || exit 1 + fi fi fi +if [ -n "$NO_ARDUINO_EXAMPLES" ]; then + echo "" + echo "WARNING: No examples copied. Set WOLFSSL_EXAMPLES_ROOT as appropriate." + echo "" +fi echo "Done!" diff --git a/IDE/ARDUINO/wolfssl.h b/IDE/ARDUINO/wolfssl.h index 46ef50d3e..8b29806b6 100644 --- a/IDE/ARDUINO/wolfssl.h +++ b/IDE/ARDUINO/wolfssl.h @@ -1,6 +1,6 @@ /* wolfssl.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -22,18 +22,28 @@ /* Edit with caution. This is an Arduino-library specific header for wolfSSL */ #ifndef WOLFSSL_USER_SETTINGS + /* Should already be defined in settings.h for #if defined(ARDUINO) */ #define WOLFSSL_USER_SETTINGS #endif #include -/* wolfSSL user_settings.h must be included from settings.h */ +/* wolfSSL user_settings.h must be included from settings.h + * Make all configurations changes in user_settings.h + * Do not edit wolfSSL `settings.h` or `config.h` files. + * Do not explicitly include user_settings.h in any source code. + * Each Arduino sketch that uses wolfSSL must have: #include "wolfssl.h" + * C/C++ source files can use: #include + * The wolfSSL "settings.h" must be included in each source file using wolfSSL. + * The wolfSSL "settings.h" must be listed before any other wolfSSL include. + */ #include #include -int wolfSSL_Arduino_Serial_Print(const char *const s) -{ - /* See wolfssl/wolfcrypt/logging.c */ - Serial.println(F(s)); - return 0; -}; +#ifndef WOLFSSL_ARDUINO_H +#define WOLFSSL_ARDUINO_H + +/* Declare a helper function to be used in wolfssl/wolfcrypt/logging.c */ +int wolfSSL_Arduino_Serial_Print(const char* const s); + +#endif /* WOLFSSL_ARDUINO_H */ diff --git a/IDE/AURIX/Cpu0_Main.c b/IDE/AURIX/Cpu0_Main.c index 687511c68..9af27eccd 100644 --- a/IDE/AURIX/Cpu0_Main.c +++ b/IDE/AURIX/Cpu0_Main.c @@ -1,6 +1,6 @@ /* Cpu0_Main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -63,7 +63,7 @@ int fputc(int ch, FILE *f) if (ch == (int)'\n') { int chcr = (int)'\r'; count = 1; - IfxAsclin_Asc_write(&g_asc, &chcr, &count, TIME_INFINITE); + IfxAsclin_Asc_write(&g_asc, &chcr, &count, TIME_INFINITE); } count = 1; IfxAsclin_Asc_write(&g_asc, &ch, &count, TIME_INFINITE); diff --git a/IDE/AURIX/README.md b/IDE/AURIX/README.md index 11f884db3..fdcb171d5 100644 --- a/IDE/AURIX/README.md +++ b/IDE/AURIX/README.md @@ -9,7 +9,7 @@ Tested Platform: ## Running wolfCrypt on TriCore -1) Add the wolfSSL source and headers to `Libraries/wolfssl`. +1) Add the wolfSSL source and headers to `Libraries/wolfssl`. - Only the following folders are required: `src`, `wolfcrypt` and `wolfssl`. - See script to help with producing bundle here: https://github.com/wolfSSL/wolfssl/blob/master/scripts/makedistsmall.sh 2) Add `WOLFSSL_USER_SETTINGS` to the Preprocessing symbols list. C/C++ Build -> Settings -> TASKING C/C++ Compiler -> Preprocessing. diff --git a/IDE/AURIX/user_settings.h b/IDE/AURIX/user_settings.h index d041a9986..1b484e751 100644 --- a/IDE/AURIX/user_settings.h +++ b/IDE/AURIX/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/AURIX/wolf_main.c b/IDE/AURIX/wolf_main.c index f88140339..994ff5cca 100644 --- a/IDE/AURIX/wolf_main.c +++ b/IDE/AURIX/wolf_main.c @@ -1,6 +1,6 @@ /* wolf_main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/CRYPTOCELL/main.c b/IDE/CRYPTOCELL/main.c index 8cd8a2028..b4115b07e 100644 --- a/IDE/CRYPTOCELL/main.c +++ b/IDE/CRYPTOCELL/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -18,8 +18,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ - - + + #include #include #include @@ -63,4 +63,3 @@ int main(void) return 0; } - diff --git a/IDE/CRYPTOCELL/user_settings.h b/IDE/CRYPTOCELL/user_settings.h index b6ffe4c78..e48dc1977 100644 --- a/IDE/CRYPTOCELL/user_settings.h +++ b/IDE/CRYPTOCELL/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 9dcc7a473..925e1d8d0 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 d74cc436e..d433307e3 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 427eef638..f135d9cb1 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 16dc09ee7..0cfd0681b 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 2c9b29641..43bfa1b50 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 edf6559f8..1c4ed730b 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 e31f4ca61..41118df66 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 b94e1fe6e..fb7a8c005 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 27f8e08e2..2765c5d78 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ECLIPSE/MICRIUM/wolfsslRunTests.c b/IDE/ECLIPSE/MICRIUM/wolfsslRunTests.c index e7553c3d7..ec5d3ae1b 100644 --- a/IDE/ECLIPSE/MICRIUM/wolfsslRunTests.c +++ b/IDE/ECLIPSE/MICRIUM/wolfsslRunTests.c @@ -1,6 +1,6 @@ /* wolfsslRunTests.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 5e5ec18b4..0c21310f7 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 511801209..00bc99972 100644 --- a/IDE/ECLIPSE/RTTHREAD/wolfssl_test.c +++ b/IDE/ECLIPSE/RTTHREAD/wolfssl_test.c @@ -1,6 +1,6 @@ /* wolfsslRunTests.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/ECLIPSE/SIFIVE/README.md b/IDE/ECLIPSE/SIFIVE/README.md index 030e14049..206793e9c 100644 --- a/IDE/ECLIPSE/SIFIVE/README.md +++ b/IDE/ECLIPSE/SIFIVE/README.md @@ -1 +1 @@ -This folder has moved to `IDE/RISCV/SIFIVE-HIFIVE1`. \ No newline at end of file +This folder has moved to `IDE/RISCV/SIFIVE-HIFIVE1`. diff --git a/IDE/Espressif/ESP-IDF/README.md b/IDE/Espressif/ESP-IDF/README.md index 2075bde35..01a860fd9 100644 --- a/IDE/Espressif/ESP-IDF/README.md +++ b/IDE/Espressif/ESP-IDF/README.md @@ -1,11 +1,12 @@ # ESP-IDF Port -These Espressif examples have been created and tested with the latest stable release branch of -[ESP-IDF V5.2](https://docs.espressif.com/projects/esp-idf/en/release-v5.2/esp32/get-started/index.html). -The prior version 4.4 ESP-IDF is still supported, however version 5.2 or greater is recommended. -Espressif has [a list of all ESP-IDF versions](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/versions.html). +These Espressif examples have been created and tested with the latest stable release branch of +ESP-IDF v5.2, v5.3 and the master branch -See the latest [Espressif Migration Guides](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/migration-guides/index.html). +The prior version 4.4 ESP-IDF is still supported, however version 5.2 or greater is recommended. +Espressif has [a list of all ESP-IDF versions](Espressifversions.html). + +See the latest Espressif Migration Guides. ## Examples @@ -34,7 +35,7 @@ looks for the wolfSSL `user_settings.h` in the project as described below. ### File: `sdkconfig.h` The Espressif `sdkconfig.h`, generated automatically from your `sdkconfig` -file at [build](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html) +file at [build](Espressif api-guides/build-system.html) time, should be included before any other files. ### File: `user_settings.h` @@ -101,7 +102,7 @@ of your source code, particularly before the `#include git clone -b v5.0.2 --recursive https://github.com/espre ## Configuration - 1. The `user_settings.h` can be found in `[project]/components/wolfssl/include/user_settings.h`. + 1. The `user_settings.h` can be found in `[project]/components/wolfssl/include/user_settings.h`. ## Configuration (Legacy IDF install) @@ -183,13 +192,13 @@ C:\SysGCC\esp32\esp-idf>git clone -b v5.0.2 --recursive https://github.com/espre For question please email [support@wolfssl.com] - Note: This is tested with : + Note: This is tested with : - OS: Ubuntu 20.04.3 LTS - Microsoft Windows 10 Pro 10.0.19041 / Windows 11 Pro 22H2 22621.2715 - Visual Studio 2022 17.7.6 with VisualGDB 5.6R9 (build 4777) - WSL 1 Ubuntu 22.04.3 LTS - - ESP-IDF: ESP-IDF v5.1 - - SoC Module : all those supported in ESP-IDF v5.1 + - ESP-IDF: ESP-IDF v5.2 + - SoC Module : all those supported in ESP-IDF v5.2 ## JTAG Debugging Notes @@ -226,3 +235,15 @@ ftdi layout_signal nSRST -data 0x0020 reset_config srst_push_pull trst_push_pull ``` + +## Windows long paths + +Check "Long Paths Enabled" in Windows registry. + +Please set registry HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled to 1. + +The operation requires Administrator privileges. Command: + +```powershell +powershell -Command "&{ Start-Process -FilePath reg 'ADD HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1 /f' -Verb runAs}" +``` diff --git a/IDE/Espressif/ESP-IDF/README_32se.md b/IDE/Espressif/ESP-IDF/README_32se.md index af440a8b5..438723c6b 100644 --- a/IDE/Espressif/ESP-IDF/README_32se.md +++ b/IDE/Espressif/ESP-IDF/README_32se.md @@ -10,7 +10,7 @@ Including the following examples: The `user_settings.h` file enables some of the hardened settings. ## Requirements -1. ESP-IDF development framework: https://docs.espressif.com/projects/esp-idf/en/latest/get-started/ +1. ESP-IDF development framework: https://github.com/espressif/esp-idf 2. Microchip CryptoAuthentication Library: https://github.com/MicrochipTech/cryptoauthlib diff --git a/IDE/Espressif/ESP-IDF/dummy_config_h b/IDE/Espressif/ESP-IDF/dummy_config_h index 258ffd3f3..11b204c67 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Espressif/ESP-IDF/dummy_test_paths.h b/IDE/Espressif/ESP-IDF/dummy_test_paths.h index 38e912407..517826434 100644 --- a/IDE/Espressif/ESP-IDF/dummy_test_paths.h +++ b/IDE/Espressif/ESP-IDF/dummy_test_paths.h @@ -1,6 +1,6 @@ /* wolfcrypt/test/test_paths.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Espressif/ESP-IDF/examples/README.md b/IDE/Espressif/ESP-IDF/examples/README.md index 1cd6696f7..a25289432 100644 --- a/IDE/Espressif/ESP-IDF/examples/README.md +++ b/IDE/Espressif/ESP-IDF/examples/README.md @@ -12,7 +12,7 @@ These are the core examples for wolfSSL: - [TLS Client](./wolfssl_client/README.md). See also [CLI Client](https://github.com/wolfSSL/wolfssl/tree/master/examples/client) and [more TLS examples](https://github.com/wolfSSL/wolfssl-examples/tree/master/tls). -- [TLS Server](./wolfssl_server/README.md). See also [CLI Server](https://github.com/wolfSSL/wolfssl/tree/master/examples/server) +- [TLS Server](./wolfssl_server/README.md). See also [CLI Server](https://github.com/wolfSSL/wolfssl/tree/master/examples/server) ## Other Espressif wolfSSL Examples @@ -44,7 +44,7 @@ TLS1.3 Linux Client to Linux Server: `TLS_AES_128_GCM_SHA256` (default) ./examples/client/client -v 4 -h 127.0.0.1 -p 11111 -A ./certs/ca-cert.pem ``` -TLS1.2 Linux Server +TLS1.2 Linux Server ``` ./examples/server/server -v 3 -b -d -p 11111 -c ./certs/server-cert.pem -k ./certs/server-key.pem ``` @@ -71,14 +71,14 @@ There's an additional example that uses wolfSSL installed as a component to the ## Installing wolfSSL for Espressif projects -[Core examples](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples) -have a local `components/wolfssl` directory with a special CMakeFile.txt that does not require +[Core examples](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples) +have a local `components/wolfssl` directory with a special CMakeFile.txt that does not require wolfSSL to be installed. -If you want to install wolfSSL, see the setup for [wolfSSL](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF#setup-for-linux) +If you want to install wolfSSL, see the setup for [wolfSSL](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF#setup-for-linux) and [wolfSSH](https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif#setup-for-linux). -The [Espressif Managed Component for wolfSSL](https://components.espressif.com/components/wolfssl/wolfssl) +The [Espressif Managed Component for wolfSSL](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/) also installs source code locally, instead of pointing to a source repository. ## VisualGDB @@ -114,7 +114,4 @@ It may be helpful to also delete the `sdkconfig` file. (Save a backup if you've - esp32.com: [GPIO6,GPIO7,GPIO8,and GPIO9 changed for ESP32-WROOM-32E](https://esp32.com/viewtopic.php?t=29058) -See also [this ESP-FAQ Handbook](https://docs.espressif.com/projects/esp-faq/en/latest/esp-faq-en-master.pdf). - - - +See also the `ESP-FAQ Handbook`. diff --git a/IDE/Espressif/ESP-IDF/examples/template/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/template/CMakeLists.txt index 649a73663..61110a150 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/template/CMakeLists.txt @@ -1,10 +1,19 @@ # wolfSSL Espressif Example Project CMakeLists.txt -# v1.0 +# v1.3 # # The following lines of boilerplate have to be in your project's # CMakeLists in this exact order for cmake to work correctly +message(STATUS "Begin project ${CMAKE_PROJECT_NAME}") + cmake_minimum_required(VERSION 3.16) +# Optional no watchdog typically used for test & benchmark +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESP_NO_WATCHDOG=1") +else() + add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +endif() + # The wolfSSL CMake file should be able to find the source code. # Otherwise, assign an environment variable or set it here: # @@ -22,34 +31,63 @@ cmake_minimum_required(VERSION 3.16) if(WIN32) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") - message("Detected Windows") + message(STATUS "Detected Windows") endif() if(CMAKE_HOST_UNIX) - message("Detected UNIX") + message(STATUS "Detected UNIX") endif() if(APPLE) - message("Detected APPLE") + message(STATUS "Detected APPLE") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") - message("Detected WSL") + message(STATUS "Detected WSL") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") - message("Detected Linux") + message(STATUS "Detected Linux") endif() if(APPLE) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") - message("Detected Apple") + message(STATUS "Detected Apple") endif() # End optional WOLFSSL_CMAKE_SYSTEM_NAME +# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. +# set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) +string(REPLACE "\\" "/" PROTOCOL_EXAMPLES_DIR "$ENV{IDF_PATH}/examples/common_components/protocol_examples_common") + +if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") + message(STATUS "Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") +else() + message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") +endif() + +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER +message(STATUS "USERNAME = $ENV{USERNAME}") +if( "$ENV{USER}" STREQUAL "" ) # the bash user + if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user + message(STATUS "could not find USER or USERNAME") + else() + # the bash user is not blank, so we'll use it. + set(THIS_USER "$ENV{USERNAME}") + endif() +else() + # the bash user is not blank, so we'll use it. + set(THIS_USER "$ENV{USER}") +endif() +message(STATUS "THIS_USER = ${THIS_USER}") + # Check that there are not conflicting wolfSSL components # The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl # The local component wolfSSL directory will be in ./components/wolfssl +message(STATUS "Checking for wolfSSL as Managed Component or not... ${CMAKE_HOME_DIRECTORY}") if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" ) # These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake' # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL) @@ -64,10 +102,47 @@ if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXI message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n" "If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove " "or rename the idf_component.yml file typically found in ./main/") -else() +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl") + # A standard project component (not a Managed Component) message(STATUS "No conflicting wolfSSL components found.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/components/wolfssl") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl") + # The official Managed Component called wolfssl from the wolfssl user. + message(STATUS "No conflicting wolfSSL components found as a Managed Component.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/gojimmypi__mywolfssl") + # There is a known gojimmypi staging component available for anyone: + message(STATUS "No conflicting wolfSSL components found as a gojimmypi staging Managed Component.") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/${THIS_USER}__mywolfssl") + # Other users with permissions might publish their own mywolfssl staging Managed Component + message(STATUS "No conflicting wolfSSL components found as a Managed Component.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/managed_components/${THIS_USER}__mywolfssl") +else() + message(STATUS "WARNING: wolfssl component directory not found.") +endif() + +# message(STATUS "EXTRA_COMPONENT_DIRS WOLFSSL_PATH: ${WOLFSSL_PATH}") +# list(APPEND EXTRA_COMPONENT_DIRS ${WOLFSSL_PATH}) + +# Not only is a project-level "set(COMPONENTS" not needed here, this will cause +# an unintuitive error about Unknown CMake command "esptool_py_flash_project_args". + +if(0) + message(STATUS "Begin optional PROTOCOL_EXAMPLES_DIR include") + # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. + set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + + if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") + message(STATUS "Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") + else() + message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + endif() + message(STATUS "End optional PROTOCOL_EXAMPLES_DIR include") endif() include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(wolfssl_template) +message(STATUS "end project") diff --git a/IDE/Espressif/ESP-IDF/examples/template/Makefile b/IDE/Espressif/ESP-IDF/examples/template/Makefile new file mode 100644 index 000000000..e2b2e18e1 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/template/Makefile @@ -0,0 +1,14 @@ +# +# This is a project Makefile. It is assumed the directory this Makefile resides in is a +# project subdirectory. +# + +CFLAGS += -DWOLFSSL_USER_SETTINGS + +# Some of the tests are CPU intenstive, so we'll force the watchdog timer off. +# There's an espressif NO_WATCHDOG; we don't use it, as it is reset by sdkconfig. +CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 + +PROJECT_NAME := wolfssl_template + +include $(IDF_PATH)/make/project.mk diff --git a/IDE/Espressif/ESP-IDF/examples/template/README.md b/IDE/Espressif/ESP-IDF/examples/template/README.md index 274e22dea..9e82e7280 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/README.md +++ b/IDE/Espressif/ESP-IDF/examples/template/README.md @@ -7,11 +7,11 @@ For general information on [wolfSSL examples for Espressif](../README.md), see t ### Prerequisites -It is assumed the [ESP-IDF environment](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/) has been installed. +It is assumed the [ESP-IDF environment](Espressifget-started/) has been installed. ### Files Included -- [main.c](./main/main.c) with a simple call to an Espressif library (`ESP_LOGI`) and a call to a wolfSSL library (`esp_ShowExtendedSystemInfo`) . +- [main.c](./main/main.c) with a simple call to an Espressif library (`ESP_LOGI`) and a call to a wolfSSL library (`esp_ShowExtendedSystemInfo`) . - See [components/wolfssl/include](./components/wolfssl/include/user_settings.h) directory to edit the wolfSSL `user_settings.h`. @@ -19,7 +19,7 @@ It is assumed the [ESP-IDF environment](https://docs.espressif.com/projects/esp- - The [components/wolfssl/CMakeLists.txt](./components/wolfssl/CMakeLists.txt) typically does not need to be changed. -- Optional [VisualGDB Project](./VisualGDB/wolfssl_template_IDF_v5.1_ESP32.vgdbproj) for Visual Studio using ESP32 and ESP-IDF v5.1. +- Optional [VisualGDB Project](./VisualGDB/README.md) for Visual Studio using ESP32 and ESP-IDF v5.2. See also [template](../template/VisualGDB/README.md) for other devices. - Edit the project [CMakeLists.txt](./CMakeLists.txt) to optionally point this project's wolfSSL component source code at a different directory: @@ -30,12 +30,12 @@ set(WOLFSSL_ROOT "~/workspace/wolfssl-other-source") ## Getting Started: -Here's an example using the command-line [idf.py](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-py.html). +Here's an example using the command-line [idf.py](Espressifapi-guides/tools/idf-py.html). Edit your `WRK_IDF_PATH`to point to your ESP-IDF install directory. ``` -WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.1 +WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.2 echo "Run export.sh from ${WRK_IDF_PATH}" . ${WRK_IDF_PATH}/export.sh @@ -53,7 +53,7 @@ idf.py flash -p /dev/ttyS19 -b 115200 idf.py flash -p /dev/ttyS19 -b 115200 monitor ``` -Press `Ctrl+]` to exit `idf.py monitor`. See [additional monitor keyboard commands](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-monitor.html). +Press `Ctrl+]` to exit `idf.py monitor`. See [additional monitor keyboard commands](Espressifapi-guides/tools/idf-monitor.html). ## Other Examples: 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 18e513b98..cc7ef0d47 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # @@ -19,18 +19,148 @@ # # cmake for wolfssl Espressif projects # -# Version 5.6.0.011 for detect test/benchmark +# Version 5.7.2 Espressif ESP-IDF integration # # See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html # - +message(STATUS "Begin wolfssl ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") cmake_minimum_required(VERSION 3.16) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") -set(CMAKE_CURRENT_SOURCE_DIR ".") -set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component -set(WOLFSSL_ROOT "$ENV{WOLFSSL_ROOT}" ) -# find the user name to search for possible "wolfssl-username" +set(VERBOSE_COMPONENT_MESSAGES 1) + +# Optional requires include: +# set(THIS_ESP_TLS "esp-tls") +set(THIS_ESP_TLS "") + +# function: IS_ESP_IDF_COMPONENT +# output: RESULT = 1 (true) if this component is located in the ESP-IDF components +# otherwise 0 (false) +function( IS_ESP_IDF_COMPONENT RESULT ) + # NOTE: Component location is based on the location of the CMakeList.txt + # and *not* the location of the wolfSSL source code. (which may be anywhere) + + # Normalize the paths to remove any trailing slashes + get_filename_component(NORMALIZED_IDF_PATH "${IDF_PATH}" REALPATH) + get_filename_component(NORMALIZED_TEST_PATH "${COMPONENT_DIR}" REALPATH) + + # Check if the test path starts with the IDF_PATH + string(FIND "${NORMALIZED_TEST_PATH}" "${NORMALIZED_IDF_PATH}" pos) + + if(${pos} EQUAL 0) + message(STATUS "${COMPONENT_DIR} is within IDF_PATH.") + set(${RESULT} 1 PARENT_SCOPE) + else() + message(STATUS "${COMPONENT_DIR} is not within IDF_PATH.") + set(${RESULT} 0 PARENT_SCOPE) + endif() +endfunction() + +# Determine if this cmake file is located in the ESP-IDF component directory or not, +# and if so, if it is being ignored (allowing the use of a local project one, instead). +IS_ESP_IDF_COMPONENT( IS_WOLSSL_ESP_IDF_COMPONENT ) +if( IS_WOLSSL_ESP_IDF_COMPONENT ) + message(STATUS "This wolfSSL is a component in ESP-IDF.") + if ( CONFIG_IGNORE_ESP_IDF_WOLFSSL_COMPONENT ) + idf_component_register() + message(STATUS "Warning: wolfSSL component in ESP-IDF is being ignored.") + return() + endif() +endif() + + +if( "${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}" STREQUAL "" ) + # nothing to do +else() + # Only forward slashes, or double backslashes are supported. + # By the time we get here the sdkconfig file has a value for wolfSSL source code root. + string(REPLACE "\\" "/" CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}) + message(STATUS "Cleaned wolfssl path: ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") +endif() + +# The scope of this CMAKE_C_FLAGS is just this component: +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWOLFSSL_USER_SETTINGS") + +set(CMAKE_CURRENT_SOURCE_DIR ".") +# set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component + +# Optionally set your source to wolfSSL in your project CMakeLists.txt like this: +# set(WOLFSSL_ROOT "c:/test/my_wolfssl" ) + +if ( "${WOLFSSL_ROOT}" STREQUAL "") + set(WOLFSSL_ROOT "$ENV{WOLFSSL_ROOT}" ) +endif() + +if( "$ENV{IDF_PATH}" STREQUAL "" ) + message(FATAL_ERROR "IDF_PATH Environment variable not set!") +else() + string(REPLACE "\\" "/" THIS_IDF_PATH "$ENV{IDF_PATH}") +endif() + +# Optional compiler definitions to help with system name detection (typically printed by app diagnostics) +if(VERBOSE_COMPONENT_MESSAGES) + if(WIN32) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") + message(STATUS "Detected Windows") + endif() + if(CMAKE_HOST_UNIX) + message(STATUS "Detected UNIX") + endif() + if(APPLE) + message(STATUS "Detected APPLE") + endif() + if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") + message(STATUS "Detected WSL") + endif() + if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") + message(STATUS "Detected Linux") + endif() + if(APPLE) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") + message(STATUS "Detected Apple") + endif() +endif() # End optional WOLFSSL_CMAKE_SYSTEM_NAME + +message(STATUS "CONFIG_TARGET_PLATFORM = ${CONFIG_TARGET_PLATFORM}") + +# Check that there are not conflicting wolfSSL components +# The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl +# The local component wolfSSL directory will be in ./components/wolfssl +if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" ) + # These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake' + # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL) + # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl/include" EXCLUDE_FROM_ALL) + # So we'll error out and let the user decide how to proceed: + message(WARNING "\nFound wolfSSL components in\n" + "./managed_components/wolfssl__wolfssl\n" + "and\n" + "./components/wolfssl\n" + "in project directory: \n" + "${CMAKE_HOME_DIRECTORY}") + message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n" + "If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove " + "or rename the idf_component.yml file typically found in ./main/") +else() + message(STATUS "No conflicting wolfSSL components found.") +endif() + + +# Don't include lwip requirement for benchmark and test apps. +if( ("${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_benchmark") OR ("${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_test") ) + message(STATUS "Not including lwip for ${CMAKE_PROJECT_NAME}") +else() + # benchmark and test do not need wifi, everything else probably does: + set(COMPONENT_REQUIRES lwip "${THIS_ESP_TLS}") # we typically don't need lwip directly in wolfssl component +endif() + +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER message(STATUS "USERNAME = $ENV{USERNAME}") if( "$ENV{USER}" STREQUAL "" ) # the bash user if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user @@ -51,6 +181,25 @@ else() string(REPLACE "\\" "/" THIS_IDF_PATH "$ENV{IDF_PATH}") endif() +# ENVIRONMENT_VAR_TO_MACRO +# Check environment variable name EVARPARAM as [name] +# If defined, and has a value of EVARVALUE as [value], +# then assign a compiler definition "-D[name]=[value]" +function(ENVIRONMENT_VAR_TO_MACRO EVARPARAM EVARVALUE) + # If the EVARPARAM environment variable name is set to EVARVALUE, + # set the compiler flag definition to enable CSV output. + if ( "$ENV{${EVARPARAM}}" STREQUAL "${EVARVALUE}") + message(STATUS "Appending compile definition: -D${EVARPARAM}=${EVARVALUE}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${EVARPARAM}=${EVARVALUE}") + else() + if(DEFINED ENV{${EVARPARAM}}) + message(STATUS "Environment variable ${EVARPARAM} detected but set to $ENV{${EVARPARAM}}, not appending compile definition.") + else() + message(STATUS "Environment variable ${EVARPARAM} not detected, not appending compile definition.") + endif() + endif() +endfunction() + # COMPONENT_NAME = wolfssl # The component name is the directory name. "No feature to change this". # See https://github.com/espressif/esp-idf/issues/8978#issuecomment-1129892685 @@ -68,7 +217,8 @@ endif() # function: IS_WOLFSSL_SOURCE # parameter: DIRECTORY_PARAMETER - the directory to test # output: RESULT = contains contents of DIRECTORY_PARAMETER for wolfssl directory, otherwise blank. -function(IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER RESULT) +function( IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER + RESULT ) if (EXISTS "${DIRECTORY_PARAMETER}/wolfcrypt/src") set(${RESULT} "${DIRECTORY_PARAMETER}" PARENT_SCOPE) else() @@ -76,27 +226,71 @@ function(IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER RESULT) endif() endfunction() +# ********************************************************************************************* # function: FIND_WOLFSSL_DIRECTORY # parameter: OUTPUT_FOUND_WOLFSSL_DIRECTORY contains root of source code, otherwise blank # +# Example usage: +# FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) +# ********************************************************************************************* function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY) - message(STATUS "Starting FIND_WOLFSSL_DIRECTORY") - set(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}") - if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) - message(STATUS "The WOLFSSL_ROOT environment variable is not set. Searching...") + message(STATUS "Starting FIND_WOLFSSL_DIRECTORY: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + + if ( "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}" STREQUAL "" ) + # The parameter is empty, so we certainly need to search. + # First, see if there's an environment variable. This takes highest priority (unless already found as hard-coded, above) + set(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}") + if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) + message(STATUS "The WOLFSSL_ROOT environment variable is not set. Searching...") + # Next, if not found, see if wolfSSL was selected for ESP-TLS Kconfig + if(CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT) + set(CURRENT_SEARCH_DIR ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}) + get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" ABSOLUTE) + message(STATUS "WOLFSSL_ROOT found in sdkconfig/KConfig: ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") + else() + message(STATUS "wolfSSL not defined in [Component Config] [wolfssl]. Continuing search...") + # If not specified as a search hint in OUTPUT_FOUND_WOLFSSL_DIRECTORY: + # This wolfSSL component CMakeLists.txt may be found EITHER in: + # 1) local project component + # 2) ESP-IDF share components + # We'll start in the CMAKE_CURRENT_SOURCE_DIR, typically [something]/projectname/components/wolfssl + # That option might find wolfSSL source code as a copy in the component directory (e.g. Managed Components) + # Unless cmake is in the ESP-IDF, in which case it is unlikely to find wolfSSL source in any parent. + message(STATUS "CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}") + get_filename_component(CURRENT_SEARCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE) + message(STATUS "CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}") + string(LENGTH ${CURRENT_SEARCH_DIR} CURRENT_SEARCH_DIR_LENGTH) + endif() # CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT + endif() # check environment var blank else() - get_filename_component(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}" ABSOLUTE) + message(STATUS "Parameter found for FIND_WOLFSSL_DIRECTORY") + message(STATUS "Setting wolfSSL search directory to: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + set(CURRENT_SEARCH_DIR "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + endif() # parameter empty + + # Check to see if we found a path in environment or config settings, above. + if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) + message(STATUS "Source for wolfSSL not specified in path nor config settings.") + # We'll continue the search by recursing up the directory tree, below. + else() + # Setting found! Does it contain a valid path? + string(REPLACE "\\" "/" CURRENT_SEARCH_DIR ${CURRENT_SEARCH_DIR}) + get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" ABSOLUTE) IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSL) if( FOUND_WOLFSSL ) - message(STATUS "Found WOLFSSL_ROOT via Environment Variable: ${CURRENT_SEARCH_DIR}") + message(STATUS "Found wolfSSL source code via setting: ${CURRENT_SEARCH_DIR}") set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) return() else() - message(FATAL_ERROR "WOLFSSL_ROOT Environment Variable defined, but path not found:") - message(STATUS "$ENV{WOLFSSL_ROOT}") + if(WIN32) + message(STATUS "When specifying a path for Windows, use forward slahes, or double backslashes.") + endif() + message(STATUS "CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT sdkconfig setting = ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") + message(STATUS "WOLFSSL_ROOT Variable defined, but source code not found: ${CURRENT_SEARCH_DIR}") endif() endif() + # we'll start in the CMAKE_CURRENT_SOURCE_DIR, typically [something]/projectname/components/wolfssl message(STATUS "CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}") get_filename_component(CURRENT_SEARCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE) @@ -114,16 +308,47 @@ function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY) return() endif() + # Maintain CURRENT_SEARCH_DIR, but check various suffixes with CURRENT_SEARCH_DIR_ALT if( THIS_USER ) # Check for "wolfssl-[username]" subdirectory as we recurse up the directory tree set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl-${THIS_USER}) - message(STATUS "Looking in ${CURRENT_SEARCH_DIR}") + message(STATUS "Looking in ${CURRENT_SEARCH_DIR_ALT}") - #if(EXISTS ${CURRENT_SEARCH_DIR_ALT} AND IS_DIRECTORY ${CURRENT_SEARCH_DIR_ALT} AND EXISTS "${CURRENT_SEARCH_DIR_ALT}/wolfcrypt/src") IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL ) if ( FOUND_WOLFSSL ) - message(STATUS "Found wolfssl in user-suffix CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}") - set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR_ALT} PARENT_SCOPE) + message(STATUS "Found wolfssl in user-suffix CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}") + set(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR_ALT}") + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) + return() + endif() + endif() + + if ( FOUND_WOLFSSL ) + # if we already found the source, skip attempt of "wolfssl-master" + else() + set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl-master) + message(STATUS "Looking in ${CURRENT_SEARCH_DIR_ALT}") + + IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL ) + if ( FOUND_WOLFSSL ) + message(STATUS "Found wolfssl in master-suffix CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}") + set(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR_ALT}") + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) + return() + endif() + endif() + + if ( FOUND_WOLFSSL ) + # if we already found the source, skip attempt of "wolfssl" + else() + set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl) + message(STATUS "Looking in ${CURRENT_SEARCH_DIR_ALT}") + + IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL ) + if ( FOUND_WOLFSSL ) + message(STATUS "Found wolfssl in CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}") + set(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR_ALT}") + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) return() endif() endif() @@ -143,7 +368,8 @@ function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY) get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" DIRECTORY) message(STATUS "Next CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}") if( "${PRIOR_SEARCH_DIR}" STREQUAL "${CURRENT_SEARCH_DIR}" ) - # when the search directory is empty, we'll give up + # When the parent is current directory, cannot go any further. We didn't find wolfssl. + # When the search directory is empty, we'll give up. set(CURRENT_SEARCH_DIR "") endif() endwhile() @@ -154,17 +380,64 @@ endfunction() # Example usage: +# +# Simply find the WOLFSSL_DIRECTORY by searching parent directories: +# FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) +# +message(STATUS "CONFIG_TARGET_PLATFORM = ${CONFIG_TARGET_PLATFORM}") +# Check for environment variable that may be assigned to macros +ENVIRONMENT_VAR_TO_MACRO("GENERATE_MACHINE_PARSEABLE_REPORT" "1") +ENVIRONMENT_VAR_TO_MACRO("WOLFSSL_BENCHMARK_FIXED_CSV" "1") +# Optional variable inspection +if (0) + get_cmake_property(_variableNames VARIABLES) + list (SORT _variableNames) + message(STATUS "") + message(STATUS "ALL VARIABLES BEGIN") + message(STATUS "") + foreach (_variableName ${_variableNames}) + message(STATUS "${_variableName}=${${_variableName}}") + endforeach() + message(STATUS "") + message(STATUS "ALL VARIABLES END") + message(STATUS "") +endif() + +if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) + # There's no esp_timer, no driver components for the ESP8266 + message(STATUS "Early expansion EXCLUDES for esp8266:") + message(STATUS "THIS_INCLUDE_DRIVER: '${THIS_INCLUDE_DRIVER}'") + message(STATUS "THIS_INCLUDE_TIMER: '${THIS_INCLUDE_TIMER}'") + message(STATUS "Early expansion INCLUDE for esp8266:") + message(STATUS "THIS_INCLUDE_PTHREAD: '${THIS_INCLUDE_PTHREAD}'") + set(THIS_ESP_TLS "") + set(THIS_INCLUDE_DRIVER "") + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_PTHREAD "pthread") +else() + message(STATUS "Early expansion includes esp_timer: ${THIS_INCLUDE_TIMER}") + message(STATUS "Early expansion includes driver: ${THIS_INCLUDE_DRIVER}") + set(THIS_ESP_TLS "esp-tls") + set(THIS_INCLUDE_DRIVER "driver") + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_PTHREAD "") + # Let the app know that we've included the esp-tls component requirement. + # This is critical for use the the esp-tls component. See wolfssl esp_crt_bundle.c file. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_REQUIRED_ESP_TLS=1") +endif() if(CMAKE_BUILD_EARLY_EXPANSION) message(STATUS "wolfssl component CMAKE_BUILD_EARLY_EXPANSION:") idf_component_register( REQUIRES "${COMPONENT_REQUIRES}" PRIV_REQUIRES # esp_hw_support - # esp_timer - # driver # this will typically only be needed for wolfSSL benchmark + "${THIS_ESP_TLS}" + "${THIS_INCLUDE_PTHREAD}" + "${THIS_INCLUDE_TIMER}" + "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark ) else() @@ -173,48 +446,99 @@ else() message(STATUS "wolfssl component config:") message(STATUS "************************************************************************************************") + if ( "${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") + # There's no esp_timer, no driver components for the ESP8266 + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_DRIVER "") + else() + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_DRIVER "driver") + endif() + # search for wolfSSL FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) if(WOLFSSL_ROOT) - message(STATUS "NEW Found wolfssl directory at: ${WOLFSSL_ROOT}") + IS_WOLFSSL_SOURCE("${WOLFSSL_ROOT}" FOUND_WOLFSSL) + if(FOUND_WOLFSSL) + message(STATUS "Found WOLFSSL_ROOT via CMake specification.") + else() + # WOLFSSL_ROOT Path specified in CMakeLists.txt is not a valid path + message(FATAL_ERROR "WOLFSSL_ROOT CMake Variable defined, but path not found: ${WOLFSSL_ROOT}\n" + "Try correcting WOLFSSL_ROOT in your project CMakeFile.txt or setting environment variable.") + # Abort CMake after fatal error. + endif() else() - message(STATUS "NEW wolfssl directory not found.") + message(STATUS "Source code for wolfSSL still not found.") + message(STATUS "Searching from project home: ${CMAKE_HOME_DIRECTORY} ...") + set(WOLFSSL_ROOT "${CMAKE_HOME_DIRECTORY}") + FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) + endif() + + + if(WOLFSSL_ROOT) + message(STATUS "Confirmed wolfssl directory at: ${WOLFSSL_ROOT}") + else() + # Try to allow a more intuitive error that the source code was not found in cmake: + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_WARNING_SOURCE_NOT_FOUND") + + message(STATUS "Failed: wolfssl source code directory not found.") # Abort. We need wolfssl _somewhere_. - message(FATAL_ERROR "Could not find wolfssl in ${WOLFSSL_ROOT}.\n" - "Try setting WOLFSSL_ROOT environment variable or git clone.") + message(STATUS "") + message(STATUS "") + message(STATUS "Could not find wolfssl in any parent directory named wolfssl-${THIS_USER}, wolfssl-master, or wolfssl.\n" + "Try setting WOLFSSL_ROOT environment variable, cmake variable in project, copy source, or use managed components.") + message(STATUS "") + message(STATUS "") + # Abort CMake after fatal error. (or not?) endif() set(INCLUDE_PATH ${WOLFSSL_ROOT}) set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/src/") - if( ${CMAKE_PROJECT_NAME} STREQUAL "wolfssl_benchmark" ) - set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark") - endif() - - if( ${CMAKE_PROJECT_NAME} STREQUAL "wolfssl_test" ) - set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/test") + # During regression tests, optionally copy source locally and use: set(USE_LOCAL_TEST_BENCH 1) + set(USE_LOCAL_TEST_BENCH 0) + if(NOT USE_LOCAL_TEST_BENCH) + if( "${CMAKE_PROJECT_NAME}" STREQUAL "hello-world" ) + message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/benchmark") + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark") + endif() + + if( "${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_benchmark" ) + message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/benchmark") + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark") + endif() + + if( "${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_test" ) + message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/test") + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/test") + endif() endif() + message(STATUS "WOLFSSL_EXTRA_PROJECT_DIR = ${WOLFSSL_EXTRA_PROJECT_DIR}") set(COMPONENT_SRCDIRS "\"${WOLFSSL_ROOT}/src/\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif/esp_crt_bundle\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/atmel\"" "\"${WOLFSSL_EXTRA_PROJECT_DIR}\"" ) # COMPONENT_SRCDIRS message(STATUS "This COMPONENT_SRCDIRS = ${COMPONENT_SRCDIRS}") + # wolfSSL user_settings.h may be in the local project. + # TODO check if exists and possibly set to ESP-IDF set(WOLFSSL_PROJECT_DIR "${CMAKE_HOME_DIRECTORY}/components/wolfssl") - add_definitions(-DWOLFSSL_USER_SETTINGS_DIR="${WOLFSSL_PROJECT_DIR}/include/user_settings.h") - + string(REPLACE "/" "//" STR_WOLFSSL_PROJECT_DIR "${WOLFSSL_PROJECT_DIR}") + add_compile_definitions(WOLFSSL_USER_SETTINGS_DIR="${STR_WOLFSSL_PROJECT_DIR}/include/user_settings.h") + message(STATUS "Added definition for user_settings.h: -DWOLFSSL_USER_SETTINGS_DIR=\"${STR_WOLFSSL_PROJECT_DIR}//include//user_settings.h\"") # Espressif may take several passes through this makefile. Check to see if we found IDF string(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "" WOLFSSL_FOUND_IDF) # get a list of all wolfcrypt assembly files; we'll exclude them as they don't target Xtensa file(GLOB EXCLUDE_ASM *.S) - file(GLOB_RECURSE EXCLUDE_ASM ${CMAKE_SOURCE_DIR} "${WOLFSSL_ROOT}/wolfcrypt/src/*.S") + file(GLOB EXCLUDE_ASM ${CMAKE_SOURCE_DIR} "${WOLFSSL_ROOT}/wolfcrypt/src/*.S") message(STATUS "IDF_PATH = $ENV{IDF_PATH}") message(STATUS "PROJECT_SOURCE_DIR = ${PROJECT_SOURCE_DIR}") @@ -237,11 +561,12 @@ else() message(STATUS "Remove either the local project component: ${WOLFSSL_PROJECT_DIR} ") message(STATUS "or the Espressif shared component installed at: $ENV{IDF_PATH}/components/wolfssl/ ") message(STATUS "") - message(FATAL_ERROR "Please use wolfSSL in either local project or Espressif components, but not both.") message(STATUS "") message(STATUS "**************************************************************************************") message(STATUS "") + message(STATUS "Please use wolfSSL in either local project or Espressif components, but not both.") + # Optional: if you change the above FATAL_ERROR to STATUS you can warn at runtime with this macro definition: set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING") @@ -291,6 +616,7 @@ else() message(FATAL_ERROR "Found stray wolfSSL user_settings.h in " "${WOLFSSL_ROOT}/include/user_settings.h " " (please move it to ${WOLFSSL_PROJECT_DIR}/include/user_settings.h )") + # Abort CMake after fatal error. else() # we won't overwrite an existing user settings file, just note that we already have one: if( EXISTS "${WOLFSSL_PROJECT_DIR}/include/user_settings.h" ) @@ -347,7 +673,9 @@ else() # depending on the environment, we may need to swap backslashes with forward slashes string(REPLACE "\\" "/" RTOS_IDF_PATH "$ENV{IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") - string(REPLACE "\\" "/" WOLFSSL_ROOT ${WOLFSSL_ROOT}) + if(WOLFSSL_ROOT) + string(REPLACE "\\" "/" WOLFSSL_ROOT ${WOLFSSL_ROOT}) + endif() if(IS_DIRECTORY "${RTOS_IDF_PATH}") message(STATUS "Found current RTOS path: ${RTOS_IDF_PATH}") @@ -360,13 +688,14 @@ else() message(STATUS "Could not find RTOS path") endif() endif() - - + message(STATUS "THIS_IDF_PATH = $THIS_IDF_PATH") + # wolfSSL-specific include directories set(COMPONENT_ADD_INCLUDEDIRS - "./include" # this is the location of wolfssl user_settings.h + "./include" # this is the location of local project wolfssl user_settings.h "\"${WOLFSSL_ROOT}/\"" "\"${WOLFSSL_ROOT}/wolfssl/\"" "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/\"" + "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/port/Espressif\"" "\"${RTOS_IDF_PATH}/\"" # wolfSSL release after v5.7 includes WiFi, time, and mem/debug helpers "${THIS_IDF_PATH}/components/esp_event/include" @@ -374,7 +703,7 @@ else() "${THIS_IDF_PATH}/components/esp_wifi/include" ) - + # Optionally include cryptoauthlib if present if(IS_DIRECTORY ${IDF_PATH}/components/cryptoauthlib) list(APPEND COMPONENT_ADD_INCLUDEDIRS "../cryptoauthlib/lib") endif() @@ -383,7 +712,7 @@ else() list(APPEND COMPONENT_ADD_INCLUDEDIRS "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/\"") - + # Some files are known to be included elsewhere, or not used for Espressif set(COMPONENT_SRCEXCLUDE "\"${WOLFSSL_ROOT}/src/bio.c\"" "\"${WOLFSSL_ROOT}/src/conf.c\"" @@ -399,6 +728,8 @@ else() "\"${WOLFSSL_ROOT}/src/ssl_sess.c\"" # included by ssl.c "\"${WOLFSSL_ROOT}/src/x509.c\"" "\"${WOLFSSL_ROOT}/src/x509_str.c\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/ext_kyber.c\"" # external non-wolfssl Kyber disabled by default + "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/ext_kyber.h\"" # external non-wolfssl Kyber disabled by default "\"${WOLFSSL_ROOT}/wolfcrypt/src/evp.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/misc.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_arm32.c\"" @@ -409,6 +740,7 @@ else() "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_cortexm.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_x86_64.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_x86_64_asm.S\"" + "\"${WOLFSSL_ROOT}/examples\"" # Examples are distributed in Managed Components, but not part of a project. "\"${EXCLUDE_ASM}\"" ) @@ -430,22 +762,144 @@ else() # see https://docs.espressif.com/projects/esp-idf/en/stable/esp32/migration-guides/release-5.x/build-system.html?highlight=space%20path # set(EXTRA_COMPONENT_DIRS "${COMPONENT_SRCDIRS}") - idf_component_register( - SRC_DIRS "${COMPONENT_SRCDIRS}" - INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}" - REQUIRES "${COMPONENT_REQUIRES}" - EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}" - PRIV_REQUIRES esp_timer driver # this will typically only be needed for wolfSSL benchmark - ) - # some optional diagnostics - if (1) + + if(WOLFSSL_ROOT) + # Only register the component if we found wolfSSL source. + # This is important to allow Cmake to finish to completion, otherwise the UI + # may not be able to display the Kconfig settings to fix a bad or missing source. + idf_component_register( + SRC_DIRS "${COMPONENT_SRCDIRS}" + INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}" + REQUIRES "${COMPONENT_REQUIRES}" + EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}" + PRIV_REQUIRES + "${THIS_ESP_TLS}" + "${THIS_INCLUDE_TIMER}" + "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark + ) + else() + # Register the component simply to allow CMake to complete, but there's no wolfSSL source. + # Expect many other errors, but the project should at least be loadable and UI can edit Kconfig settings. + idf_component_register() + message(STATUS "Warning: wolfSSL component not registered as no source code found (WOLFSSL_ROOT is blank)") + endif() + +# function(WOLFSSL_INIT_CERT_BUNDLE) +if( CONFIG_WOLFSSL_CERTIFICATE_BUNDLE + AND NOT CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + AND NOT ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") + ) + if (CMAKE_BUILD_EARLY_EXPANSION) + message(ERROR "Bundle Cert initialization must occur during CMAKE_BUILD_EARLY_EXPANSION") + endif() + # reminder: we need a value for wolfSSL root first! + if( "${WOLFSSL_ROOT}" STREQUAL "" ) + message(ERROR "Certificate bundles need a value for WOLFSSL_ROOT") + endif() + set(WOLFSSL_ESP_CRT_BUNDLE_DIR ${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif/esp_crt_bundle) + message(STATUS "WOLFSSL_ESP_CRT_BUNDLE_DIR=${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + if(EXISTS "${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + set(bundle_name "x509_crt_bundle_wolfssl") + + # For now the certs are in the same directory + set(DEFAULT_CRT_DIR "${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + + # Generate custom certificate bundle using the generate_cert_bundle utility + set(GENERATE_CERT_BUNDLEPY ${python} ${WOLFSSL_ESP_CRT_BUNDLE_DIR}/gen_crt_bundle.py) + + if(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_all.pem ${DEFAULT_CRT_DIR}/cacrt_local.pem) + elseif(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_CMN) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_all.pem ${DEFAULT_CRT_DIR}/cacrt_local.pem) + list(APPEND args --filter ${DEFAULT_CRT_DIR}/cmn_crt_authorities.csv) + endif() + + # Add deprecated root certs if enabled. This config is not visible if the default cert + # bundle is not selected + if(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEPRECATED_LIST) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_deprecated.pem) + endif() + + if(CONFIG_WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE) + get_filename_component(custom_bundle_path + ${CONFIG_WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE_PATH} ABSOLUTE BASE_DIR "${project_dir}") + list(APPEND crt_paths ${custom_bundle_path}) + message(STATUS "Using a custom wolfSSL bundle path: ${custom_bundle_path}") + else() + message(STATUS "Not using a custom wolfSSL bundle path.") + endif() + list(APPEND args --input ${crt_paths} -q) + + message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") + get_filename_component(crt_bundle + ${bundle_name} + ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") + + message(STATUS "Setting up bundle generate: ${GENERATE_CERT_BUNDLEPY} ${args}") + message(STATUS "Depends on custom bundle path: ${custom_bundle_path}") + message(STATUS "crt_bundle ${crt_bundle}") + message(STATUS "COMPONENT_LIB ${COMPONENT_LIB}") + message(STATUS "GENERATE_CERT_BUNDLEPY ${GENERATE_CERT_BUNDLEPY}") + message(STATUS "args ${args}") + message(STATUS "cert_bundle ${cert_bundle}") + + # Generate bundle according to config + # File is generated at build time, not cmake load + add_custom_command(OUTPUT ${crt_bundle} + COMMAND ${GENERATE_CERT_BUNDLEPY} ARGS ${args} + DEPENDS ${custom_bundle_path} + VERBATIM) + + if(EXISTS "${crt_bundle}") + message(STATUS "Bundle file exists from prior build: ${crt_bundle}") + else() + message(STATUS "Bundle file expected during next build: ${crt_bundle}") + endif() + + # Reminder the file is generated at build time, not cmake load time. + message(STATUS "wolfSSL Cert Bundle File to be created at build time in: ${crt_bundle}") + + add_custom_target(custom_wolfssl_bundle DEPENDS ${cert_bundle}) + + # the wolfSSL crtificate bundle is baked into wolfSSL + add_dependencies(${COMPONENT_LIB} custom_wolfssl_bundle) + + # COMPONENT_LIB may vary: __idf_wolfssl, __idf_esp_wolfssl, etc + # target_add_binary_data(__idf_wolfssl ${crt_bundle} BINARY) + target_add_binary_data(${COMPONENT_LIB} ${crt_bundle} BINARY) + set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + APPEND PROPERTY ADDITIONAL_CLEAN_FILES + "${crt_bundle}") + else() + message(STATUS "WARNING: CONFIG_WOLFSSL_CERTIFICATE_BUNDLE enabled but directory not found: ${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + endif() +endif() + +# endfunction() # WOLFSSL_INIT_CERT_BUNDLE + + # Some optional diagnostics. Verbose ones are truncated. + if (VERBOSE_COMPONENT_MESSAGES) get_cmake_property(_variableNames VARIABLES) list (SORT _variableNames) message(STATUS "") message(STATUS "ALL VARIABLES BEGIN") message(STATUS "") foreach (_variableName ${_variableNames}) - message(STATUS "${_variableName}=${${_variableName}}") + if ( ("${_variableName}" STREQUAL "bootloader_binary_files") + OR ("${_variableName}" STREQUAL "Component paths") + OR ("${_variableName}" STREQUAL "component_targets") + OR ("${_variableName}" STREQUAL "__COMPONENT_TARGETS") + OR ("${_variableName}" STREQUAL "CONFIGS_LIST") + OR ("${_variableName}" STREQUAL "__CONFIG_VARIABLES") + OR ("${_variableName}" STREQUAL "val") + OR ("${_variableName}" MATCHES "^__idf_") + ) + # Truncate the displayed value: + string(SUBSTRING "${${_variableName}}" 0 70 truncatedValue) + message(STATUS "${_variableName} = ${truncatedValue} ... (truncated)") + else() + message(STATUS "${_variableName}=${${_variableName}}") + endif() endforeach() message(STATUS "") message(STATUS "ALL VARIABLES END") @@ -453,6 +907,12 @@ else() endif() # target_sources(wolfssl PRIVATE "\"${WOLFSSL_ROOT}/wolfssl/\"" "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt\"") + message(STATUS "DETECTED_PROJECT_NAME=${CMAKE_PROJECT_NAME}") + message(STATUS "COMPONENT_TARGET=${COMPONENT_TARGET}") + target_compile_definitions(${COMPONENT_TARGET} PRIVATE DETECTED_PROJECT_NAME="${CMAKE_PROJECT_NAME}") + if( "${CMAKE_PROJECT_NAME}" STREQUAL "esp_http_client_example" ) + target_compile_definitions(${COMPONENT_TARGET} PRIVATE APP_ESP_HTTP_CLIENT_EXAMPLE="y") + endif() endif() # CMAKE_BUILD_EARLY_EXPANSION @@ -498,7 +958,7 @@ function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) message(STATUS "Found ${VAR_OUPUT}=${VAR_VALUE}") # the interesting part is defining the VAR_OUPUT name a value to use in the app - add_definitions(-D${VAR_OUPUT}=\"${VAR_VALUE}\") + add_compile_definitions(${VAR_OUPUT}=\"${VAR_VALUE}\") else() # if we get here, check the execute_process command and parameters. message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT") @@ -506,33 +966,89 @@ function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) endif() endfunction() # LIBWOLFSSL_SAVE_INFO +execute_process( + COMMAND ${git_cmd} "rev-parse" "--is-inside-work-tree" + OUTPUT_VARIABLE IS_GIT_REPO + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + # create some programmatic #define values that will be used by ShowExtendedSystemInfo(). # see wolfcrypt\src\port\Espressif\esp32_utl.c -if(NOT CMAKE_BUILD_EARLY_EXPANSION) +if(NOT CMAKE_BUILD_EARLY_EXPANSION AND WOLFSSL_ROOT AND (IS_GIT_REPO STREQUAL "true")) set (git_cmd "git") message(STATUS "Adding macro definitions:") # LIBWOLFSSL_VERSION_GIT_ORIGIN: git config --get remote.origin.url - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "config" "--get" "remote.origin.url" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "config" "--get" "remote.origin.url" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_ORIGIN "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_BRANCH: git rev-parse --abbrev-ref HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--abbrev-ref" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--abbrev-ref" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_BRANCH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_HASH: git rev-parse HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_SHORT_HASH: git rev-parse --short HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_SHORT_HASH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_HASH_DATE git show --no-patch --no-notes --pretty=\'\%cd\' - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} + "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH_DATE "${TMP_OUT}" "${TMP_RES}") - message(STATUS "************************************************************************************************") - message(STATUS "wolfssl component config complete!") - message(STATUS "************************************************************************************************") + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_WOLFSSL_ROOT "${WOLFSSL_ROOT}" "${TMP_RES}") + endif() + +# Ensure flag "-DWOLFSSL_ESPIDF" is already in CMAKE_C_FLAGS if not yet found from project +string(FIND "${CMAKE_C_FLAGS}" "-DWOLFSSL_ESPIDF" FLAG_ALRREADY_FOUND_WOLFSSL_ESPIDF) + +if(FLAG_ALRREADY_FOUND_WOLFSSL_ESPIDF EQUAL -1) + # Flag not found, append it + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESPIDF") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +endif() + +if(WOLFSSL_ROOT) + message(STATUS "Using wolfSSL in ${WOLFSSL_ROOT}") + + # PlatformIO does not process script from from the Espressif cmake process. + # We need to know where wolfSSL source code was found, so save it in the + # PIO_WOLFSSL_ROOT environment variable to later be read by extra_script.py + + set(ENV{PIO_WOLFSSL_ROOT} "${WOLFSSL_ROOT}") + message(STATUS "PIO_WOLFSSL_ROOT = $ENV{PIO_WOLFSSL_ROOT}") + message(STATUS "PLATFORMIO_BUILD_DIR = $ENV{PLATFORMIO_BUILD_DIR}") + # See esp-tls Kconfig; menu "ESP-TLS", ESP_TLS_LIBRARY_CHOOSE + if(CONFIG_ESP_TLS_USING_WOLFSSL) + if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) + message(STATUS "This version of wolfSSL is not supported on the ESP8266 esp-tls at this time. Check ESP-TLS config") + else() + message(STATUS "wolfSSL will be used for ESP-TLS") + endif() + else() + message(STATUS "WARNING: wolfSSL NOT selected for ESP-TLS. Features and performance will be limited.") + endif() +else() + message(STATUS "") + message(STATUS "Consider setting WOLFSSL_ROOT environment variable, use Kconfig setting, or set manually in this cmake file, above.") + message(STATUS "") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "ERROR: Could not find wolfSSL Source Code") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") +endif() + +message(STATUS "************************************************************************************************") +message(STATUS "wolfSSL component config complete!") +message(STATUS "************************************************************************************************") diff --git a/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/Kconfig b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/Kconfig new file mode 100644 index 000000000..150913190 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/Kconfig @@ -0,0 +1,523 @@ +# Kconfig template +# +# Copyright (C) 2006-2025 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 +# + +# Kconfig File Version 5.7.2.001 for esp-idf integration + +# Kconfig Format Rules +# +# See: +# https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/kconfig.html +# +# Format rules for Kconfig files are as follows: +# +# Option names in any menus should have consistent prefixes. The prefix +# currently should have at least 3 characters. +# +# The unit of indentation should be 4 spaces. All sub-items belonging to a +# parent item are indented by one level deeper. For example, menu is indented +# by 0 spaces, config menu by 4 spaces, help in config by 8 spaces, and the +# text under help by 12 spaces. +# +# No trailing spaces are allowed at the end of the lines. +# +# The maximum length of options is NOT 50 characters as documented. +# kconfcheck will complain that options should be 40 at most. +# +# Fix option lengths first. Superfluous errors on other lines may occur. +# +# The maximum length of lines is 120 characters. +# +# python -m kconfcheck +# +# --------------------------------------------------------------------------------------------------------------------- +# Begin main wolfSSL configuration menu +# --------------------------------------------------------------------------------------------------------------------- +# See ESP-IDF esp-tls component for config TLS_STACK_WOLFSSL + +menu "wolfSSL" + + menu "Hardening" + config ESP_WOLFSSL_WC_NO_HARDEN + bool "Disable wolfSSL hardening" + default n + help + Sets WC_NO_HARDEN + + config ESP_WOLFSSL_TFM_TIMING_RESISTANT + bool "Enable TFM Timing Resistant Code" + default n + help + Sets TFM_TIMING_RESISTANT. + + endmenu # Hardening + + config ESP_WOLFSSL_ENABLE_BENCHMARK + bool "Enable wolfSSL Benchmark Library" + default n + help + Enables wolfcrypt/benchmark/benchmark.c code for benchmark metrics. Disables NO_CRYPT_BENCHMARK. + + + menu "Benchmark Debug" + config ESP_DEBUG_WOLFSSL_BENCHMARK_TIMING + bool "Enable benchmark timing debug" + depends on ESP_WOLFSSL_ENABLE_BENCHMARK + default n + help + Enable wolfssl debug for benchmark metric timing (CPU Cycles, RTOS ticks, etc). + + config ESP_WOLFSSL_BENCHMARK_TIMER_DEBUG + bool "Enable benchmark timer debug" + depends on ESP_WOLFSSL_ENABLE_BENCHMARK + default n + help + Turn on timer debugging (used when CPU cycles not available) + + endmenu # Benchmark Debug + + # ----------------------------------------------------------------------------------------------------------------- + # wolfCrypt Test + # ----------------------------------------------------------------------------------------------------------------- + config ESP_WOLFSSL_ENABLE_TEST + bool "Enable wolfCrypt Test Library" + default n + help + Enables wolfcrypt/test/test.c code for testing. Disables NO_CRYPT_TEST. + + menu "wolfCrypt tests" + config WOLFSSL_HAVE_WOLFCRYPT_TEST_OPTIONS + bool "Enable wolfCrypt Test Options" + depends on ESP_WOLFSSL_ENABLE_TEST + default n + help + Enables HAVE_WOLFCRYPT_TEST_OPTIONS + + config TEST_ESPIDF_ALL_WOLFSSL + bool "Enable all features to use in tests" + depends on ESP_WOLFSSL_ENABLE_TEST + default n + help + Enables TEST_ESPIDF_ALL_WOLFSSL + + endmenu # wolfCrypt tests + + # ----------------------------------------------------------------------------------------------------------------- + # Apple HomeKit Options + # ----------------------------------------------------------------------------------------------------------------- + menu "Apple HomeKit" + config WOLFSSL_APPLE_HOMEKIT + bool "Enable Apple HomeKit options" + default n + help + Enables FP_MAX_BITS (8192 * 2), SRP, ChaCha, Poly1305, Base64 encoding needed for Apple HomeKit. + endmenu # Apple HomeKit + # ----------------------------------------------------------------------------------------------------------------- + + config ESP_WOLFSSL_DISABLE_MY_ECC + bool "Disable ECC in my project" + default "n" + help + ECC is enabled by default. Select this option to disable. + + config ESP_WOLFSSL_ENABLE_MY_USE_RSA + bool "Enable RSA in my project" + default "n" + help + RSA is disabled by default. Select this option to enable. + + config ESP_WOLFSSL_BENCHMARK + bool "Enable wolfSSL Benchmark" + default n + help + Enables user settings relevant to benchmark code + + config ESP_TLS_USING_WOLFSSL_SPECIFIED + bool "Use the specified wolfssl for ESP-TLS" + default Y + help + Includes wolfSSL from specified directory (not using esp-wolfssl). + + config ESP_WOLFSSL_NO_USE_FAST_MATH + bool "Disable FAST_MATH library and all ESP32 Hardware Acceleration" + select ESP_WOLFSSL_NO_HW + select ESP_WOLFSSL_NO_HW_AES + select ESP_WOLFSSL_NO_HW_HASH + select ESP_WOLFSSL_NO_HW_RSA_PRI + select ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + default n + help + When disabling all hardware acceleration for smaller memory footprint, + disabling TFM fast math provides faster wolfSSL software algorithms in an + even smaller flash memory footprint. + + menu "Protocol Config" + config WOLFSSL_HAVE_ALPN + bool "Enable ALPN (Application Layer Protocol Negotiation) in wolfSSL" + default y + + config WOLFSSL_ALLOW_TLS13 + bool "Allow TLS 1.3" + default y + help + Allow TLS to fallback to TLS1.2. Memory footprint will likely be larger for TLS1.2. + When disabled HTTPS and MQTT over TLS connections will fail if TLS1.3 not accepted. + + config WOLFSSL_ALLOW_TLS12 + bool "Allow TLS 1.2" + default n + help + Allow TLS to fallback to TLS1.2. Memory footprint will likely be larger for TLS1.2. + When disabled HTTPS and MQTT over TLS connections will fail if TLS1.3 not accepted. + + config WOLFSSL_HAVE_TLS_EXTENSIONS + bool "Enable TLS Extensions" + default y + help + Sets HAVE_TLS_EXTENSIONS which is needed for TLS 1.3, SNI, ALPN, and more. + + config WOLFSSL_ALT_CERT_CHAINS + bool "Enable Alternate Certificate Chains" + default n + help + The option relaxes the default strict wolfSSL certificate chain processing. This + will typically need to be enabled when loading only a CA file. Typically solves + the -188 ASN_NO_SIGNER_E error. Use with caution. + + config WOLFSSL_HAVE_OCSP + bool "Enable OCSP (Online Certificate Status Protocol) in wolfSSL" + default n + help + Sets HAVE_OCSP + + endmenu # Protocol Config + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + config TLS_STACK_WOLFSSL + # Invisible option that locks TLS_STACK_WOLFSSL to ESP_TLS_USING_WOLFSSL + bool + default n + select FREERTOS_ENABLE_BACKWARD_COMPATIBILITY + help + Includes wolfSSL in ESP-TLS so that it can be compiled with wolfSSL as its SSL/TLS library. + Enabled when wolfSSL is selected in ESP_TLS_LIBRARY_CHOOSE. + + menu "wolfSSL ESP-TLS" + depends on ESP_TLS_USING_WOLFSSL + + menu "Certificate Bundle" + depends on ESP_TLS_USING_WOLFSSL + + config WOLFSSL_CERTIFICATE_BUNDLE + bool "Enable trusted root certificate bundle" + default y if ESP_TLS_USING_WOLFSSL + default n + depends on ESP_TLS_USING_WOLFSSL + help + Enable support for large number of default root certificates + + When enabled this option allows user to store default as well + as customer specific root certificates in compressed format rather + than storing full certificate. For the root certificates the public key and the subject name + will be stored. + + config WOLFSSL_NO_ASN_STRICT + bool "Relax Certificate ASN Strict Checks" + default n + depends on ESP_TLS_USING_WOLFSSL + help + Allows sub-optimal certificate ASN checks. Unless using a bundle with known issues, + it is recommended to NOT enable this. + + config WOLFSSL_ASN_ALLOW_0_SERIAL + bool "Allow cert missing an ASN Serial Number" + default y + depends on ESP_TLS_USING_WOLFSSL + help + Although not recommended, there may be certificates in the bundle that are missing + a serial number. This option allows the missing value without having to fully + disable strict ASN checking with WOLFSSL_NO_ASN_STRICT. + + choice WOLFSSL_DEFAULT_CERTIFICATE_BUNDLE + bool "Default certificate bundle options" + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + default WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL + + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL + bool "Use the full default certificate bundle" + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_CMN + bool "Use only the most common certificates from the default bundles" + help + Use only the most common certificates from the default bundles, reducing the size with 50%, + while still having around 99% coverage. + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + bool "Do not use the default certificate bundle" + endchoice + + config WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + default n + bool "Add custom certificates to the default bundle" + config WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE_PATH + depends on WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + string "Custom certificate bundle path" + help + Name of the custom certificate directory or file. This path is evaluated + relative to the project root directory. + + config WOLFSSL_CERTIFICATE_BUNDLE_DEPRECATED_LIST + bool "Add deprecated root certificates" + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL && !WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + help + Include the deprecated list of root certificates in the bundle. + This list gets updated when a certificate is removed from the Mozilla's + NSS root certificate store. This config can be enabled if you would like + to ensure that none of the certificates that were deployed in the product + are affected because of the update to bundle. In turn, enabling this + config keeps expired, retracted certificates in the bundle and it may + pose a security risk. + + - Deprecated cert list may grow based based on sync with upstream bundle + - Deprecated certs would be be removed in ESP-IDF (next) major release + + config WOLFSSL_CERTIFICATE_BUNDLE_MAX_CERTS + int "Maximum no of certificates allowed in certificate bundle" + default 200 + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + + endmenu + endmenu # wolfSSL ESP-TLS + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + config ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + bool "Modify default hardware acceleration settings" + default n + help + When disabling all hardware acceleration for smaller memory footprint, + disabling TFM fast math provides faster wolfSSL software algorithms in an + even smaller flash memory footprint. + Typically used for debugging, analysis, or optimizations. The default + hardware acceleration features can be each manually adjusted. + + menu "wolfSSL Hardware Acceleration" + + config ESP_WOLFSSL_NO_ESP32_CRYPT + bool "Disable all ESP32 Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + select ESP_WOLFSSL_NO_HW_AES + select ESP_WOLFSSL_NO_HW_HASH + select ESP_WOLFSSL_NO_HW_RSA_PRI + select ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + help + Hardware acceleration enabled by default. When selected defines: NO_ESP32_CRYPT. + Consider disabling FASTMATH (other libraries are faster in software and smaller) + + config ESP_WOLFSSL_NO_HW_AES + bool "Disable all ESP32 AES Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default.When selected defines: NO_HW_AES + + config ESP_WOLFSSL_NO_HW_HASH + bool "Disable all ESP32 SHA Hash Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_HASH + + config ESP_WOLFSSL_NO_HW_RSA_PRI + bool "Disable all ESP32 RSA Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + select ESP_WOLFSSL_NO_HW_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI + + config ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + bool "Disable all ESP32 Multiplication Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI_MP_MUL + + config ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + bool "Disable all ESP32 Modular Multiplication Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI_MULMOD + + config ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + bool "Disable all ESP32 RSA Exponential Math Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. + Select this option to force disable: NO_HW_RSA_PRI_EXPTMOD + + config ESP_WOLFSSL_DEBUG_ESP_HW_MULTI_RSAMAX_BITS + bool "Enable debugging of RSA Multiplication operand length" + default n + help + Prints an esp log warning to the default console UART when one of the + multiplication operands exceeds the maximum size supported by hardware, + requiring fallback to software. This can be helpful to pick key sizes + when performance is critical. See also metrics for counting instances. + + config ESP_WOLFSSL_DEBUG_ESP_HW_MOD_RSAMAX_BITS + bool "Enable debugging of RSA Modular operand length" + default n + help + Prints an esp log warning to the default console UART when one of the + modular math operands exceeds the maximum size supported by hardware, + requiring fallback to software. This can be helpful to pick key sizes + when performance is critical. See also metrics for counting instances. + + endmenu # wolfSSL Hardware Acceleration + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Experimental Options" + + config ESP_WOLFSSL_EXPERIMENTAL_SETTINGS + bool "Enable wolfSSL Experimental Settings" + default n + help + Enables experimental settings for wolfSSL. See documentation. + + config ESP_WOLFSSL_ENABLE_KYBER + bool "Enable wolfSSL Kyber" + default n + help + Enable debugging messages for wolfSSL. See user_settings.h for additional debug options. + + endmenu # wolfSSL Experimental Options + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Debug Options" + config ESP_WOLFSSL_DEBUG_WOLFSSL + bool "Enable wolfSSL Debugging" + default n + help + Enable debugging messages for wolfSSL. See user_settings.h for additional debug options. + + config ESP_WOLFSSL_TEST_LOOP + bool "Run test apps in a loop until failure" + default y + help + Enable a loop wrapper for benchmark, http_client, and wolfssl test apps. + + endmenu # wolfSSL Debug Options + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Customization" + config CUSTOM_SETTING_WOLFSSL_ROOT + string "Enter a path for wolfSSL source code" + default "~/workspace/wolfssl" + help + This option lets you specify a directory for the wolfSSL source code (typically a git clone). + Enter the path using forward slashes (e.g., C:/myfolder/mysubfolder) or double backslashes + (e.g., C:\\myfolder\\mysubfolder). + + endmenu # wolfSSL Customization + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "Component Config" + config IGNORE_ESP_IDF_WOLFSSL_COMPONENT + bool "Ignore the ESP-IDF component of wolfSSL (if present)" + default n + help + Ignores wolfSSL present in the esp-idf/components directory. Requires wolfssl as a local component. + + config IGNORE_LOCAL_WOLFSSL_COMPONENT + bool "Ignore the local component of wolfSSL (if present)" + default n + help + Ignores wolfSSL present in the local project components directory. + Requires wolfssl as a ESP-IDF component. + + endmenu # Component Config + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "Utility Config" + config USE_WOLFSSL_ESP_SDK_TIME + bool "Enable wolfSSL time helper functions" + default n + help + Enables use of various time and date setting functions found in the esp-sdk-lib.h file. + + config USE_WOLFSSL_ESP_SDK_WIFI + bool "Enable wolfSSL WiFi helper functions" + default n + help + Enables use of various time and date setting functions found in the esp-sdk-lib.h file. + + endmenu # Utility Config +endmenu # wolfSSL +# --------------------------------------------------------------------------------------------------------------------- + + +# --------------------------------------------------------------------------------------------------------------------- +menu "wolfSSH" + config ESP_ENABLE_WOLFSSH + bool "Enable wolfSSH options" + default n + help + Enables WOLFSSH_TERM, WOLFSSL_KEY_GEN, WOLFSSL_PTHREADS, WOLFSSH_TEST_SERVER, WOLFSSH_TEST_THREADING + + config ESP_WOLFSSL_DEBUG_WOLFSSH + bool "Enable wolfSSH debugging" + default n + help + Enable wolfSSH debugging macro. See user_settings.h + +endmenu # wolfSSH +# --------------------------------------------------------------------------------------------------------------------- + +# --------------------------------------------------------------------------------------------------------------------- +menu "wolfMQTT" + config ESP_ENABLE_WOLFMQTT + bool "Enable wolfMQTT options" + default n + help + Enables WOLFMQTT + + config ESP_WOLFSSL_DEBUG_WOLFMQTT + bool "Enable wolfMQTT debugging" + default n + help + Enable wolfMQTT debugging macro. See user_settings.h + +endmenu # wolfMQTT +# --------------------------------------------------------------------------------------------------------------------- diff --git a/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/README.md b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/README.md new file mode 100644 index 000000000..d77912416 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/README.md @@ -0,0 +1,162 @@ +# wolfSSL Espressif Component + +This is the directory for wolfSSL as an Espressif ESP-IDF component. + +Other options are available, such as installing wolfSSL as a local _project_ component using the [Managed Component](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/). + +Enabling this wolfSSL ESP-IDF component allows other ESP-IDF libraries such as those that depend on [ESP-TLS](https://github.com/espressif/esp-idf/tree/master/components/esp-tls) +to also use the wolfSSL library. (See [github.com/wolfSSL/wolfssl](https://github.com/wolfSSL/wolfssl)) + +The wolfSSL source code is not included here. Instead, the `idf.py menuconfig` option can be used to configure the +`sdkconfig` file setting: `CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT` to point to the desired wolfSSL code. + +## Directory Contents + +This directory must contain, at a minimum: + +- `CMakeLists.txt` +- `./include/user_settings.h` + +The directory should also contain: +- `Kconfig` +- `component.mk` + +The directory may contain wolfSSL source, for example with a [Managed Component](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/), +or if the `setup.sh` script was used from [wolfSSL/IDE/Espressif/ESP-IDF](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF). + + +Under normal circumstances when the wolfSSL source is not included here, the `CMakeLists.txt` will search for it in this order: + +- A hard-coded `WOLFSSL_ROOT` cmake variable. +- `WOLFSSL_ROOT` Environment Variable +- The `CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT` value in the `sdkconfig` file, from the `Kconfig` option. +- Any parent directories, up to the root (if this directory is in the ESP-IDF components) +- Any parent directories, up to the root (if this directory is a project component) + +While recursing up the directory tree, the following names of wolfSSL directories will be considered: + +- `wolfssl-[current user name]` +- `wolfssl-master` +- `wolfssl` + +## Getting Started + +See the `Espressif Getting Started Guide`. + +``` +# Set environment variable to ESP-IDF location +# For example, VisualGDB in WSL +WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.2 +WRK_IDF_PATH=/mnt/c/SysGCC/esp32-master/esp-idf/v5.3-master + +# Or wherever the ESP-IDF is installed: +WRK_IDF_PATH=~/esp/esp-idf + +echo "Run export.sh from ${WRK_IDF_PATH}" +. ${WRK_IDF_PATH}/export.sh + +cd [your project] + +idf.py menuconfig +``` + +Enable wolfSSL to be used in the ESP-TLS: + +``` +Component config ---> + ESP-TLS ---> + Choose SSL/TLS library for ESP-TLS (See help for more Info) + (X) wolfSSL (License info in wolfSSL directory README) +``` + +Adjust wolfSSL settings, such as path to source code as needed: + +``` +Component config ---> + wolfSSL ---> + [*] Include wolfSSL in ESP-TLS + [*] Use the specified wolfssl for ESP-TLS + (~/workspace/wolfssl) Enter a path for wolfSSL source code +``` + +## Configuration + +All settings for wolfSSL are adjusted in the [include/user_settings.h](./include/user_settings.h) file. + +The `user_settings.h` file should not be included directly. Instead, `#include ` +before any other wolfSSL headers, like this: + + +```c +/* ESP-IDF */ +#include +#include "sdkconfig.h" + +/* wolfSSL */ +/* Always include wolfcrypt/settings.h before any other wolfSSL file. */ +/* Reminder: settings.h pulls in user_settings.h; don't include it here. */ +#if defined(WOLFSSL_USER_SETTINGS) + #include + #if defined(WOLFSSL_ESPIDF) + #include + #include + #include + #include + #include + #else + #error "Problem with wolfSSL user_settings. " \ + "Check components/wolfssl/include " \ + "and confirm WOLFSSL_USER_SETTINGS is defined, " \ + "typically in the component CMakeLists.txt" + #endif +#else + /* Define WOLFSSL_USER_SETTINGS project wide for settings.h to include */ + /* wolfSSL user settings in ./components/wolfssl/include/user_settings.h */ + #error "Missing WOLFSSL_USER_SETTINGS in CMakeLists or Makefile:\ + CFLAGS +=-DWOLFSSL_USER_SETTINGS" +#endif +``` + +## Examples + +See the wolfSSL examples: + +- [wolfSSL Core Examples](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples) +- [wolfSSL Additional Examples](https://github.com/wolfSSL/wolfssl-examples/tree/master/ESP32) +- [wolfSSH Core Examples](https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples) +- [wolfSSH Additional Examples](https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif) +- [wolfMQTT Examples](https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples) + +## Platforms + +The ESP-IDF wolfSSL is also available for PlatformIO: + +- [Release wolfSSL](https://registry.platformio.org/search?q=owner%3Awolfssl) +- [Staging / Preview wolfSSL](https://registry.platformio.org/search?q=owner%3Awolfssl-staging) + +The wolfSSL library can also be used for Espressif with Arduino: + +- [arduino.cc/reference/en/libraries/wolfssl](https://www.arduino.cc/reference/en/libraries/wolfssl/) +- [github.com/wolfSSL/Arduino-wolfSSL](https://github.com/wolfSSL/Arduino-wolfSSL) + + +## Additional Information + +- [wolfSSL Documentation](https://www.wolfssl.com/documentation/manuals/wolfssl/index.html) and [docs/espressif](https://www.wolfssl.com/docs/espressif/) +- [wolfSSL FAQ](https://www.wolfssl.com/docs/frequently-asked-questions-faq/) +- [wolfSSL Products](https://www.wolfssl.com/products/) +- [www.wolfssl.com/espressif](https://www.wolfssl.com/espressif/) +- [More...](https://www.wolfssl.com/?s=espressif) + +## Contact + +Have a specific request or questions? We'd love to hear from you! Please contact us at support@wolfssl.com or open an issue on GitHub. + +## Licensing and Support + +wolfSSL (formerly known as CyaSSL) and wolfCrypt are either licensed for use under the GPLv2 (or at your option any later version) or a standard commercial license. For our users who cannot use wolfSSL under GPLv2 (or any later version), a commercial license to wolfSSL and wolfCrypt is available. + +See the LICENSE.txt, visit wolfssl.com/license, contact us at licensing@wolfssl.com or call +1 425 245 8247 + +View Commercial Support Options: [wolfssl.com/products/support-and-maintenance](wolfssl.com/products/support-and-maintenance) + diff --git a/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/component.mk b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/component.mk new file mode 100644 index 000000000..f94bd617d --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/component.mk @@ -0,0 +1,306 @@ +# +# Copyright (C) 2006-2025 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 +# + +$(info *********** wolfssl component ************) + +# +# Component Makefile +# +# +# The Espressif Managed Components are only for newer versions of the ESP-IDF +# Typically only for ESP32[-x] targets and only for ESP-IDF v4.3 or later: +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html +# https://components.espressif.com/ +# +# Usage: +# +# make flash +# +# make flash ESPPORT=/dev/ttyS55 +# +# make flash ESPBAUD=9600 +# +# make monitor ESPPORT=COM1 +# +# make monitor ESPPORT=/dev/ttyS55 MONITORBAUD=115200 +# +# export ESPPORT=/dev/ttyS55 +# +# https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/index.html +# + +# Although the project should define WOLFSSL_USER_SETTINGS, we'll also +# define it here: +CFLAGS +=-DWOLFSSL_USER_SETTINGS + +# Note that 4 source files created by autogen are excluded here. +# +# See these files commented out, below. Adjust as needed for your application: +# +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/async.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/selftest.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_first.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_last.o + + +# NOTICE: the WOLFSSL_ROOT setting MUST be relative! +# See https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/api-guides/build-system.html?highlight=must+relative#optional-component-specific-variables +# In the wolfSSL GitHub examples for Espressif: +# https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples +# When this wolfssl component.mk makefile is in [project]/components/wolfssl +# The root is 7 directories up from here (the location of of this component.mk): +# +WOLFSSL_ROOT ?= ../../../../../../.. +THIS_DIR := $(shell pwd) +WOLFSSL_ROOT_OBJ := $(THIS_DIR) + +# When running make from commandline or VisualGDB, the current path varies: +ifeq ("$(VISUALGDB_DIR)","") + # current path is typically /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/wolfssl + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL)) +else + # current path is typically /C/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/Debug/wolfssl + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL)) +endif + +# To set the location of a different location, it is best to use relative paths. +# +# Set WOLFSSL_ROOT to a relative path from the current component directory. +# For example, if the wolfssl_client is copied from the examples to test: +# +# cp -r /IDE/Espressif/ESP-IDF/examples/wolfssl_client/* /mnt/c/test/demo +# +# we run make in /mnt/c/test/demo +# component is in /mnt/c/test/demo/components/wolfssl +# wolfssl is in /mnt/c/workspace/wolfssl-master +# +# "/mnt/c" is 4 directories up: +# 2 for `./test/demo` from where we run `make`, plus +# 2 more from the location of `component.mk` located +# in `[current directory]/components/wolfssl`. +# +# Thus we need 4 parent reference to find the relative path to wolfSSL: +# WOLFSSL_ROOT := ../../../../workspace/wolfssl-master + +# Optional CFLAGS (make works without these; for reference only) +# CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl +# CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt +# CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif + +abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) + +# print-wolfssl-path-value: +# @echo "WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)" +# @echo "WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)" + +$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info THIS_DIR defined: $(THIS_DIR)) +$(info WOLFSSL_ROOT_OBJ defined: $(WOLFSSL_ROOT_OBJ)) + +# NOTE: The wolfSSL include directory (e.g. user_settings.h) is +# located HERE in THIS project, and *not* in the wolfSSL root. +COMPONENT_ADD_INCLUDEDIRS := . +COMPONENT_ADD_INCLUDEDIRS += include +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/. +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif + +# COMPONENT_ADD_INCLUDEDIRS += $ENV(IDF_PATH)/components/freertos/include/freertos +# COMPONENT_ADD_INCLUDEDIRS += "$ENV(IDF_PATH)/soc/esp32s3/include/soc" + +# wolfSSL +COMPONENT_SRCDIRS := $(WOLFSSL_ROOT)/src + +# wolfcrypt +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src + +# Espressif +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/atmel + +COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/evp.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/misc.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/sha512_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/fe_x25519_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_gcm_x86_asm.o + +## +## wolfSSL +## +## reminder object files may end up in `./build` or `build/debug` or `build/release`, depending on build environment & settings. +## +# COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o # part of ssl.c, omitted to avoid "does not need to be compiled separately" +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/conf.o # part of ssl.c +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/crl.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls13.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/internal.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/keys.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ocsp.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/pk.o # part of ssl.c +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/quic.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/sniffer.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o +# COMPONENT_OBJS += src/ssl_asn1.o +# COMPONENT_OBJS += src/ssl_bn.o +# COMPONENT_OBJS += src/ssl_certman.o +# COMPONENT_OBJS += src/ssl_crypto.o +# COMPONENT_OBJS += src/ssl_misc.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls13.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/wolfio.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509.o # part of ssl.c +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509_str.o # part of ssl.c + +## +## wolfcrypt +## +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/aes.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/arc4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/asm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/asn.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/async.o # autogen exclusion +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/blake2b.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/blake2s.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/camellia.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/chacha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/chacha20_poly1305.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/cmac.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/coding.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/compress.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/cpuid.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/cryptocb.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/curve25519.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/curve448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/des3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/dh.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/dilithium.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/dsa.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ecc.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/eccsi.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ecc_fp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ed25519.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ed448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/error.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/evp.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_mlkem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_lms.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_xmss.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/falcon.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_low_mem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_operations.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fips.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fips_test.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ge_448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ge_low_mem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ge_operations.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/hash.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/hmac.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/hpke.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/integer.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/kdf.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/logging.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/md2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/md4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/md5.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/memory.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/misc.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/pkcs12.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/pkcs7.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/poly1305.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/pwdbased.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/random.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/rc2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ripemd.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/rsa.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sakke.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/selftest.o # autogen exclusion +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha256.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha512.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/signature.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/siphash.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sm2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sm3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sm4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sphincs.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_arm32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_arm64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_armthumb.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_c32.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_c64.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_cortexm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_dsp32.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_int.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_arm32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_arm64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_armthumb.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_c32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_c64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_cortexm.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_x86_64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_x86_64.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/srp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/tfm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_dsp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_encrypt.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_mlkem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_mlkem_poly.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_lms.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_pkcs11.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_port.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_xmss.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_first.o # autogen exclusion +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_last.o # autogen exclusion +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfevent.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfmath.o + +## +## Espressif +## +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp32_aes.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp32_mp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp32_sha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp32_util.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_mem_lib.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_time_lib.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_wifi_lib.o + +## +## wolfcrypt benchmark (optional) +## +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark +## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark + + +## +## wolfcrypt test (optional) +## +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test +## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test/include + +$(info ********** end wolfssl component **********) 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 1a13d10fe..8da276d1e 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 @@ -1,6 +1,6 @@ -/* user_settings.h +/* wolfssl-component include/user_settings.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -18,19 +18,57 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ +#define WOLFSSL_ESPIDF_COMPONENT_VERSION 0x01 + +/* Examples such as test and benchmark are known to cause watchdog timeouts. + * Note this is often set in project Makefile: + * CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 */ +#define WOLFSSL_ESP_NO_WATCHDOG 1 + +/* The Espressif project config file. See also sdkconfig.defaults */ +#include "sdkconfig.h" /* This user_settings.h is for Espressif ESP-IDF * * Standardized wolfSSL Espressif ESP32 + ESP8266 user_settings.h V5.7.0-1 * - * Do not include any wolfssl headers here + * Do not include any wolfssl headers here. * * When editing this file: - * ensure wolfssl_test and wolfssl_benchmark settings match. + * ensure all examples match. The template example is the reference. */ -/* The Espressif project config file. See also sdkconfig.defaults */ -#include "sdkconfig.h" +/* Naming convention: (see also esp32-crypt.h for the reference source). + * + * CONFIG_ + * This prefix indicates the setting came from the sdkconfig / Kconfig. + * + * May or may not be related to wolfSSL. + * + * The name after this prefix must exactly match that in the Kconfig file. + * + * WOLFSSL_ + * Typical of many, but not all wolfSSL macro names. + * + * Applies to all wolfSSL products such as wolfSSH, wolfMQTT, etc. + * + * May or may not have a corresponding sdkconfig / Kconfig control. + * + * ESP_WOLFSSL_ + * These are NOT valid wolfSSL macro names. These are names only used in + * the ESP-IDF Kconfig files. When parsed, they will have a "CONFIG_" + * suffix added. See next section. + * + * CONFIG_ESP_WOLFSSL_ + * This is a wolfSSL-specific macro that has been defined in the ESP-IDF + * via the sdkconfig / menuconfig. Any text after this prefix should + * exactly match an existing wolfSSL macro name. + * + * Applies to all wolfSSL products such as wolfSSH, wolfMQTT, etc. + * + * These macros may also be specific to only the project or environment, + * and possibly not used anywhere else in the wolfSSL libraries. + */ /* The Espressif sdkconfig will have chipset info. ** @@ -46,33 +84,264 @@ #undef WOLFSSL_ESPIDF #define WOLFSSL_ESPIDF -/* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ -#define NO_ESP_SDK_WIFI +/* Test various user_settings between applications by selecting example apps + * in `idf.py menuconfig` for Example wolfSSL Configuration settings: */ + +/* Turn on messages that are useful to see only in examples. */ +#define WOLFSSL_EXAMPLE_VERBOSITY + +/* Paths can be long, ensure the entire value printed during debug */ +#define WOLFSSL_MAX_ERROR_SZ 500 + +/* wolfSSL Examples: set macros used in example applications. + * + * These Settings NOT available in ESP-IDF (e.g. esp-tls) + * + * Any settings needed by ESP-IDF components should be explicitly set, + * and not by these example-specific settings via CONFIG_WOLFSSL_EXAMPLE_n + * + * ESP-IDF settings should be Kconfig "CONFIG_[name]" values when possible. */ +#if defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TEMPLATE) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/template */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TEST) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_test */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ + #define TEST_ESPIDF_ALL_WOLFSSL +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_BENCHMARK) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ + #define WOLFSSL_BENCHMARK_FIXED_UNITS_KB +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_CLIENT) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_client */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_SERVER) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_server */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfSSH Examples */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSH_TEMPLATE) + /* See https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples/wolfssh_template */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSH_ECHOSERVER) + /* See https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_ESP32_SSH_SERVER) + /* See https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif/ESP32/ESP32-SSH-Server */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_ESP8266_SSH_SERVER) + /* See https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif/ESP8266/ESP8266-SSH-Server */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfMQTT Examples */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFMQTT_TEMPLATE) + /* See https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples/wolfmqtt_template */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFMQTT_AWS_IOT_MQTT) + /* See https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples/AWS_IoT_MQTT */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfTPM Examples */ +#elif defined(CONFIG_WOLFTPM_EXAMPLE_NAME_ESPRESSIF) + /* See https://github.com/wolfSSL/wolfTPM/tree/master/IDE/Espressif */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* Apple HomeKit Examples */ +#elif defined(CONFIG_WOLFSSL_APPLE_HOMEKIT) + /* See https://github.com/AchimPieters/esp32-homekit-demo */ + +/* no example selected */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_NONE) + /* We'll assume the app needs to use wolfSSL sdk lib function */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* Other applications detected by cmake */ +#elif defined(APP_ESP_HTTP_CLIENT_EXAMPLE) + /* The wolfSSL Version of the client example */ + #if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C2) + /* Less memory available, so smaller key sizes: */ + #define FP_MAX_BITS (4096 * 2) + #else + #define FP_MAX_BITS (8192 * 2) + #endif + #define HAVE_ALPN + #define HAVE_SNI + #define OPENSSL_EXTRA_X509_SMALL + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES + #define OPENSSL_EXTRA + #ifndef WOLFSSL_ALWAYS_VERIFY_CB + #define WOLFSSL_ALWAYS_VERIFY_CB + #endif + #ifndef WOLFSSL_VERIFY_CB_ALL_CERTS + #define WOLFSSL_VERIFY_CB_ALL_CERTS + #endif + #ifndef KEEP_PEER_CERT + #define KEEP_PEER_CERT + #endif + +#elif defined(APP_ESP_HTTP_CLIENT) + /* The ESP-IDF Version */ + #define FP_MAX_BITS (8192 * 2) + #define HAVE_ALPN + #define HAVE_SNI + #define OPENSSL_EXTRA_X509_SMALL + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES + #define OPENSSL_EXTRA + #ifndef WOLFSSL_ALWAYS_VERIFY_CB + #define WOLFSSL_ALWAYS_VERIFY_CB + #endif + #ifndef WOLFSSL_VERIFY_CB_ALL_CERTS + #define WOLFSSL_VERIFY_CB_ALL_CERTS + #endif + #ifndef KEEP_PEER_CERT + #define KEEP_PEER_CERT + #endif +#else + #ifdef WOLFSSL_ESPIDF + /* #warning "App config undetected" */ + #endif + /* the code is older or does not have application name defined. */ +#endif /* Example wolfSSL Configuration app settings */ /* Experimental Kyber */ -#if 0 +#ifdef CONFIG_WOLFSSL_ENABLE_KYBER /* Kyber typically needs a minimum 10K stack */ #define WOLFSSL_EXPERIMENTAL_SETTINGS - #define WOLFSSL_HAVE_KYBER - #define WOLFSSL_WC_KYBER + #define WOLFSSL_HAVE_MLKEM + #define WOLFSSL_WC_MLKEM #define WOLFSSL_SHA3 + #if defined(CONFIG_IDF_TARGET_ESP8266) + /* With limited RAM, we'll disable some of the Kyber sizes: */ + #define WOLFSSL_NO_KYBER1024 + #define WOLFSSL_NO_KYBER768 + #define NO_SESSION_CACHE + #endif #endif +/* Enable AES for all examples */ +#ifdef NO_AES + #warning "Found NO_AES, wolfSSL AES Cannot be enabled. Check config." +#else + #define WOLFSSL_AES + #define WOLFSSL_AES_COUNTER + + /* Typically only needed for wolfssl_test, see docs. */ + #define WOLFSSL_AES_DIRECT +#endif + +/* Pick a cert buffer size: */ +/* #define USE_CERT_BUFFERS_2048 */ +/* #define USE_CERT_BUFFERS_1024 */ +#define USE_CERT_BUFFERS_2048 + +/* The Espressif sdkconfig will have chipset info. +** +** Some possible values: +** +** CONFIG_IDF_TARGET_ESP32 +** CONFIG_IDF_TARGET_ESP32S2 +** CONFIG_IDF_TARGET_ESP32S3 +** CONFIG_IDF_TARGET_ESP32C3 +** CONFIG_IDF_TARGET_ESP32C6 +*/ + +/* Optionally enable Apple HomeKit from compiler directive or Kconfig setting */ +#if defined(WOLFSSL_APPLE_HOMEKIT) || defined(CONFIG_WOLFSSL_APPLE_HOMEKIT) + /* SRP is known to need 8K; slow on some devices */ + #define FP_MAX_BITS (8192 * 2) + #define WOLFCRYPT_HAVE_SRP + #define HAVE_CHACHA + #define HAVE_POLY1305 + #define WOLFSSL_BASE64_ENCODE + #endif /* Apple HomeKit settings */ + +/* Used by ESP-IDF components: */ +#if defined(CONFIG_ESP_TLS_USING_WOLFSSL) + /* The ESP-TLS */ + #ifndef FP_MAX_BITS + #if defined(CONFIG_IDF_TARGET_ESP32C2) || \ + defined(CONFIG_IDF_TARGET_ESP8684) || \ + defined(CONFIG_IDF_TARGET_ESP8266) + /* Optionally set smaller size here */ + #define FP_MAX_BITS MIN_FFDHE_FP_MAX_BITS + #else + #define FP_MAX_BITS (4096 * 2) + #endif + #endif + #define HAVE_ALPN + #ifndef CONFIG_IDF_TARGET_ESP8266 + /* Unless installed in the ESP8266 RTOS SDK locally, the wolfSSL + * API for SNI will not be seen in the components/esp-tls layer. + * Only enable SNI for non-ESP8266 targets by default: */ + #define HAVE_SNI + #endif + #define OPENSSL_EXTRA_X509_SMALL + + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES +#endif + +/* Optionally enable some wolfSSH settings */ +#if defined(ESP_ENABLE_WOLFSSH) || defined(CONFIG_ESP_ENABLE_WOLFSSH) + /* Enable wolfSSH. Espressif examples need a few more settings, below */ + #undef WOLFSSL_WOLFSSH + #define WOLFSSL_WOLFSSH + + /* The default SSH Windows size is massive for an embedded target. + * Limit it: */ + #define DEFAULT_WINDOW_SZ 2000 + + /* These may be defined in cmake for other examples: */ + #undef WOLFSSH_TERM + #define WOLFSSH_TERM + + /* optional debug */ + /* #undef DEBUG_WOLFSSH */ + /* #define DEBUG_WOLFSSH */ + + #undef WOLFSSL_KEY_GEN + #define WOLFSSL_KEY_GEN + + #undef WOLFSSL_PTHREADS + #define WOLFSSL_PTHREADS + + #define WOLFSSH_TEST_SERVER + #define WOLFSSH_TEST_THREADING +#endif /* ESP_ENABLE_WOLFSSH */ + + +/* Not yet using WiFi lib, so don't compile in the esp-sdk-lib WiFi helpers: */ +/* #define USE_WOLFSSL_ESP_SDK_WIFI */ + /* * ONE of these Espressif chip families will be detected from sdkconfig: * * WOLFSSL_ESP32 + * WOLFSSL_ESPWROOM32SE * WOLFSSL_ESP8266 + * + * following ifdef detection only for syntax highlighting: */ -#undef WOLFSSL_ESPWROOM32SE -#undef WOLFSSL_ESP8266 -#undef WOLFSSL_ESP32 +#ifdef WOLFSSL_ESPWROOM32SE + #undef WOLFSSL_ESPWROOM32SE +#endif +#ifdef WOLFSSL_ESP8266 + #undef WOLFSSL_ESP8266 +#endif +#ifdef WOLFSSL_ESP32 + #undef WOLFSSL_ESP32 +#endif /* See below for chipset detection from sdkconfig.h */ /* when you want to use SINGLE THREAD. Note Default ESP-IDF is FreeRTOS */ -/* #define SINGLE_THREADED */ +#define SINGLE_THREADED -/* SMALL_SESSION_CACHE saves a lot of RAM for ClientCache and SessionCache. +/* Small session cache saves a lot of RAM for ClientCache and SessionCache. * Memory requirement is about 5KB, otherwise 20K is needed when not specified. * If extra small footprint is needed, try MICRO_SESSION_CACHE (< 1K) * When really desperate or no TLS used, try NO_SESSION_CACHE. */ @@ -92,9 +361,6 @@ /* RSA_LOW_MEM: Half as much memory but twice as slow. */ #define RSA_LOW_MEM - - - /* optionally turn off SHA512/224 SHA512/256 */ /* #define WOLFSSL_NOSHA512_224 */ /* #define WOLFSSL_NOSHA512_256 */ @@ -109,14 +375,43 @@ #define BENCH_EMBEDDED /* TLS 1.3 */ -#define WOLFSSL_TLS13 -#define HAVE_TLS_EXTENSIONS -#define WC_RSA_PSS -#define HAVE_HKDF -#define HAVE_AEAD -#define HAVE_SUPPORTED_CURVES +#ifdef CONFIG_WOLFSSL_ALLOW_TLS13 + #define WOLFSSL_TLS13 + #define HAVE_TLS_EXTENSIONS + #define HAVE_HKDF -#define WOLFSSL_BENCHMARK_FIXED_UNITS_KB + /* May be required */ + #ifndef HAVE_AEAD + #endif + + /* Required for ECC */ + #define HAVE_SUPPORTED_CURVES + + /* Required for RSA */ + #define WC_RSA_PSS + + /* TLS 1.3 normally requires HAVE_FFDHE */ + #if defined(HAVE_FFDHE_2048) || \ + defined(HAVE_FFDHE_3072) || \ + defined(HAVE_FFDHE_4096) || \ + defined(HAVE_FFDHE_6144) || \ + defined(HAVE_FFDHE_8192) + #else + #define HAVE_FFDHE_2048 + /* #error "TLS 1.3 requires HAVE_FFDHE_[nnnn]" */ + #endif +#endif + +#if defined(CONFIG_IDF_TARGET_ESP32C2) || \ + defined(CONFIG_IDF_TARGET_ESP8684) + /* Optionally set smaller size here */ + #ifdef HAVE_FFDHE_4096 + /* this size may be problematic on the C2 */ + #endif + #define HAVE_FFDHE_2048 +#else + #define HAVE_FFDHE_4096 +#endif #define NO_FILESYSTEM @@ -133,29 +428,64 @@ /* when you want to use SHA384 */ #define WOLFSSL_SHA384 -/* when you want to use SHA512 */ -#define WOLFSSL_SHA512 - -/* when you want to use SHA3 */ -#define WOLFSSL_SHA3 - - /* ED25519 requires SHA512 */ -#define HAVE_ED25519 - /* Some features not enabled for ESP8266: */ #if defined(CONFIG_IDF_TARGET_ESP8266) || \ defined(CONFIG_IDF_TARGET_ESP32C2) + /* Some known low-memory devices have features not enabled by default. */ /* TODO determine low memory configuration for ECC. */ #else - #define HAVE_ECC - #define HAVE_CURVE25519 - #define CURVE25519_SMALL + /* when you want to use SHA512 */ + #define WOLFSSL_SHA512 + + /* when you want to use SHA3 */ + /* #define WOLFSSL_SHA3 */ + + /* ED25519 requires SHA512 */ + #define HAVE_ED25519 #endif -#define HAVE_ED25519 +#if defined(CONFIG_IDF_TARGET_ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C2) + #define MY_USE_ECC 0 + #define MY_USE_RSA 1 +#else + #define MY_USE_ECC 1 + #define MY_USE_RSA 0 +#endif -/* Optional OPENSSL compatibility */ -#define OPENSSL_EXTRA +/* We can use either or both ECC and RSA, but must use at least one. */ +#if MY_USE_ECC || MY_USE_RSA + #if MY_USE_ECC + /* ---- ECDSA / ECC ---- */ + #define HAVE_ECC + #define HAVE_CURVE25519 + #define HAVE_ED25519 + #define WOLFSSL_SHA512 + /* + #define HAVE_ECC384 + #define CURVE25519_SMALL + */ + #else + #define WOLFSSH_NO_ECC + /* WOLFSSH_NO_ECDSA is typically defined automatically, + * here for clarity: */ + #define WOLFSSH_NO_ECDSA + #endif + + #if MY_USE_RSA + /* ---- RSA ----- */ + /* #define RSA_LOW_MEM */ + + /* DH disabled by default, needed if ECDSA/ECC also turned off */ + #define HAVE_DH + #else + #define WOLFSSH_NO_RSA + #endif +#else + #error "Either RSA or ECC must be enabled" +#endif + +/* Optional OpenSSL compatibility */ +/* #define OPENSSL_EXTRA */ /* #Optional HAVE_PKCS7 */ /* #define HAVE_PKCS7 */ @@ -198,8 +528,11 @@ /* #define XTIME time */ -/* adjust wait-timeout count if you see timeout in RSA HW acceleration */ -#define ESP_RSA_TIMEOUT_CNT 0x349F00 +/* Adjust wait-timeout count if you see timeout in RSA HW acceleration. + * Set to very large number and enable WOLFSSL_HW_METRICS to determine max. */ +#ifndef ESP_RSA_TIMEOUT_CNT + #define ESP_RSA_TIMEOUT_CNT 0xFF0000 +#endif /* hash limit for test.c */ #define HASH_SIZE_LIMIT @@ -208,7 +541,7 @@ #define USE_FAST_MATH /***** Use SP_MATH *****/ -/* #undef USE_FAST_MATH */ +/* #undef USE_FAST_MATH */ /* #define SP_MATH */ /* #define WOLFSSL_SP_MATH_ALL */ /* #define WOLFSSL_SP_RISCV32 */ @@ -217,6 +550,14 @@ /* #undef USE_FAST_MATH */ /* #define USE_INTEGER_HEAP_MATH */ +/* Just syntax highlighting to check math libraries: */ +#if defined(SP_MATH) || \ + defined(USE_INTEGER_HEAP_MATH) || \ + defined(USE_INTEGER_HEAP_MATH) || \ + defined(USE_FAST_MATH) || \ + defined(WOLFSSL_SP_MATH_ALL) || \ + defined(WOLFSSL_SP_RISCV32) +#endif #define WOLFSSL_SMALL_STACK @@ -224,18 +565,32 @@ #define HAVE_VERSION_EXTENDED_INFO /* #define HAVE_WC_INTROSPECTION */ -#define HAVE_SESSION_TICKET +#ifndef NO_SESSION_CACHE + #define HAVE_SESSION_TICKET +#endif /* #define HAVE_HASHDRBG */ +#if 0 +/* Example for additional cert functions */ #define WOLFSSL_KEY_GEN -#define WOLFSSL_CERT_REQ -#define WOLFSSL_CERT_GEN -#define WOLFSSL_CERT_EXT -#define WOLFSSL_SYS_CA_CERTS + #define WOLFSSL_CERT_REQ + #define WOLFSSL_CERT_GEN + #define WOLFSSL_CERT_EXT + #define WOLFSSL_SYS_CA_CERTS -#define WOLFSSL_CERT_TEXT + #define WOLFSSL_CERT_TEXT + + /* command-line options + --enable-keygen + --enable-certgen + --enable-certreq + --enable-certext + --enable-asn-template + */ + +#endif #define WOLFSSL_ASN_TEMPLATE @@ -255,10 +610,62 @@ --enable-asn-template */ +/* optional SM4 Ciphers. See https://github.com/wolfSSL/wolfsm */ +/* +#define WOLFSSL_SM2 +#define WOLFSSL_SM3 +#define WOLFSSL_SM4 +*/ + +#if defined(WOLFSSL_SM2) || defined(WOLFSSL_SM3) || defined(WOLFSSL_SM4) + /* SM settings, possible cipher suites: + + TLS13-AES128-GCM-SHA256 + TLS13-CHACHA20-POLY1305-SHA256 + TLS13-SM4-GCM-SM3 + TLS13-SM4-CCM-SM3 + + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-CCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CBC-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-GCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3:" \ + "TLS13-SM4-CCM-SM3:" + */ + + #undef WOLFSSL_BASE16 + #define WOLFSSL_BASE16 /* required for WOLFSSL_SM2 */ + + #undef WOLFSSL_SM4_ECB + #define WOLFSSL_SM4_ECB + + #undef WOLFSSL_SM4_CBC + #define WOLFSSL_SM4_CBC + + #undef WOLFSSL_SM4_CTR + #define WOLFSSL_SM4_CTR + + #undef WOLFSSL_SM4_GCM + #define WOLFSSL_SM4_GCM + + #undef WOLFSSL_SM4_CCM + #define WOLFSSL_SM4_CCM + + #define HAVE_POLY1305 + #define HAVE_CHACHA + + #undef HAVE_AESGCM + #define HAVE_AESGCM +#else + /* default settings */ + #define USE_CERT_BUFFERS_2048 +#endif + /* Chipset detection from sdkconfig.h * Default is HW enabled unless turned off. * Uncomment lines to force SW instead of HW acceleration */ -#if defined(CONFIG_IDF_TARGET_ESP32) +#if defined(CONFIG_IDF_TARGET_ESP32) || defined(WOLFSSL_ESPWROOM32SE) #define WOLFSSL_ESP32 /* Alternatively, if there's an ECC Secure Element present: */ /* #define WOLFSSL_ESPWROOM32SE */ @@ -380,12 +787,16 @@ #define WOLFSSL_ESP8266 /* There's no hardware encryption on the ESP8266 */ - /* Consider using the ESP32-C2/C3/C6 - * See https://www.espressif.com/en/products/socs/esp32-c2 */ + /* Consider using the ESP32-C2/C3/C6 */ #define NO_ESP32_CRYPT #define NO_WOLFSSL_ESP32_CRYPT_HASH #define NO_WOLFSSL_ESP32_CRYPT_AES #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI + #ifndef FP_MAX_BITS + /* FP_MAX_BITS matters in wolfssl_test, not just TLS setting. */ + /* MIN_FFDHE_FP_MAX_BITS = (MIN_FFDHE_BITS * 2); see settings.h */ + #define FP_MAX_BITS MIN_FFDHE_FP_MAX_BITS + #endif /***** END CONFIG_IDF_TARGET_ESP266 *****/ #elif defined(CONFIG_IDF_TARGET_ESP8684) @@ -397,7 +808,7 @@ /***** END CONFIG_IDF_TARGET_ESP8684 *****/ #else - /* Anything else encountered, disable HW accleration */ + /* Anything else encountered, disable HW acceleration */ #warning "Unexpected CONFIG_IDF_TARGET_NN value" #define NO_ESP32_CRYPT #define NO_WOLFSSL_ESP32_CRYPT_HASH @@ -435,18 +846,33 @@ /* Debug options: See wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h for details on debug options +optionally increase error message size for very long paths. +#define WOLFSSL_MAX_ERROR_SZ 500 + +Turn wolfSSL debugging on/off: + wolfSSL_Debugging_ON(); + wolfSSL_Debugging_OFF(); + #define ESP_VERIFY_MEMBLOCK #define DEBUG_WOLFSSL #define DEBUG_WOLFSSL_VERBOSE #define DEBUG_WOLFSSL_SHA_MUTEX +#define WOLFSSL_DEBUG_IGNORE_ASN_TIME +#define WOLFSSL_DEBUG_CERT_BUNDLE +#define WOLFSSL_DEBUG_CERT_BUNDLE_NAME #define WOLFSSL_ESP32_CRYPT_DEBUG #define WOLFSSL_ESP32_CRYPT_HASH_SHA224_DEBUG #define NO_RECOVER_SOFTWARE_CALC #define WOLFSSL_TEST_STRAY 1 #define USE_ESP_DPORT_ACCESS_READ_BUFFER #define WOLFSSL_ESP32_HW_LOCK_DEBUG +#define WOLFSSL_DEBUG_MUTEX #define WOLFSSL_DEBUG_ESP_RSA_MULM_BITS +#define WOLFSSL_DEBUG_ESP_HW_MOD_RSAMAX_BITS +#define WOLFSSL_DEBUG_ESP_HW_MULTI_RSAMAX_BITS #define ESP_DISABLE_HW_TASK_LOCK +#define ESP_MONITOR_HW_TASK_LOCK +#define USE_ESP_DPORT_ACCESS_READ_BUFFER See wolfcrypt/benchmark/benchmark.c for debug and other settings: @@ -458,7 +884,8 @@ Turn on timer debugging (used when CPU cycles not available) */ /* Pause in a loop rather than exit. */ -#define WOLFSSL_ESPIDF_ERROR_PAUSE +/* #define WOLFSSL_ESPIDF_ERROR_PAUSE */ +/* #define WOLFSSL_ESP32_HW_LOCK_DEBUG */ #define WOLFSSL_HW_METRICS @@ -507,6 +934,12 @@ Turn on timer debugging (used when CPU cycles not available) * There are various certificate examples in this header file: * https://github.com/wolfSSL/wolfssl/blob/master/wolfssl/certs_test.h * + * To use the sample certificates in code (not recommended for production!): + * + * #if defined(USE_CERT_BUFFERS_2048) || defined(USE_CERT_BUFFERS_1024) + * #include + * #endif + * * To use the sets of macros below, define *one* of these: * * USE_CERT_BUFFERS_1024 - ECC 1024 bit encoded ASN1 @@ -584,6 +1017,7 @@ Turn on timer debugging (used when CPU cycles not available) #define WOLFSSL_BASE16 #else #if defined(USE_CERT_BUFFERS_2048) + #define USE_CERT_BUFFERS_256 /* Be sure to include in app when using example certs: */ /* #include */ #define CTX_CA_CERT ca_cert_der_2048 @@ -605,6 +1039,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) + #define USE_CERT_BUFFERS_256 /* Be sure to include in app when using example certs: */ /* #include */ #define CTX_CA_CERT ca_cert_der_1024 @@ -629,3 +1064,34 @@ Turn on timer debugging (used when CPU cycles not available) #error "Must define USE_CERT_BUFFERS_2048 or USE_CERT_BUFFERS_1024" #endif #endif /* Conditional key and cert constant names */ + +/****************************************************************************** +** Sanity Checks +******************************************************************************/ +#if defined(CONFIG_ESP_MAIN_TASK_STACK_SIZE) + #if defined(WOLFCRYPT_HAVE_SRP) + #if defined(FP_MAX_BITS) + #if FP_MAX_BITS < (8192 * 2) + #define ESP_SRP_MINIMUM_STACK_8K (24 * 1024) + #else + #define ESP_SRP_MINIMUM_STACK_8K (28 * 1024) + #endif + #else + #error "Please define FP_MAX_BITS when using WOLFCRYPT_HAVE_SRP." + #endif + + #if (CONFIG_ESP_MAIN_TASK_STACK_SIZE < ESP_SRP_MINIMUM_STACK) + #warning "WOLFCRYPT_HAVE_SRP enabled with small stack size" + #endif + #endif +#else + #warning "CONFIG_ESP_MAIN_TASK_STACK_SIZE not defined!" +#endif +/* See settings.h for some of the possible hardening options: + * + * #define NO_ESPIDF_DEFAULT + * #define WC_NO_CACHE_RESISTANT + * #define WC_AES_BITSLICED + * #define HAVE_AES_ECB + * #define HAVE_AES_DIRECT + */ diff --git a/IDE/Espressif/ESP-IDF/examples/template/main/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/template/main/CMakeLists.txt index a038d035b..6a3deddc4 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/main/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/template/main/CMakeLists.txt @@ -1,35 +1,43 @@ # wolfSSL Espressif Example Project/main CMakeLists.txt -# v1.0 +# v1.2 # # wolfssl template # +message(STATUS "Begin wolfSSL main CMakeLists.txt") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + # `driver` component not available for ESP8266 + SET(THIS_PRIV_REQUIRES_DRIVER "") +else() + SET(THIS_PRIV_REQUIRES_DRIVER "driver") +endif() + if(WIN32) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") - message("Detected Windows") + message(STATUS "Detected Windows") endif() if(CMAKE_HOST_UNIX) - message("Detected UNIX") + message(STATUS "Detected UNIX") endif() if(APPLE) - message("Detected APPLE") + message(STATUS "Detected APPLE") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") - message("Detected WSL") + message(STATUS "Detected WSL") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") - message("Detected Linux") + message(STATUS "Detected Linux") endif() if(APPLE) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") - message("Detected Apple") + message(STATUS "Detected Apple") endif() set (git_cmd "git") @@ -43,10 +51,22 @@ if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl/" AND EXISTS "$ENV{IDF_PA set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING") endif() +# The wolfSL component name is named "mywolfssl" on the staging site for Managed Components. +if( NOT EXISTS "../components/wolfssl" AND ("$ENV{IDF_COMPONENT_REGISTRY_URL}" STREQUAL "https://components-staging.espressif.com") ) + message(STATUS "WARNING: Using a staging instance of wolfssl.") + set(MAIN_WOLFSSL_COMPONENT_NAME "mywolfssl") +else() + message(STATUS "Using release wolfssl component.") + set(MAIN_WOLFSSL_COMPONENT_NAME "wolfssl") +endif() + ## register_component() idf_component_register(SRCS main.c INCLUDE_DIRS "." - "./include") + "./include" + PRIV_REQUIRES "${THIS_PRIV_REQUIRES_DRIVER}" + "${MAIN_WOLFSSL_COMPONENT_NAME}" + ) # # LIBWOLFSSL_SAVE_INFO(VAR_OUPUT THIS_VAR VAR_RESULT) @@ -76,15 +96,24 @@ function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) message(STATUS "Found ${VAR_OUPUT}=${VAR_VALUE}") # the interesting part is defining the VAR_OUPUT name a value to use in the app - add_definitions(-D${VAR_OUPUT}=\"${VAR_VALUE}\") + add_compile_definitions(${VAR_OUPUT}=\"${VAR_VALUE}\") else() # if we get here, check the execute_process command and parameters. - message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT") + message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT.") + message(STATUS "Setting ${VAR_OUPUT} to \"Unknown\"") set(${VAR_OUPUT} "Unknown") endif() endfunction() # LIBWOLFSSL_SAVE_INFO -if(NOT CMAKE_BUILD_EARLY_EXPANSION) +execute_process( + COMMAND ${git_cmd} "rev-parse" "--is-inside-work-tree" + OUTPUT_VARIABLE IS_GIT_REPO + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + +# Save some project-specific details. Repo may be different than component, or may not even be a repo at all: +if(NOT CMAKE_BUILD_EARLY_EXPANSION AND (IS_GIT_REPO STREQUAL "true")) # LIBWOLFSSL_VERSION_GIT_HASH execute_process(COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") @@ -100,3 +129,4 @@ endif() message(STATUS "") +message(STATUS "End wolfSSL main CMakeLists.txt") diff --git a/IDE/Espressif/ESP-IDF/examples/template/main/Kconfig.projbuild b/IDE/Espressif/ESP-IDF/examples/template/main/Kconfig.projbuild new file mode 100644 index 000000000..06cc01df8 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/template/main/Kconfig.projbuild @@ -0,0 +1,112 @@ +# Kconfig main +# +# Copyright (C) 2006-2025 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 +# + +# Kconfig File Version 5.7.2.001 for wolfssl_template + +menu "Example wolfSSL Configuration" + +choice WOLFSSL_EXAMPLE_CHOOSE + prompt "Choose Example (See wolfssl/include/user_settings.h)" + default WOLFSSL_EXAMPLE_NAME_NONE + help + The user settings file can be adjusted to specific wolfSSL examples. + + config WOLFSSL_EXAMPLE_NAME_TEMPLATE + bool "wolfSSL Template" + help + The sample template app compiles in wolfSSL and prints the current wolfSSL Version. Nothing more. + + config WOLFSSL_EXAMPLE_NAME_TEST + bool "wolfSSL Test" + help + This app tests all cryptographic functions currently enabled. See also Benchmark performance app. + + config WOLFSSL_EXAMPLE_NAME_BENCHMARK + bool "wolfSSL Benchmark" + help + Benchmark performance app. See also cryptographic test. + + config WOLFSSL_EXAMPLE_NAME_TLS_CLIENT + bool "TLS Client" + help + TLS Client Example app. Needs WiFi and a listening server on port 11111. + + config WOLFSSL_EXAMPLE_NAME_TLS_SERVER + bool "TLS Server" + help + TLS Server Example app. Needs WiFi. More interesting with a TLS client using port 11111. + + config WOLFSSL_EXAMPLE_NAME_WOLFSSH_TEMPLATE + bool "SSH Template App" + help + Bare-bones Hello World app that only compiles in wolfSSL and wolfSSH. + See wolfSSL/wolfssh on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFSSH_ECHOSERVER + bool "SSH Echo Server" + help + See wolfSSL/wolfssh on GitHub. + + config WOLFSSL_EXAMPLE_NAME_ESP32_SSH_SERVER + bool "SSH to UART Server for the ESP32" + help + See wolfSSL/wolfssh-examples on GitHub. + + config WOLFSSL_EXAMPLE_NAME_ESP8266_SSH_SERVER + bool "SSH to UART Server for the ESP8266" + help + See wolfSSL/wolfssh-examples on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFMQTT_TEMPLATE + bool "MQTT Template" + help + See wolfSSL/wolfmqtt on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFMQTT_AWS_IOT_MQTT + bool "MQTT AWS IoT" + help + See wolfSSL/wolfmqtt on GitHub. + + config WOLFTPM_EXAMPLE_NAME_ESPRESSIF + bool "TPM Test Example for the ESP32" + help + See wolfSSL/wolfTPM on GitHub. + + config WOLFSSL_EXAMPLE_NAME_NONE + bool "Other" + help + A specific example app is not defined. + +endchoice + +config WOLFSSL_TARGET_HOST + string "Target host" + default "127.0.0.1" + help + host address for the example to connect + +config WOLFSSL_TARGET_PORT + int "Target port" + default 11111 + help + host port for the example to connect + +endmenu diff --git a/IDE/Espressif/ESP-IDF/examples/template/main/component.mk b/IDE/Espressif/ESP-IDF/examples/template/main/component.mk new file mode 100644 index 000000000..08f8fbe9b --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/template/main/component.mk @@ -0,0 +1,23 @@ +# +# Main component makefile. +# +# This Makefile can be left empty. By default, it will take the sources in the +# src/ directory, compile them and link them into lib(subdirectory_name).a +# in the build directory. This behavior is entirely configurable, +# please read the ESP-IDF documents if you need to do this. +# +# (Uses default behavior of compiling all source files in directory, adding 'include' to include path.) + +# We'll add the explicit lines only for old SDK requirements (e.h. ESP8266) + +ifeq ("$(VISUALGDB_DIR)","") + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL) ) +else + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL) ) + COMPONENT_SRCDIRS := . + COMPONENT_ADD_INCLUDEDIRS := . + COMPONENT_ADD_INCLUDEDIRS += include + + # Ensure main.c gets compiled + COMPONENT_OBJS := main.o +endif diff --git a/IDE/Espressif/ESP-IDF/examples/template/main/include/main.h b/IDE/Espressif/ESP-IDF/examples/template/main/include/main.h index 94d913235..04a7e7f26 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/main/include/main.h +++ b/IDE/Espressif/ESP-IDF/examples/template/main/include/main.h @@ -1,6 +1,6 @@ /* template main.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -18,7 +18,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ + #ifndef _MAIN_H_ #define _MAIN_H_ +void app_main(void); + #endif diff --git a/IDE/Espressif/ESP-IDF/examples/template/main/main.c b/IDE/Espressif/ESP-IDF/examples/template/main/main.c index f2f69bcb2..35826643d 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/main/main.c +++ b/IDE/Espressif/ESP-IDF/examples/template/main/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -50,6 +50,11 @@ void app_main(void) #ifdef WOLFSSL_ESPIDF_VERBOSE_EXIT_MESSAGE int ret = 0; #endif + +#if !defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TEMPLATE) + ESP_LOGW(TAG, "Warning: Example wolfSSL misconfigured? Check menuconfig."); +#endif + ESP_LOGI(TAG, "Hello wolfSSL!"); #ifdef HAVE_VERSION_EXTENDED_INFO diff --git a/IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults b/IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults index 88f1e113e..2a93afe05 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults +++ b/IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults @@ -1,25 +1,155 @@ +# Set the known example app config to template example (see user_settings.h) +CONFIG_WOLFSSL_EXAMPLE_NAME_TEMPLATE=y + +# CONFIG_EXAMPLE_WIFI_SSID="myssid" +# CONFIG_EXAMPLE_WIFI_PASSWORD="mypassword" + +# Some wolfSSL helpers +CONFIG_USE_WOLFSSL_ESP_SDK_TIME=y + +# sdkconfig.defaults for ESP8266 + ESP32 +# See separate sdkconfig.defaults.esp8266 +# FreeRTOS ticks at 1ms interval +CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_HZ=1000 CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y # -# Default main stack size +# Default main stack size. See user_settings.h # -# This is typically way bigger than needed for stack size. See user_settings.h +# This is typically bigger than needed for stack size. +# Units are words, not bytes. See user_settings.h # +# For wolfSSL SMALL_STACK, 3072 bytes should be sufficient for benchmark app. +# When using RSA, assign at least 10500 bytes, otherwise 5500 usually works for others +# We set this to 28672 for use in the "test everything possible" in the wolfssl_test app. CONFIG_ESP_MAIN_TASK_STACK_SIZE=10500 -# Legacy stack size for older ESP-IDF versions +# Legacy stack size name for older ESP-IDF versions CONFIG_MAIN_TASK_STACK_SIZE=10500 +# +# Benchmark must not have CONFIG_NEWLIB_NANO_FORMAT enabled +CONFIG_NEWLIB_NANO_FORMAT=n +# +# Watchdog Timers +# +# We don't want to have the watchdog timeout during tests & benchmarks +# +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=n +# Panic & Watchdog +CONFIG_ESP_INT_WDT_TIMEOUT_MS=10000 +CONFIG_ESP_TASK_WDT_EN=n +CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y +CONFIG_ESP_INT_WDT=n + +# ESP8266 Watchdog: +CONFIG_TASK_WDT=n +CONFIG_TASK_WDT_PANIC=n + +# ESP8266 WDT +# CONFIG_ESP_PANIC_PRINT_REBOOT is not set +CONFIG_ESP_PANIC_PRINT_REBOOT=n +CONFIG_ESP_PANIC_PRINT_HALT=y + +# CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set +CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=n + +# ESP8266 Memory +CONFIG_FREERTOS_GLOBAL_DATA_LINK_IRAM=y +CONFIG_HEAP_DISABLE_IRAM=y + +# Performance +# CONFIG_COMPILER_OPTIMIZATION_PERF=y + +# Set max CPU frequency (falls back as needed for lower maximum) +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y + +# Enable wolfSSL TLS in esp-tls +# CONFIG_ESP_TLS_USING_WOLFSSL=y +# CONFIG_TLS_STACK_WOLFSSL=y + +# Bundles take up flash space and are disabled unless otherwise known to be needed +CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=n +# CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=y +# CONFIG_ESP_WOLFSSL_SMALL_CERT_VERIFY=y +# CONFIG_ESP_TLS_INSECURE=y + +# Disable mbedTLS +CONFIG_ESP_TLS_USING_MBEDTLS=n +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n + +# Some wolfSSL helpers +CONFIG_USE_WOLFSSL_ESP_SDK_TIME=n + +# CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set +CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=n + +# ESP8266 Memory +CONFIG_FREERTOS_GLOBAL_DATA_LINK_IRAM=y +CONFIG_HEAP_DISABLE_IRAM=y + +# Performance +# CONFIG_COMPILER_OPTIMIZATION_PERF=y + +# Set max COU frequency (falls back as needed for lower maximum) +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y + +# FreeRTOS ticks at 1ms interval +CONFIG_FREERTOS_UNICORE=y +CONFIG_FREERTOS_HZ=1000 + +# Ensure mbedTLS options are disabled +# CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=n +# CONFIG_MBEDTLS_TLS_CLIENT_ONLY=n +# CONFIG_MBEDTLS_TLS_SERVER=n +# CONFIG_MBEDTLS_TLS_CLIENT=n +# CONFIG_MBEDTLS_HARDWARE_AES=n +# CONFIG_MBEDTLS_HARDWARE_MPI=n +# CONFIG_MBEDTLS_HARDWARE_SHA=n +# CONFIG_MBEDTLS_ROM_MD5=n +# CONFIG_MBEDTLS_SSL_RENEGOTIATION=n +# CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=n +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1=n +# CONFIG_MBEDTLS_SSL_ALPN=n +# CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=n +# CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=n + +# The same-name config is used for both WiFi and client/server TLS, so we cannot disable: +# CONFIG_MBEDTLS_TLS_ENABLED=n +# CONFIG_MBEDTLS_TLS_DISABLED=y + # # Compiler options # CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y +# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set +# CONFIG_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_COMPILER_OPTIMIZATION_NONE is not set CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set +CONFIG_COMPILER_FLOAT_LIB_FROM_GCCLIB=y CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2 +# CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set CONFIG_COMPILER_HIDE_PATHS_MACROS=y +# CONFIG_COMPILER_CXX_EXCEPTIONS is not set +# CONFIG_COMPILER_CXX_RTTI is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_NONE is not set CONFIG_COMPILER_STACK_CHECK_MODE_NORM=y +# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set CONFIG_COMPILER_STACK_CHECK=y +# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set +# CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS is not set +# CONFIG_COMPILER_DISABLE_GCC12_WARNINGS is not set +# CONFIG_COMPILER_DUMP_RTL_FILES is not set +# end of Compiler options + +# We don't know that the min is actually v2, +# but this is the earliest tested. +CONFIG_ESP32C3_REV_MIN_2=y # # Partition Table diff --git a/IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults.esp8266 b/IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults.esp8266 new file mode 100644 index 000000000..77299dfe4 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults.esp8266 @@ -0,0 +1,30 @@ +# ESP8266 WDT +# CONFIG_ESP_PANIC_PRINT_REBOOT is not set +CONFIG_ESP_PANIC_PRINT_REBOOT=n +CONFIG_ESP_PANIC_PRINT_HALT=y + +# Enable wolfSSL TLS in esp-tls (not yet supported in RTOS SDK 3.4 +CONFIG_ESP_TLS_USING_WOLFSSL=n +CONFIG_TLS_STACK_WOLFSSL=n + +# Bundles take up flash space and are disabled unless otherwise known to be needed +CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=n +# CONFIG_ESP_WOLFSSL_SMALL_CERT_VERIFY=y +# CONFIG_ESP_TLS_INSECURE=y + +# Disable mbedTLS +CONFIG_ESP_TLS_USING_MBEDTLS=y +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n + +# ESP8266 Memory +CONFIG_FREERTOS_GLOBAL_DATA_LINK_IRAM=y +CONFIG_HEAP_DISABLE_IRAM=y + +# ESP8266 Watchdog: +CONFIG_TASK_WDT=n +CONFIG_TASK_WDT_PANIC=n + +# ESP8266 WDT +# CONFIG_ESP_PANIC_PRINT_REBOOT is not set +CONFIG_ESP_PANIC_PRINT_REBOOT=n +CONFIG_ESP_PANIC_PRINT_HALT=y diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/CMakeLists.txt index 8c66ae269..17437542e 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/CMakeLists.txt @@ -1,11 +1,19 @@ # wolfSSL Espressif Example Project CMakeLists.txt -# v1.0 +# v1.3 # # The following lines of boilerplate have to be in your project's # CMakeLists in this exact order for cmake to work correctly +message(STATUS "Begin project ${CMAKE_PROJECT_NAME}") + cmake_minimum_required(VERSION 3.16) -add_compile_options(-DWOLFSSL_ESP_NO_WATCHDOG=1) +# Optional no watchdog typically used for test & benchmark +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESP_NO_WATCHDOG=1") +else() + add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +endif() + # The wolfSSL CMake file should be able to find the source code. # Otherwise, assign an environment variable or set it here: # @@ -20,22 +28,121 @@ add_compile_options(-DWOLFSSL_ESP_NO_WATCHDOG=1) # Linux: ~/workspace # Windows: C:\workspace # +if(WIN32) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") + message(STATUS "Detected Windows") +endif() +if(CMAKE_HOST_UNIX) + message(STATUS "Detected UNIX") +endif() +if(APPLE) + message(STATUS "Detected APPLE") +endif() +if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") + message(STATUS "Detected WSL") +endif() +if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") + message(STATUS "Detected Linux") +endif() +if(APPLE) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") + message(STATUS "Detected Apple") +endif() +# End optional WOLFSSL_CMAKE_SYSTEM_NAME -# Optionally specify a location for wolfSSL component source code -# set(WOLFSSL_ROOT "c:/mydir/wolfssl" ) # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. # set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) -# -#if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") -# message("Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") -# set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) -# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") -#else() -# message("NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") -#endif() +string(REPLACE "\\" "/" PROTOCOL_EXAMPLES_DIR "$ENV{IDF_PATH}/examples/common_components/protocol_examples_common") + +if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") + message(STATUS "Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") +else() + message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") +endif() + +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER +message(STATUS "USERNAME = $ENV{USERNAME}") +if( "$ENV{USER}" STREQUAL "" ) # the bash user + if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user + message(STATUS "could not find USER or USERNAME") + else() + # the bash user is not blank, so we'll use it. + set(THIS_USER "$ENV{USERNAME}") + endif() +else() + # the bash user is not blank, so we'll use it. + set(THIS_USER "$ENV{USER}") +endif() +message(STATUS "THIS_USER = ${THIS_USER}") + +# Check that there are not conflicting wolfSSL components +# The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl +# The local component wolfSSL directory will be in ./components/wolfssl +message(STATUS "Checking for wolfSSL as Managed Component or not... ${CMAKE_HOME_DIRECTORY}") +if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" ) + # These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake' + # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL) + # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl/include" EXCLUDE_FROM_ALL) + # So we'll error out and let the user decide how to proceed: + message(WARNING "\nFound wolfSSL components in\n" + "./managed_components/wolfssl__wolfssl\n" + "and\n" + "./components/wolfssl\n" + "in project directory: \n" + "${CMAKE_HOME_DIRECTORY}") + message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n" + "If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove " + "or rename the idf_component.yml file typically found in ./main/") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl") + # A standard project component (not a Managed Component) + message(STATUS "No conflicting wolfSSL components found.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/components/wolfssl") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl") + # The official Managed Component called wolfssl from the wolfssl user. + message(STATUS "No conflicting wolfSSL components found as a Managed Component.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/gojimmypi__mywolfssl") + # There is a known gojimmypi staging component available for anyone: + message(STATUS "No conflicting wolfSSL components found as a gojimmypi staging Managed Component.") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/${THIS_USER}__mywolfssl") + # Other users with permissions might publish their own mywolfssl staging Managed Component + message(STATUS "No conflicting wolfSSL components found as a Managed Component.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/managed_components/${THIS_USER}__mywolfssl") +else() + message(STATUS "WARNING: wolfssl component directory not found.") +endif() + +# message(STATUS "EXTRA_COMPONENT_DIRS WOLFSSL_PATH: ${WOLFSSL_PATH}") +# list(APPEND EXTRA_COMPONENT_DIRS ${WOLFSSL_PATH}) # Not only is a project-level "set(COMPONENTS" not needed here, this will cause # an unintuitive error about Unknown CMake command "esptool_py_flash_project_args". + +if(0) + message(STATUS "Begin optional PROTOCOL_EXAMPLES_DIR include") + # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. + set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + + if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") + message(STATUS "Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") + else() + message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + endif() + message(STATUS "End optional PROTOCOL_EXAMPLES_DIR include") +endif() + include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(wolfssl_benchmark) +message(STATUS "end project") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/Makefile b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/Makefile index 27637c64d..5bdaf7fa9 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/Makefile +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/Makefile @@ -4,9 +4,11 @@ # CFLAGS += -DWOLFSSL_USER_SETTINGS + # Some of the tests are CPU intenstive, so we'll force the watchdog timer off. # There's an espressif NO_WATCHDOG; we don't use it, as it is reset by sdkconfig. -EXTRA_CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG +CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 PROJECT_NAME := wolfssl_benchmark + include $(IDF_PATH)/make/project.mk diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/README.md b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/README.md index 7b3a4f255..e760db5f9 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/README.md +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/README.md @@ -7,8 +7,9 @@ For general information on [wolfSSL examples for Espressif](../README.md), see t ## Espressif ESP Component Registry -See the wolfSSL namespace at [components.espressif.com](https://components.espressif.com/components?q=wolfssl) +See the wolfSSL namespace and additional details: +https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/ ## Windows COM Port @@ -38,9 +39,7 @@ using the VisualGDB extension. The naming convention for project files is: `[project name]_IDF_[Version]_[chipset].vgdbproj`. The solution files (filename[.sln]) often will contain shortcuts to commonly used source and configuration files used by the respective project. - --------- |------------- |------------- | -ChipSet | ESP-IDF v4.4 | ESP-IDF v5.1 | +ChipSet | ESP-IDF v4.4 | ESP-IDF v5.2 | -------- |------------- |------------- | ESP32 | x | | ESP32-S2 | | | @@ -62,11 +61,12 @@ See the [feature request](https://sysprogs.com/w/forums/topic/feature-request-sh ## ESP-IDF Commandline -1. `idf.py menuconfig` to configure the program. +1. `idf.py menuconfig` to configure the program. 1-1. Example Configuration -> - BENCH_ARG : argument that you want to use. Default is "-lng 0" - The list of argument can be find in help. + BENCH_ARG : argument that you want to use. Default is "-lng 0" + The list of arguments can be found in help. See [benchmark/README.md](https://github.com/wolfSSL/wolfssl/blob/master/wolfcrypt/benchmark/README.md) + Features to be benchmarked are enabled in the `user_settings.h`. When you want to run the benchmark program @@ -89,14 +89,34 @@ git fetch git pull git submodule update --init --recursive -cd /mnt/c/workspace/wolfssl/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark +# pick your workspace location +# cd ~/workspace/wolfssl/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark +# cd /mnt/c/workspace/wolfssl/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark +# cd /mnt/c/workspace/wolfssl-master/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark +cd /mnt/c/workspace/wolfssl-$USER/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark -# Pick ESP-IDF install directory, this one for v5.1 in VisualGDB +# The ESP8266 uses a completely different toolchain: +WRK_IDF_PATH=/mnt/c/SysGCC/esp8266/rtos-sdk/v3.4 -WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.1 -WRK_IDF_PATH=/mnt/c/SysGCC/esp32-8.4/esp-idf/v4.4.1 +# Pick ESP-IDF toolchain install directory WRK_IDF_PATH=~/esp/esp-idf +# ESP-IDF v4.x uses toolchain v8.4 +WRK_IDF_PATH=/mnt/c/SysGCC/esp32-8.4/esp-idf/v4.4.1 + +# ESP-IDF v5.0 with toolchain v12.4 +WRK_IDF_PATH=/mnt/c/SysGCC/esp32-12.4/esp-idf/v5.0 + +# ESP-IDF v5.0 to v5.2.1 uses toolchain v12.4 +WRK_IDF_PATH=/mnt/c/SysGCC/esp32-12.4/esp-idf/v5.0 +WRK_IDF_PATH=/mnt/c/SysGCC/esp32-12.4/esp-idf/v5.1 +WRK_IDF_PATH=/mnt/c/SysGCC/esp32-12.4/esp-idf/v5.2.1 + +# The most recent version: +# ESP-IDF v5.2 uses toolchain v13.2 +WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.2 + + . $WRK_IDF_PATH/export.sh # Set target SoC @@ -110,9 +130,9 @@ idf.py build flash -p /dev/ttyS20 -b 115200 monitor ## Example Output -Note the default wolfSSL `user_settings.h` is configured by default to be the most +Note the default wolfSSL `user_settings.h` is configured by default to be the most compatible across the widest ranges of targets. Contact wolfSSL at support@wolfssl.com -for help in optimizing for your particular application, or see the +for help in optimizing for your particular application, or see the [docs](https://www.wolfssl.com/documentation/manuals/wolfssl/index.html). Compiled and flashed with `idf.py build flash -p /dev/ttyS7 -b 115200 monitor`: 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 f0bef7fc3..cc7ef0d47 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,5 +1,5 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # @@ -19,17 +19,67 @@ # # cmake for wolfssl Espressif projects # -# Version 5.7.0 template update + THIS_IDF_PATH +# Version 5.7.2 Espressif ESP-IDF integration # # See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html # - +message(STATUS "Begin wolfssl ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") cmake_minimum_required(VERSION 3.16) set(VERBOSE_COMPONENT_MESSAGES 1) +# Optional requires include: +# set(THIS_ESP_TLS "esp-tls") +set(THIS_ESP_TLS "") + +# function: IS_ESP_IDF_COMPONENT +# output: RESULT = 1 (true) if this component is located in the ESP-IDF components +# otherwise 0 (false) +function( IS_ESP_IDF_COMPONENT RESULT ) + # NOTE: Component location is based on the location of the CMakeList.txt + # and *not* the location of the wolfSSL source code. (which may be anywhere) + + # Normalize the paths to remove any trailing slashes + get_filename_component(NORMALIZED_IDF_PATH "${IDF_PATH}" REALPATH) + get_filename_component(NORMALIZED_TEST_PATH "${COMPONENT_DIR}" REALPATH) + + # Check if the test path starts with the IDF_PATH + string(FIND "${NORMALIZED_TEST_PATH}" "${NORMALIZED_IDF_PATH}" pos) + + if(${pos} EQUAL 0) + message(STATUS "${COMPONENT_DIR} is within IDF_PATH.") + set(${RESULT} 1 PARENT_SCOPE) + else() + message(STATUS "${COMPONENT_DIR} is not within IDF_PATH.") + set(${RESULT} 0 PARENT_SCOPE) + endif() +endfunction() + +# Determine if this cmake file is located in the ESP-IDF component directory or not, +# and if so, if it is being ignored (allowing the use of a local project one, instead). +IS_ESP_IDF_COMPONENT( IS_WOLSSL_ESP_IDF_COMPONENT ) +if( IS_WOLSSL_ESP_IDF_COMPONENT ) + message(STATUS "This wolfSSL is a component in ESP-IDF.") + if ( CONFIG_IGNORE_ESP_IDF_WOLFSSL_COMPONENT ) + idf_component_register() + message(STATUS "Warning: wolfSSL component in ESP-IDF is being ignored.") + return() + endif() +endif() + + +if( "${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}" STREQUAL "" ) + # nothing to do +else() + # Only forward slashes, or double backslashes are supported. + # By the time we get here the sdkconfig file has a value for wolfSSL source code root. + string(REPLACE "\\" "/" CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}) + message(STATUS "Cleaned wolfssl path: ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") +endif() + # The scope of this CMAKE_C_FLAGS is just this component: set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWOLFSSL_USER_SETTINGS") set(CMAKE_CURRENT_SOURCE_DIR ".") # set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component @@ -42,7 +92,7 @@ if ( "${WOLFSSL_ROOT}" STREQUAL "") endif() if( "$ENV{IDF_PATH}" STREQUAL "" ) - message(FATAL_ERROR "IDF_PATH Environment variable not set!") + message(FATAL_ERROR "IDF_PATH Environment variable not set!") else() string(REPLACE "\\" "/" THIS_IDF_PATH "$ENV{IDF_PATH}") endif() @@ -52,28 +102,28 @@ if(VERBOSE_COMPONENT_MESSAGES) if(WIN32) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") - message("Detected Windows") + message(STATUS "Detected Windows") endif() if(CMAKE_HOST_UNIX) - message("Detected UNIX") + message(STATUS "Detected UNIX") endif() if(APPLE) - message("Detected APPLE") + message(STATUS "Detected APPLE") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") - message("Detected WSL") + message(STATUS "Detected WSL") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") - message("Detected Linux") + message(STATUS "Detected Linux") endif() if(APPLE) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") - message("Detected Apple") + message(STATUS "Detected Apple") endif() endif() # End optional WOLFSSL_CMAKE_SYSTEM_NAME @@ -106,10 +156,11 @@ if( ("${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_benchmark") OR ("${CMAKE_PROJECT_ message(STATUS "Not including lwip for ${CMAKE_PROJECT_NAME}") else() # benchmark and test do not need wifi, everything else probably does: - set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component + set(COMPONENT_REQUIRES lwip "${THIS_ESP_TLS}") # we typically don't need lwip directly in wolfssl component endif() -# find the user name to search for possible "wolfssl-username" +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER message(STATUS "USERNAME = $ENV{USERNAME}") if( "$ENV{USER}" STREQUAL "" ) # the bash user if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user @@ -130,6 +181,25 @@ else() string(REPLACE "\\" "/" THIS_IDF_PATH "$ENV{IDF_PATH}") endif() +# ENVIRONMENT_VAR_TO_MACRO +# Check environment variable name EVARPARAM as [name] +# If defined, and has a value of EVARVALUE as [value], +# then assign a compiler definition "-D[name]=[value]" +function(ENVIRONMENT_VAR_TO_MACRO EVARPARAM EVARVALUE) + # If the EVARPARAM environment variable name is set to EVARVALUE, + # set the compiler flag definition to enable CSV output. + if ( "$ENV{${EVARPARAM}}" STREQUAL "${EVARVALUE}") + message(STATUS "Appending compile definition: -D${EVARPARAM}=${EVARVALUE}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${EVARPARAM}=${EVARVALUE}") + else() + if(DEFINED ENV{${EVARPARAM}}) + message(STATUS "Environment variable ${EVARPARAM} detected but set to $ENV{${EVARPARAM}}, not appending compile definition.") + else() + message(STATUS "Environment variable ${EVARPARAM} not detected, not appending compile definition.") + endif() + endif() +endfunction() + # COMPONENT_NAME = wolfssl # The component name is the directory name. "No feature to change this". # See https://github.com/espressif/esp-idf/issues/8978#issuecomment-1129892685 @@ -147,7 +217,8 @@ endif() # function: IS_WOLFSSL_SOURCE # parameter: DIRECTORY_PARAMETER - the directory to test # output: RESULT = contains contents of DIRECTORY_PARAMETER for wolfssl directory, otherwise blank. -function(IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER RESULT) +function( IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER + RESULT ) if (EXISTS "${DIRECTORY_PARAMETER}/wolfcrypt/src") set(${RESULT} "${DIRECTORY_PARAMETER}" PARENT_SCOPE) else() @@ -166,26 +237,56 @@ function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY) message(STATUS "Starting FIND_WOLFSSL_DIRECTORY: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") if ( "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}" STREQUAL "" ) + # The parameter is empty, so we certainly need to search. + # First, see if there's an environment variable. This takes highest priority (unless already found as hard-coded, above) set(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}") if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) message(STATUS "The WOLFSSL_ROOT environment variable is not set. Searching...") - else() - get_filename_component(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}" ABSOLUTE) - IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSL) - if( FOUND_WOLFSSL ) - message(STATUS "Found WOLFSSL_ROOT via Environment Variable:") + # Next, if not found, see if wolfSSL was selected for ESP-TLS Kconfig + if(CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT) + set(CURRENT_SEARCH_DIR ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}) + get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" ABSOLUTE) + message(STATUS "WOLFSSL_ROOT found in sdkconfig/KConfig: ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") else() - message(FATAL_ERROR "WOLFSSL_ROOT Environment Variable defined, but path not found:") - message(STATUS "$ENV{WOLFSSL_ROOT}") - endif() - endif() + message(STATUS "wolfSSL not defined in [Component Config] [wolfssl]. Continuing search...") + # If not specified as a search hint in OUTPUT_FOUND_WOLFSSL_DIRECTORY: + # This wolfSSL component CMakeLists.txt may be found EITHER in: + # 1) local project component + # 2) ESP-IDF share components + # We'll start in the CMAKE_CURRENT_SOURCE_DIR, typically [something]/projectname/components/wolfssl + # That option might find wolfSSL source code as a copy in the component directory (e.g. Managed Components) + # Unless cmake is in the ESP-IDF, in which case it is unlikely to find wolfSSL source in any parent. + message(STATUS "CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}") + get_filename_component(CURRENT_SEARCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE) + message(STATUS "CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}") + string(LENGTH ${CURRENT_SEARCH_DIR} CURRENT_SEARCH_DIR_LENGTH) + endif() # CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT + endif() # check environment var blank else() - get_filename_component(CURRENT_SEARCH_DIR "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}" ABSOLUTE) + message(STATUS "Parameter found for FIND_WOLFSSL_DIRECTORY") + message(STATUS "Setting wolfSSL search directory to: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + set(CURRENT_SEARCH_DIR "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + endif() # parameter empty + + # Check to see if we found a path in environment or config settings, above. + if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) + message(STATUS "Source for wolfSSL not specified in path nor config settings.") + # We'll continue the search by recursing up the directory tree, below. + else() + # Setting found! Does it contain a valid path? + string(REPLACE "\\" "/" CURRENT_SEARCH_DIR ${CURRENT_SEARCH_DIR}) + get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" ABSOLUTE) IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSL) if( FOUND_WOLFSSL ) - message(STATUS "Found WOLFSSL_ROOT via prior specification.") + message(STATUS "Found wolfSSL source code via setting: ${CURRENT_SEARCH_DIR}") + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) + return() else() - message(FATAL_ERROR "WOLFSSL_ROOT Variable defined, but path not found: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + if(WIN32) + message(STATUS "When specifying a path for Windows, use forward slahes, or double backslashes.") + endif() + message(STATUS "CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT sdkconfig setting = ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") + message(STATUS "WOLFSSL_ROOT Variable defined, but source code not found: ${CURRENT_SEARCH_DIR}") endif() endif() @@ -286,6 +387,11 @@ endfunction() message(STATUS "CONFIG_TARGET_PLATFORM = ${CONFIG_TARGET_PLATFORM}") +# Check for environment variable that may be assigned to macros +ENVIRONMENT_VAR_TO_MACRO("GENERATE_MACHINE_PARSEABLE_REPORT" "1") +ENVIRONMENT_VAR_TO_MACRO("WOLFSSL_BENCHMARK_FIXED_CSV" "1") + +# Optional variable inspection if (0) get_cmake_property(_variableNames VARIABLES) list (SORT _variableNames) @@ -302,15 +408,25 @@ endif() if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) # There's no esp_timer, no driver components for the ESP8266 - message(STATUS "Early expansion EXCLUDES esp_timer: ${THIS_INCLUDE_TIMER}") - message(STATUS "Early expansion EXCLUDES driver: ${THIS_INCLUDE_DRIVER}") - set(THIS_INCLUDE_TIMER "") - set(THIS_INCLUDE_DRIVER "") + message(STATUS "Early expansion EXCLUDES for esp8266:") + message(STATUS "THIS_INCLUDE_DRIVER: '${THIS_INCLUDE_DRIVER}'") + message(STATUS "THIS_INCLUDE_TIMER: '${THIS_INCLUDE_TIMER}'") + message(STATUS "Early expansion INCLUDE for esp8266:") + message(STATUS "THIS_INCLUDE_PTHREAD: '${THIS_INCLUDE_PTHREAD}'") + set(THIS_ESP_TLS "") + set(THIS_INCLUDE_DRIVER "") + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_PTHREAD "pthread") else() message(STATUS "Early expansion includes esp_timer: ${THIS_INCLUDE_TIMER}") message(STATUS "Early expansion includes driver: ${THIS_INCLUDE_DRIVER}") - set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_ESP_TLS "esp-tls") set(THIS_INCLUDE_DRIVER "driver") + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_PTHREAD "") + # Let the app know that we've included the esp-tls component requirement. + # This is critical for use the the esp-tls component. See wolfssl esp_crt_bundle.c file. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_REQUIRED_ESP_TLS=1") endif() if(CMAKE_BUILD_EARLY_EXPANSION) @@ -318,8 +434,10 @@ if(CMAKE_BUILD_EARLY_EXPANSION) idf_component_register( REQUIRES "${COMPONENT_REQUIRES}" PRIV_REQUIRES # esp_hw_support - ${THIS_INCLUDE_TIMER} - ${THIS_INCLUDE_DRIVER} # this will typically only be needed for wolfSSL benchmark + "${THIS_ESP_TLS}" + "${THIS_INCLUDE_PTHREAD}" + "${THIS_INCLUDE_TIMER}" + "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark ) else() @@ -328,6 +446,15 @@ else() message(STATUS "wolfssl component config:") message(STATUS "************************************************************************************************") + if ( "${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") + # There's no esp_timer, no driver components for the ESP8266 + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_DRIVER "") + else() + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_DRIVER "driver") + endif() + # search for wolfSSL FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) if(WOLFSSL_ROOT) @@ -341,7 +468,9 @@ else() # Abort CMake after fatal error. endif() else() - message(STATUS "Searching for wolfSL source code...") + message(STATUS "Source code for wolfSSL still not found.") + message(STATUS "Searching from project home: ${CMAKE_HOME_DIRECTORY} ...") + set(WOLFSSL_ROOT "${CMAKE_HOME_DIRECTORY}") FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) endif() @@ -349,11 +478,18 @@ else() if(WOLFSSL_ROOT) message(STATUS "Confirmed wolfssl directory at: ${WOLFSSL_ROOT}") else() - message(STATUS "Failed: wolfssl directory not found.") + # Try to allow a more intuitive error that the source code was not found in cmake: + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_WARNING_SOURCE_NOT_FOUND") + + message(STATUS "Failed: wolfssl source code directory not found.") # Abort. We need wolfssl _somewhere_. - message(FATAL_ERROR "Could not find wolfssl in any parent directory named wolfssl-${THIS_USER}, wolfssl-master, or wolfssl.\n" - "Try setting WOLFSSL_ROOT environment variable, cmake variable in project, copy source, or use managed components.") - # Abort CMake after fatal error. + message(STATUS "") + message(STATUS "") + message(STATUS "Could not find wolfssl in any parent directory named wolfssl-${THIS_USER}, wolfssl-master, or wolfssl.\n" + "Try setting WOLFSSL_ROOT environment variable, cmake variable in project, copy source, or use managed components.") + message(STATUS "") + message(STATUS "") + # Abort CMake after fatal error. (or not?) endif() set(INCLUDE_PATH ${WOLFSSL_ROOT}) @@ -379,22 +515,24 @@ else() endif() endif() + message(STATUS "WOLFSSL_EXTRA_PROJECT_DIR = ${WOLFSSL_EXTRA_PROJECT_DIR}") set(COMPONENT_SRCDIRS "\"${WOLFSSL_ROOT}/src/\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif/esp_crt_bundle\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/atmel\"" "\"${WOLFSSL_EXTRA_PROJECT_DIR}\"" ) # COMPONENT_SRCDIRS message(STATUS "This COMPONENT_SRCDIRS = ${COMPONENT_SRCDIRS}") - # wolfSSL user_settings.h is in the local project. + # wolfSSL user_settings.h may be in the local project. + # TODO check if exists and possibly set to ESP-IDF set(WOLFSSL_PROJECT_DIR "${CMAKE_HOME_DIRECTORY}/components/wolfssl") - # add_definitions(-DWOLFSSL_USER_SETTINGS_DIR="${WOLFSSL_PROJECT_DIR}/include/user_settings.h") string(REPLACE "/" "//" STR_WOLFSSL_PROJECT_DIR "${WOLFSSL_PROJECT_DIR}") - add_definitions(-DWOLFSSL_USER_SETTINGS_DIR="${STR_WOLFSSL_PROJECT_DIR}//include//user_settings.h") - + add_compile_definitions(WOLFSSL_USER_SETTINGS_DIR="${STR_WOLFSSL_PROJECT_DIR}/include/user_settings.h") + message(STATUS "Added definition for user_settings.h: -DWOLFSSL_USER_SETTINGS_DIR=\"${STR_WOLFSSL_PROJECT_DIR}//include//user_settings.h\"") # Espressif may take several passes through this makefile. Check to see if we found IDF string(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "" WOLFSSL_FOUND_IDF) @@ -427,8 +565,7 @@ else() message(STATUS "**************************************************************************************") message(STATUS "") - message(FATAL_ERROR "Please use wolfSSL in either local project or Espressif components, but not both.") - # Abort CMake after fatal error. + message(STATUS "Please use wolfSSL in either local project or Espressif components, but not both.") # Optional: if you change the above FATAL_ERROR to STATUS you can warn at runtime with this macro definition: set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING") @@ -536,7 +673,9 @@ else() # depending on the environment, we may need to swap backslashes with forward slashes string(REPLACE "\\" "/" RTOS_IDF_PATH "$ENV{IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") - string(REPLACE "\\" "/" WOLFSSL_ROOT ${WOLFSSL_ROOT}) + if(WOLFSSL_ROOT) + string(REPLACE "\\" "/" WOLFSSL_ROOT ${WOLFSSL_ROOT}) + endif() if(IS_DIRECTORY "${RTOS_IDF_PATH}") message(STATUS "Found current RTOS path: ${RTOS_IDF_PATH}") @@ -552,7 +691,7 @@ else() message(STATUS "THIS_IDF_PATH = $THIS_IDF_PATH") # wolfSSL-specific include directories set(COMPONENT_ADD_INCLUDEDIRS - "./include" # this is the location of wolfssl user_settings.h + "./include" # this is the location of local project wolfssl user_settings.h "\"${WOLFSSL_ROOT}/\"" "\"${WOLFSSL_ROOT}/wolfssl/\"" "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/\"" @@ -601,6 +740,7 @@ else() "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_cortexm.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_x86_64.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_x86_64_asm.S\"" + "\"${WOLFSSL_ROOT}/examples\"" # Examples are distributed in Managed Components, but not part of a project. "\"${EXCLUDE_ASM}\"" ) @@ -622,15 +762,120 @@ else() # see https://docs.espressif.com/projects/esp-idf/en/stable/esp32/migration-guides/release-5.x/build-system.html?highlight=space%20path # set(EXTRA_COMPONENT_DIRS "${COMPONENT_SRCDIRS}") - idf_component_register( - SRC_DIRS "${COMPONENT_SRCDIRS}" - INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}" - REQUIRES "${COMPONENT_REQUIRES}" - EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}" - PRIV_REQUIRES - "${THIS_INCLUDE_TIMER}" - "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark - ) + + if(WOLFSSL_ROOT) + # Only register the component if we found wolfSSL source. + # This is important to allow Cmake to finish to completion, otherwise the UI + # may not be able to display the Kconfig settings to fix a bad or missing source. + idf_component_register( + SRC_DIRS "${COMPONENT_SRCDIRS}" + INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}" + REQUIRES "${COMPONENT_REQUIRES}" + EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}" + PRIV_REQUIRES + "${THIS_ESP_TLS}" + "${THIS_INCLUDE_TIMER}" + "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark + ) + else() + # Register the component simply to allow CMake to complete, but there's no wolfSSL source. + # Expect many other errors, but the project should at least be loadable and UI can edit Kconfig settings. + idf_component_register() + message(STATUS "Warning: wolfSSL component not registered as no source code found (WOLFSSL_ROOT is blank)") + endif() + +# function(WOLFSSL_INIT_CERT_BUNDLE) +if( CONFIG_WOLFSSL_CERTIFICATE_BUNDLE + AND NOT CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + AND NOT ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") + ) + if (CMAKE_BUILD_EARLY_EXPANSION) + message(ERROR "Bundle Cert initialization must occur during CMAKE_BUILD_EARLY_EXPANSION") + endif() + # reminder: we need a value for wolfSSL root first! + if( "${WOLFSSL_ROOT}" STREQUAL "" ) + message(ERROR "Certificate bundles need a value for WOLFSSL_ROOT") + endif() + set(WOLFSSL_ESP_CRT_BUNDLE_DIR ${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif/esp_crt_bundle) + message(STATUS "WOLFSSL_ESP_CRT_BUNDLE_DIR=${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + if(EXISTS "${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + set(bundle_name "x509_crt_bundle_wolfssl") + + # For now the certs are in the same directory + set(DEFAULT_CRT_DIR "${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + + # Generate custom certificate bundle using the generate_cert_bundle utility + set(GENERATE_CERT_BUNDLEPY ${python} ${WOLFSSL_ESP_CRT_BUNDLE_DIR}/gen_crt_bundle.py) + + if(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_all.pem ${DEFAULT_CRT_DIR}/cacrt_local.pem) + elseif(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_CMN) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_all.pem ${DEFAULT_CRT_DIR}/cacrt_local.pem) + list(APPEND args --filter ${DEFAULT_CRT_DIR}/cmn_crt_authorities.csv) + endif() + + # Add deprecated root certs if enabled. This config is not visible if the default cert + # bundle is not selected + if(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEPRECATED_LIST) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_deprecated.pem) + endif() + + if(CONFIG_WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE) + get_filename_component(custom_bundle_path + ${CONFIG_WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE_PATH} ABSOLUTE BASE_DIR "${project_dir}") + list(APPEND crt_paths ${custom_bundle_path}) + message(STATUS "Using a custom wolfSSL bundle path: ${custom_bundle_path}") + else() + message(STATUS "Not using a custom wolfSSL bundle path.") + endif() + list(APPEND args --input ${crt_paths} -q) + + message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") + get_filename_component(crt_bundle + ${bundle_name} + ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") + + message(STATUS "Setting up bundle generate: ${GENERATE_CERT_BUNDLEPY} ${args}") + message(STATUS "Depends on custom bundle path: ${custom_bundle_path}") + message(STATUS "crt_bundle ${crt_bundle}") + message(STATUS "COMPONENT_LIB ${COMPONENT_LIB}") + message(STATUS "GENERATE_CERT_BUNDLEPY ${GENERATE_CERT_BUNDLEPY}") + message(STATUS "args ${args}") + message(STATUS "cert_bundle ${cert_bundle}") + + # Generate bundle according to config + # File is generated at build time, not cmake load + add_custom_command(OUTPUT ${crt_bundle} + COMMAND ${GENERATE_CERT_BUNDLEPY} ARGS ${args} + DEPENDS ${custom_bundle_path} + VERBATIM) + + if(EXISTS "${crt_bundle}") + message(STATUS "Bundle file exists from prior build: ${crt_bundle}") + else() + message(STATUS "Bundle file expected during next build: ${crt_bundle}") + endif() + + # Reminder the file is generated at build time, not cmake load time. + message(STATUS "wolfSSL Cert Bundle File to be created at build time in: ${crt_bundle}") + + add_custom_target(custom_wolfssl_bundle DEPENDS ${cert_bundle}) + + # the wolfSSL crtificate bundle is baked into wolfSSL + add_dependencies(${COMPONENT_LIB} custom_wolfssl_bundle) + + # COMPONENT_LIB may vary: __idf_wolfssl, __idf_esp_wolfssl, etc + # target_add_binary_data(__idf_wolfssl ${crt_bundle} BINARY) + target_add_binary_data(${COMPONENT_LIB} ${crt_bundle} BINARY) + set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + APPEND PROPERTY ADDITIONAL_CLEAN_FILES + "${crt_bundle}") + else() + message(STATUS "WARNING: CONFIG_WOLFSSL_CERTIFICATE_BUNDLE enabled but directory not found: ${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + endif() +endif() + +# endfunction() # WOLFSSL_INIT_CERT_BUNDLE # Some optional diagnostics. Verbose ones are truncated. if (VERBOSE_COMPONENT_MESSAGES) @@ -662,6 +907,12 @@ else() endif() # target_sources(wolfssl PRIVATE "\"${WOLFSSL_ROOT}/wolfssl/\"" "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt\"") + message(STATUS "DETECTED_PROJECT_NAME=${CMAKE_PROJECT_NAME}") + message(STATUS "COMPONENT_TARGET=${COMPONENT_TARGET}") + target_compile_definitions(${COMPONENT_TARGET} PRIVATE DETECTED_PROJECT_NAME="${CMAKE_PROJECT_NAME}") + if( "${CMAKE_PROJECT_NAME}" STREQUAL "esp_http_client_example" ) + target_compile_definitions(${COMPONENT_TARGET} PRIVATE APP_ESP_HTTP_CLIENT_EXAMPLE="y") + endif() endif() # CMAKE_BUILD_EARLY_EXPANSION @@ -707,7 +958,7 @@ function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) message(STATUS "Found ${VAR_OUPUT}=${VAR_VALUE}") # the interesting part is defining the VAR_OUPUT name a value to use in the app - add_definitions(-D${VAR_OUPUT}=\"${VAR_VALUE}\") + add_compile_definitions(${VAR_OUPUT}=\"${VAR_VALUE}\") else() # if we get here, check the execute_process command and parameters. message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT") @@ -715,35 +966,89 @@ function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) endif() endfunction() # LIBWOLFSSL_SAVE_INFO +execute_process( + COMMAND ${git_cmd} "rev-parse" "--is-inside-work-tree" + OUTPUT_VARIABLE IS_GIT_REPO + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + # create some programmatic #define values that will be used by ShowExtendedSystemInfo(). # see wolfcrypt\src\port\Espressif\esp32_utl.c -if(NOT CMAKE_BUILD_EARLY_EXPANSION) +if(NOT CMAKE_BUILD_EARLY_EXPANSION AND WOLFSSL_ROOT AND (IS_GIT_REPO STREQUAL "true")) set (git_cmd "git") message(STATUS "Adding macro definitions:") # LIBWOLFSSL_VERSION_GIT_ORIGIN: git config --get remote.origin.url - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "config" "--get" "remote.origin.url" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "config" "--get" "remote.origin.url" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_ORIGIN "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_BRANCH: git rev-parse --abbrev-ref HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--abbrev-ref" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--abbrev-ref" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_BRANCH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_HASH: git rev-parse HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_SHORT_HASH: git rev-parse --short HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_SHORT_HASH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_HASH_DATE git show --no-patch --no-notes --pretty=\'\%cd\' - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} + "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH_DATE "${TMP_OUT}" "${TMP_RES}") LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_WOLFSSL_ROOT "${WOLFSSL_ROOT}" "${TMP_RES}") - message(STATUS "************************************************************************************************") - message(STATUS "wolfssl component config complete!") - message(STATUS "************************************************************************************************") endif() + +# Ensure flag "-DWOLFSSL_ESPIDF" is already in CMAKE_C_FLAGS if not yet found from project +string(FIND "${CMAKE_C_FLAGS}" "-DWOLFSSL_ESPIDF" FLAG_ALRREADY_FOUND_WOLFSSL_ESPIDF) + +if(FLAG_ALRREADY_FOUND_WOLFSSL_ESPIDF EQUAL -1) + # Flag not found, append it + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESPIDF") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +endif() + +if(WOLFSSL_ROOT) + message(STATUS "Using wolfSSL in ${WOLFSSL_ROOT}") + + # PlatformIO does not process script from from the Espressif cmake process. + # We need to know where wolfSSL source code was found, so save it in the + # PIO_WOLFSSL_ROOT environment variable to later be read by extra_script.py + + set(ENV{PIO_WOLFSSL_ROOT} "${WOLFSSL_ROOT}") + message(STATUS "PIO_WOLFSSL_ROOT = $ENV{PIO_WOLFSSL_ROOT}") + message(STATUS "PLATFORMIO_BUILD_DIR = $ENV{PLATFORMIO_BUILD_DIR}") + # See esp-tls Kconfig; menu "ESP-TLS", ESP_TLS_LIBRARY_CHOOSE + if(CONFIG_ESP_TLS_USING_WOLFSSL) + if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) + message(STATUS "This version of wolfSSL is not supported on the ESP8266 esp-tls at this time. Check ESP-TLS config") + else() + message(STATUS "wolfSSL will be used for ESP-TLS") + endif() + else() + message(STATUS "WARNING: wolfSSL NOT selected for ESP-TLS. Features and performance will be limited.") + endif() +else() + message(STATUS "") + message(STATUS "Consider setting WOLFSSL_ROOT environment variable, use Kconfig setting, or set manually in this cmake file, above.") + message(STATUS "") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "ERROR: Could not find wolfSSL Source Code") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") +endif() + +message(STATUS "************************************************************************************************") +message(STATUS "wolfSSL component config complete!") +message(STATUS "************************************************************************************************") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/Kconfig b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/Kconfig new file mode 100644 index 000000000..150913190 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/Kconfig @@ -0,0 +1,523 @@ +# Kconfig template +# +# Copyright (C) 2006-2025 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 +# + +# Kconfig File Version 5.7.2.001 for esp-idf integration + +# Kconfig Format Rules +# +# See: +# https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/kconfig.html +# +# Format rules for Kconfig files are as follows: +# +# Option names in any menus should have consistent prefixes. The prefix +# currently should have at least 3 characters. +# +# The unit of indentation should be 4 spaces. All sub-items belonging to a +# parent item are indented by one level deeper. For example, menu is indented +# by 0 spaces, config menu by 4 spaces, help in config by 8 spaces, and the +# text under help by 12 spaces. +# +# No trailing spaces are allowed at the end of the lines. +# +# The maximum length of options is NOT 50 characters as documented. +# kconfcheck will complain that options should be 40 at most. +# +# Fix option lengths first. Superfluous errors on other lines may occur. +# +# The maximum length of lines is 120 characters. +# +# python -m kconfcheck +# +# --------------------------------------------------------------------------------------------------------------------- +# Begin main wolfSSL configuration menu +# --------------------------------------------------------------------------------------------------------------------- +# See ESP-IDF esp-tls component for config TLS_STACK_WOLFSSL + +menu "wolfSSL" + + menu "Hardening" + config ESP_WOLFSSL_WC_NO_HARDEN + bool "Disable wolfSSL hardening" + default n + help + Sets WC_NO_HARDEN + + config ESP_WOLFSSL_TFM_TIMING_RESISTANT + bool "Enable TFM Timing Resistant Code" + default n + help + Sets TFM_TIMING_RESISTANT. + + endmenu # Hardening + + config ESP_WOLFSSL_ENABLE_BENCHMARK + bool "Enable wolfSSL Benchmark Library" + default n + help + Enables wolfcrypt/benchmark/benchmark.c code for benchmark metrics. Disables NO_CRYPT_BENCHMARK. + + + menu "Benchmark Debug" + config ESP_DEBUG_WOLFSSL_BENCHMARK_TIMING + bool "Enable benchmark timing debug" + depends on ESP_WOLFSSL_ENABLE_BENCHMARK + default n + help + Enable wolfssl debug for benchmark metric timing (CPU Cycles, RTOS ticks, etc). + + config ESP_WOLFSSL_BENCHMARK_TIMER_DEBUG + bool "Enable benchmark timer debug" + depends on ESP_WOLFSSL_ENABLE_BENCHMARK + default n + help + Turn on timer debugging (used when CPU cycles not available) + + endmenu # Benchmark Debug + + # ----------------------------------------------------------------------------------------------------------------- + # wolfCrypt Test + # ----------------------------------------------------------------------------------------------------------------- + config ESP_WOLFSSL_ENABLE_TEST + bool "Enable wolfCrypt Test Library" + default n + help + Enables wolfcrypt/test/test.c code for testing. Disables NO_CRYPT_TEST. + + menu "wolfCrypt tests" + config WOLFSSL_HAVE_WOLFCRYPT_TEST_OPTIONS + bool "Enable wolfCrypt Test Options" + depends on ESP_WOLFSSL_ENABLE_TEST + default n + help + Enables HAVE_WOLFCRYPT_TEST_OPTIONS + + config TEST_ESPIDF_ALL_WOLFSSL + bool "Enable all features to use in tests" + depends on ESP_WOLFSSL_ENABLE_TEST + default n + help + Enables TEST_ESPIDF_ALL_WOLFSSL + + endmenu # wolfCrypt tests + + # ----------------------------------------------------------------------------------------------------------------- + # Apple HomeKit Options + # ----------------------------------------------------------------------------------------------------------------- + menu "Apple HomeKit" + config WOLFSSL_APPLE_HOMEKIT + bool "Enable Apple HomeKit options" + default n + help + Enables FP_MAX_BITS (8192 * 2), SRP, ChaCha, Poly1305, Base64 encoding needed for Apple HomeKit. + endmenu # Apple HomeKit + # ----------------------------------------------------------------------------------------------------------------- + + config ESP_WOLFSSL_DISABLE_MY_ECC + bool "Disable ECC in my project" + default "n" + help + ECC is enabled by default. Select this option to disable. + + config ESP_WOLFSSL_ENABLE_MY_USE_RSA + bool "Enable RSA in my project" + default "n" + help + RSA is disabled by default. Select this option to enable. + + config ESP_WOLFSSL_BENCHMARK + bool "Enable wolfSSL Benchmark" + default n + help + Enables user settings relevant to benchmark code + + config ESP_TLS_USING_WOLFSSL_SPECIFIED + bool "Use the specified wolfssl for ESP-TLS" + default Y + help + Includes wolfSSL from specified directory (not using esp-wolfssl). + + config ESP_WOLFSSL_NO_USE_FAST_MATH + bool "Disable FAST_MATH library and all ESP32 Hardware Acceleration" + select ESP_WOLFSSL_NO_HW + select ESP_WOLFSSL_NO_HW_AES + select ESP_WOLFSSL_NO_HW_HASH + select ESP_WOLFSSL_NO_HW_RSA_PRI + select ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + default n + help + When disabling all hardware acceleration for smaller memory footprint, + disabling TFM fast math provides faster wolfSSL software algorithms in an + even smaller flash memory footprint. + + menu "Protocol Config" + config WOLFSSL_HAVE_ALPN + bool "Enable ALPN (Application Layer Protocol Negotiation) in wolfSSL" + default y + + config WOLFSSL_ALLOW_TLS13 + bool "Allow TLS 1.3" + default y + help + Allow TLS to fallback to TLS1.2. Memory footprint will likely be larger for TLS1.2. + When disabled HTTPS and MQTT over TLS connections will fail if TLS1.3 not accepted. + + config WOLFSSL_ALLOW_TLS12 + bool "Allow TLS 1.2" + default n + help + Allow TLS to fallback to TLS1.2. Memory footprint will likely be larger for TLS1.2. + When disabled HTTPS and MQTT over TLS connections will fail if TLS1.3 not accepted. + + config WOLFSSL_HAVE_TLS_EXTENSIONS + bool "Enable TLS Extensions" + default y + help + Sets HAVE_TLS_EXTENSIONS which is needed for TLS 1.3, SNI, ALPN, and more. + + config WOLFSSL_ALT_CERT_CHAINS + bool "Enable Alternate Certificate Chains" + default n + help + The option relaxes the default strict wolfSSL certificate chain processing. This + will typically need to be enabled when loading only a CA file. Typically solves + the -188 ASN_NO_SIGNER_E error. Use with caution. + + config WOLFSSL_HAVE_OCSP + bool "Enable OCSP (Online Certificate Status Protocol) in wolfSSL" + default n + help + Sets HAVE_OCSP + + endmenu # Protocol Config + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + config TLS_STACK_WOLFSSL + # Invisible option that locks TLS_STACK_WOLFSSL to ESP_TLS_USING_WOLFSSL + bool + default n + select FREERTOS_ENABLE_BACKWARD_COMPATIBILITY + help + Includes wolfSSL in ESP-TLS so that it can be compiled with wolfSSL as its SSL/TLS library. + Enabled when wolfSSL is selected in ESP_TLS_LIBRARY_CHOOSE. + + menu "wolfSSL ESP-TLS" + depends on ESP_TLS_USING_WOLFSSL + + menu "Certificate Bundle" + depends on ESP_TLS_USING_WOLFSSL + + config WOLFSSL_CERTIFICATE_BUNDLE + bool "Enable trusted root certificate bundle" + default y if ESP_TLS_USING_WOLFSSL + default n + depends on ESP_TLS_USING_WOLFSSL + help + Enable support for large number of default root certificates + + When enabled this option allows user to store default as well + as customer specific root certificates in compressed format rather + than storing full certificate. For the root certificates the public key and the subject name + will be stored. + + config WOLFSSL_NO_ASN_STRICT + bool "Relax Certificate ASN Strict Checks" + default n + depends on ESP_TLS_USING_WOLFSSL + help + Allows sub-optimal certificate ASN checks. Unless using a bundle with known issues, + it is recommended to NOT enable this. + + config WOLFSSL_ASN_ALLOW_0_SERIAL + bool "Allow cert missing an ASN Serial Number" + default y + depends on ESP_TLS_USING_WOLFSSL + help + Although not recommended, there may be certificates in the bundle that are missing + a serial number. This option allows the missing value without having to fully + disable strict ASN checking with WOLFSSL_NO_ASN_STRICT. + + choice WOLFSSL_DEFAULT_CERTIFICATE_BUNDLE + bool "Default certificate bundle options" + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + default WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL + + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL + bool "Use the full default certificate bundle" + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_CMN + bool "Use only the most common certificates from the default bundles" + help + Use only the most common certificates from the default bundles, reducing the size with 50%, + while still having around 99% coverage. + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + bool "Do not use the default certificate bundle" + endchoice + + config WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + default n + bool "Add custom certificates to the default bundle" + config WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE_PATH + depends on WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + string "Custom certificate bundle path" + help + Name of the custom certificate directory or file. This path is evaluated + relative to the project root directory. + + config WOLFSSL_CERTIFICATE_BUNDLE_DEPRECATED_LIST + bool "Add deprecated root certificates" + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL && !WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + help + Include the deprecated list of root certificates in the bundle. + This list gets updated when a certificate is removed from the Mozilla's + NSS root certificate store. This config can be enabled if you would like + to ensure that none of the certificates that were deployed in the product + are affected because of the update to bundle. In turn, enabling this + config keeps expired, retracted certificates in the bundle and it may + pose a security risk. + + - Deprecated cert list may grow based based on sync with upstream bundle + - Deprecated certs would be be removed in ESP-IDF (next) major release + + config WOLFSSL_CERTIFICATE_BUNDLE_MAX_CERTS + int "Maximum no of certificates allowed in certificate bundle" + default 200 + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + + endmenu + endmenu # wolfSSL ESP-TLS + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + config ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + bool "Modify default hardware acceleration settings" + default n + help + When disabling all hardware acceleration for smaller memory footprint, + disabling TFM fast math provides faster wolfSSL software algorithms in an + even smaller flash memory footprint. + Typically used for debugging, analysis, or optimizations. The default + hardware acceleration features can be each manually adjusted. + + menu "wolfSSL Hardware Acceleration" + + config ESP_WOLFSSL_NO_ESP32_CRYPT + bool "Disable all ESP32 Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + select ESP_WOLFSSL_NO_HW_AES + select ESP_WOLFSSL_NO_HW_HASH + select ESP_WOLFSSL_NO_HW_RSA_PRI + select ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + help + Hardware acceleration enabled by default. When selected defines: NO_ESP32_CRYPT. + Consider disabling FASTMATH (other libraries are faster in software and smaller) + + config ESP_WOLFSSL_NO_HW_AES + bool "Disable all ESP32 AES Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default.When selected defines: NO_HW_AES + + config ESP_WOLFSSL_NO_HW_HASH + bool "Disable all ESP32 SHA Hash Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_HASH + + config ESP_WOLFSSL_NO_HW_RSA_PRI + bool "Disable all ESP32 RSA Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + select ESP_WOLFSSL_NO_HW_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI + + config ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + bool "Disable all ESP32 Multiplication Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI_MP_MUL + + config ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + bool "Disable all ESP32 Modular Multiplication Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI_MULMOD + + config ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + bool "Disable all ESP32 RSA Exponential Math Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. + Select this option to force disable: NO_HW_RSA_PRI_EXPTMOD + + config ESP_WOLFSSL_DEBUG_ESP_HW_MULTI_RSAMAX_BITS + bool "Enable debugging of RSA Multiplication operand length" + default n + help + Prints an esp log warning to the default console UART when one of the + multiplication operands exceeds the maximum size supported by hardware, + requiring fallback to software. This can be helpful to pick key sizes + when performance is critical. See also metrics for counting instances. + + config ESP_WOLFSSL_DEBUG_ESP_HW_MOD_RSAMAX_BITS + bool "Enable debugging of RSA Modular operand length" + default n + help + Prints an esp log warning to the default console UART when one of the + modular math operands exceeds the maximum size supported by hardware, + requiring fallback to software. This can be helpful to pick key sizes + when performance is critical. See also metrics for counting instances. + + endmenu # wolfSSL Hardware Acceleration + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Experimental Options" + + config ESP_WOLFSSL_EXPERIMENTAL_SETTINGS + bool "Enable wolfSSL Experimental Settings" + default n + help + Enables experimental settings for wolfSSL. See documentation. + + config ESP_WOLFSSL_ENABLE_KYBER + bool "Enable wolfSSL Kyber" + default n + help + Enable debugging messages for wolfSSL. See user_settings.h for additional debug options. + + endmenu # wolfSSL Experimental Options + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Debug Options" + config ESP_WOLFSSL_DEBUG_WOLFSSL + bool "Enable wolfSSL Debugging" + default n + help + Enable debugging messages for wolfSSL. See user_settings.h for additional debug options. + + config ESP_WOLFSSL_TEST_LOOP + bool "Run test apps in a loop until failure" + default y + help + Enable a loop wrapper for benchmark, http_client, and wolfssl test apps. + + endmenu # wolfSSL Debug Options + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Customization" + config CUSTOM_SETTING_WOLFSSL_ROOT + string "Enter a path for wolfSSL source code" + default "~/workspace/wolfssl" + help + This option lets you specify a directory for the wolfSSL source code (typically a git clone). + Enter the path using forward slashes (e.g., C:/myfolder/mysubfolder) or double backslashes + (e.g., C:\\myfolder\\mysubfolder). + + endmenu # wolfSSL Customization + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "Component Config" + config IGNORE_ESP_IDF_WOLFSSL_COMPONENT + bool "Ignore the ESP-IDF component of wolfSSL (if present)" + default n + help + Ignores wolfSSL present in the esp-idf/components directory. Requires wolfssl as a local component. + + config IGNORE_LOCAL_WOLFSSL_COMPONENT + bool "Ignore the local component of wolfSSL (if present)" + default n + help + Ignores wolfSSL present in the local project components directory. + Requires wolfssl as a ESP-IDF component. + + endmenu # Component Config + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "Utility Config" + config USE_WOLFSSL_ESP_SDK_TIME + bool "Enable wolfSSL time helper functions" + default n + help + Enables use of various time and date setting functions found in the esp-sdk-lib.h file. + + config USE_WOLFSSL_ESP_SDK_WIFI + bool "Enable wolfSSL WiFi helper functions" + default n + help + Enables use of various time and date setting functions found in the esp-sdk-lib.h file. + + endmenu # Utility Config +endmenu # wolfSSL +# --------------------------------------------------------------------------------------------------------------------- + + +# --------------------------------------------------------------------------------------------------------------------- +menu "wolfSSH" + config ESP_ENABLE_WOLFSSH + bool "Enable wolfSSH options" + default n + help + Enables WOLFSSH_TERM, WOLFSSL_KEY_GEN, WOLFSSL_PTHREADS, WOLFSSH_TEST_SERVER, WOLFSSH_TEST_THREADING + + config ESP_WOLFSSL_DEBUG_WOLFSSH + bool "Enable wolfSSH debugging" + default n + help + Enable wolfSSH debugging macro. See user_settings.h + +endmenu # wolfSSH +# --------------------------------------------------------------------------------------------------------------------- + +# --------------------------------------------------------------------------------------------------------------------- +menu "wolfMQTT" + config ESP_ENABLE_WOLFMQTT + bool "Enable wolfMQTT options" + default n + help + Enables WOLFMQTT + + config ESP_WOLFSSL_DEBUG_WOLFMQTT + bool "Enable wolfMQTT debugging" + default n + help + Enable wolfMQTT debugging macro. See user_settings.h + +endmenu # wolfMQTT +# --------------------------------------------------------------------------------------------------------------------- diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/README.md b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/README.md new file mode 100644 index 000000000..d77912416 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/README.md @@ -0,0 +1,162 @@ +# wolfSSL Espressif Component + +This is the directory for wolfSSL as an Espressif ESP-IDF component. + +Other options are available, such as installing wolfSSL as a local _project_ component using the [Managed Component](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/). + +Enabling this wolfSSL ESP-IDF component allows other ESP-IDF libraries such as those that depend on [ESP-TLS](https://github.com/espressif/esp-idf/tree/master/components/esp-tls) +to also use the wolfSSL library. (See [github.com/wolfSSL/wolfssl](https://github.com/wolfSSL/wolfssl)) + +The wolfSSL source code is not included here. Instead, the `idf.py menuconfig` option can be used to configure the +`sdkconfig` file setting: `CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT` to point to the desired wolfSSL code. + +## Directory Contents + +This directory must contain, at a minimum: + +- `CMakeLists.txt` +- `./include/user_settings.h` + +The directory should also contain: +- `Kconfig` +- `component.mk` + +The directory may contain wolfSSL source, for example with a [Managed Component](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/), +or if the `setup.sh` script was used from [wolfSSL/IDE/Espressif/ESP-IDF](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF). + + +Under normal circumstances when the wolfSSL source is not included here, the `CMakeLists.txt` will search for it in this order: + +- A hard-coded `WOLFSSL_ROOT` cmake variable. +- `WOLFSSL_ROOT` Environment Variable +- The `CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT` value in the `sdkconfig` file, from the `Kconfig` option. +- Any parent directories, up to the root (if this directory is in the ESP-IDF components) +- Any parent directories, up to the root (if this directory is a project component) + +While recursing up the directory tree, the following names of wolfSSL directories will be considered: + +- `wolfssl-[current user name]` +- `wolfssl-master` +- `wolfssl` + +## Getting Started + +See the `Espressif Getting Started Guide`. + +``` +# Set environment variable to ESP-IDF location +# For example, VisualGDB in WSL +WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.2 +WRK_IDF_PATH=/mnt/c/SysGCC/esp32-master/esp-idf/v5.3-master + +# Or wherever the ESP-IDF is installed: +WRK_IDF_PATH=~/esp/esp-idf + +echo "Run export.sh from ${WRK_IDF_PATH}" +. ${WRK_IDF_PATH}/export.sh + +cd [your project] + +idf.py menuconfig +``` + +Enable wolfSSL to be used in the ESP-TLS: + +``` +Component config ---> + ESP-TLS ---> + Choose SSL/TLS library for ESP-TLS (See help for more Info) + (X) wolfSSL (License info in wolfSSL directory README) +``` + +Adjust wolfSSL settings, such as path to source code as needed: + +``` +Component config ---> + wolfSSL ---> + [*] Include wolfSSL in ESP-TLS + [*] Use the specified wolfssl for ESP-TLS + (~/workspace/wolfssl) Enter a path for wolfSSL source code +``` + +## Configuration + +All settings for wolfSSL are adjusted in the [include/user_settings.h](./include/user_settings.h) file. + +The `user_settings.h` file should not be included directly. Instead, `#include ` +before any other wolfSSL headers, like this: + + +```c +/* ESP-IDF */ +#include +#include "sdkconfig.h" + +/* wolfSSL */ +/* Always include wolfcrypt/settings.h before any other wolfSSL file. */ +/* Reminder: settings.h pulls in user_settings.h; don't include it here. */ +#if defined(WOLFSSL_USER_SETTINGS) + #include + #if defined(WOLFSSL_ESPIDF) + #include + #include + #include + #include + #include + #else + #error "Problem with wolfSSL user_settings. " \ + "Check components/wolfssl/include " \ + "and confirm WOLFSSL_USER_SETTINGS is defined, " \ + "typically in the component CMakeLists.txt" + #endif +#else + /* Define WOLFSSL_USER_SETTINGS project wide for settings.h to include */ + /* wolfSSL user settings in ./components/wolfssl/include/user_settings.h */ + #error "Missing WOLFSSL_USER_SETTINGS in CMakeLists or Makefile:\ + CFLAGS +=-DWOLFSSL_USER_SETTINGS" +#endif +``` + +## Examples + +See the wolfSSL examples: + +- [wolfSSL Core Examples](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples) +- [wolfSSL Additional Examples](https://github.com/wolfSSL/wolfssl-examples/tree/master/ESP32) +- [wolfSSH Core Examples](https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples) +- [wolfSSH Additional Examples](https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif) +- [wolfMQTT Examples](https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples) + +## Platforms + +The ESP-IDF wolfSSL is also available for PlatformIO: + +- [Release wolfSSL](https://registry.platformio.org/search?q=owner%3Awolfssl) +- [Staging / Preview wolfSSL](https://registry.platformio.org/search?q=owner%3Awolfssl-staging) + +The wolfSSL library can also be used for Espressif with Arduino: + +- [arduino.cc/reference/en/libraries/wolfssl](https://www.arduino.cc/reference/en/libraries/wolfssl/) +- [github.com/wolfSSL/Arduino-wolfSSL](https://github.com/wolfSSL/Arduino-wolfSSL) + + +## Additional Information + +- [wolfSSL Documentation](https://www.wolfssl.com/documentation/manuals/wolfssl/index.html) and [docs/espressif](https://www.wolfssl.com/docs/espressif/) +- [wolfSSL FAQ](https://www.wolfssl.com/docs/frequently-asked-questions-faq/) +- [wolfSSL Products](https://www.wolfssl.com/products/) +- [www.wolfssl.com/espressif](https://www.wolfssl.com/espressif/) +- [More...](https://www.wolfssl.com/?s=espressif) + +## Contact + +Have a specific request or questions? We'd love to hear from you! Please contact us at support@wolfssl.com or open an issue on GitHub. + +## Licensing and Support + +wolfSSL (formerly known as CyaSSL) and wolfCrypt are either licensed for use under the GPLv2 (or at your option any later version) or a standard commercial license. For our users who cannot use wolfSSL under GPLv2 (or any later version), a commercial license to wolfSSL and wolfCrypt is available. + +See the LICENSE.txt, visit wolfssl.com/license, contact us at licensing@wolfssl.com or call +1 425 245 8247 + +View Commercial Support Options: [wolfssl.com/products/support-and-maintenance](wolfssl.com/products/support-and-maintenance) + diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/component.mk index 54ae8041f..83f414e50 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/component.mk @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # @@ -18,6 +18,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA # +$(info *********** wolfssl component ************) + # # Component Makefile # @@ -48,193 +50,257 @@ # define it here: CFLAGS +=-DWOLFSSL_USER_SETTINGS -# In the wolfSSL GitHub examples for Espressif, -# the root is 7 directories up from here: -WOLFSSL_ROOT := ../../../../../../../ +# Note that 4 source files created by autogen are excluded here. +# +# See these files commented out, below. Adjust as needed for your application: +# +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/async.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/selftest.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_first.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_last.o -# NOTE: The wolfSSL include diretory (e.g. user_settings.h) is + +# NOTICE: the WOLFSSL_ROOT setting MUST be relative! +# See https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/api-guides/build-system.html?highlight=must+relative#optional-component-specific-variables +# In the wolfSSL GitHub examples for Espressif: +# https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples +# When this wolfssl component.mk makefile is in [project]/components/wolfssl +# The root is 7 directories up from here (the location of of this component.mk): +# +WOLFSSL_ROOT ?= ../../../../../../.. +THIS_DIR := $(shell pwd) +WOLFSSL_ROOT_OBJ := $(THIS_DIR) + +# When running make from commandline or VisualGDB, the current path varies: +ifeq ("$(VISUALGDB_DIR)","") + # current path is typically /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/wolfssl + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL)) +else + # current path is typically /C/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/Debug/wolfssl + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL)) +endif + +# To set the location of a different location, it is best to use relative paths. +# +# Set WOLFSSL_ROOT to a relative path from the current component directory. +# For example, if the wolfssl_client is copied from the examples to test: +# +# cp -r /IDE/Espressif/ESP-IDF/examples/wolfssl_client/* /mnt/c/test/demo +# +# we run make in /mnt/c/test/demo +# component is in /mnt/c/test/demo/components/wolfssl +# wolfssl is in /mnt/c/workspace/wolfssl-master +# +# "/mnt/c" is 4 directories up: +# 2 for `./test/demo` from where we run `make`, plus +# 2 more from the location of `component.mk` located +# in `[current directory]/components/wolfssl`. +# +# Thus we need 4 parent reference to find the relative path to wolfSSL: +# WOLFSSL_ROOT := ../../../../workspace/wolfssl-master + +# Optional CFLAGS (make works without these; for reference only) +# CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl +# CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt +# CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif + +abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) + +# print-wolfssl-path-value: +# @echo "WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)" +# @echo "WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)" + +$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info THIS_DIR defined: $(THIS_DIR)) +$(info WOLFSSL_ROOT_OBJ defined: $(WOLFSSL_ROOT_OBJ)) + +# NOTE: The wolfSSL include directory (e.g. user_settings.h) is # located HERE in THIS project, and *not* in the wolfSSL root. COMPONENT_ADD_INCLUDEDIRS := . COMPONENT_ADD_INCLUDEDIRS += include -COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT). -COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfssl -COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfssl/wolfcrypt -COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfssl/wolfcrypt/port/Espressif -COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfcrypt/benchmark +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/. +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif + # COMPONENT_ADD_INCLUDEDIRS += $ENV(IDF_PATH)/components/freertos/include/freertos # COMPONENT_ADD_INCLUDEDIRS += "$ENV(IDF_PATH)/soc/esp32s3/include/soc" +# wolfSSL +COMPONENT_SRCDIRS := $(WOLFSSL_ROOT)/src -# WOLFSSL_ROOT := "" -COMPONENT_SRCDIRS := $(WOLFSSL_ROOT)src -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/src/port/atmel -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/benchmark -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/test -COMPONENT_SRCDIRS += include +# wolfcrypt +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src -COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT)wolfcrypt/src/aes_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/evp.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/misc.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/sha512_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/fe_x25519_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/aes_gcm_x86_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)src/bio.o +# Espressif +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/atmel +COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/evp.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/misc.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/sha512_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/fe_x25519_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_gcm_x86_asm.o ## ## wolfSSL ## -COMPONENT_OBJS := $(WOLFSSL_ROOT)src/bio.o -# COMPONENT_OBJS += src/conf.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/crl.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/dtls.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/dtls13.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/internal.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/keys.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/ocsp.o -# COMPONENT_OBJS += src/pk.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/quic.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/sniffer.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/ssl.o +## reminder object files may end up in `./build` or `build/debug` or `build/release`, depending on build environment & settings. +## +# COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o # part of ssl.c, omitted to avoid "does not need to be compiled separately" +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/conf.o # part of ssl.c +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/crl.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls13.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/internal.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/keys.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ocsp.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/pk.o # part of ssl.c +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/quic.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/sniffer.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o # COMPONENT_OBJS += src/ssl_asn1.o # COMPONENT_OBJS += src/ssl_bn.o # COMPONENT_OBJS += src/ssl_certman.o # COMPONENT_OBJS += src/ssl_crypto.o # COMPONENT_OBJS += src/ssl_misc.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/tls.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/tls13.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/wolfio.o -# COMPONENT_OBJS += src/x509.o -# COMPONENT_OBJS += src/x509_str.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls13.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/wolfio.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509.o # part of ssl.c +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509_str.o # part of ssl.c ## ## wolfcrypt ## -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/aes.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/arc4.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/asm.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/asn.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/async.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/blake2b.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/blake2s.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/camellia.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/chacha.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/chacha20_poly1305.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/cmac.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/coding.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/compress.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/cpuid.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/cryptocb.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/curve25519.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/curve448.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/des3.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/dh.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/dilithium.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/dsa.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ecc.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/eccsi.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ecc_fp.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ed25519.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ed448.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/error.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/evp.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ext_kyber.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ext_lms.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ext_xmss.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/falcon.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fe_448.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fe_low_mem.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fe_operations.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fips.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fips_test.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ge_448.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ge_low_mem.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ge_operations.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/hash.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/hmac.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/hpke.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/integer.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/kdf.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/logging.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/md2.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/md4.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/md5.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/memory.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/misc.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/pkcs12.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/pkcs7.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/poly1305.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/pwdbased.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/random.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/rc2.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ripemd.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/rsa.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sakke.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/selftest.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha256.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha3.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha512.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/signature.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/siphash.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sm2.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sm3.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sm4.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sphincs.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_arm32.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_arm64.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_armthumb.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_c32.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_c64.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_cortexm.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_dsp32.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_int.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_arm32.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_arm64.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_armthumb.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_c32.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_c64.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_cortexm.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_x86_64.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_x86_64.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/srp.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/tfm.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_dsp.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_encrypt.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_kyber.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_kyber_poly.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_lms.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_pkcs11.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_port.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_xmss.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfcrypt_first.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfcrypt_last.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfevent.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfmath.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/aes.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/arc4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/asm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/asn.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/async.o # autogen exclusion +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/blake2b.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/blake2s.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/camellia.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/chacha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/chacha20_poly1305.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/cmac.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/coding.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/compress.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/cpuid.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/cryptocb.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/curve25519.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/curve448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/des3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/dh.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/dilithium.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/dsa.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ecc.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/eccsi.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ecc_fp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ed25519.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ed448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/error.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/evp.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_mlkem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_lms.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_xmss.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/falcon.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_low_mem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_operations.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fips.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fips_test.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ge_448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ge_low_mem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ge_operations.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/hash.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/hmac.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/hpke.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/integer.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/kdf.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/logging.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/md2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/md4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/md5.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/memory.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/misc.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/pkcs12.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/pkcs7.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/poly1305.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/pwdbased.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/random.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/rc2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ripemd.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/rsa.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sakke.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/selftest.o # autogen exclusion +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha256.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha512.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/signature.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/siphash.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sm2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sm3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sm4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sphincs.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_arm32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_arm64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_armthumb.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_c32.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_c64.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_cortexm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_dsp32.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_int.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_arm32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_arm64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_armthumb.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_c32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_c64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_cortexm.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_x86_64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_x86_64.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/srp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/tfm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_dsp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_encrypt.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_mlkem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_mlkem_poly.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_lms.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_pkcs11.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_port.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_xmss.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_first.o # autogen exclusion +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_last.o # autogen exclusion +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfevent.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfmath.o ## ## Espressif ## -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_aes.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_mp.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_sha.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_util.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp_sdk_mem_lib.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp_sdk_time_lib.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp_sdk_wifi_lib.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp32_aes.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp32_mp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp32_sha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp32_util.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_mem_lib.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_time_lib.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_wifi_lib.o ## -## wolfcrypt benchmark (optional) +## wolfcrypt benchmark (needed for this benchmark example) ## -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/benchmark/benchmark.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark + ## ## wolfcrypt test (optional) ## -## COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/test/test.o +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test +## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test/include -## -## wolfcrypt -## -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/src +$(info ********** end wolfssl component **********) 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 1c30597da..8da276d1e 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 @@ -1,6 +1,6 @@ -/* user_settings.h +/* wolfssl-component include/user_settings.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -18,19 +18,57 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ +#define WOLFSSL_ESPIDF_COMPONENT_VERSION 0x01 + +/* Examples such as test and benchmark are known to cause watchdog timeouts. + * Note this is often set in project Makefile: + * CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 */ +#define WOLFSSL_ESP_NO_WATCHDOG 1 + +/* The Espressif project config file. See also sdkconfig.defaults */ +#include "sdkconfig.h" /* This user_settings.h is for Espressif ESP-IDF * * Standardized wolfSSL Espressif ESP32 + ESP8266 user_settings.h V5.7.0-1 * - * Do not include any wolfssl headers here + * Do not include any wolfssl headers here. * * When editing this file: - * ensure wolfssl_test and wolfssl_benchmark settings match. + * ensure all examples match. The template example is the reference. */ -/* The Espressif project config file. See also sdkconfig.defaults */ -#include "sdkconfig.h" +/* Naming convention: (see also esp32-crypt.h for the reference source). + * + * CONFIG_ + * This prefix indicates the setting came from the sdkconfig / Kconfig. + * + * May or may not be related to wolfSSL. + * + * The name after this prefix must exactly match that in the Kconfig file. + * + * WOLFSSL_ + * Typical of many, but not all wolfSSL macro names. + * + * Applies to all wolfSSL products such as wolfSSH, wolfMQTT, etc. + * + * May or may not have a corresponding sdkconfig / Kconfig control. + * + * ESP_WOLFSSL_ + * These are NOT valid wolfSSL macro names. These are names only used in + * the ESP-IDF Kconfig files. When parsed, they will have a "CONFIG_" + * suffix added. See next section. + * + * CONFIG_ESP_WOLFSSL_ + * This is a wolfSSL-specific macro that has been defined in the ESP-IDF + * via the sdkconfig / menuconfig. Any text after this prefix should + * exactly match an existing wolfSSL macro name. + * + * Applies to all wolfSSL products such as wolfSSH, wolfMQTT, etc. + * + * These macros may also be specific to only the project or environment, + * and possibly not used anywhere else in the wolfSSL libraries. + */ /* The Espressif sdkconfig will have chipset info. ** @@ -46,33 +84,264 @@ #undef WOLFSSL_ESPIDF #define WOLFSSL_ESPIDF -/* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ -#define NO_ESP_SDK_WIFI +/* Test various user_settings between applications by selecting example apps + * in `idf.py menuconfig` for Example wolfSSL Configuration settings: */ + +/* Turn on messages that are useful to see only in examples. */ +#define WOLFSSL_EXAMPLE_VERBOSITY + +/* Paths can be long, ensure the entire value printed during debug */ +#define WOLFSSL_MAX_ERROR_SZ 500 + +/* wolfSSL Examples: set macros used in example applications. + * + * These Settings NOT available in ESP-IDF (e.g. esp-tls) + * + * Any settings needed by ESP-IDF components should be explicitly set, + * and not by these example-specific settings via CONFIG_WOLFSSL_EXAMPLE_n + * + * ESP-IDF settings should be Kconfig "CONFIG_[name]" values when possible. */ +#if defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TEMPLATE) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/template */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TEST) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_test */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ + #define TEST_ESPIDF_ALL_WOLFSSL +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_BENCHMARK) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ + #define WOLFSSL_BENCHMARK_FIXED_UNITS_KB +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_CLIENT) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_client */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_SERVER) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_server */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfSSH Examples */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSH_TEMPLATE) + /* See https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples/wolfssh_template */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSH_ECHOSERVER) + /* See https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_ESP32_SSH_SERVER) + /* See https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif/ESP32/ESP32-SSH-Server */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_ESP8266_SSH_SERVER) + /* See https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif/ESP8266/ESP8266-SSH-Server */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfMQTT Examples */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFMQTT_TEMPLATE) + /* See https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples/wolfmqtt_template */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFMQTT_AWS_IOT_MQTT) + /* See https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples/AWS_IoT_MQTT */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfTPM Examples */ +#elif defined(CONFIG_WOLFTPM_EXAMPLE_NAME_ESPRESSIF) + /* See https://github.com/wolfSSL/wolfTPM/tree/master/IDE/Espressif */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* Apple HomeKit Examples */ +#elif defined(CONFIG_WOLFSSL_APPLE_HOMEKIT) + /* See https://github.com/AchimPieters/esp32-homekit-demo */ + +/* no example selected */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_NONE) + /* We'll assume the app needs to use wolfSSL sdk lib function */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* Other applications detected by cmake */ +#elif defined(APP_ESP_HTTP_CLIENT_EXAMPLE) + /* The wolfSSL Version of the client example */ + #if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C2) + /* Less memory available, so smaller key sizes: */ + #define FP_MAX_BITS (4096 * 2) + #else + #define FP_MAX_BITS (8192 * 2) + #endif + #define HAVE_ALPN + #define HAVE_SNI + #define OPENSSL_EXTRA_X509_SMALL + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES + #define OPENSSL_EXTRA + #ifndef WOLFSSL_ALWAYS_VERIFY_CB + #define WOLFSSL_ALWAYS_VERIFY_CB + #endif + #ifndef WOLFSSL_VERIFY_CB_ALL_CERTS + #define WOLFSSL_VERIFY_CB_ALL_CERTS + #endif + #ifndef KEEP_PEER_CERT + #define KEEP_PEER_CERT + #endif + +#elif defined(APP_ESP_HTTP_CLIENT) + /* The ESP-IDF Version */ + #define FP_MAX_BITS (8192 * 2) + #define HAVE_ALPN + #define HAVE_SNI + #define OPENSSL_EXTRA_X509_SMALL + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES + #define OPENSSL_EXTRA + #ifndef WOLFSSL_ALWAYS_VERIFY_CB + #define WOLFSSL_ALWAYS_VERIFY_CB + #endif + #ifndef WOLFSSL_VERIFY_CB_ALL_CERTS + #define WOLFSSL_VERIFY_CB_ALL_CERTS + #endif + #ifndef KEEP_PEER_CERT + #define KEEP_PEER_CERT + #endif +#else + #ifdef WOLFSSL_ESPIDF + /* #warning "App config undetected" */ + #endif + /* the code is older or does not have application name defined. */ +#endif /* Example wolfSSL Configuration app settings */ /* Experimental Kyber */ -#if 0 +#ifdef CONFIG_WOLFSSL_ENABLE_KYBER /* Kyber typically needs a minimum 10K stack */ #define WOLFSSL_EXPERIMENTAL_SETTINGS - #define WOLFSSL_HAVE_KYBER - #define WOLFSSL_WC_KYBER + #define WOLFSSL_HAVE_MLKEM + #define WOLFSSL_WC_MLKEM #define WOLFSSL_SHA3 + #if defined(CONFIG_IDF_TARGET_ESP8266) + /* With limited RAM, we'll disable some of the Kyber sizes: */ + #define WOLFSSL_NO_KYBER1024 + #define WOLFSSL_NO_KYBER768 + #define NO_SESSION_CACHE + #endif #endif +/* Enable AES for all examples */ +#ifdef NO_AES + #warning "Found NO_AES, wolfSSL AES Cannot be enabled. Check config." +#else + #define WOLFSSL_AES + #define WOLFSSL_AES_COUNTER + + /* Typically only needed for wolfssl_test, see docs. */ + #define WOLFSSL_AES_DIRECT +#endif + +/* Pick a cert buffer size: */ +/* #define USE_CERT_BUFFERS_2048 */ +/* #define USE_CERT_BUFFERS_1024 */ +#define USE_CERT_BUFFERS_2048 + +/* The Espressif sdkconfig will have chipset info. +** +** Some possible values: +** +** CONFIG_IDF_TARGET_ESP32 +** CONFIG_IDF_TARGET_ESP32S2 +** CONFIG_IDF_TARGET_ESP32S3 +** CONFIG_IDF_TARGET_ESP32C3 +** CONFIG_IDF_TARGET_ESP32C6 +*/ + +/* Optionally enable Apple HomeKit from compiler directive or Kconfig setting */ +#if defined(WOLFSSL_APPLE_HOMEKIT) || defined(CONFIG_WOLFSSL_APPLE_HOMEKIT) + /* SRP is known to need 8K; slow on some devices */ + #define FP_MAX_BITS (8192 * 2) + #define WOLFCRYPT_HAVE_SRP + #define HAVE_CHACHA + #define HAVE_POLY1305 + #define WOLFSSL_BASE64_ENCODE + #endif /* Apple HomeKit settings */ + +/* Used by ESP-IDF components: */ +#if defined(CONFIG_ESP_TLS_USING_WOLFSSL) + /* The ESP-TLS */ + #ifndef FP_MAX_BITS + #if defined(CONFIG_IDF_TARGET_ESP32C2) || \ + defined(CONFIG_IDF_TARGET_ESP8684) || \ + defined(CONFIG_IDF_TARGET_ESP8266) + /* Optionally set smaller size here */ + #define FP_MAX_BITS MIN_FFDHE_FP_MAX_BITS + #else + #define FP_MAX_BITS (4096 * 2) + #endif + #endif + #define HAVE_ALPN + #ifndef CONFIG_IDF_TARGET_ESP8266 + /* Unless installed in the ESP8266 RTOS SDK locally, the wolfSSL + * API for SNI will not be seen in the components/esp-tls layer. + * Only enable SNI for non-ESP8266 targets by default: */ + #define HAVE_SNI + #endif + #define OPENSSL_EXTRA_X509_SMALL + + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES +#endif + +/* Optionally enable some wolfSSH settings */ +#if defined(ESP_ENABLE_WOLFSSH) || defined(CONFIG_ESP_ENABLE_WOLFSSH) + /* Enable wolfSSH. Espressif examples need a few more settings, below */ + #undef WOLFSSL_WOLFSSH + #define WOLFSSL_WOLFSSH + + /* The default SSH Windows size is massive for an embedded target. + * Limit it: */ + #define DEFAULT_WINDOW_SZ 2000 + + /* These may be defined in cmake for other examples: */ + #undef WOLFSSH_TERM + #define WOLFSSH_TERM + + /* optional debug */ + /* #undef DEBUG_WOLFSSH */ + /* #define DEBUG_WOLFSSH */ + + #undef WOLFSSL_KEY_GEN + #define WOLFSSL_KEY_GEN + + #undef WOLFSSL_PTHREADS + #define WOLFSSL_PTHREADS + + #define WOLFSSH_TEST_SERVER + #define WOLFSSH_TEST_THREADING +#endif /* ESP_ENABLE_WOLFSSH */ + + +/* Not yet using WiFi lib, so don't compile in the esp-sdk-lib WiFi helpers: */ +/* #define USE_WOLFSSL_ESP_SDK_WIFI */ + /* * ONE of these Espressif chip families will be detected from sdkconfig: * * WOLFSSL_ESP32 + * WOLFSSL_ESPWROOM32SE * WOLFSSL_ESP8266 + * + * following ifdef detection only for syntax highlighting: */ -#undef WOLFSSL_ESPWROOM32SE -#undef WOLFSSL_ESP8266 -#undef WOLFSSL_ESP32 +#ifdef WOLFSSL_ESPWROOM32SE + #undef WOLFSSL_ESPWROOM32SE +#endif +#ifdef WOLFSSL_ESP8266 + #undef WOLFSSL_ESP8266 +#endif +#ifdef WOLFSSL_ESP32 + #undef WOLFSSL_ESP32 +#endif /* See below for chipset detection from sdkconfig.h */ /* when you want to use SINGLE THREAD. Note Default ESP-IDF is FreeRTOS */ -/* #define SINGLE_THREADED */ +#define SINGLE_THREADED -/* SMALL_SESSION_CACHE saves a lot of RAM for ClientCache and SessionCache. +/* Small session cache saves a lot of RAM for ClientCache and SessionCache. * Memory requirement is about 5KB, otherwise 20K is needed when not specified. * If extra small footprint is needed, try MICRO_SESSION_CACHE (< 1K) * When really desperate or no TLS used, try NO_SESSION_CACHE. */ @@ -92,130 +361,6 @@ /* RSA_LOW_MEM: Half as much memory but twice as slow. */ #define RSA_LOW_MEM -/* Uncommon settings for testing only */ -#define TEST_ESPIDF_ALL_WOLFSSL -#ifdef TEST_ESPIDF_ALL_WOLFSSL - #define WOLFSSL_MD2 - #define HAVE_BLAKE2 - #define HAVE_BLAKE2B - #define HAVE_BLAKE2S - - #define WC_RC2 - #define WOLFSSL_ALLOW_RC4 - - #define HAVE_POLY1305 - - #define WOLFSSL_AES_128 - #define WOLFSSL_AES_OFB - #define WOLFSSL_AES_CFB - #define WOLFSSL_AES_XTS - - /* #define WC_SRTP_KDF */ - /* TODO Causes failure with Espressif AES HW Enabled */ - /* #define HAVE_AES_ECB */ - /* #define HAVE_AESCCM */ - /* TODO sanity check when missing HAVE_AES_ECB */ - #define WOLFSSL_WOLFSSH - - #define HAVE_AESGCM - #define WOLFSSL_AES_COUNTER - - #define HAVE_FFDHE - #define HAVE_FFDHE_2048 - #if defined(CONFIG_IDF_TARGET_ESP8266) - /* TODO Full size SRP is disabled on the ESP8266 at this time. - * Low memory issue? */ - #define WOLFCRYPT_HAVE_SRP - /* MIN_FFDHE_FP_MAX_BITS = (MIN_FFDHE_BITS * 2); see settings.h */ - #define FP_MAX_BITS MIN_FFDHE_FP_MAX_BITS - #elif defined(CONFIG_IDF_TARGET_ESP32) || \ - defined(CONFIG_IDF_TARGET_ESP32S2) || \ - defined(CONFIG_IDF_TARGET_ESP32S3) - /* TODO: SRP Not enabled, known to fail on this target - * See https://github.com/wolfSSL/wolfssl/issues/7210 */ - #elif defined(CONFIG_IDF_TARGET_ESP32C3) || \ - defined(CONFIG_IDF_TARGET_ESP32H2) - /* SRP Known to be working on this target::*/ - #define WOLFCRYPT_HAVE_SRP - #define FP_MAX_BITS (8192 * 2) - #else - /* For everything else, give a try and see if SRP working: */ - #define WOLFCRYPT_HAVE_SRP - #define FP_MAX_BITS (8192 * 2) - #endif - - #define HAVE_DH - - /* TODO: there may be a problem with HAVE_CAMELLIA with HW AES disabled. - * Do not define NO_WOLFSSL_ESP32_CRYPT_AES when enabled: */ - /* #define HAVE_CAMELLIA */ - - /* DSA requires old SHA */ - #define HAVE_DSA - - /* Needs SHA512 ? */ - #define HAVE_HPKE - - /* Not for Espressif? */ - #if defined(CONFIG_IDF_TARGET_ESP32C2) || \ - defined(CONFIG_IDF_TARGET_ESP8684) || \ - defined(CONFIG_IDF_TARGET_ESP32H2) || \ - defined(CONFIG_IDF_TARGET_ESP8266) - - #if defined(CONFIG_IDF_TARGET_ESP8266) - #undef HAVE_ECC - #undef HAVE_ECC_CDH - #undef HAVE_CURVE25519 - - /* TODO does CHACHA also need alignment? Failing on ESP8266 - * See SHA256 __attribute__((aligned(4))); and WC_SHA256_ALIGN */ - #ifdef HAVE_CHACHA - #error "HAVE_CHACHA not supported on ESP8266" - #endif - #ifdef HAVE_XCHACHA - #error "HAVE_XCHACHA not supported on ESP8266" - #endif - #else - #define HAVE_XCHACHA - #define HAVE_CHACHA - /* TODO Not enabled at this time, needs further testing: - * #define WC_SRTP_KDF - * #define HAVE_COMP_KEY - * #define WOLFSSL_HAVE_XMSS - */ - #endif - /* TODO AES-EAX not working on this platform */ - - /* Optionally disable DH - * #undef HAVE_DH - * #undef HAVE_FFDHE - */ - - /* ECC_SHAMIR out of memory on ESP32-C2 during ECC */ - #ifndef HAVE_ECC - #define ECC_SHAMIR - #endif - #else - #define WOLFSSL_AES_EAX - - #define ECC_SHAMIR - #endif - - /* Only for WOLFSSL_IMX6_CAAM / WOLFSSL_QNX_CAAM ? */ - /* #define WOLFSSL_CAAM */ - /* #define WOLFSSL_CAAM_BLOB */ - - #define WOLFSSL_AES_SIV - #define WOLFSSL_CMAC - - #define WOLFSSL_CERT_PIV - - /* HAVE_SCRYPT may turn on HAVE_PBKDF2 see settings.h */ - /* #define HAVE_SCRYPT */ - #define SCRYPT_TEST_ALL - #define HAVE_X963_KDF -#endif - /* optionally turn off SHA512/224 SHA512/256 */ /* #define WOLFSSL_NOSHA512_224 */ /* #define WOLFSSL_NOSHA512_256 */ @@ -230,14 +375,43 @@ #define BENCH_EMBEDDED /* TLS 1.3 */ -#define WOLFSSL_TLS13 -#define HAVE_TLS_EXTENSIONS -#define WC_RSA_PSS -#define HAVE_HKDF -#define HAVE_AEAD -#define HAVE_SUPPORTED_CURVES +#ifdef CONFIG_WOLFSSL_ALLOW_TLS13 + #define WOLFSSL_TLS13 + #define HAVE_TLS_EXTENSIONS + #define HAVE_HKDF -#define WOLFSSL_BENCHMARK_FIXED_UNITS_KB + /* May be required */ + #ifndef HAVE_AEAD + #endif + + /* Required for ECC */ + #define HAVE_SUPPORTED_CURVES + + /* Required for RSA */ + #define WC_RSA_PSS + + /* TLS 1.3 normally requires HAVE_FFDHE */ + #if defined(HAVE_FFDHE_2048) || \ + defined(HAVE_FFDHE_3072) || \ + defined(HAVE_FFDHE_4096) || \ + defined(HAVE_FFDHE_6144) || \ + defined(HAVE_FFDHE_8192) + #else + #define HAVE_FFDHE_2048 + /* #error "TLS 1.3 requires HAVE_FFDHE_[nnnn]" */ + #endif +#endif + +#if defined(CONFIG_IDF_TARGET_ESP32C2) || \ + defined(CONFIG_IDF_TARGET_ESP8684) + /* Optionally set smaller size here */ + #ifdef HAVE_FFDHE_4096 + /* this size may be problematic on the C2 */ + #endif + #define HAVE_FFDHE_2048 +#else + #define HAVE_FFDHE_4096 +#endif #define NO_FILESYSTEM @@ -254,32 +428,67 @@ /* when you want to use SHA384 */ #define WOLFSSL_SHA384 -/* when you want to use SHA512 */ -#define WOLFSSL_SHA512 - -/* when you want to use SHA3 */ -#define WOLFSSL_SHA3 - - /* ED25519 requires SHA512 */ -#define HAVE_ED25519 - /* Some features not enabled for ESP8266: */ #if defined(CONFIG_IDF_TARGET_ESP8266) || \ defined(CONFIG_IDF_TARGET_ESP32C2) + /* Some known low-memory devices have features not enabled by default. */ /* TODO determine low memory configuration for ECC. */ #else - #define HAVE_ECC - #define HAVE_CURVE25519 - #define CURVE25519_SMALL + /* when you want to use SHA512 */ + #define WOLFSSL_SHA512 + + /* when you want to use SHA3 */ + /* #define WOLFSSL_SHA3 */ + + /* ED25519 requires SHA512 */ + #define HAVE_ED25519 #endif -#define HAVE_ED25519 +#if defined(CONFIG_IDF_TARGET_ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C2) + #define MY_USE_ECC 0 + #define MY_USE_RSA 1 +#else + #define MY_USE_ECC 1 + #define MY_USE_RSA 0 +#endif -/* Optional OPENSSL compatibility */ -#define OPENSSL_EXTRA +/* We can use either or both ECC and RSA, but must use at least one. */ +#if MY_USE_ECC || MY_USE_RSA + #if MY_USE_ECC + /* ---- ECDSA / ECC ---- */ + #define HAVE_ECC + #define HAVE_CURVE25519 + #define HAVE_ED25519 + #define WOLFSSL_SHA512 + /* + #define HAVE_ECC384 + #define CURVE25519_SMALL + */ + #else + #define WOLFSSH_NO_ECC + /* WOLFSSH_NO_ECDSA is typically defined automatically, + * here for clarity: */ + #define WOLFSSH_NO_ECDSA + #endif + + #if MY_USE_RSA + /* ---- RSA ----- */ + /* #define RSA_LOW_MEM */ + + /* DH disabled by default, needed if ECDSA/ECC also turned off */ + #define HAVE_DH + #else + #define WOLFSSH_NO_RSA + #endif +#else + #error "Either RSA or ECC must be enabled" +#endif + +/* Optional OpenSSL compatibility */ +/* #define OPENSSL_EXTRA */ /* #Optional HAVE_PKCS7 */ -#define HAVE_PKCS7 +/* #define HAVE_PKCS7 */ #if defined(HAVE_PKCS7) /* HAVE_PKCS7 may enable HAVE_PBKDF2 see settings.h */ @@ -319,8 +528,11 @@ /* #define XTIME time */ -/* adjust wait-timeout count if you see timeout in RSA HW acceleration */ -#define ESP_RSA_TIMEOUT_CNT 0x349F00 +/* Adjust wait-timeout count if you see timeout in RSA HW acceleration. + * Set to very large number and enable WOLFSSL_HW_METRICS to determine max. */ +#ifndef ESP_RSA_TIMEOUT_CNT + #define ESP_RSA_TIMEOUT_CNT 0xFF0000 +#endif /* hash limit for test.c */ #define HASH_SIZE_LIMIT @@ -329,7 +541,7 @@ #define USE_FAST_MATH /***** Use SP_MATH *****/ -/* #undef USE_FAST_MATH */ +/* #undef USE_FAST_MATH */ /* #define SP_MATH */ /* #define WOLFSSL_SP_MATH_ALL */ /* #define WOLFSSL_SP_RISCV32 */ @@ -338,6 +550,14 @@ /* #undef USE_FAST_MATH */ /* #define USE_INTEGER_HEAP_MATH */ +/* Just syntax highlighting to check math libraries: */ +#if defined(SP_MATH) || \ + defined(USE_INTEGER_HEAP_MATH) || \ + defined(USE_INTEGER_HEAP_MATH) || \ + defined(USE_FAST_MATH) || \ + defined(WOLFSSL_SP_MATH_ALL) || \ + defined(WOLFSSL_SP_RISCV32) +#endif #define WOLFSSL_SMALL_STACK @@ -345,18 +565,32 @@ #define HAVE_VERSION_EXTENDED_INFO /* #define HAVE_WC_INTROSPECTION */ -#define HAVE_SESSION_TICKET +#ifndef NO_SESSION_CACHE + #define HAVE_SESSION_TICKET +#endif /* #define HAVE_HASHDRBG */ +#if 0 +/* Example for additional cert functions */ #define WOLFSSL_KEY_GEN -#define WOLFSSL_CERT_REQ -#define WOLFSSL_CERT_GEN -#define WOLFSSL_CERT_EXT -#define WOLFSSL_SYS_CA_CERTS + #define WOLFSSL_CERT_REQ + #define WOLFSSL_CERT_GEN + #define WOLFSSL_CERT_EXT + #define WOLFSSL_SYS_CA_CERTS -#define WOLFSSL_CERT_TEXT + #define WOLFSSL_CERT_TEXT + + /* command-line options + --enable-keygen + --enable-certgen + --enable-certreq + --enable-certext + --enable-asn-template + */ + +#endif #define WOLFSSL_ASN_TEMPLATE @@ -376,10 +610,62 @@ --enable-asn-template */ +/* optional SM4 Ciphers. See https://github.com/wolfSSL/wolfsm */ +/* +#define WOLFSSL_SM2 +#define WOLFSSL_SM3 +#define WOLFSSL_SM4 +*/ + +#if defined(WOLFSSL_SM2) || defined(WOLFSSL_SM3) || defined(WOLFSSL_SM4) + /* SM settings, possible cipher suites: + + TLS13-AES128-GCM-SHA256 + TLS13-CHACHA20-POLY1305-SHA256 + TLS13-SM4-GCM-SM3 + TLS13-SM4-CCM-SM3 + + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-CCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CBC-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-GCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3:" \ + "TLS13-SM4-CCM-SM3:" + */ + + #undef WOLFSSL_BASE16 + #define WOLFSSL_BASE16 /* required for WOLFSSL_SM2 */ + + #undef WOLFSSL_SM4_ECB + #define WOLFSSL_SM4_ECB + + #undef WOLFSSL_SM4_CBC + #define WOLFSSL_SM4_CBC + + #undef WOLFSSL_SM4_CTR + #define WOLFSSL_SM4_CTR + + #undef WOLFSSL_SM4_GCM + #define WOLFSSL_SM4_GCM + + #undef WOLFSSL_SM4_CCM + #define WOLFSSL_SM4_CCM + + #define HAVE_POLY1305 + #define HAVE_CHACHA + + #undef HAVE_AESGCM + #define HAVE_AESGCM +#else + /* default settings */ + #define USE_CERT_BUFFERS_2048 +#endif + /* Chipset detection from sdkconfig.h * Default is HW enabled unless turned off. * Uncomment lines to force SW instead of HW acceleration */ -#if defined(CONFIG_IDF_TARGET_ESP32) +#if defined(CONFIG_IDF_TARGET_ESP32) || defined(WOLFSSL_ESPWROOM32SE) #define WOLFSSL_ESP32 /* Alternatively, if there's an ECC Secure Element present: */ /* #define WOLFSSL_ESPWROOM32SE */ @@ -501,12 +787,16 @@ #define WOLFSSL_ESP8266 /* There's no hardware encryption on the ESP8266 */ - /* Consider using the ESP32-C2/C3/C6 - * See https://www.espressif.com/en/products/socs/esp32-c2 */ + /* Consider using the ESP32-C2/C3/C6 */ #define NO_ESP32_CRYPT #define NO_WOLFSSL_ESP32_CRYPT_HASH #define NO_WOLFSSL_ESP32_CRYPT_AES #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI + #ifndef FP_MAX_BITS + /* FP_MAX_BITS matters in wolfssl_test, not just TLS setting. */ + /* MIN_FFDHE_FP_MAX_BITS = (MIN_FFDHE_BITS * 2); see settings.h */ + #define FP_MAX_BITS MIN_FFDHE_FP_MAX_BITS + #endif /***** END CONFIG_IDF_TARGET_ESP266 *****/ #elif defined(CONFIG_IDF_TARGET_ESP8684) @@ -518,7 +808,7 @@ /***** END CONFIG_IDF_TARGET_ESP8684 *****/ #else - /* Anything else encountered, disable HW accleration */ + /* Anything else encountered, disable HW acceleration */ #warning "Unexpected CONFIG_IDF_TARGET_NN value" #define NO_ESP32_CRYPT #define NO_WOLFSSL_ESP32_CRYPT_HASH @@ -556,18 +846,33 @@ /* Debug options: See wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h for details on debug options +optionally increase error message size for very long paths. +#define WOLFSSL_MAX_ERROR_SZ 500 + +Turn wolfSSL debugging on/off: + wolfSSL_Debugging_ON(); + wolfSSL_Debugging_OFF(); + #define ESP_VERIFY_MEMBLOCK #define DEBUG_WOLFSSL #define DEBUG_WOLFSSL_VERBOSE #define DEBUG_WOLFSSL_SHA_MUTEX +#define WOLFSSL_DEBUG_IGNORE_ASN_TIME +#define WOLFSSL_DEBUG_CERT_BUNDLE +#define WOLFSSL_DEBUG_CERT_BUNDLE_NAME #define WOLFSSL_ESP32_CRYPT_DEBUG #define WOLFSSL_ESP32_CRYPT_HASH_SHA224_DEBUG #define NO_RECOVER_SOFTWARE_CALC #define WOLFSSL_TEST_STRAY 1 #define USE_ESP_DPORT_ACCESS_READ_BUFFER #define WOLFSSL_ESP32_HW_LOCK_DEBUG +#define WOLFSSL_DEBUG_MUTEX #define WOLFSSL_DEBUG_ESP_RSA_MULM_BITS +#define WOLFSSL_DEBUG_ESP_HW_MOD_RSAMAX_BITS +#define WOLFSSL_DEBUG_ESP_HW_MULTI_RSAMAX_BITS #define ESP_DISABLE_HW_TASK_LOCK +#define ESP_MONITOR_HW_TASK_LOCK +#define USE_ESP_DPORT_ACCESS_READ_BUFFER See wolfcrypt/benchmark/benchmark.c for debug and other settings: @@ -579,7 +884,8 @@ Turn on timer debugging (used when CPU cycles not available) */ /* Pause in a loop rather than exit. */ -#define WOLFSSL_ESPIDF_ERROR_PAUSE +/* #define WOLFSSL_ESPIDF_ERROR_PAUSE */ +/* #define WOLFSSL_ESP32_HW_LOCK_DEBUG */ #define WOLFSSL_HW_METRICS @@ -628,6 +934,12 @@ Turn on timer debugging (used when CPU cycles not available) * There are various certificate examples in this header file: * https://github.com/wolfSSL/wolfssl/blob/master/wolfssl/certs_test.h * + * To use the sample certificates in code (not recommended for production!): + * + * #if defined(USE_CERT_BUFFERS_2048) || defined(USE_CERT_BUFFERS_1024) + * #include + * #endif + * * To use the sets of macros below, define *one* of these: * * USE_CERT_BUFFERS_1024 - ECC 1024 bit encoded ASN1 @@ -705,6 +1017,7 @@ Turn on timer debugging (used when CPU cycles not available) #define WOLFSSL_BASE16 #else #if defined(USE_CERT_BUFFERS_2048) + #define USE_CERT_BUFFERS_256 /* Be sure to include in app when using example certs: */ /* #include */ #define CTX_CA_CERT ca_cert_der_2048 @@ -726,6 +1039,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) + #define USE_CERT_BUFFERS_256 /* Be sure to include in app when using example certs: */ /* #include */ #define CTX_CA_CERT ca_cert_der_1024 @@ -750,3 +1064,34 @@ Turn on timer debugging (used when CPU cycles not available) #error "Must define USE_CERT_BUFFERS_2048 or USE_CERT_BUFFERS_1024" #endif #endif /* Conditional key and cert constant names */ + +/****************************************************************************** +** Sanity Checks +******************************************************************************/ +#if defined(CONFIG_ESP_MAIN_TASK_STACK_SIZE) + #if defined(WOLFCRYPT_HAVE_SRP) + #if defined(FP_MAX_BITS) + #if FP_MAX_BITS < (8192 * 2) + #define ESP_SRP_MINIMUM_STACK_8K (24 * 1024) + #else + #define ESP_SRP_MINIMUM_STACK_8K (28 * 1024) + #endif + #else + #error "Please define FP_MAX_BITS when using WOLFCRYPT_HAVE_SRP." + #endif + + #if (CONFIG_ESP_MAIN_TASK_STACK_SIZE < ESP_SRP_MINIMUM_STACK) + #warning "WOLFCRYPT_HAVE_SRP enabled with small stack size" + #endif + #endif +#else + #warning "CONFIG_ESP_MAIN_TASK_STACK_SIZE not defined!" +#endif +/* See settings.h for some of the possible hardening options: + * + * #define NO_ESPIDF_DEFAULT + * #define WC_NO_CACHE_RESISTANT + * #define WC_AES_BITSLICED + * #define HAVE_AES_ECB + * #define HAVE_AES_DIRECT + */ diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/CMakeLists.txt index e37c4d5f6..5166065a3 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/CMakeLists.txt @@ -1,11 +1,44 @@ +# wolfSSL Espressif Example Project/main CMakeLists.txt +# v1.2 # # wolfssl benchmark test # +message(STATUS "Begin wolfSSL main CMakeLists.txt") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") -set(COMPONENT_SRCS "main.c") -set(COMPONENT_ADD_INCLUDEDIRS ".") +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + # `driver` component not available for ESP8266 + SET(THIS_PRIV_REQUIRES_DRIVER "") +else() + SET(THIS_PRIV_REQUIRES_DRIVER "driver") +endif() +if(WIN32) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") + message(STATUS "Detected Windows") +endif() +if(CMAKE_HOST_UNIX) + message(STATUS "Detected UNIX") +endif() +if(APPLE) + message(STATUS "Detected APPLE") +endif() +if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") + message(STATUS "Detected WSL") +endif() +if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") + message(STATUS "Detected Linux") +endif() +if(APPLE) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") + message(STATUS "Detected Apple") +endif() set (git_cmd "git") if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl/" AND EXISTS "$ENV{IDF_PATH}/components/wolfssl/" ) @@ -18,9 +51,22 @@ if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl/" AND EXISTS "$ENV{IDF_PA set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING") endif() +# The wolfSL component name is named "mywolfssl" on the staging site for Managed Components. +if( NOT EXISTS "../components/wolfssl" AND ("$ENV{IDF_COMPONENT_REGISTRY_URL}" STREQUAL "https://components-staging.espressif.com") ) + message(STATUS "WARNING: Using a staging instance of wolfssl.") + set(MAIN_WOLFSSL_COMPONENT_NAME "mywolfssl") +else() + message(STATUS "Using release wolfssl component.") + set(MAIN_WOLFSSL_COMPONENT_NAME "wolfssl") +endif() + +## register_component() idf_component_register(SRCS main.c - INCLUDE_DIRS "." - "./include") + INCLUDE_DIRS "." + "./include" + PRIV_REQUIRES "${THIS_PRIV_REQUIRES_DRIVER}" + "${MAIN_WOLFSSL_COMPONENT_NAME}" + ) # # LIBWOLFSSL_SAVE_INFO(VAR_OUPUT THIS_VAR VAR_RESULT) @@ -50,15 +96,24 @@ function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) message(STATUS "Found ${VAR_OUPUT}=${VAR_VALUE}") # the interesting part is defining the VAR_OUPUT name a value to use in the app - add_definitions(-D${VAR_OUPUT}=\"${VAR_VALUE}\") + add_compile_definitions(${VAR_OUPUT}=\"${VAR_VALUE}\") else() # if we get here, check the execute_process command and parameters. - message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT") + message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT.") + message(STATUS "Setting ${VAR_OUPUT} to \"Unknown\"") set(${VAR_OUPUT} "Unknown") endif() endfunction() # LIBWOLFSSL_SAVE_INFO -if(NOT CMAKE_BUILD_EARLY_EXPANSION) +execute_process( + COMMAND ${git_cmd} "rev-parse" "--is-inside-work-tree" + OUTPUT_VARIABLE IS_GIT_REPO + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + +# Save some project-specific details. Repo may be different than component, or may not even be a repo at all: +if(NOT CMAKE_BUILD_EARLY_EXPANSION AND (IS_GIT_REPO STREQUAL "true")) # LIBWOLFSSL_VERSION_GIT_HASH execute_process(COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") @@ -74,3 +129,4 @@ endif() message(STATUS "") +message(STATUS "End wolfSSL main CMakeLists.txt") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/Kconfig.projbuild b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/Kconfig.projbuild index 8fd12d389..83ff73ada 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/Kconfig.projbuild +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/Kconfig.projbuild @@ -1,5 +1,102 @@ +# Kconfig main +# +# Copyright (C) 2006-2025 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 +# + +# Kconfig File Version 5.7.2.001 for wolfssl_template + menu "Example Configuration" +choice WOLFSSL_EXAMPLE_CHOOSE + prompt "Choose Example (See wolfssl/include/user_settings.h)" + default WOLFSSL_EXAMPLE_NAME_NONE + help + The user settings file can be adjusted to specific wolfSSL examples. + + config WOLFSSL_EXAMPLE_NAME_TEMPLATE + bool "wolfSSL Template" + help + The sample template app compiles in wolfSSL and prints the current wolfSSL Version. Nothing more. + + config WOLFSSL_EXAMPLE_NAME_TEST + bool "wolfSSL Test" + help + This app tests all cryptographic functions currently enabled. See also Benchmark performance app. + + config WOLFSSL_EXAMPLE_NAME_BENCHMARK + bool "wolfSSL Benchmark" + help + Benchmark performance app. See also cryptographic test. + + config WOLFSSL_EXAMPLE_NAME_TLS_CLIENT + bool "TLS Client" + help + TLS Client Example app. Needs WiFi and a listening server on port 11111. + + config WOLFSSL_EXAMPLE_NAME_TLS_SERVER + bool "TLS Server" + help + TLS Server Example app. Needs WiFi. More interesting with a TLS client using port 11111. + + config WOLFSSL_EXAMPLE_NAME_WOLFSSH_TEMPLATE + bool "SSH Template App" + help + Bare-bones Hello World app that only compiles in wolfSSL and wolfSSH. + See wolfSSL/wolfssh on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFSSH_ECHOSERVER + bool "SSH Echo Server" + help + See wolfSSL/wolfssh on GitHub. + + config WOLFSSL_EXAMPLE_NAME_ESP32_SSH_SERVER + bool "SSH to UART Server for the ESP32" + help + See wolfSSL/wolfssh-examples on GitHub. + + config WOLFSSL_EXAMPLE_NAME_ESP8266_SSH_SERVER + bool "SSH to UART Server for the ESP8266" + help + See wolfSSL/wolfssh-examples on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFMQTT_TEMPLATE + bool "MQTT Template" + help + See wolfSSL/wolfmqtt on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFMQTT_AWS_IOT_MQTT + bool "MQTT AWS IoT" + help + See wolfSSL/wolfmqtt on GitHub. + + config WOLFTPM_EXAMPLE_NAME_ESPRESSIF + bool "TPM Test Example for the ESP32" + help + See wolfSSL/wolfTPM on GitHub. + + config WOLFSSL_EXAMPLE_NAME_NONE + bool "Other" + help + A specific example app is not defined. + +endchoice + config BENCH_ARGV string "Arguments for benchmark test" default "-lng 0" @@ -22,7 +119,7 @@ config BENCH_ARGV -lng Display benchmark result by specified language. 0: English, 1: Japanese Size of block in bytes - + e.g -lng 1 e.g sha diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/component.mk index d9b752f16..08f8fbe9b 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/component.mk @@ -7,3 +7,17 @@ # please read the ESP-IDF documents if you need to do this. # # (Uses default behavior of compiling all source files in directory, adding 'include' to include path.) + +# We'll add the explicit lines only for old SDK requirements (e.h. ESP8266) + +ifeq ("$(VISUALGDB_DIR)","") + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL) ) +else + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL) ) + COMPONENT_SRCDIRS := . + COMPONENT_ADD_INCLUDEDIRS := . + COMPONENT_ADD_INCLUDEDIRS += include + + # Ensure main.c gets compiled + COMPONENT_OBJS := main.o +endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/include/main.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/include/main.h index cae03b4a9..a7828c33e 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/include/main.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/include/main.h @@ -1,6 +1,6 @@ -/* benchmark main.h +/* wolfssl_benchmark main.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -19,12 +19,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ -#ifndef _MAIN_ -#define _MAIN_ +#ifndef _MAIN_H_ +#define _MAIN_H_ void app_main(void); -/* see wolfssl/wolfcrypt/benchmark/benchmark.h */ -extern void wolf_benchmark_task(); - #endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/main.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/main.c index 3381f25fe..9af128c07 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/main.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/main.c @@ -1,6 +1,6 @@ /* benchmark main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -27,20 +27,27 @@ /* The wolfSSL user_settings.h file is automatically included by the settings.h * file and should never be explicitly included in any other source files. * The settings.h should also be listed above wolfssl library include files. */ -#include -#include -#include -#include -#ifndef WOLFSSL_ESPIDF - #error "Problem with wolfSSL user_settings. " \ - "Check components/wolfssl/include " \ - "and confirm WOLFSSL_USER_SETTINGS is defined, " \ - "typically in the component CMakeLists.txt" +#if defined(WOLFSSL_USER_SETTINGS) + #include + #if defined(WOLFSSL_ESPIDF) + #include + #include + #include + #include + #include + #else + #error "Problem with wolfSSL user_settings. " \ + "Check components/wolfssl/include " \ + "and confirm WOLFSSL_USER_SETTINGS is defined, " \ + "typically in the component CMakeLists.txt" + #endif +#else + /* Define WOLFSSL_USER_SETTINGS project wide for settings.h to include */ + /* wolfSSL user settings in ./components/wolfssl/include/user_settings.h */ + #error "Missing WOLFSSL_USER_SETTINGS in CMakeLists or Makefile:\ + CFLAGS +=-DWOLFSSL_USER_SETTINGS" #endif -#include -#include - /* Hardware; include after other libraries, * particularly after freeRTOS from settings.h */ #include @@ -152,6 +159,7 @@ char* __argv[WOLFSSL_BENCH_ARGV_MAX_ARGUMENTS]; int construct_argv() { + #define ARG_BUFF_SIZE 16 int cnt = 0; int i = 0; int len = 0; @@ -212,15 +220,16 @@ int construct_argv() /* entry point */ void app_main(void) { - int stack_start = 0; - uart_config_t uart_config = { .baud_rate = THIS_MONITOR_UART_BAUD_DATE, .data_bits = UART_DATA_8_BITS, .parity = UART_PARITY_DISABLE, .stop_bits = UART_STOP_BITS_1, }; + int stack_start = 0; + word32 loops = 0; esp_err_t ret = 0; + stack_start = esp_sdk_stack_pointer(); /* uart_set_pin(UART_NUM_0, TX_PIN, RX_PIN, @@ -270,7 +279,7 @@ void app_main(void) ESP_LOGI(TAG, "NO_CRYPT_BENCHMARK defined, skipping wolf_benchmark_task") #else - /* although wolfCrypt_Init() may be explicitly called above, + /* Although wolfCrypt_Init() may be explicitly called above, ** note it is still always called in wolf_benchmark_task. */ stack_start = uxTaskGetStackHighWaterMark(NULL); @@ -278,36 +287,41 @@ void app_main(void) do { ESP_LOGI(TAG, "Stack HWM: %d\n", uxTaskGetStackHighWaterMark(NULL)); - wolf_benchmark_task(); /* TODO capture return value! */ +#ifdef WOLFSSL_BENCH_ARGV + ret = benchmark_test(__argv); +#else + ret = benchmark_test(NULL); +#endif ESP_LOGI(TAG, "Stack used: %d\n", stack_start - uxTaskGetStackHighWaterMark(NULL)); - #if defined(WOLFSSL_HW_METRICS) && defined(WOLFSSL_HAS_METRICS) - esp_hw_show_metrics(); - #endif - } while (BENCHMARK_LOOP); - /* Reminder: wolfCrypt_Cleanup should always be called at completion, + esp_hw_show_metrics(); + + loops++; /* count of the number of tests run before fail. */ + ESP_LOGI(TAG, "Stack HWM: %d\n", uxTaskGetStackHighWaterMark(NULL)); + ESP_LOGI(TAG, "loops = %d", loops); + + } while (BENCHMARK_LOOP && (ret == 0)); + + /* Reminder: wolfCrypt_Cleanup() should always be called at completion, ** and is called in wolf_benchmark_task(). */ +#if defined BENCHMARK_LOOP && (BENCHMARK_LOOP == 1) + /* If BENCHMARK_LOOP enabled and we get here, there was likely an error. */ + ESP_LOGI(TAG, "Benchmark loops completed: %d", loops); +#endif + #if defined(SINGLE_THREADED) /* need stack monitor for single thread */ #else ESP_LOGI(TAG, "Stack HWM: %d\n", uxTaskGetStackHighWaterMark(NULL)); #endif - /* note wolfCrypt_Cleanup() should always be called when finished. - ** This is called at the end of wolf_test_task(); - */ - -#if defined(DEBUG_WOLFSSL) && defined(WOLFSSL_ESP32_CRYPT_RSA_PRI) - esp_hw_show_mp_metrics(); -#endif - #ifdef INCLUDE_uxTaskGetStackHighWaterMark - ESP_LOGI(TAG, "Stack HWM: %d", uxTaskGetStackHighWaterMark(NULL)); + ESP_LOGI(TAG, "Stack HWM: %d", uxTaskGetStackHighWaterMark(NULL)); - ESP_LOGI(TAG, "Stack used: %d", CONFIG_ESP_MAIN_TASK_STACK_SIZE - - (uxTaskGetStackHighWaterMark(NULL))); + ESP_LOGI(TAG, "Stack used: %d", CONFIG_ESP_MAIN_TASK_STACK_SIZE + - (uxTaskGetStackHighWaterMark(NULL))); #endif #ifdef WOLFSSL_ESPIDF_VERBOSE_EXIT_MESSAGE @@ -318,19 +332,19 @@ void app_main(void) ESP_LOGE(TAG, WOLFSSL_ESPIDF_VERBOSE_EXIT_MESSAGE("Failed!", ret)); } #elif defined(WOLFSSL_ESPIDF_EXIT_MESSAGE) - ESP_LOGI(TAG, WOLFSSL_ESPIDF_EXIT_MESSAGE); + ESP_LOGI(TAG, WOLFSSL_ESPIDF_EXIT_MESSAGE); #else ESP_LOGI(TAG, "\n\nDone!\n\n" "If running from idf.py monitor, press twice: Ctrl+]"); #endif - /* after the test, we'll just wait */ + /* After completion, we'll just wait */ while (1) { - /* do something other than nothing to help next program/debug session*/ -#ifndef SINGLE_THREADED - vTaskDelay(1000); +#if defined(SINGLE_THREADED) + while (1); +#else + vTaskDelay(60000); #endif - } - + } /* done while */ #endif /* NO_CRYPT_BENCHMARK */ -} /* main */ +} diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/partitions_singleapp_large.csv b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/partitions_singleapp_large.csv index a9c373bec..0b2fcd1a9 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/partitions_singleapp_large.csv +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/partitions_singleapp_large.csv @@ -1,31 +1,31 @@ -# to view: idf.py partition-table -# -# ESP-IDF Partition Table -# Name, Type, SubType, Offset, Size, Flags -nvs, data, nvs, 0x9000, 24K, -phy_init,data, phy, 0xf000, 4K, -factory, app, factory, 0x10000, 1500K, - - -# For other settings, see: -# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#creating-custom-tables -# -# Here is the summary printed for the "Single factory app, no OTA" configuration: -# -# # ESP-IDF Partition Table -# # Name, Type, SubType, Offset, Size, Flags -# nvs, data, nvs, 0x9000, 0x6000, -# phy_init, data, phy, 0xf000, 0x1000, -# factory, app, factory, 0x10000, 1M, -# -# -# Here is the summary printed for the "Factory app, two OTA definitions" configuration: -# -# # ESP-IDF Partition Table -# # Name, Type, SubType, Offset, Size, Flags -# nvs, data, nvs, 0x9000, 0x4000, -# otadata, data, ota, 0xd000, 0x2000, -# phy_init, data, phy, 0xf000, 0x1000, -# factory, app, factory, 0x10000, 1M, -# ota_0, app, ota_0, 0x110000, 1M, -# ota_1, app, ota_1, 0x210000, 1M, +# to view: idf.py partition-table +# +# ESP-IDF Partition Table +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 24K, +phy_init,data, phy, 0xf000, 4K, +factory, app, factory, 0x10000, 1500K, + + +# For other settings, see: +# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#creating-custom-tables +# +# Here is the summary printed for the "Single factory app, no OTA" configuration: +# +# # ESP-IDF Partition Table +# # Name, Type, SubType, Offset, Size, Flags +# nvs, data, nvs, 0x9000, 0x6000, +# phy_init, data, phy, 0xf000, 0x1000, +# factory, app, factory, 0x10000, 1M, +# +# +# Here is the summary printed for the "Factory app, two OTA definitions" configuration: +# +# # ESP-IDF Partition Table +# # Name, Type, SubType, Offset, Size, Flags +# nvs, data, nvs, 0x9000, 0x4000, +# otadata, data, ota, 0xd000, 0x2000, +# phy_init, data, phy, 0xf000, 0x1000, +# factory, app, factory, 0x10000, 1M, +# ota_0, app, ota_0, 0x110000, 1M, +# ota_1, app, ota_1, 0x210000, 1M, diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults index e7f303736..bc63cebf8 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults @@ -1,18 +1,34 @@ +# Set the known example app config to template example (see user_settings.h) +CONFIG_WOLFSSL_EXAMPLE_NAME_BENCHMARK=y + +# CONFIG_EXAMPLE_WIFI_SSID="myssid" +# CONFIG_EXAMPLE_WIFI_PASSWORD="mypassword" + +# Some wolfSSL helpers +CONFIG_USE_WOLFSSL_ESP_SDK_TIME=y + +# sdkconfig.defaults for ESP8266 + ESP32 +# See separate sdkconfig.defaults.esp8266 # Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. -# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults CONFIG_BENCH_ARGV="-lng 0" +# FreeRTOS ticks at 1ms interval +CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_HZ=1000 CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y # # Default main stack size. See user_settings.h # +# This is typically bigger than needed for stack size. +# Units are words, not bytes. See user_settings.h +# # For wolfSSL SMALL_STACK, 3072 bytes should be sufficient for benchmark app. # When using RSA, assign at least 10500 bytes, otherwise 5500 usually works for others -CONFIG_ESP_MAIN_TASK_STACK_SIZE=10500 +# We set this to 28672 for use in the "test everything possible" in the wolfssl_test app. +CONFIG_ESP_MAIN_TASK_STACK_SIZE=28672 -# Legacy stack size for older ESP-IDF versions -CONFIG_MAIN_TASK_STACK_SIZE=10500 +# Legacy stack size name for older ESP-IDF versions +CONFIG_MAIN_TASK_STACK_SIZE=28672 # # Benchmark must not have CONFIG_NEWLIB_NANO_FORMAT enabled @@ -30,6 +46,10 @@ CONFIG_ESP_TASK_WDT_EN=n CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y CONFIG_ESP_INT_WDT=n +# ESP8266 Watchdog: +CONFIG_TASK_WDT=n +CONFIG_TASK_WDT_PANIC=n + # ESP8266 WDT # CONFIG_ESP_PANIC_PRINT_REBOOT is not set CONFIG_ESP_PANIC_PRINT_REBOOT=n @@ -45,6 +65,36 @@ CONFIG_HEAP_DISABLE_IRAM=y # Performance # CONFIG_COMPILER_OPTIMIZATION_PERF=y +# Set max CPU frequency (falls back as needed for lower maximum) +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y + +# Enable wolfSSL TLS in esp-tls +# CONFIG_ESP_TLS_USING_WOLFSSL=y +# CONFIG_TLS_STACK_WOLFSSL=y + +# Bundles take up flash space and are disabled unless otherwise known to be needed +CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=n +# CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=y +# CONFIG_ESP_WOLFSSL_SMALL_CERT_VERIFY=y +# CONFIG_ESP_TLS_INSECURE=y + +# Disable mbedTLS +CONFIG_ESP_TLS_USING_MBEDTLS=n +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n + +# Some wolfSSL helpers +CONFIG_USE_WOLFSSL_ESP_SDK_TIME=n + +# CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set +CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=n + +# ESP8266 Memory +CONFIG_FREERTOS_GLOBAL_DATA_LINK_IRAM=y +CONFIG_HEAP_DISABLE_IRAM=y + +# Performance +# CONFIG_COMPILER_OPTIMIZATION_PERF=y + # Set max COU frequency (falls back as needed for lower maximum) CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y @@ -52,6 +102,26 @@ CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_HZ=1000 +# Ensure mbedTLS options are disabled +# CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=n +# CONFIG_MBEDTLS_TLS_CLIENT_ONLY=n +# CONFIG_MBEDTLS_TLS_SERVER=n +# CONFIG_MBEDTLS_TLS_CLIENT=n +# CONFIG_MBEDTLS_HARDWARE_AES=n +# CONFIG_MBEDTLS_HARDWARE_MPI=n +# CONFIG_MBEDTLS_HARDWARE_SHA=n +# CONFIG_MBEDTLS_ROM_MD5=n +# CONFIG_MBEDTLS_SSL_RENEGOTIATION=n +# CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=n +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1=n +# CONFIG_MBEDTLS_SSL_ALPN=n +# CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=n +# CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=n + +# The same-name config is used for both WiFi and client/server TLS, so we cannot disable: +# CONFIG_MBEDTLS_TLS_ENABLED=n +# CONFIG_MBEDTLS_TLS_DISABLED=y + # # Compiler options # diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults.esp8266 b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults.esp8266 new file mode 100644 index 000000000..77299dfe4 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults.esp8266 @@ -0,0 +1,30 @@ +# ESP8266 WDT +# CONFIG_ESP_PANIC_PRINT_REBOOT is not set +CONFIG_ESP_PANIC_PRINT_REBOOT=n +CONFIG_ESP_PANIC_PRINT_HALT=y + +# Enable wolfSSL TLS in esp-tls (not yet supported in RTOS SDK 3.4 +CONFIG_ESP_TLS_USING_WOLFSSL=n +CONFIG_TLS_STACK_WOLFSSL=n + +# Bundles take up flash space and are disabled unless otherwise known to be needed +CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=n +# CONFIG_ESP_WOLFSSL_SMALL_CERT_VERIFY=y +# CONFIG_ESP_TLS_INSECURE=y + +# Disable mbedTLS +CONFIG_ESP_TLS_USING_MBEDTLS=y +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n + +# ESP8266 Memory +CONFIG_FREERTOS_GLOBAL_DATA_LINK_IRAM=y +CONFIG_HEAP_DISABLE_IRAM=y + +# ESP8266 Watchdog: +CONFIG_TASK_WDT=n +CONFIG_TASK_WDT_PANIC=n + +# ESP8266 WDT +# CONFIG_ESP_PANIC_PRINT_REBOOT is not set +CONFIG_ESP_PANIC_PRINT_REBOOT=n +CONFIG_ESP_PANIC_PRINT_HALT=y diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/CMakeLists.txt index 14d08bf9f..f9b3bbfd0 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/CMakeLists.txt @@ -1,10 +1,19 @@ # wolfSSL Espressif Example Project CMakeLists.txt -# v1.0 +# v1.3 # # The following lines of boilerplate have to be in your project's # CMakeLists in this exact order for cmake to work correctly +message(STATUS "Begin project ${CMAKE_PROJECT_NAME}") + cmake_minimum_required(VERSION 3.16) +# Optional no watchdog typically used for test & benchmark +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESP_NO_WATCHDOG=1") +else() + add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +endif() + # The wolfSSL CMake file should be able to find the source code. # Otherwise, assign an environment variable or set it here: # @@ -22,45 +31,63 @@ cmake_minimum_required(VERSION 3.16) if(WIN32) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") - message("Detected Windows") + message(STATUS "Detected Windows") endif() if(CMAKE_HOST_UNIX) - message("Detected UNIX") + message(STATUS "Detected UNIX") endif() if(APPLE) - message("Detected APPLE") + message(STATUS "Detected APPLE") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") - message("Detected WSL") + message(STATUS "Detected WSL") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") - message("Detected Linux") + message(STATUS "Detected Linux") endif() if(APPLE) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") - message("Detected Apple") + message(STATUS "Detected Apple") endif() # End optional WOLFSSL_CMAKE_SYSTEM_NAME # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) +# set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) +string(REPLACE "\\" "/" PROTOCOL_EXAMPLES_DIR "$ENV{IDF_PATH}/examples/common_components/protocol_examples_common") if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") - message("Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + message(STATUS "Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") else() - message("NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") endif() +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER +message(STATUS "USERNAME = $ENV{USERNAME}") +if( "$ENV{USER}" STREQUAL "" ) # the bash user + if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user + message(STATUS "could not find USER or USERNAME") + else() + # the bash user is not blank, so we'll use it. + set(THIS_USER "$ENV{USERNAME}") + endif() +else() + # the bash user is not blank, so we'll use it. + set(THIS_USER "$ENV{USER}") +endif() +message(STATUS "THIS_USER = ${THIS_USER}") + # Check that there are not conflicting wolfSSL components # The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl # The local component wolfSSL directory will be in ./components/wolfssl +message(STATUS "Checking for wolfSSL as Managed Component or not... ${CMAKE_HOME_DIRECTORY}") if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" ) # These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake' # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL) @@ -75,22 +102,47 @@ if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXI message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n" "If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove " "or rename the idf_component.yml file typically found in ./main/") -else() +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl") + # A standard project component (not a Managed Component) message(STATUS "No conflicting wolfSSL components found.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/components/wolfssl") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl") + # The official Managed Component called wolfssl from the wolfssl user. + message(STATUS "No conflicting wolfSSL components found as a Managed Component.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/gojimmypi__mywolfssl") + # There is a known gojimmypi staging component available for anyone: + message(STATUS "No conflicting wolfSSL components found as a gojimmypi staging Managed Component.") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/${THIS_USER}__mywolfssl") + # Other users with permissions might publish their own mywolfssl staging Managed Component + message(STATUS "No conflicting wolfSSL components found as a Managed Component.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/managed_components/${THIS_USER}__mywolfssl") +else() + message(STATUS "WARNING: wolfssl component directory not found.") endif() +# message(STATUS "EXTRA_COMPONENT_DIRS WOLFSSL_PATH: ${WOLFSSL_PATH}") +# list(APPEND EXTRA_COMPONENT_DIRS ${WOLFSSL_PATH}) -# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) +# Not only is a project-level "set(COMPONENTS" not needed here, this will cause +# an unintuitive error about Unknown CMake command "esptool_py_flash_project_args". -if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") - message("Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") - set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") -else() - message("NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") +if(0) + message(STATUS "Begin optional PROTOCOL_EXAMPLES_DIR include") + # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. + set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + + if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") + message(STATUS "Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") + else() + message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + endif() + message(STATUS "End optional PROTOCOL_EXAMPLES_DIR include") endif() include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(wolfssl_client) +message(STATUS "end project") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/Makefile b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/Makefile index cedefce72..430abea3e 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/Makefile +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/Makefile @@ -1,6 +1,6 @@ # ESP8266 Project Makefile for wolfssl_client # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/README.md b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/README.md index 5c667ca24..ff275c711 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/README.md +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/README.md @@ -10,9 +10,7 @@ For general information on [wolfSSL examples for Espressif](../README.md), see t ## Quick Start -Use the [ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html) -for ESP32 or [RTOS SDK](https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/index.html) -for the ESP8266. +Use the `ESP-IDF` for ESP32 or `RTOS SDK` for the ESP8266. Run `menuconfig` utility (`idf.py menuconfig` for ESP32 or `make menuconfig` for the ESP8266) and set the various parameters for the target device, along with local WiFi settings: @@ -49,30 +47,30 @@ Difficulty flashing: * Check that quality USB cables are being used. * Try lowering the flash baud rate in the `menuconfig`. The 115200 is typically reliable. * Review board specifications: some require manual boot mode via on-board buttons. -* See [Espressif ESP Frequently Asked Questions](https://docs.espressif.com/projects/esp-faq/en/latest/esp-faq-en-master.pdf) +* See Espressif ESP Frequently Asked Questions `esp-faq-en-master.pdf`. ## ESP-IDF Commandline v5.x 1. `idf.py menuconfig` to config the project - 1-1. Example Configuration -> + 1-1. Example Configuration -> Target host ip address : the host that you want to connect to.(default is 127.0.0.1) 1-2. Example Connection Configuration -> - - WIFI SSID: your own WIFI, which is connected to the Internet.(default is "myssid") + + WIFI SSID: your own WIFI, which is connected to the Internet.(default is "myssid") WIFI Password: WIFI password, and default is "mypassword" - - - Note: the example program uses 11111 port. If you want to use different port + + + Note: the example program uses 11111 port. If you want to use different port , you need to modify DEFAULT_PORT definition in the code. When you want to test the wolfSSL client -1. `idf.py -p flash` and then `idf.py monitor` to load the firmware and see the context -2. You can use /examples/server/server program for test. +1. `idf.py -p flash` and then `idf.py monitor` to load the firmware and see the context +2. You can use /examples/server/server program for test. e.g. Launch ./examples/server/server -v 4 -b -i -d @@ -127,8 +125,8 @@ export IDF_PATH=~/esp/ESP8266_RTOS_SDK export PATH="$PATH:$HOME/esp/xtensa-lx106-elf/bin" # copy and navigate to project directory -mkdir -p /mnt/c/test/demo -cp -r /mnt/c/workspace/wolfssl-master/IDE/Espressif/ESP-IDF/examples/wolfssl_client/* /mnt/c/test/demo +mkdir -p /mnt/c/test/demo +cp -r /mnt/c/workspace/wolfssl-master/IDE/Espressif/ESP-IDF/examples/wolfssl_client/* /mnt/c/test/demo cd /mnt/c/test/demo # Clean diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/README_server_sm.md b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/README_server_sm.md index 01dd6baf8..87e1f0365 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/README_server_sm.md +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/README_server_sm.md @@ -49,7 +49,7 @@ make clean && make ### Others... ``` -# Success: Linux Client to ESP32 Server TLS1.2 +# Success: Linux Client to ESP32 Server TLS1.2 ./examples/client/client -h 192.168.1.113 -v 3 -l ECDHE-ECDSA-SM4-CBC-SM3 -c ./certs/sm2/client-sm2.pem -k ./certs/sm2/client-sm2-priv.pem -A ./certs/sm2/root-sm2.pem -C ./examples/client/client -h 192.168.1.113 -v 3 -l ECDHE-ECDSA-SM4-GCM-SM3 -c ./certs/sm2/client-sm2.pem -k ./certs/sm2/client-sm2-priv.pem -A ./certs/sm2/root-sm2.pem -C ./examples/client/client -h 192.168.1.113 -v 3 -l ECDHE-ECDSA-SM4-CCM-SM3 -c ./certs/sm2/client-sm2.pem -k ./certs/sm2/client-sm2-priv.pem -A ./certs/sm2/root-sm2.pem -C @@ -81,7 +81,7 @@ be the same as the Linux server files. | Usage | Certificate | Key | Certificate Authority file, default ./certs/client-cert.pem | | ----- | ---------------------------------- | ----------------------------------- | --------------------------------- | -| server | -c ./certs/sm2/server-sm2.pem | -k ./certs/sm2/server-sm2-priv.pem | -A ./certs/sm2/client-sm2.pem -V | +| server | -c ./certs/sm2/server-sm2.pem | -k ./certs/sm2/server-sm2-priv.pem | -A ./certs/sm2/client-sm2.pem -V | | client | -c ./certs/sm2/client-sm2.pem | -k ./certs/sm2/client-sm2-priv.pem | -A ./certs/sm2/root-sm2.pem -C | | emdedded: | server | wolfSSL_CTX_use_certificate_buffer
server_sm2 | wolfSSL_CTX_use_PrivateKey_buffer
server_sm2_priv | wolfSSL_CTX_load_verify_buffer
client-sm2 | @@ -156,7 +156,7 @@ I (622) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (628) heap_init: At 40094DC8 len 0000B238 (44 KiB): IRAM I (636) spi_flash: detected chip: generic I (639) spi_flash: flash io: dio -W (643) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the +W (643) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header. I (657) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. @@ -167,7 +167,7 @@ I (735) system_api: read default base MAC address from EFUSE I (755) wifi:wifi firmware version: 0d470ef I (755) wifi:wifi certification version: v7.0 I (755) wifi:config NVS flash: enabled -I (755) wifi:config nano formating: disabled +I (755) wifi:config nano formatting: disabled I (755) wifi:Init data frame dynamic rx buffer num: 32 I (765) wifi:Init management frame dynamic rx buffer num: 32 I (765) wifi:Init management short buffer num: 32 @@ -358,12 +358,12 @@ I (14715) internal.c: GrowOutputBuffer ok I (14715) wolfssl: wolfSSL Entering wolfSSL_get_options I (14725) wolfssl: Point Formats extension to write W (14735) wolfio: ssl->wflags = 0 -I (14735) wolfio: 16 03 03 00 52 02 00 00 4e 03 03 af 87 e2 58 57 -I (14735) wolfio: 73 c3 c1 35 1a 59 39 b2 03 9d 14 03 e0 b8 fb e8 -I (14745) wolfio: 9d 5b 9c 44 4f 57 4e 47 52 44 01 20 85 77 75 20 -I (14755) wolfio: 95 dd 00 e2 91 f8 42 33 f8 61 3f 1f de 81 15 58 -I (14755) wolfio: 23 0c e7 1e 71 e6 10 e5 67 23 e0 40 e0 11 00 00 -I (14765) wolfio: 06 00 0b 00 02 01 00 +I (14735) wolfio: 16 03 03 00 52 02 00 00 4e 03 03 af 87 e2 58 57 +I (14735) wolfio: 73 c3 c1 35 1a 59 39 b2 03 9d 14 03 e0 b8 fb e8 +I (14745) wolfio: 9d 5b 9c 44 4f 57 4e 47 52 44 01 20 85 77 75 20 +I (14755) wolfio: 95 dd 00 e2 91 f8 42 33 f8 61 3f 1f de 81 15 58 +I (14755) wolfio: 23 0c e7 1e 71 e6 10 e5 67 23 e0 40 e0 11 00 00 +I (14765) wolfio: 06 00 0b 00 02 01 00 W (14775) wolfio: sz = 87 I (14775) wolfssl: Shrinking output buffer I (14775) wolfssl: wolfSSL Leaving SendServerHello, return 0 @@ -372,53 +372,53 @@ I (14795) wolfssl: wolfSSL Entering SendCertificate I (14795) wolfssl: growing output buffer I (14805) internal.c: GrowOutputBuffer ok W (14815) wolfio: ssl->wflags = 0 -I (14815) wolfio: 16 03 03 02 e6 0b 00 02 e2 00 02 df 00 02 dc 30 -I (14815) wolfio: 82 02 d8 30 82 02 7e a0 03 02 01 02 02 01 01 30 -I (14825) wolfio: 0a 06 08 2a 81 1c cf 55 01 83 75 30 81 ac 31 0b -I (14835) wolfio: 30 09 06 03 55 04 06 13 02 55 53 31 10 30 0e 06 -I (14835) wolfio: 03 55 04 08 0c 07 4d 6f 6e 74 61 6e 61 31 10 30 -I (14845) wolfio: 0e 06 03 55 04 07 0c 07 42 6f 7a 65 6d 61 6e 31 -I (14855) wolfio: 14 30 12 06 03 55 04 0a 0c 0b 77 6f 6c 66 53 53 -I (14855) wolfio: 4c 5f 73 6d 32 31 0f 30 0d 06 03 55 04 0b 0c 06 -I (14865) wolfio: 43 41 2d 73 6d 32 31 18 30 16 06 03 55 04 03 0c -I (14875) wolfio: 0f 77 77 77 2e 77 6f 6c 66 73 73 6c 2e 63 6f 6d -I (14875) wolfio: 31 1f 30 1d 06 09 2a 86 48 86 f7 0d 01 09 01 16 -I (14885) wolfio: 10 69 6e 66 6f 40 77 6f 6c 66 73 73 6c 2e 63 6f -I (14895) wolfio: 6d 31 17 30 15 06 0a 09 92 26 89 93 f2 2c 64 01 -I (14895) wolfio: 01 0c 07 77 6f 6c 66 53 53 4c 30 1e 17 0d 32 33 -I (14905) wolfio: 30 32 31 35 30 36 32 33 30 37 5a 17 0d 32 35 31 -I (14915) wolfio: 31 31 31 30 36 32 33 30 37 5a 30 81 b0 31 0b 30 -I (14915) wolfio: 09 06 03 55 04 06 13 02 55 53 31 10 30 0e 06 03 -I (14925) wolfio: 55 04 08 0c 07 4d 6f 6e 74 61 6e 61 31 10 30 0e -I (14935) wolfio: 06 03 55 04 07 0c 07 42 6f 7a 65 6d 61 6e 31 14 -I (14945) wolfio: 30 12 06 03 55 04 0a 0c 0b 77 6f 6c 66 53 53 4c -I (14945) wolfio: 5f 73 6d 32 31 13 30 11 06 03 55 04 0b 0c 0a 53 -I (14955) wolfio: 65 72 76 65 72 2d 73 6d 32 31 18 30 16 06 03 55 -I (14965) wolfio: 04 03 0c 0f 77 77 77 2e 77 6f 6c 66 73 73 6c 2e -I (14965) wolfio: 63 6f 6d 31 1f 30 1d 06 09 2a 86 48 86 f7 0d 01 -I (14975) wolfio: 09 01 16 10 69 6e 66 6f 40 77 6f 6c 66 73 73 6c -I (14985) wolfio: 2e 63 6f 6d 31 17 30 15 06 0a 09 92 26 89 93 f2 -I (14985) wolfio: 2c 64 01 01 0c 07 77 6f 6c 66 53 53 4c 30 5a 30 -I (14995) wolfio: 14 06 08 2a 81 1c cf 55 01 82 2d 06 08 2a 81 1c -I (15005) wolfio: cf 55 01 82 2d 03 42 00 04 94 70 2b 46 e4 5e 0f -I (15005) wolfio: 41 fb 8f 2d 34 0a 41 40 19 5e fb d4 1d 11 ac fa -I (15015) wolfio: f5 93 37 c6 fa 87 08 f7 16 1f 2c ce 30 40 9d 4f -I (15025) wolfio: a6 2a 0a a1 d6 95 33 c3 a6 03 98 e6 8d 05 34 b0 -I (15025) wolfio: 97 0c de a4 c7 cf 53 8f d1 a3 81 89 30 81 86 30 -I (15035) wolfio: 1d 06 03 55 1d 0e 04 16 04 14 67 ae 60 ff 7e 1b -I (15045) wolfio: 0f 95 ae 1f 82 59 f2 6c 56 2d 93 ef 17 32 30 1f -I (15045) wolfio: 06 03 55 1d 23 04 18 30 16 80 14 47 0a 48 7e bb -I (15055) wolfio: 02 a8 5a 26 57 2b 19 a9 7b 61 8b 7f 5d 99 6e 30 -I (15065) wolfio: 0c 06 03 55 1d 13 01 01 ff 04 02 30 00 30 0e 06 -I (15075) wolfio: 03 55 1d 0f 01 01 ff 04 04 03 02 03 a8 30 13 06 -I (15075) wolfio: 03 55 1d 25 04 0c 30 0a 06 08 2b 06 01 05 05 07 -I (15085) wolfio: 03 01 30 11 06 09 60 86 48 01 86 f8 42 01 01 04 -I (15095) wolfio: 04 03 02 06 40 30 0a 06 08 2a 81 1c cf 55 01 83 -I (15095) wolfio: 75 03 48 00 30 45 02 20 1b ca 94 28 7f f6 b2 0d -I (15105) wolfio: 31 43 50 e1 d5 34 17 dd af 3a de 81 06 67 9a b3 -I (15115) wolfio: 06 22 7e 64 ec fd 0e b9 02 21 00 a1 48 a8 32 d1 -I (15115) wolfio: 05 09 6b 1c eb 89 12 66 d8 38 a1 c4 5c 89 09 0f -I (15125) wolfio: fd e9 c0 3b 1d fb cd b5 4c 31 68 +I (14815) wolfio: 16 03 03 02 e6 0b 00 02 e2 00 02 df 00 02 dc 30 +I (14815) wolfio: 82 02 d8 30 82 02 7e a0 03 02 01 02 02 01 01 30 +I (14825) wolfio: 0a 06 08 2a 81 1c cf 55 01 83 75 30 81 ac 31 0b +I (14835) wolfio: 30 09 06 03 55 04 06 13 02 55 53 31 10 30 0e 06 +I (14835) wolfio: 03 55 04 08 0c 07 4d 6f 6e 74 61 6e 61 31 10 30 +I (14845) wolfio: 0e 06 03 55 04 07 0c 07 42 6f 7a 65 6d 61 6e 31 +I (14855) wolfio: 14 30 12 06 03 55 04 0a 0c 0b 77 6f 6c 66 53 53 +I (14855) wolfio: 4c 5f 73 6d 32 31 0f 30 0d 06 03 55 04 0b 0c 06 +I (14865) wolfio: 43 41 2d 73 6d 32 31 18 30 16 06 03 55 04 03 0c +I (14875) wolfio: 0f 77 77 77 2e 77 6f 6c 66 73 73 6c 2e 63 6f 6d +I (14875) wolfio: 31 1f 30 1d 06 09 2a 86 48 86 f7 0d 01 09 01 16 +I (14885) wolfio: 10 69 6e 66 6f 40 77 6f 6c 66 73 73 6c 2e 63 6f +I (14895) wolfio: 6d 31 17 30 15 06 0a 09 92 26 89 93 f2 2c 64 01 +I (14895) wolfio: 01 0c 07 77 6f 6c 66 53 53 4c 30 1e 17 0d 32 33 +I (14905) wolfio: 30 32 31 35 30 36 32 33 30 37 5a 17 0d 32 35 31 +I (14915) wolfio: 31 31 31 30 36 32 33 30 37 5a 30 81 b0 31 0b 30 +I (14915) wolfio: 09 06 03 55 04 06 13 02 55 53 31 10 30 0e 06 03 +I (14925) wolfio: 55 04 08 0c 07 4d 6f 6e 74 61 6e 61 31 10 30 0e +I (14935) wolfio: 06 03 55 04 07 0c 07 42 6f 7a 65 6d 61 6e 31 14 +I (14945) wolfio: 30 12 06 03 55 04 0a 0c 0b 77 6f 6c 66 53 53 4c +I (14945) wolfio: 5f 73 6d 32 31 13 30 11 06 03 55 04 0b 0c 0a 53 +I (14955) wolfio: 65 72 76 65 72 2d 73 6d 32 31 18 30 16 06 03 55 +I (14965) wolfio: 04 03 0c 0f 77 77 77 2e 77 6f 6c 66 73 73 6c 2e +I (14965) wolfio: 63 6f 6d 31 1f 30 1d 06 09 2a 86 48 86 f7 0d 01 +I (14975) wolfio: 09 01 16 10 69 6e 66 6f 40 77 6f 6c 66 73 73 6c +I (14985) wolfio: 2e 63 6f 6d 31 17 30 15 06 0a 09 92 26 89 93 f2 +I (14985) wolfio: 2c 64 01 01 0c 07 77 6f 6c 66 53 53 4c 30 5a 30 +I (14995) wolfio: 14 06 08 2a 81 1c cf 55 01 82 2d 06 08 2a 81 1c +I (15005) wolfio: cf 55 01 82 2d 03 42 00 04 94 70 2b 46 e4 5e 0f +I (15005) wolfio: 41 fb 8f 2d 34 0a 41 40 19 5e fb d4 1d 11 ac fa +I (15015) wolfio: f5 93 37 c6 fa 87 08 f7 16 1f 2c ce 30 40 9d 4f +I (15025) wolfio: a6 2a 0a a1 d6 95 33 c3 a6 03 98 e6 8d 05 34 b0 +I (15025) wolfio: 97 0c de a4 c7 cf 53 8f d1 a3 81 89 30 81 86 30 +I (15035) wolfio: 1d 06 03 55 1d 0e 04 16 04 14 67 ae 60 ff 7e 1b +I (15045) wolfio: 0f 95 ae 1f 82 59 f2 6c 56 2d 93 ef 17 32 30 1f +I (15045) wolfio: 06 03 55 1d 23 04 18 30 16 80 14 47 0a 48 7e bb +I (15055) wolfio: 02 a8 5a 26 57 2b 19 a9 7b 61 8b 7f 5d 99 6e 30 +I (15065) wolfio: 0c 06 03 55 1d 13 01 01 ff 04 02 30 00 30 0e 06 +I (15075) wolfio: 03 55 1d 0f 01 01 ff 04 04 03 02 03 a8 30 13 06 +I (15075) wolfio: 03 55 1d 25 04 0c 30 0a 06 08 2b 06 01 05 05 07 +I (15085) wolfio: 03 01 30 11 06 09 60 86 48 01 86 f8 42 01 01 04 +I (15095) wolfio: 04 03 02 06 40 30 0a 06 08 2a 81 1c cf 55 01 83 +I (15095) wolfio: 75 03 48 00 30 45 02 20 1b ca 94 28 7f f6 b2 0d +I (15105) wolfio: 31 43 50 e1 d5 34 17 dd af 3a de 81 06 67 9a b3 +I (15115) wolfio: 06 22 7e 64 ec fd 0e b9 02 21 00 a1 48 a8 32 d1 +I (15115) wolfio: 05 09 6b 1c eb 89 12 66 d8 38 a1 c4 5c 89 09 0f +I (15125) wolfio: fd e9 c0 3b 1d fb cd b5 4c 31 68 W (15135) wolfio: sz = 747 I (15135) wolfssl: Shrinking output buffer I (15135) wolfssl: wolfSSL Leaving SendCertificate, return 0 @@ -440,16 +440,16 @@ I (15915) wolfssl: wolfSSL Entering SendHandshakeMsg I (15925) wolfssl: growing output buffer I (15925) internal.c: GrowOutputBuffer ok W (15925) wolfio: ssl->wflags = 0 -I (15935) wolfio: 16 03 03 00 95 0c 00 00 91 03 00 29 41 04 fd f5 -I (15935) wolfio: 5e 74 15 30 1d f3 84 ae a5 69 96 a9 5b dd 27 b3 -I (15945) wolfio: 00 7d 40 3a 59 93 93 6f 4d 1f 62 dc 60 48 34 1f -I (15955) wolfio: a8 1d 34 b8 76 8f 8b 27 4a 1b 77 64 8e 2e d5 27 -I (15955) wolfio: 03 95 8b 9d a5 ed a4 a6 b9 40 1b ea aa 10 07 08 -I (15965) wolfio: 00 48 30 46 02 21 00 cb 89 61 e9 21 f9 c6 4d ad -I (15975) wolfio: aa e7 f1 3f 6f 27 46 f0 35 ec 45 4e 8a ae f3 ac -I (15985) wolfio: 7c c0 cf 68 11 44 e2 02 21 00 f6 40 5c bc 66 5a -I (15985) wolfio: 74 1e 92 5d 9a 03 75 e7 7f 16 c2 b3 c8 fe 8d 5c -I (15995) wolfio: 63 35 36 da 61 38 76 dc 4e d6 +I (15935) wolfio: 16 03 03 00 95 0c 00 00 91 03 00 29 41 04 fd f5 +I (15935) wolfio: 5e 74 15 30 1d f3 84 ae a5 69 96 a9 5b dd 27 b3 +I (15945) wolfio: 00 7d 40 3a 59 93 93 6f 4d 1f 62 dc 60 48 34 1f +I (15955) wolfio: a8 1d 34 b8 76 8f 8b 27 4a 1b 77 64 8e 2e d5 27 +I (15955) wolfio: 03 95 8b 9d a5 ed a4 a6 b9 40 1b ea aa 10 07 08 +I (15965) wolfio: 00 48 30 46 02 21 00 cb 89 61 e9 21 f9 c6 4d ad +I (15975) wolfio: aa e7 f1 3f 6f 27 46 f0 35 ec 45 4e 8a ae f3 ac +I (15985) wolfio: 7c c0 cf 68 11 44 e2 02 21 00 f6 40 5c bc 66 5a +I (15985) wolfio: 74 1e 92 5d 9a 03 75 e7 7f 16 c2 b3 c8 fe 8d 5c +I (15995) wolfio: 63 35 36 da 61 38 76 dc 4e d6 W (15995) wolfio: sz = 154 I (16005) wolfssl: Shrinking output buffer I (16005) wolfssl: wolfSSL Leaving SendServerKeyExchange, return 0 @@ -459,7 +459,7 @@ I (16025) wolfssl: wolfSSL Entering SendServerHelloDone I (16035) wolfssl: growing output buffer I (16035) internal.c: GrowOutputBuffer ok W (16045) wolfio: ssl->wflags = 0 -I (16045) wolfio: 16 03 03 00 04 0e 00 00 00 +I (16045) wolfio: 16 03 03 00 04 0e 00 00 00 W (16045) wolfio: sz = 9 I (16055) wolfssl: Embed Send error I (16055) wolfssl: Connection reset @@ -479,14 +479,14 @@ I (16125) wolfssl: User calling wolfSSL_read in error state, not allowed I (16135) wolfssl: wolfSSL Leaving wolfSSL_read_internal, return -308 E (16145) tls_server: ERROR: failed to read I (16145) wolfssl: Client sends: -I (16145) wolfssl: +I (16145) wolfssl: I (16155) wolfssl: wolfSSL Entering wolfSSL_write I (16155) wolfssl: handshake not complete, trying to finish I (16165) wolfssl: wolfSSL Entering wolfSSL_negotiate I (16165) wolfssl: wolfSSL Entering wolfSSL_accept I (16175) wolfssl: wolfSSL Entering ReinitSSL W (16185) wolfio: ssl->wflags = 0 -I (16185) wolfio: 16 03 03 00 04 0e 00 00 00 +I (16185) wolfio: 16 03 03 00 04 0e 00 00 00 W (16185) wolfio: sz = 9 I (16195) wolfssl: Embed Send error I (16195) wolfssl: General error 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 c3c09ca53..cc7ef0d47 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,5 +1,5 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # @@ -19,18 +19,148 @@ # # cmake for wolfssl Espressif projects # -# Version 5.6.0.011 for detect test/benchmark +# Version 5.7.2 Espressif ESP-IDF integration # # See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html # - +message(STATUS "Begin wolfssl ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") cmake_minimum_required(VERSION 3.16) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") -set(CMAKE_CURRENT_SOURCE_DIR ".") -set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component -set(WOLFSSL_ROOT "$ENV{WOLFSSL_ROOT}" ) -# find the user name to search for possible "wolfssl-username" +set(VERBOSE_COMPONENT_MESSAGES 1) + +# Optional requires include: +# set(THIS_ESP_TLS "esp-tls") +set(THIS_ESP_TLS "") + +# function: IS_ESP_IDF_COMPONENT +# output: RESULT = 1 (true) if this component is located in the ESP-IDF components +# otherwise 0 (false) +function( IS_ESP_IDF_COMPONENT RESULT ) + # NOTE: Component location is based on the location of the CMakeList.txt + # and *not* the location of the wolfSSL source code. (which may be anywhere) + + # Normalize the paths to remove any trailing slashes + get_filename_component(NORMALIZED_IDF_PATH "${IDF_PATH}" REALPATH) + get_filename_component(NORMALIZED_TEST_PATH "${COMPONENT_DIR}" REALPATH) + + # Check if the test path starts with the IDF_PATH + string(FIND "${NORMALIZED_TEST_PATH}" "${NORMALIZED_IDF_PATH}" pos) + + if(${pos} EQUAL 0) + message(STATUS "${COMPONENT_DIR} is within IDF_PATH.") + set(${RESULT} 1 PARENT_SCOPE) + else() + message(STATUS "${COMPONENT_DIR} is not within IDF_PATH.") + set(${RESULT} 0 PARENT_SCOPE) + endif() +endfunction() + +# Determine if this cmake file is located in the ESP-IDF component directory or not, +# and if so, if it is being ignored (allowing the use of a local project one, instead). +IS_ESP_IDF_COMPONENT( IS_WOLSSL_ESP_IDF_COMPONENT ) +if( IS_WOLSSL_ESP_IDF_COMPONENT ) + message(STATUS "This wolfSSL is a component in ESP-IDF.") + if ( CONFIG_IGNORE_ESP_IDF_WOLFSSL_COMPONENT ) + idf_component_register() + message(STATUS "Warning: wolfSSL component in ESP-IDF is being ignored.") + return() + endif() +endif() + + +if( "${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}" STREQUAL "" ) + # nothing to do +else() + # Only forward slashes, or double backslashes are supported. + # By the time we get here the sdkconfig file has a value for wolfSSL source code root. + string(REPLACE "\\" "/" CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}) + message(STATUS "Cleaned wolfssl path: ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") +endif() + +# The scope of this CMAKE_C_FLAGS is just this component: +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWOLFSSL_USER_SETTINGS") + +set(CMAKE_CURRENT_SOURCE_DIR ".") +# set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component + +# Optionally set your source to wolfSSL in your project CMakeLists.txt like this: +# set(WOLFSSL_ROOT "c:/test/my_wolfssl" ) + +if ( "${WOLFSSL_ROOT}" STREQUAL "") + set(WOLFSSL_ROOT "$ENV{WOLFSSL_ROOT}" ) +endif() + +if( "$ENV{IDF_PATH}" STREQUAL "" ) + message(FATAL_ERROR "IDF_PATH Environment variable not set!") +else() + string(REPLACE "\\" "/" THIS_IDF_PATH "$ENV{IDF_PATH}") +endif() + +# Optional compiler definitions to help with system name detection (typically printed by app diagnostics) +if(VERBOSE_COMPONENT_MESSAGES) + if(WIN32) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") + message(STATUS "Detected Windows") + endif() + if(CMAKE_HOST_UNIX) + message(STATUS "Detected UNIX") + endif() + if(APPLE) + message(STATUS "Detected APPLE") + endif() + if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") + message(STATUS "Detected WSL") + endif() + if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") + message(STATUS "Detected Linux") + endif() + if(APPLE) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") + message(STATUS "Detected Apple") + endif() +endif() # End optional WOLFSSL_CMAKE_SYSTEM_NAME + +message(STATUS "CONFIG_TARGET_PLATFORM = ${CONFIG_TARGET_PLATFORM}") + +# Check that there are not conflicting wolfSSL components +# The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl +# The local component wolfSSL directory will be in ./components/wolfssl +if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" ) + # These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake' + # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL) + # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl/include" EXCLUDE_FROM_ALL) + # So we'll error out and let the user decide how to proceed: + message(WARNING "\nFound wolfSSL components in\n" + "./managed_components/wolfssl__wolfssl\n" + "and\n" + "./components/wolfssl\n" + "in project directory: \n" + "${CMAKE_HOME_DIRECTORY}") + message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n" + "If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove " + "or rename the idf_component.yml file typically found in ./main/") +else() + message(STATUS "No conflicting wolfSSL components found.") +endif() + + +# Don't include lwip requirement for benchmark and test apps. +if( ("${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_benchmark") OR ("${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_test") ) + message(STATUS "Not including lwip for ${CMAKE_PROJECT_NAME}") +else() + # benchmark and test do not need wifi, everything else probably does: + set(COMPONENT_REQUIRES lwip "${THIS_ESP_TLS}") # we typically don't need lwip directly in wolfssl component +endif() + +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER message(STATUS "USERNAME = $ENV{USERNAME}") if( "$ENV{USER}" STREQUAL "" ) # the bash user if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user @@ -51,6 +181,25 @@ else() string(REPLACE "\\" "/" THIS_IDF_PATH "$ENV{IDF_PATH}") endif() +# ENVIRONMENT_VAR_TO_MACRO +# Check environment variable name EVARPARAM as [name] +# If defined, and has a value of EVARVALUE as [value], +# then assign a compiler definition "-D[name]=[value]" +function(ENVIRONMENT_VAR_TO_MACRO EVARPARAM EVARVALUE) + # If the EVARPARAM environment variable name is set to EVARVALUE, + # set the compiler flag definition to enable CSV output. + if ( "$ENV{${EVARPARAM}}" STREQUAL "${EVARVALUE}") + message(STATUS "Appending compile definition: -D${EVARPARAM}=${EVARVALUE}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${EVARPARAM}=${EVARVALUE}") + else() + if(DEFINED ENV{${EVARPARAM}}) + message(STATUS "Environment variable ${EVARPARAM} detected but set to $ENV{${EVARPARAM}}, not appending compile definition.") + else() + message(STATUS "Environment variable ${EVARPARAM} not detected, not appending compile definition.") + endif() + endif() +endfunction() + # COMPONENT_NAME = wolfssl # The component name is the directory name. "No feature to change this". # See https://github.com/espressif/esp-idf/issues/8978#issuecomment-1129892685 @@ -68,7 +217,8 @@ endif() # function: IS_WOLFSSL_SOURCE # parameter: DIRECTORY_PARAMETER - the directory to test # output: RESULT = contains contents of DIRECTORY_PARAMETER for wolfssl directory, otherwise blank. -function(IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER RESULT) +function( IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER + RESULT ) if (EXISTS "${DIRECTORY_PARAMETER}/wolfcrypt/src") set(${RESULT} "${DIRECTORY_PARAMETER}" PARENT_SCOPE) else() @@ -76,27 +226,71 @@ function(IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER RESULT) endif() endfunction() +# ********************************************************************************************* # function: FIND_WOLFSSL_DIRECTORY # parameter: OUTPUT_FOUND_WOLFSSL_DIRECTORY contains root of source code, otherwise blank # +# Example usage: +# FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) +# ********************************************************************************************* function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY) - message(STATUS "Starting FIND_WOLFSSL_DIRECTORY") - set(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}") - if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) - message(STATUS "The WOLFSSL_ROOT environment variable is not set. Searching...") + message(STATUS "Starting FIND_WOLFSSL_DIRECTORY: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + + if ( "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}" STREQUAL "" ) + # The parameter is empty, so we certainly need to search. + # First, see if there's an environment variable. This takes highest priority (unless already found as hard-coded, above) + set(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}") + if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) + message(STATUS "The WOLFSSL_ROOT environment variable is not set. Searching...") + # Next, if not found, see if wolfSSL was selected for ESP-TLS Kconfig + if(CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT) + set(CURRENT_SEARCH_DIR ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}) + get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" ABSOLUTE) + message(STATUS "WOLFSSL_ROOT found in sdkconfig/KConfig: ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") + else() + message(STATUS "wolfSSL not defined in [Component Config] [wolfssl]. Continuing search...") + # If not specified as a search hint in OUTPUT_FOUND_WOLFSSL_DIRECTORY: + # This wolfSSL component CMakeLists.txt may be found EITHER in: + # 1) local project component + # 2) ESP-IDF share components + # We'll start in the CMAKE_CURRENT_SOURCE_DIR, typically [something]/projectname/components/wolfssl + # That option might find wolfSSL source code as a copy in the component directory (e.g. Managed Components) + # Unless cmake is in the ESP-IDF, in which case it is unlikely to find wolfSSL source in any parent. + message(STATUS "CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}") + get_filename_component(CURRENT_SEARCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE) + message(STATUS "CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}") + string(LENGTH ${CURRENT_SEARCH_DIR} CURRENT_SEARCH_DIR_LENGTH) + endif() # CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT + endif() # check environment var blank else() - get_filename_component(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}" ABSOLUTE) + message(STATUS "Parameter found for FIND_WOLFSSL_DIRECTORY") + message(STATUS "Setting wolfSSL search directory to: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + set(CURRENT_SEARCH_DIR "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + endif() # parameter empty + + # Check to see if we found a path in environment or config settings, above. + if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) + message(STATUS "Source for wolfSSL not specified in path nor config settings.") + # We'll continue the search by recursing up the directory tree, below. + else() + # Setting found! Does it contain a valid path? + string(REPLACE "\\" "/" CURRENT_SEARCH_DIR ${CURRENT_SEARCH_DIR}) + get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" ABSOLUTE) IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSL) if( FOUND_WOLFSSL ) - message(STATUS "Found WOLFSSL_ROOT via Environment Variable: ${CURRENT_SEARCH_DIR}") + message(STATUS "Found wolfSSL source code via setting: ${CURRENT_SEARCH_DIR}") set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) return() else() - message(FATAL_ERROR "WOLFSSL_ROOT Environment Variable defined, but path not found:") - message(STATUS "$ENV{WOLFSSL_ROOT}") + if(WIN32) + message(STATUS "When specifying a path for Windows, use forward slahes, or double backslashes.") + endif() + message(STATUS "CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT sdkconfig setting = ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") + message(STATUS "WOLFSSL_ROOT Variable defined, but source code not found: ${CURRENT_SEARCH_DIR}") endif() endif() + # we'll start in the CMAKE_CURRENT_SOURCE_DIR, typically [something]/projectname/components/wolfssl message(STATUS "CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}") get_filename_component(CURRENT_SEARCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE) @@ -114,16 +308,47 @@ function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY) return() endif() + # Maintain CURRENT_SEARCH_DIR, but check various suffixes with CURRENT_SEARCH_DIR_ALT if( THIS_USER ) # Check for "wolfssl-[username]" subdirectory as we recurse up the directory tree set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl-${THIS_USER}) - message(STATUS "Looking in ${CURRENT_SEARCH_DIR}") + message(STATUS "Looking in ${CURRENT_SEARCH_DIR_ALT}") - #if(EXISTS ${CURRENT_SEARCH_DIR_ALT} AND IS_DIRECTORY ${CURRENT_SEARCH_DIR_ALT} AND EXISTS "${CURRENT_SEARCH_DIR_ALT}/wolfcrypt/src") IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL ) if ( FOUND_WOLFSSL ) - message(STATUS "Found wolfssl in user-suffix CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}") - set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR_ALT} PARENT_SCOPE) + message(STATUS "Found wolfssl in user-suffix CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}") + set(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR_ALT}") + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) + return() + endif() + endif() + + if ( FOUND_WOLFSSL ) + # if we already found the source, skip attempt of "wolfssl-master" + else() + set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl-master) + message(STATUS "Looking in ${CURRENT_SEARCH_DIR_ALT}") + + IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL ) + if ( FOUND_WOLFSSL ) + message(STATUS "Found wolfssl in master-suffix CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}") + set(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR_ALT}") + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) + return() + endif() + endif() + + if ( FOUND_WOLFSSL ) + # if we already found the source, skip attempt of "wolfssl" + else() + set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl) + message(STATUS "Looking in ${CURRENT_SEARCH_DIR_ALT}") + + IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL ) + if ( FOUND_WOLFSSL ) + message(STATUS "Found wolfssl in CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}") + set(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR_ALT}") + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) return() endif() endif() @@ -143,7 +368,8 @@ function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY) get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" DIRECTORY) message(STATUS "Next CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}") if( "${PRIOR_SEARCH_DIR}" STREQUAL "${CURRENT_SEARCH_DIR}" ) - # when the search directory is empty, we'll give up + # When the parent is current directory, cannot go any further. We didn't find wolfssl. + # When the search directory is empty, we'll give up. set(CURRENT_SEARCH_DIR "") endif() endwhile() @@ -154,17 +380,64 @@ endfunction() # Example usage: +# +# Simply find the WOLFSSL_DIRECTORY by searching parent directories: +# FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) +# +message(STATUS "CONFIG_TARGET_PLATFORM = ${CONFIG_TARGET_PLATFORM}") +# Check for environment variable that may be assigned to macros +ENVIRONMENT_VAR_TO_MACRO("GENERATE_MACHINE_PARSEABLE_REPORT" "1") +ENVIRONMENT_VAR_TO_MACRO("WOLFSSL_BENCHMARK_FIXED_CSV" "1") +# Optional variable inspection +if (0) + get_cmake_property(_variableNames VARIABLES) + list (SORT _variableNames) + message(STATUS "") + message(STATUS "ALL VARIABLES BEGIN") + message(STATUS "") + foreach (_variableName ${_variableNames}) + message(STATUS "${_variableName}=${${_variableName}}") + endforeach() + message(STATUS "") + message(STATUS "ALL VARIABLES END") + message(STATUS "") +endif() + +if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) + # There's no esp_timer, no driver components for the ESP8266 + message(STATUS "Early expansion EXCLUDES for esp8266:") + message(STATUS "THIS_INCLUDE_DRIVER: '${THIS_INCLUDE_DRIVER}'") + message(STATUS "THIS_INCLUDE_TIMER: '${THIS_INCLUDE_TIMER}'") + message(STATUS "Early expansion INCLUDE for esp8266:") + message(STATUS "THIS_INCLUDE_PTHREAD: '${THIS_INCLUDE_PTHREAD}'") + set(THIS_ESP_TLS "") + set(THIS_INCLUDE_DRIVER "") + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_PTHREAD "pthread") +else() + message(STATUS "Early expansion includes esp_timer: ${THIS_INCLUDE_TIMER}") + message(STATUS "Early expansion includes driver: ${THIS_INCLUDE_DRIVER}") + set(THIS_ESP_TLS "esp-tls") + set(THIS_INCLUDE_DRIVER "driver") + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_PTHREAD "") + # Let the app know that we've included the esp-tls component requirement. + # This is critical for use the the esp-tls component. See wolfssl esp_crt_bundle.c file. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_REQUIRED_ESP_TLS=1") +endif() if(CMAKE_BUILD_EARLY_EXPANSION) message(STATUS "wolfssl component CMAKE_BUILD_EARLY_EXPANSION:") idf_component_register( REQUIRES "${COMPONENT_REQUIRES}" PRIV_REQUIRES # esp_hw_support - # esp_timer - # driver # this will typically only be needed for wolfSSL benchmark + "${THIS_ESP_TLS}" + "${THIS_INCLUDE_PTHREAD}" + "${THIS_INCLUDE_TIMER}" + "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark ) else() @@ -173,48 +446,99 @@ else() message(STATUS "wolfssl component config:") message(STATUS "************************************************************************************************") + if ( "${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") + # There's no esp_timer, no driver components for the ESP8266 + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_DRIVER "") + else() + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_DRIVER "driver") + endif() + # search for wolfSSL FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) if(WOLFSSL_ROOT) - message(STATUS "NEW Found wolfssl directory at: ${WOLFSSL_ROOT}") + IS_WOLFSSL_SOURCE("${WOLFSSL_ROOT}" FOUND_WOLFSSL) + if(FOUND_WOLFSSL) + message(STATUS "Found WOLFSSL_ROOT via CMake specification.") + else() + # WOLFSSL_ROOT Path specified in CMakeLists.txt is not a valid path + message(FATAL_ERROR "WOLFSSL_ROOT CMake Variable defined, but path not found: ${WOLFSSL_ROOT}\n" + "Try correcting WOLFSSL_ROOT in your project CMakeFile.txt or setting environment variable.") + # Abort CMake after fatal error. + endif() else() - message(STATUS "NEW wolfssl directory not found.") + message(STATUS "Source code for wolfSSL still not found.") + message(STATUS "Searching from project home: ${CMAKE_HOME_DIRECTORY} ...") + set(WOLFSSL_ROOT "${CMAKE_HOME_DIRECTORY}") + FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) + endif() + + + if(WOLFSSL_ROOT) + message(STATUS "Confirmed wolfssl directory at: ${WOLFSSL_ROOT}") + else() + # Try to allow a more intuitive error that the source code was not found in cmake: + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_WARNING_SOURCE_NOT_FOUND") + + message(STATUS "Failed: wolfssl source code directory not found.") # Abort. We need wolfssl _somewhere_. - message(FATAL_ERROR "Could not find wolfssl in ${WOLFSSL_ROOT}.\n" - "Try setting WOLFSSL_ROOT environment variable or git clone.") + message(STATUS "") + message(STATUS "") + message(STATUS "Could not find wolfssl in any parent directory named wolfssl-${THIS_USER}, wolfssl-master, or wolfssl.\n" + "Try setting WOLFSSL_ROOT environment variable, cmake variable in project, copy source, or use managed components.") + message(STATUS "") + message(STATUS "") + # Abort CMake after fatal error. (or not?) endif() set(INCLUDE_PATH ${WOLFSSL_ROOT}) set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/src/") - if( ${CMAKE_PROJECT_NAME} STREQUAL "wolfssl_benchmark" ) - set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark") - endif() - - if( ${CMAKE_PROJECT_NAME} STREQUAL "wolfssl_test" ) - set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/test") + # During regression tests, optionally copy source locally and use: set(USE_LOCAL_TEST_BENCH 1) + set(USE_LOCAL_TEST_BENCH 0) + if(NOT USE_LOCAL_TEST_BENCH) + if( "${CMAKE_PROJECT_NAME}" STREQUAL "hello-world" ) + message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/benchmark") + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark") + endif() + + if( "${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_benchmark" ) + message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/benchmark") + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark") + endif() + + if( "${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_test" ) + message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/test") + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/test") + endif() endif() + message(STATUS "WOLFSSL_EXTRA_PROJECT_DIR = ${WOLFSSL_EXTRA_PROJECT_DIR}") set(COMPONENT_SRCDIRS "\"${WOLFSSL_ROOT}/src/\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif/esp_crt_bundle\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/atmel\"" "\"${WOLFSSL_EXTRA_PROJECT_DIR}\"" ) # COMPONENT_SRCDIRS message(STATUS "This COMPONENT_SRCDIRS = ${COMPONENT_SRCDIRS}") + # wolfSSL user_settings.h may be in the local project. + # TODO check if exists and possibly set to ESP-IDF set(WOLFSSL_PROJECT_DIR "${CMAKE_HOME_DIRECTORY}/components/wolfssl") - add_definitions(-DWOLFSSL_USER_SETTINGS_DIR="${WOLFSSL_PROJECT_DIR}/include/user_settings.h") - + string(REPLACE "/" "//" STR_WOLFSSL_PROJECT_DIR "${WOLFSSL_PROJECT_DIR}") + add_compile_definitions(WOLFSSL_USER_SETTINGS_DIR="${STR_WOLFSSL_PROJECT_DIR}/include/user_settings.h") + message(STATUS "Added definition for user_settings.h: -DWOLFSSL_USER_SETTINGS_DIR=\"${STR_WOLFSSL_PROJECT_DIR}//include//user_settings.h\"") # Espressif may take several passes through this makefile. Check to see if we found IDF string(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "" WOLFSSL_FOUND_IDF) # get a list of all wolfcrypt assembly files; we'll exclude them as they don't target Xtensa file(GLOB EXCLUDE_ASM *.S) - file(GLOB_RECURSE EXCLUDE_ASM ${CMAKE_SOURCE_DIR} "${WOLFSSL_ROOT}/wolfcrypt/src/*.S") + file(GLOB EXCLUDE_ASM ${CMAKE_SOURCE_DIR} "${WOLFSSL_ROOT}/wolfcrypt/src/*.S") message(STATUS "IDF_PATH = $ENV{IDF_PATH}") message(STATUS "PROJECT_SOURCE_DIR = ${PROJECT_SOURCE_DIR}") @@ -237,11 +561,12 @@ else() message(STATUS "Remove either the local project component: ${WOLFSSL_PROJECT_DIR} ") message(STATUS "or the Espressif shared component installed at: $ENV{IDF_PATH}/components/wolfssl/ ") message(STATUS "") - message(FATAL_ERROR "Please use wolfSSL in either local project or Espressif components, but not both.") message(STATUS "") message(STATUS "**************************************************************************************") message(STATUS "") + message(STATUS "Please use wolfSSL in either local project or Espressif components, but not both.") + # Optional: if you change the above FATAL_ERROR to STATUS you can warn at runtime with this macro definition: set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING") @@ -291,6 +616,7 @@ else() message(FATAL_ERROR "Found stray wolfSSL user_settings.h in " "${WOLFSSL_ROOT}/include/user_settings.h " " (please move it to ${WOLFSSL_PROJECT_DIR}/include/user_settings.h )") + # Abort CMake after fatal error. else() # we won't overwrite an existing user settings file, just note that we already have one: if( EXISTS "${WOLFSSL_PROJECT_DIR}/include/user_settings.h" ) @@ -347,7 +673,9 @@ else() # depending on the environment, we may need to swap backslashes with forward slashes string(REPLACE "\\" "/" RTOS_IDF_PATH "$ENV{IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") - string(REPLACE "\\" "/" WOLFSSL_ROOT ${WOLFSSL_ROOT}) + if(WOLFSSL_ROOT) + string(REPLACE "\\" "/" WOLFSSL_ROOT ${WOLFSSL_ROOT}) + endif() if(IS_DIRECTORY "${RTOS_IDF_PATH}") message(STATUS "Found current RTOS path: ${RTOS_IDF_PATH}") @@ -360,21 +688,22 @@ else() message(STATUS "Could not find RTOS path") endif() endif() - - + message(STATUS "THIS_IDF_PATH = $THIS_IDF_PATH") + # wolfSSL-specific include directories set(COMPONENT_ADD_INCLUDEDIRS - "./include" # this is the location of wolfssl user_settings.h + "./include" # this is the location of local project wolfssl user_settings.h "\"${WOLFSSL_ROOT}/\"" "\"${WOLFSSL_ROOT}/wolfssl/\"" "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/\"" + "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/port/Espressif\"" "\"${RTOS_IDF_PATH}/\"" # wolfSSL release after v5.7 includes WiFi, time, and mem/debug helpers - ${THIS_IDF_PATH}/components/esp_event/include - ${THIS_IDF_PATH}/components/esp_netif/include - ${THIS_IDF_PATH}/components/esp_wifi/include + "${THIS_IDF_PATH}/components/esp_event/include" + "${THIS_IDF_PATH}/components/esp_netif/include" + "${THIS_IDF_PATH}/components/esp_wifi/include" ) - + # Optionally include cryptoauthlib if present if(IS_DIRECTORY ${IDF_PATH}/components/cryptoauthlib) list(APPEND COMPONENT_ADD_INCLUDEDIRS "../cryptoauthlib/lib") endif() @@ -399,8 +728,8 @@ else() "\"${WOLFSSL_ROOT}/src/ssl_sess.c\"" # included by ssl.c "\"${WOLFSSL_ROOT}/src/x509.c\"" "\"${WOLFSSL_ROOT}/src/x509_str.c\"" - "\"${WOLFSSL_ROOT}/wolfcrypt/src/ext_kyber.c\"" # external Kyber disabled by default - "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/ext_kyber.h\"" # external Kyber disabled by default + "\"${WOLFSSL_ROOT}/wolfcrypt/src/ext_kyber.c\"" # external non-wolfssl Kyber disabled by default + "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/ext_kyber.h\"" # external non-wolfssl Kyber disabled by default "\"${WOLFSSL_ROOT}/wolfcrypt/src/evp.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/misc.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_arm32.c\"" @@ -411,6 +740,7 @@ else() "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_cortexm.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_x86_64.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_x86_64_asm.S\"" + "\"${WOLFSSL_ROOT}/examples\"" # Examples are distributed in Managed Components, but not part of a project. "\"${EXCLUDE_ASM}\"" ) @@ -432,22 +762,144 @@ else() # see https://docs.espressif.com/projects/esp-idf/en/stable/esp32/migration-guides/release-5.x/build-system.html?highlight=space%20path # set(EXTRA_COMPONENT_DIRS "${COMPONENT_SRCDIRS}") - idf_component_register( - SRC_DIRS "${COMPONENT_SRCDIRS}" - INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}" - REQUIRES "${COMPONENT_REQUIRES}" - EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}" - PRIV_REQUIRES esp_timer driver # this will typically only be needed for wolfSSL benchmark - ) - # some optional diagnostics - if (1) + + if(WOLFSSL_ROOT) + # Only register the component if we found wolfSSL source. + # This is important to allow Cmake to finish to completion, otherwise the UI + # may not be able to display the Kconfig settings to fix a bad or missing source. + idf_component_register( + SRC_DIRS "${COMPONENT_SRCDIRS}" + INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}" + REQUIRES "${COMPONENT_REQUIRES}" + EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}" + PRIV_REQUIRES + "${THIS_ESP_TLS}" + "${THIS_INCLUDE_TIMER}" + "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark + ) + else() + # Register the component simply to allow CMake to complete, but there's no wolfSSL source. + # Expect many other errors, but the project should at least be loadable and UI can edit Kconfig settings. + idf_component_register() + message(STATUS "Warning: wolfSSL component not registered as no source code found (WOLFSSL_ROOT is blank)") + endif() + +# function(WOLFSSL_INIT_CERT_BUNDLE) +if( CONFIG_WOLFSSL_CERTIFICATE_BUNDLE + AND NOT CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + AND NOT ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") + ) + if (CMAKE_BUILD_EARLY_EXPANSION) + message(ERROR "Bundle Cert initialization must occur during CMAKE_BUILD_EARLY_EXPANSION") + endif() + # reminder: we need a value for wolfSSL root first! + if( "${WOLFSSL_ROOT}" STREQUAL "" ) + message(ERROR "Certificate bundles need a value for WOLFSSL_ROOT") + endif() + set(WOLFSSL_ESP_CRT_BUNDLE_DIR ${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif/esp_crt_bundle) + message(STATUS "WOLFSSL_ESP_CRT_BUNDLE_DIR=${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + if(EXISTS "${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + set(bundle_name "x509_crt_bundle_wolfssl") + + # For now the certs are in the same directory + set(DEFAULT_CRT_DIR "${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + + # Generate custom certificate bundle using the generate_cert_bundle utility + set(GENERATE_CERT_BUNDLEPY ${python} ${WOLFSSL_ESP_CRT_BUNDLE_DIR}/gen_crt_bundle.py) + + if(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_all.pem ${DEFAULT_CRT_DIR}/cacrt_local.pem) + elseif(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_CMN) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_all.pem ${DEFAULT_CRT_DIR}/cacrt_local.pem) + list(APPEND args --filter ${DEFAULT_CRT_DIR}/cmn_crt_authorities.csv) + endif() + + # Add deprecated root certs if enabled. This config is not visible if the default cert + # bundle is not selected + if(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEPRECATED_LIST) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_deprecated.pem) + endif() + + if(CONFIG_WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE) + get_filename_component(custom_bundle_path + ${CONFIG_WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE_PATH} ABSOLUTE BASE_DIR "${project_dir}") + list(APPEND crt_paths ${custom_bundle_path}) + message(STATUS "Using a custom wolfSSL bundle path: ${custom_bundle_path}") + else() + message(STATUS "Not using a custom wolfSSL bundle path.") + endif() + list(APPEND args --input ${crt_paths} -q) + + message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") + get_filename_component(crt_bundle + ${bundle_name} + ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") + + message(STATUS "Setting up bundle generate: ${GENERATE_CERT_BUNDLEPY} ${args}") + message(STATUS "Depends on custom bundle path: ${custom_bundle_path}") + message(STATUS "crt_bundle ${crt_bundle}") + message(STATUS "COMPONENT_LIB ${COMPONENT_LIB}") + message(STATUS "GENERATE_CERT_BUNDLEPY ${GENERATE_CERT_BUNDLEPY}") + message(STATUS "args ${args}") + message(STATUS "cert_bundle ${cert_bundle}") + + # Generate bundle according to config + # File is generated at build time, not cmake load + add_custom_command(OUTPUT ${crt_bundle} + COMMAND ${GENERATE_CERT_BUNDLEPY} ARGS ${args} + DEPENDS ${custom_bundle_path} + VERBATIM) + + if(EXISTS "${crt_bundle}") + message(STATUS "Bundle file exists from prior build: ${crt_bundle}") + else() + message(STATUS "Bundle file expected during next build: ${crt_bundle}") + endif() + + # Reminder the file is generated at build time, not cmake load time. + message(STATUS "wolfSSL Cert Bundle File to be created at build time in: ${crt_bundle}") + + add_custom_target(custom_wolfssl_bundle DEPENDS ${cert_bundle}) + + # the wolfSSL crtificate bundle is baked into wolfSSL + add_dependencies(${COMPONENT_LIB} custom_wolfssl_bundle) + + # COMPONENT_LIB may vary: __idf_wolfssl, __idf_esp_wolfssl, etc + # target_add_binary_data(__idf_wolfssl ${crt_bundle} BINARY) + target_add_binary_data(${COMPONENT_LIB} ${crt_bundle} BINARY) + set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + APPEND PROPERTY ADDITIONAL_CLEAN_FILES + "${crt_bundle}") + else() + message(STATUS "WARNING: CONFIG_WOLFSSL_CERTIFICATE_BUNDLE enabled but directory not found: ${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + endif() +endif() + +# endfunction() # WOLFSSL_INIT_CERT_BUNDLE + + # Some optional diagnostics. Verbose ones are truncated. + if (VERBOSE_COMPONENT_MESSAGES) get_cmake_property(_variableNames VARIABLES) list (SORT _variableNames) message(STATUS "") message(STATUS "ALL VARIABLES BEGIN") message(STATUS "") foreach (_variableName ${_variableNames}) - message(STATUS "${_variableName}=${${_variableName}}") + if ( ("${_variableName}" STREQUAL "bootloader_binary_files") + OR ("${_variableName}" STREQUAL "Component paths") + OR ("${_variableName}" STREQUAL "component_targets") + OR ("${_variableName}" STREQUAL "__COMPONENT_TARGETS") + OR ("${_variableName}" STREQUAL "CONFIGS_LIST") + OR ("${_variableName}" STREQUAL "__CONFIG_VARIABLES") + OR ("${_variableName}" STREQUAL "val") + OR ("${_variableName}" MATCHES "^__idf_") + ) + # Truncate the displayed value: + string(SUBSTRING "${${_variableName}}" 0 70 truncatedValue) + message(STATUS "${_variableName} = ${truncatedValue} ... (truncated)") + else() + message(STATUS "${_variableName}=${${_variableName}}") + endif() endforeach() message(STATUS "") message(STATUS "ALL VARIABLES END") @@ -455,6 +907,12 @@ else() endif() # target_sources(wolfssl PRIVATE "\"${WOLFSSL_ROOT}/wolfssl/\"" "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt\"") + message(STATUS "DETECTED_PROJECT_NAME=${CMAKE_PROJECT_NAME}") + message(STATUS "COMPONENT_TARGET=${COMPONENT_TARGET}") + target_compile_definitions(${COMPONENT_TARGET} PRIVATE DETECTED_PROJECT_NAME="${CMAKE_PROJECT_NAME}") + if( "${CMAKE_PROJECT_NAME}" STREQUAL "esp_http_client_example" ) + target_compile_definitions(${COMPONENT_TARGET} PRIVATE APP_ESP_HTTP_CLIENT_EXAMPLE="y") + endif() endif() # CMAKE_BUILD_EARLY_EXPANSION @@ -500,7 +958,7 @@ function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) message(STATUS "Found ${VAR_OUPUT}=${VAR_VALUE}") # the interesting part is defining the VAR_OUPUT name a value to use in the app - add_definitions(-D${VAR_OUPUT}=\"${VAR_VALUE}\") + add_compile_definitions(${VAR_OUPUT}=\"${VAR_VALUE}\") else() # if we get here, check the execute_process command and parameters. message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT") @@ -508,33 +966,89 @@ function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) endif() endfunction() # LIBWOLFSSL_SAVE_INFO +execute_process( + COMMAND ${git_cmd} "rev-parse" "--is-inside-work-tree" + OUTPUT_VARIABLE IS_GIT_REPO + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + # create some programmatic #define values that will be used by ShowExtendedSystemInfo(). # see wolfcrypt\src\port\Espressif\esp32_utl.c -if(NOT CMAKE_BUILD_EARLY_EXPANSION) +if(NOT CMAKE_BUILD_EARLY_EXPANSION AND WOLFSSL_ROOT AND (IS_GIT_REPO STREQUAL "true")) set (git_cmd "git") message(STATUS "Adding macro definitions:") # LIBWOLFSSL_VERSION_GIT_ORIGIN: git config --get remote.origin.url - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "config" "--get" "remote.origin.url" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "config" "--get" "remote.origin.url" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_ORIGIN "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_BRANCH: git rev-parse --abbrev-ref HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--abbrev-ref" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--abbrev-ref" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_BRANCH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_HASH: git rev-parse HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_SHORT_HASH: git rev-parse --short HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_SHORT_HASH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_HASH_DATE git show --no-patch --no-notes --pretty=\'\%cd\' - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} + "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH_DATE "${TMP_OUT}" "${TMP_RES}") - message(STATUS "************************************************************************************************") - message(STATUS "wolfssl component config complete!") - message(STATUS "************************************************************************************************") + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_WOLFSSL_ROOT "${WOLFSSL_ROOT}" "${TMP_RES}") + endif() + +# Ensure flag "-DWOLFSSL_ESPIDF" is already in CMAKE_C_FLAGS if not yet found from project +string(FIND "${CMAKE_C_FLAGS}" "-DWOLFSSL_ESPIDF" FLAG_ALRREADY_FOUND_WOLFSSL_ESPIDF) + +if(FLAG_ALRREADY_FOUND_WOLFSSL_ESPIDF EQUAL -1) + # Flag not found, append it + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESPIDF") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +endif() + +if(WOLFSSL_ROOT) + message(STATUS "Using wolfSSL in ${WOLFSSL_ROOT}") + + # PlatformIO does not process script from from the Espressif cmake process. + # We need to know where wolfSSL source code was found, so save it in the + # PIO_WOLFSSL_ROOT environment variable to later be read by extra_script.py + + set(ENV{PIO_WOLFSSL_ROOT} "${WOLFSSL_ROOT}") + message(STATUS "PIO_WOLFSSL_ROOT = $ENV{PIO_WOLFSSL_ROOT}") + message(STATUS "PLATFORMIO_BUILD_DIR = $ENV{PLATFORMIO_BUILD_DIR}") + # See esp-tls Kconfig; menu "ESP-TLS", ESP_TLS_LIBRARY_CHOOSE + if(CONFIG_ESP_TLS_USING_WOLFSSL) + if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) + message(STATUS "This version of wolfSSL is not supported on the ESP8266 esp-tls at this time. Check ESP-TLS config") + else() + message(STATUS "wolfSSL will be used for ESP-TLS") + endif() + else() + message(STATUS "WARNING: wolfSSL NOT selected for ESP-TLS. Features and performance will be limited.") + endif() +else() + message(STATUS "") + message(STATUS "Consider setting WOLFSSL_ROOT environment variable, use Kconfig setting, or set manually in this cmake file, above.") + message(STATUS "") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "ERROR: Could not find wolfSSL Source Code") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") +endif() + +message(STATUS "************************************************************************************************") +message(STATUS "wolfSSL component config complete!") +message(STATUS "************************************************************************************************") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/Kconfig b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/Kconfig new file mode 100644 index 000000000..150913190 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/Kconfig @@ -0,0 +1,523 @@ +# Kconfig template +# +# Copyright (C) 2006-2025 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 +# + +# Kconfig File Version 5.7.2.001 for esp-idf integration + +# Kconfig Format Rules +# +# See: +# https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/kconfig.html +# +# Format rules for Kconfig files are as follows: +# +# Option names in any menus should have consistent prefixes. The prefix +# currently should have at least 3 characters. +# +# The unit of indentation should be 4 spaces. All sub-items belonging to a +# parent item are indented by one level deeper. For example, menu is indented +# by 0 spaces, config menu by 4 spaces, help in config by 8 spaces, and the +# text under help by 12 spaces. +# +# No trailing spaces are allowed at the end of the lines. +# +# The maximum length of options is NOT 50 characters as documented. +# kconfcheck will complain that options should be 40 at most. +# +# Fix option lengths first. Superfluous errors on other lines may occur. +# +# The maximum length of lines is 120 characters. +# +# python -m kconfcheck +# +# --------------------------------------------------------------------------------------------------------------------- +# Begin main wolfSSL configuration menu +# --------------------------------------------------------------------------------------------------------------------- +# See ESP-IDF esp-tls component for config TLS_STACK_WOLFSSL + +menu "wolfSSL" + + menu "Hardening" + config ESP_WOLFSSL_WC_NO_HARDEN + bool "Disable wolfSSL hardening" + default n + help + Sets WC_NO_HARDEN + + config ESP_WOLFSSL_TFM_TIMING_RESISTANT + bool "Enable TFM Timing Resistant Code" + default n + help + Sets TFM_TIMING_RESISTANT. + + endmenu # Hardening + + config ESP_WOLFSSL_ENABLE_BENCHMARK + bool "Enable wolfSSL Benchmark Library" + default n + help + Enables wolfcrypt/benchmark/benchmark.c code for benchmark metrics. Disables NO_CRYPT_BENCHMARK. + + + menu "Benchmark Debug" + config ESP_DEBUG_WOLFSSL_BENCHMARK_TIMING + bool "Enable benchmark timing debug" + depends on ESP_WOLFSSL_ENABLE_BENCHMARK + default n + help + Enable wolfssl debug for benchmark metric timing (CPU Cycles, RTOS ticks, etc). + + config ESP_WOLFSSL_BENCHMARK_TIMER_DEBUG + bool "Enable benchmark timer debug" + depends on ESP_WOLFSSL_ENABLE_BENCHMARK + default n + help + Turn on timer debugging (used when CPU cycles not available) + + endmenu # Benchmark Debug + + # ----------------------------------------------------------------------------------------------------------------- + # wolfCrypt Test + # ----------------------------------------------------------------------------------------------------------------- + config ESP_WOLFSSL_ENABLE_TEST + bool "Enable wolfCrypt Test Library" + default n + help + Enables wolfcrypt/test/test.c code for testing. Disables NO_CRYPT_TEST. + + menu "wolfCrypt tests" + config WOLFSSL_HAVE_WOLFCRYPT_TEST_OPTIONS + bool "Enable wolfCrypt Test Options" + depends on ESP_WOLFSSL_ENABLE_TEST + default n + help + Enables HAVE_WOLFCRYPT_TEST_OPTIONS + + config TEST_ESPIDF_ALL_WOLFSSL + bool "Enable all features to use in tests" + depends on ESP_WOLFSSL_ENABLE_TEST + default n + help + Enables TEST_ESPIDF_ALL_WOLFSSL + + endmenu # wolfCrypt tests + + # ----------------------------------------------------------------------------------------------------------------- + # Apple HomeKit Options + # ----------------------------------------------------------------------------------------------------------------- + menu "Apple HomeKit" + config WOLFSSL_APPLE_HOMEKIT + bool "Enable Apple HomeKit options" + default n + help + Enables FP_MAX_BITS (8192 * 2), SRP, ChaCha, Poly1305, Base64 encoding needed for Apple HomeKit. + endmenu # Apple HomeKit + # ----------------------------------------------------------------------------------------------------------------- + + config ESP_WOLFSSL_DISABLE_MY_ECC + bool "Disable ECC in my project" + default "n" + help + ECC is enabled by default. Select this option to disable. + + config ESP_WOLFSSL_ENABLE_MY_USE_RSA + bool "Enable RSA in my project" + default "n" + help + RSA is disabled by default. Select this option to enable. + + config ESP_WOLFSSL_BENCHMARK + bool "Enable wolfSSL Benchmark" + default n + help + Enables user settings relevant to benchmark code + + config ESP_TLS_USING_WOLFSSL_SPECIFIED + bool "Use the specified wolfssl for ESP-TLS" + default Y + help + Includes wolfSSL from specified directory (not using esp-wolfssl). + + config ESP_WOLFSSL_NO_USE_FAST_MATH + bool "Disable FAST_MATH library and all ESP32 Hardware Acceleration" + select ESP_WOLFSSL_NO_HW + select ESP_WOLFSSL_NO_HW_AES + select ESP_WOLFSSL_NO_HW_HASH + select ESP_WOLFSSL_NO_HW_RSA_PRI + select ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + default n + help + When disabling all hardware acceleration for smaller memory footprint, + disabling TFM fast math provides faster wolfSSL software algorithms in an + even smaller flash memory footprint. + + menu "Protocol Config" + config WOLFSSL_HAVE_ALPN + bool "Enable ALPN (Application Layer Protocol Negotiation) in wolfSSL" + default y + + config WOLFSSL_ALLOW_TLS13 + bool "Allow TLS 1.3" + default y + help + Allow TLS to fallback to TLS1.2. Memory footprint will likely be larger for TLS1.2. + When disabled HTTPS and MQTT over TLS connections will fail if TLS1.3 not accepted. + + config WOLFSSL_ALLOW_TLS12 + bool "Allow TLS 1.2" + default n + help + Allow TLS to fallback to TLS1.2. Memory footprint will likely be larger for TLS1.2. + When disabled HTTPS and MQTT over TLS connections will fail if TLS1.3 not accepted. + + config WOLFSSL_HAVE_TLS_EXTENSIONS + bool "Enable TLS Extensions" + default y + help + Sets HAVE_TLS_EXTENSIONS which is needed for TLS 1.3, SNI, ALPN, and more. + + config WOLFSSL_ALT_CERT_CHAINS + bool "Enable Alternate Certificate Chains" + default n + help + The option relaxes the default strict wolfSSL certificate chain processing. This + will typically need to be enabled when loading only a CA file. Typically solves + the -188 ASN_NO_SIGNER_E error. Use with caution. + + config WOLFSSL_HAVE_OCSP + bool "Enable OCSP (Online Certificate Status Protocol) in wolfSSL" + default n + help + Sets HAVE_OCSP + + endmenu # Protocol Config + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + config TLS_STACK_WOLFSSL + # Invisible option that locks TLS_STACK_WOLFSSL to ESP_TLS_USING_WOLFSSL + bool + default n + select FREERTOS_ENABLE_BACKWARD_COMPATIBILITY + help + Includes wolfSSL in ESP-TLS so that it can be compiled with wolfSSL as its SSL/TLS library. + Enabled when wolfSSL is selected in ESP_TLS_LIBRARY_CHOOSE. + + menu "wolfSSL ESP-TLS" + depends on ESP_TLS_USING_WOLFSSL + + menu "Certificate Bundle" + depends on ESP_TLS_USING_WOLFSSL + + config WOLFSSL_CERTIFICATE_BUNDLE + bool "Enable trusted root certificate bundle" + default y if ESP_TLS_USING_WOLFSSL + default n + depends on ESP_TLS_USING_WOLFSSL + help + Enable support for large number of default root certificates + + When enabled this option allows user to store default as well + as customer specific root certificates in compressed format rather + than storing full certificate. For the root certificates the public key and the subject name + will be stored. + + config WOLFSSL_NO_ASN_STRICT + bool "Relax Certificate ASN Strict Checks" + default n + depends on ESP_TLS_USING_WOLFSSL + help + Allows sub-optimal certificate ASN checks. Unless using a bundle with known issues, + it is recommended to NOT enable this. + + config WOLFSSL_ASN_ALLOW_0_SERIAL + bool "Allow cert missing an ASN Serial Number" + default y + depends on ESP_TLS_USING_WOLFSSL + help + Although not recommended, there may be certificates in the bundle that are missing + a serial number. This option allows the missing value without having to fully + disable strict ASN checking with WOLFSSL_NO_ASN_STRICT. + + choice WOLFSSL_DEFAULT_CERTIFICATE_BUNDLE + bool "Default certificate bundle options" + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + default WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL + + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL + bool "Use the full default certificate bundle" + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_CMN + bool "Use only the most common certificates from the default bundles" + help + Use only the most common certificates from the default bundles, reducing the size with 50%, + while still having around 99% coverage. + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + bool "Do not use the default certificate bundle" + endchoice + + config WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + default n + bool "Add custom certificates to the default bundle" + config WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE_PATH + depends on WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + string "Custom certificate bundle path" + help + Name of the custom certificate directory or file. This path is evaluated + relative to the project root directory. + + config WOLFSSL_CERTIFICATE_BUNDLE_DEPRECATED_LIST + bool "Add deprecated root certificates" + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL && !WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + help + Include the deprecated list of root certificates in the bundle. + This list gets updated when a certificate is removed from the Mozilla's + NSS root certificate store. This config can be enabled if you would like + to ensure that none of the certificates that were deployed in the product + are affected because of the update to bundle. In turn, enabling this + config keeps expired, retracted certificates in the bundle and it may + pose a security risk. + + - Deprecated cert list may grow based based on sync with upstream bundle + - Deprecated certs would be be removed in ESP-IDF (next) major release + + config WOLFSSL_CERTIFICATE_BUNDLE_MAX_CERTS + int "Maximum no of certificates allowed in certificate bundle" + default 200 + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + + endmenu + endmenu # wolfSSL ESP-TLS + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + config ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + bool "Modify default hardware acceleration settings" + default n + help + When disabling all hardware acceleration for smaller memory footprint, + disabling TFM fast math provides faster wolfSSL software algorithms in an + even smaller flash memory footprint. + Typically used for debugging, analysis, or optimizations. The default + hardware acceleration features can be each manually adjusted. + + menu "wolfSSL Hardware Acceleration" + + config ESP_WOLFSSL_NO_ESP32_CRYPT + bool "Disable all ESP32 Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + select ESP_WOLFSSL_NO_HW_AES + select ESP_WOLFSSL_NO_HW_HASH + select ESP_WOLFSSL_NO_HW_RSA_PRI + select ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + help + Hardware acceleration enabled by default. When selected defines: NO_ESP32_CRYPT. + Consider disabling FASTMATH (other libraries are faster in software and smaller) + + config ESP_WOLFSSL_NO_HW_AES + bool "Disable all ESP32 AES Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default.When selected defines: NO_HW_AES + + config ESP_WOLFSSL_NO_HW_HASH + bool "Disable all ESP32 SHA Hash Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_HASH + + config ESP_WOLFSSL_NO_HW_RSA_PRI + bool "Disable all ESP32 RSA Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + select ESP_WOLFSSL_NO_HW_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI + + config ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + bool "Disable all ESP32 Multiplication Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI_MP_MUL + + config ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + bool "Disable all ESP32 Modular Multiplication Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI_MULMOD + + config ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + bool "Disable all ESP32 RSA Exponential Math Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. + Select this option to force disable: NO_HW_RSA_PRI_EXPTMOD + + config ESP_WOLFSSL_DEBUG_ESP_HW_MULTI_RSAMAX_BITS + bool "Enable debugging of RSA Multiplication operand length" + default n + help + Prints an esp log warning to the default console UART when one of the + multiplication operands exceeds the maximum size supported by hardware, + requiring fallback to software. This can be helpful to pick key sizes + when performance is critical. See also metrics for counting instances. + + config ESP_WOLFSSL_DEBUG_ESP_HW_MOD_RSAMAX_BITS + bool "Enable debugging of RSA Modular operand length" + default n + help + Prints an esp log warning to the default console UART when one of the + modular math operands exceeds the maximum size supported by hardware, + requiring fallback to software. This can be helpful to pick key sizes + when performance is critical. See also metrics for counting instances. + + endmenu # wolfSSL Hardware Acceleration + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Experimental Options" + + config ESP_WOLFSSL_EXPERIMENTAL_SETTINGS + bool "Enable wolfSSL Experimental Settings" + default n + help + Enables experimental settings for wolfSSL. See documentation. + + config ESP_WOLFSSL_ENABLE_KYBER + bool "Enable wolfSSL Kyber" + default n + help + Enable debugging messages for wolfSSL. See user_settings.h for additional debug options. + + endmenu # wolfSSL Experimental Options + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Debug Options" + config ESP_WOLFSSL_DEBUG_WOLFSSL + bool "Enable wolfSSL Debugging" + default n + help + Enable debugging messages for wolfSSL. See user_settings.h for additional debug options. + + config ESP_WOLFSSL_TEST_LOOP + bool "Run test apps in a loop until failure" + default y + help + Enable a loop wrapper for benchmark, http_client, and wolfssl test apps. + + endmenu # wolfSSL Debug Options + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Customization" + config CUSTOM_SETTING_WOLFSSL_ROOT + string "Enter a path for wolfSSL source code" + default "~/workspace/wolfssl" + help + This option lets you specify a directory for the wolfSSL source code (typically a git clone). + Enter the path using forward slashes (e.g., C:/myfolder/mysubfolder) or double backslashes + (e.g., C:\\myfolder\\mysubfolder). + + endmenu # wolfSSL Customization + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "Component Config" + config IGNORE_ESP_IDF_WOLFSSL_COMPONENT + bool "Ignore the ESP-IDF component of wolfSSL (if present)" + default n + help + Ignores wolfSSL present in the esp-idf/components directory. Requires wolfssl as a local component. + + config IGNORE_LOCAL_WOLFSSL_COMPONENT + bool "Ignore the local component of wolfSSL (if present)" + default n + help + Ignores wolfSSL present in the local project components directory. + Requires wolfssl as a ESP-IDF component. + + endmenu # Component Config + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "Utility Config" + config USE_WOLFSSL_ESP_SDK_TIME + bool "Enable wolfSSL time helper functions" + default n + help + Enables use of various time and date setting functions found in the esp-sdk-lib.h file. + + config USE_WOLFSSL_ESP_SDK_WIFI + bool "Enable wolfSSL WiFi helper functions" + default n + help + Enables use of various time and date setting functions found in the esp-sdk-lib.h file. + + endmenu # Utility Config +endmenu # wolfSSL +# --------------------------------------------------------------------------------------------------------------------- + + +# --------------------------------------------------------------------------------------------------------------------- +menu "wolfSSH" + config ESP_ENABLE_WOLFSSH + bool "Enable wolfSSH options" + default n + help + Enables WOLFSSH_TERM, WOLFSSL_KEY_GEN, WOLFSSL_PTHREADS, WOLFSSH_TEST_SERVER, WOLFSSH_TEST_THREADING + + config ESP_WOLFSSL_DEBUG_WOLFSSH + bool "Enable wolfSSH debugging" + default n + help + Enable wolfSSH debugging macro. See user_settings.h + +endmenu # wolfSSH +# --------------------------------------------------------------------------------------------------------------------- + +# --------------------------------------------------------------------------------------------------------------------- +menu "wolfMQTT" + config ESP_ENABLE_WOLFMQTT + bool "Enable wolfMQTT options" + default n + help + Enables WOLFMQTT + + config ESP_WOLFSSL_DEBUG_WOLFMQTT + bool "Enable wolfMQTT debugging" + default n + help + Enable wolfMQTT debugging macro. See user_settings.h + +endmenu # wolfMQTT +# --------------------------------------------------------------------------------------------------------------------- diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/README.md b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/README.md new file mode 100644 index 000000000..d77912416 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/README.md @@ -0,0 +1,162 @@ +# wolfSSL Espressif Component + +This is the directory for wolfSSL as an Espressif ESP-IDF component. + +Other options are available, such as installing wolfSSL as a local _project_ component using the [Managed Component](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/). + +Enabling this wolfSSL ESP-IDF component allows other ESP-IDF libraries such as those that depend on [ESP-TLS](https://github.com/espressif/esp-idf/tree/master/components/esp-tls) +to also use the wolfSSL library. (See [github.com/wolfSSL/wolfssl](https://github.com/wolfSSL/wolfssl)) + +The wolfSSL source code is not included here. Instead, the `idf.py menuconfig` option can be used to configure the +`sdkconfig` file setting: `CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT` to point to the desired wolfSSL code. + +## Directory Contents + +This directory must contain, at a minimum: + +- `CMakeLists.txt` +- `./include/user_settings.h` + +The directory should also contain: +- `Kconfig` +- `component.mk` + +The directory may contain wolfSSL source, for example with a [Managed Component](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/), +or if the `setup.sh` script was used from [wolfSSL/IDE/Espressif/ESP-IDF](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF). + + +Under normal circumstances when the wolfSSL source is not included here, the `CMakeLists.txt` will search for it in this order: + +- A hard-coded `WOLFSSL_ROOT` cmake variable. +- `WOLFSSL_ROOT` Environment Variable +- The `CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT` value in the `sdkconfig` file, from the `Kconfig` option. +- Any parent directories, up to the root (if this directory is in the ESP-IDF components) +- Any parent directories, up to the root (if this directory is a project component) + +While recursing up the directory tree, the following names of wolfSSL directories will be considered: + +- `wolfssl-[current user name]` +- `wolfssl-master` +- `wolfssl` + +## Getting Started + +See the `Espressif Getting Started Guide`. + +``` +# Set environment variable to ESP-IDF location +# For example, VisualGDB in WSL +WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.2 +WRK_IDF_PATH=/mnt/c/SysGCC/esp32-master/esp-idf/v5.3-master + +# Or wherever the ESP-IDF is installed: +WRK_IDF_PATH=~/esp/esp-idf + +echo "Run export.sh from ${WRK_IDF_PATH}" +. ${WRK_IDF_PATH}/export.sh + +cd [your project] + +idf.py menuconfig +``` + +Enable wolfSSL to be used in the ESP-TLS: + +``` +Component config ---> + ESP-TLS ---> + Choose SSL/TLS library for ESP-TLS (See help for more Info) + (X) wolfSSL (License info in wolfSSL directory README) +``` + +Adjust wolfSSL settings, such as path to source code as needed: + +``` +Component config ---> + wolfSSL ---> + [*] Include wolfSSL in ESP-TLS + [*] Use the specified wolfssl for ESP-TLS + (~/workspace/wolfssl) Enter a path for wolfSSL source code +``` + +## Configuration + +All settings for wolfSSL are adjusted in the [include/user_settings.h](./include/user_settings.h) file. + +The `user_settings.h` file should not be included directly. Instead, `#include ` +before any other wolfSSL headers, like this: + + +```c +/* ESP-IDF */ +#include +#include "sdkconfig.h" + +/* wolfSSL */ +/* Always include wolfcrypt/settings.h before any other wolfSSL file. */ +/* Reminder: settings.h pulls in user_settings.h; don't include it here. */ +#if defined(WOLFSSL_USER_SETTINGS) + #include + #if defined(WOLFSSL_ESPIDF) + #include + #include + #include + #include + #include + #else + #error "Problem with wolfSSL user_settings. " \ + "Check components/wolfssl/include " \ + "and confirm WOLFSSL_USER_SETTINGS is defined, " \ + "typically in the component CMakeLists.txt" + #endif +#else + /* Define WOLFSSL_USER_SETTINGS project wide for settings.h to include */ + /* wolfSSL user settings in ./components/wolfssl/include/user_settings.h */ + #error "Missing WOLFSSL_USER_SETTINGS in CMakeLists or Makefile:\ + CFLAGS +=-DWOLFSSL_USER_SETTINGS" +#endif +``` + +## Examples + +See the wolfSSL examples: + +- [wolfSSL Core Examples](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples) +- [wolfSSL Additional Examples](https://github.com/wolfSSL/wolfssl-examples/tree/master/ESP32) +- [wolfSSH Core Examples](https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples) +- [wolfSSH Additional Examples](https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif) +- [wolfMQTT Examples](https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples) + +## Platforms + +The ESP-IDF wolfSSL is also available for PlatformIO: + +- [Release wolfSSL](https://registry.platformio.org/search?q=owner%3Awolfssl) +- [Staging / Preview wolfSSL](https://registry.platformio.org/search?q=owner%3Awolfssl-staging) + +The wolfSSL library can also be used for Espressif with Arduino: + +- [arduino.cc/reference/en/libraries/wolfssl](https://www.arduino.cc/reference/en/libraries/wolfssl/) +- [github.com/wolfSSL/Arduino-wolfSSL](https://github.com/wolfSSL/Arduino-wolfSSL) + + +## Additional Information + +- [wolfSSL Documentation](https://www.wolfssl.com/documentation/manuals/wolfssl/index.html) and [docs/espressif](https://www.wolfssl.com/docs/espressif/) +- [wolfSSL FAQ](https://www.wolfssl.com/docs/frequently-asked-questions-faq/) +- [wolfSSL Products](https://www.wolfssl.com/products/) +- [www.wolfssl.com/espressif](https://www.wolfssl.com/espressif/) +- [More...](https://www.wolfssl.com/?s=espressif) + +## Contact + +Have a specific request or questions? We'd love to hear from you! Please contact us at support@wolfssl.com or open an issue on GitHub. + +## Licensing and Support + +wolfSSL (formerly known as CyaSSL) and wolfCrypt are either licensed for use under the GPLv2 (or at your option any later version) or a standard commercial license. For our users who cannot use wolfSSL under GPLv2 (or any later version), a commercial license to wolfSSL and wolfCrypt is available. + +See the LICENSE.txt, visit wolfssl.com/license, contact us at licensing@wolfssl.com or call +1 425 245 8247 + +View Commercial Support Options: [wolfssl.com/products/support-and-maintenance](wolfssl.com/products/support-and-maintenance) + diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/component.mk index 1008e04af..f94bd617d 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/component.mk @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # @@ -20,7 +20,7 @@ $(info *********** wolfssl component ************) - # +# # Component Makefile # # @@ -66,7 +66,19 @@ CFLAGS +=-DWOLFSSL_USER_SETTINGS # https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples # When this wolfssl component.mk makefile is in [project]/components/wolfssl # The root is 7 directories up from here (the location of of this component.mk): -WOLFSSL_ROOT := ../../../../../../.. +# +WOLFSSL_ROOT ?= ../../../../../../.. +THIS_DIR := $(shell pwd) +WOLFSSL_ROOT_OBJ := $(THIS_DIR) + +# When running make from commandline or VisualGDB, the current path varies: +ifeq ("$(VISUALGDB_DIR)","") + # current path is typically /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/wolfssl + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL)) +else + # current path is typically /C/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/Debug/wolfssl + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL)) +endif # To set the location of a different location, it is best to use relative paths. # @@ -82,7 +94,7 @@ WOLFSSL_ROOT := ../../../../../../.. # "/mnt/c" is 4 directories up: # 2 for `./test/demo` from where we run `make`, plus # 2 more from the location of `component.mk` located -# in `[currect directory]/components/wolfssl`. +# in `[current directory]/components/wolfssl`. # # Thus we need 4 parent reference to find the relative path to wolfSSL: # WOLFSSL_ROOT := ../../../../workspace/wolfssl-master @@ -92,14 +104,16 @@ WOLFSSL_ROOT := ../../../../../../.. # CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt # CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif -abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) +abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) # print-wolfssl-path-value: # @echo "WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)" # @echo "WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)" -$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) -$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info THIS_DIR defined: $(THIS_DIR)) +$(info WOLFSSL_ROOT_OBJ defined: $(WOLFSSL_ROOT_OBJ)) # NOTE: The wolfSSL include directory (e.g. user_settings.h) is # located HERE in THIS project, and *not* in the wolfSSL root. @@ -109,6 +123,7 @@ COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/. COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif + # COMPONENT_ADD_INCLUDEDIRS += $ENV(IDF_PATH)/components/freertos/include/freertos # COMPONENT_ADD_INCLUDEDIRS += "$ENV(IDF_PATH)/soc/esp32s3/include/soc" @@ -122,27 +137,27 @@ COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/atmel -COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT)/wolfcrypt/src/aes_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/evp.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/misc.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/sha512_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_x25519_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/aes_gcm_x86_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/src/bio.o - +COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/evp.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/misc.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/sha512_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/fe_x25519_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_gcm_x86_asm.o ## ## wolfSSL ## -COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o -# COMPONENT_OBJS += src/conf.o +## reminder object files may end up in `./build` or `build/debug` or `build/release`, depending on build environment & settings. +## +# COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o # part of ssl.c, omitted to avoid "does not need to be compiled separately" +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/conf.o # part of ssl.c COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/crl.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls13.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/internal.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/keys.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ocsp.o -# COMPONENT_OBJS += src/pk.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/pk.o # part of ssl.c COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/quic.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/sniffer.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o @@ -154,8 +169,8 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls13.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/wolfio.o -# COMPONENT_OBJS += src/x509.o -# COMPONENT_OBJS += src/x509_str.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509.o # part of ssl.c +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509_str.o # part of ssl.c ## ## wolfcrypt @@ -188,7 +203,7 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ed25519.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ed448.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/error.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/evp.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_kyber.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_mlkem.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_lms.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_xmss.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/falcon.o @@ -251,8 +266,8 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/srp.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/tfm.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_dsp.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_encrypt.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_kyber.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_kyber_poly.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_mlkem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_mlkem_poly.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_lms.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_pkcs11.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_port.o @@ -276,21 +291,16 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_wifi_lib. ## ## wolfcrypt benchmark (optional) ## -## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark ## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark ## ## wolfcrypt test (optional) ## -## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test - -## -## wolfcrypt -## -## COMPONENT_PRIV_INCLUDEDIRS += $(PROJECT_PATH)/components/wolfssl/include -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test +## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test/include $(info ********** end wolfssl component **********) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/include/user_settings.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/include/user_settings.h index 325e54b6a..8da276d1e 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/include/user_settings.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/include/user_settings.h @@ -1,6 +1,6 @@ -/* user_settings.h +/* wolfssl-component include/user_settings.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -18,21 +18,202 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ +#define WOLFSSL_ESPIDF_COMPONENT_VERSION 0x01 -/* Standardized wolfSSL Espressif ESP32 + ESP8266 user_settings.h V5.6.6-01 */ - -/* This user_settings.h is for Espressif ESP-IDF */ +/* Examples such as test and benchmark are known to cause watchdog timeouts. + * Note this is often set in project Makefile: + * CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 */ +#define WOLFSSL_ESP_NO_WATCHDOG 1 +/* The Espressif project config file. See also sdkconfig.defaults */ #include "sdkconfig.h" -/* #define DEBUG_WOLFSSL */ -/* #define DEBUG_WOLFSSL_VERBOSE */ +/* This user_settings.h is for Espressif ESP-IDF + * + * Standardized wolfSSL Espressif ESP32 + ESP8266 user_settings.h V5.7.0-1 + * + * Do not include any wolfssl headers here. + * + * When editing this file: + * ensure all examples match. The template example is the reference. + */ + +/* Naming convention: (see also esp32-crypt.h for the reference source). + * + * CONFIG_ + * This prefix indicates the setting came from the sdkconfig / Kconfig. + * + * May or may not be related to wolfSSL. + * + * The name after this prefix must exactly match that in the Kconfig file. + * + * WOLFSSL_ + * Typical of many, but not all wolfSSL macro names. + * + * Applies to all wolfSSL products such as wolfSSH, wolfMQTT, etc. + * + * May or may not have a corresponding sdkconfig / Kconfig control. + * + * ESP_WOLFSSL_ + * These are NOT valid wolfSSL macro names. These are names only used in + * the ESP-IDF Kconfig files. When parsed, they will have a "CONFIG_" + * suffix added. See next section. + * + * CONFIG_ESP_WOLFSSL_ + * This is a wolfSSL-specific macro that has been defined in the ESP-IDF + * via the sdkconfig / menuconfig. Any text after this prefix should + * exactly match an existing wolfSSL macro name. + * + * Applies to all wolfSSL products such as wolfSSH, wolfMQTT, etc. + * + * These macros may also be specific to only the project or environment, + * and possibly not used anywhere else in the wolfSSL libraries. + */ + +/* The Espressif sdkconfig will have chipset info. +** +** Some possible values: +** +** CONFIG_IDF_TARGET_ESP32 +** CONFIG_IDF_TARGET_ESP32S2 +** CONFIG_IDF_TARGET_ESP32S3 +** CONFIG_IDF_TARGET_ESP32C3 +** CONFIG_IDF_TARGET_ESP32C6 +*/ + +#undef WOLFSSL_ESPIDF +#define WOLFSSL_ESPIDF + +/* Test various user_settings between applications by selecting example apps + * in `idf.py menuconfig` for Example wolfSSL Configuration settings: */ + +/* Turn on messages that are useful to see only in examples. */ +#define WOLFSSL_EXAMPLE_VERBOSITY + +/* Paths can be long, ensure the entire value printed during debug */ +#define WOLFSSL_MAX_ERROR_SZ 500 + +/* wolfSSL Examples: set macros used in example applications. + * + * These Settings NOT available in ESP-IDF (e.g. esp-tls) + * + * Any settings needed by ESP-IDF components should be explicitly set, + * and not by these example-specific settings via CONFIG_WOLFSSL_EXAMPLE_n + * + * ESP-IDF settings should be Kconfig "CONFIG_[name]" values when possible. */ +#if defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TEMPLATE) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/template */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TEST) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_test */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ + #define TEST_ESPIDF_ALL_WOLFSSL +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_BENCHMARK) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ + #define WOLFSSL_BENCHMARK_FIXED_UNITS_KB +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_CLIENT) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_client */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_SERVER) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_server */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfSSH Examples */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSH_TEMPLATE) + /* See https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples/wolfssh_template */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSH_ECHOSERVER) + /* See https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_ESP32_SSH_SERVER) + /* See https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif/ESP32/ESP32-SSH-Server */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_ESP8266_SSH_SERVER) + /* See https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif/ESP8266/ESP8266-SSH-Server */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfMQTT Examples */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFMQTT_TEMPLATE) + /* See https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples/wolfmqtt_template */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFMQTT_AWS_IOT_MQTT) + /* See https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples/AWS_IoT_MQTT */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfTPM Examples */ +#elif defined(CONFIG_WOLFTPM_EXAMPLE_NAME_ESPRESSIF) + /* See https://github.com/wolfSSL/wolfTPM/tree/master/IDE/Espressif */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* Apple HomeKit Examples */ +#elif defined(CONFIG_WOLFSSL_APPLE_HOMEKIT) + /* See https://github.com/AchimPieters/esp32-homekit-demo */ + +/* no example selected */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_NONE) + /* We'll assume the app needs to use wolfSSL sdk lib function */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* Other applications detected by cmake */ +#elif defined(APP_ESP_HTTP_CLIENT_EXAMPLE) + /* The wolfSSL Version of the client example */ + #if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C2) + /* Less memory available, so smaller key sizes: */ + #define FP_MAX_BITS (4096 * 2) + #else + #define FP_MAX_BITS (8192 * 2) + #endif + #define HAVE_ALPN + #define HAVE_SNI + #define OPENSSL_EXTRA_X509_SMALL + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES + #define OPENSSL_EXTRA + #ifndef WOLFSSL_ALWAYS_VERIFY_CB + #define WOLFSSL_ALWAYS_VERIFY_CB + #endif + #ifndef WOLFSSL_VERIFY_CB_ALL_CERTS + #define WOLFSSL_VERIFY_CB_ALL_CERTS + #endif + #ifndef KEEP_PEER_CERT + #define KEEP_PEER_CERT + #endif + +#elif defined(APP_ESP_HTTP_CLIENT) + /* The ESP-IDF Version */ + #define FP_MAX_BITS (8192 * 2) + #define HAVE_ALPN + #define HAVE_SNI + #define OPENSSL_EXTRA_X509_SMALL + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES + #define OPENSSL_EXTRA + #ifndef WOLFSSL_ALWAYS_VERIFY_CB + #define WOLFSSL_ALWAYS_VERIFY_CB + #endif + #ifndef WOLFSSL_VERIFY_CB_ALL_CERTS + #define WOLFSSL_VERIFY_CB_ALL_CERTS + #endif + #ifndef KEEP_PEER_CERT + #define KEEP_PEER_CERT + #endif +#else + #ifdef WOLFSSL_ESPIDF + /* #warning "App config undetected" */ + #endif + /* the code is older or does not have application name defined. */ +#endif /* Example wolfSSL Configuration app settings */ /* Experimental Kyber */ -#if 0 +#ifdef CONFIG_WOLFSSL_ENABLE_KYBER + /* Kyber typically needs a minimum 10K stack */ #define WOLFSSL_EXPERIMENTAL_SETTINGS - #define WOLFSSL_HAVE_KYBER - #define WOLFSSL_WC_KYBER + #define WOLFSSL_HAVE_MLKEM + #define WOLFSSL_WC_MLKEM #define WOLFSSL_SHA3 #if defined(CONFIG_IDF_TARGET_ESP8266) /* With limited RAM, we'll disable some of the Kyber sizes: */ @@ -42,6 +223,17 @@ #endif #endif +/* Enable AES for all examples */ +#ifdef NO_AES + #warning "Found NO_AES, wolfSSL AES Cannot be enabled. Check config." +#else + #define WOLFSSL_AES + #define WOLFSSL_AES_COUNTER + + /* Typically only needed for wolfssl_test, see docs. */ + #define WOLFSSL_AES_DIRECT +#endif + /* Pick a cert buffer size: */ /* #define USE_CERT_BUFFERS_2048 */ /* #define USE_CERT_BUFFERS_1024 */ @@ -58,14 +250,76 @@ ** CONFIG_IDF_TARGET_ESP32C6 */ -#undef WOLFSSL_ESPIDF -#define WOLFSSL_ESPIDF +/* Optionally enable Apple HomeKit from compiler directive or Kconfig setting */ +#if defined(WOLFSSL_APPLE_HOMEKIT) || defined(CONFIG_WOLFSSL_APPLE_HOMEKIT) + /* SRP is known to need 8K; slow on some devices */ + #define FP_MAX_BITS (8192 * 2) + #define WOLFCRYPT_HAVE_SRP + #define HAVE_CHACHA + #define HAVE_POLY1305 + #define WOLFSSL_BASE64_ENCODE + #endif /* Apple HomeKit settings */ -/* We don't use WiFi helpers yet, so don't compile in the esp-sdk-lib WiFi */ -#define NO_ESP_SDK_WIFI +/* Used by ESP-IDF components: */ +#if defined(CONFIG_ESP_TLS_USING_WOLFSSL) + /* The ESP-TLS */ + #ifndef FP_MAX_BITS + #if defined(CONFIG_IDF_TARGET_ESP32C2) || \ + defined(CONFIG_IDF_TARGET_ESP8684) || \ + defined(CONFIG_IDF_TARGET_ESP8266) + /* Optionally set smaller size here */ + #define FP_MAX_BITS MIN_FFDHE_FP_MAX_BITS + #else + #define FP_MAX_BITS (4096 * 2) + #endif + #endif + #define HAVE_ALPN + #ifndef CONFIG_IDF_TARGET_ESP8266 + /* Unless installed in the ESP8266 RTOS SDK locally, the wolfSSL + * API for SNI will not be seen in the components/esp-tls layer. + * Only enable SNI for non-ESP8266 targets by default: */ + #define HAVE_SNI + #endif + #define OPENSSL_EXTRA_X509_SMALL + + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES +#endif + +/* Optionally enable some wolfSSH settings */ +#if defined(ESP_ENABLE_WOLFSSH) || defined(CONFIG_ESP_ENABLE_WOLFSSH) + /* Enable wolfSSH. Espressif examples need a few more settings, below */ + #undef WOLFSSL_WOLFSSH + #define WOLFSSL_WOLFSSH + + /* The default SSH Windows size is massive for an embedded target. + * Limit it: */ + #define DEFAULT_WINDOW_SZ 2000 + + /* These may be defined in cmake for other examples: */ + #undef WOLFSSH_TERM + #define WOLFSSH_TERM + + /* optional debug */ + /* #undef DEBUG_WOLFSSH */ + /* #define DEBUG_WOLFSSH */ + + #undef WOLFSSL_KEY_GEN + #define WOLFSSL_KEY_GEN + + #undef WOLFSSL_PTHREADS + #define WOLFSSL_PTHREADS + + #define WOLFSSH_TEST_SERVER + #define WOLFSSH_TEST_THREADING +#endif /* ESP_ENABLE_WOLFSSH */ + + +/* Not yet using WiFi lib, so don't compile in the esp-sdk-lib WiFi helpers: */ +/* #define USE_WOLFSSL_ESP_SDK_WIFI */ /* - * ONE of these Espressif chipsets should be defined: + * ONE of these Espressif chip families will be detected from sdkconfig: * * WOLFSSL_ESP32 * WOLFSSL_ESPWROOM32SE @@ -84,11 +338,28 @@ #endif /* See below for chipset detection from sdkconfig.h */ +/* when you want to use SINGLE THREAD. Note Default ESP-IDF is FreeRTOS */ +#define SINGLE_THREADED + /* Small session cache saves a lot of RAM for ClientCache and SessionCache. * Memory requirement is about 5KB, otherwise 20K is needed when not specified. * If extra small footprint is needed, try MICRO_SESSION_CACHE (< 1K) - * When really desperate, try NO_SESSION_CACHE. */ -#define MICRO_SESSION_CACHE + * When really desperate or no TLS used, try NO_SESSION_CACHE. */ +#define NO_SESSION_CACHE + +/* Small Stack uses more heap. */ +#define WOLFSSL_SMALL_STACK + +/* Full debugging turned off, but show malloc failure detail */ +/* #define DEBUG_WOLFSSL */ +#define DEBUG_WOLFSSL_MALLOC + +/* See test.c that sets cert buffers; we'll set them here: */ +#define USE_CERT_BUFFERS_256 +#define USE_CERT_BUFFERS_2048 + +/* RSA_LOW_MEM: Half as much memory but twice as slow. */ +#define RSA_LOW_MEM /* optionally turn off SHA512/224 SHA512/256 */ /* #define WOLFSSL_NOSHA512_224 */ @@ -103,19 +374,44 @@ #define BENCH_EMBEDDED -#define WOLFSSL_SMALL_STACK -#define HAVE_ECC -#define RSA_LOW_MEM - /* TLS 1.3 */ -#define WOLFSSL_TLS13 -#define HAVE_TLS_EXTENSIONS -#define WC_RSA_PSS -#define HAVE_HKDF -#define HAVE_AEAD -#define HAVE_SUPPORTED_CURVES +#ifdef CONFIG_WOLFSSL_ALLOW_TLS13 + #define WOLFSSL_TLS13 + #define HAVE_TLS_EXTENSIONS + #define HAVE_HKDF -#define WOLFSSL_BENCHMARK_FIXED_UNITS_KB + /* May be required */ + #ifndef HAVE_AEAD + #endif + + /* Required for ECC */ + #define HAVE_SUPPORTED_CURVES + + /* Required for RSA */ + #define WC_RSA_PSS + + /* TLS 1.3 normally requires HAVE_FFDHE */ + #if defined(HAVE_FFDHE_2048) || \ + defined(HAVE_FFDHE_3072) || \ + defined(HAVE_FFDHE_4096) || \ + defined(HAVE_FFDHE_6144) || \ + defined(HAVE_FFDHE_8192) + #else + #define HAVE_FFDHE_2048 + /* #error "TLS 1.3 requires HAVE_FFDHE_[nnnn]" */ + #endif +#endif + +#if defined(CONFIG_IDF_TARGET_ESP32C2) || \ + defined(CONFIG_IDF_TARGET_ESP8684) + /* Optionally set smaller size here */ + #ifdef HAVE_FFDHE_4096 + /* this size may be problematic on the C2 */ + #endif + #define HAVE_FFDHE_2048 +#else + #define HAVE_FFDHE_4096 +#endif #define NO_FILESYSTEM @@ -132,30 +428,72 @@ /* when you want to use SHA384 */ #define WOLFSSL_SHA384 -#if defined(CONFIG_IDF_TARGET_ESP8266) +/* Some features not enabled for ESP8266: */ +#if defined(CONFIG_IDF_TARGET_ESP8266) || \ + defined(CONFIG_IDF_TARGET_ESP32C2) /* Some known low-memory devices have features not enabled by default. */ + /* TODO determine low memory configuration for ECC. */ #else /* when you want to use SHA512 */ #define WOLFSSL_SHA512 /* when you want to use SHA3 */ - #define WOLFSSL_SHA3 + /* #define WOLFSSL_SHA3 */ /* ED25519 requires SHA512 */ #define HAVE_ED25519 +#endif - #define HAVE_ECC - #define HAVE_CURVE25519 - #define CURVE25519_SMALL - #define HAVE_ED25519 +#if defined(CONFIG_IDF_TARGET_ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C2) + #define MY_USE_ECC 0 + #define MY_USE_RSA 1 +#else + #define MY_USE_ECC 1 + #define MY_USE_RSA 0 +#endif + +/* We can use either or both ECC and RSA, but must use at least one. */ +#if MY_USE_ECC || MY_USE_RSA + #if MY_USE_ECC + /* ---- ECDSA / ECC ---- */ + #define HAVE_ECC + #define HAVE_CURVE25519 + #define HAVE_ED25519 + #define WOLFSSL_SHA512 + /* + #define HAVE_ECC384 + #define CURVE25519_SMALL + */ + #else + #define WOLFSSH_NO_ECC + /* WOLFSSH_NO_ECDSA is typically defined automatically, + * here for clarity: */ + #define WOLFSSH_NO_ECDSA + #endif + + #if MY_USE_RSA + /* ---- RSA ----- */ + /* #define RSA_LOW_MEM */ + + /* DH disabled by default, needed if ECDSA/ECC also turned off */ + #define HAVE_DH + #else + #define WOLFSSH_NO_RSA + #endif +#else + #error "Either RSA or ECC must be enabled" #endif /* Optional OpenSSL compatibility */ /* #define OPENSSL_EXTRA */ -/* when you want to use pkcs7 */ +/* #Optional HAVE_PKCS7 */ /* #define HAVE_PKCS7 */ + #if defined(HAVE_PKCS7) + /* HAVE_PKCS7 may enable HAVE_PBKDF2 see settings.h */ + #define NO_PBKDF2 + #define HAVE_AES_KEYWRAP #define HAVE_X963_KDF #define WOLFSSL_AES_DIRECT @@ -175,25 +513,11 @@ /* #define CUSTOM_SLOT_ALLOCATION */ #endif -/* RSA primitive specific definition */ -#if defined(WOLFSSL_ESP32) || defined(WOLFSSL_ESPWROOM32SE) - /* Define USE_FAST_MATH and SMALL_STACK */ - #define ESP32_USE_RSA_PRIMITIVE +/* WC_NO_CACHE_RESISTANT: slower but more secure */ +/* #define WC_NO_CACHE_RESISTANT */ - #if defined(CONFIG_IDF_TARGET_ESP32) - - /* NOTE HW unreliable for small values! */ - /* threshold for performance adjustment for HW primitive use */ - /* X bits of G^X mod P greater than */ - #undef ESP_RSA_EXPT_XBITS - #define ESP_RSA_EXPT_XBITS 32 - - /* X and Y of X * Y mod P greater than */ - #undef ESP_RSA_MULM_BITS - #define ESP_RSA_MULM_BITS 16 - - #endif -#endif +/* TFM_TIMING_RESISTANT: slower but more secure */ +/* #define TFM_TIMING_RESISTANT */ /* #define WOLFSSL_ATECC508A_DEBUG */ @@ -204,23 +528,40 @@ /* #define XTIME time */ -/* adjust wait-timeout count if you see timeout in RSA HW acceleration */ -#define ESP_RSA_TIMEOUT_CNT 0x249F00 +/* Adjust wait-timeout count if you see timeout in RSA HW acceleration. + * Set to very large number and enable WOLFSSL_HW_METRICS to determine max. */ +#ifndef ESP_RSA_TIMEOUT_CNT + #define ESP_RSA_TIMEOUT_CNT 0xFF0000 +#endif -#define HASH_SIZE_LIMIT /* for test.c */ +/* hash limit for test.c */ +#define HASH_SIZE_LIMIT /* USE_FAST_MATH is default */ #define USE_FAST_MATH /***** Use SP_MATH *****/ -/* #undef USE_FAST_MATH */ +/* #undef USE_FAST_MATH */ /* #define SP_MATH */ /* #define WOLFSSL_SP_MATH_ALL */ +/* #define WOLFSSL_SP_RISCV32 */ /***** Use Integer Heap Math *****/ /* #undef USE_FAST_MATH */ /* #define USE_INTEGER_HEAP_MATH */ +/* Just syntax highlighting to check math libraries: */ +#if defined(SP_MATH) || \ + defined(USE_INTEGER_HEAP_MATH) || \ + defined(USE_INTEGER_HEAP_MATH) || \ + defined(USE_FAST_MATH) || \ + defined(WOLFSSL_SP_MATH_ALL) || \ + defined(WOLFSSL_SP_RISCV32) +#endif + +#define WOLFSSL_SMALL_STACK + + #define HAVE_VERSION_EXTENDED_INFO /* #define HAVE_WC_INTROSPECTION */ @@ -230,13 +571,26 @@ /* #define HAVE_HASHDRBG */ +#if 0 +/* Example for additional cert functions */ #define WOLFSSL_KEY_GEN -#define WOLFSSL_CERT_REQ -#define WOLFSSL_CERT_GEN -#define WOLFSSL_CERT_EXT -#define WOLFSSL_SYS_CA_CERTS + #define WOLFSSL_CERT_REQ + #define WOLFSSL_CERT_GEN + #define WOLFSSL_CERT_EXT + #define WOLFSSL_SYS_CA_CERTS -#define WOLFSSL_CERT_TEXT + + #define WOLFSSL_CERT_TEXT + + /* command-line options + --enable-keygen + --enable-certgen + --enable-certreq + --enable-certext + --enable-asn-template + */ + +#endif #define WOLFSSL_ASN_TEMPLATE @@ -256,11 +610,66 @@ --enable-asn-template */ +/* optional SM4 Ciphers. See https://github.com/wolfSSL/wolfsm */ +/* +#define WOLFSSL_SM2 +#define WOLFSSL_SM3 +#define WOLFSSL_SM4 +*/ + +#if defined(WOLFSSL_SM2) || defined(WOLFSSL_SM3) || defined(WOLFSSL_SM4) + /* SM settings, possible cipher suites: + + TLS13-AES128-GCM-SHA256 + TLS13-CHACHA20-POLY1305-SHA256 + TLS13-SM4-GCM-SM3 + TLS13-SM4-CCM-SM3 + + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-CCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CBC-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-GCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3:" \ + "TLS13-SM4-CCM-SM3:" + */ + + #undef WOLFSSL_BASE16 + #define WOLFSSL_BASE16 /* required for WOLFSSL_SM2 */ + + #undef WOLFSSL_SM4_ECB + #define WOLFSSL_SM4_ECB + + #undef WOLFSSL_SM4_CBC + #define WOLFSSL_SM4_CBC + + #undef WOLFSSL_SM4_CTR + #define WOLFSSL_SM4_CTR + + #undef WOLFSSL_SM4_GCM + #define WOLFSSL_SM4_GCM + + #undef WOLFSSL_SM4_CCM + #define WOLFSSL_SM4_CCM + + #define HAVE_POLY1305 + #define HAVE_CHACHA + + #undef HAVE_AESGCM + #define HAVE_AESGCM +#else + /* default settings */ + #define USE_CERT_BUFFERS_2048 +#endif + /* Chipset detection from sdkconfig.h * Default is HW enabled unless turned off. * Uncomment lines to force SW instead of HW acceleration */ -#if defined(CONFIG_IDF_TARGET_ESP32) +#if defined(CONFIG_IDF_TARGET_ESP32) || defined(WOLFSSL_ESPWROOM32SE) #define WOLFSSL_ESP32 + /* Alternatively, if there's an ECC Secure Element present: */ + /* #define WOLFSSL_ESPWROOM32SE */ + /* wolfSSL HW Acceleration supported on ESP32. Uncomment to disable: */ /* #define NO_ESP32_CRYPT */ /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ @@ -378,12 +787,16 @@ #define WOLFSSL_ESP8266 /* There's no hardware encryption on the ESP8266 */ - /* Consider using the ESP32-C2/C3/C6 - * See https://www.espressif.com/en/products/socs/esp32-c2 */ + /* Consider using the ESP32-C2/C3/C6 */ #define NO_ESP32_CRYPT #define NO_WOLFSSL_ESP32_CRYPT_HASH #define NO_WOLFSSL_ESP32_CRYPT_AES #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI + #ifndef FP_MAX_BITS + /* FP_MAX_BITS matters in wolfssl_test, not just TLS setting. */ + /* MIN_FFDHE_FP_MAX_BITS = (MIN_FFDHE_BITS * 2); see settings.h */ + #define FP_MAX_BITS MIN_FFDHE_FP_MAX_BITS + #endif /***** END CONFIG_IDF_TARGET_ESP266 *****/ #elif defined(CONFIG_IDF_TARGET_ESP8684) @@ -395,7 +808,7 @@ /***** END CONFIG_IDF_TARGET_ESP8684 *****/ #else - /* Anything else encountered, disable HW accleration */ + /* Anything else encountered, disable HW acceleration */ #warning "Unexpected CONFIG_IDF_TARGET_NN value" #define NO_ESP32_CRYPT #define NO_WOLFSSL_ESP32_CRYPT_HASH @@ -403,29 +816,84 @@ #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI #endif /* CONFIG_IDF_TARGET Check */ +/* RSA primitive specific definition, listed AFTER the Chipset detection */ +#if defined(WOLFSSL_ESP32) || defined(WOLFSSL_ESPWROOM32SE) + /* Consider USE_FAST_MATH and SMALL_STACK */ + + #ifndef NO_RSA + #define ESP32_USE_RSA_PRIMITIVE + + #if defined(CONFIG_IDF_TARGET_ESP32) + #ifdef CONFIG_ESP_MAIN_TASK_STACK_SIZE + #if CONFIG_ESP_MAIN_TASK_STACK_SIZE < 10500 + #warning "RSA may be difficult with less than 10KB Stack "/ + #endif + #endif + + /* NOTE HW unreliable for small values! */ + /* threshold for performance adjustment for HW primitive use */ + /* X bits of G^X mod P greater than */ + #undef ESP_RSA_EXPT_XBITS + #define ESP_RSA_EXPT_XBITS 32 + + /* X and Y of X * Y mod P greater than */ + #undef ESP_RSA_MULM_BITS + #define ESP_RSA_MULM_BITS 16 + #endif + #endif +#endif + /* Debug options: See wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h for details on debug options +optionally increase error message size for very long paths. +#define WOLFSSL_MAX_ERROR_SZ 500 + +Turn wolfSSL debugging on/off: + wolfSSL_Debugging_ON(); + wolfSSL_Debugging_OFF(); + #define ESP_VERIFY_MEMBLOCK #define DEBUG_WOLFSSL #define DEBUG_WOLFSSL_VERBOSE #define DEBUG_WOLFSSL_SHA_MUTEX +#define WOLFSSL_DEBUG_IGNORE_ASN_TIME +#define WOLFSSL_DEBUG_CERT_BUNDLE +#define WOLFSSL_DEBUG_CERT_BUNDLE_NAME #define WOLFSSL_ESP32_CRYPT_DEBUG #define WOLFSSL_ESP32_CRYPT_HASH_SHA224_DEBUG #define NO_RECOVER_SOFTWARE_CALC #define WOLFSSL_TEST_STRAY 1 #define USE_ESP_DPORT_ACCESS_READ_BUFFER #define WOLFSSL_ESP32_HW_LOCK_DEBUG +#define WOLFSSL_DEBUG_MUTEX #define WOLFSSL_DEBUG_ESP_RSA_MULM_BITS +#define WOLFSSL_DEBUG_ESP_HW_MOD_RSAMAX_BITS +#define WOLFSSL_DEBUG_ESP_HW_MULTI_RSAMAX_BITS #define ESP_DISABLE_HW_TASK_LOCK +#define ESP_MONITOR_HW_TASK_LOCK +#define USE_ESP_DPORT_ACCESS_READ_BUFFER + +See wolfcrypt/benchmark/benchmark.c for debug and other settings: + +Turn on benchmark timing debugging (CPU Cycles, RTOS ticks, etc) +#define DEBUG_WOLFSSL_BENCHMARK_TIMING + +Turn on timer debugging (used when CPU cycles not available) +#define WOLFSSL_BENCHMARK_TIMER_DEBUG */ -#define WOLFSSL_ESPIDF_ERROR_PAUSE /* Pause in a loop rather than exit. */ +/* Pause in a loop rather than exit. */ +/* #define WOLFSSL_ESPIDF_ERROR_PAUSE */ +/* #define WOLFSSL_ESP32_HW_LOCK_DEBUG */ + #define WOLFSSL_HW_METRICS -/* #define HASH_SIZE_LIMIT */ /* for test.c */ +/* for test.c */ +/* #define HASH_SIZE_LIMIT */ -/* #define NO_HW_MATH_TEST */ /* Optionally turn off HW math checks */ +/* Optionally turn off HW math checks */ +/* #define NO_HW_MATH_TEST */ /* Optionally include alternate HW test library: alt_hw_test.h */ /* When enabling, the ./components/wolfssl/CMakeLists.txt file @@ -466,6 +934,12 @@ See wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h for details on debug options * There are various certificate examples in this header file: * https://github.com/wolfSSL/wolfssl/blob/master/wolfssl/certs_test.h * + * To use the sample certificates in code (not recommended for production!): + * + * #if defined(USE_CERT_BUFFERS_2048) || defined(USE_CERT_BUFFERS_1024) + * #include + * #endif + * * To use the sets of macros below, define *one* of these: * * USE_CERT_BUFFERS_1024 - ECC 1024 bit encoded ASN1 @@ -543,6 +1017,9 @@ See wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h for details on debug options #define WOLFSSL_BASE16 #else #if defined(USE_CERT_BUFFERS_2048) + #define USE_CERT_BUFFERS_256 + /* 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 #define CTX_CA_CERT_TYPE WOLFSSL_FILETYPE_ASN1 @@ -562,6 +1039,9 @@ See wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h for details on debug options #define CTX_CLIENT_KEY_TYPE WOLFSSL_FILETYPE_ASN1 #elif defined(USE_CERT_BUFFERS_1024) + #define USE_CERT_BUFFERS_256 + /* 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 #define CTX_CA_CERT_TYPE WOLFSSL_FILETYPE_ASN1 @@ -584,3 +1064,34 @@ See wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h for details on debug options #error "Must define USE_CERT_BUFFERS_2048 or USE_CERT_BUFFERS_1024" #endif #endif /* Conditional key and cert constant names */ + +/****************************************************************************** +** Sanity Checks +******************************************************************************/ +#if defined(CONFIG_ESP_MAIN_TASK_STACK_SIZE) + #if defined(WOLFCRYPT_HAVE_SRP) + #if defined(FP_MAX_BITS) + #if FP_MAX_BITS < (8192 * 2) + #define ESP_SRP_MINIMUM_STACK_8K (24 * 1024) + #else + #define ESP_SRP_MINIMUM_STACK_8K (28 * 1024) + #endif + #else + #error "Please define FP_MAX_BITS when using WOLFCRYPT_HAVE_SRP." + #endif + + #if (CONFIG_ESP_MAIN_TASK_STACK_SIZE < ESP_SRP_MINIMUM_STACK) + #warning "WOLFCRYPT_HAVE_SRP enabled with small stack size" + #endif + #endif +#else + #warning "CONFIG_ESP_MAIN_TASK_STACK_SIZE not defined!" +#endif +/* See settings.h for some of the possible hardening options: + * + * #define NO_ESPIDF_DEFAULT + * #define WC_NO_CACHE_RESISTANT + * #define WC_AES_BITSLICED + * #define HAVE_AES_ECB + * #define HAVE_AES_DIRECT + */ diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/CMakeLists.txt index 621eb8702..80a89c25a 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/CMakeLists.txt @@ -1,35 +1,43 @@ # wolfSSL Espressif Example Project/main CMakeLists.txt -# v1.0 +# v1.2 # # wolfssl client test # +message(STATUS "Begin wolfSSL main CMakeLists.txt") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + # `driver` component not available for ESP8266 + SET(THIS_PRIV_REQUIRES_DRIVER "") +else() + SET(THIS_PRIV_REQUIRES_DRIVER "driver") +endif() + if(WIN32) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") - message("Detected Windows") + message(STATUS "Detected Windows") endif() if(CMAKE_HOST_UNIX) - message("Detected UNIX") + message(STATUS "Detected UNIX") endif() if(APPLE) - message("Detected APPLE") + message(STATUS "Detected APPLE") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") - message("Detected WSL") + message(STATUS "Detected WSL") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") - message("Detected Linux") + message(STATUS "Detected Linux") endif() if(APPLE) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") - message("Detected Apple") + message(STATUS "Detected Apple") endif() set (git_cmd "git") @@ -43,14 +51,26 @@ if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl/" AND EXISTS "$ENV{IDF_PA set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING") endif() +# The wolfSL component name is named "mywolfssl" on the staging site for Managed Components. +if( NOT EXISTS "../components/wolfssl" AND ("$ENV{IDF_COMPONENT_REGISTRY_URL}" STREQUAL "https://components-staging.espressif.com") ) + message(STATUS "WARNING: Using a staging instance of wolfssl.") + set(MAIN_WOLFSSL_COMPONENT_NAME "mywolfssl") +else() + message(STATUS "Using release wolfssl component.") + set(MAIN_WOLFSSL_COMPONENT_NAME "wolfssl") +endif() + ## register_component() idf_component_register(SRCS main.c wifi_connect.c time_helper.c client-tls.c INCLUDE_DIRS "." - "./include") -# + "./include" + PRIV_REQUIRES "${MAIN_WOLFSSL_COMPONENT_NAME}" + "${THIS_PRIV_REQUIRES_DRIVER}" + nvs_flash + protocol_examples_common) # # LIBWOLFSSL_SAVE_INFO(VAR_OUPUT THIS_VAR VAR_RESULT) @@ -80,15 +100,24 @@ function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) message(STATUS "Found ${VAR_OUPUT}=${VAR_VALUE}") # the interesting part is defining the VAR_OUPUT name a value to use in the app - add_definitions(-D${VAR_OUPUT}=\"${VAR_VALUE}\") + add_compile_definitions(${VAR_OUPUT}=\"${VAR_VALUE}\") else() # if we get here, check the execute_process command and parameters. - message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT") + message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT.") + message(STATUS "Setting ${VAR_OUPUT} to \"Unknown\"") set(${VAR_OUPUT} "Unknown") endif() endfunction() # LIBWOLFSSL_SAVE_INFO -if(NOT CMAKE_BUILD_EARLY_EXPANSION) +execute_process( + COMMAND ${git_cmd} "rev-parse" "--is-inside-work-tree" + OUTPUT_VARIABLE IS_GIT_REPO + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + +# Save some project-specific details. Repo may be different than component, or may not even be a repo at all: +if(NOT CMAKE_BUILD_EARLY_EXPANSION AND (IS_GIT_REPO STREQUAL "true")) # LIBWOLFSSL_VERSION_GIT_HASH execute_process(COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") @@ -104,3 +133,4 @@ endif() message(STATUS "") +message(STATUS "End wolfSSL main CMakeLists.txt") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/Kconfig.projbuild b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/Kconfig.projbuild index 83dcd6439..06cc01df8 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/Kconfig.projbuild +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/Kconfig.projbuild @@ -1,4 +1,101 @@ -menu "Example Configuration" +# Kconfig main +# +# Copyright (C) 2006-2025 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 +# + +# Kconfig File Version 5.7.2.001 for wolfssl_template + +menu "Example wolfSSL Configuration" + +choice WOLFSSL_EXAMPLE_CHOOSE + prompt "Choose Example (See wolfssl/include/user_settings.h)" + default WOLFSSL_EXAMPLE_NAME_NONE + help + The user settings file can be adjusted to specific wolfSSL examples. + + config WOLFSSL_EXAMPLE_NAME_TEMPLATE + bool "wolfSSL Template" + help + The sample template app compiles in wolfSSL and prints the current wolfSSL Version. Nothing more. + + config WOLFSSL_EXAMPLE_NAME_TEST + bool "wolfSSL Test" + help + This app tests all cryptographic functions currently enabled. See also Benchmark performance app. + + config WOLFSSL_EXAMPLE_NAME_BENCHMARK + bool "wolfSSL Benchmark" + help + Benchmark performance app. See also cryptographic test. + + config WOLFSSL_EXAMPLE_NAME_TLS_CLIENT + bool "TLS Client" + help + TLS Client Example app. Needs WiFi and a listening server on port 11111. + + config WOLFSSL_EXAMPLE_NAME_TLS_SERVER + bool "TLS Server" + help + TLS Server Example app. Needs WiFi. More interesting with a TLS client using port 11111. + + config WOLFSSL_EXAMPLE_NAME_WOLFSSH_TEMPLATE + bool "SSH Template App" + help + Bare-bones Hello World app that only compiles in wolfSSL and wolfSSH. + See wolfSSL/wolfssh on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFSSH_ECHOSERVER + bool "SSH Echo Server" + help + See wolfSSL/wolfssh on GitHub. + + config WOLFSSL_EXAMPLE_NAME_ESP32_SSH_SERVER + bool "SSH to UART Server for the ESP32" + help + See wolfSSL/wolfssh-examples on GitHub. + + config WOLFSSL_EXAMPLE_NAME_ESP8266_SSH_SERVER + bool "SSH to UART Server for the ESP8266" + help + See wolfSSL/wolfssh-examples on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFMQTT_TEMPLATE + bool "MQTT Template" + help + See wolfSSL/wolfmqtt on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFMQTT_AWS_IOT_MQTT + bool "MQTT AWS IoT" + help + See wolfSSL/wolfmqtt on GitHub. + + config WOLFTPM_EXAMPLE_NAME_ESPRESSIF + bool "TPM Test Example for the ESP32" + help + See wolfSSL/wolfTPM on GitHub. + + config WOLFSSL_EXAMPLE_NAME_NONE + bool "Other" + help + A specific example app is not defined. + +endchoice config WOLFSSL_TARGET_HOST string "Target host" diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c index 638fdf343..9a0bdc2ec 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c @@ -1,6 +1,6 @@ /* client-tls.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -18,6 +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 */ + #include "client-tls.h" /* Espressif FreeRTOS */ @@ -36,11 +37,13 @@ /* wolfSSL */ #include +/* This project not yet using the library */ +#undef USE_WOLFSSL_ESP_SDK_WIFI #include -#if defined(WOLFSSL_WC_KYBER) - #include - #include +#if defined(WOLFSSL_WC_MLKEM) + #include + #include #endif #if defined(USE_CERT_BUFFERS_2048) || defined(USE_CERT_BUFFERS_1024) #include @@ -204,7 +207,6 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args) size_t len; - wolfSSL_Debugging_ON(); WOLFSSL_ENTER(TLS_SMP_CLIENT_TASK_NAME); doPeerCheck = 1; @@ -238,8 +240,8 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args) /* Create and initialize WOLFSSL_CTX */ ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); /* SSL 3.0 - TLS 1.3. */ /* options: */ - /* ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method()); only TLS 1.2 */ - /* ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method()); only TLS 1.3 */ + /* ctx = wolfSSL_CTX_new(wolfSSLv1_2_client_method()); only TLS 1.2 */ + /* ctx = wolfSSL_CTX_new(wolfSSLv1_3_client_method()); only TLS 1.3 */ /* wolfSSL_CTX_NoTicketTLSv12(); */ /* wolfSSL_NoTicketTLSv12(); */ if (ctx == NULL) { @@ -305,11 +307,11 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args) /* no peer check */ if (doPeerCheck == 0) { - ESP_LOGW(TAG, "doPeerCheck == 0"); + ESP_LOGW(TAG, "doPeerCheck == 0; WOLFSSL_VERIFY_NONE"); wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_NONE, 0); } else { - ESP_LOGW(TAG, "doPeerCheck != 0"); + ESP_LOGI(TAG, "doPeerCheck != 0"); WOLFSSL_MSG("Loading... our cert"); /* load our certificate */ ret_i = wolfSSL_CTX_use_certificate_chain_buffer_format(ctx, @@ -395,22 +397,22 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args) ESP_LOGI(TAG, "tls_smp_client_task heap @ %p = %d", &this_heap, this_heap); #endif -#if defined(WOLFSSL_HAVE_KYBER) +#if defined(WOLFSSL_HAVE_MLKEM) #if defined(WOLFSSL_KYBER1024) - ESP_LOGI(TAG, "WOLFSSL_HAVE_KYBER is enabled, setting key share: " + ESP_LOGI(TAG, "WOLFSSL_HAVE_MLKEM is enabled, setting key share: " "WOLFSSL_P256_KYBER_LEVEL5"); ret_i = wolfSSL_UseKeyShare(ssl, WOLFSSL_P521_KYBER_LEVEL5); #elif defined(WOLFSSL_KYBER768) - ESP_LOGI(TAG, "WOLFSSL_HAVE_KYBER is enabled, setting key share: " + ESP_LOGI(TAG, "WOLFSSL_HAVE_MLKEM is enabled, setting key share: " "WOLFSSL_P256_KYBER_LEVEL3"); ret_i = wolfSSL_UseKeyShare(ssl, WOLFSSL_P256_KYBER_LEVEL3); #elif defined(WOLFSSL_KYBER512) /* This will typically be a low memory situation, such as ESP8266 */ - ESP_LOGI(TAG, "WOLFSSL_HAVE_KYBER is enabled, setting key share: " + ESP_LOGI(TAG, "WOLFSSL_HAVE_MLKEM is enabled, setting key share: " "WOLFSSL_P256_KYBER_LEVEL1"); ret_i = wolfSSL_UseKeyShare(ssl, WOLFSSL_P256_KYBER_LEVEL1); #else - ESP_LOGW(TAG, "WOLFSSL_HAVE_KYBER enabled but no key size available."); + ESP_LOGW(TAG, "WOLFSSL_HAVE_MLKEM enabled but no key size available."); ret_i = ESP_FAIL; #endif if (ret_i == WOLFSSL_SUCCESS) { @@ -420,7 +422,7 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args) ESP_LOGE(TAG, "UseKeyShare Kyber failed"); } #else - ESP_LOGI(TAG, "WOLFSSL_HAVE_KYBER is not enabled"); + ESP_LOGI(TAG, "WOLFSSL_HAVE_MLKEM is not enabled"); #endif } @@ -460,6 +462,9 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args) } ESP_LOGI(TAG, "Connect to wolfSSL server..."); + #ifdef DEBUG_WOLFSSL + wolfSSL_Debugging_ON(); + #endif ret_i = wolfSSL_connect(ssl); #ifdef DEBUG_WOLFSSL this_heap = esp_get_free_heap_size(); @@ -570,7 +575,7 @@ WOLFSSL_ESP_TASK tls_smp_client_init(void* args) #else xTaskHandle _handle; #endif - /* See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos_idf.html#functions */ + /* See Espressif api-reference/system/freertos_idf.html#functions */ if (TLS_SMP_CLIENT_TASK_BYTES < (6 * 1024)) { /* Observed approximately 6KB limit for the RTOS task stack size. * Reminder parameter is bytes, not words as with generic FreeRTOS. */ @@ -582,8 +587,7 @@ WOLFSSL_ESP_TASK tls_smp_client_init(void* args) #endif /* Note that despite vanilla FreeRTOS using WORDS for a parameter, - * Espressif uses BYTES for the task stack size here. - * See https://docs.espressif.com/projects/esp-idf/en/v4.3/esp32/api-reference/system/freertos.html */ + * Espressif uses BYTES for the task stack size here. */ ret = xTaskCreate(tls_smp_client_task, TLS_SMP_CLIENT_TASK_NAME, TLS_SMP_CLIENT_TASK_BYTES, diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/client-tls.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/client-tls.h index b016f29a6..5df9f1474 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/client-tls.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/client-tls.h @@ -1,6 +1,6 @@ /* client-tls.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -29,9 +29,9 @@ /* See main/Kconfig.projbuild for default configuration settings */ #ifdef CONFIG_WOLFSSL_TARGET_HOST - #define TLS_SMP_TARGET_HOST "192.168.1.36" + #define TLS_SMP_TARGET_HOST CONFIG_WOLFSSL_TARGET_HOST #else - #define TLS_SMP_TARGET_HOST "192.168.1.41" + #define TLS_SMP_TARGET_HOST "192.168.1.37" #endif #ifdef CONFIG_WOLFSSL_TARGET_PORT @@ -44,7 +44,7 @@ /* Reminder: Vanilla FreeRTOS is words, Espressif is bytes. */ #if defined(WOLFSSL_ESP8266) - #if defined(WOLFSSL_HAVE_KYBER) + #if defined(WOLFSSL_HAVE_MLKEM) /* Minimum ESP8266 stack size = 10K with Kyber. * Note there's a maximum not far away as Kyber needs heap * and the total DRAM is typically only 80KB total. */ @@ -54,12 +54,12 @@ #define TLS_SMP_CLIENT_TASK_BYTES (6 * 1024) #endif #else - #if defined(WOLFSSL_HAVE_KYBER) + #if defined(WOLFSSL_HAVE_MLKEM) /* Minimum ESP32 stack size = 12K with Kyber enabled. */ #define TLS_SMP_CLIENT_TASK_BYTES (12 * 1024) #else /* Minimum ESP32 stack size = 8K without Kyber */ - #define TLS_SMP_CLIENT_TASK_BYTES (8 * 1024) + #define TLS_SMP_CLIENT_TASK_BYTES (10 * 1024) #endif #endif @@ -87,7 +87,7 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args); /* init will create an RTOS task, otherwise server is simply function call. */ #if defined(SINGLE_THREADED) - /* no init neded */ + /* no init needed */ #else WOLFSSL_ESP_TASK tls_smp_client_init(void* args); #endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/main.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/main.h index 12c452d6e..d9ed211e2 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/main.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/main.h @@ -1,6 +1,6 @@ /* wolfssl_client main.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -18,7 +18,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ + #ifndef _MAIN_H_ #define _MAIN_H_ +void app_main(void); + #endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/time_helper.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/time_helper.h index 3586ac65a..1560fbbbb 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/time_helper.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/time_helper.h @@ -1,6 +1,6 @@ /* time_helper.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -24,8 +24,8 @@ #ifndef _TIME_HELPER_H_ #define _TIME_HELPER_H_ -/* ESP-IDF uses a 64-bit signed integer to represent time_t starting from release v5.0 - * See: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html#year-2036-and-2038-overflow-issues +/* ESP-IDF uses a 64-bit signed integer to represent time_t starting from + * release v5.0 See Espressif api-reference/system/system_time */ #ifdef __cplusplus diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/wifi_connect.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/wifi_connect.h index 6888228f3..3546c4696 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/wifi_connect.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/wifi_connect.h @@ -1,6 +1,6 @@ /* wifi_connect.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -103,23 +103,29 @@ ** 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 to v5 */ #define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID #elif defined(CONFIG_EXAMPLE_WIFI_SSID) - /* tyically from ESP8266 rtos-sdk/v3.4 */ + /* typically from ESP8266 rtos-sdk/v3.4 */ #define EXAMPLE_ESP_WIFI_SSID CONFIG_EXAMPLE_WIFI_SSID #else - #define EXAMPLE_ESP_WIFI_SSID "MYSSID_WIFI_CONNECT" + /* See new esp-sdk-lib.h helpers: */ + #ifndef EXAMPLE_ESP_WIFI_SSID + #define EXAMPLE_ESP_WIFI_SSID "MYSSID_WIFI_CONNECT" + #endif #endif #if defined(CONFIG_ESP_WIFI_PASSWORD) /* tyically from ESP32 with ESP-IDF v4 or v5 */ #define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD #elif defined(CONFIG_EXAMPLE_WIFI_SSID) - /* tyically from ESP8266 rtos-sdk/v3.4 */ + /* typically from ESP8266 rtos-sdk/v3.4 */ #define EXAMPLE_ESP_WIFI_PASS CONFIG_EXAMPLE_WIFI_PASSWORD #else - #define EXAMPLE_ESP_WIFI_PASS "MYPASSWORD_WIFI_CONNECT" + /* See new esp-sdk-lib.h helpers: */ + #ifndef EXAMPLE_ESP_WIFI_PASS + #define EXAMPLE_ESP_WIFI_PASS "MYPASSWORD_WIFI_CONNECT" + #endif #endif #endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/main.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/main.c index 838ad66bd..3c0e0c1c7 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/main.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -28,22 +28,32 @@ /* wolfSSL */ /* Always include wolfcrypt/settings.h before any other wolfSSL file. */ -/* Reminder: settings.h pulls in user_settings.h; don't include it here */ -#include -#include -#ifndef WOLFSSL_ESPIDF - #warning "Problem with wolfSSL user_settings." - #warning "Check components/wolfssl/include" +/* Reminder: settings.h pulls in user_settings.h; don't include it here. */ +#ifdef WOLFSSL_USER_SETTINGS + #include + #ifndef WOLFSSL_ESPIDF + #warning "Problem with wolfSSL user_settings." + #warning "Check components/wolfssl/include" + #endif + /* This project not yet using the library */ + #undef USE_WOLFSSL_ESP_SDK_WIFI + #include +#else + /* Define WOLFSSL_USER_SETTINGS project wide for settings.h to include */ + /* wolfSSL user settings in ./components/wolfssl/include/user_settings.h */ + #error "Missing WOLFSSL_USER_SETTINGS in CMakeLists or Makefile:\ + CFLAGS +=-DWOLFSSL_USER_SETTINGS" #endif /* this project */ #include "client-tls.h" #include "time_helper.h" -#ifndef CONFIG_IDF_TARGET_ESP32H2 +#ifdef CONFIG_IDF_TARGET_ESP32H2 /* There's no WiFi on ESP32-H2. * For wired ethernet, see: * https://github.com/wolfSSL/wolfssl-examples/tree/master/ESP32/TLS13-ENC28J60-client */ +#else #include "wifi_connect.h" /* * Note ModBus TCP cannot be disabled on ESP8266 tos-sdk/v3.4 @@ -123,8 +133,12 @@ void my_atmel_free(int slotId) /* Entry for FreeRTOS */ void app_main(void) { +#if !defined(SINGLE_THREADED) && INCLUDE_uxTaskGetStackHighWaterMark int stack_start = 0; +#endif +#if !defined(SINGLE_THREADED) int this_heap = 0; +#endif esp_err_t ret = 0; ESP_LOGI(TAG, "---------------- wolfSSL TLS Client Example ------------"); ESP_LOGI(TAG, "--------------------------------------------------------"); @@ -132,7 +146,10 @@ void app_main(void) ESP_LOGI(TAG, "---------------------- BEGIN MAIN ----------------------"); ESP_LOGI(TAG, "--------------------------------------------------------"); ESP_LOGI(TAG, "--------------------------------------------------------"); -#ifdef ESP_SDK_MEM_LIB_VERSION +#if !defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_CLIENT) + ESP_LOGW(TAG, "Warning: Example wolfSSL misconfigured? Check menuconfig."); +#endif +#if defined(ESP_SDK_MEM_LIB_VERSION) && defined(DEBUG_WOLFSSL) sdk_init_meminfo(); #endif #ifdef ESP_TASK_MAIN_STACK @@ -155,7 +172,7 @@ void app_main(void) * the minimum free stack space there has been (in bytes not words, unlike * vanilla FreeRTOS) since the task started. The smaller the returned * number the closer the task has come to overflowing its stack. - * see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos_idf.html + * see Espressif api-reference/system/freertos_idf */ stack_start = uxTaskGetStackHighWaterMark(NULL); #ifdef ESP_SDK_MEM_LIB_VERSION @@ -172,7 +189,15 @@ void app_main(void) #ifdef HAVE_VERSION_EXTENDED_INFO esp_ShowExtendedSystemInfo(); #endif - +#ifdef DEBUG_WOLFSSL + wolfSSL_Debugging_OFF(); +#endif +#ifdef CONFIG_IDF_TARGET_ESP32H2 + ESP_LOGE(TAG, "No WiFi on the ESP32-H2 and ethernet not yet supported"); + while (1) { + vTaskDelay(60000); + } +#endif /* Set time for cert validation. * Some lwIP APIs, including SNTP functions, are not thread safe. */ ret = set_time(); /* need to setup NTP before WiFi */ @@ -267,7 +292,6 @@ void app_main(void) - (uxTaskGetStackHighWaterMark(NULL)) ); ESP_LOGI(TAG, "Starting TLS Client task ...\n"); - ESP_LOGI(TAG, "main tls_smp_client_init heap @ %p = %d", &this_heap, this_heap); tls_smp_client_init(args); diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/time_helper.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/time_helper.c index 0adfefcbc..5f2ebe392 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/time_helper.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/time_helper.c @@ -1,6 +1,6 @@ /* time_helper.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -19,12 +19,30 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ -/* See https://tf.nist.gov/tf-cgi/servers.cgi */ - -/* common Espressif time_helper v5.6.6.001 */ -#include "sdkconfig.h" +/* common Espressif time_helper */ #include "time_helper.h" + +#include "sdkconfig.h" +/* wolfSSL */ +/* Always include wolfcrypt/settings.h before any other wolfSSL file. */ +/* Reminder: settings.h pulls in user_settings.h; don't include it here. */ +#ifdef WOLFSSL_USER_SETTINGS + #include + #ifndef WOLFSSL_ESPIDF + #warning "Problem with wolfSSL user_settings." + #warning "Check components/wolfssl/include" + #endif + /* This project not yet using the library */ + #undef USE_WOLFSSL_ESP_SDK_WIFI + #include +#else + /* Define WOLFSSL_USER_SETTINGS project wide for settings.h to include */ + /* wolfSSL user settings in ./components/wolfssl/include/user_settings.h */ + #error "Missing WOLFSSL_USER_SETTINGS in CMakeLists or Makefile:\ + CFLAGS +=-DWOLFSSL_USER_SETTINGS" +#endif + #include #include @@ -41,8 +59,8 @@ /* TODO Consider non ESP-IDF environments */ #endif -/* ESP-IDF uses a 64-bit signed integer to represent time_t starting from release v5.0 - * See: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html#year-2036-and-2038-overflow-issues +/* ESP-IDF uses a 64-bit signed integer to represent time_t starting from + * release v5.0. See: Espressif api-reference/system/system_time */ /* see https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html */ @@ -186,7 +204,7 @@ int set_time_from_string(const char* time_buffer) int quote_offset = 0; int ret = 0; - /* perform some basic sanity checkes */ + /* perform some basic sanity checks */ ret = probably_valid_time_string(time_buffer); if (ret == ESP_OK) { /* we are expecting the string to be encapsulated in single quotes */ @@ -200,7 +218,7 @@ int set_time_from_string(const char* time_buffer) &day, &hour, &minute, &second, &year, &offset); if (ret == 8) { - /* we found a match for all componets */ + /* we found a match for all components */ const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" @@ -264,7 +282,7 @@ int set_time(void) esp_show_current_datetime(); #ifdef LIBWOLFSSL_VERSION_GIT_HASH_DATE - /* initialy set a default approximate time from recent git commit */ + /* initially set a default approximate time from recent git commit */ ESP_LOGI(TAG, "Found git hash date, attempting to set system date: %s", LIBWOLFSSL_VERSION_GIT_HASH_DATE); set_time_from_string(LIBWOLFSSL_VERSION_GIT_HASH_DATE"\0"); @@ -285,7 +303,7 @@ int set_time(void) if (NTP_SERVER_COUNT) { /* next, let's setup NTP time servers * - * see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html#sntp-time-synchronization + * see Espressif api-reference/system/system_time * * WARNING: do not set operating mode while SNTP client is running! */ diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c index 19ced3301..523c7163d 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c @@ -1,6 +1,6 @@ /* wifi_connect.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -31,12 +31,22 @@ #include /* wolfSSL */ -#include -#include -#include -#ifndef WOLFSSL_ESPIDF - #warning "Problem with wolfSSL user_settings." - #warning "Check components/wolfssl/include" +/* Always include wolfcrypt/settings.h before any other wolfSSL file. */ +/* Reminder: settings.h pulls in user_settings.h; don't include it here. */ +#ifdef WOLFSSL_USER_SETTINGS + #include + #ifndef WOLFSSL_ESPIDF + #warning "Problem with wolfSSL user_settings." + #warning "Check components/wolfssl/include" + #endif + /* This project not yet using the library */ + #undef USE_WOLFSSL_ESP_SDK_WIFI + #include +#else + /* Define WOLFSSL_USER_SETTINGS project wide for settings.h to include */ + /* wolfSSL user settings in ./components/wolfssl/include/user_settings.h */ + #error "Missing WOLFSSL_USER_SETTINGS in CMakeLists or Makefile:\ + CFLAGS +=-DWOLFSSL_USER_SETTINGS" #endif /* When there's too little heap, WiFi quietly refuses to connect */ @@ -137,7 +147,7 @@ int wifi_init_sta(void) }; /* Setting a password implies station will connect to all security modes including WEP/WPA. - * However these modes are deprecated and not advisable to be used. Incase your Access point + * However these modes are deprecated and not advisable to be used. In case your Access point * doesn't support WPA2, these mode can be enabled by commenting below line */ if (strlen((char *)wifi_config.sta.password)) { @@ -198,7 +208,7 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) ESP_LOGI(TAG, "got ip:%s", ip4addr_ntoa(&event->event_info.got_ip.ip_info.ip)); #endif - /* see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos_idf.html */ + /* see Espressif api-reference/system/freertos_idf */ xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: @@ -315,7 +325,7 @@ int wifi_init_sta(void) .ssid = EXAMPLE_ESP_WIFI_SSID, .password = EXAMPLE_ESP_WIFI_PASS, /* Authmode threshold resets to WPA2 as default if password matches - * WPA2 standards (pasword len => 8). If you want to connect the + * WPA2 standards (password len => 8). If you want to connect the * device to deprecated WEP/WPA networks, Please set the threshold * value WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with * length and format matching to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults index 765df0fe6..d2b0b890e 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults @@ -1,18 +1,31 @@ +# Set the known example app config to TLS Client (see user_settings.h) +CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_CLIENT=y + +# CONFIG_EXAMPLE_WIFI_SSID="myssid" +# CONFIG_EXAMPLE_WIFI_PASSWORD="mypassword" + +# Some wolfSSL helpers +CONFIG_USE_WOLFSSL_ESP_SDK_TIME=y + # sdkconfig.defaults for ESP8266 + ESP32 -# Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. -# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults -CONFIG_BENCH_ARGV="-lng 0" +# See separate sdkconfig.defaults.esp8266 +# FreeRTOS ticks at 1ms interval +CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_HZ=1000 CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y # # Default main stack size. See user_settings.h # +# This is typically bigger than needed for stack size. +# Units are words, not bytes. See user_settings.h +# # For wolfSSL SMALL_STACK, 3072 bytes should be sufficient for benchmark app. # When using RSA, assign at least 10500 bytes, otherwise 5500 usually works for others +# We set this to 28672 for use in the "test everything possible" in the wolfssl_test app. CONFIG_ESP_MAIN_TASK_STACK_SIZE=10500 -# Legacy stack size for older ESP-IDF versions +# Legacy stack size name for older ESP-IDF versions CONFIG_MAIN_TASK_STACK_SIZE=10500 # @@ -50,6 +63,36 @@ CONFIG_HEAP_DISABLE_IRAM=y # Performance # CONFIG_COMPILER_OPTIMIZATION_PERF=y +# Set max CPU frequency (falls back as needed for lower maximum) +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y + +# Enable wolfSSL TLS in esp-tls +# CONFIG_ESP_TLS_USING_WOLFSSL=y +# CONFIG_TLS_STACK_WOLFSSL=y + +# Bundles take up flash space and are disabled unless otherwise known to be needed +CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=n +# CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=y +# CONFIG_ESP_WOLFSSL_SMALL_CERT_VERIFY=y +# CONFIG_ESP_TLS_INSECURE=y + +# Disable mbedTLS +CONFIG_ESP_TLS_USING_MBEDTLS=n +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n + +# Some wolfSSL helpers +CONFIG_USE_WOLFSSL_ESP_SDK_TIME=n + +# CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set +CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=n + +# ESP8266 Memory +CONFIG_FREERTOS_GLOBAL_DATA_LINK_IRAM=y +CONFIG_HEAP_DISABLE_IRAM=y + +# Performance +# CONFIG_COMPILER_OPTIMIZATION_PERF=y + # Set max COU frequency (falls back as needed for lower maximum) CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y @@ -57,6 +100,26 @@ CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_HZ=1000 +# Ensure mbedTLS options are disabled +# CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=n +# CONFIG_MBEDTLS_TLS_CLIENT_ONLY=n +# CONFIG_MBEDTLS_TLS_SERVER=n +# CONFIG_MBEDTLS_TLS_CLIENT=n +# CONFIG_MBEDTLS_HARDWARE_AES=n +# CONFIG_MBEDTLS_HARDWARE_MPI=n +# CONFIG_MBEDTLS_HARDWARE_SHA=n +# CONFIG_MBEDTLS_ROM_MD5=n +# CONFIG_MBEDTLS_SSL_RENEGOTIATION=n +# CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=n +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1=n +# CONFIG_MBEDTLS_SSL_ALPN=n +# CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=n +# CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=n + +# The same-name config is used for both WiFi and client/server TLS, so we cannot disable: +# CONFIG_MBEDTLS_TLS_ENABLED=n +# CONFIG_MBEDTLS_TLS_DISABLED=y + # # Compiler options # diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults.esp32c2 b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults.esp32c2 new file mode 100644 index 000000000..a24d9302e --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults.esp32c2 @@ -0,0 +1,7 @@ +# +# Main XTAL Config +# +CONFIG_XTAL_FREQ_26=y +# CONFIG_XTAL_FREQ_40 is not set +CONFIG_XTAL_FREQ=26 +# end of Main XTAL Config diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults.esp8266 b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults.esp8266 new file mode 100644 index 000000000..77299dfe4 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults.esp8266 @@ -0,0 +1,30 @@ +# ESP8266 WDT +# CONFIG_ESP_PANIC_PRINT_REBOOT is not set +CONFIG_ESP_PANIC_PRINT_REBOOT=n +CONFIG_ESP_PANIC_PRINT_HALT=y + +# Enable wolfSSL TLS in esp-tls (not yet supported in RTOS SDK 3.4 +CONFIG_ESP_TLS_USING_WOLFSSL=n +CONFIG_TLS_STACK_WOLFSSL=n + +# Bundles take up flash space and are disabled unless otherwise known to be needed +CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=n +# CONFIG_ESP_WOLFSSL_SMALL_CERT_VERIFY=y +# CONFIG_ESP_TLS_INSECURE=y + +# Disable mbedTLS +CONFIG_ESP_TLS_USING_MBEDTLS=y +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n + +# ESP8266 Memory +CONFIG_FREERTOS_GLOBAL_DATA_LINK_IRAM=y +CONFIG_HEAP_DISABLE_IRAM=y + +# ESP8266 Watchdog: +CONFIG_TASK_WDT=n +CONFIG_TASK_WDT_PANIC=n + +# ESP8266 WDT +# CONFIG_ESP_PANIC_PRINT_REBOOT is not set +CONFIG_ESP_PANIC_PRINT_REBOOT=n +CONFIG_ESP_PANIC_PRINT_HALT=y diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/CMakeLists.txt index 11a9e467a..a61aed3f0 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/CMakeLists.txt @@ -1,10 +1,19 @@ # wolfSSL Espressif Example Project CMakeLists.txt -# v1.0 +# v1.3 # # The following lines of boilerplate have to be in your project's # CMakeLists in this exact order for cmake to work correctly +message(STATUS "Begin project ${CMAKE_PROJECT_NAME}") + cmake_minimum_required(VERSION 3.16) +# Optional no watchdog typically used for test & benchmark +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESP_NO_WATCHDOG=1") +else() + add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +endif() + # The wolfSSL CMake file should be able to find the source code. # Otherwise, assign an environment variable or set it here: # @@ -22,45 +31,63 @@ cmake_minimum_required(VERSION 3.16) if(WIN32) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") - message("Detected Windows") + message(STATUS "Detected Windows") endif() if(CMAKE_HOST_UNIX) - message("Detected UNIX") + message(STATUS "Detected UNIX") endif() if(APPLE) - message("Detected APPLE") + message(STATUS "Detected APPLE") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") - message("Detected WSL") + message(STATUS "Detected WSL") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") - message("Detected Linux") + message(STATUS "Detected Linux") endif() if(APPLE) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") - message("Detected Apple") + message(STATUS "Detected Apple") endif() # End optional WOLFSSL_CMAKE_SYSTEM_NAME # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) +# set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) +string(REPLACE "\\" "/" PROTOCOL_EXAMPLES_DIR "$ENV{IDF_PATH}/examples/common_components/protocol_examples_common") if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") - message("Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + message(STATUS "Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") else() - message("NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") endif() +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER +message(STATUS "USERNAME = $ENV{USERNAME}") +if( "$ENV{USER}" STREQUAL "" ) # the bash user + if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user + message(STATUS "could not find USER or USERNAME") + else() + # the bash user is not blank, so we'll use it. + set(THIS_USER "$ENV{USERNAME}") + endif() +else() + # the bash user is not blank, so we'll use it. + set(THIS_USER "$ENV{USER}") +endif() +message(STATUS "THIS_USER = ${THIS_USER}") + # Check that there are not conflicting wolfSSL components # The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl # The local component wolfSSL directory will be in ./components/wolfssl +message(STATUS "Checking for wolfSSL as Managed Component or not... ${CMAKE_HOME_DIRECTORY}") if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" ) # These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake' # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL) @@ -75,22 +102,47 @@ if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXI message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n" "If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove " "or rename the idf_component.yml file typically found in ./main/") -else() +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl") + # A standard project component (not a Managed Component) message(STATUS "No conflicting wolfSSL components found.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/components/wolfssl") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl") + # The official Managed Component called wolfssl from the wolfssl user. + message(STATUS "No conflicting wolfSSL components found as a Managed Component.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/gojimmypi__mywolfssl") + # There is a known gojimmypi staging component available for anyone: + message(STATUS "No conflicting wolfSSL components found as a gojimmypi staging Managed Component.") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/${THIS_USER}__mywolfssl") + # Other users with permissions might publish their own mywolfssl staging Managed Component + message(STATUS "No conflicting wolfSSL components found as a Managed Component.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/managed_components/${THIS_USER}__mywolfssl") +else() + message(STATUS "WARNING: wolfssl component directory not found.") endif() +# message(STATUS "EXTRA_COMPONENT_DIRS WOLFSSL_PATH: ${WOLFSSL_PATH}") +# list(APPEND EXTRA_COMPONENT_DIRS ${WOLFSSL_PATH}) -# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) +# Not only is a project-level "set(COMPONENTS" not needed here, this will cause +# an unintuitive error about Unknown CMake command "esptool_py_flash_project_args". -if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") - message("Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") - set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") -else() - message("NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") +if(0) + message(STATUS "Begin optional PROTOCOL_EXAMPLES_DIR include") + # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. + set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + + if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") + message(STATUS "Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") + else() + message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + endif() + message(STATUS "End optional PROTOCOL_EXAMPLES_DIR include") endif() include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(wolfssl_server) +message(STATUS "end project") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/README.md b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/README.md index c663c78cb..17d14e735 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/README.md +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/README.md @@ -20,18 +20,18 @@ The Example contains a wolfSSL simple server. 1. `idf.py menuconfig` to configure the project 1-1. Example Connection Configuration -> - - WIFI SSID : your own WIFI, which is connected to the Internet.(default is "myssid") + + WIFI SSID : your own WIFI, which is connected to the Internet.(default is "myssid") WIFI Password : WIFI password, and default is "mypassword" When you want to test the wolfSSL simple server demo 1. `idf.py -p flash` to compile the code and load the firmware 2. `idf.py monitor` to see the context. The assigned IP address can be found in output message. -3. Once the server connects to the wifi, it is waiting for client request. +3. Once the server connects to the wifi, it is waiting for client request. ("Waiting for a connection..." message will be displayed.) - -4. You can use /examples/client to test the server + +4. You can use /examples/client to test the server e.g ./example/client/client -h xx.xx.xx See the README.md file in the upper level 'examples' directory for more information about examples. @@ -39,7 +39,7 @@ See the README.md file in the upper level 'examples' directory for more informat ``` # . /mnt/c/SysGCC/esp32/esp-idf/master/export.sh -. /mnt/c/SysGCC/esp32/esp-idf/v5.1/export.sh +. /mnt/c/SysGCC/esp32/esp-idf/v5.2/export.sh cd /mnt/c/workspace/wolfssl-$USER/IDE/Espressif/ESP-IDF/examples/wolfssl_server # optionally erase @@ -82,7 +82,7 @@ After the server exits, remove the port proxy forward: netsh interface portproxy delete v4tov4 listenport=11111 listenaddress=0.0.0.0 ``` -Cipers to consider +Ciphers to consider ``` TLS13-AES128-GCM-SHA256: diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/README_server_sm.md b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/README_server_sm.md index 01dd6baf8..87e1f0365 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/README_server_sm.md +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/README_server_sm.md @@ -49,7 +49,7 @@ make clean && make ### Others... ``` -# Success: Linux Client to ESP32 Server TLS1.2 +# Success: Linux Client to ESP32 Server TLS1.2 ./examples/client/client -h 192.168.1.113 -v 3 -l ECDHE-ECDSA-SM4-CBC-SM3 -c ./certs/sm2/client-sm2.pem -k ./certs/sm2/client-sm2-priv.pem -A ./certs/sm2/root-sm2.pem -C ./examples/client/client -h 192.168.1.113 -v 3 -l ECDHE-ECDSA-SM4-GCM-SM3 -c ./certs/sm2/client-sm2.pem -k ./certs/sm2/client-sm2-priv.pem -A ./certs/sm2/root-sm2.pem -C ./examples/client/client -h 192.168.1.113 -v 3 -l ECDHE-ECDSA-SM4-CCM-SM3 -c ./certs/sm2/client-sm2.pem -k ./certs/sm2/client-sm2-priv.pem -A ./certs/sm2/root-sm2.pem -C @@ -81,7 +81,7 @@ be the same as the Linux server files. | Usage | Certificate | Key | Certificate Authority file, default ./certs/client-cert.pem | | ----- | ---------------------------------- | ----------------------------------- | --------------------------------- | -| server | -c ./certs/sm2/server-sm2.pem | -k ./certs/sm2/server-sm2-priv.pem | -A ./certs/sm2/client-sm2.pem -V | +| server | -c ./certs/sm2/server-sm2.pem | -k ./certs/sm2/server-sm2-priv.pem | -A ./certs/sm2/client-sm2.pem -V | | client | -c ./certs/sm2/client-sm2.pem | -k ./certs/sm2/client-sm2-priv.pem | -A ./certs/sm2/root-sm2.pem -C | | emdedded: | server | wolfSSL_CTX_use_certificate_buffer
server_sm2 | wolfSSL_CTX_use_PrivateKey_buffer
server_sm2_priv | wolfSSL_CTX_load_verify_buffer
client-sm2 | @@ -156,7 +156,7 @@ I (622) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (628) heap_init: At 40094DC8 len 0000B238 (44 KiB): IRAM I (636) spi_flash: detected chip: generic I (639) spi_flash: flash io: dio -W (643) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the +W (643) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header. I (657) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. @@ -167,7 +167,7 @@ I (735) system_api: read default base MAC address from EFUSE I (755) wifi:wifi firmware version: 0d470ef I (755) wifi:wifi certification version: v7.0 I (755) wifi:config NVS flash: enabled -I (755) wifi:config nano formating: disabled +I (755) wifi:config nano formatting: disabled I (755) wifi:Init data frame dynamic rx buffer num: 32 I (765) wifi:Init management frame dynamic rx buffer num: 32 I (765) wifi:Init management short buffer num: 32 @@ -358,12 +358,12 @@ I (14715) internal.c: GrowOutputBuffer ok I (14715) wolfssl: wolfSSL Entering wolfSSL_get_options I (14725) wolfssl: Point Formats extension to write W (14735) wolfio: ssl->wflags = 0 -I (14735) wolfio: 16 03 03 00 52 02 00 00 4e 03 03 af 87 e2 58 57 -I (14735) wolfio: 73 c3 c1 35 1a 59 39 b2 03 9d 14 03 e0 b8 fb e8 -I (14745) wolfio: 9d 5b 9c 44 4f 57 4e 47 52 44 01 20 85 77 75 20 -I (14755) wolfio: 95 dd 00 e2 91 f8 42 33 f8 61 3f 1f de 81 15 58 -I (14755) wolfio: 23 0c e7 1e 71 e6 10 e5 67 23 e0 40 e0 11 00 00 -I (14765) wolfio: 06 00 0b 00 02 01 00 +I (14735) wolfio: 16 03 03 00 52 02 00 00 4e 03 03 af 87 e2 58 57 +I (14735) wolfio: 73 c3 c1 35 1a 59 39 b2 03 9d 14 03 e0 b8 fb e8 +I (14745) wolfio: 9d 5b 9c 44 4f 57 4e 47 52 44 01 20 85 77 75 20 +I (14755) wolfio: 95 dd 00 e2 91 f8 42 33 f8 61 3f 1f de 81 15 58 +I (14755) wolfio: 23 0c e7 1e 71 e6 10 e5 67 23 e0 40 e0 11 00 00 +I (14765) wolfio: 06 00 0b 00 02 01 00 W (14775) wolfio: sz = 87 I (14775) wolfssl: Shrinking output buffer I (14775) wolfssl: wolfSSL Leaving SendServerHello, return 0 @@ -372,53 +372,53 @@ I (14795) wolfssl: wolfSSL Entering SendCertificate I (14795) wolfssl: growing output buffer I (14805) internal.c: GrowOutputBuffer ok W (14815) wolfio: ssl->wflags = 0 -I (14815) wolfio: 16 03 03 02 e6 0b 00 02 e2 00 02 df 00 02 dc 30 -I (14815) wolfio: 82 02 d8 30 82 02 7e a0 03 02 01 02 02 01 01 30 -I (14825) wolfio: 0a 06 08 2a 81 1c cf 55 01 83 75 30 81 ac 31 0b -I (14835) wolfio: 30 09 06 03 55 04 06 13 02 55 53 31 10 30 0e 06 -I (14835) wolfio: 03 55 04 08 0c 07 4d 6f 6e 74 61 6e 61 31 10 30 -I (14845) wolfio: 0e 06 03 55 04 07 0c 07 42 6f 7a 65 6d 61 6e 31 -I (14855) wolfio: 14 30 12 06 03 55 04 0a 0c 0b 77 6f 6c 66 53 53 -I (14855) wolfio: 4c 5f 73 6d 32 31 0f 30 0d 06 03 55 04 0b 0c 06 -I (14865) wolfio: 43 41 2d 73 6d 32 31 18 30 16 06 03 55 04 03 0c -I (14875) wolfio: 0f 77 77 77 2e 77 6f 6c 66 73 73 6c 2e 63 6f 6d -I (14875) wolfio: 31 1f 30 1d 06 09 2a 86 48 86 f7 0d 01 09 01 16 -I (14885) wolfio: 10 69 6e 66 6f 40 77 6f 6c 66 73 73 6c 2e 63 6f -I (14895) wolfio: 6d 31 17 30 15 06 0a 09 92 26 89 93 f2 2c 64 01 -I (14895) wolfio: 01 0c 07 77 6f 6c 66 53 53 4c 30 1e 17 0d 32 33 -I (14905) wolfio: 30 32 31 35 30 36 32 33 30 37 5a 17 0d 32 35 31 -I (14915) wolfio: 31 31 31 30 36 32 33 30 37 5a 30 81 b0 31 0b 30 -I (14915) wolfio: 09 06 03 55 04 06 13 02 55 53 31 10 30 0e 06 03 -I (14925) wolfio: 55 04 08 0c 07 4d 6f 6e 74 61 6e 61 31 10 30 0e -I (14935) wolfio: 06 03 55 04 07 0c 07 42 6f 7a 65 6d 61 6e 31 14 -I (14945) wolfio: 30 12 06 03 55 04 0a 0c 0b 77 6f 6c 66 53 53 4c -I (14945) wolfio: 5f 73 6d 32 31 13 30 11 06 03 55 04 0b 0c 0a 53 -I (14955) wolfio: 65 72 76 65 72 2d 73 6d 32 31 18 30 16 06 03 55 -I (14965) wolfio: 04 03 0c 0f 77 77 77 2e 77 6f 6c 66 73 73 6c 2e -I (14965) wolfio: 63 6f 6d 31 1f 30 1d 06 09 2a 86 48 86 f7 0d 01 -I (14975) wolfio: 09 01 16 10 69 6e 66 6f 40 77 6f 6c 66 73 73 6c -I (14985) wolfio: 2e 63 6f 6d 31 17 30 15 06 0a 09 92 26 89 93 f2 -I (14985) wolfio: 2c 64 01 01 0c 07 77 6f 6c 66 53 53 4c 30 5a 30 -I (14995) wolfio: 14 06 08 2a 81 1c cf 55 01 82 2d 06 08 2a 81 1c -I (15005) wolfio: cf 55 01 82 2d 03 42 00 04 94 70 2b 46 e4 5e 0f -I (15005) wolfio: 41 fb 8f 2d 34 0a 41 40 19 5e fb d4 1d 11 ac fa -I (15015) wolfio: f5 93 37 c6 fa 87 08 f7 16 1f 2c ce 30 40 9d 4f -I (15025) wolfio: a6 2a 0a a1 d6 95 33 c3 a6 03 98 e6 8d 05 34 b0 -I (15025) wolfio: 97 0c de a4 c7 cf 53 8f d1 a3 81 89 30 81 86 30 -I (15035) wolfio: 1d 06 03 55 1d 0e 04 16 04 14 67 ae 60 ff 7e 1b -I (15045) wolfio: 0f 95 ae 1f 82 59 f2 6c 56 2d 93 ef 17 32 30 1f -I (15045) wolfio: 06 03 55 1d 23 04 18 30 16 80 14 47 0a 48 7e bb -I (15055) wolfio: 02 a8 5a 26 57 2b 19 a9 7b 61 8b 7f 5d 99 6e 30 -I (15065) wolfio: 0c 06 03 55 1d 13 01 01 ff 04 02 30 00 30 0e 06 -I (15075) wolfio: 03 55 1d 0f 01 01 ff 04 04 03 02 03 a8 30 13 06 -I (15075) wolfio: 03 55 1d 25 04 0c 30 0a 06 08 2b 06 01 05 05 07 -I (15085) wolfio: 03 01 30 11 06 09 60 86 48 01 86 f8 42 01 01 04 -I (15095) wolfio: 04 03 02 06 40 30 0a 06 08 2a 81 1c cf 55 01 83 -I (15095) wolfio: 75 03 48 00 30 45 02 20 1b ca 94 28 7f f6 b2 0d -I (15105) wolfio: 31 43 50 e1 d5 34 17 dd af 3a de 81 06 67 9a b3 -I (15115) wolfio: 06 22 7e 64 ec fd 0e b9 02 21 00 a1 48 a8 32 d1 -I (15115) wolfio: 05 09 6b 1c eb 89 12 66 d8 38 a1 c4 5c 89 09 0f -I (15125) wolfio: fd e9 c0 3b 1d fb cd b5 4c 31 68 +I (14815) wolfio: 16 03 03 02 e6 0b 00 02 e2 00 02 df 00 02 dc 30 +I (14815) wolfio: 82 02 d8 30 82 02 7e a0 03 02 01 02 02 01 01 30 +I (14825) wolfio: 0a 06 08 2a 81 1c cf 55 01 83 75 30 81 ac 31 0b +I (14835) wolfio: 30 09 06 03 55 04 06 13 02 55 53 31 10 30 0e 06 +I (14835) wolfio: 03 55 04 08 0c 07 4d 6f 6e 74 61 6e 61 31 10 30 +I (14845) wolfio: 0e 06 03 55 04 07 0c 07 42 6f 7a 65 6d 61 6e 31 +I (14855) wolfio: 14 30 12 06 03 55 04 0a 0c 0b 77 6f 6c 66 53 53 +I (14855) wolfio: 4c 5f 73 6d 32 31 0f 30 0d 06 03 55 04 0b 0c 06 +I (14865) wolfio: 43 41 2d 73 6d 32 31 18 30 16 06 03 55 04 03 0c +I (14875) wolfio: 0f 77 77 77 2e 77 6f 6c 66 73 73 6c 2e 63 6f 6d +I (14875) wolfio: 31 1f 30 1d 06 09 2a 86 48 86 f7 0d 01 09 01 16 +I (14885) wolfio: 10 69 6e 66 6f 40 77 6f 6c 66 73 73 6c 2e 63 6f +I (14895) wolfio: 6d 31 17 30 15 06 0a 09 92 26 89 93 f2 2c 64 01 +I (14895) wolfio: 01 0c 07 77 6f 6c 66 53 53 4c 30 1e 17 0d 32 33 +I (14905) wolfio: 30 32 31 35 30 36 32 33 30 37 5a 17 0d 32 35 31 +I (14915) wolfio: 31 31 31 30 36 32 33 30 37 5a 30 81 b0 31 0b 30 +I (14915) wolfio: 09 06 03 55 04 06 13 02 55 53 31 10 30 0e 06 03 +I (14925) wolfio: 55 04 08 0c 07 4d 6f 6e 74 61 6e 61 31 10 30 0e +I (14935) wolfio: 06 03 55 04 07 0c 07 42 6f 7a 65 6d 61 6e 31 14 +I (14945) wolfio: 30 12 06 03 55 04 0a 0c 0b 77 6f 6c 66 53 53 4c +I (14945) wolfio: 5f 73 6d 32 31 13 30 11 06 03 55 04 0b 0c 0a 53 +I (14955) wolfio: 65 72 76 65 72 2d 73 6d 32 31 18 30 16 06 03 55 +I (14965) wolfio: 04 03 0c 0f 77 77 77 2e 77 6f 6c 66 73 73 6c 2e +I (14965) wolfio: 63 6f 6d 31 1f 30 1d 06 09 2a 86 48 86 f7 0d 01 +I (14975) wolfio: 09 01 16 10 69 6e 66 6f 40 77 6f 6c 66 73 73 6c +I (14985) wolfio: 2e 63 6f 6d 31 17 30 15 06 0a 09 92 26 89 93 f2 +I (14985) wolfio: 2c 64 01 01 0c 07 77 6f 6c 66 53 53 4c 30 5a 30 +I (14995) wolfio: 14 06 08 2a 81 1c cf 55 01 82 2d 06 08 2a 81 1c +I (15005) wolfio: cf 55 01 82 2d 03 42 00 04 94 70 2b 46 e4 5e 0f +I (15005) wolfio: 41 fb 8f 2d 34 0a 41 40 19 5e fb d4 1d 11 ac fa +I (15015) wolfio: f5 93 37 c6 fa 87 08 f7 16 1f 2c ce 30 40 9d 4f +I (15025) wolfio: a6 2a 0a a1 d6 95 33 c3 a6 03 98 e6 8d 05 34 b0 +I (15025) wolfio: 97 0c de a4 c7 cf 53 8f d1 a3 81 89 30 81 86 30 +I (15035) wolfio: 1d 06 03 55 1d 0e 04 16 04 14 67 ae 60 ff 7e 1b +I (15045) wolfio: 0f 95 ae 1f 82 59 f2 6c 56 2d 93 ef 17 32 30 1f +I (15045) wolfio: 06 03 55 1d 23 04 18 30 16 80 14 47 0a 48 7e bb +I (15055) wolfio: 02 a8 5a 26 57 2b 19 a9 7b 61 8b 7f 5d 99 6e 30 +I (15065) wolfio: 0c 06 03 55 1d 13 01 01 ff 04 02 30 00 30 0e 06 +I (15075) wolfio: 03 55 1d 0f 01 01 ff 04 04 03 02 03 a8 30 13 06 +I (15075) wolfio: 03 55 1d 25 04 0c 30 0a 06 08 2b 06 01 05 05 07 +I (15085) wolfio: 03 01 30 11 06 09 60 86 48 01 86 f8 42 01 01 04 +I (15095) wolfio: 04 03 02 06 40 30 0a 06 08 2a 81 1c cf 55 01 83 +I (15095) wolfio: 75 03 48 00 30 45 02 20 1b ca 94 28 7f f6 b2 0d +I (15105) wolfio: 31 43 50 e1 d5 34 17 dd af 3a de 81 06 67 9a b3 +I (15115) wolfio: 06 22 7e 64 ec fd 0e b9 02 21 00 a1 48 a8 32 d1 +I (15115) wolfio: 05 09 6b 1c eb 89 12 66 d8 38 a1 c4 5c 89 09 0f +I (15125) wolfio: fd e9 c0 3b 1d fb cd b5 4c 31 68 W (15135) wolfio: sz = 747 I (15135) wolfssl: Shrinking output buffer I (15135) wolfssl: wolfSSL Leaving SendCertificate, return 0 @@ -440,16 +440,16 @@ I (15915) wolfssl: wolfSSL Entering SendHandshakeMsg I (15925) wolfssl: growing output buffer I (15925) internal.c: GrowOutputBuffer ok W (15925) wolfio: ssl->wflags = 0 -I (15935) wolfio: 16 03 03 00 95 0c 00 00 91 03 00 29 41 04 fd f5 -I (15935) wolfio: 5e 74 15 30 1d f3 84 ae a5 69 96 a9 5b dd 27 b3 -I (15945) wolfio: 00 7d 40 3a 59 93 93 6f 4d 1f 62 dc 60 48 34 1f -I (15955) wolfio: a8 1d 34 b8 76 8f 8b 27 4a 1b 77 64 8e 2e d5 27 -I (15955) wolfio: 03 95 8b 9d a5 ed a4 a6 b9 40 1b ea aa 10 07 08 -I (15965) wolfio: 00 48 30 46 02 21 00 cb 89 61 e9 21 f9 c6 4d ad -I (15975) wolfio: aa e7 f1 3f 6f 27 46 f0 35 ec 45 4e 8a ae f3 ac -I (15985) wolfio: 7c c0 cf 68 11 44 e2 02 21 00 f6 40 5c bc 66 5a -I (15985) wolfio: 74 1e 92 5d 9a 03 75 e7 7f 16 c2 b3 c8 fe 8d 5c -I (15995) wolfio: 63 35 36 da 61 38 76 dc 4e d6 +I (15935) wolfio: 16 03 03 00 95 0c 00 00 91 03 00 29 41 04 fd f5 +I (15935) wolfio: 5e 74 15 30 1d f3 84 ae a5 69 96 a9 5b dd 27 b3 +I (15945) wolfio: 00 7d 40 3a 59 93 93 6f 4d 1f 62 dc 60 48 34 1f +I (15955) wolfio: a8 1d 34 b8 76 8f 8b 27 4a 1b 77 64 8e 2e d5 27 +I (15955) wolfio: 03 95 8b 9d a5 ed a4 a6 b9 40 1b ea aa 10 07 08 +I (15965) wolfio: 00 48 30 46 02 21 00 cb 89 61 e9 21 f9 c6 4d ad +I (15975) wolfio: aa e7 f1 3f 6f 27 46 f0 35 ec 45 4e 8a ae f3 ac +I (15985) wolfio: 7c c0 cf 68 11 44 e2 02 21 00 f6 40 5c bc 66 5a +I (15985) wolfio: 74 1e 92 5d 9a 03 75 e7 7f 16 c2 b3 c8 fe 8d 5c +I (15995) wolfio: 63 35 36 da 61 38 76 dc 4e d6 W (15995) wolfio: sz = 154 I (16005) wolfssl: Shrinking output buffer I (16005) wolfssl: wolfSSL Leaving SendServerKeyExchange, return 0 @@ -459,7 +459,7 @@ I (16025) wolfssl: wolfSSL Entering SendServerHelloDone I (16035) wolfssl: growing output buffer I (16035) internal.c: GrowOutputBuffer ok W (16045) wolfio: ssl->wflags = 0 -I (16045) wolfio: 16 03 03 00 04 0e 00 00 00 +I (16045) wolfio: 16 03 03 00 04 0e 00 00 00 W (16045) wolfio: sz = 9 I (16055) wolfssl: Embed Send error I (16055) wolfssl: Connection reset @@ -479,14 +479,14 @@ I (16125) wolfssl: User calling wolfSSL_read in error state, not allowed I (16135) wolfssl: wolfSSL Leaving wolfSSL_read_internal, return -308 E (16145) tls_server: ERROR: failed to read I (16145) wolfssl: Client sends: -I (16145) wolfssl: +I (16145) wolfssl: I (16155) wolfssl: wolfSSL Entering wolfSSL_write I (16155) wolfssl: handshake not complete, trying to finish I (16165) wolfssl: wolfSSL Entering wolfSSL_negotiate I (16165) wolfssl: wolfSSL Entering wolfSSL_accept I (16175) wolfssl: wolfSSL Entering ReinitSSL W (16185) wolfio: ssl->wflags = 0 -I (16185) wolfio: 16 03 03 00 04 0e 00 00 00 +I (16185) wolfio: 16 03 03 00 04 0e 00 00 00 W (16185) wolfio: sz = 9 I (16195) wolfssl: Embed Send error I (16195) wolfssl: General error 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 b809a1714..cc7ef0d47 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,5 +1,5 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # @@ -19,18 +19,148 @@ # # cmake for wolfssl Espressif projects # -# Version 5.6.0.011 for detect test/benchmark +# Version 5.7.2 Espressif ESP-IDF integration # # See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html # - +message(STATUS "Begin wolfssl ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") cmake_minimum_required(VERSION 3.16) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") -set(CMAKE_CURRENT_SOURCE_DIR ".") -set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component -set(WOLFSSL_ROOT "$ENV{WOLFSSL_ROOT}" ) -# find the user name to search for possible "wolfssl-username" +set(VERBOSE_COMPONENT_MESSAGES 1) + +# Optional requires include: +# set(THIS_ESP_TLS "esp-tls") +set(THIS_ESP_TLS "") + +# function: IS_ESP_IDF_COMPONENT +# output: RESULT = 1 (true) if this component is located in the ESP-IDF components +# otherwise 0 (false) +function( IS_ESP_IDF_COMPONENT RESULT ) + # NOTE: Component location is based on the location of the CMakeList.txt + # and *not* the location of the wolfSSL source code. (which may be anywhere) + + # Normalize the paths to remove any trailing slashes + get_filename_component(NORMALIZED_IDF_PATH "${IDF_PATH}" REALPATH) + get_filename_component(NORMALIZED_TEST_PATH "${COMPONENT_DIR}" REALPATH) + + # Check if the test path starts with the IDF_PATH + string(FIND "${NORMALIZED_TEST_PATH}" "${NORMALIZED_IDF_PATH}" pos) + + if(${pos} EQUAL 0) + message(STATUS "${COMPONENT_DIR} is within IDF_PATH.") + set(${RESULT} 1 PARENT_SCOPE) + else() + message(STATUS "${COMPONENT_DIR} is not within IDF_PATH.") + set(${RESULT} 0 PARENT_SCOPE) + endif() +endfunction() + +# Determine if this cmake file is located in the ESP-IDF component directory or not, +# and if so, if it is being ignored (allowing the use of a local project one, instead). +IS_ESP_IDF_COMPONENT( IS_WOLSSL_ESP_IDF_COMPONENT ) +if( IS_WOLSSL_ESP_IDF_COMPONENT ) + message(STATUS "This wolfSSL is a component in ESP-IDF.") + if ( CONFIG_IGNORE_ESP_IDF_WOLFSSL_COMPONENT ) + idf_component_register() + message(STATUS "Warning: wolfSSL component in ESP-IDF is being ignored.") + return() + endif() +endif() + + +if( "${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}" STREQUAL "" ) + # nothing to do +else() + # Only forward slashes, or double backslashes are supported. + # By the time we get here the sdkconfig file has a value for wolfSSL source code root. + string(REPLACE "\\" "/" CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}) + message(STATUS "Cleaned wolfssl path: ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") +endif() + +# The scope of this CMAKE_C_FLAGS is just this component: +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWOLFSSL_USER_SETTINGS") + +set(CMAKE_CURRENT_SOURCE_DIR ".") +# set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component + +# Optionally set your source to wolfSSL in your project CMakeLists.txt like this: +# set(WOLFSSL_ROOT "c:/test/my_wolfssl" ) + +if ( "${WOLFSSL_ROOT}" STREQUAL "") + set(WOLFSSL_ROOT "$ENV{WOLFSSL_ROOT}" ) +endif() + +if( "$ENV{IDF_PATH}" STREQUAL "" ) + message(FATAL_ERROR "IDF_PATH Environment variable not set!") +else() + string(REPLACE "\\" "/" THIS_IDF_PATH "$ENV{IDF_PATH}") +endif() + +# Optional compiler definitions to help with system name detection (typically printed by app diagnostics) +if(VERBOSE_COMPONENT_MESSAGES) + if(WIN32) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") + message(STATUS "Detected Windows") + endif() + if(CMAKE_HOST_UNIX) + message(STATUS "Detected UNIX") + endif() + if(APPLE) + message(STATUS "Detected APPLE") + endif() + if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") + message(STATUS "Detected WSL") + endif() + if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") + message(STATUS "Detected Linux") + endif() + if(APPLE) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") + message(STATUS "Detected Apple") + endif() +endif() # End optional WOLFSSL_CMAKE_SYSTEM_NAME + +message(STATUS "CONFIG_TARGET_PLATFORM = ${CONFIG_TARGET_PLATFORM}") + +# Check that there are not conflicting wolfSSL components +# The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl +# The local component wolfSSL directory will be in ./components/wolfssl +if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" ) + # These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake' + # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL) + # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl/include" EXCLUDE_FROM_ALL) + # So we'll error out and let the user decide how to proceed: + message(WARNING "\nFound wolfSSL components in\n" + "./managed_components/wolfssl__wolfssl\n" + "and\n" + "./components/wolfssl\n" + "in project directory: \n" + "${CMAKE_HOME_DIRECTORY}") + message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n" + "If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove " + "or rename the idf_component.yml file typically found in ./main/") +else() + message(STATUS "No conflicting wolfSSL components found.") +endif() + + +# Don't include lwip requirement for benchmark and test apps. +if( ("${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_benchmark") OR ("${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_test") ) + message(STATUS "Not including lwip for ${CMAKE_PROJECT_NAME}") +else() + # benchmark and test do not need wifi, everything else probably does: + set(COMPONENT_REQUIRES lwip "${THIS_ESP_TLS}") # we typically don't need lwip directly in wolfssl component +endif() + +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER message(STATUS "USERNAME = $ENV{USERNAME}") if( "$ENV{USER}" STREQUAL "" ) # the bash user if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user @@ -51,6 +181,25 @@ else() string(REPLACE "\\" "/" THIS_IDF_PATH "$ENV{IDF_PATH}") endif() +# ENVIRONMENT_VAR_TO_MACRO +# Check environment variable name EVARPARAM as [name] +# If defined, and has a value of EVARVALUE as [value], +# then assign a compiler definition "-D[name]=[value]" +function(ENVIRONMENT_VAR_TO_MACRO EVARPARAM EVARVALUE) + # If the EVARPARAM environment variable name is set to EVARVALUE, + # set the compiler flag definition to enable CSV output. + if ( "$ENV{${EVARPARAM}}" STREQUAL "${EVARVALUE}") + message(STATUS "Appending compile definition: -D${EVARPARAM}=${EVARVALUE}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${EVARPARAM}=${EVARVALUE}") + else() + if(DEFINED ENV{${EVARPARAM}}) + message(STATUS "Environment variable ${EVARPARAM} detected but set to $ENV{${EVARPARAM}}, not appending compile definition.") + else() + message(STATUS "Environment variable ${EVARPARAM} not detected, not appending compile definition.") + endif() + endif() +endfunction() + # COMPONENT_NAME = wolfssl # The component name is the directory name. "No feature to change this". # See https://github.com/espressif/esp-idf/issues/8978#issuecomment-1129892685 @@ -68,7 +217,8 @@ endif() # function: IS_WOLFSSL_SOURCE # parameter: DIRECTORY_PARAMETER - the directory to test # output: RESULT = contains contents of DIRECTORY_PARAMETER for wolfssl directory, otherwise blank. -function(IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER RESULT) +function( IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER + RESULT ) if (EXISTS "${DIRECTORY_PARAMETER}/wolfcrypt/src") set(${RESULT} "${DIRECTORY_PARAMETER}" PARENT_SCOPE) else() @@ -76,27 +226,71 @@ function(IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER RESULT) endif() endfunction() +# ********************************************************************************************* # function: FIND_WOLFSSL_DIRECTORY # parameter: OUTPUT_FOUND_WOLFSSL_DIRECTORY contains root of source code, otherwise blank # +# Example usage: +# FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) +# ********************************************************************************************* function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY) - message(STATUS "Starting FIND_WOLFSSL_DIRECTORY") - set(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}") - if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) - message(STATUS "The WOLFSSL_ROOT environment variable is not set. Searching...") + message(STATUS "Starting FIND_WOLFSSL_DIRECTORY: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + + if ( "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}" STREQUAL "" ) + # The parameter is empty, so we certainly need to search. + # First, see if there's an environment variable. This takes highest priority (unless already found as hard-coded, above) + set(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}") + if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) + message(STATUS "The WOLFSSL_ROOT environment variable is not set. Searching...") + # Next, if not found, see if wolfSSL was selected for ESP-TLS Kconfig + if(CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT) + set(CURRENT_SEARCH_DIR ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}) + get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" ABSOLUTE) + message(STATUS "WOLFSSL_ROOT found in sdkconfig/KConfig: ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") + else() + message(STATUS "wolfSSL not defined in [Component Config] [wolfssl]. Continuing search...") + # If not specified as a search hint in OUTPUT_FOUND_WOLFSSL_DIRECTORY: + # This wolfSSL component CMakeLists.txt may be found EITHER in: + # 1) local project component + # 2) ESP-IDF share components + # We'll start in the CMAKE_CURRENT_SOURCE_DIR, typically [something]/projectname/components/wolfssl + # That option might find wolfSSL source code as a copy in the component directory (e.g. Managed Components) + # Unless cmake is in the ESP-IDF, in which case it is unlikely to find wolfSSL source in any parent. + message(STATUS "CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}") + get_filename_component(CURRENT_SEARCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE) + message(STATUS "CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}") + string(LENGTH ${CURRENT_SEARCH_DIR} CURRENT_SEARCH_DIR_LENGTH) + endif() # CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT + endif() # check environment var blank else() - get_filename_component(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}" ABSOLUTE) + message(STATUS "Parameter found for FIND_WOLFSSL_DIRECTORY") + message(STATUS "Setting wolfSSL search directory to: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + set(CURRENT_SEARCH_DIR "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + endif() # parameter empty + + # Check to see if we found a path in environment or config settings, above. + if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) + message(STATUS "Source for wolfSSL not specified in path nor config settings.") + # We'll continue the search by recursing up the directory tree, below. + else() + # Setting found! Does it contain a valid path? + string(REPLACE "\\" "/" CURRENT_SEARCH_DIR ${CURRENT_SEARCH_DIR}) + get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" ABSOLUTE) IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSL) if( FOUND_WOLFSSL ) - message(STATUS "Found WOLFSSL_ROOT via Environment Variable: ${CURRENT_SEARCH_DIR}") + message(STATUS "Found wolfSSL source code via setting: ${CURRENT_SEARCH_DIR}") set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) return() else() - message(FATAL_ERROR "WOLFSSL_ROOT Environment Variable defined, but path not found:") - message(STATUS "$ENV{WOLFSSL_ROOT}") + if(WIN32) + message(STATUS "When specifying a path for Windows, use forward slahes, or double backslashes.") + endif() + message(STATUS "CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT sdkconfig setting = ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") + message(STATUS "WOLFSSL_ROOT Variable defined, but source code not found: ${CURRENT_SEARCH_DIR}") endif() endif() + # we'll start in the CMAKE_CURRENT_SOURCE_DIR, typically [something]/projectname/components/wolfssl message(STATUS "CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}") get_filename_component(CURRENT_SEARCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE) @@ -114,16 +308,47 @@ function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY) return() endif() + # Maintain CURRENT_SEARCH_DIR, but check various suffixes with CURRENT_SEARCH_DIR_ALT if( THIS_USER ) # Check for "wolfssl-[username]" subdirectory as we recurse up the directory tree set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl-${THIS_USER}) - message(STATUS "Looking in ${CURRENT_SEARCH_DIR}") + message(STATUS "Looking in ${CURRENT_SEARCH_DIR_ALT}") - #if(EXISTS ${CURRENT_SEARCH_DIR_ALT} AND IS_DIRECTORY ${CURRENT_SEARCH_DIR_ALT} AND EXISTS "${CURRENT_SEARCH_DIR_ALT}/wolfcrypt/src") IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL ) if ( FOUND_WOLFSSL ) - message(STATUS "Found wolfssl in user-suffix CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}") - set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR_ALT} PARENT_SCOPE) + message(STATUS "Found wolfssl in user-suffix CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}") + set(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR_ALT}") + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) + return() + endif() + endif() + + if ( FOUND_WOLFSSL ) + # if we already found the source, skip attempt of "wolfssl-master" + else() + set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl-master) + message(STATUS "Looking in ${CURRENT_SEARCH_DIR_ALT}") + + IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL ) + if ( FOUND_WOLFSSL ) + message(STATUS "Found wolfssl in master-suffix CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}") + set(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR_ALT}") + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) + return() + endif() + endif() + + if ( FOUND_WOLFSSL ) + # if we already found the source, skip attempt of "wolfssl" + else() + set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl) + message(STATUS "Looking in ${CURRENT_SEARCH_DIR_ALT}") + + IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL ) + if ( FOUND_WOLFSSL ) + message(STATUS "Found wolfssl in CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}") + set(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR_ALT}") + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) return() endif() endif() @@ -143,7 +368,8 @@ function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY) get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" DIRECTORY) message(STATUS "Next CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}") if( "${PRIOR_SEARCH_DIR}" STREQUAL "${CURRENT_SEARCH_DIR}" ) - # when the search directory is empty, we'll give up + # When the parent is current directory, cannot go any further. We didn't find wolfssl. + # When the search directory is empty, we'll give up. set(CURRENT_SEARCH_DIR "") endif() endwhile() @@ -154,17 +380,64 @@ endfunction() # Example usage: +# +# Simply find the WOLFSSL_DIRECTORY by searching parent directories: +# FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) +# +message(STATUS "CONFIG_TARGET_PLATFORM = ${CONFIG_TARGET_PLATFORM}") +# Check for environment variable that may be assigned to macros +ENVIRONMENT_VAR_TO_MACRO("GENERATE_MACHINE_PARSEABLE_REPORT" "1") +ENVIRONMENT_VAR_TO_MACRO("WOLFSSL_BENCHMARK_FIXED_CSV" "1") +# Optional variable inspection +if (0) + get_cmake_property(_variableNames VARIABLES) + list (SORT _variableNames) + message(STATUS "") + message(STATUS "ALL VARIABLES BEGIN") + message(STATUS "") + foreach (_variableName ${_variableNames}) + message(STATUS "${_variableName}=${${_variableName}}") + endforeach() + message(STATUS "") + message(STATUS "ALL VARIABLES END") + message(STATUS "") +endif() + +if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) + # There's no esp_timer, no driver components for the ESP8266 + message(STATUS "Early expansion EXCLUDES for esp8266:") + message(STATUS "THIS_INCLUDE_DRIVER: '${THIS_INCLUDE_DRIVER}'") + message(STATUS "THIS_INCLUDE_TIMER: '${THIS_INCLUDE_TIMER}'") + message(STATUS "Early expansion INCLUDE for esp8266:") + message(STATUS "THIS_INCLUDE_PTHREAD: '${THIS_INCLUDE_PTHREAD}'") + set(THIS_ESP_TLS "") + set(THIS_INCLUDE_DRIVER "") + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_PTHREAD "pthread") +else() + message(STATUS "Early expansion includes esp_timer: ${THIS_INCLUDE_TIMER}") + message(STATUS "Early expansion includes driver: ${THIS_INCLUDE_DRIVER}") + set(THIS_ESP_TLS "esp-tls") + set(THIS_INCLUDE_DRIVER "driver") + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_PTHREAD "") + # Let the app know that we've included the esp-tls component requirement. + # This is critical for use the the esp-tls component. See wolfssl esp_crt_bundle.c file. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_REQUIRED_ESP_TLS=1") +endif() if(CMAKE_BUILD_EARLY_EXPANSION) message(STATUS "wolfssl component CMAKE_BUILD_EARLY_EXPANSION:") idf_component_register( REQUIRES "${COMPONENT_REQUIRES}" PRIV_REQUIRES # esp_hw_support - # esp_timer - # driver # this will typically only be needed for wolfSSL benchmark + "${THIS_ESP_TLS}" + "${THIS_INCLUDE_PTHREAD}" + "${THIS_INCLUDE_TIMER}" + "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark ) else() @@ -173,48 +446,99 @@ else() message(STATUS "wolfssl component config:") message(STATUS "************************************************************************************************") + if ( "${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") + # There's no esp_timer, no driver components for the ESP8266 + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_DRIVER "") + else() + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_DRIVER "driver") + endif() + # search for wolfSSL FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) if(WOLFSSL_ROOT) - message(STATUS "NEW Found wolfssl directory at: ${WOLFSSL_ROOT}") + IS_WOLFSSL_SOURCE("${WOLFSSL_ROOT}" FOUND_WOLFSSL) + if(FOUND_WOLFSSL) + message(STATUS "Found WOLFSSL_ROOT via CMake specification.") + else() + # WOLFSSL_ROOT Path specified in CMakeLists.txt is not a valid path + message(FATAL_ERROR "WOLFSSL_ROOT CMake Variable defined, but path not found: ${WOLFSSL_ROOT}\n" + "Try correcting WOLFSSL_ROOT in your project CMakeFile.txt or setting environment variable.") + # Abort CMake after fatal error. + endif() else() - message(STATUS "NEW wolfssl directory not found.") + message(STATUS "Source code for wolfSSL still not found.") + message(STATUS "Searching from project home: ${CMAKE_HOME_DIRECTORY} ...") + set(WOLFSSL_ROOT "${CMAKE_HOME_DIRECTORY}") + FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) + endif() + + + if(WOLFSSL_ROOT) + message(STATUS "Confirmed wolfssl directory at: ${WOLFSSL_ROOT}") + else() + # Try to allow a more intuitive error that the source code was not found in cmake: + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_WARNING_SOURCE_NOT_FOUND") + + message(STATUS "Failed: wolfssl source code directory not found.") # Abort. We need wolfssl _somewhere_. - message(FATAL_ERROR "Could not find wolfssl in ${WOLFSSL_ROOT}.\n" - "Try setting WOLFSSL_ROOT environment variable or git clone.") + message(STATUS "") + message(STATUS "") + message(STATUS "Could not find wolfssl in any parent directory named wolfssl-${THIS_USER}, wolfssl-master, or wolfssl.\n" + "Try setting WOLFSSL_ROOT environment variable, cmake variable in project, copy source, or use managed components.") + message(STATUS "") + message(STATUS "") + # Abort CMake after fatal error. (or not?) endif() set(INCLUDE_PATH ${WOLFSSL_ROOT}) set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/src/") - if( ${CMAKE_PROJECT_NAME} STREQUAL "wolfssl_benchmark" ) - set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark") - endif() - - if( ${CMAKE_PROJECT_NAME} STREQUAL "wolfssl_test" ) - set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/test") + # During regression tests, optionally copy source locally and use: set(USE_LOCAL_TEST_BENCH 1) + set(USE_LOCAL_TEST_BENCH 0) + if(NOT USE_LOCAL_TEST_BENCH) + if( "${CMAKE_PROJECT_NAME}" STREQUAL "hello-world" ) + message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/benchmark") + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark") + endif() + + if( "${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_benchmark" ) + message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/benchmark") + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark") + endif() + + if( "${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_test" ) + message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/test") + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/test") + endif() endif() + message(STATUS "WOLFSSL_EXTRA_PROJECT_DIR = ${WOLFSSL_EXTRA_PROJECT_DIR}") set(COMPONENT_SRCDIRS "\"${WOLFSSL_ROOT}/src/\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif/esp_crt_bundle\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/atmel\"" "\"${WOLFSSL_EXTRA_PROJECT_DIR}\"" ) # COMPONENT_SRCDIRS message(STATUS "This COMPONENT_SRCDIRS = ${COMPONENT_SRCDIRS}") + # wolfSSL user_settings.h may be in the local project. + # TODO check if exists and possibly set to ESP-IDF set(WOLFSSL_PROJECT_DIR "${CMAKE_HOME_DIRECTORY}/components/wolfssl") - add_definitions(-DWOLFSSL_USER_SETTINGS_DIR="${WOLFSSL_PROJECT_DIR}/include/user_settings.h") - + string(REPLACE "/" "//" STR_WOLFSSL_PROJECT_DIR "${WOLFSSL_PROJECT_DIR}") + add_compile_definitions(WOLFSSL_USER_SETTINGS_DIR="${STR_WOLFSSL_PROJECT_DIR}/include/user_settings.h") + message(STATUS "Added definition for user_settings.h: -DWOLFSSL_USER_SETTINGS_DIR=\"${STR_WOLFSSL_PROJECT_DIR}//include//user_settings.h\"") # Espressif may take several passes through this makefile. Check to see if we found IDF string(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "" WOLFSSL_FOUND_IDF) # get a list of all wolfcrypt assembly files; we'll exclude them as they don't target Xtensa file(GLOB EXCLUDE_ASM *.S) - file(GLOB_RECURSE EXCLUDE_ASM ${CMAKE_SOURCE_DIR} "${WOLFSSL_ROOT}/wolfcrypt/src/*.S") + file(GLOB EXCLUDE_ASM ${CMAKE_SOURCE_DIR} "${WOLFSSL_ROOT}/wolfcrypt/src/*.S") message(STATUS "IDF_PATH = $ENV{IDF_PATH}") message(STATUS "PROJECT_SOURCE_DIR = ${PROJECT_SOURCE_DIR}") @@ -237,11 +561,12 @@ else() message(STATUS "Remove either the local project component: ${WOLFSSL_PROJECT_DIR} ") message(STATUS "or the Espressif shared component installed at: $ENV{IDF_PATH}/components/wolfssl/ ") message(STATUS "") - message(FATAL_ERROR "Please use wolfSSL in either local project or Espressif components, but not both.") message(STATUS "") message(STATUS "**************************************************************************************") message(STATUS "") + message(STATUS "Please use wolfSSL in either local project or Espressif components, but not both.") + # Optional: if you change the above FATAL_ERROR to STATUS you can warn at runtime with this macro definition: set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING") @@ -291,6 +616,7 @@ else() message(FATAL_ERROR "Found stray wolfSSL user_settings.h in " "${WOLFSSL_ROOT}/include/user_settings.h " " (please move it to ${WOLFSSL_PROJECT_DIR}/include/user_settings.h )") + # Abort CMake after fatal error. else() # we won't overwrite an existing user settings file, just note that we already have one: if( EXISTS "${WOLFSSL_PROJECT_DIR}/include/user_settings.h" ) @@ -347,7 +673,9 @@ else() # depending on the environment, we may need to swap backslashes with forward slashes string(REPLACE "\\" "/" RTOS_IDF_PATH "$ENV{IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") - string(REPLACE "\\" "/" WOLFSSL_ROOT ${WOLFSSL_ROOT}) + if(WOLFSSL_ROOT) + string(REPLACE "\\" "/" WOLFSSL_ROOT ${WOLFSSL_ROOT}) + endif() if(IS_DIRECTORY "${RTOS_IDF_PATH}") message(STATUS "Found current RTOS path: ${RTOS_IDF_PATH}") @@ -360,21 +688,22 @@ else() message(STATUS "Could not find RTOS path") endif() endif() - - + message(STATUS "THIS_IDF_PATH = $THIS_IDF_PATH") + # wolfSSL-specific include directories set(COMPONENT_ADD_INCLUDEDIRS - "./include" # this is the location of wolfssl user_settings.h + "./include" # this is the location of local project wolfssl user_settings.h "\"${WOLFSSL_ROOT}/\"" "\"${WOLFSSL_ROOT}/wolfssl/\"" "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/\"" + "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/port/Espressif\"" "\"${RTOS_IDF_PATH}/\"" # wolfSSL release after v5.7 includes WiFi, time, and mem/debug helpers - ${THIS_IDF_PATH}/components/esp_event/include - ${THIS_IDF_PATH}/components/esp_netif/include - ${THIS_IDF_PATH}/components/esp_wifi/include + "${THIS_IDF_PATH}/components/esp_event/include" + "${THIS_IDF_PATH}/components/esp_netif/include" + "${THIS_IDF_PATH}/components/esp_wifi/include" ) - + # Optionally include cryptoauthlib if present if(IS_DIRECTORY ${IDF_PATH}/components/cryptoauthlib) list(APPEND COMPONENT_ADD_INCLUDEDIRS "../cryptoauthlib/lib") endif() @@ -383,7 +712,7 @@ else() list(APPEND COMPONENT_ADD_INCLUDEDIRS "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/\"") - + # Some files are known to be included elsewhere, or not used for Espressif set(COMPONENT_SRCEXCLUDE "\"${WOLFSSL_ROOT}/src/bio.c\"" "\"${WOLFSSL_ROOT}/src/conf.c\"" @@ -399,8 +728,8 @@ else() "\"${WOLFSSL_ROOT}/src/ssl_sess.c\"" # included by ssl.c "\"${WOLFSSL_ROOT}/src/x509.c\"" "\"${WOLFSSL_ROOT}/src/x509_str.c\"" - "\"${WOLFSSL_ROOT}/wolfcrypt/src/ext_kyber.c\"" # external Kyber disabled by default - "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/ext_kyber.h\"" # external Kyber disabled by default + "\"${WOLFSSL_ROOT}/wolfcrypt/src/ext_kyber.c\"" # external non-wolfssl Kyber disabled by default + "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/ext_kyber.h\"" # external non-wolfssl Kyber disabled by default "\"${WOLFSSL_ROOT}/wolfcrypt/src/evp.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/misc.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_arm32.c\"" @@ -411,6 +740,7 @@ else() "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_cortexm.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_x86_64.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_x86_64_asm.S\"" + "\"${WOLFSSL_ROOT}/examples\"" # Examples are distributed in Managed Components, but not part of a project. "\"${EXCLUDE_ASM}\"" ) @@ -432,22 +762,144 @@ else() # see https://docs.espressif.com/projects/esp-idf/en/stable/esp32/migration-guides/release-5.x/build-system.html?highlight=space%20path # set(EXTRA_COMPONENT_DIRS "${COMPONENT_SRCDIRS}") - idf_component_register( - SRC_DIRS "${COMPONENT_SRCDIRS}" - INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}" - REQUIRES "${COMPONENT_REQUIRES}" - EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}" - PRIV_REQUIRES esp_timer driver # this will typically only be needed for wolfSSL benchmark - ) - # some optional diagnostics - if (1) + + if(WOLFSSL_ROOT) + # Only register the component if we found wolfSSL source. + # This is important to allow Cmake to finish to completion, otherwise the UI + # may not be able to display the Kconfig settings to fix a bad or missing source. + idf_component_register( + SRC_DIRS "${COMPONENT_SRCDIRS}" + INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}" + REQUIRES "${COMPONENT_REQUIRES}" + EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}" + PRIV_REQUIRES + "${THIS_ESP_TLS}" + "${THIS_INCLUDE_TIMER}" + "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark + ) + else() + # Register the component simply to allow CMake to complete, but there's no wolfSSL source. + # Expect many other errors, but the project should at least be loadable and UI can edit Kconfig settings. + idf_component_register() + message(STATUS "Warning: wolfSSL component not registered as no source code found (WOLFSSL_ROOT is blank)") + endif() + +# function(WOLFSSL_INIT_CERT_BUNDLE) +if( CONFIG_WOLFSSL_CERTIFICATE_BUNDLE + AND NOT CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + AND NOT ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") + ) + if (CMAKE_BUILD_EARLY_EXPANSION) + message(ERROR "Bundle Cert initialization must occur during CMAKE_BUILD_EARLY_EXPANSION") + endif() + # reminder: we need a value for wolfSSL root first! + if( "${WOLFSSL_ROOT}" STREQUAL "" ) + message(ERROR "Certificate bundles need a value for WOLFSSL_ROOT") + endif() + set(WOLFSSL_ESP_CRT_BUNDLE_DIR ${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif/esp_crt_bundle) + message(STATUS "WOLFSSL_ESP_CRT_BUNDLE_DIR=${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + if(EXISTS "${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + set(bundle_name "x509_crt_bundle_wolfssl") + + # For now the certs are in the same directory + set(DEFAULT_CRT_DIR "${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + + # Generate custom certificate bundle using the generate_cert_bundle utility + set(GENERATE_CERT_BUNDLEPY ${python} ${WOLFSSL_ESP_CRT_BUNDLE_DIR}/gen_crt_bundle.py) + + if(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_all.pem ${DEFAULT_CRT_DIR}/cacrt_local.pem) + elseif(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_CMN) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_all.pem ${DEFAULT_CRT_DIR}/cacrt_local.pem) + list(APPEND args --filter ${DEFAULT_CRT_DIR}/cmn_crt_authorities.csv) + endif() + + # Add deprecated root certs if enabled. This config is not visible if the default cert + # bundle is not selected + if(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEPRECATED_LIST) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_deprecated.pem) + endif() + + if(CONFIG_WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE) + get_filename_component(custom_bundle_path + ${CONFIG_WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE_PATH} ABSOLUTE BASE_DIR "${project_dir}") + list(APPEND crt_paths ${custom_bundle_path}) + message(STATUS "Using a custom wolfSSL bundle path: ${custom_bundle_path}") + else() + message(STATUS "Not using a custom wolfSSL bundle path.") + endif() + list(APPEND args --input ${crt_paths} -q) + + message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") + get_filename_component(crt_bundle + ${bundle_name} + ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") + + message(STATUS "Setting up bundle generate: ${GENERATE_CERT_BUNDLEPY} ${args}") + message(STATUS "Depends on custom bundle path: ${custom_bundle_path}") + message(STATUS "crt_bundle ${crt_bundle}") + message(STATUS "COMPONENT_LIB ${COMPONENT_LIB}") + message(STATUS "GENERATE_CERT_BUNDLEPY ${GENERATE_CERT_BUNDLEPY}") + message(STATUS "args ${args}") + message(STATUS "cert_bundle ${cert_bundle}") + + # Generate bundle according to config + # File is generated at build time, not cmake load + add_custom_command(OUTPUT ${crt_bundle} + COMMAND ${GENERATE_CERT_BUNDLEPY} ARGS ${args} + DEPENDS ${custom_bundle_path} + VERBATIM) + + if(EXISTS "${crt_bundle}") + message(STATUS "Bundle file exists from prior build: ${crt_bundle}") + else() + message(STATUS "Bundle file expected during next build: ${crt_bundle}") + endif() + + # Reminder the file is generated at build time, not cmake load time. + message(STATUS "wolfSSL Cert Bundle File to be created at build time in: ${crt_bundle}") + + add_custom_target(custom_wolfssl_bundle DEPENDS ${cert_bundle}) + + # the wolfSSL crtificate bundle is baked into wolfSSL + add_dependencies(${COMPONENT_LIB} custom_wolfssl_bundle) + + # COMPONENT_LIB may vary: __idf_wolfssl, __idf_esp_wolfssl, etc + # target_add_binary_data(__idf_wolfssl ${crt_bundle} BINARY) + target_add_binary_data(${COMPONENT_LIB} ${crt_bundle} BINARY) + set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + APPEND PROPERTY ADDITIONAL_CLEAN_FILES + "${crt_bundle}") + else() + message(STATUS "WARNING: CONFIG_WOLFSSL_CERTIFICATE_BUNDLE enabled but directory not found: ${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + endif() +endif() + +# endfunction() # WOLFSSL_INIT_CERT_BUNDLE + + # Some optional diagnostics. Verbose ones are truncated. + if (VERBOSE_COMPONENT_MESSAGES) get_cmake_property(_variableNames VARIABLES) list (SORT _variableNames) message(STATUS "") message(STATUS "ALL VARIABLES BEGIN") message(STATUS "") foreach (_variableName ${_variableNames}) - message(STATUS "${_variableName}=${${_variableName}}") + if ( ("${_variableName}" STREQUAL "bootloader_binary_files") + OR ("${_variableName}" STREQUAL "Component paths") + OR ("${_variableName}" STREQUAL "component_targets") + OR ("${_variableName}" STREQUAL "__COMPONENT_TARGETS") + OR ("${_variableName}" STREQUAL "CONFIGS_LIST") + OR ("${_variableName}" STREQUAL "__CONFIG_VARIABLES") + OR ("${_variableName}" STREQUAL "val") + OR ("${_variableName}" MATCHES "^__idf_") + ) + # Truncate the displayed value: + string(SUBSTRING "${${_variableName}}" 0 70 truncatedValue) + message(STATUS "${_variableName} = ${truncatedValue} ... (truncated)") + else() + message(STATUS "${_variableName}=${${_variableName}}") + endif() endforeach() message(STATUS "") message(STATUS "ALL VARIABLES END") @@ -455,6 +907,12 @@ else() endif() # target_sources(wolfssl PRIVATE "\"${WOLFSSL_ROOT}/wolfssl/\"" "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt\"") + message(STATUS "DETECTED_PROJECT_NAME=${CMAKE_PROJECT_NAME}") + message(STATUS "COMPONENT_TARGET=${COMPONENT_TARGET}") + target_compile_definitions(${COMPONENT_TARGET} PRIVATE DETECTED_PROJECT_NAME="${CMAKE_PROJECT_NAME}") + if( "${CMAKE_PROJECT_NAME}" STREQUAL "esp_http_client_example" ) + target_compile_definitions(${COMPONENT_TARGET} PRIVATE APP_ESP_HTTP_CLIENT_EXAMPLE="y") + endif() endif() # CMAKE_BUILD_EARLY_EXPANSION @@ -500,7 +958,7 @@ function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) message(STATUS "Found ${VAR_OUPUT}=${VAR_VALUE}") # the interesting part is defining the VAR_OUPUT name a value to use in the app - add_definitions(-D${VAR_OUPUT}=\"${VAR_VALUE}\") + add_compile_definitions(${VAR_OUPUT}=\"${VAR_VALUE}\") else() # if we get here, check the execute_process command and parameters. message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT") @@ -508,33 +966,89 @@ function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) endif() endfunction() # LIBWOLFSSL_SAVE_INFO +execute_process( + COMMAND ${git_cmd} "rev-parse" "--is-inside-work-tree" + OUTPUT_VARIABLE IS_GIT_REPO + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + # create some programmatic #define values that will be used by ShowExtendedSystemInfo(). # see wolfcrypt\src\port\Espressif\esp32_utl.c -if(NOT CMAKE_BUILD_EARLY_EXPANSION) +if(NOT CMAKE_BUILD_EARLY_EXPANSION AND WOLFSSL_ROOT AND (IS_GIT_REPO STREQUAL "true")) set (git_cmd "git") message(STATUS "Adding macro definitions:") # LIBWOLFSSL_VERSION_GIT_ORIGIN: git config --get remote.origin.url - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "config" "--get" "remote.origin.url" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "config" "--get" "remote.origin.url" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_ORIGIN "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_BRANCH: git rev-parse --abbrev-ref HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--abbrev-ref" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--abbrev-ref" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_BRANCH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_HASH: git rev-parse HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_SHORT_HASH: git rev-parse --short HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_SHORT_HASH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_HASH_DATE git show --no-patch --no-notes --pretty=\'\%cd\' - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} + "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH_DATE "${TMP_OUT}" "${TMP_RES}") - message(STATUS "************************************************************************************************") - message(STATUS "wolfssl component config complete!") - message(STATUS "************************************************************************************************") + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_WOLFSSL_ROOT "${WOLFSSL_ROOT}" "${TMP_RES}") + endif() + +# Ensure flag "-DWOLFSSL_ESPIDF" is already in CMAKE_C_FLAGS if not yet found from project +string(FIND "${CMAKE_C_FLAGS}" "-DWOLFSSL_ESPIDF" FLAG_ALRREADY_FOUND_WOLFSSL_ESPIDF) + +if(FLAG_ALRREADY_FOUND_WOLFSSL_ESPIDF EQUAL -1) + # Flag not found, append it + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESPIDF") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +endif() + +if(WOLFSSL_ROOT) + message(STATUS "Using wolfSSL in ${WOLFSSL_ROOT}") + + # PlatformIO does not process script from from the Espressif cmake process. + # We need to know where wolfSSL source code was found, so save it in the + # PIO_WOLFSSL_ROOT environment variable to later be read by extra_script.py + + set(ENV{PIO_WOLFSSL_ROOT} "${WOLFSSL_ROOT}") + message(STATUS "PIO_WOLFSSL_ROOT = $ENV{PIO_WOLFSSL_ROOT}") + message(STATUS "PLATFORMIO_BUILD_DIR = $ENV{PLATFORMIO_BUILD_DIR}") + # See esp-tls Kconfig; menu "ESP-TLS", ESP_TLS_LIBRARY_CHOOSE + if(CONFIG_ESP_TLS_USING_WOLFSSL) + if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) + message(STATUS "This version of wolfSSL is not supported on the ESP8266 esp-tls at this time. Check ESP-TLS config") + else() + message(STATUS "wolfSSL will be used for ESP-TLS") + endif() + else() + message(STATUS "WARNING: wolfSSL NOT selected for ESP-TLS. Features and performance will be limited.") + endif() +else() + message(STATUS "") + message(STATUS "Consider setting WOLFSSL_ROOT environment variable, use Kconfig setting, or set manually in this cmake file, above.") + message(STATUS "") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "ERROR: Could not find wolfSSL Source Code") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") +endif() + +message(STATUS "************************************************************************************************") +message(STATUS "wolfSSL component config complete!") +message(STATUS "************************************************************************************************") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/Kconfig b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/Kconfig new file mode 100644 index 000000000..150913190 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/Kconfig @@ -0,0 +1,523 @@ +# Kconfig template +# +# Copyright (C) 2006-2025 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 +# + +# Kconfig File Version 5.7.2.001 for esp-idf integration + +# Kconfig Format Rules +# +# See: +# https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/kconfig.html +# +# Format rules for Kconfig files are as follows: +# +# Option names in any menus should have consistent prefixes. The prefix +# currently should have at least 3 characters. +# +# The unit of indentation should be 4 spaces. All sub-items belonging to a +# parent item are indented by one level deeper. For example, menu is indented +# by 0 spaces, config menu by 4 spaces, help in config by 8 spaces, and the +# text under help by 12 spaces. +# +# No trailing spaces are allowed at the end of the lines. +# +# The maximum length of options is NOT 50 characters as documented. +# kconfcheck will complain that options should be 40 at most. +# +# Fix option lengths first. Superfluous errors on other lines may occur. +# +# The maximum length of lines is 120 characters. +# +# python -m kconfcheck +# +# --------------------------------------------------------------------------------------------------------------------- +# Begin main wolfSSL configuration menu +# --------------------------------------------------------------------------------------------------------------------- +# See ESP-IDF esp-tls component for config TLS_STACK_WOLFSSL + +menu "wolfSSL" + + menu "Hardening" + config ESP_WOLFSSL_WC_NO_HARDEN + bool "Disable wolfSSL hardening" + default n + help + Sets WC_NO_HARDEN + + config ESP_WOLFSSL_TFM_TIMING_RESISTANT + bool "Enable TFM Timing Resistant Code" + default n + help + Sets TFM_TIMING_RESISTANT. + + endmenu # Hardening + + config ESP_WOLFSSL_ENABLE_BENCHMARK + bool "Enable wolfSSL Benchmark Library" + default n + help + Enables wolfcrypt/benchmark/benchmark.c code for benchmark metrics. Disables NO_CRYPT_BENCHMARK. + + + menu "Benchmark Debug" + config ESP_DEBUG_WOLFSSL_BENCHMARK_TIMING + bool "Enable benchmark timing debug" + depends on ESP_WOLFSSL_ENABLE_BENCHMARK + default n + help + Enable wolfssl debug for benchmark metric timing (CPU Cycles, RTOS ticks, etc). + + config ESP_WOLFSSL_BENCHMARK_TIMER_DEBUG + bool "Enable benchmark timer debug" + depends on ESP_WOLFSSL_ENABLE_BENCHMARK + default n + help + Turn on timer debugging (used when CPU cycles not available) + + endmenu # Benchmark Debug + + # ----------------------------------------------------------------------------------------------------------------- + # wolfCrypt Test + # ----------------------------------------------------------------------------------------------------------------- + config ESP_WOLFSSL_ENABLE_TEST + bool "Enable wolfCrypt Test Library" + default n + help + Enables wolfcrypt/test/test.c code for testing. Disables NO_CRYPT_TEST. + + menu "wolfCrypt tests" + config WOLFSSL_HAVE_WOLFCRYPT_TEST_OPTIONS + bool "Enable wolfCrypt Test Options" + depends on ESP_WOLFSSL_ENABLE_TEST + default n + help + Enables HAVE_WOLFCRYPT_TEST_OPTIONS + + config TEST_ESPIDF_ALL_WOLFSSL + bool "Enable all features to use in tests" + depends on ESP_WOLFSSL_ENABLE_TEST + default n + help + Enables TEST_ESPIDF_ALL_WOLFSSL + + endmenu # wolfCrypt tests + + # ----------------------------------------------------------------------------------------------------------------- + # Apple HomeKit Options + # ----------------------------------------------------------------------------------------------------------------- + menu "Apple HomeKit" + config WOLFSSL_APPLE_HOMEKIT + bool "Enable Apple HomeKit options" + default n + help + Enables FP_MAX_BITS (8192 * 2), SRP, ChaCha, Poly1305, Base64 encoding needed for Apple HomeKit. + endmenu # Apple HomeKit + # ----------------------------------------------------------------------------------------------------------------- + + config ESP_WOLFSSL_DISABLE_MY_ECC + bool "Disable ECC in my project" + default "n" + help + ECC is enabled by default. Select this option to disable. + + config ESP_WOLFSSL_ENABLE_MY_USE_RSA + bool "Enable RSA in my project" + default "n" + help + RSA is disabled by default. Select this option to enable. + + config ESP_WOLFSSL_BENCHMARK + bool "Enable wolfSSL Benchmark" + default n + help + Enables user settings relevant to benchmark code + + config ESP_TLS_USING_WOLFSSL_SPECIFIED + bool "Use the specified wolfssl for ESP-TLS" + default Y + help + Includes wolfSSL from specified directory (not using esp-wolfssl). + + config ESP_WOLFSSL_NO_USE_FAST_MATH + bool "Disable FAST_MATH library and all ESP32 Hardware Acceleration" + select ESP_WOLFSSL_NO_HW + select ESP_WOLFSSL_NO_HW_AES + select ESP_WOLFSSL_NO_HW_HASH + select ESP_WOLFSSL_NO_HW_RSA_PRI + select ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + default n + help + When disabling all hardware acceleration for smaller memory footprint, + disabling TFM fast math provides faster wolfSSL software algorithms in an + even smaller flash memory footprint. + + menu "Protocol Config" + config WOLFSSL_HAVE_ALPN + bool "Enable ALPN (Application Layer Protocol Negotiation) in wolfSSL" + default y + + config WOLFSSL_ALLOW_TLS13 + bool "Allow TLS 1.3" + default y + help + Allow TLS to fallback to TLS1.2. Memory footprint will likely be larger for TLS1.2. + When disabled HTTPS and MQTT over TLS connections will fail if TLS1.3 not accepted. + + config WOLFSSL_ALLOW_TLS12 + bool "Allow TLS 1.2" + default n + help + Allow TLS to fallback to TLS1.2. Memory footprint will likely be larger for TLS1.2. + When disabled HTTPS and MQTT over TLS connections will fail if TLS1.3 not accepted. + + config WOLFSSL_HAVE_TLS_EXTENSIONS + bool "Enable TLS Extensions" + default y + help + Sets HAVE_TLS_EXTENSIONS which is needed for TLS 1.3, SNI, ALPN, and more. + + config WOLFSSL_ALT_CERT_CHAINS + bool "Enable Alternate Certificate Chains" + default n + help + The option relaxes the default strict wolfSSL certificate chain processing. This + will typically need to be enabled when loading only a CA file. Typically solves + the -188 ASN_NO_SIGNER_E error. Use with caution. + + config WOLFSSL_HAVE_OCSP + bool "Enable OCSP (Online Certificate Status Protocol) in wolfSSL" + default n + help + Sets HAVE_OCSP + + endmenu # Protocol Config + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + config TLS_STACK_WOLFSSL + # Invisible option that locks TLS_STACK_WOLFSSL to ESP_TLS_USING_WOLFSSL + bool + default n + select FREERTOS_ENABLE_BACKWARD_COMPATIBILITY + help + Includes wolfSSL in ESP-TLS so that it can be compiled with wolfSSL as its SSL/TLS library. + Enabled when wolfSSL is selected in ESP_TLS_LIBRARY_CHOOSE. + + menu "wolfSSL ESP-TLS" + depends on ESP_TLS_USING_WOLFSSL + + menu "Certificate Bundle" + depends on ESP_TLS_USING_WOLFSSL + + config WOLFSSL_CERTIFICATE_BUNDLE + bool "Enable trusted root certificate bundle" + default y if ESP_TLS_USING_WOLFSSL + default n + depends on ESP_TLS_USING_WOLFSSL + help + Enable support for large number of default root certificates + + When enabled this option allows user to store default as well + as customer specific root certificates in compressed format rather + than storing full certificate. For the root certificates the public key and the subject name + will be stored. + + config WOLFSSL_NO_ASN_STRICT + bool "Relax Certificate ASN Strict Checks" + default n + depends on ESP_TLS_USING_WOLFSSL + help + Allows sub-optimal certificate ASN checks. Unless using a bundle with known issues, + it is recommended to NOT enable this. + + config WOLFSSL_ASN_ALLOW_0_SERIAL + bool "Allow cert missing an ASN Serial Number" + default y + depends on ESP_TLS_USING_WOLFSSL + help + Although not recommended, there may be certificates in the bundle that are missing + a serial number. This option allows the missing value without having to fully + disable strict ASN checking with WOLFSSL_NO_ASN_STRICT. + + choice WOLFSSL_DEFAULT_CERTIFICATE_BUNDLE + bool "Default certificate bundle options" + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + default WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL + + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL + bool "Use the full default certificate bundle" + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_CMN + bool "Use only the most common certificates from the default bundles" + help + Use only the most common certificates from the default bundles, reducing the size with 50%, + while still having around 99% coverage. + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + bool "Do not use the default certificate bundle" + endchoice + + config WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + default n + bool "Add custom certificates to the default bundle" + config WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE_PATH + depends on WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + string "Custom certificate bundle path" + help + Name of the custom certificate directory or file. This path is evaluated + relative to the project root directory. + + config WOLFSSL_CERTIFICATE_BUNDLE_DEPRECATED_LIST + bool "Add deprecated root certificates" + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL && !WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + help + Include the deprecated list of root certificates in the bundle. + This list gets updated when a certificate is removed from the Mozilla's + NSS root certificate store. This config can be enabled if you would like + to ensure that none of the certificates that were deployed in the product + are affected because of the update to bundle. In turn, enabling this + config keeps expired, retracted certificates in the bundle and it may + pose a security risk. + + - Deprecated cert list may grow based based on sync with upstream bundle + - Deprecated certs would be be removed in ESP-IDF (next) major release + + config WOLFSSL_CERTIFICATE_BUNDLE_MAX_CERTS + int "Maximum no of certificates allowed in certificate bundle" + default 200 + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + + endmenu + endmenu # wolfSSL ESP-TLS + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + config ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + bool "Modify default hardware acceleration settings" + default n + help + When disabling all hardware acceleration for smaller memory footprint, + disabling TFM fast math provides faster wolfSSL software algorithms in an + even smaller flash memory footprint. + Typically used for debugging, analysis, or optimizations. The default + hardware acceleration features can be each manually adjusted. + + menu "wolfSSL Hardware Acceleration" + + config ESP_WOLFSSL_NO_ESP32_CRYPT + bool "Disable all ESP32 Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + select ESP_WOLFSSL_NO_HW_AES + select ESP_WOLFSSL_NO_HW_HASH + select ESP_WOLFSSL_NO_HW_RSA_PRI + select ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + help + Hardware acceleration enabled by default. When selected defines: NO_ESP32_CRYPT. + Consider disabling FASTMATH (other libraries are faster in software and smaller) + + config ESP_WOLFSSL_NO_HW_AES + bool "Disable all ESP32 AES Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default.When selected defines: NO_HW_AES + + config ESP_WOLFSSL_NO_HW_HASH + bool "Disable all ESP32 SHA Hash Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_HASH + + config ESP_WOLFSSL_NO_HW_RSA_PRI + bool "Disable all ESP32 RSA Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + select ESP_WOLFSSL_NO_HW_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI + + config ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + bool "Disable all ESP32 Multiplication Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI_MP_MUL + + config ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + bool "Disable all ESP32 Modular Multiplication Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI_MULMOD + + config ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + bool "Disable all ESP32 RSA Exponential Math Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. + Select this option to force disable: NO_HW_RSA_PRI_EXPTMOD + + config ESP_WOLFSSL_DEBUG_ESP_HW_MULTI_RSAMAX_BITS + bool "Enable debugging of RSA Multiplication operand length" + default n + help + Prints an esp log warning to the default console UART when one of the + multiplication operands exceeds the maximum size supported by hardware, + requiring fallback to software. This can be helpful to pick key sizes + when performance is critical. See also metrics for counting instances. + + config ESP_WOLFSSL_DEBUG_ESP_HW_MOD_RSAMAX_BITS + bool "Enable debugging of RSA Modular operand length" + default n + help + Prints an esp log warning to the default console UART when one of the + modular math operands exceeds the maximum size supported by hardware, + requiring fallback to software. This can be helpful to pick key sizes + when performance is critical. See also metrics for counting instances. + + endmenu # wolfSSL Hardware Acceleration + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Experimental Options" + + config ESP_WOLFSSL_EXPERIMENTAL_SETTINGS + bool "Enable wolfSSL Experimental Settings" + default n + help + Enables experimental settings for wolfSSL. See documentation. + + config ESP_WOLFSSL_ENABLE_KYBER + bool "Enable wolfSSL Kyber" + default n + help + Enable debugging messages for wolfSSL. See user_settings.h for additional debug options. + + endmenu # wolfSSL Experimental Options + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Debug Options" + config ESP_WOLFSSL_DEBUG_WOLFSSL + bool "Enable wolfSSL Debugging" + default n + help + Enable debugging messages for wolfSSL. See user_settings.h for additional debug options. + + config ESP_WOLFSSL_TEST_LOOP + bool "Run test apps in a loop until failure" + default y + help + Enable a loop wrapper for benchmark, http_client, and wolfssl test apps. + + endmenu # wolfSSL Debug Options + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Customization" + config CUSTOM_SETTING_WOLFSSL_ROOT + string "Enter a path for wolfSSL source code" + default "~/workspace/wolfssl" + help + This option lets you specify a directory for the wolfSSL source code (typically a git clone). + Enter the path using forward slashes (e.g., C:/myfolder/mysubfolder) or double backslashes + (e.g., C:\\myfolder\\mysubfolder). + + endmenu # wolfSSL Customization + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "Component Config" + config IGNORE_ESP_IDF_WOLFSSL_COMPONENT + bool "Ignore the ESP-IDF component of wolfSSL (if present)" + default n + help + Ignores wolfSSL present in the esp-idf/components directory. Requires wolfssl as a local component. + + config IGNORE_LOCAL_WOLFSSL_COMPONENT + bool "Ignore the local component of wolfSSL (if present)" + default n + help + Ignores wolfSSL present in the local project components directory. + Requires wolfssl as a ESP-IDF component. + + endmenu # Component Config + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "Utility Config" + config USE_WOLFSSL_ESP_SDK_TIME + bool "Enable wolfSSL time helper functions" + default n + help + Enables use of various time and date setting functions found in the esp-sdk-lib.h file. + + config USE_WOLFSSL_ESP_SDK_WIFI + bool "Enable wolfSSL WiFi helper functions" + default n + help + Enables use of various time and date setting functions found in the esp-sdk-lib.h file. + + endmenu # Utility Config +endmenu # wolfSSL +# --------------------------------------------------------------------------------------------------------------------- + + +# --------------------------------------------------------------------------------------------------------------------- +menu "wolfSSH" + config ESP_ENABLE_WOLFSSH + bool "Enable wolfSSH options" + default n + help + Enables WOLFSSH_TERM, WOLFSSL_KEY_GEN, WOLFSSL_PTHREADS, WOLFSSH_TEST_SERVER, WOLFSSH_TEST_THREADING + + config ESP_WOLFSSL_DEBUG_WOLFSSH + bool "Enable wolfSSH debugging" + default n + help + Enable wolfSSH debugging macro. See user_settings.h + +endmenu # wolfSSH +# --------------------------------------------------------------------------------------------------------------------- + +# --------------------------------------------------------------------------------------------------------------------- +menu "wolfMQTT" + config ESP_ENABLE_WOLFMQTT + bool "Enable wolfMQTT options" + default n + help + Enables WOLFMQTT + + config ESP_WOLFSSL_DEBUG_WOLFMQTT + bool "Enable wolfMQTT debugging" + default n + help + Enable wolfMQTT debugging macro. See user_settings.h + +endmenu # wolfMQTT +# --------------------------------------------------------------------------------------------------------------------- diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/README.md b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/README.md new file mode 100644 index 000000000..d77912416 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/README.md @@ -0,0 +1,162 @@ +# wolfSSL Espressif Component + +This is the directory for wolfSSL as an Espressif ESP-IDF component. + +Other options are available, such as installing wolfSSL as a local _project_ component using the [Managed Component](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/). + +Enabling this wolfSSL ESP-IDF component allows other ESP-IDF libraries such as those that depend on [ESP-TLS](https://github.com/espressif/esp-idf/tree/master/components/esp-tls) +to also use the wolfSSL library. (See [github.com/wolfSSL/wolfssl](https://github.com/wolfSSL/wolfssl)) + +The wolfSSL source code is not included here. Instead, the `idf.py menuconfig` option can be used to configure the +`sdkconfig` file setting: `CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT` to point to the desired wolfSSL code. + +## Directory Contents + +This directory must contain, at a minimum: + +- `CMakeLists.txt` +- `./include/user_settings.h` + +The directory should also contain: +- `Kconfig` +- `component.mk` + +The directory may contain wolfSSL source, for example with a [Managed Component](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/), +or if the `setup.sh` script was used from [wolfSSL/IDE/Espressif/ESP-IDF](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF). + + +Under normal circumstances when the wolfSSL source is not included here, the `CMakeLists.txt` will search for it in this order: + +- A hard-coded `WOLFSSL_ROOT` cmake variable. +- `WOLFSSL_ROOT` Environment Variable +- The `CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT` value in the `sdkconfig` file, from the `Kconfig` option. +- Any parent directories, up to the root (if this directory is in the ESP-IDF components) +- Any parent directories, up to the root (if this directory is a project component) + +While recursing up the directory tree, the following names of wolfSSL directories will be considered: + +- `wolfssl-[current user name]` +- `wolfssl-master` +- `wolfssl` + +## Getting Started + +See the `Espressif Getting Started Guide`. + +``` +# Set environment variable to ESP-IDF location +# For example, VisualGDB in WSL +WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.2 +WRK_IDF_PATH=/mnt/c/SysGCC/esp32-master/esp-idf/v5.3-master + +# Or wherever the ESP-IDF is installed: +WRK_IDF_PATH=~/esp/esp-idf + +echo "Run export.sh from ${WRK_IDF_PATH}" +. ${WRK_IDF_PATH}/export.sh + +cd [your project] + +idf.py menuconfig +``` + +Enable wolfSSL to be used in the ESP-TLS: + +``` +Component config ---> + ESP-TLS ---> + Choose SSL/TLS library for ESP-TLS (See help for more Info) + (X) wolfSSL (License info in wolfSSL directory README) +``` + +Adjust wolfSSL settings, such as path to source code as needed: + +``` +Component config ---> + wolfSSL ---> + [*] Include wolfSSL in ESP-TLS + [*] Use the specified wolfssl for ESP-TLS + (~/workspace/wolfssl) Enter a path for wolfSSL source code +``` + +## Configuration + +All settings for wolfSSL are adjusted in the [include/user_settings.h](./include/user_settings.h) file. + +The `user_settings.h` file should not be included directly. Instead, `#include ` +before any other wolfSSL headers, like this: + + +```c +/* ESP-IDF */ +#include +#include "sdkconfig.h" + +/* wolfSSL */ +/* Always include wolfcrypt/settings.h before any other wolfSSL file. */ +/* Reminder: settings.h pulls in user_settings.h; don't include it here. */ +#if defined(WOLFSSL_USER_SETTINGS) + #include + #if defined(WOLFSSL_ESPIDF) + #include + #include + #include + #include + #include + #else + #error "Problem with wolfSSL user_settings. " \ + "Check components/wolfssl/include " \ + "and confirm WOLFSSL_USER_SETTINGS is defined, " \ + "typically in the component CMakeLists.txt" + #endif +#else + /* Define WOLFSSL_USER_SETTINGS project wide for settings.h to include */ + /* wolfSSL user settings in ./components/wolfssl/include/user_settings.h */ + #error "Missing WOLFSSL_USER_SETTINGS in CMakeLists or Makefile:\ + CFLAGS +=-DWOLFSSL_USER_SETTINGS" +#endif +``` + +## Examples + +See the wolfSSL examples: + +- [wolfSSL Core Examples](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples) +- [wolfSSL Additional Examples](https://github.com/wolfSSL/wolfssl-examples/tree/master/ESP32) +- [wolfSSH Core Examples](https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples) +- [wolfSSH Additional Examples](https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif) +- [wolfMQTT Examples](https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples) + +## Platforms + +The ESP-IDF wolfSSL is also available for PlatformIO: + +- [Release wolfSSL](https://registry.platformio.org/search?q=owner%3Awolfssl) +- [Staging / Preview wolfSSL](https://registry.platformio.org/search?q=owner%3Awolfssl-staging) + +The wolfSSL library can also be used for Espressif with Arduino: + +- [arduino.cc/reference/en/libraries/wolfssl](https://www.arduino.cc/reference/en/libraries/wolfssl/) +- [github.com/wolfSSL/Arduino-wolfSSL](https://github.com/wolfSSL/Arduino-wolfSSL) + + +## Additional Information + +- [wolfSSL Documentation](https://www.wolfssl.com/documentation/manuals/wolfssl/index.html) and [docs/espressif](https://www.wolfssl.com/docs/espressif/) +- [wolfSSL FAQ](https://www.wolfssl.com/docs/frequently-asked-questions-faq/) +- [wolfSSL Products](https://www.wolfssl.com/products/) +- [www.wolfssl.com/espressif](https://www.wolfssl.com/espressif/) +- [More...](https://www.wolfssl.com/?s=espressif) + +## Contact + +Have a specific request or questions? We'd love to hear from you! Please contact us at support@wolfssl.com or open an issue on GitHub. + +## Licensing and Support + +wolfSSL (formerly known as CyaSSL) and wolfCrypt are either licensed for use under the GPLv2 (or at your option any later version) or a standard commercial license. For our users who cannot use wolfSSL under GPLv2 (or any later version), a commercial license to wolfSSL and wolfCrypt is available. + +See the LICENSE.txt, visit wolfssl.com/license, contact us at licensing@wolfssl.com or call +1 425 245 8247 + +View Commercial Support Options: [wolfssl.com/products/support-and-maintenance](wolfssl.com/products/support-and-maintenance) + diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/component.mk index 02c36849b..f94bd617d 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/component.mk @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # @@ -18,6 +18,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA # +$(info *********** wolfssl component ************) + # # Component Makefile # @@ -48,21 +50,80 @@ # define it here: CFLAGS +=-DWOLFSSL_USER_SETTINGS +# Note that 4 source files created by autogen are excluded here. +# +# See these files commented out, below. Adjust as needed for your application: +# +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/async.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/selftest.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_first.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_last.o + + # NOTICE: the WOLFSSL_ROOT setting MUST be relative! # See https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/api-guides/build-system.html?highlight=must+relative#optional-component-specific-variables # In the wolfSSL GitHub examples for Espressif: # https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples # When this wolfssl component.mk makefile is in [project]/components/wolfssl -# The root is 7 directories up from here: -WOLFSSL_ROOT := ../../../../../../.. +# The root is 7 directories up from here (the location of of this component.mk): +# +WOLFSSL_ROOT ?= ../../../../../../.. +THIS_DIR := $(shell pwd) +WOLFSSL_ROOT_OBJ := $(THIS_DIR) -# NOTE: The wolfSSL include diretory (e.g. user_settings.h) is +# When running make from commandline or VisualGDB, the current path varies: +ifeq ("$(VISUALGDB_DIR)","") + # current path is typically /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/wolfssl + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL)) +else + # current path is typically /C/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/Debug/wolfssl + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL)) +endif + +# To set the location of a different location, it is best to use relative paths. +# +# Set WOLFSSL_ROOT to a relative path from the current component directory. +# For example, if the wolfssl_client is copied from the examples to test: +# +# cp -r /IDE/Espressif/ESP-IDF/examples/wolfssl_client/* /mnt/c/test/demo +# +# we run make in /mnt/c/test/demo +# component is in /mnt/c/test/demo/components/wolfssl +# wolfssl is in /mnt/c/workspace/wolfssl-master +# +# "/mnt/c" is 4 directories up: +# 2 for `./test/demo` from where we run `make`, plus +# 2 more from the location of `component.mk` located +# in `[current directory]/components/wolfssl`. +# +# Thus we need 4 parent reference to find the relative path to wolfSSL: +# WOLFSSL_ROOT := ../../../../workspace/wolfssl-master + +# Optional CFLAGS (make works without these; for reference only) +# CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl +# CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt +# CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif + +abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) + +# print-wolfssl-path-value: +# @echo "WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)" +# @echo "WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)" + +$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info THIS_DIR defined: $(THIS_DIR)) +$(info WOLFSSL_ROOT_OBJ defined: $(WOLFSSL_ROOT_OBJ)) + +# NOTE: The wolfSSL include directory (e.g. user_settings.h) is # located HERE in THIS project, and *not* in the wolfSSL root. -COMPONENT_ADD_INCLUDEDIRS := ./include +COMPONENT_ADD_INCLUDEDIRS := . +COMPONENT_ADD_INCLUDEDIRS += include COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/. COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif + # COMPONENT_ADD_INCLUDEDIRS += $ENV(IDF_PATH)/components/freertos/include/freertos # COMPONENT_ADD_INCLUDEDIRS += "$ENV(IDF_PATH)/soc/esp32s3/include/soc" @@ -76,27 +137,27 @@ COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/atmel -COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT)/wolfcrypt/src/aes_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/evp.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/misc.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/sha512_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_x25519_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/aes_gcm_x86_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/src/bio.o - +COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/evp.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/misc.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/sha512_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/fe_x25519_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_gcm_x86_asm.o ## ## wolfSSL ## -COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o -# COMPONENT_OBJS += src/conf.o +## reminder object files may end up in `./build` or `build/debug` or `build/release`, depending on build environment & settings. +## +# COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o # part of ssl.c, omitted to avoid "does not need to be compiled separately" +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/conf.o # part of ssl.c COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/crl.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls13.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/internal.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/keys.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ocsp.o -# COMPONENT_OBJS += src/pk.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/pk.o # part of ssl.c COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/quic.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/sniffer.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o @@ -108,8 +169,8 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls13.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/wolfio.o -# COMPONENT_OBJS += src/x509.o -# COMPONENT_OBJS += src/x509_str.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509.o # part of ssl.c +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509_str.o # part of ssl.c ## ## wolfcrypt @@ -118,7 +179,7 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/aes.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/arc4.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/asm.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/asn.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/async.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/async.o # autogen exclusion COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/blake2b.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/blake2s.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/camellia.o @@ -142,7 +203,7 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ed25519.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ed448.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/error.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/evp.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ext_kyber.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_mlkem.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_lms.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_xmss.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/falcon.o @@ -174,7 +235,7 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/rc2.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ripemd.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/rsa.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sakke.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/selftest.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/selftest.o # autogen exclusion COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha256.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha3.o @@ -205,14 +266,14 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/srp.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/tfm.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_dsp.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_encrypt.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_kyber.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_kyber_poly.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_mlkem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_mlkem_poly.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_lms.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_pkcs11.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_port.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_xmss.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_first.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_last.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_first.o # autogen exclusion +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_last.o # autogen exclusion COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfevent.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfmath.o @@ -230,19 +291,16 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_wifi_lib. ## ## wolfcrypt benchmark (optional) ## -## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark ## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark ## ## wolfcrypt test (optional) ## -## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test +## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test/include -## -## wolfcrypt -## -# COMPONENT_PRIV_INCLUDEDIRS += $(PROJECT_PATH)/components/wolfssl/include -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/src +$(info ********** end wolfssl component **********) 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 380da3e69..8da276d1e 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 @@ -1,6 +1,6 @@ -/* user_settings.h +/* wolfssl-component include/user_settings.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -18,29 +18,222 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ +#define WOLFSSL_ESPIDF_COMPONENT_VERSION 0x01 -/* Standardized wolfSSL Espressif ESP32 + ESP8266 user_settings.h V5.6.6-01 */ - -/* This user_settings.h is for Espressif ESP-IDF */ +/* Examples such as test and benchmark are known to cause watchdog timeouts. + * Note this is often set in project Makefile: + * CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 */ +#define WOLFSSL_ESP_NO_WATCHDOG 1 +/* The Espressif project config file. See also sdkconfig.defaults */ #include "sdkconfig.h" -#define DEBUG_WOLFSSL -/* #define DEBUG_WOLFSSL_VERBOSE */ +/* This user_settings.h is for Espressif ESP-IDF + * + * Standardized wolfSSL Espressif ESP32 + ESP8266 user_settings.h V5.7.0-1 + * + * Do not include any wolfssl headers here. + * + * When editing this file: + * ensure all examples match. The template example is the reference. + */ + +/* Naming convention: (see also esp32-crypt.h for the reference source). + * + * CONFIG_ + * This prefix indicates the setting came from the sdkconfig / Kconfig. + * + * May or may not be related to wolfSSL. + * + * The name after this prefix must exactly match that in the Kconfig file. + * + * WOLFSSL_ + * Typical of many, but not all wolfSSL macro names. + * + * Applies to all wolfSSL products such as wolfSSH, wolfMQTT, etc. + * + * May or may not have a corresponding sdkconfig / Kconfig control. + * + * ESP_WOLFSSL_ + * These are NOT valid wolfSSL macro names. These are names only used in + * the ESP-IDF Kconfig files. When parsed, they will have a "CONFIG_" + * suffix added. See next section. + * + * CONFIG_ESP_WOLFSSL_ + * This is a wolfSSL-specific macro that has been defined in the ESP-IDF + * via the sdkconfig / menuconfig. Any text after this prefix should + * exactly match an existing wolfSSL macro name. + * + * Applies to all wolfSSL products such as wolfSSH, wolfMQTT, etc. + * + * These macros may also be specific to only the project or environment, + * and possibly not used anywhere else in the wolfSSL libraries. + */ + +/* The Espressif sdkconfig will have chipset info. +** +** Some possible values: +** +** CONFIG_IDF_TARGET_ESP32 +** CONFIG_IDF_TARGET_ESP32S2 +** CONFIG_IDF_TARGET_ESP32S3 +** CONFIG_IDF_TARGET_ESP32C3 +** CONFIG_IDF_TARGET_ESP32C6 +*/ + +#undef WOLFSSL_ESPIDF +#define WOLFSSL_ESPIDF + +/* Test various user_settings between applications by selecting example apps + * in `idf.py menuconfig` for Example wolfSSL Configuration settings: */ + +/* Turn on messages that are useful to see only in examples. */ +#define WOLFSSL_EXAMPLE_VERBOSITY + +/* Paths can be long, ensure the entire value printed during debug */ +#define WOLFSSL_MAX_ERROR_SZ 500 + +/* wolfSSL Examples: set macros used in example applications. + * + * These Settings NOT available in ESP-IDF (e.g. esp-tls) + * + * Any settings needed by ESP-IDF components should be explicitly set, + * and not by these example-specific settings via CONFIG_WOLFSSL_EXAMPLE_n + * + * ESP-IDF settings should be Kconfig "CONFIG_[name]" values when possible. */ +#if defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TEMPLATE) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/template */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TEST) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_test */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ + #define TEST_ESPIDF_ALL_WOLFSSL +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_BENCHMARK) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ + #define WOLFSSL_BENCHMARK_FIXED_UNITS_KB +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_CLIENT) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_client */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_SERVER) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_server */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfSSH Examples */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSH_TEMPLATE) + /* See https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples/wolfssh_template */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSH_ECHOSERVER) + /* See https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_ESP32_SSH_SERVER) + /* See https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif/ESP32/ESP32-SSH-Server */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_ESP8266_SSH_SERVER) + /* See https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif/ESP8266/ESP8266-SSH-Server */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfMQTT Examples */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFMQTT_TEMPLATE) + /* See https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples/wolfmqtt_template */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFMQTT_AWS_IOT_MQTT) + /* See https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples/AWS_IoT_MQTT */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfTPM Examples */ +#elif defined(CONFIG_WOLFTPM_EXAMPLE_NAME_ESPRESSIF) + /* See https://github.com/wolfSSL/wolfTPM/tree/master/IDE/Espressif */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* Apple HomeKit Examples */ +#elif defined(CONFIG_WOLFSSL_APPLE_HOMEKIT) + /* See https://github.com/AchimPieters/esp32-homekit-demo */ + +/* no example selected */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_NONE) + /* We'll assume the app needs to use wolfSSL sdk lib function */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* Other applications detected by cmake */ +#elif defined(APP_ESP_HTTP_CLIENT_EXAMPLE) + /* The wolfSSL Version of the client example */ + #if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C2) + /* Less memory available, so smaller key sizes: */ + #define FP_MAX_BITS (4096 * 2) + #else + #define FP_MAX_BITS (8192 * 2) + #endif + #define HAVE_ALPN + #define HAVE_SNI + #define OPENSSL_EXTRA_X509_SMALL + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES + #define OPENSSL_EXTRA + #ifndef WOLFSSL_ALWAYS_VERIFY_CB + #define WOLFSSL_ALWAYS_VERIFY_CB + #endif + #ifndef WOLFSSL_VERIFY_CB_ALL_CERTS + #define WOLFSSL_VERIFY_CB_ALL_CERTS + #endif + #ifndef KEEP_PEER_CERT + #define KEEP_PEER_CERT + #endif + +#elif defined(APP_ESP_HTTP_CLIENT) + /* The ESP-IDF Version */ + #define FP_MAX_BITS (8192 * 2) + #define HAVE_ALPN + #define HAVE_SNI + #define OPENSSL_EXTRA_X509_SMALL + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES + #define OPENSSL_EXTRA + #ifndef WOLFSSL_ALWAYS_VERIFY_CB + #define WOLFSSL_ALWAYS_VERIFY_CB + #endif + #ifndef WOLFSSL_VERIFY_CB_ALL_CERTS + #define WOLFSSL_VERIFY_CB_ALL_CERTS + #endif + #ifndef KEEP_PEER_CERT + #define KEEP_PEER_CERT + #endif +#else + #ifdef WOLFSSL_ESPIDF + /* #warning "App config undetected" */ + #endif + /* the code is older or does not have application name defined. */ +#endif /* Example wolfSSL Configuration app settings */ /* Experimental Kyber */ -#if 0 +#ifdef CONFIG_WOLFSSL_ENABLE_KYBER + /* Kyber typically needs a minimum 10K stack */ #define WOLFSSL_EXPERIMENTAL_SETTINGS - #define WOLFSSL_HAVE_KYBER - #define WOLFSSL_WC_KYBER + #define WOLFSSL_HAVE_MLKEM + #define WOLFSSL_WC_MLKEM #define WOLFSSL_SHA3 #if defined(CONFIG_IDF_TARGET_ESP8266) /* With limited RAM, we'll disable some of the Kyber sizes: */ #define WOLFSSL_NO_KYBER1024 #define WOLFSSL_NO_KYBER768 + #define NO_SESSION_CACHE #endif #endif +/* Enable AES for all examples */ +#ifdef NO_AES + #warning "Found NO_AES, wolfSSL AES Cannot be enabled. Check config." +#else + #define WOLFSSL_AES + #define WOLFSSL_AES_COUNTER + + /* Typically only needed for wolfssl_test, see docs. */ + #define WOLFSSL_AES_DIRECT +#endif + /* Pick a cert buffer size: */ /* #define USE_CERT_BUFFERS_2048 */ /* #define USE_CERT_BUFFERS_1024 */ @@ -57,14 +250,76 @@ ** CONFIG_IDF_TARGET_ESP32C6 */ -#undef WOLFSSL_ESPIDF -#define WOLFSSL_ESPIDF +/* Optionally enable Apple HomeKit from compiler directive or Kconfig setting */ +#if defined(WOLFSSL_APPLE_HOMEKIT) || defined(CONFIG_WOLFSSL_APPLE_HOMEKIT) + /* SRP is known to need 8K; slow on some devices */ + #define FP_MAX_BITS (8192 * 2) + #define WOLFCRYPT_HAVE_SRP + #define HAVE_CHACHA + #define HAVE_POLY1305 + #define WOLFSSL_BASE64_ENCODE + #endif /* Apple HomeKit settings */ -/* We don't use WiFi helpers yet, so don't compile in the esp-sdk-lib WiFi */ -#define NO_ESP_SDK_WIFI +/* Used by ESP-IDF components: */ +#if defined(CONFIG_ESP_TLS_USING_WOLFSSL) + /* The ESP-TLS */ + #ifndef FP_MAX_BITS + #if defined(CONFIG_IDF_TARGET_ESP32C2) || \ + defined(CONFIG_IDF_TARGET_ESP8684) || \ + defined(CONFIG_IDF_TARGET_ESP8266) + /* Optionally set smaller size here */ + #define FP_MAX_BITS MIN_FFDHE_FP_MAX_BITS + #else + #define FP_MAX_BITS (4096 * 2) + #endif + #endif + #define HAVE_ALPN + #ifndef CONFIG_IDF_TARGET_ESP8266 + /* Unless installed in the ESP8266 RTOS SDK locally, the wolfSSL + * API for SNI will not be seen in the components/esp-tls layer. + * Only enable SNI for non-ESP8266 targets by default: */ + #define HAVE_SNI + #endif + #define OPENSSL_EXTRA_X509_SMALL + + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES +#endif + +/* Optionally enable some wolfSSH settings */ +#if defined(ESP_ENABLE_WOLFSSH) || defined(CONFIG_ESP_ENABLE_WOLFSSH) + /* Enable wolfSSH. Espressif examples need a few more settings, below */ + #undef WOLFSSL_WOLFSSH + #define WOLFSSL_WOLFSSH + + /* The default SSH Windows size is massive for an embedded target. + * Limit it: */ + #define DEFAULT_WINDOW_SZ 2000 + + /* These may be defined in cmake for other examples: */ + #undef WOLFSSH_TERM + #define WOLFSSH_TERM + + /* optional debug */ + /* #undef DEBUG_WOLFSSH */ + /* #define DEBUG_WOLFSSH */ + + #undef WOLFSSL_KEY_GEN + #define WOLFSSL_KEY_GEN + + #undef WOLFSSL_PTHREADS + #define WOLFSSL_PTHREADS + + #define WOLFSSH_TEST_SERVER + #define WOLFSSH_TEST_THREADING +#endif /* ESP_ENABLE_WOLFSSH */ + + +/* Not yet using WiFi lib, so don't compile in the esp-sdk-lib WiFi helpers: */ +/* #define USE_WOLFSSL_ESP_SDK_WIFI */ /* - * ONE of these Espressif chipsets should be defined: + * ONE of these Espressif chip families will be detected from sdkconfig: * * WOLFSSL_ESP32 * WOLFSSL_ESPWROOM32SE @@ -83,11 +338,28 @@ #endif /* See below for chipset detection from sdkconfig.h */ +/* when you want to use SINGLE THREAD. Note Default ESP-IDF is FreeRTOS */ +#define SINGLE_THREADED + /* Small session cache saves a lot of RAM for ClientCache and SessionCache. * Memory requirement is about 5KB, otherwise 20K is needed when not specified. * If extra small footprint is needed, try MICRO_SESSION_CACHE (< 1K) - * When really desperate, try NO_SESSION_CACHE. */ -#define MICRO_SESSION_CACHE + * When really desperate or no TLS used, try NO_SESSION_CACHE. */ +#define NO_SESSION_CACHE + +/* Small Stack uses more heap. */ +#define WOLFSSL_SMALL_STACK + +/* Full debugging turned off, but show malloc failure detail */ +/* #define DEBUG_WOLFSSL */ +#define DEBUG_WOLFSSL_MALLOC + +/* See test.c that sets cert buffers; we'll set them here: */ +#define USE_CERT_BUFFERS_256 +#define USE_CERT_BUFFERS_2048 + +/* RSA_LOW_MEM: Half as much memory but twice as slow. */ +#define RSA_LOW_MEM /* optionally turn off SHA512/224 SHA512/256 */ /* #define WOLFSSL_NOSHA512_224 */ @@ -102,19 +374,44 @@ #define BENCH_EMBEDDED -#define WOLFSSL_SMALL_STACK -#define HAVE_ECC -#define RSA_LOW_MEM - /* TLS 1.3 */ -#define WOLFSSL_TLS13 -#define HAVE_TLS_EXTENSIONS -#define WC_RSA_PSS -#define HAVE_HKDF -#define HAVE_AEAD -#define HAVE_SUPPORTED_CURVES +#ifdef CONFIG_WOLFSSL_ALLOW_TLS13 + #define WOLFSSL_TLS13 + #define HAVE_TLS_EXTENSIONS + #define HAVE_HKDF -#define WOLFSSL_BENCHMARK_FIXED_UNITS_KB + /* May be required */ + #ifndef HAVE_AEAD + #endif + + /* Required for ECC */ + #define HAVE_SUPPORTED_CURVES + + /* Required for RSA */ + #define WC_RSA_PSS + + /* TLS 1.3 normally requires HAVE_FFDHE */ + #if defined(HAVE_FFDHE_2048) || \ + defined(HAVE_FFDHE_3072) || \ + defined(HAVE_FFDHE_4096) || \ + defined(HAVE_FFDHE_6144) || \ + defined(HAVE_FFDHE_8192) + #else + #define HAVE_FFDHE_2048 + /* #error "TLS 1.3 requires HAVE_FFDHE_[nnnn]" */ + #endif +#endif + +#if defined(CONFIG_IDF_TARGET_ESP32C2) || \ + defined(CONFIG_IDF_TARGET_ESP8684) + /* Optionally set smaller size here */ + #ifdef HAVE_FFDHE_4096 + /* this size may be problematic on the C2 */ + #endif + #define HAVE_FFDHE_2048 +#else + #define HAVE_FFDHE_4096 +#endif #define NO_FILESYSTEM @@ -131,30 +428,72 @@ /* when you want to use SHA384 */ #define WOLFSSL_SHA384 -#if defined(CONFIG_IDF_TARGET_ESP8266) +/* Some features not enabled for ESP8266: */ +#if defined(CONFIG_IDF_TARGET_ESP8266) || \ + defined(CONFIG_IDF_TARGET_ESP32C2) /* Some known low-memory devices have features not enabled by default. */ + /* TODO determine low memory configuration for ECC. */ #else /* when you want to use SHA512 */ #define WOLFSSL_SHA512 /* when you want to use SHA3 */ - #define WOLFSSL_SHA3 + /* #define WOLFSSL_SHA3 */ /* ED25519 requires SHA512 */ #define HAVE_ED25519 +#endif - #define HAVE_ECC - #define HAVE_CURVE25519 - #define CURVE25519_SMALL - #define HAVE_ED25519 +#if defined(CONFIG_IDF_TARGET_ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C2) + #define MY_USE_ECC 0 + #define MY_USE_RSA 1 +#else + #define MY_USE_ECC 1 + #define MY_USE_RSA 0 +#endif + +/* We can use either or both ECC and RSA, but must use at least one. */ +#if MY_USE_ECC || MY_USE_RSA + #if MY_USE_ECC + /* ---- ECDSA / ECC ---- */ + #define HAVE_ECC + #define HAVE_CURVE25519 + #define HAVE_ED25519 + #define WOLFSSL_SHA512 + /* + #define HAVE_ECC384 + #define CURVE25519_SMALL + */ + #else + #define WOLFSSH_NO_ECC + /* WOLFSSH_NO_ECDSA is typically defined automatically, + * here for clarity: */ + #define WOLFSSH_NO_ECDSA + #endif + + #if MY_USE_RSA + /* ---- RSA ----- */ + /* #define RSA_LOW_MEM */ + + /* DH disabled by default, needed if ECDSA/ECC also turned off */ + #define HAVE_DH + #else + #define WOLFSSH_NO_RSA + #endif +#else + #error "Either RSA or ECC must be enabled" #endif /* Optional OpenSSL compatibility */ /* #define OPENSSL_EXTRA */ -/* when you want to use pkcs7 */ +/* #Optional HAVE_PKCS7 */ /* #define HAVE_PKCS7 */ + #if defined(HAVE_PKCS7) + /* HAVE_PKCS7 may enable HAVE_PBKDF2 see settings.h */ + #define NO_PBKDF2 + #define HAVE_AES_KEYWRAP #define HAVE_X963_KDF #define WOLFSSL_AES_DIRECT @@ -174,25 +513,11 @@ /* #define CUSTOM_SLOT_ALLOCATION */ #endif -/* RSA primitive specific definition */ -#if defined(WOLFSSL_ESP32) || defined(WOLFSSL_ESPWROOM32SE) - /* Define USE_FAST_MATH and SMALL_STACK */ - #define ESP32_USE_RSA_PRIMITIVE +/* WC_NO_CACHE_RESISTANT: slower but more secure */ +/* #define WC_NO_CACHE_RESISTANT */ - #if defined(CONFIG_IDF_TARGET_ESP32) - - /* NOTE HW unreliable for small values! */ - /* threshold for performance adjustment for HW primitive use */ - /* X bits of G^X mod P greater than */ - #undef ESP_RSA_EXPT_XBITS - #define ESP_RSA_EXPT_XBITS 32 - - /* X and Y of X * Y mod P greater than */ - #undef ESP_RSA_MULM_BITS - #define ESP_RSA_MULM_BITS 16 - - #endif -#endif +/* TFM_TIMING_RESISTANT: slower but more secure */ +/* #define TFM_TIMING_RESISTANT */ /* #define WOLFSSL_ATECC508A_DEBUG */ @@ -203,37 +528,69 @@ /* #define XTIME time */ -/* adjust wait-timeout count if you see timeout in RSA HW acceleration */ -#define ESP_RSA_TIMEOUT_CNT 0x249F00 +/* Adjust wait-timeout count if you see timeout in RSA HW acceleration. + * Set to very large number and enable WOLFSSL_HW_METRICS to determine max. */ +#ifndef ESP_RSA_TIMEOUT_CNT + #define ESP_RSA_TIMEOUT_CNT 0xFF0000 +#endif -#define HASH_SIZE_LIMIT /* for test.c */ +/* hash limit for test.c */ +#define HASH_SIZE_LIMIT /* USE_FAST_MATH is default */ #define USE_FAST_MATH /***** Use SP_MATH *****/ -/* #undef USE_FAST_MATH */ +/* #undef USE_FAST_MATH */ /* #define SP_MATH */ /* #define WOLFSSL_SP_MATH_ALL */ +/* #define WOLFSSL_SP_RISCV32 */ /***** Use Integer Heap Math *****/ /* #undef USE_FAST_MATH */ /* #define USE_INTEGER_HEAP_MATH */ +/* Just syntax highlighting to check math libraries: */ +#if defined(SP_MATH) || \ + defined(USE_INTEGER_HEAP_MATH) || \ + defined(USE_INTEGER_HEAP_MATH) || \ + defined(USE_FAST_MATH) || \ + defined(WOLFSSL_SP_MATH_ALL) || \ + defined(WOLFSSL_SP_RISCV32) +#endif + +#define WOLFSSL_SMALL_STACK + + #define HAVE_VERSION_EXTENDED_INFO /* #define HAVE_WC_INTROSPECTION */ -#define HAVE_SESSION_TICKET +#ifndef NO_SESSION_CACHE + #define HAVE_SESSION_TICKET +#endif /* #define HAVE_HASHDRBG */ +#if 0 +/* Example for additional cert functions */ #define WOLFSSL_KEY_GEN -#define WOLFSSL_CERT_REQ -#define WOLFSSL_CERT_GEN -#define WOLFSSL_CERT_EXT -#define WOLFSSL_SYS_CA_CERTS + #define WOLFSSL_CERT_REQ + #define WOLFSSL_CERT_GEN + #define WOLFSSL_CERT_EXT + #define WOLFSSL_SYS_CA_CERTS -#define WOLFSSL_CERT_TEXT + + #define WOLFSSL_CERT_TEXT + + /* command-line options + --enable-keygen + --enable-certgen + --enable-certreq + --enable-certext + --enable-asn-template + */ + +#endif #define WOLFSSL_ASN_TEMPLATE @@ -253,11 +610,66 @@ --enable-asn-template */ +/* optional SM4 Ciphers. See https://github.com/wolfSSL/wolfsm */ +/* +#define WOLFSSL_SM2 +#define WOLFSSL_SM3 +#define WOLFSSL_SM4 +*/ + +#if defined(WOLFSSL_SM2) || defined(WOLFSSL_SM3) || defined(WOLFSSL_SM4) + /* SM settings, possible cipher suites: + + TLS13-AES128-GCM-SHA256 + TLS13-CHACHA20-POLY1305-SHA256 + TLS13-SM4-GCM-SM3 + TLS13-SM4-CCM-SM3 + + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-CCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CBC-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-GCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3:" \ + "TLS13-SM4-CCM-SM3:" + */ + + #undef WOLFSSL_BASE16 + #define WOLFSSL_BASE16 /* required for WOLFSSL_SM2 */ + + #undef WOLFSSL_SM4_ECB + #define WOLFSSL_SM4_ECB + + #undef WOLFSSL_SM4_CBC + #define WOLFSSL_SM4_CBC + + #undef WOLFSSL_SM4_CTR + #define WOLFSSL_SM4_CTR + + #undef WOLFSSL_SM4_GCM + #define WOLFSSL_SM4_GCM + + #undef WOLFSSL_SM4_CCM + #define WOLFSSL_SM4_CCM + + #define HAVE_POLY1305 + #define HAVE_CHACHA + + #undef HAVE_AESGCM + #define HAVE_AESGCM +#else + /* default settings */ + #define USE_CERT_BUFFERS_2048 +#endif + /* Chipset detection from sdkconfig.h * Default is HW enabled unless turned off. * Uncomment lines to force SW instead of HW acceleration */ -#if defined(CONFIG_IDF_TARGET_ESP32) +#if defined(CONFIG_IDF_TARGET_ESP32) || defined(WOLFSSL_ESPWROOM32SE) #define WOLFSSL_ESP32 + /* Alternatively, if there's an ECC Secure Element present: */ + /* #define WOLFSSL_ESPWROOM32SE */ + /* wolfSSL HW Acceleration supported on ESP32. Uncomment to disable: */ /* #define NO_ESP32_CRYPT */ /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ @@ -375,12 +787,16 @@ #define WOLFSSL_ESP8266 /* There's no hardware encryption on the ESP8266 */ - /* Consider using the ESP32-C2/C3/C6 - * See https://www.espressif.com/en/products/socs/esp32-c2 */ + /* Consider using the ESP32-C2/C3/C6 */ #define NO_ESP32_CRYPT #define NO_WOLFSSL_ESP32_CRYPT_HASH #define NO_WOLFSSL_ESP32_CRYPT_AES #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI + #ifndef FP_MAX_BITS + /* FP_MAX_BITS matters in wolfssl_test, not just TLS setting. */ + /* MIN_FFDHE_FP_MAX_BITS = (MIN_FFDHE_BITS * 2); see settings.h */ + #define FP_MAX_BITS MIN_FFDHE_FP_MAX_BITS + #endif /***** END CONFIG_IDF_TARGET_ESP266 *****/ #elif defined(CONFIG_IDF_TARGET_ESP8684) @@ -392,7 +808,7 @@ /***** END CONFIG_IDF_TARGET_ESP8684 *****/ #else - /* Anything else encountered, disable HW accleration */ + /* Anything else encountered, disable HW acceleration */ #warning "Unexpected CONFIG_IDF_TARGET_NN value" #define NO_ESP32_CRYPT #define NO_WOLFSSL_ESP32_CRYPT_HASH @@ -400,29 +816,84 @@ #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI #endif /* CONFIG_IDF_TARGET Check */ +/* RSA primitive specific definition, listed AFTER the Chipset detection */ +#if defined(WOLFSSL_ESP32) || defined(WOLFSSL_ESPWROOM32SE) + /* Consider USE_FAST_MATH and SMALL_STACK */ + + #ifndef NO_RSA + #define ESP32_USE_RSA_PRIMITIVE + + #if defined(CONFIG_IDF_TARGET_ESP32) + #ifdef CONFIG_ESP_MAIN_TASK_STACK_SIZE + #if CONFIG_ESP_MAIN_TASK_STACK_SIZE < 10500 + #warning "RSA may be difficult with less than 10KB Stack "/ + #endif + #endif + + /* NOTE HW unreliable for small values! */ + /* threshold for performance adjustment for HW primitive use */ + /* X bits of G^X mod P greater than */ + #undef ESP_RSA_EXPT_XBITS + #define ESP_RSA_EXPT_XBITS 32 + + /* X and Y of X * Y mod P greater than */ + #undef ESP_RSA_MULM_BITS + #define ESP_RSA_MULM_BITS 16 + #endif + #endif +#endif + /* Debug options: See wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h for details on debug options +optionally increase error message size for very long paths. +#define WOLFSSL_MAX_ERROR_SZ 500 + +Turn wolfSSL debugging on/off: + wolfSSL_Debugging_ON(); + wolfSSL_Debugging_OFF(); + #define ESP_VERIFY_MEMBLOCK #define DEBUG_WOLFSSL #define DEBUG_WOLFSSL_VERBOSE #define DEBUG_WOLFSSL_SHA_MUTEX +#define WOLFSSL_DEBUG_IGNORE_ASN_TIME +#define WOLFSSL_DEBUG_CERT_BUNDLE +#define WOLFSSL_DEBUG_CERT_BUNDLE_NAME #define WOLFSSL_ESP32_CRYPT_DEBUG #define WOLFSSL_ESP32_CRYPT_HASH_SHA224_DEBUG #define NO_RECOVER_SOFTWARE_CALC #define WOLFSSL_TEST_STRAY 1 #define USE_ESP_DPORT_ACCESS_READ_BUFFER #define WOLFSSL_ESP32_HW_LOCK_DEBUG +#define WOLFSSL_DEBUG_MUTEX #define WOLFSSL_DEBUG_ESP_RSA_MULM_BITS +#define WOLFSSL_DEBUG_ESP_HW_MOD_RSAMAX_BITS +#define WOLFSSL_DEBUG_ESP_HW_MULTI_RSAMAX_BITS #define ESP_DISABLE_HW_TASK_LOCK +#define ESP_MONITOR_HW_TASK_LOCK +#define USE_ESP_DPORT_ACCESS_READ_BUFFER + +See wolfcrypt/benchmark/benchmark.c for debug and other settings: + +Turn on benchmark timing debugging (CPU Cycles, RTOS ticks, etc) +#define DEBUG_WOLFSSL_BENCHMARK_TIMING + +Turn on timer debugging (used when CPU cycles not available) +#define WOLFSSL_BENCHMARK_TIMER_DEBUG */ -#define WOLFSSL_ESPIDF_ERROR_PAUSE /* Pause in a loop rather than exit. */ +/* Pause in a loop rather than exit. */ +/* #define WOLFSSL_ESPIDF_ERROR_PAUSE */ +/* #define WOLFSSL_ESP32_HW_LOCK_DEBUG */ + #define WOLFSSL_HW_METRICS -/* #define HASH_SIZE_LIMIT */ /* for test.c */ +/* for test.c */ +/* #define HASH_SIZE_LIMIT */ -/* #define NO_HW_MATH_TEST */ /* Optionally turn off HW math checks */ +/* Optionally turn off HW math checks */ +/* #define NO_HW_MATH_TEST */ /* Optionally include alternate HW test library: alt_hw_test.h */ /* When enabling, the ./components/wolfssl/CMakeLists.txt file @@ -463,6 +934,12 @@ See wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h for details on debug options * There are various certificate examples in this header file: * https://github.com/wolfSSL/wolfssl/blob/master/wolfssl/certs_test.h * + * To use the sample certificates in code (not recommended for production!): + * + * #if defined(USE_CERT_BUFFERS_2048) || defined(USE_CERT_BUFFERS_1024) + * #include + * #endif + * * To use the sets of macros below, define *one* of these: * * USE_CERT_BUFFERS_1024 - ECC 1024 bit encoded ASN1 @@ -540,6 +1017,9 @@ See wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h for details on debug options #define WOLFSSL_BASE16 #else #if defined(USE_CERT_BUFFERS_2048) + #define USE_CERT_BUFFERS_256 + /* 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 #define CTX_CA_CERT_TYPE WOLFSSL_FILETYPE_ASN1 @@ -559,6 +1039,9 @@ See wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h for details on debug options #define CTX_CLIENT_KEY_TYPE WOLFSSL_FILETYPE_ASN1 #elif defined(USE_CERT_BUFFERS_1024) + #define USE_CERT_BUFFERS_256 + /* 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 #define CTX_CA_CERT_TYPE WOLFSSL_FILETYPE_ASN1 @@ -581,3 +1064,34 @@ See wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h for details on debug options #error "Must define USE_CERT_BUFFERS_2048 or USE_CERT_BUFFERS_1024" #endif #endif /* Conditional key and cert constant names */ + +/****************************************************************************** +** Sanity Checks +******************************************************************************/ +#if defined(CONFIG_ESP_MAIN_TASK_STACK_SIZE) + #if defined(WOLFCRYPT_HAVE_SRP) + #if defined(FP_MAX_BITS) + #if FP_MAX_BITS < (8192 * 2) + #define ESP_SRP_MINIMUM_STACK_8K (24 * 1024) + #else + #define ESP_SRP_MINIMUM_STACK_8K (28 * 1024) + #endif + #else + #error "Please define FP_MAX_BITS when using WOLFCRYPT_HAVE_SRP." + #endif + + #if (CONFIG_ESP_MAIN_TASK_STACK_SIZE < ESP_SRP_MINIMUM_STACK) + #warning "WOLFCRYPT_HAVE_SRP enabled with small stack size" + #endif + #endif +#else + #warning "CONFIG_ESP_MAIN_TASK_STACK_SIZE not defined!" +#endif +/* See settings.h for some of the possible hardening options: + * + * #define NO_ESPIDF_DEFAULT + * #define WC_NO_CACHE_RESISTANT + * #define WC_AES_BITSLICED + * #define HAVE_AES_ECB + * #define HAVE_AES_DIRECT + */ diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/CMakeLists.txt index 798cecceb..4f5613953 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/CMakeLists.txt @@ -1,35 +1,43 @@ # wolfSSL Espressif Example Project/main CMakeLists.txt -# v1.0 +# v1.2 # # wolfssl server test # +message(STATUS "Begin wolfSSL main CMakeLists.txt") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + # `driver` component not available for ESP8266 + SET(THIS_PRIV_REQUIRES_DRIVER "") +else() + SET(THIS_PRIV_REQUIRES_DRIVER "driver") +endif() + if(WIN32) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") - message("Detected Windows") + message(STATUS "Detected Windows") endif() if(CMAKE_HOST_UNIX) - message("Detected UNIX") + message(STATUS "Detected UNIX") endif() if(APPLE) - message("Detected APPLE") + message(STATUS "Detected APPLE") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") - message("Detected WSL") + message(STATUS "Detected WSL") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") - message("Detected Linux") + message(STATUS "Detected Linux") endif() if(APPLE) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") - message("Detected Apple") + message(STATUS "Detected Apple") endif() set (git_cmd "git") @@ -43,14 +51,26 @@ if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl/" AND EXISTS "$ENV{IDF_PA set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING") endif() +# The wolfSL component name is named "mywolfssl" on the staging site for Managed Components. +if( NOT EXISTS "../components/wolfssl" AND ("$ENV{IDF_COMPONENT_REGISTRY_URL}" STREQUAL "https://components-staging.espressif.com") ) + message(STATUS "WARNING: Using a staging instance of wolfssl.") + set(MAIN_WOLFSSL_COMPONENT_NAME "mywolfssl") +else() + message(STATUS "Using release wolfssl component.") + set(MAIN_WOLFSSL_COMPONENT_NAME "wolfssl") +endif() + ## register_component() idf_component_register(SRCS main.c wifi_connect.c time_helper.c server-tls.c INCLUDE_DIRS "." - "./include") -# + "./include" + PRIV_REQUIRES "${MAIN_WOLFSSL_COMPONENT_NAME}" + "${THIS_PRIV_REQUIRES_DRIVER}" + nvs_flash + protocol_examples_common) # # LIBWOLFSSL_SAVE_INFO(VAR_OUPUT THIS_VAR VAR_RESULT) @@ -80,15 +100,24 @@ function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) message(STATUS "Found ${VAR_OUPUT}=${VAR_VALUE}") # the interesting part is defining the VAR_OUPUT name a value to use in the app - add_definitions(-D${VAR_OUPUT}=\"${VAR_VALUE}\") + add_compile_definitions(${VAR_OUPUT}=\"${VAR_VALUE}\") else() # if we get here, check the execute_process command and parameters. - message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT") + message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT.") + message(STATUS "Setting ${VAR_OUPUT} to \"Unknown\"") set(${VAR_OUPUT} "Unknown") endif() endfunction() # LIBWOLFSSL_SAVE_INFO -if(NOT CMAKE_BUILD_EARLY_EXPANSION) +execute_process( + COMMAND ${git_cmd} "rev-parse" "--is-inside-work-tree" + OUTPUT_VARIABLE IS_GIT_REPO + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + +# Save some project-specific details. Repo may be different than component, or may not even be a repo at all: +if(NOT CMAKE_BUILD_EARLY_EXPANSION AND (IS_GIT_REPO STREQUAL "true")) # LIBWOLFSSL_VERSION_GIT_HASH execute_process(COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") @@ -104,3 +133,4 @@ endif() message(STATUS "") +message(STATUS "End wolfSSL main CMakeLists.txt") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/Kconfig.projbuild b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/Kconfig.projbuild index 64406069d..06cc01df8 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/Kconfig.projbuild +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/Kconfig.projbuild @@ -1,9 +1,112 @@ -menu "Example Configuration" +# Kconfig main +# +# Copyright (C) 2006-2025 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 +# + +# Kconfig File Version 5.7.2.001 for wolfssl_template + +menu "Example wolfSSL Configuration" + +choice WOLFSSL_EXAMPLE_CHOOSE + prompt "Choose Example (See wolfssl/include/user_settings.h)" + default WOLFSSL_EXAMPLE_NAME_NONE + help + The user settings file can be adjusted to specific wolfSSL examples. + + config WOLFSSL_EXAMPLE_NAME_TEMPLATE + bool "wolfSSL Template" + help + The sample template app compiles in wolfSSL and prints the current wolfSSL Version. Nothing more. + + config WOLFSSL_EXAMPLE_NAME_TEST + bool "wolfSSL Test" + help + This app tests all cryptographic functions currently enabled. See also Benchmark performance app. + + config WOLFSSL_EXAMPLE_NAME_BENCHMARK + bool "wolfSSL Benchmark" + help + Benchmark performance app. See also cryptographic test. + + config WOLFSSL_EXAMPLE_NAME_TLS_CLIENT + bool "TLS Client" + help + TLS Client Example app. Needs WiFi and a listening server on port 11111. + + config WOLFSSL_EXAMPLE_NAME_TLS_SERVER + bool "TLS Server" + help + TLS Server Example app. Needs WiFi. More interesting with a TLS client using port 11111. + + config WOLFSSL_EXAMPLE_NAME_WOLFSSH_TEMPLATE + bool "SSH Template App" + help + Bare-bones Hello World app that only compiles in wolfSSL and wolfSSH. + See wolfSSL/wolfssh on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFSSH_ECHOSERVER + bool "SSH Echo Server" + help + See wolfSSL/wolfssh on GitHub. + + config WOLFSSL_EXAMPLE_NAME_ESP32_SSH_SERVER + bool "SSH to UART Server for the ESP32" + help + See wolfSSL/wolfssh-examples on GitHub. + + config WOLFSSL_EXAMPLE_NAME_ESP8266_SSH_SERVER + bool "SSH to UART Server for the ESP8266" + help + See wolfSSL/wolfssh-examples on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFMQTT_TEMPLATE + bool "MQTT Template" + help + See wolfSSL/wolfmqtt on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFMQTT_AWS_IOT_MQTT + bool "MQTT AWS IoT" + help + See wolfSSL/wolfmqtt on GitHub. + + config WOLFTPM_EXAMPLE_NAME_ESPRESSIF + bool "TPM Test Example for the ESP32" + help + See wolfSSL/wolfTPM on GitHub. + + config WOLFSSL_EXAMPLE_NAME_NONE + bool "Other" + help + A specific example app is not defined. + +endchoice + +config WOLFSSL_TARGET_HOST + string "Target host" + default "127.0.0.1" + help + host address for the example to connect config WOLFSSL_TARGET_PORT int "Target port" default 11111 help - Host listening port for the example to connect. + host port for the example to connect endmenu diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/component.mk index d31083f65..c59edbee4 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/component.mk @@ -1,3 +1,8 @@ # -# Main Makefile. This is basically the same as a component makefile. -# \ No newline at end of file +# Main component makefile. +# +# This Makefile can be left empty. By default, it will take the sources in the +# src/ directory, compile them and link them into lib(subdirectory_name).a +# in the build directory. This behavior is entirely configurable, +# please read the ESP-IDF documents if you need to do this. +# diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/main.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/main.h index 94d913235..6a7946d50 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/main.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/main.h @@ -1,6 +1,6 @@ -/* template main.h +/* wolfssl_server main.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -18,7 +18,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ + #ifndef _MAIN_H_ #define _MAIN_H_ +void app_main(void); + #endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/server-tls.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/server-tls.h index c7483039e..9e647edfb 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/server-tls.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/server-tls.h @@ -1,6 +1,6 @@ /* server-tls.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -53,7 +53,7 @@ WOLFSSL_ESP_TASK tls_smp_server_task(void *args); /* init will create an RTOS task, otherwise server is simply function call. */ #if defined(SINGLE_THREADED) - /* no init neded */ + /* no init needed */ #else WOLFSSL_ESP_TASK tls_smp_server_init(void* args); #endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/time_helper.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/time_helper.h index b3574b66b..f55d07962 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/time_helper.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/time_helper.h @@ -1,5 +1,6 @@ -/* - * Copyright (C) 2006-2024 wolfSSL Inc. +/* time_helper.h + * + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -20,11 +21,11 @@ /* common Espressif time_helper v5.6.3.001 */ -#ifndef _TIME_HELPER_H -#define _TIME_HELPER_H +#ifndef _TIME_HELPER_H_ +#define _TIME_HELPER_H_ -/* ESP-IDF uses a 64-bit signed integer to represent time_t starting from release v5.0 - * See: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html#year-2036-and-2038-overflow-issues +/* ESP-IDF uses a 64-bit signed integer to represent time_t starting from + * release v5.0 See: Espressif api-reference/system/system_time */ #ifdef __cplusplus @@ -32,7 +33,7 @@ extern "C" { #endif /* a function to show the current data and time */ -int esp_show_current_datetime(); +int esp_show_current_datetime(void); /* worst case, if GitHub time not available, used fixed time */ int set_fixed_default_time(void); diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/wifi_connect.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/wifi_connect.h index b5debf364..0fe2183c7 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/wifi_connect.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/wifi_connect.h @@ -1,6 +1,6 @@ /* wifi_connect.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -21,9 +21,6 @@ #ifndef _WIFI_CONNECT_H_ #define _WIFI_CONNECT_H_ -#include -#include - /* ESP lwip */ #define EXAMPLE_ESP_MAXIMUM_RETRY CONFIG_ESP_MAXIMUM_RETRY @@ -31,8 +28,10 @@ #define TLS_SMP_SERVER_TASK_BYTES 22240 #define TLS_SMP_SERVER_TASK_PRIORITY 8 +/* Optionally use ESP-IDF config settings #define TLS_SMP_WIFI_SSID CONFIG_WIFI_SSID #define TLS_SMP_WIFI_PASS CONFIG_WIFI_PASSWORD +*/ #define USE_WIFI_EXAMPLE #ifdef USE_WIFI_EXAMPLE @@ -52,18 +51,53 @@ * file my_private_config.h should be excluded from git updates */ /* #define USE_MY_PRIVATE_CONFIG */ -#ifdef USE_MY_PRIVATE_CONFIG +/* Note that IntelliSense may not work properly in the next section for the + * Espressif SDK 3.4 on the ESP8266. Macros should still be defined. + * See the project-level Makefile. Example found in: + * https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/template + * + * The USE_MY_PRIVATE_[OS]_CONFIG is typically an environment variable that + * triggers the make (not cmake) to add compiler defines. + */ +#if defined(USE_MY_PRIVATE_WINDOWS_CONFIG) + #include "/workspace/my_private_config.h" +#elif defined(USE_MY_PRIVATE_WSL_CONFIG) + #include "/mnt/c/workspace/my_private_config.h" +#elif defined(USE_MY_PRIVATE_LINUX_CONFIG) + #include "~/workspace/my_private_config.h" +#elif defined(USE_MY_PRIVATE_MAC_CONFIG) + #include "~/Documents/my_private_config.h" +#elif defined(USE_MY_PRIVATE_CONFIG) + /* This section works best with cmake & non-environment variable setting */ #if defined(WOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS) + #define WOLFSSL_CMAKE + #include "/workspace/my_private_config.h" + #elif defined(WOLFSSL_MAKE_SYSTEM_NAME_WINDOWS) + #define WOLFSSL_MAKE #include "/workspace/my_private_config.h" #elif defined(WOLFSSL_CMAKE_SYSTEM_NAME_WSL) + #define WOLFSSL_CMAKE + #include "/mnt/c/workspace/my_private_config.h" + #elif defined(WOLFSSL_MAKE_SYSTEM_NAME_WSL) + #define WOLFSSL_MAKE #include "/mnt/c/workspace/my_private_config.h" #elif defined(WOLFSSL_CMAKE_SYSTEM_NAME_LINUX) + #define WOLFSSL_CMAKE + #include "~/workspace/my_private_config.h" + #elif defined(WOLFSSL_MAKE_SYSTEM_NAME_LINUX) + #define WOLFSSL_MAKE #include "~/workspace/my_private_config.h" #elif defined(WOLFSSL_CMAKE_SYSTEM_NAME_APPLE) #include "~/Documents/my_private_config.h" + #elif defined(WOLFSSL_MAKE_SYSTEM_NAME_APPLE) + #define WOLFSSL_MAKE + #include "~/Documents/my_private_config.h" + #elif defined(OS_WINDOWS) + #include "/workspace/my_private_config.h" #else - #warning "did not detect environment. using ~/my_private_config.h" - #include "~/my_private_config.h" + /* Edit as needed for your private config: */ + #warning "default private config using /workspace/my_private_config.h" + #include "/workspace/my_private_config.h" #endif #else @@ -74,8 +108,12 @@ ** If you'd rather not, just change the below entries to strings with ** the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid" */ - #ifdef CONFIG_ESP_WIFI_SSID + #if defined(CONFIG_ESP_WIFI_SSID) + /* typically from ESP32 with ESP-IDF v4 to v5 */ #define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID + #elif defined(CONFIG_EXAMPLE_WIFI_SSID) + /* typically from ESP8266 rtos-sdk/v3.4 */ + #define EXAMPLE_ESP_WIFI_SSID CONFIG_EXAMPLE_WIFI_SSID #else /* See new esp-sdk-lib.h helpers: */ #ifndef EXAMPLE_ESP_WIFI_SSID @@ -83,8 +121,12 @@ #endif #endif - #ifdef CONFIG_ESP_WIFI_PASSWORD + #if defined(CONFIG_ESP_WIFI_PASSWORD) + /* tyically from ESP32 with ESP-IDF v4 or v5 */ #define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD + #elif defined(CONFIG_EXAMPLE_WIFI_SSID) + /* typically from ESP8266 rtos-sdk/v3.4 */ + #define EXAMPLE_ESP_WIFI_PASS CONFIG_EXAMPLE_WIFI_PASSWORD #else /* See new esp-sdk-lib.h helpers: */ #ifndef EXAMPLE_ESP_WIFI_PASS diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/main.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/main.c index b25991ca2..fd3af02d4 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/main.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -27,29 +27,43 @@ #include /* wolfSSL */ -#include /* includes wolfSSL user-settings.h */ -#include -#ifndef WOLFSSL_ESPIDF - #warning "Problem with wolfSSL user_settings." - #warning "Check components/wolfssl/include" +/* Always include wolfcrypt/settings.h before any other wolfSSL file. */ +/* Reminder: settings.h pulls in user_settings.h; don't include it here. */ +#ifdef WOLFSSL_USER_SETTINGS + #include + #ifndef WOLFSSL_ESPIDF + #warning "Problem with wolfSSL user_settings." + #warning "Check components/wolfssl/include" + #endif + #include +#else + /* Define WOLFSSL_USER_SETTINGS project wide for settings.h to include */ + /* wolfSSL user settings in ./components/wolfssl/include/user_settings.h */ + #error "Missing WOLFSSL_USER_SETTINGS in CMakeLists or Makefile:\ + CFLAGS +=-DWOLFSSL_USER_SETTINGS" #endif /* this project */ #include "server-tls.h" #include "time_helper.h" -#ifndef CONFIG_IDF_TARGET_ESP32H2 +#ifdef CONFIG_IDF_TARGET_ESP32H2 /* There's no WiFi on ESP32-H2. * For wired ethernet, see: * https://github.com/wolfSSL/wolfssl-examples/tree/master/ESP32/TLS13-ENC28J60-client */ +#else #include "wifi_connect.h" + /* + * Note ModBus TCP cannot be disabled on ESP8266 tos-sdk/v3.4 + * See https://github.com/espressif/esp-modbus/issues/2 + */ #endif #ifdef WOLFSSL_TRACK_MEMORY #include #endif -static const char* const TAG = "TLS Client"; +static const char* TAG = "main"; #if defined(WOLFSSL_ESPWROOM32SE) && defined(HAVE_PK_CALLBACKS) \ && defined(WOLFSSL_ATECC508A) @@ -114,42 +128,74 @@ void my_atmel_free(int slotId) #endif /* CUSTOM_SLOT_ALLOCATION */ #endif /* WOLFSSL_ESPWROOM32SE && HAVE_PK_CALLBACK && WOLFSSL_ATECC508A */ -/* for FreeRTOS */ +/* Entry for FreeRTOS */ void app_main(void) { - int stack_start = 0; esp_err_t ret = 0; +#ifndef SINGLE_THREADED + int this_heap = 0; + #ifdef INCLUDE_uxTaskGetStackHighWaterMark + int stack_start = 0; + #endif +#endif ESP_LOGI(TAG, "---------------- wolfSSL TLS Server Example ------------"); ESP_LOGI(TAG, "--------------------------------------------------------"); ESP_LOGI(TAG, "--------------------------------------------------------"); ESP_LOGI(TAG, "---------------------- BEGIN MAIN ----------------------"); ESP_LOGI(TAG, "--------------------------------------------------------"); ESP_LOGI(TAG, "--------------------------------------------------------"); +#if !defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_SERVER) + ESP_LOGW(TAG, "Warning: Example wolfSSL misconfigured? Check menuconfig."); +#endif +#if defined(ESP_SDK_MEM_LIB_VERSION) && defined(DEBUG_WOLFSSL) + sdk_init_meminfo(); +#endif #ifdef ESP_TASK_MAIN_STACK ESP_LOGI(TAG, "ESP_TASK_MAIN_STACK: %d", ESP_TASK_MAIN_STACK); #endif #ifdef TASK_EXTRA_STACK_SIZE ESP_LOGI(TAG, "TASK_EXTRA_STACK_SIZE: %d", TASK_EXTRA_STACK_SIZE); #endif -#ifdef INCLUDE_uxTaskGetStackHighWaterMark + +#ifdef SINGLE_THREADED + ESP_LOGI(TAG, "Single threaded"); +#else ESP_LOGI(TAG, "CONFIG_ESP_MAIN_TASK_STACK_SIZE = %d bytes (%d words)", CONFIG_ESP_MAIN_TASK_STACK_SIZE, - (int)(CONFIG_ESP_MAIN_TASK_STACK_SIZE / sizeof(void*))); + (int)(CONFIG_ESP_MAIN_TASK_STACK_SIZE / sizeof(void*))); - /* Returns the high water mark of the stack associated with xTask. That is, - * the minimum free stack space there has been (in bytes not words, unlike - * vanilla FreeRTOS) since the task started. The smaller the returned - * number the closer the task has come to overflowing its stack. - * see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos_idf.html - */ - stack_start = uxTaskGetStackHighWaterMark(NULL); - ESP_LOGI(TAG, "Stack Start HWM: %d bytes", stack_start); -#endif + #ifdef INCLUDE_uxTaskGetStackHighWaterMark + { + /* Returns the high water mark of the stack associated with xTask. That is, + * the minimum free stack space there has been (in bytes not words, unlike + * vanilla FreeRTOS) since the task started. The smaller the returned + * number the closer the task has come to overflowing its stack. + * see Espressif api-reference/system/freertos_idf + */ + stack_start = uxTaskGetStackHighWaterMark(NULL); + #ifdef ESP_SDK_MEM_LIB_VERSION + { + sdk_var_whereis("stack_start", &stack_start); + } + #endif + + ESP_LOGI(TAG, "Stack Start HWM: %d bytes", stack_start); + } + #endif /* INCLUDE_uxTaskGetStackHighWaterMark */ +#endif /* SINGLE_THREADED */ #ifdef HAVE_VERSION_EXTENDED_INFO esp_ShowExtendedSystemInfo(); #endif - +#ifdef DEBUG_WOLFSSL + wolfSSL_Debugging_OFF(); +#endif +#ifdef CONFIG_IDF_TARGET_ESP32H2 + ESP_LOGE(TAG, "No WiFi on the ESP32-H2 and ethernet not yet supported"); + while (1) { + vTaskDelay(60000); + } +#endif /* Set time for cert validation. * Some lwIP APIs, including SNTP functions, are not thread safe. */ ret = set_time(); /* need to setup NTP before WiFi */ @@ -183,11 +229,23 @@ void app_main(void) /* Initialize NVS */ ret = nvs_flash_init(); - if (ret == ESP_ERR_NVS_NO_FREE_PAGES || - ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { - ESP_ERROR_CHECK(nvs_flash_erase()); - ret = nvs_flash_init(); + #if defined(CONFIG_IDF_TARGET_ESP8266) + { + if (ret == ESP_ERR_NVS_NO_FREE_PAGES) { + ESP_ERROR_CHECK(nvs_flash_erase()); + ret = nvs_flash_init(); + } } + #else + { + /* Non-ESP8266 initialization is slightly different */ + if (ret == ESP_ERR_NVS_NO_FREE_PAGES || + ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { + ESP_ERROR_CHECK(nvs_flash_erase()); + ret = nvs_flash_init(); + } + } + #endif /* else not CONFIG_IDF_TARGET_ESP8266 */ ESP_ERROR_CHECK(ret); #if defined(CONFIG_IDF_TARGET_ESP32H2) @@ -202,8 +260,8 @@ void app_main(void) ESP_LOGI(TAG, "Trying WiFi again..."); ret = wifi_init_sta(); } - #endif -#endif + #endif /* else not CONFIG_IDF_TARGET_ESP32H2 */ +#endif /* else FOUND_PROTOCOL_EXAMPLES_DIR not found */ /* Once we are connected to the network, start & wait for NTP time */ ret = set_time_wait_for_ntp(); @@ -215,34 +273,46 @@ void app_main(void) esp_show_current_datetime(); } - /* HWM is maximum amount of stack space that has been unused, in bytes - * not words (unlike vanilla freeRTOS). */ - ESP_LOGI(TAG, "Initial Stack Used (before wolfSSL Server): %d bytes", - CONFIG_ESP_MAIN_TASK_STACK_SIZE - - (uxTaskGetStackHighWaterMark(NULL)) - ); - ESP_LOGI(TAG, "Starting TLS Server...\n"); - #if defined(SINGLE_THREADED) /* just call the task */ tls_smp_server_task((void*)NULL); #else tls_args args[1] = {0}; /* start a thread with the task */ + /* HWM is maximum amount of stack space that has been unused, in bytes + * not words (unlike vanilla freeRTOS). */ + this_heap = esp_get_free_heap_size(); + ESP_LOGI(TAG, "Initial Stack Used (before wolfSSL Server): %d bytes", + CONFIG_ESP_MAIN_TASK_STACK_SIZE + - (uxTaskGetStackHighWaterMark(NULL)) + ); + ESP_LOGI(TAG, "Starting TLS Server task...\n"); + ESP_LOGI(TAG, "main tls_smp_client_init heap @ %p = %d", + &this_heap, this_heap); + + + tls_smp_server_init(args); /* NULL will use the DEFAULT_PORT value */ #endif + /* Done */ +#ifdef SINGLE_THREADED + ESP_LOGV(TAG, "\n\nDone!\n\n"); + while (1); +#else + ESP_LOGV(TAG, "\n\nvTaskDelete...\n\n"); + vTaskDelete(NULL); /* done */ while (1) { + ESP_LOGV(TAG, "\n\nLoop...\n\n"); + #ifdef INCLUDE_uxTaskGetStackHighWaterMark + ESP_LOGI(TAG, "Stack HWM: %d", uxTaskGetStackHighWaterMark(NULL)); -#if defined(SINGLE_THREADED) - ESP_LOGV(TAG, "\n\nDone!\n\n"); - while (1); -#else - /* Delete this main task to free up memory */ - ESP_LOGV(TAG, "\n\nvTaskDelete...\n\n"); - vTaskDelete(NULL); -#endif + ESP_LOGI(TAG, "Stack used: %d", CONFIG_ESP_MAIN_TASK_STACK_SIZE + - (uxTaskGetStackHighWaterMark(NULL) )); + #endif + vTaskDelay(60000); } /* done while */ +#endif /* else not SINGLE_THREADED */ } /* app_main */ diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/server-tls.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/server-tls.c index b966e4e17..da8f933c1 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/server-tls.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/server-tls.c @@ -1,6 +1,6 @@ /* server-tls.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -39,10 +39,28 @@ #endif /* wolfSSL */ -#include -#include -#include - +/* Always include wolfcrypt/settings.h before any other wolfSSL file. */ +/* Reminder: settings.h pulls in user_settings.h; don't include it here. */ +#ifdef WOLFSSL_USER_SETTINGS + #include + #ifndef WOLFSSL_ESPIDF + #warning "Problem with wolfSSL user_settings." + #warning "Check components/wolfssl/include" + #endif + #include +#else + /* Define WOLFSSL_USER_SETTINGS project wide for settings.h to include */ + /* wolfSSL user settings in ./components/wolfssl/include/user_settings.h */ + #error "Missing WOLFSSL_USER_SETTINGS in CMakeLists or Makefile:\ + CFLAGS +=-DWOLFSSL_USER_SETTINGS" +#endif +#if defined(WOLFSSL_WC_MLKEM) + #include + #include +#endif +#if defined(USE_CERT_BUFFERS_2048) || defined(USE_CERT_BUFFERS_1024) + #include +#endif #ifdef WOLFSSL_TRACK_MEMORY #include #endif @@ -286,15 +304,19 @@ WOLFSSL_ESP_TASK tls_smp_server_task(void *args) my_atmel_slotInit(); atmel_set_slot_allocator(my_atmel_alloc, my_atmel_free); #endif +#endif +#ifdef WOLFSSL_EXAMPLE_VERBOSITY + ESP_LOGI(TAG, "Initial stack used: %d\n", + TLS_SMP_SERVER_TASK_BYTES - uxTaskGetStackHighWaterMark(NULL) ); #endif ESP_LOGI(TAG, "accept clients..."); /* Continue to accept clients until shutdown is issued */ while (!shutdown) { - ESP_LOGI(TAG, "Stack used: %d\n", TLS_SMP_SERVER_TASK_BYTES - - uxTaskGetStackHighWaterMark(NULL) ); WOLFSSL_MSG("Waiting for a connection..."); +#if ESP_IDF_VERSION_MAJOR >=4 + /* TODO: IP Address is problematic in RTOS SDK 3.4 */ wifi_show_ip(); - +#endif /* Accept client socket connections */ if ((connd = accept(sockfd, (struct sockaddr*)&clientAddr, &size)) == -1) { @@ -307,7 +329,7 @@ WOLFSSL_ESP_TASK tls_smp_server_task(void *args) if ((ssl = wolfSSL_new(ctx)) == NULL) { ESP_LOGE(TAG, "ERROR: failed to create WOLFSSL object"); } -#if defined(WOLFSSL_HAVE_KYBER) +#if defined(WOLFSSL_HAVE_MLKEM) else { /* If success creating CTX and Kyber enabled, set key share: */ ret = wolfSSL_UseKeyShare(ssl, WOLFSSL_P521_KYBER_LEVEL5); @@ -319,7 +341,7 @@ WOLFSSL_ESP_TASK tls_smp_server_task(void *args) } } #else - ESP_LOGI(TAG, "WOLFSSL_HAVE_KYBER is not enabled"); + ESP_LOGI(TAG, "WOLFSSL_HAVE_MLKEM is not enabled, not using PQ."); #endif /* show what cipher connected for this WOLFSSL* object */ ShowCiphers(ssl); @@ -363,6 +385,10 @@ WOLFSSL_ESP_TASK tls_smp_server_task(void *args) /* Cleanup after this connection */ wolfSSL_free(ssl); /* Free the wolfSSL object */ close(connd); /* Close the connection to the client */ +#ifdef WOLFSSL_EXAMPLE_VERBOSITY + ESP_LOGI(TAG, "Stack used: %d\n", + TLS_SMP_SERVER_TASK_BYTES - uxTaskGetStackHighWaterMark(NULL)); +#endif } /* !shutdown */ /* Cleanup and return */ wolfSSL_free(ssl); /* Free the wolfSSL object */ @@ -398,8 +424,7 @@ WOLFSSL_ESP_TASK tls_smp_server_init(void* args) xTaskHandle _handle; #endif /* Note that despite vanilla FreeRTOS using WORDS for a parameter, - * Espressif uses BYTES for the task stack size here. - * See https://docs.espressif.com/projects/esp-idf/en/v4.3/esp32/api-reference/system/freertos.html */ + * Espressif uses BYTES for the task stack size here. */ ESP_LOGI(TAG, "Creating tls_smp_server_task with stack size = %d", TLS_SMP_SERVER_TASK_BYTES); ret_i = xTaskCreate(tls_smp_server_task, diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/time_helper.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/time_helper.c index 41a0e0975..526783113 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/time_helper.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/time_helper.c @@ -1,6 +1,6 @@ /* time_helper.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -19,7 +19,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ -/* common Espressif time_helper v5.6.3.002 */ +/* See https://tf.nist.gov/tf-cgi/servers.cgi */ + +/* common Espressif time_helper v5.6.6.001 */ #include "sdkconfig.h" #include "time_helper.h" @@ -36,25 +38,23 @@ #include #endif #else - /* TODO Consider pre IDF v5? */ + /* TODO Consider non ESP-IDF environments */ #endif -/* ESP-IDF uses a 64-bit signed integer to represent time_t starting from release v5.0 - * See: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html#year-2036-and-2038-overflow-issues - */ -const static char* TAG = "time_helper"; +/* ESP-IDF uses a 64-bit signed integer to represent time_t starting from + * release v5.0. See: Espressif api-reference/system/system_time */ /* see https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html */ #ifndef TIME_ZONE -/* - * PST represents Pacific Standard Time. - * +8 specifies the offset from UTC (Coordinated Universal Time), indicating - * that Pacific Time is UTC-8 during standard time. - * PDT represents Pacific Daylight Time. - * M3.2.0 indicates that Daylight Saving Time (DST) starts on the - * second (2) Sunday (0) of March (3). - * M11.1.0 indicates that DST ends on the first (1) Sunday (0) of November (11) - */ + /* + * PST represents Pacific Standard Time. + * +8 specifies the offset from UTC (Coordinated Universal Time), indicating + * that Pacific Time is UTC-8 during standard time. + * PDT represents Pacific Daylight Time. + * M3.2.0 indicates that Daylight Saving Time (DST) starts on the + * second (2) Sunday (0) of March (3). + * M11.1.0 indicates that DST ends on the first (1) Sunday (0) of November (11) + */ #define TIME_ZONE "PST+8PDT,M3.2.0,M11.1.0" #endif /* not defined: TIME_ZONE, so we are setting our own */ @@ -87,11 +87,13 @@ const static char* TAG = "time_helper"; char* ntpServerList[NTP_SERVER_COUNT] = NTP_SERVER_LIST; +const static char* TAG = "time_helper"; + /* our NTP server list is global info */ extern char* ntpServerList[NTP_SERVER_COUNT]; /* Show the current date and time */ -int esp_show_current_datetime() +int esp_show_current_datetime(void) { time_t now; char strftime_buf[64]; @@ -104,7 +106,7 @@ int esp_show_current_datetime() localtime_r(&now, &timeinfo); strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo); ESP_LOGI(TAG, "The current date/time is: %s", strftime_buf); - return 0; + return ESP_OK; } /* the worst-case scenario is a hard-coded date/time */ @@ -113,9 +115,9 @@ int set_fixed_default_time(void) /* ideally, we'd like to set time from network, * but let's set a default time, just in case */ struct tm timeinfo = { - .tm_year = 2023 - 1900, + .tm_year = 2024 - 1900, .tm_mon = 10, - .tm_mday = 02, + .tm_mday = 11, .tm_hour = 13, .tm_min = 01, .tm_sec = 05 @@ -130,7 +132,38 @@ int set_fixed_default_time(void) ESP_LOGI(TAG, "Adjusting time from fixed value"); now = (struct timeval){ .tv_sec = interim_time }; ret = settimeofday(&now, NULL); + ESP_LOGI(TAG, "settimeofday result = %d", ret); + return ret; +} +/* probably_valid_time_string(s) + * + * some sanity checks on time string before calling sscanf() + * + * returns 0 == ESP_OK == Success if str is likely a valid time. + * -1 == ESP_FAIL otherwise + */ +int probably_valid_time_string(const char* str) +{ + int ret = ESP_OK; + size_t length = 0; + size_t spaces = 0; + size_t colons = 0; + + while (str[length] != '\0') { + if (str[length] == ' ') { + spaces++; + } + if (str[length] == ':') { + colons++; + } + length++; + } + + if ((length > 32) || (spaces < 4) || (spaces > 5) || (colons > 2)) { + ret = ESP_FAIL; + ESP_LOGE(TAG, "ERROR, failed time sanity check: %s", str); + } return ret; } @@ -138,60 +171,67 @@ int set_fixed_default_time(void) * * returns 0 = success if able to set the time from the provided string * error for any other value, typically -1 */ -int set_time_from_string(char* time_buffer) +int set_time_from_string(const char* time_buffer) { /* expecting github default formatting: 'Thu Aug 31 12:41:45 2023 -0700' */ + char offset[28]; /* large arrays, just in case there's still bad data */ + char day_str[28]; + char month_str[28]; const char *format = "%3s %3s %d %d:%d:%d %d %s"; struct tm this_timeinfo; struct timeval now; time_t interim_time; - char offset[6]; /* expecting trailing single quote, not used */ - char day_str[4]; - char month_str[4]; int day, year, hour, minute, second; int quote_offset = 0; int ret = 0; - /* we are expecting the string to be encapsulated in single quotes */ - if (*time_buffer == 0x27) { - quote_offset = 1; - } - - ret = sscanf(time_buffer + quote_offset, - format, - day_str, month_str, - &day, &hour, &minute, &second, &year, &offset); - - if (ret == 8) { - /* we found a match for all componets */ - - const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - - for (int i = 0; i < 12; i++) { - if (strcmp(month_str, months[i]) == 0) { - this_timeinfo.tm_mon = i; - break; - } + /* perform some basic sanity checks */ + ret = probably_valid_time_string(time_buffer); + if (ret == ESP_OK) { + /* we are expecting the string to be encapsulated in single quotes */ + if (*time_buffer == 0x27) { + quote_offset = 1; } - this_timeinfo.tm_mday = day; - this_timeinfo.tm_hour = hour; - this_timeinfo.tm_min = minute; - this_timeinfo.tm_sec = second; - this_timeinfo.tm_year = year - 1900; /* Number of years since 1900 */ + ret = sscanf(time_buffer + quote_offset, + format, + day_str, month_str, + &day, &hour, &minute, &second, &year, &offset); - interim_time = mktime(&this_timeinfo); - now = (struct timeval){ .tv_sec = interim_time }; - ret = settimeofday(&now, NULL); - ESP_LOGI(TAG, "Time updated to %s", time_buffer); - } - else { - ESP_LOGE(TAG, "Failed to convert \"%s\" to a tm date.", time_buffer); - ESP_LOGI(TAG, "Trying fixed date that was hard-coded."); - set_fixed_default_time(); - ret = -1; + if (ret == 8) { + /* we found a match for all components */ + + const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + + for (int i = 0; i < 12; i++) { + if (strcmp(month_str, months[i]) == 0) { + this_timeinfo.tm_mon = i; + break; + } + } + + this_timeinfo.tm_mday = day; + this_timeinfo.tm_hour = hour; + this_timeinfo.tm_min = minute; + this_timeinfo.tm_sec = second; + this_timeinfo.tm_year = year - 1900; /* Years since 1900 */ + + interim_time = mktime(&this_timeinfo); + now = (struct timeval){ .tv_sec = interim_time }; + ret = settimeofday(&now, NULL); + ESP_LOGI(TAG, "Time updated to %s", time_buffer); + } + else { + ESP_LOGE(TAG, "Failed to convert \"%s\" to a tm date.", + time_buffer); + ESP_LOGI(TAG, "Trying fixed date that was hard-coded...."); + set_fixed_default_time(); + ret = ESP_FAIL; + } } + return ret; } @@ -223,15 +263,17 @@ int set_time(void) esp_show_current_datetime(); #ifdef LIBWOLFSSL_VERSION_GIT_HASH_DATE - /* initialy set a default approximate time from recent git commit */ - ESP_LOGI(TAG, "Found git hash date, attempting to set system date."); - set_time_from_string(LIBWOLFSSL_VERSION_GIT_HASH_DATE); + /* initially set a default approximate time from recent git commit */ + ESP_LOGI(TAG, "Found git hash date, attempting to set system date: %s", + LIBWOLFSSL_VERSION_GIT_HASH_DATE); + set_time_from_string(LIBWOLFSSL_VERSION_GIT_HASH_DATE"\0"); esp_show_current_datetime(); ret = -4; #else /* otherwise set a fixed time that was hard coded */ set_fixed_default_time(); + esp_show_current_datetime(); ret = -3; #endif @@ -242,7 +284,7 @@ int set_time(void) if (NTP_SERVER_COUNT) { /* next, let's setup NTP time servers * - * see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html#sntp-time-synchronization + * see Espressifapi-reference/system/system_time.html#sntp-time-synchronization * * WARNING: do not set operating mode while SNTP client is running! */ @@ -262,6 +304,7 @@ int set_time(void) } ESP_LOGI(TAG, "%s", thisServer); sntp_setservername(i, thisServer); + ret = ESP_OK; } #ifdef HAS_ESP_NETIF_SNTP ret = esp_netif_sntp_init(&config); @@ -289,6 +332,9 @@ int set_time(void) ESP_LOGW(TAG, "No sntp time servers found."); ret = -1; } + + esp_show_current_datetime(); + ESP_LOGI(TAG, "time helper existing with result = %d", ret); return ret; } @@ -303,6 +349,8 @@ int set_time_wait_for_ntp(void) ret = esp_netif_sntp_start(); ret = esp_netif_sntp_sync_wait(500 / portTICK_PERIOD_MS); +#else + ESP_LOGW(TAG, "HAS_ESP_NETIF_SNTP not defined"); #endif /* HAS_ESP_NETIF_SNTP */ esp_show_current_datetime(); @@ -322,7 +370,7 @@ int set_time_wait_for_ntp(void) #endif if (ret == ESP_OK) { - ESP_LOGI(TAG, "Successfuly set time via NTP servers."); + ESP_LOGI(TAG, "Successfully set time via NTP servers."); } else { ESP_LOGW(TAG, "Warning: Failed to set time with NTP: " diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/wifi_connect.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/wifi_connect.c index 1b33f9805..0b79001ac 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/wifi_connect.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/wifi_connect.c @@ -1,6 +1,6 @@ /* wifi_connect.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -18,24 +18,42 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ - #include "wifi_connect.h" +#include "wifi_connect.h" +/* FreeRTOS */ #include #include #include -#include + +/* Espressif */ #include +#include +#include /* wolfSSL */ -#include -#include -#include -#ifndef WOLFSSL_ESPIDF - #warning "Problem with wolfSSL user_settings." - #warning "Check components/wolfssl/include" +/* Always include wolfcrypt/settings.h before any other wolfSSL file. */ +/* Reminder: settings.h pulls in user_settings.h; don't include it here. */ +#ifdef WOLFSSL_USER_SETTINGS + #include + #ifndef WOLFSSL_ESPIDF + #warning "Problem with wolfSSL user_settings." + #warning "Check components/wolfssl/include" + #endif + #include + #include +#else + /* Define WOLFSSL_USER_SETTINGS project wide for settings.h to include */ + /* wolfSSL user settings in ./components/wolfssl/include/user_settings.h */ + #error "Missing WOLFSSL_USER_SETTINGS in CMakeLists or Makefile:\ + CFLAGS +=-DWOLFSSL_USER_SETTINGS" #endif -#if ESP_IDF_VERSION_MAJOR >= 5 +/* When there's too little heap, WiFi quietly refuses to connect */ +#define WIFI_LOW_HEAP_WARNING 21132 + +#if defined(CONFIG_IDF_TARGET_ESP8266) +#elif ESP_IDF_VERSION_MAJOR >= 5 + /* example path set in cmake file */ #elif ESP_IDF_VERSION_MAJOR >= 4 #include "protocol_examples_common.h" #else @@ -43,7 +61,9 @@ static EventGroupHandle_t wifi_event_group; #endif -#if defined(ESP_IDF_VERSION_MAJOR) && defined(ESP_IDF_VERSION_MINOR) +#if defined(CONFIG_IDF_TARGET_ESP8266) + +#elif defined(ESP_IDF_VERSION_MAJOR) && defined(ESP_IDF_VERSION_MINOR) #if ESP_IDF_VERSION_MAJOR >= 4 /* likely using examples, see wifi_connect.h */ #else @@ -63,7 +83,114 @@ /* breadcrumb prefix for logging */ const static char *TAG = "wifi_connect"; -#if ESP_IDF_VERSION_MAJOR < 4 +#if defined(CONFIG_IDF_TARGET_ESP8266) +#ifndef CONFIG_ESP_MAX_STA_CONN + #define CONFIG_ESP_MAX_STA_CONN 4 +#endif +#define EXAMPLE_MAX_STA_CONN CONFIG_ESP_MAX_STA_CONN + +#define WIFI_CONNECTED_BIT BIT0 +#define WIFI_FAIL_BIT BIT1 +#ifndef CONFIG_ESP_MAXIMUM_RETRY + #define CONFIG_ESP_MAXIMUM_RETRY 5 +#endif +/* FreeRTOS event group to signal when we are connected*/ +static EventGroupHandle_t s_wifi_event_group; +static int s_retry_num = 0; + +#define EXAMPLE_ESP_MAXIMUM_RETRY CONFIG_ESP_MAXIMUM_RETRY +static void event_handler(void* arg, esp_event_base_t event_base, + int32_t event_id, void* event_data) +{ + if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { + esp_wifi_connect(); + } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { + if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY) { + esp_wifi_connect(); + s_retry_num++; + ESP_LOGI(TAG, "retry to connect to the AP"); + } else { + xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT); + } + ESP_LOGI(TAG,"connect to the AP fail"); + } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { + ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; + ESP_LOGI(TAG, "got ip:%s", + ip4addr_ntoa(&event->ip_info.ip)); + s_retry_num = 0; + xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); + } +} + +int wifi_init_sta(void) +{ + word32 this_heap; + + s_wifi_event_group = xEventGroupCreate(); + + tcpip_adapter_init(); + + ESP_ERROR_CHECK(esp_event_loop_create_default()); + + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + ESP_ERROR_CHECK(esp_wifi_init(&cfg)); + + ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL)); + ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL)); + + wifi_config_t wifi_config = { + .sta = { + .ssid = EXAMPLE_ESP_WIFI_SSID, + .password = EXAMPLE_ESP_WIFI_PASS + }, + }; + + /* Setting a password implies station will connect to all security modes including WEP/WPA. + * However these modes are deprecated and not advisable to be used. In case your Access point + * doesn't support WPA2, these mode can be enabled by commenting below line */ + + if (strlen((char *)wifi_config.sta.password)) { + wifi_config.sta.threshold.authmode = WIFI_AUTH_WPA2_PSK; + } + + ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) ); + ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) ); + ESP_ERROR_CHECK(esp_wifi_start() ); + + ESP_LOGI(TAG, "wifi_init_sta finished. Connecting..."); + this_heap = esp_get_free_heap_size(); + ESP_LOGI(TAG, "this heap = %d", this_heap); + if (this_heap < WIFI_LOW_HEAP_WARNING) { + ESP_LOGW(TAG, "Warning: WiFi low heap: %d", WIFI_LOW_HEAP_WARNING); + } + /* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum + * number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above) */ + EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group, + WIFI_CONNECTED_BIT | WIFI_FAIL_BIT, + pdFALSE, + pdFALSE, + portMAX_DELAY); + + ESP_LOGI(TAG, "xEventGroupWaitBits finished."); + /* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually + * happened. */ + if (bits & WIFI_CONNECTED_BIT) { + ESP_LOGI(TAG, "connected to ap SSID:%s", + EXAMPLE_ESP_WIFI_SSID); + } else if (bits & WIFI_FAIL_BIT) { + ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s", + EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS); + } else { + ESP_LOGE(TAG, "UNEXPECTED EVENT"); + } + + ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler)); + ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler)); + vEventGroupDelete(s_wifi_event_group); + return ESP_OK; +} + +#elif ESP_IDF_VERSION_MAJOR < 4 /* event handler for wifi events */ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) { @@ -80,7 +207,7 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) ESP_LOGI(TAG, "got ip:%s", ip4addr_ntoa(&event->event_info.got_ip.ip_info.ip)); #endif - /* see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos_idf.html */ + /* see Espressif api-reference/system/freertos_idf.html */ xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); break; case SYSTEM_EVENT_STA_DISCONNECTED: @@ -197,7 +324,7 @@ int wifi_init_sta(void) .ssid = EXAMPLE_ESP_WIFI_SSID, .password = EXAMPLE_ESP_WIFI_PASS, /* Authmode threshold resets to WPA2 as default if password matches - * WPA2 standards (pasword len => 8). If you want to connect the + * WPA2 standards (password len => 8). If you want to connect the * device to deprecated WEP/WPA networks, Please set the threshold * value WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with * length and format matching to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK @@ -269,7 +396,8 @@ int wifi_init_sta(void) int wifi_show_ip(void) { - /* ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip)); */ - return 0; + /* TODO Causes panic: ESP_LOGI(TAG, "got ip:" IPSTR, + * IP2STR(&event->ip_info.ip)); */ + return ESP_OK; } #endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults index f8bce25ff..ca33fd17b 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults @@ -1,25 +1,155 @@ +# Set the known example app config to TLS Server (see user_settings.h) +CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_SERVER=y + +# CONFIG_EXAMPLE_WIFI_SSID="myssid" +# CONFIG_EXAMPLE_WIFI_PASSWORD="mypassword" + +# Some wolfSSL helpers +CONFIG_USE_WOLFSSL_ESP_SDK_TIME=y + +# sdkconfig.defaults for ESP8266 + ESP32 +# See separate sdkconfig.defaults.esp8266 +# FreeRTOS ticks at 1ms interval +CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_HZ=1000 CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y # -# Default main stack size +# Default main stack size. See user_settings.h # -# This is typically way bigger than needed for stack size. See user_settings.h +# This is typically bigger than needed for stack size. +# Units are words, not bytes. See user_settings.h # -CONFIG_ESP_MAIN_TASK_STACK_SIZE=55500 +# For wolfSSL SMALL_STACK, 3072 bytes should be sufficient for benchmark app. +# When using RSA, assign at least 10500 bytes, otherwise 5500 usually works for others +# We set this to 28672 for use in the "test everything possible" in the wolfssl_test app. +CONFIG_ESP_MAIN_TASK_STACK_SIZE=10500 -# Legacy stack size for older ESP-IDF versions -CONFIG_MAIN_TASK_STACK_SIZE=55500 +# Legacy stack size name for older ESP-IDF versions +CONFIG_MAIN_TASK_STACK_SIZE=10500 + +# +# Benchmark must not have CONFIG_NEWLIB_NANO_FORMAT enabled +CONFIG_NEWLIB_NANO_FORMAT=n +# +# Watchdog Timers +# +# We don't want to have the watchdog timeout during tests & benchmarks +# +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=n +# Panic & Watchdog +CONFIG_ESP_INT_WDT_TIMEOUT_MS=10000 +CONFIG_ESP_TASK_WDT_EN=n +CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y +CONFIG_ESP_INT_WDT=n + +# ESP8266 Watchdog: +CONFIG_TASK_WDT=n +CONFIG_TASK_WDT_PANIC=n + +# ESP8266 WDT +# CONFIG_ESP_PANIC_PRINT_REBOOT is not set +CONFIG_ESP_PANIC_PRINT_REBOOT=n +CONFIG_ESP_PANIC_PRINT_HALT=y + +# CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set +CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=n + +# ESP8266 Memory +CONFIG_FREERTOS_GLOBAL_DATA_LINK_IRAM=y +CONFIG_HEAP_DISABLE_IRAM=y + +# Performance +# CONFIG_COMPILER_OPTIMIZATION_PERF=y + +# Set max CPU frequency (falls back as needed for lower maximum) +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y + +# Enable wolfSSL TLS in esp-tls +# CONFIG_ESP_TLS_USING_WOLFSSL=y +# CONFIG_TLS_STACK_WOLFSSL=y + +# Bundles take up flash space and are disabled unless otherwise known to be needed +CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=n +# CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=y +# CONFIG_ESP_WOLFSSL_SMALL_CERT_VERIFY=y +# CONFIG_ESP_TLS_INSECURE=y + +# Disable mbedTLS +CONFIG_ESP_TLS_USING_MBEDTLS=n +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n + +# Some wolfSSL helpers +CONFIG_USE_WOLFSSL_ESP_SDK_TIME=n + +# CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set +CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=n + +# ESP8266 Memory +CONFIG_FREERTOS_GLOBAL_DATA_LINK_IRAM=y +CONFIG_HEAP_DISABLE_IRAM=y + +# Performance +# CONFIG_COMPILER_OPTIMIZATION_PERF=y + +# Set max COU frequency (falls back as needed for lower maximum) +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y + +# FreeRTOS ticks at 1ms interval +CONFIG_FREERTOS_UNICORE=y +CONFIG_FREERTOS_HZ=1000 + +# Ensure mbedTLS options are disabled +# CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=n +# CONFIG_MBEDTLS_TLS_CLIENT_ONLY=n +# CONFIG_MBEDTLS_TLS_SERVER=n +# CONFIG_MBEDTLS_TLS_CLIENT=n +# CONFIG_MBEDTLS_HARDWARE_AES=n +# CONFIG_MBEDTLS_HARDWARE_MPI=n +# CONFIG_MBEDTLS_HARDWARE_SHA=n +# CONFIG_MBEDTLS_ROM_MD5=n +# CONFIG_MBEDTLS_SSL_RENEGOTIATION=n +# CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=n +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1=n +# CONFIG_MBEDTLS_SSL_ALPN=n +# CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=n +# CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=n + +# The same-name config is used for both WiFi and client/server TLS, so we cannot disable: +# CONFIG_MBEDTLS_TLS_ENABLED=n +# CONFIG_MBEDTLS_TLS_DISABLED=y # # Compiler options # CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y +# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set +# CONFIG_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_COMPILER_OPTIMIZATION_NONE is not set CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set +CONFIG_COMPILER_FLOAT_LIB_FROM_GCCLIB=y CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2 +# CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set CONFIG_COMPILER_HIDE_PATHS_MACROS=y +# CONFIG_COMPILER_CXX_EXCEPTIONS is not set +# CONFIG_COMPILER_CXX_RTTI is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_NONE is not set CONFIG_COMPILER_STACK_CHECK_MODE_NORM=y +# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set CONFIG_COMPILER_STACK_CHECK=y +# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set +# CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS is not set +# CONFIG_COMPILER_DISABLE_GCC12_WARNINGS is not set +# CONFIG_COMPILER_DUMP_RTL_FILES is not set +# end of Compiler options + +# We don't know that the min is actually v2, +# but this is the earliest tested. +CONFIG_ESP32C3_REV_MIN_2=y # # Partition Table diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults.esp32c2 b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults.esp32c2 new file mode 100644 index 000000000..a24d9302e --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults.esp32c2 @@ -0,0 +1,7 @@ +# +# Main XTAL Config +# +CONFIG_XTAL_FREQ_26=y +# CONFIG_XTAL_FREQ_40 is not set +CONFIG_XTAL_FREQ=26 +# end of Main XTAL Config diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults.esp8266 b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults.esp8266 new file mode 100644 index 000000000..77299dfe4 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults.esp8266 @@ -0,0 +1,30 @@ +# ESP8266 WDT +# CONFIG_ESP_PANIC_PRINT_REBOOT is not set +CONFIG_ESP_PANIC_PRINT_REBOOT=n +CONFIG_ESP_PANIC_PRINT_HALT=y + +# Enable wolfSSL TLS in esp-tls (not yet supported in RTOS SDK 3.4 +CONFIG_ESP_TLS_USING_WOLFSSL=n +CONFIG_TLS_STACK_WOLFSSL=n + +# Bundles take up flash space and are disabled unless otherwise known to be needed +CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=n +# CONFIG_ESP_WOLFSSL_SMALL_CERT_VERIFY=y +# CONFIG_ESP_TLS_INSECURE=y + +# Disable mbedTLS +CONFIG_ESP_TLS_USING_MBEDTLS=y +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n + +# ESP8266 Memory +CONFIG_FREERTOS_GLOBAL_DATA_LINK_IRAM=y +CONFIG_HEAP_DISABLE_IRAM=y + +# ESP8266 Watchdog: +CONFIG_TASK_WDT=n +CONFIG_TASK_WDT_PANIC=n + +# ESP8266 WDT +# CONFIG_ESP_PANIC_PRINT_REBOOT is not set +CONFIG_ESP_PANIC_PRINT_REBOOT=n +CONFIG_ESP_PANIC_PRINT_HALT=y diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/wolfssl_server_ESP8266.vgdbproj b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/wolfssl_server_ESP8266.vgdbproj new file mode 100644 index 000000000..6181d50c7 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/wolfssl_server_ESP8266.vgdbproj @@ -0,0 +1,292 @@ + + + + + + Unknown + + true + + c9687472-a434-43a7-9026-7914f425b9b4 + true + true + SourceDirs + + + + + + com.visualgdb.xtensa-lx106-elf + + 8.4.0 + 8.1 + 1 + + + + release/v3.4 + rtos-sdk/v3.4 + RTOS_SDK + + 0 + + + + + + + + + + + + + Default + + false + + BuildMachine + BuiltinShortcut + + + + + + + COM70 + + 74880 + 8 + None + One + None + + + 0 + false + true + false + ASCII + + + 255 + 0 + 0 + 0 + + + 255 + 169 + 169 + 169 + + + 255 + 211 + 211 + 211 + + + 255 + 144 + 238 + 144 + + + 255 + 169 + 169 + 169 + + + + 16 + true + true + true + true + 0 + + LF + false + false + false + + + + true + + + + + True + + true + true + + Enabled + true + true + true + + true + + + + false + + apiModeling.google.GTest + core.builtin.BuiltinFunctions + core.builtin.NoReturnFunctions + core.CallAndMessage + core.DivideZero + core.DynamicTypePropagation + core.NonnilStringConstants + core.NonNullParamChecker + core.NullDereference + core.StackAddressEscape + core.UndefinedBinaryOperatorResult + core.uninitialized.ArraySubscript + core.uninitialized.Assign + core.uninitialized.Branch + core.uninitialized.CapturedBlockVariable + core.uninitialized.UndefReturn + core.VLASize + cplusplus.NewDelete + cplusplus.NewDeleteLeaks + cplusplus.SelfAssignment + deadcode.DeadStores + nullability.NullPassedToNonnull + nullability.NullReturnedFromNonnull + security.insecureAPI.getpw + security.insecureAPI.gets + security.insecureAPI.mkstemp + security.insecureAPI.mktemp + security.insecureAPI.UncheckedReturn + security.insecureAPI.vfork + unix.API + unix.cstring.BadSizeArg + unix.cstring.NullArg + unix.Malloc + unix.MallocSizeof + unix.MismatchedDeallocator + unix.StdCLibraryFunctions + unix.Vfork + + + -analyzer-store=region + -analyzer-opt-analyze-nested-blocks + -analyzer-eagerly-assume + + + + + + Debug + + build/Debug + sdkconfig-debug + false + + + + Release + + build/Release + sdkconfig-release + false + + + + + + + + + + + + + false + false + false + false + false + false + false + false + false + + false + false + false + false + false + false + true + false + None + false + false + + true + false + false + true + 0 + false + 0 + true + false + + + openocd + + -f interface/ftdi/tigard.cfg -f target/esp8266.cfg + + + + false + + 131072 + Enabled + + set remotetimeout 60 + target remote :$$SYS:GDB_PORT$$ + mon reset halt + load + mon xtensa_no_interrupts_during_steps on + mon esp8266_autofeed_watchdog on + + false + 0 + 0 + false + + 0 + Soft + 4096 + 4096 + + size4M + freq40M + QIO + + + + true + Disabled + 0 + false + false + true + false + false + + _estack + 0 + false + + true + + \ No newline at end of file diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/CMakeLists.txt index 6e70b4a62..2090c8ae8 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/CMakeLists.txt @@ -1,15 +1,148 @@ # wolfSSL Espressif Example Project CMakeLists.txt -# v1.1 +# v1.3 # # The following lines of boilerplate have to be in your project's # CMakeLists in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.5) +message(STATUS "Begin project ${CMAKE_PROJECT_NAME}") -add_compile_options(-DWOLFSSL_ESP_NO_WATCHDOG=1) +cmake_minimum_required(VERSION 3.16) -include($ENV{IDF_PATH}/tools/cmake/project.cmake) +# Optional no watchdog typically used for test & benchmark +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESP_NO_WATCHDOG=1") +else() + add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +endif() + +# The wolfSSL CMake file should be able to find the source code. +# Otherwise, assign an environment variable or set it here: +# +# set(WOLFSSL_ROOT "~/workspace/wolfssl-other-source") +# +# Optional WOLFSSL_CMAKE_SYSTEM_NAME detection to find +# USE_MY_PRIVATE_CONFIG path for my_private_config.h +# +# Expected path varies: +# +# WSL: /mnt/c/workspace +# Linux: ~/workspace +# Windows: C:\workspace +# +if(WIN32) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") + message(STATUS "Detected Windows") +endif() +if(CMAKE_HOST_UNIX) + message(STATUS "Detected UNIX") +endif() +if(APPLE) + message(STATUS "Detected APPLE") +endif() +if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") + message(STATUS "Detected WSL") +endif() +if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") + message(STATUS "Detected Linux") +endif() +if(APPLE) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") + message(STATUS "Detected Apple") +endif() +# End optional WOLFSSL_CMAKE_SYSTEM_NAME + +# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. +# set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) +string(REPLACE "\\" "/" PROTOCOL_EXAMPLES_DIR "$ENV{IDF_PATH}/examples/common_components/protocol_examples_common") + +if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") + message(STATUS "Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") +else() + message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") +endif() + +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER +message(STATUS "USERNAME = $ENV{USERNAME}") +if( "$ENV{USER}" STREQUAL "" ) # the bash user + if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user + message(STATUS "could not find USER or USERNAME") + else() + # the bash user is not blank, so we'll use it. + set(THIS_USER "$ENV{USERNAME}") + endif() +else() + # the bash user is not blank, so we'll use it. + set(THIS_USER "$ENV{USER}") +endif() +message(STATUS "THIS_USER = ${THIS_USER}") + +# Check that there are not conflicting wolfSSL components +# The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl +# The local component wolfSSL directory will be in ./components/wolfssl +message(STATUS "Checking for wolfSSL as Managed Component or not... ${CMAKE_HOME_DIRECTORY}") +if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" ) + # These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake' + # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL) + # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl/include" EXCLUDE_FROM_ALL) + # So we'll error out and let the user decide how to proceed: + message(WARNING "\nFound wolfSSL components in\n" + "./managed_components/wolfssl__wolfssl\n" + "and\n" + "./components/wolfssl\n" + "in project directory: \n" + "${CMAKE_HOME_DIRECTORY}") + message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n" + "If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove " + "or rename the idf_component.yml file typically found in ./main/") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl") + # A standard project component (not a Managed Component) + message(STATUS "No conflicting wolfSSL components found.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/components/wolfssl") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl") + # The official Managed Component called wolfssl from the wolfssl user. + message(STATUS "No conflicting wolfSSL components found as a Managed Component.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/gojimmypi__mywolfssl") + # There is a known gojimmypi staging component available for anyone: + message(STATUS "No conflicting wolfSSL components found as a gojimmypi staging Managed Component.") +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/${THIS_USER}__mywolfssl") + # Other users with permissions might publish their own mywolfssl staging Managed Component + message(STATUS "No conflicting wolfSSL components found as a Managed Component.") + set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/managed_components/${THIS_USER}__mywolfssl") +else() + message(STATUS "WARNING: wolfssl component directory not found.") +endif() + +# message(STATUS "EXTRA_COMPONENT_DIRS WOLFSSL_PATH: ${WOLFSSL_PATH}") +# list(APPEND EXTRA_COMPONENT_DIRS ${WOLFSSL_PATH}) # Not only is a project-level "set(COMPONENTS" not needed here, this will cause # an unintuitive error about Unknown CMake command "esptool_py_flash_project_args". +if(0) + message(STATUS "Begin optional PROTOCOL_EXAMPLES_DIR include") + # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. + set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + + if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") + message(STATUS "Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") + else() + message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + endif() + message(STATUS "End optional PROTOCOL_EXAMPLES_DIR include") +endif() + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) + project(wolfssl_test) +message(STATUS "end project") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/Makefile b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/Makefile index b110e86aa..0763d5ae6 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/Makefile +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/Makefile @@ -7,7 +7,7 @@ CFLAGS += -DWOLFSSL_USER_SETTINGS # Some of the tests are CPU intenstive, so we'll force the watchdog timer off. # There's an espressif NO_WATCHDOG; we don't use it, as it is reset by sdkconfig. -EXTRA_CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG +CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 PROJECT_NAME := wolfssl_test diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/README.md b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/README.md index e4e79dce8..8b6735886 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/README.md +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/README.md @@ -7,10 +7,10 @@ For general information on [wolfSSL examples for Espressif](../README.md), see t ## ESP Registry -The easiest way to get started with wolfSSL is by using the -[ESP Registry](https://components.espressif.com/components/wolfssl/wolfssl/) examples. +The easiest way to get started with wolfSSL is by using the +[ESP Registry](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/) examples. -``` +```bash . ~/esp/esp-idf/export.sh idf.py create-project-from-example "wolfssl/wolfssl^5.6.0-stable:wolfssl_test" cd wolfssl_benchmark @@ -22,13 +22,13 @@ idf.py -b 115200 flash monitor Open the VisualGDB Visual Studio Project file in the [VisualGDB directory](./VisualGDB/README.md) and click the "Start" button. No wolfSSL setup is needed. You may need to adjust your specific COM port. The default is `COM20`. -## ESP-IDF Commandline +## ESP-IDF Commandline (version 4.4 or greater for the ESP32) -1. `idf.py menuconfig` to configure the program. +1. `idf.py menuconfig` to configure the program. 1-1. Example Configuration -> - TEST_ARG : argument that you want to use. Default is "-lng 0" - The list of argument can be find in help. + There are no parametric arguments. See [wolfcrypt/test](https://github.com/wolfSSL/wolfssl/tree/master/wolfcrypt/test). + All features enabled in the `user_settings.h` will be tested. When you want to run the test program @@ -41,17 +41,18 @@ Reminder than when building on WSL in `/mnt/c` there will be a noticeable perfor Example build on WSL, assuming `git clone` from `c:\workspace`: -``` -WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.1 +```bash +WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.2 +# WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/master echo "Run export.sh from ${WRK_IDF_PATH}" . ${WRK_IDF_PATH}/export.sh # switch to test example -cd /mnt/c/workspace/wolfssl/IDE/Espressif/ESP-IDF/examples/wolfssl_test +cd /mnt/c/workspace/wolfssl-$USER/IDE/Espressif/ESP-IDF/examples/wolfssl_test -# Pick ESP-IDF install directory, this one for v5.1 in VisualGDB -. /mnt/c/SysGCC/esp32/esp-idf/v5.1/export.sh +# Pick ESP-IDF install directory, this one for v5.2 in VisualGDB +. /mnt/c/SysGCC/esp32/esp-idf/v5.2/export.sh # set target chipset idf.py set-target esp32s3 @@ -60,21 +61,73 @@ idf.py set-target esp32s3 idf.py erase-flash -p /dev/ttyS24 -b 115200 # start with a low upload speed, then increase as found operational -idf.py +idf.py # build and flash, in this example to COM24 idf.py build flash -p /dev/ttyS24 -b 115200 monitor ``` +## ESP-IDF Commandline (version 3.5 or earlier for the ESP8266) + + +```bash +WRK_IDF_PATH=/mnt/c/SysGCC/esp8266/rtos-sdk/v3.4 +. $WRK_IDF_PATH/export.sh + +# install as needed / prompted +/mnt/c/SysGCC/esp8266/rtos-sdk/v3.4/install.sh + +cd IDE/Espressif/ESP-IDF/examples/ESP8266 + +# adjust settings as desired +idf.py menuconfig + +idf.py build flash -p /dev/ttyS55 -b 115200 +``` + +## Espressif ESP8266 RTOS SDK Make Commandline + +```bash +# Find the ESP8266 SDK directory, shown here for WSL (Windows C:\ESP8266\esp\ESP8266_RTOS_SDK) +cd /mnt/c/ESP8266/esp/ESP8266_RTOS_SDK + +# Optionally run install as needed +./install.sh + +# Setup SDK +. ./export.sh + +# Find example to build +cd /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test + +make clean + +make + +make flash + +# or: +python /mnt/c/ESP8266/esp/ESP8266_RTOS_SDK/components/esptool_py/esptool/esptool.py --chip esp8266 --port /dev/ttyUSB0 --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 2MB 0x0 /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/bootloader/bootloader.bin 0x10000 /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/wolfssl_test.bin 0x8000 /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/partitions_singleapp.bin +``` + +## Putty (via WSL) + +Define a non-blank value for `ESPIDF_PUTTY_MONITOR` to launch `testMonitor.sh` output in putty.exe sessions from Windows. +Assumes `PUTTY_EXE="/mnt/c/tools/putty.exe"`. + +```bash +export ESPIDF_PUTTY_MONITOR=true +``` + ## Example Output -Note the default wolfSSL `user_settings.h` is configured by default to be the most +Note the default wolfSSL `user_settings.h` is configured by default to be the most compatible across the widest ranges of targets. Contact wolfSSL at support@wolfssl.com -for help in optimizing for your particular application, or see the +for help in optimizing for your particular application, or see the [docs](https://www.wolfssl.com/documentation/manuals/wolfssl/index.html). Compiled and flashed with `idf.py build flash -p /dev/ttyS7 -b 115200 monitor`: -``` +```text ets Jun 8 2016 00:22:57 rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) 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 5f42ad345..cc7ef0d47 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,5 +1,5 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # @@ -19,17 +19,67 @@ # # cmake for wolfssl Espressif projects # -# Version 5.7.0 template update + THIS_IDF_PATH +# Version 5.7.2 Espressif ESP-IDF integration # # See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html # - +message(STATUS "Begin wolfssl ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") cmake_minimum_required(VERSION 3.16) set(VERBOSE_COMPONENT_MESSAGES 1) +# Optional requires include: +# set(THIS_ESP_TLS "esp-tls") +set(THIS_ESP_TLS "") + +# function: IS_ESP_IDF_COMPONENT +# output: RESULT = 1 (true) if this component is located in the ESP-IDF components +# otherwise 0 (false) +function( IS_ESP_IDF_COMPONENT RESULT ) + # NOTE: Component location is based on the location of the CMakeList.txt + # and *not* the location of the wolfSSL source code. (which may be anywhere) + + # Normalize the paths to remove any trailing slashes + get_filename_component(NORMALIZED_IDF_PATH "${IDF_PATH}" REALPATH) + get_filename_component(NORMALIZED_TEST_PATH "${COMPONENT_DIR}" REALPATH) + + # Check if the test path starts with the IDF_PATH + string(FIND "${NORMALIZED_TEST_PATH}" "${NORMALIZED_IDF_PATH}" pos) + + if(${pos} EQUAL 0) + message(STATUS "${COMPONENT_DIR} is within IDF_PATH.") + set(${RESULT} 1 PARENT_SCOPE) + else() + message(STATUS "${COMPONENT_DIR} is not within IDF_PATH.") + set(${RESULT} 0 PARENT_SCOPE) + endif() +endfunction() + +# Determine if this cmake file is located in the ESP-IDF component directory or not, +# and if so, if it is being ignored (allowing the use of a local project one, instead). +IS_ESP_IDF_COMPONENT( IS_WOLSSL_ESP_IDF_COMPONENT ) +if( IS_WOLSSL_ESP_IDF_COMPONENT ) + message(STATUS "This wolfSSL is a component in ESP-IDF.") + if ( CONFIG_IGNORE_ESP_IDF_WOLFSSL_COMPONENT ) + idf_component_register() + message(STATUS "Warning: wolfSSL component in ESP-IDF is being ignored.") + return() + endif() +endif() + + +if( "${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}" STREQUAL "" ) + # nothing to do +else() + # Only forward slashes, or double backslashes are supported. + # By the time we get here the sdkconfig file has a value for wolfSSL source code root. + string(REPLACE "\\" "/" CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}) + message(STATUS "Cleaned wolfssl path: ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") +endif() + # The scope of this CMAKE_C_FLAGS is just this component: set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWOLFSSL_USER_SETTINGS") set(CMAKE_CURRENT_SOURCE_DIR ".") # set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component @@ -42,7 +92,7 @@ if ( "${WOLFSSL_ROOT}" STREQUAL "") endif() if( "$ENV{IDF_PATH}" STREQUAL "" ) - message(FATAL_ERROR "IDF_PATH Environment variable not set!") + message(FATAL_ERROR "IDF_PATH Environment variable not set!") else() string(REPLACE "\\" "/" THIS_IDF_PATH "$ENV{IDF_PATH}") endif() @@ -52,28 +102,28 @@ if(VERBOSE_COMPONENT_MESSAGES) if(WIN32) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") - message("Detected Windows") + message(STATUS "Detected Windows") endif() if(CMAKE_HOST_UNIX) - message("Detected UNIX") + message(STATUS "Detected UNIX") endif() if(APPLE) - message("Detected APPLE") + message(STATUS "Detected APPLE") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") - message("Detected WSL") + message(STATUS "Detected WSL") endif() if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") - message("Detected Linux") + message(STATUS "Detected Linux") endif() if(APPLE) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") - message("Detected Apple") + message(STATUS "Detected Apple") endif() endif() # End optional WOLFSSL_CMAKE_SYSTEM_NAME @@ -106,10 +156,11 @@ if( ("${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_benchmark") OR ("${CMAKE_PROJECT_ message(STATUS "Not including lwip for ${CMAKE_PROJECT_NAME}") else() # benchmark and test do not need wifi, everything else probably does: - set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component + set(COMPONENT_REQUIRES lwip "${THIS_ESP_TLS}") # we typically don't need lwip directly in wolfssl component endif() -# find the user name to search for possible "wolfssl-username" +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER message(STATUS "USERNAME = $ENV{USERNAME}") if( "$ENV{USER}" STREQUAL "" ) # the bash user if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user @@ -130,6 +181,25 @@ else() string(REPLACE "\\" "/" THIS_IDF_PATH "$ENV{IDF_PATH}") endif() +# ENVIRONMENT_VAR_TO_MACRO +# Check environment variable name EVARPARAM as [name] +# If defined, and has a value of EVARVALUE as [value], +# then assign a compiler definition "-D[name]=[value]" +function(ENVIRONMENT_VAR_TO_MACRO EVARPARAM EVARVALUE) + # If the EVARPARAM environment variable name is set to EVARVALUE, + # set the compiler flag definition to enable CSV output. + if ( "$ENV{${EVARPARAM}}" STREQUAL "${EVARVALUE}") + message(STATUS "Appending compile definition: -D${EVARPARAM}=${EVARVALUE}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${EVARPARAM}=${EVARVALUE}") + else() + if(DEFINED ENV{${EVARPARAM}}) + message(STATUS "Environment variable ${EVARPARAM} detected but set to $ENV{${EVARPARAM}}, not appending compile definition.") + else() + message(STATUS "Environment variable ${EVARPARAM} not detected, not appending compile definition.") + endif() + endif() +endfunction() + # COMPONENT_NAME = wolfssl # The component name is the directory name. "No feature to change this". # See https://github.com/espressif/esp-idf/issues/8978#issuecomment-1129892685 @@ -147,7 +217,8 @@ endif() # function: IS_WOLFSSL_SOURCE # parameter: DIRECTORY_PARAMETER - the directory to test # output: RESULT = contains contents of DIRECTORY_PARAMETER for wolfssl directory, otherwise blank. -function(IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER RESULT) +function( IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER + RESULT ) if (EXISTS "${DIRECTORY_PARAMETER}/wolfcrypt/src") set(${RESULT} "${DIRECTORY_PARAMETER}" PARENT_SCOPE) else() @@ -166,26 +237,56 @@ function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY) message(STATUS "Starting FIND_WOLFSSL_DIRECTORY: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") if ( "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}" STREQUAL "" ) + # The parameter is empty, so we certainly need to search. + # First, see if there's an environment variable. This takes highest priority (unless already found as hard-coded, above) set(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}") if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) message(STATUS "The WOLFSSL_ROOT environment variable is not set. Searching...") - else() - get_filename_component(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}" ABSOLUTE) - IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSL) - if( FOUND_WOLFSSL ) - message(STATUS "Found WOLFSSL_ROOT via Environment Variable:") + # Next, if not found, see if wolfSSL was selected for ESP-TLS Kconfig + if(CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT) + set(CURRENT_SEARCH_DIR ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}) + get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" ABSOLUTE) + message(STATUS "WOLFSSL_ROOT found in sdkconfig/KConfig: ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") else() - message(FATAL_ERROR "WOLFSSL_ROOT Environment Variable defined, but path not found:") - message(STATUS "$ENV{WOLFSSL_ROOT}") - endif() - endif() + message(STATUS "wolfSSL not defined in [Component Config] [wolfssl]. Continuing search...") + # If not specified as a search hint in OUTPUT_FOUND_WOLFSSL_DIRECTORY: + # This wolfSSL component CMakeLists.txt may be found EITHER in: + # 1) local project component + # 2) ESP-IDF share components + # We'll start in the CMAKE_CURRENT_SOURCE_DIR, typically [something]/projectname/components/wolfssl + # That option might find wolfSSL source code as a copy in the component directory (e.g. Managed Components) + # Unless cmake is in the ESP-IDF, in which case it is unlikely to find wolfSSL source in any parent. + message(STATUS "CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}") + get_filename_component(CURRENT_SEARCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE) + message(STATUS "CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}") + string(LENGTH ${CURRENT_SEARCH_DIR} CURRENT_SEARCH_DIR_LENGTH) + endif() # CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT + endif() # check environment var blank else() - get_filename_component(CURRENT_SEARCH_DIR "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}" ABSOLUTE) + message(STATUS "Parameter found for FIND_WOLFSSL_DIRECTORY") + message(STATUS "Setting wolfSSL search directory to: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + set(CURRENT_SEARCH_DIR "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + endif() # parameter empty + + # Check to see if we found a path in environment or config settings, above. + if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) + message(STATUS "Source for wolfSSL not specified in path nor config settings.") + # We'll continue the search by recursing up the directory tree, below. + else() + # Setting found! Does it contain a valid path? + string(REPLACE "\\" "/" CURRENT_SEARCH_DIR ${CURRENT_SEARCH_DIR}) + get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" ABSOLUTE) IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSL) if( FOUND_WOLFSSL ) - message(STATUS "Found WOLFSSL_ROOT via prior specification.") + message(STATUS "Found wolfSSL source code via setting: ${CURRENT_SEARCH_DIR}") + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) + return() else() - message(FATAL_ERROR "WOLFSSL_ROOT Variable defined, but path not found: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + if(WIN32) + message(STATUS "When specifying a path for Windows, use forward slahes, or double backslashes.") + endif() + message(STATUS "CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT sdkconfig setting = ${CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT}") + message(STATUS "WOLFSSL_ROOT Variable defined, but source code not found: ${CURRENT_SEARCH_DIR}") endif() endif() @@ -286,6 +387,11 @@ endfunction() message(STATUS "CONFIG_TARGET_PLATFORM = ${CONFIG_TARGET_PLATFORM}") +# Check for environment variable that may be assigned to macros +ENVIRONMENT_VAR_TO_MACRO("GENERATE_MACHINE_PARSEABLE_REPORT" "1") +ENVIRONMENT_VAR_TO_MACRO("WOLFSSL_BENCHMARK_FIXED_CSV" "1") + +# Optional variable inspection if (0) get_cmake_property(_variableNames VARIABLES) list (SORT _variableNames) @@ -302,15 +408,25 @@ endif() if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) # There's no esp_timer, no driver components for the ESP8266 - message(STATUS "Early expansion EXCLUDES esp_timer: ${THIS_INCLUDE_TIMER}") - message(STATUS "Early expansion EXCLUDES driver: ${THIS_INCLUDE_DRIVER}") - set(THIS_INCLUDE_TIMER "") - set(THIS_INCLUDE_DRIVER "") + message(STATUS "Early expansion EXCLUDES for esp8266:") + message(STATUS "THIS_INCLUDE_DRIVER: '${THIS_INCLUDE_DRIVER}'") + message(STATUS "THIS_INCLUDE_TIMER: '${THIS_INCLUDE_TIMER}'") + message(STATUS "Early expansion INCLUDE for esp8266:") + message(STATUS "THIS_INCLUDE_PTHREAD: '${THIS_INCLUDE_PTHREAD}'") + set(THIS_ESP_TLS "") + set(THIS_INCLUDE_DRIVER "") + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_PTHREAD "pthread") else() message(STATUS "Early expansion includes esp_timer: ${THIS_INCLUDE_TIMER}") message(STATUS "Early expansion includes driver: ${THIS_INCLUDE_DRIVER}") - set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_ESP_TLS "esp-tls") set(THIS_INCLUDE_DRIVER "driver") + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_PTHREAD "") + # Let the app know that we've included the esp-tls component requirement. + # This is critical for use the the esp-tls component. See wolfssl esp_crt_bundle.c file. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_REQUIRED_ESP_TLS=1") endif() if(CMAKE_BUILD_EARLY_EXPANSION) @@ -318,8 +434,10 @@ if(CMAKE_BUILD_EARLY_EXPANSION) idf_component_register( REQUIRES "${COMPONENT_REQUIRES}" PRIV_REQUIRES # esp_hw_support - ${THIS_INCLUDE_TIMER} - ${THIS_INCLUDE_DRIVER} # this will typically only be needed for wolfSSL benchmark + "${THIS_ESP_TLS}" + "${THIS_INCLUDE_PTHREAD}" + "${THIS_INCLUDE_TIMER}" + "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark ) else() @@ -328,6 +446,15 @@ else() message(STATUS "wolfssl component config:") message(STATUS "************************************************************************************************") + if ( "${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") + # There's no esp_timer, no driver components for the ESP8266 + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_DRIVER "") + else() + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_DRIVER "driver") + endif() + # search for wolfSSL FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) if(WOLFSSL_ROOT) @@ -341,7 +468,9 @@ else() # Abort CMake after fatal error. endif() else() - message(STATUS "Searching for wolfSL source code...") + message(STATUS "Source code for wolfSSL still not found.") + message(STATUS "Searching from project home: ${CMAKE_HOME_DIRECTORY} ...") + set(WOLFSSL_ROOT "${CMAKE_HOME_DIRECTORY}") FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) endif() @@ -349,11 +478,18 @@ else() if(WOLFSSL_ROOT) message(STATUS "Confirmed wolfssl directory at: ${WOLFSSL_ROOT}") else() - message(STATUS "Failed: wolfssl directory not found.") + # Try to allow a more intuitive error that the source code was not found in cmake: + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_WARNING_SOURCE_NOT_FOUND") + + message(STATUS "Failed: wolfssl source code directory not found.") # Abort. We need wolfssl _somewhere_. - message(FATAL_ERROR "Could not find wolfssl in any parent directory named wolfssl-${THIS_USER}, wolfssl-master, or wolfssl.\n" - "Try setting WOLFSSL_ROOT environment variable, cmake variable in project, copy source, or use managed components.") - # Abort CMake after fatal error. + message(STATUS "") + message(STATUS "") + message(STATUS "Could not find wolfssl in any parent directory named wolfssl-${THIS_USER}, wolfssl-master, or wolfssl.\n" + "Try setting WOLFSSL_ROOT environment variable, cmake variable in project, copy source, or use managed components.") + message(STATUS "") + message(STATUS "") + # Abort CMake after fatal error. (or not?) endif() set(INCLUDE_PATH ${WOLFSSL_ROOT}) @@ -379,22 +515,24 @@ else() endif() endif() + message(STATUS "WOLFSSL_EXTRA_PROJECT_DIR = ${WOLFSSL_EXTRA_PROJECT_DIR}") set(COMPONENT_SRCDIRS "\"${WOLFSSL_ROOT}/src/\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif/esp_crt_bundle\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/atmel\"" "\"${WOLFSSL_EXTRA_PROJECT_DIR}\"" ) # COMPONENT_SRCDIRS message(STATUS "This COMPONENT_SRCDIRS = ${COMPONENT_SRCDIRS}") - # wolfSSL user_settings.h is in the local project. + # wolfSSL user_settings.h may be in the local project. + # TODO check if exists and possibly set to ESP-IDF set(WOLFSSL_PROJECT_DIR "${CMAKE_HOME_DIRECTORY}/components/wolfssl") - # add_definitions(-DWOLFSSL_USER_SETTINGS_DIR="${WOLFSSL_PROJECT_DIR}/include/user_settings.h") string(REPLACE "/" "//" STR_WOLFSSL_PROJECT_DIR "${WOLFSSL_PROJECT_DIR}") - add_definitions(-DWOLFSSL_USER_SETTINGS_DIR="${STR_WOLFSSL_PROJECT_DIR}//include//user_settings.h") - + add_compile_definitions(WOLFSSL_USER_SETTINGS_DIR="${STR_WOLFSSL_PROJECT_DIR}/include/user_settings.h") + message(STATUS "Added definition for user_settings.h: -DWOLFSSL_USER_SETTINGS_DIR=\"${STR_WOLFSSL_PROJECT_DIR}//include//user_settings.h\"") # Espressif may take several passes through this makefile. Check to see if we found IDF string(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "" WOLFSSL_FOUND_IDF) @@ -427,8 +565,7 @@ else() message(STATUS "**************************************************************************************") message(STATUS "") - message(FATAL_ERROR "Please use wolfSSL in either local project or Espressif components, but not both.") - # Abort CMake after fatal error. + message(STATUS "Please use wolfSSL in either local project or Espressif components, but not both.") # Optional: if you change the above FATAL_ERROR to STATUS you can warn at runtime with this macro definition: set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING") @@ -536,7 +673,9 @@ else() # depending on the environment, we may need to swap backslashes with forward slashes string(REPLACE "\\" "/" RTOS_IDF_PATH "$ENV{IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") - string(REPLACE "\\" "/" WOLFSSL_ROOT ${WOLFSSL_ROOT}) + if(WOLFSSL_ROOT) + string(REPLACE "\\" "/" WOLFSSL_ROOT ${WOLFSSL_ROOT}) + endif() if(IS_DIRECTORY "${RTOS_IDF_PATH}") message(STATUS "Found current RTOS path: ${RTOS_IDF_PATH}") @@ -552,7 +691,7 @@ else() message(STATUS "THIS_IDF_PATH = $THIS_IDF_PATH") # wolfSSL-specific include directories set(COMPONENT_ADD_INCLUDEDIRS - "./include" # this is the location of wolfssl user_settings.h + "./include" # this is the location of local project wolfssl user_settings.h "\"${WOLFSSL_ROOT}/\"" "\"${WOLFSSL_ROOT}/wolfssl/\"" "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/\"" @@ -589,8 +728,8 @@ else() "\"${WOLFSSL_ROOT}/src/ssl_sess.c\"" # included by ssl.c "\"${WOLFSSL_ROOT}/src/x509.c\"" "\"${WOLFSSL_ROOT}/src/x509_str.c\"" - "\"${WOLFSSL_ROOT}/wolfcrypt/src/ext_kyber.c\"" # external Kyber disabled by default - "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/ext_kyber.h\"" # external Kyber disabled by default + "\"${WOLFSSL_ROOT}/wolfcrypt/src/ext_kyber.c\"" # external non-wolfssl Kyber disabled by default + "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/ext_kyber.h\"" # external non-wolfssl Kyber disabled by default "\"${WOLFSSL_ROOT}/wolfcrypt/src/evp.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/misc.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_arm32.c\"" @@ -601,6 +740,7 @@ else() "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_cortexm.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_x86_64.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_x86_64_asm.S\"" + "\"${WOLFSSL_ROOT}/examples\"" # Examples are distributed in Managed Components, but not part of a project. "\"${EXCLUDE_ASM}\"" ) @@ -622,15 +762,120 @@ else() # see https://docs.espressif.com/projects/esp-idf/en/stable/esp32/migration-guides/release-5.x/build-system.html?highlight=space%20path # set(EXTRA_COMPONENT_DIRS "${COMPONENT_SRCDIRS}") - idf_component_register( - SRC_DIRS "${COMPONENT_SRCDIRS}" - INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}" - REQUIRES "${COMPONENT_REQUIRES}" - EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}" - PRIV_REQUIRES - "${THIS_INCLUDE_TIMER}" - "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark - ) + + if(WOLFSSL_ROOT) + # Only register the component if we found wolfSSL source. + # This is important to allow Cmake to finish to completion, otherwise the UI + # may not be able to display the Kconfig settings to fix a bad or missing source. + idf_component_register( + SRC_DIRS "${COMPONENT_SRCDIRS}" + INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}" + REQUIRES "${COMPONENT_REQUIRES}" + EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}" + PRIV_REQUIRES + "${THIS_ESP_TLS}" + "${THIS_INCLUDE_TIMER}" + "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark + ) + else() + # Register the component simply to allow CMake to complete, but there's no wolfSSL source. + # Expect many other errors, but the project should at least be loadable and UI can edit Kconfig settings. + idf_component_register() + message(STATUS "Warning: wolfSSL component not registered as no source code found (WOLFSSL_ROOT is blank)") + endif() + +# function(WOLFSSL_INIT_CERT_BUNDLE) +if( CONFIG_WOLFSSL_CERTIFICATE_BUNDLE + AND NOT CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + AND NOT ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") + ) + if (CMAKE_BUILD_EARLY_EXPANSION) + message(ERROR "Bundle Cert initialization must occur during CMAKE_BUILD_EARLY_EXPANSION") + endif() + # reminder: we need a value for wolfSSL root first! + if( "${WOLFSSL_ROOT}" STREQUAL "" ) + message(ERROR "Certificate bundles need a value for WOLFSSL_ROOT") + endif() + set(WOLFSSL_ESP_CRT_BUNDLE_DIR ${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif/esp_crt_bundle) + message(STATUS "WOLFSSL_ESP_CRT_BUNDLE_DIR=${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + if(EXISTS "${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + set(bundle_name "x509_crt_bundle_wolfssl") + + # For now the certs are in the same directory + set(DEFAULT_CRT_DIR "${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + + # Generate custom certificate bundle using the generate_cert_bundle utility + set(GENERATE_CERT_BUNDLEPY ${python} ${WOLFSSL_ESP_CRT_BUNDLE_DIR}/gen_crt_bundle.py) + + if(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_all.pem ${DEFAULT_CRT_DIR}/cacrt_local.pem) + elseif(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_CMN) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_all.pem ${DEFAULT_CRT_DIR}/cacrt_local.pem) + list(APPEND args --filter ${DEFAULT_CRT_DIR}/cmn_crt_authorities.csv) + endif() + + # Add deprecated root certs if enabled. This config is not visible if the default cert + # bundle is not selected + if(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEPRECATED_LIST) + list(APPEND crt_paths ${DEFAULT_CRT_DIR}/cacrt_deprecated.pem) + endif() + + if(CONFIG_WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE) + get_filename_component(custom_bundle_path + ${CONFIG_WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE_PATH} ABSOLUTE BASE_DIR "${project_dir}") + list(APPEND crt_paths ${custom_bundle_path}) + message(STATUS "Using a custom wolfSSL bundle path: ${custom_bundle_path}") + else() + message(STATUS "Not using a custom wolfSSL bundle path.") + endif() + list(APPEND args --input ${crt_paths} -q) + + message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") + get_filename_component(crt_bundle + ${bundle_name} + ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") + + message(STATUS "Setting up bundle generate: ${GENERATE_CERT_BUNDLEPY} ${args}") + message(STATUS "Depends on custom bundle path: ${custom_bundle_path}") + message(STATUS "crt_bundle ${crt_bundle}") + message(STATUS "COMPONENT_LIB ${COMPONENT_LIB}") + message(STATUS "GENERATE_CERT_BUNDLEPY ${GENERATE_CERT_BUNDLEPY}") + message(STATUS "args ${args}") + message(STATUS "cert_bundle ${cert_bundle}") + + # Generate bundle according to config + # File is generated at build time, not cmake load + add_custom_command(OUTPUT ${crt_bundle} + COMMAND ${GENERATE_CERT_BUNDLEPY} ARGS ${args} + DEPENDS ${custom_bundle_path} + VERBATIM) + + if(EXISTS "${crt_bundle}") + message(STATUS "Bundle file exists from prior build: ${crt_bundle}") + else() + message(STATUS "Bundle file expected during next build: ${crt_bundle}") + endif() + + # Reminder the file is generated at build time, not cmake load time. + message(STATUS "wolfSSL Cert Bundle File to be created at build time in: ${crt_bundle}") + + add_custom_target(custom_wolfssl_bundle DEPENDS ${cert_bundle}) + + # the wolfSSL crtificate bundle is baked into wolfSSL + add_dependencies(${COMPONENT_LIB} custom_wolfssl_bundle) + + # COMPONENT_LIB may vary: __idf_wolfssl, __idf_esp_wolfssl, etc + # target_add_binary_data(__idf_wolfssl ${crt_bundle} BINARY) + target_add_binary_data(${COMPONENT_LIB} ${crt_bundle} BINARY) + set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + APPEND PROPERTY ADDITIONAL_CLEAN_FILES + "${crt_bundle}") + else() + message(STATUS "WARNING: CONFIG_WOLFSSL_CERTIFICATE_BUNDLE enabled but directory not found: ${WOLFSSL_ESP_CRT_BUNDLE_DIR}") + endif() +endif() + +# endfunction() # WOLFSSL_INIT_CERT_BUNDLE # Some optional diagnostics. Verbose ones are truncated. if (VERBOSE_COMPONENT_MESSAGES) @@ -662,6 +907,12 @@ else() endif() # target_sources(wolfssl PRIVATE "\"${WOLFSSL_ROOT}/wolfssl/\"" "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt\"") + message(STATUS "DETECTED_PROJECT_NAME=${CMAKE_PROJECT_NAME}") + message(STATUS "COMPONENT_TARGET=${COMPONENT_TARGET}") + target_compile_definitions(${COMPONENT_TARGET} PRIVATE DETECTED_PROJECT_NAME="${CMAKE_PROJECT_NAME}") + if( "${CMAKE_PROJECT_NAME}" STREQUAL "esp_http_client_example" ) + target_compile_definitions(${COMPONENT_TARGET} PRIVATE APP_ESP_HTTP_CLIENT_EXAMPLE="y") + endif() endif() # CMAKE_BUILD_EARLY_EXPANSION @@ -707,7 +958,7 @@ function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) message(STATUS "Found ${VAR_OUPUT}=${VAR_VALUE}") # the interesting part is defining the VAR_OUPUT name a value to use in the app - add_definitions(-D${VAR_OUPUT}=\"${VAR_VALUE}\") + add_compile_definitions(${VAR_OUPUT}=\"${VAR_VALUE}\") else() # if we get here, check the execute_process command and parameters. message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT") @@ -715,35 +966,89 @@ function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) endif() endfunction() # LIBWOLFSSL_SAVE_INFO +execute_process( + COMMAND ${git_cmd} "rev-parse" "--is-inside-work-tree" + OUTPUT_VARIABLE IS_GIT_REPO + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + # create some programmatic #define values that will be used by ShowExtendedSystemInfo(). # see wolfcrypt\src\port\Espressif\esp32_utl.c -if(NOT CMAKE_BUILD_EARLY_EXPANSION) +if(NOT CMAKE_BUILD_EARLY_EXPANSION AND WOLFSSL_ROOT AND (IS_GIT_REPO STREQUAL "true")) set (git_cmd "git") message(STATUS "Adding macro definitions:") # LIBWOLFSSL_VERSION_GIT_ORIGIN: git config --get remote.origin.url - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "config" "--get" "remote.origin.url" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "config" "--get" "remote.origin.url" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_ORIGIN "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_BRANCH: git rev-parse --abbrev-ref HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--abbrev-ref" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--abbrev-ref" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_BRANCH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_HASH: git rev-parse HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_SHORT_HASH: git rev-parse --short HEAD - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_SHORT_HASH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_HASH_DATE git show --no-patch --no-notes --pretty=\'\%cd\' - execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ) + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} + "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" + OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ) LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH_DATE "${TMP_OUT}" "${TMP_RES}") LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_WOLFSSL_ROOT "${WOLFSSL_ROOT}" "${TMP_RES}") - message(STATUS "************************************************************************************************") - message(STATUS "wolfssl component config complete!") - message(STATUS "************************************************************************************************") endif() + +# Ensure flag "-DWOLFSSL_ESPIDF" is already in CMAKE_C_FLAGS if not yet found from project +string(FIND "${CMAKE_C_FLAGS}" "-DWOLFSSL_ESPIDF" FLAG_ALRREADY_FOUND_WOLFSSL_ESPIDF) + +if(FLAG_ALRREADY_FOUND_WOLFSSL_ESPIDF EQUAL -1) + # Flag not found, append it + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESPIDF") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +endif() + +if(WOLFSSL_ROOT) + message(STATUS "Using wolfSSL in ${WOLFSSL_ROOT}") + + # PlatformIO does not process script from from the Espressif cmake process. + # We need to know where wolfSSL source code was found, so save it in the + # PIO_WOLFSSL_ROOT environment variable to later be read by extra_script.py + + set(ENV{PIO_WOLFSSL_ROOT} "${WOLFSSL_ROOT}") + message(STATUS "PIO_WOLFSSL_ROOT = $ENV{PIO_WOLFSSL_ROOT}") + message(STATUS "PLATFORMIO_BUILD_DIR = $ENV{PLATFORMIO_BUILD_DIR}") + # See esp-tls Kconfig; menu "ESP-TLS", ESP_TLS_LIBRARY_CHOOSE + if(CONFIG_ESP_TLS_USING_WOLFSSL) + if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) + message(STATUS "This version of wolfSSL is not supported on the ESP8266 esp-tls at this time. Check ESP-TLS config") + else() + message(STATUS "wolfSSL will be used for ESP-TLS") + endif() + else() + message(STATUS "WARNING: wolfSSL NOT selected for ESP-TLS. Features and performance will be limited.") + endif() +else() + message(STATUS "") + message(STATUS "Consider setting WOLFSSL_ROOT environment variable, use Kconfig setting, or set manually in this cmake file, above.") + message(STATUS "") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "ERROR: Could not find wolfSSL Source Code") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") +endif() + +message(STATUS "************************************************************************************************") +message(STATUS "wolfSSL component config complete!") +message(STATUS "************************************************************************************************") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/Kconfig b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/Kconfig new file mode 100644 index 000000000..150913190 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/Kconfig @@ -0,0 +1,523 @@ +# Kconfig template +# +# Copyright (C) 2006-2025 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 +# + +# Kconfig File Version 5.7.2.001 for esp-idf integration + +# Kconfig Format Rules +# +# See: +# https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/kconfig.html +# +# Format rules for Kconfig files are as follows: +# +# Option names in any menus should have consistent prefixes. The prefix +# currently should have at least 3 characters. +# +# The unit of indentation should be 4 spaces. All sub-items belonging to a +# parent item are indented by one level deeper. For example, menu is indented +# by 0 spaces, config menu by 4 spaces, help in config by 8 spaces, and the +# text under help by 12 spaces. +# +# No trailing spaces are allowed at the end of the lines. +# +# The maximum length of options is NOT 50 characters as documented. +# kconfcheck will complain that options should be 40 at most. +# +# Fix option lengths first. Superfluous errors on other lines may occur. +# +# The maximum length of lines is 120 characters. +# +# python -m kconfcheck +# +# --------------------------------------------------------------------------------------------------------------------- +# Begin main wolfSSL configuration menu +# --------------------------------------------------------------------------------------------------------------------- +# See ESP-IDF esp-tls component for config TLS_STACK_WOLFSSL + +menu "wolfSSL" + + menu "Hardening" + config ESP_WOLFSSL_WC_NO_HARDEN + bool "Disable wolfSSL hardening" + default n + help + Sets WC_NO_HARDEN + + config ESP_WOLFSSL_TFM_TIMING_RESISTANT + bool "Enable TFM Timing Resistant Code" + default n + help + Sets TFM_TIMING_RESISTANT. + + endmenu # Hardening + + config ESP_WOLFSSL_ENABLE_BENCHMARK + bool "Enable wolfSSL Benchmark Library" + default n + help + Enables wolfcrypt/benchmark/benchmark.c code for benchmark metrics. Disables NO_CRYPT_BENCHMARK. + + + menu "Benchmark Debug" + config ESP_DEBUG_WOLFSSL_BENCHMARK_TIMING + bool "Enable benchmark timing debug" + depends on ESP_WOLFSSL_ENABLE_BENCHMARK + default n + help + Enable wolfssl debug for benchmark metric timing (CPU Cycles, RTOS ticks, etc). + + config ESP_WOLFSSL_BENCHMARK_TIMER_DEBUG + bool "Enable benchmark timer debug" + depends on ESP_WOLFSSL_ENABLE_BENCHMARK + default n + help + Turn on timer debugging (used when CPU cycles not available) + + endmenu # Benchmark Debug + + # ----------------------------------------------------------------------------------------------------------------- + # wolfCrypt Test + # ----------------------------------------------------------------------------------------------------------------- + config ESP_WOLFSSL_ENABLE_TEST + bool "Enable wolfCrypt Test Library" + default n + help + Enables wolfcrypt/test/test.c code for testing. Disables NO_CRYPT_TEST. + + menu "wolfCrypt tests" + config WOLFSSL_HAVE_WOLFCRYPT_TEST_OPTIONS + bool "Enable wolfCrypt Test Options" + depends on ESP_WOLFSSL_ENABLE_TEST + default n + help + Enables HAVE_WOLFCRYPT_TEST_OPTIONS + + config TEST_ESPIDF_ALL_WOLFSSL + bool "Enable all features to use in tests" + depends on ESP_WOLFSSL_ENABLE_TEST + default n + help + Enables TEST_ESPIDF_ALL_WOLFSSL + + endmenu # wolfCrypt tests + + # ----------------------------------------------------------------------------------------------------------------- + # Apple HomeKit Options + # ----------------------------------------------------------------------------------------------------------------- + menu "Apple HomeKit" + config WOLFSSL_APPLE_HOMEKIT + bool "Enable Apple HomeKit options" + default n + help + Enables FP_MAX_BITS (8192 * 2), SRP, ChaCha, Poly1305, Base64 encoding needed for Apple HomeKit. + endmenu # Apple HomeKit + # ----------------------------------------------------------------------------------------------------------------- + + config ESP_WOLFSSL_DISABLE_MY_ECC + bool "Disable ECC in my project" + default "n" + help + ECC is enabled by default. Select this option to disable. + + config ESP_WOLFSSL_ENABLE_MY_USE_RSA + bool "Enable RSA in my project" + default "n" + help + RSA is disabled by default. Select this option to enable. + + config ESP_WOLFSSL_BENCHMARK + bool "Enable wolfSSL Benchmark" + default n + help + Enables user settings relevant to benchmark code + + config ESP_TLS_USING_WOLFSSL_SPECIFIED + bool "Use the specified wolfssl for ESP-TLS" + default Y + help + Includes wolfSSL from specified directory (not using esp-wolfssl). + + config ESP_WOLFSSL_NO_USE_FAST_MATH + bool "Disable FAST_MATH library and all ESP32 Hardware Acceleration" + select ESP_WOLFSSL_NO_HW + select ESP_WOLFSSL_NO_HW_AES + select ESP_WOLFSSL_NO_HW_HASH + select ESP_WOLFSSL_NO_HW_RSA_PRI + select ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + default n + help + When disabling all hardware acceleration for smaller memory footprint, + disabling TFM fast math provides faster wolfSSL software algorithms in an + even smaller flash memory footprint. + + menu "Protocol Config" + config WOLFSSL_HAVE_ALPN + bool "Enable ALPN (Application Layer Protocol Negotiation) in wolfSSL" + default y + + config WOLFSSL_ALLOW_TLS13 + bool "Allow TLS 1.3" + default y + help + Allow TLS to fallback to TLS1.2. Memory footprint will likely be larger for TLS1.2. + When disabled HTTPS and MQTT over TLS connections will fail if TLS1.3 not accepted. + + config WOLFSSL_ALLOW_TLS12 + bool "Allow TLS 1.2" + default n + help + Allow TLS to fallback to TLS1.2. Memory footprint will likely be larger for TLS1.2. + When disabled HTTPS and MQTT over TLS connections will fail if TLS1.3 not accepted. + + config WOLFSSL_HAVE_TLS_EXTENSIONS + bool "Enable TLS Extensions" + default y + help + Sets HAVE_TLS_EXTENSIONS which is needed for TLS 1.3, SNI, ALPN, and more. + + config WOLFSSL_ALT_CERT_CHAINS + bool "Enable Alternate Certificate Chains" + default n + help + The option relaxes the default strict wolfSSL certificate chain processing. This + will typically need to be enabled when loading only a CA file. Typically solves + the -188 ASN_NO_SIGNER_E error. Use with caution. + + config WOLFSSL_HAVE_OCSP + bool "Enable OCSP (Online Certificate Status Protocol) in wolfSSL" + default n + help + Sets HAVE_OCSP + + endmenu # Protocol Config + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + config TLS_STACK_WOLFSSL + # Invisible option that locks TLS_STACK_WOLFSSL to ESP_TLS_USING_WOLFSSL + bool + default n + select FREERTOS_ENABLE_BACKWARD_COMPATIBILITY + help + Includes wolfSSL in ESP-TLS so that it can be compiled with wolfSSL as its SSL/TLS library. + Enabled when wolfSSL is selected in ESP_TLS_LIBRARY_CHOOSE. + + menu "wolfSSL ESP-TLS" + depends on ESP_TLS_USING_WOLFSSL + + menu "Certificate Bundle" + depends on ESP_TLS_USING_WOLFSSL + + config WOLFSSL_CERTIFICATE_BUNDLE + bool "Enable trusted root certificate bundle" + default y if ESP_TLS_USING_WOLFSSL + default n + depends on ESP_TLS_USING_WOLFSSL + help + Enable support for large number of default root certificates + + When enabled this option allows user to store default as well + as customer specific root certificates in compressed format rather + than storing full certificate. For the root certificates the public key and the subject name + will be stored. + + config WOLFSSL_NO_ASN_STRICT + bool "Relax Certificate ASN Strict Checks" + default n + depends on ESP_TLS_USING_WOLFSSL + help + Allows sub-optimal certificate ASN checks. Unless using a bundle with known issues, + it is recommended to NOT enable this. + + config WOLFSSL_ASN_ALLOW_0_SERIAL + bool "Allow cert missing an ASN Serial Number" + default y + depends on ESP_TLS_USING_WOLFSSL + help + Although not recommended, there may be certificates in the bundle that are missing + a serial number. This option allows the missing value without having to fully + disable strict ASN checking with WOLFSSL_NO_ASN_STRICT. + + choice WOLFSSL_DEFAULT_CERTIFICATE_BUNDLE + bool "Default certificate bundle options" + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + default WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL + + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_FULL + bool "Use the full default certificate bundle" + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_CMN + bool "Use only the most common certificates from the default bundles" + help + Use only the most common certificates from the default bundles, reducing the size with 50%, + while still having around 99% coverage. + config WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + bool "Do not use the default certificate bundle" + endchoice + + config WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + default n + bool "Add custom certificates to the default bundle" + config WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE_PATH + depends on WOLFSSL_CUSTOM_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + string "Custom certificate bundle path" + help + Name of the custom certificate directory or file. This path is evaluated + relative to the project root directory. + + config WOLFSSL_CERTIFICATE_BUNDLE_DEPRECATED_LIST + bool "Add deprecated root certificates" + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL && !WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE + help + Include the deprecated list of root certificates in the bundle. + This list gets updated when a certificate is removed from the Mozilla's + NSS root certificate store. This config can be enabled if you would like + to ensure that none of the certificates that were deployed in the product + are affected because of the update to bundle. In turn, enabling this + config keeps expired, retracted certificates in the bundle and it may + pose a security risk. + + - Deprecated cert list may grow based based on sync with upstream bundle + - Deprecated certs would be be removed in ESP-IDF (next) major release + + config WOLFSSL_CERTIFICATE_BUNDLE_MAX_CERTS + int "Maximum no of certificates allowed in certificate bundle" + default 200 + depends on WOLFSSL_CERTIFICATE_BUNDLE && ESP_TLS_USING_WOLFSSL + + endmenu + endmenu # wolfSSL ESP-TLS + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + config ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + bool "Modify default hardware acceleration settings" + default n + help + When disabling all hardware acceleration for smaller memory footprint, + disabling TFM fast math provides faster wolfSSL software algorithms in an + even smaller flash memory footprint. + Typically used for debugging, analysis, or optimizations. The default + hardware acceleration features can be each manually adjusted. + + menu "wolfSSL Hardware Acceleration" + + config ESP_WOLFSSL_NO_ESP32_CRYPT + bool "Disable all ESP32 Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + select ESP_WOLFSSL_NO_HW_AES + select ESP_WOLFSSL_NO_HW_HASH + select ESP_WOLFSSL_NO_HW_RSA_PRI + select ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + help + Hardware acceleration enabled by default. When selected defines: NO_ESP32_CRYPT. + Consider disabling FASTMATH (other libraries are faster in software and smaller) + + config ESP_WOLFSSL_NO_HW_AES + bool "Disable all ESP32 AES Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default.When selected defines: NO_HW_AES + + config ESP_WOLFSSL_NO_HW_HASH + bool "Disable all ESP32 SHA Hash Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_HASH + + config ESP_WOLFSSL_NO_HW_RSA_PRI + bool "Disable all ESP32 RSA Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + select ESP_WOLFSSL_NO_HW_PRI_MP_MUL + select ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + select ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI + + config ESP_WOLFSSL_NO_HW_RSA_PRI_MP_MUL + bool "Disable all ESP32 Multiplication Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI_MP_MUL + + config ESP_WOLFSSL_NO_HW_RSA_PRI_MULMOD + bool "Disable all ESP32 Modular Multiplication Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. When selected defines: NO_HW_RSA_PRI_MULMOD + + config ESP_WOLFSSL_NO_HW_RSA_PRI_EXPTMOD + bool "Disable all ESP32 RSA Exponential Math Hardware Acceleration" + depends on ESP_WOLFSSL_ALT_HARDWARE_ACCELERATION + default n + help + Hardware acceleration enabled by default. + Select this option to force disable: NO_HW_RSA_PRI_EXPTMOD + + config ESP_WOLFSSL_DEBUG_ESP_HW_MULTI_RSAMAX_BITS + bool "Enable debugging of RSA Multiplication operand length" + default n + help + Prints an esp log warning to the default console UART when one of the + multiplication operands exceeds the maximum size supported by hardware, + requiring fallback to software. This can be helpful to pick key sizes + when performance is critical. See also metrics for counting instances. + + config ESP_WOLFSSL_DEBUG_ESP_HW_MOD_RSAMAX_BITS + bool "Enable debugging of RSA Modular operand length" + default n + help + Prints an esp log warning to the default console UART when one of the + modular math operands exceeds the maximum size supported by hardware, + requiring fallback to software. This can be helpful to pick key sizes + when performance is critical. See also metrics for counting instances. + + endmenu # wolfSSL Hardware Acceleration + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Experimental Options" + + config ESP_WOLFSSL_EXPERIMENTAL_SETTINGS + bool "Enable wolfSSL Experimental Settings" + default n + help + Enables experimental settings for wolfSSL. See documentation. + + config ESP_WOLFSSL_ENABLE_KYBER + bool "Enable wolfSSL Kyber" + default n + help + Enable debugging messages for wolfSSL. See user_settings.h for additional debug options. + + endmenu # wolfSSL Experimental Options + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Debug Options" + config ESP_WOLFSSL_DEBUG_WOLFSSL + bool "Enable wolfSSL Debugging" + default n + help + Enable debugging messages for wolfSSL. See user_settings.h for additional debug options. + + config ESP_WOLFSSL_TEST_LOOP + bool "Run test apps in a loop until failure" + default y + help + Enable a loop wrapper for benchmark, http_client, and wolfssl test apps. + + endmenu # wolfSSL Debug Options + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "wolfSSL Customization" + config CUSTOM_SETTING_WOLFSSL_ROOT + string "Enter a path for wolfSSL source code" + default "~/workspace/wolfssl" + help + This option lets you specify a directory for the wolfSSL source code (typically a git clone). + Enter the path using forward slashes (e.g., C:/myfolder/mysubfolder) or double backslashes + (e.g., C:\\myfolder\\mysubfolder). + + endmenu # wolfSSL Customization + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "Component Config" + config IGNORE_ESP_IDF_WOLFSSL_COMPONENT + bool "Ignore the ESP-IDF component of wolfSSL (if present)" + default n + help + Ignores wolfSSL present in the esp-idf/components directory. Requires wolfssl as a local component. + + config IGNORE_LOCAL_WOLFSSL_COMPONENT + bool "Ignore the local component of wolfSSL (if present)" + default n + help + Ignores wolfSSL present in the local project components directory. + Requires wolfssl as a ESP-IDF component. + + endmenu # Component Config + # ----------------------------------------------------------------------------------------------------------------- + + # ----------------------------------------------------------------------------------------------------------------- + menu "Utility Config" + config USE_WOLFSSL_ESP_SDK_TIME + bool "Enable wolfSSL time helper functions" + default n + help + Enables use of various time and date setting functions found in the esp-sdk-lib.h file. + + config USE_WOLFSSL_ESP_SDK_WIFI + bool "Enable wolfSSL WiFi helper functions" + default n + help + Enables use of various time and date setting functions found in the esp-sdk-lib.h file. + + endmenu # Utility Config +endmenu # wolfSSL +# --------------------------------------------------------------------------------------------------------------------- + + +# --------------------------------------------------------------------------------------------------------------------- +menu "wolfSSH" + config ESP_ENABLE_WOLFSSH + bool "Enable wolfSSH options" + default n + help + Enables WOLFSSH_TERM, WOLFSSL_KEY_GEN, WOLFSSL_PTHREADS, WOLFSSH_TEST_SERVER, WOLFSSH_TEST_THREADING + + config ESP_WOLFSSL_DEBUG_WOLFSSH + bool "Enable wolfSSH debugging" + default n + help + Enable wolfSSH debugging macro. See user_settings.h + +endmenu # wolfSSH +# --------------------------------------------------------------------------------------------------------------------- + +# --------------------------------------------------------------------------------------------------------------------- +menu "wolfMQTT" + config ESP_ENABLE_WOLFMQTT + bool "Enable wolfMQTT options" + default n + help + Enables WOLFMQTT + + config ESP_WOLFSSL_DEBUG_WOLFMQTT + bool "Enable wolfMQTT debugging" + default n + help + Enable wolfMQTT debugging macro. See user_settings.h + +endmenu # wolfMQTT +# --------------------------------------------------------------------------------------------------------------------- diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/README.md b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/README.md new file mode 100644 index 000000000..d77912416 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/README.md @@ -0,0 +1,162 @@ +# wolfSSL Espressif Component + +This is the directory for wolfSSL as an Espressif ESP-IDF component. + +Other options are available, such as installing wolfSSL as a local _project_ component using the [Managed Component](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/). + +Enabling this wolfSSL ESP-IDF component allows other ESP-IDF libraries such as those that depend on [ESP-TLS](https://github.com/espressif/esp-idf/tree/master/components/esp-tls) +to also use the wolfSSL library. (See [github.com/wolfSSL/wolfssl](https://github.com/wolfSSL/wolfssl)) + +The wolfSSL source code is not included here. Instead, the `idf.py menuconfig` option can be used to configure the +`sdkconfig` file setting: `CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT` to point to the desired wolfSSL code. + +## Directory Contents + +This directory must contain, at a minimum: + +- `CMakeLists.txt` +- `./include/user_settings.h` + +The directory should also contain: +- `Kconfig` +- `component.mk` + +The directory may contain wolfSSL source, for example with a [Managed Component](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/), +or if the `setup.sh` script was used from [wolfSSL/IDE/Espressif/ESP-IDF](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF). + + +Under normal circumstances when the wolfSSL source is not included here, the `CMakeLists.txt` will search for it in this order: + +- A hard-coded `WOLFSSL_ROOT` cmake variable. +- `WOLFSSL_ROOT` Environment Variable +- The `CONFIG_CUSTOM_SETTING_WOLFSSL_ROOT` value in the `sdkconfig` file, from the `Kconfig` option. +- Any parent directories, up to the root (if this directory is in the ESP-IDF components) +- Any parent directories, up to the root (if this directory is a project component) + +While recursing up the directory tree, the following names of wolfSSL directories will be considered: + +- `wolfssl-[current user name]` +- `wolfssl-master` +- `wolfssl` + +## Getting Started + +See the `Espressif Getting Started Guide`. + +``` +# Set environment variable to ESP-IDF location +# For example, VisualGDB in WSL +WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.2 +WRK_IDF_PATH=/mnt/c/SysGCC/esp32-master/esp-idf/v5.3-master + +# Or wherever the ESP-IDF is installed: +WRK_IDF_PATH=~/esp/esp-idf + +echo "Run export.sh from ${WRK_IDF_PATH}" +. ${WRK_IDF_PATH}/export.sh + +cd [your project] + +idf.py menuconfig +``` + +Enable wolfSSL to be used in the ESP-TLS: + +``` +Component config ---> + ESP-TLS ---> + Choose SSL/TLS library for ESP-TLS (See help for more Info) + (X) wolfSSL (License info in wolfSSL directory README) +``` + +Adjust wolfSSL settings, such as path to source code as needed: + +``` +Component config ---> + wolfSSL ---> + [*] Include wolfSSL in ESP-TLS + [*] Use the specified wolfssl for ESP-TLS + (~/workspace/wolfssl) Enter a path for wolfSSL source code +``` + +## Configuration + +All settings for wolfSSL are adjusted in the [include/user_settings.h](./include/user_settings.h) file. + +The `user_settings.h` file should not be included directly. Instead, `#include ` +before any other wolfSSL headers, like this: + + +```c +/* ESP-IDF */ +#include +#include "sdkconfig.h" + +/* wolfSSL */ +/* Always include wolfcrypt/settings.h before any other wolfSSL file. */ +/* Reminder: settings.h pulls in user_settings.h; don't include it here. */ +#if defined(WOLFSSL_USER_SETTINGS) + #include + #if defined(WOLFSSL_ESPIDF) + #include + #include + #include + #include + #include + #else + #error "Problem with wolfSSL user_settings. " \ + "Check components/wolfssl/include " \ + "and confirm WOLFSSL_USER_SETTINGS is defined, " \ + "typically in the component CMakeLists.txt" + #endif +#else + /* Define WOLFSSL_USER_SETTINGS project wide for settings.h to include */ + /* wolfSSL user settings in ./components/wolfssl/include/user_settings.h */ + #error "Missing WOLFSSL_USER_SETTINGS in CMakeLists or Makefile:\ + CFLAGS +=-DWOLFSSL_USER_SETTINGS" +#endif +``` + +## Examples + +See the wolfSSL examples: + +- [wolfSSL Core Examples](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples) +- [wolfSSL Additional Examples](https://github.com/wolfSSL/wolfssl-examples/tree/master/ESP32) +- [wolfSSH Core Examples](https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples) +- [wolfSSH Additional Examples](https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif) +- [wolfMQTT Examples](https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples) + +## Platforms + +The ESP-IDF wolfSSL is also available for PlatformIO: + +- [Release wolfSSL](https://registry.platformio.org/search?q=owner%3Awolfssl) +- [Staging / Preview wolfSSL](https://registry.platformio.org/search?q=owner%3Awolfssl-staging) + +The wolfSSL library can also be used for Espressif with Arduino: + +- [arduino.cc/reference/en/libraries/wolfssl](https://www.arduino.cc/reference/en/libraries/wolfssl/) +- [github.com/wolfSSL/Arduino-wolfSSL](https://github.com/wolfSSL/Arduino-wolfSSL) + + +## Additional Information + +- [wolfSSL Documentation](https://www.wolfssl.com/documentation/manuals/wolfssl/index.html) and [docs/espressif](https://www.wolfssl.com/docs/espressif/) +- [wolfSSL FAQ](https://www.wolfssl.com/docs/frequently-asked-questions-faq/) +- [wolfSSL Products](https://www.wolfssl.com/products/) +- [www.wolfssl.com/espressif](https://www.wolfssl.com/espressif/) +- [More...](https://www.wolfssl.com/?s=espressif) + +## Contact + +Have a specific request or questions? We'd love to hear from you! Please contact us at support@wolfssl.com or open an issue on GitHub. + +## Licensing and Support + +wolfSSL (formerly known as CyaSSL) and wolfCrypt are either licensed for use under the GPLv2 (or at your option any later version) or a standard commercial license. For our users who cannot use wolfSSL under GPLv2 (or any later version), a commercial license to wolfSSL and wolfCrypt is available. + +See the LICENSE.txt, visit wolfssl.com/license, contact us at licensing@wolfssl.com or call +1 425 245 8247 + +View Commercial Support Options: [wolfssl.com/products/support-and-maintenance](wolfssl.com/products/support-and-maintenance) + diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/component.mk index 2540584c8..aacd62566 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/component.mk @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # @@ -18,6 +18,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA # +$(info *********** wolfssl component ************) + # # Component Makefile # @@ -48,193 +50,257 @@ # define it here: CFLAGS +=-DWOLFSSL_USER_SETTINGS -# In the wolfSSL GitHub examples for Espressif, -# the root is 7 directories up from here: -WOLFSSL_ROOT := ../../../../../../../ +# Note that 4 source files created by autogen are excluded here. +# +# See these files commented out, below. Adjust as needed for your application: +# +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/async.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/selftest.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_first.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_last.o + + +# NOTICE: the WOLFSSL_ROOT setting MUST be relative! +# See https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/api-guides/build-system.html?highlight=must+relative#optional-component-specific-variables +# In the wolfSSL GitHub examples for Espressif: +# https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples +# When this wolfssl component.mk makefile is in [project]/components/wolfssl +# The root is 7 directories up from here (the location of of this component.mk): +# +WOLFSSL_ROOT ?= ../../../../../../.. +THIS_DIR := $(shell pwd) +WOLFSSL_ROOT_OBJ := $(THIS_DIR) + +# When running make from commandline or VisualGDB, the current path varies: +ifeq ("$(VISUALGDB_DIR)","") + # current path is typically /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/wolfssl + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL)) +else + # current path is typically /C/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/Debug/wolfssl + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL)) +endif + +# To set the location of a different location, it is best to use relative paths. +# +# Set WOLFSSL_ROOT to a relative path from the current component directory. +# For example, if the wolfssl_client is copied from the examples to test: +# +# cp -r /IDE/Espressif/ESP-IDF/examples/wolfssl_client/* /mnt/c/test/demo +# +# we run make in /mnt/c/test/demo +# component is in /mnt/c/test/demo/components/wolfssl +# wolfssl is in /mnt/c/workspace/wolfssl-master +# +# "/mnt/c" is 4 directories up: +# 2 for `./test/demo` from where we run `make`, plus +# 2 more from the location of `component.mk` located +# in `[current directory]/components/wolfssl`. +# +# Thus we need 4 parent reference to find the relative path to wolfSSL: +# WOLFSSL_ROOT := ../../../../workspace/wolfssl-master + +# Optional CFLAGS (make works without these; for reference only) +# CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl +# CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt +# CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif + +abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) + +# print-wolfssl-path-value: +# @echo "WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)" +# @echo "WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)" + +$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info THIS_DIR defined: $(THIS_DIR)) +$(info WOLFSSL_ROOT_OBJ defined: $(WOLFSSL_ROOT_OBJ)) # NOTE: The wolfSSL include directory (e.g. user_settings.h) is # located HERE in THIS project, and *not* in the wolfSSL root. COMPONENT_ADD_INCLUDEDIRS := . COMPONENT_ADD_INCLUDEDIRS += include -COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT). -COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfssl -COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfssl/wolfcrypt -COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfssl/wolfcrypt/port/Espressif -COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfcrypt/benchmark +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/. +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif + # COMPONENT_ADD_INCLUDEDIRS += $ENV(IDF_PATH)/components/freertos/include/freertos # COMPONENT_ADD_INCLUDEDIRS += "$ENV(IDF_PATH)/soc/esp32s3/include/soc" +# wolfSSL +COMPONENT_SRCDIRS := $(WOLFSSL_ROOT)/src -# WOLFSSL_ROOT := "" -COMPONENT_SRCDIRS := $(WOLFSSL_ROOT)src -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/src/port/atmel -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/benchmark -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/test -COMPONENT_SRCDIRS += include +# wolfcrypt +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src -COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT)wolfcrypt/src/aes_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/evp.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/misc.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/sha512_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/fe_x25519_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/aes_gcm_x86_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)src/bio.o +# Espressif +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/atmel +COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/evp.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/misc.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/sha512_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/fe_x25519_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_gcm_x86_asm.o ## ## wolfSSL ## -COMPONENT_OBJS := $(WOLFSSL_ROOT)src/bio.o -# COMPONENT_OBJS += src/conf.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/crl.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/dtls.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/dtls13.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/internal.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/keys.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/ocsp.o -# COMPONENT_OBJS += src/pk.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/quic.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/sniffer.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/ssl.o +## reminder object files may end up in `./build` or `build/debug` or `build/release`, depending on build environment & settings. +## +# COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o # part of ssl.c, omitted to avoid "does not need to be compiled separately" +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/conf.o # part of ssl.c +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/crl.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls13.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/internal.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/keys.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ocsp.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/pk.o # part of ssl.c +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/quic.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/sniffer.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o # COMPONENT_OBJS += src/ssl_asn1.o # COMPONENT_OBJS += src/ssl_bn.o # COMPONENT_OBJS += src/ssl_certman.o # COMPONENT_OBJS += src/ssl_crypto.o # COMPONENT_OBJS += src/ssl_misc.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/tls.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/tls13.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)src/wolfio.o -# COMPONENT_OBJS += src/x509.o -# COMPONENT_OBJS += src/x509_str.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls13.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/wolfio.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509.o # part of ssl.c +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509_str.o # part of ssl.c ## ## wolfcrypt ## -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/aes.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/arc4.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/asm.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/asn.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/async.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/blake2b.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/blake2s.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/camellia.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/chacha.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/chacha20_poly1305.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/cmac.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/coding.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/compress.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/cpuid.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/cryptocb.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/curve25519.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/curve448.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/des3.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/dh.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/dilithium.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/dsa.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ecc.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/eccsi.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ecc_fp.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ed25519.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ed448.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/error.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/evp.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ext_kyber.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ext_lms.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ext_xmss.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/falcon.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fe_448.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fe_low_mem.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fe_operations.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fips.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fips_test.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ge_448.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ge_low_mem.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ge_operations.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/hash.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/hmac.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/hpke.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/integer.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/kdf.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/logging.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/md2.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/md4.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/md5.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/memory.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/misc.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/pkcs12.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/pkcs7.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/poly1305.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/pwdbased.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/random.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/rc2.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ripemd.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/rsa.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sakke.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/selftest.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha256.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha3.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha512.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/signature.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/siphash.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sm2.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sm3.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sm4.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sphincs.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_arm32.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_arm64.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_armthumb.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_c32.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_c64.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_cortexm.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_dsp32.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_int.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_arm32.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_arm64.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_armthumb.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_c32.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_c64.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_cortexm.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_x86_64.o -# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_x86_64.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/srp.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/tfm.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_dsp.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_encrypt.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_kyber.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_kyber_poly.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_lms.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_pkcs11.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_port.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_xmss.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfcrypt_first.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfcrypt_last.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfevent.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfmath.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/aes.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/arc4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/asm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/asn.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/async.o # autogen exclusion +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/blake2b.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/blake2s.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/camellia.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/chacha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/chacha20_poly1305.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/cmac.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/coding.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/compress.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/cpuid.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/cryptocb.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/curve25519.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/curve448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/des3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/dh.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/dilithium.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/dsa.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ecc.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/eccsi.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ecc_fp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ed25519.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ed448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/error.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/evp.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_mlkem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_lms.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ext_xmss.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/falcon.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_low_mem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_operations.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fips.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/fips_test.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ge_448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ge_low_mem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ge_operations.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/hash.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/hmac.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/hpke.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/integer.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/kdf.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/logging.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/md2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/md4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/md5.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/memory.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/misc.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/pkcs12.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/pkcs7.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/poly1305.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/pwdbased.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/random.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/rc2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/ripemd.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/rsa.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sakke.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/selftest.o # autogen exclusion +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha256.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sha512.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/signature.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/siphash.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sm2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sm3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sm4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sphincs.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_arm32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_arm64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_armthumb.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_c32.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_c64.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_cortexm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_dsp32.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_int.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_arm32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_arm64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_armthumb.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_c32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_c64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_cortexm.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_sm2_x86_64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/sp_x86_64.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/srp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/tfm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_dsp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_encrypt.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_mlkem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_mlkem_poly.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_lms.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_pkcs11.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_port.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wc_xmss.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_first.o # autogen exclusion +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfcrypt_last.o # autogen exclusion +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfevent.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/wolfmath.o ## ## Espressif ## -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_aes.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_mp.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_sha.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_util.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp_sdk_mem_lib.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp_sdk_time_lib.o -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp_sdk_wifi_lib.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp32_aes.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp32_mp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp32_sha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp32_util.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_mem_lib.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_time_lib.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_wifi_lib.o ## ## wolfcrypt benchmark (optional) ## -## COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/benchmark/benchmark.o +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark +## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark + ## -## wolfcrypt test (optional) +## wolfcrypt test (needed for this test example) ## -COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/test/test.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test/include -## -## wolfcrypt -## -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/src +$(info ********** end wolfssl component **********) 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 9cf87e8fd..89498ae70 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 @@ -1,6 +1,6 @@ -/* user_settings.h +/* wolfssl-component include/user_settings.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -18,19 +18,57 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ +#define WOLFSSL_ESPIDF_COMPONENT_VERSION 0x01 + +/* Examples such as test and benchmark are known to cause watchdog timeouts. + * Note this is often set in project Makefile: + * CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 */ +#define WOLFSSL_ESP_NO_WATCHDOG 1 + +/* The Espressif project config file. See also sdkconfig.defaults */ +#include "sdkconfig.h" /* This user_settings.h is for Espressif ESP-IDF * * Standardized wolfSSL Espressif ESP32 + ESP8266 user_settings.h V5.7.0-1 * - * Do not include any wolfssl headers here + * Do not include any wolfssl headers here. * * When editing this file: - * ensure wolfssl_test and wolfssl_benchmark settings match. + * ensure all examples match. The template example is the reference. */ -/* The Espressif project config file. See also sdkconfig.defaults */ -#include "sdkconfig.h" +/* Naming convention: (see also esp32-crypt.h for the reference source). + * + * CONFIG_ + * This prefix indicates the setting came from the sdkconfig / Kconfig. + * + * May or may not be related to wolfSSL. + * + * The name after this prefix must exactly match that in the Kconfig file. + * + * WOLFSSL_ + * Typical of many, but not all wolfSSL macro names. + * + * Applies to all wolfSSL products such as wolfSSH, wolfMQTT, etc. + * + * May or may not have a corresponding sdkconfig / Kconfig control. + * + * ESP_WOLFSSL_ + * These are NOT valid wolfSSL macro names. These are names only used in + * the ESP-IDF Kconfig files. When parsed, they will have a "CONFIG_" + * suffix added. See next section. + * + * CONFIG_ESP_WOLFSSL_ + * This is a wolfSSL-specific macro that has been defined in the ESP-IDF + * via the sdkconfig / menuconfig. Any text after this prefix should + * exactly match an existing wolfSSL macro name. + * + * Applies to all wolfSSL products such as wolfSSH, wolfMQTT, etc. + * + * These macros may also be specific to only the project or environment, + * and possibly not used anywhere else in the wolfSSL libraries. + */ /* The Espressif sdkconfig will have chipset info. ** @@ -46,33 +84,264 @@ #undef WOLFSSL_ESPIDF #define WOLFSSL_ESPIDF -/* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ -#define NO_ESP_SDK_WIFI +/* Test various user_settings between applications by selecting example apps + * in `idf.py menuconfig` for Example wolfSSL Configuration settings: */ + +/* Turn on messages that are useful to see only in examples. */ +#define WOLFSSL_EXAMPLE_VERBOSITY + +/* Paths can be long, ensure the entire value printed during debug */ +#define WOLFSSL_MAX_ERROR_SZ 500 + +/* wolfSSL Examples: set macros used in example applications. + * + * These Settings NOT available in ESP-IDF (e.g. esp-tls) + * + * Any settings needed by ESP-IDF components should be explicitly set, + * and not by these example-specific settings via CONFIG_WOLFSSL_EXAMPLE_n + * + * ESP-IDF settings should be Kconfig "CONFIG_[name]" values when possible. */ +#if defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TEMPLATE) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/template */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TEST) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_test */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ + #define TEST_ESPIDF_ALL_WOLFSSL +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_BENCHMARK) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark */ + /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */ + /* #define USE_WOLFSSL_ESP_SDK_WIFI */ + #define WOLFSSL_BENCHMARK_FIXED_UNITS_KB +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_CLIENT) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_client */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_SERVER) + /* See https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/wolfssl_server */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfSSH Examples */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSH_TEMPLATE) + /* See https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples/wolfssh_template */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSH_ECHOSERVER) + /* See https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_ESP32_SSH_SERVER) + /* See https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif/ESP32/ESP32-SSH-Server */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_ESP8266_SSH_SERVER) + /* See https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif/ESP8266/ESP8266-SSH-Server */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfMQTT Examples */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFMQTT_TEMPLATE) + /* See https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples/wolfmqtt_template */ + #define USE_WOLFSSL_ESP_SDK_WIFI +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFMQTT_AWS_IOT_MQTT) + /* See https://github.com/wolfSSL/wolfMQTT/tree/master/IDE/Espressif/ESP-IDF/examples/AWS_IoT_MQTT */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* wolfTPM Examples */ +#elif defined(CONFIG_WOLFTPM_EXAMPLE_NAME_ESPRESSIF) + /* See https://github.com/wolfSSL/wolfTPM/tree/master/IDE/Espressif */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* Apple HomeKit Examples */ +#elif defined(CONFIG_WOLFSSL_APPLE_HOMEKIT) + /* See https://github.com/AchimPieters/esp32-homekit-demo */ + +/* no example selected */ +#elif defined(CONFIG_WOLFSSL_EXAMPLE_NAME_NONE) + /* We'll assume the app needs to use wolfSSL sdk lib function */ + #define USE_WOLFSSL_ESP_SDK_WIFI + +/* Other applications detected by cmake */ +#elif defined(APP_ESP_HTTP_CLIENT_EXAMPLE) + /* The wolfSSL Version of the client example */ + #if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C2) + /* Less memory available, so smaller key sizes: */ + #define FP_MAX_BITS (4096 * 2) + #else + #define FP_MAX_BITS (8192 * 2) + #endif + #define HAVE_ALPN + #define HAVE_SNI + #define OPENSSL_EXTRA_X509_SMALL + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES + #define OPENSSL_EXTRA + #ifndef WOLFSSL_ALWAYS_VERIFY_CB + #define WOLFSSL_ALWAYS_VERIFY_CB + #endif + #ifndef WOLFSSL_VERIFY_CB_ALL_CERTS + #define WOLFSSL_VERIFY_CB_ALL_CERTS + #endif + #ifndef KEEP_PEER_CERT + #define KEEP_PEER_CERT + #endif + +#elif defined(APP_ESP_HTTP_CLIENT) + /* The ESP-IDF Version */ + #define FP_MAX_BITS (8192 * 2) + #define HAVE_ALPN + #define HAVE_SNI + #define OPENSSL_EXTRA_X509_SMALL + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES + #define OPENSSL_EXTRA + #ifndef WOLFSSL_ALWAYS_VERIFY_CB + #define WOLFSSL_ALWAYS_VERIFY_CB + #endif + #ifndef WOLFSSL_VERIFY_CB_ALL_CERTS + #define WOLFSSL_VERIFY_CB_ALL_CERTS + #endif + #ifndef KEEP_PEER_CERT + #define KEEP_PEER_CERT + #endif +#else + #ifdef WOLFSSL_ESPIDF + /* #warning "App config undetected" */ + #endif + /* the code is older or does not have application name defined. */ +#endif /* Example wolfSSL Configuration app settings */ /* Experimental Kyber */ -#if 0 +#ifdef CONFIG_WOLFSSL_ENABLE_KYBER /* Kyber typically needs a minimum 10K stack */ #define WOLFSSL_EXPERIMENTAL_SETTINGS - #define WOLFSSL_HAVE_KYBER - #define WOLFSSL_WC_KYBER + #define WOLFSSL_HAVE_MLKEM + #define WOLFSSL_WC_MLKEM #define WOLFSSL_SHA3 + #if defined(CONFIG_IDF_TARGET_ESP8266) + /* With limited RAM, we'll disable some of the Kyber sizes: */ + #define WOLFSSL_NO_KYBER1024 + #define WOLFSSL_NO_KYBER768 + #define NO_SESSION_CACHE + #endif #endif +/* Enable AES for all examples */ +#ifdef NO_AES + #warning "Found NO_AES, wolfSSL AES Cannot be enabled. Check config." +#else + #define WOLFSSL_AES + #define WOLFSSL_AES_COUNTER + + /* Typically only needed for wolfssl_test, see docs. */ + #define WOLFSSL_AES_DIRECT +#endif + +/* Pick a cert buffer size: */ +/* #define USE_CERT_BUFFERS_2048 */ +/* #define USE_CERT_BUFFERS_1024 */ +#define USE_CERT_BUFFERS_2048 + +/* The Espressif sdkconfig will have chipset info. +** +** Some possible values: +** +** CONFIG_IDF_TARGET_ESP32 +** CONFIG_IDF_TARGET_ESP32S2 +** CONFIG_IDF_TARGET_ESP32S3 +** CONFIG_IDF_TARGET_ESP32C3 +** CONFIG_IDF_TARGET_ESP32C6 +*/ + +/* Optionally enable Apple HomeKit from compiler directive or Kconfig setting */ +#if defined(WOLFSSL_APPLE_HOMEKIT) || defined(CONFIG_WOLFSSL_APPLE_HOMEKIT) + /* SRP is known to need 8K; slow on some devices */ + #define FP_MAX_BITS (8192 * 2) + #define WOLFCRYPT_HAVE_SRP + #define HAVE_CHACHA + #define HAVE_POLY1305 + #define WOLFSSL_BASE64_ENCODE + #endif /* Apple HomeKit settings */ + +/* Used by ESP-IDF components: */ +#if defined(CONFIG_ESP_TLS_USING_WOLFSSL) + /* The ESP-TLS */ + #ifndef FP_MAX_BITS + #if defined(CONFIG_IDF_TARGET_ESP32C2) || \ + defined(CONFIG_IDF_TARGET_ESP8684) || \ + defined(CONFIG_IDF_TARGET_ESP8266) + /* Optionally set smaller size here */ + #define FP_MAX_BITS MIN_FFDHE_FP_MAX_BITS + #else + #define FP_MAX_BITS (4096 * 2) + #endif + #endif + #define HAVE_ALPN + #ifndef CONFIG_IDF_TARGET_ESP8266 + /* Unless installed in the ESP8266 RTOS SDK locally, the wolfSSL + * API for SNI will not be seen in the components/esp-tls layer. + * Only enable SNI for non-ESP8266 targets by default: */ + #define HAVE_SNI + #endif + #define OPENSSL_EXTRA_X509_SMALL + + #define HAVE_TLS_EXTENSIONS + #define HAVE_SUPPORTED_CURVES +#endif + +/* Optionally enable some wolfSSH settings */ +#if defined(ESP_ENABLE_WOLFSSH) || defined(CONFIG_ESP_ENABLE_WOLFSSH) + /* Enable wolfSSH. Espressif examples need a few more settings, below */ + #undef WOLFSSL_WOLFSSH + #define WOLFSSL_WOLFSSH + + /* The default SSH Windows size is massive for an embedded target. + * Limit it: */ + #define DEFAULT_WINDOW_SZ 2000 + + /* These may be defined in cmake for other examples: */ + #undef WOLFSSH_TERM + #define WOLFSSH_TERM + + /* optional debug */ + /* #undef DEBUG_WOLFSSH */ + /* #define DEBUG_WOLFSSH */ + + #undef WOLFSSL_KEY_GEN + #define WOLFSSL_KEY_GEN + + #undef WOLFSSL_PTHREADS + #define WOLFSSL_PTHREADS + + #define WOLFSSH_TEST_SERVER + #define WOLFSSH_TEST_THREADING +#endif /* ESP_ENABLE_WOLFSSH */ + + +/* Not yet using WiFi lib, so don't compile in the esp-sdk-lib WiFi helpers: */ +/* #define USE_WOLFSSL_ESP_SDK_WIFI */ + /* * ONE of these Espressif chip families will be detected from sdkconfig: * * WOLFSSL_ESP32 + * WOLFSSL_ESPWROOM32SE * WOLFSSL_ESP8266 + * + * following ifdef detection only for syntax highlighting: */ -#undef WOLFSSL_ESPWROOM32SE -#undef WOLFSSL_ESP8266 -#undef WOLFSSL_ESP32 +#ifdef WOLFSSL_ESPWROOM32SE + #undef WOLFSSL_ESPWROOM32SE +#endif +#ifdef WOLFSSL_ESP8266 + #undef WOLFSSL_ESP8266 +#endif +#ifdef WOLFSSL_ESP32 + #undef WOLFSSL_ESP32 +#endif /* See below for chipset detection from sdkconfig.h */ /* when you want to use SINGLE THREAD. Note Default ESP-IDF is FreeRTOS */ -/* #define SINGLE_THREADED */ +#define SINGLE_THREADED -/* SMALL_SESSION_CACHE saves a lot of RAM for ClientCache and SessionCache. +/* Small session cache saves a lot of RAM for ClientCache and SessionCache. * Memory requirement is about 5KB, otherwise 20K is needed when not specified. * If extra small footprint is needed, try MICRO_SESSION_CACHE (< 1K) * When really desperate or no TLS used, try NO_SESSION_CACHE. */ @@ -92,130 +361,6 @@ /* RSA_LOW_MEM: Half as much memory but twice as slow. */ #define RSA_LOW_MEM -/* Uncommon settings for testing only */ -#define TEST_ESPIDF_ALL_WOLFSSL -#ifdef TEST_ESPIDF_ALL_WOLFSSL - #define WOLFSSL_MD2 - #define HAVE_BLAKE2 - #define HAVE_BLAKE2B - #define HAVE_BLAKE2S - - #define WC_RC2 - #define WOLFSSL_ALLOW_RC4 - - #define HAVE_POLY1305 - - #define WOLFSSL_AES_128 - #define WOLFSSL_AES_OFB - #define WOLFSSL_AES_CFB - #define WOLFSSL_AES_XTS - - /* #define WC_SRTP_KDF */ - /* TODO Causes failure with Espressif AES HW Enabled */ - /* #define HAVE_AES_ECB */ - /* #define HAVE_AESCCM */ - /* TODO sanity check when missing HAVE_AES_ECB */ - #define WOLFSSL_WOLFSSH - - #define HAVE_AESGCM - #define WOLFSSL_AES_COUNTER - - #define HAVE_FFDHE - #define HAVE_FFDHE_2048 - #if defined(CONFIG_IDF_TARGET_ESP8266) - /* TODO Full size SRP is disabled on the ESP8266 at this time. - * Low memory issue? */ - #define WOLFCRYPT_HAVE_SRP - /* MIN_FFDHE_FP_MAX_BITS = (MIN_FFDHE_BITS * 2); see settings.h */ - #define FP_MAX_BITS MIN_FFDHE_FP_MAX_BITS - #elif defined(CONFIG_IDF_TARGET_ESP32) || \ - defined(CONFIG_IDF_TARGET_ESP32S2) || \ - defined(CONFIG_IDF_TARGET_ESP32S3) - #define WOLFCRYPT_HAVE_SRP - #define FP_MAX_BITS (8192 * 2) - #elif defined(CONFIG_IDF_TARGET_ESP32C3) || \ - defined(CONFIG_IDF_TARGET_ESP32H2) - /* SRP Known to be working on this target::*/ - #define WOLFCRYPT_HAVE_SRP - #define FP_MAX_BITS (8192 * 2) - #else - /* For everything else, give a try and see if SRP working: */ - #define WOLFCRYPT_HAVE_SRP - #define FP_MAX_BITS (8192 * 2) - #endif - - #define HAVE_DH - - /* TODO: there may be a problem with HAVE_CAMELLIA with HW AES disabled. - * Do not define NO_WOLFSSL_ESP32_CRYPT_AES when enabled: */ - /* #define HAVE_CAMELLIA */ - - /* DSA requires old SHA */ - #define HAVE_DSA - - /* Needs SHA512 ? */ - #define HAVE_HPKE - - /* Not for Espressif? */ - #if defined(CONFIG_IDF_TARGET_ESP32C2) || \ - defined(CONFIG_IDF_TARGET_ESP8684) || \ - defined(CONFIG_IDF_TARGET_ESP32H2) || \ - defined(CONFIG_IDF_TARGET_ESP8266) - - #if defined(CONFIG_IDF_TARGET_ESP8266) - #undef HAVE_ECC - #undef HAVE_ECC_CDH - #undef HAVE_CURVE25519 - - /* TODO does CHACHA also need alignment? Failing on ESP8266 - * See SHA256 __attribute__((aligned(4))); and WC_SHA256_ALIGN */ - #ifdef HAVE_CHACHA - #error "HAVE_CHACHA not supported on ESP8266" - #endif - #ifdef HAVE_XCHACHA - #error "HAVE_XCHACHA not supported on ESP8266" - #endif - #else - #define HAVE_XCHACHA - #define HAVE_CHACHA - /* TODO Not enabled at this time, needs further testing: - * #define WC_SRTP_KDF - * #define HAVE_COMP_KEY - * #define WOLFSSL_HAVE_XMSS - */ - #endif - /* TODO AES-EAX not working on this platform */ - - /* Optionally disable DH - * #undef HAVE_DH - * #undef HAVE_FFDHE - */ - - /* ECC_SHAMIR out of memory on ESP32-C2 during ECC */ - #ifndef HAVE_ECC - #define ECC_SHAMIR - #endif - #else - #define WOLFSSL_AES_EAX - - #define ECC_SHAMIR - #endif - - /* Only for WOLFSSL_IMX6_CAAM / WOLFSSL_QNX_CAAM ? */ - /* #define WOLFSSL_CAAM */ - /* #define WOLFSSL_CAAM_BLOB */ - - #define WOLFSSL_AES_SIV - #define WOLFSSL_CMAC - - #define WOLFSSL_CERT_PIV - - /* HAVE_SCRYPT may turn on HAVE_PBKDF2 see settings.h */ - /* #define HAVE_SCRYPT */ - #define SCRYPT_TEST_ALL - #define HAVE_X963_KDF -#endif - /* optionally turn off SHA512/224 SHA512/256 */ /* #define WOLFSSL_NOSHA512_224 */ /* #define WOLFSSL_NOSHA512_256 */ @@ -230,14 +375,43 @@ #define BENCH_EMBEDDED /* TLS 1.3 */ -#define WOLFSSL_TLS13 -#define HAVE_TLS_EXTENSIONS -#define WC_RSA_PSS -#define HAVE_HKDF -#define HAVE_AEAD -#define HAVE_SUPPORTED_CURVES +#ifdef CONFIG_WOLFSSL_ALLOW_TLS13 + #define WOLFSSL_TLS13 + #define HAVE_TLS_EXTENSIONS + #define HAVE_HKDF -#define WOLFSSL_BENCHMARK_FIXED_UNITS_KB + /* May be required */ + #ifndef HAVE_AEAD + #endif + + /* Required for ECC */ + #define HAVE_SUPPORTED_CURVES + + /* Required for RSA */ + #define WC_RSA_PSS + + /* TLS 1.3 normally requires HAVE_FFDHE */ + #if defined(HAVE_FFDHE_2048) || \ + defined(HAVE_FFDHE_3072) || \ + defined(HAVE_FFDHE_4096) || \ + defined(HAVE_FFDHE_6144) || \ + defined(HAVE_FFDHE_8192) + #else + #define HAVE_FFDHE_2048 + /* #error "TLS 1.3 requires HAVE_FFDHE_[nnnn]" */ + #endif +#endif + +#if defined(CONFIG_IDF_TARGET_ESP32C2) || \ + defined(CONFIG_IDF_TARGET_ESP8684) + /* Optionally set smaller size here */ + #ifdef HAVE_FFDHE_4096 + /* this size may be problematic on the C2 */ + #endif + #define HAVE_FFDHE_2048 +#else + #define HAVE_FFDHE_4096 +#endif #define NO_FILESYSTEM @@ -254,32 +428,67 @@ /* when you want to use SHA384 */ #define WOLFSSL_SHA384 -/* when you want to use SHA512 */ -#define WOLFSSL_SHA512 - -/* when you want to use SHA3 */ -#define WOLFSSL_SHA3 - - /* ED25519 requires SHA512 */ -#define HAVE_ED25519 - /* Some features not enabled for ESP8266: */ #if defined(CONFIG_IDF_TARGET_ESP8266) || \ defined(CONFIG_IDF_TARGET_ESP32C2) + /* Some known low-memory devices have features not enabled by default. */ /* TODO determine low memory configuration for ECC. */ #else - #define HAVE_ECC - #define HAVE_CURVE25519 - #define CURVE25519_SMALL + /* when you want to use SHA512 */ + #define WOLFSSL_SHA512 + + /* when you want to use SHA3 */ + /* #define WOLFSSL_SHA3 */ + + /* ED25519 requires SHA512 */ + #define HAVE_ED25519 #endif -#define HAVE_ED25519 +#if defined(CONFIG_IDF_TARGET_ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C2) + #define MY_USE_ECC 0 + #define MY_USE_RSA 1 +#else + #define MY_USE_ECC 1 + #define MY_USE_RSA 0 +#endif -/* Optional OPENSSL compatibility */ -#define OPENSSL_EXTRA +/* We can use either or both ECC and RSA, but must use at least one. */ +#if MY_USE_ECC || MY_USE_RSA + #if MY_USE_ECC + /* ---- ECDSA / ECC ---- */ + #define HAVE_ECC + #define HAVE_CURVE25519 + #define HAVE_ED25519 + #define WOLFSSL_SHA512 + /* + #define HAVE_ECC384 + #define CURVE25519_SMALL + */ + #else + #define WOLFSSH_NO_ECC + /* WOLFSSH_NO_ECDSA is typically defined automatically, + * here for clarity: */ + #define WOLFSSH_NO_ECDSA + #endif + + #if MY_USE_RSA + /* ---- RSA ----- */ + /* #define RSA_LOW_MEM */ + + /* DH disabled by default, needed if ECDSA/ECC also turned off */ + #define HAVE_DH + #else + #define WOLFSSH_NO_RSA + #endif +#else + #error "Either RSA or ECC must be enabled" +#endif + +/* Optional OpenSSL compatibility */ +/* #define OPENSSL_EXTRA */ /* #Optional HAVE_PKCS7 */ -#define HAVE_PKCS7 +/* #define HAVE_PKCS7 */ #if defined(HAVE_PKCS7) /* HAVE_PKCS7 may enable HAVE_PBKDF2 see settings.h */ @@ -319,8 +528,11 @@ /* #define XTIME time */ -/* adjust wait-timeout count if you see timeout in RSA HW acceleration */ -#define ESP_RSA_TIMEOUT_CNT 0x349F00 +/* Adjust wait-timeout count if you see timeout in RSA HW acceleration. + * Set to very large number and enable WOLFSSL_HW_METRICS to determine max. */ +#ifndef ESP_RSA_TIMEOUT_CNT + #define ESP_RSA_TIMEOUT_CNT 0xFF0000 +#endif /* hash limit for test.c */ #define HASH_SIZE_LIMIT @@ -329,7 +541,7 @@ #define USE_FAST_MATH /***** Use SP_MATH *****/ -/* #undef USE_FAST_MATH */ +/* #undef USE_FAST_MATH */ /* #define SP_MATH */ /* #define WOLFSSL_SP_MATH_ALL */ /* #define WOLFSSL_SP_RISCV32 */ @@ -338,25 +550,44 @@ /* #undef USE_FAST_MATH */ /* #define USE_INTEGER_HEAP_MATH */ - -#define WOLFSSL_SMALL_STACK - +/* Just syntax highlighting to check math libraries: */ +#if defined(SP_MATH) || \ + defined(USE_INTEGER_HEAP_MATH) || \ + defined(USE_INTEGER_HEAP_MATH) || \ + defined(USE_FAST_MATH) || \ + defined(WOLFSSL_SP_MATH_ALL) || \ + defined(WOLFSSL_SP_RISCV32) +#endif #define HAVE_VERSION_EXTENDED_INFO /* #define HAVE_WC_INTROSPECTION */ -#define HAVE_SESSION_TICKET +#ifndef NO_SESSION_CACHE + #define HAVE_SESSION_TICKET +#endif /* #define HAVE_HASHDRBG */ +#if 0 +/* Example for additional cert functions */ #define WOLFSSL_KEY_GEN -#define WOLFSSL_CERT_REQ -#define WOLFSSL_CERT_GEN -#define WOLFSSL_CERT_EXT -#define WOLFSSL_SYS_CA_CERTS + #define WOLFSSL_CERT_REQ + #define WOLFSSL_CERT_GEN + #define WOLFSSL_CERT_EXT + #define WOLFSSL_SYS_CA_CERTS -#define WOLFSSL_CERT_TEXT + #define WOLFSSL_CERT_TEXT + + /* command-line options + --enable-keygen + --enable-certgen + --enable-certreq + --enable-certext + --enable-asn-template + */ + +#endif #define WOLFSSL_ASN_TEMPLATE @@ -376,10 +607,62 @@ --enable-asn-template */ +/* optional SM4 Ciphers. See https://github.com/wolfSSL/wolfsm */ +/* +#define WOLFSSL_SM2 +#define WOLFSSL_SM3 +#define WOLFSSL_SM4 +*/ + +#if defined(WOLFSSL_SM2) || defined(WOLFSSL_SM3) || defined(WOLFSSL_SM4) + /* SM settings, possible cipher suites: + + TLS13-AES128-GCM-SHA256 + TLS13-CHACHA20-POLY1305-SHA256 + TLS13-SM4-GCM-SM3 + TLS13-SM4-CCM-SM3 + + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-CCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CBC-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-GCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3:" \ + "TLS13-SM4-CCM-SM3:" + */ + + #undef WOLFSSL_BASE16 + #define WOLFSSL_BASE16 /* required for WOLFSSL_SM2 */ + + #undef WOLFSSL_SM4_ECB + #define WOLFSSL_SM4_ECB + + #undef WOLFSSL_SM4_CBC + #define WOLFSSL_SM4_CBC + + #undef WOLFSSL_SM4_CTR + #define WOLFSSL_SM4_CTR + + #undef WOLFSSL_SM4_GCM + #define WOLFSSL_SM4_GCM + + #undef WOLFSSL_SM4_CCM + #define WOLFSSL_SM4_CCM + + #define HAVE_POLY1305 + #define HAVE_CHACHA + + #undef HAVE_AESGCM + #define HAVE_AESGCM +#else + /* default settings */ + #define USE_CERT_BUFFERS_2048 +#endif + /* Chipset detection from sdkconfig.h * Default is HW enabled unless turned off. * Uncomment lines to force SW instead of HW acceleration */ -#if defined(CONFIG_IDF_TARGET_ESP32) +#if defined(CONFIG_IDF_TARGET_ESP32) || defined(WOLFSSL_ESPWROOM32SE) #define WOLFSSL_ESP32 /* Alternatively, if there's an ECC Secure Element present: */ /* #define WOLFSSL_ESPWROOM32SE */ @@ -497,16 +780,29 @@ #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI /***** END CONFIG_IDF_TARGET_ESP32H2 *****/ -#elif defined(CONFIG_IDF_TARGET_ESP8266) - #define WOLFSSL_ESP8266 - - /* There's no hardware encryption on the ESP8266 */ - /* Consider using the ESP32-C2/C3/C6 - * See https://www.espressif.com/en/products/socs/esp32-c2 */ +#elif defined(CONFIG_IDF_TARGET_ESP32P4) + #define WOLFSSL_ESP32 + /* wolfSSL Hardware Acceleration not yet implemented */ #define NO_ESP32_CRYPT #define NO_WOLFSSL_ESP32_CRYPT_HASH #define NO_WOLFSSL_ESP32_CRYPT_AES #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI + /***** END CONFIG_IDF_TARGET_ESP32P4 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP8266) + #define WOLFSSL_ESP8266 + + /* There's no hardware encryption on the ESP8266 */ + /* Consider using the ESP32-C2/C3/C6 */ + #define NO_ESP32_CRYPT + #define NO_WOLFSSL_ESP32_CRYPT_HASH + #define NO_WOLFSSL_ESP32_CRYPT_AES + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI + #ifndef FP_MAX_BITS + /* FP_MAX_BITS matters in wolfssl_test, not just TLS setting. */ + /* MIN_FFDHE_FP_MAX_BITS = (MIN_FFDHE_BITS * 2); see settings.h */ + #define FP_MAX_BITS MIN_FFDHE_FP_MAX_BITS + #endif /***** END CONFIG_IDF_TARGET_ESP266 *****/ #elif defined(CONFIG_IDF_TARGET_ESP8684) @@ -518,7 +814,7 @@ /***** END CONFIG_IDF_TARGET_ESP8684 *****/ #else - /* Anything else encountered, disable HW accleration */ + /* Anything else encountered, disable HW acceleration */ #warning "Unexpected CONFIG_IDF_TARGET_NN value" #define NO_ESP32_CRYPT #define NO_WOLFSSL_ESP32_CRYPT_HASH @@ -556,18 +852,33 @@ /* Debug options: See wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h for details on debug options +optionally increase error message size for very long paths. +#define WOLFSSL_MAX_ERROR_SZ 500 + +Turn wolfSSL debugging on/off: + wolfSSL_Debugging_ON(); + wolfSSL_Debugging_OFF(); + #define ESP_VERIFY_MEMBLOCK #define DEBUG_WOLFSSL #define DEBUG_WOLFSSL_VERBOSE #define DEBUG_WOLFSSL_SHA_MUTEX +#define WOLFSSL_DEBUG_IGNORE_ASN_TIME +#define WOLFSSL_DEBUG_CERT_BUNDLE +#define WOLFSSL_DEBUG_CERT_BUNDLE_NAME #define WOLFSSL_ESP32_CRYPT_DEBUG #define WOLFSSL_ESP32_CRYPT_HASH_SHA224_DEBUG #define NO_RECOVER_SOFTWARE_CALC #define WOLFSSL_TEST_STRAY 1 #define USE_ESP_DPORT_ACCESS_READ_BUFFER #define WOLFSSL_ESP32_HW_LOCK_DEBUG +#define WOLFSSL_DEBUG_MUTEX #define WOLFSSL_DEBUG_ESP_RSA_MULM_BITS +#define WOLFSSL_DEBUG_ESP_HW_MOD_RSAMAX_BITS +#define WOLFSSL_DEBUG_ESP_HW_MULTI_RSAMAX_BITS #define ESP_DISABLE_HW_TASK_LOCK +#define ESP_MONITOR_HW_TASK_LOCK +#define USE_ESP_DPORT_ACCESS_READ_BUFFER See wolfcrypt/benchmark/benchmark.c for debug and other settings: @@ -579,7 +890,8 @@ Turn on timer debugging (used when CPU cycles not available) */ /* Pause in a loop rather than exit. */ -#define WOLFSSL_ESPIDF_ERROR_PAUSE +/* #define WOLFSSL_ESPIDF_ERROR_PAUSE */ +/* #define WOLFSSL_ESP32_HW_LOCK_DEBUG */ #define WOLFSSL_HW_METRICS @@ -628,6 +940,12 @@ Turn on timer debugging (used when CPU cycles not available) * There are various certificate examples in this header file: * https://github.com/wolfSSL/wolfssl/blob/master/wolfssl/certs_test.h * + * To use the sample certificates in code (not recommended for production!): + * + * #if defined(USE_CERT_BUFFERS_2048) || defined(USE_CERT_BUFFERS_1024) + * #include + * #endif + * * To use the sets of macros below, define *one* of these: * * USE_CERT_BUFFERS_1024 - ECC 1024 bit encoded ASN1 @@ -705,6 +1023,7 @@ Turn on timer debugging (used when CPU cycles not available) #define WOLFSSL_BASE16 #else #if defined(USE_CERT_BUFFERS_2048) + #define USE_CERT_BUFFERS_256 /* Be sure to include in app when using example certs: */ /* #include */ #define CTX_CA_CERT ca_cert_der_2048 @@ -726,6 +1045,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) + #define USE_CERT_BUFFERS_256 /* Be sure to include in app when using example certs: */ /* #include */ #define CTX_CA_CERT ca_cert_der_1024 @@ -773,3 +1093,11 @@ Turn on timer debugging (used when CPU cycles not available) #else #warning "CONFIG_ESP_MAIN_TASK_STACK_SIZE not defined!" #endif +/* See settings.h for some of the possible hardening options: + * + * #define NO_ESPIDF_DEFAULT + * #define WC_NO_CACHE_RESISTANT + * #define WC_AES_BITSLICED + * #define HAVE_AES_ECB + * #define HAVE_AES_DIRECT + */ diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/CMakeLists.txt index 2fe1790be..2998d8ee5 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/CMakeLists.txt @@ -1,9 +1,132 @@ +# wolfSSL Espressif Example Project/main CMakeLists.txt +# v1.2 # # wolfssl crypt test # +message(STATUS "Begin wolfSSL main CMakeLists.txt") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") -idf_component_register(SRCS - "main.c" - INCLUDE_DIRS - ".") +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + # `driver` component not available for ESP8266 + SET(THIS_PRIV_REQUIRES_DRIVER "") +else() + SET(THIS_PRIV_REQUIRES_DRIVER "driver") +endif() + +if(WIN32) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") + message(STATUS "Detected Windows") +endif() +if(CMAKE_HOST_UNIX) + message(STATUS "Detected UNIX") +endif() +if(APPLE) + message(STATUS "Detected APPLE") +endif() +if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") + message(STATUS "Detected WSL") +endif() +if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") + message(STATUS "Detected Linux") +endif() +if(APPLE) + # Windows-specific configuration here + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") + message(STATUS "Detected Apple") +endif() +set (git_cmd "git") + +if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl/" AND EXISTS "$ENV{IDF_PATH}/components/wolfssl/" ) + # + # wolfSSL found in both ESP-IDF and local project - needs to be resolved by user + # + message(STATUS "") + message(STATUS "WARNING: Found components/wolfssl in both local project and IDF_PATH") + message(STATUS "") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING") +endif() + +# The wolfSL component name is named "mywolfssl" on the staging site for Managed Components. +if( NOT EXISTS "../components/wolfssl" AND ("$ENV{IDF_COMPONENT_REGISTRY_URL}" STREQUAL "https://components-staging.espressif.com") ) + message(STATUS "WARNING: Using a staging instance of wolfssl.") + set(MAIN_WOLFSSL_COMPONENT_NAME "mywolfssl") +else() + message(STATUS "Using release wolfssl component.") + set(MAIN_WOLFSSL_COMPONENT_NAME "wolfssl") +endif() + +## register_component() +idf_component_register(SRCS main.c + INCLUDE_DIRS "." + "./include" + PRIV_REQUIRES "${THIS_PRIV_REQUIRES_DRIVER}" + "${MAIN_WOLFSSL_COMPONENT_NAME}" + ) + +# +# LIBWOLFSSL_SAVE_INFO(VAR_OUPUT THIS_VAR VAR_RESULT) +# +# Save the THIS_VAR as a string in a macro called VAR_OUPUT +# +# VAR_OUPUT: the name of the macro to define +# THIS_VAR: the OUTPUT_VARIABLE result from a execute_process() +# VAR_RESULT: the RESULT_VARIABLE from a execute_process(); "0" if successful. +# +function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) + # is the RESULT_VARIABLE output value 0? If so, IS_VALID_VALUE is true. + string(COMPARE EQUAL "${VAR_RESULT}" "0" IS_VALID_VALUE) + + # if we had a successful operation, save the THIS_VAR in VAR_OUPUT + if(${IS_VALID_VALUE}) + # strip newline chars in THIS_VAR parameter and save in VAR_VALUE + string(REPLACE "\n" "" VAR_VALUE ${THIS_VAR}) + + # we'll could percolate the value to the parent for possible later use + # set(${VAR_OUPUT} ${VAR_VALUE} PARENT_SCOPE) + + # but we're only using it here in this function + set(${VAR_OUPUT} ${VAR_VALUE}) + + # we'll print what we found to the console + message(STATUS "Found ${VAR_OUPUT}=${VAR_VALUE}") + + # the interesting part is defining the VAR_OUPUT name a value to use in the app + add_compile_definitions(${VAR_OUPUT}=\"${VAR_VALUE}\") + else() + # if we get here, check the execute_process command and parameters. + message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT.") + message(STATUS "Setting ${VAR_OUPUT} to \"Unknown\"") + set(${VAR_OUPUT} "Unknown") + endif() +endfunction() # LIBWOLFSSL_SAVE_INFO + +execute_process( + COMMAND ${git_cmd} "rev-parse" "--is-inside-work-tree" + OUTPUT_VARIABLE IS_GIT_REPO + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + +# Save some project-specific details. Repo may be different than component, or may not even be a repo at all: +if(NOT CMAKE_BUILD_EARLY_EXPANSION AND (IS_GIT_REPO STREQUAL "true")) + # LIBWOLFSSL_VERSION_GIT_HASH + execute_process(COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") + + # LIBWOLFSSL_VERSION_GIT_SHORT_HASH + execute_process(COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_SHORT_HASH "${TMP_OUT}" "${TMP_RES}") + + # LIBWOLFSSL_VERSION_GIT_HASH_DATE + execute_process(COMMAND ${git_cmd} "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ) + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH_DATE "${TMP_OUT}" "${TMP_RES}") +endif() + +message(STATUS "") + +message(STATUS "End wolfSSL main CMakeLists.txt") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/Kconfig.projbuild b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/Kconfig.projbuild index 264c80883..06cc01df8 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/Kconfig.projbuild +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/Kconfig.projbuild @@ -1,29 +1,112 @@ -menu "Example Configuration" +# Kconfig main +# +# Copyright (C) 2006-2025 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 +# -config BENCH_ARGV - string "Arguments for benchmark test" - default "-lng 0" +# Kconfig File Version 5.7.2.001 for wolfssl_template + +menu "Example wolfSSL Configuration" + +choice WOLFSSL_EXAMPLE_CHOOSE + prompt "Choose Example (See wolfssl/include/user_settings.h)" + default WOLFSSL_EXAMPLE_NAME_NONE help - -? Help, print this usage - 0: English, 1: Japanese - -csv Print terminal output in csv format - -base10 Display bytes as power of 10 (eg 1 kB = 1000 Bytes) - -no_aad No additional authentication data passed. - -dgst_full Full digest operation performed. - -rsa_sign Measure RSA sign/verify instead of encrypt/decrypt. - - Algorithm to benchmark. Available algorithms include: - cipher aes-cbc aes-gcm chacha20 chacha20-poly1305 - digest md5 poly1305 sha sha2 sha224 sha256 sha384 sha512 sha3 - sha3-224 sha3-256 sha3-384 sha3-512 - mac hmac hmac-md5 hmac-sha hmac-sha224 hmac-sha256 hmac-sha384 - hmac-sha512 - asym rsa rsa-sz dh ecc-kg ecc - other rng - -lng Display benchmark result by specified language. - 0: English, 1: Japanese - Size of block in bytes + The user settings file can be adjusted to specific wolfSSL examples. - e.g -lng 1 - e.g sha + config WOLFSSL_EXAMPLE_NAME_TEMPLATE + bool "wolfSSL Template" + help + The sample template app compiles in wolfSSL and prints the current wolfSSL Version. Nothing more. + + config WOLFSSL_EXAMPLE_NAME_TEST + bool "wolfSSL Test" + help + This app tests all cryptographic functions currently enabled. See also Benchmark performance app. + + config WOLFSSL_EXAMPLE_NAME_BENCHMARK + bool "wolfSSL Benchmark" + help + Benchmark performance app. See also cryptographic test. + + config WOLFSSL_EXAMPLE_NAME_TLS_CLIENT + bool "TLS Client" + help + TLS Client Example app. Needs WiFi and a listening server on port 11111. + + config WOLFSSL_EXAMPLE_NAME_TLS_SERVER + bool "TLS Server" + help + TLS Server Example app. Needs WiFi. More interesting with a TLS client using port 11111. + + config WOLFSSL_EXAMPLE_NAME_WOLFSSH_TEMPLATE + bool "SSH Template App" + help + Bare-bones Hello World app that only compiles in wolfSSL and wolfSSH. + See wolfSSL/wolfssh on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFSSH_ECHOSERVER + bool "SSH Echo Server" + help + See wolfSSL/wolfssh on GitHub. + + config WOLFSSL_EXAMPLE_NAME_ESP32_SSH_SERVER + bool "SSH to UART Server for the ESP32" + help + See wolfSSL/wolfssh-examples on GitHub. + + config WOLFSSL_EXAMPLE_NAME_ESP8266_SSH_SERVER + bool "SSH to UART Server for the ESP8266" + help + See wolfSSL/wolfssh-examples on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFMQTT_TEMPLATE + bool "MQTT Template" + help + See wolfSSL/wolfmqtt on GitHub. + + config WOLFSSL_EXAMPLE_NAME_WOLFMQTT_AWS_IOT_MQTT + bool "MQTT AWS IoT" + help + See wolfSSL/wolfmqtt on GitHub. + + config WOLFTPM_EXAMPLE_NAME_ESPRESSIF + bool "TPM Test Example for the ESP32" + help + See wolfSSL/wolfTPM on GitHub. + + config WOLFSSL_EXAMPLE_NAME_NONE + bool "Other" + help + A specific example app is not defined. + +endchoice + +config WOLFSSL_TARGET_HOST + string "Target host" + default "127.0.0.1" + help + host address for the example to connect + +config WOLFSSL_TARGET_PORT + int "Target port" + default 11111 + help + host port for the example to connect endmenu diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/component.mk index df684f1e0..08f8fbe9b 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/component.mk @@ -6,4 +6,18 @@ # in the build directory. This behavior is entirely configurable, # please read the ESP-IDF documents if you need to do this. # -# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) +# (Uses default behavior of compiling all source files in directory, adding 'include' to include path.) + +# We'll add the explicit lines only for old SDK requirements (e.h. ESP8266) + +ifeq ("$(VISUALGDB_DIR)","") + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL) ) +else + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL) ) + COMPONENT_SRCDIRS := . + COMPONENT_ADD_INCLUDEDIRS := . + COMPONENT_ADD_INCLUDEDIRS += include + + # Ensure main.c gets compiled + COMPONENT_OBJS := main.o +endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/include/main.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/include/main.h index 94d913235..7b41f28ba 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/include/main.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/include/main.h @@ -1,6 +1,6 @@ -/* template main.h +/* wolfssl_test main.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -18,7 +18,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ + #ifndef _MAIN_H_ #define _MAIN_H_ +void app_main(void); + #endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/main.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/main.c index 315ff304c..32e0bb895 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/main.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/main.c @@ -1,6 +1,6 @@ -/* main.c +/* test main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -26,17 +26,20 @@ /* wolfSSL */ /* Always include wolfcrypt/settings.h before any other wolfSSL file. */ /* Reminder: settings.h pulls in user_settings.h; don't include it here. */ -#ifdef WOLFSSL_USER_SETTINGS +#if defined(WOLFSSL_USER_SETTINGS) #include - #ifndef WOLFSSL_ESPIDF - #warning "Problem with wolfSSL user_settings." - #warning "Check components/wolfssl/include" + #if defined(WOLFSSL_ESPIDF) + #include + #include + #include + #include + #include + #else + #error "Problem with wolfSSL user_settings. " \ + "Check components/wolfssl/include " \ + "and confirm WOLFSSL_USER_SETTINGS is defined, " \ + "typically in the component CMakeLists.txt" #endif - #include - #include - #include - #include - #include #else /* Define WOLFSSL_USER_SETTINGS project wide for settings.h to include */ /* wolfSSL user settings in ./components/wolfssl/include/user_settings.h */ @@ -44,8 +47,9 @@ CFLAGS +=-DWOLFSSL_USER_SETTINGS" #endif -#include "driver/uart.h" - +/* Hardware; include after other libraries, + * particularly after freeRTOS from settings.h */ +#include /* set to 0 for one test, ** set to 1 for continuous test loop */ @@ -76,9 +80,13 @@ /* ** although the wolfcrypt/test includes a default time setting, -** see wolfssl/wolfcrypt/port/Espressif/esp-sdk-lib.h */ - +** see the enclosed optional time helper for adding NNTP. +** be sure to add "time_helper.c" in main/CMakeLists.txt +*/ #undef WOLFSSL_USE_TIME_HELPER +#if defined(WOLFSSL_USE_TIME_HELPER) + #include "time_helper.h" +#endif /* see wolfssl/wolfcrypt/test/test.h */ extern void wolf_crypt_task(); @@ -155,13 +163,18 @@ void app_main(void) .parity = UART_PARITY_DISABLE, .stop_bits = UART_STOP_BITS_1, }; + int stack_start = 0; + int heap_start = 0; + int heap_current = 0; + int loops = 0; esp_err_t ret = 0; - wc_ptr_t stack_start = esp_sdk_stack_pointer(); + + stack_start = esp_sdk_stack_pointer(); /* uart_set_pin(UART_NUM_0, TX_PIN, RX_PIN, * UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); */ - /* Some targets may need to have UART speed set. TODO: which? */ + /* Some targets may need to have UART speed set, such as ESP8266 */ ESP_LOGI(TAG, "UART init"); uart_param_config(UART_NUM_0, &uart_config); uart_driver_install(UART_NUM_0, @@ -186,6 +199,7 @@ void app_main(void) #ifdef TASK_EXTRA_STACK_SIZE ESP_LOGI(TAG, "TASK_EXTRA_STACK_SIZE: %d", TASK_EXTRA_STACK_SIZE); #endif + #ifdef INCLUDE_uxTaskGetStackHighWaterMark ESP_LOGI(TAG, "CONFIG_ESP_MAIN_TASK_STACK_SIZE = %d bytes (%d words)", CONFIG_ESP_MAIN_TASK_STACK_SIZE, @@ -195,13 +209,13 @@ void app_main(void) * the minimum free stack space there has been (in bytes not words, unlike * vanilla FreeRTOS) since the task started. The smaller the returned * number the closer the task has come to overflowing its stack. - * see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos_idf.html + * see Espressif esp32/api-reference/system/freertos_idf.html */ stack_start = uxTaskGetStackHighWaterMark(NULL); ESP_LOGI(TAG, "Stack Start HWM: %d bytes", stack_start); #endif -#ifdef HAVE_VERSION_EXTENDED_INFO +#if defined(HAVE_VERSION_EXTENDED_INFO) esp_ShowExtendedSystemInfo(); #endif @@ -230,38 +244,49 @@ void app_main(void) ESP_LOGI(TAG, "NO_CRYPT_TEST defined, skipping wolf_test_task"); #else /* Although wolfCrypt_Init() may be explicitly called above, - ** Note it is still always called in wolf_test_task. + ** note it is still always called in wolf_test_task. */ - int loops = 0; + stack_start = uxTaskGetStackHighWaterMark(NULL); + heap_start = heap_caps_get_free_size(MALLOC_CAP_8BIT); + do { - #if defined(WOLFSSL_HW_METRICS) && defined(WOLFSSL_HAS_METRICS) + heap_current = heap_caps_get_free_size(MALLOC_CAP_8BIT); + ESP_LOGI(TAG, "Free heap memory: %d bytes; Start %d", + heap_current, heap_start); + ESP_LOGI(TAG, "Stack HWM: %d\n", uxTaskGetStackHighWaterMark(NULL)); + + ret = wolf_test_task(); + #if defined(WOLFSSL_ESP32_CRYPT_RSA_PRI) && defined(WOLFSSL_HW_METRICS) esp_hw_show_metrics(); #endif - ret = wolf_test_task(); + loops++; /* count of the number of tests run before fail. */ ESP_LOGI(TAG, "Stack HWM: %d\n", uxTaskGetStackHighWaterMark(NULL)); ESP_LOGI(TAG, "loops = %d", loops); - loops++; - } - while (TEST_LOOP && (ret == 0)); + } while (TEST_LOOP && (ret == 0)); + + /* Reminder: wolfCrypt_Cleanup() should always be called at completion, + ** and is called in wolf_test_task(). */ #if defined TEST_LOOP && (TEST_LOOP == 1) ESP_LOGI(TAG, "Test loops completed: %d", loops); #endif - /* note wolfCrypt_Cleanup() should always be called when finished. - ** This is called at the end of wolf_test_task(); - */ +#if defined(SINGLE_THREADED) + /* need stack monitor for single thread */ +#else + ESP_LOGI(TAG, "Stack HWM: %d\n", uxTaskGetStackHighWaterMark(NULL)); +#endif -#if defined(DEBUG_WOLFSSL) && defined(WOLFSSL_ESP32_CRYPT_RSA_PRI) +#if defined(WOLFSSL_HW_METRICS) && defined(WOLFSSL_ESP32_CRYPT_RSA_PRI) esp_hw_show_mp_metrics(); #endif #ifdef INCLUDE_uxTaskGetStackHighWaterMark - ESP_LOGI(TAG, "Stack HWM: %d", uxTaskGetStackHighWaterMark(NULL)); + ESP_LOGI(TAG, "Stack HWM: %d", uxTaskGetStackHighWaterMark(NULL)); - ESP_LOGI(TAG, "Stack used: %d", CONFIG_ESP_MAIN_TASK_STACK_SIZE - - (uxTaskGetStackHighWaterMark(NULL))); + ESP_LOGI(TAG, "Stack used: %d", CONFIG_ESP_MAIN_TASK_STACK_SIZE + - (uxTaskGetStackHighWaterMark(NULL))); #endif #ifdef WOLFSSL_ESPIDF_VERBOSE_EXIT_MESSAGE @@ -278,7 +303,7 @@ void app_main(void) "If running from idf.py monitor, press twice: Ctrl+]"); #endif - /* done */ + /* After completion, we'll just wait */ while (1) { #if defined(SINGLE_THREADED) while (1); diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/partitions_singleapp_large.csv b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/partitions_singleapp_large.csv index 5a1a339c9..0b2fcd1a9 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/partitions_singleapp_large.csv +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/partitions_singleapp_large.csv @@ -1,34 +1,31 @@ -# This tag is used to include this file in the ESP Component Registry: -# __ESP_COMPONENT_SOURCE__ - -# to view: idf.py partition-table -# -# ESP-IDF Partition Table -# Name, Type, SubType, Offset, Size, Flags -nvs, data, nvs, 0x9000, 24K, -phy_init,data, phy, 0xf000, 4K, -factory, app, factory, 0x10000, 1500K, - - -# For other settings, see: -# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#creating-custom-tables -# -# Here is the summary printed for the Single factory app, no OTA configuration: -# -# # ESP-IDF Partition Table -# # Name, Type, SubType, Offset, Size, Flags -# nvs, data, nvs, 0x9000, 0x6000, -# phy_init, data, phy, 0xf000, 0x1000, -# factory, app, factory, 0x10000, 1M, -# -# -# Here is the summary printed for the Factory app, two OTA definitions configuration: -# -# # ESP-IDF Partition Table -# # Name, Type, SubType, Offset, Size, Flags -# nvs, data, nvs, 0x9000, 0x4000, -# otadata, data, ota, 0xd000, 0x2000, -# phy_init, data, phy, 0xf000, 0x1000, -# factory, app, factory, 0x10000, 1M, -# ota_0, app, ota_0, 0x110000, 1M, -# ota_1, app, ota_1, 0x210000, 1M, +# to view: idf.py partition-table +# +# ESP-IDF Partition Table +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 24K, +phy_init,data, phy, 0xf000, 4K, +factory, app, factory, 0x10000, 1500K, + + +# For other settings, see: +# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#creating-custom-tables +# +# Here is the summary printed for the "Single factory app, no OTA" configuration: +# +# # ESP-IDF Partition Table +# # Name, Type, SubType, Offset, Size, Flags +# nvs, data, nvs, 0x9000, 0x6000, +# phy_init, data, phy, 0xf000, 0x1000, +# factory, app, factory, 0x10000, 1M, +# +# +# Here is the summary printed for the "Factory app, two OTA definitions" configuration: +# +# # ESP-IDF Partition Table +# # Name, Type, SubType, Offset, Size, Flags +# nvs, data, nvs, 0x9000, 0x4000, +# otadata, data, ota, 0xd000, 0x2000, +# phy_init, data, phy, 0xf000, 0x1000, +# factory, app, factory, 0x10000, 1M, +# ota_0, app, ota_0, 0x110000, 1M, +# ota_1, app, ota_1, 0x210000, 1M, diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults index 2a5ad756d..50773fdc1 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults @@ -1,19 +1,34 @@ +# Set the known example app config to template example (see user_settings.h) +CONFIG_WOLFSSL_EXAMPLE_NAME_TEST=y + +# CONFIG_EXAMPLE_WIFI_SSID="myssid" +# CONFIG_EXAMPLE_WIFI_PASSWORD="mypassword" + +# Some wolfSSL helpers +CONFIG_USE_WOLFSSL_ESP_SDK_TIME=y + # sdkconfig.defaults for ESP8266 + ESP32 +# See separate sdkconfig.defaults.esp8266 # Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. -# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults CONFIG_BENCH_ARGV="-lng 0" +# FreeRTOS ticks at 1ms interval +CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_HZ=1000 CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y # # Default main stack size. See user_settings.h # +# This is typically bigger than needed for stack size. +# Units are words, not bytes. See user_settings.h +# # For wolfSSL SMALL_STACK, 3072 bytes should be sufficient for benchmark app. # When using RSA, assign at least 10500 bytes, otherwise 5500 usually works for others -CONFIG_ESP_MAIN_TASK_STACK_SIZE=10500 +# We set this to 28672 for use in the "test everything possible" in the wolfssl_test app. +CONFIG_ESP_MAIN_TASK_STACK_SIZE=28672 -# Legacy stack size for older ESP-IDF versions -CONFIG_MAIN_TASK_STACK_SIZE=10500 +# Legacy stack size name for older ESP-IDF versions +CONFIG_MAIN_TASK_STACK_SIZE=28672 # # Benchmark must not have CONFIG_NEWLIB_NANO_FORMAT enabled @@ -31,6 +46,10 @@ CONFIG_ESP_TASK_WDT_EN=n CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y CONFIG_ESP_INT_WDT=n +# ESP8266 Watchdog: +CONFIG_TASK_WDT=n +CONFIG_TASK_WDT_PANIC=n + # ESP8266 WDT # CONFIG_ESP_PANIC_PRINT_REBOOT is not set CONFIG_ESP_PANIC_PRINT_REBOOT=n @@ -46,6 +65,36 @@ CONFIG_HEAP_DISABLE_IRAM=y # Performance # CONFIG_COMPILER_OPTIMIZATION_PERF=y +# Set max CPU frequency (falls back as needed for lower maximum) +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y + +# Enable wolfSSL TLS in esp-tls +# CONFIG_ESP_TLS_USING_WOLFSSL=y +# CONFIG_TLS_STACK_WOLFSSL=y + +# Bundles take up flash space and are disabled unless otherwise known to be needed +CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=n +# CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=y +# CONFIG_ESP_WOLFSSL_SMALL_CERT_VERIFY=y +# CONFIG_ESP_TLS_INSECURE=y + +# Disable mbedTLS +CONFIG_ESP_TLS_USING_MBEDTLS=n +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n + +# Some wolfSSL helpers +CONFIG_USE_WOLFSSL_ESP_SDK_TIME=n + +# CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set +CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=n + +# ESP8266 Memory +CONFIG_FREERTOS_GLOBAL_DATA_LINK_IRAM=y +CONFIG_HEAP_DISABLE_IRAM=y + +# Performance +# CONFIG_COMPILER_OPTIMIZATION_PERF=y + # Set max COU frequency (falls back as needed for lower maximum) CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y @@ -53,6 +102,26 @@ CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_HZ=1000 +# Ensure mbedTLS options are disabled +# CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=n +# CONFIG_MBEDTLS_TLS_CLIENT_ONLY=n +# CONFIG_MBEDTLS_TLS_SERVER=n +# CONFIG_MBEDTLS_TLS_CLIENT=n +# CONFIG_MBEDTLS_HARDWARE_AES=n +# CONFIG_MBEDTLS_HARDWARE_MPI=n +# CONFIG_MBEDTLS_HARDWARE_SHA=n +# CONFIG_MBEDTLS_ROM_MD5=n +# CONFIG_MBEDTLS_SSL_RENEGOTIATION=n +# CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=n +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1=n +# CONFIG_MBEDTLS_SSL_ALPN=n +# CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=n +# CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=n + +# The same-name config is used for both WiFi and client/server TLS, so we cannot disable: +# CONFIG_MBEDTLS_TLS_ENABLED=n +# CONFIG_MBEDTLS_TLS_DISABLED=y + # # Compiler options # diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32 b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32 new file mode 100644 index 000000000..9d61e301d --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32 @@ -0,0 +1,4 @@ +# Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults + +CONFIG_ESP_MAIN_TASK_STACK_SIZE=28672 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32c3 b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32c3 new file mode 100644 index 000000000..a252c51ba --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32c3 @@ -0,0 +1,4 @@ +# Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults + +CONFIG_ESP_MAIN_TASK_STACK_SIZE=25500 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32c6 b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32c6 new file mode 100644 index 000000000..a252c51ba --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32c6 @@ -0,0 +1,4 @@ +# Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults + +CONFIG_ESP_MAIN_TASK_STACK_SIZE=25500 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32h2 b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32h2 new file mode 100644 index 000000000..a252c51ba --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32h2 @@ -0,0 +1,4 @@ +# Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults + +CONFIG_ESP_MAIN_TASK_STACK_SIZE=25500 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32s2 b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32s2 new file mode 100644 index 000000000..9d61e301d --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32s2 @@ -0,0 +1,4 @@ +# Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults + +CONFIG_ESP_MAIN_TASK_STACK_SIZE=28672 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32s3 b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32s3 new file mode 100644 index 000000000..9d61e301d --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32s3 @@ -0,0 +1,4 @@ +# Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults + +CONFIG_ESP_MAIN_TASK_STACK_SIZE=28672 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp8266 b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp8266 new file mode 100644 index 000000000..77299dfe4 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp8266 @@ -0,0 +1,30 @@ +# ESP8266 WDT +# CONFIG_ESP_PANIC_PRINT_REBOOT is not set +CONFIG_ESP_PANIC_PRINT_REBOOT=n +CONFIG_ESP_PANIC_PRINT_HALT=y + +# Enable wolfSSL TLS in esp-tls (not yet supported in RTOS SDK 3.4 +CONFIG_ESP_TLS_USING_WOLFSSL=n +CONFIG_TLS_STACK_WOLFSSL=n + +# Bundles take up flash space and are disabled unless otherwise known to be needed +CONFIG_WOLFSSL_CERTIFICATE_BUNDLE=n +# CONFIG_ESP_WOLFSSL_SMALL_CERT_VERIFY=y +# CONFIG_ESP_TLS_INSECURE=y + +# Disable mbedTLS +CONFIG_ESP_TLS_USING_MBEDTLS=y +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n + +# ESP8266 Memory +CONFIG_FREERTOS_GLOBAL_DATA_LINK_IRAM=y +CONFIG_HEAP_DISABLE_IRAM=y + +# ESP8266 Watchdog: +CONFIG_TASK_WDT=n +CONFIG_TASK_WDT_PANIC=n + +# ESP8266 WDT +# CONFIG_ESP_PANIC_PRINT_REBOOT is not set +CONFIG_ESP_PANIC_PRINT_REBOOT=n +CONFIG_ESP_PANIC_PRINT_HALT=y diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.sln b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.sln new file mode 100644 index 000000000..57fec6c39 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.sln @@ -0,0 +1,30 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34601.278 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{803FD0C6-D64E-4E16-9DC3-1DAEC859A3D2}") = "wolfssl_test_ESP8266", "wolfssl_test_ESP8266.vgdbproj", "{C9687472-A434-43A7-9026-7914F425B9B4}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D4A6F5E5-807B-4D51-ACD5-8493BCF2E7F0}" + ProjectSection(SolutionItems) = preProject + components\wolfssl\include\user_settings.h = components\wolfssl\include\user_settings.h + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|VisualGDB = Debug|VisualGDB + Release|VisualGDB = Release|VisualGDB + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C9687472-A434-43A7-9026-7914F425B9B4}.Debug|VisualGDB.ActiveCfg = Debug|VisualGDB + {C9687472-A434-43A7-9026-7914F425B9B4}.Debug|VisualGDB.Build.0 = Debug|VisualGDB + {C9687472-A434-43A7-9026-7914F425B9B4}.Release|VisualGDB.ActiveCfg = Release|VisualGDB + {C9687472-A434-43A7-9026-7914F425B9B4}.Release|VisualGDB.Build.0 = Release|VisualGDB + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {84F29237-2909-4E98-AD33-2624E2256EF8} + EndGlobalSection +EndGlobal diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.vgdbproj b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.vgdbproj index 41509e0fd..6181d50c7 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.vgdbproj +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.vgdbproj @@ -53,7 +53,7 @@ - COM80 + COM70 74880 8 @@ -110,7 +110,7 @@ LF false false - true + false diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/README.md b/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/README.md index f2efc2f3d..7d0988aaf 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/README.md +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/README.md @@ -12,11 +12,11 @@ Open the VisualGDB Visual Studio Project file in the VisualGDB directory and cli ## ESP-IDF Commandline -1. `idf.py menuconfig` to configure the program. +1. `idf.py menuconfig` to configure the program. 1-1. Example Configuration -> - TEST_ARG : argument that you want to use. Default is "-lng 0" - The list of argument can be find in help. + There are no parametric arguments. See [wolfcrypt/test](https://github.com/wolfSSL/wolfssl/tree/master/wolfcrypt/test). + All features enabled in the `user_settings.h` will be tested. When you want to run the test program @@ -46,9 +46,9 @@ idf.py build flash -p /dev/ttyS20 -b 115200 monitor ## Example Output -Note the default wolfSSL `user_settings.h` is configured by default to be the most +Note the default wolfSSL `user_settings.h` is configured by default to be the most compatible across the widest ranges of targets. Contact wolfSSL at support@wolfssl.com -for help in optimizing for your particular application, or see the +for help in optimizing for your particular application, or see the [docs](https://www.wolfssl.com/documentation/manuals/wolfssl/index.html). Compiled and flashed with `idf.py build flash -p /dev/ttyS7 -b 115200 monitor`: diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/component.mk index e19e22a53..0adf45649 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/component.mk @@ -1,8 +1,8 @@ # # Main component makefile. # -# This Makefile can be left empty. By default, it will take the sources in the -# src/ directory, compile them and link them into lib(subdirectory_name).a +# This Makefile can be left empty. By default, it will take the sources in the +# src/ directory, compile them and link them into lib(subdirectory_name).a # in the build directory. This behaviour is entirely configurable, # please read the ESP-IDF documents if you need to do this. -# \ No newline at end of file +# diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/component.mk index d31083f65..44bd2b527 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/component.mk @@ -1,3 +1,3 @@ # # Main Makefile. This is basically the same as a component makefile. -# \ No newline at end of file +# diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/main.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/main.c index ba8c82a76..1eb568bde 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/main.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -24,15 +24,26 @@ #include "sdkconfig.h" /* wolfSSL */ -#include -#include -#include -#ifndef WOLFSSL_ESPIDF -#warning "problem with wolfSSL user settings. Check components/wolfssl/include" +/* Always include wolfcrypt/settings.h before any other wolfSSL file. */ +/* Reminder: settings.h pulls in user_settings.h; don't include it here. */ +#ifdef WOLFSSL_USER_SETTINGS + /* Unlike other examples with wolfSSL as a local component, this */ + /* example tests wolSSL *in* the ESP-IDF. If you get an error: */ + /* wolfssl/wolfcrypt/settings.h: No such file or directory */ + /* Then wolfSSL is missing from the ESP-IDF components */ + #include + #ifndef WOLFSSL_ESPIDF + #warning "Problem with wolfSSL user_settings." + #warning "Check components/wolfssl/include" + #endif + #include + #include + #include +#else + #error "Missing WOLFSSL_USER_SETTINGS in CMakeLists or Makefile: \ +CFLAGS +=-DWOLFSSL_USER_SETTINGS" #endif -#include - /* ** the wolfssl component can be installed in either: ** @@ -152,8 +163,8 @@ void app_main(void) /* some interesting settings are target specific (ESP32, -C3, -S3, etc */ -#if defined(CONFIG_IDF_TARGET_ESP32C3) - /* not available for C3 at this time */ +#if defined(CONFIG_IDF_TARGET_ESP32C2) || defined(CONFIG_IDF_TARGET_ESP32C3) + /* TODO CPU_FREQ_MHZ not available for C2/C3 at this time */ #elif defined(CONFIG_IDF_TARGET_ESP32S3) ESP_LOGI(TAG, "CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ = %u MHz", CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ @@ -173,7 +184,7 @@ void app_main(void) #if defined(NO_ESP32_CRYPT) ESP_LOGI(TAG, "NO_ESP32_CRYPT defined! HW acceleration DISABLED."); #else - #if defined(CONFIG_IDF_TARGET_ESP32C3) + #if defined(CONFIG_IDF_TARGET_ESP32C2) || defined(CONFIG_IDF_TARGET_ESP32C3) #error "ESP32_CRYPT not yet supported on ESP32-C3" #elif defined(CONFIG_IDF_TARGET_ESP32S2) #error "ESP32_CRYPT not yet supported on ESP32-S2" 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 a1a18d981..7cac2f131 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/time_helper.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/time_helper.c index 70a6cb816..abd778c25 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/time_helper.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/time_helper.c @@ -1,6 +1,6 @@ /* time_helper.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -94,7 +94,7 @@ int set_time(void) if (NTP_SERVER_COUNT) { /* next, let's setup NTP time servers * - * see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html#sntp-time-synchronization + * see Espressif api-reference/system/system_time */ sntp_setoperatingmode(SNTP_OPMODE_POLL); diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/time_helper.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/time_helper.h index e0bee14e5..0ca254c4a 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/time_helper.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test_idf/main/time_helper.h @@ -1,6 +1,6 @@ #ifndef _TIME_HELPER_H /* - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 a0ec798a2..151bc3ce9 100644 --- a/IDE/Espressif/ESP-IDF/libs/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/libs/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # diff --git a/IDE/Espressif/ESP-IDF/libs/README.md b/IDE/Espressif/ESP-IDF/libs/README.md index 703baf1ea..d5dc4c993 100644 --- a/IDE/Espressif/ESP-IDF/libs/README.md +++ b/IDE/Espressif/ESP-IDF/libs/README.md @@ -4,4 +4,4 @@ Files in IDE\Espressif\ESP-IDF\libs: `component.mk` used in ESP-IDF `wolfssl` component directory -`tigard.cfg` Tigard JTAG config file \ No newline at end of file +`tigard.cfg` Tigard JTAG config file diff --git a/IDE/Espressif/ESP-IDF/libs/component.mk b/IDE/Espressif/ESP-IDF/libs/component.mk index 047bb83ea..568b293b2 100644 --- a/IDE/Espressif/ESP-IDF/libs/component.mk +++ b/IDE/Espressif/ESP-IDF/libs/component.mk @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # @@ -17,6 +17,7 @@ # 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/Espressif/ESP-IDF/setup.sh b/IDE/Espressif/ESP-IDF/setup.sh index 7a68ae4d9..495b62921 100755 --- a/IDE/Espressif/ESP-IDF/setup.sh +++ b/IDE/Espressif/ESP-IDF/setup.sh @@ -159,4 +159,3 @@ if [ "${WOLFSSL_SETUP_VERBOSE}" == "true" ]; then echo "Copy complete!" fi -exit 1 diff --git a/IDE/Espressif/ESP-IDF/test/README.md b/IDE/Espressif/ESP-IDF/test/README.md index e832b5c50..e499c970e 100644 --- a/IDE/Espressif/ESP-IDF/test/README.md +++ b/IDE/Espressif/ESP-IDF/test/README.md @@ -2,9 +2,9 @@ The test contains of wolfSSL unit-test app on Unity. -When you want to run the app -1. Go to /esp-idf/tools/unit-test-app/ folder -2. `idf.py menuconfig` to configure unit test app. -3. `idf.py -T wolfssl build` to build wolfssl unit test app. +When you want to run the app +1. Go to /esp-idf/tools/unit-test-app/ folder +2. `idf.py menuconfig` to configure unit test app. +3. `idf.py -T wolfssl build` to build wolfssl unit test app. -See [https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/unit-tests.html] for more information about unit test app. +See Espressif for more information about unit test app. diff --git a/IDE/Espressif/ESP-IDF/user_settings.h b/IDE/Espressif/ESP-IDF/user_settings.h index 828aab9ff..e48149ee5 100644 --- a/IDE/Espressif/ESP-IDF/user_settings.h +++ b/IDE/Espressif/ESP-IDF/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -331,7 +331,7 @@ #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI /***** END CONFIG_IDF_TARGET_ESP266 *****/ #else - /* Anything else encountered, disable HW accleration */ + /* Anything else encountered, disable HW acceleration */ #define NO_ESP32_CRYPT #define NO_WOLFSSL_ESP32_CRYPT_HASH #define NO_WOLFSSL_ESP32_CRYPT_AES @@ -359,7 +359,7 @@ /* #define HASH_SIZE_LIMIT */ /* for test.c */ -/* #define NO_HW_MATH_TEST */ /* Optionall turn off HW math checks */ +/* #define NO_HW_MATH_TEST */ /* Optionally turn off HW math checks */ /* Optionally include alternate HW test library: alt_hw_test.h */ /* When enabling, the ./components/wolfssl/CMakeLists.txt file diff --git a/IDE/Espressif/README.md b/IDE/Espressif/README.md index 5bb1622f3..530c1012c 100644 --- a/IDE/Espressif/README.md +++ b/IDE/Espressif/README.md @@ -28,18 +28,16 @@ resource. ## Requirements The wolfSSL Espressif code requires the ESP-IDF to be installed for -[Windows](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/windows-setup.html) -or [Linux / MacOS](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/linux-macos-setup.html). +Windows or Linux / MacOS. -See the [Espressif Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/). +See the Espressif Getting Started Guide. -Any editor can be used. See also the [Espressif Third-Party Tools](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/resources.html) -for a list of feature-rich Integrated Development Environments. +Any editor can be used. The [wolfSSL examples](./ESP-IDF/examples/README.md) all include a `./VisualGDB` directory with SoC-specific configurations to help get started quickly. -Although not required, a [JTAG Adapter](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/jtag-debugging/index.html) -can be helpful for development. When not using a built-in JTAG from Espressif, the examples typically +Although not required, a JTAG Adapter can be helpful for development. +When not using a built-in JTAG from Espressif, the examples typically use the open source [Tigard board](https://github.com/tigard-tools/tigard#readme). ## Examples: @@ -52,7 +50,7 @@ There are a variety of examples to help get started: The wolfSSL library can be installed as a managed component: -* [Espressif Managed Component Registry](https://components.espressif.com/components/wolfssl/wolfssl) +* [Espressif Managed Component Registry](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/) ## Notes: @@ -145,7 +143,6 @@ the reset-program hardware properly, causing devices to not be programmed with t Connecting...................................... A fatal error occurred: Failed to connect to ESP32: Wrong boot mode detected (0x13)! The chip needs to be in download mode. -For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html CMake Error at run_serial_tool.cmake:56 (message): /home/gojimmypi/.espressif/python_env/idf4.4_py3.8_env/bin/python /mnt/c/SysGCC/esp32/esp-idf/v4.4.2/components/esptool_py/esptool/esptool.py @@ -188,7 +185,7 @@ Task watchdog got triggered. Guru Meditation Error: Core 0 panic'ed (unknown). Exception was unhandled. ``` -The watchdog needs to be [fed](https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/api-reference/system/wdts.html?highlight=watchdog#_CPPv418esp_task_wdt_resetv) on a regular basis +The watchdog needs to be fed on a regular basis with `void esp_task_wdt_reset(void)` from `esp8266/include/esp_task_wdt.h`. Try turning off the WDT in menuconfig, or for Makefiles: @@ -199,4 +196,4 @@ EXTRA_CFLAGS += -DNO_WATCHDOG #### Other Solutions -See also [this ESP-FAQ Handbook](https://docs.espressif.com/projects/esp-faq/en/latest/esp-faq-en-master.pdf) +See also Espressif `esp-faq-en-master.pdf` diff --git a/IDE/Espressif/include.am b/IDE/Espressif/include.am index 7fa388736..3d356b767 100644 --- a/IDE/Espressif/include.am +++ b/IDE/Espressif/include.am @@ -22,42 +22,53 @@ EXTRA_DIST+= IDE/Espressif/ESP-IDF/user_settings.h # Template EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/CMakeLists.txt EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/Kconfig +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/component.mk +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/CMakeLists.txt +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/Kconfig +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/README.md +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/include +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/include/user_settings.h +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/Makefile +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/main.c +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/Kconfig.projbuild +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/component.mk +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/CMakeLists.txt +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/include +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/include/main.h EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/partitions_singleapp_large.csv EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/README.md EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults.esp8266 EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/VisualGDB -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/CMakeLists.txt -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/include -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/include/user_settings.h -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/CMakeLists.txt -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/include -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/main.c -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/include/main.h EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/VisualGDB/wolfssl_template_IDF_v5.1_ESP32.vgdbproj # Benchmark EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/CMakeLists.txt EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/Makefile -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/partitions_singleapp_large.csv -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/README.md -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/VisualGDB EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/CMakeLists.txt +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/Kconfig EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/component.mk +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/CMakeLists.txt +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/Kconfig +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/README.md EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/include EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/include/user_settings.h +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/CMakeLists.txt EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/component.mk EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/include EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/Kconfig.projbuild EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/main.c EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/include/main.h +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/Makefile +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/partitions_singleapp_large.csv +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/README.md +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults.esp8266 +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/VisualGDB EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/VisualGDB/wolfssl_benchmark_IDF_v4.4_ESP32.sln EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/VisualGDB/wolfssl_benchmark_IDF_v5_ESP32.sln EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/VisualGDB/wolfssl_benchmark_IDF_v5_ESP32C3.sln @@ -70,17 +81,18 @@ EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/VisualGDB/wolfssl_ # TLS Client EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/CMakeLists.txt EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/components -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/main -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/Makefile -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/partitions_singleapp_large.csv -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/README.md -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/README_server_sm.md -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/CMakeLists.txt +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/Kconfig EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/component.mk +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/CMakeLists.txt +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/Kconfig +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/README.md EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/include EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/include/user_settings.h +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults.esp32c2 +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults.esp8266 +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/main EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/CMakeLists.txt EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/component.mk @@ -93,6 +105,10 @@ EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/client-t EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/main.h EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/time_helper.h EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/wifi_connect.h +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/Makefile +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/partitions_singleapp_large.csv +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/README.md +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/README_server_sm.md EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/VisualGDB/README.md EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/wolfssl_client_ESP8266.vgdbproj @@ -103,18 +119,15 @@ EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_client/VisualGDB/wolfssl_cli EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/CMakeLists.txt EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/components -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/main -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/Makefile -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/partitions_singleapp_large.csv -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/README.md -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/README_server_sm.md -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/VisualGDB EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/CMakeLists.txt +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/Kconfig EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/component.mk +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/CMakeLists.txt +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/Kconfig +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/README.md EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/include EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/include/user_settings.h +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/main EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/CMakeLists.txt EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/component.mk EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include @@ -127,8 +140,17 @@ EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/main.h EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/server-tls.h EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/time_helper.h EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/wifi_connect.h -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/VisualGDB/README.md +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/Makefile +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/partitions_singleapp_large.csv +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/README.md +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/README_server_sm.md +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults.esp32c2 +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults.esp8266 +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/wolfssl_server_ESP8266.vgdbproj +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/VisualGDB +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/VisualGDB/README.md EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/VisualGDB/wolfssl_server_IDF_v5_ESP32.sln EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/VisualGDB/wolfssl_server_IDF_v5_ESP32.vgdbproj @@ -137,24 +159,28 @@ EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/testAll.sh EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/testMonitor.sh EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/CMakeLists.txt -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/components -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/main -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/Makefile -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/partitions_singleapp_large.csv -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/README.md -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/VisualGDB EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/CMakeLists.txt +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/Kconfig EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/component.mk +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/CMakeLists.txt +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/Kconfig +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/README.md EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/include EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/include/user_settings.h + +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/main EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/CMakeLists.txt EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/component.mk EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/include EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/Kconfig.projbuild EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/main.c EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/include/main.h +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/Makefile +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/partitions_singleapp_large.csv +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/README.md +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp8266 +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/VisualGDB EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.vgdbproj EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_test/VisualGDB/wolfssl_test-IDF_v5_ESP32.sln @@ -172,7 +198,7 @@ EXTRA_DIST+= IDE/Espressif/ESP-IDF/libs/component.mk EXTRA_DIST+= IDE/Espressif/ESP-IDF/libs/README.md EXTRA_DIST+= IDE/Espressif/ESP-IDF/libs/tigard.cfg -# Other test +# Other test for wolfSSL installed in the ESP-IDF EXTRA_DIST+= IDE/Espressif/ESP-IDF/test/CMakeLists.txt EXTRA_DIST+= IDE/Espressif/ESP-IDF/test/component.mk EXTRA_DIST+= IDE/Espressif/ESP-IDF/test/README.md diff --git a/IDE/GCC-ARM/Header/user_settings.h b/IDE/GCC-ARM/Header/user_settings.h index 40986b08b..9455d1833 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/GCC-ARM/README.md b/IDE/GCC-ARM/README.md index 2aa29d969..40b2bdfd1 100644 --- a/IDE/GCC-ARM/README.md +++ b/IDE/GCC-ARM/README.md @@ -118,7 +118,7 @@ These settings are located in `Header/user_settings.h`. * `USE_SLOW_SHA`: Enables smaller/slower version of SHA. * `USE_SLOW_SHA256`: About 2k smaller and about 25% slower * `USE_SLOW_SHA512`: Over twice as small, but 50% slower -* `USE_CERT_BUFFERS_1024` or `USE_CERT_BUFFERS_2048`: Size of RSA certs / keys to test with. +* `USE_CERT_BUFFERS_1024` or `USE_CERT_BUFFERS_2048`: Size of RSA certs / keys to test with. * `BENCH_EMBEDDED`: Define this if using the wolfCrypt test/benchmark and using a low memory target. * `ECC_USER_CURVES`: Allows user to define curve sizes to enable. Default is 256-bit on. To enable others use `HAVE_ECC192`, `HAVE_ECC224`, etc.... * `TFM_ARM`, `TFM_SSE2`, `TFM_AVR32`, `TFM_PPC32`, `TFM_MIPS`, `TFM_X86` or `TFM_X86_64`: These are assembly optimizations available with USE_FAST_MATH. diff --git a/IDE/GCC-ARM/Source/armtarget.c b/IDE/GCC-ARM/Source/armtarget.c index 8b62a6b75..16f8e524c 100644 --- a/IDE/GCC-ARM/Source/armtarget.c +++ b/IDE/GCC-ARM/Source/armtarget.c @@ -1,6 +1,6 @@ /* armtarget.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 1151bbc32..c89132804 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -39,16 +39,16 @@ int main(void) { int ret; #ifndef NO_CRYPT_BENCHMARK - wolfCrypt_Init(); + wolfCrypt_Init(); - printf("\nBenchmark Test\n"); - benchmark_test(&args); + printf("\nBenchmark Test\n"); + benchmark_test(&args); ret = args.return_code; - printf("Benchmark Test: Return code %d\n", ret); + printf("Benchmark Test: Return code %d\n", ret); - wolfCrypt_Cleanup(); + wolfCrypt_Cleanup(); #else ret = NOT_COMPILED_IN; #endif - return ret; + return ret; } diff --git a/IDE/GCC-ARM/Source/test_main.c b/IDE/GCC-ARM/Source/test_main.c index c63246368..6b4a0e77b 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -40,16 +40,16 @@ int main(void) { int ret; #ifndef NO_CRYPT_TEST - wolfCrypt_Init(); + wolfCrypt_Init(); - printf("\nCrypt Test\n"); - wolfcrypt_test(&args); + printf("\nCrypt Test\n"); + wolfcrypt_test(&args); ret = args.return_code; - printf("Crypt Test: Return code %d\n", ret); + printf("Crypt Test: Return code %d\n", ret); - wolfCrypt_Cleanup(); + wolfCrypt_Cleanup(); #else ret = NOT_COMPILED_IN; #endif - return ret; + return ret; } diff --git a/IDE/GCC-ARM/Source/tls_client.c b/IDE/GCC-ARM/Source/tls_client.c index 927b854d3..cfaf7d013 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 1a19b4e53..df438c87c 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 0956773b6..ab862fca8 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Gaisler-BCC/README.md b/IDE/Gaisler-BCC/README.md new file mode 100644 index 000000000..5becddce9 --- /dev/null +++ b/IDE/Gaisler-BCC/README.md @@ -0,0 +1,65 @@ +# Gaisler BCC + +This document outlines how to compile for the Gaisler LEON range of Sparc CPUs +using the BCC2 toolkit. The steps here should also work for the original BCC. + +## Compiler + +In the examples in this document, a Linux computer is used as a cross compiler +and the compilers have been extracted to `/opt`. You can install them elsewhere, +but please adjust commands accordingly. + +### Bare-metal + +To compile for bare-metal, you need to download the BCC2 binaries from +[here](https://www.gaisler.com/index.php/downloads/compilers). You can use +either the GCC or CLang version, but do note that you will need to set the +CFLAG `-std=c99` to compile in CLang. + +### Linux + +For Linux, you will need the "GNU toolchains for LEON and NOEL" from +[this link](https://www.gaisler.com/index.php/downloads/linux). + +## Compiling + +### Bare metal + +Copy the file `examples/config/user_settings_template.h` to `user_settings.h` in +the root of the source code. Then edit this to add the following: + +```c +#define WOLFSSL_GAISLER_BCC +#define WOLFSSL_GENSEED_FORTEST +``` + +The first `#define` is only required to compile the wolfCrypt benchmark. + +**Note:** that most Gaisler LEON processors do not have a good source of +entropy for the RNG. It is recommended an external entropy source is used when +developing for production. + +You can then compile with the following. Change `leon5` to the LEON CPU version +used: + +```sh +export CC=/opt/sparc-bcc-2.3.1-gcc/bin/sparc-gaisler-elf-gcc +export CXX=/opt/sparc-bcc-2.3.1-gcc/bin/sparc-gaisler-elf-g++ +export CFLAGS="-mcpu=leon5" + +./configure --host=sparc --enable-usersettings --disable-examples --enable-static +make +``` + +### Linux + +To compile for Linux on the LEON use the following commands: + +```sh +export CC=/opt/sparc-gaisler-linux5.10/bin/sparc-gaisler-linux5.10-gcc +export CXX=/opt/sparc-gaisler-linux5.10/bin/sparc-gaisler-linux5.10-g++ +export CFLAGS="-mcpu=leon5" + +./configure --host=sparc-linux +make +``` diff --git a/IDE/Gaisler-BCC/include.am b/IDE/Gaisler-BCC/include.am new file mode 100644 index 000000000..3aaaa45f1 --- /dev/null +++ b/IDE/Gaisler-BCC/include.am @@ -0,0 +1,4 @@ +# vim:ft=automake +# All paths should be given relative to the root + +EXTRA_DIST+= IDE/Gaisler-BCC/README.md diff --git a/IDE/HEXAGON/DSP/Makefile b/IDE/HEXAGON/DSP/Makefile index 361873ee8..036354feb 100644 --- a/IDE/HEXAGON/DSP/Makefile +++ b/IDE/HEXAGON/DSP/Makefile @@ -1,6 +1,6 @@ # Makefile # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # diff --git a/IDE/HEXAGON/Makefile b/IDE/HEXAGON/Makefile index cf7252c86..eb573b575 100644 --- a/IDE/HEXAGON/Makefile +++ b/IDE/HEXAGON/Makefile @@ -1,6 +1,6 @@ # Makefile # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # diff --git a/IDE/HEXAGON/README.md b/IDE/HEXAGON/README.md index 8ac7913db..4cf6ffe17 100644 --- a/IDE/HEXAGON/README.md +++ b/IDE/HEXAGON/README.md @@ -71,5 +71,5 @@ benchmarking using threads on aDSP 20000 verifies on 4 threads took 23.261446 seconds benchmarking 1 thread on cDSP -5000 verifies on 1 threads took 18.560995 seconds +5000 verifies on 1 threads took 18.560995 seconds diff --git a/IDE/HEXAGON/ecc-verify-benchmark.c b/IDE/HEXAGON/ecc-verify-benchmark.c index d000925a5..a2822ba59 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -32,14 +32,14 @@ #define MAX_TIMES 5000 #define MAX_BLOCK_SIZE 1024 -#include +#include -static double get_time() -{ - struct timeval tv; - gettimeofday(&tv, 0); - return (double)tv.tv_sec + (double)tv.tv_usec / 1000000; -} +static double get_time() +{ + struct timeval tv; + gettimeofday(&tv, 0); + return (double)tv.tv_sec + (double)tv.tv_usec / 1000000; +} /* software version */ diff --git a/IDE/HEXAGON/ecc-verify.c b/IDE/HEXAGON/ecc-verify.c index 1e2d9510f..a626ad008 100644 --- a/IDE/HEXAGON/ecc-verify.c +++ b/IDE/HEXAGON/ecc-verify.c @@ -1,6 +1,6 @@ /* ecc-verify.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/IAR-EWARM/Projects/benchmark/benchmark-main.c b/IDE/IAR-EWARM/Projects/benchmark/benchmark-main.c index 76d4470c7..c1291c870 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 cf0f57ac6..89f576272 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/IAR-EWARM/Projects/benchmark/wolfCrypt-benchmark.ewp b/IDE/IAR-EWARM/Projects/benchmark/wolfCrypt-benchmark.ewp index 43d316fb9..18aa7462f 100644 --- a/IDE/IAR-EWARM/Projects/benchmark/wolfCrypt-benchmark.ewp +++ b/IDE/IAR-EWARM/Projects/benchmark/wolfCrypt-benchmark.ewp @@ -937,7 +937,7 @@ diff --git a/IDE/IAR-EWARM/Projects/common/minimum-startup.c b/IDE/IAR-EWARM/Projects/common/minimum-startup.c index 4463b158d..fb7805c09 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/IAR-EWARM/Projects/lib/wolfSSL-Lib.ewp b/IDE/IAR-EWARM/Projects/lib/wolfSSL-Lib.ewp index e3e4d7836..685c9f6fd 100644 --- a/IDE/IAR-EWARM/Projects/lib/wolfSSL-Lib.ewp +++ b/IDE/IAR-EWARM/Projects/lib/wolfSSL-Lib.ewp @@ -1593,7 +1593,7 @@ diff --git a/IDE/IAR-EWARM/Projects/test/test-main.c b/IDE/IAR-EWARM/Projects/test/test-main.c index 13d1308d5..880081c8e 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/IAR-EWARM/Projects/test/wolfCrypt-test.ewp b/IDE/IAR-EWARM/Projects/test/wolfCrypt-test.ewp index ca0a95067..e48aba5f0 100644 --- a/IDE/IAR-EWARM/Projects/test/wolfCrypt-test.ewp +++ b/IDE/IAR-EWARM/Projects/test/wolfCrypt-test.ewp @@ -937,7 +937,7 @@ diff --git a/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_benchmark_SAMV71_XULT/wolfcrypt_benchmark.ewp b/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_benchmark_SAMV71_XULT/wolfcrypt_benchmark.ewp index 979e36637..b927b650c 100644 --- a/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_benchmark_SAMV71_XULT/wolfcrypt_benchmark.ewp +++ b/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_benchmark_SAMV71_XULT/wolfcrypt_benchmark.ewp @@ -958,7 +958,7 @@ @@ -1627,7 +1627,7 @@ diff --git a/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_lib_SAMV71_XULT/wolfcrypt_lib.ewp b/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_lib_SAMV71_XULT/wolfcrypt_lib.ewp index 1f00a1fb3..bb7170c66 100644 --- a/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_lib_SAMV71_XULT/wolfcrypt_lib.ewp +++ b/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_lib_SAMV71_XULT/wolfcrypt_lib.ewp @@ -1624,7 +1624,7 @@ diff --git a/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_test_SAMV71_XULT/Application/runWolfcryptTests.c b/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_test_SAMV71_XULT/Application/runWolfcryptTests.c index 36937deef..07fd6c5bc 100644 --- a/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_test_SAMV71_XULT/Application/runWolfcryptTests.c +++ b/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_test_SAMV71_XULT/Application/runWolfcryptTests.c @@ -26,4 +26,4 @@ int main(void) { OS_CREATETASK(&WLFTASK, "Tests task", wolfTask, 100, WLFSTACK); OS_Start(); /* Start the OS */ return 0; -} \ No newline at end of file +} diff --git a/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_test_SAMV71_XULT/wolfcrypt_test.ewp b/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_test_SAMV71_XULT/wolfcrypt_test.ewp index 9ed45e93a..f871fcef9 100644 --- a/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_test_SAMV71_XULT/wolfcrypt_test.ewp +++ b/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_test_SAMV71_XULT/wolfcrypt_test.ewp @@ -958,7 +958,7 @@ @@ -1627,7 +1627,7 @@ diff --git a/IDE/IAR-MSP430/main.c b/IDE/IAR-MSP430/main.c index c99cb0075..3b8e37f3e 100644 --- a/IDE/IAR-MSP430/main.c +++ b/IDE/IAR-MSP430/main.c @@ -1,6 +1,6 @@ /* MSP430 example main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 fc8f6ba62..b4c79fcc3 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/INTIME-RTOS/libwolfssl.c b/IDE/INTIME-RTOS/libwolfssl.c index 94d39bb24..b92658eaf 100644 --- a/IDE/INTIME-RTOS/libwolfssl.c +++ b/IDE/INTIME-RTOS/libwolfssl.c @@ -4,7 +4,7 @@ #include BOOLEAN __stdcall RslMain( RTHANDLE hModule, - DWORD ul_reason_for_call, + DWORD ul_reason_for_call, LPVOID lpReserved ) { diff --git a/IDE/Infineon/user_settings.h b/IDE/Infineon/user_settings.h index 62f89b7c0..1b189bc6d 100644 --- a/IDE/Infineon/user_settings.h +++ b/IDE/Infineon/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/LINUX-SGX/sgx_t_static.mk b/IDE/LINUX-SGX/sgx_t_static.mk index ebb718cf7..1941bae02 100644 --- a/IDE/LINUX-SGX/sgx_t_static.mk +++ b/IDE/LINUX-SGX/sgx_t_static.mk @@ -115,7 +115,7 @@ ifeq ($(HAVE_WOLFSSL_SP), 1) endif -Flags_Just_For_C := -Wno-implicit-function-declaration -std=c11 +Flags_Just_For_C := -Wno-implicit-function-declaration -std=c99 Common_C_Cpp_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Wolfssl_Include_Paths) -fno-builtin-printf -I. Wolfssl_C_Flags := $(Flags_Just_For_C) $(Common_C_Cpp_Flags) $(Wolfssl_C_Extra_Flags) diff --git a/IDE/LPCXPRESSO/lib_wolfssl/lpc_18xx_port.c b/IDE/LPCXPRESSO/lib_wolfssl/lpc_18xx_port.c index 1bd3c8ecd..5ee4ce079 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 f5ffe3fe6..64c58bf91 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/M68K/benchmark/main.cpp b/IDE/M68K/benchmark/main.cpp index 263b9289a..fe374b7e1 100644 --- a/IDE/M68K/benchmark/main.cpp +++ b/IDE/M68K/benchmark/main.cpp @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/M68K/testwolfcrypt/main.cpp b/IDE/M68K/testwolfcrypt/main.cpp index 3df8ebd37..6e9a1b355 100644 --- a/IDE/M68K/testwolfcrypt/main.cpp +++ b/IDE/M68K/testwolfcrypt/main.cpp @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MCUEXPRESSO/RT1170/wolfssl_cm7/.cproject b/IDE/MCUEXPRESSO/RT1170/wolfssl_cm7/.cproject index 0a346c114..ab827e198 100644 --- a/IDE/MCUEXPRESSO/RT1170/wolfssl_cm7/.cproject +++ b/IDE/MCUEXPRESSO/RT1170/wolfssl_cm7/.cproject @@ -241,7 +241,7 @@ - + @@ -489,7 +489,7 @@ - + @@ -565,4 +565,4 @@ - \ No newline at end of file + diff --git a/IDE/MCUEXPRESSO/benchmark/source/run_benchmark.c b/IDE/MCUEXPRESSO/benchmark/source/run_benchmark.c index bf092fce9..81e6f89cd 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MCUEXPRESSO/user_settings.h b/IDE/MCUEXPRESSO/user_settings.h index d9fd0766c..059b5bb0f 100644 --- a/IDE/MCUEXPRESSO/user_settings.h +++ b/IDE/MCUEXPRESSO/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MCUEXPRESSO/wolfcrypt_test.c b/IDE/MCUEXPRESSO/wolfcrypt_test.c index 8d8993dda..8289a581a 100644 --- a/IDE/MCUEXPRESSO/wolfcrypt_test.c +++ b/IDE/MCUEXPRESSO/wolfcrypt_test.c @@ -1,6 +1,6 @@ /* wolfcrypt_test.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 04d480216..89cc99b35 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/Retarget.c b/IDE/MDK-ARM/MDK-ARM/wolfSSL/Retarget.c index 573247983..dadffe9dc 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/Retarget.c +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/Retarget.c @@ -2,7 +2,7 @@ #ifdef HAVE_CONFIG_H #include #endif - + #include #include #include @@ -39,7 +39,7 @@ extern int SER_PutChar (int ch); /*----------------------------------------------------------------------------- Write character to the Serial Port *----------------------------------------------------------------------------*/ -int sendchar (int c) +int sendchar (int c) { if (c == '\n') { SER_PutChar ('\r'); @@ -52,7 +52,7 @@ int sendchar (int c) /*----------------------------------------------------------------------------- Read character from the Serial Port *----------------------------------------------------------------------------*/ -int getkey (void) +int getkey (void) { int ch = SER_GetChar(); #if defined (HAVE_KEIL_RTX) @@ -67,7 +67,7 @@ int getkey (void) /*--------------------------- _ttywrch ---------------------------------------*/ -void _ttywrch (int ch) +void _ttywrch (int ch) { #ifdef STDIO sendchar (ch); @@ -76,28 +76,28 @@ void _ttywrch (int ch) /*--------------------------- _sys_open --------------------------------------*/ #ifndef NO_FILESYSTEM -static int KEIL_FS_open(const char *name, int openmode) +static int KEIL_FS_open(const char *name, int openmode) { int i ; int ret ; #define PATHSIZE 100 char path[PATHSIZE] ; char *p ; - + if(strlen(name) > PATHSIZE)return(-1) ; - + for(i = 0; i<= strlen(name); i++) { if(name[i] == '/')path[i] = '\\' ; else path[i] = name[i] ; - } + } if(path[0] == '.' && path[1] == '\\') p = path + 2 ; else p = path ; ret = __sys_open (p, openmode) ; - + return(ret) ; } #endif -FILEHANDLE _sys_open (const char *name, int openmode) +FILEHANDLE _sys_open (const char *name, int openmode) { /* Register standard Input Output devices. */ if (strcmp(name, "STDIN") == 0) { @@ -118,7 +118,7 @@ FILEHANDLE _sys_open (const char *name, int openmode) /*--------------------------- _sys_close -------------------------------------*/ -int _sys_close (FILEHANDLE fh) +int _sys_close (FILEHANDLE fh) { if (fh > 0x8000) { return (0); @@ -132,7 +132,7 @@ int _sys_close (FILEHANDLE fh) /*--------------------------- _sys_write -------------------------------------*/ -int _sys_write (FILEHANDLE fh, const U8 *buf, U32 len, int mode) +int _sys_write (FILEHANDLE fh, const U8 *buf, U32 len, int mode) { #ifdef STDIO if (fh == STDOUT) { @@ -155,7 +155,7 @@ int _sys_write (FILEHANDLE fh, const U8 *buf, U32 len, int mode) /*--------------------------- _sys_read --------------------------------------*/ -int _sys_read (FILEHANDLE fh, U8 *buf, U32 len, int mode) +int _sys_read (FILEHANDLE fh, U8 *buf, U32 len, int mode) { #ifdef STDIO if (fh == STDIN) { @@ -183,7 +183,7 @@ int _sys_read (FILEHANDLE fh, U8 *buf, U32 len, int mode) /*--------------------------- _sys_istty -------------------------------------*/ -int _sys_istty (FILEHANDLE fh) +int _sys_istty (FILEHANDLE fh) { if (fh > 0x8000) { return (1); @@ -193,7 +193,7 @@ int _sys_istty (FILEHANDLE fh) /*--------------------------- _sys_seek --------------------------------------*/ -int _sys_seek (FILEHANDLE fh, long pos) +int _sys_seek (FILEHANDLE fh, long pos) { if (fh > 0x8000) { return (-1); @@ -207,7 +207,7 @@ int _sys_seek (FILEHANDLE fh, long pos) /*--------------------------- _sys_ensure ------------------------------------*/ -int _sys_ensure (FILEHANDLE fh) +int _sys_ensure (FILEHANDLE fh) { if (fh > 0x8000) { return (-1); @@ -221,7 +221,7 @@ int _sys_ensure (FILEHANDLE fh) /*--------------------------- _sys_flen --------------------------------------*/ -long _sys_flen (FILEHANDLE fh) +long _sys_flen (FILEHANDLE fh) { if (fh > 0x8000) { return (0); @@ -236,21 +236,21 @@ long _sys_flen (FILEHANDLE fh) /*--------------------------- _sys_tmpnam ------------------------------------*/ -int _sys_tmpnam (char *name, int sig, unsigned maxlen) +int _sys_tmpnam (char *name, int sig, unsigned maxlen) { return (1); } /*--------------------------- _sys_command_string ----------------------------*/ -char *_sys_command_string (char *cmd, int len) +char *_sys_command_string (char *cmd, int len) { return (cmd); } /*--------------------------- _sys_exit --------------------------------------*/ -void _sys_exit (int return_code) +void _sys_exit (int return_code) { #ifdef WOLFSSL_MDK_SHELL return ; @@ -258,6 +258,6 @@ void _sys_exit (int return_code) /* Endless loop. */ while (1); #endif - + } diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/cert_data.c b/IDE/MDK-ARM/MDK-ARM/wolfSSL/cert_data.c index 0f57692e2..971744933 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/cert_data.h b/IDE/MDK-ARM/MDK-ARM/wolfSSL/cert_data.h index d06afdd1d..f63a58eb0 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/cert_data.h +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/cert_data.h @@ -8,8 +8,8 @@ extern int sizeof_client_key_der_1024 ; extern const unsigned char client_cert_der_1024[] ; extern int sizeof_client_cert_der_1024 ; /* ./certs/1024/dh1024.der, 1024-bit */ -extern const unsigned char dh_key_der_1024[] ; -extern int sizeof_dh_key_der_1024 ; +extern const unsigned char dh_key_der_1024[] ; +extern int sizeof_dh_key_der_1024 ; /* ./certs/1024/dsa1024.der, 1024-bit */ extern const unsigned char dsa_key_der_1024[] ; extern int sizeof_dsa_key_der_1024 ; 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 04373c97a..8f22bfcc1 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 85e02db34..ddd367b05 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 eb93fa931..1b93a77f1 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 d6fe1aa16..690b96b41 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 84d3bc4ba..13389ed9d 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 1ce952e03..be95989ad 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 f7cb61f0d..e677b7f14 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 f41a94813..7e64f6201 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 7908dfec6..4a585ab35 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 b52c547fd..e4abe982d 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MDK-ARM/STM32F2xx_StdPeriph_Lib/time-STM32F2xx.c b/IDE/MDK-ARM/STM32F2xx_StdPeriph_Lib/time-STM32F2xx.c index 3a30349ca..6ef1fe747 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 089712b85..b07e02a90 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 66623a944..bf8ea3931 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 a9b0bc0ad..9d49e0c1a 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 826a8ade2..6b0628055 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 0e40a7249..43538579a 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 a99244f63..1a9b36ab9 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 686cda6b6..524cf54f5 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 22e6a9b05..25ade0c72 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 db26c5b26..a9df7682c 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 06f39b0e8..a6dbd4239 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 a4ce55fc6..a19d89e0a 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 734b126ce..b58c71c13 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MPLABX16/README.md b/IDE/MPLABX16/README.md index a35b6dec2..440263956 100644 --- a/IDE/MPLABX16/README.md +++ b/IDE/MPLABX16/README.md @@ -38,7 +38,7 @@ steps below to generate that code. 2. Set the Project path to the wolfSSL/IDE/MPLABX16 and enter your PIC device into the interface. -3. Select MCC Clasic as the content type and click `Finish`. +3. Select MCC Classic as the content type and click `Finish`. 4. Under the Device Resources section, find the UART entry and add the UART1 peripheral. diff --git a/IDE/MPLABX16/main.c b/IDE/MPLABX16/main.c index fadad81d5..ea671f31f 100644 --- a/IDE/MPLABX16/main.c +++ b/IDE/MPLABX16/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MPLABX16/user_settings.h b/IDE/MPLABX16/user_settings.h index d4754db89..174551e95 100644 --- a/IDE/MPLABX16/user_settings.h +++ b/IDE/MPLABX16/user_settings.h @@ -51,7 +51,7 @@ extern "C" { #undef FP_MAX_BITS #define FP_MAX_BITS 2048 #else - #define WOLFSSL_SP_MATH + #define WOLFSSL_SP_MATH #define WOLFSSL_SP_SMALL #define WOLFSSL_SP_MATH_ALL #define SP_INT_BITS 256 @@ -162,7 +162,7 @@ extern "C" { /* #undef WOLFSSL_AES_DIRECT #define WOLFSSL_AES_DIRECT */ - + #undef NO_AES_CBC #define NO_AES_CBC #else @@ -301,7 +301,7 @@ extern "C" { #define NO_PKCS8 #define WOLFSSL_NO_PEM - + /* ------------------------------------------------------------------------- */ /* Enable Features */ /* ------------------------------------------------------------------------- */ @@ -397,7 +397,7 @@ extern "C" { #undef NO_PWDBASED #define NO_PWDBASED -#undef NO_MD5 +#undef NO_MD5 #define NO_MD5 #undef NO_DES3 diff --git a/IDE/MPLABX16/wolfcrypt_test.X/Makefile b/IDE/MPLABX16/wolfcrypt_test.X/Makefile index fca8e2ccd..3b52a8ba8 100644 --- a/IDE/MPLABX16/wolfcrypt_test.X/Makefile +++ b/IDE/MPLABX16/wolfcrypt_test.X/Makefile @@ -22,7 +22,7 @@ # clean remove built files from a configuration # clobber remove all built files # all build all configurations -# help print help mesage +# help print help message # # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and # .help-impl are implemented in nbproject/makefile-impl.mk. diff --git a/IDE/MPLABX16/wolfssl.X/Makefile b/IDE/MPLABX16/wolfssl.X/Makefile index fca8e2ccd..3b52a8ba8 100644 --- a/IDE/MPLABX16/wolfssl.X/Makefile +++ b/IDE/MPLABX16/wolfssl.X/Makefile @@ -22,7 +22,7 @@ # clean remove built files from a configuration # clobber remove all built files # all build all configurations -# help print help mesage +# help print help message # # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and # .help-impl are implemented in nbproject/makefile-impl.mk. diff --git a/IDE/MQX/README-jp.md b/IDE/MQX/README-jp.md index 093e98b6b..649e7c65d 100644 --- a/IDE/MQX/README-jp.md +++ b/IDE/MQX/README-jp.md @@ -26,4 +26,3 @@ CC: コンパイラコマンド AR: ARコマンド WOLF_ROOT: Makefileの格納位置を変える場合はこの定義を変更してください - \ No newline at end of file diff --git a/IDE/MQX/client-tls.c b/IDE/MQX/client-tls.c index 70ef3b4ea..5c85aeda5 100644 --- a/IDE/MQX/client-tls.c +++ b/IDE/MQX/client-tls.c @@ -1,6 +1,6 @@ /* client-tls.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MQX/include.am b/IDE/MQX/include.am index 27687d33e..deb5ebc76 100644 --- a/IDE/MQX/include.am +++ b/IDE/MQX/include.am @@ -8,4 +8,4 @@ EXTRA_DIST+= IDE/MQX/README-jp.md EXTRA_DIST+= IDE/MQX/README.md EXTRA_DIST+= IDE/MQX/server-tls.c EXTRA_DIST+= IDE/MQX/user_config.h -EXTRA_DIST+= IDE/MQX/user_settings.h \ No newline at end of file +EXTRA_DIST+= IDE/MQX/user_settings.h diff --git a/IDE/MQX/server-tls.c b/IDE/MQX/server-tls.c index ae2c7ae94..6a39adaa2 100644 --- a/IDE/MQX/server-tls.c +++ b/IDE/MQX/server-tls.c @@ -1,6 +1,6 @@ /* server-tls.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -193,4 +193,4 @@ int main() wolfSSL_Cleanup(); /* Cleanup the wolfSSL environment */ close(sockfd); /* Close the socket listening for clients */ return 0; /* Return reporting a success */ -} \ No newline at end of file +} diff --git a/IDE/MQX/user_config.h b/IDE/MQX/user_config.h index d66e53235..81bbf4e49 100644 --- a/IDE/MQX/user_config.h +++ b/IDE/MQX/user_config.h @@ -1 +1 @@ -#define MQX_CPU PSP_CPU_MK60DN512Z \ No newline at end of file +#define MQX_CPU PSP_CPU_MK60DN512Z diff --git a/IDE/MSVS-2019-AZSPHERE/client/client.c b/IDE/MSVS-2019-AZSPHERE/client/client.c index d758a39fd..53c0789a1 100644 --- a/IDE/MSVS-2019-AZSPHERE/client/client.c +++ b/IDE/MSVS-2019-AZSPHERE/client/client.c @@ -1,6 +1,6 @@ -/* client.c +/* client.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 edef19afc..39cc01140 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 dbf49efed..8e4585194 100644 --- a/IDE/MSVS-2019-AZSPHERE/server/server.c +++ b/IDE/MSVS-2019-AZSPHERE/server/server.c @@ -1,6 +1,6 @@ -/* server.c +/* server.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 e3a53b5e3..7d032217f 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 0cab4bf60..25cbb83f8 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 ea18de895..1c9ffcf4e 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * 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 cb3721ec4..d2240f333 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 +/* template_appliance.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 974d2d8e1..0b7391922 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,4 @@ -/ * Copyright (C) 2006-2024 wolfSSL Inc. +/ * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * 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 ad9cab58b..4254f21f1 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 +/* template_appliance.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/applibs_versions.h b/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/applibs_versions.h index 2afdfcf3e..4078fb7a5 100644 --- a/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/applibs_versions.h +++ b/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/applibs_versions.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once /// /// This identifier should be defined before including any of the networking-related header files. diff --git a/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/main.c b/IDE/MSVS-2019-AZSPHERE/wolfssl_new_azsphere/main.c index acd866826..0889be1c8 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 +/* main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/MYSQL/CMakeLists_wolfCrypt.txt b/IDE/MYSQL/CMakeLists_wolfCrypt.txt index ba6d98116..55c7c40b8 100644 --- a/IDE/MYSQL/CMakeLists_wolfCrypt.txt +++ b/IDE/MYSQL/CMakeLists_wolfCrypt.txt @@ -1,6 +1,6 @@ # CMakeLists.txt # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # diff --git a/IDE/MYSQL/CMakeLists_wolfSSL.txt b/IDE/MYSQL/CMakeLists_wolfSSL.txt index 7bfaa88c9..3599bedb8 100644 --- a/IDE/MYSQL/CMakeLists_wolfSSL.txt +++ b/IDE/MYSQL/CMakeLists_wolfSSL.txt @@ -1,6 +1,6 @@ # CMakeLists.txt # -# Copyright (C) 2006-2024 wolfSSL Inc. +# Copyright (C) 2006-2025 wolfSSL Inc. # # This file is part of wolfSSL. # diff --git a/IDE/NDS/README.md b/IDE/NDS/README.md new file mode 100644 index 000000000..e4cba8149 --- /dev/null +++ b/IDE/NDS/README.md @@ -0,0 +1,116 @@ +# wolfSSL for libnds + +## Requirements + +[Devkitpro](https://devkitpro.org/wiki/Getting_Started) with libnds, nds-tool and nds-dev. + + +## Building + +For MelonDS +``` +$ ./configure \ + --host=arm-none-eabi \ + CC=$DEVKITARM/bin/arm-none-eabi-g++ \ + AR=$DEVKITARM/bin/arm-none-eabi-ar \ + STRIP=$DEVKITARM/bin/arm-none-eabi-strip \ + RANLIB=$DEVKITARM/bin/arm-none-eabi-ranlib \ + LIBS="-lfat -lnds9 -lcalico_ds9" \ + LDFLAGS="-L$DEVKITPRO/libnds/lib \ + -L$DEVKITPRO/calico/lib" \ + --prefix=$DEVKITPRO/portlibs/nds \ + CFLAGS="-march=armv5te -mtune=arm946e-s \ + -specs=$DEVKITPRO/calico/share/ds9.specs \ + -D__NDS__ -DARM9 -D__thumb__=0 \ + -DWOLFSSL_MELONDS \ + -DWOLFSSL_NDS -DWOLFSSL_USER_IO \ + -I$DEVKITPRO/calico/include \ + -I$DEVKITPRO/libnds/include" \ + --enable-fastmath --disable-benchmark \ + --disable-shared --disable-examples --disable-ecc +$ make +$ sudo make install +``` + +For Hardware +``` +$ ./configure \ + --host=arm-none-eabi \ + CC=$DEVKITARM/bin/arm-none-eabi-g++ \ + AR=$DEVKITARM/bin/arm-none-eabi-ar \ + STRIP=$DEVKITARM/bin/arm-none-eabi-strip \ + RANLIB=$DEVKITARM/bin/arm-none-eabi-ranlib \ + LIBS="-lfat -lnds9 -lcalico_ds9" \ + LDFLAGS="-L$DEVKITPRO/libnds/lib \ + -L$DEVKITPRO/calico/lib" \ + --prefix=$DEVKITPRO/portlibs/nds \ + CFLAGS="-march=armv5te -mtune=arm946e-s \ + -specs=$DEVKITPRO/calico/share/ds9.specs \ + -D__NDS__ -DARM9 -D__thumb__=0 \ + -DWOLFSSL_NDS -DWOLFSSL_USER_IO \ + -I$DEVKITPRO/calico/include \ + -I$DEVKITPRO/libnds/include" \ + --enable-fastmath --disable-benchmark \ + --disable-shared --disable-examples --disable-ecc +$ make +$ sudo make install +``` + +## Run the Tests + +To run the Crypttests type the following. +Run `$ ndstool -9 ./wolfcrypt/test/testwolfcrypt -c ./wolfcrypt/test/testwolfcrypt.nds` + +copy `./certs` to `your_nds_sd_card/_nds/certs` (Follow Virtual SD card steps below for Emulator) + +Run the Rom (located in ./wolfcrypt/test/testwolfcrypt.nds) in an Emulator or real Hardware. + +If running on MelonDS it must be using the DSi mode in order to use certs from an SD card. + +## Making a virtual SD card (MacOS) + +``` +Create Virtual SD card image + +$ dd if=/dev/zero of=~/my_sd_card.img bs=1M count=64 + +Format image to FAT32 + +$ hdiutil attach -imagekey diskimage-class=CRawDiskImage -nomount ~/my_sd_card.img +$ diskutil eraseDisk FAT32 MYSDCARD MBRFormat /dev/diskX +$ hdiutil detach /dev/diskX + +Mount to Create Folder Structure and Copy Certs + +$ mkdir -p /Volumes/MYSDCARD/_nds +$ cp -r ~/wolfssl/certs /Volumes/MYSDCARD/_nds/ + +Unmount + +hdiutil detach /dev/diskX +``` + +## Making a virtual SD card (Linux) + +``` +Create Virtual SD card image + +$ dd if=/dev/zero of=~/my_sd_card.img bs=1M count=64 + +Format image to FAT32 + +$ sudo losetup -fP ~/my_sd_card.img +$ sudo losetup -l +$ sudo mkfs.vfat -F 32 /dev/loop0 +$ sudo losetup -d /dev/loop0 + +Mount to Create Folder Structure and Copy Certs + +$ sudo mount ~/my_sd_card.img /mnt +$ sudo mkdir -p /mnt/_nds +$ sudo cp -r ~/wolfssl/certs /mnt/_nds/ + +Unmount + +hdiutil detach /dev/diskX +``` diff --git a/IDE/NETOS/user_settings.h b/IDE/NETOS/user_settings.h index beaae0b20..9348efedb 100644 --- a/IDE/NETOS/user_settings.h +++ b/IDE/NETOS/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/NETOS/wolfssl_netos_custom.c b/IDE/NETOS/wolfssl_netos_custom.c index ac634e7bb..7c66a0faa 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/PlatformIO/examples/wolfssl_benchmark/README.md b/IDE/PlatformIO/examples/wolfssl_benchmark/README.md index c602facfe..6505ecbb5 100644 --- a/IDE/PlatformIO/examples/wolfssl_benchmark/README.md +++ b/IDE/PlatformIO/examples/wolfssl_benchmark/README.md @@ -9,9 +9,9 @@ For general information on [wolfSSL examples for Espressif](../README.md), see t ## Example Output -Note the default wolfSSL `user_settings.h` is configured by default to be the most +Note the default wolfSSL `user_settings.h` is configured by default to be the most compatible across the widest ranges of targets. Contact wolfSSL at support@wolfssl.com -for help in optimizing for your particular application, or see the +for help in optimizing for your particular application, or see the [docs](https://www.wolfssl.com/documentation/manuals/wolfssl/index.html). ``` @@ -59,7 +59,7 @@ I (323) cpu_start: Compile time: May 17 2024 19:42:07 I (329) cpu_start: ELF file SHA256: eebe816ce... I (334) cpu_start: ESP-IDF: 5.2.1 I (339) cpu_start: Min chip rev: v0.0 -I (344) cpu_start: Max chip rev: v3.99 +I (344) cpu_start: Max chip rev: v3.99 I (349) cpu_start: Chip rev: v1.0 I (354) heap_init: Initializing. RAM available for dynamic allocation: I (361) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM @@ -83,7 +83,7 @@ W (449) esp32_util: Warning: old cmake, user_settings.h location unknown. I (457) esp32_util: LIBWOLFSSL_VERSION_STRING = 5.7.0 I (463) esp32_util: LIBWOLFSSL_VERSION_HEX = 5007000 I (468) esp32_util: Stack HWM: 9204 -I (472) esp32_util: +I (472) esp32_util: I (475) esp32_util: Macro Name Defined Not Defined I (482) esp32_util: ------------------------- --------- ------------- I (489) esp32_util: NO_ESPIDF_DEFAULT........ X @@ -115,7 +115,7 @@ I (638) esp32_util: FREERTOS................. X I (643) esp32_util: NO_WOLFSSL_DIR........... X I (649) esp32_util: WOLFSSL_NO_CURRDIR....... X I (654) esp32_util: WOLFSSL_LWIP............. X -I (660) esp32_util: +I (660) esp32_util: I (663) esp32_util: Compiler Optimization: Default I (668) esp32_util: I (671) esp32_util: CONFIG_IDF_TARGET = esp32 diff --git a/IDE/PlatformIO/examples/wolfssl_benchmark/include/main.h b/IDE/PlatformIO/examples/wolfssl_benchmark/include/main.h index 4eff19f85..46a35fd2c 100644 --- a/IDE/PlatformIO/examples/wolfssl_benchmark/include/main.h +++ b/IDE/PlatformIO/examples/wolfssl_benchmark/include/main.h @@ -1,6 +1,6 @@ /* PlatformIO wolfssl_benchmark main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/PlatformIO/examples/wolfssl_benchmark/src/main.c b/IDE/PlatformIO/examples/wolfssl_benchmark/src/main.c index 4a8f6561e..b2db89412 100644 --- a/IDE/PlatformIO/examples/wolfssl_benchmark/src/main.c +++ b/IDE/PlatformIO/examples/wolfssl_benchmark/src/main.c @@ -1,6 +1,6 @@ /* PlatformIO wolfssl_benchmark main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/PlatformIO/examples/wolfssl_test/README.md b/IDE/PlatformIO/examples/wolfssl_test/README.md index d67d76111..86058cd57 100644 --- a/IDE/PlatformIO/examples/wolfssl_test/README.md +++ b/IDE/PlatformIO/examples/wolfssl_test/README.md @@ -10,9 +10,9 @@ For general information on [wolfSSL examples for Espressif](../README.md), see t ## Example Output -Note the default wolfSSL `user_settings.h` is configured by default to be the most +Note the default wolfSSL `user_settings.h` is configured by default to be the most compatible across the widest ranges of targets. Contact wolfSSL at support@wolfssl.com -for help in optimizing for your particular application, or see the +for help in optimizing for your particular application, or see the [docs](https://www.wolfssl.com/documentation/manuals/wolfssl/index.html). @@ -61,7 +61,7 @@ I (511) cpu_start: Compile time: May 17 2024 19:31:47 I (517) cpu_start: ELF file SHA256: 40b2541a0... I (523) cpu_start: ESP-IDF: 5.2.1 I (528) cpu_start: Min chip rev: v0.0 -I (532) cpu_start: Max chip rev: v3.99 +I (532) cpu_start: Max chip rev: v3.99 I (537) cpu_start: Chip rev: v1.0 I (542) heap_init: Initializing. RAM available for dynamic allocation: I (549) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM diff --git a/IDE/PlatformIO/examples/wolfssl_test/include/main.h b/IDE/PlatformIO/examples/wolfssl_test/include/main.h index 182fc1fbb..52135d45e 100644 --- a/IDE/PlatformIO/examples/wolfssl_test/include/main.h +++ b/IDE/PlatformIO/examples/wolfssl_test/include/main.h @@ -1,6 +1,6 @@ /* PlatformIO wolfssl_test main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/PlatformIO/examples/wolfssl_test/src/main.c b/IDE/PlatformIO/examples/wolfssl_test/src/main.c index 41bdc7278..fbe92ba99 100644 --- a/IDE/PlatformIO/examples/wolfssl_test/src/main.c +++ b/IDE/PlatformIO/examples/wolfssl_test/src/main.c @@ -1,6 +1,6 @@ /* PlatformIO wolfssl_test main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/QNX/README.md b/IDE/QNX/README.md index fb79abf6b..4a283f158 100644 --- a/IDE/QNX/README.md +++ b/IDE/QNX/README.md @@ -17,7 +17,7 @@ source ~/qnx700/qnxsdp-env.sh make ``` -Once the wolfSSL library has been built cd to IDE/QNX/CAAM-DRIVER and run "make". This will produce the wolfCrypt resource manager. It should be started on the device with root permissions. Once wolfCrypt is running on the device with root permissions then any user with access to open a connection to /dev/wolfCrypt can make use of the driver. +Once the wolfSSL library has been built cd to IDE/QNX/CAAM-DRIVER and run "make". This will produce the wolfCrypt resource manager. It should be started on the device with root permissions. Once wolfCrypt is running on the device with root permissions then any user with access to open a connection to /dev/wolfCrypt can make use of the driver. ### Momentics To build in momentics IDE: diff --git a/IDE/QNX/example-client/client-tls.c b/IDE/QNX/example-client/client-tls.c index 9c9b6e4b0..a6527a8fa 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 64d5ccacd..eb7e4149e 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -41,13 +41,13 @@ static int createTag(const byte* key, int keySz, byte* msg, int msgSz, byte* msg2, int msg2Sz) { Cmac cmac; - byte tag[AES_BLOCK_SIZE]; + byte tag[WC_AES_BLOCK_SIZE]; word32 i, tagSz; byte out[48]; word32 outSz; XMEMSET(tag, 0, sizeof(tag)); - tagSz = AES_BLOCK_SIZE; + tagSz = WC_AES_BLOCK_SIZE; outSz = 48; wc_caamCoverKey((byte*)key, keySz, out, &outSz, 0); diff --git a/IDE/QNX/example-server/server-tls.c b/IDE/QNX/example-server/server-tls.c index 1257e3b33..203a3dd5d 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/RISCV/SIFIVE-HIFIVE1/README.md b/IDE/RISCV/SIFIVE-HIFIVE1/README.md index 5e1183dea..5b3f3ed89 100644 --- a/IDE/RISCV/SIFIVE-HIFIVE1/README.md +++ b/IDE/RISCV/SIFIVE-HIFIVE1/README.md @@ -44,7 +44,7 @@ The `IDE/RISCV/SIFIVE-HIFIVE1/main.c` example application provides a function to $ export WOLFSSL_SRC_DIR=~/wolfssl ``` -5. Setup your riscv64 compiler +5. Setup your riscv64 compiler ``` $ export RISCV_OPENOCD_PATH=/opt/riscv-openocd @@ -64,7 +64,7 @@ You can build from source or create a static library. $ cd freedom-e-sdk $ make PROGRAM=wolfcrypt TARGET=sifive-hifive1-revb CONFIGURATION=debug clean software upload ``` -This example cleans, builds and uploads the software on the sifive-hifive1-revb target but you can also combine and build for any of the supported targets. +This example cleans, builds and uploads the software on the sifive-hifive1-revb target but you can also combine and build for any of the supported targets. Review the test results on the target console. diff --git a/IDE/RISCV/SIFIVE-HIFIVE1/main.c b/IDE/RISCV/SIFIVE-HIFIVE1/main.c index 3431232af..d9abefdc4 100644 --- a/IDE/RISCV/SIFIVE-HIFIVE1/main.c +++ b/IDE/RISCV/SIFIVE-HIFIVE1/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -35,7 +35,7 @@ #ifndef NO_CRYPT_BENCHMARK -/*-specs=nano.specs doesn’t include support for floating point in printf()*/ +/*-specs=nano.specs doesn't include support for floating point in printf()*/ asm (".global _printf_float"); #ifndef RTC_FREQ diff --git a/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h b/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h index 75d5f54d2..9c17a34e2 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/RISCV/SIFIVE-UNLEASHED/README.md b/IDE/RISCV/SIFIVE-UNLEASHED/README.md index 64f88ae81..c2e1c1ba6 100644 --- a/IDE/RISCV/SIFIVE-UNLEASHED/README.md +++ b/IDE/RISCV/SIFIVE-UNLEASHED/README.md @@ -6,7 +6,7 @@ Instructions for cross-compiling and running wolfSSL on the HiFive Unleashed boa SiFive Freedom U540 SoC at 1.5GHz -Getting started guide: +Getting started guide: https://sifive.cdn.prismic.io/sifive%2Ffa3a584a-a02f-4fda-b758-a2def05f49f9_hifive-unleashed-getting-started-guide-v1p1.pdf Make sure your ethernet is attached and power up board. You can connecct the micro-usb to get a UART console that will display the DHCP IP address. Default user is "root" and login password is "sifive". diff --git a/IDE/ROWLEY-CROSSWORKS-ARM/README.md b/IDE/ROWLEY-CROSSWORKS-ARM/README.md index beb941645..fc305b631 100644 --- a/IDE/ROWLEY-CROSSWORKS-ARM/README.md +++ b/IDE/ROWLEY-CROSSWORKS-ARM/README.md @@ -4,11 +4,11 @@ This directory contains a CrossWorks solution named wolfssl.hzp. Inside are three projects: -1. libwolfssl: +1. libwolfssl: This generates a library file named "libwolfssl_ARM_Debug/libwolfssl_v7em_t_le_eabi.a" -2. benchmark: +2. benchmark: This is a sample benchmark application. It runs the "benchmark_test" suite repeatedly until a failure occurs. -3. test: +3. test: This is a sample test application. It runs "wolfcrypt_test" suite suite repeatedly until a failure occurs. # Prerequisites @@ -21,7 +21,7 @@ All hardware functions are defined in `kinetis_hw.c` and are currently setup for To create support for a new ARM microcontroller the functions in `hw.h` will need to be implemented. -Also you will need to configure the ARM Architecture and ARM Core Type in the "Solution Properties" -> "ARM". +Also you will need to configure the ARM Architecture and ARM Core Type in the "Solution Properties" -> "ARM". Also the "Target Processor" in each of the projects ("Project Properties" -> "Target Processor") ## Hardware Crypto Acceleration diff --git a/IDE/ROWLEY-CROSSWORKS-ARM/arm_startup.c b/IDE/ROWLEY-CROSSWORKS-ARM/arm_startup.c index 085fa4109..c8ac4d21b 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 94f55bfb5..333e73df6 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 ffe76bf1b..27c9e0abb 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 752ec6e66..e4f04784d 100644 --- a/IDE/ROWLEY-CROSSWORKS-ARM/retarget.c +++ b/IDE/ROWLEY-CROSSWORKS-ARM/retarget.c @@ -1,6 +1,6 @@ /* retarget.c * - * Copyright (C) 2006-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 062c0982b..1a3d117e4 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/cs+/Projects/README b/IDE/Renesas/cs+/Projects/README index 38c8bc285..6f382d039 100644 --- a/IDE/Renesas/cs+/Projects/README +++ b/IDE/Renesas/cs+/Projects/README @@ -13,3 +13,6 @@ test: - set stack size in "bsp/stacksct.h" Build "test" wolfCrypt + +Note: It could need to initialize clock for the device. You can refer the link below +https://www.renesas.com/ja/document/apn/rx65n-group-rx651-group-initial-settings-example-rev211?language=en&r=1054461 diff --git a/IDE/Renesas/cs+/Projects/common/strings.h b/IDE/Renesas/cs+/Projects/common/strings.h index a66c8bbbf..7cbc78770 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 12f937494..ec6e32ec9 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 b03faa768..02f0e6348 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -25,11 +25,11 @@ #define NO_DEV_RANDOM #define USE_CERT_BUFFERS_2048 #define SIZEOF_LONG_LONG 8 -#define NO_WOLFSSL_DIR +#define NO_WOLFSSL_DIR #define WOLFSSL_NO_CURRDIR #define WOLFSSL_LOG_PRINTF #define NO_WOLFSSL_STUB -#define NO_DYNAMIC_ARRAY /* for compilers not allowed dynamic size array */ +#define NO_DYNAMIC_ARRAY /* for compilers not allowed dynamic size array */ #define WOLFSSL_SMALL_STACK #define WOLFSSL_DH_CONST @@ -76,4 +76,5 @@ #define NO_FILESYSTEM +#define XSTRCASECMP(s1,s2) strcmp((s1),(s2)) diff --git a/IDE/Renesas/cs+/Projects/common/wolfssl_dummy.c b/IDE/Renesas/cs+/Projects/common/wolfssl_dummy.c index 3c425b357..1f367b4e0 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -51,12 +51,17 @@ int strncasecmp(const char *s1, const char * s2, unsigned int sz) return 1; } } - return 0; + return 0; } - -void abort(void) + +void abort(void) { while(1); } +/* dummy return true when char is alphanumeric character */ +int isascii(const char *s) +{ + return isalnum(s); +} diff --git a/IDE/Renesas/cs+/Projects/t4_demo/README_jp.txt b/IDE/Renesas/cs+/Projects/t4_demo/README_jp.txt index d03d44371..deeec5c61 100644 --- a/IDE/Renesas/cs+/Projects/t4_demo/README_jp.txt +++ b/IDE/Renesas/cs+/Projects/t4_demo/README_jp.txt @@ -1,71 +1,71 @@ -wolfSSL/AlphaProject{[hf@ZbgAbvKCh +wolfSSL/AlphaProjectボードデモ セットアップガイド -̃f͈ȉ̊‹ŃeXgĂ܂B +このデモは以下の環境でテストしています。 Renesas : CS+ v6.01, v8.01 Board : AP-RX71M-0A wolfSSL : 3.15.3, 4.0.0 -ZbgAbv菇F +セットアップ手順: -PD\tgEFA̓ -@- AP{[ht̃\tgEFAꎮKȃtH_[ɉ𓀂܂B -@- tH_[wolfsslꎮ𓀂܂B +1.ソフトウェアの入手 + - APボード付属のソフトウェア一式を適当なフォルダー下に解凍します。 + - 同じフォルダー下にwolfssl一式を解凍します。 -QDwolfSSL̃ZbgAbv -@- CS+ɂwolfssl\IDE\Renesas\cs+\Projectwolfssl\wolfssl_lib.mtpjJ -@@wolfSSLCu[̃rh܂B -@- tH_̉t4_demo.mtpjJAfvÕrh܂B -@̃vOCu[`Ńrh܂B +2.wolfSSLのセットアップ + - CS+にてwolfssl¥IDE¥Renesas¥cs+¥Project下のwolfssl¥wolfssl_lib.mtpjを開き +  wolfSSLライブラリーのビルドをします。 + - 同じフォルダの下のt4_demo.mtpjを開き、デモプログラムのビルドをします。 + このプログラムもライブラリー形式でビルドされます。 -RDAlphaProject̃ZbgAbv +3.AlphaProject側のセットアップ - !!** TvvO v2.0 gpꍇ́A_ether_ => _usbfunc_ **!! - !!** ƒuĂ **!! + !!** サンプルプログラム v2.0 を使用する場合は、_ether_ => _usbfunc_ **!! + !!** と置き換えてください **!! -@fap_rx71m_0a_sample_cs\Sample\ap_rx71m_0a_ether_sample_cstH_ -@ap_rx71m_0a_ether_sample_cs.mtpjvWFNg𗘗p܂B -@ -@- ap_rx71m_0a_sample_cs\Sample\ap_rx71m_0a_ether_sample_cs\srctH_ -@AP_RX71M_0A.ct@CJA -@XVsڂecho_srv_init()̉wolfSSL_init()}܂B + デモはap_rx71m_0a_sample_cs¥Sample¥ap_rx71m_0a_ether_sample_csフォルダ下の + ap_rx71m_0a_ether_sample_cs.mtpjプロジェクトを利用します。 +  + - ap_rx71m_0a_sample_cs¥Sample¥ap_rx71m_0a_ether_sample_cs¥srcフォルダ下の + AP_RX71M_0A.cファイルを開き、 + 97行目のecho_srv_init()の下にwolfSSL_init()を挿入します。 === sci_init(); can_init(); echo_srv_init(); - wolfSSL_init(); <- ̍s} + wolfSSL_init(); <- この行を挿入 === -!!** TvvO v2.0 gpꍇ́AL **!! +!!** サンプルプログラム v2.0 を使用する場合は、下記 **!! === CanInit(); SciInit(); EthernetAppInit(); UsbfInit(); - wolfSSL_init(); <- ̍s} + wolfSSL_init(); <- この行を挿入 === !!**********************************************************************!! -@- ap_rx71m_0a_sample_cs\Sample\ap_rx71m_0a_ether_sample_cs\src\smc_gen\r_bsp_config.h -@JAX^bNTCYƃq[vTCYȉ̂悤ɐݒ肵܂B -@ -@120s #pragma stacksize su=0x2000 -@139s #define BSP_CFG_HEAP_BYTES (0xa000) + - ap_rx71m_0a_sample_cs¥Sample¥ap_rx71m_0a_ether_sample_cs¥src¥smc_gen¥r_bsp_config.h + を開き、スタックサイズとヒープサイズを以下のように設定します。 +  + 120行目 #pragma stacksize su=0x2000 + 139行目 #define BSP_CFG_HEAP_BYTES (0xa000) -!!** TvvO v2.0 gpꍇ́AL **!! -@- ap_rx71m_0a_sample_cs\Sample\ap_rx71m_0a_usbfunc_sample_cs\src\smc_gen\r_bsp_config.h -@JAX^bNTCYƃq[vTCYȉ̂悤ɐݒ肵܂B -@154s #pragma stacksize su=0x2000 -@175s #define BSP_CFG_HEAP_BYTES (0xa000) +!!** サンプルプログラム v2.0 を使用する場合は、下記 **!! + - ap_rx71m_0a_sample_cs¥Sample¥ap_rx71m_0a_usbfunc_sample_cs¥src¥smc_gen¥r_bsp_config.h + を開き、スタックサイズとヒープサイズを以下のように設定します。 + 154行目 #pragma stacksize su=0x2000 + 175行目 #define BSP_CFG_HEAP_BYTES (0xa000) !!**********************************************************************!! -@- IPAhX̃ftHgl͈ȉ̂悤ɂȂĂ܂B -@Kv΁ASample\ap_rx71m_0a_ether_sample_cs\src\r_t4_rx\src\config_tcpudp.c -@139sڂ̒`ύX܂B -@!!** TvvO v2.0 gpꍇ́AL **!! - Sample\ap_rx71m_0a_usbfunc_sample_cs\src\tcp_sample\src\config_tcpudp.c - 166sڂ̒`ύX܂B + - IPアドレスのデフォルト値は以下のようになっています。 + 必要があれば、Sample¥ap_rx71m_0a_ether_sample_cs¥src¥r_t4_rx¥src¥config_tcpudp.c + 内の139行目からの定義を変更します。 + !!** サンプルプログラム v2.0 を使用する場合は、下記 **!! + Sample¥ap_rx71m_0a_usbfunc_sample_cs¥src¥tcp_sample¥src¥config_tcpudp.c + 内の166行目からの定義を変更します。 !!**********************************************************************!! === @@ -75,74 +75,74 @@ wolfSSL/AlphaProject === -@- CS+ap_rx71m_0a_ether_sample_cs.mtpjvWFNgJAwolfSSLƃfCu -@o^܂BCC-RX(rhc[)->NEIvV^u->gp郉Cu -@ȉ̓‚̃t@Co^܂B -@wolfssl\IDE\Renesas\cs+\Projects\wolfssl_lib\DefaultBuild\wolfssl_lib.lib -@wolfssl\IDE\Renesas\cs+\Projects\t4_demo\DefaultBuild\t4_demo.lib + - CS+でap_rx71m_0a_ether_sample_cs.mtpjプロジェクトを開き、wolfSSLとデモライブラリを + 登録します。CC-RX(ビルドツール)->リンク・オプションタブ->使用するライブラリに + 以下の二つのファイルを登録します。 + wolfssl¥IDE¥Renesas¥cs+¥Projects¥wolfssl_lib¥DefaultBuild¥wolfssl_lib.lib + wolfssl¥IDE¥Renesas¥cs+¥Projects¥t4_demo¥DefaultBuild¥t4_demo.lib -- CC-RX(rhc[)->Cu[WFl[V^u->Cu[\uC99vɁA -ctype.hLɂu͂vɐݒ肵܂B +- CC-RX(ビルドツール)->ライブラリージェネレーションタブ->ライブラリー構成を「C99」に、 +ctype.hを有効にするを「はい」に設定します。 -@- vWFNg̃rhA^[Qbgւ̃_E[ĥA\->fobOER\[ -@R\[\܂BsJnƃR\[Ɉȉ̕\o͂܂B -@ + - プロジェクトのビルド、ターゲットへのダウンロードをしたのち、表示->デバッグ・コンソール + からコンソールを表示させます。実行を開始するとコンソールに以下の表示が出力されます。 +  === -@wolfSSL Demo + wolfSSL Demo t: test, b: benchmark, s: server, or c : client $ === -tR}hFeÍASY̊ȒPȃeXgs܂BṽASY -@gݍ܂Ă邩mF邱Ƃł܂BgݍރASY̓rhIvV -@ŕύX邱Ƃł܂Bڂ̓[U}jAQƂĂB -bR}hFeÍASYƂ̊ȒPȃx`}[Ns܂B -sR}hFȒPTLST[oN܂BNƃrhIPAhXA -@|[g50000ɂTLSڑ҂܂B -cR}hFȒPTLSNCAgN܂BNƑA[MgŎw肳ꂽ -@IPAhXAA[MgŎw肳ꂽ|[gɑ΂TLSڑ܂B +tコマンド:各暗号化アルゴリズムの簡単なテストを実行します。所要のアルゴリズムが + 組み込まれているか確認することができます。組み込むアルゴリズムはビルドオプション + で変更することができます。詳しくはユーザマニュアルを参照してください。 +bコマンド:各暗号アルゴリズムごとの簡単なベンチマークを実行します。 +sコマンド:簡単なTLSサーバを起動します。起動するとビルド時のIPアドレス、 + ポート50000にてTLS接続を待ちます。 +cコマンド:簡単なTLSクライアントを起動します。起動すると第一アーギュメントで指定された + IPアドレス、第二アーギュメントで指定されたポートに対してTLS接続します。 -̃R}hP̂ݎs܂BJԂsꍇ́AMPUZbg -ċN܂B +いずれのコマンドも1回のみ実行します。繰り返し実行したい場合は、MPUをリセットして +再起動します。 -SDΌeXg -@f̂AR}hgāA̋@ƊȒPȑΌeXg邱Ƃł܂B -@UbuntuȂǂGCC, make‹AWindowsVisual StudioȂǂ -@ΌeXgp̃T[oANCAgrh邱Ƃł܂B +4.対向テスト + デモのs、cコマンドを使って、他の機器と簡単な対向テストをすることができます。 + UbuntuなどのGCC, make環境、WindowsのVisual Studioなどで + 対向テスト用のサーバ、クライアントをビルドすることができます。 -@GCC,makeR}h‹ł́A_E[h𓀂wolfssl̃fBNgňȉ -@R}h𔭍sƁACuAeXgp̃NCAgAT[oȂLjꎮrh -@܂B -@ -@$ ./configure -@$ make check -@ -@̌Aȉ̂悤ȎwŃNCAg܂̓T[oNāA{[h -@fƑΌeXg邱Ƃł܂B -@ -@PCF -@$ ./examples/server/server -b -d -@{[hF -@@> c 11111 + GCC,makeコマンド環境では、ダウンロード解凍したwolfsslのディレクトリ下で以下の + コマンドを発行すると、ライブラリ、テスト用のクライアント、サーバなど一式がビルド + されます。 +  + $ ./configure + $ make check +  + その後、以下のような指定でクライアントまたはサーバを起動して、ボード上の + デモと対向テストすることができます。 +  + PC側: + $ ./examples/server/server -b -d + ボード側: +  > c 11111 -@{[hF -@@> s -@PCF@ -@$ ./examples/client/client -h -p 50000 -@ -@ -@WindowsVisual Studioł́A_E[h𓀂wolfssltH_wolfssl64.sln -@JA\[Vrh܂BDebugtH_Ƀrhclient.exe -@server.exe𗘗p܂B -@ - PCF -@Debug> .\server -b -d -@{[hF -@@> c 11111 + ボード側: +  > s + PC側:  + $ ./examples/client/client -h -p 50000 +  +  + WindowsのVisual Studioでは、ダウンロード解凍したwolfsslフォルダ下のwolfssl64.sln + を開き、ソリューションをビルドします。Debugフォルダ下にビルドされるclient.exeと + server.exeを利用します。 +  + PC側: + Debug> .¥server -b -d + ボード側: +  > c 11111 -@{[hF -@@> s -@PCF -@Debug> .\client -h -p 50000 + ボード側: +  > s + PC側: + Debug> .¥client -h -p 50000 -ȏA \ No newline at end of file +以上、 \ No newline at end of file diff --git a/IDE/Renesas/cs+/Projects/t4_demo/wolf_client.c b/IDE/Renesas/cs+/Projects/t4_demo/wolf_client.c index e25b038c9..ea2b7b311 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 cd7f74b85..3c8ced1e5 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -40,7 +40,7 @@ static void timeTick(void *pdata) double current_time(int reset) { if(reset) tick = 0 ; - return ((double)tick/FREQ) ; + return ((double)tick/FREQ) ; } #define ARG_SZ 256 @@ -50,10 +50,10 @@ static int get_arg(func_args *args) int i; char *arg = argBuff; args->argc = 0; - + for(i=0; i : client\n$ "); c = getchar(); - + switch(c) { case 't': get_arg(&args); @@ -95,14 +95,14 @@ void wolfSSL_main() wolfcrypt_test(&args); printf("End wolfCrypt Test\n"); break; - + case 'b': get_arg(&args); printf("Start wolfCrypt Benchmark\n"); benchmark_test(NULL); printf("End wolfCrypt Benchmark\n"); break; - + case 'c': if(get_arg(&args) < 0) break; @@ -110,7 +110,7 @@ void wolfSSL_main() wolfSSL_TLS_client(wolfSSL_cl_ctx, &args); printf("End TLS Client\n"); break; - + case 's': if(get_arg(&args) < 0) break; diff --git a/IDE/Renesas/cs+/Projects/t4_demo/wolf_server.c b/IDE/Renesas/cs+/Projects/t4_demo/wolf_server.c index 858347170..d4b4d63a1 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 dcb490acd..30dfd4723 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -45,7 +45,7 @@ void wolfcrypt_test(func_args args); void main(void) { func_args args = { 1 }; - + printf("Start wolfCrypt Test\n"); wolfcrypt_test(args); printf("End wolfCrypt Test\n"); 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 353f906dc..1c21ae2c8 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 c52f8aaf3..ee8b55a68 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/DK-S7G2/user_settings.h b/IDE/Renesas/e2studio/DK-S7G2/user_settings.h index 146f7020b..82f9e5e9a 100644 --- a/IDE/Renesas/e2studio/DK-S7G2/user_settings.h +++ b/IDE/Renesas/e2studio/DK-S7G2/user_settings.h @@ -74,4 +74,7 @@ #define HAVE_ED25519 #define WOLFSSL_SHA512 +/* NETX Duo BSD manual lists the socket len type as an INT */ +#undef XSOCKLENT +#define XSOCKLENT int #endif 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 9edf7ff84..ae4c09ff4 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 a66c8bbbf..7cbc78770 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 12f937494..ec6e32ec9 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 15ebd73b3..22cf28900 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -27,7 +27,7 @@ #define USE_CERT_BUFFERS_2048 #define WOLFSSL_USER_CURRTIME #define SIZEOF_LONG_LONG 8 -#define NO_WOLFSSL_DIR +#define NO_WOLFSSL_DIR #define WOLFSSL_NO_CURRDIR #define NO_FILESYSTEM #define WOLFSSL_LOG_PRINTF diff --git a/IDE/Renesas/e2studio/Projects/common/wolfssl_dummy.c b/IDE/Renesas/e2studio/Projects/common/wolfssl_dummy.c index bf2006d49..76ead18ba 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 d3e7a0416..29ae72b0d 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 c9be7039d..b2f649ddc 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 3e5916027..a8cfc949b 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 7ebbe2923..24a14bdc4 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 206e91d77..a0c5ece8f 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -124,7 +124,7 @@ void wolfSSL_TLS_server_init(byte doClientCheck) #if !defined(NO_FILESYSTEM) ret = wolfSSL_CTX_use_PrivateKey_file(server_ctx, key, 0); #else - ret = wolfSSL_CTX_use_PrivateKey_buffer(server_ctx, key, sizeof_key, + ret = wolfSSL_CTX_use_PrivateKey_buffer(server_ctx, key, sizeof_key, SSL_FILETYPE_ASN1); #endif if (ret != SSL_SUCCESS) { @@ -138,20 +138,20 @@ void wolfSSL_TLS_server_init(byte doClientCheck) wolfSSL_CTX_set_verify(server_ctx, WOLFSSL_VERIFY_PEER | WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0); #if !defined(NO_FILESYSTEM) - if (wolfSSL_CTX_load_verify_locations(server_ctx, clientCert, 0) + if (wolfSSL_CTX_load_verify_locations(server_ctx, clientCert, 0) != WOLFSSL_SUCCESS) #else - if (wolfSSL_CTX_load_verify_buffer(server_ctx, clientCert, + if (wolfSSL_CTX_load_verify_buffer(server_ctx, clientCert, sizeof_clicert, SSL_FILETYPE_ASN1) != SSL_SUCCESS) #endif printf("can't load ca file, Please run from wolfSSL home dir\n"); } - + /* Register callbacks */ wolfSSL_SetIORecv(server_ctx, my_IORecv); wolfSSL_SetIOSend(server_ctx, my_IOSend); - + } void wolfSSL_TLS_server( ) diff --git a/IDE/Renesas/e2studio/Projects/test/src/wolfssl_demo.h b/IDE/Renesas/e2studio/Projects/test/src/wolfssl_demo.h index 2168ad0a0..30ae8f774 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/Projects/tools/generate_rsa_keypair.sh b/IDE/Renesas/e2studio/Projects/tools/generate_rsa_keypair.sh index ac9def4cc..c5256060d 100755 --- a/IDE/Renesas/e2studio/Projects/tools/generate_rsa_keypair.sh +++ b/IDE/Renesas/e2studio/Projects/tools/generate_rsa_keypair.sh @@ -7,7 +7,7 @@ function usage(){ Description: Generate 2048 bit Rsa key pair and Display modulus and public exponent - + Options: -g generate rsa key pair, default on -s only show modulus and public exponent @@ -39,7 +39,7 @@ FLAG_S="off" if [ $FLAG_G = "on" ]; then # generate 2048bit Rsa private key - openssl genrsa 2048 2> /dev/null > private-key.pem + openssl genrsa 2048 2> /dev/null > private-key.pem # expose public key openssl rsa -in private-key.pem -pubout -out public-key.pem 2> /dev/null fi diff --git a/IDE/Renesas/e2studio/RA6M3/README.md b/IDE/Renesas/e2studio/RA6M3/README.md index a1cc8b9e6..285d89799 100644 --- a/IDE/Renesas/e2studio/RA6M3/README.md +++ b/IDE/Renesas/e2studio/RA6M3/README.md @@ -67,7 +67,7 @@ The following steps explain how to generate the missing files and where to place |Thread Symbol|wolfssl_tst_thread| |Thread Name|wolf_tst_thread| |Thread Stack size|increase depending on your environment
e.g. 0xA000| -|Thread MemoryAllocation|Dyamic| +|Thread MemoryAllocation|Dynamic| |Common General Use Mutexes|Enabled| |Common General Enable Backward Compatibility|Enabled| |Common Memory Allocation Support Dynamic Allocation|Enabled| diff --git a/IDE/Renesas/e2studio/RA6M3/README_APRA6M_en.md b/IDE/Renesas/e2studio/RA6M3/README_APRA6M_en.md index 0a68c6565..43bf3b91d 100644 --- a/IDE/Renesas/e2studio/RA6M3/README_APRA6M_en.md +++ b/IDE/Renesas/e2studio/RA6M3/README_APRA6M_en.md @@ -84,9 +84,9 @@ The following steps explain how to generate the missing files and where to place (Click the drop-down arrow to the left of the project name.) + Select and Copy the following folders/files inside dummy_library - `ra/` - `ra_gen/` - `ra_cfg/` + `ra/` + `ra_gen/` + `ra_cfg/` `script/` + Paste the copied folders/files into wolfSSL_RA6M3G @@ -108,7 +108,7 @@ The following steps explain how to generate the missing files and where to place + Select and Copy the following folder inside dummy_app - `src/` + `src/` `script/` + Paste the copied folders into `./IDE/Renesas/e2studio/RA6M3/common/ra6m3g/` @@ -132,17 +132,17 @@ Right-Click each Project and select Build. ### Run wolfCrypt Test and Benchmark -1.) Right-Click the Project name. -2.) Select `Debug As` -> `Renesas GDB Hardware Debugging` -3.) Select J-Link ARM. Click OK. +1.) Right-Click the Project name. +2.) Select `Debug As` -> `Renesas GDB Hardware Debugging` +3.) Select J-Link ARM. Click OK. 4.) Select R7Fa6M3AH. Click OK. ### Run the wolfSSL TLS Server Example. -1.) Right-Click the Project name. -2.) Select `Debug As` -> `Renesas GDB Hardware Debugging` -3.) Select J-Link ARM. Click OK. -4.) Select R7Fa6M3AH. Click OK. +1.) Right-Click the Project name. +2.) Select `Debug As` -> `Renesas GDB Hardware Debugging` +3.) Select J-Link ARM. Click OK. +4.) Select R7Fa6M3AH. Click OK. 5.) Run the following wolfSSL example client command inside the base of the wolfssl directory. ``` diff --git a/IDE/Renesas/e2studio/RA6M3/README_APRA6M_jp.md b/IDE/Renesas/e2studio/RA6M3/README_APRA6M_jp.md index d3dc23a96..93a543711 100644 --- a/IDE/Renesas/e2studio/RA6M3/README_APRA6M_jp.md +++ b/IDE/Renesas/e2studio/RA6M3/README_APRA6M_jp.md @@ -83,9 +83,9 @@ wolfSSL のプロジェクトファイルは、wolfSSL と wolfCrypt の両方 プロジェクト名横にある矢印マークをクリック + `dummy_library` の以下のフォルダーとファイルを選択 - `ra/` - `ra_gen/` - `ra_cfg/` + `ra/` + `ra_gen/` + `ra_cfg/` `script/` + 選択したフォルダーとファイルを `wolfSSL_RA6M3G`プロジェクトに貼り付け @@ -110,7 +110,7 @@ wolfSSL のプロジェクトファイルは、wolfSSL と wolfCrypt の両方 + `dummy_app`の以下のフォルダーをコピー - `src/` + `src/` `script/` + 選択したフォルダーを`./IDE/Renesas/e2studio/RA6M3/common/ra6m3g/`へコピー 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 cf7f27061..6451ed757 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 5ba72ce49..0fe5a10fd 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 d1f7e0f8c..6552c712d 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 faf154dc1..5ec3aae1d 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 f0d66117f..6adee0053 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -50,7 +50,6 @@ #define HAVE_CHACHA #define HAVE_POLY1305 #define HAVE_ECC -#define HAVE_RSA #define HAVE_SHA256 #define HAVE_SUPPORTED_CURVES #define HAVE_TLS_EXTENSIONS diff --git a/IDE/Renesas/e2studio/RA6M3/common/util.h b/IDE/Renesas/e2studio/RA6M3/common/util.h index 57eaf767b..cc69a8dc4 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 47808cb42..0d8f60830 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 7720180f1..2645a25ef 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 454f5744a..860ed4e03 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M4/README.md b/IDE/Renesas/e2studio/RA6M4/README.md index 4ce63ab33..5afae2984 100644 --- a/IDE/Renesas/e2studio/RA6M4/README.md +++ b/IDE/Renesas/e2studio/RA6M4/README.md @@ -4,13 +4,13 @@ wolfSSL for Renesas RA Evaluation Kit (EK-RA6M4) ## Description This directory contains e2studio projects targeted at the Renesas RA 32-bit MCUs. -The example projects include a wolfSSL TLS client. +The example projects include a wolfSSL TLS client. They also include benchmark and cryptography tests for the wolfCrypt library. The wolfssl project contains both the wolfSSL and wolfCrypt libraries. It is built as a `Renesas RA C Library Project` and contains the Renesas RA -configuration. The wolfssl project uses `Secure Cryptography Engine on RA6 Protected Mode` +configuration. The wolfssl project uses `Secure Cryptography Engine on RA6 Protected Mode` as hardware acceleration for cypto and TLS operation. @@ -24,27 +24,29 @@ The wolfssl Project Summary is listed below and is relevant for every project. |Board|EK-RA6M4| |Device|R7FA6M4AF3CFB| |Toolchain|GCC ARM Embedded| -|FSP Version|3.5.0| +|FSP Version|5.4.0| #### Selected software components |Components|Version| |:--|:--| -|Board Support Package Common Files|v3.6.0| -|Secure Cryptography Engine on RA6 Protected Mode|v3.6.0| -|I/O Port|v3.6.0| -|Arm CMSIS Version 5 - Core (M)|v5.8.0+fsp.3.6.0| -|RA6M4-EK Board Support Files|v3.5.0| -|Board support package for R7FA6M4AF3CFB|v3.6.0| -|Board support package for RA6M4|v3.6.0| -|Board support package for RA6M4 - FSP Data|v3.6.0| -|FreeRTOS|v10.4.3-LTS.Patch.2+fsp.3.6.0| -|FreeRTOS - Memory Management - Heap 4|v10.4.3-LTS.Patch.2+fsp.3.6.0| -|r_ether to FreeRTOS+TCP Wrapper|v3.6.0| -|Ethernet|v3.6.0| -|Ethernet PHY|v3.6.0| -|FreeRTOS+TCP|v2.3.2-LTS.Patch.1+fsp.3.6.0| -|FreeRTOS - Buffer Allocation 2|v2.3.2-LTS.Patch.1+fsp.3.6.0| +|Board Support Package Common Files|v5.4.0| +|Secure Cryptography Engine on RA6 Protected Mode|v5.4.0| +|I/O Port|v5.4.0| +|Arm CMSIS Version 5 - Core (M)|v6.1.0+fsp.5.4.0| +|RA6M4-EK Board Support Files|v5.4.0| +|Board support package for R7FA6M4AF3CFB|v5.4.0| +|Board support package for RA6M4 - Events|v5.4.0| +|Board support package for RA6M4|v5.4.0| +|Board support package for RA6M4 - FSP Data|v5.4.0| +|FreeRTOS|v10.6.1+fsp.5.4.0| +|FreeRTOS - Memory Management - Heap 4|v10.6.1+fsp.5.4.0| +|r_ether to FreeRTOS+TCP Wrapper|v5.4.0| +|Ethernet|v5.4.0| +|Ethernet PHY|v5.4.0| +|FreeRTOS+TCP|v4.0.0+fsp.5.4.0| +|FreeRTOS - Buffer Allocation 2|v4.0.0+fsp.5.4.0| +|FreeRTOS Port|v5.4.0| ## Setup Steps and Build wolfSSL Library @@ -72,7 +74,7 @@ The wolfssl Project Summary is listed below and is relevant for every project. |Thread Symbol|sce_tst_thread| |Thread Name|sce_tst_thread| |Thread Stack size|increase depending on your environment
e.g. 0xA000| -|Thread MemoryAllocation|Dyamic| +|Thread MemoryAllocation|Dynamic| |Common General Use Mutexes|Enabled| |Common General Enable Backward Compatibility|Enabled| |Common Memory Allocation Support Dynamic Allocation|Enabled| @@ -85,7 +87,7 @@ The wolfssl Project Summary is listed below and is relevant for every project. |:--|:--| |Network Events call vApplicationIPNetworkEventHook|Disable| |Use DHCP|Disable| - + + Save `dummy_library` FSP configuration + Copy configuration.xml and pincfg under `dummy_library` to `wolfSSL_RA6M4` + Open Smart Configurator by clicking copied configuration.xml @@ -105,7 +107,7 @@ The wolfssl Project Summary is listed below and is relevant for every project. + Copy the following folder and file at `dummy_application` to `test_RA6M4`\ script/\ src/sce_tst_thread_entry.c - + + Add `sce_test()` call under /* TODO: add your own code here */ line at sce_tst_thread_entry.c ``` ... @@ -119,7 +121,7 @@ The wolfssl Project Summary is listed below and is relevant for every project. + Download J-Link software from [Segger](https://www.segger.com/downloads/jlink) + Choose `J-Link Software and Documentation Pack` + Copy sample program files below from `Installed SEGGER` folder, `e.g C:\Program Files\SEGGER\JLink\Samples\RTT`, to /path/to/wolfssl/IDE/Reenesas/e2studio/RA6M4/test/src/SEGGER_RTT\ - + SEGGER_RTT.c\ SEGGER_RTT.h\ SEGGER_RTT_Conf.h\ @@ -134,7 +136,7 @@ The wolfssl Project Summary is listed below and is relevant for every project. you can specify "RTT control block" to 0x200232a8 by Address\ OR\ you can specify "RTT control block" to 0x20020000 0x10000 by Search Range - + ## Run Client 1.) Enable TLS_CLIENT definition in wolfssl_demo.h of test_RA6M4 project @@ -175,7 +177,7 @@ $./examples/server/server -b -d -i -c ./certs/server-ecc.pem -k ./certs/ecc-key. You will see the following message on J-LinK RTT Viewer when using RSA sign and verify. ``` - Start Client Example, + Start Client Example, Connecting to 192.168.11.xx [wolfSSL_TLS_client_do(00)][00] Start to connect to the server. @@ -204,7 +206,7 @@ You will see the following message on J-LinK RTT Viewer when using RSA sign and You will see the following message on J-LinK RTT Viewer when using ECDSA sign and verify. ``` - Start Client Example, + Start Client Example, Connecting to 192.168.11.xx [wolfSSL_TLS_client_do(00)][00] Start to connect to the server. @@ -235,7 +237,7 @@ You will see the following message on J-LinK RTT Viewer when using ECDSA sign an ### Run Multi Client Session example 1.) Enable TLS_CLIENT and TLS_MULTITHREAD_TEST definition in wolfssl_demo.h of test_RA6M4 project -2.) Follow [Run Client](#run-client) instruction +2.) Follow [Run Client](#run-client) instruction 3.) Prepare peer wolfssl server @@ -258,7 +260,7 @@ $./examples/server/server -b -d -c -i ./certs/server-ecc.pem -k ./certs/ecc-key. 4.) Run Multi Client Session Example You will see similar following message on J-LinK RTT Viewer when using ECDSA sign and verify. ``` - Start Client Example, + Start Client Example, Connecting to 192.168.11.xx clt_thd_taskA connecting to 11111 port @@ -291,7 +293,7 @@ You will see similar following message on J-LinK RTT Viewer when using ECDSA sig You will see similar following message on J-LinK RTT Viewer when using ECDSA sign and verify. ``` - Start Client Example, + Start Client Example, Connecting to 192.168.11.xx clt_thd_taskA connecting to 11111 port diff --git a/IDE/Renesas/e2studio/RA6M4/common/user_settings.h b/IDE/Renesas/e2studio/RA6M4/common/user_settings.h index 6f40f37f2..3c515029e 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 cbe535b2a..1dff4b177 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Renesas/e2studio/RA6M4/include.am b/IDE/Renesas/e2studio/RA6M4/include.am index cd8adec9c..db3f280f3 100644 --- a/IDE/Renesas/e2studio/RA6M4/include.am +++ b/IDE/Renesas/e2studio/RA6M4/include.am @@ -16,4 +16,4 @@ EXTRA_DIST+= IDE/Renesas/e2studio/RA6M4/test/src/common/.gitignore EXTRA_DIST+= IDE/Renesas/e2studio/RA6M4/test/key_data/key_data_sce.c EXTRA_DIST+= IDE/Renesas/e2studio/RA6M4/test/key_data/key_data.h EXTRA_DIST+= IDE/Renesas/e2studio/RA6M4/common/wolfssl_demo.h -EXTRA_DIST+= IDE/Renesas/e2studio/RA6M4/common/user_settings.h \ No newline at end of file +EXTRA_DIST+= IDE/Renesas/e2studio/RA6M4/common/user_settings.h diff --git a/IDE/Renesas/e2studio/RA6M4/test/.cproject b/IDE/Renesas/e2studio/RA6M4/test/.cproject index e7bb1ceb9..11ea16645 100644 --- a/IDE/Renesas/e2studio/RA6M4/test/.cproject +++ b/IDE/Renesas/e2studio/RA6M4/test/.cproject @@ -105,6 +105,9 @@ + + + @@ -111,6 +115,9 @@ + + + @@ -361,10 +369,14 @@ + + + @@ -389,10 +401,14 @@ + + + diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/README_EN.md b/IDE/Renesas/e2studio/RX65N/GR-ROSE/README_EN.md index 967b6ec73..0ea94144c 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/README_EN.md +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/README_EN.md @@ -6,16 +6,16 @@ wolfSSL sample application project for GR-ROSE evaluation board ## 1. Overview ----- -We provide a sample program for evaluating wolfSSL targeting the GR-ROSE evaluation board, which has RX65N MCU on it. The sample program runs in a bare metal environment that does not use a real-time OS and uses e2 studio as an IDE. This document describes the procedure from build to execution of the sample program. +We provide a sample program for evaluating wolfSSL targeting the GR-ROSE evaluation board, which has RX65N MCU on it. The sample program runs in a bare metal environment that does not use a real-time OS and uses e2 studio as an IDE. This document describes the procedure from build to execution of the sample program. The sample provided is a single application that can evaluate the following three functions: - CryptoTest: A program that automatically tests various cryptographic operation functions -- Benchmark: A program that measures the execution speed of various cryptographic operations +- Benchmark: A program that measures the execution speed of various cryptographic operations - TlsClient: A program that performs TLS communication with the opposite TLS server application

-Since the H/W settings and S/W settings for operating the evaluation board have already been prepared, the minimum settings are required to operate the sample application. In addition, the RootCA certificate and server-side certificate required for TLS communication have already been set for sample use only. +Since the H/W settings and S/W settings for operating the evaluation board have already been prepared, the minimum settings are required to operate the sample application. In addition, the RootCA certificate and server-side certificate required for TLS communication have already been set for sample use only. The following sections will walk you through the steps leading up to running the sample application.

@@ -23,16 +23,16 @@ The following sections will walk you through the steps leading up to running the ## 2. Target H/W, components and libraries ----- -This sample program uses the following hardware and software libraries. If a new version of the software component is available at the time of use, please update it as appropriate. +This sample program uses the following hardware and software libraries. If a new version of the software component is available at the time of use, please update it as appropriate. |item|name & version| |:--|:--| |Board|GR-ROSE| |Device|R5F565NEHxFP| -|IDE| Renesas e2Studio Version:2022-01 | +|IDE| Renesas e2Studio Version:2024-04 (24.4.0) | |Emulator| E1, E2 Emulator Lite | -|Toolchain|CCRX v3.04.00| -|TSIP| TSIP v1.17| +|Toolchain|CCRX v3.06.00| +|TSIP| TSIP v1.21|
The project of this sample program has a configuration file that uses the following FIT components. @@ -47,21 +47,20 @@ However, the FIT components themselves are not included in the distribution of t |Generic system timer for RX MCUs|1.01|r_sys_time_rx| |TCP/IP protocol stack[M3S-T4-Tiny] - RX Ethernet Driver Interface|1.09|r_t4_driver_rx| |TCP/IP protocol stack[M3S-T4-Tiny] for Renesas MCUs|2.10|r_t4_rx| -|TSIP(Trusted Secure IP) driver|1.17.l|r_tsip_rx| +|TSIP(Trusted Secure IP) driver|1.21|r_tsip_rx|
-Note) As of April 2022, TIPS v1.15 does not seem to be able to be added as a FIT component by adding a component in the Smart Configurator Perspective. Add it manually along the method described later.

## 3. Importing sample application project into e2Studio ---- -There is no need to create a new sample program. Since the project file is already prepared, please import the project from the IDE by following the steps below. +There is no need to create a new sample program. Since the project file is already prepared, please import the project from the IDE by following the steps below. -+ e2studio "File" menu> "Open project from file system ..."> "Directory (R) ..." Click the import source button and select the folder from which the project will be imported. Select the folder (Renesas/e2studio/{MCU}/{board-name-folder}) where this README file exists. -+ Four projects that can be imported are listed, but check only the three projects "smc", "test" and "wolfssl" and click the "Finish" button. ++ e2studio "File" menu> "Open project from file system ..."> "Directory (R) ..." Click the import source button and select the folder from which the project will be imported. Select the folder (Renesas/e2studio/{MCU}/{board-name-folder}) where this README file exists. ++ Four projects that can be imported are listed, but check only the three projects "smc", "test" and "wolfssl" and click the "Finish" button. -You should see the **smc**, **test**, and **wolfssl** 3 projects you imported into the project explorer. +You should see the **smc**, **test**, and **wolfssl** 3 projects you imported into the project explorer.

## 4. FIT module download and smart configurator file generation @@ -69,13 +68,13 @@ You should see the **smc**, **test**, and **wolfssl** 3 projects you imported in You will need to get the required FIT modules yourself. Follow the steps below to get them. -1. Open the smc project in Project Explorer and double-click the **smc.scfg** file to open the Smart Configurator Perspective. +1. Open the smc project in Project Explorer and double-click the **smc.scfg** file to open the Smart Configurator Perspective. 2. Select the "Components" tab on the software component settings pane. Then click the "Add Component" button at the top right of the pane. The software component selection dialog will pop up. Click "Download the latest version of FIT driver and middleware" at the bottom of the dialog to get the modules. You can check the download destination folder by pressing "Basic settings...". 3. The latest version of the TSIP component may not be automatically obtained due to the delay in Renesas' support by the method in step 2 above. In that case, you can download it manually from the Renesas website. Unzip the downloaded component and store the files contained in the FIT Modules folder in the download destination folder of step 2. -4. Select the required FIT components shown from the list and press the "Finish" button. Repeat this operation until you have the required FIT components. +4. Select the required FIT components shown from the list and press the "Finish" button. Repeat this operation until you have the required FIT components. 5. Select the Components tab on the Software Component Settings pane and select the r_t4_rx component. In the settings pane on the right, specify the IP address of this board as the value of the "# IP address for ch0, when DHCP disable." Property (e.g. 192.168.1.9). @@ -117,7 +116,7 @@ Then build the test application. ## 7. Build and run the test application ----- -Now that the test application is ready to build. +Now that the test application is ready to build. 1. Build the wolfssl project on the project explorer, then the test project. @@ -129,14 +128,14 @@ Now that the test application is ready to build. 5. Press the run button to run the test application. -6. CryptoTest, Benchmark or TLS_Client After displaying the execution result according to the selected behavior, it enters an infinite loop, so if you think that the output has stopped, stop debugging. +6. CryptoTest, Benchmark or TLS_Client After displaying the execution result according to the selected behavior, it enters an infinite loop, so if you think that the output has stopped, stop debugging.

## 8. Running test application as TLS_Client -----
-### 8.1 TLS version supported by the test application +### 8.1 TLS version supported by the test application
You can use the TLS1.3 protocol in addition to the existing TLS1.2. The following macro is defined to {board-name-folder}/common/user_settings.h. @@ -177,7 +176,7 @@ In the test application, the TLS version and certificate type determine the ciph |:--|:--|:--| |TLS1.3|RSA/ECDSA certificate| | |||TLS_AES_128_GCM_SHA256| -|||TLS_AES_128_CCM_SHA256| +|||TLS_AES_128_CCM_SHA256| |TLS1.2|RSA certificate| |||TLS_RSA_WITH_AES_128_CBC_SHA| |||TLS_RSA_WITH_AES_256_CBC_SHA| @@ -200,7 +199,7 @@ To operate as TLS_Client, an opposite application for TLS communication is requi Configuration options need to be changed depending on the certificate type used. -#### 8.4.1 Configuration when using ECDSA certificates +#### 8.4.1 Configuration when using ECDSA certificates
@@ -217,7 +216,7 @@ Note: Do not forget to specify "-DNO_RSA"
With the above build, /examples/server/server -Is generated. This executable acts as a TLS server application. If you execute it with the following options, it will be in the listening state for the connection from TLS_Client. +Is generated. This executable acts as a TLS server application. If you execute it with the following options, it will be in the listening state for the connection from TLS_Client.

``` @@ -247,7 +246,7 @@ is generated. This executable program acts as a server application. If you execu

``` -$ examples / server / server -b -v4 -i +$ examples / server / server -b -v 4 -i ```
@@ -298,7 +297,7 @@ If you want to use it for purposes beyond functional evaluation, you need to pre 2. RSA key pair required for RootCA certificate validation 3. The signature generated by the RootCA certificate with the private key in 2 above. -will become necessary. Please refer to the manual provided by Renesas for how to generate them. +will become necessary. Please refer to the manual provided by Renesas for how to generate them.
@@ -316,7 +315,7 @@ Use wolfSSL_use_certificate_buffer or wolfSSL_CTX_use_certificate_buffer to load (2) Loading client private key/public key -Type of the client certificate decides the keys to be loaded. +Type of the client certificate decides the keys to be loaded. a) ECDSA certificate:
Load private key using tsip_use_PrivateKey_buffer. @@ -324,25 +323,25 @@ a) ECDSA certificate:
b) RSA certificate:
Load private key using tsip_use_PrivateKey_buffer. Load public key using tsip_use_PublicKey_buffer. -Note. In case of RSA certificate, the public key will be used for internal verification of signature process. +Note. In case of RSA certificate, the public key will be used for internal verification of signature process. (3) How to generate encrypted keys The keys (private and public keys) to be loaded should be encrypted-key format. Those keys could be generated with Renesas Secure Flash Programmer or SecurityKeyManagementTool. Refer the section 7.5 and 7.6 of the application note named “RX Family TSIP Module Firmware Integration technology” how to operate above key wrapping tool. (4) Macro to be defined -Define “WOLF_PRIVATE_KEY_ID” in your user_settings.h. +Define “WOLF_PRIVATE_KEY_ID” in your user_settings.h.
## 11. Limitations ----
-wolfSSL, which supports TSIPv1.17, has the following functional restrictions. +wolfSSL, which supports TSIPv1.21, has the following functional restrictions.

1. Handshake message packets exchanged with the server during the TLS handshake are stored in plaintext in memory. This is used to calculate the hash of handshake messages. The content will be deleted at the end of the session. 1. Session resumption and early data using TSIP are not supported. -The above limitations are expected to be improved by TSIP or wolfSSL from the next version onwards. \ No newline at end of file +The above limitations are expected to be improved by TSIP or wolfSSL from the next version onwards. diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/README_JP.md b/IDE/Renesas/e2studio/RX65N/GR-ROSE/README_JP.md index c3186924a..29ca1169a 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/README_JP.md +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/README_JP.md @@ -30,10 +30,10 @@ Renesas社製MCU RX65Nを搭載した評価ボードGR-ROSEをターゲットと |:--|:--| |評価ボード|GR-ROSE| |Device|R5F565NEHxFP| -|IDE| Renesas e2Studio Version:2022-01 | +|IDE| Renesas e2Studio Version:2024-04 (24.4.0) | |エミュレーター| E1, E2エミュレーターLite | -|Toolchain|CCRX v3.04.00| -|TSIP| TSIP v1.17| +|Toolchain|CCRX v3.06.00| +|TSIP| TSIP v1.21|
本サンプルプログラムのプロジェクトには以下のFITコンポーネントを使用する設定ファイルが用意されています。 @@ -50,10 +50,7 @@ Renesas社製MCU RX65Nを搭載した評価ボードGR-ROSEをターゲットと |Generic system timer for RX MCUs|1.01|r_sys_time_rx| |TCP/IP protocol stack[M3S-T4-Tiny] - RX Ethernet Driver Interface|1.09|r_t4_driver_rx| |TCP/IP protocol stack[M3S-T4-Tiny] for Renesas MCUs|2.10|r_t4_rx| -|TSIP(Trusted Secure IP) driver|1.17.l|r_tsip_rx| - -(注意)2022年4月現在、TIPSv1.15はFITコンポーネントとしてスマートコンフィギュレータパースペクティブのコンポーネントの追加操作では追加できないようです。後ほど説明する手動での追加方法を使って追加してください。
- +|TSIP(Trusted Secure IP) driver|1.21|r_tsip_rx|

@@ -186,7 +183,7 @@ testアプリケーションでは、TLSバージョンと証明書のタイプ |:--|:--|:--| |TLS1.3|RSA/ECDSA証明書| | |||TLS_AES_128_GCM_SHA256| -|||TLS_AES_128_CCM_SHA256| +|||TLS_AES_128_CCM_SHA256| |TLS1.2|RSA証明書| |||TLS_RSA_WITH_AES_128_CBC_SHA| |||TLS_RSA_WITH_AES_256_CBC_SHA| @@ -246,7 +243,7 @@ $ make

``` -$ examples/server/server -b -v4 -i +$ examples/server/server -b -v 4 -i ```
testアプリケーションには、サーバーアプリケーションに割り当てられたIPアドレスを指定します。 @@ -336,7 +333,7 @@ user_settings.hにWOLF_PRIVATE_KEY_IDの定義を行ってください。 ## 11. 制限事項 ----- -TSIPv1.17をサポートしたwolfSSLでは以下の機能制限があります。 +TSIPv1.21をサポートしたwolfSSLでは以下の機能制限があります。 1. TLSハンドシェーク中にサーバーと交換したメッセージパケットが平文でメモリ上に蓄積されています。これはハンドシェークメッセージのハッシュ計算に使用されます。内容はセッション終了時に削除されます。 diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/strings.h b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/strings.h index a66c8bbbf..7cbc78770 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 12f937494..ec6e32ec9 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 043c03193..50e032fbc 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -30,7 +30,7 @@ /*-- Renesas TSIP usage and its version --------------------------------------- * * "WOLFSSL_RENESAS_TSIP" definition makes wolfSSL to use H/W acceleration - * for cipher operations. + * for cipher operations. * TSIP definition asks to have its version number. * "WOLFSSL_RENESAS_TSIP_VER" takes following value: * 106: TSIPv1.06 @@ -38,27 +38,29 @@ * 113: TSIPv1.13 * 114: TSIPv1.14 * 115: TSIPv1.15 + * 117: TSIPv1.17 + * 121: TSIPv1.21 *----------------------------------------------------------------------------*/ #define WOLFSSL_RENESAS_TSIP - #define WOLFSSL_RENESAS_TSIP_VER 117 + #define WOLFSSL_RENESAS_TSIP_VER 121 /*-- TLS version definitions -------------------------------------------------- * * wolfSSL supports TLSv1.2 by default. In case you want your system to support * TLSv1.3, uncomment line below. - * + * *----------------------------------------------------------------------------*/ #define WOLFSSL_TLS13 /*-- Operating System related definitions -------------------------------------- - * + * * In case any real-time OS is used, define its name(e.g. FREERTOS). * Otherwise, define "SINGLE_THREADED". They are exclusive each other. - * + * *----------------------------------------------------------------------------*/ - #define SINGLE_THREADED + #define SINGLE_THREADED /*#define FREERTOS*/ /*-- Compiler related definitions --------------------------------------------- @@ -98,34 +100,34 @@ /* USE_ECC_CERT * This macro is for selecting root CA certificate to load, it is valid only - * in example applications. wolfSSL does not refer this macro. - * If you want to use cipher suites including ECDSA authentication in + * in example applications. wolfSSL does not refer this macro. + * If you want to use cipher suites including ECDSA authentication in * the example applications with TSIP, enable this macro. - * In TSIP 1.13 or later version, following cipher suites are + * In TSIP 1.13 or later version, following cipher suites are * available: * - TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 * - TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SAH256 - * + * * Note that, this macro disables cipher suites including RSA * authentication such as: * - TLS_RSA_WITH_AES_128_CBC_SHA - * - TLS_RSA_WITH_AES_256_CBC_SHA + * - TLS_RSA_WITH_AES_256_CBC_SHA * - TLS_RSA_WITH_AES_128_CBC_SHA256 * - TLS_RSA_WITH_AES_256_CBC_SHA256 * - TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 * - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA256 - * + * */ #define USE_ECC_CERT - /* In this example application, Root CA cert buffer named - * "ca_ecc_cert_der_256" is used under the following macro definition + /* In this example application, Root CA cert buffer named + * "ca_ecc_cert_der_256" is used under the following macro definition * for ECDSA. */ #define USE_CERT_BUFFERS_256 - /* In this example application, Root CA cert buffer named - * "ca_cert_der_2048" is used under the following macro definition + /* In this example application, Root CA cert buffer named + * "ca_cert_der_2048" is used under the following macro definition * for RSA authentication. */ #define USE_CERT_BUFFERS_2048 @@ -137,7 +139,7 @@ #define SIZEOF_LONG_LONG 8 /*#define WOLFSSL_STATIC_MEMORY*/ - + #if defined(WOLFSSL_STATIC_MEMORY) #define USE_FAST_MATH #else @@ -146,24 +148,24 @@ - /* + /* * -- "NO_ASN_TIME" macro is to avoid certificate expiration validation -- - * - * Note. In your actual products, do not forget to comment-out + * + * Note. In your actual products, do not forget to comment-out * "NO_ASN_TIME" macro. And prepare time function to get calendar time, - * otherwise, certificate expiration validation will not work. + * otherwise, certificate expiration validation will not work. */ /*#define NO_ASN_TIME*/ - + #define NO_MAIN_DRIVER #define BENCH_EMBEDDED - #define NO_WOLFSSL_DIR + #define NO_WOLFSSL_DIR #define WOLFSSL_NO_CURRDIR #define NO_FILESYSTEM #define WOLFSSL_LOG_PRINTF #define WOLFSSL_HAVE_MIN #define WOLFSSL_HAVE_MAX - + #define NO_WRITEV #define WOLFSSL_USER_IO @@ -175,7 +177,7 @@ #define USE_WOLF_SUSECONDS_T #define USE_WOLF_TIMEVAL_T - + #define WC_RSA_BLINDING #define TFM_TIMING_RESISTANT #define ECC_TIMING_RESISTANT @@ -191,7 +193,7 @@ /*-- Definitions for functionality negation ----------------------------------- * - * + * *----------------------------------------------------------------------------*/ /*#define NO_RENESAS_TSIP_CRYPT*/ @@ -203,7 +205,7 @@ /*-- Consistency checking between definitions --------------------------------- * - * + * *----------------------------------------------------------------------------*/ /*-- TSIP TLS specific definitions --*/ @@ -229,7 +231,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) @@ -243,10 +244,20 @@ # undef WOLFSSL_RENESAS_TSIP_TLS # undef WOLFSSL_RENESAS_TSIP_CRYPT #endif - + /*------------------------------------------------------------------------- + * TSIP generates random numbers using the CRT-DRBG described + * in NIST SP800-90A. Recommend to define the CUSTOM_RAND_GENERATE_BLOCK + * so that wc_RNG_GenerateByte/Block() call TSIP random generatoion API + * directly. Comment out the macro will generate random number by + * wolfSSL Hash DRBG by using a seed which is generated by TSIP API. + *-----------------------------------------------------------------------*/ + #define CUSTOM_RAND_GENERATE_BLOCK wc_tsip_GenerateRandBlock #else #define OPENSSL_EXTRA #define WOLFSSL_GENSEED_FORTEST /* Warning: define your own seed gen */ + #if !defined(min) + #define min(data1, data2) _builtin_min(data1, data2) + #endif #endif @@ -260,7 +271,3 @@ #define XSTRCASECMP(s1,s2) strcmp((s1),(s2)) -#if !defined(WOLFSSL_RENESAS_TSIP_TLS) - #define min(x,y) ((x)<(y)?(x):(y)) -#endif - 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 db2911cf3..032a171cc 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -18,18 +18,33 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ - #include -#define YEAR 2023 -#define MON 6 - static int tick = 0; +#define YEAR ( \ + ((__DATE__)[7] - '0') * 1000 + \ + ((__DATE__)[8] - '0') * 100 + \ + ((__DATE__)[9] - '0') * 10 + \ + ((__DATE__)[10] - '0') * 1 \ +) + +#define MONTH ( \ + __DATE__[2] == 'n' ? (__DATE__[1] == 'a' ? 1 : 6) \ + : __DATE__[2] == 'b' ? 2 \ + : __DATE__[2] == 'r' ? (__DATE__[0] == 'M' ? 3 : 4) \ + : __DATE__[2] == 'y' ? 5 \ + : __DATE__[2] == 'l' ? 7 \ + : __DATE__[2] == 'g' ? 8 \ + : __DATE__[2] == 'p' ? 9 \ + : __DATE__[2] == 't' ? 10 \ + : __DATE__[2] == 'v' ? 11 \ + : 12 \ + ) time_t time(time_t *t) { (void)t; - return ((YEAR-1970)*365+30*MON)*24*60*60 + tick++; + return ((YEAR-1970)*365+30*MONTH)*24*60*60 + tick++; } #include diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/include.am b/IDE/Renesas/e2studio/RX65N/GR-ROSE/include.am index 60df793e5..ce88e9b15 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/include.am +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/include.am @@ -23,4 +23,8 @@ EXTRA_DIST+= IDE/Renesas/e2studio/RX65N/GR-ROSE/common/unistd.h EXTRA_DIST+= IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h EXTRA_DIST+= IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/.cproject EXTRA_DIST+= IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/.project -EXTRA_DIST+= IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/smc.scfg \ No newline at end of file +EXTRA_DIST+= IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/smc.scfg +EXTRA_DIST+= IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/README.md +EXTRA_DIST+= IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/generate_SignedCA.sh +EXTRA_DIST+= IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/rsa_private.pem +EXTRA_DIST+= IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/rsa_public.pem diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/smc.scfg b/IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/smc.scfg index 393a20ac4..9193414c7 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/smc.scfg +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/smc.scfg @@ -4,16 +4,18 @@ + - - @@ -128,7 +129,7 @@ - @@ -338,13 +339,12 @@ 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 b45157faa..12bf996f0 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -88,11 +88,11 @@ void simple_tcp_client( ) #define BUFF_SIZE 256 static const char sendBuff[]= "Hello Server\n" ; - + char rcvBuff[BUFF_SIZE] = {0}; - + static T_IPV4EP my_addr = { 0, 0 }; - + T_IPV4EP dst_addr; if((dst_addr.ipaddr = getIPaddr(SIMPLE_TCPSEVER_IP)) == 0){ @@ -109,7 +109,7 @@ void simple_tcp_client( ) goto out; } - if (my_IOSend((char*)sendBuff, strlen(sendBuff), (void*)&cepid) != + if (my_IOSend((char*)sendBuff, strlen(sendBuff), (void*)&cepid) != strlen(sendBuff)) { printf("ERROR TCP write \n"); goto out; @@ -129,4 +129,4 @@ void simple_tcp_client( ) tcp_cls_cep(cepid, TMO_FEVR); return; -} \ No newline at end of file +} 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 62c426ca0..aa11768ad 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * 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 1a096d37f..bc2cf6d67 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 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 55892f491..df55941c4 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -123,18 +123,18 @@ void wolfSSL_TLS_server_init() #if !defined(NO_FILESYSTEM) ret = wolfSSL_CTX_use_PrivateKey_file(server_ctx, key, 0); #else - ret = wolfSSL_CTX_use_PrivateKey_buffer(server_ctx, key, sizeof_key, + ret = wolfSSL_CTX_use_PrivateKey_buffer(server_ctx, key, sizeof_key, SSL_FILETYPE_ASN1); #endif if (ret != SSL_SUCCESS) { printf("Error %d loading server-key!\n", ret); return; } - + /* Register callbacks */ wolfSSL_SetIORecv(server_ctx, my_IORecv); wolfSSL_SetIOSend(server_ctx, my_IOSend); - + } void wolfSSL_TLS_server( ) 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 2fb3d2489..3614dc0b3 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -65,6 +65,7 @@ extern "C" { static long tick; static void timeTick(void *pdata) { + (void)pdata; tick++; } @@ -259,7 +260,7 @@ void main(void) #if defined(SIMPLE_TLS_TSIP_CLIENT) SetTsiptlsKey(); #endif - + do { /* simply use TCP */ #if defined(SIMPLE_TCP_CLIENT) 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 d8e035d8d..354fa3549 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-2024 wolfSSL Inc. + * Copyright (C) 2006-2025 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -36,9 +36,9 @@ /* cannot enable with other definition */ /* simplest tcp client*/ /*#define SIMPLE_TCP_CLIENT */ -/* software TLS client */ +/* software TLS client */ /* #define SIMPLE_TLS_CLIENT */ -/* use TSIP Acceleration */ +/* use TSIP Acceleration */ /*#define SIMPLE_TLS_TSIP_CLIENT*/ /* simplest tcp server */ diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/test.scfg b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/test.scfg index bf7fe0920..d5c797c88 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/test.scfg +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/test.scfg @@ -362,14 +362,14 @@ - + - - + + @@ -437,14 +437,14 @@ - - + + - - - - + + + + @@ -457,8 +457,8 @@ - - + + @@ -608,110 +608,110 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - +