Add seal/unseal examples with PCR, PolicyAuthorize, and NV policies#464
Merged
dgarske merged 3 commits intowolfSSL:masterfrom Feb 28, 2026
Merged
Add seal/unseal examples with PCR, PolicyAuthorize, and NV policies#464dgarske merged 3 commits intowolfSSL:masterfrom
dgarske merged 3 commits intowolfSSL:masterfrom
Conversation
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
There was a problem hiding this comment.
Pull request overview
Adds new TPM 2.0 seal/unseal example programs covering PCR-only, PolicyAuthorize, and NV+PCR policies, plus build integration and automated test coverage (standalone + CI) to validate the new examples.
Changes:
- Added three new example programs:
seal_pcr,seal_policy_auth, andseal_nv. - Integrated new examples into Autotools/CMake builds and updated example headers.
- Added standalone
seal_test.sh, expandedrun_examples.shintegration testing, and introduced a dedicated GitHub Actions workflow.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
examples/seal/seal_test.sh |
New standalone test runner for seal-related examples (3 test groups, logging, gating). |
examples/seal/seal_policy_auth.c |
New self-contained PolicyAuthorize + PCR seal/unseal example. |
examples/seal/seal_pcr.c |
New PCR-only policy seal/unseal example. |
examples/nvram/seal_nv.c |
New NV storage (PCR policy) example. |
examples/seal/seal.h |
Updates example function prototypes to include new seal examples. |
examples/pcr/pcr.h |
Removes obsolete PolicyAuth seal prototype from PCR header. |
examples/nvram/nvram.h |
Adds TPM2_NVRAM_SealNV_Example prototype and removes obsolete ones. |
examples/seal/include.am |
Autotools build + dist integration for new seal examples and seal_test.sh. |
examples/nvram/include.am |
Autotools build + dist integration for seal_nv. |
examples/seal/README.md |
New documentation covering seal examples, usage, testing, and policy comparison. |
examples/run_examples.sh |
Adds CI integration tests for the new seal examples. |
CMakeLists.txt |
Adds CMake build targets for the new examples. |
.gitignore |
Ignores the newly built example binaries. |
.github/workflows/seal-test.yml |
Adds a dedicated workflow to run seal_test.sh under SWTPM. |
.github/workflows/zephyr.yml |
Narrows push branch triggers to master/main/release/**. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…for supply-chain safety. Add explicit ref: master for wolfSSL, no ref for ibmswtpm2 (matches other workflows). 2. examples/seal/seal_policy_auth.c — Clarify header comment: no pre-existing key needed, but authkey.bin must be retained for unseal. 3. examples/seal/seal_test.sh - Add || return 1 to setup_pcr/change_pcr extend calls - Use grep -F -q -- for fixed-string secret matching - Add 6 new param enc tests (3.4a-c XOR, 3.5a-c AES) for seal_nv 4. examples/nvram/seal_nv.c — Implement real parameter encryption: - Add paramEncSession (separate from tpmSession to avoid conflict) - Start unsalted HMAC session with XOR/AES-CFB - Place on session slot 2 (slot 1 is used internally by NVWriteData for NV handle auth) - Clean up session in exit path 5. examples/run_examples.sh — Add seal_nv XOR param encryption integration test
dgarske
approved these changes
Feb 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds three new TPM 2.0 seal/unseal example programs demonstrating different
authorization policies, along with build system integration, a standalone
test suite, and a dedicated CI workflow.
New examples
seal_pcr(examples/seal/seal_pcr.c, 363 lines) — PCR-only policyseal/unseal. Binds secrets to specific PCR values without requiring a
password or signing key. Supports separate
-seal/-unsealoperations,combined
-bothmode, configurable PCR index (-pcr=N), custom blobfilenames (
-sealblob=), and XOR/AES parameter encryption.seal_policy_auth(examples/seal/seal_policy_auth.c, 529 lines) —PolicyAuthorize seal/unseal with a TPM-resident signing key. Creates an
ECC or RSA signing key that can re-authorize the PCR policy, allowing
secrets to survive authorized PCR changes (e.g., OS updates). Supports
-ecc/-rsakey types, split seal/unseal with persistentauthkey.bin,and XOR/AES parameter encryption.
seal_nv(examples/nvram/seal_nv.c, 364 lines) — NV storage withPCR policy. Stores secrets directly in TPM non-volatile memory protected
by a PCR policy, with
-store/-read/-deletelifecycle operations andconfigurable NV index (
-nvindex=). No external blob files needed.Build system
examples/seal/include.amandexamples/nvram/include.amwith build targets for all three new examples.CMakeLists.txtwithadd_tpm_example()entries.examples/seal/seal.handexamples/nvram/nvram.hwith new function prototypes; removed old
TPM2_PCR_Seal_With_Policy_Auth_*declarations that these examples replace.
.gitignore: Added built binaries (seal_pcr,seal_policy_auth,seal_nv).Integration testing
run_examples.sh: Added ~110 lines of integration tests coveringseal_pcr(seal/unseal + PCR mismatch negative test),seal_policy_auth(ECC + RSA variants), andseal_nv(store/read/deletelifecycle). These run as part of the existing
make checkCI.Standalone test suite
seal_test.sh(262 lines, 28 tests) — Comprehensive standalone testscript organized into 3 groups:
negative test, XOR/AES parameter encryption, custom blob filenames
seal/unseal, missing auth key negative test, XOR/AES encryption
negative test, custom NV index
seal_test.logWOLFCRYPT_ENABLE,WOLFCRYPT_DEFAULT,WOLFCRYPT_ECC,WOLFCRYPT_RSAenvironment variables for feature gatingCI workflow
.github/workflows/seal-test.yml— Dedicated GitHub Actions workflowthat builds wolfSSL + wolfTPM with SWTPM simulator and runs
seal_test.sh.Path-filtered to only trigger on changes to seal-related files. Follows
the same build pattern as
make-test-swtpm.yml. Uploadsseal_test.logon failure.
Documentation
examples/seal/README.md— Documents all four seal examples (existingseal/unseal+ new three) with usage examples, environment variablereference, and a policy comparison table.
Test plan
bash examples/seal/seal_test.sh)