Commit Graph

171 Commits (9d7f3fd79d45fd7d398791f3ac8995eeae73ce87)

Author SHA1 Message Date
Dimitar Tomov 9d7f3fd79d Added Doxygen documentation
* Doxygen configuration and script file under docs
* Added doxygen header to describe the different documentation modules
* Added doxygen comments about TPM2 Proprietary commands in wolfTPM
* Added doxygen comments about wolfTPM2 wrappers
* Added explanatory comments for TPM2 Standard commands and TPM2 IO examples
* Updates from peer feedback

Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-06-02 10:20:00 -07:00
David Garske dc5a3d8eae wolfTPM documentation improvement efforts. Most documentation exists in the root README.md and examples/README.md, but as we now have a /docs directory this PR helps provide guidance. As time permits plan to add doxygen style inline documentation for all API's. 2021-06-02 10:20:00 -07:00
David Garske ed1ec8c52d Support for QNX with wolfTPM:
* Fix for `wolfTPM2_NVCreateAuth` to return `TPM_RC_NV_DEFINED` if already exists (it used to do this, but broke with GPIO changes).
* Fixes for building wolfTPM with wolfCrypt only (no TLS).
* Fix for building without RSA and ECC.
* Fix for `--enable-smallstack` with parameter encryption,
* Fix for nvram/store unused variable.
2021-06-01 10:34:28 -07:00
Dimitar Tomov f1f4de5739 Added nameAlg hash algorithm option for a TPM key seal template
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-04-20 15:06:19 +03:00
Dimitar Tomov 5b8db8c7f4 Added new wolfTPM wrapper for creating a TPM key that seals user data
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-04-16 10:41:01 +03:00
Dimitar Tomov 35674052bb Added new example to demo TPM 2.0 extra GPIO control
* Create NV Index for GPIO access right after TPM2_GPIO_Config
* Set and read example to use the NV index created by the config example
* Added instructions about the new gpio examples
* Added vendor check, right now only ST33 supports TPM extra GPIO
* NV Index for GPIO Input requires an extra step, included in gpio/config
* Added sanity check and NV Index delete before new GPIO configuration
* Changes based on peer review

Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-04-08 08:35:14 -07:00
Dimitar Tomov 9f7c80286a Added vendor command for controlling TPM's extra I/O
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-03-29 11:14:03 +03:00
David Garske 2b8cfb8692 wolfTPM Release v2.1.0 preparation.
* Updated copyright
* Fixed minor cast warning.
* Fixed minor scan-build warnings.
* Cleanup print public and fix possible print of uninitialized field.
2021-03-17 10:13:50 -07:00
David Garske 197754b109 Minor cleanups. 2021-03-12 15:10:58 -08:00
Dimitar Tomov f0540d688e Make NVRAM and Keygen examples store the encoded public key part to save space
Before examples were always storing the maximum public key part size,
using sizeof(TPM2B_PUBLIC), with many empty fields. This meant, always
storing 616 bytes of public part, even if the public key part was less.

* writekeyBlob/readKeyBlob use the actual size of public key part
* NVRAM store/read use the actual size of the public key part
* Minor fixes from peer review
* Added comment to nvram/store about Host Endianness, per peer review
* Added public API for appending/parsing TPM2B_PUBLIC to byte streams

Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-03-12 15:10:58 -08:00
Dimitar Tomov dfb65753e1 Add TPM2_PrintPublicArea to help debugging
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-03-12 15:10:58 -08:00
Dimitar Tomov e1d9c661bd Minor fixes for NVRAM examples
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-03-01 10:52:02 +02:00
Dimitar Tomov 87e29005bf Fix parameter encryption for NVRAM commands
* Make sure hmac buffer space is reserved
* Add name computation for NV handles, modify TPM2_GetName
* Make TPM2_GetName handle multiple TPM Handle types
* Add wolfTPM2_SetNameHandle for passing handle name to parameter encryption
* Compute fresh NV Index Name during NVWrite with updated nvPublic information
* Compute fresh NV Index Name during NVRead, the same way NVWrite needs it

The NV_WRITTEN flag is being set, when there are consequtive reads, which
forces the hash to update. In order for this to take place, we need to
read the current(fresh) nvPublic information using TPM2_NV_ReadPublic.

* Add wolfTPM2_UnsetAuth to clear past authorization sessions when not needed

A way to clear auth sessions that are no longer needed was missing.

For example, after a TPM2_NVRead which uses two auth session slots, there
was no way for the user to clear the second slot afterwards. The only
possibility before was to overwrite with invalid values.

This way a TPM2_NVUndefineSpace would fail right after TPM2_NVRead, just
because there was an auth session not prevously cleared. This can be
handled either by the user manually or the user can use wolfTPM2 wrappers
that handle it now automatically using wolfTPM2_UnsetAuth.

Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-02-26 11:20:10 +02:00
Dimitar Tomov df0107605e Added TPM2_PrintAuth for debugging purposes
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-02-26 11:18:27 +02:00
Dimitar Tomov 529dcfe268 Fix typo on WOLFTPM_USER_SETTINGS ifdef
POSIX options.h is used when USER_SETTINGS are not available

Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-01-22 19:08:58 +02:00
David Garske 845b3d1da2 Release fixes and cleanups. Fixes for init of `WOLFTPM2_HASH` in `wolfTPM2_HashStart`. Fix for for various build configurations (--disable-wrapper). Fix for Microchip "sign" bit on symmetric keys. Fix for scan-build warnings. Cleanup whitespace. 2020-12-07 11:01:02 -08:00
David Garske b1a11c386a Preparation for wolfTPM v2.0 release. 2020-12-03 11:12:01 -08:00
David Garske d044360e38 Fixes for scan-build and g++ warnings. 2020-12-01 10:38:39 -08:00
David Garske 8087afaf27 Fixes from peer review. Resolve issue with make check. Removed the TPM Simulator for make check (does not build out of the box on all platforms). Make dist was not including the new tpm2_socket.h. 2020-12-01 07:45:04 -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
David Garske 4c2e8d3f43 Added response HMAC validation. Fixes for nonce and auth count. Fix for AES CFB decrypt set key (requires `AES_ENCRYPTION` on SetKey). Cleanup verbose debugging. PR ready for review. 2020-11-25 16:04:04 -08:00
David Garske 0e4c6672fd TPM Parameter Encryption with AES CFB or XOR is fully working. Tested keygen, keyload, keyimport and PCR quote with parameter encryption using both ciphers. This commit includes a refactor of the auth command structure to adhere to TPM spec. Includes optimization for AES CFB and XOR to do done inline. For for the decryption nonce to use the newer for U in KDFa. 2020-11-25 13:00:42 -08:00
David Garske 66ea1599c9 Fixes for cpHash calculation. Cleanup of the auth command/response processing. 2020-11-23 21:38:16 -08:00
David Garske 5abeea75a9 Added object names to the command hash calculation (cpHash). Added HMAC key creation. Fixed outstanding TODO items. 2020-11-23 14:54:39 -08:00
David Garske dbd8e41b47 Refactor of the session authentication. Added "-e" option to some examples to enable parameter encryption and removed the _paramenc.c files. Fixup for the `getPrimaryStoragekey` to allow persisting if not `WOLFTPM_WINAPI`. Improve command line options. Added calculation of command hash and HMAC for sessions. 2020-11-20 16:47:14 -08:00
Dimitar Tomov 7edd3950bc Extend wolfTPM2_SESSION with new field for fresh nonceCaller between commands
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2020-11-19 17:50:02 +02:00
Dimitar Tomov 8459ec712a Prepare for new nonceTPM solution and TPM session tracking
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2020-11-19 15:37:21 +02:00
Dimitar Tomov 72e365329c New nonceTPM solution needed, restoring TPMS_AUTH_COMMAND to its TCG spec form
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2020-11-19 15:30:17 +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
Dimitar Tomov 5b757b8b72 New auth session handling for TPM2 command handlers
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2020-11-18 23:50:45 +02:00
Elms 8213c7af92 socket: Add optional ability to use wolfSSL IO 2020-11-12 14:04:00 -08:00
Elms 1fcae21585 Refactor socket code to support win32 2020-11-12 14:04:00 -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 6b61e85496 Improved the key blob storage. Added ECC support to keygen example. 2020-10-27 10:16:33 -07: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
Elms 3f79e7adfb Add TBS context that persists across commands 2020-10-12 15:41:59 -07:00
Elms 3a1ef5a0a4 Add winapi for Windows TBS support (with minGW build)
TESTED:

  `./configure --host=i686 CC=i686-w64-mingw32-gcc CFLAGS="-DWIN32 \
  -DMINGW -D_WIN32_WINNT=0x0600" LIBS="-lws2_32 -ltbs" \
  --enable-winapi`
2020-10-07 13:22:19 -07:00
Elms 0fb03c12b1 compiling with minGW
- mingw visibility fix
2020-10-07 13:21:49 -07:00
David Garske 5e27edd254
Merge pull request #126 from elms/init_cleanup_document
Reduce Init_ex code and add documention on `ioCb` and `userCtx`
2020-10-01 11:10:13 -07:00
Dimitar Tomov a9bf83bc32 Final changes to XOR Parameter Encryption from peer review
Made TPM2_ParamEnc_XOR an internal function(static local).
Made TPM2_ParamEnc_CmdRequest and TPM2_ParamEnc_CmdRespones WOLFTPM_LOCAL.
Fixed one warning from static analyzer in about cmdSz related to debug print.

Signed-off-by: Dimitar Tomov <dimi@designfirst.ee>
2020-10-01 00:58:23 +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
Elms 2114fa0318 Reduce Init_ex code and add documention on `ioCb` and `userCtx` 2020-09-30 14:04:26 -07:00
Elms 322d20744f Annotate TPM2_{SWTPM,LINUX}_SendCommand() as interal API 2020-09-24 16:12:51 -07:00
Elms 03fdfb1c81 Revert public API change to TPM2_Init_minimal 2020-09-24 15:26:27 -07:00
Elms 840d30be4e change interal SendCommand to use packet struct 2020-09-24 09:47:46 -07:00
Elms 9617dab37e swtpm: Rename SOCKET option to SWTPM 2020-09-24 08:37:06 -07:00
Elms 8d6abc3856 swtpm: send startup with wrapTPM 2020-09-24 08:31:15 -07:00
Elms 63736417b2 Add socket connection option for using with TPM2 simulator
This is largely based on and tested against http://ibmswtpm.sourceforge.net/
2020-09-23 10:39:38 -07:00
Eric Blankenhorn 72464dc621 Release v1.9 preparation 2020-08-24 12:12:11 -05:00
David Garske 8eb67b5bcf Improvements to the signed timestamp example. Cleanup of the key template API's. 2020-07-21 15:24:10 -07:00