YACA: add PBKDF2 vector tests 27/78427/2
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Tue, 5 Jul 2016 11:09:36 +0000 (13:09 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Tue, 5 Jul 2016 14:05:59 +0000 (16:05 +0200)
Change-Id: Ie4a7754c8ac4dc8c574ebc66a3e42eeef8a7236e

src/yaca/test-vectors/key_pbkdf2.txt [new file with mode: 0644]
src/yaca/yaca-test-key.cpp

diff --git a/src/yaca/test-vectors/key_pbkdf2.txt b/src/yaca/test-vectors/key_pbkdf2.txt
new file mode 100644 (file)
index 0000000..3cbdfff
--- /dev/null
@@ -0,0 +1,64 @@
+password=
+salt=9d1b74e15562b40a475e119b86b93afc32b6736b
+salt_len=20
+iter=1
+algo=MD5
+key_bit_len=64
+key=52f3d57fa63dab7f
+
+password=a
+salt=412c46e8039535d7dcc8094196e2eb46cb725b62
+salt_len=20
+iter=5
+algo=SHA1
+key_bit_len=128
+key=7930fd527ea6a0e42456119e745051e2
+
+password=aaa
+salt=17eb5c11ec194175e6a62dd6d545e343c83e3598
+salt_len=20
+iter=10
+algo=SHA224
+key_bit_len=128
+key=b6471015a5e3eaa7b53a8ff768d864dc
+
+password=password
+salt=194a50ad20a87d0c26864f349b7824b5ab0a5a5b
+salt_len=20
+iter=50
+algo=SHA256
+key_bit_len=192
+key=61b91432adb8403012f8ce0b9a8272432614b0ea71a0ec94
+
+password=qwerty
+salt=a35047f285518b57ce3e7e0556673a7a8a1177fa
+salt_len=20
+iter=100
+algo=SHA384
+key_bit_len=256
+key=40ab3882c1780ddaa479585d5cf2ac92e02b7f2aec739e6353fd40f70f5e6740
+
+password=1234567890
+salt=257624551e265fe39afc16421172b8c4e5552a3c
+salt_len=20
+iter=1000
+algo=SHA512
+key_bit_len=256
+key=5694ae84cfc33c485fa4b7bac6503a1532e7e87ac34d89bb7a2c314b3f22147f
+
+password=!@#$%^&*()_+
+salt=9d8d0e1bd2ce6d31d46dc222f2d56c465812216d
+salt_len=20
+iter=10000
+algo=SHA512
+key_bit_len=256
+key=05967d6c8d8211a48c5e34677800e51d5cef1cd47af717268330a2a3113ec692
+
+password=456qweRTYuio123$%^789
+salt=70285b859c8c6c6a61d9b2e998f0c1d085d14f9d
+salt_len=20
+iter=100000
+algo=SHA512
+key_bit_len=256
+key=84013e2f464450f96cb94a8c9be87df5a891eecf3738839152bdf49be1f98136
+
index 9aba3ae496716ddadc447524ad5ddfd4ba31e52e..08281bb5fd27c92ebf0f820934a1734f9fdc9377 100644 (file)
@@ -556,3 +556,29 @@ RUNNER_TEST(T4260_yaca_key_import_x509, YacaTest)
         assert_keys_equal(cert_key, pub_key);
     }
 }
+
+RUNNER_TEST(T4270_yaca_key_derive_pbkdf2, YacaTest)
+{
+    auto tvv = loadTestVector("key_pbkdf2.txt");
+
+    for (const auto& tv : tvv) {
+        std::string password;
+        Buffer salt;
+        size_t iter;
+        yaca_digest_algorithm_e algo;
+        size_t key_bit_len;
+        Buffer key_data;
+
+        tv.get("password", password);
+        tv.get("salt", salt);
+        tv.get("iter", iter);
+        tv.get("algo", algo);
+        tv.get("key_bit_len", key_bit_len);
+        tv.get("key", key_data);
+
+        KeyPtr key_expected = import_key(YACA_KEY_TYPE_SYMMETRIC, nullptr, key_data.data(), key_data.size());
+        KeyPtr key_derived = key_derive_pbkdf2(password.c_str(), salt.data(), salt.size(), iter, algo, key_bit_len);
+
+        assert_keys_equal(key_expected, key_derived);
+    }
+}