Skip to content

Commit 4be8abb

Browse files
committed
Fix build issues and handle leak.
1 parent 2774bb4 commit 4be8abb

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/internal.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8283,6 +8283,7 @@ int WP11_Object_MatchAttr(WP11_Object* object, CK_ATTRIBUTE_TYPE type,
82838283
return ret;
82848284
}
82858285

8286+
#ifdef WOLFPKCS11_TPM
82868287
#if !defined(NO_RSA) || defined(HAVE_ECC)
82878288

82888289
static int WP11_Object_LoadTpmKey(WP11_Object* object)
@@ -8333,8 +8334,8 @@ static int WP11_Object_LoadTpmKey(WP11_Object* object)
83338334
return ret;
83348335
}
83358336

8336-
#endif
8337-
8337+
#endif /* !NO_RSA || HAVE_ECC */
8338+
#endif /* WOLFPKCS11_TPM */
83388339

83398340
#ifndef NO_RSA
83408341

@@ -8446,6 +8447,12 @@ int WP11_Rsa_GenerateKeyPair(WP11_Object* pub, WP11_Object* priv,
84468447

84478448
/* Generate into the private key. */
84488449
ret = wc_MakeRsaKey(&priv->data.rsaKey, pub->size, e, &rng);
8450+
#ifdef WOLFPKCS11_TPM
8451+
if (ret == 0) {
8452+
/* unload handle and reload when used */
8453+
wolfTPM2_UnloadHandle(&priv->slot->tpmDev, &priv->tpmKey.handle);
8454+
}
8455+
#endif
84498456
if (ret != 0) {
84508457
wc_FreeRsaKey(&priv->data.rsaKey);
84518458
}
@@ -9182,6 +9189,12 @@ int WP11_Ec_GenerateKeyPair(WP11_Object* pub, WP11_Object* priv,
91829189
if (ret == 0) {
91839190
ret = wc_ecc_make_key_ex(&rng, priv->data.ecKey.dp->size,
91849191
&priv->data.ecKey, priv->data.ecKey.dp->id);
9192+
#ifdef WOLFPKCS11_TPM
9193+
if (ret == 0) {
9194+
/* unload handle and reload when used */
9195+
wolfTPM2_UnloadHandle(&slot->tpmDev, &priv->tpmKey.handle);
9196+
}
9197+
#endif
91859198
Rng_Free(&rng);
91869199
}
91879200
if (ret == 0) {

tests/unit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,11 @@ static CK_RV run_tests(TEST_FUNC* testFunc, int testFuncCnt, int onlySet,
321321
int i;
322322
void* testArgs;
323323

324+
#ifdef DEBUG_WOLFPKCS11
324325
if (verbose) {
325326
wolfPKCS11_Debugging_On();
326327
}
328+
#endif
327329

328330
for (i = 0; i < testFuncCnt; i++) {
329331
if (testFunc[i].flags != flags)

0 commit comments

Comments
 (0)