YACA: add PBKDF2 invalid param tests 25/78425/2
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Tue, 5 Jul 2016 11:09:18 +0000 (13:09 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Tue, 5 Jul 2016 14:02:54 +0000 (16:02 +0200)
Change-Id: I8feed6eacc53c5e24e0788621196af724cc18487

src/yaca/yaca-test-key.cpp

index 4c26268..9aba3ae 100644 (file)
@@ -457,7 +457,27 @@ RUNNER_TEST(T4230_yaca_key_import_invalid_param, YacaTest)
                                        key_rsa_pub_data.get(), key_rsa_pub_data_len, &out));
 }
 
-RUNNER_TEST(T4240_yaca_key_export_import, YacaTest)
+RUNNER_TEST(T4240_yaca_key_derive_pbkdf2_invalid_param, YacaTest)
+{
+    yaca_key_h key;
+
+    YACA_INVALID_PARAM(yaca_key_derive_pbkdf2(nullptr, "salt", 4, 1, YACA_DIGEST_MD5, 128, &key));
+    YACA_INVALID_PARAM(yaca_key_derive_pbkdf2("pass", nullptr, 4, 1, YACA_DIGEST_MD5, 128, &key));
+    YACA_INVALID_PARAM(yaca_key_derive_pbkdf2("pass", nullptr, 1, 1, YACA_DIGEST_MD5, 128, &key));
+    YACA_INVALID_PARAM(yaca_key_derive_pbkdf2("pass", "salt", 0, 1, YACA_DIGEST_MD5, 128, &key));
+    YACA_INVALID_PARAM(yaca_key_derive_pbkdf2("pass", "salt", 4, 0, YACA_DIGEST_MD5, 128, &key));
+    YACA_INVALID_PARAM(yaca_key_derive_pbkdf2("pass", "salt", 4, 1,
+                                              static_cast<yaca_digest_algorithm_e>(-1),128, &key));
+    YACA_INVALID_PARAM(yaca_key_derive_pbkdf2("pass", "salt", 4, 1, YACA_DIGEST_MD5, 0, &key));
+    YACA_INVALID_PARAM(yaca_key_derive_pbkdf2("pass", "salt", 4, 1, YACA_DIGEST_MD5, 127, &key));
+    YACA_INVALID_PARAM(yaca_key_derive_pbkdf2("pass", "salt", 4, 1, YACA_DIGEST_MD5, 128, nullptr));
+
+    /* implementation specific tests, might go away at some point */
+    YACA_INVALID_PARAM(yaca_key_derive_pbkdf2("pass", "salt", 4, static_cast<size_t>(INT_MAX) + 1,
+                                              YACA_DIGEST_MD5, 128, &key));
+}
+
+RUNNER_TEST(T4250_yaca_key_export_import, YacaTest)
 {
     auto tvv = loadTestVector("key.txt");
 
@@ -519,7 +539,7 @@ RUNNER_TEST(T4240_yaca_key_export_import, YacaTest)
     }
 }
 
-RUNNER_TEST(T4250_yaca_key_import_x509, YacaTest)
+RUNNER_TEST(T4260_yaca_key_import_x509, YacaTest)
 {
     auto tvv = loadTestVector("key_x509.txt");