[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] [VTPM_TOOLS] Updated vtpmd to save complete state in preperateion to
# HG changeset patch # User kaf24@xxxxxxxxxxxxxxxxxxxx # Node ID 18587d3e94c8c3a6ccdf9bc5965eea426e6df87d # Parent 533b0709a68fbbe5ddc9eff7dfb840b55ff092f5 [VTPM_TOOLS] Updated vtpmd to save complete state in preperateion to support suspend/resume and migration. Fixed startup bug. Signed-off-by: Vincent Scarlata <vincent.r.scarlata@xxxxxxxxx> --- tools/vtpm/Rules.mk | 2 tools/vtpm/tpm_emulator-0.3-x86_64.patch | 238 +++++++++++++++++++++------- tools/vtpm/tpm_emulator.patch | 258 +++++++++++++++---------------- tools/vtpm/vtpm.patch | 236 ++++++++++++++-------------- 4 files changed, 427 insertions(+), 307 deletions(-) diff -r 533b0709a68f -r 18587d3e94c8 tools/vtpm/Rules.mk --- a/tools/vtpm/Rules.mk Tue Jun 27 11:13:24 2006 +0100 +++ b/tools/vtpm/Rules.mk Tue Jun 27 11:14:19 2006 +0100 @@ -33,7 +33,7 @@ OBJS = $(patsubst %.c,%.o,$(SRCS)) -include $(DEP_FILES) -BUILD_EMULATOR = n +BUILD_EMULATOR = y # Make sure these are just rules .PHONY : all build install clean diff -r 533b0709a68f -r 18587d3e94c8 tools/vtpm/tpm_emulator-0.3-x86_64.patch --- a/tools/vtpm/tpm_emulator-0.3-x86_64.patch Tue Jun 27 11:13:24 2006 +0100 +++ b/tools/vtpm/tpm_emulator-0.3-x86_64.patch Tue Jun 27 11:14:19 2006 +0100 @@ -1,6 +1,49 @@ diff -uprN tpm_emulator-0.3/crypto/gmp_k -diff -uprN tpm_emulator-0.3/crypto/gmp_kernel_wrapper.c tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c ---- tpm_emulator-0.3/crypto/gmp_kernel_wrapper.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c 2006-05-26 11:26:02.000000000 -0700 +diff -uprN orig/tpm_emulator-0.3/Makefile tpm_emulator-0.3-x86_64/Makefile +--- orig/tpm_emulator-0.3/Makefile 2006-01-10 04:21:45.000000000 -0800 ++++ tpm_emulator-0.3-x86_64/Makefile 2006-08-29 15:08:20.532342768 -0700 +@@ -7,6 +7,7 @@ + KERNEL_RELEASE := $(shell uname -r) + KERNEL_BUILD := /lib/modules/$(KERNEL_RELEASE)/build + MOD_SUBDIR := misc ++COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/) + + # module settings + MODULE_NAME := tpm_emulator +@@ -17,8 +18,14 @@ VERSION_BUILD := $(shell date +"%s") + # enable/disable DEBUG messages + EXTRA_CFLAGS += -Wall -DDEBUG -g + ++ifeq ($(COMPILE_ARCH),x86_64) ++LIBDIR = lib64 ++else ++LIBDIR = lib ++endif ++ + # GNU MP configuration +-GMP_LIB := /usr/lib/libgmp.a ++GMP_LIB := /usr/$(LIBDIR)/libgmp.a + GMP_HEADER := /usr/include/gmp.h + + # sources and objects +diff -uprN orig/tpm_emulator-0.3/README tpm_emulator-0.3-x86_64/README +--- orig/tpm_emulator-0.3/README 2006-01-10 04:21:45.000000000 -0800 ++++ tpm_emulator-0.3-x86_64/README 2006-08-29 15:07:43.530967832 -0700 +@@ -43,6 +43,12 @@ Example: + GMP_LIB := /usr/lib/libgmp.a + GMP_HEADER := /usr/include/gmp.h + ++GNU MP Library on 64 bit Systems ++-------------------------------------------------------------------------- ++Some 64-bit kernels have problems with importing the user-space gmp ++library (/usr/lib*/libgmp.a) into kernel space. These kernels will require ++that the gmp library be recompiled for kernel space with -mcmodel=kernel. ++ + Installation + -------------------------------------------------------------------------- + The compilation and installation process uses the build environment for +diff -uprN orig/tpm_emulator-0.3/crypto/gmp_kernel_wrapper.c tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c +--- orig/tpm_emulator-0.3/crypto/gmp_kernel_wrapper.c 2006-01-10 04:21:45.000000000 -0800 ++++ tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c 2006-08-29 15:07:43.525968592 -0700 @@ -79,7 +79,7 @@ void __attribute__ ((regparm(0))) *kerne { void *ret = (void*)kmalloc(size, GFP_KERNEL); @@ -19,9 +62,9 @@ diff -uprN tpm_emulator-0.3/crypto/gmp_k memcpy(ret, oldptr, old_size); kfree(oldptr); return ret; -diff -uprN tpm_emulator-0.3/linux_module.c tpm_emulator-0.3-x86_64/linux_module.c ---- tpm_emulator-0.3/linux_module.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator-0.3-x86_64/linux_module.c 2006-05-26 11:26:02.000000000 -0700 +diff -uprN orig/tpm_emulator-0.3/linux_module.c tpm_emulator-0.3-x86_64/linux_module.c +--- orig/tpm_emulator-0.3/linux_module.c 2006-01-10 04:21:45.000000000 -0800 ++++ tpm_emulator-0.3-x86_64/linux_module.c 2006-08-29 15:07:43.526968440 -0700 @@ -72,7 +72,7 @@ static int tpm_release(struct inode *ino static ssize_t tpm_read(struct file *file, char *buf, size_t count, loff_t *ppos) @@ -40,9 +83,9 @@ diff -uprN tpm_emulator-0.3/linux_module down(&tpm_mutex); *ppos = 0; if (tpm_response.data != NULL) kfree(tpm_response.data); -diff -uprN tpm_emulator-0.3/linux_module.h tpm_emulator-0.3-x86_64/linux_module.h ---- tpm_emulator-0.3/linux_module.h 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator-0.3-x86_64/linux_module.h 2006-05-26 11:26:02.000000000 -0700 +diff -uprN orig/tpm_emulator-0.3/linux_module.h tpm_emulator-0.3-x86_64/linux_module.h +--- orig/tpm_emulator-0.3/linux_module.h 2006-01-10 04:21:45.000000000 -0800 ++++ tpm_emulator-0.3-x86_64/linux_module.h 2006-08-29 15:07:43.527968288 -0700 @@ -28,8 +28,10 @@ /* module settings */ @@ -54,52 +97,9 @@ diff -uprN tpm_emulator-0.3/linux_module #include "tpm_version.h" #define TPM_DEVICE_MINOR 224 -diff -uprN tpm_emulator-0.3/Makefile tpm_emulator-0.3-x86_64/Makefile ---- tpm_emulator-0.3/Makefile 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator-0.3-x86_64/Makefile 2006-05-26 11:26:02.000000000 -0700 -@@ -7,6 +7,7 @@ - KERNEL_RELEASE := $(shell uname -r) - KERNEL_BUILD := /lib/modules/$(KERNEL_RELEASE)/build - MOD_SUBDIR := misc -+COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/) - - # module settings - MODULE_NAME := tpm_emulator -@@ -17,8 +18,14 @@ VERSION_BUILD := $(shell date +"%s") - # enable/disable DEBUG messages - EXTRA_CFLAGS += -Wall -DDEBUG -g - -+ifeq ($(COMPILE_ARCH),x86_64) -+LIBDIR = lib64 -+else -+LIBDIR = lib -+endif -+ - # GNU MP configuration --GMP_LIB := /usr/lib/libgmp.a -+GMP_LIB := /usr/$(LIBDIR)/libgmp.a - GMP_HEADER := /usr/include/gmp.h - - # sources and objects -diff -uprN tpm_emulator-0.3/README tpm_emulator-0.3-x86_64/README ---- tpm_emulator-0.3/README 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator-0.3-x86_64/README 2006-05-26 11:26:02.000000000 -0700 -@@ -43,6 +43,12 @@ Example: - GMP_LIB := /usr/lib/libgmp.a - GMP_HEADER := /usr/include/gmp.h - -+GNU MP Library on 64 bit Systems -+-------------------------------------------------------------------------- -+Some 64-bit kernels have problems with importing the user-space gmp -+library (/usr/lib*/libgmp.a) into kernel space. These kernels will require -+that the gmp library be recompiled for kernel space with -mcmodel=kernel. -+ - Installation - -------------------------------------------------------------------------- - The compilation and installation process uses the build environment for -diff -uprN tpm_emulator-0.3/tpm/tpm_credentials.c tpm_emulator-0.3-x86_64/tpm/tpm_credentials.c ---- tpm_emulator-0.3/tpm/tpm_credentials.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator-0.3-x86_64/tpm/tpm_credentials.c 2006-05-26 11:26:02.000000000 -0700 +diff -uprN orig/tpm_emulator-0.3/tpm/tpm_credentials.c tpm_emulator-0.3-x86_64/tpm/tpm_credentials.c +--- orig/tpm_emulator-0.3/tpm/tpm_credentials.c 2006-01-10 04:21:45.000000000 -0800 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_credentials.c 2006-08-29 15:07:43.530967832 -0700 @@ -47,16 +47,16 @@ int tpm_compute_pubkey_checksum(TPM_NONC TPM_RESULT tpm_get_pubek(TPM_PUBKEY *pubEndorsementKey) @@ -140,9 +140,9 @@ diff -uprN tpm_emulator-0.3/tpm/tpm_cred publicPortion->algorithmParms.algorithmID = TPM_ALG_RSA; publicPortion->algorithmParms.encScheme = srk->encScheme; publicPortion->algorithmParms.sigScheme = srk->sigScheme; -diff -uprN tpm_emulator-0.3/tpm/tpm_crypto.c tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c ---- tpm_emulator-0.3/tpm/tpm_crypto.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c 2006-05-26 11:26:02.000000000 -0700 +diff -uprN orig/tpm_emulator-0.3/tpm/tpm_crypto.c tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c +--- orig/tpm_emulator-0.3/tpm/tpm_crypto.c 2006-01-10 04:21:45.000000000 -0800 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c 2006-08-29 15:07:43.531967680 -0700 @@ -182,7 +182,8 @@ TPM_RESULT TPM_CertifyKey(TPM_KEY_HANDLE TPM_KEY_DATA *cert, *key; sha1_ctx_t sha1_ctx; @@ -192,10 +192,10 @@ diff -uprN tpm_emulator-0.3/tpm/tpm_cryp free_TPM_KEY_PARMS(certifyInfo->algorithmParms); return TPM_FAIL; } -diff -uprN tpm_emulator-0.3/tpm/tpm_data.c tpm_emulator-0.3-x86_64/tpm/tpm_data.c ---- tpm_emulator-0.3/tpm/tpm_data.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator-0.3-x86_64/tpm/tpm_data.c 2006-05-26 11:26:02.000000000 -0700 -@@ -214,7 +214,7 @@ static int read_from_file(uint8_t **data +diff -uprN orig/tpm_emulator-0.3/tpm/tpm_data.c tpm_emulator-0.3-x86_64/tpm/tpm_data.c +--- orig/tpm_emulator-0.3/tpm/tpm_data.c 2006-01-10 04:21:45.000000000 -0800 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_data.c 2006-08-29 15:08:20.535342312 -0700 +@@ -214,23 +214,30 @@ static int read_from_file(uint8_t **data int tpm_store_permanent_data(void) { uint8_t *buf, *ptr; @@ -203,8 +203,35 @@ diff -uprN tpm_emulator-0.3/tpm/tpm_data + UINT32 buf_length, len; /* marshal data */ - buf_length = len = sizeof_TPM_STCLEAR_FLAGS(tpmData.stclear.flags) -@@ -242,13 +242,14 @@ int tpm_store_permanent_data(void) +- buf_length = len = sizeof_TPM_STCLEAR_FLAGS(tpmData.stclear.flags) +- + sizeof_TPM_PERMANENT_FLAGS(tpmData.permanent.flags) + 2 +- + sizeof_TPM_PERMANENT_DATA(tpmData.permanent.data); ++ buf_length = len = 4 + sizeof_TPM_STCLEAR_FLAGS(tpmData.stclear.flags) ++ + sizeof_TPM_PERMANENT_FLAGS(tpmData.permanent.flags) ++ + sizeof_TPM_STANY_FLAGS(tpmData.stany.flags) + 2 ++ + sizeof_TPM_STCLEAR_DATA(tpmData.stclear.data) ++ + sizeof_TPM_PERMANENT_DATA(tpmData.permanent.data) ++ + sizeof_TPM_STANY_DATA(tpmData.stany.data); + buf = ptr = tpm_malloc(buf_length); + if (buf == NULL + || tpm_marshal_TPM_VERSION(&ptr, &len, &tpmData.permanent.data.version) + || tpm_marshal_TPM_STCLEAR_FLAGS(&ptr, &len, &tpmData.stclear.flags) + || tpm_marshal_TPM_PERMANENT_FLAGS(&ptr, &len, &tpmData.permanent.flags) ++ || tpm_marshal_TPM_STANY_FLAGS(&ptr, &len, &tpmData.stany.flags) + || tpm_marshal_BOOL(&ptr, &len, tpmData.permanent.flags.selfTestSucceeded) + || tpm_marshal_BOOL(&ptr, &len, tpmData.permanent.flags.owned) +- || tpm_marshal_TPM_PERMANENT_DATA(&ptr, &len, &tpmData.permanent.data)) { ++ || tpm_marshal_TPM_STCLEAR_DATA(&ptr, &len, &tpmData.stclear.data) ++ || tpm_marshal_TPM_PERMANENT_DATA(&ptr, &len, &tpmData.permanent.data) ++ || tpm_marshal_TPM_STANY_DATA(&ptr, &len, &tpmData.stany.data)) { + tpm_free(buf); + return -1; + } ++ + if (write_to_file(buf, buf_length - len)) { + tpm_free(buf); + return -1; +@@ -242,24 +249,29 @@ int tpm_store_permanent_data(void) int tpm_restore_permanent_data(void) { uint8_t *buf, *ptr; @@ -221,9 +248,25 @@ diff -uprN tpm_emulator-0.3/tpm/tpm_data /* unmarshal data */ if (tpm_unmarshal_TPM_VERSION(&ptr, &len, &ver) || memcmp(&ver, &tpmData.permanent.data.version, sizeof(TPM_VERSION)) -diff -uprN tpm_emulator-0.3/tpm/tpm_marshalling.c tpm_emulator-0.3-x86_64/tpm/tpm_marshalling.c ---- tpm_emulator-0.3/tpm/tpm_marshalling.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator-0.3-x86_64/tpm/tpm_marshalling.c 2006-05-26 11:26:02.000000000 -0700 + || tpm_unmarshal_TPM_STCLEAR_FLAGS(&ptr, &len, &tpmData.stclear.flags) + || tpm_unmarshal_TPM_PERMANENT_FLAGS(&ptr, &len, &tpmData.permanent.flags) ++ || tpm_unmarshal_TPM_STANY_FLAGS(&ptr, &len, &tpmData.stany.flags) + || tpm_unmarshal_BOOL(&ptr, &len, &tpmData.permanent.flags.selfTestSucceeded) + || tpm_unmarshal_BOOL(&ptr, &len, &tpmData.permanent.flags.owned) +- || tpm_unmarshal_TPM_PERMANENT_DATA(&ptr, &len, &tpmData.permanent.data)) { ++ || tpm_unmarshal_TPM_STCLEAR_DATA(&ptr, &len, &tpmData.stclear.data) ++ || tpm_unmarshal_TPM_PERMANENT_DATA(&ptr, &len, &tpmData.permanent.data) ++ || tpm_unmarshal_TPM_STANY_DATA(&ptr, &len, &tpmData.stany.data)) { + tpm_free(buf); + return -1; + } ++ + tpm_free(buf); + return 0; + } +diff -uprN orig/tpm_emulator-0.3/tpm/tpm_marshalling.c tpm_emulator-0.3-x86_64/tpm/tpm_marshalling.c +--- orig/tpm_emulator-0.3/tpm/tpm_marshalling.c 2006-01-10 04:21:45.000000000 -0800 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_marshalling.c 2006-08-29 15:08:20.537342008 -0700 @@ -1212,7 +1212,7 @@ int tpm_unmarshal_TPM_STANY_FLAGS(BYTE * int tpm_marshal_RSA(BYTE **ptr, UINT32 *length, rsa_private_key_t *v) @@ -233,9 +276,92 @@ diff -uprN tpm_emulator-0.3/tpm/tpm_mars if (*length < sizeof_RSA((*v))) return -1; if (v->size > 0) { rsa_export_modulus(v, &(*ptr)[6], &m_len); -diff -uprN tpm_emulator-0.3/tpm/tpm_owner.c tpm_emulator-0.3-x86_64/tpm/tpm_owner.c ---- tpm_emulator-0.3/tpm/tpm_owner.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator-0.3-x86_64/tpm/tpm_owner.c 2006-05-26 11:26:02.000000000 -0700 +@@ -1356,6 +1356,66 @@ int tpm_unmarshal_TPM_PERMANENT_DATA(BYT + return 0; + } + ++int tpm_marshal_TPM_STCLEAR_DATA(BYTE **ptr, UINT32 *length, TPM_STCLEAR_DATA *v) ++{ ++ if (tpm_marshal_TPM_STRUCTURE_TAG(ptr, length, v->tag) ++ || tpm_marshal_TPM_NONCE(ptr, length, &v->contextNonceKey) ++ || tpm_marshal_TPM_COUNT_ID(ptr, length, v->countID) ) return -1; ++ ++ return 0; ++} ++ ++int tpm_unmarshal_TPM_STCLEAR_DATA(BYTE **ptr, UINT32 *length, TPM_STCLEAR_DATA *v) ++{ ++ if (tpm_unmarshal_TPM_STRUCTURE_TAG(ptr, length, &v->tag) ++ || tpm_unmarshal_TPM_NONCE(ptr, length, &v->contextNonceKey) ++ || tpm_unmarshal_TPM_COUNT_ID(ptr, length, &v->countID) ) return -1; ++ ++ return 0; ++} ++ ++int tpm_marshal_TPM_STANY_DATA(BYTE **ptr, UINT32 *length, TPM_STANY_DATA *v) ++{ ++ UINT32 i; ++ if (tpm_marshal_TPM_STRUCTURE_TAG(ptr, length, v->tag) ++ || tpm_marshal_TPM_NONCE(ptr, length, &v->contextNonceSession) ++ || tpm_marshal_TPM_DIGEST(ptr, length, &v->auditDigest) ++ || tpm_marshal_BOOL(ptr, length, v->auditSession) ++ || tpm_marshal_TPM_CURRENT_TICKS(ptr, length, &v->currentTicks) ++ || tpm_marshal_UINT32(ptr, length, v->contextCount) ++ || tpm_marshal_UINT32_ARRAY(ptr, length, v->contextList, TPM_MAX_SESSION_LIST)) return -1; ++ for (i = 0; i < TPM_MAX_SESSIONS; i++) { ++ if (tpm_marshal_TPM_SESSION_DATA(ptr, length, &v->sessions[i])) return -1; ++ } ++ for (i = 0; i < TPM_MAX_SESSIONS_DAA; i++) { ++ if (tpm_marshal_TPM_DAA_SESSION_DATA(ptr, length, &v->sessionsDAA[i])) return -1; ++ } ++ if (tpm_marshal_TPM_TRANSHANDLE(ptr, length, v->transExclusive)) return -1; ++ ++ return 0; ++} ++ ++int tpm_unmarshal_TPM_STANY_DATA(BYTE **ptr, UINT32 *length, TPM_STANY_DATA *v) ++{ ++ UINT32 i; ++ if (tpm_unmarshal_TPM_STRUCTURE_TAG(ptr, length, &v->tag) ++ || tpm_unmarshal_TPM_NONCE(ptr, length, &v->contextNonceSession) ++ || tpm_unmarshal_TPM_DIGEST(ptr, length, &v->auditDigest) ++ || tpm_unmarshal_BOOL(ptr, length, &v->auditSession) ++ || tpm_unmarshal_TPM_CURRENT_TICKS(ptr, length, &v->currentTicks) ++ || tpm_unmarshal_UINT32(ptr, length, &v->contextCount) ++ || tpm_unmarshal_UINT32_ARRAY(ptr, length, v->contextList, TPM_MAX_SESSION_LIST)) return -1; ++ for (i = 0; i < TPM_MAX_SESSIONS; i++) { ++ if (tpm_unmarshal_TPM_SESSION_DATA(ptr, length, &v->sessions[i])) return -1; ++ } ++ for (i = 0; i < TPM_MAX_SESSIONS_DAA; i++) { ++ if (tpm_unmarshal_TPM_DAA_SESSION_DATA(ptr, length, &v->sessionsDAA[i])) return -1; ++ } ++ if (tpm_unmarshal_TPM_TRANSHANDLE(ptr, length, &v->transExclusive)) return -1; ++ ++ return 0; ++} ++ + int tpm_marshal_TPM_SESSION_DATA(BYTE **ptr, UINT32 *length, TPM_SESSION_DATA *v) + { + if (tpm_marshal_BYTE(ptr, length, v->type) +diff -uprN orig/tpm_emulator-0.3/tpm/tpm_marshalling.h tpm_emulator-0.3-x86_64/tpm/tpm_marshalling.h +--- orig/tpm_emulator-0.3/tpm/tpm_marshalling.h 2006-01-10 04:21:45.000000000 -0800 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_marshalling.h 2006-08-29 15:08:20.538341856 -0700 +@@ -420,6 +420,12 @@ int tpm_unmarshal_TPM_KEY_DATA(BYTE **pt + int tpm_marshal_TPM_PERMANENT_DATA(BYTE **ptr, UINT32 *length, TPM_PERMANENT_DATA *); + int tpm_unmarshal_TPM_PERMANENT_DATA(BYTE **ptr, UINT32 *length, TPM_PERMANENT_DATA *); + ++int tpm_marshal_TPM_STCLEAR_DATA(BYTE **ptr, UINT32 *length, TPM_STCLEAR_DATA *v); ++int tpm_unmarshal_TPM_STCLEAR_DATA(BYTE **ptr, UINT32 *length, TPM_STCLEAR_DATA *v); ++ ++int tpm_marshal_TPM_STANY_DATA(BYTE **ptr, UINT32 *length, TPM_STANY_DATA *v); ++int tpm_unmarshal_TPM_STANY_DATA(BYTE **ptr, UINT32 *length, TPM_STANY_DATA *v); ++ + int tpm_marshal_TPM_SESSION_DATA(BYTE **ptr, UINT32 *length, TPM_SESSION_DATA *v); + int tpm_unmarshal_TPM_SESSION_DATA(BYTE **ptr, UINT32 *length, TPM_SESSION_DATA *v); + +diff -uprN orig/tpm_emulator-0.3/tpm/tpm_owner.c tpm_emulator-0.3-x86_64/tpm/tpm_owner.c +--- orig/tpm_emulator-0.3/tpm/tpm_owner.c 2006-01-10 04:21:45.000000000 -0800 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_owner.c 2006-08-29 15:07:43.535967072 -0700 @@ -108,7 +108,7 @@ TPM_RESULT TPM_TakeOwnership(TPM_PROTOCO TPM_RESULT res; rsa_private_key_t *ek = &tpmData.permanent.data.endorsementKey; @@ -255,9 +381,63 @@ diff -uprN tpm_emulator-0.3/tpm/tpm_owne /* setup tpmProof and set state to owned */ tpm_get_random_bytes(tpmData.permanent.data.tpmProof.nonce, sizeof(tpmData.permanent.data.tpmProof.nonce)); -diff -uprN tpm_emulator-0.3/tpm/tpm_storage.c tpm_emulator-0.3-x86_64/tpm/tpm_storage.c ---- tpm_emulator-0.3/tpm/tpm_storage.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator-0.3-x86_64/tpm/tpm_storage.c 2006-05-26 14:33:18.000000000 -0700 +diff -uprN orig/tpm_emulator-0.3/tpm/tpm_startup.c tpm_emulator-0.3-x86_64/tpm/tpm_startup.c +--- orig/tpm_emulator-0.3/tpm/tpm_startup.c 2006-01-10 04:21:45.000000000 -0800 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_startup.c 2006-08-29 15:08:20.538341856 -0700 +@@ -41,24 +41,29 @@ void TPM_Init(TPM_STARTUP_TYPE startupTy + TPM_RESULT TPM_Startup(TPM_STARTUP_TYPE startupType) + { + int i; ++ int restore_fail; + info("TPM_Startup(%d)", startupType); + if (tpmData.stany.flags.postInitialise == FALSE) return TPM_INVALID_POSTINIT; +- /* reset STANY_FLAGS */ +- SET_TO_ZERO(&tpmData.stany.flags); +- tpmData.stany.flags.tag = TPM_TAG_STANY_FLAGS; +- /* reset STANY_DATA (invalidates ALL sessions) */ +- SET_TO_ZERO(&tpmData.stany.data); +- tpmData.stany.data.tag = TPM_TAG_STANY_DATA; +- /* init session-context nonce */ +- SET_TO_RAND(&tpmData.stany.data.contextNonceSession); ++ ++ /* try and restore state to get EK, SRK, etc */ ++ restore_fail = tpm_restore_permanent_data(); ++ + /* set data and flags according to the given startup type */ + if (startupType == TPM_ST_CLEAR) { ++ /* reset STANY_FLAGS */ ++ SET_TO_ZERO(&tpmData.stany.flags); ++ tpmData.stany.flags.tag = TPM_TAG_STANY_FLAGS; ++ /* reset STANY_DATA (invalidates ALL sessions) */ ++ SET_TO_ZERO(&tpmData.stany.data); ++ tpmData.stany.data.tag = TPM_TAG_STANY_DATA; ++ /* init session-context nonce */ ++ SET_TO_RAND(&tpmData.stany.data.contextNonceSession); + /* reset PCR values */ + for (i = 0; i < TPM_NUM_PCR; i++) { +- if (tpmData.permanent.data.pcrAttrib[i].pcrReset) +- SET_TO_ZERO(tpmData.permanent.data.pcrValue[i].digest); ++ if (!tpmData.permanent.data.pcrAttrib[i].pcrReset) ++ SET_TO_ZERO(&tpmData.permanent.data.pcrValue[i].digest); + else +- SET_TO_0xFF(tpmData.permanent.data.pcrValue[i].digest); ++ SET_TO_0xFF(&tpmData.permanent.data.pcrValue[i].digest); + } + /* reset STCLEAR_FLAGS */ + SET_TO_ZERO(&tpmData.stclear.flags); +@@ -77,7 +82,8 @@ TPM_RESULT TPM_Startup(TPM_STARTUP_TYPE + /* init key-context nonce */ + SET_TO_RAND(&tpmData.stclear.data.contextNonceKey); + } else if (startupType == TPM_ST_STATE) { +- if (tpm_restore_permanent_data()) { ++ /* restore must have been successful for TPM_ST_STATE */ ++ if (restore_fail) { + error("restoring permanent data failed"); + tpmData.permanent.data.testResult = "tpm_restore_permanent_data() failed"; + tpmData.permanent.flags.selfTestSucceeded = FALSE; +diff -uprN orig/tpm_emulator-0.3/tpm/tpm_storage.c tpm_emulator-0.3-x86_64/tpm/tpm_storage.c +--- orig/tpm_emulator-0.3/tpm/tpm_storage.c 2006-01-10 04:21:45.000000000 -0800 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_storage.c 2006-08-29 15:07:43.537966768 -0700 @@ -58,6 +58,7 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke BYTE *enc, UINT32 *enc_size) { @@ -482,3 +662,76 @@ diff -uprN tpm_emulator-0.3/tpm/tpm_stor if (tpm_setup_key_parms(key, &pubKey->algorithmParms) != 0) { tpm_free(pubKey->pubKey.key); return TPM_FAIL; +diff -uprN orig/tpm_emulator-0.3/tpm/tpm_structures.h tpm_emulator-0.3-x86_64/tpm/tpm_structures.h +--- orig/tpm_emulator-0.3/tpm/tpm_structures.h 2006-01-10 04:21:45.000000000 -0800 ++++ tpm_emulator-0.3-x86_64/tpm/tpm_structures.h 2006-08-29 15:08:20.545340792 -0700 +@@ -1723,6 +1723,7 @@ typedef struct tdTPM_DAA_ISSUER { + TPM_DIGEST DAA_digest_gamma; + BYTE DAA_generic_q[26]; + } TPM_DAA_ISSUER; ++#define sizeof_TPM_DAA_ISSUER(s) (2 + (20 * 6) + 26 ) + + /* + * TPM_DAA_TPM ([TPM_Part2], Section 22.8) +@@ -1738,6 +1739,7 @@ typedef struct tdTPM_DAA_TPM { + TPM_DIGEST DAA_rekey; + UINT32 DAA_count; + } TPM_DAA_TPM; ++#define sizeof_TPM_DAA_TPM(s) (2 + (4 * 20) + 4) + + /* + * TPM_DAA_CONTEXT ([TPM_Part2], Section 22.9) +@@ -1752,6 +1754,7 @@ typedef struct tdTPM_DAA_CONTEXT { + BYTE DAA_scratch[256]; + BYTE DAA_stage; + } TPM_DAA_CONTEXT; ++#define sizeof_TPM_DAA_CONTEXT(s) (2 + (3 * 20) + 256 + 1) + + /* + * TPM_DAA_JOINDATA ([TPM_Part2], Section 22.10) +@@ -1763,6 +1766,7 @@ typedef struct tdTPM_DAA_JOINDATA { + BYTE DAA_join_u1[138]; /* WATCH: 138 (v1.2 rev 85) */ + TPM_DIGEST DAA_digest_n0; + } TPM_DAA_JOINDATA; ++#define sizeof_TPM_DAA_JOINDATA(s) (1 + 1 + 20) + + /* + * TPM_DAA_BLOB ([TPM_Part2], Section 22.12) +@@ -2033,6 +2037,7 @@ typedef struct tdTPM_STCLEAR_DATA { + TPM_COUNT_ID countID; + //UINT32 ownerReference; + } TPM_STCLEAR_DATA; ++#define sizeof_TPM_STCLEAR_DATA(s) (2 + 20 + 4) + + /* + * TPM_SESSION_DATA +@@ -2069,6 +2074,11 @@ typedef struct tdTPM_DAA_SESSION_DATA { + TPM_DAA_JOINDATA DAA_joinSession; + TPM_HANDLE handle; + } TPM_DAA_SESSION_DATA; ++#define sizeof_TPM_DAA_SESSION_DATA(s) ( 1 \ ++ + sizeof_TPM_DAA_ISSUER(s.DAA_issuerSettings) \ ++ + sizeof_TPM_DAA_TPM(s.DAA_tpmSpecific) \ ++ + sizeof_TPM_DAA_CONTEXT(s.DAA_session) \ ++ + sizeof_TPM_DAA_JOINDATA(s.DAA_joinSession) + 4) + + /* + * TPM_STANY_DATA ([TPM_Part2], Section 7.6) +@@ -2095,6 +2105,17 @@ typedef struct tdTPM_STANY_DATA { + TPM_DAA_SESSION_DATA sessionsDAA[TPM_MAX_SESSIONS_DAA]; + TPM_TRANSHANDLE transExclusive; + } TPM_STANY_DATA; ++#define sizeof_TPM_STANY_DATA(s) (2 + 20 + 20 + 1 \ ++ + sizeof_TPM_CURRENT_TICKS(s.currentTicks) \ ++ + 4 + (4 * TPM_MAX_SESSION_LIST) \ ++ + (sizeof_TPM_SESSION_DATA(s.sessions[0]) * TPM_MAX_SESSION_LIST) \ ++ + (sizeof_TPM_DAA_SESSION_DATA(s.sessionsDAA[0]) * TPM_MAX_SESSIONS_DAA) + 4) ++ ++#define sizeof_TPM_PERMANENT_DATA(s) (2 + 4 + 4*20 \ ++ + sizeof_RSA(s.endorsementKey) + TPM_ORD_MAX/8 \ ++ + (1+TPM_MAX_KEYS)*sizeof_TPM_KEY_DATA(s.srk) \ ++ + TPM_NUM_PCR*(sizeof_TPM_PCR_ATTRIBUTES(x)+20) \ ++ + TPM_MAX_COUNTERS*sizeof_TPM_COUNTER_VALUE2(x) + 1 + 4 + 20) + + /* + * TPM_DATA diff -r 533b0709a68f -r 18587d3e94c8 tools/vtpm/tpm_emulator.patch --- a/tools/vtpm/tpm_emulator.patch Tue Jun 27 11:13:24 2006 +0100 +++ b/tools/vtpm/tpm_emulator.patch Tue Jun 27 11:14:19 2006 +0100 @@ -1,13 +1,13 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ -diff -uprN orig/tpm_emulator-0.3-x86_64/AUTHORS tpm_emulator/AUTHORS ---- orig/tpm_emulator-0.3-x86_64/AUTHORS 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/AUTHORS 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/AUTHORS tpm_emulator/AUTHORS +--- tpm_emulator-0.3-x86_64/AUTHORS 2006-08-29 15:07:21.618299064 -0700 ++++ tpm_emulator/AUTHORS 2006-08-29 15:26:17.099679656 -0700 @@ -1,2 +1,3 @@ Mario Strasser <mast@xxxxxxx> Heiko Stamer <stamer@xxxxxxxx> [DAA] +INTEL Corp <> [Dropped to Ring3] -diff -uprN orig/tpm_emulator-0.3-x86_64/ChangeLog tpm_emulator/ChangeLog ---- orig/tpm_emulator-0.3-x86_64/ChangeLog 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/ChangeLog 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/ChangeLog tpm_emulator/ChangeLog +--- tpm_emulator-0.3-x86_64/ChangeLog 2006-08-29 15:07:21.618299064 -0700 ++++ tpm_emulator/ChangeLog 2006-08-29 15:26:17.100679504 -0700 @@ -1,3 +1,6 @@ +2005-08-16 Intel Corp + * Moved module out of kernel to run as a ring 3 app @@ -15,9 +15,122 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ 2005-12-24 Mario Strasser <mast@xxxxxxx> * tpm_transport.c, tpm_marshalling.c, tpm_structures.h: Transport session functionality added -diff -uprN orig/tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c tpm_emulator/crypto/gmp_kernel_wrapper.c ---- orig/tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c 2006-06-05 09:54:21.000000000 -0700 -+++ tpm_emulator/crypto/gmp_kernel_wrapper.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/Makefile tpm_emulator/Makefile +--- tpm_emulator-0.3-x86_64/Makefile 2006-08-29 15:08:20.532342768 -0700 ++++ tpm_emulator/Makefile 2006-08-29 15:27:39.559143912 -0700 +@@ -1,22 +1,31 @@ + # Software-Based Trusted Platform Module (TPM) Emulator for Linux + # Copyright (C) 2004 Mario Strasser <mast@xxxxxxx> ++# Copyright (C) 2006 INTEL Corp. + # + # $Id: Makefile 69 2005-12-13 12:55:52Z mast $ + +-# kernel settings +-KERNEL_RELEASE := $(shell uname -r) +-KERNEL_BUILD := /lib/modules/$(KERNEL_RELEASE)/build +-MOD_SUBDIR := misc + COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/) + + # module settings +-MODULE_NAME := tpm_emulator ++BIN := tpm_emulator + VERSION_MAJOR := 0 + VERSION_MINOR := 3 + VERSION_BUILD := $(shell date +"%s") + +-# enable/disable DEBUG messages +-EXTRA_CFLAGS += -Wall -DDEBUG -g ++# Installation program and options ++INSTALL = install ++INSTALL_PROG = $(INSTALL) -m0755 ++INSTALL_DIR = $(INSTALL) -d -m0755 ++ ++# Xen tools installation directory ++TOOLS_INSTALL_DIR = $(DESTDIR)/usr/bin ++ ++CC := gcc ++CFLAGS += -g -Wall $(INCLUDE) -DDEBUG ++CFLAGS += -I. -Itpm ++ ++# Is the simulator running in it's own vm? ++#CFLAGS += -DVTPM_MULTI_VM + + ifeq ($(COMPILE_ARCH),x86_64) + LIBDIR = lib64 +@@ -34,38 +43,31 @@ DIRS := . crypto tpm + SRCS := $(foreach dir, $(DIRS), $(wildcard $(src)/$(dir)/*.c)) + OBJS := $(patsubst %.c, %.o, $(SRCS)) + SRCS += $(foreach dir, $(DIRS), $(wildcard $(src)/$(dir)/*.h)) +-DISTSRC := ./README ./AUTHORS ./ChangeLog ./Makefile $(SRCS) +-DISTDIR := tpm_emulator-$(VERSION_MAJOR).$(VERSION_MINOR) + +-obj-m := $(MODULE_NAME).o +-$(MODULE_NAME)-objs := $(patsubst $(src)/%.o, %.o, $(OBJS)) crypto/libgmp.a ++obj-m := $(BIN) ++$(BIN)-objs := $(patsubst $(src)/%.o, %.o, $(OBJS)) crypto/libgmp.a + + EXTRA_CFLAGS += -I$(src) -I$(src)/crypto -I$(src)/tpm + + # do not print "Entering directory ..." + MAKEFLAGS += --no-print-directory + +-all: $(src)/crypto/gmp.h $(src)/crypto/libgmp.a version +- @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules ++all: $(BIN) ++ ++$(BIN): $(src)/crypto/gmp.h $(src)/crypto/libgmp.a version $(SRCS) $(OBJS) ++ $(CC) $(CFLAGS) $(OBJS) $(src)/crypto/libgmp.a -o $(BIN) ++ ++%.o: %.c ++ $(CC) $(CFLAGS) -c $< -o $@ + +-install: +- @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules_install +- test -d /var/tpm || mkdir /var/tpm +- test -c /dev/tpm || mknod /dev/tpm c 10 224 +- chmod 666 /dev/tpm +- depmod -a ++install: $(BIN) ++ $(INSTALL_PROG) $(BIN) $(TOOLS_INSTALL_DIR) + + clean: +- @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) clean +- rm -f $(src)/crypto/gmp.h $(src)/crypto/libgmp.a ++ rm -f $(src)/crypto/gmp.h $(src)/crypto/libgmp.a $(OBJS) + +-dist: $(DISTSRC) +- rm -rf $(DISTDIR) +- mkdir $(DISTDIR) +- cp --parents $(DISTSRC) $(DISTDIR)/ +- rm -f $(DISTDIR)/crypto/gmp.h +- tar -chzf $(DISTDIR).tar.gz $(DISTDIR) +- rm -rf $(DISTDIR) ++mrproper: clean ++ rm -f $(BIN) tpm_version.h + + $(src)/crypto/libgmp.a: + test -f $(src)/crypto/libgmp.a || ln -s $(GMP_LIB) $(src)/crypto/libgmp.a +diff -uprN tpm_emulator-0.3-x86_64/README tpm_emulator/README +--- tpm_emulator-0.3-x86_64/README 2006-08-29 15:07:43.530967832 -0700 ++++ tpm_emulator/README 2006-08-29 15:26:17.105678744 -0700 +@@ -13,7 +13,8 @@ $Id: README 78 2006-01-07 10:45:39Z mast + Copyright + -------------------------------------------------------------------------- + Copyright (C) 2004 Mario Strasser <mast@xxxxxxx> and Swiss Federal +-Institute of Technology (ETH) Zurich. ++ Institute of Technology (ETH) Zurich. ++Copyright (C) 2005 INTEL Corp + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by +diff -uprN tpm_emulator-0.3-x86_64/README.1st tpm_emulator/README.1st +--- tpm_emulator-0.3-x86_64/README.1st 1969-12-31 16:00:00.000000000 -0800 ++++ tpm_emulator/README.1st 2006-08-29 15:26:17.105678744 -0700 +@@ -0,0 +1 @@ ++Note that you must manually create /tmp/tpm_in.fifo and /tmp/tpm_out.fifo for this emulator to work. +diff -uprN tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c tpm_emulator/crypto/gmp_kernel_wrapper.c +--- tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c 2006-08-29 15:07:43.525968592 -0700 ++++ tpm_emulator/crypto/gmp_kernel_wrapper.c 2006-08-29 15:26:17.101679352 -0700 @@ -1,5 +1,6 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -77,9 +190,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ } } -diff -uprN orig/tpm_emulator-0.3-x86_64/crypto/rsa.c tpm_emulator/crypto/rsa.c ---- orig/tpm_emulator-0.3-x86_64/crypto/rsa.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/crypto/rsa.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/crypto/rsa.c tpm_emulator/crypto/rsa.c +--- tpm_emulator-0.3-x86_64/crypto/rsa.c 2006-08-29 15:07:21.618299064 -0700 ++++ tpm_emulator/crypto/rsa.c 2006-08-29 15:26:17.102679200 -0700 @@ -1,5 +1,6 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -105,8 +218,8 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ sha1_final(&ctx, &msg[1]); if (memcmp(&msg[1], &msg[1 + SHA1_DIGEST_LENGTH], SHA1_DIGEST_LENGTH) != 0) return -1; -diff -uprN orig/tpm_emulator-0.3-x86_64/linux_module.c tpm_emulator/linux_module.c ---- orig/tpm_emulator-0.3-x86_64/linux_module.c 2006-06-05 09:54:21.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/linux_module.c tpm_emulator/linux_module.c +--- tpm_emulator-0.3-x86_64/linux_module.c 2006-08-29 15:07:43.526968440 -0700 +++ tpm_emulator/linux_module.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,194 +0,0 @@ -/* Software-Based Trusted Platform Module (TPM) Emulator for Linux @@ -303,9 +416,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ - return (ticks > 0) ? ticks : 1; -} - -diff -uprN orig/tpm_emulator-0.3-x86_64/linux_module.h tpm_emulator/linux_module.h ---- orig/tpm_emulator-0.3-x86_64/linux_module.h 2006-06-05 09:54:21.000000000 -0700 -+++ tpm_emulator/linux_module.h 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/linux_module.h tpm_emulator/linux_module.h +--- tpm_emulator-0.3-x86_64/linux_module.h 2006-08-29 15:07:43.527968288 -0700 ++++ tpm_emulator/linux_module.h 2006-08-29 15:26:17.103679048 -0700 @@ -1,5 +1,6 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -405,121 +518,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ #define BE16_TO_CPU(x) __be16_to_cpu(x) #define LE16_TO_CPU(x) __le16_to_cpu(x) -diff -uprN orig/tpm_emulator-0.3-x86_64/Makefile tpm_emulator/Makefile ---- orig/tpm_emulator-0.3-x86_64/Makefile 2006-06-05 09:54:21.000000000 -0700 -+++ tpm_emulator/Makefile 2006-06-02 13:36:03.000000000 -0700 -@@ -1,22 +1,31 @@ - # Software-Based Trusted Platform Module (TPM) Emulator for Linux - # Copyright (C) 2004 Mario Strasser <mast@xxxxxxx> -+# Copyright (C) 2006 INTEL Corp. - # - # $Id: Makefile 69 2005-12-13 12:55:52Z mast $ - --# kernel settings --KERNEL_RELEASE := $(shell uname -r) --KERNEL_BUILD := /lib/modules/$(KERNEL_RELEASE)/build --MOD_SUBDIR := misc - COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/) - - # module settings --MODULE_NAME := tpm_emulator -+BIN := tpm_emulator - VERSION_MAJOR := 0 - VERSION_MINOR := 3 - VERSION_BUILD := $(shell date +"%s") - --# enable/disable DEBUG messages --EXTRA_CFLAGS += -Wall -DDEBUG -g -+# Installation program and options -+INSTALL = install -+INSTALL_PROG = $(INSTALL) -m0755 -+INSTALL_DIR = $(INSTALL) -d -m0755 -+ -+# Xen tools installation directory -+TOOLS_INSTALL_DIR = $(DESTDIR)/usr/bin -+ -+CC := gcc -+CFLAGS += -g -Wall $(INCLUDE) -DDEBUG -+CFLAGS += -I. -Itpm -+ -+# Is the simulator running in it's own vm? -+#CFLAGS += -DVTPM_MULTI_VM - - ifeq ($(COMPILE_ARCH),x86_64) - LIBDIR = lib64 -@@ -34,38 +43,31 @@ DIRS := . crypto tpm - SRCS := $(foreach dir, $(DIRS), $(wildcard $(src)/$(dir)/*.c)) - OBJS := $(patsubst %.c, %.o, $(SRCS)) - SRCS += $(foreach dir, $(DIRS), $(wildcard $(src)/$(dir)/*.h)) --DISTSRC := ./README ./AUTHORS ./ChangeLog ./Makefile $(SRCS) --DISTDIR := tpm_emulator-$(VERSION_MAJOR).$(VERSION_MINOR) - --obj-m := $(MODULE_NAME).o --$(MODULE_NAME)-objs := $(patsubst $(src)/%.o, %.o, $(OBJS)) crypto/libgmp.a -+obj-m := $(BIN) -+$(BIN)-objs := $(patsubst $(src)/%.o, %.o, $(OBJS)) crypto/libgmp.a - - EXTRA_CFLAGS += -I$(src) -I$(src)/crypto -I$(src)/tpm - - # do not print "Entering directory ..." - MAKEFLAGS += --no-print-directory - --all: $(src)/crypto/gmp.h $(src)/crypto/libgmp.a version -- @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules -+all: $(BIN) -+ -+$(BIN): $(src)/crypto/gmp.h $(src)/crypto/libgmp.a version $(SRCS) $(OBJS) -+ $(CC) $(CFLAGS) $(OBJS) $(src)/crypto/libgmp.a -o $(BIN) -+ -+%.o: %.c -+ $(CC) $(CFLAGS) -c $< -o $@ - - install: -- @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules_install -- test -d /var/tpm || mkdir /var/tpm -- test -c /dev/tpm || mknod /dev/tpm c 10 224 -- chmod 666 /dev/tpm -- depmod -a -+ $(INSTALL_PROG) $(BIN) $(TOOLS_INSTALL_DIR) - - clean: -- @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) clean -- rm -f $(src)/crypto/gmp.h $(src)/crypto/libgmp.a -+ rm -f $(src)/crypto/gmp.h $(src)/crypto/libgmp.a $(OBJS) - --dist: $(DISTSRC) -- rm -rf $(DISTDIR) -- mkdir $(DISTDIR) -- cp --parents $(DISTSRC) $(DISTDIR)/ -- rm -f $(DISTDIR)/crypto/gmp.h -- tar -chzf $(DISTDIR).tar.gz $(DISTDIR) -- rm -rf $(DISTDIR) -+mrproper: clean -+ rm -f $(BIN) tpm_version.h - - $(src)/crypto/libgmp.a: - test -f $(src)/crypto/libgmp.a || ln -s $(GMP_LIB) $(src)/crypto/libgmp.a -diff -uprN orig/tpm_emulator-0.3-x86_64/README tpm_emulator/README ---- orig/tpm_emulator-0.3-x86_64/README 2006-06-05 09:54:21.000000000 -0700 -+++ tpm_emulator/README 2006-06-02 13:36:03.000000000 -0700 -@@ -13,7 +13,8 @@ $Id: README 78 2006-01-07 10:45:39Z mast - Copyright - -------------------------------------------------------------------------- - Copyright (C) 2004 Mario Strasser <mast@xxxxxxx> and Swiss Federal --Institute of Technology (ETH) Zurich. -+ Institute of Technology (ETH) Zurich. -+Copyright (C) 2005 INTEL Corp - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by -diff -uprN orig/tpm_emulator-0.3-x86_64/README.1st tpm_emulator/README.1st ---- orig/tpm_emulator-0.3-x86_64/README.1st 1969-12-31 16:00:00.000000000 -0800 -+++ tpm_emulator/README.1st 2006-06-02 13:37:48.000000000 -0700 -@@ -0,0 +1 @@ -+Note that you must manually create /tmp/tpm_in.fifo and /tmp/tpm_out.fifo for this emulator to work. -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_audit.c tpm_emulator/tpm/tpm_audit.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_audit.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/tpm/tpm_audit.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_audit.c tpm_emulator/tpm/tpm_audit.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_audit.c 2006-08-29 15:07:21.620298760 -0700 ++++ tpm_emulator/tpm/tpm_audit.c 2006-08-29 15:26:17.107678440 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -582,9 +583,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ return TPM_SUCCESS; } - -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_authorization.c tpm_emulator/tpm/tpm_authorization.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_authorization.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/tpm/tpm_authorization.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_authorization.c tpm_emulator/tpm/tpm_authorization.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_authorization.c 2006-08-29 15:07:21.620298760 -0700 ++++ tpm_emulator/tpm/tpm_authorization.c 2006-08-29 15:26:17.108678288 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -602,9 +603,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ info("tpm_verify_auth(%08x)", auth->authHandle); /* get dedicated authorization or transport session */ -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_capability.c tpm_emulator/tpm/tpm_capability.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_capability.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/tpm/tpm_capability.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_capability.c tpm_emulator/tpm/tpm_capability.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_capability.c 2006-08-29 15:07:21.620298760 -0700 ++++ tpm_emulator/tpm/tpm_capability.c 2006-08-29 15:26:17.109678136 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -627,9 +628,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ } } - -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_cmd_handler.c tpm_emulator/tpm/tpm_cmd_handler.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_cmd_handler.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/tpm/tpm_cmd_handler.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_cmd_handler.c tpm_emulator/tpm/tpm_cmd_handler.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_cmd_handler.c 2006-08-29 15:07:21.621298608 -0700 ++++ tpm_emulator/tpm/tpm_cmd_handler.c 2006-08-29 15:26:17.113677528 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -687,9 +688,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ /* setup authorisation as well as response tag and size */ memset(rsp, 0, sizeof(*rsp)); switch (req->tag) { -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c tpm_emulator/tpm/tpm_crypto.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c 2006-06-05 09:54:21.000000000 -0700 -+++ tpm_emulator/tpm/tpm_crypto.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c tpm_emulator/tpm/tpm_crypto.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c 2006-08-29 15:07:43.531967680 -0700 ++++ tpm_emulator/tpm/tpm_crypto.c 2006-08-29 15:26:17.114677376 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -712,9 +713,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ return TPM_SUCCESS; } - -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_daa.c tpm_emulator/tpm/tpm_daa.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_daa.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/tpm/tpm_daa.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_daa.c tpm_emulator/tpm/tpm_daa.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_daa.c 2006-08-29 15:07:21.622298456 -0700 ++++ tpm_emulator/tpm/tpm_daa.c 2006-08-29 15:26:17.119676616 -0700 @@ -700,14 +700,14 @@ info("tested until here"); sizeof(session->DAA_tpmSpecific.DAA_rekey)); sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, @@ -869,9 +870,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH); mpz_init(f), mpz_init(q); mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch); -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_data.c tpm_emulator/tpm/tpm_data.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_data.c 2006-06-05 09:54:21.000000000 -0700 -+++ tpm_emulator/tpm/tpm_data.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_data.c tpm_emulator/tpm/tpm_data.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_data.c 2006-08-29 15:08:20.535342312 -0700 ++++ tpm_emulator/tpm/tpm_data.c 2006-08-29 15:26:17.121676312 -0700 @@ -150,44 +150,43 @@ void tpm_release_data(void) #ifdef TPM_STORE_TO_FILE @@ -938,7 +939,7 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ if (res != *data_length) { tpm_free(*data); return -1; -@@ -267,7 +266,7 @@ int tpm_restore_permanent_data(void) +@@ -278,7 +277,7 @@ int tpm_restore_permanent_data(void) int tpm_erase_permanent_data(void) { @@ -947,9 +948,297 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ return res; } -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_deprecated.c tpm_emulator/tpm/tpm_deprecated.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_deprecated.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/tpm/tpm_deprecated.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_data.c.orig tpm_emulator/tpm/tpm_data.c.orig +--- tpm_emulator-0.3-x86_64/tpm/tpm_data.c.orig 1969-12-31 16:00:00.000000000 -0800 ++++ tpm_emulator/tpm/tpm_data.c.orig 2006-08-29 15:26:08.469991568 -0700 +@@ -0,0 +1,284 @@ ++/* Software-Based Trusted Platform Module (TPM) Emulator for Linux ++ * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, ++ * Swiss Federal Institute of Technology (ETH) Zurich ++ * ++ * This module is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published ++ * by the Free Software Foundation; either version 2 of the License, ++ * or (at your option) any later version. ++ * ++ * This module is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * $Id: tpm_data.c 36 2005-10-26 20:31:19Z hstamer $ ++ */ ++ ++#include "tpm_emulator.h" ++#include "tpm_structures.h" ++#include "tpm_marshalling.h" ++#include "linux_module.h" ++ ++TPM_DATA tpmData; ++ ++BOOL tpm_get_physical_presence(void) ++{ ++ return (tpmData.stclear.flags.physicalPresence || TRUE); ++} ++ ++static inline void init_pcr_attr(int pcr, BOOL reset, BYTE rl, BYTE el) ++{ ++ int i; ++ tpmData.permanent.data.pcrAttrib[pcr].pcrReset = reset; ++ for (i = 0; i < TPM_NUM_LOCALITY; i++) { ++ tpmData.permanent.data.pcrAttrib[pcr].pcrResetLocal[i] = (rl & (1 << i)); ++ tpmData.permanent.data.pcrAttrib[pcr].pcrExtendLocal[i] = (el & (1 << i)); ++ } ++} ++ ++void tpm_init_data(void) ++{ ++ /* endorsement key */ ++ uint8_t ek_n[] = "\xa8\xdb\xa9\x42\xa8\xf3\xb8\x06\x85\x90\x76\x93\xad\xf7" ++ "\x74\xec\x3f\xd3\x3d\x9d\xe8\x2e\xff\x15\xed\x0e\xce\x5f\x93" ++ "\x92\xeb\xd1\x96\x2b\x72\x18\x81\x79\x12\x9d\x9c\x40\xd7\x1a" ++ "\x21\xda\x5f\x56\xe0\xc9\x48\x31\xdd\x96\xdc\xbb\x45\xc6\x8e" ++ "\xad\x58\x23\xcb\xbe\xbb\x13\x2d\x6b\x86\xc5\x57\xf5\xdd\x48" ++ "\xc1\x3d\xcd\x4d\xda\x81\xc4\x43\x17\xaa\x05\x40\x33\x62\x0a" ++ "\x59\xdb\x28\xcd\xb5\x08\x31\xbb\x06\xf5\xf7\x71\xae\x21\xa8" ++ "\xf2\x2f\x0e\x17\x80\x5d\x9c\xdf\xaa\xe9\x89\x09\x54\x65\x2b" ++ "\x46\xfb\x9d\xb2\x00\x70\x63\x0d\x9a\x6d\x3d\x5e\x11\x78\x65" ++ "\x90\xe6\x26\xee\x77\xbe\x08\xff\x07\x60\x5a\xcc\xf1\x0a\xbd" ++ "\x44\x92\x6b\xca\xb6\xce\x66\xf9\x93\x40\xae\xf3\x3e\x53\x02" ++ "\x3c\xa6\x81\xb3\xbe\xad\x6e\x6c\xa6\xf0\xeb\xdf\xe9\xa2\x83" ++ "\x36\x0e\x52\x0d\x64\x17\xd9\xff\xa1\x74\x7c\x2b\xbc\x6a\xcc" ++ "\xe5\x4e\xb4\x52\xd9\xec\x43\xbd\x26\x6a\x2b\x19\x19\x6e\x97" ++ "\xb8\x1d\x9f\x7b\xe7\x32\x2d\xdd\x7c\x51\xc8\xe4\xf3\x02\xd4" ++ "\x7c\x90\x44\xa0\x33\x72\x81\x75\xa9\x16\x27\x5c\x00\x1d\x07" ++ "\x81\xd4\xf7\xac\xcb\xfe\xd6\x60\x03\x6f\x7a\xcc\x00\xd1\xc4" ++ "\x85\x37"; ++ uint8_t ek_e[] = "\x01\x00\x01"; ++ uint8_t ek_p[] = "\xd7\xea\x61\x15\x8b\xa3\x71\xdf\xa8\x74\x77\xca\x88\x95" ++ "\xd0\x76\x17\x43\x2c\xf6\x23\x27\x44\xb9\x0e\x18\x35\x7e\xe4" ++ "\xc3\xcb\x13\x6e\xfc\x38\x02\x1e\x77\x26\x40\x9d\x17\xb2\x39" ++ "\x9c\x7f\x5f\x98\xe6\xf2\x55\x0c\x12\x05\x4c\xb3\x51\xae\x29" ++ "\xe7\xcd\xce\x41\x0b\x28\x4d\x97\x13\x4b\x60\xc8\xd8\x70\x81" ++ "\xf9\x1c\x12\x44\xdf\x53\x0a\x87\x9d\x33\x92\x4a\x34\x69\xf0" ++ "\x70\x5e\x1b\x5d\x65\xc7\x84\x90\xa2\x62\xdf\x83\x14\x10\x69" ++ "\xe2\xa7\x18\x43\xd7\x1f\x60\xc9\x03\x8f\xd6\xa4\xce\xb2\x9d" ++ "\x40\x37\x70\x17\x4c\xe3\x69\xd4\x59"; ++ uint8_t ek_q[] = "\xc8\x34\xd2\xd0\x7c\xfa\xdc\x68\xe2\x72\xd7\x92\xe2\x50" ++ "\x93\xfc\xbb\x72\x55\x4d\x6b\x7a\x0c\x0b\xcf\x87\x66\x1f\x81" ++ "\x71\xf3\x50\xcb\xaa\xe6\x43\x7e\xbe\x11\xc4\xec\x00\x53\xf4" ++ "\x78\x13\x2b\x59\x26\x4a\x9f\x91\x61\x8f\xa7\x07\x64\x11\x5a" ++ "\xf4\xaf\x9c\x9b\x5a\x5d\x69\x20\x17\x55\x74\xba\xd8\xe4\x59" ++ "\x39\x1a\x0a\x7b\x4a\x30\xf0\xc8\x7f\xd9\xaf\x72\xc5\xb6\x71" ++ "\xd1\xc0\x8b\x5b\xa2\x2e\xa7\x15\xca\x50\x75\x10\x48\x9c\x2b" ++ "\x18\xb9\x67\x8f\x5d\x64\xc3\x28\x9f\x2f\x16\x2f\x08\xda\x47" ++ "\xec\x86\x43\x0c\x80\x99\x07\x34\x0f"; ++ int i; ++ /* reset all data to NULL, FALSE or 0 */ ++ memset(&tpmData, 0, sizeof(tpmData)); ++ tpmData.permanent.data.tag = TPM_TAG_PERMANENT_DATA; ++ /* set permanent flags */ ++ tpmData.permanent.flags.tag = TPM_TAG_PERMANENT_FLAGS; ++ tpmData.permanent.flags.disable = FALSE; ++ tpmData.permanent.flags.deactivated = FALSE; ++ tpmData.permanent.flags.ownership = TRUE; ++ tpmData.permanent.flags.readPubek = TRUE; ++ tpmData.permanent.flags.allowMaintenance = TRUE; ++ tpmData.permanent.flags.enableRevokeEK = TRUE; ++ /* set TPM vision */ ++ tpmData.permanent.data.version.major = 1; ++ tpmData.permanent.data.version.minor = 2; ++ tpmData.permanent.data.version.revMajor = VERSION_MAJOR; ++ tpmData.permanent.data.version.revMinor = VERSION_MINOR; ++ /* setup PCR attributes */ ++ for (i = 0; i < min(16, TPM_NUM_PCR); i++) { ++ init_pcr_attr(i, FALSE, 0x00, 0x1f); ++ } ++ if (TPM_NUM_PCR >= 24) { ++ init_pcr_attr(16, TRUE, 0x1f, 0x1f); ++ init_pcr_attr(17, TRUE, 0x10, 0x1c); ++ init_pcr_attr(18, TRUE, 0x10, 0x1c); ++ init_pcr_attr(19, TRUE, 0x10, 0x0c); ++ init_pcr_attr(20, TRUE, 0x14, 0x0e); ++ init_pcr_attr(21, TRUE, 0x04, 0x04); ++ init_pcr_attr(22, TRUE, 0x04, 0x04); ++ init_pcr_attr(23, TRUE, 0x1f, 0x1f); ++ } ++ for (i = 24; i < TPM_NUM_PCR; i++) { ++ init_pcr_attr(i, TRUE, 0x00, 0x00); ++ } ++ /* set tick type */ ++ tpmData.permanent.data.tickType = TICK_INC; ++#ifdef TPM_GENERATE_EK ++ /* generate a new endorsement key */ ++ rsa_generate_key(&tpmData.permanent.data.endorsementKey, 2048); ++#else ++ /* setup endorsement key */ ++ rsa_import_key(&tpmData.permanent.data.endorsementKey, ++ RSA_MSB_FIRST, ek_n, 256, ek_e, 3, ek_p, ek_q); ++#endif ++#ifdef TPM_GENERATE_SEED_DAA ++ /* generate the DAA seed (cf. [TPM_Part2], v1.2 rev 85, Section 7.4) */ ++ tpm_get_random_bytes(tpmData.permanent.data.tpmDAASeed.digest, ++ sizeof(tpmData.permanent.data.tpmDAASeed.digest)); ++#else ++ /* FIXME: setup DAA seed */ ++ memcpy(tpmData.permanent.data.tpmDAASeed.digest, ++ "\x77\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" ++ "\x00\x00\x00\x77", 20); ++#endif ++ ++ memcpy(tpmData.permanent.data.ekReset.nonce, "\xde\xad\xbe\xef", 4); ++} ++ ++void tpm_release_data(void) ++{ ++ int i; ++ /* release the EK, SRK as well as all other rsa keys */ ++ if (tpmData.permanent.data.endorsementKey.size > 0) ++ rsa_release_private_key(&tpmData.permanent.data.endorsementKey); ++ if (tpmData.permanent.data.srk.valid) ++ rsa_release_private_key(&tpmData.permanent.data.srk.key); ++ for (i = 0; i < TPM_MAX_KEYS; i++) ++ if (tpmData.permanent.data.keys[i].valid) ++ rsa_release_private_key(&tpmData.permanent.data.keys[i].key); ++} ++ ++#ifdef TPM_STORE_TO_FILE ++ ++#include <linux/fs.h> ++#include <linux/unistd.h> ++#include <asm/uaccess.h> ++ ++#define TPM_STORAGE_FILE "/var/tpm/tpm_emulator-1.2." STR(VERSION_MAJOR) "." STR(VERSION_MINOR) ++ ++static int write_to_file(uint8_t *data, size_t data_length) ++{ ++ int res; ++ struct file *fp; ++ mm_segment_t old_fs = get_fs(); ++ fp = filp_open(TPM_STORAGE_FILE, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR); ++ if (IS_ERR(fp)) return -1; ++ set_fs(get_ds()); ++ res = fp->f_op->write(fp, data, data_length, &fp->f_pos); ++ set_fs(old_fs); ++ filp_close(fp, NULL); ++ return (res == data_length) ? 0 : -1; ++} ++ ++static int read_from_file(uint8_t **data, size_t *data_length) ++{ ++ int res; ++ struct file *fp; ++ mm_segment_t old_fs = get_fs(); ++ fp = filp_open(TPM_STORAGE_FILE, O_RDONLY, 0); ++ if (IS_ERR(fp)) return -1; ++ *data_length = (size_t)fp->f_dentry->d_inode->i_size; ++ /* *data_length = i_size_read(fp->f_dentry->d_inode); */ ++ *data = tpm_malloc(*data_length); ++ if (*data == NULL) { ++ filp_close(fp, NULL); ++ return -1; ++ } ++ set_fs(get_ds()); ++ res = fp->f_op->read(fp, *data, *data_length, &fp->f_pos); ++ set_fs(old_fs); ++ filp_close(fp, NULL); ++ if (res != *data_length) { ++ tpm_free(*data); ++ return -1; ++ } ++ return 0; ++} ++ ++#else ++ ++static int write_to_file(uint8_t *data, size_t data_length) ++{ ++ info("TPM_STORE_TO_FILE disabled, no data written"); ++ return 0; ++} ++ ++static int read_from_file(uint8_t **data, size_t *data_length) ++{ ++ info("TPM_STORE_TO_FILE disabled, no data read"); ++ return 0; ++} ++ ++#endif /* TPM_STORE_TO_FILE */ ++ ++int tpm_store_permanent_data(void) ++{ ++ uint8_t *buf, *ptr; ++ UINT32 buf_length, len; ++ ++ /* marshal data */ ++ buf_length = len = 4 + sizeof_TPM_STCLEAR_FLAGS(tpmData.stclear.flags) ++ + sizeof_TPM_PERMANENT_FLAGS(tpmData.permanent.flags) ++ + sizeof_TPM_STANY_FLAGS(tpmData.stany.flags) + 2 ++ + sizeof_TPM_STCLEAR_DATA(tpmData.stclear.data) ++ + sizeof_TPM_PERMANENT_DATA(tpmData.permanent.data) ++ + sizeof_TPM_STANY_DATA(tpmData.stany.data); ++ buf = ptr = tpm_malloc(buf_length); ++ if (buf == NULL ++ || tpm_marshal_TPM_VERSION(&ptr, &len, &tpmData.permanent.data.version) ++ || tpm_marshal_TPM_STCLEAR_FLAGS(&ptr, &len, &tpmData.stclear.flags) ++ || tpm_marshal_TPM_PERMANENT_FLAGS(&ptr, &len, &tpmData.permanent.flags) ++ || tpm_marshal_TPM_STANY_FLAGS(&ptr, &len, &tpmData.stany.flags) ++ || tpm_marshal_BOOL(&ptr, &len, tpmData.permanent.flags.selfTestSucceeded) ++ || tpm_marshal_BOOL(&ptr, &len, tpmData.permanent.flags.owned) ++ || tpm_marshal_TPM_STCLEAR_DATA(&ptr, &len, &tpmData.stclear.data) ++ || tpm_marshal_TPM_PERMANENT_DATA(&ptr, &len, &tpmData.permanent.data) ++ || tpm_marshal_TPM_STANY_DATA(&ptr, &len, &tpmData.stany.data)) { ++ tpm_free(buf); ++ return -1; ++ } ++ ++ if (write_to_file(buf, buf_length - len)) { ++ tpm_free(buf); ++ return -1; ++ } ++ tpm_free(buf); ++ return 0; ++} ++ ++int tpm_restore_permanent_data(void) ++{ ++ uint8_t *buf, *ptr; ++ size_t buf_length; ++ UINT32 len; ++ TPM_VERSION ver; ++ ++ /* read data */ ++ if (read_from_file(&buf, &buf_length)) return -1; ++ ptr = buf; ++ len = (uint32_t) buf_length; ++ /* unmarshal data */ ++ if (tpm_unmarshal_TPM_VERSION(&ptr, &len, &ver) ++ || memcmp(&ver, &tpmData.permanent.data.version, sizeof(TPM_VERSION)) ++ || tpm_unmarshal_TPM_STCLEAR_FLAGS(&ptr, &len, &tpmData.stclear.flags) ++ || tpm_unmarshal_TPM_PERMANENT_FLAGS(&ptr, &len, &tpmData.permanent.flags) ++ || tpm_unmarshal_TPM_STANY_FLAGS(&ptr, &len, &tpmData.stany.flags) ++ || tpm_unmarshal_BOOL(&ptr, &len, &tpmData.permanent.flags.selfTestSucceeded) ++ || tpm_unmarshal_BOOL(&ptr, &len, &tpmData.permanent.flags.owned) ++ || tpm_unmarshal_TPM_STCLEAR_DATA(&ptr, &len, &tpmData.stclear.data) ++ || tpm_unmarshal_TPM_PERMANENT_DATA(&ptr, &len, &tpmData.permanent.data) ++ || tpm_unmarshal_TPM_STANY_DATA(&ptr, &len, &tpmData.stany.data)) { ++ tpm_free(buf); ++ return -1; ++ } ++ ++ tpm_free(buf); ++ return 0; ++} ++ ++int tpm_erase_permanent_data(void) ++{ ++ int res = write_to_file("", 0); ++ return res; ++} ++ +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_deprecated.c tpm_emulator/tpm/tpm_deprecated.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_deprecated.c 2006-08-29 15:07:21.622298456 -0700 ++++ tpm_emulator/tpm/tpm_deprecated.c 2006-08-29 15:26:17.122676160 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -976,9 +1265,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ authContextSize, &contextBlob); if (res != TPM_SUCCESS) return res; len = *authContextSize; -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_emulator.h tpm_emulator/tpm/tpm_emulator.h ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_emulator.h 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/tpm/tpm_emulator.h 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_emulator.h tpm_emulator/tpm/tpm_emulator.h +--- tpm_emulator-0.3-x86_64/tpm/tpm_emulator.h 2006-08-29 15:07:21.648294504 -0700 ++++ tpm_emulator/tpm/tpm_emulator.h 2006-08-29 15:26:17.122676160 -0700 @@ -1,5 +1,6 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -996,9 +1285,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ #undef TPM_GENERATE_SEED_DAA #define TPM_MANUFACTURER 0x4554485A /* 'ETHZ' */ -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_integrity.c tpm_emulator/tpm/tpm_integrity.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_integrity.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/tpm/tpm_integrity.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_integrity.c tpm_emulator/tpm/tpm_integrity.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_integrity.c 2006-08-29 15:07:21.645294960 -0700 ++++ tpm_emulator/tpm/tpm_integrity.c 2006-08-29 15:26:17.123676008 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -1012,9 +1301,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ return TPM_SUCCESS; } - -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_structures.h tpm_emulator/tpm/tpm_structures.h ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_structures.h 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/tpm/tpm_structures.h 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_structures.h tpm_emulator/tpm/tpm_structures.h +--- tpm_emulator-0.3-x86_64/tpm/tpm_structures.h 2006-08-29 15:08:20.545340792 -0700 ++++ tpm_emulator/tpm/tpm_structures.h 2006-08-29 15:26:17.125675704 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -1032,9 +1321,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ #include "crypto/rsa.h" /* -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_testing.c tpm_emulator/tpm/tpm_testing.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_testing.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/tpm/tpm_testing.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_testing.c tpm_emulator/tpm/tpm_testing.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_testing.c 2006-08-29 15:07:21.646294808 -0700 ++++ tpm_emulator/tpm/tpm_testing.c 2006-08-29 15:26:17.127675400 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -1150,9 +1439,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ rsa_private_key_t priv_key; rsa_public_key_t pub_key; -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_ticks.c tpm_emulator/tpm/tpm_ticks.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_ticks.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/tpm/tpm_ticks.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_ticks.c tpm_emulator/tpm/tpm_ticks.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_ticks.c 2006-08-29 15:07:21.646294808 -0700 ++++ tpm_emulator/tpm/tpm_ticks.c 2006-08-29 15:26:17.128675248 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -1235,9 +1524,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ } -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_transport.c tpm_emulator/tpm/tpm_transport.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_transport.c 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/tpm/tpm_transport.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_transport.c tpm_emulator/tpm/tpm_transport.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_transport.c 2006-08-29 15:07:21.647294656 -0700 ++++ tpm_emulator/tpm/tpm_transport.c 2006-08-29 15:26:17.129675096 -0700 @@ -59,7 +59,7 @@ static int decrypt_transport_auth(TPM_KE static void transport_log_in(TPM_COMMAND_CODE ordinal, BYTE parameters[20], BYTE pubKeyHash[20], TPM_DIGEST *transDigest) @@ -1295,9 +1584,19 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ memcpy(&buf[30], session->transInternal.transDigest.digest, 20); /* sign info structure */ res = tpm_sign(key, auth1, TRUE, buf, sizeof(buf), signature, signSize); -diff -uprN orig/tpm_emulator-0.3-x86_64/tpmd.c tpm_emulator/tpmd.c ---- orig/tpm_emulator-0.3-x86_64/tpmd.c 1969-12-31 16:00:00.000000000 -0800 -+++ tpm_emulator/tpmd.c 2006-06-02 13:36:03.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm_version.h tpm_emulator/tpm_version.h +--- tpm_emulator-0.3-x86_64/tpm_version.h 2006-08-29 15:07:21.649294352 -0700 ++++ tpm_emulator/tpm_version.h 1969-12-31 16:00:00.000000000 -0800 +@@ -1,6 +0,0 @@ +-#ifndef _TPM_VERSION_H_ +-#define _TPM_VERSION_H_ +-#define VERSION_MAJOR 0 +-#define VERSION_MINOR 3 +-#define VERSION_BUILD 1136893683 +-#endif /* _TPM_VERSION_H_ */ +diff -uprN tpm_emulator-0.3-x86_64/tpmd.c tpm_emulator/tpmd.c +--- tpm_emulator-0.3-x86_64/tpmd.c 1969-12-31 16:00:00.000000000 -0800 ++++ tpm_emulator/tpmd.c 2006-08-29 15:26:17.130674944 -0700 @@ -0,0 +1,141 @@ +/* Software-Based Trusted Platform Module (TPM) Emulator for Linux + * Copyright (C) 2005 INTEL Corp @@ -1440,13 +1739,3 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ + close(tpm_rx_fh); + +} -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm_version.h tpm_emulator/tpm_version.h ---- orig/tpm_emulator-0.3-x86_64/tpm_version.h 2006-01-10 04:21:45.000000000 -0800 -+++ tpm_emulator/tpm_version.h 1969-12-31 16:00:00.000000000 -0800 -@@ -1,6 +0,0 @@ --#ifndef _TPM_VERSION_H_ --#define _TPM_VERSION_H_ --#define VERSION_MAJOR 0 --#define VERSION_MINOR 3 --#define VERSION_BUILD 1136893683 --#endif /* _TPM_VERSION_H_ */ diff -r 533b0709a68f -r 18587d3e94c8 tools/vtpm/vtpm.patch --- a/tools/vtpm/vtpm.patch Tue Jun 27 11:13:24 2006 +0100 +++ b/tools/vtpm/vtpm.patch Tue Jun 27 11:14:19 2006 +0100 @@ -1,13 +1,13 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ -diff -uprN orig/tpm_emulator-0.3-x86_64/AUTHORS vtpm/AUTHORS ---- orig/tpm_emulator-0.3-x86_64/AUTHORS 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/AUTHORS 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/AUTHORS vtpm/AUTHORS +--- tpm_emulator-0.3-x86_64/AUTHORS 2006-08-29 15:07:21.618299064 -0700 ++++ vtpm/AUTHORS 2006-08-29 15:12:07.184886344 -0700 @@ -1,2 +1,3 @@ Mario Strasser <mast@xxxxxxx> Heiko Stamer <stamer@xxxxxxxx> [DAA] +INTEL Corp <> [VTPM Extensions] -diff -uprN orig/tpm_emulator-0.3-x86_64/ChangeLog vtpm/ChangeLog ---- orig/tpm_emulator-0.3-x86_64/ChangeLog 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/ChangeLog 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/ChangeLog vtpm/ChangeLog +--- tpm_emulator-0.3-x86_64/ChangeLog 2006-08-29 15:07:21.618299064 -0700 ++++ vtpm/ChangeLog 2006-08-29 15:12:07.185886192 -0700 @@ -1,3 +1,7 @@ +2005-08-16 Intel Corp + * Moved module out of kernel to run as a ring 3 app @@ -16,9 +16,117 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ 2005-12-24 Mario Strasser <mast@xxxxxxx> * tpm_transport.c, tpm_marshalling.c, tpm_structures.h: Transport session functionality added -diff -uprN orig/tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c vtpm/crypto/gmp_kernel_wrapper.c ---- orig/tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c 2006-05-30 12:28:02.000000000 -0700 -+++ vtpm/crypto/gmp_kernel_wrapper.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/Makefile vtpm/Makefile +--- tpm_emulator-0.3-x86_64/Makefile 2006-08-29 15:08:20.532342768 -0700 ++++ vtpm/Makefile 2006-08-29 15:13:53.023796384 -0700 +@@ -1,22 +1,31 @@ + # Software-Based Trusted Platform Module (TPM) Emulator for Linux + # Copyright (C) 2004 Mario Strasser <mast@xxxxxxx> ++# Copyright (C) 2006 INTEL Corp. + # + # $Id: Makefile 69 2005-12-13 12:55:52Z mast $ + +-# kernel settings +-KERNEL_RELEASE := $(shell uname -r) +-KERNEL_BUILD := /lib/modules/$(KERNEL_RELEASE)/build +-MOD_SUBDIR := misc + COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/) + + # module settings +-MODULE_NAME := tpm_emulator ++BIN := vtpmd + VERSION_MAJOR := 0 + VERSION_MINOR := 3 + VERSION_BUILD := $(shell date +"%s") + +-# enable/disable DEBUG messages +-EXTRA_CFLAGS += -Wall -DDEBUG -g ++# Installation program and options ++INSTALL = install ++INSTALL_PROG = $(INSTALL) -m0755 ++INSTALL_DIR = $(INSTALL) -d -m0755 ++ ++# Xen tools installation directory ++TOOLS_INSTALL_DIR = $(DESTDIR)/usr/bin ++ ++CC := gcc ++CFLAGS += -g -Wall $(INCLUDE) -DDEBUG ++CFLAGS += -I. -Itpm -I../../vtpm_manager/manager ++ ++# Is the simulator running in it's own vm? ++#CFLAGS += -DVTPM_MULTI_VM + + ifeq ($(COMPILE_ARCH),x86_64) + LIBDIR = lib64 +@@ -34,38 +43,31 @@ DIRS := . crypto tpm + SRCS := $(foreach dir, $(DIRS), $(wildcard $(src)/$(dir)/*.c)) + OBJS := $(patsubst %.c, %.o, $(SRCS)) + SRCS += $(foreach dir, $(DIRS), $(wildcard $(src)/$(dir)/*.h)) +-DISTSRC := ./README ./AUTHORS ./ChangeLog ./Makefile $(SRCS) +-DISTDIR := tpm_emulator-$(VERSION_MAJOR).$(VERSION_MINOR) + +-obj-m := $(MODULE_NAME).o +-$(MODULE_NAME)-objs := $(patsubst $(src)/%.o, %.o, $(OBJS)) crypto/libgmp.a ++obj-m := $(BIN) ++$(BIN)-objs := $(patsubst $(src)/%.o, %.o, $(OBJS)) crypto/libgmp.a + + EXTRA_CFLAGS += -I$(src) -I$(src)/crypto -I$(src)/tpm + + # do not print "Entering directory ..." + MAKEFLAGS += --no-print-directory + +-all: $(src)/crypto/gmp.h $(src)/crypto/libgmp.a version +- @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules ++all: $(BIN) ++ ++$(BIN): $(src)/crypto/gmp.h $(src)/crypto/libgmp.a version $(SRCS) $(OBJS) ++ $(CC) $(CFLAGS) $(OBJS) $(src)/crypto/libgmp.a -o $(BIN) ++ ++%.o: %.c ++ $(CC) $(CFLAGS) -c $< -o $@ + +-install: +- @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules_install +- test -d /var/tpm || mkdir /var/tpm +- test -c /dev/tpm || mknod /dev/tpm c 10 224 +- chmod 666 /dev/tpm +- depmod -a ++install: $(BIN) ++ $(INSTALL_PROG) $(BIN) $(TOOLS_INSTALL_DIR) + + clean: +- @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) clean +- rm -f $(src)/crypto/gmp.h $(src)/crypto/libgmp.a ++ rm -f $(src)/crypto/gmp.h $(src)/crypto/libgmp.a $(OBJS) + +-dist: $(DISTSRC) +- rm -rf $(DISTDIR) +- mkdir $(DISTDIR) +- cp --parents $(DISTSRC) $(DISTDIR)/ +- rm -f $(DISTDIR)/crypto/gmp.h +- tar -chzf $(DISTDIR).tar.gz $(DISTDIR) +- rm -rf $(DISTDIR) ++mrproper: clean ++ rm -f $(BIN) tpm_version.h + + $(src)/crypto/libgmp.a: + test -f $(src)/crypto/libgmp.a || ln -s $(GMP_LIB) $(src)/crypto/libgmp.a +diff -uprN tpm_emulator-0.3-x86_64/README vtpm/README +--- tpm_emulator-0.3-x86_64/README 2006-08-29 15:07:43.530967832 -0700 ++++ vtpm/README 2006-08-29 15:12:07.190885432 -0700 +@@ -13,7 +13,8 @@ $Id: README 78 2006-01-07 10:45:39Z mast + Copyright + -------------------------------------------------------------------------- + Copyright (C) 2004 Mario Strasser <mast@xxxxxxx> and Swiss Federal +-Institute of Technology (ETH) Zurich. ++ Institute of Technology (ETH) Zurich. ++Copyright (C) 2005 INTEL Corp + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by +diff -uprN tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c vtpm/crypto/gmp_kernel_wrapper.c +--- tpm_emulator-0.3-x86_64/crypto/gmp_kernel_wrapper.c 2006-08-29 15:07:43.525968592 -0700 ++++ vtpm/crypto/gmp_kernel_wrapper.c 2006-08-29 15:12:07.186886040 -0700 @@ -1,5 +1,6 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -78,9 +186,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ } } -diff -uprN orig/tpm_emulator-0.3-x86_64/crypto/rsa.c vtpm/crypto/rsa.c ---- orig/tpm_emulator-0.3-x86_64/crypto/rsa.c 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/crypto/rsa.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/crypto/rsa.c vtpm/crypto/rsa.c +--- tpm_emulator-0.3-x86_64/crypto/rsa.c 2006-08-29 15:07:21.618299064 -0700 ++++ vtpm/crypto/rsa.c 2006-08-29 15:12:07.187885888 -0700 @@ -1,5 +1,6 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -106,8 +214,8 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ sha1_final(&ctx, &msg[1]); if (memcmp(&msg[1], &msg[1 + SHA1_DIGEST_LENGTH], SHA1_DIGEST_LENGTH) != 0) return -1; -diff -uprN orig/tpm_emulator-0.3-x86_64/linux_module.c vtpm/linux_module.c ---- orig/tpm_emulator-0.3-x86_64/linux_module.c 2006-05-30 12:28:02.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/linux_module.c vtpm/linux_module.c +--- tpm_emulator-0.3-x86_64/linux_module.c 2006-08-29 15:07:43.526968440 -0700 +++ vtpm/linux_module.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,194 +0,0 @@ -/* Software-Based Trusted Platform Module (TPM) Emulator for Linux @@ -304,9 +412,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ - return (ticks > 0) ? ticks : 1; -} - -diff -uprN orig/tpm_emulator-0.3-x86_64/linux_module.h vtpm/linux_module.h ---- orig/tpm_emulator-0.3-x86_64/linux_module.h 2006-05-30 12:28:02.000000000 -0700 -+++ vtpm/linux_module.h 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/linux_module.h vtpm/linux_module.h +--- tpm_emulator-0.3-x86_64/linux_module.h 2006-08-29 15:07:43.527968288 -0700 ++++ vtpm/linux_module.h 2006-08-29 15:12:07.189885584 -0700 @@ -1,5 +1,6 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -406,116 +514,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ #define BE16_TO_CPU(x) __be16_to_cpu(x) #define LE16_TO_CPU(x) __le16_to_cpu(x) -diff -uprN orig/tpm_emulator-0.3-x86_64/Makefile vtpm/Makefile ---- orig/tpm_emulator-0.3-x86_64/Makefile 2006-05-30 12:28:02.000000000 -0700 -+++ vtpm/Makefile 2006-05-30 12:23:26.000000000 -0700 -@@ -1,22 +1,31 @@ - # Software-Based Trusted Platform Module (TPM) Emulator for Linux - # Copyright (C) 2004 Mario Strasser <mast@xxxxxxx> -+# Copyright (C) 2006 INTEL Corp. - # - # $Id: Makefile 69 2005-12-13 12:55:52Z mast $ - --# kernel settings --KERNEL_RELEASE := $(shell uname -r) --KERNEL_BUILD := /lib/modules/$(KERNEL_RELEASE)/build --MOD_SUBDIR := misc - COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/) - - # module settings --MODULE_NAME := tpm_emulator -+BIN := vtpmd - VERSION_MAJOR := 0 - VERSION_MINOR := 3 - VERSION_BUILD := $(shell date +"%s") - --# enable/disable DEBUG messages --EXTRA_CFLAGS += -Wall -DDEBUG -g -+# Installation program and options -+INSTALL = install -+INSTALL_PROG = $(INSTALL) -m0755 -+INSTALL_DIR = $(INSTALL) -d -m0755 -+ -+# Xen tools installation directory -+TOOLS_INSTALL_DIR = $(DESTDIR)/usr/bin -+ -+CC := gcc -+CFLAGS += -g -Wall $(INCLUDE) -DDEBUG -+CFLAGS += -I. -Itpm -I../../vtpm_manager/manager -+ -+# Is the simulator running in it's own vm? -+#CFLAGS += -DVTPM_MULTI_VM - - ifeq ($(COMPILE_ARCH),x86_64) - LIBDIR = lib64 -@@ -34,38 +43,31 @@ DIRS := . crypto tpm - SRCS := $(foreach dir, $(DIRS), $(wildcard $(src)/$(dir)/*.c)) - OBJS := $(patsubst %.c, %.o, $(SRCS)) - SRCS += $(foreach dir, $(DIRS), $(wildcard $(src)/$(dir)/*.h)) --DISTSRC := ./README ./AUTHORS ./ChangeLog ./Makefile $(SRCS) --DISTDIR := tpm_emulator-$(VERSION_MAJOR).$(VERSION_MINOR) - --obj-m := $(MODULE_NAME).o --$(MODULE_NAME)-objs := $(patsubst $(src)/%.o, %.o, $(OBJS)) crypto/libgmp.a -+obj-m := $(BIN) -+$(BIN)-objs := $(patsubst $(src)/%.o, %.o, $(OBJS)) crypto/libgmp.a - - EXTRA_CFLAGS += -I$(src) -I$(src)/crypto -I$(src)/tpm - - # do not print "Entering directory ..." - MAKEFLAGS += --no-print-directory - --all: $(src)/crypto/gmp.h $(src)/crypto/libgmp.a version -- @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules -+all: $(BIN) -+ -+$(BIN): $(src)/crypto/gmp.h $(src)/crypto/libgmp.a version $(SRCS) $(OBJS) -+ $(CC) $(CFLAGS) $(OBJS) $(src)/crypto/libgmp.a -o $(BIN) -+ -+%.o: %.c -+ $(CC) $(CFLAGS) -c $< -o $@ - - install: -- @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules_install -- test -d /var/tpm || mkdir /var/tpm -- test -c /dev/tpm || mknod /dev/tpm c 10 224 -- chmod 666 /dev/tpm -- depmod -a -+ $(INSTALL_PROG) $(BIN) $(TOOLS_INSTALL_DIR) - - clean: -- @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) clean -- rm -f $(src)/crypto/gmp.h $(src)/crypto/libgmp.a -+ rm -f $(src)/crypto/gmp.h $(src)/crypto/libgmp.a $(OBJS) - --dist: $(DISTSRC) -- rm -rf $(DISTDIR) -- mkdir $(DISTDIR) -- cp --parents $(DISTSRC) $(DISTDIR)/ -- rm -f $(DISTDIR)/crypto/gmp.h -- tar -chzf $(DISTDIR).tar.gz $(DISTDIR) -- rm -rf $(DISTDIR) -+mrproper: clean -+ rm -f $(BIN) tpm_version.h - - $(src)/crypto/libgmp.a: - test -f $(src)/crypto/libgmp.a || ln -s $(GMP_LIB) $(src)/crypto/libgmp.a -diff -uprN orig/tpm_emulator-0.3-x86_64/README vtpm/README ---- orig/tpm_emulator-0.3-x86_64/README 2006-05-30 12:28:02.000000000 -0700 -+++ vtpm/README 2006-05-30 12:23:26.000000000 -0700 -@@ -13,7 +13,8 @@ $Id: README 78 2006-01-07 10:45:39Z mast - Copyright - -------------------------------------------------------------------------- - Copyright (C) 2004 Mario Strasser <mast@xxxxxxx> and Swiss Federal --Institute of Technology (ETH) Zurich. -+ Institute of Technology (ETH) Zurich. -+Copyright (C) 2005 INTEL Corp - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_audit.c vtpm/tpm/tpm_audit.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_audit.c 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/tpm/tpm_audit.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_audit.c vtpm/tpm/tpm_audit.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_audit.c 2006-08-29 15:07:21.620298760 -0700 ++++ vtpm/tpm/tpm_audit.c 2006-08-29 15:12:07.191885280 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -578,9 +579,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ return TPM_SUCCESS; } - -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_authorization.c vtpm/tpm/tpm_authorization.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_authorization.c 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/tpm/tpm_authorization.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_authorization.c vtpm/tpm/tpm_authorization.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_authorization.c 2006-08-29 15:07:21.620298760 -0700 ++++ vtpm/tpm/tpm_authorization.c 2006-08-29 15:12:07.192885128 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -598,9 +599,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ info("tpm_verify_auth(%08x)", auth->authHandle); /* get dedicated authorization or transport session */ -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_capability.c vtpm/tpm/tpm_capability.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_capability.c 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/tpm/tpm_capability.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_capability.c vtpm/tpm/tpm_capability.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_capability.c 2006-08-29 15:07:21.620298760 -0700 ++++ vtpm/tpm/tpm_capability.c 2006-08-29 15:12:07.193884976 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -623,9 +624,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ } } - -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_cmd_handler.c vtpm/tpm/tpm_cmd_handler.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_cmd_handler.c 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/tpm/tpm_cmd_handler.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_cmd_handler.c vtpm/tpm/tpm_cmd_handler.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_cmd_handler.c 2006-08-29 15:07:21.621298608 -0700 ++++ vtpm/tpm/tpm_cmd_handler.c 2006-08-29 15:12:07.197884368 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -683,9 +684,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ /* setup authorisation as well as response tag and size */ memset(rsp, 0, sizeof(*rsp)); switch (req->tag) { -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c vtpm/tpm/tpm_crypto.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c 2006-05-30 12:28:02.000000000 -0700 -+++ vtpm/tpm/tpm_crypto.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c vtpm/tpm/tpm_crypto.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_crypto.c 2006-08-29 15:07:43.531967680 -0700 ++++ vtpm/tpm/tpm_crypto.c 2006-08-29 15:12:07.198884216 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -708,9 +709,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ return TPM_SUCCESS; } - -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_daa.c vtpm/tpm/tpm_daa.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_daa.c 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/tpm/tpm_daa.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_daa.c vtpm/tpm/tpm_daa.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_daa.c 2006-08-29 15:07:21.622298456 -0700 ++++ vtpm/tpm/tpm_daa.c 2006-08-29 15:12:07.203883456 -0700 @@ -700,14 +700,14 @@ info("tested until here"); sizeof(session->DAA_tpmSpecific.DAA_rekey)); sha1_update(&sha1, (BYTE*) &session->DAA_tpmSpecific.DAA_count, @@ -865,9 +866,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ sha1_final(&sha1, scratch + SHA1_DIGEST_LENGTH); mpz_init(f), mpz_init(q); mpz_import(f, 2 * SHA1_DIGEST_LENGTH, 1, 1, 0, 0, scratch); -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_data.c vtpm/tpm/tpm_data.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_data.c 2006-05-30 12:28:02.000000000 -0700 -+++ vtpm/tpm/tpm_data.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_data.c vtpm/tpm/tpm_data.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_data.c 2006-08-29 15:08:20.535342312 -0700 ++++ vtpm/tpm/tpm_data.c 2006-08-29 15:12:07.206883000 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -1177,7 +1178,7 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ } #else -@@ -267,7 +462,6 @@ int tpm_restore_permanent_data(void) +@@ -278,7 +473,6 @@ int tpm_restore_permanent_data(void) int tpm_erase_permanent_data(void) { @@ -1186,9 +1187,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ return res; } - -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_deprecated.c vtpm/tpm/tpm_deprecated.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_deprecated.c 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/tpm/tpm_deprecated.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_deprecated.c vtpm/tpm/tpm_deprecated.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_deprecated.c 2006-08-29 15:07:21.622298456 -0700 ++++ vtpm/tpm/tpm_deprecated.c 2006-08-29 15:12:07.207882848 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -1215,9 +1216,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ authContextSize, &contextBlob); if (res != TPM_SUCCESS) return res; len = *authContextSize; -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_emulator.h vtpm/tpm/tpm_emulator.h ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_emulator.h 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/tpm/tpm_emulator.h 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_emulator.h vtpm/tpm/tpm_emulator.h +--- tpm_emulator-0.3-x86_64/tpm/tpm_emulator.h 2006-08-29 15:07:21.648294504 -0700 ++++ vtpm/tpm/tpm_emulator.h 2006-08-29 15:12:07.208882696 -0700 @@ -1,5 +1,6 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -1235,9 +1236,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ #undef TPM_GENERATE_SEED_DAA #define TPM_MANUFACTURER 0x4554485A /* 'ETHZ' */ -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_integrity.c vtpm/tpm/tpm_integrity.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_integrity.c 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/tpm/tpm_integrity.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_integrity.c vtpm/tpm/tpm_integrity.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_integrity.c 2006-08-29 15:07:21.645294960 -0700 ++++ vtpm/tpm/tpm_integrity.c 2006-08-29 15:12:07.208882696 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -1251,9 +1252,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ return TPM_SUCCESS; } - -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_structures.h vtpm/tpm/tpm_structures.h ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_structures.h 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/tpm/tpm_structures.h 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_structures.h vtpm/tpm/tpm_structures.h +--- tpm_emulator-0.3-x86_64/tpm/tpm_structures.h 2006-08-29 15:08:20.545340792 -0700 ++++ vtpm/tpm/tpm_structures.h 2006-08-29 15:12:07.211882240 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -1271,9 +1272,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ #include "crypto/rsa.h" /* -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_testing.c vtpm/tpm/tpm_testing.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_testing.c 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/tpm/tpm_testing.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_testing.c vtpm/tpm/tpm_testing.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_testing.c 2006-08-29 15:07:21.646294808 -0700 ++++ vtpm/tpm/tpm_testing.c 2006-08-29 15:12:07.213881936 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -1389,9 +1390,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ rsa_private_key_t priv_key; rsa_public_key_t pub_key; -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_ticks.c vtpm/tpm/tpm_ticks.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_ticks.c 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/tpm/tpm_ticks.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_ticks.c vtpm/tpm/tpm_ticks.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_ticks.c 2006-08-29 15:07:21.646294808 -0700 ++++ vtpm/tpm/tpm_ticks.c 2006-08-29 15:12:07.235878592 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>, @@ -1474,9 +1475,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ } -diff -uprN orig/tpm_emulator-0.3-x86_64/tpm/tpm_transport.c vtpm/tpm/tpm_transport.c ---- orig/tpm_emulator-0.3-x86_64/tpm/tpm_transport.c 2006-01-10 04:21:45.000000000 -0800 -+++ vtpm/tpm/tpm_transport.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpm/tpm_transport.c vtpm/tpm/tpm_transport.c +--- tpm_emulator-0.3-x86_64/tpm/tpm_transport.c 2006-08-29 15:07:21.647294656 -0700 ++++ vtpm/tpm/tpm_transport.c 2006-08-29 15:12:07.239877984 -0700 @@ -59,7 +59,7 @@ static int decrypt_transport_auth(TPM_KE static void transport_log_in(TPM_COMMAND_CODE ordinal, BYTE parameters[20], BYTE pubKeyHash[20], TPM_DIGEST *transDigest) @@ -1534,9 +1535,9 @@ diff -uprN orig/tpm_emulator-0.3-x86_64/ memcpy(&buf[30], session->transInternal.transDigest.digest, 20); /* sign info structure */ res = tpm_sign(key, auth1, TRUE, buf, sizeof(buf), signature, signSize); -diff -uprN orig/tpm_emulator-0.3-x86_64/tpmd.c vtpm/tpmd.c ---- orig/tpm_emulator-0.3-x86_64/tpmd.c 1969-12-31 16:00:00.000000000 -0800 -+++ vtpm/tpmd.c 2006-05-30 12:23:26.000000000 -0700 +diff -uprN tpm_emulator-0.3-x86_64/tpmd.c vtpm/tpmd.c +--- tpm_emulator-0.3-x86_64/tpmd.c 1969-12-31 16:00:00.000000000 -0800 ++++ vtpm/tpmd.c 2006-08-29 15:12:07.240877832 -0700 @@ -0,0 +1,207 @@ +/* Software-Based Trusted Platform Module (TPM) Emulator for Linux + * Copyright (C) 2005 INTEL Corp _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |