Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for TPM2 create with decrypt or restricted flag set #275

Merged
merged 2 commits into from Jul 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/tpm2_wrap.c
Expand Up @@ -4514,7 +4514,10 @@ static int GetKeyTemplateRSA(TPMT_PUBLIC* publicTemplate,
publicTemplate->parameters.rsaDetail.exponent = exponent;
publicTemplate->parameters.rsaDetail.scheme.scheme = sigScheme;
publicTemplate->parameters.rsaDetail.scheme.details.anySig.hashAlg = sigHash;
if (objectAttributes & TPMA_OBJECT_fixedTPM) {
/* For fixedParent or (decrypt and restricted) enable symmetric */
if ((objectAttributes & TPMA_OBJECT_fixedParent) ||
((objectAttributes & TPMA_OBJECT_decrypt) &&
(objectAttributes & TPMA_OBJECT_restricted))) {
publicTemplate->parameters.rsaDetail.symmetric.algorithm = TPM_ALG_AES;
publicTemplate->parameters.rsaDetail.symmetric.keyBits.aes = 128;
publicTemplate->parameters.rsaDetail.symmetric.mode.aes = TPM_ALG_CFB;
Expand All @@ -4541,7 +4544,10 @@ static int GetKeyTemplateECC(TPMT_PUBLIC* publicTemplate,
publicTemplate->unique.ecc.x.size = curveSz;
publicTemplate->unique.ecc.y.size = curveSz;
publicTemplate->objectAttributes = objectAttributes;
if (objectAttributes & TPMA_OBJECT_fixedTPM) {
/* For fixedParent or (decrypt and restricted) enable symmetric */
if ((objectAttributes & TPMA_OBJECT_fixedParent) ||
((objectAttributes & TPMA_OBJECT_decrypt) &&
(objectAttributes & TPMA_OBJECT_restricted))) {
publicTemplate->parameters.eccDetail.symmetric.algorithm = TPM_ALG_AES;
publicTemplate->parameters.eccDetail.symmetric.keyBits.aes = 128;
publicTemplate->parameters.eccDetail.symmetric.mode.aes = TPM_ALG_CFB;
Expand Down