| OLD | NEW |
| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 dest->key_size = src->key_size; | 108 dest->key_size = src->key_size; |
| 109 dest->algorithm = src->algorithm; | 109 dest->algorithm = src->algorithm; |
| 110 dest->key_version = src->key_version; | 110 dest->key_version = src->key_version; |
| 111 Memcpy(GetPublicKeyData(dest), GetPublicKeyDataC(src), src->key_size); | 111 Memcpy(GetPublicKeyData(dest), GetPublicKeyDataC(src), src->key_size); |
| 112 return 0; | 112 return 0; |
| 113 } | 113 } |
| 114 | 114 |
| 115 | 115 |
| 116 RSAPublicKey* PublicKeyToRSA(const VbPublicKey* key) { | 116 RSAPublicKey* PublicKeyToRSA(const VbPublicKey* key) { |
| 117 RSAPublicKey *rsa; | 117 RSAPublicKey *rsa; |
| 118 int key_size; | 118 uint64_t key_size; |
| 119 | 119 |
| 120 if (kNumAlgorithms <= key->algorithm) { | 120 if (kNumAlgorithms <= key->algorithm) { |
| 121 VBDEBUG(("Invalid algorithm.\n")); | 121 VBDEBUG(("Invalid algorithm.\n")); |
| 122 return NULL; | 122 return NULL; |
| 123 } | 123 } |
| 124 if (!RSAProcessedKeySize((int)key->algorithm, &key_size) || | 124 if (!RSAProcessedKeySize(key->algorithm, &key_size) || |
| 125 key_size != (int)key->key_size) { | 125 key_size != key->key_size) { |
| 126 VBDEBUG(("Wrong key size for algorithm\n")); | 126 VBDEBUG(("Wrong key size for algorithm\n")); |
| 127 return NULL; | 127 return NULL; |
| 128 } | 128 } |
| 129 | 129 |
| 130 rsa = RSAPublicKeyFromBuf(GetPublicKeyDataC(key), (int)key->key_size); | 130 rsa = RSAPublicKeyFromBuf(GetPublicKeyDataC(key), key->key_size); |
| 131 if (!rsa) | 131 if (!rsa) |
| 132 return NULL; | 132 return NULL; |
| 133 | 133 |
| 134 rsa->algorithm = (int)key->algorithm; | 134 rsa->algorithm = (unsigned int)key->algorithm; |
| 135 return rsa; | 135 return rsa; |
| 136 } | 136 } |
| 137 | 137 |
| 138 | 138 |
| 139 int VerifyData(const uint8_t* data, uint64_t size, const VbSignature *sig, | 139 int VerifyData(const uint8_t* data, uint64_t size, const VbSignature *sig, |
| 140 const RSAPublicKey* key) { | 140 const RSAPublicKey* key) { |
| 141 | 141 |
| 142 if (sig->sig_size != siglen_map[key->algorithm]) { | 142 if (sig->sig_size != siglen_map[key->algorithm]) { |
| 143 VBDEBUG(("Wrong signature size for algorithm.\n")); | 143 VBDEBUG(("Wrong signature size for algorithm.\n")); |
| 144 return 1; | 144 return 1; |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 return VBOOT_SHARED_DATA_INVALID; | 443 return VBOOT_SHARED_DATA_INVALID; |
| 444 header->kernel_subkey_data_size = src->key_size; | 444 header->kernel_subkey_data_size = src->key_size; |
| 445 } | 445 } |
| 446 | 446 |
| 447 /* Copy the kernel sign key blob into the destination buffer */ | 447 /* Copy the kernel sign key blob into the destination buffer */ |
| 448 PublicKeyInit(kdest, (uint8_t*)header + header->kernel_subkey_data_offset, | 448 PublicKeyInit(kdest, (uint8_t*)header + header->kernel_subkey_data_offset, |
| 449 header->kernel_subkey_data_size); | 449 header->kernel_subkey_data_size); |
| 450 | 450 |
| 451 return PublicKeyCopy(kdest, src); | 451 return PublicKeyCopy(kdest, src); |
| 452 } | 452 } |
| OLD | NEW |