2013-04-19 18:28:19 -04:00
|
|
|
|
|
|
|
#define TEST_NAME "generichash"
|
|
|
|
#include "cmptest.h"
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
#define MAXLEN 64
|
2014-09-13 17:15:55 -04:00
|
|
|
unsigned char in[MAXLEN], out[crypto_generichash_BYTES_MAX], k[crypto_generichash_KEYBYTES_MAX];
|
2013-04-27 02:25:14 -04:00
|
|
|
size_t h,i,j;
|
2013-04-19 18:28:19 -04:00
|
|
|
|
|
|
|
for(h = 0; h < crypto_generichash_KEYBYTES_MAX; ++h) k[h] = h;
|
|
|
|
|
|
|
|
for(i = 0; i < MAXLEN; ++i) {
|
|
|
|
in[i]=i;
|
2013-04-21 08:46:21 -04:00
|
|
|
crypto_generichash(out, 1 + i % crypto_generichash_BYTES_MAX,
|
|
|
|
in, i,
|
|
|
|
k, 1 + i % crypto_generichash_KEYBYTES_MAX);
|
2013-04-19 18:28:19 -04:00
|
|
|
for (j = 0;j < 1 + i % crypto_generichash_BYTES_MAX;++j) {
|
|
|
|
printf("%02x",(unsigned int) out[j]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
2014-09-13 17:37:04 -04:00
|
|
|
|
|
|
|
assert(crypto_generichash_bytes_min() > 0U);
|
|
|
|
assert(crypto_generichash_bytes_max() > 0U);
|
|
|
|
assert(crypto_generichash_bytes() > 0U);
|
|
|
|
assert(crypto_generichash_bytes() >= crypto_generichash_bytes_min());
|
|
|
|
assert(crypto_generichash_bytes() <= crypto_generichash_bytes_max());
|
|
|
|
assert(crypto_generichash_keybytes_min() >= 0U);
|
|
|
|
assert(crypto_generichash_keybytes_max() > 0U);
|
|
|
|
assert(crypto_generichash_keybytes() > 0U);
|
|
|
|
assert(crypto_generichash_keybytes() >= crypto_generichash_keybytes_min());
|
|
|
|
assert(crypto_generichash_keybytes() <= crypto_generichash_keybytes_max());
|
|
|
|
assert(strcmp(crypto_generichash_primitive(), "blake2b") == 0);
|
2014-09-13 18:03:04 -04:00
|
|
|
assert(crypto_generichash_bytes_min() == crypto_generichash_blake2b_bytes_min());
|
|
|
|
assert(crypto_generichash_bytes_max() == crypto_generichash_blake2b_bytes_max());
|
|
|
|
assert(crypto_generichash_bytes() == crypto_generichash_blake2b_bytes());
|
|
|
|
assert(crypto_generichash_keybytes_min() == crypto_generichash_blake2b_keybytes_min());
|
|
|
|
assert(crypto_generichash_keybytes_max() == crypto_generichash_blake2b_keybytes_max());
|
|
|
|
assert(crypto_generichash_keybytes() == crypto_generichash_blake2b_keybytes());
|
|
|
|
assert(crypto_generichash_blake2b_saltbytes() > 0U);
|
|
|
|
assert(crypto_generichash_blake2b_personalbytes() > 0U);
|
2014-09-13 17:37:04 -04:00
|
|
|
|
2013-04-19 18:28:19 -04:00
|
|
|
return 0;
|
|
|
|
}
|