xref: /freebsd/sys/contrib/libsodium/test/default/siphashx24.c (revision fe75646a0234a261c0013bf1840fdac4acaf0cec)
1 
2 #define TEST_NAME "siphashx24"
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_siphashx24_BYTES];
12     unsigned char k[crypto_shorthash_siphashx24_KEYBYTES];
13     size_t        i;
14     size_t        j;
15 
16     for (i = 0; i < crypto_shorthash_siphashx24_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_siphashx24(out, in, (unsigned long long) i, k);
22         for (j = 0; j < crypto_shorthash_siphashx24_BYTES; ++j) {
23             printf("%02x", (unsigned int) out[j]);
24         }
25         printf("\n");
26     }
27     assert(crypto_shorthash_siphashx24_KEYBYTES >= crypto_shorthash_siphash24_KEYBYTES);
28     assert(crypto_shorthash_siphashx24_BYTES > crypto_shorthash_siphash24_BYTES);
29     assert(crypto_shorthash_siphashx24_bytes() == crypto_shorthash_siphashx24_BYTES);
30     assert(crypto_shorthash_siphashx24_keybytes() == crypto_shorthash_siphashx24_KEYBYTES);
31 
32     return 0;
33 }
34