crypto_hash_sha512.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef crypto_hash_sha512_H
  2. #define crypto_hash_sha512_H
  3. /*
  4. * WARNING: Unless you absolutely need to use SHA512 for interoperatibility,
  5. * purposes, you might want to consider crypto_generichash() instead.
  6. * Unlike SHA512, crypto_generichash() is not vulnerable to length
  7. * extension attacks.
  8. */
  9. #include <stddef.h>
  10. #include <stdint.h>
  11. #include <stdlib.h>
  12. #include "export.h"
  13. #ifdef __cplusplus
  14. # ifdef __GNUC__
  15. # pragma GCC diagnostic ignored "-Wlong-long"
  16. # endif
  17. extern "C" {
  18. #endif
  19. typedef struct crypto_hash_sha512_state {
  20. uint64_t state[8];
  21. uint64_t count[2];
  22. uint8_t buf[128];
  23. } crypto_hash_sha512_state;
  24. SODIUM_EXPORT
  25. size_t crypto_hash_sha512_statebytes(void);
  26. #define crypto_hash_sha512_BYTES 64U
  27. SODIUM_EXPORT
  28. size_t crypto_hash_sha512_bytes(void);
  29. SODIUM_EXPORT
  30. int crypto_hash_sha512(unsigned char *out, const unsigned char *in,
  31. unsigned long long inlen) __attribute__ ((nonnull(1)));
  32. SODIUM_EXPORT
  33. int crypto_hash_sha512_init(crypto_hash_sha512_state *state)
  34. __attribute__ ((nonnull));
  35. SODIUM_EXPORT
  36. int crypto_hash_sha512_update(crypto_hash_sha512_state *state,
  37. const unsigned char *in,
  38. unsigned long long inlen)
  39. __attribute__ ((nonnull(1)));
  40. SODIUM_EXPORT
  41. int crypto_hash_sha512_final(crypto_hash_sha512_state *state,
  42. unsigned char *out)
  43. __attribute__ ((nonnull));
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif