summaryrefslogtreecommitdiffstats
path: root/TPM2-Plugin
diff options
context:
space:
mode:
Diffstat (limited to 'TPM2-Plugin')
-rwxr-xr-x[-rw-r--r--]TPM2-Plugin/bootstrap0
-rw-r--r--TPM2-Plugin/lib/tpm2_plugin_api.c33
2 files changed, 20 insertions, 13 deletions
diff --git a/TPM2-Plugin/bootstrap b/TPM2-Plugin/bootstrap
index 2a09c33..2a09c33 100644..100755
--- a/TPM2-Plugin/bootstrap
+++ b/TPM2-Plugin/bootstrap
diff --git a/TPM2-Plugin/lib/tpm2_plugin_api.c b/TPM2-Plugin/lib/tpm2_plugin_api.c
index c27ec55..b328413 100644
--- a/TPM2-Plugin/lib/tpm2_plugin_api.c
+++ b/TPM2-Plugin/lib/tpm2_plugin_api.c
@@ -247,7 +247,7 @@ static TSS2_SYS_CONTEXT *sapi_ctx_init (TSS2_TCTI_CONTEXT *tcti_ctx)
#define BUFFER_SIZE(type, field) (sizeof((((type *)NULL)->t.field)))
#define TPM2B_TYPE_INIT(type, field) { .t = { .size = BUFFER_SIZE(type, field), }, }
-TPMS_AUTH_COMMAND sessionData;
+
int hex2ByteStructure(const char *inStr, UINT16 *byteLength, BYTE *byteBuffer)
{
int strLength;//if the inStr likes "1a2b...", no prefix "0x"
@@ -279,6 +279,7 @@ int hex2ByteStructure(const char *inStr, UINT16 *byteLength, BYTE *byteBuffer)
}
int load_key(TSS2_SYS_CONTEXT *sapi_context,
+ TPMS_AUTH_COMMAND sessionData,
TPMI_DH_OBJECT parentHandle,
TPM2B_PUBLIC *inPublic,
TPM2B_PRIVATE *inPrivate)
@@ -301,10 +302,6 @@ int load_key(TSS2_SYS_CONTEXT *sapi_context,
sessionsDataOut.rspAuthsCount = 1;
sessionsData.cmdAuthsCount = 1;
- sessionData.sessionHandle = TPM_RS_PW;
- sessionData.nonce.t.size = 0;
-
- *((UINT8 *)((void *)&sessionData.sessionAttributes)) = 0;
if (sessionData.hmac.t.size > 0 && hexPasswd)
{
sessionData.hmac.t.size = sizeof(sessionData.hmac) - 2;
@@ -400,21 +397,19 @@ int read_public(TSS2_SYS_CONTEXT *sapi_context,
/*
Reads the PRK_PASSWORD Environment variable
and populates that information into the
-sessionData global environment variable
+provided sessionData variable
*/
-int readPassword()
+int readPassword(TPMS_AUTH_COMMAND *sessionData)
{
char *prk_passwd;
- sessionData.hmac.t.size = 0;
-
prk_passwd = getenv("TPM_PRK_PASSWORD");
if (prk_passwd != NULL) {
- sessionData.hmac.t.size = strlen(prk_passwd);
- if (sessionData.hmac.t.size > sizeof(sessionData.hmac.t.buffer)) {
+ sessionData->hmac.t.size = strlen(prk_passwd);
+ if (sessionData->hmac.t.size > sizeof(sessionData->hmac.t.buffer)) {
return -1;
}
- memcpy(sessionData.hmac.t.buffer, prk_passwd, sessionData.hmac.t.size);
+ memcpy(sessionData->hmac.t.buffer, prk_passwd, sessionData->hmac.t.size);
return 0;
}
return 0;
@@ -430,9 +425,20 @@ int load_key_execute(SSHSM_HW_PLUGIN_ACTIVATE_LOAD_IN_INFO_t *loadkey_in_info,
TPMI_DH_OBJECT parentHandle;
TPM2B_PUBLIC inPublic;
TPM2B_PRIVATE inPrivate;
+ TPMS_AUTH_COMMAND sessionData;
UINT16 size;
int returnVal = 0;
+ /*
+ Initializing the sessionData structure to the 0 values
+ sessionAttributes is a union and the following assignment
+ is based on the method used in other tpm2 tools.
+ */
+ *((UINT8 *)((void *)&sessionData.sessionAttributes)) = 0;
+ sessionData.sessionHandle = TPM_RS_PW;
+ sessionData.nonce.t.size = 0;
+ sessionData.hmac.t.size = 0;
+
memset(&inPublic,0,sizeof(TPM2B_PUBLIC));
memset(&inPrivate,0,sizeof(TPM2B_PRIVATE));
@@ -464,12 +470,13 @@ int load_key_execute(SSHSM_HW_PLUGIN_ACTIVATE_LOAD_IN_INFO_t *loadkey_in_info,
}
// Read TPM_PRK_PASSWORD and setup sessionsData appropriately
- if (readPassword() != 0) {
+ if (readPassword(&sessionData) != 0) {
// Password read failure
return -1;
}
returnVal = load_key (sapi_context,
+ sessionData,
parentHandle,
&inPublic,
&inPrivate);
round-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.onap.ccsdk.parent</groupId>
        <artifactId>odlparent-lite</artifactId>
        <version>2.5.3</version>
    </parent>

    <groupId>org.onap.sdnc.northbound</groupId>
    <artifactId>vnftools</artifactId>
    <version>2.5.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>VNF Tools Plugin</name>
    <description>Provides execute nodes to Directed Graphs that use the VNF Module.</description>

    <modules>
        <module>provider</module>
        <module>features</module>
        <module>installer</module>
    </modules>

    <properties>
        <feature-name>vnftools</feature-name>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.onap.sdnc.northbound</groupId>
                <artifactId>vnftools-features</artifactId>
                <version>${project.version}</version>
                <type>xml</type>
                <classifier>features</classifier>
            </dependency>
            <dependency>
                <groupId>org.onap.sdnc.northbound</groupId>
                <artifactId>vnftools-provider</artifactId>
                <version>${project.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>