3
* Licensed Materials - Property of IBM
5
* trousers - An open source TCG Software Stack
7
* (C) Copyright International Business Machines Corp. 2004
8
* (C) Christian Kummer 2007
18
#include "trousers/tss.h"
19
#include "trousers_types.h"
22
#include "tcs_utils.h"
23
#include "tcs_int_literals.h"
24
#include "capabilities.h"
27
#include "tcsd_wrap.h"
32
TCSP_Extend_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
33
TCPA_PCRINDEX pcrNum, /* in */
34
TCPA_DIGEST inDigest, /* in */
35
TCPA_PCRVALUE * outDigest) /* out */
40
BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
42
LogDebug("Entering Extend");
43
if ((result = ctx_verify_context(hContext)))
46
/* PCRs are numbered 0 - (NUM_PCRS - 1), thus the >= */
47
if (pcrNum >= tpm_metrics.num_pcrs)
48
return TCSERR(TSS_E_BAD_PARAMETER);
50
if (tcsd_options.kernel_pcrs & (1 << pcrNum)) {
51
LogInfo("PCR %d is configured to be kernel controlled. Extend request denied.",
53
return TCSERR(TSS_E_FAIL);
56
if (tcsd_options.firmware_pcrs & (1 << pcrNum)) {
57
LogInfo("PCR %d is configured to be firmware controlled. Extend request denied.",
59
return TCSERR(TSS_E_FAIL);
62
if ((result = tpm_rqu_build(TPM_ORD_Extend, &offset, txBlob, pcrNum, TPM_DIGEST_SIZE,
63
inDigest.digest, NULL, NULL)))
66
if ((result = req_mgr_submit_req(txBlob)))
69
result = UnloadBlob_Header(txBlob, ¶mSize);
71
result = tpm_rsp_parse(TPM_ORD_Extend, txBlob, paramSize, NULL, outDigest->digest);
73
LogResult("Extend", result);
78
TCSP_PcrRead_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
79
TCPA_PCRINDEX pcrNum, /* in */
80
TCPA_PCRVALUE * outDigest) /* out */
85
BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
87
LogDebug("Entering PCRRead");
89
if ((result = ctx_verify_context(hContext)))
92
/* PCRs are numbered 0 - (NUM_PCRS - 1), thus the >= */
93
if (pcrNum >= tpm_metrics.num_pcrs)
94
return TCSERR(TSS_E_BAD_PARAMETER);
96
if ((result = tpm_rqu_build(TPM_ORD_PcrRead, &offset, txBlob, pcrNum, NULL)))
99
if ((result = req_mgr_submit_req(txBlob)))
102
result = UnloadBlob_Header(txBlob, ¶mSize);
104
result = tpm_rsp_parse(TPM_ORD_PcrRead, txBlob, paramSize, NULL, outDigest->digest);
106
LogResult("PCR Read", result);
111
TCSP_PcrReset_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
112
UINT32 pcrDataSizeIn, /* in */
113
BYTE * pcrDataIn) /* in */
118
BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
120
LogDebug("Entering PCRReset");
122
if ((result = ctx_verify_context(hContext)))
125
if ((result = tpm_rqu_build(TPM_ORD_PCR_Reset, &offset, txBlob, pcrDataSizeIn, pcrDataIn)))
128
if ((result = req_mgr_submit_req(txBlob)))
131
result = UnloadBlob_Header(txBlob, ¶mSize);
132
LogResult("PCR Reset", result);