2014-06-01 11:58:20 -07:00
|
|
|
|
|
|
|
#define TEST_NAME "pwhash_scrypt_ll"
|
|
|
|
#include "cmptest.h"
|
|
|
|
|
2017-02-25 12:59:54 -07:00
|
|
|
static const char * passwd1 = "";
|
|
|
|
static const char * salt1 = "";
|
|
|
|
static const uint64_t N1 = 16U;
|
|
|
|
static const uint32_t r1 = 1U;
|
|
|
|
static const uint32_t p1 = 1U;
|
|
|
|
|
|
|
|
static const char * passwd2 = "password";
|
|
|
|
static const char * salt2 = "NaCl";
|
|
|
|
static const uint64_t N2 = 1024U;
|
|
|
|
static const uint32_t r2 = 8U;
|
|
|
|
static const uint32_t p2 = 16U;
|
|
|
|
|
|
|
|
static const char * passwd3 = "pleaseletmein";
|
|
|
|
static const char * salt3 = "SodiumChloride";
|
|
|
|
static const uint64_t N3 = 16384U;
|
|
|
|
static const uint32_t r3 = 8U;
|
|
|
|
static const uint32_t p3 = 1U;
|
2017-02-23 03:30:21 -07:00
|
|
|
|
|
|
|
static void
|
2017-02-25 12:59:54 -07:00
|
|
|
tv(const char *passwd, const char *salt, uint64_t N, uint32_t r, uint32_t p)
|
2014-06-01 11:58:20 -07:00
|
|
|
{
|
2014-06-03 03:15:39 -07:00
|
|
|
uint8_t data[64];
|
2017-02-23 03:30:21 -07:00
|
|
|
size_t i;
|
2017-02-25 12:59:54 -07:00
|
|
|
size_t olen = (sizeof data / sizeof data[0]);
|
|
|
|
size_t passwd_len = strlen(passwd);
|
|
|
|
size_t salt_len = strlen(salt);
|
2017-02-25 13:00:52 -07:00
|
|
|
int line_items = 0;
|
2014-09-14 11:32:55 -07:00
|
|
|
|
|
|
|
if (crypto_pwhash_scryptsalsa208sha256_ll(
|
2017-02-25 12:59:54 -07:00
|
|
|
(const uint8_t *) passwd, passwd_len, (const uint8_t *) salt,
|
|
|
|
salt_len, N, r, p, data, olen) != 0) {
|
|
|
|
printf("pwhash_scryptsalsa208sha256_ll([%s],[%s]) failure\n", passwd,
|
2014-09-14 11:32:55 -07:00
|
|
|
salt);
|
2014-06-03 23:48:25 -07:00
|
|
|
return;
|
2014-06-03 03:15:39 -07:00
|
|
|
}
|
2014-06-03 23:48:25 -07:00
|
|
|
|
2017-02-25 12:59:54 -07:00
|
|
|
printf("scrypt('%s', '%s', %lu, %lu, %lu, %lu) =\n", passwd, salt,
|
2017-02-23 03:30:21 -07:00
|
|
|
(unsigned long) N, (unsigned long) r, (unsigned long) p,
|
|
|
|
(unsigned long) olen);
|
2014-06-01 11:58:20 -07:00
|
|
|
|
2017-02-25 12:59:54 -07:00
|
|
|
for (i = 0; i < olen; i++) {
|
2017-02-25 13:01:52 -07:00
|
|
|
printf("%02x%c", data[i], line_items < 15 ? ' ' : '\n');
|
2017-02-25 13:00:52 -07:00
|
|
|
line_items = line_items < 15 ? line_items + 1 : 0;
|
2014-06-01 11:58:20 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-23 03:30:21 -07:00
|
|
|
int
|
|
|
|
main(void)
|
2014-06-01 11:58:20 -07:00
|
|
|
{
|
2017-02-25 12:59:54 -07:00
|
|
|
tv(passwd1, salt1, N1, r1, p1);
|
|
|
|
tv(passwd2, salt2, N2, r2, p2);
|
|
|
|
tv(passwd3, salt3, N3, r3, p3);
|
2014-06-01 11:58:20 -07:00
|
|
|
|
2014-09-14 11:32:55 -07:00
|
|
|
return 0;
|
2014-06-01 11:58:20 -07:00
|
|
|
}
|