diff --git a/src/generators/.gitignore b/src/generators/.gitignore index 4c5a3f7..13a1a31 100644 --- a/src/generators/.gitignore +++ b/src/generators/.gitignore @@ -1,7 +1,9 @@ +comba_mont_gen comba_mult_gen comba_mult_smallgen comba_sqr_gen comba_sqr_smallgen +comba_mont_gen.exe comba_mult_gen.exe comba_mult_smallgen.exe comba_sqr_gen.exe diff --git a/src/generators/comba_mont_gen.c b/src/generators/comba_mont_gen.c index 04870e3..b9071ef 100644 --- a/src/generators/comba_mont_gen.c +++ b/src/generators/comba_mont_gen.c @@ -1,12 +1,14 @@ #include +#include -int main(void) +int main(int argc, char **argv) { - int x, y, z; + int x, y, z, N = 16; + if (argc > 1) N = atoi(argv[1]); printf( #if 1 -"#ifdef TFM_SMALL_SET\n" +"#ifdef TFM_SMALL_MONT_SET\n" "/* computes x/R == x (mod N) via Montgomery Reduction */\n" "void fp_montgomery_reduce_small(fp_int *a, fp_int *m, fp_digit mp)\n" "{\n" @@ -34,7 +36,7 @@ printf( "\n" " switch (pa) {\n"); -for (x = 1; x <= 16; x++) { +for (x = 1; x <= N; x++) { if (x > 16 && (x != 32 && x != 48 && x != 64)) continue; if (x > 16) printf("#ifdef TFM_HUGE\n"); diff --git a/src/generators/makefile b/src/generators/makefile index aacb11a..55d85f1 100644 --- a/src/generators/makefile +++ b/src/generators/makefile @@ -1,6 +1,8 @@ all: comba_sqr_gen comba_sqr_smallgen clean: + rm -f comba_mont_gen + rm -f comba_mont_gen.exe rm -f comba_mult_gen rm -f comba_mult_gen.exe rm -f comba_mult_smallgen @@ -10,6 +12,8 @@ clean: rm -f comba_sqr_smallgen rm -f comba_sqr_smallgen.exe +comba_mont_gen: comba_mont_gen.c + gcc -o comba_mont_gen comba_mont_gen.c comba_mult_gen: comba_mult_gen.c gcc -o comba_mult_gen comba_mult_gen.c comba_mult_smallgen: comba_mult_smallgen.c @@ -19,7 +23,8 @@ comba_sqr_gen: comba_sqr_gen.c comba_sqr_smallgen: comba_sqr_smallgen.c gcc -o comba_sqr_smallgen comba_sqr_smallgen.c -regen: comba_mult_gen comba_mult_smallgen comba_sqr_gen comba_sqr_smallgen +regen: comba_mont_gen comba_mult_gen comba_mult_smallgen comba_sqr_gen comba_sqr_smallgen + ./comba_mont_gen > ../mont/fp_mont_small.i for i in 3 4 6 7 8 9 12 17 20 24 28 32 48 64; do \ ./comba_mult_gen $$i | sed -e 's/ *$$//' > ../mul/fp_mul_comba_$$i.c; \ done @@ -28,4 +33,3 @@ regen: comba_mult_gen comba_mult_smallgen comba_sqr_gen comba_sqr_smallgen ./comba_sqr_gen $$i | sed -e 's/ *$$//' > ../sqr/fp_sqr_comba_$$i.c; \ done ./comba_sqr_smallgen > ../sqr/fp_sqr_comba_small_set.c -