1 | /* $Id: VBoxTraceLogDecoders.cpp 104961 2024-06-19 10:47:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * RTTraceLogDecoders - Implement decoders for the tracing driver.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 |
|
---|
29 | /*********************************************************************************************************************************
|
---|
30 | * Header Files *
|
---|
31 | *********************************************************************************************************************************/
|
---|
32 | #define LOG_GROUP RTLOGGROUP_DEFAULT
|
---|
33 | #include <iprt/assert.h>
|
---|
34 | #include <iprt/errcore.h>
|
---|
35 | #include <iprt/log.h>
|
---|
36 | #include <iprt/tracelog-decoder-plugin.h>
|
---|
37 |
|
---|
38 | #include <iprt/formats/tpm.h>
|
---|
39 |
|
---|
40 |
|
---|
41 | /*********************************************************************************************************************************
|
---|
42 | * Structures and Typedefs *
|
---|
43 | *********************************************************************************************************************************/
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * TPM decoder context.
|
---|
47 | */
|
---|
48 | typedef struct TPMDECODECTX
|
---|
49 | {
|
---|
50 | /** Pointer to the next data item. */
|
---|
51 | const uint8_t *pbBuf;
|
---|
52 | /** Number of bytes left for the buffer. */
|
---|
53 | size_t cbLeft;
|
---|
54 | /** Flag whether an error was encountered. */
|
---|
55 | bool fError;
|
---|
56 | } TPMDECODECTX;
|
---|
57 | /** Pointer to a TPM decoder context. */
|
---|
58 | typedef TPMDECODECTX *PTPMDECODECTX;
|
---|
59 |
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * Algorithm ID to string mapping.
|
---|
63 | */
|
---|
64 | typedef struct TPMALGID2STR
|
---|
65 | {
|
---|
66 | uint16_t u16AlgId;
|
---|
67 | const char *pszAlgId;
|
---|
68 | size_t cbDigest;
|
---|
69 | } TPMALGID2STR;
|
---|
70 | typedef const TPMALGID2STR *PCTPMALGID2STR;
|
---|
71 |
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * The TPM state.
|
---|
75 | */
|
---|
76 | typedef struct TPMSTATE
|
---|
77 | {
|
---|
78 | /** Command code. */
|
---|
79 | uint32_t u32CmdCode;
|
---|
80 | /** Command code dependent state. */
|
---|
81 | union
|
---|
82 | {
|
---|
83 | /** TPM2_CC_GET_CAPABILITY related state. */
|
---|
84 | struct
|
---|
85 | {
|
---|
86 | /** The capability group to query. */
|
---|
87 | uint32_t u32Cap;
|
---|
88 | /** Property to query. */
|
---|
89 | uint32_t u32Property;
|
---|
90 | /** Number of values to return. */
|
---|
91 | uint32_t u32Count;
|
---|
92 | } GetCapability;
|
---|
93 | /** TPM2_GET_RANDOM related state. */
|
---|
94 | struct
|
---|
95 | {
|
---|
96 | /** Number of bytes of random data to produce. */
|
---|
97 | uint16_t cbRnd;
|
---|
98 | } GetRandom;
|
---|
99 | } u;
|
---|
100 | } TPMSTATE;
|
---|
101 | typedef TPMSTATE *PTPMSTATE;
|
---|
102 |
|
---|
103 |
|
---|
104 | /**
|
---|
105 | */
|
---|
106 | typedef DECLCALLBACKTYPE(void, FNDECODETPM2CCREQ, (PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx));
|
---|
107 | /** Pointer to an event decode request callback. */
|
---|
108 | typedef FNDECODETPM2CCREQ *PFNFNDECODETPM2CCREQ;
|
---|
109 |
|
---|
110 |
|
---|
111 | /**
|
---|
112 | */
|
---|
113 | typedef DECLCALLBACKTYPE(void, FNDECODETPM2CCRESP, (PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx));
|
---|
114 | /** Pointer to an event decode request callback. */
|
---|
115 | typedef FNDECODETPM2CCRESP *PFNFNDECODETPM2CCRESP;
|
---|
116 |
|
---|
117 |
|
---|
118 | /*********************************************************************************************************************************
|
---|
119 | * Static Variables *
|
---|
120 | *********************************************************************************************************************************/
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * Algorithm ID to string mapping array.
|
---|
124 | */
|
---|
125 | static const TPMALGID2STR g_aAlgId2Str[] =
|
---|
126 | {
|
---|
127 | #define TPM_ALGID_2_STR(a_AlgId) { a_AlgId, #a_AlgId, 0 }
|
---|
128 | #define TPM_ALGID_2_STR_DIGEST(a_AlgId, a_cbDigest) { a_AlgId, #a_AlgId, a_cbDigest }
|
---|
129 |
|
---|
130 | TPM_ALGID_2_STR(TPM2_ALG_ERROR),
|
---|
131 | TPM_ALGID_2_STR(TPM2_ALG_RSA),
|
---|
132 | TPM_ALGID_2_STR(TPM2_ALG_TDES),
|
---|
133 | TPM_ALGID_2_STR_DIGEST(TPM2_ALG_SHA1, 20),
|
---|
134 | TPM_ALGID_2_STR(TPM2_ALG_HMAC),
|
---|
135 | TPM_ALGID_2_STR(TPM2_ALG_AES),
|
---|
136 | TPM_ALGID_2_STR(TPM2_ALG_MGF1),
|
---|
137 | TPM_ALGID_2_STR(TPM2_ALG_KEYEDHASH),
|
---|
138 | TPM_ALGID_2_STR(TPM2_ALG_XOR),
|
---|
139 | TPM_ALGID_2_STR_DIGEST(TPM2_ALG_SHA256, 32),
|
---|
140 | TPM_ALGID_2_STR_DIGEST(TPM2_ALG_SHA384, 48),
|
---|
141 | TPM_ALGID_2_STR_DIGEST(TPM2_ALG_SHA512, 64),
|
---|
142 | TPM_ALGID_2_STR_DIGEST(TPM2_ALG_SHA256_192, 24),
|
---|
143 | TPM_ALGID_2_STR(TPM2_ALG_NULL),
|
---|
144 | TPM_ALGID_2_STR(TPM2_ALG_SM3_256),
|
---|
145 | TPM_ALGID_2_STR(TPM2_ALG_SM4),
|
---|
146 | TPM_ALGID_2_STR(TPM2_ALG_RSASSA),
|
---|
147 | TPM_ALGID_2_STR(TPM2_ALG_RSAES),
|
---|
148 | TPM_ALGID_2_STR(TPM2_ALG_RSAPSS),
|
---|
149 | TPM_ALGID_2_STR(TPM2_ALG_OAEP),
|
---|
150 | TPM_ALGID_2_STR(TPM2_ALG_ECDSA),
|
---|
151 | TPM_ALGID_2_STR(TPM2_ALG_ECDH),
|
---|
152 | TPM_ALGID_2_STR(TPM2_ALG_ECDAA),
|
---|
153 | TPM_ALGID_2_STR(TPM2_ALG_SM2),
|
---|
154 | TPM_ALGID_2_STR(TPM2_ALG_ECSCHNORR),
|
---|
155 | TPM_ALGID_2_STR(TPM2_ALG_ECMQV),
|
---|
156 | TPM_ALGID_2_STR(TPM2_ALG_KDF1_SP800_56A),
|
---|
157 | TPM_ALGID_2_STR(TPM2_ALG_KDF2),
|
---|
158 | TPM_ALGID_2_STR(TPM2_ALG_KDF1_SP800_108),
|
---|
159 | TPM_ALGID_2_STR(TPM2_ALG_ECC),
|
---|
160 | TPM_ALGID_2_STR(TPM2_ALG_SYMCIPHER),
|
---|
161 | TPM_ALGID_2_STR(TPM2_ALG_CAMELLIA),
|
---|
162 | TPM_ALGID_2_STR_DIGEST(TPM2_ALG_SHA3_256, 32),
|
---|
163 | TPM_ALGID_2_STR_DIGEST(TPM2_ALG_SHA3_384, 48),
|
---|
164 | TPM_ALGID_2_STR_DIGEST(TPM2_ALG_SHA3_512, 64),
|
---|
165 | TPM_ALGID_2_STR(TPM2_ALG_SHAKE128),
|
---|
166 | TPM_ALGID_2_STR(TPM2_ALG_SHAKE256),
|
---|
167 | TPM_ALGID_2_STR(TPM2_ALG_SHAKE256_192),
|
---|
168 | TPM_ALGID_2_STR(TPM2_ALG_SHAKE256_256),
|
---|
169 | TPM_ALGID_2_STR(TPM2_ALG_SHAKE256_512),
|
---|
170 | TPM_ALGID_2_STR(TPM2_ALG_CMAC),
|
---|
171 | TPM_ALGID_2_STR(TPM2_ALG_CTR),
|
---|
172 | TPM_ALGID_2_STR(TPM2_ALG_OFB),
|
---|
173 | TPM_ALGID_2_STR(TPM2_ALG_CBC),
|
---|
174 | TPM_ALGID_2_STR(TPM2_ALG_CFB),
|
---|
175 | TPM_ALGID_2_STR(TPM2_ALG_ECB),
|
---|
176 | TPM_ALGID_2_STR(TPM2_ALG_CCM),
|
---|
177 | TPM_ALGID_2_STR(TPM2_ALG_GCM),
|
---|
178 | TPM_ALGID_2_STR(TPM2_ALG_KW),
|
---|
179 | TPM_ALGID_2_STR(TPM2_ALG_KWP),
|
---|
180 | TPM_ALGID_2_STR(TPM2_ALG_EAX),
|
---|
181 | TPM_ALGID_2_STR(TPM2_ALG_EDDSA),
|
---|
182 | TPM_ALGID_2_STR(TPM2_ALG_EDDSA_PH),
|
---|
183 | TPM_ALGID_2_STR(TPM2_ALG_LMS),
|
---|
184 | TPM_ALGID_2_STR(TPM2_ALG_XMSS),
|
---|
185 | TPM_ALGID_2_STR(TPM2_ALG_KEYEDXOF),
|
---|
186 | TPM_ALGID_2_STR(TPM2_ALG_KMACXOF128),
|
---|
187 | TPM_ALGID_2_STR(TPM2_ALG_KMACXOF256),
|
---|
188 | TPM_ALGID_2_STR(TPM2_ALG_KMAC128),
|
---|
189 | TPM_ALGID_2_STR(TPM2_ALG_KMAC256)
|
---|
190 | #undef TPM_ALGID_2_STR
|
---|
191 | };
|
---|
192 |
|
---|
193 |
|
---|
194 | /*********************************************************************************************************************************
|
---|
195 | * Internal Functions *
|
---|
196 | *********************************************************************************************************************************/
|
---|
197 |
|
---|
198 | DECLINLINE(void) vboxTraceLogDecodeEvtTpmDecodeCtxInit(PTPMDECODECTX pCtx, const uint8_t *pbBuf, size_t cbBuf)
|
---|
199 | {
|
---|
200 | pCtx->pbBuf = pbBuf;
|
---|
201 | pCtx->cbLeft = cbBuf;
|
---|
202 | pCtx->fError = false;
|
---|
203 | }
|
---|
204 |
|
---|
205 |
|
---|
206 | static uint8_t vboxTraceLogDecodeEvtTpmDecodeCtxGetU8(PTPMDECODECTX pCtx, PRTTRACELOGDECODERHLP pHlp, const char *pszItem)
|
---|
207 | {
|
---|
208 | if (RT_UNLIKELY(pCtx->fError))
|
---|
209 | return 0;
|
---|
210 |
|
---|
211 | if (RT_UNLIKELY(!pCtx->cbLeft))
|
---|
212 | {
|
---|
213 | pHlp->pfnErrorMsg(pHlp, "Failed to decode '%s' as there is not enough space in the buffer (required %u, available %u)",
|
---|
214 | pszItem, sizeof(uint8_t), pCtx->cbLeft);
|
---|
215 | //AssertFailed();
|
---|
216 | pCtx->fError = true;
|
---|
217 | return 0;
|
---|
218 | }
|
---|
219 |
|
---|
220 | pCtx->cbLeft--;
|
---|
221 | return *pCtx->pbBuf++;
|
---|
222 | }
|
---|
223 |
|
---|
224 |
|
---|
225 | static uint16_t vboxTraceLogDecodeEvtTpmDecodeCtxGetU16(PTPMDECODECTX pCtx, PRTTRACELOGDECODERHLP pHlp, const char *pszItem)
|
---|
226 | {
|
---|
227 | if (RT_UNLIKELY(pCtx->fError))
|
---|
228 | return 0;
|
---|
229 |
|
---|
230 | if (RT_UNLIKELY(pCtx->cbLeft < sizeof(uint16_t)))
|
---|
231 | {
|
---|
232 | pHlp->pfnErrorMsg(pHlp, "Failed to decode '%s' as there is not enough space in the buffer (required %u, available %u)",
|
---|
233 | pszItem, sizeof(uint16_t), pCtx->cbLeft);
|
---|
234 | //AssertFailed();
|
---|
235 | pCtx->fError = true;
|
---|
236 | return 0;
|
---|
237 | }
|
---|
238 |
|
---|
239 | uint16_t u16 = *(uint16_t *)pCtx->pbBuf;
|
---|
240 | pCtx->pbBuf += sizeof(uint16_t);
|
---|
241 | pCtx->cbLeft -= sizeof(uint16_t);
|
---|
242 | return RT_BE2H_U16(u16);
|
---|
243 | }
|
---|
244 |
|
---|
245 |
|
---|
246 | static uint32_t vboxTraceLogDecodeEvtTpmDecodeCtxGetU32(PTPMDECODECTX pCtx, PRTTRACELOGDECODERHLP pHlp, const char *pszItem)
|
---|
247 | {
|
---|
248 | if (RT_UNLIKELY(pCtx->fError))
|
---|
249 | return 0;
|
---|
250 |
|
---|
251 | if (RT_UNLIKELY(pCtx->cbLeft < sizeof(uint32_t)))
|
---|
252 | {
|
---|
253 | pHlp->pfnErrorMsg(pHlp, "Failed to decode '%s' as there is not enough space in the buffer (required %u, available %u)",
|
---|
254 | pszItem, sizeof(uint32_t), pCtx->cbLeft);
|
---|
255 | //AssertFailed();
|
---|
256 | pCtx->fError = true;
|
---|
257 | return 0;
|
---|
258 | }
|
---|
259 |
|
---|
260 | uint32_t u32 = *(uint32_t *)pCtx->pbBuf;
|
---|
261 | pCtx->pbBuf += sizeof(uint32_t);
|
---|
262 | pCtx->cbLeft -= sizeof(uint32_t);
|
---|
263 | return RT_BE2H_U32(u32);
|
---|
264 | }
|
---|
265 |
|
---|
266 |
|
---|
267 | static int32_t vboxTraceLogDecodeEvtTpmDecodeCtxGetI32(PTPMDECODECTX pCtx, PRTTRACELOGDECODERHLP pHlp, const char *pszItem)
|
---|
268 | {
|
---|
269 | return (int32_t)vboxTraceLogDecodeEvtTpmDecodeCtxGetU32(pCtx, pHlp, pszItem);
|
---|
270 | }
|
---|
271 |
|
---|
272 |
|
---|
273 | static uint64_t vboxTraceLogDecodeEvtTpmDecodeCtxGetU64(PTPMDECODECTX pCtx, PRTTRACELOGDECODERHLP pHlp, const char *pszItem)
|
---|
274 | {
|
---|
275 | if (RT_UNLIKELY(pCtx->fError))
|
---|
276 | return 0;
|
---|
277 |
|
---|
278 | if (RT_UNLIKELY(pCtx->cbLeft < sizeof(uint64_t)))
|
---|
279 | {
|
---|
280 | pHlp->pfnErrorMsg(pHlp, "Failed to decode '%s' as there is not enough space in the buffer (required %u, available %u)",
|
---|
281 | pszItem, sizeof(uint64_t), pCtx->cbLeft);
|
---|
282 | //AssertFailed();
|
---|
283 | pCtx->fError = true;
|
---|
284 | return 0;
|
---|
285 | }
|
---|
286 |
|
---|
287 | uint64_t u64 = *(uint64_t *)pCtx->pbBuf;
|
---|
288 | pCtx->pbBuf += sizeof(uint64_t);
|
---|
289 | pCtx->cbLeft -= sizeof(uint64_t);
|
---|
290 | return RT_BE2H_U64(u64);
|
---|
291 | }
|
---|
292 |
|
---|
293 |
|
---|
294 | static const uint8_t *vboxTraceLogDecodeEvtTpmDecodeCtxGetBuf(PTPMDECODECTX pCtx, PRTTRACELOGDECODERHLP pHlp, const char *pszItem, size_t cbBuf)
|
---|
295 | {
|
---|
296 | if (RT_UNLIKELY(pCtx->fError))
|
---|
297 | return 0;
|
---|
298 |
|
---|
299 | if (RT_UNLIKELY(pCtx->cbLeft < cbBuf))
|
---|
300 | {
|
---|
301 | pHlp->pfnErrorMsg(pHlp, "Failed to decode '%s' as there is not enough space in the buffer (required %u, available %u)",
|
---|
302 | pszItem, cbBuf, pCtx->cbLeft);
|
---|
303 | //AssertFailed();
|
---|
304 | pCtx->fError = true;
|
---|
305 | return 0;
|
---|
306 | }
|
---|
307 |
|
---|
308 | /* Just return nothing if nothing is requested. */
|
---|
309 | if (!cbBuf)
|
---|
310 | return NULL;
|
---|
311 |
|
---|
312 | const uint8_t *pb = pCtx->pbBuf;
|
---|
313 | pCtx->pbBuf += cbBuf;
|
---|
314 | pCtx->cbLeft -= cbBuf;
|
---|
315 | return pb;
|
---|
316 | }
|
---|
317 |
|
---|
318 |
|
---|
319 | static const char *vboxTraceLogDecodeEvtTpmAlgId2Str(uint16_t u16AlgId)
|
---|
320 | {
|
---|
321 | for (uint32_t i = 0; i < RT_ELEMENTS(g_aAlgId2Str); i++)
|
---|
322 | if (g_aAlgId2Str[i].u16AlgId == u16AlgId)
|
---|
323 | return g_aAlgId2Str[i].pszAlgId;
|
---|
324 |
|
---|
325 | return "<UNKNOWN>";
|
---|
326 | }
|
---|
327 |
|
---|
328 |
|
---|
329 | static size_t vboxTraceLogDecodeEvtTpmAlgId2DigestSize(uint16_t u16AlgId)
|
---|
330 | {
|
---|
331 | for (uint32_t i = 0; i < RT_ELEMENTS(g_aAlgId2Str); i++)
|
---|
332 | if (g_aAlgId2Str[i].u16AlgId == u16AlgId)
|
---|
333 | return g_aAlgId2Str[i].cbDigest;
|
---|
334 |
|
---|
335 | return 0;
|
---|
336 | }
|
---|
337 |
|
---|
338 |
|
---|
339 | #define TPM_DECODE_INIT() do {
|
---|
340 |
|
---|
341 | #define TPM_DECODE_END() \
|
---|
342 | } while (0); \
|
---|
343 | if (pCtx->fError) return
|
---|
344 |
|
---|
345 | #define TPM_DECODE_U8(a_Var, a_Name) \
|
---|
346 | uint8_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU8(pCtx, pHlp, #a_Name); \
|
---|
347 | if (pCtx->fError) break
|
---|
348 |
|
---|
349 | #define TPM_DECODE_U16(a_Var, a_Name) \
|
---|
350 | uint16_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU16(pCtx, pHlp, #a_Name); \
|
---|
351 | if (pCtx->fError) break
|
---|
352 |
|
---|
353 | #define TPM_DECODE_U32(a_Var, a_Name) \
|
---|
354 | uint32_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU32(pCtx, pHlp, #a_Name); \
|
---|
355 | if (pCtx->fError) break
|
---|
356 |
|
---|
357 | #define TPM_DECODE_U64(a_Var, a_Name) \
|
---|
358 | uint64_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU64(pCtx, pHlp, #a_Name); \
|
---|
359 | if (pCtx->fError) break
|
---|
360 |
|
---|
361 | #define TPM_DECODE_I32(a_Var, a_Name) \
|
---|
362 | int32_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetI32(pCtx, pHlp, #a_Name); \
|
---|
363 | if (pCtx->fError) break
|
---|
364 |
|
---|
365 | #define TPM_DECODE_BUF(a_Var, a_Name, a_cb) \
|
---|
366 | const uint8_t *a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetBuf(pCtx, pHlp, #a_Name, a_cb); \
|
---|
367 | if (pCtx->fError) break
|
---|
368 |
|
---|
369 | #define TPM_DECODE_BUF_STR(a_Var, a_pszName, a_cb) \
|
---|
370 | const uint8_t *a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetBuf(pCtx, pHlp, a_pszName, a_cb); \
|
---|
371 | if (pCtx->fError) break
|
---|
372 |
|
---|
373 | #define TPM_DECODE_END_IF_ERROR() \
|
---|
374 | if (pCtx->fError) return
|
---|
375 |
|
---|
376 | static void vboxTraceLogDecodePcrSelection(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx)
|
---|
377 | {
|
---|
378 | TPM_DECODE_INIT();
|
---|
379 | TPM_DECODE_U16(u16AlgId, u16AlgId);
|
---|
380 | TPM_DECODE_U8(cbPcrSelection, u8SizeOfSelect);
|
---|
381 | TPM_DECODE_BUF(pb, PCRs, cbPcrSelection);
|
---|
382 |
|
---|
383 | pHlp->pfnPrintf(pHlp, " u16AlgId: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16AlgId));
|
---|
384 | pHlp->pfnPrintf(pHlp, " u8SizeOfSlect: %u\n", cbPcrSelection);
|
---|
385 | pHlp->pfnPrintf(pHlp, " PCRs: ");
|
---|
386 |
|
---|
387 | for (uint8_t idxPcr = 0; idxPcr < cbPcrSelection * 8; idxPcr++)
|
---|
388 | if (RT_BOOL(*(pb + (idxPcr / 8)) & RT_BIT(idxPcr % 8)))
|
---|
389 | pHlp->pfnPrintf(pHlp, "%u ", idxPcr);
|
---|
390 |
|
---|
391 | pHlp->pfnPrintf(pHlp, "\n");
|
---|
392 | TPM_DECODE_END();
|
---|
393 | }
|
---|
394 |
|
---|
395 |
|
---|
396 | static void vboxTraceLogDecodePcrSelectionList(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx)
|
---|
397 | {
|
---|
398 | TPM_DECODE_INIT();
|
---|
399 | TPM_DECODE_U32(u32Count, u32Count);
|
---|
400 | pHlp->pfnPrintf(pHlp, " u32Count: %u\n", u32Count);
|
---|
401 |
|
---|
402 | /* Walk the list of PCR selection entries. */
|
---|
403 | for (uint32_t i = 0; i < u32Count; i++)
|
---|
404 | {
|
---|
405 | vboxTraceLogDecodePcrSelection(pHlp, pCtx);
|
---|
406 | TPM_DECODE_END_IF_ERROR();
|
---|
407 | }
|
---|
408 | TPM_DECODE_END();
|
---|
409 | }
|
---|
410 |
|
---|
411 |
|
---|
412 | static void vboxTraceLogDecodeEvtTpmDigestList(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx)
|
---|
413 | {
|
---|
414 | TPM_DECODE_INIT();
|
---|
415 | TPM_DECODE_U32(u32DigestCount, u32DigestCount);
|
---|
416 | pHlp->pfnPrintf(pHlp, " u32DigestCount: %u\n", u32DigestCount);
|
---|
417 | for (uint32_t i = 0; i < u32DigestCount; i++)
|
---|
418 | {
|
---|
419 | TPM_DECODE_U16(u16DigestSize, u16DigestSize);
|
---|
420 | TPM_DECODE_BUF(pbDigest, abDigest, u16DigestSize);
|
---|
421 | pHlp->pfnPrintf(pHlp, " u16DigestSize: %u\n", u16DigestSize);
|
---|
422 | pHlp->pfnPrintf(pHlp, " abDigest: %.*Rhxs\n", u16DigestSize, pbDigest);
|
---|
423 | }
|
---|
424 | TPM_DECODE_END();
|
---|
425 | }
|
---|
426 |
|
---|
427 |
|
---|
428 | static void vboxTraceLogDecodeEvtTpmDigestValuesList(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx)
|
---|
429 | {
|
---|
430 | TPM_DECODE_INIT();
|
---|
431 | TPM_DECODE_U32(u32DigestCount, u32DigestCount);
|
---|
432 | pHlp->pfnPrintf(pHlp, " u32DigestCount: %u\n", u32DigestCount);
|
---|
433 | for (uint32_t i = 0; i < u32DigestCount; i++)
|
---|
434 | {
|
---|
435 | TPM_DECODE_U16(u16HashAlg, u16HashAlg);
|
---|
436 |
|
---|
437 | size_t cbDigest = vboxTraceLogDecodeEvtTpmAlgId2DigestSize(u16HashAlg);
|
---|
438 | TPM_DECODE_BUF(pb, abDigest, cbDigest);
|
---|
439 |
|
---|
440 | pHlp->pfnPrintf(pHlp, " u16HashAlg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16HashAlg));
|
---|
441 | pHlp->pfnPrintf(pHlp, " abDigest: %.*Rhxs\n", cbDigest, pb);
|
---|
442 | }
|
---|
443 | TPM_DECODE_END();
|
---|
444 | }
|
---|
445 |
|
---|
446 |
|
---|
447 | static void vboxTraceLogDecodeEvtTpmAuthSessionReq(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx)
|
---|
448 | {
|
---|
449 | TPM_DECODE_INIT();
|
---|
450 | TPM_DECODE_U32(u32Size, u32Size);
|
---|
451 | TPM_DECODE_U32(u32SessionHandle, u32SessionHandle);
|
---|
452 | TPM_DECODE_U16(u16NonceSize, u16NonceSize);
|
---|
453 | TPM_DECODE_BUF(pbNonce, abNonce, u16NonceSize);
|
---|
454 | TPM_DECODE_U8( u8Attr, u8Attr);
|
---|
455 | TPM_DECODE_U16(u16HmacSize, u16HmacSize);
|
---|
456 | TPM_DECODE_BUF(pbHmac, abHmac, u16HmacSize);
|
---|
457 |
|
---|
458 | pHlp->pfnPrintf(pHlp, " u32AuthSize: %u\n", u32Size);
|
---|
459 | pHlp->pfnPrintf(pHlp, " u32SessionHandle: %#x\n", u32SessionHandle);
|
---|
460 | pHlp->pfnPrintf(pHlp, " u16NonceSize: %u\n", u16NonceSize);
|
---|
461 | if (u16NonceSize)
|
---|
462 | pHlp->pfnPrintf(pHlp, " abNonce: %.*Rhxs\n", u16NonceSize, pbNonce);
|
---|
463 | pHlp->pfnPrintf(pHlp, " u8Attr: %u\n", u8Attr);
|
---|
464 | pHlp->pfnPrintf(pHlp, " u16HmacSize: %u\n", u16HmacSize);
|
---|
465 | if (u16HmacSize)
|
---|
466 | pHlp->pfnPrintf(pHlp, " abHmac: %.*Rhxs\n", u16HmacSize, pbHmac);
|
---|
467 | TPM_DECODE_END();
|
---|
468 | }
|
---|
469 |
|
---|
470 |
|
---|
471 | static void vboxTraceLogDecodeEvtTpmAuthSessionResp(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx)
|
---|
472 | {
|
---|
473 | TPM_DECODE_INIT();
|
---|
474 | TPM_DECODE_U16(u16NonceSize, u16NonceSize);
|
---|
475 | TPM_DECODE_BUF(pbNonce, abNonce, u16NonceSize);
|
---|
476 | TPM_DECODE_U8( u8Attr, u8Attr);
|
---|
477 | TPM_DECODE_U16(u16AckSize, u16AckSize);
|
---|
478 | TPM_DECODE_BUF(pbAck, abAck, u16AckSize);
|
---|
479 |
|
---|
480 | pHlp->pfnPrintf(pHlp, " u16NonceSize: %u\n", u16NonceSize);
|
---|
481 | if (u16NonceSize)
|
---|
482 | pHlp->pfnPrintf(pHlp, " abNonce: %.*Rhxs\n", u16NonceSize, pbNonce);
|
---|
483 | pHlp->pfnPrintf(pHlp, " u8Attr: %u\n", u8Attr);
|
---|
484 | pHlp->pfnPrintf(pHlp, " u16AckSize: %u\n", u16AckSize);
|
---|
485 | if (u16AckSize)
|
---|
486 | pHlp->pfnPrintf(pHlp, " abAck: %.*Rhxs\n", u16AckSize, pbAck);
|
---|
487 | TPM_DECODE_END();
|
---|
488 | }
|
---|
489 |
|
---|
490 |
|
---|
491 | static void vboxTraceLogDecodeSizedBufU16(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
492 | {
|
---|
493 | TPM_DECODE_INIT();
|
---|
494 | pHlp->pfnPrintf(pHlp, " %s:\n", pszName);
|
---|
495 | TPM_DECODE_U16(u16Size, u16Size);
|
---|
496 | pHlp->pfnPrintf(pHlp, " u16Size: %u\n", u16Size);
|
---|
497 | if (u16Size)
|
---|
498 | {
|
---|
499 | TPM_DECODE_BUF_STR(pb, pszName, u16Size);
|
---|
500 | pHlp->pfnPrintf(pHlp, " %s:\n"
|
---|
501 | "%.*Rhxd\n", pszName, u16Size, pb);
|
---|
502 | }
|
---|
503 | TPM_DECODE_END();
|
---|
504 | }
|
---|
505 |
|
---|
506 |
|
---|
507 | static void vboxTraceLogDecodeSymEncDef(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
508 | {
|
---|
509 | RT_NOREF(pszName);
|
---|
510 |
|
---|
511 | TPM_DECODE_INIT();
|
---|
512 | pHlp->pfnPrintf(pHlp, " %s:\n", pszName);
|
---|
513 | TPM_DECODE_U16(u16HashAlg, u16HashAlg);
|
---|
514 | pHlp->pfnPrintf(pHlp, " u16Alg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16HashAlg));
|
---|
515 | if (u16HashAlg != TPM2_ALG_NULL)
|
---|
516 | {
|
---|
517 | TPM_DECODE_U16(u16KeyBits, u16KeyBits);
|
---|
518 | pHlp->pfnPrintf(pHlp, " u16KeyBits: %u\n", u16KeyBits);
|
---|
519 | TPM_DECODE_U16(u16SymMode, u16SymMode);
|
---|
520 | pHlp->pfnPrintf(pHlp, " u16SymMode: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16SymMode));
|
---|
521 | /* Symmetric details are not required as of now. */
|
---|
522 | }
|
---|
523 | TPM_DECODE_END();
|
---|
524 | }
|
---|
525 |
|
---|
526 |
|
---|
527 | static void vboxTraceLogDecodeNvPublic(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
528 | {
|
---|
529 | TPM_DECODE_INIT();
|
---|
530 | pHlp->pfnPrintf(pHlp, " %s:\n", pszName);
|
---|
531 | TPM_DECODE_U16(u16Size, u16Size);
|
---|
532 | pHlp->pfnPrintf(pHlp, " u16Size: %u\n", u16Size);
|
---|
533 | if (u16Size)
|
---|
534 | {
|
---|
535 | TPM_DECODE_U32(hNvIndex, hNvIndex);
|
---|
536 | TPM_DECODE_U16(u16HashAlgName, u16HashAlgName);
|
---|
537 | TPM_DECODE_U32(u32Attr, fAttr);
|
---|
538 |
|
---|
539 | pHlp->pfnPrintf(pHlp, " hNvIndex: %#x\n", hNvIndex);
|
---|
540 | pHlp->pfnPrintf(pHlp, " u16HashAlgName: %u\n", u16HashAlgName);
|
---|
541 | pHlp->pfnPrintf(pHlp, " u32Attr: %#x\n", u32Attr);
|
---|
542 |
|
---|
543 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "AuthPolicy");
|
---|
544 | TPM_DECODE_U16(u16DataSize, u16DataSize);
|
---|
545 | pHlp->pfnPrintf(pHlp, " u16DataSize: %u\n", u16DataSize);
|
---|
546 | }
|
---|
547 | TPM_DECODE_END();
|
---|
548 | }
|
---|
549 |
|
---|
550 |
|
---|
551 | static void vboxTraceLogDecodeTicket(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
552 | {
|
---|
553 | TPM_DECODE_INIT();
|
---|
554 | pHlp->pfnPrintf(pHlp, " %s:\n", pszName);
|
---|
555 |
|
---|
556 | TPM_DECODE_U16(u16Tag, u16Tag);
|
---|
557 | TPM_DECODE_U32(hHierarchy, hHierarchy);
|
---|
558 | pHlp->pfnPrintf(pHlp, " u16Tag: %#x\n", u16Tag);
|
---|
559 | pHlp->pfnPrintf(pHlp, " hHierarchy: %#x\n", hHierarchy);
|
---|
560 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Digest");
|
---|
561 | TPM_DECODE_END();
|
---|
562 | }
|
---|
563 |
|
---|
564 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeStartupShutdownReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
565 | {
|
---|
566 | RT_NOREF(pThis);
|
---|
567 |
|
---|
568 | TPM_DECODE_INIT();
|
---|
569 | TPM_DECODE_U16(u16TpmSu, u16State);
|
---|
570 |
|
---|
571 | if (u16TpmSu == TPM2_SU_CLEAR)
|
---|
572 | pHlp->pfnPrintf(pHlp, " TPM2_SU_CLEAR\n");
|
---|
573 | else if (u16TpmSu == TPM2_SU_STATE)
|
---|
574 | pHlp->pfnPrintf(pHlp, " TPM2_SU_STATE\n");
|
---|
575 | else
|
---|
576 | pHlp->pfnPrintf(pHlp, " Unknown: %#x\n", u16TpmSu);
|
---|
577 | TPM_DECODE_END();
|
---|
578 | }
|
---|
579 |
|
---|
580 |
|
---|
581 | static struct
|
---|
582 | {
|
---|
583 | const char *pszCap;
|
---|
584 | const uint32_t *paProperties;
|
---|
585 | } s_aTpm2Caps[] =
|
---|
586 | {
|
---|
587 | { RT_STR(TPM2_CAP_ALGS), NULL },
|
---|
588 | { RT_STR(TPM2_CAP_HANDLES), NULL },
|
---|
589 | { RT_STR(TPM2_CAP_COMMANDS), NULL },
|
---|
590 | { RT_STR(TPM2_CAP_PP_COMMANDS), NULL },
|
---|
591 | { RT_STR(TPM2_CAP_AUDIT_COMMANDS), NULL },
|
---|
592 | { RT_STR(TPM2_CAP_PCRS), NULL },
|
---|
593 | { RT_STR(TPM2_CAP_TPM_PROPERTIES), NULL },
|
---|
594 | { RT_STR(TPM2_CAP_PCR_PROPERTIES), NULL },
|
---|
595 | { RT_STR(TPM2_CAP_ECC_CURVES), NULL },
|
---|
596 | { RT_STR(TPM2_CAP_AUTH_POLICIES), NULL },
|
---|
597 | { RT_STR(TPM2_CAP_ACT), NULL },
|
---|
598 | };
|
---|
599 |
|
---|
600 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeGetCapabilityReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
601 | {
|
---|
602 | TPM_DECODE_INIT();
|
---|
603 | TPM_DECODE_U32(u32Cap, u32Cap);
|
---|
604 | TPM_DECODE_U32(u32Property, u32Property);
|
---|
605 | TPM_DECODE_U32(u32Count, u32Count);
|
---|
606 |
|
---|
607 | pThis->u.GetCapability.u32Cap = u32Cap;
|
---|
608 | pThis->u.GetCapability.u32Property = u32Property;
|
---|
609 | pThis->u.GetCapability.u32Count = u32Count;
|
---|
610 |
|
---|
611 | if (u32Cap < RT_ELEMENTS(s_aTpm2Caps))
|
---|
612 | pHlp->pfnPrintf(pHlp, " u32Cap: %s\n"
|
---|
613 | " u32Property: %#x\n"
|
---|
614 | " u32Count: %#x\n",
|
---|
615 | s_aTpm2Caps[u32Cap].pszCap, u32Property, u32Count);
|
---|
616 | else
|
---|
617 | pHlp->pfnPrintf(pHlp, " u32Cap: %#x (UNKNOWN)\n"
|
---|
618 | " u32Property: %#x\n"
|
---|
619 | " u32Count: %#x\n",
|
---|
620 | u32Cap, u32Property, u32Count);
|
---|
621 | TPM_DECODE_END();
|
---|
622 | }
|
---|
623 |
|
---|
624 |
|
---|
625 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeGetCapabilityResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
626 | {
|
---|
627 | RT_NOREF(pThis);
|
---|
628 |
|
---|
629 | TPM_DECODE_INIT();
|
---|
630 | TPM_DECODE_U8( fMoreData, fMoreData);
|
---|
631 | TPM_DECODE_U32(u32Cap, u32Cap);
|
---|
632 |
|
---|
633 | pHlp->pfnPrintf(pHlp, " fMoreData: %RTbool\n", fMoreData);
|
---|
634 | if (u32Cap < RT_ELEMENTS(s_aTpm2Caps))
|
---|
635 | {
|
---|
636 | pHlp->pfnPrintf(pHlp, " u32Cap: %s\n", s_aTpm2Caps[u32Cap]);
|
---|
637 | switch (u32Cap)
|
---|
638 | {
|
---|
639 | case TPM2_CAP_PCRS:
|
---|
640 | {
|
---|
641 | vboxTraceLogDecodePcrSelectionList(pHlp, pCtx);
|
---|
642 | break;
|
---|
643 | }
|
---|
644 | default:
|
---|
645 | break;
|
---|
646 | }
|
---|
647 | }
|
---|
648 | else
|
---|
649 | pHlp->pfnPrintf(pHlp, " u32Cap: %#x (UNKNOWN)\n", u32Cap);
|
---|
650 | TPM_DECODE_END();
|
---|
651 | }
|
---|
652 |
|
---|
653 |
|
---|
654 | static const char *g_apszHandlesReadPublicReq[] =
|
---|
655 | {
|
---|
656 | "hObj",
|
---|
657 | NULL
|
---|
658 | };
|
---|
659 |
|
---|
660 |
|
---|
661 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeReadPublicResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
662 | {
|
---|
663 | RT_NOREF(pThis);
|
---|
664 |
|
---|
665 | TPM_DECODE_INIT();
|
---|
666 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutPublic");
|
---|
667 | TPM_DECODE_END_IF_ERROR();
|
---|
668 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Name");
|
---|
669 | TPM_DECODE_END_IF_ERROR();
|
---|
670 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "QualifiedName");
|
---|
671 | TPM_DECODE_END_IF_ERROR();
|
---|
672 | TPM_DECODE_END();
|
---|
673 | }
|
---|
674 |
|
---|
675 |
|
---|
676 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeGetRandomReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
677 | {
|
---|
678 | TPM_DECODE_INIT();
|
---|
679 | TPM_DECODE_U16(u16RandomBytes, u16RandomBytes);
|
---|
680 | pThis->u.GetRandom.cbRnd = u16RandomBytes;
|
---|
681 | pHlp->pfnPrintf(pHlp, " u16RandomBytes: %u\n", pThis->u.GetRandom.cbRnd);
|
---|
682 | TPM_DECODE_END();
|
---|
683 | }
|
---|
684 |
|
---|
685 |
|
---|
686 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeGetRandomResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
687 | {
|
---|
688 | TPM_DECODE_INIT();
|
---|
689 | TPM_DECODE_U16(cbBuf, u16Size);
|
---|
690 | if (pThis->u.GetRandom.cbRnd != cbBuf)
|
---|
691 | {
|
---|
692 | pHlp->pfnErrorMsg(pHlp, "Requested random data size doesn't match returned data size (requested %u, returned %u), using smaller value\n",
|
---|
693 | pThis->u.GetRandom.cbRnd, cbBuf);
|
---|
694 | cbBuf = RT_MIN(cbBuf, pThis->u.GetRandom.cbRnd);
|
---|
695 | }
|
---|
696 |
|
---|
697 | TPM_DECODE_BUF(pb, RndBuf, cbBuf);
|
---|
698 | pHlp->pfnPrintf(pHlp, "%.*Rhxd\n", cbBuf, pb);
|
---|
699 | TPM_DECODE_END();
|
---|
700 | }
|
---|
701 |
|
---|
702 |
|
---|
703 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodePcrReadReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
704 | {
|
---|
705 | RT_NOREF(pThis);
|
---|
706 |
|
---|
707 | TPM_DECODE_INIT();
|
---|
708 | vboxTraceLogDecodePcrSelectionList(pHlp, pCtx);
|
---|
709 | TPM_DECODE_END();
|
---|
710 | }
|
---|
711 |
|
---|
712 |
|
---|
713 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodePcrReadResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
714 | {
|
---|
715 | RT_NOREF(pThis);
|
---|
716 |
|
---|
717 | TPM_DECODE_INIT();
|
---|
718 | TPM_DECODE_U32(u32PcrUpdateCounter, u32PcrUpdateCounter);
|
---|
719 | pHlp->pfnPrintf(pHlp, " u32PcrUpdateCounter: %u\n", u32PcrUpdateCounter);
|
---|
720 |
|
---|
721 | vboxTraceLogDecodePcrSelectionList(pHlp, pCtx);
|
---|
722 | TPM_DECODE_END_IF_ERROR();
|
---|
723 | vboxTraceLogDecodeEvtTpmDigestList(pHlp, pCtx);
|
---|
724 | TPM_DECODE_END();
|
---|
725 | }
|
---|
726 |
|
---|
727 |
|
---|
728 | static const char *g_apszHandlesPcrExtendReq[] =
|
---|
729 | {
|
---|
730 | "hPcr",
|
---|
731 | NULL
|
---|
732 | };
|
---|
733 |
|
---|
734 |
|
---|
735 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodePcrExtendReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
736 | {
|
---|
737 | RT_NOREF(pThis);
|
---|
738 |
|
---|
739 | TPM_DECODE_INIT();
|
---|
740 | vboxTraceLogDecodeEvtTpmDigestValuesList(pHlp, pCtx);
|
---|
741 | TPM_DECODE_END();
|
---|
742 | }
|
---|
743 |
|
---|
744 |
|
---|
745 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeReadClockResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
746 | {
|
---|
747 | RT_NOREF(pThis);
|
---|
748 |
|
---|
749 | TPM_DECODE_INIT();
|
---|
750 | TPM_DECODE_U64(u64Time, u64Time);
|
---|
751 | pHlp->pfnPrintf(pHlp, " u64Time: %RX64\n", u64Time);
|
---|
752 |
|
---|
753 | /* Decode TPMS_CLOCK_INFO. */
|
---|
754 | TPM_DECODE_U64(u64Clock, u64Clock);
|
---|
755 | TPM_DECODE_U32(u32ResetCount, u32ResetCount);
|
---|
756 | TPM_DECODE_U32(u32RestartCount, u32RestartCount);
|
---|
757 | TPM_DECODE_U8( fSafe, fSafe);
|
---|
758 | pHlp->pfnPrintf(pHlp, " u64Clock: %RX64\n", u64Clock);
|
---|
759 | pHlp->pfnPrintf(pHlp, " u32ResetCount: %u\n", u32ResetCount);
|
---|
760 | pHlp->pfnPrintf(pHlp, " u32RestartCount: %u\n", u32RestartCount);
|
---|
761 | pHlp->pfnPrintf(pHlp, " fSafe: %RTbool\n", fSafe);
|
---|
762 |
|
---|
763 | TPM_DECODE_END();
|
---|
764 | }
|
---|
765 |
|
---|
766 |
|
---|
767 | static const char *g_apszHandlesNvReadPublicReq[] =
|
---|
768 | {
|
---|
769 | "hNvIndex",
|
---|
770 | NULL
|
---|
771 | };
|
---|
772 |
|
---|
773 |
|
---|
774 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeNvReadPublicResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
775 | {
|
---|
776 | RT_NOREF(pThis);
|
---|
777 |
|
---|
778 | TPM_DECODE_INIT();
|
---|
779 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "NvPublic");
|
---|
780 | TPM_DECODE_END();
|
---|
781 | }
|
---|
782 |
|
---|
783 |
|
---|
784 | static const char *g_apszHandlesStartAuthSessionReq[] =
|
---|
785 | {
|
---|
786 | "hTpmKey",
|
---|
787 | "hBind",
|
---|
788 | NULL
|
---|
789 | };
|
---|
790 |
|
---|
791 |
|
---|
792 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeStartAuthSessionReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
793 | {
|
---|
794 | RT_NOREF(pThis);
|
---|
795 |
|
---|
796 | TPM_DECODE_INIT();
|
---|
797 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "NonceCaller");
|
---|
798 | TPM_DECODE_END_IF_ERROR();
|
---|
799 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "EncryptedSalt");
|
---|
800 | TPM_DECODE_END_IF_ERROR();
|
---|
801 |
|
---|
802 | TPM_DECODE_U8(u8SessionType, u8SessionType);
|
---|
803 | pHlp->pfnPrintf(pHlp, " u8SessionType: %#x\n", u8SessionType);
|
---|
804 |
|
---|
805 | vboxTraceLogDecodeSymEncDef(pHlp, pCtx, "Symmetric");
|
---|
806 | TPM_DECODE_END_IF_ERROR();
|
---|
807 |
|
---|
808 | TPM_DECODE_U16(u16HashAlg, u16HashAlg);
|
---|
809 | pHlp->pfnPrintf(pHlp, " u16HashAlg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16HashAlg));
|
---|
810 | TPM_DECODE_END();
|
---|
811 | }
|
---|
812 |
|
---|
813 |
|
---|
814 | static const char *g_apszHandlesStartAuthSessionResp[] =
|
---|
815 | {
|
---|
816 | "hSession",
|
---|
817 | NULL
|
---|
818 | };
|
---|
819 |
|
---|
820 |
|
---|
821 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeStartAuthSessionResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
822 | {
|
---|
823 | RT_NOREF(pThis);
|
---|
824 |
|
---|
825 | TPM_DECODE_INIT();
|
---|
826 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "NonceTpm");
|
---|
827 | TPM_DECODE_END();
|
---|
828 | }
|
---|
829 |
|
---|
830 |
|
---|
831 | static const char *g_apszHandlesHierarchyChangeAuthReq[] =
|
---|
832 | {
|
---|
833 | "hAuth",
|
---|
834 | NULL
|
---|
835 | };
|
---|
836 |
|
---|
837 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeHierarchyChangeAuthReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
838 | {
|
---|
839 | RT_NOREF(pThis);
|
---|
840 |
|
---|
841 | TPM_DECODE_INIT();
|
---|
842 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "NewAuth");
|
---|
843 | TPM_DECODE_END();
|
---|
844 | }
|
---|
845 |
|
---|
846 |
|
---|
847 | static const char *g_apszHandlesNvDefineSpaceReq[] =
|
---|
848 | {
|
---|
849 | "hAuth",
|
---|
850 | NULL
|
---|
851 | };
|
---|
852 |
|
---|
853 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeNvDefineSpaceReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
854 | {
|
---|
855 | RT_NOREF(pThis);
|
---|
856 |
|
---|
857 | TPM_DECODE_INIT();
|
---|
858 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Auth");
|
---|
859 | TPM_DECODE_END_IF_ERROR();
|
---|
860 |
|
---|
861 | vboxTraceLogDecodeNvPublic(pHlp, pCtx, "PublicInfo");
|
---|
862 | TPM_DECODE_END();
|
---|
863 | }
|
---|
864 |
|
---|
865 |
|
---|
866 | static const char *g_apszHandlesSetPrimaryPolicyReq[] =
|
---|
867 | {
|
---|
868 | "hAuth",
|
---|
869 | NULL
|
---|
870 | };
|
---|
871 |
|
---|
872 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeSetPrimaryPolicyReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
873 | {
|
---|
874 | RT_NOREF(pThis);
|
---|
875 |
|
---|
876 | TPM_DECODE_INIT();
|
---|
877 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "AuthPolicy");
|
---|
878 | TPM_DECODE_END_IF_ERROR();
|
---|
879 |
|
---|
880 | TPM_DECODE_U16(u16HashAlg, u16HashAlg);
|
---|
881 | pHlp->pfnPrintf(pHlp, " u16HashAlg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16HashAlg));
|
---|
882 | TPM_DECODE_END();
|
---|
883 | }
|
---|
884 |
|
---|
885 |
|
---|
886 | static const char *g_apszHandlesCreatePrimaryReq[] =
|
---|
887 | {
|
---|
888 | "hPrimary",
|
---|
889 | NULL
|
---|
890 | };
|
---|
891 |
|
---|
892 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCreatePrimaryReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
893 | {
|
---|
894 | RT_NOREF(pThis);
|
---|
895 |
|
---|
896 | TPM_DECODE_INIT();
|
---|
897 | /** @todo Decode InSensitive. */
|
---|
898 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "InSensitive");
|
---|
899 | TPM_DECODE_END_IF_ERROR();
|
---|
900 | /** @todo Decode InPublic. */
|
---|
901 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "InPublic");
|
---|
902 | TPM_DECODE_END_IF_ERROR();
|
---|
903 |
|
---|
904 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutsideInfo");
|
---|
905 | TPM_DECODE_END_IF_ERROR();
|
---|
906 |
|
---|
907 | vboxTraceLogDecodePcrSelectionList(pHlp, pCtx);
|
---|
908 |
|
---|
909 | TPM_DECODE_END();
|
---|
910 | }
|
---|
911 |
|
---|
912 |
|
---|
913 | static const char *g_apszHandlesCreatePrimaryResp[] =
|
---|
914 | {
|
---|
915 | "hObj",
|
---|
916 | NULL
|
---|
917 | };
|
---|
918 |
|
---|
919 |
|
---|
920 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCreatePrimaryResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
921 | {
|
---|
922 | RT_NOREF(pThis);
|
---|
923 |
|
---|
924 | TPM_DECODE_INIT();
|
---|
925 | /** @todo Decode OutPublic. */
|
---|
926 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutPublic");
|
---|
927 | TPM_DECODE_END_IF_ERROR();
|
---|
928 | /** @todo Decode CreationData. */
|
---|
929 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CreationData");
|
---|
930 | TPM_DECODE_END_IF_ERROR();
|
---|
931 |
|
---|
932 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CreationHash");
|
---|
933 | TPM_DECODE_END_IF_ERROR();
|
---|
934 |
|
---|
935 | vboxTraceLogDecodeTicket(pHlp, pCtx, "Ticket");
|
---|
936 | TPM_DECODE_END_IF_ERROR();
|
---|
937 |
|
---|
938 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Name");
|
---|
939 | TPM_DECODE_END();
|
---|
940 | }
|
---|
941 |
|
---|
942 |
|
---|
943 | static const char *g_apszHandlesNvIncrementReq[] =
|
---|
944 | {
|
---|
945 | "hAuth",
|
---|
946 | "hNvIndex",
|
---|
947 | NULL
|
---|
948 | };
|
---|
949 |
|
---|
950 |
|
---|
951 | static const char *g_apszHandlesNvSetBitsReq[] =
|
---|
952 | {
|
---|
953 | "hAuth",
|
---|
954 | "hNvIndex",
|
---|
955 | NULL
|
---|
956 | };
|
---|
957 |
|
---|
958 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeNvSetBitsReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
959 | {
|
---|
960 | RT_NOREF(pThis);
|
---|
961 |
|
---|
962 | TPM_DECODE_INIT();
|
---|
963 | TPM_DECODE_U64(u64BitsOr, u64BitsOr);
|
---|
964 | pHlp->pfnPrintf(pHlp, " u64BitsOr: %#RX64\n", u64BitsOr);
|
---|
965 | TPM_DECODE_END();
|
---|
966 | }
|
---|
967 |
|
---|
968 |
|
---|
969 | static const char *g_apszHandlesNvWriteReq[] =
|
---|
970 | {
|
---|
971 | "hAuth",
|
---|
972 | "hNvIndex",
|
---|
973 | NULL
|
---|
974 | };
|
---|
975 |
|
---|
976 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeNvWriteReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
977 | {
|
---|
978 | RT_NOREF(pThis);
|
---|
979 |
|
---|
980 | TPM_DECODE_INIT();
|
---|
981 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Data");
|
---|
982 | TPM_DECODE_END_IF_ERROR();
|
---|
983 |
|
---|
984 | TPM_DECODE_U16(u16Offset, u16Offset);
|
---|
985 | pHlp->pfnPrintf(pHlp, " u16Offset: %u\n", u16Offset);
|
---|
986 | TPM_DECODE_END();
|
---|
987 | }
|
---|
988 |
|
---|
989 |
|
---|
990 | static const char *g_apszHandlesDictionaryAttackParametersReq[] =
|
---|
991 | {
|
---|
992 | "hLock",
|
---|
993 | NULL
|
---|
994 | };
|
---|
995 |
|
---|
996 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeDictionaryAttackParametersReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
997 | {
|
---|
998 | RT_NOREF(pThis);
|
---|
999 |
|
---|
1000 | TPM_DECODE_INIT();
|
---|
1001 | TPM_DECODE_U32(u32NewMaxTries, u32NewMaxTries);
|
---|
1002 | TPM_DECODE_U32(u32NewRecoveryTime, u32NewRecoveryTime);
|
---|
1003 | TPM_DECODE_U32(u32LockoutRecovery, u32LockoutRecovery);
|
---|
1004 |
|
---|
1005 | pHlp->pfnPrintf(pHlp, " u32NewMaxTries: %u\n", u32NewMaxTries);
|
---|
1006 | pHlp->pfnPrintf(pHlp, " u32NewRecoveryTime: %u\n", u32NewRecoveryTime);
|
---|
1007 | pHlp->pfnPrintf(pHlp, " u32LockoutRecovery: %u\n", u32LockoutRecovery);
|
---|
1008 | TPM_DECODE_END();
|
---|
1009 | }
|
---|
1010 |
|
---|
1011 |
|
---|
1012 | static const char *g_apszHandlesCertifyCreationReq[] =
|
---|
1013 | {
|
---|
1014 | "hSign",
|
---|
1015 | "hObj",
|
---|
1016 | NULL
|
---|
1017 | };
|
---|
1018 |
|
---|
1019 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCertifyCreationReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1020 | {
|
---|
1021 | RT_NOREF(pThis);
|
---|
1022 |
|
---|
1023 | TPM_DECODE_INIT();
|
---|
1024 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "QualifyingData");
|
---|
1025 | TPM_DECODE_END_IF_ERROR();
|
---|
1026 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CreationHash");
|
---|
1027 | TPM_DECODE_END_IF_ERROR();
|
---|
1028 |
|
---|
1029 | TPM_DECODE_U16(u16SigningScheme, u16SigningScheme);
|
---|
1030 | pHlp->pfnPrintf(pHlp, " u16SigningScheme: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16SigningScheme));
|
---|
1031 |
|
---|
1032 | vboxTraceLogDecodeTicket(pHlp, pCtx, "CreationTicket");
|
---|
1033 | TPM_DECODE_END();
|
---|
1034 | }
|
---|
1035 |
|
---|
1036 |
|
---|
1037 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCertifyCreationResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1038 | {
|
---|
1039 | RT_NOREF(pThis);
|
---|
1040 |
|
---|
1041 | TPM_DECODE_INIT();
|
---|
1042 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CertifyInfo");
|
---|
1043 |
|
---|
1044 | /* Decode TPMT_SIGNATURE */
|
---|
1045 | TPM_DECODE_U16(u16SigningAlg, u16SigningAlg);
|
---|
1046 | pHlp->pfnPrintf(pHlp, " u16SigningAlg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16SigningAlg));
|
---|
1047 | TPM_DECODE_U16(u16HashAlg, u16HashAlg);
|
---|
1048 | pHlp->pfnPrintf(pHlp, " u16HashAlg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16HashAlg));
|
---|
1049 |
|
---|
1050 | TPM_DECODE_END();
|
---|
1051 | }
|
---|
1052 |
|
---|
1053 |
|
---|
1054 | static const char *g_apszHandlesNvReadReq[] =
|
---|
1055 | {
|
---|
1056 | "hAuth",
|
---|
1057 | "hNvIndex",
|
---|
1058 | NULL
|
---|
1059 | };
|
---|
1060 |
|
---|
1061 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeNvReadReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1062 | {
|
---|
1063 | RT_NOREF(pThis);
|
---|
1064 |
|
---|
1065 | TPM_DECODE_INIT();
|
---|
1066 | TPM_DECODE_U16(u16Size, u16Size);
|
---|
1067 | pHlp->pfnPrintf(pHlp, " u16Size: %u\n", u16Size);
|
---|
1068 | TPM_DECODE_U16(u16Offset, u16Offset);
|
---|
1069 | pHlp->pfnPrintf(pHlp, " u16Offset: %u\n", u16Offset);
|
---|
1070 | TPM_DECODE_END();
|
---|
1071 | }
|
---|
1072 |
|
---|
1073 |
|
---|
1074 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeNvReadResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1075 | {
|
---|
1076 | RT_NOREF(pThis);
|
---|
1077 |
|
---|
1078 | TPM_DECODE_INIT();
|
---|
1079 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Data");
|
---|
1080 | TPM_DECODE_END();
|
---|
1081 | }
|
---|
1082 |
|
---|
1083 |
|
---|
1084 | static const char *g_apszHandlesPolicySecretReq[] =
|
---|
1085 | {
|
---|
1086 | "hAuth",
|
---|
1087 | "hPolicySession",
|
---|
1088 | NULL
|
---|
1089 | };
|
---|
1090 |
|
---|
1091 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodePolicySecretReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1092 | {
|
---|
1093 | RT_NOREF(pThis);
|
---|
1094 |
|
---|
1095 | TPM_DECODE_INIT();
|
---|
1096 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "NonceTpm");
|
---|
1097 | TPM_DECODE_END_IF_ERROR();
|
---|
1098 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CpHashA");
|
---|
1099 | TPM_DECODE_END_IF_ERROR();
|
---|
1100 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "PolicyRef");
|
---|
1101 | TPM_DECODE_END_IF_ERROR();
|
---|
1102 |
|
---|
1103 | TPM_DECODE_I32(i32Expiration, i32Expiration);
|
---|
1104 | pHlp->pfnPrintf(pHlp, " i32Expiration: %u\n", i32Expiration);
|
---|
1105 | TPM_DECODE_END();
|
---|
1106 | }
|
---|
1107 |
|
---|
1108 |
|
---|
1109 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodePolicySecretResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1110 | {
|
---|
1111 | RT_NOREF(pThis);
|
---|
1112 |
|
---|
1113 | TPM_DECODE_INIT();
|
---|
1114 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Timeout");
|
---|
1115 | TPM_DECODE_END_IF_ERROR();
|
---|
1116 |
|
---|
1117 | vboxTraceLogDecodeTicket(pHlp, pCtx, "Ticket");
|
---|
1118 | TPM_DECODE_END();
|
---|
1119 | }
|
---|
1120 |
|
---|
1121 |
|
---|
1122 | static const char *g_apszHandlesCreateReq[] =
|
---|
1123 | {
|
---|
1124 | "hParent",
|
---|
1125 | NULL
|
---|
1126 | };
|
---|
1127 |
|
---|
1128 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCreateReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1129 | {
|
---|
1130 | RT_NOREF(pThis);
|
---|
1131 |
|
---|
1132 | TPM_DECODE_INIT();
|
---|
1133 | /** @todo Decode InSensitive. */
|
---|
1134 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "InSensitive");
|
---|
1135 | TPM_DECODE_END_IF_ERROR();
|
---|
1136 | /** @todo Decode InPublic. */
|
---|
1137 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "InPublic");
|
---|
1138 | TPM_DECODE_END_IF_ERROR();
|
---|
1139 |
|
---|
1140 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutsideInfo");
|
---|
1141 | TPM_DECODE_END_IF_ERROR();
|
---|
1142 |
|
---|
1143 | vboxTraceLogDecodePcrSelectionList(pHlp, pCtx);
|
---|
1144 |
|
---|
1145 | TPM_DECODE_END();
|
---|
1146 | }
|
---|
1147 |
|
---|
1148 |
|
---|
1149 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCreateResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1150 | {
|
---|
1151 | RT_NOREF(pThis);
|
---|
1152 |
|
---|
1153 | TPM_DECODE_INIT();
|
---|
1154 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutPrivate");
|
---|
1155 | TPM_DECODE_END_IF_ERROR();
|
---|
1156 | /** @todo Decode OutPublic. */
|
---|
1157 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutPublic");
|
---|
1158 | TPM_DECODE_END_IF_ERROR();
|
---|
1159 | /** @todo Decode CreationData. */
|
---|
1160 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CreationData");
|
---|
1161 | TPM_DECODE_END_IF_ERROR();
|
---|
1162 |
|
---|
1163 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CreationHash");
|
---|
1164 | TPM_DECODE_END_IF_ERROR();
|
---|
1165 |
|
---|
1166 | vboxTraceLogDecodeTicket(pHlp, pCtx, "Ticket");
|
---|
1167 | TPM_DECODE_END();
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 |
|
---|
1171 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeEccParametersReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1172 | {
|
---|
1173 | RT_NOREF(pThis);
|
---|
1174 |
|
---|
1175 | TPM_DECODE_INIT();
|
---|
1176 | TPM_DECODE_U16(u16CurveId, u16CurveId);
|
---|
1177 | pHlp->pfnPrintf(pHlp, " u16CurveId: %#x\n", u16CurveId);
|
---|
1178 | TPM_DECODE_END();
|
---|
1179 | }
|
---|
1180 |
|
---|
1181 |
|
---|
1182 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeEccParametersResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1183 | {
|
---|
1184 | RT_NOREF(pThis);
|
---|
1185 |
|
---|
1186 | TPM_DECODE_INIT();
|
---|
1187 | TPM_DECODE_U16(u16CurveId, u16CurveId);
|
---|
1188 | TPM_DECODE_U16(u16KeySize, u16KeySize);
|
---|
1189 | TPM_DECODE_U16(u16KdfScheme, u16KdfScheme);
|
---|
1190 | TPM_DECODE_U16(u16KdfSchemeHash, u16KdfSchemeHash);
|
---|
1191 | TPM_DECODE_U16(u16EccScheme, u16EccScheme);
|
---|
1192 |
|
---|
1193 | pHlp->pfnPrintf(pHlp, " u16CurveId: %#x\n", u16CurveId);
|
---|
1194 | pHlp->pfnPrintf(pHlp, " u16KeySize: %u\n", u16KeySize);
|
---|
1195 | pHlp->pfnPrintf(pHlp, " u16KdfScheme: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16KdfScheme));
|
---|
1196 | pHlp->pfnPrintf(pHlp, " u16KdfSchemeHash: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16KdfSchemeHash));
|
---|
1197 | pHlp->pfnPrintf(pHlp, " u16EccScheme: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16EccScheme));
|
---|
1198 | if (u16EccScheme != TPM2_ALG_NULL)
|
---|
1199 | {
|
---|
1200 | TPM_DECODE_U16(u16EccSchemeHash, u16EccSchemeHash);
|
---|
1201 | pHlp->pfnPrintf(pHlp, " u16EccSchemeHash: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16EccSchemeHash));
|
---|
1202 | }
|
---|
1203 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "p");
|
---|
1204 | TPM_DECODE_END_IF_ERROR();
|
---|
1205 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "a");
|
---|
1206 | TPM_DECODE_END_IF_ERROR();
|
---|
1207 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "b");
|
---|
1208 | TPM_DECODE_END_IF_ERROR();
|
---|
1209 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "gX");
|
---|
1210 | TPM_DECODE_END_IF_ERROR();
|
---|
1211 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "gY");
|
---|
1212 | TPM_DECODE_END_IF_ERROR();
|
---|
1213 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "n");
|
---|
1214 | TPM_DECODE_END_IF_ERROR();
|
---|
1215 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "h");
|
---|
1216 | TPM_DECODE_END_IF_ERROR();
|
---|
1217 | TPM_DECODE_END();
|
---|
1218 | }
|
---|
1219 |
|
---|
1220 |
|
---|
1221 | static const char *g_apszHandlesQuoteReq[] =
|
---|
1222 | {
|
---|
1223 | "hSign",
|
---|
1224 | NULL
|
---|
1225 | };
|
---|
1226 |
|
---|
1227 |
|
---|
1228 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeQuoteReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1229 | {
|
---|
1230 | RT_NOREF(pThis);
|
---|
1231 |
|
---|
1232 | TPM_DECODE_INIT();
|
---|
1233 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "QualifyingData");
|
---|
1234 | TPM_DECODE_END_IF_ERROR();
|
---|
1235 |
|
---|
1236 | TPM_DECODE_U16(u16SigScheme, u16SigScheme);
|
---|
1237 | pHlp->pfnPrintf(pHlp, " u16SigScheme: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16SigScheme));
|
---|
1238 | if (u16SigScheme != TPM2_ALG_NULL)
|
---|
1239 | {
|
---|
1240 | TPM_DECODE_U16(u16SigSchemeHash, u16SigSchemeHash);
|
---|
1241 | pHlp->pfnPrintf(pHlp, " u16SigSchemeHash: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16SigSchemeHash));
|
---|
1242 | }
|
---|
1243 |
|
---|
1244 | vboxTraceLogDecodePcrSelectionList(pHlp, pCtx);
|
---|
1245 | TPM_DECODE_END();
|
---|
1246 | }
|
---|
1247 |
|
---|
1248 |
|
---|
1249 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeQuoteResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1250 | {
|
---|
1251 | RT_NOREF(pThis);
|
---|
1252 |
|
---|
1253 | TPM_DECODE_INIT();
|
---|
1254 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Quoted");
|
---|
1255 | TPM_DECODE_END_IF_ERROR();
|
---|
1256 |
|
---|
1257 | TPM_DECODE_U16(u16SigAlg, u16SigAlg);
|
---|
1258 | pHlp->pfnPrintf(pHlp, " u16SigAlg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16SigAlg));
|
---|
1259 | if (u16SigAlg != TPM2_ALG_NULL)
|
---|
1260 | {
|
---|
1261 | TPM_DECODE_U16(u16SigAlgHash, u16SigAlgHash);
|
---|
1262 | pHlp->pfnPrintf(pHlp, " u16SigAlgHash: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16SigAlgHash));
|
---|
1263 | }
|
---|
1264 | TPM_DECODE_END();
|
---|
1265 | }
|
---|
1266 |
|
---|
1267 |
|
---|
1268 | static const char *g_apszHandlesHmacMacReq[] =
|
---|
1269 | {
|
---|
1270 | "hSymKey",
|
---|
1271 | NULL
|
---|
1272 | };
|
---|
1273 |
|
---|
1274 |
|
---|
1275 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeHmacMacReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1276 | {
|
---|
1277 | RT_NOREF(pThis);
|
---|
1278 |
|
---|
1279 | TPM_DECODE_INIT();
|
---|
1280 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Buffer");
|
---|
1281 | TPM_DECODE_END_IF_ERROR();
|
---|
1282 |
|
---|
1283 | TPM_DECODE_U16(u16HashAlg, u16HashAlg);
|
---|
1284 | pHlp->pfnPrintf(pHlp, " u16HashAlg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16HashAlg));
|
---|
1285 | TPM_DECODE_END();
|
---|
1286 | }
|
---|
1287 |
|
---|
1288 |
|
---|
1289 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeHmacMacResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1290 | {
|
---|
1291 | RT_NOREF(pThis);
|
---|
1292 |
|
---|
1293 | TPM_DECODE_INIT();
|
---|
1294 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutHmacMac");
|
---|
1295 | TPM_DECODE_END();
|
---|
1296 | }
|
---|
1297 |
|
---|
1298 |
|
---|
1299 | static const char *g_apszHandlesFlushContextReq[] =
|
---|
1300 | {
|
---|
1301 | "hFlush",
|
---|
1302 | NULL
|
---|
1303 | };
|
---|
1304 |
|
---|
1305 |
|
---|
1306 | static const char *g_apszHandlesLoadReq[] =
|
---|
1307 | {
|
---|
1308 | "hParent",
|
---|
1309 | NULL
|
---|
1310 | };
|
---|
1311 |
|
---|
1312 |
|
---|
1313 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeLoadReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1314 | {
|
---|
1315 | RT_NOREF(pThis);
|
---|
1316 |
|
---|
1317 | TPM_DECODE_INIT();
|
---|
1318 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "InPrivate");
|
---|
1319 | TPM_DECODE_END_IF_ERROR();
|
---|
1320 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "InPublic");
|
---|
1321 | TPM_DECODE_END_IF_ERROR();
|
---|
1322 | TPM_DECODE_END();
|
---|
1323 | }
|
---|
1324 |
|
---|
1325 |
|
---|
1326 | static const char *g_apszHandlesLoadResp[] =
|
---|
1327 | {
|
---|
1328 | "hObj",
|
---|
1329 | NULL
|
---|
1330 | };
|
---|
1331 |
|
---|
1332 |
|
---|
1333 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeLoadResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1334 | {
|
---|
1335 | RT_NOREF(pThis);
|
---|
1336 |
|
---|
1337 | TPM_DECODE_INIT();
|
---|
1338 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Name");
|
---|
1339 | TPM_DECODE_END_IF_ERROR();
|
---|
1340 | TPM_DECODE_END();
|
---|
1341 | }
|
---|
1342 |
|
---|
1343 |
|
---|
1344 | static struct
|
---|
1345 | {
|
---|
1346 | uint32_t u32CmdCode;
|
---|
1347 | const char *pszCmdCode;
|
---|
1348 | const char **papszHandlesReq;
|
---|
1349 | const char **papszHandlesResp;
|
---|
1350 | PFNFNDECODETPM2CCREQ pfnDecodeReq;
|
---|
1351 | PFNFNDECODETPM2CCRESP pfnDecodeResp;
|
---|
1352 | } s_aTpmCmdCodes[] =
|
---|
1353 | {
|
---|
1354 | #define TPM_CMD_CODE_INIT_NOT_IMPL(a_CmdCode) { a_CmdCode, #a_CmdCode, NULL, NULL, NULL, NULL }
|
---|
1355 | #define TPM_CMD_CODE_INIT(a_CmdCode, a_apszHandlesReq, a_apszHandlesResp, a_pfnReq, a_pfnResp) { a_CmdCode, #a_CmdCode, \
|
---|
1356 | a_apszHandlesReq, a_apszHandlesResp, \
|
---|
1357 | a_pfnReq, a_pfnResp }
|
---|
1358 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_UNDEFINE_SPACE_SPECIAL),
|
---|
1359 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_EVICT_CONTROL),
|
---|
1360 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_HIERARCHY_CONTROL),
|
---|
1361 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_UNDEFINE_SPACE),
|
---|
1362 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_CHANGE_EPS),
|
---|
1363 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_CHANGE_PPS),
|
---|
1364 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_CLEAR),
|
---|
1365 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_CLEAR_CONTROL),
|
---|
1366 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_CLOCK_SET),
|
---|
1367 | TPM_CMD_CODE_INIT( TPM2_CC_HIERARCHY_CHANGE_AUTH, g_apszHandlesHierarchyChangeAuthReq, NULL, vboxTraceLogDecodeEvtTpmDecodeHierarchyChangeAuthReq, NULL),
|
---|
1368 | TPM_CMD_CODE_INIT( TPM2_CC_NV_DEFINE_SPACE, g_apszHandlesNvDefineSpaceReq, NULL, vboxTraceLogDecodeEvtTpmDecodeNvDefineSpaceReq, NULL),
|
---|
1369 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_PCR_ALLOCATE),
|
---|
1370 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_PCR_SET_AUTH_POLICY),
|
---|
1371 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_PP_COMMANDS),
|
---|
1372 | TPM_CMD_CODE_INIT( TPM2_CC_SET_PRIMARY_POLICY, g_apszHandlesSetPrimaryPolicyReq, NULL, vboxTraceLogDecodeEvtTpmDecodeSetPrimaryPolicyReq, NULL),
|
---|
1373 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_FIELD_UPGRADE_START),
|
---|
1374 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_CLOCK_RATE_ADJUST),
|
---|
1375 | TPM_CMD_CODE_INIT( TPM2_CC_CREATE_PRIMARY, g_apszHandlesCreatePrimaryReq, g_apszHandlesCreatePrimaryResp, vboxTraceLogDecodeEvtTpmDecodeCreatePrimaryReq, vboxTraceLogDecodeEvtTpmDecodeCreatePrimaryResp),
|
---|
1376 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_GLOBAL_WRITE_LOCK),
|
---|
1377 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_GET_COMMAND_AUDIT_DIGEST),
|
---|
1378 | TPM_CMD_CODE_INIT( TPM2_CC_NV_INCREMENT, g_apszHandlesNvIncrementReq, NULL, NULL, NULL),
|
---|
1379 | TPM_CMD_CODE_INIT( TPM2_CC_NV_SET_BITS, g_apszHandlesNvSetBitsReq, NULL, vboxTraceLogDecodeEvtTpmDecodeNvSetBitsReq, NULL),
|
---|
1380 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_EXTEND),
|
---|
1381 | TPM_CMD_CODE_INIT( TPM2_CC_NV_WRITE, g_apszHandlesNvWriteReq, NULL, vboxTraceLogDecodeEvtTpmDecodeNvWriteReq, NULL),
|
---|
1382 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_WRITE_LOCK),
|
---|
1383 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_DICTIONARY_ATTACK_LOCK_RESET),
|
---|
1384 | TPM_CMD_CODE_INIT( TPM2_CC_DICTIONARY_ATTACK_PARAMETERS, g_apszHandlesDictionaryAttackParametersReq, NULL, vboxTraceLogDecodeEvtTpmDecodeDictionaryAttackParametersReq, NULL),
|
---|
1385 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_CHANGE_AUTH),
|
---|
1386 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_PCR_EVENT),
|
---|
1387 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_PCR_RESET),
|
---|
1388 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_SEQUENCE_COMPLETE),
|
---|
1389 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_SET_ALGORITHM_SET),
|
---|
1390 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_SET_COMMAND_CODE_AUDIT_STATUS),
|
---|
1391 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_FIELD_UPGRADE_DATA),
|
---|
1392 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_INCREMENTAL_SELF_TEST),
|
---|
1393 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_SELF_TEST),
|
---|
1394 | TPM_CMD_CODE_INIT( TPM2_CC_STARTUP, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeStartupShutdownReq, NULL),
|
---|
1395 | TPM_CMD_CODE_INIT( TPM2_CC_SHUTDOWN, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeStartupShutdownReq, NULL),
|
---|
1396 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_STIR_RANDOM),
|
---|
1397 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ACTIVATE_CREDENTIAL),
|
---|
1398 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_CERTIFY),
|
---|
1399 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_NV),
|
---|
1400 | TPM_CMD_CODE_INIT( TPM2_CC_CERTIFY_CREATION, g_apszHandlesCertifyCreationReq, NULL, vboxTraceLogDecodeEvtTpmDecodeCertifyCreationReq, vboxTraceLogDecodeEvtTpmDecodeCertifyCreationResp),
|
---|
1401 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_DUPLICATE),
|
---|
1402 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_GET_TIME),
|
---|
1403 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_GET_SESSION_AUDIT_DIGEST),
|
---|
1404 | TPM_CMD_CODE_INIT( TPM2_CC_NV_READ, g_apszHandlesNvReadReq, NULL, vboxTraceLogDecodeEvtTpmDecodeNvReadReq, vboxTraceLogDecodeEvtTpmDecodeNvReadResp),
|
---|
1405 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_READ_LOCK),
|
---|
1406 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_OBJECT_CHANGE_AUTH),
|
---|
1407 | TPM_CMD_CODE_INIT( TPM2_CC_POLICY_SECRET, g_apszHandlesPolicySecretReq, NULL, vboxTraceLogDecodeEvtTpmDecodePolicySecretReq, vboxTraceLogDecodeEvtTpmDecodePolicySecretResp),
|
---|
1408 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_REWRAP),
|
---|
1409 | TPM_CMD_CODE_INIT( TPM2_CC_CREATE, g_apszHandlesCreateReq, NULL, vboxTraceLogDecodeEvtTpmDecodeCreateReq, vboxTraceLogDecodeEvtTpmDecodeCreateResp),
|
---|
1410 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ECDH_ZGEN),
|
---|
1411 | TPM_CMD_CODE_INIT( TPM2_CC_HMAC_MAC, g_apszHandlesHmacMacReq, NULL, vboxTraceLogDecodeEvtTpmDecodeHmacMacReq, vboxTraceLogDecodeEvtTpmDecodeHmacMacResp),
|
---|
1412 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_IMPORT),
|
---|
1413 | TPM_CMD_CODE_INIT( TPM2_CC_LOAD, g_apszHandlesLoadReq, g_apszHandlesLoadResp, vboxTraceLogDecodeEvtTpmDecodeLoadReq, vboxTraceLogDecodeEvtTpmDecodeLoadResp),
|
---|
1414 | TPM_CMD_CODE_INIT( TPM2_CC_QUOTE, g_apszHandlesQuoteReq, NULL, vboxTraceLogDecodeEvtTpmDecodeQuoteReq, vboxTraceLogDecodeEvtTpmDecodeQuoteResp),
|
---|
1415 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_RSA_DECRYPT),
|
---|
1416 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_HMAC_MAC_START),
|
---|
1417 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_SEQUENCE_UPDATE),
|
---|
1418 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_SIGN),
|
---|
1419 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_UNSEAL),
|
---|
1420 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_SIGNED),
|
---|
1421 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_CONTEXT_LOAD),
|
---|
1422 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_CONTEXT_SAVE),
|
---|
1423 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ECDH_KEY_GEN),
|
---|
1424 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ENCRYPT_DECRYPT),
|
---|
1425 | TPM_CMD_CODE_INIT( TPM2_CC_FLUSH_CONTEXT, g_apszHandlesFlushContextReq, NULL, NULL, NULL),
|
---|
1426 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_LOAD_EXTERNAL),
|
---|
1427 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_MAKE_CREDENTIAL),
|
---|
1428 | TPM_CMD_CODE_INIT( TPM2_CC_NV_READ_PUBLIC, g_apszHandlesNvReadPublicReq, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeNvReadPublicResp),
|
---|
1429 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_AUTHORIZE),
|
---|
1430 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_AUTH_VALUE),
|
---|
1431 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_COMMAND_CODE),
|
---|
1432 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_COUNTER_TIMER),
|
---|
1433 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_CP_HASH),
|
---|
1434 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_LOCALITY),
|
---|
1435 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_NAME_HASH),
|
---|
1436 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_OR),
|
---|
1437 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_TICKET),
|
---|
1438 | TPM_CMD_CODE_INIT( TPM2_CC_READ_PUBLIC, g_apszHandlesReadPublicReq, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeReadPublicResp),
|
---|
1439 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_RSA_ENCRYPT),
|
---|
1440 | TPM_CMD_CODE_INIT( TPM2_CC_START_AUTH_SESSION, g_apszHandlesStartAuthSessionReq, g_apszHandlesStartAuthSessionResp, vboxTraceLogDecodeEvtTpmDecodeStartAuthSessionReq, vboxTraceLogDecodeEvtTpmDecodeStartAuthSessionResp),
|
---|
1441 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_VERIFY_SIGNATURE),
|
---|
1442 | TPM_CMD_CODE_INIT( TPM2_CC_ECC_PARAMETERS, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeEccParametersReq, vboxTraceLogDecodeEvtTpmDecodeEccParametersResp),
|
---|
1443 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_FIRMWARE_READ),
|
---|
1444 | TPM_CMD_CODE_INIT( TPM2_CC_GET_CAPABILITY, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeGetCapabilityReq, vboxTraceLogDecodeEvtTpmDecodeGetCapabilityResp),
|
---|
1445 | TPM_CMD_CODE_INIT( TPM2_CC_GET_RANDOM, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeGetRandomReq, vboxTraceLogDecodeEvtTpmDecodeGetRandomResp),
|
---|
1446 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_GET_TEST_RESULT),
|
---|
1447 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_GET_HASH),
|
---|
1448 | TPM_CMD_CODE_INIT( TPM2_CC_PCR_READ, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodePcrReadReq, vboxTraceLogDecodeEvtTpmDecodePcrReadResp),
|
---|
1449 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_PCR),
|
---|
1450 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_RESTART),
|
---|
1451 | TPM_CMD_CODE_INIT( TPM2_CC_READ_CLOCK, NULL, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeReadClockResp),
|
---|
1452 | TPM_CMD_CODE_INIT( TPM2_CC_PCR_EXTEND, g_apszHandlesPcrExtendReq, NULL, vboxTraceLogDecodeEvtTpmDecodePcrExtendReq, NULL),
|
---|
1453 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_PCR_SET_AUTH_VALUE),
|
---|
1454 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_CERTIFY),
|
---|
1455 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_EVENT_SEQUENCE_COMPLETE),
|
---|
1456 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_HASH_SEQUENCE_START),
|
---|
1457 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_PHYSICAL_PRESENCE),
|
---|
1458 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_DUPLICATION_SELECT),
|
---|
1459 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_GET_DIGEST),
|
---|
1460 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_TEST_PARMS),
|
---|
1461 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_COMMIT),
|
---|
1462 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_PASSWORD),
|
---|
1463 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ZGEN_2PHASE),
|
---|
1464 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_EC_EPHEMERAL),
|
---|
1465 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_NV_WRITTEN),
|
---|
1466 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_TEMPLATE),
|
---|
1467 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_CREATE_LOADED),
|
---|
1468 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_AUTHORIZE_NV),
|
---|
1469 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ENCRYPT_DECRYPT_2),
|
---|
1470 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_AC_GET_CAPABILITY),
|
---|
1471 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_AC_SEND),
|
---|
1472 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_AC_SEND_SELECT),
|
---|
1473 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_CERTIFY_X509),
|
---|
1474 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ACT_SET_TIMEOUT),
|
---|
1475 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ECC_ENCRYPT),
|
---|
1476 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ECC_DECRYPT),
|
---|
1477 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_CAPABILITY),
|
---|
1478 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_PARAMETERS),
|
---|
1479 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_DEFINE_SPACE_2),
|
---|
1480 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_READ_PUBLIC_2),
|
---|
1481 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_SET_CAPABILITY)
|
---|
1482 | #undef TPM_CMD_CODE_INIT
|
---|
1483 | };
|
---|
1484 |
|
---|
1485 | static void vboxTraceLogDecodeEvtTpmDecodeCmdBuffer(PRTTRACELOGDECODERHLP pHlp, const uint8_t *pbCmd, size_t cbCmd)
|
---|
1486 | {
|
---|
1487 | PCTPMREQHDR pHdr = (PCTPMREQHDR)pbCmd;
|
---|
1488 | if (cbCmd >= sizeof(*pHdr))
|
---|
1489 | {
|
---|
1490 | uint16_t u16Tag = RT_BE2H_U16(pHdr->u16Tag);
|
---|
1491 | uint32_t u32CmdCode = RT_BE2H_U32(pHdr->u32Ordinal);
|
---|
1492 | uint32_t cbReqPayload = RT_BE2H_U32(pHdr->cbReq) - sizeof(*pHdr);
|
---|
1493 | PTPMSTATE pTpmState = (PTPMSTATE)pHlp->pfnDecoderStateGet(pHlp);
|
---|
1494 |
|
---|
1495 | if (!pTpmState)
|
---|
1496 | {
|
---|
1497 | int rc = pHlp->pfnDecoderStateCreate(pHlp, sizeof(*pTpmState), NULL, (void **)&pTpmState);
|
---|
1498 | if (RT_SUCCESS(rc))
|
---|
1499 | pTpmState->u32CmdCode = u32CmdCode;
|
---|
1500 | else
|
---|
1501 | pHlp->pfnErrorMsg(pHlp, "Failed to allocate TPM decoder state: %Rrc\n", rc);
|
---|
1502 | }
|
---|
1503 | else
|
---|
1504 | pTpmState->u32CmdCode = u32CmdCode;
|
---|
1505 |
|
---|
1506 | for (uint32_t i = 0; i < RT_ELEMENTS(s_aTpmCmdCodes); i++)
|
---|
1507 | {
|
---|
1508 | if (s_aTpmCmdCodes[i].u32CmdCode == u32CmdCode)
|
---|
1509 | {
|
---|
1510 | pHlp->pfnPrintf(pHlp, " %s (%u bytes):\n", s_aTpmCmdCodes[i].pszCmdCode, cbReqPayload);
|
---|
1511 | pHlp->pfnPrintf(pHlp, " u16Tag: %#x\n", u16Tag);
|
---|
1512 |
|
---|
1513 |
|
---|
1514 | TPMDECODECTX Ctx;
|
---|
1515 | PTPMDECODECTX pCtx = &Ctx;
|
---|
1516 | vboxTraceLogDecodeEvtTpmDecodeCtxInit(&Ctx, (const uint8_t *)(pHdr + 1), cbReqPayload);
|
---|
1517 |
|
---|
1518 | /* Decode the handle area. */
|
---|
1519 | if (s_aTpmCmdCodes[i].papszHandlesReq)
|
---|
1520 | {
|
---|
1521 | pHlp->pfnPrintf(pHlp, " Handles:\n");
|
---|
1522 |
|
---|
1523 | const char **papszHnd = s_aTpmCmdCodes[i].papszHandlesReq;
|
---|
1524 | while (*papszHnd)
|
---|
1525 | {
|
---|
1526 | TPM_DECODE_U32(u32Hnd, u32Hnd);
|
---|
1527 | pHlp->pfnPrintf(pHlp, " %s: %#x\n", *papszHnd, u32Hnd);
|
---|
1528 | papszHnd++;
|
---|
1529 | }
|
---|
1530 | }
|
---|
1531 |
|
---|
1532 | /* Decode authorization area if available. */
|
---|
1533 | if (u16Tag == TPM2_ST_SESSIONS)
|
---|
1534 | {
|
---|
1535 | pHlp->pfnPrintf(pHlp, " Authorization Area:\n");
|
---|
1536 | vboxTraceLogDecodeEvtTpmAuthSessionReq(pHlp, pCtx);
|
---|
1537 | }
|
---|
1538 |
|
---|
1539 | /* Decode parameters. */
|
---|
1540 | if (s_aTpmCmdCodes[i].pfnDecodeReq)
|
---|
1541 | {
|
---|
1542 | pHlp->pfnPrintf(pHlp, " Parameters:\n");
|
---|
1543 | s_aTpmCmdCodes[i].pfnDecodeReq(pHlp, pTpmState, &Ctx);
|
---|
1544 | }
|
---|
1545 |
|
---|
1546 | if (pCtx->cbLeft)
|
---|
1547 | pHlp->pfnPrintf(pHlp, " Leftover undecoded data:\n"
|
---|
1548 | "%.*Rhxd\n", pCtx->cbLeft, pCtx->pbBuf);
|
---|
1549 | return;
|
---|
1550 | }
|
---|
1551 | }
|
---|
1552 | pHlp->pfnPrintf(pHlp, " <Unknown command code>: %#x\n", u32CmdCode);
|
---|
1553 |
|
---|
1554 | if (cbReqPayload)
|
---|
1555 | pHlp->pfnPrintf(pHlp, "%.*Rhxd\n", cbReqPayload, pHdr + 1);
|
---|
1556 | }
|
---|
1557 | else
|
---|
1558 | pHlp->pfnErrorMsg(pHlp, "Command buffer is smaller than the request header (required %u, given %zu\n", sizeof(*pHdr), cbCmd);
|
---|
1559 | }
|
---|
1560 |
|
---|
1561 |
|
---|
1562 | static void vboxTraceLogDecodeEvtTpmDecodeRespBuffer(PRTTRACELOGDECODERHLP pHlp, const uint8_t *pbResp, size_t cbResp)
|
---|
1563 | {
|
---|
1564 | RT_NOREF(pHlp);
|
---|
1565 |
|
---|
1566 | PCTPMRESPHDR pHdr = (PCTPMRESPHDR)pbResp;
|
---|
1567 | if (cbResp >= sizeof(*pHdr))
|
---|
1568 | {
|
---|
1569 | uint32_t cbRespPayload = RT_BE2H_U32(pHdr->cbResp) - sizeof(*pHdr);
|
---|
1570 | uint32_t u32ErrCode = RT_BE2H_U32(pHdr->u32ErrCode);
|
---|
1571 | uint16_t u16Tag = RT_BE2H_U16(pHdr->u16Tag);
|
---|
1572 |
|
---|
1573 | pHlp->pfnPrintf(pHlp, " Status code: %#x (%u bytes)\n", u32ErrCode, cbRespPayload);
|
---|
1574 | pHlp->pfnPrintf(pHlp, " u16Tag: %#x\n", u16Tag);
|
---|
1575 | PTPMSTATE pTpmState = (PTPMSTATE)pHlp->pfnDecoderStateGet(pHlp);
|
---|
1576 |
|
---|
1577 | /* Can only decode the response buffer if we know the command code. */
|
---|
1578 | if ( pTpmState
|
---|
1579 | && u32ErrCode == TPM_SUCCESS)
|
---|
1580 | {
|
---|
1581 | TPMDECODECTX Ctx;
|
---|
1582 | PTPMDECODECTX pCtx = &Ctx;
|
---|
1583 | vboxTraceLogDecodeEvtTpmDecodeCtxInit(&Ctx, (const uint8_t *)(pHdr + 1), cbRespPayload);
|
---|
1584 |
|
---|
1585 | for (uint32_t i = 0; i < RT_ELEMENTS(s_aTpmCmdCodes); i++)
|
---|
1586 | {
|
---|
1587 | if (s_aTpmCmdCodes[i].u32CmdCode == pTpmState->u32CmdCode)
|
---|
1588 | {
|
---|
1589 | /* Decode the handle area. */
|
---|
1590 | if (s_aTpmCmdCodes[i].papszHandlesResp)
|
---|
1591 | {
|
---|
1592 | pHlp->pfnPrintf(pHlp, " Handles:\n");
|
---|
1593 |
|
---|
1594 | const char **papszHnd = s_aTpmCmdCodes[i].papszHandlesResp;
|
---|
1595 | while (*papszHnd)
|
---|
1596 | {
|
---|
1597 | TPM_DECODE_U32(u32Hnd, u32Hnd);
|
---|
1598 | pHlp->pfnPrintf(pHlp, " %s: %#x\n", *papszHnd, u32Hnd);
|
---|
1599 | papszHnd++;
|
---|
1600 | }
|
---|
1601 | }
|
---|
1602 |
|
---|
1603 | if (u16Tag == TPM2_ST_SESSIONS)
|
---|
1604 | {
|
---|
1605 | TPM_DECODE_INIT();
|
---|
1606 | TPM_DECODE_U32(u32ParamSz, u32ParamSize);
|
---|
1607 | pHlp->pfnPrintf(pHlp, " u32ParamSize: %#x\n", u32ParamSz);
|
---|
1608 | TPM_DECODE_END();
|
---|
1609 | }
|
---|
1610 |
|
---|
1611 | /* Decode parameters. */
|
---|
1612 | if (s_aTpmCmdCodes[i].pfnDecodeResp)
|
---|
1613 | s_aTpmCmdCodes[i].pfnDecodeResp(pHlp, pTpmState, pCtx);
|
---|
1614 |
|
---|
1615 | /* Decode authorization area if available. */
|
---|
1616 | if (u16Tag == TPM2_ST_SESSIONS)
|
---|
1617 | {
|
---|
1618 | pHlp->pfnPrintf(pHlp, " Authorization Area:\n");
|
---|
1619 | vboxTraceLogDecodeEvtTpmAuthSessionResp(pHlp, pCtx);
|
---|
1620 | }
|
---|
1621 |
|
---|
1622 | if (pCtx->cbLeft)
|
---|
1623 | pHlp->pfnPrintf(pHlp, " Leftover undecoded data:\n"
|
---|
1624 | "%.*Rhxd\n", pCtx->cbLeft, pCtx->pbBuf);
|
---|
1625 |
|
---|
1626 | return;
|
---|
1627 | }
|
---|
1628 | }
|
---|
1629 | }
|
---|
1630 |
|
---|
1631 | if (cbRespPayload)
|
---|
1632 | pHlp->pfnPrintf(pHlp, "%.*Rhxd\n", cbRespPayload, pHdr + 1);
|
---|
1633 | }
|
---|
1634 | else
|
---|
1635 | pHlp->pfnErrorMsg(pHlp, "Response buffer is smaller than the request header (required %u, given %zu\n", sizeof(*pHdr), cbResp);
|
---|
1636 | }
|
---|
1637 |
|
---|
1638 |
|
---|
1639 | static DECLCALLBACK(int) vboxTraceLogDecodeEvtTpm(PRTTRACELOGDECODERHLP pHlp, uint32_t idDecodeEvt, RTTRACELOGRDREVT hTraceLogEvt,
|
---|
1640 | PCRTTRACELOGEVTDESC pEvtDesc, PRTTRACELOGEVTVAL paVals, uint32_t cVals)
|
---|
1641 | {
|
---|
1642 | RT_NOREF(hTraceLogEvt, pEvtDesc);
|
---|
1643 | if (idDecodeEvt == 0)
|
---|
1644 | {
|
---|
1645 | for (uint32_t i = 0; i < cVals; i++)
|
---|
1646 | {
|
---|
1647 | /* Look for the pvCmd item which stores the command buffer. */
|
---|
1648 | if ( !strcmp(paVals[i].pItemDesc->pszName, "pvCmd")
|
---|
1649 | && paVals[i].pItemDesc->enmType == RTTRACELOGTYPE_RAWDATA)
|
---|
1650 | {
|
---|
1651 | vboxTraceLogDecodeEvtTpmDecodeCmdBuffer(pHlp, paVals[i].u.RawData.pb, paVals[i].u.RawData.cb);
|
---|
1652 | return VINF_SUCCESS;
|
---|
1653 | }
|
---|
1654 | }
|
---|
1655 |
|
---|
1656 | pHlp->pfnErrorMsg(pHlp, "Failed to find the TPM command data buffer for the given event\n");
|
---|
1657 | }
|
---|
1658 | else if (idDecodeEvt == 1)
|
---|
1659 | {
|
---|
1660 | for (uint32_t i = 0; i < cVals; i++)
|
---|
1661 | {
|
---|
1662 | /* Look for the pvCmd item which stores the response buffer. */
|
---|
1663 | if ( !strcmp(paVals[i].pItemDesc->pszName, "pvResp")
|
---|
1664 | && paVals[i].pItemDesc->enmType == RTTRACELOGTYPE_RAWDATA)
|
---|
1665 | {
|
---|
1666 | vboxTraceLogDecodeEvtTpmDecodeRespBuffer(pHlp, paVals[i].u.RawData.pb, paVals[i].u.RawData.cb);
|
---|
1667 | return VINF_SUCCESS;
|
---|
1668 | }
|
---|
1669 | }
|
---|
1670 | pHlp->pfnErrorMsg(pHlp, "Failed to find the TPM command response buffer for the given event\n");
|
---|
1671 | }
|
---|
1672 |
|
---|
1673 | pHlp->pfnErrorMsg(pHlp, "Decode event ID %u is not known to this decoder\n", idDecodeEvt);
|
---|
1674 | return VERR_NOT_FOUND;
|
---|
1675 | }
|
---|
1676 |
|
---|
1677 |
|
---|
1678 | /**
|
---|
1679 | * TPM decoder event IDs.
|
---|
1680 | */
|
---|
1681 | static const RTTRACELOGDECODEEVT s_aDecodeEvtTpm[] =
|
---|
1682 | {
|
---|
1683 | { "ITpmConnector.CmdExecReq", 0 },
|
---|
1684 | { "ITpmConnector.CmdExecResp", 1 },
|
---|
1685 | { NULL, UINT32_MAX }
|
---|
1686 | };
|
---|
1687 |
|
---|
1688 |
|
---|
1689 | /**
|
---|
1690 | * Decoder plugin interface.
|
---|
1691 | */
|
---|
1692 | static const RTTRACELOGDECODERREG g_TraceLogDecoderTpm =
|
---|
1693 | {
|
---|
1694 | /** pszName */
|
---|
1695 | "TPM",
|
---|
1696 | /** pszDesc */
|
---|
1697 | "Decodes events from the ITpmConnector interface generated with the IfTrace driver.",
|
---|
1698 | /** paEvtIds */
|
---|
1699 | s_aDecodeEvtTpm,
|
---|
1700 | /** pfnDecode */
|
---|
1701 | vboxTraceLogDecodeEvtTpm,
|
---|
1702 | };
|
---|
1703 |
|
---|
1704 |
|
---|
1705 | /**
|
---|
1706 | * Shared object initialization callback.
|
---|
1707 | */
|
---|
1708 | extern "C" DECLCALLBACK(DECLEXPORT(int)) RTTraceLogDecoderLoad(void *pvUser, PRTTRACELOGDECODERREGISTER pRegisterCallbacks)
|
---|
1709 | {
|
---|
1710 | AssertLogRelMsgReturn(pRegisterCallbacks->u32Version == RT_TRACELOG_DECODERREG_CB_VERSION,
|
---|
1711 | ("pRegisterCallbacks->u32Version=%#x RT_TRACELOG_DECODERREG_CB_VERSION=%#x\n",
|
---|
1712 | pRegisterCallbacks->u32Version, RT_TRACELOG_DECODERREG_CB_VERSION),
|
---|
1713 | VERR_VERSION_MISMATCH);
|
---|
1714 |
|
---|
1715 | return pRegisterCallbacks->pfnRegisterDecoders(pvUser, &g_TraceLogDecoderTpm, 1);
|
---|
1716 | }
|
---|
1717 |
|
---|