1 // Copyright 2015 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // THIS CODE IS GENERATED - DO NOT MODIFY!
6
7 #include "MemoryLib_fp.h"
8 #include "PolicyTicket_fp.h"
9
PolicyTicket_In_Unmarshal(PolicyTicket_In * target,TPM_HANDLE request_handles[],BYTE ** buffer,INT32 * size)10 TPM_RC PolicyTicket_In_Unmarshal(PolicyTicket_In* target,
11 TPM_HANDLE request_handles[],
12 BYTE** buffer,
13 INT32* size) {
14 TPM_RC result = TPM_RC_SUCCESS;
15 // Get request handles from request_handles array.
16 target->policySession = request_handles[0];
17 // Unmarshal request parameters.
18 result = TPM2B_TIMEOUT_Unmarshal(&target->timeout, buffer, size);
19 if (result != TPM_RC_SUCCESS) {
20 return result;
21 }
22 result = TPM2B_DIGEST_Unmarshal(&target->cpHashA, buffer, size);
23 if (result != TPM_RC_SUCCESS) {
24 return result;
25 }
26 result = TPM2B_NONCE_Unmarshal(&target->policyRef, buffer, size);
27 if (result != TPM_RC_SUCCESS) {
28 return result;
29 }
30 result = TPM2B_NAME_Unmarshal(&target->authName, buffer, size);
31 if (result != TPM_RC_SUCCESS) {
32 return result;
33 }
34 result = TPMT_TK_AUTH_Unmarshal(&target->ticket, buffer, size);
35 if (result != TPM_RC_SUCCESS) {
36 return result;
37 }
38 if ((result == TPM_RC_SUCCESS) && *size) {
39 result = TPM_RC_SIZE;
40 }
41 return result;
42 }
43
Exec_PolicyTicket(TPMI_ST_COMMAND_TAG tag,BYTE ** request_parameter_buffer,INT32 * request_parameter_buffer_size,TPM_HANDLE request_handles[],UINT32 * response_handle_buffer_size,UINT32 * response_parameter_buffer_size)44 TPM_RC Exec_PolicyTicket(TPMI_ST_COMMAND_TAG tag,
45 BYTE** request_parameter_buffer,
46 INT32* request_parameter_buffer_size,
47 TPM_HANDLE request_handles[],
48 UINT32* response_handle_buffer_size,
49 UINT32* response_parameter_buffer_size) {
50 TPM_RC result = TPM_RC_SUCCESS;
51 PolicyTicket_In in;
52 #ifdef TPM_CC_PolicyTicket
53 BYTE* response_buffer;
54 INT32 response_buffer_size;
55 #endif
56 *response_handle_buffer_size = 0;
57 *response_parameter_buffer_size = 0;
58 // Unmarshal request parameters to input structure.
59 result =
60 PolicyTicket_In_Unmarshal(&in, request_handles, request_parameter_buffer,
61 request_parameter_buffer_size);
62 if (result != TPM_RC_SUCCESS) {
63 return result;
64 }
65 // Execute command.
66 result = TPM2_PolicyTicket(&in);
67 if (result != TPM_RC_SUCCESS) {
68 return result;
69 }
70 #ifdef TPM_CC_PolicyTicket
71 response_buffer = MemoryGetResponseBuffer(TPM_CC_PolicyTicket) + 10;
72 response_buffer_size = MAX_RESPONSE_SIZE - 10;
73 // Add parameter_size field, always equal to 0 here.
74 if (tag == TPM_ST_SESSIONS) {
75 UINT32_Marshal(response_parameter_buffer_size, &response_buffer,
76 &response_buffer_size);
77 }
78 return TPM_RC_SUCCESS;
79 #endif
80 return TPM_RC_COMMAND_CODE;
81 }
82