TPMT_PUBLIC_Marshal(TPMT_PUBLIC *source, BYTE **buffer, INT32 *size)
{
    UINT16 written = 0;
    written += TPMI_ALG_PUBLIC_Marshal(&source->type, buffer, size);
    written += TPMI_ALG_HASH_Marshal(&source->nameAlg, buffer, size);
    written += TPMA_OBJECT_Marshal(&source->objectAttributes, buffer, size);
    written += TPM2B_DIGEST_Marshal(&source->authPolicy, buffer, size);
    written += TPMU_PUBLIC_PARMS_Marshal(&source->parameters, buffer, size, source->type);
    written += TPMU_PUBLIC_ID_Marshal(&source->unique, buffer, size, source->type);
    return written;
}
TPMT_PUBLIC_Marshal(TPMT_PUBLIC *source, BYTE **buffer, INT32 *size)
{
    UINT16 written = 0;
    written += TPMI_ALG_PUBLIC_Marshal(&source->type, buffer, size);
    written += TPMI_ALG_HASH_Marshal(&source->nameAlg, buffer, size);
    written += TPMA_OBJECT_Marshal(&source->objectAttributes, buffer, size);
    written += TPM2B_DIGEST_Marshal(&source->authPolicy, buffer, size);
    written += TPMU_PUBLIC_PARMS_Marshal(&source->parameters, buffer, size, source->type);
    written += TPMU_PUBLIC_ID_Marshal(&source->unique, buffer, size, source->type);
    return written;
}