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

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

Issue 6719005: Cherry-pick vboot_reference files from TOT to support crossystem (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@0.11.257.B
Patch Set: 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/tpm_lite/tlcl.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 * 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 VBDEBUG(("Kernel body signature off end of preamble\n")); 374 VBDEBUG(("Kernel body signature off end of preamble\n"));
375 return VBOOT_PREAMBLE_INVALID; 375 return VBOOT_PREAMBLE_INVALID;
376 } 376 }
377 377
378 /* Success */ 378 /* Success */
379 return VBOOT_SUCCESS; 379 return VBOOT_SUCCESS;
380 } 380 }
381 381
382 382
383 int VbSharedDataInit(VbSharedDataHeader* header, uint64_t size) { 383 int VbSharedDataInit(VbSharedDataHeader* header, uint64_t size) {
384
385 VBDEBUG(("VbSharedDataInit, %d bytes, header %d bytes\n", (int)size,
386 sizeof(VbSharedDataHeader)));
387
384 if (size < sizeof(VbSharedDataHeader)) { 388 if (size < sizeof(VbSharedDataHeader)) {
385 VBDEBUG(("Not enough data for header.\n")); 389 VBDEBUG(("Not enough data for header.\n"));
386 return VBOOT_SHARED_DATA_INVALID; 390 return VBOOT_SHARED_DATA_INVALID;
387 } 391 }
388 if (size < VB_SHARED_DATA_MIN_SIZE) { 392 if (size < VB_SHARED_DATA_MIN_SIZE) {
389 VBDEBUG(("Shared data buffer too small.\n")); 393 VBDEBUG(("Shared data buffer too small.\n"));
390 return VBOOT_SHARED_DATA_INVALID; 394 return VBOOT_SHARED_DATA_INVALID;
391 } 395 }
392 396
393 if (!header) 397 if (!header)
394 return VBOOT_SHARED_DATA_INVALID; 398 return VBOOT_SHARED_DATA_INVALID;
395 399
396 /* Zero the header */ 400 /* Zero the header */
397 Memset(header, 0, sizeof(VbSharedDataHeader)); 401 Memset(header, 0, sizeof(VbSharedDataHeader));
398 402
399 /* Initialize fields */ 403 /* Initialize fields */
404 header->magic = VB_SHARED_DATA_MAGIC;
400 header->struct_version = VB_SHARED_DATA_VERSION; 405 header->struct_version = VB_SHARED_DATA_VERSION;
401 header->struct_size = sizeof(VbSharedDataHeader); 406 header->struct_size = sizeof(VbSharedDataHeader);
402 header->data_size = size; 407 header->data_size = size;
403 header->data_used = sizeof(VbSharedDataHeader); 408 header->data_used = sizeof(VbSharedDataHeader);
409 header->firmware_index = 0xFF;
404 410
405 /* Success */ 411 /* Success */
406 return VBOOT_SUCCESS; 412 return VBOOT_SUCCESS;
407 } 413 }
408 414
409 415
410 uint64_t VbSharedDataReserve(VbSharedDataHeader* header, uint64_t size) { 416 uint64_t VbSharedDataReserve(VbSharedDataHeader* header, uint64_t size) {
411 uint64_t offs = header->data_used; 417 uint64_t offs = header->data_used;
412 418
419 VBDEBUG(("VbSharedDataReserve %d bytes at %d\n", (int)size, (int)offs));
420
413 if (!header || size > header->data_size - header->data_used) { 421 if (!header || size > header->data_size - header->data_used) {
414 VBDEBUG(("VbSharedData buffer out of space.\n")); 422 VBDEBUG(("VbSharedData buffer out of space.\n"));
415 return 0; /* Not initialized, or not enough space left. */ 423 return 0; /* Not initialized, or not enough space left. */
416 } 424 }
417 header->data_used += size; 425 header->data_used += size;
418 return offs; 426 return offs;
419 } 427 }
420 428
421 429
422 int VbSharedDataSetKernelKey(VbSharedDataHeader* header, 430 int VbSharedDataSetKernelKey(VbSharedDataHeader* header,
(...skipping 12 matching lines...) Expand all
435 return VBOOT_SHARED_DATA_INVALID; 443 return VBOOT_SHARED_DATA_INVALID;
436 header->kernel_subkey_data_size = src->key_size; 444 header->kernel_subkey_data_size = src->key_size;
437 } 445 }
438 446
439 /* Copy the kernel sign key blob into the destination buffer */ 447 /* Copy the kernel sign key blob into the destination buffer */
440 PublicKeyInit(kdest, (uint8_t*)header + header->kernel_subkey_data_offset, 448 PublicKeyInit(kdest, (uint8_t*)header + header->kernel_subkey_data_offset,
441 header->kernel_subkey_data_size); 449 header->kernel_subkey_data_size);
442 450
443 return PublicKeyCopy(kdest, src); 451 return PublicKeyCopy(kdest, src);
444 } 452 }
OLDNEW
« no previous file with comments | « firmware/lib/tpm_lite/tlcl.c ('k') | firmware/lib/vboot_firmware.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698