blob: 03bd3f63495a37b99309b8f344f71792470adf75 [file] [log] [blame]
Jocelyn Bohra4ed3aa2015-07-30 10:44:16 -07001// 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 "PCR_SetAuthPolicy_fp.h"
9
10TPM_RC PCR_SetAuthPolicy_In_Unmarshal(PCR_SetAuthPolicy_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->authHandle = request_handles[0];
17 target->pcrNum = request_handles[1];
18 // Unmarshal request parameters.
19 result = TPM2B_DIGEST_Unmarshal(&target->authPolicy, buffer, size);
20 if (result != TPM_RC_SUCCESS) {
21 return result;
22 }
23 result = TPMI_ALG_HASH_Unmarshal(&target->hashAlg, buffer, size, TRUE);
24 if (result != TPM_RC_SUCCESS) {
25 return result;
26 }
Vadim Bendebury3dfffca2015-10-20 17:17:54 -070027 if ((result == TPM_RC_SUCCESS) && *size) {
28 result = TPM_RC_SIZE;
29 }
Jocelyn Bohra4ed3aa2015-07-30 10:44:16 -070030 return result;
31}
32
33TPM_RC Exec_PCR_SetAuthPolicy(TPMI_ST_COMMAND_TAG tag,
34 BYTE** request_parameter_buffer,
35 INT32* request_parameter_buffer_size,
36 TPM_HANDLE request_handles[],
37 UINT32* response_handle_buffer_size,
38 UINT32* response_parameter_buffer_size) {
39 TPM_RC result = TPM_RC_SUCCESS;
40 PCR_SetAuthPolicy_In in;
41#ifdef TPM_CC_PCR_SetAuthPolicy
42 BYTE* response_buffer;
43 INT32 response_buffer_size;
44#endif
45 *response_handle_buffer_size = 0;
46 *response_parameter_buffer_size = 0;
47 // Unmarshal request parameters to input structure.
48 result = PCR_SetAuthPolicy_In_Unmarshal(&in, request_handles,
49 request_parameter_buffer,
50 request_parameter_buffer_size);
51 if (result != TPM_RC_SUCCESS) {
52 return result;
53 }
54 // Execute command.
55 result = TPM2_PCR_SetAuthPolicy(&in);
56 if (result != TPM_RC_SUCCESS) {
57 return result;
58 }
59#ifdef TPM_CC_PCR_SetAuthPolicy
60 response_buffer = MemoryGetResponseBuffer(TPM_CC_PCR_SetAuthPolicy) + 10;
61 response_buffer_size = MAX_RESPONSE_SIZE - 10;
62 // Add parameter_size field, always equal to 0 here.
63 if (tag == TPM_ST_SESSIONS) {
64 UINT32_Marshal(response_parameter_buffer_size, &response_buffer,
65 &response_buffer_size);
66 }
67 return TPM_RC_SUCCESS;
68#endif
69 return TPM_RC_COMMAND_CODE;
70}