diff options
| author | J08nY | 2017-03-01 11:33:16 +0100 |
|---|---|---|
| committer | J08nY | 2017-03-01 11:33:16 +0100 |
| commit | fdd2bbaf35270c5ab63bf3c601ab199f2092ab2c (patch) | |
| tree | 6bb9eec9d4608545ec6bc61056061f7e92d7c409 /src/io/cli.c | |
| parent | 8c230aa00002b57d47160756a183d65fb895a7b4 (diff) | |
| download | ecgen-fdd2bbaf35270c5ab63bf3c601ab199f2092ab2c.tar.gz ecgen-fdd2bbaf35270c5ab63bf3c601ab199f2092ab2c.tar.zst ecgen-fdd2bbaf35270c5ab63bf3c601ab199f2092ab2c.zip | |
Diffstat (limited to 'src/io/cli.c')
| -rw-r--r-- | src/io/cli.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/io/cli.c b/src/io/cli.c index 798d596..374b949 100644 --- a/src/io/cli.c +++ b/src/io/cli.c @@ -26,7 +26,8 @@ enum opt_keys { OPT_APPEND = 'a', OPT_VERBOSE = 'v', OPT_FP = 1, - OPT_F2M = 2, + OPT_F2M, + OPT_POINTS }; // clang-format off @@ -42,7 +43,8 @@ struct argp_option options[] = { {"order", OPT_ORDER, "ORDER", 0, "Generate a curve with given order (using Complex Multiplication).", 2}, {"koblitz", OPT_KOBLITZ, 0, 0, "Generate a Koblitz curve (a = 0).", 2}, {"unique", OPT_UNIQUE, 0, 0, "Generate a curve with only one generator.", 2}, - //{"count", OPT_COUNT, "COUNT", 0, "Generate multiple (COUNT) curves."}, + {"points", OPT_POINTS, "TYPE", 0, "Generate points of given type (random/prime).", 2}, + {"count", OPT_COUNT, "COUNT", 0, "Generate multiple curves.", 2}, {0, 0, 0, 0, "Input/Output options:", 3}, {"format", OPT_FORMAT, "FORMAT", 0, "Format to output in. One of [csv,json], default is json.", 3}, {"input", OPT_INPUT, "FILE", 0, "Input from file.", 3}, @@ -109,6 +111,21 @@ error_t cli_parse(int key, char *arg, struct argp_state *state) { break; case OPT_UNIQUE: cfg->unique = true; break; + case OPT_POINTS: + if (arg) { + if (strstr(arg, "random")) { + long pts = strtol(arg, NULL, 10); + cfg->points.type = POINTS_RANDOM; + cfg->points.amount = (size_t)pts; + } else if (strstr(arg, "prime")) { + cfg->points.type = POINTS_PRIME; + } else { + argp_failure(state, 1, 0, "Unknow point type"); + } + } else { + argp_failure(state, 1, 0, "You have to specify what points you want."); + } + break; case OPT_SEED: cfg->from_seed = true; if (arg) { // ANSI X9.62 specifies seed as at least 160 bits in length. |
