Very frustrating, I previously tried to install trousers directly using yum, which resulted in the TPM_E_NOAUTH issue. Now, after compiling trousers-0.3.15, I can conduct experiments normally. It is still unclear which package caused the issue, so it is essential to ensure the system is completely new.
Basic Environment Preparation#
The experimental environment is based on CentOS7. Ensure your system is completely new; otherwise, there may be unclear package dependencies or conflicts.
-
Update the kernel
yum update -y
-
Install the basic development group related packages
yum groupinstall "Development Tools"
-
Install the required software packages
yum install -y automake autoconf pkgconfig libtool gtk2-devel openssl-devel glibc-devel gmp-devel cmake psmisc
-
First, upload tc.tgz, then extract it and enter the tc directory
[root@localhost ~]# ls anaconda-ks.cfg tc.tgz [root@localhost ~]# tar -xzf tc.tgz [root@localhost ~]# ls anaconda-ks.cfg tc tc.tgz [root@localhost ~]# cd tc [root@localhost tc]# ls tpm-emulator trousers-0.3.15 trusted-computing-projectv0.3
Compile tpm-emulator#
-
The directory structure of tpm-emulator is as follows:
[root@localhost tc]# cd tpm-emulator/ [root@localhost tpm-emulator]# ls AUTHORS build.bat build.sh ChangeLog CMakeLists.txt config.h.in crypto mtm README tddl tpm tpmd tpmd_dev
-
Create a build directory and enter it, then use CMake to generate the Makefile
[root@localhost tpm-emulator]# cd build [root@localhost build]# ls [root@localhost build]# cmake .. -- The C compiler identification is GNU 4.8.5 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Configuring done -- Generating done -- Build files have been written to: /root/tc/tpm-emulator/build
-
Compile and install tpm-emulator
[root@localhost build]# make -j Output omitted... [root@localhost build]# make install [ 58%] Built target tpm [ 80%] Built target mtm [ 90%] Built target tpm_crypto [ 92%] Built target tddl [ 94%] Built target tddl_static [ 96%] Built target test_tddl [ 98%] Built target tpmd_dev [100%] Built target tpmd Install the project... -- Install configuration: "" -- Installing: /usr/local/lib/libtddl.so.1.2.0.7 -- Installing: /usr/local/lib/libtddl.so.1.2 -- Installing: /usr/local/lib/libtddl.so -- Installing: /usr/local/lib/libtddl.a -- Installing: /usr/local/include/tddl.h Can't read private key -- Installing: /usr/local/bin/tpmd -- Removed runtime path from "/usr/local/bin/tpmd" [root@localhost build]# modprobe tpmd_dev
-
Start tpm-emulator
[root@localhost build]# tpmd -f tpmd.c:390: Info: starting TPM Emulator daemon (1.2.0.7-475) tpmd.c:93: Info: parsing options tpmd.c:164: Info: no startup mode was specified; assuming 'clear' tpmd.c:198: Info: installing signal handlers tpmd.c:295: Info: starting main loop tpmd.c:265: Info: initializing socket /var/run/tpm/tpmd_socket:0 tpm_emulator_extern.c:101: Info: _tpm_extern_init() tpm_data.c:120: Info: initializing TPM data to default values tpm_startup.c:29: Info: TPM_Init() tpm_testing.c:243: Info: TPM_SelfTestFull() tpm_testing.c:261: Info: Self-Test succeeded tpm_startup.c:43: Info: TPM_Startup(1)
Compile trousers#
-
Open a new terminal, enter the trousers directory, and generate
configure
usingbootstrap
[root@localhost trousers-0.3.15]# sh bootstrap.sh + aclocal + libtoolize --force -c libtoolize: putting auxiliary files in `.'. libtoolize: copying file `./ltmain.sh' libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.ac and libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree. libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am. + automake --add-missing -c --foreign + autoconf
-
Generate Makefile using
configure
[root@localhost trousers-0.3.15]# ./configure Output omitted...
-
Compile and install trousers
[root@localhost trousers-0.3.15]# make -j Output omitted... [root@localhost trousers-0.3.15]# make install Output omitted...
-
Confirm the installation was successful by checking if the directory
/usr/local/var/lib/tpm/
exists[root@localhost trousers-0.3.15]# ls /usr/local/var/lib/tpm/
-
Start trousers
[root@localhost trousers-0.3.15]# tcsd -e -f TCSD TDDL ioctl: (25) Inappropriate ioctl for device TCSD TDDL Falling back to Read/Write device support. TCSD trousers 0.3.15: TCSD up and running.
Meanwhile, the previous terminal running tpm-emulator should have output like the following:
tpm_startup.c:43: Info: TPM_Startup(1) tpm_capability.c:697: Info: TPM_GetCapability() tpm_cmd_handler.c:4084: Info: TPM command succeeded tpm_capability.c:697: Info: TPM_GetCapability() tpm_cmd_handler.c:4084: Info: TPM command succeeded tpm_capability.c:697: Info: TPM_GetCapability() tpm_cmd_handler.c:4084: Info: TPM command succeeded tpm_capability.c:697: Info: TPM_GetCapability() tpm_cmd_handler.c:4084: Info: TPM command succeeded tpm_capability.c:697: Info: TPM_GetCapability() tpm_cmd_handler.c:4084: Info: TPM command succeeded tpm_capability.c:697: Info: TPM_GetCapability() tpm_cmd_handler.c:4084: Info: TPM command succeeded
Verify the Installation Environment#
-
Open a new terminal, enter the trusted-computing-projectv0.3 directory, run
make clean
to clear previous builds, then compile. Warnings are normal; as long as there are no errors, it is fine.[root@localhost trusted-computing-projectv0.3]# make clean Output omitted... [root@localhost trusted-computing-projectv0.3]# make Output omitted...
-
Go to the init directory, take ownership, and create a migration key
[root@localhost trusted-computing-projectv0.3]# cd init/ [root@localhost init]# ls create_mig_key create_mig_key.c Makefile Tspi_TPM_TakeOwnership01 Tspi_TPM_TakeOwnership01.c [root@localhost init]# ./Tspi_TPM_TakeOwnership01 -v 1.2 <<<test_start>>> Testing Tspi_TPM_TakeOwnership01 TESTSUITE_OWNER_SECRET:(null) TESTSUITE_SRK_SECRET:(null) 1 PASS : Tspi_TPM_TakeOwnership01 returned (0) TSS_SUCCESS Cleaning up Tspi_TPM_TakeOwnership01 <<<end_test>>> [root@localhost init]# ./create_mig_key -v 1.2 Please input Migratable key's migration secret Enter PIN: Verifying - Verify PIN: success
-
Go to the SealUnseal directory, test seal and unseal; being able to unseal indicates that the environment is fine.
[root@localhost init]# cd ../SealUnseal/ [root@localhost SealUnseal]# ls extend extend.c hex-out.h Makefile seal seal.c sealedData seal_file seal_file.c test test.c unseal unseal.c [root@localhost SealUnseal]# ./seal -v 1.2 1 2 3 4 5 6 7 EncDataBlob: 00000000| 01 01 00 00 00 00 00 2c 00 02 00 80 c6 58 2c 81 .......,.....X,. 00000010| 00 7f 85 4e d3 87 3c 59 63 7a 01 8a 44 19 63 97 ...N..<Ycz..D.c. 00000020| c6 58 2c 81 00 7f 85 4e d3 87 3c 59 63 7a 01 8a .X,....N..<Ycz.. 00000030| 44 19 63 97 00 00 01 00 5d ee a6 34 cd e3 b2 e8 D.c.....]..4.... 00000040| a1 be ed 5f a6 20 67 86 17 ee fb 7c 40 2e 63 9a ..._. g....|@.c. 00000050| 76 12 6b d3 2e e6 7c bb 2f 77 3d af 07 c8 19 36 v.k...|./w=....6 00000060| d5 ef c6 74 5d 8e f0 8a 98 f2 5e 8c 22 f8 70 02 ...t].....^.".p. 00000070| 4c ca a3 4a 54 cd bf 39 1a 92 a9 2c c7 2b 96 28 L..JT..9...,.+.( 00000080| de 6e 7a f9 b3 36 62 e0 f5 c3 42 4b 74 0c 6d 6d .nz..6b...BKt.mm 00000090| 4f 65 33 1f 99 56 8e 5b 76 97 56 6e 68 17 f9 c1 Oe3..V.[v.Vnh... 000000a0| 0b 6a 81 7e dc 10 58 ed 8a 9a 03 5e e7 28 dc 87 .j.~..X....^.(.. 000000b0| c7 ba d3 95 d1 26 2c fe 8b 71 73 5b 27 23 5c b7 .....&,..qs['#\. 000000c0| 8b c9 1e f1 b8 52 ac 2b b9 a3 08 2c f8 c5 e4 95 .....R.+...,.... 000000d0| ba f2 20 ee 49 ee a7 6a 34 8d a1 b9 a9 e7 25 d8 .. .I..j4.....%. 000000e0| 28 14 58 d8 ab 47 4e dd 0a 8a 25 a4 b4 b7 69 f8 (.X..GN...%...i. 000000f0| 85 70 4c 7d af 10 12 56 42 2a e3 1d be 05 8f ff .pL}...VB*...... 00000100| 41 7c 2b 53 0c d6 f5 0f 61 6a c8 65 33 5b 02 3e A|+S....aj.e3[.> 00000110| d4 b0 30 7d 03 b0 b4 0a 09 12 18 ad 10 73 bd 83 ..0}.........s.. 00000120| 9f 2d 5e 46 57 37 1c 00 29 16 4b 44 68 e4 f2 95 .-^FW7..).KDh... 00000130| 9b 53 fe 0b 32 f1 48 78 .S..2.Hx Success [root@localhost SealUnseal]# ./unseal -v 1.2 Sealed data: 00000000| 01 01 00 00 00 00 00 2c 00 02 00 80 c6 58 2c 81 .......,.....X,. 00000010| 00 7f 85 4e d3 87 3c 59 63 7a 01 8a 44 19 63 97 ...N..<Ycz..D.c. 00000020| c6 58 2c 81 00 7f 85 4e d3 87 3c 59 63 7a 01 8a .X,....N..<Ycz.. 00000030| 44 19 63 97 00 00 01 00 5d ee a6 34 cd e3 b2 e8 D.c.....]..4.... 00000040| a1 be ed 5f a6 20 67 86 17 ee fb 7c 40 2e 63 9a ..._. g....|@.c. 00000050| 76 12 6b d3 2e e6 7c bb 2f 77 3d af 07 c8 19 36 v.k...|./w=....6 00000060| d5 ef c6 74 5d 8e f0 8a 98 f2 5e 8c 22 f8 70 02 ...t].....^.".p. 00000070| 4c ca a3 4a 54 cd bf 39 1a 92 a9 2c c7 2b 96 28 L..JT..9...,.+.( 00000080| de 6e 7a f9 b3 36 62 e0 f5 c3 42 4b 74 0c 6d 6d .nz..6b...BKt.mm 00000090| 4f 65 33 1f 99 56 8e 5b 76 97 56 6e 68 17 f9 c1 Oe3..V.[v.Vnh... 000000a0| 0b 6a 81 7e dc 10 58 ed 8a 9a 03 5e e7 28 dc 87 .j.~..X....^.(.. 000000b0| c7 ba d3 95 d1 26 2c fe 8b 71 73 5b 27 23 5c b7 .....&,..qs['#\. 000000c0| 8b c9 1e f1 b8 52 ac 2b b9 a3 08 2c f8 c5 e4 95 .....R.+...,.... 000000d0| ba f2 20 ee 49 ee a7 6a 34 8d a1 b9 a9 e7 25 d8 .. .I..j4.....%. 000000e0| 28 14 58 d8 ab 47 4e dd 0a 8a 25 a4 b4 b7 69 f8 (.X..GN...%...i. 000000f0| 85 70 4c 7d af 10 12 56 42 2a e3 1d be 05 8f ff .pL}...VB*...... 00000100| 41 7c 2b 53 0c d6 f5 0f 61 6a c8 65 33 5b 02 3e A|+S....aj.e3[.> 00000110| d4 b0 30 7d 03 b0 b4 0a 09 12 18 ad 10 73 bd 83 ..0}.........s.. 00000120| 9f 2d 5e 46 57 37 1c 00 29 16 4b 44 68 e4 f2 95 .-^FW7..).KDh... 00000130| 9b 53 fe 0b 32 f1 48 78 .S..2.Hx Unsealed Data: 00000000| 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 0123456789ABCDEF 00000010| 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 0123456789ABCDEF Success
Others#
Regarding the various issues with tpmd and tcsd, it is generally because tpmd has not been cleaned up properly. Doing the following usually resolves the issue:
[root@localhost build]# tpmd deactivated
[root@localhost build]# killall tpmd
[root@localhost build]# tpmd clear
[root@localhost build]# tpmd deactivated
My blog will soon be synchronized to Tencent Cloud + Community, inviting everyone to join: https://cloud.tencent.com/developer/support-plan?invite_code=owdvmxq0iwh9