mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-04 00:00:14 -04:00
Moved Ed25519 tests to libstrongswan
This commit is contained in:
parent
e9c2b6658b
commit
4f19112b1f
@ -1757,7 +1757,6 @@ AC_CONFIG_FILES([
|
||||
src/libstrongswan/plugins/fips_prf/Makefile
|
||||
src/libstrongswan/plugins/gmp/Makefile
|
||||
src/libstrongswan/plugins/curve25519/Makefile
|
||||
src/libstrongswan/plugins/curve25519/tests/Makefile
|
||||
src/libstrongswan/plugins/rdrand/Makefile
|
||||
src/libstrongswan/plugins/aesni/Makefile
|
||||
src/libstrongswan/plugins/random/Makefile
|
||||
|
@ -648,7 +648,3 @@ endif
|
||||
if USE_NEWHOPE
|
||||
SUBDIRS += plugins/newhope/tests
|
||||
endif
|
||||
|
||||
if USE_CURVE25519
|
||||
SUBDIRS += plugins/curve25519/tests
|
||||
endif
|
||||
|
@ -2,19 +2,10 @@ AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src/libstrongswan
|
||||
|
||||
AM_CFLAGS = \
|
||||
$(PLUGIN_CFLAGS) \
|
||||
@COVERAGE_CFLAGS@
|
||||
|
||||
# these files are also used by the tests, we can't directly refer to them
|
||||
# because of the subdirectory, which would cause distclean to fail
|
||||
noinst_LTLIBRARIES = libcurve25519.la
|
||||
libcurve25519_la_SOURCES = \
|
||||
curve25519_private_key.h curve25519_private_key.c \
|
||||
curve25519_public_key.h curve25519_public_key.c \
|
||||
ref10/ref10.h ref10/ref10.c ref10/base.h ref10/base2.h
|
||||
$(PLUGIN_CFLAGS)
|
||||
|
||||
if MONOLITHIC
|
||||
noinst_LTLIBRARIES += libstrongswan-curve25519.la
|
||||
noinst_LTLIBRARIES = libstrongswan-curve25519.la
|
||||
else
|
||||
plugin_LTLIBRARIES = libstrongswan-curve25519.la
|
||||
endif
|
||||
@ -24,9 +15,9 @@ libstrongswan_curve25519_la_SOURCES = \
|
||||
curve25519_drv.h curve25519_drv.c \
|
||||
curve25519_drv_portable.h curve25519_drv_portable.c \
|
||||
curve25519_identity_hasher.h curve25519_identity_hasher.c \
|
||||
curve25519_plugin.h curve25519_plugin.c
|
||||
curve25519_plugin.h curve25519_plugin.c \
|
||||
curve25519_private_key.h curve25519_private_key.c \
|
||||
curve25519_public_key.h curve25519_public_key.c \
|
||||
ref10/ref10.h ref10/ref10.c ref10/base.h ref10/base2.h
|
||||
|
||||
libstrongswan_curve25519_la_LDFLAGS = -module -avoid-version
|
||||
|
||||
libstrongswan_curve25519_la_LIBADD = libcurve25519.la
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
curve25519_tests
|
@ -1,21 +0,0 @@
|
||||
TESTS = curve25519_tests
|
||||
|
||||
check_PROGRAMS = $(TESTS)
|
||||
|
||||
curve25519_tests_SOURCES = \
|
||||
suites/test_curve25519_ed25519.c \
|
||||
curve25519_tests.h curve25519_tests.c
|
||||
|
||||
curve25519_tests_CFLAGS = \
|
||||
-I$(top_srcdir)/src/libstrongswan \
|
||||
-I$(top_srcdir)/src/libstrongswan/tests \
|
||||
-I$(top_srcdir)/src/libstrongswan/plugins/curve25519 \
|
||||
-DPLUGINDIR=\""$(abs_top_builddir)/src/libstrongswan/plugins\"" \
|
||||
-DPLUGINS=\""${s_plugins}\"" \
|
||||
@COVERAGE_CFLAGS@
|
||||
|
||||
curve25519_tests_LDFLAGS = @COVERAGE_LDFLAGS@
|
||||
curve25519_tests_LDADD = \
|
||||
$(top_builddir)/src/libstrongswan/libstrongswan.la \
|
||||
$(top_builddir)/src/libstrongswan/tests/libtest.la \
|
||||
../libcurve25519.la
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Andreas Steffen
|
||||
* HSR 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_runner.h>
|
||||
|
||||
#include <library.h>
|
||||
|
||||
/* declare test suite constructors */
|
||||
#define TEST_SUITE(x) test_suite_t* x();
|
||||
#include "curve25519_tests.h"
|
||||
#undef TEST_SUITE
|
||||
|
||||
static test_configuration_t tests[] = {
|
||||
#define TEST_SUITE(x) \
|
||||
{ .suite = x, },
|
||||
#include "curve25519_tests.h"
|
||||
{ .suite = NULL, }
|
||||
};
|
||||
|
||||
static bool test_runner_init(bool init)
|
||||
{
|
||||
if (init)
|
||||
{
|
||||
char *plugins, *plugindir;
|
||||
|
||||
plugins = lib->settings->get_str(lib->settings,
|
||||
"tests.load", PLUGINS);
|
||||
plugindir = lib->settings->get_str(lib->settings,
|
||||
"tests.plugindir", PLUGINDIR);
|
||||
plugin_loader_add_plugindirs(plugindir, plugins);
|
||||
if (!lib->plugins->load(lib->plugins, plugins))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lib->processor->set_threads(lib->processor, 0);
|
||||
lib->processor->cancel(lib->processor);
|
||||
lib->plugins->unload(lib->plugins);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
return test_runner_run("curve25519", tests, test_runner_init);
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Andreas Steffen
|
||||
* HSR 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.
|
||||
*/
|
||||
|
||||
TEST_SUITE(curve25519_ed25519_suite_create)
|
@ -55,7 +55,8 @@ tests_SOURCES = tests.h tests.c \
|
||||
suites/test_printf.c \
|
||||
suites/test_test_rng.c \
|
||||
suites/test_mgf1.c \
|
||||
suites/test_ntru.c
|
||||
suites/test_ntru.c \
|
||||
suites/test_ed25519.c
|
||||
|
||||
tests_CFLAGS = \
|
||||
-I$(top_srcdir)/src/libstrongswan \
|
||||
|
@ -15,9 +15,6 @@
|
||||
|
||||
#include "test_suite.h"
|
||||
|
||||
#include <curve25519_private_key.h>
|
||||
#include <curve25519_public_key.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
typedef struct sig_test_t sig_test_t;
|
||||
@ -272,7 +269,7 @@ static sig_test_t sig_tests[] = {
|
||||
}
|
||||
};
|
||||
|
||||
START_TEST(test_curve25519_ed25519_sign)
|
||||
START_TEST(test_ed25519_sign)
|
||||
{
|
||||
private_key_t *key;
|
||||
public_key_t *pubkey, *public;
|
||||
@ -316,7 +313,7 @@ START_TEST(test_curve25519_ed25519_sign)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_curve25519_ed25519_gen)
|
||||
START_TEST(test_ed25519_gen)
|
||||
{
|
||||
private_key_t *key, *key2;
|
||||
public_key_t *pubkey, *pubkey2;
|
||||
@ -390,19 +387,18 @@ START_TEST(test_curve25519_ed25519_gen)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_curve25519_ed25519_speed)
|
||||
START_TEST(test_ed25519_speed)
|
||||
{
|
||||
private_key_t *key;
|
||||
public_key_t *pubkey;
|
||||
chunk_t msg = chunk_from_str("Hello Ed25519"), sig;
|
||||
struct timespec start, stop;
|
||||
int i, count = 1000;
|
||||
|
||||
/* use /dev/urandom for true random source */
|
||||
lib->settings->set_str(lib->settings,
|
||||
"libstrongswan.plugins.random.random", "/dev/urandom");
|
||||
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
struct timespec start, stop;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_ED25519,
|
||||
@ -416,15 +412,13 @@ START_TEST(test_curve25519_ed25519_speed)
|
||||
pubkey->destroy(pubkey);
|
||||
chunk_free(&sig);
|
||||
}
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &stop);
|
||||
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &stop);
|
||||
DBG0(DBG_LIB, "%d Ed25519 keys and signatures in %d ms\n", count,
|
||||
(stop.tv_nsec - start.tv_nsec) / 1000000 +
|
||||
(stop.tv_sec - start.tv_sec) * 1000);
|
||||
|
||||
/* revert to /dev/random for true random source */
|
||||
lib->settings->set_str(lib->settings,
|
||||
"libstrongswan.plugins.random.random", "/dev/random");
|
||||
#endif
|
||||
}
|
||||
END_TEST
|
||||
|
||||
@ -435,7 +429,7 @@ static chunk_t zero_pk = chunk_from_chars(
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00);
|
||||
|
||||
START_TEST(test_curve25519_ed25519_fail)
|
||||
START_TEST(test_ed25519_fail)
|
||||
{
|
||||
private_key_t *key;
|
||||
public_key_t *pubkey;
|
||||
@ -505,28 +499,28 @@ START_TEST(test_curve25519_ed25519_fail)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
Suite *curve25519_ed25519_suite_create()
|
||||
Suite *ed25519_suite_create()
|
||||
{
|
||||
Suite *s;
|
||||
TCase *tc;
|
||||
|
||||
s = suite_create("curve25519_ed25519");
|
||||
s = suite_create("ed25519");
|
||||
|
||||
tc = tcase_create("ed25519_sign");
|
||||
tcase_add_loop_test(tc, test_curve25519_ed25519_sign, 0, countof(sig_tests));
|
||||
tcase_add_loop_test(tc, test_ed25519_sign, 0, countof(sig_tests));
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
tc = tcase_create("ed25519_gen");
|
||||
tcase_add_test(tc, test_curve25519_ed25519_gen);
|
||||
tcase_add_test(tc, test_ed25519_gen);
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
tc = tcase_create("ed25519_fail");
|
||||
tcase_add_test(tc, test_curve25519_ed25519_fail);
|
||||
tcase_add_test(tc, test_ed25519_fail);
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
tc = tcase_create("ed25519_speed");
|
||||
test_case_set_timeout(tc, 10);
|
||||
tcase_add_test(tc, test_curve25519_ed25519_speed);
|
||||
tcase_add_test(tc, test_ed25519_speed);
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
return s;
|
@ -50,3 +50,5 @@ TEST_SUITE_DEPEND(mgf1_sha1_suite_create, XOF, XOF_MGF1_SHA1)
|
||||
TEST_SUITE_DEPEND(mgf1_sha256_suite_create, XOF, XOF_MGF1_SHA256)
|
||||
TEST_SUITE_DEPEND(ntru_suite_create, DH, NTRU_112_BIT)
|
||||
TEST_SUITE_DEPEND(fetch_http_suite_create, FETCHER, "http://")
|
||||
TEST_SUITE_DEPEND(ed25519_suite_create, PRIVKEY_GEN, KEY_ED25519)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user