2013-04-21 08:26:34 -04:00
|
|
|
|
|
|
|
#define TEST_NAME "generichash2"
|
|
|
|
#include "cmptest.h"
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
#define MAXLEN 64
|
|
|
|
crypto_generichash_state st;
|
2014-09-14 14:32:55 -04:00
|
|
|
unsigned char in[MAXLEN], out[crypto_generichash_BYTES_MAX],
|
|
|
|
k[crypto_generichash_KEYBYTES_MAX];
|
|
|
|
size_t h, i, j;
|
2013-04-21 08:26:34 -04:00
|
|
|
|
2014-09-14 14:32:55 -04:00
|
|
|
for (h = 0; h < crypto_generichash_KEYBYTES_MAX; ++h)
|
|
|
|
k[h] = h;
|
2013-04-21 08:26:34 -04:00
|
|
|
|
2014-09-14 14:32:55 -04:00
|
|
|
for (i = 0; i < MAXLEN; ++i) {
|
|
|
|
in[i] = i;
|
2013-04-21 08:26:34 -04:00
|
|
|
crypto_generichash_init(&st, k, 1 + i % crypto_generichash_KEYBYTES_MAX,
|
|
|
|
1 + i % crypto_generichash_BYTES_MAX);
|
|
|
|
crypto_generichash_update(&st, in, i);
|
|
|
|
crypto_generichash_update(&st, in, i);
|
|
|
|
crypto_generichash_update(&st, in, i);
|
2014-09-14 14:32:55 -04:00
|
|
|
crypto_generichash_final(&st, out,
|
|
|
|
1 + i % crypto_generichash_BYTES_MAX);
|
|
|
|
for (j = 0; j < 1 + i % crypto_generichash_BYTES_MAX; ++j) {
|
|
|
|
printf("%02x", (unsigned int)out[j]);
|
2013-04-21 08:26:34 -04:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|