diff options
| author | J08nY | 2017-09-19 13:17:22 +0200 |
|---|---|---|
| committer | J08nY | 2017-09-19 13:17:22 +0200 |
| commit | bbcff0f1875f3ac1db7964b228db34350fb84833 (patch) | |
| tree | 49787fc74c5c2460a2b0711b46595c7b4afb11d8 | |
| parent | 2bacc9d1dee4ec1003635edae93b1a03dbb2a12d (diff) | |
| download | ecgen-bbcff0f1875f3ac1db7964b228db34350fb84833.tar.gz ecgen-bbcff0f1875f3ac1db7964b228db34350fb84833.tar.zst ecgen-bbcff0f1875f3ac1db7964b228db34350fb84833.zip | |
| -rw-r--r-- | src/exhaustive/anomalous.h | 2 | ||||
| -rw-r--r-- | src/exhaustive/ansi.c | 22 | ||||
| -rw-r--r-- | src/exhaustive/ansi.h | 2 | ||||
| -rw-r--r-- | src/exhaustive/exhaustive.c | 2 | ||||
| -rw-r--r-- | src/gen/curve.c | 2 | ||||
| -rw-r--r-- | src/gen/curve.h | 1 | ||||
| -rw-r--r-- | src/gen/equation.c | 1 | ||||
| -rw-r--r-- | src/gen/seed.c | 1 | ||||
| -rw-r--r-- | src/gen/seed.h | 1 | ||||
| -rw-r--r-- | src/io/cli.c | 9 | ||||
| -rw-r--r-- | src/io/output.c | 2 | ||||
| -rw-r--r-- | src/misc/types.h | 6 |
12 files changed, 24 insertions, 27 deletions
diff --git a/src/exhaustive/anomalous.h b/src/exhaustive/anomalous.h index cf8c208..1750f4b 100644 --- a/src/exhaustive/anomalous.h +++ b/src/exhaustive/anomalous.h @@ -10,8 +10,8 @@ #include <pari/pari.h> #include "arg.h" -#include "misc/types.h" #include "io/cli.h" +#include "misc/types.h" typedef struct disc_t { GEN d; diff --git a/src/exhaustive/ansi.c b/src/exhaustive/ansi.c index 40fbf41..6c36063 100644 --- a/src/exhaustive/ansi.c +++ b/src/exhaustive/ansi.c @@ -1,13 +1,12 @@ +#include "ansi.h" #include <misc/config.h> #include <misc/types.h> -#include "ansi.h" -#include "gen/seed.h" #include "gen/field.h" +#include "gen/seed.h" +#include "io/output.h" #include "util/bits.h" #include "util/memory.h" -#include "io/output.h" - bool ansi_seed_valid(const char *hex_str) { size_t len = strlen(hex_str); @@ -40,8 +39,8 @@ static void seed_hash(seed_t *seed) { static void seed_tsh(seed_t *seed, const config_t *cfg) { pari_sp ltop = avma; seed->ansi.t = utoi(cfg->bits); - seed->ansi.s = floorr( - rdivii(subis(seed->ansi.t, 1), stoi(160), DEFAULTPREC)); + seed->ansi.s = + floorr(rdivii(subis(seed->ansi.t, 1), stoi(160), DEFAULTPREC)); seed->ansi.h = subii(seed->ansi.t, mulis(seed->ansi.s, 160)); gerepileall(ltop, 3, &seed->ansi.t, &seed->ansi.s, &seed->ansi.h); } @@ -144,7 +143,7 @@ static GENERATOR(ansi_gen_equation_fp) { do { a = random_int(cfg->bits); b2 = mulii(powis(a, 3), r_inv); - }while (!Fp_issquare(b2, curve->field)); + } while (!Fp_issquare(b2, curve->field)); GEN b = Fp_sqrt(b2, curve->field); curve->a = a; @@ -180,9 +179,12 @@ static GENERATOR(ansi_gen_equation_f2m) { GENERATOR(ansi_gen_equation) { switch (cfg->field) { - case FIELD_PRIME: return ansi_gen_equation_fp(curve, cfg, args); - case FIELD_BINARY: return ansi_gen_equation_f2m(curve, cfg, args); - default: pari_err_BUG("Field not prime or binary?"); + case FIELD_PRIME: + return ansi_gen_equation_fp(curve, cfg, args); + case FIELD_BINARY: + return ansi_gen_equation_f2m(curve, cfg, args); + default: + pari_err_BUG("Field not prime or binary?"); return INT_MIN; /* NOT REACHABLE */ } } diff --git a/src/exhaustive/ansi.h b/src/exhaustive/ansi.h index 74e787e..ec24e13 100644 --- a/src/exhaustive/ansi.h +++ b/src/exhaustive/ansi.h @@ -52,4 +52,4 @@ UNROLL(ansi_unroll_seed); */ GENERATOR(ansi_gen_equation); -#endif //ECGEN_ANSI_H +#endif // ECGEN_ANSI_H diff --git a/src/exhaustive/exhaustive.c b/src/exhaustive/exhaustive.c index 0506409..a83bd42 100644 --- a/src/exhaustive/exhaustive.c +++ b/src/exhaustive/exhaustive.c @@ -2,8 +2,8 @@ * ecgen, tool for generating Elliptic curve domain parameters * Copyright (C) 2017 J08nY */ -#include <misc/config.h> #include "exhaustive.h" +#include <misc/config.h> #include "anomalous.h" #include "ansi.h" #include "gen/curve.h" diff --git a/src/gen/curve.c b/src/gen/curve.c index 3a8d00d..b160c97 100644 --- a/src/gen/curve.c +++ b/src/gen/curve.c @@ -2,8 +2,8 @@ * ecgen, tool for generating Elliptic curve domain parameters * Copyright (C) 2017 J08nY */ -#include <misc/config.h> #include "curve.h" +#include <misc/config.h> #include "point.h" #include "seed.h" #include "util/memory.h" diff --git a/src/gen/curve.h b/src/gen/curve.h index f5e6553..1f823df 100644 --- a/src/gen/curve.h +++ b/src/gen/curve.h @@ -35,7 +35,6 @@ GENERATOR(curve_gen_any); */ GENERATOR(curve_gen_nonzero); - /** * * @param curve diff --git a/src/gen/equation.c b/src/gen/equation.c index 33d41a9..76d0498 100644 --- a/src/gen/equation.c +++ b/src/gen/equation.c @@ -56,7 +56,6 @@ GENERATOR(a_gen_one) { return 1; } - GENERATOR(b_gen_random) { curve->b = genrand(curve->field); return 1; diff --git a/src/gen/seed.c b/src/gen/seed.c index 1653a50..2a806e9 100644 --- a/src/gen/seed.c +++ b/src/gen/seed.c @@ -48,4 +48,3 @@ void seed_free(seed_t **seed) { *seed = NULL; } } - diff --git a/src/gen/seed.h b/src/gen/seed.h index c89fc1d..a2123bf 100644 --- a/src/gen/seed.h +++ b/src/gen/seed.h @@ -53,5 +53,4 @@ seed_t *seed_new_clone(const seed_t *src); */ void seed_free(seed_t **seed); - #endif // ECGEN_SEED_H diff --git a/src/io/cli.c b/src/io/cli.c index 4545e7f..ce9d3d9 100644 --- a/src/io/cli.c +++ b/src/io/cli.c @@ -5,8 +5,8 @@ #include "cli.h" #include <string.h> #include <unistd.h> -#include "misc/config.h" #include "exhaustive/ansi.h" +#include "misc/config.h" char cli_doc[] = "ecgen, tool for generating Elliptic curve domain parameters.\v(C) 2017 " @@ -235,8 +235,7 @@ error_t cli_parse(int key, char *arg, struct argp_state *state) { "--f2m (but not both)."); } // Invalid is not prime or seed by definition. - if (cfg->invalid && - (cfg->prime || cfg->ansi || cfg->cofactor)) { + if (cfg->invalid && (cfg->prime || cfg->ansi || cfg->cofactor)) { // not seed, not prime argp_failure(state, 1, 0, "Invalid curve generation can not generate curves " @@ -251,8 +250,8 @@ error_t cli_parse(int key, char *arg, struct argp_state *state) { "prime."); } if (cfg->anomalous && - (cfg->binary_field || cfg->cofactor || cfg->ansi || - cfg->cm || cfg->invalid || cfg->koblitz)) { + (cfg->binary_field || cfg->cofactor || cfg->ansi || cfg->cm || + cfg->invalid || cfg->koblitz)) { argp_failure( state, 1, 0, "Anomalous curve generation can not generate " diff --git a/src/io/output.c b/src/io/output.c index 4e951a2..4a2427e 100644 --- a/src/io/output.c +++ b/src/io/output.c @@ -5,8 +5,8 @@ #include "output.h" #include <parson/parson.h> -#include "util/bits.h" #include "gen/field.h" +#include "util/bits.h" #include "util/memory.h" FILE *out; diff --git a/src/misc/types.h b/src/misc/types.h index b75394c..b599759 100644 --- a/src/misc/types.h +++ b/src/misc/types.h @@ -113,7 +113,7 @@ typedef struct { * @return state diff */ #define GENERATOR(gen_name) \ - int gen_name(curve_t *curve, const config_t *cfg, arg_t *args) + int gen_name(curve_t *curve, const config_t *cfg, arg_t *args) typedef GENERATOR((*gen_t)); @@ -126,8 +126,8 @@ typedef GENERATOR((*gen_t)); * @return */ #define UNROLL(unroll_name) \ - int unroll_name(curve_t *curve, const config_t *cfg, pari_sp from, \ - pari_sp to) + int unroll_name(curve_t *curve, const config_t *cfg, pari_sp from, \ + pari_sp to) typedef UNROLL((*unroll_t)); |
