Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
319d689
F-9172 - Use XSTRNCMP to parse the -digest option in pcr policy
aidangarske Sep 10, 2026
9132602
F-9173 - Return an error status from pcr policy argument validation
aidangarske Sep 10, 2026
7792efb
F-9174 - Unload the TPM hash sequence object on failure paths
aidangarske Sep 10, 2026
995b087
F-9175 - Return the flush result for an explicit handle
aidangarske Sep 10, 2026
c425242
F-9180 - Mask to the format-one field when checking hash bench errors
aidangarske Sep 10, 2026
b58bee5
F-9182 - Free PKCS7 state on error paths in the sign verify examples
aidangarske Sep 10, 2026
e3cbe8e
F-11903 - Reject a negative get random length argument
aidangarske Sep 10, 2026
9496363
F-11901 - Fail make credential when the AK name cannot be read
aidangarske Sep 10, 2026
7d4d397
F-13461 - Return success from the capabilities example handle listing
aidangarske Sep 10, 2026
27d1bf5
F-10763 - Return an error on a GPIO config vendor mismatch
aidangarske Sep 10, 2026
3adb0f5
F-13457 - Return an error for incomplete firmware update arguments
aidangarske Sep 10, 2026
0d3f2f7
F-13463 - Clear ECC r and s on all policy signing paths
aidangarske Sep 10, 2026
03446a7
F-12753 - Wipe the hex render buffer in the Espressif debug helper
aidangarske Sep 10, 2026
4b76ba6
F-13532 - Bound the advanced IO SPI size to the frame buffer
aidangarske Sep 10, 2026
cedcd8e
F-11908 - Reject truncated Nations GET_STATUS payloads
aidangarske Sep 10, 2026
1be467d
F-11909 - Reject an empty Nuvoton GET_STATUS response
aidangarske Sep 10, 2026
38850ce
F-11891 - Correct the SPDM disconnect key wipe comment
aidangarske Sep 10, 2026
e86c757
F-9179 - Reject a NULL vendor payload with a nonzero size
aidangarske Sep 10, 2026
43f3484
F-10762 - Reject an oversized vendor payload that wraps the length field
aidangarske Sep 10, 2026
c8ce45e
F-10760 - Size the key exchange buffer check to the encoded request
aidangarske Sep 10, 2026
19b33fb
F-9176 - Provision the responder PSK only after the inner set succeeds
aidangarske Sep 10, 2026
550277e
F-9177 - Reset the responder only after the end session ack is encrypted
aidangarske Sep 10, 2026
3ac5feb
F-13467 - Validate declared PSK exchange field lengths against the re…
aidangarske Sep 10, 2026
60fd8ae
F-9185 - Fail MCTP encryption once the sequence number exceeds 16 bits
aidangarske Sep 10, 2026
ef6e19e
F-11934 - Advance the SPDM receive sequence only after authentication
aidangarske Sep 10, 2026
55135d1
F-13452 - Free the wrap HMAC only after it is initialized
aidangarske Sep 10, 2026
ae35819
F-13453 - Preserve an allocation failure before generating the contex…
aidangarske Sep 10, 2026
b12c95e
F-11929 - Zeroize the append-only NV replay buffer before freeing
aidangarske Sep 10, 2026
f53b7ec
F-10824 - Zeroize the NV journal load buffer before freeing
aidangarske Sep 10, 2026
b8615b3
F-11930 - Zeroize the NV save marshal buffer before grow frees
aidangarske Sep 10, 2026
36a549d
F-11931 - Zeroize the PCR authorization buffer before freeing
aidangarske Sep 10, 2026
efa68e4
F-11932 - Zeroize the hierarchy authorization stack buffer
aidangarske Sep 10, 2026
7f02fac
F-12707 - Clean up wolfCrypt only when its init succeeded
aidangarske Sep 10, 2026
facc55c
F-9193 - Assert the TIS FIFO can hold the maximum command response
aidangarske Sep 10, 2026
651a35f
F-12755 - Zeroize the session start nonce structures on all exits
aidangarske Sep 10, 2026
ed95d45
F-11916 - Use a constant-time compare for the primary key cache lookup
aidangarske Sep 10, 2026
022fe84
F-13531 - Guard the object name marshalling on a successful allocation
aidangarske Sep 10, 2026
d679f5b
F-13530 - Guard the encrypted salt zeroization against a NULL buffer
aidangarske Sep 10, 2026
e15f515
F-13529 - Guard the EncryptDecrypt input buffer against a NULL alloca…
aidangarske Sep 10, 2026
7ce7a67
F-12713 - Reject malformed PCR_Read selection counts and sizes
aidangarske Sep 10, 2026
6ecdd4b
F-13498 - Run policy assertion compares without short-circuiting on size
aidangarske Sep 10, 2026
c06f2c2
F-13499 - Run the PolicyTemplate compare without short-circuiting on …
aidangarske Sep 10, 2026
c33c503
F-11933 - Skip the authorization area in no-auth-handle session commands
aidangarske Sep 10, 2026
58d0fa6
F-9194 - Zeroize the command auth cache on every process command exit
aidangarske Sep 10, 2026
1d8ea0c
Advance SPDM receive sequence after auth and harden size checks
aidangarske Sep 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions examples/attestation/make_credential.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,18 @@ int TPM2_MakeCredential_Example(void* userCtx, int argc, char *argv[])
fp = XFOPEN("ak.name", "rb");
if (fp != XBADFILE) {
size_t nameReadSz = XFREAD((BYTE*)&name, 1, sizeof(name), fp);
printf("Read AK Name digest %s\n",
nameReadSz == sizeof(name) ? "success" : "failed");
XFCLOSE(fp);
if (nameReadSz != sizeof(name)) {
printf("Read AK Name digest failed\n");
rc = BUFFER_E;
goto exit;
}
printf("Read AK Name digest success\n");
}
else {
printf("Failed to open ak.name\n");
rc = BAD_FUNC_ARG;
goto exit;
}
#endif

Expand Down
8 changes: 4 additions & 4 deletions examples/bench/bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,19 +516,19 @@ int TPM2_Wrapper_BenchArgs(void* userCtx, int argc, char *argv[])
/* SHA1 */
rc = bench_sym_hash(&dev, "SHA1", TPM_ALG_SHA1, message.buffer,
sizeof(message.buffer), cipher.buffer, TPM_SHA_DIGEST_SIZE, maxDuration);
if (rc != 0 && (rc & TPM_RC_HASH) != TPM_RC_HASH) goto exit;
if (rc != 0 && (rc & RC_MAX_FMT1) != TPM_RC_HASH) goto exit;
/* SHA256 */
rc = bench_sym_hash(&dev, "SHA256", TPM_ALG_SHA256, message.buffer,
sizeof(message.buffer), cipher.buffer, TPM_SHA256_DIGEST_SIZE, maxDuration);
if (rc != 0 && (rc & TPM_RC_HASH) != TPM_RC_HASH) goto exit;
if (rc != 0 && (rc & RC_MAX_FMT1) != TPM_RC_HASH) goto exit;
/* SHA384 */
rc = bench_sym_hash(&dev, "SHA384", TPM_ALG_SHA384, message.buffer,
sizeof(message.buffer), cipher.buffer, TPM_SHA384_DIGEST_SIZE, maxDuration);
if (rc != 0 && (rc & TPM_RC_HASH) != TPM_RC_HASH) goto exit;
if (rc != 0 && (rc & RC_MAX_FMT1) != TPM_RC_HASH) goto exit;
/* SHA512 */
rc = bench_sym_hash(&dev, "SHA512", TPM_ALG_SHA512, message.buffer,
sizeof(message.buffer), cipher.buffer, TPM_SHA512_DIGEST_SIZE, maxDuration);
if (rc != 0 && (rc & TPM_RC_HASH) != TPM_RC_HASH) goto exit;
if (rc != 0 && (rc & RC_MAX_FMT1) != TPM_RC_HASH) goto exit;


/* Create RSA key for encrypt/decrypt */
Expand Down
1 change: 1 addition & 0 deletions examples/firmware/ifx_fw_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ int TPM2_IFX_Firmware_Update(void* userCtx, int argc, char *argv[])
if (manifest_file == NULL || firmware_file == NULL) {
if (argc > 1) {
printf("Manifest file or firmware file arguments missing!\n");
rc = BAD_FUNC_ARG;
}
goto exit;
}
Expand Down
2 changes: 2 additions & 0 deletions examples/gpio/gpio_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ int TPM2_GPIO_Config_Example(void* userCtx, int argc, char *argv[])
#ifdef WOLFTPM_ST33
if (caps.mfg != TPM_MFG_STM) {
printf("TPM vendor mismatch. GPIO support requires an ST33 TPM 2.0 module\n");
rc = BAD_FUNC_ARG;
goto exit;
}

Expand Down Expand Up @@ -263,6 +264,7 @@ int TPM2_GPIO_Config_Example(void* userCtx, int argc, char *argv[])

if (caps.mfg != TPM_MFG_NUVOTON) {
printf("TPM vendor mismatch. GPIO support requires Nuvoton NPCT7xx TPM 2.0 module\n");
rc = BAD_FUNC_ARG;
goto exit;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/management/flush.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int TPM2_Flush_Tool(void* userCtx, int argc, char *argv[])
else {
flushCtx.flushHandle = handle;
printf("Freeing %X object\n", handle);
TPM2_FlushContext(&flushCtx);
rc = TPM2_FlushContext(&flushCtx);
}

wolfTPM2_Cleanup(&dev);
Expand Down
8 changes: 4 additions & 4 deletions examples/pcr/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int TPM2_PCR_Policy_Test(void* userCtx, int argc, char *argv[])
else if (XSTRCMP(argv[argc-1], "-xor") == 0) {
paramEncAlg = TPM_ALG_XOR;
}
else if (XMEMCMP(argv[argc-1], "-digest=", XSTRLEN("-digest=")) == 0) {
else if (XSTRNCMP(argv[argc-1], "-digest=", XSTRLEN("-digest=")) == 0) {
const char *digestStr, *end;
digestStr = argv[argc-1] + XSTRLEN("-digest=");
end = XSTRSTR(digestStr, " ");
Expand All @@ -108,13 +108,13 @@ int TPM2_PCR_Policy_Test(void* userCtx, int argc, char *argv[])
digestLen > sizeof(digest)*2) {
printf("Invalid digest! Must be 16 or 32 bytes of hex like 01020304050607080910111213141516\n");
usage();
return 0;
return BAD_FUNC_ARG;
}
hexRet = hexToByte(digestStr, digest, digestLen);
if (hexRet < 0) {
printf("Invalid hex digest string\n");
usage();
return 0;
return BAD_FUNC_ARG;
}
digestLen = (word32)hexRet;
}
Expand All @@ -124,7 +124,7 @@ int TPM2_PCR_Policy_Test(void* userCtx, int argc, char *argv[])
if (pcrIndex < (int)PCR_FIRST || pcrIndex > (int)PCR_LAST) {
printf("PCR index is out of range (0-23)\n");
usage();
return 0;
return BAD_FUNC_ARG;
}
}
else {
Expand Down
22 changes: 11 additions & 11 deletions examples/pcr/policy_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,17 @@ static int PolicySign(TPM_ALG_ID alg, const char* keyFile, const char* password,
rc = mp_init_multi(&r, &s, NULL, NULL, NULL, NULL);
if (rc == 0) {
rc = wc_ecc_sign_hash_ex(hash, hashSz, &rng, &key.ecc, &r, &s);
}
if (rc == 0) {
word32 keySz = key.ecc.dp->size;
*sigSz = keySz * 2;
/* Pre-zero in case mp export fails and leaves the buffer
* partially written. Fixed-width export of r and s
* removes the data-dependent wire offset that previously
* leaked the leading-zero count. */
XMEMSET(sig, 0, *sigSz);
mp_to_unsigned_bin_len(&r, &sig[0], keySz);
mp_to_unsigned_bin_len(&s, &sig[keySz], keySz);
if (rc == 0) {
word32 keySz = key.ecc.dp->size;
*sigSz = keySz * 2;
/* Pre-zero in case mp export fails and leaves the buffer
* partially written. Fixed-width export of r and s
* removes the data-dependent wire offset that previously
* leaked the leading-zero count. */
XMEMSET(sig, 0, *sigSz);
mp_to_unsigned_bin_len(&r, &sig[0], keySz);
mp_to_unsigned_bin_len(&s, &sig[keySz], keySz);
}
mp_clear(&r);
mp_clear(&s);
}
Expand Down
20 changes: 20 additions & 0 deletions examples/pkcs7/pkcs7.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ static int PKCS7_SignVerifyEx(WOLFTPM2_DEV* dev, int tpmDevId,
{
int rc;
wc_PKCS7 pkcs7;
int pkcs7Init = 0;
wc_HashAlg hash;
byte hashBuf[TPM_MAX_DIGEST_SIZE];
word32 hashSz;
Expand Down Expand Up @@ -155,6 +156,7 @@ static int PKCS7_SignVerifyEx(WOLFTPM2_DEV* dev, int tpmDevId,
/* Generate and verify PKCS#7 files containing data using TPM key */
rc = wc_PKCS7_Init(&pkcs7, NULL, tpmDevId);
if (rc != 0) goto exit;
pkcs7Init = 1;
rc = wc_PKCS7_InitWithCert(&pkcs7, derCert, derCertSz);
if (rc != 0) goto exit;

Expand All @@ -177,6 +179,7 @@ static int PKCS7_SignVerifyEx(WOLFTPM2_DEV* dev, int tpmDevId,
if (rc != 0) goto exit;

wc_PKCS7_Free(&pkcs7);
pkcs7Init = 0;

printf("PKCS7 Header %d\n", outputHeadSz);
TPM2_PrintBin(outputHead, outputHeadSz);
Expand Down Expand Up @@ -232,6 +235,7 @@ static int PKCS7_SignVerifyEx(WOLFTPM2_DEV* dev, int tpmDevId,
/* Test verify with TPM */
rc = wc_PKCS7_Init(&pkcs7, NULL, tpmDevId);
if (rc != 0) goto exit;
pkcs7Init = 1;
rc = wc_PKCS7_InitWithCert(&pkcs7, NULL, 0);
if (rc != 0) goto exit;

Expand All @@ -241,23 +245,29 @@ static int PKCS7_SignVerifyEx(WOLFTPM2_DEV* dev, int tpmDevId,
if (rc != 0) goto exit;

wc_PKCS7_Free(&pkcs7);
pkcs7Init = 0;

printf("PKCS7 Container Verified (using TPM)\n");

/* Test verify with software */
rc = wc_PKCS7_Init(&pkcs7, NULL, INVALID_DEVID);
if (rc != 0) goto exit;
pkcs7Init = 1;
rc = wc_PKCS7_InitWithCert(&pkcs7, NULL, 0);
if (rc != 0) goto exit;
pkcs7.contentSz = dataChunkSz;
rc = wc_PKCS7_VerifySignedData_ex(&pkcs7, hashBuf, hashSz,
outputHead, outputHeadSz, outputFoot, outputFootSz);
if (rc != 0) goto exit;
wc_PKCS7_Free(&pkcs7);
pkcs7Init = 0;

printf("PKCS7 Container Verified (using software)\n");

exit:
if (pkcs7Init) {
wc_PKCS7_Free(&pkcs7);
}
return rc;
}
#endif /* ENABLE_PKCS7EX_EXAMPLE */
Expand All @@ -268,6 +278,7 @@ static int PKCS7_SignVerify(WOLFTPM2_DEV* dev, int tpmDevId,
{
int rc;
wc_PKCS7 pkcs7;
int pkcs7Init = 0;
byte data[] = "My encoded DER cert.";
byte output[MAX_PKCS7_SIZE];
int outputSz;
Expand All @@ -280,6 +291,7 @@ static int PKCS7_SignVerify(WOLFTPM2_DEV* dev, int tpmDevId,
/* Generate and verify PKCS#7 files containing data using TPM key */
rc = wc_PKCS7_Init(&pkcs7, NULL, tpmDevId);
if (rc != 0) goto exit;
pkcs7Init = 1;
rc = wc_PKCS7_InitWithCert(&pkcs7, derCert, derCertSz);
if (rc != 0) goto exit;

Expand All @@ -296,6 +308,7 @@ static int PKCS7_SignVerify(WOLFTPM2_DEV* dev, int tpmDevId,
rc = wc_PKCS7_EncodeSignedData(&pkcs7, output, sizeof(output));
if (rc <= 0) goto exit;
wc_PKCS7_Free(&pkcs7);
pkcs7Init = 0;
outputSz = rc;

printf("PKCS7 Signed Container %d\n", outputSz);
Expand All @@ -321,26 +334,33 @@ static int PKCS7_SignVerify(WOLFTPM2_DEV* dev, int tpmDevId,
/* Test verify with TPM */
rc = wc_PKCS7_Init(&pkcs7, NULL, tpmDevId);
if (rc != 0) goto exit;
pkcs7Init = 1;
rc = wc_PKCS7_InitWithCert(&pkcs7, NULL, 0);
if (rc != 0) goto exit;
rc = wc_PKCS7_VerifySignedData(&pkcs7, output, outputSz);
if (rc != 0) goto exit;
wc_PKCS7_Free(&pkcs7);
pkcs7Init = 0;

printf("PKCS7 Container Verified (using TPM)\n");

/* Test verify with software */
rc = wc_PKCS7_Init(&pkcs7, NULL, INVALID_DEVID);
if (rc != 0) goto exit;
pkcs7Init = 1;
rc = wc_PKCS7_InitWithCert(&pkcs7, NULL, 0);
if (rc != 0) goto exit;
rc = wc_PKCS7_VerifySignedData(&pkcs7, output, outputSz);
if (rc != 0) goto exit;
wc_PKCS7_Free(&pkcs7);
pkcs7Init = 0;

printf("PKCS7 Container Verified (using software)\n");

exit:
if (pkcs7Init) {
wc_PKCS7_Free(&pkcs7);
}
return rc;
}

Expand Down
1 change: 1 addition & 0 deletions examples/wrap/caps.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ int TPM2_Wrapper_CapsArgs(void* userCtx, int argc, char *argv[])
rc = wolfTPM2_GetHandles(PERSISTENT_FIRST, NULL);
if (rc >= 0) {
printf("Found %d persistent handles\n", rc);
rc = TPM_RC_SUCCESS;
}

/* Print the available PCR's */
Expand Down
8 changes: 7 additions & 1 deletion examples/wrap/getrandom.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ int TPM2_GetRandom_Example(void* userCtx, int argc, char* argv[])
byte buf[GETRANDOM_MAX_BYTES];
word32 len = GETRANDOM_DEFAULT_BYTES;
word32 i;
int lenArg;

if (argc > 1) {
if (XSTRCMP(argv[1], "-?") == 0 ||
Expand All @@ -66,7 +67,12 @@ int TPM2_GetRandom_Example(void* userCtx, int argc, char* argv[])
usage();
return 0;
}
len = (word32)XATOI(argv[1]);
lenArg = XATOI(argv[1]);
if (lenArg < 0) {
printf("Invalid length %d\n", lenArg);
return BAD_FUNC_ARG;
}
len = (word32)lenArg;
if (len == 0) {
len = GETRANDOM_DEFAULT_BYTES;
}
Expand Down
1 change: 1 addition & 0 deletions examples/wrap/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ int TPM2_Hash_Example(void* userCtx, int argc, char* argv[])

exit:

wolfTPM2_UnloadHandle(&dev, &hash.handle);
wolfTPM2_Cleanup(&dev);

return rc;
Expand Down
44 changes: 25 additions & 19 deletions hal/tpm_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,27 +183,33 @@ int TPM2_IoCb(TPM2_CTX* ctx, INT32 isRead, UINT32 addr,
(void)userCtx;
#endif
#else
/* Build TPM header */
txBuf[1] = (addr>>16) & 0xFF;
txBuf[2] = (addr>>8) & 0xFF;
txBuf[3] = (addr) & 0xFF;
if (isRead) {
txBuf[0] = TPM_TIS_READ | ((size & 0xFF) - 1);
XMEMSET(&txBuf[TPM_TIS_HEADER_SZ], 0,
sizeof(txBuf) - TPM_TIS_HEADER_SZ);
if (buf == NULL || size == 0 ||
size > (UINT16)(sizeof(txBuf) - TPM_TIS_HEADER_SZ)) {
ret = BAD_FUNC_ARG;
}
else {
txBuf[0] = TPM_TIS_WRITE | ((size & 0xFF) - 1);
XMEMCPY(&txBuf[TPM_TIS_HEADER_SZ], buf, size);
XMEMSET(&txBuf[TPM_TIS_HEADER_SZ + size], 0,
sizeof(txBuf) - TPM_TIS_HEADER_SZ - size);
}
XMEMSET(rxBuf, 0, sizeof(rxBuf));

ret = TPM2_IoCb_SPI(ctx, txBuf, rxBuf, size + TPM_TIS_HEADER_SZ, userCtx);

if (isRead) {
XMEMCPY(buf, &rxBuf[TPM_TIS_HEADER_SZ], size);
/* Build TPM header */
txBuf[1] = (addr>>16) & 0xFF;
txBuf[2] = (addr>>8) & 0xFF;
txBuf[3] = (addr) & 0xFF;
if (isRead) {
txBuf[0] = TPM_TIS_READ | ((size & 0xFF) - 1);
XMEMSET(&txBuf[TPM_TIS_HEADER_SZ], 0,
sizeof(txBuf) - TPM_TIS_HEADER_SZ);
}
else {
txBuf[0] = TPM_TIS_WRITE | ((size & 0xFF) - 1);
XMEMCPY(&txBuf[TPM_TIS_HEADER_SZ], buf, size);
XMEMSET(&txBuf[TPM_TIS_HEADER_SZ + size], 0,
sizeof(txBuf) - TPM_TIS_HEADER_SZ - size);
}
XMEMSET(rxBuf, 0, sizeof(rxBuf));

ret = TPM2_IoCb_SPI(ctx, txBuf, rxBuf, size + TPM_TIS_HEADER_SZ, userCtx);

if (isRead) {
XMEMCPY(buf, &rxBuf[TPM_TIS_HEADER_SZ], size);
}
}
#endif

Expand Down
1 change: 1 addition & 0 deletions hal/tpm_io_espressif.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ static esp_err_t show_binary(byte* theVar, size_t dataSz) {
hex_buffer[maxSz * 2] = '\0';
ESP_LOGI("TAG", "%s", hex_buffer);
ESP_LOGI(TAG, "*********************************************************");
TPM2_ForceZero(hex_buffer, sizeof(hex_buffer));
return ESP_OK;
}
#endif
Expand Down
6 changes: 5 additions & 1 deletion src/fwtpm/fwtpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ int FWTPM_Init(FWTPM_CTX* ctx)
{
int rc;
int rngInit = 0;
int wcInit = 0;
FWTPM_NV_HAL savedNvHal;
struct FWTPM_CLOCK_HAL_S savedClockHal;
#ifndef FWTPM_NO_PP
Expand Down Expand Up @@ -96,6 +97,7 @@ int FWTPM_Init(FWTPM_CTX* ctx)
/* Initialize wolfCrypt RNG */
rc = wolfCrypt_Init();
if (rc == 0) {
wcInit = 1;
rc = wc_InitRng(&ctx->rng);
if (rc == 0) {
rngInit = 1;
Expand Down Expand Up @@ -141,7 +143,9 @@ int FWTPM_Init(FWTPM_CTX* ctx)
if (rngInit) {
wc_FreeRng(&ctx->rng);
}
wolfCrypt_Cleanup();
if (wcInit) {
wolfCrypt_Cleanup();
}
}

return rc;
Expand Down
Loading
Loading