diff options
| author | J08nY | 2018-02-27 20:48:21 +0100 |
|---|---|---|
| committer | J08nY | 2018-02-27 20:48:21 +0100 |
| commit | 40cbb213ac910ddcaf22a26a247d2a9eeddca1fc (patch) | |
| tree | 50c27834505d9994c9190bcb6ae7572bf2e9227b /test/src/math | |
| parent | 9abe42674361c08cc73e3fdd3891f72acaddc859 (diff) | |
| download | ecgen-40cbb213ac910ddcaf22a26a247d2a9eeddca1fc.tar.gz ecgen-40cbb213ac910ddcaf22a26a247d2a9eeddca1fc.tar.zst ecgen-40cbb213ac910ddcaf22a26a247d2a9eeddca1fc.zip | |
Add tests for Koblitz order store.
Diffstat (limited to 'test/src/math')
| -rw-r--r-- | test/src/math/test_koblitz.c | 33 |
1 files changed, 33 insertions, 0 deletions
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 <criterion/criterion.h> +#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 |
