_info 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "config.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. /**
  5. * siphash - a keyed hash function
  6. *
  7. * SipHash-c-d, where `c` is the number of rounds per message chunk
  8. * and `d` the number of finalization rounds,
  9. * "is a family of pseudorandom functions optimized for speed on short
  10. * messages"
  11. *
  12. * Implemented from the paper https://131002.net/siphash/
  13. * The designers recommend using SipHash-2-4 or SipHash-4-8
  14. *
  15. * SipHash-c-d uses a 16-byte key.
  16. * To defend against hash-flooding, the application needs to use
  17. * a new random key regularly.
  18. *
  19. * The designers of SipHash claim it is cryptographically strong
  20. * to use as MAC with secret key but _not_collision_resistant_.
  21. *
  22. * Returns one 64-bit word as the hash function result.
  23. *
  24. * Example:
  25. * // Outputs cf2794e0277187b7
  26. * #include <stdio.h>
  27. * #include <ccan/siphash/siphash.h>
  28. *
  29. * int main(void)
  30. * {
  31. * unsigned char t_key[16] =
  32. * {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
  33. * unsigned char data[4] = "\0\1\2\3";
  34. * uint64_t hash = siphash_2_4(data, sizeof(data), t_key);
  35. * printf("%llx\n", (unsigned long long)hash);
  36. *
  37. * return 0;
  38. * }
  39. *
  40. *
  41. * License: GPL (v2 or any later version)
  42. */
  43. int main(int argc, char *argv[])
  44. {
  45. if (argc != 2)
  46. return 1;
  47. if (strcmp(argv[1], "depends") == 0) {
  48. printf("ccan/endian\n");
  49. return 0;
  50. }
  51. return 1;
  52. }