diff options
Diffstat (limited to 'scrypt.c')
-rw-r--r-- | scrypt.c | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -645,6 +645,12 @@ smix(uint8_t * B, size_t r, uint64_t N, uint32_t * V, uint32_t * XY) le32enc(&B[4 * k], X[k]); } +#if defined(__x86_64__) +void x64_scrypt_core(uint8_t *B, uint32_t *V); +#elif defined(__i386__) +void x86_scrypt_core(uint8_t *B, uint32_t *V); +#endif + /* cpu and memory intensive function to transform a 80 byte buffer into a 32 byte output scratchpad size needs to be at least 63 + (128 * r * p) + (256 * r + 64) + (128 * r * N) bytes */ @@ -653,7 +659,6 @@ static void scrypt_1024_1_1_256_sp(const char* input, char* output, char* scratc uint8_t * B; uint32_t * V; uint32_t * XY; - uint32_t i; const uint32_t N = 1024; const uint32_t r = 1; @@ -666,11 +671,13 @@ static void scrypt_1024_1_1_256_sp(const char* input, char* output, char* scratc /* 1: (B_0 ... B_{p-1}) <-- PBKDF2(P, S, 1, p * MFLen) */ PBKDF2_SHA256((const uint8_t*)input, 80, (const uint8_t*)input, 80, 1, B, p * 128 * r); - /* 2: for i = 0 to p - 1 do */ - for (i = 0; i < p; i++) { - /* 3: B_i <-- MF(B_i, N) */ - smix(&B[i * 128 * r], r, N, V, XY); - } +#if defined(__x86_64__) + x64_scrypt_core(B, XY); +#elif defined(__i386__) + x86_scrypt_core(B, XY); +#else + smix(B, r, N, V, XY); +#endif /* 5: DK <-- PBKDF2(P, B, 1, dkLen) */ PBKDF2_SHA256((const uint8_t*)input, 80, B, p * 128 * r, 1, (uint8_t*)output, 32); |