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/shorthash.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 "shorthash"
    3 #include "cmptest.h"
    4 
    5 #define MAXLEN 64
    6 
    7 int
    8 main(void)
    9 {
   10     unsigned char in[MAXLEN];
   11     unsigned char out[crypto_shorthash_BYTES];
   12     unsigned char k[crypto_shorthash_KEYBYTES];
   13     size_t        i;
   14     size_t        j;
   15 
   16     for (i = 0; i < crypto_shorthash_KEYBYTES; ++i) {
   17         k[i] = (unsigned char) i;
   18     }
   19     for (i = 0; i < MAXLEN; ++i) {
   20         in[i] = (unsigned char) i;
   21         crypto_shorthash(out, in, (unsigned long long) i, k);
   22         for (j = 0; j < crypto_shorthash_BYTES; ++j) {
   23             printf("%02x", (unsigned int) out[j]);
   24         }
   25         printf("\n");
   26     }
   27     assert(crypto_shorthash_bytes() > 0);
   28     assert(crypto_shorthash_keybytes() > 0);
   29     assert(strcmp(crypto_shorthash_primitive(), "siphash24") == 0);
   30     assert(crypto_shorthash_bytes() == crypto_shorthash_siphash24_bytes());
   31     assert(crypto_shorthash_keybytes() ==
   32            crypto_shorthash_siphash24_keybytes());
   33 
   34     return 0;
   35 }

Cache object: a6294853cf2b7aed911cd45fb0b9ebee


[ 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.