Merge pull request #275 from dgarske/zd16249

Fix for TPM2 create with decrypt or restricted flag set
pull/279/head
John Bland 2023-07-06 13:17:32 -04:00 committed by GitHub
commit e140a8b3d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -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;
@ -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;