cangrepp

Some cryptographic attacks
Log | Files | Refs | README

commit 2eae90a8587d11c0b1df470fd30e5d4adcd85a17
parent 5bf07adcea2e5004f392618266f8191c32756c50
Author: olikru <olikru@tkruger.se>
Date:   Thu, 25 Apr 2024 13:20:56 +0200

added small tool

Diffstat:
MMakefile | 6+++++-
Msmallfactor.c | 2++
Atools/small.c | 26++++++++++++++++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile @@ -31,7 +31,8 @@ hnpsolve\ lcgfloyd\ dbtool\ pierre\ -varmkorv +varmkorv\ +small PRECOMPUTERS=\ primorial16bit SHARED=angrepp.so @@ -72,6 +73,9 @@ pierre: build $(OBJS) varmkorv: build $(OBJS) $(CC) -I. $(CFLAGS) -o $(BUILD)/tools/varmkorv $(TOOLS_DIR)/varmkorv.c $(BUILD_OBJS) $(LDFLAGS) +small: build $(OBJS) + $(CC) -I. $(CFLAGS) -o $(BUILD)/tools/small $(TOOLS_DIR)/small.c $(BUILD_OBJS) $(LDFLAGS) + dbtool: build $(OBJS) $(CC) -I. $(CFLAGS) -o $(BUILD)/tools/dbtool $(TOOLS_DIR)/dbtool.c $(BUILD_OBJS) $(LDFLAGS) -lsqlite3 diff --git a/smallfactor.c b/smallfactor.c @@ -32,6 +32,8 @@ smallfactor_euclidean(fmpz_t out, fmpz_t n) exit(EXIT_FAILURE); } + fclose(primorial_file); + fmpz_gcd(out, n, primorial); if (fmpz_cmp_ui(out, 1) > 0 && fmpz_cmp(out, n) < 0) { diff --git a/tools/small.c b/tools/small.c @@ -0,0 +1,26 @@ +#include <fmpz.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> + +#include "fmpzio.h" +#include "smallfactor.h" + +int +main(void) +{ + fmpz_t read, factor; + fmpz_init(factor); + fmpz_init(read); + + while (read_next_hex_fmpz(read) == 0) { + smallfactor_euclidean(factor, read); + fmpz_print(factor); + printf("\n"); + } + + fmpz_clear(factor); + fmpz_clear(read); + + return 0; +}