Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(990)

Side by Side Diff: firmware/lib/tpm_lite/tlcl.c

Issue 3271006: Make TPM datagrams const, since they cannot be modified in the RO firmware. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « firmware/lib/tpm_lite/include/tlcl_structures.h ('k') | firmware/stub/tpm_lite_stub.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5
6 /* A lightweight TPM command library. 6 /* A lightweight TPM command library.
7 * 7 *
8 * The general idea is that TPM commands are array of bytes whose 8 * The general idea is that TPM commands are array of bytes whose
9 * fields are mostly compile-time constant. The goal is to build much 9 * fields are mostly compile-time constant. The goal is to build much
10 * of the commands at compile time (or build time) and change some of 10 * of the commands at compile time (or build time) and change some of
(...skipping 29 matching lines...) Expand all
40 return code; 40 return code;
41 } 41 }
42 42
43 /* Gets the return code field of a TPM result. */ 43 /* Gets the return code field of a TPM result. */
44 static INLINE int TpmReturnCode(const uint8_t* buffer) { 44 static INLINE int TpmReturnCode(const uint8_t* buffer) {
45 return TpmCommandCode(buffer); 45 return TpmCommandCode(buffer);
46 } 46 }
47 47
48 /* Sends a TPM command and gets a response. Returns 0 if success or the TPM 48 /* Sends a TPM command and gets a response. Returns 0 if success or the TPM
49 * error code if error. */ 49 * error code if error. */
50 static uint32_t TlclSendReceive(uint8_t* request, uint8_t* response, 50 static uint32_t TlclSendReceive(const uint8_t* request, uint8_t* response,
51 int max_length) { 51 int max_length) {
52 52
53 uint32_t result; 53 uint32_t result;
54 54
55 #ifdef EXTRA_LOGGING 55 #ifdef EXTRA_LOGGING
56 VBDEBUG(("TPM: command: %x%x %x%x%x%x %x%x%x%x\n", 56 VBDEBUG(("TPM: command: %x%x %x%x%x%x %x%x%x%x\n",
57 request[0], request[1], 57 request[0], request[1],
58 request[2], request[3], request[4], request[5], 58 request[2], request[3], request[4], request[5],
59 request[6], request[7], request[8], request[9])); 59 request[6], request[7], request[8], request[9]));
60 #endif 60 #endif
(...skipping 17 matching lines...) Expand all
78 #endif 78 #endif
79 79
80 VBDEBUG(("TPM: command 0x%x returned 0x%x\n", 80 VBDEBUG(("TPM: command 0x%x returned 0x%x\n",
81 TpmCommandCode(request), result)); 81 TpmCommandCode(request), result));
82 82
83 return result; 83 return result;
84 } 84 }
85 85
86 86
87 /* Sends a command and returns the error code. */ 87 /* Sends a command and returns the error code. */
88 static uint32_t Send(uint8_t* command) { 88 static uint32_t Send(const uint8_t* command) {
89 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE]; 89 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
90 return TlclSendReceive(command, response, sizeof(response)); 90 return TlclSendReceive(command, response, sizeof(response));
91 } 91 }
92 92
93 /* Exported functions. */ 93 /* Exported functions. */
94 94
95 void TlclLibInit(void) { 95 void TlclLibInit(void) {
96 TlclStubInit(); 96 TlclStubInit();
97 } 97 }
98 98
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 Memcpy(&cmd, &tpm_getpermissions_cmd, sizeof(cmd)); 319 Memcpy(&cmd, &tpm_getpermissions_cmd, sizeof(cmd));
320 ToTpmUint32(cmd.buffer + tpm_getpermissions_cmd.index, index); 320 ToTpmUint32(cmd.buffer + tpm_getpermissions_cmd.index, index);
321 result = TlclSendReceive(cmd.buffer, response, sizeof(response)); 321 result = TlclSendReceive(cmd.buffer, response, sizeof(response));
322 if (result != TPM_SUCCESS) 322 if (result != TPM_SUCCESS)
323 return result; 323 return result;
324 324
325 nvdata = response + kTpmResponseHeaderLength + sizeof(size); 325 nvdata = response + kTpmResponseHeaderLength + sizeof(size);
326 FromTpmUint32(nvdata + kNvDataPublicPermissionsOffset, permissions); 326 FromTpmUint32(nvdata + kNvDataPublicPermissionsOffset, permissions);
327 return result; 327 return result;
328 } 328 }
OLDNEW
« no previous file with comments | « firmware/lib/tpm_lite/include/tlcl_structures.h ('k') | firmware/stub/tpm_lite_stub.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698