1
2 #define TEST_NAME "pwhash_scrypt_ll"
3 #include "cmptest.h"
4
5 static const char * passwd1 = "";
6 static const char * salt1 = "";
7 static const uint64_t N1 = 16U;
8 static const uint32_t r1 = 1U;
9 static const uint32_t p1 = 1U;
10
11 static const char * passwd2 = "password";
12 static const char * salt2 = "NaCl";
13 static const uint64_t N2 = 1024U;
14 static const uint32_t r2 = 8U;
15 static const uint32_t p2 = 16U;
16
17 static const char * passwd3 = "pleaseletmein";
18 static const char * salt3 = "SodiumChloride";
19 static const uint64_t N3 = 16384U;
20 static const uint32_t r3 = 8U;
21 static const uint32_t p3 = 1U;
22
23 static void
tv(const char * passwd,const char * salt,uint64_t N,uint32_t r,uint32_t p)24 tv(const char *passwd, const char *salt, uint64_t N, uint32_t r, uint32_t p)
25 {
26 uint8_t data[64];
27 size_t i;
28 size_t olen = (sizeof data / sizeof data[0]);
29 size_t passwd_len = strlen(passwd);
30 size_t salt_len = strlen(salt);
31 int line_items = 0;
32
33 if (crypto_pwhash_scryptsalsa208sha256_ll(
34 (const uint8_t *) passwd, passwd_len, (const uint8_t *) salt,
35 salt_len, N, r, p, data, olen) != 0) {
36 printf("pwhash_scryptsalsa208sha256_ll([%s],[%s]) failure\n", passwd,
37 salt);
38 return;
39 }
40
41 printf("scrypt('%s', '%s', %lu, %lu, %lu, %lu) =\n", passwd, salt,
42 (unsigned long) N, (unsigned long) r, (unsigned long) p,
43 (unsigned long) olen);
44
45 for (i = 0; i < olen; i++) {
46 printf("%02x%c", data[i], line_items < 15 ? ' ' : '\n');
47 line_items = line_items < 15 ? line_items + 1 : 0;
48 }
49 }
50
51 int
main(void)52 main(void)
53 {
54 tv(passwd1, salt1, N1, r1, p1);
55 tv(passwd2, salt2, N2, r2, p2);
56 tv(passwd3, salt3, N3, r3, p3);
57
58 return 0;
59 }
60