Skip to content

Commit

Permalink
Moved Linux specific SOCKET definition from the auto-generated header…
Browse files Browse the repository at this point in the history
… to the .c files, and updated README with information about Linux build and a link to Travis-CI build status.
  • Loading branch information
amarochk committed Dec 15, 2018
1 parent 87668b2 commit daf5209
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
# MS TPM 2.0 Reference Implementation #

This is a Microsoft Visual Studio solution that contains reference implementation of the TPM 2.0 Specification by TCG available at https://trustedcomputinggroup.org/tpm-library-specification.
[![Build Status](https://travis-ci.org/Microsoft/ms-tpm-20-ref.svg?branch=master)](https://travis-ci.org/Microsoft/ms-tpm-20-ref)

See the TPMCmd/tpm/include/TpmTypes.h header for the exact revision/date of the TPM 2.0 specification issue, which the given source tree snapshot corresponds to.
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.

## Before building the solution ##
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.

1. Uncomment and update the definitions of the following macros in the TPMCmd/tpm/include/VendorString.h header:
## Visual Studio build ##

Before building the Visual Studio solution:

1. Uncomment and 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

2. Setup the cryptography platform the TPM will use for the underlying primitives:
2. Setup the underlying cryptographic library:

### OpenSSL library ###

1. Create TPMCmd/lib folder and place a static OpenSSL library (libeay32.lib or libcrypto.lib) there. This may be either complete static library, or import library accompanying the corresponding DLL. In the latter case you'll need to copy the OpenSSL DLL into the standard Windows search path, so that it was available when you run the simulator executable (e.g. copy it into the same folder where simulator.exe is located).
1. Create `TPMCmd/lib` folder and place a static OpenSSL library (`libeay32.lib` or `libcrypto.lib`) there. This may be either complete static library, or import library accompanying the corresponding DLL. In the latter case you'll need to copy the OpenSSL DLL into 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).

If you use libcrypto.lib, you'll need to either update "Linker|Input|Additional Dependencies" property of the Tpm project in the simulator solution or, alternatively, rename libcrypto.lib to libeay32.lib.
If you use `libcrypto.lib`, you'll need to either update `Linker|Input|Additional Dependencies` property of the Tpm project in the simulator solution or, alternatively, rename `libcrypto.lib` to `libeay32.lib`.

Recommended version of OpenSSL is 1.0.2d or higher.

2. Create TPMCmd/OsslInclude/openssl folder and copy there the contents of the openssl/include/openssl folder of the OpenSSL source tree used to build the static library used on the step 2).
2. Create `TPMCmd/OsslInclude/openssl` folder and copy there the contents of the `openssl/include/openssl` folder of the OpenSSL source tree used to build the static library used on the step 2).

If you use OpenSSL 1.1, you'll additionally need to:

- Copy the openssl/crypto/bn/bn_lcl.h header to the TPMCmd/OsslInclude/openssl folder;
- Create TPMCmd/OsslInclude/openssl/internal folder and copy there the contents of the openssl/crypto/include/internal folder (do not confuse it with the openssl/include/internal folder that need not be copied).
- Copy the `openssl/crypto/bn/bn_lcl.h` header to the `TPMCmd/OsslInclude/openssl` folder;
- Create `TPMCmd/OsslInclude/openssl/internal` folder and copy there the contents of the `openssl/crypto/include/internal` folder (do not confuse it with the openssl/include/internal folder that need not be copied).

3. Build the solution with either Debug or Release as the active configuration.

Expand All @@ -42,3 +46,9 @@ See the TPMCmd/tpm/include/TpmTypes.h header for the exact revision/date of the
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:

> msbuild TPMCmd\simulator.sln /p:Configuration=WolfDebug
## Linux build

Follows the common `./bootstrap && ./configure && make` convention.

Note that autotools scripts require the following prerequisite packages: `autoconf-archive`, `pkg-config`. Their absence is not automatically detected. The build also requires `libssl-dev` package to be installed.
4 changes: 0 additions & 4 deletions TPMCmd/Simulator/include/prototypes/Simulator_fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@

//** From TcpServer.c

#ifdef __unix__
typedef int SOCKET;
#endif

//*** PlatformServer()
// This function processes incoming platform requests.
BOOL
Expand Down
2 changes: 2 additions & 0 deletions TPMCmd/Simulator/src/TPMCmdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
#ifdef _MSC_VER
#include <windows.h>
#include <winsock.h>
#elif defined(__unix__)
typedef int SOCKET;
#endif

#include "Platform_fp.h"
Expand Down
1 change: 1 addition & 0 deletions TPMCmd/Simulator/src/TPMCmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <winsock.h>
#elif defined(__unix__)
#define _strcmpi strcasecmp
typedef int SOCKET;
#else
#error "Unsupported platform."
#endif
Expand Down

0 comments on commit daf5209

Please sign in to comment.