Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1478)

Unified Diff: firmware/lib/cryptolib/rsa.c

Issue 3127013: RSAVerify() - fail on malloc() failure. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: firmware/lib/cryptolib/rsa.c
diff --git a/firmware/lib/cryptolib/rsa.c b/firmware/lib/cryptolib/rsa.c
index 51fed7713585a4b19739d700cee9634ecabb63d8..adc0dc0513fccd8a386a5cfa3549552d447add34 100644
--- a/firmware/lib/cryptolib/rsa.c
+++ b/firmware/lib/cryptolib/rsa.c
@@ -150,6 +150,8 @@ int RSAVerify(const RSAPublicKey *key,
}
buf = (uint8_t*) Malloc(sig_len);
+ if (!buf)
+ return 0;
Memcpy(buf, sig, sig_len);
modpowF4(key, buf);
@@ -161,7 +163,6 @@ int RSAVerify(const RSAPublicKey *key,
for (i = 0; i < padding_size_map[sig_type]; ++i) {
if (buf[i] != padding[i]) {
#ifndef NDEBUG
-/* TODO(gauravsh): Replace with a macro call for logging. */
VBDEBUG(("Padding: Expecting = %02x Got = %02x\n", padding[i], buf[i]));
#endif
success = 0;
@@ -172,7 +173,6 @@ int RSAVerify(const RSAPublicKey *key,
for (; i < (int)sig_len; ++i) {
if (buf[i] != *hash++) {
#ifndef NDEBUG
-/* TODO(gauravsh): Replace with a macro call for logging. */
VBDEBUG(("Digest: Expecting = %02x Got = %02x\n", padding[i], buf[i]));
#endif
success = 0;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698