Skip to content

Commit

Permalink
FAPI: Fix serialization of TPMS_POLICYTEMPLATE.
Browse files Browse the repository at this point in the history
* The unused field templateName was removed from TPMS_POLICYTEMPLATE.
* For the usage of TPMT_PUBLIC in policies the unique date is
  not needed.To simplify the definition of policies the
  unqiqe field will be set to zero if no unique definition
  is provided.

Signed-off-by: Juergen Repp <juergen_repp@web.de>
  • Loading branch information
JuergenReppSIT authored and cplappert committed Dec 15, 2022
1 parent c4feff9 commit ee99c46
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
7 changes: 0 additions & 7 deletions src/tss2-fapi/ifapi_policy_json_deserialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,13 +1061,6 @@ ifapi_json_TPMS_POLICYTEMPLATE_deserialize(json_object *jso,
out->templatePublic.size = 0;
}

if (ifapi_get_sub_object(jso, "templateName", &jso2)) {
r = ifapi_json_char_deserialize(jso2, &out->templateName);
return_if_error(r, "Bad value for field \"templateName\".");
} else {
out->templateName = NULL;
}

/* Check whether only one condition field found in policy. */
if (cond_cnt != 1) {
return_error(TSS2_FAPI_RC_BAD_VALUE,
Expand Down
8 changes: 0 additions & 8 deletions src/tss2-fapi/ifapi_policy_json_serialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,14 +811,6 @@ ifapi_json_TPMS_POLICYTEMPLATE_serialize(const TPMS_POLICYTEMPLATE *in,

json_object_object_add(*jso, "templatePublic", jso2);
}
if (in->templateName) {
jso2 = NULL;
cond_cnt++;
r = ifapi_json_char_serialize(in->templateName, &jso2);
return_if_error(r, "Serialize char");

json_object_object_add(*jso, "templateName", jso2);
}

/* Check whether only one condition field found in policy. */
if (cond_cnt != 1) {
Expand Down
1 change: 0 additions & 1 deletion src/tss2-fapi/ifapi_policy_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ typedef struct {
typedef struct {
TPM2B_DIGEST templateHash; /**< None */
TPM2B_PUBLIC templatePublic; /**< None */
char *templateName; /**< None */
} TPMS_POLICYTEMPLATE;

/** Policy type TPMS_POLICYAUTHORIZENV
Expand Down
8 changes: 4 additions & 4 deletions src/tss2-fapi/tpm_json_deserialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -4323,11 +4323,11 @@ ifapi_json_TPMT_PUBLIC_deserialize(json_object *jso, TPMT_PUBLIC *out)
return_if_error(r, "Bad value for field \"parameters\".");

if (!ifapi_get_sub_object(jso, "unique", &jso2)) {
LOG_ERROR("Field \"unique\" not found.");
return TSS2_FAPI_RC_BAD_VALUE;
memset(&out->unique, 0, sizeof(TPMU_PUBLIC_ID));
} else {
r = ifapi_json_TPMU_PUBLIC_ID_deserialize(out->type, jso2, &out->unique);
return_if_error(r, "Bad value for field \"unique\".");
}
r = ifapi_json_TPMU_PUBLIC_ID_deserialize(out->type, jso2, &out->unique);
return_if_error(r, "Bad value for field \"unique\".");

LOG_TRACE("true");
return TSS2_RC_SUCCESS;
Expand Down

0 comments on commit ee99c46

Please sign in to comment.