aboutsummaryrefslogtreecommitdiffstats
path: root/tpm-util/import
diff options
context:
space:
mode:
Diffstat (limited to 'tpm-util/import')
-rw-r--r--tpm-util/import/include/tpm_wrapper.h17
-rw-r--r--tpm-util/import/main.c8
-rw-r--r--tpm-util/import/sampleMakefile2
-rw-r--r--tpm-util/import/tpm_wrapper.c58
4 files changed, 39 insertions, 46 deletions
diff --git a/tpm-util/import/include/tpm_wrapper.h b/tpm-util/import/include/tpm_wrapper.h
index 4d1639d..ac91532 100644
--- a/tpm-util/import/include/tpm_wrapper.h
+++ b/tpm-util/import/include/tpm_wrapper.h
@@ -25,17 +25,22 @@
#include <ctype.h>
#include <getopt.h>
-#include <sapi/tpm20.h>
-
-#include <tcti/tcti-tabrmd.h>
+#include <tss2/tss2_sys.h>
+#include <tss2/tss2-tcti-tabrmd.h>
+#include <tss2/tss2_common.h>
+#include <tss2/tss2_esys.h>
+#include <tss2/tss2_mu.h>
+#include <tss2/tss2_tcti.h>
+#include <tss2/tss2_tpm2_types.h>
+#include <tss2/tpm2b.h>
#ifdef __cplusplus
extern "C" {
#endif
-#define INIT_SIMPLE_TPM2B_SIZE( type ) (type).t.size = sizeof( type ) - 2;
+#define INIT_SIMPLE_TPM2B_SIZE( type ) (type).size = sizeof( type ) - 2;
-TSS2_TCTI_CONTEXT* tpm_tcti_tabrmd_init (void);
+TSS2_TCTI_CONTEXT* tpm2_tcti_tabrmd_init (void);
TSS2_SYS_CONTEXT* sys_ctx_init (TSS2_TCTI_CONTEXT *tcti_ctx);
@@ -46,7 +51,7 @@ void TeardownSysContext( TSS2_SYS_CONTEXT **sysContext );
TSS2_RC swKeyTpmImport(
/* IN */
TSS2_SYS_CONTEXT *sysContext,
- TPM_HANDLE parentKeyHandle,
+ TPM2_HANDLE parentKeyHandle,
TPM2B_DATA* encryptionKey, TPM2B_PUBLIC* swKeyPublic, TPM2B_PRIVATE* swKeyPrivate, TPM2B_ENCRYPTED_SECRET* encSymSeed,
unsigned char* tpm_pwd, int tpm_pwd_len,
/* OUT */
diff --git a/tpm-util/import/main.c b/tpm-util/import/main.c
index 8f66fd6..678dffc 100644
--- a/tpm-util/import/main.c
+++ b/tpm-util/import/main.c
@@ -23,8 +23,6 @@
#include <string.h>
#include <unistd.h>
-#include <sapi/tpm20.h>
-
#include "tpm_wrapper.h"
#include "util.h"
@@ -45,7 +43,7 @@ void PrintHelp()
int main(int argc, char* argv[])
{
- TPM_RC rval = 0;
+ TPM2_RC rval = 0;
int count=0;
TSS2_TCTI_CONTEXT *tcti_ctx = 0;
TSS2_SYS_CONTEXT *sysContext = 0;
@@ -72,7 +70,7 @@ int main(int argc, char* argv[])
int priv_flag = 0;
unsigned short file_size = 0;
- TPM_HANDLE primaryKeyHandle = 0;
+ TPM2_HANDLE primaryKeyHandle = 0;
int H_flag = 0;
TPM2B_PUBLIC parentKeyPublicPortion;
@@ -207,7 +205,7 @@ int main(int argc, char* argv[])
if ( rval == 0 ) {
/* Initialize TCTI and sapi context */
- tcti_ctx = tpm_tcti_tabrmd_init();
+ tcti_ctx = tpm2_tcti_tabrmd_init();
if(tcti_ctx == NULL) {
printf("Creation of TCTI context with TABRMD failed ! \n");
goto end;
diff --git a/tpm-util/import/sampleMakefile b/tpm-util/import/sampleMakefile
index 96ac729..000b4da 100644
--- a/tpm-util/import/sampleMakefile
+++ b/tpm-util/import/sampleMakefile
@@ -16,7 +16,7 @@ OBJS= util.o \
CFLAGS += -g -fPIC -I./include -I${TSS_DIR}/include/ -I$(TSS_DIR)/sysapi/include
-LDFLAGS += -ldl -L/usr/local/lib/ -lsapi -ltcti-device -ltcti-tabrmd
+LDFLAGS += -L/usr/local/lib/ -ltss2-tcti-device -ltss2-sys -ltss2-tcti-tabrmd -ldl
LIBS = -lpthread -lcrypto -lssl
diff --git a/tpm-util/import/tpm_wrapper.c b/tpm-util/import/tpm_wrapper.c
index 5f4ab2a..b593d24 100644
--- a/tpm-util/import/tpm_wrapper.c
+++ b/tpm-util/import/tpm_wrapper.c
@@ -21,61 +21,49 @@
#include "util.h"
#include <errno.h>
-
-#include <sapi/tpm20.h>
-#include <sapi/tss2_sys.h>
-#include <tcti/tcti_device.h>
-#include "tcti_util.h"
+#define TSSWG_INTEROP 1
+#define TSS_SAPI_FIRST_FAMILY 2
+#define TSS_SAPI_FIRST_LEVEL 1
+#define TSS_SAPI_FIRST_VERSION 108
TSS2_RC swKeyTpmImport(
/* IN */
TSS2_SYS_CONTEXT *sysContext,
- TPM_HANDLE parentKeyHandle,
+ TPM2_HANDLE parentKeyHandle,
TPM2B_DATA* encryptionKey, TPM2B_PUBLIC* swKeyPublic, TPM2B_PRIVATE* swKeyPrivate, TPM2B_ENCRYPTED_SECRET* encSymSeed,
unsigned char* tpm_pwd, int tpm_pwd_len,
/* OUT */
TPM2B_PRIVATE *importPrivate)
{
- TPM_RC rval = TPM_RC_SUCCESS;
- TPM2B_NAME name = { { sizeof( TPM2B_NAME ) - 2, } };
+ TPM2_RC rval = TPM2_RC_SUCCESS;
+ TPM2B_NAME name = {sizeof( TPM2B_NAME ) - 2};
- TPM_HANDLE wrapperKeyHandle;
+ TPM2_HANDLE wrapperKeyHandle;
- TSS2_SYS_CMD_AUTHS npsessionsData;
- TSS2_SYS_RSP_AUTHS npsessionsDataOut;
- TPMS_AUTH_COMMAND npsessionData;
- TPMS_AUTH_RESPONSE npsessionDataOut;
+ TSS2L_SYS_AUTH_RESPONSE npsessionsDataOut;
if(NULL == tpm_pwd) {
printf("TPM password pinter is NULL \n");
return -1;
}
- *((UINT8 *)((void *)&npsessionData.sessionAttributes)) = 0;
- npsessionData.sessionHandle = TPM_RS_PW;
- npsessionData.nonce.t.size = 0;
- npsessionData.hmac.t.size = 0;
+TSS2L_SYS_AUTH_COMMAND npsessionsData = { .count = 1, .auths = {{
+ .sessionHandle = TPM2_RS_PW,
+ .sessionAttributes = 0,
+ .nonce = {.size = 0},
+ .hmac = {.size = 0}}}};
- npsessionData.hmac.t.size = tpm_pwd_len;
+ npsessionsData.auths[0].hmac.size = tpm_pwd_len;
if(tpm_pwd_len > 0)
{
- memcpy(npsessionData.hmac.t.buffer, tpm_pwd, npsessionData.hmac.t.size);
+ memcpy(npsessionsData.auths[0].hmac.buffer, tpm_pwd, npsessionsData.auths[0].hmac.size);
}
- TPMS_AUTH_COMMAND *npsessionDataArray[1];
- TPMS_AUTH_RESPONSE *npsessionDataOutArray[1];
TPMT_SYM_DEF_OBJECT symmetricAlg;
- npsessionDataArray[0] = &npsessionData;
- npsessionDataOutArray[0] = &npsessionDataOut;
- npsessionsData.cmdAuthsCount = 1;
- npsessionsData.cmdAuths = &npsessionDataArray[0];
- npsessionsDataOut.rspAuthsCount = 1;
- npsessionsDataOut.rspAuths = &npsessionDataOutArray[0];
-
- symmetricAlg.algorithm = TPM_ALG_AES;
+ symmetricAlg.algorithm = TPM2_ALG_AES;
symmetricAlg.keyBits.aes = 128;
- symmetricAlg.mode.aes = TPM_ALG_CFB;
+ symmetricAlg.mode.aes = TPM2_ALG_CFB;
rval = Tss2_Sys_Import( sysContext,
parentKeyHandle,
@@ -110,13 +98,13 @@ TSS2_RC swKeyTpmImport(
return rval;
}
-TSS2_TCTI_CONTEXT* tpm_tcti_tabrmd_init (void)
+TSS2_TCTI_CONTEXT* tpm2_tcti_tabrmd_init (void)
{
TSS2_TCTI_CONTEXT *tcti_ctx;
TSS2_RC rc;
size_t size;
- rc = tss2_tcti_tabrmd_init(NULL, &size);
+ rc = Tss2_Tcti_Tabrmd_Init(NULL, &size, NULL);
if (rc != TSS2_RC_SUCCESS) {
printf ("Failed to get size for TABRMD TCTI context: 0x%x", rc);
return NULL;
@@ -128,7 +116,7 @@ TSS2_TCTI_CONTEXT* tpm_tcti_tabrmd_init (void)
strerror (errno));
return NULL;
}
- rc = tss2_tcti_tabrmd_init (tcti_ctx, &size);
+ rc = Tss2_Tcti_Tabrmd_Init (tcti_ctx, &size, NULL);
if (rc != TSS2_RC_SUCCESS) {
printf ("Failed to initialize TABRMD TCTI context: 0x%x", rc);
free (tcti_ctx);
@@ -170,7 +158,9 @@ TSS2_SYS_CONTEXT* sys_ctx_init (TSS2_TCTI_CONTEXT *tcti_ctx)
TSS2_RC TeardownTctiContext( TSS2_TCTI_CONTEXT *tctiContext )
{
- ((TSS2_TCTI_CONTEXT_INTEL *)tctiContext)->finalize( tctiContext );
+ //(tctiContext)->finalize( tctiContext );
+ //TSS2_TCTI_FINALIZiE(tctiContext);
+ Tss2_Tcti_Finalize (tctiContext);
free (tctiContext);
tctiContext = NULL;
return TSS2_RC_SUCCESS;