[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [VTPM_TOOLS] Updated vtpm for new release of the tpm_emulator.



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID fbcb603288bb1447085df3932b37d98cd0cec423
# Parent  b3b5f3ff2100d5a497583f2b2dbdce1399623dcf
[VTPM_TOOLS] Updated vtpm for new release of the tpm_emulator.
New emulator includes AIK, DAA, and Transport Sessions
Signed-off-by: Vinnie Scarlata <Vincent.r.scarlata@xxxxxxxxx>
---
 tools/vtpm/tpm_emulator-0.2b-x86_64.patch |  431 ------------------------------
 tools/vtpm/Makefile                       |   14 
 tools/vtpm/Rules.mk                       |    1 
 tools/vtpm/tpm_emulator-0.3-x86_64.patch  |  381 ++++++++++++++++++++++++++
 tools/vtpm/vtpm.patch                     |  407 +++++++++++++++++++++-------
 5 files changed, 696 insertions(+), 538 deletions(-)

diff -r b3b5f3ff2100 -r fbcb603288bb tools/vtpm/Makefile
--- a/tools/vtpm/Makefile       Wed May 31 07:43:06 2006 +0100
+++ b/tools/vtpm/Makefile       Wed May 31 07:45:20 2006 +0100
@@ -9,7 +9,7 @@ VTPM_DIR = vtpm
 VTPM_DIR = vtpm
 
 # Emulator tarball name
-TPM_EMULATOR_TARFILE = tpm_emulator-0.2b.tar.gz
+TPM_EMULATOR_TARFILE = tpm_emulator-0.3.tar.gz
 
 GMP_HEADER = /usr/include/gmp.h
 
@@ -47,23 +47,23 @@ mrproper:
 
 # Create vtpm and TPM emulator dirs
 # apply patches for 1) used as dom0 tpm driver 2) used as vtpm device instance
-$(TPM_EMULATOR_DIR): $(TPM_EMULATOR_TARFILE) tpm_emulator.patch 
tpm_emulator-0.2b-x86_64.patch
+$(TPM_EMULATOR_DIR): $(TPM_EMULATOR_TARFILE) tpm_emulator.patch 
tpm_emulator-0.3-x86_64.patch
        if [ "$(BUILD_EMULATOR)" = "y" ]; then \
                tar -xzf $(TPM_EMULATOR_TARFILE); \
                rm -rf $(TPM_EMULATOR_DIR); \
-               mv tpm_emulator-0.2 $(TPM_EMULATOR_DIR); \
+               mv tpm_emulator-0.3 $(TPM_EMULATOR_DIR); \
                cd $(TPM_EMULATOR_DIR); \
-               patch -p1 < ../tpm_emulator-0.2b-x86_64.patch; \
+               patch -p1 < ../tpm_emulator-0.3-x86_64.patch; \
                patch -p1 <../tpm_emulator.patch; \
        fi
 
-$(VTPM_DIR): $(TPM_EMULATOR_TARFILE) tpm_emulator-0.2b-x86_64.patch vtpm.patch
+$(VTPM_DIR): $(TPM_EMULATOR_TARFILE) tpm_emulator-0.3-x86_64.patch vtpm.patch
        tar -xzf $(TPM_EMULATOR_TARFILE);  
        rm -rf $(VTPM_DIR)
-       mv tpm_emulator-0.2 $(VTPM_DIR); 
+       mv tpm_emulator-0.3 $(VTPM_DIR); 
 
        cd $(VTPM_DIR); \
-       patch -p1 < ../tpm_emulator-0.2b-x86_64.patch; \
+       patch -p1 < ../tpm_emulator-0.3-x86_64.patch; \
        patch -p1 <../vtpm.patch
 
 .PHONY: build_sub
diff -r b3b5f3ff2100 -r fbcb603288bb tools/vtpm/Rules.mk
--- a/tools/vtpm/Rules.mk       Wed May 31 07:43:06 2006 +0100
+++ b/tools/vtpm/Rules.mk       Wed May 31 07:45:20 2006 +0100
@@ -33,6 +33,7 @@ OBJS  = $(patsubst %.c,%.o,$(SRCS))
 
 -include $(DEP_FILES)
 
+# Emulator does not work on 64-bit systems, and may be broken on 32 right now
 BUILD_EMULATOR = n
 
 # Make sure these are just rules
diff -r b3b5f3ff2100 -r fbcb603288bb tools/vtpm/vtpm.patch
--- a/tools/vtpm/vtpm.patch     Wed May 31 07:43:06 2006 +0100
+++ b/tools/vtpm/vtpm.patch     Wed May 31 07:45:20 2006 +0100
@@ -1,23 +1,24 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
-diff -uprN orig/tpm_emulator-0.2-x86_64/AUTHORS vtpm/AUTHORS
---- orig/tpm_emulator-0.2-x86_64/AUTHORS       2005-08-15 00:58:57.000000000 
-0700
-+++ vtpm/AUTHORS       2006-05-17 09:31:11.000000000 -0700
-@@ -1 +1,2 @@
+diff -uprN orig/tpm_emulator-0.3-x86_64/AUTHORS vtpm/AUTHORS
+--- orig/tpm_emulator-0.3-x86_64/AUTHORS       2006-01-10 04:21:45.000000000 
-0800
++++ vtpm/AUTHORS       2006-05-30 12:23:26.000000000 -0700
+@@ -1,2 +1,3 @@
  Mario Strasser <mast@xxxxxxx>
-+INTEL Corp <>
-diff -uprN orig/tpm_emulator-0.2-x86_64/ChangeLog vtpm/ChangeLog
---- orig/tpm_emulator-0.2-x86_64/ChangeLog     2005-08-15 00:58:57.000000000 
-0700
-+++ vtpm/ChangeLog     2006-05-17 09:31:11.000000000 -0700
+ Heiko Stamer <stamer@xxxxxxxx> [DAA]
++INTEL Corp <> [VTPM Extensions]
+diff -uprN orig/tpm_emulator-0.3-x86_64/ChangeLog vtpm/ChangeLog
+--- orig/tpm_emulator-0.3-x86_64/ChangeLog     2006-01-10 04:21:45.000000000 
-0800
++++ vtpm/ChangeLog     2006-05-30 12:23:26.000000000 -0700
 @@ -1,3 +1,7 @@
 +2005-08-16 Intel Corp
-+      Moved module out of kernel to run as a ring 3 app
-+      Modified save_to_file and load_from_file to call a xen backend driver 
to call a VTPM manager
-+
- 2005-08-15  Mario Strasser <mast@xxxxxxx>
-       * all: some typos corrected
-       * tpm_integrity.c: bug in TPM_Extend fixed
-diff -uprN orig/tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c 
vtpm/crypto/gmp_kernel_wrapper.c
---- orig/tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c   2006-05-17 
09:34:13.000000000 -0700
-+++ vtpm/crypto/gmp_kernel_wrapper.c   2006-05-17 09:31:11.000000000 -0700
++      * Moved module out of kernel to run as a ring 3 app
++      * Modified save_to_file and load_from_file to call a xen backend driver 
to call a VTPM manager
++
+ 2005-12-24  Mario Strasser <mast@xxxxxxx>
+       * tpm_transport.c, tpm_marshalling.c, tpm_structures.h:
+               Transport session functionality added
+diff -uprN orig/tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c 
vtpm/crypto/gmp_kernel_wrapper.c
+--- orig/tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c   2006-05-30 
12:28:02.000000000 -0700
++++ vtpm/crypto/gmp_kernel_wrapper.c   2006-05-30 12:23:26.000000000 -0700
 @@ -1,5 +1,6 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -77,9 +78,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
    }
  }
  
-diff -uprN orig/tpm_emulator-0.2-x86_64/crypto/rsa.c vtpm/crypto/rsa.c
---- orig/tpm_emulator-0.2-x86_64/crypto/rsa.c  2005-08-15 00:58:57.000000000 
-0700
-+++ vtpm/crypto/rsa.c  2006-05-17 09:31:11.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/crypto/rsa.c vtpm/crypto/rsa.c
+--- orig/tpm_emulator-0.3-x86_64/crypto/rsa.c  2006-01-10 04:21:45.000000000 
-0800
++++ vtpm/crypto/rsa.c  2006-05-30 12:23:26.000000000 -0700
 @@ -1,5 +1,6 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -87,7 +88,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   *
   * This module is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published
-@@ -363,7 +364,7 @@ static int encode_message(int type, uint
+@@ -381,7 +382,7 @@ static int encode_message(int type, uint
        msg[0] = 0x00;
        get_random_bytes(&msg[1], SHA1_DIGEST_LENGTH);
        sha1_init(&ctx);
@@ -96,7 +97,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
        sha1_final(&ctx, &msg[1 + SHA1_DIGEST_LENGTH]);
        memset(&msg[1 + 2 * SHA1_DIGEST_LENGTH], 0x00, 
          msg_len - data_len - 2 * SHA1_DIGEST_LENGTH - 2);
-@@ -411,7 +412,7 @@ static int decode_message(int type, uint
+@@ -429,7 +430,7 @@ static int decode_message(int type, uint
        mask_generation(&msg[1], SHA1_DIGEST_LENGTH,
          &msg[1 + SHA1_DIGEST_LENGTH], msg_len - SHA1_DIGEST_LENGTH - 1);
        sha1_init(&ctx);
@@ -105,10 +106,10 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
        sha1_final(&ctx, &msg[1]);
        if (memcmp(&msg[1], &msg[1 + SHA1_DIGEST_LENGTH], 
            SHA1_DIGEST_LENGTH) != 0) return -1;
-diff -uprN orig/tpm_emulator-0.2-x86_64/linux_module.c vtpm/linux_module.c
---- orig/tpm_emulator-0.2-x86_64/linux_module.c        2006-05-17 
09:34:13.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/linux_module.c vtpm/linux_module.c
+--- orig/tpm_emulator-0.3-x86_64/linux_module.c        2006-05-30 
12:28:02.000000000 -0700
 +++ vtpm/linux_module.c        1969-12-31 16:00:00.000000000 -0800
-@@ -1,163 +0,0 @@
+@@ -1,194 +0,0 @@
 -/* Software-Based Trusted Platform Module (TPM) Emulator for Linux 
 - * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
 - *
@@ -122,7 +123,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 - * GNU General Public License for more details.
 - *
-- * $Id: linux_module.c 19 2005-05-18 08:29:37Z mast $
+- * $Id: linux_module.c 76 2006-01-02 22:17:58Z hstamer $
 - */
 -
 -#include <linux/module.h>
@@ -140,11 +141,11 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
 -
 -/* module startup parameters */
 -char *startup = "save";
--MODULE_PARM(startup, "s");
+-module_param(startup, charp, 0444);
 -MODULE_PARM_DESC(startup, " Sets the startup mode of the TPM. "
 -  "Possible values are 'clear', 'save' (default) and 'deactivated.");
--char *storage_file = "/var/tpm/tpm_emulator-1.2.0.1";
--MODULE_PARM(storage_file, "s");
+-char *storage_file = "/var/tpm/tpm_emulator-1.2.0.2";
+-module_param(storage_file, charp, 0644);
 -MODULE_PARM_DESC(storage_file, " Sets the persistent-data storage " 
 -  "file of the TPM.");
 -
@@ -172,6 +173,12 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
 -{
 -  debug("%s()", __FUNCTION__);
 -  clear_bit(STATE_IS_OPEN, (void*)&module_state);
+-  down(&tpm_mutex);
+-  if (tpm_response.data != NULL) {
+-    kfree(tpm_response.data);
+-    tpm_response.data = NULL;
+-  }
+-  up(&tpm_mutex);
 -  return 0;
 -}
 -
@@ -183,6 +190,10 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
 -    count = min(count, (size_t)tpm_response.size - (size_t)*ppos);
 -    count -= copy_to_user(buf, &tpm_response.data[*ppos], count);
 -    *ppos += count;
+-    if ((size_t)tpm_response.size == (size_t)*ppos) {
+-      kfree(tpm_response.data);
+-      tpm_response.data = NULL;
+-    }
 -  } else {
 -    count = 0;
 -  }
@@ -205,9 +216,29 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
 -  return count;
 -}
 -
+-#define TPMIOC_CANCEL   _IO('T', 0x00)
+-#define TPMIOC_TRANSMIT _IO('T', 0x01)
+-
 -static int tpm_ioctl(struct inode *inode, struct file *file, unsigned int 
cmd, unsigned long arg)
 -{
--  debug("%s(%d, %ld)", __FUNCTION__, cmd, arg);
+-  debug("%s(%d, %p)", __FUNCTION__, cmd, (char*)arg);
+-  if (cmd == TPMIOC_TRANSMIT) {
+-    uint32_t count = ntohl(*(uint32_t*)(arg + 2));
+-    down(&tpm_mutex);
+-    if (tpm_response.data != NULL) kfree(tpm_response.data);
+-    if (tpm_handle_command((char*)arg, count, &tpm_response.data,
+-                           &tpm_response.size) == 0) {
+-      tpm_response.size -= copy_to_user((char*)arg, tpm_response.data,
+-                            tpm_response.size);
+-      kfree(tpm_response.data);
+-      tpm_response.data = NULL;
+-    } else {
+-      tpm_response.size = 0;
+-      tpm_response.data = NULL;
+-    }
+-    up(&tpm_mutex);
+-    return tpm_response.size;
+-  }
 -  return -1;
 -}
 -
@@ -240,7 +271,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
 -  /* initialize TPM emulator */
 -  if (!strcmp(startup, "clear")) {
 -    tpm_emulator_init(1);
--  } else if (!strcmp(startup, "save")) { 
+-  } else if (!strcmp(startup, "save")) {
 -    tpm_emulator_init(2);
 -  } else if (!strcmp(startup, "deactivated")) {
 -    tpm_emulator_init(3);
@@ -257,6 +288,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
 -{
 -  tpm_emulator_shutdown();
 -  misc_deregister(&tpm_dev);
+-  if (tpm_response.data != NULL) kfree(tpm_response.data);
 -}
 -
 -module_init(init_tpm_module);
@@ -264,7 +296,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
 -
 -uint64_t tpm_get_ticks(void)
 -{
--  static struct timespec old_time = {0, 0}; 
+-  static struct timespec old_time = {0, 0};
 -  struct timespec new_time = current_kernel_time();
 -  uint64_t ticks = (uint64_t)(old_time.tv_sec - new_time.tv_sec) * 1000000
 -                   + (old_time.tv_nsec - new_time.tv_nsec) / 1000;
@@ -272,9 +304,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
 -  return (ticks > 0) ? ticks : 1;
 -}
 -
-diff -uprN orig/tpm_emulator-0.2-x86_64/linux_module.h vtpm/linux_module.h
---- orig/tpm_emulator-0.2-x86_64/linux_module.h        2006-05-17 
09:34:13.000000000 -0700
-+++ vtpm/linux_module.h        2006-05-17 09:31:11.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/linux_module.h vtpm/linux_module.h
+--- orig/tpm_emulator-0.3-x86_64/linux_module.h        2006-05-30 
12:28:02.000000000 -0700
++++ vtpm/linux_module.h        2006-05-30 12:23:26.000000000 -0700
 @@ -1,5 +1,6 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -374,15 +406,15 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
  #define BE16_TO_CPU(x) __be16_to_cpu(x)
  #define LE16_TO_CPU(x) __le16_to_cpu(x)
  
-diff -uprN orig/tpm_emulator-0.2-x86_64/Makefile vtpm/Makefile
---- orig/tpm_emulator-0.2-x86_64/Makefile      2006-05-17 09:34:13.000000000 
-0700
-+++ vtpm/Makefile      2006-05-17 09:31:11.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/Makefile vtpm/Makefile
+--- orig/tpm_emulator-0.3-x86_64/Makefile      2006-05-30 12:28:02.000000000 
-0700
++++ vtpm/Makefile      2006-05-30 12:23:26.000000000 -0700
 @@ -1,22 +1,31 @@
  # Software-Based Trusted Platform Module (TPM) Emulator for Linux
  # Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>
-+# Copyright (C) 2005 INTEL Corp.
++# Copyright (C) 2006 INTEL Corp.
  #
- # $Id: Makefile 10 2005-04-26 20:59:50Z mast $
+ # $Id: Makefile 69 2005-12-13 12:55:52Z mast $
  
 -# kernel settings
 -KERNEL_RELEASE := $(shell uname -r)
@@ -394,11 +426,11 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
 -MODULE_NAME    := tpm_emulator
 +BIN            := vtpmd
  VERSION_MAJOR  := 0
- VERSION_MINOR  := 2
+ VERSION_MINOR  := 3
  VERSION_BUILD  := $(shell date +"%s")
  
 -# enable/disable DEBUG messages
--EXTRA_CFLAGS   += -DDEBUG -g  
+-EXTRA_CFLAGS   += -Wall -DDEBUG -g  
 +# Installation program and options
 +INSTALL         = install
 +INSTALL_PROG    = $(INSTALL) -m0755
@@ -468,10 +500,10 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
  
  $(src)/crypto/libgmp.a:
        test -f $(src)/crypto/libgmp.a || ln -s $(GMP_LIB) 
$(src)/crypto/libgmp.a
-diff -uprN orig/tpm_emulator-0.2-x86_64/README vtpm/README
---- orig/tpm_emulator-0.2-x86_64/README        2006-05-17 09:34:13.000000000 
-0700
-+++ vtpm/README        2006-05-17 09:31:11.000000000 -0700
-@@ -13,7 +13,8 @@ $Id: README 8 2005-01-25 21:11:45Z jmoli
+diff -uprN orig/tpm_emulator-0.3-x86_64/README vtpm/README
+--- orig/tpm_emulator-0.3-x86_64/README        2006-05-30 12:28:02.000000000 
-0700
++++ vtpm/README        2006-05-30 12:23:26.000000000 -0700
+@@ -13,7 +13,8 @@ $Id: README 78 2006-01-07 10:45:39Z mast
  Copyright
  --------------------------------------------------------------------------
  Copyright (C) 2004 Mario Strasser <mast@xxxxxxx> and Swiss Federal 
@@ -481,9 +513,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
                
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
-diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_audit.c vtpm/tpm/tpm_audit.c
---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_audit.c       2005-08-15 
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_audit.c       2006-05-17 09:31:11.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_audit.c vtpm/tpm/tpm_audit.c
+--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_audit.c       2006-01-10 
04:21:45.000000000 -0800
++++ vtpm/tpm/tpm_audit.c       2006-05-30 12:23:26.000000000 -0700
 @@ -1,6 +1,7 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -546,9 +578,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
    return TPM_SUCCESS;
  }
 -
-diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_authorization.c 
vtpm/tpm/tpm_authorization.c
---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_authorization.c       2005-08-15 
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_authorization.c       2006-05-17 09:31:11.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_authorization.c 
vtpm/tpm/tpm_authorization.c
+--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_authorization.c       2006-01-10 
04:21:45.000000000 -0800
++++ vtpm/tpm/tpm_authorization.c       2006-05-30 12:23:26.000000000 -0700
 @@ -1,6 +1,7 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -557,7 +589,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   *
   * This module is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published
-@@ -268,7 +269,7 @@ TPM_RESULT tpm_verify_auth(TPM_AUTH *aut
+@@ -279,7 +280,7 @@ TPM_RESULT tpm_verify_auth(TPM_AUTH *aut
  {
    hmac_ctx_t ctx;
    TPM_SESSION_DATA *session;
@@ -565,16 +597,10 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
 +  UINT32 auth_handle = CPU_TO_BE32(auth->authHandle);
    
    info("tpm_verify_auth(%08x)", auth->authHandle);
-   /* get dedicated authorization session */
-@@ -316,5 +317,3 @@ void tpm_decrypt_auth_secret(TPM_ENCAUTH
-   for (i = 0; i < sizeof(TPM_SECRET); i++)
-     plainAuth[i] ^= encAuth[i];
- }
--
--
-diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_capability.c 
vtpm/tpm/tpm_capability.c
---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_capability.c  2005-08-15 
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_capability.c  2006-05-17 09:31:11.000000000 -0700
+   /* get dedicated authorization or transport session */
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_capability.c 
vtpm/tpm/tpm_capability.c
+--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_capability.c  2006-01-10 
04:21:45.000000000 -0800
++++ vtpm/tpm/tpm_capability.c  2006-05-30 12:23:26.000000000 -0700
 @@ -1,6 +1,7 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -583,7 +609,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   *
   * This module is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published
-@@ -398,7 +399,7 @@ TPM_RESULT TPM_GetCapability(TPM_CAPABIL
+@@ -406,7 +407,7 @@ TPM_RESULT TPM_GetCapability(TPM_CAPABIL
  
      case TPM_CAP_KEY_HANDLE:
        debug("[TPM_CAP_KEY_HANDLE]");
@@ -592,14 +618,14 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
        return cap_handle(4, (BYTE*)&subCapSize, respSize, resp);
  
      case TPM_CAP_CHECK_LOADED:
-@@ -472,4 +473,3 @@ TPM_RESULT TPM_GetCapability(TPM_CAPABIL
+@@ -480,4 +481,3 @@ TPM_RESULT TPM_GetCapability(TPM_CAPABIL
        return TPM_BAD_MODE;
    }
  }
 -
-diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_cmd_handler.c 
vtpm/tpm/tpm_cmd_handler.c
---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_cmd_handler.c 2005-08-15 
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_cmd_handler.c 2006-05-17 09:31:11.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_cmd_handler.c 
vtpm/tpm/tpm_cmd_handler.c
+--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_cmd_handler.c 2006-01-10 
04:21:45.000000000 -0800
++++ vtpm/tpm/tpm_cmd_handler.c 2006-05-30 12:23:26.000000000 -0700
 @@ -1,6 +1,7 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -608,17 +634,17 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   *
   * This module is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published
-@@ -26,7 +27,7 @@ static void tpm_compute_in_param_digest(
+@@ -73,7 +74,7 @@ void tpm_compute_in_param_digest(TPM_REQ
  {
    sha1_ctx_t sha1;
-   UINT32 offset;
+   UINT32 offset = tpm_get_param_offset(req->ordinal);
 -  UINT32 ord = cpu_to_be32(req->ordinal);
 +  UINT32 ord = CPU_TO_BE32(req->ordinal);
  
-   /* skip all key-handles at the beginning */
-   switch (req->ordinal) {
-@@ -82,8 +83,8 @@ static void tpm_compute_in_param_digest(
- static void tpm_compute_out_param_digest(TPM_COMMAND_CODE ordinal, 
TPM_RESPONSE *rsp)
+   /* compute SHA1 hash */
+   if (offset <= req->paramSize) {
+@@ -89,8 +90,8 @@ void tpm_compute_in_param_digest(TPM_REQ
+ void tpm_compute_out_param_digest(TPM_COMMAND_CODE ordinal, TPM_RESPONSE *rsp)
  {
    sha1_ctx_t sha1;
 -  UINT32 res = cpu_to_be32(rsp->result);
@@ -628,7 +654,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
  
    /* compute SHA1 hash */
    sha1_init(&sha1);
-@@ -3081,7 +3082,7 @@ static void tpm_setup_rsp_auth(TPM_COMMA
+@@ -3123,7 +3124,7 @@ static void tpm_setup_rsp_auth(TPM_COMMA
        hmac_update(&hmac, rsp->auth2->digest, sizeof(rsp->auth2->digest));
  #if 0
        if (tpm_get_auth(rsp->auth2->authHandle)->type == TPM_ST_OIAP) {
@@ -637,7 +663,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
          hmac_update(&hmac, (BYTE*)&handle, 4);
        }
  #endif
-@@ -3096,7 +3097,7 @@ static void tpm_setup_rsp_auth(TPM_COMMA
+@@ -3138,7 +3139,7 @@ static void tpm_setup_rsp_auth(TPM_COMMA
        hmac_update(&hmac, rsp->auth1->digest, sizeof(rsp->auth1->digest));
  #if 0
        if (tpm_get_auth(rsp->auth1->authHandle)->type == TPM_ST_OIAP) {
@@ -646,25 +672,20 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
          hmac_update(&hmac, (BYTE*)&handle, 4);
        }
  #endif
-@@ -3179,7 +3180,9 @@ extern const char *tpm_error_to_string(T
- static void tpm_execute_command(TPM_REQUEST *req, TPM_RESPONSE *rsp)
+@@ -3221,7 +3222,9 @@ extern const char *tpm_error_to_string(T
+ void tpm_execute_command(TPM_REQUEST *req, TPM_RESPONSE *rsp)
  {
    TPM_RESULT res;
 -  
 +
-+  req->tag = (BYTE) req->tag;  // VIN HACK!!! 
++  req->tag = (BYTE) req->tag;  // FIXME: Why is this here
 +
    /* setup authorisation as well as response tag and size */
    memset(rsp, 0, sizeof(*rsp));
    switch (req->tag) {
-@@ -3878,4 +3881,3 @@ int tpm_handle_command(const uint8_t *in
-   tpm_free(rsp.param);
-   return 0;
- }
--
-diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c vtpm/tpm/tpm_crypto.c
---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c      2006-05-17 
09:34:13.000000000 -0700
-+++ vtpm/tpm/tpm_crypto.c      2006-05-17 09:31:11.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c vtpm/tpm/tpm_crypto.c
+--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c      2006-05-30 
12:28:02.000000000 -0700
++++ vtpm/tpm/tpm_crypto.c      2006-05-30 12:23:26.000000000 -0700
 @@ -1,6 +1,7 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -683,13 +704,170 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
      if (rsa_sign(&key->key, RSA_SSA_PKCS1_SHA1, 
          buf, areaToSignSize + 30, *sig)) {
 @@ -383,4 +384,3 @@ TPM_RESULT TPM_CertifyKey2(TPM_KEY_HANDL
-   }  
+   }
    return TPM_SUCCESS;
  }
 -
-diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_data.c vtpm/tpm/tpm_data.c
---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_data.c        2006-05-17 
09:34:13.000000000 -0700
-+++ vtpm/tpm/tpm_data.c        2006-05-17 09:31:11.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_daa.c vtpm/tpm/tpm_daa.c
+--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_daa.c 2006-01-10 04:21:45.000000000 
-0800
++++ vtpm/tpm/tpm_daa.c 2006-05-30 12:23:26.000000000 -0700
+@@ -700,14 +700,14 @@ info("tested until here");
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x00", 1);
++      sha1_update(&sha1, (BYTE *) "\x00", 1);
+       sha1_final(&sha1, scratch);
+       sha1_init(&sha1);
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x01", 1);
++      sha1_update(&sha1, (BYTE *) "\x01", 1);
+       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
+       mpz_init(f), mpz_init(q);
+       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
+@@ -787,14 +787,14 @@ info("tested until here");
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x00", 1);
++      sha1_update(&sha1, (BYTE *) "\x00", 1);
+       sha1_final(&sha1, scratch);
+       sha1_init(&sha1);
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x01", 1);
++      sha1_update(&sha1, (BYTE *) "\x01", 1);
+       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
+       mpz_init(f), mpz_init(q);
+       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
+@@ -1440,14 +1440,14 @@ info("tested until here");
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x00", 1);
++      sha1_update(&sha1, (BYTE *) "\x00", 1);
+       sha1_final(&sha1, scratch);
+       sha1_init(&sha1);
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x01", 1);
++      sha1_update(&sha1, (BYTE *) "\x01", 1);
+       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
+       mpz_init(f), mpz_init(q);
+       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
+@@ -1660,14 +1660,14 @@ info("tested until here");
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x00", 1);
++      sha1_update(&sha1, (BYTE *) "\x00", 1);
+       sha1_final(&sha1, scratch);
+       sha1_init(&sha1);
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x01", 1);
++      sha1_update(&sha1, (BYTE *) "\x01", 1);
+       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
+       mpz_init(f), mpz_init(q);
+       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
+@@ -1740,14 +1740,14 @@ info("tested until here");
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x00", 1);
++      sha1_update(&sha1, (BYTE *) "\x00", 1);
+       sha1_final(&sha1, scratch);
+       sha1_init(&sha1);
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x01", 1);
++      sha1_update(&sha1, (BYTE *) "\x01", 1);
+       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
+       mpz_init(f), mpz_init(q);
+       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
+@@ -2828,14 +2828,14 @@ TPM_RESULT TPM_DAA_Sign(TPM_HANDLE handl
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x00", 1);
++      sha1_update(&sha1, (BYTE *) "\x00", 1);
+       sha1_final(&sha1, scratch);
+       sha1_init(&sha1);
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x01", 1);
++      sha1_update(&sha1, (BYTE *) "\x01", 1);
+       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
+       mpz_init(f), mpz_init(q);
+       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
+@@ -3050,7 +3050,7 @@ TPM_RESULT TPM_DAA_Sign(TPM_HANDLE handl
+         sha1_init(&sha1);
+         sha1_update(&sha1, (BYTE*) &session->DAA_session.DAA_digest, 
+           sizeof(session->DAA_session.DAA_digest));
+-        sha1_update(&sha1, "\x01", 1);
++        sha1_update(&sha1, (BYTE *) "\x01", 1);
+         sha1_update(&sha1, inputData1, inputSize1);
+         sha1_final(&sha1, (BYTE*) &session->DAA_session.DAA_digest);
+       }
+@@ -3078,7 +3078,7 @@ TPM_RESULT TPM_DAA_Sign(TPM_HANDLE handl
+         sha1_init(&sha1);
+         sha1_update(&sha1, (BYTE*) &session->DAA_session.DAA_digest, 
+           sizeof(session->DAA_session.DAA_digest));
+-        sha1_update(&sha1, "\x01", 1);
++        sha1_update(&sha1, (BYTE *) "\x01", 1);
+         rsa_export_modulus(&aikData->key, scratch, &size);
+         sha1_update(&sha1, scratch, size);
+         sha1_final(&sha1, (BYTE*) &session->DAA_session.DAA_digest);
+@@ -3134,14 +3134,14 @@ TPM_RESULT TPM_DAA_Sign(TPM_HANDLE handl
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x00", 1);
++      sha1_update(&sha1, (BYTE *) "\x00", 1);
+       sha1_final(&sha1, scratch);
+       sha1_init(&sha1);
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x01", 1);
++      sha1_update(&sha1, (BYTE *) "\x01", 1);
+       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
+       mpz_init(f), mpz_init(q);
+       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
+@@ -3213,14 +3213,14 @@ TPM_RESULT TPM_DAA_Sign(TPM_HANDLE handl
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x00", 1);
++      sha1_update(&sha1, (BYTE *) "\x00", 1);
+       sha1_final(&sha1, scratch);
+       sha1_init(&sha1);
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
+           sizeof(session->DAA_tpmSpecific.DAA_rekey));
+       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
+           sizeof(session->DAA_tpmSpecific.DAA_count));
+-      sha1_update(&sha1, "\x01", 1);
++      sha1_update(&sha1, (BYTE *) "\x01", 1);
+       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
+       mpz_init(f), mpz_init(q);
+       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_data.c vtpm/tpm/tpm_data.c
+--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_data.c        2006-05-30 
12:28:02.000000000 -0700
++++ vtpm/tpm/tpm_data.c        2006-05-30 12:23:26.000000000 -0700
 @@ -1,6 +1,7 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -698,8 +876,8 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   *
   * This module is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published
-@@ -15,9 +16,15 @@
-  * $Id: tpm_data.c 9 2005-04-26 18:15:31Z mast $
+@@ -15,10 +16,15 @@
+  * $Id: tpm_data.c 36 2005-10-26 20:31:19Z hstamer $
   */
  
 +#include <sys/types.h>
@@ -710,11 +888,12 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
  #include "tpm_emulator.h"
  #include "tpm_structures.h"
  #include "tpm_marshalling.h"
+-#include "linux_module.h"
 +#include "vtpm_manager.h"
  
  TPM_DATA tpmData;
  
-@@ -28,6 +35,7 @@ BOOL tpm_get_physical_presence(void)
+@@ -39,6 +45,7 @@ static inline void init_pcr_attr(int pcr
  
  void tpm_init_data(void)
  {
@@ -722,7 +901,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
    /* endorsement key */
    uint8_t ek_n[] =  "\xa8\xdb\xa9\x42\xa8\xf3\xb8\x06\x85\x90\x76\x93\xad\xf7"
      "\x74\xec\x3f\xd3\x3d\x9d\xe8\x2e\xff\x15\xed\x0e\xce\x5f\x93"
-@@ -66,6 +74,8 @@ void tpm_init_data(void)
+@@ -77,6 +84,8 @@ void tpm_init_data(void)
      "\xd1\xc0\x8b\x5b\xa2\x2e\xa7\x15\xca\x50\x75\x10\x48\x9c\x2b"
      "\x18\xb9\x67\x8f\x5d\x64\xc3\x28\x9f\x2f\x16\x2f\x08\xda\x47"
      "\xec\x86\x43\x0c\x80\x99\x07\x34\x0f";
@@ -731,18 +910,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
    int i;
    /* reset all data to NULL, FALSE or 0 */
    memset(&tpmData, 0, sizeof(tpmData));
-@@ -85,6 +95,10 @@ void tpm_init_data(void)
-   tpmData.permanent.data.version.revMinor = VERSION_MINOR;
-   /* setup PCR attributes */
-   for (i = 0; i < TPM_NUM_PCR; i++) {
-+    int j;
-+    for (j=0; j < TPM_NUM_LOCALITY; j++) {
-+      tpmData.permanent.data.pcrAttrib[i].pcrExtendLocal[j] = TRUE;
-+    }
-     tpmData.permanent.data.pcrAttrib[i].pcrReset = TRUE;
-   }
-   /* set tick type */
-@@ -115,49 +129,235 @@ void tpm_release_data(void)
+@@ -150,49 +159,235 @@ void tpm_release_data(void)
  
  #ifdef TPM_STORE_TO_FILE
  
@@ -1009,7 +1177,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
  }
  
  #else
-@@ -232,7 +432,6 @@ int tpm_restore_permanent_data(void)
+@@ -267,7 +462,6 @@ int tpm_restore_permanent_data(void)
  
  int tpm_erase_permanent_data(void)
  {
@@ -1018,9 +1186,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
    return res;
  }
 -
-diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_deprecated.c 
vtpm/tpm/tpm_deprecated.c
---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_deprecated.c  2005-08-15 
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_deprecated.c  2006-05-17 09:31:11.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_deprecated.c 
vtpm/tpm/tpm_deprecated.c
+--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_deprecated.c  2006-01-10 
04:21:45.000000000 -0800
++++ vtpm/tpm/tpm_deprecated.c  2006-05-30 12:23:26.000000000 -0700
 @@ -1,6 +1,7 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -1047,9 +1215,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
                          authContextSize, &contextBlob);
    if (res != TPM_SUCCESS) return res;
    len = *authContextSize;
-diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_emulator.h 
vtpm/tpm/tpm_emulator.h
---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_emulator.h    2005-08-15 
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_emulator.h    2006-05-17 09:31:11.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_emulator.h 
vtpm/tpm/tpm_emulator.h
+--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_emulator.h    2006-01-10 
04:21:45.000000000 -0800
++++ vtpm/tpm/tpm_emulator.h    2006-05-30 12:23:26.000000000 -0700
 @@ -1,5 +1,6 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -1064,12 +1232,12 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
 -#undef  TPM_GENERATE_EK
 +//#undef  TPM_GENERATE_EK
 +#define  TPM_GENERATE_EK
- 
- /**
-  * tpm_emulator_init - initialises and starts the TPM emulator
-diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_integrity.c 
vtpm/tpm/tpm_integrity.c
---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_integrity.c   2005-08-15 
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_integrity.c   2006-05-17 09:31:11.000000000 -0700
+ #undef  TPM_GENERATE_SEED_DAA
+ 
+ #define TPM_MANUFACTURER 0x4554485A /* 'ETHZ' */        
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_integrity.c 
vtpm/tpm/tpm_integrity.c
+--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_integrity.c   2006-01-10 
04:21:45.000000000 -0800
++++ vtpm/tpm/tpm_integrity.c   2006-05-30 12:23:26.000000000 -0700
 @@ -1,6 +1,7 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -1083,9 +1251,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
    return TPM_SUCCESS;
  }
 -
-diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_structures.h 
vtpm/tpm/tpm_structures.h
---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_structures.h  2005-08-15 
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_structures.h  2006-05-17 09:31:11.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_structures.h 
vtpm/tpm/tpm_structures.h
+--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_structures.h  2006-01-10 
04:21:45.000000000 -0800
++++ vtpm/tpm/tpm_structures.h  2006-05-30 12:23:26.000000000 -0700
 @@ -1,6 +1,7 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -1103,9 +1271,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
  #include "crypto/rsa.h"
  
  /*
-diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_testing.c 
vtpm/tpm/tpm_testing.c
---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_testing.c     2005-08-15 
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_testing.c     2006-05-17 09:31:11.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_testing.c 
vtpm/tpm/tpm_testing.c
+--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_testing.c     2006-01-10 
04:21:45.000000000 -0800
++++ vtpm/tpm/tpm_testing.c     2006-05-30 12:23:26.000000000 -0700
 @@ -1,6 +1,7 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -1221,9 +1389,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
    rsa_private_key_t priv_key;
    rsa_public_key_t pub_key;
  
-diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_ticks.c vtpm/tpm/tpm_ticks.c
---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_ticks.c       2005-08-15 
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_ticks.c       2006-05-17 09:31:11.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_ticks.c vtpm/tpm/tpm_ticks.c
+--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_ticks.c       2006-01-10 
04:21:45.000000000 -0800
++++ vtpm/tpm/tpm_ticks.c       2006-05-30 12:23:26.000000000 -0700
 @@ -1,6 +1,7 @@
  /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -1306,9 +1474,69 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
  }
    
  
-diff -uprN orig/tpm_emulator-0.2-x86_64/tpmd.c vtpm/tpmd.c
---- orig/tpm_emulator-0.2-x86_64/tpmd.c        1969-12-31 16:00:00.000000000 
-0800
-+++ vtpm/tpmd.c        2006-05-17 09:31:11.000000000 -0700
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_transport.c 
vtpm/tpm/tpm_transport.c
+--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_transport.c   2006-01-10 
04:21:45.000000000 -0800
++++ vtpm/tpm/tpm_transport.c   2006-05-30 12:23:26.000000000 -0700
+@@ -59,7 +59,7 @@ static int decrypt_transport_auth(TPM_KE
+ static void transport_log_in(TPM_COMMAND_CODE ordinal, BYTE parameters[20],
+                              BYTE pubKeyHash[20], TPM_DIGEST *transDigest)
+ {
+-  UINT32 tag = cpu_to_be32(TPM_TAG_TRANSPORT_LOG_IN);
++  UINT32 tag = CPU_TO_BE32(TPM_TAG_TRANSPORT_LOG_IN);
+   BYTE *ptr, buf[sizeof_TPM_TRANSPORT_LOG_IN(x)];
+   UINT32 len = sizeof(buf);
+   sha1_ctx_t sha1;
+@@ -76,7 +76,7 @@ static void transport_log_in(TPM_COMMAND
+ static void transport_log_out(TPM_CURRENT_TICKS *currentTicks, BYTE 
parameters[20],
+                               TPM_MODIFIER_INDICATOR locality, TPM_DIGEST 
*transDigest)
+ {
+-  UINT32 tag = cpu_to_be32(TPM_TAG_TRANSPORT_LOG_OUT);
++  UINT32 tag = CPU_TO_BE32(TPM_TAG_TRANSPORT_LOG_OUT);
+   BYTE *ptr, buf[sizeof_TPM_TRANSPORT_LOG_OUT(x)];
+   UINT32 len = sizeof(buf);
+   sha1_ctx_t sha1;
+@@ -191,7 +191,7 @@ static void decrypt_wrapped_command(BYTE
+     sha1_update(&sha1, auth->nonceOdd.nonce, sizeof(auth->nonceOdd.nonce));
+     sha1_update(&sha1, "in", 2);
+     sha1_update(&sha1, secret, sizeof(TPM_SECRET));
+-    j = cpu_to_be32(i);
++    j = CPU_TO_BE32(i);
+     sha1_update(&sha1, (BYTE*)&j, 4);
+     sha1_final(&sha1, mask);
+     for (j = 0; j < sizeof(mask) && buf_len > 0; j++) { 
+@@ -213,7 +213,7 @@ static void encrypt_wrapped_command(BYTE
+     sha1_update(&sha1, auth->nonceOdd.nonce, sizeof(auth->nonceOdd.nonce));
+     sha1_update(&sha1, "out", 3);
+     sha1_update(&sha1, secret, sizeof(TPM_SECRET));
+-    j = cpu_to_be32(i);
++    j = CPU_TO_BE32(i);
+     sha1_update(&sha1, (BYTE*)&j, 4);
+     sha1_final(&sha1, mask);
+     for (j = 0; j < sizeof(mask) && buf_len > 0; j++) { 
+@@ -253,9 +253,9 @@ TPM_RESULT TPM_ExecuteTransport(UINT32 i
+   /* verify authorization */
+   tpm_compute_in_param_digest(&req);
+   sha1_init(&sha1);
+-  res = cpu_to_be32(TPM_ORD_ExecuteTransport);
++  res = CPU_TO_BE32(TPM_ORD_ExecuteTransport);
+   sha1_update(&sha1, (BYTE*)&res, 4);
+-  res = cpu_to_be32(inWrappedCmdSize);
++  res = CPU_TO_BE32(inWrappedCmdSize);
+   sha1_update(&sha1, (BYTE*)&res, 4);
+   sha1_update(&sha1, req.auth1.digest, sizeof(req.auth1.digest));
+   sha1_final(&sha1, auth1->digest);
+@@ -357,7 +357,7 @@ TPM_RESULT TPM_ReleaseTransportSigned(TP
+   /* setup a TPM_SIGN_INFO structure */
+   memcpy(&buf[0], "\x05\x00TRAN", 6);
+   memcpy(&buf[6], antiReplay->nonce, 20);
+-  *(UINT32*)&buf[26] = cpu_to_be32(20);
++  *(UINT32*)&buf[26] = CPU_TO_BE32(20);
+   memcpy(&buf[30], session->transInternal.transDigest.digest, 20);
+   /* sign info structure */ 
+   res = tpm_sign(key, auth1, TRUE, buf, sizeof(buf), signature, signSize);
+diff -uprN orig/tpm_emulator-0.3-x86_64/tpmd.c vtpm/tpmd.c
+--- orig/tpm_emulator-0.3-x86_64/tpmd.c        1969-12-31 16:00:00.000000000 
-0800
++++ vtpm/tpmd.c        2006-05-30 12:23:26.000000000 -0700
 @@ -0,0 +1,207 @@
 +/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
 + * Copyright (C) 2005 INTEL Corp
diff -r b3b5f3ff2100 -r fbcb603288bb tools/vtpm/tpm_emulator-0.3-x86_64.patch
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/vtpm/tpm_emulator-0.3-x86_64.patch  Wed May 31 07:45:20 2006 +0100
@@ -0,0 +1,484 @@
+diff -uprN tpm_emulator-0.3/crypto/gmp_kernel_wrapper.c 
tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c
+--- tpm_emulator-0.3/crypto/gmp_kernel_wrapper.c       2006-01-10 
04:21:45.000000000 -0800
++++ tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c        2006-05-26 
11:26:02.000000000 -0700
+@@ -79,7 +79,7 @@ void __attribute__ ((regparm(0))) *kerne
+ {
+   void *ret  = (void*)kmalloc(size, GFP_KERNEL);
+   if (!ret) panic(KERN_CRIT TPM_MODULE_NAME 
+-    "GMP: cannot allocate memory (size=%u)\n", size);
++    "GMP: cannot allocate memory (size=%Zu)\n", size);
+   return ret;
+ }
+ 
+@@ -88,7 +88,7 @@ void __attribute__ ((regparm(0))) *kerne
+ {
+   void *ret = (void*)kmalloc(new_size, GFP_KERNEL);
+   if (!ret) panic(KERN_CRIT TPM_MODULE_NAME "GMP: Cannot reallocate memory "
+-    "(old_size=%u new_size=%u)\n", old_size, new_size);
++    "(old_size=%Zu new_size=%Zu)\n", old_size, new_size);
+   memcpy(ret, oldptr, old_size);
+   kfree(oldptr);
+   return ret;
+diff -uprN tpm_emulator-0.3/linux_module.c 
tpm_emulator-0.3-x86_64/linux_module.c
+--- tpm_emulator-0.3/linux_module.c    2006-01-10 04:21:45.000000000 -0800
++++ tpm_emulator-0.3-x86_64/linux_module.c     2006-05-26 11:26:02.000000000 
-0700
+@@ -72,7 +72,7 @@ static int tpm_release(struct inode *ino
+ 
+ static ssize_t tpm_read(struct file *file, char *buf, size_t count, loff_t 
*ppos)
+ {
+-  debug("%s(%d)", __FUNCTION__, count);
++  debug("%s(%Zu)", __FUNCTION__, count);
+   down(&tpm_mutex);
+   if (tpm_response.data != NULL) {
+     count = min(count, (size_t)tpm_response.size - (size_t)*ppos);
+@@ -91,7 +91,7 @@ static ssize_t tpm_read(struct file *fil
+ 
+ static ssize_t tpm_write(struct file *file, const char *buf, size_t count, 
loff_t *ppos)
+ {
+-  debug("%s(%d)", __FUNCTION__, count);
++  debug("%s(%Zu)", __FUNCTION__, count);
+   down(&tpm_mutex);
+   *ppos = 0;
+   if (tpm_response.data != NULL) kfree(tpm_response.data);
+diff -uprN tpm_emulator-0.3/linux_module.h 
tpm_emulator-0.3-x86_64/linux_module.h
+--- tpm_emulator-0.3/linux_module.h    2006-01-10 04:21:45.000000000 -0800
++++ tpm_emulator-0.3-x86_64/linux_module.h     2006-05-26 11:26:02.000000000 
-0700
+@@ -28,8 +28,10 @@
+ 
+ /* module settings */
+ 
++#ifndef STR
+ #define STR(s) __STR__(s)
+ #define __STR__(s) #s
++#endif
+ #include "tpm_version.h"
+ 
+ #define TPM_DEVICE_MINOR      224
+diff -uprN tpm_emulator-0.3/Makefile tpm_emulator-0.3-x86_64/Makefile
+--- tpm_emulator-0.3/Makefile  2006-01-10 04:21:45.000000000 -0800
++++ tpm_emulator-0.3-x86_64/Makefile   2006-05-26 11:26:02.000000000 -0700
+@@ -7,6 +7,7 @@
+ KERNEL_RELEASE := $(shell uname -r)
+ KERNEL_BUILD   := /lib/modules/$(KERNEL_RELEASE)/build
+ MOD_SUBDIR     := misc
++COMPILE_ARCH    ?= $(shell uname -m | sed -e s/i.86/x86_32/)
+ 
+ # module settings
+ MODULE_NAME    := tpm_emulator
+@@ -17,8 +18,14 @@ VERSION_BUILD  := $(shell date +"%s")
+ # enable/disable DEBUG messages
+ EXTRA_CFLAGS   += -Wall -DDEBUG -g  
+ 
++ifeq ($(COMPILE_ARCH),x86_64)
++LIBDIR = lib64
++else
++LIBDIR = lib
++endif
++
+ # GNU MP configuration
+-GMP_LIB        := /usr/lib/libgmp.a
++GMP_LIB        := /usr/$(LIBDIR)/libgmp.a
+ GMP_HEADER     := /usr/include/gmp.h
+ 
+ # sources and objects
+diff -uprN tpm_emulator-0.3/README tpm_emulator-0.3-x86_64/README
+--- tpm_emulator-0.3/README    2006-01-10 04:21:45.000000000 -0800
++++ tpm_emulator-0.3-x86_64/README     2006-05-26 11:26:02.000000000 -0700
+@@ -43,6 +43,12 @@ Example:
+ GMP_LIB        := /usr/lib/libgmp.a
+ GMP_HEADER     := /usr/include/gmp.h
+ 
++GNU MP Library on 64 bit Systems
++--------------------------------------------------------------------------
++Some 64-bit kernels have problems with importing the user-space gmp 
++library (/usr/lib*/libgmp.a) into kernel space.  These kernels will require
++that the gmp library be recompiled for kernel space with -mcmodel=kernel.
++
+ Installation
+ --------------------------------------------------------------------------
+ The compilation and installation process uses the build environment for 
+diff -uprN tpm_emulator-0.3/tpm/tpm_credentials.c 
tpm_emulator-0.3-x86_64/tpm/tpm_credentials.c
+--- tpm_emulator-0.3/tpm/tpm_credentials.c     2006-01-10 04:21:45.000000000 
-0800
++++ tpm_emulator-0.3-x86_64/tpm/tpm_credentials.c      2006-05-26 
11:26:02.000000000 -0700
+@@ -47,16 +47,16 @@ int tpm_compute_pubkey_checksum(TPM_NONC
+ 
+ TPM_RESULT tpm_get_pubek(TPM_PUBKEY *pubEndorsementKey)
+ {
+-  UINT32 key_length;
++  size_t key_length;
+   if (!tpmData.permanent.data.endorsementKey.size) return TPM_NO_ENDORSEMENT;
+   /* setup TPM_PUBKEY structure */
+-  key_length = tpmData.permanent.data.endorsementKey.size;
+-  pubEndorsementKey->pubKey.keyLength = key_length >> 3;
++  pubEndorsementKey->pubKey.keyLength = 
tpmData.permanent.data.endorsementKey.size >> 3;
+   pubEndorsementKey->pubKey.key = 
tpm_malloc(pubEndorsementKey->pubKey.keyLength);
+   if (pubEndorsementKey->pubKey.key == NULL) return TPM_FAIL;
+   rsa_export_modulus(&tpmData.permanent.data.endorsementKey,
+-    pubEndorsementKey->pubKey.key,
+-    &pubEndorsementKey->pubKey.keyLength);
++                   pubEndorsementKey->pubKey.key,
++                   &key_length);
++  pubEndorsementKey->pubKey.keyLength = key_length;
+   pubEndorsementKey->algorithmParms.algorithmID = TPM_ALG_RSA;
+   pubEndorsementKey->algorithmParms.encScheme = TPM_ES_RSAESOAEP_SHA1_MGF1;
+   pubEndorsementKey->algorithmParms.sigScheme = TPM_SS_NONE;
+@@ -175,6 +175,7 @@ TPM_RESULT TPM_OwnerReadInternalPub(TPM_
+ {
+   TPM_RESULT res;
+   TPM_KEY_DATA *srk = &tpmData.permanent.data.srk;
++  size_t key_length;
+   info("TPM_OwnerReadInternalPub()");
+   /* verify authorization */
+   res = tpm_verify_auth(auth1, tpmData.permanent.data.ownerAuth, 
TPM_KH_OWNER);
+@@ -186,7 +187,8 @@ TPM_RESULT TPM_OwnerReadInternalPub(TPM_
+     publicPortion->pubKey.key = tpm_malloc(publicPortion->pubKey.keyLength);
+     if (publicPortion->pubKey.key == NULL) return TPM_FAIL;
+     rsa_export_modulus(&srk->key, publicPortion->pubKey.key, 
+-      &publicPortion->pubKey.keyLength);
++      &key_length);
++    publicPortion->pubKey.keyLength = key_length;
+     publicPortion->algorithmParms.algorithmID = TPM_ALG_RSA;
+     publicPortion->algorithmParms.encScheme = srk->encScheme;
+     publicPortion->algorithmParms.sigScheme = srk->sigScheme;
+diff -uprN tpm_emulator-0.3/tpm/tpm_crypto.c 
tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c
+--- tpm_emulator-0.3/tpm/tpm_crypto.c  2006-01-10 04:21:45.000000000 -0800
++++ tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c   2006-05-26 11:26:02.000000000 
-0700
+@@ -182,7 +182,8 @@ TPM_RESULT TPM_CertifyKey(TPM_KEY_HANDLE
+   TPM_KEY_DATA *cert, *key;
+   sha1_ctx_t sha1_ctx;
+   BYTE *buf, *p;
+-  UINT32 length;
++  UINT32 length32;
++  size_t length;
+   info("TPM_CertifyKey()");
+   /* get keys */
+   cert = tpm_get_key(certHandle);
+@@ -264,14 +265,15 @@ TPM_RESULT TPM_CertifyKey(TPM_KEY_HANDLE
+   /* compute the digest of the CERTIFY_INFO[2] structure and sign it */
+   length = sizeof_TPM_CERTIFY_INFO((*certifyInfo));
+   p = buf = tpm_malloc(length);
++  length32=(UINT32) length;
+   if (buf == NULL
+-      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length, certifyInfo)) {
++      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length32, certifyInfo)) {
+     free_TPM_KEY_PARMS(certifyInfo->algorithmParms);
+     return TPM_FAIL;
+   }
+   length = sizeof_TPM_CERTIFY_INFO((*certifyInfo));
+   sha1_init(&sha1_ctx);
+-  sha1_update(&sha1_ctx, buf, length);
++  sha1_update(&sha1_ctx, buf, (size_t) length);
+   sha1_final(&sha1_ctx, buf);
+   res = tpm_sign(cert, auth1, FALSE, buf, SHA1_DIGEST_LENGTH, outData, 
outDataSize);
+   tpm_free(buf);
+@@ -292,7 +294,8 @@ TPM_RESULT TPM_CertifyKey2(TPM_KEY_HANDL
+   TPM_KEY_DATA *cert, *key;
+   sha1_ctx_t sha1_ctx;
+   BYTE *buf, *p;
+-  UINT32 length;
++  size_t length;
++  UINT32 length32;
+   info("TPM_CertifyKey2()");
+   /* get keys */
+   cert = tpm_get_key(certHandle);
+@@ -362,8 +365,9 @@ TPM_RESULT TPM_CertifyKey2(TPM_KEY_HANDL
+   /* compute the digest of the CERTIFY_INFO[2] structure and sign it */
+   length = sizeof_TPM_CERTIFY_INFO((*certifyInfo));
+   p = buf = tpm_malloc(length);
++  length32 = (UINT32) length;
+   if (buf == NULL
+-      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length, certifyInfo)) {
++      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length32, certifyInfo)) {
+     free_TPM_KEY_PARMS(certifyInfo->algorithmParms);
+     return TPM_FAIL;
+   }
+diff -uprN tpm_emulator-0.3/tpm/tpm_data.c 
tpm_emulator-0.3-x86_64/tpm/tpm_data.c
+--- tpm_emulator-0.3/tpm/tpm_data.c    2006-01-10 04:21:45.000000000 -0800
++++ tpm_emulator-0.3-x86_64/tpm/tpm_data.c     2006-05-26 11:26:02.000000000 
-0700
+@@ -214,7 +214,7 @@ static int read_from_file(uint8_t **data
+ int tpm_store_permanent_data(void)
+ {
+   uint8_t *buf, *ptr;
+-  size_t buf_length, len;
++  UINT32 buf_length, len;
+ 
+   /* marshal data */
+   buf_length = len = sizeof_TPM_STCLEAR_FLAGS(tpmData.stclear.flags)
+@@ -242,13 +242,14 @@ int tpm_store_permanent_data(void)
+ int tpm_restore_permanent_data(void)
+ {
+   uint8_t *buf, *ptr;
+-  size_t buf_length, len;
++  size_t buf_length;
++  UINT32 len;
+   TPM_VERSION ver;
+ 
+   /* read data */
+   if (read_from_file(&buf, &buf_length)) return -1;
+   ptr = buf;
+-  len = buf_length;
++  len = (uint32_t) buf_length;
+   /* unmarshal data */
+   if (tpm_unmarshal_TPM_VERSION(&ptr, &len, &ver)
+       || memcmp(&ver, &tpmData.permanent.data.version, sizeof(TPM_VERSION))
+diff -uprN tpm_emulator-0.3/tpm/tpm_marshalling.c 
tpm_emulator-0.3-x86_64/tpm/tpm_marshalling.c
+--- tpm_emulator-0.3/tpm/tpm_marshalling.c     2006-01-10 04:21:45.000000000 
-0800
++++ tpm_emulator-0.3-x86_64/tpm/tpm_marshalling.c      2006-05-26 
11:26:02.000000000 -0700
+@@ -1212,7 +1212,7 @@ int tpm_unmarshal_TPM_STANY_FLAGS(BYTE *
+ 
+ int tpm_marshal_RSA(BYTE **ptr, UINT32 *length, rsa_private_key_t *v)
+ {
+-  UINT32 m_len, e_len, q_len;
++  size_t m_len, e_len, q_len;
+   if (*length < sizeof_RSA((*v))) return -1;
+   if (v->size > 0) {
+     rsa_export_modulus(v, &(*ptr)[6], &m_len);
+diff -uprN tpm_emulator-0.3/tpm/tpm_owner.c 
tpm_emulator-0.3-x86_64/tpm/tpm_owner.c
+--- tpm_emulator-0.3/tpm/tpm_owner.c   2006-01-10 04:21:45.000000000 -0800
++++ tpm_emulator-0.3-x86_64/tpm/tpm_owner.c    2006-05-26 11:26:02.000000000 
-0700
+@@ -108,7 +108,7 @@ TPM_RESULT TPM_TakeOwnership(TPM_PROTOCO
+   TPM_RESULT res;
+   rsa_private_key_t *ek = &tpmData.permanent.data.endorsementKey;
+   TPM_KEY_DATA *srk = &tpmData.permanent.data.srk;
+-  UINT32 buf_size = ek->size >> 3;
++  size_t buf_size = ek->size >> 3, key_length; 
+   BYTE buf[buf_size];
+ 
+   info("TPM_TakeOwnership()");
+@@ -172,7 +172,8 @@ TPM_RESULT TPM_TakeOwnership(TPM_PROTOCO
+     return TPM_FAIL;
+   }
+   rsa_export_modulus(&srk->key, srkPub->pubKey.key,
+-    &srkPub->pubKey.keyLength);
++                   &key_length);
++  srkPub->pubKey.keyLength = (UINT32) key_length;
+   /* setup tpmProof and set state to owned */
+   tpm_get_random_bytes(tpmData.permanent.data.tpmProof.nonce, 
+     sizeof(tpmData.permanent.data.tpmProof.nonce));
+diff -uprN tpm_emulator-0.3/tpm/tpm_storage.c 
tpm_emulator-0.3-x86_64/tpm/tpm_storage.c
+--- tpm_emulator-0.3/tpm/tpm_storage.c 2006-01-10 04:21:45.000000000 -0800
++++ tpm_emulator-0.3-x86_64/tpm/tpm_storage.c  2006-05-26 14:33:18.000000000 
-0700
+@@ -58,6 +58,7 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke
+                         BYTE *enc, UINT32 *enc_size)
+ {
+   UINT32 len;
++  size_t enc_size32 = *enc_size;
+   BYTE *buf, *ptr;
+   rsa_public_key_t pub_key;
+   int scheme;
+@@ -72,7 +73,7 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke
+   if (buf == NULL
+       || tpm_marshal_TPM_SEALED_DATA(&ptr, &len, seal)
+       || rsa_encrypt(&pub_key, scheme, buf, sizeof_TPM_SEALED_DATA((*seal)),
+-                     enc, enc_size)) {
++                     enc, &enc_size32)) {
+     tpm_free(buf);
+     rsa_release_public_key(&pub_key);
+     return -1;
+@@ -85,7 +86,8 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke
+ int decrypt_sealed_data(TPM_KEY_DATA *key, BYTE *enc, UINT32 enc_size,
+                         TPM_SEALED_DATA *seal, BYTE **buf) 
+ {
+-  UINT32 len;
++  size_t len;
++  UINT32 len32;
+   BYTE *ptr;
+   int scheme;
+   switch (key->encScheme) {
+@@ -96,8 +98,12 @@ int decrypt_sealed_data(TPM_KEY_DATA *ke
+   len = enc_size;
+   *buf = ptr = tpm_malloc(len);
+   if (*buf == NULL
+-      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len)
+-      || tpm_unmarshal_TPM_SEALED_DATA(&ptr, &len, seal)) {
++      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len) ){
++    tpm_free(*buf);
++    return -1;
++  }
++  len32 = len;
++  if (tpm_unmarshal_TPM_SEALED_DATA(&ptr, &len32, seal)) {
+     tpm_free(*buf);
+     return -1;
+   }
+@@ -237,11 +243,12 @@ TPM_RESULT TPM_Unseal(TPM_KEY_HANDLE par
+ 
+ TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE keyHandle, UINT32 inDataSize,
+                       BYTE *inData, TPM_AUTH *auth1, 
+-                      UINT32 *outDataSize, BYTE **outData)
++                      UINT32 *outDataSize32, BYTE **outData)
+ {
+   TPM_RESULT res;
+   TPM_KEY_DATA *key;
+   int scheme;
++  size_t outDataSize;
+   info("TPM_UnBind()");
+   /* get key */
+   key = tpm_get_key(keyHandle);
+@@ -258,8 +265,8 @@ TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE key
+   /* the size of the input data muss be greater than zero */
+   if (inDataSize == 0) return TPM_BAD_PARAMETER;
+   /* decrypt data */
+-  *outDataSize = inDataSize;
+-  *outData = tpm_malloc(*outDataSize);
++  outDataSize = inDataSize;
++  *outData = tpm_malloc(outDataSize);
+   if (*outData == NULL) return TPM_FAIL;
+   switch (key->encScheme) {
+     case TPM_ES_RSAESOAEP_SHA1_MGF1: scheme = RSA_ES_OAEP_SHA1; break;
+@@ -267,20 +274,21 @@ TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE key
+     default: tpm_free(*outData); return TPM_DECRYPT_ERROR;
+   }
+   if (rsa_decrypt(&key->key, scheme, inData, inDataSize, 
+-      *outData, outDataSize)) {
++      *outData, &outDataSize)) {
+     tpm_free(*outData);
+     return TPM_DECRYPT_ERROR;
+   }
+   /* verify data if it is of type TPM_BOUND_DATA */
+   if (key->encScheme == TPM_ES_RSAESOAEP_SHA1_MGF1 
+       || key->keyUsage != TPM_KEY_LEGACY) {
+-    if (*outDataSize < 5 || memcmp(*outData, "\x01\x01\00\x00\x02", 5) != 0) {
++    if (outDataSize < 5 || memcmp(*outData, "\x01\x01\00\x00\x02", 5) != 0) {
+       tpm_free(*outData);
+       return TPM_DECRYPT_ERROR;
+     }
+-    *outDataSize -= 5;
+-    memmove(*outData, &(*outData)[5], *outDataSize);
++    outDataSize -= 5;
++    memmove(*outData, &(*outData)[5], outDataSize);
+   }
++  *outDataSize32 = (UINT32) outDataSize;
+   return TPM_SUCCESS;
+ }
+ 
+@@ -311,12 +319,13 @@ static int verify_key_digest(TPM_KEY *ke
+ }
+ 
+ int encrypt_private_key(TPM_KEY_DATA *key, TPM_STORE_ASYMKEY *store,
+-                        BYTE *enc, UINT32 *enc_size)
++                        BYTE *enc, UINT32 *enc_size32)
+ {
+   UINT32 len;
+   BYTE *buf, *ptr;
+   rsa_public_key_t pub_key;
+   int scheme;
++  size_t enc_size;
+   switch (key->encScheme) {
+     case TPM_ES_RSAESOAEP_SHA1_MGF1: scheme = RSA_ES_OAEP_SHA1; break;
+     case TPM_ES_RSAESPKCSv15: scheme = RSA_ES_PKCSV15; break;
+@@ -328,11 +337,12 @@ int encrypt_private_key(TPM_KEY_DATA *ke
+   if (buf == NULL
+       || tpm_marshal_TPM_STORE_ASYMKEY(&ptr, &len, store)
+       || rsa_encrypt(&pub_key, scheme, buf, 
sizeof_TPM_STORE_ASYMKEY((*store)),
+-                     enc, enc_size)) {
++                     enc, &enc_size)) {
+     tpm_free(buf);
+     rsa_release_public_key(&pub_key);
+     return -1;
+   }
++  *enc_size32 = (UINT32) enc_size;
+   tpm_free(buf);
+   rsa_release_public_key(&pub_key);
+   return 0;
+@@ -341,7 +351,8 @@ int encrypt_private_key(TPM_KEY_DATA *ke
+ int decrypt_private_key(TPM_KEY_DATA *key, BYTE *enc, UINT32 enc_size, 
+                         TPM_STORE_ASYMKEY *store, BYTE **buf) 
+ {
+-  UINT32 len;
++  UINT32 len32;
++  size_t len;
+   BYTE *ptr;
+   int scheme;
+   switch (key->encScheme) {
+@@ -352,8 +363,12 @@ int decrypt_private_key(TPM_KEY_DATA *ke
+   len = enc_size;
+   *buf = ptr = tpm_malloc(len);
+   if (*buf == NULL
+-      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len)
+-      || tpm_unmarshal_TPM_STORE_ASYMKEY(&ptr, &len, store)) {
++      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len) ) {
++    tpm_free(*buf);
++    return -1;
++  }
++  len32 = (UINT32) len;
++  if (tpm_unmarshal_TPM_STORE_ASYMKEY(&ptr, &len32, store)) {  
+     tpm_free(*buf);
+     return -1;
+   }
+@@ -371,7 +386,7 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN
+   TPM_SESSION_DATA *session;
+   TPM_STORE_ASYMKEY store;
+   rsa_private_key_t rsa;
+-  UINT32 key_length;
++  size_t key_length;
+ 
+   info("TPM_CreateWrapKey()");
+   /* get parent key */
+@@ -428,11 +443,11 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN
+   }
+   if (compute_key_digest(wrappedKey, &store.pubDataDigest)) return TPM_FAIL;
+   /* generate key and store it */
+-  key_length = keyInfo->algorithmParms.parms.rsa.keyLength;
+-  if (rsa_generate_key(&rsa, key_length)) return TPM_FAIL;
+-  wrappedKey->pubKey.keyLength = key_length >> 3;
++  if (rsa_generate_key(&rsa, keyInfo->algorithmParms.parms.rsa.keyLength)) 
++    return TPM_FAIL;
++  wrappedKey->pubKey.keyLength = keyInfo->algorithmParms.parms.rsa.keyLength 
>> 3;
+   wrappedKey->pubKey.key = tpm_malloc(wrappedKey->pubKey.keyLength);
+-  store.privKey.keyLength = key_length >> 4;
++  store.privKey.keyLength = keyInfo->algorithmParms.parms.rsa.keyLength >> 4;
+   store.privKey.key = tpm_malloc(store.privKey.keyLength);
+   wrappedKey->encDataSize = parent->key.size >> 3;
+   wrappedKey->encData = tpm_malloc(wrappedKey->encDataSize);
+@@ -444,9 +459,11 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN
+     tpm_free(wrappedKey->encData);
+     return TPM_FAIL;
+   }
+-  rsa_export_modulus(&rsa, wrappedKey->pubKey.key, 
+-    &wrappedKey->pubKey.keyLength);
+-  rsa_export_prime1(&rsa, store.privKey.key, &store.privKey.keyLength);
++  rsa_export_modulus(&rsa, wrappedKey->pubKey.key,
++                   &key_length);
++  wrappedKey->pubKey.keyLength = (UINT32) key_length;
++  rsa_export_prime1(&rsa, store.privKey.key, &key_length);
++  store.privKey.keyLength = (UINT32) key_length;
+   rsa_release_private_key(&rsa);
+   /* encrypt private key data */
+   if (encrypt_private_key(parent, &store, wrappedKey->encData, 
+@@ -567,6 +584,7 @@ TPM_RESULT TPM_LoadKey2(TPM_KEY_HANDLE p
+ 
+ int tpm_setup_key_parms(TPM_KEY_DATA *key, TPM_KEY_PARMS *parms)
+ {
++  size_t key_length;
+   parms->algorithmID = TPM_ALG_RSA;
+   parms->encScheme = key->encScheme;
+   parms->sigScheme = key->sigScheme;
+@@ -576,7 +594,8 @@ int tpm_setup_key_parms(TPM_KEY_DATA *ke
+   parms->parms.rsa.exponent = tpm_malloc(parms->parms.rsa.exponentSize);
+   if (parms->parms.rsa.exponent == NULL) return -1;
+   rsa_export_exponent(&key->key, parms->parms.rsa.exponent,
+-    &parms->parms.rsa.exponentSize);
++    &key_length);
++  parms->parms.rsa.exponentSize = (UINT32) key_length;
+   parms->parmSize = 12 + parms->parms.rsa.exponentSize;
+   return 0;
+ }
+@@ -587,6 +606,7 @@ TPM_RESULT TPM_GetPubKey(TPM_KEY_HANDLE 
+   TPM_RESULT res;
+   TPM_KEY_DATA *key;
+   TPM_DIGEST digest;
++  size_t key_length;
+   info("TPM_GetPubKey()");
+   /* get key */
+   if (keyHandle == TPM_KH_SRK) return TPM_BAD_PARAMETER;
+@@ -614,8 +634,8 @@ TPM_RESULT TPM_GetPubKey(TPM_KEY_HANDLE 
+   pubKey->pubKey.keyLength = key->key.size >> 3;
+   pubKey->pubKey.key = tpm_malloc(pubKey->pubKey.keyLength);
+   if (pubKey->pubKey.key == NULL) return TPM_FAIL;
+-  rsa_export_modulus(&key->key, pubKey->pubKey.key, 
+-    &pubKey->pubKey.keyLength);
++  rsa_export_modulus(&key->key, pubKey->pubKey.key, &key_length); 
++  pubKey->pubKey.keyLength = (UINT32) key_length;
+   if (tpm_setup_key_parms(key, &pubKey->algorithmParms) != 0) {
+     tpm_free(pubKey->pubKey.key);
+     return TPM_FAIL;
diff -r b3b5f3ff2100 -r fbcb603288bb tools/vtpm/tpm_emulator-0.2b-x86_64.patch
--- a/tools/vtpm/tpm_emulator-0.2b-x86_64.patch Wed May 31 07:43:06 2006 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,499 +0,0 @@
-diff -uprN tpm_emulator-0.2/crypto/gmp_kernel_wrapper.c 
tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c
---- tpm_emulator-0.2/crypto/gmp_kernel_wrapper.c       2005-08-15 
00:58:57.000000000 -0700
-+++ tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c        2005-09-19 
14:10:29.000000000 -0700
-@@ -79,7 +79,7 @@ void __attribute__ ((regparm(0))) *kerne
- {
-   void *ret  = (void*)kmalloc(size, GFP_KERNEL);
-   if (!ret) panic(KERN_CRIT TPM_MODULE_NAME 
--    "GMP: cannot allocate memory (size=%u)\n", size);
-+    "GMP: cannot allocate memory (size=%Zu)\n", size);
-   return ret;
- }
- 
-@@ -88,7 +88,7 @@ void __attribute__ ((regparm(0))) *kerne
- {
-   void *ret = (void*)kmalloc(new_size, GFP_KERNEL);
-   if (!ret) panic(KERN_CRIT TPM_MODULE_NAME "GMP: Cannot reallocate memory "
--    "(old_size=%u new_size=%u)\n", old_size, new_size);
-+    "(old_size=%Zu new_size=%Zu)\n", old_size, new_size);
-   memcpy(ret, oldptr, old_size);
-   kfree(oldptr);
-   return ret;
-diff -uprN tpm_emulator-0.2/linux_module.c 
tpm_emulator-0.2-x86_64/linux_module.c
---- tpm_emulator-0.2/linux_module.c    2005-08-15 00:58:57.000000000 -0700
-+++ tpm_emulator-0.2-x86_64/linux_module.c     2005-09-19 14:10:29.000000000 
-0700
-@@ -66,7 +66,7 @@ static int tpm_release(struct inode *ino
- 
- static ssize_t tpm_read(struct file *file, char *buf, size_t count, loff_t 
*ppos)
- {
--  debug("%s(%d)", __FUNCTION__, count);
-+  debug("%s(%Zu)", __FUNCTION__, count);
-   down(&tpm_mutex);
-   if (tpm_response.data != NULL) {
-     count = min(count, (size_t)tpm_response.size - (size_t)*ppos);
-@@ -81,7 +81,7 @@ static ssize_t tpm_read(struct file *fil
- 
- static ssize_t tpm_write(struct file *file, const char *buf, size_t count, 
loff_t *ppos)
- {
--  debug("%s(%d)", __FUNCTION__, count);
-+  debug("%s(%Zu)", __FUNCTION__, count);
-   down(&tpm_mutex);
-   *ppos = 0;
-   if (tpm_response.data != NULL) kfree(tpm_response.data);
-diff -uprN tpm_emulator-0.2/linux_module.h 
tpm_emulator-0.2-x86_64/linux_module.h
---- tpm_emulator-0.2/linux_module.h    2005-08-15 00:58:57.000000000 -0700
-+++ tpm_emulator-0.2-x86_64/linux_module.h     2005-09-19 14:10:29.000000000 
-0700
-@@ -28,8 +28,10 @@
- 
- /* module settings */
- 
-+#ifndef STR
- #define STR(s) __STR__(s)
- #define __STR__(s) #s
-+#endif
- #include "tpm_version.h"
- 
- #define TPM_DEVICE_MINOR      224
-diff -uprN tpm_emulator-0.2/Makefile tpm_emulator-0.2-x86_64/Makefile
---- tpm_emulator-0.2/Makefile  2005-08-15 00:58:57.000000000 -0700
-+++ tpm_emulator-0.2-x86_64/Makefile   2005-09-19 14:10:29.000000000 -0700
-@@ -7,6 +7,7 @@
- KERNEL_RELEASE := $(shell uname -r)
- KERNEL_BUILD   := /lib/modules/$(KERNEL_RELEASE)/build
- MOD_SUBDIR     := misc
-+COMPILE_ARCH    ?= $(shell uname -m | sed -e s/i.86/x86_32/)
- 
- # module settings
- MODULE_NAME    := tpm_emulator
-@@ -17,8 +18,14 @@ VERSION_BUILD  := $(shell date +"%s")
- # enable/disable DEBUG messages
- EXTRA_CFLAGS   += -DDEBUG -g  
- 
-+ifeq ($(COMPILE_ARCH),x86_64)
-+LIBDIR = lib64
-+else
-+LIBDIR = lib
-+endif
-+
- # GNU MP configuration
--GMP_LIB        := /usr/lib/libgmp.a
-+GMP_LIB        := /usr/$(LIBDIR)/libgmp.a
- GMP_HEADER     := /usr/include/gmp.h
- 
- # sources and objects
-diff -uprN tpm_emulator-0.2/README tpm_emulator-0.2-x86_64/README
---- tpm_emulator-0.2/README    2005-08-15 00:58:57.000000000 -0700
-+++ tpm_emulator-0.2-x86_64/README     2005-09-19 14:21:43.000000000 -0700
-@@ -45,6 +45,12 @@ Example:
- GMP_LIB        := /usr/lib/libgmp.a
- GMP_HEADER     := /usr/include/gmp.h
- 
-+GNU MP Library on 64 bit Systems
-+--------------------------------------------------------------------------
-+Some 64-bit kernels have problems with importing the user-space gmp 
-+library (/usr/lib*/libgmp.a) into kernel space.  These kernels will require
-+that the gmp library be recompiled for kernel space with -mcmodel=kernel.
-+
- Installation
- --------------------------------------------------------------------------
- The compilation and installation process uses the build environment for 
-diff -uprN tpm_emulator-0.2/tpm/tpm_credentials.c 
tpm_emulator-0.2-x86_64/tpm/tpm_credentials.c
---- tpm_emulator-0.2/tpm/tpm_credentials.c     2005-08-15 00:58:57.000000000 
-0700
-+++ tpm_emulator-0.2-x86_64/tpm/tpm_credentials.c      2005-09-19 
14:10:29.000000000 -0700
-@@ -47,16 +47,16 @@ int tpm_compute_pubkey_checksum(TPM_NONC
- 
- TPM_RESULT tpm_get_pubek(TPM_PUBKEY *pubEndorsementKey)
- {
--  UINT32 key_length;
-+  size_t key_length;
-   if (!tpmData.permanent.data.endorsementKey.size) return TPM_NO_ENDORSEMENT;
-   /* setup TPM_PUBKEY structure */
--  key_length = tpmData.permanent.data.endorsementKey.size;
--  pubEndorsementKey->pubKey.keyLength = key_length >> 3;
-+  pubEndorsementKey->pubKey.keyLength = 
tpmData.permanent.data.endorsementKey.size >> 3;
-   pubEndorsementKey->pubKey.key = 
tpm_malloc(pubEndorsementKey->pubKey.keyLength);
-   if (pubEndorsementKey->pubKey.key == NULL) return TPM_FAIL;
-   rsa_export_modulus(&tpmData.permanent.data.endorsementKey,
--    pubEndorsementKey->pubKey.key,
--    &pubEndorsementKey->pubKey.keyLength);
-+                   pubEndorsementKey->pubKey.key,
-+                   &key_length);
-+  pubEndorsementKey->pubKey.keyLength = key_length;
-   pubEndorsementKey->algorithmParms.algorithmID = TPM_ALG_RSA;
-   pubEndorsementKey->algorithmParms.encScheme = TPM_ES_RSAESOAEP_SHA1_MGF1;
-   pubEndorsementKey->algorithmParms.sigScheme = TPM_SS_NONE;
-@@ -169,6 +169,7 @@ TPM_RESULT TPM_OwnerReadInternalPub(TPM_
- {
-   TPM_RESULT res;
-   TPM_KEY_DATA *srk = &tpmData.permanent.data.srk;
-+  size_t key_length;
-   info("TPM_OwnerReadInternalPub()");
-   /* verify authorization */
-   res = tpm_verify_auth(auth1, tpmData.permanent.data.ownerAuth, 
TPM_KH_OWNER);
-@@ -180,7 +181,8 @@ TPM_RESULT TPM_OwnerReadInternalPub(TPM_
-     publicPortion->pubKey.key = tpm_malloc(publicPortion->pubKey.keyLength);
-     if (publicPortion->pubKey.key == NULL) return TPM_FAIL;
-     rsa_export_modulus(&srk->key, publicPortion->pubKey.key, 
--      &publicPortion->pubKey.keyLength);
-+      &key_length);
-+    publicPortion->pubKey.keyLength = key_length;
-     publicPortion->algorithmParms.algorithmID = TPM_ALG_RSA;
-     publicPortion->algorithmParms.encScheme = srk->encScheme;
-     publicPortion->algorithmParms.sigScheme = srk->sigScheme;
-diff -uprN tpm_emulator-0.2/tpm/tpm_crypto.c 
tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c
---- tpm_emulator-0.2/tpm/tpm_crypto.c  2005-08-15 00:58:57.000000000 -0700
-+++ tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c   2005-09-19 14:10:29.000000000 
-0700
-@@ -182,7 +182,8 @@ TPM_RESULT TPM_CertifyKey(TPM_KEY_HANDLE
-   TPM_KEY_DATA *cert, *key;
-   sha1_ctx_t sha1_ctx;
-   BYTE *buf, *p;
--  UINT32 length;
-+  UINT32 length32;
-+  size_t length;
-   info("TPM_CertifyKey()");
-   /* get keys */
-   cert = tpm_get_key(certHandle);
-@@ -264,14 +265,15 @@ TPM_RESULT TPM_CertifyKey(TPM_KEY_HANDLE
-   /* compute the digest of the CERTIFY_INFO[2] structure and sign it */
-   length = sizeof_TPM_CERTIFY_INFO((*certifyInfo));
-   p = buf = tpm_malloc(length);
-+  length32=(UINT32) length;
-   if (buf == NULL
--      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length, certifyInfo)) {
-+      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length32, certifyInfo)) {
-     free_TPM_KEY_PARMS(certifyInfo->algorithmParms);
-     return TPM_FAIL;
-   }
-   length = sizeof_TPM_CERTIFY_INFO((*certifyInfo));
-   sha1_init(&sha1_ctx);
--  sha1_update(&sha1_ctx, buf, length);
-+  sha1_update(&sha1_ctx, buf, (size_t) length);
-   sha1_final(&sha1_ctx, buf);
-   res = tpm_sign(cert, auth1, FALSE, buf, SHA1_DIGEST_LENGTH, outData, 
outDataSize);
-   tpm_free(buf);
-@@ -292,7 +294,8 @@ TPM_RESULT TPM_CertifyKey2(TPM_KEY_HANDL
-   TPM_KEY_DATA *cert, *key;
-   sha1_ctx_t sha1_ctx;
-   BYTE *buf, *p;
--  UINT32 length;
-+  size_t length;
-+  UINT32 length32;
-   info("TPM_CertifyKey2()");
-   /* get keys */
-   cert = tpm_get_key(certHandle);
-@@ -362,8 +365,9 @@ TPM_RESULT TPM_CertifyKey2(TPM_KEY_HANDL
-   /* compute the digest of the CERTIFY_INFO[2] structure and sign it */
-   length = sizeof_TPM_CERTIFY_INFO((*certifyInfo));
-   p = buf = tpm_malloc(length);
-+  length32 = (UINT32) length;
-   if (buf == NULL
--      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length, certifyInfo)) {
-+      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length32, certifyInfo)) {
-     free_TPM_KEY_PARMS(certifyInfo->algorithmParms);
-     return TPM_FAIL;
-   }
-diff -uprN tpm_emulator-0.2/tpm/tpm_data.c 
tpm_emulator-0.2-x86_64/tpm/tpm_data.c
---- tpm_emulator-0.2/tpm/tpm_data.c    2005-08-15 00:58:57.000000000 -0700
-+++ tpm_emulator-0.2-x86_64/tpm/tpm_data.c     2005-09-19 14:10:29.000000000 
-0700
-@@ -179,7 +179,7 @@ static int read_from_file(uint8_t **data
- int tpm_store_permanent_data(void)
- {
-   uint8_t *buf, *ptr;
--  size_t buf_length, len;
-+  UINT32 buf_length, len;
- 
-   /* marshal data */
-   buf_length = len = sizeof_TPM_STCLEAR_FLAGS(tpmData.stclear.flags)
-@@ -207,13 +207,14 @@ int tpm_store_permanent_data(void)
- int tpm_restore_permanent_data(void)
- {
-   uint8_t *buf, *ptr;
--  size_t buf_length, len;
-+  size_t buf_length;
-+  UINT32 len;
-   TPM_VERSION ver;
- 
-   /* read data */
-   if (read_from_file(&buf, &buf_length)) return -1;
-   ptr = buf;
--  len = buf_length;
-+  len = (uint32_t) buf_length;
-   /* unmarshal data */
-   if (tpm_unmarshal_TPM_VERSION(&ptr, &len, &ver)
-       || memcmp(&ver, &tpmData.permanent.data.version, sizeof(TPM_VERSION))
-diff -uprN tpm_emulator-0.2/tpm/tpm_marshalling.c 
tpm_emulator-0.2-x86_64/tpm/tpm_marshalling.c
---- tpm_emulator-0.2/tpm/tpm_marshalling.c     2005-08-15 00:58:57.000000000 
-0700
-+++ tpm_emulator-0.2-x86_64/tpm/tpm_marshalling.c      2005-09-19 
14:10:29.000000000 -0700
-@@ -981,7 +981,7 @@ int tpm_unmarshal_TPM_STANY_FLAGS(BYTE *
- 
- int tpm_marshal_RSA(BYTE **ptr, UINT32 *length, rsa_private_key_t *v)
- {
--  UINT32 m_len, e_len, q_len;
-+  size_t m_len, e_len, q_len;
-   if (*length < sizeof_RSA((*v))) return -1;
-   if (v->size > 0) {
-     rsa_export_modulus(v, &(*ptr)[6], &m_len);
-diff -uprN tpm_emulator-0.2/tpm/tpm_owner.c 
tpm_emulator-0.2-x86_64/tpm/tpm_owner.c
---- tpm_emulator-0.2/tpm/tpm_owner.c   2005-08-15 00:58:57.000000000 -0700
-+++ tpm_emulator-0.2-x86_64/tpm/tpm_owner.c    2005-09-19 14:10:29.000000000 
-0700
-@@ -108,7 +108,7 @@ TPM_RESULT TPM_TakeOwnership(TPM_PROTOCO
-   TPM_RESULT res;
-   rsa_private_key_t *ek = &tpmData.permanent.data.endorsementKey;
-   TPM_KEY_DATA *srk = &tpmData.permanent.data.srk;
--  UINT32 buf_size = ek->size >> 3;
-+  size_t buf_size = ek->size >> 3, key_length; 
-   BYTE buf[buf_size];
- 
-   info("TPM_TakeOwnership()");
-@@ -172,7 +172,8 @@ TPM_RESULT TPM_TakeOwnership(TPM_PROTOCO
-     return TPM_FAIL;
-   }
-   rsa_export_modulus(&srk->key, srkPub->pubKey.key,
--    &srkPub->pubKey.keyLength);
-+                   &key_length);
-+  srkPub->pubKey.keyLength = (UINT32) key_length;
-   /* setup tpmProof and set state to owned */
-   tpm_get_random_bytes(tpmData.permanent.data.tpmProof.nonce, 
-     sizeof(tpmData.permanent.data.tpmProof.nonce));
-diff -uprN tpm_emulator-0.2/tpm/tpm_storage.c 
tpm_emulator-0.2-x86_64/tpm/tpm_storage.c
---- tpm_emulator-0.2/tpm/tpm_storage.c 2005-08-15 00:58:57.000000000 -0700
-+++ tpm_emulator-0.2-x86_64/tpm/tpm_storage.c  2005-09-19 14:10:29.000000000 
-0700
-@@ -58,6 +58,7 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke
-                         BYTE *enc, UINT32 *enc_size)
- {
-   UINT32 len;
-+  size_t enc_size32 = *enc_size;
-   BYTE *buf, *ptr;
-   rsa_public_key_t pub_key;
-   int scheme;
-@@ -72,7 +73,7 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke
-   if (buf == NULL
-       || tpm_marshal_TPM_SEALED_DATA(&ptr, &len, seal)
-       || rsa_encrypt(&pub_key, scheme, buf, sizeof_TPM_SEALED_DATA((*seal)),
--                     enc, enc_size)) {
-+                     enc, &enc_size32)) {
-     tpm_free(buf);
-     rsa_release_public_key(&pub_key);
-     return -1;
-@@ -85,7 +86,8 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke
- int decrypt_sealed_data(TPM_KEY_DATA *key, BYTE *enc, UINT32 enc_size,
-                         TPM_SEALED_DATA *seal, BYTE **buf) 
- {
--  UINT32 len;
-+  size_t len;
-+  UINT32 len32;
-   BYTE *ptr;
-   int scheme;
-   switch (key->encScheme) {
-@@ -96,8 +98,12 @@ int decrypt_sealed_data(TPM_KEY_DATA *ke
-   len = enc_size;
-   *buf = ptr = tpm_malloc(len);
-   if (*buf == NULL
--      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len)
--      || tpm_unmarshal_TPM_SEALED_DATA(&ptr, &len, seal)) {
-+      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len) ){
-+    tpm_free(*buf);
-+    return -1;
-+  }
-+  len32 = len;
-+  if (tpm_unmarshal_TPM_SEALED_DATA(&ptr, &len32, seal)) {
-     tpm_free(*buf);
-     return -1;
-   }
-@@ -237,11 +243,12 @@ TPM_RESULT TPM_Unseal(TPM_KEY_HANDLE par
- 
- TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE keyHandle, UINT32 inDataSize,
-                       BYTE *inData, TPM_AUTH *auth1, 
--                      UINT32 *outDataSize, BYTE **outData)
-+                      UINT32 *outDataSize32, BYTE **outData)
- {
-   TPM_RESULT res;
-   TPM_KEY_DATA *key;
-   int scheme;
-+  size_t outDataSize;
-   info("TPM_UnBind()");
-   /* get key */
-   key = tpm_get_key(keyHandle);
-@@ -258,8 +265,8 @@ TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE key
-   /* the size of the input data muss be greater than zero */
-   if (inDataSize == 0) return TPM_BAD_PARAMETER;
-   /* decrypt data */
--  *outDataSize = inDataSize;
--  *outData = tpm_malloc(*outDataSize);
-+  outDataSize = inDataSize;
-+  *outData = tpm_malloc(outDataSize);
-   if (*outData == NULL) return TPM_FAIL;
-   switch (key->encScheme) {
-     case TPM_ES_RSAESOAEP_SHA1_MGF1: scheme = RSA_ES_OAEP_SHA1; break;
-@@ -267,20 +274,21 @@ TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE key
-     default: tpm_free(*outData); return TPM_DECRYPT_ERROR;
-   }
-   if (rsa_decrypt(&key->key, scheme, inData, inDataSize, 
--      *outData, outDataSize)) {
-+                *outData, &outDataSize) ) { 
-     tpm_free(*outData);
-     return TPM_DECRYPT_ERROR;
-   }
-   /* verify data if it is of type TPM_BOUND_DATA */
-   if (key->encScheme == TPM_ES_RSAESOAEP_SHA1_MGF1 
-       || key->keyUsage != TPM_KEY_LEGACY) {
--    if (*outDataSize < 5 || memcmp(*outData, "\x01\x01\00\x00\x02", 5) != 0) {
-+    if (outDataSize < 5 || memcmp(*outData, "\x01\x01\00\x00\x02", 5) != 0) {
-       tpm_free(*outData);
-       return TPM_DECRYPT_ERROR;
-     }
--    *outDataSize -= 5;
--    memmove(*outData, &(*outData)[5], *outDataSize);   
--  } 
-+    outDataSize -= 5;
-+    memmove(*outData, &(*outData)[5], outDataSize);   
-+  }
-+  *outDataSize32 = (UINT32) outDataSize; 
-   return TPM_SUCCESS;
- }
- 
-@@ -311,12 +319,13 @@ static int verify_key_digest(TPM_KEY *ke
- }
- 
- int encrypt_private_key(TPM_KEY_DATA *key, TPM_STORE_ASYMKEY *store,
--                        BYTE *enc, UINT32 *enc_size)
-+                        BYTE *enc, UINT32 *enc_size32)
- {
-   UINT32 len;
-   BYTE *buf, *ptr;
-   rsa_public_key_t pub_key;
-   int scheme;
-+  size_t enc_size;
-   switch (key->encScheme) {
-     case TPM_ES_RSAESOAEP_SHA1_MGF1: scheme = RSA_ES_OAEP_SHA1; break;
-     case TPM_ES_RSAESPKCSv15: scheme = RSA_ES_PKCSV15; break;
-@@ -328,11 +337,12 @@ int encrypt_private_key(TPM_KEY_DATA *ke
-   if (buf == NULL
-       || tpm_marshal_TPM_STORE_ASYMKEY(&ptr, &len, store)
-       || rsa_encrypt(&pub_key, scheme, buf, 
sizeof_TPM_STORE_ASYMKEY((*store)),
--                     enc, enc_size)) {
-+                     enc, &enc_size)) {
-     tpm_free(buf);
-     rsa_release_public_key(&pub_key);
-     return -1;
-   }
-+  *enc_size32 = (UINT32) enc_size;
-   tpm_free(buf);
-   rsa_release_public_key(&pub_key);
-   return 0;
-@@ -341,7 +351,8 @@ int encrypt_private_key(TPM_KEY_DATA *ke
- int decrypt_private_key(TPM_KEY_DATA *key, BYTE *enc, UINT32 enc_size, 
-                         TPM_STORE_ASYMKEY *store, BYTE **buf) 
- {
--  UINT32 len;
-+  UINT32 len32;
-+  size_t len;
-   BYTE *ptr;
-   int scheme;
-   switch (key->encScheme) {
-@@ -352,11 +363,16 @@ int decrypt_private_key(TPM_KEY_DATA *ke
-   len = enc_size;
-   *buf = ptr = tpm_malloc(len);
-   if (*buf == NULL
--      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len)
--      || tpm_unmarshal_TPM_STORE_ASYMKEY(&ptr, &len, store)) {
-+      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len) ) {
-+    tpm_free(*buf);
-+    return -1;
-+  }
-+  len32 = (UINT32) len;
-+  if (tpm_unmarshal_TPM_STORE_ASYMKEY(&ptr, &len32, store)) {  
-     tpm_free(*buf);
-     return -1;
-   }
-+
-   return 0;
- }
- 
-@@ -371,7 +387,7 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN
-   TPM_SESSION_DATA *session;
-   TPM_STORE_ASYMKEY store;
-   rsa_private_key_t rsa;
--  UINT32 key_length;
-+  size_t key_length;
- 
-   info("TPM_CreateWrapKey()");
-   /* get parent key */
-@@ -428,11 +444,11 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN
-   }
-   if (compute_key_digest(wrappedKey, &store.pubDataDigest)) return TPM_FAIL;
-   /* generate key and store it */
--  key_length = keyInfo->algorithmParms.parms.rsa.keyLength;
--  if (rsa_generate_key(&rsa, key_length)) return TPM_FAIL;
--  wrappedKey->pubKey.keyLength = key_length >> 3;
-+  if (rsa_generate_key(&rsa, keyInfo->algorithmParms.parms.rsa.keyLength)) 
-+    return TPM_FAIL;
-+  wrappedKey->pubKey.keyLength = keyInfo->algorithmParms.parms.rsa.keyLength 
>> 3;
-   wrappedKey->pubKey.key = tpm_malloc(wrappedKey->pubKey.keyLength);
--  store.privKey.keyLength = key_length >> 4;
-+  store.privKey.keyLength = keyInfo->algorithmParms.parms.rsa.keyLength >> 4;
-   store.privKey.key = tpm_malloc(store.privKey.keyLength);
-   wrappedKey->encDataSize = parent->key.size >> 3;
-   wrappedKey->encData = tpm_malloc(wrappedKey->encDataSize);
-@@ -444,9 +460,11 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN
-     tpm_free(wrappedKey->encData);
-     return TPM_FAIL;
-   }
--  rsa_export_modulus(&rsa, wrappedKey->pubKey.key, 
--    &wrappedKey->pubKey.keyLength);
--  rsa_export_prime1(&rsa, store.privKey.key, &store.privKey.keyLength);
-+  rsa_export_modulus(&rsa, wrappedKey->pubKey.key,
-+                   &key_length);
-+  wrappedKey->pubKey.keyLength = (UINT32) key_length;
-+  rsa_export_prime1(&rsa, store.privKey.key, &key_length);
-+  store.privKey.keyLength = (UINT32) key_length;
-   rsa_release_private_key(&rsa);
-   /* encrypt private key data */
-   if (encrypt_private_key(parent, &store, wrappedKey->encData, 
-@@ -560,6 +578,7 @@ TPM_RESULT TPM_LoadKey(TPM_KEY_HANDLE pa
- 
- int tpm_setup_key_parms(TPM_KEY_DATA *key, TPM_KEY_PARMS *parms)
- {
-+  size_t key_length;
-   parms->algorithmID = TPM_ALG_RSA;
-   parms->encScheme = key->encScheme;
-   parms->sigScheme = key->sigScheme;
-@@ -569,7 +588,8 @@ int tpm_setup_key_parms(TPM_KEY_DATA *ke
-   parms->parms.rsa.exponent = tpm_malloc(parms->parms.rsa.exponentSize);
-   if (parms->parms.rsa.exponent == NULL) return -1;
-   rsa_export_exponent(&key->key, parms->parms.rsa.exponent,
--    &parms->parms.rsa.exponentSize);
-+                      &key_length);  
-+  parms->parms.rsa.exponentSize = (UINT32) key_length;
-   parms->parmSize = 12 + parms->parms.rsa.exponentSize;  
-   return 0;
- }
-@@ -580,6 +600,7 @@ TPM_RESULT TPM_GetPubKey(TPM_KEY_HANDLE 
-   TPM_RESULT res;
-   TPM_KEY_DATA *key;
-   TPM_DIGEST digest;
-+  size_t key_length;
-   info("TPM_GetPubKey()");
-   /* get key */
-   if (keyHandle == TPM_KH_SRK) return TPM_BAD_PARAMETER;
-@@ -607,8 +628,8 @@ TPM_RESULT TPM_GetPubKey(TPM_KEY_HANDLE 
-   pubKey->pubKey.keyLength = key->key.size >> 3;
-   pubKey->pubKey.key = tpm_malloc(pubKey->pubKey.keyLength);
-   if (pubKey->pubKey.key == NULL) return TPM_FAIL;
--  rsa_export_modulus(&key->key, pubKey->pubKey.key, 
--    &pubKey->pubKey.keyLength);
-+  rsa_export_modulus(&key->key, pubKey->pubKey.key, &key_length); 
-+  pubKey->pubKey.keyLength = (UINT32) key_length;
-   if (tpm_setup_key_parms(key, &pubKey->algorithmParms) != 0) {
-     tpm_free(pubKey->pubKey.key);
-     return TPM_FAIL;  
-diff -uprN tpm_emulator-0.2/tpm_version.h tpm_emulator-0.2-x86_64/tpm_version.h
---- tpm_emulator-0.2/tpm_version.h     2005-08-15 00:58:57.000000000 -0700
-+++ tpm_emulator-0.2-x86_64/tpm_version.h      1969-12-31 16:00:00.000000000 
-0800
-@@ -1,6 +0,0 @@
--#ifndef _TPM_VERSION_H_
--#define _TPM_VERSION_H_
--#define VERSION_MAJOR 0
--#define VERSION_MINOR 2
--#define VERSION_BUILD 1123950310
--#endif /* _TPM_VERSION_H_ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.