The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/libsodium/test/default/pwhash_scrypt_ll.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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
   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
   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 }

Cache object: 2ccfbc8898162cb0a823beb1b29aec27


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.