diff --git a/configure.in b/configure.in
index d77b97c..04e1356 100644
--- a/configure.in
+++ b/configure.in
@@ -70,6 +70,18 @@ AC_CHECK_LIB([crypto], [EVP_DigestUpdate],
 AC_SUBST([CRYPTO_PACKAGE])
 AC_SUBST(CRYPTOLIB, -lcrypto)
 
+AM_CONDITIONAL(OS_WIN32, false)
+
+case ${host_os} in
+	*mingw32*)
+		AC_LIBTOOL_WIN32_DLL
+		AC_SUBST(EXTRATCSLIB, "-lws2_32 -ltbs")
+		AC_SUBST(EXTRATSPLIB, "-lws2_32 -luserenv -liconv")
+		AM_CONDITIONAL(OS_WIN32, true)
+		CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO=1"
+		;;
+esac
+
 AC_ARG_ENABLE(gcov,
 		[AC_HELP_STRING([--enable-gcov], [turn on gcov code coverage flags [default=off]])],
 		[CFLAGS="$CFLAGS -ftest-coverage -fprofile-arcs"
@@ -385,6 +397,7 @@ AC_OUTPUT(dist/tcsd.conf \
 	  Makefile \
 	  src/Makefile \
 	  src/include/Makefile \
+	  src/win32/Makefile \
 	  src/tcs/Makefile \
 	  src/tddl/Makefile \
 	  src/tspi/Makefile \
diff --git a/man/man3/Tspi_ChangeAuth.3 b/man/man3/Tspi_ChangeAuth.3
index 6a9b9f6..4940e6f 100644
--- a/man/man3/Tspi_ChangeAuth.3
+++ b/man/man3/Tspi_ChangeAuth.3
@@ -1,75 +1,75 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_Change_Auth" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_ChangeAuth \- change the authorization data of an entity.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_ChangeAuth(TSS_HOBJECT " hObjectToChange ", TSS_HOBJECT " hParentObject ","
-.BI "                           TSS_HPOLICY " hNewPolicy " );"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_ChangeAuth \fR changes the authorization data (secret) of an entity (object) and assigns the object to the policy object. All classes using secrets provide this method for changing their authorization data.
-.SH "PARAMETERS"
-.PP
-.SS hObjectToChange
-Handle of the object to change authorization for.
-.PP
-.SS hParentObject
-Handle of the parent object wrapping the object addressed by hObjectToChange.
-.PP
-.SS hNewPolicy
-Handle of the policy object providing the new authorization data.
-.SH "RETURN CODES"
-.PP
-\fBTspi_ChangeAuth\fR returns TSS_SUCCESS on success,otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - Either \fIhObjectToChange\fR, or \fIhParentObject\fR are not a valid handle.
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_ChangeAuth\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_ChangeAuthAsym\fR(3).
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_Change_Auth" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_ChangeAuth \- change the authorization data of an entity.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_ChangeAuth(TSS_HOBJECT " hObjectToChange ", TSS_HOBJECT " hParentObject ","
+.BI "                           TSS_HPOLICY " hNewPolicy " );"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_ChangeAuth \fR changes the authorization data (secret) of an entity (object) and assigns the object to the policy object. All classes using secrets provide this method for changing their authorization data.
+.SH "PARAMETERS"
+.PP
+.SS hObjectToChange
+Handle of the object to change authorization for.
+.PP
+.SS hParentObject
+Handle of the parent object wrapping the object addressed by hObjectToChange.
+.PP
+.SS hNewPolicy
+Handle of the policy object providing the new authorization data.
+.SH "RETURN CODES"
+.PP
+\fBTspi_ChangeAuth\fR returns TSS_SUCCESS on success,otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - Either \fIhObjectToChange\fR, or \fIhParentObject\fR are not a valid handle.
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_ChangeAuth\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_ChangeAuthAsym\fR(3).
+
+
+
diff --git a/man/man3/Tspi_ChangeAuthAsym.3 b/man/man3/Tspi_ChangeAuthAsym.3
index 4672601..43bc63f 100644
--- a/man/man3/Tspi_ChangeAuthAsym.3
+++ b/man/man3/Tspi_ChangeAuthAsym.3
@@ -1,76 +1,76 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_ChangeAuthAsym" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_ChangeAuthAsym \- change the authorization data of an entity using asymmetric change protocol.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_ChangeAuthAsym(TSS_HOBJECT " hObjectToChange ", TSS_HOBJECT " hParentObject ","
-.BI "                               TSS_HKEY    " hIdentKey ",       TSS_HPOLICY " hNewPolicy ");"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_ChangeAuthAsym\fR  changes the authorization data (secret) of an entity (object) utilizing the asymmetric change protocol and assigns the object to the policy object. All classes using secrets provide this method for changing their authorization data.
-This method changes the authorization data of an object ensuring that the parent of the object does not get knowledge of the new secret.
-.SH "PARAMETERS"
-.PP
-.SS hObjectToChange
-Handle of the object the authorization data should be changed.
-.PP
-.SS hParentObject
-Handle of the parent object wrapping the object addressed by \fIhObjectToChange\fR.
-.PP
-.SS hIdentKey
-Handle of the identity key object required to proof the internally created temporary key.
-.PP
-.SS hNewPolicy
-Handle of the policy object providing the new authorization data.
-.SH "RETURN CODES"
-.PP
-\fBTspi_ChangeAuthAsym\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - Either \fIhObjectToChange\fR, \fIhParentObject\fR, or \fIhIdentKey\fR is an invalid handle.
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_ChangeAuthAsym\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_ChangeAuth\fR(3).
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_ChangeAuthAsym" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_ChangeAuthAsym \- change the authorization data of an entity using asymmetric change protocol.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_ChangeAuthAsym(TSS_HOBJECT " hObjectToChange ", TSS_HOBJECT " hParentObject ","
+.BI "                               TSS_HKEY    " hIdentKey ",       TSS_HPOLICY " hNewPolicy ");"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_ChangeAuthAsym\fR  changes the authorization data (secret) of an entity (object) utilizing the asymmetric change protocol and assigns the object to the policy object. All classes using secrets provide this method for changing their authorization data.
+This method changes the authorization data of an object ensuring that the parent of the object does not get knowledge of the new secret.
+.SH "PARAMETERS"
+.PP
+.SS hObjectToChange
+Handle of the object the authorization data should be changed.
+.PP
+.SS hParentObject
+Handle of the parent object wrapping the object addressed by \fIhObjectToChange\fR.
+.PP
+.SS hIdentKey
+Handle of the identity key object required to proof the internally created temporary key.
+.PP
+.SS hNewPolicy
+Handle of the policy object providing the new authorization data.
+.SH "RETURN CODES"
+.PP
+\fBTspi_ChangeAuthAsym\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - Either \fIhObjectToChange\fR, \fIhParentObject\fR, or \fIhIdentKey\fR is an invalid handle.
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_ChangeAuthAsym\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_ChangeAuth\fR(3).
diff --git a/man/man3/Tspi_Context_Close.3 b/man/man3/Tspi_Context_Close.3
index c8c7da4..7cab7a2 100644
--- a/man/man3/Tspi_Context_Close.3
+++ b/man/man3/Tspi_Context_Close.3
@@ -1,68 +1,68 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_Context_Close" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_Context_Close \- destroy a TSP context handle.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_Context_Close(TSS_HCONTEXT " hLocalContext ");"
-.fi
-.sp
-.ad
-.hy
-.SH "DESCRIPTION"
-.PP
-\fBTspi_Context_Close\fR destroys a context by passing in the handle to that context.
-.SH "PARAMETERS"
-.PP
-.SS hLocalContext
-The handle to the context to be closed.
-
-.SH "RETURN CODES"
-.PP
-\fBTspi_Context_Close\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - \fIhLocalContext\fR is an invalid handle.
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_Context_Close\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_Context_Create\fR(3), \fBTspi_Context_Connect\fR(3).
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_Context_Close" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_Context_Close \- destroy a TSP context handle.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_Context_Close(TSS_HCONTEXT " hLocalContext ");"
+.fi
+.sp
+.ad
+.hy
+.SH "DESCRIPTION"
+.PP
+\fBTspi_Context_Close\fR destroys a context by passing in the handle to that context.
+.SH "PARAMETERS"
+.PP
+.SS hLocalContext
+The handle to the context to be closed.
+
+.SH "RETURN CODES"
+.PP
+\fBTspi_Context_Close\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - \fIhLocalContext\fR is an invalid handle.
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_Context_Close\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_Context_Create\fR(3), \fBTspi_Context_Connect\fR(3).
+
+
+
diff --git a/man/man3/Tspi_Context_CloseObject.3 b/man/man3/Tspi_Context_CloseObject.3
index eabf74e..4be1d75 100644
--- a/man/man3/Tspi_Context_CloseObject.3
+++ b/man/man3/Tspi_Context_CloseObject.3
@@ -1,69 +1,69 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_Context_CloseObject" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_Context_CloseObject \- destroy resources associated with an object handle.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI " TSS_RESULT Tspi_Context_CloseObject(TSS_HCONTEXT " hContext ", TSS_HOBJECT " hObject ");"
-.fi
-.sp
-.ad
-.hy
-.SH "DESCRIPTION"
-.PP
-\fBTSS_Context_CloseObject\fR destroys the object associated with the object handle. All allocated resources associated within the object are also released.
-.SH "PARAMETERS"
-.PP
-.SS hContext
-The handle of the context object.
-.PP
-.SS hObject
-The handle of the object to be destroyed.
-.SH "RETURN CODES"
-.PP
-\fBTspi_Context_CloseObject\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - Either \fIhContext\fR or \fIhObject\fR are invalid handles.
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_Context_CloseObject\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_Context_CreateObject\fR(3).
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_Context_CloseObject" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_Context_CloseObject \- destroy resources associated with an object handle.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI " TSS_RESULT Tspi_Context_CloseObject(TSS_HCONTEXT " hContext ", TSS_HOBJECT " hObject ");"
+.fi
+.sp
+.ad
+.hy
+.SH "DESCRIPTION"
+.PP
+\fBTSS_Context_CloseObject\fR destroys the object associated with the object handle. All allocated resources associated within the object are also released.
+.SH "PARAMETERS"
+.PP
+.SS hContext
+The handle of the context object.
+.PP
+.SS hObject
+The handle of the object to be destroyed.
+.SH "RETURN CODES"
+.PP
+\fBTspi_Context_CloseObject\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - Either \fIhContext\fR or \fIhObject\fR are invalid handles.
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_Context_CloseObject\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_Context_CreateObject\fR(3).
+
+
+
diff --git a/man/man3/Tspi_Context_Connect.3 b/man/man3/Tspi_Context_Connect.3
index f92bc2f..e793646 100644
--- a/man/man3/Tspi_Context_Connect.3
+++ b/man/man3/Tspi_Context_Connect.3
@@ -1,69 +1,69 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_Context_Connect" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME.
-Tspi_Context_Connect\- connect a TSP to a Core Services daemon
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_Context_Connect(TSS_HCONTEXT " hLocalContext ", UNICODE* " wszDestination ");"
-.fi
-.sp
-.ad
-.hy
-.SH "DESCRIPTION"
-.PP
-\fBTspi_Context_Connect\fR creates a connetion between the application and the local or remote TSS System.
-.SH "PARAMETERS"
-.PP
-.SS hLocalContext
-The handle to the context to be connected.
-.PP
-.SS wszDestination
-A null terminated unicode string which specifies  the local or remote system to which one will be connected. If \fIwszDestination\fR is NULL, the connection will be to a local TCS.
-
-.SH "RETURN CODES"
-.PP
-\fBTspi_Context_Connect\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - \fIhLocalContext\fR is an invalid handle.
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_Context_Connect\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_Context_Create\fR(3), \fBTspi_Context_Close\fR(3).
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_Context_Connect" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME.
+Tspi_Context_Connect\- connect a TSP to a Core Services daemon
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_Context_Connect(TSS_HCONTEXT " hLocalContext ", UNICODE* " wszDestination ");"
+.fi
+.sp
+.ad
+.hy
+.SH "DESCRIPTION"
+.PP
+\fBTspi_Context_Connect\fR creates a connetion between the application and the local or remote TSS System.
+.SH "PARAMETERS"
+.PP
+.SS hLocalContext
+The handle to the context to be connected.
+.PP
+.SS wszDestination
+A null terminated unicode string which specifies  the local or remote system to which one will be connected. If \fIwszDestination\fR is NULL, the connection will be to a local TCS.
+
+.SH "RETURN CODES"
+.PP
+\fBTspi_Context_Connect\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - \fIhLocalContext\fR is an invalid handle.
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_Context_Connect\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_Context_Create\fR(3), \fBTspi_Context_Close\fR(3).
+
+
diff --git a/man/man3/Tspi_Context_Create.3 b/man/man3/Tspi_Context_Create.3
index 1a7cd48..1c7abc2 100644
--- a/man/man3/Tspi_Context_Create.3
+++ b/man/man3/Tspi_Context_Create.3
@@ -1,66 +1,66 @@
-.\" Copyright (C) 2005 International Business Machines Corporation
-.\" Written by Kent Yoder based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_Context_Create" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_Context_Create \- create a TSP context handle.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_Context_Create(TSS_HCONTEXT* " phContext ");"
-.fi
-.sp
-.ad
-.hy
-.SH "DESCRIPTION"
-.PP
-\fBTspi_Context_Create\fR creates a handle to a new context object. The context is then used by other API functions to track resources related to it.
-.SH "PARAMETERS"
-.PP
-.SS phContext
-Receives the handle to the created context object.
-
-.SH "RETURN CODES"
-.PP
-\fBTspi_Context_Create\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INTERNAL_ERROR - An internal error occurred in the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_Context_Create\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_Context_Close\fR(3), \fBTspi_Context_Connect\fR(3).
-
-
-
+.\" Copyright (C) 2005 International Business Machines Corporation
+.\" Written by Kent Yoder based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_Context_Create" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_Context_Create \- create a TSP context handle.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_Context_Create(TSS_HCONTEXT* " phContext ");"
+.fi
+.sp
+.ad
+.hy
+.SH "DESCRIPTION"
+.PP
+\fBTspi_Context_Create\fR creates a handle to a new context object. The context is then used by other API functions to track resources related to it.
+.SH "PARAMETERS"
+.PP
+.SS phContext
+Receives the handle to the created context object.
+
+.SH "RETURN CODES"
+.PP
+\fBTspi_Context_Create\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INTERNAL_ERROR - An internal error occurred in the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_Context_Create\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_Context_Close\fR(3), \fBTspi_Context_Connect\fR(3).
+
+
+
diff --git a/man/man3/Tspi_Context_CreateObject.3 b/man/man3/Tspi_Context_CreateObject.3
index 1438629..284f933 100644
--- a/man/man3/Tspi_Context_CreateObject.3
+++ b/man/man3/Tspi_Context_CreateObject.3
@@ -1,125 +1,125 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_Context_CreateObject" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_Context_CreateObject \- create an empty object and return a handle to that object.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_Context_CreateObject(TSS_HCONTEXT " hContext ",  TSS_FLAG     " objectType ","
-.BI "                                     TSS_FLAG     " initFlags ", TSS_HOBJECT* " phObject ");"
-.fi
-.sp
-.ad
-.hy
-.SH "DESCRIPTION"
-.PP
-\fBTSS_Context_CreateObject\fR creates and initializes an empty object of the specified type and returns a handle addressing that object. The object is bound to an already opened context \fIhContext\fR.
-.SH "PARAMETERS"
-.PP
-.SS hContext
-The handle of the context object.
-.PP
-.SS objectType
-Flag indicating the object type to create. Possible types are:
-.TP
-.SM TSS_OBJECT_TYPE_POLICY - a policy object.
-.TP
-.SM TSS_OBJECT_TYPE_ENCDATA - an encrypted data object (either sealed or bound data).
-.TP
-.SM TSS_OBJECT_TYPE_RSAKEY - an RSA key.
-.TP
-.SM TSS_OBJECT_TYPE_PCRS - a PCR composite object.
-.TP
-.SM TSS_OBJECT_TYPE_HASH - a hash object.
-.PP
-.SS initFlags
-Flag indicating the default attributes of the object. Attributes for each type of object are:
-.TP
-.SM Policy:
- \fBTSS_POLICY_USAGE\fR - a usage policy (for authorization to use an object).
- \fBTSS_POLICY_MIGRATION\fR - a migration policy.
-.TP
-.SM Encrypted data objects:
- \fBTSS_ENCDATA_SEAL\fR - A data object used for a Seal operation.
- \fBTSS_ENCDATA_BIND\fR - A data object used for a Bind operation.
- \fBTSS_ENCDATA_LEGACY\fR - A data object for a bind operation using a legacy key.
-.TP
-.SM RSA Keys:
- \fBTSS_KEY_SIZE_DEFAULT\fR - Use the default key size of the TCS you're connected to.
- \fBTSS_KEY_SIZE_512\fR - Create a 512 bit key.
- \fBTSS_KEY_SIZE_1024\fR - Create a 1024 bit key.
- \fBTSS_KEY_SIZE_2048\fR - Create a 2048 bit key.
- \fBTSS_KEY_SIZE_4096\fR - Create a 4096 bit key.
- \fBTSS_KEY_SIZE_8192\fR - Create a 8192 bit key.
- \fBTSS_KEY_SIZE_16384\fR - Create a 16384 bit key.
- \fBTSS_KEY_TYPE_STORAGE\fR - Create a storage key. (Used to wrap other keys).
- \fBTSS_KEY_TYPE_SIGNING\fR - Create a signing key.
- \fBTSS_KEY_TYPE_BIND\fR - Create a binding key. (Used to encrypt data).
- \fBTSS_KEY_TYPE_IDENTITY\fR - Create an identity key. (Used for an identity).
- \fBTSS_KEY_TYPE_LEGACY\fR - Create a legacy key. (Can be used for signing and binding, created from data external to a TSS).
- \fBTSS_KEY_TYPE_AUTHCHANGE\fR - Create an ephemeral key used to change authorization values.
- \fBTSS_KEY_VOLATILE\fR - Create a volatile key. (Must be unloaded at startup).
- \fBTSS_KEY_NON_VOLATILE\fR - Create a non-volatile key. (May be unloaded at startup).
- \fBTSS_KEY_MIGRATABLE\fR - Create a migratable key.
- \fBTSS_KEY_NOT_MIGRATABLE\fR - Create a non-migratable key. [DEFAULT]
- \fBTSS_KEY_AUTHORIZATION\fR - Key will require authorization.
- \fBTSS_KEY_NO_AUTHORIZATION\fR - Key will not require authorization. [DEFAULT]
- \fBTSS_KEY_EMPTY_KEY\fR - Key template which will be returned as an object with very few attributes.
-
-.TP
-.SM PCR composite objects:
- None.
-.TP
-.SM Hash objects:
- \fBTSS_HASH_SHA1\fR - a hash object of type SHA-1.
- \fBTSS_HASH_OTHER\fR - a hash object of type other than SHA-1.
-.PP
-.PP
-.SS phObject
-The handle of the object to be created.
-
-.SH "RETURN CODES"
-.PP
-\fBTspi_Context_CreateObject\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - Either \fIhContext\fR or \fIphObject\fR is an invalid handle. 
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_Context_CreateObject\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_Context_CloseObject\fR(3).
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_Context_CreateObject" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_Context_CreateObject \- create an empty object and return a handle to that object.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_Context_CreateObject(TSS_HCONTEXT " hContext ",  TSS_FLAG     " objectType ","
+.BI "                                     TSS_FLAG     " initFlags ", TSS_HOBJECT* " phObject ");"
+.fi
+.sp
+.ad
+.hy
+.SH "DESCRIPTION"
+.PP
+\fBTSS_Context_CreateObject\fR creates and initializes an empty object of the specified type and returns a handle addressing that object. The object is bound to an already opened context \fIhContext\fR.
+.SH "PARAMETERS"
+.PP
+.SS hContext
+The handle of the context object.
+.PP
+.SS objectType
+Flag indicating the object type to create. Possible types are:
+.TP
+.SM TSS_OBJECT_TYPE_POLICY - a policy object.
+.TP
+.SM TSS_OBJECT_TYPE_ENCDATA - an encrypted data object (either sealed or bound data).
+.TP
+.SM TSS_OBJECT_TYPE_RSAKEY - an RSA key.
+.TP
+.SM TSS_OBJECT_TYPE_PCRS - a PCR composite object.
+.TP
+.SM TSS_OBJECT_TYPE_HASH - a hash object.
+.PP
+.SS initFlags
+Flag indicating the default attributes of the object. Attributes for each type of object are:
+.TP
+.SM Policy:
+ \fBTSS_POLICY_USAGE\fR - a usage policy (for authorization to use an object).
+ \fBTSS_POLICY_MIGRATION\fR - a migration policy.
+.TP
+.SM Encrypted data objects:
+ \fBTSS_ENCDATA_SEAL\fR - A data object used for a Seal operation.
+ \fBTSS_ENCDATA_BIND\fR - A data object used for a Bind operation.
+ \fBTSS_ENCDATA_LEGACY\fR - A data object for a bind operation using a legacy key.
+.TP
+.SM RSA Keys:
+ \fBTSS_KEY_SIZE_DEFAULT\fR - Use the default key size of the TCS you're connected to.
+ \fBTSS_KEY_SIZE_512\fR - Create a 512 bit key.
+ \fBTSS_KEY_SIZE_1024\fR - Create a 1024 bit key.
+ \fBTSS_KEY_SIZE_2048\fR - Create a 2048 bit key.
+ \fBTSS_KEY_SIZE_4096\fR - Create a 4096 bit key.
+ \fBTSS_KEY_SIZE_8192\fR - Create a 8192 bit key.
+ \fBTSS_KEY_SIZE_16384\fR - Create a 16384 bit key.
+ \fBTSS_KEY_TYPE_STORAGE\fR - Create a storage key. (Used to wrap other keys).
+ \fBTSS_KEY_TYPE_SIGNING\fR - Create a signing key.
+ \fBTSS_KEY_TYPE_BIND\fR - Create a binding key. (Used to encrypt data).
+ \fBTSS_KEY_TYPE_IDENTITY\fR - Create an identity key. (Used for an identity).
+ \fBTSS_KEY_TYPE_LEGACY\fR - Create a legacy key. (Can be used for signing and binding, created from data external to a TSS).
+ \fBTSS_KEY_TYPE_AUTHCHANGE\fR - Create an ephemeral key used to change authorization values.
+ \fBTSS_KEY_VOLATILE\fR - Create a volatile key. (Must be unloaded at startup).
+ \fBTSS_KEY_NON_VOLATILE\fR - Create a non-volatile key. (May be unloaded at startup).
+ \fBTSS_KEY_MIGRATABLE\fR - Create a migratable key.
+ \fBTSS_KEY_NOT_MIGRATABLE\fR - Create a non-migratable key. [DEFAULT]
+ \fBTSS_KEY_AUTHORIZATION\fR - Key will require authorization.
+ \fBTSS_KEY_NO_AUTHORIZATION\fR - Key will not require authorization. [DEFAULT]
+ \fBTSS_KEY_EMPTY_KEY\fR - Key template which will be returned as an object with very few attributes.
+
+.TP
+.SM PCR composite objects:
+ None.
+.TP
+.SM Hash objects:
+ \fBTSS_HASH_SHA1\fR - a hash object of type SHA-1.
+ \fBTSS_HASH_OTHER\fR - a hash object of type other than SHA-1.
+.PP
+.PP
+.SS phObject
+The handle of the object to be created.
+
+.SH "RETURN CODES"
+.PP
+\fBTspi_Context_CreateObject\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - Either \fIhContext\fR or \fIphObject\fR is an invalid handle. 
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_Context_CreateObject\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_Context_CloseObject\fR(3).
diff --git a/man/man3/Tspi_Data_Seal.3 b/man/man3/Tspi_Data_Seal.3
index 69b6f6d..a8ee798 100644
--- a/man/man3/Tspi_Data_Seal.3
+++ b/man/man3/Tspi_Data_Seal.3
@@ -1,83 +1,83 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_Data_Seal" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_Data_Seal \- encrypt a data blob in a mannar that is only decryptable by Tspi_Data_Unseal on the same system.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_Data_Seal(TSS_HENCDATA " hEncData ",     TSS_HKEY " hEncKey ","
-.BI "                          UINT32       " ulDataLength ", BYTE*    " rgbDataToSeal ","
-.BI "                          TSS_HPCRS    " hPcrComposite ");"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_Data_Seal\fR encrypts a data blob in a mannar that is only decryptable by Tspi_Data_Unseal on the same system. The data blob is encrypted using a public key operation with the nonmigratable key addressed by the given encryption key object.
-.SH "PARAMETERS"
-.PP
-.SS hEncData
-Handle of the data object which contains the sealed data on successful completion of the command.
-.PP
-.SS hEncKey
-Handle to the key object addressing the nonmigratable key which is used to encrypt the data.
-.PP
-.SS ulDataLength
-The Length (in bytes) of the rgbDataToSeal parameter.
-.PP
-.SS rgbDataToSeal
-Pointer to memory containing the data to be encrypted.
-.PP
-.SS hPcrComposite
-Handle of the PCR Composite object specifying the PCRs which are part of the sealed data blob. Set to NULL, if the encrypted data should only be bound to the system and PCRs are not of interest. 
-.SH "RETURN CODES"
-.PP
-\fBTspi_Data_Seal\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - One of the following parameters \fIhEncData\fR, \fIhEncKey\fR, \fIrgbDataToSeal\fR is invalid.
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_Data_Seal\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_Data_Unseal\fR(3).
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_Data_Seal" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_Data_Seal \- encrypt a data blob in a mannar that is only decryptable by Tspi_Data_Unseal on the same system.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_Data_Seal(TSS_HENCDATA " hEncData ",     TSS_HKEY " hEncKey ","
+.BI "                          UINT32       " ulDataLength ", BYTE*    " rgbDataToSeal ","
+.BI "                          TSS_HPCRS    " hPcrComposite ");"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_Data_Seal\fR encrypts a data blob in a mannar that is only decryptable by Tspi_Data_Unseal on the same system. The data blob is encrypted using a public key operation with the nonmigratable key addressed by the given encryption key object.
+.SH "PARAMETERS"
+.PP
+.SS hEncData
+Handle of the data object which contains the sealed data on successful completion of the command.
+.PP
+.SS hEncKey
+Handle to the key object addressing the nonmigratable key which is used to encrypt the data.
+.PP
+.SS ulDataLength
+The Length (in bytes) of the rgbDataToSeal parameter.
+.PP
+.SS rgbDataToSeal
+Pointer to memory containing the data to be encrypted.
+.PP
+.SS hPcrComposite
+Handle of the PCR Composite object specifying the PCRs which are part of the sealed data blob. Set to NULL, if the encrypted data should only be bound to the system and PCRs are not of interest. 
+.SH "RETURN CODES"
+.PP
+\fBTspi_Data_Seal\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - One of the following parameters \fIhEncData\fR, \fIhEncKey\fR, \fIrgbDataToSeal\fR is invalid.
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_Data_Seal\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_Data_Unseal\fR(3).
+
+
+
diff --git a/man/man3/Tspi_Data_Unseal.3 b/man/man3/Tspi_Data_Unseal.3
index f255356..9738adf 100644
--- a/man/man3/Tspi_Data_Unseal.3
+++ b/man/man3/Tspi_Data_Unseal.3
@@ -1,81 +1,81 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_Data_Unseal" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_Data_Unseal \- dencrypt data encrypted by Tspi_Data_Seal() only if it was encrypted on the same platform and under the current configuration.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_Data_Unseal(TSS_HENCDATA " hEncData ",              TSS_HKEY " hKey ","
-.BI "                            UINT32       " pulUnsealedDataLength ", BYTE**   " prgbUnsealedData ");"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_Data_Unseal\fR reveals data encrypted by the Tspi_Data_Seal only if it was encrypted on the same platform and the current configuration. This is internally proofed and guaranteed by the TPM.
-.SH "PARAMETERS"
-.PP
-.SS hEncData
-Handle of the data object which contains the sealed data.
-.PP
-.SS hKey
-Handle to the key object addressing the nonmigratable key which is used to decrypt the data.
-.PP
-.SS pulUnsealedDataLength
-The length (in bytes) of the prgbUnsealedData parameter.
-.PP
-.SS prgbUnsealedData
-On successful completion of the command, this parameter points to a buffer containing the plaintext data.
-.PP
-.SS hPcrComposite
-Handle of the PCR Composite object specifying the PCRs which are part of the sealed data blob. Set to NULL, if the encrypted data should only be bound to the system and PCRs are not of interest.
-.SH "RETURN CODES"
-.PP
-\fBTspi_Data_Unseal\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - Either \fBhEncData\fR or \fBhKey\fR is not a valid handle.
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_Data_Unseal\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_Data_Seal\fR(3).
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_Data_Unseal" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_Data_Unseal \- dencrypt data encrypted by Tspi_Data_Seal() only if it was encrypted on the same platform and under the current configuration.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_Data_Unseal(TSS_HENCDATA " hEncData ",              TSS_HKEY " hKey ","
+.BI "                            UINT32       " pulUnsealedDataLength ", BYTE**   " prgbUnsealedData ");"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_Data_Unseal\fR reveals data encrypted by the Tspi_Data_Seal only if it was encrypted on the same platform and the current configuration. This is internally proofed and guaranteed by the TPM.
+.SH "PARAMETERS"
+.PP
+.SS hEncData
+Handle of the data object which contains the sealed data.
+.PP
+.SS hKey
+Handle to the key object addressing the nonmigratable key which is used to decrypt the data.
+.PP
+.SS pulUnsealedDataLength
+The length (in bytes) of the prgbUnsealedData parameter.
+.PP
+.SS prgbUnsealedData
+On successful completion of the command, this parameter points to a buffer containing the plaintext data.
+.PP
+.SS hPcrComposite
+Handle of the PCR Composite object specifying the PCRs which are part of the sealed data blob. Set to NULL, if the encrypted data should only be bound to the system and PCRs are not of interest.
+.SH "RETURN CODES"
+.PP
+\fBTspi_Data_Unseal\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - Either \fBhEncData\fR or \fBhKey\fR is not a valid handle.
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_Data_Unseal\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_Data_Seal\fR(3).
+
+
+
diff --git a/man/man3/Tspi_GetAttribData.3 b/man/man3/Tspi_GetAttribData.3
index b1f1433..fe86ff4 100644
--- a/man/man3/Tspi_GetAttribData.3
+++ b/man/man3/Tspi_GetAttribData.3
@@ -1,89 +1,89 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_GetAttribData" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_GetAttribData \- get a non 32bit attribute of the object.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_GetAttribData(TSS_HOBJECT " hObject ", TSS_FLAG " attribFlag ","
-.BI "                              TSS_FLAG    " subFlag ", UINT32*  " pulAttribDataSize ","
-.BI "                              BYTE**      " prgbAttribData ");"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_GetAttribData\fR  is used to get the value of a particular attribute associated iwth a particular object where that attribute does not happen to be a UINT32. The structure and size of the attribute data depends on the attribute.
-.SH "PARAMETERS"
-.PP
-.SS hObject
-Handle of the object where to retrieve the attribute.
-.PP
-.SS attribFlag
-Flag indicating the attribute to query.
-.PP
-.SS subFlag
-Sub flag indicating the attribute to query.
-.PP
-.SS pulAttribDataSize
-Recieves the length (in bytes) of the prgbAttribData parameter.
-.PP
-.SS prgbAttribData
-On successful completion of the command, this parameter points to a buffer containing the actual data of the specified attribute.
-.SH "RETURN CODES"
-.PP
-\fBTspi_GetAttribData\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - Either \fIhObject\fR, \fIattribFlag\fR, or \fIsubFlag\fR are invalid.
-.TP
-.SM TSS_E_ATTRIB_FLAG
-.TP
-.SM TSS_E_ATTRIB_SUBFLAG
-.TP
-.SM TSS_E_ATTRIB_DATA
-.TP
-.SM TSS_E_BAD_PARAMETER
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_GetAttribData\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_SetAttribData\fR(3).
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_GetAttribData" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_GetAttribData \- get a non 32bit attribute of the object.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_GetAttribData(TSS_HOBJECT " hObject ", TSS_FLAG " attribFlag ","
+.BI "                              TSS_FLAG    " subFlag ", UINT32*  " pulAttribDataSize ","
+.BI "                              BYTE**      " prgbAttribData ");"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_GetAttribData\fR  is used to get the value of a particular attribute associated iwth a particular object where that attribute does not happen to be a UINT32. The structure and size of the attribute data depends on the attribute.
+.SH "PARAMETERS"
+.PP
+.SS hObject
+Handle of the object where to retrieve the attribute.
+.PP
+.SS attribFlag
+Flag indicating the attribute to query.
+.PP
+.SS subFlag
+Sub flag indicating the attribute to query.
+.PP
+.SS pulAttribDataSize
+Recieves the length (in bytes) of the prgbAttribData parameter.
+.PP
+.SS prgbAttribData
+On successful completion of the command, this parameter points to a buffer containing the actual data of the specified attribute.
+.SH "RETURN CODES"
+.PP
+\fBTspi_GetAttribData\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - Either \fIhObject\fR, \fIattribFlag\fR, or \fIsubFlag\fR are invalid.
+.TP
+.SM TSS_E_ATTRIB_FLAG
+.TP
+.SM TSS_E_ATTRIB_SUBFLAG
+.TP
+.SM TSS_E_ATTRIB_DATA
+.TP
+.SM TSS_E_BAD_PARAMETER
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_GetAttribData\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_SetAttribData\fR(3).
+
+
+
diff --git a/man/man3/Tspi_Key_CertifyKey.3 b/man/man3/Tspi_Key_CertifyKey.3
index c64b088..032f7bb 100644
--- a/man/man3/Tspi_Key_CertifyKey.3
+++ b/man/man3/Tspi_Key_CertifyKey.3
@@ -1,76 +1,76 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_Key_CertifyKey" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_Key_CertifyKey \- sign a public key.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_Key_CertifyKey(TSS_HKEY        " hKey ", TSS_HKEY " hCertifyingKey ","
-.BI "                               TSS_VALIDATION* " pValidationData ");"
-.fi
-.sp
-.ad
-.hy
-.SH "DESCRIPTION"
-.PP
-\fBTspi_Key_CertifyKey\fR signs a public key.
-.SH "PARAMETERS"
-.PP
-.SS hKey 
-Handle of the key object to be loaded.
-.PP
-.SS hCertifyingKey
-Handle to the certifying key used to sign the addressed by hKey.
-.PP
-.SS pValidationData
-Pointer to a structure of the type TSS_VALIDATION. After successful completion of the call the member rgbValidationData of this structure contains the signature data of the command. The member prgbData of the structure points to a buffer containing a TCPA_CERTIFY_INFO data stream as specified within the TCPA 1.1b Main Specification. 
-.SH "RETURN CODES"
-.PP
-\fBTspi_Key_CertifyKey\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - Either \fIhKey\fR or \fIhCertifyingKey\fR are invalid handles.
-.TP
-.SM TSS_E_BAD_PARAMETER
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_Key_CertifyKey\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_Key_CreateKey\fR(3), \fBTspi_Key_WrapKey\fR(3).
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_Key_CertifyKey" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_Key_CertifyKey \- sign a public key.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_Key_CertifyKey(TSS_HKEY        " hKey ", TSS_HKEY " hCertifyingKey ","
+.BI "                               TSS_VALIDATION* " pValidationData ");"
+.fi
+.sp
+.ad
+.hy
+.SH "DESCRIPTION"
+.PP
+\fBTspi_Key_CertifyKey\fR signs a public key.
+.SH "PARAMETERS"
+.PP
+.SS hKey 
+Handle of the key object to be loaded.
+.PP
+.SS hCertifyingKey
+Handle to the certifying key used to sign the addressed by hKey.
+.PP
+.SS pValidationData
+Pointer to a structure of the type TSS_VALIDATION. After successful completion of the call the member rgbValidationData of this structure contains the signature data of the command. The member prgbData of the structure points to a buffer containing a TCPA_CERTIFY_INFO data stream as specified within the TCPA 1.1b Main Specification. 
+.SH "RETURN CODES"
+.PP
+\fBTspi_Key_CertifyKey\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - Either \fIhKey\fR or \fIhCertifyingKey\fR are invalid handles.
+.TP
+.SM TSS_E_BAD_PARAMETER
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_Key_CertifyKey\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_Key_CreateKey\fR(3), \fBTspi_Key_WrapKey\fR(3).
+
+
+
diff --git a/man/man3/Tspi_Key_CreateKey.3 b/man/man3/Tspi_Key_CreateKey.3
index 27b4364..4dcf782 100644
--- a/man/man3/Tspi_Key_CreateKey.3
+++ b/man/man3/Tspi_Key_CreateKey.3
@@ -1,71 +1,71 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_Key_CreateKey" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_Key_CreateKey \- create a key pair within the TPM, wrapping it with the key addressed by hWrappingKey.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_Key_CreateKey(TSS_HKEY " hKey ", TSS_HKEY " hWrappingKey ", TSS_HPCRS " hPcrComposite ");"
-.fi
-.sp
-.ad
-.hy
-.SH "DESCRIPTION"
-.PP
-\fBTSS_Key_CreateKey\fR  
-calls the TPM command TPM_CreateWrapKey. If hPcrComposite is not set to NULL, the created key blob is bound to this PCR values. The key object addressed by hKey must contain the key information needed for the creation. 
-.SH "PARAMETERS"
-.PP
-.SS hKey
-The handle of the key object to create.
-.PP
-.SS hWrappingKey
-The handle to the key used to wrap the newly created key.
-.PP
-.SS hPcrComposite
-The handle to an object, if the value of the handle doesn't equal NULL, the newly create key will be bound ot the PCR values described with this object.
-
-.SH "RETURN CODES"
-.PP
-\fBTspi_Key_CreateKey\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - Either \fIhKey\fR, \fIhWrappingKey\fR or \fIhPcrComposite\fR are invalid parameters.
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_Key_CreateKey\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_Key_WrapKey\fR(3), \fBTspi_Key_CertifyKey\fR(3), \fBTspi_Key_RegisterKey\fR(3).
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_Key_CreateKey" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_Key_CreateKey \- create a key pair within the TPM, wrapping it with the key addressed by hWrappingKey.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_Key_CreateKey(TSS_HKEY " hKey ", TSS_HKEY " hWrappingKey ", TSS_HPCRS " hPcrComposite ");"
+.fi
+.sp
+.ad
+.hy
+.SH "DESCRIPTION"
+.PP
+\fBTSS_Key_CreateKey\fR  
+calls the TPM command TPM_CreateWrapKey. If hPcrComposite is not set to NULL, the created key blob is bound to this PCR values. The key object addressed by hKey must contain the key information needed for the creation. 
+.SH "PARAMETERS"
+.PP
+.SS hKey
+The handle of the key object to create.
+.PP
+.SS hWrappingKey
+The handle to the key used to wrap the newly created key.
+.PP
+.SS hPcrComposite
+The handle to an object, if the value of the handle doesn't equal NULL, the newly create key will be bound ot the PCR values described with this object.
+
+.SH "RETURN CODES"
+.PP
+\fBTspi_Key_CreateKey\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - Either \fIhKey\fR, \fIhWrappingKey\fR or \fIhPcrComposite\fR are invalid parameters.
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_Key_CreateKey\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_Key_WrapKey\fR(3), \fBTspi_Key_CertifyKey\fR(3), \fBTspi_Key_RegisterKey\fR(3).
diff --git a/man/man3/Tspi_Key_CreateMigrationBlob.3 b/man/man3/Tspi_Key_CreateMigrationBlob.3
index 9753849..1b7ed34 100644
--- a/man/man3/Tspi_Key_CreateMigrationBlob.3
+++ b/man/man3/Tspi_Key_CreateMigrationBlob.3
@@ -1,97 +1,97 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_Key_CreateMigrationBlob" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_Key_CreateMigrationBlob \- create a key blob suitable for migrating to another TPM.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_Key_CreateMigrationBlob(TSS_HKEY " hKeyToMigrate ",          TSS_HKEY " hParentKey ","
-.BI "                                        UINT32   " ulMigTicketLength ",      BYTE*    " rgbMigTicket ","
-.BI "                                        UINT32*  " pulRandomLength ",        BYTE**   " prgbRandom ","
-.BI "                                        UINT32*  " pulMigrationBlobLength ", BYTE**   " prgbMigrationBlob ");"
-.fi
-.sp
-.ad
-.hy
-.SH "DESCRIPTION"
-.PP
-\fBTspi_Key_CreateMigrationBlob\fR returns a key blob containing an encrypted section, which will be different depending on the migration scheme indicated within the migration ticket previously created by the method Tspi_TPM_AuthorizeMigrationTicket().
-.SH "PARAMETERS"
-.PP
-.SS hKeyToMigrate 
-Handle of the key object to migrate.
-.PP
-.SS hParentKey
-Handle to the parent key related to the key addressed by hKeyToMigrate.
-.PP
-.SS ulMigTicketLength
-The length (in bytes) of the rgbMigTickey parameter.
-.PP
-.SS rgbMigTicket
-Pointer to memory containing the migration ticket (migration public key and its authorization digest).
-.PP
-.SS pulRandomLength 
-On successful completion this parameter returns the random data length returned at the parameter prgbRandom.
-.PP
-.SS prgbRandom
-On successful completion this parameter returns the random data.
-.PP
-.SS pulMigrationBlobLength
-On successful completion this parameter returns the length of the migration blob data returned at the parameter prgbMigrationBlob.
-.PP
-.SS prgbMigrationBlob
-On successful completion this parameter returns the migration data blob. 
-.PP
-.SH "RETURN CODES"
-.PP
-\fBTspi_Key_CreateMigrationBlob\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - Either \fIhKeyToMigrate\fR, \fIhParentKey\fR or \fIrgbMigTicket\fR are invalid parameters.
-.TP
-.SM TSS_E_BAD_PARAMETER - One of the passed parameters is wrong. 
-.TP
-.SM TSS_E_KEY_NO_MIGRATION_POLICY - No migration policy picked.
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_Key_CreateMigrationBlob\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_Key_CreateKey\fR(3), \fBTspi_Key_CertifyKey\fR(3).
-
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_Key_CreateMigrationBlob" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_Key_CreateMigrationBlob \- create a key blob suitable for migrating to another TPM.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_Key_CreateMigrationBlob(TSS_HKEY " hKeyToMigrate ",          TSS_HKEY " hParentKey ","
+.BI "                                        UINT32   " ulMigTicketLength ",      BYTE*    " rgbMigTicket ","
+.BI "                                        UINT32*  " pulRandomLength ",        BYTE**   " prgbRandom ","
+.BI "                                        UINT32*  " pulMigrationBlobLength ", BYTE**   " prgbMigrationBlob ");"
+.fi
+.sp
+.ad
+.hy
+.SH "DESCRIPTION"
+.PP
+\fBTspi_Key_CreateMigrationBlob\fR returns a key blob containing an encrypted section, which will be different depending on the migration scheme indicated within the migration ticket previously created by the method Tspi_TPM_AuthorizeMigrationTicket().
+.SH "PARAMETERS"
+.PP
+.SS hKeyToMigrate 
+Handle of the key object to migrate.
+.PP
+.SS hParentKey
+Handle to the parent key related to the key addressed by hKeyToMigrate.
+.PP
+.SS ulMigTicketLength
+The length (in bytes) of the rgbMigTickey parameter.
+.PP
+.SS rgbMigTicket
+Pointer to memory containing the migration ticket (migration public key and its authorization digest).
+.PP
+.SS pulRandomLength 
+On successful completion this parameter returns the random data length returned at the parameter prgbRandom.
+.PP
+.SS prgbRandom
+On successful completion this parameter returns the random data.
+.PP
+.SS pulMigrationBlobLength
+On successful completion this parameter returns the length of the migration blob data returned at the parameter prgbMigrationBlob.
+.PP
+.SS prgbMigrationBlob
+On successful completion this parameter returns the migration data blob. 
+.PP
+.SH "RETURN CODES"
+.PP
+\fBTspi_Key_CreateMigrationBlob\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - Either \fIhKeyToMigrate\fR, \fIhParentKey\fR or \fIrgbMigTicket\fR are invalid parameters.
+.TP
+.SM TSS_E_BAD_PARAMETER - One of the passed parameters is wrong. 
+.TP
+.SM TSS_E_KEY_NO_MIGRATION_POLICY - No migration policy picked.
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_Key_CreateMigrationBlob\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_Key_CreateKey\fR(3), \fBTspi_Key_CertifyKey\fR(3).
+
+
+
+
diff --git a/man/man3/Tspi_Key_WrapKey.3 b/man/man3/Tspi_Key_WrapKey.3
index d9e0673..83a5931 100644
--- a/man/man3/Tspi_Key_WrapKey.3
+++ b/man/man3/Tspi_Key_WrapKey.3
@@ -1,72 +1,72 @@
-.\" Copyright (C) 2006 International Business Machines Corporation
-.\" Written by Kent Yoder based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_Key_WrapKey" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_Key_WrapKey \- wrap a key with the key addressed by hWrappingKey.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_Key_WrapKey(TSS_HKEY  " hKey ", TSS_HKEY " hWrappingKey ","
-.BI "                            TSS_HPCRS " hPcrComposite ");"
-.fi
-.sp
-.ad
-.hy
-.SH "DESCRIPTION"
-.PP
-\fBTSS_Key_WrapKey\fR  
-wraps the private key \fIhKey\fR using the public key addressed by \fIhWrappingKey\fR. If hPcrComposite is not set to NULL (0), the created key blob is bound to its PCR values. The key object addressed by \fIhKey\fR must contain the key information needed for the creation. On successful return from this call, \fIhKey\fR can be loaded into a TPM. \fIhKey\fR must have been created as a migratable key and should have its usage and migrations secrets set using \fBTspi_Policy_SetSecret(3)\fR.  Also, \fIhKey\fR should have had its private key set to either RSA private component, p or q.
-.SH "PARAMETERS"
-.PP
-.SS hKey
-The handle of the key object that is wrapped.
-.PP
-.SS hWrappingKey
-The handle to the key used to wrap the newly created key.
-.PP
-.SS hPcrComposite
-The handle to an object, if the value of the handle doesn't equal NULL, the newly create key will be bound ot the PCR values described with this object.
-
-.SH "RETURN CODES"
-.PP
-\fBTspi_Key_WrapKey\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - Either \fIhKey\fR, \fIhWrappingKey\fR or \fIhPcrComposite\fR are invalid handles.
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_Key_WrapKey\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_Key_CreateKey\fR(3), \fBTspi_Key_CertifyKey\fR(3), \fBTspi_Key_RegisterKey\fR(3).
+.\" Copyright (C) 2006 International Business Machines Corporation
+.\" Written by Kent Yoder based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_Key_WrapKey" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_Key_WrapKey \- wrap a key with the key addressed by hWrappingKey.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_Key_WrapKey(TSS_HKEY  " hKey ", TSS_HKEY " hWrappingKey ","
+.BI "                            TSS_HPCRS " hPcrComposite ");"
+.fi
+.sp
+.ad
+.hy
+.SH "DESCRIPTION"
+.PP
+\fBTSS_Key_WrapKey\fR  
+wraps the private key \fIhKey\fR using the public key addressed by \fIhWrappingKey\fR. If hPcrComposite is not set to NULL (0), the created key blob is bound to its PCR values. The key object addressed by \fIhKey\fR must contain the key information needed for the creation. On successful return from this call, \fIhKey\fR can be loaded into a TPM. \fIhKey\fR must have been created as a migratable key and should have its usage and migrations secrets set using \fBTspi_Policy_SetSecret(3)\fR.  Also, \fIhKey\fR should have had its private key set to either RSA private component, p or q.
+.SH "PARAMETERS"
+.PP
+.SS hKey
+The handle of the key object that is wrapped.
+.PP
+.SS hWrappingKey
+The handle to the key used to wrap the newly created key.
+.PP
+.SS hPcrComposite
+The handle to an object, if the value of the handle doesn't equal NULL, the newly create key will be bound ot the PCR values described with this object.
+
+.SH "RETURN CODES"
+.PP
+\fBTspi_Key_WrapKey\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - Either \fIhKey\fR, \fIhWrappingKey\fR or \fIhPcrComposite\fR are invalid handles.
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_Key_WrapKey\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_Key_CreateKey\fR(3), \fBTspi_Key_CertifyKey\fR(3), \fBTspi_Key_RegisterKey\fR(3).
diff --git a/man/man3/Tspi_PcrComposite_GetPcrValue.3 b/man/man3/Tspi_PcrComposite_GetPcrValue.3
index f807956..9334b13 100644
--- a/man/man3/Tspi_PcrComposite_GetPcrValue.3
+++ b/man/man3/Tspi_PcrComposite_GetPcrValue.3
@@ -1,77 +1,77 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_PcrComposite_GetPcrValue" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_PcrComposite_GetPcrValue \- get the digest value of a given PCR index inside a PCR composite object.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_PcrComposite_GetPcrValue(TSS_HPCRS " hPcrComposite ",    UINT32 " ulPcrIndex ","
-.BI "                                         UINT32*   " ulPcrValueLength ", BYTE** " rgbPcrValue ");"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_PcrComposite_GetPcrValue\fR returns the digest value of a given PCR index inside a PCR composite object. 
-.SH "PARAMETERS"
-.PP
-.SS hPcrComposite
-Handle of the PCR composite object instance where a PCR value should be returned.
-.PP
-.SS ulPcrIndex
-This parameter indicates the index of the PCR to read.
-.PP
-.SS ulPcrValueLength
-The length (in bytes) of the rgbPcrValue parameter.
-.PP
-.SS rgbPcrValue
-After successful completion this parameter recieves a pointer to the memory block containing the PCR value of the PCR indicated by ulPcrIndex.
-.SH "RETURN CODES"
-.PP
-\fBTspi_PcrComposite_GetPcrValue\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - Either \fIhPcrComposite\fR or \fIulPcrIndex\fR is an invalid parameter.
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_PcrComposite_GetPcrValue\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_PcrComposite_SelectPcrIndex\fR(3), \fBTspi_PcrComposite_SetPcrValue\fR(3).
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_PcrComposite_GetPcrValue" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_PcrComposite_GetPcrValue \- get the digest value of a given PCR index inside a PCR composite object.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_PcrComposite_GetPcrValue(TSS_HPCRS " hPcrComposite ",    UINT32 " ulPcrIndex ","
+.BI "                                         UINT32*   " ulPcrValueLength ", BYTE** " rgbPcrValue ");"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_PcrComposite_GetPcrValue\fR returns the digest value of a given PCR index inside a PCR composite object. 
+.SH "PARAMETERS"
+.PP
+.SS hPcrComposite
+Handle of the PCR composite object instance where a PCR value should be returned.
+.PP
+.SS ulPcrIndex
+This parameter indicates the index of the PCR to read.
+.PP
+.SS ulPcrValueLength
+The length (in bytes) of the rgbPcrValue parameter.
+.PP
+.SS rgbPcrValue
+After successful completion this parameter recieves a pointer to the memory block containing the PCR value of the PCR indicated by ulPcrIndex.
+.SH "RETURN CODES"
+.PP
+\fBTspi_PcrComposite_GetPcrValue\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - Either \fIhPcrComposite\fR or \fIulPcrIndex\fR is an invalid parameter.
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_PcrComposite_GetPcrValue\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_PcrComposite_SelectPcrIndex\fR(3), \fBTspi_PcrComposite_SetPcrValue\fR(3).
+
+
diff --git a/man/man3/Tspi_PcrComposite_SelectPcrIndex.3 b/man/man3/Tspi_PcrComposite_SelectPcrIndex.3
index 812ba48..6c134d4 100644
--- a/man/man3/Tspi_PcrComposite_SelectPcrIndex.3
+++ b/man/man3/Tspi_PcrComposite_SelectPcrIndex.3
@@ -1,69 +1,69 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_PcrComposite_SelectPcrIndex" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_PcrComposite_SelectPcrIndex\- select a PCR index inside a PCR composite object.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_PcrComposite_SelectPcrIndex(TSS_HPCRS " hPcrComposite ", UINT32 " ulPcrIndex ");"
-.fi
-.sp
-.ad
-.hy
-.SH "DESCRIPTION"
-.PP
-\fBTspi_PcrComposite_SelectPcrIndex\fR selects a PCR index inside a PCR composite object. The PCR composite object must be created withthe function Tspi_Context_CreateObject(). An exampled for the usage is the selection of PCR registeres before calling Tspi_TPM_Quote().
-.SH "PARAMETERS"
-.PP
-.SS hPcrComposite
-Handle of the PCR composite object instance where the index should be selected.
-.PP
-.SS ulPcrIndex
-This parameter indicates the index of the PCR to select.
-.SH "RETURN CODES"
-.PP
-\fBTspi_PcrComposite_SelectPcrIndex\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - Either \fIhPcrComposite\fR or \fIulPcrIndex\fR is an invalid handle.
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_PcrComposite_SelectPcrIndex\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_TPM_Quote\fR(3), \fBTspi_PcrComposite_SetPcrValue\fR(3), \fBTspi_PcrComposite_GetPcrValue\fR(3).
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_PcrComposite_SelectPcrIndex" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_PcrComposite_SelectPcrIndex\- select a PCR index inside a PCR composite object.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_PcrComposite_SelectPcrIndex(TSS_HPCRS " hPcrComposite ", UINT32 " ulPcrIndex ");"
+.fi
+.sp
+.ad
+.hy
+.SH "DESCRIPTION"
+.PP
+\fBTspi_PcrComposite_SelectPcrIndex\fR selects a PCR index inside a PCR composite object. The PCR composite object must be created withthe function Tspi_Context_CreateObject(). An exampled for the usage is the selection of PCR registeres before calling Tspi_TPM_Quote().
+.SH "PARAMETERS"
+.PP
+.SS hPcrComposite
+Handle of the PCR composite object instance where the index should be selected.
+.PP
+.SS ulPcrIndex
+This parameter indicates the index of the PCR to select.
+.SH "RETURN CODES"
+.PP
+\fBTspi_PcrComposite_SelectPcrIndex\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - Either \fIhPcrComposite\fR or \fIulPcrIndex\fR is an invalid handle.
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_PcrComposite_SelectPcrIndex\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_TPM_Quote\fR(3), \fBTspi_PcrComposite_SetPcrValue\fR(3), \fBTspi_PcrComposite_GetPcrValue\fR(3).
+
+
diff --git a/man/man3/Tspi_PcrComposite_SetPcrValue.3 b/man/man3/Tspi_PcrComposite_SetPcrValue.3
index d010ee1..076a590 100644
--- a/man/man3/Tspi_PcrComposite_SetPcrValue.3
+++ b/man/man3/Tspi_PcrComposite_SetPcrValue.3
@@ -1,77 +1,77 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_PcrComposite_SetPcrValue" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_PcrComposite_SetPcrValue\- set the digest for a given PCR index inside a PCR composite object.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_PcrComposite_SetPcrValue(TSS_HPCRS " hPcrComposite ",    UINT32 " ulPcrIndex ","
-.BI "                                         UINT32    " ulPcrValueLength ", BYTE*  " rgbPcrValue ");"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_PcrComposite_SetPcrValue\fR sets the digest for a given PCR index inside the PCR composite object.
-.SH "PARAMETERS"
-.PP
-.SS hPcrComposite
-Handle of the PCR composite object instance where a PCR value should be set.
-.PP
-.SS ulPcrIndex
-This parameter indicates the index of the PCR to set.
-.PP
-.SS ulPcrValueLength
-The length (in bytes) of the rgbPcrValue parameter.
-.PP
-.SS rgbPcrValue
-Pointer to memory containing the actual value which should be set for the PCR indicated by ulPcrIndex.
-.SH "RETURN CODES"
-.PP
-\fBTspi_PcrComposite_SetPcrValue\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - Either \fIhPcrComposite\fR or \fIulPcrIndex\fR is an invalid parameter.
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_PcrComposite_SetPcrValue\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_PcrComposite_SelectPcrIndex\fR(3), \fBTspi_PcrComposite_GetPcrValue\fR(3).
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_PcrComposite_SetPcrValue" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_PcrComposite_SetPcrValue\- set the digest for a given PCR index inside a PCR composite object.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_PcrComposite_SetPcrValue(TSS_HPCRS " hPcrComposite ",    UINT32 " ulPcrIndex ","
+.BI "                                         UINT32    " ulPcrValueLength ", BYTE*  " rgbPcrValue ");"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_PcrComposite_SetPcrValue\fR sets the digest for a given PCR index inside the PCR composite object.
+.SH "PARAMETERS"
+.PP
+.SS hPcrComposite
+Handle of the PCR composite object instance where a PCR value should be set.
+.PP
+.SS ulPcrIndex
+This parameter indicates the index of the PCR to set.
+.PP
+.SS ulPcrValueLength
+The length (in bytes) of the rgbPcrValue parameter.
+.PP
+.SS rgbPcrValue
+Pointer to memory containing the actual value which should be set for the PCR indicated by ulPcrIndex.
+.SH "RETURN CODES"
+.PP
+\fBTspi_PcrComposite_SetPcrValue\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - Either \fIhPcrComposite\fR or \fIulPcrIndex\fR is an invalid parameter.
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_PcrComposite_SetPcrValue\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_PcrComposite_SelectPcrIndex\fR(3), \fBTspi_PcrComposite_GetPcrValue\fR(3).
+
+
diff --git a/man/man3/Tspi_SetAttribData.3 b/man/man3/Tspi_SetAttribData.3
index d16ab47..aa36293 100644
--- a/man/man3/Tspi_SetAttribData.3
+++ b/man/man3/Tspi_SetAttribData.3
@@ -1,87 +1,87 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_SetAttribData" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_SetAttribData \- set a non 32bit attribute of an object.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_SetAttribData(TSS_HOBJECT " hObject ", TSS_FLAG " attribFlag ","
-.BI "                              TSS_FLAG    " subFlag ", UINT32   " ulAttribDataSize ","
-.BI "                              BYTE*       " rgbAttribData ");"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_SetAttribData\fR  sets the attributes associated with a given class of object that aren't UINT32. The structure and size of hte attribute data depends on the attribute.
-.SH "PARAMETERS"
-.PP
-.SS hObject
-Handle of the object where the attribute is to be set.
-.PP
-.SS attribFlag
-Flag indicating the attribute to set.
-.PP
-.SS subFlag
-Sub flag indicating the attribute to set
-.PP
-.SS ulAttribDataSize
-Supplies the length (in bytes) of the rgbAttribData.
-.PP
-.SS rgbAttribData
-Pointer to the actual data which is to be set for the specified attribute.
-.SH "RETURN CODES"
-.PP
-\fBTspi_SetAttribData\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - \fIhObject\fR is an invalid parameter.
-.TP
-.SM TSS_E_ATTRIB_FLAG - \fIattribFlag\fR is an invalid parameter.
-.TP
-.SM TSS_E_ATTRIB_SUBFLAG - \fIsubFlag\fR is an invalid parameter.
-.TP
-.SM TSS_E_ATTRIB_DATA - \fIrgbAttribData\fR is an invalid parameter.
-.TP
-.SM TSS_E_BAD_PARAMETER
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_SetAttribData\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_GetAttribData\fR(3).
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_SetAttribData" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_SetAttribData \- set a non 32bit attribute of an object.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_SetAttribData(TSS_HOBJECT " hObject ", TSS_FLAG " attribFlag ","
+.BI "                              TSS_FLAG    " subFlag ", UINT32   " ulAttribDataSize ","
+.BI "                              BYTE*       " rgbAttribData ");"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_SetAttribData\fR  sets the attributes associated with a given class of object that aren't UINT32. The structure and size of hte attribute data depends on the attribute.
+.SH "PARAMETERS"
+.PP
+.SS hObject
+Handle of the object where the attribute is to be set.
+.PP
+.SS attribFlag
+Flag indicating the attribute to set.
+.PP
+.SS subFlag
+Sub flag indicating the attribute to set
+.PP
+.SS ulAttribDataSize
+Supplies the length (in bytes) of the rgbAttribData.
+.PP
+.SS rgbAttribData
+Pointer to the actual data which is to be set for the specified attribute.
+.SH "RETURN CODES"
+.PP
+\fBTspi_SetAttribData\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - \fIhObject\fR is an invalid parameter.
+.TP
+.SM TSS_E_ATTRIB_FLAG - \fIattribFlag\fR is an invalid parameter.
+.TP
+.SM TSS_E_ATTRIB_SUBFLAG - \fIsubFlag\fR is an invalid parameter.
+.TP
+.SM TSS_E_ATTRIB_DATA - \fIrgbAttribData\fR is an invalid parameter.
+.TP
+.SM TSS_E_BAD_PARAMETER
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_SetAttribData\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_GetAttribData\fR(3).
diff --git a/man/man3/Tspi_TPM_AuthorizeMigrationTicket.3 b/man/man3/Tspi_TPM_AuthorizeMigrationTicket.3
index a68a7c0..ccda410 100644
--- a/man/man3/Tspi_TPM_AuthorizeMigrationTicket.3
+++ b/man/man3/Tspi_TPM_AuthorizeMigrationTicket.3
@@ -1,84 +1,84 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_TPM_AuthorizeMigrationTicket" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_TPM_AuthorizeMigrationTicket\- create the migration ticket required for the migration process.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_TPM_AuthorizeMigrationTicket(TSS_HTPM           " hTPM ",            TSS_HKEY " hMigrationKey ","
-.BI "                                             TSS_MIGRATE_SCHEME " migrationScheme ", UINT32*  " pulMigTicketLength ","
-.BI "                                             BYTE**             " prgbMigTicket ");"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_TPM_AuthorizeMigrationTicket\fR is used by the owner to authorize a target public key for migration. This mean sthat when a system is set up, the owner can decide that all archives should be done on a particular server. Then as keys are created, the user can pick one of these servers for the target of the migration of their keys, if they wish. This provides one of the two authorizations necessary to migrate a key.
-.SH "PARAMETERS"
-.PP
-.SS hTPM
-Handle of the TPM object
-.PP 
-.SS hMigrationKey
-Handle of the object representing the migration key.
-.PP 
-.SS migrationScheme
-Flag indiating the migration scheme to be used.
-.PP
-.SS pulMigTicketLength
-Recieves the length (in bytes) of the prgbMigTicket parameter.
-.PP
-.SS prgbMigTicket
-Recieves a pointer to thememory block containing the migration ticket blob.
-.SH "RETURN CODES"
-.PP
-\fBTspi_TPM_AuthorizeMigrationTicket\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE
-Either \fBhTPM\fR or \fBhMigrationKey\fR is not a valid handle.
-.TP
-.SM TSS_E_INTERNAL_ERROR
-An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_TPM_AuthorizeMigrationTicket\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fB(none)\fR.
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_TPM_AuthorizeMigrationTicket" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_TPM_AuthorizeMigrationTicket\- create the migration ticket required for the migration process.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_TPM_AuthorizeMigrationTicket(TSS_HTPM           " hTPM ",            TSS_HKEY " hMigrationKey ","
+.BI "                                             TSS_MIGRATE_SCHEME " migrationScheme ", UINT32*  " pulMigTicketLength ","
+.BI "                                             BYTE**             " prgbMigTicket ");"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_TPM_AuthorizeMigrationTicket\fR is used by the owner to authorize a target public key for migration. This mean sthat when a system is set up, the owner can decide that all archives should be done on a particular server. Then as keys are created, the user can pick one of these servers for the target of the migration of their keys, if they wish. This provides one of the two authorizations necessary to migrate a key.
+.SH "PARAMETERS"
+.PP
+.SS hTPM
+Handle of the TPM object
+.PP 
+.SS hMigrationKey
+Handle of the object representing the migration key.
+.PP 
+.SS migrationScheme
+Flag indiating the migration scheme to be used.
+.PP
+.SS pulMigTicketLength
+Recieves the length (in bytes) of the prgbMigTicket parameter.
+.PP
+.SS prgbMigTicket
+Recieves a pointer to thememory block containing the migration ticket blob.
+.SH "RETURN CODES"
+.PP
+\fBTspi_TPM_AuthorizeMigrationTicket\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE
+Either \fBhTPM\fR or \fBhMigrationKey\fR is not a valid handle.
+.TP
+.SM TSS_E_INTERNAL_ERROR
+An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_TPM_AuthorizeMigrationTicket\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fB(none)\fR.
+
+
+
diff --git a/man/man3/Tspi_TPM_CertifySelfTest.3 b/man/man3/Tspi_TPM_CertifySelfTest.3
index 995ac7d..a3503e8 100644
--- a/man/man3/Tspi_TPM_CertifySelfTest.3
+++ b/man/man3/Tspi_TPM_CertifySelfTest.3
@@ -1,80 +1,80 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_TPM_CertifySelfTest" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_TPM_CertifySelfTest\- have the TPM sign its self test data
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_TPM_CertifySelfTest(TSS_HTPM        " hTPM ", TSS_HKEY " hKey ","
-.BI "                                    TSS_VALIDATION* " pValidationData " );"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_TPM_CertifySelfTest\fR performs a self-test of each internal TPM function and returns an authenticated value (signature) if the test has passed.
-.SH "PARAMETERS"
-.PP
-.SS hTPM
-Handle of the TPM object
-.PP 
-.SS hKey
-Handle of the signature key object
-.PP
-.SS
-pValidationData
-Validation data structure.
-[IN] Provide externalData information required to compute the signature.
-[OUT] On successful completion of the ocmmand, the structure provides a buffer containing the validation data and a buffer containing the data the validation data was computed from.
-.SH "RETURN CODES"
-.PP
-\fBTspi_TPM_CertifySelfTest\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE
-\fBhTPM\fR is not a valid handle to a TPM object.
-.TP
-.SM TSS_E_INTERNAL_ERROR
-An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_TPM_CertifySelfTest\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_TPM_SelfTestFull\fR(3).
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_TPM_CertifySelfTest" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_TPM_CertifySelfTest\- have the TPM sign its self test data
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_TPM_CertifySelfTest(TSS_HTPM        " hTPM ", TSS_HKEY " hKey ","
+.BI "                                    TSS_VALIDATION* " pValidationData " );"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_TPM_CertifySelfTest\fR performs a self-test of each internal TPM function and returns an authenticated value (signature) if the test has passed.
+.SH "PARAMETERS"
+.PP
+.SS hTPM
+Handle of the TPM object
+.PP 
+.SS hKey
+Handle of the signature key object
+.PP
+.SS
+pValidationData
+Validation data structure.
+[IN] Provide externalData information required to compute the signature.
+[OUT] On successful completion of the ocmmand, the structure provides a buffer containing the validation data and a buffer containing the data the validation data was computed from.
+.SH "RETURN CODES"
+.PP
+\fBTspi_TPM_CertifySelfTest\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE
+\fBhTPM\fR is not a valid handle to a TPM object.
+.TP
+.SM TSS_E_INTERNAL_ERROR
+An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_TPM_CertifySelfTest\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_TPM_SelfTestFull\fR(3).
+
+
+
diff --git a/man/man3/Tspi_TPM_CheckMaintenancePubKey.3 b/man/man3/Tspi_TPM_CheckMaintenancePubKey.3
index e95ced2..b9ddd6d 100644
--- a/man/man3/Tspi_TPM_CheckMaintenancePubKey.3
+++ b/man/man3/Tspi_TPM_CheckMaintenancePubKey.3
@@ -1,100 +1,100 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_TPM_CheckMaintenancePubKey" 3 "2004-05-26" "TSS 1.1"
-.ce 1
-TCG Software Stack Developer's Reference
-.SH NAME
-Tspi_TPM_CheckMaintenancePubKey\- check the public maintenance key
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_TPM_CheckMaintenancePubKey(TSS_HTPM        " hTPM ", TSS_HKEY " hMaintenanceKey ","
-.BI "                                           TSS_VALIDATION* " pValidationData ");"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_TPM_CheckMaintenancePubKey\fR
-checks the public maintenance key. If \fIhMaintenanceKey\fR
-is NULL, then \fIpValidationData\fR must not be NULL; the caller has to
-proof the digest on its own. If \fIhMaintenanceKey\fR is not NULL, then
-\fIpValidationData\fR must be NULL; the TSS service provider proofs the
-digest got internally from the TPM. The key information required for
-proofing the public maintenance key must be set in the key object by
-Tspi_SetAttribData before this method is called. \fBThis function is
-not yet implemented\fR.
-.SH "PARAMETERS"
-.PP
-.SS hTPM
-Handle of the TPM object
-.PP
-.SS hMaintenanceKey
-Handle of the maintenance key object
-.PP
-.SS pValidationData
-Validation data structure.
-[IN] Provide externalData information required to compute the signature.
-[OUT] On successful completion of the ocmmand, the structure provides a
-buffer containing the validation data and a buffer containing the data
-the validation data was computed from.
-
-.SH "RETURN CODES"
-.PP
-\fBTspi_TPM_CheckMaintenancePubKey\fR returns TSS_SUCCESS on success,
-otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE
-\fIhTPM\fR is not a valid handle.
-.TP
-.SM TSS_E_INTERNAL_ERROR
-An internal SW error has been detected.
-.TP
-.SM TSS_E_BAD_PARAMETER
-One or more of the parameters is incorrect.
-.TP
-.SM TSS_E_NOTIMPL
-The command is not implemented.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_TPM_CheckMaintenancePubKey\fR conforms to the Trusted Computing
-Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_TPM_LoadMaintenancePubKey\fR(3),
-\fBTspi_TPM_CreateMaintenanceArchive\fR(3),
-\fBTspi_TPM_KillMaintenanceFeature\fR(3).
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_TPM_CheckMaintenancePubKey" 3 "2004-05-26" "TSS 1.1"
+.ce 1
+TCG Software Stack Developer's Reference
+.SH NAME
+Tspi_TPM_CheckMaintenancePubKey\- check the public maintenance key
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_TPM_CheckMaintenancePubKey(TSS_HTPM        " hTPM ", TSS_HKEY " hMaintenanceKey ","
+.BI "                                           TSS_VALIDATION* " pValidationData ");"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_TPM_CheckMaintenancePubKey\fR
+checks the public maintenance key. If \fIhMaintenanceKey\fR
+is NULL, then \fIpValidationData\fR must not be NULL; the caller has to
+proof the digest on its own. If \fIhMaintenanceKey\fR is not NULL, then
+\fIpValidationData\fR must be NULL; the TSS service provider proofs the
+digest got internally from the TPM. The key information required for
+proofing the public maintenance key must be set in the key object by
+Tspi_SetAttribData before this method is called. \fBThis function is
+not yet implemented\fR.
+.SH "PARAMETERS"
+.PP
+.SS hTPM
+Handle of the TPM object
+.PP
+.SS hMaintenanceKey
+Handle of the maintenance key object
+.PP
+.SS pValidationData
+Validation data structure.
+[IN] Provide externalData information required to compute the signature.
+[OUT] On successful completion of the ocmmand, the structure provides a
+buffer containing the validation data and a buffer containing the data
+the validation data was computed from.
+
+.SH "RETURN CODES"
+.PP
+\fBTspi_TPM_CheckMaintenancePubKey\fR returns TSS_SUCCESS on success,
+otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE
+\fIhTPM\fR is not a valid handle.
+.TP
+.SM TSS_E_INTERNAL_ERROR
+An internal SW error has been detected.
+.TP
+.SM TSS_E_BAD_PARAMETER
+One or more of the parameters is incorrect.
+.TP
+.SM TSS_E_NOTIMPL
+The command is not implemented.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_TPM_CheckMaintenancePubKey\fR conforms to the Trusted Computing
+Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_TPM_LoadMaintenancePubKey\fR(3),
+\fBTspi_TPM_CreateMaintenanceArchive\fR(3),
+\fBTspi_TPM_KillMaintenanceFeature\fR(3).
+
diff --git a/man/man3/Tspi_TPM_GetEvent.3 b/man/man3/Tspi_TPM_GetEvent.3
index 5a5d77a..3b0c994 100644
--- a/man/man3/Tspi_TPM_GetEvent.3
+++ b/man/man3/Tspi_TPM_GetEvent.3
@@ -1,80 +1,80 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_TPM_GetEvent" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_TPM_GetEvent\- get a PCR event for a given PCR index and event number.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_TPM_GetEvent(TSS_HTPM " hTPM ",          UINT32         " ulPcrIndex ","
-.BI "                             UINT32   " ulEventNumber ", TSS_PCR_EVENT* " pPcrEvent ");"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_TPM_GetEvent\fR provides a PCR event for a given PCR index and event number.
-.SH "PARAMETERS"
-.PP
-.SS hTPM
-Handle of the TPM object.
-.PP 
-.SS ulPcrIndex
-Index of the PCR to request.
-.PP
-.SS ulEventNumber
-Index of the event to request.
-.PP
-.SS pPcrEvent
-Receives the PCR event data.
-.SH "RETURN CODES"
-.PP
-\fBTspi_TPM_GetEvent\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE
-\fBhTPM\fR is not a valid handle to the TPM object.
-.TP
-.SM TSS_E_INTERNAL_ERROR
-An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_TPM_GetEvent\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_TPM_GetEvents\fR(3) \fBTspi_TPM_GetEventLog\fR(3).
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_TPM_GetEvent" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_TPM_GetEvent\- get a PCR event for a given PCR index and event number.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_TPM_GetEvent(TSS_HTPM " hTPM ",          UINT32         " ulPcrIndex ","
+.BI "                             UINT32   " ulEventNumber ", TSS_PCR_EVENT* " pPcrEvent ");"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_TPM_GetEvent\fR provides a PCR event for a given PCR index and event number.
+.SH "PARAMETERS"
+.PP
+.SS hTPM
+Handle of the TPM object.
+.PP 
+.SS ulPcrIndex
+Index of the PCR to request.
+.PP
+.SS ulEventNumber
+Index of the event to request.
+.PP
+.SS pPcrEvent
+Receives the PCR event data.
+.SH "RETURN CODES"
+.PP
+\fBTspi_TPM_GetEvent\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE
+\fBhTPM\fR is not a valid handle to the TPM object.
+.TP
+.SM TSS_E_INTERNAL_ERROR
+An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_TPM_GetEvent\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_TPM_GetEvents\fR(3) \fBTspi_TPM_GetEventLog\fR(3).
+
+
+
diff --git a/man/man3/Tspi_TPM_GetEventLog.3 b/man/man3/Tspi_TPM_GetEventLog.3
index c6cfb84..8486ef8 100644
--- a/man/man3/Tspi_TPM_GetEventLog.3
+++ b/man/man3/Tspi_TPM_GetEventLog.3
@@ -1,78 +1,78 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_TPM_GetEventLog" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_TPM_GetEventLog\- get the entire PCR event log.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_TPM_GetEventLog(TSS_HTPM        " hTPM ", UINT32* " pulEventNumber ","
-.BI "                                TSS_PCR_EVENT** " prgPcrEvents ");"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_TPM_GetEventLog\fR provides the whole event log that was used to create all of the PCRs. 
-.SH "PARAMETERS"
-.PP
-.SS hTPM
-Handle of the TPM object.
-.PP 
-.SS pulEventNumber
-Receives number of returned event data structures in prgPcrEvents parameter.
-.PP
-.SS prgPcrEvents
-Receives a pointer to an array of PCR event data.
-If NULL, only the numberof elements is returned in pulEventNumber parameter.
-.SH "RETURN CODES"
-.PP
-\fBTspi_TPM_GetEventLog\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE
-\fBhTPM\fR is not a valid handle to the TPM object.
-.TP
-.SM TSS_E_INTERNAL_ERROR
-An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_TPM_GetEventLog\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_TPM_GetEvent\fR(3) \fBTspi_TPM_GetEvents\fR(3).
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_TPM_GetEventLog" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_TPM_GetEventLog\- get the entire PCR event log.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_TPM_GetEventLog(TSS_HTPM        " hTPM ", UINT32* " pulEventNumber ","
+.BI "                                TSS_PCR_EVENT** " prgPcrEvents ");"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_TPM_GetEventLog\fR provides the whole event log that was used to create all of the PCRs. 
+.SH "PARAMETERS"
+.PP
+.SS hTPM
+Handle of the TPM object.
+.PP 
+.SS pulEventNumber
+Receives number of returned event data structures in prgPcrEvents parameter.
+.PP
+.SS prgPcrEvents
+Receives a pointer to an array of PCR event data.
+If NULL, only the numberof elements is returned in pulEventNumber parameter.
+.SH "RETURN CODES"
+.PP
+\fBTspi_TPM_GetEventLog\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE
+\fBhTPM\fR is not a valid handle to the TPM object.
+.TP
+.SM TSS_E_INTERNAL_ERROR
+An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_TPM_GetEventLog\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_TPM_GetEvent\fR(3) \fBTspi_TPM_GetEvents\fR(3).
+
+
+
diff --git a/man/man3/Tspi_TPM_GetEvents.3 b/man/man3/Tspi_TPM_GetEvents.3
index 83fb368..fe36d17 100644
--- a/man/man3/Tspi_TPM_GetEvents.3
+++ b/man/man3/Tspi_TPM_GetEvents.3
@@ -1,86 +1,86 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_TPM_GetEvents" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_TPM_GetEvents\- get a specific number of PCR events for a given index.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_TPM_GetEvents(TSS_HTPM       " hTPM ",            UINT32  " ulPcrIndex ", "
-.BI "                              UINT32         " ulStartNumber ",   UINT32* " pulEventNumber ", "
-.BI "                              TSS_PCR_EVENT* " prgbPcrEvents ");"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_TPM_GetEvents\fR provides a specific number of PCR events for a given index.
-.SH "PARAMETERS"
-.PP
-.SS hTPM
-Handle of the TPM object.
-.PP
-.SS ulPcrIndex
-Index of the PCR to request.
-.PP
-.SS ulStartNumber
-Indext of the first event to request
-.PP
-.SS pulEventNumber
-[IN] Number of elements to request.
-[OUT] Receives number of returned event data structures in prgbPcrEvents parameter.
-.PP
-.SS prgbPcrEvents
-Receives a pointer to an array of PCR event data.
-If NULL, only the number of elements is returned in pulEventNumber parameter.
-.SH "RETURN CODES"
-.PP
-\fBTspi_TPM_GetEvents\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE
-\fBhTPM\fR is not a valid handle to the TPM object.
-.TP
-.SM TSS_E_INTERNAL_ERROR
-An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_TPM_GetEvents\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_TPM_GetEvent\fR(3) \fBTspi_TPM_GetEventLog\fR(3).
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_TPM_GetEvents" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_TPM_GetEvents\- get a specific number of PCR events for a given index.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_TPM_GetEvents(TSS_HTPM       " hTPM ",            UINT32  " ulPcrIndex ", "
+.BI "                              UINT32         " ulStartNumber ",   UINT32* " pulEventNumber ", "
+.BI "                              TSS_PCR_EVENT* " prgbPcrEvents ");"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_TPM_GetEvents\fR provides a specific number of PCR events for a given index.
+.SH "PARAMETERS"
+.PP
+.SS hTPM
+Handle of the TPM object.
+.PP
+.SS ulPcrIndex
+Index of the PCR to request.
+.PP
+.SS ulStartNumber
+Indext of the first event to request
+.PP
+.SS pulEventNumber
+[IN] Number of elements to request.
+[OUT] Receives number of returned event data structures in prgbPcrEvents parameter.
+.PP
+.SS prgbPcrEvents
+Receives a pointer to an array of PCR event data.
+If NULL, only the number of elements is returned in pulEventNumber parameter.
+.SH "RETURN CODES"
+.PP
+\fBTspi_TPM_GetEvents\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE
+\fBhTPM\fR is not a valid handle to the TPM object.
+.TP
+.SM TSS_E_INTERNAL_ERROR
+An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_TPM_GetEvents\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_TPM_GetEvent\fR(3) \fBTspi_TPM_GetEventLog\fR(3).
+
+
+
diff --git a/man/man3/Tspi_TPM_GetTestResult.3 b/man/man3/Tspi_TPM_GetTestResult.3
index d259409..15818e7 100644
--- a/man/man3/Tspi_TPM_GetTestResult.3
+++ b/man/man3/Tspi_TPM_GetTestResult.3
@@ -1,76 +1,76 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_TPM_GetTestResult" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_TPM_GetTestResult\- get manufacturer specific information regarding the results of a self test.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_TPM_GetTestResult(TSS_HTPM " hTPM ", UINT32* " pulTestResultLength ", BYTE** " prgbTestResult ");"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_TPM_GetTestResult\fR is provided by a manufacturer of a TPM to provide manufacturer specific self test results.
-.SH "PARAMETERS"
-.PP
-.SS hTPM
-Handle of the TPM object
-.PP 
-.SS pulTestREsultLength
-Receives the length (in bytes) of the prgbTestResult parameter
-.PP
-.SS prgbTestResult
-Pointer to the memory block containing the TPM manufacturer specific information.
-.SH "RETURN CODES"
-.PP
-\fBTspi_TPM_GetTestResult\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE
-\fBhTPM\fR is not a valid handle to the TPM object.
-.TP
-.SM TSS_E_INTERNAL_ERROR
-An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_TPM_GetTestResult\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_TPM_SelfTestFull\fR(3).
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_TPM_GetTestResult" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_TPM_GetTestResult\- get manufacturer specific information regarding the results of a self test.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_TPM_GetTestResult(TSS_HTPM " hTPM ", UINT32* " pulTestResultLength ", BYTE** " prgbTestResult ");"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_TPM_GetTestResult\fR is provided by a manufacturer of a TPM to provide manufacturer specific self test results.
+.SH "PARAMETERS"
+.PP
+.SS hTPM
+Handle of the TPM object
+.PP 
+.SS pulTestREsultLength
+Receives the length (in bytes) of the prgbTestResult parameter
+.PP
+.SS prgbTestResult
+Pointer to the memory block containing the TPM manufacturer specific information.
+.SH "RETURN CODES"
+.PP
+\fBTspi_TPM_GetTestResult\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE
+\fBhTPM\fR is not a valid handle to the TPM object.
+.TP
+.SM TSS_E_INTERNAL_ERROR
+An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_TPM_GetTestResult\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_TPM_SelfTestFull\fR(3).
+
+
+
diff --git a/man/man3/Tspi_TPM_LoadMaintenancePubKey.3 b/man/man3/Tspi_TPM_LoadMaintenancePubKey.3
index 37ced39..9652196 100644
--- a/man/man3/Tspi_TPM_LoadMaintenancePubKey.3
+++ b/man/man3/Tspi_TPM_LoadMaintenancePubKey.3
@@ -1,102 +1,102 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_TPM_LoadMaintenancePubKey" 3 "2004-05-26" "TSS 1.1"
-.ce 1
-TCG Software Stack Developer's Reference
-.SH NAME
-Tspi_TPM_LoadMaintenancePubKey\- load the public maintenance key into the TPM
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_TPM_LoadMaintenancePubKey(TSS_HTPM        " hTPM ", TSS_HKEY " hMaintenanceKey ","
-.BI "                                          TSS_VALIDATION* " pValidationData ");"
-.fi
-.sp
-.ad
-.hy
-
-.SH "DESCRIPTION"
-.PP
-\fBTspi_TPM_LoadMaintenancePubKey\fR
-loads the public maintenance key into the TPM. The
-maintenance key can only be loaded once; any subsequent calls to
-this function will fail. The key information for loading the
-maintenance public key must be set in the key object by
-Tspi_SetAttribData before this method is called. If
-\fIpValidationData\fR is NULL, the TSS service provider proofs the
-digest got internally from the TPM. Otherwise, the caller has to
-proof the digest by its own.
-.SH "PARAMETERS"
-.PP
-.SS hTPM
-Handle of the TPM object
-.PP
-.SS hMaintenanceKey
-Handle of the maintenance key object
-.PP
-.SS pValidationData
-Validation data structure.
-[IN] Provide externalData information required to compute the signature.
-[OUT] On successful completion of the ocmmand, the structure provides a
-buffer containing the validation data and a buffer containing the data
-the validation data was computed from.
-
-.SH "RETURN CODES"
-.PP
-\fBTspi_TPM_LoadMaintenancePubKey\fR returns TSS_SUCCESS on success,
-otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE
-\fIhTPM\fR or \fIhMaintenanceKey\fR is not a valid handle.
-.TP
-.SM TSS_E_INTERNAL_ERROR
-An internal SW error has been detected.
-.TP
-.SM TSS_E_BAD_PARAMETER
-One or more of the parameters is incorrect.
-.TP
-.SM TSS_E_NOTIMPL
-The command is not implemented.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_TPM_LoadMaintenancePubKey\fR conforms to the Trusted Computing
-Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_TPM_CheckMaintenancePubKey\fR(3),
-\fBTspi_TPM_KillMaintenanceFeature\fR(3),
-\fBTspi_TPM_CreateMaintenanceArchive\fR(3).
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_TPM_LoadMaintenancePubKey" 3 "2004-05-26" "TSS 1.1"
+.ce 1
+TCG Software Stack Developer's Reference
+.SH NAME
+Tspi_TPM_LoadMaintenancePubKey\- load the public maintenance key into the TPM
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_TPM_LoadMaintenancePubKey(TSS_HTPM        " hTPM ", TSS_HKEY " hMaintenanceKey ","
+.BI "                                          TSS_VALIDATION* " pValidationData ");"
+.fi
+.sp
+.ad
+.hy
+
+.SH "DESCRIPTION"
+.PP
+\fBTspi_TPM_LoadMaintenancePubKey\fR
+loads the public maintenance key into the TPM. The
+maintenance key can only be loaded once; any subsequent calls to
+this function will fail. The key information for loading the
+maintenance public key must be set in the key object by
+Tspi_SetAttribData before this method is called. If
+\fIpValidationData\fR is NULL, the TSS service provider proofs the
+digest got internally from the TPM. Otherwise, the caller has to
+proof the digest by its own.
+.SH "PARAMETERS"
+.PP
+.SS hTPM
+Handle of the TPM object
+.PP
+.SS hMaintenanceKey
+Handle of the maintenance key object
+.PP
+.SS pValidationData
+Validation data structure.
+[IN] Provide externalData information required to compute the signature.
+[OUT] On successful completion of the ocmmand, the structure provides a
+buffer containing the validation data and a buffer containing the data
+the validation data was computed from.
+
+.SH "RETURN CODES"
+.PP
+\fBTspi_TPM_LoadMaintenancePubKey\fR returns TSS_SUCCESS on success,
+otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE
+\fIhTPM\fR or \fIhMaintenanceKey\fR is not a valid handle.
+.TP
+.SM TSS_E_INTERNAL_ERROR
+An internal SW error has been detected.
+.TP
+.SM TSS_E_BAD_PARAMETER
+One or more of the parameters is incorrect.
+.TP
+.SM TSS_E_NOTIMPL
+The command is not implemented.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_TPM_LoadMaintenancePubKey\fR conforms to the Trusted Computing
+Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_TPM_CheckMaintenancePubKey\fR(3),
+\fBTspi_TPM_KillMaintenanceFeature\fR(3),
+\fBTspi_TPM_CreateMaintenanceArchive\fR(3).
+
+
+
diff --git a/man/man3/Tspi_TPM_Quote.3 b/man/man3/Tspi_TPM_Quote.3
index 6ce85b0..42b1be4 100644
--- a/man/man3/Tspi_TPM_Quote.3
+++ b/man/man3/Tspi_TPM_Quote.3
@@ -1,83 +1,83 @@
-.\" Copyright (C) 2004 International Business Machines Corporation
-.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
-.\"
-.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 "Tspi_TPM_Quote" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_TPM_Quote \- retreive a signed set of PCR values.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_TPM_Quote(TSS_HTPM  " hTPM ",          TSS_HKEY        " hIdentKey ","
-.BI "                          TSS_HPCRS " hPcrComposite ", TSS_VALIDATION* " pValidationData ");"
-.fi
-.sp
-.ad
-.hy
-.SH "DESCRIPTION"
-.PP
-\fBTspi_TPM_Quote\fR destroys a context by passing in the handle to that context.
-.SH "PARAMETERS"
-.PP
-.SS hTPM
-Handle of the TPM object.
-.PP
-.SS hIdentKey
-Handle of the signature key object.
-.PP
-.SS hPcrComposite
-Handle of the PCR composite object
-.PP
-.SS pValidationData
-Validation data structure
-[IN] Provide externalData information required to compute the signature.
-[OUT] On successful completion of the command, the structure provides a buffer containing the validation data and a buffer containing the data the validation data was computed form.
-.PP 
-
-.SH "RETURN CODES"
-.PP
-\fBTspi_TPM_Quote\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - \fIhTPM\fR, \fIhIdentKey\fR or \fIhPcrComposite\fR is not a valid handle.
-.TP
-.SM TSS_E_BAD_PARAMETER
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_TPM_Quote\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
-.SH "SEE ALSO"
-
-.PP
-\fB(none)\fR.
-
-
-
+.\" Copyright (C) 2004 International Business Machines Corporation
+.\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
+.\"
+.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 "Tspi_TPM_Quote" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_TPM_Quote \- retreive a signed set of PCR values.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_TPM_Quote(TSS_HTPM  " hTPM ",          TSS_HKEY        " hIdentKey ","
+.BI "                          TSS_HPCRS " hPcrComposite ", TSS_VALIDATION* " pValidationData ");"
+.fi
+.sp
+.ad
+.hy
+.SH "DESCRIPTION"
+.PP
+\fBTspi_TPM_Quote\fR destroys a context by passing in the handle to that context.
+.SH "PARAMETERS"
+.PP
+.SS hTPM
+Handle of the TPM object.
+.PP
+.SS hIdentKey
+Handle of the signature key object.
+.PP
+.SS hPcrComposite
+Handle of the PCR composite object
+.PP
+.SS pValidationData
+Validation data structure
+[IN] Provide externalData information required to compute the signature.
+[OUT] On successful completion of the command, the structure provides a buffer containing the validation data and a buffer containing the data the validation data was computed form.
+.PP 
+
+.SH "RETURN CODES"
+.PP
+\fBTspi_TPM_Quote\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - \fIhTPM\fR, \fIhIdentKey\fR or \fIhPcrComposite\fR is not a valid handle.
+.TP
+.SM TSS_E_BAD_PARAMETER
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_TPM_Quote\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
+.SH "SEE ALSO"
+
+.PP
+\fB(none)\fR.
+
+
+
diff --git a/man/man3/Tspi_TPM_Quote2.3 b/man/man3/Tspi_TPM_Quote2.3
index 30cb1c0..aab3d33 100644
--- a/man/man3/Tspi_TPM_Quote2.3
+++ b/man/man3/Tspi_TPM_Quote2.3
@@ -1,100 +1,100 @@
-.\" Copyright (C) 2007 International Business Machines Corporation
-.\" Written by Ramon Brandão based on the Trusted Computing Group Software Stack Specification Version 1.2
-.\"
-.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 "Tspi_TPM_Quote2" 3 "2007-04-03" "TSS 1.2" "TCG Software Stack Developer's Reference"
-.SH NAME
-Tspi_TPM_Quote2 \- retreive a signed set of PCR values with a more complete view than Tspi_TPM_Quote.
-.SH "SYNOPSIS"
-.ad l
-.hy 0
-.nf
-.B #include <tss/platform.h>
-.B #include <tss/tcpa_defines.h>
-.B #include <tss/tcpa_typedef.h>
-.B #include <tss/tcpa_struct.h>
-.B #include <tss/tss_typedef.h>
-.B #include <tss/tss_structs.h>
-.B #include <tss/tspi.h>
-.sp
-.BI "TSS_RESULT Tspi_TPM_Quote2(TSS_HTPM  " hTPM ",          TSS_HKEY        " hIdentKey ","
-.BI "                          TSS_BOOL   " fAddVersion ",     TSS_HPCRS   " hPcrComposite ","
-.BI "                          TSS_VALIDATION* " pValidationData ", UINT32* " versionInfoSize ","
-.BI "                          BYTE**  " versionInfo ");"
-.fi
-.sp
-.ad
-.hy
-.SH "DESCRIPTION"
-.PP
-\fBTspi_TPM_Quote2\fR quotes a TCG system, providing the requestor 
-with a more complete view of the current platform configuration,
-than \fBTspi_TPM_Quote\fR.
-
-.SH "PARAMETERS"
-.PP
-.SS hTPM
-Handle of the TPM object.
-.PP
-.SS hIdentKey
-Handle of the signature key object.
-.PP
-.SS fAddVersion
-If TRUE, the TPM version is added to the output. If FALSE, the TPM version 
-isn't added to the output.
-.PP
-.SS hPcrComposite
-Handle of the PCR composite object, which contains the PCRs to be quoted.
-.PP
-.SS pValidationData
-Validation data structure
-[IN] Provide externalData information required to compute the signature.
-[OUT] On successful completion of the command, the structure provides a buffer containing the validation data and a buffer containing the data the validation data was computed form.
-.PP
-.SS versionInfoSize
-The size of the bytestream returned by versionInfo. If the \fIfAddVersion\fR is False
-this is zero.
-.PP
-.SS versionInfo
-The version information returned as a byte stream reflecting the data in 
-TSS_CAP_VERSION_INFO if the fAddVersion is TRUE. Else it's NULL.
-.PP 
-
-.SH "RETURN CODES"
-.PP
-\fBTspi_TPM_Quote\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
-.TP
-.SM TSS_E_INVALID_HANDLE - \fIhTPM\fR, \fIhIdentKey\fR or \fIhPcrComposite\fR is not a valid handle.
-.TP
-.SM TSS_E_BAD_PARAMETER
-.TP
-.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
-
-.SH "CONFORMING TO"
-
-.PP
-\fBTspi_TPM_Quote2\fR conforms to the Trusted Computing Group Software Specification version 1.2
-.SH "SEE ALSO"
-
-.PP
-\fBTspi_TPM_Quote\fR(3).
-
-
-
+.\" Copyright (C) 2007 International Business Machines Corporation
+.\" Written by Ramon Brandão based on the Trusted Computing Group Software Stack Specification Version 1.2
+.\"
+.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 "Tspi_TPM_Quote2" 3 "2007-04-03" "TSS 1.2" "TCG Software Stack Developer's Reference"
+.SH NAME
+Tspi_TPM_Quote2 \- retreive a signed set of PCR values with a more complete view than Tspi_TPM_Quote.
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.nf
+.B #include <tss/platform.h>
+.B #include <tss/tcpa_defines.h>
+.B #include <tss/tcpa_typedef.h>
+.B #include <tss/tcpa_struct.h>
+.B #include <tss/tss_typedef.h>
+.B #include <tss/tss_structs.h>
+.B #include <tss/tspi.h>
+.sp
+.BI "TSS_RESULT Tspi_TPM_Quote2(TSS_HTPM  " hTPM ",          TSS_HKEY        " hIdentKey ","
+.BI "                          TSS_BOOL   " fAddVersion ",     TSS_HPCRS   " hPcrComposite ","
+.BI "                          TSS_VALIDATION* " pValidationData ", UINT32* " versionInfoSize ","
+.BI "                          BYTE**  " versionInfo ");"
+.fi
+.sp
+.ad
+.hy
+.SH "DESCRIPTION"
+.PP
+\fBTspi_TPM_Quote2\fR quotes a TCG system, providing the requestor 
+with a more complete view of the current platform configuration,
+than \fBTspi_TPM_Quote\fR.
+
+.SH "PARAMETERS"
+.PP
+.SS hTPM
+Handle of the TPM object.
+.PP
+.SS hIdentKey
+Handle of the signature key object.
+.PP
+.SS fAddVersion
+If TRUE, the TPM version is added to the output. If FALSE, the TPM version 
+isn't added to the output.
+.PP
+.SS hPcrComposite
+Handle of the PCR composite object, which contains the PCRs to be quoted.
+.PP
+.SS pValidationData
+Validation data structure
+[IN] Provide externalData information required to compute the signature.
+[OUT] On successful completion of the command, the structure provides a buffer containing the validation data and a buffer containing the data the validation data was computed form.
+.PP
+.SS versionInfoSize
+The size of the bytestream returned by versionInfo. If the \fIfAddVersion\fR is False
+this is zero.
+.PP
+.SS versionInfo
+The version information returned as a byte stream reflecting the data in 
+TSS_CAP_VERSION_INFO if the fAddVersion is TRUE. Else it's NULL.
+.PP 
+
+.SH "RETURN CODES"
+.PP
+\fBTspi_TPM_Quote\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
+.TP
+.SM TSS_E_INVALID_HANDLE - \fIhTPM\fR, \fIhIdentKey\fR or \fIhPcrComposite\fR is not a valid handle.
+.TP
+.SM TSS_E_BAD_PARAMETER
+.TP
+.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
+
+.SH "CONFORMING TO"
+
+.PP
+\fBTspi_TPM_Quote2\fR conforms to the Trusted Computing Group Software Specification version 1.2
+.SH "SEE ALSO"
+
+.PP
+\fBTspi_TPM_Quote\fR(3).
+
+
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 85dc2ea..529e00f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1 +1,7 @@
-SUBDIRS = trspi tddl tcs tspi tcsd include
+SUBDIRS =
+
+if OS_WIN32
+SUBDIRS += win32
+endif
+
+SUBDIRS += trspi tddl tcs tspi tcsd include
diff --git a/src/include/flock.h b/src/include/flock.h
new file mode 100644
index 0000000..f28a428
--- /dev/null
+++ b/src/include/flock.h
@@ -0,0 +1,21 @@
+#ifndef _FLOCK_H_
+#define _FLOCK_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Operations for the 'flock' call (same as Linux kernel constants).  */
+# define LOCK_SH 1       /* Shared lock.  */
+# define LOCK_EX 2       /* Exclusive lock.  */
+# define LOCK_UN 8       /* Unlock.  */
+
+/* Can be OR'd in to one of the above.  */
+# define LOCK_NB 4       /* Don't block when locking.  */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _FLOCK_H_ */
diff --git a/src/include/libc_interface.h b/src/include/libc_interface.h
new file mode 100644
index 0000000..ebba365
--- /dev/null
+++ b/src/include/libc_interface.h
@@ -0,0 +1,170 @@
+/*
+ * purple
+ *
+ * File: libc_interface.h
+ *
+ * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com>
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ *
+ */
+#ifndef _LIBC_INTERFACE_H_
+#define _LIBC_INTERFACE_H_
+#include "libc_internal.h"
+//#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifdef _MSC_VER
+#define S_IRUSR S_IREAD
+#define S_IWUSR S_IWRITE
+#define S_IXUSR S_IEXEC
+
+#define S_ISDIR(m)	 (((m)&S_IFDIR)==S_IFDIR)
+
+#define F_OK 0
+#endif
+
+#ifdef WIN32
+#define UINT16_MAX 0xffff
+#endif
+
+/* sys/socket.h */
+#define socket( domain, style, protocol ) \
+wpurple_socket( domain, style, protocol )
+
+#define connect( socket, addr, length ) \
+wpurple_connect( socket, addr, length )
+
+#define getsockopt( socket, level, optname, optval, optlenptr ) \
+wpurple_getsockopt( socket, level, optname, optval, optlenptr )
+
+#define setsockopt( socket, level, optname, optval, optlen ) \
+wpurple_setsockopt( socket, level, optname, optval, optlen )
+
+#define getsockname( socket, addr, lenptr ) \
+wpurple_getsockname( socket, addr, lenptr )
+
+#define bind( socket, addr, length ) \
+wpurple_bind( socket, addr, length )
+
+#define listen( socket, n ) \
+wpurple_listen( socket, n )
+
+#define sendto(socket, buf, len, flags, to, tolen) \
+wpurple_sendto(socket, buf, len, flags, to, tolen)
+
+#define recv(fd, buf, len, flags) \
+wpurple_recv(fd, buf, len, flags)
+
+#define send(socket, buf, buflen, flags) \
+wpurple_send(socket, buf, buflen, flags)
+
+/* sys/ioctl.h */
+#define ioctl( fd, command, val ) \
+wpurple_ioctl( fd, command, val )
+
+/* fcntl.h */
+#define fcntl( fd, command, ... ) \
+wpurple_fcntl( fd, command, ##__VA_ARGS__ )
+
+/* arpa/inet.h */
+#define inet_aton( name, addr ) \
+wpurple_inet_aton( name, addr )
+
+#define inet_ntop( af, src, dst, cnt ) \
+wpurple_inet_ntop( af, src, dst, cnt )
+
+/* netdb.h */
+#define gethostbyname( name ) \
+wpurple_gethostbyname( name )
+
+/* netinet/in.h */
+#define ntohl( netlong ) \
+(unsigned int)ntohl( netlong )
+
+/* string.h */
+#define hstrerror( herror ) \
+wpurple_strerror( errno )
+#define strerror( errornum ) \
+wpurple_strerror( errornum )
+#define g_strerror( errornum ) \
+wpurple_strerror( errornum )
+
+/* unistd.h */
+#define read( fd, buf, buflen ) \
+wpurple_read( fd, buf, buflen )
+
+#define write( socket, buf, buflen ) \
+wpurple_write( socket, buf, buflen )
+
+#define close( fd ) \
+wpurple_close( fd )
+
+#ifndef sleep
+#define sleep(x) Sleep((x)*1000)
+#endif
+
+#define gethostname( name, size ) \
+wpurple_gethostname( name, size )
+
+#define fsync(fd) _commit(fd)
+
+/* sys/time.h */
+#define gettimeofday( timeval, timezone ) \
+wpurple_gettimeofday( timeval, timezone )
+
+/* stdio.h */
+#undef snprintf
+#define snprintf _snprintf
+//#undef vsnprintf
+//#define vsnprintf _vsnprintf
+
+//#define rename( oldname, newname ) wpurple_rename( oldname, newname )
+
+/* sys/stat.h */
+#define fchmod(a,b)
+
+/* time.h */
+//#define localtime_r( time, resultp ) wpurple_localtime_r( time, resultp )
+
+#define flock( fd, operation ) \
+trousers_flock( fd, operation )
+
+#define strncasecmp( s1, s2, n ) \
+trousers_strncasecmp( s1, s2, n )
+
+#define strcasecmp( s1, s2 ) \
+trousers_strcasecmp( s1, s2 )
+
+#define ftruncate( fd, head_offset ) \
+_chsize( fd, head_offset )
+
+#define mlock( addr, len ) \
+trousers_mlock( addr, len)
+
+#define munlock( addr, len ) \
+trousers_munlock( addr, len)
+
+#define mkdir( path, mask ) \
+_mkdir( path )
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _LIBC_INTERFACE_H_ */
diff --git a/src/include/libc_internal.h b/src/include/libc_internal.h
new file mode 100644
index 0000000..675445c
--- /dev/null
+++ b/src/include/libc_internal.h
@@ -0,0 +1,156 @@
+/*
+ * purple
+ *
+ * File: libc_internal.h
+ *
+ * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com>
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ *
+ */
+#ifndef _LIBC_INTERNAL_
+#define _LIBC_INTERNAL_
+//#include <glib.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* helper for purple_utf8_strftime() by way of purple_internal_strftime() in src/util.c */
+//const char *wpurple_get_timezone_abbreviation(const struct tm *tm);
+
+/* sys/socket.h */
+int wpurple_socket(int domain, int style, int protocol);
+int wpurple_connect(int socket, struct sockaddr *addr, u_long length);
+int wpurple_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr);
+int wpurple_setsockopt(int socket, int level, int optname, const void *optval, socklen_t optlen);
+int wpurple_getsockname (int socket, struct sockaddr *addr, socklen_t *lenptr);
+int wpurple_bind(int socket, struct sockaddr *addr, socklen_t length);
+int wpurple_listen(int socket, unsigned int n);
+int wpurple_sendto(int socket, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
+int wpurple_recv(int fd, void *buf, size_t len, int flags);
+int wpurple_send(int fd, const void *buf, unsigned int size, int flags);
+
+/* arpa/inet.h */
+int wpurple_inet_aton(const char *name, struct in_addr *addr);
+const char *
+wpurple_inet_ntop (int af, const void *src, char *dst, socklen_t cnt);
+
+/* netdb.h */
+struct hostent* wpurple_gethostbyname(const char *name);
+
+/* string.h */
+char* wpurple_strerror( int errornum );
+
+/* fcntl.h */
+int wpurple_fcntl(int socket, int command, ...);
+#define F_GETFL 3
+#define F_SETFL 4
+#define O_NONBLOCK 04000
+
+/* sys/ioctl.h */
+#define SIOCGIFCONF 0x8912 /* get iface list */
+int wpurple_ioctl(int fd, int command, void* opt);
+
+/* net/if.h */
+struct ifreq
+{
+	union
+	{
+		char ifrn_name[6];	/* Interface name, e.g. "en0".  */
+	} ifr_ifrn;
+
+	union
+	{
+		struct sockaddr ifru_addr;
+#if 0
+		struct sockaddr ifru_dstaddr;
+		struct sockaddr ifru_broadaddr;
+		struct sockaddr ifru_netmask;
+		struct sockaddr ifru_hwaddr;
+		short int ifru_flags;
+		int ifru_ivalue;
+		int ifru_mtu;
+#endif
+		char *ifru_data;
+	} ifr_ifru;
+};
+# define ifr_name	ifr_ifrn.ifrn_name	/* interface name       */
+# define ifr_addr	ifr_ifru.ifru_addr      /* address              */
+#if 0
+# define ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address          */
+# define ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-p lnk */
+# define ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address    */
+# define ifr_netmask	ifr_ifru.ifru_netmask	/* interface net mask   */
+# define ifr_flags	ifr_ifru.ifru_flags	/* flags                */
+# define ifr_metric	ifr_ifru.ifru_ivalue	/* metric               */
+# define ifr_mtu	ifr_ifru.ifru_mtu	/* mtu                  */
+#endif
+# define ifr_data	ifr_ifru.ifru_data	/* for use by interface */
+#if 0
+# define ifr_ifindex	ifr_ifru.ifru_ivalue	/* interface index      */
+# define ifr_bandwidth	ifr_ifru.ifru_ivalue	/* link bandwidth       */
+# define ifr_qlen	ifr_ifru.ifru_ivalue	/* queue length         */
+#endif
+
+
+struct ifconf
+{
+	int ifc_len;			/* Size of buffer.  */
+	union
+	{
+		char *ifcu_buf;
+		struct ifreq *ifcu_req;
+	} ifc_ifcu;
+};
+# define ifc_buf ifc_ifcu.ifcu_buf /* Buffer address.  */
+# define ifc_req ifc_ifcu.ifcu_req /* Array of structures.  */
+
+/* sys/time.h */
+#if __MINGW32_MAJOR_VERSION < 3 || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION < 10)
+struct timezone {
+	int tz_minuteswest;
+	int tz_dsttime;
+};
+#else
+#    include <sys/time.h>
+#endif
+int wpurple_gettimeofday(struct timeval *p, struct timezone *z);
+
+/* time.h */
+struct tm *wpurple_localtime_r(const time_t *time, struct tm *resultp);
+
+
+/* unistd.h */
+int wpurple_read(int fd, void *buf, unsigned int size);
+int wpurple_write(int fd, const void *buf, unsigned int size);
+int wpurple_close(int fd);
+int wpurple_gethostname(char *name, size_t size);
+
+
+/* stdio.h */
+//int wpurple_rename(const char *oldname, const char *newname);
+int trousers_flock(int fd, int operation);
+int trousers_strncasecmp(char *s1, char *s2, size_t n);
+int trousers_strcasecmp(char *s1, char *s2);
+int trousers_mlock(const void *addr, size_t len);
+int trousers_munlock(const void *addr, size_t len);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _LIBC_INTERNAL_ */
diff --git a/src/include/obj_policy.h b/src/include/obj_policy.h
index 90cd7ec..9686275 100644
--- a/src/include/obj_policy.h
+++ b/src/include/obj_policy.h
@@ -152,6 +152,7 @@ TSS_RESULT obj_policy_set_hash_mode(TSS_HPOLICY, UINT32);
 TSS_RESULT obj_policy_get_xsap_params(TSS_HPOLICY, TPM_COMMAND_CODE, TPM_ENTITY_TYPE *, UINT32 *,
 				      BYTE **, BYTE *, TSS_CALLBACK *, TSS_CALLBACK *,
 				      TSS_CALLBACK *, UINT32 *, TSS_BOOL);
+TSS_RESULT obj_policy_is_secret_set(TSS_HPOLICY, TSS_BOOL *);
 #ifdef TSS_BUILD_DELEGATION
 TSS_RESULT obj_policy_set_delegation_type(TSS_HPOLICY, UINT32);
 TSS_RESULT obj_policy_get_delegation_type(TSS_HPOLICY, UINT32 *);
diff --git a/src/include/spi_utils.h b/src/include/spi_utils.h
index f93e877..52d5fa1 100644
--- a/src/include/spi_utils.h
+++ b/src/include/spi_utils.h
@@ -13,7 +13,9 @@
 #define _SPI_UTILS_H_
 
 #include "threads.h"
+#ifndef WIN32
 #include <netinet/in.h> // for endian routines
+#endif
 
 #include "trousers_types.h"
 #include "trousers/trousers.h"
@@ -125,6 +127,7 @@ TSS_RESULT internal_GetCap(TSS_HCONTEXT, TSS_FLAG, UINT32, UINT32 *, BYTE **);
 #define TSS_LOCALHOST_STRING		"localhost"
 TSS_RESULT get_local_random(TSS_HCONTEXT, TSS_BOOL, UINT32, BYTE **);
 
+#define AUTH_RETRY_MILLISEC	500
 #define AUTH_RETRY_NANOSECS	500000000
 #define AUTH_RETRY_COUNT	5
 #define TPM_AUTH_RQU_SIZE	(sizeof(TPM_AUTHHANDLE) + sizeof(TPM_NONCE) \
diff --git a/src/include/tcs_tsp.h b/src/include/tcs_tsp.h
index bba3258..74a0450 100644
--- a/src/include/tcs_tsp.h
+++ b/src/include/tcs_tsp.h
@@ -79,7 +79,11 @@ struct key_disk_cache
 /* XXX Get rid of this, there's no reason to set an arbitrary limit */
 #define MAX_KEY_CHILDREN	10
 
+#ifdef __GNUC__
 #define STRUCTURE_PACKING_ATTRIBUTE	__attribute__((packed))
+#else
+#define STRUCTURE_PACKING_ATTRIBUTE
+#endif
 
 #ifdef TSS_DEBUG
 #define DBG_ASSERT(x)	assert(x)
diff --git a/src/include/tcsd.h b/src/include/tcsd.h
index 1f72e05..7fb417d 100644
--- a/src/include/tcsd.h
+++ b/src/include/tcsd.h
@@ -48,14 +48,23 @@ struct tcsd_config
 							of this TCS System */
 };
 
+#ifdef WIN32
+#define TCSD_CONFIG_FILE	"C://Trousers//tcsd.conf"
+#else
 #define TCSD_CONFIG_FILE	ETC_PREFIX "/tcsd.conf"
+#endif
 
 #define TSS_USER_NAME		"tss"
 #define TSS_GROUP_NAME		"tss"
 
 #define TCSD_DEFAULT_MAX_THREADS	10
+#ifdef WIN32
+#define TCSD_DEFAULT_SYSTEM_PS_FILE	"C://Trousers//system.data"
+#define TCSD_DEFAULT_SYSTEM_PS_DIR	"C://Trousers"
+#else
 #define TCSD_DEFAULT_SYSTEM_PS_FILE	VAR_PREFIX "/lib/tpm/system.data"
 #define TCSD_DEFAULT_SYSTEM_PS_DIR	VAR_PREFIX "/lib/tpm"
+#endif
 #define TCSD_DEFAULT_FIRMWARE_LOG_FILE	"/sys/kernel/security/tpm0/binary_bios_measurements"
 #define TCSD_DEFAULT_KERNEL_LOG_FILE	"/sys/kernel/security/ima/binary_runtime_measurements"
 #define TCSD_DEFAULT_FIRMWARE_PCRS	0x00000000
@@ -156,7 +165,9 @@ void	   *tcsd_thread_run(void *);
 void	   thread_signal_init();
 
 /* signal handling */
+#ifndef WIN32
 struct sigaction tcsd_sa_int;
 struct sigaction tcsd_sa_chld;
+#endif
 
 #endif
diff --git a/src/include/tcsem.h b/src/include/tcsem.h
index 4b1f215..13ec782 100644
--- a/src/include/tcsem.h
+++ b/src/include/tcsem.h
@@ -15,7 +15,7 @@ struct ext_log_source {
         int (*open)(void *, FILE **);
         TSS_RESULT (*get_entries_by_pcr)(FILE *, UINT32, UINT32, UINT32 *, TSS_PCR_EVENT **);
         TSS_RESULT (*get_entry)(FILE *, UINT32, UINT32 *, TSS_PCR_EVENT **);
-        int (*close)(FILE *);
+        int (*file_close)(FILE *);
 };
 
 struct event_wrapper {
diff --git a/src/include/tcslog.h b/src/include/tcslog.h
index 36fdce0..2b6015d 100644
--- a/src/include/tcslog.h
+++ b/src/include/tcslog.h
@@ -13,7 +13,11 @@
 #define _TCSLOG_H_
 
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#else
+#include "win32dep.h"
+#endif
 
 /* log to syslog -- change your syslog destination here */
 #define TSS_SYSLOG_LVL	LOG_LOCAL5
@@ -22,6 +26,8 @@
 #define __FUNCTION__ __func__
 #endif
 
+#ifndef WIN32
+
 #define LogMessage(dest, priority, layer, fmt, ...) \
         do { \
 		if (getenv("TCSD_FOREGROUND") != NULL) { \
@@ -31,6 +37,22 @@
 			syslog(priority, "TrouSerS " fmt "\n", ## __VA_ARGS__); \
 		} \
         } while (0)
+#else
+#define LOG_DEBUG " "
+#define LOG_ERR " "
+#define LOG_INFO " "
+#define LOG_WARNING " "
+
+#define LogMessage(dest, priority, layer, fmt, ...) \
+        do { \
+		if (getenv("TCSD_FOREGROUND") != NULL) { \
+			fprintf(dest, "%s " fmt "\n", layer, ## __VA_ARGS__); \
+		} else { \
+			trousers_log(layer, fmt "\n", ## __VA_ARGS__); \
+		} \
+        } while (0)
+#endif	/* ifndef WIN32 */
+
 
 /* Debug logging */
 #ifdef TSS_DEBUG
diff --git a/src/include/tcsps.h b/src/include/tcsps.h
index 8754296..6e38acc 100644
--- a/src/include/tcsps.h
+++ b/src/include/tcsps.h
@@ -27,6 +27,9 @@ void		   ps_destroy();
 TSS_RESULT  read_data(int, void *, UINT32);
 TSS_RESULT  write_data(int, void *, UINT32);
 #else
+#ifdef WIN32
+#define inline __inline
+#endif
 inline TSS_RESULT  read_data(int, void *, UINT32);
 inline TSS_RESULT  write_data(int, void *, UINT32);
 #endif
diff --git a/src/include/tddl.h b/src/include/tddl.h
index cf5bb3a..1770cb1 100644
--- a/src/include/tddl.h
+++ b/src/include/tddl.h
@@ -16,6 +16,18 @@
 #include "tcsd_wrap.h"
 #include "tcsd.h"
 
+#ifdef WIN32
+#include <windows.h>
+#ifdef __MINGW32__
+#include <specstrings.h>
+#endif
+#include <tbs.h>
+
+struct tpm_device_node {
+	TBS_HCONTEXT hContext;
+	TBS_CONTEXT_PARAMS contextParams;
+};
+#else
 struct tpm_device_node {
 	char *path;
 #define TDDL_TRANSMIT_IOCTL	1
@@ -23,6 +35,7 @@ struct tpm_device_node {
 	int transmit;
 	int fd;
 };
+#endif
 
 #define TDDL_TXBUF_SIZE		2048
 #define TDDL_UNDEF		-1
diff --git a/src/include/threads.h b/src/include/threads.h
index 3c57144..cb97f44 100644
--- a/src/include/threads.h
+++ b/src/include/threads.h
@@ -31,7 +31,7 @@
 #define COND_SIGNAL(c)		pthread_cond_signal(c)
 
 /* thread abstractions */
-#define THREAD_ID			((THREAD_TYPE)pthread_self())
+#define THREAD_ID			(pthread_self())
 #define THREAD_TYPE			pthread_t
 #define THREAD_JOIN			pthread_join
 #define THREAD_DETACH			pthread_detach
diff --git a/src/include/trousers/trousers.h b/src/include/trousers/trousers.h
index 39d8787..c73b83f 100644
--- a/src/include/trousers/trousers.h
+++ b/src/include/trousers/trousers.h
@@ -11,6 +11,19 @@
 #ifndef _TROUSERS_H_
 #define _TROUSERS_H_
 
+#if !defined( TRSPICALL )
+	#if !defined(WIN32) || defined (TRSP_STATIC)
+	// Linux, or a Win32 static library
+		#define TRSPICALL extern
+	#elif defined (TRSPDLL_EXPORTS)
+	// Win32 DLL build
+		#define TRSPICALL extern __declspec(dllexport)
+	#else
+	// Win32 DLL import
+		#define TRSPICALL extern __declspec(dllimport) 
+	#endif
+#endif /* TSPICALL */
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -251,13 +264,13 @@ BYTE *Trspi_UNICODE_To_Native(BYTE *string, unsigned *len);
 /* Error Functions */
 
 /* return a human readable string based on the result */
-char *Trspi_Error_String(TSS_RESULT);
+TRSPICALL char *Trspi_Error_String(TSS_RESULT);
 
 /* return a human readable error layer ( "tpm", "tddl", etc...) */
-char *Trspi_Error_Layer(TSS_RESULT);
+TRSPICALL char *Trspi_Error_Layer(TSS_RESULT);
 
 /* return just the error code bits of the result */
-TSS_RESULT Trspi_Error_Code(TSS_RESULT);
+TRSPICALL TSS_RESULT Trspi_Error_Code(TSS_RESULT);
 
 #ifdef __cplusplus
 }
diff --git a/src/include/trousers_types.h b/src/include/trousers_types.h
index 1c1d79f..68b9c32 100644
--- a/src/include/trousers_types.h
+++ b/src/include/trousers_types.h
@@ -100,7 +100,11 @@ typedef struct tdTSS_KEY11_HDR {
 typedef struct tdTSS_KEY12_HDR {
 	TPM_STRUCTURE_TAG tag;
 	UINT16 fill;
-} __attribute__((packed)) TSS_KEY12_HDR;
+}
+#ifdef __GNUC__
+  __attribute__((packed))
+#endif
+  TSS_KEY12_HDR;
 
 typedef struct tdTSS_KEY {
 	union {
diff --git a/src/include/tsplog.h b/src/include/tsplog.h
index bb2fa6b..3a4ac7b 100644
--- a/src/include/tsplog.h
+++ b/src/include/tsplog.h
@@ -13,7 +13,9 @@
 #define _TSPLOG_H_
 
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <stdlib.h>
 
 /* Debug logging */
diff --git a/src/include/tspps.h b/src/include/tspps.h
index 17b0aab..58a28e6 100644
--- a/src/include/tspps.h
+++ b/src/include/tspps.h
@@ -18,6 +18,9 @@
 
 TSS_RESULT	   get_file(int *);
 int		   put_file(int);
+#ifdef WIN32
+#define inline
+#endif
 inline TSS_RESULT  read_data(int, void *, UINT32);
 inline TSS_RESULT  write_data(int, void *, UINT32);
 UINT32		   psfile_get_num_keys(int);
diff --git a/src/include/tss/TSP.idl b/src/include/tss/TSP.idl
index 40f95b7..7dc5fd3 100644
--- a/src/include/tss/TSP.idl
+++ b/src/include/tss/TSP.idl
@@ -1,762 +1,762 @@
-/*++
-
-+++TSP.idl
-
-    Interface declarations for the TSS Service Provider 
-    - COM interface for Windows based platforms
-      
---*/
-import "oaidl.idl";		// include ODL base types 
-import "ocidl.idl";
-
-//import the header files from TSS v1.2
-import "tss_typedef.h";
-import "tss_structs.h";
-
-// forward declaration
-interface ITCPAPolicy;
-interface ITCPAKey;
-
-/*
-Missing:
-TSS_RESULT Tspi_Context_Create
-TSS_RESULT Tspi_Context_Close
-TSS_RESULT Tspi_Context_FreeMemory
-*/
-
-    //ITCPAAttrib Interface
-    [
-        local,
-        object,
-        uuid(FBCD9C2E-72CB-47BB-99DD-2317551491DE),
-
-        helpstring("ITCPAAttrib Interface"),
-        pointer_default(unique)
-    ]	
-    interface ITCPAAttrib : IUnknown
-    {
-        [helpstring("method SetAttribUint32")]
-        HRESULT SetAttribUint32([in] TSS_FLAG attribFlag, 
-                                [in] TSS_FLAG subFlags,
-                                [in] UINT32 ulAttrib);
-
-        [helpstring("method GetAttribUint32")]
-        HRESULT GetAttribUint32([in] TSS_FLAG attribFlag, 
-                                [in] TSS_FLAG subFlags,
-                                [out] UINT32* pulAttrib);
-
-        [helpstring("method SetAttribData")]
-        HRESULT SetAttribData([in] TSS_FLAG attribFlag, 
-                              [in] TSS_FLAG subFlags, 
-                              [in] UINT32 ulAttribDataSize, 
-                              [in, ptr, size_is(ulAttribDataSize)] BYTE* pbAttribData);
-
-        [helpstring("method GetAttribData")]
-        HRESULT GetAttribData([in] TSS_FLAG attribFlag, 
-                              [in] TSS_FLAG subFlags, 
-                              [out] UINT32* pulAttribDataSize,
-                              [out, size_is(, *pulAttribDataSize)] BYTE** ppbAttribData);
-    }
-
-    //ITCPAAuth Interface
-    [
-        local,
-        object,
-        uuid(FBCD9C2F-72CB-47BB-99DD-2317551491DE),
-
-        helpstring("ITCPAAuth Interface"),
-        pointer_default(unique)
-    ]	
-    interface ITCPAAuth : IUnknown
-    {
-        [helpstring("method GetPolicyObject")]
-        HRESULT GetPolicyObject([in] TSS_FLAG PolicyType, 
-                                [out] ITCPAPolicy** ppPolicyObject);
-
-        [helpstring("method ChangeAuth")]
-        HRESULT ChangeAuth([in] IUnknown* PpParentObject, 
-                           [in] ITCPAPolicy* PpNewPolicy);
-
-// HRESULT ChangeAuthAsym
-
-    };
-
-    [
-        object,
-        uuid(FBCD9C2D-72CB-47BB-99DD-2317551491DE),
-        helpstring("ITCPAPcrs Interface"),
-        pointer_default(unique)
-    ]
-    interface ITCPAPcrs : IUnknown
-    {
-        [helpstring("method SetPcrValue")]
-        HRESULT SetPcrValue([in] UINT32 ulPCRIndex,
-                            [in] UINT32 ulPcrValueLength,
-                            [in, size_is(ulPcrValueLength)] BYTE* pbPcrValue);
-
-        [helpstring("method GetPcrValue")]
-        HRESULT GetPcrValue([in] UINT32 ulPCRIndex,
-                            [out] UINT32* pulPcrValueLength,
-                            [out, size_is(, *pulPcrValueLength)] BYTE** ppbPcrValue);
-
-        [helpstring("method SelectPcrIndex")]
-        HRESULT SelectPcrIndex([in] UINT32 ulPCRIndex);
-
-    };
-
-    //ITCPAKey Interface
-    [
-        object,
-        uuid(FBCD9C27-72CB-47BB-99DD-2317551491DE),
-    
-        helpstring("ITCPAKey Interface"),
-        pointer_default(unique)
-    ]
-    interface ITCPAKey : IUnknown
-    {
-        [helpstring("method LoadKey")] 
-        HRESULT LoadKey([in] ITCPAKey* pUnwrappingKey);
-
-        [helpstring("method CreateKey")]
-        HRESULT CreateKey([in] ITCPAKey* pUnwrappingKey, 
-                          [in] ITCPAPcrs* pPcrComosite);
-
-        [helpstring("method WrapKey")] 
-        HRESULT WrapKey([in] ITCPAKey* pWrappinKey, 
-                        [in] ITCPAPcrs* pPcrComposite);
-        
-        [helpstring("method CertifyKey")] 
-        HRESULT CertifyKey([in] ITCPAKey* pCertifyingKey,
-                           [in, out, ptr] TSS_VALIDATION* pValidation);
-
-        [helpstring("method GetPubKey")]
-        HRESULT GetPubKey([out] UINT32* pulPubKeyLength,
-                          [out, size_is(, *pulPubKeyLength)] BYTE** ppbPubKey);
-
-        [helpstring("method UnLoadKey")] 
-        HRESULT UnLoadKey();
-    };
-
-    // ITCPAMigration
-    [
-        local,
-        object,
-        uuid(FBCD9C30-72CB-47BB-99DD-2317551491DE),
-    
-        helpstring("ITCPAMigration Interface"),
-        pointer_default(unique)
-    ]
-    interface ITCPAMigration : IUnknown
-    {
-        [helpstring("method CreateMigrationBlob")] 
-        HRESULT CreateMigrationBlob([in] ITCPAKey *pParentKey, 
-                                    [in] UINT32 ulMigTicketLength, 
-                                    [in, size_is(ulMigTicketLength)] BYTE* rgbMigTicket, 
-                                    [out] UINT32 *pulRandomLength, 
-                                    [out, size_is(, *pulRandomLength)] BYTE **prgbRandom, 
-                                    [out] UINT32 *pulMigrationBlobLength, 
-                                    [out, size_is(, *pulMigrationBlobLength)] BYTE **prgbMigBlob);
-
-        [helpstring("method ConvertMigrationBlob")] 
-        HRESULT ConvertMigrationBlob([in] ITCPAKey *pParentKey, 
-                                     [in] UINT32 ulRandomLength, 
-                                     [in, size_is(ulRandomLength)] BYTE *rgbRandom, 
-                                     [in] UINT32 ulMigrationBlobLength, 
-                                     [in, size_is(ulMigrationBlobLength)] BYTE *rgbMigBlob);
-    };
-
-    //ITCPAEncData Interface
-    [
-        uuid(FBCD9C29-72CB-47BB-99DD-2317551491DE),
-    
-        helpstring("ITCPAEncData Interface"),
-        pointer_default(unique)
-    ]
-    interface ITCPAEncData : IUnknown
-    {
-        [helpstring("method Seal")]
-        HRESULT Seal([in] ITCPAKey* pEncKey,
-                     [in] UINT32 ulDataLength, 
-                     [in, size_is(ulDataLength)] BYTE* pbData, 
-                     [in] ITCPAPcrs* pPcrComposite);
-
-        [helpstring("method Unseal")] 
-        HRESULT Unseal([in] ITCPAKey* pKey, 
-                       [out] UINT32* pulUnsealedDataLength, 
-                       [out, size_is(, *pulUnsealedDataLength)] BYTE** ppbData);
-
-        [helpstring("method Bind")] 
-        HRESULT Bind([in] ITCPAKey* pEncKey, 
-                     [in] UINT32 ulDataLength, 
-                     [in, size_is(ulDataLength)] BYTE* pbData);
-
-        [helpstring("method Unbind")] 
-        HRESULT Unbind([in] ITCPAKey* pKey, 
-                       [out] UINT32* pulUnboundDataLength, 
-                       [out, size_is(, *pulUnboundDataLength)] BYTE** ppbData);
-
-    };
-
-    //ITCPAHash Interface
-    [
-        local,
-        object,
-        uuid(FBCD9C2B-72CB-47BB-99DD-2317551491DE),
-    
-        helpstring("ITCPAHash Interface"),
-        pointer_default(unique)
-    ]
-    interface ITCPAHash : IUnknown
-    {
-        [helpstring("method SetHashValue")] 
-        HRESULT SetHashValue([in] UINT32 ulHashValueLength, 
-                             [in, size_is(ulHashValueLength)] BYTE* pbHash);
-
-        [helpstring("method GetHashValue")] 
-        HRESULT GetHashValue([out] UINT32* pulHashValueLength, 
-                             [out, size_is(, *pulHashValueLength)] BYTE** ppbHash);
-
-        [helpstring("method UpdateHashValue")] 
-        HRESULT UpdateHashValue([in] UINT32 ulDataLength, 
-                                [in, size_is(ulDataLength)] BYTE* pbData);
-
-        [helpstring("method Sign")] 
-        HRESULT Sign([in] ITCPAKey* pKey, 
-                     [out] UINT32* pulSignatureLength, 
-                     [out, size_is(, *pulSignatureLength)] BYTE** ppbSignature);
-
-        [helpstring("method VerifySignature")] 
-        HRESULT VerifySignature([in] ITCPAKey* pKey, 
-                                [in] UINT32 ulSignatureLength, 
-                                [in, size_is(ulSignatureLength)] BYTE* pbSignature);
-
-    };
-
-    //ITCPAPolicy Interface
-    [
-        uuid(FBCD9C1E-72CB-47BB-99DD-2317551491DE),
-    
-        helpstring("ITCPAPolicy Interface"),
-        pointer_default(unique)
-    ]
-    interface ITCPAPolicy : IUnknown
-    { 
-        [helpstring("method SetSecret")] 
-        HRESULT SetSecret([in] TSS_FLAG SecretMode, 
-                          [in] UINT32 ulSecretLength, 
-                          [in, ptr, size_is(ulSecretLength)] BYTE* pbSecret);
-
-        [helpstring("method FlushSecret")] 
-        HRESULT FlushSecret();
-        
-        [helpstring("method AssignToObject")] 
-        HRESULT AssignToObject([in] IUnknown* pUnkObject);
-
-    };
-
-    //ITCPAAdministration Interface
-    [
-        local,
-        object,
-        uuid(FBCD9C24-72CB-47BB-99DD-2317551491DE),
-
-        helpstring("ITCPAAdministration Interface"),
-        pointer_default(unique)
-    ]	
-    interface ITCPAAdministration : IUnknown
-    {
-        [helpstring("method SelfTestFull")]
-        HRESULT SelfTestFull();
-
-        [helpstring("method GetTestResult")]
-        HRESULT GetTestResult([out] UINT32* pulTestResultLength,
-                              [out, size_is(, *pulTestResultLength)] BYTE** ppbTestResult);
-
-        [helpstring("method CertifySelfTest")]
-        HRESULT CertifySelfTest([in] ITCPAKey* phKey,
-                                [in, out, ptr] TSS_VALIDATION* pValidationData);
-
-        [helpstring("method CreateEndorsementKey")] 
-        HRESULT CreateEndorsementKey([in] ITCPAKey* pEndorsementKey,
-                                     [in, out, ptr] TSS_VALIDATION* pValidation);
-
-        [helpstring("method GetPubEndorsementKey")] 
-        HRESULT GetPubEndorsementKey([in] BOOL fOwnerAuthorized,
-                                     [in, out, ptr] TSS_VALIDATION* pValidation,
-                                     [out] ITCPAKey** ppEndorsementKey);
-
-        [helpstring("method TakeOwnerShip")] 
-        HRESULT TakeOwnerShip([in] ITCPAKey* pKeySRK,
-                              [in] ITCPAKey* pEndorsementKeyPubKey);
-
-        [helpstring("method ClearOwner")] 
-        HRESULT ClearOwner([in] BOOL fForcedClear);
-
-        [helpstring("method SetStatus")] 
-        HRESULT SetStatus([in] TSS_FLAG statusFlag, 
-                          [in] BOOL fTpmState);
-
-        [helpstring("method GetStatus")] 
-        HRESULT GetStatus([in] TSS_FLAG statusFlag, 
-                          [out] BOOL* pfTpmState);
-
-        [helpstring("method AuthorizeMigrationTicket")] 
-        HRESULT AuthorizeMigrationTicket([in] ITCPAKey* pMigrationKey,
-                                         [in] UINT32 MigrationScheme,
-                                         [out] UINT32* pulMigTicketLength,
-                                         [out, size_is(, *pulMigTicketLength)] BYTE** ppbMigTicket);
-    }
-
-    //ITCPAIntegrity Interface
-    [
-        local,
-        object,
-        uuid(FBCD9C22-72CB-47BB-99DD-2317551491DE),
-    
-        helpstring("ITCPAIntegrity Interface"),
-        pointer_default(unique)
-    ]
-    interface ITCPAIntegrity : IUnknown
-    {
-        [helpstring("method PcrExtend")] 
-        HRESULT PcrExtend([in] UINT32 ulPcrIndex,
-                          [in] UINT32 ulPcrDataLength,
-                          [in, size_is(ulPcrDataLength)] BYTE* pbPcrData,
-                          [in, ptr] TSS_PCR_EVENT* pEventInfo,
-                          [out] UINT32* pulPcrValueLength,
-                          [out, size_is(, *pulPcrValueLength)] BYTE** ppbPcrValue);
-
-        [helpstring("method PcrRead")] 
-        HRESULT PcrRead([in] UINT32 ulPcrIndex,
-                        [out] UINT32* pulPcrValueLength,
-                        [out, size_is(, *pulPcrValueLength)] BYTE** ppbPcrValue);
-
-        [helpstring("method DirWrite")] 
-        HRESULT DirWrite([in] UINT32 ulDirIndex, 
-                         [in] UINT32 ulDirDataLength,
-                         [in, size_is(ulDirDataLength)] BYTE* pbDirData);
-
-        [helpstring("method DirRead")] 
-        HRESULT DirRead([in] UINT32 ulDirIndex,
-                        [out] UINT32* pulDirDataLength,
-                        [out, size_is(, *pulDirDataLength)] BYTE** pbDirData);
-
-        [helpstring("method Quote")] 
-        HRESULT Quote([in] ITCPAKey* pIdentKey, 
-                      [in] ITCPAPcrs* pPcrComposite, 
-                      [in, out, ptr] TSS_VALIDATION* pValidation);
-    };
-
-    //ITCPAIdentityCreation Interface
-    [
-      object,
-      uuid(FBCD9C23-72CB-47BB-99DD-2317551491DE),
-
-      helpstring("ITCPAIdentityCreation Interface"),
-      pointer_default(unique)
-    ]   
-    interface ITCPAIdentityCreation: IUnknown
-    {
-        [helpstring("method CollateIdentityRequest")]
-        HRESULT CollateIdentityRequest([in] ITCPAKey* pKeySRK,
-                                       [in] ITCPAKey* pCAPubKey,
-                                       [in] UINT32 ulIdentityLabelLength, 
-                                       [in, size_is(ulIdentityLabelLength)] BYTE* rgbIdentityLabelData,
-                                       [in] ITCPAKey* pIdentityKey,
-                                       [in] TSS_ALGORITHM_ID algID,
-                                       [out] UINT32* pulTCPAIdentityReqLength,
-                                       [out, size_is(, *pulTCPAIdentityReqLength)] BYTE** prgbTCPAIdentityReq);
-
-        [helpstring("method ActivateIdentity")] 
-        HRESULT ActivateIdentity([in] ITCPAKey* pIdentityKey, 
-                                 [in] UINT32 ulAsymCAContentsBlobLength,
-                                 [in, size_is(ulAsymCAContentsBlobLength)] BYTE* rgbAsymCAContentsBlob,
-                                 [in] UINT32 ulSymCAAttestationBlobLength,
-                                 [in, size_is(ulSymCAAttestationBlobLength)] BYTE* rgbSymCAAttestationBlob,
-                                 [out] UINT32* pulCredentialLength,
-                                 [out, size_is(, *pulCredentialLength)] BYTE** prgbCredential);
-    
-    };	// end of ITCPAIdentityCreation
-
-    //ITCPAMaintenance Interface
-    [
-        local,
-        object,
-        uuid(FBCD9C25-72CB-47BB-99DD-2317551491DE),
-
-        helpstring("ITCPAMaintenance Interface"),
-        pointer_default(unique)
-    ]	
-    interface ITCPAMaintenance: IUnknown
-    {
-
-// HRESULT CreateMaintenanceArchive
-// HRESULT KillMaintenanceFeature
-// HRESULT LoadMaintenancePubKey
-// HRESULT CheckMaintenancePubKey
-
-    };
-
-    //ITCPATpm Interface
-    [
-        uuid(FBCD9C21-72CB-47BB-99DD-2317551491DE),
-    
-        helpstring("ITCPATpm Interface"),
-        pointer_default(unique)
-    ]
-    interface ITCPATpm : IUnknown
-    {
-        [helpstring("method GetRandom")] 
-        HRESULT GetRandom([in] UINT32 ulRandomDataLength, 
-                          [out, size_is(, ulRandomDataLength)] BYTE** ppbData);
-
-        [helpstring("method StirRandom")] 
-        HRESULT StirRandom([in] UINT32 ulEntropyDataLength, 
-                           [in, size_is(ulEntropyDataLength)] BYTE* pbData);
-
-        [helpstring("method GetCapability")] 
-        HRESULT GetCapability([in] TSS_FLAG CapArea,
-                              [in] UINT32 ulSubCapLength,
-                              [in, ptr, size_is(ulSubCapLength)] BYTE* pbSubCap,
-                              [out] UINT32* pulRespDataLength,
-                              [out, size_is(, *pulRespDataLength)] BYTE** ppbRespData);
-                               
-        [helpstring("method GetCapabilitySigned")] 
-        HRESULT GetCapabilitySigned([in] ITCPAKey* pKey,
-                            [in] TSS_FLAG CapArea,
-                            [in] UINT32 ulSubCapLength,
-                            [in, ptr, size_is(ulSubCapLength)] BYTE* pbSubCap,
-                            [in, out, ptr] TSS_VALIDATION *pValidation,
-                            [out] UINT32* pulRespDataLength,
-                            [out, size_is(, *pulRespDataLength)] BYTE** ppbRespData);
-
-// HRESULT GetEvent
-// HRESULT GetEvents
-// HRESULT GetEventLog
-
-    };
-
-    //ITCPAPersistentStorage Interface
-    [
-        local,
-        object,
-        uuid(FBCD9C1C-72CB-47BB-99DD-2317551491DE),
-
-        helpstring("ITCPAPersistentStorage Interface"),
-        pointer_default(unique)
-    ]	
-    interface ITCPAPersistentStorage: IUnknown
-    {
-        [helpstring("method LoadKeyByUUID")]
-        HRESULT LoadKeyByUUID([in] TSS_FLAG persistentStorageType,
-                        [in] TSS_UUID uuidData,
-                        [out] ITCPAKey** ppKey);
-
-        [helpstring("method RegisterKey")] 
-        HRESULT RegisterKey([in] ITCPAKey* pKey,
-                      [in] TSS_FLAG persistentStorageType,
-                      [in] TSS_UUID uuidKey, 
-                      [in] TSS_FLAG persistentStorageTypeParent,
-                      [in] TSS_UUID uuidParentKey); 
-
-        [helpstring("method UnregisterKey")]
-        HRESULT UnregisterKey([in] TSS_FLAG persistentStorageType,
-                        [in] TSS_UUID uuidKey,
-                        [out] ITCPAKey** ppKey);
-
-        [helpstring("method DeleteKeyByUUID")] 
-        HRESULT DeleteKeyByUUID([in] TSS_FLAG persistentStorageType,
-                                [in] TSS_UUID uuidData);
-
-        [helpstring("method GetKeyByUUID")] 
-        HRESULT GetKeyByUUID([in] TSS_FLAG persistentStorageType,
-                       [in] TSS_UUID uuidData,
-                       [out] ITCPAKey** ppKey);
-
-        [helpstring("method GetKeyByPublicInfo")] 
-        HRESULT GetKeyByPublicInfo([in] TSS_FLAG persistentStorageType,
-                             [in] TSS_ALGORITHM_ID  ulAlgId,
-                             [in] UINT32 ulPublicInfoLength,
-                             [in, size_is(ulPublicInfoLength)] BYTE* pbPublicInfo,
-                             [out] ITCPAKey** ppKey);
-
-        [helpstring("method GetRegisteredKeysByUUID")] 
-        HRESULT GetRegisteredKeysByUUID([in] TSS_FLAG ulPersistentStorageType,
-                                        [in] LPOLESTR wszKeyGuid,
-                                        [out] UINT32* pulKeyHierarchySize,
-                                        [out, size_is(, *pulKeyHierarchySize)] TSS_KM_KEYINFO** ppKeyHierarchy);
-    }
-
-    //ITCPAContext Interface
-    [
-        local,
-        object,
-        uuid(FBCD9C1B-72CB-47BB-99DD-2317551491DE),
-    
-        helpstring("ITCPAContext Interface"),
-        pointer_default(unique)
-    ]
-    interface ITCPAContext : IUnknown
-    {
-        [helpstring("method Connect")] 
-        HRESULT Connect([in, ptr] LPOLESTR wszRemoteMachine);
-
-        [helpstring("method CreateObject")] 
-        HRESULT CreateObject([in] UINT32 ulObjectType, 
-                             [in] UINT32 ulInitFlags,
-                             [out] IUnknown** ppUnkObject);
-
-// HRESULT CloseObject
-
-
-        [helpstring("method LoadKeyByBlob")]
-        HRESULT LoadKeyByBlob([in] ITCPAKey* pUnwrappingKey,
-                              [in] UINT32 ulBlobLength,
-                              [in, size_is(ulBlobLength)] BYTE* pbBlobData,
-                              [out] ITCPAKey** ppKey);
-
-        [helpstring("method GetTPMObject")] 
-        HRESULT GetTPMObject([out] ITCPATpm** ppTPMObject);
-
-        [helpstring("method GetDefaultPolicy")] 
-        HRESULT GetDefaultPolicy([out] ITCPAPolicy** ppPolicyObject);
-
-        [helpstring("method GetCapability")] 
-        HRESULT GetCapability([in] TSS_FLAG ulCapArea,
-                              [in] UINT32 ulSubCapLength,
-                              [in, ptr, size_is(ulSubCapLength)] BYTE* pbSubCap,
-                              [out] UINT32* pulRespDataLength,
-                              [out, size_is(, *pulRespDataLength)] BYTE** ppbRespData);
-    };
-
-    //ITCPANonVolatileStorage Interface
-    [
-        object,
-        uuid(4730c51b-8998-43f6-993b-80befea1d404),
-    
-        helpstring("ITCPANonVolatileStorage Interface"),
-        pointer_default(unique)
-    ]
-    interface ITCPANonVolatileStorage : IUnknown
-    {
-        [helpstring("method DefineSpace")]
-        HRESULT DefineSpace([in] ITCPAPcrs* pPCRsRead,
-                            [in] ITCPAPcrs* pPCRsWrite);
-
-        [helpstring("method ReleaseSpace")] 
-        HRESULT ReleaseSpace();
-
-        [helpstring("method WriteValue")] 
-        HRESULT WriteValue([in] UINT32 ulOffset,
-                           [in] UINT32 ulDataLength,
-                           [in, size_is(ulDataLength)] BYTE* rgbData);
-
-        [helpstring("method ReadValue")] 
-        HRESULT ReadValue([in] UINT32 ulOffset,
-                          [in, out] UINT32* pulDataLength,
-                          [out, size_is(, *pulDataLength)] BYTE** prgbData);
-    };
-
-    //ITCPATransport Interface
-    [
-        object,
-        uuid(4730c51d-8998-43f6-993b-80befea1d404),
-    
-        helpstring("ITCPATransport Interface"),
-        pointer_default(unique)
-    ]
-    interface ITCPATransport : IUnknown
-    {
-        [helpstring("method SetTransEncryptionKey")]
-        HRESULT SetTransEncryptionKey([in] ITCPAKey* pKey);
-
-        [helpstring("method CloseSignTransport")] 
-        HRESULT CloseSignTransport([in] ITCPAKey* pSigningKey,
-                                   [in, out, ptr] TSS_VALIDATION* pValidationData);
-    };
-
-[
-    uuid(FBCD9C19-72CB-47BB-99DD-2317551491DE),
-    version(1.0),
-    helpstring("TSS Service Provider 1.0 Type Library")
-]
-library TSPLib
-{
-    importlib("stdole32.tlb");
-    importlib("stdole2.tlb");
-
-    interface ITCPAContext;
-    //TCPAContext Class
-    [
-        uuid(FBCD9C1A-72CB-47BB-99DD-2317551491DE),
-        helpstring("TCPAContext Class")
-    ]
-    coclass TCPAContext
-    {
-        [default] interface ITCPAContext;
-        interface ITCPAAttrib;
-        interface ITCPAPersistentStorage;
-    };
-
-    //TCPAContext2 Class extensions for TSS v1.2
-    [
-        uuid(4730C51E-8998-43F6-993B-80BEFEA1D404),
-        helpstring("TCPAContext2 Class")
-    ]
-    coclass TCPAContext2
-    {
-        [default] interface ITCPAContext;
-        interface ITCPAAttrib;
-        interface ITCPAPersistentStorage;
-        interface ITCPATransport;
-    };
-
-    // _ITCPACallback Interface for TCPAPolicy Class
-    [
-        uuid(FBCD9C1F-72CB-47BB-99DD-2317551491DE),
-        helpstring("_ITCPACallback Interface"),
-        pointer_default(unique)
-    ]
-    interface _ITCPACallback : IUnknown
-    {
-        [helpstring("method Tspicb_CallbackHMACAuth"), callback] 
-        HRESULT Tspicb_CallbackHMACAuth([in] UINT32 PulAppData,
-                                        [in] IUnknown *PpAuthorizedObject,
-                                        [in] BOOL PfReturnOrVerify,
-                                        [in] UINT32 PulPendingFunction,
-                                        [in] BOOL PfContinueUse,
-                                        [in] UINT32 PulSizeNonces,
-                                        [in, size_is(PulSizeNonces)] BYTE* PrgbNonceEven,
-                                        [in, size_is(PulSizeNonces)] BYTE* PrgbNonceOdd,
-                                        [in, size_is(PulSizeNonces)] BYTE* PrgbNonceEvenOSAP,
-                                        [in, size_is(PulSizeNonces)] BYTE* PrgbNonceOddOSAP,
-                                        [in] UINT32 PulSizeDigestHmac,
-                                        [in, size_is(PulSizeDigestHmac)] BYTE* PrgbParamDigest,
-                                        [in, out, size_is(PulSizeDigestHmac)] BYTE* PrgbHmacData);
-
-        [helpstring("method Tspicb_CallbackXorEnc"), callback] 
-        HRESULT Tspicb_CallbackXorEnc([in] UINT32 PulAppData,
-                                      [in] IUnknown *PpOSAPObject,
-                                      [in] IUnknown *PpObject,
-                                      [in] BOOL PfPurposeSecret,
-                                      [in] UINT32 PulSizeNonces,
-                                      [in, size_is(PulSizeNonces)] BYTE* PrgbNonceEven,
-                                      [in, size_is(PulSizeNonces)] BYTE* PrgbNonceOdd,
-                                      [in, size_is(PulSizeNonces)] BYTE* PrgbNonceEvenOSAP,
-                                      [in, size_is(PulSizeNonces)] BYTE* PrgbNonceOddOSAP,
-                                      [in] UINT32 PulSizeEncAuth,
-                                      [out, size_is(PulSizeEncAuth)] BYTE* PrgbEncAuthUsage,
-                                      [out, size_is(PulSizeEncAuth)] BYTE* PrgbEncAuthMigration);
-
-        [helpstring("method Tspicb_CallbackTakeOwnership"), callback] 
-        HRESULT Tspicb_CallbackTakeOwnership([in] UINT32 PulAppData,
-                                             [in] IUnknown *PpObject,
-                                             [in] IUnknown *PpObjectPubKey,
-                                             [in] UINT32 PulSizeEncAuth,
-                                             [out, size_is(PulSizeEncAuth)] BYTE* PrgbEncAuth );
-
-        [helpstring("method Tspicb_CallbackChangeAuthAsym"), callback] 
-        HRESULT Tspicb_CallbackChangeAuthAsym([in] UINT32 PulAppData,
-                                              [in] IUnknown *PpObject,
-                                              [in] IUnknown *PpObjectPubKey,
-                                              [in] UINT32 PulSizeEncAuth,
-                                              [in] UINT32 PulSizeAuthLink,
-                                              [out, size_is(PulSizeEncAuth)] BYTE* PrgbEncAuth,
-                                              [out, size_is(PulSizeAuthLink)] BYTE* PrgbAuthLink);
-    };   // end of _ITCPACallback
-
-    //TCPAPolicy Class
-    [
-        uuid(FBCD9C1D-72CB-47BB-99DD-2317551491DE),
-        helpstring("TCPAPolicy Class"),
-        noncreatable
-    ]
-
-    coclass TCPAPolicy
-    {
-        [default] interface ITCPAPolicy;
-        interface ITCPAAttrib;
-        [default, source] interface _ITCPACallback;
-    };
-
-    //TCPATpm Class
-    [
-        uuid(FBCD9C20-72CB-47BB-99DD-2317551491DE),
-        helpstring("TCPATpm Class"),
-        noncreatable
-    ]
-    coclass TCPATpm
-    {
-        [default] interface ITCPATpm;
-        interface ITCPAAttrib;
-        interface ITCPAAuth;
-        interface ITCPAIntegrity;
-        interface ITCPAAdministration;
-        interface ITCPAIdentityCreation;
-        interface ITCPAMaintenance;
-    };
-
-    //TCPAKey Class
-    [
-        uuid(FBCD9C26-72CB-47BB-99DD-2317551491DE),
-        helpstring("TCPAKey Class"),
-        noncreatable
-    ]
-    coclass TCPAKey
-    {
-        [default] interface ITCPAKey;
-        interface ITCPAAttrib;
-        interface ITCPAAuth;
-        interface ITCPAMigration;
-    };
-
-    //TCPAEncData Class
-    [
-        uuid(FBCD9C28-72CB-47BB-99DD-2317551491DE),
-        helpstring("TCPAEncData Class"),
-        noncreatable
-    ]
-    coclass TCPAEncData
-    {
-        [default] interface ITCPAEncData;
-        interface ITCPAAttrib;
-        interface ITCPAAuth;
-    };
-
-    //TCPAHash Class
-    [
-        uuid(FBCD9C2A-72CB-47BB-99DD-2317551491DE),
-        helpstring("TCPAHash Class"),
-        noncreatable
-    ]
-    coclass TCPAHash
-    {
-        [default] interface ITCPAHash;
-        interface ITCPAAttrib;
-    };
-
-    //TCPAPcrs Class
-    [
-        uuid(FBCD9C2C-72CB-47BB-99DD-2317551491DE),
-        helpstring("TCPAPcrs Class"),
-        noncreatable
-    ]
-    coclass TCPAPcrs
-    {
-        [default] interface ITCPAPcrs;
-    };
-
-    //TCPANonVolatileStorage Class
-    [
-        uuid(4730c51c-8998-43f6-993b-80befea1d404),
-        helpstring("TCPANonVolatileStorage Class"),
-        noncreatable
-    ]
-    coclass TCPANonVolatileStorage
-    {
-        [default] interface ITCPANonVolatileStorage;
-        interface ITCPAAttrib;
-        interface ITCPAAuth;
-    };
-
-};	// end of library TSPLib
+/*++
+
++++TSP.idl
+
+    Interface declarations for the TSS Service Provider 
+    - COM interface for Windows based platforms
+      
+--*/
+import "oaidl.idl";		// include ODL base types 
+import "ocidl.idl";
+
+//import the header files from TSS v1.2
+import "tss_typedef.h";
+import "tss_structs.h";
+
+// forward declaration
+interface ITCPAPolicy;
+interface ITCPAKey;
+
+/*
+Missing:
+TSS_RESULT Tspi_Context_Create
+TSS_RESULT Tspi_Context_Close
+TSS_RESULT Tspi_Context_FreeMemory
+*/
+
+    //ITCPAAttrib Interface
+    [
+        local,
+        object,
+        uuid(FBCD9C2E-72CB-47BB-99DD-2317551491DE),
+
+        helpstring("ITCPAAttrib Interface"),
+        pointer_default(unique)
+    ]	
+    interface ITCPAAttrib : IUnknown
+    {
+        [helpstring("method SetAttribUint32")]
+        HRESULT SetAttribUint32([in] TSS_FLAG attribFlag, 
+                                [in] TSS_FLAG subFlags,
+                                [in] UINT32 ulAttrib);
+
+        [helpstring("method GetAttribUint32")]
+        HRESULT GetAttribUint32([in] TSS_FLAG attribFlag, 
+                                [in] TSS_FLAG subFlags,
+                                [out] UINT32* pulAttrib);
+
+        [helpstring("method SetAttribData")]
+        HRESULT SetAttribData([in] TSS_FLAG attribFlag, 
+                              [in] TSS_FLAG subFlags, 
+                              [in] UINT32 ulAttribDataSize, 
+                              [in, ptr, size_is(ulAttribDataSize)] BYTE* pbAttribData);
+
+        [helpstring("method GetAttribData")]
+        HRESULT GetAttribData([in] TSS_FLAG attribFlag, 
+                              [in] TSS_FLAG subFlags, 
+                              [out] UINT32* pulAttribDataSize,
+                              [out, size_is(, *pulAttribDataSize)] BYTE** ppbAttribData);
+    }
+
+    //ITCPAAuth Interface
+    [
+        local,
+        object,
+        uuid(FBCD9C2F-72CB-47BB-99DD-2317551491DE),
+
+        helpstring("ITCPAAuth Interface"),
+        pointer_default(unique)
+    ]	
+    interface ITCPAAuth : IUnknown
+    {
+        [helpstring("method GetPolicyObject")]
+        HRESULT GetPolicyObject([in] TSS_FLAG PolicyType, 
+                                [out] ITCPAPolicy** ppPolicyObject);
+
+        [helpstring("method ChangeAuth")]
+        HRESULT ChangeAuth([in] IUnknown* PpParentObject, 
+                           [in] ITCPAPolicy* PpNewPolicy);
+
+// HRESULT ChangeAuthAsym
+
+    };
+
+    [
+        object,
+        uuid(FBCD9C2D-72CB-47BB-99DD-2317551491DE),
+        helpstring("ITCPAPcrs Interface"),
+        pointer_default(unique)
+    ]
+    interface ITCPAPcrs : IUnknown
+    {
+        [helpstring("method SetPcrValue")]
+        HRESULT SetPcrValue([in] UINT32 ulPCRIndex,
+                            [in] UINT32 ulPcrValueLength,
+                            [in, size_is(ulPcrValueLength)] BYTE* pbPcrValue);
+
+        [helpstring("method GetPcrValue")]
+        HRESULT GetPcrValue([in] UINT32 ulPCRIndex,
+                            [out] UINT32* pulPcrValueLength,
+                            [out, size_is(, *pulPcrValueLength)] BYTE** ppbPcrValue);
+
+        [helpstring("method SelectPcrIndex")]
+        HRESULT SelectPcrIndex([in] UINT32 ulPCRIndex);
+
+    };
+
+    //ITCPAKey Interface
+    [
+        object,
+        uuid(FBCD9C27-72CB-47BB-99DD-2317551491DE),
+    
+        helpstring("ITCPAKey Interface"),
+        pointer_default(unique)
+    ]
+    interface ITCPAKey : IUnknown
+    {
+        [helpstring("method LoadKey")] 
+        HRESULT LoadKey([in] ITCPAKey* pUnwrappingKey);
+
+        [helpstring("method CreateKey")]
+        HRESULT CreateKey([in] ITCPAKey* pUnwrappingKey, 
+                          [in] ITCPAPcrs* pPcrComosite);
+
+        [helpstring("method WrapKey")] 
+        HRESULT WrapKey([in] ITCPAKey* pWrappinKey, 
+                        [in] ITCPAPcrs* pPcrComposite);
+        
+        [helpstring("method CertifyKey")] 
+        HRESULT CertifyKey([in] ITCPAKey* pCertifyingKey,
+                           [in, out, ptr] TSS_VALIDATION* pValidation);
+
+        [helpstring("method GetPubKey")]
+        HRESULT GetPubKey([out] UINT32* pulPubKeyLength,
+                          [out, size_is(, *pulPubKeyLength)] BYTE** ppbPubKey);
+
+        [helpstring("method UnLoadKey")] 
+        HRESULT UnLoadKey();
+    };
+
+    // ITCPAMigration
+    [
+        local,
+        object,
+        uuid(FBCD9C30-72CB-47BB-99DD-2317551491DE),
+    
+        helpstring("ITCPAMigration Interface"),
+        pointer_default(unique)
+    ]
+    interface ITCPAMigration : IUnknown
+    {
+        [helpstring("method CreateMigrationBlob")] 
+        HRESULT CreateMigrationBlob([in] ITCPAKey *pParentKey, 
+                                    [in] UINT32 ulMigTicketLength, 
+                                    [in, size_is(ulMigTicketLength)] BYTE* rgbMigTicket, 
+                                    [out] UINT32 *pulRandomLength, 
+                                    [out, size_is(, *pulRandomLength)] BYTE **prgbRandom, 
+                                    [out] UINT32 *pulMigrationBlobLength, 
+                                    [out, size_is(, *pulMigrationBlobLength)] BYTE **prgbMigBlob);
+
+        [helpstring("method ConvertMigrationBlob")] 
+        HRESULT ConvertMigrationBlob([in] ITCPAKey *pParentKey, 
+                                     [in] UINT32 ulRandomLength, 
+                                     [in, size_is(ulRandomLength)] BYTE *rgbRandom, 
+                                     [in] UINT32 ulMigrationBlobLength, 
+                                     [in, size_is(ulMigrationBlobLength)] BYTE *rgbMigBlob);
+    };
+
+    //ITCPAEncData Interface
+    [
+        uuid(FBCD9C29-72CB-47BB-99DD-2317551491DE),
+    
+        helpstring("ITCPAEncData Interface"),
+        pointer_default(unique)
+    ]
+    interface ITCPAEncData : IUnknown
+    {
+        [helpstring("method Seal")]
+        HRESULT Seal([in] ITCPAKey* pEncKey,
+                     [in] UINT32 ulDataLength, 
+                     [in, size_is(ulDataLength)] BYTE* pbData, 
+                     [in] ITCPAPcrs* pPcrComposite);
+
+        [helpstring("method Unseal")] 
+        HRESULT Unseal([in] ITCPAKey* pKey, 
+                       [out] UINT32* pulUnsealedDataLength, 
+                       [out, size_is(, *pulUnsealedDataLength)] BYTE** ppbData);
+
+        [helpstring("method Bind")] 
+        HRESULT Bind([in] ITCPAKey* pEncKey, 
+                     [in] UINT32 ulDataLength, 
+                     [in, size_is(ulDataLength)] BYTE* pbData);
+
+        [helpstring("method Unbind")] 
+        HRESULT Unbind([in] ITCPAKey* pKey, 
+                       [out] UINT32* pulUnboundDataLength, 
+                       [out, size_is(, *pulUnboundDataLength)] BYTE** ppbData);
+
+    };
+
+    //ITCPAHash Interface
+    [
+        local,
+        object,
+        uuid(FBCD9C2B-72CB-47BB-99DD-2317551491DE),
+    
+        helpstring("ITCPAHash Interface"),
+        pointer_default(unique)
+    ]
+    interface ITCPAHash : IUnknown
+    {
+        [helpstring("method SetHashValue")] 
+        HRESULT SetHashValue([in] UINT32 ulHashValueLength, 
+                             [in, size_is(ulHashValueLength)] BYTE* pbHash);
+
+        [helpstring("method GetHashValue")] 
+        HRESULT GetHashValue([out] UINT32* pulHashValueLength, 
+                             [out, size_is(, *pulHashValueLength)] BYTE** ppbHash);
+
+        [helpstring("method UpdateHashValue")] 
+        HRESULT UpdateHashValue([in] UINT32 ulDataLength, 
+                                [in, size_is(ulDataLength)] BYTE* pbData);
+
+        [helpstring("method Sign")] 
+        HRESULT Sign([in] ITCPAKey* pKey, 
+                     [out] UINT32* pulSignatureLength, 
+                     [out, size_is(, *pulSignatureLength)] BYTE** ppbSignature);
+
+        [helpstring("method VerifySignature")] 
+        HRESULT VerifySignature([in] ITCPAKey* pKey, 
+                                [in] UINT32 ulSignatureLength, 
+                                [in, size_is(ulSignatureLength)] BYTE* pbSignature);
+
+    };
+
+    //ITCPAPolicy Interface
+    [
+        uuid(FBCD9C1E-72CB-47BB-99DD-2317551491DE),
+    
+        helpstring("ITCPAPolicy Interface"),
+        pointer_default(unique)
+    ]
+    interface ITCPAPolicy : IUnknown
+    { 
+        [helpstring("method SetSecret")] 
+        HRESULT SetSecret([in] TSS_FLAG SecretMode, 
+                          [in] UINT32 ulSecretLength, 
+                          [in, ptr, size_is(ulSecretLength)] BYTE* pbSecret);
+
+        [helpstring("method FlushSecret")] 
+        HRESULT FlushSecret();
+        
+        [helpstring("method AssignToObject")] 
+        HRESULT AssignToObject([in] IUnknown* pUnkObject);
+
+    };
+
+    //ITCPAAdministration Interface
+    [
+        local,
+        object,
+        uuid(FBCD9C24-72CB-47BB-99DD-2317551491DE),
+
+        helpstring("ITCPAAdministration Interface"),
+        pointer_default(unique)
+    ]	
+    interface ITCPAAdministration : IUnknown
+    {
+        [helpstring("method SelfTestFull")]
+        HRESULT SelfTestFull();
+
+        [helpstring("method GetTestResult")]
+        HRESULT GetTestResult([out] UINT32* pulTestResultLength,
+                              [out, size_is(, *pulTestResultLength)] BYTE** ppbTestResult);
+
+        [helpstring("method CertifySelfTest")]
+        HRESULT CertifySelfTest([in] ITCPAKey* phKey,
+                                [in, out, ptr] TSS_VALIDATION* pValidationData);
+
+        [helpstring("method CreateEndorsementKey")] 
+        HRESULT CreateEndorsementKey([in] ITCPAKey* pEndorsementKey,
+                                     [in, out, ptr] TSS_VALIDATION* pValidation);
+
+        [helpstring("method GetPubEndorsementKey")] 
+        HRESULT GetPubEndorsementKey([in] BOOL fOwnerAuthorized,
+                                     [in, out, ptr] TSS_VALIDATION* pValidation,
+                                     [out] ITCPAKey** ppEndorsementKey);
+
+        [helpstring("method TakeOwnerShip")] 
+        HRESULT TakeOwnerShip([in] ITCPAKey* pKeySRK,
+                              [in] ITCPAKey* pEndorsementKeyPubKey);
+
+        [helpstring("method ClearOwner")] 
+        HRESULT ClearOwner([in] BOOL fForcedClear);
+
+        [helpstring("method SetStatus")] 
+        HRESULT SetStatus([in] TSS_FLAG statusFlag, 
+                          [in] BOOL fTpmState);
+
+        [helpstring("method GetStatus")] 
+        HRESULT GetStatus([in] TSS_FLAG statusFlag, 
+                          [out] BOOL* pfTpmState);
+
+        [helpstring("method AuthorizeMigrationTicket")] 
+        HRESULT AuthorizeMigrationTicket([in] ITCPAKey* pMigrationKey,
+                                         [in] UINT32 MigrationScheme,
+                                         [out] UINT32* pulMigTicketLength,
+                                         [out, size_is(, *pulMigTicketLength)] BYTE** ppbMigTicket);
+    }
+
+    //ITCPAIntegrity Interface
+    [
+        local,
+        object,
+        uuid(FBCD9C22-72CB-47BB-99DD-2317551491DE),
+    
+        helpstring("ITCPAIntegrity Interface"),
+        pointer_default(unique)
+    ]
+    interface ITCPAIntegrity : IUnknown
+    {
+        [helpstring("method PcrExtend")] 
+        HRESULT PcrExtend([in] UINT32 ulPcrIndex,
+                          [in] UINT32 ulPcrDataLength,
+                          [in, size_is(ulPcrDataLength)] BYTE* pbPcrData,
+                          [in, ptr] TSS_PCR_EVENT* pEventInfo,
+                          [out] UINT32* pulPcrValueLength,
+                          [out, size_is(, *pulPcrValueLength)] BYTE** ppbPcrValue);
+
+        [helpstring("method PcrRead")] 
+        HRESULT PcrRead([in] UINT32 ulPcrIndex,
+                        [out] UINT32* pulPcrValueLength,
+                        [out, size_is(, *pulPcrValueLength)] BYTE** ppbPcrValue);
+
+        [helpstring("method DirWrite")] 
+        HRESULT DirWrite([in] UINT32 ulDirIndex, 
+                         [in] UINT32 ulDirDataLength,
+                         [in, size_is(ulDirDataLength)] BYTE* pbDirData);
+
+        [helpstring("method DirRead")] 
+        HRESULT DirRead([in] UINT32 ulDirIndex,
+                        [out] UINT32* pulDirDataLength,
+                        [out, size_is(, *pulDirDataLength)] BYTE** pbDirData);
+
+        [helpstring("method Quote")] 
+        HRESULT Quote([in] ITCPAKey* pIdentKey, 
+                      [in] ITCPAPcrs* pPcrComposite, 
+                      [in, out, ptr] TSS_VALIDATION* pValidation);
+    };
+
+    //ITCPAIdentityCreation Interface
+    [
+      object,
+      uuid(FBCD9C23-72CB-47BB-99DD-2317551491DE),
+
+      helpstring("ITCPAIdentityCreation Interface"),
+      pointer_default(unique)
+    ]   
+    interface ITCPAIdentityCreation: IUnknown
+    {
+        [helpstring("method CollateIdentityRequest")]
+        HRESULT CollateIdentityRequest([in] ITCPAKey* pKeySRK,
+                                       [in] ITCPAKey* pCAPubKey,
+                                       [in] UINT32 ulIdentityLabelLength, 
+                                       [in, size_is(ulIdentityLabelLength)] BYTE* rgbIdentityLabelData,
+                                       [in] ITCPAKey* pIdentityKey,
+                                       [in] TSS_ALGORITHM_ID algID,
+                                       [out] UINT32* pulTCPAIdentityReqLength,
+                                       [out, size_is(, *pulTCPAIdentityReqLength)] BYTE** prgbTCPAIdentityReq);
+
+        [helpstring("method ActivateIdentity")] 
+        HRESULT ActivateIdentity([in] ITCPAKey* pIdentityKey, 
+                                 [in] UINT32 ulAsymCAContentsBlobLength,
+                                 [in, size_is(ulAsymCAContentsBlobLength)] BYTE* rgbAsymCAContentsBlob,
+                                 [in] UINT32 ulSymCAAttestationBlobLength,
+                                 [in, size_is(ulSymCAAttestationBlobLength)] BYTE* rgbSymCAAttestationBlob,
+                                 [out] UINT32* pulCredentialLength,
+                                 [out, size_is(, *pulCredentialLength)] BYTE** prgbCredential);
+    
+    };	// end of ITCPAIdentityCreation
+
+    //ITCPAMaintenance Interface
+    [
+        local,
+        object,
+        uuid(FBCD9C25-72CB-47BB-99DD-2317551491DE),
+
+        helpstring("ITCPAMaintenance Interface"),
+        pointer_default(unique)
+    ]	
+    interface ITCPAMaintenance: IUnknown
+    {
+
+// HRESULT CreateMaintenanceArchive
+// HRESULT KillMaintenanceFeature
+// HRESULT LoadMaintenancePubKey
+// HRESULT CheckMaintenancePubKey
+
+    };
+
+    //ITCPATpm Interface
+    [
+        uuid(FBCD9C21-72CB-47BB-99DD-2317551491DE),
+    
+        helpstring("ITCPATpm Interface"),
+        pointer_default(unique)
+    ]
+    interface ITCPATpm : IUnknown
+    {
+        [helpstring("method GetRandom")] 
+        HRESULT GetRandom([in] UINT32 ulRandomDataLength, 
+                          [out, size_is(, ulRandomDataLength)] BYTE** ppbData);
+
+        [helpstring("method StirRandom")] 
+        HRESULT StirRandom([in] UINT32 ulEntropyDataLength, 
+                           [in, size_is(ulEntropyDataLength)] BYTE* pbData);
+
+        [helpstring("method GetCapability")] 
+        HRESULT GetCapability([in] TSS_FLAG CapArea,
+                              [in] UINT32 ulSubCapLength,
+                              [in, ptr, size_is(ulSubCapLength)] BYTE* pbSubCap,
+                              [out] UINT32* pulRespDataLength,
+                              [out, size_is(, *pulRespDataLength)] BYTE** ppbRespData);
+                               
+        [helpstring("method GetCapabilitySigned")] 
+        HRESULT GetCapabilitySigned([in] ITCPAKey* pKey,
+                            [in] TSS_FLAG CapArea,
+                            [in] UINT32 ulSubCapLength,
+                            [in, ptr, size_is(ulSubCapLength)] BYTE* pbSubCap,
+                            [in, out, ptr] TSS_VALIDATION *pValidation,
+                            [out] UINT32* pulRespDataLength,
+                            [out, size_is(, *pulRespDataLength)] BYTE** ppbRespData);
+
+// HRESULT GetEvent
+// HRESULT GetEvents
+// HRESULT GetEventLog
+
+    };
+
+    //ITCPAPersistentStorage Interface
+    [
+        local,
+        object,
+        uuid(FBCD9C1C-72CB-47BB-99DD-2317551491DE),
+
+        helpstring("ITCPAPersistentStorage Interface"),
+        pointer_default(unique)
+    ]	
+    interface ITCPAPersistentStorage: IUnknown
+    {
+        [helpstring("method LoadKeyByUUID")]
+        HRESULT LoadKeyByUUID([in] TSS_FLAG persistentStorageType,
+                        [in] TSS_UUID uuidData,
+                        [out] ITCPAKey** ppKey);
+
+        [helpstring("method RegisterKey")] 
+        HRESULT RegisterKey([in] ITCPAKey* pKey,
+                      [in] TSS_FLAG persistentStorageType,
+                      [in] TSS_UUID uuidKey, 
+                      [in] TSS_FLAG persistentStorageTypeParent,
+                      [in] TSS_UUID uuidParentKey); 
+
+        [helpstring("method UnregisterKey")]
+        HRESULT UnregisterKey([in] TSS_FLAG persistentStorageType,
+                        [in] TSS_UUID uuidKey,
+                        [out] ITCPAKey** ppKey);
+
+        [helpstring("method DeleteKeyByUUID")] 
+        HRESULT DeleteKeyByUUID([in] TSS_FLAG persistentStorageType,
+                                [in] TSS_UUID uuidData);
+
+        [helpstring("method GetKeyByUUID")] 
+        HRESULT GetKeyByUUID([in] TSS_FLAG persistentStorageType,
+                       [in] TSS_UUID uuidData,
+                       [out] ITCPAKey** ppKey);
+
+        [helpstring("method GetKeyByPublicInfo")] 
+        HRESULT GetKeyByPublicInfo([in] TSS_FLAG persistentStorageType,
+                             [in] TSS_ALGORITHM_ID  ulAlgId,
+                             [in] UINT32 ulPublicInfoLength,
+                             [in, size_is(ulPublicInfoLength)] BYTE* pbPublicInfo,
+                             [out] ITCPAKey** ppKey);
+
+        [helpstring("method GetRegisteredKeysByUUID")] 
+        HRESULT GetRegisteredKeysByUUID([in] TSS_FLAG ulPersistentStorageType,
+                                        [in] LPOLESTR wszKeyGuid,
+                                        [out] UINT32* pulKeyHierarchySize,
+                                        [out, size_is(, *pulKeyHierarchySize)] TSS_KM_KEYINFO** ppKeyHierarchy);
+    }
+
+    //ITCPAContext Interface
+    [
+        local,
+        object,
+        uuid(FBCD9C1B-72CB-47BB-99DD-2317551491DE),
+    
+        helpstring("ITCPAContext Interface"),
+        pointer_default(unique)
+    ]
+    interface ITCPAContext : IUnknown
+    {
+        [helpstring("method Connect")] 
+        HRESULT Connect([in, ptr] LPOLESTR wszRemoteMachine);
+
+        [helpstring("method CreateObject")] 
+        HRESULT CreateObject([in] UINT32 ulObjectType, 
+                             [in] UINT32 ulInitFlags,
+                             [out] IUnknown** ppUnkObject);
+
+// HRESULT CloseObject
+
+
+        [helpstring("method LoadKeyByBlob")]
+        HRESULT LoadKeyByBlob([in] ITCPAKey* pUnwrappingKey,
+                              [in] UINT32 ulBlobLength,
+                              [in, size_is(ulBlobLength)] BYTE* pbBlobData,
+                              [out] ITCPAKey** ppKey);
+
+        [helpstring("method GetTPMObject")] 
+        HRESULT GetTPMObject([out] ITCPATpm** ppTPMObject);
+
+        [helpstring("method GetDefaultPolicy")] 
+        HRESULT GetDefaultPolicy([out] ITCPAPolicy** ppPolicyObject);
+
+        [helpstring("method GetCapability")] 
+        HRESULT GetCapability([in] TSS_FLAG ulCapArea,
+                              [in] UINT32 ulSubCapLength,
+                              [in, ptr, size_is(ulSubCapLength)] BYTE* pbSubCap,
+                              [out] UINT32* pulRespDataLength,
+                              [out, size_is(, *pulRespDataLength)] BYTE** ppbRespData);
+    };
+
+    //ITCPANonVolatileStorage Interface
+    [
+        object,
+        uuid(4730c51b-8998-43f6-993b-80befea1d404),
+    
+        helpstring("ITCPANonVolatileStorage Interface"),
+        pointer_default(unique)
+    ]
+    interface ITCPANonVolatileStorage : IUnknown
+    {
+        [helpstring("method DefineSpace")]
+        HRESULT DefineSpace([in] ITCPAPcrs* pPCRsRead,
+                            [in] ITCPAPcrs* pPCRsWrite);
+
+        [helpstring("method ReleaseSpace")] 
+        HRESULT ReleaseSpace();
+
+        [helpstring("method WriteValue")] 
+        HRESULT WriteValue([in] UINT32 ulOffset,
+                           [in] UINT32 ulDataLength,
+                           [in, size_is(ulDataLength)] BYTE* rgbData);
+
+        [helpstring("method ReadValue")] 
+        HRESULT ReadValue([in] UINT32 ulOffset,
+                          [in, out] UINT32* pulDataLength,
+                          [out, size_is(, *pulDataLength)] BYTE** prgbData);
+    };
+
+    //ITCPATransport Interface
+    [
+        object,
+        uuid(4730c51d-8998-43f6-993b-80befea1d404),
+    
+        helpstring("ITCPATransport Interface"),
+        pointer_default(unique)
+    ]
+    interface ITCPATransport : IUnknown
+    {
+        [helpstring("method SetTransEncryptionKey")]
+        HRESULT SetTransEncryptionKey([in] ITCPAKey* pKey);
+
+        [helpstring("method CloseSignTransport")] 
+        HRESULT CloseSignTransport([in] ITCPAKey* pSigningKey,
+                                   [in, out, ptr] TSS_VALIDATION* pValidationData);
+    };
+
+[
+    uuid(FBCD9C19-72CB-47BB-99DD-2317551491DE),
+    version(1.0),
+    helpstring("TSS Service Provider 1.0 Type Library")
+]
+library TSPLib
+{
+    importlib("stdole32.tlb");
+    importlib("stdole2.tlb");
+
+    interface ITCPAContext;
+    //TCPAContext Class
+    [
+        uuid(FBCD9C1A-72CB-47BB-99DD-2317551491DE),
+        helpstring("TCPAContext Class")
+    ]
+    coclass TCPAContext
+    {
+        [default] interface ITCPAContext;
+        interface ITCPAAttrib;
+        interface ITCPAPersistentStorage;
+    };
+
+    //TCPAContext2 Class extensions for TSS v1.2
+    [
+        uuid(4730C51E-8998-43F6-993B-80BEFEA1D404),
+        helpstring("TCPAContext2 Class")
+    ]
+    coclass TCPAContext2
+    {
+        [default] interface ITCPAContext;
+        interface ITCPAAttrib;
+        interface ITCPAPersistentStorage;
+        interface ITCPATransport;
+    };
+
+    // _ITCPACallback Interface for TCPAPolicy Class
+    [
+        uuid(FBCD9C1F-72CB-47BB-99DD-2317551491DE),
+        helpstring("_ITCPACallback Interface"),
+        pointer_default(unique)
+    ]
+    interface _ITCPACallback : IUnknown
+    {
+        [helpstring("method Tspicb_CallbackHMACAuth"), callback] 
+        HRESULT Tspicb_CallbackHMACAuth([in] UINT32 PulAppData,
+                                        [in] IUnknown *PpAuthorizedObject,
+                                        [in] BOOL PfReturnOrVerify,
+                                        [in] UINT32 PulPendingFunction,
+                                        [in] BOOL PfContinueUse,
+                                        [in] UINT32 PulSizeNonces,
+                                        [in, size_is(PulSizeNonces)] BYTE* PrgbNonceEven,
+                                        [in, size_is(PulSizeNonces)] BYTE* PrgbNonceOdd,
+                                        [in, size_is(PulSizeNonces)] BYTE* PrgbNonceEvenOSAP,
+                                        [in, size_is(PulSizeNonces)] BYTE* PrgbNonceOddOSAP,
+                                        [in] UINT32 PulSizeDigestHmac,
+                                        [in, size_is(PulSizeDigestHmac)] BYTE* PrgbParamDigest,
+                                        [in, out, size_is(PulSizeDigestHmac)] BYTE* PrgbHmacData);
+
+        [helpstring("method Tspicb_CallbackXorEnc"), callback] 
+        HRESULT Tspicb_CallbackXorEnc([in] UINT32 PulAppData,
+                                      [in] IUnknown *PpOSAPObject,
+                                      [in] IUnknown *PpObject,
+                                      [in] BOOL PfPurposeSecret,
+                                      [in] UINT32 PulSizeNonces,
+                                      [in, size_is(PulSizeNonces)] BYTE* PrgbNonceEven,
+                                      [in, size_is(PulSizeNonces)] BYTE* PrgbNonceOdd,
+                                      [in, size_is(PulSizeNonces)] BYTE* PrgbNonceEvenOSAP,
+                                      [in, size_is(PulSizeNonces)] BYTE* PrgbNonceOddOSAP,
+                                      [in] UINT32 PulSizeEncAuth,
+                                      [out, size_is(PulSizeEncAuth)] BYTE* PrgbEncAuthUsage,
+                                      [out, size_is(PulSizeEncAuth)] BYTE* PrgbEncAuthMigration);
+
+        [helpstring("method Tspicb_CallbackTakeOwnership"), callback] 
+        HRESULT Tspicb_CallbackTakeOwnership([in] UINT32 PulAppData,
+                                             [in] IUnknown *PpObject,
+                                             [in] IUnknown *PpObjectPubKey,
+                                             [in] UINT32 PulSizeEncAuth,
+                                             [out, size_is(PulSizeEncAuth)] BYTE* PrgbEncAuth );
+
+        [helpstring("method Tspicb_CallbackChangeAuthAsym"), callback] 
+        HRESULT Tspicb_CallbackChangeAuthAsym([in] UINT32 PulAppData,
+                                              [in] IUnknown *PpObject,
+                                              [in] IUnknown *PpObjectPubKey,
+                                              [in] UINT32 PulSizeEncAuth,
+                                              [in] UINT32 PulSizeAuthLink,
+                                              [out, size_is(PulSizeEncAuth)] BYTE* PrgbEncAuth,
+                                              [out, size_is(PulSizeAuthLink)] BYTE* PrgbAuthLink);
+    };   // end of _ITCPACallback
+
+    //TCPAPolicy Class
+    [
+        uuid(FBCD9C1D-72CB-47BB-99DD-2317551491DE),
+        helpstring("TCPAPolicy Class"),
+        noncreatable
+    ]
+
+    coclass TCPAPolicy
+    {
+        [default] interface ITCPAPolicy;
+        interface ITCPAAttrib;
+        [default, source] interface _ITCPACallback;
+    };
+
+    //TCPATpm Class
+    [
+        uuid(FBCD9C20-72CB-47BB-99DD-2317551491DE),
+        helpstring("TCPATpm Class"),
+        noncreatable
+    ]
+    coclass TCPATpm
+    {
+        [default] interface ITCPATpm;
+        interface ITCPAAttrib;
+        interface ITCPAAuth;
+        interface ITCPAIntegrity;
+        interface ITCPAAdministration;
+        interface ITCPAIdentityCreation;
+        interface ITCPAMaintenance;
+    };
+
+    //TCPAKey Class
+    [
+        uuid(FBCD9C26-72CB-47BB-99DD-2317551491DE),
+        helpstring("TCPAKey Class"),
+        noncreatable
+    ]
+    coclass TCPAKey
+    {
+        [default] interface ITCPAKey;
+        interface ITCPAAttrib;
+        interface ITCPAAuth;
+        interface ITCPAMigration;
+    };
+
+    //TCPAEncData Class
+    [
+        uuid(FBCD9C28-72CB-47BB-99DD-2317551491DE),
+        helpstring("TCPAEncData Class"),
+        noncreatable
+    ]
+    coclass TCPAEncData
+    {
+        [default] interface ITCPAEncData;
+        interface ITCPAAttrib;
+        interface ITCPAAuth;
+    };
+
+    //TCPAHash Class
+    [
+        uuid(FBCD9C2A-72CB-47BB-99DD-2317551491DE),
+        helpstring("TCPAHash Class"),
+        noncreatable
+    ]
+    coclass TCPAHash
+    {
+        [default] interface ITCPAHash;
+        interface ITCPAAttrib;
+    };
+
+    //TCPAPcrs Class
+    [
+        uuid(FBCD9C2C-72CB-47BB-99DD-2317551491DE),
+        helpstring("TCPAPcrs Class"),
+        noncreatable
+    ]
+    coclass TCPAPcrs
+    {
+        [default] interface ITCPAPcrs;
+    };
+
+    //TCPANonVolatileStorage Class
+    [
+        uuid(4730c51c-8998-43f6-993b-80befea1d404),
+        helpstring("TCPANonVolatileStorage Class"),
+        noncreatable
+    ]
+    coclass TCPANonVolatileStorage
+    {
+        [default] interface ITCPANonVolatileStorage;
+        interface ITCPAAttrib;
+        interface ITCPAAuth;
+    };
+
+};	// end of library TSPLib
diff --git a/src/include/tss/compat11b.h b/src/include/tss/compat11b.h
index 28c7304..e827daf 100644
--- a/src/include/tss/compat11b.h
+++ b/src/include/tss/compat11b.h
@@ -1,200 +1,205 @@
-
-#ifndef __COMPAT11B_H__
-#define __COMPAT11B_H__
-
-#include <tss/tpm.h>
-
-#define TCPA_Vendor_Specific32  TPM_Vendor_Specific32
-#define TCPA_Vendor_Specific8   TPM_Vendor_Specific8
-
-typedef TSS_UNICODE             UNICODE;
-typedef TPM_DIGEST              TCPA_DIGEST;
-typedef TPM_NONCE               TCPA_NONCE;
-typedef TPM_NONCE               TCPA_SALT_NONCE;
-typedef TPM_PUBKEY              TCPA_PUBKEY;
-typedef TPM_SECRET              TCPA_SECRET;
-typedef TPM_KEY                 TCPA_KEY;
-typedef TPM_DIRVALUE            TCPA_DIRVALUE;
-typedef TPM_COMMAND_CODE        TCPA_COMMAND_CODE;
-typedef TPM_BOUND_DATA          TCPA_BOUND_DATA;
-typedef TPM_STRUCT_VER          TCPA_VERSION;
-typedef TPM_RESULT              TCPA_RESULT;
-typedef TPM_PAYLOAD_TYPE        TCPA_PAYLOAD_TYPE;
-typedef TPM_STORE_PRIVKEY       TCPA_STORE_PRIVKEY;
-typedef TPM_CHOSENID_HASH       TCPA_CHOSENID_HASH;
-typedef TPM_SYMMETRIC_KEY       TCPA_SYMMETRIC_KEY;
-typedef TPM_PCR_INFO            TCPA_PCR_INFO;
-typedef TPM_PCR_SELECTION       TCPA_PCR_SELECTION;
-typedef TPM_STORED_DATA         TCPA_STORED_DATA;
-typedef TPM_SEALED_DATA         TCPA_SEALED_DATA;
-typedef TPM_KEY_FLAGS           TCPA_KEY_FLAGS;
-typedef TPM_KEY_PARMS           TCPA_KEY_PARMS;
-typedef TPM_STORE_PUBKEY        TCPA_STORE_PUBKEY;
-typedef TPM_MIGRATIONKEYAUTH    TCPA_MIGRATIONKEYAUTH;
-typedef TPM_RSA_KEY_PARMS       TCPA_RSA_KEY_PARMS;
-typedef TPM_CERTIFY_INFO        TCPA_CERTIFY_INFO;
-typedef TPM_STORE_ASYMKEY       TCPA_STORE_ASYMKEY;
-typedef TPM_ENCAUTH             TCPA_ENCAUTH;
-typedef TPM_PCRINDEX            TCPA_PCRINDEX;
-typedef TPM_PCRVALUE            TCPA_PCRVALUE;
-typedef TPM_DIRINDEX            TCPA_DIRINDEX;
-typedef TPM_PROTOCOL_ID         TCPA_PROTOCOL_ID;
-typedef TPM_ALGORITHM_ID        TCPA_ALGORITHM_ID;
-typedef TPM_ENTITY_TYPE         TCPA_ENTITY_TYPE;
-typedef TPM_CAPABILITY_AREA     TCPA_CAPABILITY_AREA;
-typedef TPM_HMAC                TCPA_HMAC;
-typedef TPM_MIGRATE_SCHEME      TCPA_MIGRATE_SCHEME;
-typedef TPM_PHYSICAL_PRESENCE   TCPA_PHYSICAL_PRESENCE;
-typedef TPM_KEY_HANDLE          TCPA_KEY_HANDLE;
-typedef TPM_KEY_HANDLE_LIST     TCPA_KEY_HANDLE_LIST;
-typedef TPM_PCR_COMPOSITE       TCPA_PCR_COMPOSITE;
-typedef TPM_AUTH_DATA_USAGE     TCPA_AUTH_DATA_USAGE;
-typedef TPM_AUTHDATA            TCPA_AUTHDATA;
-typedef TPM_KEY_USAGE           TCPA_KEY_USAGE;
-typedef TPM_COMPOSITE_HASH      TCPA_COMPOSITE_HASH;
-typedef TPM_QUOTE_INFO          TCPA_QUOTE_INFO;
-typedef TPM_TAG                 TCPA_TAG;
-typedef TPM_ENC_SCHEME          TCPA_ENC_SCHEME;
-typedef TPM_SIG_SCHEME          TCPA_SIG_SCHEME;
-typedef TPM_STARTUP_TYPE        TCPA_STARTUP_TYPE;
-typedef TPM_AUTHHANDLE          TCPA_AUTHHANDLE;
-typedef TPM_SYM_CA_ATTESTATION  TCPA_SYM_CA_ATTESTATION;
-typedef TPM_ASYM_CA_CONTENTS    TCPA_ASYM_CA_CONTENTS;
-typedef TPM_IDENTITY_REQ        TCPA_IDENTITY_REQ;
-typedef TPM_IDENTITY_PROOF      TCPA_IDENTITY_PROOF;
-
-// These were removed from the 1.2 TPM spec
-typedef UINT32                  TCPA_ENCHANDLE;
-typedef UINT32                  TCPA_EVENTTYPE;
-typedef struct tdTCPA_AUDIT_EVENT {
-    TCPA_COMMAND_CODE ordinal;
-    TCPA_RESULT       returncode;
-} TCPA_AUDIT_EVENT;
-
-#define TCPA_SHA1_160_HASH_LEN          TPM_SHA1_160_HASH_LEN
-#define TCPA_SHA1BASED_NONCE_LEN        TPM_SHA1BASED_NONCE_LEN
-
-#define redirection             TSS_KEYFLAG_REDIRECTION
-#define migratable              TSS_KEYFLAG_MIGRATABLE
-#define volatileKey             TSS_KEYFLAG_VOLATILEKEY
-
-#define TCPA_ET_KEYHANDLE       TPM_ET_KEYHANDLE
-#define TCPA_ET_KEY             TPM_ET_KEY
-#define TCPA_ET_OWNER           TPM_ET_OWNER
-#define TCPA_ET_SRK             TPM_ET_SRK
-#define TCPA_ET_DATA            TPM_ET_DATA
-
-#define TCPA_PID_OIAP           TPM_PID_OIAP
-#define TCPA_PID_OSAP           TPM_PID_OSAP
-#define TCPA_PID_ADIP           TPM_PID_ADIP
-#define TCPA_PID_ADCP           TPM_PID_ADCP
-#define TCPA_PID_OWNER          TPM_PID_OWNER
-
-#define TCPA_PT_ASYM            TPM_PT_ASYM
-#define TCPA_PT_BIND            TPM_PT_BIND
-#define TCPA_PT_MIGRATE         TPM_PT_MIGRATE
-#define TCPA_PT_MAINT           TPM_PT_MAINT
-#define TCPA_PT_SEAL            TPM_PT_SEAL
-
-#define TCPA_CAP_ALG            TPM_CAP_ALG
-#define TCPA_CAP_ORD            TPM_CAP_ORD
-#define TCPA_CAP_PID            TPM_CAP_PID
-#define TCPA_CAP_FLAG           TPM_CAP_FLAG
-#define TCPA_CAP_VERSION        TPM_CAP_VERSION
-#define TCPA_CAP_PROPERTY       TPM_CAP_PROPERTY
-#define TCPA_CAP_KEY_HANDLE     TPM_CAP_KEY_HANDLE
-#define TCPA_CAP_CHECK_LOADED   TPM_CAP_CHECK_LOADED
-
-#define TCPA_ALG_RSA            TPM_ALG_RSA
-#define TCPA_ALG_DES            TPM_ALG_DES
-#define TCPA_ALG_3DES           TPM_ALG_3DES
-#define TCPA_ALG_SHA            TPM_ALG_SHA
-#define TCPA_ALG_HMAC           TPM_ALG_HMAC
-#define TCPA_ALG_AES            TPM_ALG_AES
-
-#define TCPA_PROTECTED_ORDINAL          TPM_PROTECTED_ORDINAL
-#define TCPA_UNPROTECTED_ORDINAL        TPM_UNPROTECTED_ORDINAL
-#define TCPA_CONNECTION_ORDINAL         TPM_CONNECTION_ORDINAL
-
-#define TCPA_PROTECTED_COMMAND          TPM_PROTECTED_COMMAND
-#define TCPA_UNPROTECTED_COMMAND        TPM_UNPROTECTED_COMMAND
-#define TCPA_CONNECTION_COMMAND         TPM_CONNECTION_COMMAND
-#define TCPA_VENDOR_COMMAND             TPM_VENDOR_COMMAND
-
-#define TCPA_MAIN               TPM_MAIN
-#define TCPA_PC                 TPM_PC
-#define TCPA_PDA                TPM_PDA
-#define TCPA_CELL_PHONE         TPM_CELL_PHONE
-
-#define TCPA_MS_MIGRATE                 TPM_MS_MIGRATE
-#define TCPA_MS_REWRAP                  TPM_MS_REWRAP
-#define TCPA_MS_MAINT                   TPM_MS_MAINT
-
-#define TCPA_ES_NONE                    TPM_ES_NONE
-#define TCPA_ES_RSAESPKCSv15            TPM_ES_RSAESPKCSv15
-#define TCPA_ES_RSAESOAEP_SHA1_MGF1     TPM_ES_RSAESOAEP_SHA1_MGF1
-
-#define TCPA_SS_NONE                    TPM_SS_NONE
-#define TCPA_SS_RSASSAPKCS1v15_SHA1     TPM_SS_RSASSAPKCS1v15_SHA1
-#define TCPA_SS_RSASSAPKCS1v15_DER      TPM_SS_RSASSAPKCS1v15_DER
-#define	TCPA_SS_RSASSAPKCS1v15_INFO	TPM_SS_RSASSAPKCS1v15_INFO
-
-#define TCPA_PHYSICAL_PRESENCE_LIFETIME_LOCK    TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK
-#define TCPA_PHYSICAL_PRESENCE_HW_ENABLE        TPM_PHYSICAL_PRESENCE_HW_ENABLE
-#define TCPA_PHYSICAL_PRESENCE_CMD_ENABLE       TPM_PHYSICAL_PRESENCE_CMD_ENABLE
-#define TCPA_PHYSICAL_PRESENCE_LOCK             TPM_PHYSICAL_PRESENCE_LOCK
-#define TCPA_PHYSICAL_PRESENCE_PRESENT          TPM_PHYSICAL_PRESENCE_PRESENT
-#define TCPA_PHYSICAL_PRESENCE_NOTPRESENT       TPM_PHYSICAL_PRESENCE_NOTPRESENT
-
-#define TCPA_SUCCESS                    TPM_SUCCESS
-#define TCPA_E_BASE                     TPM_E_BASE
-#define TCPA_E_NON_FATAL                TPM_E_NON_FATAL
-#define TCPA_E_AUTHFAIL                 TPM_E_AUTHFAIL
-#define TCPA_E_BAD_PARAMETER            TPM_E_BAD_PARAMETER
-#define TCPA_E_BADINDEX                 TPM_E_BADINDEX
-#define TCPA_E_AUDITFAILURE             TPM_E_AUDITFAILURE
-#define TCPA_E_CLEAR_DISABLED           TPM_E_CLEAR_DISABLED
-#define TCPA_E_DEACTIVATED              TPM_E_DEACTIVATED
-#define TCPA_E_DISABLED                 TPM_E_DISABLED
-#define TCPA_E_DISABLED_CMD             TPM_E_DISABLED_CMD
-#define TCPA_E_FAIL                     TPM_E_FAIL
-#define TCPA_E_INACTIVE                 TPM_E_BAD_ORDINAL
-#define TCPA_E_INSTALL_DISABLED         TPM_E_INSTALL_DISABLED
-#define TCPA_E_INVALID_KEYHANDLE        TPM_E_INVALID_KEYHANDLE
-#define TCPA_E_KEYNOTFOUND              TPM_E_KEYNOTFOUND
-#define TCPA_E_NEED_SELFTEST            TPM_E_INAPPROPRIATE_ENC
-#define TCPA_E_MIGRATEFAIL              TPM_E_MIGRATEFAIL
-#define TCPA_E_NO_PCR_INFO              TPM_E_INVALID_PCR_INFO
-#define TCPA_E_NOSPACE                  TPM_E_NOSPACE
-#define TCPA_E_NOSRK                    TPM_E_NOSRK
-#define TCPA_E_NOTSEALED_BLOB           TPM_E_NOTSEALED_BLOB
-#define TCPA_E_OWNER_SET                TPM_E_OWNER_SET
-#define TCPA_E_RESOURCES                TPM_E_RESOURCES
-#define TCPA_E_SHORTRANDOM              TPM_E_SHORTRANDOM
-#define TCPA_E_SIZE                     TPM_E_SIZE
-#define TCPA_E_WRONGPCRVAL              TPM_E_WRONGPCRVAL
-#define TCPA_E_BAD_PARAM_SIZE           TPM_E_BAD_PARAM_SIZE
-#define TCPA_E_SHA_THREAD               TPM_E_SHA_THREAD
-#define TCPA_E_SHA_ERROR                TPM_E_SHA_ERROR
-#define TCPA_E_FAILEDSELFTEST           TPM_E_FAILEDSELFTEST
-#define TCPA_E_AUTH2FAIL                TPM_E_AUTH2FAIL
-#define TCPA_E_BADTAG                   TPM_E_BADTAG
-#define TCPA_E_IOERROR                  TPM_E_IOERROR
-#define TCPA_E_ENCRYPT_ERROR            TPM_E_ENCRYPT_ERROR
-#define TCPA_E_DECRYPT_ERROR            TPM_E_DECRYPT_ERROR
-#define TCPA_E_INVALID_AUTHHANDLE       TPM_E_INVALID_AUTHHANDLE
-#define TCPA_E_NO_ENDORSEMENT           TPM_E_NO_ENDORSEMENT
-#define TCPA_E_INVALID_KEYUSAGE         TPM_E_INVALID_KEYUSAGE
-#define TCPA_E_WRONG_ENTITYTYPE         TPM_E_WRONG_ENTITYTYPE
-#define TCPA_E_INVALID_POSTINIT         TPM_E_INVALID_POSTINIT
-#define TCPA_E_INAPPROPRIATE_SIG        TPM_E_INAPPROPRIATE_SIG
-#define TCPA_E_BAD_KEY_PROPERTY         TPM_E_BAD_KEY_PROPERTY
-#define TCPA_E_BAD_MIGRATION            TPM_E_BAD_MIGRATION
-#define TCPA_E_BAD_SCHEME               TPM_E_BAD_SCHEME
-#define TCPA_E_BAD_DATASIZE             TPM_E_BAD_DATASIZE
-#define TCPA_E_BAD_MODE                 TPM_E_BAD_MODE
-#define TCPA_E_BAD_PRESENCE             TPM_E_BAD_PRESENCE
-#define TCPA_E_BAD_VERSION              TPM_E_BAD_VERSION
-#define TCPA_E_RETRY                    TPM_E_RETRY
-
-#endif
+
+#ifndef __COMPAT11B_H__
+#define __COMPAT11B_H__
+
+#include <tss/tpm.h>
+#if (defined (WIN32) && !defined(__MINGW32__))
+#include <WinError.h>
+#endif
+
+#define TCPA_Vendor_Specific32  TPM_Vendor_Specific32
+#define TCPA_Vendor_Specific8   TPM_Vendor_Specific8
+
+#ifndef WIN32
+typedef TSS_UNICODE             UNICODE;
+#endif
+typedef TPM_DIGEST              TCPA_DIGEST;
+typedef TPM_NONCE               TCPA_NONCE;
+typedef TPM_NONCE               TCPA_SALT_NONCE;
+typedef TPM_PUBKEY              TCPA_PUBKEY;
+typedef TPM_SECRET              TCPA_SECRET;
+typedef TPM_KEY                 TCPA_KEY;
+typedef TPM_DIRVALUE            TCPA_DIRVALUE;
+typedef TPM_COMMAND_CODE        TCPA_COMMAND_CODE;
+typedef TPM_BOUND_DATA          TCPA_BOUND_DATA;
+typedef TPM_STRUCT_VER          TCPA_VERSION;
+typedef TPM_RESULT              TCPA_RESULT;
+typedef TPM_PAYLOAD_TYPE        TCPA_PAYLOAD_TYPE;
+typedef TPM_STORE_PRIVKEY       TCPA_STORE_PRIVKEY;
+typedef TPM_CHOSENID_HASH       TCPA_CHOSENID_HASH;
+typedef TPM_SYMMETRIC_KEY       TCPA_SYMMETRIC_KEY;
+typedef TPM_PCR_INFO            TCPA_PCR_INFO;
+typedef TPM_PCR_SELECTION       TCPA_PCR_SELECTION;
+typedef TPM_STORED_DATA         TCPA_STORED_DATA;
+typedef TPM_SEALED_DATA         TCPA_SEALED_DATA;
+typedef TPM_KEY_FLAGS           TCPA_KEY_FLAGS;
+typedef TPM_KEY_PARMS           TCPA_KEY_PARMS;
+typedef TPM_STORE_PUBKEY        TCPA_STORE_PUBKEY;
+typedef TPM_MIGRATIONKEYAUTH    TCPA_MIGRATIONKEYAUTH;
+typedef TPM_RSA_KEY_PARMS       TCPA_RSA_KEY_PARMS;
+typedef TPM_CERTIFY_INFO        TCPA_CERTIFY_INFO;
+typedef TPM_STORE_ASYMKEY       TCPA_STORE_ASYMKEY;
+typedef TPM_ENCAUTH             TCPA_ENCAUTH;
+typedef TPM_PCRINDEX            TCPA_PCRINDEX;
+typedef TPM_PCRVALUE            TCPA_PCRVALUE;
+typedef TPM_DIRINDEX            TCPA_DIRINDEX;
+typedef TPM_PROTOCOL_ID         TCPA_PROTOCOL_ID;
+typedef TPM_ALGORITHM_ID        TCPA_ALGORITHM_ID;
+typedef TPM_ENTITY_TYPE         TCPA_ENTITY_TYPE;
+typedef TPM_CAPABILITY_AREA     TCPA_CAPABILITY_AREA;
+typedef TPM_HMAC                TCPA_HMAC;
+typedef TPM_MIGRATE_SCHEME      TCPA_MIGRATE_SCHEME;
+typedef TPM_PHYSICAL_PRESENCE   TCPA_PHYSICAL_PRESENCE;
+typedef TPM_KEY_HANDLE          TCPA_KEY_HANDLE;
+typedef TPM_KEY_HANDLE_LIST     TCPA_KEY_HANDLE_LIST;
+typedef TPM_PCR_COMPOSITE       TCPA_PCR_COMPOSITE;
+typedef TPM_AUTH_DATA_USAGE     TCPA_AUTH_DATA_USAGE;
+typedef TPM_AUTHDATA            TCPA_AUTHDATA;
+typedef TPM_KEY_USAGE           TCPA_KEY_USAGE;
+typedef TPM_COMPOSITE_HASH      TCPA_COMPOSITE_HASH;
+typedef TPM_QUOTE_INFO          TCPA_QUOTE_INFO;
+typedef TPM_TAG                 TCPA_TAG;
+typedef TPM_ENC_SCHEME          TCPA_ENC_SCHEME;
+typedef TPM_SIG_SCHEME          TCPA_SIG_SCHEME;
+typedef TPM_STARTUP_TYPE        TCPA_STARTUP_TYPE;
+typedef TPM_AUTHHANDLE          TCPA_AUTHHANDLE;
+typedef TPM_SYM_CA_ATTESTATION  TCPA_SYM_CA_ATTESTATION;
+typedef TPM_ASYM_CA_CONTENTS    TCPA_ASYM_CA_CONTENTS;
+typedef TPM_IDENTITY_REQ        TCPA_IDENTITY_REQ;
+typedef TPM_IDENTITY_PROOF      TCPA_IDENTITY_PROOF;
+
+// These were removed from the 1.2 TPM spec
+typedef UINT32                  TCPA_ENCHANDLE;
+typedef UINT32                  TCPA_EVENTTYPE;
+typedef struct tdTCPA_AUDIT_EVENT {
+    TCPA_COMMAND_CODE ordinal;
+    TCPA_RESULT       returncode;
+} TCPA_AUDIT_EVENT;
+
+#define TCPA_SHA1_160_HASH_LEN          TPM_SHA1_160_HASH_LEN
+#define TCPA_SHA1BASED_NONCE_LEN        TPM_SHA1BASED_NONCE_LEN
+
+#define redirection             TSS_KEYFLAG_REDIRECTION
+#define migratable              TSS_KEYFLAG_MIGRATABLE
+#define volatileKey             TSS_KEYFLAG_VOLATILEKEY
+
+#define TCPA_ET_KEYHANDLE       TPM_ET_KEYHANDLE
+#define TCPA_ET_KEY             TPM_ET_KEY
+#define TCPA_ET_OWNER           TPM_ET_OWNER
+#define TCPA_ET_SRK             TPM_ET_SRK
+#define TCPA_ET_DATA            TPM_ET_DATA
+
+#define TCPA_PID_OIAP           TPM_PID_OIAP
+#define TCPA_PID_OSAP           TPM_PID_OSAP
+#define TCPA_PID_ADIP           TPM_PID_ADIP
+#define TCPA_PID_ADCP           TPM_PID_ADCP
+#define TCPA_PID_OWNER          TPM_PID_OWNER
+
+#define TCPA_PT_ASYM            TPM_PT_ASYM
+#define TCPA_PT_BIND            TPM_PT_BIND
+#define TCPA_PT_MIGRATE         TPM_PT_MIGRATE
+#define TCPA_PT_MAINT           TPM_PT_MAINT
+#define TCPA_PT_SEAL            TPM_PT_SEAL
+
+#define TCPA_CAP_ALG            TPM_CAP_ALG
+#define TCPA_CAP_ORD            TPM_CAP_ORD
+#define TCPA_CAP_PID            TPM_CAP_PID
+#define TCPA_CAP_FLAG           TPM_CAP_FLAG
+#define TCPA_CAP_VERSION        TPM_CAP_VERSION
+#define TCPA_CAP_PROPERTY       TPM_CAP_PROPERTY
+#define TCPA_CAP_KEY_HANDLE     TPM_CAP_KEY_HANDLE
+#define TCPA_CAP_CHECK_LOADED   TPM_CAP_CHECK_LOADED
+
+#define TCPA_ALG_RSA            TPM_ALG_RSA
+#define TCPA_ALG_DES            TPM_ALG_DES
+#define TCPA_ALG_3DES           TPM_ALG_3DES
+#define TCPA_ALG_SHA            TPM_ALG_SHA
+#define TCPA_ALG_HMAC           TPM_ALG_HMAC
+#define TCPA_ALG_AES            TPM_ALG_AES
+
+#define TCPA_PROTECTED_ORDINAL          TPM_PROTECTED_ORDINAL
+#define TCPA_UNPROTECTED_ORDINAL        TPM_UNPROTECTED_ORDINAL
+#define TCPA_CONNECTION_ORDINAL         TPM_CONNECTION_ORDINAL
+
+#define TCPA_PROTECTED_COMMAND          TPM_PROTECTED_COMMAND
+#define TCPA_UNPROTECTED_COMMAND        TPM_UNPROTECTED_COMMAND
+#define TCPA_CONNECTION_COMMAND         TPM_CONNECTION_COMMAND
+#define TCPA_VENDOR_COMMAND             TPM_VENDOR_COMMAND
+
+#define TCPA_MAIN               TPM_MAIN
+#define TCPA_PC                 TPM_PC
+#define TCPA_PDA                TPM_PDA
+#define TCPA_CELL_PHONE         TPM_CELL_PHONE
+
+#define TCPA_MS_MIGRATE                 TPM_MS_MIGRATE
+#define TCPA_MS_REWRAP                  TPM_MS_REWRAP
+#define TCPA_MS_MAINT                   TPM_MS_MAINT
+
+#define TCPA_ES_NONE                    TPM_ES_NONE
+#define TCPA_ES_RSAESPKCSv15            TPM_ES_RSAESPKCSv15
+#define TCPA_ES_RSAESOAEP_SHA1_MGF1     TPM_ES_RSAESOAEP_SHA1_MGF1
+
+#define TCPA_SS_NONE                    TPM_SS_NONE
+#define TCPA_SS_RSASSAPKCS1v15_SHA1     TPM_SS_RSASSAPKCS1v15_SHA1
+#define TCPA_SS_RSASSAPKCS1v15_DER      TPM_SS_RSASSAPKCS1v15_DER
+#define	TCPA_SS_RSASSAPKCS1v15_INFO	TPM_SS_RSASSAPKCS1v15_INFO
+
+#define TCPA_PHYSICAL_PRESENCE_LIFETIME_LOCK    TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK
+#define TCPA_PHYSICAL_PRESENCE_HW_ENABLE        TPM_PHYSICAL_PRESENCE_HW_ENABLE
+#define TCPA_PHYSICAL_PRESENCE_CMD_ENABLE       TPM_PHYSICAL_PRESENCE_CMD_ENABLE
+#define TCPA_PHYSICAL_PRESENCE_LOCK             TPM_PHYSICAL_PRESENCE_LOCK
+#define TCPA_PHYSICAL_PRESENCE_PRESENT          TPM_PHYSICAL_PRESENCE_PRESENT
+#define TCPA_PHYSICAL_PRESENCE_NOTPRESENT       TPM_PHYSICAL_PRESENCE_NOTPRESENT
+
+#define TCPA_SUCCESS                    TPM_SUCCESS
+#define TCPA_E_BASE                     TPM_E_BASE
+#define TCPA_E_NON_FATAL                TPM_E_NON_FATAL
+#define TCPA_E_AUTHFAIL                 TPM_E_AUTHFAIL
+#define TCPA_E_BAD_PARAMETER            TPM_E_BAD_PARAMETER
+#define TCPA_E_BADINDEX                 TPM_E_BADINDEX
+#define TCPA_E_AUDITFAILURE             TPM_E_AUDITFAILURE
+#define TCPA_E_CLEAR_DISABLED           TPM_E_CLEAR_DISABLED
+#define TCPA_E_DEACTIVATED              TPM_E_DEACTIVATED
+#define TCPA_E_DISABLED                 TPM_E_DISABLED
+#define TCPA_E_DISABLED_CMD             TPM_E_DISABLED_CMD
+#define TCPA_E_FAIL                     TPM_E_FAIL
+#define TCPA_E_INACTIVE                 TPM_E_BAD_ORDINAL
+#define TCPA_E_INSTALL_DISABLED         TPM_E_INSTALL_DISABLED
+#define TCPA_E_INVALID_KEYHANDLE        TPM_E_INVALID_KEYHANDLE
+#define TCPA_E_KEYNOTFOUND              TPM_E_KEYNOTFOUND
+#define TCPA_E_NEED_SELFTEST            TPM_E_INAPPROPRIATE_ENC
+#define TCPA_E_MIGRATEFAIL              TPM_E_MIGRATEFAIL
+#define TCPA_E_NO_PCR_INFO              TPM_E_INVALID_PCR_INFO
+#define TCPA_E_NOSPACE                  TPM_E_NOSPACE
+#define TCPA_E_NOSRK                    TPM_E_NOSRK
+#define TCPA_E_NOTSEALED_BLOB           TPM_E_NOTSEALED_BLOB
+#define TCPA_E_OWNER_SET                TPM_E_OWNER_SET
+#define TCPA_E_RESOURCES                TPM_E_RESOURCES
+#define TCPA_E_SHORTRANDOM              TPM_E_SHORTRANDOM
+#define TCPA_E_SIZE                     TPM_E_SIZE
+#define TCPA_E_WRONGPCRVAL              TPM_E_WRONGPCRVAL
+#define TCPA_E_BAD_PARAM_SIZE           TPM_E_BAD_PARAM_SIZE
+#define TCPA_E_SHA_THREAD               TPM_E_SHA_THREAD
+#define TCPA_E_SHA_ERROR                TPM_E_SHA_ERROR
+#define TCPA_E_FAILEDSELFTEST           TPM_E_FAILEDSELFTEST
+#define TCPA_E_AUTH2FAIL                TPM_E_AUTH2FAIL
+#define TCPA_E_BADTAG                   TPM_E_BADTAG
+#define TCPA_E_IOERROR                  TPM_E_IOERROR
+#define TCPA_E_ENCRYPT_ERROR            TPM_E_ENCRYPT_ERROR
+#define TCPA_E_DECRYPT_ERROR            TPM_E_DECRYPT_ERROR
+#define TCPA_E_INVALID_AUTHHANDLE       TPM_E_INVALID_AUTHHANDLE
+#define TCPA_E_NO_ENDORSEMENT           TPM_E_NO_ENDORSEMENT
+#define TCPA_E_INVALID_KEYUSAGE         TPM_E_INVALID_KEYUSAGE
+#define TCPA_E_WRONG_ENTITYTYPE         TPM_E_WRONG_ENTITYTYPE
+#define TCPA_E_INVALID_POSTINIT         TPM_E_INVALID_POSTINIT
+#define TCPA_E_INAPPROPRIATE_SIG        TPM_E_INAPPROPRIATE_SIG
+#define TCPA_E_BAD_KEY_PROPERTY         TPM_E_BAD_KEY_PROPERTY
+#define TCPA_E_BAD_MIGRATION            TPM_E_BAD_MIGRATION
+#define TCPA_E_BAD_SCHEME               TPM_E_BAD_SCHEME
+#define TCPA_E_BAD_DATASIZE             TPM_E_BAD_DATASIZE
+#define TCPA_E_BAD_MODE                 TPM_E_BAD_MODE
+#define TCPA_E_BAD_PRESENCE             TPM_E_BAD_PRESENCE
+#define TCPA_E_BAD_VERSION              TPM_E_BAD_VERSION
+#define TCPA_E_RETRY                    TPM_E_RETRY
+
+#endif
diff --git a/src/include/tss/platform.h b/src/include/tss/platform.h
index 495afc7..94af24d 100644
--- a/src/include/tss/platform.h
+++ b/src/include/tss/platform.h
@@ -1,46 +1,60 @@
-/*++
-
-There are platform dependent and general defines.
-
---*/
-
-#ifndef TSS_PLATFORM_H
-#define TSS_PLATFORM_H
-
-
-/* The default implementation is to use stdint.h, a part of the C99 standard.
- * Systems that don't support this are handled on a case-by-case basis.
- */
-
-#if !defined(WIN32)
-#include <stdint.h>
-   typedef uint8_t            BYTE;
-   typedef int8_t             TSS_BOOL;
-   typedef uint16_t           UINT16;
-   typedef uint32_t           UINT32;
-   typedef uint64_t           UINT64;
-
-   typedef uint16_t           TSS_UNICODE;
-   typedef void*              PVOID;
-
-#elif defined(WIN32)
-#include <basetsd.h>
-   typedef  unsigned char    BYTE;  
-   typedef  signed char      TSS_BOOL;
-#ifndef _BASETSD_H_
-   // basetsd.h provides definitions of UINT16, UINT32 and UINT64.
-   typedef  unsigned short   UINT16;
-   typedef  unsigned long    UINT32;
-   typedef  unsigned __int64 UINT64;
-#endif
-   typedef  unsigned short   TSS_UNICODE;
-   typedef  void*            PVOID;
-#endif
-
-
-/* Include this so that applications that use names as defined in the
- * 1.1 TSS specification can still compile
- */
-#include <tss/compat11b.h>
-
-#endif // TSS_PLATFORM_H
+/*++
+
+There are platform dependent and general defines.
+
+--*/
+
+#ifndef TSS_PLATFORM_H
+#define TSS_PLATFORM_H
+
+
+/* The default implementation is to use stdint.h, a part of the C99 standard.
+ * Systems that don't support this are handled on a case-by-case basis.
+ */
+
+#if !defined(WIN32)
+#include <stdint.h>
+   typedef uint8_t            BYTE;
+   typedef int8_t             TSS_BOOL;
+   typedef uint16_t           UINT16;
+   typedef uint32_t           UINT32;
+   typedef uint64_t           UINT64;
+
+   typedef uint16_t           TSS_UNICODE;
+   typedef void*              PVOID;
+
+#elif defined(WIN32)
+#if !defined(_WIN32_WINNT)
+#      define _WIN32_WINNT 0x0600
+#endif /* !defined(_WIN32_WINNT) */
+
+/* 
+ * C90 specifications don't have inttypes.h
+ */
+#define PRIu64 "I64u"
+#ifndef __MINGW32__
+#define ssize_t long
+#endif
+
+#include <basetsd.h>
+   typedef  unsigned char    BYTE;  
+   typedef  signed char      TSS_BOOL;
+#ifndef _BASETSD_H_
+   // basetsd.h provides definitions of UINT16, UINT32 and UINT64.
+   typedef  unsigned short   UINT16;
+#ifndef __MINGW32__
+   typedef  unsigned long    UINT32;
+#endif   
+   typedef  unsigned __int64 UINT64;
+#endif
+   typedef  unsigned short   TSS_UNICODE;
+   typedef  void*            PVOID;
+#endif
+
+
+/* Include this so that applications that use names as defined in the
+ * 1.1 TSS specification can still compile
+ */
+#include <tss/compat11b.h>
+
+#endif // TSS_PLATFORM_H
diff --git a/src/include/tss/tcpa_defines.h b/src/include/tss/tcpa_defines.h
index ea0a994..acc391d 100644
--- a/src/include/tss/tcpa_defines.h
+++ b/src/include/tss/tcpa_defines.h
@@ -1,7 +1,7 @@
-
-#ifndef __TCPA_DEFINES_H__
-#define __TCPA_DEFINES_H__
-
-#warning including deprecated header file tcpa_defines.h
-
-#endif
+
+#ifndef __TCPA_DEFINES_H__
+#define __TCPA_DEFINES_H__
+
+#warning including deprecated header file tcpa_defines.h
+
+#endif
diff --git a/src/include/tss/tcpa_error.h b/src/include/tss/tcpa_error.h
index 6391227..cbb2a22 100644
--- a/src/include/tss/tcpa_error.h
+++ b/src/include/tss/tcpa_error.h
@@ -1,7 +1,7 @@
-
-#ifndef __TCPA_ERROR_H__
-#define __TCPA_ERROR_H__
-
-#warning including deprecated header file tcpa_error.h
-
-#endif
+
+#ifndef __TCPA_ERROR_H__
+#define __TCPA_ERROR_H__
+
+#warning including deprecated header file tcpa_error.h
+
+#endif
diff --git a/src/include/tss/tcpa_struct.h b/src/include/tss/tcpa_struct.h
index 8ba7db7..1b5b95d 100644
--- a/src/include/tss/tcpa_struct.h
+++ b/src/include/tss/tcpa_struct.h
@@ -1,7 +1,7 @@
-
-#ifndef __TCPA_STRUCT_H__
-#define __TCPA_STRUCT_H__
-
-#warning including deprecated header file tcpa_struct.h
-
-#endif
+
+#ifndef __TCPA_STRUCT_H__
+#define __TCPA_STRUCT_H__
+
+#warning including deprecated header file tcpa_struct.h
+
+#endif
diff --git a/src/include/tss/tcpa_typedef.h b/src/include/tss/tcpa_typedef.h
index 9bcac88..a0de2fc 100644
--- a/src/include/tss/tcpa_typedef.h
+++ b/src/include/tss/tcpa_typedef.h
@@ -1,7 +1,7 @@
-
-#ifndef __TCPA_TYPEDEF_H__
-#define __TCPA_TYPEDEF_H__
-
-#warning including deprecated header file tcpa_typedef.h
-
-#endif
+
+#ifndef __TCPA_TYPEDEF_H__
+#define __TCPA_TYPEDEF_H__
+
+#warning including deprecated header file tcpa_typedef.h
+
+#endif
diff --git a/src/include/tss/tcs.h b/src/include/tss/tcs.h
index f2ec7f4..f6538da 100644
--- a/src/include/tss/tcs.h
+++ b/src/include/tss/tcs.h
@@ -1,1129 +1,1129 @@
-#ifndef TCS_H
-#define TCS_H
-#include <tss/platform.h>
-#include <tss/tss_structs.h>
-#include <tss/tcs_typedef.h>
-#include <tss/tcs_defines.h>
-#include <tss/tcs_structs.h>
-#include <tss/tcs_error.h>
-#include <tss/tpm.h>
-
-#if defined __cplusplus
-extern "C" {
-#endif 
-
-extern TSS_RESULT Tcsi_OpenContext
-(
-    TCS_CONTEXT_HANDLE*   hContext                     // out
-);
-extern TSS_RESULT Tcsi_CloseContext
-(
-    TCS_CONTEXT_HANDLE    hContext                     // in
-);
-extern TSS_RESULT Tcsi_FreeMemory
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    BYTE*                 pMemory                      // in
-);
-extern TSS_RESULT Tcsi_GetCapability
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_CAPABILITY_AREA   capArea,                     // in
-    UINT32                subCapSize,                  // in
-    BYTE*                 subCap,                      // in
-    UINT32*               respSize,                    // out
-    BYTE**                resp                         // out
-);
-extern TSS_RESULT Tcsi_RegisterKey
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_UUID              WrappingKeyUUID,             // in
-    TSS_UUID              KeyUUID,                     // in
-    UINT32                cKeySize,                    // in
-    BYTE*                 rgbKey,                      // in
-    UINT32                cVendorDataSize,             // in
-    BYTE*                 gbVendorData                 // in
-);
-extern TSS_RESULT Tcsip_UnregisterKey
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_UUID              KeyUUID                      // in
-);
-extern TSS_RESULT Tcsip_KeyControlOwner
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        hKey,                        // in
-    UINT32                ulPubKeyLength,              // in
-    BYTE*                 prgbPubKey,                  // in
-    UINT32                attribName,                  // in
-    TSS_BOOL              attribValue,                 // in
-    TPM_AUTH*             pOwnerAuth,                  // in, out
-    TSS_UUID*             pUuidData                    // out
-);
-extern TSS_RESULT Tcsi_EnumRegisteredKeys
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_UUID*             pKeyUUID,                    // in
-    UINT32*               pcKeyHierarchySize,          // out
-    TSS_KM_KEYINFO**      ppKeyHierarchy               // out
-);
-extern TSS_RESULT Tcsi_GetRegisteredKey
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_UUID              KeyUUID,                     // in
-    TSS_KM_KEYINFO**      ppKeyInfo                    // out
-);
-extern TSS_RESULT Tcsi_GetRegisteredKeyBlob
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_UUID              KeyUUID,                     // in
-    UINT32*               pcKeySize,                   // out
-    BYTE**                prgbKey                      // out
-);
-extern TSS_RESULT Tcsip_GetRegisteredKeyByPublicInfo
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_ALGORITHM_ID      algID,                       // in
-    UINT32                ulPublicInfoLength,          // in
-    BYTE*                 rgbPublicInfo,               // in
-    UINT32*               keySize,                     // out
-    BYTE**                keyBlob                      // out
-);
-extern TSS_RESULT Tcsip_LoadKeyByBlob
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        hUnwrappingKey,              // in
-    UINT32                cWrappedKeyBlobSize,         // in
-    BYTE*                 rgbWrappedKeyBlob,           // in
-    TPM_AUTH*             pAuth,                       // in, out
-    TCS_KEY_HANDLE*       phKeyTCSI,                   // out
-    TCS_KEY_HANDLE*       phKeyHMAC                    // out
-);
-extern TSS_RESULT Tcsip_LoadKeyByUUID
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_UUID              KeyUUID,                     // in
-    TCS_LOADKEY_INFO*     pLoadKeyInfo,                // in, out
-    TCS_KEY_HANDLE*       phKeyTCSI                    // out
-);
-extern TSS_RESULT Tcsip_EvictKey
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        hKey                         // in
-);
-extern TSS_RESULT Tcsip_CreateWrapKey
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        hWrappingKey,                // in
-    TPM_ENCAUTH           KeyUsageAuth,                // in
-    TPM_ENCAUTH           KeyMigrationAuth,            // in
-    UINT32                keyInfoSize,                 // in
-    BYTE*                 keyInfo,                     // in
-    TPM_AUTH*             pAuth,                       // in, out
-    UINT32*               keyDataSize,                 // out
-    BYTE**                keyData                      // out
-);
-extern TSS_RESULT Tcsip_GetPubKey
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        hKey,                        // in
-    TPM_AUTH*             pAuth,                       // in, out
-    UINT32*               pcPubKeySize,                // out
-    BYTE**                prgbPubKey                   // out
-);
-extern TSS_RESULT Tcsip_MakeIdentity
-(
-    TCS_CONTEXT_HANDLE    hContext,                              // in
-    TPM_ENCAUTH           identityAuth,                          // in
-    TPM_CHOSENID_HASH     IDLabel_PrivCAHash,                    // in
-    UINT32                idIdentityKeyInfoSize,                 // in
-    BYTE*                 idIdentityKeyInfo,                     // in
-    TPM_AUTH*             pSrkAuth,                              // in, out
-    TPM_AUTH*             pOwnerAuth,                            // in, out
-    UINT32*               idIdentityKeySize,                     // out
-    BYTE**                idIdentityKey,                         // out
-    UINT32*               pcIdentityBindingSize,                 // out
-    BYTE**                prgbIdentityBinding,                   // out
-    UINT32*               pcEndorsementCredentialSize,           // out
-    BYTE**                prgbEndorsementCredential,             // out
-    UINT32*               pcPlatformCredentialSize,              // out
-    BYTE**                prgbPlatformCredential,                // out
-    UINT32*               pcConformanceCredentialSize,           // out
-    BYTE**                prgbConformanceCredential              // out
-);
-extern TSS_RESULT Tcsip_MakeIdentity2
-(
-    TCS_CONTEXT_HANDLE    hContext,                              // in
-    TPM_ENCAUTH           identityAuth,                          // in
-    TPM_CHOSENID_HASH     IDLabel_PrivCAHash,                    // in
-    UINT32                idIdentityKeyInfoSize,                 // in
-    BYTE*                 idIdentityKeyInfo,                     // in
-    TPM_AUTH*             pSrkAuth,                              // in, out
-    TPM_AUTH*             pOwnerAuth,                            // in, out
-    UINT32*               idIdentityKeySize,                     // out
-    BYTE**                idIdentityKey,                         // out
-    UINT32*               pcIdentityBindingSize,                 // out
-    BYTE**                prgbIdentityBinding                    // out
-);
-extern TSS_RESULT Tcsi_LogPcrEvent
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_PCR_EVENT         Event,                       // in
-    UINT32*               pNumber                      // out
-);
-extern TSS_RESULT Tcsi_GetPcrEvent
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32                PcrIndex,                    // in
-    UINT32*               pNumber,                     // in, out
-    TSS_PCR_EVENT**       ppEvent                      // out
-);
-extern TSS_RESULT Tcsi_GetPcrEventsByPcr
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32                PcrIndex,                    // in
-    UINT32                FirstEvent,                  // in
-    UINT32*               pEventCount,                 // in, out
-    TSS_PCR_EVENT**       ppEvents                     // out
-);
-extern TSS_RESULT Tcsi_GetPcrEventLog
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32*               pEventCount,                 // out
-    TSS_PCR_EVENT**       ppEvents                     // out
-);
-extern TSS_RESULT Tcsip_SetOwnerInstall
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_BOOL              state                        // in
-);
-extern TSS_RESULT Tcsip_TakeOwnership
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT16                protocolID,                  // in
-    UINT32                encOwnerAuthSize,            // in
-    BYTE*                 encOwnerAuth,                // in
-    UINT32                encSrkAuthSize,              // in
-    BYTE*                 encSrkAuth,                  // in
-    UINT32                srkKeyInfoSize,              // in
-    BYTE*                 srkKeyInfo,                  // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    UINT32*               srkKeyDataSize,              // out
-    BYTE**                srkKeyData                   // out
-);
-extern TSS_RESULT Tcsip_SetOperatorAuth
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_SECRET            operatorAuth                 // in
-);
-extern TSS_RESULT Tcsip_OIAP
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_AUTHHANDLE*       authHandle,                  // out
-    TPM_NONCE*            nonce0                       // out
-);
-extern TSS_RESULT Tcsip_OSAP
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_ENTITY_TYPE       entityType,                  // in
-    UINT32                entityValue,                 // in
-    TPM_NONCE             nonceOddOSAP,                // in
-    TCS_AUTHHANDLE*       authHandle,                  // out
-    TPM_NONCE*            nonceEven,                   // out
-    TPM_NONCE*            nonceEvenOSAP                // out
-);
-extern TSS_RESULT Tcsip_ChangeAuth
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        parentHandle,                // in
-    TPM_PROTOCOL_ID       protocolID,                  // in
-    TPM_ENCAUTH           newAuth,                     // in
-    TPM_ENTITY_TYPE       entityType,                  // in
-    UINT32                encDataSize,                 // in
-    BYTE*                 encData,                     // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    TPM_AUTH*             entityAuth,                  // in, out
-    UINT32*               outDataSize,                 // out
-    BYTE**                outData                      // out
-);
-extern TSS_RESULT Tcsip_ChangeAuthOwner
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_PROTOCOL_ID       protocolID,                  // in
-    TPM_ENCAUTH           newAuth,                     // in
-    TPM_ENTITY_TYPE       entityType,                  // in
-    TPM_AUTH*             ownerAuth                    // in, out
-);
-extern TSS_RESULT Tcsip_ChangeAuthAsymStart
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        idHandle,                    // in
-    TPM_NONCE             antiReplay,                  // in
-    UINT32                TempKeyInfoSize,             // in
-    BYTE*                 TempKeyInfoData,             // in
-    TPM_AUTH*             pAuth,                       // in, out
-    UINT32*               TempKeySize,                 // out
-    BYTE**                TempKeyData,                 // out
-    UINT32*               CertifyInfoSize,             // out
-    BYTE**                CertifyInfo,                 // out
-    UINT32*               sigSize,                     // out
-    BYTE**                sig,                         // out
-    TCS_KEY_HANDLE*       ephHandle                    // out
-);
-extern TSS_RESULT Tcsip_ChangeAuthAsymFinish
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        parentHandle,                // in
-    TCS_KEY_HANDLE        ephHandle,                   // in
-    TPM_ENTITY_TYPE       entityType,                  // in
-    TPM_HMAC              newAuthLink,                 // in
-    UINT32                newAuthSize,                 // in
-    BYTE*                 encNewAuth,                  // in
-    UINT32                encDataSizeIn,               // in
-    BYTE*                 encDataIn,                   // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    UINT32*               encDataSizeOut,              // out
-    BYTE**                encDataOut,                  // out
-    TPM_NONCE*            saltNonce,                   // out
-    TPM_DIGEST*           changeProof                  // out
-);
-extern TSS_RESULT Tcsip_TerminateHandle
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_AUTHHANDLE        handle                       // in
-);
-extern TSS_RESULT Tcsip_ActivateTPMIdentity
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        idKey,                       // in
-    UINT32                blobSize,                    // in
-    BYTE*                 blob,                        // in
-    TPM_AUTH*             idKeyAuth,                   // in, out
-    TPM_AUTH*             ownerAuth,                   // in, out
-    UINT32*               SymmetricKeySize,            // out
-    BYTE**                SymmetricKey                 // out
-);
-extern TSS_RESULT Tcsip_EstablishTransport
-(
-    TCS_CONTEXT_HANDLE            hContext,                      // in
-    UINT32                        ulTransControlFlags,           // in
-    TCS_KEY_HANDLE                hEncKey,                       // in
-    UINT32                        ulTransSessionInfoSize,        // in
-    BYTE*                         rgbTransSessionInfo,           // in
-    UINT32                        ulSecretSize,                  // in
-    BYTE*                         rgbSecret,                     // in
-    TPM_AUTH*                     pEncKeyAuth,                   // in, out
-    TPM_MODIFIER_INDICATOR*       pbLocality,                    // out
-    TCS_HANDLE*                   hTransSession,                 // out
-    UINT32*                       ulCurrentTicksSize,            // out
-    BYTE**                        prgbCurrentTicks,              // out
-    TPM_NONCE*                    pTransNonce                    // out
-);
-extern TSS_RESULT Tcsip_ExecuteTransport
-(
-    TCS_CONTEXT_HANDLE            hContext,                      // in
-    TPM_COMMAND_CODE              unWrappedCommandOrdinal,       // in
-    UINT32                        ulWrappedCmdParamInSize,       // in
-    BYTE*                         rgbWrappedCmdParamIn,          // in
-    UINT32*                       pulHandleListSize,             // in, out
-    TCS_HANDLE**                  rghHandles,                    // in, out
-    TPM_AUTH*                     pWrappedCmdAuth1,              // in, out
-    TPM_AUTH*                     pWrappedCmdAuth2,              // in, out
-    TPM_AUTH*                     pTransAuth,                    // in, out
-    UINT64*                       punCurrentTicks,               // out
-    TPM_MODIFIER_INDICATOR*       pbLocality,                    // out
-    TPM_RESULT*                   pulWrappedCmdReturnCode,       // out
-    UINT32*                       ulWrappedCmdParamOutSize,      // out
-    BYTE**                        rgbWrappedCmdParamOut          // out
-);
-extern TSS_RESULT Tcsip_ReleaseTransportSigned
-(
-    TCS_CONTEXT_HANDLE            hContext,            // in
-    TCS_KEY_HANDLE                hSignatureKey,       // in
-    TPM_NONCE                     AntiReplayNonce,     // in
-    TPM_AUTH*                     pKeyAuth,            // in, out
-    TPM_AUTH*                     pTransAuth,          // in, out
-    TPM_MODIFIER_INDICATOR*       pbLocality,          // out
-    UINT32*                       pulCurrentTicksSize, // out
-    BYTE**                        prgbCurrentTicks,    // out
-    UINT32*                       pulSignatureSize,    // out
-    BYTE**                        prgbSignature        // out
-);
-extern TSS_RESULT Tcsip_Extend
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_PCRINDEX          pcrNum,                      // in
-    TPM_DIGEST            inDigest,                    // in
-    TPM_PCRVALUE*         outDigest                    // out
-);
-extern TSS_RESULT Tcsip_PcrRead
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_PCRINDEX          pcrNum,                      // in
-    TPM_PCRVALUE*         outDigest                    // out
-);
-extern TSS_RESULT Tcsip_Quote
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        keyHandle,                   // in
-    TPM_NONCE             antiReplay,                  // in
-    UINT32                pcrTargetSize,               // in
-    BYTE*                 pcrTarget,                   // in
-    TPM_AUTH*             privAuth,                    // in, out
-    UINT32*               pcrDataSize,                 // out
-    BYTE**                pcrData,                     // out
-    UINT32*               sigSize,                     // out
-    BYTE**                sig                          // out
-);
-extern TSS_RESULT Tcsip_Quote2
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        keyHandle,                   // in
-    TPM_NONCE             antiReplay,                  // in
-    UINT32                pcrTargetSize,               // in
-    BYTE*                 pcrTarget,                   // in
-    TSS_BOOL              addVersion,                  // in
-    TPM_AUTH*             privAuth,                    // in, out
-    UINT32*               pcrDataSize,                 // out
-    BYTE**                pcrData,                     // out
-    UINT32*               versionInfoSize,             // out
-    BYTE**                versionInfo,                 // out
-    UINT32*               sigSize,                     // out
-    BYTE**                sig                          // out
-);
-extern TSS_RESULT Tcsip_DirWriteAuth
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_DIRINDEX          dirIndex,                    // in
-    TPM_DIRVALUE          newContents,                 // in
-    TPM_AUTH*             ownerAuth                    // in, out
-);
-extern TSS_RESULT Tcsip_DirRead
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_DIRINDEX          dirIndex,                    // in
-    TPM_DIRVALUE*         dirValue                     // out
-);
-extern TSS_RESULT Tcsip_Seal
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        keyHandle,                   // in
-    TPM_ENCAUTH           encAuth,                     // in
-    UINT32                pcrInfoSize,                 // in
-    BYTE*                 PcrInfo,                     // in
-    UINT32                inDataSize,                  // in
-    BYTE*                 inData,                      // in
-    TPM_AUTH*             pubAuth,                     // in, out
-    UINT32*               SealedDataSize,              // out
-    BYTE**                SealedData                   // out
-);
-extern TSS_RESULT Tcsip_Unseal
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        keyHandle,                   // in
-    UINT32                SealedDataSize,              // in
-    BYTE*                 SealedData,                  // in
-    TPM_AUTH*             keyAuth,                     // in, out
-    TPM_AUTH*             dataAuth,                    // in, out
-    UINT32*               DataSize,                    // out
-    BYTE**                Data                         // out
-);
-extern TSS_RESULT Tcsip_UnBind
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        keyHandle,                   // in
-    UINT32                inDataSize,                  // in
-    BYTE*                 inData,                      // in
-    TPM_AUTH*             privAuth,                    // in, out
-    UINT32*               outDataSize,                 // out
-    BYTE**                outData                      // out
-);
-extern TSS_RESULT Tcsip_Sealx
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        keyHandle,                   // in
-    TPM_ENCAUTH           encAuth,                     // in
-    UINT32                pcrInfoSize,                 // in
-    BYTE*                 PcrInfo,                     // in
-    UINT32                inDataSize,                  // in
-    BYTE*                 inData,                      // in
-    TPM_AUTH*             pubAuth,                     // in, out
-    UINT32*               SealedDataSize,              // out
-    BYTE**                SealedData                   // out
-);
-extern TSS_RESULT Tcsip_LoadKey2ByBlob
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        hUnwrappingKey,              // in
-    UINT32                cWrappedKeyBlobSize,         // in
-    BYTE*                 rgbWrappedKeyBlob,           // in
-    TPM_AUTH*             pAuth,                       // in, out
-    TCS_KEY_HANDLE*       phKeyTCSI                    // out
-);
-extern TSS_RESULT Tcsip_CreateMigrationBlob
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        parentHandle,                // in
-    TSS_MIGRATE_SCHEME    migrationType,               // in
-    UINT32                MigrationKeyAuthSize,        // in
-    BYTE*                 MigrationKeyAuth,            // in
-    UINT32                encDataSize,                 // in
-    BYTE*                 encData,                     // in
-    TPM_AUTH*             parentAuth,                  // in, out
-    TPM_AUTH*             entityAuth,                  // in, out
-    UINT32*               randomSize,                  // out
-    BYTE**                random,                      // out
-    UINT32*               outDataSize,                 // out
-    BYTE**                outData                      // out
-);
-extern TSS_RESULT Tcsip_ConvertMigrationBlob
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        parentHandle,                // in
-    UINT32                inDataSize,                  // in
-    BYTE*                 inData,                      // in
-    UINT32                randomSize,                  // in
-    BYTE*                 random,                      // in
-    TPM_AUTH*             parentAuth,                  // in, out
-    UINT32*               outDataSize,                 // out
-    BYTE**                outData                      // out
-);
-extern TSS_RESULT Tcsip_AuthorizeMigrationKey
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_MIGRATE_SCHEME    migrateScheme,               // in
-    UINT32                MigrationKeySize,            // in
-    BYTE*                 MigrationKey,                // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    UINT32*               MigrationKeyAuthSize,        // out
-    BYTE**                MigrationKeyAuth             // out
-);
-extern TSS_RESULT Tcsip_CertifyKey
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        certHandle,                  // in
-    TCS_KEY_HANDLE        keyHandle,                   // in
-    TPM_NONCE             antiReplay,                  // in
-    TPM_AUTH*             certAuth,                    // in, out
-    TPM_AUTH*             keyAuth,                     // in, out
-    UINT32*               CertifyInfoSize,             // out
-    BYTE**                CertifyInfo,                 // out
-    UINT32*               outDataSize,                 // out
-    BYTE**                outData                      // out
-);
-extern TSS_RESULT Tcsip_CertifyKey2
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        certHandle,                  // in
-    TCS_KEY_HANDLE        keyHandle,                   // in
-    TPM_DIGEST            MSAdigest,                   // in
-    TPM_NONCE             antiReplay,                  // in
-    TPM_AUTH*             certAuth,                    // in, out
-    TPM_AUTH*             keyAuth,                     // in, out
-    UINT32*               CertifyInfoSize,             // out
-    BYTE**                CertifyInfo,                 // out
-    UINT32*               outDataSize,                 // out
-    BYTE**                outData                      // out
-);
-extern TSS_RESULT Tcsip_Sign
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        keyHandle,                   // in
-    UINT32                areaToSignSize,              // in
-    BYTE*                 areaToSign,                  // in
-    TPM_AUTH*             privAuth,                    // in, out
-    UINT32*               sigSize,                     // out
-    BYTE**                sig                          // out
-);
-extern TSS_RESULT Tcsip_GetRandom
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32*               bytesRequested,              // in, out
-    BYTE**                randomBytes                  // out
-);
-extern TSS_RESULT Tcsip_StirRandom
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32                inDataSize,                  // in
-    BYTE*                 inData                       // in
-);
-extern TSS_RESULT Tcsip_GetCapability
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_CAPABILITY_AREA   capArea,                     // in
-    UINT32                subCapSize,                  // in
-    BYTE*                 subCap,                      // in
-    UINT32*               respSize,                    // out
-    BYTE**                resp                         // out
-);
-extern TSS_RESULT Tcsip_GetCapabilitySigned
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        keyHandle,                   // in
-    TPM_NONCE             antiReplay,                  // in
-    TPM_CAPABILITY_AREA   capArea,                     // in
-    UINT32                subCapSize,                  // in
-    BYTE*                 subCap,                      // in
-    TPM_AUTH*             privAuth,                    // in, out
-    TPM_VERSION*          Version,                     // out
-    UINT32*               respSize,                    // out
-    BYTE**                resp,                        // out
-    UINT32*               sigSize,                     // out
-    BYTE**                sig                          // out
-);
-extern TSS_RESULT Tcsip_GetCapabilityOwner
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_AUTH*             pOwnerAuth,                  // in, out
-    TPM_VERSION*          pVersion,                    // out
-    UINT32*               pNonVolatileFlags,           // out
-    UINT32*               pVolatileFlags               // out
-);
-extern TSS_RESULT Tcsip_CreateEndorsementKeyPair
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_NONCE             antiReplay,                  // in
-    UINT32                endorsementKeyInfoSize,      // in
-    BYTE*                 endorsementKeyInfo,          // in
-    UINT32*               endorsementKeySize,          // out
-    BYTE**                endorsementKey,              // out
-    TPM_DIGEST*           checksum                     // out
-);
-extern TSS_RESULT Tcsip_ReadPubek
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_NONCE             antiReplay,                  // in
-    UINT32*               pubEndorsementKeySize,       // out
-    BYTE**                pubEndorsementKey,           // out
-    TPM_DIGEST*           checksum                     // out
-);
-extern TSS_RESULT Tcsip_DisablePubekRead
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_AUTH*             ownerAuth                    // in, out
-);
-extern TSS_RESULT Tcsip_OwnerReadPubek
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    UINT32*               pubEndorsementKeySize,       // out
-    BYTE**                pubEndorsementKey            // out
-);
-extern TSS_RESULT Tcsip_SelfTestFull
-(
-    TCS_CONTEXT_HANDLE    hContext                     // in
-);
-extern TSS_RESULT Tcsip_CertifySelfTest
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        keyHandle,                   // in
-    TPM_NONCE             antiReplay,                  // in
-    TPM_AUTH*             privAuth,                    // in, out
-    UINT32*               sigSize,                     // out
-    BYTE**                sig                          // out
-);
-extern TSS_RESULT Tcsip_ContinueSelfTest
-(
-    TCS_CONTEXT_HANDLE    hContext                     // in
-);
-extern TSS_RESULT Tcsip_GetTestResult
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32*               outDataSize,                 // out
-    BYTE**                outData                      // out
-);
-extern TSS_RESULT Tcsip_OwnerSetDisable
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_BOOL              disableState,                // in
-    TPM_AUTH*             ownerAuth                    // in, out
-);
-extern TSS_RESULT Tcsip_OwnerClear
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_AUTH*             ownerAuth                    // in, out
-);
-extern TSS_RESULT Tcsip_DisableOwnerClear
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_AUTH*             ownerAuth                    // in, out
-);
-extern TSS_RESULT Tcsip_ForceClear
-(
-    TCS_CONTEXT_HANDLE    hContext                     // in
-);
-extern TSS_RESULT Tcsip_DisableForceClear
-(
-    TCS_CONTEXT_HANDLE    hContext                     // in
-);
-extern TSS_RESULT Tcsip_PhysicalDisable
-(
-    TCS_CONTEXT_HANDLE    hContext                     // in
-);
-extern TSS_RESULT Tcsip_PhysicalEnable
-(
-    TCS_CONTEXT_HANDLE    hContext                     // in
-);
-extern TSS_RESULT Tcsip_PhysicalSetDeactivated
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_BOOL              state                        // in
-);
-extern TSS_RESULT Tcsip_SetTempDeactivated
-(
-    TCS_CONTEXT_HANDLE    hContext                     // in
-);
-extern TSS_RESULT Tcsip_SetTempDeactivated2
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_AUTH*             pOperatorAuth                // in, out
-);
-extern TSS_RESULT Tcsip_OwnerReadInternalPub
-(
-    TCS_CONTEXT_HANDLE   hContext,                     // in
-    TCS_KEY_HANDLE       hKey,                         // in
-    TPM_AUTH*            pOwnerAuth,                   // in, out
-    UINT32*              punPubKeySize,                // out
-    BYTE**               ppbPubKeyData                 // out
-);
-extern TSS_RESULT Tcsip_PhysicalPresence
-(
-    TCS_CONTEXT_HANDLE            hContext,            // in
-    TPM_PHYSICAL_PRESENCE         fPhysicalPresence    // in
-);
-extern TSS_RESULT Tcsip_FieldUpgrade
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32                dataInSize,                  // in
-    BYTE*                 dataIn,                      // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    UINT32*               dataOutSize,                 // out
-    BYTE**                dataOut                      // out
-);
-extern TSS_RESULT Tcsip_ResetLockValue
-(
-    TCS_CONTEXT_HANDLE            hContext,            // in
-    TPM_AUTH*                     ownerAuth            // in, out
-);
-extern TSS_RESULT Tcsip_FlushSpecific
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_HANDLE            hResHandle,                  // in
-    TPM_RESOURCE_TYPE     resourceType                 // in
-);
-extern TSS_RESULT Tcsip_SetRedirection
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        keyHandle,                   // in
-    UINT32                c1,                          // in
-    UINT32                c2,                          // in
-    TPM_AUTH*             privAuth                     // in, out
-);
-extern TSS_RESULT Tcsip_DSAP
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_ENTITY_TYPE       entityType,                  // in
-    TCS_KEY_HANDLE        keyHandle,                   // in
-    TPM_NONCE             nonceOddDSAP,                // in
-    UINT32                entityValueSize,             // in
-    BYTE*                 entityValue,                 // in
-    TCS_AUTHHANDLE*       authHandle,                  // out
-    TPM_NONCE*            nonceEven,                   // out
-    TPM_NONCE*            nonceEvenDSAP                // out
-);
-extern TSS_RESULT Tcsip_Delegate_Manage
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_FAMILY_ID         familyID,                    // in
-    TPM_FAMILY_OPERATION  opFlag,                      // in
-    UINT32                opDataSize,                  // in
-    BYTE*                 opData,                      // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    UINT32*               retDataSize,                 // out
-    BYTE**                retData                      // out
-);
-extern TSS_RESULT Tcsip_Delegate_CreateKeyDelegation
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        hKey,                        // in
-    UINT32                publicInfoSize,              // in
-    BYTE*                 publicInfo,                  // in
-    TPM_ENCAUTH           encDelAuth,                  // in
-    TPM_AUTH*             keyAuth,                     // in, out
-    UINT32*               blobSize,                    // out
-    BYTE**                blob                         // out
-);
-extern TSS_RESULT Tcsip_Delegate_CreateOwnerDelegation
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_BOOL              increment,                   // in
-    UINT32                publicInfoSize,              // in
-    BYTE*                 publicInfo,                  // in
-    TPM_ENCAUTH           encDelAuth,                  // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    UINT32*               blobSize,                    // out
-    BYTE**                blob                         // out
-);
-extern TSS_RESULT Tcsip_Delegate_LoadOwnerDelegation
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_DELEGATE_INDEX    index,                       // in
-    UINT32                blobSize,                    // in
-    BYTE*                 blob,                        // in
-    TPM_AUTH*             ownerAuth                    // in, out
-);
-extern TSS_RESULT Tcsip_Delegate_UpdateVerificationCount
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32                inputSize,                   // in
-    BYTE*                 input,                       // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    UINT32*               outputSize,                  // out
-    BYTE**                output                       // out
-);
-extern TSS_RESULT Tcsip_Delegate_VerifyDelegation
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32                delegateSize,                // in
-    BYTE*                 delegate                     // in
-);
-extern TSS_RESULT Tcsip_Delegate_ReadTable
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32*               pulFamilyTableSize,          // out
-    BYTE**                ppFamilyTable,               // out
-    UINT32*               pulDelegateTableSize,        // out
-    BYTE**                ppDelegateTable              // out
-);
-extern TSS_RESULT Tcsip_NV_DefineOrReleaseSpace
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32                cPubInfoSize,                // in
-    BYTE*                 pPubInfo,                    // in
-    TPM_ENCAUTH           encAuth,                     // in
-    TPM_AUTH*             pAuth                        // in, out
-);
-extern TSS_RESULT Tcsip_NV_WriteValue
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_NV_INDEX          hNVStore,                    // in
-    UINT32                offset,                      // in
-    UINT32                ulDataLength,                // in
-    BYTE*                 rgbDataToWrite,              // in
-    TPM_AUTH*             privAuth                     // in, out
-);
-extern TSS_RESULT Tcsip_NV_WriteValueAuth
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_NV_INDEX          hNVStore,                    // in
-    UINT32                offset,                      // in
-    UINT32                ulDataLength,                // in
-    BYTE*                 rgbDataToWrite,              // in
-    TPM_AUTH*             NVAuth                       // in, out
-);
-extern TSS_RESULT Tcsip_NV_ReadValue
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_NV_INDEX          hNVStore,                    // in
-    UINT32                offset,                      // in
-    UINT32*               pulDataLength,               // in, out
-    TPM_AUTH*             privAuth,                    // in, out
-    BYTE**                rgbDataRead                  // out
-);
-extern TSS_RESULT Tcsip_NV_ReadValueAuth
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_NV_INDEX          hNVStore,                    // in
-    UINT32                offset,                      // in
-    UINT32*               pulDataLength,               // in, out
-    TPM_AUTH*             NVAuth,                      // in, out
-    BYTE**                rgbDataRead                  // out
-);
-extern TSS_RESULT Tcsip_CreateMaintenanceArchive
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_BOOL              generateRandom,              // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    UINT32*               randomSize,                  // out
-    BYTE**                random,                      // out
-    UINT32*               archiveSize,                 // out
-    BYTE**                archive                      // out
-);
-extern TSS_RESULT Tcsip_LoadMaintenanceArchive
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32                dataInSize,                  // in
-    BYTE*                 dataIn,                      // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    UINT32*               dataOutSize,                 // out
-    BYTE**                dataOut                      // out
-);
-extern TSS_RESULT Tcsip_KillMaintenanceFeature
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_AUTH*             ownerAuth                    // in, out
-);
-extern TSS_RESULT Tcsip_LoadManuMaintPub
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_NONCE             antiReplay,                  // in
-    UINT32                PubKeySize,                  // in
-    BYTE*                 PubKey,                      // in
-    TPM_DIGEST*           checksum                     // out
-);
-extern TSS_RESULT Tcsip_ReadManuMaintPub
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_NONCE             antiReplay,                  // in
-    TPM_DIGEST*           checksum                     // out
-);
-extern TSS_RESULT Tcsip_CreateRevocableEndorsementKeyPair
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_NONCE             antiReplay,                  // in
-    UINT32                endorsementKeyInfoSize,      // in
-    BYTE*                 endorsementKeyInfo,          // in
-    TSS_BOOL              GenResetAuth,                // in
-    TPM_DIGEST*           EKResetAuth,                 // in, out
-    UINT32*               endorsementKeySize,          // out
-    BYTE**                endorsementKey,              // out
-    TPM_DIGEST*           checksum                     // out
-);
-extern TSS_RESULT Tcsip_RevokeEndorsementKeyPair
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_DIGEST            EKResetAuth                  // in
-);
-extern TSS_RESULT Tcsip_PcrReset
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32                pcrTargetSize,               // in
-    BYTE*                 pcrTarget                    // in
-);
-extern TSS_RESULT Tcsip_ReadCounter
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_COUNTER_ID        idCounter,                   // in
-    TPM_COUNTER_VALUE*    counterValue                 // out
-);
-extern TSS_RESULT Tcsip_CreateCounter
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32                LabelSize,                   // in (=4)
-    BYTE*                 pLabel,                      // in
-    TPM_ENCAUTH           CounterAuth,                 // in
-    TPM_AUTH*             pOwnerAuth,                  // in, out
-    TSS_COUNTER_ID*       idCounter,                   // out
-    TPM_COUNTER_VALUE*    counterValue                 // out
-);
-extern TSS_RESULT Tcsip_IncrementCounter
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_COUNTER_ID        idCounter,                   // in
-    TPM_AUTH*             pCounterAuth,                // in, out
-    TPM_COUNTER_VALUE*    counterValue                 // out
-);
-extern TSS_RESULT Tcsip_ReleaseCounter
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_COUNTER_ID        idCounter,                   // in
-    TPM_AUTH*             pCounterAuth                 // in, out
-);
-extern TSS_RESULT Tcsip_ReleaseCounterOwner
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_COUNTER_ID        idCounter,                   // in
-    TPM_AUTH*             pOwnerAuth                   // in, out
-);
-extern TSS_RESULT Tcsip_ReadCurrentTicks
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32*               pulCurrentTimeSize,          // out
-    BYTE**                prgbCurrentTime              // out
-);
-extern TSS_RESULT Tcsip_TickStampBlob
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        hKey,                        // in
-    TPM_NONCE             antiReplay,                  // in
-    TPM_DIGEST            digestToStamp,               // in
-    TPM_AUTH*             privAuth,                    // in, out
-    UINT32*               pulSignatureLength,          // out
-    BYTE**                prgbSignature,               // out
-    UINT32*               pulTickCountSize,            // out
-    BYTE**                prgbTickCount                // out
-);
-extern TSS_RESULT Tcsip_TPM_DAA_Join
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_HANDLE            handle,                      // in
-    BYTE                  stage,                       // in
-    UINT32                inputSize0,                  // in
-    BYTE*                 inputData0,                  // in
-    UINT32                inputSize1,                  // in
-    BYTE*                 inputData1,                  // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    UINT32*               outputSize,                  // out
-    BYTE**                outputData                   // out
-);
-extern TSS_RESULT Tcsip_TPM_DAA_Sign
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_HANDLE            handle,                      // in
-    BYTE                  stage,                       // in
-    UINT32                inputSize0,                  // in
-    BYTE*                 inputData0,                  // in
-    UINT32                inputSize1,                  // in
-    BYTE*                 inputData1,                  // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    UINT32*               outputSize,                  // out
-    BYTE**                outputData                   // out
-);
-extern TSS_RESULT Tcsip_MigrateKey
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        hMaKey,                      // in
-    UINT32                PublicKeySize,               // in
-    BYTE*                 PublicKey,                   // in
-    UINT32                inDataSize,                  // in
-    BYTE*                 inData,                      // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    UINT32*               outDataSize,                 // out
-    BYTE**                outData                      // out
-);
-extern TSS_RESULT Tcsip_CMK_SetRestrictions
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TSS_CMK_DELEGATE      Restriction,                 // in
-    TPM_AUTH*             ownerAuth                    // in, out
-);
-extern TSS_RESULT Tcsip_CMK_ApproveMA
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_DIGEST            migAuthorityDigest,          // in
-    TPM_AUTH*             ownerAuth,                   // in, out
-    TPM_HMAC*             HmacMigAuthDigest            // out
-);
-extern TSS_RESULT Tcsip_CMK_CreateKey
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        hWrappingKey,                // in
-    TPM_ENCAUTH           KeyUsageAuth,                // in
-    TPM_HMAC              MigAuthApproval,             // in
-    TPM_DIGEST            MigAuthorityDigest,          // in
-    UINT32*               keyDataSize,                 // in, out
-    BYTE**                prgbKeyData,                 // in, out
-    TPM_AUTH*             pAuth                        // in, out
-);
-extern TSS_RESULT Tcsip_CMK_CreateTicket
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32                PublicVerifyKeySize,         // in
-    BYTE*                 PublicVerifyKey,             // in
-    TPM_DIGEST            SignedData,                  // in
-    UINT32                SigValueSize,                // in
-    BYTE*                 SigValue,                    // in
-    TPM_AUTH*             pOwnerAuth,                  // in, out
-    TPM_HMAC*             SigTicket                    // out
-);
-extern TSS_RESULT Tcsip_CMK_CreateBlob
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        parentHandle,                // in
-    TSS_MIGRATE_SCHEME    migrationType,               // in
-    UINT32                MigrationKeyAuthSize,        // in
-    BYTE*                 MigrationKeyAuth,            // in
-    TPM_DIGEST            PubSourceKeyDigest,          // in
-    UINT32                msaListSize,                 // in
-    BYTE*                 msaList,                     // in
-    UINT32                restrictTicketSize,          // in
-    BYTE*                 restrictTicket,              // in
-    UINT32                sigTicketSize,               // in
-    BYTE*                 sigTicket,                   // in
-    UINT32                encDataSize,                 // in
-    BYTE*                 encData,                     // in
-    TPM_AUTH*             parentAuth,                  // in, out
-    UINT32*               randomSize,                  // out
-    BYTE**                random,                      // out
-    UINT32*               outDataSize,                 // out
-    BYTE**                outData                      // out
-);
-extern TSS_RESULT Tcsip_CMK_ConvertMigration
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        parentHandle,                // in
-    TPM_CMK_AUTH          restrictTicket,              // in
-    TPM_HMAC              sigTicket,                   // in
-    UINT32                keyDataSize,                 // in
-    BYTE*                 prgbKeyData,                 // in
-    UINT32                msaListSize,                 // in
-    BYTE*                 msaList,                     // in
-    UINT32                randomSize,                  // in
-    BYTE*                 random,                      // in
-    TPM_AUTH*             parentAuth,                  // in, out
-    UINT32*               outDataSize,                 // out
-    BYTE**                outData                      // out
-);
-extern TSS_RESULT Tcsip_SetCapability
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TPM_CAPABILITY_AREA   capArea,                     // in
-    UINT32                subCapSize,                  // in
-    BYTE*                 subCap,                      // in
-    UINT32                valueSize,                   // in
-    BYTE*                 value,                       // in
-    TPM_AUTH*             ownerAuth                    // in, out
-);
-extern TSS_RESULT Tcsip_GetAuditDigest
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32                startOrdinal,                // in
-    TPM_DIGEST*           auditDigest,                 // out
-    UINT32*               counterValueSize,            // out
-    BYTE**                counterValue,                // out
-    TSS_BOOL*             more,                        // out
-    UINT32*               ordSize,                     // out
-    UINT32**              ordList                      // out
-);
-extern TSS_RESULT Tcsip_GetAuditDigestSigned
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    TCS_KEY_HANDLE        keyHandle,                   // in
-    TSS_BOOL              closeAudit,                  // in
-    TPM_NONCE             antiReplay,                  // in
-    TPM_AUTH*             privAuth,                    // in, out
-    UINT32*               counterValueSize,            // out
-    BYTE**                counterValue,                // out
-    TPM_DIGEST*           auditDigest,                 // out
-    TPM_DIGEST*           ordinalDigest,               // out
-    UINT32*               sigSize,                     // out
-    BYTE**                sig                          // out
-);
-extern TSS_RESULT Tcsip_SetOrdinalAuditStatus
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32                ordinalToAudit,              // in
-    TSS_BOOL              auditState,                  // in
-    TPM_AUTH*             ownerAuth                    // in, out
-);
-extern TSS_RESULT Tcsi_Admin_TSS_SessionsPerLocality
-(
-    TCS_CONTEXT_HANDLE    hContext,                    // in
-    UINT32                ulLocality,                  // in
-    UINT32                ulSessions,                  // in
-    TPM_AUTH*             pOwnerAuth                   // in, out
-);
-extern TSS_RESULT Tcsi_GetCredential
-(
-    TCS_CONTEXT_HANDLE  hContext,               // in
-    UINT32              ulCredentialType,       // in
-    UINT32              ulCredentialAccessMode, // in
-    UINT32*             pulCredentialSize,      // out
-    BYTE**              prgbCredentialData      // out
-);
-
-#if defined __cplusplus
-} // extern "C"
-#endif
-
-#endif /* TCS_H */
+#ifndef TCS_H
+#define TCS_H
+#include <tss/platform.h>
+#include <tss/tss_structs.h>
+#include <tss/tcs_typedef.h>
+#include <tss/tcs_defines.h>
+#include <tss/tcs_structs.h>
+#include <tss/tcs_error.h>
+#include <tss/tpm.h>
+
+#if defined __cplusplus
+extern "C" {
+#endif 
+
+extern TSS_RESULT Tcsi_OpenContext
+(
+    TCS_CONTEXT_HANDLE*   hContext                     // out
+);
+extern TSS_RESULT Tcsi_CloseContext
+(
+    TCS_CONTEXT_HANDLE    hContext                     // in
+);
+extern TSS_RESULT Tcsi_FreeMemory
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    BYTE*                 pMemory                      // in
+);
+extern TSS_RESULT Tcsi_GetCapability
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_CAPABILITY_AREA   capArea,                     // in
+    UINT32                subCapSize,                  // in
+    BYTE*                 subCap,                      // in
+    UINT32*               respSize,                    // out
+    BYTE**                resp                         // out
+);
+extern TSS_RESULT Tcsi_RegisterKey
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_UUID              WrappingKeyUUID,             // in
+    TSS_UUID              KeyUUID,                     // in
+    UINT32                cKeySize,                    // in
+    BYTE*                 rgbKey,                      // in
+    UINT32                cVendorDataSize,             // in
+    BYTE*                 gbVendorData                 // in
+);
+extern TSS_RESULT Tcsip_UnregisterKey
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_UUID              KeyUUID                      // in
+);
+extern TSS_RESULT Tcsip_KeyControlOwner
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        hKey,                        // in
+    UINT32                ulPubKeyLength,              // in
+    BYTE*                 prgbPubKey,                  // in
+    UINT32                attribName,                  // in
+    TSS_BOOL              attribValue,                 // in
+    TPM_AUTH*             pOwnerAuth,                  // in, out
+    TSS_UUID*             pUuidData                    // out
+);
+extern TSS_RESULT Tcsi_EnumRegisteredKeys
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_UUID*             pKeyUUID,                    // in
+    UINT32*               pcKeyHierarchySize,          // out
+    TSS_KM_KEYINFO**      ppKeyHierarchy               // out
+);
+extern TSS_RESULT Tcsi_GetRegisteredKey
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_UUID              KeyUUID,                     // in
+    TSS_KM_KEYINFO**      ppKeyInfo                    // out
+);
+extern TSS_RESULT Tcsi_GetRegisteredKeyBlob
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_UUID              KeyUUID,                     // in
+    UINT32*               pcKeySize,                   // out
+    BYTE**                prgbKey                      // out
+);
+extern TSS_RESULT Tcsip_GetRegisteredKeyByPublicInfo
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_ALGORITHM_ID      algID,                       // in
+    UINT32                ulPublicInfoLength,          // in
+    BYTE*                 rgbPublicInfo,               // in
+    UINT32*               keySize,                     // out
+    BYTE**                keyBlob                      // out
+);
+extern TSS_RESULT Tcsip_LoadKeyByBlob
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        hUnwrappingKey,              // in
+    UINT32                cWrappedKeyBlobSize,         // in
+    BYTE*                 rgbWrappedKeyBlob,           // in
+    TPM_AUTH*             pAuth,                       // in, out
+    TCS_KEY_HANDLE*       phKeyTCSI,                   // out
+    TCS_KEY_HANDLE*       phKeyHMAC                    // out
+);
+extern TSS_RESULT Tcsip_LoadKeyByUUID
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_UUID              KeyUUID,                     // in
+    TCS_LOADKEY_INFO*     pLoadKeyInfo,                // in, out
+    TCS_KEY_HANDLE*       phKeyTCSI                    // out
+);
+extern TSS_RESULT Tcsip_EvictKey
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        hKey                         // in
+);
+extern TSS_RESULT Tcsip_CreateWrapKey
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        hWrappingKey,                // in
+    TPM_ENCAUTH           KeyUsageAuth,                // in
+    TPM_ENCAUTH           KeyMigrationAuth,            // in
+    UINT32                keyInfoSize,                 // in
+    BYTE*                 keyInfo,                     // in
+    TPM_AUTH*             pAuth,                       // in, out
+    UINT32*               keyDataSize,                 // out
+    BYTE**                keyData                      // out
+);
+extern TSS_RESULT Tcsip_GetPubKey
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        hKey,                        // in
+    TPM_AUTH*             pAuth,                       // in, out
+    UINT32*               pcPubKeySize,                // out
+    BYTE**                prgbPubKey                   // out
+);
+extern TSS_RESULT Tcsip_MakeIdentity
+(
+    TCS_CONTEXT_HANDLE    hContext,                              // in
+    TPM_ENCAUTH           identityAuth,                          // in
+    TPM_CHOSENID_HASH     IDLabel_PrivCAHash,                    // in
+    UINT32                idIdentityKeyInfoSize,                 // in
+    BYTE*                 idIdentityKeyInfo,                     // in
+    TPM_AUTH*             pSrkAuth,                              // in, out
+    TPM_AUTH*             pOwnerAuth,                            // in, out
+    UINT32*               idIdentityKeySize,                     // out
+    BYTE**                idIdentityKey,                         // out
+    UINT32*               pcIdentityBindingSize,                 // out
+    BYTE**                prgbIdentityBinding,                   // out
+    UINT32*               pcEndorsementCredentialSize,           // out
+    BYTE**                prgbEndorsementCredential,             // out
+    UINT32*               pcPlatformCredentialSize,              // out
+    BYTE**                prgbPlatformCredential,                // out
+    UINT32*               pcConformanceCredentialSize,           // out
+    BYTE**                prgbConformanceCredential              // out
+);
+extern TSS_RESULT Tcsip_MakeIdentity2
+(
+    TCS_CONTEXT_HANDLE    hContext,                              // in
+    TPM_ENCAUTH           identityAuth,                          // in
+    TPM_CHOSENID_HASH     IDLabel_PrivCAHash,                    // in
+    UINT32                idIdentityKeyInfoSize,                 // in
+    BYTE*                 idIdentityKeyInfo,                     // in
+    TPM_AUTH*             pSrkAuth,                              // in, out
+    TPM_AUTH*             pOwnerAuth,                            // in, out
+    UINT32*               idIdentityKeySize,                     // out
+    BYTE**                idIdentityKey,                         // out
+    UINT32*               pcIdentityBindingSize,                 // out
+    BYTE**                prgbIdentityBinding                    // out
+);
+extern TSS_RESULT Tcsi_LogPcrEvent
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_PCR_EVENT         Event,                       // in
+    UINT32*               pNumber                      // out
+);
+extern TSS_RESULT Tcsi_GetPcrEvent
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32                PcrIndex,                    // in
+    UINT32*               pNumber,                     // in, out
+    TSS_PCR_EVENT**       ppEvent                      // out
+);
+extern TSS_RESULT Tcsi_GetPcrEventsByPcr
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32                PcrIndex,                    // in
+    UINT32                FirstEvent,                  // in
+    UINT32*               pEventCount,                 // in, out
+    TSS_PCR_EVENT**       ppEvents                     // out
+);
+extern TSS_RESULT Tcsi_GetPcrEventLog
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32*               pEventCount,                 // out
+    TSS_PCR_EVENT**       ppEvents                     // out
+);
+extern TSS_RESULT Tcsip_SetOwnerInstall
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_BOOL              state                        // in
+);
+extern TSS_RESULT Tcsip_TakeOwnership
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT16                protocolID,                  // in
+    UINT32                encOwnerAuthSize,            // in
+    BYTE*                 encOwnerAuth,                // in
+    UINT32                encSrkAuthSize,              // in
+    BYTE*                 encSrkAuth,                  // in
+    UINT32                srkKeyInfoSize,              // in
+    BYTE*                 srkKeyInfo,                  // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    UINT32*               srkKeyDataSize,              // out
+    BYTE**                srkKeyData                   // out
+);
+extern TSS_RESULT Tcsip_SetOperatorAuth
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_SECRET            operatorAuth                 // in
+);
+extern TSS_RESULT Tcsip_OIAP
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_AUTHHANDLE*       authHandle,                  // out
+    TPM_NONCE*            nonce0                       // out
+);
+extern TSS_RESULT Tcsip_OSAP
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_ENTITY_TYPE       entityType,                  // in
+    UINT32                entityValue,                 // in
+    TPM_NONCE             nonceOddOSAP,                // in
+    TCS_AUTHHANDLE*       authHandle,                  // out
+    TPM_NONCE*            nonceEven,                   // out
+    TPM_NONCE*            nonceEvenOSAP                // out
+);
+extern TSS_RESULT Tcsip_ChangeAuth
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        parentHandle,                // in
+    TPM_PROTOCOL_ID       protocolID,                  // in
+    TPM_ENCAUTH           newAuth,                     // in
+    TPM_ENTITY_TYPE       entityType,                  // in
+    UINT32                encDataSize,                 // in
+    BYTE*                 encData,                     // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    TPM_AUTH*             entityAuth,                  // in, out
+    UINT32*               outDataSize,                 // out
+    BYTE**                outData                      // out
+);
+extern TSS_RESULT Tcsip_ChangeAuthOwner
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_PROTOCOL_ID       protocolID,                  // in
+    TPM_ENCAUTH           newAuth,                     // in
+    TPM_ENTITY_TYPE       entityType,                  // in
+    TPM_AUTH*             ownerAuth                    // in, out
+);
+extern TSS_RESULT Tcsip_ChangeAuthAsymStart
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        idHandle,                    // in
+    TPM_NONCE             antiReplay,                  // in
+    UINT32                TempKeyInfoSize,             // in
+    BYTE*                 TempKeyInfoData,             // in
+    TPM_AUTH*             pAuth,                       // in, out
+    UINT32*               TempKeySize,                 // out
+    BYTE**                TempKeyData,                 // out
+    UINT32*               CertifyInfoSize,             // out
+    BYTE**                CertifyInfo,                 // out
+    UINT32*               sigSize,                     // out
+    BYTE**                sig,                         // out
+    TCS_KEY_HANDLE*       ephHandle                    // out
+);
+extern TSS_RESULT Tcsip_ChangeAuthAsymFinish
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        parentHandle,                // in
+    TCS_KEY_HANDLE        ephHandle,                   // in
+    TPM_ENTITY_TYPE       entityType,                  // in
+    TPM_HMAC              newAuthLink,                 // in
+    UINT32                newAuthSize,                 // in
+    BYTE*                 encNewAuth,                  // in
+    UINT32                encDataSizeIn,               // in
+    BYTE*                 encDataIn,                   // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    UINT32*               encDataSizeOut,              // out
+    BYTE**                encDataOut,                  // out
+    TPM_NONCE*            saltNonce,                   // out
+    TPM_DIGEST*           changeProof                  // out
+);
+extern TSS_RESULT Tcsip_TerminateHandle
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_AUTHHANDLE        handle                       // in
+);
+extern TSS_RESULT Tcsip_ActivateTPMIdentity
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        idKey,                       // in
+    UINT32                blobSize,                    // in
+    BYTE*                 blob,                        // in
+    TPM_AUTH*             idKeyAuth,                   // in, out
+    TPM_AUTH*             ownerAuth,                   // in, out
+    UINT32*               SymmetricKeySize,            // out
+    BYTE**                SymmetricKey                 // out
+);
+extern TSS_RESULT Tcsip_EstablishTransport
+(
+    TCS_CONTEXT_HANDLE            hContext,                      // in
+    UINT32                        ulTransControlFlags,           // in
+    TCS_KEY_HANDLE                hEncKey,                       // in
+    UINT32                        ulTransSessionInfoSize,        // in
+    BYTE*                         rgbTransSessionInfo,           // in
+    UINT32                        ulSecretSize,                  // in
+    BYTE*                         rgbSecret,                     // in
+    TPM_AUTH*                     pEncKeyAuth,                   // in, out
+    TPM_MODIFIER_INDICATOR*       pbLocality,                    // out
+    TCS_HANDLE*                   hTransSession,                 // out
+    UINT32*                       ulCurrentTicksSize,            // out
+    BYTE**                        prgbCurrentTicks,              // out
+    TPM_NONCE*                    pTransNonce                    // out
+);
+extern TSS_RESULT Tcsip_ExecuteTransport
+(
+    TCS_CONTEXT_HANDLE            hContext,                      // in
+    TPM_COMMAND_CODE              unWrappedCommandOrdinal,       // in
+    UINT32                        ulWrappedCmdParamInSize,       // in
+    BYTE*                         rgbWrappedCmdParamIn,          // in
+    UINT32*                       pulHandleListSize,             // in, out
+    TCS_HANDLE**                  rghHandles,                    // in, out
+    TPM_AUTH*                     pWrappedCmdAuth1,              // in, out
+    TPM_AUTH*                     pWrappedCmdAuth2,              // in, out
+    TPM_AUTH*                     pTransAuth,                    // in, out
+    UINT64*                       punCurrentTicks,               // out
+    TPM_MODIFIER_INDICATOR*       pbLocality,                    // out
+    TPM_RESULT*                   pulWrappedCmdReturnCode,       // out
+    UINT32*                       ulWrappedCmdParamOutSize,      // out
+    BYTE**                        rgbWrappedCmdParamOut          // out
+);
+extern TSS_RESULT Tcsip_ReleaseTransportSigned
+(
+    TCS_CONTEXT_HANDLE            hContext,            // in
+    TCS_KEY_HANDLE                hSignatureKey,       // in
+    TPM_NONCE                     AntiReplayNonce,     // in
+    TPM_AUTH*                     pKeyAuth,            // in, out
+    TPM_AUTH*                     pTransAuth,          // in, out
+    TPM_MODIFIER_INDICATOR*       pbLocality,          // out
+    UINT32*                       pulCurrentTicksSize, // out
+    BYTE**                        prgbCurrentTicks,    // out
+    UINT32*                       pulSignatureSize,    // out
+    BYTE**                        prgbSignature        // out
+);
+extern TSS_RESULT Tcsip_Extend
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_PCRINDEX          pcrNum,                      // in
+    TPM_DIGEST            inDigest,                    // in
+    TPM_PCRVALUE*         outDigest                    // out
+);
+extern TSS_RESULT Tcsip_PcrRead
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_PCRINDEX          pcrNum,                      // in
+    TPM_PCRVALUE*         outDigest                    // out
+);
+extern TSS_RESULT Tcsip_Quote
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        keyHandle,                   // in
+    TPM_NONCE             antiReplay,                  // in
+    UINT32                pcrTargetSize,               // in
+    BYTE*                 pcrTarget,                   // in
+    TPM_AUTH*             privAuth,                    // in, out
+    UINT32*               pcrDataSize,                 // out
+    BYTE**                pcrData,                     // out
+    UINT32*               sigSize,                     // out
+    BYTE**                sig                          // out
+);
+extern TSS_RESULT Tcsip_Quote2
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        keyHandle,                   // in
+    TPM_NONCE             antiReplay,                  // in
+    UINT32                pcrTargetSize,               // in
+    BYTE*                 pcrTarget,                   // in
+    TSS_BOOL              addVersion,                  // in
+    TPM_AUTH*             privAuth,                    // in, out
+    UINT32*               pcrDataSize,                 // out
+    BYTE**                pcrData,                     // out
+    UINT32*               versionInfoSize,             // out
+    BYTE**                versionInfo,                 // out
+    UINT32*               sigSize,                     // out
+    BYTE**                sig                          // out
+);
+extern TSS_RESULT Tcsip_DirWriteAuth
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_DIRINDEX          dirIndex,                    // in
+    TPM_DIRVALUE          newContents,                 // in
+    TPM_AUTH*             ownerAuth                    // in, out
+);
+extern TSS_RESULT Tcsip_DirRead
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_DIRINDEX          dirIndex,                    // in
+    TPM_DIRVALUE*         dirValue                     // out
+);
+extern TSS_RESULT Tcsip_Seal
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        keyHandle,                   // in
+    TPM_ENCAUTH           encAuth,                     // in
+    UINT32                pcrInfoSize,                 // in
+    BYTE*                 PcrInfo,                     // in
+    UINT32                inDataSize,                  // in
+    BYTE*                 inData,                      // in
+    TPM_AUTH*             pubAuth,                     // in, out
+    UINT32*               SealedDataSize,              // out
+    BYTE**                SealedData                   // out
+);
+extern TSS_RESULT Tcsip_Unseal
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        keyHandle,                   // in
+    UINT32                SealedDataSize,              // in
+    BYTE*                 SealedData,                  // in
+    TPM_AUTH*             keyAuth,                     // in, out
+    TPM_AUTH*             dataAuth,                    // in, out
+    UINT32*               DataSize,                    // out
+    BYTE**                Data                         // out
+);
+extern TSS_RESULT Tcsip_UnBind
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        keyHandle,                   // in
+    UINT32                inDataSize,                  // in
+    BYTE*                 inData,                      // in
+    TPM_AUTH*             privAuth,                    // in, out
+    UINT32*               outDataSize,                 // out
+    BYTE**                outData                      // out
+);
+extern TSS_RESULT Tcsip_Sealx
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        keyHandle,                   // in
+    TPM_ENCAUTH           encAuth,                     // in
+    UINT32                pcrInfoSize,                 // in
+    BYTE*                 PcrInfo,                     // in
+    UINT32                inDataSize,                  // in
+    BYTE*                 inData,                      // in
+    TPM_AUTH*             pubAuth,                     // in, out
+    UINT32*               SealedDataSize,              // out
+    BYTE**                SealedData                   // out
+);
+extern TSS_RESULT Tcsip_LoadKey2ByBlob
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        hUnwrappingKey,              // in
+    UINT32                cWrappedKeyBlobSize,         // in
+    BYTE*                 rgbWrappedKeyBlob,           // in
+    TPM_AUTH*             pAuth,                       // in, out
+    TCS_KEY_HANDLE*       phKeyTCSI                    // out
+);
+extern TSS_RESULT Tcsip_CreateMigrationBlob
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        parentHandle,                // in
+    TSS_MIGRATE_SCHEME    migrationType,               // in
+    UINT32                MigrationKeyAuthSize,        // in
+    BYTE*                 MigrationKeyAuth,            // in
+    UINT32                encDataSize,                 // in
+    BYTE*                 encData,                     // in
+    TPM_AUTH*             parentAuth,                  // in, out
+    TPM_AUTH*             entityAuth,                  // in, out
+    UINT32*               randomSize,                  // out
+    BYTE**                random,                      // out
+    UINT32*               outDataSize,                 // out
+    BYTE**                outData                      // out
+);
+extern TSS_RESULT Tcsip_ConvertMigrationBlob
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        parentHandle,                // in
+    UINT32                inDataSize,                  // in
+    BYTE*                 inData,                      // in
+    UINT32                randomSize,                  // in
+    BYTE*                 random,                      // in
+    TPM_AUTH*             parentAuth,                  // in, out
+    UINT32*               outDataSize,                 // out
+    BYTE**                outData                      // out
+);
+extern TSS_RESULT Tcsip_AuthorizeMigrationKey
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_MIGRATE_SCHEME    migrateScheme,               // in
+    UINT32                MigrationKeySize,            // in
+    BYTE*                 MigrationKey,                // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    UINT32*               MigrationKeyAuthSize,        // out
+    BYTE**                MigrationKeyAuth             // out
+);
+extern TSS_RESULT Tcsip_CertifyKey
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        certHandle,                  // in
+    TCS_KEY_HANDLE        keyHandle,                   // in
+    TPM_NONCE             antiReplay,                  // in
+    TPM_AUTH*             certAuth,                    // in, out
+    TPM_AUTH*             keyAuth,                     // in, out
+    UINT32*               CertifyInfoSize,             // out
+    BYTE**                CertifyInfo,                 // out
+    UINT32*               outDataSize,                 // out
+    BYTE**                outData                      // out
+);
+extern TSS_RESULT Tcsip_CertifyKey2
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        certHandle,                  // in
+    TCS_KEY_HANDLE        keyHandle,                   // in
+    TPM_DIGEST            MSAdigest,                   // in
+    TPM_NONCE             antiReplay,                  // in
+    TPM_AUTH*             certAuth,                    // in, out
+    TPM_AUTH*             keyAuth,                     // in, out
+    UINT32*               CertifyInfoSize,             // out
+    BYTE**                CertifyInfo,                 // out
+    UINT32*               outDataSize,                 // out
+    BYTE**                outData                      // out
+);
+extern TSS_RESULT Tcsip_Sign
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        keyHandle,                   // in
+    UINT32                areaToSignSize,              // in
+    BYTE*                 areaToSign,                  // in
+    TPM_AUTH*             privAuth,                    // in, out
+    UINT32*               sigSize,                     // out
+    BYTE**                sig                          // out
+);
+extern TSS_RESULT Tcsip_GetRandom
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32*               bytesRequested,              // in, out
+    BYTE**                randomBytes                  // out
+);
+extern TSS_RESULT Tcsip_StirRandom
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32                inDataSize,                  // in
+    BYTE*                 inData                       // in
+);
+extern TSS_RESULT Tcsip_GetCapability
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_CAPABILITY_AREA   capArea,                     // in
+    UINT32                subCapSize,                  // in
+    BYTE*                 subCap,                      // in
+    UINT32*               respSize,                    // out
+    BYTE**                resp                         // out
+);
+extern TSS_RESULT Tcsip_GetCapabilitySigned
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        keyHandle,                   // in
+    TPM_NONCE             antiReplay,                  // in
+    TPM_CAPABILITY_AREA   capArea,                     // in
+    UINT32                subCapSize,                  // in
+    BYTE*                 subCap,                      // in
+    TPM_AUTH*             privAuth,                    // in, out
+    TPM_VERSION*          Version,                     // out
+    UINT32*               respSize,                    // out
+    BYTE**                resp,                        // out
+    UINT32*               sigSize,                     // out
+    BYTE**                sig                          // out
+);
+extern TSS_RESULT Tcsip_GetCapabilityOwner
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_AUTH*             pOwnerAuth,                  // in, out
+    TPM_VERSION*          pVersion,                    // out
+    UINT32*               pNonVolatileFlags,           // out
+    UINT32*               pVolatileFlags               // out
+);
+extern TSS_RESULT Tcsip_CreateEndorsementKeyPair
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_NONCE             antiReplay,                  // in
+    UINT32                endorsementKeyInfoSize,      // in
+    BYTE*                 endorsementKeyInfo,          // in
+    UINT32*               endorsementKeySize,          // out
+    BYTE**                endorsementKey,              // out
+    TPM_DIGEST*           checksum                     // out
+);
+extern TSS_RESULT Tcsip_ReadPubek
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_NONCE             antiReplay,                  // in
+    UINT32*               pubEndorsementKeySize,       // out
+    BYTE**                pubEndorsementKey,           // out
+    TPM_DIGEST*           checksum                     // out
+);
+extern TSS_RESULT Tcsip_DisablePubekRead
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_AUTH*             ownerAuth                    // in, out
+);
+extern TSS_RESULT Tcsip_OwnerReadPubek
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    UINT32*               pubEndorsementKeySize,       // out
+    BYTE**                pubEndorsementKey            // out
+);
+extern TSS_RESULT Tcsip_SelfTestFull
+(
+    TCS_CONTEXT_HANDLE    hContext                     // in
+);
+extern TSS_RESULT Tcsip_CertifySelfTest
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        keyHandle,                   // in
+    TPM_NONCE             antiReplay,                  // in
+    TPM_AUTH*             privAuth,                    // in, out
+    UINT32*               sigSize,                     // out
+    BYTE**                sig                          // out
+);
+extern TSS_RESULT Tcsip_ContinueSelfTest
+(
+    TCS_CONTEXT_HANDLE    hContext                     // in
+);
+extern TSS_RESULT Tcsip_GetTestResult
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32*               outDataSize,                 // out
+    BYTE**                outData                      // out
+);
+extern TSS_RESULT Tcsip_OwnerSetDisable
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_BOOL              disableState,                // in
+    TPM_AUTH*             ownerAuth                    // in, out
+);
+extern TSS_RESULT Tcsip_OwnerClear
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_AUTH*             ownerAuth                    // in, out
+);
+extern TSS_RESULT Tcsip_DisableOwnerClear
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_AUTH*             ownerAuth                    // in, out
+);
+extern TSS_RESULT Tcsip_ForceClear
+(
+    TCS_CONTEXT_HANDLE    hContext                     // in
+);
+extern TSS_RESULT Tcsip_DisableForceClear
+(
+    TCS_CONTEXT_HANDLE    hContext                     // in
+);
+extern TSS_RESULT Tcsip_PhysicalDisable
+(
+    TCS_CONTEXT_HANDLE    hContext                     // in
+);
+extern TSS_RESULT Tcsip_PhysicalEnable
+(
+    TCS_CONTEXT_HANDLE    hContext                     // in
+);
+extern TSS_RESULT Tcsip_PhysicalSetDeactivated
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_BOOL              state                        // in
+);
+extern TSS_RESULT Tcsip_SetTempDeactivated
+(
+    TCS_CONTEXT_HANDLE    hContext                     // in
+);
+extern TSS_RESULT Tcsip_SetTempDeactivated2
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_AUTH*             pOperatorAuth                // in, out
+);
+extern TSS_RESULT Tcsip_OwnerReadInternalPub
+(
+    TCS_CONTEXT_HANDLE   hContext,                     // in
+    TCS_KEY_HANDLE       hKey,                         // in
+    TPM_AUTH*            pOwnerAuth,                   // in, out
+    UINT32*              punPubKeySize,                // out
+    BYTE**               ppbPubKeyData                 // out
+);
+extern TSS_RESULT Tcsip_PhysicalPresence
+(
+    TCS_CONTEXT_HANDLE            hContext,            // in
+    TPM_PHYSICAL_PRESENCE         fPhysicalPresence    // in
+);
+extern TSS_RESULT Tcsip_FieldUpgrade
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32                dataInSize,                  // in
+    BYTE*                 dataIn,                      // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    UINT32*               dataOutSize,                 // out
+    BYTE**                dataOut                      // out
+);
+extern TSS_RESULT Tcsip_ResetLockValue
+(
+    TCS_CONTEXT_HANDLE            hContext,            // in
+    TPM_AUTH*                     ownerAuth            // in, out
+);
+extern TSS_RESULT Tcsip_FlushSpecific
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_HANDLE            hResHandle,                  // in
+    TPM_RESOURCE_TYPE     resourceType                 // in
+);
+extern TSS_RESULT Tcsip_SetRedirection
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        keyHandle,                   // in
+    UINT32                c1,                          // in
+    UINT32                c2,                          // in
+    TPM_AUTH*             privAuth                     // in, out
+);
+extern TSS_RESULT Tcsip_DSAP
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_ENTITY_TYPE       entityType,                  // in
+    TCS_KEY_HANDLE        keyHandle,                   // in
+    TPM_NONCE             nonceOddDSAP,                // in
+    UINT32                entityValueSize,             // in
+    BYTE*                 entityValue,                 // in
+    TCS_AUTHHANDLE*       authHandle,                  // out
+    TPM_NONCE*            nonceEven,                   // out
+    TPM_NONCE*            nonceEvenDSAP                // out
+);
+extern TSS_RESULT Tcsip_Delegate_Manage
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_FAMILY_ID         familyID,                    // in
+    TPM_FAMILY_OPERATION  opFlag,                      // in
+    UINT32                opDataSize,                  // in
+    BYTE*                 opData,                      // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    UINT32*               retDataSize,                 // out
+    BYTE**                retData                      // out
+);
+extern TSS_RESULT Tcsip_Delegate_CreateKeyDelegation
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        hKey,                        // in
+    UINT32                publicInfoSize,              // in
+    BYTE*                 publicInfo,                  // in
+    TPM_ENCAUTH           encDelAuth,                  // in
+    TPM_AUTH*             keyAuth,                     // in, out
+    UINT32*               blobSize,                    // out
+    BYTE**                blob                         // out
+);
+extern TSS_RESULT Tcsip_Delegate_CreateOwnerDelegation
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_BOOL              increment,                   // in
+    UINT32                publicInfoSize,              // in
+    BYTE*                 publicInfo,                  // in
+    TPM_ENCAUTH           encDelAuth,                  // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    UINT32*               blobSize,                    // out
+    BYTE**                blob                         // out
+);
+extern TSS_RESULT Tcsip_Delegate_LoadOwnerDelegation
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_DELEGATE_INDEX    index,                       // in
+    UINT32                blobSize,                    // in
+    BYTE*                 blob,                        // in
+    TPM_AUTH*             ownerAuth                    // in, out
+);
+extern TSS_RESULT Tcsip_Delegate_UpdateVerificationCount
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32                inputSize,                   // in
+    BYTE*                 input,                       // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    UINT32*               outputSize,                  // out
+    BYTE**                output                       // out
+);
+extern TSS_RESULT Tcsip_Delegate_VerifyDelegation
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32                delegateSize,                // in
+    BYTE*                 delegate                     // in
+);
+extern TSS_RESULT Tcsip_Delegate_ReadTable
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32*               pulFamilyTableSize,          // out
+    BYTE**                ppFamilyTable,               // out
+    UINT32*               pulDelegateTableSize,        // out
+    BYTE**                ppDelegateTable              // out
+);
+extern TSS_RESULT Tcsip_NV_DefineOrReleaseSpace
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32                cPubInfoSize,                // in
+    BYTE*                 pPubInfo,                    // in
+    TPM_ENCAUTH           encAuth,                     // in
+    TPM_AUTH*             pAuth                        // in, out
+);
+extern TSS_RESULT Tcsip_NV_WriteValue
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_NV_INDEX          hNVStore,                    // in
+    UINT32                offset,                      // in
+    UINT32                ulDataLength,                // in
+    BYTE*                 rgbDataToWrite,              // in
+    TPM_AUTH*             privAuth                     // in, out
+);
+extern TSS_RESULT Tcsip_NV_WriteValueAuth
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_NV_INDEX          hNVStore,                    // in
+    UINT32                offset,                      // in
+    UINT32                ulDataLength,                // in
+    BYTE*                 rgbDataToWrite,              // in
+    TPM_AUTH*             NVAuth                       // in, out
+);
+extern TSS_RESULT Tcsip_NV_ReadValue
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_NV_INDEX          hNVStore,                    // in
+    UINT32                offset,                      // in
+    UINT32*               pulDataLength,               // in, out
+    TPM_AUTH*             privAuth,                    // in, out
+    BYTE**                rgbDataRead                  // out
+);
+extern TSS_RESULT Tcsip_NV_ReadValueAuth
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_NV_INDEX          hNVStore,                    // in
+    UINT32                offset,                      // in
+    UINT32*               pulDataLength,               // in, out
+    TPM_AUTH*             NVAuth,                      // in, out
+    BYTE**                rgbDataRead                  // out
+);
+extern TSS_RESULT Tcsip_CreateMaintenanceArchive
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_BOOL              generateRandom,              // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    UINT32*               randomSize,                  // out
+    BYTE**                random,                      // out
+    UINT32*               archiveSize,                 // out
+    BYTE**                archive                      // out
+);
+extern TSS_RESULT Tcsip_LoadMaintenanceArchive
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32                dataInSize,                  // in
+    BYTE*                 dataIn,                      // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    UINT32*               dataOutSize,                 // out
+    BYTE**                dataOut                      // out
+);
+extern TSS_RESULT Tcsip_KillMaintenanceFeature
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_AUTH*             ownerAuth                    // in, out
+);
+extern TSS_RESULT Tcsip_LoadManuMaintPub
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_NONCE             antiReplay,                  // in
+    UINT32                PubKeySize,                  // in
+    BYTE*                 PubKey,                      // in
+    TPM_DIGEST*           checksum                     // out
+);
+extern TSS_RESULT Tcsip_ReadManuMaintPub
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_NONCE             antiReplay,                  // in
+    TPM_DIGEST*           checksum                     // out
+);
+extern TSS_RESULT Tcsip_CreateRevocableEndorsementKeyPair
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_NONCE             antiReplay,                  // in
+    UINT32                endorsementKeyInfoSize,      // in
+    BYTE*                 endorsementKeyInfo,          // in
+    TSS_BOOL              GenResetAuth,                // in
+    TPM_DIGEST*           EKResetAuth,                 // in, out
+    UINT32*               endorsementKeySize,          // out
+    BYTE**                endorsementKey,              // out
+    TPM_DIGEST*           checksum                     // out
+);
+extern TSS_RESULT Tcsip_RevokeEndorsementKeyPair
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_DIGEST            EKResetAuth                  // in
+);
+extern TSS_RESULT Tcsip_PcrReset
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32                pcrTargetSize,               // in
+    BYTE*                 pcrTarget                    // in
+);
+extern TSS_RESULT Tcsip_ReadCounter
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_COUNTER_ID        idCounter,                   // in
+    TPM_COUNTER_VALUE*    counterValue                 // out
+);
+extern TSS_RESULT Tcsip_CreateCounter
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32                LabelSize,                   // in (=4)
+    BYTE*                 pLabel,                      // in
+    TPM_ENCAUTH           CounterAuth,                 // in
+    TPM_AUTH*             pOwnerAuth,                  // in, out
+    TSS_COUNTER_ID*       idCounter,                   // out
+    TPM_COUNTER_VALUE*    counterValue                 // out
+);
+extern TSS_RESULT Tcsip_IncrementCounter
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_COUNTER_ID        idCounter,                   // in
+    TPM_AUTH*             pCounterAuth,                // in, out
+    TPM_COUNTER_VALUE*    counterValue                 // out
+);
+extern TSS_RESULT Tcsip_ReleaseCounter
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_COUNTER_ID        idCounter,                   // in
+    TPM_AUTH*             pCounterAuth                 // in, out
+);
+extern TSS_RESULT Tcsip_ReleaseCounterOwner
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_COUNTER_ID        idCounter,                   // in
+    TPM_AUTH*             pOwnerAuth                   // in, out
+);
+extern TSS_RESULT Tcsip_ReadCurrentTicks
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32*               pulCurrentTimeSize,          // out
+    BYTE**                prgbCurrentTime              // out
+);
+extern TSS_RESULT Tcsip_TickStampBlob
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        hKey,                        // in
+    TPM_NONCE             antiReplay,                  // in
+    TPM_DIGEST            digestToStamp,               // in
+    TPM_AUTH*             privAuth,                    // in, out
+    UINT32*               pulSignatureLength,          // out
+    BYTE**                prgbSignature,               // out
+    UINT32*               pulTickCountSize,            // out
+    BYTE**                prgbTickCount                // out
+);
+extern TSS_RESULT Tcsip_TPM_DAA_Join
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_HANDLE            handle,                      // in
+    BYTE                  stage,                       // in
+    UINT32                inputSize0,                  // in
+    BYTE*                 inputData0,                  // in
+    UINT32                inputSize1,                  // in
+    BYTE*                 inputData1,                  // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    UINT32*               outputSize,                  // out
+    BYTE**                outputData                   // out
+);
+extern TSS_RESULT Tcsip_TPM_DAA_Sign
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_HANDLE            handle,                      // in
+    BYTE                  stage,                       // in
+    UINT32                inputSize0,                  // in
+    BYTE*                 inputData0,                  // in
+    UINT32                inputSize1,                  // in
+    BYTE*                 inputData1,                  // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    UINT32*               outputSize,                  // out
+    BYTE**                outputData                   // out
+);
+extern TSS_RESULT Tcsip_MigrateKey
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        hMaKey,                      // in
+    UINT32                PublicKeySize,               // in
+    BYTE*                 PublicKey,                   // in
+    UINT32                inDataSize,                  // in
+    BYTE*                 inData,                      // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    UINT32*               outDataSize,                 // out
+    BYTE**                outData                      // out
+);
+extern TSS_RESULT Tcsip_CMK_SetRestrictions
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TSS_CMK_DELEGATE      Restriction,                 // in
+    TPM_AUTH*             ownerAuth                    // in, out
+);
+extern TSS_RESULT Tcsip_CMK_ApproveMA
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_DIGEST            migAuthorityDigest,          // in
+    TPM_AUTH*             ownerAuth,                   // in, out
+    TPM_HMAC*             HmacMigAuthDigest            // out
+);
+extern TSS_RESULT Tcsip_CMK_CreateKey
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        hWrappingKey,                // in
+    TPM_ENCAUTH           KeyUsageAuth,                // in
+    TPM_HMAC              MigAuthApproval,             // in
+    TPM_DIGEST            MigAuthorityDigest,          // in
+    UINT32*               keyDataSize,                 // in, out
+    BYTE**                prgbKeyData,                 // in, out
+    TPM_AUTH*             pAuth                        // in, out
+);
+extern TSS_RESULT Tcsip_CMK_CreateTicket
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32                PublicVerifyKeySize,         // in
+    BYTE*                 PublicVerifyKey,             // in
+    TPM_DIGEST            SignedData,                  // in
+    UINT32                SigValueSize,                // in
+    BYTE*                 SigValue,                    // in
+    TPM_AUTH*             pOwnerAuth,                  // in, out
+    TPM_HMAC*             SigTicket                    // out
+);
+extern TSS_RESULT Tcsip_CMK_CreateBlob
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        parentHandle,                // in
+    TSS_MIGRATE_SCHEME    migrationType,               // in
+    UINT32                MigrationKeyAuthSize,        // in
+    BYTE*                 MigrationKeyAuth,            // in
+    TPM_DIGEST            PubSourceKeyDigest,          // in
+    UINT32                msaListSize,                 // in
+    BYTE*                 msaList,                     // in
+    UINT32                restrictTicketSize,          // in
+    BYTE*                 restrictTicket,              // in
+    UINT32                sigTicketSize,               // in
+    BYTE*                 sigTicket,                   // in
+    UINT32                encDataSize,                 // in
+    BYTE*                 encData,                     // in
+    TPM_AUTH*             parentAuth,                  // in, out
+    UINT32*               randomSize,                  // out
+    BYTE**                random,                      // out
+    UINT32*               outDataSize,                 // out
+    BYTE**                outData                      // out
+);
+extern TSS_RESULT Tcsip_CMK_ConvertMigration
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        parentHandle,                // in
+    TPM_CMK_AUTH          restrictTicket,              // in
+    TPM_HMAC              sigTicket,                   // in
+    UINT32                keyDataSize,                 // in
+    BYTE*                 prgbKeyData,                 // in
+    UINT32                msaListSize,                 // in
+    BYTE*                 msaList,                     // in
+    UINT32                randomSize,                  // in
+    BYTE*                 random,                      // in
+    TPM_AUTH*             parentAuth,                  // in, out
+    UINT32*               outDataSize,                 // out
+    BYTE**                outData                      // out
+);
+extern TSS_RESULT Tcsip_SetCapability
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TPM_CAPABILITY_AREA   capArea,                     // in
+    UINT32                subCapSize,                  // in
+    BYTE*                 subCap,                      // in
+    UINT32                valueSize,                   // in
+    BYTE*                 value,                       // in
+    TPM_AUTH*             ownerAuth                    // in, out
+);
+extern TSS_RESULT Tcsip_GetAuditDigest
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32                startOrdinal,                // in
+    TPM_DIGEST*           auditDigest,                 // out
+    UINT32*               counterValueSize,            // out
+    BYTE**                counterValue,                // out
+    TSS_BOOL*             more,                        // out
+    UINT32*               ordSize,                     // out
+    UINT32**              ordList                      // out
+);
+extern TSS_RESULT Tcsip_GetAuditDigestSigned
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    TCS_KEY_HANDLE        keyHandle,                   // in
+    TSS_BOOL              closeAudit,                  // in
+    TPM_NONCE             antiReplay,                  // in
+    TPM_AUTH*             privAuth,                    // in, out
+    UINT32*               counterValueSize,            // out
+    BYTE**                counterValue,                // out
+    TPM_DIGEST*           auditDigest,                 // out
+    TPM_DIGEST*           ordinalDigest,               // out
+    UINT32*               sigSize,                     // out
+    BYTE**                sig                          // out
+);
+extern TSS_RESULT Tcsip_SetOrdinalAuditStatus
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32                ordinalToAudit,              // in
+    TSS_BOOL              auditState,                  // in
+    TPM_AUTH*             ownerAuth                    // in, out
+);
+extern TSS_RESULT Tcsi_Admin_TSS_SessionsPerLocality
+(
+    TCS_CONTEXT_HANDLE    hContext,                    // in
+    UINT32                ulLocality,                  // in
+    UINT32                ulSessions,                  // in
+    TPM_AUTH*             pOwnerAuth                   // in, out
+);
+extern TSS_RESULT Tcsi_GetCredential
+(
+    TCS_CONTEXT_HANDLE  hContext,               // in
+    UINT32              ulCredentialType,       // in
+    UINT32              ulCredentialAccessMode, // in
+    UINT32*             pulCredentialSize,      // out
+    BYTE**              prgbCredentialData      // out
+);
+
+#if defined __cplusplus
+} // extern "C"
+#endif
+
+#endif /* TCS_H */
diff --git a/src/include/tss/tcs_defines.h b/src/include/tss/tcs_defines.h
index 5b0d192..b5a1e3d 100644
--- a/src/include/tss/tcs_defines.h
+++ b/src/include/tss/tcs_defines.h
@@ -1,28 +1,28 @@
-/*++
-
-TSS Core Service structures
-
-*/
-
-#ifndef __TCS_DEFINES_H__
-#define __TCS_DEFINES_H__
-
-#define TSS_TCSATTRIB_TRANSPORT_DEFAULT           ((UINT32)(0x00000000))
-#define TSS_TCSATTRIB_TRANSPORT_EXCLUSIVE         ((UINT32)(0x00000001))
-
-
-// Values for the ulCredentialType parameter to Tcsi_GetCredential
-#define TSS_TCS_CREDENTIAL_EKCERT                 ((UINT32)0x00000001)
-#define TSS_TCS_CREDENTIAL_TPM_CC                 ((UINT32)0x00000002)
-#define TSS_TCS_CREDENTIAL_PLATFORMCERT           ((UINT32)0x00000003)
-
-
-// Values for the ulCredentialAccessMode parameter to Tcsi_GetCredential
-//  TSS_TCS_CERT_ACCESS_AUTO triggers the default behavior.
-//  Values with TSS_TCS_CERT_VENDOR_SPECIFIC_BIT set trigger
-//    vendor specific behavior.
-#define TSS_TCS_CERT_ACCESS_AUTO                  ((UINT32)0x00000001)
-
-#define TSS_TCS_CERT_VENDOR_SPECIFIC_BIT          ((UINT32)0x80000000)
-
-#endif // __TCS_DEFINES_H__
+/*++
+
+TSS Core Service structures
+
+*/
+
+#ifndef __TCS_DEFINES_H__
+#define __TCS_DEFINES_H__
+
+#define TSS_TCSATTRIB_TRANSPORT_DEFAULT           ((UINT32)(0x00000000))
+#define TSS_TCSATTRIB_TRANSPORT_EXCLUSIVE         ((UINT32)(0x00000001))
+
+
+// Values for the ulCredentialType parameter to Tcsi_GetCredential
+#define TSS_TCS_CREDENTIAL_EKCERT                 ((UINT32)0x00000001)
+#define TSS_TCS_CREDENTIAL_TPM_CC                 ((UINT32)0x00000002)
+#define TSS_TCS_CREDENTIAL_PLATFORMCERT           ((UINT32)0x00000003)
+
+
+// Values for the ulCredentialAccessMode parameter to Tcsi_GetCredential
+//  TSS_TCS_CERT_ACCESS_AUTO triggers the default behavior.
+//  Values with TSS_TCS_CERT_VENDOR_SPECIFIC_BIT set trigger
+//    vendor specific behavior.
+#define TSS_TCS_CERT_ACCESS_AUTO                  ((UINT32)0x00000001)
+
+#define TSS_TCS_CERT_VENDOR_SPECIFIC_BIT          ((UINT32)0x80000000)
+
+#endif // __TCS_DEFINES_H__
diff --git a/src/include/tss/tcs_error.h b/src/include/tss/tcs_error.h
index 2a64c34..7ce7ef9 100644
--- a/src/include/tss/tcs_error.h
+++ b/src/include/tss/tcs_error.h
@@ -1,56 +1,56 @@
-/*++
- 
-TSS Core Service error return codes 
- 
---*/
-
-#ifndef __TCS_ERROR_H__
-#define __TCS_ERROR_H__
-
-
-#ifndef TSS_E_BASE
-#define TSS_E_BASE      0x00000000L
-#endif // TSS_E_BASE
-
-// The context handle supplied is invalid.
-#define TCS_E_INVALID_CONTEXTHANDLE  (UINT32)(TSS_E_BASE + 0x0C1L) 
-
-// The key handle supplied is invalid.
-#define TCS_E_INVALID_KEYHANDLE  (UINT32)(TSS_E_BASE + 0x0C2L) 
-
-// The authorization session handle supplied is invalid.
-#define TCS_E_INVALID_AUTHHANDLE  (UINT32)(TSS_E_BASE + 0x0C3L)
-
-// the auth session has been closed by the TPM
-#define TCS_E_INVALID_AUTHSESSION  (UINT32)(TSS_E_BASE + 0x0C4L) 
-
-// the key has been unloaded 
-#define TCS_E_INVALID_KEY   (UINT32)(TSS_E_BASE + 0x0C5L) 
-
-// Key addressed by the application key handle does not match the key addressed
-// by the given UUID.
-#define TCS_E_KEY_MISMATCH   (UINT32)(TSS_E_BASE + 0x0C8L)
-
-// Key adressed by Key's UUID cannot be loaded because one of the required
-// parent keys needs authorization.
-#define TCS_E_KM_LOADFAILED   (UINT32)(TSS_E_BASE + 0x0CAL)
-
-// The Key Cache Manager could not reload the key into the TPM.
-#define TCS_E_KEY_CONTEXT_RELOAD  (UINT32)(TSS_E_BASE + 0x0CCL)
-
-// Bad memory index
-#define TCS_E_BAD_INDEX                           (UINT32)(TSS_E_BASE + 0x0CDL)
-
-
-// These TCS_E_ macros are defined by name in the TSS spec, however
-// they are defined to have the same values as the TSS_E_ equivalents.
-#define TCS_SUCCESS                        TSS_SUCCESS
-#define TCS_E_KEY_ALREADY_REGISTERED       TSS_E_KEY_ALREADY_REGISTERED
-#define TCS_E_KEY_NOT_REGISTERED           TSS_E_KEY_NOT_REGISTERED
-#define TCS_E_BAD_PARAMETER                TSS_E_BAD_PARAMETER
-#define TCS_E_OUTOFMEMORY                  TSS_E_OUTOFMEMORY
-#define TCS_E_SIZE                         TSS_E_SIZE
-#define TCS_E_NOTIMPL                      TSS_E_NOTIMPL
-#define TCS_E_INTERNAL_ERROR               TSS_E_INTERNAL_ERROR
-
-#endif // __TCS_ERROR_H__
+/*++
+ 
+TSS Core Service error return codes 
+ 
+--*/
+
+#ifndef __TCS_ERROR_H__
+#define __TCS_ERROR_H__
+
+
+#ifndef TSS_E_BASE
+#define TSS_E_BASE      0x00000000L
+#endif // TSS_E_BASE
+
+// The context handle supplied is invalid.
+#define TCS_E_INVALID_CONTEXTHANDLE  (UINT32)(TSS_E_BASE + 0x0C1L) 
+
+// The key handle supplied is invalid.
+#define TCS_E_INVALID_KEYHANDLE  (UINT32)(TSS_E_BASE + 0x0C2L) 
+
+// The authorization session handle supplied is invalid.
+#define TCS_E_INVALID_AUTHHANDLE  (UINT32)(TSS_E_BASE + 0x0C3L)
+
+// the auth session has been closed by the TPM
+#define TCS_E_INVALID_AUTHSESSION  (UINT32)(TSS_E_BASE + 0x0C4L) 
+
+// the key has been unloaded 
+#define TCS_E_INVALID_KEY   (UINT32)(TSS_E_BASE + 0x0C5L) 
+
+// Key addressed by the application key handle does not match the key addressed
+// by the given UUID.
+#define TCS_E_KEY_MISMATCH   (UINT32)(TSS_E_BASE + 0x0C8L)
+
+// Key adressed by Key's UUID cannot be loaded because one of the required
+// parent keys needs authorization.
+#define TCS_E_KM_LOADFAILED   (UINT32)(TSS_E_BASE + 0x0CAL)
+
+// The Key Cache Manager could not reload the key into the TPM.
+#define TCS_E_KEY_CONTEXT_RELOAD  (UINT32)(TSS_E_BASE + 0x0CCL)
+
+// Bad memory index
+#define TCS_E_BAD_INDEX                           (UINT32)(TSS_E_BASE + 0x0CDL)
+
+
+// These TCS_E_ macros are defined by name in the TSS spec, however
+// they are defined to have the same values as the TSS_E_ equivalents.
+#define TCS_SUCCESS                        TSS_SUCCESS
+#define TCS_E_KEY_ALREADY_REGISTERED       TSS_E_KEY_ALREADY_REGISTERED
+#define TCS_E_KEY_NOT_REGISTERED           TSS_E_KEY_NOT_REGISTERED
+#define TCS_E_BAD_PARAMETER                TSS_E_BAD_PARAMETER
+#define TCS_E_OUTOFMEMORY                  TSS_E_OUTOFMEMORY
+#define TCS_E_SIZE                         TSS_E_SIZE
+#define TCS_E_NOTIMPL                      TSS_E_NOTIMPL
+#define TCS_E_INTERNAL_ERROR               TSS_E_INTERNAL_ERROR
+
+#endif // __TCS_ERROR_H__
diff --git a/src/include/tss/tcs_structs.h b/src/include/tss/tcs_structs.h
index 30b3fb9..0255466 100644
--- a/src/include/tss/tcs_structs.h
+++ b/src/include/tss/tcs_structs.h
@@ -1,40 +1,40 @@
-/*++
-
-TSS Core Service structures
-
-*/
-
-#ifndef __TCS_STRUCT_H__
-#define __TCS_STRUCT_H__
-
-#include <tss/tpm.h>
-#include <tss/tss_structs.h>
-#include <tss/tcs_typedef.h>
-
-typedef struct tdTCS_AUTH
-{
-    TCS_AUTHHANDLE  AuthHandle;
-    TPM_NONCE       NonceOdd;   // system  
-    TPM_NONCE       NonceEven;   // TPM   
-    TSS_BOOL        fContinueAuthSession;
-    TPM_AUTHDATA    HMAC;
-} TCS_AUTH;
-
-// This is kept for legacy compatibility
-typedef TCS_AUTH    TPM_AUTH;
-
-
-typedef struct tdTCS_LOADKEY_INFO
-{
-    TSS_UUID   keyUUID;
-    TSS_UUID   parentKeyUUID;
-    TPM_DIGEST  paramDigest; // SHA1 digest of the TPM_LoadKey
-                             // Command input parameters
-                             // As defined in TPM Main Specification
-    TPM_AUTH   authData;     // Data regarding a valid auth
-                             // Session including the
-                             // HMAC digest
-} TCS_LOADKEY_INFO;
-
-#endif // __TCS_STRUCT_H__
-
+/*++
+
+TSS Core Service structures
+
+*/
+
+#ifndef __TCS_STRUCT_H__
+#define __TCS_STRUCT_H__
+
+#include <tss/tpm.h>
+#include <tss/tss_structs.h>
+#include <tss/tcs_typedef.h>
+
+typedef struct tdTCS_AUTH
+{
+    TCS_AUTHHANDLE  AuthHandle;
+    TPM_NONCE       NonceOdd;   // system  
+    TPM_NONCE       NonceEven;   // TPM   
+    TSS_BOOL        fContinueAuthSession;
+    TPM_AUTHDATA    HMAC;
+} TCS_AUTH;
+
+// This is kept for legacy compatibility
+typedef TCS_AUTH    TPM_AUTH;
+
+
+typedef struct tdTCS_LOADKEY_INFO
+{
+    TSS_UUID   keyUUID;
+    TSS_UUID   parentKeyUUID;
+    TPM_DIGEST  paramDigest; // SHA1 digest of the TPM_LoadKey
+                             // Command input parameters
+                             // As defined in TPM Main Specification
+    TPM_AUTH   authData;     // Data regarding a valid auth
+                             // Session including the
+                             // HMAC digest
+} TCS_LOADKEY_INFO;
+
+#endif // __TCS_STRUCT_H__
+
diff --git a/src/include/tss/tcs_typedef.h b/src/include/tss/tcs_typedef.h
index 0c89839..7ef48af 100644
--- a/src/include/tss/tcs_typedef.h
+++ b/src/include/tss/tcs_typedef.h
@@ -1,32 +1,32 @@
-/*++
-
-Global typedefs for TSS Core Service
- 
-*/
-
-#ifndef __TCS_TYPEDEF_H__
-#define __TCS_TYPEDEF_H__
-
-#include <tss/tss_structs.h>
-#include <tss/tpm.h>
-
-typedef UINT32  TCS_AUTHHANDLE;
-typedef UINT32  TCS_CONTEXT_HANDLE;
-typedef UINT32  TCS_KEY_HANDLE;
-typedef UINT32  TCS_HANDLE;
-
-
-// Substitution definitions for TCS-IDL
-typedef TPM_ENCAUTH                TCG_ENCAUTH;
-typedef TPM_NONCE                  TCG_NONCE;
-typedef TPM_ENTITY_TYPE            TCG_ENTITY_TYPE;
-typedef TPM_PCRINDEX               TCG_PCRINDEX;
-typedef TPM_DIGEST                 TCG_DIGEST;
-typedef TPM_PCRVALUE               TCG_PCRVALUE;
-typedef TPM_DIRVALUE               TCG_DIRVALUE;
-typedef TPM_DIRINDEX               TCG_DIRINDEX;
-
-
-
-#endif // __TCS_TYPEDEF_H__
-
+/*++
+
+Global typedefs for TSS Core Service
+ 
+*/
+
+#ifndef __TCS_TYPEDEF_H__
+#define __TCS_TYPEDEF_H__
+
+#include <tss/tss_structs.h>
+#include <tss/tpm.h>
+
+typedef UINT32  TCS_AUTHHANDLE;
+typedef UINT32  TCS_CONTEXT_HANDLE;
+typedef UINT32  TCS_KEY_HANDLE;
+typedef UINT32  TCS_HANDLE;
+
+
+// Substitution definitions for TCS-IDL
+typedef TPM_ENCAUTH                TCG_ENCAUTH;
+typedef TPM_NONCE                  TCG_NONCE;
+typedef TPM_ENTITY_TYPE            TCG_ENTITY_TYPE;
+typedef TPM_PCRINDEX               TCG_PCRINDEX;
+typedef TPM_DIGEST                 TCG_DIGEST;
+typedef TPM_PCRVALUE               TCG_PCRVALUE;
+typedef TPM_DIRVALUE               TCG_DIRVALUE;
+typedef TPM_DIRINDEX               TCG_DIRINDEX;
+
+
+
+#endif // __TCS_TYPEDEF_H__
+
diff --git a/src/include/tss/tddl_error.h b/src/include/tss/tddl_error.h
index b63ca11..0b4b2a4 100644
--- a/src/include/tss/tddl_error.h
+++ b/src/include/tss/tddl_error.h
@@ -1,51 +1,51 @@
-/*++
-
-TPM Device Driver Library error return codes 
- 
---*/
-
-#ifndef __TDDL_ERROR_H__
-#define __TDDL_ERROR_H__
-
-#include <tss/tss_error_basics.h>
-#include <tss/tss_error.h>
-
-
-#ifndef TSS_E_BASE
-#define TSS_E_BASE      0x00000000L
-#endif // TSS_E_BASE
-
-
-//
-// specific error codes returned by the TPM device driver library
-// offset TSS_TDDL_OFFSET
-//
-#define TDDL_E_FAIL 		TSS_E_FAIL
-#define TDDL_E_TIMEOUT 		TSS_E_TIMEOUT
-
-// The connection was already established.
-#define TDDL_E_ALREADY_OPENED   (UINT32)(TSS_E_BASE + 0x081L)
-
-// The device was not connected.
-#define TDDL_E_ALREADY_CLOSED   (UINT32)(TSS_E_BASE + 0x082L)
-
-// The receive buffer is too small.
-#define TDDL_E_INSUFFICIENT_BUFFER  (UINT32)(TSS_E_BASE + 0x083L)
-
-// The command has already completed.
-#define TDDL_E_COMMAND_COMPLETED  (UINT32)(TSS_E_BASE + 0x084L)
-
-// TPM aborted processing of command.
-#define TDDL_E_COMMAND_ABORTED  (UINT32)(TSS_E_BASE + 0x085L)
-
-//  The request could not be performed because of an I/O device error.
-#define TDDL_E_IOERROR    (UINT32)(TSS_E_BASE + 0x087L)
-
-// Unsupported TAG is requested
-#define TDDL_E_BADTAG    (UINT32)(TSS_E_BASE + 0x088L)
-
-// the requested TPM component was not found
-#define TDDL_E_COMPONENT_NOT_FOUND  (UINT32)(TSS_E_BASE + 0x089L)
-
-#endif // __TDDL_ERROR_H__
-
+/*++
+
+TPM Device Driver Library error return codes 
+ 
+--*/
+
+#ifndef __TDDL_ERROR_H__
+#define __TDDL_ERROR_H__
+
+#include <tss/tss_error_basics.h>
+#include <tss/tss_error.h>
+
+
+#ifndef TSS_E_BASE
+#define TSS_E_BASE      0x00000000L
+#endif // TSS_E_BASE
+
+
+//
+// specific error codes returned by the TPM device driver library
+// offset TSS_TDDL_OFFSET
+//
+#define TDDL_E_FAIL 		TSS_E_FAIL
+#define TDDL_E_TIMEOUT 		TSS_E_TIMEOUT
+
+// The connection was already established.
+#define TDDL_E_ALREADY_OPENED   (UINT32)(TSS_E_BASE + 0x081L)
+
+// The device was not connected.
+#define TDDL_E_ALREADY_CLOSED   (UINT32)(TSS_E_BASE + 0x082L)
+
+// The receive buffer is too small.
+#define TDDL_E_INSUFFICIENT_BUFFER  (UINT32)(TSS_E_BASE + 0x083L)
+
+// The command has already completed.
+#define TDDL_E_COMMAND_COMPLETED  (UINT32)(TSS_E_BASE + 0x084L)
+
+// TPM aborted processing of command.
+#define TDDL_E_COMMAND_ABORTED  (UINT32)(TSS_E_BASE + 0x085L)
+
+//  The request could not be performed because of an I/O device error.
+#define TDDL_E_IOERROR    (UINT32)(TSS_E_BASE + 0x087L)
+
+// Unsupported TAG is requested
+#define TDDL_E_BADTAG    (UINT32)(TSS_E_BASE + 0x088L)
+
+// the requested TPM component was not found
+#define TDDL_E_COMPONENT_NOT_FOUND  (UINT32)(TSS_E_BASE + 0x089L)
+
+#endif // __TDDL_ERROR_H__
+
diff --git a/src/include/tss/tddlapi_error.h b/src/include/tss/tddlapi_error.h
index f021150..449779b 100644
--- a/src/include/tss/tddlapi_error.h
+++ b/src/include/tss/tddlapi_error.h
@@ -1,54 +1,54 @@
-/*++
-
-TDDL error return codes for the TPM Device Driver Library Interface (TDDLI)
- 
---*/
-
-#ifndef __TDDLAPI_ERROR_H__
-#define __TDDLAPI_ERROR_H__
-
-
-//
-// error coding scheme for a Microsoft Windows platform -
-// refer to the TSS Specification Parts
-//
-//  Values are 32 bit values layed out as follows:
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//  +---+-+-+-----------------------+-------+-----------------------+
-//  |Lev|C|R|     Facility          | Layer |         Code          |
-//  +---+-+-+-----------------------+-------+-----------------------+
-//  | Platform specific coding      | TSS error coding system       |
-//  +---+-+-+-----------------------+-------+-----------------------+
-//
-//      Lev - is the Level code
-//
-//          00 - Success
-//          01 - Informational
-//          10 - Warning
-//          11 - Error
-//
-//      C - is the Customer code flag  (must actually be set)
-//
-//      R - is a reserved bit    (unused)
-//
-//      Facility - is the facility code: TCPA: proposal 0x028
-//
-//      Code - is the facility's status code
-//
-
-
-// no macros are used below intentionally 
-// for a better error code recognition by the reader
-
-// note that the values of TPM_E_BASE and TSS_E_BASE, TSS_W_BASE and TSS_I_BASE
-// have to be adjusted for a platform other than Windows
-
-//
-// TPM specific error codes (layer nibble set to TPM layer TSS_LAYER_TPM)
-//
-
-
-#endif // __TDDLAPI_ERROR_H__
-
+/*++
+
+TDDL error return codes for the TPM Device Driver Library Interface (TDDLI)
+ 
+--*/
+
+#ifndef __TDDLAPI_ERROR_H__
+#define __TDDLAPI_ERROR_H__
+
+
+//
+// error coding scheme for a Microsoft Windows platform -
+// refer to the TSS Specification Parts
+//
+//  Values are 32 bit values layed out as follows:
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//  +---+-+-+-----------------------+-------+-----------------------+
+//  |Lev|C|R|     Facility          | Layer |         Code          |
+//  +---+-+-+-----------------------+-------+-----------------------+
+//  | Platform specific coding      | TSS error coding system       |
+//  +---+-+-+-----------------------+-------+-----------------------+
+//
+//      Lev - is the Level code
+//
+//          00 - Success
+//          01 - Informational
+//          10 - Warning
+//          11 - Error
+//
+//      C - is the Customer code flag  (must actually be set)
+//
+//      R - is a reserved bit    (unused)
+//
+//      Facility - is the facility code: TCPA: proposal 0x028
+//
+//      Code - is the facility's status code
+//
+
+
+// no macros are used below intentionally 
+// for a better error code recognition by the reader
+
+// note that the values of TPM_E_BASE and TSS_E_BASE, TSS_W_BASE and TSS_I_BASE
+// have to be adjusted for a platform other than Windows
+
+//
+// TPM specific error codes (layer nibble set to TPM layer TSS_LAYER_TPM)
+//
+
+
+#endif // __TDDLAPI_ERROR_H__
+
diff --git a/src/include/tss/tddli.h b/src/include/tss/tddli.h
index bfd6045..12ed329 100644
--- a/src/include/tss/tddli.h
+++ b/src/include/tss/tddli.h
@@ -1,94 +1,99 @@
-/*++
-
-TPM Device Driver Library interface
- 
---*/
-
-#ifndef __TDDLI_H__
-#define __TDDLI_H__
-
-#include <tss/tss_typedef.h>
-#include <tss/tddl_error.h>
-
-#if !defined(TDDLI)
-#ifdef WIN32
-// --- This should be used on Windows platforms
-#ifdef TDDLI_EXPORTS
-#define TDDLI __declspec(dllexport)
-#else
-#define TDDLI __declspec(dllimport)
-#endif
-#else
-#define TDDLI 
-#endif
-#endif /* !defined(TDDLI) */
-
-
-#define TDDL_CAP_VERSION   0x0100
-#define TDDL_CAP_VER_DRV   0x0101
-#define TDDL_CAP_VER_FW    0x0102
-#define TDDL_CAP_VER_FW_DATE   0x0103
-
-#define TDDL_CAP_PROPERTY   0x0200
-#define TDDL_CAP_PROP_MANUFACTURER  0x0201
-#define TDDL_CAP_PROP_MODULE_TYPE  0x0202
-#define TDDL_CAP_PROP_GLOBAL_STATE  0x0203
-
-
-//--------------------------------------------------------------------
-// TDDL specific helper redefinitions
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-    //establish a connection to the TPM device driver
-    TDDLI TSS_RESULT Tddli_Open(void);
- 
-    //close a open connection to the TPM device driver
-    TDDLI TSS_RESULT Tddli_Close(void);
-
-    //cancels the last outstanding TPM command
-    TDDLI TSS_RESULT Tddli_Cancel(void);
-
-    // read the attributes returned by the TPM HW/FW
-    TDDLI TSS_RESULT Tddli_GetCapability(
-        UINT32        CapArea,
-        UINT32        SubCap,
-        BYTE         *pCapBuf,
-        UINT32       *puntCapBufLen);
-
-    // set parameters to the TPM HW/FW
-    TDDLI TSS_RESULT Tddli_SetCapability(
-        UINT32        CapArea,
-        UINT32        SubCap,
-        BYTE         *pCapBuf,
-        UINT32        puntCapBufLen);
-
-    // get status of the TPM driver and device
-    TDDLI TSS_RESULT Tddli_GetStatus(
-        UINT32        ReqStatusType,
-        UINT32       *puntStatus);
-
-    // send any data to the TPM module
-    TDDLI TSS_RESULT Tddli_TransmitData(
-        BYTE         *pTransmitBuf,
-        UINT32        TransmitBufLen,
-        BYTE         *pReceiveBuf,
-        UINT32       *puntReceiveBufLen);
-
-    TDDLI TSS_RESULT Tddli_SetPowerManagement(
-        TSS_BOOL      SendSaveStateCommand,       // in
-        UINT32       *QuerySetNewTPMPowerState);  // in, out
-
-    TDDLI TSS_RESULT Tddli_PowerManagementControl(
-        TSS_BOOL      SendPowerManager,           // in
-        UINT32       *DriverManagesPowerStates);  // out
-
-    
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __TDDLI_H__
-
+/*++
+
+TPM Device Driver Library interface
+ 
+--*/
+
+#ifndef __TDDLI_H__
+#define __TDDLI_H__
+
+#include <tss/tss_typedef.h>
+#include <tss/tddl_error.h>
+
+#if !defined(TDDLI)
+#ifdef WIN32
+// --- This should be used on Windows platforms
+#ifdef TDDLI_EXPORTS
+#define TDDLI __declspec(dllexport)
+#else
+#ifdef FIXME
+/* Tddl is still a static library not a DLL */
+#define TDDLI __declspec(dllimport)
+#else
+#define TDDLI
+#endif
+#endif
+#else
+#define TDDLI 
+#endif
+#endif /* !defined(TDDLI) */
+
+
+#define TDDL_CAP_VERSION   0x0100
+#define TDDL_CAP_VER_DRV   0x0101
+#define TDDL_CAP_VER_FW    0x0102
+#define TDDL_CAP_VER_FW_DATE   0x0103
+
+#define TDDL_CAP_PROPERTY   0x0200
+#define TDDL_CAP_PROP_MANUFACTURER  0x0201
+#define TDDL_CAP_PROP_MODULE_TYPE  0x0202
+#define TDDL_CAP_PROP_GLOBAL_STATE  0x0203
+
+
+//--------------------------------------------------------------------
+// TDDL specific helper redefinitions
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    //establish a connection to the TPM device driver
+    TDDLI TSS_RESULT Tddli_Open(void);
+ 
+    //close a open connection to the TPM device driver
+    TDDLI TSS_RESULT Tddli_Close(void);
+
+    //cancels the last outstanding TPM command
+    TDDLI TSS_RESULT Tddli_Cancel(void);
+
+    // read the attributes returned by the TPM HW/FW
+    TDDLI TSS_RESULT Tddli_GetCapability(
+        UINT32        CapArea,
+        UINT32        SubCap,
+        BYTE         *pCapBuf,
+        UINT32       *puntCapBufLen);
+
+    // set parameters to the TPM HW/FW
+    TDDLI TSS_RESULT Tddli_SetCapability(
+        UINT32        CapArea,
+        UINT32        SubCap,
+        BYTE         *pCapBuf,
+        UINT32        puntCapBufLen);
+
+    // get status of the TPM driver and device
+    TDDLI TSS_RESULT Tddli_GetStatus(
+        UINT32        ReqStatusType,
+        UINT32       *puntStatus);
+
+    // send any data to the TPM module
+    TDDLI TSS_RESULT Tddli_TransmitData(
+        BYTE         *pTransmitBuf,
+        UINT32        TransmitBufLen,
+        BYTE         *pReceiveBuf,
+        UINT32       *puntReceiveBufLen);
+
+    TDDLI TSS_RESULT Tddli_SetPowerManagement(
+        TSS_BOOL      SendSaveStateCommand,       // in
+        UINT32       *QuerySetNewTPMPowerState);  // in, out
+
+    TDDLI TSS_RESULT Tddli_PowerManagementControl(
+        TSS_BOOL      SendPowerManager,           // in
+        UINT32       *DriverManagesPowerStates);  // out
+
+    
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __TDDLI_H__
+
diff --git a/src/include/tss/tpm.h b/src/include/tss/tpm.h
index a9057f3..b6ae198 100644
--- a/src/include/tss/tpm.h
+++ b/src/include/tss/tpm.h
@@ -1,1663 +1,1663 @@
-/*++
- * 
- * TPM structures extracted from the TPM specification 1.2, 
- * Part 2 (Structures), rev 85.
- *
- * Errata:
- *
- * *) The individual bits of TPM_STARTUP_EFFECTS were not given names in
- * the TPM spec so they are not defined in tpm.h.
- * 
- * *) A few typedefs not present in the TPM 1.2 specification have been
- * added. This was generally done when the TPM 1.2 spec defined a set of
- * related values (either bitmasks or enumeration values) but did not
- * define an associated type to hold these values. The typedefs have been
- * added and structure fields that were to hold those values have been
- * switched from generic UINT* types to the more specific types. This was
- * done to highlight exactly where those #defined values were to be used.
- * The types that have been added are:
- *   TPM_NV_PER_ATTRIBUTES
- *   TPM_DELEGATE_TYPE
- *
- * *) The layout of bitfields within a structure are compiler-dependent
- * and the use of structure bitfields has been avoided where possible. In
- * cases where a value is a collection of independent bits the type is
- * given a name (typedeffed to UINT16 or UINT32 as appropriate) and masks
- * are #defined to access the individual bits. This is not possible for
- * TPM_VERSION_BYTE because the fields are 4-bit values. A best attempt
- * has been made to make this compiler independent but it has only been
- * checked on GCC and Visual C++ on little-endian machines.
- * 
- * *) The TPM_DELEGATIONS per1 and per2 fields field are a bitmask but
- * are defined as a UINT32 because the bitfields have different meaning
- * based on the type of delegation blob.
- * 
- * *) The definitions of TPM_PERMANENT_DATA, TPM_STCLEAR_DATA,
- * TPM_STANY_DATA, and TPM_DELEGATE_TABLE_ROW are commented out. These
- * structures are internal to the TPM and are not directly accessible by
- * external software so this should not be a problem.
- * 
- * *) The definitions of TPM_FAMILY_TABLE and TPM_DELEGATE_TABLE are
- * commented out because they are variable length arrays internal to the
- * TPM. As above they are not directly accessible by external software
- * so this should not be a problem.
- */
-
-#ifndef __TPM_H__
-#define __TPM_H__
-
-#ifdef __midl
-#define SIZEIS(x)  [size_is(x)]
-#else
-#define SIZEIS(x)
-#endif
-
-#include <tss/platform.h>
-
-//-------------------------------------------------------------------
-// Part 2, section 2.1: Basic data types
-typedef BYTE   TPM_BOOL;
-#ifndef FALSE
-#define FALSE  0x00
-#define TRUE   0x01
-#endif /* ifndef FALSE */
-
-//-------------------------------------------------------------------
-// Part 2, section 2.3: Helper Redefinitions
-//   Many of the helper redefinitions appear later in this file
-//   so that they are declared next to the list of valid values
-//   they may hold.
-typedef BYTE TPM_LOCALITY_MODIFIER;
-typedef UINT32 TPM_COMMAND_CODE;                            /* 1.1b */
-typedef UINT32 TPM_COUNT_ID;
-typedef UINT32 TPM_REDIT_COMMAND;
-typedef UINT32 TPM_HANDLE;
-typedef UINT32 TPM_AUTHHANDLE;
-typedef UINT32 TPM_TRANSHANDLE;
-typedef UINT32 TPM_KEYHANDLE;
-typedef UINT32 TPM_DIRINDEX;
-typedef UINT32 TPM_PCRINDEX;
-typedef UINT32 TPM_RESULT;
-typedef UINT32 TPM_MODIFIER_INDICATOR;
-
-
-
-//-------------------------------------------------------------------
-// Part 2, section 2.2.4: Vendor Specific
-#define TPM_Vendor_Specific32  0x00000400
-#define TPM_Vendor_Specific8   0x80
-
-
-//-------------------------------------------------------------------
-// Part 2, section 3: Structure Tags
-typedef UINT16  TPM_STRUCTURE_TAG;
-#define TPM_TAG_CONTEXTBLOB            ((UINT16)0x0001)
-#define TPM_TAG_CONTEXT_SENSITIVE      ((UINT16)0x0002)
-#define TPM_TAG_CONTEXTPOINTER         ((UINT16)0x0003)
-#define TPM_TAG_CONTEXTLIST            ((UINT16)0x0004)
-#define TPM_TAG_SIGNINFO               ((UINT16)0x0005)
-#define TPM_TAG_PCR_INFO_LONG          ((UINT16)0x0006)
-#define TPM_TAG_PERSISTENT_FLAGS       ((UINT16)0x0007)
-#define TPM_TAG_VOLATILE_FLAGS         ((UINT16)0x0008)
-#define TPM_TAG_PERSISTENT_DATA        ((UINT16)0x0009)
-#define TPM_TAG_VOLATILE_DATA          ((UINT16)0x000a)
-#define TPM_TAG_SV_DATA                ((UINT16)0x000b)
-#define TPM_TAG_EK_BLOB                ((UINT16)0x000c)
-#define TPM_TAG_EK_BLOB_AUTH           ((UINT16)0x000d)
-#define TPM_TAG_COUNTER_VALUE          ((UINT16)0x000e)
-#define TPM_TAG_TRANSPORT_INTERNAL     ((UINT16)0x000f)
-#define TPM_TAG_TRANSPORT_LOG_IN       ((UINT16)0x0010)
-#define TPM_TAG_TRANSPORT_LOG_OUT      ((UINT16)0x0011)
-#define TPM_TAG_AUDIT_EVENT_IN         ((UINT16)0x0012)
-#define TPM_TAG_AUDIT_EVENT_OUT        ((UINT16)0x0013)
-#define TPM_TAG_CURRENT_TICKS          ((UINT16)0x0014)
-#define TPM_TAG_KEY                    ((UINT16)0x0015)
-#define TPM_TAG_STORED_DATA12          ((UINT16)0x0016)
-#define TPM_TAG_NV_ATTRIBUTES          ((UINT16)0x0017)
-#define TPM_TAG_NV_DATA_PUBLIC         ((UINT16)0x0018)
-#define TPM_TAG_NV_DATA_SENSITIVE      ((UINT16)0x0019)
-#define TPM_TAG_DELEGATIONS            ((UINT16)0x001a)
-#define TPM_TAG_DELEGATE_PUBLIC        ((UINT16)0x001b)
-#define TPM_TAG_DELEGATE_TABLE_ROW     ((UINT16)0x001c)
-#define TPM_TAG_TRANSPORT_AUTH         ((UINT16)0x001d)
-#define TPM_TAG_TRANSPORT_PUBLIC       ((UINT16)0x001e)
-#define TPM_TAG_PERMANENT_FLAGS        ((UINT16)0x001f)
-#define TPM_TAG_STCLEAR_FLAGS          ((UINT16)0x0020)
-#define TPM_TAG_STANY_FLAGS            ((UINT16)0x0021)
-#define TPM_TAG_PERMANENT_DATA         ((UINT16)0x0022)
-#define TPM_TAG_STCLEAR_DATA           ((UINT16)0x0023)
-#define TPM_TAG_STANY_DATA             ((UINT16)0x0024)
-#define TPM_TAG_FAMILY_TABLE_ENTRY     ((UINT16)0x0025)
-#define TPM_TAG_DELEGATE_SENSITIVE     ((UINT16)0x0026)
-#define TPM_TAG_DELG_KEY_BLOB          ((UINT16)0x0027)
-#define TPM_TAG_KEY12                  ((UINT16)0x0028)
-#define TPM_TAG_CERTIFY_INFO2          ((UINT16)0x0029)
-#define TPM_TAG_DELEGATE_OWNER_BLOB    ((UINT16)0x002a)
-#define TPM_TAG_EK_BLOB_ACTIVATE       ((UINT16)0x002b)
-#define TPM_TAG_DAA_BLOB               ((UINT16)0x002c)
-#define TPM_TAG_DAA_CONTEXT            ((UINT16)0x002d)
-#define TPM_TAG_DAA_ENFORCE            ((UINT16)0x002e)
-#define TPM_TAG_DAA_ISSUER             ((UINT16)0x002f)
-#define TPM_TAG_CAP_VERSION_INFO       ((UINT16)0x0030)
-#define TPM_TAG_DAA_SENSITIVE          ((UINT16)0x0031)
-#define TPM_TAG_DAA_TPM                ((UINT16)0x0032)
-#define TPM_TAG_CMK_MIGAUTH            ((UINT16)0x0033)
-#define TPM_TAG_CMK_SIGTICKET          ((UINT16)0x0034)
-#define TPM_TAG_CMK_MA_APPROVAL        ((UINT16)0x0035)
-#define TPM_TAG_QUOTE_INFO2            ((UINT16)0x0036)
-#define TPM_TAG_DA_INFO                ((UINT16)0x0037)
-#define TPM_TAG_DA_INFO_LIMITED        ((UINT16)0x0038)
-#define TPM_TAG_DA_ACTION_TYPE         ((UINT16)0x0039)
-
-
-//-------------------------------------------------------------------
-// Part 2, section 4: Types
-typedef UINT32 TPM_RESOURCE_TYPE;
-#define TPM_RT_KEY                     ((UINT32)0x00000001)
-#define TPM_RT_AUTH                    ((UINT32)0x00000002)
-#define TPM_RT_HASH                    ((UINT32)0x00000003)
-#define TPM_RT_TRANS                   ((UINT32)0x00000004)
-#define TPM_RT_CONTEXT                 ((UINT32)0x00000005)
-#define TPM_RT_COUNTER                 ((UINT32)0x00000006)
-#define TPM_RT_DELEGATE                ((UINT32)0x00000007)
-#define TPM_RT_DAA_TPM                 ((UINT32)0x00000008)
-#define TPM_RT_DAA_V0                  ((UINT32)0x00000009)
-#define TPM_RT_DAA_V1                  ((UINT32)0x0000000a)
-
-
-typedef BYTE TPM_PAYLOAD_TYPE;                              /* 1.1b */
-#define TPM_PT_ASYM                    ((BYTE)0x01)         /* 1.1b */
-#define TPM_PT_BIND                    ((BYTE)0x02)         /* 1.1b */
-#define TPM_PT_MIGRATE                 ((BYTE)0x03)         /* 1.1b */
-#define TPM_PT_MAINT                   ((BYTE)0x04)         /* 1.1b */
-#define TPM_PT_SEAL                    ((BYTE)0x05)         /* 1.1b */
-#define TPM_PT_MIGRATE_RESTRICTED      ((BYTE)0x06)
-#define TPM_PT_MIGRATE_EXTERNAL        ((BYTE)0x07)
-#define TPM_PT_CMK_MIGRATE             ((BYTE)0x08)
-
-
-typedef UINT16 TPM_ENTITY_TYPE;                             /* 1.1b */
-#define TPM_ET_KEYHANDLE               ((UINT16)0x0001)     /* 1.1b */
-#define TPM_ET_OWNER                   ((UINT16)0x0002)     /* 1.1b */
-#define TPM_ET_DATA                    ((UINT16)0x0003)     /* 1.1b */
-#define TPM_ET_SRK                     ((UINT16)0x0004)     /* 1.1b */
-#define TPM_ET_KEY                     ((UINT16)0x0005)     /* 1.1b */
-#define TPM_ET_REVOKE                  ((UINT16)0x0006)
-#define TPM_ET_DEL_OWNER_BLOB          ((UINT16)0x0007)
-#define TPM_ET_DEL_ROW                 ((UINT16)0x0008)
-#define TPM_ET_DEL_KEY_BLOB            ((UINT16)0x0009)
-#define TPM_ET_COUNTER                 ((UINT16)0x000a)
-#define TPM_ET_NV                      ((UINT16)0x000b)
-#define TPM_ET_OPERATOR                ((UINT16)0x000c)
-#define TPM_ET_RESERVED_HANDLE         ((UINT16)0x0040)
-
-/* The following values may be ORed into the MSB of the TPM_ENTITY_TYPE
- * to indicate particular encryption scheme
- */
-#define TPM_ET_XOR                     ((BYTE)0x00)
-#define TPM_ET_AES                     ((BYTE)0x06)
-
-typedef UINT32 TPM_KEY_HANDLE;                              /* 1.1b */
-#define TPM_KH_SRK                     ((UINT32)0x40000000)
-#define TPM_KH_OWNER                   ((UINT32)0x40000001)
-#define TPM_KH_REVOKE                  ((UINT32)0x40000002)
-#define TPM_KH_TRANSPORT               ((UINT32)0x40000003)
-#define TPM_KH_OPERATOR                ((UINT32)0x40000004)
-#define TPM_KH_ADMIN                   ((UINT32)0x40000005)
-#define TPM_KH_EK                      ((UINT32)0x40000006)
-/* 1.1b used different names, but the same values */
-#define TPM_KEYHND_SRK                 (TPM_KH_SRK)        /* 1.1b */
-#define TPM_KEYHND_OWNER               (TPM_KH_OWNER)      /* 1.1b */
-
-
-typedef UINT16 TPM_STARTUP_TYPE;                            /* 1.1b */
-#define TPM_ST_CLEAR                   ((UINT16)0x0001)     /* 1.1b */
-#define TPM_ST_STATE                   ((UINT16)0x0002)     /* 1.1b */
-#define TPM_ST_DEACTIVATED             ((UINT16)0x0003)     /* 1.1b */
-
-
-//typedef UINT32 TPM_STARTUP_EFFECTS;
-// 32-bit mask, see spec for meaning. Names not currently defined.
-// bits 0-8 have meaning
-
-typedef UINT16 TPM_PROTOCOL_ID;                             /* 1.1b */
-#define TPM_PID_OIAP                   ((UINT16)0x0001)     /* 1.1b */
-#define TPM_PID_OSAP                   ((UINT16)0x0002)     /* 1.1b */
-#define TPM_PID_ADIP                   ((UINT16)0x0003)     /* 1.1b */
-#define TPM_PID_ADCP                   ((UINT16)0x0004)     /* 1.1b */
-#define TPM_PID_OWNER                  ((UINT16)0x0005)     /* 1.1b */
-#define TPM_PID_DSAP                   ((UINT16)0x0006)
-#define TPM_PID_TRANSPORT              ((UINT16)0x0007)
-
-
-// Note in 1.2 rev 104, DES and 3DES are eliminated
-typedef UINT32 TPM_ALGORITHM_ID;                            /* 1.1b */
-#define TPM_ALG_RSA                    ((UINT32)0x00000001) /* 1.1b */
-#define TPM_ALG_DES                    ((UINT32)0x00000002) /* 1.1b */
-#define TPM_ALG_3DES                   ((UINT32)0x00000003) /* 1.1b */
-#define TPM_ALG_SHA                    ((UINT32)0x00000004) /* 1.1b */
-#define TPM_ALG_HMAC                   ((UINT32)0x00000005) /* 1.1b */
-#define TPM_ALG_AES                    ((UINT32)0x00000006) /* 1.1b */
-#define TPM_ALG_AES128                 (TPM_ALG_AES)
-#define TPM_ALG_MGF1                   ((UINT32)0x00000007)
-#define TPM_ALG_AES192                 ((UINT32)0x00000008)
-#define TPM_ALG_AES256                 ((UINT32)0x00000009)
-#define TPM_ALG_XOR                    ((UINT32)0x0000000a)
-
-
-typedef UINT16 TPM_PHYSICAL_PRESENCE;                        /* 1.1b */
-#define TPM_PHYSICAL_PRESENCE_LOCK          ((UINT16)0x0004) /* 1.1b */
-#define TPM_PHYSICAL_PRESENCE_PRESENT       ((UINT16)0x0008) /* 1.1b */
-#define TPM_PHYSICAL_PRESENCE_NOTPRESENT    ((UINT16)0x0010) /* 1.1b */
-#define TPM_PHYSICAL_PRESENCE_CMD_ENABLE    ((UINT16)0x0020) /* 1.1b */
-#define TPM_PHYSICAL_PRESENCE_HW_ENABLE     ((UINT16)0x0040) /* 1.1b */
-#define TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK ((UINT16)0x0080) /* 1.1b */
-#define TPM_PHYSICAL_PRESENCE_CMD_DISABLE   ((UINT16)0x0100)
-#define TPM_PHYSICAL_PRESENCE_HW_DISABLE    ((UINT16)0x0200)
-
-
-typedef UINT16 TPM_MIGRATE_SCHEME;                          /* 1.1b */
-#define TPM_MS_MIGRATE                   ((UINT16)0x0001)   /* 1.1b */
-#define TPM_MS_REWRAP                    ((UINT16)0x0002)   /* 1.1b */
-#define TPM_MS_MAINT                     ((UINT16)0x0003)   /* 1.1b */
-#define TPM_MS_RESTRICT_MIGRATE          ((UINT16)0x0004)
-#define TPM_MS_RESTRICT_APPROVE_DOUBLE   ((UINT16)0x0005)
-
-
-typedef UINT16 TPM_EK_TYPE;
-#define TPM_EK_TYPE_ACTIVATE           ((UINT16)0x0001)
-#define TPM_EK_TYPE_AUTH               ((UINT16)0x0002)
-
-
-typedef UINT16 TPM_PLATFORM_SPECIFIC;
-#define TPM_PS_PC_11                   ((UINT16)0x0001)
-#define TPM_PS_PC_12                   ((UINT16)0x0002)
-#define TPM_PS_PDA_12                  ((UINT16)0x0003)
-#define TPM_PS_Server_12               ((UINT16)0x0004)
-#define TPM_PS_Mobile_12               ((UINT16)0x0005)
-
-//-------------------------------------------------------------------
-// Part 2, section 5: Basic Structures
-
-typedef struct tdTPM_STRUCT_VER
-{
-    BYTE   major;
-    BYTE   minor;
-    BYTE   revMajor;
-    BYTE   revMinor;
-} TPM_STRUCT_VER;
-
-typedef struct tdTPM_VERSION_BYTE
-{
-    // This needs to be made compiler-independent.
-    int leastSigVer : 4; // least significant 4 bits
-    int mostSigVer  : 4; // most significant 4 bits
-} TPM_VERSION_BYTE;
-
-typedef struct tdTPM_VERSION
-{
-    BYTE   major;      // Should really be a TPM_VERSION_BYTE
-    BYTE   minor;      // Should really be a TPM_VERSION_BYTE
-    BYTE   revMajor;
-    BYTE   revMinor;
-} TPM_VERSION;
-
-
-// Put this in the right place:
-// byte size definition for 160 bit SHA1 hash value
-#define TPM_SHA1_160_HASH_LEN    0x14
-#define TPM_SHA1BASED_NONCE_LEN  TPM_SHA1_160_HASH_LEN
-
-typedef struct tdTPM_DIGEST
-{
-    BYTE  digest[TPM_SHA1_160_HASH_LEN];
-} TPM_DIGEST;
-
-typedef TPM_DIGEST TPM_CHOSENID_HASH;
-typedef TPM_DIGEST TPM_COMPOSITE_HASH;
-typedef TPM_DIGEST TPM_DIRVALUE;
-typedef TPM_DIGEST TPM_HMAC;
-typedef TPM_DIGEST TPM_PCRVALUE;
-typedef TPM_DIGEST TPM_AUDITDIGEST;
-
-typedef struct tdTPM_NONCE                                  /* 1.1b */
-{
-    BYTE  nonce[TPM_SHA1BASED_NONCE_LEN];
-} TPM_NONCE;
-
-typedef TPM_NONCE TPM_DAA_TPM_SEED;
-typedef TPM_NONCE TPM_DAA_CONTEXT_SEED;
-
-typedef struct tdTPM_AUTHDATA                               /* 1.1b */
-{
-    BYTE  authdata[TPM_SHA1_160_HASH_LEN];
-} TPM_AUTHDATA;
-
-typedef TPM_AUTHDATA TPM_SECRET;
-typedef TPM_AUTHDATA TPM_ENCAUTH;
-
-
-typedef struct tdTPM_KEY_HANDLE_LIST                        /* 1.1b */
-{
-    UINT16              loaded;
-    SIZEIS(loaded)
-        TPM_KEY_HANDLE *handle;
-} TPM_KEY_HANDLE_LIST;
-
-
-//-------------------------------------------------------------------
-// Part 2, section 5.8: Key usage values
-
-typedef UINT16 TPM_KEY_USAGE;                               /* 1.1b */
-#define TPM_KEY_SIGNING                ((UINT16)0x0010)     /* 1.1b */
-#define TPM_KEY_STORAGE                ((UINT16)0x0011)     /* 1.1b */
-#define TPM_KEY_IDENTITY               ((UINT16)0x0012)     /* 1.1b */
-#define TPM_KEY_AUTHCHANGE             ((UINT16)0x0013)     /* 1.1b */
-#define TPM_KEY_BIND                   ((UINT16)0x0014)     /* 1.1b */
-#define TPM_KEY_LEGACY                 ((UINT16)0x0015)     /* 1.1b */
-#define TPM_KEY_MIGRATE                ((UINT16)0x0016)
-
-typedef UINT16 TPM_SIG_SCHEME;                              /* 1.1b */
-#define TPM_SS_NONE                    ((UINT16)0x0001)     /* 1.1b */
-#define TPM_SS_RSASSAPKCS1v15_SHA1     ((UINT16)0x0002)     /* 1.1b */
-#define TPM_SS_RSASSAPKCS1v15_DER      ((UINT16)0x0003)     /* 1.1b */
-#define TPM_SS_RSASSAPKCS1v15_INFO     ((UINT16)0x0004)
-
-typedef UINT16 TPM_ENC_SCHEME;                              /* 1.1b */
-#define TPM_ES_NONE                    ((UINT16)0x0001)     /* 1.1b */
-#define TPM_ES_RSAESPKCSv15            ((UINT16)0x0002)     /* 1.1b */
-#define TPM_ES_RSAESOAEP_SHA1_MGF1     ((UINT16)0x0003)     /* 1.1b */
-#define TPM_ES_SYM_CNT                 ((UINT16)0x0004)
-#define TPM_ES_SYM_CTR                 TPM_ES_SYM_CNT
-#define TPM_ES_SYM_OFB                 ((UINT16)0x0005)
-#define TPM_ES_SYM_CBC_PKCS5PAD        ((UINT16)0x00ff)
-
-//-------------------------------------------------------------------
-// Part 2, section 5.9: TPM_AUTH_DATA_USAGE values
-
-typedef BYTE TPM_AUTH_DATA_USAGE;                           /* 1.1b */
-#define TPM_AUTH_NEVER                 ((BYTE)0x00)         /* 1.1b */
-#define TPM_AUTH_ALWAYS                ((BYTE)0x01)         /* 1.1b */
-#define TPM_AUTH_PRIV_USE_ONLY         ((BYTE)0x11)
-
-
-//-------------------------------------------------------------------
-// Part 2, section 5.10: TPM_KEY_FLAGS flags
-
-typedef UINT32 TPM_KEY_FLAGS;                               /* 1.1b */
-#define TPM_REDIRECTION                ((UINT32)0x00000001) /* 1.1b */
-#define TPM_MIGRATABLE                 ((UINT32)0x00000002) /* 1.1b */
-#define TPM_VOLATILE                   ((UINT32)0x00000004) /* 1.1b */
-#define TPM_PCRIGNOREDONREAD           ((UINT32)0x00000008)
-#define TPM_MIGRATEAUTHORITY           ((UINT32)0x00000010)
-
-
-//-------------------------------------------------------------------
-// Part 2, section 5.11: TPM_CHANGEAUTH_VALIDATE
-
-typedef struct tdTPM_CHANGEAUTH_VALIDATE
-{
-    TPM_SECRET newAuthSecret;
-    TPM_NONCE  n1;
-} TPM_CHANGEAUTH_VALIDATE;
-
-//-------------------------------------------------------------------
-// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH
-// declared after section 10 to catch declaration of TPM_PUBKEY 
-
-//-------------------------------------------------------------------
-// Part 2, section 5.13: TPM_COUNTER_VALUE;
-
-typedef UINT32 TPM_ACTUAL_COUNT;
-typedef struct tdTPM_COUNTER_VALUE
-{
-    TPM_STRUCTURE_TAG tag;
-    BYTE              label[4];
-    TPM_ACTUAL_COUNT  counter;
-} TPM_COUNTER_VALUE;
-
-//-------------------------------------------------------------------
-// Part 2, section 5.14: TPM_SIGN_INFO structure
-
-typedef struct tdTPM_SIGN_INFO
-{
-    TPM_STRUCTURE_TAG tag;
-    BYTE              fixed[4];
-    TPM_NONCE         replay;
-    UINT32            dataLen;
-    SIZEIS(dataLen)
-        BYTE         *data;
-} TPM_SIGN_INFO;
-
-//-------------------------------------------------------------------
-// Part 2, section 5.15: TPM_MSA_COMPOSITE
-
-typedef struct tdTPM_MSA_COMPOSITE
-{
-    UINT32          MSAlist;
-    SIZEIS(MSAlist)
-        TPM_DIGEST *migAuthDigest;
-} TPM_MSA_COMPOSITE;
-
-//-------------------------------------------------------------------
-// Part 2, section 5.16: TPM_CMK_AUTH
-
-typedef struct tdTPM_CMK_AUTH
-{
-    TPM_DIGEST migrationAuthorityDigest;
-    TPM_DIGEST destinationKeyDigest;
-    TPM_DIGEST sourceKeyDigest;
-} TPM_CMK_AUTH;
-
-//-------------------------------------------------------------------
-// Part 2, section 5.17: TPM_CMK_DELEGATE
-
-typedef UINT32 TPM_CMK_DELEGATE;
-#define TPM_CMK_DELEGATE_SIGNING       (((UINT32)1)<<31)
-#define TPM_CMK_DELEGATE_STORAGE       (((UINT32)1)<<30)
-#define TPM_CMK_DELEGATE_BIND          (((UINT32)1)<<29)
-#define TPM_CMK_DELEGATE_LEGACY        (((UINT32)1)<<28)
-#define TPM_CMK_DELEGATE_MIGRATE       (((UINT32)1)<<27)
-
-//-------------------------------------------------------------------
-// Part 2, section 5.18: TPM_SELECT_SIZE
-
-typedef struct tdTPM_SELECT_SIZE
-{
-    BYTE   major;
-    BYTE   minor;
-    UINT16 reqSize;
-} TPM_SELECT_SIZE;
-
-//-------------------------------------------------------------------
-// Part 2, section 5.19: TPM_CMK_MIGAUTH
-
-typedef struct tdTPM_CMK_MIGAUTH
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_DIGEST        msaDigest;
-    TPM_DIGEST        pubKeyDigest;
-} TPM_CMK_MIGAUTH;
-
-//-------------------------------------------------------------------
-// Part 2, section 5.20: TPM_CMK_SIGTICKET
-
-typedef struct tdTPM_CMK_SIGTICKET
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_DIGEST        verKeyDigest;
-    TPM_DIGEST        signedData;
-} TPM_CMK_SIGTICKET;
-
-//-------------------------------------------------------------------
-// Part 2, section 5.21: TPM_CMK_MA_APPROVAL
-
-typedef struct tdTPM_CMK_MA_APPROVAL
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_DIGEST        migrationAuthorityDigest;
-} TPM_CMK_MA_APPROVAL;
-
-
-//-------------------------------------------------------------------
-// Part 2, section 6: Command Tags
-
-typedef UINT16 TPM_TAG;                                     /* 1.1b */
-#define TPM_TAG_RQU_COMMAND            ((UINT16)0x00c1)
-#define TPM_TAG_RQU_AUTH1_COMMAND      ((UINT16)0x00c2)
-#define TPM_TAG_RQU_AUTH2_COMMAND      ((UINT16)0x00c3)
-#define TPM_TAG_RSP_COMMAND            ((UINT16)0x00c4)
-#define TPM_TAG_RSP_AUTH1_COMMAND      ((UINT16)0x00c5)
-#define TPM_TAG_RSP_AUTH2_COMMAND      ((UINT16)0x00c6)
-
-
-//-------------------------------------------------------------------
-// Part 2, section 7.1: TPM_PERMANENT_FLAGS
-
-typedef struct tdTPM_PERMANENT_FLAGS
-{
-    TPM_STRUCTURE_TAG tag;
-    TSS_BOOL disable;
-    TSS_BOOL ownership;
-    TSS_BOOL deactivated;
-    TSS_BOOL readPubek;
-    TSS_BOOL disableOwnerClear;
-    TSS_BOOL allowMaintenance;
-    TSS_BOOL physicalPresenceLifetimeLock;
-    TSS_BOOL physicalPresenceHWEnable;
-    TSS_BOOL physicalPresenceCMDEnable;
-    TSS_BOOL CEKPUsed;
-    TSS_BOOL TPMpost;
-    TSS_BOOL TPMpostLock;
-    TSS_BOOL FIPS;
-    TSS_BOOL Operator;
-    TSS_BOOL enableRevokeEK;
-    TSS_BOOL nvLocked;
-    TSS_BOOL readSRKPub;
-    TSS_BOOL tpmEstablished;
-    TSS_BOOL maintenanceDone;
-    TSS_BOOL disableFullDALogicInfo;
-} TPM_PERMANENT_FLAGS;
-
-#define TPM_PF_DISABLE                      ((UINT32)0x00000001)
-#define TPM_PF_OWNERSHIP                    ((UINT32)0x00000002)
-#define TPM_PF_DEACTIVATED                  ((UINT32)0x00000003)
-#define TPM_PF_READPUBEK                    ((UINT32)0x00000004)
-#define TPM_PF_DISABLEOWNERCLEAR            ((UINT32)0x00000005)
-#define TPM_PF_ALLOWMAINTENANCE             ((UINT32)0x00000006)
-#define TPM_PF_PHYSICALPRESENCELIFETIMELOCK ((UINT32)0x00000007)
-#define TPM_PF_PHYSICALPRESENCEHWENABLE     ((UINT32)0x00000008)
-#define TPM_PF_PHYSICALPRESENCECMDENABLE    ((UINT32)0x00000009)
-#define TPM_PF_CEKPUSED                     ((UINT32)0x0000000A)
-#define TPM_PF_TPMPOST                      ((UINT32)0x0000000B)
-#define TPM_PF_TPMPOSTLOCK                  ((UINT32)0x0000000C)
-#define TPM_PF_FIPS                         ((UINT32)0x0000000D)
-#define TPM_PF_OPERATOR                     ((UINT32)0x0000000E)
-#define TPM_PF_ENABLEREVOKEEK               ((UINT32)0x0000000F)
-#define TPM_PF_NV_LOCKED                    ((UINT32)0x00000010)
-#define TPM_PF_READSRKPUB                   ((UINT32)0x00000011)
-#define TPM_PF_RESETESTABLISHMENTBIT        ((UINT32)0x00000012)
-#define TPM_PF_MAINTENANCEDONE              ((UINT32)0x00000013)
-#define TPM_PF_DISABLEFULLDALOGICINFO       ((UINT32)0x00000014)
-
-
-//-------------------------------------------------------------------
-// Part 2, section 7.2: TPM_STCLEAR_FLAGS
-
-typedef struct tdTPM_STCLEAR_FLAGS
-{
-    TPM_STRUCTURE_TAG tag;
-    TSS_BOOL          deactivated;
-    TSS_BOOL          disableForceClear;
-    TSS_BOOL          physicalPresence;
-    TSS_BOOL          physicalPresenceLock;
-    TSS_BOOL          bGlobalLock;
-} TPM_STCLEAR_FLAGS;
-
-#define TPM_SF_DEACTIVATED             ((UINT32)0x00000001)
-#define TPM_SF_DISABLEFORCECLEAR       ((UINT32)0x00000002)
-#define TPM_SF_PHYSICALPRESENCE        ((UINT32)0x00000003)
-#define TPM_SF_PHYSICALPRESENCELOCK    ((UINT32)0x00000004)
-#define TPM_SF_GLOBALLOCK              ((UINT32)0x00000005)
-
-
-//-------------------------------------------------------------------
-// Part 2, section 7.3: TPM_STANY_FLAGS
-
-typedef struct tdTPM_STANY_FLAGS
-{
-    TPM_STRUCTURE_TAG      tag;
-    TSS_BOOL               postInitialise;
-    TPM_MODIFIER_INDICATOR localityModifier;
-    TSS_BOOL               transportExclusive;
-    TSS_BOOL               TOSPresent;
-} TPM_STANY_FLAGS;
-
-#define TPM_AF_POSTINITIALIZE          ((UINT32)0x00000001)
-#define TPM_AF_LOCALITYMODIFIER        ((UINT32)0x00000002)
-#define TPM_AF_TRANSPORTEXCLUSIVE      ((UINT32)0x00000003)
-#define TPM_AF_TOSPRESENT              ((UINT32)0x00000004)
-
-
-//-------------------------------------------------------------------
-// Part 2, section 7.4: TPM_PERMANENT_DATA
-// available inside TPM only
-//
-//#define TPM_MIN_COUNTERS          4
-//#define TPM_NUM_PCR              16
-//#define TPM_MAX_NV_WRITE_NOOWNER 64
-//
-//typedef struct tdTPM_PERMANENT_DATA
-//{
-//    TPM_STRUCTURE_TAG  tag;
-//    BYTE               revMajor;
-//    BYTE               revMinor;
-//    TPM_NONCE          tpmProof;
-//    TPM_NONCE          ekReset;
-//    TPM_SECRET         ownerAuth;
-//    TPM_SECRET         operatorAuth;
-//    TPM_DIRVALUE       authDIR[1];
-//    TPM_PUBKEY         manuMaintPub;
-//    TPM_KEY            endorsementKey;
-//    TPM_KEY            srk;
-//    TPM_KEY            contextKey;
-//    TPM_KEY            delegateKey;
-//    TPM_COUNTER_VALUE  auditMonotonicCounter;
-//    TPM_COUNTER_VALUE  monitonicCounter[TPM_MIN_COUNTERS];
-//    TPM_PCR_ATTRIBUTES pcrAttrib[TPM_NUM_PCR];
-//    BYTE               ordinalAuditStatus[];
-//    BYTE              *rngState;
-//    TPM_FAMILY_TABLE   familyTable;
-//    TPM_DELEGATE_TABLE delegateTable;
-//    UINT32             maxNVBufSize;
-//    UINT32             lastFamilyID;
-//    UINT32             noOwnerNVWrite;
-//    TPM_CMK_DELEGATE   restrictDelegate;
-//    TPM_DAA_TPM_SEED   tpmDAASeed;
-//    TPM_NONCE          daaProof;
-//    TPM_NONCE          daaBlobKey;
-//} TPM_PERMANENT_DATA;
-
-
-//-------------------------------------------------------------------
-// Part 2, section 7.5: TPM_STCLEAR_DATA
-// available inside TPM only
-//
-//typedef struct tdTPM_STCLEAR_DATA
-//{
-//    TPM_STRUCTURE_TAG tag;
-//    TPM_NONCE         contextNonceKey;
-//    TPM_COUNT_ID      countID;
-//    UINT32            ownerReference;
-//    TPM_BOOL          disableResetLock;
-//    TPM_PCRVALUE      PCR[TPM_NUM_PCR];
-//    UINT32            deferredPhysicalPresence;
-//} TPM_STCLEAR_DATA;
-    
-
-
-//-------------------------------------------------------------------
-// Part 2, section 7.5: TPM_STANY_DATA
-// available inside TPM only
-//
-//typedef struct tdTPM_STANY_DATA
-//{
-//    TPM_STRUCTURE_TAG tag;
-//    TPM_NONCE         contextNonceSession;
-//    TPM_DIGEST        auditDigest;
-//    TPM_CURRENT_TICKS currentTicks;
-//    UINT32            contextCount;
-//    UINT32            contextList[TPM_MIN_SESSION_LIST];
-//    TPM_SESSION_DATA  sessions[TPM_MIN_SESSIONS];
-//    // The following appear in section 22.6 but not in 7.5
-//    TPM_DAA_ISSUER    DAA_issuerSettings;
-//    TPM_DAA_TPM       DAA_tpmSpecific;
-//    TPM_DAA_CONTEXT   DAA_session;
-//    TPM_DAA_JOINDATA  DAA_joinSession;
-//} TPM_STANY_DATA;
-    
-
-
-//-------------------------------------------------------------------
-// Part 2, section 8: PCR Structures
-
-typedef BYTE  TPM_LOCALITY_SELECTION;
-#define TPM_LOC_FOUR                   (((UINT32)1)<<4)
-#define TPM_LOC_THREE                  (((UINT32)1)<<3)
-#define TPM_LOC_TWO                    (((UINT32)1)<<2)
-#define TPM_LOC_ONE                    (((UINT32)1)<<1)
-#define TPM_LOC_ZERO                   (((UINT32)1)<<0)
-
-typedef struct tdTPM_PCR_SELECTION                          /* 1.1b */
-{ 
-    UINT16    sizeOfSelect;
-    SIZEIS(sizeOfSelect)
-        BYTE *pcrSelect;  
-} TPM_PCR_SELECTION;
-
-typedef struct tdTPM_PCR_COMPOSITE                          /* 1.1b */
-{ 
-    TPM_PCR_SELECTION select;
-    UINT32            valueSize;
-    SIZEIS(valueSize)
-        TPM_PCRVALUE *pcrValue; 
-} TPM_PCR_COMPOSITE;
-
-typedef struct tdTPM_PCR_INFO                               /* 1.1b */
-{
-    TPM_PCR_SELECTION  pcrSelection;
-    TPM_COMPOSITE_HASH digestAtRelease;
-    TPM_COMPOSITE_HASH digestAtCreation;
-}  TPM_PCR_INFO;
-
-typedef struct tdTPM_PCR_INFO_LONG
-{
-    TPM_STRUCTURE_TAG      tag;
-    TPM_LOCALITY_SELECTION localityAtCreation;
-    TPM_LOCALITY_SELECTION localityAtRelease;
-    TPM_PCR_SELECTION      creationPCRSelection;
-    TPM_PCR_SELECTION      releasePCRSelection;
-    TPM_COMPOSITE_HASH     digestAtCreation;
-    TPM_COMPOSITE_HASH     digestAtRelease;
-}  TPM_PCR_INFO_LONG;
-
-typedef struct tdTPM_PCR_INFO_SHORT
-{
-    TPM_PCR_SELECTION      pcrSelection;
-    TPM_LOCALITY_SELECTION localityAtRelease;
-    TPM_COMPOSITE_HASH     digestAtRelease;
-}  TPM_PCR_INFO_SHORT;
-
-typedef struct tdTPM_PCR_ATTRIBUTES
-{
-    BYTE                   pcrReset;
-    TPM_LOCALITY_SELECTION pcrExtendLocal;
-    TPM_LOCALITY_SELECTION pcrResetLocal;
-} TPM_PCR_ATTRIBUTES;
-
-
-
-//-------------------------------------------------------------------
-// Part 2, section 9:
-
-typedef struct tdTPM_STORED_DATA                            /* 1.1b */
-{
-    TPM_STRUCT_VER ver;
-    UINT32         sealInfoSize;
-    SIZEIS(sealInfoSize)
-        BYTE      *sealInfo;
-    UINT32         encDataSize;
-    SIZEIS(encDataSize)
-        BYTE      *encData;
-} TPM_STORED_DATA;
-
-typedef struct tdTPM_STORED_DATA12
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_ENTITY_TYPE   et;
-    UINT32            sealInfoSize;
-    SIZEIS(sealInfoSize)
-        BYTE         *sealInfo;
-    UINT32            encDataSize;
-    SIZEIS(encDataSize)
-        BYTE         *encData;
-} TPM_STORED_DATA12;
-
-typedef struct tdTPM_SEALED_DATA                            /* 1.1b */
-{ 
-    TPM_PAYLOAD_TYPE  payload;
-    TPM_SECRET        authData;
-    TPM_NONCE         tpmProof;
-    TPM_DIGEST        storedDigest;
-    UINT32            dataSize;
-    SIZEIS(dataSize)
-        BYTE         *data;
-} TPM_SEALED_DATA;
-
-typedef struct tdTPM_SYMMETRIC_KEY                          /* 1.1b */
-{
-    TPM_ALGORITHM_ID  algId;
-    TPM_ENC_SCHEME    encScheme;
-    UINT16            size;
-    SIZEIS(size)
-        BYTE         *data;
-} TPM_SYMMETRIC_KEY;
-
-typedef struct tdTPM_BOUND_DATA
-{
-    TPM_STRUCT_VER   ver;
-    TPM_PAYLOAD_TYPE payload;
-    BYTE            *payloadData; // length is implied
-} TPM_BOUND_DATA;
-
-
-//-------------------------------------------------------------------
-// Part 2, section 10: TPM_KEY complex
-
-typedef struct tdTPM_KEY_PARMS                              /* 1.1b */
-{
-    TPM_ALGORITHM_ID  algorithmID;
-    TPM_ENC_SCHEME    encScheme;
-    TPM_SIG_SCHEME    sigScheme;
-    UINT32            parmSize;
-    SIZEIS(parmSize)
-        BYTE         *parms;
-} TPM_KEY_PARMS;
-
-typedef struct tdTPM_RSA_KEY_PARMS                          /* 1.1b */
-{  
-    UINT32    keyLength; 
-    UINT32    numPrimes; 
-    UINT32    exponentSize;
-    SIZEIS(exponentSize)
-        BYTE *exponent;
-} TPM_RSA_KEY_PARMS;
-
-typedef struct tdTPM_SYMMETRIC_KEY_PARMS
-{
-    UINT32 keyLength;
-    UINT32 blockSize;
-    UINT32 ivSize;
-    SIZEIS(ivSize)
-        BYTE *IV;
-} TPM_SYMMETRIC_KEY_PARMS;
-
-typedef struct tdTPM_STORE_PUBKEY                           /* 1.1b */
-{
-    UINT32    keyLength;
-    SIZEIS(keyLength)
-        BYTE *key;
-} TPM_STORE_PUBKEY;
-
-typedef struct tdTPM_PUBKEY                                 /* 1.1b */
-{
-    TPM_KEY_PARMS     algorithmParms;
-    TPM_STORE_PUBKEY  pubKey;
-} TPM_PUBKEY;
-
-typedef struct tdTPM_STORE_PRIVKEY                          /* 1.1b */
-{
-    UINT32    keyLength;
-    SIZEIS(keyLength)
-        BYTE *key;   
-} TPM_STORE_PRIVKEY;
-
-typedef struct tdTPM_STORE_ASYMKEY                          /* 1.1b */
-{         
-    TPM_PAYLOAD_TYPE  payload;   
-    TPM_SECRET        usageAuth;    
-    TPM_SECRET        migrationAuth;  
-    TPM_DIGEST        pubDataDigest;   
-    TPM_STORE_PRIVKEY privKey;   
-} TPM_STORE_ASYMKEY;
-
-typedef struct tdTPM_KEY                                    /* 1.1b */
-{
-    TPM_STRUCT_VER      ver;
-    TPM_KEY_USAGE       keyUsage;
-    TPM_KEY_FLAGS       keyFlags;
-    TPM_AUTH_DATA_USAGE authDataUsage;
-    TPM_KEY_PARMS       algorithmParms; 
-    UINT32              PCRInfoSize;
-    SIZEIS(PCRInfoSize)
-        BYTE           *PCRInfo;
-    TPM_STORE_PUBKEY    pubKey;
-    UINT32              encSize;
-    SIZEIS(encSize)
-        BYTE           *encData; 
-} TPM_KEY;
-
-typedef struct tdTPM_KEY12
-{
-    TPM_STRUCTURE_TAG   tag;
-    UINT16              fill;
-    TPM_KEY_USAGE       keyUsage;
-    TPM_KEY_FLAGS       keyFlags;
-    TPM_AUTH_DATA_USAGE authDataUsage;
-    TPM_KEY_PARMS       algorithmParms;
-    UINT32              PCRInfoSize;
-    SIZEIS(PCRInfoSize)
-       BYTE            *PCRInfo;
-    TPM_STORE_PUBKEY    pubKey;
-    UINT32              encSize;
-    SIZEIS(encSize)
-       BYTE            *encData;
-} TPM_KEY12;
-
-typedef struct tdTPM_MIGRATE_ASYMKEY
-{
-    TPM_PAYLOAD_TYPE payload;
-    TPM_SECRET       usageAuth;
-    TPM_DIGEST       pubDataDigest;
-    UINT32           partPrivKeyLen;
-    SIZEIS(partPrivKeyLen)
-        BYTE        *partPrivKey;
-} TPM_MIGRATE_ASYMKEY;
-
-
-typedef UINT32 TPM_KEY_CONTROL;
-#define TPM_KEY_CONTROL_OWNER_EVICT    ((UINT32)0x00000001)
-
-
-//-------------------------------------------------------------------
-// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH
-
-typedef struct tdTPM_MIGRATIONKEYAUTH                       /* 1.1b */
-{
-    TPM_PUBKEY         migrationKey;
-    TPM_MIGRATE_SCHEME migrationScheme;
-    TPM_DIGEST         digest;
-} TPM_MIGRATIONKEYAUTH;
-
-
-//-------------------------------------------------------------------
-// Part 2, section 11: Signed Structures
-
-typedef struct tdTPM_CERTIFY_INFO                           /* 1.1b */
-{
-    TPM_STRUCT_VER      version;
-    TPM_KEY_USAGE       keyUsage;
-    TPM_KEY_FLAGS       keyFlags;
-    TPM_AUTH_DATA_USAGE authDataUsage;
-    TPM_KEY_PARMS       algorithmParms;
-    TPM_DIGEST          pubkeyDigest;
-    TPM_NONCE           data;
-    TPM_BOOL            parentPCRStatus;
-    UINT32              PCRInfoSize;
-    SIZEIS(PCRInfoSize)
-        BYTE           *PCRInfo;
-} TPM_CERTIFY_INFO;
-
-typedef struct tdTPM_CERTIFY_INFO2
-{
-    TPM_STRUCTURE_TAG   tag;
-    BYTE                fill;
-    TPM_PAYLOAD_TYPE    payloadType;
-    TPM_KEY_USAGE       keyUsage;
-    TPM_KEY_FLAGS       keyFlags;
-    TPM_AUTH_DATA_USAGE authDataUsage;
-    TPM_KEY_PARMS       algorithmParms;
-    TPM_DIGEST          pubkeyDigest;
-    TPM_NONCE           data;
-    TPM_BOOL            parentPCRStatus;
-    UINT32              PCRInfoSize;
-    SIZEIS(PCRInfoSize) 
-        BYTE           *PCRInfo;
-    UINT32              migrationAuthoritySize;
-    SIZEIS(migrationAuthoritySize)
-        BYTE           *migrationAuthority;
-} TPM_CERTIFY_INFO2;
-
-typedef struct tdTPM_QUOTE_INFO                             /* 1.1b */
-{
-    TPM_STRUCT_VER     version;
-    BYTE               fixed[4];
-    TPM_COMPOSITE_HASH compositeHash; /* in 1.2 TPM spec, named digestValue */
-    TPM_NONCE          externalData;
-} TPM_QUOTE_INFO;
-
-typedef struct tdTPM_QUOTE_INFO2
-{
-    TPM_STRUCTURE_TAG  tag;
-    BYTE               fixed[4];
-    TPM_NONCE          externalData;
-    TPM_PCR_INFO_SHORT infoShort;
-} TPM_QUOTE_INFO2;
-
-
-
-//-------------------------------------------------------------------
-// Part 2, section 12: Identity Structures
-
-
-typedef struct tdTPM_EK_BLOB
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_EK_TYPE       ekType;
-    UINT32            blobSize;
-    SIZEIS(blobSize)
-        BYTE         *blob;
-} TPM_EK_BLOB;
-
-typedef struct tdTPM_EK_BLOB_ACTIVATE
-{
-    TPM_STRUCTURE_TAG  tag;
-    TPM_SYMMETRIC_KEY  sessionKey;
-    TPM_DIGEST         idDigest;
-    TPM_PCR_INFO_SHORT pcrInfo;
-} TPM_EK_BLOB_ACTIVATE;
-
-typedef struct tdTPM_EK_BLOB_AUTH
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_SECRET        authValue;
-} TPM_EK_BLOB_AUTH;
-
-
-typedef struct tdTPM_IDENTITY_CONTENTS
-{
-    TPM_STRUCT_VER    ver;
-    UINT32            ordinal;
-    TPM_CHOSENID_HASH labelPrivCADigest;
-    TPM_PUBKEY        identityPubKey;
-} TPM_IDENTITY_CONTENTS;
-
-typedef struct tdTPM_IDENTITY_REQ                           /* 1.1b */
-{
-    UINT32         asymSize;
-    UINT32         symSize;
-    TPM_KEY_PARMS  asymAlgorithm;
-    TPM_KEY_PARMS  symAlgorithm;
-    SIZEIS(asymSize)
-        BYTE      *asymBlob;
-    SIZEIS(symSize)
-        BYTE      *symBlob;
-} TPM_IDENTITY_REQ;
-
-typedef struct tdTPM_IDENTITY_PROOF                         /* 1.1b */
-{
-    TPM_STRUCT_VER  ver;
-    UINT32          labelSize;
-    UINT32          identityBindingSize;
-    UINT32          endorsementSize;
-    UINT32          platformSize;
-    UINT32          conformanceSize;
-    TPM_PUBKEY      identityKey;
-    SIZEIS(labelSize)
-      BYTE         *labelArea;
-    SIZEIS(identityBindingSize)
-      BYTE         *identityBinding;
-    SIZEIS(endorsementSize)
-      BYTE         *endorsementCredential;
-    SIZEIS(platformSize)
-      BYTE         *platformCredential;
-    SIZEIS(conformanceSize)
-      BYTE         *conformanceCredential;
-} TPM_IDENTITY_PROOF;
-
-typedef struct tdTPM_ASYM_CA_CONTENTS                       /* 1.1b */
-{
-    TPM_SYMMETRIC_KEY sessionKey;
-    TPM_DIGEST        idDigest;
-} TPM_ASYM_CA_CONTENTS;
-
-typedef struct tdTPM_SYM_CA_ATTESTATION
-{
-    UINT32         credSize;
-    TPM_KEY_PARMS  algorithm;
-    SIZEIS(credSize)
-        BYTE      *credential;
-} TPM_SYM_CA_ATTESTATION;
-
-
-
-//-------------------------------------------------------------------
-// Part 2, section 15: Tick Structures
-// Placed here out of order because definitions are used in section 13.
-
-typedef struct tdTPM_CURRENT_TICKS
-{
-    TPM_STRUCTURE_TAG tag;
-    UINT64            currentTicks;
-    UINT16            tickRate;
-    TPM_NONCE         tickNonce;
-} TPM_CURRENT_TICKS;
-
-
-
-//-------------------------------------------------------------------
-// Part 2, section 13: Transport structures
-
-typedef UINT32 TPM_TRANSPORT_ATTRIBUTES;
-#define TPM_TRANSPORT_ENCRYPT          ((UINT32)0x00000001)
-#define TPM_TRANSPORT_LOG              ((UINT32)0x00000002)
-#define TPM_TRANSPORT_EXCLUSIVE        ((UINT32)0x00000004)
-
-typedef struct tdTPM_TRANSPORT_PUBLIC
-{
-    TPM_STRUCTURE_TAG        tag;
-    TPM_TRANSPORT_ATTRIBUTES transAttributes;
-    TPM_ALGORITHM_ID         algId;
-    TPM_ENC_SCHEME           encScheme;
-} TPM_TRANSPORT_PUBLIC;
-
-typedef struct tdTPM_TRANSPORT_INTERNAL
-{
-    TPM_STRUCTURE_TAG    tag;
-    TPM_AUTHDATA         authData;
-    TPM_TRANSPORT_PUBLIC transPublic;
-    TPM_TRANSHANDLE      transHandle;
-    TPM_NONCE            transNonceEven;
-    TPM_DIGEST           transDigest;
-} TPM_TRANSPORT_INTERNAL;
-
-typedef struct tdTPM_TRANSPORT_LOG_IN
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_DIGEST        parameters;
-    TPM_DIGEST        pubKeyHash;
-} TPM_TRANSPORT_LOG_IN;
-
-typedef struct tdTPM_TRANSPORT_LOG_OUT
-{
-    TPM_STRUCTURE_TAG      tag;
-    TPM_CURRENT_TICKS      currentTicks;
-    TPM_DIGEST             parameters;
-    TPM_MODIFIER_INDICATOR locality;
-} TPM_TRANSPORT_LOG_OUT;
-
-typedef struct tdTPM_TRANSPORT_AUTH
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_AUTHDATA      authData;
-} TPM_TRANSPORT_AUTH;
-
-
-
-//-------------------------------------------------------------------
-// Part 2, section 14: Audit Structures
-
-typedef struct tdTPM_AUDIT_EVENT_IN
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_DIGEST        inputParms;
-    TPM_COUNTER_VALUE auditCount;
-} TPM_AUDIT_EVENT_IN;
-
-typedef struct tdTPM_AUDIT_EVENT_OUT
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_COMMAND_CODE  ordinal;
-    TPM_DIGEST        outputParms;
-    TPM_COUNTER_VALUE auditCount;
-    TPM_RESULT        returnCode;
-} TPM_AUDIT_EVENT_OUT;
-
-
-
-//-------------------------------------------------------------------
-// Part 2, section 16: Return codes
-
-#include <tss/tpm_error.h>
-
-
-//-------------------------------------------------------------------
-// Part 2, section 17: Ordinals
-
-#include <tss/tpm_ordinal.h>
-
-//-------------------------------------------------------------------
-// Part 2, section 18: Context structures
-
-typedef struct tdTPM_CONTEXT_BLOB
-{
-    TPM_STRUCTURE_TAG  tag;
-    TPM_RESOURCE_TYPE  resourceType;
-    TPM_HANDLE         handle;
-    BYTE               label[16];
-    UINT32             contextCount;
-    TPM_DIGEST         integrityDigest;
-    UINT32             additionalSize;
-    SIZEIS(additionalSize)
-        BYTE          *additionalData;
-    UINT32             sensitiveSize;
-    SIZEIS(sensitiveSize)
-        BYTE          *sensitiveData;
-} TPM_CONTEXT_BLOB;
-
-typedef struct tdTPM_CONTEXT_SENSITIVE
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_NONCE         contextNonce;
-    UINT32            internalSize;
-    SIZEIS(internalSize)
-        BYTE         *internalData;
-} TPM_CONTEXT_SENSITIVE;
-
-//-------------------------------------------------------------------
-// Part 2, section 19: NV Structures
-
-typedef UINT32 TPM_NV_INDEX;
-#define TPM_NV_INDEX_LOCK              ((UINT32)0xffffffff)
-#define TPM_NV_INDEX0                  ((UINT32)0x00000000)
-#define TPM_NV_INDEX_DIR               ((UINT32)0x10000001)
-#define TPM_NV_INDEX_EKCert            ((UINT32)0x0000f000)
-#define TPM_NV_INDEX_TPM_CC            ((UINT32)0x0000f001)
-#define TPM_NV_INDEX_PlatformCert      ((UINT32)0x0000f002)
-#define TPM_NV_INDEX_Platform_CC       ((UINT32)0x0000f003)
-// The following define ranges of reserved indices.
-#define TPM_NV_INDEX_TSS_BASE          ((UINT32)0x00011100)
-#define TPM_NV_INDEX_PC_BASE           ((UINT32)0x00011200)
-#define TPM_NV_INDEX_SERVER_BASE       ((UINT32)0x00011300)
-#define TPM_NV_INDEX_MOBILE_BASE       ((UINT32)0x00011400)
-#define TPM_NV_INDEX_PERIPHERAL_BASE   ((UINT32)0x00011500)
-#define TPM_NV_INDEX_GROUP_RESV_BASE   ((UINT32)0x00010000)
-
-
-typedef UINT32 TPM_NV_PER_ATTRIBUTES;
-#define TPM_NV_PER_READ_STCLEAR        (((UINT32)1)<<31)
-#define TPM_NV_PER_AUTHREAD            (((UINT32)1)<<18)
-#define TPM_NV_PER_OWNERREAD           (((UINT32)1)<<17)
-#define TPM_NV_PER_PPREAD              (((UINT32)1)<<16)
-#define TPM_NV_PER_GLOBALLOCK          (((UINT32)1)<<15)
-#define TPM_NV_PER_WRITE_STCLEAR       (((UINT32)1)<<14)
-#define TPM_NV_PER_WRITEDEFINE         (((UINT32)1)<<13)
-#define TPM_NV_PER_WRITEALL            (((UINT32)1)<<12)
-#define TPM_NV_PER_AUTHWRITE           (((UINT32)1)<<2)
-#define TPM_NV_PER_OWNERWRITE          (((UINT32)1)<<1)
-#define TPM_NV_PER_PPWRITE             (((UINT32)1)<<0)
-
-typedef struct tdTPM_NV_ATTRIBUTES
-{
-    TPM_STRUCTURE_TAG     tag;
-    TPM_NV_PER_ATTRIBUTES attributes;
-} TPM_NV_ATTRIBUTES;
-
-
-typedef struct tdTPM_NV_DATA_PUBLIC
-{
-    TPM_STRUCTURE_TAG  tag;
-    TPM_NV_INDEX       nvIndex;
-    TPM_PCR_INFO_SHORT pcrInfoRead;
-    TPM_PCR_INFO_SHORT pcrInfoWrite;
-    TPM_NV_ATTRIBUTES  permission;
-    TPM_BOOL           bReadSTClear;
-    TPM_BOOL           bWriteSTClear;
-    TPM_BOOL           bWriteDefine;
-    UINT32             dataSize;
-} TPM_NV_DATA_PUBLIC;
-
-
-#if 0
-// Internal to TPM:
-typedef struct tdTPM_NV_DATA_SENSITIVE
-{
-    TPM_STRUCTURE_TAG  tag;
-    TPM_NV_DATA_PUBLIC pubInfo;
-    TPM_AUTHDATA       authValue;
-    SIZEIS(pubInfo.dataSize)
-        BYTE          *data;
-} TPM_NV_DATA_SENSITIVE;
-#endif
-
-
-//-------------------------------------------------------------------
-// Part 2, section 20: Delegation
-
-//-------------------------------------------------------------------
-// Part 2, section 20.3: Owner Permissions Settings for per1 bits
-#define TPM_DELEGATE_SetOrdinalAuditStatus          (((UINT32)1)<<30)
-#define TPM_DELEGATE_DirWriteAuth                   (((UINT32)1)<<29)
-#define TPM_DELEGATE_CMK_ApproveMA                  (((UINT32)1)<<28)
-#define TPM_DELEGATE_NV_WriteValue                  (((UINT32)1)<<27)
-#define TPM_DELEGATE_CMK_CreateTicket               (((UINT32)1)<<26)
-#define TPM_DELEGATE_NV_ReadValue                   (((UINT32)1)<<25)
-#define TPM_DELEGATE_Delegate_LoadOwnerDelegation   (((UINT32)1)<<24)
-#define TPM_DELEGATE_DAA_Join                       (((UINT32)1)<<23)
-#define TPM_DELEGATE_AuthorizeMigrationKey          (((UINT32)1)<<22)
-#define TPM_DELEGATE_CreateMaintenanceArchive       (((UINT32)1)<<21)
-#define TPM_DELEGATE_LoadMaintenanceArchive         (((UINT32)1)<<20)
-#define TPM_DELEGATE_KillMaintenanceFeature         (((UINT32)1)<<19)
-#define TPM_DELEGATE_OwnerReadInternalPub           (((UINT32)1)<<18)
-#define TPM_DELEGATE_ResetLockValue                 (((UINT32)1)<<17)
-#define TPM_DELEGATE_OwnerClear                     (((UINT32)1)<<16)
-#define TPM_DELEGATE_DisableOwnerClear              (((UINT32)1)<<15)
-#define TPM_DELEGATE_NV_DefineSpace                 (((UINT32)1)<<14)
-#define TPM_DELEGATE_OwnerSetDisable                (((UINT32)1)<<13)
-#define TPM_DELEGATE_SetCapability                  (((UINT32)1)<<12)
-#define TPM_DELEGATE_MakeIdentity                   (((UINT32)1)<<11)
-#define TPM_DELEGATE_ActivateIdentity               (((UINT32)1)<<10)
-#define TPM_DELEGATE_OwnerReadPubek                 (((UINT32)1)<<9)
-#define TPM_DELEGATE_DisablePubekRead               (((UINT32)1)<<8)
-#define TPM_DELEGATE_SetRedirection                 (((UINT32)1)<<7)
-#define TPM_DELEGATE_FieldUpgrade                   (((UINT32)1)<<6)
-#define TPM_DELEGATE_Delegate_UpdateVerification    (((UINT32)1)<<5)
-#define TPM_DELEGATE_CreateCounter                  (((UINT32)1)<<4)
-#define TPM_DELEGATE_ReleaseCounterOwner            (((UINT32)1)<<3)
-#define TPM_DELEGATE_DelegateManage                 (((UINT32)1)<<2)
-#define TPM_DELEGATE_Delegate_CreateOwnerDelegation (((UINT32)1)<<1)
-#define TPM_DELEGATE_DAA_Sign                       (((UINT32)1)<<0)
-
-//-------------------------------------------------------------------
-// Part 2, section 20.3: Key Permissions Settings for per1 bits
-#define TPM_KEY_DELEGATE_CMK_ConvertMigration       (((UINT32)1)<<28)
-#define TPM_KEY_DELEGATE_TickStampBlob              (((UINT32)1)<<27)
-#define TPM_KEY_DELEGATE_ChangeAuthAsymStart        (((UINT32)1)<<26)
-#define TPM_KEY_DELEGATE_ChangeAuthAsymFinish       (((UINT32)1)<<25)
-#define TPM_KEY_DELEGATE_CMK_CreateKey              (((UINT32)1)<<24)
-#define TPM_KEY_DELEGATE_MigrateKey                 (((UINT32)1)<<23)
-#define TPM_KEY_DELEGATE_LoadKey2                   (((UINT32)1)<<22)
-#define TPM_KEY_DELEGATE_EstablishTransport         (((UINT32)1)<<21)
-#define TPM_KEY_DELEGATE_ReleaseTransportSigned     (((UINT32)1)<<20)
-#define TPM_KEY_DELEGATE_Quote2                     (((UINT32)1)<<19)
-#define TPM_KEY_DELEGATE_Sealx                      (((UINT32)1)<<18)
-#define TPM_KEY_DELEGATE_MakeIdentity               (((UINT32)1)<<17)
-#define TPM_KEY_DELEGATE_ActivateIdentity           (((UINT32)1)<<16)
-#define TPM_KEY_DELEGATE_GetAuditDigestSigned       (((UINT32)1)<<15)
-#define TPM_KEY_DELEGATE_Sign                       (((UINT32)1)<<14)
-#define TPM_KEY_DELEGATE_CertifyKey2                (((UINT32)1)<<13)
-#define TPM_KEY_DELEGATE_CertifyKey                 (((UINT32)1)<<12)
-#define TPM_KEY_DELEGATE_CreateWrapKey              (((UINT32)1)<<11)
-#define TPM_KEY_DELEGATE_CMK_CreateBlob             (((UINT32)1)<<10)
-#define TPM_KEY_DELEGATE_CreateMigrationBlob        (((UINT32)1)<<9)
-#define TPM_KEY_DELEGATE_ConvertMigrationBlob       (((UINT32)1)<<8)
-#define TPM_KEY_DELEGATE_CreateKeyDelegation        (((UINT32)1)<<7)
-#define TPM_KEY_DELEGATE_ChangeAuth                 (((UINT32)1)<<6)
-#define TPM_KEY_DELEGATE_GetPubKey                  (((UINT32)1)<<5)
-#define TPM_KEY_DELEGATE_UnBind                     (((UINT32)1)<<4)
-#define TPM_KEY_DELEGATE_Quote                      (((UINT32)1)<<3)
-#define TPM_KEY_DELEGATE_Unseal                     (((UINT32)1)<<2)
-#define TPM_KEY_DELEGATE_Seal                       (((UINT32)1)<<1)
-#define TPM_KEY_DELEGATE_LoadKey                    (((UINT32)1)<<0)
-
-typedef UINT32 TPM_FAMILY_VERIFICATION;
-
-typedef UINT32 TPM_FAMILY_ID;
-
-typedef UINT32 TPM_DELEGATE_INDEX;
-
-typedef UINT32 TPM_FAMILY_OPERATION;
-#define TPM_FAMILY_CREATE              ((UINT32)0x00000001)
-#define TPM_FAMILY_ENABLE              ((UINT32)0x00000002)
-#define TPM_FAMILY_ADMIN               ((UINT32)0x00000003)
-#define TPM_FAMILY_INVALIDATE          ((UINT32)0x00000004)
-
-typedef UINT32 TPM_FAMILY_FLAGS;
-#define TPM_FAMFLAG_DELEGATE_ADMIN_LOCK   (((UINT32)1)<<1)
-#define TPM_FAMFLAG_ENABLE                (((UINT32)1)<<0)
-
-typedef struct tdTPM_FAMILY_LABEL
-{
-    BYTE label;
-} TPM_FAMILY_LABEL;
-
-typedef struct tdTPM_FAMILY_TABLE_ENTRY
-{
-    TPM_STRUCTURE_TAG       tag;
-    TPM_FAMILY_LABEL        label;
-    TPM_FAMILY_ID           familyID;
-    TPM_FAMILY_VERIFICATION verificationCount;
-    TPM_FAMILY_FLAGS        flags;
-} TPM_FAMILY_TABLE_ENTRY;
-
-
-#define TPM_FAMILY_TABLE_ENTRY_MIN 8
-//typedef struct tdTPM_FAMILY_TABLE
-//{
-//    TPM_FAMILY_TABLE_ENTRY FamTableRow[TPM_NUM_FAMILY_TABLE_ENTRY_MIN];
-//} TPM_FAMILY_TABLE;
-
-
-typedef struct tdTPM_DELEGATE_LABEL
-{
-    BYTE label;
-} TPM_DELEGATE_LABEL;
-
-
-typedef UINT32 TPM_DELEGATE_TYPE;
-#define TPM_DEL_OWNER_BITS             ((UINT32)0x00000001)
-#define TPM_DEL_KEY_BITS               ((UINT32)0x00000002)
-
-typedef struct tdTPM_DELEGATIONS
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_DELEGATE_TYPE delegateType;
-    UINT32            per1;
-    UINT32            per2;
-} TPM_DELEGATIONS;
-
-typedef struct tdTPM_DELEGATE_PUBLIC
-{
-    TPM_STRUCTURE_TAG       tag;
-    TPM_DELEGATE_LABEL      label;
-    TPM_PCR_INFO_SHORT      pcrInfo;
-    TPM_DELEGATIONS         permissions;
-    TPM_FAMILY_ID           familyID;
-    TPM_FAMILY_VERIFICATION verificationCount;
-} TPM_DELEGATE_PUBLIC;
-
-typedef struct tdTPM_DELEGATE_TABLE_ROW
-{
-    TPM_STRUCTURE_TAG   tag;
-    TPM_DELEGATE_PUBLIC pub;
-    TPM_SECRET          authValue;
-} TPM_DELEGATE_TABLE_ROW;
-
-
-#define TPM_NUM_DELEGATE_TABLE_ENTRY_MIN 2
-//typedef struct tdTPM_DELEGATE_TABLE
-//{
-//    TPM_DELEGATE_TABLE_ROW delRow[TPM_NUM_DELEGATE_TABLE_ENTRY_MIN];
-//} TPM_DELEGATE_TABLE;
-
-typedef struct tdTPM_DELEGATE_SENSITIVE
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_SECRET        authValue;
-} TPM_DELEGATE_SENSITIVE;
-
-typedef struct tdTPM_DELEGATE_OWNER_BLOB
-{
-    TPM_STRUCTURE_TAG   tag;
-    TPM_DELEGATE_PUBLIC pub;
-    TPM_DIGEST          integrityDigest;
-    UINT32              additionalSize;
-    SIZEIS(additionalSize)
-        BYTE           *additionalArea;
-    UINT32              sensitiveSize;
-    SIZEIS(sensitiveSize)
-        BYTE           *sensitiveArea;
-} TPM_DELEGATE_OWNER_BLOB;
-
-typedef struct tdTPM_DELEGATE_KEY_BLOB
-{
-    TPM_STRUCTURE_TAG   tag;
-    TPM_DELEGATE_PUBLIC pub;
-    TPM_DIGEST          integrityDigest;
-    TPM_DIGEST          pubKeyDigest;
-    UINT32              additionalSize;
-    SIZEIS(additionalSize)
-        BYTE           *additionalArea;
-    UINT32              sensitiveSize;
-    SIZEIS(sensitiveSize)
-        BYTE           *sensitiveArea;
-} TPM_DELEGATE_KEY_BLOB;
-
-
-//-------------------------------------------------------------------
-// Part 2, section 21.1: TPM_CAPABILITY_AREA
-
-typedef UINT32 TPM_CAPABILITY_AREA;                         /* 1.1b */
-#define TPM_CAP_ORD                    ((UINT32)0x00000001) /* 1.1b */
-#define TPM_CAP_ALG                    ((UINT32)0x00000002) /* 1.1b */
-#define TPM_CAP_PID                    ((UINT32)0x00000003) /* 1.1b */
-#define TPM_CAP_FLAG                   ((UINT32)0x00000004) /* 1.1b */
-#define TPM_CAP_PROPERTY               ((UINT32)0x00000005) /* 1.1b */
-#define TPM_CAP_VERSION                ((UINT32)0x00000006) /* 1.1b */
-#define TPM_CAP_KEY_HANDLE             ((UINT32)0x00000007) /* 1.1b */
-#define TPM_CAP_CHECK_LOADED           ((UINT32)0x00000008) /* 1.1b */
-#define TPM_CAP_SYM_MODE               ((UINT32)0x00000009)
-#define TPM_CAP_KEY_STATUS             ((UINT32)0x0000000C)
-#define TPM_CAP_NV_LIST                ((UINT32)0x0000000D)
-#define TPM_CAP_MFR                    ((UINT32)0x00000010)
-#define TPM_CAP_NV_INDEX               ((UINT32)0x00000011)
-#define TPM_CAP_TRANS_ALG              ((UINT32)0x00000012)
-#define TPM_CAP_HANDLE                 ((UINT32)0x00000014)
-#define TPM_CAP_TRANS_ES               ((UINT32)0x00000015)
-#define TPM_CAP_AUTH_ENCRYPT           ((UINT32)0x00000017)
-#define TPM_CAP_SELECT_SIZE            ((UINT32)0x00000018)
-#define TPM_CAP_DA_LOGIC               ((UINT32)0x00000019)
-#define TPM_CAP_VERSION_VAL            ((UINT32)0x0000001A)
-
-// Part 2, section 21.1: Subcap values for CAP_FLAG
-#define TPM_CAP_FLAG_PERMANENT         ((UINT32)0x00000108)
-#define TPM_CAP_FLAG_VOLATILE          ((UINT32)0x00000109)
-
-//-------------------------------------------------------------------
-// Part 2, section 21.2: Subcap values for CAP_PROPERTY
-
-#define TPM_CAP_PROP_PCR               ((UINT32)0x00000101) /* 1.1b */
-#define TPM_CAP_PROP_DIR               ((UINT32)0x00000102) /* 1.1b */
-#define TPM_CAP_PROP_MANUFACTURER      ((UINT32)0x00000103) /* 1.1b */
-#define TPM_CAP_PROP_KEYS              ((UINT32)0x00000104)
-#define TPM_CAP_PROP_SLOTS             (TPM_CAP_PROP_KEYS)
-#define TPM_CAP_PROP_MIN_COUNTER       ((UINT32)0x00000107)
-#define TPM_CAP_PROP_AUTHSESS          ((UINT32)0x0000010A)
-#define TPM_CAP_PROP_TRANSSESS         ((UINT32)0x0000010B)
-#define TPM_CAP_PROP_COUNTERS          ((UINT32)0x0000010C)
-#define TPM_CAP_PROP_MAX_AUTHSESS      ((UINT32)0x0000010D)
-#define TPM_CAP_PROP_MAX_TRANSSESS     ((UINT32)0x0000010E)
-#define TPM_CAP_PROP_MAX_COUNTERS      ((UINT32)0x0000010F)
-#define TPM_CAP_PROP_MAX_KEYS          ((UINT32)0x00000110)
-#define TPM_CAP_PROP_OWNER             ((UINT32)0x00000111)
-#define TPM_CAP_PROP_CONTEXT           ((UINT32)0x00000112)
-#define TPM_CAP_PROP_MAX_CONTEXT       ((UINT32)0x00000113)
-#define TPM_CAP_PROP_FAMILYROWS        ((UINT32)0x00000114)
-#define TPM_CAP_PROP_TIS_TIMEOUT       ((UINT32)0x00000115)
-#define TPM_CAP_PROP_STARTUP_EFFECT    ((UINT32)0x00000116)
-#define TPM_CAP_PROP_DELEGATE_ROW      ((UINT32)0x00000117)
-#define TPM_CAP_PROP_MAX_DAASESS       ((UINT32)0x00000119)
-#define TPM_CAP_PROP_DAA_MAX           TPM_CAP_PROP_MAX_DAASESS
-#define TPM_CAP_PROP_DAASESS           ((UINT32)0x0000011A)
-#define TPM_CAP_PROP_SESSION_DAA       TPM_CAP_PROP_DAASESS
-#define TPM_CAP_PROP_CONTEXT_DIST      ((UINT32)0x0000011B)
-#define TPM_CAP_PROP_DAA_INTERRUPT     ((UINT32)0x0000011C)
-#define TPM_CAP_PROP_SESSIONS          ((UINT32)0x0000011D)
-#define TPM_CAP_PROP_MAX_SESSIONS      ((UINT32)0x0000011E)
-#define TPM_CAP_PROP_CMK_RESTRICTION   ((UINT32)0x0000011F)
-#define TPM_CAP_PROP_DURATION          ((UINT32)0x00000120)
-#define TPM_CAP_PROP_ACTIVE_COUNTER    ((UINT32)0x00000122)
-#define TPM_CAP_PROP_NV_AVAILABLE      ((UINT32)0x00000123)
-#define TPM_CAP_PROP_INPUT_BUFFER      ((UINT32)0x00000124)
-
-
-// Part 2, section 21.4: SetCapability Values
-#define TPM_SET_PERM_FLAGS             ((UINT32)0x00000001)
-#define TPM_SET_PERM_DATA              ((UINT32)0x00000002)
-#define TPM_SET_STCLEAR_FLAGS          ((UINT32)0x00000003)
-#define TPM_SET_STCLEAR_DATA           ((UINT32)0x00000004)
-#define TPM_SET_STANY_FLAGS            ((UINT32)0x00000005)
-#define TPM_SET_STANY_DATA             ((UINT32)0x00000006)
-#define TPM_SET_VENDOR                 ((UINT32)0x00000007)
-
-
-// Part 2, section 21.6: TPM_CAP_VERSION_INFO
-typedef struct tdTPM_CAP_VERSION_INFO
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_VERSION       version;
-    UINT16            specLevel;
-    BYTE              errataRev;
-    BYTE              tpmVendorID[4];
-    UINT16            vendorSpecificSize;
-    SIZEIS(vendorSpecificSize)
-        BYTE         *vendorSpecific;
-} TPM_CAP_VERSION_INFO;
-
-
-// Part 2, section 21.9: TPM_DA_STATE
-// out of order to make it available for structure definitions
-typedef BYTE TPM_DA_STATE;
-#define TPM_DA_STATE_INACTIVE          (0x00)
-#define TPM_DA_STATE_ACTIVE            (0x01)
-
-// Part 2, section 21.10: TPM_DA_ACTION_TYPE
-typedef struct tdTPM_DA_ACTION_TYPE
-{
-    TPM_STRUCTURE_TAG tag;
-    UINT32            actions;
-} TPM_DA_ACTION_TYPE;
-#define TPM_DA_ACTION_TIMEOUT          ((UINT32)0x00000001)
-#define TPM_DA_ACTION_DISABLE          ((UINT32)0x00000002)
-#define TPM_DA_ACTION_DEACTIVATE       ((UINT32)0x00000004)
-#define TPM_DA_ACTION_FAILURE_MODE     ((UINT32)0x00000008)
-
-// Part 2, section 21.7: TPM_DA_INFO
-typedef struct tdTPM_DA_INFO
-{
-    TPM_STRUCTURE_TAG  tag;
-    TPM_DA_STATE       state;
-    UINT16             currentCount;
-    UINT16             threshholdCount;
-    TPM_DA_ACTION_TYPE actionAtThreshold;
-    UINT32             actionDependValue;
-    UINT32             vendorDataSize;
-    SIZEIS(vendorDataSize)
-        BYTE          *vendorData;
-} TPM_DA_INFO;
-
-// Part 2, section 21.8: TPM_DA_INFO_LIMITED
-typedef struct tdTPM_DA_INFO_LIMITED
-{
-    TPM_STRUCTURE_TAG  tag;
-    TPM_DA_STATE       state;
-    TPM_DA_ACTION_TYPE actionAtThreshold;
-    UINT32             vendorDataSize;
-    SIZEIS(vendorDataSize)
-        BYTE          *vendorData;
-} TPM_DA_INFO_LIMITED;
-
-
-
-//-------------------------------------------------------------------
-// Part 2, section 22: DAA Structures
-
-#define TPM_DAA_SIZE_r0                (43)
-#define TPM_DAA_SIZE_r1                (43)
-#define TPM_DAA_SIZE_r2                (128)
-#define TPM_DAA_SIZE_r3                (168)
-#define TPM_DAA_SIZE_r4                (219)
-#define TPM_DAA_SIZE_NT                (20)
-#define TPM_DAA_SIZE_v0                (128)
-#define TPM_DAA_SIZE_v1                (192)
-#define TPM_DAA_SIZE_NE                (256)
-#define TPM_DAA_SIZE_w                 (256)
-#define TPM_DAA_SIZE_issuerModulus     (256)
-#define TPM_DAA_power0                 (104)
-#define TPM_DAA_power1                 (1024)
-
-typedef struct tdTPM_DAA_ISSUER
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_DIGEST        DAA_digest_R0;
-    TPM_DIGEST        DAA_digest_R1;
-    TPM_DIGEST        DAA_digest_S0;
-    TPM_DIGEST        DAA_digest_S1;
-    TPM_DIGEST        DAA_digest_n;
-    TPM_DIGEST        DAA_digest_gamma;
-    BYTE              DAA_generic_q[26];
-} TPM_DAA_ISSUER;
-
-
-typedef struct tdTPM_DAA_TPM
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_DIGEST        DAA_digestIssuer;
-    TPM_DIGEST        DAA_digest_v0;
-    TPM_DIGEST        DAA_digest_v1;
-    TPM_DIGEST        DAA_rekey;
-    UINT32            DAA_count;
-} TPM_DAA_TPM;
-
-typedef struct tdTPM_DAA_CONTEXT
-{
-    TPM_STRUCTURE_TAG    tag;
-    TPM_DIGEST           DAA_digestContext;
-    TPM_DIGEST           DAA_digest;
-    TPM_DAA_CONTEXT_SEED DAA_contextSeed;
-    BYTE                 DAA_scratch[256];
-    BYTE                 DAA_stage;
-} TPM_DAA_CONTEXT;
-
-typedef struct tdTPM_DAA_JOINDATA
-{
-    BYTE       DAA_join_u0[128];
-    BYTE       DAA_join_u1[138];
-    TPM_DIGEST DAA_digest_n0;
-} TPM_DAA_JOINDATA;
-
-typedef struct tdTPM_DAA_BLOB
-{
-    TPM_STRUCTURE_TAG tag;
-    TPM_RESOURCE_TYPE resourceType;
-    BYTE              label[16];
-    TPM_DIGEST        blobIntegrity;
-    UINT32            additionalSize;
-    SIZEIS(additionalSize)
-        BYTE         *additionalData;
-    UINT32            sensitiveSize;
-    SIZEIS(sensitiveSize)
-        BYTE         *sensitiveData;
-} TPM_DAA_BLOB;
-
-typedef struct tdTPM_DAA_SENSITIVE
-{
-    TPM_STRUCTURE_TAG tag;
-    UINT32            internalSize;
-    SIZEIS(internalSize)
-        BYTE         *internalData;
-} TPM_DAA_SENSITIVE;
-
-
-
-//-------------------------------------------------------------------
-// Part 2, section 23: Redirection
-
-// This section of the TPM spec defines exactly one value but does not
-// give it a name. The definition of TPM_SetRedirection in Part3
-// refers to exactly one name but does not give its value. We join
-// them here.
-#define TPM_REDIR_GPIO              (0x00000001)
-
-
-//-------------------------------------------------------------------
-// Part 2, section 24.6: TPM_SYM_MODE
-//    Deprecated by TPM 1.2 spec
-
-typedef UINT32 TPM_SYM_MODE;
-#define TPM_SYM_MODE_ECB            (0x00000001)
-#define TPM_SYM_MODE_CBC            (0x00000002)
-#define TPM_SYM_MODE_CFB            (0x00000003)
-
-#endif // __TPM_H__
-
+/*++
+ * 
+ * TPM structures extracted from the TPM specification 1.2, 
+ * Part 2 (Structures), rev 85.
+ *
+ * Errata:
+ *
+ * *) The individual bits of TPM_STARTUP_EFFECTS were not given names in
+ * the TPM spec so they are not defined in tpm.h.
+ * 
+ * *) A few typedefs not present in the TPM 1.2 specification have been
+ * added. This was generally done when the TPM 1.2 spec defined a set of
+ * related values (either bitmasks or enumeration values) but did not
+ * define an associated type to hold these values. The typedefs have been
+ * added and structure fields that were to hold those values have been
+ * switched from generic UINT* types to the more specific types. This was
+ * done to highlight exactly where those #defined values were to be used.
+ * The types that have been added are:
+ *   TPM_NV_PER_ATTRIBUTES
+ *   TPM_DELEGATE_TYPE
+ *
+ * *) The layout of bitfields within a structure are compiler-dependent
+ * and the use of structure bitfields has been avoided where possible. In
+ * cases where a value is a collection of independent bits the type is
+ * given a name (typedeffed to UINT16 or UINT32 as appropriate) and masks
+ * are #defined to access the individual bits. This is not possible for
+ * TPM_VERSION_BYTE because the fields are 4-bit values. A best attempt
+ * has been made to make this compiler independent but it has only been
+ * checked on GCC and Visual C++ on little-endian machines.
+ * 
+ * *) The TPM_DELEGATIONS per1 and per2 fields field are a bitmask but
+ * are defined as a UINT32 because the bitfields have different meaning
+ * based on the type of delegation blob.
+ * 
+ * *) The definitions of TPM_PERMANENT_DATA, TPM_STCLEAR_DATA,
+ * TPM_STANY_DATA, and TPM_DELEGATE_TABLE_ROW are commented out. These
+ * structures are internal to the TPM and are not directly accessible by
+ * external software so this should not be a problem.
+ * 
+ * *) The definitions of TPM_FAMILY_TABLE and TPM_DELEGATE_TABLE are
+ * commented out because they are variable length arrays internal to the
+ * TPM. As above they are not directly accessible by external software
+ * so this should not be a problem.
+ */
+
+#ifndef __TPM_H__
+#define __TPM_H__
+
+#ifdef __midl
+#define SIZEIS(x)  [size_is(x)]
+#else
+#define SIZEIS(x)
+#endif
+
+#include <tss/platform.h>
+
+//-------------------------------------------------------------------
+// Part 2, section 2.1: Basic data types
+typedef BYTE   TPM_BOOL;
+#ifndef FALSE
+#define FALSE  0x00
+#define TRUE   0x01
+#endif /* ifndef FALSE */
+
+//-------------------------------------------------------------------
+// Part 2, section 2.3: Helper Redefinitions
+//   Many of the helper redefinitions appear later in this file
+//   so that they are declared next to the list of valid values
+//   they may hold.
+typedef BYTE TPM_LOCALITY_MODIFIER;
+typedef UINT32 TPM_COMMAND_CODE;                            /* 1.1b */
+typedef UINT32 TPM_COUNT_ID;
+typedef UINT32 TPM_REDIT_COMMAND;
+typedef UINT32 TPM_HANDLE;
+typedef UINT32 TPM_AUTHHANDLE;
+typedef UINT32 TPM_TRANSHANDLE;
+typedef UINT32 TPM_KEYHANDLE;
+typedef UINT32 TPM_DIRINDEX;
+typedef UINT32 TPM_PCRINDEX;
+typedef UINT32 TPM_RESULT;
+typedef UINT32 TPM_MODIFIER_INDICATOR;
+
+
+
+//-------------------------------------------------------------------
+// Part 2, section 2.2.4: Vendor Specific
+#define TPM_Vendor_Specific32  0x00000400
+#define TPM_Vendor_Specific8   0x80
+
+
+//-------------------------------------------------------------------
+// Part 2, section 3: Structure Tags
+typedef UINT16  TPM_STRUCTURE_TAG;
+#define TPM_TAG_CONTEXTBLOB            ((UINT16)0x0001)
+#define TPM_TAG_CONTEXT_SENSITIVE      ((UINT16)0x0002)
+#define TPM_TAG_CONTEXTPOINTER         ((UINT16)0x0003)
+#define TPM_TAG_CONTEXTLIST            ((UINT16)0x0004)
+#define TPM_TAG_SIGNINFO               ((UINT16)0x0005)
+#define TPM_TAG_PCR_INFO_LONG          ((UINT16)0x0006)
+#define TPM_TAG_PERSISTENT_FLAGS       ((UINT16)0x0007)
+#define TPM_TAG_VOLATILE_FLAGS         ((UINT16)0x0008)
+#define TPM_TAG_PERSISTENT_DATA        ((UINT16)0x0009)
+#define TPM_TAG_VOLATILE_DATA          ((UINT16)0x000a)
+#define TPM_TAG_SV_DATA                ((UINT16)0x000b)
+#define TPM_TAG_EK_BLOB                ((UINT16)0x000c)
+#define TPM_TAG_EK_BLOB_AUTH           ((UINT16)0x000d)
+#define TPM_TAG_COUNTER_VALUE          ((UINT16)0x000e)
+#define TPM_TAG_TRANSPORT_INTERNAL     ((UINT16)0x000f)
+#define TPM_TAG_TRANSPORT_LOG_IN       ((UINT16)0x0010)
+#define TPM_TAG_TRANSPORT_LOG_OUT      ((UINT16)0x0011)
+#define TPM_TAG_AUDIT_EVENT_IN         ((UINT16)0x0012)
+#define TPM_TAG_AUDIT_EVENT_OUT        ((UINT16)0x0013)
+#define TPM_TAG_CURRENT_TICKS          ((UINT16)0x0014)
+#define TPM_TAG_KEY                    ((UINT16)0x0015)
+#define TPM_TAG_STORED_DATA12          ((UINT16)0x0016)
+#define TPM_TAG_NV_ATTRIBUTES          ((UINT16)0x0017)
+#define TPM_TAG_NV_DATA_PUBLIC         ((UINT16)0x0018)
+#define TPM_TAG_NV_DATA_SENSITIVE      ((UINT16)0x0019)
+#define TPM_TAG_DELEGATIONS            ((UINT16)0x001a)
+#define TPM_TAG_DELEGATE_PUBLIC        ((UINT16)0x001b)
+#define TPM_TAG_DELEGATE_TABLE_ROW     ((UINT16)0x001c)
+#define TPM_TAG_TRANSPORT_AUTH         ((UINT16)0x001d)
+#define TPM_TAG_TRANSPORT_PUBLIC       ((UINT16)0x001e)
+#define TPM_TAG_PERMANENT_FLAGS        ((UINT16)0x001f)
+#define TPM_TAG_STCLEAR_FLAGS          ((UINT16)0x0020)
+#define TPM_TAG_STANY_FLAGS            ((UINT16)0x0021)
+#define TPM_TAG_PERMANENT_DATA         ((UINT16)0x0022)
+#define TPM_TAG_STCLEAR_DATA           ((UINT16)0x0023)
+#define TPM_TAG_STANY_DATA             ((UINT16)0x0024)
+#define TPM_TAG_FAMILY_TABLE_ENTRY     ((UINT16)0x0025)
+#define TPM_TAG_DELEGATE_SENSITIVE     ((UINT16)0x0026)
+#define TPM_TAG_DELG_KEY_BLOB          ((UINT16)0x0027)
+#define TPM_TAG_KEY12                  ((UINT16)0x0028)
+#define TPM_TAG_CERTIFY_INFO2          ((UINT16)0x0029)
+#define TPM_TAG_DELEGATE_OWNER_BLOB    ((UINT16)0x002a)
+#define TPM_TAG_EK_BLOB_ACTIVATE       ((UINT16)0x002b)
+#define TPM_TAG_DAA_BLOB               ((UINT16)0x002c)
+#define TPM_TAG_DAA_CONTEXT            ((UINT16)0x002d)
+#define TPM_TAG_DAA_ENFORCE            ((UINT16)0x002e)
+#define TPM_TAG_DAA_ISSUER             ((UINT16)0x002f)
+#define TPM_TAG_CAP_VERSION_INFO       ((UINT16)0x0030)
+#define TPM_TAG_DAA_SENSITIVE          ((UINT16)0x0031)
+#define TPM_TAG_DAA_TPM                ((UINT16)0x0032)
+#define TPM_TAG_CMK_MIGAUTH            ((UINT16)0x0033)
+#define TPM_TAG_CMK_SIGTICKET          ((UINT16)0x0034)
+#define TPM_TAG_CMK_MA_APPROVAL        ((UINT16)0x0035)
+#define TPM_TAG_QUOTE_INFO2            ((UINT16)0x0036)
+#define TPM_TAG_DA_INFO                ((UINT16)0x0037)
+#define TPM_TAG_DA_INFO_LIMITED        ((UINT16)0x0038)
+#define TPM_TAG_DA_ACTION_TYPE         ((UINT16)0x0039)
+
+
+//-------------------------------------------------------------------
+// Part 2, section 4: Types
+typedef UINT32 TPM_RESOURCE_TYPE;
+#define TPM_RT_KEY                     ((UINT32)0x00000001)
+#define TPM_RT_AUTH                    ((UINT32)0x00000002)
+#define TPM_RT_HASH                    ((UINT32)0x00000003)
+#define TPM_RT_TRANS                   ((UINT32)0x00000004)
+#define TPM_RT_CONTEXT                 ((UINT32)0x00000005)
+#define TPM_RT_COUNTER                 ((UINT32)0x00000006)
+#define TPM_RT_DELEGATE                ((UINT32)0x00000007)
+#define TPM_RT_DAA_TPM                 ((UINT32)0x00000008)
+#define TPM_RT_DAA_V0                  ((UINT32)0x00000009)
+#define TPM_RT_DAA_V1                  ((UINT32)0x0000000a)
+
+
+typedef BYTE TPM_PAYLOAD_TYPE;                              /* 1.1b */
+#define TPM_PT_ASYM                    ((BYTE)0x01)         /* 1.1b */
+#define TPM_PT_BIND                    ((BYTE)0x02)         /* 1.1b */
+#define TPM_PT_MIGRATE                 ((BYTE)0x03)         /* 1.1b */
+#define TPM_PT_MAINT                   ((BYTE)0x04)         /* 1.1b */
+#define TPM_PT_SEAL                    ((BYTE)0x05)         /* 1.1b */
+#define TPM_PT_MIGRATE_RESTRICTED      ((BYTE)0x06)
+#define TPM_PT_MIGRATE_EXTERNAL        ((BYTE)0x07)
+#define TPM_PT_CMK_MIGRATE             ((BYTE)0x08)
+
+
+typedef UINT16 TPM_ENTITY_TYPE;                             /* 1.1b */
+#define TPM_ET_KEYHANDLE               ((UINT16)0x0001)     /* 1.1b */
+#define TPM_ET_OWNER                   ((UINT16)0x0002)     /* 1.1b */
+#define TPM_ET_DATA                    ((UINT16)0x0003)     /* 1.1b */
+#define TPM_ET_SRK                     ((UINT16)0x0004)     /* 1.1b */
+#define TPM_ET_KEY                     ((UINT16)0x0005)     /* 1.1b */
+#define TPM_ET_REVOKE                  ((UINT16)0x0006)
+#define TPM_ET_DEL_OWNER_BLOB          ((UINT16)0x0007)
+#define TPM_ET_DEL_ROW                 ((UINT16)0x0008)
+#define TPM_ET_DEL_KEY_BLOB            ((UINT16)0x0009)
+#define TPM_ET_COUNTER                 ((UINT16)0x000a)
+#define TPM_ET_NV                      ((UINT16)0x000b)
+#define TPM_ET_OPERATOR                ((UINT16)0x000c)
+#define TPM_ET_RESERVED_HANDLE         ((UINT16)0x0040)
+
+/* The following values may be ORed into the MSB of the TPM_ENTITY_TYPE
+ * to indicate particular encryption scheme
+ */
+#define TPM_ET_XOR                     ((BYTE)0x00)
+#define TPM_ET_AES                     ((BYTE)0x06)
+
+typedef UINT32 TPM_KEY_HANDLE;                              /* 1.1b */
+#define TPM_KH_SRK                     ((UINT32)0x40000000)
+#define TPM_KH_OWNER                   ((UINT32)0x40000001)
+#define TPM_KH_REVOKE                  ((UINT32)0x40000002)
+#define TPM_KH_TRANSPORT               ((UINT32)0x40000003)
+#define TPM_KH_OPERATOR                ((UINT32)0x40000004)
+#define TPM_KH_ADMIN                   ((UINT32)0x40000005)
+#define TPM_KH_EK                      ((UINT32)0x40000006)
+/* 1.1b used different names, but the same values */
+#define TPM_KEYHND_SRK                 (TPM_KH_SRK)        /* 1.1b */
+#define TPM_KEYHND_OWNER               (TPM_KH_OWNER)      /* 1.1b */
+
+
+typedef UINT16 TPM_STARTUP_TYPE;                            /* 1.1b */
+#define TPM_ST_CLEAR                   ((UINT16)0x0001)     /* 1.1b */
+#define TPM_ST_STATE                   ((UINT16)0x0002)     /* 1.1b */
+#define TPM_ST_DEACTIVATED             ((UINT16)0x0003)     /* 1.1b */
+
+
+//typedef UINT32 TPM_STARTUP_EFFECTS;
+// 32-bit mask, see spec for meaning. Names not currently defined.
+// bits 0-8 have meaning
+
+typedef UINT16 TPM_PROTOCOL_ID;                             /* 1.1b */
+#define TPM_PID_OIAP                   ((UINT16)0x0001)     /* 1.1b */
+#define TPM_PID_OSAP                   ((UINT16)0x0002)     /* 1.1b */
+#define TPM_PID_ADIP                   ((UINT16)0x0003)     /* 1.1b */
+#define TPM_PID_ADCP                   ((UINT16)0x0004)     /* 1.1b */
+#define TPM_PID_OWNER                  ((UINT16)0x0005)     /* 1.1b */
+#define TPM_PID_DSAP                   ((UINT16)0x0006)
+#define TPM_PID_TRANSPORT              ((UINT16)0x0007)
+
+
+// Note in 1.2 rev 104, DES and 3DES are eliminated
+typedef UINT32 TPM_ALGORITHM_ID;                            /* 1.1b */
+#define TPM_ALG_RSA                    ((UINT32)0x00000001) /* 1.1b */
+#define TPM_ALG_DES                    ((UINT32)0x00000002) /* 1.1b */
+#define TPM_ALG_3DES                   ((UINT32)0x00000003) /* 1.1b */
+#define TPM_ALG_SHA                    ((UINT32)0x00000004) /* 1.1b */
+#define TPM_ALG_HMAC                   ((UINT32)0x00000005) /* 1.1b */
+#define TPM_ALG_AES                    ((UINT32)0x00000006) /* 1.1b */
+#define TPM_ALG_AES128                 (TPM_ALG_AES)
+#define TPM_ALG_MGF1                   ((UINT32)0x00000007)
+#define TPM_ALG_AES192                 ((UINT32)0x00000008)
+#define TPM_ALG_AES256                 ((UINT32)0x00000009)
+#define TPM_ALG_XOR                    ((UINT32)0x0000000a)
+
+
+typedef UINT16 TPM_PHYSICAL_PRESENCE;                        /* 1.1b */
+#define TPM_PHYSICAL_PRESENCE_LOCK          ((UINT16)0x0004) /* 1.1b */
+#define TPM_PHYSICAL_PRESENCE_PRESENT       ((UINT16)0x0008) /* 1.1b */
+#define TPM_PHYSICAL_PRESENCE_NOTPRESENT    ((UINT16)0x0010) /* 1.1b */
+#define TPM_PHYSICAL_PRESENCE_CMD_ENABLE    ((UINT16)0x0020) /* 1.1b */
+#define TPM_PHYSICAL_PRESENCE_HW_ENABLE     ((UINT16)0x0040) /* 1.1b */
+#define TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK ((UINT16)0x0080) /* 1.1b */
+#define TPM_PHYSICAL_PRESENCE_CMD_DISABLE   ((UINT16)0x0100)
+#define TPM_PHYSICAL_PRESENCE_HW_DISABLE    ((UINT16)0x0200)
+
+
+typedef UINT16 TPM_MIGRATE_SCHEME;                          /* 1.1b */
+#define TPM_MS_MIGRATE                   ((UINT16)0x0001)   /* 1.1b */
+#define TPM_MS_REWRAP                    ((UINT16)0x0002)   /* 1.1b */
+#define TPM_MS_MAINT                     ((UINT16)0x0003)   /* 1.1b */
+#define TPM_MS_RESTRICT_MIGRATE          ((UINT16)0x0004)
+#define TPM_MS_RESTRICT_APPROVE_DOUBLE   ((UINT16)0x0005)
+
+
+typedef UINT16 TPM_EK_TYPE;
+#define TPM_EK_TYPE_ACTIVATE           ((UINT16)0x0001)
+#define TPM_EK_TYPE_AUTH               ((UINT16)0x0002)
+
+
+typedef UINT16 TPM_PLATFORM_SPECIFIC;
+#define TPM_PS_PC_11                   ((UINT16)0x0001)
+#define TPM_PS_PC_12                   ((UINT16)0x0002)
+#define TPM_PS_PDA_12                  ((UINT16)0x0003)
+#define TPM_PS_Server_12               ((UINT16)0x0004)
+#define TPM_PS_Mobile_12               ((UINT16)0x0005)
+
+//-------------------------------------------------------------------
+// Part 2, section 5: Basic Structures
+
+typedef struct tdTPM_STRUCT_VER
+{
+    BYTE   major;
+    BYTE   minor;
+    BYTE   revMajor;
+    BYTE   revMinor;
+} TPM_STRUCT_VER;
+
+typedef struct tdTPM_VERSION_BYTE
+{
+    // This needs to be made compiler-independent.
+    int leastSigVer : 4; // least significant 4 bits
+    int mostSigVer  : 4; // most significant 4 bits
+} TPM_VERSION_BYTE;
+
+typedef struct tdTPM_VERSION
+{
+    BYTE   major;      // Should really be a TPM_VERSION_BYTE
+    BYTE   minor;      // Should really be a TPM_VERSION_BYTE
+    BYTE   revMajor;
+    BYTE   revMinor;
+} TPM_VERSION;
+
+
+// Put this in the right place:
+// byte size definition for 160 bit SHA1 hash value
+#define TPM_SHA1_160_HASH_LEN    0x14
+#define TPM_SHA1BASED_NONCE_LEN  TPM_SHA1_160_HASH_LEN
+
+typedef struct tdTPM_DIGEST
+{
+    BYTE  digest[TPM_SHA1_160_HASH_LEN];
+} TPM_DIGEST;
+
+typedef TPM_DIGEST TPM_CHOSENID_HASH;
+typedef TPM_DIGEST TPM_COMPOSITE_HASH;
+typedef TPM_DIGEST TPM_DIRVALUE;
+typedef TPM_DIGEST TPM_HMAC;
+typedef TPM_DIGEST TPM_PCRVALUE;
+typedef TPM_DIGEST TPM_AUDITDIGEST;
+
+typedef struct tdTPM_NONCE                                  /* 1.1b */
+{
+    BYTE  nonce[TPM_SHA1BASED_NONCE_LEN];
+} TPM_NONCE;
+
+typedef TPM_NONCE TPM_DAA_TPM_SEED;
+typedef TPM_NONCE TPM_DAA_CONTEXT_SEED;
+
+typedef struct tdTPM_AUTHDATA                               /* 1.1b */
+{
+    BYTE  authdata[TPM_SHA1_160_HASH_LEN];
+} TPM_AUTHDATA;
+
+typedef TPM_AUTHDATA TPM_SECRET;
+typedef TPM_AUTHDATA TPM_ENCAUTH;
+
+
+typedef struct tdTPM_KEY_HANDLE_LIST                        /* 1.1b */
+{
+    UINT16              loaded;
+    SIZEIS(loaded)
+        TPM_KEY_HANDLE *handle;
+} TPM_KEY_HANDLE_LIST;
+
+
+//-------------------------------------------------------------------
+// Part 2, section 5.8: Key usage values
+
+typedef UINT16 TPM_KEY_USAGE;                               /* 1.1b */
+#define TPM_KEY_SIGNING                ((UINT16)0x0010)     /* 1.1b */
+#define TPM_KEY_STORAGE                ((UINT16)0x0011)     /* 1.1b */
+#define TPM_KEY_IDENTITY               ((UINT16)0x0012)     /* 1.1b */
+#define TPM_KEY_AUTHCHANGE             ((UINT16)0x0013)     /* 1.1b */
+#define TPM_KEY_BIND                   ((UINT16)0x0014)     /* 1.1b */
+#define TPM_KEY_LEGACY                 ((UINT16)0x0015)     /* 1.1b */
+#define TPM_KEY_MIGRATE                ((UINT16)0x0016)
+
+typedef UINT16 TPM_SIG_SCHEME;                              /* 1.1b */
+#define TPM_SS_NONE                    ((UINT16)0x0001)     /* 1.1b */
+#define TPM_SS_RSASSAPKCS1v15_SHA1     ((UINT16)0x0002)     /* 1.1b */
+#define TPM_SS_RSASSAPKCS1v15_DER      ((UINT16)0x0003)     /* 1.1b */
+#define TPM_SS_RSASSAPKCS1v15_INFO     ((UINT16)0x0004)
+
+typedef UINT16 TPM_ENC_SCHEME;                              /* 1.1b */
+#define TPM_ES_NONE                    ((UINT16)0x0001)     /* 1.1b */
+#define TPM_ES_RSAESPKCSv15            ((UINT16)0x0002)     /* 1.1b */
+#define TPM_ES_RSAESOAEP_SHA1_MGF1     ((UINT16)0x0003)     /* 1.1b */
+#define TPM_ES_SYM_CNT                 ((UINT16)0x0004)
+#define TPM_ES_SYM_CTR                 TPM_ES_SYM_CNT
+#define TPM_ES_SYM_OFB                 ((UINT16)0x0005)
+#define TPM_ES_SYM_CBC_PKCS5PAD        ((UINT16)0x00ff)
+
+//-------------------------------------------------------------------
+// Part 2, section 5.9: TPM_AUTH_DATA_USAGE values
+
+typedef BYTE TPM_AUTH_DATA_USAGE;                           /* 1.1b */
+#define TPM_AUTH_NEVER                 ((BYTE)0x00)         /* 1.1b */
+#define TPM_AUTH_ALWAYS                ((BYTE)0x01)         /* 1.1b */
+#define TPM_AUTH_PRIV_USE_ONLY         ((BYTE)0x11)
+
+
+//-------------------------------------------------------------------
+// Part 2, section 5.10: TPM_KEY_FLAGS flags
+
+typedef UINT32 TPM_KEY_FLAGS;                               /* 1.1b */
+#define TPM_REDIRECTION                ((UINT32)0x00000001) /* 1.1b */
+#define TPM_MIGRATABLE                 ((UINT32)0x00000002) /* 1.1b */
+#define TPM_VOLATILE                   ((UINT32)0x00000004) /* 1.1b */
+#define TPM_PCRIGNOREDONREAD           ((UINT32)0x00000008)
+#define TPM_MIGRATEAUTHORITY           ((UINT32)0x00000010)
+
+
+//-------------------------------------------------------------------
+// Part 2, section 5.11: TPM_CHANGEAUTH_VALIDATE
+
+typedef struct tdTPM_CHANGEAUTH_VALIDATE
+{
+    TPM_SECRET newAuthSecret;
+    TPM_NONCE  n1;
+} TPM_CHANGEAUTH_VALIDATE;
+
+//-------------------------------------------------------------------
+// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH
+// declared after section 10 to catch declaration of TPM_PUBKEY 
+
+//-------------------------------------------------------------------
+// Part 2, section 5.13: TPM_COUNTER_VALUE;
+
+typedef UINT32 TPM_ACTUAL_COUNT;
+typedef struct tdTPM_COUNTER_VALUE
+{
+    TPM_STRUCTURE_TAG tag;
+    BYTE              label[4];
+    TPM_ACTUAL_COUNT  counter;
+} TPM_COUNTER_VALUE;
+
+//-------------------------------------------------------------------
+// Part 2, section 5.14: TPM_SIGN_INFO structure
+
+typedef struct tdTPM_SIGN_INFO
+{
+    TPM_STRUCTURE_TAG tag;
+    BYTE              fixed[4];
+    TPM_NONCE         replay;
+    UINT32            dataLen;
+    SIZEIS(dataLen)
+        BYTE         *data;
+} TPM_SIGN_INFO;
+
+//-------------------------------------------------------------------
+// Part 2, section 5.15: TPM_MSA_COMPOSITE
+
+typedef struct tdTPM_MSA_COMPOSITE
+{
+    UINT32          MSAlist;
+    SIZEIS(MSAlist)
+        TPM_DIGEST *migAuthDigest;
+} TPM_MSA_COMPOSITE;
+
+//-------------------------------------------------------------------
+// Part 2, section 5.16: TPM_CMK_AUTH
+
+typedef struct tdTPM_CMK_AUTH
+{
+    TPM_DIGEST migrationAuthorityDigest;
+    TPM_DIGEST destinationKeyDigest;
+    TPM_DIGEST sourceKeyDigest;
+} TPM_CMK_AUTH;
+
+//-------------------------------------------------------------------
+// Part 2, section 5.17: TPM_CMK_DELEGATE
+
+typedef UINT32 TPM_CMK_DELEGATE;
+#define TPM_CMK_DELEGATE_SIGNING       (((UINT32)1)<<31)
+#define TPM_CMK_DELEGATE_STORAGE       (((UINT32)1)<<30)
+#define TPM_CMK_DELEGATE_BIND          (((UINT32)1)<<29)
+#define TPM_CMK_DELEGATE_LEGACY        (((UINT32)1)<<28)
+#define TPM_CMK_DELEGATE_MIGRATE       (((UINT32)1)<<27)
+
+//-------------------------------------------------------------------
+// Part 2, section 5.18: TPM_SELECT_SIZE
+
+typedef struct tdTPM_SELECT_SIZE
+{
+    BYTE   major;
+    BYTE   minor;
+    UINT16 reqSize;
+} TPM_SELECT_SIZE;
+
+//-------------------------------------------------------------------
+// Part 2, section 5.19: TPM_CMK_MIGAUTH
+
+typedef struct tdTPM_CMK_MIGAUTH
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_DIGEST        msaDigest;
+    TPM_DIGEST        pubKeyDigest;
+} TPM_CMK_MIGAUTH;
+
+//-------------------------------------------------------------------
+// Part 2, section 5.20: TPM_CMK_SIGTICKET
+
+typedef struct tdTPM_CMK_SIGTICKET
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_DIGEST        verKeyDigest;
+    TPM_DIGEST        signedData;
+} TPM_CMK_SIGTICKET;
+
+//-------------------------------------------------------------------
+// Part 2, section 5.21: TPM_CMK_MA_APPROVAL
+
+typedef struct tdTPM_CMK_MA_APPROVAL
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_DIGEST        migrationAuthorityDigest;
+} TPM_CMK_MA_APPROVAL;
+
+
+//-------------------------------------------------------------------
+// Part 2, section 6: Command Tags
+
+typedef UINT16 TPM_TAG;                                     /* 1.1b */
+#define TPM_TAG_RQU_COMMAND            ((UINT16)0x00c1)
+#define TPM_TAG_RQU_AUTH1_COMMAND      ((UINT16)0x00c2)
+#define TPM_TAG_RQU_AUTH2_COMMAND      ((UINT16)0x00c3)
+#define TPM_TAG_RSP_COMMAND            ((UINT16)0x00c4)
+#define TPM_TAG_RSP_AUTH1_COMMAND      ((UINT16)0x00c5)
+#define TPM_TAG_RSP_AUTH2_COMMAND      ((UINT16)0x00c6)
+
+
+//-------------------------------------------------------------------
+// Part 2, section 7.1: TPM_PERMANENT_FLAGS
+
+typedef struct tdTPM_PERMANENT_FLAGS
+{
+    TPM_STRUCTURE_TAG tag;
+    TSS_BOOL disable;
+    TSS_BOOL ownership;
+    TSS_BOOL deactivated;
+    TSS_BOOL readPubek;
+    TSS_BOOL disableOwnerClear;
+    TSS_BOOL allowMaintenance;
+    TSS_BOOL physicalPresenceLifetimeLock;
+    TSS_BOOL physicalPresenceHWEnable;
+    TSS_BOOL physicalPresenceCMDEnable;
+    TSS_BOOL CEKPUsed;
+    TSS_BOOL TPMpost;
+    TSS_BOOL TPMpostLock;
+    TSS_BOOL FIPS;
+    TSS_BOOL Operator;
+    TSS_BOOL enableRevokeEK;
+    TSS_BOOL nvLocked;
+    TSS_BOOL readSRKPub;
+    TSS_BOOL tpmEstablished;
+    TSS_BOOL maintenanceDone;
+    TSS_BOOL disableFullDALogicInfo;
+} TPM_PERMANENT_FLAGS;
+
+#define TPM_PF_DISABLE                      ((UINT32)0x00000001)
+#define TPM_PF_OWNERSHIP                    ((UINT32)0x00000002)
+#define TPM_PF_DEACTIVATED                  ((UINT32)0x00000003)
+#define TPM_PF_READPUBEK                    ((UINT32)0x00000004)
+#define TPM_PF_DISABLEOWNERCLEAR            ((UINT32)0x00000005)
+#define TPM_PF_ALLOWMAINTENANCE             ((UINT32)0x00000006)
+#define TPM_PF_PHYSICALPRESENCELIFETIMELOCK ((UINT32)0x00000007)
+#define TPM_PF_PHYSICALPRESENCEHWENABLE     ((UINT32)0x00000008)
+#define TPM_PF_PHYSICALPRESENCECMDENABLE    ((UINT32)0x00000009)
+#define TPM_PF_CEKPUSED                     ((UINT32)0x0000000A)
+#define TPM_PF_TPMPOST                      ((UINT32)0x0000000B)
+#define TPM_PF_TPMPOSTLOCK                  ((UINT32)0x0000000C)
+#define TPM_PF_FIPS                         ((UINT32)0x0000000D)
+#define TPM_PF_OPERATOR                     ((UINT32)0x0000000E)
+#define TPM_PF_ENABLEREVOKEEK               ((UINT32)0x0000000F)
+#define TPM_PF_NV_LOCKED                    ((UINT32)0x00000010)
+#define TPM_PF_READSRKPUB                   ((UINT32)0x00000011)
+#define TPM_PF_RESETESTABLISHMENTBIT        ((UINT32)0x00000012)
+#define TPM_PF_MAINTENANCEDONE              ((UINT32)0x00000013)
+#define TPM_PF_DISABLEFULLDALOGICINFO       ((UINT32)0x00000014)
+
+
+//-------------------------------------------------------------------
+// Part 2, section 7.2: TPM_STCLEAR_FLAGS
+
+typedef struct tdTPM_STCLEAR_FLAGS
+{
+    TPM_STRUCTURE_TAG tag;
+    TSS_BOOL          deactivated;
+    TSS_BOOL          disableForceClear;
+    TSS_BOOL          physicalPresence;
+    TSS_BOOL          physicalPresenceLock;
+    TSS_BOOL          bGlobalLock;
+} TPM_STCLEAR_FLAGS;
+
+#define TPM_SF_DEACTIVATED             ((UINT32)0x00000001)
+#define TPM_SF_DISABLEFORCECLEAR       ((UINT32)0x00000002)
+#define TPM_SF_PHYSICALPRESENCE        ((UINT32)0x00000003)
+#define TPM_SF_PHYSICALPRESENCELOCK    ((UINT32)0x00000004)
+#define TPM_SF_GLOBALLOCK              ((UINT32)0x00000005)
+
+
+//-------------------------------------------------------------------
+// Part 2, section 7.3: TPM_STANY_FLAGS
+
+typedef struct tdTPM_STANY_FLAGS
+{
+    TPM_STRUCTURE_TAG      tag;
+    TSS_BOOL               postInitialise;
+    TPM_MODIFIER_INDICATOR localityModifier;
+    TSS_BOOL               transportExclusive;
+    TSS_BOOL               TOSPresent;
+} TPM_STANY_FLAGS;
+
+#define TPM_AF_POSTINITIALIZE          ((UINT32)0x00000001)
+#define TPM_AF_LOCALITYMODIFIER        ((UINT32)0x00000002)
+#define TPM_AF_TRANSPORTEXCLUSIVE      ((UINT32)0x00000003)
+#define TPM_AF_TOSPRESENT              ((UINT32)0x00000004)
+
+
+//-------------------------------------------------------------------
+// Part 2, section 7.4: TPM_PERMANENT_DATA
+// available inside TPM only
+//
+//#define TPM_MIN_COUNTERS          4
+//#define TPM_NUM_PCR              16
+//#define TPM_MAX_NV_WRITE_NOOWNER 64
+//
+//typedef struct tdTPM_PERMANENT_DATA
+//{
+//    TPM_STRUCTURE_TAG  tag;
+//    BYTE               revMajor;
+//    BYTE               revMinor;
+//    TPM_NONCE          tpmProof;
+//    TPM_NONCE          ekReset;
+//    TPM_SECRET         ownerAuth;
+//    TPM_SECRET         operatorAuth;
+//    TPM_DIRVALUE       authDIR[1];
+//    TPM_PUBKEY         manuMaintPub;
+//    TPM_KEY            endorsementKey;
+//    TPM_KEY            srk;
+//    TPM_KEY            contextKey;
+//    TPM_KEY            delegateKey;
+//    TPM_COUNTER_VALUE  auditMonotonicCounter;
+//    TPM_COUNTER_VALUE  monitonicCounter[TPM_MIN_COUNTERS];
+//    TPM_PCR_ATTRIBUTES pcrAttrib[TPM_NUM_PCR];
+//    BYTE               ordinalAuditStatus[];
+//    BYTE              *rngState;
+//    TPM_FAMILY_TABLE   familyTable;
+//    TPM_DELEGATE_TABLE delegateTable;
+//    UINT32             maxNVBufSize;
+//    UINT32             lastFamilyID;
+//    UINT32             noOwnerNVWrite;
+//    TPM_CMK_DELEGATE   restrictDelegate;
+//    TPM_DAA_TPM_SEED   tpmDAASeed;
+//    TPM_NONCE          daaProof;
+//    TPM_NONCE          daaBlobKey;
+//} TPM_PERMANENT_DATA;
+
+
+//-------------------------------------------------------------------
+// Part 2, section 7.5: TPM_STCLEAR_DATA
+// available inside TPM only
+//
+//typedef struct tdTPM_STCLEAR_DATA
+//{
+//    TPM_STRUCTURE_TAG tag;
+//    TPM_NONCE         contextNonceKey;
+//    TPM_COUNT_ID      countID;
+//    UINT32            ownerReference;
+//    TPM_BOOL          disableResetLock;
+//    TPM_PCRVALUE      PCR[TPM_NUM_PCR];
+//    UINT32            deferredPhysicalPresence;
+//} TPM_STCLEAR_DATA;
+    
+
+
+//-------------------------------------------------------------------
+// Part 2, section 7.5: TPM_STANY_DATA
+// available inside TPM only
+//
+//typedef struct tdTPM_STANY_DATA
+//{
+//    TPM_STRUCTURE_TAG tag;
+//    TPM_NONCE         contextNonceSession;
+//    TPM_DIGEST        auditDigest;
+//    TPM_CURRENT_TICKS currentTicks;
+//    UINT32            contextCount;
+//    UINT32            contextList[TPM_MIN_SESSION_LIST];
+//    TPM_SESSION_DATA  sessions[TPM_MIN_SESSIONS];
+//    // The following appear in section 22.6 but not in 7.5
+//    TPM_DAA_ISSUER    DAA_issuerSettings;
+//    TPM_DAA_TPM       DAA_tpmSpecific;
+//    TPM_DAA_CONTEXT   DAA_session;
+//    TPM_DAA_JOINDATA  DAA_joinSession;
+//} TPM_STANY_DATA;
+    
+
+
+//-------------------------------------------------------------------
+// Part 2, section 8: PCR Structures
+
+typedef BYTE  TPM_LOCALITY_SELECTION;
+#define TPM_LOC_FOUR                   (((UINT32)1)<<4)
+#define TPM_LOC_THREE                  (((UINT32)1)<<3)
+#define TPM_LOC_TWO                    (((UINT32)1)<<2)
+#define TPM_LOC_ONE                    (((UINT32)1)<<1)
+#define TPM_LOC_ZERO                   (((UINT32)1)<<0)
+
+typedef struct tdTPM_PCR_SELECTION                          /* 1.1b */
+{ 
+    UINT16    sizeOfSelect;
+    SIZEIS(sizeOfSelect)
+        BYTE *pcrSelect;  
+} TPM_PCR_SELECTION;
+
+typedef struct tdTPM_PCR_COMPOSITE                          /* 1.1b */
+{ 
+    TPM_PCR_SELECTION select;
+    UINT32            valueSize;
+    SIZEIS(valueSize)
+        TPM_PCRVALUE *pcrValue; 
+} TPM_PCR_COMPOSITE;
+
+typedef struct tdTPM_PCR_INFO                               /* 1.1b */
+{
+    TPM_PCR_SELECTION  pcrSelection;
+    TPM_COMPOSITE_HASH digestAtRelease;
+    TPM_COMPOSITE_HASH digestAtCreation;
+}  TPM_PCR_INFO;
+
+typedef struct tdTPM_PCR_INFO_LONG
+{
+    TPM_STRUCTURE_TAG      tag;
+    TPM_LOCALITY_SELECTION localityAtCreation;
+    TPM_LOCALITY_SELECTION localityAtRelease;
+    TPM_PCR_SELECTION      creationPCRSelection;
+    TPM_PCR_SELECTION      releasePCRSelection;
+    TPM_COMPOSITE_HASH     digestAtCreation;
+    TPM_COMPOSITE_HASH     digestAtRelease;
+}  TPM_PCR_INFO_LONG;
+
+typedef struct tdTPM_PCR_INFO_SHORT
+{
+    TPM_PCR_SELECTION      pcrSelection;
+    TPM_LOCALITY_SELECTION localityAtRelease;
+    TPM_COMPOSITE_HASH     digestAtRelease;
+}  TPM_PCR_INFO_SHORT;
+
+typedef struct tdTPM_PCR_ATTRIBUTES
+{
+    BYTE                   pcrReset;
+    TPM_LOCALITY_SELECTION pcrExtendLocal;
+    TPM_LOCALITY_SELECTION pcrResetLocal;
+} TPM_PCR_ATTRIBUTES;
+
+
+
+//-------------------------------------------------------------------
+// Part 2, section 9:
+
+typedef struct tdTPM_STORED_DATA                            /* 1.1b */
+{
+    TPM_STRUCT_VER ver;
+    UINT32         sealInfoSize;
+    SIZEIS(sealInfoSize)
+        BYTE      *sealInfo;
+    UINT32         encDataSize;
+    SIZEIS(encDataSize)
+        BYTE      *encData;
+} TPM_STORED_DATA;
+
+typedef struct tdTPM_STORED_DATA12
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_ENTITY_TYPE   et;
+    UINT32            sealInfoSize;
+    SIZEIS(sealInfoSize)
+        BYTE         *sealInfo;
+    UINT32            encDataSize;
+    SIZEIS(encDataSize)
+        BYTE         *encData;
+} TPM_STORED_DATA12;
+
+typedef struct tdTPM_SEALED_DATA                            /* 1.1b */
+{ 
+    TPM_PAYLOAD_TYPE  payload;
+    TPM_SECRET        authData;
+    TPM_NONCE         tpmProof;
+    TPM_DIGEST        storedDigest;
+    UINT32            dataSize;
+    SIZEIS(dataSize)
+        BYTE         *data;
+} TPM_SEALED_DATA;
+
+typedef struct tdTPM_SYMMETRIC_KEY                          /* 1.1b */
+{
+    TPM_ALGORITHM_ID  algId;
+    TPM_ENC_SCHEME    encScheme;
+    UINT16            size;
+    SIZEIS(size)
+        BYTE         *data;
+} TPM_SYMMETRIC_KEY;
+
+typedef struct tdTPM_BOUND_DATA
+{
+    TPM_STRUCT_VER   ver;
+    TPM_PAYLOAD_TYPE payload;
+    BYTE            *payloadData; // length is implied
+} TPM_BOUND_DATA;
+
+
+//-------------------------------------------------------------------
+// Part 2, section 10: TPM_KEY complex
+
+typedef struct tdTPM_KEY_PARMS                              /* 1.1b */
+{
+    TPM_ALGORITHM_ID  algorithmID;
+    TPM_ENC_SCHEME    encScheme;
+    TPM_SIG_SCHEME    sigScheme;
+    UINT32            parmSize;
+    SIZEIS(parmSize)
+        BYTE         *parms;
+} TPM_KEY_PARMS;
+
+typedef struct tdTPM_RSA_KEY_PARMS                          /* 1.1b */
+{  
+    UINT32    keyLength; 
+    UINT32    numPrimes; 
+    UINT32    exponentSize;
+    SIZEIS(exponentSize)
+        BYTE *exponent;
+} TPM_RSA_KEY_PARMS;
+
+typedef struct tdTPM_SYMMETRIC_KEY_PARMS
+{
+    UINT32 keyLength;
+    UINT32 blockSize;
+    UINT32 ivSize;
+    SIZEIS(ivSize)
+        BYTE *IV;
+} TPM_SYMMETRIC_KEY_PARMS;
+
+typedef struct tdTPM_STORE_PUBKEY                           /* 1.1b */
+{
+    UINT32    keyLength;
+    SIZEIS(keyLength)
+        BYTE *key;
+} TPM_STORE_PUBKEY;
+
+typedef struct tdTPM_PUBKEY                                 /* 1.1b */
+{
+    TPM_KEY_PARMS     algorithmParms;
+    TPM_STORE_PUBKEY  pubKey;
+} TPM_PUBKEY;
+
+typedef struct tdTPM_STORE_PRIVKEY                          /* 1.1b */
+{
+    UINT32    keyLength;
+    SIZEIS(keyLength)
+        BYTE *key;   
+} TPM_STORE_PRIVKEY;
+
+typedef struct tdTPM_STORE_ASYMKEY                          /* 1.1b */
+{         
+    TPM_PAYLOAD_TYPE  payload;   
+    TPM_SECRET        usageAuth;    
+    TPM_SECRET        migrationAuth;  
+    TPM_DIGEST        pubDataDigest;   
+    TPM_STORE_PRIVKEY privKey;   
+} TPM_STORE_ASYMKEY;
+
+typedef struct tdTPM_KEY                                    /* 1.1b */
+{
+    TPM_STRUCT_VER      ver;
+    TPM_KEY_USAGE       keyUsage;
+    TPM_KEY_FLAGS       keyFlags;
+    TPM_AUTH_DATA_USAGE authDataUsage;
+    TPM_KEY_PARMS       algorithmParms; 
+    UINT32              PCRInfoSize;
+    SIZEIS(PCRInfoSize)
+        BYTE           *PCRInfo;
+    TPM_STORE_PUBKEY    pubKey;
+    UINT32              encSize;
+    SIZEIS(encSize)
+        BYTE           *encData; 
+} TPM_KEY;
+
+typedef struct tdTPM_KEY12
+{
+    TPM_STRUCTURE_TAG   tag;
+    UINT16              fill;
+    TPM_KEY_USAGE       keyUsage;
+    TPM_KEY_FLAGS       keyFlags;
+    TPM_AUTH_DATA_USAGE authDataUsage;
+    TPM_KEY_PARMS       algorithmParms;
+    UINT32              PCRInfoSize;
+    SIZEIS(PCRInfoSize)
+       BYTE            *PCRInfo;
+    TPM_STORE_PUBKEY    pubKey;
+    UINT32              encSize;
+    SIZEIS(encSize)
+       BYTE            *encData;
+} TPM_KEY12;
+
+typedef struct tdTPM_MIGRATE_ASYMKEY
+{
+    TPM_PAYLOAD_TYPE payload;
+    TPM_SECRET       usageAuth;
+    TPM_DIGEST       pubDataDigest;
+    UINT32           partPrivKeyLen;
+    SIZEIS(partPrivKeyLen)
+        BYTE        *partPrivKey;
+} TPM_MIGRATE_ASYMKEY;
+
+
+typedef UINT32 TPM_KEY_CONTROL;
+#define TPM_KEY_CONTROL_OWNER_EVICT    ((UINT32)0x00000001)
+
+
+//-------------------------------------------------------------------
+// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH
+
+typedef struct tdTPM_MIGRATIONKEYAUTH                       /* 1.1b */
+{
+    TPM_PUBKEY         migrationKey;
+    TPM_MIGRATE_SCHEME migrationScheme;
+    TPM_DIGEST         digest;
+} TPM_MIGRATIONKEYAUTH;
+
+
+//-------------------------------------------------------------------
+// Part 2, section 11: Signed Structures
+
+typedef struct tdTPM_CERTIFY_INFO                           /* 1.1b */
+{
+    TPM_STRUCT_VER      version;
+    TPM_KEY_USAGE       keyUsage;
+    TPM_KEY_FLAGS       keyFlags;
+    TPM_AUTH_DATA_USAGE authDataUsage;
+    TPM_KEY_PARMS       algorithmParms;
+    TPM_DIGEST          pubkeyDigest;
+    TPM_NONCE           data;
+    TPM_BOOL            parentPCRStatus;
+    UINT32              PCRInfoSize;
+    SIZEIS(PCRInfoSize)
+        BYTE           *PCRInfo;
+} TPM_CERTIFY_INFO;
+
+typedef struct tdTPM_CERTIFY_INFO2
+{
+    TPM_STRUCTURE_TAG   tag;
+    BYTE                fill;
+    TPM_PAYLOAD_TYPE    payloadType;
+    TPM_KEY_USAGE       keyUsage;
+    TPM_KEY_FLAGS       keyFlags;
+    TPM_AUTH_DATA_USAGE authDataUsage;
+    TPM_KEY_PARMS       algorithmParms;
+    TPM_DIGEST          pubkeyDigest;
+    TPM_NONCE           data;
+    TPM_BOOL            parentPCRStatus;
+    UINT32              PCRInfoSize;
+    SIZEIS(PCRInfoSize) 
+        BYTE           *PCRInfo;
+    UINT32              migrationAuthoritySize;
+    SIZEIS(migrationAuthoritySize)
+        BYTE           *migrationAuthority;
+} TPM_CERTIFY_INFO2;
+
+typedef struct tdTPM_QUOTE_INFO                             /* 1.1b */
+{
+    TPM_STRUCT_VER     version;
+    BYTE               fixed[4];
+    TPM_COMPOSITE_HASH compositeHash; /* in 1.2 TPM spec, named digestValue */
+    TPM_NONCE          externalData;
+} TPM_QUOTE_INFO;
+
+typedef struct tdTPM_QUOTE_INFO2
+{
+    TPM_STRUCTURE_TAG  tag;
+    BYTE               fixed[4];
+    TPM_NONCE          externalData;
+    TPM_PCR_INFO_SHORT infoShort;
+} TPM_QUOTE_INFO2;
+
+
+
+//-------------------------------------------------------------------
+// Part 2, section 12: Identity Structures
+
+
+typedef struct tdTPM_EK_BLOB
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_EK_TYPE       ekType;
+    UINT32            blobSize;
+    SIZEIS(blobSize)
+        BYTE         *blob;
+} TPM_EK_BLOB;
+
+typedef struct tdTPM_EK_BLOB_ACTIVATE
+{
+    TPM_STRUCTURE_TAG  tag;
+    TPM_SYMMETRIC_KEY  sessionKey;
+    TPM_DIGEST         idDigest;
+    TPM_PCR_INFO_SHORT pcrInfo;
+} TPM_EK_BLOB_ACTIVATE;
+
+typedef struct tdTPM_EK_BLOB_AUTH
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_SECRET        authValue;
+} TPM_EK_BLOB_AUTH;
+
+
+typedef struct tdTPM_IDENTITY_CONTENTS
+{
+    TPM_STRUCT_VER    ver;
+    UINT32            ordinal;
+    TPM_CHOSENID_HASH labelPrivCADigest;
+    TPM_PUBKEY        identityPubKey;
+} TPM_IDENTITY_CONTENTS;
+
+typedef struct tdTPM_IDENTITY_REQ                           /* 1.1b */
+{
+    UINT32         asymSize;
+    UINT32         symSize;
+    TPM_KEY_PARMS  asymAlgorithm;
+    TPM_KEY_PARMS  symAlgorithm;
+    SIZEIS(asymSize)
+        BYTE      *asymBlob;
+    SIZEIS(symSize)
+        BYTE      *symBlob;
+} TPM_IDENTITY_REQ;
+
+typedef struct tdTPM_IDENTITY_PROOF                         /* 1.1b */
+{
+    TPM_STRUCT_VER  ver;
+    UINT32          labelSize;
+    UINT32          identityBindingSize;
+    UINT32          endorsementSize;
+    UINT32          platformSize;
+    UINT32          conformanceSize;
+    TPM_PUBKEY      identityKey;
+    SIZEIS(labelSize)
+      BYTE         *labelArea;
+    SIZEIS(identityBindingSize)
+      BYTE         *identityBinding;
+    SIZEIS(endorsementSize)
+      BYTE         *endorsementCredential;
+    SIZEIS(platformSize)
+      BYTE         *platformCredential;
+    SIZEIS(conformanceSize)
+      BYTE         *conformanceCredential;
+} TPM_IDENTITY_PROOF;
+
+typedef struct tdTPM_ASYM_CA_CONTENTS                       /* 1.1b */
+{
+    TPM_SYMMETRIC_KEY sessionKey;
+    TPM_DIGEST        idDigest;
+} TPM_ASYM_CA_CONTENTS;
+
+typedef struct tdTPM_SYM_CA_ATTESTATION
+{
+    UINT32         credSize;
+    TPM_KEY_PARMS  algorithm;
+    SIZEIS(credSize)
+        BYTE      *credential;
+} TPM_SYM_CA_ATTESTATION;
+
+
+
+//-------------------------------------------------------------------
+// Part 2, section 15: Tick Structures
+// Placed here out of order because definitions are used in section 13.
+
+typedef struct tdTPM_CURRENT_TICKS
+{
+    TPM_STRUCTURE_TAG tag;
+    UINT64            currentTicks;
+    UINT16            tickRate;
+    TPM_NONCE         tickNonce;
+} TPM_CURRENT_TICKS;
+
+
+
+//-------------------------------------------------------------------
+// Part 2, section 13: Transport structures
+
+typedef UINT32 TPM_TRANSPORT_ATTRIBUTES;
+#define TPM_TRANSPORT_ENCRYPT          ((UINT32)0x00000001)
+#define TPM_TRANSPORT_LOG              ((UINT32)0x00000002)
+#define TPM_TRANSPORT_EXCLUSIVE        ((UINT32)0x00000004)
+
+typedef struct tdTPM_TRANSPORT_PUBLIC
+{
+    TPM_STRUCTURE_TAG        tag;
+    TPM_TRANSPORT_ATTRIBUTES transAttributes;
+    TPM_ALGORITHM_ID         algId;
+    TPM_ENC_SCHEME           encScheme;
+} TPM_TRANSPORT_PUBLIC;
+
+typedef struct tdTPM_TRANSPORT_INTERNAL
+{
+    TPM_STRUCTURE_TAG    tag;
+    TPM_AUTHDATA         authData;
+    TPM_TRANSPORT_PUBLIC transPublic;
+    TPM_TRANSHANDLE      transHandle;
+    TPM_NONCE            transNonceEven;
+    TPM_DIGEST           transDigest;
+} TPM_TRANSPORT_INTERNAL;
+
+typedef struct tdTPM_TRANSPORT_LOG_IN
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_DIGEST        parameters;
+    TPM_DIGEST        pubKeyHash;
+} TPM_TRANSPORT_LOG_IN;
+
+typedef struct tdTPM_TRANSPORT_LOG_OUT
+{
+    TPM_STRUCTURE_TAG      tag;
+    TPM_CURRENT_TICKS      currentTicks;
+    TPM_DIGEST             parameters;
+    TPM_MODIFIER_INDICATOR locality;
+} TPM_TRANSPORT_LOG_OUT;
+
+typedef struct tdTPM_TRANSPORT_AUTH
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_AUTHDATA      authData;
+} TPM_TRANSPORT_AUTH;
+
+
+
+//-------------------------------------------------------------------
+// Part 2, section 14: Audit Structures
+
+typedef struct tdTPM_AUDIT_EVENT_IN
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_DIGEST        inputParms;
+    TPM_COUNTER_VALUE auditCount;
+} TPM_AUDIT_EVENT_IN;
+
+typedef struct tdTPM_AUDIT_EVENT_OUT
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_COMMAND_CODE  ordinal;
+    TPM_DIGEST        outputParms;
+    TPM_COUNTER_VALUE auditCount;
+    TPM_RESULT        returnCode;
+} TPM_AUDIT_EVENT_OUT;
+
+
+
+//-------------------------------------------------------------------
+// Part 2, section 16: Return codes
+
+#include <tss/tpm_error.h>
+
+
+//-------------------------------------------------------------------
+// Part 2, section 17: Ordinals
+
+#include <tss/tpm_ordinal.h>
+
+//-------------------------------------------------------------------
+// Part 2, section 18: Context structures
+
+typedef struct tdTPM_CONTEXT_BLOB
+{
+    TPM_STRUCTURE_TAG  tag;
+    TPM_RESOURCE_TYPE  resourceType;
+    TPM_HANDLE         handle;
+    BYTE               label[16];
+    UINT32             contextCount;
+    TPM_DIGEST         integrityDigest;
+    UINT32             additionalSize;
+    SIZEIS(additionalSize)
+        BYTE          *additionalData;
+    UINT32             sensitiveSize;
+    SIZEIS(sensitiveSize)
+        BYTE          *sensitiveData;
+} TPM_CONTEXT_BLOB;
+
+typedef struct tdTPM_CONTEXT_SENSITIVE
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_NONCE         contextNonce;
+    UINT32            internalSize;
+    SIZEIS(internalSize)
+        BYTE         *internalData;
+} TPM_CONTEXT_SENSITIVE;
+
+//-------------------------------------------------------------------
+// Part 2, section 19: NV Structures
+
+typedef UINT32 TPM_NV_INDEX;
+#define TPM_NV_INDEX_LOCK              ((UINT32)0xffffffff)
+#define TPM_NV_INDEX0                  ((UINT32)0x00000000)
+#define TPM_NV_INDEX_DIR               ((UINT32)0x10000001)
+#define TPM_NV_INDEX_EKCert            ((UINT32)0x0000f000)
+#define TPM_NV_INDEX_TPM_CC            ((UINT32)0x0000f001)
+#define TPM_NV_INDEX_PlatformCert      ((UINT32)0x0000f002)
+#define TPM_NV_INDEX_Platform_CC       ((UINT32)0x0000f003)
+// The following define ranges of reserved indices.
+#define TPM_NV_INDEX_TSS_BASE          ((UINT32)0x00011100)
+#define TPM_NV_INDEX_PC_BASE           ((UINT32)0x00011200)
+#define TPM_NV_INDEX_SERVER_BASE       ((UINT32)0x00011300)
+#define TPM_NV_INDEX_MOBILE_BASE       ((UINT32)0x00011400)
+#define TPM_NV_INDEX_PERIPHERAL_BASE   ((UINT32)0x00011500)
+#define TPM_NV_INDEX_GROUP_RESV_BASE   ((UINT32)0x00010000)
+
+
+typedef UINT32 TPM_NV_PER_ATTRIBUTES;
+#define TPM_NV_PER_READ_STCLEAR        (((UINT32)1)<<31)
+#define TPM_NV_PER_AUTHREAD            (((UINT32)1)<<18)
+#define TPM_NV_PER_OWNERREAD           (((UINT32)1)<<17)
+#define TPM_NV_PER_PPREAD              (((UINT32)1)<<16)
+#define TPM_NV_PER_GLOBALLOCK          (((UINT32)1)<<15)
+#define TPM_NV_PER_WRITE_STCLEAR       (((UINT32)1)<<14)
+#define TPM_NV_PER_WRITEDEFINE         (((UINT32)1)<<13)
+#define TPM_NV_PER_WRITEALL            (((UINT32)1)<<12)
+#define TPM_NV_PER_AUTHWRITE           (((UINT32)1)<<2)
+#define TPM_NV_PER_OWNERWRITE          (((UINT32)1)<<1)
+#define TPM_NV_PER_PPWRITE             (((UINT32)1)<<0)
+
+typedef struct tdTPM_NV_ATTRIBUTES
+{
+    TPM_STRUCTURE_TAG     tag;
+    TPM_NV_PER_ATTRIBUTES attributes;
+} TPM_NV_ATTRIBUTES;
+
+
+typedef struct tdTPM_NV_DATA_PUBLIC
+{
+    TPM_STRUCTURE_TAG  tag;
+    TPM_NV_INDEX       nvIndex;
+    TPM_PCR_INFO_SHORT pcrInfoRead;
+    TPM_PCR_INFO_SHORT pcrInfoWrite;
+    TPM_NV_ATTRIBUTES  permission;
+    TPM_BOOL           bReadSTClear;
+    TPM_BOOL           bWriteSTClear;
+    TPM_BOOL           bWriteDefine;
+    UINT32             dataSize;
+} TPM_NV_DATA_PUBLIC;
+
+
+#if 0
+// Internal to TPM:
+typedef struct tdTPM_NV_DATA_SENSITIVE
+{
+    TPM_STRUCTURE_TAG  tag;
+    TPM_NV_DATA_PUBLIC pubInfo;
+    TPM_AUTHDATA       authValue;
+    SIZEIS(pubInfo.dataSize)
+        BYTE          *data;
+} TPM_NV_DATA_SENSITIVE;
+#endif
+
+
+//-------------------------------------------------------------------
+// Part 2, section 20: Delegation
+
+//-------------------------------------------------------------------
+// Part 2, section 20.3: Owner Permissions Settings for per1 bits
+#define TPM_DELEGATE_SetOrdinalAuditStatus          (((UINT32)1)<<30)
+#define TPM_DELEGATE_DirWriteAuth                   (((UINT32)1)<<29)
+#define TPM_DELEGATE_CMK_ApproveMA                  (((UINT32)1)<<28)
+#define TPM_DELEGATE_NV_WriteValue                  (((UINT32)1)<<27)
+#define TPM_DELEGATE_CMK_CreateTicket               (((UINT32)1)<<26)
+#define TPM_DELEGATE_NV_ReadValue                   (((UINT32)1)<<25)
+#define TPM_DELEGATE_Delegate_LoadOwnerDelegation   (((UINT32)1)<<24)
+#define TPM_DELEGATE_DAA_Join                       (((UINT32)1)<<23)
+#define TPM_DELEGATE_AuthorizeMigrationKey          (((UINT32)1)<<22)
+#define TPM_DELEGATE_CreateMaintenanceArchive       (((UINT32)1)<<21)
+#define TPM_DELEGATE_LoadMaintenanceArchive         (((UINT32)1)<<20)
+#define TPM_DELEGATE_KillMaintenanceFeature         (((UINT32)1)<<19)
+#define TPM_DELEGATE_OwnerReadInternalPub           (((UINT32)1)<<18)
+#define TPM_DELEGATE_ResetLockValue                 (((UINT32)1)<<17)
+#define TPM_DELEGATE_OwnerClear                     (((UINT32)1)<<16)
+#define TPM_DELEGATE_DisableOwnerClear              (((UINT32)1)<<15)
+#define TPM_DELEGATE_NV_DefineSpace                 (((UINT32)1)<<14)
+#define TPM_DELEGATE_OwnerSetDisable                (((UINT32)1)<<13)
+#define TPM_DELEGATE_SetCapability                  (((UINT32)1)<<12)
+#define TPM_DELEGATE_MakeIdentity                   (((UINT32)1)<<11)
+#define TPM_DELEGATE_ActivateIdentity               (((UINT32)1)<<10)
+#define TPM_DELEGATE_OwnerReadPubek                 (((UINT32)1)<<9)
+#define TPM_DELEGATE_DisablePubekRead               (((UINT32)1)<<8)
+#define TPM_DELEGATE_SetRedirection                 (((UINT32)1)<<7)
+#define TPM_DELEGATE_FieldUpgrade                   (((UINT32)1)<<6)
+#define TPM_DELEGATE_Delegate_UpdateVerification    (((UINT32)1)<<5)
+#define TPM_DELEGATE_CreateCounter                  (((UINT32)1)<<4)
+#define TPM_DELEGATE_ReleaseCounterOwner            (((UINT32)1)<<3)
+#define TPM_DELEGATE_DelegateManage                 (((UINT32)1)<<2)
+#define TPM_DELEGATE_Delegate_CreateOwnerDelegation (((UINT32)1)<<1)
+#define TPM_DELEGATE_DAA_Sign                       (((UINT32)1)<<0)
+
+//-------------------------------------------------------------------
+// Part 2, section 20.3: Key Permissions Settings for per1 bits
+#define TPM_KEY_DELEGATE_CMK_ConvertMigration       (((UINT32)1)<<28)
+#define TPM_KEY_DELEGATE_TickStampBlob              (((UINT32)1)<<27)
+#define TPM_KEY_DELEGATE_ChangeAuthAsymStart        (((UINT32)1)<<26)
+#define TPM_KEY_DELEGATE_ChangeAuthAsymFinish       (((UINT32)1)<<25)
+#define TPM_KEY_DELEGATE_CMK_CreateKey              (((UINT32)1)<<24)
+#define TPM_KEY_DELEGATE_MigrateKey                 (((UINT32)1)<<23)
+#define TPM_KEY_DELEGATE_LoadKey2                   (((UINT32)1)<<22)
+#define TPM_KEY_DELEGATE_EstablishTransport         (((UINT32)1)<<21)
+#define TPM_KEY_DELEGATE_ReleaseTransportSigned     (((UINT32)1)<<20)
+#define TPM_KEY_DELEGATE_Quote2                     (((UINT32)1)<<19)
+#define TPM_KEY_DELEGATE_Sealx                      (((UINT32)1)<<18)
+#define TPM_KEY_DELEGATE_MakeIdentity               (((UINT32)1)<<17)
+#define TPM_KEY_DELEGATE_ActivateIdentity           (((UINT32)1)<<16)
+#define TPM_KEY_DELEGATE_GetAuditDigestSigned       (((UINT32)1)<<15)
+#define TPM_KEY_DELEGATE_Sign                       (((UINT32)1)<<14)
+#define TPM_KEY_DELEGATE_CertifyKey2                (((UINT32)1)<<13)
+#define TPM_KEY_DELEGATE_CertifyKey                 (((UINT32)1)<<12)
+#define TPM_KEY_DELEGATE_CreateWrapKey              (((UINT32)1)<<11)
+#define TPM_KEY_DELEGATE_CMK_CreateBlob             (((UINT32)1)<<10)
+#define TPM_KEY_DELEGATE_CreateMigrationBlob        (((UINT32)1)<<9)
+#define TPM_KEY_DELEGATE_ConvertMigrationBlob       (((UINT32)1)<<8)
+#define TPM_KEY_DELEGATE_CreateKeyDelegation        (((UINT32)1)<<7)
+#define TPM_KEY_DELEGATE_ChangeAuth                 (((UINT32)1)<<6)
+#define TPM_KEY_DELEGATE_GetPubKey                  (((UINT32)1)<<5)
+#define TPM_KEY_DELEGATE_UnBind                     (((UINT32)1)<<4)
+#define TPM_KEY_DELEGATE_Quote                      (((UINT32)1)<<3)
+#define TPM_KEY_DELEGATE_Unseal                     (((UINT32)1)<<2)
+#define TPM_KEY_DELEGATE_Seal                       (((UINT32)1)<<1)
+#define TPM_KEY_DELEGATE_LoadKey                    (((UINT32)1)<<0)
+
+typedef UINT32 TPM_FAMILY_VERIFICATION;
+
+typedef UINT32 TPM_FAMILY_ID;
+
+typedef UINT32 TPM_DELEGATE_INDEX;
+
+typedef UINT32 TPM_FAMILY_OPERATION;
+#define TPM_FAMILY_CREATE              ((UINT32)0x00000001)
+#define TPM_FAMILY_ENABLE              ((UINT32)0x00000002)
+#define TPM_FAMILY_ADMIN               ((UINT32)0x00000003)
+#define TPM_FAMILY_INVALIDATE          ((UINT32)0x00000004)
+
+typedef UINT32 TPM_FAMILY_FLAGS;
+#define TPM_FAMFLAG_DELEGATE_ADMIN_LOCK   (((UINT32)1)<<1)
+#define TPM_FAMFLAG_ENABLE                (((UINT32)1)<<0)
+
+typedef struct tdTPM_FAMILY_LABEL
+{
+    BYTE label;
+} TPM_FAMILY_LABEL;
+
+typedef struct tdTPM_FAMILY_TABLE_ENTRY
+{
+    TPM_STRUCTURE_TAG       tag;
+    TPM_FAMILY_LABEL        label;
+    TPM_FAMILY_ID           familyID;
+    TPM_FAMILY_VERIFICATION verificationCount;
+    TPM_FAMILY_FLAGS        flags;
+} TPM_FAMILY_TABLE_ENTRY;
+
+
+#define TPM_FAMILY_TABLE_ENTRY_MIN 8
+//typedef struct tdTPM_FAMILY_TABLE
+//{
+//    TPM_FAMILY_TABLE_ENTRY FamTableRow[TPM_NUM_FAMILY_TABLE_ENTRY_MIN];
+//} TPM_FAMILY_TABLE;
+
+
+typedef struct tdTPM_DELEGATE_LABEL
+{
+    BYTE label;
+} TPM_DELEGATE_LABEL;
+
+
+typedef UINT32 TPM_DELEGATE_TYPE;
+#define TPM_DEL_OWNER_BITS             ((UINT32)0x00000001)
+#define TPM_DEL_KEY_BITS               ((UINT32)0x00000002)
+
+typedef struct tdTPM_DELEGATIONS
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_DELEGATE_TYPE delegateType;
+    UINT32            per1;
+    UINT32            per2;
+} TPM_DELEGATIONS;
+
+typedef struct tdTPM_DELEGATE_PUBLIC
+{
+    TPM_STRUCTURE_TAG       tag;
+    TPM_DELEGATE_LABEL      label;
+    TPM_PCR_INFO_SHORT      pcrInfo;
+    TPM_DELEGATIONS         permissions;
+    TPM_FAMILY_ID           familyID;
+    TPM_FAMILY_VERIFICATION verificationCount;
+} TPM_DELEGATE_PUBLIC;
+
+typedef struct tdTPM_DELEGATE_TABLE_ROW
+{
+    TPM_STRUCTURE_TAG   tag;
+    TPM_DELEGATE_PUBLIC pub;
+    TPM_SECRET          authValue;
+} TPM_DELEGATE_TABLE_ROW;
+
+
+#define TPM_NUM_DELEGATE_TABLE_ENTRY_MIN 2
+//typedef struct tdTPM_DELEGATE_TABLE
+//{
+//    TPM_DELEGATE_TABLE_ROW delRow[TPM_NUM_DELEGATE_TABLE_ENTRY_MIN];
+//} TPM_DELEGATE_TABLE;
+
+typedef struct tdTPM_DELEGATE_SENSITIVE
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_SECRET        authValue;
+} TPM_DELEGATE_SENSITIVE;
+
+typedef struct tdTPM_DELEGATE_OWNER_BLOB
+{
+    TPM_STRUCTURE_TAG   tag;
+    TPM_DELEGATE_PUBLIC pub;
+    TPM_DIGEST          integrityDigest;
+    UINT32              additionalSize;
+    SIZEIS(additionalSize)
+        BYTE           *additionalArea;
+    UINT32              sensitiveSize;
+    SIZEIS(sensitiveSize)
+        BYTE           *sensitiveArea;
+} TPM_DELEGATE_OWNER_BLOB;
+
+typedef struct tdTPM_DELEGATE_KEY_BLOB
+{
+    TPM_STRUCTURE_TAG   tag;
+    TPM_DELEGATE_PUBLIC pub;
+    TPM_DIGEST          integrityDigest;
+    TPM_DIGEST          pubKeyDigest;
+    UINT32              additionalSize;
+    SIZEIS(additionalSize)
+        BYTE           *additionalArea;
+    UINT32              sensitiveSize;
+    SIZEIS(sensitiveSize)
+        BYTE           *sensitiveArea;
+} TPM_DELEGATE_KEY_BLOB;
+
+
+//-------------------------------------------------------------------
+// Part 2, section 21.1: TPM_CAPABILITY_AREA
+
+typedef UINT32 TPM_CAPABILITY_AREA;                         /* 1.1b */
+#define TPM_CAP_ORD                    ((UINT32)0x00000001) /* 1.1b */
+#define TPM_CAP_ALG                    ((UINT32)0x00000002) /* 1.1b */
+#define TPM_CAP_PID                    ((UINT32)0x00000003) /* 1.1b */
+#define TPM_CAP_FLAG                   ((UINT32)0x00000004) /* 1.1b */
+#define TPM_CAP_PROPERTY               ((UINT32)0x00000005) /* 1.1b */
+#define TPM_CAP_VERSION                ((UINT32)0x00000006) /* 1.1b */
+#define TPM_CAP_KEY_HANDLE             ((UINT32)0x00000007) /* 1.1b */
+#define TPM_CAP_CHECK_LOADED           ((UINT32)0x00000008) /* 1.1b */
+#define TPM_CAP_SYM_MODE               ((UINT32)0x00000009)
+#define TPM_CAP_KEY_STATUS             ((UINT32)0x0000000C)
+#define TPM_CAP_NV_LIST                ((UINT32)0x0000000D)
+#define TPM_CAP_MFR                    ((UINT32)0x00000010)
+#define TPM_CAP_NV_INDEX               ((UINT32)0x00000011)
+#define TPM_CAP_TRANS_ALG              ((UINT32)0x00000012)
+#define TPM_CAP_HANDLE                 ((UINT32)0x00000014)
+#define TPM_CAP_TRANS_ES               ((UINT32)0x00000015)
+#define TPM_CAP_AUTH_ENCRYPT           ((UINT32)0x00000017)
+#define TPM_CAP_SELECT_SIZE            ((UINT32)0x00000018)
+#define TPM_CAP_DA_LOGIC               ((UINT32)0x00000019)
+#define TPM_CAP_VERSION_VAL            ((UINT32)0x0000001A)
+
+// Part 2, section 21.1: Subcap values for CAP_FLAG
+#define TPM_CAP_FLAG_PERMANENT         ((UINT32)0x00000108)
+#define TPM_CAP_FLAG_VOLATILE          ((UINT32)0x00000109)
+
+//-------------------------------------------------------------------
+// Part 2, section 21.2: Subcap values for CAP_PROPERTY
+
+#define TPM_CAP_PROP_PCR               ((UINT32)0x00000101) /* 1.1b */
+#define TPM_CAP_PROP_DIR               ((UINT32)0x00000102) /* 1.1b */
+#define TPM_CAP_PROP_MANUFACTURER      ((UINT32)0x00000103) /* 1.1b */
+#define TPM_CAP_PROP_KEYS              ((UINT32)0x00000104)
+#define TPM_CAP_PROP_SLOTS             (TPM_CAP_PROP_KEYS)
+#define TPM_CAP_PROP_MIN_COUNTER       ((UINT32)0x00000107)
+#define TPM_CAP_PROP_AUTHSESS          ((UINT32)0x0000010A)
+#define TPM_CAP_PROP_TRANSSESS         ((UINT32)0x0000010B)
+#define TPM_CAP_PROP_COUNTERS          ((UINT32)0x0000010C)
+#define TPM_CAP_PROP_MAX_AUTHSESS      ((UINT32)0x0000010D)
+#define TPM_CAP_PROP_MAX_TRANSSESS     ((UINT32)0x0000010E)
+#define TPM_CAP_PROP_MAX_COUNTERS      ((UINT32)0x0000010F)
+#define TPM_CAP_PROP_MAX_KEYS          ((UINT32)0x00000110)
+#define TPM_CAP_PROP_OWNER             ((UINT32)0x00000111)
+#define TPM_CAP_PROP_CONTEXT           ((UINT32)0x00000112)
+#define TPM_CAP_PROP_MAX_CONTEXT       ((UINT32)0x00000113)
+#define TPM_CAP_PROP_FAMILYROWS        ((UINT32)0x00000114)
+#define TPM_CAP_PROP_TIS_TIMEOUT       ((UINT32)0x00000115)
+#define TPM_CAP_PROP_STARTUP_EFFECT    ((UINT32)0x00000116)
+#define TPM_CAP_PROP_DELEGATE_ROW      ((UINT32)0x00000117)
+#define TPM_CAP_PROP_MAX_DAASESS       ((UINT32)0x00000119)
+#define TPM_CAP_PROP_DAA_MAX           TPM_CAP_PROP_MAX_DAASESS
+#define TPM_CAP_PROP_DAASESS           ((UINT32)0x0000011A)
+#define TPM_CAP_PROP_SESSION_DAA       TPM_CAP_PROP_DAASESS
+#define TPM_CAP_PROP_CONTEXT_DIST      ((UINT32)0x0000011B)
+#define TPM_CAP_PROP_DAA_INTERRUPT     ((UINT32)0x0000011C)
+#define TPM_CAP_PROP_SESSIONS          ((UINT32)0x0000011D)
+#define TPM_CAP_PROP_MAX_SESSIONS      ((UINT32)0x0000011E)
+#define TPM_CAP_PROP_CMK_RESTRICTION   ((UINT32)0x0000011F)
+#define TPM_CAP_PROP_DURATION          ((UINT32)0x00000120)
+#define TPM_CAP_PROP_ACTIVE_COUNTER    ((UINT32)0x00000122)
+#define TPM_CAP_PROP_NV_AVAILABLE      ((UINT32)0x00000123)
+#define TPM_CAP_PROP_INPUT_BUFFER      ((UINT32)0x00000124)
+
+
+// Part 2, section 21.4: SetCapability Values
+#define TPM_SET_PERM_FLAGS             ((UINT32)0x00000001)
+#define TPM_SET_PERM_DATA              ((UINT32)0x00000002)
+#define TPM_SET_STCLEAR_FLAGS          ((UINT32)0x00000003)
+#define TPM_SET_STCLEAR_DATA           ((UINT32)0x00000004)
+#define TPM_SET_STANY_FLAGS            ((UINT32)0x00000005)
+#define TPM_SET_STANY_DATA             ((UINT32)0x00000006)
+#define TPM_SET_VENDOR                 ((UINT32)0x00000007)
+
+
+// Part 2, section 21.6: TPM_CAP_VERSION_INFO
+typedef struct tdTPM_CAP_VERSION_INFO
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_VERSION       version;
+    UINT16            specLevel;
+    BYTE              errataRev;
+    BYTE              tpmVendorID[4];
+    UINT16            vendorSpecificSize;
+    SIZEIS(vendorSpecificSize)
+        BYTE         *vendorSpecific;
+} TPM_CAP_VERSION_INFO;
+
+
+// Part 2, section 21.9: TPM_DA_STATE
+// out of order to make it available for structure definitions
+typedef BYTE TPM_DA_STATE;
+#define TPM_DA_STATE_INACTIVE          (0x00)
+#define TPM_DA_STATE_ACTIVE            (0x01)
+
+// Part 2, section 21.10: TPM_DA_ACTION_TYPE
+typedef struct tdTPM_DA_ACTION_TYPE
+{
+    TPM_STRUCTURE_TAG tag;
+    UINT32            actions;
+} TPM_DA_ACTION_TYPE;
+#define TPM_DA_ACTION_TIMEOUT          ((UINT32)0x00000001)
+#define TPM_DA_ACTION_DISABLE          ((UINT32)0x00000002)
+#define TPM_DA_ACTION_DEACTIVATE       ((UINT32)0x00000004)
+#define TPM_DA_ACTION_FAILURE_MODE     ((UINT32)0x00000008)
+
+// Part 2, section 21.7: TPM_DA_INFO
+typedef struct tdTPM_DA_INFO
+{
+    TPM_STRUCTURE_TAG  tag;
+    TPM_DA_STATE       state;
+    UINT16             currentCount;
+    UINT16             threshholdCount;
+    TPM_DA_ACTION_TYPE actionAtThreshold;
+    UINT32             actionDependValue;
+    UINT32             vendorDataSize;
+    SIZEIS(vendorDataSize)
+        BYTE          *vendorData;
+} TPM_DA_INFO;
+
+// Part 2, section 21.8: TPM_DA_INFO_LIMITED
+typedef struct tdTPM_DA_INFO_LIMITED
+{
+    TPM_STRUCTURE_TAG  tag;
+    TPM_DA_STATE       state;
+    TPM_DA_ACTION_TYPE actionAtThreshold;
+    UINT32             vendorDataSize;
+    SIZEIS(vendorDataSize)
+        BYTE          *vendorData;
+} TPM_DA_INFO_LIMITED;
+
+
+
+//-------------------------------------------------------------------
+// Part 2, section 22: DAA Structures
+
+#define TPM_DAA_SIZE_r0                (43)
+#define TPM_DAA_SIZE_r1                (43)
+#define TPM_DAA_SIZE_r2                (128)
+#define TPM_DAA_SIZE_r3                (168)
+#define TPM_DAA_SIZE_r4                (219)
+#define TPM_DAA_SIZE_NT                (20)
+#define TPM_DAA_SIZE_v0                (128)
+#define TPM_DAA_SIZE_v1                (192)
+#define TPM_DAA_SIZE_NE                (256)
+#define TPM_DAA_SIZE_w                 (256)
+#define TPM_DAA_SIZE_issuerModulus     (256)
+#define TPM_DAA_power0                 (104)
+#define TPM_DAA_power1                 (1024)
+
+typedef struct tdTPM_DAA_ISSUER
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_DIGEST        DAA_digest_R0;
+    TPM_DIGEST        DAA_digest_R1;
+    TPM_DIGEST        DAA_digest_S0;
+    TPM_DIGEST        DAA_digest_S1;
+    TPM_DIGEST        DAA_digest_n;
+    TPM_DIGEST        DAA_digest_gamma;
+    BYTE              DAA_generic_q[26];
+} TPM_DAA_ISSUER;
+
+
+typedef struct tdTPM_DAA_TPM
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_DIGEST        DAA_digestIssuer;
+    TPM_DIGEST        DAA_digest_v0;
+    TPM_DIGEST        DAA_digest_v1;
+    TPM_DIGEST        DAA_rekey;
+    UINT32            DAA_count;
+} TPM_DAA_TPM;
+
+typedef struct tdTPM_DAA_CONTEXT
+{
+    TPM_STRUCTURE_TAG    tag;
+    TPM_DIGEST           DAA_digestContext;
+    TPM_DIGEST           DAA_digest;
+    TPM_DAA_CONTEXT_SEED DAA_contextSeed;
+    BYTE                 DAA_scratch[256];
+    BYTE                 DAA_stage;
+} TPM_DAA_CONTEXT;
+
+typedef struct tdTPM_DAA_JOINDATA
+{
+    BYTE       DAA_join_u0[128];
+    BYTE       DAA_join_u1[138];
+    TPM_DIGEST DAA_digest_n0;
+} TPM_DAA_JOINDATA;
+
+typedef struct tdTPM_DAA_BLOB
+{
+    TPM_STRUCTURE_TAG tag;
+    TPM_RESOURCE_TYPE resourceType;
+    BYTE              label[16];
+    TPM_DIGEST        blobIntegrity;
+    UINT32            additionalSize;
+    SIZEIS(additionalSize)
+        BYTE         *additionalData;
+    UINT32            sensitiveSize;
+    SIZEIS(sensitiveSize)
+        BYTE         *sensitiveData;
+} TPM_DAA_BLOB;
+
+typedef struct tdTPM_DAA_SENSITIVE
+{
+    TPM_STRUCTURE_TAG tag;
+    UINT32            internalSize;
+    SIZEIS(internalSize)
+        BYTE         *internalData;
+} TPM_DAA_SENSITIVE;
+
+
+
+//-------------------------------------------------------------------
+// Part 2, section 23: Redirection
+
+// This section of the TPM spec defines exactly one value but does not
+// give it a name. The definition of TPM_SetRedirection in Part3
+// refers to exactly one name but does not give its value. We join
+// them here.
+#define TPM_REDIR_GPIO              (0x00000001)
+
+
+//-------------------------------------------------------------------
+// Part 2, section 24.6: TPM_SYM_MODE
+//    Deprecated by TPM 1.2 spec
+
+typedef UINT32 TPM_SYM_MODE;
+#define TPM_SYM_MODE_ECB            (0x00000001)
+#define TPM_SYM_MODE_CBC            (0x00000002)
+#define TPM_SYM_MODE_CFB            (0x00000003)
+
+#endif // __TPM_H__
+
diff --git a/src/include/tss/tpm_error.h b/src/include/tss/tpm_error.h
index ccd4af4..bd7fe20 100644
--- a/src/include/tss/tpm_error.h
+++ b/src/include/tss/tpm_error.h
@@ -1,963 +1,964 @@
-/*
- * The TPM error codes extracted from the TPM main specification
- * version 1.2 revision 85.
- */
-
-#ifndef __TPM_ERROR_H__
-#define __TPM_ERROR_H__
-
-
-#ifndef TPM_E_BASE
-#define TPM_E_BASE        ((UINT32)0)
-#endif
-
-#ifndef TPM_E_NON_FATAL
-#define TPM_E_NON_FATAL   ((UINT32)0x00000800)
-#endif
-
-
-// Successful completion of the TPM operation.
-#define TPM_SUCCESS    TPM_E_BASE
-
-//
-// MessageId: TPM_E_AUTHFAIL
-//
-// MessageText:
-//
-// Authentication failed
-//
-#define TPM_E_AUTHFAIL ((UINT32)(TPM_E_BASE + 0x00000001))
-
-//
-// MessageId: TPM_E_BADINDEX
-//
-// MessageText:
-//
-// The index to a PCR, DIR or other register is incorrect
-//
-#define TPM_E_BADINDEX ((UINT32)(TPM_E_BASE + 0x00000002))
-
-//
-// MessageId: TPM_E_BAD_PARAMETER
-//
-// MessageText:
-//
-// One or more parameter is bad
-//
-#define TPM_E_BAD_PARAMETER ((UINT32)(TPM_E_BASE + 0x00000003))
-
-//
-// MessageId: TPM_E_AUDITFAILURE
-//
-// MessageText:
-//
-// An operation completed successfully but the auditing of that
-// operation failed.
-//
-#define TPM_E_AUDITFAILURE ((UINT32)(TPM_E_BASE + 0x00000004))
-
-//
-// MessageId: TPM_E_CLEAR_DISABLED
-//
-// MessageText:
-//
-// The clear disable flag is set and all clear operations now require
-// physical access
-//
-#define TPM_E_CLEAR_DISABLED ((UINT32)(TPM_E_BASE + 0x00000005))
-
-//
-// MessageId: TPM_E_DEACTIVATED
-//
-// MessageText:
-//
-// The TPM is deactivated
-//
-#define TPM_E_DEACTIVATED ((UINT32)(TPM_E_BASE + 0x00000006))
-
-//
-// MessageId: TPM_E_DISABLED
-//
-// MessageText:
-//
-// The TPM is disabled
-//
-#define TPM_E_DISABLED ((UINT32)(TPM_E_BASE + 0x00000007))
-
-//
-// MessageId: TPM_E_DISABLED_CMD
-//
-// MessageText:
-//
-// The target command has been disabled
-//
-#define TPM_E_DISABLED_CMD ((UINT32)(TPM_E_BASE + 0x00000008))
-
-//
-// MessageId: TPM_E_FAIL
-//
-// MessageText:
-//
-// The operation failed
-//
-#define TPM_E_FAIL ((UINT32)(TPM_E_BASE + 0x00000009))
-
-//
-// MessageId: TPM_E_BAD_ORDINAL
-//
-// MessageText:
-//
-// The ordinal was unknown or inconsistent
-//
-#define TPM_E_BAD_ORDINAL ((UINT32)(TPM_E_BASE + 0x0000000a))
-
-//
-// MessageId: TPM_E_INSTALL_DISABLED
-//
-// MessageText:
-//
-// The ability to install an owner is disabled
-//
-#define TPM_E_INSTALL_DISABLED ((UINT32)(TPM_E_BASE + 0x0000000b))
-
-//
-// MessageId: TPM_E_INVALID_KEYHANDLE
-//
-// MessageText:
-//
-// The key handle can not be interpreted
-//
-#define TPM_E_INVALID_KEYHANDLE ((UINT32)(TPM_E_BASE + 0x0000000c))
-
-//
-// MessageId: TPM_E_KEYNOTFOUND
-//
-// MessageText:
-//
-// The key handle points to an invalid key
-//
-#define TPM_E_KEYNOTFOUND ((UINT32)(TPM_E_BASE + 0x0000000d))
-
-//
-// MessageId: TPM_E_INAPPROPRIATE_ENC
-//
-// MessageText:
-//
-// Unacceptable encryption scheme
-//
-#define TPM_E_INAPPROPRIATE_ENC ((UINT32)(TPM_E_BASE + 0x0000000e))
-
-//
-// MessageId: TPM_E_MIGRATEFAIL
-//
-// MessageText:
-//
-// Migration authorization failed
-//
-#define TPM_E_MIGRATEFAIL ((UINT32)(TPM_E_BASE + 0x0000000f))
-
-//
-// MessageId: TPM_E_INVALID_PCR_INFO
-//
-// MessageText:
-//
-// PCR information could not be interpreted
-//
-#define TPM_E_INVALID_PCR_INFO ((UINT32)(TPM_E_BASE + 0x00000010))
-
-//
-// MessageId: TPM_E_NOSPACE
-//
-// MessageText:
-//
-// No room to load key.
-//
-#define TPM_E_NOSPACE ((UINT32)(TPM_E_BASE + 0x00000011))
-
-//
-// MessageId: TPM_E_NOSRK
-//
-// MessageText:
-//
-// There is no SRK set
-//
-#define TPM_E_NOSRK ((UINT32)(TPM_E_BASE + 0x00000012))
-
-//
-// MessageId: TPM_E_NOTSEALED_BLOB
-//
-// MessageText:
-//
-// An encrypted blob is invalid or was not created by this TPM
-//
-#define TPM_E_NOTSEALED_BLOB ((UINT32)(TPM_E_BASE + 0x00000013))
-
-//
-// MessageId: TPM_E_OWNER_SET
-//
-// MessageText:
-//
-// There is already an Owner 
-//
-#define TPM_E_OWNER_SET ((UINT32)(TPM_E_BASE + 0x00000014))
-
-//
-// MessageId: TPM_E_RESOURCES
-//
-// MessageText:
-//
-// The TPM has insufficient internal resources to perform the
-// requested action.
-//
-#define TPM_E_RESOURCES ((UINT32)(TPM_E_BASE + 0x00000015))
-
-//
-// MessageId: TPM_E_SHORTRANDOM
-//
-// MessageText:
-//
-// A random string was too short
-//
-#define TPM_E_SHORTRANDOM ((UINT32)(TPM_E_BASE + 0x00000016))
-
-//
-// MessageId: TPM_E_SIZE
-//
-// MessageText:
-//
-// The TPM does not have the space to perform the operation.
-//
-#define TPM_E_SIZE ((UINT32)(TPM_E_BASE + 0x00000017))
-
-//
-// MessageId: TPM_E_WRONGPCRVAL
-//
-// MessageText:
-//
-// The named PCR value does not match the current PCR value.
-//
-#define TPM_E_WRONGPCRVAL ((UINT32)(TPM_E_BASE + 0x00000018))
-
-//
-// MessageId: TPM_E_BAD_PARAM_SIZE 
-//
-// MessageText:
-//
-// The paramSize argument to the command has the incorrect value 
-//
-#define TPM_E_BAD_PARAM_SIZE ((UINT32)(TPM_E_BASE + 0x00000019))
-
-//
-// MessageId: TPM_E_SHA_THREAD
-//
-// MessageText:
-//
-// There is no existing SHA-1 thread.
-//
-#define TPM_E_SHA_THREAD ((UINT32)(TPM_E_BASE + 0x0000001a))
-
-//
-// MessageId: TPM_E_SHA_ERROR
-//
-// MessageText:
-//
-// The calculation is unable to proceed because the existing SHA-1
-// thread has already encountered an error.
-//
-#define TPM_E_SHA_ERROR ((UINT32)(TPM_E_BASE + 0x0000001b))
-
-//
-// MessageId: TPM_E_FAILEDSELFTEST
-//
-// MessageText:
-//
-// Self-test has failed and the TPM has shutdown.
-//
-#define TPM_E_FAILEDSELFTEST ((UINT32)(TPM_E_BASE + 0x0000001c))
-
-//
-// MessageId: TPM_E_AUTH2FAIL
-//
-// MessageText:
-//
-// The authorization for the second key in a 2 key function failed
-// authorization
-//
-#define TPM_E_AUTH2FAIL ((UINT32)(TPM_E_BASE + 0x0000001d))
-
-//
-// MessageId: TPM_E_BADTAG
-//
-// MessageText:
-//
-// The tag value sent to for a command is invalid
-//
-#define TPM_E_BADTAG ((UINT32)(TPM_E_BASE + 0x0000001e))
-
-//
-// MessageId: TPM_E_IOERROR
-//
-// MessageText:
-//
-// An IO error occurred transmitting information to the TPM
-//
-#define TPM_E_IOERROR ((UINT32)(TPM_E_BASE + 0x0000001f))
-
-//
-// MessageId: TPM_E_ENCRYPT_ERROR
-//
-// MessageText:
-//
-// The encryption process had a problem.
-//
-#define TPM_E_ENCRYPT_ERROR ((UINT32)(TPM_E_BASE + 0x00000020))
-
-//
-// MessageId: TPM_E_DECRYPT_ERROR
-//
-// MessageText:
-//
-// The decryption process did not complete.
-//
-#define TPM_E_DECRYPT_ERROR ((UINT32)(TPM_E_BASE + 0x00000021))
-
-//
-// MessageId: TPM_E_INVALID_AUTHHANDLE
-//
-// MessageText:
-//
-// An invalid handle was used.
-//
-#define TPM_E_INVALID_AUTHHANDLE ((UINT32)(TPM_E_BASE + 0x00000022))
-
-//
-// MessageId: TPM_E_NO_ENDORSEMENT
-//
-// MessageText:
-//
-// The TPM does not a EK installed
-//
-#define TPM_E_NO_ENDORSEMENT ((UINT32)(TPM_E_BASE + 0x00000023))
-
-//
-// MessageId: TPM_E_INVALID_KEYUSAGE
-//
-// MessageText:
-//
-// The usage of a key is not allowed
-//
-#define TPM_E_INVALID_KEYUSAGE ((UINT32)(TPM_E_BASE + 0x00000024))
-
-//
-// MessageId: TPM_E_WRONG_ENTITYTYPE
-//
-// MessageText:
-//
-// The submitted entity type is not allowed
-//
-#define TPM_E_WRONG_ENTITYTYPE ((UINT32)(TPM_E_BASE + 0x00000025))
-
-//
-// MessageId: TPM_E_INVALID_POSTINIT
-//
-// MessageText:
-//
-// The command was received in the wrong sequence relative to TPM_Init
-// and a subsequent TPM_Startup
-//
-#define TPM_E_INVALID_POSTINIT ((UINT32)(TPM_E_BASE + 0x00000026))
-
-//
-// MessageId: TPM_E_INAPPROPRIATE_SIG
-//
-// MessageText:
-//
-// Signed data cannot include additional DER information
-//
-#define TPM_E_INAPPROPRIATE_SIG ((UINT32)(TPM_E_BASE + 0x00000027))
-
-//
-// MessageId: TPM_E_BAD_KEY_PROPERTY
-//
-// MessageText:
-//
-// The key properties in TPM_KEY_PARMs are not supported by this TPM
-//
-#define TPM_E_BAD_KEY_PROPERTY ((UINT32)(TPM_E_BASE + 0x00000028))
-
-//
-// MessageId: TPM_E_BAD_MIGRATION
-//
-// MessageText:
-//
-// The migration properties of this key are incorrect.
-//
-#define TPM_E_BAD_MIGRATION ((UINT32)(TPM_E_BASE + 0x00000029))
-
-//
-// MessageId: TPM_E_BAD_SCHEME
-//
-// MessageText:
-//
-// The signature or encryption scheme for this key is incorrect or not
-// permitted in this situation.
-//
-#define TPM_E_BAD_SCHEME ((UINT32)(TPM_E_BASE + 0x0000002a))
-
-//
-// MessageId: TPM_E_BAD_DATASIZE
-//
-// MessageText:
-//
-// The size of the data (or blob) parameter is bad or inconsistent
-// with the referenced key
-//
-#define TPM_E_BAD_DATASIZE ((UINT32)(TPM_E_BASE + 0x0000002b))
-
-//
-// MessageId: TPM_E_BAD_MODE
-//
-// MessageText:
-//
-// A mode parameter is bad, such as capArea or subCapArea for
-// TPM_GetCapability, physicalPresence parameter for
-// TPM_PhysicalPresence, or migrationType for TPM_CreateMigrationBlob.
-//
-#define TPM_E_BAD_MODE ((UINT32)(TPM_E_BASE + 0x0000002c))
-
-//
-// MessageId: TPM_E_BAD_PRESENCE
-//
-// MessageText:
-//
-// Either the physicalPresence or physicalPresenceLock bits have the
-// wrong value
-//
-#define TPM_E_BAD_PRESENCE ((UINT32)(TPM_E_BASE + 0x0000002d))
-
-//
-// MessageId: TPM_E_BAD_VERSION
-//
-// MessageText:
-//
-// The TPM cannot perform this version of the capability
-//
-#define TPM_E_BAD_VERSION ((UINT32)(TPM_E_BASE + 0x0000002e))
-
-//
-// MessageId: TPM_E_NO_WRAP_TRANSPORT
-//
-// MessageText:
-//
-// The TPM does not allow for wrapped transport sessions
-//
-#define TPM_E_NO_WRAP_TRANSPORT ((UINT32)(TPM_E_BASE + 0x0000002f))
-
-//
-// MessageId: TPM_E_AUDITFAIL_UNSUCCESSFUL
-//
-// MessageText:
-//
-// TPM audit construction failed and the underlying command was
-// returning a failure code also
-//
-#define TPM_E_AUDITFAIL_UNSUCCESSFUL ((UINT32)(TPM_E_BASE + 0x00000030))
-
-//
-// MessageId: TPM_E_AUDITFAIL_SUCCESSFUL
-//
-// MessageText:
-//
-// TPM audit construction failed and the underlying command was
-// returning success
-//
-#define TPM_E_AUDITFAIL_SUCCESSFUL ((UINT32)(TPM_E_BASE + 0x00000031))
-
-//
-// MessageId: TPM_E_NOTRESETABLE
-//
-// MessageText:
-//
-// Attempt to reset a PCR register that does not have the resettable
-// attribute
-//
-#define TPM_E_NOTRESETABLE ((UINT32)(TPM_E_BASE + 0x00000032))
-
-//
-// MessageId: TPM_E_NOTLOCAL
-//
-// MessageText:
-//
-// Attempt to reset a PCR register that requires locality and locality
-// modifier not part of command transport
-//
-#define TPM_E_NOTLOCAL ((UINT32)(TPM_E_BASE + 0x00000033))
-
-//
-// MessageId: TPM_E_BAD_TYPE
-//
-// MessageText:
-//
-// Make identity blob not properly typed
-//
-#define TPM_E_BAD_TYPE ((UINT32)(TPM_E_BASE + 0x00000034))
-
-//
-// MessageId: TPM_E_INVALID_RESOURCE
-//
-// MessageText:
-//
-// When saving context identified resource type does not match actual
-// resource
-//
-#define TPM_E_INVALID_RESOURCE ((UINT32)(TPM_E_BASE + 0x00000035))
-
-//
-// MessageId: TPM_E_NOTFIPS
-//
-// MessageText:
-//
-// The TPM is attempting to execute a command only available when in
-// FIPS mode
-//
-#define TPM_E_NOTFIPS ((UINT32)(TPM_E_BASE + 0x00000036))
-
-//
-// MessageId: TPM_E_INVALID_FAMILY
-//
-// MessageText:
-//
-// The command is attempting to use an invalid family ID
-//
-#define TPM_E_INVALID_FAMILY ((UINT32)(TPM_E_BASE + 0x00000037))
-
-//
-// MessageId: TPM_E_NO_NV_PERMISSION
-//
-// MessageText:
-//
-// The permission to manipulate the NV storage is not available
-//
-#define TPM_E_NO_NV_PERMISSION ((UINT32)(TPM_E_BASE + 0x00000038))
-
-//
-// MessageId: TPM_E_REQUIRES_SIGN
-//
-// MessageText:
-//
-// The operation requires a signed command
-//
-#define TPM_E_REQUIRES_SIGN ((UINT32)(TPM_E_BASE + 0x00000039))
-
-//
-// MessageId: TPM_E_KEY_NOTSUPPORTED
-//
-// MessageText:
-//
-// Wrong operation to load an NV key
-//
-#define TPM_E_KEY_NOTSUPPORTED ((UINT32)(TPM_E_BASE + 0x0000003a))
-
-//
-// MessageId: TPM_E_AUTH_CONFLICT
-//
-// MessageText:
-//
-// NV_LoadKey blob requires both owner and blob authorization
-//
-#define TPM_E_AUTH_CONFLICT ((UINT32)(TPM_E_BASE + 0x0000003b))
-
-//
-// MessageId: TPM_E_AREA_LOCKED
-//
-// MessageText:
-//
-// The NV area is locked and not writable
-//
-#define TPM_E_AREA_LOCKED ((UINT32)(TPM_E_BASE + 0x0000003c))
-
-//
-// MessageId: TPM_E_BAD_LOCALITY
-//
-// MessageText:
-//
-// The locality is incorrect for the attempted operation
-//
-#define TPM_E_BAD_LOCALITY ((UINT32)(TPM_E_BASE + 0x0000003d))
-
-//
-// MessageId: TPM_E_READ_ONLY
-//
-// MessageText:
-//
-// The NV area is read only and can't be written to
-//
-#define TPM_E_READ_ONLY ((UINT32)(TPM_E_BASE + 0x0000003e))
-
-//
-// MessageId: TPM_E_PER_NOWRITE
-//
-// MessageText:
-//
-// There is no protection on the write to the NV area
-//
-#define TPM_E_PER_NOWRITE ((UINT32)(TPM_E_BASE + 0x0000003f))
-
-//
-// MessageId: TPM_E_FAMILYCOUNT
-//
-// MessageText:
-//
-// The family count value does not match
-//
-#define TPM_E_FAMILYCOUNT ((UINT32)(TPM_E_BASE + 0x00000040))
-
-//
-// MessageId: TPM_E_WRITE_LOCKED
-//
-// MessageText:
-//
-// The NV area has already been written to
-//
-#define TPM_E_WRITE_LOCKED ((UINT32)(TPM_E_BASE + 0x00000041))
-
-//
-// MessageId: TPM_E_BAD_ATTRIBUTES
-//
-// MessageText:
-//
-// The NV area attributes conflict
-//
-#define TPM_E_BAD_ATTRIBUTES ((UINT32)(TPM_E_BASE + 0x00000042))
-
-//
-// MessageId: TPM_E_INVALID_STRUCTURE
-//
-// MessageText:
-//
-// The structure tag and version are invalid or inconsistent
-//
-#define TPM_E_INVALID_STRUCTURE ((UINT32)(TPM_E_BASE + 0x00000043))
-
-//
-// MessageId: TPM_E_KEY_OWNER_CONTROL
-//
-// MessageText:
-//
-// The key is under control of the TPM Owner and can only be evicted
-// by the TPM Owner.
-//
-#define TPM_E_KEY_OWNER_CONTROL ((UINT32)(TPM_E_BASE + 0x00000044))
-
-//
-// MessageId: TPM_E_BAD_COUNTER
-//
-// MessageText:
-//
-// The counter handle is incorrect
-//
-#define TPM_E_BAD_COUNTER ((UINT32)(TPM_E_BASE + 0x00000045))
-
-//
-// MessageId: TPM_E_NOT_FULLWRITE
-//
-// MessageText:
-//
-// The write is not a complete write of the area
-//
-#define TPM_E_NOT_FULLWRITE ((UINT32)(TPM_E_BASE + 0x00000046))
-
-//
-// MessageId: TPM_E_CONTEXT_GAP
-//
-// MessageText:
-//
-// The gap between saved context counts is too large
-//
-#define TPM_E_CONTEXT_GAP ((UINT32)(TPM_E_BASE + 0x00000047))
-
-//
-// MessageId: TPM_E_MAXNVWRITES
-//
-// MessageText:
-//
-// The maximum number of NV writes without an owner has been exceeded
-//
-#define TPM_E_MAXNVWRITES ((UINT32)(TPM_E_BASE + 0x00000048))
-
-//
-// MessageId: TPM_E_NOOPERATOR
-//
-// MessageText:
-//
-// No operator AuthData value is set
-//
-#define TPM_E_NOOPERATOR ((UINT32)(TPM_E_BASE + 0x00000049))
-
-//
-// MessageId: TPM_E_RESOURCEMISSING
-//
-// MessageText:
-//
-// The resource pointed to by context is not loaded
-//
-#define TPM_E_RESOURCEMISSING ((UINT32)(TPM_E_BASE + 0x0000004a))
-
-//
-// MessageId: TPM_E_DELEGATE_LOCK
-//
-// MessageText:
-//
-// The delegate administration is locked
-//
-#define TPM_E_DELEGATE_LOCK ((UINT32)(TPM_E_BASE + 0x0000004b))
-
-//
-// MessageId: TPM_E_DELEGATE_FAMILY
-//
-// MessageText:
-//
-// Attempt to manage a family other then the delegated family
-//
-#define TPM_E_DELEGATE_FAMILY ((UINT32)(TPM_E_BASE + 0x0000004c))
-
-//
-// MessageId: TPM_E_DELEGATE_ADMIN
-//
-// MessageText:
-//
-// Delegation table management not enabled
-//
-#define TPM_E_DELEGATE_ADMIN ((UINT32)(TPM_E_BASE + 0x0000004d))
-
-//
-// MessageId: TPM_E_TRANSPORT_NOTEXCLUSIVE
-//
-// MessageText:
-//
-// There was a command executed outside of an exclusive transport session
-//
-#define TPM_E_TRANSPORT_NOTEXCLUSIVE ((UINT32)(TPM_E_BASE + 0x0000004e))
-
-//
-// MessageId: TPM_E_OWNER_CONTROL
-//
-// MessageText:
-//
-// Attempt to context save a owner evict controlled key
-//
-#define TPM_E_OWNER_CONTROL ((UINT32)(TPM_E_BASE + 0x0000004f))
-
-//
-// MessageId: TPM_E_DAA_RESOURCES
-//
-// MessageText:
-//
-// The DAA command has no resources available to execute the command
-//
-#define TPM_E_DAA_RESOURCES ((UINT32)(TPM_E_BASE + 0x00000050))
-
-//
-// MessageId: TPM_E_DAA_INPUT_DATA0
-//
-// MessageText:
-//
-// The consistency check on DAA parameter inputData0 has failed.
-//
-#define TPM_E_DAA_INPUT_DATA0 ((UINT32)(TPM_E_BASE + 0x00000051))
-
-//
-// MessageId: TPM_E_DAA_INPUT_DATA1
-//
-// MessageText:
-//
-// The consistency check on DAA parameter inputData1 has failed.
-//
-#define TPM_E_DAA_INPUT_DATA1 ((UINT32)(TPM_E_BASE + 0x00000052))
-
-//
-// MessageId: TPM_E_DAA_ISSUER_SETTINGS
-//
-// MessageText:
-//
-// The consistency check on DAA_issuerSettings has failed.
-//
-#define TPM_E_DAA_ISSUER_SETTINGS ((UINT32)(TPM_E_BASE + 0x00000053))
-
-//
-// MessageId: TPM_E_DAA_TPM_SETTINGS
-//
-// MessageText:
-//
-// The consistency check on DAA_tpmSpecific has failed.
-//
-#define TPM_E_DAA_TPM_SETTINGS ((UINT32)(TPM_E_BASE + 0x00000054))
-
-//
-// MessageId: TPM_E_DAA_STAGE
-//
-// MessageText:
-//
-// The atomic process indicated by the submitted DAA command is not
-// the expected process.
-//
-#define TPM_E_DAA_STAGE ((UINT32)(TPM_E_BASE + 0x00000055))
-
-//
-// MessageId: TPM_E_DAA_ISSUER_VALIDITY
-//
-// MessageText:
-//
-// The issuer's validity check has detected an inconsistency
-//
-#define TPM_E_DAA_ISSUER_VALIDITY ((UINT32)(TPM_E_BASE + 0x00000056))
-
-//
-// MessageId: TPM_E_DAA_WRONG_W
-//
-// MessageText:
-//
-// The consistency check on w has failed.
-//
-#define TPM_E_DAA_WRONG_W ((UINT32)(TPM_E_BASE + 0x00000057))
-
-//
-// MessageId: TPM_E_BAD_HANDLE
-//
-// MessageText:
-//
-// The handle is incorrect
-//
-#define TPM_E_BAD_HANDLE ((UINT32)(TPM_E_BASE + 0x00000058))
-
-//
-// MessageId: TPM_E_BAD_DELEGATE
-//
-// MessageText:
-//
-// Delegation is not correct
-//
-#define TPM_E_BAD_DELEGATE ((UINT32)(TPM_E_BASE + 0x00000059))
-
-//
-// MessageId: TPM_E_BADCONTEXT
-//
-// MessageText:
-//
-// The context blob is invalid
-//
-#define TPM_E_BADCONTEXT ((UINT32)(TPM_E_BASE + 0x0000005a))
-
-//
-// MessageId: TPM_E_TOOMANYCONTEXTS
-//
-// MessageText:
-//
-// Too many contexts held by the TPM
-//
-#define TPM_E_TOOMANYCONTEXTS ((UINT32)(TPM_E_BASE + 0x0000005b))
-
-//
-// MessageId: TPM_E_MA_TICKET_SIGNATURE
-//
-// MessageText:
-//
-// Migration authority signature validation failure
-//
-#define TPM_E_MA_TICKET_SIGNATURE ((UINT32)(TPM_E_BASE + 0x0000005c))
-
-//
-// MessageId: TPM_E_MA_DESTINATION
-//
-// MessageText:
-//
-// Migration destination not authenticated
-//
-#define TPM_E_MA_DESTINATION ((UINT32)(TPM_E_BASE + 0x0000005d))
-
-//
-// MessageId: TPM_E_MA_SOURCE
-//
-// MessageText:
-//
-// Migration source incorrect
-//
-#define TPM_E_MA_SOURCE ((UINT32)(TPM_E_BASE + 0x0000005e))
-
-//
-// MessageId: TPM_E_MA_AUTHORITY
-//
-// MessageText:
-//
-// Incorrect migration authority
-//
-#define TPM_E_MA_AUTHORITY ((UINT32)(TPM_E_BASE + 0x0000005f))
-
-//
-// MessageId: TPM_E_PERMANENTEK
-//
-// MessageText:
-//
-// Attempt to revoke the EK and the EK is not revocable
-//
-#define TPM_E_PERMANENTEK ((UINT32)(TPM_E_BASE + 0x00000061))
-
-//
-// MessageId: TPM_E_BAD_SIGNATURE
-//
-// MessageText:
-//
-// Bad signature of CMK ticket
-//
-#define TPM_E_BAD_SIGNATURE ((UINT32)(TPM_E_BASE + 0x00000062))
-
-//
-// MessageId: TPM_E_NOCONTEXTSPACE
-//
-// MessageText:
-//
-// There is no room in the context list for additional contexts
-//
-#define TPM_E_NOCONTEXTSPACE  ((UINT32)(TPM_E_BASE + 0x00000063))
-
-
-//
-// MessageId: TPM_E_RETRY
-//
-// MessageText:
-//
-// The TPM is too busy to respond to the command immediately, but the
-// command could be resubmitted at a later time. The TPM MAY return
-// TPM_Retry for any command at any time.
-//
-#define TPM_E_RETRY ((UINT32)(TPM_E_BASE + TPM_E_NON_FATAL))
-
-//
-// MessageId: TPM_E_NEEDS_SELFTEST
-//
-// MessageText:
-//
-// SelfTestFull has not been run
-//
-#define TPM_E_NEEDS_SELFTEST ((UINT32)(TPM_E_BASE + TPM_E_NON_FATAL + 1))
-
-//
-// MessageId: TPM_E_DOING_SELFTEST
-//
-// MessageText:
-//
-// The TPM is currently executing a full selftest
-//
-#define TPM_E_DOING_SELFTEST ((UINT32)(TPM_E_BASE + TPM_E_NON_FATAL + 2))
-
-//
-// MessageId: TPM_E_DEFEND_LOCK_RUNNING
-//
-// MessageText:
-//
-// The TPM is defending against dictionary attacks and is in some
-// time-out period.
-//
-#define TPM_E_DEFEND_LOCK_RUNNING ((UINT32)(TPM_E_BASE + TPM_E_NON_FATAL + 3))
-
-#endif /* __TPM_ERROR_H__ */
+/*
+ * The TPM error codes extracted from the TPM main specification
+ * version 1.2 revision 85.
+ */
+
+#ifndef __TPM_ERROR_H__
+#define __TPM_ERROR_H__
+
+
+#ifndef TPM_E_BASE
+#define TPM_E_BASE        ((UINT32)0)
+#endif
+
+#ifndef TPM_E_NON_FATAL
+#define TPM_E_NON_FATAL   ((UINT32)0x00000800)
+#endif
+
+
+// Successful completion of the TPM operation.
+#define TPM_SUCCESS    TPM_E_BASE
+
+//
+// MessageId: TPM_E_AUTHFAIL
+//
+// MessageText:
+//
+// Authentication failed
+//
+#if (!defined (WIN32) || defined(__MINGW32__))
+#define TPM_E_AUTHFAIL ((UINT32)(TPM_E_BASE + 0x00000001))
+
+//
+// MessageId: TPM_E_BADINDEX
+//
+// MessageText:
+//
+// The index to a PCR, DIR or other register is incorrect
+//
+#define TPM_E_BADINDEX ((UINT32)(TPM_E_BASE + 0x00000002))
+
+//
+// MessageId: TPM_E_BAD_PARAMETER
+//
+// MessageText:
+//
+// One or more parameter is bad
+//
+#define TPM_E_BAD_PARAMETER ((UINT32)(TPM_E_BASE + 0x00000003))
+
+//
+// MessageId: TPM_E_AUDITFAILURE
+//
+// MessageText:
+//
+// An operation completed successfully but the auditing of that
+// operation failed.
+//
+#define TPM_E_AUDITFAILURE ((UINT32)(TPM_E_BASE + 0x00000004))
+
+//
+// MessageId: TPM_E_CLEAR_DISABLED
+//
+// MessageText:
+//
+// The clear disable flag is set and all clear operations now require
+// physical access
+//
+#define TPM_E_CLEAR_DISABLED ((UINT32)(TPM_E_BASE + 0x00000005))
+
+//
+// MessageId: TPM_E_DEACTIVATED
+//
+// MessageText:
+//
+// The TPM is deactivated
+//
+#define TPM_E_DEACTIVATED ((UINT32)(TPM_E_BASE + 0x00000006))
+
+//
+// MessageId: TPM_E_DISABLED
+//
+// MessageText:
+//
+// The TPM is disabled
+//
+#define TPM_E_DISABLED ((UINT32)(TPM_E_BASE + 0x00000007))
+
+//
+// MessageId: TPM_E_DISABLED_CMD
+//
+// MessageText:
+//
+// The target command has been disabled
+//
+#define TPM_E_DISABLED_CMD ((UINT32)(TPM_E_BASE + 0x00000008))
+
+//
+// MessageId: TPM_E_FAIL
+//
+// MessageText:
+//
+// The operation failed
+//
+#define TPM_E_FAIL ((UINT32)(TPM_E_BASE + 0x00000009))
+
+//
+// MessageId: TPM_E_BAD_ORDINAL
+//
+// MessageText:
+//
+// The ordinal was unknown or inconsistent
+//
+#define TPM_E_BAD_ORDINAL ((UINT32)(TPM_E_BASE + 0x0000000a))
+
+//
+// MessageId: TPM_E_INSTALL_DISABLED
+//
+// MessageText:
+//
+// The ability to install an owner is disabled
+//
+#define TPM_E_INSTALL_DISABLED ((UINT32)(TPM_E_BASE + 0x0000000b))
+
+//
+// MessageId: TPM_E_INVALID_KEYHANDLE
+//
+// MessageText:
+//
+// The key handle can not be interpreted
+//
+#define TPM_E_INVALID_KEYHANDLE ((UINT32)(TPM_E_BASE + 0x0000000c))
+
+//
+// MessageId: TPM_E_KEYNOTFOUND
+//
+// MessageText:
+//
+// The key handle points to an invalid key
+//
+#define TPM_E_KEYNOTFOUND ((UINT32)(TPM_E_BASE + 0x0000000d))
+
+//
+// MessageId: TPM_E_INAPPROPRIATE_ENC
+//
+// MessageText:
+//
+// Unacceptable encryption scheme
+//
+#define TPM_E_INAPPROPRIATE_ENC ((UINT32)(TPM_E_BASE + 0x0000000e))
+
+//
+// MessageId: TPM_E_MIGRATEFAIL
+//
+// MessageText:
+//
+// Migration authorization failed
+//
+#define TPM_E_MIGRATEFAIL ((UINT32)(TPM_E_BASE + 0x0000000f))
+
+//
+// MessageId: TPM_E_INVALID_PCR_INFO
+//
+// MessageText:
+//
+// PCR information could not be interpreted
+//
+#define TPM_E_INVALID_PCR_INFO ((UINT32)(TPM_E_BASE + 0x00000010))
+
+//
+// MessageId: TPM_E_NOSPACE
+//
+// MessageText:
+//
+// No room to load key.
+//
+#define TPM_E_NOSPACE ((UINT32)(TPM_E_BASE + 0x00000011))
+
+//
+// MessageId: TPM_E_NOSRK
+//
+// MessageText:
+//
+// There is no SRK set
+//
+#define TPM_E_NOSRK ((UINT32)(TPM_E_BASE + 0x00000012))
+
+//
+// MessageId: TPM_E_NOTSEALED_BLOB
+//
+// MessageText:
+//
+// An encrypted blob is invalid or was not created by this TPM
+//
+#define TPM_E_NOTSEALED_BLOB ((UINT32)(TPM_E_BASE + 0x00000013))
+
+//
+// MessageId: TPM_E_OWNER_SET
+//
+// MessageText:
+//
+// There is already an Owner 
+//
+#define TPM_E_OWNER_SET ((UINT32)(TPM_E_BASE + 0x00000014))
+
+//
+// MessageId: TPM_E_RESOURCES
+//
+// MessageText:
+//
+// The TPM has insufficient internal resources to perform the
+// requested action.
+//
+#define TPM_E_RESOURCES ((UINT32)(TPM_E_BASE + 0x00000015))
+
+//
+// MessageId: TPM_E_SHORTRANDOM
+//
+// MessageText:
+//
+// A random string was too short
+//
+#define TPM_E_SHORTRANDOM ((UINT32)(TPM_E_BASE + 0x00000016))
+
+//
+// MessageId: TPM_E_SIZE
+//
+// MessageText:
+//
+// The TPM does not have the space to perform the operation.
+//
+#define TPM_E_SIZE ((UINT32)(TPM_E_BASE + 0x00000017))
+
+//
+// MessageId: TPM_E_WRONGPCRVAL
+//
+// MessageText:
+//
+// The named PCR value does not match the current PCR value.
+//
+#define TPM_E_WRONGPCRVAL ((UINT32)(TPM_E_BASE + 0x00000018))
+
+//
+// MessageId: TPM_E_BAD_PARAM_SIZE 
+//
+// MessageText:
+//
+// The paramSize argument to the command has the incorrect value 
+//
+#define TPM_E_BAD_PARAM_SIZE ((UINT32)(TPM_E_BASE + 0x00000019))
+
+//
+// MessageId: TPM_E_SHA_THREAD
+//
+// MessageText:
+//
+// There is no existing SHA-1 thread.
+//
+#define TPM_E_SHA_THREAD ((UINT32)(TPM_E_BASE + 0x0000001a))
+
+//
+// MessageId: TPM_E_SHA_ERROR
+//
+// MessageText:
+//
+// The calculation is unable to proceed because the existing SHA-1
+// thread has already encountered an error.
+//
+#define TPM_E_SHA_ERROR ((UINT32)(TPM_E_BASE + 0x0000001b))
+
+//
+// MessageId: TPM_E_FAILEDSELFTEST
+//
+// MessageText:
+//
+// Self-test has failed and the TPM has shutdown.
+//
+#define TPM_E_FAILEDSELFTEST ((UINT32)(TPM_E_BASE + 0x0000001c))
+
+//
+// MessageId: TPM_E_AUTH2FAIL
+//
+// MessageText:
+//
+// The authorization for the second key in a 2 key function failed
+// authorization
+//
+#define TPM_E_AUTH2FAIL ((UINT32)(TPM_E_BASE + 0x0000001d))
+
+//
+// MessageId: TPM_E_BADTAG
+//
+// MessageText:
+//
+// The tag value sent to for a command is invalid
+//
+#define TPM_E_BADTAG ((UINT32)(TPM_E_BASE + 0x0000001e))
+
+//
+// MessageId: TPM_E_IOERROR
+//
+// MessageText:
+//
+// An IO error occurred transmitting information to the TPM
+//
+#define TPM_E_IOERROR ((UINT32)(TPM_E_BASE + 0x0000001f))
+
+//
+// MessageId: TPM_E_ENCRYPT_ERROR
+//
+// MessageText:
+//
+// The encryption process had a problem.
+//
+#define TPM_E_ENCRYPT_ERROR ((UINT32)(TPM_E_BASE + 0x00000020))
+
+//
+// MessageId: TPM_E_DECRYPT_ERROR
+//
+// MessageText:
+//
+// The decryption process did not complete.
+//
+#define TPM_E_DECRYPT_ERROR ((UINT32)(TPM_E_BASE + 0x00000021))
+
+//
+// MessageId: TPM_E_INVALID_AUTHHANDLE
+//
+// MessageText:
+//
+// An invalid handle was used.
+//
+#define TPM_E_INVALID_AUTHHANDLE ((UINT32)(TPM_E_BASE + 0x00000022))
+
+//
+// MessageId: TPM_E_NO_ENDORSEMENT
+//
+// MessageText:
+//
+// The TPM does not a EK installed
+//
+#define TPM_E_NO_ENDORSEMENT ((UINT32)(TPM_E_BASE + 0x00000023))
+
+//
+// MessageId: TPM_E_INVALID_KEYUSAGE
+//
+// MessageText:
+//
+// The usage of a key is not allowed
+//
+#define TPM_E_INVALID_KEYUSAGE ((UINT32)(TPM_E_BASE + 0x00000024))
+
+//
+// MessageId: TPM_E_WRONG_ENTITYTYPE
+//
+// MessageText:
+//
+// The submitted entity type is not allowed
+//
+#define TPM_E_WRONG_ENTITYTYPE ((UINT32)(TPM_E_BASE + 0x00000025))
+
+//
+// MessageId: TPM_E_INVALID_POSTINIT
+//
+// MessageText:
+//
+// The command was received in the wrong sequence relative to TPM_Init
+// and a subsequent TPM_Startup
+//
+#define TPM_E_INVALID_POSTINIT ((UINT32)(TPM_E_BASE + 0x00000026))
+
+//
+// MessageId: TPM_E_INAPPROPRIATE_SIG
+//
+// MessageText:
+//
+// Signed data cannot include additional DER information
+//
+#define TPM_E_INAPPROPRIATE_SIG ((UINT32)(TPM_E_BASE + 0x00000027))
+
+//
+// MessageId: TPM_E_BAD_KEY_PROPERTY
+//
+// MessageText:
+//
+// The key properties in TPM_KEY_PARMs are not supported by this TPM
+//
+#define TPM_E_BAD_KEY_PROPERTY ((UINT32)(TPM_E_BASE + 0x00000028))
+
+//
+// MessageId: TPM_E_BAD_MIGRATION
+//
+// MessageText:
+//
+// The migration properties of this key are incorrect.
+//
+#define TPM_E_BAD_MIGRATION ((UINT32)(TPM_E_BASE + 0x00000029))
+
+//
+// MessageId: TPM_E_BAD_SCHEME
+//
+// MessageText:
+//
+// The signature or encryption scheme for this key is incorrect or not
+// permitted in this situation.
+//
+#define TPM_E_BAD_SCHEME ((UINT32)(TPM_E_BASE + 0x0000002a))
+
+//
+// MessageId: TPM_E_BAD_DATASIZE
+//
+// MessageText:
+//
+// The size of the data (or blob) parameter is bad or inconsistent
+// with the referenced key
+//
+#define TPM_E_BAD_DATASIZE ((UINT32)(TPM_E_BASE + 0x0000002b))
+
+//
+// MessageId: TPM_E_BAD_MODE
+//
+// MessageText:
+//
+// A mode parameter is bad, such as capArea or subCapArea for
+// TPM_GetCapability, physicalPresence parameter for
+// TPM_PhysicalPresence, or migrationType for TPM_CreateMigrationBlob.
+//
+#define TPM_E_BAD_MODE ((UINT32)(TPM_E_BASE + 0x0000002c))
+
+//
+// MessageId: TPM_E_BAD_PRESENCE
+//
+// MessageText:
+//
+// Either the physicalPresence or physicalPresenceLock bits have the
+// wrong value
+//
+#define TPM_E_BAD_PRESENCE ((UINT32)(TPM_E_BASE + 0x0000002d))
+
+//
+// MessageId: TPM_E_BAD_VERSION
+//
+// MessageText:
+//
+// The TPM cannot perform this version of the capability
+//
+#define TPM_E_BAD_VERSION ((UINT32)(TPM_E_BASE + 0x0000002e))
+
+//
+// MessageId: TPM_E_NO_WRAP_TRANSPORT
+//
+// MessageText:
+//
+// The TPM does not allow for wrapped transport sessions
+//
+#define TPM_E_NO_WRAP_TRANSPORT ((UINT32)(TPM_E_BASE + 0x0000002f))
+
+//
+// MessageId: TPM_E_AUDITFAIL_UNSUCCESSFUL
+//
+// MessageText:
+//
+// TPM audit construction failed and the underlying command was
+// returning a failure code also
+//
+#define TPM_E_AUDITFAIL_UNSUCCESSFUL ((UINT32)(TPM_E_BASE + 0x00000030))
+
+//
+// MessageId: TPM_E_AUDITFAIL_SUCCESSFUL
+//
+// MessageText:
+//
+// TPM audit construction failed and the underlying command was
+// returning success
+//
+#define TPM_E_AUDITFAIL_SUCCESSFUL ((UINT32)(TPM_E_BASE + 0x00000031))
+
+//
+// MessageId: TPM_E_NOTRESETABLE
+//
+// MessageText:
+//
+// Attempt to reset a PCR register that does not have the resettable
+// attribute
+//
+#define TPM_E_NOTRESETABLE ((UINT32)(TPM_E_BASE + 0x00000032))
+
+//
+// MessageId: TPM_E_NOTLOCAL
+//
+// MessageText:
+//
+// Attempt to reset a PCR register that requires locality and locality
+// modifier not part of command transport
+//
+#define TPM_E_NOTLOCAL ((UINT32)(TPM_E_BASE + 0x00000033))
+
+//
+// MessageId: TPM_E_BAD_TYPE
+//
+// MessageText:
+//
+// Make identity blob not properly typed
+//
+#define TPM_E_BAD_TYPE ((UINT32)(TPM_E_BASE + 0x00000034))
+
+//
+// MessageId: TPM_E_INVALID_RESOURCE
+//
+// MessageText:
+//
+// When saving context identified resource type does not match actual
+// resource
+//
+#define TPM_E_INVALID_RESOURCE ((UINT32)(TPM_E_BASE + 0x00000035))
+
+//
+// MessageId: TPM_E_NOTFIPS
+//
+// MessageText:
+//
+// The TPM is attempting to execute a command only available when in
+// FIPS mode
+//
+#define TPM_E_NOTFIPS ((UINT32)(TPM_E_BASE + 0x00000036))
+
+//
+// MessageId: TPM_E_INVALID_FAMILY
+//
+// MessageText:
+//
+// The command is attempting to use an invalid family ID
+//
+#define TPM_E_INVALID_FAMILY ((UINT32)(TPM_E_BASE + 0x00000037))
+
+//
+// MessageId: TPM_E_NO_NV_PERMISSION
+//
+// MessageText:
+//
+// The permission to manipulate the NV storage is not available
+//
+#define TPM_E_NO_NV_PERMISSION ((UINT32)(TPM_E_BASE + 0x00000038))
+
+//
+// MessageId: TPM_E_REQUIRES_SIGN
+//
+// MessageText:
+//
+// The operation requires a signed command
+//
+#define TPM_E_REQUIRES_SIGN ((UINT32)(TPM_E_BASE + 0x00000039))
+
+//
+// MessageId: TPM_E_KEY_NOTSUPPORTED
+//
+// MessageText:
+//
+// Wrong operation to load an NV key
+//
+#define TPM_E_KEY_NOTSUPPORTED ((UINT32)(TPM_E_BASE + 0x0000003a))
+
+//
+// MessageId: TPM_E_AUTH_CONFLICT
+//
+// MessageText:
+//
+// NV_LoadKey blob requires both owner and blob authorization
+//
+#define TPM_E_AUTH_CONFLICT ((UINT32)(TPM_E_BASE + 0x0000003b))
+
+//
+// MessageId: TPM_E_AREA_LOCKED
+//
+// MessageText:
+//
+// The NV area is locked and not writable
+//
+#define TPM_E_AREA_LOCKED ((UINT32)(TPM_E_BASE + 0x0000003c))
+
+//
+// MessageId: TPM_E_BAD_LOCALITY
+//
+// MessageText:
+//
+// The locality is incorrect for the attempted operation
+//
+#define TPM_E_BAD_LOCALITY ((UINT32)(TPM_E_BASE + 0x0000003d))
+
+//
+// MessageId: TPM_E_READ_ONLY
+//
+// MessageText:
+//
+// The NV area is read only and can't be written to
+//
+#define TPM_E_READ_ONLY ((UINT32)(TPM_E_BASE + 0x0000003e))
+
+//
+// MessageId: TPM_E_PER_NOWRITE
+//
+// MessageText:
+//
+// There is no protection on the write to the NV area
+//
+#define TPM_E_PER_NOWRITE ((UINT32)(TPM_E_BASE + 0x0000003f))
+
+//
+// MessageId: TPM_E_FAMILYCOUNT
+//
+// MessageText:
+//
+// The family count value does not match
+//
+#define TPM_E_FAMILYCOUNT ((UINT32)(TPM_E_BASE + 0x00000040))
+
+//
+// MessageId: TPM_E_WRITE_LOCKED
+//
+// MessageText:
+//
+// The NV area has already been written to
+//
+#define TPM_E_WRITE_LOCKED ((UINT32)(TPM_E_BASE + 0x00000041))
+
+//
+// MessageId: TPM_E_BAD_ATTRIBUTES
+//
+// MessageText:
+//
+// The NV area attributes conflict
+//
+#define TPM_E_BAD_ATTRIBUTES ((UINT32)(TPM_E_BASE + 0x00000042))
+
+//
+// MessageId: TPM_E_INVALID_STRUCTURE
+//
+// MessageText:
+//
+// The structure tag and version are invalid or inconsistent
+//
+#define TPM_E_INVALID_STRUCTURE ((UINT32)(TPM_E_BASE + 0x00000043))
+
+//
+// MessageId: TPM_E_KEY_OWNER_CONTROL
+//
+// MessageText:
+//
+// The key is under control of the TPM Owner and can only be evicted
+// by the TPM Owner.
+//
+#define TPM_E_KEY_OWNER_CONTROL ((UINT32)(TPM_E_BASE + 0x00000044))
+
+//
+// MessageId: TPM_E_BAD_COUNTER
+//
+// MessageText:
+//
+// The counter handle is incorrect
+//
+#define TPM_E_BAD_COUNTER ((UINT32)(TPM_E_BASE + 0x00000045))
+
+//
+// MessageId: TPM_E_NOT_FULLWRITE
+//
+// MessageText:
+//
+// The write is not a complete write of the area
+//
+#define TPM_E_NOT_FULLWRITE ((UINT32)(TPM_E_BASE + 0x00000046))
+
+//
+// MessageId: TPM_E_CONTEXT_GAP
+//
+// MessageText:
+//
+// The gap between saved context counts is too large
+//
+#define TPM_E_CONTEXT_GAP ((UINT32)(TPM_E_BASE + 0x00000047))
+
+//
+// MessageId: TPM_E_MAXNVWRITES
+//
+// MessageText:
+//
+// The maximum number of NV writes without an owner has been exceeded
+//
+#define TPM_E_MAXNVWRITES ((UINT32)(TPM_E_BASE + 0x00000048))
+
+//
+// MessageId: TPM_E_NOOPERATOR
+//
+// MessageText:
+//
+// No operator AuthData value is set
+//
+#define TPM_E_NOOPERATOR ((UINT32)(TPM_E_BASE + 0x00000049))
+
+//
+// MessageId: TPM_E_RESOURCEMISSING
+//
+// MessageText:
+//
+// The resource pointed to by context is not loaded
+//
+#define TPM_E_RESOURCEMISSING ((UINT32)(TPM_E_BASE + 0x0000004a))
+
+//
+// MessageId: TPM_E_DELEGATE_LOCK
+//
+// MessageText:
+//
+// The delegate administration is locked
+//
+#define TPM_E_DELEGATE_LOCK ((UINT32)(TPM_E_BASE + 0x0000004b))
+
+//
+// MessageId: TPM_E_DELEGATE_FAMILY
+//
+// MessageText:
+//
+// Attempt to manage a family other then the delegated family
+//
+#define TPM_E_DELEGATE_FAMILY ((UINT32)(TPM_E_BASE + 0x0000004c))
+
+//
+// MessageId: TPM_E_DELEGATE_ADMIN
+//
+// MessageText:
+//
+// Delegation table management not enabled
+//
+#define TPM_E_DELEGATE_ADMIN ((UINT32)(TPM_E_BASE + 0x0000004d))
+
+//
+// MessageId: TPM_E_TRANSPORT_NOTEXCLUSIVE
+//
+// MessageText:
+//
+// There was a command executed outside of an exclusive transport session
+//
+#define TPM_E_TRANSPORT_NOTEXCLUSIVE ((UINT32)(TPM_E_BASE + 0x0000004e))
+
+//
+// MessageId: TPM_E_OWNER_CONTROL
+//
+// MessageText:
+//
+// Attempt to context save a owner evict controlled key
+//
+#define TPM_E_OWNER_CONTROL ((UINT32)(TPM_E_BASE + 0x0000004f))
+
+//
+// MessageId: TPM_E_DAA_RESOURCES
+//
+// MessageText:
+//
+// The DAA command has no resources available to execute the command
+//
+#define TPM_E_DAA_RESOURCES ((UINT32)(TPM_E_BASE + 0x00000050))
+
+//
+// MessageId: TPM_E_DAA_INPUT_DATA0
+//
+// MessageText:
+//
+// The consistency check on DAA parameter inputData0 has failed.
+//
+#define TPM_E_DAA_INPUT_DATA0 ((UINT32)(TPM_E_BASE + 0x00000051))
+
+//
+// MessageId: TPM_E_DAA_INPUT_DATA1
+//
+// MessageText:
+//
+// The consistency check on DAA parameter inputData1 has failed.
+//
+#define TPM_E_DAA_INPUT_DATA1 ((UINT32)(TPM_E_BASE + 0x00000052))
+
+//
+// MessageId: TPM_E_DAA_ISSUER_SETTINGS
+//
+// MessageText:
+//
+// The consistency check on DAA_issuerSettings has failed.
+//
+#define TPM_E_DAA_ISSUER_SETTINGS ((UINT32)(TPM_E_BASE + 0x00000053))
+
+//
+// MessageId: TPM_E_DAA_TPM_SETTINGS
+//
+// MessageText:
+//
+// The consistency check on DAA_tpmSpecific has failed.
+//
+#define TPM_E_DAA_TPM_SETTINGS ((UINT32)(TPM_E_BASE + 0x00000054))
+
+//
+// MessageId: TPM_E_DAA_STAGE
+//
+// MessageText:
+//
+// The atomic process indicated by the submitted DAA command is not
+// the expected process.
+//
+#define TPM_E_DAA_STAGE ((UINT32)(TPM_E_BASE + 0x00000055))
+
+//
+// MessageId: TPM_E_DAA_ISSUER_VALIDITY
+//
+// MessageText:
+//
+// The issuer's validity check has detected an inconsistency
+//
+#define TPM_E_DAA_ISSUER_VALIDITY ((UINT32)(TPM_E_BASE + 0x00000056))
+
+//
+// MessageId: TPM_E_DAA_WRONG_W
+//
+// MessageText:
+//
+// The consistency check on w has failed.
+//
+#define TPM_E_DAA_WRONG_W ((UINT32)(TPM_E_BASE + 0x00000057))
+
+//
+// MessageId: TPM_E_BAD_HANDLE
+//
+// MessageText:
+//
+// The handle is incorrect
+//
+#define TPM_E_BAD_HANDLE ((UINT32)(TPM_E_BASE + 0x00000058))
+
+//
+// MessageId: TPM_E_BAD_DELEGATE
+//
+// MessageText:
+//
+// Delegation is not correct
+//
+#define TPM_E_BAD_DELEGATE ((UINT32)(TPM_E_BASE + 0x00000059))
+
+//
+// MessageId: TPM_E_BADCONTEXT
+//
+// MessageText:
+//
+// The context blob is invalid
+//
+#define TPM_E_BADCONTEXT ((UINT32)(TPM_E_BASE + 0x0000005a))
+
+//
+// MessageId: TPM_E_TOOMANYCONTEXTS
+//
+// MessageText:
+//
+// Too many contexts held by the TPM
+//
+#define TPM_E_TOOMANYCONTEXTS ((UINT32)(TPM_E_BASE + 0x0000005b))
+
+//
+// MessageId: TPM_E_MA_TICKET_SIGNATURE
+//
+// MessageText:
+//
+// Migration authority signature validation failure
+//
+#define TPM_E_MA_TICKET_SIGNATURE ((UINT32)(TPM_E_BASE + 0x0000005c))
+
+//
+// MessageId: TPM_E_MA_DESTINATION
+//
+// MessageText:
+//
+// Migration destination not authenticated
+//
+#define TPM_E_MA_DESTINATION ((UINT32)(TPM_E_BASE + 0x0000005d))
+
+//
+// MessageId: TPM_E_MA_SOURCE
+//
+// MessageText:
+//
+// Migration source incorrect
+//
+#define TPM_E_MA_SOURCE ((UINT32)(TPM_E_BASE + 0x0000005e))
+
+//
+// MessageId: TPM_E_MA_AUTHORITY
+//
+// MessageText:
+//
+// Incorrect migration authority
+//
+#define TPM_E_MA_AUTHORITY ((UINT32)(TPM_E_BASE + 0x0000005f))
+
+//
+// MessageId: TPM_E_PERMANENTEK
+//
+// MessageText:
+//
+// Attempt to revoke the EK and the EK is not revocable
+//
+#define TPM_E_PERMANENTEK ((UINT32)(TPM_E_BASE + 0x00000061))
+
+//
+// MessageId: TPM_E_BAD_SIGNATURE
+//
+// MessageText:
+//
+// Bad signature of CMK ticket
+//
+#define TPM_E_BAD_SIGNATURE ((UINT32)(TPM_E_BASE + 0x00000062))
+
+//
+// MessageId: TPM_E_NOCONTEXTSPACE
+//
+// MessageText:
+//
+// There is no room in the context list for additional contexts
+//
+#define TPM_E_NOCONTEXTSPACE  ((UINT32)(TPM_E_BASE + 0x00000063))
+
+
+//
+// MessageId: TPM_E_RETRY
+//
+// MessageText:
+//
+// The TPM is too busy to respond to the command immediately, but the
+// command could be resubmitted at a later time. The TPM MAY return
+// TPM_Retry for any command at any time.
+//
+#define TPM_E_RETRY ((UINT32)(TPM_E_BASE + TPM_E_NON_FATAL))
+
+//
+// MessageId: TPM_E_NEEDS_SELFTEST
+//
+// MessageText:
+//
+// SelfTestFull has not been run
+//
+#define TPM_E_NEEDS_SELFTEST ((UINT32)(TPM_E_BASE + TPM_E_NON_FATAL + 1))
+
+//
+// MessageId: TPM_E_DOING_SELFTEST
+//
+// MessageText:
+//
+// The TPM is currently executing a full selftest
+//
+#define TPM_E_DOING_SELFTEST ((UINT32)(TPM_E_BASE + TPM_E_NON_FATAL + 2))
+
+//
+// MessageId: TPM_E_DEFEND_LOCK_RUNNING
+//
+// MessageText:
+//
+// The TPM is defending against dictionary attacks and is in some
+// time-out period.
+//
+#define TPM_E_DEFEND_LOCK_RUNNING ((UINT32)(TPM_E_BASE + TPM_E_NON_FATAL + 3))
+#endif /* !WIN32 && __MINGW32__ */
+#endif /* __TPM_ERROR_H__ */
diff --git a/src/include/tss/tpm_ordinal.h b/src/include/tss/tpm_ordinal.h
index 9df9959..ca09611 100644
--- a/src/include/tss/tpm_ordinal.h
+++ b/src/include/tss/tpm_ordinal.h
@@ -1,151 +1,151 @@
-/*
- * TPM Ordinal definitions extracted from the TPM 1.2 specification, rev 85.
- */
-
-#ifndef __TPM_ORDINAL_H__
-#define __TPM_ORDINAL_H__
-
-#define TPM_PROTECTED_COMMAND                     ((UINT32)(0x00000000))
-#define TPM_UNPROTECTED_COMMAND                   ((UINT32)(0x80000000))
-#define TPM_CONNECTION_COMMAND                    ((UINT32)(0x40000000))
-#define TPM_VENDOR_COMMAND                        ((UINT32)(0x20000000))
-
-#define TPM_MAIN                                  ((UINT16)(0x0000))
-#define TPM_PC                                    ((UINT16)(0x0001))
-#define TPM_PDA                                   ((UINT16)(0x0002))
-#define TPM_CELL_PHONE                            ((UINT16)(0x0003))
-#define TPM_SERVER                                ((UINT16)(0x0004))
-
-#define TPM_PROTECTED_ORDINAL              (TPM_MAIN | TPM_PROTECTED_COMMAND)
-#define TPM_UNPROTECTED_ORDINAL            (TPM_MAIN | TPM_UNPROTECTED_COMMAND)
-#define TPM_CONNECTION_ORDINAL             (TPM_MAIN | TPM_CONNECTION_COMMAND)
-
-
-#define TPM_ORD_OIAP                              ((UINT32)0x0000000A)
-#define TPM_ORD_OSAP                              ((UINT32)0x0000000B)
-#define TPM_ORD_ChangeAuth                        ((UINT32)0x0000000C)
-#define TPM_ORD_TakeOwnership                     ((UINT32)0x0000000D)
-#define TPM_ORD_ChangeAuthAsymStart               ((UINT32)0x0000000E)
-#define TPM_ORD_ChangeAuthAsymFinish              ((UINT32)0x0000000F)
-#define TPM_ORD_ChangeAuthOwner                   ((UINT32)0x00000010)
-#define TPM_ORD_DSAP                              ((UINT32)0x00000011)
-#define TPM_ORD_CMK_CreateTicket                  ((UINT32)0x00000012)
-#define TPM_ORD_CMK_CreateKey                     ((UINT32)0x00000013)
-#define TPM_ORD_Extend                            ((UINT32)0x00000014)
-#define TPM_ORD_PcrRead                           ((UINT32)0x00000015)
-#define TPM_ORD_Quote                             ((UINT32)0x00000016)
-#define TPM_ORD_Seal                              ((UINT32)0x00000017)
-#define TPM_ORD_Unseal                            ((UINT32)0x00000018)
-#define TPM_ORD_DirWriteAuth                      ((UINT32)0x00000019)
-#define TPM_ORD_DirRead                           ((UINT32)0x0000001A)
-#define TPM_ORD_CMK_CreateBlob                    ((UINT32)0x0000001B)
-#define TPM_ORD_CMK_SetRestrictions               ((UINT32)0x0000001C)
-#define TPM_ORD_CMK_ApproveMA                     ((UINT32)0x0000001D)
-#define TPM_ORD_UnBind                            ((UINT32)0x0000001E)
-#define TPM_ORD_CreateWrapKey                     ((UINT32)0x0000001F)
-#define TPM_ORD_LoadKey                           ((UINT32)0x00000020)
-#define TPM_ORD_GetPubKey                         ((UINT32)0x00000021)
-#define TPM_ORD_EvictKey                          ((UINT32)0x00000022)
-#define TPM_ORD_KeyControlOwner                   ((UINT32)0x00000023)
-#define TPM_ORD_CMK_ConvertMigration              ((UINT32)0x00000024)
-#define TPM_ORD_MigrateKey                        ((UINT32)0x00000025)
-#define TPM_ORD_CreateMigrationBlob               ((UINT32)0x00000028)
-#define TPM_ORD_DAA_Join                          ((UINT32)0x00000029)
-#define TPM_ORD_ConvertMigrationBlob              ((UINT32)0x0000002A)
-#define TPM_ORD_AuthorizeMigrationKey             ((UINT32)0x0000002B)
-#define TPM_ORD_CreateMaintenanceArchive          ((UINT32)0x0000002C)
-#define TPM_ORD_LoadMaintenanceArchive            ((UINT32)0x0000002D)
-#define TPM_ORD_KillMaintenanceFeature            ((UINT32)0x0000002E)
-#define TPM_ORD_LoadManuMaintPub                  ((UINT32)0x0000002F)
-#define TPM_ORD_ReadManuMaintPub                  ((UINT32)0x00000030)
-#define TPM_ORD_DAA_Sign                          ((UINT32)0x00000031)
-#define TPM_ORD_CertifyKey                        ((UINT32)0x00000032)
-#define TPM_ORD_CertifyKey2                       ((UINT32)0x00000033)
-#define TPM_ORD_Sign                              ((UINT32)0x0000003C)
-#define TPM_ORD_Sealx                             ((UINT32)0x0000003D)
-#define TPM_ORD_Quote2                            ((UINT32)0x0000003E)
-#define TPM_ORD_SetCapability                     ((UINT32)0x0000003F)
-#define TPM_ORD_ResetLockValue                    ((UINT32)0x00000040)
-#define TPM_ORD_LoadKey2                          ((UINT32)0x00000041)
-#define TPM_ORD_GetRandom                         ((UINT32)0x00000046)
-#define TPM_ORD_StirRandom                        ((UINT32)0x00000047)
-#define TPM_ORD_SelfTestFull                      ((UINT32)0x00000050)
-#define TPM_ORD_CertifySelfTest                   ((UINT32)0x00000052)
-#define TPM_ORD_ContinueSelfTest                  ((UINT32)0x00000053)
-#define TPM_ORD_GetTestResult                     ((UINT32)0x00000054)
-#define TPM_ORD_Reset                             ((UINT32)0x0000005A)
-#define TPM_ORD_OwnerClear                        ((UINT32)0x0000005B)
-#define TPM_ORD_DisableOwnerClear                 ((UINT32)0x0000005C)
-#define TPM_ORD_ForceClear                        ((UINT32)0x0000005D)
-#define TPM_ORD_DisableForceClear                 ((UINT32)0x0000005E)
-#define TPM_ORD_GetCapabilitySigned               ((UINT32)0x00000064)
-#define TPM_ORD_GetCapability                     ((UINT32)0x00000065)
-#define TPM_ORD_GetCapabilityOwner                ((UINT32)0x00000066)
-#define TPM_ORD_OwnerSetDisable                   ((UINT32)0x0000006E)
-#define TPM_ORD_PhysicalEnable                    ((UINT32)0x0000006F)
-#define TPM_ORD_PhysicalDisable                   ((UINT32)0x00000070)
-#define TPM_ORD_SetOwnerInstall                   ((UINT32)0x00000071)
-#define TPM_ORD_PhysicalSetDeactivated            ((UINT32)0x00000072)
-#define TPM_ORD_SetTempDeactivated                ((UINT32)0x00000073)
-#define TPM_ORD_SetOperatorAuth                   ((UINT32)0x00000074)
-#define TPM_ORD_SetOwnerPointer                   ((UINT32)0x00000075)
-#define TPM_ORD_CreateEndorsementKeyPair          ((UINT32)0x00000078)
-#define TPM_ORD_MakeIdentity                      ((UINT32)0x00000079)
-#define TPM_ORD_ActivateIdentity                  ((UINT32)0x0000007A)
-#define TPM_ORD_ReadPubek                         ((UINT32)0x0000007C)
-#define TPM_ORD_OwnerReadPubek                    ((UINT32)0x0000007D)
-#define TPM_ORD_DisablePubekRead                  ((UINT32)0x0000007E)
-#define TPM_ORD_CreateRevocableEK                 ((UINT32)0x0000007F)
-#define TPM_ORD_RevokeTrust                       ((UINT32)0x00000080)
-#define TPM_ORD_OwnerReadInternalPub              ((UINT32)0x00000081)
-#define TPM_ORD_GetAuditEvent                     ((UINT32)0x00000082)
-#define TPM_ORD_GetAuditEventSigned               ((UINT32)0x00000083)
-#define TPM_ORD_GetAuditDigest                    ((UINT32)0x00000085)
-#define TPM_ORD_GetAuditDigestSigned              ((UINT32)0x00000086)
-#define TPM_ORD_GetOrdinalAuditStatus             ((UINT32)0x0000008C)
-#define TPM_ORD_SetOrdinalAuditStatus             ((UINT32)0x0000008D)
-#define TPM_ORD_Terminate_Handle                  ((UINT32)0x00000096)
-#define TPM_ORD_Init                              ((UINT32)0x00000097)
-#define TPM_ORD_SaveState                         ((UINT32)0x00000098)
-#define TPM_ORD_Startup                           ((UINT32)0x00000099)
-#define TPM_ORD_SetRedirection                    ((UINT32)0x0000009A)
-#define TPM_ORD_SHA1Start                         ((UINT32)0x000000A0)
-#define TPM_ORD_SHA1Update                        ((UINT32)0x000000A1)
-#define TPM_ORD_SHA1Complete                      ((UINT32)0x000000A2)
-#define TPM_ORD_SHA1CompleteExtend                ((UINT32)0x000000A3)
-#define TPM_ORD_FieldUpgrade                      ((UINT32)0x000000AA)
-#define TPM_ORD_SaveKeyContext                    ((UINT32)0x000000B4)
-#define TPM_ORD_LoadKeyContext                    ((UINT32)0x000000B5)
-#define TPM_ORD_SaveAuthContext                   ((UINT32)0x000000B6)
-#define TPM_ORD_LoadAuthContext                   ((UINT32)0x000000B7)
-#define TPM_ORD_SaveContext                       ((UINT32)0x000000B8)
-#define TPM_ORD_LoadContext                       ((UINT32)0x000000B9)
-#define TPM_ORD_FlushSpecific                     ((UINT32)0x000000BA)
-#define TPM_ORD_PCR_Reset                         ((UINT32)0x000000C8)
-#define TPM_ORD_NV_DefineSpace                    ((UINT32)0x000000CC)
-#define TPM_ORD_NV_WriteValue                     ((UINT32)0x000000CD)
-#define TPM_ORD_NV_WriteValueAuth                 ((UINT32)0x000000CE)
-#define TPM_ORD_NV_ReadValue                      ((UINT32)0x000000CF)
-#define TPM_ORD_NV_ReadValueAuth                  ((UINT32)0x000000D0)
-#define TPM_ORD_Delegate_UpdateVerification       ((UINT32)0x000000D1)
-#define TPM_ORD_Delegate_Manage                   ((UINT32)0x000000D2)
-#define TPM_ORD_Delegate_CreateKeyDelegation      ((UINT32)0x000000D4)
-#define TPM_ORD_Delegate_CreateOwnerDelegation    ((UINT32)0x000000D5)
-#define TPM_ORD_Delegate_VerifyDelegation         ((UINT32)0x000000D6)
-#define TPM_ORD_Delegate_LoadOwnerDelegation      ((UINT32)0x000000D8)
-#define TPM_ORD_Delegate_ReadTable                ((UINT32)0x000000DB)
-#define TPM_ORD_CreateCounter                     ((UINT32)0x000000DC)
-#define TPM_ORD_IncrementCounter                  ((UINT32)0x000000DD)
-#define TPM_ORD_ReadCounter                       ((UINT32)0x000000DE)
-#define TPM_ORD_ReleaseCounter                    ((UINT32)0x000000DF)
-#define TPM_ORD_ReleaseCounterOwner               ((UINT32)0x000000E0)
-#define TPM_ORD_EstablishTransport                ((UINT32)0x000000E6)
-#define TPM_ORD_ExecuteTransport                  ((UINT32)0x000000E7)
-#define TPM_ORD_ReleaseTransportSigned            ((UINT32)0x000000E8)
-#define TPM_ORD_GetTicks                          ((UINT32)0x000000F1)
-#define TPM_ORD_TickStampBlob                     ((UINT32)0x000000F2)
-
-#define TSC_ORD_PhysicalPresence                  ((UINT32)0x4000000A)
-#define TSC_ORD_ResetEstablishmentBit             ((UINT32)0x4000000B)
-
-#endif // __TPM_ORDINAL_H__
+/*
+ * TPM Ordinal definitions extracted from the TPM 1.2 specification, rev 85.
+ */
+
+#ifndef __TPM_ORDINAL_H__
+#define __TPM_ORDINAL_H__
+
+#define TPM_PROTECTED_COMMAND                     ((UINT32)(0x00000000))
+#define TPM_UNPROTECTED_COMMAND                   ((UINT32)(0x80000000))
+#define TPM_CONNECTION_COMMAND                    ((UINT32)(0x40000000))
+#define TPM_VENDOR_COMMAND                        ((UINT32)(0x20000000))
+
+#define TPM_MAIN                                  ((UINT16)(0x0000))
+#define TPM_PC                                    ((UINT16)(0x0001))
+#define TPM_PDA                                   ((UINT16)(0x0002))
+#define TPM_CELL_PHONE                            ((UINT16)(0x0003))
+#define TPM_SERVER                                ((UINT16)(0x0004))
+
+#define TPM_PROTECTED_ORDINAL              (TPM_MAIN | TPM_PROTECTED_COMMAND)
+#define TPM_UNPROTECTED_ORDINAL            (TPM_MAIN | TPM_UNPROTECTED_COMMAND)
+#define TPM_CONNECTION_ORDINAL             (TPM_MAIN | TPM_CONNECTION_COMMAND)
+
+
+#define TPM_ORD_OIAP                              ((UINT32)0x0000000A)
+#define TPM_ORD_OSAP                              ((UINT32)0x0000000B)
+#define TPM_ORD_ChangeAuth                        ((UINT32)0x0000000C)
+#define TPM_ORD_TakeOwnership                     ((UINT32)0x0000000D)
+#define TPM_ORD_ChangeAuthAsymStart               ((UINT32)0x0000000E)
+#define TPM_ORD_ChangeAuthAsymFinish              ((UINT32)0x0000000F)
+#define TPM_ORD_ChangeAuthOwner                   ((UINT32)0x00000010)
+#define TPM_ORD_DSAP                              ((UINT32)0x00000011)
+#define TPM_ORD_CMK_CreateTicket                  ((UINT32)0x00000012)
+#define TPM_ORD_CMK_CreateKey                     ((UINT32)0x00000013)
+#define TPM_ORD_Extend                            ((UINT32)0x00000014)
+#define TPM_ORD_PcrRead                           ((UINT32)0x00000015)
+#define TPM_ORD_Quote                             ((UINT32)0x00000016)
+#define TPM_ORD_Seal                              ((UINT32)0x00000017)
+#define TPM_ORD_Unseal                            ((UINT32)0x00000018)
+#define TPM_ORD_DirWriteAuth                      ((UINT32)0x00000019)
+#define TPM_ORD_DirRead                           ((UINT32)0x0000001A)
+#define TPM_ORD_CMK_CreateBlob                    ((UINT32)0x0000001B)
+#define TPM_ORD_CMK_SetRestrictions               ((UINT32)0x0000001C)
+#define TPM_ORD_CMK_ApproveMA                     ((UINT32)0x0000001D)
+#define TPM_ORD_UnBind                            ((UINT32)0x0000001E)
+#define TPM_ORD_CreateWrapKey                     ((UINT32)0x0000001F)
+#define TPM_ORD_LoadKey                           ((UINT32)0x00000020)
+#define TPM_ORD_GetPubKey                         ((UINT32)0x00000021)
+#define TPM_ORD_EvictKey                          ((UINT32)0x00000022)
+#define TPM_ORD_KeyControlOwner                   ((UINT32)0x00000023)
+#define TPM_ORD_CMK_ConvertMigration              ((UINT32)0x00000024)
+#define TPM_ORD_MigrateKey                        ((UINT32)0x00000025)
+#define TPM_ORD_CreateMigrationBlob               ((UINT32)0x00000028)
+#define TPM_ORD_DAA_Join                          ((UINT32)0x00000029)
+#define TPM_ORD_ConvertMigrationBlob              ((UINT32)0x0000002A)
+#define TPM_ORD_AuthorizeMigrationKey             ((UINT32)0x0000002B)
+#define TPM_ORD_CreateMaintenanceArchive          ((UINT32)0x0000002C)
+#define TPM_ORD_LoadMaintenanceArchive            ((UINT32)0x0000002D)
+#define TPM_ORD_KillMaintenanceFeature            ((UINT32)0x0000002E)
+#define TPM_ORD_LoadManuMaintPub                  ((UINT32)0x0000002F)
+#define TPM_ORD_ReadManuMaintPub                  ((UINT32)0x00000030)
+#define TPM_ORD_DAA_Sign                          ((UINT32)0x00000031)
+#define TPM_ORD_CertifyKey                        ((UINT32)0x00000032)
+#define TPM_ORD_CertifyKey2                       ((UINT32)0x00000033)
+#define TPM_ORD_Sign                              ((UINT32)0x0000003C)
+#define TPM_ORD_Sealx                             ((UINT32)0x0000003D)
+#define TPM_ORD_Quote2                            ((UINT32)0x0000003E)
+#define TPM_ORD_SetCapability                     ((UINT32)0x0000003F)
+#define TPM_ORD_ResetLockValue                    ((UINT32)0x00000040)
+#define TPM_ORD_LoadKey2                          ((UINT32)0x00000041)
+#define TPM_ORD_GetRandom                         ((UINT32)0x00000046)
+#define TPM_ORD_StirRandom                        ((UINT32)0x00000047)
+#define TPM_ORD_SelfTestFull                      ((UINT32)0x00000050)
+#define TPM_ORD_CertifySelfTest                   ((UINT32)0x00000052)
+#define TPM_ORD_ContinueSelfTest                  ((UINT32)0x00000053)
+#define TPM_ORD_GetTestResult                     ((UINT32)0x00000054)
+#define TPM_ORD_Reset                             ((UINT32)0x0000005A)
+#define TPM_ORD_OwnerClear                        ((UINT32)0x0000005B)
+#define TPM_ORD_DisableOwnerClear                 ((UINT32)0x0000005C)
+#define TPM_ORD_ForceClear                        ((UINT32)0x0000005D)
+#define TPM_ORD_DisableForceClear                 ((UINT32)0x0000005E)
+#define TPM_ORD_GetCapabilitySigned               ((UINT32)0x00000064)
+#define TPM_ORD_GetCapability                     ((UINT32)0x00000065)
+#define TPM_ORD_GetCapabilityOwner                ((UINT32)0x00000066)
+#define TPM_ORD_OwnerSetDisable                   ((UINT32)0x0000006E)
+#define TPM_ORD_PhysicalEnable                    ((UINT32)0x0000006F)
+#define TPM_ORD_PhysicalDisable                   ((UINT32)0x00000070)
+#define TPM_ORD_SetOwnerInstall                   ((UINT32)0x00000071)
+#define TPM_ORD_PhysicalSetDeactivated            ((UINT32)0x00000072)
+#define TPM_ORD_SetTempDeactivated                ((UINT32)0x00000073)
+#define TPM_ORD_SetOperatorAuth                   ((UINT32)0x00000074)
+#define TPM_ORD_SetOwnerPointer                   ((UINT32)0x00000075)
+#define TPM_ORD_CreateEndorsementKeyPair          ((UINT32)0x00000078)
+#define TPM_ORD_MakeIdentity                      ((UINT32)0x00000079)
+#define TPM_ORD_ActivateIdentity                  ((UINT32)0x0000007A)
+#define TPM_ORD_ReadPubek                         ((UINT32)0x0000007C)
+#define TPM_ORD_OwnerReadPubek                    ((UINT32)0x0000007D)
+#define TPM_ORD_DisablePubekRead                  ((UINT32)0x0000007E)
+#define TPM_ORD_CreateRevocableEK                 ((UINT32)0x0000007F)
+#define TPM_ORD_RevokeTrust                       ((UINT32)0x00000080)
+#define TPM_ORD_OwnerReadInternalPub              ((UINT32)0x00000081)
+#define TPM_ORD_GetAuditEvent                     ((UINT32)0x00000082)
+#define TPM_ORD_GetAuditEventSigned               ((UINT32)0x00000083)
+#define TPM_ORD_GetAuditDigest                    ((UINT32)0x00000085)
+#define TPM_ORD_GetAuditDigestSigned              ((UINT32)0x00000086)
+#define TPM_ORD_GetOrdinalAuditStatus             ((UINT32)0x0000008C)
+#define TPM_ORD_SetOrdinalAuditStatus             ((UINT32)0x0000008D)
+#define TPM_ORD_Terminate_Handle                  ((UINT32)0x00000096)
+#define TPM_ORD_Init                              ((UINT32)0x00000097)
+#define TPM_ORD_SaveState                         ((UINT32)0x00000098)
+#define TPM_ORD_Startup                           ((UINT32)0x00000099)
+#define TPM_ORD_SetRedirection                    ((UINT32)0x0000009A)
+#define TPM_ORD_SHA1Start                         ((UINT32)0x000000A0)
+#define TPM_ORD_SHA1Update                        ((UINT32)0x000000A1)
+#define TPM_ORD_SHA1Complete                      ((UINT32)0x000000A2)
+#define TPM_ORD_SHA1CompleteExtend                ((UINT32)0x000000A3)
+#define TPM_ORD_FieldUpgrade                      ((UINT32)0x000000AA)
+#define TPM_ORD_SaveKeyContext                    ((UINT32)0x000000B4)
+#define TPM_ORD_LoadKeyContext                    ((UINT32)0x000000B5)
+#define TPM_ORD_SaveAuthContext                   ((UINT32)0x000000B6)
+#define TPM_ORD_LoadAuthContext                   ((UINT32)0x000000B7)
+#define TPM_ORD_SaveContext                       ((UINT32)0x000000B8)
+#define TPM_ORD_LoadContext                       ((UINT32)0x000000B9)
+#define TPM_ORD_FlushSpecific                     ((UINT32)0x000000BA)
+#define TPM_ORD_PCR_Reset                         ((UINT32)0x000000C8)
+#define TPM_ORD_NV_DefineSpace                    ((UINT32)0x000000CC)
+#define TPM_ORD_NV_WriteValue                     ((UINT32)0x000000CD)
+#define TPM_ORD_NV_WriteValueAuth                 ((UINT32)0x000000CE)
+#define TPM_ORD_NV_ReadValue                      ((UINT32)0x000000CF)
+#define TPM_ORD_NV_ReadValueAuth                  ((UINT32)0x000000D0)
+#define TPM_ORD_Delegate_UpdateVerification       ((UINT32)0x000000D1)
+#define TPM_ORD_Delegate_Manage                   ((UINT32)0x000000D2)
+#define TPM_ORD_Delegate_CreateKeyDelegation      ((UINT32)0x000000D4)
+#define TPM_ORD_Delegate_CreateOwnerDelegation    ((UINT32)0x000000D5)
+#define TPM_ORD_Delegate_VerifyDelegation         ((UINT32)0x000000D6)
+#define TPM_ORD_Delegate_LoadOwnerDelegation      ((UINT32)0x000000D8)
+#define TPM_ORD_Delegate_ReadTable                ((UINT32)0x000000DB)
+#define TPM_ORD_CreateCounter                     ((UINT32)0x000000DC)
+#define TPM_ORD_IncrementCounter                  ((UINT32)0x000000DD)
+#define TPM_ORD_ReadCounter                       ((UINT32)0x000000DE)
+#define TPM_ORD_ReleaseCounter                    ((UINT32)0x000000DF)
+#define TPM_ORD_ReleaseCounterOwner               ((UINT32)0x000000E0)
+#define TPM_ORD_EstablishTransport                ((UINT32)0x000000E6)
+#define TPM_ORD_ExecuteTransport                  ((UINT32)0x000000E7)
+#define TPM_ORD_ReleaseTransportSigned            ((UINT32)0x000000E8)
+#define TPM_ORD_GetTicks                          ((UINT32)0x000000F1)
+#define TPM_ORD_TickStampBlob                     ((UINT32)0x000000F2)
+
+#define TSC_ORD_PhysicalPresence                  ((UINT32)0x4000000A)
+#define TSC_ORD_ResetEstablishmentBit             ((UINT32)0x4000000B)
+
+#endif // __TPM_ORDINAL_H__
diff --git a/src/include/tss/tspi.h b/src/include/tss/tspi.h
index 1d188f7..b5882e9 100644
--- a/src/include/tss/tspi.h
+++ b/src/include/tss/tspi.h
@@ -1,1198 +1,1198 @@
-#if !defined(_TSPI_H_)
-#define _TSPI_H_
-
-#include <tss/tss_defines.h>
-#include <tss/tss_typedef.h>
-#include <tss/tss_structs.h>
-#include <tss/tss_error.h>
-#include <tss/tss_error_basics.h>
-
-#if !defined( TSPICALL )
-  #if !defined(WIN32) || defined (TSP_STATIC)
-    // Linux, or a Win32 static library
-    #define TSPICALL extern TSS_RESULT
-  #elif defined (TSPDLL_EXPORTS)
-    // Win32 DLL build
-    #define TSPICALL extern __declspec(dllexport) TSS_RESULT
-  #else
-    // Win32 DLL import
-    #define TSPICALL extern __declspec(dllimport) TSS_RESULT
-  #endif
-#endif /* TSPICALL */
-
-#if defined ( __cplusplus )
-extern "C" {
-#endif /* __cplusplus */
-
-
-// Class-independent ASN.1 conversion functions
-TSPICALL Tspi_EncodeDER_TssBlob
-(
-    UINT32              rawBlobSize,                   // in
-    BYTE*               rawBlob,                       // in
-    UINT32              blobType,                      // in
-    UINT32*             derBlobSize,                   // in, out
-    BYTE*               derBlob                        // out
-);
-
-TSPICALL Tspi_DecodeBER_TssBlob
-(
-    UINT32              berBlobSize,                   // in
-    BYTE*               berBlob,                       // in
-    UINT32*             blobType,                      // out
-    UINT32*             rawBlobSize,                   // in, out
-    BYTE*               rawBlob                        // out
-);
-
-
-
-// Common Methods
-TSPICALL Tspi_SetAttribUint32
-(
-    TSS_HOBJECT         hObject,                       // in
-    TSS_FLAG            attribFlag,                    // in
-    TSS_FLAG            subFlag,                       // in
-    UINT32              ulAttrib                       // in
-);
-
-TSPICALL Tspi_GetAttribUint32
-(
-    TSS_HOBJECT         hObject,                       // in
-    TSS_FLAG            attribFlag,                    // in
-    TSS_FLAG            subFlag,                       // in
-    UINT32*             pulAttrib                      // out
-);
-
-TSPICALL Tspi_SetAttribData
-(
-    TSS_HOBJECT         hObject,                       // in
-    TSS_FLAG            attribFlag,                    // in
-    TSS_FLAG            subFlag,                       // in
-    UINT32              ulAttribDataSize,              // in
-    BYTE*               rgbAttribData                  // in
-);
-
-TSPICALL Tspi_GetAttribData
-(
-    TSS_HOBJECT         hObject,                       // in
-    TSS_FLAG            attribFlag,                    // in
-    TSS_FLAG            subFlag,                       // in
-    UINT32*             pulAttribDataSize,             // out
-    BYTE**              prgbAttribData                 // out
-);
-
-TSPICALL Tspi_ChangeAuth
-(
-    TSS_HOBJECT         hObjectToChange,               // in
-    TSS_HOBJECT         hParentObject,                 // in
-    TSS_HPOLICY         hNewPolicy                     // in
-);
-
-TSPICALL Tspi_ChangeAuthAsym
-(
-    TSS_HOBJECT         hObjectToChange,               // in
-    TSS_HOBJECT         hParentObject,                 // in
-    TSS_HKEY            hIdentKey,                     // in
-    TSS_HPOLICY         hNewPolicy                     // in
-);
-
-TSPICALL Tspi_GetPolicyObject
-(
-    TSS_HOBJECT         hObject,                       // in
-    TSS_FLAG            policyType,                    // in
-    TSS_HPOLICY*        phPolicy                       // out
-);
-
-
-
-// Tspi_Context Class Definitions
-TSPICALL Tspi_Context_Create
-(
-    TSS_HCONTEXT*       phContext                      // out
-);
-
-TSPICALL Tspi_Context_Close
-(
-    TSS_HCONTEXT        hContext                       // in
-);
-
-TSPICALL Tspi_Context_Connect
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_UNICODE*        wszDestination                 // in
-);
-
-TSPICALL Tspi_Context_FreeMemory
-(
-    TSS_HCONTEXT        hContext,                      // in
-    BYTE*               rgbMemory                      // in
-);
-
-TSPICALL Tspi_Context_GetDefaultPolicy
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_HPOLICY*        phPolicy                       // out
-);
-
-TSPICALL Tspi_Context_CreateObject
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_FLAG            objectType,                    // in
-    TSS_FLAG            initFlags,                     // in
-    TSS_HOBJECT*        phObject                       // out
-);
-
-TSPICALL Tspi_Context_CloseObject
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_HOBJECT         hObject                        // in
-);
-
-TSPICALL Tspi_Context_GetCapability
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_FLAG            capArea,                       // in
-    UINT32              ulSubCapLength,                // in
-    BYTE*               rgbSubCap,                     // in
-    UINT32*             pulRespDataLength,             // out
-    BYTE**              prgbRespData                   // out
-);
-
-TSPICALL Tspi_Context_GetTpmObject
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_HTPM*           phTPM                          // out
-);
-
-TSPICALL Tspi_Context_SetTransEncryptionKey
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_HKEY            hKey                           // in
-);
-
-TSPICALL Tspi_Context_CloseSignTransport
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_HKEY            hSigningKey,                   // in
-    TSS_VALIDATION*     pValidationData                // in, out
-);
-
-TSPICALL Tspi_Context_LoadKeyByBlob
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_HKEY            hUnwrappingKey,                // in
-    UINT32              ulBlobLength,                  // in
-    BYTE*               rgbBlobData,                   // in
-    TSS_HKEY*           phKey                          // out
-);
-
-TSPICALL Tspi_Context_LoadKeyByUUID
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_FLAG            persistentStorageType,         // in
-    TSS_UUID            uuidData,                      // in
-    TSS_HKEY*           phKey                          // out
-);
-
-TSPICALL Tspi_Context_RegisterKey
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_HKEY            hKey,                          // in
-    TSS_FLAG            persistentStorageType,         // in
-    TSS_UUID            uuidKey,                       // in
-    TSS_FLAG            persistentStorageTypeParent,   // in
-    TSS_UUID            uuidParentKey                  // in
-);
-
-TSPICALL Tspi_Context_UnregisterKey
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_FLAG            persistentStorageType,         // in
-    TSS_UUID            uuidKey,                       // in
-    TSS_HKEY*           phkey                          // out
-);
-
-TSPICALL Tspi_Context_GetKeyByUUID
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_FLAG            persistentStorageType,         // in
-    TSS_UUID            uuidData,                      // in
-    TSS_HKEY*           phKey                          // out
-);
-
-TSPICALL Tspi_Context_GetKeyByPublicInfo
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_FLAG            persistentStorageType,         // in
-    TSS_ALGORITHM_ID    algID,                         // in
-    UINT32              ulPublicInfoLength,            // in
-    BYTE*               rgbPublicInfo,                 // in
-    TSS_HKEY*           phKey                          // out
-);
-
-TSPICALL Tspi_Context_GetRegisteredKeysByUUID
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_FLAG            persistentStorageType,         // in
-    TSS_UUID*           pUuidData,                     // in
-    UINT32*             pulKeyHierarchySize,           // out
-    TSS_KM_KEYINFO**    ppKeyHierarchy                 // out
-);
-
-TSPICALL Tspi_Context_GetRegisteredKeysByUUID2
-(
-    TSS_HCONTEXT        hContext,                      // in
-    TSS_FLAG            persistentStorageType,         // in
-    TSS_UUID*           pUuidData,                     // in
-    UINT32*             pulKeyHierarchySize,           // out
-    TSS_KM_KEYINFO2**   ppKeyHierarchy                 // out
-);
-
-
-// Policy class definitions
-TSPICALL Tspi_Policy_SetSecret
-(
-    TSS_HPOLICY         hPolicy,                       // in
-    TSS_FLAG            secretMode,                    // in
-    UINT32              ulSecretLength,                // in
-    BYTE*               rgbSecret                      // in
-);
-
-TSPICALL Tspi_Policy_FlushSecret
-(
-    TSS_HPOLICY         hPolicy                        // in
-);
-
-TSPICALL Tspi_Policy_AssignToObject
-(
-    TSS_HPOLICY         hPolicy,                       // in
-    TSS_HOBJECT         hObject                        // in
-);
-
-
-
-// TPM Class Definitions
-TSPICALL Tspi_TPM_KeyControlOwner
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hKey,                          // in
-    UINT32              attribName,                    // in
-    TSS_BOOL            attribValue,                   // in
-    TSS_UUID*           pUuidData                      // out
-);
-
-TSPICALL Tspi_TPM_CreateEndorsementKey
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hKey,                          // in
-    TSS_VALIDATION*     pValidationData                // in, out
-);
-
-TSPICALL Tspi_TPM_CreateRevocableEndorsementKey
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hKey,                          // in
-    TSS_VALIDATION*     pValidationData,               // in, out
-    UINT32*             pulEkResetDataLength,          // in, out
-    BYTE**              rgbEkResetData                 // in, out
-);
-
-TSPICALL Tspi_TPM_RevokeEndorsementKey
-(
-    TSS_HTPM            hTPM,                          // in
-    UINT32              ulEkResetDataLength,           // in
-    BYTE*               rgbEkResetData                 // in
-);
-
-TSPICALL Tspi_TPM_GetPubEndorsementKey
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_BOOL            fOwnerAuthorized,              // in
-    TSS_VALIDATION*     pValidationData,               // in, out
-    TSS_HKEY*           phEndorsementPubKey            // out
-);
-
-TSPICALL Tspi_TPM_OwnerGetSRKPubKey
-(
-    TSS_HTPM            hTPM,                          // in
-    UINT32*             pulPubKeyLength,               // out
-    BYTE**              prgbPubKey                     // out
-);
-
-TSPICALL Tspi_TPM_TakeOwnership
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hKeySRK,                       // in
-    TSS_HKEY            hEndorsementPubKey             // in
-);
-
-TSPICALL Tspi_TPM_ClearOwner
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_BOOL            fForcedClear                   // in
-);
-
-TSPICALL Tspi_TPM_CollateIdentityRequest
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hKeySRK,                       // in
-    TSS_HKEY            hCAPubKey,                     // in
-    UINT32              ulIdentityLabelLength,         // in
-    BYTE*               rgbIdentityLabelData,          // in
-    TSS_HKEY            hIdentityKey,                  // in
-    TSS_ALGORITHM_ID    algID,                         // in
-    UINT32*             pulTCPAIdentityReqLength,      // out
-    BYTE**              prgbTCPAIdentityReq            // out
-);
-
-TSPICALL Tspi_TPM_ActivateIdentity
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hIdentKey,                     // in
-    UINT32              ulAsymCAContentsBlobLength,    // in
-    BYTE*               rgbAsymCAContentsBlob,         // in
-    UINT32              ulSymCAAttestationBlobLength,  // in
-    BYTE*               rgbSymCAAttestationBlob,       // in
-    UINT32*             pulCredentialLength,           // out
-    BYTE**              prgbCredential                 // out
-);
-
-TSPICALL Tspi_TPM_CreateMaintenanceArchive
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_BOOL            fGenerateRndNumber,            // in
-    UINT32*             pulRndNumberLength,            // out
-    BYTE**              prgbRndNumber,                 // out
-    UINT32*             pulArchiveDataLength,          // out
-    BYTE**              prgbArchiveData                // out
-);
-
-TSPICALL Tspi_TPM_KillMaintenanceFeature
-(
-    TSS_HTPM            hTPM                           // in
-);
-
-TSPICALL Tspi_TPM_LoadMaintenancePubKey
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hMaintenanceKey,               // in
-    TSS_VALIDATION*     pValidationData                // in, out
-);
-
-TSPICALL Tspi_TPM_CheckMaintenancePubKey
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hMaintenanceKey,               // in
-    TSS_VALIDATION*     pValidationData                // in, out
-);
-
-TSPICALL Tspi_TPM_SetOperatorAuth
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HPOLICY         hOperatorPolicy                // in
-);
-
-TSPICALL Tspi_TPM_SetStatus
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_FLAG            statusFlag,                    // in
-    TSS_BOOL            fTpmState                      // in
-);
-
-TSPICALL Tspi_TPM_GetStatus
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_FLAG            statusFlag,                    // in
-    TSS_BOOL*           pfTpmState                     // out
-);
-
-TSPICALL Tspi_TPM_GetCapability
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_FLAG            capArea,                       // in
-    UINT32              ulSubCapLength,                // in
-    BYTE*               rgbSubCap,                     // in
-    UINT32*             pulRespDataLength,             // out
-    BYTE**              prgbRespData                   // out
-);
-
-TSPICALL Tspi_TPM_GetCapabilitySigned
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hKey,                          // in
-    TSS_FLAG            capArea,                       // in
-    UINT32              ulSubCapLength,                // in
-    BYTE*               rgbSubCap,                     // in
-    TSS_VALIDATION*     pValidationData,               // in, out
-    UINT32*             pulRespDataLength,             // out
-    BYTE**              prgbRespData                   // out
-);
-
-TSPICALL Tspi_TPM_SelfTestFull
-(
-    TSS_HTPM            hTPM                           // in
-);
-
-TSPICALL Tspi_TPM_CertifySelfTest
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hKey,                          // in
-    TSS_VALIDATION*     pValidationData                // in, out
-);
-
-TSPICALL Tspi_TPM_GetTestResult
-(
-    TSS_HTPM            hTPM,                          // in
-    UINT32*             pulTestResultLength,           // out
-    BYTE**              prgbTestResult                 // out
-);
-
-TSPICALL Tspi_TPM_GetRandom
-(
-    TSS_HTPM            hTPM,                          // in
-    UINT32              ulRandomDataLength,            // in
-    BYTE**              prgbRandomData                 // out
-);
-
-TSPICALL Tspi_TPM_StirRandom
-(
-    TSS_HTPM            hTPM,                          // in
-    UINT32              ulEntropyDataLength,           // in
-    BYTE*               rgbEntropyData                 // in
-);
-
-TSPICALL Tspi_TPM_GetEvent
-(
-    TSS_HTPM            hTPM,                          // in
-    UINT32              ulPcrIndex,                    // in
-    UINT32              ulEventNumber,                 // in
-    TSS_PCR_EVENT*      pPcrEvent                      // out
-);
-
-TSPICALL Tspi_TPM_GetEvents
-(
-    TSS_HTPM            hTPM,                          // in
-    UINT32              ulPcrIndex,                    // in
-    UINT32              ulStartNumber,                 // in
-    UINT32*             pulEventNumber,                // in, out
-    TSS_PCR_EVENT**     prgPcrEvents                   // out
-);
-
-TSPICALL Tspi_TPM_GetEventLog
-(
-    TSS_HTPM            hTPM,                          // in
-    UINT32*             pulEventNumber,                // out
-    TSS_PCR_EVENT**     prgPcrEvents                   // out
-);
-
-TSPICALL Tspi_TPM_Quote
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hIdentKey,                     // in
-    TSS_HPCRS           hPcrComposite,                 // in
-    TSS_VALIDATION*     pValidationData                // in, out
-);
-
-TSPICALL Tspi_TPM_Quote2
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hIdentKey,                     // in
-    TSS_BOOL            fAddVersion,                   // in
-    TSS_HPCRS           hPcrComposite,                 // in
-    TSS_VALIDATION*     pValidationData,               // in, out
-    UINT32*             versionInfoSize,               // out
-    BYTE**              versionInfo                    // out
-);
-
-TSPICALL Tspi_TPM_PcrExtend
-(
-    TSS_HTPM            hTPM,                          // in
-    UINT32              ulPcrIndex,                    // in
-    UINT32              ulPcrDataLength,               // in
-    BYTE*               pbPcrData,                     // in
-    TSS_PCR_EVENT*      pPcrEvent,                     // in
-    UINT32*             pulPcrValueLength,             // out
-    BYTE**              prgbPcrValue                   // out
-);
-
-TSPICALL Tspi_TPM_PcrRead
-(
-    TSS_HTPM            hTPM,                          // in
-    UINT32              ulPcrIndex,                    // in
-    UINT32*             pulPcrValueLength,             // out
-    BYTE**              prgbPcrValue                   // out
-);
-
-TSPICALL Tspi_TPM_PcrReset
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HPCRS           hPcrComposite                  // in
-);
-
-TSPICALL Tspi_TPM_AuthorizeMigrationTicket
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hMigrationKey,                 // in
-    TSS_MIGRATE_SCHEME  migrationScheme,               // in
-    UINT32*             pulMigTicketLength,            // out
-    BYTE**              prgbMigTicket                  // out
-);
-
-TSPICALL Tspi_TPM_CMKSetRestrictions
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_CMK_DELEGATE    CmkDelegate                    // in
-);
-
-TSPICALL Tspi_TPM_CMKApproveMA
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HMIGDATA        hMaAuthData                    // in
-);
-
-TSPICALL Tspi_TPM_CMKCreateTicket
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hVerifyKey,                    // in
-    TSS_HMIGDATA        hSigData                       // in
-);
-
-TSPICALL Tspi_TPM_ReadCounter
-(
-    TSS_HTPM            hTPM,                          // in
-    UINT32*             counterValue                   // out
-);
-
-TSPICALL Tspi_TPM_ReadCurrentTicks
-(
-    TSS_HTPM            hTPM,                          // in
-    TPM_CURRENT_TICKS*  tickCount                      // out
-);
-
-TSPICALL Tspi_TPM_DirWrite
-(
-    TSS_HTPM            hTPM,                          // in
-    UINT32              ulDirIndex,                    // in
-    UINT32              ulDirDataLength,               // in
-    BYTE*               rgbDirData                     // in
-);
-
-TSPICALL Tspi_TPM_DirRead
-(
-    TSS_HTPM            hTPM,                          // in
-    UINT32              ulDirIndex,                    // in
-    UINT32*             pulDirDataLength,              // out
-    BYTE**              prgbDirData                    // out
-);
-
-TSPICALL Tspi_TPM_Delegate_AddFamily
-(
-    TSS_HTPM            hTPM,                          // in, must not be NULL
-    BYTE                bLabel,                        // in
-    TSS_HDELFAMILY*     phFamily                       // out
-);
-
-TSPICALL Tspi_TPM_Delegate_GetFamily
-(
-    TSS_HTPM            hTPM,                          // in, must not NULL
-    UINT32              ulFamilyID,                    // in
-    TSS_HDELFAMILY*     phFamily                       // out
-);
-
-TSPICALL Tspi_TPM_Delegate_InvalidateFamily
-(
-    TSS_HTPM            hTPM,                          // in, must not be NULL
-    TSS_HDELFAMILY      hFamily                        // in
-);
-
-TSPICALL Tspi_TPM_Delegate_CreateDelegation
-(
-    TSS_HOBJECT         hObject,                       // in
-    BYTE                bLabel,                        // in
-    UINT32              ulFlags,                       // in
-    TSS_HPCRS           hPcr,                          // in, may be NULL
-    TSS_HDELFAMILY      hFamily,                       // in
-    TSS_HPOLICY         hDelegation                    // in, out
-);
-
-TSPICALL Tspi_TPM_Delegate_CacheOwnerDelegation
-(
-    TSS_HTPM            hTPM,                          // in, must not be NULL
-    TSS_HPOLICY         hDelegation,                   // in, out
-    UINT32              ulIndex,                       // in
-    UINT32              ulFlags                        // in
-);
-
-TSPICALL Tspi_TPM_Delegate_UpdateVerificationCount
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HPOLICY         hDelegation                    // in, out
-);
-
-TSPICALL Tspi_TPM_Delegate_VerifyDelegation
-(
-    TSS_HPOLICY         hDelegation                    // in, out
-);
-
-TSPICALL Tspi_TPM_Delegate_ReadTables
-(
-    TSS_HCONTEXT                  hContext,                      // in
-    UINT32*                       pulFamilyTableSize,            // out
-    TSS_FAMILY_TABLE_ENTRY**      ppFamilyTable,                 // out
-    UINT32*                       pulDelegateTableSize,          // out
-    TSS_DELEGATION_TABLE_ENTRY**  ppDelegateTable                // out
-);
-
-TSPICALL Tspi_TPM_DAA_JoinInit
-(
-    TSS_HTPM                      hTPM,                          // in
-    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
-    UINT32                        daaCounter,                    // in
-    UINT32                        issuerAuthPKsLength,           // in
-    TSS_HKEY*                     issuerAuthPKs,                 // in
-    UINT32                        issuerAuthPKSignaturesLength,  // in
-    UINT32                        issuerAuthPKSignaturesLength2, // in
-    BYTE**                        issuerAuthPKSignatures,        // in
-    UINT32*                       capitalUprimeLength,           // out
-    BYTE**                        capitalUprime,                 // out
-    TSS_DAA_IDENTITY_PROOF**      identityProof,                 // out
-    UINT32*                       joinSessionLength,             // out
-    BYTE**                        joinSession                    // out
-);
-
-TSPICALL Tspi_TPM_DAA_JoinCreateDaaPubKey
-(
-    TSS_HTPM                      hTPM,                          // in
-    TSS_HDAA_CREDENTIAL           hDAACredential,                // in
-    UINT32                        authenticationChallengeLength, // in
-    BYTE*                         authenticationChallenge,       // in
-    UINT32                        nonceIssuerLength,             // in
-    BYTE*                         nonceIssuer,                   // in
-    UINT32                        attributesPlatformLength,      // in
-    UINT32                        attributesPlatformLength2,     // in
-    BYTE**                        attributesPlatform,            // in
-    UINT32                        joinSessionLength,             // in
-    BYTE*                         joinSession,                   // in
-    TSS_DAA_CREDENTIAL_REQUEST**  credentialRequest              // out
-);
-
-TSPICALL Tspi_TPM_DAA_JoinStoreCredential
-(
-    TSS_HTPM                      hTPM,                          // in
-    TSS_HDAA_CREDENTIAL           hDAACredential,                // in
-    TSS_DAA_CRED_ISSUER*          credIssuer,                    // in
-    UINT32                        joinSessionLength,             // in
-    BYTE*                         joinSession                    // in
-);
-
-TSPICALL Tspi_TPM_DAA_Sign
-(
-    TSS_HTPM                      hTPM,                          // in
-    TSS_HDAA_CREDENTIAL           hDAACredential,                // in
-    TSS_HDAA_ARA_KEY              hARAKey,                       // in
-    TSS_DAA_SELECTED_ATTRIB*      revealAttributes,              // in
-    UINT32                        verifierNonceLength,           // in
-    BYTE*                         verifierNonce,                 // in
-    UINT32                        verifierBaseNameLength,        // in
-    BYTE*                         verifierBaseName,              // in
-    TSS_HOBJECT                   signData,                      // in
-    TSS_DAA_SIGNATURE**           daaSignature                   // out
-);
-
-TSPICALL Tspi_TPM_GetAuditDigest
-(
-    TSS_HTPM            hTPM,                          // in
-    TSS_HKEY            hKey,                          // in
-    TSS_BOOL            closeAudit,                    // in
-    UINT32*             pulAuditDigestSize,            // out
-    BYTE**              prgbAuditDigest,               // out
-    TPM_COUNTER_VALUE*  pCounterValue,                 // out
-    TSS_VALIDATION*     pValidationData,               // out
-    UINT32*             ordSize,                       // out
-    UINT32**            ordList                        // out
-);
-
-
-
-// PcrComposite Class Definitions
-TSPICALL Tspi_PcrComposite_SelectPcrIndex
-(
-    TSS_HPCRS           hPcrComposite,                 // in
-    UINT32              ulPcrIndex                     // in
-);
-
-TSPICALL Tspi_PcrComposite_SelectPcrIndexEx
-(
-    TSS_HPCRS           hPcrComposite,                 // in
-    UINT32              ulPcrIndex,                    // in
-    UINT32              direction                      // in
-);
-
-TSPICALL Tspi_PcrComposite_SetPcrValue
-(
-    TSS_HPCRS           hPcrComposite,                 // in
-    UINT32              ulPcrIndex,                    // in
-    UINT32              ulPcrValueLength,              // in
-    BYTE*               rgbPcrValue                    // in
-);
-
-TSPICALL Tspi_PcrComposite_GetPcrValue
-(
-    TSS_HPCRS           hPcrComposite,                 // in
-    UINT32              ulPcrIndex,                    // in
-    UINT32*             pulPcrValueLength,             // out
-    BYTE**              prgbPcrValue                   // out
-);
-
-TSPICALL Tspi_PcrComposite_SetPcrLocality
-(
-    TSS_HPCRS           hPcrComposite,                 // in
-    UINT32              LocalityValue                  // in
-);
-
-TSPICALL Tspi_PcrComposite_GetPcrLocality
-(
-    TSS_HPCRS           hPcrComposite,                 // in
-    UINT32*             pLocalityValue                 // out
-);
-
-TSPICALL Tspi_PcrComposite_GetCompositeHash
-(
-    TSS_HPCRS           hPcrComposite,                 // in
-    UINT32*             pLen,                          // in
-    BYTE**              ppbHashData                    // out
-);
-
-
-
-// Key Class Definition
-TSPICALL Tspi_Key_LoadKey
-(
-    TSS_HKEY            hKey,                          // in
-    TSS_HKEY            hUnwrappingKey                 // in
-);
-
-TSPICALL Tspi_Key_UnloadKey
-(
-    TSS_HKEY            hKey                           // in
-);
-
-TSPICALL Tspi_Key_GetPubKey
-(
-    TSS_HKEY            hKey,                          // in
-    UINT32*             pulPubKeyLength,               // out
-    BYTE**              prgbPubKey                     // out
-);
-
-TSPICALL Tspi_Key_CertifyKey
-(
-    TSS_HKEY            hKey,                          // in
-    TSS_HKEY            hCertifyingKey,                // in
-    TSS_VALIDATION*     pValidationData                // in, out
-);
-
-TSPICALL Tspi_Key_CreateKey
-(
-    TSS_HKEY            hKey,                          // in
-    TSS_HKEY            hWrappingKey,                  // in
-    TSS_HPCRS           hPcrComposite                  // in, may be NULL
-);
-
-TSPICALL Tspi_Key_WrapKey
-(
-    TSS_HKEY            hKey,                          // in
-    TSS_HKEY            hWrappingKey,                  // in
-    TSS_HPCRS           hPcrComposite                  // in, may be NULL
-);
-
-TSPICALL Tspi_Key_CreateMigrationBlob
-(
-    TSS_HKEY            hKeyToMigrate,                 // in
-    TSS_HKEY            hParentKey,                    // in
-    UINT32              ulMigTicketLength,             // in
-    BYTE*               rgbMigTicket,                  // in
-    UINT32*             pulRandomLength,               // out
-    BYTE**              prgbRandom,                    // out
-    UINT32*             pulMigrationBlobLength,        // out
-    BYTE**              prgbMigrationBlob              // out
-);
-
-TSPICALL Tspi_Key_ConvertMigrationBlob
-(
-    TSS_HKEY            hKeyToMigrate,                 // in
-    TSS_HKEY            hParentKey,                    // in
-    UINT32              ulRandomLength,                // in
-    BYTE*               rgbRandom,                     // in
-    UINT32              ulMigrationBlobLength,         // in
-    BYTE*               rgbMigrationBlob               // in
-);
-
-TSPICALL Tspi_Key_MigrateKey
-(
-    TSS_HKEY            hMaKey,                        // in
-    TSS_HKEY            hPublicKey,                    // in
-    TSS_HKEY            hMigData                       // in
-);
-
-TSPICALL Tspi_Key_CMKCreateBlob
-(
-    TSS_HKEY            hKeyToMigrate,                 // in
-    TSS_HKEY            hParentKey,                    // in
-    TSS_HMIGDATA        hMigrationData,                // in
-    UINT32*             pulRandomLength,               // out
-    BYTE**              prgbRandom                     // out
-);
-
-TSPICALL Tspi_Key_CMKConvertMigration
-(
-    TSS_HKEY            hKeyToMigrate,                 // in
-    TSS_HKEY            hParentKey,                    // in
-    TSS_HMIGDATA        hMigrationData,                // in
-    UINT32              ulRandomLength,                // in
-    BYTE*               rgbRandom                      // in
-);
-
-
-
-// Hash Class Definition
-TSPICALL Tspi_Hash_Sign
-(
-    TSS_HHASH           hHash,                         // in
-    TSS_HKEY            hKey,                          // in
-    UINT32*             pulSignatureLength,            // out
-    BYTE**              prgbSignature                  // out
-);
-
-TSPICALL Tspi_Hash_VerifySignature
-(
-    TSS_HHASH           hHash,                         // in
-    TSS_HKEY            hKey,                          // in
-    UINT32              ulSignatureLength,             // in
-    BYTE*               rgbSignature                   // in
-);
-
-TSPICALL Tspi_Hash_SetHashValue
-(
-    TSS_HHASH           hHash,                         // in
-    UINT32              ulHashValueLength,             // in
-    BYTE*               rgbHashValue                   // in
-);
-
-TSPICALL Tspi_Hash_GetHashValue
-(
-    TSS_HHASH           hHash,                         // in
-    UINT32*             pulHashValueLength,            // out
-    BYTE**              prgbHashValue                  // out
-);
-
-TSPICALL Tspi_Hash_UpdateHashValue
-(
-    TSS_HHASH           hHash,                         // in
-    UINT32              ulDataLength,                  // in
-    BYTE*               rgbData                        // in
-);
-
-TSPICALL Tspi_Hash_TickStampBlob
-(
-    TSS_HHASH           hHash,                         // in
-    TSS_HKEY            hIdentKey,                     // in
-    TSS_VALIDATION*     pValidationData                // in
-);
-
-
-
-// EncData Class Definition
-TSPICALL Tspi_Data_Bind
-(
-    TSS_HENCDATA        hEncData,                      // in
-    TSS_HKEY            hEncKey,                       // in
-    UINT32              ulDataLength,                  // in
-    BYTE*               rgbDataToBind                  // in
-);
-
-TSPICALL Tspi_Data_Unbind
-(
-    TSS_HENCDATA        hEncData,                      // in
-    TSS_HKEY            hKey,                          // in
-    UINT32*             pulUnboundDataLength,          // out
-    BYTE**              prgbUnboundData                // out
-);
-
-TSPICALL Tspi_Data_Seal
-(
-    TSS_HENCDATA        hEncData,                      // in
-    TSS_HKEY            hEncKey,                       // in
-    UINT32              ulDataLength,                  // in
-    BYTE*               rgbDataToSeal,                 // in
-    TSS_HPCRS           hPcrComposite                  // in
-);
-
-TSPICALL Tspi_Data_Unseal
-(
-    TSS_HENCDATA        hEncData,                      // in
-    TSS_HKEY            hKey,                          // in
-    UINT32*             pulUnsealedDataLength,         // out
-    BYTE**              prgbUnsealedData               // out
-);
-
-
-
-// NV Class Definition
-TSPICALL Tspi_NV_DefineSpace
-(
-    TSS_HNVSTORE        hNVStore,                      // in
-    TSS_HPCRS           hReadPcrComposite,             // in, may be NULL
-    TSS_HPCRS           hWritePcrComposite             // in, may be NULL
-);
-
-TSPICALL Tspi_NV_ReleaseSpace
-(
-    TSS_HNVSTORE        hNVStore                       // in
-);
-
-TSPICALL Tspi_NV_WriteValue
-(
-    TSS_HNVSTORE        hNVStore,                      // in
-    UINT32              offset,                        // in
-    UINT32              ulDataLength,                  // in
-    BYTE*               rgbDataToWrite                 // in
-);
-
-TSPICALL Tspi_NV_ReadValue
-(
-    TSS_HNVSTORE        hNVStore,                      // in
-    UINT32              offset,                        // in
-    UINT32*             ulDataLength,                  // in, out
-    BYTE**              rgbDataRead                    // out
-);
-
-
-// DAA Utility functions (optional, do not require a TPM or TCS)
-TSPICALL Tspi_DAA_IssuerKeyVerify
-(
-    TSS_HDAA_CREDENTIAL           hDAACredential,                // in
-    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
-    TSS_BOOL*                     isCorrect                      // out
-);
-
-TSPICALL Tspi_DAA_Issuer_GenerateKey
-(
-    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
-    UINT32                        issuerBaseNameLength,          // in
-    BYTE*                         issuerBaseName                 // in
-);
-
-TSPICALL Tspi_DAA_Issuer_InitCredential
-(
-    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
-    TSS_HKEY                      issuerAuthPK,                  // in
-    TSS_DAA_IDENTITY_PROOF*       identityProof,                 // in
-    UINT32                        capitalUprimeLength,           // in
-    BYTE*                         capitalUprime,                 // in
-    UINT32                        daaCounter,                    // in
-    UINT32*                       nonceIssuerLength,             // out
-    BYTE**                        nonceIssuer,                   // out
-    UINT32*                       authenticationChallengeLength, // out
-    BYTE**                        authenticationChallenge,       // out
-    UINT32*                       joinSessionLength,             // out
-    BYTE**                        joinSession                    // out
-);
-
-TSPICALL Tspi_DAA_Issuer_IssueCredential
-(
-    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
-    TSS_DAA_CREDENTIAL_REQUEST*   credentialRequest,             // in
-    UINT32                        issuerJoinSessionLength,       // in
-    BYTE*                         issuerJoinSession,             // in
-    TSS_DAA_CRED_ISSUER**         credIssuer                     // out
-);
-
-TSPICALL Tspi_DAA_Verifier_Init
-(
-    TSS_HDAA_CREDENTIAL           hDAACredential,                // in
-    UINT32*                       nonceVerifierLength,           // out
-    BYTE**                        nonceVerifier,                 // out
-    UINT32*                       baseNameLength,                // out
-    BYTE**                        baseName                       // out
-);
-
-TSPICALL Tspi_DAA_VerifySignature
-(
-    TSS_HDAA_CREDENTIAL           hDAACredential,                // in
-    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
-    TSS_HDAA_ARA_KEY              hARAKey,                       // in
-    TSS_HHASH                     hARACondition,                 // in
-    UINT32                        attributesLength,              // in
-    UINT32                        attributesLength2,             // in
-    BYTE**                        attributes,                    // in
-    UINT32                        verifierNonceLength,           // in
-    BYTE*                         verifierNonce,                 // in
-    UINT32                        verifierBaseNameLength,        // in
-    BYTE*                         verifierBaseName,              // in
-    TSS_HOBJECT                   signData,                      // in
-    TSS_DAA_SIGNATURE*            daaSignature,                  // in
-    TSS_BOOL*                     isCorrect                      // out
-);
-
-TSPICALL Tspi_DAA_ARA_GenerateKey
-(
-    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
-    TSS_HDAA_ARA_KEY              hARAKey                        // in
-);
-
-TSPICALL Tspi_DAA_ARA_RevokeAnonymity
-(
-    TSS_HDAA_ARA_KEY              hARAKey,                       // in
-    TSS_HHASH                     hARACondition,                 // in
-    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
-    TSS_DAA_PSEUDONYM_ENCRYPTED*  encryptedPseudonym,            // in
-    TSS_DAA_PSEUDONYM_PLAIN**     pseudonym                      // out
-);
-
-
-
-// Callback typedefs
-typedef TSS_RESULT (*Tspicb_CallbackHMACAuth)
-(
-    PVOID            lpAppData,          // in
-    TSS_HOBJECT      hAuthorizedObject,  // in
-    TSS_BOOL         ReturnOrVerify,     // in
-    UINT32           ulPendingFunction,  // in
-    TSS_BOOL         ContinueUse,        // in
-    UINT32           ulSizeNonces,       // in
-    BYTE*            rgbNonceEven,       // in
-    BYTE*            rgbNonceOdd,        // in
-    BYTE*            rgbNonceEvenOSAP,   // in
-    BYTE*            rgbNonceOddOSAP,    // in
-    UINT32           ulSizeDigestHmac,   // in
-    BYTE*            rgbParamDigest,     // in
-    BYTE*            rgbHmacData         // in, out
-);
-
-typedef TSS_RESULT (*Tspicb_CallbackXorEnc)
-(
-   PVOID            lpAppData,            // in
-   TSS_HOBJECT      hOSAPObject,          // in
-   TSS_HOBJECT      hObject,              // in
-   TSS_FLAG         PurposeSecret,        // in
-   UINT32           ulSizeNonces,         // in
-   BYTE*            rgbNonceEven,         // in
-   BYTE*            rgbNonceOdd,          // in
-   BYTE*            rgbNonceEvenOSAP,     // in
-   BYTE*            rgbNonceOddOSAP,      // in
-   UINT32           ulSizeEncAuth,        // in
-   BYTE*            rgbEncAuthUsage,      // out
-   BYTE*            rgbEncAuthMigration   // out
-);
-
-typedef TSS_RESULT (*Tspicb_CallbackTakeOwnership)
-(
-   PVOID            lpAppData,         // in
-   TSS_HOBJECT      hObject,           // in
-   TSS_HKEY         hObjectPubKey,     // in
-   UINT32           ulSizeEncAuth,     // in
-   BYTE*            rgbEncAuth         // out
-);
-
-typedef TSS_RESULT (*Tspicb_CallbackSealxMask)
-(
-    PVOID            lpAppData,        // in
-    TSS_HKEY         hKey,             // in
-    TSS_HENCDATA     hEncData,         // in
-    TSS_ALGORITHM_ID algID,            // in
-    UINT32           ulSizeNonces,     // in
-    BYTE*            rgbNonceEven,     // in
-    BYTE*            rgbNonceOdd,      // in
-    BYTE*            rgbNonceEvenOSAP, // in
-    BYTE*            rgbNonceOddOSAP,  // in
-    UINT32           ulDataLength,     // in
-    BYTE*            rgbDataToMask,    // in
-    BYTE*            rgbMaskedData     // out
-);
-
-typedef TSS_RESULT (*Tspicb_CallbackChangeAuthAsym)
-(
-   PVOID            lpAppData,        // in
-   TSS_HOBJECT      hObject,          // in
-   TSS_HKEY         hObjectPubKey,    // in
-   UINT32           ulSizeEncAuth,    // in
-   UINT32           ulSizeAuthLink,   // in
-   BYTE*            rgbEncAuth,       // out
-   BYTE*            rgbAuthLink       // out
-);
-
-typedef TSS_RESULT (*Tspicb_CollateIdentity)
-(
-   PVOID            lpAppData,                      // in
-   UINT32           ulTCPAPlainIdentityProofLength, // in
-   BYTE*            rgbTCPAPlainIdentityProof,      // in
-   TSS_ALGORITHM_ID algID,                          // in
-   UINT32           ulSessionKeyLength,             // out
-   BYTE*            rgbSessionKey,                  // out
-   UINT32*          pulTCPAIdentityProofLength,     // out
-   BYTE*            rgbTCPAIdentityProof            // out
-);
-
-
-typedef TSS_RESULT (*Tspicb_ActivateIdentity)
-(
-   PVOID            lpAppData,                    // in
-   UINT32           ulSessionKeyLength,           // in
-   BYTE*            rgbSessionKey,                // in
-   UINT32           ulSymCAAttestationBlobLength, // in
-   BYTE*            rgbSymCAAttestationBlob,      // in
-   UINT32*          pulCredentialLength,          // out
-   BYTE*            rgbCredential                 // out
-);
-
-
-typedef TSS_RESULT (*Tspicb_DAA_Sign)
-(
-    PVOID                        lpAppData,                 // in
-    TSS_HDAA_ISSUER_KEY          daaPublicKey,              // in
-    UINT32                       gammasLength,              // in
-    BYTE**                       gammas,                    // in
-    UINT32                       attributesLength,          // in
-    BYTE**                       attributes,                // in
-    UINT32                       randomAttributesLength,    // in
-    BYTE**                       randomAttributes,          // in
-    UINT32                       attributeCommitmentsLength,// in
-    TSS_DAA_ATTRIB_COMMIT*       attributeCommitments,      // in
-    TSS_DAA_ATTRIB_COMMIT*       attributeCommitmentsProof, // in
-    TSS_DAA_PSEUDONYM_PLAIN*     pseudonym,                 // in
-    TSS_DAA_PSEUDONYM_PLAIN*     pseudonymTilde,            // in
-    TSS_DAA_PSEUDONYM_ENCRYPTED* pseudonymEncrypted,        // in
-    TSS_DAA_PSEUDONYM_ENCRYPTED* pseudonymEncProof,         // in
-    TSS_DAA_SIGN_CALLBACK**      additionalProof            // out
-);
-
-typedef TSS_RESULT (*Tspicb_DAA_VerifySignature)
-(
-    PVOID                        lpAppData,                 // in
-    UINT32                       challengeLength,           // in
-    BYTE*                        challenge,                 // in
-    TSS_DAA_SIGN_CALLBACK*       additionalProof,           // in
-    TSS_HDAA_ISSUER_KEY          daaPublicKey,              // in
-    UINT32                       gammasLength,              // in
-    BYTE**                       gammas,                    // in
-    UINT32                       sAttributesLength,         // in
-    BYTE**                       sAttributes,               // in
-    UINT32                       attributeCommitmentsLength,// in
-    TSS_DAA_ATTRIB_COMMIT*       attributeCommitments,      // in
-    TSS_DAA_ATTRIB_COMMIT*       attributeCommitmentsProof, // in
-    UINT32                       zetaLength,                // in
-    BYTE*                        zeta,                      // in
-    UINT32                       sFLength,                  // in
-    BYTE*                        sF,                        // in
-    TSS_DAA_PSEUDONYM*           pseudonym,                 // in
-    TSS_DAA_PSEUDONYM*           pseudonymProof,            // in
-    TSS_BOOL*                    isCorrect                  // out
-);
-
-
-#if defined ( __cplusplus )
-}
-#endif /* __cplusplus */
-
-
-#endif /* _TSPI_H_ */
+#if !defined(_TSPI_H_)
+#define _TSPI_H_
+
+#include <tss/tss_defines.h>
+#include <tss/tss_typedef.h>
+#include <tss/tss_structs.h>
+#include <tss/tss_error.h>
+#include <tss/tss_error_basics.h>
+
+#if !defined( TSPICALL )
+  #if !defined(WIN32) || defined (TSP_STATIC)
+    // Linux, or a Win32 static library
+    #define TSPICALL extern TSS_RESULT
+  #elif defined (TSPDLL_EXPORTS)
+    // Win32 DLL build
+    #define TSPICALL extern __declspec(dllexport) TSS_RESULT
+  #else
+    // Win32 DLL import
+    #define TSPICALL extern __declspec(dllimport) TSS_RESULT
+  #endif
+#endif /* TSPICALL */
+
+#if defined ( __cplusplus )
+extern "C" {
+#endif /* __cplusplus */
+
+
+// Class-independent ASN.1 conversion functions
+TSPICALL Tspi_EncodeDER_TssBlob
+(
+    UINT32              rawBlobSize,                   // in
+    BYTE*               rawBlob,                       // in
+    UINT32              blobType,                      // in
+    UINT32*             derBlobSize,                   // in, out
+    BYTE*               derBlob                        // out
+);
+
+TSPICALL Tspi_DecodeBER_TssBlob
+(
+    UINT32              berBlobSize,                   // in
+    BYTE*               berBlob,                       // in
+    UINT32*             blobType,                      // out
+    UINT32*             rawBlobSize,                   // in, out
+    BYTE*               rawBlob                        // out
+);
+
+
+
+// Common Methods
+TSPICALL Tspi_SetAttribUint32
+(
+    TSS_HOBJECT         hObject,                       // in
+    TSS_FLAG            attribFlag,                    // in
+    TSS_FLAG            subFlag,                       // in
+    UINT32              ulAttrib                       // in
+);
+
+TSPICALL Tspi_GetAttribUint32
+(
+    TSS_HOBJECT         hObject,                       // in
+    TSS_FLAG            attribFlag,                    // in
+    TSS_FLAG            subFlag,                       // in
+    UINT32*             pulAttrib                      // out
+);
+
+TSPICALL Tspi_SetAttribData
+(
+    TSS_HOBJECT         hObject,                       // in
+    TSS_FLAG            attribFlag,                    // in
+    TSS_FLAG            subFlag,                       // in
+    UINT32              ulAttribDataSize,              // in
+    BYTE*               rgbAttribData                  // in
+);
+
+TSPICALL Tspi_GetAttribData
+(
+    TSS_HOBJECT         hObject,                       // in
+    TSS_FLAG            attribFlag,                    // in
+    TSS_FLAG            subFlag,                       // in
+    UINT32*             pulAttribDataSize,             // out
+    BYTE**              prgbAttribData                 // out
+);
+
+TSPICALL Tspi_ChangeAuth
+(
+    TSS_HOBJECT         hObjectToChange,               // in
+    TSS_HOBJECT         hParentObject,                 // in
+    TSS_HPOLICY         hNewPolicy                     // in
+);
+
+TSPICALL Tspi_ChangeAuthAsym
+(
+    TSS_HOBJECT         hObjectToChange,               // in
+    TSS_HOBJECT         hParentObject,                 // in
+    TSS_HKEY            hIdentKey,                     // in
+    TSS_HPOLICY         hNewPolicy                     // in
+);
+
+TSPICALL Tspi_GetPolicyObject
+(
+    TSS_HOBJECT         hObject,                       // in
+    TSS_FLAG            policyType,                    // in
+    TSS_HPOLICY*        phPolicy                       // out
+);
+
+
+
+// Tspi_Context Class Definitions
+TSPICALL Tspi_Context_Create
+(
+    TSS_HCONTEXT*       phContext                      // out
+);
+
+TSPICALL Tspi_Context_Close
+(
+    TSS_HCONTEXT        hContext                       // in
+);
+
+TSPICALL Tspi_Context_Connect
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_UNICODE*        wszDestination                 // in
+);
+
+TSPICALL Tspi_Context_FreeMemory
+(
+    TSS_HCONTEXT        hContext,                      // in
+    BYTE*               rgbMemory                      // in
+);
+
+TSPICALL Tspi_Context_GetDefaultPolicy
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_HPOLICY*        phPolicy                       // out
+);
+
+TSPICALL Tspi_Context_CreateObject
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_FLAG            objectType,                    // in
+    TSS_FLAG            initFlags,                     // in
+    TSS_HOBJECT*        phObject                       // out
+);
+
+TSPICALL Tspi_Context_CloseObject
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_HOBJECT         hObject                        // in
+);
+
+TSPICALL Tspi_Context_GetCapability
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_FLAG            capArea,                       // in
+    UINT32              ulSubCapLength,                // in
+    BYTE*               rgbSubCap,                     // in
+    UINT32*             pulRespDataLength,             // out
+    BYTE**              prgbRespData                   // out
+);
+
+TSPICALL Tspi_Context_GetTpmObject
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_HTPM*           phTPM                          // out
+);
+
+TSPICALL Tspi_Context_SetTransEncryptionKey
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_HKEY            hKey                           // in
+);
+
+TSPICALL Tspi_Context_CloseSignTransport
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_HKEY            hSigningKey,                   // in
+    TSS_VALIDATION*     pValidationData                // in, out
+);
+
+TSPICALL Tspi_Context_LoadKeyByBlob
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_HKEY            hUnwrappingKey,                // in
+    UINT32              ulBlobLength,                  // in
+    BYTE*               rgbBlobData,                   // in
+    TSS_HKEY*           phKey                          // out
+);
+
+TSPICALL Tspi_Context_LoadKeyByUUID
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_FLAG            persistentStorageType,         // in
+    TSS_UUID            uuidData,                      // in
+    TSS_HKEY*           phKey                          // out
+);
+
+TSPICALL Tspi_Context_RegisterKey
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_HKEY            hKey,                          // in
+    TSS_FLAG            persistentStorageType,         // in
+    TSS_UUID            uuidKey,                       // in
+    TSS_FLAG            persistentStorageTypeParent,   // in
+    TSS_UUID            uuidParentKey                  // in
+);
+
+TSPICALL Tspi_Context_UnregisterKey
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_FLAG            persistentStorageType,         // in
+    TSS_UUID            uuidKey,                       // in
+    TSS_HKEY*           phkey                          // out
+);
+
+TSPICALL Tspi_Context_GetKeyByUUID
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_FLAG            persistentStorageType,         // in
+    TSS_UUID            uuidData,                      // in
+    TSS_HKEY*           phKey                          // out
+);
+
+TSPICALL Tspi_Context_GetKeyByPublicInfo
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_FLAG            persistentStorageType,         // in
+    TSS_ALGORITHM_ID    algID,                         // in
+    UINT32              ulPublicInfoLength,            // in
+    BYTE*               rgbPublicInfo,                 // in
+    TSS_HKEY*           phKey                          // out
+);
+
+TSPICALL Tspi_Context_GetRegisteredKeysByUUID
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_FLAG            persistentStorageType,         // in
+    TSS_UUID*           pUuidData,                     // in
+    UINT32*             pulKeyHierarchySize,           // out
+    TSS_KM_KEYINFO**    ppKeyHierarchy                 // out
+);
+
+TSPICALL Tspi_Context_GetRegisteredKeysByUUID2
+(
+    TSS_HCONTEXT        hContext,                      // in
+    TSS_FLAG            persistentStorageType,         // in
+    TSS_UUID*           pUuidData,                     // in
+    UINT32*             pulKeyHierarchySize,           // out
+    TSS_KM_KEYINFO2**   ppKeyHierarchy                 // out
+);
+
+
+// Policy class definitions
+TSPICALL Tspi_Policy_SetSecret
+(
+    TSS_HPOLICY         hPolicy,                       // in
+    TSS_FLAG            secretMode,                    // in
+    UINT32              ulSecretLength,                // in
+    BYTE*               rgbSecret                      // in
+);
+
+TSPICALL Tspi_Policy_FlushSecret
+(
+    TSS_HPOLICY         hPolicy                        // in
+);
+
+TSPICALL Tspi_Policy_AssignToObject
+(
+    TSS_HPOLICY         hPolicy,                       // in
+    TSS_HOBJECT         hObject                        // in
+);
+
+
+
+// TPM Class Definitions
+TSPICALL Tspi_TPM_KeyControlOwner
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hKey,                          // in
+    UINT32              attribName,                    // in
+    TSS_BOOL            attribValue,                   // in
+    TSS_UUID*           pUuidData                      // out
+);
+
+TSPICALL Tspi_TPM_CreateEndorsementKey
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hKey,                          // in
+    TSS_VALIDATION*     pValidationData                // in, out
+);
+
+TSPICALL Tspi_TPM_CreateRevocableEndorsementKey
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hKey,                          // in
+    TSS_VALIDATION*     pValidationData,               // in, out
+    UINT32*             pulEkResetDataLength,          // in, out
+    BYTE**              rgbEkResetData                 // in, out
+);
+
+TSPICALL Tspi_TPM_RevokeEndorsementKey
+(
+    TSS_HTPM            hTPM,                          // in
+    UINT32              ulEkResetDataLength,           // in
+    BYTE*               rgbEkResetData                 // in
+);
+
+TSPICALL Tspi_TPM_GetPubEndorsementKey
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_BOOL            fOwnerAuthorized,              // in
+    TSS_VALIDATION*     pValidationData,               // in, out
+    TSS_HKEY*           phEndorsementPubKey            // out
+);
+
+TSPICALL Tspi_TPM_OwnerGetSRKPubKey
+(
+    TSS_HTPM            hTPM,                          // in
+    UINT32*             pulPubKeyLength,               // out
+    BYTE**              prgbPubKey                     // out
+);
+
+TSPICALL Tspi_TPM_TakeOwnership
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hKeySRK,                       // in
+    TSS_HKEY            hEndorsementPubKey             // in
+);
+
+TSPICALL Tspi_TPM_ClearOwner
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_BOOL            fForcedClear                   // in
+);
+
+TSPICALL Tspi_TPM_CollateIdentityRequest
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hKeySRK,                       // in
+    TSS_HKEY            hCAPubKey,                     // in
+    UINT32              ulIdentityLabelLength,         // in
+    BYTE*               rgbIdentityLabelData,          // in
+    TSS_HKEY            hIdentityKey,                  // in
+    TSS_ALGORITHM_ID    algID,                         // in
+    UINT32*             pulTCPAIdentityReqLength,      // out
+    BYTE**              prgbTCPAIdentityReq            // out
+);
+
+TSPICALL Tspi_TPM_ActivateIdentity
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hIdentKey,                     // in
+    UINT32              ulAsymCAContentsBlobLength,    // in
+    BYTE*               rgbAsymCAContentsBlob,         // in
+    UINT32              ulSymCAAttestationBlobLength,  // in
+    BYTE*               rgbSymCAAttestationBlob,       // in
+    UINT32*             pulCredentialLength,           // out
+    BYTE**              prgbCredential                 // out
+);
+
+TSPICALL Tspi_TPM_CreateMaintenanceArchive
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_BOOL            fGenerateRndNumber,            // in
+    UINT32*             pulRndNumberLength,            // out
+    BYTE**              prgbRndNumber,                 // out
+    UINT32*             pulArchiveDataLength,          // out
+    BYTE**              prgbArchiveData                // out
+);
+
+TSPICALL Tspi_TPM_KillMaintenanceFeature
+(
+    TSS_HTPM            hTPM                           // in
+);
+
+TSPICALL Tspi_TPM_LoadMaintenancePubKey
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hMaintenanceKey,               // in
+    TSS_VALIDATION*     pValidationData                // in, out
+);
+
+TSPICALL Tspi_TPM_CheckMaintenancePubKey
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hMaintenanceKey,               // in
+    TSS_VALIDATION*     pValidationData                // in, out
+);
+
+TSPICALL Tspi_TPM_SetOperatorAuth
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HPOLICY         hOperatorPolicy                // in
+);
+
+TSPICALL Tspi_TPM_SetStatus
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_FLAG            statusFlag,                    // in
+    TSS_BOOL            fTpmState                      // in
+);
+
+TSPICALL Tspi_TPM_GetStatus
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_FLAG            statusFlag,                    // in
+    TSS_BOOL*           pfTpmState                     // out
+);
+
+TSPICALL Tspi_TPM_GetCapability
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_FLAG            capArea,                       // in
+    UINT32              ulSubCapLength,                // in
+    BYTE*               rgbSubCap,                     // in
+    UINT32*             pulRespDataLength,             // out
+    BYTE**              prgbRespData                   // out
+);
+
+TSPICALL Tspi_TPM_GetCapabilitySigned
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hKey,                          // in
+    TSS_FLAG            capArea,                       // in
+    UINT32              ulSubCapLength,                // in
+    BYTE*               rgbSubCap,                     // in
+    TSS_VALIDATION*     pValidationData,               // in, out
+    UINT32*             pulRespDataLength,             // out
+    BYTE**              prgbRespData                   // out
+);
+
+TSPICALL Tspi_TPM_SelfTestFull
+(
+    TSS_HTPM            hTPM                           // in
+);
+
+TSPICALL Tspi_TPM_CertifySelfTest
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hKey,                          // in
+    TSS_VALIDATION*     pValidationData                // in, out
+);
+
+TSPICALL Tspi_TPM_GetTestResult
+(
+    TSS_HTPM            hTPM,                          // in
+    UINT32*             pulTestResultLength,           // out
+    BYTE**              prgbTestResult                 // out
+);
+
+TSPICALL Tspi_TPM_GetRandom
+(
+    TSS_HTPM            hTPM,                          // in
+    UINT32              ulRandomDataLength,            // in
+    BYTE**              prgbRandomData                 // out
+);
+
+TSPICALL Tspi_TPM_StirRandom
+(
+    TSS_HTPM            hTPM,                          // in
+    UINT32              ulEntropyDataLength,           // in
+    BYTE*               rgbEntropyData                 // in
+);
+
+TSPICALL Tspi_TPM_GetEvent
+(
+    TSS_HTPM            hTPM,                          // in
+    UINT32              ulPcrIndex,                    // in
+    UINT32              ulEventNumber,                 // in
+    TSS_PCR_EVENT*      pPcrEvent                      // out
+);
+
+TSPICALL Tspi_TPM_GetEvents
+(
+    TSS_HTPM            hTPM,                          // in
+    UINT32              ulPcrIndex,                    // in
+    UINT32              ulStartNumber,                 // in
+    UINT32*             pulEventNumber,                // in, out
+    TSS_PCR_EVENT**     prgPcrEvents                   // out
+);
+
+TSPICALL Tspi_TPM_GetEventLog
+(
+    TSS_HTPM            hTPM,                          // in
+    UINT32*             pulEventNumber,                // out
+    TSS_PCR_EVENT**     prgPcrEvents                   // out
+);
+
+TSPICALL Tspi_TPM_Quote
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hIdentKey,                     // in
+    TSS_HPCRS           hPcrComposite,                 // in
+    TSS_VALIDATION*     pValidationData                // in, out
+);
+
+TSPICALL Tspi_TPM_Quote2
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hIdentKey,                     // in
+    TSS_BOOL            fAddVersion,                   // in
+    TSS_HPCRS           hPcrComposite,                 // in
+    TSS_VALIDATION*     pValidationData,               // in, out
+    UINT32*             versionInfoSize,               // out
+    BYTE**              versionInfo                    // out
+);
+
+TSPICALL Tspi_TPM_PcrExtend
+(
+    TSS_HTPM            hTPM,                          // in
+    UINT32              ulPcrIndex,                    // in
+    UINT32              ulPcrDataLength,               // in
+    BYTE*               pbPcrData,                     // in
+    TSS_PCR_EVENT*      pPcrEvent,                     // in
+    UINT32*             pulPcrValueLength,             // out
+    BYTE**              prgbPcrValue                   // out
+);
+
+TSPICALL Tspi_TPM_PcrRead
+(
+    TSS_HTPM            hTPM,                          // in
+    UINT32              ulPcrIndex,                    // in
+    UINT32*             pulPcrValueLength,             // out
+    BYTE**              prgbPcrValue                   // out
+);
+
+TSPICALL Tspi_TPM_PcrReset
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HPCRS           hPcrComposite                  // in
+);
+
+TSPICALL Tspi_TPM_AuthorizeMigrationTicket
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hMigrationKey,                 // in
+    TSS_MIGRATE_SCHEME  migrationScheme,               // in
+    UINT32*             pulMigTicketLength,            // out
+    BYTE**              prgbMigTicket                  // out
+);
+
+TSPICALL Tspi_TPM_CMKSetRestrictions
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_CMK_DELEGATE    CmkDelegate                    // in
+);
+
+TSPICALL Tspi_TPM_CMKApproveMA
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HMIGDATA        hMaAuthData                    // in
+);
+
+TSPICALL Tspi_TPM_CMKCreateTicket
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hVerifyKey,                    // in
+    TSS_HMIGDATA        hSigData                       // in
+);
+
+TSPICALL Tspi_TPM_ReadCounter
+(
+    TSS_HTPM            hTPM,                          // in
+    UINT32*             counterValue                   // out
+);
+
+TSPICALL Tspi_TPM_ReadCurrentTicks
+(
+    TSS_HTPM            hTPM,                          // in
+    TPM_CURRENT_TICKS*  tickCount                      // out
+);
+
+TSPICALL Tspi_TPM_DirWrite
+(
+    TSS_HTPM            hTPM,                          // in
+    UINT32              ulDirIndex,                    // in
+    UINT32              ulDirDataLength,               // in
+    BYTE*               rgbDirData                     // in
+);
+
+TSPICALL Tspi_TPM_DirRead
+(
+    TSS_HTPM            hTPM,                          // in
+    UINT32              ulDirIndex,                    // in
+    UINT32*             pulDirDataLength,              // out
+    BYTE**              prgbDirData                    // out
+);
+
+TSPICALL Tspi_TPM_Delegate_AddFamily
+(
+    TSS_HTPM            hTPM,                          // in, must not be NULL
+    BYTE                bLabel,                        // in
+    TSS_HDELFAMILY*     phFamily                       // out
+);
+
+TSPICALL Tspi_TPM_Delegate_GetFamily
+(
+    TSS_HTPM            hTPM,                          // in, must not NULL
+    UINT32              ulFamilyID,                    // in
+    TSS_HDELFAMILY*     phFamily                       // out
+);
+
+TSPICALL Tspi_TPM_Delegate_InvalidateFamily
+(
+    TSS_HTPM            hTPM,                          // in, must not be NULL
+    TSS_HDELFAMILY      hFamily                        // in
+);
+
+TSPICALL Tspi_TPM_Delegate_CreateDelegation
+(
+    TSS_HOBJECT         hObject,                       // in
+    BYTE                bLabel,                        // in
+    UINT32              ulFlags,                       // in
+    TSS_HPCRS           hPcr,                          // in, may be NULL
+    TSS_HDELFAMILY      hFamily,                       // in
+    TSS_HPOLICY         hDelegation                    // in, out
+);
+
+TSPICALL Tspi_TPM_Delegate_CacheOwnerDelegation
+(
+    TSS_HTPM            hTPM,                          // in, must not be NULL
+    TSS_HPOLICY         hDelegation,                   // in, out
+    UINT32              ulIndex,                       // in
+    UINT32              ulFlags                        // in
+);
+
+TSPICALL Tspi_TPM_Delegate_UpdateVerificationCount
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HPOLICY         hDelegation                    // in, out
+);
+
+TSPICALL Tspi_TPM_Delegate_VerifyDelegation
+(
+    TSS_HPOLICY         hDelegation                    // in, out
+);
+
+TSPICALL Tspi_TPM_Delegate_ReadTables
+(
+    TSS_HCONTEXT                  hContext,                      // in
+    UINT32*                       pulFamilyTableSize,            // out
+    TSS_FAMILY_TABLE_ENTRY**      ppFamilyTable,                 // out
+    UINT32*                       pulDelegateTableSize,          // out
+    TSS_DELEGATION_TABLE_ENTRY**  ppDelegateTable                // out
+);
+
+TSPICALL Tspi_TPM_DAA_JoinInit
+(
+    TSS_HTPM                      hTPM,                          // in
+    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
+    UINT32                        daaCounter,                    // in
+    UINT32                        issuerAuthPKsLength,           // in
+    TSS_HKEY*                     issuerAuthPKs,                 // in
+    UINT32                        issuerAuthPKSignaturesLength,  // in
+    UINT32                        issuerAuthPKSignaturesLength2, // in
+    BYTE**                        issuerAuthPKSignatures,        // in
+    UINT32*                       capitalUprimeLength,           // out
+    BYTE**                        capitalUprime,                 // out
+    TSS_DAA_IDENTITY_PROOF**      identityProof,                 // out
+    UINT32*                       joinSessionLength,             // out
+    BYTE**                        joinSession                    // out
+);
+
+TSPICALL Tspi_TPM_DAA_JoinCreateDaaPubKey
+(
+    TSS_HTPM                      hTPM,                          // in
+    TSS_HDAA_CREDENTIAL           hDAACredential,                // in
+    UINT32                        authenticationChallengeLength, // in
+    BYTE*                         authenticationChallenge,       // in
+    UINT32                        nonceIssuerLength,             // in
+    BYTE*                         nonceIssuer,                   // in
+    UINT32                        attributesPlatformLength,      // in
+    UINT32                        attributesPlatformLength2,     // in
+    BYTE**                        attributesPlatform,            // in
+    UINT32                        joinSessionLength,             // in
+    BYTE*                         joinSession,                   // in
+    TSS_DAA_CREDENTIAL_REQUEST**  credentialRequest              // out
+);
+
+TSPICALL Tspi_TPM_DAA_JoinStoreCredential
+(
+    TSS_HTPM                      hTPM,                          // in
+    TSS_HDAA_CREDENTIAL           hDAACredential,                // in
+    TSS_DAA_CRED_ISSUER*          credIssuer,                    // in
+    UINT32                        joinSessionLength,             // in
+    BYTE*                         joinSession                    // in
+);
+
+TSPICALL Tspi_TPM_DAA_Sign
+(
+    TSS_HTPM                      hTPM,                          // in
+    TSS_HDAA_CREDENTIAL           hDAACredential,                // in
+    TSS_HDAA_ARA_KEY              hARAKey,                       // in
+    TSS_DAA_SELECTED_ATTRIB*      revealAttributes,              // in
+    UINT32                        verifierNonceLength,           // in
+    BYTE*                         verifierNonce,                 // in
+    UINT32                        verifierBaseNameLength,        // in
+    BYTE*                         verifierBaseName,              // in
+    TSS_HOBJECT                   signData,                      // in
+    TSS_DAA_SIGNATURE**           daaSignature                   // out
+);
+
+TSPICALL Tspi_TPM_GetAuditDigest
+(
+    TSS_HTPM            hTPM,                          // in
+    TSS_HKEY            hKey,                          // in
+    TSS_BOOL            closeAudit,                    // in
+    UINT32*             pulAuditDigestSize,            // out
+    BYTE**              prgbAuditDigest,               // out
+    TPM_COUNTER_VALUE*  pCounterValue,                 // out
+    TSS_VALIDATION*     pValidationData,               // out
+    UINT32*             ordSize,                       // out
+    UINT32**            ordList                        // out
+);
+
+
+
+// PcrComposite Class Definitions
+TSPICALL Tspi_PcrComposite_SelectPcrIndex
+(
+    TSS_HPCRS           hPcrComposite,                 // in
+    UINT32              ulPcrIndex                     // in
+);
+
+TSPICALL Tspi_PcrComposite_SelectPcrIndexEx
+(
+    TSS_HPCRS           hPcrComposite,                 // in
+    UINT32              ulPcrIndex,                    // in
+    UINT32              direction                      // in
+);
+
+TSPICALL Tspi_PcrComposite_SetPcrValue
+(
+    TSS_HPCRS           hPcrComposite,                 // in
+    UINT32              ulPcrIndex,                    // in
+    UINT32              ulPcrValueLength,              // in
+    BYTE*               rgbPcrValue                    // in
+);
+
+TSPICALL Tspi_PcrComposite_GetPcrValue
+(
+    TSS_HPCRS           hPcrComposite,                 // in
+    UINT32              ulPcrIndex,                    // in
+    UINT32*             pulPcrValueLength,             // out
+    BYTE**              prgbPcrValue                   // out
+);
+
+TSPICALL Tspi_PcrComposite_SetPcrLocality
+(
+    TSS_HPCRS           hPcrComposite,                 // in
+    UINT32              LocalityValue                  // in
+);
+
+TSPICALL Tspi_PcrComposite_GetPcrLocality
+(
+    TSS_HPCRS           hPcrComposite,                 // in
+    UINT32*             pLocalityValue                 // out
+);
+
+TSPICALL Tspi_PcrComposite_GetCompositeHash
+(
+    TSS_HPCRS           hPcrComposite,                 // in
+    UINT32*             pLen,                          // in
+    BYTE**              ppbHashData                    // out
+);
+
+
+
+// Key Class Definition
+TSPICALL Tspi_Key_LoadKey
+(
+    TSS_HKEY            hKey,                          // in
+    TSS_HKEY            hUnwrappingKey                 // in
+);
+
+TSPICALL Tspi_Key_UnloadKey
+(
+    TSS_HKEY            hKey                           // in
+);
+
+TSPICALL Tspi_Key_GetPubKey
+(
+    TSS_HKEY            hKey,                          // in
+    UINT32*             pulPubKeyLength,               // out
+    BYTE**              prgbPubKey                     // out
+);
+
+TSPICALL Tspi_Key_CertifyKey
+(
+    TSS_HKEY            hKey,                          // in
+    TSS_HKEY            hCertifyingKey,                // in
+    TSS_VALIDATION*     pValidationData                // in, out
+);
+
+TSPICALL Tspi_Key_CreateKey
+(
+    TSS_HKEY            hKey,                          // in
+    TSS_HKEY            hWrappingKey,                  // in
+    TSS_HPCRS           hPcrComposite                  // in, may be NULL
+);
+
+TSPICALL Tspi_Key_WrapKey
+(
+    TSS_HKEY            hKey,                          // in
+    TSS_HKEY            hWrappingKey,                  // in
+    TSS_HPCRS           hPcrComposite                  // in, may be NULL
+);
+
+TSPICALL Tspi_Key_CreateMigrationBlob
+(
+    TSS_HKEY            hKeyToMigrate,                 // in
+    TSS_HKEY            hParentKey,                    // in
+    UINT32              ulMigTicketLength,             // in
+    BYTE*               rgbMigTicket,                  // in
+    UINT32*             pulRandomLength,               // out
+    BYTE**              prgbRandom,                    // out
+    UINT32*             pulMigrationBlobLength,        // out
+    BYTE**              prgbMigrationBlob              // out
+);
+
+TSPICALL Tspi_Key_ConvertMigrationBlob
+(
+    TSS_HKEY            hKeyToMigrate,                 // in
+    TSS_HKEY            hParentKey,                    // in
+    UINT32              ulRandomLength,                // in
+    BYTE*               rgbRandom,                     // in
+    UINT32              ulMigrationBlobLength,         // in
+    BYTE*               rgbMigrationBlob               // in
+);
+
+TSPICALL Tspi_Key_MigrateKey
+(
+    TSS_HKEY            hMaKey,                        // in
+    TSS_HKEY            hPublicKey,                    // in
+    TSS_HKEY            hMigData                       // in
+);
+
+TSPICALL Tspi_Key_CMKCreateBlob
+(
+    TSS_HKEY            hKeyToMigrate,                 // in
+    TSS_HKEY            hParentKey,                    // in
+    TSS_HMIGDATA        hMigrationData,                // in
+    UINT32*             pulRandomLength,               // out
+    BYTE**              prgbRandom                     // out
+);
+
+TSPICALL Tspi_Key_CMKConvertMigration
+(
+    TSS_HKEY            hKeyToMigrate,                 // in
+    TSS_HKEY            hParentKey,                    // in
+    TSS_HMIGDATA        hMigrationData,                // in
+    UINT32              ulRandomLength,                // in
+    BYTE*               rgbRandom                      // in
+);
+
+
+
+// Hash Class Definition
+TSPICALL Tspi_Hash_Sign
+(
+    TSS_HHASH           hHash,                         // in
+    TSS_HKEY            hKey,                          // in
+    UINT32*             pulSignatureLength,            // out
+    BYTE**              prgbSignature                  // out
+);
+
+TSPICALL Tspi_Hash_VerifySignature
+(
+    TSS_HHASH           hHash,                         // in
+    TSS_HKEY            hKey,                          // in
+    UINT32              ulSignatureLength,             // in
+    BYTE*               rgbSignature                   // in
+);
+
+TSPICALL Tspi_Hash_SetHashValue
+(
+    TSS_HHASH           hHash,                         // in
+    UINT32              ulHashValueLength,             // in
+    BYTE*               rgbHashValue                   // in
+);
+
+TSPICALL Tspi_Hash_GetHashValue
+(
+    TSS_HHASH           hHash,                         // in
+    UINT32*             pulHashValueLength,            // out
+    BYTE**              prgbHashValue                  // out
+);
+
+TSPICALL Tspi_Hash_UpdateHashValue
+(
+    TSS_HHASH           hHash,                         // in
+    UINT32              ulDataLength,                  // in
+    BYTE*               rgbData                        // in
+);
+
+TSPICALL Tspi_Hash_TickStampBlob
+(
+    TSS_HHASH           hHash,                         // in
+    TSS_HKEY            hIdentKey,                     // in
+    TSS_VALIDATION*     pValidationData                // in
+);
+
+
+
+// EncData Class Definition
+TSPICALL Tspi_Data_Bind
+(
+    TSS_HENCDATA        hEncData,                      // in
+    TSS_HKEY            hEncKey,                       // in
+    UINT32              ulDataLength,                  // in
+    BYTE*               rgbDataToBind                  // in
+);
+
+TSPICALL Tspi_Data_Unbind
+(
+    TSS_HENCDATA        hEncData,                      // in
+    TSS_HKEY            hKey,                          // in
+    UINT32*             pulUnboundDataLength,          // out
+    BYTE**              prgbUnboundData                // out
+);
+
+TSPICALL Tspi_Data_Seal
+(
+    TSS_HENCDATA        hEncData,                      // in
+    TSS_HKEY            hEncKey,                       // in
+    UINT32              ulDataLength,                  // in
+    BYTE*               rgbDataToSeal,                 // in
+    TSS_HPCRS           hPcrComposite                  // in
+);
+
+TSPICALL Tspi_Data_Unseal
+(
+    TSS_HENCDATA        hEncData,                      // in
+    TSS_HKEY            hKey,                          // in
+    UINT32*             pulUnsealedDataLength,         // out
+    BYTE**              prgbUnsealedData               // out
+);
+
+
+
+// NV Class Definition
+TSPICALL Tspi_NV_DefineSpace
+(
+    TSS_HNVSTORE        hNVStore,                      // in
+    TSS_HPCRS           hReadPcrComposite,             // in, may be NULL
+    TSS_HPCRS           hWritePcrComposite             // in, may be NULL
+);
+
+TSPICALL Tspi_NV_ReleaseSpace
+(
+    TSS_HNVSTORE        hNVStore                       // in
+);
+
+TSPICALL Tspi_NV_WriteValue
+(
+    TSS_HNVSTORE        hNVStore,                      // in
+    UINT32              offset,                        // in
+    UINT32              ulDataLength,                  // in
+    BYTE*               rgbDataToWrite                 // in
+);
+
+TSPICALL Tspi_NV_ReadValue
+(
+    TSS_HNVSTORE        hNVStore,                      // in
+    UINT32              offset,                        // in
+    UINT32*             ulDataLength,                  // in, out
+    BYTE**              rgbDataRead                    // out
+);
+
+
+// DAA Utility functions (optional, do not require a TPM or TCS)
+TSPICALL Tspi_DAA_IssuerKeyVerify
+(
+    TSS_HDAA_CREDENTIAL           hDAACredential,                // in
+    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
+    TSS_BOOL*                     isCorrect                      // out
+);
+
+TSPICALL Tspi_DAA_Issuer_GenerateKey
+(
+    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
+    UINT32                        issuerBaseNameLength,          // in
+    BYTE*                         issuerBaseName                 // in
+);
+
+TSPICALL Tspi_DAA_Issuer_InitCredential
+(
+    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
+    TSS_HKEY                      issuerAuthPK,                  // in
+    TSS_DAA_IDENTITY_PROOF*       identityProof,                 // in
+    UINT32                        capitalUprimeLength,           // in
+    BYTE*                         capitalUprime,                 // in
+    UINT32                        daaCounter,                    // in
+    UINT32*                       nonceIssuerLength,             // out
+    BYTE**                        nonceIssuer,                   // out
+    UINT32*                       authenticationChallengeLength, // out
+    BYTE**                        authenticationChallenge,       // out
+    UINT32*                       joinSessionLength,             // out
+    BYTE**                        joinSession                    // out
+);
+
+TSPICALL Tspi_DAA_Issuer_IssueCredential
+(
+    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
+    TSS_DAA_CREDENTIAL_REQUEST*   credentialRequest,             // in
+    UINT32                        issuerJoinSessionLength,       // in
+    BYTE*                         issuerJoinSession,             // in
+    TSS_DAA_CRED_ISSUER**         credIssuer                     // out
+);
+
+TSPICALL Tspi_DAA_Verifier_Init
+(
+    TSS_HDAA_CREDENTIAL           hDAACredential,                // in
+    UINT32*                       nonceVerifierLength,           // out
+    BYTE**                        nonceVerifier,                 // out
+    UINT32*                       baseNameLength,                // out
+    BYTE**                        baseName                       // out
+);
+
+TSPICALL Tspi_DAA_VerifySignature
+(
+    TSS_HDAA_CREDENTIAL           hDAACredential,                // in
+    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
+    TSS_HDAA_ARA_KEY              hARAKey,                       // in
+    TSS_HHASH                     hARACondition,                 // in
+    UINT32                        attributesLength,              // in
+    UINT32                        attributesLength2,             // in
+    BYTE**                        attributes,                    // in
+    UINT32                        verifierNonceLength,           // in
+    BYTE*                         verifierNonce,                 // in
+    UINT32                        verifierBaseNameLength,        // in
+    BYTE*                         verifierBaseName,              // in
+    TSS_HOBJECT                   signData,                      // in
+    TSS_DAA_SIGNATURE*            daaSignature,                  // in
+    TSS_BOOL*                     isCorrect                      // out
+);
+
+TSPICALL Tspi_DAA_ARA_GenerateKey
+(
+    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
+    TSS_HDAA_ARA_KEY              hARAKey                        // in
+);
+
+TSPICALL Tspi_DAA_ARA_RevokeAnonymity
+(
+    TSS_HDAA_ARA_KEY              hARAKey,                       // in
+    TSS_HHASH                     hARACondition,                 // in
+    TSS_HDAA_ISSUER_KEY           hIssuerKey,                    // in
+    TSS_DAA_PSEUDONYM_ENCRYPTED*  encryptedPseudonym,            // in
+    TSS_DAA_PSEUDONYM_PLAIN**     pseudonym                      // out
+);
+
+
+
+// Callback typedefs
+typedef TSS_RESULT (*Tspicb_CallbackHMACAuth)
+(
+    PVOID            lpAppData,          // in
+    TSS_HOBJECT      hAuthorizedObject,  // in
+    TSS_BOOL         ReturnOrVerify,     // in
+    UINT32           ulPendingFunction,  // in
+    TSS_BOOL         ContinueUse,        // in
+    UINT32           ulSizeNonces,       // in
+    BYTE*            rgbNonceEven,       // in
+    BYTE*            rgbNonceOdd,        // in
+    BYTE*            rgbNonceEvenOSAP,   // in
+    BYTE*            rgbNonceOddOSAP,    // in
+    UINT32           ulSizeDigestHmac,   // in
+    BYTE*            rgbParamDigest,     // in
+    BYTE*            rgbHmacData         // in, out
+);
+
+typedef TSS_RESULT (*Tspicb_CallbackXorEnc)
+(
+   PVOID            lpAppData,            // in
+   TSS_HOBJECT      hOSAPObject,          // in
+   TSS_HOBJECT      hObject,              // in
+   TSS_FLAG         PurposeSecret,        // in
+   UINT32           ulSizeNonces,         // in
+   BYTE*            rgbNonceEven,         // in
+   BYTE*            rgbNonceOdd,          // in
+   BYTE*            rgbNonceEvenOSAP,     // in
+   BYTE*            rgbNonceOddOSAP,      // in
+   UINT32           ulSizeEncAuth,        // in
+   BYTE*            rgbEncAuthUsage,      // out
+   BYTE*            rgbEncAuthMigration   // out
+);
+
+typedef TSS_RESULT (*Tspicb_CallbackTakeOwnership)
+(
+   PVOID            lpAppData,         // in
+   TSS_HOBJECT      hObject,           // in
+   TSS_HKEY         hObjectPubKey,     // in
+   UINT32           ulSizeEncAuth,     // in
+   BYTE*            rgbEncAuth         // out
+);
+
+typedef TSS_RESULT (*Tspicb_CallbackSealxMask)
+(
+    PVOID            lpAppData,        // in
+    TSS_HKEY         hKey,             // in
+    TSS_HENCDATA     hEncData,         // in
+    TSS_ALGORITHM_ID algID,            // in
+    UINT32           ulSizeNonces,     // in
+    BYTE*            rgbNonceEven,     // in
+    BYTE*            rgbNonceOdd,      // in
+    BYTE*            rgbNonceEvenOSAP, // in
+    BYTE*            rgbNonceOddOSAP,  // in
+    UINT32           ulDataLength,     // in
+    BYTE*            rgbDataToMask,    // in
+    BYTE*            rgbMaskedData     // out
+);
+
+typedef TSS_RESULT (*Tspicb_CallbackChangeAuthAsym)
+(
+   PVOID            lpAppData,        // in
+   TSS_HOBJECT      hObject,          // in
+   TSS_HKEY         hObjectPubKey,    // in
+   UINT32           ulSizeEncAuth,    // in
+   UINT32           ulSizeAuthLink,   // in
+   BYTE*            rgbEncAuth,       // out
+   BYTE*            rgbAuthLink       // out
+);
+
+typedef TSS_RESULT (*Tspicb_CollateIdentity)
+(
+   PVOID            lpAppData,                      // in
+   UINT32           ulTCPAPlainIdentityProofLength, // in
+   BYTE*            rgbTCPAPlainIdentityProof,      // in
+   TSS_ALGORITHM_ID algID,                          // in
+   UINT32           ulSessionKeyLength,             // out
+   BYTE*            rgbSessionKey,                  // out
+   UINT32*          pulTCPAIdentityProofLength,     // out
+   BYTE*            rgbTCPAIdentityProof            // out
+);
+
+
+typedef TSS_RESULT (*Tspicb_ActivateIdentity)
+(
+   PVOID            lpAppData,                    // in
+   UINT32           ulSessionKeyLength,           // in
+   BYTE*            rgbSessionKey,                // in
+   UINT32           ulSymCAAttestationBlobLength, // in
+   BYTE*            rgbSymCAAttestationBlob,      // in
+   UINT32*          pulCredentialLength,          // out
+   BYTE*            rgbCredential                 // out
+);
+
+
+typedef TSS_RESULT (*Tspicb_DAA_Sign)
+(
+    PVOID                        lpAppData,                 // in
+    TSS_HDAA_ISSUER_KEY          daaPublicKey,              // in
+    UINT32                       gammasLength,              // in
+    BYTE**                       gammas,                    // in
+    UINT32                       attributesLength,          // in
+    BYTE**                       attributes,                // in
+    UINT32                       randomAttributesLength,    // in
+    BYTE**                       randomAttributes,          // in
+    UINT32                       attributeCommitmentsLength,// in
+    TSS_DAA_ATTRIB_COMMIT*       attributeCommitments,      // in
+    TSS_DAA_ATTRIB_COMMIT*       attributeCommitmentsProof, // in
+    TSS_DAA_PSEUDONYM_PLAIN*     pseudonym,                 // in
+    TSS_DAA_PSEUDONYM_PLAIN*     pseudonymTilde,            // in
+    TSS_DAA_PSEUDONYM_ENCRYPTED* pseudonymEncrypted,        // in
+    TSS_DAA_PSEUDONYM_ENCRYPTED* pseudonymEncProof,         // in
+    TSS_DAA_SIGN_CALLBACK**      additionalProof            // out
+);
+
+typedef TSS_RESULT (*Tspicb_DAA_VerifySignature)
+(
+    PVOID                        lpAppData,                 // in
+    UINT32                       challengeLength,           // in
+    BYTE*                        challenge,                 // in
+    TSS_DAA_SIGN_CALLBACK*       additionalProof,           // in
+    TSS_HDAA_ISSUER_KEY          daaPublicKey,              // in
+    UINT32                       gammasLength,              // in
+    BYTE**                       gammas,                    // in
+    UINT32                       sAttributesLength,         // in
+    BYTE**                       sAttributes,               // in
+    UINT32                       attributeCommitmentsLength,// in
+    TSS_DAA_ATTRIB_COMMIT*       attributeCommitments,      // in
+    TSS_DAA_ATTRIB_COMMIT*       attributeCommitmentsProof, // in
+    UINT32                       zetaLength,                // in
+    BYTE*                        zeta,                      // in
+    UINT32                       sFLength,                  // in
+    BYTE*                        sF,                        // in
+    TSS_DAA_PSEUDONYM*           pseudonym,                 // in
+    TSS_DAA_PSEUDONYM*           pseudonymProof,            // in
+    TSS_BOOL*                    isCorrect                  // out
+);
+
+
+#if defined ( __cplusplus )
+}
+#endif /* __cplusplus */
+
+
+#endif /* _TSPI_H_ */
diff --git a/src/include/tss/tss_defines.h b/src/include/tss/tss_defines.h
index a525a6a..b8fafc9 100644
--- a/src/include/tss/tss_defines.h
+++ b/src/include/tss/tss_defines.h
@@ -1,1288 +1,1288 @@
-/*++
- 
-Global defines for TSS.
-
---*/
-
-#ifndef __TSS_DEFINES_H__
-#define __TSS_DEFINES_H__
-
-#include <tss/platform.h>
-#include <tss/tpm.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-// Object types:
-//////////////////////////////////////////////////////////////////////////
-
-//
-// definition of the object types that can be created via CreateObject
-//
-#define   TSS_OBJECT_TYPE_POLICY    (0x01)      // Policy object
-#define   TSS_OBJECT_TYPE_RSAKEY    (0x02)      // RSA-Key object
-#define   TSS_OBJECT_TYPE_ENCDATA   (0x03)      // Encrypted data object
-#define   TSS_OBJECT_TYPE_PCRS      (0x04)      // PCR composite object
-#define   TSS_OBJECT_TYPE_HASH      (0x05)      // Hash object
-#define   TSS_OBJECT_TYPE_DELFAMILY (0x06)      // Delegation Family object
-#define   TSS_OBJECT_TYPE_NV        (0x07)      // NV object
-#define   TSS_OBJECT_TYPE_MIGDATA   (0x08)      // CMK Migration data object
-#define   TSS_OBJECT_TYPE_DAA_CERTIFICATE (0x09) // DAA credential
-#define   TSS_OBJECT_TYPE_DAA_ISSUER_KEY  (0x0a) // DAA cred. issuer keypair
-#define   TSS_OBJECT_TYPE_DAA_ARA_KEY     (0x0b) // DAA anonymity revocation
-                                                 // authority keypair
-
-
-//////////////////////////////////////////////////////////////////////////
-// CreateObject: Flags
-//////////////////////////////////////////////////////////////////////////
-
-
-//************************************
-// Flags for creating RSAKEY object: *
-//************************************
-
-//
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//   ---------------------------------------------------------------
-//                                                              |x x|Auth
-//                                                            |x|    Volatility
-//                                                          |x|      Migration
-//                                                  |x x x x|        Type
-//                                          |x x x x|                Size
-//                                      |x x|                        CMK
-//                                |x x x|                            Version
-//              |0 0 0 0 0 0 0 0 0|                                  Reserved
-//  |x x x x x x|                                                    Fixed Type
-//
-
-//  Authorization:
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//   ---------------------------------------------------------------
-//
-//   Never                                                      |0 0|
-//   Always                                                     |0 1|
-//   Private key always                                         |1 0|
-//
-#define   TSS_KEY_NO_AUTHORIZATION            (0x00000000) // no auth needed
-                                                           // for this key
-#define   TSS_KEY_AUTHORIZATION               (0x00000001) // key needs auth
-                                                           // for all ops
-#define   TSS_KEY_AUTHORIZATION_PRIV_USE_ONLY (0x00000002) // key needs auth
-                                                           // for privkey ops,
-                                                           // noauth for pubkey
-
-//
-//  Volatility
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//   ---------------------------------------------------------------
-//
-//   Non Volatile                                             |0|
-//   Volatile                                                 |1|
-//
-#define    TSS_KEY_NON_VOLATILE      (0x00000000)   // Key is non-volatile
-#define    TSS_KEY_VOLATILE          (0x00000004)   // Key is volatile
-
-//
-//  Migration
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//   ---------------------------------------------------------------
-//
-//   Non Migratable                                         |0|
-//   Migratable                                             |1|
-//
-#define   TSS_KEY_NOT_MIGRATABLE     (0x00000000)   // key is not migratable
-#define   TSS_KEY_MIGRATABLE         (0x00000008)   // key is migratable
-
-//
-//  Usage
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//   ---------------------------------------------------------------
-//
-//   Default (Legacy)                               |0 0 0 0|
-//   Signing                                        |0 0 0 1|
-//   Storage                                        |0 0 1 0|
-//   Identity                                       |0 0 1 1|
-//   AuthChange                                     |0 1 0 0|
-//   Bind                                           |0 1 0 1|
-//   Legacy                                         |0 1 1 0|
-//
-#define   TSS_KEY_TYPE_DEFAULT    (0x00000000)   // indicate a default key
-                                                 // (Legacy-Key)
-#define   TSS_KEY_TYPE_SIGNING    (0x00000010)   // indicate a signing key
-#define   TSS_KEY_TYPE_STORAGE    (0x00000020)   // used as storage key
-#define   TSS_KEY_TYPE_IDENTITY   (0x00000030)   // indicate an idendity key
-#define   TSS_KEY_TYPE_AUTHCHANGE (0x00000040)   // indicate an ephemeral key
-#define   TSS_KEY_TYPE_BIND       (0x00000050)   // indicate a key for TPM_Bind
-#define   TSS_KEY_TYPE_LEGACY     (0x00000060)   // indicate a key that can
-                                                 // perform signing and binding
-#define   TSS_KEY_TYPE_MIGRATE    (0x00000070)   // indicate a key that can
-                                                 // act as a CMK MA
-#define   TSS_KEY_TYPE_BITMASK    (0x000000F0)   // mask to extract key type
-
-//
-//  Key size
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//   ---------------------------------------------------------------
-//
-// DEFAULT                                  |0 0 0 0|
-//   512                                    |0 0 0 1|
-//  1024                                    |0 0 1 0|
-//  2048                                    |0 0 1 1|
-//  4096                                    |0 1 0 0|
-//  8192                                    |0 1 0 1|
-// 16384                                    |0 1 1 0|
-//
-#define TSS_KEY_SIZE_DEFAULT (UINT32)(0x00000000) // indicate tpm-specific size
-#define TSS_KEY_SIZE_512     (UINT32)(0x00000100) // indicate a 512-bit key
-#define TSS_KEY_SIZE_1024    (UINT32)(0x00000200) // indicate a 1024-bit key
-#define TSS_KEY_SIZE_2048    (UINT32)(0x00000300) // indicate a 2048-bit key
-#define TSS_KEY_SIZE_4096    (UINT32)(0x00000400) // indicate a 4096-bit key
-#define TSS_KEY_SIZE_8192    (UINT32)(0x00000500) // indicate a 8192-bit key
-#define TSS_KEY_SIZE_16384   (UINT32)(0x00000600) // indicate a 16384-bit key
-#define TSS_KEY_SIZE_BITMASK (UINT32)(0x00000F00) // mask to extract key size
-
-//
-//  Certified Migratability
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//   ---------------------------------------------------------------
-//
-// DEFAULT                              |0 0|
-// Not Certified Migratable             |0 0|
-// Certified Migratable                 |0 1|
-//
-#define TSS_KEY_NOT_CERTIFIED_MIGRATABLE (UINT32)(0x00000000)
-#define TSS_KEY_CERTIFIED_MIGRATABLE     (UINT32)(0x00001000)
-
-//
-//  Specification version
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//   ---------------------------------------------------------------
-//
-// Context default                |0 0 0|
-// TPM_KEY 1.1b key               |0 0 1|
-// TPM_KEY12 1.2 key              |0 1 0|
-//
-#define TSS_KEY_STRUCT_DEFAULT            (UINT32)(0x00000000)
-#define TSS_KEY_STRUCT_KEY                (UINT32)(0x00004000)
-#define TSS_KEY_STRUCT_KEY12              (UINT32)(0x00008000)
-#define TSS_KEY_STRUCT_BITMASK            (UINT32)(0x0001C000)
-
-
-//
-//  fixed KeyTypes (templates)
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//   ---------------------------------------------------------------
-//
-//  |0 0 0 0 0 0|                             Empty Key
-//  |0 0 0 0 0 1|                             Storage Root Key
-//
-#define   TSS_KEY_EMPTY_KEY (0x00000000) // no TPM key template
-                                         // (empty TSP key object)
-#define   TSS_KEY_TSP_SRK   (0x04000000) // use a TPM SRK template
-                                         // (TSP key object for SRK)
-#define   TSS_KEY_TEMPLATE_BITMASK (0xFC000000) // bitmask to extract key
-                                                // template
-
-
-//*************************************
-// Flags for creating ENCDATA object: *
-//*************************************
-
-//
-//  Type
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//   ---------------------------------------------------------------
-//
-//   Seal                                                     |0 0 1|
-//   Bind                                                     |0 1 0|
-//   Legacy                                                   |0 1 1|
-//
-//   ENCDATA Reserved:
-//  |x x x x x x x x x x x x x x x x x x x x x x x x x x x x x|
-//
-#define   TSS_ENCDATA_SEAL     (0x00000001)   // data for seal operation
-#define   TSS_ENCDATA_BIND     (0x00000002)   // data for bind operation
-#define   TSS_ENCDATA_LEGACY   (0x00000003)   // data for legacy bind operation
-
-
-//**********************************
-// Flags for creating HASH object: *
-//**********************************
-
-//
-//  Algorithm
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//   ---------------------------------------------------------------
-//
-//   DEFAULT               
-//  |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0|
-//   SHA1
-//  |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1|
-//   OTHER
-//  |1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1|
-//
-#define   TSS_HASH_DEFAULT    (0x00000000)   // Default hash algorithm
-#define   TSS_HASH_SHA1       (0x00000001)   // SHA-1 with 20 bytes
-#define   TSS_HASH_OTHER      (0xFFFFFFFF)   // Not-specified hash algorithm
-
-
-//************************************
-// Flags for creating POLICY object: *
-//************************************
-
-//
-//  Type
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//   ---------------------------------------------------------------
-//
-//   Usage                                                    |0 0 1|
-//   Migration                                                |0 1 0|
-//   Operator                                                 |0 1 1|
-//
-//   POLICY Reserved:
-//  |x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x|
-
-#define   TSS_POLICY_USAGE         (0x00000001)   // usage policy object
-#define   TSS_POLICY_MIGRATION     (0x00000002)   // migration policy object
-#define   TSS_POLICY_OPERATOR      (0x00000003)   // migration policy object
-
-
-//******************************************
-// Flags for creating PCRComposite object: *
-//******************************************
-
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//   ---------------------------------------------------------------
-//                                                              |x x| Struct
-//  |x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x|     Reserved
-//
-
-//  PCRComposite Version:
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//   ---------------------------------------------------------------
-// TPM_PCR_DEFAULT                                            |0 0 0|
-// TPM_PCR_INFO                                               |0 0 1|
-// TPM_PCR_INFO_LONG                                          |0 1 0|
-// TPM_PCR_INFO_SHORT                                         |0 1 1|
-//
-
-#define   TSS_PCRS_STRUCT_DEFAULT    (0x00000000) // depends on context
-#define   TSS_PCRS_STRUCT_INFO       (0x00000001) // TPM_PCR_INFO
-#define   TSS_PCRS_STRUCT_INFO_LONG  (0x00000002) // TPM_PCR_INFO_LONG
-#define   TSS_PCRS_STRUCT_INFO_SHORT (0x00000003) // TPM_PCR_INFO_SHORT
-
-
-
-//////////////////////////////////////////////////////////////////////////
-// Attribute Flags, Subflags, and Values
-//////////////////////////////////////////////////////////////////////////
-
-
-//******************
-// Context object: *
-//******************
-
-//
-// Attributes
-//
-#define TSS_TSPATTRIB_CONTEXT_SILENT_MODE        (0x00000001)
-                                                    // dialog display control
-#define TSS_TSPATTRIB_CONTEXT_MACHINE_NAME       (0x00000002)
-                                                    // remote machine name
-#define TSS_TSPATTRIB_CONTEXT_VERSION_MODE       (0x00000003)
-                                                    // context version
-#define TSS_TSPATTRIB_CONTEXT_TRANSPORT          (0x00000004)
-                                                    // transport control
-#define TSS_TSPATTRIB_CONTEXT_CONNECTION_VERSION (0x00000005)
-                                                    // connection version
-#define TSS_TSPATTRIB_SECRET_HASH_MODE           (0x00000006)
-                                                    // flag indicating whether
-                                                    // NUL is included in the
-                                                    // hash of the password
-//
-// SubFlags for Flag TSS_TSPATTRIB_CONTEXT_TRANSPORT
-//
-#define   TSS_TSPATTRIB_CONTEXTTRANS_CONTROL   (0x00000008)
-#define   TSS_TSPATTRIB_CONTEXTTRANS_MODE      (0x00000010)
-
-//
-// Values for the TSS_TSPATTRIB_CONTEXT_SILENT_MODE attribute
-//
-#define   TSS_TSPATTRIB_CONTEXT_NOT_SILENT (0x00000000) // TSP dialogs enabled
-#define   TSS_TSPATTRIB_CONTEXT_SILENT     (0x00000001) // TSP dialogs disabled
-
-//
-// Values for the TSS_TSPATTRIB_CONTEXT_VERSION_MODE attribute
-//
-#define   TSS_TSPATTRIB_CONTEXT_VERSION_AUTO (0x00000001)
-#define   TSS_TSPATTRIB_CONTEXT_VERSION_V1_1 (0x00000002)
-#define   TSS_TSPATTRIB_CONTEXT_VERSION_V1_2 (0x00000003)
-
-//
-// Values for the subflag TSS_TSPATTRIB_CONTEXT_TRANS_CONTROL
-//
-#define   TSS_TSPATTRIB_DISABLE_TRANSPORT      (0x00000016)
-#define   TSS_TSPATTRIB_ENABLE_TRANSPORT       (0x00000032)
-
-//
-// Values for the subflag TSS_TSPATTRIB_CONTEXT_TRANS_MODE
-//
-#define   TSS_TSPATTRIB_TRANSPORT_NO_DEFAULT_ENCRYPTION (0x00000000)
-#define   TSS_TSPATTRIB_TRANSPORT_DEFAULT_ENCRYPTION    (0x00000001)
-#define   TSS_TSPATTRIB_TRANSPORT_AUTHENTIC_CHANNEL     (0x00000002)
-#define   TSS_TSPATTRIB_TRANSPORT_EXCLUSIVE             (0x00000004)
-#define   TSS_TSPATTRIB_TRANSPORT_STATIC_AUTH           (0x00000008)
-
-//
-// Values for the TSS_TSPATTRIB_CONTEXT_CONNECTION_VERSION attribute
-//
-#define TSS_CONNECTION_VERSION_1_1                      (0x00000001)
-#define TSS_CONNECTION_VERSION_1_2                      (0x00000002)
-
-
-//
-// Subflags of TSS_TSPATTRIB_SECRET_HASH_MODE
-//
-#define TSS_TSPATTRIB_SECRET_HASH_MODE_POPUP     (0x00000001)
-
-//
-// Values for TSS_TSPATTRIB_SECRET_HASH_MODE_POPUP subflag
-//
-#define TSS_TSPATTRIB_HASH_MODE_NOT_NULL         (0x00000000)
-#define TSS_TSPATTRIB_HASH_MODE_NULL             (0x00000001)
-
-
-// *************
-// TPM object: *
-// *************
-
-//
-// Attributes:
-//
-#define TSS_TSPATTRIB_TPM_CALLBACK_COLLATEIDENTITY  0x00000001
-#define TSS_TSPATTRIB_TPM_CALLBACK_ACTIVATEIDENTITY 0x00000002
-#define TSS_TSPATTRIB_TPM_ORDINAL_AUDIT_STATUS      0x00000003
-#define TSS_TSPATTRIB_TPM_CREDENTIAL                0x00001000
-
-//
-// Subflags for TSS_TSPATTRIB_TPM_ORDINAL_AUDIT_STATUS
-//
-#define TPM_CAP_PROP_TPM_CLEAR_ORDINAL_AUDIT        0x00000000
-#define TPM_CAP_PROP_TPM_SET_ORDINAL_AUDIT          0x00000001
-
-//
-// Subflags for TSS_TSPATTRIB_TPM_CREDENTIAL
-//
-#define TSS_TPMATTRIB_EKCERT                        0x00000001
-#define TSS_TPMATTRIB_TPM_CC                        0x00000002
-#define TSS_TPMATTRIB_PLATFORMCERT                  0x00000003
-#define TSS_TPMATTRIB_PLATFORM_CC                   0x00000004
-
-
-//*****************
-// Policy object: *
-//*****************
-
-//
-// Attributes
-//
-#define TSS_TSPATTRIB_POLICY_CALLBACK_HMAC           (0x00000080)
-                                        // enable/disable callback function
-
-#define TSS_TSPATTRIB_POLICY_CALLBACK_XOR_ENC        (0x00000100)
-                                        // enable/disable callback function
-
-#define TSS_TSPATTRIB_POLICY_CALLBACK_TAKEOWNERSHIP  (0x00000180)
-                                        // enable/disable callback function
-
-#define TSS_TSPATTRIB_POLICY_CALLBACK_CHANGEAUTHASYM (0x00000200)
-                                        // enable/disable callback function
-
-#define TSS_TSPATTRIB_POLICY_SECRET_LIFETIME         (0x00000280)
-                                        // set lifetime mode for policy secret
-
-#define TSS_TSPATTRIB_POLICY_POPUPSTRING             (0x00000300)
-                                        // set a NULL terminated UNICODE string
-                                        // which is displayed in the TSP policy
-                                        // popup dialog
-#define TSS_TSPATTRIB_POLICY_CALLBACK_SEALX_MASK     (0x00000380)
-                                        // enable/disable callback function
-#if 0
-/* This attribute flag is defined earlier with the context attributes.
- * It is valid for both context and policy objects. It is copied
- * here as a reminder to avoid collisions.
- */
-#define TSS_TSPATTRIB_SECRET_HASH_MODE               (0x00000006)
-                                                    // flag indicating whether
-                                                    // NUL is included in the
-                                                    // hash of the password
-#endif
-
-
-#define TSS_TSPATTRIB_POLICY_DELEGATION_INFO         (0x00000001)
-#define TSS_TSPATTRIB_POLICY_DELEGATION_PCR          (0x00000002)
-
-//
-// SubFlags for Flag TSS_TSPATTRIB_POLICY_SECRET_LIFETIME
-//
-#define TSS_SECRET_LIFETIME_ALWAYS  (0x00000001) // secret will not be
-                                                 // invalidated
-#define TSS_SECRET_LIFETIME_COUNTER (0x00000002) // secret lifetime
-                                                 // controlled by counter
-#define TSS_SECRET_LIFETIME_TIMER   (0x00000003) // secret lifetime
-                                                 // controlled by time
-#define TSS_TSPATTRIB_POLSECRET_LIFETIME_ALWAYS  TSS_SECRET_LIFETIME_ALWAYS
-#define TSS_TSPATTRIB_POLSECRET_LIFETIME_COUNTER TSS_SECRET_LIFETIME_COUNTER
-#define TSS_TSPATTRIB_POLSECRET_LIFETIME_TIMER   TSS_SECRET_LIFETIME_TIMER
-
-// Alternate names misspelled in the 1.1 TSS spec.
-#define TSS_TSPATTRIB_POLICYSECRET_LIFETIME_ALWAYS  TSS_SECRET_LIFETIME_ALWAYS
-#define TSS_TSPATTRIB_POLICYSECRET_LIFETIME_COUNTER TSS_SECRET_LIFETIME_COUNTER
-#define TSS_TSPATTRIB_POLICYSECRET_LIFETIME_TIMER   TSS_SECRET_LIFETIME_TIMER
-
-//
-// Subflags of TSS_TSPATTRIB_POLICY_DELEGATION_INFO
-//
-#define TSS_TSPATTRIB_POLDEL_TYPE                (0x00000001)
-#define TSS_TSPATTRIB_POLDEL_INDEX               (0x00000002)
-#define TSS_TSPATTRIB_POLDEL_PER1                (0x00000003)
-#define TSS_TSPATTRIB_POLDEL_PER2                (0x00000004)
-#define TSS_TSPATTRIB_POLDEL_LABEL               (0x00000005)
-#define TSS_TSPATTRIB_POLDEL_FAMILYID            (0x00000006)
-#define TSS_TSPATTRIB_POLDEL_VERCOUNT            (0x00000007)
-#define TSS_TSPATTRIB_POLDEL_OWNERBLOB           (0x00000008)
-#define TSS_TSPATTRIB_POLDEL_KEYBLOB             (0x00000009)
-
-//
-// Subflags of TSS_TSPATTRIB_POLICY_DELEGATION_PCR
-//
-#define TSS_TSPATTRIB_POLDELPCR_LOCALITY         (0x00000001)
-#define TSS_TSPATTRIB_POLDELPCR_DIGESTATRELEASE  (0x00000002)
-#define TSS_TSPATTRIB_POLDELPCR_SELECTION        (0x00000003)
-
-//
-// Values for the Policy TSS_TSPATTRIB_POLDEL_TYPE attribute
-//
-#define TSS_DELEGATIONTYPE_NONE                  (0x00000001)
-#define TSS_DELEGATIONTYPE_OWNER                 (0x00000002)
-#define TSS_DELEGATIONTYPE_KEY                   (0x00000003)
-
-
-
-//
-//  Flags used for the 'mode' parameter in Tspi_Policy_SetSecret()
-//
-#define TSS_SECRET_MODE_NONE     (0x00000800) // No authorization will be
-                                              // processed
-#define TSS_SECRET_MODE_SHA1     (0x00001000) // Secret string will not be
-                                              // touched by TSP 
-#define TSS_SECRET_MODE_PLAIN    (0x00001800) // Secret string will be hashed
-                                              // using SHA1
-#define TSS_SECRET_MODE_POPUP    (0x00002000) // TSS SP will ask for a secret
-#define TSS_SECRET_MODE_CALLBACK (0x00002800) // Application has to provide a
-                                              // call back function
-
-
-
-//******************
-// EncData object: *
-//******************
-
-//
-// Attributes
-//
-#define TSS_TSPATTRIB_ENCDATA_BLOB     (0x00000008)
-#define TSS_TSPATTRIB_ENCDATA_PCR      (0x00000010)
-#define TSS_TSPATTRIB_ENCDATA_PCR_LONG (0x00000018)
-#define TSS_TSPATTRIB_ENCDATA_SEAL     (0x00000020)
-
-//
-// SubFlags for Flag TSS_TSPATTRIB_ENCDATA_BLOB
-//
-#define TSS_TSPATTRIB_ENCDATABLOB_BLOB   (0x00000001)   // encrypted data blob
-
-//
-// SubFlags for Flag TSS_TSPATTRIB_ENCDATA_PCR
-//
-#define TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATCREATION       (0x00000002)
-#define TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATRELEASE        (0x00000003)
-#define TSS_TSPATTRIB_ENCDATAPCR_SELECTION               (0x00000004)
-// support typo from 1.1 headers
-#define TSS_TSPATTRIB_ENCDATAPCR_DIGEST_RELEASE \
-                          TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATRELEASE
-
-#define TSS_TSPATTRIB_ENCDATAPCRLONG_LOCALITY_ATCREATION (0x00000005)
-#define TSS_TSPATTRIB_ENCDATAPCRLONG_LOCALITY_ATRELEASE  (0x00000006)
-#define TSS_TSPATTRIB_ENCDATAPCRLONG_CREATION_SELECTION  (0x00000007)
-#define TSS_TSPATTRIB_ENCDATAPCRLONG_RELEASE_SELECTION   (0x00000008)
-#define TSS_TSPATTRIB_ENCDATAPCRLONG_DIGEST_ATCREATION   (0x00000009)
-#define TSS_TSPATTRIB_ENCDATAPCRLONG_DIGEST_ATRELEASE    (0x0000000A)
-
-
-//
-// Attribute subflags TSS_TSPATTRIB_ENCDATA_SEAL
-//
-#define TSS_TSPATTRIB_ENCDATASEAL_PROTECT_MODE           (0x00000001)
-
-//
-// Attribute values for 
-//    TSS_TSPATTRIB_ENCDATA_SEAL/TSS_TSPATTRIB_ENCDATASEAL_PROTECT_MODE
-//
-#define  TSS_TSPATTRIB_ENCDATASEAL_NOPROTECT             (0x00000000)
-#define  TSS_TSPATTRIB_ENCDATASEAL_PROTECT               (0x00000001)
-
-// Accounting for typos in original header files
-#define  TSS_TSPATTRIB_ENCDATASEAL_NO_PROTECT                                \
-                                           TSS_TSPATTRIB_ENCDATASEAL_NOPROTECT
-
-//*************
-// NV object: *
-//*************
-
-//
-// Attributes
-//
-#define TSS_TSPATTRIB_NV_INDEX                     (0x00000001)
-#define TSS_TSPATTRIB_NV_PERMISSIONS               (0x00000002)
-#define TSS_TSPATTRIB_NV_STATE                     (0x00000003)
-#define TSS_TSPATTRIB_NV_DATASIZE                  (0x00000004)
-#define TSS_TSPATTRIB_NV_PCR                       (0x00000005)
-
-#define TSS_TSPATTRIB_NVSTATE_READSTCLEAR          (0x00100000)
-#define TSS_TSPATTRIB_NVSTATE_WRITESTCLEAR         (0x00200000)
-#define TSS_TSPATTRIB_NVSTATE_WRITEDEFINE          (0x00300000)
-
-#define TSS_TSPATTRIB_NVPCR_READPCRSELECTION       (0x01000000)
-#define TSS_TSPATTRIB_NVPCR_READDIGESTATRELEASE    (0x02000000)
-#define TSS_TSPATTRIB_NVPCR_READLOCALITYATRELEASE  (0x03000000)
-#define TSS_TSPATTRIB_NVPCR_WRITEPCRSELECTION      (0x04000000)
-#define TSS_TSPATTRIB_NVPCR_WRITEDIGESTATRELEASE   (0x05000000)
-#define TSS_TSPATTRIB_NVPCR_WRITELOCALITYATRELEASE (0x06000000)
-
-/* NV index flags
- *
- * From the TPM spec, Part 2, Section 19.1.
- *
- *        3                   2                   1
- *      1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |T|P|U|D| resvd |   Purview     |          Index                |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-#define TSS_NV_TPM                (0x80000000) // TPM mfr reserved bit
-#define TSS_NV_PLATFORM           (0x40000000) // Platform mfr reserved bit
-#define TSS_NV_USER               (0x20000000) // User reserved bit
-#define TSS_NV_DEFINED            (0x10000000) // "Defined permanently" flag
-#define TSS_NV_MASK_TPM           (0x80000000) // mask to extract 'T'
-#define TSS_NV_MASK_PLATFORM      (0x40000000) // mask to extract 'P'
-#define TSS_NV_MASK_USER          (0x20000000) // mask to extract 'U'
-#define TSS_NV_MASK_DEFINED       (0x10000000) // mask to extract 'D'
-#define TSS_NV_MASK_RESERVED      (0x0f000000) // mask to extract reserved bits
-#define TSS_NV_MASK_PURVIEW       (0x00ff0000) // mask to extract purview byte
-#define TSS_NV_MASK_INDEX         (0x0000ffff) // mask to extract index byte
-
-// This is the index of the NV storage area where the number of sessions
-// per locality is stored.
-#define TSS_NV_INDEX_SESSIONS     (0x00011101)
-
-
-//******************
-// MigData object: *
-//******************
-
-//
-// Attributes
-//
-#define TSS_MIGATTRIB_MIGRATIONBLOB                    (0x00000010)
-#define TSS_MIGATTRIB_MIGRATIONTICKET                  (0x00000020)
-#define TSS_MIGATTRIB_AUTHORITY_DATA                   (0x00000030)
-#define TSS_MIGATTRIB_MIG_AUTH_DATA                    (0x00000040)
-#define TSS_MIGATTRIB_TICKET_DATA                      (0x00000050)
-#define TSS_MIGATTRIB_PAYLOAD_TYPE                     (0x00000060)
-
-//
-// Attribute subflags TSS_MIGATTRIB_MIGRATIONBLOB
-//
-#define TSS_MIGATTRIB_MIGRATION_XOR_BLOB               (0x00000101)
-#define TSS_MIGATTRIB_MIGRATION_REWRAPPED_BLOB         (0x00000102)
-#define TSS_MIGATTRIB_MIG_MSALIST_PUBKEY_BLOB          (0x00000103)
-#define TSS_MIGATTRIB_MIG_AUTHORITY_PUBKEY_BLOB        (0x00000104)
-#define TSS_MIGATTRIB_MIG_DESTINATION_PUBKEY_BLOB      (0x00000105)
-#define TSS_MIGATTRIB_MIG_SOURCE_PUBKEY_BLOB           (0x00000106)
-#define TSS_MIGATTRIB_MIG_REWRAPPED_BLOB               TSS_MIGATTRIB_MIGRATION_REWRAPPED_BLOB
-#define TSS_MIGATTRIB_MIG_XOR_BLOB                     TSS_MIGATTRIB_MIGRATION_XOR_BLOB
-
-//
-// Attribute subflags TSS_MIGATTRIB_MIGRATIONTICKET
-//
-// none
-
-//
-// Attribute subflags TSS_MIGATTRIB_AUTHORITY_DATA
-//
-#define TSS_MIGATTRIB_AUTHORITY_DIGEST                 (0x00000301)
-#define TSS_MIGATTRIB_AUTHORITY_APPROVAL_HMAC          (0x00000302)
-#define TSS_MIGATTRIB_AUTHORITY_MSALIST                (0x00000303)
-
-//
-// Attribute subflags TSS_MIGATTRIB_MIG_AUTH_DATA
-//
-#define TSS_MIGATTRIB_MIG_AUTH_AUTHORITY_DIGEST        (0x00000401)
-#define TSS_MIGATTRIB_MIG_AUTH_DESTINATION_DIGEST      (0x00000402)
-#define TSS_MIGATTRIB_MIG_AUTH_SOURCE_DIGEST           (0x00000403)
-
-//
-// Attribute subflags TSS_MIGATTRIB_TICKET_DATA
-//
-#define TSS_MIGATTRIB_TICKET_SIG_DIGEST                (0x00000501)
-#define TSS_MIGATTRIB_TICKET_SIG_VALUE                 (0x00000502)
-#define TSS_MIGATTRIB_TICKET_SIG_TICKET                (0x00000503)
-#define TSS_MIGATTRIB_TICKET_RESTRICT_TICKET           (0x00000504)
-
-//
-// Attribute subflags TSS_MIGATTRIB_PAYLOAD_TYPE
-//
-#define TSS_MIGATTRIB_PT_MIGRATE_RESTRICTED            (0x00000601)
-#define TSS_MIGATTRIB_PT_MIGRATE_EXTERNAL              (0x00000602)
-
-
-
-
-//***************
-// Hash object: *
-//***************
-
-//
-// Attributes
-//
-#define TSS_TSPATTRIB_HASH_IDENTIFIER (0x00001000) // Hash algorithm identifier
-#define TSS_TSPATTRIB_ALG_IDENTIFIER  (0x00002000) // ASN.1 alg identifier
-
-
-
-//***************
-// PCRs object: *
-//***************
-
-//
-// Attributes
-//
-#define TSS_TSPATTRIB_PCRS_INFO  (0x00000001) // info 
-
-//
-// Subflags for TSS_TSPATTRIB_PCRS_INFO flag
-//
-#define TSS_TSPATTRIB_PCRSINFO_PCRSTRUCT (0x00000001) // type of pcr struct
-                                                      // TSS_PCRS_STRUCT_TYPE_XX
-
-//****************************
-// Delegation Family object: *
-//****************************
-
-//
-// Attributes
-//
-#define TSS_TSPATTRIB_DELFAMILY_STATE            (0x00000001)
-#define TSS_TSPATTRIB_DELFAMILY_INFO             (0x00000002)
-
-// DELFAMILY_STATE sub-attributes
-#define TSS_TSPATTRIB_DELFAMILYSTATE_LOCKED      (0x00000001)
-#define TSS_TSPATTRIB_DELFAMILYSTATE_ENABLED     (0x00000002)
-
-// DELFAMILY_INFO sub-attributes
-#define TSS_TSPATTRIB_DELFAMILYINFO_LABEL        (0x00000003)
-#define TSS_TSPATTRIB_DELFAMILYINFO_VERCOUNT     (0x00000004)
-#define TSS_TSPATTRIB_DELFAMILYINFO_FAMILYID     (0x00000005)
-
-// Bitmasks for the 'ulFlags' argument to Tspi_TPM_Delegate_CreateDelegation.
-// Only one bit used for now.
-#define TSS_DELEGATE_INCREMENTVERIFICATIONCOUNT               ((UINT32)1)
-
-// Bitmasks for the 'ulFlags' argument to
-// Tspi_TPM_Delegate_CacheOwnerDelegation. Only 1 bit is used for now.
-#define TSS_DELEGATE_CACHEOWNERDELEGATION_OVERWRITEEXISTING   ((UINT32)1)
-
-
-
-//*************************
-// DAA Credential Object: *
-//*************************
-
-//
-// Attribute flags
-//
-#define TSS_TSPATTRIB_DAACRED_COMMIT                   (0x00000001)
-#define TSS_TSPATTRIB_DAACRED_ATTRIB_GAMMAS            (0x00000002)
-#define TSS_TSPATTRIB_DAACRED_CREDENTIAL_BLOB          (0x00000003)
-#define TSS_TSPATTRIB_DAACRED_CALLBACK_SIGN            (0x00000004)
-#define TSS_TSPATTRIB_DAACRED_CALLBACK_VERIFYSIGNATURE (0x00000005)
-
-//
-// Subflags for TSS_TSPATTRIB_DAACRED_COMMIT
-// 
-#define TSS_TSPATTRIB_DAACOMMIT_NUMBER              (0x00000001)
-#define TSS_TSPATTRIB_DAACOMMIT_SELECTION           (0x00000002)
-#define TSS_TSPATTRIB_DAACOMMIT_COMMITMENTS         (0x00000003)
-
-//
-// Subflags for TSS_TSPATTRIB_DAACRED_ATTRIB_GAMMAS
-// 
-#define TSS_TSPATTRIB_DAAATTRIBGAMMAS_BLOB          (0xffffffff)
-
-
-
-//*************************
-// DAA Issuer Key Object: *
-//*************************
-
-//
-// Attribute flags
-//
-#define TSS_TSPATTRIB_DAAISSUERKEY_BLOB              (0x00000001)
-#define TSS_TSPATTRIB_DAAISSUERKEY_PUBKEY            (0x00000002)
-
-//
-// Subflags for TSS_TSPATTRIB_DAAISSUERKEY_BLOB
-// 
-#define TSS_TSPATTRIB_DAAISSUERKEYBLOB_PUBLIC_KEY     (0x00000001)
-#define TSS_TSPATTRIB_DAAISSUERKEYBLOB_SECRET_KEY     (0x00000002)
-#define TSS_TSPATTRIB_DAAISSUERKEYBLOB_KEYBLOB        (0x00000003)
-#define TSS_TSPATTRIB_DAAISSUERKEYBLOB_PROOF          (0x00000004)
-
-//
-// Subflags for TSS_TSPATTRIB_DAAISSUERKEY_PUBKEY
-// 
-#define TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_ATTRIBS          (0x00000001)
-#define TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_PLATFORM_ATTRIBS (0x00000002)
-#define TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_ISSUER_ATTRIBS   (0x00000003)
-
-
-
-//***************************************
-// DAA Anonymity Revocation Key Object: *
-//***************************************
-
-//
-// Attribute flags
-//
-#define TSS_TSPATTRIB_DAAARAKEY_BLOB                 (0x00000001)
-
-//
-// Subflags for TSS_TSPATTRIB_DAAARAKEY_BLOB
-// 
-#define TSS_TSPATTRIB_DAAARAKEYBLOB_PUBLIC_KEY     (0x00000001)
-#define TSS_TSPATTRIB_DAAARAKEYBLOB_SECRET_KEY     (0x00000002)
-#define TSS_TSPATTRIB_DAAARAKEYBLOB_KEYBLOB        (0x00000003)
-
-
-
-//
-// Structure payload flags for TSS_DAA_PSEUDONYM,
-// (TSS_DAA_PSEUDONYM.payloadFlag)
-//
-#define TSS_FLAG_DAA_PSEUDONYM_PLAIN                 (0x00000000)
-#define TSS_FLAG_DAA_PSEUDONYM_ENCRYPTED             (0x00000001)
-
-
-//**************
-// Key Object: *
-//**************
-
-//
-// Attribute flags
-//
-#define TSS_TSPATTRIB_KEY_BLOB       (0x00000040) // key info as blob data
-#define TSS_TSPATTRIB_KEY_INFO       (0x00000080) // keyparam info as blob data
-#define TSS_TSPATTRIB_KEY_UUID       (0x000000C0) // key UUID info as blob data
-#define TSS_TSPATTRIB_KEY_PCR        (0x00000100) // composite digest value for
-                                                  // the key
-#define TSS_TSPATTRIB_RSAKEY_INFO    (0x00000140) // public key info
-#define TSS_TSPATTRIB_KEY_REGISTER   (0x00000180) // register location
-#define TSS_TSPATTRIB_KEY_PCR_LONG   (0x000001c0) // PCR_INFO_LONG for the key
-#define TSS_TSPATTRIB_KEY_CONTROLBIT (0x00000200) // key control flags
-#define TSS_TSPATTRIB_KEY_CMKINFO    (0x00000400) // CMK info
-
-//
-// SubFlags for Flag TSS_TSPATTRIB_KEY_BLOB
-//
-#define TSS_TSPATTRIB_KEYBLOB_BLOB        (0x00000008) // key info using the
-                                                       // key blob
-#define TSS_TSPATTRIB_KEYBLOB_PUBLIC_KEY  (0x00000010) // public key info
-                                                       // using the blob
-#define TSS_TSPATTRIB_KEYBLOB_PRIVATE_KEY (0x00000028) // encrypted private key
-                                                       // blob
-
-//
-// SubFlags for Flag TSS_TSPATTRIB_KEY_INFO
-//
-#define TSS_TSPATTRIB_KEYINFO_SIZE          (0x00000080) // key size in bits
-#define TSS_TSPATTRIB_KEYINFO_USAGE         (0x00000100) // key usage info
-#define TSS_TSPATTRIB_KEYINFO_KEYFLAGS      (0x00000180) // key flags   
-#define TSS_TSPATTRIB_KEYINFO_AUTHUSAGE     (0x00000200) // key auth usage info
-#define TSS_TSPATTRIB_KEYINFO_ALGORITHM     (0x00000280) // key algorithm ID
-#define TSS_TSPATTRIB_KEYINFO_SIGSCHEME     (0x00000300) // key sig scheme
-#define TSS_TSPATTRIB_KEYINFO_ENCSCHEME     (0x00000380) // key enc scheme   
-#define TSS_TSPATTRIB_KEYINFO_MIGRATABLE    (0x00000400) // if true then key is
-                                                         // migratable
-#define TSS_TSPATTRIB_KEYINFO_REDIRECTED    (0x00000480) // key is redirected
-#define TSS_TSPATTRIB_KEYINFO_VOLATILE      (0x00000500) // if true key is
-                                                         // volatile
-#define TSS_TSPATTRIB_KEYINFO_AUTHDATAUSAGE (0x00000580) // if true auth is
-                                                         // required
-#define TSS_TSPATTRIB_KEYINFO_VERSION       (0x00000600) // version info as TSS
-                                                         // version struct
-#define TSS_TSPATTRIB_KEYINFO_CMK           (0x00000680) // if true then key
-                                                         // is certified
-                                                         // migratable
-#define TSS_TSPATTRIB_KEYINFO_KEYSTRUCT     (0x00000700) // type of key struct
-                                                         // used for this key
-                                                         // (TPM_KEY or 
-                                                         // TPM_KEY12)
-#define TSS_TSPATTRIB_KEYCONTROL_OWNEREVICT (0x00000780) // Get current status
-							 // of owner evict flag
-
-//
-// SubFlags for Flag TSS_TSPATTRIB_RSAKEY_INFO
-//
-#define TSS_TSPATTRIB_KEYINFO_RSA_EXPONENT  (0x00001000)
-#define TSS_TSPATTRIB_KEYINFO_RSA_MODULUS   (0x00002000)
-#define TSS_TSPATTRIB_KEYINFO_RSA_KEYSIZE   (0x00003000)
-#define TSS_TSPATTRIB_KEYINFO_RSA_PRIMES    (0x00004000)
-
-//
-// SubFlags for Flag TSS_TSPATTRIB_KEY_PCR
-//
-#define TSS_TSPATTRIB_KEYPCR_DIGEST_ATCREATION  (0x00008000)
-#define TSS_TSPATTRIB_KEYPCR_DIGEST_ATRELEASE   (0x00010000)
-#define TSS_TSPATTRIB_KEYPCR_SELECTION          (0x00018000)
-
-//
-// SubFlags for TSS_TSPATTRIB_KEY_REGISTER
-//
-#define TSS_TSPATTRIB_KEYREGISTER_USER    (0x02000000)
-#define TSS_TSPATTRIB_KEYREGISTER_SYSTEM  (0x04000000)
-#define TSS_TSPATTRIB_KEYREGISTER_NO      (0x06000000)
-
-//
-// SubFlags for Flag TSS_TSPATTRIB_KEY_PCR_LONG
-//
-#define TSS_TSPATTRIB_KEYPCRLONG_LOCALITY_ATCREATION (0x00040000) /* UINT32 */
-#define TSS_TSPATTRIB_KEYPCRLONG_LOCALITY_ATRELEASE  (0x00080000) /* UINT32 */
-#define TSS_TSPATTRIB_KEYPCRLONG_CREATION_SELECTION  (0x000C0000) /* DATA */
-#define TSS_TSPATTRIB_KEYPCRLONG_RELEASE_SELECTION   (0x00100000) /* DATA */
-#define TSS_TSPATTRIB_KEYPCRLONG_DIGEST_ATCREATION   (0x00140000) /* DATA */
-#define TSS_TSPATTRIB_KEYPCRLONG_DIGEST_ATRELEASE    (0x00180000) /* DATA */
-
-//
-// SubFlags for Flag TSS_TSPATTRIB_KEY_CMKINFO
-//
-#define TSS_TSPATTRIB_KEYINFO_CMK_MA_APPROVAL  (0x00000010)
-#define TSS_TSPATTRIB_KEYINFO_CMK_MA_DIGEST    (0x00000020)
-
-
-//
-// Attribute Values
-//
-
-//
-// key size definitions
-//
-#define TSS_KEY_SIZEVAL_512BIT      (0x0200)
-#define TSS_KEY_SIZEVAL_1024BIT     (0x0400)
-#define TSS_KEY_SIZEVAL_2048BIT     (0x0800)
-#define TSS_KEY_SIZEVAL_4096BIT     (0x1000)
-#define TSS_KEY_SIZEVAL_8192BIT     (0x2000)
-#define TSS_KEY_SIZEVAL_16384BIT    (0x4000)
-
-//
-// key usage definitions
-// Values intentionally moved away from corresponding TPM values to avoid
-// possible misuse
-//
-#define TSS_KEYUSAGE_BIND           (0x00)   
-#define TSS_KEYUSAGE_IDENTITY       (0x01)   
-#define TSS_KEYUSAGE_LEGACY         (0x02)   
-#define TSS_KEYUSAGE_SIGN           (0x03)   
-#define TSS_KEYUSAGE_STORAGE        (0x04)
-#define TSS_KEYUSAGE_AUTHCHANGE     (0x05)
-#define TSS_KEYUSAGE_MIGRATE        (0x06)
-
-//
-// key flag definitions
-//
-#define TSS_KEYFLAG_REDIRECTION          (0x00000001)
-#define TSS_KEYFLAG_MIGRATABLE           (0x00000002)
-#define TSS_KEYFLAG_VOLATILEKEY          (0x00000004)
-#define TSS_KEYFLAG_CERTIFIED_MIGRATABLE (0x00000008)
-
-//
-//  algorithm ID definitions
-//
-//  This table defines the algo id's
-//  Values intentionally moved away from corresponding TPM values to avoid
-//  possible misuse
-//
-#define   TSS_ALG_RSA               (0x20)
-#define   TSS_ALG_DES               (0x21)
-#define   TSS_ALG_3DES              (0x22)
-#define   TSS_ALG_SHA               (0x23)
-#define   TSS_ALG_HMAC              (0x24)
-#define   TSS_ALG_AES128            (0x25)
-#define   TSS_ALG_AES192            (0x26)
-#define   TSS_ALG_AES256            (0x27)
-#define   TSS_ALG_XOR               (0x28)
-#define   TSS_ALG_MGF1              (0x29)
-
-#define   TSS_ALG_AES               TSS_ALG_AES128
-
-// Special values for 
-//   Tspi_Context_GetCapability(TSS_TSPCAP_ALG)
-//   Tspi_Context_GetCapability(TSS_TCSCAP_ALG)
-#define   TSS_ALG_DEFAULT           (0xfe)
-#define   TSS_ALG_DEFAULT_SIZE      (0xff)
-
-
-//
-// key signature scheme definitions
-//
-#define TSS_SS_NONE                 (0x10)
-#define TSS_SS_RSASSAPKCS1V15_SHA1  (0x11)
-#define TSS_SS_RSASSAPKCS1V15_DER   (0x12)
-#define	TSS_SS_RSASSAPKCS1V15_INFO  (0x13)
-
-//
-// key encryption scheme definitions
-//
-#define TSS_ES_NONE                 (0x10)
-#define TSS_ES_RSAESPKCSV15         (0x11)
-#define TSS_ES_RSAESOAEP_SHA1_MGF1  (0x12)
-#define TSS_ES_SYM_CNT              (0x13)
-#define TSS_ES_SYM_OFB              (0x14)
-#define TSS_ES_SYM_CBC_PKCS5PAD     (0x15)
-
-
-//
-// persistent storage registration definitions
-//
-#define TSS_PS_TYPE_USER   (1) // Key is registered persistantly in the user
-                               // storage database.
-#define TSS_PS_TYPE_SYSTEM (2) // Key is registered persistantly in the system
-                               // storage database.
-
-//
-// migration scheme definitions
-// Values intentionally moved away from corresponding TPM values to avoid
-// possible misuse
-//
-#define TSS_MS_MIGRATE                   (0x20)
-#define TSS_MS_REWRAP                    (0x21)
-#define TSS_MS_MAINT                     (0x22)
-#define TSS_MS_RESTRICT_MIGRATE          (0x23)
-#define TSS_MS_RESTRICT_APPROVE_DOUBLE   (0x24)
-#define TSS_MS_RESTRICT_MIGRATE_EXTERNAL (0x25)
-
-//
-// TPM key authorization
-// Values intentionally moved away from corresponding TPM values to avoid
-// possible misuse
-//
-#define TSS_KEYAUTH_AUTH_NEVER         (0x10)
-#define TSS_KEYAUTH_AUTH_ALWAYS        (0x11)
-#define TSS_KEYAUTH_AUTH_PRIV_USE_ONLY (0x12)
-
-
-//
-// Flags for TPM status information (GetStatus and SetStatus)
-//
-#define TSS_TPMSTATUS_DISABLEOWNERCLEAR      (0x00000001) // persistent flag
-#define TSS_TPMSTATUS_DISABLEFORCECLEAR      (0x00000002) // volatile flag
-#define TSS_TPMSTATUS_DISABLED               (0x00000003) // persistent flag
-#define TSS_TPMSTATUS_DEACTIVATED            (0x00000004) // volatile flag
-#define TSS_TPMSTATUS_OWNERSETDISABLE        (0x00000005) // persistent flag
-                                                          // for SetStatus
-                                                          // (disable flag) 
-#define TSS_TPMSTATUS_SETOWNERINSTALL        (0x00000006) // persistent flag
-                                                          // (ownership flag)
-#define TSS_TPMSTATUS_DISABLEPUBEKREAD       (0x00000007) // persistent flag
-#define TSS_TPMSTATUS_ALLOWMAINTENANCE       (0x00000008) // persistent flag
-#define TSS_TPMSTATUS_PHYSPRES_LIFETIMELOCK  (0x00000009) // persistent flag
-#define TSS_TPMSTATUS_PHYSPRES_HWENABLE      (0x0000000A) // persistent flag
-#define TSS_TPMSTATUS_PHYSPRES_CMDENABLE     (0x0000000B) // persistent flag
-#define TSS_TPMSTATUS_PHYSPRES_LOCK          (0x0000000C) // volatile flag
-#define TSS_TPMSTATUS_PHYSPRESENCE           (0x0000000D) // volatile flag
-#define TSS_TPMSTATUS_PHYSICALDISABLE        (0x0000000E) // persistent flag
-                                                          // (SetStatus
-                                                          //  disable flag)
-#define TSS_TPMSTATUS_CEKP_USED              (0x0000000F) // persistent flag
-#define TSS_TPMSTATUS_PHYSICALSETDEACTIVATED (0x00000010) // persistent flag
-                                                          // (deactivated flag)
-#define TSS_TPMSTATUS_SETTEMPDEACTIVATED     (0x00000011) // volatile flag
-                                                          // (deactivated flag)
-#define TSS_TPMSTATUS_POSTINITIALISE         (0x00000012) // volatile flag
-#define TSS_TPMSTATUS_TPMPOST                (0x00000013) // persistent flag
-#define TSS_TPMSTATUS_TPMPOSTLOCK            (0x00000014) // persistent flag
-#define TSS_TPMSTATUS_DISABLEPUBSRKREAD      (0x00000016) // persistent flag
-#define TSS_TPMSTATUS_MAINTENANCEUSED        (0x00000017) // persistent flag
-#define TSS_TPMSTATUS_OPERATORINSTALLED      (0x00000018) // persistent flag
-#define TSS_TPMSTATUS_OPERATOR_INSTALLED     (TSS_TPMSTATUS_OPERATORINSTALLED)
-#define TSS_TPMSTATUS_FIPS                   (0x00000019) // persistent flag
-#define TSS_TPMSTATUS_ENABLEREVOKEEK         (0x0000001A) // persistent flag
-#define TSS_TPMSTATUS_ENABLE_REVOKEEK        (TSS_TPMSTATUS_ENABLEREVOKEEK)
-#define TSS_TPMSTATUS_NV_LOCK                (0x0000001B) // persistent flag
-#define TSS_TPMSTATUS_TPM_ESTABLISHED        (0x0000001C) // persistent flag
-#define TSS_TPMSTATUS_RESETLOCK              (0x0000001D) // volatile flag
-#define TSS_TPMSTATUS_DISABLE_FULL_DA_LOGIC_INFO (0x0000001D) //persistent flag
-
-
-//
-// Capability flag definitions
-//
-// TPM capabilities            
-//
-#define TSS_TPMCAP_ORD                   (0x10)
-#define TSS_TPMCAP_ALG                   (0x11)
-#define TSS_TPMCAP_FLAG                  (0x12)
-#define TSS_TPMCAP_PROPERTY              (0x13)
-#define TSS_TPMCAP_VERSION               (0x14)
-#define TSS_TPMCAP_VERSION_VAL           (0x15)
-#define TSS_TPMCAP_NV_LIST               (0x16)
-#define TSS_TPMCAP_NV_INDEX              (0x17)
-#define TSS_TPMCAP_MFR                   (0x18)
-#define TSS_TPMCAP_SYM_MODE              (0x19)
-#define TSS_TPMCAP_HANDLE                (0x1a)
-#define TSS_TPMCAP_TRANS_ES              (0x1b)
-#define TSS_TPMCAP_AUTH_ENCRYPT          (0x1c)  
-#define TSS_TPMCAP_SET_PERM_FLAGS        (0x1d)  // cf. TPM_SET_PERM_FLAGS
-#define TSS_TPMCAP_SET_VENDOR            (0x1e)  // cf. TPM_SET_VENDOR
-#define TSS_TPMCAP_DA_LOGIC              (0x1f)
-
-//
-// Sub-Capability Flags for TSS_TPMCAP_PROPERTY
-//
-#define TSS_TPMCAP_PROP_PCR                 (0x10)
-#define TSS_TPMCAP_PROP_DIR                 (0x11)
-#define TSS_TPMCAP_PROP_MANUFACTURER        (0x12)
-#define TSS_TPMCAP_PROP_SLOTS               (0x13)
-#define TSS_TPMCAP_PROP_KEYS                TSS_TPMCAP_PROP_SLOTS
-#define TSS_TPMCAP_PROP_FAMILYROWS          (0x14)
-#define TSS_TPMCAP_PROP_DELEGATEROWS        (0x15)
-#define TSS_TPMCAP_PROP_OWNER               (0x16)
-#define TSS_TPMCAP_PROP_MAXKEYS             (0x18)
-#define TSS_TPMCAP_PROP_AUTHSESSIONS        (0x19)
-#define TSS_TPMCAP_PROP_MAXAUTHSESSIONS     (0x1a)
-#define TSS_TPMCAP_PROP_TRANSESSIONS        (0x1b)
-#define TSS_TPMCAP_PROP_MAXTRANSESSIONS     (0x1c)
-#define TSS_TPMCAP_PROP_SESSIONS            (0x1d)
-#define TSS_TPMCAP_PROP_MAXSESSIONS         (0x1e)
-#define TSS_TPMCAP_PROP_CONTEXTS            (0x1f)
-#define TSS_TPMCAP_PROP_MAXCONTEXTS         (0x20)
-#define TSS_TPMCAP_PROP_DAASESSIONS         (0x21)
-#define TSS_TPMCAP_PROP_MAXDAASESSIONS      (0x22)
-#define TSS_TPMCAP_PROP_DAA_INTERRUPT       (0x23)
-#define TSS_TPMCAP_PROP_COUNTERS            (0x24)
-#define TSS_TPMCAP_PROP_MAXCOUNTERS         (0x25)
-#define TSS_TPMCAP_PROP_ACTIVECOUNTER       (0x26)
-#define TSS_TPMCAP_PROP_MIN_COUNTER         (0x27)
-#define TSS_TPMCAP_PROP_TISTIMEOUTS         (0x28)
-#define TSS_TPMCAP_PROP_STARTUPEFFECTS      (0x29)
-#define TSS_TPMCAP_PROP_MAXCONTEXTCOUNTDIST (0x2a)
-#define TSS_TPMCAP_PROP_CMKRESTRICTION      (0x2b)
-#define TSS_TPMCAP_PROP_DURATION            (0x2c)
-#define TSS_TPMCAP_PROP_MAXNVAVAILABLE      (0x2d)
-#define TSS_TPMCAP_PROP_INPUTBUFFERSIZE     (0x2e)
-#define TSS_TPMCAP_PROP_REVISION            (0x2f)
-#define TSS_TPMCAP_PROP_LOCALITIES_AVAIL    (0x32)
-
-//
-// Resource type flags
-// Sub-Capability Flags for TSS_TPMCAP_HANDLE
-//
-#define TSS_RT_KEY                     ((UINT32)0x00000010)
-#define TSS_RT_AUTH                    ((UINT32)0x00000020)
-#define TSS_RT_TRANS                   ((UINT32)0x00000030)
-#define TSS_RT_COUNTER                 ((UINT32)0x00000040)
-
-
-//
-// TSS Core Service Capabilities   
-//
-#define TSS_TCSCAP_ALG                   (0x00000001)
-#define TSS_TCSCAP_VERSION               (0x00000002)
-#define TSS_TCSCAP_CACHING               (0x00000003)
-#define TSS_TCSCAP_PERSSTORAGE           (0x00000004)
-#define TSS_TCSCAP_MANUFACTURER          (0x00000005)
-#define TSS_TCSCAP_PLATFORM_CLASS        (0x00000006)
-#define TSS_TCSCAP_TRANSPORT             (0x00000007)
-#define TSS_TCSCAP_PLATFORM_INFO         (0x00000008)
-
-//
-// Sub-Capability Flags TSS-CoreService-Capabilities
-//
-#define TSS_TCSCAP_PROP_KEYCACHE         (0x00000100)
-#define TSS_TCSCAP_PROP_AUTHCACHE        (0x00000101)
-#define TSS_TCSCAP_PROP_MANUFACTURER_STR (0x00000102)
-#define TSS_TCSCAP_PROP_MANUFACTURER_ID  (0x00000103)
-#define TSS_TCSCAP_PLATFORM_VERSION      (0x00001100)
-#define TSS_TCSCAP_PLATFORM_TYPE         (0x00001101)
-#define TSS_TCSCAP_TRANS_EXCLUSIVE       (0x00002100)
-#define TSS_TCSCAP_PROP_HOST_PLATFORM    (0x00003001)
-#define TSS_TCSCAP_PROP_ALL_PLATFORMS    (0x00003002)
-
-//
-// TSS Service Provider Capabilities      
-//
-#define TSS_TSPCAP_ALG                   (0x00000010)
-#define TSS_TSPCAP_VERSION               (0x00000011)
-#define TSS_TSPCAP_PERSSTORAGE           (0x00000012)
-#define TSS_TSPCAP_MANUFACTURER          (0x00000013)
-#define TSS_TSPCAP_RETURNVALUE_INFO      (0x00000015)
-#define TSS_TSPCAP_PLATFORM_INFO         (0x00000016)
-
-// Sub-Capability Flags for TSS_TSPCAP_MANUFACTURER
-//
-#define TSS_TSPCAP_PROP_MANUFACTURER_STR (0x00000102)
-#define TSS_TSPCAP_PROP_MANUFACTURER_ID  (0x00000103)
-
-// Sub-Capability Flags for TSS_TSPCAP_PLATFORM_INFO
-//
-#define TSS_TSPCAP_PLATFORM_TYPE         (0x00000201)
-#define TSS_TSPCAP_PLATFORM_VERSION      (0x00000202)
-
-
-
-// Sub-Capability Flags for TSS_TSPCAP_RETURNVALUE_INFO
-//
-#define TSS_TSPCAP_PROP_RETURNVALUE_INFO (0x00000201)
-
-//
-// Event type definitions
-//
-#define TSS_EV_CODE_CERT                 (0x00000001)
-#define TSS_EV_CODE_NOCERT               (0x00000002)
-#define TSS_EV_XML_CONFIG                (0x00000003)
-#define TSS_EV_NO_ACTION                 (0x00000004)
-#define TSS_EV_SEPARATOR                 (0x00000005)
-#define TSS_EV_ACTION                    (0x00000006)
-#define TSS_EV_PLATFORM_SPECIFIC         (0x00000007)
-
-
-//
-// TSP random number limits
-//
-#define TSS_TSPCAP_RANDOMLIMIT     (0x00001000)   // Errata: Missing from spec
-
-//
-// UUIDs
-//
-// Errata: This are not in the spec
-#define TSS_UUID_SRK  {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 1}} // Storage root key
-#define TSS_UUID_SK   {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 2}} // System key
-#define TSS_UUID_RK   {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 3}} // roaming key
-#define TSS_UUID_CRK  {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 8}} // CMK roaming key
-#define TSS_UUID_USK1 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 4}} // user storage key 1
-#define TSS_UUID_USK2 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 5}} // user storage key 2
-#define TSS_UUID_USK3 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 6}} // user storage key 3
-#define TSS_UUID_USK4 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 7}} // user storage key 4
-#define TSS_UUID_USK5 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 9}} // user storage key 5
-#define TSS_UUID_USK6 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 10}}// user storage key 6
-
-// macro to derive UUIDs for keys whose "OwnerEvict" key is set.
-#define TSS_UUID_OWNEREVICT(i) {0, 0, 0, 0, 0, {0, 0, 0, 0, 1, (i)}}
-
-
-//
-// TPM well-known secret
-//
-#define TSS_WELL_KNOWN_SECRET \
-        {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
-         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-
-
-// Values for the "direction" parameters in the Tspi_PcrComposite_XX functions.
-#define TSS_PCRS_DIRECTION_CREATION                        ((UINT32)1)
-#define TSS_PCRS_DIRECTION_RELEASE                         ((UINT32)2)
-
-
-//
-// TSS blob version definition for ASN.1 blobs
-//
-#define TSS_BLOB_STRUCT_VERSION                              0x01
-
-//
-// TSS blob type definitions for ASN.1 blobs
-//
-#define TSS_BLOB_TYPE_KEY                                    0x01
-#define TSS_BLOB_TYPE_PUBKEY                                 0x02
-#define TSS_BLOB_TYPE_MIGKEY                                 0x03
-#define TSS_BLOB_TYPE_SEALEDDATA                             0x04
-#define TSS_BLOB_TYPE_BOUNDDATA                              0x05
-#define TSS_BLOB_TYPE_MIGTICKET                              0x06
-#define TSS_BLOB_TYPE_PRIVATEKEY                             0x07
-#define TSS_BLOB_TYPE_PRIVATEKEY_MOD1                        0x08
-#define TSS_BLOB_TYPE_RANDOM_XOR                             0x09
-#define TSS_BLOB_TYPE_CERTIFY_INFO                           0x0A
-#define TSS_BLOB_TYPE_KEY_1_2                                0x0B
-#define TSS_BLOB_TYPE_CERTIFY_INFO_2                         0x0C
-#define TSS_BLOB_TYPE_CMK_MIG_KEY                            0x0D
-#define TSS_BLOB_TYPE_CMK_BYTE_STREAM                        0x0E
-
-
-
-//
-// Values for TPM_CMK_DELEGATE bitmasks
-// For now these are exactly the same values as the corresponding
-// TPM_CMK_DELEGATE_* bitmasks.
-//
-#define TSS_CMK_DELEGATE_SIGNING       (((UINT32)1)<<31)
-#define TSS_CMK_DELEGATE_STORAGE       (((UINT32)1)<<30)
-#define TSS_CMK_DELEGATE_BIND          (((UINT32)1)<<29)
-#define TSS_CMK_DELEGATE_LEGACY        (((UINT32)1)<<28)
-#define TSS_CMK_DELEGATE_MIGRATE       (((UINT32)1)<<27)
-
-
-//
-// Constants for DAA
-//
-#define TSS_DAA_LENGTH_N                256             // Length of the RSA Modulus (2048 bits)
-#define TSS_DAA_LENGTH_F                13              // Length of the f_i's (information encoded into the certificate, 104 bits)
-#define TSS_DAA_LENGTH_E                46              // Length of the e's (exponents, part of certificate, 386 bits)
-#define TSS_DAA_LENGTH_E_PRIME          15              // Length of the interval the e's are chosen from (120 bits)
-#define TSS_DAA_LENGTH_V                317             // Length of the v's (random value, part of certificate, 2536 bits)
-#define TSS_DAA_LENGTH_SAFETY           10              // Length of the security parameter controlling the statistical zero-knowledge property (80 bits)
-#define TSS_DAA_LENGTH_HASH     TPM_SHA1_160_HASH_LEN   // Length of the output of the hash function SHA-1 used for the Fiat-Shamir heuristic(160 bits)
-#define TSS_DAA_LENGTH_S                128             // Length of the split large exponent for easier computations on the TPM (1024 bits)
-#define TSS_DAA_LENGTH_GAMMA            204             // Length of the modulus 'Gamma' (1632 bits)
-#define TSS_DAA_LENGTH_RHO              26              // Length of the order 'rho' of the sub group of Z*_Gamma that is used for roggue tagging (208 bits)
-#define TSS_DAA_LENGTH_MFG1_GAMMA       214             // Length of the output of MGF1 in conjunction with the modulus Gamma (1712 bits)
-#define TSS_DAA_LENGTH_MGF1_AR          25              // Length of the output of MGF1 used for anonymity revocation (200 bits)
-
-
-#endif // __TSS_DEFINES_H__
+/*++
+ 
+Global defines for TSS.
+
+--*/
+
+#ifndef __TSS_DEFINES_H__
+#define __TSS_DEFINES_H__
+
+#include <tss/platform.h>
+#include <tss/tpm.h>
+
+
+//////////////////////////////////////////////////////////////////////////
+// Object types:
+//////////////////////////////////////////////////////////////////////////
+
+//
+// definition of the object types that can be created via CreateObject
+//
+#define   TSS_OBJECT_TYPE_POLICY    (0x01)      // Policy object
+#define   TSS_OBJECT_TYPE_RSAKEY    (0x02)      // RSA-Key object
+#define   TSS_OBJECT_TYPE_ENCDATA   (0x03)      // Encrypted data object
+#define   TSS_OBJECT_TYPE_PCRS      (0x04)      // PCR composite object
+#define   TSS_OBJECT_TYPE_HASH      (0x05)      // Hash object
+#define   TSS_OBJECT_TYPE_DELFAMILY (0x06)      // Delegation Family object
+#define   TSS_OBJECT_TYPE_NV        (0x07)      // NV object
+#define   TSS_OBJECT_TYPE_MIGDATA   (0x08)      // CMK Migration data object
+#define   TSS_OBJECT_TYPE_DAA_CERTIFICATE (0x09) // DAA credential
+#define   TSS_OBJECT_TYPE_DAA_ISSUER_KEY  (0x0a) // DAA cred. issuer keypair
+#define   TSS_OBJECT_TYPE_DAA_ARA_KEY     (0x0b) // DAA anonymity revocation
+                                                 // authority keypair
+
+
+//////////////////////////////////////////////////////////////////////////
+// CreateObject: Flags
+//////////////////////////////////////////////////////////////////////////
+
+
+//************************************
+// Flags for creating RSAKEY object: *
+//************************************
+
+//
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//   ---------------------------------------------------------------
+//                                                              |x x|Auth
+//                                                            |x|    Volatility
+//                                                          |x|      Migration
+//                                                  |x x x x|        Type
+//                                          |x x x x|                Size
+//                                      |x x|                        CMK
+//                                |x x x|                            Version
+//              |0 0 0 0 0 0 0 0 0|                                  Reserved
+//  |x x x x x x|                                                    Fixed Type
+//
+
+//  Authorization:
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//   ---------------------------------------------------------------
+//
+//   Never                                                      |0 0|
+//   Always                                                     |0 1|
+//   Private key always                                         |1 0|
+//
+#define   TSS_KEY_NO_AUTHORIZATION            (0x00000000) // no auth needed
+                                                           // for this key
+#define   TSS_KEY_AUTHORIZATION               (0x00000001) // key needs auth
+                                                           // for all ops
+#define   TSS_KEY_AUTHORIZATION_PRIV_USE_ONLY (0x00000002) // key needs auth
+                                                           // for privkey ops,
+                                                           // noauth for pubkey
+
+//
+//  Volatility
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//   ---------------------------------------------------------------
+//
+//   Non Volatile                                             |0|
+//   Volatile                                                 |1|
+//
+#define    TSS_KEY_NON_VOLATILE      (0x00000000)   // Key is non-volatile
+#define    TSS_KEY_VOLATILE          (0x00000004)   // Key is volatile
+
+//
+//  Migration
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//   ---------------------------------------------------------------
+//
+//   Non Migratable                                         |0|
+//   Migratable                                             |1|
+//
+#define   TSS_KEY_NOT_MIGRATABLE     (0x00000000)   // key is not migratable
+#define   TSS_KEY_MIGRATABLE         (0x00000008)   // key is migratable
+
+//
+//  Usage
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//   ---------------------------------------------------------------
+//
+//   Default (Legacy)                               |0 0 0 0|
+//   Signing                                        |0 0 0 1|
+//   Storage                                        |0 0 1 0|
+//   Identity                                       |0 0 1 1|
+//   AuthChange                                     |0 1 0 0|
+//   Bind                                           |0 1 0 1|
+//   Legacy                                         |0 1 1 0|
+//
+#define   TSS_KEY_TYPE_DEFAULT    (0x00000000)   // indicate a default key
+                                                 // (Legacy-Key)
+#define   TSS_KEY_TYPE_SIGNING    (0x00000010)   // indicate a signing key
+#define   TSS_KEY_TYPE_STORAGE    (0x00000020)   // used as storage key
+#define   TSS_KEY_TYPE_IDENTITY   (0x00000030)   // indicate an idendity key
+#define   TSS_KEY_TYPE_AUTHCHANGE (0x00000040)   // indicate an ephemeral key
+#define   TSS_KEY_TYPE_BIND       (0x00000050)   // indicate a key for TPM_Bind
+#define   TSS_KEY_TYPE_LEGACY     (0x00000060)   // indicate a key that can
+                                                 // perform signing and binding
+#define   TSS_KEY_TYPE_MIGRATE    (0x00000070)   // indicate a key that can
+                                                 // act as a CMK MA
+#define   TSS_KEY_TYPE_BITMASK    (0x000000F0)   // mask to extract key type
+
+//
+//  Key size
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//   ---------------------------------------------------------------
+//
+// DEFAULT                                  |0 0 0 0|
+//   512                                    |0 0 0 1|
+//  1024                                    |0 0 1 0|
+//  2048                                    |0 0 1 1|
+//  4096                                    |0 1 0 0|
+//  8192                                    |0 1 0 1|
+// 16384                                    |0 1 1 0|
+//
+#define TSS_KEY_SIZE_DEFAULT (UINT32)(0x00000000) // indicate tpm-specific size
+#define TSS_KEY_SIZE_512     (UINT32)(0x00000100) // indicate a 512-bit key
+#define TSS_KEY_SIZE_1024    (UINT32)(0x00000200) // indicate a 1024-bit key
+#define TSS_KEY_SIZE_2048    (UINT32)(0x00000300) // indicate a 2048-bit key
+#define TSS_KEY_SIZE_4096    (UINT32)(0x00000400) // indicate a 4096-bit key
+#define TSS_KEY_SIZE_8192    (UINT32)(0x00000500) // indicate a 8192-bit key
+#define TSS_KEY_SIZE_16384   (UINT32)(0x00000600) // indicate a 16384-bit key
+#define TSS_KEY_SIZE_BITMASK (UINT32)(0x00000F00) // mask to extract key size
+
+//
+//  Certified Migratability
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//   ---------------------------------------------------------------
+//
+// DEFAULT                              |0 0|
+// Not Certified Migratable             |0 0|
+// Certified Migratable                 |0 1|
+//
+#define TSS_KEY_NOT_CERTIFIED_MIGRATABLE (UINT32)(0x00000000)
+#define TSS_KEY_CERTIFIED_MIGRATABLE     (UINT32)(0x00001000)
+
+//
+//  Specification version
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//   ---------------------------------------------------------------
+//
+// Context default                |0 0 0|
+// TPM_KEY 1.1b key               |0 0 1|
+// TPM_KEY12 1.2 key              |0 1 0|
+//
+#define TSS_KEY_STRUCT_DEFAULT            (UINT32)(0x00000000)
+#define TSS_KEY_STRUCT_KEY                (UINT32)(0x00004000)
+#define TSS_KEY_STRUCT_KEY12              (UINT32)(0x00008000)
+#define TSS_KEY_STRUCT_BITMASK            (UINT32)(0x0001C000)
+
+
+//
+//  fixed KeyTypes (templates)
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//   ---------------------------------------------------------------
+//
+//  |0 0 0 0 0 0|                             Empty Key
+//  |0 0 0 0 0 1|                             Storage Root Key
+//
+#define   TSS_KEY_EMPTY_KEY (0x00000000) // no TPM key template
+                                         // (empty TSP key object)
+#define   TSS_KEY_TSP_SRK   (0x04000000) // use a TPM SRK template
+                                         // (TSP key object for SRK)
+#define   TSS_KEY_TEMPLATE_BITMASK (0xFC000000) // bitmask to extract key
+                                                // template
+
+
+//*************************************
+// Flags for creating ENCDATA object: *
+//*************************************
+
+//
+//  Type
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//   ---------------------------------------------------------------
+//
+//   Seal                                                     |0 0 1|
+//   Bind                                                     |0 1 0|
+//   Legacy                                                   |0 1 1|
+//
+//   ENCDATA Reserved:
+//  |x x x x x x x x x x x x x x x x x x x x x x x x x x x x x|
+//
+#define   TSS_ENCDATA_SEAL     (0x00000001)   // data for seal operation
+#define   TSS_ENCDATA_BIND     (0x00000002)   // data for bind operation
+#define   TSS_ENCDATA_LEGACY   (0x00000003)   // data for legacy bind operation
+
+
+//**********************************
+// Flags for creating HASH object: *
+//**********************************
+
+//
+//  Algorithm
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//   ---------------------------------------------------------------
+//
+//   DEFAULT               
+//  |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0|
+//   SHA1
+//  |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1|
+//   OTHER
+//  |1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1|
+//
+#define   TSS_HASH_DEFAULT    (0x00000000)   // Default hash algorithm
+#define   TSS_HASH_SHA1       (0x00000001)   // SHA-1 with 20 bytes
+#define   TSS_HASH_OTHER      (0xFFFFFFFF)   // Not-specified hash algorithm
+
+
+//************************************
+// Flags for creating POLICY object: *
+//************************************
+
+//
+//  Type
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//   ---------------------------------------------------------------
+//
+//   Usage                                                    |0 0 1|
+//   Migration                                                |0 1 0|
+//   Operator                                                 |0 1 1|
+//
+//   POLICY Reserved:
+//  |x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x|
+
+#define   TSS_POLICY_USAGE         (0x00000001)   // usage policy object
+#define   TSS_POLICY_MIGRATION     (0x00000002)   // migration policy object
+#define   TSS_POLICY_OPERATOR      (0x00000003)   // migration policy object
+
+
+//******************************************
+// Flags for creating PCRComposite object: *
+//******************************************
+
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//   ---------------------------------------------------------------
+//                                                              |x x| Struct
+//  |x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x|     Reserved
+//
+
+//  PCRComposite Version:
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//   ---------------------------------------------------------------
+// TPM_PCR_DEFAULT                                            |0 0 0|
+// TPM_PCR_INFO                                               |0 0 1|
+// TPM_PCR_INFO_LONG                                          |0 1 0|
+// TPM_PCR_INFO_SHORT                                         |0 1 1|
+//
+
+#define   TSS_PCRS_STRUCT_DEFAULT    (0x00000000) // depends on context
+#define   TSS_PCRS_STRUCT_INFO       (0x00000001) // TPM_PCR_INFO
+#define   TSS_PCRS_STRUCT_INFO_LONG  (0x00000002) // TPM_PCR_INFO_LONG
+#define   TSS_PCRS_STRUCT_INFO_SHORT (0x00000003) // TPM_PCR_INFO_SHORT
+
+
+
+//////////////////////////////////////////////////////////////////////////
+// Attribute Flags, Subflags, and Values
+//////////////////////////////////////////////////////////////////////////
+
+
+//******************
+// Context object: *
+//******************
+
+//
+// Attributes
+//
+#define TSS_TSPATTRIB_CONTEXT_SILENT_MODE        (0x00000001)
+                                                    // dialog display control
+#define TSS_TSPATTRIB_CONTEXT_MACHINE_NAME       (0x00000002)
+                                                    // remote machine name
+#define TSS_TSPATTRIB_CONTEXT_VERSION_MODE       (0x00000003)
+                                                    // context version
+#define TSS_TSPATTRIB_CONTEXT_TRANSPORT          (0x00000004)
+                                                    // transport control
+#define TSS_TSPATTRIB_CONTEXT_CONNECTION_VERSION (0x00000005)
+                                                    // connection version
+#define TSS_TSPATTRIB_SECRET_HASH_MODE           (0x00000006)
+                                                    // flag indicating whether
+                                                    // NUL is included in the
+                                                    // hash of the password
+//
+// SubFlags for Flag TSS_TSPATTRIB_CONTEXT_TRANSPORT
+//
+#define   TSS_TSPATTRIB_CONTEXTTRANS_CONTROL   (0x00000008)
+#define   TSS_TSPATTRIB_CONTEXTTRANS_MODE      (0x00000010)
+
+//
+// Values for the TSS_TSPATTRIB_CONTEXT_SILENT_MODE attribute
+//
+#define   TSS_TSPATTRIB_CONTEXT_NOT_SILENT (0x00000000) // TSP dialogs enabled
+#define   TSS_TSPATTRIB_CONTEXT_SILENT     (0x00000001) // TSP dialogs disabled
+
+//
+// Values for the TSS_TSPATTRIB_CONTEXT_VERSION_MODE attribute
+//
+#define   TSS_TSPATTRIB_CONTEXT_VERSION_AUTO (0x00000001)
+#define   TSS_TSPATTRIB_CONTEXT_VERSION_V1_1 (0x00000002)
+#define   TSS_TSPATTRIB_CONTEXT_VERSION_V1_2 (0x00000003)
+
+//
+// Values for the subflag TSS_TSPATTRIB_CONTEXT_TRANS_CONTROL
+//
+#define   TSS_TSPATTRIB_DISABLE_TRANSPORT      (0x00000016)
+#define   TSS_TSPATTRIB_ENABLE_TRANSPORT       (0x00000032)
+
+//
+// Values for the subflag TSS_TSPATTRIB_CONTEXT_TRANS_MODE
+//
+#define   TSS_TSPATTRIB_TRANSPORT_NO_DEFAULT_ENCRYPTION (0x00000000)
+#define   TSS_TSPATTRIB_TRANSPORT_DEFAULT_ENCRYPTION    (0x00000001)
+#define   TSS_TSPATTRIB_TRANSPORT_AUTHENTIC_CHANNEL     (0x00000002)
+#define   TSS_TSPATTRIB_TRANSPORT_EXCLUSIVE             (0x00000004)
+#define   TSS_TSPATTRIB_TRANSPORT_STATIC_AUTH           (0x00000008)
+
+//
+// Values for the TSS_TSPATTRIB_CONTEXT_CONNECTION_VERSION attribute
+//
+#define TSS_CONNECTION_VERSION_1_1                      (0x00000001)
+#define TSS_CONNECTION_VERSION_1_2                      (0x00000002)
+
+
+//
+// Subflags of TSS_TSPATTRIB_SECRET_HASH_MODE
+//
+#define TSS_TSPATTRIB_SECRET_HASH_MODE_POPUP     (0x00000001)
+
+//
+// Values for TSS_TSPATTRIB_SECRET_HASH_MODE_POPUP subflag
+//
+#define TSS_TSPATTRIB_HASH_MODE_NOT_NULL         (0x00000000)
+#define TSS_TSPATTRIB_HASH_MODE_NULL             (0x00000001)
+
+
+// *************
+// TPM object: *
+// *************
+
+//
+// Attributes:
+//
+#define TSS_TSPATTRIB_TPM_CALLBACK_COLLATEIDENTITY  0x00000001
+#define TSS_TSPATTRIB_TPM_CALLBACK_ACTIVATEIDENTITY 0x00000002
+#define TSS_TSPATTRIB_TPM_ORDINAL_AUDIT_STATUS      0x00000003
+#define TSS_TSPATTRIB_TPM_CREDENTIAL                0x00001000
+
+//
+// Subflags for TSS_TSPATTRIB_TPM_ORDINAL_AUDIT_STATUS
+//
+#define TPM_CAP_PROP_TPM_CLEAR_ORDINAL_AUDIT        0x00000000
+#define TPM_CAP_PROP_TPM_SET_ORDINAL_AUDIT          0x00000001
+
+//
+// Subflags for TSS_TSPATTRIB_TPM_CREDENTIAL
+//
+#define TSS_TPMATTRIB_EKCERT                        0x00000001
+#define TSS_TPMATTRIB_TPM_CC                        0x00000002
+#define TSS_TPMATTRIB_PLATFORMCERT                  0x00000003
+#define TSS_TPMATTRIB_PLATFORM_CC                   0x00000004
+
+
+//*****************
+// Policy object: *
+//*****************
+
+//
+// Attributes
+//
+#define TSS_TSPATTRIB_POLICY_CALLBACK_HMAC           (0x00000080)
+                                        // enable/disable callback function
+
+#define TSS_TSPATTRIB_POLICY_CALLBACK_XOR_ENC        (0x00000100)
+                                        // enable/disable callback function
+
+#define TSS_TSPATTRIB_POLICY_CALLBACK_TAKEOWNERSHIP  (0x00000180)
+                                        // enable/disable callback function
+
+#define TSS_TSPATTRIB_POLICY_CALLBACK_CHANGEAUTHASYM (0x00000200)
+                                        // enable/disable callback function
+
+#define TSS_TSPATTRIB_POLICY_SECRET_LIFETIME         (0x00000280)
+                                        // set lifetime mode for policy secret
+
+#define TSS_TSPATTRIB_POLICY_POPUPSTRING             (0x00000300)
+                                        // set a NULL terminated UNICODE string
+                                        // which is displayed in the TSP policy
+                                        // popup dialog
+#define TSS_TSPATTRIB_POLICY_CALLBACK_SEALX_MASK     (0x00000380)
+                                        // enable/disable callback function
+#if 0
+/* This attribute flag is defined earlier with the context attributes.
+ * It is valid for both context and policy objects. It is copied
+ * here as a reminder to avoid collisions.
+ */
+#define TSS_TSPATTRIB_SECRET_HASH_MODE               (0x00000006)
+                                                    // flag indicating whether
+                                                    // NUL is included in the
+                                                    // hash of the password
+#endif
+
+
+#define TSS_TSPATTRIB_POLICY_DELEGATION_INFO         (0x00000001)
+#define TSS_TSPATTRIB_POLICY_DELEGATION_PCR          (0x00000002)
+
+//
+// SubFlags for Flag TSS_TSPATTRIB_POLICY_SECRET_LIFETIME
+//
+#define TSS_SECRET_LIFETIME_ALWAYS  (0x00000001) // secret will not be
+                                                 // invalidated
+#define TSS_SECRET_LIFETIME_COUNTER (0x00000002) // secret lifetime
+                                                 // controlled by counter
+#define TSS_SECRET_LIFETIME_TIMER   (0x00000003) // secret lifetime
+                                                 // controlled by time
+#define TSS_TSPATTRIB_POLSECRET_LIFETIME_ALWAYS  TSS_SECRET_LIFETIME_ALWAYS
+#define TSS_TSPATTRIB_POLSECRET_LIFETIME_COUNTER TSS_SECRET_LIFETIME_COUNTER
+#define TSS_TSPATTRIB_POLSECRET_LIFETIME_TIMER   TSS_SECRET_LIFETIME_TIMER
+
+// Alternate names misspelled in the 1.1 TSS spec.
+#define TSS_TSPATTRIB_POLICYSECRET_LIFETIME_ALWAYS  TSS_SECRET_LIFETIME_ALWAYS
+#define TSS_TSPATTRIB_POLICYSECRET_LIFETIME_COUNTER TSS_SECRET_LIFETIME_COUNTER
+#define TSS_TSPATTRIB_POLICYSECRET_LIFETIME_TIMER   TSS_SECRET_LIFETIME_TIMER
+
+//
+// Subflags of TSS_TSPATTRIB_POLICY_DELEGATION_INFO
+//
+#define TSS_TSPATTRIB_POLDEL_TYPE                (0x00000001)
+#define TSS_TSPATTRIB_POLDEL_INDEX               (0x00000002)
+#define TSS_TSPATTRIB_POLDEL_PER1                (0x00000003)
+#define TSS_TSPATTRIB_POLDEL_PER2                (0x00000004)
+#define TSS_TSPATTRIB_POLDEL_LABEL               (0x00000005)
+#define TSS_TSPATTRIB_POLDEL_FAMILYID            (0x00000006)
+#define TSS_TSPATTRIB_POLDEL_VERCOUNT            (0x00000007)
+#define TSS_TSPATTRIB_POLDEL_OWNERBLOB           (0x00000008)
+#define TSS_TSPATTRIB_POLDEL_KEYBLOB             (0x00000009)
+
+//
+// Subflags of TSS_TSPATTRIB_POLICY_DELEGATION_PCR
+//
+#define TSS_TSPATTRIB_POLDELPCR_LOCALITY         (0x00000001)
+#define TSS_TSPATTRIB_POLDELPCR_DIGESTATRELEASE  (0x00000002)
+#define TSS_TSPATTRIB_POLDELPCR_SELECTION        (0x00000003)
+
+//
+// Values for the Policy TSS_TSPATTRIB_POLDEL_TYPE attribute
+//
+#define TSS_DELEGATIONTYPE_NONE                  (0x00000001)
+#define TSS_DELEGATIONTYPE_OWNER                 (0x00000002)
+#define TSS_DELEGATIONTYPE_KEY                   (0x00000003)
+
+
+
+//
+//  Flags used for the 'mode' parameter in Tspi_Policy_SetSecret()
+//
+#define TSS_SECRET_MODE_NONE     (0x00000800) // No authorization will be
+                                              // processed
+#define TSS_SECRET_MODE_SHA1     (0x00001000) // Secret string will not be
+                                              // touched by TSP 
+#define TSS_SECRET_MODE_PLAIN    (0x00001800) // Secret string will be hashed
+                                              // using SHA1
+#define TSS_SECRET_MODE_POPUP    (0x00002000) // TSS SP will ask for a secret
+#define TSS_SECRET_MODE_CALLBACK (0x00002800) // Application has to provide a
+                                              // call back function
+
+
+
+//******************
+// EncData object: *
+//******************
+
+//
+// Attributes
+//
+#define TSS_TSPATTRIB_ENCDATA_BLOB     (0x00000008)
+#define TSS_TSPATTRIB_ENCDATA_PCR      (0x00000010)
+#define TSS_TSPATTRIB_ENCDATA_PCR_LONG (0x00000018)
+#define TSS_TSPATTRIB_ENCDATA_SEAL     (0x00000020)
+
+//
+// SubFlags for Flag TSS_TSPATTRIB_ENCDATA_BLOB
+//
+#define TSS_TSPATTRIB_ENCDATABLOB_BLOB   (0x00000001)   // encrypted data blob
+
+//
+// SubFlags for Flag TSS_TSPATTRIB_ENCDATA_PCR
+//
+#define TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATCREATION       (0x00000002)
+#define TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATRELEASE        (0x00000003)
+#define TSS_TSPATTRIB_ENCDATAPCR_SELECTION               (0x00000004)
+// support typo from 1.1 headers
+#define TSS_TSPATTRIB_ENCDATAPCR_DIGEST_RELEASE \
+                          TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATRELEASE
+
+#define TSS_TSPATTRIB_ENCDATAPCRLONG_LOCALITY_ATCREATION (0x00000005)
+#define TSS_TSPATTRIB_ENCDATAPCRLONG_LOCALITY_ATRELEASE  (0x00000006)
+#define TSS_TSPATTRIB_ENCDATAPCRLONG_CREATION_SELECTION  (0x00000007)
+#define TSS_TSPATTRIB_ENCDATAPCRLONG_RELEASE_SELECTION   (0x00000008)
+#define TSS_TSPATTRIB_ENCDATAPCRLONG_DIGEST_ATCREATION   (0x00000009)
+#define TSS_TSPATTRIB_ENCDATAPCRLONG_DIGEST_ATRELEASE    (0x0000000A)
+
+
+//
+// Attribute subflags TSS_TSPATTRIB_ENCDATA_SEAL
+//
+#define TSS_TSPATTRIB_ENCDATASEAL_PROTECT_MODE           (0x00000001)
+
+//
+// Attribute values for 
+//    TSS_TSPATTRIB_ENCDATA_SEAL/TSS_TSPATTRIB_ENCDATASEAL_PROTECT_MODE
+//
+#define  TSS_TSPATTRIB_ENCDATASEAL_NOPROTECT             (0x00000000)
+#define  TSS_TSPATTRIB_ENCDATASEAL_PROTECT               (0x00000001)
+
+// Accounting for typos in original header files
+#define  TSS_TSPATTRIB_ENCDATASEAL_NO_PROTECT                                \
+                                           TSS_TSPATTRIB_ENCDATASEAL_NOPROTECT
+
+//*************
+// NV object: *
+//*************
+
+//
+// Attributes
+//
+#define TSS_TSPATTRIB_NV_INDEX                     (0x00000001)
+#define TSS_TSPATTRIB_NV_PERMISSIONS               (0x00000002)
+#define TSS_TSPATTRIB_NV_STATE                     (0x00000003)
+#define TSS_TSPATTRIB_NV_DATASIZE                  (0x00000004)
+#define TSS_TSPATTRIB_NV_PCR                       (0x00000005)
+
+#define TSS_TSPATTRIB_NVSTATE_READSTCLEAR          (0x00100000)
+#define TSS_TSPATTRIB_NVSTATE_WRITESTCLEAR         (0x00200000)
+#define TSS_TSPATTRIB_NVSTATE_WRITEDEFINE          (0x00300000)
+
+#define TSS_TSPATTRIB_NVPCR_READPCRSELECTION       (0x01000000)
+#define TSS_TSPATTRIB_NVPCR_READDIGESTATRELEASE    (0x02000000)
+#define TSS_TSPATTRIB_NVPCR_READLOCALITYATRELEASE  (0x03000000)
+#define TSS_TSPATTRIB_NVPCR_WRITEPCRSELECTION      (0x04000000)
+#define TSS_TSPATTRIB_NVPCR_WRITEDIGESTATRELEASE   (0x05000000)
+#define TSS_TSPATTRIB_NVPCR_WRITELOCALITYATRELEASE (0x06000000)
+
+/* NV index flags
+ *
+ * From the TPM spec, Part 2, Section 19.1.
+ *
+ *        3                   2                   1
+ *      1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |T|P|U|D| resvd |   Purview     |          Index                |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+#define TSS_NV_TPM                (0x80000000) // TPM mfr reserved bit
+#define TSS_NV_PLATFORM           (0x40000000) // Platform mfr reserved bit
+#define TSS_NV_USER               (0x20000000) // User reserved bit
+#define TSS_NV_DEFINED            (0x10000000) // "Defined permanently" flag
+#define TSS_NV_MASK_TPM           (0x80000000) // mask to extract 'T'
+#define TSS_NV_MASK_PLATFORM      (0x40000000) // mask to extract 'P'
+#define TSS_NV_MASK_USER          (0x20000000) // mask to extract 'U'
+#define TSS_NV_MASK_DEFINED       (0x10000000) // mask to extract 'D'
+#define TSS_NV_MASK_RESERVED      (0x0f000000) // mask to extract reserved bits
+#define TSS_NV_MASK_PURVIEW       (0x00ff0000) // mask to extract purview byte
+#define TSS_NV_MASK_INDEX         (0x0000ffff) // mask to extract index byte
+
+// This is the index of the NV storage area where the number of sessions
+// per locality is stored.
+#define TSS_NV_INDEX_SESSIONS     (0x00011101)
+
+
+//******************
+// MigData object: *
+//******************
+
+//
+// Attributes
+//
+#define TSS_MIGATTRIB_MIGRATIONBLOB                    (0x00000010)
+#define TSS_MIGATTRIB_MIGRATIONTICKET                  (0x00000020)
+#define TSS_MIGATTRIB_AUTHORITY_DATA                   (0x00000030)
+#define TSS_MIGATTRIB_MIG_AUTH_DATA                    (0x00000040)
+#define TSS_MIGATTRIB_TICKET_DATA                      (0x00000050)
+#define TSS_MIGATTRIB_PAYLOAD_TYPE                     (0x00000060)
+
+//
+// Attribute subflags TSS_MIGATTRIB_MIGRATIONBLOB
+//
+#define TSS_MIGATTRIB_MIGRATION_XOR_BLOB               (0x00000101)
+#define TSS_MIGATTRIB_MIGRATION_REWRAPPED_BLOB         (0x00000102)
+#define TSS_MIGATTRIB_MIG_MSALIST_PUBKEY_BLOB          (0x00000103)
+#define TSS_MIGATTRIB_MIG_AUTHORITY_PUBKEY_BLOB        (0x00000104)
+#define TSS_MIGATTRIB_MIG_DESTINATION_PUBKEY_BLOB      (0x00000105)
+#define TSS_MIGATTRIB_MIG_SOURCE_PUBKEY_BLOB           (0x00000106)
+#define TSS_MIGATTRIB_MIG_REWRAPPED_BLOB               TSS_MIGATTRIB_MIGRATION_REWRAPPED_BLOB
+#define TSS_MIGATTRIB_MIG_XOR_BLOB                     TSS_MIGATTRIB_MIGRATION_XOR_BLOB
+
+//
+// Attribute subflags TSS_MIGATTRIB_MIGRATIONTICKET
+//
+// none
+
+//
+// Attribute subflags TSS_MIGATTRIB_AUTHORITY_DATA
+//
+#define TSS_MIGATTRIB_AUTHORITY_DIGEST                 (0x00000301)
+#define TSS_MIGATTRIB_AUTHORITY_APPROVAL_HMAC          (0x00000302)
+#define TSS_MIGATTRIB_AUTHORITY_MSALIST                (0x00000303)
+
+//
+// Attribute subflags TSS_MIGATTRIB_MIG_AUTH_DATA
+//
+#define TSS_MIGATTRIB_MIG_AUTH_AUTHORITY_DIGEST        (0x00000401)
+#define TSS_MIGATTRIB_MIG_AUTH_DESTINATION_DIGEST      (0x00000402)
+#define TSS_MIGATTRIB_MIG_AUTH_SOURCE_DIGEST           (0x00000403)
+
+//
+// Attribute subflags TSS_MIGATTRIB_TICKET_DATA
+//
+#define TSS_MIGATTRIB_TICKET_SIG_DIGEST                (0x00000501)
+#define TSS_MIGATTRIB_TICKET_SIG_VALUE                 (0x00000502)
+#define TSS_MIGATTRIB_TICKET_SIG_TICKET                (0x00000503)
+#define TSS_MIGATTRIB_TICKET_RESTRICT_TICKET           (0x00000504)
+
+//
+// Attribute subflags TSS_MIGATTRIB_PAYLOAD_TYPE
+//
+#define TSS_MIGATTRIB_PT_MIGRATE_RESTRICTED            (0x00000601)
+#define TSS_MIGATTRIB_PT_MIGRATE_EXTERNAL              (0x00000602)
+
+
+
+
+//***************
+// Hash object: *
+//***************
+
+//
+// Attributes
+//
+#define TSS_TSPATTRIB_HASH_IDENTIFIER (0x00001000) // Hash algorithm identifier
+#define TSS_TSPATTRIB_ALG_IDENTIFIER  (0x00002000) // ASN.1 alg identifier
+
+
+
+//***************
+// PCRs object: *
+//***************
+
+//
+// Attributes
+//
+#define TSS_TSPATTRIB_PCRS_INFO  (0x00000001) // info 
+
+//
+// Subflags for TSS_TSPATTRIB_PCRS_INFO flag
+//
+#define TSS_TSPATTRIB_PCRSINFO_PCRSTRUCT (0x00000001) // type of pcr struct
+                                                      // TSS_PCRS_STRUCT_TYPE_XX
+
+//****************************
+// Delegation Family object: *
+//****************************
+
+//
+// Attributes
+//
+#define TSS_TSPATTRIB_DELFAMILY_STATE            (0x00000001)
+#define TSS_TSPATTRIB_DELFAMILY_INFO             (0x00000002)
+
+// DELFAMILY_STATE sub-attributes
+#define TSS_TSPATTRIB_DELFAMILYSTATE_LOCKED      (0x00000001)
+#define TSS_TSPATTRIB_DELFAMILYSTATE_ENABLED     (0x00000002)
+
+// DELFAMILY_INFO sub-attributes
+#define TSS_TSPATTRIB_DELFAMILYINFO_LABEL        (0x00000003)
+#define TSS_TSPATTRIB_DELFAMILYINFO_VERCOUNT     (0x00000004)
+#define TSS_TSPATTRIB_DELFAMILYINFO_FAMILYID     (0x00000005)
+
+// Bitmasks for the 'ulFlags' argument to Tspi_TPM_Delegate_CreateDelegation.
+// Only one bit used for now.
+#define TSS_DELEGATE_INCREMENTVERIFICATIONCOUNT               ((UINT32)1)
+
+// Bitmasks for the 'ulFlags' argument to
+// Tspi_TPM_Delegate_CacheOwnerDelegation. Only 1 bit is used for now.
+#define TSS_DELEGATE_CACHEOWNERDELEGATION_OVERWRITEEXISTING   ((UINT32)1)
+
+
+
+//*************************
+// DAA Credential Object: *
+//*************************
+
+//
+// Attribute flags
+//
+#define TSS_TSPATTRIB_DAACRED_COMMIT                   (0x00000001)
+#define TSS_TSPATTRIB_DAACRED_ATTRIB_GAMMAS            (0x00000002)
+#define TSS_TSPATTRIB_DAACRED_CREDENTIAL_BLOB          (0x00000003)
+#define TSS_TSPATTRIB_DAACRED_CALLBACK_SIGN            (0x00000004)
+#define TSS_TSPATTRIB_DAACRED_CALLBACK_VERIFYSIGNATURE (0x00000005)
+
+//
+// Subflags for TSS_TSPATTRIB_DAACRED_COMMIT
+// 
+#define TSS_TSPATTRIB_DAACOMMIT_NUMBER              (0x00000001)
+#define TSS_TSPATTRIB_DAACOMMIT_SELECTION           (0x00000002)
+#define TSS_TSPATTRIB_DAACOMMIT_COMMITMENTS         (0x00000003)
+
+//
+// Subflags for TSS_TSPATTRIB_DAACRED_ATTRIB_GAMMAS
+// 
+#define TSS_TSPATTRIB_DAAATTRIBGAMMAS_BLOB          (0xffffffff)
+
+
+
+//*************************
+// DAA Issuer Key Object: *
+//*************************
+
+//
+// Attribute flags
+//
+#define TSS_TSPATTRIB_DAAISSUERKEY_BLOB              (0x00000001)
+#define TSS_TSPATTRIB_DAAISSUERKEY_PUBKEY            (0x00000002)
+
+//
+// Subflags for TSS_TSPATTRIB_DAAISSUERKEY_BLOB
+// 
+#define TSS_TSPATTRIB_DAAISSUERKEYBLOB_PUBLIC_KEY     (0x00000001)
+#define TSS_TSPATTRIB_DAAISSUERKEYBLOB_SECRET_KEY     (0x00000002)
+#define TSS_TSPATTRIB_DAAISSUERKEYBLOB_KEYBLOB        (0x00000003)
+#define TSS_TSPATTRIB_DAAISSUERKEYBLOB_PROOF          (0x00000004)
+
+//
+// Subflags for TSS_TSPATTRIB_DAAISSUERKEY_PUBKEY
+// 
+#define TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_ATTRIBS          (0x00000001)
+#define TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_PLATFORM_ATTRIBS (0x00000002)
+#define TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_ISSUER_ATTRIBS   (0x00000003)
+
+
+
+//***************************************
+// DAA Anonymity Revocation Key Object: *
+//***************************************
+
+//
+// Attribute flags
+//
+#define TSS_TSPATTRIB_DAAARAKEY_BLOB                 (0x00000001)
+
+//
+// Subflags for TSS_TSPATTRIB_DAAARAKEY_BLOB
+// 
+#define TSS_TSPATTRIB_DAAARAKEYBLOB_PUBLIC_KEY     (0x00000001)
+#define TSS_TSPATTRIB_DAAARAKEYBLOB_SECRET_KEY     (0x00000002)
+#define TSS_TSPATTRIB_DAAARAKEYBLOB_KEYBLOB        (0x00000003)
+
+
+
+//
+// Structure payload flags for TSS_DAA_PSEUDONYM,
+// (TSS_DAA_PSEUDONYM.payloadFlag)
+//
+#define TSS_FLAG_DAA_PSEUDONYM_PLAIN                 (0x00000000)
+#define TSS_FLAG_DAA_PSEUDONYM_ENCRYPTED             (0x00000001)
+
+
+//**************
+// Key Object: *
+//**************
+
+//
+// Attribute flags
+//
+#define TSS_TSPATTRIB_KEY_BLOB       (0x00000040) // key info as blob data
+#define TSS_TSPATTRIB_KEY_INFO       (0x00000080) // keyparam info as blob data
+#define TSS_TSPATTRIB_KEY_UUID       (0x000000C0) // key UUID info as blob data
+#define TSS_TSPATTRIB_KEY_PCR        (0x00000100) // composite digest value for
+                                                  // the key
+#define TSS_TSPATTRIB_RSAKEY_INFO    (0x00000140) // public key info
+#define TSS_TSPATTRIB_KEY_REGISTER   (0x00000180) // register location
+#define TSS_TSPATTRIB_KEY_PCR_LONG   (0x000001c0) // PCR_INFO_LONG for the key
+#define TSS_TSPATTRIB_KEY_CONTROLBIT (0x00000200) // key control flags
+#define TSS_TSPATTRIB_KEY_CMKINFO    (0x00000400) // CMK info
+
+//
+// SubFlags for Flag TSS_TSPATTRIB_KEY_BLOB
+//
+#define TSS_TSPATTRIB_KEYBLOB_BLOB        (0x00000008) // key info using the
+                                                       // key blob
+#define TSS_TSPATTRIB_KEYBLOB_PUBLIC_KEY  (0x00000010) // public key info
+                                                       // using the blob
+#define TSS_TSPATTRIB_KEYBLOB_PRIVATE_KEY (0x00000028) // encrypted private key
+                                                       // blob
+
+//
+// SubFlags for Flag TSS_TSPATTRIB_KEY_INFO
+//
+#define TSS_TSPATTRIB_KEYINFO_SIZE          (0x00000080) // key size in bits
+#define TSS_TSPATTRIB_KEYINFO_USAGE         (0x00000100) // key usage info
+#define TSS_TSPATTRIB_KEYINFO_KEYFLAGS      (0x00000180) // key flags   
+#define TSS_TSPATTRIB_KEYINFO_AUTHUSAGE     (0x00000200) // key auth usage info
+#define TSS_TSPATTRIB_KEYINFO_ALGORITHM     (0x00000280) // key algorithm ID
+#define TSS_TSPATTRIB_KEYINFO_SIGSCHEME     (0x00000300) // key sig scheme
+#define TSS_TSPATTRIB_KEYINFO_ENCSCHEME     (0x00000380) // key enc scheme   
+#define TSS_TSPATTRIB_KEYINFO_MIGRATABLE    (0x00000400) // if true then key is
+                                                         // migratable
+#define TSS_TSPATTRIB_KEYINFO_REDIRECTED    (0x00000480) // key is redirected
+#define TSS_TSPATTRIB_KEYINFO_VOLATILE      (0x00000500) // if true key is
+                                                         // volatile
+#define TSS_TSPATTRIB_KEYINFO_AUTHDATAUSAGE (0x00000580) // if true auth is
+                                                         // required
+#define TSS_TSPATTRIB_KEYINFO_VERSION       (0x00000600) // version info as TSS
+                                                         // version struct
+#define TSS_TSPATTRIB_KEYINFO_CMK           (0x00000680) // if true then key
+                                                         // is certified
+                                                         // migratable
+#define TSS_TSPATTRIB_KEYINFO_KEYSTRUCT     (0x00000700) // type of key struct
+                                                         // used for this key
+                                                         // (TPM_KEY or 
+                                                         // TPM_KEY12)
+#define TSS_TSPATTRIB_KEYCONTROL_OWNEREVICT (0x00000780) // Get current status
+							 // of owner evict flag
+
+//
+// SubFlags for Flag TSS_TSPATTRIB_RSAKEY_INFO
+//
+#define TSS_TSPATTRIB_KEYINFO_RSA_EXPONENT  (0x00001000)
+#define TSS_TSPATTRIB_KEYINFO_RSA_MODULUS   (0x00002000)
+#define TSS_TSPATTRIB_KEYINFO_RSA_KEYSIZE   (0x00003000)
+#define TSS_TSPATTRIB_KEYINFO_RSA_PRIMES    (0x00004000)
+
+//
+// SubFlags for Flag TSS_TSPATTRIB_KEY_PCR
+//
+#define TSS_TSPATTRIB_KEYPCR_DIGEST_ATCREATION  (0x00008000)
+#define TSS_TSPATTRIB_KEYPCR_DIGEST_ATRELEASE   (0x00010000)
+#define TSS_TSPATTRIB_KEYPCR_SELECTION          (0x00018000)
+
+//
+// SubFlags for TSS_TSPATTRIB_KEY_REGISTER
+//
+#define TSS_TSPATTRIB_KEYREGISTER_USER    (0x02000000)
+#define TSS_TSPATTRIB_KEYREGISTER_SYSTEM  (0x04000000)
+#define TSS_TSPATTRIB_KEYREGISTER_NO      (0x06000000)
+
+//
+// SubFlags for Flag TSS_TSPATTRIB_KEY_PCR_LONG
+//
+#define TSS_TSPATTRIB_KEYPCRLONG_LOCALITY_ATCREATION (0x00040000) /* UINT32 */
+#define TSS_TSPATTRIB_KEYPCRLONG_LOCALITY_ATRELEASE  (0x00080000) /* UINT32 */
+#define TSS_TSPATTRIB_KEYPCRLONG_CREATION_SELECTION  (0x000C0000) /* DATA */
+#define TSS_TSPATTRIB_KEYPCRLONG_RELEASE_SELECTION   (0x00100000) /* DATA */
+#define TSS_TSPATTRIB_KEYPCRLONG_DIGEST_ATCREATION   (0x00140000) /* DATA */
+#define TSS_TSPATTRIB_KEYPCRLONG_DIGEST_ATRELEASE    (0x00180000) /* DATA */
+
+//
+// SubFlags for Flag TSS_TSPATTRIB_KEY_CMKINFO
+//
+#define TSS_TSPATTRIB_KEYINFO_CMK_MA_APPROVAL  (0x00000010)
+#define TSS_TSPATTRIB_KEYINFO_CMK_MA_DIGEST    (0x00000020)
+
+
+//
+// Attribute Values
+//
+
+//
+// key size definitions
+//
+#define TSS_KEY_SIZEVAL_512BIT      (0x0200)
+#define TSS_KEY_SIZEVAL_1024BIT     (0x0400)
+#define TSS_KEY_SIZEVAL_2048BIT     (0x0800)
+#define TSS_KEY_SIZEVAL_4096BIT     (0x1000)
+#define TSS_KEY_SIZEVAL_8192BIT     (0x2000)
+#define TSS_KEY_SIZEVAL_16384BIT    (0x4000)
+
+//
+// key usage definitions
+// Values intentionally moved away from corresponding TPM values to avoid
+// possible misuse
+//
+#define TSS_KEYUSAGE_BIND           (0x00)   
+#define TSS_KEYUSAGE_IDENTITY       (0x01)   
+#define TSS_KEYUSAGE_LEGACY         (0x02)   
+#define TSS_KEYUSAGE_SIGN           (0x03)   
+#define TSS_KEYUSAGE_STORAGE        (0x04)
+#define TSS_KEYUSAGE_AUTHCHANGE     (0x05)
+#define TSS_KEYUSAGE_MIGRATE        (0x06)
+
+//
+// key flag definitions
+//
+#define TSS_KEYFLAG_REDIRECTION          (0x00000001)
+#define TSS_KEYFLAG_MIGRATABLE           (0x00000002)
+#define TSS_KEYFLAG_VOLATILEKEY          (0x00000004)
+#define TSS_KEYFLAG_CERTIFIED_MIGRATABLE (0x00000008)
+
+//
+//  algorithm ID definitions
+//
+//  This table defines the algo id's
+//  Values intentionally moved away from corresponding TPM values to avoid
+//  possible misuse
+//
+#define   TSS_ALG_RSA               (0x20)
+#define   TSS_ALG_DES               (0x21)
+#define   TSS_ALG_3DES              (0x22)
+#define   TSS_ALG_SHA               (0x23)
+#define   TSS_ALG_HMAC              (0x24)
+#define   TSS_ALG_AES128            (0x25)
+#define   TSS_ALG_AES192            (0x26)
+#define   TSS_ALG_AES256            (0x27)
+#define   TSS_ALG_XOR               (0x28)
+#define   TSS_ALG_MGF1              (0x29)
+
+#define   TSS_ALG_AES               TSS_ALG_AES128
+
+// Special values for 
+//   Tspi_Context_GetCapability(TSS_TSPCAP_ALG)
+//   Tspi_Context_GetCapability(TSS_TCSCAP_ALG)
+#define   TSS_ALG_DEFAULT           (0xfe)
+#define   TSS_ALG_DEFAULT_SIZE      (0xff)
+
+
+//
+// key signature scheme definitions
+//
+#define TSS_SS_NONE                 (0x10)
+#define TSS_SS_RSASSAPKCS1V15_SHA1  (0x11)
+#define TSS_SS_RSASSAPKCS1V15_DER   (0x12)
+#define	TSS_SS_RSASSAPKCS1V15_INFO  (0x13)
+
+//
+// key encryption scheme definitions
+//
+#define TSS_ES_NONE                 (0x10)
+#define TSS_ES_RSAESPKCSV15         (0x11)
+#define TSS_ES_RSAESOAEP_SHA1_MGF1  (0x12)
+#define TSS_ES_SYM_CNT              (0x13)
+#define TSS_ES_SYM_OFB              (0x14)
+#define TSS_ES_SYM_CBC_PKCS5PAD     (0x15)
+
+
+//
+// persistent storage registration definitions
+//
+#define TSS_PS_TYPE_USER   (1) // Key is registered persistantly in the user
+                               // storage database.
+#define TSS_PS_TYPE_SYSTEM (2) // Key is registered persistantly in the system
+                               // storage database.
+
+//
+// migration scheme definitions
+// Values intentionally moved away from corresponding TPM values to avoid
+// possible misuse
+//
+#define TSS_MS_MIGRATE                   (0x20)
+#define TSS_MS_REWRAP                    (0x21)
+#define TSS_MS_MAINT                     (0x22)
+#define TSS_MS_RESTRICT_MIGRATE          (0x23)
+#define TSS_MS_RESTRICT_APPROVE_DOUBLE   (0x24)
+#define TSS_MS_RESTRICT_MIGRATE_EXTERNAL (0x25)
+
+//
+// TPM key authorization
+// Values intentionally moved away from corresponding TPM values to avoid
+// possible misuse
+//
+#define TSS_KEYAUTH_AUTH_NEVER         (0x10)
+#define TSS_KEYAUTH_AUTH_ALWAYS        (0x11)
+#define TSS_KEYAUTH_AUTH_PRIV_USE_ONLY (0x12)
+
+
+//
+// Flags for TPM status information (GetStatus and SetStatus)
+//
+#define TSS_TPMSTATUS_DISABLEOWNERCLEAR      (0x00000001) // persistent flag
+#define TSS_TPMSTATUS_DISABLEFORCECLEAR      (0x00000002) // volatile flag
+#define TSS_TPMSTATUS_DISABLED               (0x00000003) // persistent flag
+#define TSS_TPMSTATUS_DEACTIVATED            (0x00000004) // volatile flag
+#define TSS_TPMSTATUS_OWNERSETDISABLE        (0x00000005) // persistent flag
+                                                          // for SetStatus
+                                                          // (disable flag) 
+#define TSS_TPMSTATUS_SETOWNERINSTALL        (0x00000006) // persistent flag
+                                                          // (ownership flag)
+#define TSS_TPMSTATUS_DISABLEPUBEKREAD       (0x00000007) // persistent flag
+#define TSS_TPMSTATUS_ALLOWMAINTENANCE       (0x00000008) // persistent flag
+#define TSS_TPMSTATUS_PHYSPRES_LIFETIMELOCK  (0x00000009) // persistent flag
+#define TSS_TPMSTATUS_PHYSPRES_HWENABLE      (0x0000000A) // persistent flag
+#define TSS_TPMSTATUS_PHYSPRES_CMDENABLE     (0x0000000B) // persistent flag
+#define TSS_TPMSTATUS_PHYSPRES_LOCK          (0x0000000C) // volatile flag
+#define TSS_TPMSTATUS_PHYSPRESENCE           (0x0000000D) // volatile flag
+#define TSS_TPMSTATUS_PHYSICALDISABLE        (0x0000000E) // persistent flag
+                                                          // (SetStatus
+                                                          //  disable flag)
+#define TSS_TPMSTATUS_CEKP_USED              (0x0000000F) // persistent flag
+#define TSS_TPMSTATUS_PHYSICALSETDEACTIVATED (0x00000010) // persistent flag
+                                                          // (deactivated flag)
+#define TSS_TPMSTATUS_SETTEMPDEACTIVATED     (0x00000011) // volatile flag
+                                                          // (deactivated flag)
+#define TSS_TPMSTATUS_POSTINITIALISE         (0x00000012) // volatile flag
+#define TSS_TPMSTATUS_TPMPOST                (0x00000013) // persistent flag
+#define TSS_TPMSTATUS_TPMPOSTLOCK            (0x00000014) // persistent flag
+#define TSS_TPMSTATUS_DISABLEPUBSRKREAD      (0x00000016) // persistent flag
+#define TSS_TPMSTATUS_MAINTENANCEUSED        (0x00000017) // persistent flag
+#define TSS_TPMSTATUS_OPERATORINSTALLED      (0x00000018) // persistent flag
+#define TSS_TPMSTATUS_OPERATOR_INSTALLED     (TSS_TPMSTATUS_OPERATORINSTALLED)
+#define TSS_TPMSTATUS_FIPS                   (0x00000019) // persistent flag
+#define TSS_TPMSTATUS_ENABLEREVOKEEK         (0x0000001A) // persistent flag
+#define TSS_TPMSTATUS_ENABLE_REVOKEEK        (TSS_TPMSTATUS_ENABLEREVOKEEK)
+#define TSS_TPMSTATUS_NV_LOCK                (0x0000001B) // persistent flag
+#define TSS_TPMSTATUS_TPM_ESTABLISHED        (0x0000001C) // persistent flag
+#define TSS_TPMSTATUS_RESETLOCK              (0x0000001D) // volatile flag
+#define TSS_TPMSTATUS_DISABLE_FULL_DA_LOGIC_INFO (0x0000001D) //persistent flag
+
+
+//
+// Capability flag definitions
+//
+// TPM capabilities            
+//
+#define TSS_TPMCAP_ORD                   (0x10)
+#define TSS_TPMCAP_ALG                   (0x11)
+#define TSS_TPMCAP_FLAG                  (0x12)
+#define TSS_TPMCAP_PROPERTY              (0x13)
+#define TSS_TPMCAP_VERSION               (0x14)
+#define TSS_TPMCAP_VERSION_VAL           (0x15)
+#define TSS_TPMCAP_NV_LIST               (0x16)
+#define TSS_TPMCAP_NV_INDEX              (0x17)
+#define TSS_TPMCAP_MFR                   (0x18)
+#define TSS_TPMCAP_SYM_MODE              (0x19)
+#define TSS_TPMCAP_HANDLE                (0x1a)
+#define TSS_TPMCAP_TRANS_ES              (0x1b)
+#define TSS_TPMCAP_AUTH_ENCRYPT          (0x1c)  
+#define TSS_TPMCAP_SET_PERM_FLAGS        (0x1d)  // cf. TPM_SET_PERM_FLAGS
+#define TSS_TPMCAP_SET_VENDOR            (0x1e)  // cf. TPM_SET_VENDOR
+#define TSS_TPMCAP_DA_LOGIC              (0x1f)
+
+//
+// Sub-Capability Flags for TSS_TPMCAP_PROPERTY
+//
+#define TSS_TPMCAP_PROP_PCR                 (0x10)
+#define TSS_TPMCAP_PROP_DIR                 (0x11)
+#define TSS_TPMCAP_PROP_MANUFACTURER        (0x12)
+#define TSS_TPMCAP_PROP_SLOTS               (0x13)
+#define TSS_TPMCAP_PROP_KEYS                TSS_TPMCAP_PROP_SLOTS
+#define TSS_TPMCAP_PROP_FAMILYROWS          (0x14)
+#define TSS_TPMCAP_PROP_DELEGATEROWS        (0x15)
+#define TSS_TPMCAP_PROP_OWNER               (0x16)
+#define TSS_TPMCAP_PROP_MAXKEYS             (0x18)
+#define TSS_TPMCAP_PROP_AUTHSESSIONS        (0x19)
+#define TSS_TPMCAP_PROP_MAXAUTHSESSIONS     (0x1a)
+#define TSS_TPMCAP_PROP_TRANSESSIONS        (0x1b)
+#define TSS_TPMCAP_PROP_MAXTRANSESSIONS     (0x1c)
+#define TSS_TPMCAP_PROP_SESSIONS            (0x1d)
+#define TSS_TPMCAP_PROP_MAXSESSIONS         (0x1e)
+#define TSS_TPMCAP_PROP_CONTEXTS            (0x1f)
+#define TSS_TPMCAP_PROP_MAXCONTEXTS         (0x20)
+#define TSS_TPMCAP_PROP_DAASESSIONS         (0x21)
+#define TSS_TPMCAP_PROP_MAXDAASESSIONS      (0x22)
+#define TSS_TPMCAP_PROP_DAA_INTERRUPT       (0x23)
+#define TSS_TPMCAP_PROP_COUNTERS            (0x24)
+#define TSS_TPMCAP_PROP_MAXCOUNTERS         (0x25)
+#define TSS_TPMCAP_PROP_ACTIVECOUNTER       (0x26)
+#define TSS_TPMCAP_PROP_MIN_COUNTER         (0x27)
+#define TSS_TPMCAP_PROP_TISTIMEOUTS         (0x28)
+#define TSS_TPMCAP_PROP_STARTUPEFFECTS      (0x29)
+#define TSS_TPMCAP_PROP_MAXCONTEXTCOUNTDIST (0x2a)
+#define TSS_TPMCAP_PROP_CMKRESTRICTION      (0x2b)
+#define TSS_TPMCAP_PROP_DURATION            (0x2c)
+#define TSS_TPMCAP_PROP_MAXNVAVAILABLE      (0x2d)
+#define TSS_TPMCAP_PROP_INPUTBUFFERSIZE     (0x2e)
+#define TSS_TPMCAP_PROP_REVISION            (0x2f)
+#define TSS_TPMCAP_PROP_LOCALITIES_AVAIL    (0x32)
+
+//
+// Resource type flags
+// Sub-Capability Flags for TSS_TPMCAP_HANDLE
+//
+#define TSS_RT_KEY                     ((UINT32)0x00000010)
+#define TSS_RT_AUTH                    ((UINT32)0x00000020)
+#define TSS_RT_TRANS                   ((UINT32)0x00000030)
+#define TSS_RT_COUNTER                 ((UINT32)0x00000040)
+
+
+//
+// TSS Core Service Capabilities   
+//
+#define TSS_TCSCAP_ALG                   (0x00000001)
+#define TSS_TCSCAP_VERSION               (0x00000002)
+#define TSS_TCSCAP_CACHING               (0x00000003)
+#define TSS_TCSCAP_PERSSTORAGE           (0x00000004)
+#define TSS_TCSCAP_MANUFACTURER          (0x00000005)
+#define TSS_TCSCAP_PLATFORM_CLASS        (0x00000006)
+#define TSS_TCSCAP_TRANSPORT             (0x00000007)
+#define TSS_TCSCAP_PLATFORM_INFO         (0x00000008)
+
+//
+// Sub-Capability Flags TSS-CoreService-Capabilities
+//
+#define TSS_TCSCAP_PROP_KEYCACHE         (0x00000100)
+#define TSS_TCSCAP_PROP_AUTHCACHE        (0x00000101)
+#define TSS_TCSCAP_PROP_MANUFACTURER_STR (0x00000102)
+#define TSS_TCSCAP_PROP_MANUFACTURER_ID  (0x00000103)
+#define TSS_TCSCAP_PLATFORM_VERSION      (0x00001100)
+#define TSS_TCSCAP_PLATFORM_TYPE         (0x00001101)
+#define TSS_TCSCAP_TRANS_EXCLUSIVE       (0x00002100)
+#define TSS_TCSCAP_PROP_HOST_PLATFORM    (0x00003001)
+#define TSS_TCSCAP_PROP_ALL_PLATFORMS    (0x00003002)
+
+//
+// TSS Service Provider Capabilities      
+//
+#define TSS_TSPCAP_ALG                   (0x00000010)
+#define TSS_TSPCAP_VERSION               (0x00000011)
+#define TSS_TSPCAP_PERSSTORAGE           (0x00000012)
+#define TSS_TSPCAP_MANUFACTURER          (0x00000013)
+#define TSS_TSPCAP_RETURNVALUE_INFO      (0x00000015)
+#define TSS_TSPCAP_PLATFORM_INFO         (0x00000016)
+
+// Sub-Capability Flags for TSS_TSPCAP_MANUFACTURER
+//
+#define TSS_TSPCAP_PROP_MANUFACTURER_STR (0x00000102)
+#define TSS_TSPCAP_PROP_MANUFACTURER_ID  (0x00000103)
+
+// Sub-Capability Flags for TSS_TSPCAP_PLATFORM_INFO
+//
+#define TSS_TSPCAP_PLATFORM_TYPE         (0x00000201)
+#define TSS_TSPCAP_PLATFORM_VERSION      (0x00000202)
+
+
+
+// Sub-Capability Flags for TSS_TSPCAP_RETURNVALUE_INFO
+//
+#define TSS_TSPCAP_PROP_RETURNVALUE_INFO (0x00000201)
+
+//
+// Event type definitions
+//
+#define TSS_EV_CODE_CERT                 (0x00000001)
+#define TSS_EV_CODE_NOCERT               (0x00000002)
+#define TSS_EV_XML_CONFIG                (0x00000003)
+#define TSS_EV_NO_ACTION                 (0x00000004)
+#define TSS_EV_SEPARATOR                 (0x00000005)
+#define TSS_EV_ACTION                    (0x00000006)
+#define TSS_EV_PLATFORM_SPECIFIC         (0x00000007)
+
+
+//
+// TSP random number limits
+//
+#define TSS_TSPCAP_RANDOMLIMIT     (0x00001000)   // Errata: Missing from spec
+
+//
+// UUIDs
+//
+// Errata: This are not in the spec
+#define TSS_UUID_SRK  {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 1}} // Storage root key
+#define TSS_UUID_SK   {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 2}} // System key
+#define TSS_UUID_RK   {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 3}} // roaming key
+#define TSS_UUID_CRK  {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 8}} // CMK roaming key
+#define TSS_UUID_USK1 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 4}} // user storage key 1
+#define TSS_UUID_USK2 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 5}} // user storage key 2
+#define TSS_UUID_USK3 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 6}} // user storage key 3
+#define TSS_UUID_USK4 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 7}} // user storage key 4
+#define TSS_UUID_USK5 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 9}} // user storage key 5
+#define TSS_UUID_USK6 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 10}}// user storage key 6
+
+// macro to derive UUIDs for keys whose "OwnerEvict" key is set.
+#define TSS_UUID_OWNEREVICT(i) {0, 0, 0, 0, 0, {0, 0, 0, 0, 1, (i)}}
+
+
+//
+// TPM well-known secret
+//
+#define TSS_WELL_KNOWN_SECRET \
+        {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+
+
+// Values for the "direction" parameters in the Tspi_PcrComposite_XX functions.
+#define TSS_PCRS_DIRECTION_CREATION                        ((UINT32)1)
+#define TSS_PCRS_DIRECTION_RELEASE                         ((UINT32)2)
+
+
+//
+// TSS blob version definition for ASN.1 blobs
+//
+#define TSS_BLOB_STRUCT_VERSION                              0x01
+
+//
+// TSS blob type definitions for ASN.1 blobs
+//
+#define TSS_BLOB_TYPE_KEY                                    0x01
+#define TSS_BLOB_TYPE_PUBKEY                                 0x02
+#define TSS_BLOB_TYPE_MIGKEY                                 0x03
+#define TSS_BLOB_TYPE_SEALEDDATA                             0x04
+#define TSS_BLOB_TYPE_BOUNDDATA                              0x05
+#define TSS_BLOB_TYPE_MIGTICKET                              0x06
+#define TSS_BLOB_TYPE_PRIVATEKEY                             0x07
+#define TSS_BLOB_TYPE_PRIVATEKEY_MOD1                        0x08
+#define TSS_BLOB_TYPE_RANDOM_XOR                             0x09
+#define TSS_BLOB_TYPE_CERTIFY_INFO                           0x0A
+#define TSS_BLOB_TYPE_KEY_1_2                                0x0B
+#define TSS_BLOB_TYPE_CERTIFY_INFO_2                         0x0C
+#define TSS_BLOB_TYPE_CMK_MIG_KEY                            0x0D
+#define TSS_BLOB_TYPE_CMK_BYTE_STREAM                        0x0E
+
+
+
+//
+// Values for TPM_CMK_DELEGATE bitmasks
+// For now these are exactly the same values as the corresponding
+// TPM_CMK_DELEGATE_* bitmasks.
+//
+#define TSS_CMK_DELEGATE_SIGNING       (((UINT32)1)<<31)
+#define TSS_CMK_DELEGATE_STORAGE       (((UINT32)1)<<30)
+#define TSS_CMK_DELEGATE_BIND          (((UINT32)1)<<29)
+#define TSS_CMK_DELEGATE_LEGACY        (((UINT32)1)<<28)
+#define TSS_CMK_DELEGATE_MIGRATE       (((UINT32)1)<<27)
+
+
+//
+// Constants for DAA
+//
+#define TSS_DAA_LENGTH_N                256             // Length of the RSA Modulus (2048 bits)
+#define TSS_DAA_LENGTH_F                13              // Length of the f_i's (information encoded into the certificate, 104 bits)
+#define TSS_DAA_LENGTH_E                46              // Length of the e's (exponents, part of certificate, 386 bits)
+#define TSS_DAA_LENGTH_E_PRIME          15              // Length of the interval the e's are chosen from (120 bits)
+#define TSS_DAA_LENGTH_V                317             // Length of the v's (random value, part of certificate, 2536 bits)
+#define TSS_DAA_LENGTH_SAFETY           10              // Length of the security parameter controlling the statistical zero-knowledge property (80 bits)
+#define TSS_DAA_LENGTH_HASH     TPM_SHA1_160_HASH_LEN   // Length of the output of the hash function SHA-1 used for the Fiat-Shamir heuristic(160 bits)
+#define TSS_DAA_LENGTH_S                128             // Length of the split large exponent for easier computations on the TPM (1024 bits)
+#define TSS_DAA_LENGTH_GAMMA            204             // Length of the modulus 'Gamma' (1632 bits)
+#define TSS_DAA_LENGTH_RHO              26              // Length of the order 'rho' of the sub group of Z*_Gamma that is used for roggue tagging (208 bits)
+#define TSS_DAA_LENGTH_MFG1_GAMMA       214             // Length of the output of MGF1 in conjunction with the modulus Gamma (1712 bits)
+#define TSS_DAA_LENGTH_MGF1_AR          25              // Length of the output of MGF1 used for anonymity revocation (200 bits)
+
+
+#endif // __TSS_DEFINES_H__
diff --git a/src/include/tss/tss_error.h b/src/include/tss/tss_error.h
index 3330a9b..dd64c8a 100644
--- a/src/include/tss/tss_error.h
+++ b/src/include/tss/tss_error.h
@@ -1,687 +1,687 @@
-/*++
-
-TSS error return codes 
- 
---*/
-
-#ifndef __TSS_ERROR_H__
-#define __TSS_ERROR_H__
-
-#include <tss/platform.h>
-
-//
-// error coding scheme for a Microsoft Windows platform -
-// refer to the TSS Specification Parts
-//
-//  Values are 32 bit values layed out as follows:
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//  +---+-+-+-----------------------+-------+-----------------------+
-//  |Lev|C|R|     Facility          | Layer |         Code          |
-//  +---+-+-+-----------------------+-------+-----------------------+
-//  | Platform specific coding      | TSS error coding system       |
-//  +---+-+-+-----------------------+-------+-----------------------+
-//
-//      Lev - is the Level code
-//
-//          00 - Success
-//          01 - Informational
-//          10 - Warning
-//          11 - Error
-//
-//      C - is the Customer code flag  (must actually be set)
-//
-//      R - is a reserved bit    (unused)
-//
-//      Facility - is the facility code: TCPA: proposal 0x028
-//
-//      Code - is the facility's status code
-//
-
-//
-// definitions for the code level information
-//
-#define TSS_LEVEL_SUCCESS  0x00     // code level success 
-#define TSS_LEVEL_INFO     0x40000000L    // code level information
-#define TSS_LEVEL_WARNING  0x80000000L    // code level warning
-#define TSS_LEVEL_ERROR    0xC0000000L    // code level error
-
-//
-// some defines for the platform specific information
-//
-#define FACILITY_TSS            0x28L     // facility number for TCPA return codes
-#define FACILITY_TSS_CODEPOS   (FACILITY_TSS << 16)  // shift the facility info to the code 
-                                                                        // position
-
-#define TSS_CUSTOM_CODEFLAG     0x20000000L    // bit position for the custom flag in 
-                                                                        // return code
-
-//
-//
-// TSS error return codes
-//
-//
-#ifndef TSS_E_BASE
-#define TSS_E_BASE    0x00000000L
-#endif // TSS_E_BASE
-#ifndef TSS_W_BASE
-#define TSS_W_BASE    0x00000000L
-#endif // TSS_W_BASE
-#ifndef TSS_I_BASE
-#define TSS_I_BASE    0x00000000L
-#endif // TSS_I_BASE
-
-//
-// basic error return codes common to all TSS Service Provider Interface methods
-// and returned by all TSS SW stack components
-//
-
-//
-// MessageId: TSS_SUCCESS
-//
-// MessageText:
-//
-//  Successful completion of the operation.
-//
-#define TSS_SUCCESS     (UINT32)(0x00000000L)
-
-//
-// MessageId: TSS_E_FAIL
-//
-// MessageText:
-//
-//  An internal error has been detected, but the source is unknown.
-//
-#define TSS_E_FAIL     (UINT32)(TSS_E_BASE + 0x002L)
-
-//
-// MessageId: TSS_E_BAD_PARAMETER
-//
-// MessageText:
-//
-// One or more parameter is bad.
-//
-#define TSS_E_BAD_PARAMETER    (UINT32)(TSS_E_BASE + 0x003L)
-
-//
-// MessageId: TSS_E_INTERNAL_ERROR
-//
-// MessageText:
-//
-//  An internal SW error has been detected.
-//
-#define TSS_E_INTERNAL_ERROR    (UINT32)(TSS_E_BASE + 0x004L)
-
-//
-// MessageId: TSS_E_OUTOFMEMORY
-//
-// MessageText:
-//
-// Ran out of memory.
-//
-#define TSS_E_OUTOFMEMORY    (UINT32)(TSS_E_BASE + 0x005L)
-
-//
-// MessageId: TSS_E_NOTIMPL
-//
-// MessageText:
-//
-// Not implemented.
-//
-#define TSS_E_NOTIMPL     (UINT32)(TSS_E_BASE + 0x006L)
-
-//
-// MessageId: TSS_E_KEY_ALREADY_REGISTERED
-//
-// MessageText:
-//
-//  Key is already registered
-//
-#define TSS_E_KEY_ALREADY_REGISTERED  (UINT32)(TSS_E_BASE + 0x008L)
-
-
-//
-// MessageId: TSS_E_TPM_UNEXPECTED
-//
-// MessageText:
-//
-//  An unexpected TPM error has occurred.
-//
-#define TSS_E_TPM_UNEXPECTED    (UINT32)(TSS_E_BASE + 0x010L)
-
-//
-// MessageId: TSS_E_COMM_FAILURE
-//
-// MessageText:
-//
-//  A communications error with the TPM has been detected.
-//
-#define TSS_E_COMM_FAILURE    (UINT32)(TSS_E_BASE + 0x011L)
-
-//
-// MessageId: TSS_E_TIMEOUT
-//
-// MessageText:
-//
-//  The operation has timed out.
-//
-#define TSS_E_TIMEOUT     (UINT32)(TSS_E_BASE + 0x012L)
-
-//
-// MessageId: TSS_E_TPM_UNSUPPORTED_FEATURE
-//
-// MessageText:
-//
-//  The TPM does not support the requested feature.
-//
-#define TSS_E_TPM_UNSUPPORTED_FEATURE  (UINT32)(TSS_E_BASE + 0x014L)
-
-//
-// MessageId: TSS_E_CANCELED
-//
-// MessageText:
-//
-//  The action was canceled by request.
-//
-#define TSS_E_CANCELED     (UINT32)(TSS_E_BASE + 0x016L)
-
-//
-// MessageId: TSS_E_PS_KEY_NOTFOUND
-//
-// MessageText:
-//
-// The key cannot be found in the persistent storage database.
-//
-#define TSS_E_PS_KEY_NOTFOUND    (UINT32)(TSS_E_BASE + 0x020L)
-//
-// MessageId: TSS_E_PS_KEY_EXISTS
-//
-// MessageText:
-//
-// The key already exists in the persistent storage database.
-//
-#define TSS_E_PS_KEY_EXISTS            (UINT32)(TSS_E_BASE + 0x021L)
-
-//
-// MessageId: TSS_E_PS_BAD_KEY_STATE
-//
-// MessageText:
-//
-// The key data set not valid in the persistent storage database.
-//
-#define TSS_E_PS_BAD_KEY_STATE         (UINT32)(TSS_E_BASE + 0x022L)
-
-
-//
-// error codes returned by specific TSS Service Provider Interface methods
-// offset TSS_TSPI_OFFSET
-//
-
-//
-// MessageId: TSS_E_INVALID_OBJECT_TYPE
-//
-// MessageText:
-//
-// Object type not valid for this operation.
-//
-#define TSS_E_INVALID_OBJECT_TYPE   (UINT32)(TSS_E_BASE + 0x101L)
-
-//
-// MessageId: TSS_E_NO_CONNECTION
-//
-// MessageText:
-//
-// Core Service connection doesn't exist.
-//
-#define TSS_E_NO_CONNECTION    (UINT32)(TSS_E_BASE + 0x102L)
- 
-//
-// MessageId: TSS_E_CONNECTION_FAILED
-//
-// MessageText:
-//
-// Core Service connection failed.
-//
-#define TSS_E_CONNECTION_FAILED   (UINT32)(TSS_E_BASE + 0x103L)
-
-//
-// MessageId: TSS_E_CONNECTION_BROKEN
-//
-// MessageText:
-//
-// Communication with Core Service failed.
-//
-#define TSS_E_CONNECTION_BROKEN   (UINT32)(TSS_E_BASE + 0x104L)
-
-//
-// MessageId: TSS_E_HASH_INVALID_ALG
-//
-// MessageText:
-//
-// Invalid hash algorithm.
-//
-#define TSS_E_HASH_INVALID_ALG   (UINT32)(TSS_E_BASE + 0x105L)
-
-//
-// MessageId: TSS_E_HASH_INVALID_LENGTH
-//
-// MessageText:
-//
-// Hash length is inconsistent with hash algorithm.
-//
-#define TSS_E_HASH_INVALID_LENGTH   (UINT32)(TSS_E_BASE + 0x106L)
-
-//
-// MessageId: TSS_E_HASH_NO_DATA
-//
-// MessageText:
-//
-// Hash object has no internal hash value.
-//
-#define TSS_E_HASH_NO_DATA    (UINT32)(TSS_E_BASE + 0x107L)
-
-
-//
-// MessageId: TSS_E_INVALID_ATTRIB_FLAG
-//
-// MessageText:
-//
-// Flag value for attrib-functions inconsistent.
-//
-#define TSS_E_INVALID_ATTRIB_FLAG   (UINT32)(TSS_E_BASE + 0x109L)
-
-//
-// MessageId: TSS_E_INVALID_ATTRIB_SUBFLAG
-//
-// MessageText:
-//
-// Subflag value for attrib-functions inconsistent.
-//
-#define TSS_E_INVALID_ATTRIB_SUBFLAG  (UINT32)(TSS_E_BASE + 0x10AL)
-
-//
-// MessageId: TSS_E_INVALID_ATTRIB_DATA
-//
-// MessageText:
-//
-// Data for attrib-functions invalid.
-//
-#define TSS_E_INVALID_ATTRIB_DATA   (UINT32)(TSS_E_BASE + 0x10BL)
-
-//
-// MessageId: TSS_E_INVALID_OBJECT_INITFLAG
-//
-// MessageText:
-//
-// Wrong flag information for object creation.
-// 
-// The alternate spelling is supported to be compatible with a typo
-// in the 1.1b header files.
-//
-#define TSS_E_INVALID_OBJECT_INIT_FLAG  (UINT32)(TSS_E_BASE + 0x10CL)
-#define TSS_E_INVALID_OBJECT_INITFLAG   TSS_E_INVALID_OBJECT_INIT_FLAG
- 
-//
-// MessageId: TSS_E_NO_PCRS_SET
-//
-// MessageText:
-//
-// No PCR register are selected or set.
-//
-#define TSS_E_NO_PCRS_SET    (UINT32)(TSS_E_BASE + 0x10DL)
-
-//
-// MessageId: TSS_E_KEY_NOT_LOADED
-//
-// MessageText:
-//
-// The addressed key is currently not loaded.
-//
-#define TSS_E_KEY_NOT_LOADED    (UINT32)(TSS_E_BASE + 0x10EL)
- 
-//
-// MessageId: TSS_E_KEY_NOT_SET
-//
-// MessageText:
-//
-// No key information is currently available.
-//
-#define TSS_E_KEY_NOT_SET    (UINT32)(TSS_E_BASE + 0x10FL)
-      
-//
-// MessageId: TSS_E_VALIDATION_FAILED
-//
-// MessageText:
-//
-// Internal validation of data failed.
-//
-#define TSS_E_VALIDATION_FAILED   (UINT32)(TSS_E_BASE + 0x110L)
-
-//
-// MessageId: TSS_E_TSP_AUTHREQUIRED
-//
-// MessageText:
-//
-// Authorization is required.
-//
-#define TSS_E_TSP_AUTHREQUIRED   (UINT32)(TSS_E_BASE + 0x111L)
-
-//
-// MessageId: TSS_E_TSP_AUTH2REQUIRED
-//
-// MessageText:
-//
-// Multiple authorization is required.
-//
-#define TSS_E_TSP_AUTH2REQUIRED   (UINT32)(TSS_E_BASE + 0x112L)
-
-//
-// MessageId: TSS_E_TSP_AUTHFAIL
-//
-// MessageText:
-//
-// Authorization failed.
-//
-#define TSS_E_TSP_AUTHFAIL    (UINT32)(TSS_E_BASE + 0x113L)
-
-//
-// MessageId: TSS_E_TSP_AUTH2FAIL
-//
-// MessageText:
-//
-// Multiple authorization failed.
-//
-#define TSS_E_TSP_AUTH2FAIL    (UINT32)(TSS_E_BASE + 0x114L)
- 
-//
-// MessageId: TSS_E_KEY_NO_MIGRATION_POLICY
-//
-// MessageText:
-//
-// There's no migration policy object set for the addressed key.
-//
-#define TSS_E_KEY_NO_MIGRATION_POLICY  (UINT32)(TSS_E_BASE + 0x115L) 
-
-//
-// MessageId: TSS_E_POLICY_NO_SECRET
-//
-// MessageText:
-//
-// No secret information is currently available for the addressed policy object.
-//
-#define TSS_E_POLICY_NO_SECRET   (UINT32)(TSS_E_BASE + 0x116L)
-
-//
-// MessageId: TSS_E_INVALID_OBJ_ACCESS
-//
-// MessageText:
-//
-// The operation failed due to an invalid object status.
-//
-#define TSS_E_INVALID_OBJ_ACCESS   (UINT32)(TSS_E_BASE + 0x117L)
-
-//
-// MessageId: TSS_E_INVALID_ENCSCHEME
-//
-// MessageText:
-//
-// 
-//
-#define TSS_E_INVALID_ENCSCHEME   (UINT32)(TSS_E_BASE + 0x118L)
-
-
-//
-// MessageId: TSS_E_INVALID_SIGSCHEME
-//
-// MessageText:
-//
-// 
-//
-#define TSS_E_INVALID_SIGSCHEME   (UINT32)(TSS_E_BASE + 0x119L)
-
-//
-// MessageId: TSS_E_ENC_INVALID_LENGTH
-//
-// MessageText:
-//
-// 
-//
-#define TSS_E_ENC_INVALID_LENGTH   (UINT32)(TSS_E_BASE + 0x120L)
-
-
-//
-// MessageId: TSS_E_ENC_NO_DATA
-//
-// MessageText:
-//
-// 
-//
-#define TSS_E_ENC_NO_DATA    (UINT32)(TSS_E_BASE + 0x121L)
-
-//
-// MessageId: TSS_E_ENC_INVALID_TYPE
-//
-// MessageText:
-//
-// 
-//
-#define TSS_E_ENC_INVALID_TYPE   (UINT32)(TSS_E_BASE + 0x122L)
-
-
-//
-// MessageId: TSS_E_INVALID_KEYUSAGE
-//
-// MessageText:
-//
-// 
-//
-#define TSS_E_INVALID_KEYUSAGE   (UINT32)(TSS_E_BASE + 0x123L)
-
-//
-// MessageId: TSS_E_VERIFICATION_FAILED
-//
-// MessageText:
-//
-// 
-//
-#define TSS_E_VERIFICATION_FAILED   (UINT32)(TSS_E_BASE + 0x124L)
-
-//
-// MessageId: TSS_E_HASH_NO_IDENTIFIER
-//
-// MessageText:
-//
-// Hash algorithm identifier not set.
-//
-#define TSS_E_HASH_NO_IDENTIFIER   (UINT32)(TSS_E_BASE + 0x125L)
-
-//
-// MessageId: TSS_E_INVALID_HANDLE
-//
-// MessageText:
-//
-//  An invalid handle
-//
-#define TSS_E_INVALID_HANDLE    (UINT32)(TSS_E_BASE + 0x126L)
-
-//
-// MessageId: TSS_E_SILENT_CONTEXT
-//
-// MessageText:
-//
-//  A silent context requires user input
-//
-#define TSS_E_SILENT_CONTEXT           (UINT32)(TSS_E_BASE + 0x127L)
-
-//
-// MessageId: TSS_E_EK_CHECKSUM
-//
-// MessageText:
-//
-// TSP is instructed to verify the EK checksum and it does not verify.
-//
-#define TSS_E_EK_CHECKSUM             (UINT32)(TSS_E_BASE + 0x128L)
-
-
-//
-// MessageId: TSS_E_DELGATION_NOTSET
-//
-// MessageText:
-//
-// The Policy object does not have a delegation blob set.
-//
-#define TSS_E_DELEGATION_NOTSET      (UINT32)(TSS_E_BASE + 0x129L)
-
-//
-// MessageId: TSS_E_DELFAMILY_NOTFOUND
-//
-// MessageText:
-//
-// The specified delegation family was not found
-//
-#define TSS_E_DELFAMILY_NOTFOUND       (UINT32)(TSS_E_BASE + 0x130L)
-
-//
-// MessageId: TSS_E_DELFAMILY_ROWEXISTS
-//
-// MessageText:
-//
-// The specified delegation family table row is already in use and
-// the command flags does not allow the TSS to overwrite the existing
-// entry.
-//
-#define TSS_E_DELFAMILY_ROWEXISTS    (UINT32)(TSS_E_BASE + 0x131L)
-
-//
-// MessageId: TSS_E_VERSION_MISMATCH
-//
-// MessageText:
-//
-// The specified delegation family table row is already in use and
-// the command flags does not allow the TSS to overwrite the existing
-// entry.
-//
-#define TSS_E_VERSION_MISMATCH       (UINT32)(TSS_E_BASE + 0x132L)
-
-//
-//  MessageId: TSS_E_DAA_AR_DECRYPTION_ERROR
-//
-//  Decryption of the encrypted pseudonym has failed, due to
-//  either a wrong secret key or a wrong decryption condition.
-//
-#define TSS_E_DAA_AR_DECRYPTION_ERROR             (UINT32)(TSS_E_BASE + 0x133L)
-
-//
-//  MessageId: TSS_E_DAA_AUTHENTICATION_ERROR
-//
-//  The TPM could not be authenticated by the DAA Issuer.
-//
-#define TSS_E_DAA_AUTHENTICATION_ERROR            (UINT32)(TSS_E_BASE + 0x134L)
-
-//
-//  MessageId: TSS_E_DAA_CHALLENGE_RESPONSE_ERROR
-//
-//  DAA Challenge response error.
-//
-#define TSS_E_DAA_CHALLENGE_RESPONSE_ERROR        (UINT32)(TSS_E_BASE + 0x135L)
-
-//
-//  MessageId: TSS_E_DAA_CREDENTIAL_PROOF_ERROR
-//
-//  Verification of the credential TSS_DAA_CRED_ISSUER issued by
-//  the DAA Issuer has failed.
-//
-#define TSS_E_DAA_CREDENTIAL_PROOF_ERROR          (UINT32)(TSS_E_BASE + 0x136L)
-
-//
-//  MessageId: TSS_E_DAA_CREDENTIAL_REQUEST_PROOF_ERROR
-//
-//  Verification of the platform's credential request
-//  TSS_DAA_CREDENTIAL_REQUEST has failed.
-//
-#define TSS_E_DAA_CREDENTIAL_REQUEST_PROOF_ERROR  (UINT32)(TSS_E_BASE + 0x137L)
-
-//
-//  MessageId: TSS_E_DAA_ISSUER_KEY_ERROR
-//
-//  DAA Issuer's authentication key chain could not be verified or
-//  is not correct.
-//
-#define TSS_E_DAA_ISSUER_KEY_ERROR                (UINT32)(TSS_E_BASE + 0x138L)
-
-//
-//  MessageId: TSS_E_DAA_PSEUDONYM_ERROR
-//
-//  While verifying the pseudonym of the TPM, the private key of the
-//  TPM was found on the rogue list.
-//
-#define TSS_E_DAA_PSEUDONYM_ERROR                 (UINT32)(TSS_E_BASE + 0x139L)
-
-//
-//  MessageId: TSS_E_INVALID_RESOURCE
-//
-//  Pointer to memory wrong.
-//
-#define TSS_E_INVALID_RESOURCE                    (UINT32)(TSS_E_BASE + 0x13AL)
-
-//
-//  MessageId: TSS_E_NV_AREA_EXIST
-//
-//  The NV area referenced already exists
-//
-#define TSS_E_NV_AREA_EXIST                       (UINT32)(TSS_E_BASE + 0x13BL)
-
-//
-//  MessageId: TSS_E_NV_AREA_NOT_EXIST
-//
-//  The NV area referenced doesn't exist
-//
-#define TSS_E_NV_AREA_NOT_EXIST                   (UINT32)(TSS_E_BASE + 0x13CL)
-
-//
-//  MessageId: TSS_E_TSP_TRANS_AUTHFAIL
-//
-//  The transport session authorization failed
-//
-#define TSS_E_TSP_TRANS_AUTHFAIL                  (UINT32)(TSS_E_BASE + 0x13DL)
-
-//
-//  MessageId: TSS_E_TSP_TRANS_AUTHREQUIRED
-//
-//  Authorization for transport is required
-//
-#define TSS_E_TSP_TRANS_AUTHREQUIRED              (UINT32)(TSS_E_BASE + 0x13EL)
-
-//
-//  MessageId: TSS_E_TSP_TRANS_NOT_EXCLUSIVE
-//
-//  A command was executed outside of an exclusive transport session.
-//
-#define TSS_E_TSP_TRANS_NOTEXCLUSIVE              (UINT32)(TSS_E_BASE + 0x13FL)
-
-//
-//  MessageId: TSS_E_TSP_TRANS_FAIL
-//
-//  Generic transport protection error.
-//
-#define TSS_E_TSP_TRANS_FAIL                     (UINT32)(TSS_E_BASE + 0x140L)
-
-//
-//  MessageId: TSS_E_TSP_TRANS_NO_PUBKEY
-//
-//  A command could not be executed through a logged transport session
-//  because the command used a key and the key's public key is not
-//  known to the TSP.
-//
-#define TSS_E_TSP_TRANS_NO_PUBKEY                (UINT32)(TSS_E_BASE + 0x141L)
-
-//
-//  MessageId: TSS_E_NO_ACTIVE_COUNTER
-//
-//  The TPM active counter has not been set yet.
-//
-#define TSS_E_NO_ACTIVE_COUNTER                  (UINT32)(TSS_E_BASE + 0x142L)
-
-
-#endif // __TSS_ERROR_H__
+/*++
+
+TSS error return codes 
+ 
+--*/
+
+#ifndef __TSS_ERROR_H__
+#define __TSS_ERROR_H__
+
+#include <tss/platform.h>
+
+//
+// error coding scheme for a Microsoft Windows platform -
+// refer to the TSS Specification Parts
+//
+//  Values are 32 bit values layed out as follows:
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//  +---+-+-+-----------------------+-------+-----------------------+
+//  |Lev|C|R|     Facility          | Layer |         Code          |
+//  +---+-+-+-----------------------+-------+-----------------------+
+//  | Platform specific coding      | TSS error coding system       |
+//  +---+-+-+-----------------------+-------+-----------------------+
+//
+//      Lev - is the Level code
+//
+//          00 - Success
+//          01 - Informational
+//          10 - Warning
+//          11 - Error
+//
+//      C - is the Customer code flag  (must actually be set)
+//
+//      R - is a reserved bit    (unused)
+//
+//      Facility - is the facility code: TCPA: proposal 0x028
+//
+//      Code - is the facility's status code
+//
+
+//
+// definitions for the code level information
+//
+#define TSS_LEVEL_SUCCESS  0x00     // code level success 
+#define TSS_LEVEL_INFO     0x40000000L    // code level information
+#define TSS_LEVEL_WARNING  0x80000000L    // code level warning
+#define TSS_LEVEL_ERROR    0xC0000000L    // code level error
+
+//
+// some defines for the platform specific information
+//
+#define FACILITY_TSS            0x28L     // facility number for TCPA return codes
+#define FACILITY_TSS_CODEPOS   (FACILITY_TSS << 16)  // shift the facility info to the code 
+                                                                        // position
+
+#define TSS_CUSTOM_CODEFLAG     0x20000000L    // bit position for the custom flag in 
+                                                                        // return code
+
+//
+//
+// TSS error return codes
+//
+//
+#ifndef TSS_E_BASE
+#define TSS_E_BASE    0x00000000L
+#endif // TSS_E_BASE
+#ifndef TSS_W_BASE
+#define TSS_W_BASE    0x00000000L
+#endif // TSS_W_BASE
+#ifndef TSS_I_BASE
+#define TSS_I_BASE    0x00000000L
+#endif // TSS_I_BASE
+
+//
+// basic error return codes common to all TSS Service Provider Interface methods
+// and returned by all TSS SW stack components
+//
+
+//
+// MessageId: TSS_SUCCESS
+//
+// MessageText:
+//
+//  Successful completion of the operation.
+//
+#define TSS_SUCCESS     (UINT32)(0x00000000L)
+
+//
+// MessageId: TSS_E_FAIL
+//
+// MessageText:
+//
+//  An internal error has been detected, but the source is unknown.
+//
+#define TSS_E_FAIL     (UINT32)(TSS_E_BASE + 0x002L)
+
+//
+// MessageId: TSS_E_BAD_PARAMETER
+//
+// MessageText:
+//
+// One or more parameter is bad.
+//
+#define TSS_E_BAD_PARAMETER    (UINT32)(TSS_E_BASE + 0x003L)
+
+//
+// MessageId: TSS_E_INTERNAL_ERROR
+//
+// MessageText:
+//
+//  An internal SW error has been detected.
+//
+#define TSS_E_INTERNAL_ERROR    (UINT32)(TSS_E_BASE + 0x004L)
+
+//
+// MessageId: TSS_E_OUTOFMEMORY
+//
+// MessageText:
+//
+// Ran out of memory.
+//
+#define TSS_E_OUTOFMEMORY    (UINT32)(TSS_E_BASE + 0x005L)
+
+//
+// MessageId: TSS_E_NOTIMPL
+//
+// MessageText:
+//
+// Not implemented.
+//
+#define TSS_E_NOTIMPL     (UINT32)(TSS_E_BASE + 0x006L)
+
+//
+// MessageId: TSS_E_KEY_ALREADY_REGISTERED
+//
+// MessageText:
+//
+//  Key is already registered
+//
+#define TSS_E_KEY_ALREADY_REGISTERED  (UINT32)(TSS_E_BASE + 0x008L)
+
+
+//
+// MessageId: TSS_E_TPM_UNEXPECTED
+//
+// MessageText:
+//
+//  An unexpected TPM error has occurred.
+//
+#define TSS_E_TPM_UNEXPECTED    (UINT32)(TSS_E_BASE + 0x010L)
+
+//
+// MessageId: TSS_E_COMM_FAILURE
+//
+// MessageText:
+//
+//  A communications error with the TPM has been detected.
+//
+#define TSS_E_COMM_FAILURE    (UINT32)(TSS_E_BASE + 0x011L)
+
+//
+// MessageId: TSS_E_TIMEOUT
+//
+// MessageText:
+//
+//  The operation has timed out.
+//
+#define TSS_E_TIMEOUT     (UINT32)(TSS_E_BASE + 0x012L)
+
+//
+// MessageId: TSS_E_TPM_UNSUPPORTED_FEATURE
+//
+// MessageText:
+//
+//  The TPM does not support the requested feature.
+//
+#define TSS_E_TPM_UNSUPPORTED_FEATURE  (UINT32)(TSS_E_BASE + 0x014L)
+
+//
+// MessageId: TSS_E_CANCELED
+//
+// MessageText:
+//
+//  The action was canceled by request.
+//
+#define TSS_E_CANCELED     (UINT32)(TSS_E_BASE + 0x016L)
+
+//
+// MessageId: TSS_E_PS_KEY_NOTFOUND
+//
+// MessageText:
+//
+// The key cannot be found in the persistent storage database.
+//
+#define TSS_E_PS_KEY_NOTFOUND    (UINT32)(TSS_E_BASE + 0x020L)
+//
+// MessageId: TSS_E_PS_KEY_EXISTS
+//
+// MessageText:
+//
+// The key already exists in the persistent storage database.
+//
+#define TSS_E_PS_KEY_EXISTS            (UINT32)(TSS_E_BASE + 0x021L)
+
+//
+// MessageId: TSS_E_PS_BAD_KEY_STATE
+//
+// MessageText:
+//
+// The key data set not valid in the persistent storage database.
+//
+#define TSS_E_PS_BAD_KEY_STATE         (UINT32)(TSS_E_BASE + 0x022L)
+
+
+//
+// error codes returned by specific TSS Service Provider Interface methods
+// offset TSS_TSPI_OFFSET
+//
+
+//
+// MessageId: TSS_E_INVALID_OBJECT_TYPE
+//
+// MessageText:
+//
+// Object type not valid for this operation.
+//
+#define TSS_E_INVALID_OBJECT_TYPE   (UINT32)(TSS_E_BASE + 0x101L)
+
+//
+// MessageId: TSS_E_NO_CONNECTION
+//
+// MessageText:
+//
+// Core Service connection doesn't exist.
+//
+#define TSS_E_NO_CONNECTION    (UINT32)(TSS_E_BASE + 0x102L)
+ 
+//
+// MessageId: TSS_E_CONNECTION_FAILED
+//
+// MessageText:
+//
+// Core Service connection failed.
+//
+#define TSS_E_CONNECTION_FAILED   (UINT32)(TSS_E_BASE + 0x103L)
+
+//
+// MessageId: TSS_E_CONNECTION_BROKEN
+//
+// MessageText:
+//
+// Communication with Core Service failed.
+//
+#define TSS_E_CONNECTION_BROKEN   (UINT32)(TSS_E_BASE + 0x104L)
+
+//
+// MessageId: TSS_E_HASH_INVALID_ALG
+//
+// MessageText:
+//
+// Invalid hash algorithm.
+//
+#define TSS_E_HASH_INVALID_ALG   (UINT32)(TSS_E_BASE + 0x105L)
+
+//
+// MessageId: TSS_E_HASH_INVALID_LENGTH
+//
+// MessageText:
+//
+// Hash length is inconsistent with hash algorithm.
+//
+#define TSS_E_HASH_INVALID_LENGTH   (UINT32)(TSS_E_BASE + 0x106L)
+
+//
+// MessageId: TSS_E_HASH_NO_DATA
+//
+// MessageText:
+//
+// Hash object has no internal hash value.
+//
+#define TSS_E_HASH_NO_DATA    (UINT32)(TSS_E_BASE + 0x107L)
+
+
+//
+// MessageId: TSS_E_INVALID_ATTRIB_FLAG
+//
+// MessageText:
+//
+// Flag value for attrib-functions inconsistent.
+//
+#define TSS_E_INVALID_ATTRIB_FLAG   (UINT32)(TSS_E_BASE + 0x109L)
+
+//
+// MessageId: TSS_E_INVALID_ATTRIB_SUBFLAG
+//
+// MessageText:
+//
+// Subflag value for attrib-functions inconsistent.
+//
+#define TSS_E_INVALID_ATTRIB_SUBFLAG  (UINT32)(TSS_E_BASE + 0x10AL)
+
+//
+// MessageId: TSS_E_INVALID_ATTRIB_DATA
+//
+// MessageText:
+//
+// Data for attrib-functions invalid.
+//
+#define TSS_E_INVALID_ATTRIB_DATA   (UINT32)(TSS_E_BASE + 0x10BL)
+
+//
+// MessageId: TSS_E_INVALID_OBJECT_INITFLAG
+//
+// MessageText:
+//
+// Wrong flag information for object creation.
+// 
+// The alternate spelling is supported to be compatible with a typo
+// in the 1.1b header files.
+//
+#define TSS_E_INVALID_OBJECT_INIT_FLAG  (UINT32)(TSS_E_BASE + 0x10CL)
+#define TSS_E_INVALID_OBJECT_INITFLAG   TSS_E_INVALID_OBJECT_INIT_FLAG
+ 
+//
+// MessageId: TSS_E_NO_PCRS_SET
+//
+// MessageText:
+//
+// No PCR register are selected or set.
+//
+#define TSS_E_NO_PCRS_SET    (UINT32)(TSS_E_BASE + 0x10DL)
+
+//
+// MessageId: TSS_E_KEY_NOT_LOADED
+//
+// MessageText:
+//
+// The addressed key is currently not loaded.
+//
+#define TSS_E_KEY_NOT_LOADED    (UINT32)(TSS_E_BASE + 0x10EL)
+ 
+//
+// MessageId: TSS_E_KEY_NOT_SET
+//
+// MessageText:
+//
+// No key information is currently available.
+//
+#define TSS_E_KEY_NOT_SET    (UINT32)(TSS_E_BASE + 0x10FL)
+      
+//
+// MessageId: TSS_E_VALIDATION_FAILED
+//
+// MessageText:
+//
+// Internal validation of data failed.
+//
+#define TSS_E_VALIDATION_FAILED   (UINT32)(TSS_E_BASE + 0x110L)
+
+//
+// MessageId: TSS_E_TSP_AUTHREQUIRED
+//
+// MessageText:
+//
+// Authorization is required.
+//
+#define TSS_E_TSP_AUTHREQUIRED   (UINT32)(TSS_E_BASE + 0x111L)
+
+//
+// MessageId: TSS_E_TSP_AUTH2REQUIRED
+//
+// MessageText:
+//
+// Multiple authorization is required.
+//
+#define TSS_E_TSP_AUTH2REQUIRED   (UINT32)(TSS_E_BASE + 0x112L)
+
+//
+// MessageId: TSS_E_TSP_AUTHFAIL
+//
+// MessageText:
+//
+// Authorization failed.
+//
+#define TSS_E_TSP_AUTHFAIL    (UINT32)(TSS_E_BASE + 0x113L)
+
+//
+// MessageId: TSS_E_TSP_AUTH2FAIL
+//
+// MessageText:
+//
+// Multiple authorization failed.
+//
+#define TSS_E_TSP_AUTH2FAIL    (UINT32)(TSS_E_BASE + 0x114L)
+ 
+//
+// MessageId: TSS_E_KEY_NO_MIGRATION_POLICY
+//
+// MessageText:
+//
+// There's no migration policy object set for the addressed key.
+//
+#define TSS_E_KEY_NO_MIGRATION_POLICY  (UINT32)(TSS_E_BASE + 0x115L) 
+
+//
+// MessageId: TSS_E_POLICY_NO_SECRET
+//
+// MessageText:
+//
+// No secret information is currently available for the addressed policy object.
+//
+#define TSS_E_POLICY_NO_SECRET   (UINT32)(TSS_E_BASE + 0x116L)
+
+//
+// MessageId: TSS_E_INVALID_OBJ_ACCESS
+//
+// MessageText:
+//
+// The operation failed due to an invalid object status.
+//
+#define TSS_E_INVALID_OBJ_ACCESS   (UINT32)(TSS_E_BASE + 0x117L)
+
+//
+// MessageId: TSS_E_INVALID_ENCSCHEME
+//
+// MessageText:
+//
+// 
+//
+#define TSS_E_INVALID_ENCSCHEME   (UINT32)(TSS_E_BASE + 0x118L)
+
+
+//
+// MessageId: TSS_E_INVALID_SIGSCHEME
+//
+// MessageText:
+//
+// 
+//
+#define TSS_E_INVALID_SIGSCHEME   (UINT32)(TSS_E_BASE + 0x119L)
+
+//
+// MessageId: TSS_E_ENC_INVALID_LENGTH
+//
+// MessageText:
+//
+// 
+//
+#define TSS_E_ENC_INVALID_LENGTH   (UINT32)(TSS_E_BASE + 0x120L)
+
+
+//
+// MessageId: TSS_E_ENC_NO_DATA
+//
+// MessageText:
+//
+// 
+//
+#define TSS_E_ENC_NO_DATA    (UINT32)(TSS_E_BASE + 0x121L)
+
+//
+// MessageId: TSS_E_ENC_INVALID_TYPE
+//
+// MessageText:
+//
+// 
+//
+#define TSS_E_ENC_INVALID_TYPE   (UINT32)(TSS_E_BASE + 0x122L)
+
+
+//
+// MessageId: TSS_E_INVALID_KEYUSAGE
+//
+// MessageText:
+//
+// 
+//
+#define TSS_E_INVALID_KEYUSAGE   (UINT32)(TSS_E_BASE + 0x123L)
+
+//
+// MessageId: TSS_E_VERIFICATION_FAILED
+//
+// MessageText:
+//
+// 
+//
+#define TSS_E_VERIFICATION_FAILED   (UINT32)(TSS_E_BASE + 0x124L)
+
+//
+// MessageId: TSS_E_HASH_NO_IDENTIFIER
+//
+// MessageText:
+//
+// Hash algorithm identifier not set.
+//
+#define TSS_E_HASH_NO_IDENTIFIER   (UINT32)(TSS_E_BASE + 0x125L)
+
+//
+// MessageId: TSS_E_INVALID_HANDLE
+//
+// MessageText:
+//
+//  An invalid handle
+//
+#define TSS_E_INVALID_HANDLE    (UINT32)(TSS_E_BASE + 0x126L)
+
+//
+// MessageId: TSS_E_SILENT_CONTEXT
+//
+// MessageText:
+//
+//  A silent context requires user input
+//
+#define TSS_E_SILENT_CONTEXT           (UINT32)(TSS_E_BASE + 0x127L)
+
+//
+// MessageId: TSS_E_EK_CHECKSUM
+//
+// MessageText:
+//
+// TSP is instructed to verify the EK checksum and it does not verify.
+//
+#define TSS_E_EK_CHECKSUM             (UINT32)(TSS_E_BASE + 0x128L)
+
+
+//
+// MessageId: TSS_E_DELGATION_NOTSET
+//
+// MessageText:
+//
+// The Policy object does not have a delegation blob set.
+//
+#define TSS_E_DELEGATION_NOTSET      (UINT32)(TSS_E_BASE + 0x129L)
+
+//
+// MessageId: TSS_E_DELFAMILY_NOTFOUND
+//
+// MessageText:
+//
+// The specified delegation family was not found
+//
+#define TSS_E_DELFAMILY_NOTFOUND       (UINT32)(TSS_E_BASE + 0x130L)
+
+//
+// MessageId: TSS_E_DELFAMILY_ROWEXISTS
+//
+// MessageText:
+//
+// The specified delegation family table row is already in use and
+// the command flags does not allow the TSS to overwrite the existing
+// entry.
+//
+#define TSS_E_DELFAMILY_ROWEXISTS    (UINT32)(TSS_E_BASE + 0x131L)
+
+//
+// MessageId: TSS_E_VERSION_MISMATCH
+//
+// MessageText:
+//
+// The specified delegation family table row is already in use and
+// the command flags does not allow the TSS to overwrite the existing
+// entry.
+//
+#define TSS_E_VERSION_MISMATCH       (UINT32)(TSS_E_BASE + 0x132L)
+
+//
+//  MessageId: TSS_E_DAA_AR_DECRYPTION_ERROR
+//
+//  Decryption of the encrypted pseudonym has failed, due to
+//  either a wrong secret key or a wrong decryption condition.
+//
+#define TSS_E_DAA_AR_DECRYPTION_ERROR             (UINT32)(TSS_E_BASE + 0x133L)
+
+//
+//  MessageId: TSS_E_DAA_AUTHENTICATION_ERROR
+//
+//  The TPM could not be authenticated by the DAA Issuer.
+//
+#define TSS_E_DAA_AUTHENTICATION_ERROR            (UINT32)(TSS_E_BASE + 0x134L)
+
+//
+//  MessageId: TSS_E_DAA_CHALLENGE_RESPONSE_ERROR
+//
+//  DAA Challenge response error.
+//
+#define TSS_E_DAA_CHALLENGE_RESPONSE_ERROR        (UINT32)(TSS_E_BASE + 0x135L)
+
+//
+//  MessageId: TSS_E_DAA_CREDENTIAL_PROOF_ERROR
+//
+//  Verification of the credential TSS_DAA_CRED_ISSUER issued by
+//  the DAA Issuer has failed.
+//
+#define TSS_E_DAA_CREDENTIAL_PROOF_ERROR          (UINT32)(TSS_E_BASE + 0x136L)
+
+//
+//  MessageId: TSS_E_DAA_CREDENTIAL_REQUEST_PROOF_ERROR
+//
+//  Verification of the platform's credential request
+//  TSS_DAA_CREDENTIAL_REQUEST has failed.
+//
+#define TSS_E_DAA_CREDENTIAL_REQUEST_PROOF_ERROR  (UINT32)(TSS_E_BASE + 0x137L)
+
+//
+//  MessageId: TSS_E_DAA_ISSUER_KEY_ERROR
+//
+//  DAA Issuer's authentication key chain could not be verified or
+//  is not correct.
+//
+#define TSS_E_DAA_ISSUER_KEY_ERROR                (UINT32)(TSS_E_BASE + 0x138L)
+
+//
+//  MessageId: TSS_E_DAA_PSEUDONYM_ERROR
+//
+//  While verifying the pseudonym of the TPM, the private key of the
+//  TPM was found on the rogue list.
+//
+#define TSS_E_DAA_PSEUDONYM_ERROR                 (UINT32)(TSS_E_BASE + 0x139L)
+
+//
+//  MessageId: TSS_E_INVALID_RESOURCE
+//
+//  Pointer to memory wrong.
+//
+#define TSS_E_INVALID_RESOURCE                    (UINT32)(TSS_E_BASE + 0x13AL)
+
+//
+//  MessageId: TSS_E_NV_AREA_EXIST
+//
+//  The NV area referenced already exists
+//
+#define TSS_E_NV_AREA_EXIST                       (UINT32)(TSS_E_BASE + 0x13BL)
+
+//
+//  MessageId: TSS_E_NV_AREA_NOT_EXIST
+//
+//  The NV area referenced doesn't exist
+//
+#define TSS_E_NV_AREA_NOT_EXIST                   (UINT32)(TSS_E_BASE + 0x13CL)
+
+//
+//  MessageId: TSS_E_TSP_TRANS_AUTHFAIL
+//
+//  The transport session authorization failed
+//
+#define TSS_E_TSP_TRANS_AUTHFAIL                  (UINT32)(TSS_E_BASE + 0x13DL)
+
+//
+//  MessageId: TSS_E_TSP_TRANS_AUTHREQUIRED
+//
+//  Authorization for transport is required
+//
+#define TSS_E_TSP_TRANS_AUTHREQUIRED              (UINT32)(TSS_E_BASE + 0x13EL)
+
+//
+//  MessageId: TSS_E_TSP_TRANS_NOT_EXCLUSIVE
+//
+//  A command was executed outside of an exclusive transport session.
+//
+#define TSS_E_TSP_TRANS_NOTEXCLUSIVE              (UINT32)(TSS_E_BASE + 0x13FL)
+
+//
+//  MessageId: TSS_E_TSP_TRANS_FAIL
+//
+//  Generic transport protection error.
+//
+#define TSS_E_TSP_TRANS_FAIL                     (UINT32)(TSS_E_BASE + 0x140L)
+
+//
+//  MessageId: TSS_E_TSP_TRANS_NO_PUBKEY
+//
+//  A command could not be executed through a logged transport session
+//  because the command used a key and the key's public key is not
+//  known to the TSP.
+//
+#define TSS_E_TSP_TRANS_NO_PUBKEY                (UINT32)(TSS_E_BASE + 0x141L)
+
+//
+//  MessageId: TSS_E_NO_ACTIVE_COUNTER
+//
+//  The TPM active counter has not been set yet.
+//
+#define TSS_E_NO_ACTIVE_COUNTER                  (UINT32)(TSS_E_BASE + 0x142L)
+
+
+#endif // __TSS_ERROR_H__
diff --git a/src/include/tss/tss_error_basics.h b/src/include/tss/tss_error_basics.h
index b9e965c..0ffa51c 100644
--- a/src/include/tss/tss_error_basics.h
+++ b/src/include/tss/tss_error_basics.h
@@ -1,59 +1,59 @@
-/*++
-
-Basic defines for TSS error return codes
- 
---*/
-
-#ifndef __TSS_ERROR_BASICS_H__
-#define __TSS_ERROR_BASICS_H__
-
-
-//
-// definitions for the various TSS-SW layers
-//
-#ifndef TSS_LAYER_TPM
-#define TSS_LAYER_TPM   0x0000L     // definition for TPM layer
-#endif // TSS_LAYER_TPM
-
-#define TSS_LAYER_TDDL   0x1000L     // definition for TDDL layer
-#define TSS_LAYER_TCS   0x2000L     // definition for TCS layer
-
-#ifndef TSS_LAYER_TSP
-#define TSS_LAYER_TSP   0x3000L     // definition for TSP layer
-#endif // TSS_LAYER_TSP
-
-
-//
-// definitions for the start points of layer specific error codes
-//
-#ifndef TSS_COMMON_OFFSET
-#define TSS_COMMON_OFFSET   0x000L     
-#endif // TSS_COMMON_OFFSET
-
-#define TSS_TDDL_OFFSET    0x080L     
-#define TSS_TCSI_OFFSET    0x0C0L     
-
-#ifndef TSS_TSPI_OFFSET
-#define TSS_TSPI_OFFSET    0x100L     
-#endif // TSS_TSPI_OFFSET
-
-#ifndef TSS_VENDOR_OFFSET
-#define TSS_VENDOR_OFFSET   0x800L       
-#endif // TSS_VENDOR_OFFSET
- 
-// do not exceed TSS_MAX_ERROR for vendor specific code values:               
-#ifndef TSS_MAX_ERROR              
-#define TSS_MAX_ERROR    0xFFFL 
-#endif // TSS_MAX_ERROR
-
-
-/* Macros for the construction and interpretation of error codes */
-#define TPM_ERROR(code)        (code)
-#define TDDL_ERROR(code)       ((code) ? (TSS_LAYER_TDDL | (code)) : (code))
-#define TCS_ERROR(code)        ((code) ? (TSS_LAYER_TCS | (code)) : (code))
-#define TSP_ERROR(code)        ((code) ? (TSS_LAYER_TSP | (code)) : (code))
-#define ERROR_LAYER(error)     ((error) & 0xf000)
-#define ERROR_CODE(error)      ((error) & 0x0fff)
-
-#endif // __TSS_ERROR_BASICS_H__
-
+/*++
+
+Basic defines for TSS error return codes
+ 
+--*/
+
+#ifndef __TSS_ERROR_BASICS_H__
+#define __TSS_ERROR_BASICS_H__
+
+
+//
+// definitions for the various TSS-SW layers
+//
+#ifndef TSS_LAYER_TPM
+#define TSS_LAYER_TPM   0x0000L     // definition for TPM layer
+#endif // TSS_LAYER_TPM
+
+#define TSS_LAYER_TDDL   0x1000L     // definition for TDDL layer
+#define TSS_LAYER_TCS   0x2000L     // definition for TCS layer
+
+#ifndef TSS_LAYER_TSP
+#define TSS_LAYER_TSP   0x3000L     // definition for TSP layer
+#endif // TSS_LAYER_TSP
+
+
+//
+// definitions for the start points of layer specific error codes
+//
+#ifndef TSS_COMMON_OFFSET
+#define TSS_COMMON_OFFSET   0x000L     
+#endif // TSS_COMMON_OFFSET
+
+#define TSS_TDDL_OFFSET    0x080L     
+#define TSS_TCSI_OFFSET    0x0C0L     
+
+#ifndef TSS_TSPI_OFFSET
+#define TSS_TSPI_OFFSET    0x100L     
+#endif // TSS_TSPI_OFFSET
+
+#ifndef TSS_VENDOR_OFFSET
+#define TSS_VENDOR_OFFSET   0x800L       
+#endif // TSS_VENDOR_OFFSET
+ 
+// do not exceed TSS_MAX_ERROR for vendor specific code values:               
+#ifndef TSS_MAX_ERROR              
+#define TSS_MAX_ERROR    0xFFFL 
+#endif // TSS_MAX_ERROR
+
+
+/* Macros for the construction and interpretation of error codes */
+#define TPM_ERROR(code)        (code)
+#define TDDL_ERROR(code)       ((code) ? (TSS_LAYER_TDDL | (code)) : (code))
+#define TCS_ERROR(code)        ((code) ? (TSS_LAYER_TCS | (code)) : (code))
+#define TSP_ERROR(code)        ((code) ? (TSS_LAYER_TSP | (code)) : (code))
+#define ERROR_LAYER(error)     ((error) & 0xf000)
+#define ERROR_CODE(error)      ((error) & 0x0fff)
+
+#endif // __TSS_ERROR_BASICS_H__
+
diff --git a/src/include/tss/tss_structs.h b/src/include/tss/tss_structs.h
index fa4c4b3..8b769e4 100644
--- a/src/include/tss/tss_structs.h
+++ b/src/include/tss/tss_structs.h
@@ -1,653 +1,653 @@
-/*++
-
-TSS structures for TSS
-
-*/
-
-#ifndef __TSS_STRUCTS_H__
-#define __TSS_STRUCTS_H__
-
-#include <tss/platform.h>
-#include <tss/tss_typedef.h>
-#include <tss/tpm.h>
-
-typedef struct tdTSS_VERSION 
-{
-    BYTE   bMajor;
-    BYTE   bMinor;
-    BYTE   bRevMajor;
-    BYTE   bRevMinor;
-} TSS_VERSION;
-
-typedef struct tdTSS_PCR_EVENT 
-{
-    TSS_VERSION   versionInfo;
-    UINT32        ulPcrIndex;
-    TSS_EVENTTYPE eventType;
-    UINT32        ulPcrValueLength;
-#ifdef __midl
-    [size_is(ulPcrValueLength)] 
-#endif
-    BYTE*         rgbPcrValue;
-    UINT32        ulEventLength;
-#ifdef __midl
-    [size_is(ulEventLength)] 
-#endif 
-    BYTE*         rgbEvent;
-} TSS_PCR_EVENT;
-
-
-typedef struct tdTSS_EVENT_CERT
-{
-    TSS_VERSION       versionInfo;
-    UINT32    ulCertificateHashLength;
-#ifdef __midl
-    [size_is(ulCertificateHashLength)] 
-#endif
-    BYTE*     rgbCertificateHash;
-    UINT32    ulEntityDigestLength;
-#ifdef __midl
-    [size_is(ulEntityDigestLength)] 
-#endif
-    BYTE*     rgbentityDigest;
-    TSS_BOOL  fDigestChecked;
-    TSS_BOOL  fDigestVerified;
-    UINT32    ulIssuerLength;
-#ifdef __midl
-    [size_is(ulIssuerLength)]
-#endif
-    BYTE*     rgbIssuer;
-} TSS_EVENT_CERT;
-
-typedef struct tdTSS_UUID 
-{
-    UINT32  ulTimeLow;
-    UINT16  usTimeMid;
-    UINT16  usTimeHigh;
-    BYTE   bClockSeqHigh;
-    BYTE   bClockSeqLow;
-    BYTE   rgbNode[6];
-} TSS_UUID;
-
-typedef struct tdTSS_KM_KEYINFO 
-{
-    TSS_VERSION  versionInfo;
-    TSS_UUID     keyUUID;
-    TSS_UUID     parentKeyUUID;
-    BYTE         bAuthDataUsage;   // whether auth is needed to load child keys
-    TSS_BOOL     fIsLoaded;           // TRUE: actually loaded in TPM
-    UINT32       ulVendorDataLength;  // may be 0
-#ifdef __midl
-    [size_is(ulVendorDataLength)]
-#endif
-    BYTE        *rgbVendorData;       // may be NULL
-} TSS_KM_KEYINFO;
-
-
-typedef struct tdTSS_KM_KEYINFO2
-{
-    TSS_VERSION  versionInfo;
-    TSS_UUID     keyUUID;
-    TSS_UUID     parentKeyUUID;
-    BYTE         bAuthDataUsage;   // whether auth is needed to load child keys
-    TSS_FLAG     persistentStorageType;
-    TSS_FLAG     persistentStorageTypeParent;
-    TSS_BOOL     fIsLoaded;           // TRUE: actually loaded in TPM
-    UINT32       ulVendorDataLength;  // may be 0
-#ifdef __midl
-    [size_is(ulVendorDataLength)]
-#endif
-    BYTE        *rgbVendorData;       // may be NULL
-} TSS_KM_KEYINFO2;
-
-
-typedef struct tdTSS_NONCE
-{
-    BYTE  nonce[TPM_SHA1BASED_NONCE_LEN];
-} TSS_NONCE;
-
-
-typedef struct tdTSS_VALIDATION
-{ 
-    TSS_VERSION  versionInfo;
-    UINT32       ulExternalDataLength;
-#ifdef __midl
-    [size_is(ulExternalDataLength)]
-#endif
-    BYTE*        rgbExternalData;
-    UINT32       ulDataLength;
-#ifdef __midl
-    [size_is(ulDataLength)]
-#endif
-    BYTE*     rgbData;
-    UINT32    ulValidationDataLength;
-#ifdef __midl
-    [size_is(ulValidationDataLength)]
-#endif
-    BYTE*     rgbValidationData;
-} TSS_VALIDATION;
-
-
-typedef struct tdTSS_CALLBACK
-{
-    PVOID            callback;
-    PVOID            appData;
-    TSS_ALGORITHM_ID alg;
-} TSS_CALLBACK;
-
-
-typedef struct tdTSS_DAA_PK
-{
-    TSS_VERSION versionInfo;
-    UINT32      modulusLength;
-#ifdef __midl
-    [size_is(modulusLength)] 
-#endif
-    BYTE*       modulus;
-    UINT32      capitalSLength;
-#ifdef __midl
-    [size_is(capitalSLength)] 
-#endif
-    BYTE*       capitalS;
-    UINT32      capitalZLength;
-#ifdef __midl
-    [size_is(capitalZLength)] 
-#endif
-    BYTE*       capitalZ;
-    UINT32      capitalR0Length;
-#ifdef __midl
-    [size_is(capitalR0Length)] 
-#endif
-    BYTE*       capitalR0;
-    UINT32      capitalR1Length;
-#ifdef __midl
-    [size_is(capitalR1Length)] 
-#endif
-    BYTE*       capitalR1;
-    UINT32      gammaLength;
-#ifdef __midl
-    [size_is(gammaLength)] 
-#endif
-    BYTE*       gamma;
-    UINT32      capitalGammaLength;
-#ifdef __midl
-    [size_is(capitalGammaLength)] 
-#endif
-    BYTE*       capitalGamma;
-    UINT32      rhoLength;
-#ifdef __midl
-    [size_is(rhoLength)] 
-#endif
-    BYTE*       rho;
-    UINT32      capitalYLength;         // Length of first dimenstion
-    UINT32      capitalYLength2;        // Length of second dimension
-#ifdef __midl
-    [size_is(capitalYLength,capitalYLength2)] 
-#endif
-    BYTE**      capitalY;
-    UINT32      capitalYPlatformLength;
-    UINT32      issuerBaseNameLength;
-#ifdef __midl
-    [size_is(issuerBaseName)] 
-#endif
-    BYTE*       issuerBaseName;
-    UINT32      numPlatformAttributes;
-    UINT32      numIssuerAttributes;
-} TSS_DAA_PK;
-
-typedef struct tdTSS_DAA_PK_PROOF
-{
-    TSS_VERSION versionInfo;
-    UINT32      challengeLength;
-#ifdef __midl
-    [size_is(challengeLength)] 
-#endif
-    BYTE*       challenge;
-    UINT32      responseLength;         // Length of first dimension
-    UINT32      responseLength2;        // Length of second dimension
-#ifdef __midl
-    [size_is(responseLength,responseLength2)] 
-#endif
-    BYTE**      response;
-} TSS_DAA_PK_PROOF;
-
-typedef struct tdTSS_DAA_SK
-{
-    TSS_VERSION versionInfo;
-    UINT32      productPQprimeLength;
-#ifdef __midl
-    [size_is(productPQprimeLength)] 
-#endif
-    BYTE*       productPQprime;
-} TSS_DAA_SK;
-
-
-typedef struct tdTSS_DAA_KEY_PAIR
-{
-    TSS_VERSION versionInfo;
-    TSS_DAA_SK  secretKey;
-    TSS_DAA_PK  publicKey;
-} TSS_DAA_KEY_PAIR;
-
-typedef struct tdTSS_DAA_AR_PK
-{
-    TSS_VERSION versionInfo;
-    UINT32      etaLength;
-#ifdef __midl
-    [size_is(etaLength)] 
-#endif
-    BYTE*       eta;
-    UINT32      lambda1Length;
-#ifdef __midl
-    [size_is(lambda1Length)] 
-#endif
-    BYTE*       lambda1;
-    UINT32      lambda2Length;
-#ifdef __midl
-    [size_is(lambda2Length)] 
-#endif
-    BYTE*       lambda2;
-    UINT32      lambda3Length;
-#ifdef __midl
-    [size_is(lambda3Length)] 
-#endif
-    BYTE*       lambda3;
-} TSS_DAA_AR_PK;
-
-typedef struct tdTSS_DAA_AR_SK
-{
-    TSS_VERSION versionInfo;
-    UINT32      x0Length;
-#ifdef __midl
-    [size_is(x0Length)] 
-#endif
-    BYTE*       x0;
-    UINT32      x1Length;
-#ifdef __midl
-    [size_is(x1Length)] 
-#endif
-    BYTE*       x1;
-    UINT32      x2Length;
-#ifdef __midl
-    [size_is(x2Length)] 
-#endif
-    BYTE*       x2;
-    UINT32      x3Length;
-#ifdef __midl
-    [size_is(x3Length)] 
-#endif
-    BYTE*       x3;
-    UINT32      x4Length;
-#ifdef __midl
-    [size_is(x4Length)] 
-#endif
-    BYTE*       x4;
-    UINT32      x5Length;
-#ifdef __midl
-    [size_is(x5Length)] 
-#endif
-    BYTE*       x5;
-} TSS_DAA_AR_SK;
-
-typedef struct tdTSS_DAA_AR_KEY_PAIR
-{
-    TSS_VERSION   versionInfo;
-    TSS_DAA_AR_SK secretKey;
-    TSS_DAA_AR_PK publicKey;
-} TSS_DAA_AR_KEY_PAIR;
-
-typedef struct tdTSS_DAA_CRED_ISSUER
-{
-    TSS_VERSION versionInfo;
-    UINT32      capitalALength;
-#ifdef __midl
-    [size_is(capitalALength)] 
-#endif
-    BYTE*       capitalA;
-    UINT32      eLength;
-#ifdef __midl
-    [size_is(eLength)] 
-#endif
-    BYTE*       e;
-    UINT32      vPrimePrimeLength;
-#ifdef __midl
-    [size_is(vPrimePrimeLength)] 
-#endif
-    BYTE*       vPrimePrime;
-    UINT32      attributesIssuerLength;         // Length of first dimension
-    UINT32      attributesIssuerLength2;        // Length of second dimension
-#ifdef __midl
-    [size_is(attributesIssuerLength,attributesIssuerLength2)] 
-#endif
-    BYTE**      attributesIssuer;
-    UINT32      cPrimeLength;
-#ifdef __midl
-    [size_is(cPrimeLength)] 
-#endif
-    BYTE*       cPrime;
-    UINT32      sELength;
-#ifdef __midl
-    [size_is(sELength)] 
-#endif
-    BYTE*       sE;
-} TSS_DAA_CRED_ISSUER;
-
-typedef struct tdTSS_DAA_CREDENTIAL
-{
-    TSS_VERSION versionInfo;
-    UINT32      capitalALength;
-#ifdef __midl
-    [size_is(capitalALength)] 
-#endif
-    BYTE*       capitalA;
-    UINT32      exponentLength;
-#ifdef __midl
-    [size_is(exponentLength)] 
-#endif
-    BYTE*       exponent;
-    UINT32      vBar0Length;
-#ifdef __midl
-    [size_is(vBar0Length)] 
-#endif
-    BYTE*       vBar0;
-    UINT32      vBar1Length;
-#ifdef __midl
-    [size_is(vBar1Length)] 
-#endif
-    BYTE*       vBar1;
-    UINT32      attributesLength;       // Length of first dimension
-    UINT32      attributesLength2;      // Length of second dimension
-#ifdef __midl
-    [size_is(attributesLength,attributesLength2)] 
-#endif
-    BYTE**      attributes;
-    TSS_DAA_PK  issuerPK;
-    UINT32      tpmSpecificEncLength;
-#ifdef __midl
-    [size_is(tpmSpecificEncLength)]
-#endif
-    BYTE*       tpmSpecificEnc;
-    UINT32      daaCounter;
-} TSS_DAA_CREDENTIAL;
-
-typedef struct tdTSS_DAA_ATTRIB_COMMIT
-{
-    TSS_VERSION versionInfo;
-    UINT32      betaLength;
-#ifdef __midl
-    [size_is(betaLength)]
-#endif
-    BYTE*       beta;
-    UINT32      sMuLength;
-#ifdef __midl
-    [size_is(sMuLength)]
-#endif
-    BYTE*       sMu;
-} TSS_DAA_ATTRIB_COMMIT;
-
-typedef struct tdTSS_DAA_CREDENTIAL_REQUEST
-{
-    TSS_VERSION versionInfo;
-    UINT32      capitalULength;
-#ifdef __midl
-    [size_is(capitalULength)]
-#endif
-    BYTE*       capitalU;
-    UINT32      capitalNiLength;
-#ifdef __midl
-    [size_is(capitalNiLength)]
-#endif
-    BYTE*       capitalNi;
-    UINT32      authenticationProofLength;
-#ifdef __midl
-    [size_is(authenticationProofLength)]
-#endif
-    BYTE*       authenticationProof;
-    UINT32      challengeLength;
-#ifdef __midl
-    [size_is(challengeLength)]
-#endif
-    BYTE*       challenge;
-    UINT32      nonceTpmLength;
-#ifdef __midl
-    [size_is(nonceTpmLength)]
-#endif
-    BYTE*       nonceTpm;
-    UINT32      noncePlatformLength;
-#ifdef __midl
-    [size_is(noncePlatformLength)]
-#endif
-    BYTE*       noncePlatform;
-    UINT32      sF0Length;
-#ifdef __midl
-    [size_is(sF0Length)]
-#endif
-    BYTE*       sF0;
-    UINT32      sF1Length;
-#ifdef __midl
-    [size_is(sF1Length)]
-#endif
-    BYTE*       sF1;
-    UINT32      sVprimeLength;
-#ifdef __midl
-    [size_is(sVprimeLength)]
-#endif
-    BYTE*       sVprime;
-    UINT32      sVtildePrimeLength;
-#ifdef __midl
-    [size_is(sVtildePrimeLength)]
-#endif
-    BYTE*       sVtildePrime;
-    UINT32      sALength;       // Length of first dimension
-    UINT32      sALength2;      // Length of second dimension
-#ifdef __midl
-    [size_is(sALength,sALength2)]
-#endif
-    BYTE**      sA;
-    UINT32      attributeCommitmentsLength;
-    TSS_DAA_ATTRIB_COMMIT* attributeCommitments;
-} TSS_DAA_CREDENTIAL_REQUEST;
-
-typedef struct tdTSS_DAA_SELECTED_ATTRIB
-{
-    TSS_VERSION versionInfo;
-    UINT32      indicesListLength;
-#ifdef __midl
-    [size_is(indicesListLength)]
-#endif
-    TSS_BOOL*   indicesList;
-} TSS_DAA_SELECTED_ATTRIB;
-
-typedef struct tdTSS_DAA_PSEUDONYM
-{
-    TSS_VERSION versionInfo;
-    TSS_FLAG    payloadFlag;
-    UINT32      payloadLength;
-#ifdef __midl
-    [size_is(payloadLength)]
-#endif
-    BYTE*       payload;
-} TSS_DAA_PSEUDONYM;
-
-typedef struct tdTSS_DAA_PSEUDONYM_PLAIN
-{
-    TSS_VERSION versionInfo;
-    UINT32      capitalNvLength;
-#ifdef __midl
-    [size_is(capitalNvLength)]
-#endif
-    BYTE*       capitalNv;
-} TSS_DAA_PSEUDONYM_PLAIN;
-
-typedef struct tdTSS_DAA_PSEUDONYM_ENCRYPTED
-{
-    TSS_VERSION versionInfo;
-    UINT32      delta1Length;
-#ifdef __midl
-    [size_is(delta1Length)]
-#endif
-    BYTE*       delta1;
-    UINT32      delta2Length;
-#ifdef __midl
-    [size_is(delta2Length)]
-#endif
-    BYTE*       delta2;
-    UINT32      delta3Length;
-#ifdef __midl
-    [size_is(delta3Length)]
-#endif
-    BYTE*       delta3;
-    UINT32      delta4Length;
-#ifdef __midl
-    [size_is(delta4Length)]
-#endif
-    BYTE*       delta4;
-    UINT32      sTauLength;
-#ifdef __midl
-    [size_is(sTauLength)]
-#endif
-    BYTE*       sTau;
-} TSS_DAA_PSEUDONYM_ENCRYPTED;
-
-typedef struct tdTSS_DAA_SIGN_CALLBACK
-{
-    TSS_VERSION versionInfo;
-    TSS_HHASH   challenge;
-    TSS_FLAG    payloadFlag;
-    UINT32      payloadLength;
-#ifdef __midl
-    [size_is(payloadLength)]
-#endif
-    BYTE*       payload;
-} TSS_DAA_SIGN_CALLBACK;
-
-typedef struct tdTSS_DAA_SIGNATURE
-{
-    TSS_VERSION            versionInfo;
-    UINT32                 zetaLength;
-#ifdef __midl
-    [size_is(zetaLength)]
-#endif
-    BYTE*                  zeta;
-    UINT32                 capitalTLength;
-#ifdef __midl
-    [size_is(capitalTLength)]
-#endif
-    BYTE*                  capitalT;
-    UINT32                 challengeLength;
-#ifdef __midl
-    [size_is(challengeLength)]
-#endif
-    BYTE*                  challenge;
-    UINT32                 nonceTpmLength;
-#ifdef __midl
-    [size_is(nonceTpmLength)]
-#endif
-    BYTE*                  nonceTpm;
-    UINT32                 sVLength;
-#ifdef __midl
-    [size_is(sVLength)]
-#endif
-    BYTE*                  sV;
-    UINT32                 sF0Length;
-#ifdef __midl
-    [size_is(sF0Length)]
-#endif
-    BYTE*                  sF0;
-    UINT32                 sF1Length;
-#ifdef __midl
-    [size_is(sF1Length)]
-#endif
-    BYTE*                  sF1;
-    UINT32                 sELength;
-#ifdef __midl
-    [size_is(sELength)]
-#endif
-    BYTE*                  sE;
-    UINT32                 sALength;    // Length of first dimension
-    UINT32                 sALength2;   // Length of second dimension
-#ifdef __midl
-    [size_is(sALength,sALength2)]
-#endif
-    BYTE**                 sA;
-    UINT32                 attributeCommitmentsLength;
-#ifdef __midl
-    [size_is(attributeCommitmentsLength)]
-#endif
-    TSS_DAA_ATTRIB_COMMIT* attributeCommitments;
-    TSS_DAA_PSEUDONYM      signedPseudonym;
-    TSS_DAA_SIGN_CALLBACK  callbackResult;
-} TSS_DAA_SIGNATURE;
-
-typedef struct tdTSS_DAA_IDENTITY_PROOF
-{
-    TSS_VERSION versionInfo;
-    UINT32      endorsementLength;
-#ifdef __midl
-    [size_is(endorsementLength)]
-#endif
-    BYTE*       endorsementCredential;
-    UINT32      platformLength;
-#ifdef __midl
-    [size_is(platformLength)]
-#endif
-    BYTE*       platform;
-    UINT32      conformanceLength;
-#ifdef __midl
-    [size_is(conformanceLength)]
-#endif
-    BYTE*       conformance;
-} TSS_DAA_IDENTITY_PROOF;
-
-
-////////////////////////////////////////////////////////////////////
-
-typedef UINT32 TSS_FAMILY_ID;
-typedef BYTE   TSS_DELEGATION_LABEL;
-// Values are TSS_DELEGATIONTYPE_KEY or TSS_DELEGATIONTYPE_OWNER
-typedef UINT32 TSS_DELEGATION_TYPE;
-
-typedef struct tdTSS_PCR_INFO_SHORT
-{
-    UINT32               sizeOfSelect;
-#ifdef __midl
-    [size_is(sizeOfSelect)]
-#endif
-    BYTE                *selection;
-    BYTE                 localityAtRelease;
-    UINT32               sizeOfDigestAtRelease;
-#ifdef __midl
-    [size_is(sizeOfDigestAtRelease)]
-#endif
-    BYTE                *digestAtRelease;
-} TSS_PCR_INFO_SHORT;
-
-typedef struct tdTSS_FAMILY_TABLE_ENTRY
-{
-    TSS_FAMILY_ID        familyID;
-    TSS_DELEGATION_LABEL label;
-    UINT32               verificationCount;
-    TSS_BOOL             enabled;
-    TSS_BOOL             locked;
-} TSS_FAMILY_TABLE_ENTRY;
-
-typedef struct tdTSS_DELEGATION_TABLE_ENTRY
-{
-    UINT32               tableIndex;
-    TSS_DELEGATION_LABEL label;
-    TSS_PCR_INFO_SHORT   pcrInfo;
-    UINT32               per1;
-    UINT32               per2;
-    TSS_FAMILY_ID        familyID;
-    UINT32               verificationCount;
-} TSS_DELEGATION_TABLE_ENTRY;
-
-typedef struct tdTSS_PLATFORM_CLASS
-{
-    UINT32 platformClassSimpleIdentifier;
-    UINT32 platformClassURISize;
-    BYTE*  pPlatformClassURI;
-} TSS_PLATFORM_CLASS;
-
-#endif // __TSS_STRUCTS_H__
-
+/*++
+
+TSS structures for TSS
+
+*/
+
+#ifndef __TSS_STRUCTS_H__
+#define __TSS_STRUCTS_H__
+
+#include <tss/platform.h>
+#include <tss/tss_typedef.h>
+#include <tss/tpm.h>
+
+typedef struct tdTSS_VERSION 
+{
+    BYTE   bMajor;
+    BYTE   bMinor;
+    BYTE   bRevMajor;
+    BYTE   bRevMinor;
+} TSS_VERSION;
+
+typedef struct tdTSS_PCR_EVENT 
+{
+    TSS_VERSION   versionInfo;
+    UINT32        ulPcrIndex;
+    TSS_EVENTTYPE eventType;
+    UINT32        ulPcrValueLength;
+#ifdef __midl
+    [size_is(ulPcrValueLength)] 
+#endif
+    BYTE*         rgbPcrValue;
+    UINT32        ulEventLength;
+#ifdef __midl
+    [size_is(ulEventLength)] 
+#endif 
+    BYTE*         rgbEvent;
+} TSS_PCR_EVENT;
+
+
+typedef struct tdTSS_EVENT_CERT
+{
+    TSS_VERSION       versionInfo;
+    UINT32    ulCertificateHashLength;
+#ifdef __midl
+    [size_is(ulCertificateHashLength)] 
+#endif
+    BYTE*     rgbCertificateHash;
+    UINT32    ulEntityDigestLength;
+#ifdef __midl
+    [size_is(ulEntityDigestLength)] 
+#endif
+    BYTE*     rgbentityDigest;
+    TSS_BOOL  fDigestChecked;
+    TSS_BOOL  fDigestVerified;
+    UINT32    ulIssuerLength;
+#ifdef __midl
+    [size_is(ulIssuerLength)]
+#endif
+    BYTE*     rgbIssuer;
+} TSS_EVENT_CERT;
+
+typedef struct tdTSS_UUID 
+{
+    UINT32  ulTimeLow;
+    UINT16  usTimeMid;
+    UINT16  usTimeHigh;
+    BYTE   bClockSeqHigh;
+    BYTE   bClockSeqLow;
+    BYTE   rgbNode[6];
+} TSS_UUID;
+
+typedef struct tdTSS_KM_KEYINFO 
+{
+    TSS_VERSION  versionInfo;
+    TSS_UUID     keyUUID;
+    TSS_UUID     parentKeyUUID;
+    BYTE         bAuthDataUsage;   // whether auth is needed to load child keys
+    TSS_BOOL     fIsLoaded;           // TRUE: actually loaded in TPM
+    UINT32       ulVendorDataLength;  // may be 0
+#ifdef __midl
+    [size_is(ulVendorDataLength)]
+#endif
+    BYTE        *rgbVendorData;       // may be NULL
+} TSS_KM_KEYINFO;
+
+
+typedef struct tdTSS_KM_KEYINFO2
+{
+    TSS_VERSION  versionInfo;
+    TSS_UUID     keyUUID;
+    TSS_UUID     parentKeyUUID;
+    BYTE         bAuthDataUsage;   // whether auth is needed to load child keys
+    TSS_FLAG     persistentStorageType;
+    TSS_FLAG     persistentStorageTypeParent;
+    TSS_BOOL     fIsLoaded;           // TRUE: actually loaded in TPM
+    UINT32       ulVendorDataLength;  // may be 0
+#ifdef __midl
+    [size_is(ulVendorDataLength)]
+#endif
+    BYTE        *rgbVendorData;       // may be NULL
+} TSS_KM_KEYINFO2;
+
+
+typedef struct tdTSS_NONCE
+{
+    BYTE  nonce[TPM_SHA1BASED_NONCE_LEN];
+} TSS_NONCE;
+
+
+typedef struct tdTSS_VALIDATION
+{ 
+    TSS_VERSION  versionInfo;
+    UINT32       ulExternalDataLength;
+#ifdef __midl
+    [size_is(ulExternalDataLength)]
+#endif
+    BYTE*        rgbExternalData;
+    UINT32       ulDataLength;
+#ifdef __midl
+    [size_is(ulDataLength)]
+#endif
+    BYTE*     rgbData;
+    UINT32    ulValidationDataLength;
+#ifdef __midl
+    [size_is(ulValidationDataLength)]
+#endif
+    BYTE*     rgbValidationData;
+} TSS_VALIDATION;
+
+
+typedef struct tdTSS_CALLBACK
+{
+    PVOID            callback;
+    PVOID            appData;
+    TSS_ALGORITHM_ID alg;
+} TSS_CALLBACK;
+
+
+typedef struct tdTSS_DAA_PK
+{
+    TSS_VERSION versionInfo;
+    UINT32      modulusLength;
+#ifdef __midl
+    [size_is(modulusLength)] 
+#endif
+    BYTE*       modulus;
+    UINT32      capitalSLength;
+#ifdef __midl
+    [size_is(capitalSLength)] 
+#endif
+    BYTE*       capitalS;
+    UINT32      capitalZLength;
+#ifdef __midl
+    [size_is(capitalZLength)] 
+#endif
+    BYTE*       capitalZ;
+    UINT32      capitalR0Length;
+#ifdef __midl
+    [size_is(capitalR0Length)] 
+#endif
+    BYTE*       capitalR0;
+    UINT32      capitalR1Length;
+#ifdef __midl
+    [size_is(capitalR1Length)] 
+#endif
+    BYTE*       capitalR1;
+    UINT32      gammaLength;
+#ifdef __midl
+    [size_is(gammaLength)] 
+#endif
+    BYTE*       gamma;
+    UINT32      capitalGammaLength;
+#ifdef __midl
+    [size_is(capitalGammaLength)] 
+#endif
+    BYTE*       capitalGamma;
+    UINT32      rhoLength;
+#ifdef __midl
+    [size_is(rhoLength)] 
+#endif
+    BYTE*       rho;
+    UINT32      capitalYLength;         // Length of first dimenstion
+    UINT32      capitalYLength2;        // Length of second dimension
+#ifdef __midl
+    [size_is(capitalYLength,capitalYLength2)] 
+#endif
+    BYTE**      capitalY;
+    UINT32      capitalYPlatformLength;
+    UINT32      issuerBaseNameLength;
+#ifdef __midl
+    [size_is(issuerBaseName)] 
+#endif
+    BYTE*       issuerBaseName;
+    UINT32      numPlatformAttributes;
+    UINT32      numIssuerAttributes;
+} TSS_DAA_PK;
+
+typedef struct tdTSS_DAA_PK_PROOF
+{
+    TSS_VERSION versionInfo;
+    UINT32      challengeLength;
+#ifdef __midl
+    [size_is(challengeLength)] 
+#endif
+    BYTE*       challenge;
+    UINT32      responseLength;         // Length of first dimension
+    UINT32      responseLength2;        // Length of second dimension
+#ifdef __midl
+    [size_is(responseLength,responseLength2)] 
+#endif
+    BYTE**      response;
+} TSS_DAA_PK_PROOF;
+
+typedef struct tdTSS_DAA_SK
+{
+    TSS_VERSION versionInfo;
+    UINT32      productPQprimeLength;
+#ifdef __midl
+    [size_is(productPQprimeLength)] 
+#endif
+    BYTE*       productPQprime;
+} TSS_DAA_SK;
+
+
+typedef struct tdTSS_DAA_KEY_PAIR
+{
+    TSS_VERSION versionInfo;
+    TSS_DAA_SK  secretKey;
+    TSS_DAA_PK  publicKey;
+} TSS_DAA_KEY_PAIR;
+
+typedef struct tdTSS_DAA_AR_PK
+{
+    TSS_VERSION versionInfo;
+    UINT32      etaLength;
+#ifdef __midl
+    [size_is(etaLength)] 
+#endif
+    BYTE*       eta;
+    UINT32      lambda1Length;
+#ifdef __midl
+    [size_is(lambda1Length)] 
+#endif
+    BYTE*       lambda1;
+    UINT32      lambda2Length;
+#ifdef __midl
+    [size_is(lambda2Length)] 
+#endif
+    BYTE*       lambda2;
+    UINT32      lambda3Length;
+#ifdef __midl
+    [size_is(lambda3Length)] 
+#endif
+    BYTE*       lambda3;
+} TSS_DAA_AR_PK;
+
+typedef struct tdTSS_DAA_AR_SK
+{
+    TSS_VERSION versionInfo;
+    UINT32      x0Length;
+#ifdef __midl
+    [size_is(x0Length)] 
+#endif
+    BYTE*       x0;
+    UINT32      x1Length;
+#ifdef __midl
+    [size_is(x1Length)] 
+#endif
+    BYTE*       x1;
+    UINT32      x2Length;
+#ifdef __midl
+    [size_is(x2Length)] 
+#endif
+    BYTE*       x2;
+    UINT32      x3Length;
+#ifdef __midl
+    [size_is(x3Length)] 
+#endif
+    BYTE*       x3;
+    UINT32      x4Length;
+#ifdef __midl
+    [size_is(x4Length)] 
+#endif
+    BYTE*       x4;
+    UINT32      x5Length;
+#ifdef __midl
+    [size_is(x5Length)] 
+#endif
+    BYTE*       x5;
+} TSS_DAA_AR_SK;
+
+typedef struct tdTSS_DAA_AR_KEY_PAIR
+{
+    TSS_VERSION   versionInfo;
+    TSS_DAA_AR_SK secretKey;
+    TSS_DAA_AR_PK publicKey;
+} TSS_DAA_AR_KEY_PAIR;
+
+typedef struct tdTSS_DAA_CRED_ISSUER
+{
+    TSS_VERSION versionInfo;
+    UINT32      capitalALength;
+#ifdef __midl
+    [size_is(capitalALength)] 
+#endif
+    BYTE*       capitalA;
+    UINT32      eLength;
+#ifdef __midl
+    [size_is(eLength)] 
+#endif
+    BYTE*       e;
+    UINT32      vPrimePrimeLength;
+#ifdef __midl
+    [size_is(vPrimePrimeLength)] 
+#endif
+    BYTE*       vPrimePrime;
+    UINT32      attributesIssuerLength;         // Length of first dimension
+    UINT32      attributesIssuerLength2;        // Length of second dimension
+#ifdef __midl
+    [size_is(attributesIssuerLength,attributesIssuerLength2)] 
+#endif
+    BYTE**      attributesIssuer;
+    UINT32      cPrimeLength;
+#ifdef __midl
+    [size_is(cPrimeLength)] 
+#endif
+    BYTE*       cPrime;
+    UINT32      sELength;
+#ifdef __midl
+    [size_is(sELength)] 
+#endif
+    BYTE*       sE;
+} TSS_DAA_CRED_ISSUER;
+
+typedef struct tdTSS_DAA_CREDENTIAL
+{
+    TSS_VERSION versionInfo;
+    UINT32      capitalALength;
+#ifdef __midl
+    [size_is(capitalALength)] 
+#endif
+    BYTE*       capitalA;
+    UINT32      exponentLength;
+#ifdef __midl
+    [size_is(exponentLength)] 
+#endif
+    BYTE*       exponent;
+    UINT32      vBar0Length;
+#ifdef __midl
+    [size_is(vBar0Length)] 
+#endif
+    BYTE*       vBar0;
+    UINT32      vBar1Length;
+#ifdef __midl
+    [size_is(vBar1Length)] 
+#endif
+    BYTE*       vBar1;
+    UINT32      attributesLength;       // Length of first dimension
+    UINT32      attributesLength2;      // Length of second dimension
+#ifdef __midl
+    [size_is(attributesLength,attributesLength2)] 
+#endif
+    BYTE**      attributes;
+    TSS_DAA_PK  issuerPK;
+    UINT32      tpmSpecificEncLength;
+#ifdef __midl
+    [size_is(tpmSpecificEncLength)]
+#endif
+    BYTE*       tpmSpecificEnc;
+    UINT32      daaCounter;
+} TSS_DAA_CREDENTIAL;
+
+typedef struct tdTSS_DAA_ATTRIB_COMMIT
+{
+    TSS_VERSION versionInfo;
+    UINT32      betaLength;
+#ifdef __midl
+    [size_is(betaLength)]
+#endif
+    BYTE*       beta;
+    UINT32      sMuLength;
+#ifdef __midl
+    [size_is(sMuLength)]
+#endif
+    BYTE*       sMu;
+} TSS_DAA_ATTRIB_COMMIT;
+
+typedef struct tdTSS_DAA_CREDENTIAL_REQUEST
+{
+    TSS_VERSION versionInfo;
+    UINT32      capitalULength;
+#ifdef __midl
+    [size_is(capitalULength)]
+#endif
+    BYTE*       capitalU;
+    UINT32      capitalNiLength;
+#ifdef __midl
+    [size_is(capitalNiLength)]
+#endif
+    BYTE*       capitalNi;
+    UINT32      authenticationProofLength;
+#ifdef __midl
+    [size_is(authenticationProofLength)]
+#endif
+    BYTE*       authenticationProof;
+    UINT32      challengeLength;
+#ifdef __midl
+    [size_is(challengeLength)]
+#endif
+    BYTE*       challenge;
+    UINT32      nonceTpmLength;
+#ifdef __midl
+    [size_is(nonceTpmLength)]
+#endif
+    BYTE*       nonceTpm;
+    UINT32      noncePlatformLength;
+#ifdef __midl
+    [size_is(noncePlatformLength)]
+#endif
+    BYTE*       noncePlatform;
+    UINT32      sF0Length;
+#ifdef __midl
+    [size_is(sF0Length)]
+#endif
+    BYTE*       sF0;
+    UINT32      sF1Length;
+#ifdef __midl
+    [size_is(sF1Length)]
+#endif
+    BYTE*       sF1;
+    UINT32      sVprimeLength;
+#ifdef __midl
+    [size_is(sVprimeLength)]
+#endif
+    BYTE*       sVprime;
+    UINT32      sVtildePrimeLength;
+#ifdef __midl
+    [size_is(sVtildePrimeLength)]
+#endif
+    BYTE*       sVtildePrime;
+    UINT32      sALength;       // Length of first dimension
+    UINT32      sALength2;      // Length of second dimension
+#ifdef __midl
+    [size_is(sALength,sALength2)]
+#endif
+    BYTE**      sA;
+    UINT32      attributeCommitmentsLength;
+    TSS_DAA_ATTRIB_COMMIT* attributeCommitments;
+} TSS_DAA_CREDENTIAL_REQUEST;
+
+typedef struct tdTSS_DAA_SELECTED_ATTRIB
+{
+    TSS_VERSION versionInfo;
+    UINT32      indicesListLength;
+#ifdef __midl
+    [size_is(indicesListLength)]
+#endif
+    TSS_BOOL*   indicesList;
+} TSS_DAA_SELECTED_ATTRIB;
+
+typedef struct tdTSS_DAA_PSEUDONYM
+{
+    TSS_VERSION versionInfo;
+    TSS_FLAG    payloadFlag;
+    UINT32      payloadLength;
+#ifdef __midl
+    [size_is(payloadLength)]
+#endif
+    BYTE*       payload;
+} TSS_DAA_PSEUDONYM;
+
+typedef struct tdTSS_DAA_PSEUDONYM_PLAIN
+{
+    TSS_VERSION versionInfo;
+    UINT32      capitalNvLength;
+#ifdef __midl
+    [size_is(capitalNvLength)]
+#endif
+    BYTE*       capitalNv;
+} TSS_DAA_PSEUDONYM_PLAIN;
+
+typedef struct tdTSS_DAA_PSEUDONYM_ENCRYPTED
+{
+    TSS_VERSION versionInfo;
+    UINT32      delta1Length;
+#ifdef __midl
+    [size_is(delta1Length)]
+#endif
+    BYTE*       delta1;
+    UINT32      delta2Length;
+#ifdef __midl
+    [size_is(delta2Length)]
+#endif
+    BYTE*       delta2;
+    UINT32      delta3Length;
+#ifdef __midl
+    [size_is(delta3Length)]
+#endif
+    BYTE*       delta3;
+    UINT32      delta4Length;
+#ifdef __midl
+    [size_is(delta4Length)]
+#endif
+    BYTE*       delta4;
+    UINT32      sTauLength;
+#ifdef __midl
+    [size_is(sTauLength)]
+#endif
+    BYTE*       sTau;
+} TSS_DAA_PSEUDONYM_ENCRYPTED;
+
+typedef struct tdTSS_DAA_SIGN_CALLBACK
+{
+    TSS_VERSION versionInfo;
+    TSS_HHASH   challenge;
+    TSS_FLAG    payloadFlag;
+    UINT32      payloadLength;
+#ifdef __midl
+    [size_is(payloadLength)]
+#endif
+    BYTE*       payload;
+} TSS_DAA_SIGN_CALLBACK;
+
+typedef struct tdTSS_DAA_SIGNATURE
+{
+    TSS_VERSION            versionInfo;
+    UINT32                 zetaLength;
+#ifdef __midl
+    [size_is(zetaLength)]
+#endif
+    BYTE*                  zeta;
+    UINT32                 capitalTLength;
+#ifdef __midl
+    [size_is(capitalTLength)]
+#endif
+    BYTE*                  capitalT;
+    UINT32                 challengeLength;
+#ifdef __midl
+    [size_is(challengeLength)]
+#endif
+    BYTE*                  challenge;
+    UINT32                 nonceTpmLength;
+#ifdef __midl
+    [size_is(nonceTpmLength)]
+#endif
+    BYTE*                  nonceTpm;
+    UINT32                 sVLength;
+#ifdef __midl
+    [size_is(sVLength)]
+#endif
+    BYTE*                  sV;
+    UINT32                 sF0Length;
+#ifdef __midl
+    [size_is(sF0Length)]
+#endif
+    BYTE*                  sF0;
+    UINT32                 sF1Length;
+#ifdef __midl
+    [size_is(sF1Length)]
+#endif
+    BYTE*                  sF1;
+    UINT32                 sELength;
+#ifdef __midl
+    [size_is(sELength)]
+#endif
+    BYTE*                  sE;
+    UINT32                 sALength;    // Length of first dimension
+    UINT32                 sALength2;   // Length of second dimension
+#ifdef __midl
+    [size_is(sALength,sALength2)]
+#endif
+    BYTE**                 sA;
+    UINT32                 attributeCommitmentsLength;
+#ifdef __midl
+    [size_is(attributeCommitmentsLength)]
+#endif
+    TSS_DAA_ATTRIB_COMMIT* attributeCommitments;
+    TSS_DAA_PSEUDONYM      signedPseudonym;
+    TSS_DAA_SIGN_CALLBACK  callbackResult;
+} TSS_DAA_SIGNATURE;
+
+typedef struct tdTSS_DAA_IDENTITY_PROOF
+{
+    TSS_VERSION versionInfo;
+    UINT32      endorsementLength;
+#ifdef __midl
+    [size_is(endorsementLength)]
+#endif
+    BYTE*       endorsementCredential;
+    UINT32      platformLength;
+#ifdef __midl
+    [size_is(platformLength)]
+#endif
+    BYTE*       platform;
+    UINT32      conformanceLength;
+#ifdef __midl
+    [size_is(conformanceLength)]
+#endif
+    BYTE*       conformance;
+} TSS_DAA_IDENTITY_PROOF;
+
+
+////////////////////////////////////////////////////////////////////
+
+typedef UINT32 TSS_FAMILY_ID;
+typedef BYTE   TSS_DELEGATION_LABEL;
+// Values are TSS_DELEGATIONTYPE_KEY or TSS_DELEGATIONTYPE_OWNER
+typedef UINT32 TSS_DELEGATION_TYPE;
+
+typedef struct tdTSS_PCR_INFO_SHORT
+{
+    UINT32               sizeOfSelect;
+#ifdef __midl
+    [size_is(sizeOfSelect)]
+#endif
+    BYTE                *selection;
+    BYTE                 localityAtRelease;
+    UINT32               sizeOfDigestAtRelease;
+#ifdef __midl
+    [size_is(sizeOfDigestAtRelease)]
+#endif
+    BYTE                *digestAtRelease;
+} TSS_PCR_INFO_SHORT;
+
+typedef struct tdTSS_FAMILY_TABLE_ENTRY
+{
+    TSS_FAMILY_ID        familyID;
+    TSS_DELEGATION_LABEL label;
+    UINT32               verificationCount;
+    TSS_BOOL             enabled;
+    TSS_BOOL             locked;
+} TSS_FAMILY_TABLE_ENTRY;
+
+typedef struct tdTSS_DELEGATION_TABLE_ENTRY
+{
+    UINT32               tableIndex;
+    TSS_DELEGATION_LABEL label;
+    TSS_PCR_INFO_SHORT   pcrInfo;
+    UINT32               per1;
+    UINT32               per2;
+    TSS_FAMILY_ID        familyID;
+    UINT32               verificationCount;
+} TSS_DELEGATION_TABLE_ENTRY;
+
+typedef struct tdTSS_PLATFORM_CLASS
+{
+    UINT32 platformClassSimpleIdentifier;
+    UINT32 platformClassURISize;
+    BYTE*  pPlatformClassURI;
+} TSS_PLATFORM_CLASS;
+
+#endif // __TSS_STRUCTS_H__
+
diff --git a/src/include/tss/tss_typedef.h b/src/include/tss/tss_typedef.h
index c23ef09..269ce00 100644
--- a/src/include/tss/tss_typedef.h
+++ b/src/include/tss/tss_typedef.h
@@ -1,48 +1,48 @@
-/*++
-
-Global typedefs for TSS
- 
-*/
-
-#ifndef __TSS_TYPEDEF_H__
-#define __TSS_TYPEDEF_H__
-
-#include <tss/platform.h>
-
-//--------------------------------------------------------------------
-// definitions for TSS Service Provider (TSP)
-//
-typedef  UINT32  TSS_HANDLE;
-
-typedef  UINT32  TSS_FLAG;  // object attributes
-typedef  UINT32  TSS_RESULT;  // the return code from a TSS function
-
-typedef  UINT32          TSS_HOBJECT;     // basic object handle
-typedef  TSS_HOBJECT     TSS_HCONTEXT;    // context object handle
-typedef  TSS_HOBJECT     TSS_HPOLICY;     // policy object handle
-typedef  TSS_HOBJECT     TSS_HTPM;        // TPM object handle
-typedef  TSS_HOBJECT     TSS_HKEY;        // key object handle
-typedef  TSS_HOBJECT     TSS_HENCDATA;    // encrypted data object handle
-typedef  TSS_HOBJECT     TSS_HPCRS;       // PCR composite object handle
-typedef  TSS_HOBJECT     TSS_HHASH;       // hash object handle
-typedef  TSS_HOBJECT     TSS_HNVSTORE;    // NV storage object handle
-typedef  TSS_HOBJECT     TSS_HMIGDATA;    // migration data utility obj handle
-typedef  TSS_HOBJECT     TSS_HDELFAMILY;  // delegation family object handle
-typedef  TSS_HOBJECT     TSS_HDAA_CREDENTIAL; // daa credential
-typedef  TSS_HOBJECT     TSS_HDAA_ISSUER_KEY; // daa credential issuer keypair
-typedef  TSS_HOBJECT     TSS_HDAA_ARA_KEY;    // daa anonymity revocation
-                                              // authority keypair
-
-typedef UINT32  TSS_EVENTTYPE;
-typedef UINT16  TSS_MIGRATE_SCHEME;
-typedef UINT32  TSS_ALGORITHM_ID;
-typedef UINT32  TSS_KEY_USAGE_ID;
-typedef UINT16  TSS_KEY_ENC_SCHEME;
-typedef UINT16  TSS_KEY_SIG_SCHEME;
-typedef BYTE    TSS_KEY_AUTH_DATA_USAGE;
-typedef UINT32  TSS_CMK_DELEGATE;
-typedef UINT32  TSS_NV_INDEX;
-typedef UINT32  TSS_COUNTER_ID;
-
-#endif // __TSS_TYPEDEF_H__
-
+/*++
+
+Global typedefs for TSS
+ 
+*/
+
+#ifndef __TSS_TYPEDEF_H__
+#define __TSS_TYPEDEF_H__
+
+#include <tss/platform.h>
+
+//--------------------------------------------------------------------
+// definitions for TSS Service Provider (TSP)
+//
+typedef  UINT32  TSS_HANDLE;
+
+typedef  UINT32  TSS_FLAG;  // object attributes
+typedef  UINT32  TSS_RESULT;  // the return code from a TSS function
+
+typedef  UINT32          TSS_HOBJECT;     // basic object handle
+typedef  TSS_HOBJECT     TSS_HCONTEXT;    // context object handle
+typedef  TSS_HOBJECT     TSS_HPOLICY;     // policy object handle
+typedef  TSS_HOBJECT     TSS_HTPM;        // TPM object handle
+typedef  TSS_HOBJECT     TSS_HKEY;        // key object handle
+typedef  TSS_HOBJECT     TSS_HENCDATA;    // encrypted data object handle
+typedef  TSS_HOBJECT     TSS_HPCRS;       // PCR composite object handle
+typedef  TSS_HOBJECT     TSS_HHASH;       // hash object handle
+typedef  TSS_HOBJECT     TSS_HNVSTORE;    // NV storage object handle
+typedef  TSS_HOBJECT     TSS_HMIGDATA;    // migration data utility obj handle
+typedef  TSS_HOBJECT     TSS_HDELFAMILY;  // delegation family object handle
+typedef  TSS_HOBJECT     TSS_HDAA_CREDENTIAL; // daa credential
+typedef  TSS_HOBJECT     TSS_HDAA_ISSUER_KEY; // daa credential issuer keypair
+typedef  TSS_HOBJECT     TSS_HDAA_ARA_KEY;    // daa anonymity revocation
+                                              // authority keypair
+
+typedef UINT32  TSS_EVENTTYPE;
+typedef UINT16  TSS_MIGRATE_SCHEME;
+typedef UINT32  TSS_ALGORITHM_ID;
+typedef UINT32  TSS_KEY_USAGE_ID;
+typedef UINT16  TSS_KEY_ENC_SCHEME;
+typedef UINT16  TSS_KEY_SIG_SCHEME;
+typedef BYTE    TSS_KEY_AUTH_DATA_USAGE;
+typedef UINT32  TSS_CMK_DELEGATE;
+typedef UINT32  TSS_NV_INDEX;
+typedef UINT32  TSS_COUNTER_ID;
+
+#endif // __TSS_TYPEDEF_H__
+
diff --git a/src/include/win32dep.h b/src/include/win32dep.h
new file mode 100644
index 0000000..1ed9731
--- /dev/null
+++ b/src/include/win32dep.h
@@ -0,0 +1,25 @@
+#ifndef _WIN32DEP_H_
+#define _WIN32DEP_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+char *trousers_getUserDir(void);			//WARNING: code from PhysicsFS
+unsigned int Curl_rand(void);
+void Curl_srand(void);
+void trousers_setenv(const char *name, const char *value, int overwrite);
+void trousers_log(const char *layer, const char *fmt, ...);
+
+#ifndef HAVE_SETENV
+#define setenv( name, value, overwrite) \
+trousers_setenv( name, value, overwrite)
+#define unsetenv( name) \
+setenv (name, "", 1)
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _WIN32DEP_H_ */
diff --git a/src/tcs/Makefile.am b/src/tcs/Makefile.am
index 8540a9a..3dd8b68 100644
--- a/src/tcs/Makefile.am
+++ b/src/tcs/Makefile.am
@@ -15,6 +15,9 @@ libtcs_a_SOURCES=log.c \
 		 tcs_auth_mgr.c tcsi_auth.c rpc/@RPC@/rpc_auth.c \
 		 tcs_pbg.c
 
+if OS_WIN32
+libtcs_a_LIBADD+=${top_builddir}/src/win32/libc_interface.la
+endif
 if TSS_BUILD_TRANSPORT
 libtcs_a_SOURCES+=tcsi_transport.c rpc/@RPC@/rpc_transport.c
 libtcs_a_CFLAGS+=-DTSS_BUILD_TRANSPORT
diff --git a/src/tcs/log.c b/src/tcs/log.c
index 8f3d0b4..57a9148 100644
--- a/src/tcs/log.c
+++ b/src/tcs/log.c
@@ -9,12 +9,21 @@
  */
 
 
+#ifdef WIN32
+#include <ws2tcpip.h>
+#include <windows.h>
+#endif
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 
 #include "trousers/tss.h"
 #include "tcslog.h"
+#ifdef WIN32
+#include "libc_interface.h"
+#endif
 
 #ifdef TSS_DEBUG
 
@@ -36,8 +45,10 @@ LogBlobData(char *szDescriptor, unsigned long sizeOfBlob, unsigned char *blob)
 	unsigned int i;
 
 
+#ifndef WIN32
 	if (getenv("TCSD_FOREGROUND") == NULL)
 		openlog(szDescriptor, LOG_NDELAY|LOG_PID, TSS_SYSLOG_LVL);
+#endif
 	memset(temp, 0, sizeof(temp));
 
 	for (i = 0; (unsigned long)i < sizeOfBlob; i++) {
@@ -45,7 +56,11 @@ LogBlobData(char *szDescriptor, unsigned long sizeOfBlob, unsigned char *blob)
 			if (getenv("TCSD_FOREGROUND") != NULL)
 				fprintf(stdout, "%s %s\n", szDescriptor, temp);
 			else
+#ifdef WIN32
+				trousers_log(APPID, "%s\n", temp);
+#else
 				syslog(LOG_DEBUG, "%s", temp);
+#endif
 			memset(temp, 0, sizeof(temp));
 		}
 		snprintf(&temp[(i%16)*3], 4, "%.2X ", blob[i]);
@@ -55,7 +70,11 @@ LogBlobData(char *szDescriptor, unsigned long sizeOfBlob, unsigned char *blob)
 		if (getenv("TCSD_FOREGROUND") != NULL)
 			fprintf(stdout, "%s %s\n", szDescriptor, temp);
 		else
+#ifdef WIN32
+			trousers_log(APPID, "%s\n", temp);
+#else
 			syslog(LOG_DEBUG, "%s", temp);
+#endif
 	}
 }
 
diff --git a/src/tcs/ps/ps_utils.c b/src/tcs/ps/ps_utils.c
index 2e7f502..f96fb99 100644
--- a/src/tcs/ps/ps_utils.c
+++ b/src/tcs/ps/ps_utils.c
@@ -10,7 +10,9 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
 #if defined(HAVE_BYTEORDER_H)
diff --git a/src/tcs/ps/tcsps.c b/src/tcs/ps/tcsps.c
index 00ad435..c2ee6b8 100644
--- a/src/tcs/ps/tcsps.c
+++ b/src/tcs/ps/tcsps.c
@@ -9,13 +9,21 @@
  */
 
 
+#ifdef WIN32
+#include <ws2tcpip.h>
+#include <windows.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <errno.h>
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/file.h>
+#endif
 #include <sys/stat.h>
 #if defined (HAVE_BYTEORDER_H)
 #include <sys/byteorder.h>
@@ -42,11 +50,17 @@
 #include "tcslog.h"
 #include "tcsd_wrap.h"
 #include "tcsd.h"
+#ifdef WIN32
+#include "flock.h"
+#include "libc_interface.h"
+#endif
 
 int system_ps_fd = -1;
 MUTEX_DECLARE(disk_cache_lock);
 
+#if defined (SOLARIS)
 static struct flock fl;
+#endif
 
 int
 get_file()
@@ -56,8 +70,12 @@ get_file()
 	if (system_ps_fd != -1) {
 		int rc = 0;
 
+#if defined (SOLARIS)
 		fl.l_type = F_WRLCK;
 		if ((rc = fcntl(system_ps_fd, F_SETLKW, &fl))) {
+#else
+		if ((rc = flock(system_ps_fd, LOCK_EX))) {
+#endif /* SOLARIS */
 			LogError("failed to get system PS lock: %s", strerror(errno));
 			return -1;
 		}
@@ -66,15 +84,23 @@ get_file()
 	}
 
 	/* open and lock the file */
+#ifdef WIN32
+	system_ps_fd = open(tcsd_options.system_ps_file, O_CREAT|O_RDWR|O_BINARY, 0600);
+#else
 	system_ps_fd = open(tcsd_options.system_ps_file, O_CREAT|O_RDWR, 0600);
+#endif
 	if (system_ps_fd < 0) {
 		LogError("system PS: open() of %s failed: %s",
 				tcsd_options.system_ps_file, strerror(errno));
 		return -1;
 	}
 
+#if defined (SOLARIS)
 	fl.l_type = F_WRLCK;
 	if ((rc = fcntl(system_ps_fd, F_SETLKW, &fl))) {
+#else
+	if ((rc = flock(system_ps_fd, LOCK_EX))) {
+#endif /* SOLARIS */
 		LogError("failed to get system PS lock of file %s: %s",
 			tcsd_options.system_ps_file, strerror(errno));
 		return -1;
@@ -89,8 +115,12 @@ put_file(int fd)
 	int rc = 0;
 	/* release the file lock */
 	
+#if defined (SOLARIS)
 	fl.l_type = F_UNLCK;
 	if ((rc = fcntl(fd, F_SETLKW, &fl))) {
+#else
+	if ((rc = flock(fd, LOCK_UN))) {
+#endif /* SOLARIS */
 		LogError("failed to unlock system PS file: %s",
 			strerror(errno));
 		return -1;
diff --git a/src/tcs/rpc/tcstp/rpc.c b/src/tcs/rpc/tcstp/rpc.c
index ca1a4df..26c5a06 100644
--- a/src/tcs/rpc/tcstp/rpc.c
+++ b/src/tcs/rpc/tcstp/rpc.c
@@ -7,12 +7,19 @@
  * (C) Copyright International Business Machines Corp. 2004-2007
  *
  */
-
+#ifdef WIN32
+#include <ws2tcpip.h>
+#include <windows.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 #if (defined (__OpenBSD__) || defined (__FreeBSD__))
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -30,6 +37,9 @@
 #include "tcsd.h"
 #include "rpc_tcstp_tcs.h"
 
+#ifdef WIN32
+#include "libc_interface.h"
+#endif
 
 /* Lock is not static because we need to reference it in the auth manager */
 MUTEX_DECLARE_INIT(tcsp_lock);
@@ -59,7 +69,7 @@ recv_from_socket(int sock, void *buffer, int size)
 
 	while (recv_total < size) {
 		errno = 0;
-		if ((recv_size = recv(sock, buffer+recv_total, size-recv_total, 0)) <= 0) {
+		if ((recv_size = recv(sock, (char *)buffer+recv_total, size-recv_total, 0)) <= 0) {
 			if (recv_size < 0) {
 				if (errno == EINTR)
 					continue;
@@ -82,7 +92,7 @@ send_to_socket(int sock, void *buffer, int size)
 	int send_size = 0, send_total = 0;
 
 	while (send_total < size) {
-		if ((send_size = send(sock, buffer+send_total, size-send_total, 0)) < 0) {
+		if ((send_size = send(sock, (char *)buffer+send_total, size-send_total, 0)) < 0) {
 			LogError("Socket send connection error: %s.", strerror(errno));
 			return -1;
 		}
diff --git a/src/tcs/rpc/tcstp/rpc_admin.c b/src/tcs/rpc/tcstp/rpc_admin.c
index 4f357c3..17913be 100644
--- a/src/tcs/rpc/tcstp/rpc_admin.c
+++ b/src/tcs/rpc/tcstp/rpc_admin.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_aik.c b/src/tcs/rpc/tcstp/rpc_aik.c
index 0f758f9..c8e841a 100644
--- a/src/tcs/rpc/tcstp/rpc_aik.c
+++ b/src/tcs/rpc/tcstp/rpc_aik.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_audit.c b/src/tcs/rpc/tcstp/rpc_audit.c
index 0fcfd18..237e5fb 100644
--- a/src/tcs/rpc/tcstp/rpc_audit.c
+++ b/src/tcs/rpc/tcstp/rpc_audit.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_auth.c b/src/tcs/rpc/tcstp/rpc_auth.c
index 2437c6b..9d378be 100644
--- a/src/tcs/rpc/tcstp/rpc_auth.c
+++ b/src/tcs/rpc/tcstp/rpc_auth.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_bind.c b/src/tcs/rpc/tcstp/rpc_bind.c
index 92eee24..8192aed 100644
--- a/src/tcs/rpc/tcstp/rpc_bind.c
+++ b/src/tcs/rpc/tcstp/rpc_bind.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_caps.c b/src/tcs/rpc/tcstp/rpc_caps.c
index 4fd2c11..9bd45e5 100644
--- a/src/tcs/rpc/tcstp/rpc_caps.c
+++ b/src/tcs/rpc/tcstp/rpc_caps.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_caps_tpm.c b/src/tcs/rpc/tcstp/rpc_caps_tpm.c
index 2bcac27..2aa74a4 100644
--- a/src/tcs/rpc/tcstp/rpc_caps_tpm.c
+++ b/src/tcs/rpc/tcstp/rpc_caps_tpm.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_certify.c b/src/tcs/rpc/tcstp/rpc_certify.c
index 85c9321..f89b1df 100644
--- a/src/tcs/rpc/tcstp/rpc_certify.c
+++ b/src/tcs/rpc/tcstp/rpc_certify.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_changeauth.c b/src/tcs/rpc/tcstp/rpc_changeauth.c
index 97af192..9d1dd13 100644
--- a/src/tcs/rpc/tcstp/rpc_changeauth.c
+++ b/src/tcs/rpc/tcstp/rpc_changeauth.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_cmk.c b/src/tcs/rpc/tcstp/rpc_cmk.c
index 3d00c13..1d2eb96 100644
--- a/src/tcs/rpc/tcstp/rpc_cmk.c
+++ b/src/tcs/rpc/tcstp/rpc_cmk.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_context.c b/src/tcs/rpc/tcstp/rpc_context.c
index b04449e..387c81b 100644
--- a/src/tcs/rpc/tcstp/rpc_context.c
+++ b/src/tcs/rpc/tcstp/rpc_context.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_counter.c b/src/tcs/rpc/tcstp/rpc_counter.c
index 6bb654e..27e9185 100644
--- a/src/tcs/rpc/tcstp/rpc_counter.c
+++ b/src/tcs/rpc/tcstp/rpc_counter.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_daa.c b/src/tcs/rpc/tcstp/rpc_daa.c
index 6da24a1..0c59403 100644
--- a/src/tcs/rpc/tcstp/rpc_daa.c
+++ b/src/tcs/rpc/tcstp/rpc_daa.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
@@ -41,10 +45,9 @@ tcs_wrap_DaaJoin(struct tcsd_thread_data *data)
 	if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
 		return TCSERR(TSS_E_INTERNAL_ERROR);
 
-	LogDebugFn("thread %ld hDAA %x", THREAD_ID, hDAA);
-
 	if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hDAA, 0, &data->comm))
 		return TCSERR(TSS_E_INTERNAL_ERROR);
+	LogDebugFn("thread %ld hDAA %x", THREAD_ID, hDAA);
 
 	if (getData(TCSD_PACKET_TYPE_BYTE, 2, &stage, 0, &data->comm))
 		return TCSERR(TSS_E_INTERNAL_ERROR);
@@ -145,9 +148,9 @@ tcs_wrap_DaaSign(struct tcsd_thread_data *data)
 	if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
 		return TCSERR(TSS_E_INTERNAL_ERROR);
 
-	LogDebugFn("thread %ld hDAA %x", THREAD_ID, hDAA);
 	if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hDAA, 0, &data->comm))
 		return TCSERR(TSS_E_INTERNAL_ERROR);
+	LogDebugFn("thread %ld hDAA %x", THREAD_ID, hDAA);
 
 	if (getData(TCSD_PACKET_TYPE_BYTE, 2, &stage, 0, &data->comm))
 		return TCSERR(TSS_E_INTERNAL_ERROR);
diff --git a/src/tcs/rpc/tcstp/rpc_delegate.c b/src/tcs/rpc/tcstp/rpc_delegate.c
index 5bd0cd8..ba77d1b 100644
--- a/src/tcs/rpc/tcstp/rpc_delegate.c
+++ b/src/tcs/rpc/tcstp/rpc_delegate.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_dir.c b/src/tcs/rpc/tcstp/rpc_dir.c
index 47baec6..4040caa 100644
--- a/src/tcs/rpc/tcstp/rpc_dir.c
+++ b/src/tcs/rpc/tcstp/rpc_dir.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_ek.c b/src/tcs/rpc/tcstp/rpc_ek.c
index 0b49718..f44bc14 100644
--- a/src/tcs/rpc/tcstp/rpc_ek.c
+++ b/src/tcs/rpc/tcstp/rpc_ek.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_evlog.c b/src/tcs/rpc/tcstp/rpc_evlog.c
index 4187c25..b9b22e5 100644
--- a/src/tcs/rpc/tcstp/rpc_evlog.c
+++ b/src/tcs/rpc/tcstp/rpc_evlog.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_key.c b/src/tcs/rpc/tcstp/rpc_key.c
index d3a5153..e8d1434 100644
--- a/src/tcs/rpc/tcstp/rpc_key.c
+++ b/src/tcs/rpc/tcstp/rpc_key.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_maint.c b/src/tcs/rpc/tcstp/rpc_maint.c
index f51a4f2..ee28621 100644
--- a/src/tcs/rpc/tcstp/rpc_maint.c
+++ b/src/tcs/rpc/tcstp/rpc_maint.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_migration.c b/src/tcs/rpc/tcstp/rpc_migration.c
index 5233096..722248f 100644
--- a/src/tcs/rpc/tcstp/rpc_migration.c
+++ b/src/tcs/rpc/tcstp/rpc_migration.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_nv.c b/src/tcs/rpc/tcstp/rpc_nv.c
index 71c170d..77d0443 100644
--- a/src/tcs/rpc/tcstp/rpc_nv.c
+++ b/src/tcs/rpc/tcstp/rpc_nv.c
@@ -25,9 +25,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_oper.c b/src/tcs/rpc/tcstp/rpc_oper.c
index 8e097be..41a9882 100644
--- a/src/tcs/rpc/tcstp/rpc_oper.c
+++ b/src/tcs/rpc/tcstp/rpc_oper.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_own.c b/src/tcs/rpc/tcstp/rpc_own.c
index beb2a8c..cfe6268 100644
--- a/src/tcs/rpc/tcstp/rpc_own.c
+++ b/src/tcs/rpc/tcstp/rpc_own.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_pcr_extend.c b/src/tcs/rpc/tcstp/rpc_pcr_extend.c
index e9fd9cd..855d3b2 100644
--- a/src/tcs/rpc/tcstp/rpc_pcr_extend.c
+++ b/src/tcs/rpc/tcstp/rpc_pcr_extend.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_ps.c b/src/tcs/rpc/tcstp/rpc_ps.c
index 3f6e5a7..e6eb500 100644
--- a/src/tcs/rpc/tcstp/rpc_ps.c
+++ b/src/tcs/rpc/tcstp/rpc_ps.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_quote.c b/src/tcs/rpc/tcstp/rpc_quote.c
index aeb469c..6307304 100644
--- a/src/tcs/rpc/tcstp/rpc_quote.c
+++ b/src/tcs/rpc/tcstp/rpc_quote.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_quote2.c b/src/tcs/rpc/tcstp/rpc_quote2.c
index 2a10ead..a122fc1 100644
--- a/src/tcs/rpc/tcstp/rpc_quote2.c
+++ b/src/tcs/rpc/tcstp/rpc_quote2.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_random.c b/src/tcs/rpc/tcstp/rpc_random.c
index 6fd9606..00747e1 100644
--- a/src/tcs/rpc/tcstp/rpc_random.c
+++ b/src/tcs/rpc/tcstp/rpc_random.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_seal.c b/src/tcs/rpc/tcstp/rpc_seal.c
index f0dd359..5392a0d 100644
--- a/src/tcs/rpc/tcstp/rpc_seal.c
+++ b/src/tcs/rpc/tcstp/rpc_seal.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_selftest.c b/src/tcs/rpc/tcstp/rpc_selftest.c
index 4cad0c9..d9ebaa7 100644
--- a/src/tcs/rpc/tcstp/rpc_selftest.c
+++ b/src/tcs/rpc/tcstp/rpc_selftest.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_sign.c b/src/tcs/rpc/tcstp/rpc_sign.c
index 2cd2027..bc40459 100644
--- a/src/tcs/rpc/tcstp/rpc_sign.c
+++ b/src/tcs/rpc/tcstp/rpc_sign.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_tick.c b/src/tcs/rpc/tcstp/rpc_tick.c
index 98e53ad..c998f21 100644
--- a/src/tcs/rpc/tcstp/rpc_tick.c
+++ b/src/tcs/rpc/tcstp/rpc_tick.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/rpc/tcstp/rpc_transport.c b/src/tcs/rpc/tcstp/rpc_transport.c
index 1993cb3..a7c4128 100644
--- a/src/tcs/rpc/tcstp/rpc_transport.c
+++ b/src/tcs/rpc/tcstp/rpc_transport.c
@@ -10,9 +10,13 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <string.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcs_aik.c b/src/tcs/tcs_aik.c
index 1d22506..b05e4e3 100644
--- a/src/tcs/tcs_aik.c
+++ b/src/tcs/tcs_aik.c
@@ -12,10 +12,14 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef WIN32
 #include <sys/mman.h>
+#endif
 #include <fcntl.h>
 #include <errno.h>
 
@@ -85,7 +89,6 @@ get_credential(UINT32 type, UINT32 *size, BYTE **cred)
 {
 	int rc, fd;
 	char *path = NULL;
-	void *file = NULL;
 	struct stat stat_buf;
 	size_t file_size;
 
@@ -121,23 +124,15 @@ get_credential(UINT32 type, UINT32 *size, BYTE **cred)
 
 	LogDebugFn("%s, (%zd bytes)", path, file_size);
 
-	file = mmap(0, file_size, PROT_READ, MAP_PRIVATE, fd, 0);
-	if (file == MAP_FAILED) {
-		LogError("Error reading credential: %s: %s", path, strerror(errno));
-		close(fd);
-		goto done;
-	}
-	close(fd);
-
-	if ((*cred = malloc(file_size)) == NULL) {
+	if ((*cred = malloc(file_size + 1)) == NULL) {
 		LogError("malloc of %zd bytes failed.", file_size);
-		munmap(file, file_size);
 		goto done;
 	}
 
-	memcpy(*cred, file, file_size);
+	memset(*cred, 0, file_size + 1);
+	read(fd, *cred, file_size);
+	close(fd);
 	*size = file_size;
-	munmap(file, file_size);
 
 	return;
 done:
diff --git a/src/tcs/tcs_caps.c b/src/tcs/tcs_caps.c
index c4cff7c..1ce245b 100644
--- a/src/tcs/tcs_caps.c
+++ b/src/tcs/tcs_caps.c
@@ -12,10 +12,14 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef WIN32
 #include <sys/mman.h>
+#endif
 #include <fcntl.h>
 #include <errno.h>
 
diff --git a/src/tcs/tcs_counter.c b/src/tcs/tcs_counter.c
index f212ac6..a73d6fc 100644
--- a/src/tcs/tcs_counter.c
+++ b/src/tcs/tcs_counter.c
@@ -12,10 +12,14 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef WIN32
 #include <sys/mman.h>
+#endif
 #include <fcntl.h>
 #include <errno.h>
 
diff --git a/src/tcs/tcs_evlog_biosem.c b/src/tcs/tcs_evlog_biosem.c
index 7065e12..9c1f344 100644
--- a/src/tcs/tcs_evlog_biosem.c
+++ b/src/tcs/tcs_evlog_biosem.c
@@ -23,7 +23,9 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <limits.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcs_evlog_imaem.c b/src/tcs/tcs_evlog_imaem.c
index fbdd29a..6f19d6c 100644
--- a/src/tcs/tcs_evlog_imaem.c
+++ b/src/tcs/tcs_evlog_imaem.c
@@ -36,7 +36,9 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <limits.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
@@ -84,7 +86,7 @@ ima_get_entries_by_pcr(FILE *handle, UINT32 pcr_index, UINT32 first,
 	struct event_wrapper *cur = list;
 	TSS_RESULT result = TCSERR(TSS_E_INTERNAL_ERROR);
 	FILE *fp = (FILE *) handle;
-	uint len;
+	unsigned int len;
 	char name[255];
 
 	if (list == NULL) {
@@ -226,7 +228,7 @@ TSS_RESULT
 ima_get_entry(FILE *handle, UINT32 pcr_index, UINT32 *num, TSS_PCR_EVENT **ppEvent)
 {
 	int pcr_value, ptr = 0;
-	uint len;
+	unsigned int len;
 	char page[IMA_READ_SIZE];
 	UINT32 seen_indices = 0;
 	TSS_RESULT result = TCSERR(TSS_E_INTERNAL_ERROR);
diff --git a/src/tcs/tcs_key_mem_cache.c b/src/tcs/tcs_key_mem_cache.c
index a44278e..185a8e0 100644
--- a/src/tcs/tcs_key_mem_cache.c
+++ b/src/tcs/tcs_key_mem_cache.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <errno.h>
 
 #include "trousers/tss.h"
diff --git a/src/tcs/tcs_key_ps.c b/src/tcs/tcs_key_ps.c
index 0ea28c1..e165492 100644
--- a/src/tcs/tcs_key_ps.c
+++ b/src/tcs/tcs_key_ps.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <errno.h>
 
 #include "trousers/tss.h"
diff --git a/src/tcs/tcs_migration.c b/src/tcs/tcs_migration.c
index f653737..f4e92f1 100644
--- a/src/tcs/tcs_migration.c
+++ b/src/tcs/tcs_migration.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcs_pbg.c b/src/tcs/tcs_pbg.c
index 5eaa6f7..5050d09 100644
--- a/src/tcs/tcs_pbg.c
+++ b/src/tcs/tcs_pbg.c
@@ -13,10 +13,14 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef WIN32
 #include <sys/mman.h>
+#endif
 #include <fcntl.h>
 #include <errno.h>
 
@@ -916,6 +920,7 @@ TSS_RESULT
 tpm_rqu_build(TPM_COMMAND_CODE ordinal, UINT64 *outOffset, BYTE *out_blob, ...)
 {
 	TSS_RESULT result = TSS_SUCCESS;
+	UINT64 blob_size;
 	va_list ap;
 
 	DBG_ASSERT(ordinal);
@@ -1448,6 +1453,13 @@ tpm_rqu_build(TPM_COMMAND_CODE ordinal, UINT64 *outOffset, BYTE *out_blob, ...)
 		TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
 		va_end(ap);
 
+		blob_size = in_len1 + in_len2 + TPM_DIGEST_SIZE + sizeof(TPM_AUTH);
+		if (blob_size > TSS_TPM_TXBLOB_SIZE) {
+			result = TCSERR(TSS_E_BAD_PARAMETER);
+			LogError("Oversized input when building ordinal 0x%x", ordinal);
+			break;
+		}
+				
 		if (!keySlot1 || !in_blob2 || !auth1) {
 			result = TCSERR(TSS_E_INTERNAL_ERROR);
 			LogError("Internal error for ordinal 0x%x", ordinal);
diff --git a/src/tcs/tcs_quote.c b/src/tcs/tcs_quote.c
index 0c84687..21f0530 100644
--- a/src/tcs/tcs_quote.c
+++ b/src/tcs/tcs_quote.c
@@ -12,10 +12,14 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef WIN32
 #include <sys/mman.h>
+#endif
 #include <fcntl.h>
 #include <errno.h>
 
diff --git a/src/tcs/tcs_quote2.c b/src/tcs/tcs_quote2.c
index aa7ba51..d62ec98 100644
--- a/src/tcs/tcs_quote2.c
+++ b/src/tcs/tcs_quote2.c
@@ -12,10 +12,14 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef WIN32
 #include <sys/mman.h>
+#endif
 #include <fcntl.h>
 #include <errno.h>
 
diff --git a/src/tcs/tcs_req_mgr.c b/src/tcs/tcs_req_mgr.c
index 701cedb..1b02c5a 100644
--- a/src/tcs/tcs_req_mgr.c
+++ b/src/tcs/tcs_req_mgr.c
@@ -11,11 +11,15 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <signal.h>
 #include <string.h>
 #include <errno.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 
 #include "trousers/tss.h"
 #include "tcs_tsp.h"
diff --git a/src/tcs/tcs_seal.c b/src/tcs/tcs_seal.c
index e021948..01de608 100644
--- a/src/tcs/tcs_seal.c
+++ b/src/tcs/tcs_seal.c
@@ -12,10 +12,14 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef WIN32
 #include <sys/mman.h>
+#endif
 #include <fcntl.h>
 #include <errno.h>
 
diff --git a/src/tcs/tcs_utils.c b/src/tcs/tcs_utils.c
index d621ef8..8da0549 100644
--- a/src/tcs/tcs_utils.c
+++ b/src/tcs/tcs_utils.c
@@ -12,10 +12,14 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef WIN32
 #include <sys/mman.h>
+#endif
 #include <fcntl.h>
 #include <errno.h>
 
diff --git a/src/tcs/tcsi_admin.c b/src/tcs/tcsi_admin.c
index 3830b12..1fbec1d 100644
--- a/src/tcs/tcsi_admin.c
+++ b/src/tcs/tcsi_admin.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
@@ -171,7 +173,11 @@ TCSP_PhysicalPresence_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
 	BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
 	char runlevel;
 
+#ifdef FIXME
 	runlevel = platform_get_runlevel();
+#else
+	runlevel = 3;
+#endif
 
 	if (runlevel != 's' && runlevel != 'S' && runlevel != '1') {
 		LogInfo("Physical Presence command denied: Must be in single"
diff --git a/src/tcs/tcsi_aik.c b/src/tcs/tcsi_aik.c
index 8915d13..20a83fe 100644
--- a/src/tcs/tcsi_aik.c
+++ b/src/tcs/tcsi_aik.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_auth.c b/src/tcs/tcsi_auth.c
index ec4a11e..63b4a99 100644
--- a/src/tcs/tcsi_auth.c
+++ b/src/tcs/tcsi_auth.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_bind.c b/src/tcs/tcsi_bind.c
index 7c9fb46..e512d96 100644
--- a/src/tcs/tcsi_bind.c
+++ b/src/tcs/tcsi_bind.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_caps.c b/src/tcs/tcsi_caps.c
index 2d7684f..117b92d 100644
--- a/src/tcs/tcsi_caps.c
+++ b/src/tcs/tcsi_caps.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_caps_tpm.c b/src/tcs/tcsi_caps_tpm.c
index c64513f..d74a1b7 100644
--- a/src/tcs/tcsi_caps_tpm.c
+++ b/src/tcs/tcsi_caps_tpm.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_certify.c b/src/tcs/tcsi_certify.c
index 8fae84e..fdc951e 100644
--- a/src/tcs/tcsi_certify.c
+++ b/src/tcs/tcsi_certify.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_changeauth.c b/src/tcs/tcsi_changeauth.c
index 59329ea..0c9a7a0 100644
--- a/src/tcs/tcsi_changeauth.c
+++ b/src/tcs/tcsi_changeauth.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_daa.c b/src/tcs/tcsi_daa.c
index 293f4b3..a43f603 100644
--- a/src/tcs/tcsi_daa.c
+++ b/src/tcs/tcsi_daa.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_dir.c b/src/tcs/tcsi_dir.c
index 9d5030a..6eeff0f 100644
--- a/src/tcs/tcsi_dir.c
+++ b/src/tcs/tcsi_dir.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_ek.c b/src/tcs/tcsi_ek.c
index 34388da..9dc2862 100644
--- a/src/tcs/tcsi_ek.c
+++ b/src/tcs/tcsi_ek.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_evlog.c b/src/tcs/tcsi_evlog.c
index 355f30a..2892cdd 100644
--- a/src/tcs/tcsi_evlog.c
+++ b/src/tcs/tcsi_evlog.c
@@ -77,11 +77,11 @@ TCS_GetExternalPcrEvent(UINT32 PcrIndex,		/* in */
 
 			if (tcs_event_log->kernel_source->get_entry(log_handle, PcrIndex,
 						pNumber, ppEvent)) {
-				tcs_event_log->kernel_source->close(log_handle);
+				tcs_event_log->kernel_source->file_close(log_handle);
 				return TCSERR(TSS_E_INTERNAL_ERROR);
 			}
 
-			tcs_event_log->kernel_source->close(log_handle);
+			tcs_event_log->kernel_source->file_close(log_handle);
 		} else {
 			LogError("No source for externel kernel events was compiled in, but "
 					"the tcsd is configured to use one! (see %s)",
@@ -97,11 +97,11 @@ TCS_GetExternalPcrEvent(UINT32 PcrIndex,		/* in */
 
 			if (tcs_event_log->firmware_source->get_entry(log_handle, PcrIndex,
 						pNumber, ppEvent)) {
-				tcs_event_log->firmware_source->close(log_handle);
+				tcs_event_log->firmware_source->file_close(log_handle);
 				return TCSERR(TSS_E_INTERNAL_ERROR);
 			}
 
-			tcs_event_log->firmware_source->close(log_handle);
+			tcs_event_log->firmware_source->file_close(log_handle);
 		} else {
 			LogError("No source for externel firmware events was compiled in, but "
 					"the tcsd is configured to use one! (see %s)",
@@ -192,11 +192,11 @@ TCS_GetExternalPcrEventsByPcr(UINT32 PcrIndex,		/* in */
 
 			if (tcs_event_log->kernel_source->get_entries_by_pcr(log_handle, PcrIndex,
 						FirstEvent, pEventCount, ppEvents)) {
-				tcs_event_log->kernel_source->close(log_handle);
+				tcs_event_log->kernel_source->file_close(log_handle);
 				return TCSERR(TSS_E_INTERNAL_ERROR);
 			}
 
-			tcs_event_log->kernel_source->close(log_handle);
+			tcs_event_log->kernel_source->file_close(log_handle);
 		} else {
 			LogError("No source for externel kernel events was compiled in, but "
 					"the tcsd is configured to use one! (see %s)",
@@ -212,11 +212,11 @@ TCS_GetExternalPcrEventsByPcr(UINT32 PcrIndex,		/* in */
 
 			if (tcs_event_log->firmware_source->get_entries_by_pcr(log_handle, PcrIndex,
 						FirstEvent, pEventCount, ppEvents)) {
-				tcs_event_log->firmware_source->close(log_handle);
+				tcs_event_log->firmware_source->file_close(log_handle);
 				return TCSERR(TSS_E_INTERNAL_ERROR);
 			}
 
-			tcs_event_log->firmware_source->close(log_handle);
+			tcs_event_log->firmware_source->file_close(log_handle);
 		} else {
 			LogError("No source for externel firmware events was compiled in, but "
 					"the tcsd is configured to use one! (see %s)",
diff --git a/src/tcs/tcsi_maint.c b/src/tcs/tcsi_maint.c
index fea756d..f33d4d5 100644
--- a/src/tcs/tcsi_maint.c
+++ b/src/tcs/tcsi_maint.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_migration.c b/src/tcs/tcsi_migration.c
index 8467f02..f1b3b48 100644
--- a/src/tcs/tcsi_migration.c
+++ b/src/tcs/tcsi_migration.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_nv.c b/src/tcs/tcsi_nv.c
index cd88f20..e845436 100644
--- a/src/tcs/tcsi_nv.c
+++ b/src/tcs/tcsi_nv.c
@@ -27,7 +27,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_pcr.c b/src/tcs/tcsi_pcr.c
index 2cb97e3..9ab976b 100644
--- a/src/tcs/tcsi_pcr.c
+++ b/src/tcs/tcsi_pcr.c
@@ -13,7 +13,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_quote.c b/src/tcs/tcsi_quote.c
index 632b0cc..b56eddd 100644
--- a/src/tcs/tcsi_quote.c
+++ b/src/tcs/tcsi_quote.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_quote2.c b/src/tcs/tcsi_quote2.c
index 0ced27f..f420d44 100644
--- a/src/tcs/tcsi_quote2.c
+++ b/src/tcs/tcsi_quote2.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_random.c b/src/tcs/tcsi_random.c
index 9670df4..b1cdeb0 100644
--- a/src/tcs/tcsi_random.c
+++ b/src/tcs/tcsi_random.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_seal.c b/src/tcs/tcsi_seal.c
index bc72ecd..aea71c6 100644
--- a/src/tcs/tcsi_seal.c
+++ b/src/tcs/tcsi_seal.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_selftest.c b/src/tcs/tcsi_selftest.c
index 95869bc..4887bd2 100644
--- a/src/tcs/tcsi_selftest.c
+++ b/src/tcs/tcsi_selftest.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcs/tcsi_sign.c b/src/tcs/tcsi_sign.c
index 3671fb1..3266818 100644
--- a/src/tcs/tcsi_sign.c
+++ b/src/tcs/tcsi_sign.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
diff --git a/src/tcsd/Makefile.am b/src/tcsd/Makefile.am
index ff61a21..3ed3eb8 100644
--- a/src/tcsd/Makefile.am
+++ b/src/tcsd/Makefile.am
@@ -1,10 +1,14 @@
 sbin_PROGRAMS=tcsd
 
 tcsd_CFLAGS=-DAPPID=\"TCSD\" -DVAR_PREFIX=\"@localstatedir@\" -DETC_PREFIX=\"@sysconfdir@\" -I${top_srcdir}/src/include
-tcsd_LDADD=${top_builddir}/src/tcs/libtcs.a ${top_builddir}/src/tddl/libtddl.a -lpthread @CRYPTOLIB@
+tcsd_LDADD=${top_builddir}/src/tcs/libtcs.a ${top_builddir}/src/tddl/libtddl.a -lpthread @CRYPTOLIB@ @EXTRATCSLIB@
 
 tcsd_SOURCES=svrside.c tcsd_conf.c tcsd_threads.c platform.c
 
+if OS_WIN32
+tcsd_LDADD+=${top_builddir}/src/win32/libc_interface.la
+tcsd_CFLAGS+=-DDEBUG_APP
+endif
 if TSS_BUILD_PS
 tcsd_CFLAGS+=-DTSS_BUILD_PS
 endif
diff --git a/src/tcsd/platform.c b/src/tcsd/platform.c
index c7a1c80..c54e830 100644
--- a/src/tcsd/platform.c
+++ b/src/tcsd/platform.c
@@ -19,7 +19,9 @@
 #include <utmpx.h>
 #endif
 
+#ifndef WIN32
 #include <sys/time.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/src/tcsd/svrside.c b/src/tcsd/svrside.c
index 27c18bf..9a2ea8b 100644
--- a/src/tcsd/svrside.c
+++ b/src/tcsd/svrside.c
@@ -9,11 +9,18 @@
  */
 
 
+#ifdef WIN32
+#include <ws2tcpip.h>
+#include <windows.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <string.h>
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/wait.h>
@@ -21,10 +28,13 @@
 #include <sys/socket.h>
 #include <netdb.h>
 #include <pwd.h>
+#endif
 #if (defined (__OpenBSD__) || defined (__FreeBSD__))
 #include <netinet/in.h>
 #endif
+#ifndef WIN32
 #include <arpa/inet.h>
+#endif
 #include <errno.h>
 #include <getopt.h>
 #include "trousers/tss.h"
@@ -38,11 +48,19 @@
 #include "tcsps.h"
 #include "tcsd.h"
 #include "req_mgr.h"
+#ifdef WIN32
+#include "win32dep.h"
+#include "libc_interface.h"
+#define SERVICE_NAME		"tcsd"
+#define WIN32_LEAN_AND_MEAN
+#include <tchar.h>
+#endif
 
 struct tcsd_config tcsd_options;
 struct tpm_properties tpm_metrics;
 static volatile int hup = 0, term = 0;
 extern char *optarg;
+int sd = -1;
 
 static void
 tcsd_shutdown(void)
@@ -61,6 +79,8 @@ static void
 tcsd_signal_term(int signal)
 {
 	term = 1;
+	close(sd);
+	sd = -1;
 }
 
 void
@@ -69,9 +89,95 @@ tcsd_signal_hup(int signal)
 	hup = 1;
 }
 
+#ifdef WIN32
+int serviceflag = 0;
+SERVICE_STATUS_HANDLE serviceStatusHandle;
+HANDLE killServiceEvent = INVALID_HANDLE_VALUE;
+BOOL serviceRunning = 0;
+BOOL servicePaused = 0;
+DWORD serviceCurrentStatus;
+
+/************************************************************************/
+/* UpdateSCMStatus							*/
+/************************************************************************/
+BOOL UpdateSCMStatus (DWORD dwCurrentState,
+					  DWORD dwWin32ExitCode,
+					  DWORD dwServiceSpecificExitCode,
+					  DWORD dwCheckPoint,
+					  DWORD dwWaitHint)
+{
+	BOOL success;
+	SERVICE_STATUS serviceStatus;
+
+	if (serviceflag == 0)
+		return TRUE;
+
+	serviceCurrentStatus = dwCurrentState;
+	serviceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+	serviceStatus.dwCurrentState = dwCurrentState;
+
+	if (dwCurrentState == SERVICE_START_PENDING)
+		serviceStatus.dwControlsAccepted = 0;
+	else {
+		serviceStatus.dwControlsAccepted =
+			SERVICE_ACCEPT_STOP |
+			//SERVICE_ACCEPT_PAUSE_CONTINUE |
+			SERVICE_ACCEPT_SHUTDOWN;
+	}
+
+	if (dwServiceSpecificExitCode == 0)
+		serviceStatus.dwWin32ExitCode = dwWin32ExitCode;
+	else
+		serviceStatus.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR;
+
+	serviceStatus.dwServiceSpecificExitCode = dwServiceSpecificExitCode;
+	serviceStatus.dwCheckPoint = dwCheckPoint;
+	serviceStatus.dwWaitHint = dwWaitHint;
+
+	success = SetServiceStatus (serviceStatusHandle, &serviceStatus);
+	if (!success)
+		return FALSE;
+
+	return success;
+}
+
+BOOL signal_handler(DWORD event)
+{
+	tcsd_signal_term(0);
+	return TRUE;
+}
+
+/************************************************************************/
+/* ServiceCtrlHandler							*/
+/************************************************************************/
+VOID ServiceCtrlHandler (DWORD controlCode)
+{
+	BOOL success;
+	switch(controlCode)
+	{
+
+	case SERVICE_CONTROL_PAUSE:
+		break;
+	case SERVICE_CONTROL_CONTINUE:
+		break;
+	case SERVICE_CONTROL_INTERROGATE:
+		break;
+	case SERVICE_CONTROL_STOP:
+	case SERVICE_CONTROL_SHUTDOWN:
+		success = UpdateSCMStatus(SERVICE_STOP_PENDING, NO_ERROR, 0, 1, 5000);
+		signal_handler(CTRL_CLOSE_EVENT);
+		return;
+	default:
+		break;
+	}
+	UpdateSCMStatus(serviceCurrentStatus, NO_ERROR, 0, 0, 0);
+}
+#endif
+
 static TSS_RESULT
 signals_init(void)
 {
+#ifndef WIN32
 	int rc;
 	sigset_t sigmask;
 	struct sigaction sa;
@@ -104,6 +210,13 @@ signals_init(void)
 		LogError("signal SIGHUP not registered: %s", strerror(errno));
 		return TCSERR(TSS_E_INTERNAL_ERROR);
 	}
+#else
+	if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)signal_handler,TRUE)) {
+		LogError("SetConsoleCtrlHandler() failed: %s", strerror(errno));
+		return TCSERR(TSS_E_INTERNAL_ERROR);
+	}
+	return 0;
+#endif
 
 	return TSS_SUCCESS;
 }
@@ -208,47 +321,54 @@ reload_config(void)
 }
 
 
-int
-main(int argc, char **argv)
+void
+tcsd_main(int argc, char **argv)
 {
 	struct sockaddr_in serv_addr, client_addr;
-	TSS_RESULT result;
-	int sd, newsd, c, option_index = 0;
-	unsigned client_len;
+	TSS_RESULT result = TSS_SUCCESS;
+	int newsd, c;
+	socklen_t client_len;
 	char *hostname = NULL;
-	struct passwd *pwd;
 	struct hostent *client_hostent = NULL;
-	struct option long_options[] = {
-		{"help", 0, NULL, 'h'},
-		{"foreground", 0, NULL, 'f'},
-		{0, 0, 0, 0}
-	};
-
-	unsetenv("TCSD_USE_TCP_DEVICE");
-	while ((c = getopt_long(argc, argv, "fhe", long_options, &option_index)) != -1) {
-		switch (c) {
-			case 'f':
-				setenv("TCSD_FOREGROUND", "1", 1);
-				break;
-			case 'h':
-				/* fall through */
-			case 'e':
-				setenv("TCSD_USE_TCP_DEVICE", "1", 1);
-				break;
-			default:
-				usage();
-				return -1;
-				break;
+	
+#ifdef WIN32
+	BOOL success = 0;
+	WSADATA wsaData;
+
+	/* Registers ServiceCtrlHandler function to handle service control 
+	 * requests. The return value is the service status handle. */
+	if (serviceflag == 1) {
+		serviceStatusHandle = RegisterServiceCtrlHandler((LPTSTR)SERVICE_NAME,
+			(LPHANDLER_FUNCTION) ServiceCtrlHandler);
+		if (serviceStatusHandle == 0) {
+			LogError("RegisterServiceCtrlHandler() failed: %s", strerror(errno));
+			goto outlast;
 		}
 	}
 
-	if ((result = tcsd_startup()))
-		return (int)result;
+	/* SCM is notified that the service is in state START PENDING */
+	success = UpdateSCMStatus(SERVICE_START_PENDING, NO_ERROR, 0, 1, 5000);
+	if (!success) {
+		LogError("UpdateSCMStatus() failed");
+		goto outlast;
+	}
+
+	result = WSAStartup(MAKEWORD(2,2), &wsaData);
+	if(result) {
+		LogError("WSAStartup failed.");	
+		goto outlast;
+	}
+#endif
+
+	if ((result = tcsd_startup())) {
+		LogError("tcsd_startup failed: %d", result);
+		goto outlast;
+	}
 
 	sd = socket(AF_INET, SOCK_STREAM, 0);
 	if (sd < 0) {
 		LogError("Failed socket: %s", strerror(errno));
-		return -1;
+		goto out;
 	}
 
 	memset(&serv_addr, 0, sizeof (serv_addr));
@@ -266,35 +386,23 @@ main(int argc, char **argv)
 	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;
+		goto out;
 	}
-#ifndef SOLARIS
-	pwd = getpwnam(TSS_USER_NAME);
-	if (pwd == NULL) {
-		if (errno == 0) {
-			LogError("User \"%s\" not found, please add this user"
-					" manually.", TSS_USER_NAME);
-		} else {
-			LogError("getpwnam(%s): %s", TSS_USER_NAME, strerror(errno));
-		}
-		return TCSERR(TSS_E_INTERNAL_ERROR);
-	}
-	setuid(pwd->pw_uid);
-#endif
+
 	if (listen(sd, TCSD_MAX_SOCKETS_QUEUED) < 0) {
 		LogError("Failed listen: %s", strerror(errno));
-		return -1;
+		goto out;
 	}
 	client_len = (unsigned)sizeof(client_addr);
-	
-	if (getenv("TCSD_FOREGROUND") == NULL) {
-		if (daemon(0, 0) == -1) {
-			perror("daemon");
-			tcsd_shutdown();
-			return -1;
-		}
-	}
 
+#ifdef WIN32
+	/* SCM is notified that the service is still in the state RUNNING */
+	success = UpdateSCMStatus(SERVICE_RUNNING, NO_ERROR, 0, 0, 0);
+	if (!success){
+		LogError("UpdateSCMStatus() failed");
+		goto out;
+	}
+#endif
 	LogInfo("%s: TCSD up and running.", PACKAGE_STRING);
 	do {
 		newsd = accept(sd, (struct sockaddr *) &client_addr, &client_len);
@@ -318,7 +426,7 @@ main(int argc, char **argv)
 						    sizeof(client_addr.sin_addr),
 						    AF_INET)) == NULL) {
 			char buf[16];
-                        uint32_t addr = htonl(client_addr.sin_addr.s_addr);
+                        UINT32 addr = htonl(client_addr.sin_addr.s_addr);
 
                         snprintf(buf, 16, "%d.%d.%d.%d", (addr & 0xff000000) >> 24,
                                  (addr & 0x00ff0000) >> 16, (addr & 0x0000ff00) >> 8,
@@ -339,5 +447,91 @@ main(int argc, char **argv)
 	} while (term ==0);
 
 	/* To close correctly, we must receive a SIGTERM */
+out:
+	if (term != 1)
+		result = GetLastError();
+	if (sd != -1)
+		close(sd);
+	tcsd_shutdown();
+#ifdef WIN32
+	WSACleanup();
+outlast:
+	UpdateSCMStatus(SERVICE_STOPPED, result,0,0,0);
+#endif
+	return;
+} 
+
+int
+main(int argc, char **argv)
+{
+	int c, option_index = 0;
+#if (!defined SOLARIS && !defined WIN32)
+	struct passwd *pwd;
+#endif
+
+	struct option long_options[] = {
+		{"help", 0, NULL, 'h'},
+		{"foreground", 0, NULL, 'f'},
+		{0, 0, 0, 0}
+	};
+
+	unsetenv("TCSD_USE_TCP_DEVICE");
+	while ((c = getopt_long(argc, argv, "fhe", long_options, &option_index)) != -1) {
+		switch (c) {
+			case 'f':
+				setenv("TCSD_FOREGROUND", "1", 1);
+				break;
+			case 'h':
+			case 'e':
+				setenv("TCSD_USE_TCP_DEVICE", "1", 1);
+				break;
+			default:
+				usage();
+				return -1;
+				break;
+		}
+	}
+
+#if !defined SOLARIS && !defined WIN32
+	pwd = getpwnam(TSS_USER_NAME);
+	if (pwd == NULL) {
+		if (errno == 0) {
+			LogError("User \"%s\" not found, please add this user"
+					" manually.", TSS_USER_NAME);
+		} else {
+			LogError("getpwnam(%s): %s", TSS_USER_NAME, strerror(errno));
+		}
+		return TCSERR(TSS_E_INTERNAL_ERROR);
+	}
+	setuid(pwd->pw_uid);
+#endif
+	if (getenv("TCSD_FOREGROUND") == NULL) {
+#ifdef WIN32
+		SERVICE_TABLE_ENTRY serviceTable[] = {
+			{ (LPTSTR)SERVICE_NAME, (LPSERVICE_MAIN_FUNCTION)tcsd_main },
+			{ NULL, NULL } };
+		int result;
+
+		serviceflag = 1;
+
+		/* Connects the main thread of a service process to the service 
+		* control manager, which causes the thread to be the service control 
+		* dispatcher thread for the calling process (in our case the ServiceMain) 
+		* If the function succeeds, the return value is nonzero */
+		result = StartServiceCtrlDispatcher(serviceTable);
+		if (result == 0) {
+	  		LogError("StartServiceCtrlDispatcher() failed: %s", strerror(errno));
+			return -1;
+		}
+
+		return TSS_SUCCESS;
+#else
+		if (daemon(0, 0) == -1) {
+			perror("daemon");
+			return -1;
+		}
+#endif
+	}
+	tcsd_main(0, NULL);
 	return 0;
 }
diff --git a/src/tcsd/tcsd_conf.c b/src/tcsd/tcsd_conf.c
index fbb6d1a..c2cd650 100644
--- a/src/tcsd/tcsd_conf.c
+++ b/src/tcsd/tcsd_conf.c
@@ -9,18 +9,32 @@
  */
 
 
+#ifdef WIN32
+#include <ws2tcpip.h>
+#include <windows.h>
+#endif
 #include <stdio.h>
+#ifndef WIN32
 #include <pwd.h>
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <ctype.h>
 #include <string.h>
+#ifndef WIN32
 #include <strings.h>
+#endif
 #include <errno.h>
+#ifndef WIN32
 #include <grp.h>
+#endif
 #include <stdlib.h>
 
+#ifdef WIN32
+#include <direct.h>
+#include "libc_interface.h"
+#endif
 #ifdef SOLARIS
 #include <libscf.h>
 #endif
@@ -307,7 +321,7 @@ read_conf_line(char *buf, int line_num, struct tcsd_config *conf)
 	case opt_firmware_pcrs:
 		conf->unset &= ~TCSD_OPTION_FIRMWARE_PCRS;
 		while (1) {
-			comma = rindex(arg, ',');
+			comma = strrchr(arg, ',');
 
 			if (comma == NULL) {
 				if (!isdigit(*arg))
@@ -336,7 +350,7 @@ read_conf_line(char *buf, int line_num, struct tcsd_config *conf)
 	case opt_kernel_pcrs:
 		conf->unset &= ~TCSD_OPTION_KERNEL_PCRS;
 		while (1) {
-			comma = rindex(arg, ',');
+			comma = strrchr(arg, ',');
 
 			if (comma == NULL) {
 				if (!isdigit(*arg))
@@ -388,7 +402,7 @@ read_conf_line(char *buf, int line_num, struct tcsd_config *conf)
 				free(conf->system_ps_dir);
 
 			/* break out the system ps directory from the file path */
-			dir_ptr = rindex(tmp_ptr, '/');
+			dir_ptr = strrchr(tmp_ptr, '/');
 			*dir_ptr = '\0';
 			if (strlen(tmp_ptr) == 0)
 				conf->system_ps_dir = strdup("/");
@@ -537,10 +551,10 @@ read_conf_line(char *buf, int line_num, struct tcsd_config *conf)
 		break;
 	case opt_remote_ops:
 		conf->unset &= ~TCSD_OPTION_REMOTE_OPS;
-		comma = rindex(arg, '\n');
+		comma = strrchr(arg, '\n');
 		*comma = '\0';
 		while (1) {
-			comma = rindex(arg, ',');
+			comma = strrchr(arg, ',');
 
 			if (comma == NULL) {
 				comma = arg;
@@ -576,10 +590,10 @@ read_conf_line(char *buf, int line_num, struct tcsd_config *conf)
 	case opt_host_platform_class:
 		/* append the host class on the list */
 		conf->unset &= ~TCSD_OPTION_HOST_PLATFORM_CLASS;
-		comma = rindex(arg,'\n');
+		comma = strrchr(arg,'\n');
 		*comma = '\0';
 
-		comma = rindex(arg,',');
+		comma = strrchr(arg,',');
 		/* At least one comma: error - more than one host class defined */
 		if (comma != NULL) {
 			LogError("Config option \"host_platform_class\" error: more than one "
@@ -597,10 +611,10 @@ read_conf_line(char *buf, int line_num, struct tcsd_config *conf)
 		break;
 	case opt_all_platform_classes:
 		/* append each of the comma separated values on the list */
-		comma = rindex(arg, '\n');
+		comma = strrchr(arg, '\n');
 		*comma = '\0';
 		while (1) {
-			comma = rindex(arg, ',');
+			comma = strrchr(arg, ',');
 
 			if (comma == NULL) {
 				comma = arg;
@@ -706,7 +720,7 @@ conf_file_init(struct tcsd_config *conf)
 {
 	FILE *f = NULL;
 	struct stat stat_buf;
-#ifndef SOLARIS
+#if (!defined SOLARIS && !defined WIN32)
 	struct group *grp;
 	struct passwd *pw;
 	mode_t mode = (S_IRUSR|S_IWUSR);
@@ -736,7 +750,7 @@ conf_file_init(struct tcsd_config *conf)
 		}
 	}
 
-#ifndef SOLARIS
+#if (!defined SOLARIS && !defined WIN32)
 	/* find the gid that owns the conf file */
 	errno = 0;
 	grp = getgrnam(TSS_GROUP_NAME);
@@ -805,7 +819,9 @@ TSS_RESULT
 ps_dirs_init()
 {
 	struct stat stat_buf;
+#ifndef WIN32
 	mode_t mode = S_IRWXU; /* 0700 */
+#endif
 
 	/* query the key storage directory to make sure it exists and is of the right mode */
 	if (stat(tcsd_options.system_ps_dir, &stat_buf) == -1) {
@@ -832,6 +848,7 @@ ps_dirs_init()
 		return TCSERR(TSS_E_INTERNAL_ERROR);
 	}
 
+#ifndef WIN32 
 	/* tcsd_options.system_ps_dir should be a directory with mode equal to mode */
 	if (!S_ISDIR(stat_buf.st_mode)) {
 		LogError("PS dir %s is not a directory! Exiting.", tcsd_options.system_ps_dir);
@@ -846,6 +863,9 @@ ps_dirs_init()
 			return TCSERR(TSS_E_INTERNAL_ERROR);
 		}
 	}
+#else
+	
+#endif
 
 	return TSS_SUCCESS;
 }
diff --git a/src/tcsd/tcsd_threads.c b/src/tcsd/tcsd_threads.c
index a061ab9..bf7cc6e 100644
--- a/src/tcsd/tcsd_threads.c
+++ b/src/tcsd/tcsd_threads.c
@@ -11,12 +11,18 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <errno.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/socket.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
@@ -28,6 +34,12 @@
 #include "tcslog.h"
 #include "rpc_tcstp_tcs.h"
 
+#ifdef WIN32
+#include <ws2tcpip.h>
+#include <windows.h>
+#include "libc_interface.h"
+#endif
+
 struct tcsd_thread_mgr *tm = NULL;
 
 TSS_RESULT
@@ -180,6 +192,7 @@ out:
 void
 thread_signal_init()
 {
+#ifndef WIN32
 	sigset_t thread_sigmask;
 	int rc;
 
@@ -194,6 +207,7 @@ thread_signal_init()
 		LogError("worker thread %ld is exiting prematurely", THREAD_ID);
 		THREAD_EXIT(NULL);
 	}
+#endif
 }
 #if 0
 void *
@@ -450,9 +464,8 @@ tcsd_thread_run(void *v)
 	data->thread_id = THREAD_NULL;
 	pthread_mutex_unlock(&(tm->lock));
 	pthread_exit(NULL);
-#else
-	return NULL;
 #endif
+	return NULL;
 }
 
 #endif
diff --git a/src/tddl/tddl.c b/src/tddl/tddl.c
index b4f95b2..c52494f 100644
--- a/src/tddl/tddl.c
+++ b/src/tddl/tddl.c
@@ -1,4 +1,3 @@
-
 /*
  * Licensed Materials - Property of IBM
  *
@@ -9,12 +8,21 @@
  */
 
 
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <fcntl.h>
+#ifdef WIN32
+#include <ws2tcpip.h>
+#include <windows.h>
+#include "libc_interface.h"
+#endif
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
+#ifndef WIN32
 #include <sys/ioctl.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
@@ -22,6 +30,7 @@
 #include "tcslog.h"
 #include "tddl.h"
 
+#ifndef WIN32
 struct tpm_device_node tpm_device_nodes[] = {
 	{"/dev/tpm0", TDDL_UNDEF, TDDL_UNDEF},
 	{"/udev/tpm0", TDDL_UNDEF, TDDL_UNDEF},
@@ -30,11 +39,16 @@ struct tpm_device_node tpm_device_nodes[] = {
 };
 
 struct tpm_device_node *opened_device = NULL;
+#else
+struct tpm_device_node opened_device;
+int tddli_dh = -1;
+#endif
 
 BYTE txBuffer[TDDL_TXBUF_SIZE];
 TSS_BOOL use_in_socket = FALSE;
 struct tcsd_config *_tcsd_options = NULL;
 
+#ifndef WIN32
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <netinet/in.h>
@@ -116,10 +130,74 @@ open_device()
 	}
 	return fd;
 }
+#else
+TSS_RESULT open_device(const char *device_name)
+{
+	/* open the named pipe and generate a posix file handle */
+	DWORD mode = PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE;
+	HANDLE ph = CreateFile(device_name, GENERIC_READ | GENERIC_WRITE,
+				0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+	SetNamedPipeHandleState(ph, &mode, NULL, NULL);
+	tddli_dh = _open_osfhandle((DWORD)ph, O_RDWR | O_BINARY);
+	if (tddli_dh < 0)
+		return TDDLERR(TDDL_E_FAIL);
+
+	return TSS_SUCCESS;
+}
+
+TSS_RESULT send_to_tpm(BYTE* pTransmitBuf, UINT32 TransmitBufLen)
+{
+	ssize_t res;
+	res = write(tddli_dh, pTransmitBuf, TransmitBufLen);
+	if (res < 0 || (UINT32)res != TransmitBufLen) 
+		return TDDL_E_IOERROR;
+
+	return TSS_SUCCESS;
+}
+
+TSS_RESULT receive_from_tpm(BYTE* pReceiveBuf, UINT32* puntReceiveBufLen)
+{
+	ssize_t res;
+	UINT32 len;
+	if (*puntReceiveBufLen < 10)
+		return TDDL_E_INSUFFICIENT_BUFFER;
+	res = read(tddli_dh, pReceiveBuf, *puntReceiveBufLen);
+	if (res < 10)
+		return TDDL_E_IOERROR;
+	*puntReceiveBufLen = res;
+	len = ((UINT32)pReceiveBuf[2] << 24) | ((UINT32)pReceiveBuf[3] << 16)
+	      | ((UINT32)pReceiveBuf[4] << 8) | (UINT32)pReceiveBuf[5];
+	if (len != *puntReceiveBufLen)
+		return TDDL_E_INSUFFICIENT_BUFFER;
+
+	return TSS_SUCCESS;
+}
+#endif
 
 TSS_RESULT
 Tddli_Open()
 {
+#ifdef WIN32
+	HRESULT hr;
+	LPTSTR tpm_device_name = TEXT("\\\\.\\pipe\\tpmd:0"); 
+
+	if (opened_device.hContext != 0 || tddli_dh != -1) {
+		LogDebug("attempted to re-open the TPM driver!");
+		return TDDLERR(TDDL_E_ALREADY_OPENED);
+	}
+
+	opened_device.contextParams.version = TBS_CONTEXT_VERSION_ONE;
+	hr = Tbsi_Context_Create(&opened_device.contextParams,
+				 &opened_device.hContext);
+	if (FAILED(hr)) {
+		LogDebug("Failed to contact TPM Base Services, trying to connect to TPM Emulator...");
+		hr = open_device(tpm_device_name);
+		if (hr != TSS_SUCCESS) {
+			LogError("Failed to find an available TPM!");
+			return TDDLERR(TDDL_E_FAIL);
+		}
+	}
+#else
 	int rc;
 
 	if (opened_device != NULL) {
@@ -138,12 +216,27 @@ Tddli_Open()
 		return TDDLERR(TDDL_E_FAIL);
 	}
 
+#endif
 	return TSS_SUCCESS;
 }
 
 TSS_RESULT
 Tddli_Close()
 {
+#ifdef WIN32
+	if (opened_device.hContext == 0 && tddli_dh == -1) {
+		LogDebug("attempted to re-close the TPM driver!");
+		return TDDLERR(TDDL_E_ALREADY_CLOSED);
+	}
+
+	if (opened_device.hContext != 0) {
+		Tbsip_Context_Close(opened_device.hContext);
+		opened_device.hContext = 0;
+	} else {
+		close(tddli_dh);
+		tddli_dh = -1;
+	}
+#else	
 	if (opened_device == NULL) {
 		LogDebug("attempted to re-close the TPM driver!");
 		return TDDLERR(TDDL_E_ALREADY_CLOSED);
@@ -153,6 +246,7 @@ Tddli_Close()
 	opened_device->fd = TDDL_UNDEF;
 	opened_device = NULL;
 
+#endif
 	return TSS_SUCCESS;
 }
 
@@ -161,6 +255,8 @@ Tddli_TransmitData(BYTE * pTransmitBuf, UINT32 TransmitBufLen, BYTE * pReceiveBu
 		   UINT32 * pReceiveBufLen)
 {
 	int sizeResult;
+#ifdef WIN32
+	HRESULT hr;
 
 	if (TransmitBufLen > TDDL_TXBUF_SIZE) {
 		LogError("buffer size handed to TDDL is too large! (%u bytes)", TransmitBufLen);
@@ -168,6 +264,40 @@ Tddli_TransmitData(BYTE * pTransmitBuf, UINT32 TransmitBufLen, BYTE * pReceiveBu
 	}
 
 	memcpy(txBuffer, pTransmitBuf, TransmitBufLen);
+	sizeResult = sizeof(txBuffer);
+	LogDebug("Calling write to driver");
+
+	if (opened_device.hContext != 0) {
+		hr = Tbsip_Submit_Command(opened_device.hContext,
+								  TBS_COMMAND_LOCALITY_ZERO,
+								  TBS_COMMAND_PRIORITY_NORMAL,
+								  txBuffer,
+								  TransmitBufLen,
+								  txBuffer,
+								  (unsigned *)&sizeResult);
+		if (FAILED(hr)) {
+			return TDDLERR(TDDL_E_FAIL);
+		}
+
+		if ((unsigned)sizeResult > *pReceiveBufLen) {
+			return TDDLERR(TDDL_E_INSUFFICIENT_BUFFER);
+		}
+	} else if (tddli_dh != -1) {
+		hr = send_to_tpm(txBuffer, TransmitBufLen);
+		if (hr != TSS_SUCCESS)
+			return TDDLERR(TDDL_E_FAIL);
+		
+		hr = receive_from_tpm(txBuffer, (unsigned *)&sizeResult);
+		if (hr != TSS_SUCCESS)
+			return TDDLERR(TDDL_E_FAIL);
+	}
+#else
+	if (TransmitBufLen > TDDL_TXBUF_SIZE) {
+		LogError("buffer size handed to TDDL is too large! (%u bytes)", TransmitBufLen);
+		return TDDLERR(TDDL_E_FAIL);
+	}
+
+	memcpy(txBuffer, pTransmitBuf, TransmitBufLen);
 	LogDebug("Calling write to driver");
 
 	if (use_in_socket) {
@@ -227,6 +357,7 @@ Tddli_TransmitData(BYTE * pTransmitBuf, UINT32 TransmitBufLen, BYTE * pReceiveBu
 		return TDDLERR(TDDL_E_INSUFFICIENT_BUFFER);
 	}
 
+#endif
 	*pReceiveBufLen = sizeResult;
 
 	memcpy(pReceiveBuf, txBuffer, *pReceiveBufLen);
@@ -246,15 +377,101 @@ Tddli_SetCapability(UINT32 CapArea, UINT32 SubCap,
 	return TDDLERR(TSS_E_NOTIMPL);
 }
 
+#ifdef WIN32
+static TSS_RESULT cap_version(UINT32 SubCap, BYTE* pCapBuf,
+                              UINT32* puntCapBufLen)
+{
+	TSS_RESULT res;
+	UINT32 len = 18;
+	BYTE buf[18];
+
+	switch (SubCap) {
+	case TDDL_CAP_VER_DRV:
+		if (*puntCapBufLen < 4) return TDDL_E_INSUFFICIENT_BUFFER;
+		*puntCapBufLen = 4;
+		memcpy(pCapBuf, "\x01\x05\x00\x00", 4);
+		return TSS_SUCCESS;
+
+	case TDDL_CAP_VER_FW:
+		if (*puntCapBufLen < 4) return TDDL_E_INSUFFICIENT_BUFFER;
+		*puntCapBufLen = 4;
+		res = send_to_tpm((BYTE *)"\x00\xc1\x00\x00\x00\x12\x00\x00\x00\x65"
+		  "\x00\x00\x00\x06\x00\x00\x00\x00", 18);
+		if (res != TSS_SUCCESS)
+			return res;
+		res = receive_from_tpm(buf, &len);
+		if (res != TSS_SUCCESS)
+			return res;
+		if (len != 18 || (buf[6] | buf[7] | buf[8] | buf[9]) != 0)
+			return TDDL_E_FAIL;
+		memcpy(pCapBuf, &buf[14], 4);
+		return TSS_SUCCESS;
+
+	case TDDL_CAP_VER_FW_DATE:
+		/* this is not yet supported by the TPM emulator */
+		return TDDLERR(TSS_E_NOTIMPL);
+
+	default:
+		return TDDLERR(TSS_E_BAD_PARAMETER);
+	}
+}
+
+static TSS_RESULT cap_property(UINT32 SubCap, BYTE* pCapBuf,
+                               UINT32* puntCapBufLen)
+{
+	static const char *manufacturer = "Mario Strasser, ETH Zurich";
+	static const char *type = "Software-based TPM Emulator";
+
+	switch (SubCap) {
+	case TDDL_CAP_PROP_MANUFACTURER:
+		if (*puntCapBufLen < strlen(manufacturer))
+			return TDDL_E_INSUFFICIENT_BUFFER;
+		*puntCapBufLen = strlen(manufacturer);
+		memcpy(pCapBuf, manufacturer, *puntCapBufLen);
+		return TSS_SUCCESS;
+
+	case TDDL_CAP_PROP_MODULE_TYPE:
+		if (*puntCapBufLen < strlen(type)) 
+			return TDDL_E_INSUFFICIENT_BUFFER;
+		*puntCapBufLen = strlen(type);
+		memcpy(pCapBuf, type, *puntCapBufLen);
+		return TSS_SUCCESS;
+
+	default:
+		return TDDLERR(TSS_E_BAD_PARAMETER);
+	}
+}
+#endif
+
 TSS_RESULT
 Tddli_GetCapability(UINT32 CapArea, UINT32 SubCap,
 		    BYTE *pCapBuf, UINT32 *pCapBufLen)
 {
+#ifdef WIN32
+	TSS_RESULT res = TSS_SUCCESS;
+	if (tddli_dh < 0) 
+		return TDDL_E_FAIL;
+	switch (CapArea) {
+	case TDDL_CAP_VERSION:
+		res = cap_version(SubCap, pCapBuf, pCapBufLen);    
+		break;
+	case TDDL_CAP_PROPERTY:
+		res = cap_property(SubCap, pCapBuf, pCapBufLen);
+		break;
+	default:
+		res = TDDLERR(TSS_E_BAD_PARAMETER);
+	}
+	return res;
+#else
 	return TDDLERR(TSS_E_NOTIMPL);
+#endif
 }
 
 TSS_RESULT Tddli_Cancel(void)
 {
+#ifdef WIN32
+	return TSS_E_NOTIMPL;
+#else
 	int rc;
 
 	if (opened_device->transmit == TDDL_TRANSMIT_IOCTL) {
@@ -270,4 +487,5 @@ TSS_RESULT Tddli_Cancel(void)
 	} else {
 		return TDDLERR(TSS_E_NOTIMPL);
 	}
+#endif
 }
diff --git a/src/test/test.c b/src/test/test.c
new file mode 100644
index 0000000..ebe012e
--- /dev/null
+++ b/src/test/test.c
@@ -0,0 +1,484 @@
+// test.cpp : Defines the entry point for the console application.
+//
+
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include <stdlib.h>
+#include <trousers/tss.h>
+#include <trousers/trousers.h>
+
+#ifdef WIN32
+#include <windows.h>
+#include <sys/stat.h>
+#else
+#include <sys/stat.h>
+#endif
+
+#define ERR 1
+
+#ifdef RAND
+int main (int argc, char ** argv) {
+
+    TSS_HCONTEXT        hContext;
+    TSS_RESULT          result;
+    TSS_HTPM            hTPM;
+    BYTE                *rand;
+	int i, j;
+    
+    TSS_UUID SRK_UUID = TSS_UUID_SRK;
+
+    result = Tspi_Context_Create( &hContext );
+    if ( result != TSS_SUCCESS )
+    {
+        printf( "ERR - Tspi_Context_Create");
+        Tspi_Context_FreeMemory( hContext, NULL );
+        Tspi_Context_Close( hContext );
+        exit (ERR);
+    }
+
+    result = Tspi_Context_Connect( hContext, NULL );
+    if ( result != TSS_SUCCESS )
+    {
+        printf( "ERR - Tspi_Context_Connect");
+        Tspi_Context_FreeMemory( hContext, NULL );
+        Tspi_Context_Close( hContext );
+        exit (ERR);
+    }
+    
+    result = Tspi_Context_GetTpmObject( hContext, &hTPM );
+    if ( result != TSS_SUCCESS )
+    {
+        printf( "ERR - Tspi_Context_GetTpmObject");
+        Tspi_Context_FreeMemory( hContext, NULL );
+        Tspi_Context_Close( hContext );
+        exit (ERR);
+    }
+
+    for( i=0; i<2; i++ )
+    {
+        for( j=0; j<6; j++ )
+        {
+            result = Tspi_TPM_GetRandom( hTPM, 1, &rand );
+            if ( result != TSS_SUCCESS )
+            {
+                printf( "ERR - Tspi_Context_GetTpmObject");
+                Tspi_Context_FreeMemory( hContext, NULL );
+                Tspi_Context_Close( hContext );
+                exit (ERR);
+            }
+            printf("%d ", (*rand%90)+1 );
+        }
+        printf("\n");    
+    }
+        
+    /* Clean */
+	Tspi_Context_CloseObject( hContext, hTPM );
+    Tspi_Context_FreeMemory( hContext, NULL );
+    Tspi_Context_Close( hContext );
+
+    return 0;
+}
+#endif
+
+
+#ifdef CREATEKEY
+int main(int argc, char **argv)
+{
+	TSS_HCONTEXT hContext;
+	TSS_HPOLICY  hPolicySRK ;
+	TSS_HKEY     hSrk;
+	TSS_HKEY     hKey;	
+	TSS_RESULT   result;
+	char srkpwd[50];
+	int srkpwdlen= 0;
+	TSS_UUID SRK_UUID=TSS_UUID_SRK;
+	BYTE *keyblob = NULL;
+	UINT32 keylen = 0;
+	int fp;
+	TSS_FLAG keyFlags = TSS_KEY_TYPE_STORAGE | TSS_KEY_SIZE_2048
+			| TSS_KEY_VOLATILE | TSS_KEY_AUTHORIZATION | TSS_KEY_NOT_MIGRATABLE;
+	
+	result = Tspi_Context_Create(&hContext);
+	if (result != TSS_SUCCESS) {
+		printf("Error: Tspi_Context_Create returned %d\n", result);
+		exit(result);
+	}
+	
+	result = Tspi_Context_Connect(hContext,NULL);
+	if (result != TSS_SUCCESS) {
+		printf("Error: Tspi_Context_Connect returned %d)\n", result);
+		Tspi_Context_FreeMemory(hContext, NULL);                 
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}	
+	
+	if((result = Tspi_Context_LoadKeyByUUID(hContext, TSS_PS_TYPE_SYSTEM, SRK_UUID, &hSrk)) != 0) {
+		printf("LoadKeyByUUID(): res: %d\n", result);
+		Tspi_Context_FreeMemory(hContext, NULL);
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}
+	
+	result = Tspi_GetPolicyObject(hSrk, TSS_POLICY_USAGE, &hPolicySRK);
+	if (result != TSS_SUCCESS)
+	{
+		printf("Error: Tspi_GetPolicyObject returned %d\n", result);
+		Tspi_Context_FreeMemory(hContext, NULL);
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}
+		
+	/* Set password */	
+	printf("Insert the TPM SRK password: ");
+	scanf("%s", srkpwd);
+	srkpwdlen = strlen(srkpwd);
+
+	result = Tspi_Policy_SetSecret(hPolicySRK, TSS_SECRET_MODE_PLAIN, srkpwdlen, (BYTE *)srkpwd);
+	if (result != TSS_SUCCESS)
+	{
+		printf("Error: Tspi_Policy_SetSecret returned %d\n", result);
+		Tspi_Context_FreeMemory(hContext, NULL);
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}
+	
+	result = Tspi_Context_CreateObject(hContext,TSS_OBJECT_TYPE_RSAKEY, keyFlags, &hKey); 
+	if (result != 0)
+	{
+		printf("Error: Tspi_GetPolicyObject returned %d\n", result);
+		Tspi_Context_FreeMemory(hContext, NULL);
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}
+	
+/*	if((result = Tspi_SetAttribUint32(hKey, TSS_TSPATTRIB_KEY_INFO, TSS_TSPATTRIB_KEYINFO_USAGE, TSS_KEYUSAGE_BIND))!= 0) {
+		printf("Tspi_SetAttribUint32(): res: %d\n", result);
+		Tspi_Context_FreeMemory(hContext, NULL);
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}*/
+	
+	if((result = Tspi_Key_CreateKey(hKey, hSrk, 0))!= 0) {
+		printf("CreateKey(): res: %d\n", result);
+		Tspi_Context_FreeMemory(hContext, NULL);
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}	
+	
+	printf("Result: %d\n", result);
+	Tspi_GetAttribData(hKey, TSS_TSPATTRIB_KEY_BLOB, TSS_TSPATTRIB_KEYBLOB_BLOB, &keylen, &keyblob);
+#ifdef WIN32
+	if((fp=open("key", O_WRONLY | O_CREAT | O_BINARY, 0600))<0)
+#else
+	if((fp=open("key", O_WRONLY | O_CREAT, 0600))<0)
+#endif
+		goto end_create;
+
+	write(fp, (char *)keyblob, keylen);
+	close(fp);
+
+end_create:
+	Tspi_Key_UnloadKey(hKey);
+	Tspi_Key_UnloadKey(hSrk);
+	Tspi_Context_CloseObject(hContext,hKey);
+	Tspi_Context_CloseObject(hContext,hSrk);
+	Tspi_Context_CloseObject(hContext,hPolicySRK);
+	Tspi_Context_Close(hContext);
+	
+	return result;
+}
+
+#endif
+
+#ifdef LOADKEY
+
+int createkey2(TSS_HCONTEXT hContext, TSS_HKEY hParent)
+{
+	TSS_RESULT   result;
+	char srkpwd[50];
+	int srkpwdlen= 0;
+	TSS_UUID SRK_UUID=TSS_UUID_SRK;
+	BYTE *keyblob = NULL;
+	UINT32 keylen = 0;
+	int fp;
+	TSS_HKEY hKey;
+	
+	TSS_FLAG keyFlags = TSS_KEY_TYPE_BIND | TSS_KEY_SIZE_2048  | \
+									 TSS_KEY_VOLATILE | TSS_KEY_AUTHORIZATION  | \
+									 TSS_KEY_NOT_MIGRATABLE;
+
+	
+		
+	/* Set password */	
+/*	printf("Insert the TPM SRK password: ");
+	scanf("%s", srkpwd);
+	srkpwdlen = strlen(srkpwd);
+
+	result = Tspi_Policy_SetSecret(hPolicySRK, TSS_SECRET_MODE_PLAIN, srkpwdlen, (BYTE *)srkpwd);
+	if (result != TSS_SUCCESS)
+	{
+		printf("Error: Tspi_Policy_SetSecret returned %d\n", result);
+		Tspi_Context_FreeMemory(hContext, NULL);
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}
+*/	
+	result = Tspi_Context_CreateObject(hContext,TSS_OBJECT_TYPE_RSAKEY, keyFlags, &hKey); 
+	if (result != 0)
+	{
+		printf("Error: Tspi_GetPolicyObject returned %d(%s)\n", result, Trspi_Error_String(result));
+		Tspi_Context_FreeMemory(hContext, NULL);
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}
+	
+/*	if((result = Tspi_SetAttribUint32(hKey, TSS_TSPATTRIB_KEY_INFO, TSS_TSPATTRIB_KEYINFO_USAGE, TSS_KEYUSAGE_BIND))!= 0) {
+		printf("Tspi_SetAttribUint32(): res: %d\n", result);
+		Tspi_Context_FreeMemory(hContext, NULL);
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}*/
+	
+	if((result = Tspi_Key_CreateKey(hKey, hParent, 0))!= 0) {
+		printf("CreateKey(): res: %d(%s)\n", result, Trspi_Error_String(result));
+		Tspi_Context_FreeMemory(hContext, NULL);
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}	
+	
+	printf("Result: %d(%s)\n", result, Trspi_Error_String(result));
+	Tspi_GetAttribData(hKey, TSS_TSPATTRIB_KEY_BLOB, TSS_TSPATTRIB_KEYBLOB_BLOB, &keylen, &keyblob);
+#ifdef WIN32
+	if((fp=open("key2", O_WRONLY | O_CREAT | O_BINARY, 0600))<0)
+#else
+	if((fp=open("key2", O_WRONLY | O_CREAT, 0600))<0)
+#endif
+		goto end_create;
+
+	write(fp, (char *)keyblob, keylen);
+	close(fp);
+
+end_create:
+	Tspi_Key_UnloadKey(hKey);
+	Tspi_Context_CloseObject(hContext,hKey);
+
+	return result;
+}
+
+int main(int argc, char **argv)
+{
+	TSS_HCONTEXT hContext;
+	TSS_HPOLICY  hPolicySRK ;
+	TSS_HKEY     hSrk;
+	TSS_HKEY     hKey;	
+	TSS_RESULT   result;
+	char srkpwd[50];
+	int srkpwdlen= 0;
+	TSS_UUID SRK_UUID=TSS_UUID_SRK;
+	BYTE *keyblob = NULL;
+	UINT32 keylen = 0;
+	int fp;
+	struct stat st;
+	
+	result = Tspi_Context_Create(&hContext);
+	if (result != TSS_SUCCESS) {
+		printf("Error: Tspi_Context_Create returned %d(%s)\n", result, Trspi_Error_String(result));
+		exit(result);
+	}
+	
+	result = Tspi_Context_Connect(hContext,NULL);
+	if (result != TSS_SUCCESS) {
+		printf("Error: Tspi_Context_Connect returned %d(%s)\n", result, Trspi_Error_String(result));
+		Tspi_Context_FreeMemory(hContext, NULL);                 
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}	
+	
+	if((result = Tspi_Context_LoadKeyByUUID(hContext, TSS_PS_TYPE_SYSTEM, SRK_UUID, &hSrk)) != 0) {
+		printf("LoadKeyByUUID(): res: %d\n", result);
+		Tspi_Context_FreeMemory(hContext, NULL);
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}
+	
+	result = Tspi_GetPolicyObject(hSrk, TSS_POLICY_USAGE, &hPolicySRK);
+	if (result != TSS_SUCCESS)
+	{
+		printf("Error: Tspi_GetPolicyObject returned %d(%s)\n", result, Trspi_Error_String(result));
+		Tspi_Context_FreeMemory(hContext, NULL);
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}
+		
+	/* Set password */	
+	printf("Insert the TPM SRK password: ");
+	scanf("%s", srkpwd);
+	srkpwdlen = strlen(srkpwd);
+
+	result = Tspi_Policy_SetSecret(hPolicySRK, TSS_SECRET_MODE_PLAIN, srkpwdlen, (BYTE *)srkpwd);
+	if (result != TSS_SUCCESS)
+	{
+		printf("Error: Tspi_Policy_SetSecret returned %d(%s)\n", result, Trspi_Error_String(result));
+		Tspi_Context_FreeMemory(hContext, NULL);
+		Tspi_Context_Close(hContext);
+		exit(result);
+	}
+
+	stat("key", &st);
+	keylen = st.st_size;
+	keyblob=calloc(keylen, sizeof(BYTE));
+#ifdef WIN32	
+	if((fp=open("key", O_RDONLY | O_BINARY))<0)
+#else
+	if((fp=open("key", O_RDONLY))<0)
+#endif
+		goto end_load;
+
+	read(fp, (char *)keyblob, keylen);
+	close(fp);
+
+	if((result=Tspi_Context_LoadKeyByBlob(hContext, hSrk, keylen, keyblob, &hKey))!= 0) {
+		printf("LoadKeyByBlob(): res: %d(%s)\n", result), Trspi_Error_String(result);
+		goto end_load;
+	}
+
+	printf("Result: %d(%s)\n", result, Trspi_Error_String(result));
+
+	createkey2(hContext, hKey);
+
+end_load:
+	Tspi_Key_UnloadKey(hKey);
+	Tspi_Key_UnloadKey(hSrk);
+	Tspi_Context_CloseObject(hContext,hKey);
+	Tspi_Context_CloseObject(hContext,hSrk);
+	Tspi_Context_CloseObject(hContext,hPolicySRK);
+	Tspi_Context_Close(hContext);
+	
+	return result;
+
+
+
+}
+#endif
+
+#ifdef TAKE_OWNERSHIP
+int main (int argc, char ** argv) {
+
+    TSS_HCONTEXT        hContext;
+    TSS_RESULT          result;
+    TSS_HTPM            hTPM;
+	TSS_HPOLICY			hPolicy;	
+	TSS_HPOLICY			hPolicy1;
+	char				secret_owner[50] = {0};
+	char				secret_srk[50] = {0};
+	int					secret_owner_len = 0;
+	int					secret_srk_len = 0;
+	TSS_FLAG			keyFlags = TSS_KEY_TSP_SRK | TSS_KEY_AUTHORIZATION;
+    TSS_HKEY			hSRK;
+
+    TSS_UUID SRK_UUID = TSS_UUID_SRK;
+
+	/* Be careful with scanf!! Buffer Overflow!!! :-) */
+	printf("Insert the TPM Owner password: ");
+	scanf("%s", secret_owner);
+	secret_owner_len = strlen(secret_owner);
+
+	printf("Insert the TPM SRK password: ");
+	scanf("%s", secret_srk);
+	secret_srk_len = strlen(secret_srk);
+
+    result = Tspi_Context_Create( &hContext );
+    if ( result != TSS_SUCCESS )
+    {
+        printf( "ERR - Tspi_Context_Create");
+        Tspi_Context_FreeMemory( hContext, NULL );
+        Tspi_Context_Close( hContext );
+        exit (ERR);
+    }
+
+    result = Tspi_Context_Connect( hContext, NULL );
+    if ( result != TSS_SUCCESS )
+    {
+        printf( "ERR - Tspi_Context_Connect");
+        Tspi_Context_FreeMemory( hContext, NULL );
+        Tspi_Context_Close( hContext );
+        exit (ERR);
+    }
+    
+    result = Tspi_Context_GetTpmObject( hContext, &hTPM );
+    if ( result != TSS_SUCCESS )
+    {
+        printf( "ERR - Tspi_Context_GetTpmObject");
+        Tspi_Context_FreeMemory( hContext, NULL );
+        Tspi_Context_Close( hContext );
+        exit (ERR);
+    }
+
+	result = Tspi_GetPolicyObject(hTPM, TSS_POLICY_USAGE, &hPolicy);
+	if (result != TSS_SUCCESS) {
+        printf( "ERR - Tspi_GetPolicyObject");
+        Tspi_Context_FreeMemory( hContext, NULL );
+        Tspi_Context_Close( hContext );
+        exit (ERR);
+	}
+
+	result = Tspi_Policy_SetSecret(hPolicy, TSS_SECRET_MODE_PLAIN,
+			secret_owner_len, (BYTE*)secret_owner);
+	if (result != TSS_SUCCESS) {
+        printf( "ERR - Tspi_Policy_SetSecret");
+        Tspi_Context_FreeMemory( hContext, NULL );
+        Tspi_Context_Close( hContext );
+        exit (ERR);
+	}
+
+	result = Tspi_Context_CreateObject(hContext,
+			TSS_OBJECT_TYPE_RSAKEY, keyFlags, &hSRK);
+	if (result != TSS_SUCCESS) {
+		printf( "ERR - Tspi_Context_CreateObject");
+        Tspi_Context_FreeMemory( hContext, NULL );
+        Tspi_Context_Close( hContext );
+        exit (ERR);
+	}
+
+	result = Tspi_Context_CreateObject(hContext,
+			TSS_OBJECT_TYPE_POLICY, TSS_POLICY_USAGE, &hPolicy1);
+	if (result != TSS_SUCCESS) {
+		printf( "ERR - Tspi_Context_CreateObject");
+        Tspi_Context_FreeMemory( hContext, NULL );
+        Tspi_Context_Close( hContext );
+        exit (ERR);
+	}
+
+	result = Tspi_Policy_SetSecret(hPolicy1, TSS_SECRET_MODE_PLAIN,
+		secret_srk_len, (BYTE *)secret_srk);
+	if (result != TSS_SUCCESS) {
+		printf( "ERR - Tspi_Policy_SetSecret");
+        Tspi_Context_FreeMemory( hContext, NULL );
+        Tspi_Context_Close( hContext );
+        exit (ERR);
+	}
+
+	result = Tspi_Policy_AssignToObject(hPolicy1, hSRK);
+	if (result != TSS_SUCCESS) {
+		printf( "ERR - Tspi_Policy_AssignToObject");
+        Tspi_Context_FreeMemory( hContext, NULL );
+        Tspi_Context_Close( hContext );
+        exit (ERR);
+	}
+
+	result = Tspi_TPM_TakeOwnership(hTPM, hSRK, (TSS_HKEY)NULL);
+	if (result != TSS_SUCCESS) {
+		printf( "ERR - Tspi_TPM_TakeOwnership or Ownership already taken");
+        goto end;
+	}
+
+end:
+	Tspi_Context_CloseObject(hContext,hTPM);
+	Tspi_Context_CloseObject(hContext,hSRK);
+	Tspi_Context_CloseObject(hContext,hPolicy);
+	Tspi_Context_CloseObject(hContext,hPolicy1);
+	Tspi_Context_Close(hContext);
+}
+#endif
diff --git a/src/trspi/Makefile.am b/src/trspi/Makefile.am
index 300e492..dac2ed8 100644
--- a/src/trspi/Makefile.am
+++ b/src/trspi/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES=libtrousers.la
 
 libtrousers_la_SOURCES=trousers.c crypto/@CRYPTO_PACKAGE@/hash.c
-libtrousers_la_CFLAGS=-DAPPID=\"TSPI\" -I${top_srcdir}/src/include
+libtrousers_la_CFLAGS=-DAPPID=\"TSPI\" -I${top_srcdir}/src/include -DTRSPDLL_EXPORTS
 
 if TSS_BUILD_ASYM_CRYPTO
 libtrousers_la_SOURCES+=crypto/@CRYPTO_PACKAGE@/rsa.c
diff --git a/src/trspi/trousers.c b/src/trspi/trousers.c
index e4007a8..d53ee91 100644
--- a/src/trspi/trousers.c
+++ b/src/trspi/trousers.c
@@ -9,13 +9,24 @@
  */
 
 
+#ifdef WIN32
+#include <ws2tcpip.h>
+#include <windows.h>
+#include "libc_interface.h"
+#define inline __inline
+#define BSD_CONST
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/mman.h>
 #include <langinfo.h>
+#endif
 #include <iconv.h>
 #include <wchar.h>
 #include <errno.h>
@@ -1231,7 +1242,7 @@ Trspi_LoadBlob_BOUND_DATA(UINT64 *offset, TCPA_BOUND_DATA bd, UINT32 payloadLeng
 }
 
 /* function to mimic strerror with TSS error codes */
-char *
+TRSPICALL char *
 Trspi_Error_String(TSS_RESULT r)
 {
 	/* Check the return code to see if it is common to all layers.
@@ -1450,7 +1461,7 @@ Trspi_Error_String(TSS_RESULT r)
 	}
 }
 
-char *
+TRSPICALL char *
 Trspi_Error_Layer(TSS_RESULT r)
 {
 	switch (TSS_ERROR_LAYER(r)) {
@@ -1462,7 +1473,7 @@ Trspi_Error_Layer(TSS_RESULT r)
 	}
 }
 
-TSS_RESULT
+TRSPICALL TSS_RESULT
 Trspi_Error_Code(TSS_RESULT r)
 {
 	return TSS_ERROR_CODE(r);
@@ -1508,6 +1519,7 @@ char_width(char *codeset)
 }
 
 #define MAX_BUF_SIZE	4096
+#define CODESET_LENGTH 	13
 
 BYTE *
 Trspi_Native_To_UNICODE(BYTE *string, unsigned *size)
@@ -1517,16 +1529,31 @@ Trspi_Native_To_UNICODE(BYTE *string, unsigned *size)
 	unsigned len = 0, tmplen;
 	iconv_t cd = 0;
 	size_t rc, outbytesleft, inbytesleft;
+#ifdef WIN32
+	static char buf[CODESET_LENGTH];
+	char *codeset;
+
+	snprintf (buf, CODESET_LENGTH, "CP%u", GetACP ());
+	codeset = buf;
+#endif
 
 	if (string == NULL)
 		goto alloc_string;
 
+#ifdef WIN32
+	if ((cd = iconv_open("UTF-16LE", codeset)) == (iconv_t)-1) {
+#else
 	if ((cd = iconv_open("UTF-16LE", nl_langinfo(CODESET))) == (iconv_t)-1) {
+#endif
 		LogDebug("iconv_open: %s", strerror(errno));
 		return NULL;
 	}
 
+#ifdef WIN32
+	if ((tmplen = hacky_strlen(codeset, string)) == 0) {
+#else
 	if ((tmplen = hacky_strlen(nl_langinfo(CODESET), string)) == 0) {
+#endif
 		LogDebug("hacky_strlen returned 0");
 		goto alloc_string;
 	}
@@ -1576,14 +1603,24 @@ Trspi_UNICODE_To_Native(BYTE *string, unsigned *size)
 	unsigned len = 0, tmplen;
 	iconv_t cd;
 	size_t rc, outbytesleft, inbytesleft;
+#ifdef WIN32
+	static char buf[CODESET_LENGTH];
+	char *codeset;
+
+	snprintf (buf, CODESET_LENGTH, "CP%u", GetACP());
+	codeset = buf;
+#endif
 
 	if (string == NULL) {
 		if (size)
 			*size = 0;
 		return NULL;
 	}
-
+#ifdef WIN32
+	if ((cd = iconv_open(codeset, "UTF-16LE")) == (iconv_t)-1) {
+#else
 	if ((cd = iconv_open(nl_langinfo(CODESET), "UTF-16LE")) == (iconv_t)-1) {
+#endif
 		LogDebug("iconv_open: %s", strerror(errno));
 		return NULL;
 	}
@@ -1605,7 +1642,11 @@ Trspi_UNICODE_To_Native(BYTE *string, unsigned *size)
 	} while (rc == (size_t)-1 && errno == E2BIG);
 
 	/* add terminating bytes of the correct width */
+#ifdef WIN32
+	len += char_width(codeset);
+#else
 	len += char_width(nl_langinfo(CODESET));
+#endif
 	if (len > MAX_BUF_SIZE) {
 		LogDebug("string too long.");
 		iconv_close(cd);
diff --git a/src/tspi/Makefile.am b/src/tspi/Makefile.am
index 89fc011..94fce22 100644
--- a/src/tspi/Makefile.am
+++ b/src/tspi/Makefile.am
@@ -1,7 +1,13 @@
 lib_LTLIBRARIES=libtspi.la
 
+#noinst_DATA = libtspi.dll libtspi.dll.a libtspi.def
+
 libtspi_la_LIBADD=${top_builddir}/src/trspi/libtrousers.la
 
+if OS_WIN32
+libtspi_la_LIBADD+=${top_builddir}/src/win32/libc_interface.la
+endif
+
 # On setting -version-info, from the libtool manual:
 #
 # -version-info current:revision:age
@@ -17,9 +23,13 @@ libtspi_la_LIBADD=${top_builddir}/src/trspi/libtrousers.la
 # 5. If any interfaces have been added since the last public release, then increment age.
 # 6. If any interfaces have been removed since the last public release, then set age to 0.
 
-libtspi_la_LDFLAGS=-version-info 2:3:1 -lpthread @CRYPTOLIB@
+libtspi_la_LDFLAGS=-version-info 2:3:1 -lpthread @CRYPTOLIB@ @EXTRATSPLIB@
+
+if OS_WIN32
+libtspi_la_LDFLAGS+=-no-undefined 
+endif
 
-libtspi_la_CFLAGS=-I$(top_srcdir)/src/include -DAPPID=\"TSPI\" -DVAR_PREFIX=\"@localstatedir@\" -DETC_PREFIX=\"@sysconfdir@\"
+libtspi_la_CFLAGS=-I$(top_srcdir)/src/include -DAPPID=\"TSPI\" -DVAR_PREFIX=\"@localstatedir@\" -DETC_PREFIX=\"@sysconfdir@\" -DTSPDLL_EXPORTS -DTRSP_STATIC
 
 libtspi_la_SOURCES=log.c \
                    spi_utils.c \
diff --git a/src/tspi/gtk/interface.c b/src/tspi/gtk/interface.c
index c295beb..ce54bbf 100644
--- a/src/tspi/gtk/interface.c
+++ b/src/tspi/gtk/interface.c
@@ -18,7 +18,9 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <string.h>
 #include <stdio.h>
 
diff --git a/src/tspi/gtk/support.c b/src/tspi/gtk/support.c
index 6ce3870..b03389f 100644
--- a/src/tspi/gtk/support.c
+++ b/src/tspi/gtk/support.c
@@ -18,7 +18,9 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <string.h>
 #include <stdio.h>
 
diff --git a/src/tspi/obj_context.c b/src/tspi/obj_context.c
index cb2091e..2c0f49d 100644
--- a/src/tspi/obj_context.c
+++ b/src/tspi/obj_context.c
@@ -910,7 +910,7 @@ do_transport_decryption(TPM_TRANSPORT_PUBLIC *transPub,
 	UINT32 i, decLen;
 	UINT32 seedLen, ivLen;
 	BYTE *dec;
-	BYTE seed[(2 * sizeof(TPM_NONCE)) + strlen("out") + TPM_SHA1_160_HASH_LEN];
+	BYTE *seed;
 
 	/* allocate the most data anyone below might need */
 	decLen = inLen;//((inLen / TSS_MAX_SYM_BLOCK_SIZE) + 1) * TSS_MAX_SYM_BLOCK_SIZE;
@@ -919,6 +919,13 @@ do_transport_decryption(TPM_TRANSPORT_PUBLIC *transPub,
 		return TSPERR(TSS_E_OUTOFMEMORY);
 	}
 
+	seedLen = (2 * sizeof(TPM_NONCE)) + strlen("out") + TPM_SHA1_160_HASH_LEN;
+	if ((seed = malloc(seedLen + 1)) == NULL) {
+		LogError("malloc of %u bytes failed", seedLen);
+		free(dec);
+		return TSPERR(TSS_E_OUTOFMEMORY);
+	}
+
 	/* set the common 3 initial values of 'seed', which is used to generate either the IV or
 	 * mask */
 	memcpy(seed, pTransAuth->NonceEven.nonce, sizeof(TPM_NONCE));
@@ -934,10 +941,8 @@ do_transport_decryption(TPM_TRANSPORT_PUBLIC *transPub,
 		/* add the secret data to the seed for MGF1 */
 		memcpy(&seed[2 * sizeof(TPM_NONCE) + strlen("out")], secret, TPM_SHA1_160_HASH_LEN);
 
-		if ((result = Trspi_MGF1(TSS_HASH_SHA1, seedLen, seed, decLen, dec))) {
-			free(dec);
-			return result;
-		}
+		if ((result = Trspi_MGF1(TSS_HASH_SHA1, seedLen, seed, decLen, dec)))
+			goto fail;
 
 		for (i = 0; i < inLen; i++)
 			dec[i] ^= in[i];
@@ -950,17 +955,13 @@ do_transport_decryption(TPM_TRANSPORT_PUBLIC *transPub,
 		ivLen = TSS_MAX_SYM_BLOCK_SIZE;
 		seedLen = (2 * sizeof(TPM_NONCE)) + strlen("out");
 
-		if ((result = Trspi_MGF1(TSS_HASH_SHA1, seedLen, seed, ivLen, iv))) {
-			free(dec);
-			return result;
-		}
+		if ((result = Trspi_MGF1(TSS_HASH_SHA1, seedLen, seed, ivLen, iv)))
+			goto fail;
 
 		/* use the secret data as the key for AES */
 		if ((result = Trspi_SymEncrypt(transPub->algId, transPub->encScheme, secret, iv, in,
-					       inLen, dec, &decLen))) {
-			free(dec);
-			return result;
-		}
+					       inLen, dec, &decLen)))
+			goto fail;
 
 		break;
 	}
@@ -973,6 +974,11 @@ do_transport_decryption(TPM_TRANSPORT_PUBLIC *transPub,
 
 	*out = dec;
 	*outLen = decLen;
+	return TSS_SUCCESS;
+
+fail:
+	free(dec);
+	free(seed);
 
 	return result;
 }
@@ -989,8 +995,8 @@ do_transport_encryption(TPM_TRANSPORT_PUBLIC *transPub,
 	TSS_RESULT result;
 	UINT32 i, encLen;
 	UINT32 seedLen, ivLen;
-	BYTE *enc;
-	BYTE seed[(2 * sizeof(TPM_NONCE)) + strlen("in") + TPM_SHA1_160_HASH_LEN];
+	BYTE *enc = NULL;
+	BYTE *seed = NULL;
 
 	/* allocate the most data anyone below might need */
 	encLen = ((inLen / TSS_MAX_SYM_BLOCK_SIZE) + 1) * TSS_MAX_SYM_BLOCK_SIZE;
@@ -999,6 +1005,13 @@ do_transport_encryption(TPM_TRANSPORT_PUBLIC *transPub,
 		return TSPERR(TSS_E_OUTOFMEMORY);
 	}
 
+	seedLen = (2 * sizeof(TPM_NONCE)) + strlen("in") + TPM_SHA1_160_HASH_LEN;
+	if ((seed = malloc(seedLen + 1)) == NULL) {
+		LogError("malloc of %u bytes failed", seedLen);
+		free(enc);
+		return TSPERR(TSS_E_OUTOFMEMORY);
+	}
+
 	/* set the common 3 initial values of 'seed', which is used to generate either the IV or
 	 * mask */
 	memcpy(seed, pTransAuth->NonceEven.nonce, sizeof(TPM_NONCE));
@@ -1014,10 +1027,8 @@ do_transport_encryption(TPM_TRANSPORT_PUBLIC *transPub,
 		/* add the secret data to the seed for MGF1 */
 		memcpy(&seed[2 * sizeof(TPM_NONCE) + strlen("in")], secret, TPM_SHA1_160_HASH_LEN);
 
-		if ((result = Trspi_MGF1(TSS_HASH_SHA1, seedLen, seed, encLen, enc))) {
-			free(enc);
-			return result;
-		}
+		if ((result = Trspi_MGF1(TSS_HASH_SHA1, seedLen, seed, encLen, enc)))
+			goto fail;
 
 		for (i = 0; i < inLen; i++)
 			enc[i] ^= in[i];
@@ -1030,30 +1041,31 @@ do_transport_encryption(TPM_TRANSPORT_PUBLIC *transPub,
 		ivLen = TSS_MAX_SYM_BLOCK_SIZE;
 		seedLen = (2 * sizeof(TPM_NONCE)) + strlen("in");
 
-		if ((result = Trspi_MGF1(TSS_HASH_SHA1, seedLen, seed, ivLen, iv))) {
-			free(enc);
-			return result;
-		}
+		if ((result = Trspi_MGF1(TSS_HASH_SHA1, seedLen, seed, ivLen, iv)))
+			goto fail;
 
 		/* use the secret data as the key for AES */
 		if ((result = Trspi_SymEncrypt(transPub->algId, transPub->encScheme, secret, iv, in,
-					       inLen, enc, &encLen))) {
-			free(enc);
-			return result;
-		}
+					       inLen, enc, &encLen)))
+			goto fail;
 
 		break;
 	}
 	default:
 		LogDebug("Unknown algorithm for encrypted transport session: 0x%x",
 			 transPub->algId);
-		free(enc);
-		return TSPERR(TSS_E_INTERNAL_ERROR);
+		result = TSPERR(TSS_E_INTERNAL_ERROR);
+		goto fail;
 	}
 
 	*out = enc;
 	*outLen = encLen;
 
+	return TSS_SUCCESS;
+fail:
+	free(enc);
+	free(seed);
+
 	return result;
 }
 
diff --git a/src/tspi/obj_policy.c b/src/tspi/obj_policy.c
index f19a02f..e76681b 100644
--- a/src/tspi/obj_policy.c
+++ b/src/tspi/obj_policy.c
@@ -302,6 +302,25 @@ done:
 }
 
 TSS_RESULT
+obj_policy_is_secret_set(TSS_HPOLICY hPolicy, TSS_BOOL *secretSet) 
+{
+	struct tsp_object *obj;
+	struct tr_policy_obj *policy;
+	TSS_RESULT result = TSS_SUCCESS;
+
+	if ((obj = obj_list_get_obj(&policy_list, hPolicy)) == NULL)
+		return TSPERR(TSS_E_INVALID_HANDLE);
+
+	policy = (struct tr_policy_obj *)obj->data;
+	
+	*secretSet = policy->SecretSet;
+	obj_list_put(&policy_list);
+	
+	return result;
+}
+	
+
+TSS_RESULT
 obj_policy_set_secret(TSS_HPOLICY hPolicy, TSS_FLAG mode, UINT32 size, BYTE *data)
 {
 	TCPA_DIGEST digest;
diff --git a/src/tspi/obj_rsakey.c b/src/tspi/obj_rsakey.c
index 1a0e0be..6dd664e 100644
--- a/src/tspi/obj_rsakey.c
+++ b/src/tspi/obj_rsakey.c
@@ -9,11 +9,17 @@
  */
 
 
+#ifdef WIN32
+#include <windows.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
+
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/obj_tpm.c b/src/tspi/obj_tpm.c
index 962fd51..189b296 100644
--- a/src/tspi/obj_tpm.c
+++ b/src/tspi/obj_tpm.c
@@ -9,6 +9,9 @@
  */
 
 
+#ifdef WIN32
+#include <windows.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
diff --git a/src/tspi/ps/ps_utils.c b/src/tspi/ps/ps_utils.c
index aac40a1..34e4f79 100644
--- a/src/tspi/ps/ps_utils.c
+++ b/src/tspi/ps/ps_utils.c
@@ -9,9 +9,15 @@
  */
 
 
+#ifdef WIN32
+#include <ws2tcpip.h>
+#include <windows.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <string.h>
 #include <errno.h>
 
@@ -21,6 +27,9 @@
 #include "spi_utils.h"
 #include "tspps.h"
 #include "tsplog.h"
+#ifdef WIN32
+#include "libc_interface.h"
+#endif
 
 inline TSS_RESULT
 read_data(int fd, void *data, UINT32 size)
diff --git a/src/tspi/ps/tspps.c b/src/tspi/ps/tspps.c
index 9dfc16d..244ad97 100644
--- a/src/tspi/ps/tspps.c
+++ b/src/tspi/ps/tspps.c
@@ -9,19 +9,34 @@
  */
 
 
+#ifdef WIN32
+#include <ws2tcpip.h>
+#include <windows.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <errno.h>
+#ifndef WIN32
 #include <pwd.h>
+#endif
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/file.h>
 #include <sys/stat.h>
+#else
+#include <sys/stat.h>
+#include <direct.h>
+#endif
 #include <assert.h>
 #include <fcntl.h>
 #include <limits.h>
+#ifndef WIN32
 #include <netdb.h>
+#endif
 #if defined (HAVE_BYTEORDER_H)
 #include <sys/byteorder.h>
 #elif defined(HAVE_ENDIAN_H)
@@ -42,6 +57,11 @@
 #include "spi_utils.h"
 #include "tspps.h"
 #include "tsplog.h"
+#ifdef WIN32
+#include "flock.h"
+#include "win32dep.h"
+#include "libc_interface.h"
+#endif
 
 static int user_ps_fd = -1;
 static MUTEX_DECLARE_INIT(user_ps_lock);
@@ -69,13 +89,15 @@ get_user_ps_path(char **file)
 {
 	TSS_RESULT result;
 	char *file_name = NULL, *home_dir = NULL;
-	struct passwd *pwp;
 #if (defined (__linux) || defined (linux) || defined(__GLIBC__))
 	struct passwd pw;
 #endif
 	struct stat stat_buf;
 	char buf[PASSWD_BUFSIZE];
+#ifndef WIN32
 	uid_t euid;
+	struct passwd *pwp;
+#endif
 	int rc;
 
 	if ((file_name = getenv("TSS_USER_PS_FILE"))) {
@@ -85,8 +107,9 @@ get_user_ps_path(char **file)
 #if (defined (__FreeBSD__) || defined (__OpenBSD__))
 	MUTEX_LOCK(user_ps_path);
 #endif
-
+#ifndef WIN32
 	euid = geteuid();
+#endif
 
 #if defined (SOLARIS)
 	/*
@@ -98,6 +121,7 @@ get_user_ps_path(char **file)
          */
         rc = snprintf(buf, sizeof (buf), "%s/%d", TSS_USER_PS_DIR, euid);
 #else
+#ifndef WIN32
 	setpwent();
 	while (1) {
 #if (defined (__linux) || defined (linux) || defined(__GLIBC__))
@@ -124,6 +148,9 @@ get_user_ps_path(char **file)
                 }
         }
         endpwent();
+#else
+	home_dir = trousers_getUserDir();
+#endif
 
 	if (!home_dir)
 		return TSPERR(TSS_E_OUTOFMEMORY);
@@ -164,7 +191,7 @@ get_user_ps_path(char **file)
 		      TSS_USER_PS_FILE);
 #endif
 	if (rc == sizeof (buf)) {
-		LogDebugFn("USER PS: Path to file too long! (> %d bytes)", sizeof (buf));
+		LogDebugFn("USER PS: Path to file too long! (> %zd bytes)", sizeof (buf));
 	} else
 		*file = strdup(buf);
 
@@ -206,7 +233,11 @@ get_file(int *fd)
 		return result;
 	}
 
+#ifdef WIN32
+	user_ps_fd = open(file_name, O_CREAT|O_RDWR|O_BINARY, 0600);
+#else
 	user_ps_fd = open(file_name, O_CREAT|O_RDWR, 0600);
+#endif
 	if (user_ps_fd < 0) {
 		LogDebug("USER PS: open of %s failed: %s", file_name, strerror(errno));
 		free(file_name);
diff --git a/src/tspi/rpc/hosttable.c b/src/tspi/rpc/hosttable.c
index f3ec2eb..292138a 100644
--- a/src/tspi/rpc/hosttable.c
+++ b/src/tspi/rpc/hosttable.c
@@ -9,6 +9,9 @@
  */
 
 
+#ifdef WIN32
+#include <windows.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -20,6 +23,8 @@
 #include "obj.h"
 
 struct host_table *ht = NULL;
+TSS_RESULT host_table_init();
+void host_table_final();
 
 TSS_RESULT
 host_table_init()
@@ -35,6 +40,7 @@ host_table_init()
 	return TSS_SUCCESS;
 }
 
+#ifndef WIN32
 #ifdef SOLARIS
 #pragma init(_init)
 void _init(void)
@@ -45,6 +51,32 @@ void __attribute__ ((constructor)) my_init(void)
 	host_table_init();
 	__tspi_obj_list_init();
 }
+#else
+BOOL APIENTRY DllMain(HINSTANCE hinstDLL,
+		      DWORD fdwReason,
+		      LPVOID lpvReserved)
+{ 
+	switch (fdwReason) { 
+	case DLL_PROCESS_ATTACH: 
+		host_table_init();
+		__tspi_obj_list_init();
+		break; 
+	case DLL_THREAD_ATTACH: 
+		break; 
+	case DLL_THREAD_DETACH: 
+		break; 
+	case DLL_PROCESS_DETACH:
+		host_table_final();
+		break;
+	default: 
+		break; 
+	} 
+
+	return TRUE; 
+	UNREFERENCED_PARAMETER(hinstDLL); 
+	UNREFERENCED_PARAMETER(lpvReserved); 
+}
+#endif
 
 void
 host_table_final()
@@ -69,6 +101,7 @@ host_table_final()
 	ht = NULL;
 }
 
+#ifndef WIN32
 #ifdef SOLARIS
 #pragma fini(_fini)
 void _fini(void)
@@ -78,6 +111,7 @@ void __attribute__ ((destructor)) my_fini(void)
 {
 	host_table_final();
 }
+#endif
 
 TSS_RESULT
 __tspi_add_table_entry(TSS_HCONTEXT tspContext, BYTE *host, int type, struct host_table_entry **ret)
diff --git a/src/tspi/rpc/tcs_api.c b/src/tspi/rpc/tcs_api.c
index 3eeb1fb..f75b911 100644
--- a/src/tspi/rpc/tcs_api.c
+++ b/src/tspi/rpc/tcs_api.c
@@ -9,9 +9,15 @@
  */
 
 
+#ifdef WIN32
+#include <ws2tcpip.h>
+#include <windows.h>
+#endif
 #include <stdlib.h>
+#ifndef WIN32
 #include <syslog.h>
 #include <unistd.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
@@ -21,6 +27,9 @@
 #include "tsplog.h"
 #include "rpc_tcstp_tsp.h"
 #include "obj_context.h"
+#ifdef WIN32
+#include "libc_interface.h"
+#endif
 
 
 TSS_RESULT
diff --git a/src/tspi/rpc/tcstp/rpc.c b/src/tspi/rpc/tcstp/rpc.c
index 963da1f..a193d0e 100644
--- a/src/tspi/rpc/tcstp/rpc.c
+++ b/src/tspi/rpc/tcstp/rpc.c
@@ -8,14 +8,24 @@
  *
  */
 
+#ifdef WIN32
+#include <ws2tcpip.h>
+#include <windows.h>
+#endif
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <errno.h>
 #include <string.h>
+#ifndef WIN32
 #include <sys/socket.h>
+#endif
 #include <sys/types.h>
+#ifndef WIN32
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <netdb.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <assert.h>
@@ -31,7 +41,9 @@
 #include "tcsd_wrap.h"
 #include "obj.h"
 #include "rpc_tcstp_tsp.h"
-
+#ifdef WIN32
+#include "libc_interface.h"
+#endif
 
 void
 initData(struct tcsd_comm_data *comm, int parm_count)
@@ -304,7 +316,7 @@ recv_from_socket(int sock, void *buffer, int size)
 
 	while (recv_total < size) {
 		errno = 0;
-		if ((recv_size = recv(sock, buffer+recv_total, size-recv_total, 0)) <= 0) {
+		if ((recv_size = recv(sock, (char *)buffer+recv_total, size-recv_total, 0)) <= 0) {
 			if (recv_size < 0) {
 				if (errno == EINTR)
 					continue;
@@ -327,7 +339,7 @@ send_to_socket(int sock, void *buffer, int size)
 	int send_size = 0, send_total = 0;
 
 	while (send_total < size) {
-		if ((send_size = send(sock, buffer+send_total, size-send_total, 0)) < 0) {
+		if ((send_size = send(sock, (char *)buffer+send_total, size-send_total, 0)) < 0) {
 			LogError("Socket send connection error: %s.", strerror(errno));
 			return -1;
 		}
@@ -348,6 +360,16 @@ send_init(struct host_table_entry *hte)
 	struct sockaddr_in addr;
 	struct hostent *hEnt = NULL;
 
+#ifdef WIN32
+	WSADATA wsaData;
+	
+	// Initialize Winsock
+	result = WSAStartup(MAKEWORD(2,2), &wsaData);
+	if(result) {
+		LogError("Error when initializing the WINSOCK library");
+		return TSPERR(TSS_E_COMM_FAILURE);
+	}
+#endif
 	sd = socket(PF_INET, SOCK_STREAM, 0);
 	if (sd == -1) {
 		LogError("socket: %s", strerror(errno));
@@ -432,6 +454,9 @@ send_init(struct host_table_entry *hte)
 
 err_exit:
 	close(sd);
+#ifdef WIN32
+	WSACleanup();
+#endif
 	return result;
 }
 
diff --git a/src/tspi/spi_utils.c b/src/tspi/spi_utils.c
index de80bc1..0ff9373 100644
--- a/src/tspi/spi_utils.c
+++ b/src/tspi/spi_utils.c
@@ -12,9 +12,16 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
+
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/mman.h>
+#else
+#include <time.h>
+#endif
 #include <errno.h>
 
 #include "trousers/tss.h"
@@ -26,11 +33,308 @@
 #include "tsplog.h"
 #include "obj.h"
 
+#ifdef WIN32
+#include "win32dep.h"
+#endif
 
 TSS_UUID NULL_UUID = { 0, 0, 0, 0, 0, { 0, 0, 0, 0, 0, 0 } };
 
 TSS_VERSION VERSION_1_1 = { 1, 1, 0, 0 };
 
+#ifdef WIN32
+struct tcs_api_table tcs_normal_api = {
+#ifdef TSS_BUILD_KEY
+	RPC_LoadKeyByBlob,
+	RPC_EvictKey,
+	RPC_CreateWrapKey,
+	RPC_GetPubKey,
+	RPC_OwnerReadInternalPub,
+#ifdef TSS_BUILD_CERTIFY
+	RPC_CertifyKey,
+#endif
+#endif
+#ifdef TSS_BUILD_OWN
+	RPC_OwnerClear,
+	RPC_ForceClear,
+#endif
+#ifdef TSS_BUILD_AUTH
+	RPC_OIAP,
+	RPC_OSAP,
+	RPC_TerminateHandle,
+#endif
+#ifdef TSS_BUILD_CHANGEAUTH
+	RPC_ChangeAuth,
+	RPC_ChangeAuthOwner,
+	RPC_ChangeAuthAsymStart,
+	RPC_ChangeAuthAsymFinish,
+#endif
+#ifdef TSS_BUILD_AIK
+	RPC_ActivateTPMIdentity,
+#endif
+#ifdef TSS_BUILD_PCR_EXTEND
+	RPC_Extend,
+	RPC_PcrRead,
+	RPC_PcrReset,
+#endif
+#ifdef TSS_BUILD_QUOTE
+	RPC_Quote,
+#endif
+#ifdef TSS_BUILD_QUOTE2
+	RPC_Quote2,
+#endif
+#ifdef TSS_BUILD_DIR
+	RPC_DirWriteAuth,
+	RPC_DirRead,
+#endif
+#ifdef TSS_BUILD_SEAL
+	RPC_Seal,
+	RPC_Sealx,
+	RPC_Unseal,
+#endif
+#ifdef TSS_BUILD_BIND
+	RPC_UnBind,
+#endif
+#ifdef TSS_BUILD_MIGRATION
+	RPC_CreateMigrationBlob,
+	RPC_ConvertMigrationBlob,
+	RPC_AuthorizeMigrationKey,
+#endif
+#ifdef TSS_BUILD_SIGN
+	RPC_Sign,
+#endif
+#ifdef TSS_BUILD_RANDOM
+	RPC_GetRandom,
+	RPC_StirRandom,
+#endif
+#ifdef TSS_BUILD_CAPS_TPM
+	RPC_GetTPMCapability,
+	RPC_SetCapability,
+	RPC_GetCapabilityOwner,
+#endif
+#ifdef TSS_BUILD_EK
+	RPC_CreateEndorsementKeyPair,
+	RPC_ReadPubek,
+	RPC_OwnerReadPubek,
+#endif
+#ifdef TSS_BUILD_SELFTEST
+	RPC_SelfTestFull,
+	RPC_CertifySelfTest,
+	RPC_GetTestResult,
+#endif
+#ifdef TSS_BUILD_ADMIN
+	RPC_DisablePubekRead,
+	RPC_SetOwnerInstall,
+	RPC_OwnerSetDisable,
+	RPC_ResetLockValue,
+	RPC_DisableOwnerClear,
+	RPC_DisableForceClear,
+	RPC_PhysicalDisable,
+	RPC_PhysicalEnable,
+	RPC_PhysicalSetDeactivated,
+	RPC_PhysicalPresence,
+	RPC_SetTempDeactivated,
+	RPC_SetTempDeactivated2,
+#endif
+#ifdef TSS_BUILD_MAINT
+	RPC_CreateMaintenanceArchive,
+	RPC_LoadMaintenanceArchive,
+	RPC_KillMaintenanceFeature,
+	RPC_LoadManuMaintPub,
+	RPC_ReadManuMaintPub,
+#endif
+#ifdef TSS_BUILD_DAA
+	RPC_DaaJoin,
+	RPC_DaaSign,
+#endif
+#ifdef TSS_BUILD_COUNTER
+	RPC_ReadCounter,
+	RPC_CreateCounter,
+	RPC_IncrementCounter,
+	RPC_ReleaseCounter,
+	RPC_ReleaseCounterOwner,
+#endif
+#ifdef TSS_BUILD_TICK
+	RPC_ReadCurrentTicks,
+	RPC_TickStampBlob,
+#endif
+#ifdef TSS_BUILD_NV
+	RPC_NV_DefineOrReleaseSpace,
+	RPC_NV_WriteValue,
+	RPC_NV_WriteValueAuth,
+	RPC_NV_ReadValue,
+	RPC_NV_ReadValueAuth,
+#endif
+#ifdef TSS_BUILD_AUDIT
+	RPC_SetOrdinalAuditStatus,
+	RPC_GetAuditDigest,
+	RPC_GetAuditDigestSigned,
+#endif
+#ifdef TSS_BUILD_TSS12
+	RPC_SetOperatorAuth,
+	RPC_FlushSpecific,
+#endif
+#ifdef TSS_BUILD_DELEGATION
+	RPC_Delegate_Manage,
+	RPC_Delegate_CreateKeyDelegation,
+	RPC_Delegate_CreateOwnerDelegation,
+	RPC_Delegate_LoadOwnerDelegation,
+	RPC_Delegate_ReadTable,
+	RPC_Delegate_UpdateVerificationCount,
+	RPC_Delegate_VerifyDelegation,
+	RPC_DSAP,
+#endif
+	RPC_FieldUpgrade,
+	RPC_SetRedirection,
+};
+
+#ifdef TSS_BUILD_TRANSPORT
+struct tcs_api_table tcs_transport_api = {
+#ifdef TSS_BUILD_KEY
+	Transport_LoadKeyByBlob,
+	Transport_EvictKey,
+	Transport_CreateWrapKey,
+	Transport_GetPubKey,
+	Transport_OwnerReadInternalPub,
+#ifdef TSS_BUILD_CERTIFY
+	Transport_CertifyKey,
+#endif
+#endif
+#ifdef TSS_BUILD_OWN
+	Transport_OwnerClear,
+	Transport_ForceClear,
+#endif
+#ifdef TSS_BUILD_AUTH
+	Transport_OIAP,
+	Transport_OSAP,
+	Transport_TerminateHandle,
+#endif
+#ifdef TSS_BUILD_CHANGEAUTH
+	Transport_ChangeAuth,
+	Transport_ChangeAuthOwner,
+	RPC_ChangeAuthAsymStart,
+	RPC_ChangeAuthAsymFinish,
+#endif
+#ifdef TSS_BUILD_AIK
+	Transport_ActivateTPMIdentity,
+#endif
+#ifdef TSS_BUILD_PCR_EXTEND
+	Transport_Extend,
+	Transport_PcrRead,
+	Transport_PcrReset,
+#endif
+#ifdef TSS_BUILD_QUOTE
+	Transport_Quote,
+#endif
+#ifdef TSS_BUILD_QUOTE2
+	Transport_Quote2,
+#endif
+#ifdef TSS_BUILD_DIR
+	Transport_DirWriteAuth,
+	Transport_DirRead,
+#endif
+#ifdef TSS_BUILD_SEAL
+	Transport_Seal,
+	Transport_Sealx,
+	Transport_Unseal,
+#endif
+#ifdef TSS_BUILD_BIND
+	Transport_UnBind,
+#endif
+#ifdef TSS_BUILD_MIGRATION
+	Transport_CreateMigrationBlob,
+	Transport_ConvertMigrationBlob,
+	Transport_AuthorizeMigrationKey,
+#endif
+#ifdef TSS_BUILD_SIGN
+	Transport_Sign,
+#endif
+#ifdef TSS_BUILD_RANDOM
+	Transport_GetRandom,
+	Transport_StirRandom,
+#endif
+#ifdef TSS_BUILD_CAPS_TPM
+	Transport_GetTPMCapability,
+	Transport_SetCapability,
+	Transport_GetCapabilityOwner,
+#endif
+#ifdef TSS_BUILD_EK
+	RPC_CreateEndorsementKeyPair,
+	RPC_ReadPubek,
+	RPC_OwnerReadPubek,
+#endif
+#ifdef TSS_BUILD_SELFTEST
+	Transport_SelfTestFull,
+	Transport_CertifySelfTest,
+	Transport_GetTestResult,
+#endif
+#ifdef TSS_BUILD_ADMIN
+	Transport_DisablePubekRead,
+	Transport_SetOwnerInstall,
+	Transport_OwnerSetDisable,
+	Transport_ResetLockValue,
+	Transport_DisableOwnerClear,
+	Transport_DisableForceClear,
+	Transport_PhysicalDisable,
+	Transport_PhysicalEnable,
+	Transport_PhysicalSetDeactivated,
+	Transport_PhysicalPresence,
+	Transport_SetTempDeactivated,
+	Transport_SetTempDeactivated2,
+#endif
+#ifdef TSS_BUILD_MAINT
+	Transport_CreateMaintenanceArchive,
+	Transport_LoadMaintenanceArchive,
+	Transport_KillMaintenanceFeature,
+	Transport_LoadManuMaintPub,
+	Transport_ReadManuMaintPub,
+#endif
+#ifdef TSS_BUILD_DAA
+	RPC_DaaJoin,
+	RPC_DaaSign,
+#endif
+#ifdef TSS_BUILD_COUNTER
+	Transport_ReadCounter,
+	RPC_CreateCounter,
+	RPC_IncrementCounter,
+	RPC_ReleaseCounter,
+	RPC_ReleaseCounterOwner,
+#endif
+#ifdef TSS_BUILD_TICK
+	Transport_ReadCurrentTicks,
+	Transport_TickStampBlob,
+#endif
+#ifdef TSS_BUILD_NV
+	Transport_NV_DefineOrReleaseSpace,
+	Transport_NV_WriteValue,
+	Transport_NV_WriteValueAuth,
+	Transport_NV_ReadValue,
+	Transport_NV_ReadValueAuth,
+#endif
+#ifdef TSS_BUILD_AUDIT
+	Transport_SetOrdinalAuditStatus,
+	Transport_GetAuditDigest,
+	Transport_GetAuditDigestSigned,
+#endif
+#ifdef TSS_BUILD_TSS12
+	Transport_SetOperatorAuth,
+	Transport_FlushSpecific,
+#endif
+#ifdef TSS_BUILD_DELEGATION
+	Transport_Delegate_Manage,
+	Transport_Delegate_CreateKeyDelegation,
+	Transport_Delegate_CreateOwnerDelegation,
+	Transport_Delegate_LoadOwnerDelegation,
+	Transport_Delegate_ReadTable,
+	Transport_Delegate_UpdateVerificationCount,
+	Transport_Delegate_VerifyDelegation,
+	Transport_DSAP,
+#endif
+	RPC_FieldUpgrade,
+	RPC_SetRedirection,
+};
+#endif
+
+#else
 struct tcs_api_table tcs_normal_api = {
 #ifdef TSS_BUILD_KEY
 	.LoadKeyByBlob = RPC_LoadKeyByBlob,
@@ -329,6 +633,7 @@ struct tcs_api_table tcs_transport_api = {
 	.SetRedirection = RPC_SetRedirection,
 };
 #endif
+#endif
 
 UINT16
 Decode_UINT16(BYTE * in)
@@ -421,6 +726,7 @@ UnloadBlob_AUTH(UINT64 *offset, BYTE *blob, TPM_AUTH *auth)
 	Trspi_UnloadBlob(offset, 20, blob, (BYTE *)&auth->HMAC);
 }
 
+#ifndef WIN32
 /* If alloc is true, we allocate a new buffer for the bytes and set *data to that.
  * If alloc is false, data is really a BYTE*, so write the bytes directly to that buffer */
 TSS_RESULT
@@ -457,3 +763,33 @@ get_local_random(TSS_HCONTEXT tspContext, TSS_BOOL alloc, UINT32 size, BYTE **da
 
 	return TSS_SUCCESS;
 }
+#else
+TSS_RESULT
+get_local_random(TSS_HCONTEXT tspContext, TSS_BOOL alloc, UINT32 size, BYTE **data)
+{
+	BYTE *buf = NULL;
+	size_t i;
+
+	static const char table16[]="0123456789abcdef";
+
+	if (alloc) {
+		buf = calloc_tspi(tspContext, size);
+		if (buf == NULL) {
+			LogError("malloc of %u bytes failed", size);
+			return TSPERR(TSS_E_OUTOFMEMORY);
+		}
+	} else
+		buf = (BYTE *)data;
+
+	Curl_srand();
+	
+	for (i=0; i<size; i++) {
+		buf[i] = table16[Curl_rand()%16];
+	}
+
+	if (alloc)
+		*data = buf;
+
+	return TSS_SUCCESS;  
+}
+#endif
diff --git a/src/tspi/tsp_auth.c b/src/tspi/tsp_auth.c
index 55b9ccf..1c41ae5 100755
--- a/src/tspi/tsp_auth.c
+++ b/src/tspi/tsp_auth.c
@@ -9,6 +9,9 @@
  */
 
 
+#ifdef WIN32
+#include <windows.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -73,11 +76,14 @@ secret_PerformAuth_OIAP(TSS_HOBJECT hAuthorizedObject,
 		if (result == TCPA_E_RESOURCES) {
 			int retry = 0;
 			do {
+#ifdef WIN32
+				Sleep(AUTH_RETRY_MILLISEC);
+#else
 				/* POSIX sleep time, { secs, nanosecs } */
 				struct timespec t = { 0, AUTH_RETRY_NANOSECS };
 
 				nanosleep(&t, NULL);
-
+#endif
 				result = OIAP(tspContext, &auth->AuthHandle, &auth->NonceEven);
 			} while (result == TCPA_E_RESOURCES && ++retry < AUTH_RETRY_COUNT);
 		}
@@ -404,11 +410,14 @@ OSAP_Calc(TSS_HCONTEXT tspContext, UINT16 EntityType, UINT32 EntityValue,
 		if (rc == TCPA_E_RESOURCES) {
 			int retry = 0;
 			do {
+#ifdef WIN32
+				Sleep(AUTH_RETRY_MILLISEC);
+#else
 				/* POSIX sleep time, { secs, nanosecs } */
 				struct timespec t = { 0, AUTH_RETRY_NANOSECS };
 
 				nanosleep(&t, NULL);
-
+#endif
 				rc = TCS_API(tspContext)->OSAP(tspContext, EntityType, EntityValue,
 							       &auth->NonceOdd, &auth->AuthHandle,
 							       &auth->NonceEven, &nonceEvenOSAP);
@@ -622,11 +631,14 @@ authsess_do_dsap(struct authsess *sess)
 		if (result == TCPA_E_RESOURCES) {
 			int retry = 0;
 			do {
+#ifdef WIN32
+				Sleep(AUTH_RETRY_MILLISEC);
+#else
 				/* POSIX sleep time, { secs, nanosecs } */
 				struct timespec t = { 0, AUTH_RETRY_NANOSECS };
 
 				nanosleep(&t, NULL);
-
+#endif
 				result = TCS_API(sess->tspContext)->DSAP(sess->tspContext,
 									 sess->entity_type,
 									 sess->obj_parent,
@@ -657,11 +669,14 @@ authsess_do_osap(struct authsess *sess)
 		if (result == TCPA_E_RESOURCES) {
 			int retry = 0;
 			do {
+#ifdef WIN32
+				Sleep(AUTH_RETRY_MILLISEC);
+#else
 				/* POSIX sleep time, { secs, nanosecs } */
 				struct timespec t = { 0, AUTH_RETRY_NANOSECS };
 
 				nanosleep(&t, NULL);
-
+#endif
 				result = TCS_API(sess->tspContext)->OSAP(sess->tspContext,
 									 sess->entity_type,
 									 sess->obj_parent,
@@ -774,7 +789,7 @@ authsess_xsap_init(TSS_HCONTEXT     tspContext,
 		   struct authsess  **xsess)
 {
 	TSS_RESULT result;
-	TSS_BOOL authdatausage = FALSE, req_auth = TRUE, get_child_auth = TRUE;
+	TSS_BOOL authdatausage = FALSE, req_auth = TRUE, get_child_auth = TRUE, secret_set = FALSE;
 	BYTE hmacBlob[2 * sizeof(TPM_DIGEST)];
 	UINT64 offset;
 	TSS_BOOL new_secret = TR_SECRET_CTX_NOT_NEW;
@@ -921,7 +936,10 @@ authsess_xsap_init(TSS_HCONTEXT     tspContext,
 					goto error;
 			}
 
-			if (!sess->hUsageChild) {
+			if ((result = obj_policy_is_secret_set(sess->hUsageChild, &secret_set)))
+				goto error;
+
+			if (!secret_set) {
 				result = TSPERR(TSS_E_TSP_AUTHREQUIRED);
 				goto error;
 			}
diff --git a/src/tspi/tsp_caps.c b/src/tspi/tsp_caps.c
index f06fbd6..2d6dc18 100644
--- a/src/tspi/tsp_caps.c
+++ b/src/tspi/tsp_caps.c
@@ -12,9 +12,14 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
+
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/mman.h>
+#endif
 #include <errno.h>
 
 #include "trousers/tss.h"
diff --git a/src/tspi/tsp_caps_tpm.c b/src/tspi/tsp_caps_tpm.c
index 1203dbe..b93ad8f 100644
--- a/src/tspi/tsp_caps_tpm.c
+++ b/src/tspi/tsp_caps_tpm.c
@@ -8,10 +8,15 @@
  *
  */
 
+#ifdef WIN32
+#include <windows.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tsp_ek.c b/src/tspi/tsp_ek.c
index 4c2ae4f..865e287 100644
--- a/src/tspi/tsp_ek.c
+++ b/src/tspi/tsp_ek.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tsp_get_flags.c b/src/tspi/tsp_get_flags.c
index f974052..f6b3208 100644
--- a/src/tspi/tsp_get_flags.c
+++ b/src/tspi/tsp_get_flags.c
@@ -12,9 +12,13 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/mman.h>
+#endif
 #include <errno.h>
 
 #include "trousers/tss.h"
diff --git a/src/tspi/tsp_maint.c b/src/tspi/tsp_maint.c
index 3e50ddd..7f8c466 100644
--- a/src/tspi/tsp_maint.c
+++ b/src/tspi/tsp_maint.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tsp_migration.c b/src/tspi/tsp_migration.c
index 9c83753..38d9a1d 100644
--- a/src/tspi/tsp_migration.c
+++ b/src/tspi/tsp_migration.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tsp_nv.c b/src/tspi/tsp_nv.c
index 511a6c9..63e3cee 100644
--- a/src/tspi/tsp_nv.c
+++ b/src/tspi/tsp_nv.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tsp_pcr.c b/src/tspi/tsp_pcr.c
index cc562d7..c5ed1da 100644
--- a/src/tspi/tsp_pcr.c
+++ b/src/tspi/tsp_pcr.c
@@ -9,12 +9,19 @@
  */
 
 
+#ifdef WIN32
+#include <windows.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/mman.h>
+#endif
 #include <errno.h>
 
 #include "trousers/tss.h"
diff --git a/src/tspi/tsp_policy.c b/src/tspi/tsp_policy.c
index 9d5ec5d..c548557 100644
--- a/src/tspi/tsp_policy.c
+++ b/src/tspi/tsp_policy.c
@@ -9,15 +9,26 @@
  */
 
 
+#ifdef WIN32
+#include <ws2tcpip.h>
+#include <windows.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
 #include <errno.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/mman.h>
+#endif
 
+#ifdef __MINGW32__
+#include <stdint.h>
+#endif
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
 #include "trousers_types.h"
@@ -25,8 +36,15 @@
 #include "capabilities.h"
 #include "tsplog.h"
 #include "obj.h"
+#ifdef WIN32
+#include "libc_interface.h"
+#endif
 
+#if defined _SC_PAGESIZE
 #define	PGSIZE sysconf(_SC_PAGESIZE)
+#else
+#define PGSIZE 4096
+#endif
 #define PGOFFSET (PGSIZE - 1)
 #define PGMASK (~PGOFFSET)
 
@@ -86,11 +104,13 @@ popup_GetSecret(UINT32 new_pin, UINT32 hash_mode, BYTE *popup_str, void *auth_ha
 int
 pin_mem(void *addr, size_t len)
 {
+#ifdef FIXME
 	/* only root can lock pages into RAM */
 	if (getuid() != (uid_t)0) {
 		LogWarn("Not pinning secrets in memory due to insufficient perms.");
 		return 0;
 	}
+#endif
 
 	len += (uintptr_t)addr & PGOFFSET;
 	addr = (void *)((uintptr_t)addr & PGMASK);
@@ -105,10 +125,12 @@ pin_mem(void *addr, size_t len)
 int
 unpin_mem(void *addr, size_t len)
 {
+#ifdef FIXME
 	/* only root can lock pages into RAM */
 	if (getuid() != (uid_t)0) {
 		return 0;
 	}
+#endif
 
 	len += (uintptr_t)addr & PGOFFSET;
 	addr = (void *)((uintptr_t)addr & PGMASK);
diff --git a/src/tspi/tsp_ps.c b/src/tspi/tsp_ps.c
index 96c267a..06cdf87 100644
--- a/src/tspi/tsp_ps.c
+++ b/src/tspi/tsp_ps.c
@@ -11,10 +11,14 @@
 #include <limits.h>
 #include <stdlib.h>
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/file.h>
+#endif
 #include <errno.h>
 #include <string.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <stdio.h>
 #include <limits.h>
 
diff --git a/src/tspi/tsp_quote.c b/src/tspi/tsp_quote.c
index 24e026b..3d92c66 100644
--- a/src/tspi/tsp_quote.c
+++ b/src/tspi/tsp_quote.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tsp_quote2.c b/src/tspi/tsp_quote2.c
index 76ccc2e..325bfc8 100644
--- a/src/tspi/tsp_quote2.c
+++ b/src/tspi/tsp_quote2.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tsp_random.c b/src/tspi/tsp_random.c
index 80aff66..33ae715 100644
--- a/src/tspi/tsp_random.c
+++ b/src/tspi/tsp_random.c
@@ -10,8 +10,10 @@
 
 
 #include <stdlib.h>
+#ifndef WIN32
 #include <syslog.h>
 #include <unistd.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tsp_selftest.c b/src/tspi/tsp_selftest.c
index 5a27110..650648b 100644
--- a/src/tspi/tsp_selftest.c
+++ b/src/tspi/tsp_selftest.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_admin.c b/src/tspi/tspi_admin.c
index a20ab45..e6e0c55 100644
--- a/src/tspi/tspi_admin.c
+++ b/src/tspi/tspi_admin.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_aik.c b/src/tspi/tspi_aik.c
index 9476341..dd0be79 100644
--- a/src/tspi/tspi_aik.c
+++ b/src/tspi/tspi_aik.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 #include <limits.h>
 
 #include "trousers/tss.h"
diff --git a/src/tspi/tspi_asn1.c b/src/tspi/tspi_asn1.c
index f17ce41..fc4e07c 100644
--- a/src/tspi/tspi_asn1.c
+++ b/src/tspi/tspi_asn1.c
@@ -9,6 +9,10 @@
  */
 
 
+#ifdef WIN32
+#include <windows.h>
+#define UINT16_MAX 0xffff
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -17,8 +21,10 @@
 #include <openssl/asn1t.h>
 
 #ifndef TSS_BUILD_ASN1_OPENSSL
+#ifndef WIN32
 #include <arpa/inet.h>
 #endif
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_caps_tpm.c b/src/tspi/tspi_caps_tpm.c
index 131e67b..0d36e33 100644
--- a/src/tspi/tspi_caps_tpm.c
+++ b/src/tspi/tspi_caps_tpm.c
@@ -8,10 +8,15 @@
  *
  */
 
+#ifdef WIN32
+#include <windows.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_cmk.c b/src/tspi/tspi_cmk.c
index 6ced203..94ce1ec 100644
--- a/src/tspi/tspi_cmk.c
+++ b/src/tspi/tspi_cmk.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_delegate.c b/src/tspi/tspi_delegate.c
index c8fcb6a..c7c1303 100644
--- a/src/tspi/tspi_delegate.c
+++ b/src/tspi/tspi_delegate.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_dir.c b/src/tspi/tspi_dir.c
index 10c0c38..b27aa3a 100644
--- a/src/tspi/tspi_dir.c
+++ b/src/tspi/tspi_dir.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_ek.c b/src/tspi/tspi_ek.c
index d1b2065..ce10d51 100644
--- a/src/tspi/tspi_ek.c
+++ b/src/tspi/tspi_ek.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_maint.c b/src/tspi/tspi_maint.c
index 5576ed3..ead5482 100644
--- a/src/tspi/tspi_maint.c
+++ b/src/tspi/tspi_maint.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_migration.c b/src/tspi/tspi_migration.c
index 83b73f4..63fb407 100644
--- a/src/tspi/tspi_migration.c
+++ b/src/tspi/tspi_migration.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_nv.c b/src/tspi/tspi_nv.c
index 4789cb2..8fd4ffa 100644
--- a/src/tspi/tspi_nv.c
+++ b/src/tspi/tspi_nv.c
@@ -29,7 +29,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
@@ -130,9 +132,12 @@ Tspi_NV_DefineSpace(TSS_HNVSTORE hNvstore,	/* in */
 	free_tspi(tspContext, pWritePCR);
 
 	if ((result = authsess_xsap_init(tspContext, hTpm, hNvstore, need_authdata,
-					 TPM_ORD_NV_DefineSpace, TPM_ET_OWNER, &xsap)))
+					 TPM_ORD_NV_DefineSpace, TPM_ET_OWNER, &xsap))) {
+		if (result == TSPERR(TSS_E_TSP_AUTHREQUIRED))
+			result = TSS_ERROR_CODE(TSS_E_BAD_PARAMETER);
 		return result;
-
+	}
+	
 	result = Trspi_HashInit(&hashCtx, TSS_HASH_SHA1);
 	result |= Trspi_Hash_UINT32(&hashCtx, TPM_ORD_NV_DefineSpace);
 	result |= Trspi_HashUpdate(&hashCtx, NVPublic_DataSize, NVPublicData);
diff --git a/src/tspi/tspi_own.c b/src/tspi/tspi_own.c
index ef6a44c..a9c669b 100644
--- a/src/tspi/tspi_own.c
+++ b/src/tspi/tspi_own.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_pcr_events.c b/src/tspi/tspi_pcr_events.c
index c860715..e00c924 100644
--- a/src/tspi/tspi_pcr_events.c
+++ b/src/tspi/tspi_pcr_events.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_pcr_extend.c b/src/tspi/tspi_pcr_extend.c
index 6193fd2..6dd07d2 100644
--- a/src/tspi/tspi_pcr_extend.c
+++ b/src/tspi/tspi_pcr_extend.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_quote.c b/src/tspi/tspi_quote.c
index 58d5de0..4bc69b2 100644
--- a/src/tspi/tspi_quote.c
+++ b/src/tspi/tspi_quote.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_quote2.c b/src/tspi/tspi_quote2.c
index 67d4dc1..b5e2ba4 100644
--- a/src/tspi/tspi_quote2.c
+++ b/src/tspi/tspi_quote2.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_random.c b/src/tspi/tspi_random.c
index 9fe8c27..d810b86 100644
--- a/src/tspi/tspi_random.c
+++ b/src/tspi/tspi_random.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_selftest.c b/src/tspi/tspi_selftest.c
index 2cd31d2..f679110 100644
--- a/src/tspi/tspi_selftest.c
+++ b/src/tspi/tspi_selftest.c
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/tspi/tspi_transport.c b/src/tspi/tspi_transport.c
index bd956cd..5c27685 100644
--- a/src/tspi/tspi_transport.c
+++ b/src/tspi/tspi_transport.c
@@ -12,7 +12,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
 #include <inttypes.h>
+#endif
 
 #include "trousers/tss.h"
 #include "trousers/trousers.h"
diff --git a/src/win32/Makefile.am b/src/win32/Makefile.am
new file mode 100644
index 0000000..f2b71bf
--- /dev/null
+++ b/src/win32/Makefile.am
@@ -0,0 +1,6 @@
+noinst_LTLIBRARIES=libc_interface.la
+
+libc_interface_la_SOURCES=libc_interface.c win32dep.c
+
+libc_interface_la_CFLAGS=-DAPPID=\"WIN32LIB\" -I${top_srcdir}/src/include
+libc_interface_la_LDFLAGS="-lws2_32 -luserenv"
diff --git a/src/win32/libc_interface.c b/src/win32/libc_interface.c
new file mode 100644
index 0000000..5aab7c1
--- /dev/null
+++ b/src/win32/libc_interface.c
@@ -0,0 +1,609 @@
+/*
+ * purple
+ *
+ * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com>
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ *
+ */
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <io.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/timeb.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <ctype.h>
+#include "libc_internal.h"
+#define TSS_RESULT UINT32
+#include "tcslog.h"
+#include "flock.h"
+
+/** This is redefined here because we can't include internal.h */
+#ifdef ENABLE_NLS
+#  include <locale.h>
+#  include <libintl.h>
+#  define _(String) ((const char *)dgettext(PACKAGE, String))
+#  ifdef gettext_noop
+#    define N_(String) gettext_noop (String)
+#  else
+#    define N_(String) (String)
+#  endif
+#else
+#  include <locale.h>
+#  define N_(String) (String)
+#  ifndef _
+#    define _(String) ((const char *)String)
+#  endif
+#  define ngettext(Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
+#  define dngettext(Domain, Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
+#endif
+
+#ifndef S_ISDIR
+# define S_ISDIR(m) (((m)&S_IFDIR)==S_IFDIR)
+#endif
+
+#undef snprintf
+#define snprintf _snprintf
+
+static char errbuf[1024];
+
+/* helpers */
+static int wpurple_is_socket( int fd ) {
+	int optval;
+	int optlen = sizeof(int);
+
+	if( (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void*)&optval, &optlen)) == SOCKET_ERROR ) {
+		int error = WSAGetLastError();
+		if( error == WSAENOTSOCK )
+			return FALSE;
+		else {
+//                      LogDebug("getsockopt returned error: %d", error);
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
+
+/* socket.h */
+int wpurple_socket (int namespace, int style, int protocol) {
+	int ret;
+
+	ret = socket( namespace, style, protocol );
+
+	if( (unsigned)ret == INVALID_SOCKET ) {
+		errno = WSAGetLastError();
+		return -1;
+	}
+	return ret;
+}
+
+int wpurple_connect(int socket, struct sockaddr *addr, u_long length) {
+	int ret;
+
+	ret = connect( socket, addr, length );
+
+	if( ret == SOCKET_ERROR ) {
+		errno = WSAGetLastError();
+		if( errno == WSAEWOULDBLOCK )
+			errno = WSAEINPROGRESS;
+		return -1;
+	}
+	return 0;
+}
+
+int wpurple_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr) {
+	if(getsockopt(socket, level, optname, optval, optlenptr) == SOCKET_ERROR ) {
+		errno = WSAGetLastError();
+		return -1;
+	}
+	return 0;
+}
+
+int wpurple_setsockopt(int socket, int level, int optname, const void *optval, socklen_t optlen) {
+	if(setsockopt(socket, level, optname, optval, optlen) == SOCKET_ERROR ) {
+		errno = WSAGetLastError();
+		return -1;
+	}
+	return 0;
+}
+
+int wpurple_getsockname(int socket, struct sockaddr *addr, socklen_t *lenptr) {
+        if(getsockname(socket, addr, lenptr) == SOCKET_ERROR) {
+                errno = WSAGetLastError();
+                return -1;
+        }
+        return 0;
+}
+
+int wpurple_bind(int socket, struct sockaddr *addr, socklen_t length) {
+        if(bind(socket, addr, length) == SOCKET_ERROR) {
+                errno = WSAGetLastError();
+                return -1;
+        }
+        return 0;
+}
+
+int wpurple_listen(int socket, unsigned int n) {
+        if(listen(socket, n) == SOCKET_ERROR) {
+                errno = WSAGetLastError();
+                return -1;
+        }
+        return 0;
+}
+
+int wpurple_sendto(int socket, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) {
+	int ret;
+	if ((ret = sendto(socket, buf, len, flags, to, tolen)
+			) == SOCKET_ERROR) {
+		errno = WSAGetLastError();
+		if(errno == WSAEWOULDBLOCK || errno == WSAEINPROGRESS)
+			errno = EAGAIN;
+		return -1;
+	}
+	return ret;
+}
+
+/* fcntl.h */
+/* This is not a full implementation of fcntl. Update as needed.. */
+int wpurple_fcntl(int socket, int command, ...) {
+
+	switch( command ) {
+	case F_GETFL:
+		return 0;
+
+	case F_SETFL:
+	{
+		va_list args;
+		int val;
+		int ret=0;
+
+		va_start(args, command);
+		val = va_arg(args, int);
+		va_end(args);
+
+		switch( val ) {
+		case O_NONBLOCK:
+		{
+			u_long imode=1;
+			ret = ioctlsocket(socket, FIONBIO, &imode);
+			break;
+		}
+		case 0:
+		{
+			u_long imode=0;
+			ret = ioctlsocket(socket, FIONBIO, &imode);
+			break;
+		}
+		default:
+			errno = EINVAL;
+			return -1;
+		}/*end switch*/
+		if( ret == SOCKET_ERROR ) {
+			errno = WSAGetLastError();
+			return -1;
+		}
+		return 0;
+	}
+	default:
+                LogDebug("fcntl: Unsupported command");
+		return -1;
+	}/*end switch*/
+}
+
+/* sys/ioctl.h */
+int wpurple_ioctl(int fd, int command, void* val) {
+	switch( command ) {
+	case FIONBIO:
+	{
+		if (ioctlsocket(fd, FIONBIO, (unsigned long *)val) == SOCKET_ERROR) {
+			errno = WSAGetLastError();
+			return -1;
+		}
+		return 0;
+	}
+	case SIOCGIFCONF:
+	{
+		INTERFACE_INFO InterfaceList[20];
+		unsigned long nBytesReturned;
+		if (WSAIoctl(fd, SIO_GET_INTERFACE_LIST,
+				0, 0, &InterfaceList,
+				sizeof(InterfaceList), &nBytesReturned,
+				0, 0) == SOCKET_ERROR) {
+			errno = WSAGetLastError();
+			return -1;
+		} else {
+			int i;
+			struct ifconf *ifc = val;
+			char *tmp = ifc->ifc_buf;
+			int nNumInterfaces =
+				nBytesReturned / sizeof(INTERFACE_INFO);
+			for (i = 0; i < nNumInterfaces; i++) {
+				INTERFACE_INFO ii = InterfaceList[i];
+				struct ifreq *ifr = (struct ifreq *) tmp;
+				struct sockaddr_in *sa = (struct sockaddr_in *) &ifr->ifr_addr;
+
+				sa->sin_family = ii.iiAddress.AddressIn.sin_family;
+				sa->sin_port = ii.iiAddress.AddressIn.sin_port;
+				sa->sin_addr.s_addr = ii.iiAddress.AddressIn.sin_addr.s_addr;
+				tmp += sizeof(struct ifreq);
+
+				/* Make sure that we can fit in the original buffer */
+				if (tmp >= (ifc->ifc_buf + ifc->ifc_len + sizeof(struct ifreq))) {
+					break;
+				}
+			}
+			/* Replace the length with the actually used length */
+			ifc->ifc_len = ifc->ifc_len - (ifc->ifc_buf - tmp);
+			return 0;
+		}
+	}
+	default:
+		errno = EINVAL;
+		return -1;
+	}/*end switch*/
+}
+
+/* arpa/inet.h */
+int wpurple_inet_aton(const char *name, struct in_addr *addr) {
+	if((addr->s_addr = inet_addr(name)) == INADDR_NONE)
+		return 0;
+	else
+		return 1;
+}
+
+/* Thanks to GNU wget for this inet_ntop() implementation */
+const char *
+wpurple_inet_ntop (int af, const void *src, char *dst, socklen_t cnt)
+{
+  /* struct sockaddr can't accomodate struct sockaddr_in6. */
+  union {
+    struct sockaddr_in6 sin6;
+    struct sockaddr_in sin;
+  } sa;
+  DWORD dstlen = cnt;
+  size_t srcsize;
+
+  ZeroMemory(&sa, sizeof(sa));
+  switch (af)
+    {
+    case AF_INET:
+      sa.sin.sin_family = AF_INET;
+      sa.sin.sin_addr = *(struct in_addr *) src;
+      srcsize = sizeof (sa.sin);
+      break;
+    case AF_INET6:
+      sa.sin6.sin6_family = AF_INET6;
+      sa.sin6.sin6_addr = *(struct in6_addr *) src;
+      srcsize = sizeof (sa.sin6);
+      break;
+    default:
+      abort ();
+    }
+
+  if (WSAAddressToString ((struct sockaddr *) &sa, srcsize, NULL, dst, &dstlen) != 0)
+    {
+      errno = WSAGetLastError();
+      return NULL;
+    }
+  return (const char *) dst;
+}
+
+
+/* netdb.h */
+struct hostent* wpurple_gethostbyname(const char *name) {
+	struct hostent *hp;
+
+	if((hp = gethostbyname(name)) == NULL) {
+		errno = WSAGetLastError();
+		return NULL;
+	}
+	return hp;
+}
+
+/* string.h */
+char* wpurple_strerror(int errornum) {
+	if (errornum > WSABASEERR) {
+		switch(errornum) {
+			case WSAECONNABORTED: /* 10053 */
+				snprintf(errbuf, sizeof(errbuf), _("Connection interrupted by other software on your computer."));
+				break;
+			case WSAECONNRESET: /* 10054 */
+				snprintf(errbuf, sizeof(errbuf), _("Remote host closed connection."));
+				break;
+			case WSAETIMEDOUT: /* 10060 */
+				snprintf(errbuf, sizeof(errbuf), _("Connection timed out."));
+				break;
+			case WSAECONNREFUSED: /* 10061 */
+				snprintf(errbuf, sizeof(errbuf), _("Connection refused."));
+				break;
+			case WSAEADDRINUSE: /* 10048 */
+				snprintf(errbuf, sizeof(errbuf), _("Address already in use."));
+				break;
+			default:
+				snprintf(errbuf, sizeof(errbuf), "Windows socket error #%d", errornum);
+		}
+	} else {
+		const char *tmp = strerror(errornum);
+		snprintf(errbuf, sizeof(errbuf), tmp);
+	}
+	return errbuf;
+}
+
+/* unistd.h */
+
+/*
+ *  We need to figure out whether fd is a file or socket handle.
+ */
+int wpurple_read(int fd, void *buf, unsigned int size) {
+	int ret;
+
+	if (fd < 0) {
+		errno = EBADF;
+		return -1;
+	}
+
+	if(wpurple_is_socket(fd)) {
+		if((ret = recv(fd, buf, size, 0)) == SOCKET_ERROR) {
+			errno = WSAGetLastError();
+			if(errno == WSAEWOULDBLOCK || errno == WSAEINPROGRESS)
+				errno = EAGAIN;
+			return -1;
+		}
+#if 0
+		else if( ret == 0 ) {
+			/* connection has been gracefully closed */
+			errno = WSAENOTCONN;
+			return -1;
+		}
+#endif
+		else {
+			/* success reading socket */
+			return ret;
+		}
+	} else {
+		/* fd is not a socket handle.. pass it off to read */
+		return _read(fd, buf, size);
+	}
+}
+
+int wpurple_send(int fd, const void *buf, unsigned int size, int flags) {
+	int ret;
+
+	ret = send(fd, buf, size, flags);
+
+	if (ret == SOCKET_ERROR) {
+		errno = WSAGetLastError();
+		if(errno == WSAEWOULDBLOCK || errno == WSAEINPROGRESS)
+			errno = EAGAIN;
+		return -1;
+	}
+	return ret;
+}
+
+int wpurple_write(int fd, const void *buf, unsigned int size) {
+
+	if (fd < 0) {
+		errno = EBADF;
+		return -1;
+	}
+
+	if(wpurple_is_socket(fd))
+		return wpurple_send(fd, buf, size, 0);
+	else
+		return _write(fd, buf, size);
+}
+
+int wpurple_recv(int fd, void *buf, size_t len, int flags) {
+	int ret;
+
+	if((ret = recv(fd, buf, len, flags)) == SOCKET_ERROR) {
+			errno = WSAGetLastError();
+			if(errno == WSAEWOULDBLOCK || errno == WSAEINPROGRESS)
+				errno = EAGAIN;
+			return -1;
+	} else {
+		return ret;
+	}
+}
+
+int wpurple_close(int fd) {
+	int ret;
+
+	if (fd < 0) {
+		errno = EBADF;
+		return -1;
+	}
+
+	if( wpurple_is_socket(fd) ) {
+		if( (ret = closesocket(fd)) == SOCKET_ERROR ) {
+			errno = WSAGetLastError();
+			return -1;
+		}
+		else {
+			return 0;
+		}
+	}
+	else {
+		return _close(fd);
+	}
+}
+
+int wpurple_gethostname(char *name, size_t size) {
+        if(gethostname(name, size) == SOCKET_ERROR) {
+                errno = WSAGetLastError();
+			return -1;
+        }
+        return 0;
+}
+
+/* sys/time.h */
+
+int wpurple_gettimeofday(struct timeval *p, struct timezone *z) {
+	int res = 0;
+	struct _timeb timebuffer;
+
+	if (z != 0) {
+		_tzset();
+		z->tz_minuteswest = _timezone/60;
+		z->tz_dsttime = _daylight;
+	}
+
+	if (p != 0) {
+		_ftime(&timebuffer);
+		p->tv_sec = timebuffer.time;			/* seconds since 1-1-1970 */
+		p->tv_usec = timebuffer.millitm*1000; 	/* microseconds */
+	}
+
+	return res;
+}
+
+/* stdio.h */
+
+//int wpurple_rename (const char *oldname, const char *newname) {
+//	return -1; //g_rename(oldname, newname);
+//}
+
+/* time.h */
+
+//struct tm * wpurple_localtime_r (const time_t *time, struct tm *resultp) {
+//	struct tm* tmptm;
+//
+//	if(!time)
+//		return NULL;
+//	tmptm = localtime(time);
+//	if(resultp && tmptm)
+//		return memcpy(resultp, tmptm, sizeof(struct tm));
+//	else
+//		return NULL;
+//}
+
+int trousers_flock(int fd, int operation)
+{
+	HANDLE h = (HANDLE) _get_osfhandle (fd);
+	DWORD res;
+	OVERLAPPED ovlp;
+	int non_blocking;
+	DWORD size_lower = -1, size_upper = -1;
+	int flags = 0;
+	DWORD NumBytes;
+
+	if (h == INVALID_HANDLE_VALUE) {
+		errno = EBADF;
+		return -1;
+	}
+
+	non_blocking = operation & LOCK_NB;
+	operation &= ~LOCK_NB;
+	memset (&ovlp, 0, sizeof ovlp);
+
+	if (non_blocking)
+		flags |= LOCKFILE_FAIL_IMMEDIATELY;
+
+	switch (operation) {
+	case LOCK_SH:
+		res = LockFileEx (h, flags, 0, size_lower, size_upper, &ovlp);
+		break;
+	case LOCK_EX:
+		res = LockFileEx (h, flags | LOCKFILE_EXCLUSIVE_LOCK, 0, size_lower, size_upper, &ovlp);
+		break;
+	case LOCK_UN:
+		res = UnlockFileEx (h, 0, size_lower, size_upper, &ovlp);
+		break;
+	default:
+		errno = EINVAL;
+		CloseHandle(ovlp.hEvent);
+		return -1;
+	}
+
+	/* Map Windows errors into Unix errnos.  As usual MSDN fails to
+	* document the permissible error codes.
+	*/
+	if (!res) {
+		DWORD err = GetLastError ();
+		switch (err) {
+		/* This means someone else is holding a lock. */
+		case ERROR_LOCK_VIOLATION:
+			errno = EAGAIN;
+			break;
+
+		  /* Out of memory. */
+		case ERROR_NOT_ENOUGH_MEMORY:
+			errno = ENOMEM;
+			break;
+
+		case ERROR_BAD_COMMAND:
+			errno = EINVAL;
+			break;
+		case ERROR_IO_PENDING:
+			if (GetOverlappedResult(h, &ovlp, &NumBytes, TRUE) == FALSE) {
+				LogError("GetOverlappedResult for Overlapped.hEvent failed with error 0x%08x.", 
+						GetLastError());
+				CloseHandle(ovlp.hEvent);
+				return -1;
+			}
+			res = TRUE;
+			break;
+		default:
+			errno = err;
+		}
+		CloseHandle(ovlp.hEvent);
+		return -1;
+	}
+
+	CloseHandle(ovlp.hEvent);
+	return 0;
+}
+
+int trousers_strncasecmp(char *s1, char *s2, size_t n)
+{
+	if (n == 0)
+		return 0;
+
+	while (n-- != 0 && tolower(*s1) == tolower(*s2)) {
+		if (n == 0 || *s1 == '\0' || *s2 == '\0')
+			break;
+		s1++;
+		s2++;
+	}
+
+	return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
+}
+
+int trousers_strcasecmp(char *s1, char *s2)
+{
+	while (*s1 != '\0' && tolower(*s1) == tolower(*s2)) {
+		s1++;
+		s2++;
+	}
+
+	return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
+}
+
+int trousers_mlock(const void *addr, size_t len) {
+	if (VirtualLock ((void *)addr, len) == 0)
+		return 0;
+	else
+		return -1;
+}
+
+int trousers_munlock(const void *addr, size_t len) {
+	if (VirtualUnlock ((void *)addr, len) == 0)
+		return 0;
+	else
+		return -1;
+}
diff --git a/src/win32/win32dep.c b/src/win32/win32dep.c
new file mode 100644
index 0000000..b1690a4
--- /dev/null
+++ b/src/win32/win32dep.c
@@ -0,0 +1,141 @@
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include <windows.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <time.h>
+#include <fcntl.h>
+#ifdef __MINGW32__
+#include <userenv.h>
+#else
+#include <Userenv.h>
+#include <direct.h>
+#endif /* __MINGW32__ */
+
+#define trousers_log_file "C://Trousers/tcsd_log.txt"
+#define MAX_LINE_LEN 512
+#define HEADER_LEN 20
+
+#undef snprintf
+#define snprintf _snprintf
+
+char *trousers_getUserDir(void)			//WARNING: code from PhysicsFS
+{
+	DWORD psize = 100;
+	char dummy[100];
+	BOOL rc = 0;
+	HANDLE processHandle;
+	HANDLE accessToken = NULL;
+	char *userDir = NULL;
+
+	processHandle = GetCurrentProcess();
+	if (OpenProcessToken(processHandle, TOKEN_QUERY, &accessToken)) {
+		rc = GetUserProfileDirectory(accessToken, dummy, &psize);
+		if(!rc)
+			return NULL;
+
+		userDir = strdup(dummy);
+
+		CloseHandle(processHandle);
+	}
+	return userDir;
+}
+
+
+/* Private pseudo-random number seed. Unsigned integer >= 32bit. Threads
+   mutual exclusion is not implemented to acess it since we do not require
+   high quality random numbers (only used in form boudary generation). */
+
+static unsigned int randseed;
+
+/* Pseudo-random number support. */
+
+unsigned int Curl_rand(void)
+{
+	unsigned int r;
+	/* Return an unsigned 32-bit pseudo-random number. */
+	r = randseed = randseed * 1103515245 + 12345;
+	return (r << 16) | ((r >> 16) & 0xFFFF);
+}
+
+void Curl_srand(void)
+{
+	/* Randomize pseudo-random number sequence. */
+
+	randseed = (unsigned int) time(NULL);
+	Curl_rand();
+	Curl_rand();
+	Curl_rand();
+}
+
+void trousers_setenv(const char *name, const char *value, int overwrite) {
+	int len = 0;
+	char *str = NULL;
+
+	if (getenv(name) != NULL && overwrite == 0)
+		return;
+
+	len = strlen(name) + 1 + strlen(value) + 1 + 1;
+	str = malloc(len);
+	if (str == NULL)
+		return;
+
+	snprintf(str, len, "%s=%s", name, value);
+	putenv(str);
+	free(str);
+}
+
+void trousers_log(const char *layer, const char *fmt, ...)
+{
+	int fh;
+	va_list ap;
+	char *line = NULL;
+	int offset = 0;
+
+	time_t tv;
+	struct tm t;
+	time(&tv);
+	memcpy(&t, localtime(&tv), sizeof(t));
+	va_start(ap, fmt);
+
+	fh = open(trousers_log_file, O_CREAT | O_WRONLY | O_APPEND | O_BINARY, 0600);
+	if (fh >=0) {
+		line = (char *)malloc(MAX_LINE_LEN);
+		if (line == NULL)
+			return;
+
+		memset(line, 0, MAX_LINE_LEN);
+		offset += snprintf(line, MAX_LINE_LEN, "%04d-%02d-%02d %02d:%02d:%02d ",
+			t.tm_year + 1900, t.tm_mon + 1, t.tm_mday,
+			t.tm_hour, t.tm_min, t.tm_sec);
+		offset += snprintf(line + offset, MAX_LINE_LEN - offset, "-%s- ", layer);
+		offset += vsnprintf(line + offset, MAX_LINE_LEN - offset, fmt, ap);
+		write(fh, line, offset);
+		close(fh);
+		free(line);
+	}
+	va_end(ap);
+}
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 41c87ba..7a404f6 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -7,3 +7,9 @@ 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
+
+
+if OS_WIN32
+ps_inspect_LDADD+=${top_builddir}/src/win32/libc_interface.la
+ps_convert_LDADD+=${top_builddir}/src/win32/libc_interface.la
+endif
diff --git a/tools/ps_convert.c b/tools/ps_convert.c
index 2a2d85a..63caf4d 100644
--- a/tools/ps_convert.c
+++ b/tools/ps_convert.c
@@ -64,7 +64,7 @@
 #define PRINTERR(...)	fprintf(stderr, ##__VA_ARGS__)
 #define PRINT(...)	printf("PS " __VA_ARGS__)
 
-#define OUT(stream, buf, size) \
+#define OUTDATA(stream, buf, size) \
 	do { \
 		if (fwrite(buf, size, 1, stream) != 1) { \
 			PRINTERR("fwrite error: %s\n", strerror(errno)); \
@@ -107,17 +107,17 @@ convertkey_0(FILE *in, FILE *out)
 	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));
+	OUTDATA(out, buf, sizeof(TSS_UUID));
+	OUTDATA(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));
+	OUTDATA(out, &pub_data_size, sizeof(UINT16));
+	OUTDATA(out, &blob_size, sizeof(UINT16));
+	OUTDATA(out, &vendor_data_size, sizeof(UINT32));
+	OUTDATA(out, &cache_flags, sizeof(UINT16));
 
 	/* trash buf, we've got what we needed from it */
 	if ((members = fread(buf, pub_data_size + blob_size,
@@ -126,8 +126,8 @@ convertkey_0(FILE *in, FILE *out)
 		return -1;
 	}
 
-	OUT(out, buf, pub_data_size);
-	OUT(out, &buf[pub_data_size], blob_size);
+	OUTDATA(out, buf, pub_data_size);
+	OUTDATA(out, &buf[pub_data_size], blob_size);
 
 	return 0;
 }
@@ -140,10 +140,10 @@ version_0_convert(FILE *in, FILE *out)
 	UINT32 *u32 = (UINT32 *) &buf;
 
 	/* output the PS version */
-	OUT(out, "\1", 1);
+	OUTDATA(out, "\1", 1);
 
 	/* number of keys */
-	OUT(out, u32, sizeof(UINT32));
+	OUTDATA(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 */
