1 Star 1 Fork 0

Yogile / tpm_pcr

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
pcr_read.c 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
Yogile 提交于 2021-07-30 11:55 . 单独提取仓库
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <tss/tss_error.h>
#include <tss/platform.h>
#include <tss/tss_defines.h>
#include <tss/tss_typedef.h>
#include <tss/tss_structs.h>
#include <tss/tspi.h>
#include <trousers/trousers.h>
#define Debug(message, tResult) printf("%s : %s\n", message, (char *)Trspi_Error_String(result))
void pcr_read() {
// 声明上下文对象句柄
TSS_HCONTEXT hContext = 0;
TSS_HTPM hTPM = 0;
TSS_RESULT result;
UINT32 ulPcrIndex;
UINT32 pulPcrValueLength;
BYTE* prgbPcrValue;
/* 告诉系统我们正在与本地TPM通讯 */
result = Tspi_Context_Create(&hContext);
Debug("Create &hContext Context", result);
result = Tspi_Context_Connect(hContext, NULL);
Debug("Context hContext Connect", result);
/* 获得TPM句柄 */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
Debug("Get TPM Handle", result);
//输出所有PCR寄存器内的值
/*********************/
for (int j = 0; j < 2; j++)//24
{
result = Tspi_TPM_PcrRead(hTPM, j, &pulPcrValueLength, &prgbPcrValue);
printf("PCR %02d ", j);
for (int i = 0; i < 20; i++) {
printf("%02x", *(prgbPcrValue + i));
}
printf("\n");
}
//Clean up
Tspi_Context_FreeMemory(hContext, NULL);
Tspi_Context_Close(hContext);
}
int main()
{
pcr_read();
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/Yogile/tpm_pcr.git
git@gitee.com:Yogile/tpm_pcr.git
Yogile
tpm_pcr
tpm_pcr
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891