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

Unified Diff: src/platform/vboot_reference/crypto/rsa_utility.c

Issue 1430001: VBoot Reference: Fix splicing bugs in Firmware and Kernel verification. (Closed)
Patch Set: . Created 10 years, 9 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
Index: src/platform/vboot_reference/crypto/rsa_utility.c
diff --git a/src/platform/vboot_reference/crypto/rsa_utility.c b/src/platform/vboot_reference/crypto/rsa_utility.c
index 9b419d03b66e81ef1e47f399c975bf3168e0bdb4..3559dfde30c0f1bd9470c64383c89cda7028bf45 100644
--- a/src/platform/vboot_reference/crypto/rsa_utility.c
+++ b/src/platform/vboot_reference/crypto/rsa_utility.c
@@ -100,3 +100,34 @@ int RSAVerifyBinary_f(const uint8_t* key_blob,
RSAPublicKeyFree(verification_key); /* Only free if we allocated it. */
return success;
}
+
+/* Version of RSAVerifyBinary_f() where instead of the raw binary blob
+ * of data, its digest is passed as the argument. */
+int RSAVerifyBinaryWithDigest_f(const uint8_t* key_blob,
+ const RSAPublicKey* key,
+ const uint8_t* digest,
+ const uint8_t* sig,
+ int algorithm) {
+ RSAPublicKey* verification_key = NULL;
+ int key_size;
+ int sig_size;
+ int success;
+
+ if (algorithm >= kNumAlgorithms)
+ return 0; /* Invalid algorithm. */
+ key_size = RSAProcessedKeySize(algorithm);
+ sig_size = siglen_map[algorithm];
+
+ if (key_blob && !key)
+ verification_key = RSAPublicKeyFromBuf(key_blob, key_size);
+ else if (!key_blob && key)
+ verification_key = (RSAPublicKey*) key; /* Supress const warning. */
+ else
+ return 0; /* Both can't be NULL or non-NULL. */
+
+ success = RSAVerify(verification_key, sig, sig_size, algorithm, digest);
+
+ if (!key)
+ RSAPublicKeyFree(verification_key); /* Only free if we allocated it. */
+ return success;
+}

Powered by Google App Engine
This is Rietveld 408576698