HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / wsutil / md5.h
blobc9a3592233aace5420d62bba2c8ccba807ccd3be
1 /* $Id$ */
2 /*
3 * Copyright (C) 2003-2005 Benny Prijono <benny@prijono.org>
4 * Copyright (C) 2012 C Elston, Katalix Systems Ltd <celston@katalix.com>
6 * MD5 code from pjlib-util http://www.pjsip.org
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 * 2012-08-21 - C Elston - Split md5_hmac function to allow incremental usage.
25 #ifndef __MD5_H__ /**@todo Should this be _CRYPT_MD5_H__ ?*/
26 #define __MD5_H__
28 #include "ws_symbol_export.h"
30 /**
31 * @file md5.h
32 * @brief MD5 Functions
35 /* Don't define this group for Wireshark
36 * @defgroup PJLIB_UTIL_MD5 MD5 Functions
37 * @ingroup PJLIB_UTIL
38 * @{
41 #define md5_byte_t guint8
43 /** MD5 context. */
44 typedef struct md5_state_s
46 guint32 buf[4];
47 guint32 bits[2];
48 guint32 in[16];
49 } md5_state_t;
51 /** Initialize the algorithm.
52 * @param pms MD5 context.
54 WS_DLL_PUBLIC
55 void md5_init(md5_state_t *pms);
57 /** Append a string to the message.
58 * @param pms MD5 context.
59 * @param data Data.
60 * @param nbytes Length of data.
62 WS_DLL_PUBLIC
63 void md5_append( md5_state_t *pms,
64 const guint8 *data, size_t nbytes);
66 /** Finish the message and return the digest.
67 * @param pms MD5 context.
68 * @param digest 16 byte digest.
70 WS_DLL_PUBLIC
71 void md5_finish(md5_state_t *pms, guint8 digest[16]);
73 typedef struct md5_hmac_state_s
75 md5_state_t ctx;
76 guint8 k_opad[65];
77 } md5_hmac_state_t;
79 WS_DLL_PUBLIC
80 void md5_hmac_init(md5_hmac_state_t *hctx,
81 const guint8* key, size_t key_len);
83 WS_DLL_PUBLIC
84 void md5_hmac_append(md5_hmac_state_t *hctx,
85 const guint8* text, size_t text_len);
87 WS_DLL_PUBLIC
88 void md5_hmac_finish(md5_hmac_state_t *hctx, guint8 digest[16]);
90 WS_DLL_PUBLIC
91 void md5_hmac(const guint8* text, size_t text_len, const guint8* key,
92 size_t key_len, guint8 digest[16]);
95 * @}
98 #endif /* _CRYPT_MD5_H__ */