From 9ce7e8414a2afd8c2e0626a5406d1811ec1842f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Sat, 29 Mar 2014 17:06:43 +0100 Subject: [PATCH] Add test for des_key_check_weak() --- tests/suites/test_suite_des.data | 12 ++++++++++++ tests/suites/test_suite_des.function | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/tests/suites/test_suite_des.data b/tests/suites/test_suite_des.data index 729164905..559d5de8e 100644 --- a/tests/suites/test_suite_des.data +++ b/tests/suites/test_suite_des.data @@ -1,3 +1,15 @@ +DES check weak key #1 +des_check_weak:"0101010101010101":1 + +DES check weak key #2 +des_check_weak:"FEE0FEE0FEF1FEF1":1 + +DES check weak key #3 +des_check_weak:"0101010101010100":0 + +DES check weak key #4 +des_check_weak:"EEE0FEE0FEF1FEF1":0 + DES Encrypt OpenSSL Test Vector #1 des_encrypt_ecb:"0000000000000000":"0000000000000000":"8CA64DE9C1B123A7" diff --git a/tests/suites/test_suite_des.function b/tests/suites/test_suite_des.function index ee327c917..d5d0f11ed 100644 --- a/tests/suites/test_suite_des.function +++ b/tests/suites/test_suite_des.function @@ -7,6 +7,19 @@ * END_DEPENDENCIES */ +/* BEGIN_CASE */ +void des_check_weak( char *key_hex, int ret ) +{ + unsigned char key[DES_KEY_SIZE]; + + memset( key, 0, sizeof key ); + + unhexify( key, key_hex ); + + TEST_ASSERT( des_key_check_weak( key ) == ret ); +} +/* END_CASE */ + /* BEGIN_CASE */ void des_encrypt_ecb( char *hex_key_string, char *hex_src_string, char *hex_dst_string )