File tpm-tools-1.3.1_SRKpwd-for-unseal-lib_v20080713.patch of Package tpm-tools

diff -ur ./include/tpm_unseal.h ../tpm-tools-1.3.1-SRKpwd/include/tpm_unseal.h
--- ./include/tpm_unseal.h	2006-03-15 23:06:08.000000000 +0100
+++ ../tpm-tools-1.3.1-SRKpwd/include/tpm_unseal.h	2008-07-13 19:28:36.000000000 +0200
@@ -19,6 +19,14 @@
  * http://www.opensource.org/licenses/cpl1.0.php.
  */
 
+/*
+ * Portions by G. Ramunno (Politecnico di Torino, http://security.polito.it)
+ * for the OpenTC project (http://www.opentc.net). 
+ *
+ * The OpenTC project is developed by Open_TC consortium and co-financed by
+ * the European Commission (contract no.: IST-027635).
+*/
+
 #ifndef __TPM_UNSEAL_H
 #define __TPM_UNSEAL_H
 
@@ -37,7 +45,8 @@
 
 extern int tpm_errno;
 
-int tpmUnsealFile(char*, unsigned char**, int*);
+int tpmUnsealFile(char*, unsigned char**, int*); 
+int tpmUnsealFileSRKpwd(char*, unsigned char**, int*, char*); /* OpenTC */
 void tpmUnsealShred(unsigned char*, int);
 char* tpmUnsealStrerror(int);
 
diff -ur ./lib/tpm_unseal.c ../tpm-tools-1.3.1-SRKpwd/lib/tpm_unseal.c
--- ./lib/tpm_unseal.c	2007-05-31 19:18:42.000000000 +0200
+++ ../tpm-tools-1.3.1-SRKpwd/lib/tpm_unseal.c	2008-07-13 19:29:16.000000000 +0200
@@ -19,6 +19,14 @@
  * http://www.opensource.org/licenses/cpl1.0.php.
  */
 
+/*
+ * Portions by G. Ramunno (Politecnico di Torino, http://security.polito.it)
+ * for the OpenTC project (http://www.opentc.net). 
+ *
+ * The OpenTC project is developed by Open_TC consortium and co-financed by
+ * the European Commission (contract no.: IST-027635).
+*/
+
 #include "tpm_tspi.h"
 #include "tpm_seal.h"
 #include "tpm_unseal.h"
@@ -65,9 +73,18 @@
 int tpm_errno;
 TSS_UUID SRK_UUID = TSS_UUID_SRK;
 
+/* OpenTC: added wrapper for backward compatibility */
 int tpmUnsealFile( char* fname, unsigned char** tss_data, int* tss_size ) {
+	
+	return tpmUnsealFileSRKpwd( fname, tss_data, tss_size, (char* )NULL );
+
+}
+
+/* OpenTC: function updated to support the SRK password and name changed */
+int tpmUnsealFileSRKpwd( char* fname, unsigned char** tss_data, int* tss_size, char* SRKpwd ) {
 
 	int rc, rcLen=0, tssLen=0, evpLen=0;
+	int SRKpwdLen=0; /* OpenTC */
 	BYTE* rcPtr;
 	char data[EVP_CIPHER_block_size(EVP_aes_256_cbc()) * 16];
 	BYTE *tssKeyData = NULL;
@@ -332,7 +349,13 @@
 		goto tss_out;
 	}
 
-	if ((rc=Tspi_Policy_SetSecret(hPolicy, TSS_SECRET_MODE_PLAIN, 0, NULL)) 
+	/* OpenTC: added setting for SRK password */
+	if (SRKpwd != NULL)
+		SRKpwdLen = strlen(SRKpwd);
+		
+	/* OpenTC: added setting for SRK password */
+	if ((rc=Tspi_Policy_SetSecret(hPolicy, TSS_SECRET_MODE_PLAIN,
+					SRKpwdLen, (BYTE *) SRKpwd )) 
 					!= TSS_SUCCESS) {
 		tpm_errno = ETSPIPOLSS;
 		goto tss_out;
openSUSE Build Service is sponsored by