2 #define TEST_NAME "pwhash_scrypt_ll"
5 /* Tarsnap test vectors, see: https://www.tarsnap.com/scrypt/scrypt.pdf */
7 static const char *password1
= "";
8 static const char *salt1
= "";
9 static uint64_t N1
= 16U;
10 static uint32_t r1
= 1U;
11 static uint32_t p1
= 1U;
13 static const char *password2
= "password";
14 static const char *salt2
= "NaCl";
15 static uint64_t N2
= 1024U;
16 static uint32_t r2
= 8U;
17 static uint32_t p2
= 16U;
19 static const char *password3
= "pleaseletmein";
20 static const char *salt3
= "SodiumChloride";
21 static uint64_t N3
= 16384U;
22 static uint32_t r3
= 8U;
23 static uint32_t p3
= 1U;
25 static void test_vector(const char *password
, const char *salt
, uint64_t N
,
26 uint32_t r
, uint32_t p
)
30 size_t olen
= (sizeof data
/ sizeof data
[0]);
31 size_t passwordLength
= strlen(password
);
32 size_t saltLenght
= strlen(salt
);
34 int lineitemsLimit
= 15;
36 if (crypto_pwhash_scryptsalsa208sha256_ll(
37 (const uint8_t *)password
, passwordLength
, (const uint8_t *)salt
,
38 saltLenght
, N
, r
, p
, data
, olen
) != 0) {
39 printf("pwhash_scryptsalsa208sha256_ll([%s],[%s]) failure\n", password
,
44 printf("scrypt('%s', '%s', %lu, %lu, %lu, %lu) =\n", password
, salt
,
45 (unsigned long)N
, (unsigned long)r
, (unsigned long)p
,
48 for (i
= 0; i
< olen
; ++i
) {
49 printf("%02x%c", data
[i
], lineitems
< lineitemsLimit
? ' ' : '\n');
50 lineitems
= lineitems
< lineitemsLimit
? lineitems
+ 1 : 0;
56 test_vector(password1
, salt1
, N1
, r1
, p1
);
57 test_vector(password2
, salt2
, N2
, r2
, p2
);
58 test_vector(password3
, salt3
, N3
, r3
, p3
);