ia64/xen-unstable

view tools/vtpm_manager/manager/vtpmpriv.h @ 9116:f3661f9a95dd

VTPM_Tools: Fix error when closing only vtpm, and fix restore bug when
no dmis exist

The first bug prevented the TPM tests from running successfully more
than once in a row.

Signed-off-by: Vinnie Scarlata <vincent.r.scarlata@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Mar 03 10:46:06 2006 +0100 (2006-03-03)
parents 201d48272a57
children 72ef14e79cc0
line source
1 // ===================================================================
2 //
3 // Copyright (c) 2005, Intel Corp.
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions
8 // are met:
9 //
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 // * Neither the name of Intel Corporation nor the names of its
17 // contributors may be used to endorse or promote products derived
18 // from this software without specific prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 // OF THE POSSIBILITY OF SUCH DAMAGE.
32 // ===================================================================
33 //
34 // vtpmpriv.h
35 //
36 // Structures and functions private to the manager
37 //
38 // ==================================================================
40 #ifndef __VTPMPRIV_H__
41 #define __VTPMPRIV_H__
43 #include "tcg.h"
44 #include "tcs.h"
45 #include "buffer.h"
46 #include "crypto.h"
48 #define STATE_FILE "/var/vtpm/VTPM"
49 #define DMI_NVM_FILE "/var/vtpm/vtpm_dm_%d.data"
50 #define VTPM_BE_DEV "/dev/vtpm"
51 #define VTPM_CTL_DM 0
53 #ifndef VTPM_MUTLI_VM
54 #include <sys/types.h>
55 #define GUEST_TX_FIFO "/var/vtpm/fifos/guest-to-%d.fifo"
56 #define GUEST_RX_FIFO "/var/vtpm/fifos/guest-from-all.fifo"
58 #define VTPM_TX_FIFO "/var/vtpm/fifos/vtpm-to-%d.fifo"
59 #define VTPM_RX_FIFO "/var/vtpm/fifos/vtpm-from-all.fifo"
61 #define BE_LISTENER_THREAD 1
62 #define DMI_LISTENER_THREAD 2
64 // Seconds until DMI timeout. Timeouts result in DMI being out
65 // of sync, which may require a reboot of DMI and guest to recover
66 // from. Don't set this to low. Also note that DMI may issue a TPM
67 // call so we should expect time to process at DMI + TPM processing.
68 #define DMI_TIMEOUT 90
69 #endif
72 // ------------------------ Private Structures -----------------------
73 typedef struct VTPM_DMI_RESOURCE_T {
74 // I/O info for Manager to talk to DMI's over FIFOs
75 #ifndef VTPM_MUTLI_VM
76 int guest_tx_fh; // open GUEST_TX_FIFO
77 int vtpm_tx_fh; // open VTPM_TX_FIFO
78 char *guest_tx_fname; // open GUEST_TX_FIFO
79 char *vtpm_tx_fname; // open VTPM_TX_FIFO
81 pid_t dmi_pid;
82 #endif
83 // Non-persistent Information
84 bool connected;
85 UINT32 dmi_domain_id;
86 TCS_CONTEXT_HANDLE TCSContext; // TCS Handle
87 char *NVMLocation; // NULL term string indicating location
88 // of NVM.
89 // Persistent Information about DMI
90 UINT32 dmi_id;
91 TPM_DIGEST NVM_measurement; // Equal to the SHA1 of the blob
92 TPM_DIGEST DMI_measurement; // Correct measurement of the owning DMI
93 } VTPM_DMI_RESOURCE;
95 typedef struct tdVTPM_GLOBALS {
96 // Non-persistent data
97 int be_fh; // File handle to ipc used to communicate with backend
98 #ifndef VTPM_MULTI_VM
99 int vtpm_rx_fh;
100 int guest_rx_fh;
101 int connected_dmis; // Used to close guest_rx when no dmis are connected
103 pid_t master_pid;
104 #endif
105 struct hashtable *dmi_map; // Table of all DMI's known indexed by persistent instance #
106 #ifndef VTPM_MULTI_VM
107 pthread_mutex_t dmi_map_mutex; //
108 #endif
109 TCS_CONTEXT_HANDLE manager_tcs_handle; // TCS Handle used by manager
110 TPM_HANDLE storageKeyHandle; // Key used by persistent store
111 CRYPTO_INFO storageKey; // For software encryption
112 CRYPTO_INFO bootKey; // For saving table
113 TCS_AUTH keyAuth; // OIAP session for storageKey
114 BOOL DMI_table_dirty; // Indicates that a command
115 // has updated the DMI table
118 // Persistent Data
119 TPM_AUTHDATA owner_usage_auth; // OwnerAuth of real TPM
120 buffer_t storageKeyWrap; // Wrapped copy of storageKey
121 TPM_AUTHDATA srk_usage_auth;
122 TPM_AUTHDATA storage_key_usage_auth;
124 buffer_t bootKeyWrap; // Wrapped copy of boot key
126 }VTPM_GLOBALS;
128 // --------------------------- Global Values --------------------------
129 extern VTPM_GLOBALS *vtpm_globals; // Key info and DMI states
130 extern const TPM_AUTHDATA SRK_AUTH; // SRK Well Known Auth Value
132 // ********************** Command Handler Prototypes ***********************
133 TPM_RESULT VTPM_Handle_Load_NVM( VTPM_DMI_RESOURCE *myDMI,
134 const buffer_t *inbuf,
135 buffer_t *outbuf);
137 TPM_RESULT VTPM_Handle_Save_NVM( VTPM_DMI_RESOURCE *myDMI,
138 const buffer_t *inbuf,
139 buffer_t *outbuf);
141 TPM_RESULT VTPM_Handle_TPM_Command( VTPM_DMI_RESOURCE *dmi,
142 buffer_t *inbuf,
143 buffer_t *outbuf);
145 TPM_RESULT VTPM_Handle_New_DMI(const buffer_t *param_buf);
147 TPM_RESULT VTPM_Handle_Close_DMI(const buffer_t *param_buf);
149 TPM_RESULT VTPM_Handle_Delete_DMI(const buffer_t *param_buf);
151 TPM_RESULT VTPM_SaveService(void);
152 TPM_RESULT VTPM_LoadService(void);
154 TPM_RESULT close_dmi( VTPM_DMI_RESOURCE *dmi_res);
155 #endif // __VTPMPRIV_H__