ghmac.h 3.1 KB

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