Initial commit
[authen-passphrase-scrypt.git] / scrypt-1.2.1 / tests / test_scrypt.c
1 #include <stdint.h>
2 #include <stdio.h>
3 #include <string.h>
4
5 #include "crypto_scrypt.h"
6 #include "warnp.h"
7
8 static struct scrypt_test {
9 const char * passwd;
10 const char * salt;
11 uint64_t N;
12 uint32_t r;
13 uint32_t p;
14 } tests[4] = {
15 { "", "", 16, 1, 1 },
16 { "password", "NaCl", 1024, 8, 16 },
17 { "pleaseletmein", "SodiumChloride", 16384, 8, 1 },
18 { "pleaseletmein", "SodiumChloride", 1048576, 8, 1 }
19 };
20
21 int
22 main(int argc, char * argv[])
23 {
24 struct scrypt_test * test;
25 char kbuf[64];
26 size_t i;
27
28 WARNP_INIT;
29
30 (void)argc; /* UNUSED */
31 (void)argv; /* UNUSED */
32
33 for (test = tests;
34 test < tests + sizeof(tests) / sizeof(tests[0]);
35 test++) {
36 crypto_scrypt((const uint8_t *)test->passwd,
37 strlen(test->passwd), (const uint8_t *)test->salt,
38 strlen(test->salt), test->N, test->r, test->p,
39 (uint8_t *)kbuf, 64);
40 printf("scrypt(\"%s\", \"%s\", %u, %u, %u, 64) =\n",
41 test->passwd, test->salt, (unsigned int)test->N,
42 (unsigned int)(test->r), (unsigned int)test->p);
43 for (i = 0; i < 64; i++) {
44 printf("%02x ", (uint8_t)kbuf[i]);
45 if ((i % 16) == 15)
46 printf("\n");
47 }
48 }
49
50 return (0);
51 }
This page took 0.024224 seconds and 4 git commands to generate.