Coverage Report

Created: 2026-12-01 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tpm2/Marshal_StartAuthSession.c
Line
Count
Source
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 "StartAuthSession_fp.h"
9
10
#if IS_CC_ENABLED(StartAuthSession)
11
static UINT16 StartAuthSession_Out_Marshal(StartAuthSession_Out* source,
12
                                           TPMI_ST_COMMAND_TAG tag,
13
                                           BYTE** buffer,
14
15
                                           INT32* size) {
15
15
  UINT16 total_size = 0;
16
15
  UINT32 parameter_size = 0;
17
15
  BYTE* parameter_size_location;
18
15
  INT32 parameter_size_size = sizeof(UINT32);
19
15
  UINT32 num_response_handles = 1;
20
  // Marshal response handles.
21
15
  total_size +=
22
15
      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
15
  if (tag == TPM_ST_SESSIONS) {
26
0
    parameter_size_location = *buffer;
27
    // Don't add to total_size, but increment *buffer and decrement *size.
28
0
    UINT32_Marshal(&parameter_size, buffer, size);
29
0
  }
30
  // Marshal response parameters.
31
15
  total_size += TPM2B_NONCE_Marshal(&source->nonceTPM, buffer, size);
32
  // Compute actual parameter_size. Don't add result to total_size.
33
15
  if (tag == TPM_ST_SESSIONS) {
34
0
    parameter_size = total_size - num_response_handles * sizeof(TPM_HANDLE);
35
0
    UINT32_Marshal(&parameter_size, &parameter_size_location,
36
0
                   &parameter_size_size);
37
0
  }
38
15
  return total_size;
39
15
}
40
#endif
41
42
static TPM_RC StartAuthSession_In_Unmarshal(StartAuthSession_In* target,
43
                                            TPM_HANDLE request_handles[],
44
                                            BYTE** buffer,
45
141
                                            INT32* size) {
46
141
  TPM_RC result = TPM_RC_SUCCESS;
47
  // Get request handles from request_handles array.
48
141
  target->tpmKey = request_handles[0];
49
141
  target->bind = request_handles[1];
50
  // Unmarshal request parameters.
51
141
  result = TPM2B_NONCE_Unmarshal(&target->nonceCaller, buffer, size);
52
141
  if (result != TPM_RC_SUCCESS) {
53
26
    return result;
54
26
  }
55
115
  result =
56
115
      TPM2B_ENCRYPTED_SECRET_Unmarshal(&target->encryptedSalt, buffer, size);
57
115
  if (result != TPM_RC_SUCCESS) {
58
31
    return result;
59
31
  }
60
84
  result = TPM_SE_Unmarshal(&target->sessionType, buffer, size);
61
84
  if (result != TPM_RC_SUCCESS) {
62
17
    return result;
63
17
  }
64
67
  result = TPMT_SYM_DEF_Unmarshal(&target->symmetric, buffer, size);
65
67
  if (result != TPM_RC_SUCCESS) {
66
26
    return result;
67
26
  }
68
41
  result = TPMI_ALG_HASH_Unmarshal(&target->authHash, buffer, size, FALSE);
69
41
  if (result != TPM_RC_SUCCESS) {
70
15
    return result;
71
15
  }
72
26
  if ((result == TPM_RC_SUCCESS) && *size) {
73
1
    result = TPM_RC_SIZE;
74
1
  }
75
26
  return result;
76
41
}
77
78
TPM_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
141
                             UINT32* response_parameter_buffer_size) {
84
141
  TPM_RC result = TPM_RC_SUCCESS;
85
141
  StartAuthSession_In in;
86
141
  StartAuthSession_Out out;
87
141
#if IS_CC_ENABLED(StartAuthSession)
88
141
  BYTE* response_buffer;
89
141
  INT32 response_buffer_size;
90
141
  UINT16 bytes_marshalled;
91
141
  UINT16 num_response_handles = 1;
92
141
#endif
93
141
  *response_handle_buffer_size = 0;
94
141
  *response_parameter_buffer_size = 0;
95
  // Unmarshal request parameters to input structure.
96
141
  result = StartAuthSession_In_Unmarshal(&in, request_handles,
97
141
                                         request_parameter_buffer,
98
141
                                         request_parameter_buffer_size);
99
141
  if (result != TPM_RC_SUCCESS) {
100
116
    return result;
101
116
  }
102
  // Execute command.
103
25
  result = TPM2_StartAuthSession(&in, &out);
104
25
  if (result != TPM_RC_SUCCESS) {
105
10
    return result;
106
10
  }
107
// Marshal output structure to global response buffer.
108
15
#if IS_CC_ENABLED(StartAuthSession)
109
15
  response_buffer = MemoryGetResponseBuffer(TPM_CC_StartAuthSession) + 10;
110
15
  response_buffer_size = MAX_RESPONSE_SIZE - 10;
111
15
  bytes_marshalled = StartAuthSession_Out_Marshal(&out, tag, &response_buffer,
112
15
                                                  &response_buffer_size);
113
15
  *response_handle_buffer_size = num_response_handles * sizeof(TPM_HANDLE);
114
15
  *response_parameter_buffer_size =
115
15
      bytes_marshalled - *response_handle_buffer_size;
116
15
  return TPM_RC_SUCCESS;
117
0
#endif
118
0
  return TPM_RC_COMMAND_CODE;
119
25
}