diff options
author | Yves-Alexis Perez <corsac@debian.org> | 2015-06-08 15:35:16 +0200 |
---|---|---|
committer | Yves-Alexis Perez <corsac@debian.org> | 2015-06-08 15:35:16 +0200 |
commit | b238cf34df3fe4476ae6b7012e7cb3e9769d4d51 (patch) | |
tree | f17b69b2ade74cd41aaee818e50657465602522d /src/libstrongswan/tests | |
parent | fc556ec2bc92a9d476c11406fad2c33db8bf7cb0 (diff) | |
download | vyos-strongswan-b238cf34df3fe4476ae6b7012e7cb3e9769d4d51.tar.gz vyos-strongswan-b238cf34df3fe4476ae6b7012e7cb3e9769d4d51.zip |
Imported Upstream version 5.3.2
Diffstat (limited to 'src/libstrongswan/tests')
-rw-r--r-- | src/libstrongswan/tests/Makefile.am | 1 | ||||
-rw-r--r-- | src/libstrongswan/tests/Makefile.in | 19 | ||||
-rw-r--r-- | src/libstrongswan/tests/suites/test_iv_gen.c | 73 | ||||
-rw-r--r-- | src/libstrongswan/tests/tests.h | 1 |
4 files changed, 94 insertions, 0 deletions
diff --git a/src/libstrongswan/tests/Makefile.am b/src/libstrongswan/tests/Makefile.am index 8c081c673..d86584ad1 100644 --- a/src/libstrongswan/tests/Makefile.am +++ b/src/libstrongswan/tests/Makefile.am @@ -47,6 +47,7 @@ tests_SOURCES = tests.h tests.c \ suites/test_hasher.c \ suites/test_crypter.c \ suites/test_crypto_factory.c \ + suites/test_iv_gen.c \ suites/test_pen.c \ suites/test_asn1.c \ suites/test_asn1_parser.c \ diff --git a/src/libstrongswan/tests/Makefile.in b/src/libstrongswan/tests/Makefile.in index 97e24bdb7..13fd4cc25 100644 --- a/src/libstrongswan/tests/Makefile.in +++ b/src/libstrongswan/tests/Makefile.in @@ -143,6 +143,7 @@ am_tests_OBJECTS = tests-tests.$(OBJEXT) \ suites/tests-test_hasher.$(OBJEXT) \ suites/tests-test_crypter.$(OBJEXT) \ suites/tests-test_crypto_factory.$(OBJEXT) \ + suites/tests-test_iv_gen.$(OBJEXT) \ suites/tests-test_pen.$(OBJEXT) \ suites/tests-test_asn1.$(OBJEXT) \ suites/tests-test_asn1_parser.$(OBJEXT) \ @@ -507,6 +508,7 @@ tests_SOURCES = tests.h tests.c \ suites/test_hasher.c \ suites/test_crypter.c \ suites/test_crypto_factory.c \ + suites/test_iv_gen.c \ suites/test_pen.c \ suites/test_asn1.c \ suites/test_asn1_parser.c \ @@ -652,6 +654,8 @@ suites/tests-test_crypter.$(OBJEXT): suites/$(am__dirstamp) \ suites/$(DEPDIR)/$(am__dirstamp) suites/tests-test_crypto_factory.$(OBJEXT): suites/$(am__dirstamp) \ suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_iv_gen.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) suites/tests-test_pen.$(OBJEXT): suites/$(am__dirstamp) \ suites/$(DEPDIR)/$(am__dirstamp) suites/tests-test_asn1.$(OBJEXT): suites/$(am__dirstamp) \ @@ -701,6 +705,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_hashtable.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_host.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_identification.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_iv_gen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_linked_list.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_linked_list_enumerator.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_mgf1.Po@am__quote@ @@ -1156,6 +1161,20 @@ suites/tests-test_crypto_factory.obj: suites/test_crypto_factory.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_crypto_factory.obj `if test -f 'suites/test_crypto_factory.c'; then $(CYGPATH_W) 'suites/test_crypto_factory.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_crypto_factory.c'; fi` +suites/tests-test_iv_gen.o: suites/test_iv_gen.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_iv_gen.o -MD -MP -MF suites/$(DEPDIR)/tests-test_iv_gen.Tpo -c -o suites/tests-test_iv_gen.o `test -f 'suites/test_iv_gen.c' || echo '$(srcdir)/'`suites/test_iv_gen.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_iv_gen.Tpo suites/$(DEPDIR)/tests-test_iv_gen.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_iv_gen.c' object='suites/tests-test_iv_gen.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_iv_gen.o `test -f 'suites/test_iv_gen.c' || echo '$(srcdir)/'`suites/test_iv_gen.c + +suites/tests-test_iv_gen.obj: suites/test_iv_gen.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_iv_gen.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_iv_gen.Tpo -c -o suites/tests-test_iv_gen.obj `if test -f 'suites/test_iv_gen.c'; then $(CYGPATH_W) 'suites/test_iv_gen.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_iv_gen.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_iv_gen.Tpo suites/$(DEPDIR)/tests-test_iv_gen.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_iv_gen.c' object='suites/tests-test_iv_gen.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_iv_gen.obj `if test -f 'suites/test_iv_gen.c'; then $(CYGPATH_W) 'suites/test_iv_gen.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_iv_gen.c'; fi` + suites/tests-test_pen.o: suites/test_pen.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_pen.o -MD -MP -MF suites/$(DEPDIR)/tests-test_pen.Tpo -c -o suites/tests-test_pen.o `test -f 'suites/test_pen.c' || echo '$(srcdir)/'`suites/test_pen.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_pen.Tpo suites/$(DEPDIR)/tests-test_pen.Po diff --git a/src/libstrongswan/tests/suites/test_iv_gen.c b/src/libstrongswan/tests/suites/test_iv_gen.c new file mode 100644 index 000000000..4e45c8538 --- /dev/null +++ b/src/libstrongswan/tests/suites/test_iv_gen.c @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2015 Tobias Brunner + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "test_suite.h" + +#include <crypto/iv/iv_gen_seq.h> +#include <utils/test.h> + +START_TEST(test_iv_gen_seq) +{ + iv_gen_t *iv_gen; + u_int64_t iv0, iv1_1, iv1_2; + + iv_gen = iv_gen_seq_create(); + ck_assert(iv_gen->get_iv(iv_gen, 0, 8, (u_int8_t*)&iv0)); + ck_assert(iv_gen->get_iv(iv_gen, 1, 8, (u_int8_t*)&iv1_1)); + ck_assert(iv0 != iv1_1); + /* every sequence number may be used twice, but results in a different IV */ + ck_assert(iv_gen->get_iv(iv_gen, 1, 8, (u_int8_t*)&iv1_2)); + ck_assert(iv0 != iv1_2); + ck_assert(iv1_1 != iv1_2); + ck_assert(!iv_gen->get_iv(iv_gen, 1, 8, (u_int8_t*)&iv1_2)); + iv_gen->destroy(iv_gen); +} +END_TEST + +START_TEST(test_iv_gen_seq_len) +{ + iv_gen_t *iv_gen; + u_int64_t iv; + u_int8_t buf[9]; + + iv_gen = iv_gen_seq_create(); + ck_assert(!iv_gen->get_iv(iv_gen, 0, 0, (u_int8_t*)&iv)); + ck_assert(!iv_gen->get_iv(iv_gen, 0, 1, (u_int8_t*)&iv)); + ck_assert(!iv_gen->get_iv(iv_gen, 0, 2, (u_int8_t*)&iv)); + ck_assert(!iv_gen->get_iv(iv_gen, 0, 3, (u_int8_t*)&iv)); + ck_assert(!iv_gen->get_iv(iv_gen, 0, 4, (u_int8_t*)&iv)); + ck_assert(!iv_gen->get_iv(iv_gen, 0, 5, (u_int8_t*)&iv)); + ck_assert(!iv_gen->get_iv(iv_gen, 0, 6, (u_int8_t*)&iv)); + ck_assert(!iv_gen->get_iv(iv_gen, 0, 7, (u_int8_t*)&iv)); + ck_assert(iv_gen->get_iv(iv_gen, 0, 8, (u_int8_t*)&iv)); + ck_assert(iv_gen->get_iv(iv_gen, 0, 9, buf)); + iv_gen->destroy(iv_gen); +} +END_TEST + +Suite *iv_gen_suite_create() +{ + Suite *s; + TCase *tc; + + s = suite_create("iv-gen"); + + tc = tcase_create("iv-gen-seq"); + tcase_add_test(tc, test_iv_gen_seq); + tcase_add_test(tc, test_iv_gen_seq_len); + suite_add_tcase(s, tc); + + return s; +} diff --git a/src/libstrongswan/tests/tests.h b/src/libstrongswan/tests/tests.h index e1d8ca4ba..e1074b931 100644 --- a/src/libstrongswan/tests/tests.h +++ b/src/libstrongswan/tests/tests.h @@ -40,6 +40,7 @@ TEST_SUITE(printf_suite_create) TEST_SUITE(hasher_suite_create) TEST_SUITE(crypter_suite_create) TEST_SUITE(crypto_factory_suite_create) +TEST_SUITE(iv_gen_suite_create) TEST_SUITE(pen_suite_create) TEST_SUITE(asn1_suite_create) TEST_SUITE(asn1_parser_suite_create) |