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
|