Skip to content

Commit 2fbbef4

Browse files
committed
Fix using default wolfSSL ./configure.
1 parent 2ca4190 commit 2fbbef4

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

examples/wrap/wrap_test.c

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -451,24 +451,27 @@ int TPM2_Wrapper_TestArgs(void* userCtx, int argc, char *argv[])
451451
XMEMSET(&testKey, 0, sizeof(testKey));
452452
rc = wolfTPM2_CreateRsaKeyBlob(&dev, &storageKey, &wolfRsaPrivKey,
453453
&testKey);
454-
wc_FreeRsaKey(&wolfRsaPrivKey);
455-
if (rc != 0 && rc != NOT_COMPILED_IN) {
454+
wc_FreeRsaKey(&wolfRsaPrivKey); /* free wolf key */
455+
456+
if (rc == 0) {
457+
printf("RSA Private Key Blob created (private = %d bytes)\n",
458+
testKey.priv.size);
459+
460+
rc = wolfTPM2_LoadKey(&dev, &testKey, &storageKey.handle);
461+
if (rc != 0) goto exit;
462+
printf("RSA Private Key Loaded into TPM: Handle 0x%x\n",
463+
(word32)rsaKey.handle.hndl);
464+
465+
/* Use TPM Handle... */
466+
467+
rc = wolfTPM2_UnloadHandle(&dev, &testKey.handle);
468+
if (rc != 0) goto exit;
469+
}
470+
else if (rc != NOT_COMPILED_IN) {
456471
/* NOT_COMPILED_IN here likely means that AES-CFB is not enabled for
457472
* encrypting secrets */
458473
goto exit;
459474
}
460-
printf("RSA Private Key Blob created (private = %d bytes)\n",
461-
testKey.priv.size);
462-
463-
rc = wolfTPM2_LoadKey(&dev, &testKey, &storageKey.handle);
464-
if (rc != 0) goto exit;
465-
printf("RSA Private Key Loaded into TPM: Handle 0x%x\n",
466-
(word32)rsaKey.handle.hndl);
467-
468-
/* Use TPM Handle... */
469-
470-
rc = wolfTPM2_UnloadHandle(&dev, &testKey.handle);
471-
if (rc != 0) goto exit;
472475
#endif /* !WOLFTPM2_NO_WOLFCRYPT && !NO_RSA && !NO_ASN */
473476

474477
/* Load raw RSA private key into TPM */
@@ -691,24 +694,26 @@ int TPM2_Wrapper_TestArgs(void* userCtx, int argc, char *argv[])
691694
XMEMSET(&testKey, 0, sizeof(testKey));
692695
rc = wolfTPM2_CreateEccKeyBlob(&dev, &storageKey, &wolfEccPrivKey,
693696
&testKey);
694-
wc_ecc_free(&wolfEccPrivKey);
695-
if (rc != 0 && rc != NOT_COMPILED_IN) {
697+
wc_ecc_free(&wolfEccPrivKey); /* free wolf key */
698+
if (rc == 0) {
699+
printf("ECC Private Key Blob created (private = %d bytes)\n",
700+
testKey.priv.size);
701+
rc = wolfTPM2_LoadKey(&dev, &testKey, &storageKey.handle);
702+
if (rc != 0) goto exit;
703+
printf("ECC Private Key Loaded into TPM: Handle 0x%x\n",
704+
(word32)testKey.handle.hndl);
705+
706+
/* Use TPM Handle... */
707+
708+
rc = wolfTPM2_UnloadHandle(&dev, &testKey.handle);
709+
if (rc != 0) goto exit;
710+
}
711+
else if (rc != NOT_COMPILED_IN) {
696712
/* NOT_COMPILED_IN here likely means the WOLFSSL_PUBLIC_MP is enabled
697713
* exposing the mp_ math API's or AES CFB is not enabled.
698714
* Both are needed for encrypting secrets */
699715
goto exit;
700716
}
701-
printf("ECC Private Key Blob created (private = %d bytes)\n",
702-
testKey.priv.size);
703-
rc = wolfTPM2_LoadKey(&dev, &testKey, &storageKey.handle);
704-
if (rc != 0) goto exit;
705-
printf("ECC Private Key Loaded into TPM: Handle 0x%x\n",
706-
(word32)testKey.handle.hndl);
707-
708-
/* Use TPM Handle... */
709-
710-
rc = wolfTPM2_UnloadHandle(&dev, &testKey.handle);
711-
if (rc != 0) goto exit;
712717
#endif /* !WOLFTPM2_NO_WOLFCRYPT && HAVE_ECC && !NO_ASN */
713718

714719
/* Load raw ECC private key into TPM */

0 commit comments

Comments
 (0)