VirtualBox

source: vbox/trunk/include/iprt/tpm.h@ 97583

Last change on this file since 97583 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/** @file
2 * IPRT Trusted Platform Module API abstracting host specific APIs.
3 */
4
5/*
6 * Copyright (C) 2021-2022 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef IPRT_INCLUDED_tpm_h
37#define IPRT_INCLUDED_tpm_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <iprt/types.h>
43
44#include <iprt/formats/tpm.h>
45
46
47RT_C_DECLS_BEGIN
48
49/** @defgroup grp_rt_tpm IPRT Trusted Platform Module API
50 * @ingroup grp_rt
51 *
52 * This API provides a uniform way to access a Trusted Platform Module across all
53 * supported hosts.
54 *
55 * @{
56 */
57
58
59/**
60 * TPM version.
61 */
62typedef enum RTTPMVERSION
63{
64 /** The usual invalid option. */
65 RTTPMVERSION_INVALID = 0,
66 /** TPM conforms to version 1.2 of the TCG specification. */
67 RTTPMVERSION_1_2,
68 /** TPM conforms to version 2.0 of the TCG specification. */
69 RTTPMVERSION_2_0,
70 /** TPM version couldn't be acquired. */
71 RTTPMVERSION_UNKNOWN,
72 /** Usual 32bit hack. */
73 RTTPMVERSION_32BIT_HACK = 0x7fffffff
74} RTTPMVERSION;
75/** Pointer to a TPM version. */
76typedef RTTPMVERSION *PRTTPMVERSION;
77
78/** TPM handle. */
79typedef struct RTTPMINT *RTTPM;
80/** Pointer to a TPM handle. */
81typedef RTTPM *PRTTPM;
82/** NIL TPM handle value. */
83#define NIL_RTTPM ((RTTPM)0)
84
85
86/** Default TPM of the host. */
87#define RTTPM_ID_DEFAULT UINT32_C(0xffffffff)
88
89/**
90 * Tries to open the given TPM returning a handle.
91 *
92 * @returns IPRT status code.
93 * @param phTpm Where to store the handle to the TPM module on success.
94 * @param idTpm The TPM to open, use RTTPM_ID_DEFAULT for the default TPM of the system.
95 */
96RTDECL(int) RTTpmOpen(PRTTPM phTpm, uint32_t idTpm);
97
98
99/**
100 * Closes the given TPM handle freeing all allocated resources.
101 *
102 * @returns IPRT status code.
103 * @param hTpm Handle of the TPM to close.
104 */
105RTDECL(int) RTTpmClose(RTTPM hTpm);
106
107
108/**
109 * Returns the version of the TPM for the given handle.
110 *
111 * @returns Version implemented by the TPM.
112 * @param hTpm Handle of the TPM.
113 */
114RTDECL(RTTPMVERSION) RTTpmGetVersion(RTTPM hTpm);
115
116
117/**
118 * Returns the maximum locality supported by the given TPM.
119 *
120 * @returns Maximum locality supported (0-4).
121 * @param hTpm Handle of the TPM.
122 */
123RTDECL(uint32_t) RTTpmGetLocalityMax(RTTPM hTpm);
124
125
126/**
127 * Cancels a currently executed request for the given TPM handle.
128 *
129 * @returns IPRT status code.
130 * @param hTpm Handle of the TPM.
131 */
132RTDECL(int) RTTpmReqCancel(RTTPM hTpm);
133
134
135/**
136 * Executes the given request on the given TPM handle.
137 *
138 * @returns IPRT status code.
139 * @param hTpm Handle of the TPM.
140 * @param bLoc The locality to use (only 0 might be supported on some hosts).
141 * @param pvReq The request data.
142 * @param cbReq Size of the request in bytes.
143 * @param pvResp Where to store the response data.
144 * @param cbRespMax Size of the response buffer.
145 * @param pcbResp Where to store the actual size of the response, optional.
146 */
147RTDECL(int) RTTpmReqExec(RTTPM hTpm, uint8_t bLoc, const void *pvReq, size_t cbReq,
148 void *pvResp, size_t cbRespMax, size_t *pcbResp);
149
150
151/** @} */
152
153RT_C_DECLS_END
154
155#endif /* !IPRT_INCLUDED_tpm_h */
156
Note: See TracBrowser for help on using the repository browser.

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