安装Centos 的时候,选择自定义,把除虚拟化以外的全部软件都装上,这样就可以避免在安装CMake和TPM emulator出现下面的错误:
#./configure
no acceptable C compiler found in $PATH
#make
make: Command not found
编译器GCC G++当然是必须要装的。一般情况下,只要安装的内核是2.6.18的,系统安装好后,直接安装TPM emulator 就可以了,不需要重新用make menuconfig来重新编译内核,因为这个内核默认支持TPM。
根据tpm emulator专业网站(http://tpm-emulator.berlios.de/documentation.html)第一段的描述:
The compilation and installation of the TPM emulator package is based on the CMake build environment (version 2.6 or newer) and requires that the GNU MP library (version 4.0 or newer) is properly installed on your system. A working MinGW compiler suite is further required on Windows.
CMake需要在安装tpm emulator之前自行下载安装。GMP是已经安装系统时安装好了的。CMake下载地址:http://www.piaodown.com/soft/19650.htm
TPM emulator安装过程可参见: http://blog.chinaunix.net/u3/96833/showart_1932475.html
1.tpmd –用户空间的deamon实现TPM模拟,通过Socket实现访问
2.tpmd_dev –内核模块提供模拟硬件/dev/tpm,用于后台的兼容性和前台命令接收到tpmd
3.tddl—tpm驱动库,用与提供模块接口。
注:
#tpmd [-d] [-f][-h] [start mode]
其中[-d]: enable debug mode
[-f]:force the application to run in the forground 会显示你发送给tpmd的命令
[-h]:print this help message 打印帮助消息
Start mode:’clear’清除之前的状态, ’save’默认情况下打开之前的状态, ‘deactivate’无效
初始化
#tpmd deactivated //make the initialized TPM stopping working
#killall tpmd
#tpmd clear //clear the before state use,because the before exit may //wrong
/*
可能会遇见socket忙碌问题,导致命令不可用,此时需要去早var目录下的tpm文件夹内,把当前的socket文件删除。然后重新执行命令,会重新初始化socket
*/
#rm /var/run/tpm/tpmd_socket/:0
启动虚拟TPM
#modprobe tpmd_dev // add the module into kernel
//(if show FATAL: Module tpmd_dev not found,run:depmod -a)
/*
使用tddl函数接口编程,建议在模式选用时用参数f,这样你就可以看到对应的函数执行时具体会使用哪个tpm命令,便于理解。
*/
#tpmd -f -d (tpmd -h查看启动参数)
……
/tmp/tpm_emulator-0.7/tpm/tpm_testing.c:210: Debug: tpm_rsa_encrypt(RSA_ES_PKCSV15)
/tmp/tpm_emulator-0.7/tpm/tpm_testing.c:214: Debug: tpm_rsa_decrypt(RSA_ES_PKCSV15)
/tmp/tpm_emulator-0.7/tpm/tpm_testing.c:218: Debug: verify plain text
/tmp/tpm_emulator-0.7/tpm/tpm_testing.c:221: Debug: tpm_rsa_encrypt(RSA_ES_OAEP_SHA1)
/tmp/tpm_emulator-0.7/tpm/tpm_testing.c:225: Debug: tpm_rsa_decrypt(RSA_ES_OAEP_SHA1)
/tmp/tpm_emulator-0.7/tpm/tpm_testing.c:229: Debug: verify plain text
/tmp/tpm_emulator-0.7/tpm/tpm_testing.c:261: Info: Self-Test succeeded
/tmp/tpm_emulator-0.7/tpm/tpm_startup.c:43: Info: TPM_Startup(2)
/tmp/tpm_emulator-0.7/tpmd/unix/tpmd.c:401: Debug: waiting for connections...
/tmp/tpm_emulator-0.7/tpmd/unix/tpmd.c:401: Debug: waiting for connections...
/tmp/tpm_emulator-0.7/tpmd/unix/tpmd.c:401: Debug: waiting for connections...
/tmp/tpm_emulator-0.7/tpmd/unix/tpmd.c:401: Debug: waiting for connections...
......
It’s right, means waiting for your connection to use the modue TPM!!