MCPcopy Create free account
hub / github.com/LUX-Core/lux / scrypt

Function scrypt

src/crypto/scrypt.cpp:362–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360}
361
362void scrypt(const char* pass, unsigned int pLen, const char* salt, unsigned int sLen, char *output, unsigned int N, unsigned int r, unsigned int p, unsigned int dkLen)
363{
364 //containers
365 void* V0 = malloc(128 * r * N + 63);
366 void* XY0 = malloc(256 * r + 64 + 63);
367 void* B1 = malloc(128 * r * p + 63);
368 uint8_t* B = (uint8_t *)(((uintptr_t)(B1) + 63) & ~ (uintptr_t)(63));
369 uint32_t* V = (uint32_t *)(((uintptr_t)(V0) + 63) & ~ (uintptr_t)(63));
370 uint32_t* XY = (uint32_t *)(((uintptr_t)(XY0) + 63) & ~ (uintptr_t)(63));
371
372 PBKDF2_SHA256((const uint8_t *)pass, pLen, (const uint8_t *)salt, sLen, 1, B, p * 128 * r);
373
374 for(unsigned int i = 0; i < p; i++)
375 {
376 SMix(&B[i * 128 * r], r, N, V, XY);
377 }
378
379 PBKDF2_SHA256((const uint8_t *)pass, pLen, B, p * 128 * r, 1, (uint8_t *)output, dkLen);
380
381 free(V0);
382 free(XY0);
383 free(B1);
384}

Callers 3

scrypt_hashFunction · 0.85
deriveNewKeyFunction · 0.85
decryptMethod · 0.85

Calls 2

PBKDF2_SHA256Function · 0.85
SMixFunction · 0.85

Tested by

no test coverage detected