3
* Licensed Materials - Property of IBM
5
* trousers - An open source TCG Software Stack
7
* (C) Copyright International Business Machines Corp. 2007
16
#include "trousers/tss.h"
17
#include "trousers_types.h"
18
#include "tcs_utils.h"
23
TCSP_SetOrdinalAuditStatus_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
24
TPM_AUTH *ownerAuth, /* in/out */
25
UINT32 ulOrdinal, /* in */
26
TSS_BOOL bAuditState) /* in */
31
BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
35
if ((result = ctx_verify_context(hContext)))
38
if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
41
if ((result = tpm_rqu_build(TPM_ORD_SetOrdinalAuditStatus, &offset, txBlob, ulOrdinal,
42
bAuditState, ownerAuth)))
45
if ((result = req_mgr_submit_req(txBlob)))
49
result = UnloadBlob_Header(txBlob, ¶mSize);
52
result = tpm_rsp_parse(TPM_ORD_SetOrdinalAuditStatus, txBlob, paramSize, ownerAuth);
55
LogResult("SetOrdinalAuditStatus", result);
58
auth_mgr_release_auth(ownerAuth, NULL, hContext);
64
TCSP_GetAuditDigest_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
65
UINT32 startOrdinal, /* in */
66
TPM_DIGEST *auditDigest, /* out */
67
UINT32 *counterValueSize, /* out */
68
BYTE **counterValue, /* out */
69
TSS_BOOL *more, /* out */
70
UINT32 *ordSize, /* out */
71
UINT32 **ordList) /* out */
76
BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
80
if ((result = ctx_verify_context(hContext)))
83
if ((result = tpm_rqu_build(TPM_ORD_GetAuditDigest, &offset, txBlob, startOrdinal, NULL)))
86
if ((result = req_mgr_submit_req(txBlob)))
89
result = UnloadBlob_Header(txBlob, ¶mSize);
91
if ((result = tpm_rsp_parse(TPM_ORD_GetAuditDigest, txBlob, paramSize, auditDigest,
92
counterValueSize, counterValue, more, ordSize,
96
/* ordSize is returned from the TPM as the number of bytes in ordList
97
so ordSize needs to be converted to comply with the TSS spec which
98
returns the number of ordinals contained in ordList */
99
*ordSize = *ordSize / sizeof(UINT32);
102
LogResult("GetAuditDigest", result);
109
TCSP_GetAuditDigestSigned_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
110
TCS_KEY_HANDLE keyHandle, /* in */
111
TSS_BOOL closeAudit, /* in */
112
TPM_NONCE antiReplay, /* in */
113
TPM_AUTH *privAuth, /* in/out */
114
UINT32 *counterValueSize, /* out */
115
BYTE **counterValue, /* out */
116
TPM_DIGEST *auditDigest, /* out */
117
TPM_DIGEST *ordinalDigest, /* out */
118
UINT32 *sigSize, /* out */
119
BYTE **sig) /* out */
122
TCPA_KEY_HANDLE keySlot;
123
UINT64 offset = 0;//, old_offset;
125
BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
129
if ((result = ctx_verify_context(hContext)))
132
if (privAuth != NULL)
133
if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle)))
136
if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
139
if ((result = tpm_rqu_build(TPM_ORD_GetAuditDigestSigned, &offset, txBlob, keySlot,
140
closeAudit, antiReplay.nonce, privAuth)))
143
if ((result = req_mgr_submit_req(txBlob)))
146
result = UnloadBlob_Header(txBlob, ¶mSize);
148
result = tpm_rsp_parse(TPM_ORD_GetAuditDigestSigned, txBlob, paramSize,
149
counterValueSize, counterValue, auditDigest, ordinalDigest,
150
sigSize, sig, privAuth);
153
LogResult("GetAuditDigestSigned", result);
156
auth_mgr_release_auth(privAuth, NULL, hContext);