1
// ===================================================================
3
// Copyright (c) 2005, Intel Corp.
4
// All rights reserved.
6
// Redistribution and use in source and binary forms, with or without
7
// modification, are permitted provided that the following conditions
10
// * Redistributions of source code must retain the above copyright
11
// notice, this list of conditions and the following disclaimer.
12
// * Redistributions in binary form must reproduce the above
13
// copyright notice, this list of conditions and the following
14
// disclaimer in the documentation and/or other materials provided
15
// with the distribution.
16
// * Neither the name of Intel Corporation nor the names of its
17
// contributors may be used to endorse or promote products derived
18
// from this software without specific prior written permission.
20
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31
// OF THE POSSIBILITY OF SUCH DAMAGE.
32
// ===================================================================
36
// This file contains API's for the TPM Byte Stream functions
38
// ==================================================================
46
typedef unsigned int BSG_UINT32;
47
typedef unsigned char BSG_BYTE;
50
struct pack_const_tuple_t;
56
* Byte stream generator
58
// this has to be manually kept in sync with the
60
// but now we have a self-check function which can make sure things are well
65
BSG_TYPE_UINT32 = 1, // start at 1 so that Type 0 only serves as an
66
// unused/special value
70
BSG_TPM_SIZE32_DATA, // a 32 bit unsigned size, followed by
71
// a pointer to that much data. can pass a
72
// struct pack_buf_t as the param
76
BSG_TPM_RESOURCE_TYPE,
78
BSG_TPM_AUTH_DATA_USAGE,
84
BSG_TPM_MIGRATE_SCHEME,
93
BSG_TPM_COMPOSITE_HASH,
94
BSG_TPM_CHOSENID_HASH,
97
BSG_TPM_KEY_HANDLE_LIST,
99
BSG_TPM_RSA_KEY_PARMS,
100
BSG_TPM_STORE_PUBKEY,
104
BSG_TPM_MIGRATIONKEYAUTH,
105
BSG_TCPA_AUDIT_EVENT,
107
BSG_TPM_PCR_SELECTION,
108
BSG_TPM_PCR_COMPOSITE,
111
BSG_TPM_SYMMETRIC_KEY,
112
BSG_TPM_STORE_PRIVKEY,
113
BSG_TPM_STORE_ASYMKEY,
114
BSG_TPM_MIGRATE_ASYMKEY,
116
BSG_TPM_IDENTITY_CONTENTS,
121
// this is the BSG_TPM_KEY struct without the encData field
122
BSG_TPM_KEY_NONSENSITIVE,
129
struct pack_const_tuple_t {
135
typedef struct pack_tuple_t {
140
int BSG_Pack(BSG_Type type, const void* src, BSG_BYTE* dst);
141
int BSG_Unpack(BSG_Type type, const BSG_BYTE* src, void* dst);
142
void BSG_Destroy(BSG_Type type, void* src);
144
// wrappers of Pack and PackList which malloc the ouput buffer. to be freed
145
// by the caller later. returns size of allocated buffer, or -1 in case
147
int BSG_PackMalloc (BSG_Type type, const void* src, BSG_BYTE** o_dst);
148
int BSG_PackListMalloc (BSG_BYTE** outBuffer, int ParamCount, ... );
150
// a va_list version of PackList
151
int BSG_PackList(BSG_BYTE* outBuffer, int ParamCount, ... );
152
int BSG_UnpackList(const BSG_BYTE* inBuffer, int ParamCount, ... );
153
void BSG_DestroyList(int ParamCount, ... );
155
// wrapper of PackList which uses a buffer_t
156
TPM_RESULT BSG_PackListBuf (buffer_t * o_buf, int ParamCount, ...);
158
// and a tuple version
159
TPM_RESULT BSG_DestroyTuple (int numParams, pack_tuple_t params[]);
161
void BSG_PackConst(BSG_UINT32 val, int size, BSG_BYTE* dst);
162
BSG_UINT32 BSG_UnpackConst(const BSG_BYTE* src, int size);
164
BOOL BSG_static_selfcheck ();