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__ ?*/
28 #include "ws_symbol_export.h"
32 * @brief MD5 Functions
35 /* Don't define this group for Wireshark
36 * @defgroup PJLIB_UTIL_MD5 MD5 Functions
41 #define md5_byte_t guint8
44 typedef struct md5_state_s
51 /** Initialize the algorithm.
52 * @param pms MD5 context.
55 void md5_init(md5_state_t
*pms
);
57 /** Append a string to the message.
58 * @param pms MD5 context.
60 * @param nbytes Length of data.
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.
71 void md5_finish(md5_state_t
*pms
, guint8 digest
[16]);
73 typedef struct md5_hmac_state_s
80 void md5_hmac_init(md5_hmac_state_t
*hctx
,
81 const guint8
* key
, size_t key_len
);
84 void md5_hmac_append(md5_hmac_state_t
*hctx
,
85 const guint8
* text
, size_t text_len
);
88 void md5_hmac_finish(md5_hmac_state_t
*hctx
, guint8 digest
[16]);
91 void md5_hmac(const guint8
* text
, size_t text_len
, const guint8
* key
,
92 size_t key_len
, guint8 digest
[16]);
98 #endif /* _CRYPT_MD5_H__ */