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

Side by Side Diff: firmware/lib/tpm_bootmode.c

Issue 6676039: Fix compiler errors on MSVC (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: ...and fix gcc again Created 9 years, 9 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/rollback_index.c ('k') | firmware/lib/vboot_firmware.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) 2011 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2011 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 * Functions for updating the TPM state with the status of boot path. 5 * Functions for updating the TPM state with the status of boot path.
6 */ 6 */
7 7
8 #include "tpm_bootmode.h" 8 #include "tpm_bootmode.h"
9 9
10 #include "tlcl.h" 10 #include "tlcl.h"
(...skipping 10 matching lines...) Expand all
21 * Keyblock flags are defined in vboot_struct.h 21 * Keyblock flags are defined in vboot_struct.h
22 * 22 *
23 * We map them to Keyblock_Mode as follows: 23 * We map them to Keyblock_Mode as follows:
24 * ----------------------------------------- 24 * -----------------------------------------
25 * Keyblock Flags | Keyblock Mode 25 * Keyblock Flags | Keyblock Mode
26 * ----------------------------------------- 26 * -----------------------------------------
27 * 6 (Dev-signed firmware) | 2 27 * 6 (Dev-signed firmware) | 2
28 * 7 Normal-signed firmware | 1 28 * 7 Normal-signed firmware | 1
29 * (anything else) | 0 29 * (anything else) | 0
30 */ 30 */
31 const uint8_t kBootStateSHA1Digests[][20] = { 31
32 const char* kBootStateSHA1Digests[] = {
32 /* SHA1("\x00\x00\x00") */ 33 /* SHA1("\x00\x00\x00") */
33 "\x29\xe2\xdc\xfb\xb1\x6f\x63\xbb\x02\x54\xdf\x75\x85\xa1\x5b\xb6" 34 "\x29\xe2\xdc\xfb\xb1\x6f\x63\xbb\x02\x54\xdf\x75\x85\xa1\x5b\xb6"
34 "\xfb\x5e\x92\x7d", 35 "\xfb\x5e\x92\x7d",
35 36
36 /* SHA1("\x00\x00\x01") */ 37 /* SHA1("\x00\x00\x01") */
37 "\x25\x47\xcc\x73\x6e\x95\x1f\xa4\x91\x98\x53\xc4\x3a\xe8\x90\x86" 38 "\x25\x47\xcc\x73\x6e\x95\x1f\xa4\x91\x98\x53\xc4\x3a\xe8\x90\x86"
38 "\x1a\x3b\x32\x64", 39 "\x1a\x3b\x32\x64",
39 40
40 /* SHA1("\x00\x00\x02") */ 41 /* SHA1("\x00\x00\x02") */
41 "\x1e\xf6\x24\x48\x2d\x62\x0e\x43\xe6\xd3\x4d\xa1\xaf\xe4\x62\x67" 42 "\x1e\xf6\x24\x48\x2d\x62\x0e\x43\xe6\xd3\x4d\xa1\xaf\xe4\x62\x67"
(...skipping 29 matching lines...) Expand all
71 72
72 /* SHA1("\x01\x01\x01") */ 73 /* SHA1("\x01\x01\x01") */
73 "\x28\xd8\x6c\x56\xb3\xbf\x26\xd2\x36\x56\x9b\x8d\xc8\xc3\xf9\x1f" 74 "\x28\xd8\x6c\x56\xb3\xbf\x26\xd2\x36\x56\x9b\x8d\xc8\xc3\xf9\x1f"
74 "\x32\xf4\x7b\xc7", 75 "\x32\xf4\x7b\xc7",
75 76
76 /* SHA1("\x01\x01\x02") */ 77 /* SHA1("\x01\x01\x02") */
77 "\x12\xa3\x40\xd7\x89\x7f\xe7\x13\xfc\x8f\x02\xac\x53\x65\xb8\x6e" 78 "\x12\xa3\x40\xd7\x89\x7f\xe7\x13\xfc\x8f\x02\xac\x53\x65\xb8\x6e"
78 "\xbf\x35\x31\x78", 79 "\xbf\x35\x31\x78",
79 }; 80 };
80 81
81 #define MAX_BOOT_STATE_INDEX (sizeof(kBootStateSHA1Digests)/sizeof(char[20])) 82 #define MAX_BOOT_STATE_INDEX (sizeof(kBootStateSHA1Digests)/sizeof(char*))
82 83
83 /* Used for PCR extend when the passed-in boot state is invalid or 84 /* Used for PCR extend when the passed-in boot state is invalid or
84 * if there is an internal error. */ 85 * if there is an internal error. */
85 const uint8_t kBootInvalidSHA1Digest[20] = { 86 const uint8_t kBootInvalidSHA1Digest[] = {
86 "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" 87 "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
87 "\xff\xff\xff\xff" 88 "\xff\xff\xff\xff"
88 }; 89 };
89 90
90 /* Given the boot state, return the correct SHA1 digest index for TPMExtend 91 /* Given the boot state, return the correct SHA1 digest index for TPMExtend
91 * in kBootStateSHA1Digests[]. */ 92 * in kBootStateSHA1Digests[]. */
92 int GetBootStateIndex(int dev_mode, int rec_mode, int keyblock_flags) { 93 int GetBootStateIndex(int dev_mode, int rec_mode, int keyblock_flags) {
93 int index = 0; 94 int index = 0;
94 95
95 /* Convert keyblock flags into keyblock mode which we use to index into 96 /* Convert keyblock flags into keyblock mode which we use to index into
(...skipping 20 matching lines...) Expand all
116 117
117 uint32_t SetTPMBootModeState(int developer_mode, int recovery_mode, 118 uint32_t SetTPMBootModeState(int developer_mode, int recovery_mode,
118 int fw_keyblock_flags) { 119 int fw_keyblock_flags) {
119 uint32_t result; 120 uint32_t result;
120 const uint8_t* in_digest = NULL; 121 const uint8_t* in_digest = NULL;
121 uint8_t out_digest[20]; /* For PCR extend output. */ 122 uint8_t out_digest[20]; /* For PCR extend output. */
122 int digest_index = GetBootStateIndex(developer_mode, recovery_mode, 123 int digest_index = GetBootStateIndex(developer_mode, recovery_mode,
123 fw_keyblock_flags); 124 fw_keyblock_flags);
124 125
125 if (digest_index >= 0 && digest_index < MAX_BOOT_STATE_INDEX) 126 if (digest_index >= 0 && digest_index < MAX_BOOT_STATE_INDEX)
126 in_digest = kBootStateSHA1Digests[digest_index]; 127 in_digest = (const uint8_t*)kBootStateSHA1Digests[digest_index];
127 else 128 else
128 in_digest = kBootInvalidSHA1Digest; /* Internal out of bounds error. */ 129 in_digest = kBootInvalidSHA1Digest; /* Internal out of bounds error. */
129 result = TlclExtend(BOOT_MODE_PCR, in_digest, out_digest); 130 result = TlclExtend(BOOT_MODE_PCR, in_digest, out_digest);
130 VBDEBUG(("TPM: SetTPMBootModeState boot mode PCR out_digest %02x %02x %02x " 131 VBDEBUG(("TPM: SetTPMBootModeState boot mode PCR out_digest %02x %02x %02x "
131 "%02x\n", out_digest, out_digest+1, out_digest+2, out_digest+3)); 132 "%02x\n", out_digest, out_digest+1, out_digest+2, out_digest+3));
132 return result; 133 return result;
133 } 134 }
OLDNEW
« no previous file with comments | « firmware/lib/rollback_index.c ('k') | firmware/lib/vboot_firmware.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698