From a65bb9861b85dafe81b32e80d4b6b2dc5ab089ec Mon Sep 17 00:00:00 2001 From: David Phillips Date: Sun, 21 May 2017 22:14:10 +1200 Subject: Add sanity check to back up SSSE3 algorithm --- sand-leek.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sand-leek.c') diff --git a/sand-leek.c b/sand-leek.c index c6d5226..a33b524 100644 --- a/sand-leek.c +++ b/sand-leek.c @@ -92,6 +92,9 @@ key_update_d(RSA *rsa_key) { void* work(void *arg) { char onion[17]; +#ifdef SSSE3_ONION_BASE32 + char check_onion[17]; /* buffer for onion address used in sanity check */ +#endif unsigned char sha[20]; unsigned long e = EXPONENT_MIN; unsigned int e_big_endian = 0; @@ -171,6 +174,20 @@ work(void *arg) { goto STOP; } if(strncmp(onion, search, search_len) == 0) { +#ifdef SSSE3_ONION_BASE32 + /* sanity check: my SSE algorithm is still experimental, so + * check it with old trusty */ + onion_base32(check_onion, sha); + check_onion[16] = '\0'; + if (strcmp(check_onion, onion)) { + fprintf(stderr, + "BUG: Discrepancy between SSE algorithm and old trusty\n" + "SSE gave me %s, but trusty says it should be %s\n" + "Please report this to the developer\n", + onion, check_onion); + continue; + } +#endif fprintf(stderr, "Found %s.onion\n", onion); #if OPENSSL_VERSION_NUMBER >= 0x10100000L -- cgit v1.1