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

Side by Side Diff: vboot_firmware/lib/vboot_common.c

Issue 2848006: Refactor LoadFrmware() to avoid global variables, which don't work when running out of ROM (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Undo change to vboot_struct 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 unified diff | Download patch
« no previous file with comments | « vboot_firmware/lib/load_firmware_fw.c ('k') | vboot_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) 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 * Common functions between firmware and kernel verified boot. 5 * Common functions between firmware and kernel verified boot.
6 * (Firmware portion) 6 * (Firmware portion)
7 */ 7 */
8 8
9 9
10 #include "vboot_common.h" 10 #include "vboot_common.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 79
80 int VerifySignatureInside(const void* parent, uint64_t parent_size, 80 int VerifySignatureInside(const void* parent, uint64_t parent_size,
81 const VbSignature* sig) { 81 const VbSignature* sig) {
82 return VerifyMemberInside(parent, parent_size, 82 return VerifyMemberInside(parent, parent_size,
83 sig, sizeof(VbSignature), 83 sig, sizeof(VbSignature),
84 sig->sig_offset, sig->sig_size); 84 sig->sig_offset, sig->sig_size);
85 } 85 }
86 86
87 87
88 void PublicKeyInit(VbPublicKey* key, uint8_t* key_data, uint64_t key_size) {
89 key->key_offset = OffsetOf(key, key_data);
90 key->key_size = key_size;
91 key->algorithm = kNumAlgorithms; /* Key not present yet */
92 key->key_version = 0;
93 }
94
95
96 int PublicKeyCopy(VbPublicKey* dest, const VbPublicKey* src) {
97 if (dest->key_size < src->key_size)
98 return 1;
99
100 dest->key_size = src->key_size;
101 dest->algorithm = src->algorithm;
102 dest->key_version = src->key_version;
103 Memcpy(GetPublicKeyData(dest), GetPublicKeyDataC(src), src->key_size);
104 return 0;
105 }
106
107
88 RSAPublicKey* PublicKeyToRSA(const VbPublicKey* key) { 108 RSAPublicKey* PublicKeyToRSA(const VbPublicKey* key) {
89 RSAPublicKey *rsa; 109 RSAPublicKey *rsa;
90 110
91 if (kNumAlgorithms <= key->algorithm) { 111 if (kNumAlgorithms <= key->algorithm) {
92 debug("Invalid algorithm.\n"); 112 debug("Invalid algorithm.\n");
93 return NULL; 113 return NULL;
94 } 114 }
95 if (RSAProcessedKeySize(key->algorithm) != key->key_size) { 115 if (RSAProcessedKeySize(key->algorithm) != key->key_size) {
96 debug("Wrong key size for algorithm\n"); 116 debug("Wrong key size for algorithm\n");
97 return NULL; 117 return NULL;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 /* Verify body signature is inside the block */ 332 /* Verify body signature is inside the block */
313 if (VerifySignatureInside(preamble, preamble->preamble_size, 333 if (VerifySignatureInside(preamble, preamble->preamble_size,
314 &preamble->body_signature)) { 334 &preamble->body_signature)) {
315 debug("Kernel body signature off end of preamble\n"); 335 debug("Kernel body signature off end of preamble\n");
316 return VBOOT_PREAMBLE_INVALID; 336 return VBOOT_PREAMBLE_INVALID;
317 } 337 }
318 338
319 /* Success */ 339 /* Success */
320 return VBOOT_SUCCESS; 340 return VBOOT_SUCCESS;
321 } 341 }
OLDNEW
« no previous file with comments | « vboot_firmware/lib/load_firmware_fw.c ('k') | vboot_firmware/lib/vboot_firmware.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698