| 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 * 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 115 } |
| 116 | 116 |
| 117 if (!RSAVerifyBinary_f(NULL, key, data, sig->data_size, | 117 if (!RSAVerifyBinary_f(NULL, key, data, sig->data_size, |
| 118 GetSignatureDataC(sig), key->algorithm)) | 118 GetSignatureDataC(sig), key->algorithm)) |
| 119 return 1; | 119 return 1; |
| 120 | 120 |
| 121 return 0; | 121 return 0; |
| 122 } | 122 } |
| 123 | 123 |
| 124 | 124 |
| 125 int VerifyDigest(const uint8_t* digest, const VbSignature *sig, |
| 126 const RSAPublicKey* key) { |
| 127 |
| 128 if (sig->sig_size != siglen_map[key->algorithm]) { |
| 129 debug("Wrong signature size for algorithm.\n"); |
| 130 return 1; |
| 131 } |
| 132 |
| 133 if (!RSAVerifyBinaryWithDigest_f(NULL, key, digest, |
| 134 GetSignatureDataC(sig), key->algorithm)) |
| 135 return 1; |
| 136 |
| 137 return 0; |
| 138 } |
| 139 |
| 140 |
| 125 int KeyBlockVerify(const VbKeyBlockHeader* block, uint64_t size, | 141 int KeyBlockVerify(const VbKeyBlockHeader* block, uint64_t size, |
| 126 const VbPublicKey *key) { | 142 const VbPublicKey *key) { |
| 127 | 143 |
| 128 const VbSignature* sig; | 144 const VbSignature* sig; |
| 129 | 145 |
| 130 /* Sanity checks before attempting signature of data */ | 146 /* Sanity checks before attempting signature of data */ |
| 131 if (SafeMemcmp(block->magic, KEY_BLOCK_MAGIC, KEY_BLOCK_MAGIC_SIZE)) { | 147 if (SafeMemcmp(block->magic, KEY_BLOCK_MAGIC, KEY_BLOCK_MAGIC_SIZE)) { |
| 132 debug("Not a valid verified boot key block.\n"); | 148 debug("Not a valid verified boot key block.\n"); |
| 133 return VBOOT_KEY_BLOCK_INVALID; | 149 return VBOOT_KEY_BLOCK_INVALID; |
| 134 } | 150 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 /* Verify body signature is inside the block */ | 312 /* Verify body signature is inside the block */ |
| 297 if (VerifySignatureInside(preamble, preamble->preamble_size, | 313 if (VerifySignatureInside(preamble, preamble->preamble_size, |
| 298 &preamble->body_signature)) { | 314 &preamble->body_signature)) { |
| 299 debug("Kernel body signature off end of preamble\n"); | 315 debug("Kernel body signature off end of preamble\n"); |
| 300 return VBOOT_PREAMBLE_INVALID; | 316 return VBOOT_PREAMBLE_INVALID; |
| 301 } | 317 } |
| 302 | 318 |
| 303 /* Success */ | 319 /* Success */ |
| 304 return VBOOT_SUCCESS; | 320 return VBOOT_SUCCESS; |
| 305 } | 321 } |
| OLD | NEW |