Commit Graph

64 Commits (fc511714d37e8052a089e602ddaaf6b8c4af5ce7)

Author SHA1 Message Date
David Garske dafb0f62cf F-4742 fix and test case 2026-06-01 15:57:40 -07:00
Aidan Garske 0801a30ede fwTPM v1.85: TCG compliance fixes + PQC CI matrix
Closes 13 spec-conformance findings flagged by two TCG compliance reviews
  of the v1.85 PQC handlers. Each fix maps to a specific Part 2 / Part 3
  section; all are exercised by negative test fixtures in
  tests/fwtpm_unit_tests.c that bite-verify each fix in isolation.

  Spec-RC corrections (one-line each):
  - Drop TPMA_ML_PARAMETER_SET_extMu from TPM_PT_ML_PARAMETER_SETS — Part 2
    §12.2.3.6 (no μ-direct sign API in wolfCrypt yet).
  - Sign* handlers return TPM_RC_SCHEME (not TPM_RC_KEY) for valid keys
    with unsupported scheme — Part 3 §17.5.1 / §20.7.1.
  - SignDigest / VerifyDigestSignature return TPM_RC_ATTRIBUTES (not
    TPM_RC_EXT_MU) when key's allowExternalMu=NO — EXT_MU is reserved for
    capability errors, ATTRIBUTES for key-attribute errors.

  Validation additions:
  - SignDigest rejects restricted and x509sign keys at entry
    (TPM_RC_ATTRIBUTES, Part 3 §20.7.1).
  - VerifyDigestSignature enforces sigHashAlg == key.hashAlg
    (TPM_RC_SCHEME, Part 3 §20.4.1) and digest size == hashAlg digest size
    (TPM_RC_SIZE).
  - CreatePrimary / Create / CreateLoaded / TestParms reject MLDSA with
    allowExternalMu=YES at object-creation time (TPM_RC_EXT_MU, Part 2
    §12.2.3.6) instead of letting the request succeed and fail later.
  - TestParms validates ML-DSA / Hash-ML-DSA / ML-KEM parameterSet ranges.
  - SignSequenceComplete rejects restricted keys signing messages whose
    first 4 bytes are TPM_GENERATED_VALUE (0xFF544347) (TPM_RC_VALUE,
    Part 3 §20.6.1).
  - SignSequenceComplete rejects x509sign keys (TPM_RC_ATTRIBUTES).
  - TPM_RC_ONE_SHOT_SIGNATURE moved from SequenceUpdate to
    SignSequenceComplete (Part 3 §20.6.1: it's a Complete-time RC about
    non-empty sequence, not an Update-time RC).

  Structural fixes:
  - TPMA_OBJECT_x509sign (bit 19, Part 2 §8.3.3 v1.85) added to the enum
    in wolftpm/tpm2.h and enforced in the two sign-side handlers.
  - TPM_PT_ML_PARAMETER_SETS bits gated on wolfCrypt build symbols
    (WOLFSSL_HAVE_MLKEM / KYBER_*, WOLFSSL_WC_DILITHIUM / HAVE_DILITHIUM)
    so the capability matches what the build actually delivers.
  - wolfTPM2_EncryptSecret_MLKEM applies KDFa(SECRET, ct, pub) over the
    ML-KEM shared secret per Part 1 §47.4 Eq 66 (Labeled-KEM); previous
    code emitted raw K as the salt.
  - VerifySequenceComplete and VerifyDigestSignature emit hierarchy-bound
    TPMT_TK_VERIFIED tickets (Part 2 §10.6.5) instead of the
    TPM_RH_NULL + empty-HMAC stub.

  Tests (tests/fwtpm_unit_tests.c, 8 new + 4 updated, all under fwtpm_unit):
  - 8 new spec-bite negatives, one per finding where a single-RC test is
    meaningful. Each was bite-verified by reverting its source fix and
    confirming the test fails with a different RC.
  - 4 existing negatives updated to assert the new spec-mandated RCs and
    reshaped where the rejection point moved (SequenceUpdate → Complete).

  CI:
  - New .github/workflows/pqc-examples.yml: builds + smoke-runs the v1.85
    examples + invokes tests/check_doc_constants.sh on each PR.
  - tests/check_doc_constants.sh greps every FWTPM_* size/seed/digest
    constant from wolftpm/fwtpm/fwtpm.h and asserts each is mentioned in
    docs/FWTPM.md (catches doc drift like the v1.85
    FWTPM_MAX_COMMAND_SIZE 4096→8192 bump). docs/FWTPM.md gains 6 missing
    entries (CMD_AUTHS, SENSITIVE_SIZE, SIGN_SEQ, SYM_KEY_SIZE,
    HMAC_KEY_SIZE, HMAC_DIGEST_SIZE) so the check passes clean.
  - fuzz.yml / fwtpm-test.yml / make-test-swtpm.yml / sanitizer.yml each
    gain a v1.85 matrix entry running the same checks under
    --enable-v185 + wolfSSL --enable-dilithium --enable-mlkem
    --enable-experimental.
2026-04-29 10:28:44 -07:00
David Garske 0c52f3be4d Add firmware TPM 2.0 (fwTPM) implementation
Add portable firmware TPM 2.0 implementation (fwTPM) built on wolfCrypt.
Implements 105/113 TPM 2.0 v1.38 commands (93%) as a standalone server
with socket and TIS transports, NV storage, and full CI/fuzz coverage.
2026-04-16 16:57:57 -07:00
Aidan Garske ddf990a4c9 Address review feedback
- Renamed spdm_demo to spdm_ctrl: file, binary, internal demo_* functions to ctrl_*, all references in
  include.am, spdm_test.sh, .gitignore, CLAUDE.md, both READMEs
  - README mentions Nations: title updated to Nuvoton NPCT75x and Nations NS350 TPMs, added Nations build section
  - README section header renamed from Demo Commands to Setup/Control Commands
  - README added reset pin control section: documents GPIO reset requirement, Pi-specific example, custom hardware
  design guidance
  - Moved spdm_tcg.c to common build section, no longer conditional on Nuvoton/Nations in src/spdm/include.am
  - Removed redundant wolfSSL options include from spdm_internal.h since tpm2_types.h handles this
  - Added WOLFTPM_SPDM_TCG generic guard as auto-define in spdm_types.h, replaced ~30 occurrences of #if        defined(WOLFSPDM_NUVOTON) || defined(WOLFSPDM_NATIONS) across all files
2026-03-25 18:59:32 +00:00
Aidan Garske 49c767432f Add Nuvoton NPCT75x and NSING NS350 SPDM support for wolfTPM 2026-03-24 18:15:38 +00:00
Paul Adelsbach 383bdb4887 Add test case for early returns from test_wolfTPM2_EncryptSecret 2026-03-08 22:16:12 -07:00
Aidan Garske bb6a71c0fa Add seal/unseal examples with PCR, PolicyAuthorize, and NV policies
New examples:
   - seal_pcr: PCR-only policy seal/unseal. Binds secrets to specific PCR
     values without password or signing key. Supports split seal/unseal,
     configurable PCR index, custom blob filenames, XOR/AES param encryption.
   - seal_policy_auth: PolicyAuthorize with TPM-resident signing key (ECC/RSA).
     Signing key can re-authorize PCR policy, allowing secrets to survive
     authorized PCR changes (e.g., OS updates). Supports split seal/unseal,
     XOR/AES param encryption.
   - seal_nv: NV storage with PCR policy. Stores secrets directly in TPM
     non-volatile memory with store/read/delete lifecycle and configurable
     NV index. No external blob files needed.

   Build system:
   - Autotools: Updated include.am for seal and nvram with new build targets
   - CMake: Added add_tpm_example() entries for all three examples
   - Headers: Updated seal.h and nvram.h with new prototypes, removed old
     TPM2_PCR_Seal_With_Policy_Auth_* declarations
   - .gitignore: Added built binaries

   Testing:
   - run_examples.sh: Added ~110 lines of integration tests for seal_pcr,
     seal_policy_auth (ECC + RSA), and seal_nv (store/read/delete lifecycle)
   - seal_test.sh: Standalone test script with 28 tests across 3 groups
     including positive, negative, param encryption, and custom path tests
   - seal-test.yml: Dedicated CI workflow with SWTPM, path-filtered to
     seal-related files, follows make-test-swtpm.yml pattern

   Documentation:
   - README.md: Usage examples and policy comparison table for all seal examples
2026-02-26 16:35:12 -08:00
Aidan Garske 0b50f632ae Add stm33ktpm support LMS and non-LMS 2026-01-27 15:57:09 -08:00
David Garske 2d5a27d238 Example for HMAC with persistent key. ZD 20109. 2025-06-26 11:06:28 -07:00
David Garske c42fff4f7f EK Cert Verification with TPM only (no wolfCrypt). Example assumes ST33KTPM2X. `./configure --disable-wolfcrypt && make && ./examples/endorsement/verify_ek_cert` 2025-01-24 09:54:11 -08:00
David Garske 5bd553a6a3 wolfTPM v3.8.0 release. 2025-01-06 11:46:49 -08:00
David Garske 8177ba8c1d Create separate tool for performing the TPM2_Clear (don't use args to wrap_test). 2024-12-13 14:52:38 -08:00
David Garske 53feb3fb96 Add support for TPM2_GetCapability for TPM_CAP_PCRS. ZD 18881
Improve PCR extend to support -alg option.
2024-10-30 12:57:08 -07:00
David Garske a6d7ed8695 Added example for `TPM2_Certify`:
* Added new build option for TPM provisioning (`--enable-provisioning` on by default).
* Added new `wolfTPM2_CreatePrimaryKey_ex` and `WOLFTPM2_PKEY` that supports returning creation ticket/hash.
* Added key templates for initial device (IDevID) and attestation keys (IAK).
* Extended `create_primary` example to support creation or IDevID and IAK.
* Added new policy hash helper API `wolfTPM2_PolicyHash`
* Switch handle/nvIndex string parsing to use `strtoul`.

ZD 18347
2024-08-22 10:38:01 -07:00
David Garske 6951b8d307 Fix for /dev/tpm0 file descriptor check (fixes #365). Added documentation for /dev/tpm0 permissions (fixes #358). Various spelling and documentation cleanups. 2024-07-31 11:21:53 -07:00
David Garske 57f12df97b Support for getting TPM EK Certificates. Added `wolfTPM2_GetKeyTemplate_EK` and `wolfTPM2_GetKeyTemplate_EK` API's for getting EK public templates for generating the EK primary key. Fix TLS example build issues with wolfSSL not having crypto callback or PK callback enabled. 2024-07-26 13:02:57 -07:00
gojimmypi 398b41f93e Some changes to /gitignore for Visual Studio, VisualGDB, etc 2024-05-10 17:46:03 -07:00
David Garske 892726e6b5 Added support for Infineon SLB9672/SLB9673 Firmware upgrade (see examples/firmware/README.md)
Added Infineon Modus Toolbox support. See `wolfssl/IDE/Infineon/README.md` for setup instructions.
Added support for Infineon CyHal I2C support.
Added Firmware extraction tool
Added Firmware update example application `examples/firmware/ifx_fw_update`.
Added support for vendor capabilities `TPM_CAP_VENDOR_PROPERTY`.
Added `XSLEEP_MS` macro for firmware update delay.
Added support for getting key group id, operational mode and update counts.
Added support for abandoning an update.
Added support for firmware update done, but not finalized
Fix auto-detect to not define SLB9672/SLB9673.
2024-04-01 17:21:18 -07:00
David Garske 65e03e15e6 Added Windows Visual Studio project for wolfTPM. 2023-12-06 15:10:44 -08:00
David Garske 31cd20e645 Added new policy_nv example. 2023-09-11 14:37:12 -07:00
David Garske a15260342f wolfTPM Support for sealing/unsealing based on a PCR that is signed externally. Use an external key to sign a PCR digest. Allows a new signed policy to be sent with updates to continue allowing a sealed secret to be unsealed when PCR's change. This resolves the issue with PCR brittleness. 2023-08-29 18:47:18 -07:00
David Garske 14a331d648 Example for secure boot solution to store root of trust in NV. Provides authentication and tamper protection. Fixed uses of arg= in examples. 2023-08-07 11:08:02 -07:00
David Garske ae6bac26c5 Added documentation and tests. 2023-07-19 13:28:50 -07:00
John Bland 6678ea7c4b add external nvram policy sealing example, fix wolfTPM2_SealWithAuthSigNV
wolfTPM2_SealWithAuthSigNV needs to have PolicyPCR called as a part of its logic since it uses wolfTPM2_SetAuthPassword, which interferes with the policy digest
2023-04-17 18:29:18 -04:00
John Bland b4a8ba698e
Sealing secrets with PolicyPCR and PolicyAuthorize (#261)
* Support for PCR with policy. Issue #109

* Progress on PCR policy. Work from John Bland.

* add wrapper functions to seal secrets the NVM with policy authorization

fix the seal and unseal with policy functions to work with non trial policies

update policy examples to allow multiple pcr indicies to be used, currently only 2 can be used because TPML_PCR_SELECTION only allows 2 pcr sellections, may need to be refactored but I didn't want to blow that part of the codebase up

* fix TPM2_SetupPCRSel to correctly use hash type banks

* update policy functions and examples based on pr comments

fixed rsa keys not working due to null default signing algorithm, seal_policy_auth can now be called with no arguments and will pick defaults

* update policy examples based on pcr comments

added error codes and htons macro for use when wolfcrypt is not available

* added policySigned logic to policy seal with nv functions

currently the policy seal with auth nv example is broken due to strange session issues

* Improvements to the session authentication for policy sessions.

* update the sealNV functions, add PolicyRestart and manual htnos

wolfTPM2_SealWithAuthSigNV allows for sealing secrets to NV with just the public part of the sealing key and a pre signed signature so that the private part of the key can be kept off the system. PolicyRestart was added to make reseting the policyDigest easy and a manual htnos function was added for use in wolfBoot

* update policy code based on pr comments

* reconfigure wolfTPM after setting up ibm simulator

* define XREWIND in wolfTPM since it is no longer in wolfssl

* fix scan-build warnings

* remove RSA_SIG_SZ

* use signed char in HexCharToByte for strict build options

* update based on pr comments

---------

Co-authored-by: David Garske <david@wolfssl.com>
2023-04-13 11:24:37 -07:00
David Garske fac51233c3 Added example for NV counter increment. Fixes for NV auth handling. 2022-10-04 13:09:05 -07:00
David Garske b41a14689f Add create primary key example. Add support for using a unique template with create and create primary. 2022-06-28 16:40:46 -07:00
David Garske 0ce7038863 Add `wolfTPM2_SetAuthSession` and `wolfTPM2_NVStoreKey`. 2022-05-23 13:51:28 -07:00
Elms a37d2387e0 cmake: fix `unseal` warning and add build to ignore 2022-04-07 12:01:13 -07:00
Elms 56a827ae44 Fix `make install` by renaming pcr example `read.c`
example files are installed into the same directory and must have
unique names.
2021-11-18 10:22:15 -08:00
Dimitar Tomov 5dfa13ec75 Added PCR Read example
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-07-28 14:48:58 +03:00
David Garske c83088decf Release for wolfTPM v2.2.0 preparation. 2021-07-13 11:26:12 -07:00
David Garske 8455beaae4 Fixes for Public PEM functions. Cleanups. 2021-07-12 17:12:22 -07:00
David Garske aa71cfd73d Minor cleanups. 2021-07-12 15:07:45 -07:00
David Garske 9b6791657b Fixes to support "make dox". 2021-06-02 10:20:00 -07:00
Dimitar Tomov 009a5df963 Added examples to create a remote attestation credential
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-04-29 23:26:24 +03:00
Dimitar Tomov ef4925a094 Updated gitignore to include binaries from the new gpio and seal examples
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-04-26 17:04:32 +03:00
David Garske 197754b109 Minor cleanups. 2021-03-12 15:10:58 -08:00
David Garske 4b0b70861c Added parameter encryption support to more examples. Fix to not set "encrypt" or "decrypt" if command doesn't allow it. Updated documentation. 2020-11-30 12:00:54 -08:00
Dimitar Tomov 23e5b629fb Added keyload with parameter encryption example
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2020-11-19 15:08:30 +02:00
Dimitar Tomov 24a49de385 Added AES CFB parameter support, salted TPM session, fixed KDFa and examples
* Added key generation example with parameter encryption
* Fixes and cleanups for KDFa
* Added KDFa unit test (passes)
* Added AES CFB support
* Fix for nonceTPM
* Added support for encrypted RSA salt and salted-unbounded session
* Removed unsalted-unbounded specific code for authValueKDF from KDFa
* Add innerWrap support
* Add missing wolfcrypt header for AES CFB
* Fixes for casting when calling KDFa for AES CFB parameter encryption
* Add outerWrap support

Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2020-11-19 15:08:30 +02:00
David Garske b48f53f5e7 Improvements to the example tls_server to accept "RSA" or "ECC". Improvement to TLS examples to old load keys/certs that are needed (reduces max handle load count). Added missing `scripts/tls_setup.sh` to automake. 2020-11-13 16:33:14 -08:00
David Garske 961710de63 Added support for importing external private key to get a key blob for easy re-loading. 2020-11-02 14:23:47 -08:00
David Garske 21daf5a21c Key generation and loading examples using disk to store the key. Leverage wolfSSL filesystem abstraction. 2020-10-26 15:49:51 -07:00
Dimitar Tomov 9770252a20 Add flush tool for clearing transient TPM objects like keys and auth sessions
Signed-off-by: Dimitar Tomov <dimi@designfirst.ee>
2020-10-01 00:36:25 +03:00
Dimitar Tomov 3ff97f675b Add TPM2.0 Quote example with Parameter Encryption over the user data
Signed-off-by: Dimitar Tomov <dimi@designfirst.ee>
2020-10-01 00:36:25 +03:00
Dimitar Tomov 0e2837b60d Add TPM2.0 parameter encryption using XOR obfuscation
Signed-off-by: Dimitar Tomov <dimi@designfirst.ee>
2020-10-01 00:36:25 +03:00
David Garske ebfbd4dd2d Moved the new clock_set example into the existing timestamp examples directory. Minor cleanups and fix for printf warning. 2020-09-02 11:46:12 -07:00
Dimitar Tomov 32d423cf71 Add TPM clock increment example
Signed-off-by: Dimitar Tomov <dimi@designfirst.ee>
2020-09-02 11:46:12 -07:00
Dimitar Tomov be3f9b7385 Cleanups based on peer review. Updated gitignore.
Signed-off-by: Dimitar Tomov <dimi@designfirst.ee>
2020-07-22 00:17:50 +03:00