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 Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 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 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __G_HMAC_H__
20#define __G_HMAC_H__
21
22#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
23#error "Only <glib.h> can be included directly."
24#endif
25
26#include <glib/gtypes.h>
27#include "gchecksum.h"
28
29G_BEGIN_DECLS
30
31/**
32 * GHmac:
33 *
34 * An opaque structure representing a HMAC operation.
35 * To create a new GHmac, use g_hmac_new(). To free
36 * a GHmac, use g_hmac_unref().
37 *
38 * Since: 2.30
39 */
40typedef struct _GHmac GHmac;
41
42GLIB_AVAILABLE_IN_2_30
43GHmac * g_hmac_new (GChecksumType digest_type,
44 const guchar *key,
45 gsize key_len);
46GLIB_AVAILABLE_IN_2_30
47GHmac * g_hmac_copy (const GHmac *hmac);
48GLIB_AVAILABLE_IN_2_30
49GHmac * g_hmac_ref (GHmac *hmac);
50GLIB_AVAILABLE_IN_2_30
51void g_hmac_unref (GHmac *hmac);
52GLIB_AVAILABLE_IN_2_30
53void g_hmac_update (GHmac *hmac,
54 const guchar *data,
55 gssize length);
56GLIB_AVAILABLE_IN_2_30
57const gchar * g_hmac_get_string (GHmac *hmac);
58GLIB_AVAILABLE_IN_2_30
59void g_hmac_get_digest (GHmac *hmac,
60 guint8 *buffer,
61 gsize *digest_len);
62
63GLIB_AVAILABLE_IN_2_30
64gchar *g_compute_hmac_for_data (GChecksumType digest_type,
65 const guchar *key,
66 gsize key_len,
67 const guchar *data,
68 gsize length);
69GLIB_AVAILABLE_IN_2_30
70gchar *g_compute_hmac_for_string (GChecksumType digest_type,
71 const guchar *key,
72 gsize key_len,
73 const gchar *str,
74 gssize length);
75GLIB_AVAILABLE_IN_2_50
76gchar *g_compute_hmac_for_bytes (GChecksumType digest_type,
77 GBytes *key,
78 GBytes *data);
79
80
81G_END_DECLS
82
83#endif /* __G_CHECKSUM_H__ */
84