diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/exhaustive/ansi.c | 2 | ||||
| -rw-r--r-- | src/exhaustive/exhaustive.c | 4 | ||||
| -rw-r--r-- | src/io/cli.c | 14 | ||||
| -rw-r--r-- | src/io/config.h | 2 | ||||
| -rw-r--r-- | src/io/output.c | 11 |
5 files changed, 22 insertions, 11 deletions
diff --git a/src/exhaustive/ansi.c b/src/exhaustive/ansi.c index a2b24c8..b407d8e 100644 --- a/src/exhaustive/ansi.c +++ b/src/exhaustive/ansi.c @@ -150,7 +150,7 @@ static GENERATOR(ansi_gen_equation_fp) { curve->a = a; curve->b = b; - gerepileall(ltop, 3, &r, &a, &b); + gerepileall(ltop, 3, &curve->seed->ansi.r, &curve->a, &curve->b); bits_free(&c0); bits_free(&W0); bits_free(&W); diff --git a/src/exhaustive/exhaustive.c b/src/exhaustive/exhaustive.c index c15172a..af4be22 100644 --- a/src/exhaustive/exhaustive.c +++ b/src/exhaustive/exhaustive.c @@ -16,7 +16,7 @@ #include "util/memory.h" static void exhaustive_ginit(gen_t *generators, const config_t *cfg) { - if (cfg->from_seed) { + if (cfg->ansi) { // setup ANSI X9.62 generators if (cfg->seed) { generators[OFFSET_SEED] = &ansi_gen_seed_argument; @@ -144,7 +144,7 @@ static void exhaustive_ainit(arg_t **argss, const config_t *cfg) { } void exhaustive_uinit(unroll_t *unrolls, const config_t *cfg) { - if (cfg->from_seed) { + if (cfg->ansi) { unrolls[OFFSET_SEED] = &ansi_unroll_seed; } else { unrolls[OFFSET_SEED] = &unroll_skip; diff --git a/src/io/cli.c b/src/io/cli.c index 960c827..4c6dae2 100644 --- a/src/io/cli.c +++ b/src/io/cli.c @@ -19,7 +19,7 @@ enum opt_keys { OPT_PRIME = 'p', OPT_COFACTOR = 'k', OPT_RANDOM = 'r', - OPT_SEED = 's', + OPT_ANSI = 's', OPT_INVALID = 'i', OPT_ORDER = 'n', OPT_KOBLITZ = 'K', @@ -52,7 +52,7 @@ struct argp_option cli_options[] = { {"unique", OPT_UNIQUE, 0, 0, "Generate a curve with only one generator.", 2}, {"anomalous", OPT_ANOMALOUS, 0, 0, "Generate an anomalous curve (of trace one, with field order equal to curve order).", 2}, {"points", OPT_POINTS, "TYPE", 0, "Generate points of given type (random/prime/all/nonprime/none).", 2}, - {"seed", OPT_SEED, "SEED", OPTION_ARG_OPTIONAL, "Generate a curve from SEED (ANSI X9.62 verifiable procedure). **NOT IMPLEMENTED**", 2}, + {"ansi", OPT_ANSI, "SEED", OPTION_ARG_OPTIONAL, "Generate a curve from SEED (ANSI X9.62 verifiable procedure).", 2}, {"invalid", OPT_INVALID, 0, 0, "Generate a set of invalid curves, for a given curve (using Invalid curve algorithm).", 2}, {"order", OPT_ORDER, "ORDER", 0, "Generate a curve with given order (using Complex Multiplication). **NOT IMPLEMENTED**", 2}, {"count", OPT_COUNT, "COUNT", 0, "Generate multiple curves.", 2}, @@ -198,8 +198,8 @@ error_t cli_parse(int key, char *arg, struct argp_state *state) { } break; } - case OPT_SEED: - cfg->from_seed = true; + case OPT_ANSI: + cfg->ansi = true; if (arg) { if (!ansi_seed_valid(arg)) { argp_failure( @@ -236,13 +236,13 @@ error_t cli_parse(int key, char *arg, struct argp_state *state) { } // Invalid is not prime or seed by definition. if (cfg->invalid && - (cfg->prime || cfg->from_seed || cfg->cofactor)) { + (cfg->prime || cfg->ansi || cfg->cofactor)) { // not seed, not prime argp_failure(state, 1, 0, "Invalid curve generation can not generate curves " "from seed, exhaustive or prime order."); } - if (cfg->cm && (cfg->prime || cfg->from_seed || cfg->invalid || + if (cfg->cm && (cfg->prime || cfg->ansi || cfg->invalid || cfg->cofactor || cfg->anomalous)) { argp_failure(state, 1, 0, "Fixed order curve generation can not generate " @@ -251,7 +251,7 @@ error_t cli_parse(int key, char *arg, struct argp_state *state) { "prime."); } if (cfg->anomalous && - (cfg->binary_field || cfg->cofactor || cfg->from_seed || + (cfg->binary_field || cfg->cofactor || cfg->ansi || cfg->cm || cfg->invalid || cfg->koblitz)) { argp_failure( state, 1, 0, diff --git a/src/io/config.h b/src/io/config.h index 0894b5e..7b9a9dc 100644 --- a/src/io/config.h +++ b/src/io/config.h @@ -41,7 +41,7 @@ typedef struct { long koblitz_value; bool cofactor; long cofactor_bound; - bool from_seed; + bool ansi; char *seed; bool unique; struct points_s points; diff --git a/src/io/output.c b/src/io/output.c index 4cabafd..4e951a2 100644 --- a/src/io/output.c +++ b/src/io/output.c @@ -5,6 +5,7 @@ #include "output.h" #include <parson/parson.h> +#include "util/bits.h" #include "gen/field.h" #include "util/memory.h" @@ -154,6 +155,16 @@ static JSON_Value *output_jjson(curve_t *curve, const config_t *cfg) { fprintf(err, "Error, field has unknown amount of elements.\n"); exit(1); } + if (curve->seed) { + char *hex_str = bits_to_hex(curve->seed->seed); + char *hex = try_calloc(strlen(hex_str) + 3); + hex[0] = '0'; + hex[1] = 'x'; + strcat(hex, hex_str); + json_object_set_string(root_object, "seed", hex); + try_free(hex_str); + try_free(hex); + } char *a = pari_sprintf("%P0#*x", cfg->hex_digits, field_elementi(curve->a)); json_object_set_string(root_object, "a", a); |
