diff --git a/script/yaml_mu_gen.py b/script/yaml_mu_gen.py index 990f687b0..167fd31d5 100755 --- a/script/yaml_mu_gen.py +++ b/script/yaml_mu_gen.py @@ -737,6 +737,25 @@ def type_to_root(scalar_map: dict, scalar: CScalar) -> CScalar: resolved = scalar return resolved +def find_union_selector(parent_field_map: {str, CType}): + + possible_selectors = [ + key + for key, value in parent_field_map.items() + if isinstance(value, CScalar) + ] + + if len(possible_selectors) != 1: + if "type" in possible_selectors: + possible_selectors = [ "type" ] + else: + raise RuntimeError( + f"Unexpected, Cannot handle {len(possible_selectors)} union selectors" + ) + + found_selector = possible_selectors[0] + return found_selector + def generate_complex_code_gen( cprsr: CTypeParser, @@ -835,34 +854,26 @@ def generate_complex_code_gen( if not name.startswith(prefix): continue + if name == "TPMS_ATTEST": + pass + needed_protos.append(name) emitters = [] parsers = [] field_map = type_.fields - # if it contains a TPMU subfield, we DROP the selector, so figure it out - found_selector = None - has_union_field = any(isinstance(x, CUnion) for x in field_map.values()) - if has_union_field: - possible_selectors = [ - key - for key, value in field_map.items() - if isinstance(value, CScalar) - ] - if len(possible_selectors) != 1: - if "type" in possible_selectors: - possible_selectors = "type" - else: - raise RuntimeError( - f"Unexpected, Cannot handle {len(possible_selectors)} union selectors" - ) - elif len(possible_selectors) == 1: - found_selector = possible_selectors[0] + + # AFAICT a type containing TPMU's will only have one selector + found_unions = [ x for x in field_map.values() if isinstance(x, CUnion) ] + union_selector = find_union_selector(field_map) if found_unions else None for field_name, field_type in field_map.items(): - # TODO we don't want to call the default scalar handler if we have - # scalar names, ie TPM2_ALG_ID for sha256... + + # We never directly consume or output the union selector + if field_name == union_selector: + continue + if isinstance(field_type, CScalar): resolved_type = type_to_root( scalar_type_map, scalar_type_map[field_type.name] @@ -883,19 +894,21 @@ def generate_complex_code_gen( else: fn_name = f"yaml_internal_{resolved_type.name}" - if has_union_field and found_selector == field_name: + if isinstance(resolved_type, CUnion): + emitters.append( - f' KVP_ADD_MARSHAL("{field_name}", 0, NULL, NULL)' + f' KVPU_ADD_MARSHAL("{field_name}", sizeof(src->{union_selector}), &src->{union_selector}, yaml_internal_{resolved_type.name}_scalar_marshal, sizeof(src->{field_name}), &src->{field_name}, yaml_internal_{resolved_type.name}_marshal)' ) - + parsers.append( - f' KVP_ADD_UNMARSHAL("{field_name}", 0, NULL, NULL)' + f' KVPU_ADD_UNMARSHAL("{field_name}", sizeof(tmp_dest.{union_selector}), &tmp_dest.{union_selector}, yaml_internal_{resolved_type.name}_scalar_unmarshal, sizeof(tmp_dest.{field_name}), &tmp_dest.{field_name}, {fn_name}_unmarshal)' ) + else: emitters.append( f' KVP_ADD_MARSHAL("{field_name}", sizeof(src->{field_name}), &src->{field_name}, {fn_name}_marshal)' ) - + parsers.append( f' KVP_ADD_UNMARSHAL("{field_name}", sizeof(tmp_dest.{field_name}), &tmp_dest.{field_name}, {fn_name}_unmarshal)' ) @@ -1298,9 +1311,6 @@ def generate_protos(proj_root: str, needed_protos: list[str]): cprsr, proj_root, "yaml-tpmt", "TPMT_", needed_protos, needed_leafs ) - # TODO generated leaf functions for UNIONS should unpack them and call the proper - # underlying method based on type. - # generate_union_code_gen( # cprsr, proj_root, needed_protos, needed_leafs # ) @@ -1308,6 +1318,8 @@ def generate_protos(proj_root: str, needed_protos: list[str]): # TODO TPMU # TODO TPML + # BILL PICK UP HERE + # TODO TPMU leafs should be "internal" and generated, this will also fix my TPMU TODO. generate_leafs(cprsr, proj_root, needed_leafs) generate_protos(proj_root, needed_protos) diff --git a/src/tss2-mu-yaml/yaml-common.h b/src/tss2-mu-yaml/yaml-common.h index 7ee255064..9be4f3a4d 100644 --- a/src/tss2-mu-yaml/yaml-common.h +++ b/src/tss2-mu-yaml/yaml-common.h @@ -27,8 +27,10 @@ struct datum { }; struct key_value { + bool is_union; const char *key; datum value; + datum union_extra; }; typedef struct write_data write_data; @@ -53,8 +55,11 @@ struct parser_state { #define FIELD_TYPE(type, field) typeof(((type *)NULL)->field) /* Adding key values to the list for emitting (generating YAML) */ -#define KVP_ADD_MARSHAL(k, s, v, m) {.key = k, .value = { .data = (void *)v, .size = s, .marshal = m }} -#define KVP_ADD_UNMARSHAL(k, s, v, u) {.key = k, .value = { .data = (void *)v, .size = s, .unmarshal = u }} +#define KVP_ADD_MARSHAL(k, s, v, m) {.is_union = false, .key = k, .value = { .data = (void *)v, .size = s, .marshal = m }, .union_extra = { 0 }} +#define KVP_ADD_UNMARSHAL(k, s, v, u) {.is_union = false, .key = k, .value = { .data = (void *)v, .size = s, .unmarshal = u }, .union_extra = { 0 }} + +#define KVPU_ADD_MARSHAL(k, us, uv, um, s, v, m) {.is_union = true, .key = k, .union_extra = { .data = (void *)uv, .size = us, .marshal = um }, .value = { .data = (void *)v, .size = s, .masrhal = m }} +#define KVPU_ADD_UNMARSHAL(k, us, uv, uu, s, v, u) {.is_union = true, .key = k, .union_extra = { .data = (void *)uv, .size = us, .marshal = uu }, .value = { .data = (void *)v, .size = s, .unmarshal = u }} #define return_yaml_rc(rc) do { if (!rc) { return yaml_to_tss2_rc(rc); } } while (0) diff --git a/src/tss2-mu-yaml/yaml-internal.c b/src/tss2-mu-yaml/yaml-internal.c index d817ad110..d92981cf1 100644 --- a/src/tss2-mu-yaml/yaml-internal.c +++ b/src/tss2-mu-yaml/yaml-internal.c @@ -10,118 +10,6 @@ #include "yaml-common.h" #include "yaml-internal.h" -TSS2_RC yaml_internal_TPMA_SESSION_scalar_marshal(const datum *in, char **out) { - assert(in); - assert(out); - assert(sizeof(TPMA_SESSION) == in->size); - - const TPMA_SESSION *d = (const TPMA_SESSION *)in->data; - TPMA_SESSION tmp = *d; - - static struct { - TPMA_SESSION key; - const char *value; - } lookup[] = { - {TPMA_SESSION_AUDIT, "audit"}, - {TPMA_SESSION_DECRYPT, "decrypt"}, - {TPMA_SESSION_ENCRYPT, "encrypt"}, - {TPMA_SESSION_AUDITRESET, "auditreset"}, - {TPMA_SESSION_AUDITEXCLUSIVE, "auditexclusive"}, - {TPMA_SESSION_CONTINUESESSION, "continuesession"} - }; - - // TODO more intelligence on size selection? - char buf[1024] = { 0 }; - char *p = buf; - while(tmp) { - unsigned i; - for (i=0; i < ARRAY_LEN(lookup); i++) { - if (tmp & lookup[i].key) { - /* turns down the bit OR sets to 0 to break the loop */ - tmp &= ~lookup[i].key; - strncat(p, lookup[i].value, sizeof(buf) - 1); - break; - } - } - if (i >= ARRAY_LEN(lookup)) { - return yaml_common_scalar_int8_t_marshal(*d, out); - } - } - - if (buf[0] == ',') { - p++; - } - - char *s = strdup(p); - if (!s) { - return TSS2_MU_RC_MEMORY; - } - - *out = s; - return TSS2_RC_SUCCESS; -} - -TSS2_RC yaml_internal_TPMA_SESSION_scalar_unmarshal(const char *in, size_t len, datum *out) { - - assert(in); - assert(out); - assert(out->size == sizeof(TPMA_SESSION)); - - // TODO can we plumb this right? - UNUSED(len); - - char *s = strdup(in); - if (!s) { - return TSS2_MU_RC_MEMORY; - } - - char *saveptr = NULL; - char *token = NULL; - - TPMA_SESSION tmp = 0; - TPMA_SESSION *result = out->data; - - yaml_common_to_lower(s); - - static const struct { - const char *key; - TPMA_SESSION value; - } lookup[] = { - {"tpma_session_continuesession", TPMA_SESSION_CONTINUESESSION}, - {"continuesession", TPMA_SESSION_CONTINUESESSION}, - {"tpma_session_auditexclusive", TPMA_SESSION_AUDITEXCLUSIVE}, - {"auditexclusive", TPMA_SESSION_AUDITEXCLUSIVE}, - {"tpma_session_auditreset", TPMA_SESSION_AUDITRESET}, - {"auditreset", TPMA_SESSION_AUDITRESET}, - {"tpma_session_decrypt", TPMA_SESSION_DECRYPT}, - {"decrypt", TPMA_SESSION_DECRYPT}, - {"tpma_session_encrypt", TPMA_SESSION_ENCRYPT}, - {"encrypt", TPMA_SESSION_ENCRYPT}, - {"tpma_session_audit", TPMA_SESSION_AUDIT}, - {"audit", TPMA_SESSION_AUDIT} - }; - - char *x = s; - while ((token = strtok_r(x, ",", &saveptr))) { - x = NULL; - size_t i; - for(i=0; i < ARRAY_LEN(lookup); i++) { - if (!strcmp(token, lookup[i].key)) { - tmp |= lookup[i].value; - break; - } - } - if (i >= ARRAY_LEN(lookup)) { - free(s); - return yaml_common_scalar_int8_t_unmarshal(in, len, result); - } - } - - *result = tmp; - free(s); - return TSS2_RC_SUCCESS; -} - TSS2_RC yaml_internal_TPM2_PT_PCR_scalar_marshal(const datum *in, char **out) { assert(in); assert(out); @@ -271,7 +159,6 @@ TSS2_RC yaml_internal_TPM2_PT_PCR_scalar_unmarshal(const char *in, size_t len, d for(i=0; i < ARRAY_LEN(lookup); i++) { if (!strcmp(token, lookup[i].key)) { tmp |= lookup[i].value; - break; } } if (i >= ARRAY_LEN(lookup)) { @@ -285,372 +172,333 @@ TSS2_RC yaml_internal_TPM2_PT_PCR_scalar_unmarshal(const char *in, size_t len, d return TSS2_RC_SUCCESS; } -TSS2_RC yaml_internal_TPM2B_AUTH_marshal(const datum *in, char **out) -{ +TSS2_RC yaml_internal_TPMA_ALGORITHM_scalar_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPM2B_AUTH) == in->size); + assert(sizeof(TPMA_ALGORITHM) == in->size); - const TPM2B_AUTH *x = (const TPM2B_AUTH *)in->data; + const TPMA_ALGORITHM *d = (const TPMA_ALGORITHM *)in->data; + TPMA_ALGORITHM tmp = *d; - return Tss2_MU_YAML_TPM2B_AUTH_Marshal(x, out); -} + static struct { + TPMA_ALGORITHM key; + const char *value; + } lookup[] = { + {TPMA_ALGORITHM_HASH, "hash"}, + {TPMA_ALGORITHM_OBJECT, "object"}, + {TPMA_ALGORITHM_METHOD, "method"}, + {TPMA_ALGORITHM_SIGNING, "signing"}, + {TPMA_ALGORITHM_SYMMETRIC, "symmetric"}, + {TPMA_ALGORITHM_ASYMMETRIC, "asymmetric"}, + {TPMA_ALGORITHM_ENCRYPTING, "encrypting"} + }; -TSS2_RC yaml_internal_TPM2B_AUTH_unmarshal(const char *in, size_t len, datum *out) { + // TODO more intelligence on size selection? + char buf[1024] = { 0 }; + char *p = buf; + while(tmp) { + unsigned i; + for (i=0; i < ARRAY_LEN(lookup); i++) { + if (tmp & lookup[i].key) { + /* turns down the bit OR sets to 0 to break the loop */ + tmp &= ~lookup[i].key; + strncat(p, lookup[i].value, sizeof(buf) - 1); + break; + } + } + if (i >= ARRAY_LEN(lookup)) { + return yaml_common_scalar_int32_t_marshal(*d, out); + } + } - assert(in); - assert(out); - assert(sizeof(TPM2B_AUTH) == out->size); + if (buf[0] == ',') { + p++; + } - TPM2B_AUTH *x = (TPM2B_AUTH *)out->data; + char *s = strdup(p); + if (!s) { + return TSS2_MU_RC_MEMORY; + } - return Tss2_MU_YAML_TPM2B_AUTH_Unmarshal(in, len, x); + *out = s; + return TSS2_RC_SUCCESS; } -TSS2_RC yaml_internal_TPMT_SYM_DEF_OBJECT_marshal(const datum *in, char **out) -{ +TSS2_RC yaml_internal_TPMA_ALGORITHM_scalar_unmarshal(const char *in, size_t len, datum *out) { + assert(in); assert(out); - assert(sizeof(TPMT_SYM_DEF_OBJECT) == in->size); + assert(out->size == sizeof(TPMA_ALGORITHM)); - const TPMT_SYM_DEF_OBJECT *x = (const TPMT_SYM_DEF_OBJECT *)in->data; + // TODO can we plumb this right? + UNUSED(len); - return Tss2_MU_YAML_TPMT_SYM_DEF_OBJECT_Marshal(x, out); -} + char *s = strdup(in); + if (!s) { + return TSS2_MU_RC_MEMORY; + } -TSS2_RC yaml_internal_TPMT_SYM_DEF_OBJECT_unmarshal(const char *in, size_t len, datum *out) { + char *saveptr = NULL; + char *token = NULL; - assert(in); - assert(out); - assert(sizeof(TPMT_SYM_DEF_OBJECT) == out->size); + TPMA_ALGORITHM tmp = 0; + TPMA_ALGORITHM *result = out->data; - TPMT_SYM_DEF_OBJECT *x = (TPMT_SYM_DEF_OBJECT *)out->data; + yaml_common_to_lower(s); - return Tss2_MU_YAML_TPMT_SYM_DEF_OBJECT_Unmarshal(in, len, x); + static const struct { + const char *key; + TPMA_ALGORITHM value; + } lookup[] = { + {"tpma_algorithm_asymmetric", TPMA_ALGORITHM_ASYMMETRIC}, + {"asymmetric", TPMA_ALGORITHM_ASYMMETRIC}, + {"tpma_algorithm_symmetric", TPMA_ALGORITHM_SYMMETRIC}, + {"symmetric", TPMA_ALGORITHM_SYMMETRIC}, + {"tpma_algorithm_hash", TPMA_ALGORITHM_HASH}, + {"hash", TPMA_ALGORITHM_HASH}, + {"tpma_algorithm_object", TPMA_ALGORITHM_OBJECT}, + {"object", TPMA_ALGORITHM_OBJECT}, + {"tpma_algorithm_signing", TPMA_ALGORITHM_SIGNING}, + {"signing", TPMA_ALGORITHM_SIGNING}, + {"tpma_algorithm_encrypting", TPMA_ALGORITHM_ENCRYPTING}, + {"encrypting", TPMA_ALGORITHM_ENCRYPTING}, + {"tpma_algorithm_method", TPMA_ALGORITHM_METHOD}, + {"method", TPMA_ALGORITHM_METHOD} + }; + + char *x = s; + while ((token = strtok_r(x, ",", &saveptr))) { + x = NULL; + size_t i; + for(i=0; i < ARRAY_LEN(lookup); i++) { + if (!strcmp(token, lookup[i].key)) { + tmp |= lookup[i].value; + } + } + if (i >= ARRAY_LEN(lookup)) { + free(s); + return yaml_common_scalar_int32_t_unmarshal(in, len, result); + } + } + + *result = tmp; + free(s); + return TSS2_RC_SUCCESS; } -TSS2_RC yaml_internal_TPMU_PUBLIC_ID_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPM2B_MAX_NV_BUFFER_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPMU_PUBLIC_ID) == in->size); + assert(sizeof(TPM2B_MAX_NV_BUFFER) == in->size); - const TPMU_PUBLIC_ID *x = (const TPMU_PUBLIC_ID *)in->data; + const TPM2B_MAX_NV_BUFFER *x = (const TPM2B_MAX_NV_BUFFER *)in->data; - return Tss2_MU_YAML_TPMU_PUBLIC_ID_Marshal(x, out); + return Tss2_MU_YAML_TPM2B_MAX_NV_BUFFER_Marshal(x, out); } -TSS2_RC yaml_internal_TPMU_PUBLIC_ID_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPM2B_MAX_NV_BUFFER_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPMU_PUBLIC_ID) == out->size); + assert(sizeof(TPM2B_MAX_NV_BUFFER) == out->size); - TPMU_PUBLIC_ID *x = (TPMU_PUBLIC_ID *)out->data; + TPM2B_MAX_NV_BUFFER *x = (TPM2B_MAX_NV_BUFFER *)out->data; - return Tss2_MU_YAML_TPMU_PUBLIC_ID_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPM2B_MAX_NV_BUFFER_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPMT_ECC_SCHEME_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPMS_TIME_INFO_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPMT_ECC_SCHEME) == in->size); + assert(sizeof(TPMS_TIME_INFO) == in->size); - const TPMT_ECC_SCHEME *x = (const TPMT_ECC_SCHEME *)in->data; + const TPMS_TIME_INFO *x = (const TPMS_TIME_INFO *)in->data; - return Tss2_MU_YAML_TPMT_ECC_SCHEME_Marshal(x, out); + return Tss2_MU_YAML_TPMS_TIME_INFO_Marshal(x, out); } -TSS2_RC yaml_internal_TPMT_ECC_SCHEME_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMS_TIME_INFO_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPMT_ECC_SCHEME) == out->size); + assert(sizeof(TPMS_TIME_INFO) == out->size); - TPMT_ECC_SCHEME *x = (TPMT_ECC_SCHEME *)out->data; + TPMS_TIME_INFO *x = (TPMS_TIME_INFO *)out->data; - return Tss2_MU_YAML_TPMT_ECC_SCHEME_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPMS_TIME_INFO_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPM2B_CONTEXT_SENSITIVE_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPMT_KDF_SCHEME_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPM2B_CONTEXT_SENSITIVE) == in->size); + assert(sizeof(TPMT_KDF_SCHEME) == in->size); - const TPM2B_CONTEXT_SENSITIVE *x = (const TPM2B_CONTEXT_SENSITIVE *)in->data; + const TPMT_KDF_SCHEME *x = (const TPMT_KDF_SCHEME *)in->data; - return Tss2_MU_YAML_TPM2B_CONTEXT_SENSITIVE_Marshal(x, out); + return Tss2_MU_YAML_TPMT_KDF_SCHEME_Marshal(x, out); } -TSS2_RC yaml_internal_TPM2B_CONTEXT_SENSITIVE_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMT_KDF_SCHEME_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPM2B_CONTEXT_SENSITIVE) == out->size); + assert(sizeof(TPMT_KDF_SCHEME) == out->size); - TPM2B_CONTEXT_SENSITIVE *x = (TPM2B_CONTEXT_SENSITIVE *)out->data; + TPMT_KDF_SCHEME *x = (TPMT_KDF_SCHEME *)out->data; - return Tss2_MU_YAML_TPM2B_CONTEXT_SENSITIVE_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPMT_KDF_SCHEME_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPMS_TIME_INFO_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPM2B_CONTEXT_DATA_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPMS_TIME_INFO) == in->size); + assert(sizeof(TPM2B_CONTEXT_DATA) == in->size); - const TPMS_TIME_INFO *x = (const TPMS_TIME_INFO *)in->data; + const TPM2B_CONTEXT_DATA *x = (const TPM2B_CONTEXT_DATA *)in->data; - return Tss2_MU_YAML_TPMS_TIME_INFO_Marshal(x, out); + return Tss2_MU_YAML_TPM2B_CONTEXT_DATA_Marshal(x, out); } -TSS2_RC yaml_internal_TPMS_TIME_INFO_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPM2B_CONTEXT_DATA_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPMS_TIME_INFO) == out->size); + assert(sizeof(TPM2B_CONTEXT_DATA) == out->size); - TPMS_TIME_INFO *x = (TPMS_TIME_INFO *)out->data; + TPM2B_CONTEXT_DATA *x = (TPM2B_CONTEXT_DATA *)out->data; - return Tss2_MU_YAML_TPMS_TIME_INFO_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPM2B_CONTEXT_DATA_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPMT_HA_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPMU_SENSITIVE_COMPOSITE_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPMT_HA) == in->size); + assert(sizeof(TPMU_SENSITIVE_COMPOSITE) == in->size); - const TPMT_HA *x = (const TPMT_HA *)in->data; + const TPMU_SENSITIVE_COMPOSITE *x = (const TPMU_SENSITIVE_COMPOSITE *)in->data; - return Tss2_MU_YAML_TPMT_HA_Marshal(x, out); + return Tss2_MU_YAML_TPMU_SENSITIVE_COMPOSITE_Marshal(x, out); } -TSS2_RC yaml_internal_TPMT_HA_unmarshal(const char *in, size_t len, datum *out) { - - assert(in); - assert(out); - assert(sizeof(TPMT_HA) == out->size); - - TPMT_HA *x = (TPMT_HA *)out->data; - - return Tss2_MU_YAML_TPMT_HA_Unmarshal(in, len, x); -} +TSS2_RC yaml_internal_TPMU_SENSITIVE_COMPOSITE_unmarshal(const char *in, size_t len, datum *out) { -TSS2_RC yaml_internal_uint64_t_scalar_marshal(const datum *in, char **out) -{ assert(in); assert(out); - assert(sizeof(uint64_t) == in->size); - - const uint64_t *x = (const uint64_t *)in->data; + assert(sizeof(TPMU_SENSITIVE_COMPOSITE) == out->size); - return yaml_common_scalar_uint64_t_marshal(*x, out); -} + TPMU_SENSITIVE_COMPOSITE *x = (TPMU_SENSITIVE_COMPOSITE *)out->data; -TSS2_RC yaml_internal_uint64_t_scalar_unmarshal(const char *in, size_t len, datum *out) -{ - assert(in); - return yaml_common_scalar_uint64_t_unmarshal(in, len, (uint64_t *)out->data); + return Tss2_MU_YAML_TPMU_SENSITIVE_COMPOSITE_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPMU_SYM_MODE_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPMU_SIGNATURE_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPMU_SYM_MODE) == in->size); + assert(sizeof(TPMU_SIGNATURE) == in->size); - const TPMU_SYM_MODE *x = (const TPMU_SYM_MODE *)in->data; + const TPMU_SIGNATURE *x = (const TPMU_SIGNATURE *)in->data; - return Tss2_MU_YAML_TPMU_SYM_MODE_Marshal(x, out); + return Tss2_MU_YAML_TPMU_SIGNATURE_Marshal(x, out); } -TSS2_RC yaml_internal_TPMU_SYM_MODE_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMU_SIGNATURE_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPMU_SYM_MODE) == out->size); + assert(sizeof(TPMU_SIGNATURE) == out->size); - TPMU_SYM_MODE *x = (TPMU_SYM_MODE *)out->data; + TPMU_SIGNATURE *x = (TPMU_SIGNATURE *)out->data; - return Tss2_MU_YAML_TPMU_SYM_MODE_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPMU_SIGNATURE_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPMA_LOCALITY_scalar_marshal(const datum *in, char **out) { +TSS2_RC yaml_internal_TPMU_KDF_SCHEME_marshal(const datum *in, char **out) +{ assert(in); assert(out); - assert(sizeof(TPMA_LOCALITY) == in->size); - - const TPMA_LOCALITY *d = (const TPMA_LOCALITY *)in->data; - TPMA_LOCALITY tmp = *d; - - static struct { - TPMA_LOCALITY key; - const char *value; - } lookup[] = { - {TPMA_LOCALITY_TPM2_LOC_ONE, "tpm2_loc_one"}, - {TPMA_LOCALITY_TPM2_LOC_TWO, "tpm2_loc_two"}, - {TPMA_LOCALITY_TPM2_LOC_ZERO, "tpm2_loc_zero"}, - {TPMA_LOCALITY_TPM2_LOC_FOUR, "tpm2_loc_four"}, - {TPMA_LOCALITY_TPM2_LOC_THREE, "tpm2_loc_three"} - }; - - // TODO more intelligence on size selection? - char buf[1024] = { 0 }; - char *p = buf; - while(tmp) { - unsigned i; - for (i=0; i < ARRAY_LEN(lookup); i++) { - if (tmp & lookup[i].key) { - /* turns down the bit OR sets to 0 to break the loop */ - tmp &= ~lookup[i].key; - strncat(p, lookup[i].value, sizeof(buf) - 1); - break; - } - } - if (i >= ARRAY_LEN(lookup)) { - return yaml_common_scalar_int8_t_marshal(*d, out); - } - } - - if (buf[0] == ',') { - p++; - } + assert(sizeof(TPMU_KDF_SCHEME) == in->size); - char *s = strdup(p); - if (!s) { - return TSS2_MU_RC_MEMORY; - } + const TPMU_KDF_SCHEME *x = (const TPMU_KDF_SCHEME *)in->data; - *out = s; - return TSS2_RC_SUCCESS; + return Tss2_MU_YAML_TPMU_KDF_SCHEME_Marshal(x, out); } -TSS2_RC yaml_internal_TPMA_LOCALITY_scalar_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMU_KDF_SCHEME_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(out->size == sizeof(TPMA_LOCALITY)); - - // TODO can we plumb this right? - UNUSED(len); - - char *s = strdup(in); - if (!s) { - return TSS2_MU_RC_MEMORY; - } - - char *saveptr = NULL; - char *token = NULL; - - TPMA_LOCALITY tmp = 0; - TPMA_LOCALITY *result = out->data; - - yaml_common_to_lower(s); - - static const struct { - const char *key; - TPMA_LOCALITY value; - } lookup[] = { - {"tpma_locality_tpm2_loc_zero", TPMA_LOCALITY_TPM2_LOC_ZERO}, - {"tpm2_loc_zero", TPMA_LOCALITY_TPM2_LOC_ZERO}, - {"tpma_locality_tpm2_loc_one", TPMA_LOCALITY_TPM2_LOC_ONE}, - {"tpm2_loc_one", TPMA_LOCALITY_TPM2_LOC_ONE}, - {"tpma_locality_tpm2_loc_two", TPMA_LOCALITY_TPM2_LOC_TWO}, - {"tpm2_loc_two", TPMA_LOCALITY_TPM2_LOC_TWO}, - {"tpma_locality_tpm2_loc_three", TPMA_LOCALITY_TPM2_LOC_THREE}, - {"tpm2_loc_three", TPMA_LOCALITY_TPM2_LOC_THREE}, - {"tpma_locality_tpm2_loc_four", TPMA_LOCALITY_TPM2_LOC_FOUR}, - {"tpm2_loc_four", TPMA_LOCALITY_TPM2_LOC_FOUR} - }; + assert(sizeof(TPMU_KDF_SCHEME) == out->size); - char *x = s; - while ((token = strtok_r(x, ",", &saveptr))) { - x = NULL; - size_t i; - for(i=0; i < ARRAY_LEN(lookup); i++) { - if (!strcmp(token, lookup[i].key)) { - tmp |= lookup[i].value; - break; - } - } - if (i >= ARRAY_LEN(lookup)) { - free(s); - return yaml_common_scalar_int8_t_unmarshal(in, len, result); - } - } + TPMU_KDF_SCHEME *x = (TPMU_KDF_SCHEME *)out->data; - *result = tmp; - free(s); - return TSS2_RC_SUCCESS; + return Tss2_MU_YAML_TPMU_KDF_SCHEME_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPMU_SYM_KEY_BITS_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPMU_SIG_SCHEME_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPMU_SYM_KEY_BITS) == in->size); + assert(sizeof(TPMU_SIG_SCHEME) == in->size); - const TPMU_SYM_KEY_BITS *x = (const TPMU_SYM_KEY_BITS *)in->data; + const TPMU_SIG_SCHEME *x = (const TPMU_SIG_SCHEME *)in->data; - return Tss2_MU_YAML_TPMU_SYM_KEY_BITS_Marshal(x, out); + return Tss2_MU_YAML_TPMU_SIG_SCHEME_Marshal(x, out); } -TSS2_RC yaml_internal_TPMU_SYM_KEY_BITS_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMU_SIG_SCHEME_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPMU_SYM_KEY_BITS) == out->size); + assert(sizeof(TPMU_SIG_SCHEME) == out->size); - TPMU_SYM_KEY_BITS *x = (TPMU_SYM_KEY_BITS *)out->data; + TPMU_SIG_SCHEME *x = (TPMU_SIG_SCHEME *)out->data; - return Tss2_MU_YAML_TPMU_SYM_KEY_BITS_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPMU_SIG_SCHEME_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPMU_PUBLIC_PARMS_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_uint16_t_scalar_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPMU_PUBLIC_PARMS) == in->size); + assert(sizeof(uint16_t) == in->size); - const TPMU_PUBLIC_PARMS *x = (const TPMU_PUBLIC_PARMS *)in->data; + const uint16_t *x = (const uint16_t *)in->data; - return Tss2_MU_YAML_TPMU_PUBLIC_PARMS_Marshal(x, out); + return yaml_common_scalar_uint16_t_marshal(*x, out); } -TSS2_RC yaml_internal_TPMU_PUBLIC_PARMS_unmarshal(const char *in, size_t len, datum *out) { - +TSS2_RC yaml_internal_uint16_t_scalar_unmarshal(const char *in, size_t len, datum *out) +{ assert(in); - assert(out); - assert(sizeof(TPMU_PUBLIC_PARMS) == out->size); - - TPMU_PUBLIC_PARMS *x = (TPMU_PUBLIC_PARMS *)out->data; - - return Tss2_MU_YAML_TPMU_PUBLIC_PARMS_Unmarshal(in, len, x); + return yaml_common_scalar_uint16_t_unmarshal(in, len, (uint16_t *)out->data); } -TSS2_RC yaml_internal_TPMT_KEYEDHASH_SCHEME_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPMU_SCHEME_KEYEDHASH_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPMT_KEYEDHASH_SCHEME) == in->size); + assert(sizeof(TPMU_SCHEME_KEYEDHASH) == in->size); - const TPMT_KEYEDHASH_SCHEME *x = (const TPMT_KEYEDHASH_SCHEME *)in->data; + const TPMU_SCHEME_KEYEDHASH *x = (const TPMU_SCHEME_KEYEDHASH *)in->data; - return Tss2_MU_YAML_TPMT_KEYEDHASH_SCHEME_Marshal(x, out); + return Tss2_MU_YAML_TPMU_SCHEME_KEYEDHASH_Marshal(x, out); } -TSS2_RC yaml_internal_TPMT_KEYEDHASH_SCHEME_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMU_SCHEME_KEYEDHASH_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPMT_KEYEDHASH_SCHEME) == out->size); + assert(sizeof(TPMU_SCHEME_KEYEDHASH) == out->size); - TPMT_KEYEDHASH_SCHEME *x = (TPMT_KEYEDHASH_SCHEME *)out->data; + TPMU_SCHEME_KEYEDHASH *x = (TPMU_SCHEME_KEYEDHASH *)out->data; - return Tss2_MU_YAML_TPMT_KEYEDHASH_SCHEME_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPMU_SCHEME_KEYEDHASH_Unmarshal(in, len, x); } TSS2_RC yaml_internal_TPM2_ALG_ID_scalar_marshal(const datum *in, char **out) { @@ -853,7 +701,6 @@ TSS2_RC yaml_internal_TPM2_ALG_ID_scalar_unmarshal(const char *in, size_t len, d for(i=0; i < ARRAY_LEN(lookup); i++) { if (!strcmp(token, lookup[i].key)) { tmp |= lookup[i].value; - break; } } if (i >= ARRAY_LEN(lookup)) { @@ -867,26 +714,329 @@ TSS2_RC yaml_internal_TPM2_ALG_ID_scalar_unmarshal(const char *in, size_t len, d return TSS2_RC_SUCCESS; } -TSS2_RC yaml_internal_TPML_PCR_SELECTION_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPM2B_DATA_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPML_PCR_SELECTION) == in->size); + assert(sizeof(TPM2B_DATA) == in->size); - const TPML_PCR_SELECTION *x = (const TPML_PCR_SELECTION *)in->data; + const TPM2B_DATA *x = (const TPM2B_DATA *)in->data; - return Tss2_MU_YAML_TPML_PCR_SELECTION_Marshal(x, out); + return Tss2_MU_YAML_TPM2B_DATA_Marshal(x, out); } -TSS2_RC yaml_internal_TPML_PCR_SELECTION_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPM2B_DATA_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPML_PCR_SELECTION) == out->size); + assert(sizeof(TPM2B_DATA) == out->size); - TPML_PCR_SELECTION *x = (TPML_PCR_SELECTION *)out->data; + TPM2B_DATA *x = (TPM2B_DATA *)out->data; - return Tss2_MU_YAML_TPML_PCR_SELECTION_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPM2B_DATA_Unmarshal(in, len, x); +} + +TSS2_RC yaml_internal_TPMU_SYM_MODE_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(TPMU_SYM_MODE) == in->size); + + const TPMU_SYM_MODE *x = (const TPMU_SYM_MODE *)in->data; + + return Tss2_MU_YAML_TPMU_SYM_MODE_Marshal(x, out); +} + +TSS2_RC yaml_internal_TPMU_SYM_MODE_unmarshal(const char *in, size_t len, datum *out) { + + assert(in); + assert(out); + assert(sizeof(TPMU_SYM_MODE) == out->size); + + TPMU_SYM_MODE *x = (TPMU_SYM_MODE *)out->data; + + return Tss2_MU_YAML_TPMU_SYM_MODE_Unmarshal(in, len, x); +} + +TSS2_RC yaml_internal_TPM2B_NONCE_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(TPM2B_NONCE) == in->size); + + const TPM2B_NONCE *x = (const TPM2B_NONCE *)in->data; + + return Tss2_MU_YAML_TPM2B_NONCE_Marshal(x, out); +} + +TSS2_RC yaml_internal_TPM2B_NONCE_unmarshal(const char *in, size_t len, datum *out) { + + assert(in); + assert(out); + assert(sizeof(TPM2B_NONCE) == out->size); + + TPM2B_NONCE *x = (TPM2B_NONCE *)out->data; + + return Tss2_MU_YAML_TPM2B_NONCE_Unmarshal(in, len, x); +} + +TSS2_RC yaml_internal_TPM2B_AUTH_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(TPM2B_AUTH) == in->size); + + const TPM2B_AUTH *x = (const TPM2B_AUTH *)in->data; + + return Tss2_MU_YAML_TPM2B_AUTH_Marshal(x, out); +} + +TSS2_RC yaml_internal_TPM2B_AUTH_unmarshal(const char *in, size_t len, datum *out) { + + assert(in); + assert(out); + assert(sizeof(TPM2B_AUTH) == out->size); + + TPM2B_AUTH *x = (TPM2B_AUTH *)out->data; + + return Tss2_MU_YAML_TPM2B_AUTH_Unmarshal(in, len, x); +} + +TSS2_RC yaml_internal_TPMU_CAPABILITIES_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(TPMU_CAPABILITIES) == in->size); + + const TPMU_CAPABILITIES *x = (const TPMU_CAPABILITIES *)in->data; + + return Tss2_MU_YAML_TPMU_CAPABILITIES_Marshal(x, out); +} + +TSS2_RC yaml_internal_TPMU_CAPABILITIES_unmarshal(const char *in, size_t len, datum *out) { + + assert(in); + assert(out); + assert(sizeof(TPMU_CAPABILITIES) == out->size); + + TPMU_CAPABILITIES *x = (TPMU_CAPABILITIES *)out->data; + + return Tss2_MU_YAML_TPMU_CAPABILITIES_Unmarshal(in, len, x); +} + +TSS2_RC yaml_internal_TPM2B_LABEL_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(TPM2B_LABEL) == in->size); + + const TPM2B_LABEL *x = (const TPM2B_LABEL *)in->data; + + return Tss2_MU_YAML_TPM2B_LABEL_Marshal(x, out); +} + +TSS2_RC yaml_internal_TPM2B_LABEL_unmarshal(const char *in, size_t len, datum *out) { + + assert(in); + assert(out); + assert(sizeof(TPM2B_LABEL) == out->size); + + TPM2B_LABEL *x = (TPM2B_LABEL *)out->data; + + return Tss2_MU_YAML_TPM2B_LABEL_Unmarshal(in, len, x); +} + +TSS2_RC yaml_internal_TPM2B_CONTEXT_SENSITIVE_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(TPM2B_CONTEXT_SENSITIVE) == in->size); + + const TPM2B_CONTEXT_SENSITIVE *x = (const TPM2B_CONTEXT_SENSITIVE *)in->data; + + return Tss2_MU_YAML_TPM2B_CONTEXT_SENSITIVE_Marshal(x, out); +} + +TSS2_RC yaml_internal_TPM2B_CONTEXT_SENSITIVE_unmarshal(const char *in, size_t len, datum *out) { + + assert(in); + assert(out); + assert(sizeof(TPM2B_CONTEXT_SENSITIVE) == out->size); + + TPM2B_CONTEXT_SENSITIVE *x = (TPM2B_CONTEXT_SENSITIVE *)out->data; + + return Tss2_MU_YAML_TPM2B_CONTEXT_SENSITIVE_Unmarshal(in, len, x); +} + +TSS2_RC yaml_internal_TPM2B_PUBLIC_KEY_RSA_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(TPM2B_PUBLIC_KEY_RSA) == in->size); + + const TPM2B_PUBLIC_KEY_RSA *x = (const TPM2B_PUBLIC_KEY_RSA *)in->data; + + return Tss2_MU_YAML_TPM2B_PUBLIC_KEY_RSA_Marshal(x, out); +} + +TSS2_RC yaml_internal_TPM2B_PUBLIC_KEY_RSA_unmarshal(const char *in, size_t len, datum *out) { + + assert(in); + assert(out); + assert(sizeof(TPM2B_PUBLIC_KEY_RSA) == out->size); + + TPM2B_PUBLIC_KEY_RSA *x = (TPM2B_PUBLIC_KEY_RSA *)out->data; + + return Tss2_MU_YAML_TPM2B_PUBLIC_KEY_RSA_Unmarshal(in, len, x); +} + +TSS2_RC yaml_internal_TPM2B_SENSITIVE_DATA_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(TPM2B_SENSITIVE_DATA) == in->size); + + const TPM2B_SENSITIVE_DATA *x = (const TPM2B_SENSITIVE_DATA *)in->data; + + return Tss2_MU_YAML_TPM2B_SENSITIVE_DATA_Marshal(x, out); +} + +TSS2_RC yaml_internal_TPM2B_SENSITIVE_DATA_unmarshal(const char *in, size_t len, datum *out) { + + assert(in); + assert(out); + assert(sizeof(TPM2B_SENSITIVE_DATA) == out->size); + + TPM2B_SENSITIVE_DATA *x = (TPM2B_SENSITIVE_DATA *)out->data; + + return Tss2_MU_YAML_TPM2B_SENSITIVE_DATA_Unmarshal(in, len, x); +} + +TSS2_RC yaml_internal_TPM2B_NAME_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(TPM2B_NAME) == in->size); + + const TPM2B_NAME *x = (const TPM2B_NAME *)in->data; + + return Tss2_MU_YAML_TPM2B_NAME_Marshal(x, out); +} + +TSS2_RC yaml_internal_TPM2B_NAME_unmarshal(const char *in, size_t len, datum *out) { + + assert(in); + assert(out); + assert(sizeof(TPM2B_NAME) == out->size); + + TPM2B_NAME *x = (TPM2B_NAME *)out->data; + + return Tss2_MU_YAML_TPM2B_NAME_Unmarshal(in, len, x); +} + +TSS2_RC yaml_internal_TPMT_ASYM_SCHEME_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(TPMT_ASYM_SCHEME) == in->size); + + const TPMT_ASYM_SCHEME *x = (const TPMT_ASYM_SCHEME *)in->data; + + return Tss2_MU_YAML_TPMT_ASYM_SCHEME_Marshal(x, out); +} + +TSS2_RC yaml_internal_TPMT_ASYM_SCHEME_unmarshal(const char *in, size_t len, datum *out) { + + assert(in); + assert(out); + assert(sizeof(TPMT_ASYM_SCHEME) == out->size); + + TPMT_ASYM_SCHEME *x = (TPMT_ASYM_SCHEME *)out->data; + + return Tss2_MU_YAML_TPMT_ASYM_SCHEME_Unmarshal(in, len, x); +} + +TSS2_RC yaml_internal_TPMU_PUBLIC_PARMS_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(TPMU_PUBLIC_PARMS) == in->size); + + const TPMU_PUBLIC_PARMS *x = (const TPMU_PUBLIC_PARMS *)in->data; + + return Tss2_MU_YAML_TPMU_PUBLIC_PARMS_Marshal(x, out); +} + +TSS2_RC yaml_internal_TPMU_PUBLIC_PARMS_unmarshal(const char *in, size_t len, datum *out) { + + assert(in); + assert(out); + assert(sizeof(TPMU_PUBLIC_PARMS) == out->size); + + TPMU_PUBLIC_PARMS *x = (TPMU_PUBLIC_PARMS *)out->data; + + return Tss2_MU_YAML_TPMU_PUBLIC_PARMS_Unmarshal(in, len, x); +} + +TSS2_RC yaml_internal_uint8_t_scalar_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(uint8_t) == in->size); + + const uint8_t *x = (const uint8_t *)in->data; + + return yaml_common_scalar_uint8_t_marshal(*x, out); +} + +TSS2_RC yaml_internal_uint8_t_scalar_unmarshal(const char *in, size_t len, datum *out) +{ + assert(in); + return yaml_common_scalar_uint8_t_unmarshal(in, len, (uint8_t *)out->data); +} + +TSS2_RC yaml_internal_TPMT_SYM_DEF_OBJECT_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(TPMT_SYM_DEF_OBJECT) == in->size); + + const TPMT_SYM_DEF_OBJECT *x = (const TPMT_SYM_DEF_OBJECT *)in->data; + + return Tss2_MU_YAML_TPMT_SYM_DEF_OBJECT_Marshal(x, out); +} + +TSS2_RC yaml_internal_TPMT_SYM_DEF_OBJECT_unmarshal(const char *in, size_t len, datum *out) { + + assert(in); + assert(out); + assert(sizeof(TPMT_SYM_DEF_OBJECT) == out->size); + + TPMT_SYM_DEF_OBJECT *x = (TPMT_SYM_DEF_OBJECT *)out->data; + + return Tss2_MU_YAML_TPMT_SYM_DEF_OBJECT_Unmarshal(in, len, x); +} + +TSS2_RC yaml_internal_TPMT_HA_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(TPMT_HA) == in->size); + + const TPMT_HA *x = (const TPMT_HA *)in->data; + + return Tss2_MU_YAML_TPMT_HA_Marshal(x, out); +} + +TSS2_RC yaml_internal_TPMT_HA_unmarshal(const char *in, size_t len, datum *out) { + + assert(in); + assert(out); + assert(sizeof(TPMT_HA) == out->size); + + TPMT_HA *x = (TPMT_HA *)out->data; + + return Tss2_MU_YAML_TPMT_HA_Unmarshal(in, len, x); } TSS2_RC yaml_internal_TPMA_OBJECT_scalar_marshal(const datum *in, char **out) { @@ -1011,7 +1161,6 @@ TSS2_RC yaml_internal_TPMA_OBJECT_scalar_unmarshal(const char *in, size_t len, d for(i=0; i < ARRAY_LEN(lookup); i++) { if (!strcmp(token, lookup[i].key)) { tmp |= lookup[i].value; - break; } } if (i >= ARRAY_LEN(lookup)) { @@ -1021,243 +1170,110 @@ TSS2_RC yaml_internal_TPMA_OBJECT_scalar_unmarshal(const char *in, size_t len, d } *result = tmp; - free(s); - return TSS2_RC_SUCCESS; -} - -TSS2_RC yaml_internal_TPMU_CAPABILITIES_marshal(const datum *in, char **out) -{ - assert(in); - assert(out); - assert(sizeof(TPMU_CAPABILITIES) == in->size); - - const TPMU_CAPABILITIES *x = (const TPMU_CAPABILITIES *)in->data; - - return Tss2_MU_YAML_TPMU_CAPABILITIES_Marshal(x, out); -} - -TSS2_RC yaml_internal_TPMU_CAPABILITIES_unmarshal(const char *in, size_t len, datum *out) { - - assert(in); - assert(out); - assert(sizeof(TPMU_CAPABILITIES) == out->size); - - TPMU_CAPABILITIES *x = (TPMU_CAPABILITIES *)out->data; - - return Tss2_MU_YAML_TPMU_CAPABILITIES_Unmarshal(in, len, x); -} - -TSS2_RC yaml_internal_TPMT_ASYM_SCHEME_marshal(const datum *in, char **out) -{ - assert(in); - assert(out); - assert(sizeof(TPMT_ASYM_SCHEME) == in->size); - - const TPMT_ASYM_SCHEME *x = (const TPMT_ASYM_SCHEME *)in->data; - - return Tss2_MU_YAML_TPMT_ASYM_SCHEME_Marshal(x, out); -} - -TSS2_RC yaml_internal_TPMT_ASYM_SCHEME_unmarshal(const char *in, size_t len, datum *out) { - - assert(in); - assert(out); - assert(sizeof(TPMT_ASYM_SCHEME) == out->size); - - TPMT_ASYM_SCHEME *x = (TPMT_ASYM_SCHEME *)out->data; - - return Tss2_MU_YAML_TPMT_ASYM_SCHEME_Unmarshal(in, len, x); -} - -TSS2_RC yaml_internal_TPM2B_DATA_marshal(const datum *in, char **out) -{ - assert(in); - assert(out); - assert(sizeof(TPM2B_DATA) == in->size); - - const TPM2B_DATA *x = (const TPM2B_DATA *)in->data; - - return Tss2_MU_YAML_TPM2B_DATA_Marshal(x, out); -} - -TSS2_RC yaml_internal_TPM2B_DATA_unmarshal(const char *in, size_t len, datum *out) { - - assert(in); - assert(out); - assert(sizeof(TPM2B_DATA) == out->size); - - TPM2B_DATA *x = (TPM2B_DATA *)out->data; - - return Tss2_MU_YAML_TPM2B_DATA_Unmarshal(in, len, x); -} - -TSS2_RC yaml_internal_TPM2B_LABEL_marshal(const datum *in, char **out) -{ - assert(in); - assert(out); - assert(sizeof(TPM2B_LABEL) == in->size); - - const TPM2B_LABEL *x = (const TPM2B_LABEL *)in->data; - - return Tss2_MU_YAML_TPM2B_LABEL_Marshal(x, out); -} - -TSS2_RC yaml_internal_TPM2B_LABEL_unmarshal(const char *in, size_t len, datum *out) { - - assert(in); - assert(out); - assert(sizeof(TPM2B_LABEL) == out->size); - - TPM2B_LABEL *x = (TPM2B_LABEL *)out->data; - - return Tss2_MU_YAML_TPM2B_LABEL_Unmarshal(in, len, x); -} - -TSS2_RC yaml_internal_TPMU_SENSITIVE_COMPOSITE_marshal(const datum *in, char **out) -{ - assert(in); - assert(out); - assert(sizeof(TPMU_SENSITIVE_COMPOSITE) == in->size); - - const TPMU_SENSITIVE_COMPOSITE *x = (const TPMU_SENSITIVE_COMPOSITE *)in->data; - - return Tss2_MU_YAML_TPMU_SENSITIVE_COMPOSITE_Marshal(x, out); -} - -TSS2_RC yaml_internal_TPMU_SENSITIVE_COMPOSITE_unmarshal(const char *in, size_t len, datum *out) { - - assert(in); - assert(out); - assert(sizeof(TPMU_SENSITIVE_COMPOSITE) == out->size); - - TPMU_SENSITIVE_COMPOSITE *x = (TPMU_SENSITIVE_COMPOSITE *)out->data; - - return Tss2_MU_YAML_TPMU_SENSITIVE_COMPOSITE_Unmarshal(in, len, x); -} - -TSS2_RC yaml_internal_TPMU_ASYM_SCHEME_marshal(const datum *in, char **out) -{ - assert(in); - assert(out); - assert(sizeof(TPMU_ASYM_SCHEME) == in->size); - - const TPMU_ASYM_SCHEME *x = (const TPMU_ASYM_SCHEME *)in->data; - - return Tss2_MU_YAML_TPMU_ASYM_SCHEME_Marshal(x, out); -} - -TSS2_RC yaml_internal_TPMU_ASYM_SCHEME_unmarshal(const char *in, size_t len, datum *out) { - - assert(in); - assert(out); - assert(sizeof(TPMU_ASYM_SCHEME) == out->size); - - TPMU_ASYM_SCHEME *x = (TPMU_ASYM_SCHEME *)out->data; - - return Tss2_MU_YAML_TPMU_ASYM_SCHEME_Unmarshal(in, len, x); + free(s); + return TSS2_RC_SUCCESS; } -TSS2_RC yaml_internal_TPM2B_ECC_PARAMETER_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPMU_SYM_KEY_BITS_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPM2B_ECC_PARAMETER) == in->size); + assert(sizeof(TPMU_SYM_KEY_BITS) == in->size); - const TPM2B_ECC_PARAMETER *x = (const TPM2B_ECC_PARAMETER *)in->data; + const TPMU_SYM_KEY_BITS *x = (const TPMU_SYM_KEY_BITS *)in->data; - return Tss2_MU_YAML_TPM2B_ECC_PARAMETER_Marshal(x, out); + return Tss2_MU_YAML_TPMU_SYM_KEY_BITS_Marshal(x, out); } -TSS2_RC yaml_internal_TPM2B_ECC_PARAMETER_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMU_SYM_KEY_BITS_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPM2B_ECC_PARAMETER) == out->size); + assert(sizeof(TPMU_SYM_KEY_BITS) == out->size); - TPM2B_ECC_PARAMETER *x = (TPM2B_ECC_PARAMETER *)out->data; + TPMU_SYM_KEY_BITS *x = (TPMU_SYM_KEY_BITS *)out->data; - return Tss2_MU_YAML_TPM2B_ECC_PARAMETER_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPMU_SYM_KEY_BITS_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPMU_KDF_SCHEME_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPMS_CLOCK_INFO_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPMU_KDF_SCHEME) == in->size); + assert(sizeof(TPMS_CLOCK_INFO) == in->size); - const TPMU_KDF_SCHEME *x = (const TPMU_KDF_SCHEME *)in->data; + const TPMS_CLOCK_INFO *x = (const TPMS_CLOCK_INFO *)in->data; - return Tss2_MU_YAML_TPMU_KDF_SCHEME_Marshal(x, out); + return Tss2_MU_YAML_TPMS_CLOCK_INFO_Marshal(x, out); } -TSS2_RC yaml_internal_TPMU_KDF_SCHEME_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMS_CLOCK_INFO_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPMU_KDF_SCHEME) == out->size); + assert(sizeof(TPMS_CLOCK_INFO) == out->size); - TPMU_KDF_SCHEME *x = (TPMU_KDF_SCHEME *)out->data; + TPMS_CLOCK_INFO *x = (TPMS_CLOCK_INFO *)out->data; - return Tss2_MU_YAML_TPMU_KDF_SCHEME_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPMS_CLOCK_INFO_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPM2B_NONCE_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_uint64_t_scalar_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPM2B_NONCE) == in->size); + assert(sizeof(uint64_t) == in->size); - const TPM2B_NONCE *x = (const TPM2B_NONCE *)in->data; + const uint64_t *x = (const uint64_t *)in->data; - return Tss2_MU_YAML_TPM2B_NONCE_Marshal(x, out); + return yaml_common_scalar_uint64_t_marshal(*x, out); } -TSS2_RC yaml_internal_TPM2B_NONCE_unmarshal(const char *in, size_t len, datum *out) { - +TSS2_RC yaml_internal_uint64_t_scalar_unmarshal(const char *in, size_t len, datum *out) +{ assert(in); - assert(out); - assert(sizeof(TPM2B_NONCE) == out->size); - - TPM2B_NONCE *x = (TPM2B_NONCE *)out->data; - - return Tss2_MU_YAML_TPM2B_NONCE_Unmarshal(in, len, x); + return yaml_common_scalar_uint64_t_unmarshal(in, len, (uint64_t *)out->data); } -TSS2_RC yaml_internal_TPMS_CLOCK_INFO_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPMT_ECC_SCHEME_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPMS_CLOCK_INFO) == in->size); + assert(sizeof(TPMT_ECC_SCHEME) == in->size); - const TPMS_CLOCK_INFO *x = (const TPMS_CLOCK_INFO *)in->data; + const TPMT_ECC_SCHEME *x = (const TPMT_ECC_SCHEME *)in->data; - return Tss2_MU_YAML_TPMS_CLOCK_INFO_Marshal(x, out); + return Tss2_MU_YAML_TPMT_ECC_SCHEME_Marshal(x, out); } -TSS2_RC yaml_internal_TPMS_CLOCK_INFO_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMT_ECC_SCHEME_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPMS_CLOCK_INFO) == out->size); + assert(sizeof(TPMT_ECC_SCHEME) == out->size); - TPMS_CLOCK_INFO *x = (TPMS_CLOCK_INFO *)out->data; + TPMT_ECC_SCHEME *x = (TPMT_ECC_SCHEME *)out->data; - return Tss2_MU_YAML_TPMS_CLOCK_INFO_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPMT_ECC_SCHEME_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPM2_GENERATED_scalar_marshal(const datum *in, char **out) { +TSS2_RC yaml_internal_TPMA_LOCALITY_scalar_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPM2_GENERATED) == in->size); + assert(sizeof(TPMA_LOCALITY) == in->size); - const TPM2_GENERATED *d = (const TPM2_GENERATED *)in->data; - TPM2_GENERATED tmp = *d; + const TPMA_LOCALITY *d = (const TPMA_LOCALITY *)in->data; + TPMA_LOCALITY tmp = *d; static struct { - TPM2_GENERATED key; + TPMA_LOCALITY key; const char *value; } lookup[] = { - {TPM2_GENERATED_VALUE, "value"} + {TPMA_LOCALITY_TPM2_LOC_ONE, "tpm2_loc_one"}, + {TPMA_LOCALITY_TPM2_LOC_TWO, "tpm2_loc_two"}, + {TPMA_LOCALITY_TPM2_LOC_ZERO, "tpm2_loc_zero"}, + {TPMA_LOCALITY_TPM2_LOC_FOUR, "tpm2_loc_four"}, + {TPMA_LOCALITY_TPM2_LOC_THREE, "tpm2_loc_three"} }; // TODO more intelligence on size selection? @@ -1266,7 +1282,7 @@ TSS2_RC yaml_internal_TPM2_GENERATED_scalar_marshal(const datum *in, char **out) while(tmp) { unsigned i; for (i=0; i < ARRAY_LEN(lookup); i++) { - if (tmp == lookup[i].key) { + if (tmp & lookup[i].key) { /* turns down the bit OR sets to 0 to break the loop */ tmp &= ~lookup[i].key; strncat(p, lookup[i].value, sizeof(buf) - 1); @@ -1274,7 +1290,7 @@ TSS2_RC yaml_internal_TPM2_GENERATED_scalar_marshal(const datum *in, char **out) } } if (i >= ARRAY_LEN(lookup)) { - return yaml_common_scalar_int32_t_marshal(*d, out); + return yaml_common_scalar_int8_t_marshal(*d, out); } } @@ -1291,11 +1307,11 @@ TSS2_RC yaml_internal_TPM2_GENERATED_scalar_marshal(const datum *in, char **out) return TSS2_RC_SUCCESS; } -TSS2_RC yaml_internal_TPM2_GENERATED_scalar_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMA_LOCALITY_scalar_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(out->size == sizeof(TPM2_GENERATED)); + assert(out->size == sizeof(TPMA_LOCALITY)); // TODO can we plumb this right? UNUSED(len); @@ -1308,17 +1324,25 @@ TSS2_RC yaml_internal_TPM2_GENERATED_scalar_unmarshal(const char *in, size_t len char *saveptr = NULL; char *token = NULL; - TPM2_GENERATED tmp = 0; - TPM2_GENERATED *result = out->data; + TPMA_LOCALITY tmp = 0; + TPMA_LOCALITY *result = out->data; yaml_common_to_lower(s); static const struct { const char *key; - TPM2_GENERATED value; + TPMA_LOCALITY value; } lookup[] = { - {"tpm2_generated_value", TPM2_GENERATED_VALUE}, - {"value", TPM2_GENERATED_VALUE} + {"tpma_locality_tpm2_loc_zero", TPMA_LOCALITY_TPM2_LOC_ZERO}, + {"tpm2_loc_zero", TPMA_LOCALITY_TPM2_LOC_ZERO}, + {"tpma_locality_tpm2_loc_one", TPMA_LOCALITY_TPM2_LOC_ONE}, + {"tpm2_loc_one", TPMA_LOCALITY_TPM2_LOC_ONE}, + {"tpma_locality_tpm2_loc_two", TPMA_LOCALITY_TPM2_LOC_TWO}, + {"tpm2_loc_two", TPMA_LOCALITY_TPM2_LOC_TWO}, + {"tpma_locality_tpm2_loc_three", TPMA_LOCALITY_TPM2_LOC_THREE}, + {"tpm2_loc_three", TPMA_LOCALITY_TPM2_LOC_THREE}, + {"tpma_locality_tpm2_loc_four", TPMA_LOCALITY_TPM2_LOC_FOUR}, + {"tpm2_loc_four", TPMA_LOCALITY_TPM2_LOC_FOUR} }; char *x = s; @@ -1328,12 +1352,11 @@ TSS2_RC yaml_internal_TPM2_GENERATED_scalar_unmarshal(const char *in, size_t len for(i=0; i < ARRAY_LEN(lookup); i++) { if (!strcmp(token, lookup[i].key)) { tmp |= lookup[i].value; - break; } } if (i >= ARRAY_LEN(lookup)) { free(s); - return yaml_common_scalar_int32_t_unmarshal(in, len, result); + return yaml_common_scalar_int8_t_unmarshal(in, len, result); } } @@ -1342,240 +1365,208 @@ TSS2_RC yaml_internal_TPM2_GENERATED_scalar_unmarshal(const char *in, size_t len return TSS2_RC_SUCCESS; } -TSS2_RC yaml_internal_TPM2B_NAME_marshal(const datum *in, char **out) -{ - assert(in); - assert(out); - assert(sizeof(TPM2B_NAME) == in->size); - - const TPM2B_NAME *x = (const TPM2B_NAME *)in->data; - - return Tss2_MU_YAML_TPM2B_NAME_Marshal(x, out); -} - -TSS2_RC yaml_internal_TPM2B_NAME_unmarshal(const char *in, size_t len, datum *out) { - - assert(in); - assert(out); - assert(sizeof(TPM2B_NAME) == out->size); - - TPM2B_NAME *x = (TPM2B_NAME *)out->data; - - return Tss2_MU_YAML_TPM2B_NAME_Unmarshal(in, len, x); -} - -TSS2_RC yaml_internal_TPMU_SIG_SCHEME_marshal(const datum *in, char **out) -{ - assert(in); - assert(out); - assert(sizeof(TPMU_SIG_SCHEME) == in->size); - - const TPMU_SIG_SCHEME *x = (const TPMU_SIG_SCHEME *)in->data; - - return Tss2_MU_YAML_TPMU_SIG_SCHEME_Marshal(x, out); -} - -TSS2_RC yaml_internal_TPMU_SIG_SCHEME_unmarshal(const char *in, size_t len, datum *out) { - - assert(in); - assert(out); - assert(sizeof(TPMU_SIG_SCHEME) == out->size); - - TPMU_SIG_SCHEME *x = (TPMU_SIG_SCHEME *)out->data; - - return Tss2_MU_YAML_TPMU_SIG_SCHEME_Unmarshal(in, len, x); -} - -TSS2_RC yaml_internal_TPM2B_CONTEXT_DATA_marshal(const datum *in, char **out) -{ +TSS2_RC yaml_internal_TPM2_GENERATED_scalar_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPM2B_CONTEXT_DATA) == in->size); - - const TPM2B_CONTEXT_DATA *x = (const TPM2B_CONTEXT_DATA *)in->data; - - return Tss2_MU_YAML_TPM2B_CONTEXT_DATA_Marshal(x, out); -} - -TSS2_RC yaml_internal_TPM2B_CONTEXT_DATA_unmarshal(const char *in, size_t len, datum *out) { + assert(sizeof(TPM2_GENERATED) == in->size); - assert(in); - assert(out); - assert(sizeof(TPM2B_CONTEXT_DATA) == out->size); + const TPM2_GENERATED *d = (const TPM2_GENERATED *)in->data; + TPM2_GENERATED tmp = *d; - TPM2B_CONTEXT_DATA *x = (TPM2B_CONTEXT_DATA *)out->data; + static struct { + TPM2_GENERATED key; + const char *value; + } lookup[] = { + {TPM2_GENERATED_VALUE, "value"} + }; - return Tss2_MU_YAML_TPM2B_CONTEXT_DATA_Unmarshal(in, len, x); -} + // TODO more intelligence on size selection? + char buf[1024] = { 0 }; + char *p = buf; + while(tmp) { + unsigned i; + for (i=0; i < ARRAY_LEN(lookup); i++) { + if (tmp == lookup[i].key) { + /* turns down the bit OR sets to 0 to break the loop */ + tmp &= ~lookup[i].key; + strncat(p, lookup[i].value, sizeof(buf) - 1); + break; + } + } + if (i >= ARRAY_LEN(lookup)) { + return yaml_common_scalar_int32_t_marshal(*d, out); + } + } -TSS2_RC yaml_internal_TPMU_SIGNATURE_marshal(const datum *in, char **out) -{ - assert(in); - assert(out); - assert(sizeof(TPMU_SIGNATURE) == in->size); + if (buf[0] == ',') { + p++; + } - const TPMU_SIGNATURE *x = (const TPMU_SIGNATURE *)in->data; + char *s = strdup(p); + if (!s) { + return TSS2_MU_RC_MEMORY; + } - return Tss2_MU_YAML_TPMU_SIGNATURE_Marshal(x, out); + *out = s; + return TSS2_RC_SUCCESS; } -TSS2_RC yaml_internal_TPMU_SIGNATURE_unmarshal(const char *in, size_t len, datum *out) { - - assert(in); - assert(out); - assert(sizeof(TPMU_SIGNATURE) == out->size); - - TPMU_SIGNATURE *x = (TPMU_SIGNATURE *)out->data; - - return Tss2_MU_YAML_TPMU_SIGNATURE_Unmarshal(in, len, x); -} +TSS2_RC yaml_internal_TPM2_GENERATED_scalar_unmarshal(const char *in, size_t len, datum *out) { -TSS2_RC yaml_internal_uint8_t_scalar_marshal(const datum *in, char **out) -{ assert(in); assert(out); - assert(sizeof(uint8_t) == in->size); - - const uint8_t *x = (const uint8_t *)in->data; - - return yaml_common_scalar_uint8_t_marshal(*x, out); -} + assert(out->size == sizeof(TPM2_GENERATED)); -TSS2_RC yaml_internal_uint8_t_scalar_unmarshal(const char *in, size_t len, datum *out) -{ - assert(in); - return yaml_common_scalar_uint8_t_unmarshal(in, len, (uint8_t *)out->data); -} + // TODO can we plumb this right? + UNUSED(len); -TSS2_RC yaml_internal_TPMU_HA_marshal(const datum *in, char **out) -{ - assert(in); - assert(out); - assert(sizeof(TPMU_HA) == in->size); + char *s = strdup(in); + if (!s) { + return TSS2_MU_RC_MEMORY; + } - const TPMU_HA *x = (const TPMU_HA *)in->data; + char *saveptr = NULL; + char *token = NULL; - return Tss2_MU_YAML_TPMU_HA_Marshal(x, out); -} + TPM2_GENERATED tmp = 0; + TPM2_GENERATED *result = out->data; -TSS2_RC yaml_internal_TPMU_HA_unmarshal(const char *in, size_t len, datum *out) { + yaml_common_to_lower(s); - assert(in); - assert(out); - assert(sizeof(TPMU_HA) == out->size); + static const struct { + const char *key; + TPM2_GENERATED value; + } lookup[] = { + {"tpm2_generated_value", TPM2_GENERATED_VALUE}, + {"value", TPM2_GENERATED_VALUE} + }; - TPMU_HA *x = (TPMU_HA *)out->data; + char *x = s; + while ((token = strtok_r(x, ",", &saveptr))) { + x = NULL; + size_t i; + for(i=0; i < ARRAY_LEN(lookup); i++) { + if (!strcmp(token, lookup[i].key)) { + tmp |= lookup[i].value; + } + } + if (i >= ARRAY_LEN(lookup)) { + free(s); + return yaml_common_scalar_int32_t_unmarshal(in, len, result); + } + } - return Tss2_MU_YAML_TPMU_HA_Unmarshal(in, len, x); + *result = tmp; + free(s); + return TSS2_RC_SUCCESS; } -TSS2_RC yaml_internal_TPMU_SCHEME_KEYEDHASH_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPM2B_DIGEST_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPMU_SCHEME_KEYEDHASH) == in->size); + assert(sizeof(TPM2B_DIGEST) == in->size); - const TPMU_SCHEME_KEYEDHASH *x = (const TPMU_SCHEME_KEYEDHASH *)in->data; + const TPM2B_DIGEST *x = (const TPM2B_DIGEST *)in->data; - return Tss2_MU_YAML_TPMU_SCHEME_KEYEDHASH_Marshal(x, out); + return Tss2_MU_YAML_TPM2B_DIGEST_Marshal(x, out); } -TSS2_RC yaml_internal_TPMU_SCHEME_KEYEDHASH_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPM2B_DIGEST_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPMU_SCHEME_KEYEDHASH) == out->size); + assert(sizeof(TPM2B_DIGEST) == out->size); - TPMU_SCHEME_KEYEDHASH *x = (TPMU_SCHEME_KEYEDHASH *)out->data; + TPM2B_DIGEST *x = (TPM2B_DIGEST *)out->data; - return Tss2_MU_YAML_TPMU_SCHEME_KEYEDHASH_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPM2B_DIGEST_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPM2B_SENSITIVE_DATA_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPML_PCR_SELECTION_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPM2B_SENSITIVE_DATA) == in->size); + assert(sizeof(TPML_PCR_SELECTION) == in->size); - const TPM2B_SENSITIVE_DATA *x = (const TPM2B_SENSITIVE_DATA *)in->data; + const TPML_PCR_SELECTION *x = (const TPML_PCR_SELECTION *)in->data; - return Tss2_MU_YAML_TPM2B_SENSITIVE_DATA_Marshal(x, out); + return Tss2_MU_YAML_TPML_PCR_SELECTION_Marshal(x, out); } -TSS2_RC yaml_internal_TPM2B_SENSITIVE_DATA_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPML_PCR_SELECTION_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPM2B_SENSITIVE_DATA) == out->size); + assert(sizeof(TPML_PCR_SELECTION) == out->size); - TPM2B_SENSITIVE_DATA *x = (TPM2B_SENSITIVE_DATA *)out->data; + TPML_PCR_SELECTION *x = (TPML_PCR_SELECTION *)out->data; - return Tss2_MU_YAML_TPM2B_SENSITIVE_DATA_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPML_PCR_SELECTION_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPM2B_MAX_NV_BUFFER_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPM2B_ECC_PARAMETER_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPM2B_MAX_NV_BUFFER) == in->size); + assert(sizeof(TPM2B_ECC_PARAMETER) == in->size); - const TPM2B_MAX_NV_BUFFER *x = (const TPM2B_MAX_NV_BUFFER *)in->data; + const TPM2B_ECC_PARAMETER *x = (const TPM2B_ECC_PARAMETER *)in->data; - return Tss2_MU_YAML_TPM2B_MAX_NV_BUFFER_Marshal(x, out); + return Tss2_MU_YAML_TPM2B_ECC_PARAMETER_Marshal(x, out); } -TSS2_RC yaml_internal_TPM2B_MAX_NV_BUFFER_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPM2B_ECC_PARAMETER_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPM2B_MAX_NV_BUFFER) == out->size); + assert(sizeof(TPM2B_ECC_PARAMETER) == out->size); - TPM2B_MAX_NV_BUFFER *x = (TPM2B_MAX_NV_BUFFER *)out->data; + TPM2B_ECC_PARAMETER *x = (TPM2B_ECC_PARAMETER *)out->data; - return Tss2_MU_YAML_TPM2B_MAX_NV_BUFFER_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPM2B_ECC_PARAMETER_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPM2B_DIGEST_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPMT_RSA_SCHEME_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPM2B_DIGEST) == in->size); + assert(sizeof(TPMT_RSA_SCHEME) == in->size); - const TPM2B_DIGEST *x = (const TPM2B_DIGEST *)in->data; + const TPMT_RSA_SCHEME *x = (const TPMT_RSA_SCHEME *)in->data; - return Tss2_MU_YAML_TPM2B_DIGEST_Marshal(x, out); + return Tss2_MU_YAML_TPMT_RSA_SCHEME_Marshal(x, out); } -TSS2_RC yaml_internal_TPM2B_DIGEST_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMT_RSA_SCHEME_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPM2B_DIGEST) == out->size); + assert(sizeof(TPMT_RSA_SCHEME) == out->size); - TPM2B_DIGEST *x = (TPM2B_DIGEST *)out->data; + TPMT_RSA_SCHEME *x = (TPMT_RSA_SCHEME *)out->data; - return Tss2_MU_YAML_TPM2B_DIGEST_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPMT_RSA_SCHEME_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPMA_ALGORITHM_scalar_marshal(const datum *in, char **out) { +TSS2_RC yaml_internal_TPMA_SESSION_scalar_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPMA_ALGORITHM) == in->size); + assert(sizeof(TPMA_SESSION) == in->size); - const TPMA_ALGORITHM *d = (const TPMA_ALGORITHM *)in->data; - TPMA_ALGORITHM tmp = *d; + const TPMA_SESSION *d = (const TPMA_SESSION *)in->data; + TPMA_SESSION tmp = *d; static struct { - TPMA_ALGORITHM key; + TPMA_SESSION key; const char *value; } lookup[] = { - {TPMA_ALGORITHM_HASH, "hash"}, - {TPMA_ALGORITHM_OBJECT, "object"}, - {TPMA_ALGORITHM_METHOD, "method"}, - {TPMA_ALGORITHM_SIGNING, "signing"}, - {TPMA_ALGORITHM_SYMMETRIC, "symmetric"}, - {TPMA_ALGORITHM_ASYMMETRIC, "asymmetric"}, - {TPMA_ALGORITHM_ENCRYPTING, "encrypting"} + {TPMA_SESSION_AUDIT, "audit"}, + {TPMA_SESSION_DECRYPT, "decrypt"}, + {TPMA_SESSION_ENCRYPT, "encrypt"}, + {TPMA_SESSION_AUDITRESET, "auditreset"}, + {TPMA_SESSION_AUDITEXCLUSIVE, "auditexclusive"}, + {TPMA_SESSION_CONTINUESESSION, "continuesession"} }; // TODO more intelligence on size selection? @@ -1592,7 +1583,7 @@ TSS2_RC yaml_internal_TPMA_ALGORITHM_scalar_marshal(const datum *in, char **out) } } if (i >= ARRAY_LEN(lookup)) { - return yaml_common_scalar_int32_t_marshal(*d, out); + return yaml_common_scalar_int8_t_marshal(*d, out); } } @@ -1609,11 +1600,11 @@ TSS2_RC yaml_internal_TPMA_ALGORITHM_scalar_marshal(const datum *in, char **out) return TSS2_RC_SUCCESS; } -TSS2_RC yaml_internal_TPMA_ALGORITHM_scalar_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMA_SESSION_scalar_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(out->size == sizeof(TPMA_ALGORITHM)); + assert(out->size == sizeof(TPMA_SESSION)); // TODO can we plumb this right? UNUSED(len); @@ -1626,29 +1617,27 @@ TSS2_RC yaml_internal_TPMA_ALGORITHM_scalar_unmarshal(const char *in, size_t len char *saveptr = NULL; char *token = NULL; - TPMA_ALGORITHM tmp = 0; - TPMA_ALGORITHM *result = out->data; + TPMA_SESSION tmp = 0; + TPMA_SESSION *result = out->data; yaml_common_to_lower(s); static const struct { const char *key; - TPMA_ALGORITHM value; + TPMA_SESSION value; } lookup[] = { - {"tpma_algorithm_asymmetric", TPMA_ALGORITHM_ASYMMETRIC}, - {"asymmetric", TPMA_ALGORITHM_ASYMMETRIC}, - {"tpma_algorithm_symmetric", TPMA_ALGORITHM_SYMMETRIC}, - {"symmetric", TPMA_ALGORITHM_SYMMETRIC}, - {"tpma_algorithm_hash", TPMA_ALGORITHM_HASH}, - {"hash", TPMA_ALGORITHM_HASH}, - {"tpma_algorithm_object", TPMA_ALGORITHM_OBJECT}, - {"object", TPMA_ALGORITHM_OBJECT}, - {"tpma_algorithm_signing", TPMA_ALGORITHM_SIGNING}, - {"signing", TPMA_ALGORITHM_SIGNING}, - {"tpma_algorithm_encrypting", TPMA_ALGORITHM_ENCRYPTING}, - {"encrypting", TPMA_ALGORITHM_ENCRYPTING}, - {"tpma_algorithm_method", TPMA_ALGORITHM_METHOD}, - {"method", TPMA_ALGORITHM_METHOD} + {"tpma_session_continuesession", TPMA_SESSION_CONTINUESESSION}, + {"continuesession", TPMA_SESSION_CONTINUESESSION}, + {"tpma_session_auditexclusive", TPMA_SESSION_AUDITEXCLUSIVE}, + {"auditexclusive", TPMA_SESSION_AUDITEXCLUSIVE}, + {"tpma_session_auditreset", TPMA_SESSION_AUDITRESET}, + {"auditreset", TPMA_SESSION_AUDITRESET}, + {"tpma_session_decrypt", TPMA_SESSION_DECRYPT}, + {"decrypt", TPMA_SESSION_DECRYPT}, + {"tpma_session_encrypt", TPMA_SESSION_ENCRYPT}, + {"encrypt", TPMA_SESSION_ENCRYPT}, + {"tpma_session_audit", TPMA_SESSION_AUDIT}, + {"audit", TPMA_SESSION_AUDIT} }; char *x = s; @@ -1658,12 +1647,11 @@ TSS2_RC yaml_internal_TPMA_ALGORITHM_scalar_unmarshal(const char *in, size_t len for(i=0; i < ARRAY_LEN(lookup); i++) { if (!strcmp(token, lookup[i].key)) { tmp |= lookup[i].value; - break; } } if (i >= ARRAY_LEN(lookup)) { free(s); - return yaml_common_scalar_int32_t_unmarshal(in, len, result); + return yaml_common_scalar_int8_t_unmarshal(in, len, result); } } @@ -1672,26 +1660,43 @@ TSS2_RC yaml_internal_TPMA_ALGORITHM_scalar_unmarshal(const char *in, size_t len return TSS2_RC_SUCCESS; } -TSS2_RC yaml_internal_TPMT_KDF_SCHEME_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPMU_PUBLIC_ID_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPMT_KDF_SCHEME) == in->size); + assert(sizeof(TPMU_PUBLIC_ID) == in->size); - const TPMT_KDF_SCHEME *x = (const TPMT_KDF_SCHEME *)in->data; + const TPMU_PUBLIC_ID *x = (const TPMU_PUBLIC_ID *)in->data; - return Tss2_MU_YAML_TPMT_KDF_SCHEME_Marshal(x, out); + return Tss2_MU_YAML_TPMU_PUBLIC_ID_Marshal(x, out); } -TSS2_RC yaml_internal_TPMT_KDF_SCHEME_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMU_PUBLIC_ID_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPMT_KDF_SCHEME) == out->size); + assert(sizeof(TPMU_PUBLIC_ID) == out->size); - TPMT_KDF_SCHEME *x = (TPMT_KDF_SCHEME *)out->data; + TPMU_PUBLIC_ID *x = (TPMU_PUBLIC_ID *)out->data; - return Tss2_MU_YAML_TPMT_KDF_SCHEME_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPMU_PUBLIC_ID_Unmarshal(in, len, x); +} + +TSS2_RC yaml_internal_uint32_t_scalar_marshal(const datum *in, char **out) +{ + assert(in); + assert(out); + assert(sizeof(uint32_t) == in->size); + + const uint32_t *x = (const uint32_t *)in->data; + + return yaml_common_scalar_uint32_t_marshal(*x, out); +} + +TSS2_RC yaml_internal_uint32_t_scalar_unmarshal(const char *in, size_t len, datum *out) +{ + assert(in); + return yaml_common_scalar_uint32_t_unmarshal(in, len, (uint32_t *)out->data); } TSS2_RC yaml_internal_TPMU_ATTEST_marshal(const datum *in, char **out) @@ -1716,80 +1721,68 @@ TSS2_RC yaml_internal_TPMU_ATTEST_unmarshal(const char *in, size_t len, datum *o return Tss2_MU_YAML_TPMU_ATTEST_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_uint16_t_scalar_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPMU_ASYM_SCHEME_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(uint16_t) == in->size); + assert(sizeof(TPMU_ASYM_SCHEME) == in->size); - const uint16_t *x = (const uint16_t *)in->data; + const TPMU_ASYM_SCHEME *x = (const TPMU_ASYM_SCHEME *)in->data; - return yaml_common_scalar_uint16_t_marshal(*x, out); + return Tss2_MU_YAML_TPMU_ASYM_SCHEME_Marshal(x, out); } -TSS2_RC yaml_internal_uint16_t_scalar_unmarshal(const char *in, size_t len, datum *out) -{ - assert(in); - return yaml_common_scalar_uint16_t_unmarshal(in, len, (uint16_t *)out->data); -} +TSS2_RC yaml_internal_TPMU_ASYM_SCHEME_unmarshal(const char *in, size_t len, datum *out) { -TSS2_RC yaml_internal_uint32_t_scalar_marshal(const datum *in, char **out) -{ assert(in); assert(out); - assert(sizeof(uint32_t) == in->size); - - const uint32_t *x = (const uint32_t *)in->data; + assert(sizeof(TPMU_ASYM_SCHEME) == out->size); - return yaml_common_scalar_uint32_t_marshal(*x, out); -} + TPMU_ASYM_SCHEME *x = (TPMU_ASYM_SCHEME *)out->data; -TSS2_RC yaml_internal_uint32_t_scalar_unmarshal(const char *in, size_t len, datum *out) -{ - assert(in); - return yaml_common_scalar_uint32_t_unmarshal(in, len, (uint32_t *)out->data); + return Tss2_MU_YAML_TPMU_ASYM_SCHEME_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPM2B_PUBLIC_KEY_RSA_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPMT_KEYEDHASH_SCHEME_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPM2B_PUBLIC_KEY_RSA) == in->size); + assert(sizeof(TPMT_KEYEDHASH_SCHEME) == in->size); - const TPM2B_PUBLIC_KEY_RSA *x = (const TPM2B_PUBLIC_KEY_RSA *)in->data; + const TPMT_KEYEDHASH_SCHEME *x = (const TPMT_KEYEDHASH_SCHEME *)in->data; - return Tss2_MU_YAML_TPM2B_PUBLIC_KEY_RSA_Marshal(x, out); + return Tss2_MU_YAML_TPMT_KEYEDHASH_SCHEME_Marshal(x, out); } -TSS2_RC yaml_internal_TPM2B_PUBLIC_KEY_RSA_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMT_KEYEDHASH_SCHEME_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPM2B_PUBLIC_KEY_RSA) == out->size); + assert(sizeof(TPMT_KEYEDHASH_SCHEME) == out->size); - TPM2B_PUBLIC_KEY_RSA *x = (TPM2B_PUBLIC_KEY_RSA *)out->data; + TPMT_KEYEDHASH_SCHEME *x = (TPMT_KEYEDHASH_SCHEME *)out->data; - return Tss2_MU_YAML_TPM2B_PUBLIC_KEY_RSA_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPMT_KEYEDHASH_SCHEME_Unmarshal(in, len, x); } -TSS2_RC yaml_internal_TPMT_RSA_SCHEME_marshal(const datum *in, char **out) +TSS2_RC yaml_internal_TPMU_HA_marshal(const datum *in, char **out) { assert(in); assert(out); - assert(sizeof(TPMT_RSA_SCHEME) == in->size); + assert(sizeof(TPMU_HA) == in->size); - const TPMT_RSA_SCHEME *x = (const TPMT_RSA_SCHEME *)in->data; + const TPMU_HA *x = (const TPMU_HA *)in->data; - return Tss2_MU_YAML_TPMT_RSA_SCHEME_Marshal(x, out); + return Tss2_MU_YAML_TPMU_HA_Marshal(x, out); } -TSS2_RC yaml_internal_TPMT_RSA_SCHEME_unmarshal(const char *in, size_t len, datum *out) { +TSS2_RC yaml_internal_TPMU_HA_unmarshal(const char *in, size_t len, datum *out) { assert(in); assert(out); - assert(sizeof(TPMT_RSA_SCHEME) == out->size); + assert(sizeof(TPMU_HA) == out->size); - TPMT_RSA_SCHEME *x = (TPMT_RSA_SCHEME *)out->data; + TPMU_HA *x = (TPMU_HA *)out->data; - return Tss2_MU_YAML_TPMT_RSA_SCHEME_Unmarshal(in, len, x); + return Tss2_MU_YAML_TPMU_HA_Unmarshal(in, len, x); } diff --git a/src/tss2-mu-yaml/yaml-internal.h b/src/tss2-mu-yaml/yaml-internal.h index 48eb8f5d8..339bee5b6 100644 --- a/src/tss2-mu-yaml/yaml-internal.h +++ b/src/tss2-mu-yaml/yaml-internal.h @@ -6,142 +6,142 @@ /* forward declare to break cyclic dependency on yaml-common.h */ typedef struct datum datum; -TSS2_RC yaml_internal_TPMA_SESSION_scalar_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMA_SESSION_scalar_unmarshal(const char *in, size_t len, datum *out); - TSS2_RC yaml_internal_TPM2_PT_PCR_scalar_marshal(const datum *in, char **out); TSS2_RC yaml_internal_TPM2_PT_PCR_scalar_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPM2B_AUTH_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPM2B_AUTH_unmarshal(const char *in, size_t len, datum *out); - -TSS2_RC yaml_internal_TPMT_SYM_DEF_OBJECT_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMT_SYM_DEF_OBJECT_unmarshal(const char *in, size_t len, datum *out); - -TSS2_RC yaml_internal_TPMU_PUBLIC_ID_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMU_PUBLIC_ID_unmarshal(const char *in, size_t len, datum *out); - -TSS2_RC yaml_internal_TPMT_ECC_SCHEME_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMT_ECC_SCHEME_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMA_ALGORITHM_scalar_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMA_ALGORITHM_scalar_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPM2B_CONTEXT_SENSITIVE_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPM2B_CONTEXT_SENSITIVE_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPM2B_MAX_NV_BUFFER_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPM2B_MAX_NV_BUFFER_unmarshal(const char *in, size_t len, datum *out); TSS2_RC yaml_internal_TPMS_TIME_INFO_marshal(const datum *in, char **out); TSS2_RC yaml_internal_TPMS_TIME_INFO_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMT_HA_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMT_HA_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMT_KDF_SCHEME_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMT_KDF_SCHEME_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_uint64_t_scalar_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_uint64_t_scalar_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPM2B_CONTEXT_DATA_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPM2B_CONTEXT_DATA_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMU_SYM_MODE_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMU_SYM_MODE_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMU_SENSITIVE_COMPOSITE_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMU_SENSITIVE_COMPOSITE_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMA_LOCALITY_scalar_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMA_LOCALITY_scalar_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMU_SIGNATURE_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMU_SIGNATURE_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMU_SYM_KEY_BITS_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMU_SYM_KEY_BITS_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMU_KDF_SCHEME_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMU_KDF_SCHEME_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMU_PUBLIC_PARMS_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMU_PUBLIC_PARMS_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMU_SIG_SCHEME_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMU_SIG_SCHEME_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMT_KEYEDHASH_SCHEME_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMT_KEYEDHASH_SCHEME_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_uint16_t_scalar_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_uint16_t_scalar_unmarshal(const char *in, size_t len, datum *out); + +TSS2_RC yaml_internal_TPMU_SCHEME_KEYEDHASH_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMU_SCHEME_KEYEDHASH_unmarshal(const char *in, size_t len, datum *out); TSS2_RC yaml_internal_TPM2_ALG_ID_scalar_marshal(const datum *in, char **out); TSS2_RC yaml_internal_TPM2_ALG_ID_scalar_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPML_PCR_SELECTION_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPML_PCR_SELECTION_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPM2B_DATA_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPM2B_DATA_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMA_OBJECT_scalar_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMA_OBJECT_scalar_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMU_SYM_MODE_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMU_SYM_MODE_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMU_CAPABILITIES_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMU_CAPABILITIES_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPM2B_NONCE_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPM2B_NONCE_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMT_ASYM_SCHEME_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMT_ASYM_SCHEME_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPM2B_AUTH_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPM2B_AUTH_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPM2B_DATA_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPM2B_DATA_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMU_CAPABILITIES_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMU_CAPABILITIES_unmarshal(const char *in, size_t len, datum *out); TSS2_RC yaml_internal_TPM2B_LABEL_marshal(const datum *in, char **out); TSS2_RC yaml_internal_TPM2B_LABEL_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMU_SENSITIVE_COMPOSITE_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMU_SENSITIVE_COMPOSITE_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPM2B_CONTEXT_SENSITIVE_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPM2B_CONTEXT_SENSITIVE_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMU_ASYM_SCHEME_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMU_ASYM_SCHEME_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPM2B_PUBLIC_KEY_RSA_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPM2B_PUBLIC_KEY_RSA_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPM2B_ECC_PARAMETER_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPM2B_ECC_PARAMETER_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPM2B_SENSITIVE_DATA_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPM2B_SENSITIVE_DATA_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMU_KDF_SCHEME_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMU_KDF_SCHEME_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPM2B_NAME_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPM2B_NAME_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPM2B_NONCE_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPM2B_NONCE_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMT_ASYM_SCHEME_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMT_ASYM_SCHEME_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMS_CLOCK_INFO_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMS_CLOCK_INFO_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMU_PUBLIC_PARMS_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMU_PUBLIC_PARMS_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPM2_GENERATED_scalar_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPM2_GENERATED_scalar_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_uint8_t_scalar_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_uint8_t_scalar_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPM2B_NAME_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPM2B_NAME_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMT_SYM_DEF_OBJECT_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMT_SYM_DEF_OBJECT_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMU_SIG_SCHEME_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMU_SIG_SCHEME_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMT_HA_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMT_HA_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPM2B_CONTEXT_DATA_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPM2B_CONTEXT_DATA_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMA_OBJECT_scalar_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMA_OBJECT_scalar_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMU_SIGNATURE_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMU_SIGNATURE_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMU_SYM_KEY_BITS_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMU_SYM_KEY_BITS_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_uint8_t_scalar_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_uint8_t_scalar_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMS_CLOCK_INFO_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMS_CLOCK_INFO_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMU_HA_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMU_HA_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_uint64_t_scalar_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_uint64_t_scalar_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMU_SCHEME_KEYEDHASH_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMU_SCHEME_KEYEDHASH_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMT_ECC_SCHEME_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMT_ECC_SCHEME_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPM2B_SENSITIVE_DATA_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPM2B_SENSITIVE_DATA_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMA_LOCALITY_scalar_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMA_LOCALITY_scalar_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPM2B_MAX_NV_BUFFER_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPM2B_MAX_NV_BUFFER_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPM2_GENERATED_scalar_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPM2_GENERATED_scalar_unmarshal(const char *in, size_t len, datum *out); TSS2_RC yaml_internal_TPM2B_DIGEST_marshal(const datum *in, char **out); TSS2_RC yaml_internal_TPM2B_DIGEST_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMA_ALGORITHM_scalar_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMA_ALGORITHM_scalar_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPML_PCR_SELECTION_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPML_PCR_SELECTION_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMT_KDF_SCHEME_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMT_KDF_SCHEME_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPM2B_ECC_PARAMETER_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPM2B_ECC_PARAMETER_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMU_ATTEST_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMU_ATTEST_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMT_RSA_SCHEME_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMT_RSA_SCHEME_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_uint16_t_scalar_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_uint16_t_scalar_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMA_SESSION_scalar_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMA_SESSION_scalar_unmarshal(const char *in, size_t len, datum *out); + +TSS2_RC yaml_internal_TPMU_PUBLIC_ID_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMU_PUBLIC_ID_unmarshal(const char *in, size_t len, datum *out); TSS2_RC yaml_internal_uint32_t_scalar_marshal(const datum *in, char **out); TSS2_RC yaml_internal_uint32_t_scalar_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPM2B_PUBLIC_KEY_RSA_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPM2B_PUBLIC_KEY_RSA_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMU_ATTEST_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMU_ATTEST_unmarshal(const char *in, size_t len, datum *out); -TSS2_RC yaml_internal_TPMT_RSA_SCHEME_marshal(const datum *in, char **out); -TSS2_RC yaml_internal_TPMT_RSA_SCHEME_unmarshal(const char *in, size_t len, datum *out); +TSS2_RC yaml_internal_TPMU_ASYM_SCHEME_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMU_ASYM_SCHEME_unmarshal(const char *in, size_t len, datum *out); + +TSS2_RC yaml_internal_TPMT_KEYEDHASH_SCHEME_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMT_KEYEDHASH_SCHEME_unmarshal(const char *in, size_t len, datum *out); + +TSS2_RC yaml_internal_TPMU_HA_marshal(const datum *in, char **out); +TSS2_RC yaml_internal_TPMU_HA_unmarshal(const char *in, size_t len, datum *out); #endif /* SRC_TSS2_MU_YAML_YAML_SCALAR_H_ */ diff --git a/src/tss2-mu-yaml/yaml-tpms.c b/src/tss2-mu-yaml/yaml-tpms.c index 15abc515e..c2616f6ca 100644 --- a/src/tss2-mu-yaml/yaml-tpms.c +++ b/src/tss2-mu-yaml/yaml-tpms.c @@ -552,8 +552,7 @@ Tss2_MU_YAML_TPMS_CAPABILITY_DATA_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("capability", 0, NULL, NULL), - KVP_ADD_MARSHAL("data", sizeof(src->data), &src->data, yaml_internal_TPMU_CAPABILITIES_marshal) + KVPU_ADD_MARSHAL("data", sizeof(src->capability), &src->capability, yaml_internal_TPMU_CAPABILITIES_scalar_marshal, sizeof(src->data), &src->data, yaml_internal_TPMU_CAPABILITIES_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -581,8 +580,7 @@ Tss2_MU_YAML_TPMS_CAPABILITY_DATA_Unmarshal( TPMS_CAPABILITY_DATA tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("capability", 0, NULL, NULL), - KVP_ADD_UNMARSHAL("data", sizeof(tmp_dest.data), &tmp_dest.data, yaml_internal_TPMU_CAPABILITIES_unmarshal) + KVPU_ADD_UNMARSHAL("data", sizeof(tmp_dest.capability), &tmp_dest.capability, yaml_internal_TPMU_CAPABILITIES_scalar_unmarshal, sizeof(tmp_dest.data), &tmp_dest.data, yaml_internal_TPMU_CAPABILITIES_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); @@ -1278,12 +1276,11 @@ Tss2_MU_YAML_TPMS_ATTEST_Marshal( struct key_value kvs[] = { KVP_ADD_MARSHAL("magic", sizeof(src->magic), &src->magic, yaml_internal_TPM2_GENERATED_scalar_marshal), - KVP_ADD_MARSHAL("type", sizeof(src->type), &src->type, yaml_internal_uint16_t_scalar_marshal), KVP_ADD_MARSHAL("qualifiedSigner", sizeof(src->qualifiedSigner), &src->qualifiedSigner, yaml_internal_TPM2B_NAME_marshal), KVP_ADD_MARSHAL("extraData", sizeof(src->extraData), &src->extraData, yaml_internal_TPM2B_DATA_marshal), KVP_ADD_MARSHAL("clockInfo", sizeof(src->clockInfo), &src->clockInfo, yaml_internal_TPMS_CLOCK_INFO_marshal), KVP_ADD_MARSHAL("firmwareVersion", sizeof(src->firmwareVersion), &src->firmwareVersion, yaml_internal_uint64_t_scalar_marshal), - KVP_ADD_MARSHAL("attested", sizeof(src->attested), &src->attested, yaml_internal_TPMU_ATTEST_marshal) + KVPU_ADD_MARSHAL("attested", sizeof(src->type), &src->type, yaml_internal_TPMU_ATTEST_scalar_marshal, sizeof(src->attested), &src->attested, yaml_internal_TPMU_ATTEST_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -1312,12 +1309,11 @@ Tss2_MU_YAML_TPMS_ATTEST_Unmarshal( key_value parsed_data[] = { KVP_ADD_UNMARSHAL("magic", sizeof(tmp_dest.magic), &tmp_dest.magic, yaml_internal_TPM2_GENERATED_scalar_unmarshal), - KVP_ADD_UNMARSHAL("type", sizeof(tmp_dest.type), &tmp_dest.type, yaml_internal_uint16_t_scalar_unmarshal), KVP_ADD_UNMARSHAL("qualifiedSigner", sizeof(tmp_dest.qualifiedSigner), &tmp_dest.qualifiedSigner, yaml_internal_TPM2B_NAME_unmarshal), KVP_ADD_UNMARSHAL("extraData", sizeof(tmp_dest.extraData), &tmp_dest.extraData, yaml_internal_TPM2B_DATA_unmarshal), KVP_ADD_UNMARSHAL("clockInfo", sizeof(tmp_dest.clockInfo), &tmp_dest.clockInfo, yaml_internal_TPMS_CLOCK_INFO_unmarshal), KVP_ADD_UNMARSHAL("firmwareVersion", sizeof(tmp_dest.firmwareVersion), &tmp_dest.firmwareVersion, yaml_internal_uint64_t_scalar_unmarshal), - KVP_ADD_UNMARSHAL("attested", sizeof(tmp_dest.attested), &tmp_dest.attested, yaml_internal_TPMU_ATTEST_unmarshal) + KVPU_ADD_UNMARSHAL("attested", sizeof(tmp_dest.type), &tmp_dest.type, yaml_internal_TPMU_ATTEST_scalar_unmarshal, sizeof(tmp_dest.attested), &tmp_dest.attested, yaml_internal_TPMU_ATTEST_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); diff --git a/src/tss2-mu-yaml/yaml-tpmt.c b/src/tss2-mu-yaml/yaml-tpmt.c index 5ac5b88e3..2e6254967 100644 --- a/src/tss2-mu-yaml/yaml-tpmt.c +++ b/src/tss2-mu-yaml/yaml-tpmt.c @@ -28,8 +28,7 @@ Tss2_MU_YAML_TPMT_HA_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("hashAlg", 0, NULL, NULL), - KVP_ADD_MARSHAL("digest", sizeof(src->digest), &src->digest, yaml_internal_TPMU_HA_marshal) + KVPU_ADD_MARSHAL("digest", sizeof(src->hashAlg), &src->hashAlg, yaml_internal_TPMU_HA_scalar_marshal, sizeof(src->digest), &src->digest, yaml_internal_TPMU_HA_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -57,8 +56,7 @@ Tss2_MU_YAML_TPMT_HA_Unmarshal( TPMT_HA tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("hashAlg", 0, NULL, NULL), - KVP_ADD_UNMARSHAL("digest", sizeof(tmp_dest.digest), &tmp_dest.digest, yaml_internal_TPMU_HA_unmarshal) + KVPU_ADD_UNMARSHAL("digest", sizeof(tmp_dest.hashAlg), &tmp_dest.hashAlg, yaml_internal_TPMU_HA_scalar_unmarshal, sizeof(tmp_dest.digest), &tmp_dest.digest, yaml_internal_TPMU_HA_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); @@ -361,9 +359,8 @@ Tss2_MU_YAML_TPMT_SYM_DEF_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("algorithm", 0, NULL, NULL), - KVP_ADD_MARSHAL("keyBits", sizeof(src->keyBits), &src->keyBits, yaml_internal_TPMU_SYM_KEY_BITS_marshal), - KVP_ADD_MARSHAL("mode", sizeof(src->mode), &src->mode, yaml_internal_TPMU_SYM_MODE_marshal) + KVPU_ADD_MARSHAL("keyBits", sizeof(src->algorithm), &src->algorithm, yaml_internal_TPMU_SYM_KEY_BITS_scalar_marshal, sizeof(src->keyBits), &src->keyBits, yaml_internal_TPMU_SYM_KEY_BITS_marshal), + KVPU_ADD_MARSHAL("mode", sizeof(src->algorithm), &src->algorithm, yaml_internal_TPMU_SYM_MODE_scalar_marshal, sizeof(src->mode), &src->mode, yaml_internal_TPMU_SYM_MODE_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -391,9 +388,8 @@ Tss2_MU_YAML_TPMT_SYM_DEF_Unmarshal( TPMT_SYM_DEF tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("algorithm", 0, NULL, NULL), - KVP_ADD_UNMARSHAL("keyBits", sizeof(tmp_dest.keyBits), &tmp_dest.keyBits, yaml_internal_TPMU_SYM_KEY_BITS_unmarshal), - KVP_ADD_UNMARSHAL("mode", sizeof(tmp_dest.mode), &tmp_dest.mode, yaml_internal_TPMU_SYM_MODE_unmarshal) + KVPU_ADD_UNMARSHAL("keyBits", sizeof(tmp_dest.algorithm), &tmp_dest.algorithm, yaml_internal_TPMU_SYM_KEY_BITS_scalar_unmarshal, sizeof(tmp_dest.keyBits), &tmp_dest.keyBits, yaml_internal_TPMU_SYM_KEY_BITS_unmarshal), + KVPU_ADD_UNMARSHAL("mode", sizeof(tmp_dest.algorithm), &tmp_dest.algorithm, yaml_internal_TPMU_SYM_MODE_scalar_unmarshal, sizeof(tmp_dest.mode), &tmp_dest.mode, yaml_internal_TPMU_SYM_MODE_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); @@ -428,9 +424,8 @@ Tss2_MU_YAML_TPMT_SYM_DEF_OBJECT_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("algorithm", 0, NULL, NULL), - KVP_ADD_MARSHAL("keyBits", sizeof(src->keyBits), &src->keyBits, yaml_internal_TPMU_SYM_KEY_BITS_marshal), - KVP_ADD_MARSHAL("mode", sizeof(src->mode), &src->mode, yaml_internal_TPMU_SYM_MODE_marshal) + KVPU_ADD_MARSHAL("keyBits", sizeof(src->algorithm), &src->algorithm, yaml_internal_TPMU_SYM_KEY_BITS_scalar_marshal, sizeof(src->keyBits), &src->keyBits, yaml_internal_TPMU_SYM_KEY_BITS_marshal), + KVPU_ADD_MARSHAL("mode", sizeof(src->algorithm), &src->algorithm, yaml_internal_TPMU_SYM_MODE_scalar_marshal, sizeof(src->mode), &src->mode, yaml_internal_TPMU_SYM_MODE_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -458,9 +453,8 @@ Tss2_MU_YAML_TPMT_SYM_DEF_OBJECT_Unmarshal( TPMT_SYM_DEF_OBJECT tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("algorithm", 0, NULL, NULL), - KVP_ADD_UNMARSHAL("keyBits", sizeof(tmp_dest.keyBits), &tmp_dest.keyBits, yaml_internal_TPMU_SYM_KEY_BITS_unmarshal), - KVP_ADD_UNMARSHAL("mode", sizeof(tmp_dest.mode), &tmp_dest.mode, yaml_internal_TPMU_SYM_MODE_unmarshal) + KVPU_ADD_UNMARSHAL("keyBits", sizeof(tmp_dest.algorithm), &tmp_dest.algorithm, yaml_internal_TPMU_SYM_KEY_BITS_scalar_unmarshal, sizeof(tmp_dest.keyBits), &tmp_dest.keyBits, yaml_internal_TPMU_SYM_KEY_BITS_unmarshal), + KVPU_ADD_UNMARSHAL("mode", sizeof(tmp_dest.algorithm), &tmp_dest.algorithm, yaml_internal_TPMU_SYM_MODE_scalar_unmarshal, sizeof(tmp_dest.mode), &tmp_dest.mode, yaml_internal_TPMU_SYM_MODE_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); @@ -495,8 +489,7 @@ Tss2_MU_YAML_TPMT_KEYEDHASH_SCHEME_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("scheme", 0, NULL, NULL), - KVP_ADD_MARSHAL("details", sizeof(src->details), &src->details, yaml_internal_TPMU_SCHEME_KEYEDHASH_marshal) + KVPU_ADD_MARSHAL("details", sizeof(src->scheme), &src->scheme, yaml_internal_TPMU_SCHEME_KEYEDHASH_scalar_marshal, sizeof(src->details), &src->details, yaml_internal_TPMU_SCHEME_KEYEDHASH_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -524,8 +517,7 @@ Tss2_MU_YAML_TPMT_KEYEDHASH_SCHEME_Unmarshal( TPMT_KEYEDHASH_SCHEME tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("scheme", 0, NULL, NULL), - KVP_ADD_UNMARSHAL("details", sizeof(tmp_dest.details), &tmp_dest.details, yaml_internal_TPMU_SCHEME_KEYEDHASH_unmarshal) + KVPU_ADD_UNMARSHAL("details", sizeof(tmp_dest.scheme), &tmp_dest.scheme, yaml_internal_TPMU_SCHEME_KEYEDHASH_scalar_unmarshal, sizeof(tmp_dest.details), &tmp_dest.details, yaml_internal_TPMU_SCHEME_KEYEDHASH_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); @@ -560,8 +552,7 @@ Tss2_MU_YAML_TPMT_SIG_SCHEME_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("scheme", 0, NULL, NULL), - KVP_ADD_MARSHAL("details", sizeof(src->details), &src->details, yaml_internal_TPMU_SIG_SCHEME_marshal) + KVPU_ADD_MARSHAL("details", sizeof(src->scheme), &src->scheme, yaml_internal_TPMU_SIG_SCHEME_scalar_marshal, sizeof(src->details), &src->details, yaml_internal_TPMU_SIG_SCHEME_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -589,8 +580,7 @@ Tss2_MU_YAML_TPMT_SIG_SCHEME_Unmarshal( TPMT_SIG_SCHEME tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("scheme", 0, NULL, NULL), - KVP_ADD_UNMARSHAL("details", sizeof(tmp_dest.details), &tmp_dest.details, yaml_internal_TPMU_SIG_SCHEME_unmarshal) + KVPU_ADD_UNMARSHAL("details", sizeof(tmp_dest.scheme), &tmp_dest.scheme, yaml_internal_TPMU_SIG_SCHEME_scalar_unmarshal, sizeof(tmp_dest.details), &tmp_dest.details, yaml_internal_TPMU_SIG_SCHEME_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); @@ -625,8 +615,7 @@ Tss2_MU_YAML_TPMT_KDF_SCHEME_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("scheme", 0, NULL, NULL), - KVP_ADD_MARSHAL("details", sizeof(src->details), &src->details, yaml_internal_TPMU_KDF_SCHEME_marshal) + KVPU_ADD_MARSHAL("details", sizeof(src->scheme), &src->scheme, yaml_internal_TPMU_KDF_SCHEME_scalar_marshal, sizeof(src->details), &src->details, yaml_internal_TPMU_KDF_SCHEME_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -654,8 +643,7 @@ Tss2_MU_YAML_TPMT_KDF_SCHEME_Unmarshal( TPMT_KDF_SCHEME tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("scheme", 0, NULL, NULL), - KVP_ADD_UNMARSHAL("details", sizeof(tmp_dest.details), &tmp_dest.details, yaml_internal_TPMU_KDF_SCHEME_unmarshal) + KVPU_ADD_UNMARSHAL("details", sizeof(tmp_dest.scheme), &tmp_dest.scheme, yaml_internal_TPMU_KDF_SCHEME_scalar_unmarshal, sizeof(tmp_dest.details), &tmp_dest.details, yaml_internal_TPMU_KDF_SCHEME_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); @@ -690,8 +678,7 @@ Tss2_MU_YAML_TPMT_ASYM_SCHEME_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("scheme", 0, NULL, NULL), - KVP_ADD_MARSHAL("details", sizeof(src->details), &src->details, yaml_internal_TPMU_ASYM_SCHEME_marshal) + KVPU_ADD_MARSHAL("details", sizeof(src->scheme), &src->scheme, yaml_internal_TPMU_ASYM_SCHEME_scalar_marshal, sizeof(src->details), &src->details, yaml_internal_TPMU_ASYM_SCHEME_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -719,8 +706,7 @@ Tss2_MU_YAML_TPMT_ASYM_SCHEME_Unmarshal( TPMT_ASYM_SCHEME tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("scheme", 0, NULL, NULL), - KVP_ADD_UNMARSHAL("details", sizeof(tmp_dest.details), &tmp_dest.details, yaml_internal_TPMU_ASYM_SCHEME_unmarshal) + KVPU_ADD_UNMARSHAL("details", sizeof(tmp_dest.scheme), &tmp_dest.scheme, yaml_internal_TPMU_ASYM_SCHEME_scalar_unmarshal, sizeof(tmp_dest.details), &tmp_dest.details, yaml_internal_TPMU_ASYM_SCHEME_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); @@ -755,8 +741,7 @@ Tss2_MU_YAML_TPMT_RSA_SCHEME_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("scheme", 0, NULL, NULL), - KVP_ADD_MARSHAL("details", sizeof(src->details), &src->details, yaml_internal_TPMU_ASYM_SCHEME_marshal) + KVPU_ADD_MARSHAL("details", sizeof(src->scheme), &src->scheme, yaml_internal_TPMU_ASYM_SCHEME_scalar_marshal, sizeof(src->details), &src->details, yaml_internal_TPMU_ASYM_SCHEME_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -784,8 +769,7 @@ Tss2_MU_YAML_TPMT_RSA_SCHEME_Unmarshal( TPMT_RSA_SCHEME tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("scheme", 0, NULL, NULL), - KVP_ADD_UNMARSHAL("details", sizeof(tmp_dest.details), &tmp_dest.details, yaml_internal_TPMU_ASYM_SCHEME_unmarshal) + KVPU_ADD_UNMARSHAL("details", sizeof(tmp_dest.scheme), &tmp_dest.scheme, yaml_internal_TPMU_ASYM_SCHEME_scalar_unmarshal, sizeof(tmp_dest.details), &tmp_dest.details, yaml_internal_TPMU_ASYM_SCHEME_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); @@ -820,8 +804,7 @@ Tss2_MU_YAML_TPMT_RSA_DECRYPT_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("scheme", 0, NULL, NULL), - KVP_ADD_MARSHAL("details", sizeof(src->details), &src->details, yaml_internal_TPMU_ASYM_SCHEME_marshal) + KVPU_ADD_MARSHAL("details", sizeof(src->scheme), &src->scheme, yaml_internal_TPMU_ASYM_SCHEME_scalar_marshal, sizeof(src->details), &src->details, yaml_internal_TPMU_ASYM_SCHEME_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -849,8 +832,7 @@ Tss2_MU_YAML_TPMT_RSA_DECRYPT_Unmarshal( TPMT_RSA_DECRYPT tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("scheme", 0, NULL, NULL), - KVP_ADD_UNMARSHAL("details", sizeof(tmp_dest.details), &tmp_dest.details, yaml_internal_TPMU_ASYM_SCHEME_unmarshal) + KVPU_ADD_UNMARSHAL("details", sizeof(tmp_dest.scheme), &tmp_dest.scheme, yaml_internal_TPMU_ASYM_SCHEME_scalar_unmarshal, sizeof(tmp_dest.details), &tmp_dest.details, yaml_internal_TPMU_ASYM_SCHEME_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); @@ -885,8 +867,7 @@ Tss2_MU_YAML_TPMT_ECC_SCHEME_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("scheme", 0, NULL, NULL), - KVP_ADD_MARSHAL("details", sizeof(src->details), &src->details, yaml_internal_TPMU_ASYM_SCHEME_marshal) + KVPU_ADD_MARSHAL("details", sizeof(src->scheme), &src->scheme, yaml_internal_TPMU_ASYM_SCHEME_scalar_marshal, sizeof(src->details), &src->details, yaml_internal_TPMU_ASYM_SCHEME_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -914,8 +895,7 @@ Tss2_MU_YAML_TPMT_ECC_SCHEME_Unmarshal( TPMT_ECC_SCHEME tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("scheme", 0, NULL, NULL), - KVP_ADD_UNMARSHAL("details", sizeof(tmp_dest.details), &tmp_dest.details, yaml_internal_TPMU_ASYM_SCHEME_unmarshal) + KVPU_ADD_UNMARSHAL("details", sizeof(tmp_dest.scheme), &tmp_dest.scheme, yaml_internal_TPMU_ASYM_SCHEME_scalar_unmarshal, sizeof(tmp_dest.details), &tmp_dest.details, yaml_internal_TPMU_ASYM_SCHEME_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); @@ -950,8 +930,7 @@ Tss2_MU_YAML_TPMT_SIGNATURE_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("sigAlg", 0, NULL, NULL), - KVP_ADD_MARSHAL("signature", sizeof(src->signature), &src->signature, yaml_internal_TPMU_SIGNATURE_marshal) + KVPU_ADD_MARSHAL("signature", sizeof(src->sigAlg), &src->sigAlg, yaml_internal_TPMU_SIGNATURE_scalar_marshal, sizeof(src->signature), &src->signature, yaml_internal_TPMU_SIGNATURE_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -979,8 +958,7 @@ Tss2_MU_YAML_TPMT_SIGNATURE_Unmarshal( TPMT_SIGNATURE tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("sigAlg", 0, NULL, NULL), - KVP_ADD_UNMARSHAL("signature", sizeof(tmp_dest.signature), &tmp_dest.signature, yaml_internal_TPMU_SIGNATURE_unmarshal) + KVPU_ADD_UNMARSHAL("signature", sizeof(tmp_dest.sigAlg), &tmp_dest.sigAlg, yaml_internal_TPMU_SIGNATURE_scalar_unmarshal, sizeof(tmp_dest.signature), &tmp_dest.signature, yaml_internal_TPMU_SIGNATURE_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); @@ -1015,8 +993,7 @@ Tss2_MU_YAML_TPMT_PUBLIC_PARMS_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("type", 0, NULL, NULL), - KVP_ADD_MARSHAL("parameters", sizeof(src->parameters), &src->parameters, yaml_internal_TPMU_PUBLIC_PARMS_marshal) + KVPU_ADD_MARSHAL("parameters", sizeof(src->type), &src->type, yaml_internal_TPMU_PUBLIC_PARMS_scalar_marshal, sizeof(src->parameters), &src->parameters, yaml_internal_TPMU_PUBLIC_PARMS_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -1044,8 +1021,7 @@ Tss2_MU_YAML_TPMT_PUBLIC_PARMS_Unmarshal( TPMT_PUBLIC_PARMS tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("type", 0, NULL, NULL), - KVP_ADD_UNMARSHAL("parameters", sizeof(tmp_dest.parameters), &tmp_dest.parameters, yaml_internal_TPMU_PUBLIC_PARMS_unmarshal) + KVPU_ADD_UNMARSHAL("parameters", sizeof(tmp_dest.type), &tmp_dest.type, yaml_internal_TPMU_PUBLIC_PARMS_scalar_unmarshal, sizeof(tmp_dest.parameters), &tmp_dest.parameters, yaml_internal_TPMU_PUBLIC_PARMS_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); @@ -1080,12 +1056,11 @@ Tss2_MU_YAML_TPMT_PUBLIC_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("type", sizeof(src->type), &src->type, yaml_internal_TPM2_ALG_ID_scalar_marshal), KVP_ADD_MARSHAL("nameAlg", sizeof(src->nameAlg), &src->nameAlg, yaml_internal_TPM2_ALG_ID_scalar_marshal), KVP_ADD_MARSHAL("objectAttributes", sizeof(src->objectAttributes), &src->objectAttributes, yaml_internal_TPMA_OBJECT_scalar_marshal), KVP_ADD_MARSHAL("authPolicy", sizeof(src->authPolicy), &src->authPolicy, yaml_internal_TPM2B_DIGEST_marshal), - KVP_ADD_MARSHAL("parameters", sizeof(src->parameters), &src->parameters, yaml_internal_TPMU_PUBLIC_PARMS_marshal), - KVP_ADD_MARSHAL("unique", sizeof(src->unique), &src->unique, yaml_internal_TPMU_PUBLIC_ID_marshal) + KVPU_ADD_MARSHAL("parameters", sizeof(src->type), &src->type, yaml_internal_TPMU_PUBLIC_PARMS_scalar_marshal, sizeof(src->parameters), &src->parameters, yaml_internal_TPMU_PUBLIC_PARMS_marshal), + KVPU_ADD_MARSHAL("unique", sizeof(src->type), &src->type, yaml_internal_TPMU_PUBLIC_ID_scalar_marshal, sizeof(src->unique), &src->unique, yaml_internal_TPMU_PUBLIC_ID_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -1113,12 +1088,11 @@ Tss2_MU_YAML_TPMT_PUBLIC_Unmarshal( TPMT_PUBLIC tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("type", sizeof(tmp_dest.type), &tmp_dest.type, yaml_internal_TPM2_ALG_ID_scalar_unmarshal), KVP_ADD_UNMARSHAL("nameAlg", sizeof(tmp_dest.nameAlg), &tmp_dest.nameAlg, yaml_internal_TPM2_ALG_ID_scalar_unmarshal), KVP_ADD_UNMARSHAL("objectAttributes", sizeof(tmp_dest.objectAttributes), &tmp_dest.objectAttributes, yaml_internal_TPMA_OBJECT_scalar_unmarshal), KVP_ADD_UNMARSHAL("authPolicy", sizeof(tmp_dest.authPolicy), &tmp_dest.authPolicy, yaml_internal_TPM2B_DIGEST_unmarshal), - KVP_ADD_UNMARSHAL("parameters", sizeof(tmp_dest.parameters), &tmp_dest.parameters, yaml_internal_TPMU_PUBLIC_PARMS_unmarshal), - KVP_ADD_UNMARSHAL("unique", sizeof(tmp_dest.unique), &tmp_dest.unique, yaml_internal_TPMU_PUBLIC_ID_unmarshal) + KVPU_ADD_UNMARSHAL("parameters", sizeof(tmp_dest.type), &tmp_dest.type, yaml_internal_TPMU_PUBLIC_PARMS_scalar_unmarshal, sizeof(tmp_dest.parameters), &tmp_dest.parameters, yaml_internal_TPMU_PUBLIC_PARMS_unmarshal), + KVPU_ADD_UNMARSHAL("unique", sizeof(tmp_dest.type), &tmp_dest.type, yaml_internal_TPMU_PUBLIC_ID_scalar_unmarshal, sizeof(tmp_dest.unique), &tmp_dest.unique, yaml_internal_TPMU_PUBLIC_ID_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data)); @@ -1153,10 +1127,9 @@ Tss2_MU_YAML_TPMT_SENSITIVE_Marshal( } struct key_value kvs[] = { - KVP_ADD_MARSHAL("sensitiveType", 0, NULL, NULL), KVP_ADD_MARSHAL("authValue", sizeof(src->authValue), &src->authValue, yaml_internal_TPM2B_AUTH_marshal), KVP_ADD_MARSHAL("seedValue", sizeof(src->seedValue), &src->seedValue, yaml_internal_TPM2B_DIGEST_marshal), - KVP_ADD_MARSHAL("sensitive", sizeof(src->sensitive), &src->sensitive, yaml_internal_TPMU_SENSITIVE_COMPOSITE_marshal) + KVPU_ADD_MARSHAL("sensitive", sizeof(src->sensitiveType), &src->sensitiveType, yaml_internal_TPMU_SENSITIVE_COMPOSITE_scalar_marshal, sizeof(src->sensitive), &src->sensitive, yaml_internal_TPMU_SENSITIVE_COMPOSITE_marshal) }; rc = add_kvp_list(&doc, root, kvs, ARRAY_LEN(kvs)); return_if_error(rc, "Could not add KVPs"); @@ -1184,10 +1157,9 @@ Tss2_MU_YAML_TPMT_SENSITIVE_Unmarshal( TPMT_SENSITIVE tmp_dest = { 0 }; key_value parsed_data[] = { - KVP_ADD_UNMARSHAL("sensitiveType", 0, NULL, NULL), KVP_ADD_UNMARSHAL("authValue", sizeof(tmp_dest.authValue), &tmp_dest.authValue, yaml_internal_TPM2B_AUTH_unmarshal), KVP_ADD_UNMARSHAL("seedValue", sizeof(tmp_dest.seedValue), &tmp_dest.seedValue, yaml_internal_TPM2B_DIGEST_unmarshal), - KVP_ADD_UNMARSHAL("sensitive", sizeof(tmp_dest.sensitive), &tmp_dest.sensitive, yaml_internal_TPMU_SENSITIVE_COMPOSITE_unmarshal) + KVPU_ADD_UNMARSHAL("sensitive", sizeof(tmp_dest.sensitiveType), &tmp_dest.sensitiveType, yaml_internal_TPMU_SENSITIVE_COMPOSITE_scalar_unmarshal, sizeof(tmp_dest.sensitive), &tmp_dest.sensitive, yaml_internal_TPMU_SENSITIVE_COMPOSITE_unmarshal) }; TSS2_RC rc = yaml_parse(yaml, yaml_len, parsed_data, ARRAY_LEN(parsed_data));