├── .cyignore
├── .github
└── workflows
│ ├── cmake-build.yml
│ ├── make-test-swtpm.yml
│ ├── win-test.yml
│ └── zephyr.yml
├── .gitignore
├── CMakeLists.txt
├── ChangeLog.md
├── IDE
├── Espressif
│ ├── CMakeLists.txt
│ ├── README.md
│ ├── VisualGDB
│ │ └── wolfssl_IDF_v5.2_ESP32.vgdbproj
│ ├── components
│ │ ├── wolfssl
│ │ │ ├── CMakeLists.txt
│ │ │ └── include
│ │ │ │ └── user_settings.h
│ │ └── wolftpm
│ │ │ ├── CMakeLists.txt
│ │ │ └── include
│ │ │ └── README.md
│ ├── include.am
│ ├── main
│ │ ├── CMakeLists.txt
│ │ ├── Kconfig.projbuild
│ │ ├── include
│ │ │ └── main.h
│ │ └── main.c
│ ├── partitions_singleapp_large.csv
│ └── sdkconfig.defaults
├── IAR-EWARM
│ ├── ewarm-tpm2.ewp
│ ├── ewarm-tpm2.eww
│ ├── header
│ │ └── tpm_main.h
│ ├── include.am
│ └── source
│ │ ├── main.c
│ │ └── tpm_main.c
├── OPENSTM32
│ ├── .cproject
│ ├── .project
│ ├── Inc
│ │ ├── user_settings.h
│ │ └── wolftpm_example.h
│ ├── README.md
│ ├── Src
│ │ ├── main.c
│ │ └── wolftpm_example.c
│ ├── include.am
│ ├── wolfSTM32.cfg
│ ├── wolfSTM32.ioc
│ └── wolfSTM32.xml
├── QNX
│ ├── README.md
│ └── include.am
├── STM32CUBE
│ ├── README.md
│ ├── default_conf.ftl
│ ├── include.am
│ ├── wolftpm_test.c
│ └── wolftpm_test.h
├── VisualStudio
│ ├── README.md
│ ├── include.am
│ ├── tls_server.vcxproj
│ ├── user_settings.h
│ ├── wolfcrypt_test.vcxproj
│ ├── wolfssl.vcxproj
│ ├── wolftpm.sln
│ ├── wolftpm.vcxproj
│ └── wrap_test.vcxproj
└── include.am
├── LICENSE
├── Makefile.am
├── README.md
├── autogen.sh
├── certs
├── ca-ecc.cnf
├── ca-rsa.cnf
├── certreq.sh
├── example-ecc256-key-pub.der
├── example-ecc256-key-pub.pem
├── example-ecc256-key.der
├── example-ecc256-key.pem
├── example-ecc384-key-pub.der
├── example-ecc384-key-pub.pem
├── example-ecc384-key.der
├── example-ecc384-key.pem
├── example-rsa2048-key-pub.der
├── example-rsa2048-key-pub.pem
├── example-rsa2048-key.der
├── example-rsa2048-key.pem
├── include.am
├── wolf-ca-ecc-cert.pem
└── wolf-ca-rsa-cert.pem
├── cmake
├── README.md
├── config.in
└── include.am
├── commit-tests.sh
├── configure.ac
├── docs
├── Doxyfile
├── README.md
├── SWTPM.md
├── WindowTBS.md
├── generate_documentation.sh
└── include.am
├── examples
├── README.md
├── attestation
│ ├── README.md
│ ├── activate_credential.c
│ ├── attestation.h
│ ├── certify.c
│ ├── include.am
│ ├── make_credential.c
│ ├── tpm_iak_policy.png
│ └── tpm_idevid_policy.png
├── bench
│ ├── bench.c
│ ├── bench.h
│ └── include.am
├── boot
│ ├── README.md
│ ├── boot.h
│ ├── include.am
│ ├── secret_seal.c
│ ├── secret_unseal.c
│ └── secure_rot.c
├── csr
│ ├── csr.c
│ ├── csr.h
│ └── include.am
├── endorsement
│ ├── README.md
│ ├── endorsement.h
│ ├── get_ek_certs.c
│ ├── include.am
│ ├── trusted_certs.h
│ ├── trusted_certs_der.h
│ └── verify_ek_cert.c
├── firmware
│ ├── Makefile
│ ├── README.md
│ ├── ifx_fw_extract.c
│ ├── ifx_fw_update.c
│ ├── ifx_fw_update.h
│ └── include.am
├── gpio
│ ├── gpio.h
│ ├── gpio_config.c
│ ├── gpio_read.c
│ ├── gpio_set.c
│ └── include.am
├── include.am
├── keygen
│ ├── create_primary.c
│ ├── external_import.c
│ ├── include.am
│ ├── keygen.c
│ ├── keygen.h
│ ├── keyimport.c
│ └── keyload.c
├── management
│ ├── flush.c
│ ├── include.am
│ ├── management.h
│ └── tpmclear.c
├── native
│ ├── include.am
│ ├── native_test.c
│ └── native_test.h
├── nvram
│ ├── counter.c
│ ├── extend.c
│ ├── include.am
│ ├── nvram.h
│ ├── policy_nv.c
│ ├── read.c
│ └── store.c
├── pcr
│ ├── README.md
│ ├── demo-quote-zip.sh
│ ├── demo.sh
│ ├── extend.c
│ ├── include.am
│ ├── pcr.h
│ ├── policy.c
│ ├── policy_sign.c
│ ├── quote.c
│ ├── quote.h
│ ├── read_pcr.c
│ └── reset.c
├── pkcs7
│ ├── include.am
│ ├── pkcs7.c
│ └── pkcs7.h
├── run_examples.sh
├── seal
│ ├── include.am
│ ├── seal.c
│ ├── seal.h
│ └── unseal.c
├── timestamp
│ ├── clock_set.c
│ ├── clock_set.h
│ ├── include.am
│ ├── signed_timestamp.c
│ └── signed_timestamp.h
├── tls
│ ├── include.am
│ ├── tls_client.c
│ ├── tls_client.h
│ ├── tls_client_notpm.c
│ ├── tls_common.h
│ ├── tls_server.c
│ └── tls_server.h
├── tpm_test.h
├── tpm_test_keys.c
├── tpm_test_keys.h
├── u-boot
│ └── README.md
└── wrap
│ ├── caps.c
│ ├── include.am
│ ├── wrap_test.c
│ └── wrap_test.h
├── hal
├── README.md
├── include.am
├── tpm_io.c
├── tpm_io.h
├── tpm_io_atmel.c
├── tpm_io_barebox.c
├── tpm_io_espressif.c
├── tpm_io_infineon.c
├── tpm_io_linux.c
├── tpm_io_microchip.c
├── tpm_io_mmio.c
├── tpm_io_qnx.c
├── tpm_io_st.c
├── tpm_io_uboot.c
├── tpm_io_xilinx.c
└── tpm_io_zephyr.c
├── m4
├── ax_add_am_macro.m4
├── ax_am_jobserver.m4
├── ax_am_macros.m4
├── ax_append_compile_flags.m4
├── ax_append_flag.m4
├── ax_append_link_flags.m4
├── ax_append_to_file.m4
├── ax_check_compile_flag.m4
├── ax_check_library.m4
├── ax_check_link_flag.m4
├── ax_compiler_version.m4
├── ax_count_cpus.m4
├── ax_create_generic_config.m4
├── ax_debug.m4
├── ax_file_escapes.m4
├── ax_harden_compiler_flags.m4
├── ax_print_to_file.m4
├── ax_pthread.m4
├── ax_require_defined.m4
├── ax_tls.m4
├── ax_vcs_checkout.m4
├── hexversion.m4
├── lib-ld.m4
├── lib-link.m4
├── lib-prefix.m4
├── visibility.m4
└── wolfssl_darwin_clang.m4
├── pre-commit.sh
├── scripts
├── include.am
├── swtpm_sim.test
└── tls_setup.sh
├── src
├── include.am
├── tpm2.c
├── tpm2_asn.c
├── tpm2_cryptocb.c
├── tpm2_linux.c
├── tpm2_packet.c
├── tpm2_param_enc.c
├── tpm2_swtpm.c
├── tpm2_tis.c
├── tpm2_winapi.c
└── tpm2_wrap.c
├── tests
├── include.am
└── unit_tests.c
├── wolftpm
├── include.am
├── options.h.in
├── tpm2.h
├── tpm2_asn.h
├── tpm2_linux.h
├── tpm2_packet.h
├── tpm2_param_enc.h
├── tpm2_socket.h
├── tpm2_swtpm.h
├── tpm2_tis.h
├── tpm2_types.h
├── tpm2_winapi.h
├── tpm2_wrap.h
├── version.h
├── version.h.in
└── visibility.h
├── wrapper
├── CSharp
│ ├── .runsettings
│ ├── README.md
│ ├── include.am
│ ├── wolfTPM-csharp.csproj
│ ├── wolfTPM-tests.cs
│ └── wolfTPM.cs
├── include.am
└── wolfTPM-csharp.sln
└── zephyr
├── CMakeLists.txt
├── Kconfig
├── README.md
├── include.am
├── module.yml
├── samples
├── wolftpm_wrap_caps
│ ├── CMakeLists.txt
│ ├── prj.conf
│ └── sample.yaml
└── wolftpm_wrap_test
│ ├── CMakeLists.txt
│ ├── prj.conf
│ └── sample.yaml
└── user_settings.h
/.cyignore:
--------------------------------------------------------------------------------
1 | # wolfTPM folders
2 | $(SEARCH_wolftpm)/IDE
3 | $(SEARCH_wolftpm)/examples
4 | $(SEARCH_wolftpm)/tests
--------------------------------------------------------------------------------
/.github/workflows/cmake-build.yml:
--------------------------------------------------------------------------------
1 | name: WolfTPM CMake Build Tests
2 |
3 | on:
4 | push:
5 | branches: [ 'master', 'main', 'release/**' ]
6 | pull_request:
7 | branches: [ '*' ]
8 |
9 | jobs:
10 | build:
11 |
12 | runs-on: ubuntu-latest
13 |
14 | steps:
15 | #pull wolfTPM
16 | - uses: actions/checkout@master
17 |
18 | # Install cmake
19 | - name: Install cmake
20 | run: |
21 | sudo apt-get update
22 | sudo apt-get install -y cmake
23 |
24 | #pull and build wolfssl
25 | - name: Checkout wolfssl
26 | uses: actions/checkout@master
27 | with:
28 | repository: wolfssl/wolfssl
29 | path: wolfssl
30 | - name: Build wolfssl
31 | working-directory: ./wolfssl
32 | run: |
33 | mkdir build
34 | cd build
35 | # wolfSSL PR 7188 broke "make install" unless WOLFSSL_INSTALL is set
36 | cmake -DWOLFSSL_TPM=yes -DWOLFSSL_INSTALL=yes -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install" ..
37 | cmake --build .
38 | cmake --install .
39 |
40 | #build wolftpm
41 | - name: Build wolfTPM
42 | run: |
43 | mkdir build
44 | cd build
45 | cmake -DWOLFTPM_INTERFACE=SWTPM -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install" -DWITH_WOLFSSL="$GITHUB_WORKSPACE/install" ..
46 | cmake --build .
47 | cmake --install .
48 |
--------------------------------------------------------------------------------
/.github/workflows/win-test.yml:
--------------------------------------------------------------------------------
1 | name: Windows Build Test
2 |
3 | on:
4 | push:
5 | branches: [ 'master', 'main', 'release/**' ]
6 | pull_request:
7 | branches: [ '*' ]
8 |
9 | jobs:
10 | build:
11 |
12 | runs-on: windows-latest
13 |
14 | # This should be a safe limit for the tests to run.
15 | timeout-minutes: 6
16 |
17 | env:
18 | # Path to the solution file relative to the root of the project.
19 | SOLUTION_FILE_PATH: wolftpm\IDE\VisualStudio\wolftpm.sln
20 |
21 | # Configuration type to build.
22 | # You can convert this to a build matrix if you need coverage of multiple configuration types.
23 | # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
24 | BUILD_CONFIGURATION: Debug
25 | BUILD_PLATFORM: x64
26 |
27 | steps:
28 | - name: Pull wolfTPM
29 | uses: actions/checkout@master
30 | with:
31 | repository: wolfssl/wolftpm
32 | path: wolftpm
33 |
34 | - name: Pull wolfssl
35 | uses: actions/checkout@master
36 | with:
37 | repository: wolfssl/wolfssl
38 | path: wolfssl
39 | - name: Create FIPS stub files (autogen)
40 | working-directory: wolfssl
41 | run: |
42 | echo $null >> wolfcrypt\src\fips.c
43 | echo $null >> wolfcrypt\src\fips_test.c
44 | echo $null >> wolfcrypt\src\wolfcrypt_first.c
45 | echo $null >> wolfcrypt\src\wolfcrypt_last.c
46 |
47 | - name: Add MSBuild to PATH
48 | uses: microsoft/setup-msbuild@v1
49 |
50 | - name: Build
51 | working-directory: ${{env.GITHUB_WORKSPACE}}
52 | # Add additional options to the MSBuild command line here (like platform or verbosity level).
53 | # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
54 | run: msbuild /m /p:PlatformToolset=v142 /p:Platform=${{env.BUILD_PLATFORM}} /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}}
55 |
56 | # The GitHub CI runners do not have a TPM.
57 | # Failure 0x8028400f: unknown error number
58 | # TBS_E_TPM_NOT_FOUND (0x8028400F) A compatible Trusted Platform Module (TPM) Security Device cannot be found on this computer.
59 | #- name: Run Wrap Test
60 | # working-directory: ${{env.GITHUB_WORKSPACE}}
61 | # run: wolftpm\IDE\VisualStudio\Debug\x64\wrap_test.exe
62 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | patch/
3 | *.swp
4 | .metadata
5 | language.settings.xml
6 | src/config.h.in
7 | autom4te.cache
8 | build-aux
9 | aclocal.m4
10 | configure
11 | Makefile.in
12 | m4
13 | aminclude.am
14 | config.log
15 | config.status
16 | libtool
17 | Makefile
18 | wolftpm-config
19 | .dirstamp
20 | *.la
21 | *.lo
22 | config.h
23 | stamp-h1
24 | test-suite.log
25 | src/.deps
26 | src/.libs
27 | RemoteSystemsTempFiles
28 | *.o
29 | *.dep
30 | *.deps
31 | *.libs
32 | *.dSYM
33 | .vs
34 | IDE/IAR-EWARM/settings
35 | wolftpm/options.h
36 |
37 | # common cmake build location
38 | build/
39 |
40 | examples/wrap/wrap_test
41 | examples/wrap/caps
42 | examples/native/native_test
43 | examples/bench/bench
44 | examples/csr/csr
45 | examples/tls/tls_client
46 | examples/pkcs7/pkcs7
47 | examples/timestamp/signed_timestamp
48 | examples/pcr/quote
49 | examples/pcr/read_pcr
50 | examples/pcr/extend
51 | examples/pcr/policy
52 | examples/pcr/policy_sign
53 | examples/pcr/reset
54 | examples/timestamp/clock_set
55 | examples/management/flush
56 | examples/management/tpmclear
57 | pkcs7tpmsigned.p7s
58 | pkcs7tpmsignedex.p7s
59 | examples/tls/tls_server
60 | examples/tls/tls_client_notpm
61 | tests/unit.test
62 | examples/keygen/create_primary
63 | examples/keygen/keyload
64 | examples/keygen/keygen
65 | examples/keygen/keyimport
66 | examples/keygen/external_import
67 | examples/nvram/extend
68 | examples/nvram/store
69 | examples/nvram/read
70 | examples/nvram/counter
71 | examples/nvram/policy_nv
72 | examples/gpio/gpio_config
73 | examples/gpio/gpio_set
74 | examples/gpio/gpio_read
75 | examples/gpio/gpio_nuvoton
76 | examples/seal/seal
77 | examples/seal/unseal
78 | examples/attestation/make_credential
79 | examples/attestation/activate_credential
80 | examples/attestation/certify
81 | examples/boot/secure_rot
82 | examples/boot/secret_seal
83 | examples/boot/secret_unseal
84 | examples/firmware/ifx_fw_extract
85 | examples/firmware/ifx_fw_update
86 | examples/endorsement/get_ek_certs
87 | examples/endorsement/verify_ek_cert
88 |
89 | # Generated Cert Files
90 | certs/ca-*.pem
91 | certs/ca-*.der
92 | certs/ca-*.crl
93 | certs/*.par
94 | certs/crlnumber*
95 | certs/serial
96 | certs/index*
97 | certs/tpm-*.csr
98 | certs/server-*.der
99 | certs/server-*.pem
100 | certs/client-*.der
101 | certs/client-*.pem
102 | certs/serial.old
103 | certs/0*.pem
104 | certs/1*.pem
105 | certs/2*.pem
106 | certs/3*.pem
107 | certs/4*.pem
108 | certs/5*.pem
109 | certs/6*.pem
110 | certs/7*.pem
111 | certs/8*.pem
112 | certs/9*.pem
113 |
114 | # Test files
115 | quote.blob
116 | keyblob.bin
117 | ecc_test_blob.raw
118 | rsa_test_blob.raw
119 | ak.name
120 | cred.blob
121 | ek.pub
122 | srk.pub
123 | ak.pem
124 | ek.pem
125 |
126 | # Generated Documentation
127 | docs/html
128 | docs/xml
129 |
130 | # Wrapper
131 | wrapper/CSharp/obj
132 | wrapper/CSharp/bin
133 |
134 | # Visual Studio
135 | IDE/VisualStudio/Debug
136 | IDE/VisualStudio/DLL Debug
137 | IDE/VisualStudio/DLL Release
138 | IDE/VisualStudio/Release
139 |
140 |
141 | # Visual Studio Code Workspace Files
142 | *.vscode
143 | *.userprefs
144 | *.exe
145 | *.dll
146 | .vs
147 | Backup
148 | UpgradeLog.htm
149 | *.aps
150 | *.VC.db
151 | *.filters
152 |
153 | # Backup and old files
154 | /**/*.bak
155 | /**/*.old
156 |
157 | # VisualGDB
158 | **/.visualgdb
159 | **/*.vgdbproj.*.user
160 |
161 | # PlatformIO
162 | /IDE/PlatformIO/**/.pio
163 | /IDE/PlatformIO/**/.vscode/.browse.c_cpp.db*
164 | /IDE/PlatformIO/**/.vscode/c_cpp_properties.json
165 | /IDE/PlatformIO/**/.vscode/launch.json
166 | /IDE/PlatformIO/**/.vscode/ipch
167 |
168 | # Espressif sdk config default should be saved in sdkconfig.defaults
169 | # we won't track the actual working sdkconfig files
170 | /IDE/Espressif/**/sdkconfig
171 | /IDE/Espressif/**/sdkconfig.old
172 |
--------------------------------------------------------------------------------
/IDE/Espressif/README.md:
--------------------------------------------------------------------------------
1 | # wolfTPM for Espressif
2 |
3 | Initial minimum memory requirements: 35KB Stack. See `sdkconfig.defaults`.
4 |
5 | Current memory assigned: 50960
6 |
7 | ## Pin assignments
8 |
9 | **Note:** The following pin assignments are used by default, you can change these in the `menuconfig` .
10 |
11 | | | SDA | SCL |
12 | | ---------------- | -------------- | -------------- |
13 | | ESP I2C Master | I2C_MASTER_SDA | I2C_MASTER_SCL |
14 | | TPM2 Device | SDA | SCL |
15 |
16 | For the actual default value of `I2C_MASTER_SDA` and `I2C_MASTER_SCL` see `Example Configuration` in `menuconfig`.
17 |
18 | **Note:** There's no need to add an external pull-up resistors for SDA/SCL pin, because the driver will enable the internal pull-up resistors.
19 |
20 | ## Troubleshooting
21 |
22 | If problems are encountered with the I2C module:
23 |
24 | - Beware that printing to the UART during an I2C transaction may affect timing and cause errors.
25 | - Ensure the TPM module has been reset after flash updated.
26 | - Check wiring. `SCL` to `SCL`, `SDA` to `SDA`. Probably best to ensure GND is connected. Vcc is 3.3v only.
27 | - Ensure the proper pins are connected on the ESP32. SCL default is `GPIO 19`; SDA default is `GPIO 18`.
28 | - Test with only a single I2C device before testing concurrent with other I2C boards.
29 | - When using multiple I2C boards, check for appropriate pullups. See data sheet.
30 | - Reset TPM device again. Press button on TPM SLB9673 eval board or set TPM pin 17 as appropriate.
31 | -
--------------------------------------------------------------------------------
/IDE/Espressif/components/wolftpm/include/README.md:
--------------------------------------------------------------------------------
1 | # wolfTPM include
2 |
3 | Please see the wolfSSL user_settings.h for wolfTPM configuration settings.
4 |
5 |
--------------------------------------------------------------------------------
/IDE/Espressif/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # included from Top Level Makefile.am
3 | # All paths should be given relative to the root
4 | #
5 | # Don't list any config.h files here
6 |
7 | EXTRA_DIST+= IDE/Espressif/CMakeLists.txt
8 | EXTRA_DIST+= IDE/Espressif/README.md
9 | EXTRA_DIST+= IDE/Espressif/partitions_singleapp_large.csv
10 | EXTRA_DIST+= IDE/Espressif/sdkconfig.defaults
11 |
12 | # wolfSSL source code is not included here and must be available in separate directory.
13 | EXTRA_DIST+= IDE/Espressif/components/wolfssl/CMakeLists.txt
14 | EXTRA_DIST+= IDE/Espressif/components/wolfssl/include/user_settings.h
15 |
16 | # the wolfTPM source code used will typically be the parent of the IDE directory.
17 | EXTRA_DIST+= IDE/Espressif/components/wolftpm/CMakeLists.txt
18 | EXTRA_DIST+= IDE/Espressif/components/wolftpm/include/README.md
19 |
20 | # The example application.
21 | EXTRA_DIST+= IDE/Espressif/main/CMakeLists.txt
22 | EXTRA_DIST+= IDE/Espressif/main/Kconfig.projbuild
23 | EXTRA_DIST+= IDE/Espressif/main/main.c
24 | EXTRA_DIST+= IDE/Espressif/main/include/main.h
25 |
26 | # VisualGDB Project Files. See also https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/template/VisualGDB
27 | EXTRA_DIST+= IDE/Espressif/VisualGDB/wolfssl_IDF_v5.2_ESP32.vgdbproj
28 |
--------------------------------------------------------------------------------
/IDE/Espressif/main/Kconfig.projbuild:
--------------------------------------------------------------------------------
1 | menu "Example Configuration"
2 |
3 | orsource "$IDF_PATH/examples/common_components/env_caps/$IDF_TARGET/Kconfig.env_caps"
4 |
5 | config I2C_MASTER_SCL
6 | int "SCL GPIO Num"
7 | range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX
8 | default 19 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
9 | default 2
10 | help
11 | GPIO number for I2C Master clock line.
12 |
13 | config I2C_MASTER_SDA
14 | int "SDA GPIO Num"
15 | range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX
16 | default 18 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
17 | default 1
18 | help
19 | GPIO number for I2C Master data line.
20 |
21 | endmenu
22 |
--------------------------------------------------------------------------------
/IDE/Espressif/main/include/main.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _MAIN_H_
23 | #define _MAIN_H_
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/IDE/Espressif/partitions_singleapp_large.csv:
--------------------------------------------------------------------------------
1 | # to view: idf.py partition-table
2 | #
3 | # ESP-IDF Partition Table
4 | # Name, Type, SubType, Offset, Size, Flags
5 | nvs, data, nvs, 0x9000, 24K,
6 | phy_init,data, phy, 0xf000, 4K,
7 | factory, app, factory, 0x10000, 1500K,
8 |
9 |
10 | # For other settings, see:
11 | # https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#creating-custom-tables
12 | #
13 | # Here is the summary printed for the "Single factory app, no OTA" configuration:
14 | #
15 | # # ESP-IDF Partition Table
16 | # # Name, Type, SubType, Offset, Size, Flags
17 | # nvs, data, nvs, 0x9000, 0x6000,
18 | # phy_init, data, phy, 0xf000, 0x1000,
19 | # factory, app, factory, 0x10000, 1M,
20 | #
21 | #
22 | # Here is the summary printed for the "Factory app, two OTA definitions" configuration:
23 | #
24 | # # ESP-IDF Partition Table
25 | # # Name, Type, SubType, Offset, Size, Flags
26 | # nvs, data, nvs, 0x9000, 0x4000,
27 | # otadata, data, ota, 0xd000, 0x2000,
28 | # phy_init, data, phy, 0xf000, 0x1000,
29 | # factory, app, factory, 0x10000, 1M,
30 | # ota_0, app, ota_0, 0x110000, 1M,
31 | # ota_1, app, ota_1, 0x210000, 1M,
32 |
--------------------------------------------------------------------------------
/IDE/Espressif/sdkconfig.defaults:
--------------------------------------------------------------------------------
1 | CONFIG_FREERTOS_HZ=1000
2 | CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
3 |
4 | #
5 | # Default main stack size
6 | #
7 | # This is typically way bigger than needed for stack size. See user_settings.h
8 | #
9 | CONFIG_ESP_MAIN_TASK_STACK_SIZE=35840
10 |
11 | # Legacy stack size for older ESP-IDF versions
12 | CONFIG_MAIN_TASK_STACK_SIZE=35840
13 |
14 | #
15 | # Compiler options
16 | #
17 | CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y
18 | CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y
19 | CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2
20 | CONFIG_COMPILER_HIDE_PATHS_MACROS=y
21 | CONFIG_COMPILER_STACK_CHECK_MODE_NORM=y
22 | CONFIG_COMPILER_STACK_CHECK=y
23 |
24 | #
25 | # Partition Table
26 | #
27 | # CONFIG_PARTITION_TABLE_SINGLE_APP is not set
28 | CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
29 | # CONFIG_PARTITION_TABLE_TWO_OTA is not set
30 | # CONFIG_PARTITION_TABLE_CUSTOM is not set
31 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
32 | CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp_large.csv"
33 | CONFIG_PARTITION_TABLE_OFFSET=0x8000
34 | CONFIG_PARTITION_TABLE_MD5=y
35 | # end of Partition Table
36 |
--------------------------------------------------------------------------------
/IDE/IAR-EWARM/ewarm-tpm2.eww:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $WS_DIR$\ewarm-tpm2.ewp
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/IDE/IAR-EWARM/header/tpm_main.h:
--------------------------------------------------------------------------------
1 | #ifndef _TPM_MAIN_H_
2 | #define _TPM_MAIN_H_
3 |
4 |
5 | int TPM2_Cust_Example(void* userCtx);
6 |
7 |
8 | #endif /* _TPM_MAIN_H_ */
9 |
--------------------------------------------------------------------------------
/IDE/IAR-EWARM/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # included from Top Level Makefile.am
3 | # All paths should be given relative to the root
4 |
5 | EXTRA_DIST+= IDE/IAR-EWARM/ewarm-tpm2.eww
6 | EXTRA_DIST+= IDE/IAR-EWARM/ewarm-tpm2.ewp
7 | EXTRA_DIST+= IDE/IAR-EWARM/source/main.c
8 | EXTRA_DIST+= IDE/IAR-EWARM/source/tpm_main.c
9 | EXTRA_DIST+= IDE/IAR-EWARM/header/tpm_main.h
10 |
--------------------------------------------------------------------------------
/IDE/IAR-EWARM/source/main.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "tpm_main.h"
4 |
5 | int main()
6 | {
7 | int ret;
8 |
9 | //---------------------------------------------------------------------------
10 | // TPM Example
11 | ret = TPM2_Cust_Example(NULL);
12 |
13 | return ret;
14 | }
15 |
--------------------------------------------------------------------------------
/IDE/OPENSTM32/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | wolfSTM32_CubeMX
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
25 | fr.ac6.mcu.ide.core.MCUProjectNature
26 |
27 |
28 |
29 | wolfTPM
30 | 2
31 | virtual:/virtual
32 |
33 |
34 | wolfTPM/examples
35 | 2
36 | WORKSPACE_LOC/examples
37 |
38 |
39 | wolfTPM/include
40 | 2
41 | WORKSPACE_LOC/wolftpm
42 |
43 |
44 | wolfTPM/src
45 | 2
46 | WORKSPACE_LOC/src
47 |
48 |
49 |
50 |
51 | 1518128563380
52 | wolfTPM/examples
53 | 5
54 |
55 | org.eclipse.ui.ide.multiFilter
56 | 1.0-name-matches-false-false-*.c
57 |
58 |
59 |
60 | 1518128563383
61 | wolfTPM/examples
62 | 5
63 |
64 | org.eclipse.ui.ide.multiFilter
65 | 1.0-name-matches-false-false-*.h
66 |
67 |
68 |
69 | 1518044338192
70 | wolfTPM/include
71 | 5
72 |
73 | org.eclipse.ui.ide.multiFilter
74 | 1.0-name-matches-false-false-*.h
75 |
76 |
77 |
78 | 1518044304150
79 | wolfTPM/src
80 | 5
81 |
82 | org.eclipse.ui.ide.multiFilter
83 | 1.0-name-matches-false-false-*.c
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/IDE/OPENSTM32/Inc/wolftpm_example.h:
--------------------------------------------------------------------------------
1 | /* wolftpm_example.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 |
23 | #ifndef WOLFTPM_EXAMPLE_H_
24 | #define WOLFTPM_EXAMPLE_H_
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | #ifndef WOLFSSL_USER_SETTINGS
31 | #include
32 | #endif
33 | #include
34 | #include
35 | #include
36 | #include
37 |
38 | #include
39 |
40 | void wolfTPMDemo(void const * argument);
41 |
42 |
43 | #endif /* WOLFTPM_EXAMPLE_H_ */
44 |
--------------------------------------------------------------------------------
/IDE/OPENSTM32/README.md:
--------------------------------------------------------------------------------
1 | # wolfSSL STM32F2/F4 Example for Open STM32 Tools System Workbench
2 |
3 |
4 | ## Requirements
5 |
6 | * STM32CubeMX: STM32 CubeMX HAL code generation tool - [http://www.st.com/en/development-tools/stm32cubemx.html](http://www.st.com/en/development-tools/stm32cubemx.html)
7 | * SystemWorkbench for STM32 - [http://www.st.com/en/development-tools/sw4stm32.html](http://www.st.com/en/development-tools/sw4stm32.html)
8 |
9 | ## Setup
10 |
11 | 1. Using the STM32CubeMX tool, load the `/IDE/OPENSTM32/wolfSTM32.ino` file.
12 | 2. Adjust the HAL options based on your specific micro-controller.
13 | 3. Generate source code.
14 | 4. Run `SystemWorkbench` and choose a new workspace location for this project.
15 | 5. Import `wolfSTM32' project from `/IDE/OPENSTM32/`.
16 | 6. Adjust the micro-controller define in `Project Settings -> C/C++ General -> Paths and Symbols -> Symbols -> GNU C`. Example uses `STM32F437xx`, but should be changed to reflect your micro-controller type.
17 | 7. Build and Run
18 |
19 | Note: You may need to manually copy over the CubeMX HAL files for `stm32f4xx_hal_cryp.c`, `stm32f4xx_hal_cryp_ex.c`, `stm32f4xx_hal_cryp.h`, `stm32f4xx_hal_cryp_ex.h`. Also uncomment the `#define HAL_CRYP_MODULE_ENABLED` line in `stm32f4xx_hal_conf.h`.
20 |
21 | ## Configuration
22 |
23 | The settings for the wolfSTM32 project are located in `/IDE/OPENSTM32/Inc/user_settings.h`.
24 |
25 | ## Support
26 |
27 | For questions please email [support@wolfssl.com](mailto:support@wolfssl.com)
--------------------------------------------------------------------------------
/IDE/OPENSTM32/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # included from Top Level Makefile.am
3 | # All paths should be given relative to the root
4 |
5 | EXTRA_DIST+= IDE/OPENSTM32/README.md
6 | EXTRA_DIST+= IDE/OPENSTM32/.cproject
7 | EXTRA_DIST+= IDE/OPENSTM32/.project
8 | EXTRA_DIST+= IDE/OPENSTM32/wolfSTM32.cfg
9 | EXTRA_DIST+= IDE/OPENSTM32/wolfSTM32.ioc
10 | EXTRA_DIST+= IDE/OPENSTM32/wolfSTM32.xml
11 | EXTRA_DIST+= IDE/OPENSTM32/Src/main.c
12 | EXTRA_DIST+= IDE/OPENSTM32/Src/wolftpm_example.c
13 | EXTRA_DIST+= IDE/OPENSTM32/Inc/user_settings.h
14 | EXTRA_DIST+= IDE/OPENSTM32/Inc/wolftpm_example.h
15 |
--------------------------------------------------------------------------------
/IDE/OPENSTM32/wolfSTM32.cfg:
--------------------------------------------------------------------------------
1 | # This is an wolfSTM32 board with a single STM32F437IIHx chip.
2 | # Generated by System Workbench for STM32
3 |
4 | source [find interface/stlink-v2-1.cfg]
5 |
6 | set WORKAREASIZE 0x30000
7 | transport select "hla_jtag"
8 | set CPUTAPID 0x4ba00477
9 |
10 | source [find target/stm32f4x_stlink.cfg]
11 |
12 | # use hardware reset, connect under reset
13 | reset_config srst_only srst_nogate
14 |
--------------------------------------------------------------------------------
/IDE/OPENSTM32/wolfSTM32.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | wolfSTM32
5 | stm32f437iihx
6 | JTAG
7 | ST-LinkV2-1
8 |
9 |
10 |
--------------------------------------------------------------------------------
/IDE/QNX/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # included from Top Level Makefile.am
3 | # All paths should be given relative to the root
4 |
5 | EXTRA_DIST+= IDE/QNX/README.md
6 |
--------------------------------------------------------------------------------
/IDE/STM32CUBE/README.md:
--------------------------------------------------------------------------------
1 | # wolfTPM for STM32 Cube IDE
2 |
3 | The wolfTPM Cube Pack can be found [here](https://www.wolfssl.com/files/ide/I-CUBE-wolfTPM.pack) and has an optional (and recommended) dependency on the `wolfCrypt` library.
4 |
5 | 1. The first step is to set up the wolfCrypt library in your ST project following the guide here [https://github.com/wolfSSL/wolfssl/blob/master/IDE/STM32Cube/README.md](https://github.com/wolfSSL/wolfssl/blob/master/IDE/STM32Cube/README.md). To run the wolfTPM unit tests, name the entry function `wolfTPMTest` instead of `wolfCryptDemo`.
6 |
7 | 2. Then install the wolfTPM Cube Pack in the same manner as the wolfSSL pack with CUBEMX.
8 |
9 | 3. Open the project `.ioc` file and click the `Software Packs` drop down menu and then `Select Components`. Expand the `wolfTPM` pack and check all the components.
10 |
11 | 4. In the `Software Packs` configuration category of the `.ioc` file, click on the wolfTPM pack and enable the library by checking the box.
12 |
13 | 5. In the `Connectivity` category, find and enable SPI for you project.
14 |
15 | 6. In the `Software Packs` configuration category, open the wolfTPM pack and set `Enable wolfCrypt` parameter to True.
16 |
17 | 7. Save your changes and select yes to the prompt asking about generating code.
18 |
19 | 8. Build the project and run the unit tests.
20 |
21 | ## Notes
22 | - Make sure to make [these changes](https://github.com/wolfSSL/wolfssl/tree/master/IDE/STM32Cube#stm32-printf) to redirect the printf's to the UART.
23 |
24 |
--------------------------------------------------------------------------------
/IDE/STM32CUBE/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # included from Top Level Makefile.am
3 | # All paths should be given relative to the root
4 |
5 | EXTRA_DIST+= IDE/STM32CUBE/wolftpm_test.c
6 | EXTRA_DIST+= IDE/STM32CUBE/wolftpm_test.h
7 | EXTRA_DIST+= IDE/STM32CUBE/README.md
8 | EXTRA_DIST+= IDE/STM32CUBE/default_conf.ftl
9 |
--------------------------------------------------------------------------------
/IDE/STM32CUBE/wolftpm_test.c:
--------------------------------------------------------------------------------
1 | /* wolftpm_test.c
2 | *
3 | * Copyright (C) 2014-2023 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with wolfTPM. If not, see .
19 | */
20 |
21 | #ifdef HAVE_CONFIG_H
22 | #include
23 | #endif
24 | #include "wolftpm_test.h"
25 |
26 | #ifndef SINGLE_THREADED
27 | #include
28 |
29 | #ifdef WOLFSSL_DEBUG_MEMORY
30 | /* for memory debugging */
31 | #include
32 | #endif
33 | #endif
34 |
35 | #include
36 | #include
37 |
38 | extern int TPM2_Wrapper_Test(void* userCtx);
39 |
40 | #ifdef CMSIS_OS2_H_
41 | void wolfTPMTest(void* argument)
42 | #else
43 | void wolfTPMTest(const void* argument)
44 | #endif
45 | {
46 | int ret = 0;
47 |
48 | printf("Running wolfTPM Wrap Test...\n");
49 |
50 | /* Run wolfTPM wrap test */
51 | ret = TPM2_Wrapper_Test((void*)argument);
52 |
53 | printf("wolfTPM wrap test: Return code %d\n", ret);
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/IDE/STM32CUBE/wolftpm_test.h:
--------------------------------------------------------------------------------
1 | /* wolftpm_test.h
2 | *
3 | * Copyright (C) 2014-2023 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with wolfTPM. If not, see .
19 | */
20 |
21 | #ifndef WOLFTPM_TEST_H_
22 | #define WOLFTPM_TEST_H_
23 |
24 | #include
25 |
26 | #ifndef SINGLE_THREADED
27 | #include
28 | #endif
29 |
30 | #ifdef CMSIS_OS2_H_
31 | void wolfTPMTest(void* argument);
32 | #else
33 | void wolfTPMTest(void const * argument);
34 | #endif
35 |
36 | #endif /* WOLFTPM_TEST_H_ */
37 |
--------------------------------------------------------------------------------
/IDE/VisualStudio/README.md:
--------------------------------------------------------------------------------
1 | # Visual Studio Solution for wolfTPM
2 |
3 | This includes projects for building wolfssl, wolftpm and some examples. The solution and project are based on older VS 2015, but can be retargeted / updated to newer when opened.
4 |
5 | All build settings are contained in IDE/VisualStudio/user_settings.h. This module supports using the FIPS ready bundle from the website. Just enable the `#if 0` FIPS section in user_settings.h. See wolfssl/IDE/WIN10/README.txt for details on setting the FIPS integrity check in fips_test.c at run-time.
6 |
7 | These projects assume `wolftpm` and `wolfssl` directories reside next to each other.
8 |
--------------------------------------------------------------------------------
/IDE/VisualStudio/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # included from Top Level Makefile.am
3 | # All paths should be given relative to the root
4 |
5 | EXTRA_DIST+= IDE/VisualStudio/README.md
6 | EXTRA_DIST+= IDE/VisualStudio/wolftpm.sln
7 | EXTRA_DIST+= IDE/VisualStudio/wolftpm.vcxproj
8 | EXTRA_DIST+= IDE/VisualStudio/wolfssl.vcxproj
9 | EXTRA_DIST+= IDE/VisualStudio/wolfcrypt_test.vcxproj
10 | EXTRA_DIST+= IDE/VisualStudio/tls_server.vcxproj
11 | EXTRA_DIST+= IDE/VisualStudio/wrap_test.vcxproj
12 | EXTRA_DIST+= IDE/VisualStudio/user_settings.h
13 |
--------------------------------------------------------------------------------
/IDE/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # included from Top Level Makefile.am
3 | # All paths should be given relative to the root
4 |
5 | include IDE/STM32CUBE/include.am
6 | include IDE/OPENSTM32/include.am
7 | include IDE/IAR-EWARM/include.am
8 | include IDE/QNX/include.am
9 | include IDE/VisualStudio/include.am
10 | include IDE/Espressif/include.am
11 |
--------------------------------------------------------------------------------
/Makefile.am:
--------------------------------------------------------------------------------
1 | # includes append to these:
2 | SUFFIXES =
3 | TESTS =
4 | CLEANFILES =
5 | DISTCLEANFILES =
6 | bin_PROGRAMS =
7 | noinst_HEADERS =
8 | lib_LTLIBRARIES =
9 | man_MANS =
10 | noinst_LTLIBRARIES =
11 | noinst_PROGRAMS =
12 | include_HEADERS =
13 | nobase_include_HEADERS =
14 | check_PROGRAMS =
15 | EXTRA_HEADERS =
16 | BUILT_SOURCES =
17 | EXTRA_DIST =
18 | noinst_SCRIPTS =
19 | check_SCRIPTS =
20 | dist_noinst_SCRIPTS =
21 | dist_doc_DATA =
22 |
23 |
24 | #includes additional rules from aminclude.am
25 | @INC_AMINCLUDE@
26 | DISTCLEANFILES+= aminclude.am
27 |
28 | # make sure we pass the correct flags to distcheck
29 | AM_DISTCHECK_CONFIGURE_FLAGS = --enable-swtpm
30 |
31 | exampledir = $(docdir)/example
32 | dist_example_DATA=
33 |
34 | ACLOCAL_AMFLAGS= -I m4
35 |
36 |
37 | include src/include.am
38 | include wolftpm/include.am
39 | include examples/include.am
40 | include scripts/include.am
41 | include IDE/include.am
42 | include certs/include.am
43 | include tests/include.am
44 | include docs/include.am
45 | include wrapper/include.am
46 | include hal/include.am
47 | include cmake/include.am
48 | include zephyr/include.am
49 |
50 | EXTRA_DIST+= .cyignore
51 | EXTRA_DIST+= README.md
52 | EXTRA_DIST+= ChangeLog.md
53 | EXTRA_DIST+= LICENSE
54 | EXTRA_DIST+= autogen.sh
55 | EXTRA_DIST+= CMakeLists.txt
56 |
57 | TEST_EXTENSIONS=.test
58 | TESTS += $(check_PROGRAMS)
59 |
60 | check_SCRIPTS+= $(dist_noinst_SCRIPTS)
61 | TESTS += $(check_SCRIPTS)
62 |
63 | test: check
64 |
65 | DISTCLEANFILES+= wolftpm-config
66 |
67 |
68 | maintainer-clean-local:
69 | -rm Makefile.in
70 | -rm aclocal.m4
71 | -rm build-aux/compile
72 | -rm build-aux/config.guess
73 | -rm build-aux/config.sub
74 | -rm build-aux/depcomp
75 | -rm build-aux/install-sh
76 | -rm build-aux/ltmain.sh
77 | -rm build-aux/missing
78 | -rm wolftpm-config
79 | -rmdir build-aux
80 | -rm configure
81 | -rm config.log
82 | -rm config.status
83 | -rm config.in
84 | -rm m4/libtool.m4
85 | -rm m4/ltoptions.m4
86 | -rm m4/ltsugar.m4
87 | -rm m4/ltversion.m4
88 | -rm m4/lt~obsolete.m4
89 | find . -type f -name '*~' -exec rm -f '{}' \;
90 | -rm -f @PACKAGE@-*.tar.gz
91 | -rm -f @PACKAGE@-*.rpm
92 |
93 | # !!!! first line of rule has to start with a hard (real) tab, not spaces
94 | egs:
95 | $(MAKE) examples/tpm/tpm2_demo;
96 |
97 | install-exec-local: install-generic-config
98 |
99 | install-generic-config:
100 | $(mkinstalldirs) $(DESTDIR)$(bindir)
101 | $(INSTALL_SCRIPT) @GENERIC_CONFIG@ $(DESTDIR)$(bindir)
102 |
103 | uninstall-local:
104 | -rm -f $(DESTDIR)$(bindir)/@GENERIC_CONFIG@
105 |
106 | merge-clean:
107 | @find ./ | $(GREP) \.gcda | xargs rm -f
108 | @find ./ | $(GREP) \.gcno | xargs rm -f
109 | @find ./ | $(GREP) \.gz | xargs rm -f
110 | @find ./ | $(GREP) \.orig | xargs rm -f
111 | @find ./ | $(GREP) \.rej | xargs rm -f
112 | @find ./ | $(GREP) \.rpm | xargs rm -f
113 | @find ./ | $(GREP) \.THIS | xargs rm -f
114 | @find ./ | $(GREP) \.OTHER | xargs rm -f
115 | @find ./ | $(GREP) \.BASE | xargs rm -f
116 | @find ./ | $(GREP) \~$$ | xargs rm -f
117 |
--------------------------------------------------------------------------------
/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Create configure and makefile stuff...
4 | #
5 |
6 | set -e
7 |
8 | # Check environment
9 | if [ -n "$WSL_DISTRO_NAME" ]; then
10 | # we found a non-blank WSL environment distro name
11 | current_path="$(pwd)"
12 | pattern="/mnt/?"
13 | if [ "$(echo "$current_path" | grep -E "^$pattern")" ]; then
14 | # if we are in WSL and shared Windows file system, 'ln' does not work.
15 | no_links=true
16 | else
17 | no_links=
18 | fi
19 | fi
20 |
21 | # if get an error about libtool not setup
22 | # " error: Libtool library used but 'LIBTOOL' is undefined
23 | # The usual way to define 'LIBTOOL' is to add 'LT_INIT' "
24 | # manually call libtoolize or glibtoolize before running this again
25 | # (g)libtoolize
26 |
27 | # if you get an error about config.rpath missing, some buggy automake versions
28 | # then touch the missing file (may need to make config/ first).
29 | # touch config/config.rpath
30 | # touch config.rpath
31 |
32 | if test ! -d build-aux; then
33 | echo "Making missing build-aux directory."
34 | mkdir -p build-aux
35 | fi
36 |
37 | if test ! -f build-aux/config.rpath; then
38 | echo "Touching missing build-aux/config.rpath file."
39 | touch build-aux/config.rpath
40 | fi
41 |
42 |
43 | # If this is a source checkout then call autoreconf with error as well
44 | if [ -e .git ]; then
45 | export WARNINGS="all,error"
46 | else
47 | export WARNINGS="all"
48 | fi
49 |
50 | autoreconf --install --force --verbose
51 |
--------------------------------------------------------------------------------
/certs/ca-ecc.cnf:
--------------------------------------------------------------------------------
1 | [ ca ]
2 | # `man ca`
3 | default_ca = CA_default
4 |
5 | [ CA_default ]
6 | # Directory and file locations.
7 | dir = .
8 | certs = $dir/certs
9 | new_certs_dir = $dir/certs
10 | database = $dir/certs/index.txt
11 | serial = $dir/certs/serial
12 | RANDFILE = $dir/private/.rand
13 |
14 | # The root key and root certificate.
15 | private_key = $dir/certs/ca-ecc-key.pem
16 | certificate = $dir/certs/ca-ecc-cert.pem
17 |
18 | # For certificate revocation lists.
19 | crlnumber = $dir/certs/crlnumber
20 | crl_extensions = crl_ext
21 | default_crl_days = 1000
22 |
23 | # SHA-1 is deprecated, so use SHA-2 instead.
24 | default_md = sha256
25 |
26 | name_opt = ca_default
27 | cert_opt = ca_default
28 | default_days = 3650
29 | preserve = no
30 | policy = policy_loose
31 | unique_subject = no
32 |
33 | [ policy_strict ]
34 | # The root CA should only sign intermediate certificates that match.
35 | # See the POLICY FORMAT section of `man ca`.
36 | countryName = match
37 | stateOrProvinceName = match
38 | organizationName = match
39 | organizationalUnitName = optional
40 | commonName = supplied
41 | emailAddress = optional
42 |
43 | [ policy_loose ]
44 | # Allow the intermediate CA to sign a more diverse range of certificates.
45 | # See the POLICY FORMAT section of the `ca` man page.
46 | countryName = optional
47 | stateOrProvinceName = optional
48 | localityName = optional
49 | organizationName = optional
50 | organizationalUnitName = optional
51 | commonName = supplied
52 | emailAddress = optional
53 |
54 | [ req ]
55 | # Options for the `req` tool (`man req`).
56 | default_bits = 2048
57 | distinguished_name = req_distinguished_name
58 | string_mask = utf8only
59 |
60 | # SHA-1 is deprecated, so use SHA-2 instead.
61 | default_md = sha256
62 |
63 | # Extension to add when the -x509 option is used.
64 | x509_extensions = v3_ca
65 |
66 | [ req_distinguished_name ]
67 | countryName = US
68 | stateOrProvinceName = Washington
69 | localityName = Seattle
70 | 0.organizationName = wolfSSL
71 | organizationalUnitName = Development
72 | commonName = www.wolfssl.com
73 | emailAddress = info@wolfssl.com
74 |
75 | [ v3_ca ]
76 | # Extensions for a typical CA (`man x509v3_config`).
77 | subjectKeyIdentifier = hash
78 | authorityKeyIdentifier = keyid:always,issuer
79 | basicConstraints = critical, CA:true
80 | keyUsage = critical, digitalSignature, cRLSign, keyCertSign
81 |
82 | [ v3_intermediate_ca ]
83 | # Extensions for a typical intermediate CA (`man x509v3_config`).
84 | subjectKeyIdentifier = hash
85 | authorityKeyIdentifier = keyid:always,issuer
86 | basicConstraints = critical, CA:true, pathlen:0
87 | keyUsage = critical, digitalSignature, cRLSign, keyCertSign
88 |
89 | [ usr_cert ]
90 | # Extensions for client certificates (`man x509v3_config`).
91 | basicConstraints = CA:FALSE
92 | nsCertType = client, email
93 | subjectKeyIdentifier = hash
94 | authorityKeyIdentifier = keyid,issuer
95 | keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment
96 | extendedKeyUsage = clientAuth, emailProtection
97 |
98 | [ server_cert ]
99 | # Extensions for server certificates (`man x509v3_config`).
100 | basicConstraints = CA:FALSE
101 | nsCertType = server
102 | subjectKeyIdentifier = hash
103 | subjectAltName=IP:127.0.0.1
104 | authorityKeyIdentifier = keyid,issuer:always
105 | keyUsage = critical, digitalSignature, keyEncipherment, keyAgreement
106 | extendedKeyUsage = serverAuth
107 |
108 | [ crl_ext ]
109 | # Extension for CRLs (`man x509v3_config`).
110 | authorityKeyIdentifier=keyid:always
111 |
--------------------------------------------------------------------------------
/certs/ca-rsa.cnf:
--------------------------------------------------------------------------------
1 | [ ca ]
2 | # `man ca`
3 | default_ca = CA_default
4 |
5 | [ CA_default ]
6 | # Directory and file locations.
7 | dir = .
8 | certs = $dir/certs
9 | new_certs_dir = $dir/certs
10 | database = $dir/certs/index.txt
11 | serial = $dir/certs/serial
12 | RANDFILE = $dir/private/.rand
13 |
14 | # The root key and root certificate.
15 | private_key = $dir/certs/ca-rsa-key.pem
16 | certificate = $dir/certs/ca-rsa-cert.pem
17 |
18 | # For certificate revocation lists.
19 | crlnumber = $dir/certs/crlnumber
20 | crl_extensions = crl_ext
21 | default_crl_days = 1000
22 |
23 | # SHA-1 is deprecated, so use SHA-2 instead.
24 | default_md = sha256
25 |
26 | name_opt = ca_default
27 | cert_opt = ca_default
28 | default_days = 3650
29 | preserve = no
30 | policy = policy_loose
31 | unique_subject = no
32 |
33 | [ policy_strict ]
34 | # The root CA should only sign intermediate certificates that match.
35 | # See the POLICY FORMAT section of `man ca`.
36 | countryName = match
37 | stateOrProvinceName = match
38 | organizationName = match
39 | organizationalUnitName = optional
40 | commonName = supplied
41 | emailAddress = optional
42 |
43 | [ policy_loose ]
44 | # Allow the intermediate CA to sign a more diverse range of certificates.
45 | # See the POLICY FORMAT section of the `ca` man page.
46 | countryName = optional
47 | stateOrProvinceName = optional
48 | localityName = optional
49 | organizationName = optional
50 | organizationalUnitName = optional
51 | commonName = supplied
52 | emailAddress = optional
53 |
54 | [ req ]
55 | # Options for the `req` tool (`man req`).
56 | default_bits = 2048
57 | distinguished_name = req_distinguished_name
58 | string_mask = utf8only
59 |
60 | # SHA-1 is deprecated, so use SHA-2 instead.
61 | default_md = sha256
62 |
63 | # Extension to add when the -x509 option is used.
64 | x509_extensions = v3_ca
65 |
66 | [ req_distinguished_name ]
67 | countryName = US
68 | stateOrProvinceName = Washington
69 | localityName = Seattle
70 | 0.organizationName = wolfSSL
71 | organizationalUnitName = Development
72 | commonName = www.wolfssl.com
73 | emailAddress = info@wolfssl.com
74 |
75 | [ v3_ca ]
76 | # Extensions for a typical CA (`man x509v3_config`).
77 | subjectKeyIdentifier = hash
78 | authorityKeyIdentifier = keyid:always,issuer
79 | basicConstraints = critical, CA:true
80 | keyUsage = critical, digitalSignature, cRLSign, keyCertSign
81 |
82 | [ v3_intermediate_ca ]
83 | # Extensions for a typical intermediate CA (`man x509v3_config`).
84 | subjectKeyIdentifier = hash
85 | authorityKeyIdentifier = keyid:always,issuer
86 | basicConstraints = critical, CA:true, pathlen:0
87 | keyUsage = critical, digitalSignature, cRLSign, keyCertSign
88 |
89 | [ usr_cert ]
90 | # Extensions for client certificates (`man x509v3_config`).
91 | basicConstraints = CA:FALSE
92 | nsCertType = client, email
93 | subjectKeyIdentifier = hash
94 | authorityKeyIdentifier = keyid,issuer
95 | keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment
96 | extendedKeyUsage = clientAuth, emailProtection
97 |
98 | [ server_cert ]
99 | # Extensions for server certificates (`man x509v3_config`).
100 | basicConstraints = CA:FALSE
101 | nsCertType = server
102 | subjectKeyIdentifier = hash
103 | subjectAltName=IP:127.0.0.1
104 | authorityKeyIdentifier = keyid,issuer:always
105 | keyUsage = critical, digitalSignature, keyEncipherment, keyAgreement
106 | extendedKeyUsage = serverAuth
107 |
108 | [ crl_ext ]
109 | # Extension for CRLs (`man x509v3_config`).
110 | authorityKeyIdentifier=keyid:always
111 |
--------------------------------------------------------------------------------
/certs/example-ecc256-key-pub.der:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wolfSSL/wolfTPM/bd682553ac45c4537dc5790da9cb0acb62bc844c/certs/example-ecc256-key-pub.der
--------------------------------------------------------------------------------
/certs/example-ecc256-key-pub.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN PUBLIC KEY-----
2 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuzOsTCdQSsZKpQTDPN6fNttyLc6U
3 | 6iv6yyAJOSwW6GEC6a9N0wKTmjFbl5Ihf/DPGNqREQI0huggWDMLgDSJ2A==
4 | -----END PUBLIC KEY-----
5 |
--------------------------------------------------------------------------------
/certs/example-ecc256-key.der:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wolfSSL/wolfTPM/bd682553ac45c4537dc5790da9cb0acb62bc844c/certs/example-ecc256-key.der
--------------------------------------------------------------------------------
/certs/example-ecc256-key.pem:
--------------------------------------------------------------------------------
1 | ASN1 OID: prime256v1
2 | -----BEGIN EC PARAMETERS-----
3 | BggqhkjOPQMBBw==
4 | -----END EC PARAMETERS-----
5 | -----BEGIN EC PRIVATE KEY-----
6 | MHcCAQEEIEW2aQJznGyFoThbcujox6zEA41TNQT6bCjcNI3hqAmMoAoGCCqGSM49
7 | AwEHoUQDQgAEuzOsTCdQSsZKpQTDPN6fNttyLc6U6iv6yyAJOSwW6GEC6a9N0wKT
8 | mjFbl5Ihf/DPGNqREQI0huggWDMLgDSJ2A==
9 | -----END EC PRIVATE KEY-----
10 |
--------------------------------------------------------------------------------
/certs/example-ecc384-key-pub.der:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wolfSSL/wolfTPM/bd682553ac45c4537dc5790da9cb0acb62bc844c/certs/example-ecc384-key-pub.der
--------------------------------------------------------------------------------
/certs/example-ecc384-key-pub.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN PUBLIC KEY-----
2 | MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE6s+TTywJuzkUD1Zkw0C03w5jruVxSwDM
3 | BJf/4ek4lrtfkbJqzLU5X49wWfEB9lorAWxoC89VJa9tmEgKqHTJqRegDMP70yNo
4 | /gQ8Y1CIO7lPfGc09zupc+cbw1FeIhjs
5 | -----END PUBLIC KEY-----
6 |
--------------------------------------------------------------------------------
/certs/example-ecc384-key.der:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wolfSSL/wolfTPM/bd682553ac45c4537dc5790da9cb0acb62bc844c/certs/example-ecc384-key.der
--------------------------------------------------------------------------------
/certs/example-ecc384-key.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN PRIVATE KEY-----
2 | MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDCk5QboBhY+q4n4YEPA
3 | YCXbunv+GTUIVWV24tzgAYtraN/Pb4ASznk36yuce8RoHHShZANiAATqz5NPLAm7
4 | ORQPVmTDQLTfDmOu5XFLAMwEl//h6TiWu1+RsmrMtTlfj3BZ8QH2WisBbGgLz1Ul
5 | r22YSAqodMmpF6AMw/vTI2j+BDxjUIg7uU98ZzT3O6lz5xvDUV4iGOw=
6 | -----END PRIVATE KEY-----
7 |
--------------------------------------------------------------------------------
/certs/example-rsa2048-key-pub.der:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wolfSSL/wolfTPM/bd682553ac45c4537dc5790da9cb0acb62bc844c/certs/example-rsa2048-key-pub.der
--------------------------------------------------------------------------------
/certs/example-rsa2048-key-pub.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN PUBLIC KEY-----
2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnj22EdUiGQC/9vBWG4Kc
3 | cpxDYLxwAjPS3M2Z7IFZGWMcdzvQ022tlU8YTDdtYv2qHCQs2Qd+ar8/kYnJMr1g
4 | ajw12riRJ/YnD14EpJ6sc8NGQE8y9MG6v05OU/qCExRQhifP22haJLTiroj+R+dA
5 | 8el9ltajR4i5GxquzW1xwPGBtsMyvZMIpKMEl0FQe6WeW4I1tqu97yBkrHlvNNn+
6 | yP99MG3+KEdb35ODkLq7E/bJdghSzbeWyUsOpRU5uAToAu0N26Rz8wv2CrhWFihn
7 | kC/RgrBGVVhwjOr83pOkjcENHqENIvSLhdKLP9JyQ8HVxGV/TqAYRU+9e7L5cQ16
8 | RQIDAQAB
9 | -----END PUBLIC KEY-----
10 |
--------------------------------------------------------------------------------
/certs/example-rsa2048-key.der:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wolfSSL/wolfTPM/bd682553ac45c4537dc5790da9cb0acb62bc844c/certs/example-rsa2048-key.der
--------------------------------------------------------------------------------
/certs/example-rsa2048-key.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN PRIVATE KEY-----
2 | MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCePbYR1SIZAL/2
3 | 8FYbgpxynENgvHACM9LczZnsgVkZYxx3O9DTba2VTxhMN21i/aocJCzZB35qvz+R
4 | ickyvWBqPDXauJEn9icPXgSknqxzw0ZATzL0wbq/Tk5T+oITFFCGJ8/baFoktOKu
5 | iP5H50Dx6X2W1qNHiLkbGq7NbXHA8YG2wzK9kwikowSXQVB7pZ5bgjW2q73vIGSs
6 | eW802f7I/30wbf4oR1vfk4OQursT9sl2CFLNt5bJSw6lFTm4BOgC7Q3bpHPzC/YK
7 | uFYWKGeQL9GCsEZVWHCM6vzek6SNwQ0eoQ0i9IuF0os/0nJDwdXEZX9OoBhFT717
8 | svlxDXpFAgMBAAECggEABYIV6Jx/5ZloVTbr9GSxP+8PDFq61mTJ6fwxJ7Gf8ZmI
9 | 1+Cp5fYrJOeeK6cBRIEabwTWV86iOKKEGrOOYJkFdmU2pbCngtnXZbpK1JUeYSAy
10 | vZHULv9gWgDmipdNeE8Md4MCwfspqh3uxw8HNOcIlHMhd0Ls55RLhzVAUO/GliXz
11 | 5HIDhohyQAUvPvkwz1yrPNn5BQwMlJBARc2OKSKf+pJrlFw1KJWR9TKzGvRzMbI4
12 | gwrq9BZ5LCX5y6C7BpuzXdySHXofwihPNmi1KU/88cWhas2E0Xz+p+N/ifmkquTN
13 | 3EqzqKBW+xobryM6X9JfQ6has211eUaZKNuU2/idKQKBgQC5rymu0UKHuAkr4uPS
14 | NLGmaWb4p+kDNxbVyzS2ENjtoJ6JyEo/pZQrTG4S/kCWFgGsuztCbx+1Kgk0Pgwi
15 | znaGvcfrjiP9XE1oVfMifA2JmH+drjASyjPqNfsf0BKQtlk0nZXwUO/C1FQ5vUU4
16 | lpmpx4EhTnucQ9E7r0+uXnQHTQKBgQDaKh4bBV7dLBF4ZxwCdydMMSZkBgckBiH7
17 | 83BvyLW6I0GKXcFTa7KKLgTj41pXeWh6bmM9365+Cr8fxTZop28EfGRYFBMp08/g
18 | wHpmS3NZ4moSgirJ+PhZsH+nBq89W75INR7BqV4SAc3n4lcwv9eBL9q0Q/YJZ1ph
19 | NCKvz79y2QKBgFyDFPVwdQFBg/BFntRARLJwmUkR/1oGvG3QTHbZdfsOp25mR/fl
20 | +yiHb+AupOciF7uDnUbALsAILYXF1C4TR6JiM5T8wJmev0JYcEaiH+yJ+isJehIi
21 | hDMQqglzlYxcDZ3VVbrh2FLtjvklf7Nt9SlNqNx7ScLVVw2xjrWFgbGRAoGBAMjo
22 | Wnsl0fu6Noh74/Z9RmpLJQCd8HuDTk6ZHCVFX91/1D6ZIo0xM+U+hfBbkfnWa5m8
23 | CJaVZDrcqK+YTQfJkVo/N6VJL3Coh9qBRvbnat4OvQI4bzE6n3LxME1fwYeu8ifL
24 | C3zq/R92G+n8rbDOKqbkq/KwV2bHkBrOCVeA6NzZAoGACztyZbS5jCuSlPqk/xoN
25 | EzX9Cev/GipF5tZMeOcQlty+anPg3TC70O06yZ1SIJKLzOOyoPCUDNrM2M5TCaau
26 | vT0vW1GeNAryc+q9aOmFT3AlZ93Tfst+90Q+NJecEEhkO43tU5S1ZK2iVf9XAOV6
27 | ovHegJU35IUeaoyg23HjFWU=
28 | -----END PRIVATE KEY-----
29 |
--------------------------------------------------------------------------------
/certs/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 | #
4 |
5 | EXTRA_DIST += \
6 | certs/certreq.sh \
7 | certs/ca-rsa.cnf \
8 | certs/ca-ecc.cnf \
9 | certs/wolf-ca-ecc-cert.pem \
10 | certs/wolf-ca-rsa-cert.pem \
11 | certs/example-rsa2048-key.pem \
12 | certs/example-rsa2048-key.der \
13 | certs/example-rsa2048-key-pub.pem \
14 | certs/example-rsa2048-key-pub.der \
15 | certs/example-ecc256-key.pem \
16 | certs/example-ecc256-key.der \
17 | certs/example-ecc256-key-pub.pem \
18 | certs/example-ecc256-key-pub.der \
19 | certs/example-ecc384-key.pem \
20 | certs/example-ecc384-key.der \
21 | certs/example-ecc384-key-pub.pem \
22 | certs/example-ecc384-key-pub.der
23 |
--------------------------------------------------------------------------------
/certs/wolf-ca-ecc-cert.pem:
--------------------------------------------------------------------------------
1 | Certificate:
2 | Data:
3 | Version: 3 (0x2)
4 | Serial Number:
5 | 0f:17:46:70:fd:c2:70:d1:f9:42:49:9c:1a:c3:5d:dd:30:c8:5f:85
6 | Signature Algorithm: ecdsa-with-SHA256
7 | Issuer: C = US, ST = Washington, L = Seattle, O = wolfSSL, OU = Development, CN = www.wolfssl.com, emailAddress = info@wolfssl.com
8 | Validity
9 | Not Before: Dec 13 22:19:28 2023 GMT
10 | Not After : Sep 8 22:19:28 2026 GMT
11 | Subject: C = US, ST = Washington, L = Seattle, O = wolfSSL, OU = Development, CN = www.wolfssl.com, emailAddress = info@wolfssl.com
12 | Subject Public Key Info:
13 | Public Key Algorithm: id-ecPublicKey
14 | Public-Key: (256 bit)
15 | pub:
16 | 04:02:d3:d9:6e:d6:01:8e:45:c8:b9:90:31:e5:c0:
17 | 4c:e3:9e:ad:29:38:98:ba:10:d6:e9:09:2a:80:a9:
18 | 2e:17:2a:b9:8a:bf:33:83:46:e3:95:0b:e4:77:40:
19 | b5:3b:43:45:33:0f:61:53:7c:37:44:c1:cb:fc:80:
20 | ca:e8:43:ea:a7
21 | ASN1 OID: prime256v1
22 | NIST CURVE: P-256
23 | X509v3 extensions:
24 | X509v3 Subject Key Identifier:
25 | 56:8E:9A:C3:F0:42:DE:18:B9:45:55:6E:F9:93:CF:EA:C3:F3:A5:21
26 | X509v3 Authority Key Identifier:
27 | keyid:56:8E:9A:C3:F0:42:DE:18:B9:45:55:6E:F9:93:CF:EA:C3:F3:A5:21
28 |
29 | X509v3 Basic Constraints: critical
30 | CA:TRUE
31 | X509v3 Key Usage: critical
32 | Digital Signature, Certificate Sign, CRL Sign
33 | Signature Algorithm: ecdsa-with-SHA256
34 | 30:45:02:21:00:c8:64:7f:ee:4b:be:83:48:13:ea:92:f8:1a:
35 | 82:1e:85:b1:5a:a4:1c:e3:e8:ea:25:44:6f:e7:70:fd:eb:f3:
36 | 76:02:20:44:02:a2:ec:c5:a1:ae:e2:a4:8a:d9:13:95:2b:a6:
37 | 5b:09:57:86:61:42:96:97:f0:95:62:0c:03:e6:53:04:25
38 | -----BEGIN CERTIFICATE-----
39 | MIIClTCCAjugAwIBAgIUDxdGcP3CcNH5QkmcGsNd3TDIX4UwCgYIKoZIzj0EAwIw
40 | gZcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRAwDgYDVQQHDAdT
41 | ZWF0dGxlMRAwDgYDVQQKDAd3b2xmU1NMMRQwEgYDVQQLDAtEZXZlbG9wbWVudDEY
42 | MBYGA1UEAwwPd3d3LndvbGZzc2wuY29tMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdv
43 | bGZzc2wuY29tMB4XDTIzMTIxMzIyMTkyOFoXDTI2MDkwODIyMTkyOFowgZcxCzAJ
44 | BgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRAwDgYDVQQHDAdTZWF0dGxl
45 | MRAwDgYDVQQKDAd3b2xmU1NMMRQwEgYDVQQLDAtEZXZlbG9wbWVudDEYMBYGA1UE
46 | AwwPd3d3LndvbGZzc2wuY29tMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdvbGZzc2wu
47 | Y29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAtPZbtYBjkXIuZAx5cBM456t
48 | KTiYuhDW6QkqgKkuFyq5ir8zg0bjlQvkd0C1O0NFMw9hU3w3RMHL/IDK6EPqp6Nj
49 | MGEwHQYDVR0OBBYEFFaOmsPwQt4YuUVVbvmTz+rD86UhMB8GA1UdIwQYMBaAFFaO
50 | msPwQt4YuUVVbvmTz+rD86UhMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD
51 | AgGGMAoGCCqGSM49BAMCA0gAMEUCIQDIZH/uS76DSBPqkvgagh6FsVqkHOPo6iVE
52 | b+dw/evzdgIgRAKi7MWhruKkitkTlSumWwlXhmFClpfwlWIMA+ZTBCU=
53 | -----END CERTIFICATE-----
54 |
--------------------------------------------------------------------------------
/cmake/README.md:
--------------------------------------------------------------------------------
1 | # wolfTPM CMake
2 |
3 | This directory contains some supplementary files for the [CMakeLists.txt](../CMakeLists.txt) in the root.
4 |
5 | See also cmake notes in the [INSTALL](../INSTALL) documentation file.
6 |
--------------------------------------------------------------------------------
/cmake/config.in:
--------------------------------------------------------------------------------
1 | /* Define to 1 if you have the header file. */
2 | #cmakedefine HAVE_FCNTL_H @HAVE_FCNTL_H@
3 |
4 | /* Define to 1 if you have the header file. */
5 | #cmakedefine HAVE_NETDB_H @HAVE_NETDB_H@
6 |
7 | /* Define to 1 if you have the header file. */
8 | #cmakedefine HAVE_TIME_H @HAVE_TIME_H@
9 |
10 | /* Define to 1 if you have the header file. */
11 | #cmakedefine HAVE_SYS_IOCTL_H @HAVE_SYS_IOCTL_H@
12 |
13 | /* Define to 1 if you have the header file. */
14 | #cmakedefine HAVE_SYS_SOCKET_H @HAVE_SYS_SOCKET_H@
15 |
16 | /* Define to 1 if you have the header file. */
17 | #cmakedefine HAVE_SYS_TIME_H @HAVE_SYS_TIME_H@
18 |
19 | /* Define to 1 if you have the header file. */
20 | #cmakedefine HAVE_ERRNO_H @HAVE_ERRNO_H@
21 |
22 | /* Define to 1 if you have the header file. */
23 | #cmakedefine HAVE_STDINT_H @HAVE_STDINT_H@
24 |
25 | /* Define to 1 if you have the header file. */
26 | #cmakedefine HAVE_STDLIB_H @HAVE_STDLIB_H@
27 |
28 | /* Define to 1 if you have the header file. */
29 | #cmakedefine HAVE_STRING_H @HAVE_STRING_H@
30 |
31 | /* Define to 1 if you have the header file. */
32 | #cmakedefine HAVE_SYS_STAT_H @HAVE_SYS_STAT_H@
33 |
34 | /* Define to 1 if you have the header file. */
35 | #cmakedefine HAVE_SYS_TYPES_H @HAVE_SYS_TYPES_H@
36 |
37 | /* Define to 1 if you have the header file. */
38 | #cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@
39 |
40 |
41 | /* Define to 1 if you have the `getaddrinfo' function. */
42 | #cmakedefine HAVE_GETADDRINFO @HAVE_GETADDRINFO@
43 |
44 | /* Define to 1 if you have the `gethostbyname' function. */
45 | #cmakedefine HAVE_GETHOSTBYNAME @HAVE_GETHOSTBYNAME@
46 |
47 | /* Define to 1 if you have the `gettimeofday' function. */
48 | #cmakedefine HAVE_GETTIMEOFDAY @HAVE_GETTIMEOFDAY@
49 |
--------------------------------------------------------------------------------
/cmake/include.am:
--------------------------------------------------------------------------------
1 | EXTRA_DIST += cmake/README.md
2 | EXTRA_DIST += cmake/config.in
3 |
--------------------------------------------------------------------------------
/commit-tests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #commit-tests.sh
4 |
5 |
6 | # make sure current config is ok
7 | echo -e "\n\nTesting current config...\n\n"
8 | make clean; make -j 8 test;
9 | RESULT=$?
10 | [ $RESULT -ne 0 ] && echo -e "\n\nCurrent config make test failed" && exit 1
11 |
12 |
13 | # make sure basic config is ok
14 | echo -e "\n\nTesting no TLS config too...\n\n"
15 | ./configure;
16 | RESULT=$?
17 | [ $RESULT -ne 0 ] && echo -e "\n\nTest './configure' failed" && exit 1
18 |
19 | make -j 8 test;
20 | RESULT=$?
21 | [ $RESULT -ne 0 ] && echo -e "\n\nTest './configure' make test failed " && exit 1
22 |
23 |
24 | exit 0
25 |
--------------------------------------------------------------------------------
/docs/WindowTBS.md:
--------------------------------------------------------------------------------
1 | # Using wolfTPM with Windows TBS
2 |
3 | wolfTPM can be built to use Windows native TBS (TPM Base Services)
4 |
5 | When using the Windows TBS interface the NV access is blocked by default. TPM NV storage space is very limited and when filled can cause undefined behaviors, such as failures loading key handles. These are not managed by TBS.
6 |
7 | The TPM is designed to return an encrypted private key blob on key creation using `TPM2_Create`, which you can safely store on the disk and load when needed. The symmetric encryption key used to protect the private key blob is only known by the TPM. When you load a key using `TPM2_Load` you get a transient handle, which can be used for signing and even encryption/decryption.
8 |
9 | For primary keys created with `TPM2_CreatePrimary` you get back a handle. There is no encrypted private data returned. That handle will remain loaded until `TPM2_FlushContext` is called.
10 |
11 | For normal key creation using `TPM2_Create` you get back a `TPM2B_PRIVATE outPrivate`, which is the encrypted blob that you can store and load anytime using `TPM2_Load`.
12 |
13 | ## Limitations
14 |
15 | wolfTPM has been tested on Windows 10 with TPM 2.0 devices. While
16 | Windows does support TPM 1.2, functionality is limited and not
17 | supported by wolfTPM.
18 |
19 | Presence of TPM 2.0 can be checked by opening PowerShell
20 | and running `Get-PnpDevice -Class SecurityDevices`
21 |
22 | ```
23 | Status Class FriendlyName
24 | ------ ----- ------------
25 | OK SecurityDevices Trusted Platform Module 2.0
26 | Unknown SecurityDevices Trusted Platform Module 2.0
27 | ```
28 |
29 | ## Building in MSYS2
30 |
31 | Tested using MSYS2
32 |
33 | ```
34 | export PREFIX=$PWD/tmp_install
35 |
36 | cd wolfssl
37 | ./autogen.sh
38 | ./configure --prefix="$PREFIX" --enable-wolftpm
39 | make
40 | make install
41 |
42 | cd wolftpm/
43 | ./autogen.sh
44 | ./configure --prefix="$PREFIX" --enable-winapi
45 | make
46 | ./examples
47 | ```
48 |
49 | Note: To install the development base tools on MSYS2 use: `pacman -s base-devel` and `pacman -S mingw-w64-x86_64-toolchain`.
50 |
51 | ## Building on linux
52 |
53 | Tested using mingw-w32-bin_x86_64-linux_20131221.tar.bz2
54 | [source](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Automated%20Builds/)
55 |
56 | Extract the tools and add them to the `PATH`
57 | ```
58 | mkdir mingw_tools
59 | cd mingw_tools
60 | tar xjvf ../mingw-w32-bin_x86_64-linux_20131221.tar.bz2
61 | export PATH=$PWD/bin/:$PWD/i686-w64-mingw32/bin:$PATH
62 | cd ..
63 | ```
64 |
65 | Build
66 | ```
67 | export PREFIX=$PWD/tmp_install
68 | export CFLAGS="-DWIN32 -DMINGW -D_WIN32_WINNT=0x0600 -DUSE_WOLF_STRTOK"
69 | export LIBS="-lws2_32"
70 |
71 | cd wolfssl
72 | ./autogen.sh
73 | ./configure --host=i686 CC=i686-w64-mingw32-gcc --prefix="$PREFIX" --enable-wolftpm
74 | make
75 | make install
76 |
77 | cd ../wolftpm/
78 | ./autogen.sh
79 | ./configure --host=i686 CC=i686-w64-mingw32-gcc --prefix="$PREFIX" --enable-winapi
80 | make
81 | cd ..
82 | ```
83 |
84 | ## Running on Windows
85 |
86 | To confirm presence and status of TPM on the machine run `tpm.msc`
87 |
88 | See [examples/README.md](/examples/README.md)
89 |
--------------------------------------------------------------------------------
/docs/generate_documentation.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | CURRDIR=${PWD##*/}
4 | if [ "$CURRDIR" = "docs" ]; then
5 | echo "Please run from the wolfTPM root directory"
6 | exit 1
7 | fi
8 |
9 | # Run from ./docs
10 | echo "Generating html..."
11 | doxygen ./docs/Doxyfile
12 | echo "Finished generating html..."
13 |
14 | echo "To view the html files use a browser to open the index.html file located at docs/html/index.html"
15 |
--------------------------------------------------------------------------------
/docs/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # included from Top Level Makefile.am
3 | # All paths should be given relative to the root
4 |
5 | dist_doc_DATA+= docs/README.md
6 | dist_doc_DATA+= docs/SWTPM.md
7 | dist_doc_DATA+= docs/WindowTBS.md
8 | dist_doc_DATA+= docs/Doxyfile
9 |
10 |
11 | dox:
12 | echo "Generating HTML"
13 | doxygen ./docs/Doxyfile
14 |
15 | clean-local:
16 | -rm -rf docs/html/
17 |
--------------------------------------------------------------------------------
/examples/attestation/attestation.h:
--------------------------------------------------------------------------------
1 | /* attestation.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _ATTESTATION_H_
23 | #define _ATTESTATION_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | #define CRED_SECRET_SIZE 32
30 |
31 | int TPM2_MakeCredential_Example(void* userCtx, int argc, char *argv[]);
32 | int TPM2_ActivateCredential_Example(void* userCtx, int argc, char *argv[]);
33 | int TPM2_Certify_Example(void* userCtx, int argc, char *argv[]);
34 |
35 | #ifdef __cplusplus
36 | } /* extern "C" */
37 | #endif
38 |
39 | #endif /* _ATTESTATION_H_ */
40 |
--------------------------------------------------------------------------------
/examples/attestation/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_PROGRAMS += examples/attestation/make_credential \
6 | examples/attestation/activate_credential \
7 | examples/attestation/certify
8 |
9 | noinst_HEADERS += examples/attestation/attestation.h
10 |
11 | examples_attestation_make_credential_SOURCES = examples/attestation/make_credential.c \
12 | examples/tpm_test_keys.c
13 | examples_attestation_make_credential_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
14 | examples_attestation_make_credential_DEPENDENCIES = src/libwolftpm.la
15 |
16 | examples_attestation_activate_credential_SOURCES = examples/attestation/activate_credential.c \
17 | examples/tpm_test_keys.c
18 | examples_attestation_activate_credential_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
19 | examples_attestation_activate_credential_DEPENDENCIES = src/libwolftpm.la
20 |
21 | examples_attestation_certify_SOURCES = examples/attestation/certify.c \
22 | examples/tpm_test_keys.c
23 | examples_attestation_certify_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
24 | examples_attestation_certify_DEPENDENCIES = src/libwolftpm.la
25 | endif
26 | example_attestationdir = $(exampledir)/attestation
27 | dist_example_attestation_DATA = \
28 | examples/attestation/make_credential.c \
29 | examples/attestation/activate_credential.c \
30 | examples/attestation/certify.c
31 |
32 | DISTCLEANFILES+= examples/attestation/.libs/make_credential \
33 | examples/attestation/.libs/activate_credential \
34 | examples/attestation/.libs/certify
35 |
36 | EXTRA_DIST+= examples/attestation/README.md \
37 | examples/attestation/tpm_idevid_policy.png \
38 | examples/attestation/tpm_iak_policy.png
39 |
--------------------------------------------------------------------------------
/examples/attestation/tpm_iak_policy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wolfSSL/wolfTPM/bd682553ac45c4537dc5790da9cb0acb62bc844c/examples/attestation/tpm_iak_policy.png
--------------------------------------------------------------------------------
/examples/attestation/tpm_idevid_policy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wolfSSL/wolfTPM/bd682553ac45c4537dc5790da9cb0acb62bc844c/examples/attestation/tpm_idevid_policy.png
--------------------------------------------------------------------------------
/examples/bench/bench.h:
--------------------------------------------------------------------------------
1 | /* bench.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _WRAP_BENCH_H_
23 | #define _WRAP_BENCH_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_Wrapper_BenchArgs(void* userCtx, int argc, char *argv[]);
30 | int TPM2_Wrapper_Bench(void* userCtx);
31 |
32 | #ifdef __cplusplus
33 | } /* extern "C" */
34 | #endif
35 |
36 | #endif /* _WRAP_BENCH_H_ */
37 |
--------------------------------------------------------------------------------
/examples/bench/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_PROGRAMS += examples/bench/bench
6 | noinst_HEADERS += examples/bench/bench.h
7 | examples_bench_bench_SOURCES = examples/bench/bench.c \
8 | examples/tpm_test_keys.c
9 | examples_bench_bench_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
10 | examples_bench_bench_DEPENDENCIES = src/libwolftpm.la
11 | endif
12 |
13 | example_benchdir = $(exampledir)/bench
14 | dist_example_bench_DATA = examples/bench/bench.c
15 |
16 | DISTCLEANFILES+= examples/bench/.libs/bench
17 |
--------------------------------------------------------------------------------
/examples/boot/boot.h:
--------------------------------------------------------------------------------
1 | /* boot.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _BOOT_SECURE_EXAMPLES_H_
23 | #define _BOOT_SECURE_EXAMPLES_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_Boot_SecureROT_Example(void* userCtx, int argc, char *argv[]);
30 | int TPM2_Boot_SecretSeal_Example(void* userCtx, int argc, char *argv[]);
31 | int TPM2_Boot_SecretUnseal_Example(void* userCtx, int argc, char *argv[]);
32 |
33 | #ifdef __cplusplus
34 | } /* extern "C" */
35 | #endif
36 |
37 | #endif /* _BOOT_SECURE_EXAMPLES_H_ */
38 |
--------------------------------------------------------------------------------
/examples/boot/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | EXTRA_DIST += examples/boot/README.md
5 |
6 | if BUILD_EXAMPLES
7 | noinst_HEADERS += examples/boot/boot.h
8 |
9 | noinst_PROGRAMS += examples/boot/secure_rot
10 | examples_boot_secure_rot_SOURCES = examples/boot/secure_rot.c \
11 | examples/tpm_test_keys.c
12 | examples_boot_secure_rot_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
13 | examples_boot_secure_rot_DEPENDENCIES = src/libwolftpm.la
14 |
15 | noinst_PROGRAMS += examples/boot/secret_seal
16 | examples_boot_secret_seal_SOURCES = examples/boot/secret_seal.c \
17 | examples/tpm_test_keys.c
18 | examples_boot_secret_seal_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
19 | examples_boot_secret_seal_DEPENDENCIES = src/libwolftpm.la
20 |
21 | noinst_PROGRAMS += examples/boot/secret_unseal
22 | examples_boot_secret_unseal_SOURCES = examples/boot/secret_unseal.c \
23 | examples/tpm_test_keys.c
24 | examples_boot_secret_unseal_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
25 | examples_boot_secret_unseal_DEPENDENCIES = src/libwolftpm.la
26 | endif
27 |
28 | example_bootdir = $(exampledir)/boot
29 | dist_example_boot_DATA = examples/boot/secure_rot.c \
30 | examples/boot/secret_seal.c \
31 | examples/boot/secret_unseal.c
32 |
33 | DISTCLEANFILES+= examples/boot/.libs/secure_rot \
34 | examples/boot/.libs/secret_seal \
35 | examples/boot/.libs/secret_unseal
36 |
--------------------------------------------------------------------------------
/examples/csr/csr.h:
--------------------------------------------------------------------------------
1 | /* csr.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _TPM_CSR_EXAMPLE_H_
23 | #define _TPM_CSR_EXAMPLE_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_CSR_Example(void* userCtx);
30 | int TPM2_CSR_ExampleArgs(void* userCtx, int argc, char *argv[]);
31 |
32 | #ifdef __cplusplus
33 | } /* extern "C" */
34 | #endif
35 |
36 | #endif /* _TPM_CSR_EXAMPLE_H_ */
37 |
--------------------------------------------------------------------------------
/examples/csr/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_PROGRAMS += examples/csr/csr
6 | noinst_HEADERS += examples/csr/csr.h
7 | examples_csr_csr_SOURCES = examples/csr/csr.c \
8 | examples/tpm_test_keys.c
9 | examples_csr_csr_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
10 | examples_csr_csr_DEPENDENCIES = src/libwolftpm.la
11 | endif
12 |
13 | example_csrdir = $(exampledir)/csr
14 | dist_example_csr_DATA = examples/csr/csr.c
15 |
16 | DISTCLEANFILES+= examples/csr/.libs/csr
17 |
--------------------------------------------------------------------------------
/examples/endorsement/endorsement.h:
--------------------------------------------------------------------------------
1 | /* endorsement.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _WOLFTPM_ENDORSEMENT_H_
23 | #define _WOLFTPM_ENDORSEMENT_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_EndorsementCert_Example(void* userCtx, int argc, char *argv[]);
30 | int TPM2_EndorsementCertVerify_Example(void* userCtx, int argc, char *argv[]);
31 |
32 | #ifdef __cplusplus
33 | } /* extern "C" */
34 | #endif
35 |
36 | #endif /* _WOLFTPM_ENDORSEMENT_H_ */
37 |
--------------------------------------------------------------------------------
/examples/endorsement/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_HEADERS += \
6 | examples/endorsement/endorsement.h \
7 | examples/endorsement/trusted_certs.h \
8 | examples/endorsement/trusted_certs_der.h
9 |
10 | noinst_PROGRAMS += examples/endorsement/get_ek_certs
11 | examples_endorsement_get_ek_certs_SOURCES = examples/endorsement/get_ek_certs.c
12 | examples_endorsement_get_ek_certs_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
13 | examples_endorsement_get_ek_certs_DEPENDENCIES = src/libwolftpm.la
14 |
15 | noinst_PROGRAMS += examples/endorsement/verify_ek_cert
16 | examples_endorsement_verify_ek_cert_SOURCES = examples/endorsement/verify_ek_cert.c
17 | examples_endorsement_verify_ek_cert_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
18 | examples_endorsement_verify_ek_cert_DEPENDENCIES = src/libwolftpm.la
19 | endif
20 |
21 | EXTRA_DIST+=examples/endorsement/README.md
22 | example_endorsementdir = $(exampledir)/endorsement
23 | dist_example_endorsement_DATA = \
24 | examples/endorsement/get_ek_certs.c \
25 | examples/endorsement/verify_ek_cert.c
26 |
27 | DISTCLEANFILES+= \
28 | examples/endorsement/.libs/get_ek_certs \
29 | examples/endorsement/.libs/verify_ek_cert
30 |
--------------------------------------------------------------------------------
/examples/firmware/Makefile:
--------------------------------------------------------------------------------
1 | CC=gcc
2 | CFLAGS=-Wall -Werror -Wextra -g
3 | LIBS=
4 |
5 | all: clean ifx_fw_extract
6 |
7 | ifx_fw_extract: ifx_fw_extract.o
8 | $(CC) -o $@ $^ $(CFLAGS) $(LIBS)
9 |
10 | .PHONY: clean
11 |
12 | clean:
13 | rm -f *.o ifx_fw_extract
14 |
--------------------------------------------------------------------------------
/examples/firmware/ifx_fw_update.h:
--------------------------------------------------------------------------------
1 | /* ifx_firmware_update.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _IFX_FIRMWARE_H_
23 | #define _IFX_FIRMWARE_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_IFX_Firmware_Update(void* userCtx, int argc, char *argv[]);
30 |
31 | #ifdef __cplusplus
32 | } /* extern "C" */
33 | #endif
34 |
35 | #endif /* _IFX_FIRMWARE_H_ */
36 |
--------------------------------------------------------------------------------
/examples/firmware/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | EXTRA_DIST += examples/firmware/README.md
5 | EXTRA_DIST += examples/firmware/Makefile
6 |
7 | # Host side tool for extracting the firmware manifest and data
8 | EXTRA_DIST += examples/firmware/ifx_fw_extract.c
9 |
10 | if BUILD_EXAMPLES
11 | if BUILD_INFINEON
12 | noinst_PROGRAMS += examples/firmware/ifx_fw_update
13 | noinst_HEADERS += examples/firmware/ifx_fw_update.h
14 | examples_firmware_ifx_fw_update_SOURCES = examples/firmware/ifx_fw_update.c \
15 | examples/tpm_test_keys.c
16 | examples_firmware_ifx_fw_update_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
17 | examples_firmware_ifx_fw_update_DEPENDENCIES = src/libwolftpm.la
18 | endif
19 | endif
20 |
21 | example_firmwaredir = $(exampledir)/firmware
22 | dist_example_firmware_DATA = examples/firmware/ifx_fw_update.c
23 |
24 | DISTCLEANFILES+= examples/firmware/.libs/ifx_fw_update
25 |
--------------------------------------------------------------------------------
/examples/gpio/gpio.h:
--------------------------------------------------------------------------------
1 | /* gpio.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _GPIO_H_
23 | #define _GPIO_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_GPIO_Config_Example(void* userCtx, int argc, char *argv[]);
30 | int TPM2_GPIO_Read_Example(void* userCtx, int argc, char *argv[]);
31 | int TPM2_GPIO_Set_Example(void* userCtx, int argc, char *argv[]);
32 |
33 | #ifdef __cplusplus
34 | } /* extern "C" */
35 | #endif
36 |
37 | #endif /* _GPIO_H_ */
38 |
--------------------------------------------------------------------------------
/examples/gpio/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_PROGRAMS += examples/gpio/gpio_config \
6 | examples/gpio/gpio_read \
7 | examples/gpio/gpio_set
8 |
9 | noinst_HEADERS += examples/gpio/gpio.h
10 |
11 | examples_gpio_gpio_config_SOURCES = examples/gpio/gpio_config.c
12 | examples_gpio_gpio_config_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
13 | examples_gpio_gpio_config_DEPENDENCIES = src/libwolftpm.la
14 |
15 | examples_gpio_gpio_read_SOURCES = examples/gpio/gpio_read.c
16 | examples_gpio_gpio_read_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
17 | examples_gpio_gpio_read_DEPENDENCIES = src/libwolftpm.la
18 |
19 | examples_gpio_gpio_set_SOURCES = examples/gpio/gpio_set.c
20 | examples_gpio_gpio_set_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
21 | examples_gpio_gpio_set_DEPENDENCIES = src/libwolftpm.la
22 | endif
23 |
24 | example_gpiodir = $(exampledir)/gpio
25 | dist_example_gpio_DATA = \
26 | examples/gpio/gpio_config.c \
27 | examples/gpio/gpio_read.c \
28 | examples/gpio/gpio_set.c
29 |
30 | DISTCLEANFILES+= examples/gpio/.libs/gpio_config
31 | DISTCLEANFILES+= examples/gpio/.libs/gpio_read
32 | DISTCLEANFILES+= examples/gpio/.libs/gpio_set
33 |
--------------------------------------------------------------------------------
/examples/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | include examples/native/include.am
5 | include examples/wrap/include.am
6 | include examples/bench/include.am
7 | include examples/boot/include.am
8 | include examples/tls/include.am
9 | include examples/csr/include.am
10 | include examples/pkcs7/include.am
11 | include examples/timestamp/include.am
12 | include examples/pcr/include.am
13 | include examples/management/include.am
14 | include examples/keygen/include.am
15 | include examples/nvram/include.am
16 | include examples/gpio/include.am
17 | include examples/seal/include.am
18 | include examples/attestation/include.am
19 | include examples/firmware/include.am
20 | include examples/endorsement/include.am
21 |
22 | if BUILD_EXAMPLES
23 | EXTRA_DIST += examples/run_examples.sh
24 | endif
25 |
26 | dist_example_DATA+= examples/README.md \
27 | examples/tpm_test_keys.c \
28 | examples/tpm_test_keys.h \
29 | examples/tpm_test.h
30 |
--------------------------------------------------------------------------------
/examples/keygen/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_HEADERS += examples/keygen/keygen.h
6 |
7 | noinst_PROGRAMS += examples/keygen/create_primary
8 | examples_keygen_create_primary_SOURCES = examples/keygen/create_primary.c \
9 | examples/tpm_test_keys.c
10 | examples_keygen_create_primary_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
11 | examples_keygen_create_primary_DEPENDENCIES = src/libwolftpm.la
12 |
13 | noinst_PROGRAMS += examples/keygen/keyload
14 | examples_keygen_keyload_SOURCES = examples/keygen/keyload.c \
15 | examples/tpm_test_keys.c
16 | examples_keygen_keyload_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
17 | examples_keygen_keyload_DEPENDENCIES = src/libwolftpm.la
18 |
19 | noinst_PROGRAMS += examples/keygen/keygen
20 | examples_keygen_keygen_SOURCES = examples/keygen/keygen.c \
21 | examples/tpm_test_keys.c
22 | examples_keygen_keygen_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
23 | examples_keygen_keygen_DEPENDENCIES = src/libwolftpm.la
24 |
25 | noinst_PROGRAMS += examples/keygen/keyimport
26 | examples_keygen_keyimport_SOURCES = examples/keygen/keyimport.c \
27 | examples/tpm_test_keys.c
28 | examples_keygen_keyimport_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
29 | examples_keygen_keyimport_DEPENDENCIES = src/libwolftpm.la
30 |
31 | noinst_PROGRAMS += examples/keygen/external_import
32 | examples_keygen_external_import_SOURCES = examples/keygen/external_import.c \
33 | examples/tpm_test_keys.c
34 | examples_keygen_external_import_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
35 | examples_keygen_external_import_DEPENDENCIES = src/libwolftpm.la
36 | endif
37 |
38 | example_keygendir = $(exampledir)/keygen
39 | dist_example_keygen_DATA = \
40 | examples/keygen/create_primary.c \
41 | examples/keygen/keyload.c \
42 | examples/keygen/keygen.c \
43 | examples/keygen/keyimport.c \
44 | examples/keygen/external_import.c
45 |
46 | DISTCLEANFILES+= examples/keygen/.libs/create_primary
47 | DISTCLEANFILES+= examples/keygen/.libs/keyload
48 | DISTCLEANFILES+= examples/keygen/.libs/keygen
49 | DISTCLEANFILES+= examples/keygen/.libs/keyimport
50 | DISTCLEANFILES+= examples/keygen/.libs/external_import
51 |
--------------------------------------------------------------------------------
/examples/keygen/keygen.h:
--------------------------------------------------------------------------------
1 | /* keygen.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _KEYGEN_H_
23 | #define _KEYGEN_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_CreatePrimaryKey_Example(void* userCtx, int argc, char *argv[]);
30 | int TPM2_Keygen_Example(void* userCtx, int argc, char *argv[]);
31 | int TPM2_Keyload_Example(void* userCtx, int argc, char *argv[]);
32 | int TPM2_Keyimport_Example(void* userCtx, int argc, char *argv[]);
33 | int TPM2_ExternalImport_Example(void* userCtx, int argc, char *argv[]);
34 |
35 | #ifdef __cplusplus
36 | } /* extern "C" */
37 | #endif
38 |
39 | #endif /* _KEYGEN_H_ */
40 |
--------------------------------------------------------------------------------
/examples/management/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_PROGRAMS += examples/management/flush \
6 | examples/management/tpmclear
7 |
8 | noinst_HEADERS += examples/management/management.h
9 |
10 | examples_management_flush_SOURCES = examples/management/flush.c
11 | examples_management_flush_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
12 | examples_management_flush_DEPENDENCIES = src/libwolftpm.la
13 |
14 | examples_management_tpmclear_SOURCES = examples/management/tpmclear.c
15 | examples_management_tpmclear_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
16 | examples_management_tpmclear_DEPENDENCIES = src/libwolftpm.la
17 | endif
18 |
19 | example_managementdir = $(exampledir)/management
20 | dist_example_management_DATA = examples/management/flush.c \
21 | examples/management/tpmclear.c
22 |
23 | DISTCLEANFILES+= examples/management/.libs/flush \
24 | examples/management/.libs/tpmclear
25 |
--------------------------------------------------------------------------------
/examples/management/management.h:
--------------------------------------------------------------------------------
1 | /* management.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _FLUSH_H_
23 | #define _FLUSH_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_Flush_Tool(void* userCtx, int argc, char *argv[]);
30 | int TPM2_Clear_Tool(void* userCtx, int argc, char *argv[]);
31 |
32 | #ifdef __cplusplus
33 | } /* extern "C" */
34 | #endif
35 |
36 | #endif /* _FLUSH_H_ */
37 |
--------------------------------------------------------------------------------
/examples/management/tpmclear.c:
--------------------------------------------------------------------------------
1 | /* tpmclear.c
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | /* This is a tool for performing a TPM2_Clear call to reset the NV */
23 |
24 | #ifdef HAVE_CONFIG_H
25 | #include
26 | #endif
27 |
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 | #include
34 |
35 | #ifndef WOLFTPM2_NO_WRAPPER
36 | int TPM2_Clear_Tool(void* userCtx, int argc, char *argv[])
37 | {
38 | int rc = TPM_RC_FAILURE;
39 | WOLFTPM2_DEV dev;
40 |
41 | (void)argc;
42 | (void)argv;
43 |
44 | printf("Preparing to clear TPM\n");
45 | rc = wolfTPM2_Init(&dev, TPM2_IoCb, userCtx);
46 | if (rc != TPM_RC_SUCCESS) {
47 | printf("wolfTPM2_Init failed 0x%x: %s\n", rc, TPM2_GetRCString(rc));
48 | return rc;
49 | }
50 |
51 | /* reset all content on TPM and reseed */
52 | rc = wolfTPM2_Clear(&dev);
53 | if (rc == 0) {
54 | printf("TPM Clear success\n");
55 | }
56 |
57 | if (rc != 0) {
58 | printf("Failure 0x%x: %s\n", rc, wolfTPM2_GetRCString(rc));
59 | }
60 | wolfTPM2_Cleanup(&dev);
61 | return rc;
62 | }
63 | #endif /* !WOLFTPM2_NO_WRAPPER */
64 |
65 | #ifndef NO_MAIN_DRIVER
66 | int main(int argc, char *argv[])
67 | {
68 | int rc = NOT_COMPILED_IN;
69 |
70 | #ifndef WOLFTPM2_NO_WRAPPER
71 | rc = TPM2_Clear_Tool(NULL, argc, argv);
72 | #else
73 | printf("Flush tool not compiled in\n");
74 | (void)argc;
75 | (void)argv;
76 | #endif
77 |
78 | return rc;
79 | }
80 | #endif
81 |
--------------------------------------------------------------------------------
/examples/native/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_PROGRAMS += examples/native/native_test
6 | noinst_HEADERS += examples/native/native_test.h
7 | examples_native_native_test_SOURCES = examples/native/native_test.c
8 | examples_native_native_test_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
9 | examples_native_native_test_DEPENDENCIES = src/libwolftpm.la
10 | endif
11 |
12 | example_nativedir = $(exampledir)/native
13 | dist_example_native_DATA = examples/native/native_test.c
14 |
15 | DISTCLEANFILES+= examples/native/.libs/native_test
16 |
--------------------------------------------------------------------------------
/examples/native/native_test.h:
--------------------------------------------------------------------------------
1 | /* native_test.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _NATIVE_TEST_H_
23 | #define _NATIVE_TEST_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_Native_Test(void* userCtx);
30 | int TPM2_Native_TestArgs(void* userCtx, int argc, char *argv[]);
31 |
32 | #ifdef __cplusplus
33 | } /* extern "C" */
34 | #endif
35 |
36 | #endif /* _NATIVE_TEST_H_ */
37 |
--------------------------------------------------------------------------------
/examples/nvram/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_HEADERS += examples/nvram/nvram.h
6 |
7 | noinst_PROGRAMS += examples/nvram/store
8 | examples_nvram_store_SOURCES = examples/nvram/store.c \
9 | examples/tpm_test_keys.c
10 | examples_nvram_store_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
11 | examples_nvram_store_DEPENDENCIES = src/libwolftpm.la
12 |
13 | noinst_PROGRAMS += examples/nvram/read
14 | examples_nvram_read_SOURCES = examples/nvram/read.c \
15 | examples/tpm_test_keys.c
16 | examples_nvram_read_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
17 | examples_nvram_read_DEPENDENCIES = src/libwolftpm.la
18 |
19 | noinst_PROGRAMS += examples/nvram/counter
20 | examples_nvram_counter_SOURCES = examples/nvram/counter.c \
21 | examples/tpm_test_keys.c
22 | examples_nvram_counter_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
23 | examples_nvram_counter_DEPENDENCIES = src/libwolftpm.la
24 |
25 | noinst_PROGRAMS += examples/nvram/policy_nv
26 | examples_nvram_policy_nv_SOURCES = examples/nvram/policy_nv.c \
27 | examples/tpm_test_keys.c
28 | examples_nvram_policy_nv_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
29 | examples_nvram_policy_nv_DEPENDENCIES = src/libwolftpm.la
30 |
31 | noinst_PROGRAMS += examples/nvram/extend
32 | examples_nvram_extend_SOURCES = examples/nvram/extend.c \
33 | examples/tpm_test_keys.c
34 | examples_nvram_extend_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
35 | examples_nvram_extend_DEPENDENCIES = src/libwolftpm.la
36 | endif
37 |
38 | example_nvramdir = $(exampledir)/nvram
39 | dist_example_nvram_DATA = \
40 | examples/nvram/store.c \
41 | examples/nvram/read.c \
42 | examples/nvram/counter.c \
43 | examples/nvram/policy_nv.c \
44 | examples/nvram/extend.c
45 |
46 | DISTCLEANFILES+= examples/nvram/.libs/store \
47 | examples/nvram/.libs/read \
48 | examples/nvram/.libs/counter \
49 | examples/nvram/.libs/policy_nv \
50 | examples/nvram/.libs/extend
51 |
--------------------------------------------------------------------------------
/examples/nvram/nvram.h:
--------------------------------------------------------------------------------
1 | /* nvram.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _NVRAM_EXAMPLE_H_
23 | #define _NVRAM_EXAMPLE_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_NVRAM_Store_Example(void* userCtx, int argc, char *argv[]);
30 | int TPM2_NVRAM_Read_Example(void* userCtx, int argc, char *argv[]);
31 | int TPM2_NVRAM_Counter_Example(void* userCtx, int argc, char *argv[]);
32 | int TPM2_PCR_Seal_With_Policy_Auth_NV_Test(void* userCtx, int argc, char *argv[]);
33 | int TPM2_PCR_Seal_With_Policy_Auth_NV_External_Test(void* userCtx, int argc, char *argv[]);
34 | int TPM2_NVRAM_PolicyNV_Example(void* userCtx, int argc, char *argv[]);
35 | int TPM2_NVRAM_Extend_Example(void* userCtx, int argc, char *argv[]);
36 |
37 | #ifdef __cplusplus
38 | } /* extern "C" */
39 | #endif
40 |
41 | #endif /* _NVRAM_EXAMPLE_H_ */
42 |
--------------------------------------------------------------------------------
/examples/pcr/demo-quote-zip.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | echo "wolfTPM Quote & Attestation demo"
4 | echo
5 | echo "Starting from a known PCR state"
6 |
7 | ./examples/pcr/reset 16
8 |
9 | echo
10 | echo "Extending with precalculated hash value"
11 | echo
12 |
13 | ./examples/pcr/extend 16 /usr/bin/zip
14 |
15 | echo
16 | echo "Generating TPM-signed structure with this PCR digest"
17 | echo
18 |
19 | ./examples/pcr/quote 16 zip.quote
20 |
21 | echo
22 | echo "TPMS_ATTEST structure is saved to a binary file 'zip.quote'"
23 | echo
24 |
--------------------------------------------------------------------------------
/examples/pcr/demo.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | echo "wolfTPM Quote & Attestation demo"
4 | echo
5 | echo "Starting from a known PCR state"
6 |
7 | ./examples/pcr/reset
8 |
9 | echo
10 | echo "Extending with precalculated hash value"
11 | echo
12 |
13 | ./examples/pcr/extend
14 |
15 | echo
16 | echo "Generating TPM-signed structure with this PCR digest"
17 | echo
18 |
19 | ./examples/pcr/quote
20 |
21 | echo
22 | echo "TPMS_ATTEST structure is saved to a binary file 'quote.blob'"
23 | echo
24 |
--------------------------------------------------------------------------------
/examples/pcr/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_PROGRAMS += examples/pcr/quote \
6 | examples/pcr/read_pcr \
7 | examples/pcr/extend \
8 | examples/pcr/policy \
9 | examples/pcr/policy_sign \
10 | examples/pcr/reset
11 |
12 | noinst_HEADERS += examples/pcr/quote.h \
13 | examples/pcr/pcr.h
14 |
15 | examples_pcr_quote_SOURCES = examples/pcr/quote.c \
16 | examples/tpm_test_keys.c
17 | examples_pcr_quote_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
18 | examples_pcr_quote_DEPENDENCIES = src/libwolftpm.la
19 |
20 | examples_pcr_read_pcr_SOURCES = examples/pcr/read_pcr.c
21 | examples_pcr_read_pcr_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
22 | examples_pcr_read_pcr_DEPENDENCIES = src/libwolftpm.la
23 |
24 | examples_pcr_extend_SOURCES = examples/pcr/extend.c
25 | examples_pcr_extend_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
26 | examples_pcr_extend_DEPENDENCIES = src/libwolftpm.la
27 |
28 | examples_pcr_reset_SOURCES = examples/pcr/reset.c
29 | examples_pcr_reset_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
30 | examples_pcr_reset_DEPENDENCIES = src/libwolftpm.la
31 |
32 | examples_pcr_policy_SOURCES = examples/pcr/policy.c \
33 | examples/tpm_test_keys.c
34 | examples_pcr_policy_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
35 | examples_pcr_policy_DEPENDENCIES = src/libwolftpm.la
36 |
37 | examples_pcr_policy_sign_SOURCES = examples/pcr/policy_sign.c \
38 | examples/tpm_test_keys.c
39 | examples_pcr_policy_sign_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
40 | examples_pcr_policy_sign_DEPENDENCIES = src/libwolftpm.la
41 | endif
42 |
43 | example_pcrdir = $(exampledir)/pcr
44 | dist_example_pcr_DATA = \
45 | examples/pcr/quote.c \
46 | examples/pcr/read_pcr.c \
47 | examples/pcr/extend.c \
48 | examples/pcr/policy.c \
49 | examples/pcr/policy_sign.c \
50 | examples/pcr/reset.c
51 |
52 | DISTCLEANFILES+= examples/pcr/.libs/quote \
53 | examples/pcr/.libs/read_pcr \
54 | examples/pcr/.libs/policy \
55 | examples/pcr/.libs/policy_sign \
56 | examples/pcr/.libs/extend \
57 | examples/pcr/.libs/reset
58 |
59 | EXTRA_DIST+= examples/pcr/README.md \
60 | examples/pcr/demo.sh \
61 | examples/pcr/demo-quote-zip.sh
62 |
--------------------------------------------------------------------------------
/examples/pcr/pcr.h:
--------------------------------------------------------------------------------
1 | /* pcr.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _PCR_H_
23 | #define _PCR_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_PCR_Read_Test(void* userCtx, int argc, char *argv[]);
30 | int TPM2_PCR_Extend_Test(void* userCtx, int argc, char *argv[]);
31 | int TPM2_PCR_Reset_Test(void* userCtx, int argc, char *argv[]);
32 | int TPM2_PCR_Policy_Test(void* userCtx, int argc, char *argv[]);
33 | int TPM2_PCR_PolicySign_Example(void* userCtx, int argc, char *argv[]);
34 | int TPM2_PCR_Seal_With_Policy_Auth_Test(void* userCtx, int argc, char *argv[]);
35 |
36 | #ifdef __cplusplus
37 | } /* extern "C" */
38 | #endif
39 |
40 | #endif /* _PCR_H_ */
41 |
--------------------------------------------------------------------------------
/examples/pcr/quote.h:
--------------------------------------------------------------------------------
1 | /* quote.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _QUOTE_H_
23 | #define _QUOTE_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_PCR_Quote_Test(void* userCtx, int argc, char *argv[]);
30 |
31 | #ifdef __cplusplus
32 | } /* extern "C" */
33 | #endif
34 |
35 | #endif /* _QUOTE_H_ */
36 |
--------------------------------------------------------------------------------
/examples/pkcs7/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_PROGRAMS += examples/pkcs7/pkcs7
6 | noinst_HEADERS += examples/pkcs7/pkcs7.h
7 | examples_pkcs7_pkcs7_SOURCES = examples/pkcs7/pkcs7.c \
8 | examples/tpm_test_keys.c
9 | examples_pkcs7_pkcs7_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
10 | examples_pkcs7_pkcs7_DEPENDENCIES = src/libwolftpm.la
11 | endif
12 |
13 | example_pkcs7dir = $(exampledir)/pkcs7
14 | dist_example_pkcs7_DATA = examples/pkcs7/pkcs7.c
15 |
16 | DISTCLEANFILES+= examples/pkcs7/.libs/pkcs7
17 |
--------------------------------------------------------------------------------
/examples/pkcs7/pkcs7.h:
--------------------------------------------------------------------------------
1 | /* pkcs7.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _TPM_PKCS7_EXAMPLE_H_
23 | #define _TPM_PKCS7_EXAMPLE_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_PKCS7_Example(void* userCtx);
30 | int TPM2_PKCS7_ExampleArgs(void* userCtx, int argc, char *argv[]);
31 |
32 | #ifdef __cplusplus
33 | } /* extern "C" */
34 | #endif
35 |
36 | #endif /* _TPM_PKCS7_EXAMPLE_H_ */
37 |
--------------------------------------------------------------------------------
/examples/seal/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_PROGRAMS += examples/seal/seal \
6 | examples/seal/unseal
7 |
8 | noinst_HEADERS += examples/seal/seal.h
9 |
10 | examples_seal_seal_SOURCES = examples/seal/seal.c \
11 | examples/tpm_test_keys.c
12 | examples_seal_seal_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
13 | examples_seal_seal_DEPENDENCIES = src/libwolftpm.la
14 |
15 | examples_seal_unseal_SOURCES = examples/seal/unseal.c \
16 | examples/tpm_test_keys.c
17 | examples_seal_unseal_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
18 | examples_seal_unseal_DEPENDENCIES = src/libwolftpm.la
19 | endif
20 |
21 | example_sealdir = $(exampledir)/seal
22 | dist_example_seal_DATA = \
23 | examples/seal/seal.c \
24 | examples/seal/unseal.c
25 |
26 | DISTCLEANFILES+= examples/seal/.libs/seal
27 | DISTCLEANFILES+= examples/seal/.libs/unseal
28 |
29 |
--------------------------------------------------------------------------------
/examples/seal/seal.h:
--------------------------------------------------------------------------------
1 | /* seal.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _SEAL_H_
23 | #define _SEAL_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_Seal_Example(void* userCtx, int argc, char *argv[]);
30 | int TPM2_Unseal_Example(void* userCtx, int argc, char *argv[]);
31 | int TPM2_PCR_Seal_With_Policy_Auth_Test(void* userCtx, int argc, char *argv[]);
32 |
33 | #ifdef __cplusplus
34 | } /* extern "C" */
35 | #endif
36 |
37 | #endif /* _SEAL_H_ */
38 |
--------------------------------------------------------------------------------
/examples/timestamp/clock_set.h:
--------------------------------------------------------------------------------
1 | /* clock_set.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _CLOCK_SET_H_
23 | #define _CLOCK_SET_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_ClockSet_Test(void* userCtx, int argc, char *argv[]);
30 |
31 | #ifdef __cplusplus
32 | } /* extern "C" */
33 | #endif
34 |
35 | #endif /* _CLOCK_SET_H_ */
36 |
--------------------------------------------------------------------------------
/examples/timestamp/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_PROGRAMS += examples/timestamp/signed_timestamp
6 | noinst_HEADERS += examples/timestamp/signed_timestamp.h
7 | examples_timestamp_signed_timestamp_SOURCES = examples/timestamp/signed_timestamp.c \
8 | examples/tpm_test_keys.c
9 | examples_timestamp_signed_timestamp_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
10 | examples_timestamp_signed_timestamp_DEPENDENCIES = src/libwolftpm.la
11 |
12 |
13 | noinst_PROGRAMS += examples/timestamp/clock_set
14 | noinst_HEADERS += examples/timestamp/clock_set.h
15 | examples_timestamp_clock_set_SOURCES = examples/timestamp/clock_set.c
16 | examples_timestamp_clock_set_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
17 | examples_timestamp_clock_set_DEPENDENCIES = src/libwolftpm.la
18 | endif
19 |
20 | example_timestampdir = $(exampledir)/timestamp
21 | dist_example_timestamp_DATA = \
22 | examples/timestamp/clock_set.c \
23 | examples/timestamp/signed_timestamp.c
24 |
25 | DISTCLEANFILES+= examples/timestamp/.libs/signed_timestamp
26 | DISTCLEANFILES+= examples/timestamp/.libs/clock_set
27 |
--------------------------------------------------------------------------------
/examples/timestamp/signed_timestamp.h:
--------------------------------------------------------------------------------
1 | /* signed_timestamp.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _SIGNED_TIMESTAMP_H_
23 | #define _SIGNED_TIMESTAMP_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_Timestamp_Test(void* userCtx);
30 | int TPM2_Timestamp_TestArgs(void* userCtx, int argc, char *argv[]);
31 |
32 | #ifdef __cplusplus
33 | } /* extern "C" */
34 | #endif
35 |
36 | #endif /* _SIGNED_TIMESTAMP_H_ */
37 |
--------------------------------------------------------------------------------
/examples/tls/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_PROGRAMS += examples/tls/tls_client
6 | noinst_HEADERS += examples/tls/tls_client.h \
7 | examples/tls/tls_common.h
8 | examples_tls_tls_client_SOURCES = examples/tls/tls_client.c \
9 | examples/tpm_test_keys.c
10 | examples_tls_tls_client_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
11 | examples_tls_tls_client_DEPENDENCIES = src/libwolftpm.la
12 |
13 | noinst_PROGRAMS += examples/tls/tls_client_notpm
14 | noinst_HEADERS += examples/tls/tls_client.h \
15 | examples/tls/tls_common.h
16 | examples_tls_tls_client_notpm_SOURCES = examples/tls/tls_client_notpm.c \
17 | examples/tpm_test_keys.c
18 | examples_tls_tls_client_notpm_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
19 | examples_tls_tls_client_notpm_DEPENDENCIES = src/libwolftpm.la
20 |
21 | noinst_PROGRAMS += examples/tls/tls_server
22 | noinst_HEADERS += examples/tls/tls_server.h \
23 | examples/tls/tls_common.h
24 | examples_tls_tls_server_SOURCES = examples/tls/tls_server.c \
25 | examples/tpm_test_keys.c
26 | examples_tls_tls_server_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
27 | examples_tls_tls_server_DEPENDENCIES = src/libwolftpm.la
28 |
29 | endif
30 |
31 | example_tlsdir = $(exampledir)/tls
32 | dist_example_tls_DATA = \
33 | examples/tls/tls_client.c \
34 | examples/tls/tls_server.c
35 |
36 | DISTCLEANFILES+= examples/tls/.libs/tls_client
37 | DISTCLEANFILES+= examples/tls/.libs/tls_server
38 |
--------------------------------------------------------------------------------
/examples/tls/tls_client.h:
--------------------------------------------------------------------------------
1 | /* tls_client.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _TPM_TLS_CLIENT_H_
23 | #define _TPM_TLS_CLIENT_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_TLS_Client(void* userCtx);
30 | int TPM2_TLS_ClientArgs(void* userCtx, int argc, char *argv[]);
31 | int TLS_Client(void);
32 | int TLS_ClientArgs(int argc, char *argv[]);
33 |
34 | #ifdef __cplusplus
35 | } /* extern "C" */
36 | #endif
37 |
38 | #endif /* _TPM_TLS_CLIENT_H_ */
39 |
--------------------------------------------------------------------------------
/examples/tls/tls_server.h:
--------------------------------------------------------------------------------
1 | /* tls_server.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _TPM_TLS_SERVER_H_
23 | #define _TPM_TLS_SERVER_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_TLS_Server(void* userCtx);
30 | int TPM2_TLS_ServerArgs(void* userCtx, int argc, char* argv[]);
31 |
32 | #ifdef __cplusplus
33 | } /* extern "C" */
34 | #endif
35 |
36 | #endif /* _TPM_TLS_SERVER_H_ */
37 |
--------------------------------------------------------------------------------
/examples/tpm_test_keys.h:
--------------------------------------------------------------------------------
1 | /* tpm_test_keys.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _TPM_TEST_KEYS_H_
23 | #define _TPM_TEST_KEYS_H_
24 |
25 | #ifndef WOLFTPM2_NO_WRAPPER
26 | #include
27 | #include
28 |
29 | WOLFTPM_LOCAL int readKeyBlob(const char* filename, WOLFTPM2_KEYBLOB* key);
30 | WOLFTPM_LOCAL int writeKeyBlob(const char* filename, WOLFTPM2_KEYBLOB* key);
31 |
32 | WOLFTPM_LOCAL int writeBin(const char* filename, const byte *buf, word32 bufSz);
33 | WOLFTPM_LOCAL int readBin(const char* filename, byte *buf, word32* bufSz);
34 |
35 | WOLFTPM_LOCAL int readAndLoadKey(WOLFTPM2_DEV* pDev,
36 | WOLFTPM2_KEY* key,
37 | WOLFTPM2_HANDLE* parent,
38 | const char* filename,
39 | const byte* auth,
40 | int authSz);
41 |
42 | WOLFTPM_LOCAL int createAndLoadKey(WOLFTPM2_DEV* pDev,
43 | WOLFTPM2_KEY* key,
44 | WOLFTPM2_HANDLE* parent,
45 | const char* filename,
46 | const byte* auth,
47 | int authSz,
48 | TPMT_PUBLIC* publicTemplate);
49 |
50 |
51 | WOLFTPM_LOCAL int getPrimaryStoragekey(WOLFTPM2_DEV* pDev,
52 | WOLFTPM2_KEY* pStorageKey,
53 | TPM_ALG_ID alg);
54 |
55 | WOLFTPM_LOCAL int getRSAkey(WOLFTPM2_DEV* pDev,
56 | WOLFTPM2_KEY* pStorageKey,
57 | WOLFTPM2_KEY* key,
58 | void* pWolfRsaKey,
59 | int tpmDevId,
60 | const byte* auth, int authSz,
61 | TPMT_PUBLIC* publicTemplate);
62 |
63 | WOLFTPM_LOCAL int getECCkey(WOLFTPM2_DEV* pDev,
64 | WOLFTPM2_KEY* pStorageKey,
65 | WOLFTPM2_KEY* key,
66 | void* pWolfEccKey,
67 | int tpmDevId,
68 | const byte* auth, int authSz,
69 | TPMT_PUBLIC* publicTemplate);
70 |
71 |
72 | /* if *buf != NULL, it will use existing buffer and provided bufLen */
73 | WOLFTPM_LOCAL int loadFile(const char* fname, byte** buf, size_t* bufLen);
74 |
75 | WOLFTPM_LOCAL int hexToByte(const char *hex, unsigned char *output, unsigned long sz);
76 | WOLFTPM_LOCAL void printHexString(const unsigned char* bin, unsigned long sz,
77 | unsigned long maxLine);
78 |
79 | #endif /* !WOLFTPM2_NO_WRAPPER */
80 |
81 | #endif /* _TPM_TEST_KEYS_H_ */
82 |
--------------------------------------------------------------------------------
/examples/wrap/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_EXAMPLES
5 | noinst_PROGRAMS += examples/wrap/wrap_test \
6 | examples/wrap/caps
7 | noinst_HEADERS += examples/wrap/wrap_test.h
8 | examples_wrap_wrap_test_SOURCES = examples/wrap/wrap_test.c
9 | examples_wrap_wrap_test_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
10 | examples_wrap_wrap_test_DEPENDENCIES = src/libwolftpm.la
11 |
12 | examples_wrap_caps_SOURCES = examples/wrap/caps.c
13 | examples_wrap_caps_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
14 | examples_wrap_caps_DEPENDENCIES = src/libwolftpm.la
15 | endif
16 |
17 | example_wrapdir = $(exampledir)/wrap
18 | dist_example_wrap_DATA = examples/wrap/wrap_test.c \
19 | examples/wrap/caps.c
20 |
21 | DISTCLEANFILES+= examples/wrap/.libs/wrap_test \
22 | examples/wrap/.libs/caps
23 |
--------------------------------------------------------------------------------
/examples/wrap/wrap_test.h:
--------------------------------------------------------------------------------
1 | /* wrap_test.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _WRAP_TEST_H_
23 | #define _WRAP_TEST_H_
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | int TPM2_Wrapper_Test(void* userCtx);
30 | int TPM2_Wrapper_TestArgs(void* userCtx, int argc, char *argv[]);
31 |
32 | int TPM2_Wrapper_Caps(void* userCtx);
33 | int TPM2_Wrapper_CapsArgs(void* userCtx, int argc, char *argv[]);
34 |
35 | #ifdef __cplusplus
36 | } /* extern "C" */
37 | #endif
38 |
39 | #endif /* _WRAP_TEST_H_ */
40 |
--------------------------------------------------------------------------------
/hal/README.md:
--------------------------------------------------------------------------------
1 | # wolfTPM Hardware Interface Abstraction Layer (HAL) IO
2 |
3 | A single HAL callback must be registered to handle communication to the hardware.
4 |
5 | We distribute examples for several platforms to help with initial setup.
6 |
7 | If using one of the builtin system provided hardware interfaces then `NULL` can be supplied for the HAL IO callback.
8 |
9 | The available system TPM interfaces are:
10 | * Linux `/dev/tpm0`: Enabled with `WOLFTPM_LINUX_DEV` or `--enable-devtpm`.
11 | * Windows TBS: Enabled with `WOLFTPM_WINAPI` or `--enable-winapi`.
12 | * Software TPM Simulator: Enabled with `WOLFTPM_SWTPM` or `--enable-swtpm`.
13 |
14 | If using a HAL IO callback it is registered on library initialization using:
15 | * TPM2 Native API's: `TPM2_Init`
16 | * wolfTPM Wrappers: `wolfTPM2_Init`
17 |
18 | ## Example HAL Implementations
19 |
20 | | Platform | Example File | Build Option |
21 | | -------- | ------------ | ------------ |
22 | | Atmel ASF | `tpm_io_atmel.c` | `WOLFSSL_ATMEL` |
23 | | Barebox | `tpm_io_barebox.c` | `__BAREBOX__` |
24 | | Infineon | `tpm_io_infineon.c` | `WOLFTPM_INFINEON_TRICORE` |
25 | | Linux | `tpm_io_linux.c` | `__linux__` |
26 | | Microchip | `tpm_io_microchip.c` | `WOLFTPM_MICROCHIP_HARMONY` |
27 | | QNX | `tpm_io_qnx.c` | `__QNX__` |
28 | | ST Cube HAL | `tpm_io_st.c` | `WOLFSSL_STM32_CUBEMX` |
29 | | Xilinx | `tpm_io_xilinx.c` | `__XILINX__` |
30 |
31 | ## HAL IO Callback Function
32 |
33 | Here are the prototypes for the HAL callback function:
34 |
35 | ```c
36 | #ifdef WOLFTPM_ADV_IO
37 | typedef int (*TPM2HalIoCb)(struct TPM2_CTX*, INT32 isRead, UINT32 addr,
38 | BYTE* xferBuf, UINT16 xferSz, void* userCtx);
39 | #else
40 | typedef int (*TPM2HalIoCb)(struct TPM2_CTX*, const BYTE* txBuf, BYTE* rxBuf,
41 | UINT16 xferSz, void* userCtx);
42 | #endif
43 | ```
44 |
45 | Here are example function definitions:
46 |
47 | ```c
48 | #ifdef WOLFTPM_ADV_IO
49 | int TPM2_IoCb(TPM2_CTX*, int isRead, word32 addr, byte* buf, word16 size,
50 | void* userCtx);
51 | #else
52 | int TPM2_IoCb(TPM2_CTX* ctx, const byte* txBuf, byte* rxBuf,
53 | word16 xferSz, void* userCtx);
54 | #endif
55 | ```
56 |
57 | ## Additional Build options
58 |
59 | * `WOLFTPM_CHECK_WAIT_STATE`: Enables check of the wait state during a SPI transaction. Most TPM 2.0 chips require this and typically only require 0-2 wait cycles depending on the command. Only the Infineon TPM's guarantee no wait states.
60 | * `WOLFTPM_ADV_IO`: Enables advanced IO callback mode that includes TIS register and read/write flag. This is requires for I2C, but can be used with SPI also.
61 | * `WOLFTPM_DEBUG_IO`: Enable logging of the IO (if using the example HAL).
62 |
63 | ## Additional Compiler macros
64 |
65 | * `TPM2_SPI_DEV_PATH`: Set to the device string to be opened by the Linux IOCb. Default: "/dev/spidev0."
66 | * `TPM2_SPI_DEV_CS`: Set to the number string of the CS to use. Default: "0"
67 |
68 | These can be set during configure as:
69 | ./configure CPPFLAGS="-DTPM2_SPI_DEV_PATH=\"/dev/spidev0.\" -DTPM2_SPI_DEV_CS=\"0\" "
70 |
71 | Note that autodetect will use TPM2_SPI_DEV_PATH[0..4] for the searched device paths.
72 |
--------------------------------------------------------------------------------
/hal/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | if BUILD_HAL
5 | src_libwolftpm_la_SOURCES += \
6 | hal/tpm_io.c \
7 | hal/tpm_io_atmel.c \
8 | hal/tpm_io_barebox.c \
9 | hal/tpm_io_espressif.c \
10 | hal/tpm_io_linux.c \
11 | hal/tpm_io_infineon.c \
12 | hal/tpm_io_mmio.c \
13 | hal/tpm_io_microchip.c \
14 | hal/tpm_io_st.c \
15 | hal/tpm_io_qnx.c \
16 | hal/tpm_io_uboot.c \
17 | hal/tpm_io_xilinx.c
18 | endif
19 |
20 | nobase_include_HEADERS += hal/tpm_io.h
21 | EXTRA_DIST += hal/README.md
22 |
--------------------------------------------------------------------------------
/hal/tpm_io_barebox.c:
--------------------------------------------------------------------------------
1 | /* tpm_io_barebox.c
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | /* This example shows IO interfaces for Barebox */
23 |
24 | #ifdef HAVE_CONFIG_H
25 | #include
26 | #endif
27 |
28 | #include
29 | #include
30 | #include "tpm_io.h"
31 |
32 | /******************************************************************************/
33 | /* --- BEGIN IO Callback Logic -- */
34 | /******************************************************************************/
35 |
36 | /* Included via tpm_io.c if WOLFTPM_INCLUDE_IO_FILE is defined */
37 | #ifdef WOLFTPM_INCLUDE_IO_FILE
38 |
39 | #if ! (defined(WOLFTPM_LINUX_DEV) || \
40 | defined(WOLFTPM_SWTPM) || \
41 | defined(WOLFTPM_WINAPI) )
42 |
43 | /* Use the max speed by default - see tpm2_types.h for chip specific max values */
44 | #ifndef TPM2_SPI_HZ
45 | #define TPM2_SPI_HZ TPM2_SPI_MAX_HZ
46 | #endif
47 |
48 | #if defined(__BAREBOX__)
49 | #include
50 | #include
51 |
52 | int TPM2_IoCb_Barebox_SPI(TPM2_CTX* ctx, const byte* txBuf,
53 | byte* rxBuf, word16 xferSz, void* userCtx)
54 | {
55 | int ret = TPM_RC_FAILURE;
56 | struct spi_device spi;
57 | int bus = 0;
58 | struct spi_transfer t;
59 | struct spi_message m;
60 |
61 | #ifdef WOLFTPM_CHECK_WAIT_STATE
62 | #error SPI check wait state logic not supported for BareBox
63 | #endif
64 |
65 | XMEMSET(&spi, 0, sizeof(spi));
66 | spi.master = spi_get_master(bus); /* get bus 0 master */
67 | spi.max_speed_hz = 1 * 1000 * 1000; /* 1 MHz */
68 | spi.mode = 0; /* Mode 0 (CPOL=0, CPHA=0) */
69 | spi.bits_per_word = 8; /* 8-bits */
70 | spi.chip_select = 0; /* Use CS 0 */
71 |
72 | /* setup SPI master */
73 | ret = spi.master->setup(&spi);
74 |
75 | /* setup transfer */
76 | XMEMSET(&t, 0, sizeof(t));
77 | t.tx_buf = txBuf;
78 | t.rx_buf = rxBuf;
79 | t.len = xferSz;
80 | spi_message_init(&m);
81 | spi_message_add_tail(&t, &m);
82 | ret = spi_sync(&spi, &m);
83 | if (ret == 0)
84 | ret = TPM_RC_SUCCESS;
85 |
86 | (void)userCtx;
87 | (void)ctx;
88 |
89 | return ret;
90 | }
91 |
92 | #endif
93 | #endif /* !(WOLFTPM_LINUX_DEV || WOLFTPM_SWTPM || WOLFTPM_WINAPI) */
94 | #endif /* WOLFTPM_INCLUDE_IO_FILE */
95 |
96 | /******************************************************************************/
97 | /* --- END IO Callback Logic -- */
98 | /******************************************************************************/
99 |
--------------------------------------------------------------------------------
/hal/tpm_io_uboot.c:
--------------------------------------------------------------------------------
1 | /* tpm_io_uboot.c
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 | */
21 |
22 | /* This example shows IO interfaces for U-boot */
23 |
24 | #include
25 | #include
26 | #include "tpm_io.h"
27 |
28 | /******************************************************************************/
29 | /* --- BEGIN IO Callback Logic -- */
30 | /******************************************************************************/
31 |
32 | /* Included via tpm_io.c if WOLFTPM_INCLUDE_IO_FILE is defined */
33 | #ifdef WOLFTPM_INCLUDE_IO_FILE
34 |
35 | #if ! (defined(WOLFTPM_LINUX_DEV) || \
36 | defined(WOLFTPM_SWTPM) || \
37 | defined(WOLFTPM_WINAPI) )
38 |
39 | /* Use the max speed by default - see tpm2_types.h for chip specific max values */
40 | #ifndef TPM2_SPI_HZ
41 | #define TPM2_SPI_HZ TPM2_SPI_MAX_HZ
42 | #endif
43 |
44 | #if defined(__UBOOT__)
45 | #include
46 | int TPM2_IoCb_Uboot_SPI(TPM2_CTX* ctx, const byte* txBuf,
47 | byte* rxBuf, word16 xferSz, void* userCtx)
48 | {
49 | int ret = 0;
50 | struct udevice *dev;
51 |
52 | /* Get the TPM device */
53 | if (ret == 0) {
54 | ret = tcg2_platform_get_tpm2(&dev);
55 | if ( ret != 0 || dev == NULL) {
56 | #ifdef DEBUG_WOLFTPM
57 | printf("Failed to get TPM device with error: %d\n", ret);
58 | #endif
59 | return TPM_RC_FAILURE;
60 | }
61 | }
62 |
63 | /* Transfer the device data using tpm_xfer */
64 | if (ret == 0) {
65 | ret = tpm_xfer(dev, txBuf, xferSz, rxBuf, &xferSz);
66 | if (ret != 0) {
67 | #ifdef DEBUG_WOLFTPM
68 | printf("tpm_xfer failed with error: %d\n", ret);
69 | #endif
70 | return TPM_RC_FAILURE;
71 | }
72 | }
73 |
74 | return TPM_RC_SUCCESS;
75 | }
76 | #endif /* __UBOOT__ */
77 | #endif /* WOLFTPM_LINUX_DEV || WOLFTPM_SWTPM || WOLFTPM_WINAPI */
78 | #endif /* WOLFTPM_INCLUDE_IO_FILE */
79 |
80 | /******************************************************************************/
81 | /* --- END IO Callback Logic -- */
82 | /******************************************************************************/
83 |
--------------------------------------------------------------------------------
/m4/ax_add_am_macro.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_add_am_macro.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_ADD_AM_MACRO([RULE])
8 | #
9 | # DESCRIPTION
10 | #
11 | # Adds the specified rule to $AMINCLUDE. This macro will only work
12 | # properly with implementations of Make which allow include statements.
13 | # See also AX_ADD_AM_MACRO_STATIC.
14 | #
15 | # LICENSE
16 | #
17 | # Copyright (c) 2009 Tom Howard
18 | #
19 | # Copying and distribution of this file, with or without modification, are
20 | # permitted in any medium without royalty provided the copyright notice
21 | # and this notice are preserved. This file is offered as-is, without any
22 | # warranty.
23 |
24 | #serial 10
25 |
26 | AC_DEFUN([AX_ADD_AM_MACRO],[
27 | AC_REQUIRE([AX_AM_MACROS])
28 | AX_APPEND_TO_FILE([$AMINCLUDE],[$1])
29 | ])
30 |
--------------------------------------------------------------------------------
/m4/ax_am_jobserver.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_am_jobserver.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_AM_JOBSERVER([default_value])
8 | #
9 | # DESCRIPTION
10 | #
11 | # Enables the use of make's jobserver for the purpose of parallel building
12 | # by passing the -j option to make.
13 | #
14 | # The option --enable-jobserver is added to configure which can accept a
15 | # yes, no, or an integer. The integer is the number of separate jobs to
16 | # allow. If 'yes' is given, then the is assumed to be one more than the
17 | # number of CPUs (determined through AX_COUNT_CPUS). If the value of no is
18 | # given, then the jobserver is disabled. The default value is given by the
19 | # first argument of the macro, or 'yes' if the argument is omitted.
20 | #
21 | # This macro makes use of AX_AM_MACROS, so you must add the following line
22 | #
23 | # @INC_AMINCLUDE@
24 | #
25 | # to your Makefile.am files.
26 | #
27 | # LICENSE
28 | #
29 | # Copyright (c) 2008 Michael Paul Bailey
30 | #
31 | # Copying and distribution of this file, with or without modification, are
32 | # permitted in any medium without royalty provided the copyright notice
33 | # and this notice are preserved. This file is offered as-is, without any
34 | # warranty.
35 |
36 | #serial 8
37 |
38 | AC_DEFUN([AX_AM_JOBSERVER], [
39 | AC_REQUIRE([AX_COUNT_CPUS])
40 | AC_REQUIRE([AX_AM_MACROS])
41 | AC_ARG_ENABLE( jobserver,
42 | [ --enable-jobserver@<:@=no/yes/@%:@@:>@ default=m4_ifval([$1],[$1],[yes])
43 | Enable up to @%:@ make jobs
44 | yes: enable one more than CPU count
45 | ],, [enable_jobserver=m4_ifval([$1],[$1],[yes])])
46 | if test "x$enable_jobserver" = "xyes"; then
47 | enable_jobserver=$CPU_COUNT
48 | ((enable_jobserver++))
49 | fi
50 | m4_pattern_allow(AM_MAKEFLAGS)
51 | if test "x$enable_jobserver" != "xno"; then
52 | AC_MSG_NOTICE([added jobserver support to make for $enable_jobserver jobs])
53 | AX_ADD_AM_MACRO( AM_MAKEFLAGS += -j$enable_jobserver )
54 | fi
55 | ])
56 |
--------------------------------------------------------------------------------
/m4/ax_am_macros.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_am_macros.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_AM_MACROS
8 | #
9 | # DESCRIPTION
10 | #
11 | # Adds support for macros that create Make rules. You must manually add
12 | # the following line
13 | #
14 | # @INC_AMINCLUDE@
15 | #
16 | # to your Makefile.in (or Makefile.am if you use Automake) files.
17 | #
18 | # LICENSE
19 | #
20 | # Copyright (c) 2009 Tom Howard
21 | #
22 | # Copying and distribution of this file, with or without modification, are
23 | # permitted in any medium without royalty provided the copyright notice
24 | # and this notice are preserved. This file is offered as-is, without any
25 | # warranty.
26 |
27 | #serial 11
28 |
29 | AC_DEFUN([AX_AM_MACROS],
30 | [
31 | AC_MSG_NOTICE([adding automake macro support])
32 | AMINCLUDE="aminclude.am"
33 | AC_SUBST(AMINCLUDE)
34 | AC_MSG_NOTICE([creating $AMINCLUDE])
35 | AMINCLUDE_TIME=`LC_ALL=C date`
36 | AX_PRINT_TO_FILE([$AMINCLUDE],[[
37 | # generated automatically by configure from AX_AUTOMAKE_MACROS
38 | # on $AMINCLUDE_TIME
39 |
40 | ]])
41 |
42 | INC_AMINCLUDE="include \$(top_builddir)/$AMINCLUDE"
43 | AC_SUBST(INC_AMINCLUDE)
44 | ])
45 |
--------------------------------------------------------------------------------
/m4/ax_append_compile_flags.m4:
--------------------------------------------------------------------------------
1 | # ============================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
3 | # ============================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
8 | #
9 | # DESCRIPTION
10 | #
11 | # For every FLAG1, FLAG2 it is checked whether the compiler works with the
12 | # flag. If it does, the flag is added FLAGS-VARIABLE
13 | #
14 | # If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
15 | # CFLAGS) is used. During the check the flag is always added to the
16 | # current language's flags.
17 | #
18 | # If EXTRA-FLAGS is defined, it is added to the current language's default
19 | # flags (e.g. CFLAGS) when the check is done. The check is thus made with
20 | # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
21 | # force the compiler to issue an error when a bad flag is given.
22 | #
23 | # INPUT gives an alternative input source to AC_COMPILE_IFELSE.
24 | #
25 | # NOTE: This macro depends on the AX_APPEND_FLAG and
26 | # AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
27 | # AX_APPEND_LINK_FLAGS.
28 | #
29 | # LICENSE
30 | #
31 | # Copyright (c) 2011 Maarten Bosmans
32 | #
33 | # This program is free software: you can redistribute it and/or modify it
34 | # under the terms of the GNU General Public License as published by the
35 | # Free Software Foundation, either version 3 of the License, or (at your
36 | # option) any later version.
37 | #
38 | # This program is distributed in the hope that it will be useful, but
39 | # WITHOUT ANY WARRANTY; without even the implied warranty of
40 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
41 | # Public License for more details.
42 | #
43 | # You should have received a copy of the GNU General Public License along
44 | # with this program. If not, see .
45 | #
46 | # As a special exception, the respective Autoconf Macro's copyright owner
47 | # gives unlimited permission to copy, distribute and modify the configure
48 | # scripts that are the output of Autoconf when processing the Macro. You
49 | # need not follow the terms of the GNU General Public License when using
50 | # or distributing such scripts, even though portions of the text of the
51 | # Macro appear in them. The GNU General Public License (GPL) does govern
52 | # all other use of the material that constitutes the Autoconf Macro.
53 | #
54 | # This special exception to the GPL applies to versions of the Autoconf
55 | # Macro released by the Autoconf Archive. When you make and distribute a
56 | # modified version of the Autoconf Macro, you may extend this special
57 | # exception to the GPL to apply to your modified version as well.
58 |
59 | #serial 6
60 |
61 | AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
62 | [AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
63 | AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
64 | for flag in $1; do
65 | AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4])
66 | done
67 | ])dnl AX_APPEND_COMPILE_FLAGS
68 |
--------------------------------------------------------------------------------
/m4/ax_append_flag.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_append_flag.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
8 | #
9 | # DESCRIPTION
10 | #
11 | # FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
12 | # added in between.
13 | #
14 | # If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
15 | # CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
16 | # FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
17 | # FLAG.
18 | #
19 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
20 | #
21 | # LICENSE
22 | #
23 | # Copyright (c) 2008 Guido U. Draheim
24 | # Copyright (c) 2011 Maarten Bosmans
25 | #
26 | # This program is free software: you can redistribute it and/or modify it
27 | # under the terms of the GNU General Public License as published by the
28 | # Free Software Foundation, either version 3 of the License, or (at your
29 | # option) any later version.
30 | #
31 | # This program is distributed in the hope that it will be useful, but
32 | # WITHOUT ANY WARRANTY; without even the implied warranty of
33 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
34 | # Public License for more details.
35 | #
36 | # You should have received a copy of the GNU General Public License along
37 | # with this program. If not, see .
38 | #
39 | # As a special exception, the respective Autoconf Macro's copyright owner
40 | # gives unlimited permission to copy, distribute and modify the configure
41 | # scripts that are the output of Autoconf when processing the Macro. You
42 | # need not follow the terms of the GNU General Public License when using
43 | # or distributing such scripts, even though portions of the text of the
44 | # Macro appear in them. The GNU General Public License (GPL) does govern
45 | # all other use of the material that constitutes the Autoconf Macro.
46 | #
47 | # This special exception to the GPL applies to versions of the Autoconf
48 | # Macro released by the Autoconf Archive. When you make and distribute a
49 | # modified version of the Autoconf Macro, you may extend this special
50 | # exception to the GPL to apply to your modified version as well.
51 |
52 | #serial 7
53 |
54 | AC_DEFUN([AX_APPEND_FLAG],
55 | [dnl
56 | AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
57 | AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
58 | AS_VAR_SET_IF(FLAGS,[
59 | AS_CASE([" AS_VAR_GET(FLAGS) "],
60 | [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
61 | [
62 | AS_VAR_APPEND(FLAGS,[" $1"])
63 | AC_RUN_LOG([: FLAGS="$FLAGS"])
64 | ])
65 | ],
66 | [
67 | AS_VAR_SET(FLAGS,[$1])
68 | AC_RUN_LOG([: FLAGS="$FLAGS"])
69 | ])
70 | AS_VAR_POPDEF([FLAGS])dnl
71 | ])dnl AX_APPEND_FLAG
72 |
--------------------------------------------------------------------------------
/m4/ax_append_link_flags.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
8 | #
9 | # DESCRIPTION
10 | #
11 | # For every FLAG1, FLAG2 it is checked whether the linker works with the
12 | # flag. If it does, the flag is added FLAGS-VARIABLE
13 | #
14 | # If FLAGS-VARIABLE is not specified, the linker's flags (LDFLAGS) is
15 | # used. During the check the flag is always added to the linker's flags.
16 | #
17 | # If EXTRA-FLAGS is defined, it is added to the linker's default flags
18 | # when the check is done. The check is thus made with the flags: "LDFLAGS
19 | # EXTRA-FLAGS FLAG". This can for example be used to force the linker to
20 | # issue an error when a bad flag is given.
21 | #
22 | # INPUT gives an alternative input source to AC_COMPILE_IFELSE.
23 | #
24 | # NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG.
25 | # Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS.
26 | #
27 | # LICENSE
28 | #
29 | # Copyright (c) 2011 Maarten Bosmans
30 | #
31 | # This program is free software: you can redistribute it and/or modify it
32 | # under the terms of the GNU General Public License as published by the
33 | # Free Software Foundation, either version 3 of the License, or (at your
34 | # option) any later version.
35 | #
36 | # This program is distributed in the hope that it will be useful, but
37 | # WITHOUT ANY WARRANTY; without even the implied warranty of
38 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
39 | # Public License for more details.
40 | #
41 | # You should have received a copy of the GNU General Public License along
42 | # with this program. If not, see .
43 | #
44 | # As a special exception, the respective Autoconf Macro's copyright owner
45 | # gives unlimited permission to copy, distribute and modify the configure
46 | # scripts that are the output of Autoconf when processing the Macro. You
47 | # need not follow the terms of the GNU General Public License when using
48 | # or distributing such scripts, even though portions of the text of the
49 | # Macro appear in them. The GNU General Public License (GPL) does govern
50 | # all other use of the material that constitutes the Autoconf Macro.
51 | #
52 | # This special exception to the GPL applies to versions of the Autoconf
53 | # Macro released by the Autoconf Archive. When you make and distribute a
54 | # modified version of the Autoconf Macro, you may extend this special
55 | # exception to the GPL to apply to your modified version as well.
56 |
57 | #serial 6
58 |
59 | AC_DEFUN([AX_APPEND_LINK_FLAGS],
60 | [AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
61 | AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
62 | for flag in $1; do
63 | AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3], [$4])
64 | done
65 | ])dnl AX_APPEND_LINK_FLAGS
66 |
--------------------------------------------------------------------------------
/m4/ax_append_to_file.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_append_to_file.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_APPEND_TO_FILE([FILE],[DATA])
8 | #
9 | # DESCRIPTION
10 | #
11 | # Appends the specified data to the specified file.
12 | #
13 | # LICENSE
14 | #
15 | # Copyright (c) 2008 Tom Howard
16 | #
17 | # Copying and distribution of this file, with or without modification, are
18 | # permitted in any medium without royalty provided the copyright notice
19 | # and this notice are preserved. This file is offered as-is, without any
20 | # warranty.
21 |
22 | #serial 9
23 |
24 | AC_DEFUN([AX_APPEND_TO_FILE],[
25 | AC_REQUIRE([AX_FILE_ESCAPES])
26 | printf "%s" "$2" >> "$1"
27 | ])
28 |
--------------------------------------------------------------------------------
/m4/ax_check_compile_flag.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
8 | #
9 | # DESCRIPTION
10 | #
11 | # Check whether the given FLAG works with the current language's compiler
12 | # or gives an error. (Warnings, however, are ignored)
13 | #
14 | # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
15 | # success/failure.
16 | #
17 | # If EXTRA-FLAGS is defined, it is added to the current language's default
18 | # flags (e.g. CFLAGS) when the check is done. The check is thus made with
19 | # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
20 | # force the compiler to issue an error when a bad flag is given.
21 | #
22 | # INPUT gives an alternative input source to AC_COMPILE_IFELSE.
23 | #
24 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
25 | # macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
26 | #
27 | # LICENSE
28 | #
29 | # Copyright (c) 2008 Guido U. Draheim
30 | # Copyright (c) 2011 Maarten Bosmans
31 | #
32 | # This program is free software: you can redistribute it and/or modify it
33 | # under the terms of the GNU General Public License as published by the
34 | # Free Software Foundation, either version 3 of the License, or (at your
35 | # option) any later version.
36 | #
37 | # This program is distributed in the hope that it will be useful, but
38 | # WITHOUT ANY WARRANTY; without even the implied warranty of
39 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
40 | # Public License for more details.
41 | #
42 | # You should have received a copy of the GNU General Public License along
43 | # with this program. If not, see .
44 | #
45 | # As a special exception, the respective Autoconf Macro's copyright owner
46 | # gives unlimited permission to copy, distribute and modify the configure
47 | # scripts that are the output of Autoconf when processing the Macro. You
48 | # need not follow the terms of the GNU General Public License when using
49 | # or distributing such scripts, even though portions of the text of the
50 | # Macro appear in them. The GNU General Public License (GPL) does govern
51 | # all other use of the material that constitutes the Autoconf Macro.
52 | #
53 | # This special exception to the GPL applies to versions of the Autoconf
54 | # Macro released by the Autoconf Archive. When you make and distribute a
55 | # modified version of the Autoconf Macro, you may extend this special
56 | # exception to the GPL to apply to your modified version as well.
57 |
58 | #serial 5
59 |
60 | AC_DEFUN([AX_CHECK_COMPILE_FLAG],
61 | [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
62 | AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
63 | AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
64 | ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
65 | _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
66 | AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
67 | [AS_VAR_SET(CACHEVAR,[yes])],
68 | [AS_VAR_SET(CACHEVAR,[no])])
69 | _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
70 | AS_VAR_IF(CACHEVAR,yes,
71 | [m4_default([$2], :)],
72 | [m4_default([$3], :)])
73 | AS_VAR_POPDEF([CACHEVAR])dnl
74 | ])dnl AX_CHECK_COMPILE_FLAGS
75 |
--------------------------------------------------------------------------------
/m4/ax_check_link_flag.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
8 | #
9 | # DESCRIPTION
10 | #
11 | # Check whether the given FLAG works with the linker or gives an error.
12 | # (Warnings, however, are ignored)
13 | #
14 | # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
15 | # success/failure.
16 | #
17 | # If EXTRA-FLAGS is defined, it is added to the linker's default flags
18 | # when the check is done. The check is thus made with the flags: "LDFLAGS
19 | # EXTRA-FLAGS FLAG". This can for example be used to force the linker to
20 | # issue an error when a bad flag is given.
21 | #
22 | # INPUT gives an alternative input source to AC_LINK_IFELSE.
23 | #
24 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
25 | # macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
26 | #
27 | # LICENSE
28 | #
29 | # Copyright (c) 2008 Guido U. Draheim
30 | # Copyright (c) 2011 Maarten Bosmans
31 | #
32 | # This program is free software: you can redistribute it and/or modify it
33 | # under the terms of the GNU General Public License as published by the
34 | # Free Software Foundation, either version 3 of the License, or (at your
35 | # option) any later version.
36 | #
37 | # This program is distributed in the hope that it will be useful, but
38 | # WITHOUT ANY WARRANTY; without even the implied warranty of
39 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
40 | # Public License for more details.
41 | #
42 | # You should have received a copy of the GNU General Public License along
43 | # with this program. If not, see .
44 | #
45 | # As a special exception, the respective Autoconf Macro's copyright owner
46 | # gives unlimited permission to copy, distribute and modify the configure
47 | # scripts that are the output of Autoconf when processing the Macro. You
48 | # need not follow the terms of the GNU General Public License when using
49 | # or distributing such scripts, even though portions of the text of the
50 | # Macro appear in them. The GNU General Public License (GPL) does govern
51 | # all other use of the material that constitutes the Autoconf Macro.
52 | #
53 | # This special exception to the GPL applies to versions of the Autoconf
54 | # Macro released by the Autoconf Archive. When you make and distribute a
55 | # modified version of the Autoconf Macro, you may extend this special
56 | # exception to the GPL to apply to your modified version as well.
57 |
58 | #serial 5
59 |
60 | AC_DEFUN([AX_CHECK_LINK_FLAG],
61 | [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
62 | AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
63 | AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
64 | ax_check_save_flags=$LDFLAGS
65 | LDFLAGS="$LDFLAGS $4 $1"
66 | AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
67 | [AS_VAR_SET(CACHEVAR,[yes])],
68 | [AS_VAR_SET(CACHEVAR,[no])])
69 | LDFLAGS=$ax_check_save_flags])
70 | AS_VAR_IF(CACHEVAR,yes,
71 | [m4_default([$2], :)],
72 | [m4_default([$3], :)])
73 | AS_VAR_POPDEF([CACHEVAR])dnl
74 | ])dnl AX_CHECK_LINK_FLAGS
75 |
--------------------------------------------------------------------------------
/m4/ax_debug.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://github.com/BrianAker/ddm4/
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_DEBUG()
8 | #
9 | # DESCRIPTION
10 | #
11 | # --enable-debug
12 | #
13 | # LICENSE
14 | #
15 | # Copyright (C) 2012 Brian Aker
16 | # All rights reserved.
17 | #
18 | # Redistribution and use in source and binary forms, with or without
19 | # modification, are permitted provided that the following conditions are
20 | # met:
21 | #
22 | # * Redistributions of source code must retain the above copyright
23 | # notice, this list of conditions and the following disclaimer.
24 | #
25 | # * Redistributions in binary form must reproduce the above
26 | # copyright notice, this list of conditions and the following disclaimer
27 | # in the documentation and/or other materials provided with the
28 | # distribution.
29 | #
30 | # * The names of its contributors may not be used to endorse or
31 | # promote products derived from this software without specific prior
32 | # written permission.
33 | #
34 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
37 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
38 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
42 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 |
46 | #serial 6.1
47 |
48 | AC_DEFUN([AX_DEBUG],
49 | [AC_PREREQ([2.63])dnl
50 | AC_ARG_ENABLE([debug],
51 | [AS_HELP_STRING([--enable-debug],
52 | [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])],
53 | [ax_enable_debug=$enableval],
54 | [ax_enable_debug=no])
55 |
56 | AS_IF([test "x$ax_enable_debug" != "xno"],
57 | [AC_DEFINE([DEBUG],[1],[Define to 1 to enable debugging code.])],
58 | [AC_SUBST([MCHECK])
59 | AC_DEFINE([DEBUG],[0],[Define to 1 to enable debugging code.])])
60 |
61 | AC_MSG_CHECKING([for debug])
62 | AC_MSG_RESULT([$ax_enable_debug])
63 | AM_CONDITIONAL([DEBUG],[test "x${ax_enable_debug}" = xyes])])
64 |
--------------------------------------------------------------------------------
/m4/ax_file_escapes.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_file_escapes.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_FILE_ESCAPES
8 | #
9 | # DESCRIPTION
10 | #
11 | # Writes the specified data to the specified file.
12 | #
13 | # LICENSE
14 | #
15 | # Copyright (c) 2008 Tom Howard
16 | #
17 | # Copying and distribution of this file, with or without modification, are
18 | # permitted in any medium without royalty provided the copyright notice
19 | # and this notice are preserved. This file is offered as-is, without any
20 | # warranty.
21 |
22 | #serial 8
23 |
24 | AC_DEFUN([AX_FILE_ESCAPES],[
25 | AX_DOLLAR="\$"
26 | AX_SRB="\\135"
27 | AX_SLB="\\133"
28 | AX_BS="\\\\"
29 | AX_DQ="\""
30 | ])
31 |
--------------------------------------------------------------------------------
/m4/ax_print_to_file.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_print_to_file.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_PRINT_TO_FILE([FILE],[DATA])
8 | #
9 | # DESCRIPTION
10 | #
11 | # Writes the specified data to the specified file.
12 | #
13 | # LICENSE
14 | #
15 | # Copyright (c) 2008 Tom Howard
16 | #
17 | # Copying and distribution of this file, with or without modification, are
18 | # permitted in any medium without royalty provided the copyright notice
19 | # and this notice are preserved. This file is offered as-is, without any
20 | # warranty.
21 |
22 | #serial 8
23 |
24 | AC_DEFUN([AX_PRINT_TO_FILE],[
25 | AC_REQUIRE([AX_FILE_ESCAPES])
26 | printf "$2" > "$1"
27 | ])
28 |
--------------------------------------------------------------------------------
/m4/ax_require_defined.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_require_defined.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_REQUIRE_DEFINED(MACRO)
8 | #
9 | # DESCRIPTION
10 | #
11 | # AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
12 | # been defined and thus are available for use. This avoids random issues
13 | # where a macro isn't expanded. Instead the configure script emits a
14 | # non-fatal:
15 | #
16 | # ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
17 | #
18 | # It's like AC_REQUIRE except it doesn't expand the required macro.
19 | #
20 | # Here's an example:
21 | #
22 | # AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
23 | #
24 | # LICENSE
25 | #
26 | # Copyright (c) 2014 Mike Frysinger
27 | #
28 | # Copying and distribution of this file, with or without modification, are
29 | # permitted in any medium without royalty provided the copyright notice
30 | # and this notice are preserved. This file is offered as-is, without any
31 | # warranty.
32 |
33 | #serial 2
34 |
35 | AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
36 | m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
37 | ])dnl AX_REQUIRE_DEFINED
38 |
--------------------------------------------------------------------------------
/m4/ax_tls.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_tls.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_TLS([action-if-found], [action-if-not-found])
8 | #
9 | # DESCRIPTION
10 | #
11 | # Provides a test for the compiler support of thread local storage (TLS)
12 | # extensions. Defines TLS if it is found. Currently knows about C++11,
13 | # GCC/ICC, and MSVC. I think SunPro uses the same as GCC, and Borland
14 | # apparently supports either.
15 | #
16 | # LICENSE
17 | #
18 | # Copyright (c) 2008 Alan Woodland
19 | # Copyright (c) 2010 Diego Elio Petteno`
20 | #
21 | # This program is free software: you can redistribute it and/or modify it
22 | # under the terms of the GNU General Public License as published by the
23 | # Free Software Foundation, either version 3 of the License, or (at your
24 | # option) any later version.
25 | #
26 | # This program is distributed in the hope that it will be useful, but
27 | # WITHOUT ANY WARRANTY; without even the implied warranty of
28 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
29 | # Public License for more details.
30 | #
31 | # You should have received a copy of the GNU General Public License along
32 | # with this program. If not, see .
33 | #
34 | # As a special exception, the respective Autoconf Macro's copyright owner
35 | # gives unlimited permission to copy, distribute and modify the configure
36 | # scripts that are the output of Autoconf when processing the Macro. You
37 | # need not follow the terms of the GNU General Public License when using
38 | # or distributing such scripts, even though portions of the text of the
39 | # Macro appear in them. The GNU General Public License (GPL) does govern
40 | # all other use of the material that constitutes the Autoconf Macro.
41 | #
42 | # This special exception to the GPL applies to versions of the Autoconf
43 | # Macro released by the Autoconf Archive. When you make and distribute a
44 | # modified version of the Autoconf Macro, you may extend this special
45 | # exception to the GPL to apply to your modified version as well.
46 |
47 | #serial 15
48 |
49 | # Define m4_ifblank and m4_ifnblank macros from introduced in
50 | # autotools 2.64 m4sugar.m4 if using an earlier autotools.
51 |
52 | ifdef([m4_ifblank], [], [
53 | m4_define([m4_ifblank],
54 | [m4_if(m4_translit([[$1]], [ ][ ][
55 | ]), [], [$2], [$3])])
56 | ])
57 |
58 | ifdef([m4_ifnblank], [], [
59 | m4_define([m4_ifnblank],
60 | [m4_if(m4_translit([[$1]], [ ][ ][
61 | ]), [], [$3], [$2])])
62 | ])
63 |
64 | AC_DEFUN([AX_TLS], [
65 | AC_MSG_CHECKING([for thread local storage (TLS) class])
66 | AC_CACHE_VAL([ac_cv_tls],
67 | [for ax_tls_keyword in thread_local _Thread_local __thread '__declspec(thread)' none; do
68 | AS_CASE([$ax_tls_keyword],
69 | [none], [ac_cv_tls=none ; break],
70 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
71 | [#include ],
72 | [static $ax_tls_keyword int bar;]
73 | )],
74 | [ac_cv_tls=$ax_tls_keyword ; break],
75 | [ac_cv_tls=none]
76 | )]
77 | )
78 | done ]
79 | )
80 | AC_MSG_RESULT([$ac_cv_tls])
81 |
82 | AS_IF([test "$ac_cv_tls" != "none"],
83 | [AC_DEFINE_UNQUOTED([TLS],[$ac_cv_tls],[If the compiler supports a TLS storage class, define it to that here])
84 | m4_ifnblank([$1],[$1],[[:]])],
85 | [m4_ifnblank([$2],[$2],[[:]])])
86 | ])
87 |
--------------------------------------------------------------------------------
/m4/ax_vcs_checkout.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # http://
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_VCS_CHECKOUT
8 | #
9 | # DESCRIPTION
10 | #
11 | # Discover whether or not we are operating with a tree which
12 | # has been checked out of a version control system.
13 | #
14 | #
15 | # LICENSE
16 | #
17 | # Copyright (C) 2012 Brian Aker
18 | # All rights reserved.
19 | #
20 | # Redistribution and use in source and binary forms, with or without
21 | # modification, are permitted provided that the following conditions are
22 | # met:
23 | #
24 | # * Redistributions of source code must retain the above copyright
25 | # notice, this list of conditions and the following disclaimer.
26 | #
27 | # * Redistributions in binary form must reproduce the above
28 | # copyright notice, this list of conditions and the following disclaimer
29 | # in the documentation and/or other materials provided with the
30 | # distribution.
31 | #
32 | # * The names of its contributors may not be used to endorse or
33 | # promote products derived from this software without specific prior
34 | # written permission.
35 | #
36 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
37 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
38 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
39 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
40 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
43 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
45 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
46 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47 |
48 | #serial 6
49 |
50 | AC_DEFUN([AX_VCS_SYSTEM],
51 | [AC_PREREQ([2.63])dnl
52 | AC_CACHE_CHECK([for vcs system], [ac_cv_vcs_system],
53 | [ac_cv_vcs_system="none"
54 | AS_IF([test -d ".bzr"],[ac_cv_vcs_system="bazaar"])
55 | AS_IF([test -d ".svn"],[ac_cv_vcs_system="svn"])
56 | AS_IF([test -d ".hg"],[ac_cv_vcs_system="mercurial"])
57 | AS_IF([test -d ".git"],[ac_cv_vcs_system="git"])
58 | ])
59 | AC_DEFINE_UNQUOTED([VCS_SYSTEM],["$ac_cv_vcs_system"],[VCS system])
60 | ])
61 |
62 | AC_DEFUN([AX_VCS_CHECKOUT],
63 | [AC_PREREQ([2.63])dnl
64 | AC_REQUIRE([AX_VCS_SYSTEM])
65 | AC_CACHE_CHECK([for vcs checkout],[ac_cv_vcs_checkout],
66 | [AS_IF([test "x$ac_cv_vcs_system" != "xnone"],
67 | [ac_cv_vcs_checkout=yes],
68 | [ac_cv_vcs_checkout=no])
69 | ])
70 |
71 | AM_CONDITIONAL([IS_VCS_CHECKOUT],[test "x$ac_cv_vcs_checkout" = "xyes"])
72 | AS_IF([test "x$ac_cv_vcs_checkout" = "xyes"],
73 | [AC_DEFINE([VCS_CHECKOUT],[1],[Define if the code was built from VCS.])],
74 | [AC_DEFINE([VCS_CHECKOUT],[0],[Define if the code was built from VCS.])])
75 | ])
76 |
--------------------------------------------------------------------------------
/m4/hexversion.m4:
--------------------------------------------------------------------------------
1 | AC_DEFUN([CREATE_HEX_VERSION],[
2 |
3 | HEX_VERSION=`echo $VERSION | sed 's|[\-a-z0-9]*$||' | \
4 | awk -F. '{printf "0x%0.2d%0.3d%0.3d", $[]1, $[]2, $[]3}'`
5 | AC_SUBST([HEX_VERSION])
6 | ])
7 |
--------------------------------------------------------------------------------
/m4/lib-ld.m4:
--------------------------------------------------------------------------------
1 | # lib-ld.m4 serial 3 (gettext-0.13)
2 | dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
3 | dnl This file is free software; the Free Software Foundation
4 | dnl gives unlimited permission to copy and/or distribute it,
5 | dnl with or without modifications, as long as this notice is preserved.
6 |
7 | dnl Subroutines of libtool.m4,
8 | dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
9 | dnl with libtool.m4.
10 |
11 | dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
12 | AC_DEFUN([AC_LIB_PROG_LD_GNU],
13 | [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
14 | [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
15 | case `$LD -v 2>&1 conf$$.sh
35 | echo "exit 0" >>conf$$.sh
36 | chmod +x conf$$.sh
37 | if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
38 | PATH_SEPARATOR=';'
39 | else
40 | PATH_SEPARATOR=:
41 | fi
42 | rm -f conf$$.sh
43 | fi
44 | ac_prog=ld
45 | if test "$GCC" = yes; then
46 | # Check if gcc -print-prog-name=ld gives a path.
47 | AC_MSG_CHECKING([for ld used by GCC])
48 | case $host in
49 | *-*-mingw*)
50 | # gcc leaves a trailing carriage return which upsets mingw
51 | ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
52 | *)
53 | ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
54 | esac
55 | case $ac_prog in
56 | # Accept absolute paths.
57 | [[\\/]* | [A-Za-z]:[\\/]*)]
58 | [re_direlt='/[^/][^/]*/\.\./']
59 | # Canonicalize the path of ld
60 | ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
61 | while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
62 | ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
63 | done
64 | test -z "$LD" && LD="$ac_prog"
65 | ;;
66 | "")
67 | # If it fails, then pretend we aren't using GCC.
68 | ac_prog=ld
69 | ;;
70 | *)
71 | # If it is relative, then search for the first ld in PATH.
72 | with_gnu_ld=unknown
73 | ;;
74 | esac
75 | elif test "$with_gnu_ld" = yes; then
76 | AC_MSG_CHECKING([for GNU ld])
77 | else
78 | AC_MSG_CHECKING([for non-GNU ld])
79 | fi
80 | AC_CACHE_VAL(acl_cv_path_LD,
81 | [if test -z "$LD"; then
82 | IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
83 | for ac_dir in $PATH; do
84 | test -z "$ac_dir" && ac_dir=.
85 | if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
86 | acl_cv_path_LD="$ac_dir/$ac_prog"
87 | # Check to see if the program is GNU ld. I'd rather use --version,
88 | # but apparently some GNU ld's only accept -v.
89 | # Break only if it was the GNU/non-GNU ld that we prefer.
90 | case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
91 | *GNU* | *'with BFD'*)
92 | test "$with_gnu_ld" != no && break ;;
93 | *)
94 | test "$with_gnu_ld" != yes && break ;;
95 | esac
96 | fi
97 | done
98 | IFS="$ac_save_ifs"
99 | else
100 | acl_cv_path_LD="$LD" # Let the user override the test with a path.
101 | fi])
102 | LD="$acl_cv_path_LD"
103 | if test -n "$LD"; then
104 | AC_MSG_RESULT($LD)
105 | else
106 | AC_MSG_RESULT(no)
107 | fi
108 | test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
109 | AC_LIB_PROG_LD_GNU
110 | ])
111 |
--------------------------------------------------------------------------------
/m4/visibility.m4:
--------------------------------------------------------------------------------
1 | # visibility.m4 serial 5 (gettext-0.18.2)
2 | dnl Copyright (C) 2005, 2008, 2010-2018 Free Software Foundation, Inc.
3 | dnl This file is free software; the Free Software Foundation
4 | dnl gives unlimited permission to copy and/or distribute it,
5 | dnl with or without modifications, as long as this notice is preserved.
6 |
7 | dnl From Bruno Haible.
8 |
9 | dnl Tests whether the compiler supports the command-line option
10 | dnl -fvisibility=hidden and the function and variable attributes
11 | dnl __attribute__((__visibility__("hidden"))) and
12 | dnl __attribute__((__visibility__("default"))).
13 | dnl Does *not* test for __visibility__("protected") - which has tricky
14 | dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
15 | dnl Mac OS X.
16 | dnl Does *not* test for __visibility__("internal") - which has processor
17 | dnl dependent semantics.
18 | dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
19 | dnl "really only recommended for legacy code".
20 | dnl Set the variable CFLAG_VISIBILITY.
21 | dnl Defines and sets the variable HAVE_VISIBILITY.
22 |
23 | AC_DEFUN([gl_VISIBILITY],
24 | [
25 | AC_REQUIRE([AC_PROG_CC])
26 | CFLAG_VISIBILITY=
27 | HAVE_VISIBILITY=0
28 | if test -n "$GCC"; then
29 | dnl First, check whether -Werror can be added to the command line, or
30 | dnl whether it leads to an error because of some other option that the
31 | dnl user has put into $CC $CFLAGS $CPPFLAGS.
32 | AC_MSG_CHECKING([whether the -Werror option is usable])
33 | AC_CACHE_VAL([gl_cv_cc_vis_werror], [
34 | gl_save_CFLAGS="$CFLAGS"
35 | CFLAGS="$CFLAGS -Werror"
36 | AC_COMPILE_IFELSE(
37 | [AC_LANG_PROGRAM([[]], [[]])],
38 | [gl_cv_cc_vis_werror=yes],
39 | [gl_cv_cc_vis_werror=no])
40 | CFLAGS="$gl_save_CFLAGS"])
41 | AC_MSG_RESULT([$gl_cv_cc_vis_werror])
42 | dnl Now check whether visibility declarations are supported.
43 | AC_MSG_CHECKING([for simple visibility declarations])
44 | AC_CACHE_VAL([gl_cv_cc_visibility], [
45 | gl_save_CFLAGS="$CFLAGS"
46 | CFLAGS="$CFLAGS -fvisibility=hidden"
47 | dnl We use the option -Werror and a function dummyfunc, because on some
48 | dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
49 | dnl "visibility attribute not supported in this configuration; ignored"
50 | dnl at the first function definition in every compilation unit, and we
51 | dnl don't want to use the option in this case.
52 | if test $gl_cv_cc_vis_werror = yes; then
53 | CFLAGS="$CFLAGS -Werror"
54 | fi
55 | AC_COMPILE_IFELSE(
56 | [AC_LANG_PROGRAM(
57 | [[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
58 | extern __attribute__((__visibility__("default"))) int exportedvar;
59 | extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
60 | extern __attribute__((__visibility__("default"))) int exportedfunc (void);
61 | void dummyfunc (void) {}
62 | ]],
63 | [[]])],
64 | [gl_cv_cc_visibility=yes],
65 | [gl_cv_cc_visibility=no])
66 | CFLAGS="$gl_save_CFLAGS"])
67 | AC_MSG_RESULT([$gl_cv_cc_visibility])
68 | if test $gl_cv_cc_visibility = yes; then
69 | CFLAG_VISIBILITY="-fvisibility=hidden"
70 | HAVE_VISIBILITY=1
71 | fi
72 | fi
73 | AC_SUBST([CFLAG_VISIBILITY])
74 | AC_SUBST([HAVE_VISIBILITY])
75 | AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY],
76 | [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.])
77 | ])
78 |
--------------------------------------------------------------------------------
/m4/wolfssl_darwin_clang.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | #
3 | # SYNOPSIS
4 | #
5 | # WOLFSSL_DARWIN_USING_CLANG
6 | #
7 | # DESCRIPTION
8 | #
9 | # With the advent of Apple Xcode v5.0, the old tool sets are missing from
10 | # the distribution. The provided "gcc" executable wrapper accepts the
11 | # "-pthread" flag, and passes it to the underlying "clang" which chokes
12 | # on it. This script checks the version of the gcc executable to see if
13 | # it reports it is really "clang".
14 | #
15 | # The value is placed in the wolfssl_darwin_clang variable.
16 | #
17 | # LICENSE
18 | #
19 | # Copyright (c) 2013 John Safranek
20 | #
21 | # Copying and distribution of this file, with or without modification, are
22 | # permitted in any medium without royalty provided the copyright notice
23 | # and this notice are preserved. This file is offered as-is, without any
24 | # warranty.
25 |
26 | #serial 1
27 |
28 | AC_DEFUN([WOLFSSL_DARWIN_USING_CLANG],
29 | [
30 | if test x"$CC" = xclang; then
31 | wolfssl_darwin_clang=yes
32 | elif test x"$CC" = x || test x"$CC" = xgcc; then
33 | if /usr/bin/gcc -v 2>&1 | grep 'clang' >/dev/null 2>&1; then
34 | wolfssl_darwin_clang=yes
35 | fi
36 | fi
37 | ])
38 |
--------------------------------------------------------------------------------
/pre-commit.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | #
4 | # Our "pre-commit" hook.
5 |
6 | # save current config
7 | echo "\n\nSaving current config\n\n"
8 | cp config.status tmp.status
9 | cp wolftpm/options.h tmp.options.h
10 |
11 | # stash modified files not part of this commit, don't test them
12 | echo "\n\nStashing any modified files not part of commit\n\n"
13 | git stash -q --keep-index
14 |
15 | # do the commit tests
16 | echo "\n\nRunning commit tests...\n\n"
17 | ./commit-tests.sh
18 | RESULT=$?
19 |
20 | # restore modified files not part of this commit
21 | echo "\n\nPopping any stashed modified files not part of commit\n"
22 | git stash pop -q
23 |
24 | # restore current config
25 | echo "\nRestoring current config\n"
26 | mv tmp.status config.status
27 | # don't show output incase error from above
28 | ./config.status >/dev/null 2>&1
29 | mv tmp.options.h wolftpm/options.h
30 | make clean >/dev/null 2>&1
31 | make -j 8 >/dev/null 2>&1
32 |
33 | [ $RESULT -ne 0 ] && echo "\nOops, your commit failed\n" && exit 1
34 |
35 | echo "\nCommit tests passed!\n"
36 | exit 0
37 |
--------------------------------------------------------------------------------
/scripts/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # included from Top Level Makefile.am
3 | # All paths should be given relative to the root
4 |
5 | EXTRA_DIST += scripts/swtpm_sim.test
6 | EXTRA_DIST += scripts/tls_setup.sh
7 |
--------------------------------------------------------------------------------
/scripts/swtpm_sim.test:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run tests against SWTPM simulator
4 | # Setting TESTS to a list of tests to run
5 | # TESTS=./examples/native/native_test\ ./examples/wrap/wrap_test ./scripts/swtpm_sim.test
6 | #
7 |
8 | # set -x
9 |
10 | TOP_DIR=$(realpath $(dirname $0)/..)
11 |
12 | die() {
13 | echo $* >&2
14 | ps $swtpm_pid > /dev/null && kill $swtpm_pid
15 | exit 1
16 | }
17 |
18 | build() {
19 | if [ ! -d "$SWTPM_DIR" ]; then
20 | echo "Cloning SWTPM from $SWTPM_GIT_URL to $SWTPM_DIR";
21 | git clone $SWTPM_GIT_URL $SWTPM_DIR || die "unable to clone $SWTPM_GIT_URL for simualtor";
22 | fi
23 | echo "Building SWTPM: $(git -C "$SWTPM_DIR" describe --long)";
24 | case "$OSTYPE" in
25 | "darwin"*)
26 | MAKE_EXTRA_OPTS="-f makefile.mac"
27 | ;;
28 | esac
29 | make -j4 -C $SWTPM_DIR/src $MAKE_EXTRA_OPTS > /dev/null || die "Failed to build $SWTPM_DIR";
30 | }
31 |
32 | TESTS=${TESTS:="${TOP_DIR}/tests/unit.test"}
33 | SWTPM_GIT_URL=${SWTPM_GIT_URL:="https://github.com/kgoldman/ibmswtpm2.git"}
34 |
35 | SWTPM_DIR="$(realpath $(basename $SWTPM_GIT_URL | sed 's/\.git//'))"
36 |
37 | # check if on path or clone and build
38 | which ${SWTPM_EXEC:=tpm_server} > /dev/null
39 | if [ 0 -ne $? ]; then
40 | build
41 | SWTPM_EXEC=$SWTPM_DIR/src/$SWTPM_EXEC
42 | fi;
43 |
44 | # start swtpm server
45 | $SWTPM_EXEC -rm >/dev/null &
46 | swtpm_pid=$!
47 | ps $swtpm_pid > /dev/null
48 | if [ 0 -eq $? ]; then
49 | echo "Started $SWTPM_EXEC (pid:$swtpm_pid)";
50 | else
51 | echo "WARNING: $SWTPM_EXEC unable to start. Trying tests in case other instance is running" >&2
52 | fi
53 |
54 | # execute unit test
55 | for test_exec in $TESTS; do
56 | echo "Running $test_exec" >&2;
57 | $test_exec || die "Failed on running $test_exec";
58 | done;
59 |
60 | # shutdown swtpm server
61 | ps $swtpm_pid > /dev/null && kill $swtpm_pid
62 |
--------------------------------------------------------------------------------
/scripts/tls_setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Generate keyblobs and certs needed for TLS examples
4 | #
5 |
6 | ./examples/keygen/keygen rsa_test_blob.raw -rsa -t
7 | ./examples/keygen/keygen ecc_test_blob.raw -ecc -t
8 | ./examples/csr/csr
9 | ./certs/certreq.sh
10 |
11 | cp ./certs/ca-ecc-cert.pem ../wolfssl/certs/tpm-ca-ecc-cert.pem
12 | cp ./certs/ca-rsa-cert.pem ../wolfssl/certs/tpm-ca-rsa-cert.pem
13 |
--------------------------------------------------------------------------------
/src/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # included from Top Level Makefile.am
3 | # All paths should be given relative to the root
4 |
5 |
6 | lib_LTLIBRARIES+= src/libwolftpm.la
7 | src_libwolftpm_la_SOURCES = \
8 | src/tpm2.c \
9 | src/tpm2_packet.c \
10 | src/tpm2_tis.c \
11 | src/tpm2_wrap.c \
12 | src/tpm2_asn.c \
13 | src/tpm2_param_enc.c \
14 | src/tpm2_cryptocb.c
15 |
16 | if BUILD_DEVTPM
17 | src_libwolftpm_la_SOURCES += src/tpm2_linux.c
18 | endif
19 | if BUILD_SWTPM
20 | src_libwolftpm_la_SOURCES += src/tpm2_swtpm.c
21 | endif
22 | if BUILD_WINAPI
23 | src_libwolftpm_la_SOURCES += src/tpm2_winapi.c
24 | src_libwolftpm_la_LIBADD = -ltbs
25 | endif
26 |
27 | src_libwolftpm_la_CFLAGS = $(src_libwolftpm_la_EXTRAS) -DBUILDING_WOLFTPM $(AM_CFLAGS)
28 | src_libwolftpm_la_CPPFLAGS = -DBUILDING_WOLFTPM $(AM_CPPFLAGS)
29 | src_libwolftpm_la_LDFLAGS = ${AM_LDFLAGS} -no-undefined -version-info ${WOLFTPM_LIBRARY_VERSION}
30 |
31 | #src_libwolftpm_la_DEPENDENCIES =
32 | #EXTRA_DIST +=
33 |
--------------------------------------------------------------------------------
/src/tpm2_winapi.c:
--------------------------------------------------------------------------------
1 | /* tpm2_winapi.c
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifdef HAVE_CONFIG_H
23 | #include
24 | #endif
25 |
26 | #include
27 |
28 | #ifdef WOLFTPM_WINAPI
29 | #include
30 |
31 | #include
32 | #include
33 |
34 | /*
35 | * minGW doesn't define the structs necessary for TPM2, so the TBS
36 | * structures are defined here to match the windows API.
37 | */
38 | #ifndef TBS_CONTEXT_VERSION_TWO
39 | #define TBS_CONTEXT_VERSION_TWO 2
40 |
41 | /**
42 | * This supports native windows API for TPM support. This uses the
43 | * Windows TBSI (TPM Base Service Interface)
44 | */
45 | typedef struct tdTBS_CONTEXT_PARAMS2
46 | {
47 | UINT32 version;
48 |
49 | union
50 | {
51 | struct
52 | {
53 | UINT32 requestRaw : 1; // if set to 1, request raw context
54 | UINT32 includeTpm12 : 1; // if 1.2 device present, can use this
55 | UINT32 includeTpm20 : 1; // if 2.0 device present, can use this
56 | };
57 | UINT32 asUINT32;
58 | };
59 | } TBS_CONTEXT_PARAMS2, *PTBS_CONTEXT_PARAMS2;
60 | typedef const TBS_CONTEXT_PARAMS2 *PCTBS_CONTEXT_PARAMS2;
61 |
62 | #endif /* ! TBS_CONTEXT_VERSION_TWO */
63 |
64 |
65 | /* Talk to a TPM device using Windows TBS */
66 | int TPM2_WinApi_SendCommand(TPM2_CTX* ctx, TPM2_Packet* packet)
67 | {
68 | int rc = 0;
69 | TBS_CONTEXT_PARAMS2 tbs_params;
70 | tbs_params.version = TBS_CONTEXT_VERSION_TWO;
71 | tbs_params.includeTpm12 = 0;
72 | tbs_params.includeTpm20 = 1;
73 |
74 |
75 | /* open, if not already open */
76 | if (ctx->winCtx.tbs_context == NULL) {
77 | rc = Tbsi_Context_Create((TBS_CONTEXT_PARAMS*)&tbs_params,
78 | &ctx->winCtx.tbs_context);
79 | }
80 |
81 | /* send the command to the device. Error if the device send fails. */
82 | if (rc == 0) {
83 | uint32_t tmp = packet->size;
84 | rc = Tbsip_Submit_Command(ctx->winCtx.tbs_context,
85 | TBS_COMMAND_LOCALITY_ZERO,
86 | TBS_COMMAND_PRIORITY_NORMAL,
87 | packet->buf,
88 | packet->pos,
89 | packet->buf,
90 | (UINT32*)&tmp);
91 | packet->pos = tmp;
92 | }
93 |
94 | return rc;
95 | }
96 |
97 | int TPM2_WinApi_Cleanup(TPM2_CTX* ctx)
98 | {
99 | int rc = TPM_RC_SUCCESS;
100 | if (ctx->winCtx.tbs_context != NULL) {
101 | rc = Tbsip_Context_Close(ctx->winCtx.tbs_context);
102 | ctx->winCtx.tbs_context = NULL;
103 | }
104 |
105 | return rc;
106 | }
107 |
108 | #endif
109 |
--------------------------------------------------------------------------------
/tests/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # included from Top Level Makefile.am
3 | # All paths should be given relative to the root
4 |
5 | if BUILD_EXAMPLES
6 | check_PROGRAMS += tests/unit.test
7 | noinst_PROGRAMS += tests/unit.test
8 | tests_unit_test_SOURCES = tests/unit_tests.c \
9 | examples/tpm_test_keys.c
10 | tests_unit_test_CFLAGS = $(AM_CFLAGS)
11 | tests_unit_test_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
12 | tests_unit_test_DEPENDENCIES = src/libwolftpm.la
13 | endif
14 |
--------------------------------------------------------------------------------
/wolftpm/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 | #
4 |
5 | nobase_include_HEADERS+= \
6 | wolftpm/tpm2.h \
7 | wolftpm/tpm2_packet.h \
8 | wolftpm/tpm2_tis.h \
9 | wolftpm/tpm2_types.h \
10 | wolftpm/tpm2_wrap.h \
11 | wolftpm/tpm2_linux.h \
12 | wolftpm/tpm2_swtpm.h \
13 | wolftpm/tpm2_winapi.h \
14 | wolftpm/tpm2_param_enc.h \
15 | wolftpm/tpm2_socket.h \
16 | wolftpm/tpm2_asn.h \
17 | wolftpm/version.h \
18 | wolftpm/visibility.h \
19 | wolftpm/options.h
20 |
--------------------------------------------------------------------------------
/wolftpm/options.h.in:
--------------------------------------------------------------------------------
1 | /* options.h.in
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 |
23 | /* default blank options for autoconf */
24 |
25 | #ifndef WOLFTPM_OPTIONS_H
26 | #define WOLFTPM_OPTIONS_H
27 |
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 |
34 | #ifdef __cplusplus
35 | }
36 | #endif
37 |
38 |
39 | #endif /* WOLFTPM_OPTIONS_H */
40 |
--------------------------------------------------------------------------------
/wolftpm/tpm2_linux.h:
--------------------------------------------------------------------------------
1 | /* tpm2_linux.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _TPM2_LINUX_H_
23 | #define _TPM2_LINUX_H_
24 |
25 | #include
26 | #include
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | /* TPM2 IO for using TPM through the Linux kernel driver */
33 | WOLFTPM_LOCAL int TPM2_LINUX_SendCommand(TPM2_CTX* ctx, TPM2_Packet* packet);
34 |
35 | #ifdef __cplusplus
36 | } /* extern "C" */
37 | #endif
38 |
39 | #endif /* _TPM2_LINUX_H_ */
40 |
--------------------------------------------------------------------------------
/wolftpm/tpm2_param_enc.h:
--------------------------------------------------------------------------------
1 | /* tpm2_param_enc.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _TPM2_PARAM_ENC_H_
23 | #define _TPM2_PARAM_ENC_H_
24 |
25 | #include
26 | #include
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | WOLFTPM_API int TPM2_KDFa(
33 | TPM_ALG_ID hashAlg, TPM2B_DATA *keyIn,
34 | const char *label, TPM2B_NONCE *contextU, TPM2B_NONCE *contextV,
35 | BYTE *key, UINT32 keySz
36 | );
37 |
38 | WOLFTPM_LOCAL int TPM2_CalcHmac(TPMI_ALG_HASH authHash, TPM2B_AUTH* auth,
39 | const TPM2B_DIGEST* hash, const TPM2B_NONCE* nonceNew,
40 | const TPM2B_NONCE* nonceOld, TPMA_SESSION sessionAttributes,
41 | TPM2B_AUTH* hmac);
42 | WOLFTPM_LOCAL int TPM2_CalcRpHash(TPMI_ALG_HASH authHash,
43 | TPM_CC cmdCode, BYTE* param, UINT32 paramSz, TPM2B_DIGEST* hash);
44 | WOLFTPM_LOCAL int TPM2_CalcCpHash(TPMI_ALG_HASH authHash, TPM_CC cmdCode,
45 | TPM2B_NAME* name1, TPM2B_NAME* name2, TPM2B_NAME* name3,
46 | BYTE* param, UINT32 paramSz, TPM2B_DIGEST* hash);
47 |
48 | /* Perform encryption over the first parameter of a TPM packet */
49 | WOLFTPM_LOCAL TPM_RC TPM2_ParamEnc_CmdRequest(TPM2_AUTH_SESSION *session,
50 | BYTE *paramData, UINT32 paramSz);
51 | WOLFTPM_LOCAL TPM_RC TPM2_ParamDec_CmdResponse(TPM2_AUTH_SESSION *session,
52 | BYTE *paramData, UINT32 paramSz);
53 |
54 | #ifdef __cplusplus
55 | } /* extern "C" */
56 | #endif
57 |
58 | #endif /* _TPM2_PARAM_ENC_H_ */
59 |
--------------------------------------------------------------------------------
/wolftpm/tpm2_socket.h:
--------------------------------------------------------------------------------
1 | /* tpm2_socket.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _TPM2_SOCKET_H_
23 | #define _TPM2_SOCKET_H_
24 |
25 | #if !defined(WOLFTPM2_NO_WOLFCRYPT) && !defined(WOLFCRYPT_ONLY)
26 | #include
27 | #endif
28 |
29 | #ifndef USE_WOLFSSL_IO
30 |
31 | /* socket includes */
32 | #if defined(_WIN32)
33 |
34 | #define SOCKET_T SOCKET
35 |
36 | /* TODO: HACKY for win32 */
37 | #undef SOCKET_INVALID
38 | #define SOCKET_INVALID 0xFFFFFFFF
39 | #elif defined(WOLFTPM_ZEPHYR)
40 | #include
41 |
42 | #define SOCKET_T int
43 | #else
44 | #include
45 | #include
46 |
47 | #define SOCKET_T int
48 | #endif
49 |
50 | #ifdef USE_WINDOWS_API
51 | #ifndef CloseSocket
52 | #define CloseSocket(s) closesocket(s)
53 | #endif
54 | #else
55 | #ifndef CloseSocket
56 | #define CloseSocket(s) close(s)
57 | #endif
58 | #endif
59 |
60 | #ifndef XSOCKLENT
61 | #ifdef _WIN32
62 | #define XSOCKLENT int
63 | #else
64 | #define XSOCKLENT socklen_t
65 | #endif
66 | #endif
67 |
68 | #ifdef _WIN32
69 | /* no epipe yet */
70 | #ifndef WSAEPIPE
71 | #define WSAEPIPE -12345
72 | #endif
73 | #define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
74 | #define SOCKET_EAGAIN WSAETIMEDOUT
75 | #define SOCKET_ECONNRESET WSAECONNRESET
76 | #define SOCKET_EINTR WSAEINTR
77 | #define SOCKET_EPIPE WSAEPIPE
78 | #define SOCKET_ECONNREFUSED WSAENOTCONN
79 | #define SOCKET_ECONNABORTED WSAECONNABORTED
80 | #else
81 | #define SOCKET_EWOULDBLOCK EWOULDBLOCK
82 | #define SOCKET_EAGAIN EAGAIN
83 | #define SOCKET_ECONNRESET ECONNRESET
84 | #define SOCKET_EINTR EINTR
85 | #define SOCKET_EPIPE EPIPE
86 | #define SOCKET_ECONNREFUSED ECONNREFUSED
87 | #define SOCKET_ECONNABORTED ECONNABORTED
88 | #endif /* USE_WINDOWS_API */
89 |
90 | #endif /* !USE_WOLFSSL_IO */
91 |
92 | #endif /* _TPM2_SOCKET_H_ */
93 |
--------------------------------------------------------------------------------
/wolftpm/tpm2_swtpm.h:
--------------------------------------------------------------------------------
1 | /* tpm2_swtpm.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _TPM2_SWTPM_H_
23 | #define _TPM2_SWTPM_H_
24 |
25 | #include
26 | #include
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | /* copy from TpmTcpProtocol.h */
33 | #if 0
34 | #define TPM_SIGNAL_POWER_ON 1
35 | #define TPM_SIGNAL_POWER_OFF 2
36 | #define TPM_SIGNAL_NV_ON 11
37 | #endif
38 |
39 | #define TPM_SEND_COMMAND 8
40 | #define TPM_SESSION_END 20
41 | #if 0
42 | #define TPM_STOP 21
43 | #endif
44 |
45 | /* TPM2 IO for using TPM through a Socket connection */
46 | WOLFTPM_LOCAL int TPM2_SWTPM_SendCommand(TPM2_CTX* ctx, TPM2_Packet* packet);
47 |
48 | #ifdef __cplusplus
49 | } /* extern "C" */
50 | #endif
51 |
52 | #endif /* _TPM2_SWTPM_H_ */
53 |
--------------------------------------------------------------------------------
/wolftpm/tpm2_tis.h:
--------------------------------------------------------------------------------
1 | /* tpm2_tis.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef __TPM2_TIS_H__
23 | #define __TPM2_TIS_H__
24 |
25 | #include
26 | #include
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | /* The default locality to use */
33 | #ifndef WOLFTPM_LOCALITY_DEFAULT
34 | #define WOLFTPM_LOCALITY_DEFAULT 0
35 | #endif
36 |
37 | #define TPM_TIS_READ 0x80
38 | #define TPM_TIS_WRITE 0x00
39 |
40 | #define TPM_TIS_HEADER_SZ 4
41 |
42 | #define TPM_TIS_READY_MASK 0x01
43 |
44 | /* Typically only 0-2 wait states are required */
45 | #ifndef TPM_TIS_MAX_WAIT
46 | #define TPM_TIS_MAX_WAIT 3
47 | #endif
48 |
49 | WOLFTPM_LOCAL int TPM2_TIS_GetBurstCount(TPM2_CTX* ctx, word16* burstCount);
50 | WOLFTPM_LOCAL int TPM2_TIS_SendCommand(TPM2_CTX* ctx, TPM2_Packet* packet);
51 | WOLFTPM_LOCAL int TPM2_TIS_Ready(TPM2_CTX* ctx);
52 | WOLFTPM_LOCAL int TPM2_TIS_WaitForStatus(TPM2_CTX* ctx, byte status, byte status_mask);
53 | WOLFTPM_LOCAL int TPM2_TIS_Status(TPM2_CTX* ctx, byte* status);
54 | WOLFTPM_LOCAL int TPM2_TIS_GetInfo(TPM2_CTX* ctx);
55 | WOLFTPM_LOCAL int TPM2_TIS_RequestLocality(TPM2_CTX* ctx, int timeout);
56 | WOLFTPM_LOCAL int TPM2_TIS_CheckLocality(TPM2_CTX* ctx, int locality, byte* access);
57 | WOLFTPM_LOCAL int TPM2_TIS_StartupWait(TPM2_CTX* ctx, int timeout);
58 | WOLFTPM_LOCAL int TPM2_TIS_Write(TPM2_CTX* ctx, word32 addr, const byte* value, word32 len);
59 | WOLFTPM_LOCAL int TPM2_TIS_Read(TPM2_CTX* ctx, word32 addr, byte* result, word32 len);
60 |
61 | #ifdef __cplusplus
62 | } /* extern "C" */
63 | #endif
64 |
65 | #endif /* __TPM2_TIS_H__ */
66 |
--------------------------------------------------------------------------------
/wolftpm/tpm2_winapi.h:
--------------------------------------------------------------------------------
1 | /* tpm2_winapi.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | #ifndef _TPM2_WINAPI_H_
23 | #define _TPM2_WINAPI_H_
24 |
25 | #include
26 | #include
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | /* TPM2 IO for using TPM through the Winapi kernel driver */
33 | WOLFTPM_LOCAL int TPM2_WinApi_SendCommand(TPM2_CTX* ctx, TPM2_Packet* packet);
34 |
35 | /* Cleanup winpi context */
36 | WOLFTPM_LOCAL int TPM2_WinApi_Cleanup(TPM2_CTX* ctx);
37 |
38 | #ifdef __cplusplus
39 | } /* extern "C" */
40 | #endif
41 |
42 | #endif /* _TPM2_WINAPI_H_ */
43 |
--------------------------------------------------------------------------------
/wolftpm/version.h:
--------------------------------------------------------------------------------
1 | /* version.h.in
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 |
23 | /*
24 | * The version header provides the current version number to the code
25 | * based and is updated automatically by the configure script. A copy
26 | * of the last generated copy of version.h is included with the
27 | * distribution for environments that do not use configure.
28 | */
29 |
30 |
31 | #pragma once
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | #define LIBWOLFTPM_VERSION_STRING "3.9.1"
38 | #define LIBWOLFTPM_VERSION_HEX 0x03009001
39 |
40 | #ifdef __cplusplus
41 | }
42 | #endif
43 |
--------------------------------------------------------------------------------
/wolftpm/version.h.in:
--------------------------------------------------------------------------------
1 | /* version.h.in
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 |
23 | /*
24 | * The version header provides the current version number to the code
25 | * based and is updated automatically by the configure script. A copy
26 | * of the last generated copy of version.h is included with the
27 | * distribution for environments that do not use configure.
28 | */
29 |
30 |
31 | #pragma once
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | #define LIBWOLFTPM_VERSION_STRING "@VERSION@"
38 | #define LIBWOLFTPM_VERSION_HEX @HEX_VERSION@
39 |
40 | #ifdef __cplusplus
41 | }
42 | #endif
43 |
--------------------------------------------------------------------------------
/wolftpm/visibility.h:
--------------------------------------------------------------------------------
1 | /* visibility.h
2 | *
3 | * Copyright (C) 2006-2025 wolfSSL Inc.
4 | *
5 | * This file is part of wolfTPM.
6 | *
7 | * wolfTPM is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * wolfTPM is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 | */
21 |
22 | /* Visibility control macros */
23 |
24 | #ifndef WOLFTPM_VISIBILITY_H
25 | #define WOLFTPM_VISIBILITY_H
26 |
27 | /* WOLFTPM_API is used for the public API symbols.
28 | It either imports or exports (or does nothing for static builds)
29 |
30 | WOLFTPM_LOCAL is used for non-API symbols (private).
31 | */
32 |
33 | #if defined(BUILDING_WOLFTPM)
34 | #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) || \
35 | defined(_WIN32_WCE)
36 | #ifdef WOLFTPM_DLL
37 | #define WOLFTPM_API __declspec(dllexport)
38 | #else
39 | #define WOLFTPM_API
40 | #endif
41 | #define WOLFTPM_LOCAL
42 | #elif defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
43 | #define WOLFTPM_API __attribute__ ((visibility("default")))
44 | #define WOLFTPM_LOCAL __attribute__ ((visibility("hidden")))
45 | #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
46 | #define WOLFTPM_API __global
47 | #define WOLFTPM_LOCAL __hidden
48 | #else
49 | #define WOLFTPM_API
50 | #define WOLFTPM_LOCAL
51 | #endif /* HAVE_VISIBILITY */
52 | #else /* BUILDING_WOLFTPM */
53 | #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) || \
54 | defined(_WIN32_WCE)
55 | #ifdef WOLFTPM_DLL
56 | #define WOLFTPM_API __declspec(dllimport)
57 | #else
58 | #define WOLFTPM_API
59 | #endif
60 | #define WOLFTPM_LOCAL
61 | #else
62 | #define WOLFTPM_API
63 | #define WOLFTPM_LOCAL
64 | #endif
65 | #endif /* BUILDING_WOLFTPM */
66 |
67 | #endif /* WOLFTPM_VISIBILITY_H */
68 |
--------------------------------------------------------------------------------
/wrapper/CSharp/.runsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
12 | %PATH%;..\..\..\..\..\out\install\windows-default\bin;..\..\..\..\..\..\wolfssl\out\install\windows-default\bin
13 |
14 |
15 |
--------------------------------------------------------------------------------
/wrapper/CSharp/README.md:
--------------------------------------------------------------------------------
1 | # wolfTPM (TPM 2.0) CSharp Wrappers
2 |
3 | This directory contains the CSharp wrapper for the TPM 2.0 API wrapper API.
4 |
5 |
6 | Once you have created the simulator, you can build wolfssl as described in the
7 | `README.md` in the root of this repo. Then you can build wolfTPM:
8 |
9 | ## Windows
10 |
11 | A Visual Studio solution is provided. This will allow you to build the
12 | wrappers. In order to run the tests you will need to update the
13 | `.runsettings` to add the location of the `wolftpm.dll`. There is a
14 | placeholder to leverage a vcpkg build, but cmake can also be used to
15 | build wolfTPM with Visual Studios.
16 |
17 | When building wolfTPM with cmake on Windows here is an example of the settings used:
18 |
19 | ```
20 | "WOLFTPM_INTERFACE": "WINAPI",
21 | "WOLFTPM_EXAMPLES": "no",
22 | "WOLFTPM_DEBUG": "yes",
23 | "WITH_WOLFSSL": "C:/Users/[username]/wolfssl/out/install/windows-default"
24 | ```
25 |
26 | ## Linux
27 |
28 | The wrapper has been tested with the swtpm TCP protocol for use with
29 | the simulator. Please follow instructions in the `docs/SWTPM.md` file
30 | for building and running the simulator.
31 |
32 |
33 | ```
34 | ./autogen.sh
35 | ./configure --enable-swtpm
36 | make all
37 | make check
38 | ```
39 |
40 | Prerequisites for linux
41 |
42 | ```
43 | apt install mono-tools-devel nunit nunit-console
44 | ```
45 |
46 | You can then build wolfTPM as described above in the Linux or Windows section
47 | of this document. After that, build and run the wolfTPM CSharp wrapper and run
48 | some tests:
49 |
50 | ```
51 | cd wrapper/CSharp
52 | mcs wolfTPM.cs wolfTPM-tests.cs -r:/usr/lib/cli/nunit.framework-2.6.3/nunit.framework.dll -t:library
53 |
54 | # run selftest case
55 | LD_LIBRARY_PATH=../../src/.libs/ nunit-console wolfTPM.dll -run=tpm_csharp_test.WolfTPMTest.TrySelfTest
56 | #run all tests
57 | LD_LIBRARY_PATH=../../src/.libs/ nunit-console wolfTPM.dll
58 | ```
59 |
60 |
61 | You should see something similar to the following output:
62 |
63 | ```
64 | Selected test(s): tpm_csharp_test.WolfTPMTest.TrySelfTest
65 |
66 | wolfSSL Entering wolfCrypt_Init
67 | .
68 | Tests run: 1, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0.1530346 seconds
69 |
70 | Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
71 |
72 | wolfSSL Entering wolfCrypt_Cleanup
73 | ```
74 |
--------------------------------------------------------------------------------
/wrapper/CSharp/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | wrapper_CSharpdir = $(wrapperdir)/CSharp
5 |
6 | dist_wrapper_CSharp_DATA= \
7 | wrapper/CSharp/README.md \
8 | wrapper/CSharp/wolfTPM.cs \
9 | wrapper/CSharp/wolfTPM-tests.cs \
10 | wrapper/CSharp/.runsettings \
11 | wrapper/CSharp/wolfTPM-csharp.csproj
12 |
--------------------------------------------------------------------------------
/wrapper/CSharp/wolfTPM-csharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Library
5 | netcoreapp3.1
6 | wolfTPM_csharp
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/wrapper/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # All paths should be given relative to the root
3 |
4 | include wrapper/CSharp/include.am
5 |
6 | wrapperdir = $(docdir)/wrapper
7 | dist_wrapper_DATA= wrapper/wolfTPM-csharp.sln
8 |
--------------------------------------------------------------------------------
/wrapper/wolfTPM-csharp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31205.134
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "wolfTPM-csharp", "CSharp\wolfTPM-csharp.csproj", "{B94757A8-B2A3-4289-887D-A0B23C34F418}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {B94757A8-B2A3-4289-887D-A0B23C34F418}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {B94757A8-B2A3-4289-887D-A0B23C34F418}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {B94757A8-B2A3-4289-887D-A0B23C34F418}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {B94757A8-B2A3-4289-887D-A0B23C34F418}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {C5F3DA80-4658-45F2-9224-EF22CAD6108B}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/zephyr/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if(CONFIG_WOLFTPM)
2 | zephyr_include_directories(${ZEPHYR_CURRENT_MODULE_DIR})
3 | zephyr_include_directories(${ZEPHYR_CURRENT_MODULE_DIR}/zephyr)
4 | zephyr_library_include_directories(${ZEPHYR_CURRENT_MODULE_DIR})
5 | FILE(GLOB wolftpm_sources
6 | ${ZEPHYR_CURRENT_MODULE_DIR}/src/*.c
7 | ${ZEPHYR_CURRENT_MODULE_DIR}/hal/*.c
8 | )
9 | target_sources(app PRIVATE ${wolftpm_sources})
10 |
11 | if(CONFIG_WOLFTPM_DEBUG)
12 | target_compile_definitions(app PUBLIC DEBUG_WOLFTPM)
13 | endif()
14 |
15 | target_compile_definitions(app PUBLIC WOLFTPM_ZEPHYR)
16 |
17 | endif()
18 |
--------------------------------------------------------------------------------
/zephyr/Kconfig:
--------------------------------------------------------------------------------
1 | menuconfig WOLFTPM
2 | bool "wolfTPM module support"
3 | select WOLFSSL
4 |
5 | if WOLFTPM
6 | config WOLFTPM_DEBUG
7 | bool "wolfTPM debug activation"
8 | help
9 | Enable debugging activation for wolfTPM.
10 |
11 | config WOLFTPM_I2C
12 | bool "wolfTPM I2C support"
13 | help
14 | Enables the I2C HAL and Advanced IO
15 |
16 | config WOLFTPM_SPI
17 | bool "wolfTPM SPI support"
18 | help
19 | Enables the SPI HAL (default)
20 |
21 | config ZEPHYR_WOLFTPM_MODULE
22 | bool
23 | depends on WOLFTPM
24 | endif
25 |
26 | # Add relevant macros for tpm
27 |
28 |
--------------------------------------------------------------------------------
/zephyr/README.md:
--------------------------------------------------------------------------------
1 | Zephyr Project Port
2 | ===================
3 |
4 | ## Overview
5 |
6 | This port is for the Zephyr RTOS Project, available [here](https://www.zephyrproject.org/).
7 |
8 |
9 | It provides the following zephyr code.
10 |
11 | - modules/lib/wolftpm
12 | - wolfTPM library code
13 | - modules/lib/wolftpm/zephyr/
14 | - Configuration and CMake files for wolfTPM as a Zephyr module
15 | - modules/lib/wolftpm/zephyr/samples/wolftpm_wrap_caps
16 | - wolfTPM test application
17 | - modules/lib/wolftpm/zephyr/samples/wolftpm_wrap_test
18 | - wolfTPM test application
19 |
20 | ## How to setup as a Zephyr Module
21 |
22 | Follow the [instructions](https://docs.zephyrproject.org/latest/develop/getting_started/index.html) to setup a zephyr project.
23 |
24 | ### Modify your project's west manifest
25 |
26 | Add wolfTPM as a project to your west.yml:
27 |
28 | ```
29 | manifest:
30 | remotes:
31 | #
32 | - name: wolftpm
33 | url-base: https://github.com/wolfssl
34 |
35 | projects:
36 | #
37 | - name: wolftpm
38 | path: modules/lib/wolftpm
39 | revision: master
40 | remote: wolftpm
41 | ```
42 |
43 | Note: wolfTPM has dependencies with wolfSSL so you need to also need to add wolfSSL into the west.yml like shown above.
44 |
45 | Update west's modules:
46 |
47 | ```bash
48 | west update
49 | ```
50 |
51 | Now west recognizes 'wolftpm' as a module, and will include it's Kconfig and
52 | CMakeFiles.txt in the build system.
53 |
54 | ## Build and Run Tests
55 |
56 | ### Build and Run wolfTPM wrap Test Application
57 |
58 | If you want to run build apps without running `west zephyr-export` then it is
59 | possible by setting the `CMAKE_PREFIX_PATH` variable to the location of the
60 | zephyr sdk and building from the `zephyr` directory. For example:
61 |
62 | ```
63 | CMAKE_PREFIX_PATH=/path/to/zephyr-sdk- west build -p always -b qemu_x86 ../modules/lib/wolftpm/zephyr/samples/wolftpm_wrap_test/
64 | ```
65 |
66 | build and execute `wolftpm_wrap_test`
67 |
68 | ```
69 | cd [zephyrproject]
70 | west build -p auto -b qemu_x86 modules/lib/wolftpm/zephyr/samples/wolftpm_wrap_test
71 | west build -t run
72 | ```
73 |
74 | ### Build and Run wolfTPM wrap Capabilities Application
75 |
76 | build and execute `wolftpm_wrap_caps`
77 |
78 | ```
79 | cd [zephyrproject]
80 | west build -p auto -b qemu_x86 modules/lib/wolftpm/zephyr/samples/wolftpm_wrap_caps
81 | west build -t run
82 | ```
83 |
--------------------------------------------------------------------------------
/zephyr/include.am:
--------------------------------------------------------------------------------
1 | # vim:ft=automake
2 | # included from Top Level Makefile.am
3 | # All paths should be given relative to the root
4 |
5 | EXTRA_DIST+= zephyr/CMakeLists.txt
6 | EXTRA_DIST+= zephyr/Kconfig
7 | EXTRA_DIST+= zephyr/module.yml
8 | EXTRA_DIST+= zephyr/README.md
9 | EXTRA_DIST+= zephyr/user_settings.h
10 | EXTRA_DIST+= zephyr/samples/wolftpm_wrap_caps/CMakeLists.txt
11 | EXTRA_DIST+= zephyr/samples/wolftpm_wrap_caps/prj.conf
12 | EXTRA_DIST+= zephyr/samples/wolftpm_wrap_caps/sample.yaml
13 | EXTRA_DIST+= zephyr/samples/wolftpm_wrap_test/CMakeLists.txt
14 | EXTRA_DIST+= zephyr/samples/wolftpm_wrap_test/prj.conf
15 | EXTRA_DIST+= zephyr/samples/wolftpm_wrap_test/sample.yaml
16 |
--------------------------------------------------------------------------------
/zephyr/module.yml:
--------------------------------------------------------------------------------
1 | name: wolftpm
2 | build:
3 | cmake: zephyr
4 | kconfig: zephyr/Kconfig
5 | depends:
6 | - wolfssl
7 |
--------------------------------------------------------------------------------
/zephyr/samples/wolftpm_wrap_caps/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.13.1)
2 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
3 | project(wolftpm_wrap_caps)
4 |
5 | # Include source code for wrap test
6 | target_sources(app PRIVATE ${ZEPHYR_WOLFTPM_MODULE_DIR}/examples/wrap/caps.c)
7 | target_sources(app PRIVATE ${app_sources})
8 |
9 | # Include header files
10 | target_include_directories(app PRIVATE
11 | ${ZEPHYR_BASE}/include
12 | ${ZEPHYR_BASE}/include/zephyr
13 | ${ZEPHYR_WOLFTPM_MODULE_DIR}/zephyr
14 | ${ZEPHYR_WOLFTPM_MODULE_DIR}/hal
15 | ${ZEPHYR_WOLFTPM_MODULE_DIR}/tests
16 | ${ZEPHYR_WOLFTPM_MODULE_DIR}/wolftpm
17 | ${ZEPHYR_WOLFTPM_MODULE_DIR}/examples/wrap
18 | ${ZEPHYR_WOLFTPM_MODULE_DIR}/examples
19 | ${ZEPHYR_WOLFTPM_MODULE_DIR}
20 | )
21 |
22 | add_definitions(-DWOLFSSL_ZEPHYR)
23 | add_definitions(-DWOLFSSL_USER_SETTINGS)
24 | add_definitions(-DWOLFTPM_USER_SETTINGS)
25 |
--------------------------------------------------------------------------------
/zephyr/samples/wolftpm_wrap_caps/prj.conf:
--------------------------------------------------------------------------------
1 | # Configure stack and heap sizes
2 | CONFIG_MAIN_STACK_SIZE=32768
3 | CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=8192
4 |
5 | # Include wolfTPM config
6 | CONFIG_WOLFTPM=y
7 | CONFIG_WOLFTPM_I2C=n
8 | CONFIG_WOLFTPM_SPI=n
9 |
10 | # POSIX file operations
11 | CONFIG_POSIX_API=y
12 | CONFIG_POSIX_FS=n
13 |
14 | # Pthreads
15 | CONFIG_PTHREAD_IPC=y
16 |
17 | # Clock for time()
18 | CONFIG_POSIX_CLOCK=y
19 |
20 | # TLS configuration
21 | CONFIG_WOLFSSL=y
22 | CONFIG_WOLFSSL_BUILTIN=y
23 |
24 | # Floating Point
25 | CONFIG_FPU=y
26 |
27 | # Networking configuration
28 | CONFIG_NETWORKING=y
29 | CONFIG_NET_SOCKETS=y
30 |
31 | # Logging
32 | CONFIG_PRINTK=y
33 | CONFIG_CBPRINTF_LIBC_SUBSTS=y
34 | CONFIG_CBPRINTF_FP_SUPPORT=y
35 | CONFIG_CONSOLE=y
36 | CONFIG_LOG=y
37 | CONFIG_LOG_BACKEND_UART=y
38 | CONFIG_LOG_BUFFER_SIZE=15360
39 | CONFIG_LOG_MODE_IMMEDIATE=y
40 | #CONFIG_WOLFSSL_DEBUG=y
41 |
42 | # Entropy
43 | CONFIG_TEST_RANDOM_GENERATOR=y
44 | CONFIG_ENTROPY_GENERATOR=y
45 | CONFIG_ENTROPY_DEVICE_RANDOM_GENERATOR=y
46 |
--------------------------------------------------------------------------------
/zephyr/samples/wolftpm_wrap_caps/sample.yaml:
--------------------------------------------------------------------------------
1 | sample:
2 | description: wolfTPM wrap caps
3 | name: wolfTPM wrap caps
4 | common:
5 | harness: console
6 | harness_config:
7 | type: one_line
8 | regex:
9 | - "wolfTPM caps read successfully"
10 | tests:
11 | sample.lib.wolftpm_wrap_caps:
12 | timeout: 200
13 | platform_allow: qemu_x86
14 | integration_platforms:
15 | - qemu_x86
16 |
--------------------------------------------------------------------------------
/zephyr/samples/wolftpm_wrap_test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.13.1)
2 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
3 | project(wolftpm_wrap_test)
4 |
5 | # Include source code for wrap test
6 | target_sources(app PRIVATE ${ZEPHYR_WOLFTPM_MODULE_DIR}/examples/wrap/wrap_test.c)
7 | target_sources(app PRIVATE ${app_sources})
8 |
9 | # Include header files
10 | target_include_directories(app PRIVATE
11 | ${ZEPHYR_BASE}/include
12 | ${ZEPHYR_BASE}/include/zephyr
13 | ${ZEPHYR_WOLFTPM_MODULE_DIR}/zephyr
14 | ${ZEPHYR_WOLFTPM_MODULE_DIR}/hal
15 | ${ZEPHYR_WOLFTPM_MODULE_DIR}/tests
16 | ${ZEPHYR_WOLFTPM_MODULE_DIR}/wolftpm
17 | ${ZEPHYR_WOLFTPM_MODULE_DIR}/examples/wrap
18 | ${ZEPHYR_WOLFTPM_MODULE_DIR}/examples
19 | ${ZEPHYR_WOLFTPM_MODULE_DIR}
20 | )
21 |
22 | add_definitions(-DWOLFSSL_ZEPHYR)
23 | add_definitions(-DWOLFSSL_USER_SETTINGS)
24 | add_definitions(-DWOLFTPM_USER_SETTINGS)
25 |
--------------------------------------------------------------------------------
/zephyr/samples/wolftpm_wrap_test/prj.conf:
--------------------------------------------------------------------------------
1 | # Configure stack and heap sizes
2 | CONFIG_MAIN_STACK_SIZE=32768
3 | CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=8192
4 |
5 | # Include wolfTPM config
6 | CONFIG_WOLFTPM=y
7 | CONFIG_WOLFTPM_I2C=n
8 | CONFIG_WOLFTPM_SPI=n
9 |
10 | # POSIX file operations
11 | CONFIG_POSIX_API=y
12 | CONFIG_POSIX_FS=n
13 |
14 | # Pthreads
15 | CONFIG_PTHREAD_IPC=y
16 |
17 | # Clock for time()
18 | CONFIG_POSIX_CLOCK=y
19 |
20 | # TLS configuration
21 | CONFIG_WOLFSSL=y
22 | CONFIG_WOLFSSL_BUILTIN=y
23 |
24 | # Floating Point
25 | CONFIG_FPU=y
26 |
27 | # Networking configuration
28 | CONFIG_NETWORKING=y
29 | CONFIG_NET_SOCKETS=y
30 |
31 | # Logging
32 | CONFIG_PRINTK=y
33 | CONFIG_CBPRINTF_LIBC_SUBSTS=y
34 | CONFIG_CBPRINTF_FP_SUPPORT=y
35 | CONFIG_CONSOLE=y
36 | CONFIG_LOG=y
37 | CONFIG_LOG_BACKEND_UART=y
38 | CONFIG_LOG_BUFFER_SIZE=15360
39 | CONFIG_LOG_MODE_IMMEDIATE=y
40 | #CONFIG_WOLFSSL_DEBUG=y
41 |
42 | # Entropy
43 | CONFIG_TEST_RANDOM_GENERATOR=y
44 | CONFIG_ENTROPY_GENERATOR=y
45 | CONFIG_ENTROPY_DEVICE_RANDOM_GENERATOR=y
46 |
--------------------------------------------------------------------------------
/zephyr/samples/wolftpm_wrap_test/sample.yaml:
--------------------------------------------------------------------------------
1 | sample:
2 | description: wolfTPM wrap test
3 | name: wolfTPM wrap test
4 | common:
5 | harness: console
6 | harness_config:
7 | type: one_line
8 | regex:
9 | - "wolfTPM wrapper test completed successfully"
10 | tests:
11 | sample.lib.wolftpm_wrap_test:
12 | timeout: 200
13 | platform_allow: qemu_x86
14 | integration_platforms:
15 | - qemu_x86
16 |
--------------------------------------------------------------------------------