Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 1 | # Official TPM 2.0 Reference Implementation (by Microsoft) #
|
Brian Telfer | 5e0fa6b | 2018-02-22 00:08:02 +0000 | [diff] [blame] | 2 |
|
Andrey Marochko | daf5209 | 2018-12-14 22:22:15 -0800 | [diff] [blame] | 3 | [](https://travis-ci.org/Microsoft/ms-tpm-20-ref)
|
Andrey Marochko | b8e5992 | 2017-06-29 17:13:14 -0700 | [diff] [blame] | 4 |
|
Andrey Marochko | daf5209 | 2018-12-14 22:22:15 -0800 | [diff] [blame] | 5 | This is the official TCG reference implementation of the [TPM 2.0 Specification](https://trustedcomputinggroup.org/tpm-library-specification). The project contains complete source code of the reference implementation with a Microsoft Visual Studio solution and Linux autotools build scripts.
|
Andrey Marochko | b8e5992 | 2017-06-29 17:13:14 -0700 | [diff] [blame] | 6 |
|
Andrey Marochko | daf5209 | 2018-12-14 22:22:15 -0800 | [diff] [blame] | 7 | See the definition of the `SPEC_VERSION`, `SPEC_YEAR` and `SPEC_DAY_OF_YEAR` values in the [TpmTypes.h](TPMCmd/tpm/include/TpmTypes.h) header for the exact revision/date of the TPM 2.0 specification, which the given source tree snapshot corresponds to.
|
Andrey Marochko | b8e5992 | 2017-06-29 17:13:14 -0700 | [diff] [blame] | 8 |
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 9 | The reference implementation can be directly used via the [TPM 2.0 simulator](TPMCmd/Simulator) that emulates a TPM 2.0 device and can be accessed via a custom TCP based protocol. The simplest way to work with the simulator is to use a [TSS library](https://github.com/Microsoft/TSS.MSR) for the programming language of your choice - C#/.Net, C++, Java, Python, JavaScript/Node.js are currently supported. The C language TSS implementing the TCG's TSS API specifiaction is available [here](https://github.com/tpm2-software/tpm2-tss).
|
| 10 |
|
Andrey Marochko | f640b4b | 2020-12-09 12:36:43 -0800 | [diff] [blame] | 11 | ## Windows build ##
|
Andrey Marochko | daf5209 | 2018-12-14 22:22:15 -0800 | [diff] [blame] | 12 |
|
Andrey Marochko | f640b4b | 2020-12-09 12:36:43 -0800 | [diff] [blame] | 13 | Windows build is implemented as a Visual Studio 2017 solution. Before building it:
|
Andrey Marochko | daf5209 | 2018-12-14 22:22:15 -0800 | [diff] [blame] | 14 |
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 15 | * Setup one or both of the following underlying cryptographic libraries:
|
Andrey Marochko | d81005b | 2017-07-24 18:16:24 -0700 | [diff] [blame] | 16 |
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 17 | ### OpenSSL library ###
|
Andrey Marochko | d81005b | 2017-07-24 18:16:24 -0700 | [diff] [blame] | 18 |
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 19 | 1. Create `TPMCmd/lib` folder and place a static OpenSSL library (`libcrypto.lib`) built for the `x86` architecture there. For the `x64` architecture use the `TPMCmd/lib/x64` folder.
|
Brian Telfer | 5e0fa6b | 2018-02-22 00:08:02 +0000 | [diff] [blame] | 20 |
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 21 | The static libs can be either static libraries proper, or import libraries accompanying the corresponding DLLs. In the latter case you'll need to ensure that ther is a matching copy of the OpenSSL DLL in the standard Windows search path, so that it is available when you run the simulator executable (e.g. copy it into the same folder where `simulator.exe` is located).
|
Brian Telfer | 5e0fa6b | 2018-02-22 00:08:02 +0000 | [diff] [blame] | 22 |
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 23 | Recommended version of OpenSSL is `1.1.1d` or higher.
|
Andrey Marochko | 37055a6 | 2020-04-13 23:19:14 -0700 | [diff] [blame] | 24 |
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 25 | 2. Create `TPMCmd/OsslInclude/openssl` folder and copy there the contents of the `openssl/include/openssl` folder in the OpenSSL source tree used to build the OpenSSL library.
|
Brian Telfer | 5e0fa6b | 2018-02-22 00:08:02 +0000 | [diff] [blame] | 26 |
|
Andrey Marochko | f640b4b | 2020-12-09 12:36:43 -0800 | [diff] [blame] | 27 | If you enable SM{2,3,4} algorithms in `TpmProfile.h`, the build may fail because of missing `SM{2,3,4}.h` headers. In this case you will need to manually copy them over from OpenSSL’s `include/crypt` folder.
|
Brian Telfer | 5e0fa6b | 2018-02-22 00:08:02 +0000 | [diff] [blame] | 28 |
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 29 | 3. Build the solution with either Debug or Release as the active configuration.
|
Brian Telfer | 5e0fa6b | 2018-02-22 00:08:02 +0000 | [diff] [blame] | 30 |
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 31 | ### Wolfcrypt library (wolfSSL) ###
|
Brian Telfer | 5e0fa6b | 2018-02-22 00:08:02 +0000 | [diff] [blame] | 32 |
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 33 | 1. WolfSSL is included as a submodule. Initialize and update the submodule to fetch the project and checkout the appropriate commit.
|
Brian Telfer | 5e0fa6b | 2018-02-22 00:08:02 +0000 | [diff] [blame] | 34 |
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 35 | > git submodule init
|
| 36 | > git submodule update
|
Brian Telfer | 5e0fa6b | 2018-02-22 00:08:02 +0000 | [diff] [blame] | 37 |
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 38 | The current commit will point the minimum recommended version of wolfSSL. Moving to a more recent tag or commit should also be supported but might not be tested.
|
Brian Telfer | 5e0fa6b | 2018-02-22 00:08:02 +0000 | [diff] [blame] | 39 |
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 40 | 2. Build the solution with either WolfDebug or WolfRelease as the active configuration, either from inside the Visual Studio or with the following command line:
|
Brian Telfer | 5e0fa6b | 2018-02-22 00:08:02 +0000 | [diff] [blame] | 41 |
|
Andrey Marochko | fc98d14 | 2018-04-05 23:59:45 -0700 | [diff] [blame] | 42 | > msbuild TPMCmd\simulator.sln /p:Configuration=WolfDebug
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 43 |
|
| 44 | * If necessary, update the definitions of the following macros in the [VendorString.h](TPMCmd/tpm/include/VendorString.h) header: `MANUFACTURER`, `VENDOR_STRING_1`, `FIRMWARE_V1 and FIRMWARE_V2`
|
| 45 |
|
Andrey Marochko | daf5209 | 2018-12-14 22:22:15 -0800 | [diff] [blame] | 46 | ## Linux build
|
| 47 |
|
| 48 | Follows the common `./bootstrap && ./configure && make` convention.
|
| 49 |
|
Andrey Marochko | 9f79f0f | 2020-05-04 17:18:24 -0700 | [diff] [blame] | 50 | Note that autotools scripts require the following prerequisite packages: `autoconf-archive`, `pkg-config`, and sometimes `build-essential` and `automake`. Their absence is not automatically detected. The build also needs `gcc` and `libssl-dev` packages.
|
Andrey Marochko | bcad02c | 2020-10-16 16:01:56 -0700 | [diff] [blame] | 51 |
|
Andrey Marochko | f640b4b | 2020-12-09 12:36:43 -0800 | [diff] [blame] | 52 | Similarly to the Windows build, if you enable SM{2,3,4} algorithms in `TpmProfile.h`, the build may fail because of missing `SM{2,3,4}.h` headers. In this case you will need to manually copy them over from OpenSSL’s `include/crypt` folder.
|