summaryrefslogtreecommitdiff
path: root/src/tcs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tcs')
-rw-r--r--src/tcs/Makefile.am142
-rw-r--r--src/tcs/Makefile.in2069
-rw-r--r--src/tcs/crypto/openssl/crypto.c68
-rw-r--r--src/tcs/log.c87
-rw-r--r--src/tcs/ps/ps_utils.c538
-rw-r--r--src/tcs/ps/tcsps.c784
-rw-r--r--src/tcs/rpc/tcstp/rpc.c628
-rw-r--r--src/tcs/rpc/tcstp/rpc_admin.c404
-rw-r--r--src/tcs/rpc/tcstp/rpc_aik.c285
-rw-r--r--src/tcs/rpc/tcstp/rpc_audit.c230
-rw-r--r--src/tcs/rpc/tcstp/rpc_auth.c113
-rw-r--r--src/tcs/rpc/tcstp/rpc_bind.c105
-rw-r--r--src/tcs/rpc/tcstp/rpc_caps.c81
-rw-r--r--src/tcs/rpc/tcstp/rpc_caps_tpm.c220
-rw-r--r--src/tcs/rpc/tcstp/rpc_certify.c120
-rw-r--r--src/tcs/rpc/tcstp/rpc_changeauth.c158
-rw-r--r--src/tcs/rpc/tcstp/rpc_cmk.c617
-rw-r--r--src/tcs/rpc/tcstp/rpc_context.c81
-rw-r--r--src/tcs/rpc/tcstp/rpc_counter.c231
-rw-r--r--src/tcs/rpc/tcstp/rpc_daa.c238
-rw-r--r--src/tcs/rpc/tcstp/rpc_delegate.c590
-rw-r--r--src/tcs/rpc/tcstp/rpc_dir.c103
-rw-r--r--src/tcs/rpc/tcstp/rpc_ek.c324
-rw-r--r--src/tcs/rpc/tcstp/rpc_evlog.c285
-rw-r--r--src/tcs/rpc/tcstp/rpc_key.c476
-rw-r--r--src/tcs/rpc/tcstp/rpc_maint.c283
-rw-r--r--src/tcs/rpc/tcstp/rpc_migration.c321
-rw-r--r--src/tcs/rpc/tcstp/rpc_nv.c344
-rw-r--r--src/tcs/rpc/tcstp/rpc_oper.c57
-rw-r--r--src/tcs/rpc/tcstp/rpc_own.c170
-rw-r--r--src/tcs/rpc/tcstp/rpc_pcr_extend.c139
-rw-r--r--src/tcs/rpc/tcstp/rpc_ps.c510
-rw-r--r--src/tcs/rpc/tcstp/rpc_quote.c126
-rw-r--r--src/tcs/rpc/tcstp/rpc_quote2.c163
-rw-r--r--src/tcs/rpc/tcstp/rpc_random.c107
-rw-r--r--src/tcs/rpc/tcstp/rpc_seal.c251
-rw-r--r--src/tcs/rpc/tcstp/rpc_selftest.c154
-rw-r--r--src/tcs/rpc/tcstp/rpc_sign.c106
-rw-r--r--src/tcs/rpc/tcstp/rpc_tick.c138
-rw-r--r--src/tcs/rpc/tcstp/rpc_transport.c397
-rw-r--r--src/tcs/tcs_aik.c146
-rw-r--r--src/tcs/tcs_auth_mgr.c584
-rw-r--r--src/tcs/tcs_caps.c195
-rw-r--r--src/tcs/tcs_context.c320
-rw-r--r--src/tcs/tcs_context_key.c162
-rw-r--r--src/tcs/tcs_counter.c54
-rw-r--r--src/tcs/tcs_evlog.c223
-rw-r--r--src/tcs/tcs_evlog_biosem.c298
-rw-r--r--src/tcs/tcs_evlog_imaem.c352
-rw-r--r--src/tcs/tcs_key.c588
-rw-r--r--src/tcs/tcs_key_mem_cache.c1175
-rw-r--r--src/tcs/tcs_key_ps.c367
-rw-r--r--src/tcs/tcs_migration.c51
-rw-r--r--src/tcs/tcs_pbg.c2201
-rw-r--r--src/tcs/tcs_ps.c176
-rw-r--r--src/tcs/tcs_quote.c101
-rw-r--r--src/tcs/tcs_quote2.c72
-rw-r--r--src/tcs/tcs_req_mgr.c83
-rw-r--r--src/tcs/tcs_seal.c84
-rw-r--r--src/tcs/tcs_utils.c537
-rw-r--r--src/tcs/tcsi_admin.c518
-rw-r--r--src/tcs/tcsi_aik.c227
-rw-r--r--src/tcs/tcsi_audit.c159
-rw-r--r--src/tcs/tcsi_auth.c111
-rw-r--r--src/tcs/tcsi_bind.c78
-rw-r--r--src/tcs/tcsi_caps.c269
-rw-r--r--src/tcs/tcsi_caps_tpm.c138
-rw-r--r--src/tcs/tcsi_certify.c90
-rw-r--r--src/tcs/tcsi_changeauth.c374
-rw-r--r--src/tcs/tcsi_cmk.c326
-rw-r--r--src/tcs/tcsi_context.c62
-rw-r--r--src/tcs/tcsi_counter.c212
-rw-r--r--src/tcs/tcsi_daa.c192
-rw-r--r--src/tcs/tcsi_delegate.c366
-rw-r--r--src/tcs/tcsi_dir.c103
-rw-r--r--src/tcs/tcsi_ek.c226
-rw-r--r--src/tcs/tcsi_evlog.c388
-rw-r--r--src/tcs/tcsi_key.c388
-rw-r--r--src/tcs/tcsi_maint.c197
-rw-r--r--src/tcs/tcsi_migration.c217
-rw-r--r--src/tcs/tcsi_nv.c242
-rw-r--r--src/tcs/tcsi_oper.c49
-rw-r--r--src/tcs/tcsi_own.c169
-rw-r--r--src/tcs/tcsi_pcr.c134
-rw-r--r--src/tcs/tcsi_ps.c636
-rw-r--r--src/tcs/tcsi_quote.c81
-rw-r--r--src/tcs/tcsi_quote2.c86
-rw-r--r--src/tcs/tcsi_random.c147
-rw-r--r--src/tcs/tcsi_seal.c149
-rw-r--r--src/tcs/tcsi_selftest.c129
-rw-r--r--src/tcs/tcsi_sign.c78
-rw-r--r--src/tcs/tcsi_tick.c119
-rw-r--r--src/tcs/tcsi_transport.c513
93 files changed, 27185 insertions, 0 deletions
diff --git a/src/tcs/Makefile.am b/src/tcs/Makefile.am
new file mode 100644
index 0000000..8540a9a
--- /dev/null
+++ b/src/tcs/Makefile.am
@@ -0,0 +1,142 @@
+noinst_LIBRARIES=libtcs.a
+
+CFLAGS+=-I${top_srcdir}/src/include
+libtcs_a_LIBADD=${top_builddir}/src/tddl/libtddl.a
+libtcs_a_CFLAGS=-DAPPID=\"TCSD\ TCS\" -DVAR_PREFIX=\"@localstatedir@\" -DETC_PREFIX=\"@sysconfdir@\"
+
+libtcs_a_SOURCES=log.c \
+ tcs_caps.c \
+ tcs_req_mgr.c \
+ tcs_context.c \
+ tcsi_context.c \
+ tcs_utils.c \
+ rpc/@RPC@/rpc.c rpc/@RPC@/rpc_context.c \
+ tcsi_caps_tpm.c rpc/@RPC@/rpc_caps_tpm.c \
+ tcs_auth_mgr.c tcsi_auth.c rpc/@RPC@/rpc_auth.c \
+ tcs_pbg.c
+
+if TSS_BUILD_TRANSPORT
+libtcs_a_SOURCES+=tcsi_transport.c rpc/@RPC@/rpc_transport.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_TRANSPORT
+endif
+if TSS_BUILD_TICK
+libtcs_a_SOURCES+=tcsi_tick.c rpc/@RPC@/rpc_tick.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_TICK
+endif
+if TSS_BUILD_COUNTER
+libtcs_a_SOURCES+=tcsi_counter.c tcs_counter.c rpc/@RPC@/rpc_counter.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_COUNTER
+endif
+if TSS_BUILD_RANDOM
+libtcs_a_SOURCES+=tcsi_random.c rpc/@RPC@/rpc_random.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_RANDOM
+endif
+if TSS_BUILD_CAPS
+libtcs_a_SOURCES+=tcsi_caps.c rpc/@RPC@/rpc_caps.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_CAPS
+endif
+if TSS_BUILD_DIR
+libtcs_a_SOURCES+=tcsi_dir.c rpc/@RPC@/rpc_dir.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_DIR
+endif
+if TSS_BUILD_PCR_EVENTS
+libtcs_a_SOURCES+=tcsi_evlog.c tcs_evlog_biosem.c tcs_evlog_imaem.c tcs_evlog.c \
+ rpc/@RPC@/rpc_evlog.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_PCR_EVENTS
+endif
+if TSS_BUILD_SIGN
+libtcs_a_SOURCES+=tcsi_sign.c rpc/@RPC@/rpc_sign.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_SIGN
+endif
+if TSS_BUILD_QUOTE
+libtcs_a_SOURCES+=tcsi_quote.c tcs_quote.c rpc/@RPC@/rpc_quote.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_QUOTE
+endif
+if TSS_BUILD_SEAL
+libtcs_a_SOURCES+=tcsi_seal.c tcs_seal.c rpc/@RPC@/rpc_seal.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_SEAL
+endif
+if TSS_BUILD_CHANGEAUTH
+libtcs_a_SOURCES+=tcsi_changeauth.c rpc/@RPC@/rpc_changeauth.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_CHANGEAUTH
+endif
+if TSS_BUILD_BIND
+libtcs_a_SOURCES+=tcsi_bind.c rpc/@RPC@/rpc_bind.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_BIND
+endif
+if TSS_BUILD_OWN
+libtcs_a_SOURCES+=tcsi_own.c rpc/@RPC@/rpc_own.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_OWN
+endif
+if TSS_BUILD_PS
+libtcs_a_SOURCES+=ps/ps_utils.c ps/tcsps.c tcsi_ps.c tcs_ps.c tcs_key_ps.c rpc/@RPC@/rpc_ps.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_PS
+endif
+if TSS_BUILD_ADMIN
+libtcs_a_SOURCES+=tcsi_admin.c rpc/@RPC@/rpc_admin.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_ADMIN
+endif
+if TSS_BUILD_AIK
+libtcs_a_SOURCES+=tcsi_aik.c tcs_aik.c rpc/@RPC@/rpc_aik.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_AIK
+endif
+if TSS_BUILD_EK
+libtcs_a_SOURCES+=tcsi_ek.c rpc/@RPC@/rpc_ek.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_EK
+endif
+if TSS_BUILD_CERTIFY
+libtcs_a_SOURCES+=tcsi_certify.c rpc/@RPC@/rpc_certify.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_CERTIFY
+endif
+if TSS_BUILD_KEY
+libtcs_a_SOURCES+=tcsi_key.c tcs_key.c tcs_key_mem_cache.c tcs_context_key.c rpc/@RPC@/rpc_key.c \
+ crypto/@CRYPTO_PACKAGE@/crypto.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_KEY
+endif
+if TSS_BUILD_MAINT
+libtcs_a_SOURCES+=tcsi_maint.c rpc/@RPC@/rpc_maint.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_MAINT
+endif
+if TSS_BUILD_MIGRATION
+libtcs_a_SOURCES+=tcsi_migration.c tcs_migration.c rpc/@RPC@/rpc_migration.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_MIGRATION
+endif
+if TSS_BUILD_PCR_EXTEND
+libtcs_a_SOURCES+=tcsi_pcr.c rpc/@RPC@/rpc_pcr_extend.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_PCR_EXTEND
+endif
+if TSS_BUILD_SELFTEST
+libtcs_a_SOURCES+=tcsi_selftest.c rpc/@RPC@/rpc_selftest.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_SELFTEST
+endif
+if TSS_BUILD_DAA
+libtcs_a_SOURCES+=tcsi_daa.c rpc/@RPC@/rpc_daa.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_DAA
+endif
+if TSS_BUILD_NV
+libtcs_a_SOURCES+=tcsi_nv.c rpc/@RPC@/rpc_nv.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_NV
+endif
+if TSS_BUILD_AUDIT
+libtcs_a_SOURCES+=tcsi_audit.c rpc/@RPC@/rpc_audit.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_AUDIT
+endif
+if TSS_BUILD_SEALX
+libtcs_a_CFLAGS+=-DTSS_BUILD_SEALX
+endif
+if TSS_BUILD_TSS12
+libtcs_a_SOURCES+=tcsi_oper.c rpc/@RPC@/rpc_oper.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_TSS12
+endif
+if TSS_BUILD_DELEGATION
+libtcs_a_SOURCES+=tcsi_delegate.c rpc/@RPC@/rpc_delegate.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_DELEGATION
+endif
+if TSS_BUILD_QUOTE2
+libtcs_a_SOURCES+=tcsi_quote2.c tcs_quote2.c rpc/@RPC@/rpc_quote2.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_QUOTE2
+endif
+if TSS_BUILD_CMK
+libtcs_a_SOURCES+=tcsi_cmk.c rpc/@RPC@/rpc_cmk.c
+libtcs_a_CFLAGS+=-DTSS_BUILD_CMK
+endif
diff --git a/src/tcs/Makefile.in b/src/tcs/Makefile.in
new file mode 100644
index 0000000..1c64f40
--- /dev/null
+++ b/src/tcs/Makefile.in
@@ -0,0 +1,2069 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+@TSS_BUILD_TRANSPORT_TRUE@am__append_1 = tcsi_transport.c rpc/@RPC@/rpc_transport.c
+@TSS_BUILD_TRANSPORT_TRUE@am__append_2 = -DTSS_BUILD_TRANSPORT
+@TSS_BUILD_TICK_TRUE@am__append_3 = tcsi_tick.c rpc/@RPC@/rpc_tick.c
+@TSS_BUILD_TICK_TRUE@am__append_4 = -DTSS_BUILD_TICK
+@TSS_BUILD_COUNTER_TRUE@am__append_5 = tcsi_counter.c tcs_counter.c rpc/@RPC@/rpc_counter.c
+@TSS_BUILD_COUNTER_TRUE@am__append_6 = -DTSS_BUILD_COUNTER
+@TSS_BUILD_RANDOM_TRUE@am__append_7 = tcsi_random.c rpc/@RPC@/rpc_random.c
+@TSS_BUILD_RANDOM_TRUE@am__append_8 = -DTSS_BUILD_RANDOM
+@TSS_BUILD_CAPS_TRUE@am__append_9 = tcsi_caps.c rpc/@RPC@/rpc_caps.c
+@TSS_BUILD_CAPS_TRUE@am__append_10 = -DTSS_BUILD_CAPS
+@TSS_BUILD_DIR_TRUE@am__append_11 = tcsi_dir.c rpc/@RPC@/rpc_dir.c
+@TSS_BUILD_DIR_TRUE@am__append_12 = -DTSS_BUILD_DIR
+@TSS_BUILD_PCR_EVENTS_TRUE@am__append_13 = tcsi_evlog.c tcs_evlog_biosem.c tcs_evlog_imaem.c tcs_evlog.c \
+@TSS_BUILD_PCR_EVENTS_TRUE@ rpc/@RPC@/rpc_evlog.c
+
+@TSS_BUILD_PCR_EVENTS_TRUE@am__append_14 = -DTSS_BUILD_PCR_EVENTS
+@TSS_BUILD_SIGN_TRUE@am__append_15 = tcsi_sign.c rpc/@RPC@/rpc_sign.c
+@TSS_BUILD_SIGN_TRUE@am__append_16 = -DTSS_BUILD_SIGN
+@TSS_BUILD_QUOTE_TRUE@am__append_17 = tcsi_quote.c tcs_quote.c rpc/@RPC@/rpc_quote.c
+@TSS_BUILD_QUOTE_TRUE@am__append_18 = -DTSS_BUILD_QUOTE
+@TSS_BUILD_SEAL_TRUE@am__append_19 = tcsi_seal.c tcs_seal.c rpc/@RPC@/rpc_seal.c
+@TSS_BUILD_SEAL_TRUE@am__append_20 = -DTSS_BUILD_SEAL
+@TSS_BUILD_CHANGEAUTH_TRUE@am__append_21 = tcsi_changeauth.c rpc/@RPC@/rpc_changeauth.c
+@TSS_BUILD_CHANGEAUTH_TRUE@am__append_22 = -DTSS_BUILD_CHANGEAUTH
+@TSS_BUILD_BIND_TRUE@am__append_23 = tcsi_bind.c rpc/@RPC@/rpc_bind.c
+@TSS_BUILD_BIND_TRUE@am__append_24 = -DTSS_BUILD_BIND
+@TSS_BUILD_OWN_TRUE@am__append_25 = tcsi_own.c rpc/@RPC@/rpc_own.c
+@TSS_BUILD_OWN_TRUE@am__append_26 = -DTSS_BUILD_OWN
+@TSS_BUILD_PS_TRUE@am__append_27 = ps/ps_utils.c ps/tcsps.c tcsi_ps.c tcs_ps.c tcs_key_ps.c rpc/@RPC@/rpc_ps.c
+@TSS_BUILD_PS_TRUE@am__append_28 = -DTSS_BUILD_PS
+@TSS_BUILD_ADMIN_TRUE@am__append_29 = tcsi_admin.c rpc/@RPC@/rpc_admin.c
+@TSS_BUILD_ADMIN_TRUE@am__append_30 = -DTSS_BUILD_ADMIN
+@TSS_BUILD_AIK_TRUE@am__append_31 = tcsi_aik.c tcs_aik.c rpc/@RPC@/rpc_aik.c
+@TSS_BUILD_AIK_TRUE@am__append_32 = -DTSS_BUILD_AIK
+@TSS_BUILD_EK_TRUE@am__append_33 = tcsi_ek.c rpc/@RPC@/rpc_ek.c
+@TSS_BUILD_EK_TRUE@am__append_34 = -DTSS_BUILD_EK
+@TSS_BUILD_CERTIFY_TRUE@am__append_35 = tcsi_certify.c rpc/@RPC@/rpc_certify.c
+@TSS_BUILD_CERTIFY_TRUE@am__append_36 = -DTSS_BUILD_CERTIFY
+@TSS_BUILD_KEY_TRUE@am__append_37 = tcsi_key.c tcs_key.c tcs_key_mem_cache.c tcs_context_key.c rpc/@RPC@/rpc_key.c \
+@TSS_BUILD_KEY_TRUE@ crypto/@CRYPTO_PACKAGE@/crypto.c
+
+@TSS_BUILD_KEY_TRUE@am__append_38 = -DTSS_BUILD_KEY
+@TSS_BUILD_MAINT_TRUE@am__append_39 = tcsi_maint.c rpc/@RPC@/rpc_maint.c
+@TSS_BUILD_MAINT_TRUE@am__append_40 = -DTSS_BUILD_MAINT
+@TSS_BUILD_MIGRATION_TRUE@am__append_41 = tcsi_migration.c tcs_migration.c rpc/@RPC@/rpc_migration.c
+@TSS_BUILD_MIGRATION_TRUE@am__append_42 = -DTSS_BUILD_MIGRATION
+@TSS_BUILD_PCR_EXTEND_TRUE@am__append_43 = tcsi_pcr.c rpc/@RPC@/rpc_pcr_extend.c
+@TSS_BUILD_PCR_EXTEND_TRUE@am__append_44 = -DTSS_BUILD_PCR_EXTEND
+@TSS_BUILD_SELFTEST_TRUE@am__append_45 = tcsi_selftest.c rpc/@RPC@/rpc_selftest.c
+@TSS_BUILD_SELFTEST_TRUE@am__append_46 = -DTSS_BUILD_SELFTEST
+@TSS_BUILD_DAA_TRUE@am__append_47 = tcsi_daa.c rpc/@RPC@/rpc_daa.c
+@TSS_BUILD_DAA_TRUE@am__append_48 = -DTSS_BUILD_DAA
+@TSS_BUILD_NV_TRUE@am__append_49 = tcsi_nv.c rpc/@RPC@/rpc_nv.c
+@TSS_BUILD_NV_TRUE@am__append_50 = -DTSS_BUILD_NV
+@TSS_BUILD_AUDIT_TRUE@am__append_51 = tcsi_audit.c rpc/@RPC@/rpc_audit.c
+@TSS_BUILD_AUDIT_TRUE@am__append_52 = -DTSS_BUILD_AUDIT
+@TSS_BUILD_SEALX_TRUE@am__append_53 = -DTSS_BUILD_SEALX
+@TSS_BUILD_TSS12_TRUE@am__append_54 = tcsi_oper.c rpc/@RPC@/rpc_oper.c
+@TSS_BUILD_TSS12_TRUE@am__append_55 = -DTSS_BUILD_TSS12
+@TSS_BUILD_DELEGATION_TRUE@am__append_56 = tcsi_delegate.c rpc/@RPC@/rpc_delegate.c
+@TSS_BUILD_DELEGATION_TRUE@am__append_57 = -DTSS_BUILD_DELEGATION
+@TSS_BUILD_QUOTE2_TRUE@am__append_58 = tcsi_quote2.c tcs_quote2.c rpc/@RPC@/rpc_quote2.c
+@TSS_BUILD_QUOTE2_TRUE@am__append_59 = -DTSS_BUILD_QUOTE2
+@TSS_BUILD_CMK_TRUE@am__append_60 = tcsi_cmk.c rpc/@RPC@/rpc_cmk.c
+@TSS_BUILD_CMK_TRUE@am__append_61 = -DTSS_BUILD_CMK
+subdir = src/tcs
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libtcs_a_AR = $(AR) $(ARFLAGS)
+libtcs_a_DEPENDENCIES = ${top_builddir}/src/tddl/libtddl.a
+am__libtcs_a_SOURCES_DIST = log.c tcs_caps.c tcs_req_mgr.c \
+ tcs_context.c tcsi_context.c tcs_utils.c rpc/@RPC@/rpc.c \
+ rpc/@RPC@/rpc_context.c tcsi_caps_tpm.c \
+ rpc/@RPC@/rpc_caps_tpm.c tcs_auth_mgr.c tcsi_auth.c \
+ rpc/@RPC@/rpc_auth.c tcs_pbg.c tcsi_transport.c \
+ rpc/@RPC@/rpc_transport.c tcsi_tick.c rpc/@RPC@/rpc_tick.c \
+ tcsi_counter.c tcs_counter.c rpc/@RPC@/rpc_counter.c \
+ tcsi_random.c rpc/@RPC@/rpc_random.c tcsi_caps.c \
+ rpc/@RPC@/rpc_caps.c tcsi_dir.c rpc/@RPC@/rpc_dir.c \
+ tcsi_evlog.c tcs_evlog_biosem.c tcs_evlog_imaem.c tcs_evlog.c \
+ rpc/@RPC@/rpc_evlog.c tcsi_sign.c rpc/@RPC@/rpc_sign.c \
+ tcsi_quote.c tcs_quote.c rpc/@RPC@/rpc_quote.c tcsi_seal.c \
+ tcs_seal.c rpc/@RPC@/rpc_seal.c tcsi_changeauth.c \
+ rpc/@RPC@/rpc_changeauth.c tcsi_bind.c rpc/@RPC@/rpc_bind.c \
+ tcsi_own.c rpc/@RPC@/rpc_own.c ps/ps_utils.c ps/tcsps.c \
+ tcsi_ps.c tcs_ps.c tcs_key_ps.c rpc/@RPC@/rpc_ps.c \
+ tcsi_admin.c rpc/@RPC@/rpc_admin.c tcsi_aik.c tcs_aik.c \
+ rpc/@RPC@/rpc_aik.c tcsi_ek.c rpc/@RPC@/rpc_ek.c \
+ tcsi_certify.c rpc/@RPC@/rpc_certify.c tcsi_key.c tcs_key.c \
+ tcs_key_mem_cache.c tcs_context_key.c rpc/@RPC@/rpc_key.c \
+ crypto/@CRYPTO_PACKAGE@/crypto.c tcsi_maint.c \
+ rpc/@RPC@/rpc_maint.c tcsi_migration.c tcs_migration.c \
+ rpc/@RPC@/rpc_migration.c tcsi_pcr.c \
+ rpc/@RPC@/rpc_pcr_extend.c tcsi_selftest.c \
+ rpc/@RPC@/rpc_selftest.c tcsi_daa.c rpc/@RPC@/rpc_daa.c \
+ tcsi_nv.c rpc/@RPC@/rpc_nv.c tcsi_audit.c \
+ rpc/@RPC@/rpc_audit.c tcsi_oper.c rpc/@RPC@/rpc_oper.c \
+ tcsi_delegate.c rpc/@RPC@/rpc_delegate.c tcsi_quote2.c \
+ tcs_quote2.c rpc/@RPC@/rpc_quote2.c tcsi_cmk.c \
+ rpc/@RPC@/rpc_cmk.c
+@TSS_BUILD_TRANSPORT_TRUE@am__objects_1 = \
+@TSS_BUILD_TRANSPORT_TRUE@ libtcs_a-tcsi_transport.$(OBJEXT) \
+@TSS_BUILD_TRANSPORT_TRUE@ libtcs_a-rpc_transport.$(OBJEXT)
+@TSS_BUILD_TICK_TRUE@am__objects_2 = libtcs_a-tcsi_tick.$(OBJEXT) \
+@TSS_BUILD_TICK_TRUE@ libtcs_a-rpc_tick.$(OBJEXT)
+@TSS_BUILD_COUNTER_TRUE@am__objects_3 = \
+@TSS_BUILD_COUNTER_TRUE@ libtcs_a-tcsi_counter.$(OBJEXT) \
+@TSS_BUILD_COUNTER_TRUE@ libtcs_a-tcs_counter.$(OBJEXT) \
+@TSS_BUILD_COUNTER_TRUE@ libtcs_a-rpc_counter.$(OBJEXT)
+@TSS_BUILD_RANDOM_TRUE@am__objects_4 = libtcs_a-tcsi_random.$(OBJEXT) \
+@TSS_BUILD_RANDOM_TRUE@ libtcs_a-rpc_random.$(OBJEXT)
+@TSS_BUILD_CAPS_TRUE@am__objects_5 = libtcs_a-tcsi_caps.$(OBJEXT) \
+@TSS_BUILD_CAPS_TRUE@ libtcs_a-rpc_caps.$(OBJEXT)
+@TSS_BUILD_DIR_TRUE@am__objects_6 = libtcs_a-tcsi_dir.$(OBJEXT) \
+@TSS_BUILD_DIR_TRUE@ libtcs_a-rpc_dir.$(OBJEXT)
+@TSS_BUILD_PCR_EVENTS_TRUE@am__objects_7 = \
+@TSS_BUILD_PCR_EVENTS_TRUE@ libtcs_a-tcsi_evlog.$(OBJEXT) \
+@TSS_BUILD_PCR_EVENTS_TRUE@ libtcs_a-tcs_evlog_biosem.$(OBJEXT) \
+@TSS_BUILD_PCR_EVENTS_TRUE@ libtcs_a-tcs_evlog_imaem.$(OBJEXT) \
+@TSS_BUILD_PCR_EVENTS_TRUE@ libtcs_a-tcs_evlog.$(OBJEXT) \
+@TSS_BUILD_PCR_EVENTS_TRUE@ libtcs_a-rpc_evlog.$(OBJEXT)
+@TSS_BUILD_SIGN_TRUE@am__objects_8 = libtcs_a-tcsi_sign.$(OBJEXT) \
+@TSS_BUILD_SIGN_TRUE@ libtcs_a-rpc_sign.$(OBJEXT)
+@TSS_BUILD_QUOTE_TRUE@am__objects_9 = libtcs_a-tcsi_quote.$(OBJEXT) \
+@TSS_BUILD_QUOTE_TRUE@ libtcs_a-tcs_quote.$(OBJEXT) \
+@TSS_BUILD_QUOTE_TRUE@ libtcs_a-rpc_quote.$(OBJEXT)
+@TSS_BUILD_SEAL_TRUE@am__objects_10 = libtcs_a-tcsi_seal.$(OBJEXT) \
+@TSS_BUILD_SEAL_TRUE@ libtcs_a-tcs_seal.$(OBJEXT) \
+@TSS_BUILD_SEAL_TRUE@ libtcs_a-rpc_seal.$(OBJEXT)
+@TSS_BUILD_CHANGEAUTH_TRUE@am__objects_11 = \
+@TSS_BUILD_CHANGEAUTH_TRUE@ libtcs_a-tcsi_changeauth.$(OBJEXT) \
+@TSS_BUILD_CHANGEAUTH_TRUE@ libtcs_a-rpc_changeauth.$(OBJEXT)
+@TSS_BUILD_BIND_TRUE@am__objects_12 = libtcs_a-tcsi_bind.$(OBJEXT) \
+@TSS_BUILD_BIND_TRUE@ libtcs_a-rpc_bind.$(OBJEXT)
+@TSS_BUILD_OWN_TRUE@am__objects_13 = libtcs_a-tcsi_own.$(OBJEXT) \
+@TSS_BUILD_OWN_TRUE@ libtcs_a-rpc_own.$(OBJEXT)
+@TSS_BUILD_PS_TRUE@am__objects_14 = libtcs_a-ps_utils.$(OBJEXT) \
+@TSS_BUILD_PS_TRUE@ libtcs_a-tcsps.$(OBJEXT) \
+@TSS_BUILD_PS_TRUE@ libtcs_a-tcsi_ps.$(OBJEXT) \
+@TSS_BUILD_PS_TRUE@ libtcs_a-tcs_ps.$(OBJEXT) \
+@TSS_BUILD_PS_TRUE@ libtcs_a-tcs_key_ps.$(OBJEXT) \
+@TSS_BUILD_PS_TRUE@ libtcs_a-rpc_ps.$(OBJEXT)
+@TSS_BUILD_ADMIN_TRUE@am__objects_15 = libtcs_a-tcsi_admin.$(OBJEXT) \
+@TSS_BUILD_ADMIN_TRUE@ libtcs_a-rpc_admin.$(OBJEXT)
+@TSS_BUILD_AIK_TRUE@am__objects_16 = libtcs_a-tcsi_aik.$(OBJEXT) \
+@TSS_BUILD_AIK_TRUE@ libtcs_a-tcs_aik.$(OBJEXT) \
+@TSS_BUILD_AIK_TRUE@ libtcs_a-rpc_aik.$(OBJEXT)
+@TSS_BUILD_EK_TRUE@am__objects_17 = libtcs_a-tcsi_ek.$(OBJEXT) \
+@TSS_BUILD_EK_TRUE@ libtcs_a-rpc_ek.$(OBJEXT)
+@TSS_BUILD_CERTIFY_TRUE@am__objects_18 = \
+@TSS_BUILD_CERTIFY_TRUE@ libtcs_a-tcsi_certify.$(OBJEXT) \
+@TSS_BUILD_CERTIFY_TRUE@ libtcs_a-rpc_certify.$(OBJEXT)
+@TSS_BUILD_KEY_TRUE@am__objects_19 = libtcs_a-tcsi_key.$(OBJEXT) \
+@TSS_BUILD_KEY_TRUE@ libtcs_a-tcs_key.$(OBJEXT) \
+@TSS_BUILD_KEY_TRUE@ libtcs_a-tcs_key_mem_cache.$(OBJEXT) \
+@TSS_BUILD_KEY_TRUE@ libtcs_a-tcs_context_key.$(OBJEXT) \
+@TSS_BUILD_KEY_TRUE@ libtcs_a-rpc_key.$(OBJEXT) \
+@TSS_BUILD_KEY_TRUE@ libtcs_a-crypto.$(OBJEXT)
+@TSS_BUILD_MAINT_TRUE@am__objects_20 = libtcs_a-tcsi_maint.$(OBJEXT) \
+@TSS_BUILD_MAINT_TRUE@ libtcs_a-rpc_maint.$(OBJEXT)
+@TSS_BUILD_MIGRATION_TRUE@am__objects_21 = \
+@TSS_BUILD_MIGRATION_TRUE@ libtcs_a-tcsi_migration.$(OBJEXT) \
+@TSS_BUILD_MIGRATION_TRUE@ libtcs_a-tcs_migration.$(OBJEXT) \
+@TSS_BUILD_MIGRATION_TRUE@ libtcs_a-rpc_migration.$(OBJEXT)
+@TSS_BUILD_PCR_EXTEND_TRUE@am__objects_22 = \
+@TSS_BUILD_PCR_EXTEND_TRUE@ libtcs_a-tcsi_pcr.$(OBJEXT) \
+@TSS_BUILD_PCR_EXTEND_TRUE@ libtcs_a-rpc_pcr_extend.$(OBJEXT)
+@TSS_BUILD_SELFTEST_TRUE@am__objects_23 = \
+@TSS_BUILD_SELFTEST_TRUE@ libtcs_a-tcsi_selftest.$(OBJEXT) \
+@TSS_BUILD_SELFTEST_TRUE@ libtcs_a-rpc_selftest.$(OBJEXT)
+@TSS_BUILD_DAA_TRUE@am__objects_24 = libtcs_a-tcsi_daa.$(OBJEXT) \
+@TSS_BUILD_DAA_TRUE@ libtcs_a-rpc_daa.$(OBJEXT)
+@TSS_BUILD_NV_TRUE@am__objects_25 = libtcs_a-tcsi_nv.$(OBJEXT) \
+@TSS_BUILD_NV_TRUE@ libtcs_a-rpc_nv.$(OBJEXT)
+@TSS_BUILD_AUDIT_TRUE@am__objects_26 = libtcs_a-tcsi_audit.$(OBJEXT) \
+@TSS_BUILD_AUDIT_TRUE@ libtcs_a-rpc_audit.$(OBJEXT)
+@TSS_BUILD_TSS12_TRUE@am__objects_27 = libtcs_a-tcsi_oper.$(OBJEXT) \
+@TSS_BUILD_TSS12_TRUE@ libtcs_a-rpc_oper.$(OBJEXT)
+@TSS_BUILD_DELEGATION_TRUE@am__objects_28 = \
+@TSS_BUILD_DELEGATION_TRUE@ libtcs_a-tcsi_delegate.$(OBJEXT) \
+@TSS_BUILD_DELEGATION_TRUE@ libtcs_a-rpc_delegate.$(OBJEXT)
+@TSS_BUILD_QUOTE2_TRUE@am__objects_29 = \
+@TSS_BUILD_QUOTE2_TRUE@ libtcs_a-tcsi_quote2.$(OBJEXT) \
+@TSS_BUILD_QUOTE2_TRUE@ libtcs_a-tcs_quote2.$(OBJEXT) \
+@TSS_BUILD_QUOTE2_TRUE@ libtcs_a-rpc_quote2.$(OBJEXT)
+@TSS_BUILD_CMK_TRUE@am__objects_30 = libtcs_a-tcsi_cmk.$(OBJEXT) \
+@TSS_BUILD_CMK_TRUE@ libtcs_a-rpc_cmk.$(OBJEXT)
+am_libtcs_a_OBJECTS = libtcs_a-log.$(OBJEXT) \
+ libtcs_a-tcs_caps.$(OBJEXT) libtcs_a-tcs_req_mgr.$(OBJEXT) \
+ libtcs_a-tcs_context.$(OBJEXT) libtcs_a-tcsi_context.$(OBJEXT) \
+ libtcs_a-tcs_utils.$(OBJEXT) libtcs_a-rpc.$(OBJEXT) \
+ libtcs_a-rpc_context.$(OBJEXT) \
+ libtcs_a-tcsi_caps_tpm.$(OBJEXT) \
+ libtcs_a-rpc_caps_tpm.$(OBJEXT) \
+ libtcs_a-tcs_auth_mgr.$(OBJEXT) libtcs_a-tcsi_auth.$(OBJEXT) \
+ libtcs_a-rpc_auth.$(OBJEXT) libtcs_a-tcs_pbg.$(OBJEXT) \
+ $(am__objects_1) $(am__objects_2) $(am__objects_3) \
+ $(am__objects_4) $(am__objects_5) $(am__objects_6) \
+ $(am__objects_7) $(am__objects_8) $(am__objects_9) \
+ $(am__objects_10) $(am__objects_11) $(am__objects_12) \
+ $(am__objects_13) $(am__objects_14) $(am__objects_15) \
+ $(am__objects_16) $(am__objects_17) $(am__objects_18) \
+ $(am__objects_19) $(am__objects_20) $(am__objects_21) \
+ $(am__objects_22) $(am__objects_23) $(am__objects_24) \
+ $(am__objects_25) $(am__objects_26) $(am__objects_27) \
+ $(am__objects_28) $(am__objects_29) $(am__objects_30)
+libtcs_a_OBJECTS = $(am_libtcs_a_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libtcs_a_SOURCES)
+DIST_SOURCES = $(am__libtcs_a_SOURCES_DIST)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@ -I${top_srcdir}/src/include
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CRYPTOLIB = @CRYPTOLIB@
+CRYPTO_PACKAGE = @CRYPTO_PACKAGE@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_LIB_DIR = @OPENSSL_LIB_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+RANLIB = @RANLIB@
+RPC = @RPC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TCSD_DEFAULT_PORT = @TCSD_DEFAULT_PORT@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+noinst_LIBRARIES = libtcs.a
+libtcs_a_LIBADD = ${top_builddir}/src/tddl/libtddl.a
+libtcs_a_CFLAGS = -DAPPID=\"TCSD\ TCS\" \
+ -DVAR_PREFIX=\"@localstatedir@\" -DETC_PREFIX=\"@sysconfdir@\" \
+ $(am__append_2) $(am__append_4) $(am__append_6) \
+ $(am__append_8) $(am__append_10) $(am__append_12) \
+ $(am__append_14) $(am__append_16) $(am__append_18) \
+ $(am__append_20) $(am__append_22) $(am__append_24) \
+ $(am__append_26) $(am__append_28) $(am__append_30) \
+ $(am__append_32) $(am__append_34) $(am__append_36) \
+ $(am__append_38) $(am__append_40) $(am__append_42) \
+ $(am__append_44) $(am__append_46) $(am__append_48) \
+ $(am__append_50) $(am__append_52) $(am__append_53) \
+ $(am__append_55) $(am__append_57) $(am__append_59) \
+ $(am__append_61)
+libtcs_a_SOURCES = log.c tcs_caps.c tcs_req_mgr.c tcs_context.c \
+ tcsi_context.c tcs_utils.c rpc/@RPC@/rpc.c \
+ rpc/@RPC@/rpc_context.c tcsi_caps_tpm.c \
+ rpc/@RPC@/rpc_caps_tpm.c tcs_auth_mgr.c tcsi_auth.c \
+ rpc/@RPC@/rpc_auth.c tcs_pbg.c $(am__append_1) $(am__append_3) \
+ $(am__append_5) $(am__append_7) $(am__append_9) \
+ $(am__append_11) $(am__append_13) $(am__append_15) \
+ $(am__append_17) $(am__append_19) $(am__append_21) \
+ $(am__append_23) $(am__append_25) $(am__append_27) \
+ $(am__append_29) $(am__append_31) $(am__append_33) \
+ $(am__append_35) $(am__append_37) $(am__append_39) \
+ $(am__append_41) $(am__append_43) $(am__append_45) \
+ $(am__append_47) $(am__append_49) $(am__append_51) \
+ $(am__append_54) $(am__append_56) $(am__append_58) \
+ $(am__append_60)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/tcs/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/tcs/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libtcs.a: $(libtcs_a_OBJECTS) $(libtcs_a_DEPENDENCIES)
+ -rm -f libtcs.a
+ $(libtcs_a_AR) libtcs.a $(libtcs_a_OBJECTS) $(libtcs_a_LIBADD)
+ $(RANLIB) libtcs.a
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-crypto.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-log.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-ps_utils.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_admin.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_aik.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_audit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_auth.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_bind.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_caps.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_caps_tpm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_certify.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_changeauth.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_cmk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_context.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_counter.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_daa.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_delegate.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_dir.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_ek.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_evlog.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_key.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_maint.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_migration.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_nv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_oper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_own.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_pcr_extend.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_ps.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_quote.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_quote2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_random.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_seal.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_selftest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_sign.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_tick.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-rpc_transport.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_aik.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_auth_mgr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_caps.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_context.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_context_key.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_counter.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_evlog.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_evlog_biosem.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_evlog_imaem.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_key.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_key_mem_cache.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_key_ps.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_migration.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_pbg.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_ps.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_quote.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_quote2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_req_mgr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_seal.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcs_utils.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_admin.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_aik.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_audit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_auth.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_bind.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_caps.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_caps_tpm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_certify.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_changeauth.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_cmk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_context.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_counter.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_daa.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_delegate.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_dir.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_ek.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_evlog.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_key.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_maint.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_migration.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_nv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_oper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_own.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_pcr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_ps.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_quote.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_quote2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_random.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_seal.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_selftest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_sign.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_tick.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsi_transport.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtcs_a-tcsps.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+libtcs_a-log.o: log.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-log.o -MD -MP -MF $(DEPDIR)/libtcs_a-log.Tpo -c -o libtcs_a-log.o `test -f 'log.c' || echo '$(srcdir)/'`log.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-log.Tpo $(DEPDIR)/libtcs_a-log.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='log.c' object='libtcs_a-log.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-log.o `test -f 'log.c' || echo '$(srcdir)/'`log.c
+
+libtcs_a-log.obj: log.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-log.obj -MD -MP -MF $(DEPDIR)/libtcs_a-log.Tpo -c -o libtcs_a-log.obj `if test -f 'log.c'; then $(CYGPATH_W) 'log.c'; else $(CYGPATH_W) '$(srcdir)/log.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-log.Tpo $(DEPDIR)/libtcs_a-log.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='log.c' object='libtcs_a-log.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-log.obj `if test -f 'log.c'; then $(CYGPATH_W) 'log.c'; else $(CYGPATH_W) '$(srcdir)/log.c'; fi`
+
+libtcs_a-tcs_caps.o: tcs_caps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_caps.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_caps.Tpo -c -o libtcs_a-tcs_caps.o `test -f 'tcs_caps.c' || echo '$(srcdir)/'`tcs_caps.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_caps.Tpo $(DEPDIR)/libtcs_a-tcs_caps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_caps.c' object='libtcs_a-tcs_caps.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_caps.o `test -f 'tcs_caps.c' || echo '$(srcdir)/'`tcs_caps.c
+
+libtcs_a-tcs_caps.obj: tcs_caps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_caps.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_caps.Tpo -c -o libtcs_a-tcs_caps.obj `if test -f 'tcs_caps.c'; then $(CYGPATH_W) 'tcs_caps.c'; else $(CYGPATH_W) '$(srcdir)/tcs_caps.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_caps.Tpo $(DEPDIR)/libtcs_a-tcs_caps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_caps.c' object='libtcs_a-tcs_caps.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_caps.obj `if test -f 'tcs_caps.c'; then $(CYGPATH_W) 'tcs_caps.c'; else $(CYGPATH_W) '$(srcdir)/tcs_caps.c'; fi`
+
+libtcs_a-tcs_req_mgr.o: tcs_req_mgr.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_req_mgr.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_req_mgr.Tpo -c -o libtcs_a-tcs_req_mgr.o `test -f 'tcs_req_mgr.c' || echo '$(srcdir)/'`tcs_req_mgr.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_req_mgr.Tpo $(DEPDIR)/libtcs_a-tcs_req_mgr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_req_mgr.c' object='libtcs_a-tcs_req_mgr.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_req_mgr.o `test -f 'tcs_req_mgr.c' || echo '$(srcdir)/'`tcs_req_mgr.c
+
+libtcs_a-tcs_req_mgr.obj: tcs_req_mgr.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_req_mgr.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_req_mgr.Tpo -c -o libtcs_a-tcs_req_mgr.obj `if test -f 'tcs_req_mgr.c'; then $(CYGPATH_W) 'tcs_req_mgr.c'; else $(CYGPATH_W) '$(srcdir)/tcs_req_mgr.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_req_mgr.Tpo $(DEPDIR)/libtcs_a-tcs_req_mgr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_req_mgr.c' object='libtcs_a-tcs_req_mgr.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_req_mgr.obj `if test -f 'tcs_req_mgr.c'; then $(CYGPATH_W) 'tcs_req_mgr.c'; else $(CYGPATH_W) '$(srcdir)/tcs_req_mgr.c'; fi`
+
+libtcs_a-tcs_context.o: tcs_context.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_context.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_context.Tpo -c -o libtcs_a-tcs_context.o `test -f 'tcs_context.c' || echo '$(srcdir)/'`tcs_context.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_context.Tpo $(DEPDIR)/libtcs_a-tcs_context.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_context.c' object='libtcs_a-tcs_context.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_context.o `test -f 'tcs_context.c' || echo '$(srcdir)/'`tcs_context.c
+
+libtcs_a-tcs_context.obj: tcs_context.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_context.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_context.Tpo -c -o libtcs_a-tcs_context.obj `if test -f 'tcs_context.c'; then $(CYGPATH_W) 'tcs_context.c'; else $(CYGPATH_W) '$(srcdir)/tcs_context.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_context.Tpo $(DEPDIR)/libtcs_a-tcs_context.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_context.c' object='libtcs_a-tcs_context.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_context.obj `if test -f 'tcs_context.c'; then $(CYGPATH_W) 'tcs_context.c'; else $(CYGPATH_W) '$(srcdir)/tcs_context.c'; fi`
+
+libtcs_a-tcsi_context.o: tcsi_context.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_context.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_context.Tpo -c -o libtcs_a-tcsi_context.o `test -f 'tcsi_context.c' || echo '$(srcdir)/'`tcsi_context.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_context.Tpo $(DEPDIR)/libtcs_a-tcsi_context.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_context.c' object='libtcs_a-tcsi_context.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_context.o `test -f 'tcsi_context.c' || echo '$(srcdir)/'`tcsi_context.c
+
+libtcs_a-tcsi_context.obj: tcsi_context.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_context.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_context.Tpo -c -o libtcs_a-tcsi_context.obj `if test -f 'tcsi_context.c'; then $(CYGPATH_W) 'tcsi_context.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_context.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_context.Tpo $(DEPDIR)/libtcs_a-tcsi_context.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_context.c' object='libtcs_a-tcsi_context.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_context.obj `if test -f 'tcsi_context.c'; then $(CYGPATH_W) 'tcsi_context.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_context.c'; fi`
+
+libtcs_a-tcs_utils.o: tcs_utils.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_utils.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_utils.Tpo -c -o libtcs_a-tcs_utils.o `test -f 'tcs_utils.c' || echo '$(srcdir)/'`tcs_utils.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_utils.Tpo $(DEPDIR)/libtcs_a-tcs_utils.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_utils.c' object='libtcs_a-tcs_utils.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_utils.o `test -f 'tcs_utils.c' || echo '$(srcdir)/'`tcs_utils.c
+
+libtcs_a-tcs_utils.obj: tcs_utils.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_utils.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_utils.Tpo -c -o libtcs_a-tcs_utils.obj `if test -f 'tcs_utils.c'; then $(CYGPATH_W) 'tcs_utils.c'; else $(CYGPATH_W) '$(srcdir)/tcs_utils.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_utils.Tpo $(DEPDIR)/libtcs_a-tcs_utils.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_utils.c' object='libtcs_a-tcs_utils.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_utils.obj `if test -f 'tcs_utils.c'; then $(CYGPATH_W) 'tcs_utils.c'; else $(CYGPATH_W) '$(srcdir)/tcs_utils.c'; fi`
+
+libtcs_a-rpc.o: rpc/@RPC@/rpc.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc.Tpo -c -o libtcs_a-rpc.o `test -f 'rpc/@RPC@/rpc.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc.Tpo $(DEPDIR)/libtcs_a-rpc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc.c' object='libtcs_a-rpc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc.o `test -f 'rpc/@RPC@/rpc.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc.c
+
+libtcs_a-rpc.obj: rpc/@RPC@/rpc.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc.Tpo -c -o libtcs_a-rpc.obj `if test -f 'rpc/@RPC@/rpc.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc.Tpo $(DEPDIR)/libtcs_a-rpc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc.c' object='libtcs_a-rpc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc.obj `if test -f 'rpc/@RPC@/rpc.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc.c'; fi`
+
+libtcs_a-rpc_context.o: rpc/@RPC@/rpc_context.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_context.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_context.Tpo -c -o libtcs_a-rpc_context.o `test -f 'rpc/@RPC@/rpc_context.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_context.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_context.Tpo $(DEPDIR)/libtcs_a-rpc_context.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_context.c' object='libtcs_a-rpc_context.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_context.o `test -f 'rpc/@RPC@/rpc_context.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_context.c
+
+libtcs_a-rpc_context.obj: rpc/@RPC@/rpc_context.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_context.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_context.Tpo -c -o libtcs_a-rpc_context.obj `if test -f 'rpc/@RPC@/rpc_context.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_context.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_context.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_context.Tpo $(DEPDIR)/libtcs_a-rpc_context.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_context.c' object='libtcs_a-rpc_context.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_context.obj `if test -f 'rpc/@RPC@/rpc_context.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_context.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_context.c'; fi`
+
+libtcs_a-tcsi_caps_tpm.o: tcsi_caps_tpm.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_caps_tpm.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_caps_tpm.Tpo -c -o libtcs_a-tcsi_caps_tpm.o `test -f 'tcsi_caps_tpm.c' || echo '$(srcdir)/'`tcsi_caps_tpm.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_caps_tpm.Tpo $(DEPDIR)/libtcs_a-tcsi_caps_tpm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_caps_tpm.c' object='libtcs_a-tcsi_caps_tpm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_caps_tpm.o `test -f 'tcsi_caps_tpm.c' || echo '$(srcdir)/'`tcsi_caps_tpm.c
+
+libtcs_a-tcsi_caps_tpm.obj: tcsi_caps_tpm.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_caps_tpm.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_caps_tpm.Tpo -c -o libtcs_a-tcsi_caps_tpm.obj `if test -f 'tcsi_caps_tpm.c'; then $(CYGPATH_W) 'tcsi_caps_tpm.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_caps_tpm.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_caps_tpm.Tpo $(DEPDIR)/libtcs_a-tcsi_caps_tpm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_caps_tpm.c' object='libtcs_a-tcsi_caps_tpm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_caps_tpm.obj `if test -f 'tcsi_caps_tpm.c'; then $(CYGPATH_W) 'tcsi_caps_tpm.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_caps_tpm.c'; fi`
+
+libtcs_a-rpc_caps_tpm.o: rpc/@RPC@/rpc_caps_tpm.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_caps_tpm.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_caps_tpm.Tpo -c -o libtcs_a-rpc_caps_tpm.o `test -f 'rpc/@RPC@/rpc_caps_tpm.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_caps_tpm.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_caps_tpm.Tpo $(DEPDIR)/libtcs_a-rpc_caps_tpm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_caps_tpm.c' object='libtcs_a-rpc_caps_tpm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_caps_tpm.o `test -f 'rpc/@RPC@/rpc_caps_tpm.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_caps_tpm.c
+
+libtcs_a-rpc_caps_tpm.obj: rpc/@RPC@/rpc_caps_tpm.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_caps_tpm.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_caps_tpm.Tpo -c -o libtcs_a-rpc_caps_tpm.obj `if test -f 'rpc/@RPC@/rpc_caps_tpm.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_caps_tpm.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_caps_tpm.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_caps_tpm.Tpo $(DEPDIR)/libtcs_a-rpc_caps_tpm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_caps_tpm.c' object='libtcs_a-rpc_caps_tpm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_caps_tpm.obj `if test -f 'rpc/@RPC@/rpc_caps_tpm.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_caps_tpm.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_caps_tpm.c'; fi`
+
+libtcs_a-tcs_auth_mgr.o: tcs_auth_mgr.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_auth_mgr.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_auth_mgr.Tpo -c -o libtcs_a-tcs_auth_mgr.o `test -f 'tcs_auth_mgr.c' || echo '$(srcdir)/'`tcs_auth_mgr.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_auth_mgr.Tpo $(DEPDIR)/libtcs_a-tcs_auth_mgr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_auth_mgr.c' object='libtcs_a-tcs_auth_mgr.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_auth_mgr.o `test -f 'tcs_auth_mgr.c' || echo '$(srcdir)/'`tcs_auth_mgr.c
+
+libtcs_a-tcs_auth_mgr.obj: tcs_auth_mgr.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_auth_mgr.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_auth_mgr.Tpo -c -o libtcs_a-tcs_auth_mgr.obj `if test -f 'tcs_auth_mgr.c'; then $(CYGPATH_W) 'tcs_auth_mgr.c'; else $(CYGPATH_W) '$(srcdir)/tcs_auth_mgr.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_auth_mgr.Tpo $(DEPDIR)/libtcs_a-tcs_auth_mgr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_auth_mgr.c' object='libtcs_a-tcs_auth_mgr.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_auth_mgr.obj `if test -f 'tcs_auth_mgr.c'; then $(CYGPATH_W) 'tcs_auth_mgr.c'; else $(CYGPATH_W) '$(srcdir)/tcs_auth_mgr.c'; fi`
+
+libtcs_a-tcsi_auth.o: tcsi_auth.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_auth.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_auth.Tpo -c -o libtcs_a-tcsi_auth.o `test -f 'tcsi_auth.c' || echo '$(srcdir)/'`tcsi_auth.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_auth.Tpo $(DEPDIR)/libtcs_a-tcsi_auth.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_auth.c' object='libtcs_a-tcsi_auth.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_auth.o `test -f 'tcsi_auth.c' || echo '$(srcdir)/'`tcsi_auth.c
+
+libtcs_a-tcsi_auth.obj: tcsi_auth.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_auth.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_auth.Tpo -c -o libtcs_a-tcsi_auth.obj `if test -f 'tcsi_auth.c'; then $(CYGPATH_W) 'tcsi_auth.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_auth.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_auth.Tpo $(DEPDIR)/libtcs_a-tcsi_auth.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_auth.c' object='libtcs_a-tcsi_auth.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_auth.obj `if test -f 'tcsi_auth.c'; then $(CYGPATH_W) 'tcsi_auth.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_auth.c'; fi`
+
+libtcs_a-rpc_auth.o: rpc/@RPC@/rpc_auth.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_auth.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_auth.Tpo -c -o libtcs_a-rpc_auth.o `test -f 'rpc/@RPC@/rpc_auth.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_auth.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_auth.Tpo $(DEPDIR)/libtcs_a-rpc_auth.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_auth.c' object='libtcs_a-rpc_auth.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_auth.o `test -f 'rpc/@RPC@/rpc_auth.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_auth.c
+
+libtcs_a-rpc_auth.obj: rpc/@RPC@/rpc_auth.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_auth.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_auth.Tpo -c -o libtcs_a-rpc_auth.obj `if test -f 'rpc/@RPC@/rpc_auth.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_auth.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_auth.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_auth.Tpo $(DEPDIR)/libtcs_a-rpc_auth.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_auth.c' object='libtcs_a-rpc_auth.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_auth.obj `if test -f 'rpc/@RPC@/rpc_auth.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_auth.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_auth.c'; fi`
+
+libtcs_a-tcs_pbg.o: tcs_pbg.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_pbg.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_pbg.Tpo -c -o libtcs_a-tcs_pbg.o `test -f 'tcs_pbg.c' || echo '$(srcdir)/'`tcs_pbg.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_pbg.Tpo $(DEPDIR)/libtcs_a-tcs_pbg.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_pbg.c' object='libtcs_a-tcs_pbg.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_pbg.o `test -f 'tcs_pbg.c' || echo '$(srcdir)/'`tcs_pbg.c
+
+libtcs_a-tcs_pbg.obj: tcs_pbg.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_pbg.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_pbg.Tpo -c -o libtcs_a-tcs_pbg.obj `if test -f 'tcs_pbg.c'; then $(CYGPATH_W) 'tcs_pbg.c'; else $(CYGPATH_W) '$(srcdir)/tcs_pbg.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_pbg.Tpo $(DEPDIR)/libtcs_a-tcs_pbg.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_pbg.c' object='libtcs_a-tcs_pbg.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_pbg.obj `if test -f 'tcs_pbg.c'; then $(CYGPATH_W) 'tcs_pbg.c'; else $(CYGPATH_W) '$(srcdir)/tcs_pbg.c'; fi`
+
+libtcs_a-tcsi_transport.o: tcsi_transport.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_transport.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_transport.Tpo -c -o libtcs_a-tcsi_transport.o `test -f 'tcsi_transport.c' || echo '$(srcdir)/'`tcsi_transport.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_transport.Tpo $(DEPDIR)/libtcs_a-tcsi_transport.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_transport.c' object='libtcs_a-tcsi_transport.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_transport.o `test -f 'tcsi_transport.c' || echo '$(srcdir)/'`tcsi_transport.c
+
+libtcs_a-tcsi_transport.obj: tcsi_transport.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_transport.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_transport.Tpo -c -o libtcs_a-tcsi_transport.obj `if test -f 'tcsi_transport.c'; then $(CYGPATH_W) 'tcsi_transport.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_transport.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_transport.Tpo $(DEPDIR)/libtcs_a-tcsi_transport.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_transport.c' object='libtcs_a-tcsi_transport.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_transport.obj `if test -f 'tcsi_transport.c'; then $(CYGPATH_W) 'tcsi_transport.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_transport.c'; fi`
+
+libtcs_a-rpc_transport.o: rpc/@RPC@/rpc_transport.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_transport.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_transport.Tpo -c -o libtcs_a-rpc_transport.o `test -f 'rpc/@RPC@/rpc_transport.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_transport.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_transport.Tpo $(DEPDIR)/libtcs_a-rpc_transport.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_transport.c' object='libtcs_a-rpc_transport.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_transport.o `test -f 'rpc/@RPC@/rpc_transport.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_transport.c
+
+libtcs_a-rpc_transport.obj: rpc/@RPC@/rpc_transport.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_transport.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_transport.Tpo -c -o libtcs_a-rpc_transport.obj `if test -f 'rpc/@RPC@/rpc_transport.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_transport.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_transport.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_transport.Tpo $(DEPDIR)/libtcs_a-rpc_transport.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_transport.c' object='libtcs_a-rpc_transport.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_transport.obj `if test -f 'rpc/@RPC@/rpc_transport.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_transport.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_transport.c'; fi`
+
+libtcs_a-tcsi_tick.o: tcsi_tick.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_tick.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_tick.Tpo -c -o libtcs_a-tcsi_tick.o `test -f 'tcsi_tick.c' || echo '$(srcdir)/'`tcsi_tick.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_tick.Tpo $(DEPDIR)/libtcs_a-tcsi_tick.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_tick.c' object='libtcs_a-tcsi_tick.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_tick.o `test -f 'tcsi_tick.c' || echo '$(srcdir)/'`tcsi_tick.c
+
+libtcs_a-tcsi_tick.obj: tcsi_tick.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_tick.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_tick.Tpo -c -o libtcs_a-tcsi_tick.obj `if test -f 'tcsi_tick.c'; then $(CYGPATH_W) 'tcsi_tick.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_tick.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_tick.Tpo $(DEPDIR)/libtcs_a-tcsi_tick.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_tick.c' object='libtcs_a-tcsi_tick.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_tick.obj `if test -f 'tcsi_tick.c'; then $(CYGPATH_W) 'tcsi_tick.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_tick.c'; fi`
+
+libtcs_a-rpc_tick.o: rpc/@RPC@/rpc_tick.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_tick.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_tick.Tpo -c -o libtcs_a-rpc_tick.o `test -f 'rpc/@RPC@/rpc_tick.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_tick.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_tick.Tpo $(DEPDIR)/libtcs_a-rpc_tick.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_tick.c' object='libtcs_a-rpc_tick.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_tick.o `test -f 'rpc/@RPC@/rpc_tick.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_tick.c
+
+libtcs_a-rpc_tick.obj: rpc/@RPC@/rpc_tick.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_tick.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_tick.Tpo -c -o libtcs_a-rpc_tick.obj `if test -f 'rpc/@RPC@/rpc_tick.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_tick.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_tick.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_tick.Tpo $(DEPDIR)/libtcs_a-rpc_tick.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_tick.c' object='libtcs_a-rpc_tick.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_tick.obj `if test -f 'rpc/@RPC@/rpc_tick.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_tick.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_tick.c'; fi`
+
+libtcs_a-tcsi_counter.o: tcsi_counter.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_counter.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_counter.Tpo -c -o libtcs_a-tcsi_counter.o `test -f 'tcsi_counter.c' || echo '$(srcdir)/'`tcsi_counter.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_counter.Tpo $(DEPDIR)/libtcs_a-tcsi_counter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_counter.c' object='libtcs_a-tcsi_counter.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_counter.o `test -f 'tcsi_counter.c' || echo '$(srcdir)/'`tcsi_counter.c
+
+libtcs_a-tcsi_counter.obj: tcsi_counter.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_counter.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_counter.Tpo -c -o libtcs_a-tcsi_counter.obj `if test -f 'tcsi_counter.c'; then $(CYGPATH_W) 'tcsi_counter.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_counter.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_counter.Tpo $(DEPDIR)/libtcs_a-tcsi_counter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_counter.c' object='libtcs_a-tcsi_counter.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_counter.obj `if test -f 'tcsi_counter.c'; then $(CYGPATH_W) 'tcsi_counter.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_counter.c'; fi`
+
+libtcs_a-tcs_counter.o: tcs_counter.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_counter.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_counter.Tpo -c -o libtcs_a-tcs_counter.o `test -f 'tcs_counter.c' || echo '$(srcdir)/'`tcs_counter.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_counter.Tpo $(DEPDIR)/libtcs_a-tcs_counter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_counter.c' object='libtcs_a-tcs_counter.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_counter.o `test -f 'tcs_counter.c' || echo '$(srcdir)/'`tcs_counter.c
+
+libtcs_a-tcs_counter.obj: tcs_counter.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_counter.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_counter.Tpo -c -o libtcs_a-tcs_counter.obj `if test -f 'tcs_counter.c'; then $(CYGPATH_W) 'tcs_counter.c'; else $(CYGPATH_W) '$(srcdir)/tcs_counter.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_counter.Tpo $(DEPDIR)/libtcs_a-tcs_counter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_counter.c' object='libtcs_a-tcs_counter.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_counter.obj `if test -f 'tcs_counter.c'; then $(CYGPATH_W) 'tcs_counter.c'; else $(CYGPATH_W) '$(srcdir)/tcs_counter.c'; fi`
+
+libtcs_a-rpc_counter.o: rpc/@RPC@/rpc_counter.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_counter.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_counter.Tpo -c -o libtcs_a-rpc_counter.o `test -f 'rpc/@RPC@/rpc_counter.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_counter.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_counter.Tpo $(DEPDIR)/libtcs_a-rpc_counter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_counter.c' object='libtcs_a-rpc_counter.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_counter.o `test -f 'rpc/@RPC@/rpc_counter.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_counter.c
+
+libtcs_a-rpc_counter.obj: rpc/@RPC@/rpc_counter.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_counter.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_counter.Tpo -c -o libtcs_a-rpc_counter.obj `if test -f 'rpc/@RPC@/rpc_counter.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_counter.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_counter.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_counter.Tpo $(DEPDIR)/libtcs_a-rpc_counter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_counter.c' object='libtcs_a-rpc_counter.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_counter.obj `if test -f 'rpc/@RPC@/rpc_counter.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_counter.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_counter.c'; fi`
+
+libtcs_a-tcsi_random.o: tcsi_random.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_random.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_random.Tpo -c -o libtcs_a-tcsi_random.o `test -f 'tcsi_random.c' || echo '$(srcdir)/'`tcsi_random.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_random.Tpo $(DEPDIR)/libtcs_a-tcsi_random.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_random.c' object='libtcs_a-tcsi_random.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_random.o `test -f 'tcsi_random.c' || echo '$(srcdir)/'`tcsi_random.c
+
+libtcs_a-tcsi_random.obj: tcsi_random.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_random.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_random.Tpo -c -o libtcs_a-tcsi_random.obj `if test -f 'tcsi_random.c'; then $(CYGPATH_W) 'tcsi_random.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_random.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_random.Tpo $(DEPDIR)/libtcs_a-tcsi_random.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_random.c' object='libtcs_a-tcsi_random.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_random.obj `if test -f 'tcsi_random.c'; then $(CYGPATH_W) 'tcsi_random.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_random.c'; fi`
+
+libtcs_a-rpc_random.o: rpc/@RPC@/rpc_random.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_random.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_random.Tpo -c -o libtcs_a-rpc_random.o `test -f 'rpc/@RPC@/rpc_random.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_random.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_random.Tpo $(DEPDIR)/libtcs_a-rpc_random.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_random.c' object='libtcs_a-rpc_random.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_random.o `test -f 'rpc/@RPC@/rpc_random.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_random.c
+
+libtcs_a-rpc_random.obj: rpc/@RPC@/rpc_random.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_random.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_random.Tpo -c -o libtcs_a-rpc_random.obj `if test -f 'rpc/@RPC@/rpc_random.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_random.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_random.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_random.Tpo $(DEPDIR)/libtcs_a-rpc_random.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_random.c' object='libtcs_a-rpc_random.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_random.obj `if test -f 'rpc/@RPC@/rpc_random.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_random.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_random.c'; fi`
+
+libtcs_a-tcsi_caps.o: tcsi_caps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_caps.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_caps.Tpo -c -o libtcs_a-tcsi_caps.o `test -f 'tcsi_caps.c' || echo '$(srcdir)/'`tcsi_caps.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_caps.Tpo $(DEPDIR)/libtcs_a-tcsi_caps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_caps.c' object='libtcs_a-tcsi_caps.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_caps.o `test -f 'tcsi_caps.c' || echo '$(srcdir)/'`tcsi_caps.c
+
+libtcs_a-tcsi_caps.obj: tcsi_caps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_caps.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_caps.Tpo -c -o libtcs_a-tcsi_caps.obj `if test -f 'tcsi_caps.c'; then $(CYGPATH_W) 'tcsi_caps.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_caps.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_caps.Tpo $(DEPDIR)/libtcs_a-tcsi_caps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_caps.c' object='libtcs_a-tcsi_caps.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_caps.obj `if test -f 'tcsi_caps.c'; then $(CYGPATH_W) 'tcsi_caps.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_caps.c'; fi`
+
+libtcs_a-rpc_caps.o: rpc/@RPC@/rpc_caps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_caps.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_caps.Tpo -c -o libtcs_a-rpc_caps.o `test -f 'rpc/@RPC@/rpc_caps.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_caps.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_caps.Tpo $(DEPDIR)/libtcs_a-rpc_caps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_caps.c' object='libtcs_a-rpc_caps.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_caps.o `test -f 'rpc/@RPC@/rpc_caps.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_caps.c
+
+libtcs_a-rpc_caps.obj: rpc/@RPC@/rpc_caps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_caps.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_caps.Tpo -c -o libtcs_a-rpc_caps.obj `if test -f 'rpc/@RPC@/rpc_caps.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_caps.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_caps.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_caps.Tpo $(DEPDIR)/libtcs_a-rpc_caps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_caps.c' object='libtcs_a-rpc_caps.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_caps.obj `if test -f 'rpc/@RPC@/rpc_caps.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_caps.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_caps.c'; fi`
+
+libtcs_a-tcsi_dir.o: tcsi_dir.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_dir.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_dir.Tpo -c -o libtcs_a-tcsi_dir.o `test -f 'tcsi_dir.c' || echo '$(srcdir)/'`tcsi_dir.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_dir.Tpo $(DEPDIR)/libtcs_a-tcsi_dir.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_dir.c' object='libtcs_a-tcsi_dir.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_dir.o `test -f 'tcsi_dir.c' || echo '$(srcdir)/'`tcsi_dir.c
+
+libtcs_a-tcsi_dir.obj: tcsi_dir.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_dir.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_dir.Tpo -c -o libtcs_a-tcsi_dir.obj `if test -f 'tcsi_dir.c'; then $(CYGPATH_W) 'tcsi_dir.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_dir.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_dir.Tpo $(DEPDIR)/libtcs_a-tcsi_dir.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_dir.c' object='libtcs_a-tcsi_dir.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_dir.obj `if test -f 'tcsi_dir.c'; then $(CYGPATH_W) 'tcsi_dir.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_dir.c'; fi`
+
+libtcs_a-rpc_dir.o: rpc/@RPC@/rpc_dir.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_dir.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_dir.Tpo -c -o libtcs_a-rpc_dir.o `test -f 'rpc/@RPC@/rpc_dir.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_dir.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_dir.Tpo $(DEPDIR)/libtcs_a-rpc_dir.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_dir.c' object='libtcs_a-rpc_dir.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_dir.o `test -f 'rpc/@RPC@/rpc_dir.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_dir.c
+
+libtcs_a-rpc_dir.obj: rpc/@RPC@/rpc_dir.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_dir.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_dir.Tpo -c -o libtcs_a-rpc_dir.obj `if test -f 'rpc/@RPC@/rpc_dir.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_dir.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_dir.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_dir.Tpo $(DEPDIR)/libtcs_a-rpc_dir.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_dir.c' object='libtcs_a-rpc_dir.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_dir.obj `if test -f 'rpc/@RPC@/rpc_dir.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_dir.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_dir.c'; fi`
+
+libtcs_a-tcsi_evlog.o: tcsi_evlog.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_evlog.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_evlog.Tpo -c -o libtcs_a-tcsi_evlog.o `test -f 'tcsi_evlog.c' || echo '$(srcdir)/'`tcsi_evlog.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_evlog.Tpo $(DEPDIR)/libtcs_a-tcsi_evlog.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_evlog.c' object='libtcs_a-tcsi_evlog.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_evlog.o `test -f 'tcsi_evlog.c' || echo '$(srcdir)/'`tcsi_evlog.c
+
+libtcs_a-tcsi_evlog.obj: tcsi_evlog.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_evlog.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_evlog.Tpo -c -o libtcs_a-tcsi_evlog.obj `if test -f 'tcsi_evlog.c'; then $(CYGPATH_W) 'tcsi_evlog.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_evlog.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_evlog.Tpo $(DEPDIR)/libtcs_a-tcsi_evlog.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_evlog.c' object='libtcs_a-tcsi_evlog.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_evlog.obj `if test -f 'tcsi_evlog.c'; then $(CYGPATH_W) 'tcsi_evlog.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_evlog.c'; fi`
+
+libtcs_a-tcs_evlog_biosem.o: tcs_evlog_biosem.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_evlog_biosem.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_evlog_biosem.Tpo -c -o libtcs_a-tcs_evlog_biosem.o `test -f 'tcs_evlog_biosem.c' || echo '$(srcdir)/'`tcs_evlog_biosem.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_evlog_biosem.Tpo $(DEPDIR)/libtcs_a-tcs_evlog_biosem.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_evlog_biosem.c' object='libtcs_a-tcs_evlog_biosem.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_evlog_biosem.o `test -f 'tcs_evlog_biosem.c' || echo '$(srcdir)/'`tcs_evlog_biosem.c
+
+libtcs_a-tcs_evlog_biosem.obj: tcs_evlog_biosem.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_evlog_biosem.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_evlog_biosem.Tpo -c -o libtcs_a-tcs_evlog_biosem.obj `if test -f 'tcs_evlog_biosem.c'; then $(CYGPATH_W) 'tcs_evlog_biosem.c'; else $(CYGPATH_W) '$(srcdir)/tcs_evlog_biosem.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_evlog_biosem.Tpo $(DEPDIR)/libtcs_a-tcs_evlog_biosem.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_evlog_biosem.c' object='libtcs_a-tcs_evlog_biosem.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_evlog_biosem.obj `if test -f 'tcs_evlog_biosem.c'; then $(CYGPATH_W) 'tcs_evlog_biosem.c'; else $(CYGPATH_W) '$(srcdir)/tcs_evlog_biosem.c'; fi`
+
+libtcs_a-tcs_evlog_imaem.o: tcs_evlog_imaem.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_evlog_imaem.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_evlog_imaem.Tpo -c -o libtcs_a-tcs_evlog_imaem.o `test -f 'tcs_evlog_imaem.c' || echo '$(srcdir)/'`tcs_evlog_imaem.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_evlog_imaem.Tpo $(DEPDIR)/libtcs_a-tcs_evlog_imaem.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_evlog_imaem.c' object='libtcs_a-tcs_evlog_imaem.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_evlog_imaem.o `test -f 'tcs_evlog_imaem.c' || echo '$(srcdir)/'`tcs_evlog_imaem.c
+
+libtcs_a-tcs_evlog_imaem.obj: tcs_evlog_imaem.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_evlog_imaem.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_evlog_imaem.Tpo -c -o libtcs_a-tcs_evlog_imaem.obj `if test -f 'tcs_evlog_imaem.c'; then $(CYGPATH_W) 'tcs_evlog_imaem.c'; else $(CYGPATH_W) '$(srcdir)/tcs_evlog_imaem.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_evlog_imaem.Tpo $(DEPDIR)/libtcs_a-tcs_evlog_imaem.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_evlog_imaem.c' object='libtcs_a-tcs_evlog_imaem.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_evlog_imaem.obj `if test -f 'tcs_evlog_imaem.c'; then $(CYGPATH_W) 'tcs_evlog_imaem.c'; else $(CYGPATH_W) '$(srcdir)/tcs_evlog_imaem.c'; fi`
+
+libtcs_a-tcs_evlog.o: tcs_evlog.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_evlog.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_evlog.Tpo -c -o libtcs_a-tcs_evlog.o `test -f 'tcs_evlog.c' || echo '$(srcdir)/'`tcs_evlog.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_evlog.Tpo $(DEPDIR)/libtcs_a-tcs_evlog.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_evlog.c' object='libtcs_a-tcs_evlog.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_evlog.o `test -f 'tcs_evlog.c' || echo '$(srcdir)/'`tcs_evlog.c
+
+libtcs_a-tcs_evlog.obj: tcs_evlog.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_evlog.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_evlog.Tpo -c -o libtcs_a-tcs_evlog.obj `if test -f 'tcs_evlog.c'; then $(CYGPATH_W) 'tcs_evlog.c'; else $(CYGPATH_W) '$(srcdir)/tcs_evlog.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_evlog.Tpo $(DEPDIR)/libtcs_a-tcs_evlog.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_evlog.c' object='libtcs_a-tcs_evlog.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_evlog.obj `if test -f 'tcs_evlog.c'; then $(CYGPATH_W) 'tcs_evlog.c'; else $(CYGPATH_W) '$(srcdir)/tcs_evlog.c'; fi`
+
+libtcs_a-rpc_evlog.o: rpc/@RPC@/rpc_evlog.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_evlog.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_evlog.Tpo -c -o libtcs_a-rpc_evlog.o `test -f 'rpc/@RPC@/rpc_evlog.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_evlog.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_evlog.Tpo $(DEPDIR)/libtcs_a-rpc_evlog.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_evlog.c' object='libtcs_a-rpc_evlog.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_evlog.o `test -f 'rpc/@RPC@/rpc_evlog.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_evlog.c
+
+libtcs_a-rpc_evlog.obj: rpc/@RPC@/rpc_evlog.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_evlog.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_evlog.Tpo -c -o libtcs_a-rpc_evlog.obj `if test -f 'rpc/@RPC@/rpc_evlog.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_evlog.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_evlog.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_evlog.Tpo $(DEPDIR)/libtcs_a-rpc_evlog.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_evlog.c' object='libtcs_a-rpc_evlog.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_evlog.obj `if test -f 'rpc/@RPC@/rpc_evlog.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_evlog.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_evlog.c'; fi`
+
+libtcs_a-tcsi_sign.o: tcsi_sign.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_sign.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_sign.Tpo -c -o libtcs_a-tcsi_sign.o `test -f 'tcsi_sign.c' || echo '$(srcdir)/'`tcsi_sign.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_sign.Tpo $(DEPDIR)/libtcs_a-tcsi_sign.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_sign.c' object='libtcs_a-tcsi_sign.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_sign.o `test -f 'tcsi_sign.c' || echo '$(srcdir)/'`tcsi_sign.c
+
+libtcs_a-tcsi_sign.obj: tcsi_sign.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_sign.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_sign.Tpo -c -o libtcs_a-tcsi_sign.obj `if test -f 'tcsi_sign.c'; then $(CYGPATH_W) 'tcsi_sign.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_sign.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_sign.Tpo $(DEPDIR)/libtcs_a-tcsi_sign.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_sign.c' object='libtcs_a-tcsi_sign.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_sign.obj `if test -f 'tcsi_sign.c'; then $(CYGPATH_W) 'tcsi_sign.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_sign.c'; fi`
+
+libtcs_a-rpc_sign.o: rpc/@RPC@/rpc_sign.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_sign.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_sign.Tpo -c -o libtcs_a-rpc_sign.o `test -f 'rpc/@RPC@/rpc_sign.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_sign.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_sign.Tpo $(DEPDIR)/libtcs_a-rpc_sign.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_sign.c' object='libtcs_a-rpc_sign.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_sign.o `test -f 'rpc/@RPC@/rpc_sign.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_sign.c
+
+libtcs_a-rpc_sign.obj: rpc/@RPC@/rpc_sign.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_sign.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_sign.Tpo -c -o libtcs_a-rpc_sign.obj `if test -f 'rpc/@RPC@/rpc_sign.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_sign.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_sign.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_sign.Tpo $(DEPDIR)/libtcs_a-rpc_sign.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_sign.c' object='libtcs_a-rpc_sign.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_sign.obj `if test -f 'rpc/@RPC@/rpc_sign.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_sign.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_sign.c'; fi`
+
+libtcs_a-tcsi_quote.o: tcsi_quote.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_quote.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_quote.Tpo -c -o libtcs_a-tcsi_quote.o `test -f 'tcsi_quote.c' || echo '$(srcdir)/'`tcsi_quote.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_quote.Tpo $(DEPDIR)/libtcs_a-tcsi_quote.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_quote.c' object='libtcs_a-tcsi_quote.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_quote.o `test -f 'tcsi_quote.c' || echo '$(srcdir)/'`tcsi_quote.c
+
+libtcs_a-tcsi_quote.obj: tcsi_quote.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_quote.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_quote.Tpo -c -o libtcs_a-tcsi_quote.obj `if test -f 'tcsi_quote.c'; then $(CYGPATH_W) 'tcsi_quote.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_quote.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_quote.Tpo $(DEPDIR)/libtcs_a-tcsi_quote.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_quote.c' object='libtcs_a-tcsi_quote.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_quote.obj `if test -f 'tcsi_quote.c'; then $(CYGPATH_W) 'tcsi_quote.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_quote.c'; fi`
+
+libtcs_a-tcs_quote.o: tcs_quote.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_quote.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_quote.Tpo -c -o libtcs_a-tcs_quote.o `test -f 'tcs_quote.c' || echo '$(srcdir)/'`tcs_quote.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_quote.Tpo $(DEPDIR)/libtcs_a-tcs_quote.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_quote.c' object='libtcs_a-tcs_quote.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_quote.o `test -f 'tcs_quote.c' || echo '$(srcdir)/'`tcs_quote.c
+
+libtcs_a-tcs_quote.obj: tcs_quote.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_quote.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_quote.Tpo -c -o libtcs_a-tcs_quote.obj `if test -f 'tcs_quote.c'; then $(CYGPATH_W) 'tcs_quote.c'; else $(CYGPATH_W) '$(srcdir)/tcs_quote.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_quote.Tpo $(DEPDIR)/libtcs_a-tcs_quote.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_quote.c' object='libtcs_a-tcs_quote.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_quote.obj `if test -f 'tcs_quote.c'; then $(CYGPATH_W) 'tcs_quote.c'; else $(CYGPATH_W) '$(srcdir)/tcs_quote.c'; fi`
+
+libtcs_a-rpc_quote.o: rpc/@RPC@/rpc_quote.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_quote.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_quote.Tpo -c -o libtcs_a-rpc_quote.o `test -f 'rpc/@RPC@/rpc_quote.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_quote.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_quote.Tpo $(DEPDIR)/libtcs_a-rpc_quote.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_quote.c' object='libtcs_a-rpc_quote.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_quote.o `test -f 'rpc/@RPC@/rpc_quote.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_quote.c
+
+libtcs_a-rpc_quote.obj: rpc/@RPC@/rpc_quote.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_quote.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_quote.Tpo -c -o libtcs_a-rpc_quote.obj `if test -f 'rpc/@RPC@/rpc_quote.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_quote.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_quote.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_quote.Tpo $(DEPDIR)/libtcs_a-rpc_quote.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_quote.c' object='libtcs_a-rpc_quote.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_quote.obj `if test -f 'rpc/@RPC@/rpc_quote.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_quote.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_quote.c'; fi`
+
+libtcs_a-tcsi_seal.o: tcsi_seal.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_seal.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_seal.Tpo -c -o libtcs_a-tcsi_seal.o `test -f 'tcsi_seal.c' || echo '$(srcdir)/'`tcsi_seal.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_seal.Tpo $(DEPDIR)/libtcs_a-tcsi_seal.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_seal.c' object='libtcs_a-tcsi_seal.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_seal.o `test -f 'tcsi_seal.c' || echo '$(srcdir)/'`tcsi_seal.c
+
+libtcs_a-tcsi_seal.obj: tcsi_seal.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_seal.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_seal.Tpo -c -o libtcs_a-tcsi_seal.obj `if test -f 'tcsi_seal.c'; then $(CYGPATH_W) 'tcsi_seal.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_seal.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_seal.Tpo $(DEPDIR)/libtcs_a-tcsi_seal.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_seal.c' object='libtcs_a-tcsi_seal.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_seal.obj `if test -f 'tcsi_seal.c'; then $(CYGPATH_W) 'tcsi_seal.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_seal.c'; fi`
+
+libtcs_a-tcs_seal.o: tcs_seal.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_seal.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_seal.Tpo -c -o libtcs_a-tcs_seal.o `test -f 'tcs_seal.c' || echo '$(srcdir)/'`tcs_seal.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_seal.Tpo $(DEPDIR)/libtcs_a-tcs_seal.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_seal.c' object='libtcs_a-tcs_seal.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_seal.o `test -f 'tcs_seal.c' || echo '$(srcdir)/'`tcs_seal.c
+
+libtcs_a-tcs_seal.obj: tcs_seal.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_seal.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_seal.Tpo -c -o libtcs_a-tcs_seal.obj `if test -f 'tcs_seal.c'; then $(CYGPATH_W) 'tcs_seal.c'; else $(CYGPATH_W) '$(srcdir)/tcs_seal.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_seal.Tpo $(DEPDIR)/libtcs_a-tcs_seal.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_seal.c' object='libtcs_a-tcs_seal.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_seal.obj `if test -f 'tcs_seal.c'; then $(CYGPATH_W) 'tcs_seal.c'; else $(CYGPATH_W) '$(srcdir)/tcs_seal.c'; fi`
+
+libtcs_a-rpc_seal.o: rpc/@RPC@/rpc_seal.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_seal.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_seal.Tpo -c -o libtcs_a-rpc_seal.o `test -f 'rpc/@RPC@/rpc_seal.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_seal.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_seal.Tpo $(DEPDIR)/libtcs_a-rpc_seal.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_seal.c' object='libtcs_a-rpc_seal.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_seal.o `test -f 'rpc/@RPC@/rpc_seal.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_seal.c
+
+libtcs_a-rpc_seal.obj: rpc/@RPC@/rpc_seal.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_seal.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_seal.Tpo -c -o libtcs_a-rpc_seal.obj `if test -f 'rpc/@RPC@/rpc_seal.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_seal.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_seal.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_seal.Tpo $(DEPDIR)/libtcs_a-rpc_seal.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_seal.c' object='libtcs_a-rpc_seal.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_seal.obj `if test -f 'rpc/@RPC@/rpc_seal.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_seal.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_seal.c'; fi`
+
+libtcs_a-tcsi_changeauth.o: tcsi_changeauth.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_changeauth.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_changeauth.Tpo -c -o libtcs_a-tcsi_changeauth.o `test -f 'tcsi_changeauth.c' || echo '$(srcdir)/'`tcsi_changeauth.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_changeauth.Tpo $(DEPDIR)/libtcs_a-tcsi_changeauth.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_changeauth.c' object='libtcs_a-tcsi_changeauth.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_changeauth.o `test -f 'tcsi_changeauth.c' || echo '$(srcdir)/'`tcsi_changeauth.c
+
+libtcs_a-tcsi_changeauth.obj: tcsi_changeauth.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_changeauth.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_changeauth.Tpo -c -o libtcs_a-tcsi_changeauth.obj `if test -f 'tcsi_changeauth.c'; then $(CYGPATH_W) 'tcsi_changeauth.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_changeauth.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_changeauth.Tpo $(DEPDIR)/libtcs_a-tcsi_changeauth.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_changeauth.c' object='libtcs_a-tcsi_changeauth.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_changeauth.obj `if test -f 'tcsi_changeauth.c'; then $(CYGPATH_W) 'tcsi_changeauth.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_changeauth.c'; fi`
+
+libtcs_a-rpc_changeauth.o: rpc/@RPC@/rpc_changeauth.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_changeauth.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_changeauth.Tpo -c -o libtcs_a-rpc_changeauth.o `test -f 'rpc/@RPC@/rpc_changeauth.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_changeauth.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_changeauth.Tpo $(DEPDIR)/libtcs_a-rpc_changeauth.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_changeauth.c' object='libtcs_a-rpc_changeauth.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_changeauth.o `test -f 'rpc/@RPC@/rpc_changeauth.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_changeauth.c
+
+libtcs_a-rpc_changeauth.obj: rpc/@RPC@/rpc_changeauth.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_changeauth.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_changeauth.Tpo -c -o libtcs_a-rpc_changeauth.obj `if test -f 'rpc/@RPC@/rpc_changeauth.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_changeauth.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_changeauth.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_changeauth.Tpo $(DEPDIR)/libtcs_a-rpc_changeauth.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_changeauth.c' object='libtcs_a-rpc_changeauth.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_changeauth.obj `if test -f 'rpc/@RPC@/rpc_changeauth.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_changeauth.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_changeauth.c'; fi`
+
+libtcs_a-tcsi_bind.o: tcsi_bind.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_bind.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_bind.Tpo -c -o libtcs_a-tcsi_bind.o `test -f 'tcsi_bind.c' || echo '$(srcdir)/'`tcsi_bind.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_bind.Tpo $(DEPDIR)/libtcs_a-tcsi_bind.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_bind.c' object='libtcs_a-tcsi_bind.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_bind.o `test -f 'tcsi_bind.c' || echo '$(srcdir)/'`tcsi_bind.c
+
+libtcs_a-tcsi_bind.obj: tcsi_bind.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_bind.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_bind.Tpo -c -o libtcs_a-tcsi_bind.obj `if test -f 'tcsi_bind.c'; then $(CYGPATH_W) 'tcsi_bind.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_bind.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_bind.Tpo $(DEPDIR)/libtcs_a-tcsi_bind.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_bind.c' object='libtcs_a-tcsi_bind.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_bind.obj `if test -f 'tcsi_bind.c'; then $(CYGPATH_W) 'tcsi_bind.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_bind.c'; fi`
+
+libtcs_a-rpc_bind.o: rpc/@RPC@/rpc_bind.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_bind.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_bind.Tpo -c -o libtcs_a-rpc_bind.o `test -f 'rpc/@RPC@/rpc_bind.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_bind.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_bind.Tpo $(DEPDIR)/libtcs_a-rpc_bind.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_bind.c' object='libtcs_a-rpc_bind.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_bind.o `test -f 'rpc/@RPC@/rpc_bind.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_bind.c
+
+libtcs_a-rpc_bind.obj: rpc/@RPC@/rpc_bind.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_bind.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_bind.Tpo -c -o libtcs_a-rpc_bind.obj `if test -f 'rpc/@RPC@/rpc_bind.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_bind.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_bind.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_bind.Tpo $(DEPDIR)/libtcs_a-rpc_bind.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_bind.c' object='libtcs_a-rpc_bind.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_bind.obj `if test -f 'rpc/@RPC@/rpc_bind.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_bind.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_bind.c'; fi`
+
+libtcs_a-tcsi_own.o: tcsi_own.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_own.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_own.Tpo -c -o libtcs_a-tcsi_own.o `test -f 'tcsi_own.c' || echo '$(srcdir)/'`tcsi_own.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_own.Tpo $(DEPDIR)/libtcs_a-tcsi_own.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_own.c' object='libtcs_a-tcsi_own.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_own.o `test -f 'tcsi_own.c' || echo '$(srcdir)/'`tcsi_own.c
+
+libtcs_a-tcsi_own.obj: tcsi_own.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_own.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_own.Tpo -c -o libtcs_a-tcsi_own.obj `if test -f 'tcsi_own.c'; then $(CYGPATH_W) 'tcsi_own.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_own.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_own.Tpo $(DEPDIR)/libtcs_a-tcsi_own.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_own.c' object='libtcs_a-tcsi_own.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_own.obj `if test -f 'tcsi_own.c'; then $(CYGPATH_W) 'tcsi_own.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_own.c'; fi`
+
+libtcs_a-rpc_own.o: rpc/@RPC@/rpc_own.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_own.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_own.Tpo -c -o libtcs_a-rpc_own.o `test -f 'rpc/@RPC@/rpc_own.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_own.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_own.Tpo $(DEPDIR)/libtcs_a-rpc_own.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_own.c' object='libtcs_a-rpc_own.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_own.o `test -f 'rpc/@RPC@/rpc_own.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_own.c
+
+libtcs_a-rpc_own.obj: rpc/@RPC@/rpc_own.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_own.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_own.Tpo -c -o libtcs_a-rpc_own.obj `if test -f 'rpc/@RPC@/rpc_own.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_own.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_own.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_own.Tpo $(DEPDIR)/libtcs_a-rpc_own.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_own.c' object='libtcs_a-rpc_own.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_own.obj `if test -f 'rpc/@RPC@/rpc_own.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_own.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_own.c'; fi`
+
+libtcs_a-ps_utils.o: ps/ps_utils.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-ps_utils.o -MD -MP -MF $(DEPDIR)/libtcs_a-ps_utils.Tpo -c -o libtcs_a-ps_utils.o `test -f 'ps/ps_utils.c' || echo '$(srcdir)/'`ps/ps_utils.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-ps_utils.Tpo $(DEPDIR)/libtcs_a-ps_utils.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ps/ps_utils.c' object='libtcs_a-ps_utils.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-ps_utils.o `test -f 'ps/ps_utils.c' || echo '$(srcdir)/'`ps/ps_utils.c
+
+libtcs_a-ps_utils.obj: ps/ps_utils.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-ps_utils.obj -MD -MP -MF $(DEPDIR)/libtcs_a-ps_utils.Tpo -c -o libtcs_a-ps_utils.obj `if test -f 'ps/ps_utils.c'; then $(CYGPATH_W) 'ps/ps_utils.c'; else $(CYGPATH_W) '$(srcdir)/ps/ps_utils.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-ps_utils.Tpo $(DEPDIR)/libtcs_a-ps_utils.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ps/ps_utils.c' object='libtcs_a-ps_utils.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-ps_utils.obj `if test -f 'ps/ps_utils.c'; then $(CYGPATH_W) 'ps/ps_utils.c'; else $(CYGPATH_W) '$(srcdir)/ps/ps_utils.c'; fi`
+
+libtcs_a-tcsps.o: ps/tcsps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsps.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsps.Tpo -c -o libtcs_a-tcsps.o `test -f 'ps/tcsps.c' || echo '$(srcdir)/'`ps/tcsps.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsps.Tpo $(DEPDIR)/libtcs_a-tcsps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ps/tcsps.c' object='libtcs_a-tcsps.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsps.o `test -f 'ps/tcsps.c' || echo '$(srcdir)/'`ps/tcsps.c
+
+libtcs_a-tcsps.obj: ps/tcsps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsps.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsps.Tpo -c -o libtcs_a-tcsps.obj `if test -f 'ps/tcsps.c'; then $(CYGPATH_W) 'ps/tcsps.c'; else $(CYGPATH_W) '$(srcdir)/ps/tcsps.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsps.Tpo $(DEPDIR)/libtcs_a-tcsps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ps/tcsps.c' object='libtcs_a-tcsps.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsps.obj `if test -f 'ps/tcsps.c'; then $(CYGPATH_W) 'ps/tcsps.c'; else $(CYGPATH_W) '$(srcdir)/ps/tcsps.c'; fi`
+
+libtcs_a-tcsi_ps.o: tcsi_ps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_ps.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_ps.Tpo -c -o libtcs_a-tcsi_ps.o `test -f 'tcsi_ps.c' || echo '$(srcdir)/'`tcsi_ps.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_ps.Tpo $(DEPDIR)/libtcs_a-tcsi_ps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_ps.c' object='libtcs_a-tcsi_ps.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_ps.o `test -f 'tcsi_ps.c' || echo '$(srcdir)/'`tcsi_ps.c
+
+libtcs_a-tcsi_ps.obj: tcsi_ps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_ps.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_ps.Tpo -c -o libtcs_a-tcsi_ps.obj `if test -f 'tcsi_ps.c'; then $(CYGPATH_W) 'tcsi_ps.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_ps.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_ps.Tpo $(DEPDIR)/libtcs_a-tcsi_ps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_ps.c' object='libtcs_a-tcsi_ps.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_ps.obj `if test -f 'tcsi_ps.c'; then $(CYGPATH_W) 'tcsi_ps.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_ps.c'; fi`
+
+libtcs_a-tcs_ps.o: tcs_ps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_ps.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_ps.Tpo -c -o libtcs_a-tcs_ps.o `test -f 'tcs_ps.c' || echo '$(srcdir)/'`tcs_ps.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_ps.Tpo $(DEPDIR)/libtcs_a-tcs_ps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_ps.c' object='libtcs_a-tcs_ps.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_ps.o `test -f 'tcs_ps.c' || echo '$(srcdir)/'`tcs_ps.c
+
+libtcs_a-tcs_ps.obj: tcs_ps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_ps.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_ps.Tpo -c -o libtcs_a-tcs_ps.obj `if test -f 'tcs_ps.c'; then $(CYGPATH_W) 'tcs_ps.c'; else $(CYGPATH_W) '$(srcdir)/tcs_ps.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_ps.Tpo $(DEPDIR)/libtcs_a-tcs_ps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_ps.c' object='libtcs_a-tcs_ps.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_ps.obj `if test -f 'tcs_ps.c'; then $(CYGPATH_W) 'tcs_ps.c'; else $(CYGPATH_W) '$(srcdir)/tcs_ps.c'; fi`
+
+libtcs_a-tcs_key_ps.o: tcs_key_ps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_key_ps.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_key_ps.Tpo -c -o libtcs_a-tcs_key_ps.o `test -f 'tcs_key_ps.c' || echo '$(srcdir)/'`tcs_key_ps.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_key_ps.Tpo $(DEPDIR)/libtcs_a-tcs_key_ps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_key_ps.c' object='libtcs_a-tcs_key_ps.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_key_ps.o `test -f 'tcs_key_ps.c' || echo '$(srcdir)/'`tcs_key_ps.c
+
+libtcs_a-tcs_key_ps.obj: tcs_key_ps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_key_ps.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_key_ps.Tpo -c -o libtcs_a-tcs_key_ps.obj `if test -f 'tcs_key_ps.c'; then $(CYGPATH_W) 'tcs_key_ps.c'; else $(CYGPATH_W) '$(srcdir)/tcs_key_ps.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_key_ps.Tpo $(DEPDIR)/libtcs_a-tcs_key_ps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_key_ps.c' object='libtcs_a-tcs_key_ps.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_key_ps.obj `if test -f 'tcs_key_ps.c'; then $(CYGPATH_W) 'tcs_key_ps.c'; else $(CYGPATH_W) '$(srcdir)/tcs_key_ps.c'; fi`
+
+libtcs_a-rpc_ps.o: rpc/@RPC@/rpc_ps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_ps.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_ps.Tpo -c -o libtcs_a-rpc_ps.o `test -f 'rpc/@RPC@/rpc_ps.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_ps.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_ps.Tpo $(DEPDIR)/libtcs_a-rpc_ps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_ps.c' object='libtcs_a-rpc_ps.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_ps.o `test -f 'rpc/@RPC@/rpc_ps.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_ps.c
+
+libtcs_a-rpc_ps.obj: rpc/@RPC@/rpc_ps.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_ps.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_ps.Tpo -c -o libtcs_a-rpc_ps.obj `if test -f 'rpc/@RPC@/rpc_ps.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_ps.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_ps.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_ps.Tpo $(DEPDIR)/libtcs_a-rpc_ps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_ps.c' object='libtcs_a-rpc_ps.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_ps.obj `if test -f 'rpc/@RPC@/rpc_ps.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_ps.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_ps.c'; fi`
+
+libtcs_a-tcsi_admin.o: tcsi_admin.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_admin.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_admin.Tpo -c -o libtcs_a-tcsi_admin.o `test -f 'tcsi_admin.c' || echo '$(srcdir)/'`tcsi_admin.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_admin.Tpo $(DEPDIR)/libtcs_a-tcsi_admin.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_admin.c' object='libtcs_a-tcsi_admin.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_admin.o `test -f 'tcsi_admin.c' || echo '$(srcdir)/'`tcsi_admin.c
+
+libtcs_a-tcsi_admin.obj: tcsi_admin.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_admin.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_admin.Tpo -c -o libtcs_a-tcsi_admin.obj `if test -f 'tcsi_admin.c'; then $(CYGPATH_W) 'tcsi_admin.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_admin.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_admin.Tpo $(DEPDIR)/libtcs_a-tcsi_admin.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_admin.c' object='libtcs_a-tcsi_admin.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_admin.obj `if test -f 'tcsi_admin.c'; then $(CYGPATH_W) 'tcsi_admin.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_admin.c'; fi`
+
+libtcs_a-rpc_admin.o: rpc/@RPC@/rpc_admin.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_admin.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_admin.Tpo -c -o libtcs_a-rpc_admin.o `test -f 'rpc/@RPC@/rpc_admin.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_admin.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_admin.Tpo $(DEPDIR)/libtcs_a-rpc_admin.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_admin.c' object='libtcs_a-rpc_admin.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_admin.o `test -f 'rpc/@RPC@/rpc_admin.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_admin.c
+
+libtcs_a-rpc_admin.obj: rpc/@RPC@/rpc_admin.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_admin.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_admin.Tpo -c -o libtcs_a-rpc_admin.obj `if test -f 'rpc/@RPC@/rpc_admin.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_admin.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_admin.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_admin.Tpo $(DEPDIR)/libtcs_a-rpc_admin.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_admin.c' object='libtcs_a-rpc_admin.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_admin.obj `if test -f 'rpc/@RPC@/rpc_admin.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_admin.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_admin.c'; fi`
+
+libtcs_a-tcsi_aik.o: tcsi_aik.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_aik.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_aik.Tpo -c -o libtcs_a-tcsi_aik.o `test -f 'tcsi_aik.c' || echo '$(srcdir)/'`tcsi_aik.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_aik.Tpo $(DEPDIR)/libtcs_a-tcsi_aik.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_aik.c' object='libtcs_a-tcsi_aik.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_aik.o `test -f 'tcsi_aik.c' || echo '$(srcdir)/'`tcsi_aik.c
+
+libtcs_a-tcsi_aik.obj: tcsi_aik.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_aik.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_aik.Tpo -c -o libtcs_a-tcsi_aik.obj `if test -f 'tcsi_aik.c'; then $(CYGPATH_W) 'tcsi_aik.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_aik.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_aik.Tpo $(DEPDIR)/libtcs_a-tcsi_aik.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_aik.c' object='libtcs_a-tcsi_aik.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_aik.obj `if test -f 'tcsi_aik.c'; then $(CYGPATH_W) 'tcsi_aik.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_aik.c'; fi`
+
+libtcs_a-tcs_aik.o: tcs_aik.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_aik.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_aik.Tpo -c -o libtcs_a-tcs_aik.o `test -f 'tcs_aik.c' || echo '$(srcdir)/'`tcs_aik.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_aik.Tpo $(DEPDIR)/libtcs_a-tcs_aik.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_aik.c' object='libtcs_a-tcs_aik.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_aik.o `test -f 'tcs_aik.c' || echo '$(srcdir)/'`tcs_aik.c
+
+libtcs_a-tcs_aik.obj: tcs_aik.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_aik.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_aik.Tpo -c -o libtcs_a-tcs_aik.obj `if test -f 'tcs_aik.c'; then $(CYGPATH_W) 'tcs_aik.c'; else $(CYGPATH_W) '$(srcdir)/tcs_aik.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_aik.Tpo $(DEPDIR)/libtcs_a-tcs_aik.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_aik.c' object='libtcs_a-tcs_aik.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_aik.obj `if test -f 'tcs_aik.c'; then $(CYGPATH_W) 'tcs_aik.c'; else $(CYGPATH_W) '$(srcdir)/tcs_aik.c'; fi`
+
+libtcs_a-rpc_aik.o: rpc/@RPC@/rpc_aik.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_aik.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_aik.Tpo -c -o libtcs_a-rpc_aik.o `test -f 'rpc/@RPC@/rpc_aik.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_aik.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_aik.Tpo $(DEPDIR)/libtcs_a-rpc_aik.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_aik.c' object='libtcs_a-rpc_aik.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_aik.o `test -f 'rpc/@RPC@/rpc_aik.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_aik.c
+
+libtcs_a-rpc_aik.obj: rpc/@RPC@/rpc_aik.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_aik.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_aik.Tpo -c -o libtcs_a-rpc_aik.obj `if test -f 'rpc/@RPC@/rpc_aik.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_aik.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_aik.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_aik.Tpo $(DEPDIR)/libtcs_a-rpc_aik.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_aik.c' object='libtcs_a-rpc_aik.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_aik.obj `if test -f 'rpc/@RPC@/rpc_aik.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_aik.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_aik.c'; fi`
+
+libtcs_a-tcsi_ek.o: tcsi_ek.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_ek.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_ek.Tpo -c -o libtcs_a-tcsi_ek.o `test -f 'tcsi_ek.c' || echo '$(srcdir)/'`tcsi_ek.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_ek.Tpo $(DEPDIR)/libtcs_a-tcsi_ek.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_ek.c' object='libtcs_a-tcsi_ek.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_ek.o `test -f 'tcsi_ek.c' || echo '$(srcdir)/'`tcsi_ek.c
+
+libtcs_a-tcsi_ek.obj: tcsi_ek.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_ek.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_ek.Tpo -c -o libtcs_a-tcsi_ek.obj `if test -f 'tcsi_ek.c'; then $(CYGPATH_W) 'tcsi_ek.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_ek.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_ek.Tpo $(DEPDIR)/libtcs_a-tcsi_ek.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_ek.c' object='libtcs_a-tcsi_ek.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_ek.obj `if test -f 'tcsi_ek.c'; then $(CYGPATH_W) 'tcsi_ek.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_ek.c'; fi`
+
+libtcs_a-rpc_ek.o: rpc/@RPC@/rpc_ek.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_ek.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_ek.Tpo -c -o libtcs_a-rpc_ek.o `test -f 'rpc/@RPC@/rpc_ek.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_ek.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_ek.Tpo $(DEPDIR)/libtcs_a-rpc_ek.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_ek.c' object='libtcs_a-rpc_ek.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_ek.o `test -f 'rpc/@RPC@/rpc_ek.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_ek.c
+
+libtcs_a-rpc_ek.obj: rpc/@RPC@/rpc_ek.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_ek.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_ek.Tpo -c -o libtcs_a-rpc_ek.obj `if test -f 'rpc/@RPC@/rpc_ek.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_ek.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_ek.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_ek.Tpo $(DEPDIR)/libtcs_a-rpc_ek.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_ek.c' object='libtcs_a-rpc_ek.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_ek.obj `if test -f 'rpc/@RPC@/rpc_ek.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_ek.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_ek.c'; fi`
+
+libtcs_a-tcsi_certify.o: tcsi_certify.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_certify.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_certify.Tpo -c -o libtcs_a-tcsi_certify.o `test -f 'tcsi_certify.c' || echo '$(srcdir)/'`tcsi_certify.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_certify.Tpo $(DEPDIR)/libtcs_a-tcsi_certify.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_certify.c' object='libtcs_a-tcsi_certify.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_certify.o `test -f 'tcsi_certify.c' || echo '$(srcdir)/'`tcsi_certify.c
+
+libtcs_a-tcsi_certify.obj: tcsi_certify.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_certify.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_certify.Tpo -c -o libtcs_a-tcsi_certify.obj `if test -f 'tcsi_certify.c'; then $(CYGPATH_W) 'tcsi_certify.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_certify.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_certify.Tpo $(DEPDIR)/libtcs_a-tcsi_certify.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_certify.c' object='libtcs_a-tcsi_certify.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_certify.obj `if test -f 'tcsi_certify.c'; then $(CYGPATH_W) 'tcsi_certify.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_certify.c'; fi`
+
+libtcs_a-rpc_certify.o: rpc/@RPC@/rpc_certify.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_certify.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_certify.Tpo -c -o libtcs_a-rpc_certify.o `test -f 'rpc/@RPC@/rpc_certify.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_certify.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_certify.Tpo $(DEPDIR)/libtcs_a-rpc_certify.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_certify.c' object='libtcs_a-rpc_certify.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_certify.o `test -f 'rpc/@RPC@/rpc_certify.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_certify.c
+
+libtcs_a-rpc_certify.obj: rpc/@RPC@/rpc_certify.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_certify.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_certify.Tpo -c -o libtcs_a-rpc_certify.obj `if test -f 'rpc/@RPC@/rpc_certify.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_certify.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_certify.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_certify.Tpo $(DEPDIR)/libtcs_a-rpc_certify.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_certify.c' object='libtcs_a-rpc_certify.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_certify.obj `if test -f 'rpc/@RPC@/rpc_certify.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_certify.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_certify.c'; fi`
+
+libtcs_a-tcsi_key.o: tcsi_key.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_key.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_key.Tpo -c -o libtcs_a-tcsi_key.o `test -f 'tcsi_key.c' || echo '$(srcdir)/'`tcsi_key.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_key.Tpo $(DEPDIR)/libtcs_a-tcsi_key.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_key.c' object='libtcs_a-tcsi_key.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_key.o `test -f 'tcsi_key.c' || echo '$(srcdir)/'`tcsi_key.c
+
+libtcs_a-tcsi_key.obj: tcsi_key.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_key.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_key.Tpo -c -o libtcs_a-tcsi_key.obj `if test -f 'tcsi_key.c'; then $(CYGPATH_W) 'tcsi_key.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_key.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_key.Tpo $(DEPDIR)/libtcs_a-tcsi_key.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_key.c' object='libtcs_a-tcsi_key.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_key.obj `if test -f 'tcsi_key.c'; then $(CYGPATH_W) 'tcsi_key.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_key.c'; fi`
+
+libtcs_a-tcs_key.o: tcs_key.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_key.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_key.Tpo -c -o libtcs_a-tcs_key.o `test -f 'tcs_key.c' || echo '$(srcdir)/'`tcs_key.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_key.Tpo $(DEPDIR)/libtcs_a-tcs_key.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_key.c' object='libtcs_a-tcs_key.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_key.o `test -f 'tcs_key.c' || echo '$(srcdir)/'`tcs_key.c
+
+libtcs_a-tcs_key.obj: tcs_key.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_key.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_key.Tpo -c -o libtcs_a-tcs_key.obj `if test -f 'tcs_key.c'; then $(CYGPATH_W) 'tcs_key.c'; else $(CYGPATH_W) '$(srcdir)/tcs_key.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_key.Tpo $(DEPDIR)/libtcs_a-tcs_key.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_key.c' object='libtcs_a-tcs_key.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_key.obj `if test -f 'tcs_key.c'; then $(CYGPATH_W) 'tcs_key.c'; else $(CYGPATH_W) '$(srcdir)/tcs_key.c'; fi`
+
+libtcs_a-tcs_key_mem_cache.o: tcs_key_mem_cache.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_key_mem_cache.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_key_mem_cache.Tpo -c -o libtcs_a-tcs_key_mem_cache.o `test -f 'tcs_key_mem_cache.c' || echo '$(srcdir)/'`tcs_key_mem_cache.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_key_mem_cache.Tpo $(DEPDIR)/libtcs_a-tcs_key_mem_cache.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_key_mem_cache.c' object='libtcs_a-tcs_key_mem_cache.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_key_mem_cache.o `test -f 'tcs_key_mem_cache.c' || echo '$(srcdir)/'`tcs_key_mem_cache.c
+
+libtcs_a-tcs_key_mem_cache.obj: tcs_key_mem_cache.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_key_mem_cache.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_key_mem_cache.Tpo -c -o libtcs_a-tcs_key_mem_cache.obj `if test -f 'tcs_key_mem_cache.c'; then $(CYGPATH_W) 'tcs_key_mem_cache.c'; else $(CYGPATH_W) '$(srcdir)/tcs_key_mem_cache.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_key_mem_cache.Tpo $(DEPDIR)/libtcs_a-tcs_key_mem_cache.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_key_mem_cache.c' object='libtcs_a-tcs_key_mem_cache.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_key_mem_cache.obj `if test -f 'tcs_key_mem_cache.c'; then $(CYGPATH_W) 'tcs_key_mem_cache.c'; else $(CYGPATH_W) '$(srcdir)/tcs_key_mem_cache.c'; fi`
+
+libtcs_a-tcs_context_key.o: tcs_context_key.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_context_key.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_context_key.Tpo -c -o libtcs_a-tcs_context_key.o `test -f 'tcs_context_key.c' || echo '$(srcdir)/'`tcs_context_key.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_context_key.Tpo $(DEPDIR)/libtcs_a-tcs_context_key.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_context_key.c' object='libtcs_a-tcs_context_key.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_context_key.o `test -f 'tcs_context_key.c' || echo '$(srcdir)/'`tcs_context_key.c
+
+libtcs_a-tcs_context_key.obj: tcs_context_key.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_context_key.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_context_key.Tpo -c -o libtcs_a-tcs_context_key.obj `if test -f 'tcs_context_key.c'; then $(CYGPATH_W) 'tcs_context_key.c'; else $(CYGPATH_W) '$(srcdir)/tcs_context_key.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_context_key.Tpo $(DEPDIR)/libtcs_a-tcs_context_key.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_context_key.c' object='libtcs_a-tcs_context_key.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_context_key.obj `if test -f 'tcs_context_key.c'; then $(CYGPATH_W) 'tcs_context_key.c'; else $(CYGPATH_W) '$(srcdir)/tcs_context_key.c'; fi`
+
+libtcs_a-rpc_key.o: rpc/@RPC@/rpc_key.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_key.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_key.Tpo -c -o libtcs_a-rpc_key.o `test -f 'rpc/@RPC@/rpc_key.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_key.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_key.Tpo $(DEPDIR)/libtcs_a-rpc_key.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_key.c' object='libtcs_a-rpc_key.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_key.o `test -f 'rpc/@RPC@/rpc_key.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_key.c
+
+libtcs_a-rpc_key.obj: rpc/@RPC@/rpc_key.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_key.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_key.Tpo -c -o libtcs_a-rpc_key.obj `if test -f 'rpc/@RPC@/rpc_key.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_key.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_key.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_key.Tpo $(DEPDIR)/libtcs_a-rpc_key.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_key.c' object='libtcs_a-rpc_key.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_key.obj `if test -f 'rpc/@RPC@/rpc_key.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_key.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_key.c'; fi`
+
+libtcs_a-crypto.o: crypto/@CRYPTO_PACKAGE@/crypto.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-crypto.o -MD -MP -MF $(DEPDIR)/libtcs_a-crypto.Tpo -c -o libtcs_a-crypto.o `test -f 'crypto/@CRYPTO_PACKAGE@/crypto.c' || echo '$(srcdir)/'`crypto/@CRYPTO_PACKAGE@/crypto.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-crypto.Tpo $(DEPDIR)/libtcs_a-crypto.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='crypto/@CRYPTO_PACKAGE@/crypto.c' object='libtcs_a-crypto.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-crypto.o `test -f 'crypto/@CRYPTO_PACKAGE@/crypto.c' || echo '$(srcdir)/'`crypto/@CRYPTO_PACKAGE@/crypto.c
+
+libtcs_a-crypto.obj: crypto/@CRYPTO_PACKAGE@/crypto.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-crypto.obj -MD -MP -MF $(DEPDIR)/libtcs_a-crypto.Tpo -c -o libtcs_a-crypto.obj `if test -f 'crypto/@CRYPTO_PACKAGE@/crypto.c'; then $(CYGPATH_W) 'crypto/@CRYPTO_PACKAGE@/crypto.c'; else $(CYGPATH_W) '$(srcdir)/crypto/@CRYPTO_PACKAGE@/crypto.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-crypto.Tpo $(DEPDIR)/libtcs_a-crypto.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='crypto/@CRYPTO_PACKAGE@/crypto.c' object='libtcs_a-crypto.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-crypto.obj `if test -f 'crypto/@CRYPTO_PACKAGE@/crypto.c'; then $(CYGPATH_W) 'crypto/@CRYPTO_PACKAGE@/crypto.c'; else $(CYGPATH_W) '$(srcdir)/crypto/@CRYPTO_PACKAGE@/crypto.c'; fi`
+
+libtcs_a-tcsi_maint.o: tcsi_maint.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_maint.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_maint.Tpo -c -o libtcs_a-tcsi_maint.o `test -f 'tcsi_maint.c' || echo '$(srcdir)/'`tcsi_maint.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_maint.Tpo $(DEPDIR)/libtcs_a-tcsi_maint.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_maint.c' object='libtcs_a-tcsi_maint.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_maint.o `test -f 'tcsi_maint.c' || echo '$(srcdir)/'`tcsi_maint.c
+
+libtcs_a-tcsi_maint.obj: tcsi_maint.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_maint.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_maint.Tpo -c -o libtcs_a-tcsi_maint.obj `if test -f 'tcsi_maint.c'; then $(CYGPATH_W) 'tcsi_maint.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_maint.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_maint.Tpo $(DEPDIR)/libtcs_a-tcsi_maint.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_maint.c' object='libtcs_a-tcsi_maint.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_maint.obj `if test -f 'tcsi_maint.c'; then $(CYGPATH_W) 'tcsi_maint.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_maint.c'; fi`
+
+libtcs_a-rpc_maint.o: rpc/@RPC@/rpc_maint.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_maint.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_maint.Tpo -c -o libtcs_a-rpc_maint.o `test -f 'rpc/@RPC@/rpc_maint.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_maint.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_maint.Tpo $(DEPDIR)/libtcs_a-rpc_maint.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_maint.c' object='libtcs_a-rpc_maint.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_maint.o `test -f 'rpc/@RPC@/rpc_maint.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_maint.c
+
+libtcs_a-rpc_maint.obj: rpc/@RPC@/rpc_maint.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_maint.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_maint.Tpo -c -o libtcs_a-rpc_maint.obj `if test -f 'rpc/@RPC@/rpc_maint.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_maint.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_maint.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_maint.Tpo $(DEPDIR)/libtcs_a-rpc_maint.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_maint.c' object='libtcs_a-rpc_maint.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_maint.obj `if test -f 'rpc/@RPC@/rpc_maint.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_maint.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_maint.c'; fi`
+
+libtcs_a-tcsi_migration.o: tcsi_migration.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_migration.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_migration.Tpo -c -o libtcs_a-tcsi_migration.o `test -f 'tcsi_migration.c' || echo '$(srcdir)/'`tcsi_migration.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_migration.Tpo $(DEPDIR)/libtcs_a-tcsi_migration.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_migration.c' object='libtcs_a-tcsi_migration.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_migration.o `test -f 'tcsi_migration.c' || echo '$(srcdir)/'`tcsi_migration.c
+
+libtcs_a-tcsi_migration.obj: tcsi_migration.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_migration.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_migration.Tpo -c -o libtcs_a-tcsi_migration.obj `if test -f 'tcsi_migration.c'; then $(CYGPATH_W) 'tcsi_migration.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_migration.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_migration.Tpo $(DEPDIR)/libtcs_a-tcsi_migration.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_migration.c' object='libtcs_a-tcsi_migration.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_migration.obj `if test -f 'tcsi_migration.c'; then $(CYGPATH_W) 'tcsi_migration.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_migration.c'; fi`
+
+libtcs_a-tcs_migration.o: tcs_migration.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_migration.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_migration.Tpo -c -o libtcs_a-tcs_migration.o `test -f 'tcs_migration.c' || echo '$(srcdir)/'`tcs_migration.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_migration.Tpo $(DEPDIR)/libtcs_a-tcs_migration.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_migration.c' object='libtcs_a-tcs_migration.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_migration.o `test -f 'tcs_migration.c' || echo '$(srcdir)/'`tcs_migration.c
+
+libtcs_a-tcs_migration.obj: tcs_migration.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_migration.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_migration.Tpo -c -o libtcs_a-tcs_migration.obj `if test -f 'tcs_migration.c'; then $(CYGPATH_W) 'tcs_migration.c'; else $(CYGPATH_W) '$(srcdir)/tcs_migration.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_migration.Tpo $(DEPDIR)/libtcs_a-tcs_migration.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_migration.c' object='libtcs_a-tcs_migration.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_migration.obj `if test -f 'tcs_migration.c'; then $(CYGPATH_W) 'tcs_migration.c'; else $(CYGPATH_W) '$(srcdir)/tcs_migration.c'; fi`
+
+libtcs_a-rpc_migration.o: rpc/@RPC@/rpc_migration.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_migration.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_migration.Tpo -c -o libtcs_a-rpc_migration.o `test -f 'rpc/@RPC@/rpc_migration.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_migration.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_migration.Tpo $(DEPDIR)/libtcs_a-rpc_migration.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_migration.c' object='libtcs_a-rpc_migration.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_migration.o `test -f 'rpc/@RPC@/rpc_migration.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_migration.c
+
+libtcs_a-rpc_migration.obj: rpc/@RPC@/rpc_migration.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_migration.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_migration.Tpo -c -o libtcs_a-rpc_migration.obj `if test -f 'rpc/@RPC@/rpc_migration.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_migration.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_migration.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_migration.Tpo $(DEPDIR)/libtcs_a-rpc_migration.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_migration.c' object='libtcs_a-rpc_migration.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_migration.obj `if test -f 'rpc/@RPC@/rpc_migration.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_migration.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_migration.c'; fi`
+
+libtcs_a-tcsi_pcr.o: tcsi_pcr.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_pcr.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_pcr.Tpo -c -o libtcs_a-tcsi_pcr.o `test -f 'tcsi_pcr.c' || echo '$(srcdir)/'`tcsi_pcr.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_pcr.Tpo $(DEPDIR)/libtcs_a-tcsi_pcr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_pcr.c' object='libtcs_a-tcsi_pcr.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_pcr.o `test -f 'tcsi_pcr.c' || echo '$(srcdir)/'`tcsi_pcr.c
+
+libtcs_a-tcsi_pcr.obj: tcsi_pcr.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_pcr.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_pcr.Tpo -c -o libtcs_a-tcsi_pcr.obj `if test -f 'tcsi_pcr.c'; then $(CYGPATH_W) 'tcsi_pcr.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_pcr.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_pcr.Tpo $(DEPDIR)/libtcs_a-tcsi_pcr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_pcr.c' object='libtcs_a-tcsi_pcr.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_pcr.obj `if test -f 'tcsi_pcr.c'; then $(CYGPATH_W) 'tcsi_pcr.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_pcr.c'; fi`
+
+libtcs_a-rpc_pcr_extend.o: rpc/@RPC@/rpc_pcr_extend.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_pcr_extend.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_pcr_extend.Tpo -c -o libtcs_a-rpc_pcr_extend.o `test -f 'rpc/@RPC@/rpc_pcr_extend.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_pcr_extend.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_pcr_extend.Tpo $(DEPDIR)/libtcs_a-rpc_pcr_extend.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_pcr_extend.c' object='libtcs_a-rpc_pcr_extend.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_pcr_extend.o `test -f 'rpc/@RPC@/rpc_pcr_extend.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_pcr_extend.c
+
+libtcs_a-rpc_pcr_extend.obj: rpc/@RPC@/rpc_pcr_extend.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_pcr_extend.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_pcr_extend.Tpo -c -o libtcs_a-rpc_pcr_extend.obj `if test -f 'rpc/@RPC@/rpc_pcr_extend.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_pcr_extend.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_pcr_extend.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_pcr_extend.Tpo $(DEPDIR)/libtcs_a-rpc_pcr_extend.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_pcr_extend.c' object='libtcs_a-rpc_pcr_extend.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_pcr_extend.obj `if test -f 'rpc/@RPC@/rpc_pcr_extend.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_pcr_extend.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_pcr_extend.c'; fi`
+
+libtcs_a-tcsi_selftest.o: tcsi_selftest.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_selftest.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_selftest.Tpo -c -o libtcs_a-tcsi_selftest.o `test -f 'tcsi_selftest.c' || echo '$(srcdir)/'`tcsi_selftest.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_selftest.Tpo $(DEPDIR)/libtcs_a-tcsi_selftest.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_selftest.c' object='libtcs_a-tcsi_selftest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_selftest.o `test -f 'tcsi_selftest.c' || echo '$(srcdir)/'`tcsi_selftest.c
+
+libtcs_a-tcsi_selftest.obj: tcsi_selftest.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_selftest.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_selftest.Tpo -c -o libtcs_a-tcsi_selftest.obj `if test -f 'tcsi_selftest.c'; then $(CYGPATH_W) 'tcsi_selftest.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_selftest.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_selftest.Tpo $(DEPDIR)/libtcs_a-tcsi_selftest.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_selftest.c' object='libtcs_a-tcsi_selftest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_selftest.obj `if test -f 'tcsi_selftest.c'; then $(CYGPATH_W) 'tcsi_selftest.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_selftest.c'; fi`
+
+libtcs_a-rpc_selftest.o: rpc/@RPC@/rpc_selftest.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_selftest.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_selftest.Tpo -c -o libtcs_a-rpc_selftest.o `test -f 'rpc/@RPC@/rpc_selftest.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_selftest.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_selftest.Tpo $(DEPDIR)/libtcs_a-rpc_selftest.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_selftest.c' object='libtcs_a-rpc_selftest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_selftest.o `test -f 'rpc/@RPC@/rpc_selftest.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_selftest.c
+
+libtcs_a-rpc_selftest.obj: rpc/@RPC@/rpc_selftest.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_selftest.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_selftest.Tpo -c -o libtcs_a-rpc_selftest.obj `if test -f 'rpc/@RPC@/rpc_selftest.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_selftest.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_selftest.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_selftest.Tpo $(DEPDIR)/libtcs_a-rpc_selftest.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_selftest.c' object='libtcs_a-rpc_selftest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_selftest.obj `if test -f 'rpc/@RPC@/rpc_selftest.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_selftest.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_selftest.c'; fi`
+
+libtcs_a-tcsi_daa.o: tcsi_daa.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_daa.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_daa.Tpo -c -o libtcs_a-tcsi_daa.o `test -f 'tcsi_daa.c' || echo '$(srcdir)/'`tcsi_daa.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_daa.Tpo $(DEPDIR)/libtcs_a-tcsi_daa.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_daa.c' object='libtcs_a-tcsi_daa.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_daa.o `test -f 'tcsi_daa.c' || echo '$(srcdir)/'`tcsi_daa.c
+
+libtcs_a-tcsi_daa.obj: tcsi_daa.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_daa.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_daa.Tpo -c -o libtcs_a-tcsi_daa.obj `if test -f 'tcsi_daa.c'; then $(CYGPATH_W) 'tcsi_daa.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_daa.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_daa.Tpo $(DEPDIR)/libtcs_a-tcsi_daa.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_daa.c' object='libtcs_a-tcsi_daa.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_daa.obj `if test -f 'tcsi_daa.c'; then $(CYGPATH_W) 'tcsi_daa.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_daa.c'; fi`
+
+libtcs_a-rpc_daa.o: rpc/@RPC@/rpc_daa.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_daa.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_daa.Tpo -c -o libtcs_a-rpc_daa.o `test -f 'rpc/@RPC@/rpc_daa.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_daa.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_daa.Tpo $(DEPDIR)/libtcs_a-rpc_daa.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_daa.c' object='libtcs_a-rpc_daa.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_daa.o `test -f 'rpc/@RPC@/rpc_daa.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_daa.c
+
+libtcs_a-rpc_daa.obj: rpc/@RPC@/rpc_daa.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_daa.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_daa.Tpo -c -o libtcs_a-rpc_daa.obj `if test -f 'rpc/@RPC@/rpc_daa.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_daa.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_daa.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_daa.Tpo $(DEPDIR)/libtcs_a-rpc_daa.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_daa.c' object='libtcs_a-rpc_daa.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_daa.obj `if test -f 'rpc/@RPC@/rpc_daa.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_daa.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_daa.c'; fi`
+
+libtcs_a-tcsi_nv.o: tcsi_nv.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_nv.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_nv.Tpo -c -o libtcs_a-tcsi_nv.o `test -f 'tcsi_nv.c' || echo '$(srcdir)/'`tcsi_nv.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_nv.Tpo $(DEPDIR)/libtcs_a-tcsi_nv.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_nv.c' object='libtcs_a-tcsi_nv.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_nv.o `test -f 'tcsi_nv.c' || echo '$(srcdir)/'`tcsi_nv.c
+
+libtcs_a-tcsi_nv.obj: tcsi_nv.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_nv.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_nv.Tpo -c -o libtcs_a-tcsi_nv.obj `if test -f 'tcsi_nv.c'; then $(CYGPATH_W) 'tcsi_nv.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_nv.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_nv.Tpo $(DEPDIR)/libtcs_a-tcsi_nv.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_nv.c' object='libtcs_a-tcsi_nv.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_nv.obj `if test -f 'tcsi_nv.c'; then $(CYGPATH_W) 'tcsi_nv.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_nv.c'; fi`
+
+libtcs_a-rpc_nv.o: rpc/@RPC@/rpc_nv.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_nv.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_nv.Tpo -c -o libtcs_a-rpc_nv.o `test -f 'rpc/@RPC@/rpc_nv.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_nv.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_nv.Tpo $(DEPDIR)/libtcs_a-rpc_nv.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_nv.c' object='libtcs_a-rpc_nv.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_nv.o `test -f 'rpc/@RPC@/rpc_nv.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_nv.c
+
+libtcs_a-rpc_nv.obj: rpc/@RPC@/rpc_nv.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_nv.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_nv.Tpo -c -o libtcs_a-rpc_nv.obj `if test -f 'rpc/@RPC@/rpc_nv.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_nv.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_nv.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_nv.Tpo $(DEPDIR)/libtcs_a-rpc_nv.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_nv.c' object='libtcs_a-rpc_nv.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_nv.obj `if test -f 'rpc/@RPC@/rpc_nv.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_nv.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_nv.c'; fi`
+
+libtcs_a-tcsi_audit.o: tcsi_audit.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_audit.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_audit.Tpo -c -o libtcs_a-tcsi_audit.o `test -f 'tcsi_audit.c' || echo '$(srcdir)/'`tcsi_audit.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_audit.Tpo $(DEPDIR)/libtcs_a-tcsi_audit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_audit.c' object='libtcs_a-tcsi_audit.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_audit.o `test -f 'tcsi_audit.c' || echo '$(srcdir)/'`tcsi_audit.c
+
+libtcs_a-tcsi_audit.obj: tcsi_audit.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_audit.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_audit.Tpo -c -o libtcs_a-tcsi_audit.obj `if test -f 'tcsi_audit.c'; then $(CYGPATH_W) 'tcsi_audit.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_audit.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_audit.Tpo $(DEPDIR)/libtcs_a-tcsi_audit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_audit.c' object='libtcs_a-tcsi_audit.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_audit.obj `if test -f 'tcsi_audit.c'; then $(CYGPATH_W) 'tcsi_audit.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_audit.c'; fi`
+
+libtcs_a-rpc_audit.o: rpc/@RPC@/rpc_audit.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_audit.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_audit.Tpo -c -o libtcs_a-rpc_audit.o `test -f 'rpc/@RPC@/rpc_audit.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_audit.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_audit.Tpo $(DEPDIR)/libtcs_a-rpc_audit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_audit.c' object='libtcs_a-rpc_audit.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_audit.o `test -f 'rpc/@RPC@/rpc_audit.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_audit.c
+
+libtcs_a-rpc_audit.obj: rpc/@RPC@/rpc_audit.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_audit.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_audit.Tpo -c -o libtcs_a-rpc_audit.obj `if test -f 'rpc/@RPC@/rpc_audit.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_audit.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_audit.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_audit.Tpo $(DEPDIR)/libtcs_a-rpc_audit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_audit.c' object='libtcs_a-rpc_audit.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_audit.obj `if test -f 'rpc/@RPC@/rpc_audit.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_audit.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_audit.c'; fi`
+
+libtcs_a-tcsi_oper.o: tcsi_oper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_oper.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_oper.Tpo -c -o libtcs_a-tcsi_oper.o `test -f 'tcsi_oper.c' || echo '$(srcdir)/'`tcsi_oper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_oper.Tpo $(DEPDIR)/libtcs_a-tcsi_oper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_oper.c' object='libtcs_a-tcsi_oper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_oper.o `test -f 'tcsi_oper.c' || echo '$(srcdir)/'`tcsi_oper.c
+
+libtcs_a-tcsi_oper.obj: tcsi_oper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_oper.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_oper.Tpo -c -o libtcs_a-tcsi_oper.obj `if test -f 'tcsi_oper.c'; then $(CYGPATH_W) 'tcsi_oper.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_oper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_oper.Tpo $(DEPDIR)/libtcs_a-tcsi_oper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_oper.c' object='libtcs_a-tcsi_oper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_oper.obj `if test -f 'tcsi_oper.c'; then $(CYGPATH_W) 'tcsi_oper.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_oper.c'; fi`
+
+libtcs_a-rpc_oper.o: rpc/@RPC@/rpc_oper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_oper.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_oper.Tpo -c -o libtcs_a-rpc_oper.o `test -f 'rpc/@RPC@/rpc_oper.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_oper.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_oper.Tpo $(DEPDIR)/libtcs_a-rpc_oper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_oper.c' object='libtcs_a-rpc_oper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_oper.o `test -f 'rpc/@RPC@/rpc_oper.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_oper.c
+
+libtcs_a-rpc_oper.obj: rpc/@RPC@/rpc_oper.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_oper.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_oper.Tpo -c -o libtcs_a-rpc_oper.obj `if test -f 'rpc/@RPC@/rpc_oper.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_oper.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_oper.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_oper.Tpo $(DEPDIR)/libtcs_a-rpc_oper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_oper.c' object='libtcs_a-rpc_oper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_oper.obj `if test -f 'rpc/@RPC@/rpc_oper.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_oper.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_oper.c'; fi`
+
+libtcs_a-tcsi_delegate.o: tcsi_delegate.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_delegate.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_delegate.Tpo -c -o libtcs_a-tcsi_delegate.o `test -f 'tcsi_delegate.c' || echo '$(srcdir)/'`tcsi_delegate.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_delegate.Tpo $(DEPDIR)/libtcs_a-tcsi_delegate.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_delegate.c' object='libtcs_a-tcsi_delegate.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_delegate.o `test -f 'tcsi_delegate.c' || echo '$(srcdir)/'`tcsi_delegate.c
+
+libtcs_a-tcsi_delegate.obj: tcsi_delegate.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_delegate.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_delegate.Tpo -c -o libtcs_a-tcsi_delegate.obj `if test -f 'tcsi_delegate.c'; then $(CYGPATH_W) 'tcsi_delegate.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_delegate.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_delegate.Tpo $(DEPDIR)/libtcs_a-tcsi_delegate.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_delegate.c' object='libtcs_a-tcsi_delegate.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_delegate.obj `if test -f 'tcsi_delegate.c'; then $(CYGPATH_W) 'tcsi_delegate.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_delegate.c'; fi`
+
+libtcs_a-rpc_delegate.o: rpc/@RPC@/rpc_delegate.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_delegate.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_delegate.Tpo -c -o libtcs_a-rpc_delegate.o `test -f 'rpc/@RPC@/rpc_delegate.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_delegate.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_delegate.Tpo $(DEPDIR)/libtcs_a-rpc_delegate.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_delegate.c' object='libtcs_a-rpc_delegate.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_delegate.o `test -f 'rpc/@RPC@/rpc_delegate.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_delegate.c
+
+libtcs_a-rpc_delegate.obj: rpc/@RPC@/rpc_delegate.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_delegate.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_delegate.Tpo -c -o libtcs_a-rpc_delegate.obj `if test -f 'rpc/@RPC@/rpc_delegate.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_delegate.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_delegate.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_delegate.Tpo $(DEPDIR)/libtcs_a-rpc_delegate.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_delegate.c' object='libtcs_a-rpc_delegate.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_delegate.obj `if test -f 'rpc/@RPC@/rpc_delegate.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_delegate.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_delegate.c'; fi`
+
+libtcs_a-tcsi_quote2.o: tcsi_quote2.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_quote2.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_quote2.Tpo -c -o libtcs_a-tcsi_quote2.o `test -f 'tcsi_quote2.c' || echo '$(srcdir)/'`tcsi_quote2.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_quote2.Tpo $(DEPDIR)/libtcs_a-tcsi_quote2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_quote2.c' object='libtcs_a-tcsi_quote2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_quote2.o `test -f 'tcsi_quote2.c' || echo '$(srcdir)/'`tcsi_quote2.c
+
+libtcs_a-tcsi_quote2.obj: tcsi_quote2.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_quote2.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_quote2.Tpo -c -o libtcs_a-tcsi_quote2.obj `if test -f 'tcsi_quote2.c'; then $(CYGPATH_W) 'tcsi_quote2.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_quote2.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_quote2.Tpo $(DEPDIR)/libtcs_a-tcsi_quote2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_quote2.c' object='libtcs_a-tcsi_quote2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_quote2.obj `if test -f 'tcsi_quote2.c'; then $(CYGPATH_W) 'tcsi_quote2.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_quote2.c'; fi`
+
+libtcs_a-tcs_quote2.o: tcs_quote2.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_quote2.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_quote2.Tpo -c -o libtcs_a-tcs_quote2.o `test -f 'tcs_quote2.c' || echo '$(srcdir)/'`tcs_quote2.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_quote2.Tpo $(DEPDIR)/libtcs_a-tcs_quote2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_quote2.c' object='libtcs_a-tcs_quote2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_quote2.o `test -f 'tcs_quote2.c' || echo '$(srcdir)/'`tcs_quote2.c
+
+libtcs_a-tcs_quote2.obj: tcs_quote2.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcs_quote2.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcs_quote2.Tpo -c -o libtcs_a-tcs_quote2.obj `if test -f 'tcs_quote2.c'; then $(CYGPATH_W) 'tcs_quote2.c'; else $(CYGPATH_W) '$(srcdir)/tcs_quote2.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcs_quote2.Tpo $(DEPDIR)/libtcs_a-tcs_quote2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcs_quote2.c' object='libtcs_a-tcs_quote2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcs_quote2.obj `if test -f 'tcs_quote2.c'; then $(CYGPATH_W) 'tcs_quote2.c'; else $(CYGPATH_W) '$(srcdir)/tcs_quote2.c'; fi`
+
+libtcs_a-rpc_quote2.o: rpc/@RPC@/rpc_quote2.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_quote2.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_quote2.Tpo -c -o libtcs_a-rpc_quote2.o `test -f 'rpc/@RPC@/rpc_quote2.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_quote2.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_quote2.Tpo $(DEPDIR)/libtcs_a-rpc_quote2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_quote2.c' object='libtcs_a-rpc_quote2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_quote2.o `test -f 'rpc/@RPC@/rpc_quote2.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_quote2.c
+
+libtcs_a-rpc_quote2.obj: rpc/@RPC@/rpc_quote2.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_quote2.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_quote2.Tpo -c -o libtcs_a-rpc_quote2.obj `if test -f 'rpc/@RPC@/rpc_quote2.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_quote2.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_quote2.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_quote2.Tpo $(DEPDIR)/libtcs_a-rpc_quote2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_quote2.c' object='libtcs_a-rpc_quote2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_quote2.obj `if test -f 'rpc/@RPC@/rpc_quote2.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_quote2.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_quote2.c'; fi`
+
+libtcs_a-tcsi_cmk.o: tcsi_cmk.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_cmk.o -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_cmk.Tpo -c -o libtcs_a-tcsi_cmk.o `test -f 'tcsi_cmk.c' || echo '$(srcdir)/'`tcsi_cmk.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_cmk.Tpo $(DEPDIR)/libtcs_a-tcsi_cmk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_cmk.c' object='libtcs_a-tcsi_cmk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_cmk.o `test -f 'tcsi_cmk.c' || echo '$(srcdir)/'`tcsi_cmk.c
+
+libtcs_a-tcsi_cmk.obj: tcsi_cmk.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-tcsi_cmk.obj -MD -MP -MF $(DEPDIR)/libtcs_a-tcsi_cmk.Tpo -c -o libtcs_a-tcsi_cmk.obj `if test -f 'tcsi_cmk.c'; then $(CYGPATH_W) 'tcsi_cmk.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_cmk.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-tcsi_cmk.Tpo $(DEPDIR)/libtcs_a-tcsi_cmk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcsi_cmk.c' object='libtcs_a-tcsi_cmk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-tcsi_cmk.obj `if test -f 'tcsi_cmk.c'; then $(CYGPATH_W) 'tcsi_cmk.c'; else $(CYGPATH_W) '$(srcdir)/tcsi_cmk.c'; fi`
+
+libtcs_a-rpc_cmk.o: rpc/@RPC@/rpc_cmk.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_cmk.o -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_cmk.Tpo -c -o libtcs_a-rpc_cmk.o `test -f 'rpc/@RPC@/rpc_cmk.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_cmk.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_cmk.Tpo $(DEPDIR)/libtcs_a-rpc_cmk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_cmk.c' object='libtcs_a-rpc_cmk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_cmk.o `test -f 'rpc/@RPC@/rpc_cmk.c' || echo '$(srcdir)/'`rpc/@RPC@/rpc_cmk.c
+
+libtcs_a-rpc_cmk.obj: rpc/@RPC@/rpc_cmk.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -MT libtcs_a-rpc_cmk.obj -MD -MP -MF $(DEPDIR)/libtcs_a-rpc_cmk.Tpo -c -o libtcs_a-rpc_cmk.obj `if test -f 'rpc/@RPC@/rpc_cmk.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_cmk.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_cmk.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libtcs_a-rpc_cmk.Tpo $(DEPDIR)/libtcs_a-rpc_cmk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rpc/@RPC@/rpc_cmk.c' object='libtcs_a-rpc_cmk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtcs_a_CFLAGS) $(CFLAGS) -c -o libtcs_a-rpc_cmk.obj `if test -f 'rpc/@RPC@/rpc_cmk.c'; then $(CYGPATH_W) 'rpc/@RPC@/rpc_cmk.c'; else $(CYGPATH_W) '$(srcdir)/rpc/@RPC@/rpc_cmk.c'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/tcs/crypto/openssl/crypto.c b/src/tcs/crypto/openssl/crypto.c
new file mode 100644
index 0000000..c02db27
--- /dev/null
+++ b/src/tcs/crypto/openssl/crypto.c
@@ -0,0 +1,68 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2006
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include <openssl/evp.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcslog.h"
+
+/*
+ * Hopefully this will make the code clearer since
+ * OpenSSL returns 1 on success
+ */
+#define EVP_SUCCESS 1
+
+TSS_RESULT
+Hash(UINT32 HashType, UINT32 BufSize, BYTE* Buf, BYTE* Digest)
+{
+ EVP_MD_CTX md_ctx;
+ unsigned int result_size;
+ int rv;
+
+ switch (HashType) {
+ case TSS_HASH_SHA1:
+ rv = EVP_DigestInit(&md_ctx, EVP_sha1());
+ break;
+ default:
+ rv = TCSERR(TSS_E_BAD_PARAMETER);
+ goto out;
+ break;
+ }
+
+ if (rv != EVP_SUCCESS) {
+ rv = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto out;
+ }
+
+ rv = EVP_DigestUpdate(&md_ctx, Buf, BufSize);
+ if (rv != EVP_SUCCESS) {
+ rv = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto out;
+ }
+
+ result_size = EVP_MD_CTX_size(&md_ctx);
+ rv = EVP_DigestFinal(&md_ctx, Digest, &result_size);
+ if (rv != EVP_SUCCESS) {
+ rv = TCSERR(TSS_E_INTERNAL_ERROR);
+ } else
+ rv = TSS_SUCCESS;
+
+out:
+ return rv;
+}
diff --git a/src/tcs/log.c b/src/tcs/log.c
new file mode 100644
index 0000000..8f3d0b4
--- /dev/null
+++ b/src/tcs/log.c
@@ -0,0 +1,87 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+
+#include <stdio.h>
+#include <string.h>
+#include <syslog.h>
+
+#include "trousers/tss.h"
+#include "tcslog.h"
+
+#ifdef TSS_DEBUG
+
+/*
+ * LogBlobData()
+ *
+ * Log a blob's data to the debugging stream
+ *
+ * szDescriptor - The APPID tag found in the caller's environment at build time
+ * sizeOfBlob - The size of the data to log
+ * blob - the data to log
+ *
+ */
+
+void
+LogBlobData(char *szDescriptor, unsigned long sizeOfBlob, unsigned char *blob)
+{
+ char temp[64];
+ unsigned int i;
+
+
+ if (getenv("TCSD_FOREGROUND") == NULL)
+ openlog(szDescriptor, LOG_NDELAY|LOG_PID, TSS_SYSLOG_LVL);
+ memset(temp, 0, sizeof(temp));
+
+ for (i = 0; (unsigned long)i < sizeOfBlob; i++) {
+ if ((i > 0) && ((i % 16) == 0)) {
+ if (getenv("TCSD_FOREGROUND") != NULL)
+ fprintf(stdout, "%s %s\n", szDescriptor, temp);
+ else
+ syslog(LOG_DEBUG, "%s", temp);
+ memset(temp, 0, sizeof(temp));
+ }
+ snprintf(&temp[(i%16)*3], 4, "%.2X ", blob[i]);
+ }
+
+ if (i == sizeOfBlob) {
+ if (getenv("TCSD_FOREGROUND") != NULL)
+ fprintf(stdout, "%s %s\n", szDescriptor, temp);
+ else
+ syslog(LOG_DEBUG, "%s", temp);
+ }
+}
+
+void
+LogTPMERR(TSS_RESULT result, char *file, int line)
+{
+ if (getenv("TSS_DEBUG_OFF") == NULL)
+ fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", "TPM", file, line, result);
+}
+
+TSS_RESULT
+LogTDDLERR(TSS_RESULT result, char *file, int line)
+{
+ if (getenv("TSS_DEBUG_OFF") == NULL)
+ fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", APPID, file, line, result);
+
+ return (result | TSS_LAYER_TDDL);
+}
+
+TSS_RESULT
+LogTCSERR(TSS_RESULT result, char *file, int line)
+{
+ if (getenv("TSS_DEBUG_OFF") == NULL)
+ fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", APPID, file, line, result);
+
+ return (result | TSS_LAYER_TCS);
+}
+
+#endif
diff --git a/src/tcs/ps/ps_utils.c b/src/tcs/ps/ps_utils.c
new file mode 100644
index 0000000..2e7f502
--- /dev/null
+++ b/src/tcs/ps/ps_utils.c
@@ -0,0 +1,538 @@
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#if defined(HAVE_BYTEORDER_H)
+#include <sys/byteorder.h>
+#elif defined(HTOLE_DEFINED)
+#include <endian.h>
+#define LE_16 htole16
+#define LE_32 htole32
+#define LE_64 htole64
+#else
+#define LE_16(x) (x)
+#define LE_32(x) (x)
+#define LE_64(x) (x)
+#endif
+#include <fcntl.h>
+#include <string.h>
+#include <limits.h>
+#include <assert.h>
+#include <errno.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_int_literals.h"
+#include "tcsps.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcslog.h"
+
+struct key_disk_cache *key_disk_cache_head = NULL;
+
+
+#ifdef SOLARIS
+TSS_RESULT
+#else
+inline TSS_RESULT
+#endif
+read_data(int fd, void *data, UINT32 size)
+{
+ int rc;
+
+ rc = read(fd, data, size);
+ if (rc == -1) {
+ LogError("read of %d bytes: %s", size, strerror(errno));
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else if ((unsigned)rc != size) {
+ LogError("read of %d bytes (only %d read)", size, rc);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ return TSS_SUCCESS;
+}
+
+
+#ifdef SOLARIS
+TSS_RESULT
+#else
+inline TSS_RESULT
+#endif
+write_data(int fd, void *data, UINT32 size)
+{
+ int rc;
+
+ rc = write(fd, data, size);
+ if (rc == -1) {
+ LogError("write of %d bytes: %s", size, strerror(errno));
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else if ((unsigned)rc != size) {
+ LogError("write of %d bytes (only %d written)", size, rc);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ return TSS_SUCCESS;
+}
+
+/*
+ * called by write_key_init to find the next available location in the PS file to
+ * write a new key to.
+ */
+int
+find_write_offset(UINT32 pub_data_size, UINT32 blob_size, UINT32 vendor_data_size)
+{
+ struct key_disk_cache *tmp;
+ unsigned int offset;
+
+ MUTEX_LOCK(disk_cache_lock);
+
+ tmp = key_disk_cache_head;
+ while (tmp) {
+ /* if we find a deleted key of the right size, return its offset */
+ if (!(tmp->flags & CACHE_FLAG_VALID) &&
+ tmp->pub_data_size == pub_data_size &&
+ tmp->blob_size == blob_size &&
+ tmp->vendor_data_size == vendor_data_size) {
+ offset = tmp->offset;
+ MUTEX_UNLOCK(disk_cache_lock);
+ return offset;
+ }
+ tmp = tmp->next;
+ }
+
+ MUTEX_UNLOCK(disk_cache_lock);
+
+ /* no correctly sized holes */
+ return -1;
+}
+
+/*
+ * move the file pointer to the point where the next key can be written and return
+ * that offset
+ */
+int
+write_key_init(int fd, UINT32 pub_data_size, UINT32 blob_size, UINT32 vendor_data_size)
+{
+ UINT32 num_keys;
+ BYTE version;
+ int rc, offset;
+
+ /* seek to the PS version */
+ rc = lseek(fd, TSSPS_VERSION_OFFSET, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return -1;
+ }
+
+ /* go to NUM_KEYS */
+ rc = lseek(fd, TSSPS_NUM_KEYS_OFFSET, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return -1;
+ }
+
+ /* read the number of keys */
+ rc = read(fd, &num_keys, sizeof(UINT32));
+ num_keys = LE_32(num_keys);
+ if (rc == -1) {
+ LogError("read of %zd bytes: %s", sizeof(UINT32), strerror(errno));
+ return -1;
+ } else if (rc == 0) {
+ /* This is the first key being written */
+ num_keys = 1;
+ version = 1;
+
+ /* seek to the PS version */
+ rc = lseek(fd, TSSPS_VERSION_OFFSET, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return -1;
+ }
+
+ /* write out the version info byte */
+ if ((rc = write_data(fd, &version, sizeof(BYTE)))) {
+ LogError("%s", __FUNCTION__);
+ return rc;
+ }
+
+ rc = lseek(fd, TSSPS_NUM_KEYS_OFFSET, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return -1;
+ }
+
+ num_keys = LE_32(num_keys);
+ if ((rc = write_data(fd, &num_keys, sizeof(UINT32)))) {
+ LogError("%s", __FUNCTION__);
+ return rc;
+ }
+
+ /* return the offset */
+ return (TSSPS_NUM_KEYS_OFFSET + sizeof(UINT32));
+ }
+
+ /* if there is a hole in the file we can write to, find it */
+ offset = find_write_offset(pub_data_size, blob_size, vendor_data_size);
+
+ if (offset != -1) {
+ /* we found a hole, seek to it and don't increment the # of keys on disk */
+ rc = lseek(fd, offset, SEEK_SET);
+ } else {
+ /* we didn't find a hole, increment the number of keys on disk and seek
+ * to the end of the file
+ */
+ num_keys++;
+
+ /* go to the beginning */
+ rc = lseek(fd, TSSPS_NUM_KEYS_OFFSET, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return -1;
+ }
+ num_keys = LE_32(num_keys);
+ if ((rc = write_data(fd, &num_keys, sizeof(UINT32)))) {
+ LogError("%s", __FUNCTION__);
+ return rc;
+ }
+
+ rc = lseek(fd, 0, SEEK_END);
+ }
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return -1;
+ }
+
+ /* lseek returns the number of bytes of offset from the beginning of the file */
+ return rc;
+}
+
+/*
+ * add a new cache entry for a written key
+ */
+TSS_RESULT
+cache_key(UINT32 offset, UINT16 flags,
+ TSS_UUID *uuid, TSS_UUID *parent_uuid,
+ UINT16 pub_data_size, UINT32 blob_size,
+ UINT32 vendor_data_size)
+{
+ struct key_disk_cache *tmp;
+
+ MUTEX_LOCK(disk_cache_lock);
+
+ tmp = key_disk_cache_head;
+
+ for (; tmp; tmp = tmp->next) {
+ /* reuse an invalidated key cache entry */
+ if (!(tmp->flags & CACHE_FLAG_VALID))
+ goto fill_cache_entry;
+ }
+
+ tmp = malloc(sizeof(struct key_disk_cache));
+ if (tmp == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(struct key_disk_cache));
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ tmp->next = key_disk_cache_head;
+ key_disk_cache_head = tmp;
+
+fill_cache_entry:
+ tmp->offset = offset;
+#ifdef TSS_DEBUG
+ if (offset == 0)
+ LogDebug("Storing key with file offset==0!!!");
+#endif
+ tmp->flags = flags;
+ tmp->blob_size = blob_size;
+ tmp->pub_data_size = pub_data_size;
+ tmp->vendor_data_size = vendor_data_size;
+ memcpy(&tmp->uuid, uuid, sizeof(TSS_UUID));
+ memcpy(&tmp->parent_uuid, parent_uuid, sizeof(TSS_UUID));
+
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TSS_SUCCESS;
+}
+
+/*
+ * read into the PS file and return the number of keys
+ */
+int
+get_num_keys_in_file(int fd)
+{
+ UINT32 num_keys;
+ int rc;
+
+ /* go to the number of keys */
+ rc = lseek(fd, TSSPS_NUM_KEYS_OFFSET, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return 0;
+ }
+
+ rc = read(fd, &num_keys, sizeof(UINT32));
+ if (rc < 0) {
+ LogError("read of %zd bytes: %s", sizeof(UINT32), strerror(errno));
+ return 0;
+ } else if ((unsigned)rc < sizeof(UINT32)) {
+ num_keys = 0;
+ }
+ num_keys = LE_32(num_keys);
+
+ return num_keys;
+}
+
+/*
+ * count the number of valid keys in the cache
+ */
+int
+get_num_keys()
+{
+ int num_keys = 0;
+ struct key_disk_cache *tmp;
+
+ MUTEX_LOCK(disk_cache_lock);
+
+ tmp = key_disk_cache_head;
+
+ for (; tmp; tmp = tmp->next) {
+ if (tmp->flags & CACHE_FLAG_VALID)
+ num_keys++;
+ }
+
+ MUTEX_UNLOCK(disk_cache_lock);
+ return num_keys;
+}
+
+/*
+ * disk store format:
+ *
+ * TrouSerS 0.2.0 and before:
+ * Version 0: cached?
+ * [UINT32 num_keys_on_disk]
+ * [TSS_UUID uuid0 ] yes
+ * [TSS_UUID uuid_parent0 ] yes
+ * [UINT16 pub_data_size0 ] yes
+ * [UINT16 blob_size0 ] yes
+ * [UINT16 cache_flags0 ] yes
+ * [BYTE[] pub_data0 ]
+ * [BYTE[] blob0 ]
+ * [...]
+ *
+ * TrouSerS 0.2.1+
+ * Version 1: cached?
+ * [BYTE PS version = '\1']
+ * [UINT32 num_keys_on_disk ]
+ * [TSS_UUID uuid0 ] yes
+ * [TSS_UUID uuid_parent0 ] yes
+ * [UINT16 pub_data_size0 ] yes
+ * [UINT16 blob_size0 ] yes
+ * [UINT32 vendor_data_size0] yes
+ * [UINT16 cache_flags0 ] yes
+ * [BYTE[] pub_data0 ]
+ * [BYTE[] blob0 ]
+ * [BYTE[] vendor_data0 ]
+ * [...]
+ *
+ */
+/*
+ * read the PS file pointed to by fd and create a cache based on it
+ */
+int
+init_disk_cache(int fd)
+{
+ UINT32 num_keys = get_num_keys_in_file(fd);
+ UINT16 i;
+ UINT64 tmp_offset;
+ int rc = 0, offset;
+ struct key_disk_cache *tmp, *prev = NULL;
+ BYTE srk_blob[2048];
+ TSS_KEY srk_key;
+#ifdef TSS_DEBUG
+ int valid_keys = 0;
+#endif
+
+ MUTEX_LOCK(disk_cache_lock);
+
+ if (num_keys == 0) {
+ key_disk_cache_head = NULL;
+ MUTEX_UNLOCK(disk_cache_lock);
+ return 0;
+ } else {
+ key_disk_cache_head = tmp = calloc(1, sizeof(struct key_disk_cache));
+ if (tmp == NULL) {
+ LogError("malloc of %zd bytes failed.",
+ sizeof(struct key_disk_cache));
+ rc = -1;
+ goto err_exit;
+ }
+ }
+
+ /* make sure the file pointer is where we expect, just after the number
+ * of keys on disk at the head of the file
+ */
+ offset = lseek(fd, TSSPS_KEYS_OFFSET, SEEK_SET);
+ if (offset == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ rc = -1;
+ goto err_exit;
+ }
+
+ for (i=0; i<num_keys; i++) {
+ offset = lseek(fd, 0, SEEK_CUR);
+ if (offset == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ rc = -1;
+ goto err_exit;
+ }
+ tmp->offset = offset;
+#ifdef TSS_DEBUG
+ if (offset == 0)
+ LogDebug("Storing key with file offset==0!!!");
+#endif
+ /* read UUID */
+ if ((rc = read_data(fd, (void *)&tmp->uuid, sizeof(TSS_UUID)))) {
+ LogError("%s", __FUNCTION__);
+ goto err_exit;
+ }
+
+ /* read parent UUID */
+ if ((rc = read_data(fd, (void *)&tmp->parent_uuid, sizeof(TSS_UUID)))) {
+ LogError("%s", __FUNCTION__);
+ goto err_exit;
+ }
+
+ /* pub data size */
+ if ((rc = read_data(fd, &tmp->pub_data_size, sizeof(UINT16)))) {
+ LogError("%s", __FUNCTION__);
+ goto err_exit;
+ }
+ tmp->pub_data_size = LE_16(tmp->pub_data_size);
+
+ DBG_ASSERT(tmp->pub_data_size <= 2048 && tmp->pub_data_size > 0);
+
+ /* blob size */
+ if ((rc = read_data(fd, &tmp->blob_size, sizeof(UINT16)))) {
+ LogError("%s", __FUNCTION__);
+ goto err_exit;
+ }
+ tmp->blob_size = LE_16(tmp->blob_size);
+ DBG_ASSERT(tmp->blob_size <= 4096 && tmp->blob_size > 0);
+
+ /* vendor data size */
+ if ((rc = read_data(fd, &tmp->vendor_data_size, sizeof(UINT32)))) {
+ LogError("%s", __FUNCTION__);
+ goto err_exit;
+ }
+ tmp->vendor_data_size = LE_32(tmp->vendor_data_size);
+
+ /* cache flags */
+ if ((rc = read_data(fd, &tmp->flags, sizeof(UINT16)))) {
+ LogError("%s", __FUNCTION__);
+ goto err_exit;
+ }
+ tmp->flags = LE_16(tmp->flags);
+
+#ifdef TSS_DEBUG
+ if (tmp->flags & CACHE_FLAG_VALID)
+ valid_keys++;
+#endif
+ /* fast forward over the pub key */
+ offset = lseek(fd, tmp->pub_data_size, SEEK_CUR);
+ if (offset == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ rc = -1;
+ goto err_exit;
+ }
+
+ /* if this is the SRK, load it into memory, since its already loaded in
+ * the chip */
+ if (!memcmp(&SRK_UUID, &tmp->uuid, sizeof(TSS_UUID))) {
+ /* read SRK blob from disk */
+ if ((rc = read_data(fd, srk_blob, tmp->blob_size))) {
+ LogError("%s", __FUNCTION__);
+ goto err_exit;
+ }
+
+ tmp_offset = 0;
+ if ((rc = UnloadBlob_TSS_KEY(&tmp_offset, srk_blob, &srk_key)))
+ goto err_exit;
+ /* add to the mem cache */
+ if ((rc = mc_add_entry_init(SRK_TPM_HANDLE, SRK_TPM_HANDLE, &srk_key,
+ &SRK_UUID))) {
+ LogError("Error adding SRK to mem cache.");
+ destroy_key_refs(&srk_key);
+ goto err_exit;
+ }
+ destroy_key_refs(&srk_key);
+ } else {
+ /* fast forward over the blob */
+ offset = lseek(fd, tmp->blob_size, SEEK_CUR);
+ if (offset == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ rc = -1;
+ goto err_exit;
+ }
+
+ /* fast forward over the vendor data */
+ offset = lseek(fd, tmp->vendor_data_size, SEEK_CUR);
+ if (offset == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ rc = -1;
+ goto err_exit;
+ }
+ }
+
+ tmp->next = calloc(1, sizeof(struct key_disk_cache));
+ if (tmp->next == NULL) {
+ LogError("malloc of %zd bytes failed.",
+ sizeof(struct key_disk_cache));
+ rc = -1;
+ goto err_exit;
+ }
+ prev = tmp;
+ tmp = tmp->next;
+ }
+
+ /* delete the dangling, unfilled cache entry */
+ free(tmp);
+ prev->next = NULL;
+ rc = 0;
+ LogDebug("%s: found %d valid key(s) on disk.\n", __FUNCTION__, valid_keys);
+
+err_exit:
+ MUTEX_UNLOCK(disk_cache_lock);
+ return rc;
+}
+
+int
+close_disk_cache(int fd)
+{
+ struct key_disk_cache *tmp, *tmp_next;
+
+ if (key_disk_cache_head == NULL)
+ return 0;
+
+ MUTEX_LOCK(disk_cache_lock);
+ tmp = key_disk_cache_head;
+
+ do {
+ tmp_next = tmp->next;
+ free(tmp);
+ tmp = tmp_next;
+ } while (tmp);
+
+ MUTEX_UNLOCK(disk_cache_lock);
+
+ return 0;
+}
diff --git a/src/tcs/ps/tcsps.c b/src/tcs/ps/tcsps.c
new file mode 100644
index 0000000..0d55608
--- /dev/null
+++ b/src/tcs/ps/tcsps.c
@@ -0,0 +1,784 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#if defined (HAVE_BYTEORDER_H)
+#include <sys/byteorder.h>
+#elif defined (HTOLE_DEFINED)
+#include <endian.h>
+#define LE_16 htole16
+#define LE_32 htole32
+#define LE_64 htole64
+#else
+#define LE_16(x) (x)
+#define LE_32(x) (x)
+#define LE_64(x) (x)
+#endif
+#include <assert.h>
+#include <fcntl.h>
+#include <limits.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcsps.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+int system_ps_fd = -1;
+MUTEX_DECLARE(disk_cache_lock);
+
+static struct flock fl;
+
+int
+get_file()
+{
+ int rc;
+ /* check the global file handle first. If it exists, lock it and return */
+ if (system_ps_fd != -1) {
+ int rc = 0;
+
+ fl.l_type = F_WRLCK;
+ if ((rc = fcntl(system_ps_fd, F_SETLKW, &fl))) {
+ LogError("failed to get system PS lock: %s", strerror(errno));
+ return -1;
+ }
+
+ return system_ps_fd;
+ }
+
+ /* open and lock the file */
+ system_ps_fd = open(tcsd_options.system_ps_file, O_CREAT|O_RDWR, 0600);
+ if (system_ps_fd < 0) {
+ LogError("system PS: open() of %s failed: %s",
+ tcsd_options.system_ps_file, strerror(errno));
+ return -1;
+ }
+
+ fl.l_type = F_WRLCK;
+ if ((rc = fcntl(system_ps_fd, F_SETLKW, &fl))) {
+ LogError("failed to get system PS lock of file %s: %s",
+ tcsd_options.system_ps_file, strerror(errno));
+ return -1;
+ }
+
+ return system_ps_fd;
+}
+
+int
+put_file(int fd)
+{
+ int rc = 0;
+ /* release the file lock */
+
+ fl.l_type = F_UNLCK;
+ if ((rc = fcntl(fd, F_SETLKW, &fl))) {
+ LogError("failed to unlock system PS file: %s",
+ strerror(errno));
+ return -1;
+ }
+
+ return rc;
+}
+
+void
+close_file(int fd)
+{
+ close(fd);
+ system_ps_fd = -1;
+}
+
+TSS_RESULT
+psfile_get_parent_uuid_by_uuid(int fd, TSS_UUID *uuid, TSS_UUID *ret_uuid)
+{
+ int rc;
+ UINT32 file_offset = 0;
+ struct key_disk_cache *tmp;
+
+ MUTEX_LOCK(disk_cache_lock);
+ tmp = key_disk_cache_head;
+
+ while (tmp) {
+ if (memcmp(uuid, &tmp->uuid, sizeof(TSS_UUID)) || !(tmp->flags & CACHE_FLAG_VALID)) {
+ tmp = tmp->next;
+ continue;
+ }
+
+ /* jump to the location of the parent uuid */
+ file_offset = TSSPS_PARENT_UUID_OFFSET(tmp);
+
+ rc = lseek(fd, file_offset, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ MUTEX_UNLOCK(disk_cache_lock);
+ return -1;
+ }
+
+ if ((rc = read_data(fd, ret_uuid, sizeof(TSS_UUID)))) {
+ LogError("%s", __FUNCTION__);
+ MUTEX_UNLOCK(disk_cache_lock);
+ return rc;
+ }
+
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TSS_SUCCESS;
+ }
+ MUTEX_UNLOCK(disk_cache_lock);
+ /* key not found */
+ return -2;
+}
+
+/*
+ * return a key blob from PS given a uuid
+ */
+TSS_RESULT
+psfile_get_key_by_uuid(int fd, TSS_UUID *uuid, BYTE *ret_buffer, UINT16 *ret_buffer_size)
+{
+ int rc;
+ UINT32 file_offset = 0;
+ struct key_disk_cache *tmp;
+
+ MUTEX_LOCK(disk_cache_lock);
+ tmp = key_disk_cache_head;
+
+ while (tmp) {
+ if (memcmp(uuid, &tmp->uuid, sizeof(TSS_UUID)) || !(tmp->flags & CACHE_FLAG_VALID)) {
+ tmp = tmp->next;
+ continue;
+ }
+
+ /* jump to the location of the key blob */
+ file_offset = TSSPS_BLOB_DATA_OFFSET(tmp);
+
+ rc = lseek(fd, file_offset, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ /* we found the key; file ptr is pointing at the blob */
+ if (*ret_buffer_size < tmp->blob_size) {
+ /* not enough room */
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TCSERR(TSS_E_FAIL);
+ }
+
+ if ((rc = read_data(fd, ret_buffer, tmp->blob_size))) {
+ LogError("%s", __FUNCTION__);
+ MUTEX_UNLOCK(disk_cache_lock);
+ return rc;
+ }
+ *ret_buffer_size = tmp->blob_size;
+ LogDebugUnrollKey(ret_buffer);
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TSS_SUCCESS;
+ }
+ MUTEX_UNLOCK(disk_cache_lock);
+ /* key not found */
+ return TCSERR(TSS_E_FAIL);
+}
+
+/*
+ * return a key blob from PS given its cache entry. The disk cache must be
+ * locked by the caller.
+ */
+TSS_RESULT
+psfile_get_key_by_cache_entry(int fd, struct key_disk_cache *c, BYTE *ret_buffer,
+ UINT16 *ret_buffer_size)
+{
+ int rc;
+ UINT32 file_offset = 0;
+
+ /* jump to the location of the key blob */
+ file_offset = TSSPS_BLOB_DATA_OFFSET(c);
+
+ rc = lseek(fd, file_offset, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ /* we found the key; file ptr is pointing at the blob */
+ if (*ret_buffer_size < c->blob_size) {
+ /* not enough room */
+ LogError("%s: Buf size too small. Needed %d bytes, passed %d", __FUNCTION__,
+ c->blob_size, *ret_buffer_size);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if ((rc = read_data(fd, ret_buffer, c->blob_size))) {
+ LogError("%s: error reading %d bytes", __FUNCTION__, c->blob_size);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ *ret_buffer_size = c->blob_size;
+
+ return TSS_SUCCESS;
+}
+
+/*
+ * return the vendor data from PS given its cache entry. The disk cache must be
+ * locked by the caller.
+ */
+TSS_RESULT
+psfile_get_vendor_data(int fd, struct key_disk_cache *c, UINT32 *size, BYTE **data)
+{
+ int rc;
+ UINT32 file_offset;
+
+ /* jump to the location of the data */
+ file_offset = TSSPS_VENDOR_DATA_OFFSET(c);
+
+ rc = lseek(fd, file_offset, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if ((*data = malloc(c->vendor_data_size)) == NULL) {
+ LogError("malloc of %u bytes failed", c->vendor_data_size);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ if ((rc = read_data(fd, *data, c->vendor_data_size))) {
+ LogError("%s: error reading %u bytes", __FUNCTION__, c->vendor_data_size);
+ free(*data);
+ *data = NULL;
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ *size = c->vendor_data_size;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+psfile_get_ps_type_by_uuid(int fd, TSS_UUID *uuid, UINT32 *ret_ps_type)
+{
+ struct key_disk_cache *tmp;
+
+ MUTEX_LOCK(disk_cache_lock);
+ tmp = key_disk_cache_head;
+
+ while (tmp) {
+ if (memcmp(uuid, &tmp->uuid, sizeof(TSS_UUID)) ||
+ !(tmp->flags & CACHE_FLAG_VALID)) {
+ tmp = tmp->next;
+ continue;
+ }
+
+ if (tmp->flags & CACHE_FLAG_PARENT_PS_SYSTEM) {
+ *ret_ps_type = TSS_PS_TYPE_SYSTEM;
+ goto done;
+ } else
+ break;
+ }
+
+ *ret_ps_type = TSS_PS_TYPE_USER;
+done:
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+psfile_is_pub_registered(int fd, TCPA_STORE_PUBKEY *pub, TSS_BOOL *is_reg)
+{
+ int rc;
+ UINT32 file_offset = 0;
+ struct key_disk_cache *tmp;
+ char tmp_buffer[2048];
+
+ MUTEX_LOCK(disk_cache_lock);
+ tmp = key_disk_cache_head;
+
+ while (tmp) {
+ /* if the key is of the wrong size or is invalid, try the next one */
+ if (pub->keyLength != tmp->pub_data_size || !(tmp->flags & CACHE_FLAG_VALID)) {
+ tmp = tmp->next;
+ continue;
+ }
+
+ /* we have a valid key with the same key size as the one we're looking for.
+ * grab the pub key data off disk and compare it. */
+
+ /* jump to the location of the public key */
+ file_offset = TSSPS_PUB_DATA_OFFSET(tmp);
+
+ rc = lseek(fd, file_offset, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ DBG_ASSERT(tmp->pub_data_size < 2048);
+
+ /* read in the key */
+ if ((rc = read_data(fd, tmp_buffer, tmp->pub_data_size))) {
+ LogError("%s", __FUNCTION__);
+ MUTEX_UNLOCK(disk_cache_lock);
+ return rc;
+ }
+
+ /* do the compare */
+ if (memcmp(tmp_buffer, pub->key, tmp->pub_data_size)) {
+ tmp = tmp->next;
+ continue;
+ }
+
+ /* the key matches, copy the uuid out */
+ *is_reg = TRUE;
+
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TSS_SUCCESS;
+ }
+ MUTEX_UNLOCK(disk_cache_lock);
+ /* key not found */
+ *is_reg = FALSE;
+ return TSS_SUCCESS;
+}
+
+
+TSS_RESULT
+psfile_get_uuid_by_pub(int fd, TCPA_STORE_PUBKEY *pub, TSS_UUID **ret_uuid)
+{
+ int rc;
+ UINT32 file_offset = 0;
+ struct key_disk_cache *tmp;
+ char tmp_buffer[2048];
+
+ MUTEX_LOCK(disk_cache_lock);
+ tmp = key_disk_cache_head;
+
+ while (tmp) {
+ /* if the key is of the wrong size or is invalid, try the next one */
+ if (pub->keyLength != tmp->pub_data_size || !(tmp->flags & CACHE_FLAG_VALID)) {
+ tmp = tmp->next;
+ continue;
+ }
+
+ /* we have a valid key with the same key size as the one we're looking for.
+ * grab the pub key data off disk and compare it. */
+
+ /* jump to the location of the public key */
+ file_offset = TSSPS_PUB_DATA_OFFSET(tmp);
+
+ rc = lseek(fd, file_offset, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ DBG_ASSERT(tmp->pub_data_size < 2048);
+
+ if (tmp->pub_data_size > sizeof(tmp_buffer)) {
+ LogError("Source buffer size too big! Size: %d",
+ tmp->pub_data_size);
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ /* read in the key */
+ if ((rc = read_data(fd, tmp_buffer, tmp->pub_data_size))) {
+ LogError("%s", __FUNCTION__);
+ MUTEX_UNLOCK(disk_cache_lock);
+ return rc;
+ }
+
+ /* do the compare */
+ if (memcmp(tmp_buffer, pub->key, tmp->pub_data_size)) {
+ tmp = tmp->next;
+ continue;
+ }
+
+ *ret_uuid = (TSS_UUID *)malloc(sizeof(TSS_UUID));
+ if (*ret_uuid == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(TSS_UUID));
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ /* the key matches, copy the uuid out */
+ memcpy(*ret_uuid, &tmp->uuid, sizeof(TSS_UUID));
+
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TSS_SUCCESS;
+ }
+ MUTEX_UNLOCK(disk_cache_lock);
+ /* key not found */
+ return TCSERR(TSS_E_PS_KEY_NOTFOUND);
+}
+
+TSS_RESULT
+psfile_get_key_by_pub(int fd, TCPA_STORE_PUBKEY *pub, UINT32 *size, BYTE **ret_key)
+{
+ int rc;
+ UINT32 file_offset = 0;
+ struct key_disk_cache *tmp;
+ BYTE tmp_buffer[4096];
+
+ MUTEX_LOCK(disk_cache_lock);
+ tmp = key_disk_cache_head;
+
+ while (tmp) {
+ /* if the key is of the wrong size or is invalid, try the next one */
+ if (pub->keyLength != tmp->pub_data_size || !(tmp->flags & CACHE_FLAG_VALID)) {
+ tmp = tmp->next;
+ continue;
+ }
+
+ /* we have a valid key with the same key size as the one we're looking for.
+ * grab the pub key data off disk and compare it. */
+
+ /* jump to the location of the public key */
+ file_offset = TSSPS_PUB_DATA_OFFSET(tmp);
+
+ rc = lseek(fd, file_offset, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ DBG_ASSERT(tmp->pub_data_size < 2048);
+ if (tmp->pub_data_size > sizeof(tmp_buffer)) {
+ LogError("Source buffer size too big! Size: %d",
+ tmp->pub_data_size);
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ /* read in the key */
+ if ((rc = read_data(fd, tmp_buffer, tmp->pub_data_size))) {
+ LogError("%s", __FUNCTION__);
+ MUTEX_UNLOCK(disk_cache_lock);
+ return rc;
+ }
+
+ /* do the compare */
+ if (memcmp(tmp_buffer, pub->key, tmp->pub_data_size)) {
+ tmp = tmp->next;
+ continue;
+ }
+
+ /* jump to the location of the key blob */
+ file_offset = TSSPS_BLOB_DATA_OFFSET(tmp);
+
+ rc = lseek(fd, file_offset, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ DBG_ASSERT(tmp->blob_size < 4096);
+ if (tmp->blob_size > sizeof(tmp_buffer)) {
+ LogError("Blob size greater than 4096! Size: %d",
+ tmp->blob_size);
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ /* read in the key blob */
+ if ((rc = read_data(fd, tmp_buffer, tmp->blob_size))) {
+ LogError("%s", __FUNCTION__);
+ MUTEX_UNLOCK(disk_cache_lock);
+ return rc;
+ }
+
+ *ret_key = malloc(tmp->blob_size);
+ if (*ret_key == NULL) {
+ LogError("malloc of %d bytes failed.", tmp->blob_size);
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ memcpy(*ret_key, tmp_buffer, tmp->blob_size);
+ *size = tmp->blob_size;
+
+ MUTEX_UNLOCK(disk_cache_lock);
+ return rc;
+ }
+ MUTEX_UNLOCK(disk_cache_lock);
+ /* key not found */
+ return -2;
+}
+
+/*
+ * disk store format:
+ *
+ * TrouSerS 0.2.0 and before:
+ * Version 0: cached?
+ * [UINT32 num_keys_on_disk]
+ * [TSS_UUID uuid0 ] yes
+ * [TSS_UUID uuid_parent0 ] yes
+ * [UINT16 pub_data_size0 ] yes
+ * [UINT16 blob_size0 ] yes
+ * [UINT16 cache_flags0 ] yes
+ * [BYTE[] pub_data0 ]
+ * [BYTE[] blob0 ]
+ * [...]
+ *
+ * TrouSerS 0.2.1+
+ * Version 1: cached?
+ * [BYTE PS version = '\1']
+ * [UINT32 num_keys_on_disk ]
+ * [TSS_UUID uuid0 ] yes
+ * [TSS_UUID uuid_parent0 ] yes
+ * [UINT16 pub_data_size0 ] yes
+ * [UINT16 blob_size0 ] yes
+ * [UINT32 vendor_data_size0] yes
+ * [UINT16 cache_flags0 ] yes
+ * [BYTE[] pub_data0 ]
+ * [BYTE[] blob0 ]
+ * [BYTE[] vendor_data0 ]
+ * [...]
+ *
+ */
+TSS_RESULT
+psfile_write_key(int fd,
+ TSS_UUID *uuid,
+ TSS_UUID *parent_uuid,
+ UINT32 *parent_ps,
+ BYTE *vendor_data,
+ UINT32 vendor_size,
+ BYTE *key_blob,
+ UINT16 key_blob_size)
+{
+ TSS_KEY key;
+ UINT16 pub_key_size, cache_flags = CACHE_FLAG_VALID;
+ UINT64 offset;
+ int rc = 0;
+
+ /* leaving the cache flag for parent ps type as 0 implies TSS_PS_TYPE_USER */
+ if (*parent_ps == TSS_PS_TYPE_SYSTEM)
+ cache_flags |= CACHE_FLAG_PARENT_PS_SYSTEM;
+
+ /* Unload the blob to get the public key */
+ offset = 0;
+ if ((rc = UnloadBlob_TSS_KEY(&offset, key_blob, &key)))
+ return rc;
+
+ pub_key_size = key.pubKey.keyLength;
+
+ if ((rc = write_key_init(fd, pub_key_size, key_blob_size, vendor_size)) < 0)
+ goto done;
+
+ /* offset now holds the number of bytes from the beginning of the file
+ * the key will be stored at
+ */
+ offset = rc;
+
+#ifdef TSS_DEBUG
+ if (offset == 0)
+ LogDebug("ERROR: key being written with offset 0!!");
+#endif
+
+ /* [TSS_UUID uuid0 ] yes */
+ if ((rc = write_data(fd, (void *)uuid, sizeof(TSS_UUID)))) {
+ LogError("%s", __FUNCTION__);
+ goto done;
+ }
+
+ /* [TSS_UUID uuid_parent0 ] yes */
+ if ((rc = write_data(fd, (void *)parent_uuid, sizeof(TSS_UUID)))) {
+ LogError("%s", __FUNCTION__);
+ goto done;
+ }
+
+ /* [UINT16 pub_data_size0 ] yes */
+ pub_key_size = LE_16(pub_key_size);
+ if ((rc = write_data(fd, &pub_key_size, sizeof(UINT16)))) {
+ LogError("%s", __FUNCTION__);
+ goto done;
+ }
+ /* Swap it back for later */
+ pub_key_size = LE_16(pub_key_size);
+
+ /* [UINT16 blob_size0 ] yes */
+ key_blob_size = LE_16(key_blob_size);
+ if ((rc = write_data(fd, &key_blob_size, sizeof(UINT16)))) {
+ LogError("%s", __FUNCTION__);
+ goto done;
+ }
+ /* Swap it back for later */
+ key_blob_size = LE_16(key_blob_size);
+
+ /* [UINT32 vendor_data_size0 ] yes */
+ vendor_size = LE_32(vendor_size);
+ if ((rc = write_data(fd, &vendor_size, sizeof(UINT32)))) {
+ LogError("%s", __FUNCTION__);
+ goto done;
+ }
+ /* Swap it back for later */
+ vendor_size = LE_32(vendor_size);
+
+ /* [UINT16 cache_flags0 ] yes */
+ cache_flags = LE_16(cache_flags);
+ if ((rc = write_data(fd, &cache_flags, sizeof(UINT16)))) {
+ LogError("%s", __FUNCTION__);
+ goto done;
+ }
+ /* Swap it back for later */
+ cache_flags = LE_16(cache_flags);
+
+ /* [BYTE[] pub_data0 ] no */
+ if ((rc = write_data(fd, (void *)key.pubKey.key, pub_key_size))) {
+ LogError("%s", __FUNCTION__);
+ goto done;
+ }
+
+ /* [BYTE[] blob0 ] no */
+ if ((rc = write_data(fd, (void *)key_blob, key_blob_size))) {
+ LogError("%s", __FUNCTION__);
+ goto done;
+ }
+
+ /* [BYTE[] vendor_data0 ] no */
+ if (vendor_size > 0) {
+ if ((rc = write_data(fd, (void *)vendor_data, vendor_size))) {
+ LogError("%s", __FUNCTION__);
+ goto done;
+ }
+ }
+
+ if ((rc = cache_key((UINT32)offset, cache_flags, uuid, parent_uuid, pub_key_size,
+ key_blob_size, vendor_size)))
+ goto done;
+done:
+ destroy_key_refs(&key);
+
+ return rc;
+}
+
+TSS_RESULT
+psfile_remove_key(int fd, struct key_disk_cache *c)
+{
+ TSS_RESULT result;
+ UINT32 head_offset = 0, tail_offset, num_keys;
+ BYTE buf[4096];
+ struct stat stat_buf;
+ int rc, size = 0;
+
+ if ((rc = fstat(fd, &stat_buf)) != 0) {
+ LogError("fstat: %s", strerror(errno));
+ return TSS_E_INTERNAL_ERROR;
+ }
+
+ /* head_offset is the offset the beginning of the key */
+ head_offset = TSSPS_UUID_OFFSET(c);
+
+ /* tail_offset is the offset the beginning of the next key */
+ tail_offset = TSSPS_VENDOR_DATA_OFFSET(c) + c->vendor_data_size;
+
+ rc = lseek(fd, tail_offset, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ /* read in from tail, write out to head to fill the gap */
+ while ((rc = read(fd, buf, sizeof(buf))) > 0) {
+ size = rc;
+ tail_offset += size;
+
+ /* set the file pointer to where we want to write */
+ rc = lseek(fd, head_offset, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ /* write the data */
+ if ((result = write_data(fd, (void *)buf, size))) {
+ LogError("%s", __FUNCTION__);
+ return result;
+ }
+ head_offset += size;
+
+ /* set the file pointer to where we want to read in the next
+ * loop */
+ rc = lseek(fd, tail_offset, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (rc < 0) {
+ LogError("read: %s", strerror(errno));
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ /* set the file pointer to where we want to write */
+ rc = lseek(fd, head_offset, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ /* head_offset now contains a pointer to where we want to truncate the
+ * file. Zero out the old tail end of the file and truncate it. */
+
+ memset(buf, 0, sizeof(buf));
+
+ /* Zero out the old tail end of the file */
+ if ((result = write_data(fd, (void *)buf, tail_offset - head_offset))) {
+ LogError("%s", __FUNCTION__);
+ return result;
+ }
+
+ if ((rc = ftruncate(fd, head_offset)) < 0) {
+ LogError("ftruncate: %s", strerror(errno));
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ /* we succeeded in removing a key from the disk. Decrement the number
+ * of keys in the file */
+ rc = lseek(fd, TSSPS_NUM_KEYS_OFFSET, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ rc = read(fd, &num_keys, sizeof(UINT32));
+ num_keys = LE_32(num_keys);
+ if (rc != sizeof(UINT32)) {
+ LogError("read of %zd bytes: %s", sizeof(UINT32), strerror(errno));
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ rc = lseek(fd, TSSPS_NUM_KEYS_OFFSET, SEEK_SET);
+ if (rc == ((off_t) - 1)) {
+ LogError("lseek: %s", strerror(errno));
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ /* decrement, then write back out to disk */
+ num_keys--;
+
+ num_keys = LE_32(num_keys);
+ if ((result = write_data(fd, (void *)&num_keys, sizeof(UINT32)))) {
+ LogError("%s", __FUNCTION__);
+ return result;
+ }
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc.c b/src/tcs/rpc/tcstp/rpc.c
new file mode 100644
index 0000000..7660675
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc.c
@@ -0,0 +1,628 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2007
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+#if (defined (__OpenBSD__) || defined (__FreeBSD__))
+#include <sys/types.h>
+#include <sys/socket.h>
+#endif
+#include <errno.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "rpc_tcstp_tcs.h"
+
+
+/* Lock is not static because we need to reference it in the auth manager */
+MUTEX_DECLARE_INIT(tcsp_lock);
+
+
+void
+LoadBlob_Auth_Special(UINT64 *offset, BYTE *blob, TPM_AUTH *auth)
+{
+ LoadBlob(offset, TCPA_SHA1BASED_NONCE_LEN, blob, auth->NonceEven.nonce);
+ LoadBlob_BOOL(offset, auth->fContinueAuthSession, blob);
+ LoadBlob(offset, TCPA_SHA1BASED_NONCE_LEN, blob, (BYTE *)&auth->HMAC);
+}
+
+void
+UnloadBlob_Auth_Special(UINT64 *offset, BYTE *blob, TPM_AUTH *auth)
+{
+ UnloadBlob_UINT32(offset, &auth->AuthHandle, blob);
+ UnloadBlob(offset, TCPA_SHA1BASED_NONCE_LEN, blob, auth->NonceOdd.nonce);
+ UnloadBlob_BOOL(offset, &auth->fContinueAuthSession, blob);
+ UnloadBlob(offset, TCPA_SHA1BASED_NONCE_LEN, blob, (BYTE *)&auth->HMAC);
+}
+
+int
+recv_from_socket(int sock, void *buffer, int size)
+{
+ int recv_size = 0, recv_total = 0;
+
+ while (recv_total < size) {
+ errno = 0;
+ if ((recv_size = recv(sock, buffer+recv_total, size-recv_total, 0)) <= 0) {
+ if (recv_size < 0) {
+ if (errno == EINTR)
+ continue;
+ LogError("Socket receive connection error: %s.", strerror(errno));
+ } else {
+ LogDebug("Socket connection closed.");
+ }
+
+ return -1;
+ }
+ recv_total += recv_size;
+ }
+
+ return recv_total;
+}
+
+int
+send_to_socket(int sock, void *buffer, int size)
+{
+ int send_size = 0, send_total = 0;
+
+ while (send_total < size) {
+ if ((send_size = send(sock, buffer+send_total, size-send_total, 0)) < 0) {
+ LogError("Socket send connection error: %s.", strerror(errno));
+ return -1;
+ }
+ send_total += send_size;
+ }
+
+ return send_total;
+}
+
+
+void
+initData(struct tcsd_comm_data *comm, int parm_count)
+{
+ /* min packet size should be the size of the header */
+ memset(&comm->hdr, 0, sizeof(struct tcsd_packet_hdr));
+ comm->hdr.packet_size = sizeof(struct tcsd_packet_hdr);
+ if (parm_count > 0) {
+ comm->hdr.type_offset = sizeof(struct tcsd_packet_hdr);
+ comm->hdr.parm_offset = comm->hdr.type_offset +
+ (sizeof(TCSD_PACKET_TYPE) * parm_count);
+ comm->hdr.packet_size = comm->hdr.parm_offset;
+ }
+
+ memset(comm->buf, 0, comm->buf_size);
+}
+
+int
+loadData(UINT64 *offset, TCSD_PACKET_TYPE data_type, void *data, int data_size, BYTE *blob)
+{
+ switch (data_type) {
+ case TCSD_PACKET_TYPE_BYTE:
+ LoadBlob_BYTE(offset, *((BYTE *) (data)), blob);
+ break;
+ case TCSD_PACKET_TYPE_BOOL:
+ LoadBlob_BOOL(offset, *((TSS_BOOL *) (data)), blob);
+ break;
+ case TCSD_PACKET_TYPE_UINT16:
+ LoadBlob_UINT16(offset, *((UINT16 *) (data)), blob);
+ break;
+ case TCSD_PACKET_TYPE_UINT32:
+ LoadBlob_UINT32(offset, *((UINT32 *) (data)), blob);
+ break;
+ case TCSD_PACKET_TYPE_UINT64:
+ LoadBlob_UINT64(offset, *((UINT64 *) (data)), blob);
+ break;
+ case TCSD_PACKET_TYPE_PBYTE:
+ LoadBlob(offset, data_size, blob, data);
+ break;
+ case TCSD_PACKET_TYPE_NONCE:
+ LoadBlob(offset, sizeof(TCPA_NONCE), blob, ((TCPA_NONCE *)data)->nonce);
+ break;
+ case TCSD_PACKET_TYPE_DIGEST:
+ LoadBlob(offset, sizeof(TCPA_DIGEST), blob, ((TCPA_DIGEST *)data)->digest);
+ break;
+ case TCSD_PACKET_TYPE_AUTH:
+ LoadBlob_Auth_Special(offset, blob, ((TPM_AUTH *)data));
+ break;
+#ifdef TSS_BUILD_PS
+ case TCSD_PACKET_TYPE_UUID:
+ LoadBlob_UUID(offset, blob, *((TSS_UUID *)data));
+ break;
+ case TCSD_PACKET_TYPE_KM_KEYINFO:
+ LoadBlob_KM_KEYINFO(offset, blob, ((TSS_KM_KEYINFO *)data));
+ break;
+ case TCSD_PACKET_TYPE_KM_KEYINFO2:
+ LoadBlob_KM_KEYINFO2(offset, blob, ((TSS_KM_KEYINFO2 *)data));
+ break;
+ case TCSD_PACKET_TYPE_LOADKEY_INFO:
+ LoadBlob_LOADKEY_INFO(offset, blob, ((TCS_LOADKEY_INFO *)data));
+ break;
+#endif
+ case TCSD_PACKET_TYPE_ENCAUTH:
+ LoadBlob(offset, sizeof(TCPA_ENCAUTH), blob,
+ ((TCPA_ENCAUTH *)data)->authdata);
+ break;
+ case TCSD_PACKET_TYPE_VERSION:
+ LoadBlob_VERSION(offset, blob, ((TPM_VERSION *)data));
+ break;
+#ifdef TSS_BUILD_PCR_EVENTS
+ case TCSD_PACKET_TYPE_PCR_EVENT:
+ LoadBlob_PCR_EVENT(offset, blob, ((TSS_PCR_EVENT *)data));
+ break;
+#endif
+ case TCSD_PACKET_TYPE_SECRET:
+ LoadBlob(offset, sizeof(TCPA_SECRET), blob,
+ ((TCPA_SECRET *)data)->authdata);
+ break;
+ default:
+ LogError("TCSD packet type unknown! (0x%x)", data_type & 0xff);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ return TSS_SUCCESS;
+}
+
+
+int
+setData(TCSD_PACKET_TYPE dataType,
+ unsigned int index,
+ void *theData,
+ int theDataSize,
+ struct tcsd_comm_data *comm)
+{
+ UINT64 old_offset, offset;
+ TSS_RESULT result;
+ TCSD_PACKET_TYPE *type;
+
+ /* Calculate the size of the area needed (use NULL for blob address) */
+ offset = 0;
+ if ((result = loadData(&offset, dataType, theData, theDataSize, NULL)) != TSS_SUCCESS)
+ return result;
+
+ if ((comm->hdr.packet_size + offset) > comm->buf_size) {
+ /* reallocate the buffer */
+ BYTE *buffer;
+ int buffer_size = comm->hdr.packet_size + offset;
+
+ LogDebug("Increasing communication buffer to %d bytes.", buffer_size);
+ buffer = realloc(comm->buf, buffer_size);
+ if (buffer == NULL) {
+ LogError("realloc of %d bytes failed.", buffer_size);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ comm->buf_size = buffer_size;
+ comm->buf = buffer;
+ }
+
+ offset = old_offset = comm->hdr.parm_offset + comm->hdr.parm_size;
+ if ((result = loadData(&offset, dataType, theData, theDataSize, comm->buf)) != TSS_SUCCESS)
+ return result;
+ type = (TCSD_PACKET_TYPE *)(comm->buf + comm->hdr.type_offset) + index;
+ *type = dataType;
+ comm->hdr.type_size += sizeof(TCSD_PACKET_TYPE);
+ comm->hdr.parm_size += (offset - old_offset);
+
+ comm->hdr.packet_size = offset;
+ comm->hdr.num_parms++;
+
+ return TSS_SUCCESS;
+}
+
+UINT32
+getData(TCSD_PACKET_TYPE dataType,
+ unsigned int index,
+ void *theData,
+ int theDataSize,
+ struct tcsd_comm_data *comm)
+{
+ UINT64 old_offset, offset;
+ TCSD_PACKET_TYPE *type;
+
+ if ((comm->hdr.type_offset + index) > comm->buf_size)
+ return TSS_TCP_RPC_BAD_PACKET_TYPE;
+
+ type = (comm->buf + comm->hdr.type_offset) + index;
+
+ if ((UINT32)index >= comm->hdr.num_parms || dataType != *type) {
+ LogDebug("Data type of TCS packet element %d doesn't match.", index);
+ return TSS_TCP_RPC_BAD_PACKET_TYPE;
+ }
+ old_offset = offset = comm->hdr.parm_offset;
+ switch (dataType) {
+ case TCSD_PACKET_TYPE_BYTE:
+ if (old_offset + sizeof(BYTE) > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ UnloadBlob_BYTE(&offset, (BYTE *) (theData), comm->buf);
+ break;
+ case TCSD_PACKET_TYPE_BOOL:
+ if (old_offset + sizeof(TSS_BOOL) > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ UnloadBlob_BOOL(&offset, (TSS_BOOL *) (theData), comm->buf);
+ break;
+ case TCSD_PACKET_TYPE_UINT16:
+ if (old_offset + sizeof(UINT16) > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ UnloadBlob_UINT16(&offset, (UINT16 *) (theData), comm->buf);
+ break;
+ case TCSD_PACKET_TYPE_UINT32:
+ if (old_offset + sizeof(UINT32) > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ UnloadBlob_UINT32(&offset, (UINT32 *) (theData), comm->buf);
+ break;
+ case TCSD_PACKET_TYPE_PBYTE:
+ if (old_offset + theDataSize > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ UnloadBlob(&offset, theDataSize, comm->buf, theData);
+ break;
+ case TCSD_PACKET_TYPE_NONCE:
+ if (old_offset + sizeof(TPM_NONCE) > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ UnloadBlob(&offset, sizeof(TCPA_NONCE), comm->buf,
+ ((TCPA_NONCE *) (theData))->nonce);
+ break;
+ case TCSD_PACKET_TYPE_DIGEST:
+ if (old_offset + sizeof(TPM_DIGEST) > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ UnloadBlob(&offset, sizeof(TCPA_DIGEST), comm->buf,
+ ((TCPA_DIGEST *) (theData))->digest);
+ break;
+ case TCSD_PACKET_TYPE_AUTH:
+ if ((old_offset + sizeof(TCS_AUTHHANDLE)
+ + sizeof(TPM_BOOL)
+ + (2 * sizeof(TPM_NONCE))) > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ UnloadBlob_Auth_Special(&offset, comm->buf, ((TPM_AUTH *) theData));
+ break;
+ case TCSD_PACKET_TYPE_ENCAUTH:
+ if (old_offset + sizeof(TPM_ENCAUTH) > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ UnloadBlob(&offset, sizeof(TCPA_ENCAUTH), comm->buf,
+ ((TCPA_ENCAUTH *) theData)->authdata);
+ break;
+ case TCSD_PACKET_TYPE_VERSION:
+ if (old_offset + sizeof(TPM_VERSION) > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ UnloadBlob_VERSION(&offset, comm->buf, ((TPM_VERSION *) theData));
+ break;
+#ifdef TSS_BUILD_PS
+ case TCSD_PACKET_TYPE_KM_KEYINFO:
+ UnloadBlob_KM_KEYINFO(&old_offset, comm->buf, NULL);
+
+ if (old_offset > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ old_offset = offset;
+ UnloadBlob_KM_KEYINFO(&offset, comm->buf, ((TSS_KM_KEYINFO *)theData));
+ break;
+ case TCSD_PACKET_TYPE_LOADKEY_INFO:
+ UnloadBlob_LOADKEY_INFO(&old_offset, comm->buf, NULL);
+
+ if (old_offset > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ old_offset = offset;
+ UnloadBlob_LOADKEY_INFO(&offset, comm->buf, ((TCS_LOADKEY_INFO *)theData));
+ break;
+ case TCSD_PACKET_TYPE_UUID:
+ if (old_offset + sizeof(TSS_UUID) > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ UnloadBlob_UUID(&offset, comm->buf, (TSS_UUID *) theData);
+ break;
+#endif
+#ifdef TSS_BUILD_PCR_EVENTS
+ case TCSD_PACKET_TYPE_PCR_EVENT:
+ {
+ TSS_RESULT result;
+
+ (void)UnloadBlob_PCR_EVENT(&old_offset, comm->buf, NULL);
+
+ if (old_offset > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ old_offset = offset;
+ if ((result = UnloadBlob_PCR_EVENT(&offset, comm->buf,
+ ((TSS_PCR_EVENT *)theData))))
+ return result;
+ break;
+ }
+#endif
+ case TCSD_PACKET_TYPE_SECRET:
+ if (old_offset + sizeof(TPM_SECRET) > comm->hdr.packet_size)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ UnloadBlob(&offset, sizeof(TCPA_SECRET), comm->buf,
+ ((TCPA_SECRET *) theData)->authdata);
+ break;
+ default:
+ LogError("TCSD packet type unknown! (0x%x)", dataType & 0xff);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ comm->hdr.parm_offset = offset;
+ comm->hdr.parm_size -= (offset - old_offset);
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_Error(struct tcsd_thread_data *data)
+{
+ LogError("%s reached.", __FUNCTION__);
+
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = TCSERR(TSS_E_FAIL);
+
+ return TSS_SUCCESS;
+
+}
+
+/* Dispatch */
+typedef struct tdDispatchTable {
+ TSS_RESULT (*Func) (struct tcsd_thread_data *);
+ const char *name;
+} DispatchTable;
+
+DispatchTable tcs_func_table[TCSD_MAX_NUM_ORDS] = {
+ {tcs_wrap_Error,"Error"}, /* 0 */
+ {tcs_wrap_OpenContext,"OpenContext"},
+ {tcs_wrap_CloseContext,"CloseContext"},
+ {tcs_wrap_Error,"Error"},
+ {tcs_wrap_TCSGetCapability,"TCSGetCapability"},
+ {tcs_wrap_RegisterKey,"RegisterKey"}, /* 5 */
+ {tcs_wrap_UnregisterKey,"UnregisterKey"},
+ {tcs_wrap_EnumRegisteredKeys,"EnumRegisteredKeys"},
+ {tcs_wrap_Error,"Error"},
+ {tcs_wrap_GetRegisteredKeyBlob,"GetRegisteredKeyBlob"},
+ {tcs_wrap_GetRegisteredKeyByPublicInfo,"GetRegisteredKeyByPublicInfo"}, /* 10 */
+ {tcs_wrap_LoadKeyByBlob,"LoadKeyByBlob"},
+ {tcs_wrap_LoadKeyByUUID,"LoadKeyByUUID"},
+ {tcs_wrap_EvictKey,"EvictKey"},
+ {tcs_wrap_CreateWrapKey,"CreateWrapKey"},
+ {tcs_wrap_GetPubkey,"GetPubkey"}, /* 15 */
+ {tcs_wrap_MakeIdentity,"MakeIdentity"},
+ {tcs_wrap_LogPcrEvent,"LogPcrEvent"},
+ {tcs_wrap_GetPcrEvent,"GetPcrEvent"},
+ {tcs_wrap_GetPcrEventsByPcr,"GetPcrEventsByPcr"},
+ {tcs_wrap_GetPcrEventLog,"GetPcrEventLog"}, /* 20 */
+ {tcs_wrap_SetOwnerInstall,"SetOwnerInstall"},
+ {tcs_wrap_TakeOwnership,"TakeOwnership"},
+ {tcs_wrap_OIAP,"OIAP"},
+ {tcs_wrap_OSAP,"OSAP"},
+ {tcs_wrap_ChangeAuth,"ChangeAuth"}, /* 25 */
+ {tcs_wrap_ChangeAuthOwner,"ChangeAuthOwner"},
+ {tcs_wrap_Error,"Error"},
+ {tcs_wrap_Error,"Error"},
+ {tcs_wrap_TerminateHandle,"TerminateHandle"},
+ {tcs_wrap_ActivateIdentity,"ActivateIdentity"}, /* 30 */
+ {tcs_wrap_Extend,"Extend"},
+ {tcs_wrap_PcrRead,"PcrRead"},
+ {tcs_wrap_Quote,"Quote"},
+ {tcs_wrap_DirWriteAuth,"DirWriteAuth"},
+ {tcs_wrap_DirRead,"DirRead"}, /* 35 */
+ {tcs_wrap_Seal,"Seal"},
+ {tcs_wrap_UnSeal,"UnSeal"},
+ {tcs_wrap_UnBind,"UnBind"},
+ {tcs_wrap_CreateMigrationBlob,"CreateMigrationBlob"},
+ {tcs_wrap_ConvertMigrationBlob,"ConvertMigrationBlob"}, /* 40 */
+ {tcs_wrap_AuthorizeMigrationKey,"AuthorizeMigrationKey"},
+ {tcs_wrap_CertifyKey,"CertifyKey"},
+ {tcs_wrap_Sign,"Sign"},
+ {tcs_wrap_GetRandom,"GetRandom"},
+ {tcs_wrap_StirRandom,"StirRandom"}, /* 45 */
+ {tcs_wrap_GetCapability,"GetCapability"},
+ {tcs_wrap_Error,"Error"},
+ {tcs_wrap_GetCapabilityOwner,"GetCapabilityOwner"},
+ {tcs_wrap_CreateEndorsementKeyPair,"CreateEndorsementKeyPair"},
+ {tcs_wrap_ReadPubek,"ReadPubek"}, /* 50 */
+ {tcs_wrap_DisablePubekRead,"DisablePubekRead"},
+ {tcs_wrap_OwnerReadPubek,"OwnerReadPubek"},
+ {tcs_wrap_SelfTestFull,"SelfTestFull"},
+ {tcs_wrap_CertifySelfTest,"CertifySelfTest"},
+ {tcs_wrap_Error,"Error"}, /* 55 */
+ {tcs_wrap_GetTestResult,"GetTestResult"},
+ {tcs_wrap_OwnerSetDisable,"OwnerSetDisable"},
+ {tcs_wrap_OwnerClear,"OwnerClear"},
+ {tcs_wrap_DisableOwnerClear,"DisableOwnerClear"},
+ {tcs_wrap_ForceClear,"ForceClear"}, /* 60 */
+ {tcs_wrap_DisableForceClear,"DisableForceClear"},
+ {tcs_wrap_PhysicalDisable,"PhysicalDisable"},
+ {tcs_wrap_PhysicalEnable,"PhysicalEnable"},
+ {tcs_wrap_PhysicalSetDeactivated,"PhysicalSetDeactivated"},
+ {tcs_wrap_SetTempDeactivated,"SetTempDeactivated"}, /* 65 */
+ {tcs_wrap_PhysicalPresence,"PhysicalPresence"},
+ {tcs_wrap_Error,"Error"},
+ {tcs_wrap_Error,"Error"},
+ {tcs_wrap_CreateMaintenanceArchive,"CreateMaintenanceArchive"},
+ {tcs_wrap_LoadMaintenanceArchive,"LoadMaintenanceArchive"}, /* 70 */
+ {tcs_wrap_KillMaintenanceFeature,"KillMaintenanceFeature"},
+ {tcs_wrap_LoadManuMaintPub,"LoadManuMaintPub"},
+ {tcs_wrap_ReadManuMaintPub,"ReadManuMaintPub"},
+ {tcs_wrap_DaaJoin,"DaaJoin"},
+ {tcs_wrap_DaaSign,"DaaSign"}, /* 75 */
+ {tcs_wrap_SetCapability,"SetCapability"},
+ {tcs_wrap_ResetLockValue,"ResetLockValue"},
+ {tcs_wrap_PcrReset,"PcrReset"},
+ {tcs_wrap_ReadCounter,"ReadCounter"},
+ {tcs_wrap_CreateCounter,"CreateCounter"}, /* 80 */
+ {tcs_wrap_IncrementCounter,"IncrementCounter"},
+ {tcs_wrap_ReleaseCounter,"ReleaseCounter"},
+ {tcs_wrap_ReleaseCounterOwner,"ReleaseCounterOwner"},
+ {tcs_wrap_ReadCurrentTicks,"ReadCurrentTicks"},
+ {tcs_wrap_TickStampBlob,"TicksStampBlob"}, /* 85 */
+ {tcs_wrap_GetCredential,"GetCredential"},
+ {tcs_wrap_NV_DefineOrReleaseSpace,"NVDefineOrReleaseSpace"},
+ {tcs_wrap_NV_WriteValue,"NVWriteValue"},
+ {tcs_wrap_NV_WriteValueAuth,"NVWriteValueAuth"},
+ {tcs_wrap_NV_ReadValue,"NVReadValue"}, /* 90 */
+ {tcs_wrap_NV_ReadValueAuth,"NVReadValueAuth"},
+ {tcs_wrap_EstablishTransport,"EstablishTransport"},
+ {tcs_wrap_ExecuteTransport,"ExecuteTransport"},
+ {tcs_wrap_ReleaseTransportSigned,"ReleaseTransportSigned"},
+ {tcs_wrap_SetOrdinalAuditStatus,"SetOrdinalAuditStatus"}, /* 95 */
+ {tcs_wrap_GetAuditDigest,"GetAuditDigest"},
+ {tcs_wrap_GetAuditDigestSigned,"GetAuditDigestSigned"},
+ {tcs_wrap_Sealx,"Sealx"},
+ {tcs_wrap_SetOperatorAuth,"SetOperatorAuth"},
+ {tcs_wrap_OwnerReadInternalPub,"OwnerReadInternalPub"}, /* 100 */
+ {tcs_wrap_EnumRegisteredKeys2,"EnumRegisteredKeys2"},
+ {tcs_wrap_SetTempDeactivated2,"SetTempDeactivated2"},
+ {tcs_wrap_Delegate_Manage,"Delegate_Manage"},
+ {tcs_wrap_Delegate_CreateKeyDelegation,"Delegate_CreateKeyDelegation"},
+ {tcs_wrap_Delegate_CreateOwnerDelegation,"Delegate_CreateOwnerDelegation"}, /* 105 */
+ {tcs_wrap_Delegate_LoadOwnerDelegation,"Delegate_LoadOwnerDelegation"},
+ {tcs_wrap_Delegate_ReadTable,"Delegate_ReadTable"},
+ {tcs_wrap_Delegate_UpdateVerificationCount,"Delegate_UpdateVerificationCount"},
+ {tcs_wrap_Delegate_VerifyDelegation,"Delegate_VerifyDelegation"},
+ {tcs_wrap_CreateRevocableEndorsementKeyPair,"CreateRevocableEndorsementKeyPair"}, /* 110 */
+ {tcs_wrap_RevokeEndorsementKeyPair,"RevokeEndorsementKeyPair"},
+ {tcs_wrap_Error,"Error - was MakeIdentity2"},
+ {tcs_wrap_Quote2,"Quote2"},
+ {tcs_wrap_CMK_SetRestrictions,"CMK_SetRestrictions"},
+ {tcs_wrap_CMK_ApproveMA,"CMK_ApproveMA"}, /* 115 */
+ {tcs_wrap_CMK_CreateKey,"CMK_CreateKey"},
+ {tcs_wrap_CMK_CreateTicket,"CMK_CreateTicket"},
+ {tcs_wrap_CMK_CreateBlob,"CMK_CreateBlob"},
+ {tcs_wrap_CMK_ConvertMigration,"CMK_ConvertMigration"},
+ {tcs_wrap_FlushSpecific,"FlushSpecific"}, /* 120 */
+ {tcs_wrap_KeyControlOwner, "KeyControlOwner"},
+ {tcs_wrap_DSAP, "DSAP"}
+};
+
+int
+access_control(struct tcsd_thread_data *thread_data)
+{
+ int i = 0;
+ struct hostent *local_hostent = NULL;
+ static char *localhostname = NULL;
+ static int localhostname_len = 0;
+
+ if (!localhostname) {
+ if ((local_hostent = gethostbyname("localhost")) == NULL) {
+ LogError("Error resolving localhost: %s", hstrerror(h_errno));
+ return 1;
+ }
+
+ LogDebugFn("Cached local hostent:");
+ LogDebugFn("h_name: %s", local_hostent->h_name);
+ for (i = 0; local_hostent->h_aliases[i]; i++) {
+ LogDebugFn("h_aliases[%d]: %s", i, local_hostent->h_aliases[i]);
+ }
+ LogDebugFn("h_addrtype: %s",
+ (local_hostent->h_addrtype == AF_INET6 ? "AF_INET6" : "AF_INET"));
+
+ localhostname_len = strlen(local_hostent->h_name);
+ if ((localhostname = strdup(local_hostent->h_name)) == NULL) {
+ LogError("malloc of %d bytes failed.", localhostname_len);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ }
+
+ /* if the request comes from localhost, or is in the accepted ops list,
+ * approve it */
+ if (!strncmp(thread_data->hostname, localhostname,
+ MIN((size_t)localhostname_len, strlen(thread_data->hostname)))) {
+ return 0;
+ } else {
+ while (tcsd_options.remote_ops[i]) {
+ if ((UINT32)tcsd_options.remote_ops[i] == thread_data->comm.hdr.u.ordinal) {
+ LogInfo("Accepted %s operation from %s",
+ tcs_func_table[thread_data->comm.hdr.u.ordinal].name,
+ thread_data->hostname);
+ return 0;
+ }
+ i++;
+ }
+ }
+
+ return 1;
+}
+
+TSS_RESULT
+dispatchCommand(struct tcsd_thread_data *data)
+{
+ UINT64 offset;
+ TSS_RESULT result;
+
+ /* First, check the ordinal bounds */
+ if (data->comm.hdr.u.ordinal >= TCSD_MAX_NUM_ORDS) {
+ LogError("Illegal TCSD Ordinal");
+ return TCSERR(TSS_E_FAIL);
+ }
+
+ LogDebug("Dispatching ordinal %u", data->comm.hdr.u.ordinal);
+ /* We only need to check access_control if there are remote operations that are defined
+ * in the config file, which means we allow remote connections */
+ if (tcsd_options.remote_ops[0] && access_control(data)) {
+ LogWarn("Denied %s operation from %s",
+ tcs_func_table[data->comm.hdr.u.ordinal].name, data->hostname);
+
+ /* set platform header */
+ memset(&data->comm.hdr, 0, sizeof(data->comm.hdr));
+ data->comm.hdr.packet_size = sizeof(struct tcsd_packet_hdr);
+ data->comm.hdr.u.result = TCSERR(TSS_E_FAIL);
+
+ /* set the comm buffer */
+ memset(data->comm.buf, 0, data->comm.buf_size);
+ offset = 0;
+ LoadBlob_UINT32(&offset, data->comm.hdr.packet_size, data->comm.buf);
+ LoadBlob_UINT32(&offset, data->comm.hdr.u.result, data->comm.buf);
+
+ return TSS_SUCCESS;
+ }
+
+ /* Now, dispatch */
+ if ((result = tcs_func_table[data->comm.hdr.u.ordinal].Func(data)) == TSS_SUCCESS) {
+ /* set the comm buffer */
+ offset = 0;
+ LoadBlob_UINT32(&offset, data->comm.hdr.packet_size, data->comm.buf);
+ LoadBlob_UINT32(&offset, data->comm.hdr.u.result, data->comm.buf);
+ LoadBlob_UINT32(&offset, data->comm.hdr.num_parms, data->comm.buf);
+ LoadBlob_UINT32(&offset, data->comm.hdr.type_size, data->comm.buf);
+ LoadBlob_UINT32(&offset, data->comm.hdr.type_offset, data->comm.buf);
+ LoadBlob_UINT32(&offset, data->comm.hdr.parm_size, data->comm.buf);
+ LoadBlob_UINT32(&offset, data->comm.hdr.parm_offset, data->comm.buf);
+ }
+
+ return result;
+
+}
+
+TSS_RESULT
+getTCSDPacket(struct tcsd_thread_data *data)
+{
+ /* make sure the all the data is present */
+ if (data->comm.hdr.num_parms > 0 &&
+ data->comm.hdr.packet_size !=
+ (UINT32)(data->comm.hdr.parm_offset + data->comm.hdr.parm_size))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ /* dispatch the command to the TCS */
+ return dispatchCommand(data);
+}
diff --git a/src/tcs/rpc/tcstp/rpc_admin.c b/src/tcs/rpc/tcstp/rpc_admin.c
new file mode 100644
index 0000000..4f357c3
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_admin.c
@@ -0,0 +1,404 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2007
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_PhysicalSetDeactivated(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_BOOL state;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_BOOL, 1, &state, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_PhysicalSetDeactivated_Internal(hContext, state);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_DisableOwnerClear(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ TPM_AUTH auth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 1, &auth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_DisableOwnerClear_Internal(hContext, &auth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &auth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_ForceClear(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_ForceClear_Internal(hContext);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_DisableForceClear(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_DisableForceClear_Internal(hContext);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_PhysicalEnable(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_PhysicalEnable_Internal(hContext);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_SetOwnerInstall(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_BOOL state;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_BOOL, 1, &state, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_SetOwnerInstall_Internal(hContext, state);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_OwnerSetDisable(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_BOOL disableState;
+ TPM_AUTH ownerAuth;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_BOOL, 1, &disableState, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 2, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_OwnerSetDisable_Internal(hContext, disableState, &ownerAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_PhysicalDisable(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_PhysicalDisable_Internal(hContext);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_PhysicalPresence(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ TCPA_PHYSICAL_PRESENCE phyPresFlags;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT16, 1, &phyPresFlags, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_PhysicalPresence_Internal(hContext, phyPresFlags);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_SetTempDeactivated(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_SetTempDeactivated_Internal(hContext);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+#ifdef TSS_BUILD_TSS12
+TSS_RESULT
+tcs_wrap_SetTempDeactivated2(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TPM_AUTH operatorAuth, nullAuth, *pAuth;
+ TSS_RESULT result;
+
+ memset(&operatorAuth, 0, sizeof(TPM_AUTH));
+ memset(&nullAuth, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 1, &operatorAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (memcmp(&nullAuth, &operatorAuth, sizeof(TPM_AUTH)))
+ pAuth = &operatorAuth;
+ else
+ pAuth = NULL;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_SetTempDeactivated2_Internal(hContext, pAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, pAuth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_ResetLockValue(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TPM_AUTH ownerAuth;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 1, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_ResetLockValue_Internal(hContext, &ownerAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_FlushSpecific(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_HANDLE hResHandle;
+ TPM_RESOURCE_TYPE resourceType;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hResHandle, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &resourceType, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_FlushSpecific_Internal(hContext, hResHandle, resourceType);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+#endif
diff --git a/src/tcs/rpc/tcstp/rpc_aik.c b/src/tcs/rpc/tcstp/rpc_aik.c
new file mode 100644
index 0000000..0f758f9
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_aik.c
@@ -0,0 +1,285 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_MakeIdentity(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCPA_ENCAUTH identityAuth;
+ TCPA_CHOSENID_HASH privCAHash;
+ UINT32 idKeyInfoSize;
+ BYTE *idKeyInfo = NULL;
+
+ TPM_AUTH auth1, auth2;
+ TPM_AUTH *pSRKAuth, *pOwnerAuth;
+
+ UINT32 idKeySize;
+ BYTE *idKey = NULL;
+ UINT32 pcIDBindSize;
+ BYTE *prgbIDBind = NULL;
+ UINT32 pcECSize;
+ BYTE *prgbEC = NULL;
+ UINT32 pcPlatCredSize;
+ BYTE *prgbPlatCred = NULL;
+ UINT32 pcConfCredSize;
+ BYTE *prgbConfCred = NULL;
+ TSS_RESULT result;
+
+ int i;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_ENCAUTH, 1, &identityAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_DIGEST, 2, &privCAHash, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &idKeyInfoSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ idKeyInfo = (BYTE *) calloc(1, idKeyInfoSize);
+ if (idKeyInfo == NULL) {
+ LogError("malloc of %d bytes failed.", idKeyInfoSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 4, idKeyInfo, idKeyInfoSize, &data->comm)) {
+ free(idKeyInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_AUTH, 5, &auth1, 0, &data->comm)) {
+ free(idKeyInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ result = getData(TCSD_PACKET_TYPE_AUTH, 6, &auth2, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE) {
+ pOwnerAuth = &auth1;
+ pSRKAuth = NULL;
+ } else if (result) {
+ free(idKeyInfo);
+ return result;
+ } else {
+ pOwnerAuth = &auth2;
+ pSRKAuth = &auth1;
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_MakeIdentity_Internal(hContext, identityAuth, privCAHash,
+ idKeyInfoSize, idKeyInfo, pSRKAuth,
+ pOwnerAuth, &idKeySize, &idKey,
+ &pcIDBindSize, &prgbIDBind, &pcECSize,
+ &prgbEC, &pcPlatCredSize, &prgbPlatCred,
+ &pcConfCredSize, &prgbConfCred);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(idKeyInfo);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 12);
+ if (pSRKAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pSRKAuth, 0, &data->comm))
+ goto internal_error;
+ }
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pOwnerAuth, 0, &data->comm))
+ goto internal_error;
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &idKeySize, 0, &data->comm))
+ goto internal_error;
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, idKey, idKeySize, &data->comm))
+ goto internal_error;
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &pcIDBindSize, 0, &data->comm))
+ goto internal_error;
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, prgbIDBind, pcIDBindSize, &data->comm))
+ goto internal_error;
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &pcECSize, 0, &data->comm))
+ goto internal_error;
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, prgbEC, pcECSize, &data->comm))
+ goto internal_error;
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &pcPlatCredSize, 0, &data->comm))
+ goto internal_error;
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, prgbPlatCred, pcPlatCredSize, &data->comm))
+ goto internal_error;
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &pcConfCredSize, 0, &data->comm))
+ goto internal_error;
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, prgbConfCred, pcConfCredSize, &data->comm))
+ goto internal_error;
+
+ free(idKey);
+ free(prgbIDBind);
+ free(prgbEC);
+ free(prgbPlatCred);
+ free(prgbConfCred);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+
+internal_error:
+ free(idKey);
+ free(prgbIDBind);
+ free(prgbEC);
+ free(prgbPlatCred);
+ free(prgbConfCred);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+}
+
+TSS_RESULT
+tcs_wrap_ActivateIdentity(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE idKeyHandle;
+ TPM_AUTH *pIdKeyAuth = NULL, *pOwnerAuth = NULL, auth1, auth2;
+ UINT32 SymmetricKeySize, blobSize;
+ BYTE *SymmetricKey, *blob;
+ TSS_RESULT result;
+ UINT32 i;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &idKeyHandle, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &blobSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if ((blob = malloc(blobSize)) == NULL)
+ return TCSERR(TSS_E_OUTOFMEMORY);
+
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, blob, blobSize, &data->comm)) {
+ free(blob);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 4, &auth1, 0, &data->comm)) {
+ free(blob);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ result = getData(TCSD_PACKET_TYPE_AUTH, 5, &auth2, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
+ pOwnerAuth = &auth1;
+ else if (result) {
+ free(blob);
+ return result;
+ } else {
+ pIdKeyAuth = &auth1;
+ pOwnerAuth = &auth2;
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_ActivateTPMIdentity_Internal(hContext, idKeyHandle, blobSize,
+ blob, pIdKeyAuth, pOwnerAuth,
+ &SymmetricKeySize,
+ &SymmetricKey);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(blob);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 4);
+ if (pIdKeyAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pIdKeyAuth, 0, &data->comm)) {
+ free(SymmetricKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pOwnerAuth, 0, &data->comm)) {
+ free(SymmetricKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &SymmetricKeySize, 0, &data->comm)) {
+ free(SymmetricKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, SymmetricKey, SymmetricKeySize, &data->comm)) {
+ free(SymmetricKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(SymmetricKey);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+#ifdef TSS_BUILD_TSS12
+TSS_RESULT
+tcs_wrap_GetCredential(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT32 CredType;
+ UINT32 CredAccessMode;
+ UINT32 CredSize;
+ BYTE *CredData = NULL;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &CredType, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &CredAccessMode, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ result = TCS_GetCredential_Internal(hContext, CredType, CredAccessMode,
+ &CredSize, &CredData);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &CredSize, 0, &data->comm))
+ goto internal_error;
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 1, CredData, CredSize, &data->comm))
+ goto internal_error;
+
+ free(CredData);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+
+internal_error:
+ free(CredData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+}
+#endif
diff --git a/src/tcs/rpc/tcstp/rpc_audit.c b/src/tcs/rpc/tcstp/rpc_audit.c
new file mode 100644
index 0000000..0fcfd18
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_audit.c
@@ -0,0 +1,230 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2007
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_SetOrdinalAuditStatus(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TPM_AUTH ownerAuth;
+ UINT32 ulOrdinal;
+ TSS_BOOL bAuditState;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &ulOrdinal, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_BOOL, 2, &bAuditState, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 3, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_SetOrdinalAuditStatus_Internal(hContext, &ownerAuth, ulOrdinal, bAuditState);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_GetAuditDigest(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT32 startOrdinal;
+ TPM_DIGEST auditDigest;
+ UINT32 counterValueSize;
+ BYTE *counterValue;
+ TSS_BOOL more;
+ UINT32 ordSize;
+ UINT32 *ordList;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &startOrdinal, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_GetAuditDigest_Internal(hContext, startOrdinal, &auditDigest, &counterValueSize, &counterValue,
+ &more, &ordSize, &ordList);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 6);
+ if (setData(TCSD_PACKET_TYPE_DIGEST, 0, &auditDigest, 0, &data->comm)) {
+ free(counterValue);
+ free(ordList);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &counterValueSize, 0, &data->comm)) {
+ free(counterValue);
+ free(ordList);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 2, counterValue, counterValueSize, &data->comm)) {
+ free(counterValue);
+ free(ordList);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(counterValue);
+ if (setData(TCSD_PACKET_TYPE_BOOL, 3, &more, 0, &data->comm)) {
+ free(ordList);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, 4, &ordSize, 0, &data->comm)) {
+ free(ordList);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 5, ordList, ordSize * sizeof(UINT32), &data->comm)) {
+ free(ordList);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(ordList);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_GetAuditDigestSigned(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE keyHandle;
+ TSS_BOOL closeAudit;
+ TPM_NONCE antiReplay;
+ TPM_AUTH privAuth, nullAuth, *pAuth;
+ UINT32 counterValueSize;
+ BYTE *counterValue;
+ TPM_DIGEST auditDigest;
+ TPM_DIGEST ordinalDigest;
+ UINT32 sigSize;
+ BYTE *sig;
+ TSS_RESULT result;
+ int i;
+
+ memset(&privAuth, 0, sizeof(TPM_AUTH));
+ memset(&nullAuth, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &keyHandle, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_BOOL, 2, &closeAudit, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_NONCE, 3, &antiReplay, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_AUTH, 4, &privAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (memcmp(&nullAuth, &privAuth, sizeof(TPM_AUTH)))
+ pAuth = &privAuth;
+ else
+ pAuth = NULL;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_GetAuditDigestSigned_Internal(hContext, keyHandle, closeAudit, antiReplay,
+ pAuth, &counterValueSize, &counterValue,
+ &auditDigest, &ordinalDigest,
+ &sigSize, &sig);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 7);
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth, 0, &data->comm)) {
+ free(counterValue);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &counterValueSize, 0, &data->comm)) {
+ free(counterValue);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, counterValue, counterValueSize, &data->comm)) {
+ free(counterValue);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(counterValue);
+ if (setData(TCSD_PACKET_TYPE_DIGEST, i++, &auditDigest, 0, &data->comm)) {
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_DIGEST, i++, &ordinalDigest, 0, &data->comm)) {
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &sigSize, 0, &data->comm)) {
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, sig, sigSize, &data->comm)) {
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(sig);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_auth.c b/src/tcs/rpc/tcstp/rpc_auth.c
new file mode 100644
index 0000000..2437c6b
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_auth.c
@@ -0,0 +1,113 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_OIAP(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_AUTHHANDLE authHandle;
+ TCPA_NONCE n0;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = auth_mgr_oiap(hContext, &authHandle, &n0);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &authHandle, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_NONCE, 1, &n0, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_OSAP(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCPA_ENTITY_TYPE entityType;
+ UINT32 entityValue;
+ TCPA_NONCE nonceOddOSAP;
+
+ TCS_AUTHHANDLE authHandle;
+ TCPA_NONCE nonceEven;
+ TCPA_NONCE nonceEvenOSAP;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT16, 1, &entityType, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &entityValue, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_NONCE, 3, &nonceOddOSAP, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = auth_mgr_osap(hContext, entityType, entityValue, nonceOddOSAP,
+ &authHandle, &nonceEven, &nonceEvenOSAP);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 3);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &authHandle, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_NONCE, 1, &nonceEven, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_NONCE, 2, &nonceEvenOSAP, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_bind.c b/src/tcs/rpc/tcstp/rpc_bind.c
new file mode 100644
index 0000000..92eee24
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_bind.c
@@ -0,0 +1,105 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_UnBind(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE keyHandle;
+ UINT32 inDataSize;
+ BYTE *inData;
+
+ TPM_AUTH privAuth;
+ TPM_AUTH *pPrivAuth;
+
+ UINT32 outDataSize;
+ BYTE *outData;
+ TSS_RESULT result;
+
+ int i;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &keyHandle, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &inDataSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ inData = calloc(1, inDataSize);
+ if (inData == NULL) {
+ LogError("malloc of %u bytes failed.", inDataSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, inData, inDataSize, &data->comm)) {
+ free(inData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ result = getData(TCSD_PACKET_TYPE_AUTH, 4, &privAuth, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
+ pPrivAuth = NULL;
+ else if (result) {
+ free(inData);
+ return result;
+ } else
+ pPrivAuth = &privAuth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_UnBind_Internal(hContext, keyHandle, inDataSize, inData,
+ pPrivAuth, &outDataSize, &outData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(inData);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 3);
+ if (pPrivAuth != NULL) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pPrivAuth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &outDataSize, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, outData, outDataSize, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(outData);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_caps.c b/src/tcs/rpc/tcstp/rpc_caps.c
new file mode 100644
index 0000000..4fd2c11
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_caps.c
@@ -0,0 +1,81 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_TCSGetCapability(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCPA_CAPABILITY_AREA capArea;
+ UINT32 subCapSize;
+ BYTE *subCap;
+ UINT32 respSize;
+ BYTE *resp;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &capArea, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &subCapSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ subCap = calloc(1, subCapSize);
+ if (subCap == NULL) {
+ LogError("malloc of %u bytes failed.", subCapSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, subCap, subCapSize, &data->comm)) {
+ free(subCap);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ result = TCS_GetCapability_Internal(hContext, capArea, subCapSize, subCap,
+ &respSize, &resp);
+ free(subCap);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &respSize, 0, &data->comm)) {
+ free(resp);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 1, resp, respSize, &data->comm)) {
+ free(resp);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(resp);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_caps_tpm.c b/src/tcs/rpc/tcstp/rpc_caps_tpm.c
new file mode 100644
index 0000000..2bcac27
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_caps_tpm.c
@@ -0,0 +1,220 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_GetCapability(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCPA_CAPABILITY_AREA capArea;
+ UINT32 subCapSize;
+ BYTE *subCap;
+ UINT32 respSize;
+ BYTE *resp;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ldd context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &capArea, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &subCapSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (subCapSize == 0)
+ subCap = NULL;
+ else {
+ subCap = calloc(1, subCapSize);
+ if (subCap == NULL) {
+ LogError("malloc of %u bytes failed.", subCapSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, subCap, subCapSize, &data->comm)) {
+ free(subCap);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_GetCapability_Internal(hContext, capArea, subCapSize, subCap, &respSize,
+ &resp);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(subCap);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &respSize, 0, &data->comm)) {
+ free(resp);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 1, resp, respSize, &data->comm)) {
+ free(resp);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(resp);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_GetCapabilityOwner(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TPM_AUTH ownerAuth;
+ TCPA_VERSION version;
+ UINT32 nonVol;
+ UINT32 vol;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 1, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_GetCapabilityOwner_Internal(hContext, &ownerAuth, &version, &nonVol, &vol);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 4);
+ if (setData(TCSD_PACKET_TYPE_VERSION, 0, &version, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &nonVol, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, 2, &vol, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_AUTH, 3, &ownerAuth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_SetCapability(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCPA_CAPABILITY_AREA capArea;
+ UINT32 subCapSize;
+ BYTE *subCap;
+ UINT32 valueSize;
+ BYTE *value;
+ TSS_RESULT result;
+ TPM_AUTH ownerAuth, *pOwnerAuth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &capArea, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &subCapSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (subCapSize == 0)
+ subCap = NULL;
+ else {
+ subCap = calloc(1, subCapSize);
+ if (subCap == NULL) {
+ LogError("malloc of %u bytes failed.", subCapSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, subCap, subCapSize, &data->comm)) {
+ free(subCap);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 4, &valueSize, 0, &data->comm)) {
+ free(subCap);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (valueSize == 0)
+ value = NULL;
+ else {
+ value = calloc(1, valueSize);
+ if (value == NULL) {
+ free(subCap);
+ LogError("malloc of %u bytes failed.", valueSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 5, value, valueSize, &data->comm)) {
+ free(subCap);
+ free(value);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 6, &ownerAuth, 0, &data->comm))
+ pOwnerAuth = NULL;
+ else
+ pOwnerAuth = &ownerAuth;
+
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_SetCapability_Internal(hContext, capArea, subCapSize, subCap, valueSize,
+ value, pOwnerAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(subCap);
+ free(value);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (pOwnerAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, pOwnerAuth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_certify.c b/src/tcs/rpc/tcstp/rpc_certify.c
new file mode 100644
index 0000000..85c9321
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_certify.c
@@ -0,0 +1,120 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_CertifyKey(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE certHandle, keyHandle;
+ TPM_AUTH *pCertAuth = NULL, *pKeyAuth = NULL, certAuth, keyAuth, nullAuth;
+ UINT32 CertifyInfoSize, outDataSize;
+ BYTE *CertifyInfo, *outData;
+ TCPA_NONCE antiReplay;
+ TSS_RESULT result;
+ UINT32 i;
+
+ memset(&nullAuth, 0, sizeof(TPM_AUTH));
+ memset(&certAuth, 0, sizeof(TPM_AUTH));
+ memset(&keyAuth, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &certHandle, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &keyHandle, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_NONCE, 3, &antiReplay, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 4, &certAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_AUTH, 5, &keyAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (memcmp(&nullAuth, &certAuth, sizeof(TPM_AUTH)))
+ pCertAuth = &certAuth;
+
+ if (memcmp(&nullAuth, &keyAuth, sizeof(TPM_AUTH)))
+ pKeyAuth = &keyAuth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_CertifyKey_Internal(hContext, certHandle, keyHandle, antiReplay, pCertAuth,
+ pKeyAuth, &CertifyInfoSize, &CertifyInfo, &outDataSize,
+ &outData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 6);
+ if (pCertAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pCertAuth, 0, &data->comm)) {
+ free(CertifyInfo);
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (pKeyAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pKeyAuth, 0, &data->comm)) {
+ free(CertifyInfo);
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &CertifyInfoSize, 0, &data->comm)) {
+ free(CertifyInfo);
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, CertifyInfo, CertifyInfoSize, &data->comm)) {
+ free(CertifyInfo);
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(CertifyInfo);
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &outDataSize, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, outData, outDataSize, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(outData);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_changeauth.c b/src/tcs/rpc/tcstp/rpc_changeauth.c
new file mode 100644
index 0000000..97af192
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_changeauth.c
@@ -0,0 +1,158 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_ChangeAuth(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE parentHandle;
+ TCPA_PROTOCOL_ID protocolID;
+ TCPA_ENCAUTH newAuth;
+ TCPA_ENTITY_TYPE entityType;
+ UINT32 encDataSize;
+ BYTE *encData;
+
+ TPM_AUTH ownerAuth;
+ TPM_AUTH entityAuth;
+
+ UINT32 outDataSize;
+ BYTE *outData;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &parentHandle, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT16, 2, &protocolID, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_ENCAUTH, 3, &newAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT16, 4, &entityType, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 5, &encDataSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ encData = calloc(1, encDataSize);
+ if (encData == NULL) {
+ LogError("malloc of %d bytes failed.", encDataSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 6, encData, encDataSize, &data->comm)) {
+ free(encData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_AUTH, 7, &ownerAuth, 0, &data->comm)) {
+ free(encData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_AUTH, 8, &entityAuth, 0, &data->comm)) {
+ free(encData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_ChangeAuth_Internal(hContext, parentHandle, protocolID, newAuth, entityType,
+ encDataSize, encData, &ownerAuth, &entityAuth,
+ &outDataSize, &outData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(encData);
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 4);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_AUTH, 1, &entityAuth, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, 2, &outDataSize, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 3, outData, outDataSize, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(outData);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_ChangeAuthOwner(struct tcsd_thread_data *data)
+{
+
+ TCS_CONTEXT_HANDLE hContext;
+ TCPA_PROTOCOL_ID protocolID;
+ TCPA_ENCAUTH newAuth;
+ TCPA_ENTITY_TYPE entityType;
+
+ TPM_AUTH ownerAuth;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT16, 1, &protocolID, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_ENCAUTH, 2, &newAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT16, 3, &entityType, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_AUTH, 4, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_ChangeAuthOwner_Internal(hContext, protocolID, newAuth, entityType,
+ &ownerAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_cmk.c b/src/tcs/rpc/tcstp/rpc_cmk.c
new file mode 100644
index 0000000..3d00c13
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_cmk.c
@@ -0,0 +1,617 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2007
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_CMK_SetRestrictions(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_CMK_DELEGATE restriction;
+ TPM_AUTH ownerAuth;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &restriction, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 2, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_CMK_SetRestrictions_Internal(hContext, restriction, &ownerAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_CMK_ApproveMA(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TPM_DIGEST migAuthorityDigest;
+ TPM_AUTH ownerAuth;
+ TPM_HMAC migAuthorityApproval;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_DIGEST, 1, &migAuthorityDigest, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 2, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_CMK_ApproveMA_Internal(hContext, migAuthorityDigest, &ownerAuth,
+ &migAuthorityApproval);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (setData(TCSD_PACKET_TYPE_DIGEST, 1, &migAuthorityApproval, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_CMK_CreateKey(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hKey;
+ TPM_ENCAUTH keyUsageAuth;
+ TPM_HMAC migAuthorityApproval;
+ TPM_DIGEST migAuthorityDigest;
+ UINT32 keyDataSize;
+ BYTE *keyData;
+ TPM_AUTH parentAuth, nullAuth, *pAuth;
+ TSS_RESULT result;
+
+ memset(&parentAuth, 0, sizeof(TPM_AUTH));
+ memset(&nullAuth, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_ENCAUTH, 2, &keyUsageAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_DIGEST, 3, &migAuthorityApproval, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_DIGEST, 4, &migAuthorityDigest, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 5, &keyDataSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ keyData = malloc(keyDataSize);
+ if (keyData == NULL) {
+ LogError("malloc of %u bytes failed.", keyDataSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 6, keyData, keyDataSize, &data->comm)) {
+ free(keyData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 7, &parentAuth, 0, &data->comm)) {
+ free(keyData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (memcmp(&nullAuth, &parentAuth, sizeof(TPM_AUTH)))
+ pAuth = &parentAuth;
+ else
+ pAuth = NULL;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_CMK_CreateKey_Internal(hContext, hKey, keyUsageAuth, migAuthorityApproval,
+ migAuthorityDigest, &keyDataSize, &keyData, pAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 3);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &keyDataSize, 0, &data->comm)) {
+ free(keyData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 1, keyData, keyDataSize, &data->comm)) {
+ free(keyData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(keyData);
+
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, 2, pAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_CMK_CreateTicket(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT32 publicVerifyKeySize;
+ BYTE *publicVerifyKey;
+ TPM_DIGEST signedData;
+ UINT32 sigValueSize;
+ BYTE *sigValue;
+ TPM_AUTH ownerAuth;
+ TPM_HMAC sigTicket;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &publicVerifyKeySize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ publicVerifyKey = malloc(publicVerifyKeySize);
+ if (publicVerifyKey == NULL) {
+ LogError("malloc of %u bytes failed.", publicVerifyKeySize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 2, publicVerifyKey, publicVerifyKeySize, &data->comm)) {
+ free(publicVerifyKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_DIGEST, 3, &signedData, 0, &data->comm)) {
+ free(publicVerifyKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 4, &sigValueSize, 0, &data->comm)) {
+ free(publicVerifyKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ sigValue = malloc(sigValueSize);
+ if (sigValue == NULL) {
+ LogError("malloc of %u bytes failed.", sigValueSize);
+ free(publicVerifyKey);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 5, sigValue, sigValueSize, &data->comm)) {
+ free(publicVerifyKey);
+ free(sigValue);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 6, &ownerAuth, 0, &data->comm)) {
+ free(publicVerifyKey);
+ free(sigValue);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_CMK_CreateTicket_Internal(hContext, publicVerifyKeySize, publicVerifyKey,
+ signedData, sigValueSize, sigValue, &ownerAuth, &sigTicket);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(publicVerifyKey);
+ free(sigValue);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (setData(TCSD_PACKET_TYPE_DIGEST, 1, &sigTicket, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_CMK_CreateBlob(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hKey;
+ UINT16 migrationType;
+ UINT32 migKeyAuthSize;
+ BYTE *migKeyAuth;
+ TPM_DIGEST pubSourceKeyDigest;
+ UINT32 msaListSize, restrictTicketSize, sigTicketSize, encDataSize;
+ BYTE *msaList, *restrictTicket, *sigTicket, *encData;
+ TPM_AUTH parentAuth, nullAuth, *pAuth;
+ UINT32 randomSize, outDataSize;
+ BYTE *random, *outData;
+ TSS_RESULT result;
+ int i;
+
+ memset(&parentAuth, 0, sizeof(TPM_AUTH));
+ memset(&nullAuth, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT16, 2, &migrationType, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &migKeyAuthSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ migKeyAuth = malloc(migKeyAuthSize);
+ if (migKeyAuth == NULL) {
+ LogError("malloc of %u bytes failed.", migKeyAuthSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 4, migKeyAuth, migKeyAuthSize, &data->comm)) {
+ free(migKeyAuth);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_DIGEST, 5, &pubSourceKeyDigest, 0, &data->comm)) {
+ free(migKeyAuth);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 6, &msaListSize, 0, &data->comm)) {
+ free(migKeyAuth);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ msaList = malloc(msaListSize);
+ if (msaList == NULL) {
+ LogError("malloc of %u bytes failed.", msaListSize);
+ free(migKeyAuth);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 7, msaList, msaListSize, &data->comm)) {
+ free(migKeyAuth);
+ free(msaList);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 8, &restrictTicketSize, 0, &data->comm)) {
+ free(migKeyAuth);
+ free(msaList);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ restrictTicket = malloc(restrictTicketSize);
+ if (restrictTicket == NULL) {
+ LogError("malloc of %u bytes failed.", restrictTicketSize);
+ free(migKeyAuth);
+ free(msaList);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 9, restrictTicket, restrictTicketSize, &data->comm)) {
+ free(migKeyAuth);
+ free(msaList);
+ free(restrictTicket);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 10, &sigTicketSize, 0, &data->comm)) {
+ free(migKeyAuth);
+ free(msaList);
+ free(restrictTicket);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ sigTicket = malloc(sigTicketSize);
+ if (sigTicket == NULL) {
+ LogError("malloc of %u bytes failed.", sigTicketSize);
+ free(migKeyAuth);
+ free(msaList);
+ free(restrictTicket);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 11, sigTicket, sigTicketSize, &data->comm)) {
+ free(migKeyAuth);
+ free(msaList);
+ free(restrictTicket);
+ free(sigTicket);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 12, &encDataSize, 0, &data->comm)) {
+ free(migKeyAuth);
+ free(msaList);
+ free(restrictTicket);
+ free(sigTicket);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ encData = malloc(encDataSize);
+ if (encData == NULL) {
+ LogError("malloc of %u bytes failed.", encDataSize);
+ free(migKeyAuth);
+ free(msaList);
+ free(restrictTicket);
+ free(sigTicket);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 13, encData, encDataSize, &data->comm)) {
+ free(migKeyAuth);
+ free(msaList);
+ free(restrictTicket);
+ free(sigTicket);
+ free(encData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 14, &parentAuth, 0, &data->comm)) {
+ free(migKeyAuth);
+ free(msaList);
+ free(restrictTicket);
+ free(sigTicket);
+ free(encData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (memcmp(&nullAuth, &parentAuth, sizeof(TPM_AUTH)))
+ pAuth = &parentAuth;
+ else
+ pAuth = NULL;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_CMK_CreateBlob_Internal(hContext, hKey, migrationType, migKeyAuthSize,
+ migKeyAuth, pubSourceKeyDigest, msaListSize, msaList, restrictTicketSize,
+ restrictTicket, sigTicketSize, sigTicket, encDataSize, encData, pAuth,
+ &randomSize, &random, &outDataSize, &outData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(migKeyAuth);
+ free(msaList);
+ free(restrictTicket);
+ free(sigTicket);
+ free(encData);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 5);
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth, 0, &data->comm)) {
+ free(random);
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &randomSize, 0, &data->comm)) {
+ free(random);
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, random, randomSize, &data->comm)) {
+ free(random);
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(random);
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &outDataSize, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, outData, outDataSize, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(outData);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_CMK_ConvertMigration(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hKey;
+ TPM_CMK_AUTH restrictTicket;
+ TPM_HMAC sigTicket;
+ UINT32 keyDataSize, msaListSize, randomSize;
+ BYTE *keyData, *msaList, *random;
+ TPM_AUTH parentAuth, nullAuth, *pAuth;
+ UINT32 outDataSize;
+ BYTE *outData;
+ TSS_RESULT result;
+ int i;
+
+ memset(&parentAuth, 0, sizeof(TPM_AUTH));
+ memset(&nullAuth, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 2, &restrictTicket, sizeof(restrictTicket), &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_DIGEST, 3, &sigTicket, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 4, &keyDataSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ keyData = malloc(keyDataSize);
+ if (keyData == NULL) {
+ LogError("malloc of %u bytes failed.", keyDataSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 5, keyData, keyDataSize, &data->comm)) {
+ free(keyData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 6, &msaListSize, 0, &data->comm)) {
+ free(keyData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ msaList = malloc(msaListSize);
+ if (msaList == NULL) {
+ LogError("malloc of %u bytes failed.", msaListSize);
+ free(keyData);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 7, msaList, msaListSize, &data->comm)) {
+ free(keyData);
+ free(msaList);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 8, &randomSize, 0, &data->comm)) {
+ free(keyData);
+ free(msaList);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ random = malloc(randomSize);
+ if (random == NULL) {
+ LogError("malloc of %u bytes failed.", randomSize);
+ free(keyData);
+ free(msaList);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 9, random, randomSize, &data->comm)) {
+ free(keyData);
+ free(msaList);
+ free(random);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 10, &parentAuth, 0, &data->comm)) {
+ free(keyData);
+ free(msaList);
+ free(random);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (memcmp(&nullAuth, &parentAuth, sizeof(TPM_AUTH)))
+ pAuth = &parentAuth;
+ else
+ pAuth = NULL;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_CMK_ConvertMigration_Internal(hContext, hKey, restrictTicket, sigTicket,
+ keyDataSize, keyData, msaListSize, msaList, randomSize, random,
+ pAuth, &outDataSize, &outData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(keyData);
+ free(msaList);
+ free(random);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 3);
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &outDataSize, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, outData, outDataSize, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(outData);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
diff --git a/src/tcs/rpc/tcstp/rpc_context.c b/src/tcs/rpc/tcstp/rpc_context.c
new file mode 100644
index 0000000..b04449e
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_context.c
@@ -0,0 +1,81 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_OpenContext(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ UINT32 tpm_version = tpm_metrics.version.minor;
+
+ LogDebugFn("thread %ld", THREAD_ID);
+
+ result = TCS_OpenContext_Internal(&hContext);
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &tpm_version, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ /* Set the context in the thread's object. Later, if something goes wrong
+ * and the connection can't be closed cleanly, we'll still have a reference
+ * to what resources need to be freed. */
+ data->context = hContext;
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_CloseContext(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ result = TCS_CloseContext_Internal(hContext);
+
+ /* This will signal the thread that the connection has been closed cleanly */
+ if (result == TSS_SUCCESS)
+ data->context = NULL_TCS_HANDLE;
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_counter.c b/src/tcs/rpc/tcstp/rpc_counter.c
new file mode 100644
index 0000000..6bb654e
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_counter.c
@@ -0,0 +1,231 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2007
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_ReadCounter(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_COUNTER_ID idCounter;
+ TPM_COUNTER_VALUE counterValue;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &idCounter, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_ReadCounter_Internal(hContext, idCounter, &counterValue);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_COUNTER_VALUE, 0, &counterValue, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_CreateCounter(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_COUNTER_ID idCounter;
+ TPM_COUNTER_VALUE counterValue;
+ TPM_AUTH auth;
+ TPM_ENCAUTH encauth;
+ UINT32 LabelSize;
+ BYTE *pLabel = NULL;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &LabelSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if ((pLabel = calloc(1, LabelSize)) == NULL) {
+ LogError("malloc of %u bytes failed.", LabelSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 2, &pLabel, LabelSize, &data->comm)) {
+ free(pLabel);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_ENCAUTH, 3, &encauth, 0, &data->comm)) {
+ free(pLabel);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_AUTH, 4, &auth, 0, &data->comm)) {
+ free(pLabel);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_CreateCounter_Internal(hContext, LabelSize, pLabel, encauth, &auth,
+ &idCounter, &counterValue);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(pLabel);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 3);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &auth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &idCounter, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (setData(TCSD_PACKET_TYPE_COUNTER_VALUE, 2, &counterValue, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_IncrementCounter(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_COUNTER_ID idCounter;
+ TPM_COUNTER_VALUE counterValue;
+ TPM_AUTH auth;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &idCounter, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_AUTH, 2, &auth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_IncrementCounter_Internal(hContext, idCounter, &auth, &counterValue);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &auth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (setData(TCSD_PACKET_TYPE_COUNTER_VALUE, 1, &counterValue, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_ReleaseCounter(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_COUNTER_ID idCounter;
+ TPM_AUTH auth;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &idCounter, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_AUTH, 2, &auth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_ReleaseCounter_Internal(hContext, idCounter, &auth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &auth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_ReleaseCounterOwner(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_COUNTER_ID idCounter;
+ TPM_AUTH auth;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &idCounter, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_AUTH, 2, &auth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_ReleaseCounterOwner_Internal(hContext, idCounter, &auth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &auth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_daa.c b/src/tcs/rpc/tcstp/rpc_daa.c
new file mode 100644
index 0000000..6b9c1c6
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_daa.c
@@ -0,0 +1,238 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_DaaJoin(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TPM_HANDLE hDAA;
+ BYTE stage;
+ UINT32 inputSize0, inputSize1, outputSize, i;
+ BYTE *inputData0 = NULL, *inputData1 = NULL,*outputData;
+ TSS_RESULT result;
+ TPM_AUTH ownerAuth, *pOwnerAuth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hDAA, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ LogDebugFn("thread %ld hDAA %x", THREAD_ID, hDAA);
+
+ if (getData(TCSD_PACKET_TYPE_BYTE, 2, &stage, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ LogDebug("getData 2 (stage=%d)", (int)stage);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &inputSize0, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ LogDebug("getData 3 inputSize0=%d", inputSize0);
+
+ inputData0 = calloc(1, inputSize0);
+ if (inputData0 == NULL) {
+ LogError("malloc of %d bytes failed.", inputSize0);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ LogDebug("getData 4 inputData0");
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 4, inputData0, inputSize0, &data->comm)) {
+ free(inputData0);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ LogDebug("getData 5");
+ if (getData(TCSD_PACKET_TYPE_UINT32, 5, &inputSize1, 0, &data->comm)) {
+ free( inputData0);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ LogDebug("getData 5 inputSize1=%d", inputSize1);
+
+ if( inputSize1 > 0) {
+ inputData1 = calloc(1, inputSize1);
+ if (inputData1 == NULL) {
+ LogError("malloc of %d bytes failed.", inputSize1);
+ free( inputData0);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ LogDebug("getData 6 inputData1");
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 6, inputData1, inputSize1, &data->comm)) {
+ free(inputData0);
+ free(inputData1);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ LogDebug("getData 7");
+ if (getData(TCSD_PACKET_TYPE_AUTH, 7, &ownerAuth, 0, &data->comm)) {
+ pOwnerAuth = NULL;
+ } else {
+ pOwnerAuth = &ownerAuth;
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_DaaJoin_internal(hContext, hDAA, stage, inputSize0, inputData0, inputSize1,
+ inputData1, pOwnerAuth, &outputSize, &outputData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(inputData0);
+ if( inputData1 != NULL) free(inputData1);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 3);
+ if ( pOwnerAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pOwnerAuth, 0, &data->comm)) {
+ free(outputData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &outputSize, 0, &data->comm)) {
+ free(outputData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, outputData, outputSize, &data->comm)) {
+ free(outputData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(outputData);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_DaaSign(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TPM_HANDLE hDAA;
+ BYTE stage;
+ UINT32 inputSize0, inputSize1, outputSize, i;
+ BYTE *inputData0 = NULL, *inputData1 = NULL,*outputData;
+ TSS_RESULT result;
+ TPM_AUTH ownerAuth, *pOwnerAuth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hDAA, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ LogDebugFn("thread %ld hDAA %x", THREAD_ID, hDAA);
+
+ if (getData(TCSD_PACKET_TYPE_BYTE, 2, &stage, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ LogDebugFn("getData 2 (stage=%d)", (int)stage);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &inputSize0, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ LogDebug("getData 3 inputSize0=%d", inputSize0);
+
+ inputData0 = calloc(1, inputSize0);
+ if (inputData0 == NULL) {
+ LogError("malloc of %d bytes failed.", inputSize0);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ LogDebug("getData 4 inputData0");
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 4, inputData0, inputSize0, &data->comm)) {
+ free(inputData0);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ LogDebug("getData 5");
+ if (getData(TCSD_PACKET_TYPE_UINT32, 5, &inputSize1, 0, &data->comm)) {
+ free( inputData0);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ LogDebug("getData 5 inputSize1=%d", inputSize1);
+
+ if( inputSize1 > 0) {
+ inputData1 = calloc(1, inputSize1);
+ if (inputData1 == NULL) {
+ LogError("malloc of %d bytes failed.", inputSize1);
+ free( inputData0);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ LogDebug("getData 6 inputData1");
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 6, inputData1, inputSize1, &data->comm)) {
+ free(inputData0);
+ free(inputData1);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ LogDebug("getData 7");
+ if (getData(TCSD_PACKET_TYPE_AUTH, 7, &ownerAuth, 0, &data->comm)) {
+ pOwnerAuth = NULL;
+ } else {
+ pOwnerAuth = &ownerAuth;
+ }
+
+ LogDebugFn("-> TCSP_DaaSign_internal");
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_DaaSign_internal(hContext, hDAA, stage, inputSize0, inputData0, inputSize1,
+ inputData1, pOwnerAuth, &outputSize, &outputData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ LogDebugFn("<- TCSP_DaaSign_internal");
+
+ free(inputData0);
+ if( inputData1 != NULL) free(inputData1);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 3);
+ if ( pOwnerAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pOwnerAuth, 0, &data->comm)) {
+ free(outputData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &outputSize, 0, &data->comm)) {
+ free(outputData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, outputData, outputSize, &data->comm)) {
+ free(outputData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(outputData);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_delegate.c b/src/tcs/rpc/tcstp/rpc_delegate.c
new file mode 100644
index 0000000..5bd0cd8
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_delegate.c
@@ -0,0 +1,590 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2007
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_Delegate_Manage(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TPM_FAMILY_ID familyId;
+ TPM_FAMILY_OPERATION opFlag;
+ UINT32 opDataSize;
+ BYTE *opData;
+ TPM_AUTH ownerAuth, nullAuth, *pAuth;
+ UINT32 retDataSize;
+ BYTE *retData;
+ TSS_RESULT result;
+ int i;
+
+ memset(&ownerAuth, 0, sizeof(TPM_AUTH));
+ memset(&nullAuth, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &familyId, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &opFlag, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &opDataSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ opData = malloc(opDataSize);
+ if (opData == NULL) {
+ LogError("malloc of %u bytes failed.", opDataSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 4, opData, opDataSize, &data->comm)) {
+ free(opData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 5, &ownerAuth, 0, &data->comm)) {
+ free(opData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (memcmp(&nullAuth, &ownerAuth, sizeof(TPM_AUTH)))
+ pAuth = &ownerAuth;
+ else
+ pAuth = NULL;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_Delegate_Manage_Internal(hContext, familyId, opFlag,
+ opDataSize, opData, pAuth, &retDataSize, &retData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(opData);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 3);
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth, 0, &data->comm)) {
+ free(retData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &retDataSize, 0, &data->comm)) {
+ free(retData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, retData, retDataSize, &data->comm)) {
+ free(retData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(retData);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_Delegate_CreateKeyDelegation(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hKey;
+ UINT32 publicInfoSize;
+ BYTE *publicInfo;
+ TPM_ENCAUTH encDelAuth;
+ TPM_AUTH keyAuth, nullAuth, *pAuth;
+ UINT32 blobSize;
+ BYTE *blob;
+ TSS_RESULT result;
+ int i;
+
+ memset(&keyAuth, 0, sizeof(TPM_AUTH));
+ memset(&nullAuth, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &publicInfoSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ publicInfo = malloc(publicInfoSize);
+ if (publicInfo == NULL) {
+ LogError("malloc of %u bytes failed.", publicInfoSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, publicInfo, publicInfoSize, &data->comm)) {
+ free(publicInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_ENCAUTH, 4, &encDelAuth, 0, &data->comm)) {
+ free(publicInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 5, &keyAuth, 0, &data->comm)) {
+ free(publicInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (memcmp(&nullAuth, &keyAuth, sizeof(TPM_AUTH)))
+ pAuth = &keyAuth;
+ else
+ pAuth = NULL;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_Delegate_CreateKeyDelegation_Internal(hContext, hKey,
+ publicInfoSize, publicInfo, &encDelAuth, pAuth, &blobSize, &blob);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(publicInfo);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 3);
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth, 0, &data->comm)) {
+ free(blob);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &blobSize, 0, &data->comm)) {
+ free(blob);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, blob, blobSize, &data->comm)) {
+ free(blob);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(blob);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_Delegate_CreateOwnerDelegation(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_BOOL increment;
+ UINT32 publicInfoSize;
+ BYTE *publicInfo;
+ TPM_ENCAUTH encDelAuth;
+ TPM_AUTH ownerAuth, nullAuth, *pAuth;
+ UINT32 blobSize;
+ BYTE *blob;
+ TSS_RESULT result;
+ int i;
+
+ memset(&ownerAuth, 0, sizeof(TPM_AUTH));
+ memset(&nullAuth, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_BOOL, 1, &increment, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &publicInfoSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ publicInfo = malloc(publicInfoSize);
+ if (publicInfo == NULL) {
+ LogError("malloc of %u bytes failed.", publicInfoSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, publicInfo, publicInfoSize, &data->comm)) {
+ free(publicInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_ENCAUTH, 4, &encDelAuth, 0, &data->comm)) {
+ free(publicInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 5, &ownerAuth, 0, &data->comm)) {
+ free(publicInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (memcmp(&nullAuth, &ownerAuth, sizeof(TPM_AUTH)))
+ pAuth = &ownerAuth;
+ else
+ pAuth = NULL;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_Delegate_CreateOwnerDelegation_Internal(hContext, increment,
+ publicInfoSize, publicInfo, &encDelAuth, pAuth, &blobSize, &blob);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(publicInfo);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 3);
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth, 0, &data->comm)) {
+ free(blob);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &blobSize, 0, &data->comm)) {
+ free(blob);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, blob, blobSize, &data->comm)) {
+ free(blob);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(blob);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_Delegate_LoadOwnerDelegation(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TPM_DELEGATE_INDEX index;
+ UINT32 blobSize;
+ BYTE *blob;
+ TPM_AUTH ownerAuth, nullAuth, *pAuth;
+ TSS_RESULT result;
+
+ memset(&ownerAuth, 0, sizeof(TPM_AUTH));
+ memset(&nullAuth, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &index, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &blobSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ blob = malloc(blobSize);
+ if (blob == NULL) {
+ LogError("malloc of %u bytes failed.", blobSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, blob, blobSize, &data->comm)) {
+ free(blob);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 4, &ownerAuth, 0, &data->comm)) {
+ free(blob);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (memcmp(&nullAuth, &ownerAuth, sizeof(TPM_AUTH)))
+ pAuth = &ownerAuth;
+ else
+ pAuth = NULL;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_Delegate_LoadOwnerDelegation_Internal(hContext, index, blobSize, blob,
+ pAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(blob);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, pAuth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_Delegate_ReadTable(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT32 familyTableSize;
+ BYTE *familyTable;
+ UINT32 delegateTableSize;
+ BYTE *delegateTable;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_Delegate_ReadTable_Internal(hContext, &familyTableSize, &familyTable,
+ &delegateTableSize, &delegateTable);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 4);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &familyTableSize, 0, &data->comm)) {
+ free(familyTable);
+ free(delegateTable);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 1, familyTable, familyTableSize, &data->comm)) {
+ free(familyTable);
+ free(delegateTable);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(familyTable);
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, 2, &delegateTableSize, 0, &data->comm)) {
+ free(delegateTable);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 3, delegateTable, delegateTableSize, &data->comm)) {
+ free(delegateTable);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(delegateTable);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_Delegate_UpdateVerificationCount(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT32 inputSize;
+ BYTE *input;
+ TPM_AUTH ownerAuth, nullAuth, *pAuth;
+ UINT32 outputSize;
+ BYTE *output;
+ TSS_RESULT result;
+ int i;
+
+ memset(&ownerAuth, 0, sizeof(TPM_AUTH));
+ memset(&nullAuth, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &inputSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ input = malloc(inputSize);
+ if (input == NULL) {
+ LogError("malloc of %u bytes failed.", inputSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 2, input, inputSize, &data->comm)) {
+ free(input);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 3, &ownerAuth, 0, &data->comm)) {
+ free(input);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (memcmp(&nullAuth, &ownerAuth, sizeof(TPM_AUTH)))
+ pAuth = &ownerAuth;
+ else
+ pAuth = NULL;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_Delegate_UpdateVerificationCount_Internal(hContext, inputSize, input,
+ pAuth, &outputSize, &output);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(input);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 3);
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth, 0, &data->comm)) {
+ free(output);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &outputSize, 0, &data->comm)) {
+ free(output);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, output, outputSize, &data->comm)) {
+ free(output);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(output);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_Delegate_VerifyDelegation(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT32 delegateSize;
+ BYTE *delegate;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &delegateSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ delegate = malloc(delegateSize);
+ if (delegate == NULL) {
+ LogError("malloc of %u bytes failed.", delegateSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 2, delegate, delegateSize, &data->comm)) {
+ free(delegate);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_Delegate_VerifyDelegation_Internal(hContext, delegateSize, delegate);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(delegate);
+
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_DSAP(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT16 entityType;
+ TCS_KEY_HANDLE keyHandle;
+ TPM_NONCE nonceOddDSAP, nonceEven, nonceEvenDSAP;
+ UINT32 entityValueSize;
+ BYTE *entityValue;
+ TCS_AUTHHANDLE authHandle;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT16, 1, &entityType, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &keyHandle, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_NONCE, 3, &nonceOddDSAP, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 4, &entityValueSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ entityValue = malloc(entityValueSize);
+ if (entityValue == NULL) {
+ LogError("malloc of %u bytes failed.", entityValueSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 5, entityValue, entityValueSize, &data->comm)) {
+ free(entityValue);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_DSAP_Internal(hContext, entityType, keyHandle, &nonceOddDSAP, entityValueSize,
+ entityValue, &authHandle, &nonceEven, &nonceEvenDSAP);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(entityValue);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 3);
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &authHandle, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (setData(TCSD_PACKET_TYPE_NONCE, 1, &nonceEven, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (setData(TCSD_PACKET_TYPE_NONCE, 2, &nonceEvenDSAP, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
diff --git a/src/tcs/rpc/tcstp/rpc_dir.c b/src/tcs/rpc/tcstp/rpc_dir.c
new file mode 100644
index 0000000..47baec6
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_dir.c
@@ -0,0 +1,103 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_DirWriteAuth(struct tcsd_thread_data *data)
+{
+ TSS_RESULT result;
+ TSS_HCONTEXT hContext;
+ TCPA_DIRINDEX dirIndex;
+ TCPA_DIGEST dirDigest;
+ TPM_AUTH auth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &dirIndex, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_DIGEST, 2, &dirDigest, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_AUTH, 3, &auth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_DirWriteAuth_Internal(hContext, dirIndex, dirDigest, &auth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &auth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_DirRead(struct tcsd_thread_data *data)
+{
+ TSS_RESULT result;
+ TSS_HCONTEXT hContext;
+ TCPA_DIRINDEX dirIndex;
+ TCPA_DIRVALUE dirValue;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &dirIndex, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_DirRead_Internal(hContext, dirIndex, &dirValue);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_DIGEST, 0, &dirValue, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_ek.c b/src/tcs/rpc/tcstp/rpc_ek.c
new file mode 100644
index 0000000..0b49718
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_ek.c
@@ -0,0 +1,324 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2007
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_CreateEndorsementKeyPair(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCPA_NONCE antiReplay;
+ UINT32 eKPtrSize;
+ BYTE *eKPtr;
+ UINT32 eKSize;
+ BYTE* eK;
+ TCPA_DIGEST checksum;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_NONCE, 1, &antiReplay, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &eKPtrSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ eKPtr = calloc(1, eKPtrSize);
+ if (eKPtr == NULL) {
+ LogError("malloc of %u bytes failed.", eKPtrSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, eKPtr, eKPtrSize, &data->comm)) {
+ free(eKPtr);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_CreateEndorsementKeyPair_Internal(hContext, antiReplay, eKPtrSize, eKPtr,
+ &eKSize, &eK, &checksum);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(eKPtr);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 3);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &eKSize, 0, &data->comm)) {
+ free(eK);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 1, eK, eKSize, &data->comm)) {
+ free(eK);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(eK);
+ if (setData(TCSD_PACKET_TYPE_DIGEST, 2, &checksum, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_ReadPubek(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCPA_NONCE antiReplay;
+ UINT32 pubEKSize;
+ BYTE *pubEK;
+ TCPA_DIGEST checksum;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_NONCE, 1, &antiReplay, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_ReadPubek_Internal(hContext, antiReplay, &pubEKSize, &pubEK, &checksum);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 3);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &pubEKSize, 0, &data->comm)) {
+ free(pubEK);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 1, pubEK, pubEKSize, &data->comm)) {
+ free(pubEK);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(pubEK);
+ if (setData(TCSD_PACKET_TYPE_DIGEST, 2, &checksum, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_OwnerReadPubek(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT32 pubEKSize;
+ BYTE *pubEK;
+ TSS_RESULT result;
+ TPM_AUTH auth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 1, &auth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_OwnerReadPubek_Internal(hContext, &auth, &pubEKSize, &pubEK);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 3);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &auth, 0, &data->comm)) {
+ free(pubEK);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &pubEKSize, 0, &data->comm)) {
+ free(pubEK);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 2, pubEK, pubEKSize, &data->comm)) {
+ free(pubEK);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(pubEK);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_DisablePubekRead(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ TPM_AUTH auth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 1, &auth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_DisablePubekRead_Internal(hContext, &auth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &auth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+#ifdef TSS_BUILD_TSS12
+TSS_RESULT
+tcs_wrap_CreateRevocableEndorsementKeyPair(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TPM_NONCE antiReplay;
+ UINT32 eKPtrSize;
+ BYTE *eKPtr;
+ TSS_BOOL genResetAuth;
+ TPM_DIGEST eKResetAuth;
+ UINT32 eKSize;
+ BYTE* eK;
+ TPM_DIGEST checksum;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_NONCE, 1, &antiReplay, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &eKPtrSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ eKPtr = calloc(1, eKPtrSize);
+ if (eKPtr == NULL) {
+ LogError("malloc of %d bytes failed.", eKPtrSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, eKPtr, eKPtrSize, &data->comm)) {
+ free(eKPtr);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_BOOL, 4, &genResetAuth, 0, &data->comm)) {
+ free(eKPtr);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_DIGEST, 5, &eKResetAuth, 0, &data->comm)) {
+ free(eKPtr);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_CreateRevocableEndorsementKeyPair_Internal(hContext, antiReplay,
+ eKPtrSize, eKPtr, genResetAuth, &eKResetAuth, &eKSize, &eK, &checksum);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(eKPtr);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 4);
+ if (setData(TCSD_PACKET_TYPE_DIGEST, 0, &eKResetAuth, 0, &data->comm)) {
+ free(eK);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &eKSize, 0, &data->comm)) {
+ free(eK);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 2, eK, eKSize, &data->comm)) {
+ free(eK);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(eK);
+ if (setData(TCSD_PACKET_TYPE_DIGEST, 3, &checksum, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_RevokeEndorsementKeyPair(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TPM_DIGEST eKResetAuth;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_DIGEST, 1, &eKResetAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_RevokeEndorsementKeyPair_Internal(hContext, eKResetAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+#endif
diff --git a/src/tcs/rpc/tcstp/rpc_evlog.c b/src/tcs/rpc/tcstp/rpc_evlog.c
new file mode 100644
index 0000000..12c4151
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_evlog.c
@@ -0,0 +1,285 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_GetPcrEvent(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_PCR_EVENT *pEvent = NULL;
+ TSS_RESULT result;
+ UINT32 pcrIndex, number;
+ BYTE lengthOnly;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &pcrIndex, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &number, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_BYTE, 3, &lengthOnly, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (lengthOnly)
+ result = TCS_GetPcrEvent_Internal(hContext, pcrIndex, &number, NULL);
+ else
+ result = TCS_GetPcrEvent_Internal(hContext, pcrIndex, &number, &pEvent);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &number, 0, &data->comm)) {
+ if (lengthOnly == FALSE)
+ free_external_events(1, pEvent);
+ free(pEvent);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (lengthOnly == FALSE) {
+ if (setData(TCSD_PACKET_TYPE_PCR_EVENT, 1, pEvent, 0, &data->comm)) {
+ free_external_events(1, pEvent);
+ free(pEvent);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free_external_events(1, pEvent);
+ free(pEvent);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+
+TSS_RESULT
+tcs_wrap_GetPcrEventsByPcr(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_PCR_EVENT *ppEvents = NULL;
+ TSS_RESULT result;
+ UINT32 firstEvent, eventCount, totalSize, pcrIndex, i, j;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &pcrIndex, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &firstEvent, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &eventCount, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ result = TCS_GetPcrEventsByPcr_Internal(hContext, pcrIndex, firstEvent, &eventCount, &ppEvents);
+
+ if (result == TSS_SUCCESS) {
+ /* XXX totalSize not used */
+ for (i = 0, totalSize = 0; i < eventCount; i++)
+ totalSize += get_pcr_event_size(&(ppEvents[i]));
+
+ initData(&data->comm, eventCount + 1);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &eventCount, 0, &data->comm)) {
+ free_external_events(eventCount, ppEvents);
+ free(ppEvents);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ i = 1;
+ for (j = 0; j < eventCount; j++) {
+ if (setData(TCSD_PACKET_TYPE_PCR_EVENT, i++, &(ppEvents[j]), 0, &data->comm)) {
+ free_external_events(eventCount, ppEvents);
+ free(ppEvents);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ free_external_events(eventCount, ppEvents);
+ free(ppEvents);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_GetPcrEventLog(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_PCR_EVENT *ppEvents;
+ TSS_RESULT result;
+ UINT32 eventCount, totalSize, i, j;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ result = TCS_GetPcrEventLog_Internal(hContext, &eventCount, &ppEvents);
+
+ if (result == TSS_SUCCESS) {
+ for (i = 0, totalSize = 0; i < eventCount; i++)
+ totalSize += get_pcr_event_size(&(ppEvents[i]));
+
+ initData(&data->comm, eventCount + 1);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &eventCount, 0, &data->comm)) {
+ free_external_events(eventCount, ppEvents);
+ free(ppEvents);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ i = 1;
+ for (j = 0; j < eventCount; j++) {
+ if (setData(TCSD_PACKET_TYPE_PCR_EVENT, i++, &(ppEvents[j]), 0, &data->comm)) {
+ free_external_events(eventCount, ppEvents);
+ free(ppEvents);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ free_external_events(eventCount, ppEvents);
+ free(ppEvents);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_LogPcrEvent(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_PCR_EVENT event;
+ TSS_RESULT result;
+ UINT32 number;
+
+ /* Receive */
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_PCR_EVENT , 1, &event, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ result = TCS_LogPcrEvent_Internal(hContext, event, &number);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &number, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+void
+LoadBlob_PCR_EVENT(UINT64 *offset, BYTE *blob, TSS_PCR_EVENT *event)
+{
+ LoadBlob_VERSION(offset, blob, (TPM_VERSION *)&(event->versionInfo));
+ LoadBlob_UINT32(offset, event->ulPcrIndex, blob);
+ LoadBlob_UINT32(offset, event->eventType, blob);
+
+ LoadBlob_UINT32(offset, event->ulPcrValueLength, blob);
+ if (event->ulPcrValueLength > 0)
+ LoadBlob(offset, event->ulPcrValueLength, blob, event->rgbPcrValue);
+
+ LoadBlob_UINT32(offset, event->ulEventLength, blob);
+ if (event->ulEventLength > 0)
+ LoadBlob(offset, event->ulEventLength, blob, event->rgbEvent);
+
+}
+
+TSS_RESULT
+UnloadBlob_PCR_EVENT(UINT64 *offset, BYTE *blob, TSS_PCR_EVENT *event)
+{
+ if (!event) {
+ UINT32 ulPcrValueLength, ulEventLength;
+
+ UnloadBlob_VERSION(offset, blob, NULL);
+ UnloadBlob_UINT32(offset, NULL, blob);
+ UnloadBlob_UINT32(offset, NULL, blob);
+
+ UnloadBlob_UINT32(offset, &ulPcrValueLength, blob);
+ (*offset) += ulPcrValueLength;
+
+ UnloadBlob_UINT32(offset, &ulEventLength, blob);
+ (*offset) += ulEventLength;
+
+ return TSS_SUCCESS;
+ }
+
+ UnloadBlob_VERSION(offset, blob, (TPM_VERSION *)&(event->versionInfo));
+ UnloadBlob_UINT32(offset, &event->ulPcrIndex, blob);
+ UnloadBlob_UINT32(offset, &event->eventType, blob);
+
+ UnloadBlob_UINT32(offset, &event->ulPcrValueLength, blob);
+ if (event->ulPcrValueLength > 0) {
+ event->rgbPcrValue = malloc(event->ulPcrValueLength);
+ if (event->rgbPcrValue == NULL) {
+ LogError("malloc of %u bytes failed.", event->ulPcrValueLength);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ UnloadBlob(offset, event->ulPcrValueLength, blob, event->rgbPcrValue);
+ } else {
+ event->rgbPcrValue = NULL;
+ }
+
+ UnloadBlob_UINT32(offset, &event->ulEventLength, blob);
+ if (event->ulEventLength > 0) {
+ event->rgbEvent = malloc(event->ulEventLength);
+ if (event->rgbEvent == NULL) {
+ LogError("malloc of %u bytes failed.", event->ulEventLength);
+ free(event->rgbPcrValue);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ UnloadBlob(offset, event->ulEventLength, blob, event->rgbEvent);
+ } else {
+ event->rgbEvent = NULL;
+ }
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_key.c b/src/tcs/rpc/tcstp/rpc_key.c
new file mode 100644
index 0000000..d3a5153
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_key.c
@@ -0,0 +1,476 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_EvictKey(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hKey;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = key_mgr_evict(hContext, hKey);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_GetPubkey(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hKey;
+ TPM_AUTH auth;
+ TPM_AUTH *pAuth;
+ UINT32 pubKeySize;
+ BYTE *pubKey;
+ TSS_RESULT result;
+ int i;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ result = getData(TCSD_PACKET_TYPE_AUTH, 2, &auth, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
+ pAuth = NULL;
+ else if (result)
+ return result;
+ else
+ pAuth = &auth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_GetPubKey_Internal(hContext, hKey, pAuth, &pubKeySize, &pubKey);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 3);
+ if (pAuth != NULL)
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth, 0, &data->comm)) {
+ free(pubKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &pubKeySize, 0, &data->comm)) {
+ free(pubKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, pubKey, pubKeySize, &data->comm)) {
+ free(pubKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(pubKey);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_TerminateHandle(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_AUTHHANDLE authHandle;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &authHandle, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_TerminateHandle_Internal(hContext, authHandle);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_LoadKeyByBlob(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hUnwrappingKey;
+ UINT32 cWrappedKeyBlob;
+ BYTE *rgbWrappedKeyBlob;
+
+ TPM_AUTH auth;
+
+ TCS_KEY_HANDLE phKeyTCSI;
+ TCS_KEY_HANDLE phKeyHMAC;
+
+ TPM_AUTH *pAuth;
+ TSS_RESULT result;
+ int i;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hUnwrappingKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &cWrappedKeyBlob, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ rgbWrappedKeyBlob = calloc(1, cWrappedKeyBlob);
+ if (rgbWrappedKeyBlob == NULL) {
+ LogError("malloc of %d bytes failed.", cWrappedKeyBlob);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, rgbWrappedKeyBlob, cWrappedKeyBlob, &data->comm)) {
+ free(rgbWrappedKeyBlob);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ result = getData(TCSD_PACKET_TYPE_AUTH, 4, &auth, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
+ pAuth = NULL;
+ else if (result) {
+ free(rgbWrappedKeyBlob);
+ return result;
+ } else
+ pAuth = &auth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = key_mgr_load_by_blob(hContext, hUnwrappingKey, cWrappedKeyBlob, rgbWrappedKeyBlob,
+ pAuth, &phKeyTCSI, &phKeyHMAC);
+
+ if (!result)
+ result = ctx_mark_key_loaded(hContext, phKeyTCSI);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(rgbWrappedKeyBlob);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 3);
+ if (pAuth != NULL) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &phKeyTCSI, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &phKeyHMAC, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+#ifdef TSS_BUILD_TSS12
+TSS_RESULT
+tcs_wrap_LoadKey2ByBlob(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hUnwrappingKey;
+ UINT32 cWrappedKeyBlob;
+ BYTE *rgbWrappedKeyBlob;
+ TPM_AUTH auth;
+ TCS_KEY_HANDLE phKeyTCSI;
+ TPM_AUTH *pAuth;
+ TSS_RESULT result;
+ int i;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hUnwrappingKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &cWrappedKeyBlob, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ rgbWrappedKeyBlob = calloc(1, cWrappedKeyBlob);
+ if (rgbWrappedKeyBlob == NULL) {
+ LogError("malloc of %d bytes failed.", cWrappedKeyBlob);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, rgbWrappedKeyBlob, cWrappedKeyBlob, &data->comm)) {
+ free(rgbWrappedKeyBlob);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ result = getData(TCSD_PACKET_TYPE_AUTH, 4, &auth, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
+ pAuth = NULL;
+ else if (result) {
+ free(rgbWrappedKeyBlob);
+ return result;
+ } else
+ pAuth = &auth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = key_mgr_load_by_blob(hContext, hUnwrappingKey, cWrappedKeyBlob, rgbWrappedKeyBlob,
+ pAuth, &phKeyTCSI, NULL);
+
+ if (!result)
+ result = ctx_mark_key_loaded(hContext, phKeyTCSI);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(rgbWrappedKeyBlob);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 2);
+ if (pAuth != NULL) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &phKeyTCSI, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+#endif
+
+TSS_RESULT
+tcs_wrap_CreateWrapKey(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hWrappingKey;
+ TCPA_ENCAUTH KeyUsageAuth;
+ TCPA_ENCAUTH KeyMigrationAuth;
+ UINT32 keyInfoSize;
+ BYTE *keyInfo;
+
+ TPM_AUTH *pAuth, auth;
+
+ UINT32 keyDataSize;
+ BYTE *keyData;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hWrappingKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_ENCAUTH, 2, &KeyUsageAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_ENCAUTH, 3, &KeyMigrationAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 4, &keyInfoSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ keyInfo = calloc(1, keyInfoSize);
+ if (keyInfo == NULL) {
+ LogError("malloc of %d bytes failed.", keyInfoSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 5, keyInfo, keyInfoSize, &data->comm)) {
+ free(keyInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_AUTH, 6, &auth, 0, &data->comm))
+ pAuth = NULL;
+ else
+ pAuth = &auth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_CreateWrapKey_Internal(hContext, hWrappingKey, KeyUsageAuth, KeyMigrationAuth,
+ keyInfoSize, keyInfo, &keyDataSize, &keyData, pAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(keyInfo);
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 3);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &keyDataSize, 0, &data->comm)) {
+ free(keyData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 1, keyData, keyDataSize, &data->comm)) {
+ free(keyData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(keyData);
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, 2, pAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+#ifdef TSS_BUILD_TSS12
+TSS_RESULT
+tcs_wrap_OwnerReadInternalPub(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hKey;
+ TPM_AUTH ownerAuth;
+ UINT32 pubKeySize;
+ BYTE *pubKeyData;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_AUTH, 2, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_OwnerReadInternalPub_Internal(hContext, hKey, &ownerAuth, &pubKeySize, &pubKeyData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 3);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &pubKeySize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 2, pubKeyData, pubKeySize, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_KeyControlOwner(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hKey;
+ UINT32 ulPublicKeyLength;
+ BYTE* rgbPublicKey;
+ UINT32 attribName;
+ TSS_BOOL attribValue;
+ TPM_AUTH ownerAuth;
+ TSS_UUID uuidData;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &ulPublicKeyLength, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ rgbPublicKey = (BYTE *) malloc(ulPublicKeyLength);
+ if (rgbPublicKey == NULL) {
+ LogError("malloc of %u bytes failed.", ulPublicKeyLength);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, rgbPublicKey, ulPublicKeyLength, &data->comm)) {
+ free(rgbPublicKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_UINT32, 4, &attribName, 0, &data->comm)) {
+ free(rgbPublicKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_BOOL, 5, &attribValue, 0, &data->comm)) {
+ free(rgbPublicKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_AUTH, 6, &ownerAuth, 0, &data->comm)) {
+ free(rgbPublicKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_KeyControlOwner_Internal(hContext, hKey, ulPublicKeyLength, rgbPublicKey,
+ attribName, attribValue, &ownerAuth, &uuidData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (setData(TCSD_PACKET_TYPE_UUID, 1, &uuidData, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+
+}
+#endif
diff --git a/src/tcs/rpc/tcstp/rpc_maint.c b/src/tcs/rpc/tcstp/rpc_maint.c
new file mode 100644
index 0000000..f51a4f2
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_maint.c
@@ -0,0 +1,283 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_KillMaintenanceFeature(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ TPM_AUTH ownerAuth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 1, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_KillMaintenanceFeature_Internal(hContext, &ownerAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_CreateMaintenanceArchive(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ TPM_AUTH ownerAuth;
+ TSS_BOOL generateRandom;
+ UINT32 randomSize, archiveSize;
+ BYTE *random, *archive;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_BOOL, 1, &generateRandom, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 2, &ownerAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_CreateMaintenanceArchive_Internal(hContext, generateRandom, &ownerAuth,
+ &randomSize, &random, &archiveSize,
+ &archive);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 5);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm)) {
+ free(random);
+ free(archive);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &randomSize, 0, &data->comm)) {
+ free(random);
+ free(archive);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 2, random, randomSize, &data->comm)) {
+ free(random);
+ free(archive);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, 3, &archiveSize, 0, &data->comm)) {
+ free(random);
+ free(archive);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 4, archive, archiveSize, &data->comm)) {
+ free(random);
+ free(archive);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ free(random);
+ free(archive);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_LoadMaintenanceArchive(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ TPM_AUTH ownerAuth;
+ UINT32 dataInSize, dataOutSize;
+ BYTE *dataIn, *dataOut;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &dataInSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ dataIn = (BYTE *)malloc(dataInSize);
+ if (dataIn == NULL) {
+ LogError("malloc of %d bytes failed.", dataInSize);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 2, dataIn, dataInSize, &data->comm)) {
+ free(dataIn);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 3, &ownerAuth, 0, &data->comm)) {
+ free(dataIn);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_LoadMaintenanceArchive_Internal(hContext, dataInSize, dataIn, &ownerAuth,
+ &dataOutSize, &dataOut);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(dataIn);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 3);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm)) {
+ free(dataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &dataOutSize, 0, &data->comm)) {
+ free(dataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 2, dataOut, dataOutSize, &data->comm)) {
+ free(dataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ free(dataOut);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_LoadManuMaintPub(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ UINT32 pubKeySize;
+ BYTE *pubKey;
+ TCPA_NONCE antiReplay;
+ TCPA_DIGEST checksum;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_NONCE, 1, &antiReplay, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &pubKeySize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ pubKey = (BYTE *)malloc(pubKeySize);
+ if (pubKey == NULL) {
+ LogError("malloc of %d bytes failed.", pubKeySize);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, pubKey, pubKeySize, &data->comm)) {
+ free(pubKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_LoadManuMaintPub_Internal(hContext, antiReplay, pubKeySize, pubKey,
+ &checksum);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(pubKey);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_DIGEST, 0, &checksum, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_ReadManuMaintPub(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ TCPA_NONCE antiReplay;
+ TCPA_DIGEST checksum;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_NONCE, 1, &antiReplay, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_ReadManuMaintPub_Internal(hContext, antiReplay, &checksum);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_DIGEST, 0, &checksum, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_migration.c b/src/tcs/rpc/tcstp/rpc_migration.c
new file mode 100644
index 0000000..5233096
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_migration.c
@@ -0,0 +1,321 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_CreateMigrationBlob(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ TCS_KEY_HANDLE parentHandle;
+ TSS_MIGRATE_SCHEME migrationType;
+ UINT32 MigrationKeyAuthSize, encDataSize, randomSize, outDataSize;
+ BYTE *MigrationKeyAuth, *encData, *random, *outData;
+ TPM_AUTH auth1, auth2, *pParentAuth, *pEntityAuth;
+ UINT32 i;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &parentHandle, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT16, 2, &migrationType, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &MigrationKeyAuthSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MigrationKeyAuth = (BYTE *)malloc(MigrationKeyAuthSize);
+ if (MigrationKeyAuth == NULL) {
+ LogError("malloc of %d bytes failed.", MigrationKeyAuthSize);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 4, MigrationKeyAuth, MigrationKeyAuthSize, &data->comm)) {
+ free(MigrationKeyAuth);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 5, &encDataSize, 0, &data->comm)) {
+ free(MigrationKeyAuth);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ encData = (BYTE *)malloc(encDataSize);
+ if (encData == NULL) {
+ free(MigrationKeyAuth);
+ LogError("malloc of %d bytes failed.", encDataSize);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 6, encData, encDataSize, &data->comm)) {
+ free(MigrationKeyAuth);
+ free(encData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 7, &auth1, 0, &data->comm)) {
+ free(MigrationKeyAuth);
+ free(encData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 8, &auth2, 0, &data->comm)) {
+ /* If loading the 2nd auth fails, the first one was entity auth */
+ pParentAuth = NULL;
+ pEntityAuth = &auth1;
+ } else {
+ /* If loading the 2nd auth succeeds, the first one was parent auth */
+ pParentAuth = &auth1;
+ pEntityAuth = &auth2;
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_CreateMigrationBlob_Internal(hContext, parentHandle, migrationType,
+ MigrationKeyAuthSize, MigrationKeyAuth,
+ encDataSize, encData, pParentAuth, pEntityAuth,
+ &randomSize, &random, &outDataSize, &outData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(MigrationKeyAuth);
+ free(encData);
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 6);
+ if (pParentAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pParentAuth, 0, &data->comm)) {
+ free(random);
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pEntityAuth, 0, &data->comm)) {
+ free(random);
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &randomSize, 0, &data->comm)) {
+ free(random);
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (randomSize > 0) {
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, random, randomSize, &data->comm)) {
+ free(random);
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &outDataSize, 0, &data->comm)) {
+ free(random);
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, outData, outDataSize, &data->comm)) {
+ free(random);
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ free(random);
+ free(outData);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_ConvertMigrationBlob(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ TCS_KEY_HANDLE parentHandle;
+ UINT32 outDataSize, randomSize, inDataSize;
+ BYTE *outData, *random, *inData;
+ TPM_AUTH parentAuth, *pParentAuth;
+ UINT32 i;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &parentHandle, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &inDataSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ inData = (BYTE *)malloc(inDataSize);
+ if (inData == NULL) {
+ LogError("malloc of %d bytes failed.", inDataSize);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, inData, inDataSize, &data->comm)) {
+ free(inData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 4, &randomSize, 0, &data->comm)) {
+ free(inData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ random = (BYTE *)malloc(randomSize);
+ if (random == NULL) {
+ free(inData);
+ LogError("malloc of %d bytes failed.", randomSize);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 5, random, randomSize, &data->comm)) {
+ free(inData);
+ free(random);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 6, &parentAuth, 0, &data->comm))
+ pParentAuth = NULL;
+ else
+ pParentAuth = &parentAuth;
+
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_ConvertMigrationBlob_Internal(hContext, parentHandle, inDataSize, inData,
+ randomSize, random, pParentAuth, &outDataSize,
+ &outData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(inData);
+ free(random);
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 3);
+ if (pParentAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pParentAuth, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &outDataSize, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, outData, outDataSize, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ free(outData);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_AuthorizeMigrationKey(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ TSS_MIGRATE_SCHEME migrateScheme;
+ UINT32 MigrationKeySize, MigrationKeyAuthSize;
+ BYTE *MigrationKey, *MigrationKeyAuth;
+ TPM_AUTH ownerAuth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT16, 1, &migrateScheme, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &MigrationKeySize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MigrationKey = (BYTE *)malloc(MigrationKeySize);
+ if (MigrationKey == NULL) {
+ LogError("malloc of %d bytes failed.", MigrationKeySize);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, MigrationKey, MigrationKeySize, &data->comm)) {
+ free(MigrationKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 4, &ownerAuth, 0, &data->comm)) {
+ free(MigrationKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_AuthorizeMigrationKey_Internal(hContext, migrateScheme, MigrationKeySize,
+ MigrationKey, &ownerAuth,
+ &MigrationKeyAuthSize, &MigrationKeyAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(MigrationKey);
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 3);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm)) {
+ free(MigrationKeyAuth);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &MigrationKeyAuthSize, 0, &data->comm)) {
+ free(MigrationKeyAuth);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 2, MigrationKeyAuth, MigrationKeyAuthSize,
+ &data->comm)) {
+ free(MigrationKeyAuth);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ free(MigrationKeyAuth);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_nv.c b/src/tcs/rpc/tcstp/rpc_nv.c
new file mode 100644
index 0000000..71c170d
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_nv.c
@@ -0,0 +1,344 @@
+/*
+ * The Initial Developer of the Original Code is Intel Corporation.
+ * Portions created by Intel Corporation are Copyright (C) 2007 Intel Corporation.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the Common Public License as published by
+ * IBM Corporation; either version 1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program 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
+ * Common Public License for more details.
+ *
+ * You should have received a copy of the Common Public License
+ * along with this program; if not, a copy can be viewed at
+ * http://www.opensource.org/licenses/cpl1.0.php.
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * Author: james.xu@intel.com Rossey.liu@intel.com
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_NV_DefineOrReleaseSpace(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT32 cPubInfoSize;
+ BYTE *pubInfo = NULL;
+ TSS_RESULT result;
+ TPM_ENCAUTH encAuth;
+ TPM_AUTH Auth, *pAuth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &cPubInfoSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ pubInfo = calloc(1, cPubInfoSize);
+ if (pubInfo == NULL) {
+ LogError("malloc of %u bytes failed.", cPubInfoSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 2, pubInfo, cPubInfoSize, &data->comm)) {
+ free(pubInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_ENCAUTH, 3, &encAuth, 0, &data->comm)) {
+ free(pubInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 4, &Auth, 0, &data->comm))
+ pAuth = NULL;
+ else
+ pAuth = &Auth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_NV_DefineOrReleaseSpace_Internal(hContext,
+ cPubInfoSize, pubInfo, encAuth, pAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(pubInfo);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if ( pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, pAuth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_NV_WriteValue(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_NV_INDEX hNVStore;
+ UINT32 offset,ulDataLength;
+ BYTE *rgbDataToWrite = NULL;
+ TSS_RESULT result;
+ TPM_AUTH Auth, *pAuth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hNVStore, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &offset, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &ulDataLength, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ rgbDataToWrite = calloc(1, ulDataLength);
+ if (rgbDataToWrite == NULL) {
+ LogError("malloc of %u bytes failed.", ulDataLength);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 4, rgbDataToWrite, ulDataLength, &data->comm)) {
+ free(rgbDataToWrite);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 5, &Auth, 0, &data->comm))
+ pAuth = NULL;
+ else
+ pAuth = &Auth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_NV_WriteValue_Internal(hContext, hNVStore,
+ offset, ulDataLength, rgbDataToWrite, pAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(rgbDataToWrite);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, pAuth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_NV_WriteValueAuth(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_NV_INDEX hNVStore;
+ UINT32 offset,ulDataLength;
+ BYTE *rgbDataToWrite = NULL;
+ TSS_RESULT result;
+ TPM_AUTH Auth, *pAuth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hNVStore, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &offset, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &ulDataLength, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ rgbDataToWrite = calloc(1, ulDataLength);
+ if (rgbDataToWrite == NULL) {
+ LogError("malloc of %u bytes failed.", ulDataLength);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 4, rgbDataToWrite, ulDataLength, &data->comm)) {
+ free(rgbDataToWrite);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_AUTH, 5, &Auth, 0, &data->comm))
+ pAuth = NULL;
+ else
+ pAuth = &Auth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_NV_WriteValueAuth_Internal(hContext, hNVStore,
+ offset, ulDataLength, rgbDataToWrite, pAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(rgbDataToWrite);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if ( pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, pAuth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_NV_ReadValue(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_NV_INDEX hNVStore;
+ UINT32 offset,ulDataLength, i;
+ BYTE *rgbDataRead = NULL;
+ TSS_RESULT result;
+ TPM_AUTH Auth, *pAuth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hNVStore, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &offset, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &ulDataLength, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 4, &Auth, 0, &data->comm))
+ pAuth = NULL;
+ else
+ pAuth = &Auth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_NV_ReadValue_Internal(hContext, hNVStore,
+ offset, &ulDataLength, pAuth, &rgbDataRead);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 3);
+ if ( pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth, 0, &data->comm)) {
+ free(rgbDataRead);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &ulDataLength, 0, &data->comm)) {
+ free(rgbDataRead);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, rgbDataRead, ulDataLength, &data->comm)) {
+ free(rgbDataRead);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(rgbDataRead);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_NV_ReadValueAuth(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_NV_INDEX hNVStore;
+ UINT32 offset,ulDataLength, i;
+ BYTE *rgbDataRead = NULL;
+ TSS_RESULT result;
+ TPM_AUTH NVAuth, *pNVAuth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hNVStore, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &offset, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &ulDataLength, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 4, &NVAuth, 0, &data->comm)) {
+ pNVAuth = NULL;
+ } else {
+ pNVAuth = &NVAuth;
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_NV_ReadValueAuth_Internal(hContext, hNVStore,
+ offset, &ulDataLength, pNVAuth, &rgbDataRead);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 3);
+ if ( pNVAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pNVAuth, 0, &data->comm)) {
+ free(rgbDataRead);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &ulDataLength, 0, &data->comm)) {
+ free(rgbDataRead);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, rgbDataRead, ulDataLength, &data->comm)) {
+ free(rgbDataRead);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(rgbDataRead);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
diff --git a/src/tcs/rpc/tcstp/rpc_oper.c b/src/tcs/rpc/tcstp/rpc_oper.c
new file mode 100644
index 0000000..8e097be
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_oper.c
@@ -0,0 +1,57 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2007
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_SetOperatorAuth(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCPA_SECRET operatorAuth;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_SECRET, 1, &operatorAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_SetOperatorAuth_Internal(hContext, &operatorAuth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
diff --git a/src/tcs/rpc/tcstp/rpc_own.c b/src/tcs/rpc/tcstp/rpc_own.c
new file mode 100644
index 0000000..beb2a8c
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_own.c
@@ -0,0 +1,170 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_TakeOwnership(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT16 protocolID;
+ UINT32 encOwnerAuthSize;
+ BYTE *encOwnerAuth;
+ UINT32 encSrkAuthSize;
+ BYTE *encSrkAuth;
+ UINT32 srkInfoSize;
+ BYTE *srkInfo;
+ TPM_AUTH ownerAuth;
+
+ UINT32 srkKeySize;
+ BYTE *srkKey;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT16, 1, &protocolID, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &encOwnerAuthSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ encOwnerAuth = calloc(1, encOwnerAuthSize);
+ if (encOwnerAuth == NULL) {
+ LogError("malloc of %d bytes failed.", encOwnerAuthSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, encOwnerAuth, encOwnerAuthSize, &data->comm)) {
+ free(encOwnerAuth);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_UINT32, 4, &encSrkAuthSize, 0, &data->comm)) {
+ free(encOwnerAuth);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ encSrkAuth = calloc(1, encSrkAuthSize);
+ if (encSrkAuth == NULL) {
+ LogError("malloc of %d bytes failed.", encSrkAuthSize);
+ free(encOwnerAuth);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 5, encSrkAuth, encSrkAuthSize, &data->comm)) {
+ free(encOwnerAuth);
+ free(encSrkAuth);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_UINT32, 6, &srkInfoSize, 0, &data->comm)) {
+ free(encOwnerAuth);
+ free(encSrkAuth);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ srkInfo = calloc(1, srkInfoSize);
+ if (srkInfo == NULL) {
+ LogError("malloc of %d bytes failed.", srkInfoSize);
+ free(encOwnerAuth);
+ free(encSrkAuth);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 7, srkInfo, srkInfoSize, &data->comm)) {
+ free(encOwnerAuth);
+ free(encSrkAuth);
+ free(srkInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_AUTH, 8, &ownerAuth, 0, &data->comm)) {
+ free(encOwnerAuth);
+ free(encSrkAuth);
+ free(srkInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_TakeOwnership_Internal(hContext, protocolID, encOwnerAuthSize, encOwnerAuth,
+ encSrkAuthSize, encSrkAuth, srkInfoSize, srkInfo,
+ &ownerAuth, &srkKeySize, &srkKey);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(encOwnerAuth);
+ free(encSrkAuth);
+ free(srkInfo);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 3);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm)) {
+ free(srkKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &srkKeySize, 0, &data->comm)) {
+ free(srkKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 2, srkKey, srkKeySize, &data->comm)) {
+ free(srkKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(srkKey);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_OwnerClear(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ TPM_AUTH auth;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 1, &auth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_OwnerClear_Internal(hContext, &auth);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &auth, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_pcr_extend.c b/src/tcs/rpc/tcstp/rpc_pcr_extend.c
new file mode 100644
index 0000000..e9fd9cd
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_pcr_extend.c
@@ -0,0 +1,139 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_Extend(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT32 pcrIndex;
+ TCPA_DIGEST inDigest;
+ TSS_RESULT result;
+ TCPA_DIGEST outDigest;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &pcrIndex, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_DIGEST, 2, &inDigest, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_Extend_Internal(hContext, pcrIndex, inDigest, &outDigest);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_DIGEST, 0, &outDigest, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_PcrRead(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT32 pcrIndex;
+ TCPA_DIGEST digest;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &pcrIndex, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_PcrRead_Internal(hContext, pcrIndex, &digest);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_DIGEST, 0, &digest, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_PcrReset(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT32 pcrDataSizeIn;
+ BYTE *pcrDataIn;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &pcrDataSizeIn, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ pcrDataIn = (BYTE *)malloc(pcrDataSizeIn);
+ if (pcrDataIn == NULL) {
+ LogError("malloc of %u bytes failed.", pcrDataSizeIn);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 2, pcrDataIn, pcrDataSizeIn, &data->comm)) {
+ free(pcrDataIn);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_PcrReset_Internal(hContext, pcrDataSizeIn, pcrDataIn);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(pcrDataIn);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return result;
+}
+
diff --git a/src/tcs/rpc/tcstp/rpc_ps.c b/src/tcs/rpc/tcstp/rpc_ps.c
new file mode 100644
index 0000000..3f6e5a7
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_ps.c
@@ -0,0 +1,510 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_RegisterKey(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_UUID WrappingKeyUUID;
+ TSS_UUID KeyUUID;
+ UINT32 cKeySize;
+ BYTE *rgbKey;
+ UINT32 cVendorData;
+ BYTE *gbVendorData;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UUID, 1, &WrappingKeyUUID, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UUID, 2, &KeyUUID, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &cKeySize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ rgbKey = calloc(1, cKeySize);
+ if (rgbKey == NULL) {
+ LogError("malloc of %d bytes failed.", cKeySize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 4, rgbKey, cKeySize, &data->comm)) {
+ free(rgbKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_UINT32, 5, &cVendorData, 0, &data->comm)) {
+ free(rgbKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (cVendorData == 0)
+ gbVendorData = NULL;
+ else {
+ gbVendorData = calloc(1, cVendorData);
+ if (gbVendorData == NULL) {
+ LogError("malloc of %d bytes failed.", cVendorData);
+ free(rgbKey);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 6, gbVendorData, cVendorData, &data->comm)) {
+ free(rgbKey);
+ free(gbVendorData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ result = TCS_RegisterKey_Internal(hContext, &WrappingKeyUUID, &KeyUUID,
+ cKeySize, rgbKey, cVendorData,
+ gbVendorData);
+ free(rgbKey);
+ free(gbVendorData);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_UnregisterKey(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_UUID uuid;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UUID, 1, &uuid, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ result = TCS_UnregisterKey_Internal(hContext, uuid);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_GetRegisteredKeyBlob(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_UUID uuid;
+ UINT32 pcKeySize;
+ BYTE *prgbKey;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UUID, 1, &uuid, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ result = TCS_GetRegisteredKeyBlob_Internal(hContext, &uuid, &pcKeySize,
+ &prgbKey);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &pcKeySize, 0, &data->comm)) {
+ free(prgbKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 1, prgbKey, pcKeySize, &data->comm)) {
+ free(prgbKey);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(prgbKey);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_LoadKeyByUUID(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_UUID uuid;
+ TCS_LOADKEY_INFO info, *pInfo;
+ TCS_KEY_HANDLE phKeyTCSI;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UUID, 1, &uuid, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ result = getData(TCSD_PACKET_TYPE_LOADKEY_INFO, 2, &info, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
+ pInfo = NULL;
+ else if (result)
+ return result;
+ else
+ pInfo = &info;
+
+ result = key_mgr_load_by_uuid(hContext, &uuid, pInfo, &phKeyTCSI);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &phKeyTCSI, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (pInfo != NULL) {
+ if (setData(TCSD_PACKET_TYPE_LOADKEY_INFO, 1, pInfo, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ } else {
+ if (result == TCSERR(TCS_E_KM_LOADFAILED) && pInfo != NULL) {
+ initData(&data->comm, 1);
+ if (setData(TCSD_PACKET_TYPE_LOADKEY_INFO, 0, pInfo, 0, &data->comm)) {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ }
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_EnumRegisteredKeys(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_UUID uuid, *pUuid;
+ UINT32 cKeyHierarchySize;
+ TSS_KM_KEYINFO *pKeyHierarchy;
+ unsigned int i, j;
+ TSS_RESULT result;
+
+ /* Receive */
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ result = getData(TCSD_PACKET_TYPE_UUID , 1, &uuid, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
+ pUuid = NULL;
+ else if (result)
+ return result;
+ else
+ pUuid = &uuid;
+
+ result = TCS_EnumRegisteredKeys_Internal(
+ hContext,
+ pUuid,
+ &cKeyHierarchySize,
+ &pKeyHierarchy);
+
+ if (result == TSS_SUCCESS) {
+ i=0;
+ initData(&data->comm, cKeyHierarchySize + 1);
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &cKeyHierarchySize, 0, &data->comm)) {
+ free(pKeyHierarchy);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ for (j = 0; j < cKeyHierarchySize; j++) {
+ if (setData(TCSD_PACKET_TYPE_KM_KEYINFO, i++, &pKeyHierarchy[j], 0, &data->comm)) {
+ free(pKeyHierarchy);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ free(pKeyHierarchy);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_EnumRegisteredKeys2(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_UUID uuid, *pUuid;
+ UINT32 cKeyHierarchySize;
+ TSS_KM_KEYINFO2 *pKeyHierarchy;
+ unsigned int i, j;
+ TSS_RESULT result;
+
+ /* Receive */
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ result = getData(TCSD_PACKET_TYPE_UUID , 1, &uuid, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
+ pUuid = NULL;
+ else if (result)
+ return result;
+ else
+ pUuid = &uuid;
+
+ result = TCS_EnumRegisteredKeys_Internal2(
+ hContext,
+ pUuid,
+ &cKeyHierarchySize,
+ &pKeyHierarchy);
+
+ if (result == TSS_SUCCESS) {
+ i=0;
+ initData(&data->comm, cKeyHierarchySize + 1);
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &cKeyHierarchySize, 0, &data->comm)) {
+ free(pKeyHierarchy);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ for (j = 0; j < cKeyHierarchySize; j++) {
+ if (setData(TCSD_PACKET_TYPE_KM_KEYINFO2, i++, &pKeyHierarchy[j], 0, &data->comm)) {
+ free(pKeyHierarchy);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ free(pKeyHierarchy);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_GetRegisteredKeyByPublicInfo(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ UINT32 algId, ulPublicInfoLength, keySize;
+ BYTE *rgbPublicInfo, *keyBlob;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &algId, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &ulPublicInfoLength, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ rgbPublicInfo = (BYTE *)calloc(1, ulPublicInfoLength);
+ if (rgbPublicInfo == NULL) {
+ LogError("malloc of %d bytes failed.", ulPublicInfoLength);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, rgbPublicInfo, ulPublicInfoLength, &data->comm)) {
+ free(rgbPublicInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ result = TCSP_GetRegisteredKeyByPublicInfo_Internal(hContext, algId,
+ ulPublicInfoLength, rgbPublicInfo, &keySize, &keyBlob);
+
+ free(rgbPublicInfo);
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &keySize, 0, &data->comm)) {
+ free(keyBlob);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 1, keyBlob, keySize, &data->comm)) {
+ free(keyBlob);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(keyBlob);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+void
+LoadBlob_LOADKEY_INFO(UINT64 *offset, BYTE *blob, TCS_LOADKEY_INFO *info)
+{
+ LoadBlob_UUID(offset, blob, info->keyUUID);
+ LoadBlob_UUID(offset, blob, info->parentKeyUUID);
+ LoadBlob(offset, TCPA_DIGEST_SIZE, blob, info->paramDigest.digest);
+ LoadBlob_UINT32(offset, info->authData.AuthHandle, blob);
+ LoadBlob(offset, TCPA_NONCE_SIZE, blob, info->authData.NonceOdd.nonce);
+ LoadBlob(offset, TCPA_NONCE_SIZE, blob, info->authData.NonceEven.nonce);
+ LoadBlob_BOOL(offset, info->authData.fContinueAuthSession, blob);
+ LoadBlob(offset, TCPA_AUTHDATA_SIZE, blob, (BYTE *)&info->authData.HMAC);
+}
+
+void
+UnloadBlob_LOADKEY_INFO(UINT64 *offset, BYTE *blob, TCS_LOADKEY_INFO *info)
+{
+ if (!info) {
+ UnloadBlob_UUID(offset, blob, NULL);
+ UnloadBlob_UUID(offset, blob, NULL);
+ UnloadBlob(offset, TCPA_DIGEST_SIZE, blob, NULL);
+ UnloadBlob_UINT32(offset, NULL, blob);
+ UnloadBlob(offset, TCPA_NONCE_SIZE, blob, NULL);
+ UnloadBlob(offset, TCPA_NONCE_SIZE, blob, NULL);
+ UnloadBlob_BOOL(offset, NULL, blob);
+ UnloadBlob(offset, TCPA_DIGEST_SIZE, blob, NULL);
+
+ return;
+ }
+
+ UnloadBlob_UUID(offset, blob, &info->keyUUID);
+ UnloadBlob_UUID(offset, blob, &info->parentKeyUUID);
+ UnloadBlob(offset, TCPA_DIGEST_SIZE, blob, info->paramDigest.digest);
+ UnloadBlob_UINT32(offset, &info->authData.AuthHandle, blob);
+ UnloadBlob(offset, TCPA_NONCE_SIZE, blob, (BYTE *)&info->authData.NonceOdd.nonce);
+ UnloadBlob(offset, TCPA_NONCE_SIZE, blob, (BYTE *)&info->authData.NonceEven.nonce);
+ UnloadBlob_BOOL(offset, &info->authData.fContinueAuthSession, blob);
+ UnloadBlob(offset, TCPA_DIGEST_SIZE, blob, (BYTE *)&info->authData.HMAC);
+}
+
+void
+LoadBlob_UUID(UINT64 *offset, BYTE * blob, TSS_UUID uuid)
+{
+ LoadBlob_UINT32(offset, uuid.ulTimeLow, blob);
+ LoadBlob_UINT16(offset, uuid.usTimeMid, blob);
+ LoadBlob_UINT16(offset, uuid.usTimeHigh, blob);
+ LoadBlob_BYTE(offset, uuid.bClockSeqHigh, blob);
+ LoadBlob_BYTE(offset, uuid.bClockSeqLow, blob);
+ LoadBlob(offset, 6, blob, uuid.rgbNode);
+}
+
+void
+UnloadBlob_UUID(UINT64 *offset, BYTE * blob, TSS_UUID *uuid)
+{
+ if (!uuid) {
+ UnloadBlob_UINT32(offset, NULL, blob);
+ UnloadBlob_UINT16(offset, NULL, blob);
+ UnloadBlob_UINT16(offset, NULL, blob);
+ UnloadBlob_BYTE(offset, NULL, blob);
+ UnloadBlob_BYTE(offset, NULL, blob);
+ UnloadBlob(offset, 6, blob, NULL);
+
+ return;
+ }
+
+ memset(uuid, 0, sizeof(TSS_UUID));
+ UnloadBlob_UINT32(offset, &uuid->ulTimeLow, blob);
+ UnloadBlob_UINT16(offset, &uuid->usTimeMid, blob);
+ UnloadBlob_UINT16(offset, &uuid->usTimeHigh, blob);
+ UnloadBlob_BYTE(offset, &uuid->bClockSeqHigh, blob);
+ UnloadBlob_BYTE(offset, &uuid->bClockSeqLow, blob);
+ UnloadBlob(offset, 6, blob, uuid->rgbNode);
+}
+
+void
+LoadBlob_KM_KEYINFO(UINT64 *offset, BYTE *blob, TSS_KM_KEYINFO *info)
+{
+ LoadBlob_VERSION(offset, blob, (TPM_VERSION *)&(info->versionInfo));
+ LoadBlob_UUID(offset, blob, info->keyUUID);
+ LoadBlob_UUID(offset, blob, info->parentKeyUUID);
+ LoadBlob_BYTE(offset, info->bAuthDataUsage, blob);
+ LoadBlob_BOOL(offset, info->fIsLoaded, blob);
+ LoadBlob_UINT32(offset, info->ulVendorDataLength, blob);
+ LoadBlob(offset, info->ulVendorDataLength, blob, info->rgbVendorData);
+}
+
+void
+LoadBlob_KM_KEYINFO2(UINT64 *offset, BYTE *blob, TSS_KM_KEYINFO2 *info)
+{
+ LoadBlob_VERSION(offset, blob, (TPM_VERSION *)&(info->versionInfo));
+ LoadBlob_UUID(offset, blob, info->keyUUID);
+ LoadBlob_UUID(offset, blob, info->parentKeyUUID);
+ LoadBlob_BYTE(offset, info->bAuthDataUsage, blob);
+ /* Load the infos of the blob regarding the new data type TSS_KM_KEYINFO2 */
+ LoadBlob_UINT32(offset,info->persistentStorageType,blob);
+ LoadBlob_UINT32(offset, info->persistentStorageTypeParent,blob);
+
+ LoadBlob_BOOL(offset, info->fIsLoaded, blob);
+ LoadBlob_UINT32(offset, info->ulVendorDataLength, blob);
+ LoadBlob(offset, info->ulVendorDataLength, blob, info->rgbVendorData);
+}
+
+void
+UnloadBlob_KM_KEYINFO(UINT64 *offset, BYTE *blob, TSS_KM_KEYINFO *info)
+{
+ if (!info) {
+ UINT32 ulVendorDataLength;
+
+ UnloadBlob_VERSION(offset, blob, NULL);
+ UnloadBlob_UUID(offset, blob, NULL);
+ UnloadBlob_UUID(offset, blob, NULL);
+ UnloadBlob_BYTE(offset, blob, NULL);
+ UnloadBlob_BOOL(offset, NULL, blob);
+ UnloadBlob_UINT32(offset, &ulVendorDataLength, blob);
+
+ (*offset) += ulVendorDataLength;
+
+ return;
+ }
+
+ UnloadBlob_VERSION(offset, blob, (TPM_VERSION *)&(info->versionInfo));
+ UnloadBlob_UUID(offset, blob, &info->keyUUID);
+ UnloadBlob_UUID(offset, blob, &info->parentKeyUUID);
+ UnloadBlob_BYTE(offset, blob, &info->bAuthDataUsage);
+ UnloadBlob_BOOL(offset, &info->fIsLoaded, blob);
+ UnloadBlob_UINT32(offset, &info->ulVendorDataLength, blob);
+ UnloadBlob(offset, info->ulVendorDataLength, info->rgbVendorData, blob);
+}
+
+#if 0
+void
+UnloadBlob_KM_KEYINFO2(UINT64 *offset, BYTE *blob, TSS_KM_KEYINFO2 *info)
+{
+ UnloadBlob_VERSION(offset, blob, (TCPA_VERSION *)&(info->versionInfo));
+ UnloadBlob_UUID(offset, blob, &info->keyUUID);
+ UnloadBlob_UUID(offset, blob, &info->parentKeyUUID);
+ UnloadBlob_BYTE(offset, blob, &info->bAuthDataUsage);
+
+ /* Extract the infos of the blob regarding the new data type TSS_KM_KEYINFO2 */
+ UnloadBlob_UINT32(offset, &info->persistentStorageType, blob);
+ UnloadBlob_UINT32(offset, &info->persistentStorageTypeParent, blob);
+
+ UnloadBlob_BOOL(offset, &info->fIsLoaded, blob);
+ UnloadBlob_UINT32(offset, &info->ulVendorDataLength, blob);
+ UnloadBlob(offset, info->ulVendorDataLength, info->rgbVendorData, blob);
+}
+#endif
diff --git a/src/tcs/rpc/tcstp/rpc_quote.c b/src/tcs/rpc/tcstp/rpc_quote.c
new file mode 100644
index 0000000..aeb469c
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_quote.c
@@ -0,0 +1,126 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_Quote(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hKey;
+ TCPA_NONCE antiReplay;
+ UINT32 pcrDataSizeIn;
+ BYTE *pcrDataIn;
+
+ TPM_AUTH privAuth;
+ TPM_AUTH *pPrivAuth;
+
+ UINT32 pcrDataSizeOut;
+ BYTE *pcrDataOut;
+ UINT32 sigSize;
+ BYTE *sig;
+ TSS_RESULT result;
+
+ int i;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_NONCE, 2, &antiReplay, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &pcrDataSizeIn, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ pcrDataIn = (BYTE *)calloc(1, pcrDataSizeIn);
+ if (pcrDataIn == NULL) {
+ LogError("malloc of %d bytes failed.", pcrDataSizeIn);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 4, pcrDataIn, pcrDataSizeIn, &data->comm)) {
+ free(pcrDataIn);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ result = getData(TCSD_PACKET_TYPE_AUTH, 5, &privAuth, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
+ pPrivAuth = NULL;
+ else if (result) {
+ free(pcrDataIn);
+ return result;
+ } else
+ pPrivAuth = &privAuth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_Quote_Internal(hContext, hKey, antiReplay, pcrDataSizeIn, pcrDataIn,
+ pPrivAuth, &pcrDataSizeOut, &pcrDataOut, &sigSize, &sig);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(pcrDataIn);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 5);
+ if (pPrivAuth != NULL) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pPrivAuth, 0, &data->comm)) {
+ free(pcrDataOut);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &pcrDataSizeOut, 0, &data->comm)) {
+ free(pcrDataOut);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, pcrDataOut, pcrDataSizeOut, &data->comm)) {
+ free(pcrDataOut);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &sigSize, 0, &data->comm)) {
+ free(pcrDataOut);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, sig, sigSize, &data->comm)) {
+ free(pcrDataOut);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ free(pcrDataOut);
+ free(sig);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_quote2.c b/src/tcs/rpc/tcstp/rpc_quote2.c
new file mode 100644
index 0000000..2a10ead
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_quote2.c
@@ -0,0 +1,163 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2007
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_Quote2(struct tcsd_thread_data *data)
+{
+ /* Data to be forwarded to the next level */
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hKey;
+ TCPA_NONCE antiReplay;
+ UINT32 pcrDataSizeIn;
+ BYTE *pcrDataIn;
+ TSS_BOOL addVersion;
+ TPM_AUTH privAuth; /* in/out */
+ TPM_AUTH *pPrivAuth;
+
+ UINT32 pcrDataSizeOut;
+ BYTE *pcrDataOut;
+
+ UINT32 versionInfoSize;
+ BYTE * versionInfo;
+
+ UINT32 sigSize;
+ BYTE *sig;
+ TSS_RESULT result;
+
+ int i;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_NONCE, 2, &antiReplay, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &pcrDataSizeIn, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ pcrDataIn = (BYTE *)calloc(1, pcrDataSizeIn);
+ if (pcrDataIn == NULL) {
+ LogError("malloc of %u bytes failed.", pcrDataSizeIn);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 4, pcrDataIn, pcrDataSizeIn, &data->comm)) {
+ free(pcrDataIn);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_BOOL,5,&addVersion, 0, &data->comm)) {
+ free(pcrDataIn);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ result = getData(TCSD_PACKET_TYPE_AUTH, 6, &privAuth, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
+ pPrivAuth = NULL;
+ else if (result) {
+ free(pcrDataIn);
+ return result;
+ } else
+ pPrivAuth = &privAuth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_Quote2_Internal(hContext, hKey, antiReplay, pcrDataSizeIn, pcrDataIn,
+ addVersion,pPrivAuth, &pcrDataSizeOut, &pcrDataOut, &versionInfoSize,
+ &versionInfo,&sigSize, &sig);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(pcrDataIn);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+
+ initData(&data->comm,7); /* Add versionInfoSize and versionInfo */
+ if (pPrivAuth != NULL) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pPrivAuth, 0, &data->comm)) {
+ free(pcrDataOut);
+ /* It's a null pointer when addVersion == FALSE */
+ if (addVersion)
+ free(versionInfo);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &pcrDataSizeOut, 0, &data->comm)) {
+ free(pcrDataOut);
+ if (addVersion)
+ free(versionInfo);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, pcrDataOut, pcrDataSizeOut, &data->comm)) {
+ free(pcrDataOut);
+ if (addVersion)
+ free(versionInfo);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &versionInfoSize, 0, &data->comm)) {
+ free(pcrDataOut);
+ free(versionInfo);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (versionInfoSize > 0){
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, versionInfo, versionInfoSize, &data->comm)) {
+ free(pcrDataOut);
+ free(versionInfo);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &sigSize, 0, &data->comm)) {
+ free(pcrDataOut);
+ if (addVersion)
+ free(versionInfo);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, sig, sigSize, &data->comm)) {
+ free(pcrDataOut);
+ if (addVersion)
+ free(versionInfo);
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ free(pcrDataOut);
+ if (versionInfoSize >0)
+ free(versionInfo);
+ free(sig);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_random.c b/src/tcs/rpc/tcstp/rpc_random.c
new file mode 100644
index 0000000..6fd9606
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_random.c
@@ -0,0 +1,107 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_GetRandom(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT32 bytesRequested;
+ BYTE *randomBytes = NULL;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &bytesRequested, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_GetRandom_Internal(hContext, &bytesRequested, &randomBytes);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &bytesRequested, 0, &data->comm)) {
+ free(randomBytes);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 1, randomBytes, bytesRequested, &data->comm)) {
+ free(randomBytes);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(randomBytes);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_StirRandom(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT32 inDataSize;
+ BYTE *inData;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &inDataSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ inData = calloc(1, inDataSize);
+ if (inData == NULL) {
+ LogError("malloc of %d bytes failed.", inDataSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 2, inData, inDataSize, &data->comm)) {
+ free(inData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_StirRandom_Internal(hContext, inDataSize, inData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(inData);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_seal.c b/src/tcs/rpc/tcstp/rpc_seal.c
new file mode 100644
index 0000000..f0dd359
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_seal.c
@@ -0,0 +1,251 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_common_Seal(UINT32 sealOrdinal,
+ struct tcsd_thread_data *data)
+{
+ TSS_RESULT result;
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE keyHandle;
+ TCPA_ENCAUTH KeyUsageAuth;
+ UINT32 PCRInfoSize, inDataSize;
+ BYTE *PCRInfo = NULL, *inData = NULL;
+ TPM_AUTH emptyAuth, pubAuth, *pAuth;
+ UINT32 outDataSize;
+ BYTE *outData;
+
+ int i = 0;
+
+ memset(&emptyAuth, 0, sizeof(TPM_AUTH));
+ memset(&pubAuth, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, i++, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, i++, &keyHandle, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_ENCAUTH, i++, &KeyUsageAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, i++, &PCRInfoSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (PCRInfoSize > 0) {
+ PCRInfo = calloc(1, PCRInfoSize);
+ if (PCRInfo == NULL) {
+ LogError("malloc of %u bytes failed.", PCRInfoSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_PBYTE, i++, PCRInfo, PCRInfoSize, &data->comm)) {
+ free(PCRInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, i++, &inDataSize, 0, &data->comm)) {
+ free(PCRInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (inDataSize > 0) {
+ inData = calloc(1, inDataSize);
+ if (inData == NULL) {
+ LogError("malloc of %u bytes failed.", inDataSize);
+ free(PCRInfo);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_PBYTE, i++, inData, inDataSize, &data->comm)) {
+ free(inData);
+ free(PCRInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ result = getData(TCSD_PACKET_TYPE_AUTH, i++, &pubAuth, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
+ pAuth = NULL;
+ else if (result) {
+ free(inData);
+ free(PCRInfo);
+ return result;
+ } else
+ pAuth = &pubAuth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_Seal_Internal(sealOrdinal, hContext, keyHandle, KeyUsageAuth, PCRInfoSize,
+ PCRInfo, inDataSize, inData, pAuth, &outDataSize, &outData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(inData);
+ free(PCRInfo);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 3);
+ if (pAuth != NULL) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, pAuth, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &outDataSize, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 2, outData, outDataSize, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(outData);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_Seal(struct tcsd_thread_data *data)
+{
+ return tcs_common_Seal(TPM_ORD_Seal, data);
+}
+
+#ifdef TSS_BUILD_SEALX
+TSS_RESULT
+tcs_wrap_Sealx(struct tcsd_thread_data *data)
+{
+ return tcs_common_Seal(TPM_ORD_Sealx, data);
+}
+#endif
+
+TSS_RESULT
+tcs_wrap_UnSeal(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE parentHandle;
+ UINT32 inDataSize;
+ BYTE *inData;
+
+ TPM_AUTH parentAuth, dataAuth, emptyAuth;
+ TPM_AUTH *pParentAuth, *pDataAuth;
+
+ UINT32 outDataSize;
+ BYTE *outData;
+ TSS_RESULT result;
+
+ memset(&emptyAuth, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &parentHandle, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &inDataSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ inData = calloc(1, inDataSize);
+ if (inData == NULL) {
+ LogError("malloc of %d bytes failed.", inDataSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, inData, inDataSize, &data->comm)) {
+ free(inData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ result = getData(TCSD_PACKET_TYPE_AUTH, 4, &parentAuth, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
+ pParentAuth = NULL;
+ else if (result) {
+ free(inData);
+ return result;
+ } else
+ pParentAuth = &parentAuth;
+
+ result = getData(TCSD_PACKET_TYPE_AUTH, 5, &dataAuth, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE) {
+ pDataAuth = pParentAuth;
+ pParentAuth = NULL;
+ } else if (result) {
+ free(inData);
+ return result;
+ } else
+ pDataAuth = &dataAuth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_Unseal_Internal(hContext, parentHandle, inDataSize, inData, pParentAuth,
+ pDataAuth, &outDataSize, &outData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(inData);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 4);
+ if (pParentAuth != NULL) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, pParentAuth, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else {
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &emptyAuth, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (setData(TCSD_PACKET_TYPE_AUTH, 1, &dataAuth, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, 2, &outDataSize, 0, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 3, outData, outDataSize, &data->comm)) {
+ free(outData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(outData);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_selftest.c b/src/tcs/rpc/tcstp/rpc_selftest.c
new file mode 100644
index 0000000..4cad0c9
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_selftest.c
@@ -0,0 +1,154 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_SelfTestFull(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_SelfTestFull_Internal(hContext);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ initData(&data->comm, 0);
+ data->comm.hdr.u.result = result;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_CertifySelfTest(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ UINT32 sigSize;
+ BYTE *sigData = NULL;
+ TCS_KEY_HANDLE hKey;
+ TCPA_NONCE antiReplay;
+ TPM_AUTH privAuth;
+ TPM_AUTH *pPrivAuth;
+ int i;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_NONCE, 2, &antiReplay, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ result = getData(TCSD_PACKET_TYPE_AUTH, 3, &privAuth, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
+ pPrivAuth = NULL;
+ else if (result)
+ return result;
+ else
+ pPrivAuth = &privAuth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_CertifySelfTest_Internal(hContext, hKey, antiReplay, pPrivAuth, &sigSize,
+ &sigData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ i = 0;
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 3);
+ if (pPrivAuth != NULL) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pPrivAuth, 0, &data->comm)) {
+ free(sigData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &sigSize, 0, &data->comm)) {
+ free(sigData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, sigData, sigSize, &data->comm)) {
+ free(sigData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(sigData);
+ } else
+ initData(&data->comm, 0);
+
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_GetTestResult(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TSS_RESULT result;
+ UINT32 resultDataSize;
+ BYTE *resultData = NULL;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_GetTestResult_Internal(hContext, &resultDataSize, &resultData);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &resultDataSize, 0, &data->comm)) {
+ free(resultData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 1, resultData, resultDataSize, &data->comm)) {
+ free(resultData);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(resultData);
+ } else
+ initData(&data->comm, 0);
+
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_sign.c b/src/tcs/rpc/tcstp/rpc_sign.c
new file mode 100644
index 0000000..2cd2027
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_sign.c
@@ -0,0 +1,106 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_Sign(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hKey;
+ UINT32 areaToSignSize;
+ BYTE *areaToSign;
+
+ TPM_AUTH auth;
+ TPM_AUTH *pAuth;
+
+ UINT32 sigSize;
+ BYTE *sig;
+ TSS_RESULT result;
+
+ int i;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &areaToSignSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ areaToSign = calloc(1, areaToSignSize);
+ if (areaToSign == NULL) {
+ LogError("malloc of %d bytes failed.", areaToSignSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 3, areaToSign, areaToSignSize, &data->comm)) {
+ free(areaToSign);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ result = getData(TCSD_PACKET_TYPE_AUTH, 4, &auth, 0, &data->comm);
+ if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
+ pAuth = NULL;
+ else if (result) {
+ free(areaToSign);
+ return result;
+ } else
+ pAuth = &auth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_Sign_Internal(hContext, hKey, areaToSignSize, areaToSign, pAuth, &sigSize,
+ &sig);
+
+ MUTEX_UNLOCK(tcsp_lock);
+ free(areaToSign);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 3);
+ if (pAuth != NULL) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, &auth, 0, &data->comm)) {
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &sigSize, 0, &data->comm)) {
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, sig, sigSize, &data->comm)) {
+ free(sig);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(sig);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_tick.c b/src/tcs/rpc/tcstp/rpc_tick.c
new file mode 100644
index 0000000..98e53ad
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_tick.c
@@ -0,0 +1,138 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2007
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_ReadCurrentTicks(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ UINT32 pulCurrentTime;
+ BYTE *prgbCurrentTime;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_ReadCurrentTicks_Internal(hContext, &pulCurrentTime, &prgbCurrentTime);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 2);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &pulCurrentTime, 0, &data->comm)) {
+ free(prgbCurrentTime);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 1, prgbCurrentTime, pulCurrentTime,
+ &data->comm)) {
+ free(prgbCurrentTime);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(prgbCurrentTime);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_TickStampBlob(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hKey;
+ TPM_AUTH auth, *pAuth;
+ TPM_NONCE nonce;
+ TPM_DIGEST digest;
+ UINT32 sigSize, tcSize, i;
+ BYTE *sig, *tc;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_NONCE, 2, &nonce, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_DIGEST, 3, &digest, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_AUTH, 4, &auth, 0, &data->comm))
+ pAuth = NULL;
+ else
+ pAuth = &auth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_TickStampBlob_Internal(hContext, hKey, &nonce, &digest, pAuth, &sigSize, &sig,
+ &tcSize, &tc);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 5);
+ i = 0;
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth, 0, &data->comm)) {
+ free(sig);
+ free(tc);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &sigSize, 0, &data->comm)) {
+ free(sig);
+ free(tc);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, sig, sigSize, &data->comm)) {
+ free(sig);
+ free(tc);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &tcSize, 0, &data->comm)) {
+ free(sig);
+ free(tc);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, tc, tcSize, &data->comm)) {
+ free(sig);
+ free(tc);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/rpc/tcstp/rpc_transport.c b/src/tcs/rpc/tcstp/rpc_transport.c
new file mode 100644
index 0000000..1993cb3
--- /dev/null
+++ b/src/tcs/rpc/tcstp/rpc_transport.c
@@ -0,0 +1,397 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2007
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <netdb.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_utils.h"
+#include "rpc_tcstp_tcs.h"
+
+
+TSS_RESULT
+tcs_wrap_EstablishTransport(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hEncKey, hTransSession;
+ UINT32 ulTransControlFlags, ulTransSessionInfoSize, ulSecretSize, ulCurrentTicks, i;
+ BYTE *rgbTransSessionInfo, *rgbSecret, *prgbCurrentTicks;
+ TPM_MODIFIER_INDICATOR pbLocality;
+ TPM_AUTH pEncKeyAuth, *pAuth;
+ TPM_NONCE pTransNonce;
+ TSS_RESULT result;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &ulTransControlFlags, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 2, &hEncKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, 3, &ulTransSessionInfoSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ rgbTransSessionInfo = malloc(ulTransSessionInfoSize);
+ if (rgbTransSessionInfo == NULL) {
+ LogError("malloc of %u bytes failed.", ulTransSessionInfoSize);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 4, rgbTransSessionInfo, ulTransSessionInfoSize,
+ &data->comm)) {
+ free(rgbTransSessionInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 5, &ulSecretSize, 0, &data->comm)) {
+ free(rgbTransSessionInfo);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ rgbSecret = malloc(ulSecretSize);
+ if (rgbSecret == NULL) {
+ free(rgbTransSessionInfo);
+ LogError("malloc of %u bytes failed.", ulSecretSize);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, 6, rgbSecret, ulSecretSize, &data->comm)) {
+ free(rgbTransSessionInfo);
+ free(rgbSecret);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_AUTH, 7, &pEncKeyAuth, 0, &data->comm))
+ pAuth = NULL;
+ else
+ pAuth = &pEncKeyAuth;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_EstablishTransport_Internal(hContext, ulTransControlFlags, hEncKey,
+ ulTransSessionInfoSize, rgbTransSessionInfo,
+ ulSecretSize, rgbSecret, pAuth, &pbLocality,
+ &hTransSession, &ulCurrentTicks,
+ &prgbCurrentTicks, &pTransNonce);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(rgbSecret);
+ free(rgbTransSessionInfo);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 6);
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth, 0, &data->comm)) {
+ free(prgbCurrentTicks);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &pbLocality, 0, &data->comm)) {
+ free(prgbCurrentTicks);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &hTransSession, 0, &data->comm)) {
+ free(prgbCurrentTicks);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &ulCurrentTicks, 0, &data->comm)) {
+ free(prgbCurrentTicks);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, prgbCurrentTicks, ulCurrentTicks,
+ &data->comm)) {
+ free(prgbCurrentTicks);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(prgbCurrentTicks);
+ if (setData(TCSD_PACKET_TYPE_NONCE, i++, &pTransNonce, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_ExecuteTransport(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TPM_COMMAND_CODE unWrappedCommandOrdinal;
+ TCS_HANDLE *rghHandles = NULL, handles[2];
+ UINT32 ulWrappedCmdDataInSize, pulHandleListSize, ulWrappedCmdDataOutSize, i = 0;
+ BYTE *rgbWrappedCmdDataIn, *rgbWrappedCmdDataOut;
+ TPM_MODIFIER_INDICATOR pbLocality;
+ TPM_AUTH pWrappedCmdAuth1, pWrappedCmdAuth2, pTransAuth, *pAuth1, *pAuth2, null_auth;
+ UINT64 punCurrentTicks;
+ TSS_RESULT result, pulWrappedCmdReturnCode;
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, i++, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, i++, &unWrappedCommandOrdinal, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_UINT32, i++, &ulWrappedCmdDataInSize, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ rgbWrappedCmdDataIn = malloc(ulWrappedCmdDataInSize);
+ if (rgbWrappedCmdDataIn == NULL) {
+ LogError("malloc of %u bytes failed", ulWrappedCmdDataInSize);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_PBYTE, i++, rgbWrappedCmdDataIn, ulWrappedCmdDataInSize,
+ &data->comm)) {
+ free(rgbWrappedCmdDataIn);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_UINT32, i++, &pulHandleListSize, 0, &data->comm)) {
+ free(rgbWrappedCmdDataIn);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (pulHandleListSize > 2) {
+ free(rgbWrappedCmdDataIn);
+ return TCSERR(TSS_E_BAD_PARAMETER);
+ }
+
+ if (pulHandleListSize) {
+ if (getData(TCSD_PACKET_TYPE_PBYTE, i++, handles,
+ pulHandleListSize * sizeof(UINT32), &data->comm)) {
+ free(rgbWrappedCmdDataIn);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ rghHandles = handles;
+
+ memset(&null_auth, 0, sizeof(TPM_AUTH));
+ memset(&pWrappedCmdAuth1, 0, sizeof(TPM_AUTH));
+ memset(&pWrappedCmdAuth2, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, i++, &pWrappedCmdAuth1, 0, &data->comm)) {
+ free(rgbWrappedCmdDataIn);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_AUTH, i++, &pWrappedCmdAuth2, 0, &data->comm)) {
+ free(rgbWrappedCmdDataIn);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (getData(TCSD_PACKET_TYPE_AUTH, i++, &pTransAuth, 0, &data->comm)) {
+ free(rgbWrappedCmdDataIn);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (!memcmp(&pWrappedCmdAuth1, &null_auth, sizeof(TPM_AUTH)))
+ pAuth1 = NULL;
+ else
+ pAuth1 = &pWrappedCmdAuth1;
+
+ if (!memcmp(&pWrappedCmdAuth2, &null_auth, sizeof(TPM_AUTH)))
+ pAuth2 = NULL;
+ else
+ pAuth2 = &pWrappedCmdAuth2;
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_ExecuteTransport_Internal(hContext, unWrappedCommandOrdinal,
+ ulWrappedCmdDataInSize, rgbWrappedCmdDataIn,
+ &pulHandleListSize, &rghHandles, pAuth1, pAuth2,
+ &pTransAuth, &punCurrentTicks, &pbLocality,
+ &pulWrappedCmdReturnCode, &ulWrappedCmdDataOutSize,
+ &rgbWrappedCmdDataOut);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ free(rgbWrappedCmdDataIn);
+
+ if (result == TSS_SUCCESS) {
+ i = 0;
+ initData(&data->comm, 10);
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &pulHandleListSize, 0, &data->comm)) {
+ free(rgbWrappedCmdDataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (pulHandleListSize) {
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, rghHandles,
+ pulHandleListSize * sizeof(UINT32), &data->comm)) {
+ free(rgbWrappedCmdDataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (pAuth1) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth1, 0, &data->comm)) {
+ free(rgbWrappedCmdDataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, &null_auth, 0, &data->comm)) {
+ free(rgbWrappedCmdDataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (pAuth2) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, pAuth2, 0, &data->comm)) {
+ free(rgbWrappedCmdDataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else {
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, &null_auth, 0, &data->comm)) {
+ free(rgbWrappedCmdDataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_AUTH, i++, &pTransAuth, 0, &data->comm)) {
+ free(rgbWrappedCmdDataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT64, i++, &punCurrentTicks, 0, &data->comm)) {
+ free(rgbWrappedCmdDataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &pbLocality, 0, &data->comm)) {
+ free(rgbWrappedCmdDataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &pulWrappedCmdReturnCode, 0,
+ &data->comm)) {
+ free(rgbWrappedCmdDataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, i++, &ulWrappedCmdDataOutSize, 0,
+ &data->comm)) {
+ free(rgbWrappedCmdDataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (ulWrappedCmdDataOutSize) {
+ if (setData(TCSD_PACKET_TYPE_PBYTE, i++, rgbWrappedCmdDataOut,
+ ulWrappedCmdDataOutSize, &data->comm)) {
+ free(rgbWrappedCmdDataOut);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ free(rgbWrappedCmdDataOut);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+tcs_wrap_ReleaseTransportSigned(struct tcsd_thread_data *data)
+{
+ TCS_CONTEXT_HANDLE hContext;
+ TCS_KEY_HANDLE hSignatureKey;
+ TPM_NONCE AntiReplayNonce;
+ UINT32 pulCurrentTicks, pulSignatureSize;
+ BYTE *prgbCurrentTicks, *prgbSignature;
+ TPM_MODIFIER_INDICATOR pbLocality;
+ TPM_AUTH pKeyAuth, pTransAuth, *pAuth, null_auth;
+ TSS_RESULT result;
+
+ memset(&null_auth, 0, sizeof(TPM_AUTH));
+ memset(&pKeyAuth, 0, sizeof(TPM_AUTH));
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
+
+ if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hSignatureKey, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_NONCE, 2, &AntiReplayNonce, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ if (getData(TCSD_PACKET_TYPE_AUTH, 3, &pKeyAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (!memcmp(&null_auth, &pKeyAuth, sizeof(TPM_AUTH)))
+ pAuth = NULL;
+ else
+ pAuth = &pKeyAuth;
+
+ if (getData(TCSD_PACKET_TYPE_AUTH, 4, &pTransAuth, 0, &data->comm))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+
+ MUTEX_LOCK(tcsp_lock);
+
+ result = TCSP_ReleaseTransportSigned_Internal(hContext, hSignatureKey, &AntiReplayNonce,
+ pAuth, &pTransAuth, &pbLocality,
+ &pulCurrentTicks, &prgbCurrentTicks,
+ &pulSignatureSize, &prgbSignature);
+
+ MUTEX_UNLOCK(tcsp_lock);
+
+ if (result == TSS_SUCCESS) {
+ initData(&data->comm, 7);
+ if (pAuth) {
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, pAuth, 0, &data->comm)) {
+ free(prgbCurrentTicks);
+ free(prgbSignature);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else {
+ if (setData(TCSD_PACKET_TYPE_AUTH, 0, &null_auth, 0, &data->comm)) {
+ free(prgbCurrentTicks);
+ free(prgbSignature);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ }
+ if (setData(TCSD_PACKET_TYPE_AUTH, 1, &pTransAuth, 0, &data->comm)) {
+ free(prgbCurrentTicks);
+ free(prgbSignature);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, 2, &pbLocality, 0, &data->comm)) {
+ free(prgbCurrentTicks);
+ free(prgbSignature);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_UINT32, 3, &pulCurrentTicks, 0, &data->comm)) {
+ free(prgbCurrentTicks);
+ free(prgbSignature);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 4, prgbCurrentTicks, pulCurrentTicks,
+ &data->comm)) {
+ free(prgbCurrentTicks);
+ free(prgbSignature);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(prgbCurrentTicks);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 5, &pulSignatureSize, 0, &data->comm)) {
+ free(prgbSignature);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 6, prgbSignature, pulSignatureSize,
+ &data->comm)) {
+ free(prgbSignature);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ free(prgbSignature);
+ } else
+ initData(&data->comm, 0);
+
+ data->comm.hdr.u.result = result;
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/tcs_aik.c b/src/tcs/tcs_aik.c
new file mode 100644
index 0000000..1d22506
--- /dev/null
+++ b/src/tcs/tcs_aik.c
@@ -0,0 +1,146 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "tcsps.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcs_aik.h"
+
+void
+LoadBlob_SYMMETRIC_KEY(UINT64 *offset, BYTE *blob, TCPA_SYMMETRIC_KEY *key)
+{
+ LoadBlob_UINT32(offset, key->algId, blob);
+ LoadBlob_UINT16(offset, key->encScheme, blob);
+ LoadBlob_UINT16(offset, key->size, blob);
+
+ if (key->size > 0) {
+ LoadBlob(offset, key->size, blob, key->data);
+ } else {
+ key->data = NULL;
+ }
+}
+
+TSS_RESULT
+UnloadBlob_SYMMETRIC_KEY(UINT64 *offset, BYTE *blob, TCPA_SYMMETRIC_KEY *key)
+{
+ if (!key) {
+ UINT16 size;
+
+ UnloadBlob_UINT32(offset, NULL, blob);
+ UnloadBlob_UINT16(offset, NULL, blob);
+ UnloadBlob_UINT16(offset, &size, blob);
+
+ if (size > 0)
+ UnloadBlob(offset, size, blob, NULL);
+
+ return TSS_SUCCESS;
+ }
+
+ UnloadBlob_UINT32(offset, &key->algId, blob);
+ UnloadBlob_UINT16(offset, &key->encScheme, blob);
+ UnloadBlob_UINT16(offset, &key->size, blob);
+
+ if (key->size > 0) {
+ key->data = (BYTE *)malloc(key->size);
+ if (key->data == NULL) {
+ LogError("malloc of %hu bytes failed.", key->size);
+ key->size = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(offset, key->size, blob, key->data);
+ } else {
+ key->data = NULL;
+ }
+
+ return TSS_SUCCESS;
+}
+
+void
+get_credential(UINT32 type, UINT32 *size, BYTE **cred)
+{
+ int rc, fd;
+ char *path = NULL;
+ void *file = NULL;
+ struct stat stat_buf;
+ size_t file_size;
+
+ switch (type) {
+ case TSS_TCS_CREDENTIAL_PLATFORMCERT:
+ path = tcsd_options.platform_cred;
+ break;
+ case TSS_TCS_CREDENTIAL_TPM_CC:
+ path = tcsd_options.conformance_cred;
+ break;
+ case TSS_TCS_CREDENTIAL_EKCERT:
+ path = tcsd_options.endorsement_cred;
+ break;
+ default:
+ LogDebugFn("Bad credential type");
+ break;
+ }
+
+ if (path == NULL)
+ goto done;
+
+ if ((fd = open(path, O_RDONLY)) < 0) {
+ LogError("open(%s): %s", path, strerror(errno));
+ goto done;
+ }
+
+ if ((rc = fstat(fd, &stat_buf)) == -1) {
+ LogError("Error stating credential: %s: %s", path, strerror(errno));
+ goto done;
+ }
+
+ file_size = (size_t)stat_buf.st_size;
+
+ LogDebugFn("%s, (%zd bytes)", path, file_size);
+
+ file = mmap(0, file_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (file == MAP_FAILED) {
+ LogError("Error reading credential: %s: %s", path, strerror(errno));
+ close(fd);
+ goto done;
+ }
+ close(fd);
+
+ if ((*cred = malloc(file_size)) == NULL) {
+ LogError("malloc of %zd bytes failed.", file_size);
+ munmap(file, file_size);
+ goto done;
+ }
+
+ memcpy(*cred, file, file_size);
+ *size = file_size;
+ munmap(file, file_size);
+
+ return;
+done:
+ *cred = NULL;
+ *size = 0;
+}
diff --git a/src/tcs/tcs_auth_mgr.c b/src/tcs/tcs_auth_mgr.c
new file mode 100644
index 0000000..5d07832
--- /dev/null
+++ b/src/tcs/tcs_auth_mgr.c
@@ -0,0 +1,584 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "auth_mgr.h"
+#include "req_mgr.h"
+
+
+MUTEX_DECLARE_EXTERN(tcsp_lock);
+
+/* Note: The after taking the auth_mgr_lock in any of the functions below, the
+ * mem_cache_lock cannot be taken without risking a deadlock. So, the auth_mgr
+ * functions must be "self-contained" wrt locking */
+
+/* no locking done in init since its called by only a single thread */
+TSS_RESULT
+auth_mgr_init()
+{
+ memset(&auth_mgr, 0, sizeof(struct _auth_mgr));
+
+ auth_mgr.max_auth_sessions = tpm_metrics.num_auths;
+
+ auth_mgr.overflow = calloc(TSS_DEFAULT_OVERFLOW_AUTHS, sizeof(COND_VAR *));
+ if (auth_mgr.overflow == NULL) {
+ LogError("malloc of %zd bytes failed",
+ (TSS_DEFAULT_OVERFLOW_AUTHS * sizeof(COND_VAR *)));
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ auth_mgr.overflow_size = TSS_DEFAULT_OVERFLOW_AUTHS;
+
+ auth_mgr.auth_mapper = calloc(TSS_DEFAULT_AUTH_TABLE_SIZE, sizeof(struct auth_map));
+ if (auth_mgr.auth_mapper == NULL) {
+ LogError("malloc of %zd bytes failed",
+ (TSS_DEFAULT_AUTH_TABLE_SIZE * sizeof(struct auth_map)));
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ auth_mgr.auth_mapper_size = TSS_DEFAULT_AUTH_TABLE_SIZE;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+auth_mgr_final()
+{
+ UINT32 i;
+
+ /* wake up any sleeping threads, so they can be joined */
+ for (i = 0; i < auth_mgr.overflow_size; i++) {
+ if (auth_mgr.overflow[i] != NULL)
+ COND_SIGNAL(auth_mgr.overflow[i]);
+ }
+
+ free(auth_mgr.overflow);
+ free(auth_mgr.auth_mapper);
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+auth_mgr_save_ctx(TCS_CONTEXT_HANDLE hContext)
+{
+ TSS_RESULT result = TSS_SUCCESS;
+ UINT32 i;
+
+ for (i = 0; i < auth_mgr.auth_mapper_size; i++) {
+ if (auth_mgr.auth_mapper[i].full == TRUE &&
+ auth_mgr.auth_mapper[i].swap == NULL &&
+ auth_mgr.auth_mapper[i].tcs_ctx != hContext) {
+ LogDebug("Calling TPM_SaveAuthContext for TCS CTX %x. Swapping out: TCS %x "
+ "TPM %x", hContext, auth_mgr.auth_mapper[i].tcs_ctx,
+ auth_mgr.auth_mapper[i].tpm_handle);
+
+ if ((result = TPM_SaveAuthContext(auth_mgr.auth_mapper[i].tpm_handle,
+ &auth_mgr.auth_mapper[i].swap_size,
+ &auth_mgr.auth_mapper[i].swap))) {
+ LogDebug("TPM_SaveAuthContext failed: 0x%x", result);
+ return result;
+ }
+ break;
+ }
+ }
+
+ return result;
+}
+
+/* if there's a TCS context waiting to get auth, wake it up or swap it in */
+void
+auth_mgr_swap_in()
+{
+ if (auth_mgr.overflow[auth_mgr.of_tail] != NULL) {
+ LogDebug("waking up thread %lddd, auth slot has opened", THREAD_ID);
+ /* wake up the next sleeping thread in order and increment tail */
+ COND_SIGNAL(auth_mgr.overflow[auth_mgr.of_tail]);
+ auth_mgr.overflow[auth_mgr.of_tail] = NULL;
+ auth_mgr.of_tail = (auth_mgr.of_tail + 1) % auth_mgr.overflow_size;
+ } else {
+ /* else nobody needs to be swapped in, so continue */
+ LogDebug("no threads need to be signaled.");
+ }
+}
+
+/* we need to swap out an auth context or add a waiting context to the overflow queue */
+TSS_RESULT
+auth_mgr_swap_out(TCS_CONTEXT_HANDLE hContext)
+{
+ COND_VAR *cond;
+
+ /* If the TPM can do swapping and it succeeds, return, else cond wait below */
+ if (tpm_metrics.authctx_swap && !auth_mgr_save_ctx(hContext))
+ return TSS_SUCCESS;
+
+ if ((cond = ctx_get_cond_var(hContext)) == NULL) {
+ LogError("Auth swap variable not found for TCS context 0x%x", hContext);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ /* Test whether we are the last awake thread. If we are, we can't go to sleep
+ * since then there'd be no worker thread to wake the others up. This situation
+ * can arise when we're on a busy system who's TPM doesn't support auth ctx
+ * swapping.
+ */
+ if (auth_mgr.sleeping_threads == (tcsd_options.num_threads - 1)) {
+ LogError("auth mgr failing: too many threads already waiting");
+ LogTPMERR(TCPA_E_RESOURCES, __FILE__, __LINE__);
+ return TCPA_E_RESOURCES;
+ }
+
+ if (auth_mgr.overflow[auth_mgr.of_head] == NULL) {
+ auth_mgr.overflow[auth_mgr.of_head] = cond;
+ auth_mgr.of_head = (auth_mgr.of_head + 1) % auth_mgr.overflow_size;
+ /* go to sleep */
+ LogDebug("thread %lddd going to sleep until auth slot opens", THREAD_ID);
+ auth_mgr.sleeping_threads++;
+ COND_WAIT(cond, &tcsp_lock);
+ auth_mgr.sleeping_threads--;
+ } else if (auth_mgr.overflow_size + TSS_DEFAULT_OVERFLOW_AUTHS < UINT_MAX) {
+ COND_VAR **tmp = auth_mgr.overflow;
+
+ LogDebugFn("Table of sleeping threads is full (%hu), growing to %hu entries",
+ auth_mgr.sleeping_threads,
+ auth_mgr.overflow_size + TSS_DEFAULT_OVERFLOW_AUTHS);
+
+ auth_mgr.overflow = calloc(auth_mgr.overflow_size + TSS_DEFAULT_OVERFLOW_AUTHS,
+ sizeof(COND_VAR *));
+ if (auth_mgr.overflow == NULL) {
+ LogDebugFn("malloc of %zd bytes failed",
+ (auth_mgr.overflow_size + TSS_DEFAULT_OVERFLOW_AUTHS) *
+ sizeof(COND_VAR *));
+ auth_mgr.overflow = tmp;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ auth_mgr.overflow_size += TSS_DEFAULT_OVERFLOW_AUTHS;
+
+ LogDebugFn("Success.");
+ memcpy(auth_mgr.overflow, tmp, auth_mgr.sleeping_threads * sizeof(COND_VAR *));
+ free(tmp);
+
+ /* XXX This could temporarily wake threads up out of order */
+ auth_mgr.of_head = auth_mgr.sleeping_threads;
+ auth_mgr.of_tail = 0;
+ auth_mgr.overflow[auth_mgr.of_head] = cond;
+ auth_mgr.of_head = (auth_mgr.of_head + 1) % auth_mgr.overflow_size;
+ LogDebug("thread %lddd going to sleep until auth slot opens", THREAD_ID);
+ auth_mgr.sleeping_threads++;
+ COND_WAIT(cond, &tcsp_lock);
+ auth_mgr.sleeping_threads--;
+ } else {
+ LogError("Auth table overflow is full (%u entries), some will fail.",
+ auth_mgr.overflow_size);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ return TSS_SUCCESS;
+}
+
+/* close all auth contexts associated with this TCS_CONTEXT_HANDLE */
+TSS_RESULT
+auth_mgr_close_context(TCS_CONTEXT_HANDLE tcs_handle)
+{
+ UINT32 i;
+ TSS_RESULT result;
+
+ for (i = 0; i < auth_mgr.auth_mapper_size; i++) {
+ if (auth_mgr.auth_mapper[i].full == TRUE &&
+ auth_mgr.auth_mapper[i].tcs_ctx == tcs_handle) {
+ if (auth_mgr.auth_mapper[i].swap) {
+ /* This context is swapped out of the TPM, so we can just free the
+ * blob */
+ free(auth_mgr.auth_mapper[i].swap);
+ auth_mgr.auth_mapper[i].swap = NULL;
+ auth_mgr.auth_mapper[i].swap_size = 0;
+ } else {
+ result = TCSP_FlushSpecific_Common(auth_mgr.auth_mapper[i].tpm_handle,
+ TPM_RT_AUTH);
+
+ /* Ok, probably dealing with a 1.1 TPM */
+ if (result == TPM_E_BAD_ORDINAL)
+ result = internal_TerminateHandle(
+ auth_mgr.auth_mapper[i].tpm_handle);
+
+ if (result == TCPA_E_INVALID_AUTHHANDLE) {
+ LogDebug("Tried to close an invalid auth handle: %x",
+ auth_mgr.auth_mapper[i].tpm_handle);
+ } else if (result != TCPA_SUCCESS) {
+ LogDebug("TPM_TerminateHandle returned %d", result);
+ }
+ }
+ /* clear the slot */
+ auth_mgr.open_auth_sessions--;
+ auth_mgr.auth_mapper[i].full = FALSE;
+ auth_mgr.auth_mapper[i].tpm_handle = 0;
+ auth_mgr.auth_mapper[i].tcs_ctx = 0;
+ LogDebug("released auth for TCS %x TPM %x", tcs_handle,
+ auth_mgr.auth_mapper[i].tpm_handle);
+
+ auth_mgr_swap_in();
+ }
+ }
+
+ return TSS_SUCCESS;
+}
+
+void
+auth_mgr_release_auth(TPM_AUTH *auth0, TPM_AUTH *auth1, TCS_CONTEXT_HANDLE tcs_handle)
+{
+ if (auth0)
+ auth_mgr_release_auth_handle(auth0->AuthHandle, tcs_handle,
+ auth0->fContinueAuthSession);
+
+ if (auth1)
+ auth_mgr_release_auth_handle(auth1->AuthHandle, tcs_handle,
+ auth1->fContinueAuthSession);
+}
+
+/* unload the auth ctx associated with this auth handle */
+TSS_RESULT
+auth_mgr_release_auth_handle(TCS_AUTHHANDLE tpm_auth_handle, TCS_CONTEXT_HANDLE tcs_handle,
+ TSS_BOOL cont)
+{
+ UINT32 i;
+ TSS_RESULT result = TSS_SUCCESS;
+
+ for (i = 0; i < auth_mgr.auth_mapper_size; i++) {
+ if (auth_mgr.auth_mapper[i].full == TRUE &&
+ auth_mgr.auth_mapper[i].tpm_handle == tpm_auth_handle &&
+ auth_mgr.auth_mapper[i].tcs_ctx == tcs_handle) {
+ if (!cont) {
+ /*
+ * This function should not be necessary, but
+ * if the main operation resulted in an error,
+ * the TPM may still hold the auth handle
+ * and it must be freed. Most of the time
+ * this call will result in TPM_E_INVALID_AUTHHANDLE
+ * error which can be ignored.
+ */
+ result = TCSP_FlushSpecific_Common(
+ auth_mgr.auth_mapper[i].tpm_handle,
+ TPM_RT_AUTH);
+
+ /* Ok, probably dealing with a 1.1 TPM */
+ if (result == TPM_E_BAD_ORDINAL)
+ result = internal_TerminateHandle(
+ auth_mgr.auth_mapper[i].tpm_handle);
+
+ if (result == TCPA_E_INVALID_AUTHHANDLE) {
+ LogDebug("Tried to close an invalid auth handle: %x",
+ auth_mgr.auth_mapper[i].tpm_handle);
+ } else if (result != TCPA_SUCCESS) {
+ LogDebug("TPM_TerminateHandle returned %d", result);
+ }
+
+ if (result == TPM_SUCCESS) {
+ LogDebug("released auth for TCS %x TPM %x",
+ auth_mgr.auth_mapper[i].tcs_ctx, tpm_auth_handle);
+ }
+ /*
+ * Mark it as released, the "cont" flag indicates
+ * that it is no longer needed.
+ */
+ auth_mgr.open_auth_sessions--;
+ auth_mgr.auth_mapper[i].full = FALSE;
+ auth_mgr.auth_mapper[i].tpm_handle = 0;
+ auth_mgr.auth_mapper[i].tcs_ctx = 0;
+ auth_mgr_swap_in();
+ }
+ /* If the cont flag is TRUE, we have to keep the handle */
+ }
+ }
+
+ return result;
+}
+
+TSS_RESULT
+auth_mgr_check(TCS_CONTEXT_HANDLE tcsContext, TPM_AUTHHANDLE *tpm_auth_handle)
+{
+ UINT32 i;
+ TSS_RESULT result = TSS_SUCCESS;
+
+ for (i = 0; i < auth_mgr.auth_mapper_size; i++) {
+ if (auth_mgr.auth_mapper[i].full == TRUE &&
+ auth_mgr.auth_mapper[i].tpm_handle == *tpm_auth_handle &&
+ auth_mgr.auth_mapper[i].tcs_ctx == tcsContext) {
+ /* We have a record of this session, now swap it into the TPM if need be. */
+ if (auth_mgr.auth_mapper[i].swap) {
+ LogDebugFn("TPM_LoadAuthContext for TCS %x TPM %x", tcsContext,
+ auth_mgr.auth_mapper[i].tpm_handle);
+
+ result = TPM_LoadAuthContext(auth_mgr.auth_mapper[i].swap_size,
+ auth_mgr.auth_mapper[i].swap,
+ tpm_auth_handle);
+ if (result == TSS_SUCCESS) {
+ free(auth_mgr.auth_mapper[i].swap);
+ auth_mgr.auth_mapper[i].swap = NULL;
+ auth_mgr.auth_mapper[i].swap_size = 0;
+
+ LogDebugFn("TPM_LoadAuthContext succeeded. Old TPM: %x, New"
+ " TPM: %x", auth_mgr.auth_mapper[i].tpm_handle,
+ *tpm_auth_handle);
+
+ auth_mgr.auth_mapper[i].tpm_handle = *tpm_auth_handle;
+ } else if (result == TPM_E_RESOURCES) {
+ if ((result = auth_mgr_swap_out(tcsContext))) {
+ LogDebugFn("TPM_LoadAuthContext failed with TPM_E_R"
+ "ESOURCES and swapping out failed, retur"
+ "ning error");
+ return result;
+ }
+
+ LogDebugFn("Retrying TPM_LoadAuthContext after swap"
+ " out...");
+ result =
+ TPM_LoadAuthContext(auth_mgr.auth_mapper[i].swap_size,
+ auth_mgr.auth_mapper[i].swap,
+ tpm_auth_handle);
+ free(auth_mgr.auth_mapper[i].swap);
+ auth_mgr.auth_mapper[i].swap = NULL;
+ auth_mgr.auth_mapper[i].swap_size = 0;
+ } else {
+ LogDebug("TPM_LoadAuthContext failed: 0x%x.", result);
+ }
+ }
+
+ return result;
+ }
+ }
+
+ LogDebugFn("Can't find auth for TCS handle %x, should be %x", tcsContext, *tpm_auth_handle);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+}
+
+TSS_RESULT
+auth_mgr_add(TCS_CONTEXT_HANDLE tcsContext, TCS_AUTHHANDLE tpm_auth_handle)
+{
+ struct auth_map *tmp = auth_mgr.auth_mapper;
+ UINT32 i;
+
+ for (i = 0; i < auth_mgr.auth_mapper_size; i++) {
+ if (auth_mgr.auth_mapper[i].full == FALSE) {
+ auth_mgr.auth_mapper[i].tpm_handle = tpm_auth_handle;
+ auth_mgr.auth_mapper[i].tcs_ctx = tcsContext;
+ auth_mgr.auth_mapper[i].full = TRUE;
+ auth_mgr.open_auth_sessions++;
+ LogDebug("added auth for TCS %x TPM %x", tcsContext, tpm_auth_handle);
+
+ return TSS_SUCCESS;
+ }
+ }
+
+
+ LogDebugFn("Thread %ld growing the auth table to %u entries", THREAD_ID,
+ auth_mgr.auth_mapper_size + TSS_DEFAULT_AUTH_TABLE_SIZE);
+
+ auth_mgr.auth_mapper = calloc(auth_mgr.auth_mapper_size +
+ TSS_DEFAULT_AUTH_TABLE_SIZE, sizeof(struct auth_map));
+ if (auth_mgr.auth_mapper == NULL) {
+ auth_mgr.auth_mapper = tmp;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ } else {
+ memcpy(auth_mgr.auth_mapper, tmp,
+ auth_mgr.auth_mapper_size * sizeof(struct auth_map));
+ auth_mgr.auth_mapper_size += TSS_DEFAULT_AUTH_TABLE_SIZE;
+ LogDebugFn("Success.");
+ return TSS_SUCCESS;
+ }
+}
+
+/* A thread wants a new OIAP or OSAP session with the TPM. Returning TRUE indicates that we should
+ * allow it to open the session, FALSE to indicate that the request should be queued or have
+ * another thread's session swapped out to make room for it.
+ */
+TSS_BOOL
+auth_mgr_req_new(TCS_CONTEXT_HANDLE hContext)
+{
+ UINT32 i, opened = 0;
+
+ for (i = 0; i < auth_mgr.auth_mapper_size; i++) {
+ if (auth_mgr.auth_mapper[i].full == TRUE &&
+ auth_mgr.auth_mapper[i].tcs_ctx == hContext) {
+ opened++;
+ }
+ }
+
+ /* If this TSP has already opened its max open auth handles, deny another open */
+ if (opened >= MAX(2, (UINT32)auth_mgr.max_auth_sessions/2)) {
+ LogDebug("Max opened auth handles already opened.");
+ return FALSE;
+ }
+
+ /* if we have one opened already and there's a slot available, ok */
+ if (opened && ((auth_mgr.max_auth_sessions - auth_mgr.open_auth_sessions) >= 1))
+ return TRUE;
+
+ /* we don't already have one open and there are at least 2 slots left */
+ if ((auth_mgr.max_auth_sessions - auth_mgr.open_auth_sessions) >= 2)
+ return TRUE;
+
+ LogDebug("Request for new auth handle denied by TCS. (%d opened sessions)", opened);
+
+ return FALSE;
+}
+
+TSS_RESULT
+auth_mgr_oiap(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_AUTHHANDLE *authHandle, /* out */
+ TCPA_NONCE *nonce0) /* out */
+{
+ TSS_RESULT result;
+
+ /* are the maximum number of auth sessions open? */
+ if (auth_mgr_req_new(hContext) == FALSE) {
+ if ((result = auth_mgr_swap_out(hContext)))
+ goto done;
+ }
+
+ if ((result = TCSP_OIAP_Internal(hContext, authHandle, nonce0)))
+ goto done;
+
+ /* success, add an entry to the table */
+ result = auth_mgr_add(hContext, *authHandle);
+done:
+ return result;
+}
+
+TSS_RESULT
+auth_mgr_osap(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_ENTITY_TYPE entityType, /* in */
+ UINT32 entityValue, /* in */
+ TCPA_NONCE nonceOddOSAP, /* in */
+ TCS_AUTHHANDLE *authHandle, /* out */
+ TCPA_NONCE *nonceEven, /* out */
+ TCPA_NONCE *nonceEvenOSAP) /* out */
+{
+ TSS_RESULT result;
+ UINT32 newEntValue = 0;
+
+ /* if ET is not KEYHANDLE or KEY, newEntValue is a don't care */
+ if (entityType == TCPA_ET_KEYHANDLE || entityType == TCPA_ET_KEY) {
+ if (ensureKeyIsLoaded(hContext, entityValue, &newEntValue))
+ return TCSERR(TSS_E_FAIL);
+ } else {
+ newEntValue = entityValue;
+ }
+
+ /* are the maximum number of auth sessions open? */
+ if (auth_mgr_req_new(hContext) == FALSE) {
+ if ((result = auth_mgr_swap_out(hContext)))
+ goto done;
+ }
+
+ if ((result = TCSP_OSAP_Internal(hContext, entityType, newEntValue, nonceOddOSAP,
+ authHandle, nonceEven, nonceEvenOSAP)))
+ goto done;
+
+ /* success, add an entry to the table */
+ result = auth_mgr_add(hContext, *authHandle);
+done:
+ return result;
+}
+
+/* This function is only called directly from the TSP, we use other internal routines to free
+ * our handles. */
+TSS_RESULT
+TCSP_TerminateHandle_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_AUTHHANDLE handle) /* in */
+{
+ TSS_RESULT result;
+
+ LogDebug("Entering TCSI_TerminateHandle");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = auth_mgr_check(hContext, &handle)))
+ return result;
+
+ result = auth_mgr_release_auth_handle(handle, hContext, TRUE);
+
+ LogResult("Terminate Handle", result);
+ return result;
+}
+
+TSS_RESULT
+TPM_SaveAuthContext(TPM_AUTHHANDLE handle, UINT32 *size, BYTE **blob)
+{
+ UINT64 offset;
+ UINT32 trash, bsize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ offset = 10;
+ LoadBlob_UINT32(&offset, handle, txBlob);
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, offset, TPM_ORD_SaveAuthContext, txBlob);
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &trash);
+
+ LogDebug("total packet size received from TPM: %u", trash);
+
+ if (!result) {
+ offset = 10;
+ UnloadBlob_UINT32(&offset, &bsize, txBlob);
+
+ LogDebug("Reported blob size from TPM: %u", bsize);
+
+ *blob = malloc(bsize);
+ if (*blob == NULL) {
+ LogError("malloc of %u bytes failed.", bsize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset, bsize, txBlob, *blob);
+ *size = bsize;
+ }
+
+ return result;
+}
+
+TSS_RESULT
+TPM_LoadAuthContext(UINT32 size, BYTE *blob, TPM_AUTHHANDLE *handle)
+{
+ UINT64 offset;
+ UINT32 trash;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Loading %u byte auth blob back into TPM", size);
+
+ offset = 10;
+ LoadBlob_UINT32(&offset, size, txBlob);
+ LoadBlob(&offset, size, txBlob, blob);
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, offset, TPM_ORD_LoadAuthContext, txBlob);
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &trash);
+
+ if (!result) {
+ offset = 10;
+ UnloadBlob_UINT32(&offset, handle, txBlob);
+ }
+
+ return result;
+}
diff --git a/src/tcs/tcs_caps.c b/src/tcs/tcs_caps.c
new file mode 100644
index 0000000..c4cff7c
--- /dev/null
+++ b/src/tcs/tcs_caps.c
@@ -0,0 +1,195 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcsps.h"
+#include "tcslog.h"
+#include "tddl.h"
+#include "req_mgr.h"
+
+
+TSS_RESULT
+get_current_version(TPM_VERSION *version)
+{
+ TCPA_CAPABILITY_AREA capArea = TPM_CAP_VERSION_VAL;
+ UINT32 respSize;
+ BYTE *resp;
+ TSS_RESULT result;
+ UINT64 offset;
+
+ /* try the 1.2 way first */
+ result = TCSP_GetCapability_Internal(InternalContext, capArea, 0, NULL, &respSize, &resp);
+ if (result == TSS_SUCCESS) {
+ offset = sizeof(UINT16); // XXX hack
+ UnloadBlob_VERSION(&offset, resp, version);
+ free(resp);
+ } else if (result == TCPA_E_BAD_MODE) {
+ /* if the TPM doesn't understand VERSION_VAL, try the 1.1 way */
+ capArea = TCPA_CAP_VERSION;
+ result = TCSP_GetCapability_Internal(InternalContext, capArea, 0, NULL, &respSize,
+ &resp);
+ if (result == TSS_SUCCESS) {
+ offset = 0;
+ UnloadBlob_VERSION(&offset, resp, version);
+ free(resp);
+ }
+ }
+
+ return result;
+}
+
+TSS_RESULT
+get_cap_uint32(TCPA_CAPABILITY_AREA capArea, BYTE *subCap, UINT32 subCapSize, UINT32 *v)
+{
+ UINT32 respSize;
+ BYTE *resp;
+ TSS_RESULT result;
+ UINT64 offset;
+
+ result = TCSP_GetCapability_Internal(InternalContext, capArea, subCapSize, subCap,
+ &respSize, &resp);
+ if (!result) {
+ offset = 0;
+ switch (respSize) {
+ case 1:
+ UnloadBlob_BYTE(&offset, (BYTE *)v, resp);
+ break;
+ case sizeof(UINT16):
+ UnloadBlob_UINT16(&offset, (UINT16 *)v, resp);
+ break;
+ case sizeof(UINT32):
+ UnloadBlob_UINT32(&offset, v, resp);
+ break;
+ default:
+ LogDebug("TCSP_GetCapability_Internal returned"
+ " %u bytes", respSize);
+ result = TCSERR(TSS_E_FAIL);
+ break;
+ }
+ free(resp);
+ }
+
+ return result;
+}
+
+
+TSS_RESULT
+get_max_auths(UINT32 *auths)
+{
+ TCS_AUTHHANDLE handles[TSS_MAX_AUTHS_CAP];
+ TCPA_NONCE nonce;
+ UINT32 subCap;
+ TSS_RESULT result;
+ int i;
+
+ if (TPM_VERSION_IS(1,2)) {
+ UINT32ToArray(TPM_CAP_PROP_MAX_AUTHSESS, (BYTE *)(&subCap));
+ result = get_cap_uint32(TPM_CAP_PROPERTY, (BYTE *)&subCap, sizeof(subCap), auths);
+ } else if (TPM_VERSION_IS(1,1)) {
+ /* open auth sessions until we get a failure */
+ for (i = 0; i < TSS_MAX_AUTHS_CAP; i++) {
+ result = TCSP_OIAP_Internal(InternalContext, &(handles[i]), &nonce);
+ if (result != TSS_SUCCESS) {
+ /* this is not off by one since we're 0 indexed */
+ *auths = i;
+ break;
+ }
+ }
+
+ if (i == TSS_MAX_AUTHS_CAP)
+ *auths = TSS_MAX_AUTHS_CAP;
+
+ /* close the auth sessions */
+ for (i = 0; (UINT32)i < *auths; i++) {
+ internal_TerminateHandle(handles[i]);
+ }
+ } else {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ *auths = 0;
+ }
+
+ if (*auths < 2) {
+ LogError("%s reported only %u auth available!", __FUNCTION__, *auths);
+ LogError("Your TPM must be reset before the TCSD can be started.");
+ } else {
+ LogDebug("get_max_auths reports %u auth contexts found", *auths);
+ result = TSS_SUCCESS;
+ }
+
+ return result;
+}
+
+/* This is only called from init paths, so printing an error message is
+ * appropriate if something goes wrong */
+TSS_RESULT
+get_tpm_metrics(struct tpm_properties *p)
+{
+ TSS_RESULT result;
+ UINT32 subCap, rv = 0;
+
+ if ((result = get_current_version(&p->version)))
+ goto err;
+
+ UINT32ToArray(TPM_ORD_SaveKeyContext, (BYTE *)&subCap);
+ if ((result = get_cap_uint32(TCPA_CAP_ORD, (BYTE *)&subCap, sizeof(UINT32), &rv)))
+ goto err;
+ p->keyctx_swap = rv ? TRUE : FALSE;
+
+ rv = 0;
+ UINT32ToArray(TPM_ORD_SaveAuthContext, (BYTE *)&subCap);
+ if ((result = get_cap_uint32(TCPA_CAP_ORD, (BYTE *)&subCap, sizeof(UINT32), &rv)))
+ goto err;
+ p->authctx_swap = rv ? TRUE : FALSE;
+
+ UINT32ToArray(TPM_CAP_PROP_PCR, (BYTE *)&subCap);
+ if ((result = get_cap_uint32(TCPA_CAP_PROPERTY, (BYTE *)&subCap, sizeof(UINT32),
+ &p->num_pcrs)))
+ goto err;
+
+ UINT32ToArray(TPM_CAP_PROP_DIR, (BYTE *)&subCap);
+ if ((result = get_cap_uint32(TCPA_CAP_PROPERTY, (BYTE *)&subCap, sizeof(UINT32),
+ &p->num_dirs)))
+ goto err;
+
+ UINT32ToArray(TPM_CAP_PROP_SLOTS, (BYTE *)&subCap);
+ if ((result = get_cap_uint32(TCPA_CAP_PROPERTY, (BYTE *)&subCap, sizeof(UINT32),
+ &p->num_keys)))
+ goto err;
+
+ UINT32ToArray(TPM_CAP_PROP_MANUFACTURER, (BYTE *)&subCap);
+ if ((result = get_cap_uint32(TCPA_CAP_PROPERTY, (BYTE *)&subCap, sizeof(UINT32),
+ (UINT32 *)&p->manufacturer)))
+ goto err;
+
+ result = get_max_auths(&(p->num_auths));
+
+err:
+ if (result)
+ LogError("TCS GetCapability failed with result = 0x%x", result);
+
+ return result;
+}
+
diff --git a/src/tcs/tcs_context.c b/src/tcs/tcs_context.c
new file mode 100644
index 0000000..1e9f4b8
--- /dev/null
+++ b/src/tcs/tcs_context.c
@@ -0,0 +1,320 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <time.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_context.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+unsigned long nextContextHandle = 0xA0000000;
+struct tcs_context *tcs_context_table = NULL;
+
+MUTEX_DECLARE_INIT(tcs_ctx_lock);
+
+TCS_CONTEXT_HANDLE getNextHandle();
+struct tcs_context *create_tcs_context();
+struct tcs_context *get_context(TCS_CONTEXT_HANDLE);
+struct tcs_context *get_previous_context(TCS_CONTEXT_HANDLE);
+
+TSS_BOOL initContextHandle = 1;
+
+TCS_CONTEXT_HANDLE
+getNextHandle()
+{
+ UINT32 tempRand;
+ time_t currentTime;
+
+ if (initContextHandle) {
+ currentTime = time(NULL);
+ srand(currentTime);
+ tempRand = rand();
+ tempRand = tempRand << 16;
+ tempRand &= 0x00FF0000;
+ nextContextHandle |= tempRand;
+ initContextHandle = 0;
+ }
+ currentTime = time(NULL);
+ srand(currentTime + 1);
+ tempRand = rand();
+ tempRand = tempRand << 8;
+ tempRand &= 0x0000FF00;
+ if (nextContextHandle == 0)
+ return getNextHandle();
+ else
+ return ((nextContextHandle++) | tempRand);
+}
+
+struct tcs_context *
+create_tcs_context()
+{
+ struct tcs_context *ret = (struct tcs_context *)calloc(1, sizeof(struct tcs_context));
+
+ if (ret != NULL) {
+ ret->handle = getNextHandle();
+ COND_INIT(ret->cond);
+ }
+ return ret;
+}
+
+struct tcs_context *
+get_context(TCS_CONTEXT_HANDLE handle)
+{
+ struct tcs_context *index;
+ index = tcs_context_table;
+ while (index) {
+ if (index->handle == handle)
+ break;
+ index = index->next;
+ }
+
+ return index;
+}
+
+struct tcs_context *
+get_previous_context(TCS_CONTEXT_HANDLE handle)
+{
+ struct tcs_context *index;
+ index = tcs_context_table;
+ while (index) {
+ if (index->next) {
+ if (index->next->handle == handle)
+ return index;
+ }
+ index = index->next;
+ }
+
+ return 0;
+}
+
+void
+destroy_context(TCS_CONTEXT_HANDLE handle)
+{
+ struct tcs_context *toKill;
+ struct tcs_context *previous;
+
+ MUTEX_LOCK(tcs_ctx_lock);
+
+ toKill = get_context(handle);
+ previous = get_previous_context(handle);
+
+ if (!previous && tcs_context_table->handle == handle) {
+ /* this means that toKill is the first one */
+ tcs_context_table = tcs_context_table->next;
+ } else if (previous && toKill) {
+ /* both are found */
+ previous->next = toKill->next;
+ } else {
+ MUTEX_UNLOCK(tcs_ctx_lock);
+ return;
+ }
+
+ MUTEX_UNLOCK(tcs_ctx_lock);
+
+ CTX_ref_count_keys(toKill);
+
+#ifdef TSS_BUILD_TRANSPORT
+ /* Free existing transport session if necessary */
+ if (toKill->transHandle)
+ TCSP_FlushSpecific_Common(toKill->transHandle, TPM_RT_TRANS);
+#endif
+
+ free(toKill);
+}
+
+TCS_CONTEXT_HANDLE
+make_context()
+{
+ struct tcs_context *index;
+
+ MUTEX_LOCK(tcs_ctx_lock);
+
+ index = tcs_context_table;
+
+ if (!index) {
+ tcs_context_table = create_tcs_context();
+ if (tcs_context_table == NULL) {
+ LogError("Malloc Failure.");
+ MUTEX_UNLOCK(tcs_ctx_lock);
+ return 0;
+ }
+ index = tcs_context_table;
+ } else {
+ while (index->next) {
+ index = index->next;
+ }
+ index->next = create_tcs_context();
+ if (index->next == NULL) {
+ LogError("Malloc Failure.");
+ MUTEX_UNLOCK(tcs_ctx_lock);
+ return 0;
+ }
+ index = index->next;
+ }
+
+ MUTEX_UNLOCK(tcs_ctx_lock);
+
+ return index->handle;
+}
+
+
+TSS_RESULT
+ctx_verify_context(TCS_CONTEXT_HANDLE tcsContext)
+{
+ struct tcs_context *c;
+
+ if (tcsContext == InternalContext) {
+ LogDebug("Success: %x is an Internal Context", tcsContext);
+ return TSS_SUCCESS;
+ }
+
+ MUTEX_LOCK(tcs_ctx_lock);
+
+ c = get_context(tcsContext);
+
+ MUTEX_UNLOCK(tcs_ctx_lock);
+
+ if (c == NULL) {
+ LogDebug("Fail: Context %x not found", tcsContext);
+ return TCSERR(TCS_E_INVALID_CONTEXTHANDLE);
+ }
+
+ return TSS_SUCCESS;
+}
+
+
+COND_VAR *
+ctx_get_cond_var(TCS_CONTEXT_HANDLE tcs_handle)
+{
+ struct tcs_context *c;
+ COND_VAR *ret = NULL;
+
+ MUTEX_LOCK(tcs_ctx_lock);
+
+ c = get_context(tcs_handle);
+
+ if (c != NULL)
+ ret = &c->cond;
+
+ MUTEX_UNLOCK(tcs_ctx_lock);
+
+ return ret;
+}
+
+/* the only transport flag at the TCS level is whether the session is exclusive or not. If the app
+ * is requesting an exclusive transport session, check that no other exclusive sessions exist and
+ * if not, flag this context as being the one. If so, return internal error. */
+TSS_RESULT
+ctx_req_exclusive_transport(TCS_CONTEXT_HANDLE tcsContext)
+{
+ TSS_RESULT result = TSS_SUCCESS;
+ struct tcs_context *tmp, *self = NULL;
+
+ /* If the daemon is configured to ignore apps that want an exclusive transport, just
+ * return */
+ if (!tcsd_options.exclusive_transport)
+ return result;
+
+ MUTEX_LOCK(tcs_ctx_lock);
+
+ tmp = tcs_context_table;
+ while (tmp) {
+ if (tmp->flags & TSS_CONTEXT_FLAG_TRANSPORT_EXCLUSIVE) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto done;
+ }
+
+ if (tmp->handle == tcsContext)
+ self = tmp;
+
+ tmp = tmp->next;
+ }
+
+ if (self)
+ self->flags |= TSS_CONTEXT_FLAG_TRANSPORT_EXCLUSIVE;
+ else
+ result = TCSERR(TCS_E_INVALID_CONTEXTHANDLE);
+done:
+ MUTEX_UNLOCK(tcs_ctx_lock);
+
+ return result;
+}
+
+TSS_RESULT
+ctx_set_transport_enabled(TCS_CONTEXT_HANDLE tcsContext, UINT32 hTransHandle)
+{
+ TSS_RESULT result = TSS_SUCCESS;
+ struct tcs_context *tmp, *self = NULL;
+
+ MUTEX_LOCK(tcs_ctx_lock);
+
+ tmp = tcs_context_table;
+ while (tmp) {
+ if (tmp->handle == tcsContext) {
+ self = tmp;
+ break;
+ }
+
+ tmp = tmp->next;
+ }
+
+ if (self) {
+ self->flags |= TSS_CONTEXT_FLAG_TRANSPORT_ENABLED;
+ self->transHandle = hTransHandle;
+ } else
+ result = TCSERR(TCS_E_INVALID_CONTEXTHANDLE);
+
+ MUTEX_UNLOCK(tcs_ctx_lock);
+
+ return result;
+}
+
+TSS_RESULT
+ctx_set_transport_disabled(TCS_CONTEXT_HANDLE tcsContext, TCS_HANDLE *transHandle)
+{
+ TSS_RESULT result = TSS_SUCCESS;
+ struct tcs_context *tmp, *self = NULL;
+
+ MUTEX_LOCK(tcs_ctx_lock);
+
+ tmp = tcs_context_table;
+ while (tmp) {
+ if (tmp->handle == tcsContext) {
+ self = tmp;
+ break;
+ }
+
+ tmp = tmp->next;
+ }
+
+ if (self) {
+ if (!transHandle || *transHandle == self->transHandle) {
+ self->transHandle = 0;
+ self->flags &= ~TSS_CONTEXT_FLAG_TRANSPORT_ENABLED;
+ }
+ } else
+ result = TCSERR(TCS_E_INVALID_CONTEXTHANDLE);
+
+ MUTEX_UNLOCK(tcs_ctx_lock);
+
+ return result;
+}
diff --git a/src/tcs/tcs_context_key.c b/src/tcs/tcs_context_key.c
new file mode 100644
index 0000000..dcec6dc
--- /dev/null
+++ b/src/tcs/tcs_context_key.c
@@ -0,0 +1,162 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+
+#include <time.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_context.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+
+MUTEX_DECLARE_EXTERN(tcs_ctx_lock);
+
+/* runs through the list of all keys loaded by context c and decrements
+ * their ref count by 1, then free's their structures.
+ */
+void
+ctx_ref_count_keys(struct tcs_context *c)
+{
+ struct keys_loaded *cur, *prev;
+
+ if (c == NULL)
+ return;
+
+ cur = prev = c->keys;
+
+ while (cur != NULL) {
+ key_mgr_dec_ref_count(cur->key_handle);
+ cur = cur->next;
+ free(prev);
+ prev = cur;
+ }
+}
+/* Traverse loaded keys list and if matching key handle is found return TRUE else return FALSE
+ */
+TSS_BOOL
+ctx_has_key_loaded(TCS_CONTEXT_HANDLE ctx_handle, TCS_KEY_HANDLE key_handle)
+{
+ struct tcs_context *c;
+ struct keys_loaded *k = NULL;
+
+ MUTEX_LOCK(tcs_ctx_lock);
+
+ c = get_context(ctx_handle);
+ if (c == NULL) {
+ MUTEX_UNLOCK(tcs_ctx_lock);
+ return FALSE;
+ }
+ k = c->keys;
+ while (k != NULL) {
+ if (k->key_handle == key_handle) {
+ MUTEX_UNLOCK(tcs_ctx_lock);
+ return TRUE;
+ }
+ k = k->next;
+ }
+
+ MUTEX_UNLOCK(tcs_ctx_lock);
+ return FALSE;
+}
+
+/* Traverse loaded keys list and if matching key handle is found remove it */
+TSS_RESULT
+ctx_remove_key_loaded(TCS_CONTEXT_HANDLE ctx_handle, TCS_KEY_HANDLE key_handle)
+{
+ struct tcs_context *c;
+ struct keys_loaded *cur, *prev;
+
+ MUTEX_LOCK(tcs_ctx_lock);
+
+ c = get_context(ctx_handle);
+ if (c == NULL) {
+ MUTEX_UNLOCK(tcs_ctx_lock);
+ return TCSERR(TCS_E_INVALID_CONTEXTHANDLE);
+ }
+
+ for (prev = cur = c->keys; cur; prev = cur, cur = cur->next) {
+ if (cur->key_handle == key_handle) {
+ if (prev == c->keys)
+ c->keys = cur->next;
+ else
+ prev->next = cur->next;
+
+ free(cur);
+ MUTEX_UNLOCK(tcs_ctx_lock);
+ return TCS_SUCCESS;
+ }
+ }
+
+ MUTEX_UNLOCK(tcs_ctx_lock);
+ return TCSERR(TCS_E_INVALID_KEY);
+}
+
+/* make a new entry in the per-context list of loaded keys. If the list already
+ * contains a pointer to the key in memory, just return success.
+ */
+TSS_RESULT
+ctx_mark_key_loaded(TCS_CONTEXT_HANDLE ctx_handle, TCS_KEY_HANDLE key_handle)
+{
+ struct tcs_context *c;
+ struct keys_loaded *k = NULL, *new;
+ TSS_RESULT result;
+
+ MUTEX_LOCK(tcs_ctx_lock);
+
+ c = get_context(ctx_handle);
+
+ if (c != NULL) {
+ k = c->keys;
+ while (k != NULL) {
+ if (k->key_handle == key_handle) {
+ /* we've previously created a pointer to key_handle in the global
+ * list of loaded keys and incremented that key's reference count,
+ * so there's no need to do anything.
+ */
+ result = TSS_SUCCESS;
+ break;
+ }
+
+ k = k->next;
+ }
+ } else {
+ MUTEX_UNLOCK(tcs_ctx_lock);
+ return TCSERR(TSS_E_FAIL);
+ }
+
+ /* if we have no record of this key being loaded by this context, create a new
+ * entry and increment the key's reference count in the global list.
+ */
+ if (k == NULL) {
+ new = calloc(1, sizeof(struct keys_loaded));
+ if (new == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(struct keys_loaded));
+ MUTEX_UNLOCK(tcs_ctx_lock);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ new->key_handle = key_handle;
+ new->next = c->keys;
+ c->keys = new;
+ result = key_mgr_inc_ref_count(new->key_handle);
+ }
+
+ MUTEX_UNLOCK(tcs_ctx_lock);
+
+ return result;
+}
+
diff --git a/src/tcs/tcs_counter.c b/src/tcs/tcs_counter.c
new file mode 100644
index 0000000..f212ac6
--- /dev/null
+++ b/src/tcs/tcs_counter.c
@@ -0,0 +1,54 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcsps.h"
+#include "tcslog.h"
+
+
+void
+UnloadBlob_COUNTER_VALUE(UINT64 *offset, BYTE *blob, TPM_COUNTER_VALUE *ctr)
+{
+ if (!ctr) {
+ UnloadBlob_UINT16(offset, NULL, blob);
+ UnloadBlob(offset, 4, blob, NULL);
+ UnloadBlob_UINT32(offset, NULL, blob);
+ return;
+ }
+
+ UnloadBlob_UINT16(offset, &ctr->tag, blob);
+ UnloadBlob(offset, 4, blob, (BYTE *)&ctr->label);
+ UnloadBlob_UINT32(offset, &ctr->counter, blob);
+}
+
+void
+LoadBlob_COUNTER_VALUE(UINT64 *offset, BYTE *blob, TPM_COUNTER_VALUE *ctr)
+{
+ LoadBlob_UINT16(offset, ctr->tag, blob);
+ LoadBlob(offset, 4, blob, (BYTE *)&ctr->label);
+ LoadBlob_UINT32(offset, ctr->counter, blob);
+}
diff --git a/src/tcs/tcs_evlog.c b/src/tcs/tcs_evlog.c
new file mode 100644
index 0000000..f854e4e
--- /dev/null
+++ b/src/tcs/tcs_evlog.c
@@ -0,0 +1,223 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcslog.h"
+#include "tcsem.h"
+
+
+struct event_log *tcs_event_log = NULL;
+
+TSS_RESULT
+event_log_init()
+{
+ if (tcs_event_log != NULL)
+ return TSS_SUCCESS;
+
+ tcs_event_log = calloc(1, sizeof(struct event_log));
+ if (tcs_event_log == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(struct event_log));
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ MUTEX_INIT(tcs_event_log->lock);
+
+ /* allocate as many event lists as there are PCR's */
+ tcs_event_log->lists = calloc(tpm_metrics.num_pcrs, sizeof(struct event_wrapper *));
+ if (tcs_event_log->lists == NULL) {
+ LogError("malloc of %zd bytes failed.",
+ tpm_metrics.num_pcrs * sizeof(struct event_wrapper *));
+ free(tcs_event_log);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ /* assign external event log sources here */
+ //tcs_event_log->firmware_source = EVLOG_IMA_SOURCE;
+ tcs_event_log->firmware_source = EVLOG_BIOS_SOURCE;
+ tcs_event_log->kernel_source = EVLOG_IMA_SOURCE;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+event_log_final()
+{
+ struct event_wrapper *cur, *next;
+ UINT32 i;
+
+ MUTEX_LOCK(tcs_event_log->lock);
+
+ for (i = 0; i < tpm_metrics.num_pcrs; i++) {
+ cur = tcs_event_log->lists[i];
+ while (cur != NULL) {
+ next = cur->next;
+ free(cur->event.rgbPcrValue);
+ free(cur->event.rgbEvent);
+ free(cur);
+ cur = next;
+ }
+ }
+
+ MUTEX_UNLOCK(tcs_event_log->lock);
+
+ free(tcs_event_log->lists);
+ free(tcs_event_log);
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+copy_pcr_event(TSS_PCR_EVENT *dest, TSS_PCR_EVENT *source)
+{
+ memcpy(dest, source, sizeof(TSS_PCR_EVENT));
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+event_log_add(TSS_PCR_EVENT *event, UINT32 *pNumber)
+{
+ struct event_wrapper *new, *tmp;
+ TSS_RESULT result;
+ UINT32 i;
+
+ MUTEX_LOCK(tcs_event_log->lock);
+
+ new = calloc(1, sizeof(struct event_wrapper));
+ if (new == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(struct event_wrapper));
+ MUTEX_UNLOCK(tcs_event_log->lock);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ if ((result = copy_pcr_event(&(new->event), event))) {
+ free(new);
+ MUTEX_UNLOCK(tcs_event_log->lock);
+ return result;
+ }
+
+ /* go to the end of the list to add the element, so that they're in order */
+ i = 0;
+ if (tcs_event_log->lists[event->ulPcrIndex] == NULL) {
+ tcs_event_log->lists[event->ulPcrIndex] = new;
+ } else {
+ i++;
+ tmp = tcs_event_log->lists[event->ulPcrIndex];
+ while (tmp->next != NULL) {
+ i++;
+ tmp = tmp->next;
+ }
+ tmp->next = new;
+ }
+
+ *pNumber = ++i;
+
+ MUTEX_UNLOCK(tcs_event_log->lock);
+
+ return TSS_SUCCESS;
+}
+
+TSS_PCR_EVENT *
+get_pcr_event(UINT32 pcrIndex, UINT32 eventNumber)
+{
+ struct event_wrapper *tmp;
+ UINT32 counter = 0;
+
+ MUTEX_LOCK(tcs_event_log->lock);
+
+ tmp = tcs_event_log->lists[pcrIndex];
+ for (; tmp; tmp = tmp->next) {
+ if (counter == eventNumber) {
+ break;
+ }
+ counter++;
+ }
+
+ MUTEX_UNLOCK(tcs_event_log->lock);
+
+ return (tmp ? &(tmp->event) : NULL);
+}
+
+/* the lock should be held before calling this function */
+UINT32
+get_num_events(UINT32 pcrIndex)
+{
+ struct event_wrapper *tmp;
+ UINT32 counter = 0;
+
+ tmp = tcs_event_log->lists[pcrIndex];
+ for (; tmp; tmp = tmp->next) {
+ counter++;
+ }
+
+ return counter;
+}
+
+TSS_PCR_EVENT *
+concat_pcr_events(TSS_PCR_EVENT **list_so_far, UINT32 list_size, TSS_PCR_EVENT *addition,
+ UINT32 addition_size)
+{
+ TSS_PCR_EVENT *ret;
+
+ ret = realloc(*list_so_far, (list_size + addition_size) * sizeof(TSS_PCR_EVENT));
+ if (ret == NULL) {
+ LogError("malloc of %zd bytes failed",
+ (list_size + addition_size) * sizeof(TSS_PCR_EVENT));
+ return ret;
+ }
+
+ memcpy(&ret[list_size], addition, addition_size * sizeof(TSS_PCR_EVENT));
+ return ret;
+}
+
+/* XXX make this a macro */
+UINT32
+get_pcr_event_size(TSS_PCR_EVENT *e)
+{
+ return (sizeof(TSS_PCR_EVENT) + e->ulEventLength + e->ulPcrValueLength);
+}
+
+void
+free_external_events(UINT32 eventCount, TSS_PCR_EVENT *ppEvents)
+{
+ UINT32 j;
+
+ if (!ppEvents)
+ return;
+
+ for (j = 0; j < eventCount; j++) {
+ /* This is a fairly heinous hack, but PCR event logs can get really large
+ * and without it, there is a real potential to exhaust memory by leaks.
+ * The PCR event logs that we pull out of securityfs have had their
+ * rgbPcrValue and rgbEvent pointers malloc'd dynamically as the
+ * securityfs log was parsed. The other event log lists that are
+ * maintained by the TCSD don't need to have this data free'd, since that
+ * will happen at shutdown time only. So, for each PCR index that's
+ * read from securityfs, we need to free its pointers after that data has
+ * been set in the packet to send back to the TSP. */
+ if ((tcsd_options.kernel_pcrs & (1 << ppEvents[j].ulPcrIndex)) ||
+ (tcsd_options.firmware_pcrs & (1 << ppEvents[j].ulPcrIndex))) {
+ free(ppEvents[j].rgbPcrValue);
+ free(ppEvents[j].rgbEvent);
+ }
+ }
+}
diff --git a/src/tcs/tcs_evlog_biosem.c b/src/tcs/tcs_evlog_biosem.c
new file mode 100644
index 0000000..7065e12
--- /dev/null
+++ b/src/tcs/tcs_evlog_biosem.c
@@ -0,0 +1,298 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2006
+ *
+ */
+
+/*
+ * biosem.c
+ *
+ * Routines for handling PCR events from the TCG Compliant BIOS
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+#include <unistd.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcsps.h"
+#include "tcslog.h"
+#include "tcsem.h"
+
+#ifdef EVLOG_SOURCE_BIOS
+
+struct ext_log_source bios_source = {
+ bios_open,
+ bios_get_entries_by_pcr,
+ bios_get_entry,
+ bios_close
+};
+
+int
+bios_open(void *source, FILE **handle)
+{
+ FILE *fd;
+
+ if ((fd = fopen((char *)source, "r")) == NULL ) {
+ LogError("Error opening BIOS Eventlog file %s: %s", (char *)source,
+ strerror(errno));
+ return -1;
+ }
+
+ *handle = fd;
+
+ return 0;
+}
+
+TSS_RESULT
+bios_get_entries_by_pcr(FILE *handle, UINT32 pcr_index, UINT32 first,
+ UINT32 *count, TSS_PCR_EVENT **events)
+{
+ char page[BIOS_READ_SIZE];
+ int error_path = 1;
+ UINT32 seen_indices = 0, copied_events = 0, i;
+ struct event_wrapper *list = calloc(1, sizeof(struct event_wrapper));
+ struct event_wrapper *cur = list;
+ TSS_RESULT result = TSS_E_INTERNAL_ERROR;
+ TCG_PCClientPCREventStruc *event = NULL;
+ int num=0;
+
+ if (list == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(struct event_wrapper));
+ return TSS_E_OUTOFMEMORY;
+ }
+
+ if (*count == 0) {
+ result = TSS_SUCCESS;
+ goto free_list;
+ }
+
+ while (1) {
+ /* read event header from the file */
+ if ((fread(page, 32, 1, handle)) <= 0) {
+ goto copy_events;
+ }
+
+ event = (TCG_PCClientPCREventStruc *)page;
+
+ /* if the index is the one we're looking for, grab the entry */
+ if (pcr_index == event->pcrIndex) {
+ if (seen_indices >= first) {
+ /* grab this entry */
+ cur->event.rgbPcrValue = malloc(20);
+ if (cur->event.rgbPcrValue == NULL) {
+ LogError("malloc of %d bytes failed.", 20);
+ result = TSS_E_OUTOFMEMORY;
+ goto free_list;
+ }
+
+ cur->event.ulPcrIndex = pcr_index;
+ cur->event.eventType = event->eventType;
+ cur->event.ulPcrValueLength = 20;
+
+ /* copy the SHA1 XXX endianess ignored */
+ memcpy(cur->event.rgbPcrValue, event->digest, 20);
+
+ /* copy the event name XXX endianess ignored */
+ cur->event.ulEventLength = event->eventDataSize;
+
+ if (event->eventDataSize>0) {
+ cur->event.rgbEvent = malloc(event->eventDataSize);
+ if (cur->event.rgbEvent == NULL) {
+ LogError("malloc of %d bytes failed.",
+ event->eventDataSize);
+ free(cur->event.rgbPcrValue);
+ result = TSS_E_OUTOFMEMORY;
+ goto free_list;
+ }
+ if ((fread(cur->event.rgbEvent,
+ event->eventDataSize, 1, handle)) <= 0) {
+ LogError("read from event source failed: %s",
+ strerror(errno));
+ return result;
+ }
+ } else {
+ cur->event.rgbEvent = NULL;
+ }
+
+ copied_events++;
+ if (copied_events == *count)
+ goto copy_events;
+
+ cur->next = calloc(1, sizeof(struct event_wrapper));
+ if (cur->next == NULL) {
+ LogError("malloc of %zd bytes failed.",
+ sizeof(struct event_wrapper));
+ result = TSS_E_OUTOFMEMORY;
+ goto free_list;
+ }
+ cur = cur->next;
+ } else {
+ /* skip */
+ if (event->eventDataSize > 0)
+ fseek(handle,event->eventDataSize,SEEK_CUR);
+ }
+ seen_indices++;
+ } else {
+ if (event->eventDataSize > 0)
+ fseek(handle,event->eventDataSize,SEEK_CUR);
+ }
+ num++;
+ }
+
+copy_events:
+
+ /* we've copied all the events we need to from this PCR, now
+ * copy them all into one contiguous memory block
+ */
+ *events = calloc(copied_events, sizeof(TSS_PCR_EVENT));
+ if (*events == NULL) {
+ LogError("malloc of %zd bytes failed.", copied_events * sizeof(TSS_PCR_EVENT));
+ result = TSS_E_OUTOFMEMORY;
+ goto free_list;
+ }
+
+ cur = list;
+ for (i = 0; i < copied_events; i++) {
+ memcpy(&((*events)[i]), &(cur->event), sizeof(TSS_PCR_EVENT));
+ cur = cur->next;
+ }
+
+ *count = copied_events;
+ /* assume we're in an error path until we get here */
+ error_path = 0;
+ result = TSS_SUCCESS;
+
+free_list:
+ cur = list->next;
+ while (cur != NULL) {
+ if (error_path) {
+ free(cur->event.rgbEvent);
+ free(cur->event.rgbPcrValue);
+ }
+ free(list);
+ list = cur;
+ cur = list->next;
+ }
+ free(list);
+ return result;
+}
+
+TSS_RESULT
+bios_get_entry(FILE *handle, UINT32 pcr_index, UINT32 *num, TSS_PCR_EVENT **ppEvent)
+{
+ char page[BIOS_READ_SIZE];
+ UINT32 seen_indices = 0;
+ TSS_RESULT result = TSS_E_INTERNAL_ERROR;
+ TSS_PCR_EVENT *e = NULL;
+ TCG_PCClientPCREventStruc *event = NULL;
+
+ while (1) {
+ /* read event header from the file */
+ if ((fread(page, 32, 1, handle)) == 0) {
+ goto done;
+ }
+
+ event = (TCG_PCClientPCREventStruc *)page;
+
+ if (pcr_index == event->pcrIndex) {
+ if (ppEvent && !*ppEvent && seen_indices == *num) {
+ *ppEvent = calloc(1, sizeof(TSS_PCR_EVENT));
+ if (*ppEvent == NULL) {
+ LogError("malloc of %zd bytes failed.",
+ sizeof(TSS_PCR_EVENT));
+ return TSS_E_INTERNAL_ERROR;
+ }
+
+ e = *ppEvent;
+
+ e->rgbPcrValue = malloc(20);
+ if (e->rgbPcrValue == NULL) {
+ LogError("malloc of %d bytes failed.", 20);
+ free(e);
+ e = NULL;
+ break;
+ }
+
+ e->ulPcrIndex = pcr_index;
+ e->eventType = event->eventType;
+ e->ulPcrValueLength = 20;
+
+ /* copy the SHA1 XXX endianess ignored */
+ memcpy(e->rgbPcrValue, event->digest, 20);
+
+ e->ulEventLength = event->eventDataSize;
+
+ if (event->eventDataSize>0) {
+ e->rgbEvent = malloc(e->ulEventLength);
+ if (e->rgbEvent == NULL) {
+ LogError("malloc of %d bytes failed.",
+ e->ulEventLength);
+ free(e->rgbPcrValue);
+ free(e);
+ e = NULL;
+ break;
+ }
+ if ((fread(e->rgbEvent,
+ event->eventDataSize,
+ 1, handle)) <= 0) {
+ LogError("read from event source failed: %s",
+ strerror(errno));
+ return result;
+ }
+ } else {
+ e->rgbEvent = NULL;
+ }
+ result = TSS_SUCCESS;
+
+ break;
+ } else {
+ /* skip */
+ if (event->eventDataSize > 0) {
+ fseek(handle,event->eventDataSize,SEEK_CUR);
+ }
+ }
+ seen_indices++;
+ } else {
+ /* skip */
+ if (event->eventDataSize > 0) {
+ fseek(handle,event->eventDataSize,SEEK_CUR);
+ }
+ }
+ }
+
+done:
+ if (!ppEvent) {
+ *num = seen_indices;
+ result = TSS_SUCCESS;
+ } else if (e == NULL)
+ *ppEvent = NULL;
+
+ return result;
+}
+
+int
+bios_close(FILE *handle)
+{
+ fclose(handle);
+
+ return 0;
+}
+
+#endif
diff --git a/src/tcs/tcs_evlog_imaem.c b/src/tcs/tcs_evlog_imaem.c
new file mode 100644
index 0000000..fbdd29a
--- /dev/null
+++ b/src/tcs/tcs_evlog_imaem.c
@@ -0,0 +1,352 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+/*
+ * imaem.c
+ *
+ * Routines for handling PCR events from the Integrity Measurement
+ * Architecture.
+ *
+ * The external event source format used by IMA:
+ *
+ * 4 bytes PCR Index (bin)
+ * 20 bytes SHA1 template (bin)
+ * 4 bytes template name_len
+ * 1-255 bytes template name
+ * 20 bytes SHA1 IMA(bin)
+ * 4 bytes IMA name len
+ * 1-255 bytes eventname
+ * 1 byte separator = '\0'
+ *
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+#include <unistd.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcsps.h"
+#include "tcslog.h"
+#include "tcsem.h"
+
+#ifdef EVLOG_SOURCE_IMA
+
+struct ext_log_source ima_source = {
+ ima_open,
+ ima_get_entries_by_pcr,
+ ima_get_entry,
+ ima_close
+};
+
+int
+ima_open(void *source, FILE **handle)
+{
+ FILE *fd;
+
+ if ((fd = fopen((char *)source, "r")) == NULL) {
+ LogError("Error opening PCR log file %s: %s",
+ (char *)source, strerror(errno));
+ return -1;
+ }
+
+ *handle = fd;
+ return 0;
+}
+
+TSS_RESULT
+ima_get_entries_by_pcr(FILE *handle, UINT32 pcr_index, UINT32 first,
+ UINT32 *count, TSS_PCR_EVENT **events)
+{
+ int pcr_value;
+ char page[IMA_READ_SIZE];
+ int error_path = 1, ptr = 0;
+ UINT32 copied_events = 0, i;
+ struct event_wrapper *list = calloc(1, sizeof(struct event_wrapper));
+ struct event_wrapper *cur = list;
+ TSS_RESULT result = TCSERR(TSS_E_INTERNAL_ERROR);
+ FILE *fp = (FILE *) handle;
+ uint len;
+ char name[255];
+
+ if (list == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(struct event_wrapper));
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ if (*count == 0) {
+ result = TSS_SUCCESS;
+ goto free_list;
+ }
+
+ if (!fp) {
+ perror("unable to open file\n");
+ return 1;
+ }
+ rewind(fp);
+
+ while (fread(page, 24, 1, fp)) {
+ /* copy the initial 4 bytes (PCR index) XXX endianess ignored */
+ ptr = 0;
+ memcpy(&pcr_value, &page[ptr], sizeof(int));
+ cur->event.ulPcrIndex = pcr_value;
+ ptr += sizeof(int);
+
+ /* grab this entry */
+ cur->event.ulPcrValueLength = 20;
+ cur->event.rgbPcrValue = malloc(cur->event.ulPcrValueLength);
+ if (cur->event.rgbPcrValue == NULL) {
+ LogError("malloc of %d bytes failed.", 20);
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto free_list;
+ }
+
+ /* copy the template SHA1 XXX endianess ignored */
+ memcpy(cur->event.rgbPcrValue, &page[ptr],
+ cur->event.ulPcrValueLength);
+
+/* Get the template name size, template name */
+{
+ char digest[20];
+
+ if (fread(&len, 1, sizeof(len), fp) != (sizeof(len))) {
+ LogError("Failed to read event log file");
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto free_list;
+ }
+
+ memset(name, 0, sizeof name);
+ if (fread(name, 1, len, fp) != len) {
+ LogError("Failed to read event log file");
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto free_list;
+ }
+ if (fread(digest, 1, sizeof digest, fp) != (sizeof(digest))) {
+ LogError("Failed to read event log file");
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto free_list;
+ }
+}
+ /* Get the template data namelen and data */
+ if (fread(&cur->event.ulEventLength, 1, sizeof(int), fp) != sizeof(int)) {
+ LogError("Failed to read event log file");
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto free_list;
+ }
+ cur->event.rgbEvent = malloc(cur->event.ulEventLength + 1);
+ if (cur->event.rgbEvent == NULL) {
+ free(cur->event.rgbPcrValue);
+ LogError("malloc of %u bytes failed.",
+ cur->event.ulEventLength);
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto free_list;
+ }
+ memset(cur->event.rgbEvent, 0, cur->event.ulEventLength);
+ if (fread(cur->event.rgbEvent, 1, cur->event.ulEventLength, fp) != cur->event.ulEventLength) {
+ free(cur->event.rgbPcrValue);
+ LogError("Failed to read event log file");
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto free_list;
+ }
+
+ copied_events++;
+printf("%d %s ", copied_events, name);
+
+printf("%s\n", cur->event.rgbEvent);
+ if (copied_events == *count)
+ goto copy_events;
+
+ cur->next = calloc(1, sizeof(struct event_wrapper));
+ if (cur->next == NULL) {
+ LogError("malloc of %zd bytes failed.",
+ sizeof(struct event_wrapper));
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto free_list;
+ }
+ cur = cur->next;
+ }
+
+copy_events:
+ /* we've copied all the events we need to from this PCR, now
+ * copy them all into one contiguous memory block
+ */
+printf("copied_events: %d\n", copied_events);
+ *events = calloc(copied_events, sizeof(TSS_PCR_EVENT));
+ if (*events == NULL) {
+ LogError("malloc of %zd bytes failed.", copied_events * sizeof(TSS_PCR_EVENT));
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto free_list;
+ }
+
+ cur = list;
+ for (i = 0; i < copied_events; i++) {
+ memcpy(&((*events)[i]), &(cur->event), sizeof(TSS_PCR_EVENT));
+ cur = cur->next;
+ }
+
+ *count = copied_events;
+ /* assume we're in an error path until we get here */
+ error_path = 0;
+ result = TSS_SUCCESS;
+
+free_list:
+ cur = list->next;
+ while (cur != NULL) {
+ if (error_path) {
+ free(cur->event.rgbEvent);
+ free(cur->event.rgbPcrValue);
+ }
+ free(list);
+ list = cur;
+ cur = list->next;
+ }
+ free(list);
+ return result;
+}
+
+TSS_RESULT
+ima_get_entry(FILE *handle, UINT32 pcr_index, UINT32 *num, TSS_PCR_EVENT **ppEvent)
+{
+ int pcr_value, ptr = 0;
+ uint len;
+ char page[IMA_READ_SIZE];
+ UINT32 seen_indices = 0;
+ TSS_RESULT result = TCSERR(TSS_E_INTERNAL_ERROR);
+ TSS_PCR_EVENT *event = NULL;
+ FILE *fp = (FILE *) handle;
+ char name[255];
+
+ rewind(fp);
+ while (fread(page, 24, 1, fp)) {
+ /* copy the initial 4 bytes (PCR index) XXX endianess ignored */
+ ptr = 0;
+ memcpy(&pcr_value, &page[ptr], sizeof(int));
+
+ if (pcr_index == (UINT32)pcr_value) {
+ event = calloc(1, sizeof(TSS_PCR_EVENT));
+ event->ulPcrIndex = pcr_value;
+ ptr += sizeof(int);
+ /* This is the case where we're looking for a specific event number in a
+ * specific PCR index. When we've reached the correct event, malloc
+ * space for it, copy it in, then break out of the while loop */
+ if (ppEvent && seen_indices == *num) {
+ /* grab this entry */
+ event->ulPcrValueLength = 20;
+ event->rgbPcrValue = malloc(event->ulPcrValueLength);
+ if (event->rgbPcrValue == NULL) {
+ LogError("malloc of %d bytes failed.", 20);
+ free(event);
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+
+ /* copy the template SHA1 XXX endianess ignored */
+ memcpy(event->rgbPcrValue, &page[ptr],
+ event->ulPcrValueLength);
+
+ /* Get the template name size, template name */
+ {
+ char digest[20];
+
+ if (fread(&len, 1, sizeof(len), fp) != sizeof(len)) {
+ free(event);
+ LogError("Failed to read event log file");
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto done;
+ }
+ memset(name, 0, sizeof name);
+ if (fread(name, 1, len, fp) != len) {
+ free(event);
+ LogError("Failed to read event log file");
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto done;
+ }
+ if (fread(digest, 1, sizeof(digest), fp) != sizeof(digest)) {
+ free(event);
+ LogError("Failed to read event log file");
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto done;
+ }
+ }
+ /* Get the template data namelen and data */
+ if (fread(&event->ulEventLength, 1, sizeof(int), fp) != sizeof(int)) {
+ free(event);
+ LogError("Failed to read event log file");
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto done;
+ }
+ event->rgbEvent = malloc(event->ulEventLength + 1);
+ if (event->rgbEvent == NULL) {
+ free(event->rgbPcrValue);
+ free(event);
+ LogError("malloc of %u bytes failed.",
+ event->ulEventLength);
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+ memset(event->rgbEvent, 0, event->ulEventLength);
+ if (fread(event->rgbEvent, 1, event->ulEventLength, fp) != event->ulEventLength ) {
+ free(event->rgbPcrValue);
+ free(event);
+ LogError("Failed to read event log file");
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto done;
+ }
+
+ *ppEvent = event;
+ result = TSS_SUCCESS;
+ break;
+ }
+ }
+ if (fread(&len, 1, sizeof(len), fp) != sizeof(len)) {
+ free(event->rgbPcrValue);
+ free(event);
+ LogError("Failed to read event log file");
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto done;
+ }
+ fseek(fp, len + 20, SEEK_CUR);
+ if (fread(&len, 1, sizeof(len), fp) != sizeof(len)) {
+ free(event->rgbPcrValue);
+ free(event);
+ LogError("Failed to read event log file");
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto done;
+ }
+ fseek(fp, len, SEEK_CUR);
+ seen_indices++;
+ printf("%d - index\n", seen_indices);
+ }
+done:
+ if (ppEvent == NULL)
+ *num = seen_indices;
+
+ return result;
+}
+
+int
+ima_close(FILE *handle)
+{
+ fclose((FILE *)handle);
+
+ return 0;
+}
+#endif
diff --git a/src/tcs/tcs_key.c b/src/tcs/tcs_key.c
new file mode 100644
index 0000000..bb73f57
--- /dev/null
+++ b/src/tcs/tcs_key.c
@@ -0,0 +1,588 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+
+#include <string.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "req_mgr.h"
+#include "tcs_tsp.h"
+#include "tcslog.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+
+struct key_mem_cache *key_mem_cache_head = NULL;
+
+TSS_UUID NULL_UUID = { 0, 0, 0, 0, 0, { 0, 0, 0, 0, 0, 0 } };
+
+
+TSS_RESULT
+add_cache_entry(TCS_CONTEXT_HANDLE hContext,
+ BYTE* blob,
+ TCS_KEY_HANDLE hParent,
+ TPM_KEY_HANDLE hSlot,
+ TCS_KEY_HANDLE* new)
+{
+ UINT64 offset;
+ TSS_RESULT result;
+ TCS_KEY_HANDLE tcsHandle;
+ TSS_KEY key, *pKey;
+
+ if (!blob) {
+ pKey = NULL;
+ } else {
+ offset = 0;
+ if ((result = UnloadBlob_TSS_KEY(&offset, blob, &key)))
+ return result;
+
+ if ((tcsHandle = mc_get_handle_by_pub(&key.pubKey, hParent)) == NULL_TCS_HANDLE) {
+ pKey = &key;
+ } else {
+ mc_set_slot_by_handle(tcsHandle, hSlot);
+ *new = tcsHandle;
+ goto done;
+ }
+ }
+
+ LogDebugFn("No existing key handle for this key, creating new one...");
+ /* Get a new TCS Key Handle */
+ tcsHandle = getNextTcsKeyHandle();
+ LogDebugFn("calling mc_add_entry, TCS handle: 0x%x, TPM handle 0x%x", tcsHandle, hSlot);
+
+ if ((result = mc_add_entry(tcsHandle, hSlot, pKey)))
+ goto done;
+
+ LogDebugFn("ctx_mark_key_loaded");
+ if (ctx_mark_key_loaded(hContext, tcsHandle)) {
+ LogError("Error marking key as loaded");
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto done;
+ }
+
+ if ((result = mc_set_parent_by_handle(tcsHandle, hParent))) {
+ LogError("mc_set_parent_by_handle failed.");
+ goto done;
+ }
+
+ *new = tcsHandle;
+done:
+ if (blob)
+ destroy_key_refs(&key);
+ return result;
+}
+
+/* Check that the context has this key loaded and return the associated slot. Do not search PS if
+ * the key is not found */
+TSS_RESULT
+get_slot_lite(TCS_CONTEXT_HANDLE hContext, TCS_KEY_HANDLE hKey, TPM_KEY_HANDLE *out)
+{
+ if (ctx_has_key_loaded(hContext, hKey)) {
+ if ((*out = mc_get_slot_by_handle(hKey)) == NULL_TPM_HANDLE)
+ return TCSERR(TCS_E_INVALID_KEY);
+
+ return TSS_SUCCESS;
+ }
+
+ return TCSERR(TCS_E_INVALID_KEY);
+}
+
+/* XXX Can get_slot be merged with ensureKeyIsLoaded? */
+
+/* Given a handle, get_slot searches the mem cache for a mapping to a TPM handle. If there is no
+ * mapping, it looks up the pub key of the handle and attempts to load it by finding its pub key
+ * in the persistent store. If that's not found, return error. */
+TSS_RESULT
+get_slot(TCS_CONTEXT_HANDLE hContext, TCS_KEY_HANDLE hKey, TPM_KEY_HANDLE *out)
+{
+ TSS_RESULT result = TSS_SUCCESS;
+ TPM_STORE_PUBKEY *pub = NULL;
+ TPM_KEY_HANDLE slot;
+
+ LogDebugFn("calling mc_get_slot_by_handle");
+ if ((slot = mc_get_slot_by_handle(hKey)) == NULL_TPM_HANDLE) {
+ LogDebugFn("calling mc_get_pub_by_slot");
+ if ((pub = mc_get_pub_by_slot(hKey)) == NULL)
+ return TCSERR(TCS_E_KM_LOADFAILED);
+
+ LogDebugFn("calling LoadKeyShim");
+ /* Otherwise, try to load it using the shim */
+ result = LoadKeyShim(hContext, pub, NULL, &slot);
+ }
+
+ if (!result)
+ *out = slot;
+
+ return result;
+}
+
+/* load_key_init is the common entry point for all load key requests to the TCSD. These can come in
+ * as straight load or load2 requests, or through a transport session.
+ *
+ * We'll always attempt to load the key if
+ * A) It requires auth (load should fail if auth is bad, even when its already been loaded by
+ * another thread)
+ * B) Its in a transport session (the key blob is encrypted)
+ *
+ * Otherwise if the key is already loaded by another thread and it doesn't require auth, then we
+ * will just set *load_key to FALSE, telling the caller that there's no need to send anything to
+ * the TPM.
+ */
+TSS_RESULT
+load_key_init(TPM_COMMAND_CODE ord,
+ TCS_CONTEXT_HANDLE hContext,
+ TCS_KEY_HANDLE parent_handle,
+ UINT32 blob_size,
+ BYTE* blob,
+ TSS_BOOL encrypted,
+ TPM_AUTH* auth,
+ TSS_BOOL* load_key,
+ UINT64* out_len,
+ BYTE* out,
+ TCS_KEY_HANDLE* handle,
+ TPM_KEY_HANDLE* slot)
+{
+ TSS_RESULT result = TSS_SUCCESS;
+ TSS_KEY key;
+ UINT64 offset;
+ TPM_KEY_HANDLE tpm_slot;
+ TCS_KEY_HANDLE tcs_handle;
+ TSS_BOOL canLoad;
+
+
+ if (!encrypted) {
+ offset = 0;
+ memset(&key, 0, sizeof(TSS_KEY));
+ if ((result = UnloadBlob_TSS_KEY(&offset, blob, &key)))
+ return result;
+ }
+
+ if (!auth && !encrypted) {
+ LogDebugFn("Checking if LoadKeyByBlob can be avoided by using existing key");
+
+ if ((tcs_handle = mc_get_handle_by_pub(&key.pubKey, parent_handle))) {
+ LogDebugFn("tcs key handle exists");
+
+ tpm_slot = mc_get_slot_by_handle(tcs_handle);
+ if (tpm_slot && (isKeyLoaded(tpm_slot) == TRUE)) {
+ LogDebugFn("Don't need to reload this key.");
+ *handle = tcs_handle;
+ *slot = tpm_slot;
+ *load_key = FALSE;
+ goto done;
+ }
+ }
+ }
+ *load_key = TRUE;
+
+ LogDebugFn("calling canILoadThisKey");
+ if (!encrypted) {
+ if ((result = canILoadThisKey(&(key.algorithmParms), &canLoad)))
+ goto error;
+
+ if (canLoad == FALSE) {
+ LogDebugFn("calling evictFirstKey");
+ /* Evict a key that isn't the parent */
+ if ((result = evictFirstKey(parent_handle)))
+ goto error;
+ }
+ }
+
+error:
+ if (!encrypted)
+ destroy_key_refs(&key);
+done:
+ return result;
+}
+
+TSS_RESULT
+load_key_final(TCS_CONTEXT_HANDLE hContext,
+ TCS_KEY_HANDLE parent_handle,
+ TCS_KEY_HANDLE* tcs_handle,
+ BYTE* blob,
+ TPM_KEY_HANDLE slot)
+{
+ if (*tcs_handle == NULL_TCS_HANDLE)
+ return add_cache_entry(hContext, blob, parent_handle, slot, tcs_handle);
+ else
+ return mc_set_slot_by_handle(*tcs_handle, slot);
+}
+
+TSS_RESULT
+canILoadThisKey(TCPA_KEY_PARMS *parms, TSS_BOOL *b)
+{
+ UINT16 subCapLength;
+ UINT64 offset;
+ BYTE subCap[100];
+ TCPA_RESULT result;
+ UINT32 respDataLength;
+ BYTE *respData;
+
+ offset = 0;
+ LoadBlob_KEY_PARMS(&offset, subCap, parms);
+ subCapLength = offset;
+
+ if ((result = TCSP_GetCapability_Internal(InternalContext, TCPA_CAP_CHECK_LOADED,
+ subCapLength, subCap, &respDataLength,
+ &respData))) {
+ *b = FALSE;
+ LogDebugFn("NO");
+ return result;
+ }
+
+ *b = respData[0];
+ free(respData);
+ LogDebugFn("%s", *b ? "YES" : "NO");
+
+ return TSS_SUCCESS;
+}
+
+TCPA_RESULT
+internal_EvictByKeySlot(TCPA_KEY_HANDLE slot)
+{
+ TCPA_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Evict Key");
+
+#ifdef TSS_BUILD_TSS12
+ if (TPM_VERSION_IS(1,2)) {
+ LogDebugFn("Evicting key using FlushSpecific for TPM 1.2");
+
+ return TCSP_FlushSpecific_Common(slot, TPM_RT_KEY);
+ }
+#endif
+
+ offset = 10;
+ LoadBlob_UINT32(&offset, slot, txBlob);
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, offset, TPM_ORD_EvictKey, txBlob);
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ LogResult("Evict Key", result);
+ return result;
+}
+
+TSS_RESULT
+clearUnknownKeys(TCS_CONTEXT_HANDLE hContext, UINT32 *cleared)
+{
+ TSS_RESULT result = TSS_SUCCESS;
+ TCPA_KEY_HANDLE_LIST keyList = { 0, NULL };
+ int i;
+ BYTE *respData = NULL;
+ UINT32 respDataSize = 0, count = 0;
+ TCPA_CAPABILITY_AREA capArea = -1;
+ UINT64 offset = 0;
+ TSS_BOOL found = FALSE;
+ struct key_mem_cache *tmp;
+
+ capArea = TCPA_CAP_KEY_HANDLE;
+
+ if ((result = TCSP_GetCapability_Internal(hContext, capArea, 0, NULL, &respDataSize,
+ &respData)))
+ return result;
+
+ if ((result = UnloadBlob_KEY_HANDLE_LIST(&offset, respData, &keyList)))
+ goto done;
+
+#ifdef TSS_DEBUG
+ LogDebug("Loaded TPM key handles:");
+ for (i = 0; i < keyList.loaded; i++) {
+ LogDebugFn("%d: %x", i, keyList.handle[i]);
+ }
+
+ LogDebug("Loaded TCSD key handles:");
+ i=0;
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("%d: 0x%x -> 0x%x", i++, tmp->tpm_handle,
+ tmp->tcs_handle);
+ }
+#endif
+
+ for (i = 0; i < keyList.loaded; i++) {
+ /* as long as we're only called from evictFirstKey(), we don't
+ * need to lock here */
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ if (tmp->tpm_handle == keyList.handle[i]) {
+ found = TRUE;
+ break;
+ }
+ }
+ if (found)
+ found = FALSE;
+ else {
+ if ((result = internal_EvictByKeySlot(keyList.handle[i])))
+ goto done;
+ else
+ count++;
+ }
+ }
+
+ *cleared = count;
+done:
+ free(keyList.handle);
+ free(respData);
+
+ return TSS_SUCCESS;
+}
+
+#if 0
+TCPA_RESULT
+clearKeysFromChip(TCS_CONTEXT_HANDLE hContext)
+{
+ TCPA_RESULT result;
+ TCPA_KEY_HANDLE_LIST keyList;
+ UINT32 i;
+ BYTE *respData = 0;
+ UINT32 respDataSize = 0;
+ TCPA_CAPABILITY_AREA capArea = -1;
+ UINT64 offset = 0;
+
+ capArea = TCPA_CAP_KEY_HANDLE;
+
+ if ((result = TCSP_GetCapability_Internal(hContext, capArea, 0, NULL,
+ &respDataSize, &respData)))
+ return result;
+
+ if ((result = UnloadBlob_KEY_HANDLE_LIST(&offset, respData, &keyList)))
+ return result;
+ for (i = 0; i < keyList.loaded; i++) {
+ if (keyList.handle[i] == SRK_TPM_HANDLE || /*can't evict SRK */
+ keyList.handle[i] == EK_TPM_HANDLE) /*can't evict EK */
+ continue;
+ if ((result = internal_EvictByKeySlot(keyList.handle[i])))
+ return result;
+ }
+ return TSS_SUCCESS;
+}
+#endif
+
+void
+LoadBlob_KEY_PARMS(UINT64 *offset, BYTE *blob, TCPA_KEY_PARMS *keyInfo)
+{
+ LoadBlob_UINT32(offset, keyInfo->algorithmID, blob);
+ LoadBlob_UINT16(offset, keyInfo->encScheme, blob);
+ LoadBlob_UINT16(offset, keyInfo->sigScheme, blob);
+ LoadBlob_UINT32(offset, keyInfo->parmSize, blob);
+ LoadBlob(offset, keyInfo->parmSize, blob, keyInfo->parms);
+}
+
+TSS_RESULT
+UnloadBlob_STORE_PUBKEY(UINT64 *offset, BYTE *blob, TCPA_STORE_PUBKEY *store)
+{
+ if (!store) {
+ UINT32 keyLength;
+
+ UnloadBlob_UINT32(offset, &keyLength, blob);
+
+ if (keyLength > 0)
+ UnloadBlob(offset, keyLength, blob, NULL);
+
+ return TSS_SUCCESS;
+ }
+
+ UnloadBlob_UINT32(offset, &store->keyLength, blob);
+
+ if (store->keyLength == 0) {
+ store->key = NULL;
+ LogWarn("Unloading a public key of size 0!");
+ } else {
+ store->key = (BYTE *)malloc(store->keyLength);
+ if (store->key == NULL) {
+ LogError("malloc of %u bytes failed.", store->keyLength);
+ store->keyLength = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ UnloadBlob(offset, store->keyLength, blob, store->key);
+ }
+
+ return TSS_SUCCESS;
+}
+
+void
+LoadBlob_STORE_PUBKEY(UINT64 *offset, BYTE * blob, TCPA_STORE_PUBKEY * store)
+{
+ LoadBlob_UINT32(offset, store->keyLength, blob);
+ LoadBlob(offset, store->keyLength, blob, store->key);
+}
+
+TSS_RESULT
+UnloadBlob_TSS_KEY(UINT64 *offset, BYTE *blob, TSS_KEY *key)
+{
+ TSS_RESULT rc;
+
+ if (!key) {
+ UINT32 size;
+
+ /* TPM_KEY's ver and TPM_KEY12's tag/file are
+ the same size, so... */
+ UnloadBlob_VERSION(offset, blob, NULL);
+ UnloadBlob_UINT16(offset, NULL, blob);
+ UnloadBlob_KEY_FLAGS(offset, blob, NULL);
+ UnloadBlob_BOOL(offset, NULL, blob);
+ if ((rc = UnloadBlob_KEY_PARMS(offset, blob, NULL)))
+ return rc;
+ UnloadBlob_UINT32(offset, &size, blob);
+
+ if (size > 0)
+ UnloadBlob(offset, size, blob, NULL);
+
+ if ((rc = UnloadBlob_STORE_PUBKEY(offset, blob, NULL)))
+ return rc;
+
+ UnloadBlob_UINT32(offset, &size, blob);
+
+ if (size > 0)
+ UnloadBlob(offset, size, blob, NULL);
+
+ return TSS_SUCCESS;
+ }
+
+ if (key->hdr.key12.tag == TPM_TAG_KEY12) {
+ UnloadBlob_UINT16(offset, &key->hdr.key12.tag, blob);
+ UnloadBlob_UINT16(offset, &key->hdr.key12.fill, blob);
+ } else
+ UnloadBlob_TCPA_VERSION(offset, blob, &key->hdr.key11.ver);
+ UnloadBlob_UINT16(offset, &key->keyUsage, blob);
+ UnloadBlob_KEY_FLAGS(offset, blob, &key->keyFlags);
+ UnloadBlob_BOOL(offset, (TSS_BOOL *)&key->authDataUsage, blob);
+ if ((rc = UnloadBlob_KEY_PARMS(offset, blob, &key->algorithmParms)))
+ return rc;
+ UnloadBlob_UINT32(offset, &key->PCRInfoSize, blob);
+
+ if (key->PCRInfoSize == 0)
+ key->PCRInfo = NULL;
+ else {
+ key->PCRInfo = malloc(key->PCRInfoSize);
+ if (key->PCRInfo == NULL) {
+ LogError("malloc of %u bytes failed.", key->PCRInfoSize);
+ key->PCRInfoSize = 0;
+ free(key->algorithmParms.parms);
+ key->algorithmParms.parms = NULL;
+ key->algorithmParms.parmSize = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(offset, key->PCRInfoSize, blob, key->PCRInfo);
+ }
+
+ if ((rc = UnloadBlob_STORE_PUBKEY(offset, blob, &key->pubKey))) {
+ free(key->PCRInfo);
+ key->PCRInfo = NULL;
+ key->PCRInfoSize = 0;
+ free(key->algorithmParms.parms);
+ key->algorithmParms.parms = NULL;
+ key->algorithmParms.parmSize = 0;
+ return rc;
+ }
+ UnloadBlob_UINT32(offset, &key->encSize, blob);
+
+ if (key->encSize == 0)
+ key->encData = NULL;
+ else {
+ key->encData = (BYTE *)malloc(key->encSize);
+ if (key->encData == NULL) {
+ LogError("malloc of %d bytes failed.", key->encSize);
+ key->encSize = 0;
+ free(key->algorithmParms.parms);
+ key->algorithmParms.parms = NULL;
+ key->algorithmParms.parmSize = 0;
+ free(key->PCRInfo);
+ key->PCRInfo = NULL;
+ key->PCRInfoSize = 0;
+ free(key->pubKey.key);
+ key->pubKey.key = NULL;
+ key->pubKey.keyLength = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(offset, key->encSize, blob, key->encData);
+ }
+
+ return TSS_SUCCESS;
+}
+
+void
+LoadBlob_TSS_KEY(UINT64 *offset, BYTE * blob, TSS_KEY * key)
+{
+ if (key->hdr.key12.tag == TPM_TAG_KEY12) {
+ LoadBlob_UINT16(offset, key->hdr.key12.tag, blob);
+ LoadBlob_UINT16(offset, key->hdr.key12.fill, blob);
+ } else
+ LoadBlob_TCPA_VERSION(offset, blob, &key->hdr.key11.ver);
+ LoadBlob_UINT16(offset, key->keyUsage, blob);
+ LoadBlob_KEY_FLAGS(offset, blob, &key->keyFlags);
+ LoadBlob_BOOL(offset, key->authDataUsage, blob);
+ LoadBlob_KEY_PARMS(offset, blob, &key->algorithmParms);
+ LoadBlob_UINT32(offset, key->PCRInfoSize, blob);
+ LoadBlob(offset, key->PCRInfoSize, blob, key->PCRInfo);
+ LoadBlob_STORE_PUBKEY(offset, blob, &key->pubKey);
+ LoadBlob_UINT32(offset, key->encSize, blob);
+ LoadBlob(offset, key->encSize, blob, key->encData);
+}
+
+void
+LoadBlob_PUBKEY(UINT64 *offset, BYTE * blob, TCPA_PUBKEY * key)
+{
+ LoadBlob_KEY_PARMS(offset, blob, &(key->algorithmParms));
+ LoadBlob_STORE_PUBKEY(offset, blob, &(key->pubKey));
+}
+
+TSS_RESULT
+UnloadBlob_PUBKEY(UINT64 *offset, BYTE *blob, TCPA_PUBKEY *key)
+{
+ TSS_RESULT rc;
+
+ if (!key) {
+ if ((rc = UnloadBlob_KEY_PARMS(offset, blob, NULL)))
+ return rc;
+ return UnloadBlob_STORE_PUBKEY(offset, blob, NULL);
+ }
+
+ if ((rc = UnloadBlob_KEY_PARMS(offset, blob, &key->algorithmParms)))
+ return rc;
+ if ((rc = UnloadBlob_STORE_PUBKEY(offset, blob, &key->pubKey))) {
+ free(key->algorithmParms.parms);
+ key->algorithmParms.parms = NULL;
+ key->algorithmParms.parmSize = 0;
+ }
+
+ return rc;
+}
+
+void
+LoadBlob_KEY_FLAGS(UINT64 *offset, BYTE * blob, TCPA_KEY_FLAGS * flags)
+{
+ LoadBlob_UINT32(offset, *flags, blob);
+}
+
+void
+destroy_key_refs(TSS_KEY *key)
+{
+ free(key->algorithmParms.parms);
+ key->algorithmParms.parms = NULL;
+ key->algorithmParms.parmSize = 0;
+
+ free(key->pubKey.key);
+ key->pubKey.key = NULL;
+ key->pubKey.keyLength = 0;
+
+ free(key->encData);
+ key->encData = NULL;
+ key->encSize = 0;
+
+ free(key->PCRInfo);
+ key->PCRInfo = NULL;
+ key->PCRInfoSize = 0;
+}
diff --git a/src/tcs/tcs_key_mem_cache.c b/src/tcs/tcs_key_mem_cache.c
new file mode 100644
index 0000000..4db0259
--- /dev/null
+++ b/src/tcs/tcs_key_mem_cache.c
@@ -0,0 +1,1175 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsps.h"
+#include "req_mgr.h"
+
+#include "tcs_key_ps.h"
+
+/*
+ * mem_cache_lock will be responsible for protecting the key_mem_cache_head list. This is a
+ * TCSD global linked list of all keys which have been loaded into the TPM at some time.
+ */
+MUTEX_DECLARE_INIT(mem_cache_lock);
+
+/*
+ * tcs_keyhandle_lock is only used to make TCS keyhandle generation atomic for all TCSD
+ * threads.
+ */
+static MUTEX_DECLARE_INIT(tcs_keyhandle_lock);
+
+/*
+ * timestamp_lock is only used to make TCS key timestamp generation atomic for all TCSD
+ * threads.
+ */
+static MUTEX_DECLARE_INIT(timestamp_lock);
+
+TCS_KEY_HANDLE
+getNextTcsKeyHandle()
+{
+ static TCS_KEY_HANDLE NextTcsKeyHandle = 0x22330000;
+ TCS_KEY_HANDLE ret;
+
+ MUTEX_LOCK(tcs_keyhandle_lock);
+
+ do {
+ ret = NextTcsKeyHandle++;
+ } while (NextTcsKeyHandle == SRK_TPM_HANDLE || NextTcsKeyHandle == NULL_TCS_HANDLE);
+
+ MUTEX_UNLOCK(tcs_keyhandle_lock);
+
+ return ret;
+}
+
+UINT32
+getNextTimeStamp()
+{
+ static UINT32 time_stamp = 1;
+ UINT32 ret;
+
+ MUTEX_LOCK(timestamp_lock);
+ ret = time_stamp++;
+ MUTEX_UNLOCK(timestamp_lock);
+
+ return ret;
+}
+
+/* only called from load key paths, so no locking */
+TCPA_STORE_PUBKEY *
+mc_get_pub_by_slot(TCPA_KEY_HANDLE tpm_handle)
+{
+ struct key_mem_cache *tmp;
+ TCPA_STORE_PUBKEY *ret;
+
+ if (tpm_handle == NULL_TPM_HANDLE)
+ return NULL;
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x",
+ tmp->tcs_handle);
+ if (tmp->tpm_handle == tpm_handle) {
+ ret = tmp->blob ? &tmp->blob->pubKey : NULL;
+ return ret;
+ }
+ }
+ LogDebugFn("returning NULL TCPA_STORE_PUBKEY");
+ return NULL;
+}
+
+/* only called from load key paths, so no locking */
+TCPA_STORE_PUBKEY *
+mc_get_pub_by_handle(TCS_KEY_HANDLE tcs_handle)
+{
+ struct key_mem_cache *tmp;
+ TCPA_STORE_PUBKEY *ret;
+
+ LogDebugFn("looking for 0x%x", tcs_handle);
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x",
+ tmp->tcs_handle);
+ if (tmp->tcs_handle == tcs_handle) {
+ ret = tmp->blob ? &tmp->blob->pubKey : NULL;
+ return ret;
+ }
+ }
+
+ LogDebugFn("returning NULL TCPA_STORE_PUBKEY");
+ return NULL;
+}
+
+/* only called from load key paths, so no locking */
+TSS_RESULT
+mc_set_parent_by_handle(TCS_KEY_HANDLE tcs_handle, TCS_KEY_HANDLE p_tcs_handle)
+{
+ struct key_mem_cache *tmp, *parent;
+
+ /* find parent */
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebug("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (tmp->tcs_handle == p_tcs_handle) {
+ parent = tmp;
+ break;
+ }
+ }
+
+ /* didn't find parent */
+ if (tmp == NULL)
+ goto done;
+
+ /* set parent blob in child */
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ if (tmp->tcs_handle == tcs_handle) {
+ tmp->parent = parent;
+ return TSS_SUCCESS;
+ }
+ }
+done:
+ return TCSERR(TSS_E_FAIL);
+}
+
+TCPA_RESULT
+ensureKeyIsLoaded(TCS_CONTEXT_HANDLE hContext, TCS_KEY_HANDLE keyHandle, TCPA_KEY_HANDLE * keySlot)
+{
+ TCPA_RESULT result = TSS_SUCCESS;
+ TCPA_STORE_PUBKEY *myPub;
+
+ LogDebugFn("0x%x", keyHandle);
+
+ if (!ctx_has_key_loaded(hContext, keyHandle))
+ return TCSERR(TCS_E_INVALID_KEY);
+
+ MUTEX_LOCK(mem_cache_lock);
+
+ *keySlot = mc_get_slot_by_handle(keyHandle);
+ LogDebug("keySlot is %08X", *keySlot);
+ if (*keySlot == NULL_TPM_HANDLE || isKeyLoaded(*keySlot) == FALSE) {
+ LogDebug("calling mc_get_pub_by_handle");
+ if ((myPub = mc_get_pub_by_handle(keyHandle)) == NULL) {
+ LogDebug("Failed to find pub by handle");
+ result = TCSERR(TCS_E_KM_LOADFAILED);
+ goto done;
+ }
+
+ LogDebugFn("calling LoadKeyShim");
+ if ((result = LoadKeyShim(hContext, myPub, NULL, keySlot))) {
+ LogDebug("Failed shim");
+ goto done;
+ }
+
+ if (*keySlot == NULL_TPM_HANDLE) {
+ LogDebug("Key slot is still invalid after ensureKeyIsLoaded");
+ result = TCSERR(TCS_E_KM_LOADFAILED);
+ goto done;
+ }
+ }
+ mc_update_time_stamp(*keySlot);
+
+done:
+ MUTEX_UNLOCK(mem_cache_lock);
+ LogDebugFn("Exit");
+ return result;
+}
+
+
+/* only called from load key paths, so no locking */
+TSS_UUID *
+mc_get_uuid_by_pub(TCPA_STORE_PUBKEY *pub)
+{
+ TSS_UUID *ret;
+ struct key_mem_cache *tmp;
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (tmp->blob &&
+ tmp->blob->pubKey.keyLength == pub->keyLength &&
+ !memcmp(tmp->blob->pubKey.key, pub->key, pub->keyLength)) {
+ ret = &tmp->uuid;
+ return ret;
+ }
+ }
+
+ return NULL;
+}
+
+TSS_RESULT
+mc_get_handles_by_uuid(TSS_UUID *uuid, TCS_KEY_HANDLE *tcsHandle, TCPA_KEY_HANDLE *slot)
+{
+ struct key_mem_cache *tmp;
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ if (!memcmp(&tmp->uuid, uuid, sizeof(TSS_UUID))) {
+ *tcsHandle = tmp->tcs_handle;
+ *slot = tmp->tpm_handle;
+ return TSS_SUCCESS;
+ }
+ }
+
+ return TCSERR(TSS_E_FAIL);
+}
+
+TCS_KEY_HANDLE
+mc_get_handle_by_encdata(BYTE *encData)
+{
+ struct key_mem_cache *tmp;
+ TCS_KEY_HANDLE ret;
+
+ MUTEX_LOCK(mem_cache_lock);
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (!tmp->blob || tmp->blob->encSize == 0)
+ continue;
+ if (!memcmp(tmp->blob->encData, encData, tmp->blob->encSize)) {
+ ret = tmp->tcs_handle;
+ MUTEX_UNLOCK(mem_cache_lock);
+ return ret;
+ }
+ }
+ MUTEX_UNLOCK(mem_cache_lock);
+ return 0;
+}
+
+TSS_RESULT
+mc_update_encdata(BYTE *encData, BYTE *newEncData)
+{
+ struct key_mem_cache *tmp;
+ BYTE *tmp_enc_data;
+
+ MUTEX_LOCK(mem_cache_lock);
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (!tmp->blob || tmp->blob->encSize == 0)
+ continue;
+ if (!memcmp(tmp->blob->encData, encData, tmp->blob->encSize)) {
+ tmp_enc_data = (BYTE *)malloc(tmp->blob->encSize);
+ if (tmp_enc_data == NULL) {
+ LogError("malloc of %u bytes failed.", tmp->blob->encSize);
+ MUTEX_UNLOCK(mem_cache_lock);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ memcpy(tmp_enc_data, newEncData, tmp->blob->encSize);
+ free(tmp->blob->encData);
+ tmp->blob->encData = tmp_enc_data;
+ MUTEX_UNLOCK(mem_cache_lock);
+ return TSS_SUCCESS;
+ }
+ }
+ MUTEX_UNLOCK(mem_cache_lock);
+ LogError("Couldn't find requested encdata in mem cache");
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+}
+
+/*
+ * only called from load key paths and the init (single thread time) path,
+ * so no locking
+ */
+TSS_RESULT
+mc_add_entry(TCS_KEY_HANDLE tcs_handle,
+ TCPA_KEY_HANDLE tpm_handle,
+ TSS_KEY *key_blob)
+{
+ struct key_mem_cache *entry, *tmp;
+
+ /* Make sure the cache doesn't already have an entry for this key */
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (tcs_handle == tmp->tcs_handle) {
+ return TSS_SUCCESS;
+ }
+ }
+
+ /* Not found - we need to create a new entry */
+ entry = (struct key_mem_cache *)calloc(1, sizeof(struct key_mem_cache));
+ if (entry == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(struct key_mem_cache));
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ entry->tcs_handle = tcs_handle;
+ if (tpm_handle != NULL_TPM_HANDLE)
+ entry->time_stamp = getNextTimeStamp();
+
+ entry->tpm_handle = tpm_handle;
+
+ if (!key_blob)
+ goto add;
+
+ /* allocate space for the blob */
+ entry->blob = calloc(1, sizeof(TSS_KEY));
+ if (entry->blob == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(TSS_KEY));
+ free(entry);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ memcpy(entry->blob, key_blob, sizeof(TSS_KEY));
+
+ /* allocate space for the key parameters if necessary */
+ if (key_blob->algorithmParms.parmSize) {
+ BYTE *tmp_parms = (BYTE *)malloc(key_blob->algorithmParms.parmSize);
+ if (tmp_parms == NULL) {
+ LogError("malloc of %u bytes failed.", key_blob->algorithmParms.parmSize);
+ free(entry->blob);
+ free(entry);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ memcpy(tmp_parms, key_blob->algorithmParms.parms, key_blob->algorithmParms.parmSize);
+ entry->blob->algorithmParms.parms = tmp_parms;
+ }
+ entry->blob->algorithmParms.parmSize = key_blob->algorithmParms.parmSize;
+
+ /* allocate space for the public key */
+ if (key_blob->pubKey.keyLength > 0) {
+ entry->blob->pubKey.key = (BYTE *)malloc(key_blob->pubKey.keyLength);
+ if (entry->blob->pubKey.key == NULL) {
+ LogError("malloc of %u bytes failed.", key_blob->pubKey.keyLength);
+ free(entry->blob->algorithmParms.parms);
+ free(entry->blob);
+ free(entry);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ memcpy(entry->blob->pubKey.key, key_blob->pubKey.key, key_blob->pubKey.keyLength);
+ }
+ entry->blob->pubKey.keyLength = key_blob->pubKey.keyLength;
+
+ /* allocate space for the PCR info */
+ if (key_blob->PCRInfoSize > 0) {
+ entry->blob->PCRInfo = (BYTE *)malloc(key_blob->PCRInfoSize);
+ if (entry->blob->PCRInfo == NULL) {
+ LogError("malloc of %u bytes failed.", key_blob->PCRInfoSize);
+ free(entry->blob->pubKey.key);
+ free(entry->blob->algorithmParms.parms);
+ free(entry->blob);
+ free(entry);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ memcpy(entry->blob->PCRInfo, key_blob->PCRInfo, key_blob->PCRInfoSize);
+ }
+ entry->blob->PCRInfoSize = key_blob->PCRInfoSize;
+
+ /* allocate space for the encData if necessary */
+ if (key_blob->encSize > 0) {
+ entry->blob->encData = (BYTE *)malloc(key_blob->encSize);
+ if (entry->blob->encData == NULL) {
+ LogError("malloc of %u bytes failed.", key_blob->encSize);
+ free(entry->blob->PCRInfo);
+ free(entry->blob->pubKey.key);
+ free(entry->blob->algorithmParms.parms);
+ free(entry->blob);
+ free(entry);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ memcpy(entry->blob->encData, key_blob->encData, key_blob->encSize);
+ }
+ entry->blob->encSize = key_blob->encSize;
+add:
+ /* add to the front of the list */
+ entry->next = key_mem_cache_head;
+ if (key_mem_cache_head) {
+ /* set the reference count to 0 initially for all keys not being the SRK. Up
+ * the call chain, a reference to this mem cache entry will be set in the
+ * context object of the calling context and this reference count will be
+ * incremented there. */
+ entry->ref_cnt = 0;
+
+ key_mem_cache_head->prev = entry;
+ } else {
+ /* if we are the SRK, initially set the reference count to 1, so that it is
+ * always seen as loaded in the TPM. */
+ entry->ref_cnt = 1;
+ }
+ key_mem_cache_head = entry;
+
+ return TSS_SUCCESS;
+}
+
+/* caller must lock the mem cache before calling! */
+TSS_RESULT
+mc_remove_entry(TCS_KEY_HANDLE tcs_handle)
+{
+ struct key_mem_cache *cur;
+
+ for (cur = key_mem_cache_head; cur; cur = cur->next) {
+ if (cur->tcs_handle == tcs_handle) {
+ if (cur->blob) {
+ destroy_key_refs(cur->blob);
+ free(cur->blob);
+ }
+
+ if (cur->prev != NULL)
+ cur->prev->next = cur->next;
+ if (cur->next != NULL)
+ cur->next->prev = cur->prev;
+
+ if (cur == key_mem_cache_head)
+ key_mem_cache_head = cur->next;
+ free(cur);
+
+ return TSS_SUCCESS;
+ }
+ }
+
+ return TCSERR(TSS_E_FAIL);
+}
+
+TSS_RESULT
+mc_add_entry_init(TCS_KEY_HANDLE tcs_handle,
+ TCPA_KEY_HANDLE tpm_handle,
+ TSS_KEY *key_blob,
+ TSS_UUID *uuid)
+{
+ struct key_mem_cache *entry, *tmp;
+
+ /* Make sure the cache doesn't already have an entry for this key */
+ MUTEX_LOCK(mem_cache_lock);
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ if (tcs_handle == tmp->tcs_handle) {
+ mc_remove_entry(tcs_handle);
+ }
+ }
+ MUTEX_UNLOCK(mem_cache_lock);
+
+ /* Not found - we need to create a new entry */
+ entry = (struct key_mem_cache *)calloc(1, sizeof(struct key_mem_cache));
+ if (entry == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(struct key_mem_cache));
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ entry->tcs_handle = tcs_handle;
+ if (tpm_handle != NULL_TPM_HANDLE)
+ entry->time_stamp = getNextTimeStamp();
+
+ entry->tpm_handle = tpm_handle;
+
+ if (key_blob) {
+ /* allocate space for the blob */
+ entry->blob = malloc(sizeof(TSS_KEY));
+ if (entry->blob == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(TSS_KEY));
+ free(entry);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ memcpy(entry->blob, key_blob, sizeof(TSS_KEY));
+
+ /* allocate space for the key parameters if necessary */
+ if (key_blob->algorithmParms.parmSize) {
+ BYTE *tmp_parms = (BYTE *)malloc(key_blob->algorithmParms.parmSize);
+ if (tmp_parms == NULL) {
+ LogError("malloc of %u bytes failed.",
+ key_blob->algorithmParms.parmSize);
+ free(entry->blob);
+ free(entry);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ memcpy(tmp_parms, key_blob->algorithmParms.parms,
+ key_blob->algorithmParms.parmSize);
+ entry->blob->algorithmParms.parms = tmp_parms;
+ }
+
+ /* allocate space for the public key */
+ entry->blob->pubKey.key = (BYTE *)malloc(key_blob->pubKey.keyLength);
+ if (entry->blob->pubKey.key == NULL) {
+ LogError("malloc of %u bytes failed.", key_blob->pubKey.keyLength);
+ free(entry->blob);
+ free(entry);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ memcpy(entry->blob->pubKey.key, key_blob->pubKey.key, key_blob->pubKey.keyLength);
+
+ /* allocate space for the encData if necessary */
+ if (key_blob->encSize != 0) {
+ entry->blob->encData = (BYTE *)malloc(key_blob->encSize);
+ if (entry->blob->encData == NULL) {
+ LogError("malloc of %u bytes failed.", key_blob->encSize);
+ free(entry->blob->pubKey.key);
+ free(entry->blob);
+ free(entry);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ memcpy(entry->blob->encData, key_blob->encData, key_blob->encSize);
+ }
+ entry->blob->encSize = key_blob->encSize;
+ }
+
+ memcpy(&entry->uuid, uuid, sizeof(TSS_UUID));
+
+ MUTEX_LOCK(mem_cache_lock);
+
+ entry->next = key_mem_cache_head;
+ if (key_mem_cache_head)
+ key_mem_cache_head->prev = entry;
+
+ entry->ref_cnt = 1;
+ key_mem_cache_head = entry;
+ MUTEX_UNLOCK(mem_cache_lock);
+
+ return TSS_SUCCESS;
+}
+
+/* only called from evict key paths, so no locking */
+TSS_RESULT
+mc_set_slot_by_slot(TCPA_KEY_HANDLE old_handle, TCPA_KEY_HANDLE new_handle)
+{
+ struct key_mem_cache *tmp;
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ if (tmp->tpm_handle == old_handle) {
+ LogDebugFn("Set TCS key 0x%x, old TPM handle: 0x%x "
+ "new TPM handle: 0x%x", tmp->tcs_handle,
+ old_handle, new_handle);
+ if (new_handle == NULL_TPM_HANDLE)
+ tmp->time_stamp = 0;
+ else
+ tmp->time_stamp = getNextTimeStamp();
+ tmp->tpm_handle = new_handle;
+ return TSS_SUCCESS;
+ }
+ }
+
+ return TCSERR(TSS_E_FAIL);
+}
+
+/* only called from load key paths, so no locking */
+TSS_RESULT
+mc_set_slot_by_handle(TCS_KEY_HANDLE tcs_handle, TCPA_KEY_HANDLE tpm_handle)
+{
+ struct key_mem_cache *tmp;
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebug("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (tmp->tcs_handle == tcs_handle) {
+ if (tpm_handle == NULL_TPM_HANDLE)
+ tmp->time_stamp = 0;
+ else
+ tmp->time_stamp = getNextTimeStamp();
+ tmp->tpm_handle = tpm_handle;
+ return TSS_SUCCESS;
+ }
+ }
+
+ return TCSERR(TSS_E_FAIL);
+}
+
+/* the beginnings of a key manager start here ;-) */
+
+TSS_RESULT
+key_mgr_evict(TCS_CONTEXT_HANDLE hContext, TCS_KEY_HANDLE hKey)
+{
+ TSS_RESULT result = TCS_SUCCESS;
+
+ if ((result = ctx_remove_key_loaded(hContext, hKey)))
+ return result;
+
+ if ((result = key_mgr_dec_ref_count(hKey)))
+ return result;
+
+ key_mgr_ref_count();
+
+ return result;
+}
+
+TSS_RESULT
+key_mgr_load_by_blob(TCS_CONTEXT_HANDLE hContext, TCS_KEY_HANDLE hUnwrappingKey,
+ UINT32 cWrappedKeyBlob, BYTE *rgbWrappedKeyBlob,
+ TPM_AUTH *pAuth, TCS_KEY_HANDLE *phKeyTCSI, TCS_KEY_HANDLE *phKeyHMAC)
+{
+ TSS_RESULT result;
+
+ /* Check that auth for the parent key is loaded outside the mem_cache_lock. We have to do
+ * this here because if the TPM can't process this request right now, the thread could be
+ * put to sleep while holding the mem_cache_lock, which would result in a deadlock */
+ if (pAuth) {
+ if ((result = auth_mgr_check(hContext, &pAuth->AuthHandle)))
+ return result;
+ }
+
+ MUTEX_LOCK(mem_cache_lock);
+
+ if (TPM_VERSION_IS(1,2)) {
+ result = TCSP_LoadKey2ByBlob_Internal(hContext, hUnwrappingKey, cWrappedKeyBlob,
+ rgbWrappedKeyBlob, pAuth, phKeyTCSI);
+ } else {
+ result = TCSP_LoadKeyByBlob_Internal(hContext, hUnwrappingKey, cWrappedKeyBlob,
+ rgbWrappedKeyBlob, pAuth, phKeyTCSI,
+ phKeyHMAC);
+ }
+
+ MUTEX_UNLOCK(mem_cache_lock);
+
+ return result;
+}
+
+/* create a reference to one key. This is called from the key_mgr_load_*
+ * functions only, so no locking is done.
+ */
+TSS_RESULT
+key_mgr_inc_ref_count(TCS_KEY_HANDLE key_handle)
+{
+ struct key_mem_cache *cur;
+
+ for (cur = key_mem_cache_head; cur; cur = cur->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x", cur->tcs_handle);
+ if (cur->tcs_handle == key_handle) {
+ cur->ref_cnt++;
+ return TSS_SUCCESS;
+ }
+ }
+
+ return TCSERR(TSS_E_FAIL);
+}
+
+/* de-reference one key. This is called by the context routines, so
+ * locking is necessary.
+ */
+TSS_RESULT
+key_mgr_dec_ref_count(TCS_KEY_HANDLE key_handle)
+{
+ struct key_mem_cache *cur;
+
+ MUTEX_LOCK(mem_cache_lock);
+
+ for (cur = key_mem_cache_head; cur; cur = cur->next) {
+ if (cur->tcs_handle == key_handle) {
+ cur->ref_cnt--;
+ LogDebugFn("decrementing ref cnt for key 0x%x",
+ key_handle);
+ MUTEX_UNLOCK(mem_cache_lock);
+ return TSS_SUCCESS;
+ }
+ }
+
+ MUTEX_UNLOCK(mem_cache_lock);
+ return TCSERR(TSS_E_FAIL);
+}
+
+/* run through the global list and free any keys with reference counts of 0 */
+void
+key_mgr_ref_count()
+{
+ struct key_mem_cache *tmp, *cur;
+
+ MUTEX_LOCK(mem_cache_lock);
+
+ for (cur = key_mem_cache_head; cur;) {
+ if (cur->ref_cnt == 0) {
+ if (cur->tpm_handle != NULL_TPM_HANDLE) {
+ LogDebugFn("Key 0x%x being freed from TPM", cur->tpm_handle);
+ internal_EvictByKeySlot(cur->tpm_handle);
+ }
+ LogDebugFn("Key 0x%x being freed", cur->tcs_handle);
+ if (cur->blob) {
+ destroy_key_refs(cur->blob);
+ free(cur->blob);
+ }
+ if (cur->prev != NULL)
+ cur->prev->next = cur->next;
+ if (cur->next != NULL)
+ cur->next->prev = cur->prev;
+
+ tmp = cur;
+ if (cur == key_mem_cache_head)
+ key_mem_cache_head = cur->next;
+ cur = cur->next;
+ free(tmp);
+ } else {
+ cur = cur->next;
+ }
+ }
+
+ MUTEX_UNLOCK(mem_cache_lock);
+}
+
+/* only called from load key paths, so no locking */
+TCPA_KEY_HANDLE
+mc_get_slot_by_handle(TCS_KEY_HANDLE tcs_handle)
+{
+ struct key_mem_cache *tmp;
+ TCS_KEY_HANDLE ret;
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (tmp->tcs_handle == tcs_handle) {
+ ret = tmp->tpm_handle;
+ return ret;
+ }
+ }
+
+ LogDebugFn("returning NULL_TPM_HANDLE");
+ return NULL_TPM_HANDLE;
+}
+
+/* called from functions outside the load key path */
+TCPA_KEY_HANDLE
+mc_get_slot_by_handle_lock(TCS_KEY_HANDLE tcs_handle)
+{
+ struct key_mem_cache *tmp;
+ TCS_KEY_HANDLE ret;
+
+ MUTEX_LOCK(mem_cache_lock);
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (tmp->tcs_handle == tcs_handle) {
+ ret = tmp->tpm_handle;
+ MUTEX_UNLOCK(mem_cache_lock);
+ return ret;
+ }
+ }
+
+ MUTEX_UNLOCK(mem_cache_lock);
+ LogDebugFn("returning NULL_TPM_HANDLE");
+ return NULL_TPM_HANDLE;
+}
+
+/* only called from load key paths, so no locking */
+TCPA_KEY_HANDLE
+mc_get_slot_by_pub(TCPA_STORE_PUBKEY *pub)
+{
+ struct key_mem_cache *tmp;
+ TCPA_KEY_HANDLE ret;
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (tmp->blob &&
+ !memcmp(tmp->blob->pubKey.key, pub->key, pub->keyLength)) {
+ ret = tmp->tpm_handle;
+ return ret;
+ }
+ }
+
+ LogDebugFn("returning NULL_TPM_HANDLE");
+ return NULL_TPM_HANDLE;
+}
+
+/* Check the mem cache for a key with public key pub. If a parent TCS key handle
+ * is passed in, make sure the parent of the key find matches it, else return
+ * key not found */
+/* only called from load key paths, so no locking */
+TCS_KEY_HANDLE
+mc_get_handle_by_pub(TCPA_STORE_PUBKEY *pub, TCS_KEY_HANDLE parent)
+{
+ struct key_mem_cache *tmp;
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (tmp->blob &&
+ pub->keyLength == tmp->blob->pubKey.keyLength &&
+ !memcmp(tmp->blob->pubKey.key, pub->key, pub->keyLength)) {
+ if (parent) {
+ if (!tmp->parent)
+ continue;
+ if (parent == tmp->parent->tcs_handle)
+ return tmp->tcs_handle;
+ } else
+ return tmp->tcs_handle;
+ }
+ }
+
+ LogDebugFn("returning NULL_TCS_HANDLE");
+ return NULL_TCS_HANDLE;
+}
+
+/* only called from load key paths, so no locking */
+TCPA_STORE_PUBKEY *
+mc_get_parent_pub_by_pub(TCPA_STORE_PUBKEY *pub)
+{
+ struct key_mem_cache *tmp;
+ TCPA_STORE_PUBKEY *ret = NULL;
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (tmp->tcs_handle == TPM_KEYHND_SRK) {
+ LogDebugFn("skipping the SRK");
+ continue;
+ }
+ if (tmp->blob &&
+ !memcmp(tmp->blob->pubKey.key, pub->key, pub->keyLength)) {
+ if (tmp->parent && tmp->parent->blob) {
+ ret = &tmp->parent->blob->pubKey;
+ LogDebugFn("Success");
+ } else {
+ LogError("parent pointer not set in key mem cache object w/ TCS "
+ "handle: 0x%x", tmp->tcs_handle);
+ }
+ return ret;
+ }
+ }
+
+ LogDebugFn("returning NULL TCPA_STORE_PUBKEY");
+ return NULL;
+}
+
+/* only called from load key paths, so no locking */
+TSS_RESULT
+mc_get_blob_by_pub(TCPA_STORE_PUBKEY *pub, TSS_KEY **ret_key)
+{
+ struct key_mem_cache *tmp;
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (tmp->blob &&
+ !memcmp(tmp->blob->pubKey.key, pub->key, pub->keyLength)) {
+ *ret_key = tmp->blob;
+ return TSS_SUCCESS;
+ }
+ }
+
+ LogDebugFn("returning TSS_E_FAIL");
+ return TCSERR(TSS_E_FAIL);
+}
+
+/* only called from load key paths, so no locking */
+TCS_KEY_HANDLE
+mc_get_handle_by_slot(TCPA_KEY_HANDLE tpm_handle)
+{
+ struct key_mem_cache *tmp;
+ TCS_KEY_HANDLE ret;
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (tmp->tpm_handle == tpm_handle) {
+ ret = tmp->tcs_handle;
+ return ret;
+ }
+ }
+
+ return NULL_TCS_HANDLE;
+}
+
+/* only called from load key paths, so no locking */
+TSS_RESULT
+mc_update_time_stamp(TCPA_KEY_HANDLE tpm_handle)
+{
+ struct key_mem_cache *tmp;
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (tmp->tpm_handle == tpm_handle) {
+ tmp->time_stamp = getNextTimeStamp();
+ return TSS_SUCCESS;
+ }
+ }
+
+ return TCSERR(TSS_E_FAIL);
+}
+
+/* Right now this evicts the LRU key assuming it's not the parent */
+TSS_RESULT
+evictFirstKey(TCS_KEY_HANDLE parent_tcs_handle)
+{
+ struct key_mem_cache *tmp;
+ TCS_KEY_HANDLE tpm_handle_to_evict = NULL_TPM_HANDLE;
+ UINT32 smallestTimeStamp = ~(0U); /* largest */
+ TSS_RESULT result;
+ UINT32 count;
+
+ /* First, see if there are any known keys worth evicting */
+ if ((result = clearUnknownKeys(InternalContext, &count)))
+ return result;
+
+ if (count > 0) {
+ LogDebugFn("Evicted %u unknown keys", count);
+ return TSS_SUCCESS;
+ }
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ if (tmp->tpm_handle != NULL_TPM_HANDLE && /* not already evicted */
+ tmp->tpm_handle != SRK_TPM_HANDLE && /* not the srk */
+ tmp->tcs_handle != parent_tcs_handle && /* not my parent */
+ tmp->time_stamp < smallestTimeStamp) { /* is the smallest time
+ stamp so far */
+ tpm_handle_to_evict = tmp->tpm_handle;
+ smallestTimeStamp = tmp->time_stamp;
+ }
+ }
+
+ if (tpm_handle_to_evict != NULL_TCS_HANDLE) {
+ if ((result = internal_EvictByKeySlot(tpm_handle_to_evict)))
+ return result;
+
+ LogDebugFn("Evicted key w/ TPM handle 0x%x", tpm_handle_to_evict);
+ result = mc_set_slot_by_slot(tpm_handle_to_evict, NULL_TPM_HANDLE);
+ } else
+ return TSS_SUCCESS;
+
+ return result;
+}
+
+TSS_BOOL
+isKeyLoaded(TCPA_KEY_HANDLE keySlot)
+{
+ UINT64 offset;
+ UINT32 i;
+ TCPA_KEY_HANDLE_LIST keyList;
+ UINT32 respSize;
+ BYTE *resp;
+ TSS_RESULT result;
+
+ if (keySlot == SRK_TPM_HANDLE) {
+ return TRUE;
+ }
+
+ if ((result = TCSP_GetCapability_Internal(InternalContext, TCPA_CAP_KEY_HANDLE, 0, NULL,
+ &respSize, &resp)))
+ goto not_loaded;
+
+ offset = 0;
+ UnloadBlob_KEY_HANDLE_LIST(&offset, resp, &keyList);
+ free(resp);
+ for (i = 0; i < keyList.loaded; i++) {
+ LogDebugFn("loaded TPM key handle: 0x%x", keyList.handle[i]);
+ if (keyList.handle[i] == keySlot) {
+ free(keyList.handle);
+ return TRUE;
+ }
+ }
+
+ free(keyList.handle);
+
+not_loaded:
+ LogDebugFn("Key is not loaded, changing slot");
+ mc_set_slot_by_slot(keySlot, NULL_TPM_HANDLE);
+ return FALSE;
+}
+
+/* all calls to LoadKeyShim are inside locks */
+TSS_RESULT
+LoadKeyShim(TCS_CONTEXT_HANDLE hContext, TCPA_STORE_PUBKEY *pubKey,
+ TSS_UUID *parentUuid, TCPA_KEY_HANDLE *slotOut)
+{
+
+ TCPA_STORE_PUBKEY *parentPub;
+ UINT32 result;
+ TCPA_KEY_HANDLE keySlot;
+ TCPA_KEY_HANDLE parentSlot;
+ TCS_KEY_HANDLE tcsKeyHandle;
+ TSS_KEY *myKey;
+ UINT64 offset;
+ TCS_KEY_HANDLE parentHandle;
+ BYTE keyBlob[1024];
+
+ LogDebugFn("calling mc_get_slot_by_pub");
+
+ /* If I'm loaded, then no point being here. Get the slot and return */
+ keySlot = mc_get_slot_by_pub(pubKey);
+ if (keySlot != NULL_TPM_HANDLE && isKeyLoaded(keySlot)) {
+ *slotOut = keySlot;
+ return TSS_SUCCESS;
+ }
+
+ /*
+ * Before proceeding, the parent must be loaded.
+ * If the parent is registered, then it can be loaded by UUID.
+ * If not, then the shim will be called to load it's parent and then try
+ * to load it based on the persistent store.
+ */
+
+ LogDebugFn("calling mc_get_parent_pub_by_pub");
+ /* Check if the Key is in the memory cache */
+ if ((parentPub = mc_get_parent_pub_by_pub(pubKey)) == NULL) {
+#if 0
+ LogDebugFn("parentPub is NULL");
+ /* If parentUUID is not handed in, then this key was never loaded and isn't reg'd */
+ if (parentUuid == NULL)
+ return TCSERR(TCS_E_KM_LOADFAILED);
+
+ LogDebugFn("calling TCSP_LoadKeyByUUID_Internal");
+ /* This will try to load my parent by UUID */
+ if ((result = TCSP_LoadKeyByUUID_Internal(hContext, parentUuid, NULL, &parentSlot)))
+ return result;
+#else
+ return TCSERR(TCS_E_KM_LOADFAILED);
+#endif
+ } else {
+ LogDebugFn("calling LoadKeyShim");
+ if ((result = LoadKeyShim(hContext, parentPub, NULL, &parentSlot)))
+ return result;
+ }
+
+ /*
+ * Now that the parent is loaded, I can load myself.
+ * If I'm registered, that's by UUID. If I'm not,
+ * that's by blob. If there is no persistent storage data, then I cannot be
+ * loaded by blob. The user must have some point loaded this key manually.
+ */
+
+ /* check the mem cache */
+ if (mc_get_blob_by_pub(pubKey, &myKey) == TSS_SUCCESS) {
+ parentHandle = mc_get_handle_by_slot(parentSlot);
+ if (parentHandle == 0)
+ return TCSERR(TCS_E_KM_LOADFAILED);
+
+ offset = 0;
+ LoadBlob_TSS_KEY(&offset, keyBlob, myKey);
+ if (TPM_VERSION_IS(1,2))
+ result = TCSP_LoadKey2ByBlob_Internal(hContext,
+ parentHandle, offset,
+ keyBlob, NULL,
+ &tcsKeyHandle);
+ else
+ result = TCSP_LoadKeyByBlob_Internal(hContext,
+ parentHandle, offset,
+ keyBlob, NULL,
+ &tcsKeyHandle, slotOut);
+ if (result)
+ return result;
+
+ return ctx_mark_key_loaded(hContext, tcsKeyHandle);
+#if TSS_BUILD_PS
+ } else {
+ TSS_UUID *uuid;
+
+ /* check registered */
+ if (ps_is_pub_registered(pubKey) == FALSE)
+ return TCSERR(TCS_E_KM_LOADFAILED);
+ //uuid = mc_get_uuid_by_pub(pubKey); // XXX pub is not in MC
+ if ((result = ps_get_uuid_by_pub(pubKey, &uuid)))
+ return result;
+
+ if ((result = TCSP_LoadKeyByUUID_Internal(hContext, uuid, NULL, &tcsKeyHandle))) {
+ free(uuid);
+ return result;
+ }
+ free(uuid);
+ *slotOut = mc_get_slot_by_handle(tcsKeyHandle);
+
+ return ctx_mark_key_loaded(hContext, tcsKeyHandle);
+#endif
+ }
+
+ return TCSERR(TCS_E_KM_LOADFAILED);
+}
+
+TSS_RESULT
+owner_evict_init()
+{
+ TSS_RESULT result = TSS_SUCCESS;
+ TCPA_KEY_HANDLE_LIST keyList = { 0, NULL };
+ BYTE *respData = NULL, ownerEvictCtr = 0;
+ UINT32 respDataSize = 0, i;
+ UINT64 offset = 0;
+
+ /* If we're a 1.1 TPM, we can exit immediately since only 1.2+ supports owner evict */
+ if (TPM_VERSION_IS(1,1))
+ return TSS_SUCCESS;
+
+ if ((result = TCSP_GetCapability_Internal(InternalContext, TPM_CAP_KEY_HANDLE, 0, NULL,
+ &respDataSize, &respData)))
+ return result;
+
+ if ((result = UnloadBlob_KEY_HANDLE_LIST(&offset, respData, &keyList))) {
+ free(respData);
+ return result;
+ }
+
+ free(respData);
+ for (i = 0; i < keyList.loaded; i++) {
+ UINT64 offset = 0;
+ UINT32 keyHandle;
+
+ LoadBlob_UINT32(&offset, keyList.handle[i], (BYTE *)&keyHandle);
+ /* get the ownerEvict flag for this key handle */
+ result = TCSP_GetCapability_Internal(InternalContext, TPM_CAP_KEY_STATUS,
+ sizeof(UINT32), (BYTE *)&keyHandle,
+ &respDataSize, &respData);
+ /* special case, invalid keys are automatically evicted later */
+ if (result == TPM_E_INVALID_KEYHANDLE)
+ continue;
+ if (result != TSS_SUCCESS) {
+ free(keyList.handle);
+ return result;
+ }
+
+ if (*(TPM_BOOL *)respData == TRUE) {
+ TSS_UUID uuid = TSS_UUID_OWNEREVICT(ownerEvictCtr);
+
+ LogDebugFn("Found an owner evict key, assigned uuid %hhu", ownerEvictCtr);
+ if ((result = mc_add_entry_init(getNextTcsKeyHandle(), keyList.handle[i],
+ NULL, &uuid))) {
+ free(keyList.handle);
+ return result;
+ }
+ ownerEvictCtr++;
+ }
+ }
+
+ return result;
+}
+
+/* find next lowest OWNEREVICT uuid */
+TSS_RESULT
+mc_find_next_ownerevict_uuid(TSS_UUID *uuid)
+{
+ TCS_KEY_HANDLE tmpKey;
+ TCPA_KEY_HANDLE tmpSlot;
+ UINT16 seed = 0;
+ TSS_RESULT result = TCSERR(TSS_E_FAIL);
+
+ MUTEX_LOCK(mem_cache_lock);
+
+ for (seed = 0; seed <= 255; seed++) {
+ TSS_UUID tmpUuid = TSS_UUID_OWNEREVICT(seed);
+
+ /* if UUID is found, continue on, trying the next UUID */
+ if (!mc_get_handles_by_uuid(&tmpUuid, &tmpKey, &tmpSlot))
+ continue;
+
+ /* UUID is not found, so its the first one available */
+ memcpy(uuid, &tmpUuid, sizeof(TSS_UUID));
+ result = TSS_SUCCESS;
+ break;
+ }
+
+ MUTEX_UNLOCK(mem_cache_lock);
+ return result;
+}
+
+TSS_RESULT
+mc_set_uuid(TCS_KEY_HANDLE tcs_handle, TSS_UUID *uuid)
+{
+ struct key_mem_cache *tmp;
+ TSS_RESULT result = TCSERR(TSS_E_FAIL);
+
+ MUTEX_LOCK(mem_cache_lock);
+
+ LogDebugFn("looking for 0x%x", tcs_handle);
+
+ for (tmp = key_mem_cache_head; tmp; tmp = tmp->next) {
+ LogDebugFn("TCSD mem_cached handle: 0x%x", tmp->tcs_handle);
+ if (tmp->tcs_handle == tcs_handle) {
+ LogDebugFn("Handle found, re-setting UUID");
+ memcpy(&tmp->uuid, uuid, sizeof(TSS_UUID));
+ result = TSS_SUCCESS;
+ break;
+ }
+ }
+ MUTEX_UNLOCK(mem_cache_lock);
+
+ return result;
+}
diff --git a/src/tcs/tcs_key_ps.c b/src/tcs/tcs_key_ps.c
new file mode 100644
index 0000000..0ea28c1
--- /dev/null
+++ b/src/tcs/tcs_key_ps.c
@@ -0,0 +1,367 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsps.h"
+#include "req_mgr.h"
+
+
+TSS_RESULT
+ps_init_disk_cache(void)
+{
+ int fd;
+ TSS_RESULT rc;
+
+ MUTEX_INIT(disk_cache_lock);
+
+ if ((fd = get_file()) < 0)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if ((rc = init_disk_cache(fd)))
+ return rc;
+
+ /* this is temporary, to clear out a PS file from trousers
+ * versions before 0.2.1 */
+ if ((rc = clean_disk_cache(fd)))
+ return rc;
+
+ put_file(fd);
+ return TSS_SUCCESS;
+}
+
+void
+ps_close_disk_cache(void)
+{
+ int fd;
+
+ if ((fd = get_file()) < 0) {
+ LogError("get_file() failed while trying to close disk cache.");
+ return;
+ }
+
+ close_disk_cache(fd);
+
+ put_file(fd);
+}
+
+TSS_BOOL
+ps_is_key_registered(TCPA_STORE_PUBKEY *pub)
+{
+ TSS_UUID *uuid;
+ int fd;
+ TSS_RESULT rc;
+ TSS_BOOL is_reg = FALSE;
+
+ if ((fd = get_file()) < 0)
+ return FALSE;
+
+ if ((rc = psfile_get_uuid_by_pub(fd, pub, &uuid))) {
+ put_file(fd);
+ return FALSE;
+ }
+
+ put_file(fd);
+
+ if ((isUUIDRegistered(uuid, &is_reg)))
+ is_reg = FALSE;
+
+ free(uuid);
+ return is_reg;
+}
+
+TSS_RESULT
+getParentUUIDByUUID(TSS_UUID *uuid, TSS_UUID *ret_uuid)
+{
+ struct key_disk_cache *disk_tmp;
+
+ /* check the registered key disk cache */
+ MUTEX_LOCK(disk_cache_lock);
+
+ for (disk_tmp = key_disk_cache_head; disk_tmp; disk_tmp = disk_tmp->next) {
+ if ((disk_tmp->flags & CACHE_FLAG_VALID) &&
+ !memcmp(&disk_tmp->uuid, uuid, sizeof(TSS_UUID))) {
+ memcpy(ret_uuid, &disk_tmp->parent_uuid, sizeof(TSS_UUID));
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TSS_SUCCESS;
+ }
+ }
+ MUTEX_UNLOCK(disk_cache_lock);
+
+ return TCSERR(TSS_E_FAIL);
+}
+
+TSS_RESULT
+isUUIDRegistered(TSS_UUID *uuid, TSS_BOOL *is_reg)
+{
+ struct key_disk_cache *disk_tmp;
+
+ /* check the registered key disk cache */
+ MUTEX_LOCK(disk_cache_lock);
+
+ for (disk_tmp = key_disk_cache_head; disk_tmp; disk_tmp = disk_tmp->next) {
+ if ((disk_tmp->flags & CACHE_FLAG_VALID) &&
+ !memcmp(&disk_tmp->uuid, uuid, sizeof(TSS_UUID))) {
+ *is_reg = TRUE;
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TSS_SUCCESS;
+ }
+ }
+ MUTEX_UNLOCK(disk_cache_lock);
+ *is_reg = FALSE;
+
+ return TSS_SUCCESS;
+}
+
+void
+disk_cache_shift(struct key_disk_cache *c)
+{
+ UINT32 key_size, offset;
+ struct key_disk_cache *tmp = key_disk_cache_head;
+
+ /* offset is the end of the key location in the file */
+ offset = TSSPS_VENDOR_DATA_OFFSET(c) + c->vendor_data_size;
+ /* key_size is the size of the key entry on disk */
+ key_size = offset - TSSPS_UUID_OFFSET(c);
+
+ /* for each disk cache entry, if the data for that entry is at an
+ * offset greater than the key beign removed, then the entry needs to
+ * be decremented by the size of key's disk footprint (the key_size
+ * variable) */
+ while (tmp) {
+ if (tmp->offset >= offset) {
+ tmp->offset -= key_size;
+ }
+
+ tmp = tmp->next;
+ }
+}
+
+TSS_RESULT
+ps_remove_key(TSS_UUID *uuid)
+{
+ struct key_disk_cache *tmp, *prev = NULL;
+ TSS_RESULT rc;
+ int fd = -1;
+
+ MUTEX_LOCK(disk_cache_lock);
+ tmp = key_disk_cache_head;
+
+ for (; tmp; prev = tmp, tmp = tmp->next) {
+ if ((tmp->flags & CACHE_FLAG_VALID) &&
+ !memcmp(uuid, &tmp->uuid, sizeof(TSS_UUID))) {
+ if ((fd = get_file()) < 0) {
+ rc = TCSERR(TSS_E_INTERNAL_ERROR);
+ break;
+ }
+
+ rc = psfile_remove_key(fd, tmp);
+
+ put_file(fd);
+
+ /* if moving the file contents around succeeded, then
+ * change the offsets of the keys in the cache in
+ * mem_cache_shift() and remove the key from the
+ * cache. */
+ if (!rc) {
+ disk_cache_shift(tmp);
+ if (prev) {
+ prev->next = tmp->next;
+ } else {
+ key_disk_cache_head = tmp->next;
+ }
+ free(tmp);
+ } else {
+ LogError("Error removing registered key.");
+ }
+
+ MUTEX_UNLOCK(disk_cache_lock);
+ return rc;
+ }
+ }
+
+ MUTEX_UNLOCK(disk_cache_lock);
+
+ return TCSERR(TCSERR(TSS_E_PS_KEY_NOTFOUND));
+}
+
+/*
+ * temporary function to clean out blanked keys from a PS file from
+ * trousers 0.2.0 and before
+ */
+TSS_RESULT
+clean_disk_cache(int fd)
+{
+ struct key_disk_cache *tmp, *prev = NULL;
+ TSS_RESULT rc;
+
+ MUTEX_LOCK(disk_cache_lock);
+ tmp = key_disk_cache_head;
+
+ for (; tmp; prev = tmp, tmp = tmp->next) {
+ if (!(tmp->flags & CACHE_FLAG_VALID)) {
+ rc = psfile_remove_key(fd, tmp);
+
+ /* if moving the file contents around succeeded, then
+ * change the offsets of the keys in the cache in
+ * mem_cache_shift() and remove the key from the
+ * cache. */
+ if (!rc) {
+ disk_cache_shift(tmp);
+ if (prev) {
+ prev->next = tmp->next;
+ }
+ free(tmp);
+ } else {
+ LogError("Error removing blank key.");
+ }
+
+ MUTEX_UNLOCK(disk_cache_lock);
+ return rc;
+ }
+ }
+
+ MUTEX_UNLOCK(disk_cache_lock);
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+ps_get_key_by_uuid(TSS_UUID *uuid, BYTE *blob, UINT16 *blob_size)
+{
+ int fd = -1;
+ TSS_RESULT rc = TSS_SUCCESS;
+
+ if ((fd = get_file()) < 0)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ rc = psfile_get_key_by_uuid(fd, uuid, blob, blob_size);
+
+ put_file(fd);
+ return rc;
+}
+
+TSS_RESULT
+ps_get_key_by_cache_entry(struct key_disk_cache *c, BYTE *blob, UINT16 *blob_size)
+{
+ int fd = -1;
+ TSS_RESULT rc = TSS_SUCCESS;
+
+ if ((fd = get_file()) < 0)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ rc = psfile_get_key_by_cache_entry(fd, c, blob, blob_size);
+
+ put_file(fd);
+ return rc;
+}
+
+TSS_RESULT
+ps_get_vendor_data(struct key_disk_cache *c, UINT32 *size, BYTE **data)
+{
+ int fd = -1;
+ TSS_RESULT rc;
+
+ if ((fd = get_file()) < 0)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ rc = psfile_get_vendor_data(fd, c, size, data);
+
+ put_file(fd);
+ return rc;
+}
+
+TSS_RESULT
+ps_is_pub_registered(TCPA_STORE_PUBKEY *key)
+{
+ int fd = -1;
+ TSS_BOOL answer;
+
+ if ((fd = get_file()) < 0)
+ return FALSE;
+
+ if (psfile_is_pub_registered(fd, key, &answer)) {
+ put_file(fd);
+ return FALSE;
+ }
+
+ put_file(fd);
+ return answer;
+}
+
+TSS_RESULT
+ps_get_uuid_by_pub(TCPA_STORE_PUBKEY *pub, TSS_UUID **uuid)
+{
+ int fd = -1;
+ TSS_RESULT ret;
+
+ if ((fd = get_file()) < 0)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ ret = psfile_get_uuid_by_pub(fd, pub, uuid);
+
+ put_file(fd);
+ return ret;
+}
+
+TSS_RESULT
+ps_get_key_by_pub(TCPA_STORE_PUBKEY *pub, UINT32 *size, BYTE **key)
+{
+ int fd = -1;
+ TSS_RESULT ret;
+
+ if ((fd = get_file()) < 0)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ ret = psfile_get_key_by_pub(fd, pub, size, key);
+
+ put_file(fd);
+ return ret;
+}
+
+TSS_RESULT
+ps_write_key(TSS_UUID *uuid, TSS_UUID *parent_uuid, BYTE *vendor_data,
+ UINT32 vendor_size, BYTE *blob, UINT32 blob_size)
+{
+ int fd = -1;
+ TSS_RESULT rc;
+ UINT32 parent_ps;
+ UINT16 short_blob_size = (UINT16)blob_size;
+
+ if ((fd = get_file()) < 0)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ /* this case needed for PS file init. if the key file doesn't yet exist, the
+ * psfile_get_parent_ps_type_by_uuid() call would fail. */
+ if (!memcmp(parent_uuid, &NULL_UUID, sizeof(TSS_UUID))) {
+ parent_ps = TSS_PS_TYPE_SYSTEM;
+ } else {
+ if ((rc = psfile_get_ps_type_by_uuid(fd, parent_uuid, &parent_ps)))
+ return rc;
+ }
+
+ rc = psfile_write_key(fd, uuid, parent_uuid, &parent_ps, vendor_data,
+ vendor_size, blob, short_blob_size);
+
+ put_file(fd);
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/tcs_migration.c b/src/tcs/tcs_migration.c
new file mode 100644
index 0000000..f653737
--- /dev/null
+++ b/src/tcs/tcs_migration.c
@@ -0,0 +1,51 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2006
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+TSS_RESULT
+UnloadBlob_MIGRATIONKEYAUTH(UINT64 *offset, BYTE *blob, TCPA_MIGRATIONKEYAUTH *mkAuth)
+{
+ TSS_RESULT result;
+
+ if (!mkAuth) {
+ if ((result = UnloadBlob_PUBKEY(offset, blob, NULL)))
+ return result;
+
+ UnloadBlob_UINT16(offset, NULL, blob);
+ UnloadBlob(offset, 20, blob, NULL);
+
+ return TSS_SUCCESS;
+ }
+
+ if ((result = UnloadBlob_PUBKEY(offset, blob, &mkAuth->migrationKey)))
+ return result;
+
+ UnloadBlob_UINT16(offset, &mkAuth->migrationScheme, blob);
+ UnloadBlob(offset, 20, blob, mkAuth->digest.digest);
+
+ return result;
+}
diff --git a/src/tcs/tcs_pbg.c b/src/tcs/tcs_pbg.c
new file mode 100644
index 0000000..39c688c
--- /dev/null
+++ b/src/tcs/tcs_pbg.c
@@ -0,0 +1,2201 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcsps.h"
+#include "tcslog.h"
+
+
+#define TSS_TPM_RSP_BLOB_AUTH_LEN (sizeof(TPM_NONCE) + sizeof(TPM_DIGEST) + sizeof(TPM_BOOL))
+
+TSS_RESULT
+tpm_rsp_parse(TPM_COMMAND_CODE ordinal, BYTE *b, UINT32 len, ...)
+{
+ TSS_RESULT result = TSS_SUCCESS;
+ UINT64 offset1, offset2;
+ va_list ap;
+
+ DBG_ASSERT(ordinal);
+ DBG_ASSERT(b);
+
+ va_start(ap, len);
+
+ switch (ordinal) {
+ case TPM_ORD_ExecuteTransport:
+ {
+ UINT32 *val1 = va_arg(ap, UINT32 *);
+ UINT32 *val2 = va_arg(ap, UINT32 *);
+ UINT32 *len1 = va_arg(ap, UINT32 *);
+ BYTE **blob1 = va_arg(ap, BYTE **);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (auth1 && auth2) {
+ offset1 = offset2 = len - (2 * TSS_TPM_RSP_BLOB_AUTH_LEN);
+ UnloadBlob_Auth(&offset1, b, auth1);
+ UnloadBlob_Auth(&offset1, b, auth2);
+ } else if (auth1) {
+ offset1 = offset2 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth1);
+ } else if (auth2) {
+ offset1 = offset2 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth2);
+ } else
+ offset2 = len;
+
+ offset1 = TSS_TPM_TXBLOB_HDR_LEN;
+ if (val1)
+ UnloadBlob_UINT32(&offset1, val1, b);
+ if (val2)
+ UnloadBlob_UINT32(&offset1, val2, b);
+
+ *len1 = offset2 - offset1;
+ if (*len1) {
+ if ((*blob1 = malloc(*len1)) == NULL) {
+ LogError("malloc of %u bytes failed", *len1);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset1, *len1, b, *blob1);
+ } else
+ *blob1 = NULL;
+
+ break;
+ }
+#ifdef TSS_BUILD_TICK
+ /* TPM BLOB: TPM_CURRENT_TICKS, UINT32, BLOB, optional AUTH */
+ case TPM_ORD_TickStampBlob:
+ {
+ UINT32 *len1 = va_arg(ap, UINT32 *);
+ BYTE **blob1 = va_arg(ap, BYTE **);
+ UINT32 *len2 = va_arg(ap, UINT32 *);
+ BYTE **blob2 = va_arg(ap, BYTE **);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!len1 || !blob1 || !len2 || !blob2) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (auth1) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth1);
+ }
+
+ offset1 = offset2 = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_CURRENT_TICKS(&offset2, b, NULL);
+ *len1 = (UINT32)offset2 - offset1;
+
+ if ((*blob1 = malloc(*len1)) == NULL) {
+ LogError("malloc of %u bytes failed", *len1);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ UnloadBlob(&offset1, *len1, b, *blob1);
+ UnloadBlob_UINT32(&offset1, len2, b);
+
+ if ((*blob2 = malloc(*len2)) == NULL) {
+ LogError("malloc of %u bytes failed", *len2);
+ free(*blob1);
+ *blob1 = NULL;
+ *len1 = 0;
+ *len2 = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset1, *len2, b, *blob2);
+
+ break;
+ }
+#endif
+#ifdef TSS_BUILD_QUOTE
+ /* TPM BLOB: TPM_PCR_COMPOSITE, UINT32, BLOB, 1 optional AUTH
+ * return UINT32*, BYTE**, UINT32*, BYTE**, 1 optional AUTH */
+ case TPM_ORD_Quote:
+ {
+ UINT32 *len1 = va_arg(ap, UINT32 *);
+ BYTE **blob1 = va_arg(ap, BYTE **);
+ UINT32 *len2 = va_arg(ap, UINT32 *);
+ BYTE **blob2 = va_arg(ap, BYTE **);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!len1 || !blob1 || !len2 || !blob2) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (auth1) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth1);
+ }
+
+ offset1 = offset2 = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_PCR_COMPOSITE(&offset2, b, NULL);
+ *len1 = offset2 - offset1;
+
+ if ((*blob1 = malloc(*len1)) == NULL) {
+ LogError("malloc of %u bytes failed", *len1);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset1, *len1, b, *blob1);
+ UnloadBlob_UINT32(&offset1, len2, b);
+
+ if ((*blob2 = malloc(*len2)) == NULL) {
+ LogError("malloc of %u bytes failed", *len2);
+ free(*blob1);
+ *blob1 = NULL;
+ *len1 = 0;
+ *len2 = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset1, *len2, b, *blob2);
+
+ break;
+ }
+#endif
+#ifdef TSS_BUILD_TSS12
+ /* TPM BLOB: TPM_PCR_INFO_SHORT, (UINT32, BLOB,) UINT32, BLOB, 1 optional AUTH */
+ case TPM_ORD_Quote2:
+ {
+ UINT32 *len1 = va_arg(ap, UINT32 *); /* pcrDataSizeOut */
+ BYTE **blob1 = va_arg(ap, BYTE **); /* pcrDataOut */
+ TSS_BOOL *addVersion = va_arg(ap, TSS_BOOL *); /* addVersion */
+ UINT32 *len2 = va_arg(ap, UINT32 *); /* versionInfoSize */
+ BYTE **blob2 = va_arg(ap, BYTE **); /* versionInfo */
+ UINT32 *len3 = va_arg(ap, UINT32 *); /* sigSize */
+ BYTE **blob3 = va_arg(ap, BYTE **); /* sig */
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *); /* privAuth */
+ va_end(ap);
+
+ if (!len1 || !blob1 || !len2 || !blob2 || !len3 || !blob3 || !addVersion) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (auth1) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth1);
+ }
+
+ offset1 = offset2 = TSS_TPM_TXBLOB_HDR_LEN;
+ /* Adjust the offset to take the TPM_PCR_INFO_SHORT size:
+ * need to allocate this size into blob1
+ */
+ UnloadBlob_PCR_INFO_SHORT(&offset2, b, NULL);
+
+ /* Get the size of the TSS_TPM_INFO_SHORT
+ * and copy it into blob1 */
+ *len1 = offset2 - offset1;
+ LogDebugFn("QUOTE2 Core: PCR_INFO_SHORT is %u size", *len1);
+ if ((*blob1 = malloc(*len1)) == NULL) {
+ LogError("malloc of %u bytes failed", *len1);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset1, *len1, b, *blob1); /* TPM_PCR_INFO_SHORT */
+
+ UnloadBlob_UINT32(&offset1, len2,b); /* versionInfoSize */
+ LogDebugFn("QUOTE2 Core: versionInfoSize=%u", *len2);
+ if ((*blob2 = malloc(*len2)) == NULL) {
+ LogError("malloc of %u bytes failed", *len2);
+ free(*blob1);
+ *blob1 = NULL;
+ *len1 = 0;
+ *len2 = 0;
+ *len3 = 0;
+ *blob3 = NULL;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset1, *len2, b, *blob2);
+
+ /* Take the sigSize */
+ UnloadBlob_UINT32(&offset1, len3, b);
+ LogDebugFn("QUOTE2 Core: sigSize=%u", *len3);
+ /* sig */
+ if ((*blob3 = malloc(*len3)) == NULL) {
+ LogError("malloc of %u bytes failed", *len3);
+ free(*blob1);
+ *blob1 = NULL;
+ if (*len2 > 0){
+ free(*blob2);
+ *blob2 = NULL;
+ }
+ *len1 = 0;
+ *len2 = 0;
+ *len3 = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset1, *len3, b, *blob3);
+ break;
+ }
+#endif
+ /* TPM BLOB: TPM_CERTIFY_INFO, UINT32, BLOB, 2 optional AUTHs
+ * return UINT32*, BYTE**, UINT32*, BYTE**, 2 optional AUTHs */
+ case TPM_ORD_CertifyKey:
+ {
+ UINT32 *len1 = va_arg(ap, UINT32 *);
+ BYTE **blob1 = va_arg(ap, BYTE **);
+ UINT32 *len2 = va_arg(ap, UINT32 *);
+ BYTE **blob2 = va_arg(ap, BYTE **);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!len1 || !blob1 || !len2 || !blob2) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (auth1 && auth2) {
+ offset1 = len - (2 * TSS_TPM_RSP_BLOB_AUTH_LEN);
+ UnloadBlob_Auth(&offset1, b, auth1);
+ UnloadBlob_Auth(&offset1, b, auth2);
+ } else if (auth1) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth1);
+ } else if (auth2) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth2);
+ }
+
+ offset1 = offset2 = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_CERTIFY_INFO(&offset2, b, NULL);
+ *len1 = offset2 - offset1;
+
+ if ((*blob1 = malloc(*len1)) == NULL) {
+ LogError("malloc of %u bytes failed", *len1);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset1, *len1, b, *blob1);
+ UnloadBlob_UINT32(&offset1, len2, b);
+
+ if ((*blob2 = malloc(*len2)) == NULL) {
+ LogError("malloc of %u bytes failed", *len2);
+ free(*blob1);
+ *blob1 = NULL;
+ *len1 = 0;
+ *len2 = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset1, *len2, b, *blob2);
+
+ break;
+ }
+#ifdef TSS_BUILD_AUDIT
+ /* TPM_BLOB: TPM_COUNTER_VALUE, DIGEST, DIGEST, UINT32, BLOB, optional AUTH
+ * return: UINT32*, BYTE**, DIGEST*, DIGEST*, UINT32*, BYTE**, optional AUTH */
+ case TPM_ORD_GetAuditDigestSigned:
+ {
+ UINT32 *len1 = va_arg(ap, UINT32 *);
+ BYTE **blob1 = va_arg(ap, BYTE **);
+ TPM_DIGEST *digest1 = va_arg(ap, TPM_DIGEST *);
+ TPM_DIGEST *digest2 = va_arg(ap, TPM_DIGEST *);
+ UINT32 *len2 = va_arg(ap, UINT32 *);
+ BYTE **blob2 = va_arg(ap, BYTE **);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!digest1 || !digest2 || !len1 || !blob1 || !len2 || !blob2) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ offset1 = offset2 = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_COUNTER_VALUE(&offset2, b, NULL);
+ *len1 = offset2 - offset1;
+
+ if ((*blob1 = malloc(*len1)) == NULL) {
+ LogError("malloc of %u bytes failed", *len1);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset1, *len1, b, *blob1);
+
+ UnloadBlob_DIGEST(&offset1, b, digest1);
+ UnloadBlob_DIGEST(&offset1, b, digest2);
+ UnloadBlob_UINT32(&offset1, len2, b);
+
+ if ((*blob2 = malloc(*len2)) == NULL) {
+ LogError("malloc of %u bytes failed", *len2);
+ free(*blob1);
+ *blob1 = NULL;
+ *len1 = 0;
+ *len2 = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset1, *len2, b, *blob2);
+
+ if (auth1)
+ UnloadBlob_Auth(&offset1, b, auth1);
+
+ break;
+ }
+ /* TPM_BLOB: TPM_COUNTER_VALUE, DIGEST, BOOL, UINT32, BLOB
+ * return: DIGEST*, UINT32*, BYTE**, BOOL, UINT32*, BYTE** */
+ case TPM_ORD_GetAuditDigest:
+ {
+ TPM_DIGEST *digest1 = va_arg(ap, TPM_DIGEST *);
+ UINT32 *len1 = va_arg(ap, UINT32 *);
+ BYTE **blob1 = va_arg(ap, BYTE **);
+ TSS_BOOL *bool1 = va_arg(ap, TSS_BOOL *);
+ UINT32 *len2 = va_arg(ap, UINT32 *);
+ BYTE **blob2 = va_arg(ap, BYTE **);
+ va_end(ap);
+
+ if (!digest1 || !len1 || !blob1 || !len2 || !blob2 || !bool1) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ offset1 = offset2 = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_COUNTER_VALUE(&offset2, b, NULL);
+ *len1 = offset2 - offset1;
+
+ if ((*blob1 = malloc(*len1)) == NULL) {
+ LogError("malloc of %u bytes failed", *len1);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset1, *len1, b, *blob1);
+
+ UnloadBlob_DIGEST(&offset1, b, digest1);
+ UnloadBlob_BOOL(&offset1, bool1, b);
+ UnloadBlob_UINT32(&offset1, len2, b);
+
+ if ((*blob2 = malloc(*len2)) == NULL) {
+ LogError("malloc of %u bytes failed", *len2);
+ free(*blob1);
+ *blob1 = NULL;
+ *len1 = 0;
+ *len2 = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset1, *len2, b, *blob2);
+
+ break;
+ }
+#endif
+#ifdef TSS_BUILD_COUNTER
+ /* optional UINT32, TPM_COUNTER_VALUE, optional AUTH */
+ case TPM_ORD_ReadCounter:
+ case TPM_ORD_CreateCounter:
+ case TPM_ORD_IncrementCounter:
+ {
+ UINT32 *val1 = va_arg(ap, UINT32 *);
+ TPM_COUNTER_VALUE *ctr = va_arg(ap, TPM_COUNTER_VALUE *);
+ TPM_AUTH * auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!ctr) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (auth1) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth1);
+ }
+
+ offset1 = TSS_TPM_TXBLOB_HDR_LEN;
+ if (val1)
+ UnloadBlob_UINT32(&offset1, val1, b);
+ UnloadBlob_COUNTER_VALUE(&offset1, b, ctr);
+
+ break;
+ }
+#endif
+ /* TPM BLOB: UINT32, BLOB, UINT32, BLOB, optional AUTH, optional AUTH */
+ case TPM_ORD_CreateMaintenanceArchive:
+ case TPM_ORD_CreateMigrationBlob:
+ case TPM_ORD_Delegate_ReadTable:
+ case TPM_ORD_CMK_CreateBlob:
+ {
+ UINT32 *len1 = va_arg(ap, UINT32 *);
+ BYTE **blob1 = va_arg(ap, BYTE **);
+ UINT32 *len2 = va_arg(ap, UINT32 *);
+ BYTE **blob2 = va_arg(ap, BYTE **);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!len1 || !blob1 || !len2 || !blob2) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (auth1 && auth2) {
+ offset1 = len - (2 * TSS_TPM_RSP_BLOB_AUTH_LEN);
+ UnloadBlob_Auth(&offset1, b, auth1);
+ UnloadBlob_Auth(&offset1, b, auth2);
+ } else if (auth1) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth1);
+ } else if (auth2) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth2);
+ }
+
+ offset1 = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_UINT32(&offset1, len1, b);
+ if ((*blob1 = malloc(*len1)) == NULL) {
+ LogError("malloc of %u bytes failed", *len1);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ UnloadBlob(&offset1, *len1, b, *blob1);
+
+ UnloadBlob_UINT32(&offset1, len2, b);
+ if ((*blob2 = malloc(*len2)) == NULL) {
+ free(*blob1);
+ LogError("malloc of %u bytes failed", *len2);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ UnloadBlob(&offset1, *len2, b, *blob2);
+
+ break;
+ }
+ /* TPM BLOB: BLOB, optional AUTH, AUTH
+ * return: UINT32 *, BYTE **, optional AUTH, AUTH */
+ case TPM_ORD_ActivateIdentity:
+ {
+ UINT32 *len1 = va_arg(ap, UINT32 *);
+ BYTE **blob1 = va_arg(ap, BYTE **);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!len1 || !blob1 || !auth2) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (auth1 && auth2) {
+ offset1 = offset2 = len - (2 * TSS_TPM_RSP_BLOB_AUTH_LEN);
+ UnloadBlob_Auth(&offset1, b, auth1);
+ UnloadBlob_Auth(&offset1, b, auth2);
+ } else if (auth2) {
+ offset1 = offset2 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth2);
+ } else
+ offset2 = len;
+
+ offset1 = TSS_TPM_TXBLOB_HDR_LEN;
+ offset2 -= TSS_TPM_TXBLOB_HDR_LEN;
+ if ((*blob1 = malloc(offset2)) == NULL) {
+ LogError("malloc of %zd bytes failed", (size_t)offset2);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ *len1 = offset2;
+ UnloadBlob(&offset1, *len1, b, *blob1);
+
+ break;
+ }
+ /* TPM BLOB: TPM_KEY, UINT32, BLOB, optional AUTH, AUTH
+ * return: UINT32 *, BYTE **, UINT32 *, BYTE **, optional AUTH, AUTH */
+ case TPM_ORD_MakeIdentity:
+ {
+ UINT32 *len1, *len2;
+ BYTE **blob1, **blob2;
+ TPM_AUTH *auth1, *auth2;
+
+ len1 = va_arg(ap, UINT32 *);
+ blob1 = va_arg(ap, BYTE **);
+ len2 = va_arg(ap, UINT32 *);
+ blob2 = va_arg(ap, BYTE **);
+ auth1 = va_arg(ap, TPM_AUTH *);
+ auth2 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!len1 || !blob1 || !len2 || !blob2 || !auth2) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ offset1 = offset2 = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_TSS_KEY(&offset1, b, NULL);
+ offset1 -= TSS_TPM_TXBLOB_HDR_LEN;
+
+ if ((*blob1 = malloc(offset1)) == NULL) {
+ LogError("malloc of %zd bytes failed", (size_t)offset1);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ *len1 = offset1;
+
+ UnloadBlob(&offset2, offset1, b, *blob1);
+
+ /* offset2 points to the stuff after the key */
+ UnloadBlob_UINT32(&offset2, len2, b);
+
+ if ((*blob2 = malloc(*len2)) == NULL) {
+ free(*blob1);
+ LogError("malloc of %u bytes failed", *len2);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ UnloadBlob(&offset2, *len2, b, *blob2);
+
+ if (auth1)
+ UnloadBlob_Auth(&offset2, b, auth1);
+ UnloadBlob_Auth(&offset2, b, auth2);
+
+ break;
+ }
+ /* 1 TPM_VERSION, 2 UINT32s, 1 optional AUTH */
+ case TPM_ORD_GetCapabilityOwner:
+ {
+ TPM_VERSION *ver1 = va_arg(ap, TPM_VERSION *);
+ UINT32 *data1 = va_arg(ap, UINT32 *);
+ UINT32 *data2 = va_arg(ap, UINT32 *);
+ TPM_AUTH *auth = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!data1 || !data2 || !ver1) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (auth) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth);
+ }
+
+ offset1 = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_VERSION(&offset1, b, ver1);
+ UnloadBlob_UINT32(&offset1, data1, b);
+ UnloadBlob_UINT32(&offset1, data2, b);
+ break;
+ }
+ /* TPM BLOB: 1 UINT32, 1 BLOB, 2 optional AUTHs
+ * return: UINT32 *, BYTE**, 2 optional AUTHs */
+ case TPM_ORD_Sign:
+ case TPM_ORD_GetTestResult:
+ case TPM_ORD_CertifySelfTest:
+ case TPM_ORD_Unseal:
+ case TPM_ORD_GetRandom:
+ case TPM_ORD_DAA_Join:
+ case TPM_ORD_DAA_Sign:
+ case TPM_ORD_ChangeAuth:
+ case TPM_ORD_GetCapability:
+ case TPM_ORD_LoadMaintenanceArchive:
+ case TPM_ORD_ConvertMigrationBlob:
+ case TPM_ORD_NV_ReadValue:
+ case TPM_ORD_NV_ReadValueAuth:
+ case TPM_ORD_Delegate_Manage:
+ case TPM_ORD_Delegate_CreateKeyDelegation:
+ case TPM_ORD_Delegate_CreateOwnerDelegation:
+ case TPM_ORD_Delegate_UpdateVerification:
+ case TPM_ORD_CMK_ConvertMigration:
+ {
+ UINT32 *data_len = va_arg(ap, UINT32 *);
+ BYTE **data = va_arg(ap, BYTE **);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!data || !data_len) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (auth1 && auth2) {
+ offset1 = len - (2 * TSS_TPM_RSP_BLOB_AUTH_LEN);
+ UnloadBlob_Auth(&offset1, b, auth1);
+ UnloadBlob_Auth(&offset1, b, auth2);
+ } else if (auth1) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth1);
+ } else if (auth2) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth2);
+ }
+
+ offset1 = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_UINT32(&offset1, data_len, b);
+ if ((*data = malloc(*data_len)) == NULL) {
+ LogError("malloc of %u bytes failed", *data_len);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ UnloadBlob(&offset1, *data_len, b, *data);
+ break;
+ }
+ /* TPM BLOB: 1 UINT32, 1 BLOB, 1 optional AUTH
+ * return: UINT32 *, BYTE**, 1 optional AUTH*/
+ case TPM_ORD_UnBind:
+ {
+ UINT32 *data_len = va_arg(ap, UINT32 *);
+ BYTE **data = va_arg(ap, BYTE **);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!data || !data_len) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (auth1) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth1);
+ }
+
+ offset1 = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_UINT32(&offset1, data_len, b);
+ if ((*data = malloc(*data_len)) == NULL) {
+ LogError("malloc of %u bytes failed", *data_len);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ UnloadBlob(&offset1, *data_len, b, *data);
+ break;
+ }
+ /* TPM BLOB: 1 BLOB, 1 optional AUTH
+ * return: UINT32 *, BYTE**, 1 optional AUTH*/
+ case TPM_ORD_GetTicks:
+ case TPM_ORD_Seal:
+ case TPM_ORD_Sealx:
+ case TPM_ORD_FieldUpgrade:
+ case TPM_ORD_CreateWrapKey:
+ case TPM_ORD_GetPubKey:
+ case TPM_ORD_OwnerReadPubek:
+ case TPM_ORD_OwnerReadInternalPub:
+ case TPM_ORD_AuthorizeMigrationKey:
+ case TPM_ORD_TakeOwnership:
+ case TPM_ORD_CMK_CreateKey:
+ {
+ UINT32 *data_len = va_arg(ap, UINT32 *);
+ BYTE **data = va_arg(ap, BYTE **);
+ TPM_AUTH *auth = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!data || !data_len) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ /* remove the auth data from the back end of the data */
+ if (auth) {
+ offset1 = offset2 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth);
+ } else
+ offset2 = len;
+
+ /* everything after the header is returned as the blob */
+ offset1 = TSS_TPM_TXBLOB_HDR_LEN;
+ offset2 -= offset1;
+ if ((*data = malloc((size_t)offset2)) == NULL) {
+ LogError("malloc of %zd bytes failed", (size_t)offset2);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ if ((offset1 + offset2) > TSS_TPM_TXBLOB_SIZE)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ memcpy(*data, &b[offset1], offset2);
+ *data_len = offset2;
+ break;
+ }
+ /* TPM BLOB: BLOB, optional DIGEST */
+ case TPM_ORD_CreateEndorsementKeyPair:
+ case TPM_ORD_ReadPubek:
+ {
+ UINT32 *data_len = va_arg(ap, UINT32 *);
+ BYTE **data = va_arg(ap, BYTE **);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ va_end(ap);
+
+ if (!data || !data_len) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if ((offset2 + TPM_DIGEST_SIZE) > TSS_TPM_TXBLOB_SIZE)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (digest1) {
+ offset1 = offset2 = len - TPM_DIGEST_SIZE;
+ memcpy(digest1, &b[offset2], TPM_DIGEST_SIZE);
+ } else
+ offset2 = len;
+
+ offset1 = TSS_TPM_TXBLOB_HDR_LEN;
+ offset2 -= offset1;
+ if ((*data = malloc((size_t)offset2)) == NULL) {
+ LogError("malloc of %zd bytes failed", (size_t)offset2);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ UnloadBlob(&offset1, offset2, b, *data);
+ *data_len = offset2;
+ break;
+ }
+#ifdef TSS_BUILD_TSS12
+ /* TPM BLOB: BLOB, DIGEST, DIGEST
+ * return: UINT32 *, BYTE**, DIGEST, DIGEST */
+ case TPM_ORD_CreateRevocableEK:
+ {
+ UINT32 *data_len = va_arg(ap, UINT32 *);
+ BYTE **data = va_arg(ap, BYTE **);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ BYTE *digest2 = va_arg(ap, BYTE *);
+ va_end(ap);
+
+ if (!data || !data_len || !digest1 || !digest2) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (len > TSS_TPM_TXBLOB_SIZE)
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ offset2 = len - TPM_DIGEST_SIZE;
+ memcpy(digest2, &b[offset2], TPM_DIGEST_SIZE);
+
+ offset2 -= TPM_DIGEST_SIZE;
+ memcpy(digest1, &b[offset2], TPM_DIGEST_SIZE);
+
+ offset1 = TSS_TPM_TXBLOB_HDR_LEN;
+ offset2 -= offset1;
+ if ((*data = malloc((size_t)offset2)) == NULL) {
+ LogError("malloc of %zd bytes failed", (size_t)offset2);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ UnloadBlob(&offset1, offset2, b, *data);
+ *data_len = offset2;
+ break;
+ }
+#endif
+ /* 1 UINT32, 1 optional AUTH */
+ case TPM_ORD_LoadKey:
+ case TPM_ORD_LoadKey2:
+ {
+ UINT32 *handle;
+ TPM_AUTH *auth;
+
+ handle = va_arg(ap, UINT32 *);
+ auth = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!handle) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (auth) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth);
+ }
+
+ offset1 = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_UINT32(&offset1, handle, b);
+ break;
+ }
+ /* 1 optional UINT32, 1 20 byte value */
+ case TPM_ORD_DirRead:
+ case TPM_ORD_OIAP:
+ case TPM_ORD_LoadManuMaintPub:
+ case TPM_ORD_ReadManuMaintPub:
+ case TPM_ORD_Extend:
+ case TPM_ORD_PcrRead:
+ {
+ UINT32 *handle = va_arg(ap, UINT32 *);
+ BYTE *nonce = va_arg(ap, BYTE *);
+ va_end(ap);
+
+ if (!nonce) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ offset1 = TSS_TPM_TXBLOB_HDR_LEN;
+ if (handle)
+ UnloadBlob_UINT32(&offset1, handle, b);
+ UnloadBlob(&offset1, TPM_NONCE_SIZE, b, nonce);
+ break;
+ }
+ /* 1 UINT32, 2 20 byte values */
+ case TPM_ORD_OSAP:
+ case TPM_ORD_DSAP:
+ {
+ UINT32 *handle = va_arg(ap, UINT32 *);
+ BYTE *nonce1 = va_arg(ap, BYTE *);
+ BYTE *nonce2 = va_arg(ap, BYTE *);
+ va_end(ap);
+
+ if (!handle || !nonce1 || !nonce2) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ offset1 = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_UINT32(&offset1, handle, b);
+ UnloadBlob(&offset1, TPM_NONCE_SIZE, b, nonce1);
+ UnloadBlob(&offset1, TPM_NONCE_SIZE, b, nonce2);
+ break;
+ }
+#ifdef TSS_BUILD_CMK
+ /* 1 20 byte value, 1 optional AUTH */
+ case TPM_ORD_CMK_ApproveMA:
+ case TPM_ORD_CMK_CreateTicket:
+ {
+ BYTE *hmac1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!hmac1) {
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ offset1 = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob(&offset1, TPM_SHA1_160_HASH_LEN, b, hmac1);
+ if (auth) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth);
+ }
+ break;
+ }
+#endif
+ /* 1 optional AUTH */
+ case TPM_ORD_DisablePubekRead:
+ case TPM_ORD_DirWriteAuth:
+ case TPM_ORD_ReleaseCounter:
+ case TPM_ORD_ReleaseCounterOwner:
+ case TPM_ORD_ChangeAuthOwner:
+ case TPM_ORD_SetCapability:
+ case TPM_ORD_SetOrdinalAuditStatus:
+ case TPM_ORD_ResetLockValue:
+ case TPM_ORD_SetRedirection:
+ case TPM_ORD_DisableOwnerClear:
+ case TPM_ORD_OwnerSetDisable:
+ case TPM_ORD_SetTempDeactivated:
+ case TPM_ORD_KillMaintenanceFeature:
+ case TPM_ORD_NV_DefineSpace:
+ case TPM_ORD_NV_WriteValue:
+ case TPM_ORD_NV_WriteValueAuth:
+ case TPM_ORD_OwnerClear:
+ case TPM_ORD_Delegate_LoadOwnerDelegation:
+ case TPM_ORD_CMK_SetRestrictions:
+ case TPM_ORD_FlushSpecific:
+ case TPM_ORD_KeyControlOwner:
+ {
+ TPM_AUTH *auth = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (auth) {
+ offset1 = len - TSS_TPM_RSP_BLOB_AUTH_LEN;
+ UnloadBlob_Auth(&offset1, b, auth);
+ }
+ break;
+ }
+ default:
+ LogError("Unknown ordinal: 0x%x", ordinal);
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ break;
+ }
+
+ return result;
+}
+
+/* XXX optimize these cases by always passing in lengths for blobs, no more "20 byte values" */
+TSS_RESULT
+tpm_rqu_build(TPM_COMMAND_CODE ordinal, UINT64 *outOffset, BYTE *out_blob, ...)
+{
+ TSS_RESULT result = TSS_SUCCESS;
+ UINT64 blob_size;
+ va_list ap;
+
+ DBG_ASSERT(ordinal);
+ DBG_ASSERT(outOffset);
+ DBG_ASSERT(out_blob);
+
+ va_start(ap, out_blob);
+
+ switch (ordinal) {
+#ifdef TSS_BUILD_DELEGATION
+ /* 1 UINT16, 1 UINT32, 1 20 bytes value, 1 UINT32, 1 BLOB */
+ case TPM_ORD_DSAP:
+ {
+ UINT16 val1 = va_arg(ap, int);
+ UINT32 handle1 = va_arg(ap, UINT32);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ va_end(ap);
+
+ if (!digest1 || !in_blob1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT16(outOffset, val1, out_blob);
+ LoadBlob_UINT32(outOffset, handle1, out_blob);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob_UINT32(outOffset, in_len1, out_blob);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+ /* 1 BOOL, 1 UINT32, 1 BLOB, 1 20 byte value, 1 AUTH */
+ case TPM_ORD_Delegate_CreateOwnerDelegation:
+ {
+ TSS_BOOL bool1 = va_arg(ap, int);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!in_len1 || !in_blob1 || !digest1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_BOOL(outOffset, bool1, out_blob);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+ /* 2 UINT32's, 1 BLOB, 1 20 byte value, 1 AUTH */
+ case TPM_ORD_Delegate_CreateKeyDelegation:
+ {
+ UINT32 keyslot1 = va_arg(ap, UINT32);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!keyslot1 || !in_len1 || !in_blob1 || !digest1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, keyslot1, out_blob);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+#endif
+#ifdef TSS_BUILD_TRANSPORT
+ /* 3 UINT32's, 1 BLOB, 2 AUTHs */
+ case TPM_ORD_ExecuteTransport:
+ {
+ UINT32 ord1 = va_arg(ap, UINT32);
+ UINT32 *keyslot1 = va_arg(ap, UINT32 *);
+ UINT32 *keyslot2 = va_arg(ap, UINT32 *);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ if (keyslot1)
+ LoadBlob_UINT32(outOffset, *keyslot1, out_blob);
+ if (keyslot2)
+ LoadBlob_UINT32(outOffset, *keyslot2, out_blob);
+ //LoadBlob_UINT32(outOffset, in_len1, out_blob);
+ if (in_blob1)
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+
+ if (auth1 && auth2) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Auth(outOffset, out_blob, auth2);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH2_COMMAND, *outOffset, ord1, out_blob);
+ } else if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ord1, out_blob);
+ } else if (auth2) {
+ LoadBlob_Auth(outOffset, out_blob, auth2);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ord1, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ord1, out_blob);
+ }
+
+ break;
+ }
+#endif
+ /* 1 UINT32, 1 UINT16, 1 BLOB, 1 UINT32, 1 BLOB, 1 options AUTH, 1 AUTH */
+ case TPM_ORD_CreateMigrationBlob:
+ {
+ UINT32 keyslot1 = va_arg(ap, UINT32);
+ UINT16 type1 = va_arg(ap, int);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ UINT32 in_len2 = va_arg(ap, UINT32);
+ BYTE *in_blob2 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!in_blob1 || !in_blob2 || !auth2) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, keyslot1, out_blob);
+ LoadBlob_UINT16(outOffset, type1, out_blob);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob_UINT32(outOffset, in_len2, out_blob);
+ LoadBlob(outOffset, in_len2, out_blob, in_blob2);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Auth(outOffset, out_blob, auth2);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH2_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Auth(outOffset, out_blob, auth2);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+ /* 1 UINT32, 1 UINT16, 1 20 byte value, 1 UINT16, 1 UINT32, 1 BLOB, 2 AUTHs */
+ case TPM_ORD_ChangeAuth:
+ {
+ UINT32 keyslot1 = va_arg(ap, UINT32);
+ UINT16 proto1 = va_arg(ap, int);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ UINT16 entity1 = va_arg(ap, int);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!digest1 || !in_blob1 || !auth1 || !auth2) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, keyslot1, out_blob);
+ LoadBlob_UINT16(outOffset, proto1, out_blob);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob_UINT16(outOffset, entity1, out_blob);
+ LoadBlob_UINT32(outOffset, in_len1, out_blob);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Auth(outOffset, out_blob, auth2);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH2_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+ /* 2 DIGEST/ENCAUTH's, 1 UINT32, 1 BLOB, 1 optional AUTH, 1 AUTH */
+ case TPM_ORD_MakeIdentity:
+ {
+ BYTE *dig1, *dig2, *blob1;
+ UINT32 len1;
+ TPM_AUTH *auth1, *auth2;
+
+ dig1 = va_arg(ap, BYTE *);
+ dig2 = va_arg(ap, BYTE *);
+ len1 = va_arg(ap, UINT32);
+ blob1 = va_arg(ap, BYTE *);
+ auth1 = va_arg(ap, TPM_AUTH *);
+ auth2 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!dig1 || !dig2 || !blob1 || !auth2) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, dig1);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, dig2);
+ LoadBlob(outOffset, len1, out_blob, blob1);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Auth(outOffset, out_blob, auth2);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH2_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Auth(outOffset, out_blob, auth2);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+#if (TSS_BUILD_NV || TSS_BUILD_DELEGATION)
+ /* 3 UINT32's, 1 BLOB, 1 optional AUTH */
+ case TPM_ORD_NV_WriteValue:
+ case TPM_ORD_NV_WriteValueAuth:
+ case TPM_ORD_Delegate_Manage:
+ {
+ UINT32 i = va_arg(ap, UINT32);
+ UINT32 j = va_arg(ap, UINT32);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!in_blob1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, i, out_blob);
+ LoadBlob_UINT32(outOffset, j, out_blob);
+ LoadBlob_UINT32(outOffset, in_len1, out_blob);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+#endif
+ /* 3 UINT32's, 1 optional AUTH */
+ case TPM_ORD_NV_ReadValue:
+ case TPM_ORD_NV_ReadValueAuth:
+ case TPM_ORD_SetRedirection:
+ {
+ UINT32 i = va_arg(ap, UINT32);
+ UINT32 j = va_arg(ap, UINT32);
+ UINT32 k = va_arg(ap, UINT32);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, i, out_blob);
+ LoadBlob_UINT32(outOffset, j, out_blob);
+ LoadBlob_UINT32(outOffset, k, out_blob);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+ /* 1 20 byte value, 1 UINT32, 1 BLOB */
+ case TPM_ORD_CreateEndorsementKeyPair:
+ {
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ va_end(ap);
+
+ if (!digest1 || !in_blob1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+#ifdef TSS_BUILD_TSS12
+ /* 1 20 byte value, 1 UINT32, 1 BLOB, 1 BOOL, 1 20 byte value */
+ case TPM_ORD_CreateRevocableEK:
+ {
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ TSS_BOOL in_bool1 = va_arg(ap, int);
+ BYTE *digest2 = va_arg(ap, BYTE *);
+ va_end(ap);
+
+ if (!digest1 || !in_blob1 || !digest2) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob_BOOL(outOffset, in_bool1, out_blob);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest2);
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+ /* 1 20 byte value */
+ case TPM_ORD_RevokeTrust:
+ {
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ va_end(ap);
+
+ if (!digest1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+#endif
+#ifdef TSS_BUILD_COUNTER
+ /* 1 20 byte value, 1 UINT32, 1 BLOB, 1 AUTH */
+ case TPM_ORD_CreateCounter:
+ {
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!digest1 || !in_blob1 || !auth1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+#endif
+#ifdef TSS_BUILD_DAA
+ /* 1 UINT32, 1 BYTE, 1 UINT32, 1 BLOB, 1 UINT32, 1 BLOB, 1 AUTH */
+ case TPM_ORD_DAA_Sign:
+ case TPM_ORD_DAA_Join:
+ {
+ UINT32 keySlot1 = va_arg(ap, UINT32);
+ BYTE stage1 = va_arg(ap, int);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ UINT32 in_len2 = va_arg(ap, UINT32);
+ BYTE *in_blob2 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!keySlot1 || !in_blob1 || !auth1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, keySlot1, out_blob);
+ LoadBlob_BOOL(outOffset, stage1, out_blob);
+ LoadBlob_UINT32(outOffset, in_len1, out_blob);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob_UINT32(outOffset, in_len2, out_blob);
+ LoadBlob(outOffset, in_len2, out_blob, in_blob2);
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+#endif
+ /* 2 UINT32's, 1 BLOB, 1 UINT32, 1 BLOB, 1 optional AUTH */
+ case TPM_ORD_ConvertMigrationBlob:
+ case TPM_ORD_SetCapability:
+ {
+ UINT32 keySlot1 = va_arg(ap, UINT32);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ UINT32 in_len2 = va_arg(ap, UINT32);
+ BYTE *in_blob2 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!keySlot1 || !in_blob1 || !in_blob2) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, keySlot1, out_blob);
+ LoadBlob_UINT32(outOffset, in_len1, out_blob);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob_UINT32(outOffset, in_len2, out_blob);
+ LoadBlob(outOffset, in_len2, out_blob, in_blob2);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+ /* 2 UINT32's, 1 20 byte value, 2 optional AUTHs */
+ case TPM_ORD_CertifyKey:
+ {
+ UINT32 keySlot1 = va_arg(ap, UINT32);
+ UINT32 keySlot2 = va_arg(ap, UINT32);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!keySlot1 || !keySlot2 || !digest1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, keySlot1, out_blob);
+ LoadBlob_UINT32(outOffset, keySlot2, out_blob);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ if (auth1 && auth2) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Auth(outOffset, out_blob, auth2);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH2_COMMAND, *outOffset, ordinal, out_blob);
+ } else if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else if (auth2) {
+ LoadBlob_Auth(outOffset, out_blob, auth2);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+ /* 2 UINT32's, 1 BLOB, 1 optional AUTH */
+ case TPM_ORD_Delegate_LoadOwnerDelegation:
+ case TPM_ORD_GetCapability:
+ case TPM_ORD_UnBind:
+ case TPM_ORD_Sign:
+ {
+ UINT32 keySlot1 = va_arg(ap, UINT32);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (in_len1 && !in_blob1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, keySlot1, out_blob);
+ LoadBlob_UINT32(outOffset, in_len1, out_blob);
+ if (in_len1)
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+ /* 1 UINT32, 1 20 byte value, 1 UINT32, 1 optional BLOB, 1 UINT32, 1 BLOB, 1 AUTH */
+ case TPM_ORD_Seal:
+ case TPM_ORD_Sealx:
+ {
+ UINT32 keySlot1 = va_arg(ap, UINT32);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ UINT32 in_len2 = va_arg(ap, UINT32);
+ BYTE *in_blob2 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ blob_size = in_len1 + in_len2 + TPM_DIGEST_SIZE + sizeof(TPM_AUTH);
+ if (blob_size > TSS_TPM_TXBLOB_SIZE) {
+ result = TCSERR(TSS_E_BAD_PARAMETER);
+ LogError("Oversized input when building ordinal 0x%x", ordinal);
+ break;
+ }
+
+ if (!keySlot1 || !in_blob2 || !auth1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, keySlot1, out_blob);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob_UINT32(outOffset, in_len1, out_blob);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob_UINT32(outOffset, in_len2, out_blob);
+ LoadBlob(outOffset, in_len2, out_blob, in_blob2);
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+ /* 2 UINT32's, 1 BLOB, 1 optional AUTH, 1 AUTH */
+ case TPM_ORD_ActivateIdentity:
+ {
+ UINT32 keySlot1 = va_arg(ap, UINT32);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!keySlot1 || !in_blob1 || !auth2) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, keySlot1, out_blob);
+ LoadBlob_UINT32(outOffset, in_len1, out_blob);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Auth(outOffset, out_blob, auth2);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH2_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Auth(outOffset, out_blob, auth2);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+ /* 1 UINT32, 1 20-byte blob, 1 BLOB, 1 optional AUTH */
+ case TPM_ORD_Quote:
+ {
+ UINT32 keySlot1 = va_arg(ap, UINT32);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!keySlot1 || !digest1 || !in_blob1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, keySlot1, out_blob);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+#ifdef TSS_BUILD_TSS12
+ /* 1 UINT32, 1 20-byte blob, 1 BLOB, 1 BOOL, 1 optional AUTH */
+ case TPM_ORD_Quote2:
+ {
+ /* Input vars */
+ UINT32 keySlot1 = va_arg(ap, UINT32);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ TSS_BOOL* addVersion = va_arg(ap,TSS_BOOL *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!keySlot1 || !digest1 || !in_blob1 || !addVersion) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, keySlot1, out_blob);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+
+ /* Load the addVersion Bool */
+ LoadBlob_BOOL(outOffset,*addVersion,out_blob);
+
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+#endif
+ /* 1 UINT32, 2 20-byte blobs, 1 BLOB, 1 optional AUTH */
+ case TPM_ORD_CreateWrapKey:
+ {
+ UINT32 keySlot1 = va_arg(ap, UINT32);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ BYTE *digest2 = va_arg(ap, BYTE *);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!keySlot1 || !digest1 || !digest2 || !in_blob1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, keySlot1, out_blob);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest2);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+ /* 2 BLOBs, 1 optional AUTH */
+ case TPM_ORD_NV_DefineSpace:
+ case TPM_ORD_LoadManuMaintPub:
+ {
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ UINT32 in_len2 = va_arg(ap, UINT32);
+ BYTE *in_blob2 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!in_blob1 || !in_blob2) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob(outOffset, in_len2, out_blob, in_blob2);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+#ifdef TSS_BUILD_TICK
+ /* 1 UINT32, 2 20-byte blobs, 1 optional AUTH */
+ case TPM_ORD_TickStampBlob:
+ {
+ UINT32 keySlot1 = va_arg(ap, UINT32);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ BYTE *digest2 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!keySlot1 || !digest1 || !digest2) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, keySlot1, out_blob);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest2);
+
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+#endif
+ /* 1 BLOB */
+ case TPM_ORD_ReadManuMaintPub:
+ case TPM_ORD_ReadPubek:
+ case TPM_ORD_PCR_Reset:
+ case TPM_ORD_SetOperatorAuth:
+ {
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ va_end(ap);
+
+ if (!in_blob1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+ /* 1 UINT32, 1 BLOB, 2 optional AUTHs */
+ case TPM_ORD_LoadKey:
+ case TPM_ORD_LoadKey2:
+ case TPM_ORD_DirWriteAuth:
+ case TPM_ORD_CertifySelfTest:
+ case TPM_ORD_Unseal:
+ case TPM_ORD_Extend:
+ case TPM_ORD_StirRandom:
+ case TPM_ORD_LoadMaintenanceArchive: /* XXX */
+ case TPM_ORD_FieldUpgrade:
+ case TPM_ORD_Delegate_UpdateVerification:
+ case TPM_ORD_Delegate_VerifyDelegation:
+ {
+ UINT32 val1 = va_arg(ap, UINT32);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (in_len1 && !in_blob1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, val1, out_blob);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ if (auth1 && auth2) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Auth(outOffset, out_blob, auth2);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH2_COMMAND, *outOffset, ordinal, out_blob);
+ } else if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else if (auth2) {
+ LoadBlob_Auth(outOffset, out_blob, auth2);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+ /* 1 UINT16, 1 BLOB, 1 AUTH */
+ case TPM_ORD_AuthorizeMigrationKey:
+ {
+ UINT16 scheme1 = va_arg(ap, int);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!in_blob1 || !auth1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT16(outOffset, scheme1, out_blob);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+ /* 1 UINT16, 1 UINT32, 1 BLOB, 1 UINT32, 2 BLOBs, 1 AUTH */
+ case TPM_ORD_TakeOwnership:
+ {
+ UINT16 scheme1 = va_arg(ap, int);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ UINT32 in_len2 = va_arg(ap, UINT32);
+ BYTE *in_blob2 = va_arg(ap, BYTE *);
+ UINT32 in_len3 = va_arg(ap, UINT32);
+ BYTE *in_blob3 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!in_blob1 || !in_blob2 || !in_blob3 || !auth1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT16(outOffset, scheme1, out_blob);
+ LoadBlob_UINT32(outOffset, in_len1, out_blob);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob_UINT32(outOffset, in_len2, out_blob);
+ LoadBlob(outOffset, in_len2, out_blob, in_blob2);
+ LoadBlob(outOffset, in_len3, out_blob, in_blob3);
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+#ifdef TSS_BUILD_AUDIT
+ /* 1 UINT32, 1 BOOL, 1 20 byte value, 1 optional AUTH */
+ case TPM_ORD_GetAuditDigestSigned:
+ {
+ UINT32 keyslot1 = va_arg(ap, UINT32);
+ TSS_BOOL bool1 = va_arg(ap, int);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!digest1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, keyslot1, out_blob);
+ LoadBlob_BOOL(outOffset, bool1, out_blob);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+#endif
+ /* 1 UINT16, 1 UINT32, 1 20 byte value */
+ case TPM_ORD_OSAP:
+ {
+ UINT16 type1 = va_arg(ap, int);
+ UINT32 value1 = va_arg(ap, UINT32);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ va_end(ap);
+
+ if (!digest1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT16(outOffset, type1, out_blob);
+ LoadBlob_UINT32(outOffset, value1, out_blob);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+ /* 1 UINT16, 1 20 byte value, 1 UINT16, 1 AUTH */
+ case TPM_ORD_ChangeAuthOwner:
+ {
+ UINT16 type1 = va_arg(ap, int);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ UINT16 type2 = va_arg(ap, int);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!digest1 || !auth1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT16(outOffset, type1, out_blob);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob_UINT16(outOffset, type2, out_blob);
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+#ifdef TSS_BUILD_AUDIT
+ /* 1 UINT32, 1 BOOL, 1 AUTH */
+ case TPM_ORD_SetOrdinalAuditStatus:
+ {
+ UINT32 ord1 = va_arg(ap, UINT32);
+ TSS_BOOL bool1 = va_arg(ap, int);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!auth1) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, ord1, out_blob);
+ LoadBlob_BOOL(outOffset, bool1, out_blob);
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+#endif
+ /* 1 BOOL, 1 optional AUTH */
+ case TPM_ORD_OwnerSetDisable:
+ case TPM_ORD_PhysicalSetDeactivated:
+ case TPM_ORD_CreateMaintenanceArchive:
+ case TPM_ORD_SetOwnerInstall:
+ {
+ TSS_BOOL bool1 = va_arg(ap, int);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_BOOL(outOffset, bool1, out_blob);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+ /* 1 optional AUTH */
+ case TPM_ORD_OwnerClear:
+ case TPM_ORD_DisablePubekRead:
+ case TPM_ORD_GetCapabilityOwner:
+ case TPM_ORD_ResetLockValue:
+ case TPM_ORD_DisableOwnerClear:
+ case TPM_ORD_SetTempDeactivated:
+ case TPM_ORD_OIAP:
+ case TPM_ORD_OwnerReadPubek:
+ case TPM_ORD_SelfTestFull:
+ case TPM_ORD_GetTicks:
+ case TPM_ORD_GetTestResult:
+ case TPM_ORD_KillMaintenanceFeature:
+ case TPM_ORD_Delegate_ReadTable:
+ case TPM_ORD_PhysicalEnable:
+ case TPM_ORD_DisableForceClear:
+ case TPM_ORD_ForceClear:
+ {
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+ /* 1 UINT32, 1 optional AUTH */
+ case TPM_ORD_OwnerReadInternalPub:
+ case TPM_ORD_GetPubKey:
+ case TPM_ORD_ReleaseCounterOwner:
+ case TPM_ORD_ReleaseCounter:
+ case TPM_ORD_IncrementCounter:
+ case TPM_ORD_PcrRead:
+ case TPM_ORD_DirRead:
+ case TPM_ORD_ReadCounter:
+ case TPM_ORD_Terminate_Handle:
+ case TPM_ORD_GetAuditDigest:
+ case TPM_ORD_GetRandom:
+ case TPM_ORD_CMK_SetRestrictions:
+ {
+ UINT32 i = va_arg(ap, UINT32);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, i, out_blob);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+#ifdef TSS_BUILD_CMK
+ /* 1 20 byte value, 1 optional AUTH */
+ case TPM_ORD_CMK_ApproveMA:
+ {
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+#endif
+ /* 1 UINT16 only */
+ case TSC_ORD_PhysicalPresence:
+ {
+ UINT16 i = va_arg(ap, int);
+ va_end(ap);
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT16(outOffset, i, out_blob);
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+#ifdef TSS_BUILD_CMK
+ /* 1 UINT32, 1 20 byte value, 1 BLOB, 2 20 byte values, 1 optional AUTH */
+ case TPM_ORD_CMK_CreateKey:
+ {
+ UINT32 key1 = va_arg(ap, UINT32);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ BYTE *digest2 = va_arg(ap, BYTE *);
+ BYTE *digest3 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!digest1 || !in_blob1 || !digest2 || !digest3) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, key1, out_blob);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest2);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest3);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+ /* 1 BLOB, 1 20 byte value, 1 UINT32, 1 BLOB, 1 optional AUTH */
+ case TPM_ORD_CMK_CreateTicket:
+ {
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ UINT32 in_len2 = va_arg(ap, UINT32);
+ BYTE *in_blob2 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!digest1 || !in_blob1 || !in_blob2) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob_UINT32(outOffset, in_len2, out_blob);
+ LoadBlob(outOffset, in_len2, out_blob, in_blob2);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+ /* 1 UINT32, 1 UINT16, 1 BLOB, 1 20 byte value, 4 x (1 UINT32, 1 BLOB), 1 optional AUTH */
+ case TPM_ORD_CMK_CreateBlob:
+ {
+ UINT32 in_key1 = va_arg(ap, UINT32);
+ UINT16 i = va_arg(ap, int);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ UINT32 in_len2 = va_arg(ap, UINT32);
+ BYTE *in_blob2 = va_arg(ap, BYTE *);
+ UINT32 in_len3 = va_arg(ap, UINT32);
+ BYTE *in_blob3 = va_arg(ap, BYTE *);
+ UINT32 in_len4 = va_arg(ap, UINT32);
+ BYTE *in_blob4 = va_arg(ap, BYTE *);
+ UINT32 in_len5 = va_arg(ap, UINT32);
+ BYTE *in_blob5 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!digest1 || !in_blob1 || !in_blob2 || !in_blob3 || !in_blob4 || !in_blob5) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, in_key1, out_blob);
+ LoadBlob_UINT16(outOffset, i, out_blob);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob_UINT32(outOffset, in_len2, out_blob);
+ LoadBlob(outOffset, in_len2, out_blob, in_blob2);
+ LoadBlob_UINT32(outOffset, in_len3, out_blob);
+ LoadBlob(outOffset, in_len3, out_blob, in_blob3);
+ LoadBlob_UINT32(outOffset, in_len4, out_blob);
+ LoadBlob(outOffset, in_len4, out_blob, in_blob4);
+ LoadBlob_UINT32(outOffset, in_len5, out_blob);
+ LoadBlob(outOffset, in_len5, out_blob, in_blob5);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+ /* 1 UINT32, 1 60 byte value, 1 20 byte value, 1 BLOB, 2 x (1 UINT32, 1 BLOB),
+ * 1 optional AUTH */
+ case TPM_ORD_CMK_ConvertMigration:
+ {
+ UINT32 key1 = va_arg(ap, UINT32);
+ BYTE *cmkauth1 = va_arg(ap, BYTE *);
+ BYTE *digest1 = va_arg(ap, BYTE *);
+ UINT32 in_len1 = va_arg(ap, UINT32);
+ BYTE *in_blob1 = va_arg(ap, BYTE *);
+ UINT32 in_len2 = va_arg(ap, UINT32);
+ BYTE *in_blob2 = va_arg(ap, BYTE *);
+ UINT32 in_len3 = va_arg(ap, UINT32);
+ BYTE *in_blob3 = va_arg(ap, BYTE *);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ if (!cmkauth1 || !digest1 || !in_blob1 || !in_blob2 || !in_blob3) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ LogError("Internal error for ordinal 0x%x", ordinal);
+ break;
+ }
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, key1, out_blob);
+ LoadBlob(outOffset, 3 * TPM_SHA1_160_HASH_LEN, out_blob, cmkauth1);
+ LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
+ LoadBlob(outOffset, in_len1, out_blob, in_blob1);
+ LoadBlob_UINT32(outOffset, in_len2, out_blob);
+ LoadBlob(outOffset, in_len2, out_blob, in_blob2);
+ LoadBlob_UINT32(outOffset, in_len3, out_blob);
+ LoadBlob(outOffset, in_len3, out_blob, in_blob3);
+ if (auth1) {
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+ }
+
+ break;
+ }
+#endif
+#ifdef TSS_BUILD_TSS12
+ case TPM_ORD_FlushSpecific:
+ {
+ UINT32 val1 = va_arg(ap, UINT32);
+ UINT32 val2 = va_arg(ap, UINT32);
+ va_end(ap);
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, val1, out_blob);
+ LoadBlob_UINT32(outOffset, val2, out_blob);
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+ /* 1 UINT32, 1 BLOB, 1 UINT32, 1 BOOL, 1 AUTH */
+ case TPM_ORD_KeyControlOwner:
+ {
+ UINT32 i = va_arg(ap, UINT32);
+ UINT32 len1 = va_arg(ap, UINT32);
+ BYTE *blob1 = va_arg(ap, BYTE *);
+ UINT32 j = va_arg(ap, UINT32);
+ TSS_BOOL bool1 = va_arg(ap, int);
+ TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
+ va_end(ap);
+
+ *outOffset += TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(outOffset, i, out_blob);
+ LoadBlob(outOffset, len1, out_blob, blob1);
+ LoadBlob_UINT32(outOffset, j, out_blob);
+ LoadBlob_BOOL(outOffset, bool1, out_blob);
+ LoadBlob_Auth(outOffset, out_blob, auth1);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, *outOffset, ordinal, out_blob);
+
+ break;
+ }
+#endif
+ default:
+ LogError("Unknown ordinal: 0x%x", ordinal);
+ break;
+ }
+
+ return result;
+}
diff --git a/src/tcs/tcs_ps.c b/src/tcs/tcs_ps.c
new file mode 100644
index 0000000..cd3d0c3
--- /dev/null
+++ b/src/tcs/tcs_ps.c
@@ -0,0 +1,176 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcsps.h"
+#include "tcslog.h"
+#include "tddl.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+TSS_RESULT
+get_vendor_data(struct key_disk_cache *d, UINT32 *size, BYTE **data)
+{
+ if (d->vendor_data_size == 0) {
+ *size = 0;
+ *data = NULL;
+
+ return TSS_SUCCESS;
+ }
+
+ return ps_get_vendor_data(d, size, data);
+}
+
+TSS_RESULT
+fill_key_info(struct key_disk_cache *d, struct key_mem_cache *m, TSS_KM_KEYINFO *key_info)
+{
+ BYTE tmp_blob[2048];
+ UINT16 tmp_blob_size = 2048;
+ TSS_KEY tmp_key;
+ UINT64 offset;
+ TSS_RESULT result;
+
+ if (m == NULL) {
+ key_info->fIsLoaded = FALSE;
+
+ /* read key from disk */
+ if ((result = ps_get_key_by_cache_entry(d, (BYTE *)&tmp_blob, &tmp_blob_size)))
+ return result;
+
+ offset = 0;
+ /* XXX add a real context handle here */
+ if ((result = UnloadBlob_TSS_KEY(&offset, tmp_blob, &tmp_key)))
+ return result;
+
+ if (tmp_key.hdr.key12.tag == TPM_TAG_KEY12) {
+ key_info->versionInfo.bMajor = TSS_SPEC_MAJOR;
+ key_info->versionInfo.bMinor = TSS_SPEC_MINOR;
+ key_info->versionInfo.bRevMajor = 0;
+ key_info->versionInfo.bRevMajor = 0;
+ } else
+ memcpy(&key_info->versionInfo, &tmp_key.hdr.key11.ver, sizeof(TSS_VERSION));
+ memcpy(&key_info->bAuthDataUsage, &tmp_key.authDataUsage,
+ sizeof(TCPA_AUTH_DATA_USAGE));
+ destroy_key_refs(&tmp_key);
+ } else {
+ if (m->tpm_handle == NULL_TPM_HANDLE)
+ key_info->fIsLoaded = FALSE;
+ else
+ key_info->fIsLoaded = TRUE;
+
+ if (m->blob->hdr.key12.tag == TPM_TAG_KEY12) {
+ key_info->versionInfo.bMajor = TSS_SPEC_MAJOR;
+ key_info->versionInfo.bMinor = TSS_SPEC_MINOR;
+ key_info->versionInfo.bRevMajor = 0;
+ key_info->versionInfo.bRevMajor = 0;
+ } else
+ memcpy(&key_info->versionInfo, &m->blob->hdr.key11.ver, sizeof(TSS_VERSION));
+ memcpy(&key_info->bAuthDataUsage, &m->blob->authDataUsage,
+ sizeof(TCPA_AUTH_DATA_USAGE));
+ }
+
+ memcpy(&key_info->keyUUID, &d->uuid, sizeof(TSS_UUID));
+ memcpy(&key_info->parentKeyUUID, &d->parent_uuid, sizeof(TSS_UUID));
+
+ return get_vendor_data(d, &key_info->ulVendorDataLength, &key_info->rgbVendorData);
+}
+
+TSS_RESULT
+fill_key_info2(struct key_disk_cache *d, struct key_mem_cache *m, TSS_KM_KEYINFO2 *key_info)
+{
+ BYTE tmp_blob[2048];
+ UINT16 tmp_blob_size = 2048;
+ TSS_KEY tmp_key;
+ UINT64 offset;
+ TSS_RESULT result;
+
+ if (m == NULL) {
+ key_info->fIsLoaded = FALSE;
+
+ /* read key from disk */
+ if ((result = ps_get_key_by_cache_entry(d, (BYTE *)&tmp_blob, &tmp_blob_size)))
+ return result;
+
+ offset = 0;
+ /* XXX add a real context handle here */
+ if ((result = UnloadBlob_TSS_KEY(&offset, tmp_blob, &tmp_key)))
+ return result;
+
+ if (tmp_key.hdr.key12.tag == TPM_TAG_KEY12) {
+ key_info->versionInfo.bMajor = TSS_SPEC_MAJOR;
+ key_info->versionInfo.bMinor = TSS_SPEC_MINOR;
+ key_info->versionInfo.bRevMajor = 0;
+ key_info->versionInfo.bRevMajor = 0;
+ } else
+ memcpy(&key_info->versionInfo, &tmp_key.hdr.key11.ver, sizeof(TSS_VERSION));
+ memcpy(&key_info->bAuthDataUsage, &tmp_key.authDataUsage,
+ sizeof(TCPA_AUTH_DATA_USAGE));
+ destroy_key_refs(&tmp_key);
+ } else {
+ if (m->tpm_handle == NULL_TPM_HANDLE)
+ key_info->fIsLoaded = FALSE;
+ else
+ key_info->fIsLoaded = TRUE;
+
+ if (m->blob->hdr.key12.tag == TPM_TAG_KEY12) {
+ key_info->versionInfo.bMajor = TSS_SPEC_MAJOR;
+ key_info->versionInfo.bMinor = TSS_SPEC_MINOR;
+ key_info->versionInfo.bRevMajor = 0;
+ key_info->versionInfo.bRevMajor = 0;
+ } else
+ memcpy(&key_info->versionInfo, &m->blob->hdr.key11.ver, sizeof(TSS_VERSION));
+ memcpy(&key_info->bAuthDataUsage, &m->blob->authDataUsage,
+ sizeof(TCPA_AUTH_DATA_USAGE));
+ }
+
+ memcpy(&key_info->keyUUID, &d->uuid, sizeof(TSS_UUID));
+ memcpy(&key_info->parentKeyUUID, &d->parent_uuid, sizeof(TSS_UUID));
+
+ /* Fill the two new TSS_KM_KEYINFO2 fields here */
+ key_info->persistentStorageTypeParent = d->flags & CACHE_FLAG_PARENT_PS_SYSTEM ?
+ TSS_PS_TYPE_SYSTEM : TSS_PS_TYPE_USER;
+ key_info->persistentStorageType = TSS_PS_TYPE_SYSTEM;
+
+ return get_vendor_data(d, &key_info->ulVendorDataLength, &key_info->rgbVendorData);
+}
+
+TSS_RESULT
+key_mgr_load_by_uuid(TCS_CONTEXT_HANDLE hContext,
+ TSS_UUID *uuid,
+ TCS_LOADKEY_INFO *pInfo,
+ TCS_KEY_HANDLE *phKeyTCSI)
+{
+ TSS_RESULT result;
+
+ MUTEX_LOCK(mem_cache_lock);
+
+ result = TCSP_LoadKeyByUUID_Internal(hContext, uuid, pInfo, phKeyTCSI);
+
+ LogDebug("Key %s loaded by UUID w/ TCS handle: 0x%x",
+ result ? "NOT" : "successfully", result ? 0 : *phKeyTCSI);
+
+ MUTEX_UNLOCK(mem_cache_lock);
+
+ return result;
+}
+
diff --git a/src/tcs/tcs_quote.c b/src/tcs/tcs_quote.c
new file mode 100644
index 0000000..0c84687
--- /dev/null
+++ b/src/tcs/tcs_quote.c
@@ -0,0 +1,101 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcsps.h"
+#include "tcslog.h"
+#include "tddl.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+TSS_RESULT
+UnloadBlob_PCR_SELECTION(UINT64 *offset, BYTE *blob, TCPA_PCR_SELECTION *pcr)
+{
+ if (!pcr) {
+ UINT16 size;
+
+ UnloadBlob_UINT16(offset, &size, blob);
+
+ if (size > 0)
+ UnloadBlob(offset, size, blob, NULL);
+
+ return TSS_SUCCESS;
+ }
+
+ UnloadBlob_UINT16(offset, &pcr->sizeOfSelect, blob);
+ pcr->pcrSelect = malloc(pcr->sizeOfSelect);
+ if (pcr->pcrSelect == NULL) {
+ LogError("malloc of %hu bytes failed.", pcr->sizeOfSelect);
+ pcr->sizeOfSelect = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(offset, pcr->sizeOfSelect, blob, pcr->pcrSelect);
+
+ return TSS_SUCCESS;
+}
+
+void
+LoadBlob_PCR_SELECTION(UINT64 *offset, BYTE * blob, TCPA_PCR_SELECTION pcr)
+{
+ LoadBlob_UINT16(offset, pcr.sizeOfSelect, blob);
+ LoadBlob(offset, pcr.sizeOfSelect, blob, pcr.pcrSelect);
+}
+
+TSS_RESULT
+UnloadBlob_PCR_COMPOSITE(UINT64 *offset, BYTE *blob, TCPA_PCR_COMPOSITE *out)
+{
+ TSS_RESULT rc;
+
+ if (!out) {
+ UINT32 size;
+
+ if ((rc = UnloadBlob_PCR_SELECTION(offset, blob, NULL)))
+ return rc;
+
+ UnloadBlob_UINT32(offset, &size, blob);
+ if (size > 0)
+ UnloadBlob(offset, size, blob, NULL);
+
+ return TSS_SUCCESS;
+ }
+
+ if ((rc = UnloadBlob_PCR_SELECTION(offset, blob, &out->select)))
+ return rc;
+
+ UnloadBlob_UINT32(offset, &out->valueSize, blob);
+ out->pcrValue = malloc(out->valueSize);
+ if (out->pcrValue == NULL) {
+ LogError("malloc of %u bytes failed.", out->valueSize);
+ out->valueSize = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(offset, out->valueSize, blob, (BYTE *) out->pcrValue);
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/tcs_quote2.c b/src/tcs/tcs_quote2.c
new file mode 100644
index 0000000..aa7ba51
--- /dev/null
+++ b/src/tcs/tcs_quote2.c
@@ -0,0 +1,72 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcsps.h"
+#include "tcslog.h"
+#include "tddl.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+TSS_RESULT
+UnloadBlob_PCR_INFO_SHORT(UINT64 *offset, BYTE *blob, TPM_PCR_INFO_SHORT *pcrInfoOut)
+{
+ TSS_RESULT result;
+ BYTE locAtRelease;
+ TPM_DIGEST digest;
+
+ LogDebugFn("UnloadBlob_PCR_INFO_SHORT.");
+ /* Only adjust the offset until the end of this data type */
+ if (!pcrInfoOut) {
+ if ((result = UnloadBlob_PCR_SELECTION(offset, blob, NULL)))
+ return result;
+ /* What should go to &pcrInfoOut->localityAtRelease */
+ UnloadBlob_BYTE(offset, NULL, blob);
+ /* What should go to &pcrInfoOut->digestAtRelease */
+ UnloadBlob_DIGEST(offset, blob, NULL);
+ return TSS_SUCCESS;
+ }
+
+ /* Normal retrieve or TPM_PCR_INFO_SHORT (not used yet, kept for
+ * integrity purposes.
+ * TPM_PCR_SELECTION pcrSelection
+ * TPM_LOCALITY_SELECTION localityAtRelease
+ * TPM_COMPOSITE_HASH digestAtRelease
+ * */
+ if ((result = UnloadBlob_PCR_SELECTION(offset, blob, &pcrInfoOut->pcrSelection)))
+ return result;
+
+ UnloadBlob_BYTE(offset, &locAtRelease, blob);
+ pcrInfoOut->localityAtRelease = locAtRelease;
+ UnloadBlob_DIGEST(offset, blob, &digest);
+ pcrInfoOut->digestAtRelease = digest;
+
+ return TSS_SUCCESS;
+}
+
+
diff --git a/src/tcs/tcs_req_mgr.c b/src/tcs/tcs_req_mgr.c
new file mode 100644
index 0000000..701cedb
--- /dev/null
+++ b/src/tcs/tcs_req_mgr.c
@@ -0,0 +1,83 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <signal.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "trousers/tss.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tddl.h"
+#include "req_mgr.h"
+#include "tcslog.h"
+
+static struct tpm_req_mgr *trm;
+
+#ifdef TSS_DEBUG
+#define TSS_TPM_DEBUG
+#endif
+
+TSS_RESULT
+req_mgr_submit_req(BYTE *blob)
+{
+ TSS_RESULT result;
+ BYTE loc_buf[TSS_TPM_TXBLOB_SIZE];
+ UINT32 size = TSS_TPM_TXBLOB_SIZE;
+ UINT32 retry = TSS_REQ_MGR_MAX_RETRIES;
+
+ MUTEX_LOCK(trm->queue_lock);
+
+#ifdef TSS_TPM_DEBUG
+ LogBlobData("To TPM:", Decode_UINT32(&blob[2]), blob);
+#endif
+
+ do {
+ result = Tddli_TransmitData(blob, Decode_UINT32(&blob[2]), loc_buf, &size);
+ } while (!result && (Decode_UINT32(&loc_buf[6]) == TCPA_E_RETRY) && --retry);
+
+ if (!result)
+ memcpy(blob, loc_buf, Decode_UINT32(&loc_buf[2]));
+
+#ifdef TSS_TPM_DEBUG
+ LogBlobData("From TPM:", size, loc_buf);
+#endif
+
+ MUTEX_UNLOCK(trm->queue_lock);
+
+ return result;
+}
+
+TSS_RESULT
+req_mgr_init()
+{
+ if ((trm = calloc(1, sizeof(struct tpm_req_mgr))) == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(struct tpm_req_mgr));
+ return TSS_E_OUTOFMEMORY;
+ }
+
+ MUTEX_INIT(trm->queue_lock);
+
+ return Tddli_Open();
+}
+
+TSS_RESULT
+req_mgr_final()
+{
+ free(trm);
+
+ return Tddli_Close();
+}
+
diff --git a/src/tcs/tcs_seal.c b/src/tcs/tcs_seal.c
new file mode 100644
index 0000000..e021948
--- /dev/null
+++ b/src/tcs/tcs_seal.c
@@ -0,0 +1,84 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcslog.h"
+
+
+TSS_RESULT
+UnloadBlob_STORED_DATA(UINT64 *offset, BYTE *blob, TCPA_STORED_DATA *data)
+{
+ if (!data) {
+ UINT32 size;
+
+ UnloadBlob_VERSION(offset, blob, NULL);
+
+ UnloadBlob_UINT32(offset, &size, blob);
+
+ if (size > 0)
+ UnloadBlob(offset, size, blob, NULL);
+
+ UnloadBlob_UINT32(offset, &size, blob);
+
+ if (size > 0)
+ UnloadBlob(offset, size, blob, NULL);
+
+ return TSS_SUCCESS;
+ }
+
+ UnloadBlob_VERSION(offset, blob, (TPM_VERSION *)&data->ver);
+
+ UnloadBlob_UINT32(offset, &data->sealInfoSize, blob);
+
+ if (data->sealInfoSize > 0) {
+ data->sealInfo = (BYTE *)calloc(1, data->sealInfoSize);
+ if (data->sealInfo == NULL) {
+ LogError("malloc of %u bytes failed.", data->sealInfoSize);
+ data->sealInfoSize = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(offset, data->sealInfoSize, blob, data->sealInfo);
+ } else {
+ data->sealInfo = NULL;
+ }
+
+ UnloadBlob_UINT32(offset, &data->encDataSize, blob);
+
+ if (data->encDataSize > 0) {
+ data->encData = (BYTE *)calloc(1, data->encDataSize);
+ if (data->encData == NULL) {
+ LogError("malloc of %u bytes failed.", data->encDataSize);
+ data->encDataSize = 0;
+ free(data->sealInfo);
+ data->sealInfo = NULL;
+ data->sealInfoSize = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(offset, data->encDataSize, blob, data->encData);
+ } else {
+ data->encData = NULL;
+ }
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/tcs_utils.c b/src/tcs/tcs_utils.c
new file mode 100644
index 0000000..7e19d09
--- /dev/null
+++ b/src/tcs/tcs_utils.c
@@ -0,0 +1,537 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcsps.h"
+#include "tcslog.h"
+
+
+TCS_CONTEXT_HANDLE InternalContext = 0x30000000;
+TSS_UUID SRK_UUID = TSS_UUID_SRK;
+
+
+void
+LogData(char *string, UINT32 data)
+{
+#if 0
+ /* commenting out temporarily, logs getting too chatty */
+ LogDebug("%s %08x", string, data);
+#endif
+}
+
+void
+LogResult(char *string, TCPA_RESULT result)
+{
+#if 0
+ /* commenting out temporarily, logs getting too chatty */
+ LogDebug("Leaving %s with result 0x%08x", string, result);
+#endif
+}
+
+UINT16
+Decode_UINT16(BYTE * in)
+{
+ UINT16 temp = 0;
+ temp = (in[1] & 0xFF);
+ temp |= (in[0] << 8);
+ return temp;
+}
+
+void
+UINT64ToArray(UINT64 i, BYTE * out)
+{
+ out[0] = (BYTE) ((i >> 56) & 0xFF);
+ out[1] = (BYTE) ((i >> 48) & 0xFF);
+ out[2] = (BYTE) ((i >> 40) & 0xFF);
+ out[3] = (BYTE) ((i >> 32) & 0xFF);
+ out[4] = (BYTE) ((i >> 24) & 0xFF);
+ out[5] = (BYTE) ((i >> 16) & 0xFF);
+ out[6] = (BYTE) ((i >> 8) & 0xFF);
+ out[7] = (BYTE) (i & 0xFF);
+}
+
+void
+UINT32ToArray(UINT32 i, BYTE * out)
+{
+ out[0] = (BYTE) ((i >> 24) & 0xFF);
+ out[1] = (BYTE) ((i >> 16) & 0xFF);
+ out[2] = (BYTE) ((i >> 8) & 0xFF);
+ out[3] = (BYTE) (i & 0xFF);
+}
+
+void
+UINT16ToArray(UINT16 i, BYTE * out)
+{
+ out[0] = (BYTE) ((i >> 8) & 0xFF);
+ out[1] = (BYTE) (i & 0xFF);
+}
+
+UINT32
+Decode_UINT32(BYTE * y)
+{
+ UINT32 x = 0;
+
+ x = y[0];
+ x = ((x << 8) | (y[1] & 0xFF));
+ x = ((x << 8) | (y[2] & 0xFF));
+ x = ((x << 8) | (y[3] & 0xFF));
+
+ return x;
+}
+
+UINT64
+Decode_UINT64(BYTE *y)
+{
+ UINT64 x = 0;
+
+ x = y[0];
+ x = ((x << 8) | (y[1] & 0xFF));
+ x = ((x << 8) | (y[2] & 0xFF));
+ x = ((x << 8) | (y[3] & 0xFF));
+ x = ((x << 8) | (y[4] & 0xFF));
+ x = ((x << 8) | (y[5] & 0xFF));
+ x = ((x << 8) | (y[6] & 0xFF));
+ x = ((x << 8) | (y[7] & 0xFF));
+
+ return x;
+}
+
+void
+LoadBlob_UINT64(UINT64 *offset, UINT64 in, BYTE * blob)
+{
+ if (blob)
+ UINT64ToArray(in, &blob[*offset]);
+ *offset += sizeof(UINT64);
+}
+
+void
+LoadBlob_UINT32(UINT64 *offset, UINT32 in, BYTE * blob)
+{
+ if (blob)
+ UINT32ToArray(in, &blob[*offset]);
+ *offset += sizeof(UINT32);
+}
+
+void
+LoadBlob_UINT16(UINT64 *offset, UINT16 in, BYTE * blob)
+{
+ if (blob)
+ UINT16ToArray(in, &blob[*offset]);
+ *offset += sizeof(UINT16);
+}
+
+void
+UnloadBlob_UINT64(UINT64 *offset, UINT64 * out, BYTE * blob)
+{
+ if (out)
+ *out = Decode_UINT64(&blob[*offset]);
+ *offset += sizeof(UINT64);
+}
+
+void
+UnloadBlob_UINT32(UINT64 *offset, UINT32 * out, BYTE * blob)
+{
+ if (out)
+ *out = Decode_UINT32(&blob[*offset]);
+ *offset += sizeof(UINT32);
+}
+
+void
+UnloadBlob_UINT16(UINT64 *offset, UINT16 * out, BYTE * blob)
+{
+ if (out)
+ *out = Decode_UINT16(&blob[*offset]);
+ *offset += sizeof(UINT16);
+}
+
+void
+LoadBlob_BYTE(UINT64 *offset, BYTE data, BYTE * blob)
+{
+ if (blob)
+ blob[*offset] = data;
+ (*offset)++;
+}
+
+void
+UnloadBlob_BYTE(UINT64 *offset, BYTE * dataOut, BYTE * blob)
+{
+ if (dataOut)
+ *dataOut = blob[*offset];
+ (*offset)++;
+}
+
+void
+LoadBlob_BOOL(UINT64 *offset, TSS_BOOL data, BYTE * blob)
+{
+ if (blob)
+ blob[*offset] = data;
+ (*offset)++;
+}
+
+void
+UnloadBlob_BOOL(UINT64 *offset, TSS_BOOL *dataOut, BYTE * blob)
+{
+ if (dataOut)
+ *dataOut = blob[*offset];
+ (*offset)++;
+}
+
+void
+LoadBlob(UINT64 *offset, UINT32 size, BYTE *container, BYTE *object)
+{
+ if ((size == 0) || ((*offset + size) > TSS_TPM_TXBLOB_SIZE))
+ return;
+
+ if (container)
+ memcpy(&container[*offset], object, size);
+ (*offset) += (UINT64) size;
+}
+
+void
+UnloadBlob(UINT64 *offset, UINT32 size, BYTE *container, BYTE *object)
+{
+ if ((size == 0) || ((*offset + size) > TSS_TPM_TXBLOB_SIZE))
+ return;
+
+ if (object)
+ memcpy(object, &container[*offset], size);
+ (*offset) += (UINT64) size;
+}
+
+void
+LoadBlob_Header(UINT16 tag, UINT32 paramSize, UINT32 ordinal, BYTE * blob)
+{
+
+ UINT16ToArray(tag, &blob[0]);
+ LogData("Header Tag:", tag);
+ UINT32ToArray(paramSize, &blob[2]);
+ LogData("Header ParamSize:", paramSize);
+ UINT32ToArray(ordinal, &blob[6]);
+ LogData("Header Ordinal:", ordinal);
+#if 0
+ LogInfo("Blob's TPM Ordinal: 0x%x", ordinal);
+#endif
+}
+
+#ifdef TSS_DEBUG
+TSS_RESULT
+LogUnloadBlob_Header(BYTE * blob, UINT32 * size, char *file, int line)
+{
+ TSS_RESULT result;
+
+ UINT16 temp = Decode_UINT16(blob);
+ LogData("UnloadBlob_Tag:", (temp));
+ *size = Decode_UINT32(&blob[2]);
+ LogData("UnloadBlob_Header, size:", *size);
+ LogData("UnloadBlob_Header, returnCode:", Decode_UINT32(&blob[6]));
+
+ if ((result = Decode_UINT32(&blob[6]))) {
+ LogTPMERR(result, file, line);
+ }
+
+ return result;
+}
+#else
+TSS_RESULT
+UnloadBlob_Header(BYTE * blob, UINT32 * size)
+{
+ UINT16 temp = Decode_UINT16(blob);
+ LogData("UnloadBlob_Tag:", (temp));
+ *size = Decode_UINT32(&blob[2]);
+ LogData("UnloadBlob_Header, size:", *size);
+ LogData("UnloadBlob_Header, returnCode:", Decode_UINT32(&blob[6]));
+ return Decode_UINT32(&blob[6]);
+}
+#endif
+
+void
+LoadBlob_Auth(UINT64 *offset, BYTE * blob, TPM_AUTH * auth)
+{
+ LoadBlob_UINT32(offset, auth->AuthHandle, blob);
+ LoadBlob(offset, TCPA_NONCE_SIZE, blob, auth->NonceOdd.nonce);
+ LoadBlob_BOOL(offset, auth->fContinueAuthSession, blob);
+ LoadBlob(offset, TCPA_AUTHDATA_SIZE, blob, (BYTE *)&auth->HMAC);
+}
+
+void
+UnloadBlob_Auth(UINT64 *offset, BYTE * blob, TPM_AUTH * auth)
+{
+ if (!auth) {
+ UnloadBlob(offset, TCPA_NONCE_SIZE, blob, NULL);
+ UnloadBlob_BOOL(offset, NULL, blob);
+ UnloadBlob(offset, TCPA_DIGEST_SIZE, blob, NULL);
+
+ return;
+ }
+
+ UnloadBlob(offset, TCPA_NONCE_SIZE, blob, auth->NonceEven.nonce);
+ UnloadBlob_BOOL(offset, &auth->fContinueAuthSession, blob);
+ UnloadBlob(offset, TCPA_DIGEST_SIZE, blob, (BYTE *)&auth->HMAC);
+}
+
+void
+UnloadBlob_VERSION(UINT64 *offset, BYTE *blob, TPM_VERSION *out)
+{
+ if (!out) {
+ *offset += (sizeof(BYTE) * 4);
+ return;
+ }
+
+ UnloadBlob_BYTE(offset, &out->major, blob);
+ UnloadBlob_BYTE(offset, &out->minor, blob);
+ UnloadBlob_BYTE(offset, &out->revMajor, blob);
+ UnloadBlob_BYTE(offset, &out->revMinor, blob);
+}
+
+void
+LoadBlob_VERSION(UINT64 *offset, BYTE *blob, TPM_VERSION *ver)
+{
+ LoadBlob_BYTE(offset, ver->major, blob);
+ LoadBlob_BYTE(offset, ver->minor, blob);
+ LoadBlob_BYTE(offset, ver->revMajor, blob);
+ LoadBlob_BYTE(offset, ver->revMinor, blob);
+}
+
+void
+UnloadBlob_TCPA_VERSION(UINT64 *offset, BYTE *blob, TCPA_VERSION *out)
+{
+ if (!out) {
+ *offset += (sizeof(BYTE) * 4);
+ return;
+ }
+
+ UnloadBlob_BYTE(offset, &out->major, blob);
+ UnloadBlob_BYTE(offset, &out->minor, blob);
+ UnloadBlob_BYTE(offset, &out->revMajor, blob);
+ UnloadBlob_BYTE(offset, &out->revMinor, blob);
+}
+
+void
+LoadBlob_TCPA_VERSION(UINT64 *offset, BYTE *blob, TCPA_VERSION *ver)
+{
+ LoadBlob_BYTE(offset, ver->major, blob);
+ LoadBlob_BYTE(offset, ver->minor, blob);
+ LoadBlob_BYTE(offset, ver->revMajor, blob);
+ LoadBlob_BYTE(offset, ver->revMinor, blob);
+}
+
+TSS_RESULT
+UnloadBlob_KEY_PARMS(UINT64 *offset, BYTE *blob, TCPA_KEY_PARMS *keyParms)
+{
+ if (!keyParms) {
+ UINT32 parmSize;
+
+ UnloadBlob_UINT32(offset, NULL, blob);
+ UnloadBlob_UINT16(offset, NULL, blob);
+ UnloadBlob_UINT16(offset, NULL, blob);
+ UnloadBlob_UINT32(offset, &parmSize, blob);
+
+ if (parmSize > 0)
+ UnloadBlob(offset, parmSize, blob, NULL);
+
+ return TSS_SUCCESS;
+ }
+
+ UnloadBlob_UINT32(offset, &keyParms->algorithmID, blob);
+ UnloadBlob_UINT16(offset, &keyParms->encScheme, blob);
+ UnloadBlob_UINT16(offset, &keyParms->sigScheme, blob);
+ UnloadBlob_UINT32(offset, &keyParms->parmSize, blob);
+
+ if (keyParms->parmSize == 0)
+ keyParms->parms = NULL;
+ else {
+ keyParms->parms = malloc(keyParms->parmSize);
+ if (keyParms->parms == NULL) {
+ LogError("malloc of %u bytes failed.", keyParms->parmSize);
+ keyParms->parmSize = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ UnloadBlob(offset, keyParms->parmSize, blob, keyParms->parms);
+ }
+
+ return TSS_SUCCESS;
+}
+
+void
+UnloadBlob_KEY_FLAGS(UINT64 *offset, BYTE *blob, TCPA_KEY_FLAGS *flags)
+{
+ if (!flags) {
+ UnloadBlob_UINT32(offset, NULL, blob);
+
+ return;
+ }
+
+ UnloadBlob_UINT32(offset, flags, blob);
+}
+
+TSS_RESULT
+UnloadBlob_CERTIFY_INFO(UINT64 *offset, BYTE *blob, TCPA_CERTIFY_INFO *certify)
+{
+ TSS_RESULT rc;
+
+ if (!certify) {
+ TPM_VERSION version;
+ UINT32 size;
+
+ UnloadBlob_VERSION(offset, blob, &version);
+ UnloadBlob_UINT16(offset, NULL, blob);
+ UnloadBlob_KEY_FLAGS(offset, blob, NULL);
+ UnloadBlob_BOOL(offset, NULL, blob);
+
+ if ((rc = UnloadBlob_KEY_PARMS(offset, blob, NULL)))
+ return rc;
+
+ UnloadBlob(offset, TCPA_DIGEST_SIZE, blob, NULL);
+ UnloadBlob(offset, TCPA_NONCE_SIZE, blob, NULL);
+ UnloadBlob_BOOL(offset, NULL, blob);
+ UnloadBlob_UINT32(offset, &size, blob);
+
+ if (size > 0)
+ UnloadBlob(offset, size, blob, NULL);
+
+ if (Decode_UINT16((BYTE *) &version) == TPM_TAG_CERTIFY_INFO2){
+ /* This is a TPM_CERTIFY_INFO2 structure. */
+ /* Read migrationAuthority. */
+ UnloadBlob_UINT32(offset, &size, blob);
+ if (size > 0)
+ UnloadBlob(offset, size, blob, NULL);
+ }
+
+ return TSS_SUCCESS;
+ }
+
+ UnloadBlob_VERSION(offset, blob, (TPM_VERSION *)&certify->version);
+ UnloadBlob_UINT16(offset, &certify->keyUsage, blob);
+ UnloadBlob_KEY_FLAGS(offset, blob, &certify->keyFlags);
+ UnloadBlob_BOOL(offset, (TSS_BOOL *)&certify->authDataUsage, blob);
+
+ if ((rc = UnloadBlob_KEY_PARMS(offset, blob, &certify->algorithmParms)))
+ return rc;
+
+ UnloadBlob(offset, TCPA_DIGEST_SIZE, blob, certify->pubkeyDigest.digest);
+ UnloadBlob(offset, TCPA_NONCE_SIZE, blob, certify->data.nonce);
+ UnloadBlob_BOOL(offset, (TSS_BOOL *)&certify->parentPCRStatus, blob);
+ UnloadBlob_UINT32(offset, &certify->PCRInfoSize, blob);
+
+ if (certify->PCRInfoSize > 0) {
+ certify->PCRInfo = (BYTE *)malloc(certify->PCRInfoSize);
+ if (certify->PCRInfo == NULL) {
+ LogError("malloc of %u bytes failed.", certify->PCRInfoSize);
+ certify->PCRInfoSize = 0;
+ free(certify->algorithmParms.parms);
+ certify->algorithmParms.parms = NULL;
+ certify->algorithmParms.parmSize = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(offset, certify->PCRInfoSize, blob, certify->PCRInfo);
+ } else {
+ certify->PCRInfo = NULL;
+ }
+
+ if (Decode_UINT16((BYTE *) &certify->version) == TPM_TAG_CERTIFY_INFO2){
+ /* This is a TPM_CERTIFY_INFO2 structure. */
+ /* Read migrationAuthority. */
+ UINT32 size;
+ UnloadBlob_UINT32(offset, &size, blob);
+ if (size > 0)
+ UnloadBlob(offset, size, blob, NULL);
+ }
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+UnloadBlob_KEY_HANDLE_LIST(UINT64 *offset, BYTE *blob, TCPA_KEY_HANDLE_LIST *list)
+{
+ UINT16 i;
+
+ if (!list) {
+ UINT16 size;
+
+ UnloadBlob_UINT16(offset, &size, blob);
+
+ *offset += (size * sizeof(UINT32));
+
+ return TSS_SUCCESS;
+ }
+
+ UnloadBlob_UINT16(offset, &list->loaded, blob);
+ if (list->loaded == 0) {
+ list->handle = NULL;
+ return TSS_SUCCESS;
+ }
+
+ list->handle = malloc(list->loaded * sizeof (UINT32));
+ if (list->handle == NULL) {
+ LogError("malloc of %zd bytes failed.", list->loaded * sizeof (UINT32));
+ list->loaded = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ for (i = 0; i < list->loaded; i++)
+ UnloadBlob_UINT32(offset, &list->handle[i], blob);
+
+ return TSS_SUCCESS;
+}
+
+void
+LoadBlob_DIGEST(UINT64 *offset, BYTE *blob, TPM_DIGEST *digest)
+{
+ LoadBlob(offset, TPM_SHA1_160_HASH_LEN, blob, digest->digest);
+}
+
+void
+UnloadBlob_DIGEST(UINT64 *offset, BYTE *blob, TPM_DIGEST *digest)
+{
+ UnloadBlob(offset, TPM_SHA1_160_HASH_LEN, blob, digest->digest);
+}
+
+void
+LoadBlob_NONCE(UINT64 *offset, BYTE *blob, TPM_NONCE *nonce)
+{
+ LoadBlob(offset, TCPA_NONCE_SIZE, blob, nonce->nonce);
+}
+
+void
+UnloadBlob_NONCE(UINT64 *offset, BYTE *blob, TPM_NONCE *nonce)
+{
+ UnloadBlob(offset, TCPA_NONCE_SIZE, blob, nonce->nonce);
+}
+
+void
+LoadBlob_AUTHDATA(UINT64 *offset, BYTE *blob, TPM_AUTHDATA *authdata)
+{
+ LoadBlob(offset, TPM_SHA1_160_HASH_LEN, blob, authdata->authdata);
+}
+
+void
+UnloadBlob_AUTHDATA(UINT64 *offset, BYTE *blob, TPM_AUTHDATA *authdata)
+{
+ UnloadBlob(offset, TPM_SHA1_160_HASH_LEN, blob, authdata->authdata);
+}
+
diff --git a/src/tcs/tcsi_admin.c b/src/tcs/tcsi_admin.c
new file mode 100644
index 0000000..3830b12
--- /dev/null
+++ b/src/tcs/tcsi_admin.c
@@ -0,0 +1,518 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004, 2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+TSS_RESULT
+TCSP_SetOwnerInstall_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_BOOL state) /* in */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering SetOwnerInstall");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_SetOwnerInstall, &offset, txBlob, state, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogResult("SetOwnerInstall", result);
+ return result;
+}
+
+TSS_RESULT
+TCSP_OwnerSetDisable_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_BOOL disableState, /* in */
+ TPM_AUTH * ownerAuth) /* in, out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_OwnerSetDisable, &offset, txBlob, disableState,
+ ownerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_OwnerSetDisable, txBlob, paramSize, ownerAuth);
+ }
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_DisableOwnerClear_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_AUTH * ownerAuth) /* in, out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering DisableownerClear");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_DisableOwnerClear, &offset, txBlob, ownerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_DisableOwnerClear, txBlob, paramSize, ownerAuth);
+ }
+ LogResult("DisableOwnerClear", result);
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_ForceClear_Internal(TCS_CONTEXT_HANDLE hContext) /* in */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Force Clear");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_ForceClear, &offset, txBlob, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogResult("Force Clear", result);
+ return result;
+}
+
+TSS_RESULT
+TCSP_DisableForceClear_Internal(TCS_CONTEXT_HANDLE hContext) /* in */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Disable Force Clear");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_DisableForceClear, &offset, txBlob, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogResult("Disable Force Clear", result);
+ return result;
+}
+
+TSS_RESULT
+TCSP_PhysicalPresence_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_PHYSICAL_PRESENCE fPhysicalPresence) /* in */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result = TCSERR(TSS_E_NOTIMPL);
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+ char runlevel;
+
+ runlevel = platform_get_runlevel();
+
+ if (runlevel != 's' && runlevel != 'S' && runlevel != '1') {
+ LogInfo("Physical Presence command denied: Must be in single"
+ " user mode.");
+ return TCSERR(TSS_E_NOTIMPL);
+ }
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TSC_ORD_PhysicalPresence, &offset, txBlob, fPhysicalPresence)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ return UnloadBlob_Header(txBlob, &paramSize);
+}
+
+TSS_RESULT
+TCSP_PhysicalDisable_Internal(TCS_CONTEXT_HANDLE hContext) /* in */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Physical Disable");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_PhysicalDisable, &offset, txBlob, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogResult("Physical Disable", result);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_PhysicalEnable_Internal(TCS_CONTEXT_HANDLE hContext) /* in */
+{
+ UINT64 offset = 0;
+ TSS_RESULT result;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Physical Enable");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_PhysicalEnable, &offset, txBlob, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogResult("Physical Enable", result);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_PhysicalSetDeactivated_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_BOOL state) /* in */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Physical Set Deactivated");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_PhysicalSetDeactivated, &offset, txBlob, state, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogResult("PhysicalSetDeactivated", result);
+ return result;
+}
+
+TSS_RESULT
+TCSP_SetTempDeactivated_Internal(TCS_CONTEXT_HANDLE hContext) /* in */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Set Temp Deactivated");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_SetTempDeactivated, &offset, txBlob, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogResult("SetTempDeactivated", result);
+
+ return result;
+}
+
+#ifdef TSS_BUILD_TSS12
+TSS_RESULT
+TCSP_SetTempDeactivated2_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_AUTH * operatorAuth) /* in, out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Set Temp Deactivated2");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (operatorAuth) {
+ if ((result = auth_mgr_check(hContext, &operatorAuth->AuthHandle)))
+ return result;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_SetTempDeactivated, &offset, txBlob, operatorAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_SetTempDeactivated, txBlob, paramSize,
+ operatorAuth);
+ }
+
+ LogResult("SetTempDeactivated2", result);
+
+done:
+ auth_mgr_release_auth(operatorAuth, NULL, hContext);
+
+ return result;
+}
+#endif
+
+TSS_RESULT
+TCSP_FieldUpgrade_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 dataInSize, /* in */
+ BYTE * dataIn, /* in */
+ UINT32 * dataOutSize, /* out */
+ BYTE ** dataOut, /* out */
+ TPM_AUTH * ownerAuth) /* in, out */
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Field Upgrade");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_FieldUpgrade, &offset, txBlob, dataInSize, dataInSize,
+ dataIn, ownerAuth, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_FieldUpgrade, txBlob, paramSize, dataOutSize,
+ dataOut, ownerAuth);
+ }
+ LogResult("Field Upgrade", result);
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_SetRedirection_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE keyHandle, /* in */
+ UINT32 c1, /* in */
+ UINT32 c2, /* in */
+ TPM_AUTH * privAuth) /* in, out */
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ TCPA_KEY_HANDLE keySlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Set Redirection");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (privAuth != NULL) {
+ if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle)))
+ goto done;
+ }
+
+ if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot))) {
+ result = TCSERR(TSS_E_FAIL);
+ goto done;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_SetRedirection, &offset, txBlob, keySlot, c1, c2,
+ privAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_SetRedirection, txBlob, paramSize, privAuth);
+ }
+ LogResult("Set Redirection", result);
+done:
+ auth_mgr_release_auth(privAuth, NULL, hContext);
+ return result;
+}
+
+#ifdef TSS_BUILD_TSS12
+TSS_RESULT
+TCSP_ResetLockValue_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_AUTH * ownerAuth) /* in, out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_ResetLockValue, &offset, txBlob, ownerAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_ResetLockValue, txBlob, paramSize, ownerAuth);
+ }
+
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_FlushSpecific_Common(UINT32 tpmResHandle, TPM_RESOURCE_TYPE resourceType)
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = tpm_rqu_build(TPM_ORD_FlushSpecific, &offset, txBlob, tpmResHandle,
+ resourceType)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_FlushSpecific, txBlob, paramSize, NULL);
+ }
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_FlushSpecific_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_HANDLE hResHandle, /* in */
+ TPM_RESOURCE_TYPE resourceType) /* in */
+{
+ UINT32 tpmResHandle;
+ TSS_RESULT result;
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ switch (resourceType) {
+ case TPM_RT_KEY:
+ if ((result = get_slot_lite(hContext, hResHandle, &tpmResHandle)))
+ return result;
+
+ if ((result = ctx_remove_key_loaded(hContext, hResHandle)))
+ return result;
+
+ if ((result = key_mgr_dec_ref_count(hResHandle)))
+ return result;
+ break;
+ case TPM_RT_AUTH:
+ if ((result = auth_mgr_check(hContext, &hResHandle)))
+ return result;
+
+ auth_mgr_release_auth_handle(hResHandle, hContext, FALSE);
+ /* fall through */
+ case TPM_RT_TRANS:
+ case TPM_RT_DAA_TPM:
+ tpmResHandle = hResHandle;
+ break;
+ case TPM_RT_CONTEXT:
+ result = TCSERR(TSS_E_NOTIMPL);
+ goto done;
+ default:
+ LogDebugFn("Unknown resource type: 0x%x", resourceType);
+ goto done;
+ }
+
+ result = TCSP_FlushSpecific_Common(tpmResHandle, resourceType);
+
+done:
+ return result;
+}
+#endif
+
diff --git a/src/tcs/tcsi_aik.c b/src/tcs/tcsi_aik.c
new file mode 100644
index 0000000..8915d13
--- /dev/null
+++ b/src/tcs/tcsi_aik.c
@@ -0,0 +1,227 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsps.h"
+#include "req_mgr.h"
+#include "tcs_aik.h"
+
+
+TSS_RESULT
+TCSP_MakeIdentity_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_ENCAUTH identityAuth, /* in */
+ TCPA_CHOSENID_HASH IDLabel_PrivCAHash, /* in */
+ UINT32 idKeyInfoSize, /* in */
+ BYTE * idKeyInfo, /* in */
+ TPM_AUTH * pSrkAuth, /* in, out */
+ TPM_AUTH * pOwnerAuth, /* in, out */
+ UINT32 * idKeySize, /* out */
+ BYTE ** idKey, /* out */
+ UINT32 * pcIdentityBindingSize, /* out */
+ BYTE ** prgbIdentityBinding, /* out */
+ UINT32 * pcEndorsementCredentialSize, /* out */
+ BYTE ** prgbEndorsementCredential, /* out */
+ UINT32 * pcPlatformCredentialSize, /* out */
+ BYTE ** prgbPlatformCredential, /* out */
+ UINT32 * pcConformanceCredentialSize, /* out */
+ BYTE ** prgbConformanceCredential) /* out */
+{
+ UINT64 offset;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (pSrkAuth != NULL) {
+ LogDebug("SRK Auth Used");
+ if ((result = auth_mgr_check(hContext, &pSrkAuth->AuthHandle)))
+ goto done;
+ } else {
+ LogDebug("No SRK Auth");
+ }
+
+ if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
+ goto done;
+
+ offset = 0;
+ if ((result = tpm_rqu_build(TPM_ORD_MakeIdentity, &offset, txBlob, identityAuth.authdata,
+ IDLabel_PrivCAHash.digest, idKeyInfoSize, idKeyInfo, pSrkAuth,
+ pOwnerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ if ((result = tpm_rsp_parse(TPM_ORD_MakeIdentity, txBlob, paramSize, idKeySize,
+ idKey, pcIdentityBindingSize, prgbIdentityBinding,
+ pSrkAuth, pOwnerAuth)))
+ goto done;
+
+ /* If an error occurs, these will return NULL */
+ get_credential(TSS_TCS_CREDENTIAL_PLATFORMCERT, pcPlatformCredentialSize,
+ prgbPlatformCredential);
+ get_credential(TSS_TCS_CREDENTIAL_TPM_CC, pcConformanceCredentialSize,
+ prgbConformanceCredential);
+ get_credential(TSS_TCS_CREDENTIAL_EKCERT, pcEndorsementCredentialSize,
+ prgbEndorsementCredential);
+ }
+ LogResult("Make Identity", result);
+done:
+ auth_mgr_release_auth(pSrkAuth, pOwnerAuth, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_ActivateTPMIdentity_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE idKey, /* in */
+ UINT32 blobSize, /* in */
+ BYTE * blob, /* in */
+ TPM_AUTH * idKeyAuth, /* in, out */
+ TPM_AUTH * ownerAuth, /* in, out */
+ UINT32 * SymmetricKeySize, /* out */
+ BYTE ** SymmetricKey) /* out */
+{
+ UINT64 offset;
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT32 keySlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("TCSP_ActivateTPMIdentity");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (idKeyAuth != NULL) {
+ if ((result = auth_mgr_check(hContext, &idKeyAuth->AuthHandle)))
+ goto done;
+ }
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = ensureKeyIsLoaded(hContext, idKey, &keySlot)))
+ goto done;
+
+ offset = 0;
+ if ((result = tpm_rqu_build(TPM_ORD_ActivateIdentity, &offset, txBlob, keySlot, blobSize,
+ blob, idKeyAuth, ownerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ if ((result = tpm_rsp_parse(TPM_ORD_ActivateIdentity, txBlob, paramSize,
+ SymmetricKeySize, SymmetricKey, idKeyAuth, ownerAuth)))
+ goto done;
+ }
+
+done:
+ auth_mgr_release_auth(idKeyAuth, ownerAuth, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCS_GetCredential_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 ulCredentialType, /* in */
+ UINT32 ulCredentialAccessMode, /* in */
+ UINT32 * pulCredentialSize, /* out */
+ BYTE ** prgbCredentialData) /* out */
+{
+ TSS_RESULT result;
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((ulCredentialType != TSS_TCS_CREDENTIAL_EKCERT) &&
+ (ulCredentialType != TSS_TCS_CREDENTIAL_TPM_CC) &&
+ (ulCredentialType != TSS_TCS_CREDENTIAL_PLATFORMCERT)) {
+ LogError("GetCredential - Unsupported Credential Type");
+ return TCSERR(TSS_E_BAD_PARAMETER);
+ }
+
+ if (ulCredentialAccessMode == TSS_TCS_CERT_ACCESS_AUTO) {
+ get_credential(ulCredentialType, pulCredentialSize, prgbCredentialData);
+ } else {
+ LogError("GetCredential - Unsupported Credential Access Mode");
+ return TCSERR(TSS_E_FAIL);
+ }
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+TCSP_MakeIdentity2_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_ENCAUTH identityAuth, /* in */
+ TCPA_CHOSENID_HASH IDLabel_PrivCAHash, /* in */
+ UINT32 idKeyInfoSize, /* in */
+ BYTE * idKeyInfo, /* in */
+ TPM_AUTH * pSrkAuth, /* in, out */
+ TPM_AUTH * pOwnerAuth, /* in, out */
+ UINT32 * idKeySize, /* out */
+ BYTE ** idKey, /* out */
+ UINT32 * pcIdentityBindingSize, /* out */
+ BYTE ** prgbIdentityBinding) /* out */
+{
+ UINT64 offset;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (pSrkAuth) {
+ if ((result = auth_mgr_check(hContext, &pSrkAuth->AuthHandle)))
+ goto done;
+ }
+
+ if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
+ goto done;
+
+ offset = 0;
+ if ((result = tpm_rqu_build(TPM_ORD_MakeIdentity, &offset, txBlob, identityAuth.authdata,
+ IDLabel_PrivCAHash.digest, idKeyInfoSize, idKeyInfo, pSrkAuth,
+ pOwnerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ if ((result = tpm_rsp_parse(TPM_ORD_MakeIdentity, txBlob, paramSize, idKeySize,
+ idKey, pcIdentityBindingSize, prgbIdentityBinding,
+ pSrkAuth, pOwnerAuth)))
+ goto done;
+ }
+ LogResult("Make Identity", result);
+done:
+ auth_mgr_release_auth(pSrkAuth, pOwnerAuth, hContext);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_audit.c b/src/tcs/tcsi_audit.c
new file mode 100644
index 0000000..1832f19
--- /dev/null
+++ b/src/tcs/tcsi_audit.c
@@ -0,0 +1,159 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_utils.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+
+TSS_RESULT
+TCSP_SetOrdinalAuditStatus_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_AUTH *ownerAuth, /* in/out */
+ UINT32 ulOrdinal, /* in */
+ TSS_BOOL bAuditState) /* in */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_SetOrdinalAuditStatus, &offset, txBlob, ulOrdinal,
+ bAuditState, ownerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ offset = 10;
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_SetOrdinalAuditStatus, txBlob, paramSize, ownerAuth);
+ }
+
+ LogResult("SetOrdinalAuditStatus", result);
+
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_GetAuditDigest_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 startOrdinal, /* in */
+ TPM_DIGEST *auditDigest, /* out */
+ UINT32 *counterValueSize, /* out */
+ BYTE **counterValue, /* out */
+ TSS_BOOL *more, /* out */
+ UINT32 *ordSize, /* out */
+ UINT32 **ordList) /* out */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_GetAuditDigest, &offset, txBlob, startOrdinal, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ if ((result = tpm_rsp_parse(TPM_ORD_GetAuditDigest, txBlob, paramSize, auditDigest,
+ counterValueSize, counterValue, more, ordSize,
+ ordList)))
+ goto done;
+
+ /* ordSize is returned from the TPM as the number of bytes in ordList
+ so ordSize needs to be converted to comply with the TSS spec which
+ returns the number of ordinals contained in ordList */
+ *ordSize = *ordSize / sizeof(UINT32);
+ }
+
+ LogResult("GetAuditDigest", result);
+
+done:
+ return result;
+}
+
+TSS_RESULT
+TCSP_GetAuditDigestSigned_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE keyHandle, /* in */
+ TSS_BOOL closeAudit, /* in */
+ TPM_NONCE antiReplay, /* in */
+ TPM_AUTH *privAuth, /* in/out */
+ UINT32 *counterValueSize, /* out */
+ BYTE **counterValue, /* out */
+ TPM_DIGEST *auditDigest, /* out */
+ TPM_DIGEST *ordinalDigest, /* out */
+ UINT32 *sigSize, /* out */
+ BYTE **sig) /* out */
+{
+ TSS_RESULT result;
+ TCPA_KEY_HANDLE keySlot;
+ UINT64 offset = 0;//, old_offset;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (privAuth != NULL)
+ if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle)))
+ return result;
+
+ if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_GetAuditDigestSigned, &offset, txBlob, keySlot,
+ closeAudit, antiReplay.nonce, privAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_GetAuditDigestSigned, txBlob, paramSize,
+ counterValueSize, counterValue, auditDigest, ordinalDigest,
+ sigSize, sig, privAuth);
+ }
+
+ LogResult("GetAuditDigestSigned", result);
+
+done:
+ auth_mgr_release_auth(privAuth, NULL, hContext);
+
+ return result;
+}
diff --git a/src/tcs/tcsi_auth.c b/src/tcs/tcsi_auth.c
new file mode 100644
index 0000000..ec4a11e
--- /dev/null
+++ b/src/tcs/tcsi_auth.c
@@ -0,0 +1,111 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+TSS_RESULT
+TCSP_OIAP_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_AUTHHANDLE *authHandle, /* out */
+ TCPA_NONCE *nonce0) /* out */
+{
+ UINT64 offset = 0;
+ TSS_RESULT result;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering TCSI_OIAP");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_OIAP, &offset, txBlob, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_OIAP, txBlob, paramSize, authHandle, nonce0->nonce);
+ }
+
+ LogResult("OIAP", result);
+ return result;
+}
+
+TSS_RESULT
+TCSP_OSAP_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_ENTITY_TYPE entityType, /* in */
+ UINT32 entityValue, /* in */
+ TCPA_NONCE nonceOddOSAP, /* in */
+ TCS_AUTHHANDLE * authHandle, /* out */
+ TCPA_NONCE * nonceEven, /* out */
+ TCPA_NONCE * nonceEvenOSAP) /* out */
+{
+ UINT64 offset = 0;
+ TSS_RESULT result;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering OSAP");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_OSAP, &offset, txBlob, entityType, entityValue,
+ nonceOddOSAP.nonce)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_OSAP, txBlob, paramSize, authHandle,
+ nonceEven->nonce, nonceEvenOSAP->nonce);
+ }
+ LogResult("OSAP", result);
+
+ return result;
+}
+
+TSS_RESULT
+internal_TerminateHandle(TCS_AUTHHANDLE handle)
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = tpm_rqu_build(TPM_ORD_Terminate_Handle, &offset, txBlob, handle, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ return UnloadBlob_Header(txBlob, &paramSize);
+}
+
diff --git a/src/tcs/tcsi_bind.c b/src/tcs/tcsi_bind.c
new file mode 100644
index 0000000..7c9fb46
--- /dev/null
+++ b/src/tcs/tcsi_bind.c
@@ -0,0 +1,78 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+TSS_RESULT
+TCSP_UnBind_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE keyHandle, /* in */
+ UINT32 inDataSize, /* in */
+ BYTE * inData, /* in */
+ TPM_AUTH * privAuth, /* in, out */
+ UINT32 * outDataSize, /* out */
+ BYTE ** outData) /* out */
+{
+ UINT32 paramSize;
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ TCPA_KEY_HANDLE keySlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering TCSI_UnBind");
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (privAuth != NULL) {
+ LogDebug("Auth Used");
+ if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle)))
+ goto done;
+ } else {
+ LogDebug("No Auth");
+ }
+
+ LogDebugFn("calling ensureKeyIsLoaded for TCS handle 0x%x", keyHandle);
+ if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_UnBind, &offset, txBlob, keySlot, inDataSize, inData,
+ privAuth, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_UnBind, txBlob, paramSize, outDataSize, outData,
+ privAuth, NULL);
+ }
+
+done:
+ auth_mgr_release_auth(privAuth, NULL, hContext);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_caps.c b/src/tcs/tcsi_caps.c
new file mode 100644
index 0000000..2d7684f
--- /dev/null
+++ b/src/tcs/tcsi_caps.c
@@ -0,0 +1,269 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+extern struct tcsd_config tcsd_options;
+
+TSS_RESULT
+internal_TCSGetCap(TCS_CONTEXT_HANDLE hContext,
+ TCPA_CAPABILITY_AREA capArea,
+ UINT32 subCap,
+ UINT32 * respSize, BYTE ** resp)
+{
+ UINT32 u32value = 0;
+ UINT64 offset;
+ TPM_VERSION tcsVersion = INTERNAL_CAP_VERSION;
+ struct tcsd_config *config = &tcsd_options;
+ struct platform_class *platClass;
+ TSS_BOOL bValue = FALSE;
+
+ LogDebug("Checking Software Cap of TCS");
+ switch (capArea) {
+ case TSS_TCSCAP_ALG:
+ LogDebug("TSS_TCSCAP_ALG");
+
+ switch (subCap) {
+ case TSS_ALG_RSA:
+ *respSize = sizeof(TSS_BOOL);
+ bValue = INTERNAL_CAP_TCS_ALG_RSA;
+ break;
+ case TSS_ALG_DES:
+ *respSize = sizeof(TSS_BOOL);
+ bValue = INTERNAL_CAP_TCS_ALG_DES;
+ break;
+ case TSS_ALG_3DES:
+ *respSize = sizeof(TSS_BOOL);
+ bValue = INTERNAL_CAP_TCS_ALG_3DES;
+ break;
+ case TSS_ALG_SHA:
+ *respSize = sizeof(TSS_BOOL);
+ bValue = INTERNAL_CAP_TCS_ALG_SHA;
+ break;
+ case TSS_ALG_AES:
+ *respSize = sizeof(TSS_BOOL);
+ bValue = INTERNAL_CAP_TCS_ALG_AES;
+ break;
+ case TSS_ALG_HMAC:
+ *respSize = sizeof(TSS_BOOL);
+ bValue = INTERNAL_CAP_TCS_ALG_HMAC;
+ break;
+ case TSS_ALG_DEFAULT:
+ *respSize = sizeof(UINT32);
+ u32value = INTERNAL_CAP_TCS_ALG_DEFAULT;
+ break;
+ case TSS_ALG_DEFAULT_SIZE:
+ *respSize = sizeof(UINT32);
+ u32value = INTERNAL_CAP_TCS_ALG_DEFAULT_SIZE;
+ break;
+ default:
+ *respSize = 0;
+ LogDebugFn("Bad subcap");
+ return TCSERR(TSS_E_BAD_PARAMETER);
+ }
+
+ if ((*resp = malloc(*respSize)) == NULL) {
+ LogError("malloc of %u bytes failed.", *respSize);
+ *respSize = 0;
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ offset = 0;
+ if (*respSize == sizeof(TSS_BOOL))
+ *(TSS_BOOL *)(*resp) = bValue;
+ else
+ *(UINT32 *)(*resp) = u32value;
+ break;
+ case TSS_TCSCAP_VERSION:
+ LogDebug("TSS_TCSCAP_VERSION");
+ if ((*resp = calloc(1, sizeof(TSS_VERSION))) == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(TSS_VERSION));
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ offset = 0;
+ LoadBlob_VERSION(&offset, *resp, &tcsVersion);
+ *respSize = sizeof(TSS_VERSION);
+ break;
+ case TSS_TCSCAP_PERSSTORAGE:
+ LogDebug("TSS_TCSCAP_PERSSTORAGE");
+ if ((*resp = malloc(sizeof(TSS_BOOL))) == NULL) {
+ LogError("malloc of %zd byte failed.", sizeof(TSS_BOOL));
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ *(TSS_BOOL *)(*resp) = INTERNAL_CAP_TCS_PERSSTORAGE;
+ *respSize = sizeof(TSS_BOOL);
+ break;
+ case TSS_TCSCAP_CACHING:
+ LogDebug("TSS_TCSCAP_CACHING");
+
+ if (subCap == TSS_TCSCAP_PROP_KEYCACHE)
+ bValue = INTERNAL_CAP_TCS_CACHING_KEYCACHE;
+ else if (subCap == TSS_TCSCAP_PROP_AUTHCACHE)
+ bValue = INTERNAL_CAP_TCS_CACHING_AUTHCACHE;
+ else {
+ LogDebugFn("Bad subcap");
+ return TCSERR(TSS_E_BAD_PARAMETER);
+ }
+
+ if ((*resp = malloc(sizeof(TSS_BOOL))) == NULL) {
+ LogError("malloc of %zd byte failed.", sizeof(TSS_BOOL));
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ *respSize = sizeof(TSS_BOOL);
+ *(TSS_BOOL *)(*resp) = bValue;
+ break;
+ case TSS_TCSCAP_MANUFACTURER:
+ if (subCap == TSS_TCSCAP_PROP_MANUFACTURER_ID) {
+ if ((*resp = malloc(sizeof(UINT32))) == NULL) {
+ LogError("malloc of %zd byte failed.", sizeof(UINT32));
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ *(UINT32 *)(*resp) = INTERNAL_CAP_MANUFACTURER_ID;
+ *respSize = sizeof(UINT32);
+ } else if (subCap == TSS_TCSCAP_PROP_MANUFACTURER_STR) {
+ BYTE str[] = INTERNAL_CAP_MANUFACTURER_STR;
+
+ if ((*resp = malloc(INTERNAL_CAP_MANUFACTURER_STR_LEN)) == NULL) {
+ LogError("malloc of %d bytes failed.",
+ INTERNAL_CAP_MANUFACTURER_STR_LEN);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ memcpy(*resp, str, INTERNAL_CAP_MANUFACTURER_STR_LEN);
+ *respSize = INTERNAL_CAP_MANUFACTURER_STR_LEN;
+ } else {
+ LogDebugFn("Bad subcap");
+ return TCSERR(TSS_E_BAD_PARAMETER);
+ }
+ break;
+ case TSS_TCSCAP_TRANSPORT:
+ /* A zero value here means the TSP is asking whether we support transport sessions
+ * at all */
+ if (subCap == TSS_TCSCAP_TRANS_EXCLUSIVE || subCap == 0) {
+ *respSize = sizeof(TSS_BOOL);
+ if ((*resp = malloc(sizeof(TSS_BOOL))) == NULL) {
+ LogError("malloc of %zd byte failed.", sizeof(TSS_BOOL));
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ if (subCap == TSS_TCSCAP_TRANS_EXCLUSIVE)
+ *(TSS_BOOL *)(*resp) = config->exclusive_transport ? TRUE : FALSE;
+ else
+ *(TSS_BOOL *)(*resp) = TRUE;
+ } else {
+ LogDebugFn("Bad subcap");
+ return TCSERR(TSS_E_BAD_PARAMETER);
+ }
+ break;
+ case TSS_TCSCAP_PLATFORM_CLASS:
+ LogDebug("TSS_TCSCAP_PLATFORM_CLASS");
+
+ switch (subCap) {
+ case TSS_TCSCAP_PROP_HOST_PLATFORM:
+ /* Return the TSS_PLATFORM_CLASS */
+ LogDebugFn("TSS_TCSCAP_PROP_HOST_PLATFORM");
+ platClass = config->host_platform_class;
+ /* Computes the size of host platform structure */
+ *respSize = (2 * sizeof(UINT32)) + platClass->classURISize;
+ *resp = malloc(*respSize);
+ if (*resp == NULL) {
+ LogError("malloc of %u bytes failed.", *respSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ memset(*resp, 0, *respSize);
+ offset = 0;
+ LoadBlob_UINT32(&offset, platClass->simpleID, *resp);
+ LoadBlob_UINT32(&offset, platClass->classURISize, *resp);
+ memcpy(&(*resp)[offset], platClass->classURI, platClass->classURISize);
+ LogBlob(*respSize, *resp);
+ break;
+ case TSS_TCSCAP_PROP_ALL_PLATFORMS:
+ /* Return an array of TSS_PLATFORM_CLASSes, when existent */
+ LogDebugFn("TSS_TCSCAP_PROP_ALL_PLATFORMS");
+ *respSize = 0;
+ *resp = NULL;
+ if ((platClass = config->all_platform_classes) != NULL) {
+ /* Computes the size of all Platform Structures */
+ while (platClass != NULL) {
+ *respSize += (2 * sizeof(UINT32)) + platClass->classURISize;
+ platClass = platClass->next;
+ }
+ *resp = malloc(*respSize);
+ if (*resp == NULL) {
+ LogError("malloc of %u bytes failed.", *respSize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ memset(*resp, 0, *respSize);
+ offset = 0;
+ /* Concatenates all the structures on the BYTE * resp */
+ platClass = config->all_platform_classes;
+ while (platClass != NULL){
+ LoadBlob_UINT32(&offset, platClass->simpleID, *resp);
+ LoadBlob_UINT32(&offset, platClass->classURISize, *resp);
+ memcpy(&(*resp)[offset], platClass->classURI,
+ platClass->classURISize);
+ offset += platClass->classURISize;
+ platClass = platClass->next;
+ }
+ LogBlob(*respSize, *resp);
+ }
+ break;
+ default:
+ LogDebugFn("Bad subcap");
+ return TCSERR(TSS_E_BAD_PARAMETER);
+ }
+ break;
+ default:
+ LogDebugFn("Bad cap area");
+ return TCSERR(TSS_E_BAD_PARAMETER);
+ }
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+TCS_GetCapability_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_CAPABILITY_AREA capArea, /* in */
+ UINT32 subCapSize, /* in */
+ BYTE * subCap, /* in */
+ UINT32 * respSize, /* out */
+ BYTE ** resp /* out */
+ )
+{
+ TSS_RESULT result;
+ UINT32 ulSubCap;
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (subCapSize == sizeof(UINT32))
+ ulSubCap = *(UINT32 *)subCap;
+ else if (subCapSize == 0)
+ ulSubCap = 0;
+ else
+ return TCSERR(TSS_E_BAD_PARAMETER);
+
+ return internal_TCSGetCap(hContext, capArea, ulSubCap, respSize, resp);
+}
+
diff --git a/src/tcs/tcsi_caps_tpm.c b/src/tcs/tcsi_caps_tpm.c
new file mode 100644
index 0000000..c64513f
--- /dev/null
+++ b/src/tcs/tcsi_caps_tpm.c
@@ -0,0 +1,138 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+TSS_RESULT
+TCSP_GetCapability_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_CAPABILITY_AREA capArea, /* in */
+ UINT32 subCapSize, /* in */
+ BYTE * subCap, /* in */
+ UINT32 * respSize, /* out */
+ BYTE ** resp) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Get Cap");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_GetCapability, &offset, txBlob, capArea, subCapSize,
+ subCap, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_GetCapability, txBlob, paramSize, respSize, resp,
+ NULL, NULL);
+ }
+ LogResult("Get Cap", result);
+ return result;
+}
+
+TSS_RESULT
+TCSP_GetCapabilityOwner_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_AUTH * pOwnerAuth, /* in / out */
+ TCPA_VERSION * pVersion, /* out */
+ UINT32 * pNonVolatileFlags, /* out */
+ UINT32 * pVolatileFlags) /* out */
+{
+ UINT64 offset = 0;
+ TSS_RESULT result;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Getcap owner");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_GetCapabilityOwner, &offset, txBlob, pOwnerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_GetCapabilityOwner, txBlob, paramSize, pVersion,
+ pNonVolatileFlags, pVolatileFlags, pOwnerAuth);
+ }
+
+ LogResult("GetCapowner", result);
+done:
+ auth_mgr_release_auth(pOwnerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_SetCapability_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_CAPABILITY_AREA capArea, /* in */
+ UINT32 subCapSize, /* in */
+ BYTE * subCap, /* in */
+ UINT32 valueSize, /* in */
+ BYTE * value, /* in */
+ TPM_AUTH * pOwnerAuth) /* in, out */
+{
+ UINT64 offset = 0;
+ TSS_RESULT result;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_SetCapability, &offset, txBlob, capArea, subCapSize,
+ subCap, valueSize, value, pOwnerAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_SetCapability, txBlob, paramSize, pOwnerAuth);
+ }
+
+done:
+ auth_mgr_release_auth(pOwnerAuth, NULL, hContext);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_certify.c b/src/tcs/tcsi_certify.c
new file mode 100644
index 0000000..8fae84e
--- /dev/null
+++ b/src/tcs/tcsi_certify.c
@@ -0,0 +1,90 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+TSS_RESULT
+TCSP_CertifyKey_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE certHandle, /* in */
+ TCS_KEY_HANDLE keyHandle, /* in */
+ TCPA_NONCE antiReplay, /* in */
+ TPM_AUTH * certAuth, /* in, out */
+ TPM_AUTH * keyAuth, /* in, out */
+ UINT32 * CertifyInfoSize, /* out */
+ BYTE ** CertifyInfo, /* out */
+ UINT32 * outDataSize, /* out */
+ BYTE ** outData) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ TCPA_KEY_HANDLE certKeySlot, keySlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Certify Key");
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (certAuth != NULL) {
+ LogDebug("Auth Used for Cert signing key");
+ if ((result = auth_mgr_check(hContext, &certAuth->AuthHandle)))
+ goto done;
+ } else {
+ LogDebug("No Auth used for Cert signing key");
+ }
+
+ if (keyAuth != NULL) {
+ LogDebug("Auth Used for Key being signed");
+ if ((result = auth_mgr_check(hContext, &keyAuth->AuthHandle)))
+ goto done;
+ } else {
+ LogDebug("No Auth used for Key being signed");
+ }
+
+ if ((result = ensureKeyIsLoaded(hContext, certHandle, &certKeySlot)))
+ goto done;
+
+ if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_CertifyKey, &offset, txBlob, certKeySlot, keySlot,
+ antiReplay.nonce, certAuth, keyAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_CertifyKey, txBlob, paramSize, CertifyInfoSize,
+ CertifyInfo, outDataSize, outData, certAuth, keyAuth);
+ }
+ LogResult("Certify Key", result);
+done:
+ auth_mgr_release_auth(certAuth, keyAuth, hContext);
+ return result;
+}
diff --git a/src/tcs/tcsi_changeauth.c b/src/tcs/tcsi_changeauth.c
new file mode 100644
index 0000000..59329ea
--- /dev/null
+++ b/src/tcs/tcsi_changeauth.c
@@ -0,0 +1,374 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+TSS_RESULT
+TCSP_ChangeAuth_Internal(TCS_CONTEXT_HANDLE contextHandle, /* in */
+ TCS_KEY_HANDLE parentHandle, /* in */
+ TCPA_PROTOCOL_ID protocolID, /* in */
+ TCPA_ENCAUTH newAuth, /* in */
+ TCPA_ENTITY_TYPE entityType, /* in */
+ UINT32 encDataSize, /* in */
+ BYTE *encData, /* in */
+ TPM_AUTH *ownerAuth, /* in, out */
+ TPM_AUTH *entityAuth, /* in, out */
+ UINT32 *outDataSize, /* out */
+ BYTE **outData /* out */
+ )
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ TCPA_KEY_HANDLE keySlot;
+ TCS_KEY_HANDLE tcsKeyHandleToEvict;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Changeauth");
+ if ((result = ctx_verify_context(contextHandle)))
+ goto done;
+
+ if ((result = auth_mgr_check(contextHandle, &ownerAuth->AuthHandle)))
+ goto done;
+ if ((result = auth_mgr_check(contextHandle, &entityAuth->AuthHandle)))
+ goto done;
+
+ if ((result = ensureKeyIsLoaded(contextHandle, parentHandle, &keySlot)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_ChangeAuth, &offset, txBlob, keySlot, protocolID,
+ newAuth.authdata, entityType, encDataSize, encData, ownerAuth,
+ entityAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_ChangeAuth, txBlob, paramSize, outDataSize, outData,
+ ownerAuth, entityAuth);
+
+ /* if the malloc above failed, terminate the 2 new auth handles and exit */
+ if (result)
+ goto done;
+
+ /*
+ * Check if ET is a key. If it is, we need to
+ * 1 - Evict the key if loaded
+ * 2 - update the mem cache entry
+ */
+ if (entityType == TCPA_ET_KEYHANDLE || entityType == TCPA_ET_KEY) {
+ LogDebug("entity type is a key. Check if mem cache needs updating...");
+ tcsKeyHandleToEvict = mc_get_handle_by_encdata(encData);
+ LogDebug("tcsKeyHandle being evicted is %.8X", tcsKeyHandleToEvict);
+ /*--- If it was found in knowledge, replace it */
+ if (tcsKeyHandleToEvict != 0) {
+ internal_EvictByKeySlot(keySlot);
+ mc_update_encdata(encData, *outData);
+ }
+
+ }
+ }
+ LogResult("ChangeAuth", result);
+done:
+ auth_mgr_release_auth(ownerAuth, entityAuth, contextHandle);
+ return result;
+}
+
+TSS_RESULT
+TCSP_ChangeAuthOwner_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_PROTOCOL_ID protocolID, /* in */
+ TCPA_ENCAUTH newAuth, /* in */
+ TCPA_ENTITY_TYPE entityType, /* in */
+ TPM_AUTH * ownerAuth /* in, out */
+ )
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering ChangeAuthOwner");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_ChangeAuthOwner, &offset, txBlob, protocolID,
+ newAuth.authdata, entityType, ownerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_ChangeAuthOwner, txBlob, paramSize, ownerAuth);
+ }
+
+ LogResult("ChangeAuthOwner", result);
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_ChangeAuthAsymStart_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE idHandle, /* in */
+ TCPA_NONCE antiReplay, /* in */
+ UINT32 KeySizeIn, /* in */
+ BYTE * KeyDataIn, /* in */
+ TPM_AUTH * pAuth, /* in, out */
+ UINT32 * KeySizeOut, /* out */
+ BYTE ** KeyDataOut, /* out */
+ UINT32 * CertifyInfoSize, /* out */
+ BYTE ** CertifyInfo, /* out */
+ UINT32 * sigSize, /* out */
+ BYTE ** sig, /* out */
+ TCS_KEY_HANDLE * ephHandle /* out */
+ )
+{
+#if 0
+#warning Locking trouble in evictFirstKey
+ UINT64 offset;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ UINT32 keySlot;
+ TCPA_CERTIFY_INFO certifyInfo;
+ TSS_KEY tempKey;
+ UINT32 tempSize;
+ TCPA_KEY_PARMS keyParmsContainer;
+ TSS_BOOL canLoad;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering ChangeAuthAsymStart");
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (pAuth != NULL) {
+ LogDebug("Auth Command");
+ if ((result = auth_mgr_check(hContext, pAuth->AuthHandle)))
+ goto done;
+ } else {
+ LogDebug("No Auth");
+ }
+
+ if ((result = ensureKeyIsLoaded(hContext, idHandle, &keySlot)))
+ goto done;
+
+ LogDebug("Checking for room to load the eph key");
+ offset = 0;
+ if ((result = UnloadBlob_KEY_PARMS(&offset, KeyDataIn, &keyParmsContainer)))
+ goto done;
+
+ /* if we can't load the key, evict keys until we can */
+ if ((result = canILoadThisKey(&keyParmsContainer, &canLoad)))
+ goto done;
+
+ while (canLoad == FALSE) {
+ /* Evict a key that isn't the parent */
+ if ((result = evictFirstKey(idHandle)))
+ goto done;
+
+ if ((result = canILoadThisKey(&keyParmsContainer, &canLoad)))
+ goto done;
+ }
+
+ offset = 10;
+ LoadBlob_UINT32(&offset, keySlot, txBlob);
+ LoadBlob(&offset, TCPA_NONCE_SIZE, txBlob, antiReplay.nonce);
+/* LoadBlob_KEY_PARMS( &offset, txBlob, &tempKeyParms ); */
+/* LoadBlob_UINT32( &offset, KeySizeIn, txBlob ); */
+ LoadBlob(&offset, KeySizeIn, txBlob, KeyDataIn);
+
+ if (pAuth != NULL) {
+ LoadBlob_Auth(&offset, txBlob, pAuth);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, offset,
+ TPM_ORD_ChangeAuthAsymStart, txBlob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, offset,
+ TPM_ORD_ChangeAuthAsymStart, txBlob);
+ }
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ offset = 10;
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (result == 0) {
+ UnloadBlob_CERTIFY_INFO(&offset, txBlob, &certifyInfo);
+ *CertifyInfoSize = offset - 10;
+ *CertifyInfo = malloc(*CertifyInfoSize);
+ if (*CertifyInfo == NULL) {
+ LogError("malloc of %u bytes failed.", *CertifyInfoSize);
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+ memcpy(*CertifyInfo, &txBlob[offset - *CertifyInfoSize],
+ *CertifyInfoSize);
+ UnloadBlob_UINT32(&offset, sigSize, txBlob);
+ *sig = malloc(*sigSize);
+ if (*sig == NULL) {
+ LogError("malloc of %u bytes failed.", *sigSize);
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+ UnloadBlob(&offset, *sigSize, txBlob, *sig);
+ UnloadBlob_UINT32(&offset, ephHandle, txBlob);
+ tempSize = offset;
+ UnloadBlob_TSS_KEY(&offset, txBlob, &tempKey);
+ *KeySizeOut = offset - tempSize;
+ *KeyDataOut = malloc(*KeySizeOut);
+ if (*KeyDataOut == NULL) {
+ LogError("malloc of %u bytes failed.", *KeySizeOut);
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+ memcpy(*KeyDataOut, &txBlob[offset - *KeySizeOut], *KeySizeOut);
+ if (pAuth != NULL)
+ UnloadBlob_Auth(&offset, txBlob, pAuth);
+ }
+
+ LogResult("ChangeAuthAsymStart", result);
+done:
+ auth_mgr_release_auth(pAuth, NULL, hContext);
+ return result;
+#else
+ return TCSERR(TSS_E_NOTIMPL);
+#endif
+}
+
+TSS_RESULT
+TCSP_ChangeAuthAsymFinish_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE parentHandle, /* in */
+ TCS_KEY_HANDLE ephHandle, /* in */
+ TCPA_ENTITY_TYPE entityType, /* in */
+ TCPA_HMAC newAuthLink, /* in */
+ UINT32 newAuthSize, /* in */
+ BYTE * encNewAuth, /* in */
+ UINT32 encDataSizeIn, /* in */
+ BYTE * encDataIn, /* in */
+ TPM_AUTH * ownerAuth, /* in, out */
+ UINT32 * encDataSizeOut, /* out */
+ BYTE ** encDataOut, /* out */
+ TCPA_SALT_NONCE * saltNonce, /* out */
+ TCPA_DIGEST * changeProof /* out */
+ )
+{
+#if 0
+ UINT64 offset;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ UINT32 keySlot;
+#if 0
+ TCPA_CERTIFY_INFO certifyInfo;
+ TSS_KEY tempKey;
+ UINT32 tempSize;
+ TSS_UUID *uuidKeyToEvict;
+#endif
+ TCS_KEY_HANDLE tcsKeyHandleToEvict;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering ChangeAuthAsymFinish");
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (ownerAuth != NULL) {
+ LogDebug("Auth used");
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+ } else {
+ LogDebug("No Auth");
+ }
+ if ((result = ensureKeyIsLoaded(hContext, parentHandle, &keySlot)))
+ goto done;
+
+ offset = 10;
+ LoadBlob_UINT32(&offset, keySlot, txBlob);
+ LoadBlob_UINT32(&offset, ephHandle, txBlob);
+ LoadBlob_UINT16(&offset, entityType, txBlob);
+ LoadBlob(&offset, 20, txBlob, newAuthLink.digest);
+ LoadBlob_UINT32(&offset, newAuthSize, txBlob);
+ LoadBlob(&offset, newAuthSize, txBlob, encNewAuth);
+ LoadBlob_UINT32(&offset, encDataSizeIn, txBlob);
+ LoadBlob(&offset, encDataSizeIn, txBlob, encDataIn);
+
+ if (ownerAuth != NULL) {
+ LoadBlob_Auth(&offset, txBlob, ownerAuth);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, offset,
+ TPM_ORD_ChangeAuthAsymFinish, txBlob);
+ } else {
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, offset,
+ TPM_ORD_ChangeAuthAsymFinish, txBlob);
+ }
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ offset = 10;
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ UnloadBlob_UINT32(&offset, encDataSizeOut, txBlob);
+ *encDataOut = calloc(1, *encDataSizeOut);
+ if (*encDataOut == NULL) {
+ LogError("malloc of %u bytes failed.", *encDataSizeOut);
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+ UnloadBlob(&offset, *encDataSizeOut, txBlob, *encDataOut);
+ UnloadBlob(&offset, 20, txBlob, saltNonce->nonce);
+ UnloadBlob(&offset, 20, txBlob, changeProof->digest);
+ if (ownerAuth != NULL)
+ UnloadBlob_Auth(&offset, txBlob, ownerAuth);
+
+ /* Check if ET is a key. If it is, we need to
+ * 1 - Evict the key if loaded
+ * 2 - update the mem cache entry
+ */
+ if (entityType == TCPA_ET_KEYHANDLE ||
+ entityType == TCPA_ET_KEY) {
+ tcsKeyHandleToEvict = mc_get_handle_by_encdata(encDataIn);
+ /* If it was found in mem cache, replace it */
+ if (tcsKeyHandleToEvict != 0) {
+ key_mgr_evict(hContext, tcsKeyHandleToEvict);
+ mc_update_encdata(encDataIn, *encDataOut);
+ }
+ }
+ }
+
+ LogResult("ChangeAuthAsymFinish", result);
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+#else
+ return TCSERR(TSS_E_NOTIMPL);
+#endif
+}
+
diff --git a/src/tcs/tcsi_cmk.c b/src/tcs/tcsi_cmk.c
new file mode 100644
index 0000000..3f83133
--- /dev/null
+++ b/src/tcs/tcsi_cmk.c
@@ -0,0 +1,326 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_utils.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+
+TSS_RESULT
+TCSP_CMK_SetRestrictions_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_CMK_DELEGATE Restriction, /* in */
+ TPM_AUTH* ownerAuth) /* in */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_CMK_SetRestrictions, &offset, txBlob,
+ Restriction, ownerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_CMK_SetRestrictions, txBlob, paramSize,
+ ownerAuth);
+ }
+
+ LogResult("CMK_SetRestrictions", result);
+
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_CMK_ApproveMA_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_DIGEST migAuthorityDigest, /* in */
+ TPM_AUTH* ownerAuth, /* in, out */
+ TPM_HMAC* HmacMigAuthDigest) /* out */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_CMK_ApproveMA, &offset, txBlob,
+ &migAuthorityDigest, ownerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_CMK_ApproveMA, txBlob, paramSize,
+ HmacMigAuthDigest, ownerAuth);
+ }
+
+ LogResult("CMK_SetRestrictions", result);
+
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_CMK_CreateKey_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE hWrappingKey, /* in */
+ TPM_ENCAUTH KeyUsageAuth, /* in */
+ TPM_HMAC MigAuthApproval, /* in */
+ TPM_DIGEST MigAuthorityDigest, /* in */
+ UINT32* keyDataSize, /* in, out */
+ BYTE** prgbKeyData, /* in, out */
+ TPM_AUTH* pAuth) /* in, out */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ UINT32 parentSlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext))) {
+ free(*prgbKeyData);
+ return result;
+ }
+
+ if ((result = get_slot(hContext, hWrappingKey, &parentSlot))) {
+ free(*prgbKeyData);
+ return result;
+ }
+
+ if (pAuth) {
+ if ((result = auth_mgr_check(hContext, &pAuth->AuthHandle))) {
+ free(*prgbKeyData);
+ return result;
+ }
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_CMK_CreateKey, &offset, txBlob,
+ parentSlot, &KeyUsageAuth, *keyDataSize, *prgbKeyData,
+ &MigAuthApproval, &MigAuthorityDigest, pAuth))) {
+ free(*prgbKeyData);
+ goto done;
+ }
+ free(*prgbKeyData);
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_CMK_CreateKey, txBlob, paramSize,
+ keyDataSize, prgbKeyData, pAuth);
+ }
+
+ LogResult("CMK_SetRestrictions", result);
+
+done:
+ auth_mgr_release_auth(pAuth, NULL, hContext);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_CMK_CreateTicket_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 PublicVerifyKeySize, /* in */
+ BYTE* PublicVerifyKey, /* in */
+ TPM_DIGEST SignedData, /* in */
+ UINT32 SigValueSize, /* in */
+ BYTE* SigValue, /* in */
+ TPM_AUTH* pOwnerAuth, /* in, out */
+ TPM_HMAC* SigTicket) /* out */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_CMK_CreateTicket, &offset, txBlob,
+ PublicVerifyKeySize, PublicVerifyKey, &SignedData,
+ SigValueSize, SigValue, pOwnerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_CMK_CreateTicket, txBlob, paramSize,
+ SigTicket, pOwnerAuth);
+ }
+
+ LogResult("CMK_SetRestrictions", result);
+
+done:
+ auth_mgr_release_auth(pOwnerAuth, NULL, hContext);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_CMK_CreateBlob_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE parentHandle, /* in */
+ TSS_MIGRATE_SCHEME migrationType, /* in */
+ UINT32 MigrationKeyAuthSize, /* in */
+ BYTE* MigrationKeyAuth, /* in */
+ TPM_DIGEST PubSourceKeyDigest, /* in */
+ UINT32 msaListSize, /* in */
+ BYTE* msaList, /* in */
+ UINT32 restrictTicketSize, /* in */
+ BYTE* restrictTicket, /* in */
+ UINT32 sigTicketSize, /* in */
+ BYTE* sigTicket, /* in */
+ UINT32 encDataSize, /* in */
+ BYTE* encData, /* in */
+ TPM_AUTH* parentAuth, /* in, out */
+ UINT32* randomSize, /* out */
+ BYTE** random, /* out */
+ UINT32* outDataSize, /* out */
+ BYTE** outData) /* out */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ UINT32 parentSlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = get_slot(hContext, parentHandle, &parentSlot)))
+ return result;
+
+ if (parentAuth) {
+ if ((result = auth_mgr_check(hContext, &parentAuth->AuthHandle)))
+ return result;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_CMK_CreateBlob, &offset, txBlob,
+ parentSlot, migrationType, MigrationKeyAuthSize,
+ MigrationKeyAuth, &PubSourceKeyDigest, msaListSize, msaList,
+ restrictTicketSize, restrictTicket, sigTicketSize, sigTicket,
+ encDataSize, encData, parentAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_CMK_CreateBlob, txBlob, paramSize,
+ randomSize, random, outDataSize, outData, parentAuth, NULL);
+ }
+
+ LogResult("CMK_SetRestrictions", result);
+
+done:
+ auth_mgr_release_auth(parentAuth, NULL, hContext);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_CMK_ConvertMigration_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE parentHandle, /* in */
+ TPM_CMK_AUTH restrictTicket, /* in */
+ TPM_HMAC sigTicket, /* in */
+ UINT32 keyDataSize, /* in */
+ BYTE* prgbKeyData, /* in */
+ UINT32 msaListSize, /* in */
+ BYTE* msaList, /* in */
+ UINT32 randomSize, /* in */
+ BYTE* random, /* in */
+ TPM_AUTH* parentAuth, /* in, out */
+ UINT32* outDataSize, /* out */
+ BYTE** outData) /* out */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ UINT32 parentSlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = get_slot(hContext, parentHandle, &parentSlot)))
+ return result;
+
+ if (parentAuth) {
+ if ((result = auth_mgr_check(hContext, &parentAuth->AuthHandle)))
+ return result;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_CMK_ConvertMigration, &offset, txBlob,
+ parentSlot, &restrictTicket, &sigTicket,
+ keyDataSize, prgbKeyData, msaListSize, msaList,
+ randomSize, random, parentAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_CMK_ConvertMigration, txBlob, paramSize,
+ outDataSize, outData, parentAuth, NULL);
+ }
+
+ LogResult("CMK_SetRestrictions", result);
+
+done:
+ auth_mgr_release_auth(parentAuth, NULL, hContext);
+
+ return result;
+}
+
diff --git a/src/tcs/tcsi_context.c b/src/tcs/tcsi_context.c
new file mode 100644
index 0000000..d6fe606
--- /dev/null
+++ b/src/tcs/tcsi_context.c
@@ -0,0 +1,62 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+
+
+TSS_RESULT
+TCS_OpenContext_Internal(TCS_CONTEXT_HANDLE * hContext) /* out */
+{
+ *hContext = make_context();
+ if (*hContext == 0)
+ return TCSERR(TSS_E_OUTOFMEMORY);
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+TCS_CloseContext_Internal(TCS_CONTEXT_HANDLE hContext) /* in */
+{
+ TSS_RESULT result;
+
+ LogDebug("Closing context %.8X", hContext);
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ destroy_context(hContext);
+
+ /* close all auth handles associated with hContext */
+ auth_mgr_close_context(hContext);
+
+ KEY_MGR_ref_count();
+
+ LogDebug("Context %.8X closed", hContext);
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+TCS_FreeMemory_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ BYTE *pMemory) /* in */
+{
+ free(pMemory);
+
+ return TSS_SUCCESS;
+}
diff --git a/src/tcs/tcsi_counter.c b/src/tcs/tcsi_counter.c
new file mode 100644
index 0000000..edba088
--- /dev/null
+++ b/src/tcs/tcsi_counter.c
@@ -0,0 +1,212 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsps.h"
+#include "req_mgr.h"
+
+
+TSS_RESULT
+TCSP_ReadCounter_Internal(TCS_CONTEXT_HANDLE hContext,
+ TSS_COUNTER_ID idCounter,
+ TPM_COUNTER_VALUE* counterValue)
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_ReadCounter, &offset, txBlob, idCounter, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto out;
+
+ if ((result = UnloadBlob_Header(txBlob, &paramSize))) {
+ LogDebugFn("TPM_ReadCounter failed: rc=0x%x", result);
+ goto out;
+ }
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_ReadCounter, txBlob, paramSize, NULL, counterValue,
+ NULL);
+ }
+
+out:
+ return result;
+}
+
+TSS_RESULT
+TCSP_CreateCounter_Internal(TCS_CONTEXT_HANDLE hContext,
+ UINT32 LabelSize,
+ BYTE* pLabel,
+ TPM_ENCAUTH CounterAuth,
+ TPM_AUTH* pOwnerAuth,
+ TSS_COUNTER_ID* idCounter,
+ TPM_COUNTER_VALUE* counterValue)
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if (LabelSize != 4) {
+ LogDebugFn("BAD_PARAMETER: LabelSize != 4");
+ return TCSERR(TSS_E_BAD_PARAMETER);
+ }
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_CreateCounter, &offset, txBlob, CounterAuth.authdata,
+ LabelSize, pLabel, pOwnerAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto out;
+
+ if ((result = UnloadBlob_Header(txBlob, &paramSize))) {
+ LogDebugFn("TPM_CreateCounter failed: rc=0x%x", result);
+ goto out;
+ }
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_CreateCounter, txBlob, paramSize, idCounter,
+ counterValue, pOwnerAuth);
+ }
+
+out:
+ return result;
+}
+
+TSS_RESULT
+TCSP_IncrementCounter_Internal(TCS_CONTEXT_HANDLE hContext,
+ TSS_COUNTER_ID idCounter,
+ TPM_AUTH* pCounterAuth,
+ TPM_COUNTER_VALUE* counterValue)
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = auth_mgr_check(hContext, &pCounterAuth->AuthHandle)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_IncrementCounter, &offset, txBlob, idCounter,
+ pCounterAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto out;
+
+ if ((result = UnloadBlob_Header(txBlob, &paramSize))) {
+ LogDebugFn("UnloadBlob_Header failed: rc=0x%x", result);
+ goto out;
+ }
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_IncrementCounter, txBlob, paramSize, NULL,
+ counterValue, pCounterAuth);
+ }
+out:
+ return result;
+}
+
+TSS_RESULT
+TCSP_ReleaseCounter_Internal(TCS_CONTEXT_HANDLE hContext,
+ TSS_COUNTER_ID idCounter,
+ TPM_AUTH* pCounterAuth)
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = auth_mgr_check(hContext, &pCounterAuth->AuthHandle)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_ReleaseCounter, &offset, txBlob, idCounter,
+ pCounterAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto out;
+
+ if ((result = UnloadBlob_Header(txBlob, &paramSize))) {
+ LogDebugFn("UnloadBlob_Header failed: rc=0x%x", result);
+ goto out;
+ }
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_ReleaseCounter, txBlob, paramSize, pCounterAuth);
+ }
+out:
+ return result;
+}
+
+TSS_RESULT
+TCSP_ReleaseCounterOwner_Internal(TCS_CONTEXT_HANDLE hContext,
+ TSS_COUNTER_ID idCounter,
+ TPM_AUTH* pOwnerAuth)
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_ReleaseCounterOwner, &offset, txBlob, idCounter,
+ pOwnerAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto out;
+
+ if ((result = UnloadBlob_Header(txBlob, &paramSize))) {
+ LogDebugFn("UnloadBlob_Header failed: rc=0x%x", result);
+ goto out;
+ }
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_ReleaseCounterOwner, txBlob, paramSize, pOwnerAuth);
+ }
+out:
+ return result;
+}
+
diff --git a/src/tcs/tcsi_daa.c b/src/tcs/tcsi_daa.c
new file mode 100644
index 0000000..293f4b3
--- /dev/null
+++ b/src/tcs/tcsi_daa.c
@@ -0,0 +1,192 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+TSS_RESULT
+TCSP_DaaJoin_internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_HANDLE handle, /* in */
+ BYTE stage, /* in */
+ UINT32 inputSize0, /* in */
+ BYTE *inputData0, /* in */
+ UINT32 inputSize1, /* in */
+ BYTE *inputData1, /* in */
+ TPM_AUTH * ownerAuth, /* in, out */
+ UINT32 *outputSize, /* out */
+ BYTE **outputData) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+ if ( (result = ctx_verify_context(hContext)) != TSS_SUCCESS)
+ return result;
+ if( (result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)) != TSS_SUCCESS)
+ goto done;
+
+#if 0
+ offset = 10;
+ LoadBlob_UINT32( &offset, handle, txBlob);
+ LogDebug("load BYTE: stage: %x", stage);
+ LoadBlob( &offset, sizeof(BYTE), txBlob, &stage);
+
+ LogDebug("load UNIT32: inputSize0: %x (oldOffset=%" PRIu64 ")", inputSize0, offset);
+ LoadBlob_UINT32(&offset, inputSize0, txBlob);
+ LogDebug("load Data: inputData0: %X (oldOffset=%" PRIu64 ")", (int)inputData0, offset);
+ LoadBlob(&offset, inputSize0, txBlob, inputData0);
+ LogDebug("load UINT32: inputSize1:%x (oldOffset=%" PRIu64 ")", inputSize1, offset);
+ LoadBlob_UINT32(&offset, inputSize1, txBlob);
+ if( inputSize1>0) {
+ LogDebug("load Data: inputData1: %X (oldOffset=%" PRIu64 ")", (int)inputData1, offset);
+ LoadBlob(&offset, inputSize1, txBlob, inputData1);
+ }
+ LogDebug("load Auth: ownerAuth: %X (oldOffset=%" PRIu64 ")", (int)ownerAuth, offset);
+ LoadBlob_Auth(&offset, txBlob, ownerAuth);
+
+ LogDebug("load Header: ordinal: %X (oldOffset=%" PRIu64 ")", TPM_ORD_DAA_Join, offset);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, offset, TPM_ORD_DAA_Join, txBlob);
+#else
+ if ((result = tpm_rqu_build(TPM_ORD_DAA_Join, &offset, txBlob, handle, stage, inputSize0,
+ inputData0, inputSize1, inputData1, ownerAuth)))
+ goto done;
+#endif
+
+ LogDebug("req_mgr_submit_req (oldOffset=%" PRIu64 ")", offset);
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogDebug("UnloadBlob (paramSize=%d) result=%d", paramSize, result);
+ if (!result) {
+#if 0
+ offset = 10;
+ UnloadBlob_UINT32( &offset, outputSize, txBlob);
+ LogDebug("Unload outputSize=%d", *outputSize);
+ *outputData = malloc(*outputSize);
+ if( *outputData == NULL) {
+ LogError("malloc of %u bytes failed.", *outputSize);
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+ LogDebug("Unload outputData");
+ UnloadBlob( &offset, *outputSize, txBlob, *outputData);
+ LogDebug("Unload Auth");
+ UnloadBlob_Auth(&offset, txBlob, ownerAuth);
+#else
+ result = tpm_rsp_parse(TPM_ORD_DAA_Join, txBlob, paramSize, outputSize, outputData,
+ ownerAuth);
+#endif
+ }
+done:
+ LogDebug("Leaving DaaJoin with result:%d", result);
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT TCSP_DaaSign_internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_HANDLE handle, /* in */
+ BYTE stage, /* in */
+ UINT32 inputSize0, /* in */
+ BYTE *inputData0, /* in */
+ UINT32 inputSize1, /* in */
+ BYTE *inputData1, /* in */
+ TPM_AUTH * ownerAuth, /* in, out */
+ UINT32 *outputSize, /* out */
+ BYTE **outputData) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+ if ( (result = ctx_verify_context(hContext)) != TSS_SUCCESS)
+ return result;
+
+ if( (result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)) != TSS_SUCCESS)
+ goto done;
+
+#if 0
+ offset = 10;
+ LoadBlob_UINT32( &offset, handle, txBlob);
+ LogDebug("load BYTE: stage: %x", stage);
+ LoadBlob( &offset, sizeof(BYTE), txBlob, &stage);
+
+ LogDebug("load UNIT32: inputSize0: %x (oldOffset=%" PRIu64 ")", inputSize0, offset);
+ LoadBlob_UINT32(&offset, inputSize0, txBlob);
+ LogDebug("load Data: inputData0: %X (oldOffset=%" PRIu64 ")", (int)inputData0, offset);
+ LoadBlob(&offset, inputSize0, txBlob, inputData0);
+ LogDebug("load UINT32: inputSize1:%x (oldOffset=%" PRIu64 ")", inputSize1, offset);
+ LoadBlob_UINT32(&offset, inputSize1, txBlob);
+ if( inputSize1>0) {
+ LogDebug("load Data: inputData1: %X (oldOffset=%" PRIu64 ")", (int)inputData1, offset);
+ LoadBlob(&offset, inputSize1, txBlob, inputData1);
+ }
+ LogDebug("load Auth: ownerAuth: %X (oldOffset=%" PRIu64 ")", (int)ownerAuth, offset);
+ LoadBlob_Auth(&offset, txBlob, ownerAuth);
+
+ LogDebug("load Header: ordinal: %X (oldOffset=%" PRIu64 ")", TPM_ORD_DAA_Sign, offset);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, offset, TPM_ORD_DAA_Sign, txBlob);
+#else
+ if ((result = tpm_rqu_build(TPM_ORD_DAA_Sign, &offset, txBlob, handle, stage, inputSize0,
+ inputData0, inputSize1, inputData1, ownerAuth)))
+ goto done;
+#endif
+
+ LogDebug("req_mgr_submit_req (oldOffset=%" PRIu64 ")", offset);
+ if ((result = req_mgr_submit_req(txBlob))) goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogDebug("UnloadBlob (paramSize=%d) result=%d", paramSize, result);
+ if (!result) {
+#if 0
+ offset = 10;
+ UnloadBlob_UINT32( &offset, outputSize, txBlob);
+ LogDebug("Unload outputSize=%d", *outputSize);
+ *outputData = malloc(*outputSize);
+ if( *outputData == NULL) {
+ LogError("malloc of %u bytes failed.", *outputSize);
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+ LogDebug("Unload outputData");
+ UnloadBlob(&offset, *outputSize, txBlob, *outputData);
+ LogDebug("Unload Auth");
+ UnloadBlob_Auth(&offset, txBlob, ownerAuth);
+#else
+ result = tpm_rsp_parse(TPM_ORD_DAA_Sign, txBlob, paramSize, outputSize, outputData,
+ ownerAuth);
+#endif
+ }
+done:
+ LogDebug("Leaving DaaSign with result:%d", result);
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_delegate.c b/src/tcs/tcsi_delegate.c
new file mode 100644
index 0000000..b46501c
--- /dev/null
+++ b/src/tcs/tcsi_delegate.c
@@ -0,0 +1,366 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_utils.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+
+TSS_RESULT
+TCSP_Delegate_Manage_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_FAMILY_ID familyID, /* in */
+ TPM_FAMILY_OPERATION opFlag, /* in */
+ UINT32 opDataSize, /* in */
+ BYTE *opData, /* in */
+ TPM_AUTH *ownerAuth, /* in/out */
+ UINT32 *retDataSize, /* out */
+ BYTE **retData) /* out */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (ownerAuth) {
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ return result;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_Delegate_Manage, &offset, txBlob, familyID, opFlag,
+ opDataSize, opData, ownerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_Delegate_Manage, txBlob, paramSize, retDataSize,
+ retData, ownerAuth, NULL);
+ }
+
+ LogResult("Delegate_Manage", result);
+
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_Delegate_CreateKeyDelegation_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE hKey, /* in */
+ UINT32 publicInfoSize, /* in */
+ BYTE *publicInfo, /* in */
+ TPM_ENCAUTH *encDelAuth, /* in */
+ TPM_AUTH *keyAuth, /* in, out */
+ UINT32 *blobSize, /* out */
+ BYTE **blob) /* out */
+{
+ TSS_RESULT result;
+ TCPA_KEY_HANDLE keySlot;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (keyAuth) {
+ if ((result = auth_mgr_check(hContext, &keyAuth->AuthHandle)))
+ return result;
+ }
+
+ if ((result = ensureKeyIsLoaded(hContext, hKey, &keySlot)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_Delegate_CreateKeyDelegation, &offset, txBlob, keySlot,
+ publicInfoSize, publicInfo, encDelAuth, keyAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_Delegate_CreateKeyDelegation, txBlob, paramSize,
+ blobSize, blob, keyAuth, NULL);
+ }
+
+ LogResult("Delegate_CreateKeyDelegation", result);
+
+done:
+ auth_mgr_release_auth(keyAuth, NULL, hContext);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_Delegate_CreateOwnerDelegation_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_BOOL increment, /* in */
+ UINT32 publicInfoSize, /* in */
+ BYTE *publicInfo, /* in */
+ TPM_ENCAUTH *encDelAuth, /* in */
+ TPM_AUTH *ownerAuth, /* in, out */
+ UINT32 *blobSize, /* out */
+ BYTE **blob) /* out */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (ownerAuth) {
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ return result;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_Delegate_CreateOwnerDelegation, &offset, txBlob,
+ increment, publicInfoSize, publicInfo, encDelAuth, ownerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_Delegate_CreateOwnerDelegation, txBlob, paramSize,
+ blobSize, blob, ownerAuth, NULL);
+ }
+
+ LogResult("Delegate_CreateOwnerDelegation", result);
+
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_Delegate_LoadOwnerDelegation_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_DELEGATE_INDEX index, /* in */
+ UINT32 blobSize, /* in */
+ BYTE *blob, /* in */
+ TPM_AUTH *ownerAuth) /* in, out */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (ownerAuth) {
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ return result;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_Delegate_LoadOwnerDelegation, &offset, txBlob, index,
+ blobSize, blob, ownerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_Delegate_LoadOwnerDelegation, txBlob, paramSize,
+ ownerAuth);
+ }
+
+ LogResult("Delegate_LoadOwnerDelegation", result);
+
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_Delegate_ReadTable_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 *familyTableSize, /* out */
+ BYTE **familyTable, /* out */
+ UINT32 *delegateTableSize, /* out */
+ BYTE **delegateTable) /* out */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_Delegate_ReadTable, &offset, txBlob, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_Delegate_ReadTable, txBlob, paramSize,
+ familyTableSize, familyTable, delegateTableSize,
+ delegateTable, NULL, NULL);
+ }
+
+ LogResult("Delegate_ReadTable", result);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_Delegate_UpdateVerificationCount_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 inputSize, /* in */
+ BYTE *input, /* in */
+ TPM_AUTH *ownerAuth, /* in, out */
+ UINT32 *outputSize, /* out */
+ BYTE **output) /* out */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (ownerAuth) {
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ return result;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_Delegate_UpdateVerification, &offset, txBlob, inputSize,
+ inputSize, input, ownerAuth, NULL)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_Delegate_UpdateVerification, txBlob, paramSize,
+ outputSize, output, ownerAuth, NULL);
+ }
+
+ LogResult("Delegate_UpdateVerificationCount", result);
+
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_Delegate_VerifyDelegation_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 delegateSize, /* in */
+ BYTE *delegate) /* in */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_Delegate_VerifyDelegation, &offset, txBlob,
+ delegateSize, delegateSize, delegate, NULL, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ LogResult("Delegate_VerifyDelegation", result);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_DSAP_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_ENTITY_TYPE entityType, /* in */
+ TCS_KEY_HANDLE keyHandle, /* in */
+ TPM_NONCE *nonceOddDSAP, /* in */
+ UINT32 entityValueSize, /* in */
+ BYTE *entityValue, /* in */
+ TCS_AUTHHANDLE *authHandle, /* out */
+ TPM_NONCE *nonceEven, /* out */
+ TPM_NONCE *nonceEvenDSAP) /* out */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TPM_KEY_HANDLE tpmKeyHandle;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (ensureKeyIsLoaded(hContext, keyHandle, &tpmKeyHandle))
+ return TCSERR(TSS_E_KEY_NOT_LOADED);
+
+ /* are the maximum number of auth sessions open? */
+ if (auth_mgr_req_new(hContext) == FALSE) {
+ if ((result = auth_mgr_swap_out(hContext)))
+ goto done;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_DSAP, &offset, txBlob, entityType, tpmKeyHandle,
+ nonceOddDSAP, entityValueSize, entityValue)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ if ((result = tpm_rsp_parse(TPM_ORD_DSAP, txBlob, paramSize, authHandle,
+ nonceEven->nonce, nonceEvenDSAP->nonce)))
+ goto done;
+
+ /* success, add an entry to the table */
+ result = auth_mgr_add(hContext, *authHandle);
+ }
+done:
+ LogResult("DSAP", result);
+
+ return result;
+}
diff --git a/src/tcs/tcsi_dir.c b/src/tcs/tcsi_dir.c
new file mode 100644
index 0000000..9d5030a
--- /dev/null
+++ b/src/tcs/tcsi_dir.c
@@ -0,0 +1,103 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+TSS_RESULT
+TCSP_DirWriteAuth_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_DIRINDEX dirIndex, /* in */
+ TCPA_DIRVALUE newContents, /* in */
+ TPM_AUTH * ownerAuth) /* in, out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering dirwriteauth");
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ if (dirIndex > tpm_metrics.num_dirs) {
+ result = TCSERR(TSS_E_BAD_PARAMETER);
+ goto done;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_DirWriteAuth, &offset, txBlob, dirIndex,
+ TPM_DIGEST_SIZE, newContents.digest, ownerAuth, NULL)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_DirWriteAuth, txBlob, paramSize, ownerAuth);
+ }
+ LogResult("DirWriteAuth", result);
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_DirRead_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_DIRINDEX dirIndex, /* in */
+ TCPA_DIRVALUE * dirValue) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering DirRead");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (dirValue == NULL)
+ return TCSERR(TSS_E_BAD_PARAMETER);
+
+ if (dirIndex > tpm_metrics.num_dirs)
+ return TCSERR(TSS_E_BAD_PARAMETER);
+
+ if ((result = tpm_rqu_build(TPM_ORD_DirRead, &offset, txBlob, dirIndex, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_DirRead, txBlob, paramSize, NULL, dirValue->digest);
+ }
+ LogResult("DirRead", result);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_ek.c b/src/tcs/tcsi_ek.c
new file mode 100644
index 0000000..34388da
--- /dev/null
+++ b/src/tcs/tcsi_ek.c
@@ -0,0 +1,226 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004, 2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+TSS_RESULT
+TCSP_CreateEndorsementKeyPair_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_NONCE antiReplay, /* in */
+ UINT32 endorsementKeyInfoSize, /* in */
+ BYTE * endorsementKeyInfo, /* in */
+ UINT32 * endorsementKeySize, /* out */
+ BYTE ** endorsementKey, /* out */
+ TCPA_DIGEST * checksum) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_CreateEndorsementKeyPair, &offset, txBlob,
+ antiReplay.nonce, endorsementKeyInfoSize,
+ endorsementKeyInfo)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_CreateEndorsementKeyPair, txBlob, paramSize,
+ endorsementKeySize, endorsementKey, checksum->digest);
+ }
+ LogDebug("Leaving CreateEKPair with result: 0x%x", result);
+ return result;
+}
+
+TSS_RESULT
+TCSP_ReadPubek_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_NONCE antiReplay, /* in */
+ UINT32 * pubEndorsementKeySize, /* out */
+ BYTE ** pubEndorsementKey, /* out */
+ TCPA_DIGEST * checksum) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_ReadPubek, &offset, txBlob, TPM_NONCE_SIZE,
+ antiReplay.nonce)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_ReadPubek, txBlob, paramSize, pubEndorsementKeySize,
+ pubEndorsementKey, checksum->digest);
+ }
+ LogDebugFn("result: 0x%x", result);
+ return result;
+}
+
+TSS_RESULT
+TCSP_DisablePubekRead_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_AUTH * ownerAuth) /* in, out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("DisablePubekRead");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_DisablePubekRead, &offset, txBlob, ownerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_DisablePubekRead, txBlob, paramSize, ownerAuth);
+ }
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_OwnerReadPubek_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_AUTH * ownerAuth, /* in, out */
+ UINT32 * pubEndorsementKeySize, /* out */
+ BYTE ** pubEndorsementKey) /* out */
+{
+ UINT32 paramSize;
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering OwnerReadPubek");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_OwnerReadPubek, &offset, txBlob, ownerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_OwnerReadPubek, txBlob, paramSize,
+ pubEndorsementKeySize, pubEndorsementKey, ownerAuth);
+ }
+ LogResult("Owner Read Pubek", result);
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_CreateRevocableEndorsementKeyPair_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_NONCE antiReplay, /* in */
+ UINT32 endorsementKeyInfoSize, /* in */
+ BYTE * endorsementKeyInfo, /* in */
+ TSS_BOOL genResetAuth, /* in */
+ TPM_DIGEST * eKResetAuth, /* in, out */
+ UINT32 * endorsementKeySize, /* out */
+ BYTE ** endorsementKey, /* out */
+ TPM_DIGEST * checksum) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_CreateRevocableEK, &offset, txBlob,
+ antiReplay.nonce, endorsementKeyInfoSize,
+ endorsementKeyInfo, genResetAuth, eKResetAuth->digest)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_CreateRevocableEK, txBlob, paramSize,
+ endorsementKeySize, endorsementKey, checksum->digest,
+ eKResetAuth->digest);
+ }
+
+ LogDebug("Leaving CreateRevocableEKPair with result: 0x%x", result);
+ return result;
+}
+
+TSS_RESULT
+TCSP_RevokeEndorsementKeyPair_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_DIGEST EKResetAuth) /* in */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_RevokeTrust, &offset, txBlob, EKResetAuth.digest)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ LogDebug("Leaving RevokeEKPair with result: 0x%x", result);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_evlog.c b/src/tcs/tcsi_evlog.c
new file mode 100644
index 0000000..7d49600
--- /dev/null
+++ b/src/tcs/tcsi_evlog.c
@@ -0,0 +1,388 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+#include "tcslog.h"
+#include "tcsem.h"
+
+
+TSS_RESULT
+TCS_LogPcrEvent_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_PCR_EVENT Event, /* in */
+ UINT32 *pNumber) /* out */
+{
+ TSS_RESULT result;
+
+ if((result = ctx_verify_context(hContext)))
+ return result;
+
+ if(Event.ulPcrIndex >= tpm_metrics.num_pcrs)
+ return TCSERR(TSS_E_BAD_PARAMETER);
+
+ if (tcsd_options.kernel_pcrs & (1 << Event.ulPcrIndex)) {
+ LogInfo("PCR %d is configured to be kernel controlled. Event logging denied.",
+ Event.ulPcrIndex);
+ return TCSERR(TSS_E_FAIL);
+ }
+
+ if (tcsd_options.firmware_pcrs & (1 << Event.ulPcrIndex)) {
+ LogInfo("PCR %d is configured to be firmware controlled. Event logging denied.",
+ Event.ulPcrIndex);
+ return TCSERR(TSS_E_FAIL);
+ }
+
+ return event_log_add(&Event, pNumber);
+}
+
+/* This routine will handle creating the TSS_PCR_EVENT structures from log
+ * data produced by an external source. The external source in mind here
+ * is the log of PCR extends done by the kernel from beneath the TSS
+ * (via direct calls to the device driver).
+ */
+TSS_RESULT
+TCS_GetExternalPcrEvent(UINT32 PcrIndex, /* in */
+ UINT32 *pNumber, /* in, out */
+ TSS_PCR_EVENT **ppEvent) /* out */
+{
+ FILE *log_handle;
+ char *source;
+
+ if (tcsd_options.kernel_pcrs & (1 << PcrIndex)) {
+ source = tcsd_options.kernel_log_file;
+
+ if (tcs_event_log->kernel_source != NULL) {
+ if (tcs_event_log->kernel_source->open((void *)source,
+ (FILE **) &log_handle))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (tcs_event_log->kernel_source->get_entry(log_handle, PcrIndex,
+ pNumber, ppEvent)) {
+ tcs_event_log->kernel_source->close(log_handle);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ tcs_event_log->kernel_source->close(log_handle);
+ } else {
+ LogError("No source for externel kernel events was compiled in, but "
+ "the tcsd is configured to use one! (see %s)",
+ tcsd_config_file);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else if (tcsd_options.firmware_pcrs & (1 << PcrIndex)) {
+ source = tcsd_options.firmware_log_file;
+
+ if (tcs_event_log->firmware_source != NULL) {
+ if (tcs_event_log->firmware_source->open((void *)source, &log_handle))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (tcs_event_log->firmware_source->get_entry(log_handle, PcrIndex,
+ pNumber, ppEvent)) {
+ tcs_event_log->firmware_source->close(log_handle);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ tcs_event_log->firmware_source->close(log_handle);
+ } else {
+ LogError("No source for externel firmware events was compiled in, but "
+ "the tcsd is configured to use one! (see %s)",
+ tcsd_config_file);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else {
+ LogError("PCR index %d not flagged as kernel or firmware controlled.", PcrIndex);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+TCS_GetPcrEvent_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 PcrIndex, /* in */
+ UINT32 *pNumber, /* in, out */
+ TSS_PCR_EVENT **ppEvent) /* out */
+{
+ TSS_RESULT result;
+ TSS_PCR_EVENT *event;
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if(PcrIndex >= tpm_metrics.num_pcrs)
+ return TCSERR(TSS_E_BAD_PARAMETER);
+
+ /* if this is a kernel or firmware controlled PCR, call an external routine */
+ if ((tcsd_options.kernel_pcrs & (1 << PcrIndex)) ||
+ (tcsd_options.firmware_pcrs & (1 << PcrIndex))) {
+ MUTEX_LOCK(tcs_event_log->lock);
+ result = TCS_GetExternalPcrEvent(PcrIndex, pNumber, ppEvent);
+ MUTEX_UNLOCK(tcs_event_log->lock);
+
+ return result;
+ }
+
+ if (ppEvent == NULL) {
+ MUTEX_LOCK(tcs_event_log->lock);
+
+ *pNumber = get_num_events(PcrIndex);
+
+ MUTEX_UNLOCK(tcs_event_log->lock);
+ } else {
+ *ppEvent = calloc(1, sizeof(TSS_PCR_EVENT));
+ if (*ppEvent == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(TSS_PCR_EVENT));
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ event = get_pcr_event(PcrIndex, *pNumber);
+ if (event == NULL) {
+ free(*ppEvent);
+ return TCSERR(TSS_E_BAD_PARAMETER);
+ }
+
+ if ((result = copy_pcr_event(*ppEvent, event))) {
+ free(*ppEvent);
+ return result;
+ }
+ }
+
+ return TSS_SUCCESS;
+}
+
+/* This routine will handle creating the TSS_PCR_EVENT structures from log
+ * data produced by an external source. The external source in mind here
+ * is the log of PCR extends done by the kernel from beneath the TSS
+ * (via direct calls to the device driver).
+ */
+TSS_RESULT
+TCS_GetExternalPcrEventsByPcr(UINT32 PcrIndex, /* in */
+ UINT32 FirstEvent, /* in */
+ UINT32 *pEventCount, /* in, out */
+ TSS_PCR_EVENT **ppEvents) /* out */
+{
+ FILE *log_handle;
+ char *source;
+
+ if (tcsd_options.kernel_pcrs & (1 << PcrIndex)) {
+ source = tcsd_options.kernel_log_file;
+
+ if (tcs_event_log->kernel_source != NULL) {
+ if (tcs_event_log->kernel_source->open((void *)source, &log_handle))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (tcs_event_log->kernel_source->get_entries_by_pcr(log_handle, PcrIndex,
+ FirstEvent, pEventCount, ppEvents)) {
+ tcs_event_log->kernel_source->close(log_handle);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ tcs_event_log->kernel_source->close(log_handle);
+ } else {
+ LogError("No source for externel kernel events was compiled in, but "
+ "the tcsd is configured to use one! (see %s)",
+ tcsd_config_file);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else if (tcsd_options.firmware_pcrs & (1 << PcrIndex)) {
+ source = tcsd_options.firmware_log_file;
+
+ if (tcs_event_log->firmware_source != NULL) {
+ if (tcs_event_log->firmware_source->open((void *)source, &log_handle))
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+
+ if (tcs_event_log->firmware_source->get_entries_by_pcr(log_handle, PcrIndex,
+ FirstEvent, pEventCount, ppEvents)) {
+ tcs_event_log->firmware_source->close(log_handle);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ tcs_event_log->firmware_source->close(log_handle);
+ } else {
+ LogError("No source for externel firmware events was compiled in, but "
+ "the tcsd is configured to use one! (see %s)",
+ tcsd_config_file);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ } else {
+ LogError("PCR index %d not flagged as kernel or firmware controlled.", PcrIndex);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+TCS_GetPcrEventsByPcr_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 PcrIndex, /* in */
+ UINT32 FirstEvent, /* in */
+ UINT32 *pEventCount, /* in, out */
+ TSS_PCR_EVENT **ppEvents) /* out */
+{
+ UINT32 lastEventNumber, i, eventIndex;
+ TSS_RESULT result;
+ struct event_wrapper *tmp;
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (PcrIndex >= tpm_metrics.num_pcrs)
+ return TCSERR(TSS_E_BAD_PARAMETER);
+
+ /* if this is a kernel or firmware controlled PCR, call an external routine */
+ if ((tcsd_options.kernel_pcrs & (1 << PcrIndex)) ||
+ (tcsd_options.firmware_pcrs & (1 << PcrIndex))) {
+ MUTEX_LOCK(tcs_event_log->lock);
+ result = TCS_GetExternalPcrEventsByPcr(PcrIndex, FirstEvent,
+ pEventCount, ppEvents);
+ MUTEX_UNLOCK(tcs_event_log->lock);
+
+ return result;
+ }
+
+ MUTEX_LOCK(tcs_event_log->lock);
+
+ lastEventNumber = get_num_events(PcrIndex);
+
+ MUTEX_UNLOCK(tcs_event_log->lock);
+
+ /* if pEventCount is larger than the number of events to return, just return less.
+ * *pEventCount will be set to the number returned below.
+ */
+ lastEventNumber = MIN(lastEventNumber, FirstEvent + *pEventCount);
+
+ if (FirstEvent > lastEventNumber)
+ return TCSERR(TSS_E_BAD_PARAMETER);
+
+ if (lastEventNumber == 0) {
+ *pEventCount = 0;
+ *ppEvents = NULL;
+ return TSS_SUCCESS;
+ }
+
+ /* FirstEvent is 0 indexed see TSS 1.1b spec section 4.7.2.2.3. That means that
+ * the following calculation is not off by one. :-)
+ */
+ *ppEvents = calloc((lastEventNumber - FirstEvent), sizeof(TSS_PCR_EVENT));
+ if (*ppEvents == NULL) {
+ LogError("malloc of %zd bytes failed.",
+ sizeof(TSS_PCR_EVENT) * (lastEventNumber - FirstEvent));
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ MUTEX_LOCK(tcs_event_log->lock);
+
+ tmp = tcs_event_log->lists[PcrIndex];
+
+ /* move through the list until we get to the first event requested */
+ for (i = 0; i < FirstEvent; i++)
+ tmp = tmp->next;
+
+ /* copy events from the first requested to the last requested */
+ for (eventIndex = 0; i < lastEventNumber; eventIndex++, i++) {
+ copy_pcr_event(&((*ppEvents)[eventIndex]), &(tmp->event));
+ tmp = tmp->next;
+ }
+
+ MUTEX_UNLOCK(tcs_event_log->lock);
+
+ *pEventCount = eventIndex;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+TCS_GetPcrEventLog_Internal(TCS_CONTEXT_HANDLE hContext,/* in */
+ UINT32 *pEventCount, /* out */
+ TSS_PCR_EVENT **ppEvents) /* out */
+{
+ TSS_RESULT result;
+ UINT32 i, j, event_count, aggregate_count = 0;
+ struct event_wrapper *tmp;
+ TSS_PCR_EVENT *event_list = NULL, *aggregate_list = NULL;
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ MUTEX_LOCK(tcs_event_log->lock);
+
+ /* for each PCR index, if its externally controlled, get the total number of events
+ * externally, else copy the events from the TCSD list. Then tack that list onto a
+ * master list to returned. */
+ for (i = 0; i < tpm_metrics.num_pcrs; i++) {
+ if ((tcsd_options.kernel_pcrs & (1 << i)) ||
+ (tcsd_options.firmware_pcrs & (1 << i))) {
+ /* A kernel or firmware controlled PCR event list */
+ event_count = UINT_MAX;
+ if ((result = TCS_GetExternalPcrEventsByPcr(i, 0, &event_count,
+ &event_list))) {
+ LogDebug("Getting External event list for PCR %u failed", i);
+ free(aggregate_list);
+ goto error;
+ }
+ LogDebug("Retrieved %u events from PCR %u (external)", event_count, i);
+ } else {
+ /* A TCSD controlled PCR event list */
+ event_count = get_num_events(i);
+
+ if (event_count == 0)
+ continue;
+
+ if ((event_list = calloc(event_count, sizeof(TSS_PCR_EVENT))) == NULL) {
+ LogError("malloc of %zd bytes failed",
+ event_count * sizeof(TSS_PCR_EVENT));
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ free(aggregate_list);
+ goto error;
+ }
+
+ tmp = tcs_event_log->lists[i];
+ for (j = 0; j < event_count; j++) {
+ copy_pcr_event(&event_list[j], &(tmp->event));
+ tmp = tmp->next;
+ }
+ }
+
+ if (event_count == 0)
+ continue;
+
+ /* Tack the list onto the aggregate_list */
+ aggregate_list = concat_pcr_events(&aggregate_list, aggregate_count, event_list,
+ event_count);
+ if (aggregate_list == NULL) {
+ free(event_list);
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto error;
+ }
+ aggregate_count += event_count;
+ free(event_list);
+ }
+
+ *ppEvents = aggregate_list;
+ *pEventCount = aggregate_count;
+ result = TSS_SUCCESS;
+error:
+ MUTEX_UNLOCK(tcs_event_log->lock);
+
+ return result;
+}
+
diff --git a/src/tcs/tcsi_key.c b/src/tcs/tcsi_key.c
new file mode 100644
index 0000000..984e046
--- /dev/null
+++ b/src/tcs/tcsi_key.c
@@ -0,0 +1,388 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsps.h"
+#include "req_mgr.h"
+
+
+TSS_RESULT
+TCSP_LoadKeyByBlob_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE hUnwrappingKey, /* in */
+ UINT32 cWrappedKeyBlobSize, /* in */
+ BYTE * rgbWrappedKeyBlob, /* in */
+ TPM_AUTH * pAuth, /* in, out */
+ TCS_KEY_HANDLE * phKeyTCSI, /* out */
+ TCS_KEY_HANDLE * phKeyHMAC) /* out */
+{
+ return LoadKeyByBlob_Internal(TPM_ORD_LoadKey, hContext, hUnwrappingKey,
+ cWrappedKeyBlobSize, rgbWrappedKeyBlob, pAuth, phKeyTCSI,
+ phKeyHMAC);
+}
+
+TSS_RESULT
+TCSP_LoadKey2ByBlob_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE hUnwrappingKey, /* in */
+ UINT32 cWrappedKeyBlobSize, /* in */
+ BYTE * rgbWrappedKeyBlob, /* in */
+ TPM_AUTH * pAuth, /* in, out */
+ TCS_KEY_HANDLE * phKeyTCSI) /* out */
+{
+ return LoadKeyByBlob_Internal(TPM_ORD_LoadKey2, hContext, hUnwrappingKey,
+ cWrappedKeyBlobSize, rgbWrappedKeyBlob, pAuth, phKeyTCSI,
+ NULL);
+}
+
+TSS_RESULT
+LoadKeyByBlob_Internal(UINT32 ord, /* The ordinal to use, LoadKey or LoadKey2 */
+ TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE hUnwrappingKey, /* in */
+ UINT32 cWrappedKeyBlobSize, /* in */
+ BYTE * rgbWrappedKeyBlob, /* in */
+ TPM_AUTH * pAuth, /* in, out */
+ TCS_KEY_HANDLE * phKeyTCSI, /* out */
+ TCS_KEY_HANDLE * phKeyHMAC) /* out */
+{
+ UINT64 offset;
+ TSS_RESULT result;
+ UINT32 paramSize;
+ TPM_KEY_HANDLE parentSlot, newSlot;
+ TCS_KEY_HANDLE newHandle = NULL_TCS_HANDLE;
+ TSS_BOOL canLoad;
+ TSS_KEY key;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ LogDebugFn("Enter");
+ LogDebugUnrollKey(rgbWrappedKeyBlob);
+
+ if ((result = get_slot(hContext, hUnwrappingKey, &parentSlot)))
+ return result;
+
+ offset = 0;
+ memset(&key, 0, sizeof(TSS_KEY));
+ if ((result = UnloadBlob_TSS_KEY(&offset, rgbWrappedKeyBlob, &key)))
+ return result;
+
+ if (!pAuth) {
+ LogDebugFn("Checking if LoadKeyByBlob can be avoided by using existing key");
+
+ if ((newHandle = mc_get_handle_by_pub(&key.pubKey, hUnwrappingKey))) {
+ LogDebugFn("tcs key handle exists");
+
+ newSlot = mc_get_slot_by_handle(newHandle);
+ if (newSlot && (isKeyLoaded(newSlot) == TRUE)) {
+ LogDebugFn("Don't need to reload this key.");
+ *phKeyTCSI = newHandle;
+ if (phKeyHMAC)
+ *phKeyHMAC = newSlot;
+ return TSS_SUCCESS;
+ }
+ }
+ }
+
+ LogDebugFn("calling canILoadThisKey");
+ if ((result = canILoadThisKey(&(key.algorithmParms), &canLoad)))
+ goto error;
+
+ if (canLoad == FALSE) {
+ LogDebugFn("calling evictFirstKey");
+ /* Evict a key that isn't the parent */
+ if ((result = evictFirstKey(hUnwrappingKey)))
+ goto error;
+ }
+
+ offset = 0;
+ if ((result = tpm_rqu_build(ord, &offset, txBlob, parentSlot, cWrappedKeyBlobSize,
+ rgbWrappedKeyBlob, pAuth, NULL)))
+ goto error;
+
+ LogDebugFn("Submitting request to the TPM");
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto error;
+
+ if ((result = UnloadBlob_Header(txBlob, &paramSize))) {
+ LogDebugFn("UnloadBlob_Header failed: rc=0x%x", result);
+ goto error;
+ }
+
+ if ((result = tpm_rsp_parse(ord, txBlob, paramSize, &newSlot, pAuth)))
+ goto error;
+
+ if ((result = load_key_final(hContext, hUnwrappingKey, &newHandle, rgbWrappedKeyBlob,
+ newSlot)))
+ goto error;
+
+ /* Setup the outHandles */
+ *phKeyTCSI = newHandle;
+ if (phKeyHMAC)
+ *phKeyHMAC = newSlot;
+
+ LogDebugFn("Key handles for loadKeyByBlob slot:%.8X tcshandle:%.8X", newSlot, newHandle);
+error:
+ auth_mgr_release_auth(pAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_EvictKey_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE hKey) /* in */
+{
+ TSS_RESULT result;
+ TCPA_KEY_HANDLE tpm_handle;
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ tpm_handle = mc_get_slot_by_handle(hKey);
+ if (tpm_handle == NULL_TPM_HANDLE)
+ return TSS_SUCCESS; /*let's call this success if the key is already evicted */
+
+ if ((result = internal_EvictByKeySlot(tpm_handle)))
+ return result;
+
+ result = mc_set_slot_by_slot(tpm_handle, NULL_TPM_HANDLE);
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_CreateWrapKey_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE hWrappingKey, /* in */
+ TCPA_ENCAUTH KeyUsageAuth, /* in */
+ TCPA_ENCAUTH KeyMigrationAuth, /* in */
+ UINT32 keyInfoSize, /* in */
+ BYTE * keyInfo, /* in */
+ UINT32 * keyDataSize, /* out */
+ BYTE ** keyData, /* out */
+ TPM_AUTH * pAuth) /* in, out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ TCPA_KEY_HANDLE parentSlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Create Wrap Key");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (pAuth) {
+ if ((result = auth_mgr_check(hContext, &pAuth->AuthHandle)))
+ goto done;
+ }
+
+ /* Since hWrappingKey must already be loaded, we can fail immediately if
+ * mc_get_slot_by_handle_lock() fails.*/
+ parentSlot = mc_get_slot_by_handle_lock(hWrappingKey);
+ if (parentSlot == NULL_TPM_HANDLE) {
+ result = TCSERR(TSS_E_FAIL);
+ goto done;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_CreateWrapKey, &offset, txBlob, parentSlot,
+ KeyUsageAuth.authdata, KeyMigrationAuth.authdata, keyInfoSize,
+ keyInfo, pAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_CreateWrapKey, txBlob, paramSize, keyDataSize,
+ keyData, pAuth);
+ }
+ LogResult("Create Wrap Key", result);
+
+done:
+ auth_mgr_release_auth(pAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_GetPubKey_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE hKey, /* in */
+ TPM_AUTH * pAuth, /* in, out */
+ UINT32 * pcPubKeySize, /* out */
+ BYTE ** prgbPubKey) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ TCPA_KEY_HANDLE keySlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Get pub key");
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (pAuth != NULL) {
+ LogDebug("Auth Used");
+ if ((result = auth_mgr_check(hContext, &pAuth->AuthHandle)))
+ goto done;
+ } else {
+ LogDebug("No Auth");
+ }
+
+ if (ensureKeyIsLoaded(hContext, hKey, &keySlot)) {
+ result = TCSERR(TCS_E_KM_LOADFAILED);
+ goto done;
+ }
+
+ LogDebug("GetPubKey: handle: 0x%x, slot: 0x%x", hKey, keySlot);
+ if ((result = tpm_rqu_build(TPM_ORD_GetPubKey, &offset, txBlob, keySlot, pAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ offset = 10;
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_GetPubKey, txBlob, paramSize, pcPubKeySize,
+ prgbPubKey, pAuth);
+ }
+ LogResult("Get Public Key", result);
+done:
+ auth_mgr_release_auth(pAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_OwnerReadInternalPub_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE hKey, /* in */
+ TPM_AUTH * pOwnerAuth, /* in, out */
+ UINT32 * punPubKeySize, /* out */
+ BYTE ** ppbPubKeyData) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering OwnerReadInternalPub");
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ LogDebug("OwnerReadInternalPub: handle: 0x%x", hKey);
+ if (hKey != TPM_KH_SRK && hKey != TPM_KH_EK) {
+ result = TCSERR(TSS_E_FAIL);
+ LogDebug("OwnerReadInternalPub - Unsupported Key Handle");
+ goto done;
+ }
+
+ if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_OwnerReadInternalPub, &offset, txBlob, hKey,
+ pOwnerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_OwnerReadInternalPub, txBlob, paramSize,
+ punPubKeySize, ppbPubKeyData, pOwnerAuth);
+ }
+ LogResult("OwnerReadInternalPub", result);
+done:
+ auth_mgr_release_auth(pOwnerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_KeyControlOwner_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE hTcsKey, /* in */
+ UINT32 ulPubKeyLength, /* in */
+ BYTE* rgbPubKey, /* in */
+ UINT32 attribName, /* in */
+ TSS_BOOL attribValue, /* in */
+ TPM_AUTH* pOwnerAuth, /* in,out */
+ TSS_UUID* pUuidData) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ TPM_KEY_HANDLE hTpmKey;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+ if ((result = ctx_verify_context(hContext))) {
+ LogDebug("Invalid TSS Context");
+ goto done;
+ }
+
+ if ((result = get_slot_lite(hContext, hTcsKey, &hTpmKey))) {
+ LogDebug("Can't get TPM Keyhandle for TCS key 0x%x", hTcsKey);
+ goto done;
+ }
+ LogDebugFn("TCS hKey=0x%x, TPM hKey=0x%x", hTcsKey, hTpmKey);
+
+ if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle))) {
+ LogDebug("Owner Authentication failed");
+ goto done;
+ }
+
+ if ((result = mc_find_next_ownerevict_uuid(pUuidData))) {
+ LogDebugFn("mc_find_next_ownerevict_uuid failed: rc=0x%x", result);
+ goto done;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_KeyControlOwner, &offset, txBlob, hTpmKey,
+ ulPubKeyLength, rgbPubKey, attribName, attribValue,
+ pOwnerAuth))) {
+ LogDebugFn("rqu build failed");
+ goto done;
+ }
+
+ if ((result = req_mgr_submit_req(txBlob))) {
+ LogDebugFn("Request submission failed");
+ goto done;
+ }
+
+ if ((result = UnloadBlob_Header(txBlob, &paramSize))) {
+ LogDebugFn("UnloadBlob_Header failed: rc=0x%x", result);
+ goto done;
+ }
+
+ if ((result = tpm_rsp_parse(TPM_ORD_KeyControlOwner, txBlob, paramSize, pOwnerAuth))) {
+ LogDebugFn("tpm_rsp_parse failed: rc=0x%x", result);
+ goto done;
+ }
+
+ if ((result = mc_set_uuid(hTcsKey, pUuidData))){
+ LogDebugFn("mc_set_uuid failed: rc=0x%x", result);
+ goto done;
+ }
+
+ LogResult("KeyControlOwner", result);
+done:
+ auth_mgr_release_auth(pOwnerAuth, NULL, hContext);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_maint.c b/src/tcs/tcsi_maint.c
new file mode 100644
index 0000000..fea756d
--- /dev/null
+++ b/src/tcs/tcsi_maint.c
@@ -0,0 +1,197 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+TSS_RESULT
+TCSP_CreateMaintenanceArchive_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_BOOL generateRandom, /* in */
+ TPM_AUTH * ownerAuth, /* in, out */
+ UINT32 * randomSize, /* out */
+ BYTE ** random, /* out */
+ UINT32 * archiveSize, /* out */
+ BYTE ** archive) /* out */
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Create Main Archive");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_CreateMaintenanceArchive, &offset, txBlob,
+ generateRandom, ownerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_CreateMaintenanceArchive, txBlob, paramSize,
+ randomSize, random, archiveSize, archive, ownerAuth);
+ }
+ LogResult("Create Main Archive", result);
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_LoadMaintenanceArchive_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 dataInSize, /* in */
+ BYTE * dataIn, /* in */
+ TPM_AUTH * ownerAuth, /* in, out */
+ UINT32 * dataOutSize, /* out */
+ BYTE ** dataOut) /* out */
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Load Maint Archive");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_LoadMaintenanceArchive, &offset, txBlob, dataInSize,
+ dataInSize, dataIn, ownerAuth, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_LoadMaintenanceArchive, txBlob, paramSize,
+ dataOutSize, dataOut, ownerAuth, NULL);
+ }
+ LogResult("Load Maint Archive", result);
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_KillMaintenanceFeature_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_AUTH * ownerAuth) /* in, out */
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_KillMaintenanceFeature, &offset, txBlob, ownerAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_KillMaintenanceFeature, txBlob, paramSize,
+ ownerAuth);
+ }
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_LoadManuMaintPub_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_NONCE antiReplay, /* in */
+ UINT32 PubKeySize, /* in */
+ BYTE * PubKey, /* in */
+ TCPA_DIGEST * checksum) /* out */
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Load Manu Maint Pub");
+
+ if ((result = tpm_rqu_build(TPM_ORD_LoadManuMaintPub, &offset, txBlob, TPM_NONCE_SIZE,
+ antiReplay.nonce, PubKeySize, PubKey, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_LoadManuMaintPub, txBlob, paramSize, NULL,
+ checksum->digest);
+ }
+ LogResult("Load Manu Maint Pub", result);
+ return result;
+}
+
+TSS_RESULT
+TCSP_ReadManuMaintPub_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_NONCE antiReplay, /* in */
+ TCPA_DIGEST * checksum) /* out */
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Read Manu Maint Pub");
+
+ if ((result = tpm_rqu_build(TPM_ORD_ReadManuMaintPub, &offset, txBlob, TPM_NONCE_SIZE,
+ antiReplay.nonce)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_ReadManuMaintPub, txBlob, paramSize, NULL,
+ checksum->digest);
+ }
+ LogResult("Read Manu Maint Pub", result);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_migration.c b/src/tcs/tcsi_migration.c
new file mode 100644
index 0000000..8467f02
--- /dev/null
+++ b/src/tcs/tcsi_migration.c
@@ -0,0 +1,217 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+TSS_RESULT
+TCSP_CreateMigrationBlob_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE parentHandle, /* in */
+ TSS_MIGRATE_SCHEME migrationType, /* in */
+ UINT32 MigrationKeyAuthSize, /* in */
+ BYTE * MigrationKeyAuth, /* in */
+ UINT32 encDataSize, /* in */
+ BYTE * encData, /* in */
+ TPM_AUTH * parentAuth, /* in, out */
+ TPM_AUTH * entityAuth, /* in, out */
+ UINT32 * randomSize, /* out */
+ BYTE ** random, /* out */
+ UINT32 * outDataSize, /* out */
+ BYTE ** outData) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ TCPA_KEY_HANDLE keyHandle;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering TPM_CreateMigrationBlob");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (parentAuth != NULL) {
+ if ((result = auth_mgr_check(hContext, &parentAuth->AuthHandle)))
+ goto done;
+ }
+
+ if ((result = auth_mgr_check(hContext, &entityAuth->AuthHandle)))
+ goto done;
+
+ if ((result = ensureKeyIsLoaded(hContext, parentHandle, &keyHandle)))
+ goto done;
+
+ switch (migrationType) {
+ case TSS_MS_MIGRATE:
+ migrationType = TCPA_MS_MIGRATE;
+ break;
+ case TSS_MS_REWRAP:
+ migrationType = TCPA_MS_REWRAP;
+ break;
+ case TSS_MS_MAINT:
+ migrationType = TCPA_MS_MAINT;
+ break;
+ default:
+ /* Let the TPM return an error */
+ break;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_CreateMigrationBlob, &offset, txBlob, keyHandle,
+ migrationType, MigrationKeyAuthSize, MigrationKeyAuth,
+ encDataSize, encData, parentAuth, entityAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (result == TSS_SUCCESS) {
+ result = tpm_rsp_parse(TPM_ORD_CreateMigrationBlob, txBlob, paramSize, randomSize,
+ random, outDataSize, outData, parentAuth, entityAuth);
+ }
+ LogResult("TPM_CreateMigrationBlob", result);
+
+done:
+ auth_mgr_release_auth(entityAuth, parentAuth, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_ConvertMigrationBlob_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE parentHandle, /* in */
+ UINT32 inDataSize, /* in */
+ BYTE * inData, /* in */
+ UINT32 randomSize, /* in */
+ BYTE * random, /* in */
+ TPM_AUTH * parentAuth, /* in, out */
+ UINT32 * outDataSize, /* out */
+ BYTE ** outData) /* out */
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ TCPA_KEY_HANDLE keySlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("ConvertMigBlob");
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (parentAuth != NULL) {
+ LogDebug("Auth Used");
+ if ((result = auth_mgr_check(hContext, &parentAuth->AuthHandle)))
+ goto done;
+ } else {
+ LogDebug("No Auth");
+ }
+ if ((result = ensureKeyIsLoaded(hContext, parentHandle, &keySlot)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_ConvertMigrationBlob, &offset, txBlob, keySlot,
+ inDataSize, inData, randomSize, random, parentAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ offset = 10;
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_ConvertMigrationBlob, txBlob, paramSize, outDataSize,
+ outData, parentAuth, NULL);
+ }
+ LogResult("***Leaving ConvertMigrationBlob with result ", result);
+done:
+ auth_mgr_release_auth(parentAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_AuthorizeMigrationKey_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_MIGRATE_SCHEME migrateScheme, /* in */
+ UINT32 MigrationKeySize, /* in */
+ BYTE * MigrationKey, /* in */
+ TPM_AUTH * ownerAuth, /* in, out */
+ UINT32 * MigrationKeyAuthSize, /* out */
+ BYTE ** MigrationKeyAuth) /* out */
+{
+
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ //TCPA_MIGRATIONKEYAUTH container;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("TCSP_AuthorizeMigrationKey");
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ switch (migrateScheme) {
+ case TSS_MS_MIGRATE:
+ migrateScheme = TCPA_MS_MIGRATE;
+ break;
+ case TSS_MS_REWRAP:
+ migrateScheme = TCPA_MS_REWRAP;
+ break;
+ case TSS_MS_MAINT:
+ migrateScheme = TCPA_MS_MAINT;
+ break;
+#ifdef TSS_BUILD_CMK
+ case TSS_MS_RESTRICT_MIGRATE:
+ migrateScheme = TPM_MS_RESTRICT_MIGRATE;
+ break;
+
+ case TSS_MS_RESTRICT_APPROVE_DOUBLE:
+ migrateScheme = TPM_MS_RESTRICT_APPROVE_DOUBLE;
+ break;
+#endif
+ default:
+ /* Let the TPM return an error */
+ break;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_AuthorizeMigrationKey, &offset, txBlob, migrateScheme,
+ MigrationKeySize, MigrationKey, ownerAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_AuthorizeMigrationKey, txBlob, paramSize,
+ MigrationKeyAuthSize, MigrationKeyAuth, ownerAuth);
+ }
+ LogDebugFn("TPM_AuthorizeMigrationKey result: 0x%x", result);
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+
+}
+
diff --git a/src/tcs/tcsi_nv.c b/src/tcs/tcsi_nv.c
new file mode 100644
index 0000000..cd88f20
--- /dev/null
+++ b/src/tcs/tcsi_nv.c
@@ -0,0 +1,242 @@
+
+/*
+ * The Initial Developer of the Original Code is Intel Corporation.
+ * Portions created by Intel Corporation are Copyright (C) 2007 Intel Corporation.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the Common Public License as published by
+ * IBM Corporation; either version 1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program 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
+ * Common Public License for more details.
+ *
+ * You should have received a copy of the Common Public License
+ * along with this program; if not, a copy can be viewed at
+ * http://www.opensource.org/licenses/cpl1.0.php.
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * Author: james.xu@intel.com Rossey.liu@intel.com
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+TSS_RESULT
+TCSP_NV_DefineOrReleaseSpace_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 cPubInfoSize, /* in */
+ BYTE* pPubInfo, /* in */
+ TPM_ENCAUTH encAuth, /* in */
+ TPM_AUTH* pAuth) /* in, out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (pAuth) {
+ if ((result = auth_mgr_check(hContext, &pAuth->AuthHandle)))
+ goto done;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_NV_DefineSpace, &offset, txBlob, cPubInfoSize, pPubInfo,
+ TPM_ENCAUTH_SIZE, encAuth.authdata, pAuth)))
+ return result;
+
+ LogDebug("req_mgr_submit_req (oldOffset=%" PRIu64 ")", offset);
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogDebug("UnloadBlob (paramSize=%u) result=%u", paramSize, result);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_NV_DefineSpace, txBlob, paramSize, pAuth);
+ }
+done:
+ LogDebug("Leaving DefineSpace with result:%u", result);
+ auth_mgr_release_auth(pAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_NV_WriteValue_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_NV_INDEX hNVStore, /* in */
+ UINT32 offset, /* in */
+ UINT32 ulDataLength, /* in */
+ BYTE * rgbDataToWrite, /* in */
+ TPM_AUTH * privAuth) /* in, out */
+{
+ UINT64 off_set = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+ if ( (result = ctx_verify_context(hContext)))
+ return result;
+ if (privAuth) {
+ if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle)))
+ goto done;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_NV_WriteValue, &off_set, txBlob, hNVStore, offset,
+ ulDataLength, rgbDataToWrite, privAuth)))
+ return result;
+
+ LogDebug("req_mgr_submit_req (oldOffset=%" PRIu64 ")", off_set);
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogDebug("UnloadBlob (paramSize=%u) result=%u", paramSize, result);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_NV_WriteValue, txBlob, paramSize, privAuth);
+ }
+done:
+ LogDebug("Leaving NVWriteValue with result:%u", result);
+ auth_mgr_release_auth(privAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_NV_WriteValueAuth_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_NV_INDEX hNVStore, /* in */
+ UINT32 offset, /* in */
+ UINT32 ulDataLength, /* in */
+ BYTE * rgbDataToWrite, /* in */
+ TPM_AUTH * NVAuth) /* in, out */
+{
+ UINT64 off_set = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+ if ((result = auth_mgr_check(hContext, &NVAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_NV_WriteValueAuth, &off_set, txBlob, hNVStore, offset,
+ ulDataLength, rgbDataToWrite, NVAuth)))
+ return result;
+
+ LogDebug("req_mgr_submit_req (oldOffset=%" PRIu64 ")", off_set);
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogDebug("UnloadBlob (paramSize=%u) result=%u", paramSize, result);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_NV_WriteValueAuth, txBlob, paramSize, NVAuth);
+ }
+done:
+ LogDebug("Leaving NVWriteValueAuth with result:%u", result);
+ auth_mgr_release_auth(NVAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_NV_ReadValue_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_NV_INDEX hNVStore, /* in */
+ UINT32 offset, /* in */
+ UINT32 * pulDataLength, /* in, out */
+ TPM_AUTH * privAuth, /* in, out */
+ BYTE ** rgbDataRead) /* out */
+{
+ UINT64 off_set = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (privAuth) {
+ if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle)))
+ goto done;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_NV_ReadValue, &off_set, txBlob, hNVStore, offset,
+ *pulDataLength, privAuth)))
+ return result;
+
+ LogDebug("req_mgr_submit_req (oldOffset=%" PRIu64 ")", off_set);
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogDebug("UnloadBlob (paramSize=%u) result=%u", paramSize, result);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_NV_ReadValue, txBlob, paramSize, pulDataLength,
+ rgbDataRead, privAuth, NULL);
+ }
+done:
+ LogDebug("Leaving NVReadValue with result:%u", result);
+ auth_mgr_release_auth(privAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_NV_ReadValueAuth_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_NV_INDEX hNVStore, /* in */
+ UINT32 offset, /* in */
+ UINT32 * pulDataLength, /* in, out */
+ TPM_AUTH * NVAuth, /* in, out */
+ BYTE ** rgbDataRead) /* out */
+{
+ UINT64 off_set = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+ if ((result = auth_mgr_check(hContext, &NVAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_NV_ReadValueAuth, &off_set, txBlob, hNVStore, offset,
+ *pulDataLength, NVAuth)))
+ return result;
+
+ LogDebug("req_mgr_submit_req (oldOffset=%" PRIu64 ")", off_set);
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogDebug("UnloadBlob (paramSize=%u) result=%u", paramSize, result);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_NV_ReadValueAuth, txBlob, paramSize, pulDataLength,
+ rgbDataRead, NVAuth, NULL);
+ }
+done:
+ LogDebug("Leaving NVReadValueAuth with result:%u", result);
+ auth_mgr_release_auth(NVAuth, NULL, hContext);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_oper.c b/src/tcs/tcsi_oper.c
new file mode 100644
index 0000000..eee6c76
--- /dev/null
+++ b/src/tcs/tcsi_oper.c
@@ -0,0 +1,49 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_utils.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+
+TSS_RESULT
+TCSP_SetOperatorAuth_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_SECRET *operatorAuth) /* in */
+{
+ TSS_RESULT result;
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebugFn("Enter");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_SetOperatorAuth, &offset, txBlob, TPM_AUTHDATA_SIZE,
+ operatorAuth->authdata)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ LogResult("SetOperatorAuth", result);
+done:
+ return result;
+}
+
diff --git a/src/tcs/tcsi_own.c b/src/tcs/tcsi_own.c
new file mode 100644
index 0000000..48361d4
--- /dev/null
+++ b/src/tcs/tcsi_own.c
@@ -0,0 +1,169 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsps.h"
+#include "req_mgr.h"
+
+
+TSS_RESULT
+TCSP_TakeOwnership_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT16 protocolID, /* in */
+ UINT32 encOwnerAuthSize, /* in */
+ BYTE * encOwnerAuth, /* in */
+ UINT32 encSrkAuthSize, /* in */
+ BYTE * encSrkAuth, /* in */
+ UINT32 srkInfoSize, /*in */
+ BYTE * srkInfo, /*in */
+ TPM_AUTH * ownerAuth, /* in, out */
+ UINT32 * srkKeySize, /*out */
+ BYTE ** srkKey) /*out */
+{
+ UINT64 offset;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ TSS_KEY srkKeyContainer;
+ BYTE fake_pubkey[256] = { 0, }, fake_srk[2048] = { 0, };
+ BYTE oldAuthDataUsage;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ /* Check on the Atmel Bug Patch */
+ offset = 0;
+ UnloadBlob_TSS_KEY(&offset, srkInfo, &srkKeyContainer);
+ oldAuthDataUsage = srkKeyContainer.authDataUsage;
+ LogDebug("auth data usage is %.2X", oldAuthDataUsage);
+
+ offset = 0;
+ if ((result = tpm_rqu_build(TPM_ORD_TakeOwnership, &offset, txBlob, protocolID,
+ encOwnerAuthSize, encOwnerAuth, encSrkAuthSize, encSrkAuth,
+ srkInfoSize, srkInfo, ownerAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ if ((result = tpm_rsp_parse(TPM_ORD_TakeOwnership, txBlob, paramSize, srkKeySize,
+ srkKey, ownerAuth)))
+ goto done;
+
+ offset = 0;
+ if ((result = UnloadBlob_TSS_KEY(&offset, *srkKey, &srkKeyContainer))) {
+ *srkKeySize = 0;
+ free(*srkKey);
+ goto done;
+ }
+
+ if (srkKeyContainer.authDataUsage != oldAuthDataUsage) {
+ LogDebug("AuthDataUsage was changed by TPM. Atmel Bug. Fixing it in PS");
+ srkKeyContainer.authDataUsage = oldAuthDataUsage;
+ }
+
+#ifdef TSS_BUILD_PS
+ {
+ BYTE *save;
+
+ /* Once the key file is created, it stays forever. There could be
+ * migratable keys in the hierarchy that are still useful to someone.
+ */
+ result = ps_remove_key(&SRK_UUID);
+ if (result != TSS_SUCCESS && result != TCSERR(TSS_E_PS_KEY_NOTFOUND)) {
+ destroy_key_refs(&srkKeyContainer);
+ LogError("Error removing SRK from key file.");
+ *srkKeySize = 0;
+ free(*srkKey);
+ goto done;
+ }
+
+ /* Set the SRK pubkey to all 0's before writing the SRK to disk, this is for
+ * privacy reasons as outlined in the TSS spec */
+ save = srkKeyContainer.pubKey.key;
+ srkKeyContainer.pubKey.key = fake_pubkey;
+ offset = 0;
+ LoadBlob_TSS_KEY(&offset, fake_srk, &srkKeyContainer);
+
+ if ((result = ps_write_key(&SRK_UUID, &NULL_UUID, NULL, 0, fake_srk,
+ offset))) {
+ destroy_key_refs(&srkKeyContainer);
+ LogError("Error writing SRK to disk");
+ *srkKeySize = 0;
+ free(*srkKey);
+ goto done;
+ }
+
+ srkKeyContainer.pubKey.key = save;
+ }
+#endif
+ if ((result = mc_add_entry_init(SRK_TPM_HANDLE, SRK_TPM_HANDLE, &srkKeyContainer,
+ &SRK_UUID))) {
+ destroy_key_refs(&srkKeyContainer);
+ LogError("Error creating SRK mem cache entry");
+ *srkKeySize = 0;
+ free(*srkKey);
+ }
+ destroy_key_refs(&srkKeyContainer);
+ }
+ LogResult("TakeOwnership", result);
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_OwnerClear_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TPM_AUTH * ownerAuth) /* in, out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering OwnerClear");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_OwnerClear, &offset, txBlob, ownerAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_OwnerClear, txBlob, paramSize, ownerAuth);
+ }
+ LogResult("Ownerclear", result);
+done:
+ auth_mgr_release_auth(ownerAuth, NULL, hContext);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_pcr.c b/src/tcs/tcsi_pcr.c
new file mode 100644
index 0000000..2cb97e3
--- /dev/null
+++ b/src/tcs/tcsi_pcr.c
@@ -0,0 +1,134 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ * (C) Christian Kummer 2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+TSS_RESULT
+TCSP_Extend_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_PCRINDEX pcrNum, /* in */
+ TCPA_DIGEST inDigest, /* in */
+ TCPA_PCRVALUE * outDigest) /* out */
+{
+ UINT64 offset = 0;
+ TSS_RESULT result;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Extend");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ /* PCRs are numbered 0 - (NUM_PCRS - 1), thus the >= */
+ if (pcrNum >= tpm_metrics.num_pcrs)
+ return TCSERR(TSS_E_BAD_PARAMETER);
+
+ if (tcsd_options.kernel_pcrs & (1 << pcrNum)) {
+ LogInfo("PCR %d is configured to be kernel controlled. Extend request denied.",
+ pcrNum);
+ return TCSERR(TSS_E_FAIL);
+ }
+
+ if (tcsd_options.firmware_pcrs & (1 << pcrNum)) {
+ LogInfo("PCR %d is configured to be firmware controlled. Extend request denied.",
+ pcrNum);
+ return TCSERR(TSS_E_FAIL);
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_Extend, &offset, txBlob, pcrNum, TPM_DIGEST_SIZE,
+ inDigest.digest, NULL, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_Extend, txBlob, paramSize, NULL, outDigest->digest);
+ }
+ LogResult("Extend", result);
+ return result;
+}
+
+TSS_RESULT
+TCSP_PcrRead_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCPA_PCRINDEX pcrNum, /* in */
+ TCPA_PCRVALUE * outDigest) /* out */
+{
+ UINT64 offset = 0;
+ TSS_RESULT result;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering PCRRead");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ /* PCRs are numbered 0 - (NUM_PCRS - 1), thus the >= */
+ if (pcrNum >= tpm_metrics.num_pcrs)
+ return TCSERR(TSS_E_BAD_PARAMETER);
+
+ if ((result = tpm_rqu_build(TPM_ORD_PcrRead, &offset, txBlob, pcrNum, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_PcrRead, txBlob, paramSize, NULL, outDigest->digest);
+ }
+ LogResult("PCR Read", result);
+ return result;
+}
+
+TSS_RESULT
+TCSP_PcrReset_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 pcrDataSizeIn, /* in */
+ BYTE * pcrDataIn) /* in */
+{
+ UINT64 offset = 0;
+ TSS_RESULT result;
+ UINT32 paramSize;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering PCRReset");
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_PCR_Reset, &offset, txBlob, pcrDataSizeIn, pcrDataIn)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogResult("PCR Reset", result);
+ return result;
+}
diff --git a/src/tcs/tcsi_ps.c b/src/tcs/tcsi_ps.c
new file mode 100644
index 0000000..87db219
--- /dev/null
+++ b/src/tcs/tcsi_ps.c
@@ -0,0 +1,636 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsps.h"
+
+TSS_RESULT
+TCS_RegisterKey_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_UUID *WrappingKeyUUID, /* in */
+ TSS_UUID *KeyUUID, /* in */
+ UINT32 cKeySize, /* in */
+ BYTE * rgbKey, /* in */
+ UINT32 cVendorData, /* in */
+ BYTE * gbVendorData) /* in */
+{
+ TSS_RESULT result;
+ TSS_BOOL is_reg;
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ /* Check if key is already regisitered */
+ if (isUUIDRegistered(KeyUUID, &is_reg) != TSS_SUCCESS) {
+ LogError("Failed checking if UUID is registered.");
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if (is_reg == TRUE || TSS_UUID_IS_OWNEREVICT(KeyUUID)) {
+ LogDebug("UUID is already registered");
+ return TCSERR(TSS_E_KEY_ALREADY_REGISTERED);
+ }
+
+ LogDebugUnrollKey(rgbKey);
+
+ /* Go ahead and store it in system persistant storage */
+ if ((result = ps_write_key(KeyUUID, WrappingKeyUUID, gbVendorData, cVendorData, rgbKey,
+ cKeySize))) {
+ LogError("Error writing key to file");
+ return result;
+ }
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+TCS_UnregisterKey_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_UUID KeyUUID) /* in */
+{
+ TSS_RESULT result;
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ return ps_remove_key(&KeyUUID);
+}
+
+TSS_RESULT
+TCS_EnumRegisteredKeys_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_UUID * pKeyUUID, /* in */
+ UINT32 * pcKeyHierarchySize, /* out */
+ TSS_KM_KEYINFO ** ppKeyHierarchy) /* out */
+{
+ TSS_RESULT result = TSS_SUCCESS;
+ UINT32 count = 0, i;
+ TSS_KM_KEYINFO *ret = NULL;
+ TSS_UUID tmp_uuid;
+ struct key_disk_cache *disk_ptr, *tmp_ptrs[MAX_KEY_CHILDREN];
+ struct key_mem_cache *mem_ptr;
+ TSS_BOOL is_reg = FALSE;
+
+ LogDebug("Enum Reg Keys");
+
+ if (pcKeyHierarchySize == NULL || ppKeyHierarchy == NULL)
+ return TCSERR(TSS_E_BAD_PARAMETER);
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (pKeyUUID != NULL) {
+ /* First have to verify the key is registered */
+ if ((result = isUUIDRegistered(pKeyUUID, &is_reg)))
+ return result;
+
+ if (is_reg == FALSE) {
+ /* This return code is not listed as possible in the TSS 1.1 spec,
+ * but it makes more sense than just TCS_SUCCESS or TSS_E_FAIL */
+ return TCSERR(TSS_E_PS_KEY_NOTFOUND);
+ }
+ }
+
+ /* this entire operation needs to be atomic wrt registered keys. We must
+ * lock the mem cache as well to test if a given key is loaded. */
+ MUTEX_LOCK(disk_cache_lock);
+ MUTEX_LOCK(mem_cache_lock);
+
+ /* return an array of all registered keys if pKeyUUID == NULL */
+ if (pKeyUUID == NULL) {
+ /* determine the number of registered keys */
+ for (disk_ptr = key_disk_cache_head; disk_ptr; disk_ptr = disk_ptr->next) {
+ if (disk_ptr->flags & CACHE_FLAG_VALID)
+ count++;
+ }
+
+ /* malloc a structure for each of them */
+ if (count != 0) {
+ ret = calloc(count, sizeof(TSS_KM_KEYINFO));
+ if (ret == NULL) {
+ LogError("malloc of %zd bytes failed.",
+ (count * sizeof(TSS_KM_KEYINFO)));
+ count = 0;
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+ } else {
+ goto done;
+ }
+
+ /* fill out the structure for each key */
+ i = 0;
+ for (disk_ptr = key_disk_cache_head; disk_ptr; disk_ptr = disk_ptr->next) {
+ if (disk_ptr->flags & CACHE_FLAG_VALID) {
+ /* look for a mem cache entry to check if its loaded */
+ for (mem_ptr = key_mem_cache_head; mem_ptr; mem_ptr = mem_ptr->next) {
+ if (!memcmp(&mem_ptr->uuid, &disk_ptr->uuid, sizeof(TSS_UUID))) {
+ if ((result = fill_key_info(disk_ptr, mem_ptr, &ret[i]))) {
+ free(ret);
+ ret = NULL;
+ count = 0;
+ goto done;
+ }
+ break;
+ }
+ }
+ /* if there is no mem cache entry for this key, go ahead and call
+ * fill_key_info(), it will pull everything from disk */
+ if (mem_ptr == NULL) {
+ if ((result = fill_key_info(disk_ptr, NULL, &ret[i]))) {
+ free(ret);
+ ret = NULL;
+ count = 0;
+ goto done;
+ }
+ }
+ i++;
+ }
+ }
+ } else {
+ /* return a chain of a key and its parents up to the SRK */
+ /* determine the number of keys in the chain */
+ memcpy(&tmp_uuid, pKeyUUID, sizeof(TSS_UUID));
+ disk_ptr = key_disk_cache_head;
+ while (disk_ptr != NULL && count < MAX_KEY_CHILDREN)
+ {
+ if (disk_ptr->flags & CACHE_FLAG_VALID &&
+ !memcmp(&disk_ptr->uuid, &tmp_uuid, sizeof(TSS_UUID)))
+ {
+ /* increment count, then search for the parent */
+ count++;
+ /* save a pointer to this cache entry */
+ tmp_ptrs[count - 1] = disk_ptr;
+ /* if the parent of this key is NULL, we're at the root of the tree */
+ if (!memcmp(&disk_ptr->parent_uuid, &NULL_UUID, sizeof(TSS_UUID)))
+ break;
+ /* overwrite tmp_uuid with the parent, which we will now search for */
+ memcpy(&tmp_uuid, &disk_ptr->parent_uuid, sizeof(TSS_UUID));
+ disk_ptr = key_disk_cache_head;
+ continue;
+ }
+ disk_ptr = disk_ptr->next;
+ }
+ /* when we reach this point, we have an array of TSS_UUID's that leads from the
+ * requested key up to the SRK*/
+
+ /* malloc a structure for each of them */
+ if (count != 0) {
+ ret = calloc(count, sizeof(TSS_KM_KEYINFO));
+ if (ret == NULL) {
+ LogError("malloc of %zd bytes failed.",
+ (count * sizeof(TSS_KM_KEYINFO)));
+ count = 0;
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+ } else {
+ goto done;
+ }
+
+ for (i = 0; i < count; i++) {
+ /* look for a mem cache entry to check if its loaded */
+ for (mem_ptr = key_mem_cache_head; mem_ptr; mem_ptr = mem_ptr->next) {
+ if (!memcmp(&mem_ptr->uuid, &tmp_ptrs[i]->uuid, sizeof(TSS_UUID))) {
+ if ((result = fill_key_info(tmp_ptrs[i], mem_ptr, &ret[i]))) {
+ free(ret);
+ ret = NULL;
+ count = 0;
+ goto done;
+ }
+ break;
+ }
+ }
+ /* if there is no mem cache entry for this key, go ahead and call
+ * fill_key_info(), it will pull everything from disk */
+ if (mem_ptr == NULL) {
+ if ((result = fill_key_info(tmp_ptrs[i], NULL, &ret[i]))) {
+ free(ret);
+ ret = NULL;
+ count = 0;
+ goto done;
+ }
+ }
+ }
+ }
+done:
+
+ MUTEX_UNLOCK(disk_cache_lock);
+ MUTEX_UNLOCK(mem_cache_lock);
+
+ *ppKeyHierarchy = ret;
+ *pcKeyHierarchySize = count;
+
+ return result;
+}
+
+TSS_RESULT
+TCS_EnumRegisteredKeys_Internal2(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_UUID * pKeyUUID, /* in */
+ UINT32 * pcKeyHierarchySize, /* out */
+ TSS_KM_KEYINFO2 ** ppKeyHierarchy) /* out */
+{
+ TSS_RESULT result = TSS_SUCCESS;
+ UINT32 count = 0, i;
+ TSS_KM_KEYINFO2 *ret = NULL;
+ TSS_UUID tmp_uuid;
+ struct key_disk_cache *disk_ptr, *tmp_ptrs[MAX_KEY_CHILDREN];
+ struct key_mem_cache *mem_ptr;
+ TSS_BOOL is_reg = FALSE;
+
+ LogDebug("Enum Reg Keys2");
+
+ if (pcKeyHierarchySize == NULL || ppKeyHierarchy == NULL)
+ return TCSERR(TSS_E_BAD_PARAMETER);
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (pKeyUUID != NULL) {
+ /* First have to verify the key is registered */
+ if ((result = isUUIDRegistered(pKeyUUID, &is_reg)))
+ return result;
+
+ if (is_reg == FALSE) {
+ /* This return code is not listed as possible in the TSS 1.1 spec,
+ * but it makes more sense than just TCS_SUCCESS or TSS_E_FAIL */
+ return TCSERR(TSS_E_PS_KEY_NOTFOUND);
+ }
+ }
+
+ /* this entire operation needs to be atomic wrt registered keys. We must
+ * lock the mem cache as well to test if a given key is loaded. */
+ MUTEX_LOCK(disk_cache_lock);
+ MUTEX_LOCK(mem_cache_lock);
+
+ /* return an array of all registered keys if pKeyUUID == NULL */
+ if (pKeyUUID == NULL) {
+ /* determine the number of registered keys */
+ for (disk_ptr = key_disk_cache_head; disk_ptr; disk_ptr = disk_ptr->next) {
+ if (disk_ptr->flags & CACHE_FLAG_VALID)
+ count++;
+ }
+
+ /* malloc a structure for each of them */
+ if (count != 0) {
+ ret = calloc(count, sizeof(TSS_KM_KEYINFO2));
+ if (ret == NULL) {
+ LogError("malloc of %zd bytes failed.",
+ (count * sizeof(TSS_KM_KEYINFO2)));
+ count = 0;
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+ } else {
+ goto done;
+ }
+
+ /* fill out the structure for each key */
+ i = 0;
+ for (disk_ptr = key_disk_cache_head; disk_ptr; disk_ptr = disk_ptr->next) {
+ if (disk_ptr->flags & CACHE_FLAG_VALID) {
+ /* look for a mem cache entry to check if its loaded */
+ for (mem_ptr = key_mem_cache_head; mem_ptr; mem_ptr = mem_ptr->next) {
+ if (!memcmp(&mem_ptr->uuid, &disk_ptr->uuid, sizeof(TSS_UUID))) {
+ if ((result = fill_key_info2(disk_ptr, mem_ptr, &ret[i]))) {
+ free(ret);
+ ret = NULL;
+ count = 0;
+ goto done;
+ }
+ break;
+ }
+ }
+ /* if there is no mem cache entry for this key, go ahead and call
+ * fill_key_info2(), it will pull everything from disk */
+ if (mem_ptr == NULL) {
+ if ((result = fill_key_info2(disk_ptr, NULL, &ret[i]))) {
+ free(ret);
+ ret = NULL;
+ count = 0;
+ goto done;
+ }
+ }
+ i++;
+ }
+ }
+ } else {
+ /* return a chain of a key and its parents up to the SRK */
+ /* determine the number of keys in the chain */
+ memcpy(&tmp_uuid, pKeyUUID, sizeof(TSS_UUID));
+ disk_ptr = key_disk_cache_head;
+ while (disk_ptr != NULL && count < MAX_KEY_CHILDREN)
+ {
+ if (disk_ptr->flags & CACHE_FLAG_VALID &&
+ !memcmp(&disk_ptr->uuid, &tmp_uuid, sizeof(TSS_UUID)))
+ {
+ /* increment count, then search for the parent */
+ count++;
+ /* save a pointer to this cache entry */
+ tmp_ptrs[count - 1] = disk_ptr;
+ /* if the parent of this key is NULL, we're at the root of the tree */
+ if (!memcmp(&disk_ptr->parent_uuid, &NULL_UUID, sizeof(TSS_UUID)))
+ break;
+ /* overwrite tmp_uuid with the parent, which we will now search for */
+ memcpy(&tmp_uuid, &disk_ptr->parent_uuid, sizeof(TSS_UUID));
+ disk_ptr = key_disk_cache_head;
+ continue;
+ }
+ disk_ptr = disk_ptr->next;
+ }
+ /* when we reach this point, we have an array of TSS_UUID's that leads from the
+ * requested key up to the SRK*/
+
+ /* malloc a structure for each of them */
+ if (count != 0) {
+ ret = calloc(count, sizeof(TSS_KM_KEYINFO2));
+ if (ret == NULL) {
+ LogError("malloc of %zd bytes failed.",
+ (count * sizeof(TSS_KM_KEYINFO2)));
+ count = 0;
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+ } else {
+ goto done;
+ }
+
+ for (i = 0; i < count; i++) {
+ /* look for a mem cache entry to check if its loaded */
+ for (mem_ptr = key_mem_cache_head; mem_ptr; mem_ptr = mem_ptr->next) {
+ if (!memcmp(&mem_ptr->uuid, &tmp_ptrs[i]->uuid, sizeof(TSS_UUID))) {
+ if ((result = fill_key_info2(tmp_ptrs[i], mem_ptr, &ret[i]))) {
+ free(ret);
+ ret = NULL;
+ count = 0;
+ goto done;
+ }
+ break;
+ }
+ }
+ /* if there is no mem cache entry for this key, go ahead and call
+ * fill_key_info(), it will pull everything from disk */
+ if (mem_ptr == NULL) {
+ if ((result = fill_key_info2(tmp_ptrs[i], NULL, &ret[i]))) {
+ free(ret);
+ ret = NULL;
+ count = 0;
+ goto done;
+ }
+ }
+ }
+ }
+done:
+
+ MUTEX_UNLOCK(disk_cache_lock);
+ MUTEX_UNLOCK(mem_cache_lock);
+
+ *ppKeyHierarchy = ret;
+ *pcKeyHierarchySize = count;
+
+ return result;
+}
+
+TSS_RESULT
+TCS_GetRegisteredKey_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_UUID *KeyUUID, /* in */
+ TSS_KM_KEYINFO ** ppKeyInfo) /* out */
+{
+ TSS_RESULT result;
+ UINT64 offset;
+ BYTE tcpaKeyBlob[1024];
+ TSS_KEY tcpaKey;
+ UINT16 keySize = sizeof (tcpaKeyBlob);
+ TSS_UUID parentUUID;
+
+ /* This should be set in case we return before the malloc */
+ *ppKeyInfo = NULL;
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = ps_get_key_by_uuid(KeyUUID, tcpaKeyBlob, &keySize))) {
+ return TCSERR(TSS_E_PS_KEY_NOTFOUND);
+ }
+
+ if ((result = getParentUUIDByUUID(KeyUUID, &parentUUID)))
+ return TCSERR(TSS_E_FAIL);
+
+ *ppKeyInfo = malloc(sizeof(TSS_KM_KEYINFO));
+ if (*ppKeyInfo == NULL) {
+ LogError("malloc of %zd bytes failed.", sizeof(TSS_KM_KEYINFO));
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ offset = 0;
+ UnloadBlob_TSS_KEY(&offset, tcpaKeyBlob, &tcpaKey);
+
+ (*ppKeyInfo)->bAuthDataUsage = tcpaKey.authDataUsage;
+
+ (*ppKeyInfo)->fIsLoaded = FALSE;
+
+ if (tcpaKey.hdr.key12.tag == TPM_TAG_KEY12) {
+ (*ppKeyInfo)->versionInfo.bMajor = TSS_SPEC_MAJOR;
+ (*ppKeyInfo)->versionInfo.bMinor = TSS_SPEC_MINOR;
+ (*ppKeyInfo)->versionInfo.bRevMajor = 0;
+ (*ppKeyInfo)->versionInfo.bRevMinor = 0;
+ } else {
+ (*ppKeyInfo)->versionInfo.bMajor = tcpaKey.hdr.key11.ver.major;
+ (*ppKeyInfo)->versionInfo.bMinor = tcpaKey.hdr.key11.ver.minor;
+ (*ppKeyInfo)->versionInfo.bRevMajor = tcpaKey.hdr.key11.ver.revMajor;
+ (*ppKeyInfo)->versionInfo.bRevMinor = tcpaKey.hdr.key11.ver.revMinor;
+ }
+
+ memcpy(&((*ppKeyInfo)->keyUUID), KeyUUID, sizeof(TSS_UUID));
+
+ (*ppKeyInfo)->ulVendorDataLength = 0;
+ (*ppKeyInfo)->rgbVendorData = 0;
+
+ memcpy(&((*ppKeyInfo)->parentKeyUUID), &parentUUID, sizeof(TSS_UUID));
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+TCS_GetRegisteredKeyBlob_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_UUID *KeyUUID, /* in */
+ UINT32 * pcKeySize, /* out */
+ BYTE ** prgbKey) /* out */
+{
+ UINT16 keySize;
+ BYTE buffer[4096];
+ TSS_RESULT result;
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ keySize = sizeof(buffer);
+ if ((result = ps_get_key_by_uuid(KeyUUID, buffer, &keySize)))
+ return TCSERR(TSS_E_PS_KEY_NOTFOUND);
+
+ *prgbKey = calloc(1, keySize);
+ if (*prgbKey == NULL) {
+ LogError("malloc of %d bytes failed.", keySize);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ } else {
+ memcpy(*prgbKey, buffer, keySize);
+ }
+ *pcKeySize = keySize;
+
+ return TSS_SUCCESS;
+}
+
+TSS_RESULT
+TCSP_LoadKeyByUUID_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TSS_UUID *KeyUUID, /* in */
+ TCS_LOADKEY_INFO * pLoadKeyInfo, /* in, out */
+ TCS_KEY_HANDLE * phKeyTCSI) /* out */
+{
+ UINT32 keyslot = 0, keySize;
+ UINT32 ordinal;
+ TSS_RESULT result;
+ TSS_UUID parentUuid;
+ BYTE keyBlob[0x1000];
+ UINT16 blobSize = sizeof(keyBlob);
+ UINT64 offset;
+ TCS_KEY_HANDLE parentTCSKeyHandle;
+
+ if (TPM_VERSION_IS(1,2))
+ ordinal = TPM_ORD_LoadKey2;
+ else
+ ordinal = TPM_ORD_LoadKey;
+
+ LogDebugFn("Enter: uuid: 0x%lx auth? 0x%x ***********", (unsigned long)KeyUUID,
+ pLoadKeyInfo == NULL ? 0xdeadbeef : pLoadKeyInfo->authData.AuthHandle);
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ memset(&parentUuid, 0, sizeof(TSS_UUID));
+
+ if (pLoadKeyInfo &&
+ memcmp(&pLoadKeyInfo->parentKeyUUID, &parentUuid, sizeof(TSS_UUID))) {
+ if (ps_get_key_by_uuid(&pLoadKeyInfo->keyUUID, keyBlob, &blobSize))
+ return TCSERR(TSS_E_PS_KEY_NOTFOUND);
+
+ if (mc_get_handles_by_uuid(&pLoadKeyInfo->parentKeyUUID, &parentTCSKeyHandle,
+ &keyslot))
+ return TCSERR(TCS_E_KM_LOADFAILED);
+
+ return LoadKeyByBlob_Internal(ordinal, hContext, parentTCSKeyHandle,
+ blobSize, keyBlob,
+ &pLoadKeyInfo->authData,
+ phKeyTCSI, &keyslot);
+ }
+
+ /* if KeyUUID is already loaded, increment the ref count and return */
+ if (mc_get_handles_by_uuid(KeyUUID, phKeyTCSI, &keyslot) == TSS_SUCCESS) {
+ if (keyslot) {
+ if (ctx_mark_key_loaded(hContext, *phKeyTCSI)) {
+ LogError("Error marking key as loaded");
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+ return TSS_SUCCESS;
+ }
+ }
+ /*********************************************************************
+ * The first thing to do in this func is setup all the info and make sure
+ * that we get it all from either the keyfile or the keyCache
+ * also, it's important to return if the key is already loaded
+ ***********************************************************************/
+ LogDebugFn("calling ps_get_key_by_uuid");
+ if (ps_get_key_by_uuid(KeyUUID, keyBlob, &blobSize))
+ return TCSERR(TSS_E_PS_KEY_NOTFOUND);
+ /* convert UINT16 to UIN32 */
+ keySize = blobSize;
+
+ LogDebugFn("calling getParentUUIDByUUID");
+ /*--- Get my parent's UUID. Since My key is registered, my parent should be as well. */
+ if ((result = getParentUUIDByUUID(KeyUUID, &parentUuid)))
+ return TCSERR(TCS_E_KM_LOADFAILED);
+
+ if ((result = TCSP_LoadKeyByUUID_Internal(hContext, &parentUuid,
+ pLoadKeyInfo, &parentTCSKeyHandle)))
+ return result;
+
+ LogDebugFn("calling LoadKeyByBlob_Internal");
+ /*******************************************************
+ * If no errors have happend up till now, then the parent is loaded and ready for use.
+ * The parent's TCS Handle should be in parentTCSKeyHandle.
+ ******************************************************/
+ if ((result = LoadKeyByBlob_Internal(ordinal, hContext, parentTCSKeyHandle,
+ keySize, keyBlob,
+ NULL,
+ phKeyTCSI, &keyslot))) {
+ LogDebugFn("LoadKeyByBlob_Internal returned 0x%x", result);
+ if (result == TCPA_E_AUTHFAIL && pLoadKeyInfo) {
+ BYTE blob[1000];
+
+ /* set up a load key info struct */
+ memcpy(&pLoadKeyInfo->parentKeyUUID, &parentUuid, sizeof(TSS_UUID));
+ memcpy(&pLoadKeyInfo->keyUUID, KeyUUID, sizeof(TSS_UUID));
+
+ /* calculate the paramDigest */
+ offset = 0;
+ LoadBlob_UINT32(&offset, ordinal, blob);
+ LoadBlob(&offset, keySize, blob, keyBlob);
+ if (Hash(TSS_HASH_SHA1, offset, blob,
+ (BYTE *)&pLoadKeyInfo->paramDigest.digest))
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+
+ result = TCSERR(TCS_E_KM_LOADFAILED);
+ }
+ }
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_GetRegisteredKeyByPublicInfo_Internal(TCS_CONTEXT_HANDLE tcsContext, /* in */
+ TCPA_ALGORITHM_ID algID, /* in */
+ UINT32 ulPublicInfoLength, /* in */
+ BYTE * rgbPublicInfo, /* in */
+ UINT32 * keySize, /* out */
+ BYTE ** keyBlob) /* out */
+{
+ TCPA_STORE_PUBKEY pubKey;
+ TSS_RESULT result = TCSERR(TSS_E_FAIL);
+
+ if ((result = ctx_verify_context(tcsContext)))
+ return result;
+
+ if (algID == TCPA_ALG_RSA) {
+ /*--- Convert Public info to a structure */
+ pubKey.keyLength = ulPublicInfoLength;
+ pubKey.key = malloc(pubKey.keyLength);
+ if (pubKey.key == NULL) {
+ LogError("malloc of %d bytes failed.", pubKey.keyLength);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+
+ memcpy(pubKey.key, rgbPublicInfo, pubKey.keyLength);
+
+ if ((result = ps_get_key_by_pub(&pubKey, keySize, keyBlob))) {
+ LogDebug("Public key data not found in PS");
+ free(pubKey.key);
+ return TCSERR(TSS_E_PS_KEY_NOTFOUND);
+ }
+ }
+ free(pubKey.key);
+
+ return result;
+}
diff --git a/src/tcs/tcsi_quote.c b/src/tcs/tcsi_quote.c
new file mode 100644
index 0000000..632b0cc
--- /dev/null
+++ b/src/tcs/tcsi_quote.c
@@ -0,0 +1,81 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2006
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+TSS_RESULT
+TCSP_Quote_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE keyHandle, /* in */
+ TCPA_NONCE antiReplay, /* in */
+ UINT32 pcrDataSizeIn, /* in */
+ BYTE * pcrDataIn, /* in */
+ TPM_AUTH * privAuth, /* in, out */
+ UINT32 * pcrDataSizeOut, /* out */
+ BYTE ** pcrDataOut, /* out */
+ UINT32 * sigSize, /* out */
+ BYTE ** sig) /* out */
+{
+
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ UINT32 keySlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering quote");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (privAuth != NULL) {
+ LogDebug("Auth Used");
+ if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle)))
+ goto done;
+ } else {
+ LogDebug("No Auth");
+ }
+ if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_Quote, &offset, txBlob, keySlot, antiReplay.nonce,
+ pcrDataSizeIn, pcrDataIn, privAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_Quote, txBlob, paramSize, pcrDataSizeOut, pcrDataOut,
+ sigSize, sig, privAuth);
+ }
+ LogResult("Quote", result);
+done:
+ auth_mgr_release_auth(privAuth, NULL, hContext);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_quote2.c b/src/tcs/tcsi_quote2.c
new file mode 100644
index 0000000..0ced27f
--- /dev/null
+++ b/src/tcs/tcsi_quote2.c
@@ -0,0 +1,86 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+TSS_RESULT
+TCSP_Quote2_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE keyHandle, /* in */
+ TCPA_NONCE antiReplay, /* in */
+ UINT32 pcrDataSizeIn, /* in */
+ BYTE * pcrDataIn, /* in */
+ TSS_BOOL addVersion, /* in */
+ TPM_AUTH * privAuth, /* in, out */
+ UINT32 * pcrDataSizeOut, /* out */
+ BYTE ** pcrDataOut, /* out */
+ UINT32 * versionInfoSize, /* out */
+ BYTE ** versionInfo, /* out */
+ UINT32 * sigSize, /* out */
+ BYTE ** sig) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ UINT32 keySlot;
+
+ /* Command packet to be sent to the TPM */
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering quote2");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (privAuth != NULL) {
+ LogDebug("Auth Used");
+ if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle)))
+ goto done;
+ } else {
+ LogDebug("No Auth");
+ }
+ if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_Quote2, &offset, txBlob, keySlot, antiReplay.nonce,
+ pcrDataSizeIn, pcrDataIn, &addVersion, privAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_Quote2, txBlob, paramSize, pcrDataSizeOut,
+ pcrDataOut, &addVersion, versionInfoSize, versionInfo,
+ sigSize, sig, privAuth);
+ }
+ LogResult("Quote2", result);
+done:
+ auth_mgr_release_auth(privAuth, NULL, hContext);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_random.c b/src/tcs/tcsi_random.c
new file mode 100644
index 0000000..9670df4
--- /dev/null
+++ b/src/tcs/tcsi_random.c
@@ -0,0 +1,147 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+/*
+ * Get a random number generated by the TPM. Most (all?) TPMs return a maximum number of random
+ * bytes that's less than the max allowed to be returned at the TSP level, which is 4K bytes.
+ * According to the TPM compliance work posted here: http://www.prosec.rub.de/tpmcompliance.html,
+ * some TPMs return as little as 132 bytes per query, which would require about 30 loops to get 4K.
+ * We'll be extremely conservative here and loop 50 times, since it won't affect performance on
+ * TPMs that return more bytes.
+ */
+TSS_RESULT
+TCSP_GetRandom_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 * bytesRequested, /* in, out */
+ BYTE ** randomBytes) /* out */
+{
+ UINT64 offset;
+ TSS_RESULT result;
+ UINT32 paramSize, totalReturned = 0, bytesReturned, retries = 50;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE], *rnd_tmp = NULL, *rnd_tmp2 = NULL;
+
+ LogDebugFn("%u bytes", *bytesRequested);
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ do {
+ offset = 0;
+ if ((result = tpm_rqu_build(TPM_ORD_GetRandom, &offset, txBlob,
+ *bytesRequested - totalReturned, NULL)))
+ break;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ break;;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+#if 0
+ offset = 10;
+ UnloadBlob_UINT32(&offset, &bytesReturned, txBlob);
+
+ LogDebugFn("received %u bytes from the TPM", bytesReturned);
+
+ rnd_tmp = realloc(rnd_tmp, totalReturned + bytesReturned);
+ if (rnd_tmp == NULL) {
+ LogError("malloc of %u bytes failed.", bytesReturned);
+ return TCSERR(TSS_E_OUTOFMEMORY);
+ }
+ UnloadBlob(&offset, bytesReturned, txBlob, &rnd_tmp[totalReturned]);
+#else
+ /* XXX */
+ if ((result = tpm_rsp_parse(TPM_ORD_GetRandom, txBlob, paramSize,
+ &bytesReturned, &rnd_tmp, NULL, NULL)))
+ break;
+
+ rnd_tmp2 = realloc(*randomBytes, totalReturned + bytesReturned);
+ if (rnd_tmp2 == NULL) {
+ free(rnd_tmp);
+ rnd_tmp = NULL;
+ LogError("malloc of %u bytes failed.", bytesReturned);
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ break;
+ }
+ *randomBytes = rnd_tmp2;
+ memcpy(*randomBytes + totalReturned, rnd_tmp, bytesReturned);
+ free(rnd_tmp);
+ rnd_tmp = NULL;
+#endif
+ totalReturned += bytesReturned;
+ } else {
+ free(rnd_tmp);
+ return result;
+ }
+ } while (totalReturned < *bytesRequested && retries--);
+
+ if (totalReturned != *bytesRequested) {
+ LogDebugFn("Only %u random bytes recieved from TPM.", totalReturned);
+ free(rnd_tmp);
+ result = TCSERR(TSS_E_FAIL);
+#if 0
+ } else
+ *randomBytes = rnd_tmp;
+#else
+ }
+#endif
+
+ return result;
+}
+
+TSS_RESULT
+TCSP_StirRandom_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 inDataSize, /* in */
+ BYTE * inData) /* in */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering stir random");
+
+ if (inDataSize > 255) {
+ LogDebugFn("inData is too large! (%u bytes)", inDataSize);
+ return TCSERR(TSS_E_BAD_PARAMETER);
+ }
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_StirRandom, &offset, txBlob, inDataSize, inDataSize,
+ inData, NULL, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogResult("Stir random", result);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_seal.c b/src/tcs/tcsi_seal.c
new file mode 100644
index 0000000..bc72ecd
--- /dev/null
+++ b/src/tcs/tcsi_seal.c
@@ -0,0 +1,149 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+TSS_RESULT
+TCSP_Seal_Internal(UINT32 sealOrdinal, /* in */
+ TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE keyHandle, /* in */
+ TCPA_ENCAUTH encAuth, /* in */
+ UINT32 pcrInfoSize, /* in */
+ BYTE * PcrInfo, /* in */
+ UINT32 inDataSize, /* in */
+ BYTE * inData, /* in */
+ TPM_AUTH * pubAuth, /* in, out */
+ UINT32 * SealedDataSize, /* out */
+ BYTE ** SealedData) /* out */
+{
+ UINT64 offset = 0;
+ TSS_RESULT result;
+ UINT32 paramSize;
+ TCPA_KEY_HANDLE keySlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Seal");
+ if (!pubAuth)
+ return TCSERR(TSS_E_BAD_PARAMETER);
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if ((result = auth_mgr_check(hContext, &pubAuth->AuthHandle)))
+ goto done;
+
+ if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
+ goto done;
+
+ /* XXX What's this check for? */
+ if (keySlot == 0) {
+ result = TCSERR(TSS_E_FAIL);
+ goto done;
+ }
+
+ if ((result = tpm_rqu_build(sealOrdinal, &offset, txBlob, keySlot, encAuth.authdata,
+ pcrInfoSize, PcrInfo, inDataSize, inData, pubAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ offset = 10;
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ if (!result) {
+ result = tpm_rsp_parse(sealOrdinal, txBlob, paramSize, SealedDataSize,
+ SealedData, pubAuth);
+ }
+ LogResult("Seal", result);
+done:
+ auth_mgr_release_auth(pubAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_Unseal_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE parentHandle, /* in */
+ UINT32 SealedDataSize, /* in */
+ BYTE * SealedData, /* in */
+ TPM_AUTH * parentAuth, /* in, out */
+ TPM_AUTH * dataAuth, /* in, out */
+ UINT32 * DataSize, /* out */
+ BYTE ** Data) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ TCPA_KEY_HANDLE keySlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Unseal");
+
+ if (dataAuth == NULL)
+ return TCSERR(TSS_E_BAD_PARAMETER);
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (parentAuth != NULL) {
+ LogDebug("Auth used");
+ if ((result = auth_mgr_check(hContext, &parentAuth->AuthHandle)))
+ goto done;
+ } else {
+ LogDebug("No Auth");
+ }
+
+ if ((result = auth_mgr_check(hContext, &dataAuth->AuthHandle)))
+ goto done;
+
+ if ((result = ensureKeyIsLoaded(hContext, parentHandle, &keySlot)))
+ goto done;
+
+ /* XXX What's this check for? */
+ if (keySlot == 0) {
+ result = TCSERR(TSS_E_FAIL);
+ goto done;
+ }
+
+ if ((result = tpm_rqu_build(TPM_ORD_Unseal, &offset, txBlob, keySlot, SealedDataSize,
+ SealedData, parentAuth, dataAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ offset = 10;
+ result = UnloadBlob_Header(txBlob, &paramSize);
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_Unseal, txBlob, paramSize, DataSize, Data,
+ parentAuth, dataAuth);
+ }
+ LogResult("Unseal", result);
+done:
+ auth_mgr_release_auth(parentAuth, dataAuth, hContext);
+ return result;
+}
diff --git a/src/tcs/tcsi_selftest.c b/src/tcs/tcsi_selftest.c
new file mode 100644
index 0000000..95869bc
--- /dev/null
+++ b/src/tcs/tcsi_selftest.c
@@ -0,0 +1,129 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+TSS_RESULT
+TCSP_SelfTestFull_Internal(TCS_CONTEXT_HANDLE hContext) /* in */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Self Test Full");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_SelfTestFull, &offset, txBlob, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ LogResult("Self Test Full", result);
+ return result;
+}
+
+TSS_RESULT
+TCSP_CertifySelfTest_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE keyHandle, /* in */
+ TCPA_NONCE antiReplay, /* in */
+ TPM_AUTH * privAuth, /* in, out */
+ UINT32 * sigSize, /* out */
+ BYTE ** sig) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ TCPA_KEY_HANDLE keySlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Certify Self Test");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (privAuth != NULL) {
+ LogDebug("Auth Used");
+ if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle)))
+ goto done;
+ } else {
+ LogDebug("No Auth");
+ }
+
+ if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_CertifySelfTest, &offset, txBlob, keySlot,
+ TPM_NONCE_SIZE, antiReplay.nonce, privAuth, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_CertifySelfTest, txBlob, paramSize, sigSize, sig,
+ privAuth, NULL);
+ }
+ LogResult("Certify Self Test", result);
+done:
+ auth_mgr_release_auth(privAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_GetTestResult_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ UINT32 * outDataSize, /* out */
+ BYTE ** outData) /* out */
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Get Test Result");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_GetTestResult, &offset, txBlob, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ return result;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_GetTestResult, txBlob, paramSize, outDataSize,
+ outData, NULL, NULL);
+ }
+ LogResult("Get Test Result", result);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_sign.c b/src/tcs/tcsi_sign.c
new file mode 100644
index 0000000..3671fb1
--- /dev/null
+++ b/src/tcs/tcsi_sign.c
@@ -0,0 +1,78 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+TSS_RESULT
+TCSP_Sign_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE keyHandle, /* in */
+ UINT32 areaToSignSize, /* in */
+ BYTE * areaToSign, /* in */
+ TPM_AUTH * privAuth, /* in, out */
+ UINT32 * sigSize, /* out */
+ BYTE ** sig /* out */
+ )
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ TCPA_KEY_HANDLE keySlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering Sign");
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (privAuth != NULL) {
+ LogDebug("Auth Used");
+ if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle)))
+ goto done;
+ } else {
+ LogDebug("No Auth");
+ }
+
+ if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_Sign, &offset, txBlob, keySlot, areaToSignSize,
+ areaToSign, privAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_Sign, txBlob, paramSize, sigSize, sig, privAuth,
+ NULL);
+ }
+ LogResult("sign", result);
+done:
+ auth_mgr_release_auth(privAuth, NULL, hContext);
+ return result;
+}
+
diff --git a/src/tcs/tcsi_tick.c b/src/tcs/tcsi_tick.c
new file mode 100644
index 0000000..b752e83
--- /dev/null
+++ b/src/tcs/tcsi_tick.c
@@ -0,0 +1,119 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsps.h"
+#include "req_mgr.h"
+
+
+TSS_RESULT
+TCSP_ReadCurrentTicks_Internal(TCS_CONTEXT_HANDLE hContext,
+ UINT32* pulCurrentTime,
+ BYTE** prgbCurrentTime)
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if ((result = tpm_rqu_build(TPM_ORD_GetTicks, &offset, txBlob, NULL)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result)
+ result = tpm_rsp_parse(TPM_ORD_GetTicks, txBlob, paramSize, pulCurrentTime,
+ prgbCurrentTime, NULL);
+
+done:
+ return result;
+}
+
+TSS_RESULT
+TCSP_TickStampBlob_Internal(TCS_CONTEXT_HANDLE hContext,
+ TCS_KEY_HANDLE hKey,
+ TPM_NONCE* antiReplay,
+ TPM_DIGEST* digestToStamp,
+ TPM_AUTH* privAuth,
+ UINT32* pulSignatureLength,
+ BYTE** prgbSignature,
+ UINT32* pulTickCountLength,
+ BYTE** prgbTickCount)
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset = 0;
+ TPM_KEY_HANDLE keySlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (privAuth) {
+ if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle)))
+ goto done;
+ }
+
+ if ((result = ensureKeyIsLoaded(hContext, hKey, &keySlot)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_TickStampBlob, &offset, txBlob, keySlot, antiReplay,
+ digestToStamp, privAuth)))
+ return result;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ if ((result = UnloadBlob_Header(txBlob, &paramSize))) {
+ LogDebugFn("UnloadBlob_Header failed: rc=0x%x", result);
+ goto done;
+ }
+
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_TickStampBlob, txBlob, paramSize, pulTickCountLength,
+ prgbTickCount, pulSignatureLength, prgbSignature, privAuth);
+ }
+done:
+ return result;
+}
+
+void
+UnloadBlob_CURRENT_TICKS(UINT64 *offset, BYTE *b, TPM_CURRENT_TICKS *t)
+{
+ if (!t) {
+ UnloadBlob_UINT16(offset, NULL, b);
+ UnloadBlob_UINT64(offset, NULL, b);
+ UnloadBlob_UINT16(offset, NULL, b);
+ UnloadBlob(offset, sizeof(TPM_NONCE), b, NULL);
+
+ return;
+ }
+
+ UnloadBlob_UINT16(offset, &t->tag, b);
+ UnloadBlob_UINT64(offset, &t->currentTicks, b);
+ UnloadBlob_UINT16(offset, &t->tickRate, b);
+ UnloadBlob(offset, sizeof(TPM_NONCE), b, (BYTE *)&t->tickNonce);
+}
diff --git a/src/tcs/tcsi_transport.c b/src/tcs/tcsi_transport.c
new file mode 100644
index 0000000..38a3b32
--- /dev/null
+++ b/src/tcs/tcsi_transport.c
@@ -0,0 +1,513 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "tcsps.h"
+#include "req_mgr.h"
+
+
+TSS_RESULT
+TCSP_EstablishTransport_Internal(TCS_CONTEXT_HANDLE hContext,
+ UINT32 ulTransControlFlags,
+ TCS_KEY_HANDLE hEncKey,
+ UINT32 ulTransSessionInfoSize,
+ BYTE* rgbTransSessionInfo,
+ UINT32 ulSecretSize,
+ BYTE* rgbSecret,
+ TPM_AUTH* pEncKeyAuth,
+ TPM_MODIFIER_INDICATOR* pbLocality,
+ TCS_HANDLE* hTransSession,
+ UINT32* ulCurrentTicks,
+ BYTE** prgbCurrentTicks,
+ TPM_NONCE* pTransNonce)
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset;
+ TPM_KEY_HANDLE keySlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (ulTransControlFlags == TSS_TCSATTRIB_TRANSPORT_EXCLUSIVE) {
+ if ((result = ctx_req_exclusive_transport(hContext)))
+ return result;
+ }
+
+ if (pEncKeyAuth) {
+ if ((result = auth_mgr_check(hContext, &pEncKeyAuth->AuthHandle)))
+ return result;
+ }
+
+ /* if hEncKey is set to TPM_KH_TRANSPORT, that's the signal to the TPM that this will be
+ * an unencrypted transport session, so we don't need to check that its loaded */
+ if (hEncKey != TPM_KH_TRANSPORT) {
+ if ((result = ensureKeyIsLoaded(hContext, hEncKey, &keySlot)))
+ return result;
+ }
+
+ offset = TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(&offset, keySlot, txBlob);
+ LoadBlob(&offset, ulTransSessionInfoSize, txBlob, rgbTransSessionInfo);
+ LoadBlob_UINT32(&offset, ulSecretSize, txBlob);
+ LoadBlob(&offset, ulSecretSize, txBlob, rgbSecret);
+ if (pEncKeyAuth) {
+ LoadBlob_Auth(&offset, txBlob, pEncKeyAuth);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, offset, TPM_ORD_EstablishTransport,
+ txBlob);
+ } else
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, offset, TPM_ORD_EstablishTransport, txBlob);
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ if ((result = UnloadBlob_Header(txBlob, &paramSize))) {
+ LogDebugFn("UnloadBlob_Header failed: rc=0x%x", result);
+ goto done;
+ }
+
+ offset = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_UINT32(&offset, hTransSession, txBlob);
+ UnloadBlob_UINT32(&offset, pbLocality, txBlob);
+
+ *ulCurrentTicks = sizeof(TPM_STRUCTURE_TAG)
+ + sizeof(UINT64)
+ + sizeof(UINT16)
+ + sizeof(TPM_NONCE);
+
+ *prgbCurrentTicks = malloc(*ulCurrentTicks);
+ if (*prgbCurrentTicks == NULL) {
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+
+ UnloadBlob(&offset, *ulCurrentTicks, txBlob, *prgbCurrentTicks);
+ UnloadBlob(&offset, sizeof(TPM_NONCE), txBlob, (BYTE *)pTransNonce);
+ if (pEncKeyAuth)
+ UnloadBlob_Auth(&offset, txBlob, pEncKeyAuth);
+
+ ctx_set_transport_enabled(hContext, *hTransSession);
+done:
+ auth_mgr_release_auth(pEncKeyAuth, NULL, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_ExecuteTransport_Internal(TCS_CONTEXT_HANDLE hContext,
+ TPM_COMMAND_CODE unWrappedCommandOrdinal,
+ UINT32 ulWrappedCmdParamInSize,
+ BYTE* rgbWrappedCmdParamIn,
+ UINT32* pulHandleListSize, /* in, out */
+ TCS_HANDLE** rghHandles, /* in, out */
+ TPM_AUTH* pWrappedCmdAuth1, /* in, out */
+ TPM_AUTH* pWrappedCmdAuth2, /* in, out */
+ TPM_AUTH* pTransAuth, /* in, out */
+ UINT64* punCurrentTicks,
+ TPM_MODIFIER_INDICATOR* pbLocality,
+ TPM_RESULT* pulWrappedCmdReturnCode,
+ UINT32* ulWrappedCmdParamOutSize,
+ BYTE** rgbWrappedCmdParamOut)
+{
+ TSS_RESULT result;
+ UINT32 paramSize, wrappedSize, val1 = 0, val2 = 0, *pVal1 = NULL, *pVal2 = NULL;
+ TCS_HANDLE handle1 = 0, handle2 = 0;
+ UINT64 offset, wrappedOffset = 0;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+
+ if (*pulHandleListSize > 2) {
+ LogDebugFn("************ EXPAND KEYSLOT SIZE *********");
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (pWrappedCmdAuth1)
+ if ((result = auth_mgr_check(hContext, &pWrappedCmdAuth1->AuthHandle)))
+ goto done;
+
+ if (pWrappedCmdAuth2)
+ if ((result = auth_mgr_check(hContext, &pWrappedCmdAuth2->AuthHandle)))
+ goto done;
+
+ switch (unWrappedCommandOrdinal) {
+ /* If the command is FlushSpecific, we get handle that needs to be freed, but we don't know
+ * what type it is. */
+ case TPM_ORD_FlushSpecific:
+ if (*pulHandleListSize == 0) { /* invalid */
+ result = TCSERR(TSS_E_BAD_PARAMETER);
+ goto done;
+ }
+
+ /* If this is a transport handle, remove the context's reference to the session */
+ ctx_set_transport_disabled(hContext, rghHandles[0]);
+
+ /* Is it a key? If so, jump to the get_slot_lite and key management calls below */
+ if (ctx_has_key_loaded(hContext, *rghHandles[0]))
+ goto map_key_handles;
+
+ /* fall through */
+ case TPM_ORD_Terminate_Handle:
+ if (!auth_mgr_check(hContext, rghHandles[0]))
+ auth_mgr_release_auth_handle(*rghHandles[0], hContext, FALSE);
+
+ /* If the handle is an auth handle or any other kind of handle, there's no
+ * mapping done in the TCS, so pass its value straight to the TPM and jump over
+ * the switch statement below where we assume FLushSpecific is being done on a
+ * key */
+ handle1 = val1 = *rghHandles[0];
+ pVal1 = &val1;
+
+ goto build_command;
+ default:
+ break;
+ }
+
+map_key_handles:
+ if (*pulHandleListSize == 2) {
+ handle2 = (*rghHandles)[1];
+
+ if ((result = get_slot_lite(hContext, handle2, &val2))) {
+ *pulHandleListSize = 0;
+ goto done;
+ }
+
+ pVal2 = &val2;
+ }
+
+ if (*pulHandleListSize >= 1) {
+ handle1 = *rghHandles[0];
+
+ *pulHandleListSize = 0;
+
+ if ((result = get_slot_lite(hContext, handle1, &val1)))
+ goto done;
+
+ pVal1 = &val1;
+ }
+
+ switch (unWrappedCommandOrdinal) {
+ case TPM_ORD_EvictKey:
+ case TPM_ORD_FlushSpecific:
+ {
+ if ((result = ctx_remove_key_loaded(hContext, handle1)))
+ goto done;
+
+ if ((result = key_mgr_dec_ref_count(handle1)))
+ goto done;
+
+ /* we can't call key_mgr_ref_cnt() here since it calls TPM_EvictKey directly */
+ mc_set_slot_by_handle(handle1, NULL_TPM_HANDLE);
+ break;
+ }
+ case TPM_ORD_OIAP:
+ {
+ /* are the maximum number of auth sessions open? */
+ if (auth_mgr_req_new(hContext) == FALSE) {
+ if ((result = auth_mgr_swap_out(hContext)))
+ goto done;
+ }
+
+ break;
+ }
+ case TPM_ORD_OSAP:
+ {
+ UINT16 entityType;
+ UINT32 entityValue, newEntValue;
+
+ /* are the maximum number of auth sessions open? */
+ if (auth_mgr_req_new(hContext) == FALSE) {
+ if ((result = auth_mgr_swap_out(hContext)))
+ goto done;
+ }
+
+ offset = 0;
+ UnloadBlob_UINT16(&offset, &entityType, rgbWrappedCmdParamIn);
+ UnloadBlob_UINT32(&offset, &entityValue, rgbWrappedCmdParamIn);
+
+ if (entityType == TCPA_ET_KEYHANDLE || entityType == TCPA_ET_KEY) {
+ if (ensureKeyIsLoaded(hContext, entityValue, &newEntValue))
+ return TCSERR(TSS_E_KEY_NOT_LOADED);
+
+ /* OSAP is never encrypted in a transport session, so changing
+ * rgbWrappedCmdParamIn is ok here */
+ offset = sizeof(UINT16);
+ LoadBlob_UINT32(&offset, newEntValue, rgbWrappedCmdParamIn);
+ }
+
+ break;
+ }
+ case TPM_ORD_DSAP:
+ {
+ UINT16 entityType;
+ UINT32 keyHandle, tpmKeyHandle;
+
+ /* are the maximum number of auth sessions open? */
+ if (auth_mgr_req_new(hContext) == FALSE) {
+ if ((result = auth_mgr_swap_out(hContext)))
+ goto done;
+ }
+
+ offset = 0;
+ UnloadBlob_UINT16(&offset, &entityType, rgbWrappedCmdParamIn);
+ UnloadBlob_UINT32(&offset, &keyHandle, rgbWrappedCmdParamIn);
+
+ if (ensureKeyIsLoaded(hContext, keyHandle, &tpmKeyHandle)) {
+ result = TCSERR(TSS_E_KEY_NOT_LOADED);
+ goto done;
+ }
+
+ /* DSAP's only encrypted paramter is entityValue, so replacing keyHandle inside
+ * rgbWrappedCmdParamIn is ok */
+ offset = sizeof(UINT16);
+ LoadBlob_UINT32(&offset, tpmKeyHandle, rgbWrappedCmdParamIn);
+ }
+ default:
+ break;
+ }
+
+build_command:
+ if ((result = tpm_rqu_build(TPM_ORD_ExecuteTransport, &wrappedOffset,
+ &txBlob[TSS_TXBLOB_WRAPPEDCMD_OFFSET], unWrappedCommandOrdinal,
+ pVal1, pVal2, ulWrappedCmdParamInSize, rgbWrappedCmdParamIn,
+ pWrappedCmdAuth1, pWrappedCmdAuth2)))
+ goto done;
+
+ /* The blob we'll load here looks like this:
+ *
+ * |TAGet|LENet|ORDet|wrappedCmdSize|wrappedCmd|AUTHet|
+ *
+ * wrappedCmd looks like this:
+ *
+ * |TAGw|LENw|ORDw|HANDLESw|DATAw|AUTH1w|AUTH2w|
+ *
+ * w = wrapped command info
+ * et = execute transport command info
+ *
+ * Note that the wrapped command was loaded into the blob by the tpm_rqu_build call
+ * above.
+ *
+ */
+ offset = TSS_TPM_TXBLOB_HDR_LEN;
+ /* Load wrapped command size: |wrappedCmdSize| */
+ LoadBlob_UINT32(&offset, wrappedOffset, txBlob);
+
+ /* offset + wrappedOffset is the position of the execute transport auth struct */
+ offset += wrappedOffset;
+
+ if (pTransAuth) {
+ /* Load the auth for the execute transport command: |AUTHet| */
+ LoadBlob_Auth(&offset, txBlob, pTransAuth);
+ /* Load the outer header: |TAGet|LENet|ORDet| */
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, offset, TPM_ORD_ExecuteTransport,
+ txBlob);
+ } else {
+ /* Load the outer header: |TAGet|LENet|ORDet| */
+ LoadBlob_Header(TPM_TAG_RQU_COMMAND, offset, TPM_ORD_ExecuteTransport, txBlob);
+ }
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ /* Unload the Execute Transport (outer) header */
+ if ((result = UnloadBlob_Header(txBlob, &paramSize))) {
+ LogDebugFn("UnloadBlob_Header failed: rc=0x%x", result);
+ goto done;
+ }
+
+ /* The response from the TPM looks like this:
+ *
+ * |TAGet|LENet|RCet|currentTicks|locality|wrappedRspSize|wrappedRsp|AUTHet|
+ *
+ * and wrappedRsp looks like:
+ *
+ * |TAGw|LENw|RCw|HANDLESw|DATAw|AUTH1w|AUTH2w|
+ */
+
+ offset = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_UINT64(&offset, punCurrentTicks, txBlob);
+ UnloadBlob_UINT32(&offset, pbLocality, txBlob);
+
+ /* Unload the wrapped response size: |wrappedRspSize| */
+ UnloadBlob_UINT32(&offset, &wrappedSize, txBlob);
+
+ /* We've parsed right up to wrappedRsp, so save off this offset for later */
+ wrappedOffset = offset;
+
+ /* The current offset + the response size will be the offset of |AUTHet| */
+ offset += wrappedSize;
+ if (pTransAuth)
+ UnloadBlob_Auth(&offset, txBlob, pTransAuth);
+
+ /* Now parse through the returned response @ wrappedOffset */
+ if ((result = UnloadBlob_Header(&txBlob[wrappedOffset], &paramSize))) {
+ LogDebugFn("Wrapped command (Ordinal 0x%x) failed: rc=0x%x",
+ unWrappedCommandOrdinal, result);
+
+ /* This is the result of the wrapped command. If its not success, return its value
+ * in the pulWrappedCmdReturnCode variable and return indicating that the execute
+ * transport command was successful */
+ *pulWrappedCmdReturnCode = result;
+ *ulWrappedCmdParamOutSize = 0;
+ *rgbWrappedCmdParamOut = NULL;
+ auth_mgr_release_auth(pWrappedCmdAuth1, pWrappedCmdAuth2, hContext);
+
+ return TSS_SUCCESS;
+ }
+
+ *pulWrappedCmdReturnCode = TSS_SUCCESS;
+
+ pVal1 = pVal2 = NULL;
+ switch (unWrappedCommandOrdinal) {
+ /* The commands below have 1 outgoing handle */
+ case TPM_ORD_LoadKey2:
+ pVal1 = &val1;
+ break;
+ default:
+ break;
+ }
+
+ result = tpm_rsp_parse(TPM_ORD_ExecuteTransport, &txBlob[wrappedOffset], paramSize,
+ pVal1, pVal2, ulWrappedCmdParamOutSize, rgbWrappedCmdParamOut,
+ pWrappedCmdAuth1, pWrappedCmdAuth2);
+
+ offset = 0;
+ switch (unWrappedCommandOrdinal) {
+ case TPM_ORD_LoadKey2:
+ {
+ TCS_KEY_HANDLE tcs_handle = NULL_TCS_HANDLE;
+
+ if ((result = load_key_final(hContext, handle1, &tcs_handle, NULL, val1)))
+ goto done;
+
+ *rghHandles[0] = tcs_handle;
+ *pulHandleListSize = 1;
+ break;
+ }
+ case TPM_ORD_DSAP:
+ case TPM_ORD_OSAP:
+ case TPM_ORD_OIAP:
+ {
+ UINT32 handle;
+
+ UnloadBlob_UINT32(&offset, &handle, *rgbWrappedCmdParamOut);
+ result = auth_mgr_add(hContext, handle);
+ break;
+ }
+ default:
+ break;
+ }
+
+done:
+ auth_mgr_release_auth(pWrappedCmdAuth1, pWrappedCmdAuth2, hContext);
+ return result;
+}
+
+TSS_RESULT
+TCSP_ReleaseTransportSigned_Internal(TCS_CONTEXT_HANDLE hContext,
+ TCS_KEY_HANDLE hSignatureKey,
+ TPM_NONCE* AntiReplayNonce,
+ TPM_AUTH* pKeyAuth, /* in, out */
+ TPM_AUTH* pTransAuth, /* in, out */
+ TPM_MODIFIER_INDICATOR* pbLocality,
+ UINT32* pulCurrentTicksSize,
+ BYTE** prgbCurrentTicks,
+ UINT32* pulSignatureSize,
+ BYTE** prgbSignature)
+{
+ TSS_RESULT result;
+ UINT32 paramSize;
+ UINT64 offset;
+ TPM_KEY_HANDLE keySlot;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ if ((result = ctx_verify_context(hContext)))
+ return result;
+
+ if (pKeyAuth) {
+ if ((result = auth_mgr_check(hContext, &pKeyAuth->AuthHandle)))
+ return result;
+ }
+
+ if ((result = ensureKeyIsLoaded(hContext, hSignatureKey, &keySlot)))
+ return result;
+
+ offset = TSS_TPM_TXBLOB_HDR_LEN;
+ LoadBlob_UINT32(&offset, keySlot, txBlob);
+ LoadBlob(&offset, sizeof(TPM_NONCE), txBlob, (BYTE *)AntiReplayNonce);
+ if (pKeyAuth) {
+ LoadBlob_Auth(&offset, txBlob, pKeyAuth);
+ LoadBlob_Auth(&offset, txBlob, pTransAuth);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH2_COMMAND, offset, TPM_ORD_ReleaseTransportSigned,
+ txBlob);
+ } else {
+ LoadBlob_Auth(&offset, txBlob, pTransAuth);
+ LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, offset, TPM_ORD_ReleaseTransportSigned,
+ txBlob);
+ }
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ if ((result = UnloadBlob_Header(txBlob, &paramSize))) {
+ LogDebugFn("UnloadBlob_Header failed: rc=0x%x", result);
+ goto done;
+ }
+
+ /* unconditionally disable our accounting of the session */
+ ctx_set_transport_disabled(hContext, NULL);
+
+ offset = TSS_TPM_TXBLOB_HDR_LEN;
+ UnloadBlob_UINT32(&offset, pbLocality, txBlob);
+
+ *pulCurrentTicksSize = sizeof(TPM_STRUCTURE_TAG)
+ + sizeof(UINT64)
+ + sizeof(UINT16)
+ + sizeof(TPM_NONCE);
+
+ *prgbCurrentTicks = malloc(*pulCurrentTicksSize);
+ if (*prgbCurrentTicks == NULL) {
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+
+ UnloadBlob(&offset, *pulCurrentTicksSize, txBlob, *prgbCurrentTicks);
+ UnloadBlob_UINT32(&offset, pulSignatureSize, txBlob);
+
+ *prgbSignature = malloc(*pulSignatureSize);
+ if (*prgbSignature == NULL) {
+ free(*prgbCurrentTicks);
+ result = TCSERR(TSS_E_OUTOFMEMORY);
+ goto done;
+ }
+
+ UnloadBlob(&offset, *pulSignatureSize, txBlob, *prgbSignature);
+
+ if (pKeyAuth)
+ UnloadBlob_Auth(&offset, txBlob, pKeyAuth);
+ UnloadBlob_Auth(&offset, txBlob, pTransAuth);
+
+done:
+ auth_mgr_release_auth(pKeyAuth, NULL, hContext);
+ return result;
+}