libsodium 1.0.8
[tomato.git] / release / src / router / libsodium / test / default / shorthash.c
blob9205740f96440da863ab47317c02504da2c4e283
2 #define TEST_NAME "shorthash"
3 #include "cmptest.h"
5 #define MAXLEN 64
7 int main(void)
9 unsigned char in[MAXLEN];
10 unsigned char out[crypto_shorthash_BYTES];
11 unsigned char k[crypto_shorthash_KEYBYTES];
12 size_t i;
13 size_t j;
15 for (i = 0; i < crypto_shorthash_KEYBYTES; ++i) {
16 k[i] = (unsigned char) i;
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]);
25 printf("\n");
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());
34 return 0;