diff --git a/GlobalBoost-Y.pro b/GlobalBoost-Y.pro index 45ba3c1..26ea339 100755 --- a/GlobalBoost-Y.pro +++ b/GlobalBoost-Y.pro @@ -292,7 +292,7 @@ SOURCES += src/qt/bitcoin.cpp \ src/qt/rpcconsole.cpp \ src/sha256_Y.c \ src/yescryptcommon.c \ - src/yescrypt-opt.c \ + src/yescrypt-best.c \ src/noui.cpp \ src/leveldb.cpp \ src/txdb.cpp \ diff --git a/src/makefile.unix b/src/makefile.unix index f42d8e5..e8334c7 100755 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -137,7 +137,7 @@ OBJS= \ obj/rpcblockchain.o \ obj/rpcrawtransaction.o \ obj/script.o \ - obj/yescrypt-opt.o \ + obj/yescrypt-best.o \ obj/yescryptcommom.o \ obj/sha256_Y.o \ obj/sync.o \ @@ -169,7 +169,7 @@ leveldb/libleveldb.a: obj/yescryptcommom.o: yescryptcommon.c gcc -c -o $@ $^ -obj/yescrypt-opt.o: yescrypt-opt.c +obj/yescrypt-best.o: yescrypt-best.c gcc -c -o $@ $^ obj/sha256_Y.o: sha256_Y.c diff --git a/src/yescrypt-best.c b/src/yescrypt-best.c index 4b63ec4..4e83621 100755 --- a/src/yescrypt-best.c +++ b/src/yescrypt-best.c @@ -1,5 +1,5 @@ #ifdef __SSE2__ -//#include "yescrypt-simd.c" +#include "yescrypt-simd.c" #else #include "yescrypt-opt.c" #endif diff --git a/src/yescrypt-simd.c b/src/yescrypt-simd.c index 8f236a2..94a08f6 100755 --- a/src/yescrypt-simd.c +++ b/src/yescrypt-simd.c @@ -1354,7 +1354,13 @@ yescrypt_kdf(const yescrypt_shared_t * shared, yescrypt_local_t * local, { HMAC_SHA256_CTX_Y ctx; HMAC_SHA256_Init_Y(&ctx, buf, buflen); +#if 0 +/* Proper yescrypt */ HMAC_SHA256_Update_Y(&ctx, "Client Key", 10); +#else +/* GlobalBoost-Y buggy yescrypt */ + HMAC_SHA256_Update_Y(&ctx, salt, saltlen); +#endif HMAC_SHA256_Final_Y(sha256, &ctx); } /* Compute StoredKey */ diff --git a/src/yescryptcommon.c b/src/yescryptcommon.c index 3d08b1b..97ec04b 100755 --- a/src/yescryptcommon.c +++ b/src/yescryptcommon.c @@ -327,36 +327,46 @@ yescrypt_gensalt(uint32_t N_log2, uint32_t r, uint32_t p, buf, sizeof(buf)); } -int -crypto_scrypt(const uint8_t * passwd, size_t passwdlen, +static int +yescrypt_btsy(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt, size_t saltlen, uint64_t N, uint32_t r, uint32_t p, uint8_t * buf, size_t buflen) { - yescrypt_shared_t shared; - yescrypt_local_t local; + static __thread int initialized = 0; + static __thread yescrypt_shared_t shared; + static __thread yescrypt_local_t local; int retval; - if (yescrypt_init_shared(&shared, NULL, 0, - 0, 0, 0, YESCRYPT_SHARED_DEFAULTS, 0, NULL, 0)) - return -1; - if (yescrypt_init_local(&local)) { - yescrypt_free_shared(&shared); - return -1; + if (!initialized) { +/* "shared" could in fact be shared, but it's simpler to keep it private + * along with "local". It's dummy and tiny anyway. */ + if (yescrypt_init_shared(&shared, NULL, 0, + 0, 0, 0, YESCRYPT_SHARED_DEFAULTS, 0, NULL, 0)) + return -1; + if (yescrypt_init_local(&local)) { + yescrypt_free_shared(&shared); + return -1; + } + initialized = 1; } retval = yescrypt_kdf(&shared, &local, - passwd, passwdlen, salt, saltlen, N, r, p, 0, YESCRYPT_FLAGS, buf, buflen); + passwd, passwdlen, salt, saltlen, N, r, p, 0, YESCRYPT_FLAGS, + buf, buflen); +#if 0 if (yescrypt_free_local(&local)) { yescrypt_free_shared(&shared); return -1; } if (yescrypt_free_shared(&shared)) return -1; + initialized = 0; +#endif return retval; } void yescrypt_hash_sp(const char *input, char *output) { - crypto_scrypt((const uint8_t *) input, 80,(const uint8_t *) input, 80, 2048, 8, 1, (uint8_t *)output, 32); + yescrypt_btsy((const uint8_t *)input, 80, (const uint8_t *) input, 80, 2048, 8, 1, (uint8_t *)output, 32); } void yescrypt_hash(const char *input, char *output)