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 "PolicyDuplicationSelect_fp.h"
9 
PolicyDuplicationSelect_In_Unmarshal(PolicyDuplicationSelect_In * target,TPM_HANDLE request_handles[],BYTE ** buffer,INT32 * size)10 TPM_RC PolicyDuplicationSelect_In_Unmarshal(PolicyDuplicationSelect_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_NAME_Unmarshal(&target->objectName, buffer, size);
19   if (result != TPM_RC_SUCCESS) {
20     return result;
21   }
22   result = TPM2B_NAME_Unmarshal(&target->newParentName, buffer, size);
23   if (result != TPM_RC_SUCCESS) {
24     return result;
25   }
26   result = TPMI_YES_NO_Unmarshal(&target->includeObject, buffer, size);
27   if (result != TPM_RC_SUCCESS) {
28     return result;
29   }
30   if ((result == TPM_RC_SUCCESS) && *size) {
31     result = TPM_RC_SIZE;
32   }
33   return result;
34 }
35 
Exec_PolicyDuplicationSelect(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)36 TPM_RC Exec_PolicyDuplicationSelect(TPMI_ST_COMMAND_TAG tag,
37                                     BYTE** request_parameter_buffer,
38                                     INT32* request_parameter_buffer_size,
39                                     TPM_HANDLE request_handles[],
40                                     UINT32* response_handle_buffer_size,
41                                     UINT32* response_parameter_buffer_size) {
42   TPM_RC result = TPM_RC_SUCCESS;
43   PolicyDuplicationSelect_In in;
44 #ifdef TPM_CC_PolicyDuplicationSelect
45   BYTE* response_buffer;
46   INT32 response_buffer_size;
47 #endif
48   *response_handle_buffer_size = 0;
49   *response_parameter_buffer_size = 0;
50   // Unmarshal request parameters to input structure.
51   result = PolicyDuplicationSelect_In_Unmarshal(&in, request_handles,
52                                                 request_parameter_buffer,
53                                                 request_parameter_buffer_size);
54   if (result != TPM_RC_SUCCESS) {
55     return result;
56   }
57   // Execute command.
58   result = TPM2_PolicyDuplicationSelect(&in);
59   if (result != TPM_RC_SUCCESS) {
60     return result;
61   }
62 #ifdef TPM_CC_PolicyDuplicationSelect
63   response_buffer =
64       MemoryGetResponseBuffer(TPM_CC_PolicyDuplicationSelect) + 10;
65   response_buffer_size = MAX_RESPONSE_SIZE - 10;
66   // Add parameter_size field, always equal to 0 here.
67   if (tag == TPM_ST_SESSIONS) {
68     UINT32_Marshal(response_parameter_buffer_size, &response_buffer,
69                    &response_buffer_size);
70   }
71   return TPM_RC_SUCCESS;
72 #endif
73   return TPM_RC_COMMAND_CODE;
74 }
75