Skip to content

Commit

Permalink
Merge pull request wolfSSL#310 from dgarske/csr_cryptocb_devid
Browse files Browse the repository at this point in the history
Use a different (not default) devId for the CSR crypto callback.
  • Loading branch information
embhorn authored Nov 28, 2023
2 parents ce56065 + b366a8d commit 4d65e9f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/tpm2_wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -6213,11 +6213,22 @@ static int CSR_KeySetup(WOLFTPM2_DEV* dev, WOLFTPM2_CSR* csr, WOLFTPM2_KEY* key,
#ifdef HAVE_ECC
csrKey->tpmCtx.eccKey = key;
#endif
rc = wolfTPM2_SetCryptoDevCb(dev, wolfTPM2_CryptoDevCb,
&csrKey->tpmCtx, &csrKey->tpmDevId);

rc = wolfTPM2_GetTpmDevId(dev);
if (rc >= 0) {
devId = rc;
devId += 1; /* use a different devId for the CSR callback */
rc = 0;
}
if (rc == 0) {
devId = csrKey->tpmDevId;
csrKey->tpmCtx.dev = dev;
rc = wc_CryptoCb_RegisterDevice(devId, wolfTPM2_CryptoDevCb,
&csrKey->tpmCtx);
}
if (rc != 0) {
return rc;
}
csrKey->tpmDevId = devId;
}

/* determine the type of key in WOLFTPM2_KEY */
Expand Down

0 comments on commit 4d65e9f

Please sign in to comment.