cangrepp

Some cryptographic attacks
Log | Files | Refs | README

commit 4d0d581701c661d98c56b9d77b0c061c2ca11821
parent 847230c311c8d9e0101a1de98f69a7f800c966fe
Author: olikru <olikru@tkruger.se>
Date:   Thu, 11 Jan 2024 11:17:45 +0100

added asset and precomputer for primorial

Diffstat:
MMakefile | 11++++++++++-
Aassets/primorial16b.bin | 0
Aprecomputers/primorial16bit.c | 23+++++++++++++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile @@ -21,17 +21,21 @@ smallfactor.o\ hnp.o TOOLS=\ hnpsolve +PRECOMPUTERS=\ +primorial16bit SHARED=angrepp.so LIBSHARED=libangrepp.so BUILD_OBJS=$(OBJS:S/^/$(BUILD)\//g) TOOLS_DIR=tools +PRECOMPUTERS_DIR=precomputers -all: build $(OBJS) $(SHARED) $(TOOLS) test +all: build $(OBJS) $(SHARED) $(TOOLS) $(PRECOMPUTERS) test build: mkdir -p $(BUILD) mkdir -p $(BUILD)/tools + mkdir -p $(BUILD)/precomputers .c.o: $(CC) $(CFLAGS) -c $< -o $(BUILD)/$@ @@ -47,6 +51,11 @@ test: $(TEST_SOURCE) hnpsolve: build $(OBJS) $(CC) -I. $(CFLAGS) -o $(BUILD)/tools/hnpsolve $(TOOLS_DIR)/hnpsolve.c $(BUILD_OBJS) $(LDFLAGS) +# -- precomputers + +primorial16bit: build $(OBJS) + $(CC) -I. $(CFLAGS) -o $(BUILD)/precomputers/primorial16bit $(PRECOMPUTERS_DIR)/primorial16bit.c $(BUILD_OBJS) $(LDFLAGS) + install: mkdir -p $(INSTALL_PATH)/lib/angrepp cp $(BUILD)/$(SHARED) $(INSTALL_PATH)/lib/angrepp/$(LIBSHARED) diff --git a/assets/primorial16b.bin b/assets/primorial16b.bin Binary files differ. diff --git a/precomputers/primorial16bit.c b/precomputers/primorial16bit.c @@ -0,0 +1,23 @@ +/** + * Precomputes the primorial of 2^16 (i.e. the product of all primes < + * 2^16). The result is printed to stdout. This is used to create the + * assets/primorial16b.bin file. + */ +#include <stdlib.h> +#include <stdio.h> +#include <flint.h> +#include <fmpz.h> + +int main() { + fmpz_t primorial; + fmpz_init(primorial); + + fmpz_primorial(primorial, 1 << 16); + + if(fmpz_out_raw(stdout, primorial) == 0) { + fprintf(stderr, "Error! Writing to stdout failed.\n"); + exit(1); + } + + return 0; +}