Commit Graph

88 Commits (b69496c42847411017f9c3f6796e26463c71f24c)

Author SHA1 Message Date
David Garske d035cd239c Fix for a few spelling errors. Whitespace cleanup. 2021-12-07 11:10:50 -08:00
David Garske 8455beaae4 Fixes for Public PEM functions. Cleanups. 2021-07-12 17:12:22 -07:00
Dimitar Tomov 8528a326be Added fixes and unit tests for wolfTPM2_CreateLoadedKey and TPM2_CreateLoaded
* Added new units tests and fixed missing XMEMSET
* Renamed and modified PemToTpm to PubPemToTpm, works only with Pub keys
* Fixes from peer feedback

Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-07-12 15:09:28 -07:00
Dimitar Tomov 3e217cc497 Made keygen and attestation examples work with EH keys
* Added option in keygen example to create and use keys under the EK
    - Added PolicySecret to provide EK auth

* Fix wrong total auth area size when multiple auth sessions are used
* Workaround policy Session for EK auth
* Added flag in WOLFTPM2_HANDLE to specify when policyAuth is used
* Added three macros to check TPM2.0 Policy session type

* Added option to use keys under Endorsement Hierarchy in attestation examples
    - MakeCredential modified to work without auth as TCG spec defines
    - MakeCredential can now use EK pub to encrypt challenge
    - AcivateCredential can now work with EK pub to decrypt challenge

* Added new wolfTPM2 wrapper for TPM2_CreateLoaded
    - Added missing TPM2_CreateLoaded command in tpm2.c
    - Create and load a key in single TPM 2.0 operation

* Added new wolfTPM2 wrappers to use PEM format in keygen
    - wolfTPM2_RsaKey_TpmToPem
    - wolfTPM2_RsaKey_PemToTpm

* Improved keygen, output in PEM format and saving EK's TPM2B_PUBLIC
    - Added keygen option to output PEM files for TPM public keys
    - Added saving of EK's TPM2B_PUBLIC for attestation purposes

* Modified keygen
    - Uses new wolfTPM2_CreateLoaded wrapper to acquire correct AK name
    - Stores AK name for attestation purposes

* Modified keyload to be able to load keys created under the EK/EH
    - Uses new wrapper
    - Can load keys created under EK/EH, non-AK and AK

* Added new wrapper for satisfying EK policy

* Applied fixes from peer review

Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
2021-07-12 15:09:28 -07:00
David Garske e5a61e069d Revert change in docs PR to `WOLFTPM2_HANDLE`. Broke build. 2021-06-02 13:52:36 -07:00
David Garske 6d7937ac82 Fixes from enabling warning reporting. Moving `WOLFTPM2_HANDLE` fixed an issue with the struct not being detected. 2021-06-02 11:08:00 -07:00
David Garske 87d1be8b0e Fixes from peer review. Thanks Jeff. 2021-06-02 11:03:18 -07:00
David Garske 1942b3fd05 Move doxy group defs to the same header files and remove `doxygen.h`. 2021-06-02 10:20:00 -07:00
David Garske 6bef9cd46b Added TPM2 wrapper API documentation for crypto callbacks. 2021-06-02 10:20:00 -07:00
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
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
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
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
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 d044360e38 Fixes for scan-build and g++ warnings. 2020-12-01 10:38:39 -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 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 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 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 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
Elms 2114fa0318 Reduce Init_ex code and add documention on `ioCb` and `userCtx` 2020-09-30 14:04:26 -07: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
David Garske 30f2e644aa Added NPCT75x Nuvoton support. 2020-07-13 09:54:00 -07:00
David Garske 3de776b9e4 TPM RSA sign and verify wrapper support and expanded RSA key loading support:
* Added RSA support for `wolfTPM2_SignHash` and `wolfTPM2_VerifyHash`.
* Added `wolfTPM2_SignHashScheme` and `wolfTPM2_VerifyHashScheme` support for signature scheme and hash algo.
* Added `wolfTPM2_LoadRsaPrivateKey_ex` and `wolfTPM2_LoadRsaPublicKey_ex` support for signature scheme and hash algo.
* Fix for typo on hashAlg and sigAlg (per spec).
* Added RSA sign/verify examples for PKCSv1.5 (SSA) and PSS padding schemes.
* Fixes for building without ECC key import/export.
2020-06-18 14:35:59 -07:00
Dimitar Tomov 4d4a0a8d3b Cleanups and fixes based on peer review.
Signed-off-by: Dimitar Tomov <dimi@designfirst.ee>
2020-05-29 16:58:22 +03:00
Dimitar Tomov 5ffdd5a176 Add wolfTPM2 wrapper for creating signed timestamps and update example
Signed-off-by: Dimitar Tomov <dimi@designfirst.ee>
2020-05-29 16:21:10 +03:00
Dimitar Tomov 6e04d6fc5c Add wrappers for creating typical TPM encrypted keys, AIK, SRK and EK
Signed-off-by: Dimitar Tomov <dimi@designfirst.ee>
2020-05-29 16:19:48 +03:00
Chris Conlon 91ef0b0e6e update copyright to 2020 2020-01-03 15:31:27 -08:00
David Garske 7887130287 wolfTPM v1.7 Release 2019-12-27 14:43:30 -08:00
David Garske 9ebc039edb Added new wrappers for shutdown and handle cleanup. 2019-10-22 12:23:06 -07:00
Eric Blankenhorn 0e4788bebd
Merge pull request #79 from dgarske/nvauth
Added support for using authentication with NV
2019-08-15 15:34:06 -05:00
David Garske 4f1fb41d7e Added support for using authentication with NV. Adds new wrapper API's: `wolfTPM2_NVWriteAuth`, `wolfTPM2_NVReadAuth` and `wolfTPM2_NVDeleteAuth`. 2019-08-15 13:19:40 -07:00
David Garske 78be5098cc Added wrapper for changing a key's authentication `wolfTPM2_ChangeAuthKey`. 2019-08-08 21:06:58 -07:00
David Garske a4cf30838d Added support for keeping an HMAC key loaded on finish to allow using the same key for additional HMAC operations. 2019-07-25 08:52:56 -07:00
David Garske c6e45dc580 Added new wrapper API `wolfTPM2_OpenExisting` for accessing device that's already started. Added unit test framework. 2019-07-23 14:43:40 -07:00
David Garske 4b0ac61ef5 Added FIPS mode and Use Symmetric options. 2019-07-15 14:34:40 -07:00
David Garske b2063f67f3 Added new `wolfTPM2_ExtendPCR` wrapper. Added wrapper tests for PCR wrapper functions. 2019-06-19 16:29:40 -07:00
David Garske 3e9d70c159 Fix to better handle chip detection. Added stdio printf include for TPM benchmark. Added C++ support. 2019-05-07 10:39:17 -07:00
David Garske 01f5dc856c Added new API `wolfTPM2_Test` for testing for TPM and optionally returning capabilties. This API is useful for providing a "single shot" call without context to init and test the TPM module. 2019-05-06 13:54:44 -07:00
David Garske 6d836b91ad Fix to make sure the Crypto callback is unregistered on cleanup. 2019-02-12 09:21:37 -08:00
David Garske 19bfc49d4e Fix for polling timeout issue on RSA key gen. Improved performance for SLB9670 by adding 10us delay between polling. Tuned max SPI clock and performance for supported TPM 2.0 chips. Cleanups for the configure automake output. Updated benchmarks and console output for examples in README.md. Added self test wrapper and call to it in wrapper init to resolve ATTPM20 issue (can also be enabled using `WOLFTPM_PERFORM_SELFTEST`). 2019-02-08 17:29:34 -08:00
David Garske 7706f9a652 Fix for AES IV output to support blocks over 1024 bytes. Added more AES tests. 2019-02-07 10:12:47 -08:00
David Garske 586219164c Fixes for TPM HMAC with CryptoCb. 2019-02-05 17:47:58 -08:00
David Garske 1a27e9676a Added HMAC wrapper support. Added HMAC crypto callback support. 2019-02-03 17:18:58 -08:00