]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Move EAP-SIM PRF module test into the hwsim framework
authorJouni Malinen <j@w1.fi>
Mon, 23 Nov 2015 21:52:52 +0000 (23:52 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 23 Nov 2015 22:00:21 +0000 (00:00 +0200)
The old wpa_supplicant/Makefile target test-eap_sim_common did not work
anymore and anyway, this test is better placed in the newer hwsim
framework to make sure the test case gets executed automatically.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/crypto/crypto_module_tests.c
wpa_supplicant/Makefile
wpa_supplicant/tests/test_eap_sim_common.c [deleted file]

index 2b19a4a0c31fd3c75dc54466c69dbfd33fd7eea2..087953b6e896694727380983a08700772b25e48d 100644 (file)
@@ -1605,6 +1605,35 @@ static int test_sha256(void)
 }
 
 
+static int test_fips186_2_prf(void)
+{
+       /* http://csrc.nist.gov/encryption/dss/Examples-1024bit.pdf */
+       u8 xkey[] = {
+               0xbd, 0x02, 0x9b, 0xbe, 0x7f, 0x51, 0x96, 0x0b,
+               0xcf, 0x9e, 0xdb, 0x2b, 0x61, 0xf0, 0x6f, 0x0f,
+               0xeb, 0x5a, 0x38, 0xb6
+       };
+       u8 w[] = {
+               0x20, 0x70, 0xb3, 0x22, 0x3d, 0xba, 0x37, 0x2f,
+               0xde, 0x1c, 0x0f, 0xfc, 0x7b, 0x2e, 0x3b, 0x49,
+               0x8b, 0x26, 0x06, 0x14, 0x3c, 0x6c, 0x18, 0xba,
+               0xcb, 0x0f, 0x6c, 0x55, 0xba, 0xbb, 0x13, 0x78,
+               0x8e, 0x20, 0xd7, 0x37, 0xa3, 0x27, 0x51, 0x16
+       };
+       u8 buf[40];
+
+       wpa_printf(MSG_INFO,
+                  "Testing EAP-SIM PRF (FIPS 186-2 + change notice 1)");
+       if (fips186_2_prf(xkey, sizeof(xkey), buf, sizeof(buf)) < 0 ||
+           os_memcmp(w, buf, sizeof(w)) != 0) {
+               wpa_printf(MSG_INFO, "fips186_2_prf failed");
+               return 1;
+       }
+
+       return 0;
+}
+
+
 static int test_ms_funcs(void)
 {
 #ifndef CONFIG_FIPS
@@ -1721,6 +1750,7 @@ int crypto_module_tests(void)
            test_md5() ||
            test_sha1() ||
            test_sha256() ||
+           test_fips186_2_prf() ||
            test_ms_funcs())
                ret = -1;
 
index 21013605263adbfacd79325b47b8cb6cc561730e..31d54da87bdce7ab88731747b91942efeb23a4a1 100644 (file)
@@ -1756,17 +1756,6 @@ wpa_gui-qt4/lang/wpa_gui_de.qm: wpa_gui-qt4/lang/wpa_gui_de.ts
 wpa_gui-qt4: wpa_gui-qt4/Makefile wpa_gui-qt4/lang/wpa_gui_de.qm
        $(MAKE) -C wpa_gui-qt4
 
-TEST_EAP_SIM_COMMON_OBJS = $(SHA1OBJS) $(MD5OBJS) \
-       ../src/utils/common.o ../src/utils/os_unix.o \
-       ../src/utils/wpa_debug.o $(AESOBJS) \
-       tests/test_eap_sim_common.o
-test-eap_sim_common: $(TEST_EAP_SIM_COMMON_OBJS)
-       $(LDO) $(LDFLAGS) -o $@ $(TEST_EAP_SIM_COMMON_OBJS) $(LIBS)
-       ./test-eap_sim_common
-       rm test-eap_sim_common
-
-tests: test-eap_sim_common
-
 FIPSDIR=/usr/local/ssl/fips-2.0
 FIPSLD=$(FIPSDIR)/bin/fipsld
 fips:
diff --git a/wpa_supplicant/tests/test_eap_sim_common.c b/wpa_supplicant/tests/test_eap_sim_common.c
deleted file mode 100644 (file)
index f60b182..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Test program for EAP-SIM PRF
- * Copyright (c) 2004-2006, Jouni Malinen <j@w1.fi>
- *
- * This software may be distributed under the terms of the BSD license.
- * See README for more details.
- */
-
-#include "eap_common/eap_sim_common.c"
-
-
-static int test_eap_sim_prf(void)
-{
-       /* http://csrc.nist.gov/encryption/dss/Examples-1024bit.pdf */
-       u8 xkey[] = {
-               0xbd, 0x02, 0x9b, 0xbe, 0x7f, 0x51, 0x96, 0x0b,
-               0xcf, 0x9e, 0xdb, 0x2b, 0x61, 0xf0, 0x6f, 0x0f,
-               0xeb, 0x5a, 0x38, 0xb6
-       };
-       u8 w[] = {
-               0x20, 0x70, 0xb3, 0x22, 0x3d, 0xba, 0x37, 0x2f,
-               0xde, 0x1c, 0x0f, 0xfc, 0x7b, 0x2e, 0x3b, 0x49,
-               0x8b, 0x26, 0x06, 0x14, 0x3c, 0x6c, 0x18, 0xba,
-               0xcb, 0x0f, 0x6c, 0x55, 0xba, 0xbb, 0x13, 0x78,
-               0x8e, 0x20, 0xd7, 0x37, 0xa3, 0x27, 0x51, 0x16
-       };
-       u8 buf[40];
-
-       printf("Testing EAP-SIM PRF (FIPS 186-2 + change notice 1)\n");
-       eap_sim_prf(xkey, buf, sizeof(buf));
-       if (memcmp(w, buf, sizeof(w)) != 0) {
-               printf("eap_sim_prf failed\n");
-               return 1;
-       }
-
-       return 0;
-}
-
-
-int main(int argc, char *argv[])
-{
-       int errors = 0;
-
-       errors += test_eap_sim_prf();
-
-       return errors;
-}