Home | History | Annotate | Download | only in tpm2
      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 "PolicyAuthorize_fp.h"
      9 
     10 TPM_RC PolicyAuthorize_In_Unmarshal(PolicyAuthorize_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_DIGEST_Unmarshal(&target->approvedPolicy, buffer, size);
     19   if (result != TPM_RC_SUCCESS) {
     20     return result;
     21   }
     22   result = TPM2B_NONCE_Unmarshal(&target->policyRef, buffer, size);
     23   if (result != TPM_RC_SUCCESS) {
     24     return result;
     25   }
     26   result = TPM2B_NAME_Unmarshal(&target->keySign, buffer, size);
     27   if (result != TPM_RC_SUCCESS) {
     28     return result;
     29   }
     30   result = TPMT_TK_VERIFIED_Unmarshal(&target->checkTicket, buffer, size);
     31   if (result != TPM_RC_SUCCESS) {
     32     return result;
     33   }
     34   if ((result == TPM_RC_SUCCESS) && *size) {
     35     result = TPM_RC_SIZE;
     36   }
     37   return result;
     38 }
     39 
     40 TPM_RC Exec_PolicyAuthorize(TPMI_ST_COMMAND_TAG tag,
     41                             BYTE** request_parameter_buffer,
     42                             INT32* request_parameter_buffer_size,
     43                             TPM_HANDLE request_handles[],
     44                             UINT32* response_handle_buffer_size,
     45                             UINT32* response_parameter_buffer_size) {
     46   TPM_RC result = TPM_RC_SUCCESS;
     47   PolicyAuthorize_In in;
     48 #ifdef TPM_CC_PolicyAuthorize
     49   BYTE* response_buffer;
     50   INT32 response_buffer_size;
     51 #endif
     52   *response_handle_buffer_size = 0;
     53   *response_parameter_buffer_size = 0;
     54   // Unmarshal request parameters to input structure.
     55   result = PolicyAuthorize_In_Unmarshal(&in, request_handles,
     56                                         request_parameter_buffer,
     57                                         request_parameter_buffer_size);
     58   if (result != TPM_RC_SUCCESS) {
     59     return result;
     60   }
     61   // Execute command.
     62   result = TPM2_PolicyAuthorize(&in);
     63   if (result != TPM_RC_SUCCESS) {
     64     return result;
     65   }
     66 #ifdef TPM_CC_PolicyAuthorize
     67   response_buffer = MemoryGetResponseBuffer(TPM_CC_PolicyAuthorize) + 10;
     68   response_buffer_size = MAX_RESPONSE_SIZE - 10;
     69   // Add parameter_size field, always equal to 0 here.
     70   if (tag == TPM_ST_SESSIONS) {
     71     UINT32_Marshal(response_parameter_buffer_size, &response_buffer,
     72                    &response_buffer_size);
     73   }
     74   return TPM_RC_SUCCESS;
     75 #endif
     76   return TPM_RC_COMMAND_CODE;
     77 }
     78