microsoft / ms-tpm-20-ref

Reference implementation of the TCG Trusted Platform Module 2.0 specification.
Other
333 stars 133 forks source link

Build fails #101

Closed kvijay1918 closed 11 months ago

kvijay1918 commented 12 months ago

latest source build is failing in linux:

TPMCmd]# make
gcc -DPACKAGE_NAME=\"ms-tpm-20-ref\" -DPACKAGE_TARNAME=\"ms-tpm-20-ref\" -DPACKAGE_VERSION=\"0.1\" -DPACKAGE_STRING=\"ms-tpm-20-ref\ 0.1\" -DPACKAGE_BUGREPORT=\"https://github.com/microsoft/ms-tpm-20-ref/issues\" -DPACKAGE_URL=\"https://github.com/microsoft/ms-tpm-20-ref\" -DPACKAGE=\"ms-tpm-20-ref\" -DVERSION=\"0.1\" -DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -DHASH_LIB=Ossl -DSYM_LIB=Ossl -DMATH_LIB=Ossl -I.    -std=gnu11 -Werror -Wall -Wformat-security -fstack-protector-all -fPIC -Wno-error=empty-body -Wno-error=expansion-to-defined -Wno-error=parentheses -Wno-error=pointer-to-int-cast -Wno-error=missing-braces -Wno-error=unused-result -I ./Platform/include -I ./Platform/include/prototypes -I ./tpm/include -I ./tpm/include/prototypes -I ./Simulator/include -I ./Simulator/include/prototypes  -pthread -g -O2 -MT Simulator/src/tpm2_simulator-TPMCmdp.o -MD -MP -MF Simulator/src/.deps/tpm2_simulator-TPMCmdp.Tpo -c -o Simulator/src/tpm2_simulator-TPMCmdp.o `test -f 'Simulator/src/TPMCmdp.c' || echo './'`Simulator/src/TPMCmdp.c
mv -f Simulator/src/.deps/tpm2_simulator-TPMCmdp.Tpo Simulator/src/.deps/tpm2_simulator-TPMCmdp.Po
gcc -DPACKAGE_NAME=\"ms-tpm-20-ref\" -DPACKAGE_TARNAME=\"ms-tpm-20-ref\" -DPACKAGE_VERSION=\"0.1\" -DPACKAGE_STRING=\"ms-tpm-20-ref\ 0.1\" -DPACKAGE_BUGREPORT=\"https://github.com/microsoft/ms-tpm-20-ref/issues\" -DPACKAGE_URL=\"https://github.com/microsoft/ms-tpm-20-ref\" -DPACKAGE=\"ms-tpm-20-ref\" -DVERSION=\"0.1\" -DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -DHASH_LIB=Ossl -DSYM_LIB=Ossl -DMATH_LIB=Ossl -I.    -std=gnu11 -Werror -Wall -Wformat-security -fstack-protector-all -fPIC -Wno-error=empty-body -Wno-error=expansion-to-defined -Wno-error=parentheses -Wno-error=pointer-to-int-cast -Wno-error=missing-braces -Wno-error=unused-result -I ./Platform/include -I ./Platform/include/prototypes -I ./tpm/include -I ./tpm/include/prototypes -I ./Simulator/include -I ./Simulator/include/prototypes  -pthread -g -O2 -MT Simulator/src/tpm2_simulator-TPMCmds.o -MD -MP -MF Simulator/src/.deps/tpm2_simulator-TPMCmds.Tpo -c -o Simulator/src/tpm2_simulator-TPMCmds.o `test -f 'Simulator/src/TPMCmds.c' || echo './'`Simulator/src/TPMCmds.c
mv -f Simulator/src/.deps/tpm2_simulator-TPMCmds.Tpo Simulator/src/.deps/tpm2_simulator-TPMCmds.Po
gcc -DPACKAGE_NAME=\"ms-tpm-20-ref\" -DPACKAGE_TARNAME=\"ms-tpm-20-ref\" -DPACKAGE_VERSION=\"0.1\" -DPACKAGE_STRING=\"ms-tpm-20-ref\ 0.1\" -DPACKAGE_BUGREPORT=\"https://github.com/microsoft/ms-tpm-20-ref/issues\" -DPACKAGE_URL=\"https://github.com/microsoft/ms-tpm-20-ref\" -DPACKAGE=\"ms-tpm-20-ref\" -DVERSION=\"0.1\" -DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -DHASH_LIB=Ossl -DSYM_LIB=Ossl -DMATH_LIB=Ossl -I.    -std=gnu11 -Werror -Wall -Wformat-security -fstack-protector-all -fPIC -Wno-error=empty-body -Wno-error=expansion-to-defined -Wno-error=parentheses -Wno-error=pointer-to-int-cast -Wno-error=missing-braces -Wno-error=unused-result -I ./Platform/include -I ./Platform/include/prototypes -I ./tpm/include -I ./tpm/include/prototypes -I ./Simulator/include -I ./Simulator/include/prototypes  -pthread -g -O2 -MT Simulator/src/tpm2_simulator-TcpServer.o -MD -MP -MF Simulator/src/.deps/tpm2_simulator-TcpServer.Tpo -c -o Simulator/src/tpm2_simulator-TcpServer.o `test -f 'Simulator/src/TcpServer.c' || echo './'`Simulator/src/TcpServer.c
Simulator/src/TcpServer.c:565:6: error: conflicting types for ‘ReadVarBytes’
 bool ReadVarBytes(SOCKET s, char* buffer, uint32_t* BytesReceived, uint32_t MaxLen)
      ^~~~~~~~~~~~
In file included from Simulator/src/TcpServer.c:75:
./Simulator/include/prototypes/Simulator_fp.h:96:6: note: previous declaration of ‘ReadVarBytes’ was here
 bool ReadVarBytes(SOCKET s, char* buffer, uint32_t* BytesReceived, int MaxLen);
      ^~~~~~~~~~~~
make: *** [Makefile:5497: Simulator/src/tpm2_simulator-TcpServer.o] Error 1

Fix this in your source. I have fixed myself this locally, built and generated tpm2-simulator by running make install-exec

when running this executable,

root@host:/usr/local/bin# ./tpm2-simulator
LIBRARY_COMPATIBILITY_CHECK is ON
TPM command server listening on port 2321
Platform server listening on port 2322

My question here is, as it is Linux machine and running this simulator on linux, will this simulator create /dev/tpm0 and /dev/tpmrm0 files to run and work with tpm2 commands??

I don't see these files created. How is this simulator working and how to confirm this??

in one terminal I have run this executable and opened another terminal and ran, tpm2_pcrread command which has to show pcr data,

tpm2_pcrread
ERROR:tcti:src/tss2-tcti/tcti-device.c:439:Tss2_Tcti_Device_Init() Failed to open device file /dev/tpmrm0: No such file or directory
WARNING:tcti:src/tss2-tcti/tctildr.c:62:tcti_from_init() TCTI init for function 0x7fabcab22fb0 failed with a000a
WARNING:tcti:src/tss2-tcti/tctildr.c:92:tcti_from_info() Could not initialize TCTI named: tcti-device
ERROR:tcti:src/tss2-tcti/tctildr-dl.c:150:tcti_from_file() Could not initialize TCTI file: libtss2-tcti-device.so.0
ERROR:tcti:src/tss2-tcti/tcti-device.c:439:Tss2_Tcti_Device_Init() Failed to open device file /dev/tpm0: No such file or directory
WARNING:tcti:src/tss2-tcti/tctildr.c:62:tcti_from_init() TCTI init for function 0x7fabcab22fb0 failed with a000a
WARNING:tcti:src/tss2-tcti/tctildr.c:92:tcti_from_info() Could not initialize TCTI named: tcti-device
ERROR:tcti:src/tss2-tcti/tctildr-dl.c:150:tcti_from_file() Could not initialize TCTI file: libtss2-tcti-device.so.0
WARNING:esys:src/tss2-esys/api/Esys_GetCapability.c:303:Esys_GetCapability_Finish() Received TPM Error
ERROR:esys:src/tss2-esys/api/Esys_GetCapability.c:107:Esys_GetCapability() Esys Finish ErrorCode (0x00000100)
ERROR: Esys_GetCapability(0x100) - tpm:error(2.0): TPM not initialized by TPM2_Startup or already initialized
ERROR: Unable to run tpm2_pcrread

it fails because there is no /dev/tpm0 file. But in server log,

root@ubuntu-20-04-cnskc-testing:/usr/local/bin# ./tpm2-simulator
LIBRARY_COMPATIBILITY_CHECK is ON
TPM command server listening on port 2321
Platform server listening on port 2322

**Client accepted
Client accepted**
Platform server listening on port 2322
TPM command server listening on port 2321

Getting messages like, Client accepted.