| 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)
|
|
|