TPMU_CAPABILITIES_Unmarshal(TPMU_CAPABILITIES *target, BYTE **buffer, INT32 *size, UINT32 selector)
{
    TPM_RC rc = TPM_RC_SUCCESS;

    switch (selector) {
      case TPM_CAP_ALGS:
	rc = TPML_ALG_PROPERTY_Unmarshal(&target->algorithms, buffer, size);
	break;
      case TPM_CAP_HANDLES:
	rc = TPML_HANDLE_Unmarshal(&target->handles, buffer, size);
	break;
      case TPM_CAP_COMMANDS:
	rc = TPML_CCA_Unmarshal(&target->command, buffer, size);
	break;
      case TPM_CAP_PP_COMMANDS:
	rc = TPML_CC_Unmarshal(&target->ppCommands, buffer, size);
	break;
      case TPM_CAP_AUDIT_COMMANDS:
	rc = TPML_CC_Unmarshal(&target->auditCommands, buffer, size);
	break;
      case TPM_CAP_PCRS:
	rc = TPML_PCR_SELECTION_Unmarshal(&target->assignedPCR, buffer, size);
	break;
      case TPM_CAP_TPM_PROPERTIES:
	rc = TPML_TAGGED_TPM_PROPERTY_Unmarshal(&target->tpmProperties, buffer, size);
	break;
      case TPM_CAP_PCR_PROPERTIES:
	rc = TPML_TAGGED_PCR_PROPERTY_Unmarshal(&target->pcrProperties, buffer, size);
	break;
      case TPM_CAP_ECC_CURVES:
	rc = TPML_ECC_CURVE_Unmarshal(&target->eccCurves, buffer, size);
	break;
      case TPM_CAP_AUTH_POLICIES:	
	rc = TPML_TAGGED_POLICY_Unmarshal(&target->authPolicies, buffer, size);
	break;
      default:
	rc = TPM_RC_SELECTOR;
    }
    return rc;
}
TPMU_CAPABILITIES_Unmarshal(TPMU_CAPABILITIES *target, BYTE **buffer, INT32 *size, UINT32 selector)
{
    TPM_RC rc = TPM_RC_SUCCESS;

    switch (selector) {
      case TPM_CAP_ALGS:
	rc = TPML_ALG_PROPERTY_Unmarshal(&target->algorithms, buffer, size);
	break;
      case TPM_CAP_HANDLES:
	rc = TPML_HANDLE_Unmarshal(&target->handles, buffer, size);
	break;
      case TPM_CAP_COMMANDS:
	rc = TPML_CCA_Unmarshal(&target->command, buffer, size);
	break;
      case TPM_CAP_PP_COMMANDS:
	rc = TPML_CC_Unmarshal(&target->ppCommands, buffer, size);
	break;
      case TPM_CAP_AUDIT_COMMANDS:
	rc = TPML_CC_Unmarshal(&target->auditCommands, buffer, size);
	break;
      case TPM_CAP_PCRS:
	rc = TPML_PCR_SELECTION_Unmarshal(&target->assignedPCR, buffer, size);
	break;
      case TPM_CAP_TPM_PROPERTIES:
	rc = TPML_TAGGED_TPM_PROPERTY_Unmarshal(&target->tpmProperties, buffer, size);
	break;
      case TPM_CAP_PCR_PROPERTIES:
	rc = TPML_TAGGED_PCR_PROPERTY_Unmarshal(&target->pcrProperties, buffer, size);
	break;
      case TPM_CAP_ECC_CURVES:
	rc = TPML_ECC_CURVE_Unmarshal(&target->eccCurves, buffer, size);
	break;
      case TPM_CAP_AUTH_POLICIES:	
	rc = TPML_TAGGED_POLICY_Unmarshal(&target->authPolicies, buffer, size);
	break;
      default:
	rc = TPM_RC_SELECTOR;
    }
    return rc;
}