VirtualBox

Changeset 104918 in vbox


Ignore:
Timestamp:
Jun 14, 2024 9:01:03 AM (10 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
163520
Message:

Devices/Trace: Some more decoding for TPM commands, bugref:10701

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/formats/tpm.h

    r104905 r104918  
    55
    66/*
    7  * Copyright (C) 2021-2023 Oracle and/or its affiliates.
     7 * Copyright (C) 2021-2024 Oracle and/or its affiliates.
    88 *
    99 * This file is part of VirtualBox base platform packages, as
     
    4646#include <iprt/assertcompile.h>
    4747#include <iprt/string.h>
     48
     49
     50/** A TPM generic handle (TPM_HANDLE). */
     51typedef uint32_t TPMHANDLE;
     52/** TPM interface object handle. */
     53typedef TPMHANDLE TPMIDHOBJECT;
    4854
    4955
     
    414420/** @name Defines related to TPM2_CC_GET_CAPABILITY.
    415421 * @{ */
     422#define TPM2_CAP_ALGS                       UINT32_C(0x00000000)
     423#define TPM2_CAP_HANDLES                    UINT32_C(0x00000001)
     424#define TPM2_CAP_COMMANDS                   UINT32_C(0x00000002)
     425#define TPM2_CAP_PP_COMMANDS                UINT32_C(0x00000003)
     426#define TPM2_CAP_AUDIT_COMMANDS             UINT32_C(0x00000004)
     427#define TPM2_CAP_PCRS                       UINT32_C(0x00000005)
     428#define TPM2_CAP_ALGS                       UINT32_C(0x00000000)
    416429/** Return a TPM related property. */
    417 #define TPM2_CAP_TPM_PROPERTIES             UINT32_C(6)
    418 
     430#define TPM2_CAP_TPM_PROPERTIES             UINT32_C(0x00000006)
     431#define TPM2_CAP_PCR_PROPERTIES             UINT32_C(0x00000007)
     432#define TPM2_CAP_ECC_CURVES                 UINT32_C(0x00000008)
     433#define TPM2_CAP_AUTH_POLICIES              UINT32_C(0x00000009)
     434#define TPM2_CAP_ACT                        UINT32_C(0x0000000a)
     435
     436
     437#define TPM2_PT_FAMILY_INDICATOR            UINT32_C(0x00000100)
     438#define TPM2_PT_LEVEL                       UINT32_C(0x00000101)
     439#define TPM2_PT_REVISION                    UINT32_C(0x00000102)
     440#define TPM2_PT_DAY_OF_YEAR                 UINT32_C(0x00000103)
     441#define TPM2_PT_YEAR                        UINT32_C(0x00000104)
     442#define TPM2_PT_MANUFACTURER                UINT32_C(0x00000105)
     443#define TPM2_PT_VENDOR_STRING_1             UINT32_C(0x00000106)
     444#define TPM2_PT_VENDOR_STRING_2             UINT32_C(0x00000107)
     445#define TPM2_PT_VENDOR_STRING_3             UINT32_C(0x00000108)
     446#define TPM2_PT_VENDOR_STRING_4             UINT32_C(0x00000109)
     447#define TPM2_PT_VENDOR_TPM_TYPE             UINT32_C(0x0000010a)
     448#define TPM2_PT_FIRMWARE_VERSION_1          UINT32_C(0x0000010b)
     449#define TPM2_PT_FIRMWARE_VERSION_2          UINT32_C(0x0000010c)
    419450/** Returns the size of the input buffer. */
    420 #define TPM2_PT_INPUT_BUFFER                UINT32_C(0x10d)
     451#define TPM2_PT_INPUT_BUFFER                UINT32_C(0x0000010d)
     452#define TPM2_PT_HR_TRANSIENT_MIN            UINT32_C(0x0000010e)
     453#define TPM2_PT_HR_PERSISTENT_MIN           UINT32_C(0x0000010f)
     454#define TPM2_PT_HR_LOADED_MIN               UINT32_C(0x00000110)
     455#define TPM2_PT_ACTIVE_SESSIONS_MAX         UINT32_C(0x00000111)
     456#define TPM2_PT_PCR_COUNT                   UINT32_C(0x00000112)
     457#define TPM2_PT_PCR_SELECT_MIN              UINT32_C(0x00000113)
     458#define TPM2_PT_CONTEXT_GAP_MAX             UINT32_C(0x00000114)
     459#define TPM2_PT_RESERVED                    UINT32_C(0x00000115)
     460#define TPM2_PT_NV_COUNTERS_MAX             UINT32_C(0x00000116)
     461#define TPM2_PT_NV_INDEX                    UINT32_C(0x00000117)
     462#define TPM2_PT_MEMORY                      UINT32_C(0x00000118)
     463#define TPM2_PT_CLOCK_UPDATE                UINT32_C(0x00000119)
     464#define TPM2_PT_CONTEXT_HASH                UINT32_C(0x0000011a)
     465#define TPM2_PT_CONTEXT_SYM                 UINT32_C(0x0000011b)
     466#define TPM2_PT_CONTEXT_SYM_SIZE            UINT32_C(0x0000011c)
     467#define TPM2_PT_ORDERLY_COUNT               UINT32_C(0x0000011d)
     468#define TPM2_PT_MAX_COMMAND_SIZE            UINT32_C(0x0000011e)
     469#define TPM2_PT_MAX_RESPONSE_SIZE           UINT32_C(0x0000011f)
     470#define TPM2_PT_MAX_DIGEST                  UINT32_C(0x00000120)
     471#define TPM2_PT_MAX_OBJECT_CONTEXT          UINT32_C(0x00000121)
     472#define TPM2_PT_MAX_SESSION_CONTEXT         UINT32_C(0x00000122)
     473#define TPM2_PT_PS_FAMILY_INDICATOR         UINT32_C(0x00000123)
     474#define TPM2_PT_PS_LEVEL                    UINT32_C(0x00000124)
     475#define TPM2_PT_PS_REVISION                 UINT32_C(0x00000125)
     476#define TPM2_PT_PS_DAY_OF_YEAR              UINT32_C(0x00000126)
     477#define TPM2_PT_PS_YEAR                     UINT32_C(0x00000127)
     478#define TPM2_PT_SPLIT_MAX                   UINT32_C(0x00000128)
     479#define TPM2_PT_TOTAL_COMMANDS              UINT32_C(0x00000129)
     480#define TPM2_PT_LIBRARY_COMMANDS            UINT32_C(0x0000012a)
     481#define TPM2_PT_VENDOR_COMMANDS             UINT32_C(0x0000012b)
     482#define TPM2_PT_NV_BUFFER_MAX               UINT32_C(0x0000012c)
     483#define TPM2_PT_MODES                       UINT32_C(0x0000012d)
     484#define TPM2_PT_MAX_CAP_BUFFER              UINT32_C(0x0000012e)
     485#define TPM2_PT_FIRMWARE_SVN                UINT32_C(0x0000012f)
     486#define TPM2_PT_FIRMWARE_MAX_SVN            UINT32_C(0x00000130)
     487
    421488
    422489/**
     
    440507/** Pointer to a const TPM2_CC_GET_CAPABILITY request. */
    441508typedef const TPM2REQGETCAPABILITY *PCTPM2REQGETCAPABILITY;
     509/** @} */
     510
     511
     512/** @name Defines related to TPM2_CC_READ_PUBLIC.
     513 * @{ */
     514/**
     515 * TPM2_CC_READ_PUBLIC request.
     516 */
     517#pragma pack(1)
     518typedef struct TPM2REQREADPUBLIC
     519{
     520    /** Request header. */
     521    TPMREQHDR                   Hdr;
     522    /** The object handle to query. */
     523    TPMIDHOBJECT                hObj;
     524} TPM2REQREADPUBLIC;
     525#pragma pack()
     526/** Pointer to a TPM2_CC_READ_PUBLIC request. */
     527typedef TPM2REQREADPUBLIC *PTPM2REQREADPUBLIC;
     528/** Pointer to a const TPM2_CC_READ_PUBLIC request. */
     529typedef const TPM2REQREADPUBLIC *PCTPM2REQREADPUBLIC;
    442530/** @} */
    443531
  • trunk/src/VBox/Devices/Trace/VBoxTraceLogDecoders.cpp

    r104903 r104918  
    7878
    7979
     80static struct
     81{
     82    const char     *pszCap;
     83    const uint32_t *paProperties;   
     84} s_aTpm2Caps[] =
     85{
     86    { RT_STR(TPM2_CAP_ALGS),            NULL },
     87    { RT_STR(TPM2_CAP_HANDLES),         NULL },
     88    { RT_STR(TPM2_CAP_COMMANDS),        NULL },
     89    { RT_STR(TPM2_CAP_PP_COMMANDS),     NULL },
     90    { RT_STR(TPM2_CAP_AUDIT_COMMANDS),  NULL },
     91    { RT_STR(TPM2_CAP_PCRS),            NULL },
     92    { RT_STR(TPM2_CAP_TPM_PROPERTIES),  NULL },
     93    { RT_STR(TPM2_CAP_PCR_PROPERTIES),  NULL },
     94    { RT_STR(TPM2_CAP_ECC_CURVES),      NULL },
     95    { RT_STR(TPM2_CAP_AUTH_POLICIES),   NULL },
     96    { RT_STR(TPM2_CAP_ACT),             NULL },
     97};
     98
    8099static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeGetCapability(PCTPMREQHDR pHdr, size_t cb)
    81100{
     
    83102    {
    84103        PCTPM2REQGETCAPABILITY pReq = (PCTPM2REQGETCAPABILITY)pHdr;
    85         RTMsgInfo("        u32Cap:      %#x\n"
    86                   "        u32Property: %#x\n"
    87                   "        u32Count:    %#x\n",
    88                   RT_BE2H_U32(pReq->u32Cap),
    89                   RT_BE2H_U32(pReq->u32Property),
    90                   RT_BE2H_U32(pReq->u32Count));
     104        uint32_t u32Cap      = RT_BE2H_U32(pReq->u32Cap);
     105        uint32_t u32Property = RT_BE2H_U32(pReq->u32Property);
     106        uint32_t u32Count    = RT_BE2H_U32(pReq->u32Count);
     107        if (u32Cap < RT_ELEMENTS(s_aTpm2Caps))
     108            RTMsgInfo("        u32Cap:      %s\n"
     109                      "        u32Property: %#x\n"
     110                      "        u32Count:    %#x\n",
     111                      s_aTpm2Caps[u32Cap], u32Property, u32Count);
     112        else
     113            RTMsgInfo("        u32Cap:      %#x (UNKNOWN)\n"
     114                      "        u32Property: %#x\n"
     115                      "        u32Count:    %#x\n",
     116                      u32Cap, u32Property, u32Count);
    91117        return;
    92118    }
    93119
    94120    RTMsgError("Malformed TPM2_CC_GET_CAPABILITY command, not enough room for the input\n");
     121}
     122
     123
     124static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeReadPublic(PCTPMREQHDR pHdr, size_t cb)
     125{
     126    if (cb >= sizeof(TPM2REQREADPUBLIC))
     127    {
     128        PCTPM2REQREADPUBLIC pReq = (PCTPM2REQREADPUBLIC)pHdr;
     129        TPMIDHOBJECT hObj = RT_BE2H_U32(pReq->hObj);
     130        RTMsgInfo("        hObj:      %#x\n", hObj);
     131        return;
     132    }
     133
     134    RTMsgError("Malformed TPM2_CC_READ_PUBLIC command, not enough room for the input\n");
    95135}
    96136
     
    184224    TPM_CMD_CODE_INIT(TPM2_CC_POLICY_OR,                        NULL),
    185225    TPM_CMD_CODE_INIT(TPM2_CC_POLICY_TICKET,                    NULL),
    186     TPM_CMD_CODE_INIT(TPM2_CC_READ_PUBLIC,                      NULL),
     226    TPM_CMD_CODE_INIT(TPM2_CC_READ_PUBLIC,                      vboxTraceLogDecodeEvtTpmDecodeReadPublic),
    187227    TPM_CMD_CODE_INIT(TPM2_CC_RSA_ENCRYPT,                      NULL),
    188228    TPM_CMD_CODE_INIT(TPM2_CC_START_AUTH_SESSION,               NULL),
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette