1/*
2 * Copyright 2015 The Chromium OS Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
7#ifndef __TPM2_MARSHAL_FP_H
8#define __TPM2_MARSHAL_FP_H
9
10UINT16 Common_Marshal(void *source, BYTE **buffer, INT32 *size,
11                      UINT16 type_size);
12TPM_RC Common_Unmarshal(void *source, BYTE **buffer, INT32 *size,
13                        UINT16 type_size);
14
15#define MARSHAL_WRAPPER(name)                                          \
16  static inline UINT16 name##_Marshal(void *x, BYTE **y, INT32 *z) {   \
17    return Common_Marshal(x, y, z, sizeof(name));                      \
18  }                                                                    \
19  static inline TPM_RC name##_Unmarshal(void *x, BYTE **y, INT32 *z) { \
20    return Common_Unmarshal(x, y, z, sizeof(name));                    \
21  }
22
23MARSHAL_WRAPPER(SESSION)
24MARSHAL_WRAPPER(TPM2B_AUTH)
25MARSHAL_WRAPPER(TPM2B_DIGEST)
26MARSHAL_WRAPPER(TPM2B_IV)
27MARSHAL_WRAPPER(TPM2B_NONCE)
28MARSHAL_WRAPPER(TPMA_LOCALITY)
29MARSHAL_WRAPPER(TPMA_SESSION)
30MARSHAL_WRAPPER(TPMI_SH_AUTH_SESSION)
31MARSHAL_WRAPPER(TPMI_ST_COMMAND_TAG)
32MARSHAL_WRAPPER(TPML_PCR_SELECTION)
33MARSHAL_WRAPPER(TPMS_ATTEST)
34MARSHAL_WRAPPER(TPMS_CREATION_DATA)
35MARSHAL_WRAPPER(TPMS_ECC_POINT)
36MARSHAL_WRAPPER(TPMS_NV_PUBLIC)
37MARSHAL_WRAPPER(TPMS_TIME_INFO)
38MARSHAL_WRAPPER(TPMT_PUBLIC)
39MARSHAL_WRAPPER(TPMT_SENSITIVE)
40MARSHAL_WRAPPER(TPM_CC)
41MARSHAL_WRAPPER(TPM_GENERATED)
42MARSHAL_WRAPPER(TPM_HANDLE)
43MARSHAL_WRAPPER(TPM_RC)
44MARSHAL_WRAPPER(TPM_ST)
45MARSHAL_WRAPPER(UINT16)
46MARSHAL_WRAPPER(UINT32)
47
48UINT16 TPMU_PUBLIC_PARMS_Marshal(TPMU_PUBLIC_PARMS *x, BYTE **y, INT32 *z,
49                                 TPMI_ALG_PUBLIC type);
50
51#endif  // __TPM2_MARSHAL_FP_H
52