?? rpc_random.c
字號(hào):
/* * 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 <syslog.h>#include <string.h>#include <netdb.h>#include "trousers/tss.h"#include "trousers_types.h"#include "tcs_tsp.h"#include "tcs_utils.h"#include "tcs_int_literals.h"#include "capabilities.h"#include "tcslog.h"#include "tcsd_wrap.h"#include "tcsd.h"#include "tcs_utils.h"#include "rpc_tcstp_tcs.h"TSS_RESULTtcs_wrap_GetRandom(struct tcsd_thread_data *data){ TCS_CONTEXT_HANDLE hContext; UINT32 bytesRequested; BYTE *randomBytes = NULL; TSS_RESULT result; if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm)) return TCSERR(TSS_E_INTERNAL_ERROR); LogDebugFn("thread %zd context %x", THREAD_ID, hContext); if (getData(TCSD_PACKET_TYPE_UINT32, 1, &bytesRequested, 0, &data->comm)) return TCSERR(TSS_E_INTERNAL_ERROR); MUTEX_LOCK(tcsp_lock); result = TCSP_GetRandom_Internal(hContext, &bytesRequested, &randomBytes); MUTEX_UNLOCK(tcsp_lock); if (result == TSS_SUCCESS) { initData(&data->comm, 2); if (setData(TCSD_PACKET_TYPE_UINT32, 0, &bytesRequested, 0, &data->comm)) { free(randomBytes); return TCSERR(TSS_E_INTERNAL_ERROR); } if (setData(TCSD_PACKET_TYPE_PBYTE, 1, randomBytes, bytesRequested, &data->comm)) { free(randomBytes); return TCSERR(TSS_E_INTERNAL_ERROR); } free(randomBytes); } else initData(&data->comm, 0); data->comm.hdr.u.result = result; return TSS_SUCCESS;}TSS_RESULTtcs_wrap_StirRandom(struct tcsd_thread_data *data){ TCS_CONTEXT_HANDLE hContext; UINT32 inDataSize; BYTE *inData; TSS_RESULT result; if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm)) return TCSERR(TSS_E_INTERNAL_ERROR); LogDebugFn("thread %zd context %x", THREAD_ID, hContext); if (getData(TCSD_PACKET_TYPE_UINT32, 1, &inDataSize, 0, &data->comm)) return TCSERR(TSS_E_INTERNAL_ERROR); inData = calloc(1, inDataSize); if (inData == NULL) { LogError("malloc of %d bytes failed.", inDataSize); return TCSERR(TSS_E_OUTOFMEMORY); } if (getData(TCSD_PACKET_TYPE_PBYTE, 2, inData, inDataSize, &data->comm)) { free(inData); return TCSERR(TSS_E_INTERNAL_ERROR); } MUTEX_LOCK(tcsp_lock); result = TCSP_StirRandom_Internal(hContext, inDataSize, inData); MUTEX_UNLOCK(tcsp_lock); free(inData); initData(&data->comm, 0); data->comm.hdr.u.result = result; return TSS_SUCCESS;}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -