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

Unified Diff: utility/vbutil_keyblock.c

Issue 2729021: Clean up of key block functions (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: More key block cleanup Created 10 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utility/vbutil_kernel.c ('k') | vboot_firmware/lib/include/vboot_common.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utility/vbutil_keyblock.c
diff --git a/utility/vbutil_keyblock.c b/utility/vbutil_keyblock.c
index 860a07cebbc3222e1858322b0af39a379f0b6d9e..43c5f061a7181deb24acfec14533e2cc05fef000 100644
--- a/utility/vbutil_keyblock.c
+++ b/utility/vbutil_keyblock.c
@@ -99,11 +99,11 @@ static int Pack(const char* outfile, const char* datapubkey,
return 1;
}
- block = CreateKeyBlock(data_key, signing_key, flags);
+ block = KeyBlockCreate(data_key, signing_key, flags);
Free(data_key);
Free(signing_key);
- if (0 != WriteFile(outfile, block, block->key_block_size)) {
+ if (0 != KeyBlockWrite(outfile, block)) {
fprintf(stderr, "vbutil_keyblock: Error writing key block.\n");
return 1;
}
@@ -117,7 +117,6 @@ static int Unpack(const char* infile, const char* datapubkey,
VbPublicKey* data_key;
VbPublicKey* sign_key;
VbKeyBlockHeader* block;
- uint64_t block_size;
if (!infile || !signpubkey) {
fprintf(stderr, "vbutil_keyblock: Must specify filename and signpubkey\n");
@@ -130,12 +129,17 @@ static int Unpack(const char* infile, const char* datapubkey,
return 1;
}
- block = (VbKeyBlockHeader*)ReadFile(infile, &block_size);
+ block = KeyBlockRead(infile);
if (!block) {
fprintf(stderr, "vbutil_keyblock: Error reading key block.\n");
return 1;
}
- if (0 != VerifyKeyBlock(block, block_size, sign_key)) {
+ /* Verify the block with the signing public key, since
+ * KeyBlockRead() only verified the hash. */
+ /* TODO: should just print a warning, since self-signed key blocks
+ * won't have a public key; signpubkey should also be an optional
+ * argument. */
+ if (0 != KeyBlockVerify(block, block->key_block_size, sign_key)) {
fprintf(stderr, "vbutil_keyblock: Error verifying key block.\n");
return 1;
}
« no previous file with comments | « utility/vbutil_kernel.c ('k') | vboot_firmware/lib/include/vboot_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698