(转)TPM笔记(2)--TPM安装手册
| 分类: 安全 |
判断机器上是否有TPM芯片的简单方法
查看BIOS-Security中是否有TPM设置选项。
实验环境:Ubuntu 11.10 Linux Kernel 3.0.0
软件包准备:
(两条重要的命令,”apt-get install”, “apt-cache search”)
trousers-0.3.7.tar.gz(必备)
tpm-tools-1.3.5.tar.gz(必备,主要用于tpm模拟测试)
下载链接:http://sourceforge.net/projects/trousers/files/
tpmmanager-0.8.1.tar.gz(可选,测试tpm)
下载链接:http://sourceforge.net/projects/tpmmanager/files/
1.装gmp-4.2.2
#sudo apt-get install libgmp10 libgmp-dev
3.安装trousers(TSS软件栈)
(养成好的习惯,安装之前阅读README和INSTALL文件)
#sh bootstrap.sh
很奇怪的是最新版的trousers竟然没有bootstrap.sh这个文件,如果不使用这个文件,直接configure会出错,可以直接从旧版本的trousers中拷一个来用。
在bootstrap.sh运行时,可能会显示缺少某个程序,如缺少autopoint,则使用sudo apt-get install autopoint即可解决,同理其他。
在configure之前,修改configure文件,删除其中所有的-Werror字符串,其实只有一处.
#configure
#sudo
make
#sudo make install
检查trousers是否安装成功,需要安装完成后需要启动tpm驱动和运行tcs daemon
#sudo modprobe tpm_tis
也可以atmel/infineon等具体厂商驱动,使用lsmod查看驱动模块是否加载成功(#modprobe tpm_infineon)
#sudo tcsd
start
#ps-e| grep tcsd检查守护进程是否启动
http://blog.chinaunix.net/attachment/201202/16/23757972_13293873791vS8.png
图1
4.装tpm-tools
#sh bootstrap.sh
在configure之前,修改configure文件,删除其中所有的-Werror字符串,其实只有一处
#./configure
# make
#sudo make install
现在就可以通过tpm-tools提供的命令检查TPM的模拟环境。进入tpm-tools-1.3.5/src/tpm_mgmt/目录下运行命令
(在运行之前记得安装驱动,modprobe tpm_tis; sudo tcsd start)
#./tpm_version
#./tpm_getpubek
#./tpm_takeownership
如果都成功表明TPM模拟环境已经完全构建成功了。
http://blog.chinaunix.net/attachment/201202/16/23757972_1329387564Nj35.png
图2
5.安装tpmmanager 0.8.1
其实tpmmanager可装可不装,主要是它提供QT界面可以直观查看和管理TPM而已,比较方便。tpmmanager-0.8安装需要QT支持,需要安装qt4-qmake。但是make过程会出现缺少uic-qt4 command not found,还需要安装libqt4-dev。编译安装过程
#cd tpmmanager-0.8
#qmake
–v
#qmake
#make
(make的过程提示错误,src/TPMManager.cxx:412:47:error: can not call constructor ‘QUrl::Qurl’ directly[-fpermissive],如果出现了同样的错误,打开这个文件,修改TPMManager.cxx 412行,将
QUrl myURL
= QUrl::QUrl(url, QUrl::strictMode)修改为QUrl myURL =
QUrl(url,
QUrl::strictMode)
# install bin/tpmmanager /usr/local/bin
运行tpmmanager
#tpmmanager
除此之外还可以安装tpm openssl engine等工具,这样就能够提供更多的操作方式和开发接口。
http://blog.chinaunix.net/attachment/201202/16/23757972_1329387572POMl.png
图3
http://blog.chinaunix.net/attachment/201202/16/23757972_132938757842nx.png
图4
http://blog.chinaunix.net/attachment/201202/16/23757972_1329387582cBGW.png
图5
http://blog.chinaunix.net/attachment/201202/16/23757972_1329387589LUuG.png
图6
http://blog.chinaunix.net/attachment/201202/16/23757972_1329387593KYUu.png
图7
TPM
#include
#include
#include "trousers/tss.h"
#define TPMMAX 4096
int TPM_Transmit(unsigned char * blob){
unsigned int tpmfp, len;
printf("could not open /dev/tpm0\n");
exit(-1);
};
size = ntohl (*(int *)&blob[2]);
len = write(tpmfp, blob, size);
len = read(tpmfp, blob,TPMMAX);
for(i = 0; i< len; i++) {
printf("\n");
close(tpmfp);
return len;
}
int TPM_Reset() {
unsigned char blob[TPMMAX] = {
0, 193,
return (TPM_Transmit(blob));
}
int TPM_PcrRead(int pcrindex){
0, 0, 0, pcrindex
}
int TPM_Extend(int pcrindex){
0, 0, 0, 34,
0, 0, 0, 20,
0, 0, 0, pcrindex ,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1
}
int TPM_SHA1Start(){
0, 0, 0, 10,
0, 0, 0, 160,
}
int TPM_SHA1Complete(){
0, 193,
0, 0, 0, 15,
0, 0, 0, 162,
0, 0, 0, 1,
}
int main(){
}
#gcc -o test test.c
#./test
出现错误:
#fuser /dev/tpm0
发现有个进程在用它,
http://blog.chinaunix.net/attachment/201202/16/23757972_13293875988873.png

加载中…