ghmac.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* ghmac.h - secure data hashing
  2. *
  3. * Copyright (C) 2011 Stef Walter <stefw@collabora.co.uk>
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License
  18. * along with this library; if not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef __G_HMAC_H__
  21. #define __G_HMAC_H__
  22. #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  23. #error "Only <glib.h> can be included directly."
  24. #endif
  25. #include <glib/gtypes.h>
  26. #include "gchecksum.h"
  27. G_BEGIN_DECLS
  28. typedef struct _GHmac GHmac;
  29. GLIB_AVAILABLE_IN_2_30
  30. GHmac * g_hmac_new (GChecksumType digest_type,
  31. const guchar *key,
  32. gsize key_len);
  33. GLIB_AVAILABLE_IN_2_30
  34. GHmac * g_hmac_copy (const GHmac *hmac);
  35. GLIB_AVAILABLE_IN_2_30
  36. GHmac * g_hmac_ref (GHmac *hmac);
  37. GLIB_AVAILABLE_IN_2_30
  38. void g_hmac_unref (GHmac *hmac);
  39. GLIB_AVAILABLE_IN_2_30
  40. void g_hmac_update (GHmac *hmac,
  41. const guchar *data,
  42. gssize length);
  43. GLIB_AVAILABLE_IN_2_30
  44. const gchar * g_hmac_get_string (GHmac *hmac);
  45. GLIB_AVAILABLE_IN_2_30
  46. void g_hmac_get_digest (GHmac *hmac,
  47. guint8 *buffer,
  48. gsize *digest_len);
  49. GLIB_AVAILABLE_IN_2_30
  50. gchar *g_compute_hmac_for_data (GChecksumType digest_type,
  51. const guchar *key,
  52. gsize key_len,
  53. const guchar *data,
  54. gsize length);
  55. GLIB_AVAILABLE_IN_2_30
  56. gchar *g_compute_hmac_for_string (GChecksumType digest_type,
  57. const guchar *key,
  58. gsize key_len,
  59. const gchar *str,
  60. gssize length);
  61. GLIB_AVAILABLE_IN_2_50
  62. gchar *g_compute_hmac_for_bytes (GChecksumType digest_type,
  63. GBytes *key,
  64. GBytes *data);
  65. G_END_DECLS
  66. #endif /* __G_CHECKSUM_H__ */