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

Unified Diff: tests/vboot_common2_tests.c

Issue 2802002: Implemented pipelined hash calculation in LoadFirmware() (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Add comment Created 10 years, 6 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 | vboot_firmware/lib/include/vboot_common.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/vboot_common2_tests.c
diff --git a/tests/vboot_common2_tests.c b/tests/vboot_common2_tests.c
index 1b7d4a1936c4fe9b041e928c4263a9a5c32f63af..86a560f069a8e7760c45812fc2b53e935c9124df 100644
--- a/tests/vboot_common2_tests.c
+++ b/tests/vboot_common2_tests.c
@@ -45,8 +45,8 @@ static void VerifyDataTest(const VbPublicKey* public_key,
const VbPrivateKey* private_key) {
const uint8_t test_data[] = "This is some test data to sign.";
- VbSignature *sig;
- RSAPublicKey *rsa;
+ VbSignature* sig;
+ RSAPublicKey* rsa;
sig = CalculateSignature(test_data, sizeof(test_data), private_key);
rsa = PublicKeyToRSA(public_key);
@@ -68,6 +68,32 @@ static void VerifyDataTest(const VbPublicKey* public_key,
}
+static void VerifyDigestTest(const VbPublicKey* public_key,
+ const VbPrivateKey* private_key) {
+
+ const uint8_t test_data[] = "This is some other test data to sign.";
+ VbSignature* sig;
+ RSAPublicKey* rsa;
+ uint8_t* digest;
+
+ sig = CalculateSignature(test_data, sizeof(test_data), private_key);
+ rsa = PublicKeyToRSA(public_key);
+ digest = DigestBuf(test_data, sizeof(test_data), public_key->algorithm);
+ TEST_NEQ(sig && rsa && digest, 0, "VerifyData() prerequisites");
+ if (!sig || !rsa || !digest)
+ return;
+
+ TEST_EQ(VerifyDigest(digest, sig, rsa), 0, "VerifyDigest() ok");
+
+ GetSignatureData(sig)[0] ^= 0x5A;
+ TEST_EQ(VerifyDigest(digest, sig, rsa), 1, "VerifyDigest() wrong sig");
+
+ RSAPublicKeyFree(rsa);
+ Free(sig);
+ Free(digest);
+}
+
+
static void ReSignKernelPreamble(VbKernelPreambleHeader *h,
const VbPrivateKey *key) {
VbSignature *sig = CalculateSignature((const uint8_t*)h,
@@ -201,6 +227,7 @@ int main(int argc, char* argv[]) {
VerifyPublicKeyToRSA(public_key);
VerifyDataTest(public_key, private_key);
+ VerifyDigestTest(public_key, private_key);
VerifyKernelPreambleTest(public_key, private_key);
if (public_key)
« no previous file with comments | « no previous file | vboot_firmware/lib/include/vboot_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698