main.c 1.0 KB

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