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

Unified Diff: host/lib/host_keyblock.c

Issue 3124004: Changes to allow user-signed kernels to be generated. (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Respond to feedback Created 10 years, 4 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 | « firmware/version.c ('k') | tests/run_vbutil_tests.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: host/lib/host_keyblock.c
diff --git a/host/lib/host_keyblock.c b/host/lib/host_keyblock.c
index f86f35bdb5f1ec41d370d0caa81ab6b1108732a5..1c1fa1275b84a191f1de96f56f1412dd564384b1 100644
--- a/host/lib/host_keyblock.c
+++ b/host/lib/host_keyblock.c
@@ -22,7 +22,7 @@ VbKeyBlockHeader* KeyBlockCreate(const VbPublicKey* data_key,
VbKeyBlockHeader* h;
uint64_t signed_size = sizeof(VbKeyBlockHeader) + data_key->key_size;
uint64_t block_size = (signed_size + SHA512_DIGEST_SIZE +
- siglen_map[signing_key->algorithm]);
+ (signing_key ? siglen_map[signing_key->algorithm] : 0));
uint8_t* data_key_dest;
uint8_t* block_sig_dest;
uint8_t* block_chk_dest;
@@ -49,8 +49,11 @@ VbKeyBlockHeader* KeyBlockCreate(const VbPublicKey* data_key,
/* Set up signature structs so we can calculate the signatures */
SignatureInit(&h->key_block_checksum, block_chk_dest,
SHA512_DIGEST_SIZE, signed_size);
- SignatureInit(&h->key_block_signature, block_sig_dest,
- siglen_map[signing_key->algorithm], signed_size);
+ if (signing_key)
+ SignatureInit(&h->key_block_signature, block_sig_dest,
+ siglen_map[signing_key->algorithm], signed_size);
+ else
+ Memset(&h->key_block_signature, 0, sizeof(VbSignature));
/* Calculate checksum */
sigtmp = CalculateChecksum((uint8_t*)h, signed_size);
@@ -58,9 +61,11 @@ VbKeyBlockHeader* KeyBlockCreate(const VbPublicKey* data_key,
Free(sigtmp);
/* Calculate signature */
- sigtmp = CalculateSignature((uint8_t*)h, signed_size, signing_key);
- SignatureCopy(&h->key_block_signature, sigtmp);
- Free(sigtmp);
+ if (signing_key) {
+ sigtmp = CalculateSignature((uint8_t*)h, signed_size, signing_key);
+ SignatureCopy(&h->key_block_signature, sigtmp);
+ Free(sigtmp);
+ }
/* Return the header */
return h;
« no previous file with comments | « firmware/version.c ('k') | tests/run_vbutil_tests.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698