YACA: add DATA_MISMATCH testing for verification vector tests 37/77437/4
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Wed, 29 Jun 2016 15:50:03 +0000 (17:50 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Thu, 30 Jun 2016 09:18:06 +0000 (11:18 +0200)
Change-Id: I75f89e874f9357f5415e2d863dde1ea0badf2e73

src/yaca/yaca-test-sign.cpp

index d48dc32..ca63d64 100644 (file)
@@ -302,7 +302,21 @@ RUNNER_TEST(T6120_yaca_sign_verify_test_vectors, YacaTest)
         int ret = yaca_verify_finalize(ctx.get(), output.data(), output_len);
         YACA_ASSERT_MSG(YACA_ERROR_NONE == ret,
                         "Verification failed for \"" << truncate_str(input, 16) << "\" with "
-                        << digest2str(algo) << " and " << keytype2str(key_type) << " key" );
+                        << digest2str(algo) << " and " << keytype2str(key_type) << " key");
+
+        std::string input_wrong = input + "!";
+        ctx = verify_init(algo, key_pub);
+
+        for (size_t i = 0; i < repeats; i++)
+            YACA_SUCCESS(yaca_verify_update(ctx.get(),
+                                            input_wrong.c_str(),
+                                            input_wrong.size()));
+
+        ret = yaca_verify_finalize(ctx.get(), output.data(), output_len);
+        YACA_ASSERT_MSG(YACA_ERROR_DATA_MISMATCH == ret,
+                        "Verification succeeded for \"" << truncate_str(input, 16) << "\" with "
+                        << digest2str(algo) << " and " << keytype2str(key_type)
+                        << " key while the input was tampered with");
     }
 }