1 | /* $Id: VBoxTraceLogDecoders.cpp 105046 2024-06-27 09:05:03Z 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 RTTRACELOGDECODERSTRUCTBLDENUM 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 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_TERM
|
---|
191 | #undef TPM_ALGID_2_STR
|
---|
192 | };
|
---|
193 |
|
---|
194 |
|
---|
195 | /*********************************************************************************************************************************
|
---|
196 | * Internal Functions *
|
---|
197 | *********************************************************************************************************************************/
|
---|
198 |
|
---|
199 | DECLINLINE(void) vboxTraceLogDecodeEvtTpmDecodeCtxInit(PTPMDECODECTX pCtx, const uint8_t *pbBuf, size_t cbBuf)
|
---|
200 | {
|
---|
201 | pCtx->pbBuf = pbBuf;
|
---|
202 | pCtx->cbLeft = cbBuf;
|
---|
203 | pCtx->fError = false;
|
---|
204 | }
|
---|
205 |
|
---|
206 |
|
---|
207 | static uint8_t vboxTraceLogDecodeEvtTpmDecodeCtxGetU8(PTPMDECODECTX pCtx, PRTTRACELOGDECODERHLP pHlp, const char *pszItem)
|
---|
208 | {
|
---|
209 | if (RT_UNLIKELY(pCtx->fError))
|
---|
210 | return 0;
|
---|
211 |
|
---|
212 | if (RT_UNLIKELY(!pCtx->cbLeft))
|
---|
213 | {
|
---|
214 | pHlp->pfnErrorMsg(pHlp, "Failed to decode '%s' as there is not enough space in the buffer (required %u, available %u)",
|
---|
215 | pszItem, sizeof(uint8_t), pCtx->cbLeft);
|
---|
216 | AssertFailed();
|
---|
217 | pCtx->fError = true;
|
---|
218 | return 0;
|
---|
219 | }
|
---|
220 |
|
---|
221 | pCtx->cbLeft--;
|
---|
222 | return *pCtx->pbBuf++;
|
---|
223 | }
|
---|
224 |
|
---|
225 |
|
---|
226 | static uint16_t vboxTraceLogDecodeEvtTpmDecodeCtxGetU16(PTPMDECODECTX pCtx, PRTTRACELOGDECODERHLP pHlp, const char *pszItem)
|
---|
227 | {
|
---|
228 | if (RT_UNLIKELY(pCtx->fError))
|
---|
229 | return 0;
|
---|
230 |
|
---|
231 | if (RT_UNLIKELY(pCtx->cbLeft < sizeof(uint16_t)))
|
---|
232 | {
|
---|
233 | pHlp->pfnErrorMsg(pHlp, "Failed to decode '%s' as there is not enough space in the buffer (required %u, available %u)",
|
---|
234 | pszItem, sizeof(uint16_t), pCtx->cbLeft);
|
---|
235 | AssertFailed();
|
---|
236 | pCtx->fError = true;
|
---|
237 | return 0;
|
---|
238 | }
|
---|
239 |
|
---|
240 | uint16_t u16 = *(uint16_t *)pCtx->pbBuf;
|
---|
241 | pCtx->pbBuf += sizeof(uint16_t);
|
---|
242 | pCtx->cbLeft -= sizeof(uint16_t);
|
---|
243 | return RT_BE2H_U16(u16);
|
---|
244 | }
|
---|
245 |
|
---|
246 |
|
---|
247 | static uint32_t vboxTraceLogDecodeEvtTpmDecodeCtxGetU32(PTPMDECODECTX pCtx, PRTTRACELOGDECODERHLP pHlp, const char *pszItem)
|
---|
248 | {
|
---|
249 | if (RT_UNLIKELY(pCtx->fError))
|
---|
250 | return 0;
|
---|
251 |
|
---|
252 | if (RT_UNLIKELY(pCtx->cbLeft < sizeof(uint32_t)))
|
---|
253 | {
|
---|
254 | pHlp->pfnErrorMsg(pHlp, "Failed to decode '%s' as there is not enough space in the buffer (required %u, available %u)",
|
---|
255 | pszItem, sizeof(uint32_t), pCtx->cbLeft);
|
---|
256 | AssertFailed();
|
---|
257 | pCtx->fError = true;
|
---|
258 | return 0;
|
---|
259 | }
|
---|
260 |
|
---|
261 | uint32_t u32 = *(uint32_t *)pCtx->pbBuf;
|
---|
262 | pCtx->pbBuf += sizeof(uint32_t);
|
---|
263 | pCtx->cbLeft -= sizeof(uint32_t);
|
---|
264 | return RT_BE2H_U32(u32);
|
---|
265 | }
|
---|
266 |
|
---|
267 |
|
---|
268 | static int32_t vboxTraceLogDecodeEvtTpmDecodeCtxGetI32(PTPMDECODECTX pCtx, PRTTRACELOGDECODERHLP pHlp, const char *pszItem)
|
---|
269 | {
|
---|
270 | return (int32_t)vboxTraceLogDecodeEvtTpmDecodeCtxGetU32(pCtx, pHlp, pszItem);
|
---|
271 | }
|
---|
272 |
|
---|
273 |
|
---|
274 | static uint64_t vboxTraceLogDecodeEvtTpmDecodeCtxGetU64(PTPMDECODECTX pCtx, PRTTRACELOGDECODERHLP pHlp, const char *pszItem)
|
---|
275 | {
|
---|
276 | if (RT_UNLIKELY(pCtx->fError))
|
---|
277 | return 0;
|
---|
278 |
|
---|
279 | if (RT_UNLIKELY(pCtx->cbLeft < sizeof(uint64_t)))
|
---|
280 | {
|
---|
281 | pHlp->pfnErrorMsg(pHlp, "Failed to decode '%s' as there is not enough space in the buffer (required %u, available %u)",
|
---|
282 | pszItem, sizeof(uint64_t), pCtx->cbLeft);
|
---|
283 | AssertFailed();
|
---|
284 | pCtx->fError = true;
|
---|
285 | return 0;
|
---|
286 | }
|
---|
287 |
|
---|
288 | uint64_t u64 = *(uint64_t *)pCtx->pbBuf;
|
---|
289 | pCtx->pbBuf += sizeof(uint64_t);
|
---|
290 | pCtx->cbLeft -= sizeof(uint64_t);
|
---|
291 | return RT_BE2H_U64(u64);
|
---|
292 | }
|
---|
293 |
|
---|
294 |
|
---|
295 | static const uint8_t *vboxTraceLogDecodeEvtTpmDecodeCtxGetBuf(PTPMDECODECTX pCtx, PRTTRACELOGDECODERHLP pHlp, const char *pszItem, size_t cbBuf)
|
---|
296 | {
|
---|
297 | if (RT_UNLIKELY(pCtx->fError))
|
---|
298 | return 0;
|
---|
299 |
|
---|
300 | if (RT_UNLIKELY(pCtx->cbLeft < cbBuf))
|
---|
301 | {
|
---|
302 | pHlp->pfnErrorMsg(pHlp, "Failed to decode '%s' as there is not enough space in the buffer (required %u, available %u)",
|
---|
303 | pszItem, cbBuf, pCtx->cbLeft);
|
---|
304 | AssertFailed();
|
---|
305 | pCtx->fError = true;
|
---|
306 | return 0;
|
---|
307 | }
|
---|
308 |
|
---|
309 | /* Just return nothing if nothing is requested. */
|
---|
310 | if (!cbBuf)
|
---|
311 | return NULL;
|
---|
312 |
|
---|
313 | const uint8_t *pb = pCtx->pbBuf;
|
---|
314 | pCtx->pbBuf += cbBuf;
|
---|
315 | pCtx->cbLeft -= cbBuf;
|
---|
316 | return pb;
|
---|
317 | }
|
---|
318 |
|
---|
319 |
|
---|
320 | static size_t vboxTraceLogDecodeEvtTpmAlgId2DigestSize(uint16_t u16AlgId)
|
---|
321 | {
|
---|
322 | for (uint32_t i = 0; i < RT_ELEMENTS(g_aAlgId2Str); i++)
|
---|
323 | if (g_aAlgId2Str[i].u64EnumVal == u16AlgId)
|
---|
324 | return g_aAlgId2Str[i].uPtrUser;
|
---|
325 |
|
---|
326 | return 0;
|
---|
327 | }
|
---|
328 |
|
---|
329 |
|
---|
330 | #define TPM_DECODE_INIT() do {
|
---|
331 |
|
---|
332 | #define TPM_DECODE_END() \
|
---|
333 | } while (0); \
|
---|
334 | if (pCtx->fError) return
|
---|
335 |
|
---|
336 | #define TPM_DECODE_BOOL(a_Var, a_Name) \
|
---|
337 | uint8_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU8(pCtx, pHlp, #a_Name); \
|
---|
338 | if (pCtx->fError) break; \
|
---|
339 | pHlp->pfnStructBldAddBool(pHlp, #a_Name, 0 /*fFlags*/, RT_BOOL(a_Var))
|
---|
340 |
|
---|
341 | #define TPM_DECODE_U8(a_Var, a_Name) \
|
---|
342 | uint8_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU8(pCtx, pHlp, #a_Name); \
|
---|
343 | if (pCtx->fError) break; \
|
---|
344 | pHlp->pfnStructBldAddU8(pHlp, #a_Name, 0 /*fFlags*/, a_Var)
|
---|
345 |
|
---|
346 | #define TPM_DECODE_U16(a_Var, a_Name) \
|
---|
347 | uint16_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU16(pCtx, pHlp, #a_Name); \
|
---|
348 | if (pCtx->fError) break; \
|
---|
349 | pHlp->pfnStructBldAddU16(pHlp, #a_Name, 0 /*fFlags*/, a_Var)
|
---|
350 |
|
---|
351 | #define TPM_DECODE_U32(a_Var, a_Name) \
|
---|
352 | uint32_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU32(pCtx, pHlp, #a_Name); \
|
---|
353 | if (pCtx->fError) break; \
|
---|
354 | pHlp->pfnStructBldAddU32(pHlp, #a_Name, 0 /*fFlags*/, a_Var)
|
---|
355 |
|
---|
356 | #define TPM_DECODE_U64(a_Var, a_Name) \
|
---|
357 | uint64_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU64(pCtx, pHlp, #a_Name); \
|
---|
358 | if (pCtx->fError) break; \
|
---|
359 | pHlp->pfnStructBldAddU64(pHlp, #a_Name, 0 /*fFlags*/, a_Var)
|
---|
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 | pHlp->pfnStructBldAddS32(pHlp, #a_Name, 0 /*fFlags*/, a_Var)
|
---|
365 |
|
---|
366 | #define TPM_DECODE_U8_HEX(a_Var, a_Name) \
|
---|
367 | uint8_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU8(pCtx, pHlp, #a_Name); \
|
---|
368 | if (pCtx->fError) break; \
|
---|
369 | pHlp->pfnStructBldAddU8(pHlp, #a_Name, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, a_Var)
|
---|
370 |
|
---|
371 | #define TPM_DECODE_U16_HEX(a_Var, a_Name) \
|
---|
372 | uint16_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU16(pCtx, pHlp, #a_Name); \
|
---|
373 | if (pCtx->fError) break; \
|
---|
374 | pHlp->pfnStructBldAddU16(pHlp, #a_Name, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, a_Var)
|
---|
375 |
|
---|
376 | #define TPM_DECODE_U32_HEX(a_Var, a_Name) \
|
---|
377 | uint32_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU32(pCtx, pHlp, #a_Name); \
|
---|
378 | if (pCtx->fError) break; \
|
---|
379 | pHlp->pfnStructBldAddU32(pHlp, #a_Name, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, a_Var)
|
---|
380 |
|
---|
381 | #define TPM_DECODE_U32_HEX_STR(a_Var, a_pszName) \
|
---|
382 | uint32_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU32(pCtx, pHlp, a_pszName); \
|
---|
383 | if (pCtx->fError) break; \
|
---|
384 | pHlp->pfnStructBldAddU32(pHlp, a_pszName, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, a_Var)
|
---|
385 |
|
---|
386 | #define TPM_DECODE_U64_HEX(a_Var, a_Name) \
|
---|
387 | uint64_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU64(pCtx, pHlp, #a_Name); \
|
---|
388 | if (pCtx->fError) break; \
|
---|
389 | pHlp->pfnStructBldAddU64(pHlp, #a_Name, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, a_Var)
|
---|
390 |
|
---|
391 | #define TPM_DECODE_I32_HEX(a_Var, a_Name) \
|
---|
392 | int32_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetI32(pCtx, pHlp, #a_Name); \
|
---|
393 | if (pCtx->fError) break; \
|
---|
394 | pHlp->pfnStructBldAddS32(pHlp, #a_Name, 0 /*fFlags*/, a_Var)
|
---|
395 |
|
---|
396 | #define TPM_DECODE_BUF_EX(a_Var, a_Name, a_cb) \
|
---|
397 | const uint8_t *a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetBuf(pCtx, pHlp, #a_Name, a_cb); \
|
---|
398 | if (pCtx->fError) break
|
---|
399 |
|
---|
400 | #define TPM_DECODE_BUF(a_Var, a_Name, a_cb) \
|
---|
401 | const uint8_t *a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetBuf(pCtx, pHlp, #a_Name, a_cb); \
|
---|
402 | if (pCtx->fError) break; \
|
---|
403 | if (a_Var) \
|
---|
404 | pHlp->pfnStructBldAddBuf(pHlp, #a_Name, 0 /*fFlags*/, a_Var, a_cb);
|
---|
405 |
|
---|
406 | #define TPM_DECODE_BUF_HEX_STRING(a_Var, a_Name, a_cb) \
|
---|
407 | const uint8_t *a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetBuf(pCtx, pHlp, #a_Name, a_cb); \
|
---|
408 | if (pCtx->fError) break; \
|
---|
409 | if (a_Var) \
|
---|
410 | pHlp->pfnStructBldAddBuf(pHlp, #a_Name, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX_DUMP_STR, a_Var, a_cb);
|
---|
411 |
|
---|
412 | #define TPM_DECODE_U16_ENUM(a_Var, a_Name, a_aEnums) \
|
---|
413 | uint16_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU16(pCtx, pHlp, #a_Name); \
|
---|
414 | if (pCtx->fError) break; \
|
---|
415 | pHlp->pfnStructBldAddEnum(pHlp, #a_Name, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, 16, a_aEnums, a_Var)
|
---|
416 |
|
---|
417 | #define TPM_DECODE_U32_ENUM(a_Var, a_Name, a_aEnums) \
|
---|
418 | uint32_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU32(pCtx, pHlp, #a_Name); \
|
---|
419 | if (pCtx->fError) break; \
|
---|
420 | pHlp->pfnStructBldAddEnum(pHlp, #a_Name, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, 32, a_aEnums, a_Var)
|
---|
421 |
|
---|
422 | #define TPM_DECODE_BUF_STR(a_Var, a_pszName, a_cb) \
|
---|
423 | const uint8_t *a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetBuf(pCtx, pHlp, a_pszName, a_cb); \
|
---|
424 | if (pCtx->fError) break; \
|
---|
425 | if (a_Var) \
|
---|
426 | pHlp->pfnStructBldAddBuf(pHlp, a_pszName, 0 /*fFlags*/, a_Var, a_cb);
|
---|
427 |
|
---|
428 | #define TPM_DECODE_END_IF_ERROR() \
|
---|
429 | if (pCtx->fError) return
|
---|
430 |
|
---|
431 | static void vboxTraceLogDecodePcrSelection(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx)
|
---|
432 | {
|
---|
433 | TPM_DECODE_INIT();
|
---|
434 | TPM_DECODE_U16_ENUM(u16AlgId, u16AlgId, g_aAlgId2Str );
|
---|
435 | TPM_DECODE_U8( cbPcrSelection, u8SizeOfSelect );
|
---|
436 | TPM_DECODE_BUF_EX( pb, PCRs, cbPcrSelection);
|
---|
437 |
|
---|
438 | pHlp->pfnStructBldArrayBegin(pHlp, "PCRs");
|
---|
439 |
|
---|
440 | for (uint8_t idxPcr = 0; idxPcr < cbPcrSelection * 8; idxPcr++)
|
---|
441 | if (RT_BOOL(*(pb + (idxPcr / 8)) & RT_BIT(idxPcr % 8)))
|
---|
442 | pHlp->pfnStructBldAddU8(pHlp, NULL, 0 /*fFlags*/, idxPcr);
|
---|
443 |
|
---|
444 | pHlp->pfnStructBldArrayEnd(pHlp);
|
---|
445 |
|
---|
446 | TPM_DECODE_END();
|
---|
447 | }
|
---|
448 |
|
---|
449 |
|
---|
450 | static void vboxTraceLogDecodePcrSelectionList(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx)
|
---|
451 | {
|
---|
452 | TPM_DECODE_INIT();
|
---|
453 | TPM_DECODE_U32(u32Count, u32Count);
|
---|
454 |
|
---|
455 | pHlp->pfnStructBldBegin(pHlp, "aPcrSelection");
|
---|
456 |
|
---|
457 | /* Walk the list of PCR selection entries. */
|
---|
458 | for (uint32_t i = 0; i < u32Count; i++)
|
---|
459 | {
|
---|
460 | vboxTraceLogDecodePcrSelection(pHlp, pCtx);
|
---|
461 | TPM_DECODE_END_IF_ERROR();
|
---|
462 | }
|
---|
463 |
|
---|
464 | pHlp->pfnStructBldEnd(pHlp);
|
---|
465 |
|
---|
466 | TPM_DECODE_END();
|
---|
467 | }
|
---|
468 |
|
---|
469 |
|
---|
470 | static void vboxTraceLogDecodeEvtTpmDigestList(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx)
|
---|
471 | {
|
---|
472 | TPM_DECODE_INIT();
|
---|
473 | TPM_DECODE_U32(u32DigestCount, u32DigestCount);
|
---|
474 |
|
---|
475 | pHlp->pfnStructBldBegin(pHlp, "aDigests");
|
---|
476 |
|
---|
477 | for (uint32_t i = 0; i < u32DigestCount; i++)
|
---|
478 | {
|
---|
479 | TPM_DECODE_U16(u16DigestSize, u16DigestSize);
|
---|
480 | TPM_DECODE_BUF_HEX_STRING(pbDigest, abDigest, u16DigestSize);
|
---|
481 | }
|
---|
482 |
|
---|
483 | pHlp->pfnStructBldEnd(pHlp);
|
---|
484 |
|
---|
485 | TPM_DECODE_END();
|
---|
486 | }
|
---|
487 |
|
---|
488 |
|
---|
489 | static void vboxTraceLogDecodeEvtTpmDigestValuesList(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx)
|
---|
490 | {
|
---|
491 | TPM_DECODE_INIT();
|
---|
492 | TPM_DECODE_U32(u32DigestCount, u32DigestCount);
|
---|
493 |
|
---|
494 | pHlp->pfnStructBldBegin(pHlp, "aDigests");
|
---|
495 |
|
---|
496 | for (uint32_t i = 0; i < u32DigestCount; i++)
|
---|
497 | {
|
---|
498 | TPM_DECODE_U16_ENUM(u16HashAlg, u16HashAlg, g_aAlgId2Str);
|
---|
499 |
|
---|
500 | size_t cbDigest = vboxTraceLogDecodeEvtTpmAlgId2DigestSize(u16HashAlg);
|
---|
501 | TPM_DECODE_BUF_HEX_STRING(pb, abDigest, cbDigest);
|
---|
502 | }
|
---|
503 |
|
---|
504 | pHlp->pfnStructBldEnd(pHlp);
|
---|
505 |
|
---|
506 | TPM_DECODE_END();
|
---|
507 | }
|
---|
508 |
|
---|
509 |
|
---|
510 | static void vboxTraceLogDecodeEvtTpmAuthSessionReq(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx)
|
---|
511 | {
|
---|
512 | TPM_DECODE_INIT();
|
---|
513 | TPM_DECODE_U32_HEX(u32SessionHandle, u32SessionHandle);
|
---|
514 | TPM_DECODE_U16( u16NonceSize, u16NonceSize);
|
---|
515 | TPM_DECODE_BUF( pbNonce, abNonce, u16NonceSize);
|
---|
516 | TPM_DECODE_U8( u8Attr, u8Attr);
|
---|
517 | TPM_DECODE_U16( u16HmacSize, u16HmacSize);
|
---|
518 | TPM_DECODE_BUF( pbHmac, abHmac, u16HmacSize);
|
---|
519 | TPM_DECODE_END();
|
---|
520 | }
|
---|
521 |
|
---|
522 |
|
---|
523 | static void vboxTraceLogDecodeEvtTpmAuthSessionResp(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx)
|
---|
524 | {
|
---|
525 | pHlp->pfnStructBldBegin(pHlp, "AuthArea");
|
---|
526 | TPM_DECODE_INIT();
|
---|
527 | TPM_DECODE_U16(u16NonceSize, u16NonceSize);
|
---|
528 | TPM_DECODE_BUF(pbNonce, abNonce, u16NonceSize);
|
---|
529 | TPM_DECODE_U8( u8Attr, u8Attr);
|
---|
530 | TPM_DECODE_U16(u16AckSize, u16AckSize);
|
---|
531 | TPM_DECODE_BUF(pbAck, abAck, u16AckSize);
|
---|
532 | TPM_DECODE_END();
|
---|
533 | pHlp->pfnStructBldEnd(pHlp);
|
---|
534 | }
|
---|
535 |
|
---|
536 |
|
---|
537 | static void vboxTraceLogDecodeSizedBufU16(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
538 | {
|
---|
539 | if (pszName)
|
---|
540 | pHlp->pfnStructBldBegin(pHlp, pszName);
|
---|
541 | TPM_DECODE_INIT();
|
---|
542 | TPM_DECODE_U16(u16Size, u16Size);
|
---|
543 | if (u16Size)
|
---|
544 | {
|
---|
545 | TPM_DECODE_BUF_STR(pb, pszName, u16Size);
|
---|
546 | }
|
---|
547 | TPM_DECODE_END();
|
---|
548 | if (pszName)
|
---|
549 | pHlp->pfnStructBldEnd(pHlp);
|
---|
550 | }
|
---|
551 |
|
---|
552 |
|
---|
553 | static void vboxTraceLogDecodeSymEncDef(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
554 | {
|
---|
555 | pHlp->pfnStructBldBegin(pHlp, pszName);
|
---|
556 | TPM_DECODE_INIT();
|
---|
557 | TPM_DECODE_U16_ENUM(u16HashAlg, u16HashAlg, g_aAlgId2Str);
|
---|
558 | if (u16HashAlg != TPM2_ALG_NULL)
|
---|
559 | {
|
---|
560 | TPM_DECODE_U16(u16KeyBits, u16KeyBits);
|
---|
561 | TPM_DECODE_U16_ENUM(u16SymMode, u16SymMode, g_aAlgId2Str);
|
---|
562 | /* Symmetric details are not required as of now. */
|
---|
563 | }
|
---|
564 | TPM_DECODE_END();
|
---|
565 | pHlp->pfnStructBldEnd(pHlp);
|
---|
566 | }
|
---|
567 |
|
---|
568 |
|
---|
569 | static void vboxTraceLogDecodeNvPublic(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
570 | {
|
---|
571 | pHlp->pfnStructBldBegin(pHlp, pszName);
|
---|
572 | TPM_DECODE_INIT();
|
---|
573 | TPM_DECODE_U16(u16Size, u16Size);
|
---|
574 | if (u16Size)
|
---|
575 | {
|
---|
576 | TPM_DECODE_U32_HEX(hNvIndex, hNvIndex);
|
---|
577 | TPM_DECODE_U16(u16HashAlgName, u16HashAlgName);
|
---|
578 | TPM_DECODE_U32(u32Attr, fAttr);
|
---|
579 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "AuthPolicy");
|
---|
580 | TPM_DECODE_U16(u16DataSize, u16DataSize);
|
---|
581 | }
|
---|
582 | TPM_DECODE_END();
|
---|
583 | pHlp->pfnStructBldEnd(pHlp);
|
---|
584 | }
|
---|
585 |
|
---|
586 |
|
---|
587 | static void vboxTraceLogDecodeTicket(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
588 | {
|
---|
589 | pHlp->pfnStructBldBegin(pHlp, pszName);
|
---|
590 | TPM_DECODE_INIT();
|
---|
591 | TPM_DECODE_U16_HEX(u16Tag, u16Tag);
|
---|
592 | TPM_DECODE_U32_HEX(hHierarchy, hHierarchy);
|
---|
593 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Digest");
|
---|
594 | TPM_DECODE_END();
|
---|
595 | pHlp->pfnStructBldEnd(pHlp);
|
---|
596 | }
|
---|
597 |
|
---|
598 |
|
---|
599 | static void vboxTraceLogDecode_TPMT_SIGNATURE(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
600 | {
|
---|
601 | pHlp->pfnStructBldBegin(pHlp, pszName);
|
---|
602 | TPM_DECODE_INIT();
|
---|
603 | TPM_DECODE_U16_ENUM(u16SigningAlg, u16SigningAlg, g_aAlgId2Str);
|
---|
604 | if (u16SigningAlg != TPM2_ALG_NULL)
|
---|
605 | {
|
---|
606 | TPM_DECODE_U16_ENUM(u16HashAlg, u16HashAlg, g_aAlgId2Str);
|
---|
607 | }
|
---|
608 | TPM_DECODE_END();
|
---|
609 | pHlp->pfnStructBldEnd(pHlp);
|
---|
610 | }
|
---|
611 |
|
---|
612 |
|
---|
613 | static void vboxTraceLogDecode_TPMT_SIG_SCHEME(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
614 | {
|
---|
615 | pHlp->pfnStructBldBegin(pHlp, pszName);
|
---|
616 | TPM_DECODE_INIT();
|
---|
617 | TPM_DECODE_U16_ENUM(u16Scheme, u16Scheme, g_aAlgId2Str);
|
---|
618 | if (u16Scheme != TPM2_ALG_NULL)
|
---|
619 | {
|
---|
620 | TPM_DECODE_U16_ENUM(u16HashAlg, u16HashAlg, g_aAlgId2Str);
|
---|
621 | }
|
---|
622 | TPM_DECODE_END();
|
---|
623 | pHlp->pfnStructBldEnd(pHlp);
|
---|
624 | }
|
---|
625 |
|
---|
626 |
|
---|
627 | static void vboxTraceLogDecode_TPML_DIGEST(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
628 | {
|
---|
629 | pHlp->pfnStructBldBegin(pHlp, pszName);
|
---|
630 | TPM_DECODE_INIT();
|
---|
631 | TPM_DECODE_U32(u32Count, u32Count);
|
---|
632 | for (uint32_t i = 0; i < u32Count; i++)
|
---|
633 | {
|
---|
634 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Digest");
|
---|
635 | TPM_DECODE_END_IF_ERROR();
|
---|
636 | }
|
---|
637 | TPM_DECODE_END();
|
---|
638 | pHlp->pfnStructBldEnd(pHlp);
|
---|
639 | }
|
---|
640 |
|
---|
641 |
|
---|
642 | static void vboxTraceLogDecode_TPMS_CONTEXT(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
643 | {
|
---|
644 | pHlp->pfnStructBldBegin(pHlp, pszName);
|
---|
645 | TPM_DECODE_INIT();
|
---|
646 | TPM_DECODE_U64( u64Sequence, u64Sequence);
|
---|
647 | TPM_DECODE_U32_HEX(hSaved, hSaved);
|
---|
648 | TPM_DECODE_U32_HEX(hHierarchy, hHierarchy);
|
---|
649 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "ContextBlob");
|
---|
650 | TPM_DECODE_END();
|
---|
651 | pHlp->pfnStructBldEnd(pHlp);
|
---|
652 | }
|
---|
653 |
|
---|
654 |
|
---|
655 | static void vboxTraceLogDecode_TPM2B_SENSITIVE_CREATE(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
656 | {
|
---|
657 | pHlp->pfnStructBldBegin(pHlp, pszName);
|
---|
658 | TPM_DECODE_INIT();
|
---|
659 | /** @todo */
|
---|
660 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, NULL /*pszName*/);
|
---|
661 | TPM_DECODE_END();
|
---|
662 | pHlp->pfnStructBldEnd(pHlp);
|
---|
663 | }
|
---|
664 |
|
---|
665 |
|
---|
666 | static void vboxTraceLogDecode_TPM2B_TEMPLATE(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
667 | {
|
---|
668 | pHlp->pfnStructBldBegin(pHlp, pszName);
|
---|
669 | TPM_DECODE_INIT();
|
---|
670 | /** @todo */
|
---|
671 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, NULL /*pszName*/);
|
---|
672 | TPM_DECODE_END();
|
---|
673 | pHlp->pfnStructBldEnd(pHlp);
|
---|
674 | }
|
---|
675 |
|
---|
676 |
|
---|
677 | static void vboxTraceLogDecode_TPM2B_PRIVATE(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
678 | {
|
---|
679 | pHlp->pfnStructBldBegin(pHlp, pszName);
|
---|
680 | TPM_DECODE_INIT();
|
---|
681 | /** @todo */
|
---|
682 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, NULL /*pszName*/);
|
---|
683 | TPM_DECODE_END();
|
---|
684 | pHlp->pfnStructBldEnd(pHlp);
|
---|
685 | }
|
---|
686 |
|
---|
687 |
|
---|
688 | static void vboxTraceLogDecode_TPM2B_PUBLIC(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
689 | {
|
---|
690 | pHlp->pfnStructBldBegin(pHlp, pszName);
|
---|
691 | TPM_DECODE_INIT();
|
---|
692 | /** @todo */
|
---|
693 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, NULL /*pszName*/);
|
---|
694 | TPM_DECODE_END();
|
---|
695 | pHlp->pfnStructBldEnd(pHlp);
|
---|
696 | }
|
---|
697 |
|
---|
698 |
|
---|
699 | static void vboxTraceLogDecode_TPM2B_NAME(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName)
|
---|
700 | {
|
---|
701 | pHlp->pfnStructBldBegin(pHlp, pszName);
|
---|
702 | TPM_DECODE_INIT();
|
---|
703 | /** @todo */
|
---|
704 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, NULL /*pszName*/);
|
---|
705 | TPM_DECODE_END();
|
---|
706 | pHlp->pfnStructBldEnd(pHlp);
|
---|
707 | }
|
---|
708 |
|
---|
709 |
|
---|
710 | static const char *g_apszHandlesEvictControlReq[] =
|
---|
711 | {
|
---|
712 | "hAuth",
|
---|
713 | "hObj",
|
---|
714 | NULL
|
---|
715 | };
|
---|
716 |
|
---|
717 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeEvictControlReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
718 | {
|
---|
719 | RT_NOREF(pThis);
|
---|
720 |
|
---|
721 | TPM_DECODE_INIT();
|
---|
722 | TPM_DECODE_U32_HEX(hPersistent, hPersistent);
|
---|
723 | TPM_DECODE_END();
|
---|
724 | }
|
---|
725 |
|
---|
726 |
|
---|
727 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeSelfTestReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
728 | {
|
---|
729 | RT_NOREF(pThis);
|
---|
730 |
|
---|
731 | TPM_DECODE_INIT();
|
---|
732 | TPM_DECODE_BOOL(fFullTest, fFullTest);
|
---|
733 | TPM_DECODE_END();
|
---|
734 | }
|
---|
735 |
|
---|
736 |
|
---|
737 | static RTTRACELOGDECODERSTRUCTBLDENUM g_aStartupShutdownParam[] =
|
---|
738 | {
|
---|
739 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_SU_CLEAR),
|
---|
740 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_SU_STATE)
|
---|
741 | };
|
---|
742 |
|
---|
743 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeStartupShutdownReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
744 | {
|
---|
745 | RT_NOREF(pThis);
|
---|
746 |
|
---|
747 | TPM_DECODE_INIT();
|
---|
748 | TPM_DECODE_U16_ENUM(u16TpmSu, u16State, g_aStartupShutdownParam);
|
---|
749 | TPM_DECODE_END();
|
---|
750 | }
|
---|
751 |
|
---|
752 |
|
---|
753 | static RTTRACELOGDECODERSTRUCTBLDENUM g_aTpm2Caps[] =
|
---|
754 | {
|
---|
755 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_ALGS),
|
---|
756 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_HANDLES),
|
---|
757 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_COMMANDS),
|
---|
758 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_PP_COMMANDS),
|
---|
759 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_AUDIT_COMMANDS),
|
---|
760 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_PCRS),
|
---|
761 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_TPM_PROPERTIES),
|
---|
762 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_PCR_PROPERTIES),
|
---|
763 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_ECC_CURVES),
|
---|
764 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_AUTH_POLICIES),
|
---|
765 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_ACT),
|
---|
766 | RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_TERM
|
---|
767 | };
|
---|
768 |
|
---|
769 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeGetCapabilityReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
770 | {
|
---|
771 | TPM_DECODE_INIT();
|
---|
772 | TPM_DECODE_U32_ENUM(u32Cap, u32Cap, g_aTpm2Caps);
|
---|
773 | TPM_DECODE_U32_HEX( u32Property, u32Property );
|
---|
774 | TPM_DECODE_U32( u32Count, u32Count );
|
---|
775 |
|
---|
776 | pThis->u.GetCapability.u32Cap = u32Cap;
|
---|
777 | pThis->u.GetCapability.u32Property = u32Property;
|
---|
778 | pThis->u.GetCapability.u32Count = u32Count;
|
---|
779 | TPM_DECODE_END();
|
---|
780 | }
|
---|
781 |
|
---|
782 |
|
---|
783 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeGetCapabilityResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
784 | {
|
---|
785 | RT_NOREF(pThis);
|
---|
786 |
|
---|
787 | TPM_DECODE_INIT();
|
---|
788 | TPM_DECODE_BOOL( fMoreData, fMoreData);
|
---|
789 | TPM_DECODE_U32_ENUM(u32Cap, u32Cap, g_aTpm2Caps);
|
---|
790 |
|
---|
791 | switch (u32Cap)
|
---|
792 | {
|
---|
793 | case TPM2_CAP_PCRS:
|
---|
794 | {
|
---|
795 | vboxTraceLogDecodePcrSelectionList(pHlp, pCtx);
|
---|
796 | break;
|
---|
797 | }
|
---|
798 | case TPM2_CAP_TPM_PROPERTIES:
|
---|
799 | {
|
---|
800 | TPM_DECODE_U32(u32Count, u32Count);
|
---|
801 | pHlp->pfnStructBldBegin(pHlp, "aProperties");
|
---|
802 | for (uint32_t i = 0; i < u32Count; i++)
|
---|
803 | {
|
---|
804 | TPM_DECODE_U32_HEX(u32Property, u32Property);
|
---|
805 | TPM_DECODE_U32_HEX(u32Value, u32Value);
|
---|
806 | }
|
---|
807 | pHlp->pfnStructBldEnd(pHlp);
|
---|
808 | break;
|
---|
809 | }
|
---|
810 | case TPM2_CAP_COMMANDS:
|
---|
811 | {
|
---|
812 | TPM_DECODE_U32(u32Count, u32Count);
|
---|
813 | pHlp->pfnStructBldBegin(pHlp, "aCommands");
|
---|
814 | for (uint32_t i = 0; i < u32Count; i++)
|
---|
815 | {
|
---|
816 | TPM_DECODE_U32_HEX(u32CmdCode, u32CmdCode);
|
---|
817 | }
|
---|
818 | pHlp->pfnStructBldEnd(pHlp);
|
---|
819 | break;
|
---|
820 | }
|
---|
821 | case TPM2_CAP_HANDLES:
|
---|
822 | {
|
---|
823 | TPM_DECODE_U32(u32Count, u32Count);
|
---|
824 | pHlp->pfnStructBldBegin(pHlp, "aCommands");
|
---|
825 | for (uint32_t i = 0; i < u32Count; i++)
|
---|
826 | {
|
---|
827 | TPM_DECODE_U32_HEX(u32Handle, u32Handle);
|
---|
828 | }
|
---|
829 | pHlp->pfnStructBldEnd(pHlp);
|
---|
830 | break;
|
---|
831 | }
|
---|
832 | default:
|
---|
833 | break;
|
---|
834 | }
|
---|
835 | TPM_DECODE_END();
|
---|
836 | }
|
---|
837 |
|
---|
838 |
|
---|
839 | static const char *g_apszHandlesReadPublicReq[] =
|
---|
840 | {
|
---|
841 | "hObj",
|
---|
842 | NULL
|
---|
843 | };
|
---|
844 |
|
---|
845 |
|
---|
846 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeReadPublicResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
847 | {
|
---|
848 | RT_NOREF(pThis);
|
---|
849 |
|
---|
850 | TPM_DECODE_INIT();
|
---|
851 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutPublic");
|
---|
852 | TPM_DECODE_END_IF_ERROR();
|
---|
853 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Name");
|
---|
854 | TPM_DECODE_END_IF_ERROR();
|
---|
855 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "QualifiedName");
|
---|
856 | TPM_DECODE_END_IF_ERROR();
|
---|
857 | TPM_DECODE_END();
|
---|
858 | }
|
---|
859 |
|
---|
860 |
|
---|
861 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeGetRandomReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
862 | {
|
---|
863 | TPM_DECODE_INIT();
|
---|
864 | TPM_DECODE_U16(u16RandomBytes, u16RandomBytes);
|
---|
865 | pThis->u.GetRandom.cbRnd = u16RandomBytes;
|
---|
866 | TPM_DECODE_END();
|
---|
867 | }
|
---|
868 |
|
---|
869 |
|
---|
870 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeGetRandomResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
871 | {
|
---|
872 | TPM_DECODE_INIT();
|
---|
873 | TPM_DECODE_U16(cbBuf, u16Size);
|
---|
874 | if (pThis->u.GetRandom.cbRnd != cbBuf)
|
---|
875 | {
|
---|
876 | pHlp->pfnErrorMsg(pHlp, "Requested random data size doesn't match returned data size (requested %u, returned %u), using smaller value\n",
|
---|
877 | pThis->u.GetRandom.cbRnd, cbBuf);
|
---|
878 | cbBuf = RT_MIN(cbBuf, pThis->u.GetRandom.cbRnd);
|
---|
879 | }
|
---|
880 |
|
---|
881 | TPM_DECODE_BUF(pb, RndBuf, cbBuf);
|
---|
882 | TPM_DECODE_END();
|
---|
883 | }
|
---|
884 |
|
---|
885 |
|
---|
886 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodePcrReadReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
887 | {
|
---|
888 | RT_NOREF(pThis);
|
---|
889 |
|
---|
890 | TPM_DECODE_INIT();
|
---|
891 | vboxTraceLogDecodePcrSelectionList(pHlp, pCtx);
|
---|
892 | TPM_DECODE_END();
|
---|
893 | }
|
---|
894 |
|
---|
895 |
|
---|
896 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodePcrReadResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
897 | {
|
---|
898 | RT_NOREF(pThis);
|
---|
899 |
|
---|
900 | TPM_DECODE_INIT();
|
---|
901 | TPM_DECODE_U32(u32PcrUpdateCounter, u32PcrUpdateCounter);
|
---|
902 | vboxTraceLogDecodePcrSelectionList(pHlp, pCtx);
|
---|
903 | TPM_DECODE_END_IF_ERROR();
|
---|
904 | vboxTraceLogDecodeEvtTpmDigestList(pHlp, pCtx);
|
---|
905 | TPM_DECODE_END();
|
---|
906 | }
|
---|
907 |
|
---|
908 |
|
---|
909 | static const char *g_apszHandlesPcrExtendReq[] =
|
---|
910 | {
|
---|
911 | "hPcr",
|
---|
912 | NULL
|
---|
913 | };
|
---|
914 |
|
---|
915 |
|
---|
916 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodePcrExtendReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
917 | {
|
---|
918 | RT_NOREF(pThis);
|
---|
919 |
|
---|
920 | TPM_DECODE_INIT();
|
---|
921 | vboxTraceLogDecodeEvtTpmDigestValuesList(pHlp, pCtx);
|
---|
922 | TPM_DECODE_END();
|
---|
923 | }
|
---|
924 |
|
---|
925 |
|
---|
926 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeReadClockResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
927 | {
|
---|
928 | RT_NOREF(pThis);
|
---|
929 |
|
---|
930 | TPM_DECODE_INIT();
|
---|
931 | TPM_DECODE_U64(u64Time, u64Time);
|
---|
932 |
|
---|
933 | /* Decode TPMS_CLOCK_INFO. */
|
---|
934 | TPM_DECODE_U64( u64Clock, u64Clock);
|
---|
935 | TPM_DECODE_U32( u32ResetCount, u32ResetCount);
|
---|
936 | TPM_DECODE_U32( u32RestartCount, u32RestartCount);
|
---|
937 | TPM_DECODE_BOOL(fSafe, fSafe);
|
---|
938 | TPM_DECODE_END();
|
---|
939 | }
|
---|
940 |
|
---|
941 |
|
---|
942 | static const char *g_apszHandlesContextLoadResp[] =
|
---|
943 | {
|
---|
944 | "hLoaded",
|
---|
945 | NULL
|
---|
946 | };
|
---|
947 |
|
---|
948 |
|
---|
949 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeContextLoadReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
950 | {
|
---|
951 | RT_NOREF(pThis);
|
---|
952 |
|
---|
953 | TPM_DECODE_INIT();
|
---|
954 | vboxTraceLogDecode_TPMS_CONTEXT(pHlp, pCtx, "Context");
|
---|
955 | TPM_DECODE_END();
|
---|
956 | }
|
---|
957 |
|
---|
958 |
|
---|
959 | static const char *g_apszHandlesContextSaveReq[] =
|
---|
960 | {
|
---|
961 | "hSave",
|
---|
962 | NULL
|
---|
963 | };
|
---|
964 |
|
---|
965 |
|
---|
966 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeContextSaveResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
967 | {
|
---|
968 | RT_NOREF(pThis);
|
---|
969 |
|
---|
970 | TPM_DECODE_INIT();
|
---|
971 | vboxTraceLogDecode_TPMS_CONTEXT(pHlp, pCtx, "Context");
|
---|
972 | TPM_DECODE_END();
|
---|
973 | }
|
---|
974 |
|
---|
975 |
|
---|
976 | static const char *g_apszHandlesNvReadPublicReq[] =
|
---|
977 | {
|
---|
978 | "hNvIndex",
|
---|
979 | NULL
|
---|
980 | };
|
---|
981 |
|
---|
982 |
|
---|
983 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeNvReadPublicResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
984 | {
|
---|
985 | RT_NOREF(pThis);
|
---|
986 |
|
---|
987 | TPM_DECODE_INIT();
|
---|
988 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "NvPublic");
|
---|
989 | TPM_DECODE_END();
|
---|
990 | }
|
---|
991 |
|
---|
992 |
|
---|
993 | static const char *g_apszHandlesStartAuthSessionReq[] =
|
---|
994 | {
|
---|
995 | "hTpmKey",
|
---|
996 | "hBind",
|
---|
997 | NULL
|
---|
998 | };
|
---|
999 |
|
---|
1000 |
|
---|
1001 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeStartAuthSessionReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1002 | {
|
---|
1003 | RT_NOREF(pThis);
|
---|
1004 |
|
---|
1005 | TPM_DECODE_INIT();
|
---|
1006 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "NonceCaller");
|
---|
1007 | TPM_DECODE_END_IF_ERROR();
|
---|
1008 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "EncryptedSalt");
|
---|
1009 | TPM_DECODE_END_IF_ERROR();
|
---|
1010 |
|
---|
1011 | TPM_DECODE_U8_HEX(u8SessionType, u8SessionType);
|
---|
1012 |
|
---|
1013 | vboxTraceLogDecodeSymEncDef(pHlp, pCtx, "Symmetric");
|
---|
1014 | TPM_DECODE_END_IF_ERROR();
|
---|
1015 |
|
---|
1016 | TPM_DECODE_U16_ENUM(u16HashAlg, u16HashAlg, g_aAlgId2Str);
|
---|
1017 | TPM_DECODE_END();
|
---|
1018 | }
|
---|
1019 |
|
---|
1020 |
|
---|
1021 | static const char *g_apszHandlesStartAuthSessionResp[] =
|
---|
1022 | {
|
---|
1023 | "hSession",
|
---|
1024 | NULL
|
---|
1025 | };
|
---|
1026 |
|
---|
1027 |
|
---|
1028 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeStartAuthSessionResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1029 | {
|
---|
1030 | RT_NOREF(pThis);
|
---|
1031 |
|
---|
1032 | TPM_DECODE_INIT();
|
---|
1033 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "NonceTpm");
|
---|
1034 | TPM_DECODE_END();
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 |
|
---|
1038 | static const char *g_apszHandlesClearReq[] =
|
---|
1039 | {
|
---|
1040 | "hAuth",
|
---|
1041 | NULL
|
---|
1042 | };
|
---|
1043 |
|
---|
1044 |
|
---|
1045 | static const char *g_apszHandlesClearControlReq[] =
|
---|
1046 | {
|
---|
1047 | "hAuth",
|
---|
1048 | NULL
|
---|
1049 | };
|
---|
1050 |
|
---|
1051 |
|
---|
1052 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeClearControlReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1053 | {
|
---|
1054 | RT_NOREF(pThis);
|
---|
1055 |
|
---|
1056 | TPM_DECODE_INIT();
|
---|
1057 | TPM_DECODE_BOOL(fDisable, fDisable);
|
---|
1058 | TPM_DECODE_END();
|
---|
1059 | }
|
---|
1060 |
|
---|
1061 |
|
---|
1062 | static const char *g_apszHandlesClockSetReq[] =
|
---|
1063 | {
|
---|
1064 | "hAuth",
|
---|
1065 | NULL
|
---|
1066 | };
|
---|
1067 |
|
---|
1068 |
|
---|
1069 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeClockSetReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1070 | {
|
---|
1071 | RT_NOREF(pThis);
|
---|
1072 |
|
---|
1073 | TPM_DECODE_INIT();
|
---|
1074 | TPM_DECODE_U64(u64NewTime, u64NewTime);
|
---|
1075 | TPM_DECODE_END();
|
---|
1076 | }
|
---|
1077 |
|
---|
1078 |
|
---|
1079 | static const char *g_apszHandlesHierarchyChangeAuthReq[] =
|
---|
1080 | {
|
---|
1081 | "hAuth",
|
---|
1082 | NULL
|
---|
1083 | };
|
---|
1084 |
|
---|
1085 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeHierarchyChangeAuthReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1086 | {
|
---|
1087 | RT_NOREF(pThis);
|
---|
1088 |
|
---|
1089 | TPM_DECODE_INIT();
|
---|
1090 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "NewAuth");
|
---|
1091 | TPM_DECODE_END();
|
---|
1092 | }
|
---|
1093 |
|
---|
1094 |
|
---|
1095 | static const char *g_apszHandlesHierarchyControlReq[] =
|
---|
1096 | {
|
---|
1097 | "hAuth",
|
---|
1098 | NULL
|
---|
1099 | };
|
---|
1100 |
|
---|
1101 |
|
---|
1102 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeHierarchyControlReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1103 | {
|
---|
1104 | RT_NOREF(pThis);
|
---|
1105 |
|
---|
1106 | TPM_DECODE_INIT();
|
---|
1107 | TPM_DECODE_U32_HEX(hEnable, hEnable);
|
---|
1108 | TPM_DECODE_BOOL( fState, fState);
|
---|
1109 | TPM_DECODE_END();
|
---|
1110 | }
|
---|
1111 |
|
---|
1112 |
|
---|
1113 | static const char *g_apszHandlesNvUndefineSpaceReq[] =
|
---|
1114 | {
|
---|
1115 | "hAuth",
|
---|
1116 | "hNvIndex",
|
---|
1117 | NULL
|
---|
1118 | };
|
---|
1119 |
|
---|
1120 |
|
---|
1121 | static const char *g_apszHandlesChangeEpsPpsReq[] =
|
---|
1122 | {
|
---|
1123 | "hAuth",
|
---|
1124 | NULL
|
---|
1125 | };
|
---|
1126 |
|
---|
1127 |
|
---|
1128 | static const char *g_apszHandlesNvDefineSpaceReq[] =
|
---|
1129 | {
|
---|
1130 | "hAuth",
|
---|
1131 | NULL
|
---|
1132 | };
|
---|
1133 |
|
---|
1134 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeNvDefineSpaceReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1135 | {
|
---|
1136 | RT_NOREF(pThis);
|
---|
1137 |
|
---|
1138 | TPM_DECODE_INIT();
|
---|
1139 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Auth");
|
---|
1140 | TPM_DECODE_END_IF_ERROR();
|
---|
1141 |
|
---|
1142 | vboxTraceLogDecodeNvPublic(pHlp, pCtx, "PublicInfo");
|
---|
1143 | TPM_DECODE_END();
|
---|
1144 | }
|
---|
1145 |
|
---|
1146 |
|
---|
1147 | static const char *g_apszHandlesSetPrimaryPolicyReq[] =
|
---|
1148 | {
|
---|
1149 | "hAuth",
|
---|
1150 | NULL
|
---|
1151 | };
|
---|
1152 |
|
---|
1153 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeSetPrimaryPolicyReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1154 | {
|
---|
1155 | RT_NOREF(pThis);
|
---|
1156 |
|
---|
1157 | TPM_DECODE_INIT();
|
---|
1158 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "AuthPolicy");
|
---|
1159 | TPM_DECODE_END_IF_ERROR();
|
---|
1160 |
|
---|
1161 | TPM_DECODE_U16_ENUM(u16HashAlg, u16HashAlg, g_aAlgId2Str);
|
---|
1162 | TPM_DECODE_END();
|
---|
1163 | }
|
---|
1164 |
|
---|
1165 |
|
---|
1166 | static const char *g_apszHandlesCreatePrimaryReq[] =
|
---|
1167 | {
|
---|
1168 | "hPrimary",
|
---|
1169 | NULL
|
---|
1170 | };
|
---|
1171 |
|
---|
1172 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCreatePrimaryReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1173 | {
|
---|
1174 | RT_NOREF(pThis);
|
---|
1175 |
|
---|
1176 | TPM_DECODE_INIT();
|
---|
1177 | /** @todo Decode InSensitive. */
|
---|
1178 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "InSensitive");
|
---|
1179 | TPM_DECODE_END_IF_ERROR();
|
---|
1180 | /** @todo Decode InPublic. */
|
---|
1181 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "InPublic");
|
---|
1182 | TPM_DECODE_END_IF_ERROR();
|
---|
1183 |
|
---|
1184 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutsideInfo");
|
---|
1185 | TPM_DECODE_END_IF_ERROR();
|
---|
1186 |
|
---|
1187 | vboxTraceLogDecodePcrSelectionList(pHlp, pCtx);
|
---|
1188 |
|
---|
1189 | TPM_DECODE_END();
|
---|
1190 | }
|
---|
1191 |
|
---|
1192 |
|
---|
1193 | static const char *g_apszHandlesCreatePrimaryResp[] =
|
---|
1194 | {
|
---|
1195 | "hObj",
|
---|
1196 | NULL
|
---|
1197 | };
|
---|
1198 |
|
---|
1199 |
|
---|
1200 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCreatePrimaryResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1201 | {
|
---|
1202 | RT_NOREF(pThis);
|
---|
1203 |
|
---|
1204 | TPM_DECODE_INIT();
|
---|
1205 | /** @todo Decode OutPublic. */
|
---|
1206 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutPublic");
|
---|
1207 | TPM_DECODE_END_IF_ERROR();
|
---|
1208 | /** @todo Decode CreationData. */
|
---|
1209 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CreationData");
|
---|
1210 | TPM_DECODE_END_IF_ERROR();
|
---|
1211 |
|
---|
1212 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CreationHash");
|
---|
1213 | TPM_DECODE_END_IF_ERROR();
|
---|
1214 |
|
---|
1215 | vboxTraceLogDecodeTicket(pHlp, pCtx, "Ticket");
|
---|
1216 | TPM_DECODE_END_IF_ERROR();
|
---|
1217 |
|
---|
1218 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Name");
|
---|
1219 | TPM_DECODE_END();
|
---|
1220 | }
|
---|
1221 |
|
---|
1222 |
|
---|
1223 | static const char *g_apszHandlesNvIncrementReq[] =
|
---|
1224 | {
|
---|
1225 | "hAuth",
|
---|
1226 | "hNvIndex",
|
---|
1227 | NULL
|
---|
1228 | };
|
---|
1229 |
|
---|
1230 |
|
---|
1231 | static const char *g_apszHandlesNvSetBitsReq[] =
|
---|
1232 | {
|
---|
1233 | "hAuth",
|
---|
1234 | "hNvIndex",
|
---|
1235 | NULL
|
---|
1236 | };
|
---|
1237 |
|
---|
1238 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeNvSetBitsReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1239 | {
|
---|
1240 | RT_NOREF(pThis);
|
---|
1241 |
|
---|
1242 | TPM_DECODE_INIT();
|
---|
1243 | TPM_DECODE_U64_HEX(u64BitsOr, u64BitsOr);
|
---|
1244 | TPM_DECODE_END();
|
---|
1245 | }
|
---|
1246 |
|
---|
1247 |
|
---|
1248 | static const char *g_apszHandlesNvWriteReq[] =
|
---|
1249 | {
|
---|
1250 | "hAuth",
|
---|
1251 | "hNvIndex",
|
---|
1252 | NULL
|
---|
1253 | };
|
---|
1254 |
|
---|
1255 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeNvWriteReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1256 | {
|
---|
1257 | RT_NOREF(pThis);
|
---|
1258 |
|
---|
1259 | TPM_DECODE_INIT();
|
---|
1260 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Data");
|
---|
1261 | TPM_DECODE_END_IF_ERROR();
|
---|
1262 |
|
---|
1263 | TPM_DECODE_U16(u16Offset, u16Offset);
|
---|
1264 | TPM_DECODE_END();
|
---|
1265 | }
|
---|
1266 |
|
---|
1267 |
|
---|
1268 | static const char *g_apszHandlesNvWriteLockReq[] =
|
---|
1269 | {
|
---|
1270 | "hAuth",
|
---|
1271 | "hNvIndex",
|
---|
1272 | NULL
|
---|
1273 | };
|
---|
1274 |
|
---|
1275 |
|
---|
1276 | static const char *g_apszHandlesDictionaryAttackParametersReq[] =
|
---|
1277 | {
|
---|
1278 | "hLock",
|
---|
1279 | NULL
|
---|
1280 | };
|
---|
1281 |
|
---|
1282 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeDictionaryAttackParametersReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1283 | {
|
---|
1284 | RT_NOREF(pThis);
|
---|
1285 |
|
---|
1286 | TPM_DECODE_INIT();
|
---|
1287 | TPM_DECODE_U32(u32NewMaxTries, u32NewMaxTries);
|
---|
1288 | TPM_DECODE_U32(u32NewRecoveryTime, u32NewRecoveryTime);
|
---|
1289 | TPM_DECODE_U32(u32LockoutRecovery, u32LockoutRecovery);
|
---|
1290 | TPM_DECODE_END();
|
---|
1291 | }
|
---|
1292 |
|
---|
1293 |
|
---|
1294 | static const char *g_apszHandlesCertifyReq[] =
|
---|
1295 | {
|
---|
1296 | "hSign",
|
---|
1297 | "hObj",
|
---|
1298 | NULL
|
---|
1299 | };
|
---|
1300 |
|
---|
1301 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCertifyReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1302 | {
|
---|
1303 | RT_NOREF(pThis);
|
---|
1304 |
|
---|
1305 | TPM_DECODE_INIT();
|
---|
1306 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "QualifyingData");
|
---|
1307 | TPM_DECODE_END_IF_ERROR();
|
---|
1308 |
|
---|
1309 | /* Decode TPMT_SIG_SCHEME+ */
|
---|
1310 | TPM_DECODE_U16_ENUM(u16SigningScheme, u16SigningScheme, g_aAlgId2Str);
|
---|
1311 | if (u16SigningScheme != TPM2_ALG_NULL)
|
---|
1312 | {
|
---|
1313 | TPM_DECODE_U16_ENUM(u16HashAlg, u16HashAlg, g_aAlgId2Str);
|
---|
1314 | }
|
---|
1315 | TPM_DECODE_END();
|
---|
1316 | }
|
---|
1317 |
|
---|
1318 |
|
---|
1319 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCertifyResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1320 | {
|
---|
1321 | RT_NOREF(pThis);
|
---|
1322 |
|
---|
1323 | TPM_DECODE_INIT();
|
---|
1324 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CertifyInfo");
|
---|
1325 | vboxTraceLogDecode_TPMT_SIGNATURE(pHlp, pCtx, "Signature");
|
---|
1326 | TPM_DECODE_END();
|
---|
1327 | }
|
---|
1328 |
|
---|
1329 |
|
---|
1330 | static const char *g_apszHandlesCertifyCreationReq[] =
|
---|
1331 | {
|
---|
1332 | "hSign",
|
---|
1333 | "hObj",
|
---|
1334 | NULL
|
---|
1335 | };
|
---|
1336 |
|
---|
1337 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCertifyCreationReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1338 | {
|
---|
1339 | RT_NOREF(pThis);
|
---|
1340 |
|
---|
1341 | TPM_DECODE_INIT();
|
---|
1342 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "QualifyingData");
|
---|
1343 | TPM_DECODE_END_IF_ERROR();
|
---|
1344 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CreationHash");
|
---|
1345 | TPM_DECODE_END_IF_ERROR();
|
---|
1346 |
|
---|
1347 | TPM_DECODE_U16_ENUM(u16SigningScheme, u16SigningScheme, g_aAlgId2Str);
|
---|
1348 | vboxTraceLogDecodeTicket(pHlp, pCtx, "CreationTicket");
|
---|
1349 | TPM_DECODE_END();
|
---|
1350 | }
|
---|
1351 |
|
---|
1352 |
|
---|
1353 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCertifyCreationResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1354 | {
|
---|
1355 | RT_NOREF(pThis);
|
---|
1356 |
|
---|
1357 | TPM_DECODE_INIT();
|
---|
1358 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CertifyInfo");
|
---|
1359 | vboxTraceLogDecode_TPMT_SIGNATURE(pHlp, pCtx, "Signature");
|
---|
1360 | TPM_DECODE_END();
|
---|
1361 | }
|
---|
1362 |
|
---|
1363 |
|
---|
1364 | static const char *g_apszHandlesNvReadReq[] =
|
---|
1365 | {
|
---|
1366 | "hAuth",
|
---|
1367 | "hNvIndex",
|
---|
1368 | NULL
|
---|
1369 | };
|
---|
1370 |
|
---|
1371 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeNvReadReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1372 | {
|
---|
1373 | RT_NOREF(pThis);
|
---|
1374 |
|
---|
1375 | TPM_DECODE_INIT();
|
---|
1376 | TPM_DECODE_U16(u16Size, u16Size);
|
---|
1377 | TPM_DECODE_U16(u16Offset, u16Offset);
|
---|
1378 | TPM_DECODE_END();
|
---|
1379 | }
|
---|
1380 |
|
---|
1381 |
|
---|
1382 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeNvReadResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1383 | {
|
---|
1384 | RT_NOREF(pThis);
|
---|
1385 |
|
---|
1386 | TPM_DECODE_INIT();
|
---|
1387 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Data");
|
---|
1388 | TPM_DECODE_END();
|
---|
1389 | }
|
---|
1390 |
|
---|
1391 |
|
---|
1392 | static const char *g_apszHandlesPolicySecretReq[] =
|
---|
1393 | {
|
---|
1394 | "hAuth",
|
---|
1395 | "hPolicySession",
|
---|
1396 | NULL
|
---|
1397 | };
|
---|
1398 |
|
---|
1399 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodePolicySecretReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1400 | {
|
---|
1401 | RT_NOREF(pThis);
|
---|
1402 |
|
---|
1403 | TPM_DECODE_INIT();
|
---|
1404 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "NonceTpm");
|
---|
1405 | TPM_DECODE_END_IF_ERROR();
|
---|
1406 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CpHashA");
|
---|
1407 | TPM_DECODE_END_IF_ERROR();
|
---|
1408 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "PolicyRef");
|
---|
1409 | TPM_DECODE_END_IF_ERROR();
|
---|
1410 |
|
---|
1411 | TPM_DECODE_I32(i32Expiration, i32Expiration);
|
---|
1412 | TPM_DECODE_END();
|
---|
1413 | }
|
---|
1414 |
|
---|
1415 |
|
---|
1416 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodePolicySecretResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1417 | {
|
---|
1418 | RT_NOREF(pThis);
|
---|
1419 |
|
---|
1420 | TPM_DECODE_INIT();
|
---|
1421 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Timeout");
|
---|
1422 | TPM_DECODE_END_IF_ERROR();
|
---|
1423 |
|
---|
1424 | vboxTraceLogDecodeTicket(pHlp, pCtx, "Ticket");
|
---|
1425 | TPM_DECODE_END();
|
---|
1426 | }
|
---|
1427 |
|
---|
1428 |
|
---|
1429 | static const char *g_apszHandlesCreateReq[] =
|
---|
1430 | {
|
---|
1431 | "hParent",
|
---|
1432 | NULL
|
---|
1433 | };
|
---|
1434 |
|
---|
1435 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCreateReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1436 | {
|
---|
1437 | RT_NOREF(pThis);
|
---|
1438 |
|
---|
1439 | TPM_DECODE_INIT();
|
---|
1440 | /** @todo Decode InSensitive. */
|
---|
1441 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "InSensitive");
|
---|
1442 | TPM_DECODE_END_IF_ERROR();
|
---|
1443 | /** @todo Decode InPublic. */
|
---|
1444 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "InPublic");
|
---|
1445 | TPM_DECODE_END_IF_ERROR();
|
---|
1446 |
|
---|
1447 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutsideInfo");
|
---|
1448 | TPM_DECODE_END_IF_ERROR();
|
---|
1449 |
|
---|
1450 | vboxTraceLogDecodePcrSelectionList(pHlp, pCtx);
|
---|
1451 |
|
---|
1452 | TPM_DECODE_END();
|
---|
1453 | }
|
---|
1454 |
|
---|
1455 |
|
---|
1456 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCreateResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1457 | {
|
---|
1458 | RT_NOREF(pThis);
|
---|
1459 |
|
---|
1460 | TPM_DECODE_INIT();
|
---|
1461 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutPrivate");
|
---|
1462 | TPM_DECODE_END_IF_ERROR();
|
---|
1463 | /** @todo Decode OutPublic. */
|
---|
1464 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutPublic");
|
---|
1465 | TPM_DECODE_END_IF_ERROR();
|
---|
1466 | /** @todo Decode CreationData. */
|
---|
1467 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CreationData");
|
---|
1468 | TPM_DECODE_END_IF_ERROR();
|
---|
1469 |
|
---|
1470 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "CreationHash");
|
---|
1471 | TPM_DECODE_END_IF_ERROR();
|
---|
1472 |
|
---|
1473 | vboxTraceLogDecodeTicket(pHlp, pCtx, "Ticket");
|
---|
1474 | TPM_DECODE_END();
|
---|
1475 | }
|
---|
1476 |
|
---|
1477 |
|
---|
1478 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeEccParametersReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1479 | {
|
---|
1480 | RT_NOREF(pThis);
|
---|
1481 |
|
---|
1482 | TPM_DECODE_INIT();
|
---|
1483 | TPM_DECODE_U16(u16CurveId, u16CurveId);
|
---|
1484 | TPM_DECODE_END();
|
---|
1485 | }
|
---|
1486 |
|
---|
1487 |
|
---|
1488 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeEccParametersResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1489 | {
|
---|
1490 | RT_NOREF(pThis);
|
---|
1491 |
|
---|
1492 | TPM_DECODE_INIT();
|
---|
1493 | TPM_DECODE_U16_HEX( u16CurveId, u16CurveId);
|
---|
1494 | TPM_DECODE_U16( u16KeySize, u16KeySize);
|
---|
1495 | TPM_DECODE_U16_ENUM(u16KdfScheme, u16KdfScheme, g_aAlgId2Str);
|
---|
1496 | TPM_DECODE_U16_ENUM(u16KdfSchemeHash, u16KdfSchemeHash, g_aAlgId2Str);
|
---|
1497 | TPM_DECODE_U16_ENUM(u16EccScheme, u16EccScheme, g_aAlgId2Str);
|
---|
1498 | if (u16EccScheme != TPM2_ALG_NULL)
|
---|
1499 | {
|
---|
1500 | TPM_DECODE_U16_ENUM(u16EccSchemeHash, u16EccSchemeHash, g_aAlgId2Str);
|
---|
1501 | }
|
---|
1502 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "p");
|
---|
1503 | TPM_DECODE_END_IF_ERROR();
|
---|
1504 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "a");
|
---|
1505 | TPM_DECODE_END_IF_ERROR();
|
---|
1506 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "b");
|
---|
1507 | TPM_DECODE_END_IF_ERROR();
|
---|
1508 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "gX");
|
---|
1509 | TPM_DECODE_END_IF_ERROR();
|
---|
1510 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "gY");
|
---|
1511 | TPM_DECODE_END_IF_ERROR();
|
---|
1512 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "n");
|
---|
1513 | TPM_DECODE_END_IF_ERROR();
|
---|
1514 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "h");
|
---|
1515 | TPM_DECODE_END_IF_ERROR();
|
---|
1516 | TPM_DECODE_END();
|
---|
1517 | }
|
---|
1518 |
|
---|
1519 |
|
---|
1520 | static const char *g_apszHandlesQuoteReq[] =
|
---|
1521 | {
|
---|
1522 | "hSign",
|
---|
1523 | NULL
|
---|
1524 | };
|
---|
1525 |
|
---|
1526 |
|
---|
1527 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeQuoteReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1528 | {
|
---|
1529 | RT_NOREF(pThis);
|
---|
1530 |
|
---|
1531 | TPM_DECODE_INIT();
|
---|
1532 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "QualifyingData");
|
---|
1533 | TPM_DECODE_END_IF_ERROR();
|
---|
1534 |
|
---|
1535 | TPM_DECODE_U16_ENUM(u16SigScheme, u16SigScheme, g_aAlgId2Str);
|
---|
1536 | if (u16SigScheme != TPM2_ALG_NULL)
|
---|
1537 | {
|
---|
1538 | TPM_DECODE_U16_ENUM(u16SigSchemeHash, u16SigSchemeHash, g_aAlgId2Str);
|
---|
1539 | }
|
---|
1540 |
|
---|
1541 | vboxTraceLogDecodePcrSelectionList(pHlp, pCtx);
|
---|
1542 | TPM_DECODE_END();
|
---|
1543 | }
|
---|
1544 |
|
---|
1545 |
|
---|
1546 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeQuoteResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1547 | {
|
---|
1548 | RT_NOREF(pThis);
|
---|
1549 |
|
---|
1550 | TPM_DECODE_INIT();
|
---|
1551 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Quoted");
|
---|
1552 | TPM_DECODE_END_IF_ERROR();
|
---|
1553 | vboxTraceLogDecode_TPMT_SIGNATURE(pHlp, pCtx, "Signature");
|
---|
1554 | TPM_DECODE_END();
|
---|
1555 | }
|
---|
1556 |
|
---|
1557 |
|
---|
1558 | static const char *g_apszHandlesSignReq[] =
|
---|
1559 | {
|
---|
1560 | "hKey",
|
---|
1561 | NULL
|
---|
1562 | };
|
---|
1563 |
|
---|
1564 |
|
---|
1565 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeSignReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1566 | {
|
---|
1567 | RT_NOREF(pThis);
|
---|
1568 |
|
---|
1569 | TPM_DECODE_INIT();
|
---|
1570 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Digest");
|
---|
1571 | TPM_DECODE_END_IF_ERROR();
|
---|
1572 |
|
---|
1573 | vboxTraceLogDecode_TPMT_SIG_SCHEME(pHlp, pCtx, "InScheme");
|
---|
1574 | vboxTraceLogDecodeTicket(pHlp, pCtx, "Validation"); /* TPMT_TK_HASHCHECK */
|
---|
1575 | TPM_DECODE_END();
|
---|
1576 | }
|
---|
1577 |
|
---|
1578 |
|
---|
1579 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeSignResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1580 | {
|
---|
1581 | RT_NOREF(pThis);
|
---|
1582 |
|
---|
1583 | TPM_DECODE_INIT();
|
---|
1584 | vboxTraceLogDecode_TPMT_SIGNATURE(pHlp, pCtx, "Signature");
|
---|
1585 | TPM_DECODE_END();
|
---|
1586 | }
|
---|
1587 |
|
---|
1588 |
|
---|
1589 | static const char *g_apszHandlesHmacMacReq[] =
|
---|
1590 | {
|
---|
1591 | "hSymKey",
|
---|
1592 | NULL
|
---|
1593 | };
|
---|
1594 |
|
---|
1595 |
|
---|
1596 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeHmacMacReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1597 | {
|
---|
1598 | RT_NOREF(pThis);
|
---|
1599 |
|
---|
1600 | TPM_DECODE_INIT();
|
---|
1601 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Buffer");
|
---|
1602 | TPM_DECODE_END_IF_ERROR();
|
---|
1603 |
|
---|
1604 | TPM_DECODE_U16_ENUM(u16HashAlg, u16HashAlg, g_aAlgId2Str);
|
---|
1605 | TPM_DECODE_END();
|
---|
1606 | }
|
---|
1607 |
|
---|
1608 |
|
---|
1609 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeHmacMacResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1610 | {
|
---|
1611 | RT_NOREF(pThis);
|
---|
1612 |
|
---|
1613 | TPM_DECODE_INIT();
|
---|
1614 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutHmacMac");
|
---|
1615 | TPM_DECODE_END();
|
---|
1616 | }
|
---|
1617 |
|
---|
1618 |
|
---|
1619 | static const char *g_apszHandlesFlushContextReq[] =
|
---|
1620 | {
|
---|
1621 | "hFlush",
|
---|
1622 | NULL
|
---|
1623 | };
|
---|
1624 |
|
---|
1625 |
|
---|
1626 | static const char *g_apszHandlesImportReq[] =
|
---|
1627 | {
|
---|
1628 | "hParent",
|
---|
1629 | NULL
|
---|
1630 | };
|
---|
1631 |
|
---|
1632 |
|
---|
1633 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeImportReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1634 | {
|
---|
1635 | RT_NOREF(pThis);
|
---|
1636 |
|
---|
1637 | TPM_DECODE_INIT();
|
---|
1638 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "EncryptionKey");
|
---|
1639 | TPM_DECODE_END_IF_ERROR();
|
---|
1640 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "ObjectPublic");
|
---|
1641 | TPM_DECODE_END_IF_ERROR();
|
---|
1642 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Duplicate");
|
---|
1643 | TPM_DECODE_END_IF_ERROR();
|
---|
1644 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "InSymSeed");
|
---|
1645 | TPM_DECODE_END_IF_ERROR();
|
---|
1646 | vboxTraceLogDecodeSymEncDef(pHlp, pCtx, "SymmetricAlg");
|
---|
1647 | TPM_DECODE_END();
|
---|
1648 | }
|
---|
1649 |
|
---|
1650 |
|
---|
1651 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeImportResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1652 | {
|
---|
1653 | RT_NOREF(pThis);
|
---|
1654 |
|
---|
1655 | TPM_DECODE_INIT();
|
---|
1656 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "OutPrivate");
|
---|
1657 | TPM_DECODE_END_IF_ERROR();
|
---|
1658 | TPM_DECODE_END();
|
---|
1659 | }
|
---|
1660 |
|
---|
1661 |
|
---|
1662 | static const char *g_apszHandlesLoadReq[] =
|
---|
1663 | {
|
---|
1664 | "hParent",
|
---|
1665 | NULL
|
---|
1666 | };
|
---|
1667 |
|
---|
1668 |
|
---|
1669 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeLoadReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1670 | {
|
---|
1671 | RT_NOREF(pThis);
|
---|
1672 |
|
---|
1673 | TPM_DECODE_INIT();
|
---|
1674 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "InPrivate");
|
---|
1675 | TPM_DECODE_END_IF_ERROR();
|
---|
1676 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "InPublic");
|
---|
1677 | TPM_DECODE_END_IF_ERROR();
|
---|
1678 | TPM_DECODE_END();
|
---|
1679 | }
|
---|
1680 |
|
---|
1681 |
|
---|
1682 | static const char *g_apszHandlesLoadResp[] =
|
---|
1683 | {
|
---|
1684 | "hObj",
|
---|
1685 | NULL
|
---|
1686 | };
|
---|
1687 |
|
---|
1688 |
|
---|
1689 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeLoadResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1690 | {
|
---|
1691 | RT_NOREF(pThis);
|
---|
1692 |
|
---|
1693 | TPM_DECODE_INIT();
|
---|
1694 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Name");
|
---|
1695 | TPM_DECODE_END_IF_ERROR();
|
---|
1696 | TPM_DECODE_END();
|
---|
1697 | }
|
---|
1698 |
|
---|
1699 |
|
---|
1700 | static const char *g_apszHandlesPolicyGetDigestReq[] =
|
---|
1701 | {
|
---|
1702 | "hPolicySession",
|
---|
1703 | NULL
|
---|
1704 | };
|
---|
1705 |
|
---|
1706 |
|
---|
1707 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodePolicyGetDigestResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1708 | {
|
---|
1709 | RT_NOREF(pThis);
|
---|
1710 |
|
---|
1711 | TPM_DECODE_INIT();
|
---|
1712 | vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "PolicyDigest");
|
---|
1713 | TPM_DECODE_END();
|
---|
1714 | }
|
---|
1715 |
|
---|
1716 |
|
---|
1717 | static const char *g_apszHandlesPolicyAuthValueReq[] =
|
---|
1718 | {
|
---|
1719 | "hPolicySession",
|
---|
1720 | NULL
|
---|
1721 | };
|
---|
1722 |
|
---|
1723 |
|
---|
1724 | static const char *g_apszHandlesPolicyCommandCodeReq[] =
|
---|
1725 | {
|
---|
1726 | "hPolicySession",
|
---|
1727 | NULL
|
---|
1728 | };
|
---|
1729 |
|
---|
1730 |
|
---|
1731 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodePolicyCommandCodeReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1732 | {
|
---|
1733 | RT_NOREF(pThis);
|
---|
1734 |
|
---|
1735 | TPM_DECODE_INIT();
|
---|
1736 | TPM_DECODE_U32_HEX(u32CmdCode, u32CmdCode);
|
---|
1737 | TPM_DECODE_END();
|
---|
1738 | }
|
---|
1739 |
|
---|
1740 |
|
---|
1741 | static const char *g_apszHandlesPolicyOrReq[] =
|
---|
1742 | {
|
---|
1743 | "hPolicySession",
|
---|
1744 | NULL
|
---|
1745 | };
|
---|
1746 |
|
---|
1747 |
|
---|
1748 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodePolicyOrReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1749 | {
|
---|
1750 | RT_NOREF(pThis);
|
---|
1751 |
|
---|
1752 | TPM_DECODE_INIT();
|
---|
1753 | vboxTraceLogDecode_TPML_DIGEST(pHlp, pCtx, "HashList");
|
---|
1754 | TPM_DECODE_END();
|
---|
1755 | }
|
---|
1756 |
|
---|
1757 |
|
---|
1758 | static const char *g_apszHandlesCreateLoadedReq[] =
|
---|
1759 | {
|
---|
1760 | "hParent",
|
---|
1761 | NULL
|
---|
1762 | };
|
---|
1763 |
|
---|
1764 |
|
---|
1765 | static const char *g_apszHandlesCreateLoadedResp[] =
|
---|
1766 | {
|
---|
1767 | "hObj",
|
---|
1768 | NULL
|
---|
1769 | };
|
---|
1770 |
|
---|
1771 |
|
---|
1772 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCreateLoadedReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1773 | {
|
---|
1774 | RT_NOREF(pThis);
|
---|
1775 |
|
---|
1776 | TPM_DECODE_INIT();
|
---|
1777 | vboxTraceLogDecode_TPM2B_SENSITIVE_CREATE(pHlp, pCtx, "InSensitive");
|
---|
1778 | TPM_DECODE_END_IF_ERROR();
|
---|
1779 | vboxTraceLogDecode_TPM2B_TEMPLATE(pHlp, pCtx, "InPublic");
|
---|
1780 | TPM_DECODE_END_IF_ERROR();
|
---|
1781 | TPM_DECODE_END();
|
---|
1782 | }
|
---|
1783 |
|
---|
1784 |
|
---|
1785 | static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeCreateLoadedResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)
|
---|
1786 | {
|
---|
1787 | RT_NOREF(pThis);
|
---|
1788 |
|
---|
1789 | TPM_DECODE_INIT();
|
---|
1790 | vboxTraceLogDecode_TPM2B_PRIVATE(pHlp, pCtx, "OutPrivate");
|
---|
1791 | TPM_DECODE_END_IF_ERROR();
|
---|
1792 | vboxTraceLogDecode_TPM2B_PUBLIC(pHlp, pCtx, "OutPublic");
|
---|
1793 | TPM_DECODE_END_IF_ERROR();
|
---|
1794 | vboxTraceLogDecode_TPM2B_NAME(pHlp, pCtx, "Name");
|
---|
1795 | TPM_DECODE_END_IF_ERROR();
|
---|
1796 | TPM_DECODE_END();
|
---|
1797 | }
|
---|
1798 |
|
---|
1799 |
|
---|
1800 | static struct
|
---|
1801 | {
|
---|
1802 | uint32_t u32CmdCode;
|
---|
1803 | const char *pszCmdCode;
|
---|
1804 | const char **papszHandlesReq;
|
---|
1805 | const char **papszHandlesResp;
|
---|
1806 | PFNFNDECODETPM2CCREQ pfnDecodeReq;
|
---|
1807 | PFNFNDECODETPM2CCRESP pfnDecodeResp;
|
---|
1808 | } s_aTpmCmdCodes[] =
|
---|
1809 | {
|
---|
1810 | #define TPM_CMD_CODE_INIT_NOT_IMPL(a_CmdCode) { a_CmdCode, #a_CmdCode, NULL, NULL, NULL, NULL }
|
---|
1811 | #define TPM_CMD_CODE_INIT(a_CmdCode, a_apszHandlesReq, a_apszHandlesResp, a_pfnReq, a_pfnResp) { a_CmdCode, #a_CmdCode, \
|
---|
1812 | a_apszHandlesReq, a_apszHandlesResp, \
|
---|
1813 | a_pfnReq, a_pfnResp }
|
---|
1814 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_UNDEFINE_SPACE_SPECIAL),
|
---|
1815 | TPM_CMD_CODE_INIT( TPM2_CC_EVICT_CONTROL, g_apszHandlesEvictControlReq, NULL, vboxTraceLogDecodeEvtTpmDecodeEvictControlReq, NULL),
|
---|
1816 | TPM_CMD_CODE_INIT( TPM2_CC_HIERARCHY_CONTROL, g_apszHandlesHierarchyControlReq, NULL, vboxTraceLogDecodeEvtTpmDecodeHierarchyControlReq, NULL),
|
---|
1817 | TPM_CMD_CODE_INIT( TPM2_CC_NV_UNDEFINE_SPACE, g_apszHandlesNvUndefineSpaceReq, NULL, NULL, NULL),
|
---|
1818 | TPM_CMD_CODE_INIT( TPM2_CC_CHANGE_EPS, g_apszHandlesChangeEpsPpsReq, NULL, NULL, NULL),
|
---|
1819 | TPM_CMD_CODE_INIT( TPM2_CC_CHANGE_PPS, g_apszHandlesChangeEpsPpsReq, NULL, NULL, NULL),
|
---|
1820 | TPM_CMD_CODE_INIT( TPM2_CC_CLEAR, g_apszHandlesClearReq, NULL, NULL, NULL),
|
---|
1821 | TPM_CMD_CODE_INIT( TPM2_CC_CLEAR_CONTROL, g_apszHandlesClearControlReq, NULL, vboxTraceLogDecodeEvtTpmDecodeClearControlReq, NULL),
|
---|
1822 | TPM_CMD_CODE_INIT( TPM2_CC_CLOCK_SET, g_apszHandlesClockSetReq, NULL, vboxTraceLogDecodeEvtTpmDecodeClockSetReq, NULL),
|
---|
1823 | TPM_CMD_CODE_INIT( TPM2_CC_HIERARCHY_CHANGE_AUTH, g_apszHandlesHierarchyChangeAuthReq, NULL, vboxTraceLogDecodeEvtTpmDecodeHierarchyChangeAuthReq, NULL),
|
---|
1824 | TPM_CMD_CODE_INIT( TPM2_CC_NV_DEFINE_SPACE, g_apszHandlesNvDefineSpaceReq, NULL, vboxTraceLogDecodeEvtTpmDecodeNvDefineSpaceReq, NULL),
|
---|
1825 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_PCR_ALLOCATE),
|
---|
1826 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_PCR_SET_AUTH_POLICY),
|
---|
1827 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_PP_COMMANDS),
|
---|
1828 | TPM_CMD_CODE_INIT( TPM2_CC_SET_PRIMARY_POLICY, g_apszHandlesSetPrimaryPolicyReq, NULL, vboxTraceLogDecodeEvtTpmDecodeSetPrimaryPolicyReq, NULL),
|
---|
1829 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_FIELD_UPGRADE_START),
|
---|
1830 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_CLOCK_RATE_ADJUST),
|
---|
1831 | TPM_CMD_CODE_INIT( TPM2_CC_CREATE_PRIMARY, g_apszHandlesCreatePrimaryReq, g_apszHandlesCreatePrimaryResp, vboxTraceLogDecodeEvtTpmDecodeCreatePrimaryReq, vboxTraceLogDecodeEvtTpmDecodeCreatePrimaryResp),
|
---|
1832 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_GLOBAL_WRITE_LOCK),
|
---|
1833 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_GET_COMMAND_AUDIT_DIGEST),
|
---|
1834 | TPM_CMD_CODE_INIT( TPM2_CC_NV_INCREMENT, g_apszHandlesNvIncrementReq, NULL, NULL, NULL),
|
---|
1835 | TPM_CMD_CODE_INIT( TPM2_CC_NV_SET_BITS, g_apszHandlesNvSetBitsReq, NULL, vboxTraceLogDecodeEvtTpmDecodeNvSetBitsReq, NULL),
|
---|
1836 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_EXTEND),
|
---|
1837 | TPM_CMD_CODE_INIT( TPM2_CC_NV_WRITE, g_apszHandlesNvWriteReq, NULL, vboxTraceLogDecodeEvtTpmDecodeNvWriteReq, NULL),
|
---|
1838 | TPM_CMD_CODE_INIT( TPM2_CC_NV_WRITE_LOCK, g_apszHandlesNvWriteLockReq, NULL, NULL, NULL),
|
---|
1839 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_DICTIONARY_ATTACK_LOCK_RESET),
|
---|
1840 | TPM_CMD_CODE_INIT( TPM2_CC_DICTIONARY_ATTACK_PARAMETERS, g_apszHandlesDictionaryAttackParametersReq, NULL, vboxTraceLogDecodeEvtTpmDecodeDictionaryAttackParametersReq, NULL),
|
---|
1841 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_CHANGE_AUTH),
|
---|
1842 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_PCR_EVENT),
|
---|
1843 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_PCR_RESET),
|
---|
1844 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_SEQUENCE_COMPLETE),
|
---|
1845 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_SET_ALGORITHM_SET),
|
---|
1846 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_SET_COMMAND_CODE_AUDIT_STATUS),
|
---|
1847 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_FIELD_UPGRADE_DATA),
|
---|
1848 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_INCREMENTAL_SELF_TEST),
|
---|
1849 | TPM_CMD_CODE_INIT( TPM2_CC_SELF_TEST, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeSelfTestReq, NULL),
|
---|
1850 | TPM_CMD_CODE_INIT( TPM2_CC_STARTUP, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeStartupShutdownReq, NULL),
|
---|
1851 | TPM_CMD_CODE_INIT( TPM2_CC_SHUTDOWN, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeStartupShutdownReq, NULL),
|
---|
1852 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_STIR_RANDOM),
|
---|
1853 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ACTIVATE_CREDENTIAL),
|
---|
1854 | TPM_CMD_CODE_INIT( TPM2_CC_CERTIFY, g_apszHandlesCertifyReq, NULL, vboxTraceLogDecodeEvtTpmDecodeCertifyReq, vboxTraceLogDecodeEvtTpmDecodeCertifyResp),
|
---|
1855 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_NV),
|
---|
1856 | TPM_CMD_CODE_INIT( TPM2_CC_CERTIFY_CREATION, g_apszHandlesCertifyCreationReq, NULL, vboxTraceLogDecodeEvtTpmDecodeCertifyCreationReq, vboxTraceLogDecodeEvtTpmDecodeCertifyCreationResp),
|
---|
1857 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_DUPLICATE),
|
---|
1858 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_GET_TIME),
|
---|
1859 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_GET_SESSION_AUDIT_DIGEST),
|
---|
1860 | TPM_CMD_CODE_INIT( TPM2_CC_NV_READ, g_apszHandlesNvReadReq, NULL, vboxTraceLogDecodeEvtTpmDecodeNvReadReq, vboxTraceLogDecodeEvtTpmDecodeNvReadResp),
|
---|
1861 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_READ_LOCK),
|
---|
1862 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_OBJECT_CHANGE_AUTH),
|
---|
1863 | TPM_CMD_CODE_INIT( TPM2_CC_POLICY_SECRET, g_apszHandlesPolicySecretReq, NULL, vboxTraceLogDecodeEvtTpmDecodePolicySecretReq, vboxTraceLogDecodeEvtTpmDecodePolicySecretResp),
|
---|
1864 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_REWRAP),
|
---|
1865 | TPM_CMD_CODE_INIT( TPM2_CC_CREATE, g_apszHandlesCreateReq, NULL, vboxTraceLogDecodeEvtTpmDecodeCreateReq, vboxTraceLogDecodeEvtTpmDecodeCreateResp),
|
---|
1866 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ECDH_ZGEN),
|
---|
1867 | TPM_CMD_CODE_INIT( TPM2_CC_HMAC_MAC, g_apszHandlesHmacMacReq, NULL, vboxTraceLogDecodeEvtTpmDecodeHmacMacReq, vboxTraceLogDecodeEvtTpmDecodeHmacMacResp),
|
---|
1868 | TPM_CMD_CODE_INIT( TPM2_CC_IMPORT, g_apszHandlesImportReq, NULL, vboxTraceLogDecodeEvtTpmDecodeImportReq, vboxTraceLogDecodeEvtTpmDecodeImportResp),
|
---|
1869 | TPM_CMD_CODE_INIT( TPM2_CC_LOAD, g_apszHandlesLoadReq, g_apszHandlesLoadResp, vboxTraceLogDecodeEvtTpmDecodeLoadReq, vboxTraceLogDecodeEvtTpmDecodeLoadResp),
|
---|
1870 | TPM_CMD_CODE_INIT( TPM2_CC_QUOTE, g_apszHandlesQuoteReq, NULL, vboxTraceLogDecodeEvtTpmDecodeQuoteReq, vboxTraceLogDecodeEvtTpmDecodeQuoteResp),
|
---|
1871 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_RSA_DECRYPT),
|
---|
1872 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_HMAC_MAC_START),
|
---|
1873 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_SEQUENCE_UPDATE),
|
---|
1874 | TPM_CMD_CODE_INIT( TPM2_CC_SIGN, g_apszHandlesSignReq, NULL, vboxTraceLogDecodeEvtTpmDecodeSignReq, vboxTraceLogDecodeEvtTpmDecodeSignResp),
|
---|
1875 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_UNSEAL),
|
---|
1876 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_SIGNED),
|
---|
1877 | TPM_CMD_CODE_INIT( TPM2_CC_CONTEXT_LOAD, NULL, g_apszHandlesContextLoadResp, vboxTraceLogDecodeEvtTpmDecodeContextLoadReq, NULL),
|
---|
1878 | TPM_CMD_CODE_INIT( TPM2_CC_CONTEXT_SAVE, g_apszHandlesContextSaveReq, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeContextSaveResp),
|
---|
1879 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ECDH_KEY_GEN),
|
---|
1880 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ENCRYPT_DECRYPT),
|
---|
1881 | TPM_CMD_CODE_INIT( TPM2_CC_FLUSH_CONTEXT, g_apszHandlesFlushContextReq, NULL, NULL, NULL),
|
---|
1882 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_LOAD_EXTERNAL),
|
---|
1883 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_MAKE_CREDENTIAL),
|
---|
1884 | TPM_CMD_CODE_INIT( TPM2_CC_NV_READ_PUBLIC, g_apszHandlesNvReadPublicReq, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeNvReadPublicResp),
|
---|
1885 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_AUTHORIZE),
|
---|
1886 | TPM_CMD_CODE_INIT( TPM2_CC_POLICY_AUTH_VALUE, g_apszHandlesPolicyAuthValueReq, NULL, NULL, NULL),
|
---|
1887 | TPM_CMD_CODE_INIT( TPM2_CC_POLICY_COMMAND_CODE, g_apszHandlesPolicyCommandCodeReq, NULL, vboxTraceLogDecodeEvtTpmDecodePolicyCommandCodeReq, NULL),
|
---|
1888 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_COUNTER_TIMER),
|
---|
1889 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_CP_HASH),
|
---|
1890 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_LOCALITY),
|
---|
1891 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_NAME_HASH),
|
---|
1892 | TPM_CMD_CODE_INIT( TPM2_CC_POLICY_OR, g_apszHandlesPolicyOrReq, NULL, vboxTraceLogDecodeEvtTpmDecodePolicyOrReq, NULL),
|
---|
1893 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_TICKET),
|
---|
1894 | TPM_CMD_CODE_INIT( TPM2_CC_READ_PUBLIC, g_apszHandlesReadPublicReq, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeReadPublicResp),
|
---|
1895 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_RSA_ENCRYPT),
|
---|
1896 | TPM_CMD_CODE_INIT( TPM2_CC_START_AUTH_SESSION, g_apszHandlesStartAuthSessionReq, g_apszHandlesStartAuthSessionResp, vboxTraceLogDecodeEvtTpmDecodeStartAuthSessionReq, vboxTraceLogDecodeEvtTpmDecodeStartAuthSessionResp),
|
---|
1897 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_VERIFY_SIGNATURE),
|
---|
1898 | TPM_CMD_CODE_INIT( TPM2_CC_ECC_PARAMETERS, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeEccParametersReq, vboxTraceLogDecodeEvtTpmDecodeEccParametersResp),
|
---|
1899 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_FIRMWARE_READ),
|
---|
1900 | TPM_CMD_CODE_INIT( TPM2_CC_GET_CAPABILITY, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeGetCapabilityReq, vboxTraceLogDecodeEvtTpmDecodeGetCapabilityResp),
|
---|
1901 | TPM_CMD_CODE_INIT( TPM2_CC_GET_RANDOM, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeGetRandomReq, vboxTraceLogDecodeEvtTpmDecodeGetRandomResp),
|
---|
1902 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_GET_TEST_RESULT),
|
---|
1903 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_GET_HASH),
|
---|
1904 | TPM_CMD_CODE_INIT( TPM2_CC_PCR_READ, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodePcrReadReq, vboxTraceLogDecodeEvtTpmDecodePcrReadResp),
|
---|
1905 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_PCR),
|
---|
1906 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_RESTART),
|
---|
1907 | TPM_CMD_CODE_INIT( TPM2_CC_READ_CLOCK, NULL, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodeReadClockResp),
|
---|
1908 | TPM_CMD_CODE_INIT( TPM2_CC_PCR_EXTEND, g_apszHandlesPcrExtendReq, NULL, vboxTraceLogDecodeEvtTpmDecodePcrExtendReq, NULL),
|
---|
1909 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_PCR_SET_AUTH_VALUE),
|
---|
1910 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_CERTIFY),
|
---|
1911 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_EVENT_SEQUENCE_COMPLETE),
|
---|
1912 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_HASH_SEQUENCE_START),
|
---|
1913 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_PHYSICAL_PRESENCE),
|
---|
1914 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_DUPLICATION_SELECT),
|
---|
1915 | TPM_CMD_CODE_INIT( TPM2_CC_POLICY_GET_DIGEST, g_apszHandlesPolicyGetDigestReq, NULL, NULL, vboxTraceLogDecodeEvtTpmDecodePolicyGetDigestResp),
|
---|
1916 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_TEST_PARMS),
|
---|
1917 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_COMMIT),
|
---|
1918 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_PASSWORD),
|
---|
1919 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ZGEN_2PHASE),
|
---|
1920 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_EC_EPHEMERAL),
|
---|
1921 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_NV_WRITTEN),
|
---|
1922 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_TEMPLATE),
|
---|
1923 | TPM_CMD_CODE_INIT( TPM2_CC_CREATE_LOADED, g_apszHandlesCreateLoadedReq, g_apszHandlesCreateLoadedResp, vboxTraceLogDecodeEvtTpmDecodeCreateLoadedReq, vboxTraceLogDecodeEvtTpmDecodeCreateLoadedResp),
|
---|
1924 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_AUTHORIZE_NV),
|
---|
1925 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ENCRYPT_DECRYPT_2),
|
---|
1926 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_AC_GET_CAPABILITY),
|
---|
1927 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_AC_SEND),
|
---|
1928 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_AC_SEND_SELECT),
|
---|
1929 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_CERTIFY_X509),
|
---|
1930 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ACT_SET_TIMEOUT),
|
---|
1931 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ECC_ENCRYPT),
|
---|
1932 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_ECC_DECRYPT),
|
---|
1933 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_CAPABILITY),
|
---|
1934 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_POLICY_PARAMETERS),
|
---|
1935 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_DEFINE_SPACE_2),
|
---|
1936 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_NV_READ_PUBLIC_2),
|
---|
1937 | TPM_CMD_CODE_INIT_NOT_IMPL(TPM2_CC_SET_CAPABILITY)
|
---|
1938 | #undef TPM_CMD_CODE_INIT
|
---|
1939 | };
|
---|
1940 |
|
---|
1941 | static void vboxTraceLogDecodeEvtTpmDecodeCmdBuffer(PRTTRACELOGDECODERHLP pHlp, const uint8_t *pbCmd, size_t cbCmd)
|
---|
1942 | {
|
---|
1943 | PCTPMREQHDR pHdr = (PCTPMREQHDR)pbCmd;
|
---|
1944 | if (cbCmd >= sizeof(*pHdr))
|
---|
1945 | {
|
---|
1946 | uint16_t u16Tag = RT_BE2H_U16(pHdr->u16Tag);
|
---|
1947 | uint32_t u32CmdCode = RT_BE2H_U32(pHdr->u32Ordinal);
|
---|
1948 | uint32_t cbReqPayload = RT_BE2H_U32(pHdr->cbReq) - sizeof(*pHdr);
|
---|
1949 | PTPMSTATE pTpmState = (PTPMSTATE)pHlp->pfnDecoderStateGet(pHlp);
|
---|
1950 |
|
---|
1951 | if (!pTpmState)
|
---|
1952 | {
|
---|
1953 | int rc = pHlp->pfnDecoderStateCreate(pHlp, sizeof(*pTpmState), NULL, (void **)&pTpmState);
|
---|
1954 | if (RT_SUCCESS(rc))
|
---|
1955 | pTpmState->u32CmdCode = u32CmdCode;
|
---|
1956 | else
|
---|
1957 | pHlp->pfnErrorMsg(pHlp, "Failed to allocate TPM decoder state: %Rrc\n", rc);
|
---|
1958 | }
|
---|
1959 | else
|
---|
1960 | pTpmState->u32CmdCode = u32CmdCode;
|
---|
1961 |
|
---|
1962 | for (uint32_t i = 0; i < RT_ELEMENTS(s_aTpmCmdCodes); i++)
|
---|
1963 | {
|
---|
1964 | if (s_aTpmCmdCodes[i].u32CmdCode == u32CmdCode)
|
---|
1965 | {
|
---|
1966 | pHlp->pfnStructBldBegin(pHlp, "Command");
|
---|
1967 | pHlp->pfnStructBldAddStr(pHlp, "CmdCode", 0 /*fFlags*/, s_aTpmCmdCodes[i].pszCmdCode);
|
---|
1968 | pHlp->pfnStructBldAddU32(pHlp, "PayloadSize", 0 /*fFlags*/, cbReqPayload);
|
---|
1969 | pHlp->pfnStructBldAddU16(pHlp, "u16Tag", RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, u16Tag);
|
---|
1970 |
|
---|
1971 | TPMDECODECTX Ctx;
|
---|
1972 | PTPMDECODECTX pCtx = &Ctx;
|
---|
1973 | vboxTraceLogDecodeEvtTpmDecodeCtxInit(&Ctx, (const uint8_t *)(pHdr + 1), cbReqPayload);
|
---|
1974 |
|
---|
1975 | /* Decode the handle area. */
|
---|
1976 | if (s_aTpmCmdCodes[i].papszHandlesReq)
|
---|
1977 | {
|
---|
1978 | pHlp->pfnStructBldBegin(pHlp, "Handles");
|
---|
1979 |
|
---|
1980 | const char **papszHnd = s_aTpmCmdCodes[i].papszHandlesReq;
|
---|
1981 | while (*papszHnd)
|
---|
1982 | {
|
---|
1983 | TPM_DECODE_U32_HEX_STR(u32Hnd, *papszHnd);
|
---|
1984 | papszHnd++;
|
---|
1985 | }
|
---|
1986 |
|
---|
1987 | pHlp->pfnStructBldEnd(pHlp);
|
---|
1988 | }
|
---|
1989 |
|
---|
1990 | /* Decode authorization area if available. */
|
---|
1991 | if (u16Tag == TPM2_ST_SESSIONS)
|
---|
1992 | {
|
---|
1993 | size_t cbAuthArea = 0;
|
---|
1994 | TPM_DECODE_INIT();
|
---|
1995 | TPM_DECODE_U32(u32AuthSize, u32AuthSize);
|
---|
1996 | cbAuthArea = u32AuthSize;
|
---|
1997 | TPM_DECODE_END();
|
---|
1998 |
|
---|
1999 | if (cbAuthArea)
|
---|
2000 | {
|
---|
2001 | const uint8_t *pb = vboxTraceLogDecodeEvtTpmDecodeCtxGetBuf(pCtx, pHlp, "AuthArea", cbAuthArea);
|
---|
2002 | if (!pCtx->fError)
|
---|
2003 | {
|
---|
2004 | TPMDECODECTX CtxAuth;
|
---|
2005 | vboxTraceLogDecodeEvtTpmDecodeCtxInit(&CtxAuth, pb, cbAuthArea);
|
---|
2006 |
|
---|
2007 | pHlp->pfnStructBldBegin(pHlp, "AuthArea");
|
---|
2008 | while ( CtxAuth.cbLeft
|
---|
2009 | && !CtxAuth.fError)
|
---|
2010 | vboxTraceLogDecodeEvtTpmAuthSessionReq(pHlp, &CtxAuth);
|
---|
2011 | pHlp->pfnStructBldEnd(pHlp);
|
---|
2012 | }
|
---|
2013 | }
|
---|
2014 | }
|
---|
2015 |
|
---|
2016 | /* Decode parameters. */
|
---|
2017 | if (s_aTpmCmdCodes[i].pfnDecodeReq)
|
---|
2018 | {
|
---|
2019 | pHlp->pfnStructBldBegin(pHlp, "Parameters");
|
---|
2020 | s_aTpmCmdCodes[i].pfnDecodeReq(pHlp, pTpmState, &Ctx);
|
---|
2021 | pHlp->pfnStructBldEnd(pHlp);
|
---|
2022 | }
|
---|
2023 |
|
---|
2024 | if (pCtx->cbLeft)
|
---|
2025 | pHlp->pfnStructBldAddBuf(pHlp, "Leftover undecoded data", 0 /*fFlags*/, pCtx->pbBuf, pCtx->cbLeft);
|
---|
2026 |
|
---|
2027 | pHlp->pfnStructBldEnd(pHlp);
|
---|
2028 | return;
|
---|
2029 | }
|
---|
2030 | }
|
---|
2031 | pHlp->pfnPrintf(pHlp, " <Unknown command code>: %#x\n", u32CmdCode);
|
---|
2032 |
|
---|
2033 | if (cbReqPayload)
|
---|
2034 | pHlp->pfnPrintf(pHlp, "%.*Rhxd\n", cbReqPayload, pHdr + 1);
|
---|
2035 | }
|
---|
2036 | else
|
---|
2037 | pHlp->pfnErrorMsg(pHlp, "Command buffer is smaller than the request header (required %u, given %zu\n", sizeof(*pHdr), cbCmd);
|
---|
2038 | }
|
---|
2039 |
|
---|
2040 |
|
---|
2041 | static void vboxTraceLogDecodeEvtTpmDecodeRespBuffer(PRTTRACELOGDECODERHLP pHlp, const uint8_t *pbResp, size_t cbResp)
|
---|
2042 | {
|
---|
2043 | RT_NOREF(pHlp);
|
---|
2044 |
|
---|
2045 | PCTPMRESPHDR pHdr = (PCTPMRESPHDR)pbResp;
|
---|
2046 | if (cbResp >= sizeof(*pHdr))
|
---|
2047 | {
|
---|
2048 | uint32_t cbRespPayload = RT_BE2H_U32(pHdr->cbResp) - sizeof(*pHdr);
|
---|
2049 | uint32_t u32ErrCode = RT_BE2H_U32(pHdr->u32ErrCode);
|
---|
2050 | uint16_t u16Tag = RT_BE2H_U16(pHdr->u16Tag);
|
---|
2051 |
|
---|
2052 | pHlp->pfnStructBldBegin(pHlp, "Response");
|
---|
2053 |
|
---|
2054 | pHlp->pfnStructBldAddU16(pHlp, "u16Tag", RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, u16Tag);
|
---|
2055 | pHlp->pfnStructBldAddU32(pHlp, "u32ErrCode", 0 /*fFlags*/, u32ErrCode);
|
---|
2056 | pHlp->pfnStructBldAddU32(pHlp, "cbResponse", 0 /*fFlags*/, cbRespPayload);
|
---|
2057 |
|
---|
2058 | PTPMSTATE pTpmState = (PTPMSTATE)pHlp->pfnDecoderStateGet(pHlp);
|
---|
2059 |
|
---|
2060 | /* Can only decode the response buffer if we know the command code. */
|
---|
2061 | if ( pTpmState
|
---|
2062 | && u32ErrCode == TPM_SUCCESS)
|
---|
2063 | {
|
---|
2064 | TPMDECODECTX Ctx;
|
---|
2065 | PTPMDECODECTX pCtx = &Ctx;
|
---|
2066 | vboxTraceLogDecodeEvtTpmDecodeCtxInit(&Ctx, (const uint8_t *)(pHdr + 1), cbRespPayload);
|
---|
2067 |
|
---|
2068 | for (uint32_t i = 0; i < RT_ELEMENTS(s_aTpmCmdCodes); i++)
|
---|
2069 | {
|
---|
2070 | if (s_aTpmCmdCodes[i].u32CmdCode == pTpmState->u32CmdCode)
|
---|
2071 | {
|
---|
2072 | /* Decode the handle area. */
|
---|
2073 | uint32_t cHandles = 0;
|
---|
2074 | if (s_aTpmCmdCodes[i].papszHandlesResp)
|
---|
2075 | {
|
---|
2076 | pHlp->pfnStructBldBegin(pHlp, "Handles");
|
---|
2077 |
|
---|
2078 | const char **papszHnd = s_aTpmCmdCodes[i].papszHandlesResp;
|
---|
2079 | while (*papszHnd)
|
---|
2080 | {
|
---|
2081 | TPM_DECODE_U32_HEX_STR(u32Hnd, *papszHnd);
|
---|
2082 | papszHnd++;
|
---|
2083 | cHandles++;
|
---|
2084 | }
|
---|
2085 |
|
---|
2086 | pHlp->pfnStructBldEnd(pHlp);
|
---|
2087 | }
|
---|
2088 |
|
---|
2089 | size_t cbParams = cbRespPayload - cHandles * sizeof(uint32_t);
|
---|
2090 | if (u16Tag == TPM2_ST_SESSIONS)
|
---|
2091 | {
|
---|
2092 | TPM_DECODE_INIT();
|
---|
2093 | TPM_DECODE_U32(u32ParamSz, u32ParamSize);
|
---|
2094 | cbParams = u32ParamSz;
|
---|
2095 | TPM_DECODE_END();
|
---|
2096 | }
|
---|
2097 |
|
---|
2098 | /* Decode parameters. */
|
---|
2099 | if ( s_aTpmCmdCodes[i].pfnDecodeResp
|
---|
2100 | && cbParams)
|
---|
2101 | {
|
---|
2102 | const uint8_t *pb = vboxTraceLogDecodeEvtTpmDecodeCtxGetBuf(pCtx, pHlp, "Parameters", cbParams);
|
---|
2103 | if (!pCtx->fError)
|
---|
2104 | {
|
---|
2105 | TPMDECODECTX CtxParams;
|
---|
2106 | vboxTraceLogDecodeEvtTpmDecodeCtxInit(&CtxParams, pb, cbParams);
|
---|
2107 |
|
---|
2108 | pHlp->pfnStructBldBegin(pHlp, "Parameters");
|
---|
2109 | s_aTpmCmdCodes[i].pfnDecodeResp(pHlp, pTpmState, &CtxParams);
|
---|
2110 |
|
---|
2111 | if (CtxParams.cbLeft)
|
---|
2112 | pHlp->pfnStructBldAddBuf(pHlp, "Leftover undecoded data", 0 /*fFlags*/, CtxParams.pbBuf, CtxParams.cbLeft);
|
---|
2113 | pHlp->pfnStructBldEnd(pHlp);
|
---|
2114 | }
|
---|
2115 | }
|
---|
2116 |
|
---|
2117 | /* Decode authorization area if available. */
|
---|
2118 | if (u16Tag == TPM2_ST_SESSIONS)
|
---|
2119 | vboxTraceLogDecodeEvtTpmAuthSessionResp(pHlp, pCtx);
|
---|
2120 |
|
---|
2121 | if (pCtx->cbLeft)
|
---|
2122 | pHlp->pfnStructBldAddBuf(pHlp, "Leftover undecoded data", 0 /*fFlags*/, pCtx->pbBuf, pCtx->cbLeft);
|
---|
2123 | pHlp->pfnStructBldEnd(pHlp);
|
---|
2124 | return;
|
---|
2125 | }
|
---|
2126 | }
|
---|
2127 | }
|
---|
2128 |
|
---|
2129 | if (cbRespPayload)
|
---|
2130 | pHlp->pfnStructBldAddBuf(pHlp, "Data", 0 /*fFlags*/, (const uint8_t *)(pHdr + 1), cbRespPayload);
|
---|
2131 |
|
---|
2132 | pHlp->pfnStructBldEnd(pHlp);
|
---|
2133 | }
|
---|
2134 | else
|
---|
2135 | pHlp->pfnErrorMsg(pHlp, "Response buffer is smaller than the request header (required %u, given %zu\n", sizeof(*pHdr), cbResp);
|
---|
2136 | }
|
---|
2137 |
|
---|
2138 |
|
---|
2139 | static DECLCALLBACK(int) vboxTraceLogDecodeEvtTpm(PRTTRACELOGDECODERHLP pHlp, uint32_t idDecodeEvt, RTTRACELOGRDREVT hTraceLogEvt,
|
---|
2140 | PCRTTRACELOGEVTDESC pEvtDesc, PRTTRACELOGEVTVAL paVals, uint32_t cVals)
|
---|
2141 | {
|
---|
2142 | RT_NOREF(hTraceLogEvt, pEvtDesc);
|
---|
2143 | if (idDecodeEvt == 0)
|
---|
2144 | {
|
---|
2145 | for (uint32_t i = 0; i < cVals; i++)
|
---|
2146 | {
|
---|
2147 | /* Look for the pvCmd item which stores the command buffer. */
|
---|
2148 | if ( !strcmp(paVals[i].pItemDesc->pszName, "pvCmd")
|
---|
2149 | && paVals[i].pItemDesc->enmType == RTTRACELOGTYPE_RAWDATA)
|
---|
2150 | {
|
---|
2151 | vboxTraceLogDecodeEvtTpmDecodeCmdBuffer(pHlp, paVals[i].u.RawData.pb, paVals[i].u.RawData.cb);
|
---|
2152 | return VINF_SUCCESS;
|
---|
2153 | }
|
---|
2154 | }
|
---|
2155 |
|
---|
2156 | pHlp->pfnErrorMsg(pHlp, "Failed to find the TPM command data buffer for the given event\n");
|
---|
2157 | }
|
---|
2158 | else if (idDecodeEvt == 1)
|
---|
2159 | {
|
---|
2160 | for (uint32_t i = 0; i < cVals; i++)
|
---|
2161 | {
|
---|
2162 | /* Look for the pvCmd item which stores the response buffer. */
|
---|
2163 | if ( !strcmp(paVals[i].pItemDesc->pszName, "pvResp")
|
---|
2164 | && paVals[i].pItemDesc->enmType == RTTRACELOGTYPE_RAWDATA)
|
---|
2165 | {
|
---|
2166 | vboxTraceLogDecodeEvtTpmDecodeRespBuffer(pHlp, paVals[i].u.RawData.pb, paVals[i].u.RawData.cb);
|
---|
2167 | return VINF_SUCCESS;
|
---|
2168 | }
|
---|
2169 | }
|
---|
2170 | pHlp->pfnErrorMsg(pHlp, "Failed to find the TPM command response buffer for the given event\n");
|
---|
2171 | }
|
---|
2172 |
|
---|
2173 | pHlp->pfnErrorMsg(pHlp, "Decode event ID %u is not known to this decoder\n", idDecodeEvt);
|
---|
2174 | return VERR_NOT_FOUND;
|
---|
2175 | }
|
---|
2176 |
|
---|
2177 |
|
---|
2178 | /**
|
---|
2179 | * TPM decoder event IDs.
|
---|
2180 | */
|
---|
2181 | static const RTTRACELOGDECODEEVT s_aDecodeEvtTpm[] =
|
---|
2182 | {
|
---|
2183 | { "ITpmConnector.CmdExecReq", 0 },
|
---|
2184 | { "ITpmConnector.CmdExecResp", 1 },
|
---|
2185 | { NULL, UINT32_MAX }
|
---|
2186 | };
|
---|
2187 |
|
---|
2188 |
|
---|
2189 | /**
|
---|
2190 | * Decoder plugin interface.
|
---|
2191 | */
|
---|
2192 | static const RTTRACELOGDECODERREG g_TraceLogDecoderTpm =
|
---|
2193 | {
|
---|
2194 | /** pszName */
|
---|
2195 | "TPM",
|
---|
2196 | /** pszDesc */
|
---|
2197 | "Decodes events from the ITpmConnector interface generated with the IfTrace driver.",
|
---|
2198 | /** paEvtIds */
|
---|
2199 | s_aDecodeEvtTpm,
|
---|
2200 | /** pfnDecode */
|
---|
2201 | vboxTraceLogDecodeEvtTpm,
|
---|
2202 | };
|
---|
2203 |
|
---|
2204 |
|
---|
2205 | /**
|
---|
2206 | * Shared object initialization callback.
|
---|
2207 | */
|
---|
2208 | extern "C" DECLCALLBACK(DECLEXPORT(int)) RTTraceLogDecoderLoad(void *pvUser, PRTTRACELOGDECODERREGISTER pRegisterCallbacks)
|
---|
2209 | {
|
---|
2210 | AssertLogRelMsgReturn(pRegisterCallbacks->u32Version == RT_TRACELOG_DECODERREG_CB_VERSION,
|
---|
2211 | ("pRegisterCallbacks->u32Version=%#x RT_TRACELOG_DECODERREG_CB_VERSION=%#x\n",
|
---|
2212 | pRegisterCallbacks->u32Version, RT_TRACELOG_DECODERREG_CB_VERSION),
|
---|
2213 | VERR_VERSION_MISMATCH);
|
---|
2214 |
|
---|
2215 | return pRegisterCallbacks->pfnRegisterDecoders(pvUser, &g_TraceLogDecoderTpm, 1);
|
---|
2216 | }
|
---|
2217 |
|
---|