cangrepp

Some cryptographic attacks
Log | Files | Refs | README

commit 63f2128090e0906f6e77df62e1cc6f207f2ada6d
parent d162e6c2fb73d96c9ee2c09f23595fd12e144364
Author: olikru <olikru@tkruger.se>
Date:   Tue, 16 Apr 2024 12:39:52 +0200

added test case for smallfactor

Diffstat:
Mtest_angrepp.c | 27++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/test_angrepp.c b/test_angrepp.c @@ -7,6 +7,7 @@ #include "cyclefind.h" #include "pierre.h" #include "wiener.h" +#include "smallfactor.h" static uint64_t test_f(uint64_t x) @@ -55,6 +56,7 @@ static void test_wiener_factor_small_d(void) { fmpz_t N, e, res; + int ret; fmpz_init(N); fmpz_init(e); fmpz_init(res); @@ -62,7 +64,7 @@ test_wiener_factor_small_d(void) fmpz_set_str(N, "32193226917433121", 10); fmpz_set_str(e, "8403467516040173", 10); - int ret = wiener_factor_small_d(res, e, N); + ret = wiener_factor_small_d(res, e, N); assert(ret == 1); assert(fmpz_divisible(N, res)); @@ -73,6 +75,28 @@ test_wiener_factor_small_d(void) fmpz_clear(res); } +static void +test_smallfactor_euclidean(void) +{ + fmpz_t N, res; + int ret; + fmpz_init(N); + fmpz_init(res); + + // N = 61363 * 1278934673 + fmpz_set_str(N, "78607161806599", 10); + + ret = smallfactor_euclidean(res, N); + + assert(ret == SMALLFACTOR_FOUND); + assert(fmpz_divisible(N, res)); + assert(fmpz_cmp_ui(res, 1) > 0); + assert(fmpz_cmp(res, N) < 0); + + fmpz_clear(N); + fmpz_clear(res); +} + int main(void) { @@ -80,6 +104,7 @@ main(void) test_cyclefind_brent(); test_pierre_factor(); test_wiener_factor_small_d(); + test_smallfactor_euclidean(); printf("test ok\n"); }