前提:
#export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
#tcsd
源码如下:
#include <stdio.h>
#include "trousers/tss.h"
#define CKERR if(result != TSS_SUCCESS) {perror("erro/n"); return 1;}
int main(){
TSS_HCONTEXT hContext;
TSS_HTPM hTPM;
TSS_HPOLICY hOwnerPolicy;
TSS_HNVSTORE hNVStore;
TSS_RESULT result;
BYTE *data;
UINT32 len = 6;
result = Tspi_Context_Create(&hContext); CKERR
result = Tspi_Context_Connect(hContext, NULL); CKERR
result = Tspi_Context_GetTpmObject(hContext, &hTPM); CKERR
result = Tspi_GetPolicyObject(hTPM, TSS_POLICY_USAGE, &hOwnerPolicy); CKERR
result = Tspi_Policy_SetSecret(hOwnerPolicy, TSS_SECRET_MODE_PLAIN, strlen("happy"), "happy"); CKERR
result = Tspi_Context_CreateObject(hContext,