diff --git a/scrypt.cpp b/scrypt.cpp index 5a53ca1e..3566c3e1 100644 --- a/scrypt.cpp +++ b/scrypt.cpp @@ -245,8 +245,14 @@ size_t Scrypt::DeriveKey(byte*derived, size_t derivedLen, const byte*secret, siz // 1: (B_0 ... B_{p-1}) <-- PBKDF2(P, S, 1, p * MFLen) PBKDF2_SHA256(B, B.size(), secret, secretLen, salt, saltLen, 1); + #ifdef _OPENMP + int threads = STDMIN(omp_get_max_threads(), + static_cast(STDMIN(static_cast(parallel), + static_cast(std::numeric_limits::max())))); + #endif + // http://stackoverflow.com/q/49604260/608639 - #pragma omp parallel + #pragma omp parallel num_threads(threads) { // Each thread gets its own copy AlignedSecByteBlock XY(static_cast(blockSize * 256U));