aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TPM2-Plugin/lib/tpm2_plugin_api.c26
-rwxr-xr-xtest/integration/samplecaservicecontainer/applicationfiles/CaSign.java8
2 files changed, 24 insertions, 10 deletions
diff --git a/TPM2-Plugin/lib/tpm2_plugin_api.c b/TPM2-Plugin/lib/tpm2_plugin_api.c
index 75e4fc1..c763ef3 100644
--- a/TPM2-Plugin/lib/tpm2_plugin_api.c
+++ b/TPM2-Plugin/lib/tpm2_plugin_api.c
@@ -414,20 +414,34 @@ int load_key_execute(SSHSM_HW_PLUGIN_ACTIVATE_LOAD_IN_INFO_t *loadkey_in_info,
int returnVal = 0;
memset(&inPublic,0,sizeof(TPM2B_PUBLIC));
- memset(&inPrivate,0,sizeof(TPM2B_SENSITIVE));
+ memset(&inPrivate,0,sizeof(TPM2B_PRIVATE));
setbuf(stdout, NULL);
setvbuf (stdout, NULL, _IONBF, BUFSIZ);
- //parentHandle = 0x81000011;
parentHandle = srk_handle;
if (loadkey_in_info->num_buffers != 2)
return -1;
- memcpy(&inPublic, loadkey_in_info->buffer_info[0]->buffer,
- loadkey_in_info->buffer_info[0]->length_of_buffer);
- memcpy(&inPrivate, loadkey_in_info->buffer_info[1]->buffer,
- loadkey_in_info->buffer_info[1]->length_of_buffer);
+
+ /*
+ Identify which buffer is public vs which is private
+ TPM2B_PUBLIC should be 360 bytes
+ TPM2B_PRIVATE should be 912 bytes
+ */
+
+ for (int i=0; i<2; i++) {
+ if (loadkey_in_info->buffer_info[i]->length_of_buffer == sizeof(TPM2B_PUBLIC)) {
+ memcpy(&inPublic, loadkey_in_info->buffer_info[i]->buffer,
+ loadkey_in_info->buffer_info[i]->length_of_buffer);
+ continue;
+ }
+ if (loadkey_in_info->buffer_info[i]->length_of_buffer == sizeof(TPM2B_PRIVATE)) {
+ memcpy(&inPrivate, loadkey_in_info->buffer_info[i]->buffer,
+ loadkey_in_info->buffer_info[i]->length_of_buffer);
+ continue;
+ }
+ }
returnVal = load_key (sapi_context,
parentHandle,
diff --git a/test/integration/samplecaservicecontainer/applicationfiles/CaSign.java b/test/integration/samplecaservicecontainer/applicationfiles/CaSign.java
index a43e262..61cdf0b 100755
--- a/test/integration/samplecaservicecontainer/applicationfiles/CaSign.java
+++ b/test/integration/samplecaservicecontainer/applicationfiles/CaSign.java
@@ -107,7 +107,7 @@ public class CaSign {
System.out.println(args[i]);
}
// Set up the Sun PKCS 11 provider
- String configName = "/tmp/pkcs11.cfg";
+ String configName = "pkcs11.cfg";
Provider p = new SunPKCS11(configName);
//Provider p = Security.getProvider("SunPKCS11-pkcs11Test");
if (p==null) {
@@ -128,7 +128,7 @@ public class CaSign {
PrivateKeyEntry privateKeyEntry = (PrivateKeyEntry) keyStore.getEntry(args[1], null);
PrivateKey privateKey = privateKeyEntry.getPrivateKey();
- File csrf = new File("/tmp/test.csr");
+ File csrf = new File("test.csr");
if ( csrf == null )
System.out.println("Make sure to copy the test.csr file to /tmp");
Reader pemcsr = new FileReader(csrf);
@@ -192,10 +192,10 @@ public class CaSign {
sw.write("-----BEGIN CERTIFICATE-----\n");
sw.write(DatatypeConverter.printBase64Binary(x509.getEncoded()).replaceAll("(.{64})", "$1\n"));
sw.write("\n-----END CERTIFICATE-----\n");
- FileWriter fw = new FileWriter("/tmp/test.cert");
+ FileWriter fw = new FileWriter("test.cert");
fw.write(sw.toString());
fw.close();
- System.out.println("Done - Signed certificate at /tmp/test.cert");
+ System.out.println("Done - Signed certificate at test.cert");
}
}