microsoft / ms-tpm-20-ref

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

Windows and Linux build fails #46

Closed mwyborski closed 4 years ago

mwyborski commented 4 years ago

Compiling on windows failed, because i haven't found a compatible libcrypto. Can you please point me to a version that is known to work?

Also compiling on Ubuntu 19.10 failed:

gcc -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   -o Simulator/src/tpm2-simulator Simulator/src/tpm2_simulator-TPMCmdp.o Simulator/src/tpm2_simulator-TPMCmds.o Simulator/src/tpm2_simulator-TcpServer.o  Platform/src/libplatform.a tpm/src/libtpm.a Platform/src/libplatform.a -lcrypto   
/usr/bin/ld: tpm/src/libtpm.a(libtpm_a-CryptSym.o): in function `CryptSymmetricEncrypt':
/home/marek/git/ms-tpm-20-ref/TPMCmd/tpm/src/crypt/CryptSym.c:190: undefined reference to `SM4_set_key'
/usr/bin/ld: /home/marek/git/ms-tpm-20-ref/TPMCmd/tpm/src/crypt/CryptSym.c:190: undefined reference to `SM4_encrypt'
/usr/bin/ld: tpm/src/libtpm.a(libtpm_a-CryptSym.o): in function `CryptSymmetricDecrypt':
/home/marek/git/ms-tpm-20-ref/TPMCmd/tpm/src/crypt/CryptSym.c:363: undefined reference to `SM4_set_key'
/usr/bin/ld: /home/marek/git/ms-tpm-20-ref/TPMCmd/tpm/src/crypt/CryptSym.c:363: undefined reference to `SM4_encrypt'
/usr/bin/ld: /home/marek/git/ms-tpm-20-ref/TPMCmd/tpm/src/crypt/CryptSym.c:358: undefined reference to `SM4_set_key'
/usr/bin/ld: /home/marek/git/ms-tpm-20-ref/TPMCmd/tpm/src/crypt/CryptSym.c:358: undefined reference to `SM4_decrypt'
/usr/bin/ld: tpm/src/libtpm.a(libtpm_a-CryptHash.o):/home/marek/git/ms-tpm-20-ref/TPMCmd/tpm/src/crypt/CryptHash.c:62: undefined reference to `sm3_init'
/usr/bin/ld: tpm/src/libtpm.a(libtpm_a-CryptHash.o):(.data.rel.ro+0x8): undefined reference to `sm3_update'
/usr/bin/ld: tpm/src/libtpm.a(libtpm_a-CryptHash.o):(.data.rel.ro+0x10): undefined reference to `sm3_final'
/usr/bin/ld: tpm/src/libtpm.a(libtpm_a-CryptCmac.o): in function `CryptCmacData':
/home/marek/git/ms-tpm-20-ref/TPMCmd/tpm/src/crypt/CryptCmac.c:104: undefined reference to `SM4_set_key'
/usr/bin/ld: /home/marek/git/ms-tpm-20-ref/TPMCmd/tpm/src/crypt/CryptCmac.c:104: undefined reference to `SM4_encrypt'
/usr/bin/ld: tpm/src/libtpm.a(libtpm_a-CryptCmac.o): in function `CryptCmacEnd':
/home/marek/git/ms-tpm-20-ref/TPMCmd/tpm/src/crypt/CryptCmac.c:144: undefined reference to `SM4_set_key'
/usr/bin/ld: /home/marek/git/ms-tpm-20-ref/TPMCmd/tpm/src/crypt/CryptCmac.c:144: undefined reference to `SM4_encrypt'
collect2: error: ld returned 1 exit status
make: *** [Makefile:2174: Simulator/src/tpm2-simulator] Fehler 1
amarochk commented 4 years ago

1.1.1d or any stable 1.1.1 version should work. I've updated readme.md with OpenSSL build instructions.

As for the Linux, what is the value of OPENSSL_VERSION_NUMBER? Most likely the binary OpenSSL module was built with no SM support, but the opensslconf.h does not have OPENSSL_NO_SM4...

You can also disable SM4 in the reference implementation by setting ALG_SM4 to ALG_NO in TpmProfile.h.

mwyborski commented 4 years ago

@amarochk thank you very much for your help!

I was able to compile it now on Linux.