~ubuntu-branches/ubuntu/hardy/trousers/hardy-proposed

« back to all changes in this revision

Viewing changes to src/tcs/tcsi_audit.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-01-23 22:03:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080123220300-fhtqja3c0oq0gp6z
Tags: 0.3.1-4
* Added patch from Aaron M. Ucko <ucko@debian.org> to allow trousers to
  build successfully on amd64, and presumably also other 64-bit
  architectures (Closes: #457400).
* Including udev rule for /dev/tpm from William Lima
  <wlima.amadeus@gmail.com> as suggested by David Smith <dds@google.com>
  (Closes: #459682).
* Added lintian overrides.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 * Licensed Materials - Property of IBM
 
4
 *
 
5
 * trousers - An open source TCG Software Stack
 
6
 *
 
7
 * (C) Copyright International Business Machines Corp. 2007
 
8
 *
 
9
 */
 
10
 
 
11
 
 
12
#include <stdlib.h>
 
13
#include <stdio.h>
 
14
#include <string.h>
 
15
 
 
16
#include "trousers/tss.h"
 
17
#include "trousers_types.h"
 
18
#include "tcs_utils.h"
 
19
#include "tcslog.h"
 
20
#include "req_mgr.h"
 
21
 
 
22
TSS_RESULT
 
23
TCSP_SetOrdinalAuditStatus_Internal(TCS_CONTEXT_HANDLE hContext,        /* in */
 
24
                                    TPM_AUTH *ownerAuth,                /* in/out */
 
25
                                    UINT32 ulOrdinal,                   /* in */
 
26
                                    TSS_BOOL bAuditState)               /* in */
 
27
{
 
28
        TSS_RESULT result;
 
29
        UINT64 offset = 0;
 
30
        UINT32 paramSize;
 
31
        BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
 
32
 
 
33
        LogDebugFn("Enter");
 
34
 
 
35
        if ((result = ctx_verify_context(hContext)))
 
36
                return result;
 
37
 
 
38
        if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
 
39
                return result;
 
40
 
 
41
        if ((result = tpm_rqu_build(TPM_ORD_SetOrdinalAuditStatus, &offset, txBlob, ulOrdinal,
 
42
                                    bAuditState, ownerAuth)))
 
43
                goto done;
 
44
 
 
45
        if ((result = req_mgr_submit_req(txBlob)))
 
46
                goto done;
 
47
 
 
48
        offset = 10;
 
49
        result = UnloadBlob_Header(txBlob, &paramSize);
 
50
 
 
51
        if (!result) {
 
52
                result = tpm_rsp_parse(TPM_ORD_SetOrdinalAuditStatus, txBlob, paramSize, ownerAuth);
 
53
        }
 
54
 
 
55
        LogResult("SetOrdinalAuditStatus", result);
 
56
 
 
57
done:
 
58
        auth_mgr_release_auth(ownerAuth, NULL, hContext);
 
59
 
 
60
        return result;
 
61
}
 
62
 
 
63
TSS_RESULT
 
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 */
 
72
{
 
73
        TSS_RESULT result;
 
74
        UINT64 offset = 0;
 
75
        UINT32 paramSize;
 
76
        BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
 
77
 
 
78
        LogDebugFn("Enter");
 
79
 
 
80
        if ((result = ctx_verify_context(hContext)))
 
81
                return result;
 
82
 
 
83
        if ((result = tpm_rqu_build(TPM_ORD_GetAuditDigest, &offset, txBlob, startOrdinal, NULL)))
 
84
                return result;
 
85
 
 
86
        if ((result = req_mgr_submit_req(txBlob)))
 
87
                goto done;
 
88
 
 
89
        result = UnloadBlob_Header(txBlob, &paramSize);
 
90
        if (!result) {
 
91
                if ((result = tpm_rsp_parse(TPM_ORD_GetAuditDigest, txBlob, paramSize, auditDigest,
 
92
                                            counterValueSize, counterValue, more, ordSize,
 
93
                                            ordList)))
 
94
                        goto done;
 
95
 
 
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);
 
100
        }
 
101
 
 
102
        LogResult("GetAuditDigest", result);
 
103
 
 
104
done:
 
105
        return result;
 
106
}
 
107
 
 
108
TSS_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 */
 
120
{
 
121
        TSS_RESULT result;
 
122
        TCPA_KEY_HANDLE keySlot;
 
123
        UINT64 offset = 0;//, old_offset;
 
124
        UINT32 paramSize;
 
125
        BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
 
126
 
 
127
        LogDebugFn("Enter");
 
128
 
 
129
        if ((result = ctx_verify_context(hContext)))
 
130
                return result;
 
131
 
 
132
        if (privAuth != NULL)
 
133
                if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle)))
 
134
                        return result;
 
135
 
 
136
        if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
 
137
                goto done;
 
138
 
 
139
        if ((result = tpm_rqu_build(TPM_ORD_GetAuditDigestSigned, &offset, txBlob, keySlot,
 
140
                                    closeAudit, antiReplay.nonce, privAuth)))
 
141
                goto done;
 
142
 
 
143
        if ((result = req_mgr_submit_req(txBlob)))
 
144
                goto done;
 
145
 
 
146
        result = UnloadBlob_Header(txBlob, &paramSize);
 
147
        if (!result) {
 
148
                result = tpm_rsp_parse(TPM_ORD_GetAuditDigestSigned, txBlob, paramSize,
 
149
                                       counterValueSize, counterValue, auditDigest, ordinalDigest,
 
150
                                       sigSize, sig, privAuth);
 
151
        }
 
152
 
 
153
        LogResult("GetAuditDigestSigned", result);
 
154
 
 
155
done:
 
156
        auth_mgr_release_auth(privAuth, NULL, hContext);
 
157
 
 
158
        return result;
 
159
}