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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 *pout_len = n; | 77 *pout_len = n; |
78 Memcpy(out, response, n); | 78 Memcpy(out, response, n); |
79 } | 79 } |
80 } | 80 } |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 | 84 |
85 /* Gets the tag field of a TPM command. | 85 /* Gets the tag field of a TPM command. |
86 */ | 86 */ |
87 POSSIBLY_UNUSED static INLINE int TpmTag(uint8_t* buffer) { | 87 POSSIBLY_UNUSED static INLINE int TpmTag(const uint8_t* buffer) { |
88 uint16_t tag; | 88 uint16_t tag; |
89 FromTpmUint16(buffer, &tag); | 89 FromTpmUint16(buffer, &tag); |
90 return (int) tag; | 90 return (int) tag; |
91 } | 91 } |
92 | 92 |
93 | 93 |
94 /* Gets the size field of a TPM command. | 94 /* Gets the size field of a TPM command. |
95 */ | 95 */ |
96 POSSIBLY_UNUSED static INLINE int TpmResponseSize(const uint8_t* buffer) { | 96 POSSIBLY_UNUSED static INLINE int TpmResponseSize(const uint8_t* buffer) { |
97 uint32_t size; | 97 uint32_t size; |
(...skipping 24 matching lines...) Expand all Loading... |
122 device_path = TPM_DEVICE_PATH; | 122 device_path = TPM_DEVICE_PATH; |
123 } | 123 } |
124 | 124 |
125 tpm_fd = open(device_path, O_RDWR); | 125 tpm_fd = open(device_path, O_RDWR); |
126 if (tpm_fd < 0) { | 126 if (tpm_fd < 0) { |
127 error("cannot open TPM device %s: %s\n", device_path, strerror(errno)); | 127 error("cannot open TPM device %s: %s\n", device_path, strerror(errno)); |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 | 131 |
132 uint32_t TlclStubSendReceive(uint8_t* request, int request_length, | 132 uint32_t TlclStubSendReceive(const uint8_t* request, int request_length, |
133 uint8_t* response, int max_length) { | 133 uint8_t* response, int max_length) { |
134 /* | 134 /* |
135 * In a real firmware implementation, this function should contain | 135 * In a real firmware implementation, this function should contain |
136 * the equivalent API call for the firmware TPM driver which takes a | 136 * the equivalent API call for the firmware TPM driver which takes a |
137 * raw sequence of bytes as input command and a pointer to the | 137 * raw sequence of bytes as input command and a pointer to the |
138 * output buffer for putting in the results. | 138 * output buffer for putting in the results. |
139 * | 139 * |
140 * For EFI firmwares, this can make use of the EFI TPM driver as | 140 * For EFI firmwares, this can make use of the EFI TPM driver as |
141 * follows (based on page 16, of TCG EFI Protocol Specs Version 1.20 | 141 * follows (based on page 16, of TCG EFI Protocol Specs Version 1.20 |
142 * availaible from the TCG website): | 142 * availaible from the TCG website): |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 (tag == TPM_TAG_RQU_COMMAND && | 179 (tag == TPM_TAG_RQU_COMMAND && |
180 response_tag == TPM_TAG_RSP_COMMAND) || | 180 response_tag == TPM_TAG_RSP_COMMAND) || |
181 (tag == TPM_TAG_RQU_AUTH1_COMMAND && | 181 (tag == TPM_TAG_RQU_AUTH1_COMMAND && |
182 response_tag == TPM_TAG_RSP_AUTH1_COMMAND) || | 182 response_tag == TPM_TAG_RSP_AUTH1_COMMAND) || |
183 (tag == TPM_TAG_RQU_AUTH2_COMMAND && | 183 (tag == TPM_TAG_RQU_AUTH2_COMMAND && |
184 response_tag == TPM_TAG_RSP_AUTH2_COMMAND)); | 184 response_tag == TPM_TAG_RSP_AUTH2_COMMAND)); |
185 assert(response_length == TpmResponseSize(response)); | 185 assert(response_length == TpmResponseSize(response)); |
186 | 186 |
187 return 0; /* Success */ | 187 return 0; /* Success */ |
188 } | 188 } |
OLD | NEW |