From 40cbb213ac910ddcaf22a26a247d2a9eeddca1fc Mon Sep 17 00:00:00 2001 From: J08nY Date: Tue, 27 Feb 2018 20:48:21 +0100 Subject: Add tests for Koblitz order store. --- test/src/math/test_koblitz.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/src/math/test_koblitz.c (limited to 'test/src/math') diff --git a/test/src/math/test_koblitz.c b/test/src/math/test_koblitz.c new file mode 100644 index 0000000..03e411c --- /dev/null +++ b/test/src/math/test_koblitz.c @@ -0,0 +1,33 @@ +/* + * ecgen, tool for generating Elliptic curve domain parameters + * Copyright (C) 2017 J08nY + */ +#include +#include "gen/point.h" +#include "math/koblitz.h" +#include "test/default.h" + +TestSuite(koblitz, .init = default_setup, .fini = default_teardown); + +Test(koblitz, test_koblitz_is_curve) { + curve_t curve = { + .field = stoi(23), + .a = mkintmodu(3, 23), + .b = mkintmodu(2, 23) + }; + + cr_assert_not(koblitz_is_curve(&curve),); + curve.a = mkintmodu(1, 23); + curve.b = mkintmodu(1, 23); + cr_assert(koblitz_is_curve(&curve),); +} + +Test(koblitz, test_koblitz_find) { + const koblitz_t *koblitz = koblitz_find(107, 0); + cr_assert_not_null(koblitz, ); +} + +Test(koblitz, test_koblitz_get_order) { + GEN order = koblitz_get_order(107, 0); + cr_assert(gequal(order, strtoi("0x7ffffffffffffb57c25324737c4")), ); +} \ No newline at end of file -- cgit v1.2.3-70-g09d2