| 360 | } |
| 361 | |
| 362 | void 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 | } |
no test coverage detected