Skip to content

Commit 5b288d4

Browse files
Merge pull request #306 from dgarske/rel_v3.0_prep
Prep for release v3.0
2 parents 45847e3 + a10a10d commit 5b288d4

File tree

16 files changed

+169
-75
lines changed

16 files changed

+169
-75
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
cmake_minimum_required(VERSION 3.16)
2323

24-
project(wolfTPM VERSION 2.7.0 LANGUAGES C)
24+
project(wolfTPM VERSION 3.0.0 LANGUAGES C)
2525

2626
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2727
set(WOLFTPM_DEFINITIONS)

ChangeLog.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,51 @@
11
# Release Notes
22

3+
## wolfTPM Release 3.0.0 (Oct 31, 2023)
4+
5+
**Summary**
6+
7+
Refactor of command authentication. Support for ECC sessions and secrets. Support for policy sealing/unsealing. Examples for secure boot.
8+
9+
**Detail**
10+
* Refactor of the command authentication. If command does not require auth do not supply it (PR #305)
11+
* Refactor HAL and added Microchip Harmony SPI HAL support (PR #251)
12+
* Relocate crypto callback code to its own code file (PR #304)
13+
* Fixed using a custom wolfTPM CSR sigType (PR #307)
14+
* Fixed support for ECC 384-bit only support (PR #307)
15+
* Fixed issue with using struct assignment (switched to memcpy) (PR #303)
16+
* Fixed various issues building with C++ compiler (PR #303)
17+
* Fixed issues with STM32 I2C build and improved performance (PR #302)
18+
* Fixed seal with RSA and PCR extend auth. (PR #296)
19+
* Fixed issue including user_settings.h when `--disable-wolfcrypt` set (PR #285)
20+
* Fixed TPM private key import with custom seed (PR #281)
21+
* Fixed autogen.sh (autoconf) to generate without warnings (PR #279)
22+
* Fixed TPM2 create with decrypt or restricted flag set (PR #275)
23+
* Fixed and improved low resource build options (PR #269)
24+
* Fixed the TPM_E_COMMAND_BLOCKED macro to have the correct value (PR #257)
25+
* Fixed casting and unused variable problems on windows (PR #255)
26+
* Fixed Linux usage of `cs_change` and added config overrides (PR #268)
27+
* Fixed and improved the NV auth and session auth set/unset (PR #299)
28+
* Fixed capability to handle unknown `TPM2_GetCapability` type and fix bad printf (PR #293)
29+
* Fixed macros for file IO XFEOF and XREWIND to make sure they are available (PR #277)
30+
* Fixed seal/unseal example (PR #306)
31+
* Fixed TLS examples with param enc enabled (PR #306)
32+
* Fixed signed_timestamp with ECC (PR #306)
33+
* Added CI tests for CSharp wrappers (PR #307)
34+
* Added support for sealing/unsealing based on a PCR that is signed externally (PR #294)
35+
* Added examples for Secure Boot solution to store root of trust in NV (PR's #276, #289, #291 and #292)
36+
* Added support for importing and loading public ECC/RSA keys formatted as PEM or DER (PR #290)
37+
* Added new policy_nv example (PR #298)
38+
* Added `-nvhandle` argument to nvram examples (PR #296)
39+
* Added code to test external import between two TPM's (PR #288)
40+
* Added support for STM32 Cube Expansion Pack (PR #287)
41+
* Added support memory mapped (MMIO) TPM's (PR #271)
42+
* Added `wc_SetSeed_Cb` call for FIPS ecc (PR #270)
43+
* Added wrapper support for setting key usage (not just extended key usage) (PR #307)
44+
* Added RSA key import methods to handle PEM and DER encoding directly (PR #252)
45+
* Added thread local storage macro and make gActiveTPM local to the thread (PR #253)
46+
* Added Microchip macro names and Support for bench with MPLABX Harmony (PR #256)
47+
* Improvements to cmake build (PR's #280, #283 and #284)
48+
349
## wolfTPM Release 2.7.0 (Dec 27, 2022)
450

551
**Summary**

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -791,11 +791,9 @@ Connection: close
791791

792792
## Todo
793793

794-
* Update to v1.59 of specification.
795-
* Add HMAC support for "authValue".
796-
* Add ECC encrypted salt.
797-
* Add bound auth session support.
798-
* Add multiple auth session (nonceTPMDecrypt and nonceTPMEncrypt) support.
794+
* Key Generation and Attestation examples using endorsement hierarchy "-eh" are broken.
795+
* Update to v1.59 of specification (adding CertifyX509)
796+
* Inner wrap support for SensitiveToPrivate.
799797

800798
## Support
801799

configure.ac

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# All right reserved.
44

55
AC_COPYRIGHT([Copyright (C) 2014-2021 wolfSSL Inc.])
6-
AC_INIT([wolftpm],[2.7.0],[https://github.com/wolfssl/wolfTPM/issues],[wolftpm],[http://www.wolfssl.com])
6+
AC_INIT([wolftpm],[3.0.0],[https://github.com/wolfssl/wolfTPM/issues],[wolftpm],[http://www.wolfssl.com])
77

88
AC_PREREQ([2.63])
99
AC_CONFIG_AUX_DIR([build-aux])
@@ -28,7 +28,7 @@ AC_ARG_PROGRAM
2828

2929
AC_CONFIG_HEADERS([src/config.h])
3030

31-
WOLFTPM_LIBRARY_VERSION=15:0:0
31+
WOLFTPM_LIBRARY_VERSION=16:0:0
3232
# | | |
3333
# +------+ | +---+
3434
# | | |
@@ -241,13 +241,17 @@ then
241241
fi
242242

243243
# Windows TBS device Support
244+
AC_ARG_ENABLE([wintbs],,
245+
[ ENABLED_WINTBS=$enableval ],
246+
[ ENABLED_WINTBS=no ]
247+
)
244248
AC_ARG_ENABLE([winapi],
245249
[AS_HELP_STRING([--enable-winapi],[Enable use of TPM through Windows driver (default: disabled)])],
246250
[ ENABLED_WINAPI=$enableval ],
247251
[ ENABLED_WINAPI=no ]
248252
)
249253

250-
if test "x$ENABLED_WINAPI" = "xyes"
254+
if test "x$ENABLED_WINAPI" = "xyes" || test "x$ENABLED_WINTBS" = "xyes"
251255
then
252256
if test "x$ENABLED_DEVTPM" = "xyes" -o "x$ENABLED_SWTPM" = "xyes"
253257
then

examples/keygen/external_import.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ int TPM2_ExternalImport_Example(void* userCtx, int argc, char *argv[])
8989
TPMT_PUBLIC publicTemplate3;
9090
TPMA_OBJECT attributes;
9191
TPMI_ALG_PUBLIC alg = TPM_ALG_RSA;
92-
#if !defined(NO_FILESYSTEM) && !defined(NO_WRITE_TEMP_FILES)
9392
const char* keyblobFile = "keyblob.bin";
94-
#endif
9593
int loadKeyBlob = 0;
9694

9795
if (argc >= 2) {

examples/pcr/policy_sign.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ static int PolicySign(TPM_ALG_ID alg, const char* keyFile, const char* password,
165165
wc_FreeRsaKey(&key.rsa);
166166
}
167167
#else
168+
(void)hashAlg;
168169
rc = NOT_COMPILED_IN;
169170
#endif
170171
}

examples/run_examples.sh

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,9 @@ if [ $WOLFCRYPT_ENABLE -eq 1 ]; then
7777
./examples/keygen/keyload ecckeyblob.bin -aes >> run.out
7878
RESULT=$?
7979
[ $RESULT -ne 0 ] && echo -e "keyload ecc param enc failed! $RESULT" && exit 1
80-
8180
./examples/keygen/keyimport ecckeyblob.bin -ecc >> run.out
8281
RESULT=$?
8382
[ $RESULT -ne 0 ] && echo -e "keyload ecc import failed! $RESULT" && exit 1
84-
# TODO: TPM2_Load (TPM_RC_INTEGRITY)
85-
#./examples/keygen/keyload ecckeyblob.bin >> run.out
8683
fi
8784
rm -f ecckeyblob.bin
8885

@@ -201,7 +198,7 @@ run_tpm_tls_client() { # Usage: run_tpm_tls_client [ecc/rsa] [tpmargs]]
201198
RESULT=$?
202199
[ $RESULT -ne 0 ] && echo -e "tls server $1 $2 failed! $RESULT" && exit 1
203200
popd >> run.out
204-
sleep 0.2
201+
sleep 0.4
205202
./examples/tls/tls_client -p=$port -$1 $2 2>&1 >> run.out
206203
RESULT=$?
207204
[ $RESULT -ne 0 ] && echo -e "tpm tls client $1 $2 failed! $RESULT" && exit 1
@@ -214,7 +211,7 @@ run_tpm_tls_server() { # Usage: run_tpm_tls_server [ecc/rsa] [tpmargs]]
214211
RESULT=$?
215212
[ $RESULT -ne 0 ] && echo -e "tpm tls server $1 $2 failed! $RESULT" && exit 1
216213
pushd $WOLFSSL_PATH >> run.out
217-
sleep 0.2
214+
sleep 0.4
218215
./examples/client/client -p $port -g -A ./certs/tpm-ca-$1-cert.pem 2>&1 >> $PWD/run.out
219216
RESULT=$?
220217
[ $RESULT -ne 0 ] && echo -e "tls client $1 $2 failed! $RESULT" && exit 1
@@ -223,24 +220,20 @@ run_tpm_tls_server() { # Usage: run_tpm_tls_server [ecc/rsa] [tpmargs]]
223220

224221
if [ $WOLFCRYPT_ENABLE -eq 1 ]; then
225222
run_tpm_tls_client "rsa" ""
226-
# TODO: Not working (TPM2_Load TPM_RC_COMMAND_SIZE)
227-
#run_tpm_tls_client "rsa" "-aes"
223+
run_tpm_tls_client "rsa" "-aes"
228224
run_tpm_tls_client "ecc" ""
229-
# TODO: Not working (TPM2_Load TPM_RC_COMMAND_SIZE)
230-
#run_tpm_tls_client "ecc" "-aes"
225+
run_tpm_tls_client "ecc" "-aes"
231226

232227
run_tpm_tls_server "rsa" ""
233-
# TODO: Not working (TPM2_Load TPM_RC_COMMAND_SIZE)
234-
#run_tpm_tls_server "rsa" "-aes"
228+
run_tpm_tls_server "rsa" "-aes"
235229
run_tpm_tls_server "ecc" ""
236-
# TODO: Not working (TPM2_Load TPM_RC_COMMAND_SIZE)
237-
#run_tpm_tls_server "ecc" "-aes"
230+
run_tpm_tls_server "ecc" "-aes"
238231
fi
239232

240233

241234
# Clock Tests
242235
echo -e "Clock tests"
243-
./examples/timestamp/clock_set
236+
./examples/timestamp/clock_set >> run.out
244237
RESULT=$?
245238
[ $RESULT -ne 0 ] && echo -e "clock set failed! $RESULT" && exit 1
246239

@@ -255,11 +248,14 @@ if [ $WOLFCRYPT_ENABLE -eq 1 ]; then
255248
RESULT=$?
256249
[ $RESULT -ne 0 ] && echo -e "signed_timestamp param enc failed! $RESULT" && exit 1
257250
fi
258-
# TODO: Test broken (wolfTPM2_GetTime TPM_RC_SCHEME)
259-
#./examples/timestamp/signed_timestamp -ecc >> run.out
260-
#if [ $WOLFCRYPT_ENABLE -eq 1 ]; then
261-
#./examples/timestamp/signed_timestamp -ecc -aes >> run.out
262-
#fi
251+
./examples/timestamp/signed_timestamp -ecc >> run.out
252+
RESULT=$?
253+
[ $RESULT -ne 0 ] && echo -e "signed_timestamp ecc failed! $RESULT" && exit 1
254+
if [ $WOLFCRYPT_ENABLE -eq 1 ]; then
255+
./examples/timestamp/signed_timestamp -ecc -aes >> run.out
256+
RESULT=$?
257+
[ $RESULT -ne 0 ] && echo -e "signed_timestamp ecc param enc failed! $RESULT" && exit 1
258+
fi
263259

264260
./examples/attestation/make_credential >> run.out
265261
RESULT=$?
@@ -350,11 +346,21 @@ fi
350346
echo -e "Seal/Unseal (PCR policy)"
351347
./examples/seal/seal sealedkeyblob.bin mySecretMessage >> run.out
352348
RESULT=$?
353-
[ $RESULT -ne 0 ] && echo -e "seal pcr failed! $RESULT" && exit 1
354-
# TODO (TPM2_Load TPM_RC_BAD_AUTH)
355-
#./examples/seal/unseal message.raw sealedkeyblob.bin >> run.out
349+
[ $RESULT -ne 0 ] && echo -e "seal failed! $RESULT" && exit 1
350+
./examples/seal/unseal message.raw sealedkeyblob.bin >> run.out
351+
RESULT=$?
352+
[ $RESULT -ne 0 ] && echo -e "unseal failed! $RESULT" && exit 1
356353
rm -f sealedkeyblob.bin
357354

355+
if [ $WOLFCRYPT_ENABLE -eq 1 ]; then
356+
./examples/seal/seal sealedkeyblob.bin mySecretMessage -aes >> run.out
357+
RESULT=$?
358+
[ $RESULT -ne 0 ] && echo -e "seal aes failed! $RESULT" && exit 1
359+
./examples/seal/unseal message.raw sealedkeyblob.bin -aes >> run.out
360+
RESULT=$?
361+
[ $RESULT -ne 0 ] && echo -e "unseal aes failed! $RESULT" && exit 1
362+
rm -f sealedkeyblob.bin
363+
fi
358364

359365
# Seal/Unseal (Policy auth)
360366
echo -e "Seal/Unseal (Policy auth)"

examples/seal/seal.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ static void usage(void)
4040
{
4141
printf("Expected usage:\n");
4242
printf("./examples/seal/seal [filename] [userdata]\n");
43-
printf("* filename: Name of the file where the TPM key will be stored\n");
44-
printf("* userdata: Arbitrary data to seal inside the TPM key (no whitespaces)\n");
45-
printf("Demo usage, without parameters, uses keyblob.bin as a filename\n");
43+
printf("* -aes/xor: Use Parameter Encryption\n");
44+
printf("* filename: Name of the file where the TPM key will be stored (default: keyblob.bin)\n");
45+
printf("* userdata: Arbitrary data to seal inside the TPM key (no whitespaces) (default: My1Pass2Phrase3)\n");
4646
}
4747

4848
int TPM2_Seal_Example(void* userCtx, int argc, char *argv[])
@@ -95,6 +95,7 @@ int TPM2_Seal_Example(void* userCtx, int argc, char *argv[])
9595

9696
printf("TPM2.0 Simple Seal example\n");
9797
printf("\tKey Blob: %s\n", outputFile);
98+
printf("\tUser Data: %s\n", userData);
9899
printf("\tUse Parameter Encryption: %s\n", TPM2_GetAlgName(paramEncAlg));
99100

100101
rc = wolfTPM2_Init(&dev, TPM2_IoCb, userCtx);
@@ -159,6 +160,9 @@ int TPM2_Seal_Example(void* userCtx, int argc, char *argv[])
159160
printf("\nFailure 0x%x: %s\n\n", rc, wolfTPM2_GetRCString(rc));
160161
}
161162

163+
/* Remove the auth for loaded TPM seal object */
164+
wolfTPM2_UnsetAuth(&dev, 0);
165+
162166
/* Close handles */
163167
wolfTPM2_UnloadHandle(&dev, &storage.handle);
164168
wolfTPM2_UnloadHandle(&dev, &newKey.handle);

examples/seal/unseal.c

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,20 @@ static void usage(void)
4141
{
4242
printf("Expected usage:\n");
4343
printf("./examples/seal/unseal [filename] [inkey_filename]\n");
44-
printf("* filename - File contaning a TPM seal key\n");
44+
printf("* -aes/xor: Use Parameter Encryption\n");
45+
printf("* filename: Output for unsealed data (default: unseal.bin)\n");
46+
printf("* inkey_filename: File with sealed keyed hashed object (keyblob.bin)\n");
4547
printf("Demo usage, without arguments, uses keyblob.bin file input.\n");
4648
}
4749

4850
int TPM2_Unseal_Example(void* userCtx, int argc, char *argv[])
4951
{
5052
int rc;
5153
WOLFTPM2_DEV dev;
52-
WOLFTPM2_KEY key;
53-
TPM2B_AUTH auth;
54+
WOLFTPM2_KEYBLOB newKey;
55+
WOLFTPM2_KEY storage; /* SRK */
56+
TPM_ALG_ID paramEncAlg = TPM_ALG_NULL;
57+
WOLFTPM2_SESSION tpmSession;
5458
const char *filename = "unseal.bin";
5559
const char *inkeyfilename = "keyblob.bin";
5660
#if !defined(NO_FILESYSTEM) && !defined(NO_WRITE_TEMP_FILES)
@@ -60,14 +64,11 @@ int TPM2_Unseal_Example(void* userCtx, int argc, char *argv[])
6064
Unseal_In cmdIn_unseal;
6165
Unseal_Out cmdOut_unseal;
6266

63-
WOLFTPM2_KEYBLOB newKey;
64-
WOLFTPM2_KEY storage; /* SRK */
65-
66-
67+
XMEMSET(&storage, 0, sizeof(storage));
68+
XMEMSET(&tpmSession, 0, sizeof(tpmSession));
6769
XMEMSET(&cmdIn_unseal, 0, sizeof(cmdIn_unseal));
6870
XMEMSET(&cmdOut_unseal, 0, sizeof(cmdOut_unseal));
69-
XMEMSET(&key, 0, sizeof(key));
70-
XMEMSET(&auth, 0, sizeof(auth));
71+
XMEMSET(&newKey, 0, sizeof(newKey));
7172

7273
if (argc >= 2) {
7374
if (XSTRCMP(argv[1], "-?") == 0 ||
@@ -85,6 +86,23 @@ int TPM2_Unseal_Example(void* userCtx, int argc, char *argv[])
8586
inkeyfilename = argv[2];
8687
}
8788
}
89+
while (argc > 1) {
90+
if (XSTRCMP(argv[argc-1], "-aes") == 0) {
91+
paramEncAlg = TPM_ALG_CFB;
92+
}
93+
else if (XSTRCMP(argv[argc-1], "-xor") == 0) {
94+
paramEncAlg = TPM_ALG_XOR;
95+
}
96+
else if (argv[argc-1][0] == '-') {
97+
printf("Warning: Unrecognized option: %s\n", argv[argc-1]);
98+
}
99+
argc--;
100+
}
101+
102+
printf("TPM2.0 Simple Unseal example\n");
103+
printf("\tKey Blob: %s\n", inkeyfilename);
104+
printf("\tUse Parameter Encryption: %s\n", TPM2_GetAlgName(paramEncAlg));
105+
88106

89107
printf("Example how to unseal data using TPM2.0\n");
90108
rc = wolfTPM2_Init(&dev, TPM2_IoCb, userCtx);
@@ -97,6 +115,21 @@ int TPM2_Unseal_Example(void* userCtx, int argc, char *argv[])
97115
rc = getPrimaryStoragekey(&dev, &storage, TPM_ALG_RSA);
98116
if (rc != 0) goto exit;
99117

118+
if (paramEncAlg != TPM_ALG_NULL) {
119+
/* Start an authenticated session (salted / unbound) with parameter encryption */
120+
rc = wolfTPM2_StartSession(&dev, &tpmSession, &storage, NULL,
121+
TPM_SE_HMAC, paramEncAlg);
122+
if (rc != 0) goto exit;
123+
printf("TPM2_StartAuthSession: sessionHandle 0x%x\n",
124+
(word32)tpmSession.handle.hndl);
125+
126+
/* set session for authorization of the storage key */
127+
rc = wolfTPM2_SetAuthSession(&dev, 1, &tpmSession,
128+
(TPMA_SESSION_decrypt | TPMA_SESSION_encrypt | TPMA_SESSION_continueSession));
129+
if (rc != 0) goto exit;
130+
131+
}
132+
100133
rc = readKeyBlob(inkeyfilename, &newKey);
101134
if (rc != 0) goto exit;
102135

@@ -109,9 +142,9 @@ int TPM2_Unseal_Example(void* userCtx, int argc, char *argv[])
109142
(word32)newKey.handle.hndl);
110143

111144
/* Set authorization for using the seal key */
112-
auth.size = (int)sizeof(gKeyAuth) - 1;
113-
XMEMCPY(auth.buffer, gKeyAuth, auth.size);
114-
wolfTPM2_SetAuthPassword(&dev, 0, &auth);
145+
newKey.handle.auth.size = (int)sizeof(gKeyAuth) - 1;
146+
XMEMCPY(newKey.handle.auth.buffer, gKeyAuth, newKey.handle.auth.size);
147+
wolfTPM2_SetAuthHandle(&dev, 0, &newKey.handle);
115148

116149
cmdIn_unseal.itemHandle = newKey.handle.hndl;
117150

@@ -146,12 +179,13 @@ int TPM2_Unseal_Example(void* userCtx, int argc, char *argv[])
146179
(void)filename;
147180
#endif
148181

149-
/* Remove the loaded TPM seal object */
150-
wolfTPM2_SetAuthPassword(&dev, 0, NULL);
182+
/* Remove the auth for loaded TPM seal object */
183+
wolfTPM2_UnsetAuth(&dev, 0);
151184

152185
exit:
153186
wolfTPM2_UnloadHandle(&dev, &storage.handle);
154187
wolfTPM2_UnloadHandle(&dev, &newKey.handle);
188+
wolfTPM2_UnloadHandle(&dev, &tpmSession.handle);
155189

156190
wolfTPM2_Cleanup(&dev);
157191
return rc;

examples/timestamp/signed_timestamp.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,8 @@ int TPM2_Timestamp_TestArgs(void* userCtx, int argc, char *argv[])
180180
if (paramEncAlg != TPM_ALG_NULL) {
181181
sessionAttributes |= (TPMA_SESSION_decrypt | TPMA_SESSION_encrypt);
182182
}
183-
#if 0
184-
/* TODO: Investigate param enc with signed timestamp */
185183
rc = wolfTPM2_SetAuthSession(&dev, 2, &tpmSession, sessionAttributes);
186184
if (rc != 0) goto exit;
187-
#else
188-
(void)sessionAttributes;
189-
#endif
190185

191186
/* At this stage: The SRK is created, AIK is created and loaded,
192187
* Endorsement Hierarchy is enabled through policySecret,

0 commit comments

Comments
 (0)