ia64/xen-unstable

changeset 10225:fbcb603288bb

[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@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed May 31 07:45:20 2006 +0100 (2006-05-31)
parents b3b5f3ff2100
children 59bd5b9f5043
files tools/vtpm/Makefile tools/vtpm/Rules.mk tools/vtpm/tpm_emulator-0.3-x86_64.patch tools/vtpm/vtpm.patch
line diff
     1.1 --- a/tools/vtpm/Makefile	Wed May 31 07:43:06 2006 +0100
     1.2 +++ b/tools/vtpm/Makefile	Wed May 31 07:45:20 2006 +0100
     1.3 @@ -9,7 +9,7 @@ TPM_EMULATOR_DIR = tpm_emulator
     1.4  VTPM_DIR = vtpm
     1.5  
     1.6  # Emulator tarball name
     1.7 -TPM_EMULATOR_TARFILE = tpm_emulator-0.2b.tar.gz
     1.8 +TPM_EMULATOR_TARFILE = tpm_emulator-0.3.tar.gz
     1.9  
    1.10  GMP_HEADER = /usr/include/gmp.h
    1.11  
    1.12 @@ -47,23 +47,23 @@ mrproper:
    1.13  
    1.14  # Create vtpm and TPM emulator dirs
    1.15  # apply patches for 1) used as dom0 tpm driver 2) used as vtpm device instance
    1.16 -$(TPM_EMULATOR_DIR): $(TPM_EMULATOR_TARFILE) tpm_emulator.patch tpm_emulator-0.2b-x86_64.patch
    1.17 +$(TPM_EMULATOR_DIR): $(TPM_EMULATOR_TARFILE) tpm_emulator.patch tpm_emulator-0.3-x86_64.patch
    1.18  	if [ "$(BUILD_EMULATOR)" = "y" ]; then \
    1.19  		tar -xzf $(TPM_EMULATOR_TARFILE); \
    1.20  		rm -rf $(TPM_EMULATOR_DIR); \
    1.21 -		mv tpm_emulator-0.2 $(TPM_EMULATOR_DIR); \
    1.22 +		mv tpm_emulator-0.3 $(TPM_EMULATOR_DIR); \
    1.23  		cd $(TPM_EMULATOR_DIR); \
    1.24 -		patch -p1 < ../tpm_emulator-0.2b-x86_64.patch; \
    1.25 +		patch -p1 < ../tpm_emulator-0.3-x86_64.patch; \
    1.26  		patch -p1 <../tpm_emulator.patch; \
    1.27  	fi
    1.28  
    1.29 -$(VTPM_DIR): $(TPM_EMULATOR_TARFILE) tpm_emulator-0.2b-x86_64.patch vtpm.patch
    1.30 +$(VTPM_DIR): $(TPM_EMULATOR_TARFILE) tpm_emulator-0.3-x86_64.patch vtpm.patch
    1.31  	tar -xzf $(TPM_EMULATOR_TARFILE);  
    1.32  	rm -rf $(VTPM_DIR)
    1.33 -	mv tpm_emulator-0.2 $(VTPM_DIR); 
    1.34 +	mv tpm_emulator-0.3 $(VTPM_DIR); 
    1.35  
    1.36  	cd $(VTPM_DIR); \
    1.37 -	patch -p1 < ../tpm_emulator-0.2b-x86_64.patch; \
    1.38 +	patch -p1 < ../tpm_emulator-0.3-x86_64.patch; \
    1.39  	patch -p1 <../vtpm.patch
    1.40  
    1.41  .PHONY: build_sub
     2.1 --- a/tools/vtpm/Rules.mk	Wed May 31 07:43:06 2006 +0100
     2.2 +++ b/tools/vtpm/Rules.mk	Wed May 31 07:45:20 2006 +0100
     2.3 @@ -33,6 +33,7 @@ OBJS	= $(patsubst %.c,%.o,$(SRCS))
     2.4  
     2.5  -include $(DEP_FILES)
     2.6  
     2.7 +# Emulator does not work on 64-bit systems, and may be broken on 32 right now
     2.8  BUILD_EMULATOR = n
     2.9  
    2.10  # Make sure these are just rules
     3.1 --- a/tools/vtpm/tpm_emulator-0.2b-x86_64.patch	Wed May 31 07:43:06 2006 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,499 +0,0 @@
     3.4 -diff -uprN tpm_emulator-0.2/crypto/gmp_kernel_wrapper.c tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c
     3.5 ---- tpm_emulator-0.2/crypto/gmp_kernel_wrapper.c	2005-08-15 00:58:57.000000000 -0700
     3.6 -+++ tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c	2005-09-19 14:10:29.000000000 -0700
     3.7 -@@ -79,7 +79,7 @@ void __attribute__ ((regparm(0))) *kerne
     3.8 - {
     3.9 -   void *ret  = (void*)kmalloc(size, GFP_KERNEL);
    3.10 -   if (!ret) panic(KERN_CRIT TPM_MODULE_NAME 
    3.11 --    "GMP: cannot allocate memory (size=%u)\n", size);
    3.12 -+    "GMP: cannot allocate memory (size=%Zu)\n", size);
    3.13 -   return ret;
    3.14 - }
    3.15 - 
    3.16 -@@ -88,7 +88,7 @@ void __attribute__ ((regparm(0))) *kerne
    3.17 - {
    3.18 -   void *ret = (void*)kmalloc(new_size, GFP_KERNEL);
    3.19 -   if (!ret) panic(KERN_CRIT TPM_MODULE_NAME "GMP: Cannot reallocate memory "
    3.20 --    "(old_size=%u new_size=%u)\n", old_size, new_size);
    3.21 -+    "(old_size=%Zu new_size=%Zu)\n", old_size, new_size);
    3.22 -   memcpy(ret, oldptr, old_size);
    3.23 -   kfree(oldptr);
    3.24 -   return ret;
    3.25 -diff -uprN tpm_emulator-0.2/linux_module.c tpm_emulator-0.2-x86_64/linux_module.c
    3.26 ---- tpm_emulator-0.2/linux_module.c	2005-08-15 00:58:57.000000000 -0700
    3.27 -+++ tpm_emulator-0.2-x86_64/linux_module.c	2005-09-19 14:10:29.000000000 -0700
    3.28 -@@ -66,7 +66,7 @@ static int tpm_release(struct inode *ino
    3.29 - 
    3.30 - static ssize_t tpm_read(struct file *file, char *buf, size_t count, loff_t *ppos)
    3.31 - {
    3.32 --  debug("%s(%d)", __FUNCTION__, count);
    3.33 -+  debug("%s(%Zu)", __FUNCTION__, count);
    3.34 -   down(&tpm_mutex);
    3.35 -   if (tpm_response.data != NULL) {
    3.36 -     count = min(count, (size_t)tpm_response.size - (size_t)*ppos);
    3.37 -@@ -81,7 +81,7 @@ static ssize_t tpm_read(struct file *fil
    3.38 - 
    3.39 - static ssize_t tpm_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
    3.40 - {
    3.41 --  debug("%s(%d)", __FUNCTION__, count);
    3.42 -+  debug("%s(%Zu)", __FUNCTION__, count);
    3.43 -   down(&tpm_mutex);
    3.44 -   *ppos = 0;
    3.45 -   if (tpm_response.data != NULL) kfree(tpm_response.data);
    3.46 -diff -uprN tpm_emulator-0.2/linux_module.h tpm_emulator-0.2-x86_64/linux_module.h
    3.47 ---- tpm_emulator-0.2/linux_module.h	2005-08-15 00:58:57.000000000 -0700
    3.48 -+++ tpm_emulator-0.2-x86_64/linux_module.h	2005-09-19 14:10:29.000000000 -0700
    3.49 -@@ -28,8 +28,10 @@
    3.50 - 
    3.51 - /* module settings */
    3.52 - 
    3.53 -+#ifndef STR
    3.54 - #define STR(s) __STR__(s)
    3.55 - #define __STR__(s) #s
    3.56 -+#endif
    3.57 - #include "tpm_version.h"
    3.58 - 
    3.59 - #define TPM_DEVICE_MINOR	224
    3.60 -diff -uprN tpm_emulator-0.2/Makefile tpm_emulator-0.2-x86_64/Makefile
    3.61 ---- tpm_emulator-0.2/Makefile	2005-08-15 00:58:57.000000000 -0700
    3.62 -+++ tpm_emulator-0.2-x86_64/Makefile	2005-09-19 14:10:29.000000000 -0700
    3.63 -@@ -7,6 +7,7 @@
    3.64 - KERNEL_RELEASE := $(shell uname -r)
    3.65 - KERNEL_BUILD   := /lib/modules/$(KERNEL_RELEASE)/build
    3.66 - MOD_SUBDIR     := misc
    3.67 -+COMPILE_ARCH    ?= $(shell uname -m | sed -e s/i.86/x86_32/)
    3.68 - 
    3.69 - # module settings
    3.70 - MODULE_NAME    := tpm_emulator
    3.71 -@@ -17,8 +18,14 @@ VERSION_BUILD  := $(shell date +"%s")
    3.72 - # enable/disable DEBUG messages
    3.73 - EXTRA_CFLAGS   += -DDEBUG -g  
    3.74 - 
    3.75 -+ifeq ($(COMPILE_ARCH),x86_64)
    3.76 -+LIBDIR = lib64
    3.77 -+else
    3.78 -+LIBDIR = lib
    3.79 -+endif
    3.80 -+
    3.81 - # GNU MP configuration
    3.82 --GMP_LIB        := /usr/lib/libgmp.a
    3.83 -+GMP_LIB        := /usr/$(LIBDIR)/libgmp.a
    3.84 - GMP_HEADER     := /usr/include/gmp.h
    3.85 - 
    3.86 - # sources and objects
    3.87 -diff -uprN tpm_emulator-0.2/README tpm_emulator-0.2-x86_64/README
    3.88 ---- tpm_emulator-0.2/README	2005-08-15 00:58:57.000000000 -0700
    3.89 -+++ tpm_emulator-0.2-x86_64/README	2005-09-19 14:21:43.000000000 -0700
    3.90 -@@ -45,6 +45,12 @@ Example:
    3.91 - GMP_LIB        := /usr/lib/libgmp.a
    3.92 - GMP_HEADER     := /usr/include/gmp.h
    3.93 - 
    3.94 -+GNU MP Library on 64 bit Systems
    3.95 -+--------------------------------------------------------------------------
    3.96 -+Some 64-bit kernels have problems with importing the user-space gmp 
    3.97 -+library (/usr/lib*/libgmp.a) into kernel space.  These kernels will require
    3.98 -+that the gmp library be recompiled for kernel space with -mcmodel=kernel.
    3.99 -+
   3.100 - Installation
   3.101 - --------------------------------------------------------------------------
   3.102 - The compilation and installation process uses the build environment for 
   3.103 -diff -uprN tpm_emulator-0.2/tpm/tpm_credentials.c tpm_emulator-0.2-x86_64/tpm/tpm_credentials.c
   3.104 ---- tpm_emulator-0.2/tpm/tpm_credentials.c	2005-08-15 00:58:57.000000000 -0700
   3.105 -+++ tpm_emulator-0.2-x86_64/tpm/tpm_credentials.c	2005-09-19 14:10:29.000000000 -0700
   3.106 -@@ -47,16 +47,16 @@ int tpm_compute_pubkey_checksum(TPM_NONC
   3.107 - 
   3.108 - TPM_RESULT tpm_get_pubek(TPM_PUBKEY *pubEndorsementKey)
   3.109 - {
   3.110 --  UINT32 key_length;
   3.111 -+  size_t key_length;
   3.112 -   if (!tpmData.permanent.data.endorsementKey.size) return TPM_NO_ENDORSEMENT;
   3.113 -   /* setup TPM_PUBKEY structure */
   3.114 --  key_length = tpmData.permanent.data.endorsementKey.size;
   3.115 --  pubEndorsementKey->pubKey.keyLength = key_length >> 3;
   3.116 -+  pubEndorsementKey->pubKey.keyLength = tpmData.permanent.data.endorsementKey.size >> 3;
   3.117 -   pubEndorsementKey->pubKey.key = tpm_malloc(pubEndorsementKey->pubKey.keyLength);
   3.118 -   if (pubEndorsementKey->pubKey.key == NULL) return TPM_FAIL;
   3.119 -   rsa_export_modulus(&tpmData.permanent.data.endorsementKey,
   3.120 --    pubEndorsementKey->pubKey.key,
   3.121 --    &pubEndorsementKey->pubKey.keyLength);
   3.122 -+		     pubEndorsementKey->pubKey.key,
   3.123 -+		     &key_length);
   3.124 -+  pubEndorsementKey->pubKey.keyLength = key_length;
   3.125 -   pubEndorsementKey->algorithmParms.algorithmID = TPM_ALG_RSA;
   3.126 -   pubEndorsementKey->algorithmParms.encScheme = TPM_ES_RSAESOAEP_SHA1_MGF1;
   3.127 -   pubEndorsementKey->algorithmParms.sigScheme = TPM_SS_NONE;
   3.128 -@@ -169,6 +169,7 @@ TPM_RESULT TPM_OwnerReadInternalPub(TPM_
   3.129 - {
   3.130 -   TPM_RESULT res;
   3.131 -   TPM_KEY_DATA *srk = &tpmData.permanent.data.srk;
   3.132 -+  size_t key_length;
   3.133 -   info("TPM_OwnerReadInternalPub()");
   3.134 -   /* verify authorization */
   3.135 -   res = tpm_verify_auth(auth1, tpmData.permanent.data.ownerAuth, TPM_KH_OWNER);
   3.136 -@@ -180,7 +181,8 @@ TPM_RESULT TPM_OwnerReadInternalPub(TPM_
   3.137 -     publicPortion->pubKey.key = tpm_malloc(publicPortion->pubKey.keyLength);
   3.138 -     if (publicPortion->pubKey.key == NULL) return TPM_FAIL;
   3.139 -     rsa_export_modulus(&srk->key, publicPortion->pubKey.key, 
   3.140 --      &publicPortion->pubKey.keyLength);
   3.141 -+      &key_length);
   3.142 -+    publicPortion->pubKey.keyLength = key_length;
   3.143 -     publicPortion->algorithmParms.algorithmID = TPM_ALG_RSA;
   3.144 -     publicPortion->algorithmParms.encScheme = srk->encScheme;
   3.145 -     publicPortion->algorithmParms.sigScheme = srk->sigScheme;
   3.146 -diff -uprN tpm_emulator-0.2/tpm/tpm_crypto.c tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c
   3.147 ---- tpm_emulator-0.2/tpm/tpm_crypto.c	2005-08-15 00:58:57.000000000 -0700
   3.148 -+++ tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c	2005-09-19 14:10:29.000000000 -0700
   3.149 -@@ -182,7 +182,8 @@ TPM_RESULT TPM_CertifyKey(TPM_KEY_HANDLE
   3.150 -   TPM_KEY_DATA *cert, *key;
   3.151 -   sha1_ctx_t sha1_ctx;
   3.152 -   BYTE *buf, *p;
   3.153 --  UINT32 length;
   3.154 -+  UINT32 length32;
   3.155 -+  size_t length;
   3.156 -   info("TPM_CertifyKey()");
   3.157 -   /* get keys */
   3.158 -   cert = tpm_get_key(certHandle);
   3.159 -@@ -264,14 +265,15 @@ TPM_RESULT TPM_CertifyKey(TPM_KEY_HANDLE
   3.160 -   /* compute the digest of the CERTIFY_INFO[2] structure and sign it */
   3.161 -   length = sizeof_TPM_CERTIFY_INFO((*certifyInfo));
   3.162 -   p = buf = tpm_malloc(length);
   3.163 -+  length32=(UINT32) length;
   3.164 -   if (buf == NULL
   3.165 --      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length, certifyInfo)) {
   3.166 -+      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length32, certifyInfo)) {
   3.167 -     free_TPM_KEY_PARMS(certifyInfo->algorithmParms);
   3.168 -     return TPM_FAIL;
   3.169 -   }
   3.170 -   length = sizeof_TPM_CERTIFY_INFO((*certifyInfo));
   3.171 -   sha1_init(&sha1_ctx);
   3.172 --  sha1_update(&sha1_ctx, buf, length);
   3.173 -+  sha1_update(&sha1_ctx, buf, (size_t) length);
   3.174 -   sha1_final(&sha1_ctx, buf);
   3.175 -   res = tpm_sign(cert, auth1, FALSE, buf, SHA1_DIGEST_LENGTH, outData, outDataSize);
   3.176 -   tpm_free(buf);
   3.177 -@@ -292,7 +294,8 @@ TPM_RESULT TPM_CertifyKey2(TPM_KEY_HANDL
   3.178 -   TPM_KEY_DATA *cert, *key;
   3.179 -   sha1_ctx_t sha1_ctx;
   3.180 -   BYTE *buf, *p;
   3.181 --  UINT32 length;
   3.182 -+  size_t length;
   3.183 -+  UINT32 length32;
   3.184 -   info("TPM_CertifyKey2()");
   3.185 -   /* get keys */
   3.186 -   cert = tpm_get_key(certHandle);
   3.187 -@@ -362,8 +365,9 @@ TPM_RESULT TPM_CertifyKey2(TPM_KEY_HANDL
   3.188 -   /* compute the digest of the CERTIFY_INFO[2] structure and sign it */
   3.189 -   length = sizeof_TPM_CERTIFY_INFO((*certifyInfo));
   3.190 -   p = buf = tpm_malloc(length);
   3.191 -+  length32 = (UINT32) length;
   3.192 -   if (buf == NULL
   3.193 --      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length, certifyInfo)) {
   3.194 -+      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length32, certifyInfo)) {
   3.195 -     free_TPM_KEY_PARMS(certifyInfo->algorithmParms);
   3.196 -     return TPM_FAIL;
   3.197 -   }
   3.198 -diff -uprN tpm_emulator-0.2/tpm/tpm_data.c tpm_emulator-0.2-x86_64/tpm/tpm_data.c
   3.199 ---- tpm_emulator-0.2/tpm/tpm_data.c	2005-08-15 00:58:57.000000000 -0700
   3.200 -+++ tpm_emulator-0.2-x86_64/tpm/tpm_data.c	2005-09-19 14:10:29.000000000 -0700
   3.201 -@@ -179,7 +179,7 @@ static int read_from_file(uint8_t **data
   3.202 - int tpm_store_permanent_data(void)
   3.203 - {
   3.204 -   uint8_t *buf, *ptr;
   3.205 --  size_t buf_length, len;
   3.206 -+  UINT32 buf_length, len;
   3.207 - 
   3.208 -   /* marshal data */
   3.209 -   buf_length = len = sizeof_TPM_STCLEAR_FLAGS(tpmData.stclear.flags)
   3.210 -@@ -207,13 +207,14 @@ int tpm_store_permanent_data(void)
   3.211 - int tpm_restore_permanent_data(void)
   3.212 - {
   3.213 -   uint8_t *buf, *ptr;
   3.214 --  size_t buf_length, len;
   3.215 -+  size_t buf_length;
   3.216 -+  UINT32 len;
   3.217 -   TPM_VERSION ver;
   3.218 - 
   3.219 -   /* read data */
   3.220 -   if (read_from_file(&buf, &buf_length)) return -1;
   3.221 -   ptr = buf;
   3.222 --  len = buf_length;
   3.223 -+  len = (uint32_t) buf_length;
   3.224 -   /* unmarshal data */
   3.225 -   if (tpm_unmarshal_TPM_VERSION(&ptr, &len, &ver)
   3.226 -       || memcmp(&ver, &tpmData.permanent.data.version, sizeof(TPM_VERSION))
   3.227 -diff -uprN tpm_emulator-0.2/tpm/tpm_marshalling.c tpm_emulator-0.2-x86_64/tpm/tpm_marshalling.c
   3.228 ---- tpm_emulator-0.2/tpm/tpm_marshalling.c	2005-08-15 00:58:57.000000000 -0700
   3.229 -+++ tpm_emulator-0.2-x86_64/tpm/tpm_marshalling.c	2005-09-19 14:10:29.000000000 -0700
   3.230 -@@ -981,7 +981,7 @@ int tpm_unmarshal_TPM_STANY_FLAGS(BYTE *
   3.231 - 
   3.232 - int tpm_marshal_RSA(BYTE **ptr, UINT32 *length, rsa_private_key_t *v)
   3.233 - {
   3.234 --  UINT32 m_len, e_len, q_len;
   3.235 -+  size_t m_len, e_len, q_len;
   3.236 -   if (*length < sizeof_RSA((*v))) return -1;
   3.237 -   if (v->size > 0) {
   3.238 -     rsa_export_modulus(v, &(*ptr)[6], &m_len);
   3.239 -diff -uprN tpm_emulator-0.2/tpm/tpm_owner.c tpm_emulator-0.2-x86_64/tpm/tpm_owner.c
   3.240 ---- tpm_emulator-0.2/tpm/tpm_owner.c	2005-08-15 00:58:57.000000000 -0700
   3.241 -+++ tpm_emulator-0.2-x86_64/tpm/tpm_owner.c	2005-09-19 14:10:29.000000000 -0700
   3.242 -@@ -108,7 +108,7 @@ TPM_RESULT TPM_TakeOwnership(TPM_PROTOCO
   3.243 -   TPM_RESULT res;
   3.244 -   rsa_private_key_t *ek = &tpmData.permanent.data.endorsementKey;
   3.245 -   TPM_KEY_DATA *srk = &tpmData.permanent.data.srk;
   3.246 --  UINT32 buf_size = ek->size >> 3;
   3.247 -+  size_t buf_size = ek->size >> 3, key_length; 
   3.248 -   BYTE buf[buf_size];
   3.249 - 
   3.250 -   info("TPM_TakeOwnership()");
   3.251 -@@ -172,7 +172,8 @@ TPM_RESULT TPM_TakeOwnership(TPM_PROTOCO
   3.252 -     return TPM_FAIL;
   3.253 -   }
   3.254 -   rsa_export_modulus(&srk->key, srkPub->pubKey.key,
   3.255 --    &srkPub->pubKey.keyLength);
   3.256 -+		     &key_length);
   3.257 -+  srkPub->pubKey.keyLength = (UINT32) key_length;
   3.258 -   /* setup tpmProof and set state to owned */
   3.259 -   tpm_get_random_bytes(tpmData.permanent.data.tpmProof.nonce, 
   3.260 -     sizeof(tpmData.permanent.data.tpmProof.nonce));
   3.261 -diff -uprN tpm_emulator-0.2/tpm/tpm_storage.c tpm_emulator-0.2-x86_64/tpm/tpm_storage.c
   3.262 ---- tpm_emulator-0.2/tpm/tpm_storage.c	2005-08-15 00:58:57.000000000 -0700
   3.263 -+++ tpm_emulator-0.2-x86_64/tpm/tpm_storage.c	2005-09-19 14:10:29.000000000 -0700
   3.264 -@@ -58,6 +58,7 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke
   3.265 -                         BYTE *enc, UINT32 *enc_size)
   3.266 - {
   3.267 -   UINT32 len;
   3.268 -+  size_t enc_size32 = *enc_size;
   3.269 -   BYTE *buf, *ptr;
   3.270 -   rsa_public_key_t pub_key;
   3.271 -   int scheme;
   3.272 -@@ -72,7 +73,7 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke
   3.273 -   if (buf == NULL
   3.274 -       || tpm_marshal_TPM_SEALED_DATA(&ptr, &len, seal)
   3.275 -       || rsa_encrypt(&pub_key, scheme, buf, sizeof_TPM_SEALED_DATA((*seal)),
   3.276 --                     enc, enc_size)) {
   3.277 -+                     enc, &enc_size32)) {
   3.278 -     tpm_free(buf);
   3.279 -     rsa_release_public_key(&pub_key);
   3.280 -     return -1;
   3.281 -@@ -85,7 +86,8 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke
   3.282 - int decrypt_sealed_data(TPM_KEY_DATA *key, BYTE *enc, UINT32 enc_size,
   3.283 -                         TPM_SEALED_DATA *seal, BYTE **buf) 
   3.284 - {
   3.285 --  UINT32 len;
   3.286 -+  size_t len;
   3.287 -+  UINT32 len32;
   3.288 -   BYTE *ptr;
   3.289 -   int scheme;
   3.290 -   switch (key->encScheme) {
   3.291 -@@ -96,8 +98,12 @@ int decrypt_sealed_data(TPM_KEY_DATA *ke
   3.292 -   len = enc_size;
   3.293 -   *buf = ptr = tpm_malloc(len);
   3.294 -   if (*buf == NULL
   3.295 --      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len)
   3.296 --      || tpm_unmarshal_TPM_SEALED_DATA(&ptr, &len, seal)) {
   3.297 -+      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len) ){
   3.298 -+    tpm_free(*buf);
   3.299 -+    return -1;
   3.300 -+  }
   3.301 -+  len32 = len;
   3.302 -+  if (tpm_unmarshal_TPM_SEALED_DATA(&ptr, &len32, seal)) {
   3.303 -     tpm_free(*buf);
   3.304 -     return -1;
   3.305 -   }
   3.306 -@@ -237,11 +243,12 @@ TPM_RESULT TPM_Unseal(TPM_KEY_HANDLE par
   3.307 - 
   3.308 - TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE keyHandle, UINT32 inDataSize,
   3.309 -                       BYTE *inData, TPM_AUTH *auth1, 
   3.310 --                      UINT32 *outDataSize, BYTE **outData)
   3.311 -+                      UINT32 *outDataSize32, BYTE **outData)
   3.312 - {
   3.313 -   TPM_RESULT res;
   3.314 -   TPM_KEY_DATA *key;
   3.315 -   int scheme;
   3.316 -+  size_t outDataSize;
   3.317 -   info("TPM_UnBind()");
   3.318 -   /* get key */
   3.319 -   key = tpm_get_key(keyHandle);
   3.320 -@@ -258,8 +265,8 @@ TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE key
   3.321 -   /* the size of the input data muss be greater than zero */
   3.322 -   if (inDataSize == 0) return TPM_BAD_PARAMETER;
   3.323 -   /* decrypt data */
   3.324 --  *outDataSize = inDataSize;
   3.325 --  *outData = tpm_malloc(*outDataSize);
   3.326 -+  outDataSize = inDataSize;
   3.327 -+  *outData = tpm_malloc(outDataSize);
   3.328 -   if (*outData == NULL) return TPM_FAIL;
   3.329 -   switch (key->encScheme) {
   3.330 -     case TPM_ES_RSAESOAEP_SHA1_MGF1: scheme = RSA_ES_OAEP_SHA1; break;
   3.331 -@@ -267,20 +274,21 @@ TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE key
   3.332 -     default: tpm_free(*outData); return TPM_DECRYPT_ERROR;
   3.333 -   }
   3.334 -   if (rsa_decrypt(&key->key, scheme, inData, inDataSize, 
   3.335 --      *outData, outDataSize)) {
   3.336 -+		  *outData, &outDataSize) ) { 
   3.337 -     tpm_free(*outData);
   3.338 -     return TPM_DECRYPT_ERROR;
   3.339 -   }
   3.340 -   /* verify data if it is of type TPM_BOUND_DATA */
   3.341 -   if (key->encScheme == TPM_ES_RSAESOAEP_SHA1_MGF1 
   3.342 -       || key->keyUsage != TPM_KEY_LEGACY) {
   3.343 --    if (*outDataSize < 5 || memcmp(*outData, "\x01\x01\00\x00\x02", 5) != 0) {
   3.344 -+    if (outDataSize < 5 || memcmp(*outData, "\x01\x01\00\x00\x02", 5) != 0) {
   3.345 -       tpm_free(*outData);
   3.346 -       return TPM_DECRYPT_ERROR;
   3.347 -     }
   3.348 --    *outDataSize -= 5;
   3.349 --    memmove(*outData, &(*outData)[5], *outDataSize);   
   3.350 --  } 
   3.351 -+    outDataSize -= 5;
   3.352 -+    memmove(*outData, &(*outData)[5], outDataSize);   
   3.353 -+  }
   3.354 -+  *outDataSize32 = (UINT32) outDataSize; 
   3.355 -   return TPM_SUCCESS;
   3.356 - }
   3.357 - 
   3.358 -@@ -311,12 +319,13 @@ static int verify_key_digest(TPM_KEY *ke
   3.359 - }
   3.360 - 
   3.361 - int encrypt_private_key(TPM_KEY_DATA *key, TPM_STORE_ASYMKEY *store,
   3.362 --                        BYTE *enc, UINT32 *enc_size)
   3.363 -+                        BYTE *enc, UINT32 *enc_size32)
   3.364 - {
   3.365 -   UINT32 len;
   3.366 -   BYTE *buf, *ptr;
   3.367 -   rsa_public_key_t pub_key;
   3.368 -   int scheme;
   3.369 -+  size_t enc_size;
   3.370 -   switch (key->encScheme) {
   3.371 -     case TPM_ES_RSAESOAEP_SHA1_MGF1: scheme = RSA_ES_OAEP_SHA1; break;
   3.372 -     case TPM_ES_RSAESPKCSv15: scheme = RSA_ES_PKCSV15; break;
   3.373 -@@ -328,11 +337,12 @@ int encrypt_private_key(TPM_KEY_DATA *ke
   3.374 -   if (buf == NULL
   3.375 -       || tpm_marshal_TPM_STORE_ASYMKEY(&ptr, &len, store)
   3.376 -       || rsa_encrypt(&pub_key, scheme, buf, sizeof_TPM_STORE_ASYMKEY((*store)),
   3.377 --                     enc, enc_size)) {
   3.378 -+                     enc, &enc_size)) {
   3.379 -     tpm_free(buf);
   3.380 -     rsa_release_public_key(&pub_key);
   3.381 -     return -1;
   3.382 -   }
   3.383 -+  *enc_size32 = (UINT32) enc_size;
   3.384 -   tpm_free(buf);
   3.385 -   rsa_release_public_key(&pub_key);
   3.386 -   return 0;
   3.387 -@@ -341,7 +351,8 @@ int encrypt_private_key(TPM_KEY_DATA *ke
   3.388 - int decrypt_private_key(TPM_KEY_DATA *key, BYTE *enc, UINT32 enc_size, 
   3.389 -                         TPM_STORE_ASYMKEY *store, BYTE **buf) 
   3.390 - {
   3.391 --  UINT32 len;
   3.392 -+  UINT32 len32;
   3.393 -+  size_t len;
   3.394 -   BYTE *ptr;
   3.395 -   int scheme;
   3.396 -   switch (key->encScheme) {
   3.397 -@@ -352,11 +363,16 @@ int decrypt_private_key(TPM_KEY_DATA *ke
   3.398 -   len = enc_size;
   3.399 -   *buf = ptr = tpm_malloc(len);
   3.400 -   if (*buf == NULL
   3.401 --      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len)
   3.402 --      || tpm_unmarshal_TPM_STORE_ASYMKEY(&ptr, &len, store)) {
   3.403 -+      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len) ) {
   3.404 -+    tpm_free(*buf);
   3.405 -+    return -1;
   3.406 -+  }
   3.407 -+  len32 = (UINT32) len;
   3.408 -+  if (tpm_unmarshal_TPM_STORE_ASYMKEY(&ptr, &len32, store)) {  
   3.409 -     tpm_free(*buf);
   3.410 -     return -1;
   3.411 -   }
   3.412 -+
   3.413 -   return 0;
   3.414 - }
   3.415 - 
   3.416 -@@ -371,7 +387,7 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN
   3.417 -   TPM_SESSION_DATA *session;
   3.418 -   TPM_STORE_ASYMKEY store;
   3.419 -   rsa_private_key_t rsa;
   3.420 --  UINT32 key_length;
   3.421 -+  size_t key_length;
   3.422 - 
   3.423 -   info("TPM_CreateWrapKey()");
   3.424 -   /* get parent key */
   3.425 -@@ -428,11 +444,11 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN
   3.426 -   }
   3.427 -   if (compute_key_digest(wrappedKey, &store.pubDataDigest)) return TPM_FAIL;
   3.428 -   /* generate key and store it */
   3.429 --  key_length = keyInfo->algorithmParms.parms.rsa.keyLength;
   3.430 --  if (rsa_generate_key(&rsa, key_length)) return TPM_FAIL;
   3.431 --  wrappedKey->pubKey.keyLength = key_length >> 3;
   3.432 -+  if (rsa_generate_key(&rsa, keyInfo->algorithmParms.parms.rsa.keyLength)) 
   3.433 -+    return TPM_FAIL;
   3.434 -+  wrappedKey->pubKey.keyLength = keyInfo->algorithmParms.parms.rsa.keyLength >> 3;
   3.435 -   wrappedKey->pubKey.key = tpm_malloc(wrappedKey->pubKey.keyLength);
   3.436 --  store.privKey.keyLength = key_length >> 4;
   3.437 -+  store.privKey.keyLength = keyInfo->algorithmParms.parms.rsa.keyLength >> 4;
   3.438 -   store.privKey.key = tpm_malloc(store.privKey.keyLength);
   3.439 -   wrappedKey->encDataSize = parent->key.size >> 3;
   3.440 -   wrappedKey->encData = tpm_malloc(wrappedKey->encDataSize);
   3.441 -@@ -444,9 +460,11 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN
   3.442 -     tpm_free(wrappedKey->encData);
   3.443 -     return TPM_FAIL;
   3.444 -   }
   3.445 --  rsa_export_modulus(&rsa, wrappedKey->pubKey.key, 
   3.446 --    &wrappedKey->pubKey.keyLength);
   3.447 --  rsa_export_prime1(&rsa, store.privKey.key, &store.privKey.keyLength);
   3.448 -+  rsa_export_modulus(&rsa, wrappedKey->pubKey.key,
   3.449 -+		     &key_length);
   3.450 -+  wrappedKey->pubKey.keyLength = (UINT32) key_length;
   3.451 -+  rsa_export_prime1(&rsa, store.privKey.key, &key_length);
   3.452 -+  store.privKey.keyLength = (UINT32) key_length;
   3.453 -   rsa_release_private_key(&rsa);
   3.454 -   /* encrypt private key data */
   3.455 -   if (encrypt_private_key(parent, &store, wrappedKey->encData, 
   3.456 -@@ -560,6 +578,7 @@ TPM_RESULT TPM_LoadKey(TPM_KEY_HANDLE pa
   3.457 - 
   3.458 - int tpm_setup_key_parms(TPM_KEY_DATA *key, TPM_KEY_PARMS *parms)
   3.459 - {
   3.460 -+  size_t key_length;
   3.461 -   parms->algorithmID = TPM_ALG_RSA;
   3.462 -   parms->encScheme = key->encScheme;
   3.463 -   parms->sigScheme = key->sigScheme;
   3.464 -@@ -569,7 +588,8 @@ int tpm_setup_key_parms(TPM_KEY_DATA *ke
   3.465 -   parms->parms.rsa.exponent = tpm_malloc(parms->parms.rsa.exponentSize);
   3.466 -   if (parms->parms.rsa.exponent == NULL) return -1;
   3.467 -   rsa_export_exponent(&key->key, parms->parms.rsa.exponent,
   3.468 --    &parms->parms.rsa.exponentSize);
   3.469 -+                      &key_length);  
   3.470 -+  parms->parms.rsa.exponentSize = (UINT32) key_length;
   3.471 -   parms->parmSize = 12 + parms->parms.rsa.exponentSize;  
   3.472 -   return 0;
   3.473 - }
   3.474 -@@ -580,6 +600,7 @@ TPM_RESULT TPM_GetPubKey(TPM_KEY_HANDLE 
   3.475 -   TPM_RESULT res;
   3.476 -   TPM_KEY_DATA *key;
   3.477 -   TPM_DIGEST digest;
   3.478 -+  size_t key_length;
   3.479 -   info("TPM_GetPubKey()");
   3.480 -   /* get key */
   3.481 -   if (keyHandle == TPM_KH_SRK) return TPM_BAD_PARAMETER;
   3.482 -@@ -607,8 +628,8 @@ TPM_RESULT TPM_GetPubKey(TPM_KEY_HANDLE 
   3.483 -   pubKey->pubKey.keyLength = key->key.size >> 3;
   3.484 -   pubKey->pubKey.key = tpm_malloc(pubKey->pubKey.keyLength);
   3.485 -   if (pubKey->pubKey.key == NULL) return TPM_FAIL;
   3.486 --  rsa_export_modulus(&key->key, pubKey->pubKey.key, 
   3.487 --    &pubKey->pubKey.keyLength);
   3.488 -+  rsa_export_modulus(&key->key, pubKey->pubKey.key, &key_length); 
   3.489 -+  pubKey->pubKey.keyLength = (UINT32) key_length;
   3.490 -   if (tpm_setup_key_parms(key, &pubKey->algorithmParms) != 0) {
   3.491 -     tpm_free(pubKey->pubKey.key);
   3.492 -     return TPM_FAIL;  
   3.493 -diff -uprN tpm_emulator-0.2/tpm_version.h tpm_emulator-0.2-x86_64/tpm_version.h
   3.494 ---- tpm_emulator-0.2/tpm_version.h	2005-08-15 00:58:57.000000000 -0700
   3.495 -+++ tpm_emulator-0.2-x86_64/tpm_version.h	1969-12-31 16:00:00.000000000 -0800
   3.496 -@@ -1,6 +0,0 @@
   3.497 --#ifndef _TPM_VERSION_H_
   3.498 --#define _TPM_VERSION_H_
   3.499 --#define VERSION_MAJOR 0
   3.500 --#define VERSION_MINOR 2
   3.501 --#define VERSION_BUILD 1123950310
   3.502 --#endif /* _TPM_VERSION_H_ */
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/tools/vtpm/tpm_emulator-0.3-x86_64.patch	Wed May 31 07:45:20 2006 +0100
     4.3 @@ -0,0 +1,484 @@
     4.4 +diff -uprN tpm_emulator-0.3/crypto/gmp_kernel_wrapper.c tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c
     4.5 +--- tpm_emulator-0.3/crypto/gmp_kernel_wrapper.c	2006-01-10 04:21:45.000000000 -0800
     4.6 ++++ tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c	2006-05-26 11:26:02.000000000 -0700
     4.7 +@@ -79,7 +79,7 @@ void __attribute__ ((regparm(0))) *kerne
     4.8 + {
     4.9 +   void *ret  = (void*)kmalloc(size, GFP_KERNEL);
    4.10 +   if (!ret) panic(KERN_CRIT TPM_MODULE_NAME 
    4.11 +-    "GMP: cannot allocate memory (size=%u)\n", size);
    4.12 ++    "GMP: cannot allocate memory (size=%Zu)\n", size);
    4.13 +   return ret;
    4.14 + }
    4.15 + 
    4.16 +@@ -88,7 +88,7 @@ void __attribute__ ((regparm(0))) *kerne
    4.17 + {
    4.18 +   void *ret = (void*)kmalloc(new_size, GFP_KERNEL);
    4.19 +   if (!ret) panic(KERN_CRIT TPM_MODULE_NAME "GMP: Cannot reallocate memory "
    4.20 +-    "(old_size=%u new_size=%u)\n", old_size, new_size);
    4.21 ++    "(old_size=%Zu new_size=%Zu)\n", old_size, new_size);
    4.22 +   memcpy(ret, oldptr, old_size);
    4.23 +   kfree(oldptr);
    4.24 +   return ret;
    4.25 +diff -uprN tpm_emulator-0.3/linux_module.c tpm_emulator-0.3-x86_64/linux_module.c
    4.26 +--- tpm_emulator-0.3/linux_module.c	2006-01-10 04:21:45.000000000 -0800
    4.27 ++++ tpm_emulator-0.3-x86_64/linux_module.c	2006-05-26 11:26:02.000000000 -0700
    4.28 +@@ -72,7 +72,7 @@ static int tpm_release(struct inode *ino
    4.29 + 
    4.30 + static ssize_t tpm_read(struct file *file, char *buf, size_t count, loff_t *ppos)
    4.31 + {
    4.32 +-  debug("%s(%d)", __FUNCTION__, count);
    4.33 ++  debug("%s(%Zu)", __FUNCTION__, count);
    4.34 +   down(&tpm_mutex);
    4.35 +   if (tpm_response.data != NULL) {
    4.36 +     count = min(count, (size_t)tpm_response.size - (size_t)*ppos);
    4.37 +@@ -91,7 +91,7 @@ static ssize_t tpm_read(struct file *fil
    4.38 + 
    4.39 + static ssize_t tpm_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
    4.40 + {
    4.41 +-  debug("%s(%d)", __FUNCTION__, count);
    4.42 ++  debug("%s(%Zu)", __FUNCTION__, count);
    4.43 +   down(&tpm_mutex);
    4.44 +   *ppos = 0;
    4.45 +   if (tpm_response.data != NULL) kfree(tpm_response.data);
    4.46 +diff -uprN tpm_emulator-0.3/linux_module.h tpm_emulator-0.3-x86_64/linux_module.h
    4.47 +--- tpm_emulator-0.3/linux_module.h	2006-01-10 04:21:45.000000000 -0800
    4.48 ++++ tpm_emulator-0.3-x86_64/linux_module.h	2006-05-26 11:26:02.000000000 -0700
    4.49 +@@ -28,8 +28,10 @@
    4.50 + 
    4.51 + /* module settings */
    4.52 + 
    4.53 ++#ifndef STR
    4.54 + #define STR(s) __STR__(s)
    4.55 + #define __STR__(s) #s
    4.56 ++#endif
    4.57 + #include "tpm_version.h"
    4.58 + 
    4.59 + #define TPM_DEVICE_MINOR	224
    4.60 +diff -uprN tpm_emulator-0.3/Makefile tpm_emulator-0.3-x86_64/Makefile
    4.61 +--- tpm_emulator-0.3/Makefile	2006-01-10 04:21:45.000000000 -0800
    4.62 ++++ tpm_emulator-0.3-x86_64/Makefile	2006-05-26 11:26:02.000000000 -0700
    4.63 +@@ -7,6 +7,7 @@
    4.64 + KERNEL_RELEASE := $(shell uname -r)
    4.65 + KERNEL_BUILD   := /lib/modules/$(KERNEL_RELEASE)/build
    4.66 + MOD_SUBDIR     := misc
    4.67 ++COMPILE_ARCH    ?= $(shell uname -m | sed -e s/i.86/x86_32/)
    4.68 + 
    4.69 + # module settings
    4.70 + MODULE_NAME    := tpm_emulator
    4.71 +@@ -17,8 +18,14 @@ VERSION_BUILD  := $(shell date +"%s")
    4.72 + # enable/disable DEBUG messages
    4.73 + EXTRA_CFLAGS   += -Wall -DDEBUG -g  
    4.74 + 
    4.75 ++ifeq ($(COMPILE_ARCH),x86_64)
    4.76 ++LIBDIR = lib64
    4.77 ++else
    4.78 ++LIBDIR = lib
    4.79 ++endif
    4.80 ++
    4.81 + # GNU MP configuration
    4.82 +-GMP_LIB        := /usr/lib/libgmp.a
    4.83 ++GMP_LIB        := /usr/$(LIBDIR)/libgmp.a
    4.84 + GMP_HEADER     := /usr/include/gmp.h
    4.85 + 
    4.86 + # sources and objects
    4.87 +diff -uprN tpm_emulator-0.3/README tpm_emulator-0.3-x86_64/README
    4.88 +--- tpm_emulator-0.3/README	2006-01-10 04:21:45.000000000 -0800
    4.89 ++++ tpm_emulator-0.3-x86_64/README	2006-05-26 11:26:02.000000000 -0700
    4.90 +@@ -43,6 +43,12 @@ Example:
    4.91 + GMP_LIB        := /usr/lib/libgmp.a
    4.92 + GMP_HEADER     := /usr/include/gmp.h
    4.93 + 
    4.94 ++GNU MP Library on 64 bit Systems
    4.95 ++--------------------------------------------------------------------------
    4.96 ++Some 64-bit kernels have problems with importing the user-space gmp 
    4.97 ++library (/usr/lib*/libgmp.a) into kernel space.  These kernels will require
    4.98 ++that the gmp library be recompiled for kernel space with -mcmodel=kernel.
    4.99 ++
   4.100 + Installation
   4.101 + --------------------------------------------------------------------------
   4.102 + The compilation and installation process uses the build environment for 
   4.103 +diff -uprN tpm_emulator-0.3/tpm/tpm_credentials.c tpm_emulator-0.3-x86_64/tpm/tpm_credentials.c
   4.104 +--- tpm_emulator-0.3/tpm/tpm_credentials.c	2006-01-10 04:21:45.000000000 -0800
   4.105 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_credentials.c	2006-05-26 11:26:02.000000000 -0700
   4.106 +@@ -47,16 +47,16 @@ int tpm_compute_pubkey_checksum(TPM_NONC
   4.107 + 
   4.108 + TPM_RESULT tpm_get_pubek(TPM_PUBKEY *pubEndorsementKey)
   4.109 + {
   4.110 +-  UINT32 key_length;
   4.111 ++  size_t key_length;
   4.112 +   if (!tpmData.permanent.data.endorsementKey.size) return TPM_NO_ENDORSEMENT;
   4.113 +   /* setup TPM_PUBKEY structure */
   4.114 +-  key_length = tpmData.permanent.data.endorsementKey.size;
   4.115 +-  pubEndorsementKey->pubKey.keyLength = key_length >> 3;
   4.116 ++  pubEndorsementKey->pubKey.keyLength = tpmData.permanent.data.endorsementKey.size >> 3;
   4.117 +   pubEndorsementKey->pubKey.key = tpm_malloc(pubEndorsementKey->pubKey.keyLength);
   4.118 +   if (pubEndorsementKey->pubKey.key == NULL) return TPM_FAIL;
   4.119 +   rsa_export_modulus(&tpmData.permanent.data.endorsementKey,
   4.120 +-    pubEndorsementKey->pubKey.key,
   4.121 +-    &pubEndorsementKey->pubKey.keyLength);
   4.122 ++		     pubEndorsementKey->pubKey.key,
   4.123 ++		     &key_length);
   4.124 ++  pubEndorsementKey->pubKey.keyLength = key_length;
   4.125 +   pubEndorsementKey->algorithmParms.algorithmID = TPM_ALG_RSA;
   4.126 +   pubEndorsementKey->algorithmParms.encScheme = TPM_ES_RSAESOAEP_SHA1_MGF1;
   4.127 +   pubEndorsementKey->algorithmParms.sigScheme = TPM_SS_NONE;
   4.128 +@@ -175,6 +175,7 @@ TPM_RESULT TPM_OwnerReadInternalPub(TPM_
   4.129 + {
   4.130 +   TPM_RESULT res;
   4.131 +   TPM_KEY_DATA *srk = &tpmData.permanent.data.srk;
   4.132 ++  size_t key_length;
   4.133 +   info("TPM_OwnerReadInternalPub()");
   4.134 +   /* verify authorization */
   4.135 +   res = tpm_verify_auth(auth1, tpmData.permanent.data.ownerAuth, TPM_KH_OWNER);
   4.136 +@@ -186,7 +187,8 @@ TPM_RESULT TPM_OwnerReadInternalPub(TPM_
   4.137 +     publicPortion->pubKey.key = tpm_malloc(publicPortion->pubKey.keyLength);
   4.138 +     if (publicPortion->pubKey.key == NULL) return TPM_FAIL;
   4.139 +     rsa_export_modulus(&srk->key, publicPortion->pubKey.key, 
   4.140 +-      &publicPortion->pubKey.keyLength);
   4.141 ++      &key_length);
   4.142 ++    publicPortion->pubKey.keyLength = key_length;
   4.143 +     publicPortion->algorithmParms.algorithmID = TPM_ALG_RSA;
   4.144 +     publicPortion->algorithmParms.encScheme = srk->encScheme;
   4.145 +     publicPortion->algorithmParms.sigScheme = srk->sigScheme;
   4.146 +diff -uprN tpm_emulator-0.3/tpm/tpm_crypto.c tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c
   4.147 +--- tpm_emulator-0.3/tpm/tpm_crypto.c	2006-01-10 04:21:45.000000000 -0800
   4.148 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c	2006-05-26 11:26:02.000000000 -0700
   4.149 +@@ -182,7 +182,8 @@ TPM_RESULT TPM_CertifyKey(TPM_KEY_HANDLE
   4.150 +   TPM_KEY_DATA *cert, *key;
   4.151 +   sha1_ctx_t sha1_ctx;
   4.152 +   BYTE *buf, *p;
   4.153 +-  UINT32 length;
   4.154 ++  UINT32 length32;
   4.155 ++  size_t length;
   4.156 +   info("TPM_CertifyKey()");
   4.157 +   /* get keys */
   4.158 +   cert = tpm_get_key(certHandle);
   4.159 +@@ -264,14 +265,15 @@ TPM_RESULT TPM_CertifyKey(TPM_KEY_HANDLE
   4.160 +   /* compute the digest of the CERTIFY_INFO[2] structure and sign it */
   4.161 +   length = sizeof_TPM_CERTIFY_INFO((*certifyInfo));
   4.162 +   p = buf = tpm_malloc(length);
   4.163 ++  length32=(UINT32) length;
   4.164 +   if (buf == NULL
   4.165 +-      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length, certifyInfo)) {
   4.166 ++      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length32, certifyInfo)) {
   4.167 +     free_TPM_KEY_PARMS(certifyInfo->algorithmParms);
   4.168 +     return TPM_FAIL;
   4.169 +   }
   4.170 +   length = sizeof_TPM_CERTIFY_INFO((*certifyInfo));
   4.171 +   sha1_init(&sha1_ctx);
   4.172 +-  sha1_update(&sha1_ctx, buf, length);
   4.173 ++  sha1_update(&sha1_ctx, buf, (size_t) length);
   4.174 +   sha1_final(&sha1_ctx, buf);
   4.175 +   res = tpm_sign(cert, auth1, FALSE, buf, SHA1_DIGEST_LENGTH, outData, outDataSize);
   4.176 +   tpm_free(buf);
   4.177 +@@ -292,7 +294,8 @@ TPM_RESULT TPM_CertifyKey2(TPM_KEY_HANDL
   4.178 +   TPM_KEY_DATA *cert, *key;
   4.179 +   sha1_ctx_t sha1_ctx;
   4.180 +   BYTE *buf, *p;
   4.181 +-  UINT32 length;
   4.182 ++  size_t length;
   4.183 ++  UINT32 length32;
   4.184 +   info("TPM_CertifyKey2()");
   4.185 +   /* get keys */
   4.186 +   cert = tpm_get_key(certHandle);
   4.187 +@@ -362,8 +365,9 @@ TPM_RESULT TPM_CertifyKey2(TPM_KEY_HANDL
   4.188 +   /* compute the digest of the CERTIFY_INFO[2] structure and sign it */
   4.189 +   length = sizeof_TPM_CERTIFY_INFO((*certifyInfo));
   4.190 +   p = buf = tpm_malloc(length);
   4.191 ++  length32 = (UINT32) length;
   4.192 +   if (buf == NULL
   4.193 +-      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length, certifyInfo)) {
   4.194 ++      || tpm_marshal_TPM_CERTIFY_INFO(&p, &length32, certifyInfo)) {
   4.195 +     free_TPM_KEY_PARMS(certifyInfo->algorithmParms);
   4.196 +     return TPM_FAIL;
   4.197 +   }
   4.198 +diff -uprN tpm_emulator-0.3/tpm/tpm_data.c tpm_emulator-0.3-x86_64/tpm/tpm_data.c
   4.199 +--- tpm_emulator-0.3/tpm/tpm_data.c	2006-01-10 04:21:45.000000000 -0800
   4.200 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_data.c	2006-05-26 11:26:02.000000000 -0700
   4.201 +@@ -214,7 +214,7 @@ static int read_from_file(uint8_t **data
   4.202 + int tpm_store_permanent_data(void)
   4.203 + {
   4.204 +   uint8_t *buf, *ptr;
   4.205 +-  size_t buf_length, len;
   4.206 ++  UINT32 buf_length, len;
   4.207 + 
   4.208 +   /* marshal data */
   4.209 +   buf_length = len = sizeof_TPM_STCLEAR_FLAGS(tpmData.stclear.flags)
   4.210 +@@ -242,13 +242,14 @@ int tpm_store_permanent_data(void)
   4.211 + int tpm_restore_permanent_data(void)
   4.212 + {
   4.213 +   uint8_t *buf, *ptr;
   4.214 +-  size_t buf_length, len;
   4.215 ++  size_t buf_length;
   4.216 ++  UINT32 len;
   4.217 +   TPM_VERSION ver;
   4.218 + 
   4.219 +   /* read data */
   4.220 +   if (read_from_file(&buf, &buf_length)) return -1;
   4.221 +   ptr = buf;
   4.222 +-  len = buf_length;
   4.223 ++  len = (uint32_t) buf_length;
   4.224 +   /* unmarshal data */
   4.225 +   if (tpm_unmarshal_TPM_VERSION(&ptr, &len, &ver)
   4.226 +       || memcmp(&ver, &tpmData.permanent.data.version, sizeof(TPM_VERSION))
   4.227 +diff -uprN tpm_emulator-0.3/tpm/tpm_marshalling.c tpm_emulator-0.3-x86_64/tpm/tpm_marshalling.c
   4.228 +--- tpm_emulator-0.3/tpm/tpm_marshalling.c	2006-01-10 04:21:45.000000000 -0800
   4.229 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_marshalling.c	2006-05-26 11:26:02.000000000 -0700
   4.230 +@@ -1212,7 +1212,7 @@ int tpm_unmarshal_TPM_STANY_FLAGS(BYTE *
   4.231 + 
   4.232 + int tpm_marshal_RSA(BYTE **ptr, UINT32 *length, rsa_private_key_t *v)
   4.233 + {
   4.234 +-  UINT32 m_len, e_len, q_len;
   4.235 ++  size_t m_len, e_len, q_len;
   4.236 +   if (*length < sizeof_RSA((*v))) return -1;
   4.237 +   if (v->size > 0) {
   4.238 +     rsa_export_modulus(v, &(*ptr)[6], &m_len);
   4.239 +diff -uprN tpm_emulator-0.3/tpm/tpm_owner.c tpm_emulator-0.3-x86_64/tpm/tpm_owner.c
   4.240 +--- tpm_emulator-0.3/tpm/tpm_owner.c	2006-01-10 04:21:45.000000000 -0800
   4.241 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_owner.c	2006-05-26 11:26:02.000000000 -0700
   4.242 +@@ -108,7 +108,7 @@ TPM_RESULT TPM_TakeOwnership(TPM_PROTOCO
   4.243 +   TPM_RESULT res;
   4.244 +   rsa_private_key_t *ek = &tpmData.permanent.data.endorsementKey;
   4.245 +   TPM_KEY_DATA *srk = &tpmData.permanent.data.srk;
   4.246 +-  UINT32 buf_size = ek->size >> 3;
   4.247 ++  size_t buf_size = ek->size >> 3, key_length; 
   4.248 +   BYTE buf[buf_size];
   4.249 + 
   4.250 +   info("TPM_TakeOwnership()");
   4.251 +@@ -172,7 +172,8 @@ TPM_RESULT TPM_TakeOwnership(TPM_PROTOCO
   4.252 +     return TPM_FAIL;
   4.253 +   }
   4.254 +   rsa_export_modulus(&srk->key, srkPub->pubKey.key,
   4.255 +-    &srkPub->pubKey.keyLength);
   4.256 ++		     &key_length);
   4.257 ++  srkPub->pubKey.keyLength = (UINT32) key_length;
   4.258 +   /* setup tpmProof and set state to owned */
   4.259 +   tpm_get_random_bytes(tpmData.permanent.data.tpmProof.nonce, 
   4.260 +     sizeof(tpmData.permanent.data.tpmProof.nonce));
   4.261 +diff -uprN tpm_emulator-0.3/tpm/tpm_storage.c tpm_emulator-0.3-x86_64/tpm/tpm_storage.c
   4.262 +--- tpm_emulator-0.3/tpm/tpm_storage.c	2006-01-10 04:21:45.000000000 -0800
   4.263 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_storage.c	2006-05-26 14:33:18.000000000 -0700
   4.264 +@@ -58,6 +58,7 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke
   4.265 +                         BYTE *enc, UINT32 *enc_size)
   4.266 + {
   4.267 +   UINT32 len;
   4.268 ++  size_t enc_size32 = *enc_size;
   4.269 +   BYTE *buf, *ptr;
   4.270 +   rsa_public_key_t pub_key;
   4.271 +   int scheme;
   4.272 +@@ -72,7 +73,7 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke
   4.273 +   if (buf == NULL
   4.274 +       || tpm_marshal_TPM_SEALED_DATA(&ptr, &len, seal)
   4.275 +       || rsa_encrypt(&pub_key, scheme, buf, sizeof_TPM_SEALED_DATA((*seal)),
   4.276 +-                     enc, enc_size)) {
   4.277 ++                     enc, &enc_size32)) {
   4.278 +     tpm_free(buf);
   4.279 +     rsa_release_public_key(&pub_key);
   4.280 +     return -1;
   4.281 +@@ -85,7 +86,8 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke
   4.282 + int decrypt_sealed_data(TPM_KEY_DATA *key, BYTE *enc, UINT32 enc_size,
   4.283 +                         TPM_SEALED_DATA *seal, BYTE **buf) 
   4.284 + {
   4.285 +-  UINT32 len;
   4.286 ++  size_t len;
   4.287 ++  UINT32 len32;
   4.288 +   BYTE *ptr;
   4.289 +   int scheme;
   4.290 +   switch (key->encScheme) {
   4.291 +@@ -96,8 +98,12 @@ int decrypt_sealed_data(TPM_KEY_DATA *ke
   4.292 +   len = enc_size;
   4.293 +   *buf = ptr = tpm_malloc(len);
   4.294 +   if (*buf == NULL
   4.295 +-      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len)
   4.296 +-      || tpm_unmarshal_TPM_SEALED_DATA(&ptr, &len, seal)) {
   4.297 ++      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len) ){
   4.298 ++    tpm_free(*buf);
   4.299 ++    return -1;
   4.300 ++  }
   4.301 ++  len32 = len;
   4.302 ++  if (tpm_unmarshal_TPM_SEALED_DATA(&ptr, &len32, seal)) {
   4.303 +     tpm_free(*buf);
   4.304 +     return -1;
   4.305 +   }
   4.306 +@@ -237,11 +243,12 @@ TPM_RESULT TPM_Unseal(TPM_KEY_HANDLE par
   4.307 + 
   4.308 + TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE keyHandle, UINT32 inDataSize,
   4.309 +                       BYTE *inData, TPM_AUTH *auth1, 
   4.310 +-                      UINT32 *outDataSize, BYTE **outData)
   4.311 ++                      UINT32 *outDataSize32, BYTE **outData)
   4.312 + {
   4.313 +   TPM_RESULT res;
   4.314 +   TPM_KEY_DATA *key;
   4.315 +   int scheme;
   4.316 ++  size_t outDataSize;
   4.317 +   info("TPM_UnBind()");
   4.318 +   /* get key */
   4.319 +   key = tpm_get_key(keyHandle);
   4.320 +@@ -258,8 +265,8 @@ TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE key
   4.321 +   /* the size of the input data muss be greater than zero */
   4.322 +   if (inDataSize == 0) return TPM_BAD_PARAMETER;
   4.323 +   /* decrypt data */
   4.324 +-  *outDataSize = inDataSize;
   4.325 +-  *outData = tpm_malloc(*outDataSize);
   4.326 ++  outDataSize = inDataSize;
   4.327 ++  *outData = tpm_malloc(outDataSize);
   4.328 +   if (*outData == NULL) return TPM_FAIL;
   4.329 +   switch (key->encScheme) {
   4.330 +     case TPM_ES_RSAESOAEP_SHA1_MGF1: scheme = RSA_ES_OAEP_SHA1; break;
   4.331 +@@ -267,20 +274,21 @@ TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE key
   4.332 +     default: tpm_free(*outData); return TPM_DECRYPT_ERROR;
   4.333 +   }
   4.334 +   if (rsa_decrypt(&key->key, scheme, inData, inDataSize, 
   4.335 +-      *outData, outDataSize)) {
   4.336 ++      *outData, &outDataSize)) {
   4.337 +     tpm_free(*outData);
   4.338 +     return TPM_DECRYPT_ERROR;
   4.339 +   }
   4.340 +   /* verify data if it is of type TPM_BOUND_DATA */
   4.341 +   if (key->encScheme == TPM_ES_RSAESOAEP_SHA1_MGF1 
   4.342 +       || key->keyUsage != TPM_KEY_LEGACY) {
   4.343 +-    if (*outDataSize < 5 || memcmp(*outData, "\x01\x01\00\x00\x02", 5) != 0) {
   4.344 ++    if (outDataSize < 5 || memcmp(*outData, "\x01\x01\00\x00\x02", 5) != 0) {
   4.345 +       tpm_free(*outData);
   4.346 +       return TPM_DECRYPT_ERROR;
   4.347 +     }
   4.348 +-    *outDataSize -= 5;
   4.349 +-    memmove(*outData, &(*outData)[5], *outDataSize);
   4.350 ++    outDataSize -= 5;
   4.351 ++    memmove(*outData, &(*outData)[5], outDataSize);
   4.352 +   }
   4.353 ++  *outDataSize32 = (UINT32) outDataSize;
   4.354 +   return TPM_SUCCESS;
   4.355 + }
   4.356 + 
   4.357 +@@ -311,12 +319,13 @@ static int verify_key_digest(TPM_KEY *ke
   4.358 + }
   4.359 + 
   4.360 + int encrypt_private_key(TPM_KEY_DATA *key, TPM_STORE_ASYMKEY *store,
   4.361 +-                        BYTE *enc, UINT32 *enc_size)
   4.362 ++                        BYTE *enc, UINT32 *enc_size32)
   4.363 + {
   4.364 +   UINT32 len;
   4.365 +   BYTE *buf, *ptr;
   4.366 +   rsa_public_key_t pub_key;
   4.367 +   int scheme;
   4.368 ++  size_t enc_size;
   4.369 +   switch (key->encScheme) {
   4.370 +     case TPM_ES_RSAESOAEP_SHA1_MGF1: scheme = RSA_ES_OAEP_SHA1; break;
   4.371 +     case TPM_ES_RSAESPKCSv15: scheme = RSA_ES_PKCSV15; break;
   4.372 +@@ -328,11 +337,12 @@ int encrypt_private_key(TPM_KEY_DATA *ke
   4.373 +   if (buf == NULL
   4.374 +       || tpm_marshal_TPM_STORE_ASYMKEY(&ptr, &len, store)
   4.375 +       || rsa_encrypt(&pub_key, scheme, buf, sizeof_TPM_STORE_ASYMKEY((*store)),
   4.376 +-                     enc, enc_size)) {
   4.377 ++                     enc, &enc_size)) {
   4.378 +     tpm_free(buf);
   4.379 +     rsa_release_public_key(&pub_key);
   4.380 +     return -1;
   4.381 +   }
   4.382 ++  *enc_size32 = (UINT32) enc_size;
   4.383 +   tpm_free(buf);
   4.384 +   rsa_release_public_key(&pub_key);
   4.385 +   return 0;
   4.386 +@@ -341,7 +351,8 @@ int encrypt_private_key(TPM_KEY_DATA *ke
   4.387 + int decrypt_private_key(TPM_KEY_DATA *key, BYTE *enc, UINT32 enc_size, 
   4.388 +                         TPM_STORE_ASYMKEY *store, BYTE **buf) 
   4.389 + {
   4.390 +-  UINT32 len;
   4.391 ++  UINT32 len32;
   4.392 ++  size_t len;
   4.393 +   BYTE *ptr;
   4.394 +   int scheme;
   4.395 +   switch (key->encScheme) {
   4.396 +@@ -352,8 +363,12 @@ int decrypt_private_key(TPM_KEY_DATA *ke
   4.397 +   len = enc_size;
   4.398 +   *buf = ptr = tpm_malloc(len);
   4.399 +   if (*buf == NULL
   4.400 +-      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len)
   4.401 +-      || tpm_unmarshal_TPM_STORE_ASYMKEY(&ptr, &len, store)) {
   4.402 ++      || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len) ) {
   4.403 ++    tpm_free(*buf);
   4.404 ++    return -1;
   4.405 ++  }
   4.406 ++  len32 = (UINT32) len;
   4.407 ++  if (tpm_unmarshal_TPM_STORE_ASYMKEY(&ptr, &len32, store)) {  
   4.408 +     tpm_free(*buf);
   4.409 +     return -1;
   4.410 +   }
   4.411 +@@ -371,7 +386,7 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN
   4.412 +   TPM_SESSION_DATA *session;
   4.413 +   TPM_STORE_ASYMKEY store;
   4.414 +   rsa_private_key_t rsa;
   4.415 +-  UINT32 key_length;
   4.416 ++  size_t key_length;
   4.417 + 
   4.418 +   info("TPM_CreateWrapKey()");
   4.419 +   /* get parent key */
   4.420 +@@ -428,11 +443,11 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN
   4.421 +   }
   4.422 +   if (compute_key_digest(wrappedKey, &store.pubDataDigest)) return TPM_FAIL;
   4.423 +   /* generate key and store it */
   4.424 +-  key_length = keyInfo->algorithmParms.parms.rsa.keyLength;
   4.425 +-  if (rsa_generate_key(&rsa, key_length)) return TPM_FAIL;
   4.426 +-  wrappedKey->pubKey.keyLength = key_length >> 3;
   4.427 ++  if (rsa_generate_key(&rsa, keyInfo->algorithmParms.parms.rsa.keyLength)) 
   4.428 ++    return TPM_FAIL;
   4.429 ++  wrappedKey->pubKey.keyLength = keyInfo->algorithmParms.parms.rsa.keyLength >> 3;
   4.430 +   wrappedKey->pubKey.key = tpm_malloc(wrappedKey->pubKey.keyLength);
   4.431 +-  store.privKey.keyLength = key_length >> 4;
   4.432 ++  store.privKey.keyLength = keyInfo->algorithmParms.parms.rsa.keyLength >> 4;
   4.433 +   store.privKey.key = tpm_malloc(store.privKey.keyLength);
   4.434 +   wrappedKey->encDataSize = parent->key.size >> 3;
   4.435 +   wrappedKey->encData = tpm_malloc(wrappedKey->encDataSize);
   4.436 +@@ -444,9 +459,11 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN
   4.437 +     tpm_free(wrappedKey->encData);
   4.438 +     return TPM_FAIL;
   4.439 +   }
   4.440 +-  rsa_export_modulus(&rsa, wrappedKey->pubKey.key, 
   4.441 +-    &wrappedKey->pubKey.keyLength);
   4.442 +-  rsa_export_prime1(&rsa, store.privKey.key, &store.privKey.keyLength);
   4.443 ++  rsa_export_modulus(&rsa, wrappedKey->pubKey.key,
   4.444 ++		     &key_length);
   4.445 ++  wrappedKey->pubKey.keyLength = (UINT32) key_length;
   4.446 ++  rsa_export_prime1(&rsa, store.privKey.key, &key_length);
   4.447 ++  store.privKey.keyLength = (UINT32) key_length;
   4.448 +   rsa_release_private_key(&rsa);
   4.449 +   /* encrypt private key data */
   4.450 +   if (encrypt_private_key(parent, &store, wrappedKey->encData, 
   4.451 +@@ -567,6 +584,7 @@ TPM_RESULT TPM_LoadKey2(TPM_KEY_HANDLE p
   4.452 + 
   4.453 + int tpm_setup_key_parms(TPM_KEY_DATA *key, TPM_KEY_PARMS *parms)
   4.454 + {
   4.455 ++  size_t key_length;
   4.456 +   parms->algorithmID = TPM_ALG_RSA;
   4.457 +   parms->encScheme = key->encScheme;
   4.458 +   parms->sigScheme = key->sigScheme;
   4.459 +@@ -576,7 +594,8 @@ int tpm_setup_key_parms(TPM_KEY_DATA *ke
   4.460 +   parms->parms.rsa.exponent = tpm_malloc(parms->parms.rsa.exponentSize);
   4.461 +   if (parms->parms.rsa.exponent == NULL) return -1;
   4.462 +   rsa_export_exponent(&key->key, parms->parms.rsa.exponent,
   4.463 +-    &parms->parms.rsa.exponentSize);
   4.464 ++    &key_length);
   4.465 ++  parms->parms.rsa.exponentSize = (UINT32) key_length;
   4.466 +   parms->parmSize = 12 + parms->parms.rsa.exponentSize;
   4.467 +   return 0;
   4.468 + }
   4.469 +@@ -587,6 +606,7 @@ TPM_RESULT TPM_GetPubKey(TPM_KEY_HANDLE 
   4.470 +   TPM_RESULT res;
   4.471 +   TPM_KEY_DATA *key;
   4.472 +   TPM_DIGEST digest;
   4.473 ++  size_t key_length;
   4.474 +   info("TPM_GetPubKey()");
   4.475 +   /* get key */
   4.476 +   if (keyHandle == TPM_KH_SRK) return TPM_BAD_PARAMETER;
   4.477 +@@ -614,8 +634,8 @@ TPM_RESULT TPM_GetPubKey(TPM_KEY_HANDLE 
   4.478 +   pubKey->pubKey.keyLength = key->key.size >> 3;
   4.479 +   pubKey->pubKey.key = tpm_malloc(pubKey->pubKey.keyLength);
   4.480 +   if (pubKey->pubKey.key == NULL) return TPM_FAIL;
   4.481 +-  rsa_export_modulus(&key->key, pubKey->pubKey.key, 
   4.482 +-    &pubKey->pubKey.keyLength);
   4.483 ++  rsa_export_modulus(&key->key, pubKey->pubKey.key, &key_length); 
   4.484 ++  pubKey->pubKey.keyLength = (UINT32) key_length;
   4.485 +   if (tpm_setup_key_parms(key, &pubKey->algorithmParms) != 0) {
   4.486 +     tpm_free(pubKey->pubKey.key);
   4.487 +     return TPM_FAIL;
     5.1 --- a/tools/vtpm/vtpm.patch	Wed May 31 07:43:06 2006 +0100
     5.2 +++ b/tools/vtpm/vtpm.patch	Wed May 31 07:45:20 2006 +0100
     5.3 @@ -1,23 +1,24 @@
     5.4 -diff -uprN orig/tpm_emulator-0.2-x86_64/AUTHORS vtpm/AUTHORS
     5.5 ---- orig/tpm_emulator-0.2-x86_64/AUTHORS	2005-08-15 00:58:57.000000000 -0700
     5.6 -+++ vtpm/AUTHORS	2006-05-17 09:31:11.000000000 -0700
     5.7 -@@ -1 +1,2 @@
     5.8 +diff -uprN orig/tpm_emulator-0.3-x86_64/AUTHORS vtpm/AUTHORS
     5.9 +--- orig/tpm_emulator-0.3-x86_64/AUTHORS	2006-01-10 04:21:45.000000000 -0800
    5.10 ++++ vtpm/AUTHORS	2006-05-30 12:23:26.000000000 -0700
    5.11 +@@ -1,2 +1,3 @@
    5.12   Mario Strasser <mast@gmx.net>
    5.13 -+INTEL Corp <>
    5.14 -diff -uprN orig/tpm_emulator-0.2-x86_64/ChangeLog vtpm/ChangeLog
    5.15 ---- orig/tpm_emulator-0.2-x86_64/ChangeLog	2005-08-15 00:58:57.000000000 -0700
    5.16 -+++ vtpm/ChangeLog	2006-05-17 09:31:11.000000000 -0700
    5.17 + Heiko Stamer <stamer@gaos.org> [DAA]
    5.18 ++INTEL Corp <> [VTPM Extensions]
    5.19 +diff -uprN orig/tpm_emulator-0.3-x86_64/ChangeLog vtpm/ChangeLog
    5.20 +--- orig/tpm_emulator-0.3-x86_64/ChangeLog	2006-01-10 04:21:45.000000000 -0800
    5.21 ++++ vtpm/ChangeLog	2006-05-30 12:23:26.000000000 -0700
    5.22  @@ -1,3 +1,7 @@
    5.23  +2005-08-16 Intel Corp
    5.24 -+	Moved module out of kernel to run as a ring 3 app
    5.25 -+	Modified save_to_file and load_from_file to call a xen backend driver to call a VTPM manager
    5.26 ++	* Moved module out of kernel to run as a ring 3 app
    5.27 ++	* Modified save_to_file and load_from_file to call a xen backend driver to call a VTPM manager
    5.28  +
    5.29 - 2005-08-15  Mario Strasser <mast@gmx.net>
    5.30 - 	* all: some typos corrected
    5.31 - 	* tpm_integrity.c: bug in TPM_Extend fixed
    5.32 -diff -uprN orig/tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c vtpm/crypto/gmp_kernel_wrapper.c
    5.33 ---- orig/tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c	2006-05-17 09:34:13.000000000 -0700
    5.34 -+++ vtpm/crypto/gmp_kernel_wrapper.c	2006-05-17 09:31:11.000000000 -0700
    5.35 + 2005-12-24  Mario Strasser <mast@gmx.net>
    5.36 + 	* tpm_transport.c, tpm_marshalling.c, tpm_structures.h:
    5.37 + 		Transport session functionality added
    5.38 +diff -uprN orig/tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c vtpm/crypto/gmp_kernel_wrapper.c
    5.39 +--- orig/tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c	2006-05-30 12:28:02.000000000 -0700
    5.40 ++++ vtpm/crypto/gmp_kernel_wrapper.c	2006-05-30 12:23:26.000000000 -0700
    5.41  @@ -1,5 +1,6 @@
    5.42   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
    5.43    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
    5.44 @@ -77,9 +78,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
    5.45     }
    5.46   }
    5.47   
    5.48 -diff -uprN orig/tpm_emulator-0.2-x86_64/crypto/rsa.c vtpm/crypto/rsa.c
    5.49 ---- orig/tpm_emulator-0.2-x86_64/crypto/rsa.c	2005-08-15 00:58:57.000000000 -0700
    5.50 -+++ vtpm/crypto/rsa.c	2006-05-17 09:31:11.000000000 -0700
    5.51 +diff -uprN orig/tpm_emulator-0.3-x86_64/crypto/rsa.c vtpm/crypto/rsa.c
    5.52 +--- orig/tpm_emulator-0.3-x86_64/crypto/rsa.c	2006-01-10 04:21:45.000000000 -0800
    5.53 ++++ vtpm/crypto/rsa.c	2006-05-30 12:23:26.000000000 -0700
    5.54  @@ -1,5 +1,6 @@
    5.55   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
    5.56    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
    5.57 @@ -87,7 +88,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
    5.58    *
    5.59    * This module is free software; you can redistribute it and/or modify
    5.60    * it under the terms of the GNU General Public License as published
    5.61 -@@ -363,7 +364,7 @@ static int encode_message(int type, uint
    5.62 +@@ -381,7 +382,7 @@ static int encode_message(int type, uint
    5.63         msg[0] = 0x00;
    5.64         get_random_bytes(&msg[1], SHA1_DIGEST_LENGTH);
    5.65         sha1_init(&ctx);
    5.66 @@ -96,7 +97,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
    5.67         sha1_final(&ctx, &msg[1 + SHA1_DIGEST_LENGTH]);
    5.68         memset(&msg[1 + 2 * SHA1_DIGEST_LENGTH], 0x00, 
    5.69           msg_len - data_len - 2 * SHA1_DIGEST_LENGTH - 2);
    5.70 -@@ -411,7 +412,7 @@ static int decode_message(int type, uint
    5.71 +@@ -429,7 +430,7 @@ static int decode_message(int type, uint
    5.72         mask_generation(&msg[1], SHA1_DIGEST_LENGTH,
    5.73           &msg[1 + SHA1_DIGEST_LENGTH], msg_len - SHA1_DIGEST_LENGTH - 1);
    5.74         sha1_init(&ctx);
    5.75 @@ -105,10 +106,10 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
    5.76         sha1_final(&ctx, &msg[1]);
    5.77         if (memcmp(&msg[1], &msg[1 + SHA1_DIGEST_LENGTH], 
    5.78             SHA1_DIGEST_LENGTH) != 0) return -1;
    5.79 -diff -uprN orig/tpm_emulator-0.2-x86_64/linux_module.c vtpm/linux_module.c
    5.80 ---- orig/tpm_emulator-0.2-x86_64/linux_module.c	2006-05-17 09:34:13.000000000 -0700
    5.81 +diff -uprN orig/tpm_emulator-0.3-x86_64/linux_module.c vtpm/linux_module.c
    5.82 +--- orig/tpm_emulator-0.3-x86_64/linux_module.c	2006-05-30 12:28:02.000000000 -0700
    5.83  +++ vtpm/linux_module.c	1969-12-31 16:00:00.000000000 -0800
    5.84 -@@ -1,163 +0,0 @@
    5.85 +@@ -1,194 +0,0 @@
    5.86  -/* Software-Based Trusted Platform Module (TPM) Emulator for Linux 
    5.87  - * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
    5.88  - *
    5.89 @@ -122,7 +123,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
    5.90  - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    5.91  - * GNU General Public License for more details.
    5.92  - *
    5.93 -- * $Id: linux_module.c 19 2005-05-18 08:29:37Z mast $
    5.94 +- * $Id: linux_module.c 76 2006-01-02 22:17:58Z hstamer $
    5.95  - */
    5.96  -
    5.97  -#include <linux/module.h>
    5.98 @@ -140,11 +141,11 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
    5.99  -
   5.100  -/* module startup parameters */
   5.101  -char *startup = "save";
   5.102 --MODULE_PARM(startup, "s");
   5.103 +-module_param(startup, charp, 0444);
   5.104  -MODULE_PARM_DESC(startup, " Sets the startup mode of the TPM. "
   5.105  -  "Possible values are 'clear', 'save' (default) and 'deactivated.");
   5.106 --char *storage_file = "/var/tpm/tpm_emulator-1.2.0.1";
   5.107 --MODULE_PARM(storage_file, "s");
   5.108 +-char *storage_file = "/var/tpm/tpm_emulator-1.2.0.2";
   5.109 +-module_param(storage_file, charp, 0644);
   5.110  -MODULE_PARM_DESC(storage_file, " Sets the persistent-data storage " 
   5.111  -  "file of the TPM.");
   5.112  -
   5.113 @@ -172,6 +173,12 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.114  -{
   5.115  -  debug("%s()", __FUNCTION__);
   5.116  -  clear_bit(STATE_IS_OPEN, (void*)&module_state);
   5.117 +-  down(&tpm_mutex);
   5.118 +-  if (tpm_response.data != NULL) {
   5.119 +-    kfree(tpm_response.data);
   5.120 +-    tpm_response.data = NULL;
   5.121 +-  }
   5.122 +-  up(&tpm_mutex);
   5.123  -  return 0;
   5.124  -}
   5.125  -
   5.126 @@ -183,6 +190,10 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.127  -    count = min(count, (size_t)tpm_response.size - (size_t)*ppos);
   5.128  -    count -= copy_to_user(buf, &tpm_response.data[*ppos], count);
   5.129  -    *ppos += count;
   5.130 +-    if ((size_t)tpm_response.size == (size_t)*ppos) {
   5.131 +-      kfree(tpm_response.data);
   5.132 +-      tpm_response.data = NULL;
   5.133 +-    }
   5.134  -  } else {
   5.135  -    count = 0;
   5.136  -  }
   5.137 @@ -205,9 +216,29 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.138  -  return count;
   5.139  -}
   5.140  -
   5.141 +-#define TPMIOC_CANCEL   _IO('T', 0x00)
   5.142 +-#define TPMIOC_TRANSMIT _IO('T', 0x01)
   5.143 +-
   5.144  -static int tpm_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
   5.145  -{
   5.146 --  debug("%s(%d, %ld)", __FUNCTION__, cmd, arg);
   5.147 +-  debug("%s(%d, %p)", __FUNCTION__, cmd, (char*)arg);
   5.148 +-  if (cmd == TPMIOC_TRANSMIT) {
   5.149 +-    uint32_t count = ntohl(*(uint32_t*)(arg + 2));
   5.150 +-    down(&tpm_mutex);
   5.151 +-    if (tpm_response.data != NULL) kfree(tpm_response.data);
   5.152 +-    if (tpm_handle_command((char*)arg, count, &tpm_response.data,
   5.153 +-                           &tpm_response.size) == 0) {
   5.154 +-      tpm_response.size -= copy_to_user((char*)arg, tpm_response.data,
   5.155 +-                            tpm_response.size);
   5.156 +-      kfree(tpm_response.data);
   5.157 +-      tpm_response.data = NULL;
   5.158 +-    } else {
   5.159 +-      tpm_response.size = 0;
   5.160 +-      tpm_response.data = NULL;
   5.161 +-    }
   5.162 +-    up(&tpm_mutex);
   5.163 +-    return tpm_response.size;
   5.164 +-  }
   5.165  -  return -1;
   5.166  -}
   5.167  -
   5.168 @@ -240,7 +271,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.169  -  /* initialize TPM emulator */
   5.170  -  if (!strcmp(startup, "clear")) {
   5.171  -    tpm_emulator_init(1);
   5.172 --  } else if (!strcmp(startup, "save")) { 
   5.173 +-  } else if (!strcmp(startup, "save")) {
   5.174  -    tpm_emulator_init(2);
   5.175  -  } else if (!strcmp(startup, "deactivated")) {
   5.176  -    tpm_emulator_init(3);
   5.177 @@ -257,6 +288,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.178  -{
   5.179  -  tpm_emulator_shutdown();
   5.180  -  misc_deregister(&tpm_dev);
   5.181 +-  if (tpm_response.data != NULL) kfree(tpm_response.data);
   5.182  -}
   5.183  -
   5.184  -module_init(init_tpm_module);
   5.185 @@ -264,7 +296,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.186  -
   5.187  -uint64_t tpm_get_ticks(void)
   5.188  -{
   5.189 --  static struct timespec old_time = {0, 0}; 
   5.190 +-  static struct timespec old_time = {0, 0};
   5.191  -  struct timespec new_time = current_kernel_time();
   5.192  -  uint64_t ticks = (uint64_t)(old_time.tv_sec - new_time.tv_sec) * 1000000
   5.193  -                   + (old_time.tv_nsec - new_time.tv_nsec) / 1000;
   5.194 @@ -272,9 +304,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.195  -  return (ticks > 0) ? ticks : 1;
   5.196  -}
   5.197  -
   5.198 -diff -uprN orig/tpm_emulator-0.2-x86_64/linux_module.h vtpm/linux_module.h
   5.199 ---- orig/tpm_emulator-0.2-x86_64/linux_module.h	2006-05-17 09:34:13.000000000 -0700
   5.200 -+++ vtpm/linux_module.h	2006-05-17 09:31:11.000000000 -0700
   5.201 +diff -uprN orig/tpm_emulator-0.3-x86_64/linux_module.h vtpm/linux_module.h
   5.202 +--- orig/tpm_emulator-0.3-x86_64/linux_module.h	2006-05-30 12:28:02.000000000 -0700
   5.203 ++++ vtpm/linux_module.h	2006-05-30 12:23:26.000000000 -0700
   5.204  @@ -1,5 +1,6 @@
   5.205   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.206    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
   5.207 @@ -374,15 +406,15 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.208   #define BE16_TO_CPU(x) __be16_to_cpu(x)
   5.209   #define LE16_TO_CPU(x) __le16_to_cpu(x)
   5.210   
   5.211 -diff -uprN orig/tpm_emulator-0.2-x86_64/Makefile vtpm/Makefile
   5.212 ---- orig/tpm_emulator-0.2-x86_64/Makefile	2006-05-17 09:34:13.000000000 -0700
   5.213 -+++ vtpm/Makefile	2006-05-17 09:31:11.000000000 -0700
   5.214 +diff -uprN orig/tpm_emulator-0.3-x86_64/Makefile vtpm/Makefile
   5.215 +--- orig/tpm_emulator-0.3-x86_64/Makefile	2006-05-30 12:28:02.000000000 -0700
   5.216 ++++ vtpm/Makefile	2006-05-30 12:23:26.000000000 -0700
   5.217  @@ -1,22 +1,31 @@
   5.218   # Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.219   # Copyright (C) 2004 Mario Strasser <mast@gmx.net>
   5.220 -+# Copyright (C) 2005 INTEL Corp.
   5.221 ++# Copyright (C) 2006 INTEL Corp.
   5.222   #
   5.223 - # $Id: Makefile 10 2005-04-26 20:59:50Z mast $
   5.224 + # $Id: Makefile 69 2005-12-13 12:55:52Z mast $
   5.225   
   5.226  -# kernel settings
   5.227  -KERNEL_RELEASE := $(shell uname -r)
   5.228 @@ -394,11 +426,11 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.229  -MODULE_NAME    := tpm_emulator
   5.230  +BIN            := vtpmd
   5.231   VERSION_MAJOR  := 0
   5.232 - VERSION_MINOR  := 2
   5.233 + VERSION_MINOR  := 3
   5.234   VERSION_BUILD  := $(shell date +"%s")
   5.235   
   5.236  -# enable/disable DEBUG messages
   5.237 --EXTRA_CFLAGS   += -DDEBUG -g  
   5.238 +-EXTRA_CFLAGS   += -Wall -DDEBUG -g  
   5.239  +# Installation program and options
   5.240  +INSTALL         = install
   5.241  +INSTALL_PROG    = $(INSTALL) -m0755
   5.242 @@ -468,10 +500,10 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.243   
   5.244   $(src)/crypto/libgmp.a:
   5.245   	test -f $(src)/crypto/libgmp.a || ln -s $(GMP_LIB) $(src)/crypto/libgmp.a
   5.246 -diff -uprN orig/tpm_emulator-0.2-x86_64/README vtpm/README
   5.247 ---- orig/tpm_emulator-0.2-x86_64/README	2006-05-17 09:34:13.000000000 -0700
   5.248 -+++ vtpm/README	2006-05-17 09:31:11.000000000 -0700
   5.249 -@@ -13,7 +13,8 @@ $Id: README 8 2005-01-25 21:11:45Z jmoli
   5.250 +diff -uprN orig/tpm_emulator-0.3-x86_64/README vtpm/README
   5.251 +--- orig/tpm_emulator-0.3-x86_64/README	2006-05-30 12:28:02.000000000 -0700
   5.252 ++++ vtpm/README	2006-05-30 12:23:26.000000000 -0700
   5.253 +@@ -13,7 +13,8 @@ $Id: README 78 2006-01-07 10:45:39Z mast
   5.254   Copyright
   5.255   --------------------------------------------------------------------------
   5.256   Copyright (C) 2004 Mario Strasser <mast@gmx.net> and Swiss Federal 
   5.257 @@ -481,9 +513,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.258                 
   5.259   This program is free software; you can redistribute it and/or modify
   5.260   it under the terms of the GNU General Public License as published by
   5.261 -diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_audit.c vtpm/tpm/tpm_audit.c
   5.262 ---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_audit.c	2005-08-15 00:58:57.000000000 -0700
   5.263 -+++ vtpm/tpm/tpm_audit.c	2006-05-17 09:31:11.000000000 -0700
   5.264 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_audit.c vtpm/tpm/tpm_audit.c
   5.265 +--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_audit.c	2006-01-10 04:21:45.000000000 -0800
   5.266 ++++ vtpm/tpm/tpm_audit.c	2006-05-30 12:23:26.000000000 -0700
   5.267  @@ -1,6 +1,7 @@
   5.268   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.269    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
   5.270 @@ -546,9 +578,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.271     return TPM_SUCCESS;
   5.272   }
   5.273  -
   5.274 -diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_authorization.c vtpm/tpm/tpm_authorization.c
   5.275 ---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_authorization.c	2005-08-15 00:58:57.000000000 -0700
   5.276 -+++ vtpm/tpm/tpm_authorization.c	2006-05-17 09:31:11.000000000 -0700
   5.277 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_authorization.c vtpm/tpm/tpm_authorization.c
   5.278 +--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_authorization.c	2006-01-10 04:21:45.000000000 -0800
   5.279 ++++ vtpm/tpm/tpm_authorization.c	2006-05-30 12:23:26.000000000 -0700
   5.280  @@ -1,6 +1,7 @@
   5.281   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.282    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
   5.283 @@ -557,7 +589,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.284    *
   5.285    * This module is free software; you can redistribute it and/or modify
   5.286    * it under the terms of the GNU General Public License as published
   5.287 -@@ -268,7 +269,7 @@ TPM_RESULT tpm_verify_auth(TPM_AUTH *aut
   5.288 +@@ -279,7 +280,7 @@ TPM_RESULT tpm_verify_auth(TPM_AUTH *aut
   5.289   {
   5.290     hmac_ctx_t ctx;
   5.291     TPM_SESSION_DATA *session;
   5.292 @@ -565,16 +597,10 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.293  +  UINT32 auth_handle = CPU_TO_BE32(auth->authHandle);
   5.294     
   5.295     info("tpm_verify_auth(%08x)", auth->authHandle);
   5.296 -   /* get dedicated authorization session */
   5.297 -@@ -316,5 +317,3 @@ void tpm_decrypt_auth_secret(TPM_ENCAUTH
   5.298 -   for (i = 0; i < sizeof(TPM_SECRET); i++)
   5.299 -     plainAuth[i] ^= encAuth[i];
   5.300 - }
   5.301 --
   5.302 --
   5.303 -diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_capability.c vtpm/tpm/tpm_capability.c
   5.304 ---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_capability.c	2005-08-15 00:58:57.000000000 -0700
   5.305 -+++ vtpm/tpm/tpm_capability.c	2006-05-17 09:31:11.000000000 -0700
   5.306 +   /* get dedicated authorization or transport session */
   5.307 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_capability.c vtpm/tpm/tpm_capability.c
   5.308 +--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_capability.c	2006-01-10 04:21:45.000000000 -0800
   5.309 ++++ vtpm/tpm/tpm_capability.c	2006-05-30 12:23:26.000000000 -0700
   5.310  @@ -1,6 +1,7 @@
   5.311   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.312    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
   5.313 @@ -583,7 +609,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.314    *
   5.315    * This module is free software; you can redistribute it and/or modify
   5.316    * it under the terms of the GNU General Public License as published
   5.317 -@@ -398,7 +399,7 @@ TPM_RESULT TPM_GetCapability(TPM_CAPABIL
   5.318 +@@ -406,7 +407,7 @@ TPM_RESULT TPM_GetCapability(TPM_CAPABIL
   5.319   
   5.320       case TPM_CAP_KEY_HANDLE:
   5.321         debug("[TPM_CAP_KEY_HANDLE]");
   5.322 @@ -592,14 +618,14 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.323         return cap_handle(4, (BYTE*)&subCapSize, respSize, resp);
   5.324   
   5.325       case TPM_CAP_CHECK_LOADED:
   5.326 -@@ -472,4 +473,3 @@ TPM_RESULT TPM_GetCapability(TPM_CAPABIL
   5.327 +@@ -480,4 +481,3 @@ TPM_RESULT TPM_GetCapability(TPM_CAPABIL
   5.328         return TPM_BAD_MODE;
   5.329     }
   5.330   }
   5.331  -
   5.332 -diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_cmd_handler.c vtpm/tpm/tpm_cmd_handler.c
   5.333 ---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_cmd_handler.c	2005-08-15 00:58:57.000000000 -0700
   5.334 -+++ vtpm/tpm/tpm_cmd_handler.c	2006-05-17 09:31:11.000000000 -0700
   5.335 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_cmd_handler.c vtpm/tpm/tpm_cmd_handler.c
   5.336 +--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_cmd_handler.c	2006-01-10 04:21:45.000000000 -0800
   5.337 ++++ vtpm/tpm/tpm_cmd_handler.c	2006-05-30 12:23:26.000000000 -0700
   5.338  @@ -1,6 +1,7 @@
   5.339   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.340    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
   5.341 @@ -608,17 +634,17 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.342    *
   5.343    * This module is free software; you can redistribute it and/or modify
   5.344    * it under the terms of the GNU General Public License as published
   5.345 -@@ -26,7 +27,7 @@ static void tpm_compute_in_param_digest(
   5.346 +@@ -73,7 +74,7 @@ void tpm_compute_in_param_digest(TPM_REQ
   5.347   {
   5.348     sha1_ctx_t sha1;
   5.349 -   UINT32 offset;
   5.350 +   UINT32 offset = tpm_get_param_offset(req->ordinal);
   5.351  -  UINT32 ord = cpu_to_be32(req->ordinal);
   5.352  +  UINT32 ord = CPU_TO_BE32(req->ordinal);
   5.353   
   5.354 -   /* skip all key-handles at the beginning */
   5.355 -   switch (req->ordinal) {
   5.356 -@@ -82,8 +83,8 @@ static void tpm_compute_in_param_digest(
   5.357 - static void tpm_compute_out_param_digest(TPM_COMMAND_CODE ordinal, TPM_RESPONSE *rsp)
   5.358 +   /* compute SHA1 hash */
   5.359 +   if (offset <= req->paramSize) {
   5.360 +@@ -89,8 +90,8 @@ void tpm_compute_in_param_digest(TPM_REQ
   5.361 + void tpm_compute_out_param_digest(TPM_COMMAND_CODE ordinal, TPM_RESPONSE *rsp)
   5.362   {
   5.363     sha1_ctx_t sha1;
   5.364  -  UINT32 res = cpu_to_be32(rsp->result);
   5.365 @@ -628,7 +654,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.366   
   5.367     /* compute SHA1 hash */
   5.368     sha1_init(&sha1);
   5.369 -@@ -3081,7 +3082,7 @@ static void tpm_setup_rsp_auth(TPM_COMMA
   5.370 +@@ -3123,7 +3124,7 @@ static void tpm_setup_rsp_auth(TPM_COMMA
   5.371         hmac_update(&hmac, rsp->auth2->digest, sizeof(rsp->auth2->digest));
   5.372   #if 0
   5.373         if (tpm_get_auth(rsp->auth2->authHandle)->type == TPM_ST_OIAP) {
   5.374 @@ -637,7 +663,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.375           hmac_update(&hmac, (BYTE*)&handle, 4);
   5.376         }
   5.377   #endif
   5.378 -@@ -3096,7 +3097,7 @@ static void tpm_setup_rsp_auth(TPM_COMMA
   5.379 +@@ -3138,7 +3139,7 @@ static void tpm_setup_rsp_auth(TPM_COMMA
   5.380         hmac_update(&hmac, rsp->auth1->digest, sizeof(rsp->auth1->digest));
   5.381   #if 0
   5.382         if (tpm_get_auth(rsp->auth1->authHandle)->type == TPM_ST_OIAP) {
   5.383 @@ -646,25 +672,20 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.384           hmac_update(&hmac, (BYTE*)&handle, 4);
   5.385         }
   5.386   #endif
   5.387 -@@ -3179,7 +3180,9 @@ extern const char *tpm_error_to_string(T
   5.388 - static void tpm_execute_command(TPM_REQUEST *req, TPM_RESPONSE *rsp)
   5.389 +@@ -3221,7 +3222,9 @@ extern const char *tpm_error_to_string(T
   5.390 + void tpm_execute_command(TPM_REQUEST *req, TPM_RESPONSE *rsp)
   5.391   {
   5.392     TPM_RESULT res;
   5.393  -  
   5.394  +
   5.395 -+  req->tag = (BYTE) req->tag;  // VIN HACK!!! 
   5.396 ++  req->tag = (BYTE) req->tag;  // FIXME: Why is this here
   5.397  +
   5.398     /* setup authorisation as well as response tag and size */
   5.399     memset(rsp, 0, sizeof(*rsp));
   5.400     switch (req->tag) {
   5.401 -@@ -3878,4 +3881,3 @@ int tpm_handle_command(const uint8_t *in
   5.402 -   tpm_free(rsp.param);
   5.403 -   return 0;
   5.404 - }
   5.405 --
   5.406 -diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c vtpm/tpm/tpm_crypto.c
   5.407 ---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c	2006-05-17 09:34:13.000000000 -0700
   5.408 -+++ vtpm/tpm/tpm_crypto.c	2006-05-17 09:31:11.000000000 -0700
   5.409 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c vtpm/tpm/tpm_crypto.c
   5.410 +--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c	2006-05-30 12:28:02.000000000 -0700
   5.411 ++++ vtpm/tpm/tpm_crypto.c	2006-05-30 12:23:26.000000000 -0700
   5.412  @@ -1,6 +1,7 @@
   5.413   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.414    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
   5.415 @@ -683,13 +704,170 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.416       if (rsa_sign(&key->key, RSA_SSA_PKCS1_SHA1, 
   5.417           buf, areaToSignSize + 30, *sig)) {
   5.418  @@ -383,4 +384,3 @@ TPM_RESULT TPM_CertifyKey2(TPM_KEY_HANDL
   5.419 -   }  
   5.420 +   }
   5.421     return TPM_SUCCESS;
   5.422   }
   5.423  -
   5.424 -diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_data.c vtpm/tpm/tpm_data.c
   5.425 ---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_data.c	2006-05-17 09:34:13.000000000 -0700
   5.426 -+++ vtpm/tpm/tpm_data.c	2006-05-17 09:31:11.000000000 -0700
   5.427 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_daa.c vtpm/tpm/tpm_daa.c
   5.428 +--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_daa.c	2006-01-10 04:21:45.000000000 -0800
   5.429 ++++ vtpm/tpm/tpm_daa.c	2006-05-30 12:23:26.000000000 -0700
   5.430 +@@ -700,14 +700,14 @@ info("tested until here");
   5.431 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.432 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.433 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.434 +-      sha1_update(&sha1, "\x00", 1);
   5.435 ++      sha1_update(&sha1, (BYTE *) "\x00", 1);
   5.436 +       sha1_final(&sha1, scratch);
   5.437 +       sha1_init(&sha1);
   5.438 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
   5.439 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.440 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.441 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.442 +-      sha1_update(&sha1, "\x01", 1);
   5.443 ++      sha1_update(&sha1, (BYTE *) "\x01", 1);
   5.444 +       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
   5.445 +       mpz_init(f), mpz_init(q);
   5.446 +       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
   5.447 +@@ -787,14 +787,14 @@ info("tested until here");
   5.448 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.449 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.450 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.451 +-      sha1_update(&sha1, "\x00", 1);
   5.452 ++      sha1_update(&sha1, (BYTE *) "\x00", 1);
   5.453 +       sha1_final(&sha1, scratch);
   5.454 +       sha1_init(&sha1);
   5.455 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
   5.456 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.457 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.458 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.459 +-      sha1_update(&sha1, "\x01", 1);
   5.460 ++      sha1_update(&sha1, (BYTE *) "\x01", 1);
   5.461 +       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
   5.462 +       mpz_init(f), mpz_init(q);
   5.463 +       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
   5.464 +@@ -1440,14 +1440,14 @@ info("tested until here");
   5.465 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.466 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.467 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.468 +-      sha1_update(&sha1, "\x00", 1);
   5.469 ++      sha1_update(&sha1, (BYTE *) "\x00", 1);
   5.470 +       sha1_final(&sha1, scratch);
   5.471 +       sha1_init(&sha1);
   5.472 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
   5.473 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.474 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.475 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.476 +-      sha1_update(&sha1, "\x01", 1);
   5.477 ++      sha1_update(&sha1, (BYTE *) "\x01", 1);
   5.478 +       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
   5.479 +       mpz_init(f), mpz_init(q);
   5.480 +       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
   5.481 +@@ -1660,14 +1660,14 @@ info("tested until here");
   5.482 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.483 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.484 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.485 +-      sha1_update(&sha1, "\x00", 1);
   5.486 ++      sha1_update(&sha1, (BYTE *) "\x00", 1);
   5.487 +       sha1_final(&sha1, scratch);
   5.488 +       sha1_init(&sha1);
   5.489 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
   5.490 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.491 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.492 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.493 +-      sha1_update(&sha1, "\x01", 1);
   5.494 ++      sha1_update(&sha1, (BYTE *) "\x01", 1);
   5.495 +       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
   5.496 +       mpz_init(f), mpz_init(q);
   5.497 +       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
   5.498 +@@ -1740,14 +1740,14 @@ info("tested until here");
   5.499 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.500 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.501 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.502 +-      sha1_update(&sha1, "\x00", 1);
   5.503 ++      sha1_update(&sha1, (BYTE *) "\x00", 1);
   5.504 +       sha1_final(&sha1, scratch);
   5.505 +       sha1_init(&sha1);
   5.506 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
   5.507 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.508 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.509 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.510 +-      sha1_update(&sha1, "\x01", 1);
   5.511 ++      sha1_update(&sha1, (BYTE *) "\x01", 1);
   5.512 +       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
   5.513 +       mpz_init(f), mpz_init(q);
   5.514 +       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
   5.515 +@@ -2828,14 +2828,14 @@ TPM_RESULT TPM_DAA_Sign(TPM_HANDLE handl
   5.516 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.517 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.518 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.519 +-      sha1_update(&sha1, "\x00", 1);
   5.520 ++      sha1_update(&sha1, (BYTE *) "\x00", 1);
   5.521 +       sha1_final(&sha1, scratch);
   5.522 +       sha1_init(&sha1);
   5.523 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
   5.524 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.525 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.526 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.527 +-      sha1_update(&sha1, "\x01", 1);
   5.528 ++      sha1_update(&sha1, (BYTE *) "\x01", 1);
   5.529 +       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
   5.530 +       mpz_init(f), mpz_init(q);
   5.531 +       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
   5.532 +@@ -3050,7 +3050,7 @@ TPM_RESULT TPM_DAA_Sign(TPM_HANDLE handl
   5.533 +         sha1_init(&sha1);
   5.534 +         sha1_update(&sha1, (BYTE*) &session->DAA_session.DAA_digest, 
   5.535 +           sizeof(session->DAA_session.DAA_digest));
   5.536 +-        sha1_update(&sha1, "\x01", 1);
   5.537 ++        sha1_update(&sha1, (BYTE *) "\x01", 1);
   5.538 +         sha1_update(&sha1, inputData1, inputSize1);
   5.539 +         sha1_final(&sha1, (BYTE*) &session->DAA_session.DAA_digest);
   5.540 +       }
   5.541 +@@ -3078,7 +3078,7 @@ TPM_RESULT TPM_DAA_Sign(TPM_HANDLE handl
   5.542 +         sha1_init(&sha1);
   5.543 +         sha1_update(&sha1, (BYTE*) &session->DAA_session.DAA_digest, 
   5.544 +           sizeof(session->DAA_session.DAA_digest));
   5.545 +-        sha1_update(&sha1, "\x01", 1);
   5.546 ++        sha1_update(&sha1, (BYTE *) "\x01", 1);
   5.547 +         rsa_export_modulus(&aikData->key, scratch, &size);
   5.548 +         sha1_update(&sha1, scratch, size);
   5.549 +         sha1_final(&sha1, (BYTE*) &session->DAA_session.DAA_digest);
   5.550 +@@ -3134,14 +3134,14 @@ TPM_RESULT TPM_DAA_Sign(TPM_HANDLE handl
   5.551 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.552 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.553 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.554 +-      sha1_update(&sha1, "\x00", 1);
   5.555 ++      sha1_update(&sha1, (BYTE *) "\x00", 1);
   5.556 +       sha1_final(&sha1, scratch);
   5.557 +       sha1_init(&sha1);
   5.558 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
   5.559 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.560 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.561 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.562 +-      sha1_update(&sha1, "\x01", 1);
   5.563 ++      sha1_update(&sha1, (BYTE *) "\x01", 1);
   5.564 +       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
   5.565 +       mpz_init(f), mpz_init(q);
   5.566 +       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
   5.567 +@@ -3213,14 +3213,14 @@ TPM_RESULT TPM_DAA_Sign(TPM_HANDLE handl
   5.568 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.569 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.570 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.571 +-      sha1_update(&sha1, "\x00", 1);
   5.572 ++      sha1_update(&sha1, (BYTE *) "\x00", 1);
   5.573 +       sha1_final(&sha1, scratch);
   5.574 +       sha1_init(&sha1);
   5.575 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_rekey, 
   5.576 +           sizeof(session->DAA_tpmSpecific.DAA_rekey));
   5.577 +       sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, 
   5.578 +           sizeof(session->DAA_tpmSpecific.DAA_count));
   5.579 +-      sha1_update(&sha1, "\x01", 1);
   5.580 ++      sha1_update(&sha1, (BYTE *) "\x01", 1);
   5.581 +       sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH);
   5.582 +       mpz_init(f), mpz_init(q);
   5.583 +       mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch);
   5.584 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_data.c vtpm/tpm/tpm_data.c
   5.585 +--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_data.c	2006-05-30 12:28:02.000000000 -0700
   5.586 ++++ vtpm/tpm/tpm_data.c	2006-05-30 12:23:26.000000000 -0700
   5.587  @@ -1,6 +1,7 @@
   5.588   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.589    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
   5.590 @@ -698,8 +876,8 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.591    *
   5.592    * This module is free software; you can redistribute it and/or modify
   5.593    * it under the terms of the GNU General Public License as published
   5.594 -@@ -15,9 +16,15 @@
   5.595 -  * $Id: tpm_data.c 9 2005-04-26 18:15:31Z mast $
   5.596 +@@ -15,10 +16,15 @@
   5.597 +  * $Id: tpm_data.c 36 2005-10-26 20:31:19Z hstamer $
   5.598    */
   5.599   
   5.600  +#include <sys/types.h>
   5.601 @@ -710,11 +888,12 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.602   #include "tpm_emulator.h"
   5.603   #include "tpm_structures.h"
   5.604   #include "tpm_marshalling.h"
   5.605 +-#include "linux_module.h"
   5.606  +#include "vtpm_manager.h"
   5.607   
   5.608   TPM_DATA tpmData;
   5.609   
   5.610 -@@ -28,6 +35,7 @@ BOOL tpm_get_physical_presence(void)
   5.611 +@@ -39,6 +45,7 @@ static inline void init_pcr_attr(int pcr
   5.612   
   5.613   void tpm_init_data(void)
   5.614   {
   5.615 @@ -722,7 +901,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.616     /* endorsement key */
   5.617     uint8_t ek_n[] =  "\xa8\xdb\xa9\x42\xa8\xf3\xb8\x06\x85\x90\x76\x93\xad\xf7"
   5.618       "\x74\xec\x3f\xd3\x3d\x9d\xe8\x2e\xff\x15\xed\x0e\xce\x5f\x93"
   5.619 -@@ -66,6 +74,8 @@ void tpm_init_data(void)
   5.620 +@@ -77,6 +84,8 @@ void tpm_init_data(void)
   5.621       "\xd1\xc0\x8b\x5b\xa2\x2e\xa7\x15\xca\x50\x75\x10\x48\x9c\x2b"
   5.622       "\x18\xb9\x67\x8f\x5d\x64\xc3\x28\x9f\x2f\x16\x2f\x08\xda\x47"
   5.623       "\xec\x86\x43\x0c\x80\x99\x07\x34\x0f";
   5.624 @@ -731,18 +910,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.625     int i;
   5.626     /* reset all data to NULL, FALSE or 0 */
   5.627     memset(&tpmData, 0, sizeof(tpmData));
   5.628 -@@ -85,6 +95,10 @@ void tpm_init_data(void)
   5.629 -   tpmData.permanent.data.version.revMinor = VERSION_MINOR;
   5.630 -   /* setup PCR attributes */
   5.631 -   for (i = 0; i < TPM_NUM_PCR; i++) {
   5.632 -+    int j;
   5.633 -+    for (j=0; j < TPM_NUM_LOCALITY; j++) {
   5.634 -+      tpmData.permanent.data.pcrAttrib[i].pcrExtendLocal[j] = TRUE;
   5.635 -+    }
   5.636 -     tpmData.permanent.data.pcrAttrib[i].pcrReset = TRUE;
   5.637 -   }
   5.638 -   /* set tick type */
   5.639 -@@ -115,49 +129,235 @@ void tpm_release_data(void)
   5.640 +@@ -150,49 +159,235 @@ void tpm_release_data(void)
   5.641   
   5.642   #ifdef TPM_STORE_TO_FILE
   5.643   
   5.644 @@ -1009,7 +1177,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.645   }
   5.646   
   5.647   #else
   5.648 -@@ -232,7 +432,6 @@ int tpm_restore_permanent_data(void)
   5.649 +@@ -267,7 +462,6 @@ int tpm_restore_permanent_data(void)
   5.650   
   5.651   int tpm_erase_permanent_data(void)
   5.652   {
   5.653 @@ -1018,9 +1186,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.654     return res;
   5.655   }
   5.656  -
   5.657 -diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_deprecated.c vtpm/tpm/tpm_deprecated.c
   5.658 ---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_deprecated.c	2005-08-15 00:58:57.000000000 -0700
   5.659 -+++ vtpm/tpm/tpm_deprecated.c	2006-05-17 09:31:11.000000000 -0700
   5.660 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_deprecated.c vtpm/tpm/tpm_deprecated.c
   5.661 +--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_deprecated.c	2006-01-10 04:21:45.000000000 -0800
   5.662 ++++ vtpm/tpm/tpm_deprecated.c	2006-05-30 12:23:26.000000000 -0700
   5.663  @@ -1,6 +1,7 @@
   5.664   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.665    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
   5.666 @@ -1047,9 +1215,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.667                           authContextSize, &contextBlob);
   5.668     if (res != TPM_SUCCESS) return res;
   5.669     len = *authContextSize;
   5.670 -diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_emulator.h vtpm/tpm/tpm_emulator.h
   5.671 ---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_emulator.h	2005-08-15 00:58:57.000000000 -0700
   5.672 -+++ vtpm/tpm/tpm_emulator.h	2006-05-17 09:31:11.000000000 -0700
   5.673 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_emulator.h vtpm/tpm/tpm_emulator.h
   5.674 +--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_emulator.h	2006-01-10 04:21:45.000000000 -0800
   5.675 ++++ vtpm/tpm/tpm_emulator.h	2006-05-30 12:23:26.000000000 -0700
   5.676  @@ -1,5 +1,6 @@
   5.677   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.678    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
   5.679 @@ -1064,12 +1232,12 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.680  -#undef  TPM_GENERATE_EK
   5.681  +//#undef  TPM_GENERATE_EK
   5.682  +#define  TPM_GENERATE_EK
   5.683 + #undef  TPM_GENERATE_SEED_DAA
   5.684   
   5.685 - /**
   5.686 -  * tpm_emulator_init - initialises and starts the TPM emulator
   5.687 -diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_integrity.c vtpm/tpm/tpm_integrity.c
   5.688 ---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_integrity.c	2005-08-15 00:58:57.000000000 -0700
   5.689 -+++ vtpm/tpm/tpm_integrity.c	2006-05-17 09:31:11.000000000 -0700
   5.690 + #define TPM_MANUFACTURER 0x4554485A /* 'ETHZ' */        
   5.691 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_integrity.c vtpm/tpm/tpm_integrity.c
   5.692 +--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_integrity.c	2006-01-10 04:21:45.000000000 -0800
   5.693 ++++ vtpm/tpm/tpm_integrity.c	2006-05-30 12:23:26.000000000 -0700
   5.694  @@ -1,6 +1,7 @@
   5.695   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.696    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
   5.697 @@ -1083,9 +1251,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.698     return TPM_SUCCESS;
   5.699   }
   5.700  -
   5.701 -diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_structures.h vtpm/tpm/tpm_structures.h
   5.702 ---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_structures.h	2005-08-15 00:58:57.000000000 -0700
   5.703 -+++ vtpm/tpm/tpm_structures.h	2006-05-17 09:31:11.000000000 -0700
   5.704 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_structures.h vtpm/tpm/tpm_structures.h
   5.705 +--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_structures.h	2006-01-10 04:21:45.000000000 -0800
   5.706 ++++ vtpm/tpm/tpm_structures.h	2006-05-30 12:23:26.000000000 -0700
   5.707  @@ -1,6 +1,7 @@
   5.708   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.709    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
   5.710 @@ -1103,9 +1271,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.711   #include "crypto/rsa.h"
   5.712   
   5.713   /*
   5.714 -diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_testing.c vtpm/tpm/tpm_testing.c
   5.715 ---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_testing.c	2005-08-15 00:58:57.000000000 -0700
   5.716 -+++ vtpm/tpm/tpm_testing.c	2006-05-17 09:31:11.000000000 -0700
   5.717 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_testing.c vtpm/tpm/tpm_testing.c
   5.718 +--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_testing.c	2006-01-10 04:21:45.000000000 -0800
   5.719 ++++ vtpm/tpm/tpm_testing.c	2006-05-30 12:23:26.000000000 -0700
   5.720  @@ -1,6 +1,7 @@
   5.721   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.722    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
   5.723 @@ -1221,9 +1389,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.724     rsa_private_key_t priv_key;
   5.725     rsa_public_key_t pub_key;
   5.726   
   5.727 -diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_ticks.c vtpm/tpm/tpm_ticks.c
   5.728 ---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_ticks.c	2005-08-15 00:58:57.000000000 -0700
   5.729 -+++ vtpm/tpm/tpm_ticks.c	2006-05-17 09:31:11.000000000 -0700
   5.730 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_ticks.c vtpm/tpm/tpm_ticks.c
   5.731 +--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_ticks.c	2006-01-10 04:21:45.000000000 -0800
   5.732 ++++ vtpm/tpm/tpm_ticks.c	2006-05-30 12:23:26.000000000 -0700
   5.733  @@ -1,6 +1,7 @@
   5.734   /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.735    * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
   5.736 @@ -1306,9 +1474,69 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
   5.737   }
   5.738     
   5.739   
   5.740 -diff -uprN orig/tpm_emulator-0.2-x86_64/tpmd.c vtpm/tpmd.c
   5.741 ---- orig/tpm_emulator-0.2-x86_64/tpmd.c	1969-12-31 16:00:00.000000000 -0800
   5.742 -+++ vtpm/tpmd.c	2006-05-17 09:31:11.000000000 -0700
   5.743 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_transport.c vtpm/tpm/tpm_transport.c
   5.744 +--- orig/tpm_emulator-0.3-x86_64/tpm/tpm_transport.c	2006-01-10 04:21:45.000000000 -0800
   5.745 ++++ vtpm/tpm/tpm_transport.c	2006-05-30 12:23:26.000000000 -0700
   5.746 +@@ -59,7 +59,7 @@ static int decrypt_transport_auth(TPM_KE
   5.747 + static void transport_log_in(TPM_COMMAND_CODE ordinal, BYTE parameters[20],
   5.748 +                              BYTE pubKeyHash[20], TPM_DIGEST *transDigest)
   5.749 + {
   5.750 +-  UINT32 tag = cpu_to_be32(TPM_TAG_TRANSPORT_LOG_IN);
   5.751 ++  UINT32 tag = CPU_TO_BE32(TPM_TAG_TRANSPORT_LOG_IN);
   5.752 +   BYTE *ptr, buf[sizeof_TPM_TRANSPORT_LOG_IN(x)];
   5.753 +   UINT32 len = sizeof(buf);
   5.754 +   sha1_ctx_t sha1;
   5.755 +@@ -76,7 +76,7 @@ static void transport_log_in(TPM_COMMAND
   5.756 + static void transport_log_out(TPM_CURRENT_TICKS *currentTicks, BYTE parameters[20],
   5.757 +                               TPM_MODIFIER_INDICATOR locality, TPM_DIGEST *transDigest)
   5.758 + {
   5.759 +-  UINT32 tag = cpu_to_be32(TPM_TAG_TRANSPORT_LOG_OUT);
   5.760 ++  UINT32 tag = CPU_TO_BE32(TPM_TAG_TRANSPORT_LOG_OUT);
   5.761 +   BYTE *ptr, buf[sizeof_TPM_TRANSPORT_LOG_OUT(x)];
   5.762 +   UINT32 len = sizeof(buf);
   5.763 +   sha1_ctx_t sha1;
   5.764 +@@ -191,7 +191,7 @@ static void decrypt_wrapped_command(BYTE
   5.765 +     sha1_update(&sha1, auth->nonceOdd.nonce, sizeof(auth->nonceOdd.nonce));
   5.766 +     sha1_update(&sha1, "in", 2);
   5.767 +     sha1_update(&sha1, secret, sizeof(TPM_SECRET));
   5.768 +-    j = cpu_to_be32(i);
   5.769 ++    j = CPU_TO_BE32(i);
   5.770 +     sha1_update(&sha1, (BYTE*)&j, 4);
   5.771 +     sha1_final(&sha1, mask);
   5.772 +     for (j = 0; j < sizeof(mask) && buf_len > 0; j++) { 
   5.773 +@@ -213,7 +213,7 @@ static void encrypt_wrapped_command(BYTE
   5.774 +     sha1_update(&sha1, auth->nonceOdd.nonce, sizeof(auth->nonceOdd.nonce));
   5.775 +     sha1_update(&sha1, "out", 3);
   5.776 +     sha1_update(&sha1, secret, sizeof(TPM_SECRET));
   5.777 +-    j = cpu_to_be32(i);
   5.778 ++    j = CPU_TO_BE32(i);
   5.779 +     sha1_update(&sha1, (BYTE*)&j, 4);
   5.780 +     sha1_final(&sha1, mask);
   5.781 +     for (j = 0; j < sizeof(mask) && buf_len > 0; j++) { 
   5.782 +@@ -253,9 +253,9 @@ TPM_RESULT TPM_ExecuteTransport(UINT32 i
   5.783 +   /* verify authorization */
   5.784 +   tpm_compute_in_param_digest(&req);
   5.785 +   sha1_init(&sha1);
   5.786 +-  res = cpu_to_be32(TPM_ORD_ExecuteTransport);
   5.787 ++  res = CPU_TO_BE32(TPM_ORD_ExecuteTransport);
   5.788 +   sha1_update(&sha1, (BYTE*)&res, 4);
   5.789 +-  res = cpu_to_be32(inWrappedCmdSize);
   5.790 ++  res = CPU_TO_BE32(inWrappedCmdSize);
   5.791 +   sha1_update(&sha1, (BYTE*)&res, 4);
   5.792 +   sha1_update(&sha1, req.auth1.digest, sizeof(req.auth1.digest));
   5.793 +   sha1_final(&sha1, auth1->digest);
   5.794 +@@ -357,7 +357,7 @@ TPM_RESULT TPM_ReleaseTransportSigned(TP
   5.795 +   /* setup a TPM_SIGN_INFO structure */
   5.796 +   memcpy(&buf[0], "\x05\x00TRAN", 6);
   5.797 +   memcpy(&buf[6], antiReplay->nonce, 20);
   5.798 +-  *(UINT32*)&buf[26] = cpu_to_be32(20);
   5.799 ++  *(UINT32*)&buf[26] = CPU_TO_BE32(20);
   5.800 +   memcpy(&buf[30], session->transInternal.transDigest.digest, 20);
   5.801 +   /* sign info structure */ 
   5.802 +   res = tpm_sign(key, auth1, TRUE, buf, sizeof(buf), signature, signSize);
   5.803 +diff -uprN orig/tpm_emulator-0.3-x86_64/tpmd.c vtpm/tpmd.c
   5.804 +--- orig/tpm_emulator-0.3-x86_64/tpmd.c	1969-12-31 16:00:00.000000000 -0800
   5.805 ++++ vtpm/tpmd.c	2006-05-30 12:23:26.000000000 -0700
   5.806  @@ -0,0 +1,207 @@
   5.807  +/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
   5.808  + * Copyright (C) 2005 INTEL Corp