加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

(转)TPM笔记(2)--TPM安装手册

(2013-11-30 09:04:17)
分类: 安全
转自: http://blog.chinaunix.net/uid-23757972-id-3074677.html

在带有TPM的DELL机器上,安装TCG软件栈(TSS)的方法。

判断机器上是否有TPM芯片的简单方法

查看BIOS-Security中是否有TPM设置选项。

 

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.安装trousersTSS软件栈)

(养成好的习惯,安装之前阅读READMEINSTALL文件)

#sh bootstrap.sh

很奇怪的是最新版的trousers竟然没有bootstrap.sh这个文件,如果不使用这个文件,直接configure会出错,可以直接从旧版本的trousers中拷一个来用。

bootstrap.sh运行时,可能会显示缺少某个程序,如缺少autopoint,则使用sudo apt-get install autopoint即可解决,同理其他。

configure之前,修改configure文件,删除其中所有的-Werror字符串,其实只有一处.

#configure

#sudo make            #不用sudo貌似会出问题?

#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    #查看ek公钥

#./tpm_takeownership      #获取owner

如果都成功表明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    #查看qt版本,如果没有,apt-get install qt4-qmake

#qmake

#make

(make的过程提示错误,src/TPMManager.cxx412:47error: 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

 

 

 下面是一个小的测试程序

 为了测试一下接口,写了以下程序test.c来验证:

TPM 测试程序:

#include
#include
#include "trousers/tss.h"
#define TPMMAX 4096
int TPM_Transmit(unsigned char * blob){
unsigned int tpmfp, len;
 int i, size;
 tpmfp = open("/dev/tpm0", O_RDWR);
 if(tpmfp < 0){
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("x ", blob[i]);
 }
printf("\n");
close(tpmfp);
return len;
}
int TPM_Reset() {
unsigned char blob[TPMMAX] = {
0, 193,
 0, 0, 0, 10, 0,
 0, 0, 90
 };
return (TPM_Transmit(blob));
}
int TPM_PcrRead(int pcrindex){
 unsigned char blob[TPMMAX] = {
 0, 193,
 0, 0, 0, 14,
 0, 0, 0, 21,
0, 0, 0, pcrindex
 };

 return (TPM_Transmit(blob));
}
int TPM_Extend(int pcrindex){
 unsigned char blob[TPMMAX] = {
 0, 193,
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
 };
 return (TPM_Transmit(blob));
}
int TPM_SHA1Start(){
 unsigned char blob[TPMMAX] = {
 0, 193,
0, 0, 0, 10,
0, 0, 0, 160,
 };
 return (TPM_Transmit(blob));
}
int TPM_SHA1Complete(){
 unsigned char blob[TPMMAX] = {
0, 193,
0, 0, 0, 15,
0, 0, 0, 162,
0, 0, 0, 1,
 1
 };
 return (TPM_Transmit(blob));
}
int main(){
 TPM_PcrRead(0);
 TPM_Extend(0);
 TPM_Reset();
 TPM_SHA1Start();
 TPM_SHA1Complete();
}

gcc -o test test.c

#./test

出现错误: Device or Resource busy

fuser /dev/tpm0

发现有个进程在用它,  kill ~

http://blog.chinaunix.net/attachment/201202/16/23757972_13293875988873.png

 

 

 


0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有