shorthash.c 968 B

1234567891011121314151617181920212223242526272829303132333435
  1. #define TEST_NAME "shorthash"
  2. #include "cmptest.h"
  3. #define MAXLEN 64
  4. int
  5. main(void)
  6. {
  7. unsigned char in[MAXLEN];
  8. unsigned char out[crypto_shorthash_BYTES];
  9. unsigned char k[crypto_shorthash_KEYBYTES];
  10. size_t i;
  11. size_t j;
  12. for (i = 0; i < crypto_shorthash_KEYBYTES; ++i) {
  13. k[i] = (unsigned char) i;
  14. }
  15. for (i = 0; i < MAXLEN; ++i) {
  16. in[i] = (unsigned char) i;
  17. crypto_shorthash(out, in, (unsigned long long) i, k);
  18. for (j = 0; j < crypto_shorthash_BYTES; ++j) {
  19. printf("%02x", (unsigned int) out[j]);
  20. }
  21. printf("\n");
  22. }
  23. assert(crypto_shorthash_bytes() > 0);
  24. assert(crypto_shorthash_keybytes() > 0);
  25. assert(strcmp(crypto_shorthash_primitive(), "siphash24") == 0);
  26. assert(crypto_shorthash_bytes() == crypto_shorthash_siphash24_bytes());
  27. assert(crypto_shorthash_keybytes() ==
  28. crypto_shorthash_siphash24_keybytes());
  29. return 0;
  30. }