summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2019-01-07 15:18:03 +0000
committerchristos <christos@NetBSD.org>2019-01-07 15:18:03 +0000
commitafd0b6f49445aa3494dd3d3995d5e388fc3ed7bd (patch)
tree415e80c4cc4339d58ae631be8286049c4103ecae /crypto
parent0861b3311dafb3dfb78dd65c92776e4d66dd5b13 (diff)
merge conflicts
Diffstat (limited to 'crypto')
-rw-r--r--crypto/external/cpl/trousers/bin/tcsd/Makefile15
-rw-r--r--crypto/external/cpl/trousers/dist/configure.in403
-rw-r--r--crypto/external/cpl/trousers/dist/man/man5/tcsd.conf.5129
-rw-r--r--crypto/external/cpl/trousers/dist/man/man8/tcsd.8112
-rw-r--r--crypto/external/cpl/trousers/dist/src/include/tcsd.h12
-rw-r--r--crypto/external/cpl/trousers/dist/src/include/tcsps.h6
-rw-r--r--crypto/external/cpl/trousers/dist/src/include/trousers_types.h2
-rw-r--r--crypto/external/cpl/trousers/dist/src/tcs/ps/ps_utils.c20
-rw-r--r--crypto/external/cpl/trousers/dist/src/tcs/ps/tcsps.c8
-rw-r--r--crypto/external/cpl/trousers/dist/src/tcs/rpc/tcstp/rpc.c83
-rw-r--r--crypto/external/cpl/trousers/dist/src/tcsd/platform.c7
-rw-r--r--crypto/external/cpl/trousers/dist/src/tcsd/svrside.c349
-rw-r--r--crypto/external/cpl/trousers/dist/src/tcsd/tcsd_conf.c36
-rw-r--r--crypto/external/cpl/trousers/dist/src/tcsd/tcsd_threads.c216
-rw-r--r--crypto/external/cpl/trousers/dist/src/tspi/ps/tspps.c16
-rw-r--r--crypto/external/cpl/trousers/dist/tools/Makefile.am9
-rw-r--r--crypto/external/cpl/trousers/dist/tools/Makefile.in524
-rw-r--r--crypto/external/cpl/trousers/dist/tools/ps_convert.c261
-rw-r--r--crypto/external/cpl/trousers/dist/tools/ps_inspect.c349
19 files changed, 475 insertions, 2082 deletions
diff --git a/crypto/external/cpl/trousers/bin/tcsd/Makefile b/crypto/external/cpl/trousers/bin/tcsd/Makefile
index 237110ec2f0..c5922234e57 100644
--- a/crypto/external/cpl/trousers/bin/tcsd/Makefile
+++ b/crypto/external/cpl/trousers/bin/tcsd/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2012/01/28 02:15:26 christos Exp $
+# $NetBSD: Makefile,v 1.2 2019/01/07 15:18:03 christos Exp $
.include "../Makefile.inc"
.PATH.c: ${DIST}/src/tcsd
@@ -19,10 +19,17 @@ LIBTCSOBJDIR!= cd ${.CURDIR}/../../lib/libtcs && ${PRINTOBJDIR}
DPADD+=${LIBTDDL} ${LIBCRYPTO} ${LIBPTHREAD}
LDADD+=-L${LIBTCSOBJDIR} -ltcs -ltddl -lcrypto -lpthread
-.SUFFIXES: .5 .8
-.PATH.5: ${DIST}/man/man5
-.PATH.8: ${DIST}/man/man8
+.SUFFIXES: .in
+.PATH.in: ${DIST}/man/man5 ${DIST}/man/man8
MAN+=tcsd.conf.5 tcsd.8
+CLEANFILES+= tcsd.conf.5 tcsd.8
+
+__mansed: .USE
+ @${TOOL_SED} -e s/@PACKAGE_BUGREPORT@/gnats-bugs@NetBSD.org/g \
+ -e s/@TCSD_DEFAULT_PORT@/30003/g ${.ALLSRC} > ${.TARGET}
+
+tcsd.8: tcsd.8.in __mansed
+tcsd.conf.5: tcsd.conf.5.in __mansed
.include <bsd.prog.mk>
diff --git a/crypto/external/cpl/trousers/dist/configure.in b/crypto/external/cpl/trousers/dist/configure.in
deleted file mode 100644
index b8a113813f9..00000000000
--- a/crypto/external/cpl/trousers/dist/configure.in
+++ /dev/null
@@ -1,403 +0,0 @@
-#
-# configure.in for the trousers project
-#
-
-AC_INIT(trousers, 0.3.8, trousers-tech@lists.sf.net)
-
-TSS_SPEC_MAJOR=1
-TSS_SPEC_MINOR=2
-TSS_VER_MAJOR=0
-TSS_VER_MINOR=3
-
-# compute $target
-AC_CANONICAL_TARGET
-AM_INIT_AUTOMAKE([foreign 1.6])
-
-# Debugging support
-AC_ARG_ENABLE([debug],
- [AC_HELP_STRING([--enable-debug], [turn on all trousers debugging flags [default=off]])],
- AC_MSG_RESULT([*** Enabling debugging at user request ***]),)
-
-# If the user has not set CFLAGS, do something appropriate
-test_CFLAGS=${CFLAGS+set}
-if test "$test_CFLAGS" != set; then
- if test "x$enable_debug" = "xyes"; then
- CFLAGS="-O0 -g -DTSS_DEBUG -Wreturn-type"
-# CFLAGS="-O0 -g -DTSS_DEBUG -Wreturn-type -DTCSD_SINGLE_THREAD_DEBUG"
- else
- CFLAGS="-O2"
- fi
-else
- if test "x$enable_debug" = "xyes"; then
- CFLAGS="${CFLAGS} -O0 -g -DTSS_DEBUG -Wreturn-type"
- fi
-fi
-
-# Arch specific stuff
-case $target in
- *ppc64* | *powerpc64* | *x86_64*)
- CFLAGS="$CFLAGS -m64"
- ;;
- *solaris*)
- CFLAGS="$CFLAGS -DSOLARIS"
- ;;
- *)
- ;;
-esac
-
-# Non-standard OpenSSL location
-AC_MSG_CHECKING([Non-standard OpenSSL location])
-AC_ARG_WITH(openssl,
- AC_HELP_STRING([--with-openssl=PATH], [Location of openssl libs/includes]),
- [OPENSSL_INCLUDE_DIR="$withval/include"
- OPENSSL_LIB_DIR="$withval/lib"
- if [[ ! -d $OPENSSL_INCLUDE_DIR -o ! -d $OPENSSL_LIB_DIR ]]; then
- AC_MSG_ERROR([$OPENSSL_INCLUDE_DIR or $OPENSSL_LIB_DIR doen't exist!])
- else
- AC_MSG_RESULT([yes])
- CFLAGS="$CFLAGS -L$OPENSSL_LIB_DIR -I$OPENSSL_INCLUDE_DIR"
- AC_SUBST([OPENSSL_LIB_DIR])
- fi],
- [AC_MSG_RESULT([no])
- AC_SUBST([OPENSSL_LIB_DIR], []) ] )
-
-# The tspi Makefile will look for trspi/crypto/@CRYPTO_PACKAGE@/crypto.c
-# Future crypto packages can go in their own subdir of trspi/crypto
-# and a check for them should be made here
-AC_CHECK_LIB([crypto], [EVP_DigestUpdate],
- [CRYPTO_PACKAGE='openssl'],
- [AC_MSG_ERROR([openssl is currently the only supported crypto library for trousers. Please install openssl from http://www.openssl.org or the -devel package from your distro])])
-AC_SUBST([CRYPTO_PACKAGE])
-AC_SUBST(CRYPTOLIB, -lcrypto)
-
-AC_ARG_ENABLE(gcov,
- [AC_HELP_STRING([--enable-gcov], [turn on gcov code coverage flags [default=off]])],
- [CFLAGS="$CFLAGS -ftest-coverage -fprofile-arcs"
- AC_MSG_RESULT([*** Enabling gcov at user request ***])],)
-
-# profiling support
-AC_ARG_ENABLE(gprof,
- [AC_HELP_STRING([--enable-gprof], [enable profiling with gprof [default=off]])],
- [CFLAGS="$CFLAGS -pg"
- AC_MSG_RESULT([*** Enabling profiling at user request ***])],)
-
-SPEC_COMP=0
-# strict spec compliance
-AC_ARG_ENABLE(strict-spec-compliance,
- [AC_HELP_STRING([--enable-strict-spec-compliance], [build TrouSerS as strictly spec compliant [default=off]])],
- [CFLAGS="$CFLAGS -DTSS_SPEC_COMPLIANCE"
- SPEC_COMP=1
- AC_MSG_RESULT([*** Enabling spec compliance at user request ***])],)
-
-# daa math lib: gmp or openssl (default openssl)
-MATH_DEFINE=BI_OPENSSL
-AC_ARG_WITH([gmp],
- AC_HELP_STRING([--with-gmp], [build TrouSerS with the GMP math lib (used in DAA)]),
- [AC_CHECK_LIB(gmp, [__gmp_rand], [], [])
- AC_CHECK_HEADERS([gmp.h])
- MATH_DEFINE=BI_GMP
- AC_MSG_RESULT([*** Enabling GMP lib at user request ***]) ]
-)
-
-case "$MATH_DEFINE" in
-BI_OPENSSL)
- AC_CHECK_HEADERS([ openssl/bn.h openssl/engine.h])
- ;;
-esac
-CFLAGS="$CFLAGS -D$MATH_DEFINE"
-
-GUI=openssl
-AC_ARG_WITH(gui,
- [AC_HELP_STRING([--with-gui], [type of gui popup (gtk/none) [default=gtk]])],
- [GUI=$withval],
- [])
-
-if test "x$GUI" = "xgtk"; then
- # section imported from Glade compile
- pkg_modules="gtk+-2.0 >= 2.0.0"
- PKG_CHECK_MODULES(GTK,
- [$pkg_modules],
- AM_CONDITIONAL(HAVE_GTK, true),
- [AM_CONDITIONAL(HAVE_GTK, false)
- AC_MSG_ERROR([Please install the gtk2-devel package for your distro or select another gui option.]) ])
- AM_CONDITIONAL(OPENSSL_UI, false)
- AC_SUBST(GTK_CFLAGS)
- AC_SUBST(GTK_LIBS)
-elif test "x$GUI" = "xopenssl"; then
- # We know we have OpenSSL
- AM_CONDITIONAL(OPENSSL_UI, true)
- AM_CONDITIONAL(HAVE_GTK, false)
-elif test "x$GUI" = "xnone"; then
- if test $SPEC_COMP -eq 1; then
- AC_MSG_ERROR([Popups must be enabled in strict spec compliance mode])
- fi
- AC_MSG_RESULT([*** Disabling GUI popups at user request ***])
- AC_MSG_RESULT([*** WARNING: This may break apps! ***])
- CFLAGS="$CFLAGS -DTSS_NO_GUI"
- AM_CONDITIONAL(HAVE_GTK, false)
- AM_CONDITIONAL(OPENSSL_UI, false)
-else
- AC_MSG_ERROR(["gtk", "openssl" and "none" are the only supported gui options for trousers])
-fi
-
-#
-# The default port that the TCS daemon listens on
-#
-AC_SUBST(TCSD_DEFAULT_PORT, 30003)
-#
-# The RPC mechanism to build into both libtspi and the tcsd
-#
-# AC_SUBST(RPC, "soap")
-AC_SUBST(RPC, "tcstp")
-
-#
-# API= The TSS API level to build by default.
-#
-# To build a 1.1 TSS, set API=1.1 (./configure --with-api=1.1)
-# To build a 1.2 TSS, set API=1.2 (./configure --with-api=1.2)
-#
-# In order to build a custom TSS API, set API to the lowest API level that
-# contains the APIs you need. For instance, if you need only APIs that are
-# a subset of the TSS 1.1 API, set this to 1.1. If you need any of the 1.2
-# APIs, you'll need to set this to 1.2. Send mail to trousers-tech@lists.sf.net
-# if you have questions.
-#
-API=1.2
-AC_ARG_WITH(api,
- [AC_HELP_STRING([--with-api], [Version of the TSS API to build [default=1.2]])],
- [API=$withval],
- [])
-
-if test "x$API" != "x1.1" && test "x$API" != "x1.2"; then
- AC_MSG_ERROR(["1.1" and "1.2" are the only supported API versions for trousers.
- Custom API build options are available by editing 'configure.in'.])
-fi
-
-if test "x$API" = "x1.1" || test "x$API" = "x1.2"; then
- # Tspi_Hash_GetHashValue,SetHashValue,UpdateHashValue
- AM_CONDITIONAL(TSS_BUILD_HASH, true)
- # Tspi_{Get|Set}Attribdata,{Get|Set}AttribUint32
- AM_CONDITIONAL(TSS_BUILD_GETSET, true)
- # Tspi_TPM_GetRandom,StirRandom
- AM_CONDITIONAL(TSS_BUILD_RANDOM, true)
- # Tspi_GetCapability (for TSP and TCS capabilities)
- AM_CONDITIONAL(TSS_BUILD_CAPS, true)
- # Tspi_TPM_GetCapability (for TPM chip capabilities)
- AM_CONDITIONAL(TSS_BUILD_CAPS_TPM, true)
- # Tspi_GetPolicyObject, Tspi_Policy_SetSecret,FlushSecret,AssignToObject
- AM_CONDITIONAL(TSS_BUILD_POLICY, true)
- # Tspi_TPM_DirWrite,DirRead
- AM_CONDITIONAL(TSS_BUILD_DIR, true)
- # Tspi_TPM_GetEvent,GetEvents,GetEventLog
- AM_CONDITIONAL(TSS_BUILD_PCR_EVENTS, true)
- # Tspi_Hash_Sign,VerifySignature
- AM_CONDITIONAL(TSS_BUILD_SIGN, true)
- # Tspi_TPM_Quote
- AM_CONDITIONAL(TSS_BUILD_QUOTE, true)
- # Tspi_PcrComposite_{Set|Get}PcrValue,SelectPcrIndex
- AM_CONDITIONAL(TSS_BUILD_PCR_COMP, true)
- # Tspi_Data_Seal,Unseal
- AM_CONDITIONAL(TSS_BUILD_SEAL, true)
- # Tspi_ChangeAuth,ChangeAuthAsym
- AM_CONDITIONAL(TSS_BUILD_CHANGEAUTH, true)
- # Tspi_Data_Bind,Unbind
- AM_CONDITIONAL(TSS_BUILD_BIND, true)
- # Tspi_TPM_TakeOwnership,ClearOwner (REQ: EK)
- AM_CONDITIONAL(TSS_BUILD_OWN, true)
- # Tspi_TPM_CreateEndorsementKey,GetPubEndorsementKey
- AM_CONDITIONAL(TSS_BUILD_EK, true)
- # Tspi_Context_RegisterKey,UnregisterKey,LoadKeyByUUID,GetKeyByUUID,GetKeyByPublicInfo,
- # GetRegisteredKeysByUUID
- AM_CONDITIONAL(TSS_BUILD_PS, true)
- # Tspi_TPM_{Set|Get}Status
- AM_CONDITIONAL(TSS_BUILD_ADMIN, true)
- # Tspi_TPM_CollateIdentityRequest,ActivateIdentity
- AM_CONDITIONAL(TSS_BUILD_AIK, true)
- # Tspi_Key_CertifyKey
- AM_CONDITIONAL(TSS_BUILD_CERTIFY, true)
- # Tspi_TPM_CreateMaintenanceArchive,KillMaintenanceFeature,LoadMaintenancePubKey,
- # CheckMaintenancePubKey
- AM_CONDITIONAL(TSS_BUILD_MAINT, true)
- # Tspi_TPM_AuthorizeMigrationTicket,Key_CreateMigrationBlob,ConvertMigrationBlob
- AM_CONDITIONAL(TSS_BUILD_MIGRATION, true)
- # Tspi_Context_LoadKeyByBlob,Key_LoadKey,UnloadKey,CreateKey,WrapKey,GetPubKey
- AM_CONDITIONAL(TSS_BUILD_KEY, true)
- # Tspi_TPM_PcrExtend,PcrRead,PcrReset
- AM_CONDITIONAL(TSS_BUILD_PCR_EXTEND, true)
- # Tspi_TPM_SelfTestFull,CertifySelfTest,GetTestResult
- AM_CONDITIONAL(TSS_BUILD_SELFTEST, true)
-fi
-
-if test "x$API" = "x1.2"; then
- AM_CONDITIONAL(TSS_BUILD_TSS12, true)
- # Don't build DAA until the API is fixed - KEY
- AM_CONDITIONAL(TSS_BUILD_DAA, false)
- AM_CONDITIONAL(TSS_BUILD_PCR_COMP12, true)
- AM_CONDITIONAL(TSS_BUILD_COUNTER, true)
- AM_CONDITIONAL(TSS_BUILD_TICK, true)
- AM_CONDITIONAL(TSS_BUILD_TRANSPORT, true)
- AM_CONDITIONAL(TSS_BUILD_ASN1, true)
- AM_CONDITIONAL(TSS_BUILD_NV, true)
- AM_CONDITIONAL(TSS_BUILD_AUDIT, true)
- AM_CONDITIONAL(TSS_BUILD_SEALX, true)
- AM_CONDITIONAL(TSS_BUILD_DELEGATION, true)
- AM_CONDITIONAL(TSS_BUILD_QUOTE2,true)
- # CMK depends on MIGRATION
- AM_CONDITIONAL(TSS_BUILD_CMK, true)
-else
- AM_CONDITIONAL(TSS_BUILD_TSS12, false)
- AM_CONDITIONAL(TSS_BUILD_DAA, false)
- AM_CONDITIONAL(TSS_BUILD_PCR_COMP12, false)
- AM_CONDITIONAL(TSS_BUILD_COUNTER, false)
- AM_CONDITIONAL(TSS_BUILD_TICK, false)
- AM_CONDITIONAL(TSS_BUILD_TRANSPORT, false)
- AM_CONDITIONAL(TSS_BUILD_ASN1, false)
- AM_CONDITIONAL(TSS_BUILD_NV, false)
- AM_CONDITIONAL(TSS_BUILD_AUDIT, false)
- AM_CONDITIONAL(TSS_BUILD_SEALX, false)
- AM_CONDITIONAL(TSS_BUILD_DELEGATION, false)
- AM_CONDITIONAL(TSS_BUILD_QUOTE2,false)
- AM_CONDITIONAL(TSS_BUILD_CMK, false)
-fi
-
-#
-# There's no need to edit anything below, these conditionals control the building
-# of files that support the files above, which all contain TSS APIs
-#
-AM_CONDITIONAL(TSS_BUILD_NV_LIST, test -z $TSS_BUILD_NV_TRUE)
-AM_CONDITIONAL(TSS_BUILD_NV_SUPPORT, test -z $TSS_BUILD_NV_TRUE)
-AM_CONDITIONAL(TSS_BUILD_GET_FLAGS, test -z $TSS_BUILD_ADMIN_TRUE || \
- test -z $TSS_BUILD_CAPS_TPM_TRUE)
-AM_CONDITIONAL(TSS_BUILD_PCRS_LIST, test -z $TSS_BUILD_SEAL_TRUE || \
- test -z $TSS_BUILD_QUOTE_TRUE || \
- test -z $TSS_BUILD_PCRS_TRUE || \
- test -z $TSS_BUILD_PCR_COMP_TRUE || \
- test -z $TSS_BUILD_SEALX_TRUE)
-AM_CONDITIONAL(TSS_BUILD_HASH_LIST, test -z $TSS_BUILD_SIGN_TRUE || test -z $TSS_BUILD_HASH_TRUE)
-AM_CONDITIONAL(TSS_BUILD_ENCDATA_LIST, test -z $TSS_BUILD_SEAL_TRUE || \
- test -z $TSS_BUILD_CHANGEAUTH_TRUE || \
- test -z $TSS_BUILD_BIND_TRUE || \
- test -z $TSS_BUILD_SEALX_TRUE)
-AM_CONDITIONAL(TSS_BUILD_RSAKEY_LIST, test -z $TSS_BUILD_ADMIN_TRUE || \
- test -z $TSS_BUILD_EK_TRUE || \
- test -z $TSS_BUILD_MIGRATION_TRUE || \
- test -z $TSS_BUILD_MAINT_TRUE || \
- test -z $TSS_BUILD_CERTIFY_TRUE || \
- test -z $TSS_BUILD_AIK_TRUE || \
- test -z $TSS_BUILD_QUOTE_TRUE || \
- test -z $TSS_BUILD_BIND_TRUE || \
- test -z $TSS_BUILD_CHANGEAUTH_TRUE || \
- test -z $TSS_BUILD_OWN_TRUE || \
- test -z $TSS_BUILD_SIGN_TRUE || \
- test -z $TSS_BUILD_PS_TRUE || \
- test -z $TSS_BUILD_SEAL_TRUE || \
- test -z $TSS_BUILD_DAA_TRUE || \
- test -z $TSS_BUILD_KEY_TRUE || \
- test -z $TSS_BUILD_SEALX_TRUE)
-AM_CONDITIONAL(TSS_BUILD_AUTH, test -z $TSS_BUILD_HASH_TRUE || \
- test -z $TSS_BUILD_CAPS_TRUE || \
- test -z $TSS_BUILD_CAPS_TPM_TRUE || \
- test -z $TSS_BUILD_POLICY_TRUE || \
- test -z $TSS_BUILD_DIR_TRUE || \
- test -z $TSS_BUILD_PCR_EVENTS_TRUE || \
- test -z $TSS_BUILD_SIGN_TRUE || \
- test -z $TSS_BUILD_QUOTE_TRUE || \
- test -z $TSS_BUILD_PCR_COMP_TRUE || \
- test -z $TSS_BUILD_SEAL_TRUE || \
- test -z $TSS_BUILD_SEALX_TRUE || \
- test -z $TSS_BUILD_CHANGEAUTH_TRUE || \
- test -z $TSS_BUILD_BIND_TRUE || \
- test -z $TSS_BUILD_OWN_TRUE || \
- test -z $TSS_BUILD_PS_TRUE || \
- test -z $TSS_BUILD_ADMIN_TRUE || \
- test -z $TSS_BUILD_AIK_TRUE || \
- test -z $TSS_BUILD_EK_TRUE || \
- test -z $TSS_BUILD_CERTIFY_TRUE || \
- test -z $TSS_BUILD_MAINT_TRUE || \
- test -z $TSS_BUILD_MIGRATION_TRUE || \
- test -z $TSS_BUILD_KEY_TRUE || \
- test -z $TSS_BUILD_PCR_EXTEND_TRUE || \
- test -z $TSS_BUILD_SELFTEST_TRUE || \
- test -z $TSS_BUILD_DAA_TRUE)
-AM_CONDITIONAL(TSS_BUILD_ASYM_CRYPTO, test -z $TSS_BUILD_AIK_TRUE || \
- test -z $TSS_BUILD_CERTIFY_TRUE || \
- test -z $TSS_BUILD_QUOTE_TRUE || \
- test -z $TSS_BUILD_EK_TRUE || \
- test -z $TSS_BUILD_CHANGEAUTH_TRUE || \
- test -z $TSS_BUILD_BIND_TRUE || \
- test -z $TSS_BUILD_OWN_TRUE || \
- test -z $TSS_BUILD_SELFTEST_TRUE || \
- test -z $TSS_BUILD_SIGN_TRUE || \
- test -z $TSS_BUILD_KEY_TRUE || \
- test -z $TSS_BUILD_DAA_TRUE)
-AM_CONDITIONAL(TSS_BUILD_SYM_CRYPTO, test -z $TSS_BUILD_AIK_TRUE || \
- test -z $TSS_BUILD_TRANSPORT_TRUE)
-
-#GETTEXT_PACKAGE=trousers
-#AC_SUBST(GETTEXT_PACKAGE)
-#AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE")
-
-dnl Add the languages which your application supports here.
-#ALL_LINGUAS=""
-#AM_GLIB_GNU_GETTEXT
-
-# end Glade section
-
-AC_CHECK_HEADER(pthread.h, [AC_DEFINE(HAVE_PTHREAD_H, 1, [pthread header])])
-
-AC_DISABLE_STATIC
-AC_PROG_CC
-AC_PROG_LIBTOOL
-
-AC_C_BIGENDIAN([AC_DEFINE(_BIG_ENDIAN, 1, [big-endian host])])
-AC_CHECK_DECL(htole32, [AC_DEFINE(HTOLE_DEFINED, 1, [htole32 function is available])])
-AC_CHECK_HEADER(sys/byteorder.h, [AC_DEFINE(HAVE_BYTEORDER_H, 1, [sys/byteorder.h header])])
-AC_CHECK_FUNC(daemon, [ AC_DEFINE(HAVE_DAEMON, 1, [daemon function is available]) ])
-
-if test "x${GCC}" = "xyes"; then
- CFLAGS="$CFLAGS -W -Wall -Werror -Wno-unused-parameter -Wsign-compare"
-fi
-
-CFLAGS="$CFLAGS -I../include \
- -DTCSD_DEFAULT_PORT=${TCSD_DEFAULT_PORT} -DTSS_VER_MAJOR=${TSS_VER_MAJOR} \
- -DTSS_VER_MINOR=${TSS_VER_MINOR} -DTSS_SPEC_MAJOR=${TSS_SPEC_MAJOR} \
- -DTSS_SPEC_MINOR=${TSS_SPEC_MINOR}"
-#CFLAGS="$CFLAGS -I../include -std=c99 -pedantic -W -Wall"
-KERNEL_VERSION=`uname -r`
-AC_SUBST(CFLAGS)
-
-# When we build the rpms, prefix will be /usr. This'll do some things that make sense,
-# like put our sbin stuff in /usr/sbin and our library in /usr/lib. It'll do some other
-# things that don't make sense like put our config file in /usr/etc. So, I'll just hack
-# it here. If the --prefix option isn't specified during configure, let it all go to
-# /usr/local, even /usr/local/etc. :-P
-if test x"${prefix}" = x"/usr"; then
- sysconfdir="/etc"
- localstatedir="/var"
- mandir="/usr/share/man"
-elif test x"${prefix}" = x"NONE"; then
- localstatedir="/usr/local/var"
-fi
-
-AC_OUTPUT(dist/tcsd.conf \
- dist/fedora/trousers.spec \
- dist/trousers.spec \
- Makefile \
- src/Makefile \
- src/include/Makefile \
- src/tcs/Makefile \
- src/tddl/Makefile \
- src/tspi/Makefile \
- src/trspi/Makefile \
- src/tcsd/Makefile \
- tools/Makefile \
- man/man8/tcsd.8 \
- man/man5/tcsd.conf.5 \
- dist/Makefile \
- man/Makefile \
- man/man3/Makefile \
- man/man5/Makefile \
- man/man8/Makefile)
-
-echo "CFLAGS=$CFLAGS"
-
diff --git a/crypto/external/cpl/trousers/dist/man/man5/tcsd.conf.5 b/crypto/external/cpl/trousers/dist/man/man5/tcsd.conf.5
deleted file mode 100644
index 52284c5420e..00000000000
--- a/crypto/external/cpl/trousers/dist/man/man5/tcsd.conf.5
+++ /dev/null
@@ -1,129 +0,0 @@
-.\" Copyright (C) 2005 International Business Machines Corporation
-.\"
-.de Sh \" Subsection
-.br
-.if t .Sp
-.ne 5
-.PP
-\fB\\$1\fR
-.PP
-..
-.de Sp \" Vertical space (when we can't use .PP)
-.if t .sp .5v
-.if n .sp
-..
-.de Ip \" List item
-.br
-.ie \\n(.$>=3 .ne \\$3
-.el .ne 3
-.IP "\\$1" \\$2
-..
-.TH "tcsd.conf" 5 "2006-07-14" "TSS 1.1"
-.ce 1
-TCG Software Stack
-.SH NAME
-tcsd.conf \- configuration file for the trousers TCS daemon.
-.SH "DESCRIPTION"
-.PP
-This file, by default
-.IR /etc/tcsd.conf
-is read by the trousers TCSD daemon, tcsd (see tcsd(8)). The tcsd.conf file
-that is installed by trousers contains all the default options, commented out.
-.SH "OPTIONS"
-.PP
-.BI port
-The port that TCSD will listen on for connections, local and remote, from
-applications.
-
-.BI num_threads
-The maximum number of threads that the TCSD will spawn simultaneously to service
-applications. After
-.BI num_threads
-threads have been spawned, any application that attempts to connect to the TCSD
-will receive an error.
-
-.BI system_ps_file
-The location of the system persistent storage file. The system persistent
-storage file holds keys and data across restarts of the TCSD and system
-reboots.
-
-.BI firmware_log_file
-Path to the file containing the current firmware PCR event log data. The
-interface to this log is usually provided by the TPM device driver.
-
-.BI kernel_log_file
-Path to the file containing the current kernel PCR event log data. By default,
-this data will be parsed in the format provided by the Integrity Measurement
-Architecture LSM.
-
-.BI firmware_pcrs
-A list of PCR indices that are manipulated only by the system firmware and
-therefore are not extended or logged by the TCSD. Applications that call
-Tcsi_PcrExtend on PCRs listed here will receive an error.
-
-.BI kernel_pcrs
-A list of PCR indices that are manipulated only by the kernel and therefore
-are not extended or logged by the TCSD. Applications that call Tcsi_PcrExtend
-on PCRs listed here will receive an error.
-
-.BI platform_cred
-Path to the platform credential for your TPM. Your TPM manufacturer may have
-provided you with a set of credentials (certificates) that should be used when
-creating identities using your TPM. When a user of your TPM makes an identity,
-this credential will be encrypted as part of that process. See the 1.1b TPM Main
-specification section 9.3 for information on this process.
-
-.BI conformance_cred
-Path to the conformance credential for your TPM. Your TPM manufacturer may have
-provided you with a set of credentials (certificates) that should be used when
-creating identities using your TPM. When a user of your TPM makes an identity,
-this credential will be encrypted as part of that process. See the 1.1b TPM Main
-specification section 9.3 for information on this process.
-
-.BI endorsement_cred
-Path to the endorsement credential for your TPM. Your TPM manufacturer may have
-provided you with a set of credentials (certificates) that should be used when
-creating identities using your TPM. When a user of your TPM makes an identity,
-this credential will be encrypted as part of that process. See the 1.1b TPM Main
-specification section 9.3 for information on this process.
-
-.BI remote_ops
-A list of TCS commands which will be allowed to be executed on this machine's
-TCSD by TSP's on non-local hosts (over the internet). By default, access to all
-operations is denied.
-
-.BI host_platform_class
-Determines the TCG specification of the host's platform class. This refers to
-one of the specifications contained in the TCG web site. The default is PC
-specification version 1.2 .
-
-.BI all_platform_classes
-Specifies all the TCG defined platforms associated with the host platform. The
-host_platform_class must not be defined here. By default, all platforms but
-the host platform are associated.
-
-.SH "EXAMPLE"
-.PP
-.IP
-.nf
-port = 30003
-num_threads = 10
-system_ps_file = /usr/local/var/tpm/system.data
-firmware_log_file = /proc/tpm/firmware_events
-kernel_log_file = /proc/tcg/measurement_events
-firmware_pcrs = 0,1,2,3,4,5,6,7
-kernel_pcrs = 10,11
-platform_cred = /usr/local/var/lib/tpm/platform.cert
-conformance_cred = /usr/local/var/lib/tpm/conformance.cert
-endorsement_cred = /usr/local/var/lib/tpm/endorsement.cert
-remote_ops = create_key,random
-host_platform_class = server_12
-all_platform_classes = pc_11,pc_12,mobile_12
-.fi
-.SH "SEE ALSO"
-.PP
-\fBtcsd\fR(8)
-.SH "AUTHOR"
-Kent Yoder
-.SH "REPORTING BUGS"
-Report bugs to <trousers-tech@lists.sf.net>
diff --git a/crypto/external/cpl/trousers/dist/man/man8/tcsd.8 b/crypto/external/cpl/trousers/dist/man/man8/tcsd.8
deleted file mode 100644
index e383102adbb..00000000000
--- a/crypto/external/cpl/trousers/dist/man/man8/tcsd.8
+++ /dev/null
@@ -1,112 +0,0 @@
-.\" Copyright (C) 2005 International Business Machines Corporation
-.\"
-.de Sh \" Subsection
-.br
-.if t .Sp
-.ne 5
-.PP
-\fB\\$1\fR
-.PP
-..
-.de Sp \" Vertical space (when we can't use .PP)
-.if t .sp .5v
-.if n .sp
-..
-.de Ip \" List item
-.br
-.ie \\n(.$>=3 .ne \\$3
-.el .ne 3
-.IP "\\$1" \\$2
-..
-.TH "tcsd" 8 "2005-03-15" "TSS 1.1"
-.ce 1
-TCG Software Stack
-.SH NAME
-tcsd \- daemon that manages Trusted Computing resources
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.B tcsd
-.RB [ \-f ]
-.RB [ \-c\ <configfile>\ ]
-
-.SH "DESCRIPTION"
-.PP
-Trousers is an open-source TCG Software Stack (TSS), released under the Common
-Public License. Trousers aims to be compliant with the current (1.1b) and
-upcoming (1.2) TSS specifications available from the Trusted Computing Group
-website: http://www.trustedcomputinggroup.org.
-
-\fBtcsd\fR is a user space daemon that should be (according to the TSS spec)
-the only portal to the TPM device driver. At boot time, \fBtcsd\fR should
-be started, it should open the TPM device driver and from that point on, all
-requests to the TPM should go through the TSS stack. The \fBtcsd\fR manages TPM
-resources and handles requests from TSP's both local and remote.
-
-.TP
-\fB\-f\fR
-run the daemon in the foreground
-
-.TP
-\fB\-c <configfile>\fR
-use the provided configuration file rather than the default configuration file
-
-.SH "ACCESS CONTROL"
-.PP
-There are two types of access control for the \fBtcsd\fR, access to the
-daemon's socket itself and access to specific commands internal to the
-\fBtcsd\fR. Access to the \fBtcsd\fR's port should be controlled by the system
-administrator using firewall rules. If using iptables, the following rule
-will allow a specific host access to the tcsd:
-
-# iptables -A INPUT -s $IP_ADDRESS -p tcp --destination-port 30003 -j ACCEPT
-
-Access to individual commands internal to the tcsd is configured by the
-\fBtcsd\fR configuration file's "remote_ops" directive. Each function call
-in the TCS API is reachable by a unique ordinal. Each labeled "remote op"
-actually defines a set of ordinals (usually more than one) necessary to
-accomplish the operation. So, for example, the "random" operation enables
-the ordinals for opening and closing a context, calling TCS_StirRandom
-and TCS_GetRandom, as well as TCS_FreeMemory. By default, connections from
-localhost will allow any ordinals.
-
-.SH "DATA FILES"
-.PP
-TSS applications have access to 2 different kinds of 'persistant' storage. 'User'
-persistant storage has the lifetime of that of the application using it
-and therefore is destroyed when an application exits. User PS is controlled
-by the TSP of the application. 'System' persistent storage is controlled by
-the TCS and stays valid across application lifetimes, \fBtcsd\fR restarts and
-system resets. Data registered in system PS stays valid until an application
-requests that it be removed. User PS files are by default stored as
-/var/tpm/user.{pid} and the system PS file by default is /var/tpm/system.data.
-The system PS file is initially created when ownership of the TPM is first
-taken.
-
-.SH "CONFIGURATION"
-\fBtcsd\fR configuration is stored by default in /etc/tcsd.conf
-
-.SH "DEBUG OUTPUT"
-If TrouSerS has been compiled with debugging enabled, the debugging output
-can be supressed by setting the TSS_DEBUG_OFF environment variable.
-
-.SH "DEVICE DRIVERS"
-.PP
-\fBtcsd\fR is compatible with the IBM Research TPM device driver available
-from http://www.research.ibm.com/gsal/tcpa and the TPM device driver available
-from http://sf.net/projects/tmpdd
-
-.SH "CONFORMING TO"
-.PP
-\fBtcsd\fR conforms to the Trusted Computing Group Software
-Specification version 1.1 Golden
-
-.SH "SEE ALSO"
-.PP
-\fBtcsd.conf\fR(5)
-
-.SH "AUTHOR"
-Kent Yoder
-
-.SH "REPORTING BUGS"
-Report bugs to <trousers-tech@lists.sf.net>
diff --git a/crypto/external/cpl/trousers/dist/src/include/tcsd.h b/crypto/external/cpl/trousers/dist/src/include/tcsd.h
index 4bdef3eb866..59944a26fc4 100644
--- a/crypto/external/cpl/trousers/dist/src/include/tcsd.h
+++ b/crypto/external/cpl/trousers/dist/src/include/tcsd.h
@@ -46,6 +46,8 @@ struct tcsd_config
struct platform_class *host_platform_class; /* Host platform class of this TCS System */
struct platform_class *all_platform_classes; /* List of platform classes
of this TCS System */
+ int disable_ipv4;
+ int disable_ipv6;
};
#define TCSD_DEFAULT_CONFIG_FILE ETC_PREFIX "/tcsd.conf"
@@ -66,6 +68,8 @@ extern char *tcsd_config_file;
#define TCSD_DEFAULT_KERNEL_LOG_FILE "/sys/kernel/security/ima/binary_runtime_measurements"
#define TCSD_DEFAULT_FIRMWARE_PCRS 0x00000000
#define TCSD_DEFAULT_KERNEL_PCRS 0x00000000
+#define TCSD_DEFAULT_DISABLE_IPV4 0
+#define TCSD_DEFAULT_DISABLE_IPV6 0
/* This will change when a system with more than 32 PCR's exists */
#define TCSD_MAX_PCRS 32
@@ -102,6 +106,8 @@ struct tcg_platform_spec {
#define TCSD_OPTION_REMOTE_OPS 0x0400
#define TCSD_OPTION_EXCLUSIVE_TRANSPORT 0x0800
#define TCSD_OPTION_HOST_PLATFORM_CLASS 0x1000
+#define TCSD_OPTION_DISABLE_IPV4 0x2000
+#define TCSD_OPTION_DISABLE_IPV6 0x4000
#define TSS_TCP_RPC_MAX_DATA_LEN 1048576
#define TSS_TCP_RPC_BAD_PACKET_TYPE 0x10000000
@@ -120,7 +126,9 @@ enum tcsd_config_option_code {
opt_remote_ops,
opt_exclusive_transport,
opt_host_platform_class,
- opt_all_platform_classes
+ opt_all_platform_classes,
+ opt_disable_ipv4,
+ opt_disable_ipv6
};
struct tcsd_config_options {
@@ -162,7 +170,9 @@ void *tcsd_thread_run(void *);
void thread_signal_init();
/* signal handling */
+#ifndef __APPLE__
struct sigaction tcsd_sa_int;
struct sigaction tcsd_sa_chld;
+#endif
#endif
diff --git a/crypto/external/cpl/trousers/dist/src/include/tcsps.h b/crypto/external/cpl/trousers/dist/src/include/tcsps.h
index 92a4efed4f1..7a6f9358c8d 100644
--- a/crypto/external/cpl/trousers/dist/src/include/tcsps.h
+++ b/crypto/external/cpl/trousers/dist/src/include/tcsps.h
@@ -23,8 +23,10 @@ int get_file();
int put_file(int);
void close_file(int);
void ps_destroy();
-TSS_RESULT read_data(int, void *, UINT32);
-TSS_RESULT write_data(int, void *, UINT32);
+
+TSS_RESULT read_data(int, void *, UINT32);
+TSS_RESULT write_data(int, void *, UINT32);
+
int write_key_init(int, UINT32, UINT32, UINT32);
TSS_RESULT cache_key(UINT32, UINT16, TSS_UUID *, TSS_UUID *, UINT16, UINT32, UINT32);
TSS_RESULT UnloadBlob_KEY_PS(UINT16 *, BYTE *, TSS_KEY *);
diff --git a/crypto/external/cpl/trousers/dist/src/include/trousers_types.h b/crypto/external/cpl/trousers/dist/src/include/trousers_types.h
index 8774ffda6a9..e1e30c16525 100644
--- a/crypto/external/cpl/trousers/dist/src/include/trousers_types.h
+++ b/crypto/external/cpl/trousers/dist/src/include/trousers_types.h
@@ -120,7 +120,7 @@ typedef struct tdTSS_KEY {
#if (defined (__linux) || defined (linux) || defined (SOLARIS) || defined (__GLIBC__))
#define BSD_CONST
-#elif (defined (__OpenBSD__) || defined (__FreeBSD__) || defined(__NetBSD__))
+#elif defined (__OpenBSD__) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__APPLE__)
#define BSD_CONST const
#endif
diff --git a/crypto/external/cpl/trousers/dist/src/tcs/ps/ps_utils.c b/crypto/external/cpl/trousers/dist/src/tcs/ps/ps_utils.c
index 261819ac740..3e256985625 100644
--- a/crypto/external/cpl/trousers/dist/src/tcs/ps/ps_utils.c
+++ b/crypto/external/cpl/trousers/dist/src/tcs/ps/ps_utils.c
@@ -13,14 +13,16 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
-#if defined(HAVE_BYTEORDER_H)
+#if defined (HAVE_BYTEORDER_H)
#include <sys/byteorder.h>
-#elif defined(HTOLE_DEFINED)
-#ifdef __NetBSD__
-#include <sys/endian.h>
-#else
+#elif defined (HTOLE_DEFINED)
+
+#ifndef __APPLE__
#include <endian.h>
+#else
+#include "portable_endian.h"
#endif
+
#define LE_16 htole16
#define LE_32 htole32
#define LE_64 htole64
@@ -46,11 +48,7 @@
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;
@@ -68,11 +66,7 @@ read_data(int fd, void *data, UINT32 size)
}
-#ifdef SOLARIS
TSS_RESULT
-#else
-inline TSS_RESULT
-#endif
write_data(int fd, void *data, UINT32 size)
{
int rc;
diff --git a/crypto/external/cpl/trousers/dist/src/tcs/ps/tcsps.c b/crypto/external/cpl/trousers/dist/src/tcs/ps/tcsps.c
index a08c3cdd9ba..e47154b2061 100644
--- a/crypto/external/cpl/trousers/dist/src/tcs/ps/tcsps.c
+++ b/crypto/external/cpl/trousers/dist/src/tcs/ps/tcsps.c
@@ -20,11 +20,13 @@
#if defined (HAVE_BYTEORDER_H)
#include <sys/byteorder.h>
#elif defined (HTOLE_DEFINED)
-#ifdef __NetBSD__
-#include <sys/endian.h>
-#else
+
+#ifndef __APPLE__
#include <endian.h>
+#else
+#include "portable_endian.h"
#endif
+
#define LE_16 htole16
#define LE_32 htole32
#define LE_64 htole64
diff --git a/crypto/external/cpl/trousers/dist/src/tcs/rpc/tcstp/rpc.c b/crypto/external/cpl/trousers/dist/src/tcs/rpc/tcstp/rpc.c
index c68ca6e1052..d09e0274c07 100644
--- a/crypto/external/cpl/trousers/dist/src/tcs/rpc/tcstp/rpc.c
+++ b/crypto/external/cpl/trousers/dist/src/tcs/rpc/tcstp/rpc.c
@@ -16,6 +16,7 @@
#if (defined (__OpenBSD__) || defined (__FreeBSD__) || defined(__NetBSD__))
#include <sys/types.h>
#include <sys/socket.h>
+#include <netinet/in.h>
#endif
#include <errno.h>
@@ -181,7 +182,7 @@ loadData(UINT64 *offset, TCSD_PACKET_TYPE data_type, void *data, int data_size,
int
setData(TCSD_PACKET_TYPE dataType,
- int index,
+ unsigned int index,
void *theData,
int theDataSize,
struct tcsd_comm_data *comm)
@@ -194,11 +195,8 @@ setData(TCSD_PACKET_TYPE dataType,
offset = 0;
if ((result = loadData(&offset, dataType, theData, theDataSize, NULL)) != TSS_SUCCESS)
return result;
- if (((int)comm->hdr.packet_size + (int)offset) < 0) {
- LogError("Too much data to be transmitted!");
- return TCSERR(TSS_E_INTERNAL_ERROR);
- }
- if (((int)comm->hdr.packet_size + (int)offset) > comm->buf_size) {
+
+ if ((comm->hdr.packet_size + offset) > comm->buf_size) {
/* reallocate the buffer */
BYTE *buffer;
int buffer_size = comm->hdr.packet_size + offset;
@@ -229,13 +227,18 @@ setData(TCSD_PACKET_TYPE dataType,
UINT32
getData(TCSD_PACKET_TYPE dataType,
- int index,
+ unsigned int index,
void *theData,
int theDataSize,
struct tcsd_comm_data *comm)
{
UINT64 old_offset, offset;
- TCSD_PACKET_TYPE *type = (TCSD_PACKET_TYPE *)(comm->buf + comm->hdr.type_offset) + index;
+ 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);
@@ -517,37 +520,40 @@ 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"));
+ int is_localhost;
+ struct sockaddr_storage sas;
+ struct sockaddr *sa;
+ socklen_t sas_len = sizeof(sas);
+
+ if (getpeername(thread_data->sock, (struct sockaddr *)&sas,
+ &sas_len) == -1) {
+ LogError("Error retrieving local socket address: %s", strerror(errno));
+ return 1;
+ }
- 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);
- }
+ sa = (struct sockaddr *)&sas;
+
+ is_localhost = 0;
+ // Check if it's localhost for both inet protocols
+ if (sa->sa_family == AF_INET) {
+ struct sockaddr_in *sa_in = (struct sockaddr_in *)sa;
+ in_addr_t nloopaddr = htonl(INADDR_LOOPBACK);
+ if (memcmp(&sa_in->sin_addr.s_addr, &nloopaddr,
+ sizeof(in_addr_t)) == 0)
+ is_localhost = 1;
+ }
+ else if (sa->sa_family == AF_INET6) {
+ struct sockaddr_in6 *sa_in6 = (struct sockaddr_in6 *)sa;
+ if (memcmp(&sa_in6->sin6_addr.s6_addr, &in6addr_loopback,
+ sizeof(struct in6_addr)) == 0)
+ is_localhost = 1;
}
/* 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)))) {
+ if (is_localhost)
return 0;
- } else {
+ 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",
@@ -574,7 +580,8 @@ dispatchCommand(struct tcsd_thread_data *data)
return TCSERR(TSS_E_FAIL);
}
- LogDebug("Dispatching ordinal %u", data->comm.hdr.u.ordinal);
+ LogDebug("Dispatching ordinal %u (%s)", data->comm.hdr.u.ordinal,
+ tcs_func_table[data->comm.hdr.u.ordinal].name);
/* 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)) {
@@ -615,11 +622,11 @@ dispatchCommand(struct tcsd_thread_data *data)
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))
+ if (data->comm.hdr.packet_size !=
+ (UINT32)(data->comm.hdr.parm_offset + data->comm.hdr.parm_size)) {
+ LogError("Invalid packet received by TCSD");
return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
/* dispatch the command to the TCS */
return dispatchCommand(data);
diff --git a/crypto/external/cpl/trousers/dist/src/tcsd/platform.c b/crypto/external/cpl/trousers/dist/src/tcsd/platform.c
index 6c2e94ef8e9..0367f53af58 100644
--- a/crypto/external/cpl/trousers/dist/src/tcsd/platform.c
+++ b/crypto/external/cpl/trousers/dist/src/tcsd/platform.c
@@ -9,7 +9,7 @@
*/
-#if (defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__))
+#if defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) || defined (__APPLE__)
#include <sys/param.h>
#include <sys/sysctl.h>
#include <err.h>
@@ -52,6 +52,7 @@ platform_get_runlevel()
ut.ut_type = RUN_LVL;
+ setutent();
next = getutid(&ut);
while (next != NULL) {
@@ -81,7 +82,7 @@ platform_get_runlevel()
return runlevel;
}
-#elif (defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__))
+#elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) || defined (__APPLE__)
char
platform_get_runlevel()
@@ -112,7 +113,7 @@ MUTEX_DECLARE_INIT(utmp_lock);
char
platform_get_runlevel()
{
- char runlevel;
+ char runlevel = 'u'; /* unknown run level */
struct utmpx ut, *utp = NULL;
MUTEX_LOCK(utmp_lock);
diff --git a/crypto/external/cpl/trousers/dist/src/tcsd/svrside.c b/crypto/external/cpl/trousers/dist/src/tcsd/svrside.c
index 4e9bd133fa1..d25cd824067 100644
--- a/crypto/external/cpl/trousers/dist/src/tcsd/svrside.c
+++ b/crypto/external/cpl/trousers/dist/src/tcsd/svrside.c
@@ -27,6 +27,7 @@
#include <arpa/inet.h>
#include <errno.h>
#include <getopt.h>
+#include <sys/select.h>
#include "trousers/tss.h"
#include "trousers_types.h"
#include "tcs_tsp.h"
@@ -43,12 +44,38 @@ struct tcsd_config tcsd_options;
struct tpm_properties tpm_metrics;
static volatile int hup = 0, term = 0;
extern char *optarg;
-int sd;
char *tcsd_config_file = NULL;
+struct srv_sock_info {
+ int sd;
+ int domain; // AF_INET or AF_INET6
+ socklen_t addr_len;
+};
+#define MAX_IP_PROTO 2
+#define INVALID_ADDR_STR "<Invalid client address>"
+
+static void close_server_socks(struct srv_sock_info *socks_info)
+{
+ int i, rv;
+
+ for (i=0; i < MAX_IP_PROTO; i++) {
+ if (socks_info[i].sd != -1) {
+ do {
+ rv = close(socks_info[i].sd);
+ if (rv == -1 && errno != EINTR) {
+ LogError("Error closing server socket descriptor - %s",
+ strerror(errno));
+ continue;
+ }
+ } while (rv == -1 && errno == EINTR);
+ }
+ }
+}
+
static void
-tcsd_shutdown(void)
+tcsd_shutdown(struct srv_sock_info socks_info[])
{
+ close_server_socks(socks_info);
/* order is important here:
* allow all threads to complete their current request */
tcsd_threads_final();
@@ -63,7 +90,6 @@ static void
tcsd_signal_term(int signal)
{
term = 1;
- close(sd);
}
void
@@ -211,17 +237,193 @@ reload_config(void)
return result;
}
+int setup_ipv4_socket(struct srv_sock_info ssi[])
+{
+ struct sockaddr_in serv_addr;
+ int sd, opt;
+
+ ssi->sd = -1;
+
+ // Initialization of IPv4 socket.
+ sd = socket(AF_INET, SOCK_STREAM, 0);
+ if (sd < 0) {
+ LogWarn("Failed IPv4 socket: %s", strerror(errno));
+ goto err;
+ }
+
+ memset(&serv_addr, 0, sizeof (serv_addr));
+ serv_addr.sin_family = AF_INET;
+ serv_addr.sin_port = htons(tcsd_options.port);
+
+ /* If no remote_ops are defined, restrict connections to localhost
+ * only at the socket. */
+ if (tcsd_options.remote_ops[0] == 0)
+ serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ else
+ serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+
+ opt = 1;
+ setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
+ if (bind(sd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) < 0) {
+ LogWarn("Failed IPv4 bind: %s", strerror(errno));
+ goto err;
+ }
+
+ if (listen(sd, TCSD_MAX_SOCKETS_QUEUED) < 0) {
+ LogWarn("Failed IPv4 listen: %s", strerror(errno));
+ goto err;
+ }
+
+ ssi->domain = AF_INET;
+ ssi->sd = sd;
+ ssi->addr_len = sizeof(serv_addr);
+
+ return 0;
+
+ err:
+ if (sd != -1)
+ close(sd);
+
+ return -1;
+}
+
+int setup_ipv6_socket(struct srv_sock_info *ssi)
+{
+ struct sockaddr_in6 serv6_addr;
+ int sd6, opt;
+
+ ssi->sd = -1;
+
+ sd6 = socket(AF_INET6, SOCK_STREAM, 0);
+ if (sd6 < 0) {
+ LogWarn("Failed IPv6 socket: %s", strerror(errno));
+ goto err;
+ }
+
+ memset(&serv6_addr, 0, sizeof (serv6_addr));
+ serv6_addr.sin6_family = AF_INET6;
+ serv6_addr.sin6_port = htons(tcsd_options.port);
+
+ /* If no remote_ops are defined, restrict connections to localhost
+ * only at the socket. */
+ if (tcsd_options.remote_ops[0] == 0)
+ serv6_addr.sin6_addr = in6addr_loopback;
+ else
+ serv6_addr.sin6_addr = in6addr_any;
+
+#ifdef __linux__
+ /* Linux, by default, allows one socket to be used by both IP stacks
+ * This option disables that behavior, so you must have one socket for
+ * each IP protocol. */
+ opt = 1;
+ if(setsockopt(sd6, IPPROTO_IPV6, IPV6_V6ONLY, &opt, sizeof(opt)) == -1) {
+ LogWarn("Could not set IPv6 socket option properly.\n");
+ goto err;
+ }
+#endif
+
+ opt = 1;
+ setsockopt(sd6, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
+ if (bind(sd6, (struct sockaddr *) &serv6_addr, sizeof (serv6_addr)) < 0) {
+ LogWarn("Failed IPv6 bind: %s", strerror(errno));
+ goto err;
+ }
+
+ if (listen(sd6, TCSD_MAX_SOCKETS_QUEUED) < 0) {
+ LogWarn("Failed IPv6 listen: %s", strerror(errno));
+ goto err;
+ }
+
+ ssi->domain = AF_INET6;
+ ssi->sd = sd6;
+ ssi->addr_len = sizeof(serv6_addr);
+
+ return 0;
+
+ err:
+ if (sd6 != -1)
+ close(sd6);
+
+ return -1;
+}
+
+int setup_server_sockets(struct srv_sock_info ssi[])
+{
+ int i=0;
+
+ ssi[0].sd = ssi[1].sd = -1;
+ // Only enqueue sockets successfully bound or that weren't disabled.
+ if (tcsd_options.disable_ipv4) {
+ LogWarn("IPv4 support disabled by configuration option");
+ } else {
+ if (setup_ipv4_socket(&ssi[i]) == 0)
+ i++;
+ }
+
+ if (tcsd_options.disable_ipv6) {
+ LogWarn("IPv6 support disabled by configuration option");
+ } else {
+ setup_ipv6_socket(&ssi[i]);
+ }
+
+ // It's only a failure if both sockets are unavailable.
+ if ((ssi[0].sd == -1) && (ssi[1].sd == -1)) {
+ return -1;
+ }
+
+ return 0;
+}
+
+char *fetch_hostname(struct sockaddr_storage *client_addr, socklen_t socklen)
+{
+ char buf[NI_MAXHOST];
+
+ if (getnameinfo((struct sockaddr *)client_addr, socklen, buf,
+ sizeof(buf), NULL, 0, 0) != 0) {
+ LogWarn("Could not retrieve client address info");
+ return NULL;
+ } else {
+ return strdup(buf);
+ }
+}
+
+void prepare_for_select(struct srv_sock_info *socks_info, int *num_fds,
+ fd_set *rdfd_set, int *nfds)
+{
+ int i;
+
+ FD_ZERO(rdfd_set);
+ *num_fds = 0;
+ *nfds = 0;
+ // Filter out socket descriptors in the queue that
+ // has the -1 value.
+ for (i=0; i < MAX_IP_PROTO; i++) {
+ if (socks_info[i].sd == -1)
+ break;
+
+ FD_SET(socks_info[i].sd, rdfd_set);
+ (*num_fds)++;
+ if (*nfds < socks_info[i].sd) // grab highest sd for select call
+ *nfds = socks_info[i].sd;
+ }
+}
int
main(int argc, char **argv)
{
- struct sockaddr_in serv_addr, client_addr;
TSS_RESULT result;
- int newsd, c, option_index = 0;
- unsigned client_len;
+ int newsd, c, rv, option_index = 0;
+ int i;
+ socklen_t client_len;
char *hostname = NULL;
+ fd_set rdfd_set;
+ int num_fds = 0;
+ int nfds = 0;
+ int stor_errno;
+ sigset_t sigmask, termmask, oldsigmask;
+ struct sockaddr_storage client_addr;
+ struct srv_sock_info socks_info[MAX_IP_PROTO];
struct passwd *pwd;
- struct hostent *client_hostent = NULL;
struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"foreground", 0, NULL, 'f'},
@@ -256,29 +458,10 @@ main(int argc, char **argv)
if ((result = tcsd_startup()))
return (int)result;
- sd = socket(AF_INET, SOCK_STREAM, 0);
- if (sd < 0) {
- LogError("Failed socket: %s", strerror(errno));
- return -1;
- }
-
- memset(&serv_addr, 0, sizeof (serv_addr));
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_port = htons(tcsd_options.port);
-
- /* If no remote_ops are defined, restrict connections to localhost
- * only at the socket. */
- if (tcsd_options.remote_ops[0] == 0)
- serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- else
- serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
-
- c = 1;
- setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &c, sizeof(c));
- if (bind(sd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) < 0) {
- LogError("Failed bind: %s", strerror(errno));
- return -1;
- }
+#ifdef NOUSERCHECK
+ LogWarn("will not switch user or check for file permissions. "
+ "(Compiled with --disable-usercheck)");
+#else
#ifndef SOLARIS
pwd = getpwnam(TSS_USER_NAME);
if (pwd == NULL) {
@@ -292,64 +475,96 @@ main(int argc, char **argv)
}
setuid(pwd->pw_uid);
#endif
- if (listen(sd, TCSD_MAX_SOCKETS_QUEUED) < 0) {
- LogError("Failed listen: %s", strerror(errno));
+#endif
+
+ if (setup_server_sockets(socks_info) == -1) {
+ LogError("Could not create sockets to listen to connections. Aborting...");
return -1;
}
- client_len = (unsigned)sizeof(client_addr);
-
+
if (getenv("TCSD_FOREGROUND") == NULL) {
if (daemon(0, 0) == -1) {
perror("daemon");
- tcsd_shutdown();
+ tcsd_shutdown(socks_info);
return -1;
}
}
LogInfo("%s: TCSD up and running.", PACKAGE_STRING);
- do {
- newsd = accept(sd, (struct sockaddr *) &client_addr, &client_len);
- if (newsd < 0) {
- if (errno == EINTR) {
- if (term)
- break;
- else if (hup) {
- if (reload_config() != TSS_SUCCESS)
- LogError("Failed reloading config");
- }
- continue;
- } else {
- LogError("Failed accept: %s", strerror(errno));
- continue;
- }
- }
- LogDebug("accepted socket %i", newsd);
- if ((client_hostent = gethostbyaddr((char *) &client_addr.sin_addr,
- sizeof(client_addr.sin_addr),
- AF_INET)) == NULL) {
- char buf[16];
- uint32_t addr = htonl(client_addr.sin_addr.s_addr);
+ sigemptyset(&sigmask);
+ sigaddset(&sigmask, SIGTERM);
+ sigaddset(&sigmask, SIGHUP);
- snprintf(buf, 16, "%d.%d.%d.%d", (addr & 0xff000000) >> 24,
- (addr & 0x00ff0000) >> 16, (addr & 0x0000ff00) >> 8,
- addr & 0x000000ff);
+ sigemptyset(&termmask);
+ sigaddset(&termmask, SIGTERM);
- LogWarn("Host name for connecting IP %s could not be resolved", buf);
- hostname = strdup(buf);
- } else {
- hostname = strdup(client_hostent->h_name);
+ do {
+ prepare_for_select(socks_info, &num_fds, &rdfd_set, &nfds);
+ // Sanity check
+ if (num_fds == 0) {
+ LogError("No server sockets available to listen connections. Aborting...");
+ return -1;
}
- tcsd_thread_create(newsd, hostname);
- hostname = NULL;
+ // Block TERM and HUP signals to prevent race condition
+ if (sigprocmask(SIG_BLOCK, &sigmask, &oldsigmask) == -1) {
+ LogError("Error setting interrupt mask before accept");
+ }
+
+ // TERM and HUP are blocked here, so its safe to test flags.
if (hup) {
+ // Config reading can be slow, so unmask SIGTERM.
+ if (sigprocmask(SIG_UNBLOCK, &termmask, NULL) == -1) {
+ LogError("Error unblocking SIGTERM before config reload");
+ }
if (reload_config() != TSS_SUCCESS)
LogError("Failed reloading config");
+ if (sigprocmask(SIG_BLOCK, &termmask, NULL) == -1) {
+ LogError("Error blocking SIGTERM after config reload");
+ }
+ }
+ if (term)
+ break;
+
+ // Select IPv4 and IPv6 socket descriptors with appropriate sigmask.
+ LogDebug("Waiting for connections");
+ rv = pselect(nfds+1, &rdfd_set, NULL, NULL, NULL, &oldsigmask);
+ stor_errno = errno; // original mask must be set ASAP, so store errno.
+ if (sigprocmask(SIG_SETMASK, &oldsigmask, NULL) == -1) {
+ LogError("Error reseting signal mask to the original configuration.");
+ }
+ if (rv == -1) {
+ if (stor_errno != EINTR) {
+ LogError("Error monitoring server socket descriptors.");
+ return -1;
+ }
+ continue;
}
+
+ for (i=0; i < num_fds; i++) { // accept connections from all IP versions (with valid sd)
+ if (!FD_ISSET(socks_info[i].sd, &rdfd_set)) {
+ continue;
+ }
+ client_len = socks_info[i].addr_len;
+ newsd = accept(socks_info[i].sd, (struct sockaddr *) &client_addr, &client_len);
+ if (newsd < 0) {
+ if (errno != EINTR)
+ LogError("Failed accept: %s", strerror(errno));
+ continue;
+ }
+ LogDebug("accepted socket %i", newsd);
+
+ hostname = fetch_hostname(&client_addr, client_len);
+ if (hostname == NULL)
+ hostname=INVALID_ADDR_STR;
+
+ tcsd_thread_create(newsd, hostname);
+ hostname = NULL;
+ } // for (i=0; i < MAX_IP_PROTO; i++)
} while (term ==0);
/* To close correctly, we must receive a SIGTERM */
- tcsd_shutdown();
+ tcsd_shutdown(socks_info);
return 0;
}
diff --git a/crypto/external/cpl/trousers/dist/src/tcsd/tcsd_conf.c b/crypto/external/cpl/trousers/dist/src/tcsd/tcsd_conf.c
index d6ae150b8fc..49f78b037cc 100644
--- a/crypto/external/cpl/trousers/dist/src/tcsd/tcsd_conf.c
+++ b/crypto/external/cpl/trousers/dist/src/tcsd/tcsd_conf.c
@@ -51,6 +51,8 @@ struct tcsd_config_options options_list[] = {
{"enforce_exclusive_transport", opt_exclusive_transport},
{"host_platform_class", opt_host_platform_class},
{"all_platform_classes", opt_all_platform_classes},
+ {"disable_ipv4", opt_disable_ipv4},
+ {"disable_ipv6", opt_disable_ipv6},
{NULL, 0}
};
@@ -83,6 +85,8 @@ init_tcsd_config(struct tcsd_config *conf)
conf->exclusive_transport = 0;
conf->host_platform_class = NULL;
conf->all_platform_classes = NULL;
+ conf->disable_ipv4 = 0;
+ conf->disable_ipv6 = 0;
}
TSS_RESULT
@@ -107,6 +111,7 @@ platform_class_list_append(struct tcsd_config *conf, char *specName, TSS_BOOL is
new_class->classURI = malloc(new_class->classURISize);
if (new_class->classURI == NULL) {
LogError("malloc of %u bytes failed", new_class->classURISize);
+ free(new_class);
return TCSERR(TSS_E_OUTOFMEMORY);
}
memcpy(new_class->classURI, tcg_platform_specs[i].specURI,
@@ -161,6 +166,12 @@ config_set_defaults(struct tcsd_config *conf)
if (conf->unset & TCSD_OPTION_HOST_PLATFORM_CLASS)
platform_class_list_append(conf, "PC_12", TRUE);
+
+ if (conf->unset & TCSD_OPTION_DISABLE_IPV4)
+ conf->disable_ipv4 = TCSD_DEFAULT_DISABLE_IPV4;
+
+ if (conf->unset & TCSD_OPTION_DISABLE_IPV6)
+ conf->disable_ipv6 = TCSD_DEFAULT_DISABLE_IPV6;
}
int
@@ -626,6 +637,29 @@ read_conf_line(char *buf, int line_num, struct tcsd_config *conf)
}
}
break;
+ case opt_disable_ipv4:
+ tmp_int = atoi(arg);
+ if (tmp_int < 0 || tmp_int > 1) {
+ LogError("Config option \"disable_ipv4\" out of range."
+ " %s:%d: \"%d\"", tcsd_config_file, line_num, tmp_int);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else {
+ conf->disable_ipv4 = tmp_int;
+ conf->unset &= ~TCSD_OPTION_DISABLE_IPV4;
+ }
+
+ break;
+ case opt_disable_ipv6:
+ tmp_int = atoi(arg);
+ if (tmp_int < 0 || tmp_int > 1) {
+ LogError("Config option \"disable_ipv6\" out of range."
+ " %s:%d: \"%d\"", tcsd_config_file, line_num, tmp_int);
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ } else {
+ conf->disable_ipv6 = tmp_int;
+ conf->unset &= ~TCSD_OPTION_DISABLE_IPV6;
+ }
+ break;
default:
/* bail out on any unknown option */
LogError("Unknown config option %s:%d \"%s\"!", tcsd_config_file, line_num, arg);
@@ -736,6 +770,7 @@ conf_file_init(struct tcsd_config *conf)
}
}
+#ifndef NOUSERCHECK
#ifndef SOLARIS
/* find the gid that owns the conf file */
errno = 0;
@@ -775,6 +810,7 @@ conf_file_init(struct tcsd_config *conf)
return TCSERR(TSS_E_INTERNAL_ERROR);
}
#endif /* SOLARIS */
+#endif /* NOUSERCHECK */
if ((f = fopen(tcsd_config_file, "r")) == NULL) {
LogError("fopen(%s): %s", tcsd_config_file, strerror(errno));
diff --git a/crypto/external/cpl/trousers/dist/src/tcsd/tcsd_threads.c b/crypto/external/cpl/trousers/dist/src/tcsd/tcsd_threads.c
index b7a9371e4ce..e67a05f68e8 100644
--- a/crypto/external/cpl/trousers/dist/src/tcsd/tcsd_threads.c
+++ b/crypto/external/cpl/trousers/dist/src/tcsd/tcsd_threads.c
@@ -165,7 +165,8 @@ out:
/* cleanup in case of error */
if (rc != TCS_SUCCESS) {
if (hostname != NULL) {
- tm->thread_data[thread_num].hostname = NULL;
+ if (thread_num != -1)
+ tm->thread_data[thread_num].hostname = NULL;
free(hostname);
}
close(socket);
@@ -195,145 +196,13 @@ thread_signal_init()
THREAD_EXIT(NULL);
}
}
-#if 0
-void *
-tcsd_thread_run(void *v)
-{
- struct tcsd_thread_data *data = (struct tcsd_thread_data *)v;
- BYTE buffer[TCSD_TXBUF_SIZE];
- struct tcsd_packet_hdr *ret_buf = NULL;
- TSS_RESULT result;
- int sizeToSend, sent_total, sent;
- UINT64 offset;
-#ifndef TCSD_SINGLE_THREAD_DEBUG
- int rc;
-
- thread_signal_init();
-#endif
-
- if ((data->buf_size = recv(data->sock, buffer, TCSD_TXBUF_SIZE, 0)) < 0) {
- LogError("Failed Receive: %s", strerror(errno));
- goto done;
- }
- LogDebug("Rx'd packet");
-
- data->buf = buffer;
-
- while (1) {
- sent_total = 0;
- if (data->buf_size > TCSD_TXBUF_SIZE) {
- LogError("Packet received from socket %d was too large (%u bytes)",
- data->sock, data->buf_size);
- goto done;
- } else if (data->buf_size < (int)((2 * sizeof(UINT32)) + sizeof(UINT16))) {
- LogError("Packet received from socket %d was too small (%u bytes)",
- data->sock, data->buf_size);
- goto done;
- }
-
- if ((result = getTCSDPacket(data, &ret_buf)) != TSS_SUCCESS) {
- /* something internal to the TCSD went wrong in preparing the packet
- * to return to the TSP. Use our already allocated buffer to return a
- * TSS_E_INTERNAL_ERROR return code to the TSP. In the non-error path,
- * these LoadBlob's are done in getTCSDPacket().
- */
- offset = 0;
- /* load result */
- LoadBlob_UINT32(&offset, result, buffer);
- /* load packet size */
- LoadBlob_UINT32(&offset, sizeof(struct tcsd_packet_hdr), buffer);
- /* load num parms */
- LoadBlob_UINT16(&offset, 0, buffer);
-
- sizeToSend = sizeof(struct tcsd_packet_hdr);
- LogDebug("Sending 0x%X bytes back", sizeToSend);
-
- while (sent_total < sizeToSend) {
- if ((sent = send(data->sock,
- &data->buf[sent_total],
- sizeToSend - sent_total, 0)) < 0) {
- LogError("Packet send to TSP failed: send: %s. Thread exiting.",
- strerror(errno));
- goto done;
- }
- sent_total += sent;
- }
- } else {
- sizeToSend = Decode_UINT32((BYTE *)&(ret_buf->packet_size));
-
- LogDebug("Sending 0x%X bytes back", sizeToSend);
-
- while (sent_total < sizeToSend) {
- if ((sent = send(data->sock,
- &(((BYTE *)ret_buf)[sent_total]),
- sizeToSend - sent_total, 0)) < 0) {
- LogError("response to TSP failed: send: %s. Thread exiting.",
- strerror(errno));
- free(ret_buf);
- ret_buf = NULL;
- goto done;
- }
- sent_total += sent;
- }
- free(ret_buf);
- ret_buf = NULL;
- }
-
- if (tm->shutdown) {
- LogDebug("Thread %zd exiting via shutdown signal!", THREAD_ID);
- break;
- }
-
- /* receive the next packet */
- if ((data->buf_size = recv(data->sock, buffer, TCSD_TXBUF_SIZE, 0)) < 0) {
- LogError("TSP has closed its connection: %s. Thread exiting.",
- strerror(errno));
- break;
- } else if (data->buf_size == 0) {
- LogDebug("The TSP has closed the socket's connection. Thread exiting.");
- break;
- }
- }
-
-done:
- /* Closing connection to TSP */
- close(data->sock);
- data->sock = -1;
- data->buf = NULL;
- data->buf_size = -1;
- /* If the connection was not shut down cleanly, free TCS resources here */
- if (data->context != NULL_TCS_HANDLE) {
- TCS_CloseContext_Internal(data->context);
- data->context = NULL_TCS_HANDLE;
- }
-#ifndef TCSD_SINGLE_THREAD_DEBUG
- MUTEX_LOCK(tm->lock);
- tm->num_active_threads--;
- /* if we're not in shutdown mode, then nobody is waiting to join this thread, so
- * detach it so that its resources are free at THREAD_EXIT() time. */
- if (!tm->shutdown) {
- if ((rc = THREAD_DETACH(*(data->thread_id)))) {
- LogError("Thread detach failed (errno %d)."
- " Resources may not be properly released.", rc);
- }
- }
- free(data->hostname);
- data->hostname = NULL;
- data->thread_id = THREAD_NULL;
- MUTEX_UNLOCK(tm->lock);
- THREAD_EXIT(NULL);
-#else
- return NULL;
-#endif
-}
-#else
void *
tcsd_thread_run(void *v)
{
struct tcsd_thread_data *data = (struct tcsd_thread_data *)v;
BYTE *buffer;
- int recv_size, send_size;
+ int recd_so_far, empty_space, total_recv_size, recv_chunk_size, send_size;
TSS_RESULT result;
UINT64 offset;
#ifndef TCSD_SINGLE_THREAD_DEBUG
@@ -346,38 +215,73 @@ tcsd_thread_run(void *v)
data->comm.buf = calloc(1, data->comm.buf_size);
while (data->comm.buf) {
/* get the packet header to get the size of the incoming packet */
- buffer = data->comm.buf;
- recv_size = sizeof(struct tcsd_packet_hdr);
- if ((recv_size = recv_from_socket(data->sock, buffer, recv_size)) < 0)
+ if (recv_from_socket(data->sock, data->comm.buf,
+ sizeof(struct tcsd_packet_hdr)) < 0)
break;
- buffer += sizeof(struct tcsd_packet_hdr); /* increment the buffer pointer */
+
+ recd_so_far = sizeof(struct tcsd_packet_hdr);
/* check the packet size */
- recv_size = Decode_UINT32(data->comm.buf);
- if (recv_size < (int)sizeof(struct tcsd_packet_hdr)) {
+ total_recv_size = Decode_UINT32(data->comm.buf);
+ if (total_recv_size < (int)sizeof(struct tcsd_packet_hdr)) {
LogError("Packet to receive from socket %d is too small (%d bytes)",
- data->sock, recv_size);
+ data->sock, total_recv_size);
break;
}
- if (recv_size > data->comm.buf_size ) {
+ LogDebug("total_recv_size %d, buf_size %u, recd_so_far %d", total_recv_size,
+ data->comm.buf_size, recd_so_far);
+
+ empty_space = data->comm.buf_size - recd_so_far;
+
+ /* instead of blindly allocating recv_size bytes off the bat, stage the realloc
+ * and wait for the data to come in over the socket. This protects against
+ * trivially asking tcsd to alloc 2GB */
+ while (total_recv_size > (int) data->comm.buf_size) {
BYTE *new_buffer;
+ int new_bufsize;
+
+ if ((int)data->comm.buf_size + TCSD_INCR_TXBUF_SIZE < total_recv_size) {
+ new_bufsize = data->comm.buf_size + TCSD_INCR_TXBUF_SIZE;
+ recv_chunk_size = empty_space + TCSD_INCR_TXBUF_SIZE;
+ } else {
+ new_bufsize = total_recv_size;
+ recv_chunk_size = total_recv_size - recd_so_far;
+ }
- LogDebug("Increasing communication buffer to %d bytes.", recv_size);
- new_buffer = realloc(data->comm.buf, recv_size);
+ LogDebug("Increasing communication buffer to %d bytes.", new_bufsize);
+ new_buffer = realloc(data->comm.buf, new_bufsize);
if (new_buffer == NULL) {
- LogError("realloc of %d bytes failed.", recv_size);
- break;
+ LogError("realloc of %d bytes failed.", new_bufsize);
+ data->comm.buf = NULL;
+ goto no_mem_error;
}
- buffer = new_buffer + sizeof(struct tcsd_packet_hdr);
- data->comm.buf_size = recv_size;
+
+ data->comm.buf_size = new_bufsize;
data->comm.buf = new_buffer;
+ buffer = data->comm.buf + recd_so_far;
+
+ LogDebug("recv_chunk_size %d recd_so_far %d", recv_chunk_size, recd_so_far);
+ if (recv_from_socket(data->sock, buffer, recv_chunk_size) < 0) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto error;
+ }
+
+ recd_so_far += recv_chunk_size;
+ empty_space = 0;
}
- /* get the rest of the packet */
- recv_size -= sizeof(struct tcsd_packet_hdr); /* already received the header */
- if ((recv_size = recv_from_socket(data->sock, buffer, recv_size)) < 0)
- break;
+ if (recd_so_far < total_recv_size) {
+ buffer = data->comm.buf + recd_so_far;
+ recv_chunk_size = total_recv_size - recd_so_far;
+
+ LogDebug("recv_chunk_size %d recd_so_far %d", recv_chunk_size, recd_so_far);
+
+ if (recv_from_socket(data->sock, buffer, recv_chunk_size) < 0) {
+ result = TCSERR(TSS_E_INTERNAL_ERROR);
+ goto error;
+ }
+ }
LogDebug("Rx'd packet");
/* create a platform version of the tcsd header */
@@ -390,7 +294,9 @@ tcsd_thread_run(void *v)
UnloadBlob_UINT32(&offset, &data->comm.hdr.parm_size, data->comm.buf);
UnloadBlob_UINT32(&offset, &data->comm.hdr.parm_offset, data->comm.buf);
- if ((result = getTCSDPacket(data)) != TSS_SUCCESS) {
+ result = getTCSDPacket(data);
+error:
+ if (result) {
/* something internal to the TCSD went wrong in preparing the packet
* to return to the TSP. Use our already allocated buffer to return a
* TSS_E_INTERNAL_ERROR return code to the TSP. In the non-error path,
@@ -416,7 +322,7 @@ tcsd_thread_run(void *v)
break;
}
}
-
+no_mem_error:
LogDebug("Thread exiting.");
/* Closing connection to TSP */
@@ -453,5 +359,3 @@ tcsd_thread_run(void *v)
#endif
return NULL;
}
-
-#endif
diff --git a/crypto/external/cpl/trousers/dist/src/tspi/ps/tspps.c b/crypto/external/cpl/trousers/dist/src/tspi/ps/tspps.c
index 959ab1a07bd..acdec74135e 100644
--- a/crypto/external/cpl/trousers/dist/src/tspi/ps/tspps.c
+++ b/crypto/external/cpl/trousers/dist/src/tspi/ps/tspps.c
@@ -24,12 +24,14 @@
#include <netdb.h>
#if defined (HAVE_BYTEORDER_H)
#include <sys/byteorder.h>
-#elif defined(HTOLE_DEFINED)
-#ifdef __NetBSD__
-#include <sys/endian.h>
-#else
+#elif defined (HTOLE_DEFINED)
+
+#ifndef __APPLE__
#include <endian.h>
+#else
+#include "portable_endian.h"
#endif
+
#define LE_16 htole16
#define LE_32 htole32
#define LE_64 htole64
@@ -655,7 +657,7 @@ psfile_remove_key(int fd, TSS_UUID *uuid)
/* 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));
+ __tspi_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))) {
@@ -920,7 +922,7 @@ restart_search:
free(keyinfos);
return TSPERR(TSS_E_OUTOFMEMORY);
}
- memset(&keyinfos[j], 0, sizeof(TSS_KM_KEYINFO));
+ __tspi_memset(&keyinfos[j], 0, sizeof(TSS_KM_KEYINFO));
if ((result = copy_key_info(fd, &keyinfos[j], &cache_entries[i]))) {
free(cache_entries);
@@ -1010,7 +1012,7 @@ psfile_get_registered_keys2(int fd,
}
/* Here the key UUID is found and needs to be copied for the array*/
/* Initializes the keyinfos with 0's*/
- memset(&keyinfos[j], 0, sizeof(TSS_KM_KEYINFO2));
+ __tspi_memset(&keyinfos[j], 0, sizeof(TSS_KM_KEYINFO2));
if ((result = copy_key_info2(fd, &keyinfos[j], &cache_entries[i]))) {
free(cache_entries);
diff --git a/crypto/external/cpl/trousers/dist/tools/Makefile.am b/crypto/external/cpl/trousers/dist/tools/Makefile.am
deleted file mode 100644
index 41c87ba37de..00000000000
--- a/crypto/external/cpl/trousers/dist/tools/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-noinst_PROGRAMS=ps_inspect ps_convert
-
-ps_inspect_SOURCES=ps_inspect.c
-ps_inspect_LDADD=${top_builddir}/src/tspi/libtspi.la
-ps_inspect_CFLAGS=-I${top_srcdir}/src/include
-
-ps_convert_SOURCES=ps_convert.c
-ps_convert_LDADD=${top_builddir}/src/tspi/libtspi.la
-ps_convert_CFLAGS=-I${top_srcdir}/src/include
diff --git a/crypto/external/cpl/trousers/dist/tools/Makefile.in b/crypto/external/cpl/trousers/dist/tools/Makefile.in
deleted file mode 100644
index 628cec0ed33..00000000000
--- a/crypto/external/cpl/trousers/dist/tools/Makefile.in
+++ /dev/null
@@ -1,524 +0,0 @@
-# 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@
-noinst_PROGRAMS = ps_inspect$(EXEEXT) ps_convert$(EXEEXT)
-subdir = tools
-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 =
-PROGRAMS = $(noinst_PROGRAMS)
-am_ps_convert_OBJECTS = ps_convert-ps_convert.$(OBJEXT)
-ps_convert_OBJECTS = $(am_ps_convert_OBJECTS)
-ps_convert_DEPENDENCIES = ${top_builddir}/src/tspi/libtspi.la
-ps_convert_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(ps_convert_CFLAGS) \
- $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-am_ps_inspect_OBJECTS = ps_inspect-ps_inspect.$(OBJEXT)
-ps_inspect_OBJECTS = $(am_ps_inspect_OBJECTS)
-ps_inspect_DEPENDENCIES = ${top_builddir}/src/tspi/libtspi.la
-ps_inspect_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(ps_inspect_CFLAGS) \
- $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-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 = $(ps_convert_SOURCES) $(ps_inspect_SOURCES)
-DIST_SOURCES = $(ps_convert_SOURCES) $(ps_inspect_SOURCES)
-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@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CRYPTOLIB = @CRYPTOLIB@
-CRYPTO_PACKAGE = @CRYPTO_PACKAGE@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-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@
-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_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@
-lt_ECHO = @lt_ECHO@
-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@
-ps_inspect_SOURCES = ps_inspect.c
-ps_inspect_LDADD = ${top_builddir}/src/tspi/libtspi.la
-ps_inspect_CFLAGS = -I${top_srcdir}/src/include
-ps_convert_SOURCES = ps_convert.c
-ps_convert_LDADD = ${top_builddir}/src/tspi/libtspi.la
-ps_convert_CFLAGS = -I${top_srcdir}/src/include
-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 tools/Makefile'; \
- $(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --foreign tools/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-noinstPROGRAMS:
- @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
- echo " rm -f" $$list; \
- rm -f $$list || exit $$?; \
- test -n "$(EXEEXT)" || exit 0; \
- list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f" $$list; \
- rm -f $$list
-ps_convert$(EXEEXT): $(ps_convert_OBJECTS) $(ps_convert_DEPENDENCIES)
- @rm -f ps_convert$(EXEEXT)
- $(ps_convert_LINK) $(ps_convert_OBJECTS) $(ps_convert_LDADD) $(LIBS)
-ps_inspect$(EXEEXT): $(ps_inspect_OBJECTS) $(ps_inspect_DEPENDENCIES)
- @rm -f ps_inspect$(EXEEXT)
- $(ps_inspect_LINK) $(ps_inspect_OBJECTS) $(ps_inspect_LDADD) $(LIBS)
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT)
-
-distclean-compile:
- -rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ps_convert-ps_convert.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ps_inspect-ps_inspect.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 $@ $<
-
-ps_convert-ps_convert.o: ps_convert.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ps_convert_CFLAGS) $(CFLAGS) -MT ps_convert-ps_convert.o -MD -MP -MF $(DEPDIR)/ps_convert-ps_convert.Tpo -c -o ps_convert-ps_convert.o `test -f 'ps_convert.c' || echo '$(srcdir)/'`ps_convert.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ps_convert-ps_convert.Tpo $(DEPDIR)/ps_convert-ps_convert.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ps_convert.c' object='ps_convert-ps_convert.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) $(ps_convert_CFLAGS) $(CFLAGS) -c -o ps_convert-ps_convert.o `test -f 'ps_convert.c' || echo '$(srcdir)/'`ps_convert.c
-
-ps_convert-ps_convert.obj: ps_convert.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ps_convert_CFLAGS) $(CFLAGS) -MT ps_convert-ps_convert.obj -MD -MP -MF $(DEPDIR)/ps_convert-ps_convert.Tpo -c -o ps_convert-ps_convert.obj `if test -f 'ps_convert.c'; then $(CYGPATH_W) 'ps_convert.c'; else $(CYGPATH_W) '$(srcdir)/ps_convert.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ps_convert-ps_convert.Tpo $(DEPDIR)/ps_convert-ps_convert.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ps_convert.c' object='ps_convert-ps_convert.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) $(ps_convert_CFLAGS) $(CFLAGS) -c -o ps_convert-ps_convert.obj `if test -f 'ps_convert.c'; then $(CYGPATH_W) 'ps_convert.c'; else $(CYGPATH_W) '$(srcdir)/ps_convert.c'; fi`
-
-ps_inspect-ps_inspect.o: ps_inspect.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ps_inspect_CFLAGS) $(CFLAGS) -MT ps_inspect-ps_inspect.o -MD -MP -MF $(DEPDIR)/ps_inspect-ps_inspect.Tpo -c -o ps_inspect-ps_inspect.o `test -f 'ps_inspect.c' || echo '$(srcdir)/'`ps_inspect.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ps_inspect-ps_inspect.Tpo $(DEPDIR)/ps_inspect-ps_inspect.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ps_inspect.c' object='ps_inspect-ps_inspect.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) $(ps_inspect_CFLAGS) $(CFLAGS) -c -o ps_inspect-ps_inspect.o `test -f 'ps_inspect.c' || echo '$(srcdir)/'`ps_inspect.c
-
-ps_inspect-ps_inspect.obj: ps_inspect.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ps_inspect_CFLAGS) $(CFLAGS) -MT ps_inspect-ps_inspect.obj -MD -MP -MF $(DEPDIR)/ps_inspect-ps_inspect.Tpo -c -o ps_inspect-ps_inspect.obj `if test -f 'ps_inspect.c'; then $(CYGPATH_W) 'ps_inspect.c'; else $(CYGPATH_W) '$(srcdir)/ps_inspect.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ps_inspect-ps_inspect.Tpo $(DEPDIR)/ps_inspect-ps_inspect.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ps_inspect.c' object='ps_inspect-ps_inspect.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) $(ps_inspect_CFLAGS) $(CFLAGS) -c -o ps_inspect-ps_inspect.obj `if test -f 'ps_inspect.c'; then $(CYGPATH_W) 'ps_inspect.c'; else $(CYGPATH_W) '$(srcdir)/ps_inspect.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 $(PROGRAMS)
-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-noinstPROGRAMS \
- 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-noinstPROGRAMS 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/crypto/external/cpl/trousers/dist/tools/ps_convert.c b/crypto/external/cpl/trousers/dist/tools/ps_convert.c
deleted file mode 100644
index 2a2d85aa483..00000000000
--- a/crypto/external/cpl/trousers/dist/tools/ps_convert.c
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- *
- * Copyright (C) International Business Machines Corp., 2005
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 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 GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * ps_convert.c
- *
- * Convert a persistent storage file from one version to another.
- *
- * There are 2 different types of persistent storage files:
- *
- * A)
- *
- * [UINT32 num_keys_on_disk]
- * [TSS_UUID uuid0 ]
- * [TSS_UUID uuid_parent0 ]
- * [UINT16 pub_data_size0 ]
- * [UINT16 blob_size0 ]
- * [UINT16 cache_flags0 ]
- * [BYTE[] pub_data0 ]
- * [BYTE[] blob0 ]
- * [...]
- *
- * B)
- *
- * [BYTE TrouSerS PS version='1']
- * [UINT32 num_keys_on_disk ]
- * [TSS_UUID uuid0 ]
- * [TSS_UUID uuid_parent0 ]
- * [UINT16 pub_data_size0 ]
- * [UINT16 blob_size0 ]
- * [UINT32 vendor_data_size0 ]
- * [UINT16 cache_flags0 ]
- * [BYTE[] pub_data0 ]
- * [BYTE[] blob0 ]
- * [BYTE[] vendor_data0 ]
- * [...]
- *
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-
-#include <trousers/tss.h>
-
-#define PRINTERR(...) fprintf(stderr, ##__VA_ARGS__)
-#define PRINT(...) printf("PS " __VA_ARGS__)
-
-#define OUT(stream, buf, size) \
- do { \
- if (fwrite(buf, size, 1, stream) != 1) { \
- PRINTERR("fwrite error: %s\n", strerror(errno)); \
- return -1; \
- } \
- } while (0)
-
-/* one global buffer we read into from the PS file */
-unsigned char buf[1024];
-
-void
-usage(char *argv0)
-{
- PRINTERR("usage: %s filename\n"
- "\nBrings a persistent storage file up to date with the latest "
- "version of trousers.\nOutput will be to \"filename.new\".\n", argv0);
- exit(-1);
-}
-
-void
-print_hex(BYTE *buf, UINT32 len)
-{
- UINT32 i = 0, j;
-
- while (i < len) {
- for (j=0; (j < 4) && (i < len); j++, i+=4)
- printf("%02x%02x%02x%02x ",
- buf[i] & 0xff, buf[i+1] & 0xff,
- buf[i+2] & 0xff, buf[i+3] & 0xff);
- printf("\n");
- }
-}
-
-
-int
-convertkey_0(FILE *in, FILE *out)
-{
- UINT16 pub_data_size, blob_size, cache_flags;
- UINT32 vendor_data_size = 0;
- int members;
-
- /* output the key's UUID and parent UUID */
- OUT(out, buf, sizeof(TSS_UUID));
- OUT(out, &buf[sizeof(TSS_UUID)], sizeof(TSS_UUID));
-
- pub_data_size = *(UINT16 *)&buf[(2 * sizeof(TSS_UUID))];
- blob_size = *(UINT16 *)&buf[(2 * sizeof(TSS_UUID)) + sizeof(UINT16)];
- cache_flags = *(UINT16 *)&buf[2*sizeof(TSS_UUID) + 2*sizeof(UINT16)];
-
- OUT(out, &pub_data_size, sizeof(UINT16));
- OUT(out, &blob_size, sizeof(UINT16));
- OUT(out, &vendor_data_size, sizeof(UINT32));
- OUT(out, &cache_flags, sizeof(UINT16));
-
- /* trash buf, we've got what we needed from it */
- if ((members = fread(buf, pub_data_size + blob_size,
- 1, in)) != 1) {
- PRINTERR("fread: %s: %d members read\n", strerror(errno), members);
- return -1;
- }
-
- OUT(out, buf, pub_data_size);
- OUT(out, &buf[pub_data_size], blob_size);
-
- return 0;
-}
-
-int
-version_0_convert(FILE *in, FILE *out)
-{
- int rc, members = 0;
- UINT32 i;
- UINT32 *u32 = (UINT32 *) &buf;
-
- /* output the PS version */
- OUT(out, "\1", 1);
-
- /* number of keys */
- OUT(out, u32, sizeof(UINT32));
-
- /* The +- 1's below account for the byte we read in to determine
- * if the PS file had a version byte at the beginning */
-
- /* align the beginning of the buffer with the beginning of the key */
- memcpy(buf, &buf[4], sizeof(TSS_UUID) + 1);
-
- /* read in the rest of the first key's header */
- if ((members = fread(&buf[sizeof(TSS_UUID) + 1],
- sizeof(TSS_UUID) + (3 * sizeof(UINT16)) - 1,
- 1, in)) != 1) {
- PRINTERR("fread: %s\n", strerror(errno));
- return -1;
- }
-
- if (convertkey_0(in, out)) {
- PRINTERR("printkey_0 failed.\n");
- return -1;
- }
-
- for (i = 1; i < *u32; i++) {
- /* read in subsequent key's headers */
- if ((members = fread(buf, 2*sizeof(TSS_UUID) + 3*sizeof(UINT16),
- 1, in)) != 1) {
- PRINTERR("fread: %s\n", strerror(errno));
- return -1;
- }
-
- if ((rc = convertkey_0(in, out)))
- return rc;
- }
-
- return 0;
-}
-
-int
-inspect(char *filename, FILE *in)
-{
- int members = 0, rc, namelen;
- FILE *out = NULL;
- char outfile[256];
- UINT32 *num_keys;
- TSS_UUID SRK_UUID = TSS_UUID_SRK;
-
- /* do the initial read, which should include sizeof(TSS_UUID)
- * + sizeof(UINT32) + 1 bytes */
- if ((members = fread(buf,
- sizeof(TSS_UUID) + sizeof(UINT32) + 1,
- 1, in)) != 1) {
- PRINTERR("fread: %s\n", strerror(errno));
- return -1;
- }
-
- if (buf[0] == '\1') {
- num_keys = (UINT32 *)&buf[1];
- if (*num_keys == 0)
- goto version0;
-
- if (memcmp(&buf[5], &SRK_UUID, sizeof(TSS_UUID)))
- goto version0;
-
- printf("%s is already up to date.\n", filename);
-
- return -2;
- }
-
-version0:
- if (memcmp(&buf[4], &SRK_UUID, sizeof(TSS_UUID))) {
- printf("This file does not appear to be a valid PS file.\n");
- return -2;
- }
-
- printf("%s appears to be a version 0 PS file. Updating to version 1... ",
- filename);
-
- namelen = strlen(filename);
- memcpy(outfile, filename, namelen);
- memcpy(&outfile[namelen], ".new", 5);
-
- if ((out = fopen(outfile, "w+")) == NULL) {
- PRINTERR("fopen(%s, \"w+\"): %s\n", outfile, strerror(errno));
- return -1;
- }
-
- rc = version_0_convert(in, out);
-
- fclose(out);
-
- return rc;
-}
-
-int
-main(int argc, char ** argv)
-{
- FILE *in = NULL;
- int rc;
-
- if (argc != 2)
- usage(argv[0]);
-
- if ((in = fopen(argv[1], "r")) == NULL) {
- PRINTERR("fopen(%s, \"r\"): %s\n", argv[1], strerror(errno));
- return -1;
- }
-
- if ((rc = inspect(argv[1], in)) == 0) {
- printf("Success.\n");
- } else if (rc != -2) {
- printf("Failure.\n");
- }
-
- fclose(in);
-
- return rc;
-}
diff --git a/crypto/external/cpl/trousers/dist/tools/ps_inspect.c b/crypto/external/cpl/trousers/dist/tools/ps_inspect.c
deleted file mode 100644
index 3c2437c1f3a..00000000000
--- a/crypto/external/cpl/trousers/dist/tools/ps_inspect.c
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- *
- * Copyright (C) International Business Machines Corp., 2005
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 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 GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * ps_inspect.c
- *
- * Inspect a persistent storage file, printing information about it based
- * on best guesses.
- *
- * There are 2 different types of persistent storage files:
- *
- * A)
- *
- * [UINT32 num_keys_on_disk]
- * [TSS_UUID uuid0 ]
- * [TSS_UUID uuid_parent0 ]
- * [UINT16 pub_data_size0 ]
- * [UINT16 blob_size0 ]
- * [UINT16 cache_flags0 ]
- * [BYTE[] pub_data0 ]
- * [BYTE[] blob0 ]
- * [...]
- *
- * B)
- *
- * [BYTE TrouSerS PS version='1']
- * [UINT32 num_keys_on_disk ]
- * [TSS_UUID uuid0 ]
- * [TSS_UUID uuid_parent0 ]
- * [UINT16 pub_data_size0 ]
- * [UINT16 blob_size0 ]
- * [UINT32 vendor_data_size0 ]
- * [UINT16 cache_flags0 ]
- * [BYTE[] pub_data0 ]
- * [BYTE[] blob0 ]
- * [BYTE[] vendor_data0 ]
- * [...]
- *
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/unistd.h>
-
-#include <trousers/tss.h>
-
-#define PRINTERR(...) fprintf(stderr, ##__VA_ARGS__)
-#define PRINT(...) printf("PS " __VA_ARGS__)
-
-#if (defined (__FreeBSD__) || defined (__OpenBSD__))
-#define OFF_T_PRINTF "lld"
-#else
-#define OFF_T_PRINTF "ld"
-#endif
-
-/* one global buffer we read into from the PS file */
-unsigned char buf[1024];
-
-void
-usage(char *argv0)
-{
- PRINTERR("usage: %s filename\n", argv0);
- exit(-1);
-}
-
-void
-print_hex(BYTE *buf, UINT32 len)
-{
- UINT32 i, j;
-
- for (i=0, j=1; (i+4) < len; j++, i+=4) {
- printf("%02x%02x%02x%02x ",
- buf[i] & 0xff, buf[i+1] & 0xff,
- buf[i+2] & 0xff, buf[i+3] & 0xff);
- if (!(j % 4))
- printf("\n");
- }
-
- while (i < len)
- printf("%02x", buf[i++] & 0xff);
- printf("\n");
-}
-
-int
-printkey_0(int i, FILE *f)
-{
- UINT16 pub_data_size, blob_size, cache_flags;
- int members;
-
- PRINT("uuid%d: ", i);
- print_hex(buf, sizeof(TSS_UUID));
-
- PRINT("parent uuid%d: ", i);
- print_hex(&buf[sizeof(TSS_UUID)], sizeof(TSS_UUID));
-
- pub_data_size = *(UINT16 *)&buf[(2 * sizeof(TSS_UUID))];
- blob_size = *(UINT16 *)&buf[(2 * sizeof(TSS_UUID)) + sizeof(UINT16)];
- cache_flags = *(UINT16 *)&buf[2*sizeof(TSS_UUID) + 2*sizeof(UINT16)];
-
- PRINT("pub_data_size%d: %hu\n", i, pub_data_size);
- PRINT("blob_size%d: %hu\n", i, blob_size);
- PRINT("cache_flags%d: %02hx\n", i, cache_flags);
-
- /* trash buf, we've got what we needed from it */
- if ((members = fread(buf, pub_data_size + blob_size,
- 1, f)) != 1) {
- PRINTERR("fread: %s: %d members read\n", strerror(errno), members);
- return -1;
- }
-
- PRINT("pub_data%d:\n", i);
- print_hex(buf, pub_data_size);
-
- PRINT("blob%d:\n", i);
- print_hex(&buf[pub_data_size], blob_size);
-
- return 0;
-}
-
-int
-printkey_1(int i, FILE *f)
-{
- UINT16 pub_data_size, blob_size, cache_flags;
- UINT32 vendor_data_size;
- int members;
-
- PRINT("uuid%d: ", i);
- print_hex(buf, sizeof(TSS_UUID));
-
- PRINT("parent uuid%d: ", i);
- print_hex(&buf[sizeof(TSS_UUID)], sizeof(TSS_UUID));
-
- pub_data_size = *(UINT16 *)&buf[(2 * sizeof(TSS_UUID))];
- blob_size = *(UINT16 *)&buf[(2 * sizeof(TSS_UUID)) + sizeof(UINT16)];
- vendor_data_size = *(UINT32 *)&buf[(2 * sizeof(TSS_UUID)) + 2*sizeof(UINT16)];
- cache_flags = *(UINT16 *)&buf[2*sizeof(TSS_UUID) + sizeof(UINT16) + sizeof(UINT32)];
-
- PRINT("pub_data_size%d: %hu\n", i, pub_data_size);
- PRINT("blob_size%d: %hu\n", i, blob_size);
- PRINT("vendor_data_size%d: %u\n", i, vendor_data_size);
- PRINT("cache_flags%d: %02hx\n", i, cache_flags);
-
- /* trash buf, we've got what we needed from it */
- if ((members = fread(buf, pub_data_size + blob_size + vendor_data_size,
- 1, f)) != 1) {
- PRINTERR("fread: %s: %d members read\n", strerror(errno), members);
- return -1;
- }
-
- PRINT("pub_data%d:\n", i);
- print_hex(buf, pub_data_size);
-
- PRINT("blob%d:\n", i);
- print_hex(&buf[pub_data_size], blob_size);
-
- PRINT("vendor_data%d:\n", i);
- if (vendor_data_size > 0)
- print_hex(&buf[pub_data_size + blob_size], vendor_data_size);
-
- return 0;
-}
-
-int
-version_0_print(FILE *f)
-{
- int rc, members = 0;
- UINT32 i;
- UINT32 *u32 = (UINT32 *) &buf;
-
- PRINT("version: 0\n");
- PRINT("number of keys: %u\n", *u32);
-
- /* The +- 1's below account for the byte we read in to determine
- * if the PS file had a version byte at the beginning */
-
- /* align the beginning of the buffer with the beginning of the key */
- memcpy(buf, &buf[4], sizeof(TSS_UUID) + 1);
-
- /* read in the rest of the first key's header */
- if ((members = fread(&buf[sizeof(TSS_UUID) + 1],
- sizeof(TSS_UUID) + (3 * sizeof(UINT16)) - 1,
- 1, f)) != 1) {
- PRINTERR("fread: %s\n", strerror(errno));
- return -1;
- }
-
- if (printkey_0(0, f)) {
- PRINTERR("printkey_0 failed.\n");
- return -1;
- }
-
- for (i = 1; i < *u32; i++) {
- /* read in subsequent key's headers */
- if ((members = fread(buf, 2*sizeof(TSS_UUID) + 3*sizeof(UINT16),
- 1, f)) != 1) {
- PRINTERR("fread: %s\n", strerror(errno));
- return -1;
- }
-
- if ((rc = printkey_0(i, f)))
- return rc;
- }
-
- return 0;
-}
-
-int
-version_1_print(FILE *f)
-{
- int rc, members = 0;
- UINT32 i, u32 = *(UINT32 *)&buf[1];
-
- PRINT("version: 1\n");
- PRINT("number of keys: %u\n", u32);
-
- /* align the beginning of the buffer with the beginning of the key */
- memcpy(buf, &buf[5], sizeof(TSS_UUID));
-
- /* read in the rest of the first key's header */
- if ((members = fread(&buf[sizeof(TSS_UUID)],
- sizeof(TSS_UUID) + (3 * sizeof(UINT16)) + sizeof(UINT32),
- 1, f)) != 1) {
- PRINTERR("fread: %s\n", strerror(errno));
- return -1;
- }
-
- if (printkey_1(0, f)) {
- PRINTERR("printkey_1 failed.\n");
- return -1;
- }
-
- for (i = 1; i < u32; i++) {
- /* read in subsequent key's headers */
- if ((members = fread(buf, 2*sizeof(TSS_UUID) + 3*sizeof(UINT16)
- + sizeof(UINT32), 1, f)) != 1) {
- PRINTERR("fread: %s\n", strerror(errno));
- return -1;
- }
-
- if ((rc = printkey_1(i, f)))
- return rc;
- }
-
- return 0;
-}
-
-/* the smallest key on disk should be around 360 bytes total
- * and the largest should be about 560 bytes, so if the number
- * of keys is not in this ballpark, this is probably not a PS
- * file
- */
-int
-bad_file_size(UINT32 num_keys, off_t file_size)
-{
- if ((num_keys * 360) > (unsigned long)file_size)
- return 1;
-
- if ((num_keys * 560) < (unsigned long)file_size)
- return 1;
-
- return 0;
-}
-
-int
-inspect(FILE *f, off_t file_size)
-{
- int members = 0;
- UINT32 *num_keys;
-
- /* do the initial read, which should include sizeof(TSS_UUID)
- * + sizeof(UINT32) + 1 bytes */
- if ((members = fread(buf,
- sizeof(TSS_UUID) + sizeof(UINT32) + 1,
- 1, f)) != 1) {
- printf("File is empty.\n");
- return -1;
- }
-
- if (buf[0] == '\1') {
- num_keys = (UINT32 *)&buf[1];
- if (*num_keys == 0 || bad_file_size(*num_keys, file_size))
- goto version0;
-
- return version_1_print(f);
- }
-
-version0:
- num_keys = (UINT32 *)&buf[0];
- if (*num_keys == 0 || bad_file_size(*num_keys, file_size)) {
- printf("This file does not appear to be a valid PS file.\n");
- return -1;
- }
-
- return version_0_print(f);
-}
-
-int
-main(int argc, char ** argv)
-{
- FILE *f = NULL;
- int rc;
- struct stat stat_buf;
- off_t file_size;
-
- if (argc != 2)
- usage(argv[0]);
-
- if ((f = fopen(argv[1], "r")) == NULL) {
- PRINTERR("fopen(%s): %s\n", argv[1], strerror(errno));
- return -1;
- }
-
- if ((rc = fstat(fileno(f), &stat_buf))) {
- PRINTERR("fstat(%s): %s\n", argv[1], strerror(errno));
- fclose(f);
- return -1;
- }
-
- file_size = stat_buf.st_size;
-
- PRINT("filename: %s (%lld bytes)\n", argv[1], (long long) file_size);
-
- rc = inspect(f, file_size);
-
- fclose(f);
-
- return rc;
-}