可信平台模块TPM(Trusted Platform Module)是一种植于计算机内部为计算机提供可信根的芯片。该芯片的规格由可信计算组(Trusted Computing Group)来制定。 中国国内研究的TCM(trusted cryptography module,可信密码模块),与之对应。
文献
google开发的一个tpm开源工具。非常好的文档和测试用例。可在网页直接测试。
- https://google.github.io/tpm-js
微软相关介绍
- https://docs.microsoft.com/en-us/windows/security/information-protection/tpm/trusted-platform-module-top-node
相关书籍
Intel TPM2 Software Stack (TSS)等安装使用
- tpm2-tss是根据TCG(Trusted Computing Group)组织定义的TPM2.0的一比一实现。
- tpm2-abrmd是实现了TPM2 access broker (TAB) & Resource Manager (RM)的守护进程
- tpm2-tools是命令行工具
检查依赖包:包的依赖关系
tpm2-tools version | tpm2-tss version | tpm2-abrmd version |
---|---|---|
master | master | master |
4.2 | >=2.4.0 | >=2.3.1 |
安装TPM工具
具体安装过程及依赖包的安装可参考
- 安装tss包 https://github.com/tpm2-software/tpm2-tss/blob/master/INSTALL.md
- 安装abrmd包 https://github.com/tpm2-software/tpm2-abrmd/blob/master/INSTALL.md
- 安装tools包 https://github.com/tpm2-software/tpm2-tools/blob/master/doc/INSTALL.md
注意,如果没有使用tpm模拟器,文档提到最好不要单元测试,不然对tpm硬件可能造成无法恢复的损伤。
若依然有缺乏的依赖,可以参考如下命令
sudo apt-get install lcov pandoc autoconf-archive
sudo apt-get install liburiparser-dev
sudo apt-get install libdbus-1-dev libglib2.0-dev dbus-x11
sudo apt-get install -y automake
sudo apt install autoconf -y
sudo apt install libtool -y
sudo apt-get install libjson-c-dev -y
sudo apt-get install libcurl3 -y
sudo apt-get install libcurl4 libcurl4-openssl-dev -y
sudo apt-get install -y doxygen
## How Install gio-unix-2.0
sudo apt-get install libglib2.0-dev
abrmd的安装和启动比较麻烦
按照文档,依然失败了很多次,要么dbus报错,要么*abrmd.service没起来,经测试,如下命令可行,下面命令来自参考自TOOLS-INSTALL.md
cd tpm2-abrmd
./bootstrap
./configure --with-dbuspolicydir=/etc/dbus-1/system.d --with-udevrulesdir=/usr/lib/udev/rules.d --with-systemdsystemunitdir=/usr/lib/systemd/system
make -j5
sudo make install
run
如果主板上有TPM,则可以不用模拟器。root权限启动abrmd。
启动前先执行
sudo ldconfig
然后启动
sudo tpm2-abrmd --allow-root &
hello world
tpm2_pcrread
sha1:
0 : 0xAAAB2F9467FB088B67F29B5437200FB631E92CC9
1 : 0xD633C974C89C0B51CED6660BBBBAA7D4313A06D2
2 : 0xB2A83B0EBF2F8374299A5B2BDFC31EA955AD7236
3 : 0xB2A83B0EBF2F8374299A5B2BDFC31EA955AD7236
4 : 0x3B5569D8B67CC4DF6228B9F5F0D24B0547762096
5 : 0xC6B78F833B5A77B4CA16C72C5636981A08040CEC
6 : 0xB2A83B0EBF2F8374299A5B2BDFC31EA955AD7236
7 : 0x6653ABA680BF45C7130D897EA1D8A18FD32CADE6
8 : 0x0000000000000000000000000000000000000000
9 : 0x0000000000000000000000000000000000000000
10: 0x517927AF9D3726175B51C021F190F089CDD186B4
11: 0x0000000000000000000000000000000000000000
12: 0x0000000000000000000000000000000000000000
13: 0x0000000000000000000000000000000000000000
<snip>
如果使用了tpm模拟器
ibmtpm
$ mkdir ibmtpm && cd ibmtpm
$ wget https://sourceforge.net/projects/ibmswtpm2/files/latest/download -O ibmtpm.tar.gz
$ tar -zxvf ibmtpm.tar.gz
$ cd src
$ make -j5
启动模拟器
./tpm_server &
TPM command server listening on port 2321
Platform server listening on port 2322
启动 abrmd
tpm2-abrmd --allow-root --tcti=mssim
测试
tpm2_pcrread
sha1 :
0 : 0000000000000000000000000000000000000003
1 : 0000000000000000000000000000000000000000
2 : 0000000000000000000000000000000000000000
3 : 0000000000000000000000000000000000000000
4 : 0000000000000000000000000000000000000000
5 : 0000000000000000000000000000000000000000
<snip>
tpm2-tools的使用教程在man目录下,github wiki中的教程可能年久失修了。
参考https://github.com/tpm2-software/tpm2-tools/wiki/Getting-Started#installing