aboutsummaryrefslogtreecommitdiffstats
path: root/tools/vtpm_manager
diff options
context:
space:
mode:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2006-06-27 11:13:24 +0100
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2006-06-27 11:13:24 +0100
commitf8b88793c549b5281ad0bd86bdcf0fd2b8fc6d3d (patch)
tree53d2c8d31503fcd7602ca988c2f0dd2785abe14d /tools/vtpm_manager
parentdb57f1b6d8534b39dd1b757cb507d9f285f21ccc (diff)
downloadxen-f8b88793c549b5281ad0bd86bdcf0fd2b8fc6d3d.tar.gz
xen-f8b88793c549b5281ad0bd86bdcf0fd2b8fc6d3d.tar.bz2
xen-f8b88793c549b5281ad0bd86bdcf0fd2b8fc6d3d.zip
[VTPM_TOOLS] Moved the developement tpm_emulator down to ring 3, which
should make debugging easier as well as fix the emulator for x86_64 Signed-off-by: Vincent Scarlata <vincent.r.scarlata@intel.com>
Diffstat (limited to 'tools/vtpm_manager')
-rw-r--r--tools/vtpm_manager/Rules.mk3
-rw-r--r--tools/vtpm_manager/manager/vtpm_manager.c8
-rw-r--r--tools/vtpm_manager/tcs/transmit.c42
3 files changed, 37 insertions, 16 deletions
diff --git a/tools/vtpm_manager/Rules.mk b/tools/vtpm_manager/Rules.mk
index 0a56da49f8..6f553b56fc 100644
--- a/tools/vtpm_manager/Rules.mk
+++ b/tools/vtpm_manager/Rules.mk
@@ -56,6 +56,9 @@ CFLAGS += -DLOGGING_MODULES="(BITMASK(VTPM_LOG_TCS)|BITMASK(VTPM_LOG_VTSP)|BITMA
# vtpm_manager listens on fifo's rather than backend
#CFLAGS += -DDUMMY_BACKEND
+# TCS talks to fifo's rather than /dev/tpm. TPM Emulator assumed on fifos
+#CFLAGS += -DDUMMY_TPM
+
# Do not have manager launch DMs.
#CFLAGS += -DMANUAL_DM_LAUNCH
diff --git a/tools/vtpm_manager/manager/vtpm_manager.c b/tools/vtpm_manager/manager/vtpm_manager.c
index b3c98115db..6d02952e3b 100644
--- a/tools/vtpm_manager/manager/vtpm_manager.c
+++ b/tools/vtpm_manager/manager/vtpm_manager.c
@@ -92,8 +92,9 @@ TPM_RESULT VTPM_Create_Manager(){
status = VTSP_ReadPubek(vtpm_globals->manager_tcs_handle, &ek_cryptoInfo);
// If we can read PubEK then there is no owner and we should take it.
+ // We use the abilty to read the pubEK to flag that the TPM is owned.
+ // FIXME: Change to just trying to take ownership and react to the status
if (status == TPM_SUCCESS) {
- vtpmloginfo(VTPM_LOG_VTPM, "Failed to readEK meaning TPM has an owner. Creating Keys off existing SRK.\n");
TPMTRYRETURN(VTSP_TakeOwnership(vtpm_globals->manager_tcs_handle,
(const TPM_AUTHDATA*)&vtpm_globals->owner_usage_auth,
&SRK_AUTH,
@@ -103,6 +104,8 @@ TPM_RESULT VTPM_Create_Manager(){
TPMTRYRETURN(VTSP_DisablePubekRead(vtpm_globals->manager_tcs_handle,
(const TPM_AUTHDATA*)&vtpm_globals->owner_usage_auth,
&vtpm_globals->keyAuth));
+ } else {
+ vtpmloginfo(VTPM_LOG_VTPM, "Failed to readEK meaning TPM has an owner. Creating Keys off existing SRK.\n");
}
// Generate storage key's auth
@@ -165,7 +168,6 @@ TPM_RESULT VTPM_Create_Manager(){
&vtpm_globals->bootKey,
TRUE ) );
- printf("***************************** FIXME: SAVE NEW STATE *******\n");
goto egress;
abort_egress:
@@ -181,7 +183,7 @@ TPM_RESULT VTPM_Create_Manager(){
TPM_RESULT VTPM_Init_Manager() {
TPM_RESULT status = TPM_FAIL, serviceStatus;
BYTE *randomsead;
- UINT32 randomsize;
+ UINT32 randomsize=256;
if ((vtpm_globals = (VTPM_GLOBALS *) malloc(sizeof(VTPM_GLOBALS))) == NULL){
status = TPM_FAIL;
diff --git a/tools/vtpm_manager/tcs/transmit.c b/tools/vtpm_manager/tcs/transmit.c
index 9501f4cbe0..e994d91482 100644
--- a/tools/vtpm_manager/tcs/transmit.c
+++ b/tools/vtpm_manager/tcs/transmit.c
@@ -43,7 +43,17 @@
// flag to track whether TDDL has been opened
static int g_TDDL_open = 0;
-static int g_fd = -1; // the fd to the TPM
+static int g_tx_fd = -1; // the fd to the TPM
+
+#ifndef DUMMY_TPM
+ #define TPM_TX_FNAME "/dev/tpm0"
+ static int *g_rx_fdp = &g_tx_fd;
+#else
+ #define TPM_TX_FNAME "/tmp/tpm_in.fifo"
+ #define TPM_RX_FNAME "/tmp/tpm_out.fifo"
+ static int g_rx_fd = -1;
+ static int *g_rx_fdp = &g_rx_fd; // the fd to the TPM
+#endif
TPM_RESULT
TDDL_TransmitData( TDDL_BYTE* in,
@@ -60,10 +70,9 @@ TDDL_TransmitData( TDDL_BYTE* in,
vtpmloginfomore(VTPM_LOG_TXDATA, "\n");
ssize_t size = 0;
- int fd = g_fd;
// send the request
- size = write (fd, in, insize);
+ size = write (g_tx_fd, in, insize);
if (size < 0) {
vtpmlogerror(VTPM_LOG_TXDATA, "write() failed");
ERRORDIE (TPM_IOERROR);
@@ -74,7 +83,7 @@ TDDL_TransmitData( TDDL_BYTE* in,
}
// read the response
- size = read (fd, out, TCPA_MAX_BUFFER_LENGTH);
+ size = read (*g_rx_fdp, out, TCPA_MAX_BUFFER_LENGTH);
if (size < 0) {
vtpmlogerror(VTPM_LOG_TXDATA, "read() failed");
ERRORDIE (TPM_IOERROR);
@@ -98,18 +107,20 @@ TDDL_TransmitData( TDDL_BYTE* in,
TPM_RESULT TDDL_Open() {
TDDL_RESULT status = TDDL_SUCCESS;
- int fd = -1;
if (g_TDDL_open)
return TPM_FAIL;
-
- fd = open ("/dev/tpm0", O_RDWR);
- if (fd < 0) {
+
+#ifdef DUMMY_TPM
+ *g_rx_fdp = open (TPM_RX_FNAME, O_RDWR);
+#endif
+
+ g_tx_fd = open (TPM_TX_FNAME, O_RDWR);
+ if (g_tx_fd < 0) {
vtpmlogerror(VTPM_LOG_TXDATA, "TPM open failed");
return TPM_IOERROR;
}
- g_fd = fd;
g_TDDL_open = 1;
return status;
@@ -119,13 +130,18 @@ void TDDL_Close() {
if (! g_TDDL_open)
return;
- if (g_fd>= 0) {
- if (close(g_fd) < 0)
+ if (g_tx_fd>= 0) {
+ if (close(g_tx_fd) < 0)
vtpmlogerror(VTPM_LOG_TXDATA, "closeing tpm failed");
-
- g_fd = -1;
+ g_tx_fd = -1;
}
+ if (*g_rx_fdp>= 0) {
+ if (close(*g_rx_fdp) < 0)
+ vtpmlogerror(VTPM_LOG_TXDATA, "closeing tpm failed");
+ *g_rx_fdp = -1;
+ }
+
g_TDDL_open = 0;
}