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

Side by Side Diff: utility/vbutil_keyblock.c

Issue 3602014: Display keyblock information, even if not checking the signature. (Closed) Base URL: http://git.chromium.org/git/vboot_reference.git
Patch Set: Created 10 years, 2 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 | « no previous file | no next file » | 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 * Verified boot key block utility 5 * Verified boot key block utility
6 */ 6 */
7 7
8 #include <getopt.h> 8 #include <getopt.h>
9 #include <inttypes.h> /* For PRIu64 */ 9 #include <inttypes.h> /* For PRIu64 */
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 120 }
121 121
122 block = KeyBlockRead(infile); 122 block = KeyBlockRead(infile);
123 if (!block) { 123 if (!block) {
124 fprintf(stderr, "vbutil_keyblock: Error reading key block.\n"); 124 fprintf(stderr, "vbutil_keyblock: Error reading key block.\n");
125 return 1; 125 return 1;
126 } 126 }
127 127
128 /* If the block is signed, then verify it with the signing public key, since 128 /* If the block is signed, then verify it with the signing public key, since
129 KeyBlockRead() only verified the hash. */ 129 KeyBlockRead() only verified the hash. */
130 if (block->key_block_signature.sig_size) { 130 if (block->key_block_signature.sig_size && signpubkey) {
131 if (!signpubkey) {
132 fprintf(stderr,
133 "vbutil_keyblock: keyblock requires public key to verify\n");
134 return 1;
135 }
136 sign_key = PublicKeyRead(signpubkey); 131 sign_key = PublicKeyRead(signpubkey);
137 if (!sign_key) { 132 if (!sign_key) {
138 fprintf(stderr, "vbutil_keyblock: Error reading signpubkey.\n"); 133 fprintf(stderr, "vbutil_keyblock: Error reading signpubkey.\n");
139 return 1; 134 return 1;
140 } 135 }
141 if (0 != KeyBlockVerify(block, block->key_block_size, sign_key, 0)) { 136 if (0 != KeyBlockVerify(block, block->key_block_size, sign_key, 0)) {
142 fprintf(stderr, "vbutil_keyblock: Error verifying key block.\n"); 137 fprintf(stderr, "vbutil_keyblock: Error verifying key block.\n");
143 return 1; 138 return 1;
144 } 139 }
145 printf("Signature algorithm: %" PRIu64 " %s\n", sign_key->algorithm,
146 (sign_key->algorithm < kNumAlgorithms ?
147 algo_strings[sign_key->algorithm] : "(invalid)"));
148 Free(sign_key); 140 Free(sign_key);
149 } else {
150 printf("Signature Algorithm: <none>\n");
151 } 141 }
152 142
153 printf("Key block file: %s\n", infile); 143 printf("Key block file: %s\n", infile);
154 printf("Flags: %" PRIu64 "\n", block->key_block_flags); 144 printf("Signature %s\n", sign_key ? "valid" : "ignored");
145 printf("Flags: %" PRIu64 " ", block->key_block_flags);
155 if (block->key_block_flags & KEY_BLOCK_FLAG_DEVELOPER_0) 146 if (block->key_block_flags & KEY_BLOCK_FLAG_DEVELOPER_0)
156 printf(" !DEV"); 147 printf(" !DEV");
157 if (block->key_block_flags & KEY_BLOCK_FLAG_DEVELOPER_1) 148 if (block->key_block_flags & KEY_BLOCK_FLAG_DEVELOPER_1)
158 printf(" DEV"); 149 printf(" DEV");
159 if (block->key_block_flags & KEY_BLOCK_FLAG_RECOVERY_0) 150 if (block->key_block_flags & KEY_BLOCK_FLAG_RECOVERY_0)
160 printf(" !REC"); 151 printf(" !REC");
161 if (block->key_block_flags & KEY_BLOCK_FLAG_RECOVERY_1) 152 if (block->key_block_flags & KEY_BLOCK_FLAG_RECOVERY_1)
162 printf(" REC"); 153 printf(" REC");
163 printf("\n"); 154 printf("\n");
164 155
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 switch(mode) { 235 switch(mode) {
245 case OPT_MODE_PACK: 236 case OPT_MODE_PACK:
246 return Pack(filename, datapubkey, signprivate, flags); 237 return Pack(filename, datapubkey, signprivate, flags);
247 case OPT_MODE_UNPACK: 238 case OPT_MODE_UNPACK:
248 return Unpack(filename, datapubkey, signpubkey); 239 return Unpack(filename, datapubkey, signpubkey);
249 default: 240 default:
250 printf("Must specify a mode.\n"); 241 printf("Must specify a mode.\n");
251 return PrintHelp(progname); 242 return PrintHelp(progname);
252 } 243 }
253 } 244 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698