| 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_keyblock.h" | 10 #include "host_keyblock.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 * pointer, and must free it with Free(). | 71 * pointer, and must free it with Free(). |
| 72 * | 72 * |
| 73 * Returns NULL if error. */ | 73 * Returns NULL if error. */ |
| 74 VbKeyBlockHeader* KeyBlockRead(const char* filename) { | 74 VbKeyBlockHeader* KeyBlockRead(const char* filename) { |
| 75 | 75 |
| 76 VbKeyBlockHeader* block; | 76 VbKeyBlockHeader* block; |
| 77 uint64_t file_size; | 77 uint64_t file_size; |
| 78 | 78 |
| 79 block = (VbKeyBlockHeader*)ReadFile(filename, &file_size); | 79 block = (VbKeyBlockHeader*)ReadFile(filename, &file_size); |
| 80 if (!block) { | 80 if (!block) { |
| 81 debug("Error reading key block file: %s\n", filename); | 81 VBDEBUG(("Error reading key block file: %s\n", filename)); |
| 82 return NULL; | 82 return NULL; |
| 83 } | 83 } |
| 84 | 84 |
| 85 /* Verify the hash of the key block, since we can do that without | 85 /* Verify the hash of the key block, since we can do that without |
| 86 * the public signing key. */ | 86 * the public signing key. */ |
| 87 if (0 != KeyBlockVerify(block, file_size, NULL)) { | 87 if (0 != KeyBlockVerify(block, file_size, NULL)) { |
| 88 debug("Invalid key block file: filename\n", filename); | 88 VBDEBUG(("Invalid key block file: filename\n", filename)); |
| 89 Free(block); | 89 Free(block); |
| 90 return NULL; | 90 return NULL; |
| 91 } | 91 } |
| 92 | 92 |
| 93 return block; | 93 return block; |
| 94 } | 94 } |
| 95 | 95 |
| 96 | 96 |
| 97 /* Write a key block to a file in .keyblock format. */ | 97 /* Write a key block to a file in .keyblock format. */ |
| 98 int KeyBlockWrite(const char* filename, const VbKeyBlockHeader* key_block) { | 98 int KeyBlockWrite(const char* filename, const VbKeyBlockHeader* key_block) { |
| 99 | 99 |
| 100 if (0 != WriteFile(filename, key_block, key_block->key_block_size)) { | 100 if (0 != WriteFile(filename, key_block, key_block->key_block_size)) { |
| 101 debug("KeyBlockWrite() error writing key block\n"); | 101 VBDEBUG(("KeyBlockWrite() error writing key block\n")); |
| 102 return 1; | 102 return 1; |
| 103 } | 103 } |
| 104 | 104 |
| 105 return 0; | 105 return 0; |
| 106 } | 106 } |
| OLD | NEW |