aboutsummaryrefslogtreecommitdiff
path: root/src/misc/config.h
blob: 6c61b0f336310d1e567e9defdc01dd945bfc94f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
 * ecgen, tool for generating Elliptic curve domain parameters
 * Copyright (C) 2017-2018 J08nY
 */
/**
 * @file config.h
 */
#ifndef ECGEN_MISC_CONFIG_H
#define ECGEN_MISC_CONFIG_H

#include <stdbool.h>
#include <stddef.h>

enum field_e { FIELD_PRIME = 1 << 0, FIELD_BINARY = 1 << 1 };
enum format_e { FORMAT_JSON };
enum points_e {
	POINTS_PRIME = 0,
	POINTS_NONPRIME,
	POINTS_RANDOM,
	POINTS_ALL,
	POINTS_NONE
};
struct points_s {
	enum points_e type;
	size_t amount;
};

/**
 * @brief
 */
typedef enum {
	RANDOM_NONE = 0,
	RANDOM_SEED = 1 << 0,
	RANDOM_FIELD = 1 << 1,
	RANDOM_A = 1 << 2,
	RANDOM_B = 1 << 3,
	RANDOM_EQUATION = RANDOM_A | RANDOM_B,
	RANDOM_ALL = RANDOM_SEED | RANDOM_FIELD | RANDOM_EQUATION
} random_e;

/**
 * @brief
 */
typedef enum {
	METHOD_DEFAULT = 0,
	METHOD_CM = 1 << 0,
	METHOD_ANOMALOUS = 1 << 1,
	METHOD_SEED = 1 << 2,
	METHOD_INVALID = 1 << 3,
	METHOD_TWIST = 1 << 4,
	METHOD_SUPERSINGULAR = 1 << 5
} method_e;

/**
 * @brief
 */
typedef enum {
	SEED_NONE = 0,
	SEED_ANSI,
	SEED_BRAINPOOL,
	SEED_BRAINPOOL_RFC,
	SEED_FIPS
} seed_e;

/**
 * @brief
 */
typedef struct {
	/** @brief What field should the curves be generated over. */
	enum field_e field;

	/** @brief Generation method. */
	method_e method;

	/** @brief How many curves should be generated. */
	long count;
	/** @brief What parameters should be generated at random (no input). */
	random_e random;
	/** @brief Whether the curves should have prime order. */
	bool prime;
	/** @brief Whether the Complex Multiplication method should be used. */
	char *cm_order;
	/** @brief Whether the Anomalous method should be used. */
	char *anom_order;
	/** @brief Whether the curves should be Koblitz (a \\in {0, 1}, b = 1). */
	bool koblitz;
	long koblitz_value;
	/** @brief Whether the curves should have a bound on the cofactor value. */
	bool cofactor;
	long cofactor_value;
	/** @brief A range of prime orders that should be generated in invalid
	 * generation. */
	char *invalid_primes;
	/** @brief What seed algorithm, if any, to use to generate the curves. */
	seed_e seed_algo;
	/** @brief What seed to use, if any, to generate the curves. */
	char *seed;
	/** @brief Whether the curves should be uniquely generated (one generator).
	 */
	bool unique;
	/** @brief */
	char *hex_check;
	/** @brief What points to generate on the curves. */
	struct points_s points;
	/** @brief Compute curve metadata. */
	bool metadata;

	/** @brief The datadir to use, if any. */
	char *datadir;
	/** @brief How much memory to allocate for the PARI stack. */
	unsigned long memory;
	/** @brief How many threads to use, only useful for invalid generation(atm).
	 */
	unsigned long threads;
	/** @brief How much memory to allocate for the PARI stack, per thread. */
	unsigned long thread_memory;
	/** @brief How long of a timeout interval, if any, to give to parameter
	 * generation. */
	unsigned long timeout;

	/** @brief What output format to use. */
	enum format_e format;
	/** @brief What, if any, output file to write to. */
	char *output;
	/** @brief What, if any, input file to read from. */
	char *input;
	/** @brief Whether to append or truncate the output file on output. */
	bool append;

	/** @brief What verbosity level to run on. */
	long verbose;
	/** @brief What file, if any, to write the verbose messages. */
	char *verbose_log;

	/** @brief The size of the field to generate curves over, in bits. */
	unsigned long bits;
	unsigned long hex_digits;
} config_t;

extern config_t cfg_s;
extern config_t *cfg;

#endif  // ECGEN_MISC_CONFIG_H