diff --git a/src/cm/cm.c b/src/cm/cm.c index b606f83..9dffc1d 100644 --- a/src/cm/cm.c +++ b/src/cm/cm.c @@ -74,6 +74,7 @@ static void cm_ginit(gen_f *generators, bool prime) { } generators[OFFSET_ORDER] = &cm_gen_order; } else if (cfg->method == METHOD_ANOMALOUS) { + GET(random); // Used within the method. generators[OFFSET_FIELD] = &anomalous_gen_field; generators[OFFSET_A] = &gen_skip; generators[OFFSET_B] = &anomalous_gen_equation; @@ -247,6 +248,7 @@ int cm_do() { if (result) { return result; } + GET(count); config_report_unused(); result = exhaustive_generate(&setup); diff --git a/src/ecgen.c b/src/ecgen.c index 238311b..3c9b227 100644 --- a/src/ecgen.c +++ b/src/ecgen.c @@ -120,6 +120,7 @@ int main(int argc, char *argv[]) { } int status; + GET(method); if (cfg->method == METHOD_CM || cfg->method == METHOD_ANOMALOUS || cfg->method == METHOD_SUPERSINGULAR) { status = cm_do(); diff --git a/src/exhaustive/exhaustive.c b/src/exhaustive/exhaustive.c index 413f93b..6523170 100644 --- a/src/exhaustive/exhaustive.c +++ b/src/exhaustive/exhaustive.c @@ -484,6 +484,7 @@ int exhaustive_do() { .check_argss = check_argss, .unrolls = unrolls}; exhaustive_init(&setup); + GET(count); config_report_unused(); int result = exhaustive_generate(&setup); exhaustive_quit(&setup); diff --git a/src/invalid/invalid.c b/src/invalid/invalid.c index d7433fc..3679c6b 100644 --- a/src/invalid/invalid.c +++ b/src/invalid/invalid.c @@ -77,7 +77,6 @@ static size_t invalid_primes(GEN order, pari_ulong **primes) { pari_ulong upper = 0; size_t nprimes = 0; - GET(invalid_primes); if (cfg->invalid_primes) { char *end = NULL; last = (pari_ulong)strtol(cfg->invalid_primes, &end, 10) - 1; @@ -353,6 +352,7 @@ int invalid_do() { .check_argss = common_check_argss, .unrolls = common_unrolls}; invalid_invalid_ginit(invalid_gens); + GET(invalid_primes); config_report_unused(); debug_log_start("Starting to create curve to invalidate"); diff --git a/src/io/cli.c b/src/io/cli.c index 5307d70..5f29047 100644 --- a/src/io/cli.c +++ b/src/io/cli.c @@ -205,6 +205,16 @@ static void cli_end(struct argp_state *state) { "Can only generate supersingular curves over prime fields " "currently."); } + // Some method specific things + if (cfg->method == METHOD_SEED && cfg->seed_algo == SEED_NUMS && + cfg->random) { + argp_failure(state, 1, 0, + "NUMS curve generation is a deterministic process."); + } + if (cfg->method == METHOD_ANOMALOUS && !cfg->random) { + argp_failure(state, 1, 0, + "Anomalous curves can only be generated randomly (specify the -r option)."); + } // default values if (!cfg->count) { cfg->count = 1; diff --git a/src/misc/config.c b/src/misc/config.c index 8beeae0..155cbb4 100644 --- a/src/misc/config.c +++ b/src/misc/config.c @@ -4,6 +4,7 @@ */ #include "config.h" #include +#include config_t cfg_s; config_t *cfg = &cfg_s; @@ -15,83 +16,108 @@ config_names_t cfg_set_s = {0}; config_names_t *cfg_set = &cfg_set_s; void config_report_unused() { + bool unused = false; if (cfg_set->field && !cfg_used->field) { fprintf( stderr, "Warning: Ignored command-line argument \"field\" (--fp/--f2m).\n"); + unused = true; } if (cfg_set->method && !cfg_used->method) { fprintf(stderr, "Warning: Ignored command-line argument method.\n"); + unused = true; } if (cfg_set->count && !cfg_used->count) { fprintf(stderr, "Warning: Ignored command-line argument count (-c/--count).\n"); + unused = true; } if (cfg_set->random && !cfg_used->random) { fprintf( stderr, "Warning: Ignored command-line argument random (-r/--random).\n"); + unused = true; } if (cfg_set->prime && !cfg_used->prime) { fprintf(stderr, "Warning: Ignored command-line argument prime (-p/--prime).\n"); + unused = true; } if (cfg_set->cm_order && !cfg_used->cm_order) { fprintf( stderr, "Warning: Ignored command-line argument cm_order (-n/--order).\n"); + unused = true; } if (cfg_set->koblitz && !cfg_used->koblitz) { fprintf( stderr, "Warning: Ignored command-line argument koblitz (-K/--koblitz).\n"); + unused = true; } if (cfg_set->koblitz_value && !cfg_used->koblitz_value) { fprintf(stderr, "Warning: Ignored command-line argument koblitz_value " "(-K/--koblitz).\n"); + unused = true; } if (cfg_set->smooth && !cfg_used->smooth) { fprintf( stderr, "Warning: Ignored command-line argument smooth (-B/--smooth).\n"); + unused = true; } if (cfg_set->cofactor && !cfg_used->cofactor) { fprintf(stderr, "Warning: Ignored command-line argument cofactor " "(-k/--cofactor).\n"); + unused = true; } if (cfg_set->invalid_primes && !cfg_used->invalid_primes) { fprintf(stderr, "Warning: Ignored command-line argument invalid_primes " "(-i/--invalid).\n"); + unused = true; } if (cfg_set->seed_algo && !cfg_used->seed_algo) { fprintf( stderr, "Warning: Ignored command-line argument seed_algo (-s/--ansi).\n"); + unused = true; } if (cfg_set->seed && !cfg_used->seed) { fprintf(stderr, "Warning: Ignored command-line argument seed (-s/--ansi).\n"); + unused = true; } if (cfg_set->unique && !cfg_used->unique) { fprintf( stderr, "Warning: Ignored command-line argument unique (-u/--unique).\n"); + unused = true; } if (cfg_set->hex_check && !cfg_used->hex_check) { fprintf(stderr, "Warning: Ignored command-line argument hex_check " "(--hex-check).\n"); + unused = true; } if (cfg_set->points && !cfg_used->points) { fprintf(stderr, "Warning: Ignored command-line argument points (--points).\n"); + unused = true; } if (cfg_set->metadata && !cfg_used->metadata) { fprintf( stderr, "Warning: Ignored command-line argument metadata (--metadata).\n"); + unused = true; } +#if DEBUG + if (unused) { + exit(42); + } +#else + (void)unused; +#endif } \ No newline at end of file diff --git a/test/ecgen.sh b/test/ecgen.sh index 86fe244..7aa146b 100755 --- a/test/ecgen.sh +++ b/test/ecgen.sh @@ -94,8 +94,8 @@ function brainpool() { function nums() { start_test - assert_raises "${ecgen} --fp -r --nums 10" - assert_raises "${ecgen} --f2m -r --nums 10" 1 + assert_raises "${ecgen} --fp --nums 10" + assert_raises "${ecgen} --f2m --nums 10" 1 } function anomalous() {