You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
969 B

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