summaryrefslogtreecommitdiff
path: root/firmware/lib/vboot_common.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2010-07-19 10:35:40 -0700
committerRandall Spangler <rspangler@chromium.org>2010-07-19 10:35:40 -0700
commit87c13d806b1f58542b0fc0893144de45d31cabd2 (patch)
tree2b99c041f6be2e734a120de649026c0e3566a86f /firmware/lib/vboot_common.c
parent3e1081fb71385d72fd3a522599c35b516dda7a37 (diff)
downloadvboot-87c13d806b1f58542b0fc0893144de45d31cabd2.tar.gz
Added size param to VerifyData()
Also renamed verify preamble functions, now that they do not need the '2' at the end to differentiate them from the now-deleted original implementation. BUG=4501 TEST=Ran make runtests; all pass. Review URL: http://codereview.chromium.org/3027009
Diffstat (limited to 'firmware/lib/vboot_common.c')
-rw-r--r--firmware/lib/vboot_common.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/firmware/lib/vboot_common.c b/firmware/lib/vboot_common.c
index be5a34de..a2a5d9f5 100644
--- a/firmware/lib/vboot_common.c
+++ b/firmware/lib/vboot_common.c
@@ -126,13 +126,17 @@ RSAPublicKey* PublicKeyToRSA(const VbPublicKey* key) {
}
-int VerifyData(const uint8_t* data, const VbSignature *sig,
+int VerifyData(const uint8_t* data, uint64_t size, const VbSignature *sig,
const RSAPublicKey* key) {
if (sig->sig_size != siglen_map[key->algorithm]) {
VBDEBUG(("Wrong signature size for algorithm.\n"));
return 1;
}
+ if (sig->data_size > size) {
+ VBDEBUG(("Data buffer smaller than length of signed data.\n"));
+ return 1;
+ }
if (!RSAVerifyBinary_f(NULL, key, data, sig->data_size,
GetSignatureDataC(sig), key->algorithm))
@@ -201,7 +205,7 @@ int KeyBlockVerify(const VbKeyBlockHeader* block, uint64_t size,
VBDEBUG(("Signature calculated past end of the block\n"));
return VBOOT_KEY_BLOCK_INVALID;
}
- rv = VerifyData((const uint8_t*)block, sig, rsa);
+ rv = VerifyData((const uint8_t*)block, size, sig, rsa);
RSAPublicKeyFree(rsa);
if (rv)
return VBOOT_KEY_BLOCK_SIGNATURE;
@@ -253,7 +257,7 @@ int KeyBlockVerify(const VbKeyBlockHeader* block, uint64_t size,
}
-int VerifyFirmwarePreamble2(const VbFirmwarePreambleHeader* preamble,
+int VerifyFirmwarePreamble(const VbFirmwarePreambleHeader* preamble,
uint64_t size, const RSAPublicKey* key) {
const VbSignature* sig = &preamble->preamble_signature;
@@ -281,7 +285,7 @@ int VerifyFirmwarePreamble2(const VbFirmwarePreambleHeader* preamble,
return VBOOT_PREAMBLE_INVALID;
}
- if (VerifyData((const uint8_t*)preamble, sig, key)) {
+ if (VerifyData((const uint8_t*)preamble, size, sig, key)) {
VBDEBUG(("Preamble signature validation failed\n"));
return VBOOT_PREAMBLE_SIGNATURE;
}
@@ -311,7 +315,7 @@ int VerifyFirmwarePreamble2(const VbFirmwarePreambleHeader* preamble,
}
-int VerifyKernelPreamble2(const VbKernelPreambleHeader* preamble,
+int VerifyKernelPreamble(const VbKernelPreambleHeader* preamble,
uint64_t size, const RSAPublicKey* key) {
const VbSignature* sig = &preamble->preamble_signature;
@@ -331,7 +335,7 @@ int VerifyKernelPreamble2(const VbKernelPreambleHeader* preamble,
VBDEBUG(("Preamble signature off end of preamble\n"));
return VBOOT_PREAMBLE_INVALID;
}
- if (VerifyData((const uint8_t*)preamble, sig, key)) {
+ if (VerifyData((const uint8_t*)preamble, size, sig, key)) {
VBDEBUG(("Preamble signature validation failed\n"));
return VBOOT_PREAMBLE_SIGNATURE;
}