TPMU_CAPABILITIES_Marshal(TPMU_CAPABILITIES *source, BYTE **buffer, INT32 *size, UINT32 selector)
{
    UINT16 written = 0;

    switch (selector) {
      case TPM_CAP_ALGS:
	written += TPML_ALG_PROPERTY_Marshal(&source->algorithms, buffer, size);
	break;
      case TPM_CAP_HANDLES:
	written += TPML_HANDLE_Marshal(&source->handles, buffer, size);
	break;
      case TPM_CAP_COMMANDS:
	written += TPML_CCA_Marshal(&source->command, buffer, size);
	break;
      case TPM_CAP_PP_COMMANDS:
	written += TPML_CC_Marshal(&source->ppCommands, buffer, size);
	break;
      case TPM_CAP_AUDIT_COMMANDS:
	written += TPML_CC_Marshal(&source->auditCommands, buffer, size);
	break;
      case TPM_CAP_PCRS:
	written += TPML_PCR_SELECTION_Marshal(&source->assignedPCR, buffer, size);
	break;
      case TPM_CAP_TPM_PROPERTIES:
	written += TPML_TAGGED_TPM_PROPERTY_Marshal(&source->tpmProperties, buffer, size);
	break;
      case TPM_CAP_PCR_PROPERTIES:
	written += TPML_TAGGED_PCR_PROPERTY_Marshal(&source->pcrProperties, buffer, size);
	break;
      case TPM_CAP_ECC_CURVES:
	written += TPML_ECC_CURVE_Marshal(&source->eccCurves, buffer, size);
	break;
      case TPM_CAP_AUTH_POLICIES:
	written += TPML_TAGGED_POLICY_Marshal(&source->authPolicies, buffer, size);
	break;
      case TPM_CAP_ACT:
	written += TPML_ACT_DATA_Marshal(&source->actData, buffer, size);
	break;
      default:
	pAssert(FALSE);
    }
    return written;
}
TPMU_CAPABILITIES_Marshal(TPMU_CAPABILITIES *source, BYTE **buffer, INT32 *size, UINT32 selector)
{
    UINT16 written = 0;

    switch (selector) {
      case TPM_CAP_ALGS:
	written += TPML_ALG_PROPERTY_Marshal(&source->algorithms, buffer, size);
	break;
      case TPM_CAP_HANDLES:
	written += TPML_HANDLE_Marshal(&source->handles, buffer, size);
	break;
      case TPM_CAP_COMMANDS:
	written += TPML_CCA_Marshal(&source->command, buffer, size);
	break;
      case TPM_CAP_PP_COMMANDS:
	written += TPML_CC_Marshal(&source->ppCommands, buffer, size);
	break;
      case TPM_CAP_AUDIT_COMMANDS:
	written += TPML_CC_Marshal(&source->auditCommands, buffer, size);
	break;
      case TPM_CAP_PCRS:
	written += TPML_PCR_SELECTION_Marshal(&source->assignedPCR, buffer, size);
	break;
      case TPM_CAP_TPM_PROPERTIES:
	written += TPML_TAGGED_TPM_PROPERTY_Marshal(&source->tpmProperties, buffer, size);
	break;
      case TPM_CAP_PCR_PROPERTIES:
	written += TPML_TAGGED_PCR_PROPERTY_Marshal(&source->pcrProperties, buffer, size);
	break;
      case TPM_CAP_ECC_CURVES:
	written += TPML_ECC_CURVE_Marshal(&source->eccCurves, buffer, size);
	break;
      case TPM_CAP_AUTH_POLICIES:
	written += TPML_TAGGED_POLICY_Marshal(&source->authPolicies, buffer, size);
	break;
      case TPM_CAP_ACT:
	written += TPML_ACT_DATA_Marshal(&source->actData, buffer, size);
	break;
      default:
	pAssert(FALSE);
    }
    return written;
}