Skip to content

Commit 3f29c59

Browse files
committed
Add support for encrypting secret using ECC key. Allows using ECC for parameter encryption and importing ECC keys with custom seed. Requires wolfSSL/wolfssl#6683
1 parent 135b610 commit 3f29c59

4 files changed

Lines changed: 314 additions & 81 deletions

File tree

examples/keygen/external_import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ int TPM2_ExternalImport_Example(void* userCtx, int argc, char *argv[])
159159
XMEMCPY(seedValue.buffer, custSeed, seedValue.size);
160160
}
161161
#endif
162-
printf("Import RSA Seed %d\n", seedValue.size);
162+
printf("Import Seed %d\n", seedValue.size);
163163
TPM2_PrintBin(seedValue.buffer, seedValue.size);
164164

165165
rc = wolfTPM2_ImportPrivateKeyBuffer(&dev, &storage, TPM_ALG_RSA, key2,

examples/wrap/wrap_test.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ int TPM2_Wrapper_TestArgs(void* userCtx, int argc, char *argv[])
510510
storageKey.handle.auth.size);
511511
}
512512

513-
#if 0 /* disabled until ECC Encrypted salt is added */
514513
/* Start an authenticated session (salted / unbound) with parameter encryption */
515514
if (paramEncAlg != TPM_ALG_NULL) {
516515
rc = wolfTPM2_StartSession(&dev, &tpmSession, &storageKey, NULL,
@@ -520,11 +519,10 @@ int TPM2_Wrapper_TestArgs(void* userCtx, int argc, char *argv[])
520519
(word32)tpmSession.handle.hndl);
521520

522521
/* set session for authorization of the storage key */
523-
rc = wolfTPM2_SetAuthSession(&dev, 1, &tpmSession,
522+
rc = wolfTPM2_SetAuthSession(&dev, 0, &tpmSession,
524523
(TPMA_SESSION_decrypt | TPMA_SESSION_encrypt | TPMA_SESSION_continueSession));
525524
if (rc != 0) goto exit;
526525
}
527-
#endif
528526

529527
/* Create an ECC key for ECDSA */
530528
rc = wolfTPM2_GetKeyTemplate_ECC(&publicTemplate,
@@ -661,7 +659,11 @@ int TPM2_Wrapper_TestArgs(void* userCtx, int argc, char *argv[])
661659
if (rc != 0) goto exit;
662660
rc = wolfTPM2_EccKey_WolfToTpm_ex(&dev, &storageKey, &wolfEccPrivKey,
663661
&eccKey);
664-
if (rc != 0) goto exit;
662+
if (rc != 0 && rc != NOT_COMPILED_IN) {
663+
/* a NOT_COMPILED_IN here likely means the WOLFSSL_PUBLIC_MP is enabled
664+
* exposing the mp_ math API's needed for encrypting secrets */
665+
goto exit;
666+
}
665667
/* Use TPM Handle... */
666668
wc_ecc_free(&wolfEccPrivKey);
667669
rc = wolfTPM2_UnloadHandle(&dev, &eccKey.handle);
@@ -672,7 +674,11 @@ int TPM2_Wrapper_TestArgs(void* userCtx, int argc, char *argv[])
672674
kEccKeyPubXRaw, (word32)sizeof(kEccKeyPubXRaw),
673675
kEccKeyPubYRaw, (word32)sizeof(kEccKeyPubYRaw),
674676
kEccKeyPrivD, (word32)sizeof(kEccKeyPrivD));
675-
if (rc != 0) goto exit;
677+
if (rc != 0 && rc != NOT_COMPILED_IN) {
678+
/* a NOT_COMPILED_IN here likely means the WOLFSSL_PUBLIC_MP is enabled
679+
* exposing the mp_ math API's needed for encrypting secrets */
680+
goto exit;
681+
}
676682
/* Use TPM Handle... */
677683
printf("ECC Private Key Loaded into TPM: Handle 0x%x\n",
678684
(word32)eccKey.handle.hndl);

0 commit comments

Comments
 (0)