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/hash.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 "hash"
    3 #include "cmptest.h"
    4 
    5 static unsigned char x[] = "testing\n";
    6 static unsigned char x2[] =
    7     "The Conscience of a Hacker is a small essay written January 8, 1986 by a "
    8     "computer security hacker who went by the handle of The Mentor, who "
    9     "belonged to the 2nd generation of Legion of Doom.";
   10 static unsigned char h[crypto_hash_BYTES];
   11 
   12 int
   13 main(void)
   14 {
   15     size_t i;
   16 
   17     crypto_hash(h, x, sizeof x - 1U);
   18     for (i = 0; i < crypto_hash_BYTES; ++i) {
   19         printf("%02x", (unsigned int) h[i]);
   20     }
   21     printf("\n");
   22     crypto_hash(h, x2, sizeof x2 - 1U);
   23     for (i = 0; i < crypto_hash_BYTES; ++i) {
   24         printf("%02x", (unsigned int) h[i]);
   25     }
   26     printf("\n");
   27     crypto_hash_sha256(h, x, sizeof x - 1U);
   28     for (i = 0; i < crypto_hash_sha256_BYTES; ++i) {
   29         printf("%02x", (unsigned int) h[i]);
   30     }
   31     printf("\n");
   32     crypto_hash_sha256(h, x2, sizeof x2 - 1U);
   33     for (i = 0; i < crypto_hash_sha256_BYTES; ++i) {
   34         printf("%02x", (unsigned int) h[i]);
   35     }
   36     printf("\n");
   37 
   38     assert(crypto_hash_bytes() > 0U);
   39     assert(strcmp(crypto_hash_primitive(), "sha512") == 0);
   40     assert(crypto_hash_sha256_bytes() > 0U);
   41     assert(crypto_hash_sha512_bytes() >= crypto_hash_sha256_bytes());
   42     assert(crypto_hash_sha512_bytes() == crypto_hash_bytes());
   43     assert(crypto_hash_sha256_statebytes() == sizeof(crypto_hash_sha256_state));
   44     assert(crypto_hash_sha512_statebytes() == sizeof(crypto_hash_sha512_state));
   45 
   46     return 0;
   47 }

Cache object: 05efa7066504078951ba77832ccc6c87


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