diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b17a273 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{c,h}] +indent_style = tab + +[{GNUmakefile.in,configure.ac}] +indent_style = tab + +[ed25519/{ref10,amd64-51-30k,amd64-64-24k}/*.{c,h,py}] +indent_style = space +indent_size = 2 diff --git a/GNUmakefile.in b/GNUmakefile.in index d7cff38..c457061 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -122,6 +122,7 @@ distclean: clean $(RM) GNUmakefile depend: + # makedepend from imake cd "@SRCDIR@" && makedepend -Y -fGNUmakefile.in -o.c.o -- $(CSTD) $(ED25519_DEFS) -- $(ALL_C) VPATH=@SRCDIR@ @@ -397,7 +398,8 @@ ed25519/ref10/sign.c.o: ed25519/ref10/crypto_int32.h ed25519/ref10/sc.h ioutil.c.o: types.h ioutil.h keccak.c.o: types.h keccak.h main.c.o: types.h vec.h base32.h cpucount.h keccak.h ioutil.h common.h yaml.h -main.c.o: filters.h worker.h filters_main.inc.h filters_common.inc.h +main.c.o: filters.h worker.h filters_inc.inc.h filters_main.inc.h +main.c.o: filters_common.inc.h test_base16.c.o: types.h base16.h test_base32.c.o: types.h base32.h test_base64.c.o: types.h base64.h @@ -452,7 +454,7 @@ worker.c.o: ed25519/ed25519-donna/ed25519-donna-32bit-sse2.h worker.c.o: ed25519/ed25519-donna/ed25519-donna-64bit-sse2.h worker.c.o: ed25519/ed25519-donna/ed25519-donna-impl-sse2.h worker.c.o: ed25519/ed25519-donna/ed25519-donna-impl-base.h ioutil.h common.h -worker.c.o: yaml.h worker.h filters.h filters_worker.inc.h +worker.c.o: yaml.h worker.h filters.h filters_inc.inc.h filters_worker.inc.h worker.c.o: filters_common.inc.h worker_slow.inc.h worker_fast.inc.h worker.c.o: worker_fast_pass.inc.h worker_batch.inc.h worker_batch_pass.inc.h yaml.c.o: types.h yaml.h ioutil.h base32.h base64.h common.h diff --git a/configure.ac b/configure.ac index 9c2ddac..3ff867d 100644 --- a/configure.ac +++ b/configure.ac @@ -33,9 +33,9 @@ oldcflags="$CFLAGS" CFLAGS="-nopie -Werror" AC_MSG_CHECKING([whether CC supports -nopie]) AC_LINK_IFELSE([AC_LANG_PROGRAM([])], - [AC_MSG_RESULT([yes])] - [nopie="-nopie"], - [AC_MSG_RESULT([no])] + [AC_MSG_RESULT([yes])] + [nopie="-nopie"], + [AC_MSG_RESULT([no])] ) CFLAGS="$oldcflags" @@ -178,35 +178,35 @@ oldcflags="$CFLAGS" CFLAGS="-std=c99" AC_MSG_CHECKING([whether CC supports -std=c99]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], - [AC_MSG_RESULT([yes])] - [c99="yes"] - [cstd="-std=c99"], - [AC_MSG_RESULT([no])] + [AC_MSG_RESULT([yes])] + [c99="yes"] + [cstd="-std=c99"], + [AC_MSG_RESULT([no])] ) CFLAGS="$cstd -Wall" AC_MSG_CHECKING([whether CC supports -Wall]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], - [AC_MSG_RESULT([yes])] - [cstd="$cstd -Wall"], - [AC_MSG_RESULT([no])] + [AC_MSG_RESULT([yes])] + [cstd="$cstd -Wall"], + [AC_MSG_RESULT([no])] ) CFLAGS="$cstd -Wextra" AC_MSG_CHECKING([whether CC supports -Wextra]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], - [AC_MSG_RESULT([yes])] - [cstd="$cstd -Wextra"], - [AC_MSG_RESULT([no])] + [AC_MSG_RESULT([yes])] + [cstd="$cstd -Wextra"], + [AC_MSG_RESULT([no])] ) # (negative) detection on clang fails without -Werror CFLAGS="$cstd -Wno-maybe-uninitialized -Werror" AC_MSG_CHECKING([whether CC supports -Wno-maybe-uninitialized]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], - [AC_MSG_RESULT([yes])] - [cstd="$cstd -Wno-maybe-uninitialized"], - [AC_MSG_RESULT([no])] + [AC_MSG_RESULT([yes])] + [cstd="$cstd -Wno-maybe-uninitialized"], + [AC_MSG_RESULT([no])] ) if test "x$c99" = "xyes" -a "x$ed25519impl" != "xdonna" -a "x$enable_intfilter" != "x128" @@ -244,18 +244,18 @@ fi CFLAGS="$cstd -Wmissing-prototypes -Werror" AC_MSG_CHECKING([whether CC supports -Wmissing-prototypes]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], - [AC_MSG_RESULT([yes])] - [cstd="$cstd -Wmissing-prototypes"], - [AC_MSG_RESULT([no])] + [AC_MSG_RESULT([yes])] + [cstd="$cstd -Wmissing-prototypes"], + [AC_MSG_RESULT([no])] ) # XXX AC_LANG_PROGRAM produces unsuitable prototype so this check must be last one CFLAGS="$cstd -Wstrict-prototypes -Werror" AC_MSG_CHECKING([whether CC supports -Wstrict-prototypes]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])], - [AC_MSG_RESULT([yes])] - [cstd="$cstd -Wstrict-prototypes"], - [AC_MSG_RESULT([no])] + [AC_MSG_RESULT([yes])] + [cstd="$cstd -Wstrict-prototypes"], + [AC_MSG_RESULT([no])] ) CFLAGS="$oldcflags" diff --git a/filters_common.inc.h b/filters_common.inc.h index 613e694..dbe2fd8 100644 --- a/filters_common.inc.h +++ b/filters_common.inc.h @@ -1,6 +1,6 @@ #ifdef INTFILTER -static inline size_t filter_len(size_t i) +static inline size_t S(filter_len)(size_t i) { # ifndef OMITMASK const u8 *m = (const u8 *)&VEC_BUF(filters,i).m; @@ -23,12 +23,13 @@ static inline size_t filter_len(size_t i) } return c; } +#define filter_len S(filter_len) #endif // INTFILTER #ifdef BINFILTER -static inline size_t filter_len(size_t i) +static inline size_t S(filter_len)(size_t i) { size_t c = VEC_BUF(filters,i).len * 8; u8 v = VEC_BUF(filters,i).mask; @@ -41,6 +42,7 @@ static inline size_t filter_len(size_t i) v <<= 1; } } +#define filter_len S(filter_len) #endif // BINFILTER diff --git a/filters_inc.inc.h b/filters_inc.inc.h new file mode 100644 index 0000000..5eb7f72 --- /dev/null +++ b/filters_inc.inc.h @@ -0,0 +1 @@ +#define S(x) x diff --git a/main.c b/main.c index 54169fb..b26b139 100644 --- a/main.c +++ b/main.c @@ -100,9 +100,9 @@ static void printhelp(FILE *out,const char *progname) "\t-j numthreads - same as -t\n" "\t-n numkeys - specify number of keys (default - 0 - unlimited)\n" "\t-N numwords - specify number of words per key (default - 1)\n" - "\t-z - use faster key generation method; this is now default\n" - "\t-Z - use slower key generation method\n" - "\t-B - use batching key generation method (>10x faster than -z, experimental)\n" + "\t-Z - use \"slower\" key generation method (initial default)\n" + "\t-z - use \"faster\" key generation method (later default)\n" + "\t-B - use batching key generation method (>10x faster than -z, current default)\n" "\t-s - print statistics each 10 seconds\n" "\t-S t - print statistics every specified ammount of seconds\n" "\t-T - do not reset statistics counters when printing\n" @@ -177,8 +177,15 @@ static void setpassphrase(const char *pass) VEC_STRUCT(threadvec, pthread_t); +#include "filters_inc.inc.h" #include "filters_main.inc.h" +enum worker_type { + WT_SLOW, + WT_FAST, + WT_BATCH, +}; + int main(int argc,char **argv) { const char *outfile = 0; @@ -188,8 +195,7 @@ int main(int argc,char **argv) int ignoreargs = 0; int dirnameflag = 0; int numthreads = 0; - int fastkeygen = 1; - int batchkeygen = 0; + enum worker_type wt = WT_BATCH; int yamlinput = 0; #ifdef PASSPHRASE int deterministic = 0; @@ -319,11 +325,11 @@ int main(int argc,char **argv) e_additional(); } else if (*arg == 'Z') - fastkeygen = 0; + wt = WT_SLOW; else if (*arg == 'z') - fastkeygen = 1; + wt = WT_FAST; else if (*arg == 'B') - batchkeygen = 1; + wt = WT_BATCH; else if (*arg == 's') { #ifdef STATISTICS reportdelay = 10000000; @@ -531,13 +537,23 @@ int main(int argc,char **argv) #ifdef STATISTICS tp = &VEC_BUF(stats,i); #endif - tret = pthread_create(&VEC_BUF(threads,i),0, + tret = pthread_create( + &VEC_BUF(threads,i),0, #ifdef PASSPHRASE - deterministic ? ( - batchkeygen ? worker_batch_pass : worker_fast_pass) : + deterministic + ? (wt == WT_BATCH + ? worker_batch_pass + : worker_fast_pass) + : #endif - batchkeygen ? worker_batch : - (fastkeygen ? worker_fast : worker_slow),tp); + wt == WT_BATCH + ? worker_batch + : + wt == WT_FAST + ? worker_fast + : worker_slow, + tp + ); if (tret) { fprintf(stderr,"error while making " FSZ "th thread: %s\n",i,strerror(tret)); exit(1); diff --git a/worker.c b/worker.c index 4962c8b..d4f48de 100644 --- a/worker.c +++ b/worker.c @@ -93,6 +93,8 @@ static void onionready(char *sname,const u8 *secret,const u8 *pubonion) pthread_mutex_unlock(&keysgenerated_mutex); } + // disabled as this was never ever triggered as far as I'm aware +#if 0 // Sanity check that the public key matches the private one. ge_p3 point; u8 testpk[PUBLIC_LEN]; @@ -100,6 +102,7 @@ static void onionready(char *sname,const u8 *secret,const u8 *pubonion) ge_p3_tobytes(testpk, &point); if (!memcmp(testpk, pubonion, PUBLIC_LEN)) abort(); +#endif if (!yamloutput) { if (createdir(sname,1) != 0) { @@ -133,6 +136,7 @@ static void onionready(char *sname,const u8 *secret,const u8 *pubonion) yamlout_writekeys(&sname[direndpos],pubonion,secret,yamlraw); } +#include "filters_inc.inc.h" #include "filters_worker.inc.h" #ifdef STATISTICS