mirror of https://github.com/wolfSSL/wolfTPM.git
Prepare for new nonceTPM solution and TPM session tracking
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>pull/129/head
parent
72e365329c
commit
8459ec712a
|
@ -609,7 +609,6 @@ int wolfTPM2_StartSession(WOLFTPM2_DEV* dev, WOLFTPM2_SESSION* session,
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
session->handle.dev = dev;
|
|
||||||
session->handle.hndl = authSesOut.sessionHandle;
|
session->handle.hndl = authSesOut.sessionHandle;
|
||||||
session->nonceTPM = authSesOut.nonceTPM;
|
session->nonceTPM = authSesOut.nonceTPM;
|
||||||
|
|
||||||
|
@ -661,7 +660,6 @@ int wolfTPM2_CreatePrimaryKey(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* key,
|
||||||
#endif
|
#endif
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
key->handle.dev = dev;
|
|
||||||
key->handle.hndl = createPriOut.objectHandle;
|
key->handle.hndl = createPriOut.objectHandle;
|
||||||
key->handle.auth = createPriIn.inSensitive.sensitive.userAuth;
|
key->handle.auth = createPriIn.inSensitive.sensitive.userAuth;
|
||||||
|
|
||||||
|
@ -730,7 +728,6 @@ int wolfTPM2_ChangeAuthKey(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* key,
|
||||||
XMEMSET(&dev->session[0].auth, 0, sizeof(dev->session[0].auth));
|
XMEMSET(&dev->session[0].auth, 0, sizeof(dev->session[0].auth));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
key->handle.dev = dev;
|
|
||||||
key->handle.hndl = loadOut.objectHandle;
|
key->handle.hndl = loadOut.objectHandle;
|
||||||
key->handle.auth = changeIn.newAuth;
|
key->handle.auth = changeIn.newAuth;
|
||||||
|
|
||||||
|
@ -791,8 +788,7 @@ int wolfTPM2_CreateKey(WOLFTPM2_DEV* dev, WOLFTPM2_KEYBLOB* keyBlob,
|
||||||
printf("save\n");
|
printf("save\n");
|
||||||
TPM2_PrintBin(createOut.outPrivate.buffer, createOut.outPrivate.size);
|
TPM2_PrintBin(createOut.outPrivate.buffer, createOut.outPrivate.size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
keyBlob->handle.dev = dev;
|
|
||||||
keyBlob->handle.auth = createIn.inSensitive.sensitive.userAuth;
|
keyBlob->handle.auth = createIn.inSensitive.sensitive.userAuth;
|
||||||
keyBlob->pub = createOut.outPublic;
|
keyBlob->pub = createOut.outPublic;
|
||||||
keyBlob->priv = createOut.outPrivate;
|
keyBlob->priv = createOut.outPrivate;
|
||||||
|
@ -829,7 +825,6 @@ int wolfTPM2_LoadKey(WOLFTPM2_DEV* dev, WOLFTPM2_KEYBLOB* keyBlob,
|
||||||
XMEMSET(&dev->session[0].auth, 0, sizeof(dev->session[0].auth));
|
XMEMSET(&dev->session[0].auth, 0, sizeof(dev->session[0].auth));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
keyBlob->handle.dev = dev;
|
|
||||||
keyBlob->handle.hndl = loadOut.objectHandle;
|
keyBlob->handle.hndl = loadOut.objectHandle;
|
||||||
|
|
||||||
#ifdef DEBUG_WOLFTPM
|
#ifdef DEBUG_WOLFTPM
|
||||||
|
@ -885,7 +880,6 @@ int wolfTPM2_LoadPublicKey(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* key,
|
||||||
#endif
|
#endif
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
key->handle.dev = dev;
|
|
||||||
key->handle.hndl = loadExtOut.objectHandle;
|
key->handle.hndl = loadExtOut.objectHandle;
|
||||||
key->pub = loadExtIn.inPublic;
|
key->pub = loadExtIn.inPublic;
|
||||||
|
|
||||||
|
@ -1128,7 +1122,6 @@ int wolfTPM2_ImportPrivateKey(WOLFTPM2_DEV* dev, const WOLFTPM2_KEY* parentKey,
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyBlob->handle.dev = dev;
|
|
||||||
keyBlob->pub = importIn.objectPublic;
|
keyBlob->pub = importIn.objectPublic;
|
||||||
keyBlob->priv = importOut.outPrivate;
|
keyBlob->priv = importOut.outPrivate;
|
||||||
|
|
||||||
|
@ -1423,7 +1416,6 @@ int wolfTPM2_ReadPublicKey(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* key,
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
key->handle.dev = dev;
|
|
||||||
key->handle.hndl = readPubIn.objectHandle;
|
key->handle.hndl = readPubIn.objectHandle;
|
||||||
key->pub = readPubOut.outPublic;
|
key->pub = readPubOut.outPublic;
|
||||||
|
|
||||||
|
@ -3043,7 +3035,6 @@ int wolfTPM2_LoadSymmetricKey(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* key, int alg,
|
||||||
/* Load private key */
|
/* Load private key */
|
||||||
rc = TPM2_LoadExternal(&loadExtIn, &loadExtOut);
|
rc = TPM2_LoadExternal(&loadExtIn, &loadExtOut);
|
||||||
if (rc == TPM_RC_SUCCESS) {
|
if (rc == TPM_RC_SUCCESS) {
|
||||||
key->handle.dev = dev;
|
|
||||||
key->handle.hndl = loadExtOut.objectHandle;
|
key->handle.hndl = loadExtOut.objectHandle;
|
||||||
key->pub = loadExtIn.inPublic;
|
key->pub = loadExtIn.inPublic;
|
||||||
|
|
||||||
|
@ -3272,7 +3263,6 @@ int wolfTPM2_LoadKeyedHashKey(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* key,
|
||||||
XMEMSET(&dev->session[0].auth, 0, sizeof(dev->session[0].auth));
|
XMEMSET(&dev->session[0].auth, 0, sizeof(dev->session[0].auth));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
key->handle.dev = dev;
|
|
||||||
key->handle.hndl = loadOut.objectHandle;
|
key->handle.hndl = loadOut.objectHandle;
|
||||||
key->handle.auth = createIn.inSensitive.sensitive.userAuth;
|
key->handle.auth = createIn.inSensitive.sensitive.userAuth;
|
||||||
|
|
||||||
|
@ -3427,7 +3417,6 @@ int wolfTPM2_UnloadHandles(WOLFTPM2_DEV* dev, word32 handleStart, word32 handleC
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
}
|
}
|
||||||
XMEMSET(&handle, 0, sizeof(handle));
|
XMEMSET(&handle, 0, sizeof(handle));
|
||||||
handle.dev = dev;
|
|
||||||
handle.auth = dev->session[0].auth;
|
handle.auth = dev->session[0].auth;
|
||||||
for (hndl=handleStart; hndl < handleStart+handleCount; hndl++) {
|
for (hndl=handleStart; hndl < handleStart+handleCount; hndl++) {
|
||||||
handle.hndl = hndl;
|
handle.hndl = hndl;
|
||||||
|
|
|
@ -28,25 +28,26 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct WOLFTPM2_DEV {
|
|
||||||
TPM2_CTX ctx;
|
|
||||||
TPMS_AUTH_COMMAND session[MAX_SESSION_NUM];
|
|
||||||
} WOLFTPM2_DEV;
|
|
||||||
|
|
||||||
typedef struct WOLFTPM2_HANDLE {
|
typedef struct WOLFTPM2_HANDLE {
|
||||||
WOLFTPM2_DEV* dev;
|
|
||||||
TPM_HANDLE hndl;
|
TPM_HANDLE hndl;
|
||||||
TPM2B_AUTH auth;
|
TPM2B_AUTH auth;
|
||||||
TPMT_SYM_DEF symmetric;
|
TPMT_SYM_DEF symmetric;
|
||||||
} WOLFTPM2_HANDLE;
|
} WOLFTPM2_HANDLE;
|
||||||
|
|
||||||
typedef struct WOLFTPM2_SESSION {
|
typedef struct WOLFTPM2_SESSION {
|
||||||
|
TPM_ST_T type;
|
||||||
WOLFTPM2_HANDLE handle;
|
WOLFTPM2_HANDLE handle;
|
||||||
TPM2B_NONCE nonceTPM;
|
TPM2B_NONCE nonceTPM;
|
||||||
TPM2B_DIGEST salt;
|
TPM2B_DIGEST salt;
|
||||||
const char* bindPassword;
|
const char* bindPassword;
|
||||||
} WOLFTPM2_SESSION;
|
} WOLFTPM2_SESSION;
|
||||||
|
|
||||||
|
typedef struct WOLFTPM2_DEV {
|
||||||
|
TPM2_CTX ctx;
|
||||||
|
TPMS_AUTH_COMMAND session[MAX_SESSION_NUM]; /* TODO: rename ot authCmd for consistency with native naming */
|
||||||
|
WOLFTPM2_SESSION sessions[MAX_SESSION_NUM];
|
||||||
|
} WOLFTPM2_DEV;
|
||||||
|
|
||||||
typedef struct WOLFTPM2_KEY {
|
typedef struct WOLFTPM2_KEY {
|
||||||
WOLFTPM2_HANDLE handle;
|
WOLFTPM2_HANDLE handle;
|
||||||
TPM2B_PUBLIC pub;
|
TPM2B_PUBLIC pub;
|
||||||
|
|
Loading…
Reference in New Issue