crypto_auth_hmacsha256.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef crypto_auth_hmacsha256_H
  2. #define crypto_auth_hmacsha256_H
  3. #include <stddef.h>
  4. #include "crypto_hash_sha256.h"
  5. #include "export.h"
  6. #ifdef __cplusplus
  7. # ifdef __GNUC__
  8. # pragma GCC diagnostic ignored "-Wlong-long"
  9. # endif
  10. extern "C" {
  11. #endif
  12. #define crypto_auth_hmacsha256_BYTES 32U
  13. SODIUM_EXPORT
  14. size_t crypto_auth_hmacsha256_bytes(void);
  15. #define crypto_auth_hmacsha256_KEYBYTES 32U
  16. SODIUM_EXPORT
  17. size_t crypto_auth_hmacsha256_keybytes(void);
  18. SODIUM_EXPORT
  19. int crypto_auth_hmacsha256(unsigned char *out,
  20. const unsigned char *in,
  21. unsigned long long inlen,
  22. const unsigned char *k) __attribute__ ((nonnull(1, 4)));
  23. SODIUM_EXPORT
  24. int crypto_auth_hmacsha256_verify(const unsigned char *h,
  25. const unsigned char *in,
  26. unsigned long long inlen,
  27. const unsigned char *k)
  28. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
  29. /* ------------------------------------------------------------------------- */
  30. typedef struct crypto_auth_hmacsha256_state {
  31. crypto_hash_sha256_state ictx;
  32. crypto_hash_sha256_state octx;
  33. } crypto_auth_hmacsha256_state;
  34. SODIUM_EXPORT
  35. size_t crypto_auth_hmacsha256_statebytes(void);
  36. SODIUM_EXPORT
  37. int crypto_auth_hmacsha256_init(crypto_auth_hmacsha256_state *state,
  38. const unsigned char *key,
  39. size_t keylen) __attribute__ ((nonnull));
  40. SODIUM_EXPORT
  41. int crypto_auth_hmacsha256_update(crypto_auth_hmacsha256_state *state,
  42. const unsigned char *in,
  43. unsigned long long inlen)
  44. __attribute__ ((nonnull(1)));
  45. SODIUM_EXPORT
  46. int crypto_auth_hmacsha256_final(crypto_auth_hmacsha256_state *state,
  47. unsigned char *out) __attribute__ ((nonnull));
  48. SODIUM_EXPORT
  49. void crypto_auth_hmacsha256_keygen(unsigned char k[crypto_auth_hmacsha256_KEYBYTES])
  50. __attribute__ ((nonnull));
  51. #ifdef __cplusplus
  52. }
  53. #endif
  54. #endif