diff --git a/.gitignore b/.gitignore index 76500c6..4d8142e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # output files mkp224o +calcest +test_* *.o # generated onions @@ -7,6 +9,7 @@ mkp224o # garbage configure +configure~ GNUmakefile GNUmakefile.in.bak config.status 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"); } 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 diff --git a/worker.c b/worker.c index f0aaf62..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_p3_tobytes(testpk, &point); - if (!memcmp(testpk, pubonion, PUBLIC_LEN)) + ge_scalarmult_base(&point,&secret[SKPREFIX_SIZE]); + ge_p3_tobytes(testpk,&point); + if (memcmp(testpk,&pubonion[PKPREFIX_SIZE],PUBLIC_LEN) != 0) abort(); #endif diff --git a/worker_batch.inc.h b/worker_batch.inc.h index 8de5330..2e0788f 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 @@ -36,6 +38,7 @@ void *worker_batch(void *task) sname = makesname(); initseed: + #ifdef STATISTICS ++st->numrestart.v; #endif @@ -112,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 3676eec..44006ff 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 @@ -37,6 +39,7 @@ void *worker_batch_pass(void *task) sname = makesname(); initseed: + #ifdef STATISTICS ++st->numrestart.v; #endif @@ -133,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; @@ -189,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 799e4aa..278b58b 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); @@ -32,6 +33,7 @@ void *worker_slow(void *task) initseed: randombytes(seed,sizeof(seed)); ed25519_seckey_expand(sk,seed); + #ifdef STATISTICS ++st->numrestart.v; #endif @@ -82,8 +84,11 @@ next: end: free(sname); + POSTFILTER + sodium_memzero(secret,sizeof(secret)); sodium_memzero(seed,sizeof(seed)); + return 0; }