| OLD | NEW |
| 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 * Host functions for verified boot. | 5 * Host functions for verified boot. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 /* TODO: change all 'return 0', 'return 1' into meaningful return codes */ | 8 /* TODO: change all 'return 0', 'return 1' into meaningful return codes */ |
| 9 | 9 |
| 10 #include "host_common.h" | 10 #include "host_common.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 uint8_t* body_sig_dest; | 87 uint8_t* body_sig_dest; |
| 88 uint8_t* block_sig_dest; | 88 uint8_t* block_sig_dest; |
| 89 VbSignature *sigtmp; | 89 VbSignature *sigtmp; |
| 90 | 90 |
| 91 /* If the block size is smaller than the desired size, pad it */ | 91 /* If the block size is smaller than the desired size, pad it */ |
| 92 if (block_size < desired_size) | 92 if (block_size < desired_size) |
| 93 block_size = desired_size; | 93 block_size = desired_size; |
| 94 | 94 |
| 95 /* Allocate key block */ | 95 /* Allocate key block */ |
| 96 h = (VbKernelPreambleHeader*)Malloc(block_size); | 96 h = (VbKernelPreambleHeader*)Malloc(block_size); |
| 97 Memset(h, 0, block_size); |
| 98 |
| 97 if (!h) | 99 if (!h) |
| 98 return NULL; | 100 return NULL; |
| 99 body_sig_dest = (uint8_t*)(h + 1); | 101 body_sig_dest = (uint8_t*)(h + 1); |
| 100 block_sig_dest = body_sig_dest + body_signature->sig_size; | 102 block_sig_dest = body_sig_dest + body_signature->sig_size; |
| 101 | 103 |
| 102 h->header_version_major = KERNEL_PREAMBLE_HEADER_VERSION_MAJOR; | 104 h->header_version_major = KERNEL_PREAMBLE_HEADER_VERSION_MAJOR; |
| 103 h->header_version_minor = KERNEL_PREAMBLE_HEADER_VERSION_MINOR; | 105 h->header_version_minor = KERNEL_PREAMBLE_HEADER_VERSION_MINOR; |
| 104 h->preamble_size = block_size; | 106 h->preamble_size = block_size; |
| 105 h->kernel_version = kernel_version; | 107 h->kernel_version = kernel_version; |
| 106 h->body_load_address = body_load_address; | 108 h->body_load_address = body_load_address; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 117 siglen_map[signing_key->algorithm], signed_size); | 119 siglen_map[signing_key->algorithm], signed_size); |
| 118 | 120 |
| 119 /* Calculate signature */ | 121 /* Calculate signature */ |
| 120 sigtmp = CalculateSignature((uint8_t*)h, signed_size, signing_key); | 122 sigtmp = CalculateSignature((uint8_t*)h, signed_size, signing_key); |
| 121 SignatureCopy(&h->preamble_signature, sigtmp); | 123 SignatureCopy(&h->preamble_signature, sigtmp); |
| 122 Free(sigtmp); | 124 Free(sigtmp); |
| 123 | 125 |
| 124 /* Return the header */ | 126 /* Return the header */ |
| 125 return h; | 127 return h; |
| 126 } | 128 } |
| OLD | NEW |