本文以代码的方式描述如何调用TPM生成随机数。
编译方式
gcc -Wall -Wextra -std=c99 -g xxx.c -o xxx
1.头文件
#ifndef _ELTT2_H_
#define _ELTT2_H_
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>
//-------------"Defines"-------------
#define ERR_COMMUNICATION -1 ///< Return error check for read and write to the TPM.
#define PRINT_RESPONSE_WITHOUT_HEADER 12 ///< Prints the response buffer from byte 12.
static const uint8_t tpm2_getrandom[] = {
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x0C,