| OLD | NEW | 
|---|
| 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 
| 2  * Use of this source code is governed by a BSD-style license that can be | 2  * Use of this source code is governed by a BSD-style license that can be | 
| 3  * found in the LICENSE file. | 3  * found in the LICENSE file. | 
| 4  * | 4  * | 
| 5  * Stub implementations of utility functions which call their linux-specific | 5  * Stub implementations of utility functions which call their linux-specific | 
| 6  * equivalents. | 6  * equivalents. | 
| 7  */ | 7  */ | 
| 8 | 8 | 
| 9 #define _STUB_IMPLEMENTATION_ | 9 #define _STUB_IMPLEMENTATION_ | 
| 10 #include "tlcl.h" | 10 #include "tlcl.h" | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 49   } | 49   } | 
| 50 } | 50 } | 
| 51 | 51 | 
| 52 | 52 | 
| 53 /* Executes a command on the TPM. | 53 /* Executes a command on the TPM. | 
| 54  */ | 54  */ | 
| 55 static void TpmExecute(const uint8_t *in, const uint32_t in_len, | 55 static void TpmExecute(const uint8_t *in, const uint32_t in_len, | 
| 56                 uint8_t *out, uint32_t *pout_len) { | 56                 uint8_t *out, uint32_t *pout_len) { | 
| 57   uint8_t response[TPM_MAX_COMMAND_SIZE]; | 57   uint8_t response[TPM_MAX_COMMAND_SIZE]; | 
| 58   if (in_len <= 0) { | 58   if (in_len <= 0) { | 
| 59     error("invalid command length %d\n", in_len); | 59     error("invalid command length %d for command 0x%x\n", in_len, in[9]); | 
| 60   } else if (tpm_fd < 0) { | 60   } else if (tpm_fd < 0) { | 
| 61     error("the TPM device was not opened.  Forgot to call TlclLibInit?\n"); | 61     error("the TPM device was not opened.  Forgot to call TlclLibInit?\n"); | 
| 62   } else { | 62   } else { | 
| 63     int n = write(tpm_fd, in, in_len); | 63     int n = write(tpm_fd, in, in_len); | 
| 64     if (n != in_len) { | 64     if (n != in_len) { | 
| 65       error("write failure to TPM device: %s\n", strerror(errno)); | 65       error("write failure to TPM device: %s\n", strerror(errno)); | 
| 66     } | 66     } | 
| 67     n = read(tpm_fd, response, sizeof(response)); | 67     n = read(tpm_fd, response, sizeof(response)); | 
| 68     if (n == 0) { | 68     if (n == 0) { | 
| 69       error("null read from TPM device\n"); | 69       error("null read from TPM device\n"); | 
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 169   response_tag = TpmTag(response); | 169   response_tag = TpmTag(response); | 
| 170   assert( | 170   assert( | 
| 171     (tag == TPM_TAG_RQU_COMMAND && | 171     (tag == TPM_TAG_RQU_COMMAND && | 
| 172      response_tag == TPM_TAG_RSP_COMMAND) || | 172      response_tag == TPM_TAG_RSP_COMMAND) || | 
| 173     (tag == TPM_TAG_RQU_AUTH1_COMMAND && | 173     (tag == TPM_TAG_RQU_AUTH1_COMMAND && | 
| 174      response_tag == TPM_TAG_RSP_AUTH1_COMMAND) || | 174      response_tag == TPM_TAG_RSP_AUTH1_COMMAND) || | 
| 175     (tag == TPM_TAG_RQU_AUTH2_COMMAND && | 175     (tag == TPM_TAG_RQU_AUTH2_COMMAND && | 
| 176      response_tag == TPM_TAG_RSP_AUTH2_COMMAND)); | 176      response_tag == TPM_TAG_RSP_AUTH2_COMMAND)); | 
| 177   assert(response_length == TpmResponseSize(response)); | 177   assert(response_length == TpmResponseSize(response)); | 
| 178 } | 178 } | 
| OLD | NEW | 
|---|