Jocelyn Bohr | a4ed3aa | 2015-07-30 10:44:16 -0700 | [diff] [blame] | 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 "GetCommandAuditDigest_fp.h" |
| 9 | |
Vadim Bendebury | c3730f6 | 2019-01-15 11:59:05 -0800 | [diff] [blame] | 10 | #if IS_CC_ENABLED(GetCommandAuditDigest) |
Vadim Bendebury | 56abbbf | 2018-08-28 15:34:31 -0700 | [diff] [blame] | 11 | static UINT16 GetCommandAuditDigest_Out_Marshal( |
| 12 | GetCommandAuditDigest_Out* source, |
| 13 | TPMI_ST_COMMAND_TAG tag, |
| 14 | BYTE** buffer, |
| 15 | INT32* size) { |
Jocelyn Bohr | a4ed3aa | 2015-07-30 10:44:16 -0700 | [diff] [blame] | 16 | UINT16 total_size = 0; |
| 17 | UINT32 parameter_size = 0; |
| 18 | BYTE* parameter_size_location; |
| 19 | INT32 parameter_size_size = sizeof(UINT32); |
| 20 | UINT32 num_response_handles = 0; |
| 21 | // Add parameter_size=0 to indicate size of the parameter area. Will be |
| 22 | // replaced later by computed parameter_size. |
| 23 | if (tag == TPM_ST_SESSIONS) { |
| 24 | parameter_size_location = *buffer; |
| 25 | // Don't add to total_size, but increment *buffer and decrement *size. |
| 26 | UINT32_Marshal(¶meter_size, buffer, size); |
| 27 | } |
| 28 | // Marshal response parameters. |
| 29 | total_size += TPM2B_ATTEST_Marshal(&source->auditInfo, buffer, size); |
| 30 | total_size += TPMT_SIGNATURE_Marshal(&source->signature, buffer, size); |
| 31 | // Compute actual parameter_size. Don't add result to total_size. |
| 32 | if (tag == TPM_ST_SESSIONS) { |
| 33 | parameter_size = total_size - num_response_handles * sizeof(TPM_HANDLE); |
| 34 | UINT32_Marshal(¶meter_size, ¶meter_size_location, |
| 35 | ¶meter_size_size); |
| 36 | } |
| 37 | return total_size; |
| 38 | } |
Vadim Bendebury | 56abbbf | 2018-08-28 15:34:31 -0700 | [diff] [blame] | 39 | #endif |
Jocelyn Bohr | a4ed3aa | 2015-07-30 10:44:16 -0700 | [diff] [blame] | 40 | |
Vadim Bendebury | 56abbbf | 2018-08-28 15:34:31 -0700 | [diff] [blame] | 41 | static TPM_RC GetCommandAuditDigest_In_Unmarshal( |
| 42 | GetCommandAuditDigest_In* target, |
| 43 | TPM_HANDLE request_handles[], |
| 44 | BYTE** buffer, |
| 45 | INT32* size) { |
Jocelyn Bohr | a4ed3aa | 2015-07-30 10:44:16 -0700 | [diff] [blame] | 46 | TPM_RC result = TPM_RC_SUCCESS; |
| 47 | // Get request handles from request_handles array. |
| 48 | target->privacyHandle = request_handles[0]; |
| 49 | target->signHandle = request_handles[1]; |
| 50 | // Unmarshal request parameters. |
| 51 | result = TPM2B_DATA_Unmarshal(&target->qualifyingData, buffer, size); |
| 52 | if (result != TPM_RC_SUCCESS) { |
| 53 | return result; |
| 54 | } |
| 55 | result = TPMT_SIG_SCHEME_Unmarshal(&target->inScheme, buffer, size); |
| 56 | if (result != TPM_RC_SUCCESS) { |
| 57 | return result; |
| 58 | } |
Vadim Bendebury | 3dfffca | 2015-10-20 17:17:54 -0700 | [diff] [blame] | 59 | if ((result == TPM_RC_SUCCESS) && *size) { |
| 60 | result = TPM_RC_SIZE; |
| 61 | } |
Jocelyn Bohr | a4ed3aa | 2015-07-30 10:44:16 -0700 | [diff] [blame] | 62 | return result; |
| 63 | } |
| 64 | |
| 65 | TPM_RC Exec_GetCommandAuditDigest(TPMI_ST_COMMAND_TAG tag, |
| 66 | BYTE** request_parameter_buffer, |
| 67 | INT32* request_parameter_buffer_size, |
| 68 | TPM_HANDLE request_handles[], |
| 69 | UINT32* response_handle_buffer_size, |
| 70 | UINT32* response_parameter_buffer_size) { |
| 71 | TPM_RC result = TPM_RC_SUCCESS; |
| 72 | GetCommandAuditDigest_In in; |
| 73 | GetCommandAuditDigest_Out out; |
Vadim Bendebury | c3730f6 | 2019-01-15 11:59:05 -0800 | [diff] [blame] | 74 | #if IS_CC_ENABLED(GetCommandAuditDigest) |
Jocelyn Bohr | a4ed3aa | 2015-07-30 10:44:16 -0700 | [diff] [blame] | 75 | BYTE* response_buffer; |
| 76 | INT32 response_buffer_size; |
| 77 | UINT16 bytes_marshalled; |
| 78 | UINT16 num_response_handles = 0; |
| 79 | #endif |
| 80 | *response_handle_buffer_size = 0; |
| 81 | *response_parameter_buffer_size = 0; |
| 82 | // Unmarshal request parameters to input structure. |
| 83 | result = GetCommandAuditDigest_In_Unmarshal(&in, request_handles, |
| 84 | request_parameter_buffer, |
| 85 | request_parameter_buffer_size); |
| 86 | if (result != TPM_RC_SUCCESS) { |
| 87 | return result; |
| 88 | } |
| 89 | // Execute command. |
| 90 | result = TPM2_GetCommandAuditDigest(&in, &out); |
| 91 | if (result != TPM_RC_SUCCESS) { |
| 92 | return result; |
| 93 | } |
| 94 | // Marshal output structure to global response buffer. |
Vadim Bendebury | c3730f6 | 2019-01-15 11:59:05 -0800 | [diff] [blame] | 95 | #if IS_CC_ENABLED(GetCommandAuditDigest) |
Jocelyn Bohr | a4ed3aa | 2015-07-30 10:44:16 -0700 | [diff] [blame] | 96 | response_buffer = MemoryGetResponseBuffer(TPM_CC_GetCommandAuditDigest) + 10; |
| 97 | response_buffer_size = MAX_RESPONSE_SIZE - 10; |
| 98 | bytes_marshalled = GetCommandAuditDigest_Out_Marshal( |
| 99 | &out, tag, &response_buffer, &response_buffer_size); |
| 100 | *response_handle_buffer_size = num_response_handles * sizeof(TPM_HANDLE); |
| 101 | *response_parameter_buffer_size = |
| 102 | bytes_marshalled - *response_handle_buffer_size; |
| 103 | return TPM_RC_SUCCESS; |
| 104 | #endif |
| 105 | return TPM_RC_COMMAND_CODE; |
| 106 | } |