blob: d9bf135015a17a39d712cf23f5aa6e75592e98b7 [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 "StartAuthSession_fp.h"
9
Vadim Bendeburyc3730f62019-01-15 11:59:05 -080010#if IS_CC_ENABLED(StartAuthSession)
Vadim Bendebury56abbbf2018-08-28 15:34:31 -070011static UINT16 StartAuthSession_Out_Marshal(StartAuthSession_Out* source,
12 TPMI_ST_COMMAND_TAG tag,
13 BYTE** buffer,
14 INT32* size) {
Jocelyn Bohra4ed3aa2015-07-30 10:44:16 -070015 UINT16 total_size = 0;
16 UINT32 parameter_size = 0;
17 BYTE* parameter_size_location;
18 INT32 parameter_size_size = sizeof(UINT32);
19 UINT32 num_response_handles = 1;
20 // Marshal response handles.
21 total_size +=
22 TPMI_SH_AUTH_SESSION_Marshal(&source->sessionHandle, buffer, size);
23 // Add parameter_size=0 to indicate size of the parameter area. Will be
24 // replaced later by computed parameter_size.
25 if (tag == TPM_ST_SESSIONS) {
26 parameter_size_location = *buffer;
27 // Don't add to total_size, but increment *buffer and decrement *size.
28 UINT32_Marshal(&parameter_size, buffer, size);
29 }
30 // Marshal response parameters.
31 total_size += TPM2B_NONCE_Marshal(&source->nonceTPM, buffer, size);
32 // Compute actual parameter_size. Don't add result to total_size.
33 if (tag == TPM_ST_SESSIONS) {
34 parameter_size = total_size - num_response_handles * sizeof(TPM_HANDLE);
35 UINT32_Marshal(&parameter_size, &parameter_size_location,
36 &parameter_size_size);
37 }
38 return total_size;
39}
Vadim Bendebury56abbbf2018-08-28 15:34:31 -070040#endif
Jocelyn Bohra4ed3aa2015-07-30 10:44:16 -070041
Vadim Bendebury56abbbf2018-08-28 15:34:31 -070042static TPM_RC StartAuthSession_In_Unmarshal(StartAuthSession_In* target,
43 TPM_HANDLE request_handles[],
44 BYTE** buffer,
45 INT32* size) {
Jocelyn Bohra4ed3aa2015-07-30 10:44:16 -070046 TPM_RC result = TPM_RC_SUCCESS;
47 // Get request handles from request_handles array.
48 target->tpmKey = request_handles[0];
49 target->bind = request_handles[1];
50 // Unmarshal request parameters.
51 result = TPM2B_NONCE_Unmarshal(&target->nonceCaller, buffer, size);
52 if (result != TPM_RC_SUCCESS) {
53 return result;
54 }
55 result =
56 TPM2B_ENCRYPTED_SECRET_Unmarshal(&target->encryptedSalt, buffer, size);
57 if (result != TPM_RC_SUCCESS) {
58 return result;
59 }
60 result = TPM_SE_Unmarshal(&target->sessionType, buffer, size);
61 if (result != TPM_RC_SUCCESS) {
62 return result;
63 }
64 result = TPMT_SYM_DEF_Unmarshal(&target->symmetric, buffer, size);
65 if (result != TPM_RC_SUCCESS) {
66 return result;
67 }
68 result = TPMI_ALG_HASH_Unmarshal(&target->authHash, buffer, size, FALSE);
69 if (result != TPM_RC_SUCCESS) {
70 return result;
71 }
Vadim Bendebury3dfffca2015-10-20 17:17:54 -070072 if ((result == TPM_RC_SUCCESS) && *size) {
73 result = TPM_RC_SIZE;
74 }
Jocelyn Bohra4ed3aa2015-07-30 10:44:16 -070075 return result;
76}
77
78TPM_RC Exec_StartAuthSession(TPMI_ST_COMMAND_TAG tag,
79 BYTE** request_parameter_buffer,
80 INT32* request_parameter_buffer_size,
81 TPM_HANDLE request_handles[],
82 UINT32* response_handle_buffer_size,
83 UINT32* response_parameter_buffer_size) {
84 TPM_RC result = TPM_RC_SUCCESS;
85 StartAuthSession_In in;
86 StartAuthSession_Out out;
Vadim Bendeburyc3730f62019-01-15 11:59:05 -080087#if IS_CC_ENABLED(StartAuthSession)
Jocelyn Bohra4ed3aa2015-07-30 10:44:16 -070088 BYTE* response_buffer;
89 INT32 response_buffer_size;
90 UINT16 bytes_marshalled;
91 UINT16 num_response_handles = 1;
92#endif
93 *response_handle_buffer_size = 0;
94 *response_parameter_buffer_size = 0;
95 // Unmarshal request parameters to input structure.
96 result = StartAuthSession_In_Unmarshal(&in, request_handles,
97 request_parameter_buffer,
98 request_parameter_buffer_size);
99 if (result != TPM_RC_SUCCESS) {
100 return result;
101 }
102 // Execute command.
103 result = TPM2_StartAuthSession(&in, &out);
104 if (result != TPM_RC_SUCCESS) {
105 return result;
106 }
107// Marshal output structure to global response buffer.
Vadim Bendeburyc3730f62019-01-15 11:59:05 -0800108#if IS_CC_ENABLED(StartAuthSession)
Jocelyn Bohra4ed3aa2015-07-30 10:44:16 -0700109 response_buffer = MemoryGetResponseBuffer(TPM_CC_StartAuthSession) + 10;
110 response_buffer_size = MAX_RESPONSE_SIZE - 10;
111 bytes_marshalled = StartAuthSession_Out_Marshal(&out, tag, &response_buffer,
112 &response_buffer_size);
113 *response_handle_buffer_size = num_response_handles * sizeof(TPM_HANDLE);
114 *response_parameter_buffer_size =
115 bytes_marshalled - *response_handle_buffer_size;
116 return TPM_RC_SUCCESS;
117#endif
118 return TPM_RC_COMMAND_CODE;
119}