rpc_dir.c

来自「TCG软件栈 linux系统上使用 为可信应用软件提供和 TPM通信的 接」· C语言 代码 · 共 90 行

C
90
字号
/* * Licensed Materials - Property of IBM * * trousers - An open source TCG Software Stack * * (C) Copyright International Business Machines Corp. 2004-2006 * */#include <stdlib.h>#include <stdio.h>#include <string.h>#include <assert.h>#include "trousers/tss.h"#include "trousers/trousers.h"#include "trousers_types.h"#include "spi_utils.h"#include "capabilities.h"#include "tsplog.h"#include "hosttable.h"#include "tcsd_wrap.h"#include "obj.h"#include "rpc_tcstp_tsp.h"TSS_RESULTRPC_DirWriteAuth_TP(struct host_table_entry *hte,				 TCPA_DIRINDEX dirIndex,	/* in */				 TCPA_DIRVALUE *newContents,	/* in */				 TPM_AUTH * ownerAuth	/* in, out */    ) {	TSS_RESULT result;	initData(&hte->comm, 4);	hte->comm.hdr.u.ordinal = TCSD_ORD_DIRWRITEAUTH;	LogDebugFn("TCS Context: 0x%x", hte->tcsContext);	if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))		return TSPERR(TSS_E_INTERNAL_ERROR);	if (setData(TCSD_PACKET_TYPE_UINT32, 1, &dirIndex, 0, &hte->comm))		return TSPERR(TSS_E_INTERNAL_ERROR);	if (setData(TCSD_PACKET_TYPE_DIGEST, 2, newContents, 0, &hte->comm))		return TSPERR(TSS_E_INTERNAL_ERROR);	if (setData(TCSD_PACKET_TYPE_AUTH, 3, ownerAuth, 0, &hte->comm))		return TSPERR(TSS_E_INTERNAL_ERROR);	result = sendTCSDPacket(hte);	if (result == TSS_SUCCESS)		result = hte->comm.hdr.u.result;	if (result == TSS_SUCCESS) {		if (getData(TCSD_PACKET_TYPE_AUTH, 0, ownerAuth, 0, &hte->comm))			result = TSPERR(TSS_E_INTERNAL_ERROR);	}	return result;}TSS_RESULTRPC_DirRead_TP(struct host_table_entry *hte,			    TCPA_DIRINDEX dirIndex,	/* in */			    TCPA_DIRVALUE * dirValue	/* out */    ) {	TSS_RESULT result;	initData(&hte->comm, 2);	hte->comm.hdr.u.ordinal = TCSD_ORD_DIRREAD;	LogDebugFn("TCS Context: 0x%x", hte->tcsContext);	if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))		return TSPERR(TSS_E_INTERNAL_ERROR);	if (setData(TCSD_PACKET_TYPE_UINT32, 1, &dirIndex, 0, &hte->comm))		return TSPERR(TSS_E_INTERNAL_ERROR);	result = sendTCSDPacket(hte);	if (result == TSS_SUCCESS)		result = hte->comm.hdr.u.result;	if (hte->comm.hdr.u.result == TSS_SUCCESS) {		if (getData(TCSD_PACKET_TYPE_DIGEST, 0, dirValue, 0, &hte->comm))			result = TSPERR(TSS_E_INTERNAL_ERROR);	}	return result;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?