diff -r a4cf3e17bb25 tools/vtpm/Makefile --- a/tools/vtpm/Makefile Fri Sep 16 18:59:59 2005 +++ b/tools/vtpm/Makefile Mon Sep 19 16:18:48 2005 @@ -4,7 +4,7 @@ include $(XEN_ROOT)/tools/vtpm/Rules.mk # Dir name for emulator (as dom0 tpm driver) -TPM_EMULATOR_DIR = tpm_emulator-0.2 +TPM_EMULATOR_DIR = tpm_emulator # Dir name for vtpm instance VTPM_DIR = vtpm @@ -13,7 +13,7 @@ all: build -build: $(TPM_EMULATOR_TARFILE) extract patch build_sub +build: $(TPM_EMULATOR_DIR) $(VTPM_DIR) build_sub install: build $(MAKE) -C $(TPM_EMULATOR_DIR) $@ @@ -26,36 +26,32 @@ if [ -d $(VTPM_DIR) ]; \ then $(MAKE) -C $(VTPM_DIR) clean; \ fi + +mrproper: + rm -f $(TPM_EMULATOR_TARFILE) rm -rf $(TPM_EMULATOR_DIR) rm -rf $(VTPM_DIR) - -mrproper: clean - rm -f $(TPM_EMULATOR_TARFILE) # Download Swiss emulator $(TPM_EMULATOR_TARFILE): wget http://download.berlios.de/tpm-emulator/$(TPM_EMULATOR_TARFILE) # Create vtpm and TPM emulator dirs -extract: $(TPM_EMULATOR_DIR)/README $(VTPM_DIR)/README - -$(TPM_EMULATOR_DIR)/README: - -rm -rf $(TPM_EMULATOR_DIR) - tar -xzf $(TPM_EMULATOR_TARFILE) - -$(VTPM_DIR)/README: - -rm -rf $(VTPM_DIR) - cp -r --preserve $(TPM_EMULATOR_DIR) $(VTPM_DIR) - # apply patches for 1) used as dom0 tpm driver 2) used as vtpm device instance -patch: $(TPM_EMULATOR_DIR)/Makefile $(VTPM_DIR)/Makefile - -$(TPM_EMULATOR_DIR)/Makefile: tpm_emulator.patch +$(TPM_EMULATOR_DIR): $(TPM_EMULATOR_TARFILE) + tar -xzf $(TPM_EMULATOR_TARFILE); + mv tpm_emulator-0.2 $(TPM_EMULATOR_DIR); + -cd $(TPM_EMULATOR_DIR); \ + patch -p1 < ../tpm_emulator-0.2b-x86_64.patch; \ patch -p1 <../tpm_emulator.patch -$(VTPM_DIR)/Makefile: vtpm.patch +$(VTPM_DIR): $(TPM_EMULATOR_TARFILE) + tar -xzf $(TPM_EMULATOR_TARFILE); + mv tpm_emulator-0.2 $(VTPM_DIR); + -cd $(VTPM_DIR); \ + patch -p1 < ../tpm_emulator-0.2b-x86_64.patch; \ patch -p1 <../vtpm.patch build_sub: diff -r a4cf3e17bb25 tools/vtpm/README --- a/tools/vtpm/README Fri Sep 16 18:59:59 2005 +++ b/tools/vtpm/README Mon Sep 19 16:18:48 2005 @@ -23,6 +23,7 @@ - xen-unstable - IBM frontend/backend vtpm driver patch - vtpm_managerd +- GNU MP Big number library (GMP) vtpmd Flow (for vtpm_manager. vtpmd never run by default) ============================ diff -r a4cf3e17bb25 tools/vtpm/tpm_emulator.patch --- a/tools/vtpm/tpm_emulator.patch Fri Sep 16 18:59:59 2005 +++ b/tools/vtpm/tpm_emulator.patch Mon Sep 19 16:18:48 2005 @@ -1,12 +1,12 @@ -diff -uprN orig/tpm_emulator-0.2/AUTHORS tpm_emulator-0.2/AUTHORS ---- orig/tpm_emulator-0.2/AUTHORS 2005-08-17 10:58:36.000000000 -0700 -+++ tpm_emulator-0.2/AUTHORS 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/AUTHORS tpm_emulator/AUTHORS +--- orig/tpm_emulator-0.2-x86_64/AUTHORS 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator/AUTHORS 2005-09-14 20:27:22.000000000 -0700 @@ -1 +1,2 @@ Mario Strasser +INTEL Corp <> -diff -uprN orig/tpm_emulator-0.2/ChangeLog tpm_emulator-0.2/ChangeLog ---- orig/tpm_emulator-0.2/ChangeLog 2005-08-17 10:58:36.000000000 -0700 -+++ tpm_emulator-0.2/ChangeLog 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/ChangeLog tpm_emulator/ChangeLog +--- orig/tpm_emulator-0.2-x86_64/ChangeLog 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator/ChangeLog 2005-09-14 20:27:22.000000000 -0700 @@ -1,3 +1,7 @@ +2005-08-16: INTEL Corp + * Set default permissions to PCRs @@ -15,10 +15,29 @@ 2005-08-15 Mario Strasser * all: some typos corrected * tpm_integrity.c: bug in TPM_Extend fixed -diff -uprN orig/tpm_emulator-0.2/Makefile tpm_emulator-0.2/Makefile ---- orig/tpm_emulator-0.2/Makefile 2005-08-17 10:58:36.000000000 -0700 -+++ tpm_emulator-0.2/Makefile 2005-08-17 10:55:52.000000000 -0700 -@@ -1,15 +1,19 @@ +diff -uprN orig/tpm_emulator-0.2-x86_64/linux_module.h tpm_emulator/linux_module.h +--- orig/tpm_emulator-0.2-x86_64/linux_module.h 2005-09-15 19:21:14.844078720 -0700 ++++ tpm_emulator/linux_module.h 2005-09-14 20:27:22.000000000 -0700 +@@ -1,5 +1,6 @@ + /* Software-Based Trusted Platform Module (TPM) Emulator for Linux + * Copyright (C) 2004 Mario Strasser , ++ * Copyright (C) 2005 INTEL Corp. + * + * This module is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published +@@ -35,7 +36,7 @@ + #include "tpm_version.h" + + #define TPM_DEVICE_MINOR 224 +-#define TPM_DEVICE_NAME "tpm" ++#define TPM_DEVICE_NAME "tpm0" + #define TPM_MODULE_NAME "tpm_emulator" + + /* debug and log output functions */ +diff -uprN orig/tpm_emulator-0.2-x86_64/Makefile tpm_emulator/Makefile +--- orig/tpm_emulator-0.2-x86_64/Makefile 2005-09-15 19:21:14.845078568 -0700 ++++ tpm_emulator/Makefile 2005-09-14 20:27:22.000000000 -0700 +@@ -1,16 +1,20 @@ # Software-Based Trusted Platform Module (TPM) Emulator for Linux # Copyright (C) 2004 Mario Strasser +# Copyright (C) 2005 INTEL Corp. @@ -33,6 +52,7 @@ -KERNEL_BUILD := /lib/modules/$(KERNEL_RELEASE)/build +KERNEL_BUILD := $(XEN_ROOT)/linux-2.6.12-xen0 MOD_SUBDIR := misc + COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/) # module settings -MODULE_NAME := tpm_emulator @@ -40,7 +60,7 @@ VERSION_MAJOR := 0 VERSION_MINOR := 2 VERSION_BUILD := $(shell date +"%s") -@@ -27,11 +30,9 @@ DIRS := . crypto tpm +@@ -34,11 +38,9 @@ DIRS := . crypto tpm SRCS := $(foreach dir, $(DIRS), $(wildcard $(src)/$(dir)/*.c)) OBJS := $(patsubst %.c, %.o, $(SRCS)) SRCS += $(foreach dir, $(DIRS), $(wildcard $(src)/$(dir)/*.h)) @@ -54,7 +74,7 @@ EXTRA_CFLAGS += -I$(src) -I$(src)/crypto -I$(src)/tpm -@@ -42,23 +43,17 @@ all: $(src)/crypto/gmp.h $(src)/crypto/l +@@ -49,23 +51,17 @@ all: $(src)/crypto/gmp.h $(src)/crypto/l @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules install: @@ -84,9 +104,9 @@ $(src)/crypto/libgmp.a: test -f $(src)/crypto/libgmp.a || ln -s $(GMP_LIB) $(src)/crypto/libgmp.a -diff -uprN orig/tpm_emulator-0.2/README tpm_emulator-0.2/README ---- orig/tpm_emulator-0.2/README 2005-08-17 10:58:36.000000000 -0700 -+++ tpm_emulator-0.2/README 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/README tpm_emulator/README +--- orig/tpm_emulator-0.2-x86_64/README 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator/README 2005-09-14 20:27:22.000000000 -0700 @@ -13,7 +13,8 @@ $Id: README 8 2005-01-25 21:11:45Z jmoli Copyright -------------------------------------------------------------------------- @@ -97,28 +117,9 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -diff -uprN orig/tpm_emulator-0.2/linux_module.h tpm_emulator-0.2/linux_module.h ---- orig/tpm_emulator-0.2/linux_module.h 2005-08-17 10:58:36.000000000 -0700 -+++ tpm_emulator-0.2/linux_module.h 2005-08-17 10:55:52.000000000 -0700 -@@ -1,5 +1,6 @@ - /* Software-Based Trusted Platform Module (TPM) Emulator for Linux - * Copyright (C) 2004 Mario Strasser , -+ * Copyright (C) 2005 INTEL Corp. - * - * This module is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published -@@ -33,7 +34,7 @@ - #include "tpm_version.h" - - #define TPM_DEVICE_MINOR 224 --#define TPM_DEVICE_NAME "tpm" -+#define TPM_DEVICE_NAME "tpm0" - #define TPM_MODULE_NAME "tpm_emulator" - - /* debug and log output functions */ -diff -uprN orig/tpm_emulator-0.2/tpm/tpm_data.c tpm_emulator-0.2/tpm/tpm_data.c ---- orig/tpm_emulator-0.2/tpm/tpm_data.c 2005-08-17 10:58:36.000000000 -0700 -+++ tpm_emulator-0.2/tpm/tpm_data.c 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_data.c tpm_emulator/tpm/tpm_data.c +--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_data.c 2005-09-15 19:21:14.847078264 -0700 ++++ tpm_emulator/tpm/tpm_data.c 2005-09-14 20:27:22.000000000 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -139,13 +140,3 @@ tpmData.permanent.data.pcrAttrib[i].pcrReset = TRUE; } /* set tick type */ -diff -uprN orig/tpm_emulator-0.2/tpm_version.h tpm_emulator-0.2/tpm_version.h ---- orig/tpm_emulator-0.2/tpm_version.h 2005-08-17 10:58:36.000000000 -0700 -+++ tpm_emulator-0.2/tpm_version.h 2005-08-17 10:55:53.000000000 -0700 -@@ -2,5 +2,5 @@ - #define _TPM_VERSION_H_ - #define VERSION_MAJOR 0 - #define VERSION_MINOR 2 --#define VERSION_BUILD 1123950310 -+#define VERSION_BUILD 1124301353 - #endif /* _TPM_VERSION_H_ */ diff -r a4cf3e17bb25 tools/vtpm/vtpm.patch --- a/tools/vtpm/vtpm.patch Fri Sep 16 18:59:59 2005 +++ b/tools/vtpm/vtpm.patch Mon Sep 19 16:18:48 2005 @@ -1,12 +1,12 @@ -diff -uprN orig/tpm_emulator-0.2/AUTHORS vtpm/AUTHORS ---- orig/tpm_emulator-0.2/AUTHORS 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/AUTHORS 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/AUTHORS vtpm/AUTHORS +--- orig/tpm_emulator-0.2-x86_64/AUTHORS 2005-08-15 00:58:57.000000000 -0700 ++++ vtpm/AUTHORS 2005-09-14 20:27:22.000000000 -0700 @@ -1 +1,2 @@ Mario Strasser +INTEL Corp <> -diff -uprN orig/tpm_emulator-0.2/ChangeLog vtpm/ChangeLog ---- orig/tpm_emulator-0.2/ChangeLog 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/ChangeLog 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/ChangeLog vtpm/ChangeLog +--- orig/tpm_emulator-0.2-x86_64/ChangeLog 2005-08-15 00:58:57.000000000 -0700 ++++ vtpm/ChangeLog 2005-09-14 20:27:22.000000000 -0700 @@ -1,3 +1,7 @@ +2005-08-16 Intel Corp + Moved module out of kernel to run as a ring 3 app @@ -15,115 +15,9 @@ 2005-08-15 Mario Strasser * all: some typos corrected * tpm_integrity.c: bug in TPM_Extend fixed -diff -uprN orig/tpm_emulator-0.2/Makefile vtpm/Makefile ---- orig/tpm_emulator-0.2/Makefile 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/Makefile 2005-08-17 10:55:52.000000000 -0700 -@@ -1,21 +1,29 @@ - # Software-Based Trusted Platform Module (TPM) Emulator for Linux - # Copyright (C) 2004 Mario Strasser -+# Copyright (C) 2005 INTEL Corp. - # - # $Id: Makefile 10 2005-04-26 20:59:50Z mast $ - --# kernel settings --KERNEL_RELEASE := $(shell uname -r) --KERNEL_BUILD := /lib/modules/$(KERNEL_RELEASE)/build --MOD_SUBDIR := misc -- - # module settings --MODULE_NAME := tpm_emulator -+BIN := vtpmd - VERSION_MAJOR := 0 - VERSION_MINOR := 2 - VERSION_BUILD := $(shell date +"%s") - --# enable/disable DEBUG messages --EXTRA_CFLAGS += -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 - - # GNU MP configuration - GMP_LIB := /usr/lib/libgmp.a -@@ -27,38 +35,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) - - $(src)/crypto/libgmp.a: - test -f $(src)/crypto/libgmp.a || ln -s $(GMP_LIB) $(src)/crypto/libgmp.a -diff -uprN orig/tpm_emulator-0.2/README vtpm/README ---- orig/tpm_emulator-0.2/README 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/README 2005-08-17 10:55:52.000000000 -0700 -@@ -13,7 +13,8 @@ $Id: README 8 2005-01-25 21:11:45Z jmoli - Copyright - -------------------------------------------------------------------------- - Copyright (C) 2004 Mario Strasser 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.2/crypto/gmp_kernel_wrapper.c vtpm/crypto/gmp_kernel_wrapper.c ---- orig/tpm_emulator-0.2/crypto/gmp_kernel_wrapper.c 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/crypto/gmp_kernel_wrapper.c 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c vtpm/crypto/gmp_kernel_wrapper.c +--- orig/tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c 2005-09-15 19:21:42.508873032 -0700 ++++ vtpm/crypto/gmp_kernel_wrapper.c 2005-09-15 19:25:37.319176440 -0700 @@ -1,5 +1,6 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -154,9 +48,9 @@ { - void *ret = (void*)kmalloc(size, GFP_KERNEL); - if (!ret) panic(KERN_CRIT TPM_MODULE_NAME -- "GMP: cannot allocate memory (size=%u)\n", size); +- "GMP: cannot allocate memory (size=%Zu)\n", size); + void *ret = (void*)malloc(size); -+ if (!ret) error("GMP: cannot allocate memory (size=%u)\n", size); ++ if (!ret) error("GMP: cannot allocate memory (size=%Zu)\n", size); return ret; } @@ -165,9 +59,10 @@ { - void *ret = (void*)kmalloc(new_size, GFP_KERNEL); - if (!ret) panic(KERN_CRIT TPM_MODULE_NAME "GMP: Cannot reallocate memory " +- "(old_size=%Zu new_size=%Zu)\n", old_size, new_size); + void *ret = (void*)malloc(new_size); + if (!ret) error("GMP: Cannot reallocate memory " - "(old_size=%u new_size=%u)\n", old_size, new_size); ++ "(old_size=%Zu new_size=%Zu)\n", old_size, new_size); memcpy(ret, oldptr, old_size); - kfree(oldptr); + free(oldptr); @@ -183,9 +78,9 @@ } } -diff -uprN orig/tpm_emulator-0.2/crypto/rsa.c vtpm/crypto/rsa.c ---- orig/tpm_emulator-0.2/crypto/rsa.c 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/crypto/rsa.c 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/crypto/rsa.c vtpm/crypto/rsa.c +--- orig/tpm_emulator-0.2-x86_64/crypto/rsa.c 2005-08-15 00:58:57.000000000 -0700 ++++ vtpm/crypto/rsa.c 2005-09-14 20:27:22.000000000 -0700 @@ -1,5 +1,6 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -211,8 +106,8 @@ sha1_final(&ctx, &msg[1]); if (memcmp(&msg[1], &msg[1 + SHA1_DIGEST_LENGTH], SHA1_DIGEST_LENGTH) != 0) return -1; -diff -uprN orig/tpm_emulator-0.2/linux_module.c vtpm/linux_module.c ---- orig/tpm_emulator-0.2/linux_module.c 2005-08-17 10:58:36.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/linux_module.c vtpm/linux_module.c +--- orig/tpm_emulator-0.2-x86_64/linux_module.c 2005-09-15 19:22:40.343080896 -0700 +++ vtpm/linux_module.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,163 +0,0 @@ -/* Software-Based Trusted Platform Module (TPM) Emulator for Linux @@ -283,7 +178,7 @@ - -static ssize_t tpm_read(struct file *file, char *buf, size_t count, loff_t *ppos) -{ -- debug("%s(%d)", __FUNCTION__, count); +- debug("%s(%Zu)", __FUNCTION__, count); - down(&tpm_mutex); - if (tpm_response.data != NULL) { - count = min(count, (size_t)tpm_response.size - (size_t)*ppos); @@ -298,7 +193,7 @@ - -static ssize_t tpm_write(struct file *file, const char *buf, size_t count, loff_t *ppos) -{ -- debug("%s(%d)", __FUNCTION__, count); +- debug("%s(%Zu)", __FUNCTION__, count); - down(&tpm_mutex); - *ppos = 0; - if (tpm_response.data != NULL) kfree(tpm_response.data); @@ -378,9 +273,9 @@ - return (ticks > 0) ? ticks : 1; -} - -diff -uprN orig/tpm_emulator-0.2/linux_module.h vtpm/linux_module.h ---- orig/tpm_emulator-0.2/linux_module.h 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/linux_module.h 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/linux_module.h vtpm/linux_module.h +--- orig/tpm_emulator-0.2-x86_64/linux_module.h 2005-09-15 19:21:14.844078720 -0700 ++++ vtpm/linux_module.h 2005-09-14 20:27:22.000000000 -0700 @@ -1,5 +1,6 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -416,17 +311,20 @@ +/* module settings */ +#define min(A,B) ((A)<(B)?(A):(B)) + #ifndef STR #define STR(s) __STR__(s) #define __STR__(s) #s - #include "tpm_version.h" -@@ -39,32 +45,35 @@ +@@ -39,34 +45,38 @@ + #define TPM_MODULE_NAME "tpm_emulator" + /* debug and log output functions */ ++extern int dmi_id; #ifdef DEBUG -#define debug(fmt, ...) printk(KERN_DEBUG "%s %s:%d: Debug: " fmt "\n", \ - TPM_MODULE_NAME, __FILE__, __LINE__, ## __VA_ARGS__) -+#define debug(fmt, ...) printf("%s:%d: Debug: " fmt "\n", \ -+ __FILE__, __LINE__, ## __VA_ARGS__) ++#define debug(fmt, ...) printf("TPMD[%d]: %s:%d: Debug: " fmt "\n", \ ++ dmi_id, __FILE__, __LINE__, ## __VA_ARGS__) #else #define debug(fmt, ...) #endif @@ -436,12 +334,12 @@ - TPM_MODULE_NAME, __FILE__, __LINE__, ## __VA_ARGS__) -#define alert(fmt, ...) printk(KERN_ALERT "%s %s:%d: Alert: " fmt "\n", \ - TPM_MODULE_NAME, __FILE__, __LINE__, ## __VA_ARGS__) -+#define info(fmt, ...) printf("%s:%d: Info: " fmt "\n", \ -+ __FILE__, __LINE__, ## __VA_ARGS__) -+#define error(fmt, ...) printf("%s:%d: Error: " fmt "\n", \ -+ __FILE__, __LINE__, ## __VA_ARGS__) -+#define alert(fmt, ...) printf("%s:%d: Alert: " fmt "\n", \ -+ __FILE__, __LINE__, ## __VA_ARGS__) ++#define info(fmt, ...) printf("TPMD[%d]: %s:%d: Info: " fmt "\n", \ ++ dmi_id, __FILE__, __LINE__, ## __VA_ARGS__) ++#define error(fmt, ...) printf("TPMD[%d]: %s:%d: Error: " fmt "\n", \ ++ dmi_id, __FILE__, __LINE__, ## __VA_ARGS__) ++#define alert(fmt, ...) printf("TPMD[%d]: %s:%d: Alert: " fmt "\n", \ ++ dmi_id, __FILE__, __LINE__, ## __VA_ARGS__) /* memory allocation */ @@ -465,7 +363,7 @@ static inline void tpm_get_random_bytes(void *buf, int nbytes) { get_random_bytes(buf, nbytes); -@@ -84,9 +93,9 @@ uint64_t tpm_get_ticks(void); +@@ -86,9 +96,9 @@ uint64_t tpm_get_ticks(void); #define CPU_TO_LE16(x) __cpu_to_le16(x) #define BE64_TO_CPU(x) __be64_to_cpu(x) @@ -477,9 +375,116 @@ #define BE16_TO_CPU(x) __be16_to_cpu(x) #define LE16_TO_CPU(x) __le16_to_cpu(x) -diff -uprN orig/tpm_emulator-0.2/tpm/tpm_audit.c vtpm/tpm/tpm_audit.c ---- orig/tpm_emulator-0.2/tpm/tpm_audit.c 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/tpm/tpm_audit.c 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/Makefile vtpm/Makefile +--- orig/tpm_emulator-0.2-x86_64/Makefile 2005-09-15 19:21:14.845078568 -0700 ++++ vtpm/Makefile 2005-09-14 20:27:22.000000000 -0700 +@@ -1,22 +1,31 @@ + # Software-Based Trusted Platform Module (TPM) Emulator for Linux + # Copyright (C) 2004 Mario Strasser ++# Copyright (C) 2005 INTEL Corp. + # + # $Id: Makefile 10 2005-04-26 20:59:50Z 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 := 2 + VERSION_BUILD := $(shell date +"%s") + +-# enable/disable DEBUG messages +-EXTRA_CFLAGS += -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.2-x86_64/README vtpm/README +--- orig/tpm_emulator-0.2-x86_64/README 2005-08-15 00:58:57.000000000 -0700 ++++ vtpm/README 2005-09-14 20:27:22.000000000 -0700 +@@ -13,7 +13,8 @@ $Id: README 8 2005-01-25 21:11:45Z jmoli + Copyright + -------------------------------------------------------------------------- + Copyright (C) 2004 Mario Strasser 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.2-x86_64/tpm/tpm_audit.c vtpm/tpm/tpm_audit.c +--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_audit.c 2005-08-15 00:58:57.000000000 -0700 ++++ vtpm/tpm/tpm_audit.c 2005-09-14 20:27:22.000000000 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -542,9 +547,9 @@ return TPM_SUCCESS; } - -diff -uprN orig/tpm_emulator-0.2/tpm/tpm_authorization.c vtpm/tpm/tpm_authorization.c ---- orig/tpm_emulator-0.2/tpm/tpm_authorization.c 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/tpm/tpm_authorization.c 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_authorization.c vtpm/tpm/tpm_authorization.c +--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_authorization.c 2005-08-15 00:58:57.000000000 -0700 ++++ vtpm/tpm/tpm_authorization.c 2005-09-14 20:27:22.000000000 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -568,9 +573,9 @@ } - - -diff -uprN orig/tpm_emulator-0.2/tpm/tpm_capability.c vtpm/tpm/tpm_capability.c ---- orig/tpm_emulator-0.2/tpm/tpm_capability.c 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/tpm/tpm_capability.c 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_capability.c vtpm/tpm/tpm_capability.c +--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_capability.c 2005-08-15 00:58:57.000000000 -0700 ++++ vtpm/tpm/tpm_capability.c 2005-09-14 20:27:22.000000000 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -593,9 +598,9 @@ } } - -diff -uprN orig/tpm_emulator-0.2/tpm/tpm_cmd_handler.c vtpm/tpm/tpm_cmd_handler.c ---- orig/tpm_emulator-0.2/tpm/tpm_cmd_handler.c 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/tpm/tpm_cmd_handler.c 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_cmd_handler.c vtpm/tpm/tpm_cmd_handler.c +--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_cmd_handler.c 2005-08-15 00:58:57.000000000 -0700 ++++ vtpm/tpm/tpm_cmd_handler.c 2005-09-14 20:27:22.000000000 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -658,9 +663,9 @@ return 0; } - -diff -uprN orig/tpm_emulator-0.2/tpm/tpm_crypto.c vtpm/tpm/tpm_crypto.c ---- orig/tpm_emulator-0.2/tpm/tpm_crypto.c 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/tpm/tpm_crypto.c 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c vtpm/tpm/tpm_crypto.c +--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c 2005-09-15 19:21:14.846078416 -0700 ++++ vtpm/tpm/tpm_crypto.c 2005-09-14 20:27:22.000000000 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -678,14 +683,14 @@ memcpy(&buf[30], areaToSign, areaToSignSize); if (rsa_sign(&key->key, RSA_SSA_PKCS1_SHA1, buf, areaToSignSize + 30, *sig)) { -@@ -379,4 +380,3 @@ TPM_RESULT TPM_CertifyKey2(TPM_KEY_HANDL +@@ -383,4 +384,3 @@ TPM_RESULT TPM_CertifyKey2(TPM_KEY_HANDL } return TPM_SUCCESS; } - -diff -uprN orig/tpm_emulator-0.2/tpm/tpm_data.c vtpm/tpm/tpm_data.c ---- orig/tpm_emulator-0.2/tpm/tpm_data.c 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/tpm/tpm_data.c 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_data.c vtpm/tpm/tpm_data.c +--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_data.c 2005-09-15 19:21:14.847078264 -0700 ++++ vtpm/tpm/tpm_data.c 2005-09-14 20:27:22.000000000 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -1005,7 +1010,7 @@ } #else -@@ -231,7 +431,6 @@ int tpm_restore_permanent_data(void) +@@ -232,7 +432,6 @@ int tpm_restore_permanent_data(void) int tpm_erase_permanent_data(void) { @@ -1014,9 +1019,9 @@ return res; } - -diff -uprN orig/tpm_emulator-0.2/tpm/tpm_deprecated.c vtpm/tpm/tpm_deprecated.c ---- orig/tpm_emulator-0.2/tpm/tpm_deprecated.c 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/tpm/tpm_deprecated.c 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_deprecated.c vtpm/tpm/tpm_deprecated.c +--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_deprecated.c 2005-08-15 00:58:57.000000000 -0700 ++++ vtpm/tpm/tpm_deprecated.c 2005-09-14 20:27:22.000000000 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -1043,9 +1048,9 @@ authContextSize, &contextBlob); if (res != TPM_SUCCESS) return res; len = *authContextSize; -diff -uprN orig/tpm_emulator-0.2/tpm/tpm_emulator.h vtpm/tpm/tpm_emulator.h ---- orig/tpm_emulator-0.2/tpm/tpm_emulator.h 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/tpm/tpm_emulator.h 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_emulator.h vtpm/tpm/tpm_emulator.h +--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_emulator.h 2005-08-15 00:58:57.000000000 -0700 ++++ vtpm/tpm/tpm_emulator.h 2005-09-14 20:27:22.000000000 -0700 @@ -1,5 +1,6 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -1063,9 +1068,9 @@ /** * tpm_emulator_init - initialises and starts the TPM emulator -diff -uprN orig/tpm_emulator-0.2/tpm/tpm_integrity.c vtpm/tpm/tpm_integrity.c ---- orig/tpm_emulator-0.2/tpm/tpm_integrity.c 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/tpm/tpm_integrity.c 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_integrity.c vtpm/tpm/tpm_integrity.c +--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_integrity.c 2005-08-15 00:58:57.000000000 -0700 ++++ vtpm/tpm/tpm_integrity.c 2005-09-14 20:27:22.000000000 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -1079,9 +1084,9 @@ return TPM_SUCCESS; } - -diff -uprN orig/tpm_emulator-0.2/tpm/tpm_structures.h vtpm/tpm/tpm_structures.h ---- orig/tpm_emulator-0.2/tpm/tpm_structures.h 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/tpm/tpm_structures.h 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_structures.h vtpm/tpm/tpm_structures.h +--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_structures.h 2005-08-15 00:58:57.000000000 -0700 ++++ vtpm/tpm/tpm_structures.h 2005-09-14 20:27:22.000000000 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -1099,9 +1104,9 @@ #include "crypto/rsa.h" /* -diff -uprN orig/tpm_emulator-0.2/tpm/tpm_testing.c vtpm/tpm/tpm_testing.c ---- orig/tpm_emulator-0.2/tpm/tpm_testing.c 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/tpm/tpm_testing.c 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_testing.c vtpm/tpm/tpm_testing.c +--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_testing.c 2005-08-15 00:58:57.000000000 -0700 ++++ vtpm/tpm/tpm_testing.c 2005-09-14 20:27:22.000000000 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -1217,9 +1222,9 @@ rsa_private_key_t priv_key; rsa_public_key_t pub_key; -diff -uprN orig/tpm_emulator-0.2/tpm/tpm_ticks.c vtpm/tpm/tpm_ticks.c ---- orig/tpm_emulator-0.2/tpm/tpm_ticks.c 2005-08-17 10:58:36.000000000 -0700 -+++ vtpm/tpm/tpm_ticks.c 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_ticks.c vtpm/tpm/tpm_ticks.c +--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_ticks.c 2005-08-15 00:58:57.000000000 -0700 ++++ vtpm/tpm/tpm_ticks.c 2005-09-14 20:27:22.000000000 -0700 @@ -1,6 +1,7 @@ /* Software-Based Trusted Platform Module (TPM) Emulator for Linux * Copyright (C) 2004 Mario Strasser , @@ -1302,9 +1307,9 @@ } -diff -uprN orig/tpm_emulator-0.2/tpm/vtpm_manager.h vtpm/tpm/vtpm_manager.h ---- orig/tpm_emulator-0.2/tpm/vtpm_manager.h 1969-12-31 16:00:00.000000000 -0800 -+++ vtpm/tpm/vtpm_manager.h 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/vtpm_manager.h vtpm/tpm/vtpm_manager.h +--- orig/tpm_emulator-0.2-x86_64/tpm/vtpm_manager.h 1969-12-31 16:00:00.000000000 -0800 ++++ vtpm/tpm/vtpm_manager.h 2005-09-14 20:27:22.000000000 -0700 @@ -0,0 +1,126 @@ +// =================================================================== +// @@ -1432,9 +1437,9 @@ +*********************************************************************/ + +#endif //_VTPM_MANAGER_H_ -diff -uprN orig/tpm_emulator-0.2/tpmd.c vtpm/tpmd.c ---- orig/tpm_emulator-0.2/tpmd.c 1969-12-31 16:00:00.000000000 -0800 -+++ vtpm/tpmd.c 2005-08-17 10:55:52.000000000 -0700 +diff -uprN orig/tpm_emulator-0.2-x86_64/tpmd.c vtpm/tpmd.c +--- orig/tpm_emulator-0.2-x86_64/tpmd.c 1969-12-31 16:00:00.000000000 -0800 ++++ vtpm/tpmd.c 2005-09-15 19:28:55.783005352 -0700 @@ -0,0 +1,207 @@ +/* Software-Based Trusted Platform Module (TPM) Emulator for Linux + * Copyright (C) 2005 INTEL Corp @@ -1468,9 +1473,9 @@ +#else + #define GUEST_RX_FIFO_D "/var/vtpm/fifos/guest-to-%d.fifo" + #define GUEST_TX_FIFO "/var/vtpm/fifos/guest-from-all.fifo" ++#endif + + int dmi_id; -+#endif + +#define BUFFER_SIZE 2048 + @@ -1506,7 +1511,7 @@ +{ + uint8_t in[BUFFER_SIZE], *out, *addressed_out; + uint32_t out_size; -+ int in_size, written ; ++ int in_size, written; + int i, guest_id=-1; + + int vtpm_tx_fh=-1, vtpm_rx_fh=-1; @@ -1602,7 +1607,7 @@ + written = write(vtpm_tx_fh, ctrl_msg, sizeof(ctrl_msg)); + + if (written != sizeof(ctrl_msg)) { -+ printf("ERROR: Part of response not written %d/%d.\n", written, sizeof(ctrl_msg)); ++ printf("ERROR: Part of response not written %d/%Zu.\n", written, sizeof(ctrl_msg)); + } else { + printf("Send Ctrl Message confermation\n"); + } @@ -1623,7 +1628,7 @@ + printf("%x ", addressed_out[i]); + printf("\n"); + } else { -+ printf("Sent[%d]: ", out_size + sizeof(uint32_t)); ++ printf("Sent[%Zu]: ", out_size + sizeof(uint32_t)); + for (i=0; i< out_size+ sizeof(uint32_t); i++) + printf("%x ", addressed_out[i]); + printf("\n"); diff -r a4cf3e17bb25 tools/vtpm/tpm_emulator-0.2b-x86_64.patch --- /dev/null Fri Sep 16 18:59:59 2005 +++ b/tools/vtpm/tpm_emulator-0.2b-x86_64.patch Mon Sep 19 16:18:48 2005 @@ -0,0 +1,499 @@ +diff -uprN tpm_emulator-0.2/crypto/gmp_kernel_wrapper.c tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c +--- tpm_emulator-0.2/crypto/gmp_kernel_wrapper.c 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c 2005-09-19 14:10:29.000000000 -0700 +@@ -79,7 +79,7 @@ void __attribute__ ((regparm(0))) *kerne + { + void *ret = (void*)kmalloc(size, GFP_KERNEL); + if (!ret) panic(KERN_CRIT TPM_MODULE_NAME +- "GMP: cannot allocate memory (size=%u)\n", size); ++ "GMP: cannot allocate memory (size=%Zu)\n", size); + return ret; + } + +@@ -88,7 +88,7 @@ void __attribute__ ((regparm(0))) *kerne + { + void *ret = (void*)kmalloc(new_size, GFP_KERNEL); + if (!ret) panic(KERN_CRIT TPM_MODULE_NAME "GMP: Cannot reallocate memory " +- "(old_size=%u new_size=%u)\n", old_size, new_size); ++ "(old_size=%Zu new_size=%Zu)\n", old_size, new_size); + memcpy(ret, oldptr, old_size); + kfree(oldptr); + return ret; +diff -uprN tpm_emulator-0.2/linux_module.c tpm_emulator-0.2-x86_64/linux_module.c +--- tpm_emulator-0.2/linux_module.c 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator-0.2-x86_64/linux_module.c 2005-09-19 14:10:29.000000000 -0700 +@@ -66,7 +66,7 @@ static int tpm_release(struct inode *ino + + static ssize_t tpm_read(struct file *file, char *buf, size_t count, loff_t *ppos) + { +- debug("%s(%d)", __FUNCTION__, count); ++ debug("%s(%Zu)", __FUNCTION__, count); + down(&tpm_mutex); + if (tpm_response.data != NULL) { + count = min(count, (size_t)tpm_response.size - (size_t)*ppos); +@@ -81,7 +81,7 @@ static ssize_t tpm_read(struct file *fil + + static ssize_t tpm_write(struct file *file, const char *buf, size_t count, loff_t *ppos) + { +- debug("%s(%d)", __FUNCTION__, count); ++ debug("%s(%Zu)", __FUNCTION__, count); + down(&tpm_mutex); + *ppos = 0; + if (tpm_response.data != NULL) kfree(tpm_response.data); +diff -uprN tpm_emulator-0.2/linux_module.h tpm_emulator-0.2-x86_64/linux_module.h +--- tpm_emulator-0.2/linux_module.h 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator-0.2-x86_64/linux_module.h 2005-09-19 14:10:29.000000000 -0700 +@@ -28,8 +28,10 @@ + + /* module settings */ + ++#ifndef STR + #define STR(s) __STR__(s) + #define __STR__(s) #s ++#endif + #include "tpm_version.h" + + #define TPM_DEVICE_MINOR 224 +diff -uprN tpm_emulator-0.2/Makefile tpm_emulator-0.2-x86_64/Makefile +--- tpm_emulator-0.2/Makefile 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator-0.2-x86_64/Makefile 2005-09-19 14:10:29.000000000 -0700 +@@ -7,6 +7,7 @@ + KERNEL_RELEASE := $(shell uname -r) + KERNEL_BUILD := /lib/modules/$(KERNEL_RELEASE)/build + MOD_SUBDIR := misc ++COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/) + + # module settings + MODULE_NAME := tpm_emulator +@@ -17,8 +18,14 @@ VERSION_BUILD := $(shell date +"%s") + # enable/disable DEBUG messages + EXTRA_CFLAGS += -DDEBUG -g + ++ifeq ($(COMPILE_ARCH),x86_64) ++LIBDIR = lib64 ++else ++LIBDIR = lib ++endif ++ + # GNU MP configuration +-GMP_LIB := /usr/lib/libgmp.a ++GMP_LIB := /usr/$(LIBDIR)/libgmp.a + GMP_HEADER := /usr/include/gmp.h + + # sources and objects +diff -uprN tpm_emulator-0.2/README tpm_emulator-0.2-x86_64/README +--- tpm_emulator-0.2/README 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator-0.2-x86_64/README 2005-09-19 14:21:43.000000000 -0700 +@@ -45,6 +45,12 @@ Example: + GMP_LIB := /usr/lib/libgmp.a + GMP_HEADER := /usr/include/gmp.h + ++GNU MP Library on 64 bit Systems ++-------------------------------------------------------------------------- ++Some 64-bit kernels have problems with importing the user-space gmp ++library (/usr/lib*/libgmp.a) into kernel space. These kernels will require ++that the gmp library be recompiled for kernel space with -mcmodel=kernel. ++ + Installation + -------------------------------------------------------------------------- + The compilation and installation process uses the build environment for +diff -uprN tpm_emulator-0.2/tpm/tpm_credentials.c tpm_emulator-0.2-x86_64/tpm/tpm_credentials.c +--- tpm_emulator-0.2/tpm/tpm_credentials.c 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator-0.2-x86_64/tpm/tpm_credentials.c 2005-09-19 14:10:29.000000000 -0700 +@@ -47,16 +47,16 @@ int tpm_compute_pubkey_checksum(TPM_NONC + + TPM_RESULT tpm_get_pubek(TPM_PUBKEY *pubEndorsementKey) + { +- UINT32 key_length; ++ size_t key_length; + if (!tpmData.permanent.data.endorsementKey.size) return TPM_NO_ENDORSEMENT; + /* setup TPM_PUBKEY structure */ +- key_length = tpmData.permanent.data.endorsementKey.size; +- pubEndorsementKey->pubKey.keyLength = key_length >> 3; ++ pubEndorsementKey->pubKey.keyLength = tpmData.permanent.data.endorsementKey.size >> 3; + pubEndorsementKey->pubKey.key = tpm_malloc(pubEndorsementKey->pubKey.keyLength); + if (pubEndorsementKey->pubKey.key == NULL) return TPM_FAIL; + rsa_export_modulus(&tpmData.permanent.data.endorsementKey, +- pubEndorsementKey->pubKey.key, +- &pubEndorsementKey->pubKey.keyLength); ++ pubEndorsementKey->pubKey.key, ++ &key_length); ++ pubEndorsementKey->pubKey.keyLength = key_length; + pubEndorsementKey->algorithmParms.algorithmID = TPM_ALG_RSA; + pubEndorsementKey->algorithmParms.encScheme = TPM_ES_RSAESOAEP_SHA1_MGF1; + pubEndorsementKey->algorithmParms.sigScheme = TPM_SS_NONE; +@@ -169,6 +169,7 @@ TPM_RESULT TPM_OwnerReadInternalPub(TPM_ + { + TPM_RESULT res; + TPM_KEY_DATA *srk = &tpmData.permanent.data.srk; ++ size_t key_length; + info("TPM_OwnerReadInternalPub()"); + /* verify authorization */ + res = tpm_verify_auth(auth1, tpmData.permanent.data.ownerAuth, TPM_KH_OWNER); +@@ -180,7 +181,8 @@ TPM_RESULT TPM_OwnerReadInternalPub(TPM_ + publicPortion->pubKey.key = tpm_malloc(publicPortion->pubKey.keyLength); + if (publicPortion->pubKey.key == NULL) return TPM_FAIL; + rsa_export_modulus(&srk->key, publicPortion->pubKey.key, +- &publicPortion->pubKey.keyLength); ++ &key_length); ++ publicPortion->pubKey.keyLength = key_length; + publicPortion->algorithmParms.algorithmID = TPM_ALG_RSA; + publicPortion->algorithmParms.encScheme = srk->encScheme; + publicPortion->algorithmParms.sigScheme = srk->sigScheme; +diff -uprN tpm_emulator-0.2/tpm/tpm_crypto.c tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c +--- tpm_emulator-0.2/tpm/tpm_crypto.c 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c 2005-09-19 14:10:29.000000000 -0700 +@@ -182,7 +182,8 @@ TPM_RESULT TPM_CertifyKey(TPM_KEY_HANDLE + TPM_KEY_DATA *cert, *key; + sha1_ctx_t sha1_ctx; + BYTE *buf, *p; +- UINT32 length; ++ UINT32 length32; ++ size_t length; + info("TPM_CertifyKey()"); + /* get keys */ + cert = tpm_get_key(certHandle); +@@ -264,14 +265,15 @@ TPM_RESULT TPM_CertifyKey(TPM_KEY_HANDLE + /* compute the digest of the CERTIFY_INFO[2] structure and sign it */ + length = sizeof_TPM_CERTIFY_INFO((*certifyInfo)); + p = buf = tpm_malloc(length); ++ length32=(UINT32) length; + if (buf == NULL +- || tpm_marshal_TPM_CERTIFY_INFO(&p, &length, certifyInfo)) { ++ || tpm_marshal_TPM_CERTIFY_INFO(&p, &length32, certifyInfo)) { + free_TPM_KEY_PARMS(certifyInfo->algorithmParms); + return TPM_FAIL; + } + length = sizeof_TPM_CERTIFY_INFO((*certifyInfo)); + sha1_init(&sha1_ctx); +- sha1_update(&sha1_ctx, buf, length); ++ sha1_update(&sha1_ctx, buf, (size_t) length); + sha1_final(&sha1_ctx, buf); + res = tpm_sign(cert, auth1, FALSE, buf, SHA1_DIGEST_LENGTH, outData, outDataSize); + tpm_free(buf); +@@ -292,7 +294,8 @@ TPM_RESULT TPM_CertifyKey2(TPM_KEY_HANDL + TPM_KEY_DATA *cert, *key; + sha1_ctx_t sha1_ctx; + BYTE *buf, *p; +- UINT32 length; ++ size_t length; ++ UINT32 length32; + info("TPM_CertifyKey2()"); + /* get keys */ + cert = tpm_get_key(certHandle); +@@ -362,8 +365,9 @@ TPM_RESULT TPM_CertifyKey2(TPM_KEY_HANDL + /* compute the digest of the CERTIFY_INFO[2] structure and sign it */ + length = sizeof_TPM_CERTIFY_INFO((*certifyInfo)); + p = buf = tpm_malloc(length); ++ length32 = (UINT32) length; + if (buf == NULL +- || tpm_marshal_TPM_CERTIFY_INFO(&p, &length, certifyInfo)) { ++ || tpm_marshal_TPM_CERTIFY_INFO(&p, &length32, certifyInfo)) { + free_TPM_KEY_PARMS(certifyInfo->algorithmParms); + return TPM_FAIL; + } +diff -uprN tpm_emulator-0.2/tpm/tpm_data.c tpm_emulator-0.2-x86_64/tpm/tpm_data.c +--- tpm_emulator-0.2/tpm/tpm_data.c 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator-0.2-x86_64/tpm/tpm_data.c 2005-09-19 14:10:29.000000000 -0700 +@@ -179,7 +179,7 @@ static int read_from_file(uint8_t **data + int tpm_store_permanent_data(void) + { + uint8_t *buf, *ptr; +- size_t buf_length, len; ++ UINT32 buf_length, len; + + /* marshal data */ + buf_length = len = sizeof_TPM_STCLEAR_FLAGS(tpmData.stclear.flags) +@@ -207,13 +207,14 @@ int tpm_store_permanent_data(void) + int tpm_restore_permanent_data(void) + { + uint8_t *buf, *ptr; +- size_t buf_length, len; ++ size_t buf_length; ++ UINT32 len; + TPM_VERSION ver; + + /* read data */ + if (read_from_file(&buf, &buf_length)) return -1; + ptr = buf; +- len = buf_length; ++ len = (uint32_t) buf_length; + /* unmarshal data */ + if (tpm_unmarshal_TPM_VERSION(&ptr, &len, &ver) + || memcmp(&ver, &tpmData.permanent.data.version, sizeof(TPM_VERSION)) +diff -uprN tpm_emulator-0.2/tpm/tpm_marshalling.c tpm_emulator-0.2-x86_64/tpm/tpm_marshalling.c +--- tpm_emulator-0.2/tpm/tpm_marshalling.c 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator-0.2-x86_64/tpm/tpm_marshalling.c 2005-09-19 14:10:29.000000000 -0700 +@@ -981,7 +981,7 @@ int tpm_unmarshal_TPM_STANY_FLAGS(BYTE * + + int tpm_marshal_RSA(BYTE **ptr, UINT32 *length, rsa_private_key_t *v) + { +- UINT32 m_len, e_len, q_len; ++ size_t m_len, e_len, q_len; + if (*length < sizeof_RSA((*v))) return -1; + if (v->size > 0) { + rsa_export_modulus(v, &(*ptr)[6], &m_len); +diff -uprN tpm_emulator-0.2/tpm/tpm_owner.c tpm_emulator-0.2-x86_64/tpm/tpm_owner.c +--- tpm_emulator-0.2/tpm/tpm_owner.c 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator-0.2-x86_64/tpm/tpm_owner.c 2005-09-19 14:10:29.000000000 -0700 +@@ -108,7 +108,7 @@ TPM_RESULT TPM_TakeOwnership(TPM_PROTOCO + TPM_RESULT res; + rsa_private_key_t *ek = &tpmData.permanent.data.endorsementKey; + TPM_KEY_DATA *srk = &tpmData.permanent.data.srk; +- UINT32 buf_size = ek->size >> 3; ++ size_t buf_size = ek->size >> 3, key_length; + BYTE buf[buf_size]; + + info("TPM_TakeOwnership()"); +@@ -172,7 +172,8 @@ TPM_RESULT TPM_TakeOwnership(TPM_PROTOCO + return TPM_FAIL; + } + rsa_export_modulus(&srk->key, srkPub->pubKey.key, +- &srkPub->pubKey.keyLength); ++ &key_length); ++ srkPub->pubKey.keyLength = (UINT32) key_length; + /* setup tpmProof and set state to owned */ + tpm_get_random_bytes(tpmData.permanent.data.tpmProof.nonce, + sizeof(tpmData.permanent.data.tpmProof.nonce)); +diff -uprN tpm_emulator-0.2/tpm/tpm_storage.c tpm_emulator-0.2-x86_64/tpm/tpm_storage.c +--- tpm_emulator-0.2/tpm/tpm_storage.c 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator-0.2-x86_64/tpm/tpm_storage.c 2005-09-19 14:10:29.000000000 -0700 +@@ -58,6 +58,7 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke + BYTE *enc, UINT32 *enc_size) + { + UINT32 len; ++ size_t enc_size32 = *enc_size; + BYTE *buf, *ptr; + rsa_public_key_t pub_key; + int scheme; +@@ -72,7 +73,7 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke + if (buf == NULL + || tpm_marshal_TPM_SEALED_DATA(&ptr, &len, seal) + || rsa_encrypt(&pub_key, scheme, buf, sizeof_TPM_SEALED_DATA((*seal)), +- enc, enc_size)) { ++ enc, &enc_size32)) { + tpm_free(buf); + rsa_release_public_key(&pub_key); + return -1; +@@ -85,7 +86,8 @@ int encrypt_sealed_data(TPM_KEY_DATA *ke + int decrypt_sealed_data(TPM_KEY_DATA *key, BYTE *enc, UINT32 enc_size, + TPM_SEALED_DATA *seal, BYTE **buf) + { +- UINT32 len; ++ size_t len; ++ UINT32 len32; + BYTE *ptr; + int scheme; + switch (key->encScheme) { +@@ -96,8 +98,12 @@ int decrypt_sealed_data(TPM_KEY_DATA *ke + len = enc_size; + *buf = ptr = tpm_malloc(len); + if (*buf == NULL +- || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len) +- || tpm_unmarshal_TPM_SEALED_DATA(&ptr, &len, seal)) { ++ || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len) ){ ++ tpm_free(*buf); ++ return -1; ++ } ++ len32 = len; ++ if (tpm_unmarshal_TPM_SEALED_DATA(&ptr, &len32, seal)) { + tpm_free(*buf); + return -1; + } +@@ -237,11 +243,12 @@ TPM_RESULT TPM_Unseal(TPM_KEY_HANDLE par + + TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE keyHandle, UINT32 inDataSize, + BYTE *inData, TPM_AUTH *auth1, +- UINT32 *outDataSize, BYTE **outData) ++ UINT32 *outDataSize32, BYTE **outData) + { + TPM_RESULT res; + TPM_KEY_DATA *key; + int scheme; ++ size_t outDataSize; + info("TPM_UnBind()"); + /* get key */ + key = tpm_get_key(keyHandle); +@@ -258,8 +265,8 @@ TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE key + /* the size of the input data muss be greater than zero */ + if (inDataSize == 0) return TPM_BAD_PARAMETER; + /* decrypt data */ +- *outDataSize = inDataSize; +- *outData = tpm_malloc(*outDataSize); ++ outDataSize = inDataSize; ++ *outData = tpm_malloc(outDataSize); + if (*outData == NULL) return TPM_FAIL; + switch (key->encScheme) { + case TPM_ES_RSAESOAEP_SHA1_MGF1: scheme = RSA_ES_OAEP_SHA1; break; +@@ -267,20 +274,21 @@ TPM_RESULT TPM_UnBind(TPM_KEY_HANDLE key + default: tpm_free(*outData); return TPM_DECRYPT_ERROR; + } + if (rsa_decrypt(&key->key, scheme, inData, inDataSize, +- *outData, outDataSize)) { ++ *outData, &outDataSize) ) { + tpm_free(*outData); + return TPM_DECRYPT_ERROR; + } + /* verify data if it is of type TPM_BOUND_DATA */ + if (key->encScheme == TPM_ES_RSAESOAEP_SHA1_MGF1 + || key->keyUsage != TPM_KEY_LEGACY) { +- if (*outDataSize < 5 || memcmp(*outData, "\x01\x01\00\x00\x02", 5) != 0) { ++ if (outDataSize < 5 || memcmp(*outData, "\x01\x01\00\x00\x02", 5) != 0) { + tpm_free(*outData); + return TPM_DECRYPT_ERROR; + } +- *outDataSize -= 5; +- memmove(*outData, &(*outData)[5], *outDataSize); +- } ++ outDataSize -= 5; ++ memmove(*outData, &(*outData)[5], outDataSize); ++ } ++ *outDataSize32 = (UINT32) outDataSize; + return TPM_SUCCESS; + } + +@@ -311,12 +319,13 @@ static int verify_key_digest(TPM_KEY *ke + } + + int encrypt_private_key(TPM_KEY_DATA *key, TPM_STORE_ASYMKEY *store, +- BYTE *enc, UINT32 *enc_size) ++ BYTE *enc, UINT32 *enc_size32) + { + UINT32 len; + BYTE *buf, *ptr; + rsa_public_key_t pub_key; + int scheme; ++ size_t enc_size; + switch (key->encScheme) { + case TPM_ES_RSAESOAEP_SHA1_MGF1: scheme = RSA_ES_OAEP_SHA1; break; + case TPM_ES_RSAESPKCSv15: scheme = RSA_ES_PKCSV15; break; +@@ -328,11 +337,12 @@ int encrypt_private_key(TPM_KEY_DATA *ke + if (buf == NULL + || tpm_marshal_TPM_STORE_ASYMKEY(&ptr, &len, store) + || rsa_encrypt(&pub_key, scheme, buf, sizeof_TPM_STORE_ASYMKEY((*store)), +- enc, enc_size)) { ++ enc, &enc_size)) { + tpm_free(buf); + rsa_release_public_key(&pub_key); + return -1; + } ++ *enc_size32 = (UINT32) enc_size; + tpm_free(buf); + rsa_release_public_key(&pub_key); + return 0; +@@ -341,7 +351,8 @@ int encrypt_private_key(TPM_KEY_DATA *ke + int decrypt_private_key(TPM_KEY_DATA *key, BYTE *enc, UINT32 enc_size, + TPM_STORE_ASYMKEY *store, BYTE **buf) + { +- UINT32 len; ++ UINT32 len32; ++ size_t len; + BYTE *ptr; + int scheme; + switch (key->encScheme) { +@@ -352,11 +363,16 @@ int decrypt_private_key(TPM_KEY_DATA *ke + len = enc_size; + *buf = ptr = tpm_malloc(len); + if (*buf == NULL +- || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len) +- || tpm_unmarshal_TPM_STORE_ASYMKEY(&ptr, &len, store)) { ++ || rsa_decrypt(&key->key, scheme, enc, enc_size, *buf, &len) ) { ++ tpm_free(*buf); ++ return -1; ++ } ++ len32 = (UINT32) len; ++ if (tpm_unmarshal_TPM_STORE_ASYMKEY(&ptr, &len32, store)) { + tpm_free(*buf); + return -1; + } ++ + return 0; + } + +@@ -371,7 +387,7 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN + TPM_SESSION_DATA *session; + TPM_STORE_ASYMKEY store; + rsa_private_key_t rsa; +- UINT32 key_length; ++ size_t key_length; + + info("TPM_CreateWrapKey()"); + /* get parent key */ +@@ -428,11 +444,11 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN + } + if (compute_key_digest(wrappedKey, &store.pubDataDigest)) return TPM_FAIL; + /* generate key and store it */ +- key_length = keyInfo->algorithmParms.parms.rsa.keyLength; +- if (rsa_generate_key(&rsa, key_length)) return TPM_FAIL; +- wrappedKey->pubKey.keyLength = key_length >> 3; ++ if (rsa_generate_key(&rsa, keyInfo->algorithmParms.parms.rsa.keyLength)) ++ return TPM_FAIL; ++ wrappedKey->pubKey.keyLength = keyInfo->algorithmParms.parms.rsa.keyLength >> 3; + wrappedKey->pubKey.key = tpm_malloc(wrappedKey->pubKey.keyLength); +- store.privKey.keyLength = key_length >> 4; ++ store.privKey.keyLength = keyInfo->algorithmParms.parms.rsa.keyLength >> 4; + store.privKey.key = tpm_malloc(store.privKey.keyLength); + wrappedKey->encDataSize = parent->key.size >> 3; + wrappedKey->encData = tpm_malloc(wrappedKey->encDataSize); +@@ -444,9 +460,11 @@ TPM_RESULT TPM_CreateWrapKey(TPM_KEY_HAN + tpm_free(wrappedKey->encData); + return TPM_FAIL; + } +- rsa_export_modulus(&rsa, wrappedKey->pubKey.key, +- &wrappedKey->pubKey.keyLength); +- rsa_export_prime1(&rsa, store.privKey.key, &store.privKey.keyLength); ++ rsa_export_modulus(&rsa, wrappedKey->pubKey.key, ++ &key_length); ++ wrappedKey->pubKey.keyLength = (UINT32) key_length; ++ rsa_export_prime1(&rsa, store.privKey.key, &key_length); ++ store.privKey.keyLength = (UINT32) key_length; + rsa_release_private_key(&rsa); + /* encrypt private key data */ + if (encrypt_private_key(parent, &store, wrappedKey->encData, +@@ -560,6 +578,7 @@ TPM_RESULT TPM_LoadKey(TPM_KEY_HANDLE pa + + int tpm_setup_key_parms(TPM_KEY_DATA *key, TPM_KEY_PARMS *parms) + { ++ size_t key_length; + parms->algorithmID = TPM_ALG_RSA; + parms->encScheme = key->encScheme; + parms->sigScheme = key->sigScheme; +@@ -569,7 +588,8 @@ int tpm_setup_key_parms(TPM_KEY_DATA *ke + parms->parms.rsa.exponent = tpm_malloc(parms->parms.rsa.exponentSize); + if (parms->parms.rsa.exponent == NULL) return -1; + rsa_export_exponent(&key->key, parms->parms.rsa.exponent, +- &parms->parms.rsa.exponentSize); ++ &key_length); ++ parms->parms.rsa.exponentSize = (UINT32) key_length; + parms->parmSize = 12 + parms->parms.rsa.exponentSize; + return 0; + } +@@ -580,6 +600,7 @@ TPM_RESULT TPM_GetPubKey(TPM_KEY_HANDLE + TPM_RESULT res; + TPM_KEY_DATA *key; + TPM_DIGEST digest; ++ size_t key_length; + info("TPM_GetPubKey()"); + /* get key */ + if (keyHandle == TPM_KH_SRK) return TPM_BAD_PARAMETER; +@@ -607,8 +628,8 @@ TPM_RESULT TPM_GetPubKey(TPM_KEY_HANDLE + pubKey->pubKey.keyLength = key->key.size >> 3; + pubKey->pubKey.key = tpm_malloc(pubKey->pubKey.keyLength); + if (pubKey->pubKey.key == NULL) return TPM_FAIL; +- rsa_export_modulus(&key->key, pubKey->pubKey.key, +- &pubKey->pubKey.keyLength); ++ rsa_export_modulus(&key->key, pubKey->pubKey.key, &key_length); ++ pubKey->pubKey.keyLength = (UINT32) key_length; + if (tpm_setup_key_parms(key, &pubKey->algorithmParms) != 0) { + tpm_free(pubKey->pubKey.key); + return TPM_FAIL; +diff -uprN tpm_emulator-0.2/tpm_version.h tpm_emulator-0.2-x86_64/tpm_version.h +--- tpm_emulator-0.2/tpm_version.h 2005-08-15 00:58:57.000000000 -0700 ++++ tpm_emulator-0.2-x86_64/tpm_version.h 1969-12-31 16:00:00.000000000 -0800 +@@ -1,6 +0,0 @@ +-#ifndef _TPM_VERSION_H_ +-#define _TPM_VERSION_H_ +-#define VERSION_MAJOR 0 +-#define VERSION_MINOR 2 +-#define VERSION_BUILD 1123950310 +-#endif /* _TPM_VERSION_H_ */