From 7dea621e419119786122879725add5b9b908ba06 Mon Sep 17 00:00:00 2001 From: cathugger Date: Tue, 2 Nov 2021 15:07:37 +0000 Subject: [PATCH 1/6] some tweaks --- .gitignore | 1 + worker_batch.inc.h | 2 ++ worker_batch_pass.inc.h | 2 ++ worker_slow.inc.h | 1 + 4 files changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 76500c6..01a1447 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ mkp224o # garbage configure +configure~ GNUmakefile GNUmakefile.in.bak config.status diff --git a/worker_batch.inc.h b/worker_batch.inc.h index 8de5330..508f7ab 100644 --- a/worker_batch.inc.h +++ b/worker_batch.inc.h @@ -21,6 +21,8 @@ void *worker_batch(void *task) #ifdef STATISTICS struct statstruct *st = (struct statstruct *)task; +#else + (void) task; #endif PREFILTER diff --git a/worker_batch_pass.inc.h b/worker_batch_pass.inc.h index 3676eec..74320a4 100644 --- a/worker_batch_pass.inc.h +++ b/worker_batch_pass.inc.h @@ -22,6 +22,8 @@ void *worker_batch_pass(void *task) #ifdef STATISTICS struct statstruct *st = (struct statstruct *)task; +#else + (void) task; #endif PREFILTER diff --git a/worker_slow.inc.h b/worker_slow.inc.h index 799e4aa..2df8930 100644 --- a/worker_slow.inc.h +++ b/worker_slow.inc.h @@ -17,6 +17,7 @@ void *worker_slow(void *task) #else (void) task; #endif + PREFILTER memcpy(secret,skprefix,SKPREFIX_SIZE); From f1c56e74805fd0f6268c5d1a899f96b32b912c83 Mon Sep 17 00:00:00 2001 From: cathugger Date: Tue, 2 Nov 2021 17:32:10 +0200 Subject: [PATCH 2/6] idk --- worker.c | 6 +++--- worker_batch.inc.h | 4 ++++ worker_batch_pass.inc.h | 4 ++++ worker_fast.inc.h | 4 ++++ worker_fast_pass.inc.h | 4 ++++ worker_slow.inc.h | 4 ++++ 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/worker.c b/worker.c index f0aaf62..818413c 100644 --- a/worker.c +++ b/worker.c @@ -98,9 +98,9 @@ static void onionready(char *sname,const u8 *secret,const u8 *pubonion) // Sanity check that the public key matches the private one. ge_p3 ALIGN(16) point; u8 testpk[PUBLIC_LEN]; - ge_scalarmult_base(&point, secret); - ge_p3_tobytes(testpk, &point); - if (!memcmp(testpk, pubonion, PUBLIC_LEN)) + ge_scalarmult_base(&point,secret); + ge_p3_tobytes(testpk,&point); + if (!memcmp(testpk,pubonion,PUBLIC_LEN)) abort(); #endif diff --git a/worker_batch.inc.h b/worker_batch.inc.h index 508f7ab..2e0788f 100644 --- a/worker_batch.inc.h +++ b/worker_batch.inc.h @@ -38,6 +38,7 @@ void *worker_batch(void *task) sname = makesname(); initseed: + #ifdef STATISTICS ++st->numrestart.v; #endif @@ -114,8 +115,11 @@ initseed: end: free(sname); + POSTFILTER + sodium_memzero(secret,sizeof(secret)); sodium_memzero(seed,sizeof(seed)); + return 0; } diff --git a/worker_batch_pass.inc.h b/worker_batch_pass.inc.h index 74320a4..5f07c70 100644 --- a/worker_batch_pass.inc.h +++ b/worker_batch_pass.inc.h @@ -39,6 +39,7 @@ void *worker_batch_pass(void *task) sname = makesname(); initseed: + #ifdef STATISTICS ++st->numrestart.v; #endif @@ -191,9 +192,12 @@ initseed: end: free(sname); + POSTFILTER + sodium_memzero(secret,sizeof(secret)); sodium_memzero(seed,sizeof(seed)); + return 0; } #endif // PASSPHRASE diff --git a/worker_fast.inc.h b/worker_fast.inc.h index 141a34b..1d7443f 100644 --- a/worker_fast.inc.h +++ b/worker_fast.inc.h @@ -33,6 +33,7 @@ void *worker_fast(void *task) sname = makesname(); initseed: + #ifdef STATISTICS ++st->numrestart.v; #endif @@ -96,8 +97,11 @@ initseed: end: free(sname); + POSTFILTER + sodium_memzero(secret,sizeof(secret)); sodium_memzero(seed,sizeof(seed)); + return 0; } diff --git a/worker_fast_pass.inc.h b/worker_fast_pass.inc.h index 2d482b3..132aed6 100644 --- a/worker_fast_pass.inc.h +++ b/worker_fast_pass.inc.h @@ -34,6 +34,7 @@ void *worker_fast_pass(void *task) sname = makesname(); initseed: + #ifdef STATISTICS ++st->numrestart.v; #endif @@ -104,9 +105,12 @@ initseed: end: free(sname); + POSTFILTER + sodium_memzero(secret,sizeof(secret)); sodium_memzero(seed,sizeof(seed)); + return 0; } #endif // PASSPHRASE diff --git a/worker_slow.inc.h b/worker_slow.inc.h index 2df8930..278b58b 100644 --- a/worker_slow.inc.h +++ b/worker_slow.inc.h @@ -33,6 +33,7 @@ void *worker_slow(void *task) initseed: randombytes(seed,sizeof(seed)); ed25519_seckey_expand(sk,seed); + #ifdef STATISTICS ++st->numrestart.v; #endif @@ -83,8 +84,11 @@ next: end: free(sname); + POSTFILTER + sodium_memzero(secret,sizeof(secret)); sodium_memzero(seed,sizeof(seed)); + return 0; } From e12a3eb7c974c623ebfaf0e2b0c0a9c93d2c1e74 Mon Sep 17 00:00:00 2001 From: cathugger Date: Tue, 2 Nov 2021 17:07:30 +0000 Subject: [PATCH 3/6] apparently this check was always wrong lmao --- worker.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worker.c b/worker.c index 818413c..7f8cb03 100644 --- a/worker.c +++ b/worker.c @@ -98,9 +98,9 @@ static void onionready(char *sname,const u8 *secret,const u8 *pubonion) // Sanity check that the public key matches the private one. ge_p3 ALIGN(16) point; u8 testpk[PUBLIC_LEN]; - ge_scalarmult_base(&point,secret); + ge_scalarmult_base(&point,&secret[SKPREFIX_SIZE]); ge_p3_tobytes(testpk,&point); - if (!memcmp(testpk,pubonion,PUBLIC_LEN)) + if (memcmp(testpk,&pubonion[PKPREFIX_SIZE],PUBLIC_LEN) != 0) abort(); #endif From eea863e3ac543167df639b8888849330466ff995 Mon Sep 17 00:00:00 2001 From: cathugger Date: Wed, 3 Nov 2021 00:20:43 +0000 Subject: [PATCH 4/6] a bit of calcest and some other stuff --- .gitignore | 2 ++ GNUmakefile.in | 1 + calcest.c | 11 ++++++----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 01a1447..4d8142e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # output files mkp224o +calcest +test_* *.o # generated onions diff --git a/GNUmakefile.in b/GNUmakefile.in index 71beef6..d566837 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -57,6 +57,7 @@ TEST_ED25519_OBJ= \ ALL_O= $(sort \ $(MAIN_OBJ) \ + $(UTIL_CALCEST_OBJ) \ $(TEST_BASE64_OBJ) \ $(TEST_BASE32_OBJ) \ $(TEST_BASE16_OBJ) \ diff --git a/calcest.c b/calcest.c index 28d9c98..0315a3a 100644 --- a/calcest.c +++ b/calcest.c @@ -15,19 +15,20 @@ */ const double probs[] = { 0.5, 0.8, 0.9, 0.95, 0.99 }; -const int charcounts[] = { 2, 3, 4, 5, 6, 7 }; +const int charcounts[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10 }; -int main(void) +int main(int argc,char **argv) { + printf(" |"); for (size_t i = 0; i < sizeof(probs)/sizeof(probs[0]); ++i) { - printf(" %11d%% |",(int)((probs[i]*100)+0.5)); + printf(" %15d%% |",(int)((probs[i]*100)+0.5)); } printf("\n"); printf("---+"); for (size_t i = 0; i < sizeof(probs)/sizeof(probs[0]); ++i) { - printf("--------------+"); + printf("------------------+"); } printf("\n"); @@ -35,7 +36,7 @@ int main(void) printf("%2d |",charcounts[i]); for (size_t j = 0; j < sizeof(probs)/sizeof(probs[0]); ++j) { double t = log2(1 - probs[j]) / log2(1 - (1 / pow(32,charcounts[i]))); - printf(" %12.0f |",t); + printf(" %16.0f |",t); } printf("\n"); } From d6e2aecf520ed2ed637da536aeb728dd53f03655 Mon Sep 17 00:00:00 2001 From: cathugger Date: Wed, 3 Nov 2021 19:57:41 +0200 Subject: [PATCH 5/6] small fixup --- worker_batch_pass.inc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker_batch_pass.inc.h b/worker_batch_pass.inc.h index 5f07c70..44006ff 100644 --- a/worker_batch_pass.inc.h +++ b/worker_batch_pass.inc.h @@ -136,7 +136,7 @@ initseed: ge_p1p1_to_p3(&ge_public,&sum); } // NOTE: leaves unfinished one bit at the very end - ge_p3_batchtobytes_destructive_1(pk_batch,ge_batch,batchgez,tmp_batch,remaining); + ge_p3_batchtobytes_destructive_1(pk_batch,ge_batch,tmp_batch,remaining); #ifdef STATISTICS st->numcalc.v += remaining; From 73d2791286a4afb470a5976ade707fc79f7bf1b0 Mon Sep 17 00:00:00 2001 From: cathugger Date: Wed, 8 Dec 2021 16:25:58 +0000 Subject: [PATCH 6/6] fix default ed25519 impl check in configure.ac --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index aad12af..35a488e 100644 --- a/configure.ac +++ b/configure.ac @@ -112,7 +112,7 @@ AC_ARG_ENABLE([donna-sse2], ) # default -AS_IF([test "x$ed25519impl" == "x"],[ed25519impl="donna"]) +AS_IF([test "x$ed25519impl" = "x"],[ed25519impl="donna"]) if test "$ed25519impl" = "donna-sse2" then