blob: 9e627dd825fe3feb3861c94c265064bce4fd1fbf [file] [log] [blame]
vincentc1a03d42005-09-28 15:47:44 +00001/* $USAGI: md5.h,v 1.2 2000/11/02 11:59:25 yoshfuji Exp $ */
2/* $KAME: md5.h,v 1.4 2000/03/27 04:36:22 sumikawa Exp $ */
paul34204aa2005-11-03 09:00:23 +00003/* $Id: md5.h,v 1.2 2005/11/03 09:00:23 paul Exp $ */
vincentc1a03d42005-09-28 15:47:44 +00004
5/*
6 * Copyright (C) 2004 6WIND
7 * <Vincent.Jardin@6WIND.com>
8 * All rights reserved.
9 *
10 * This MD5 code is Big endian and Little Endian compatible.
11 */
12
13/*
14 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 * 3. Neither the name of the project nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
40 */
41
42#ifndef _LIBZEBRA_MD5_H_
43#define _LIBZEBRA_MD5_H_
44
45#define MD5_BUFLEN 64
46
47typedef struct {
48 union {
paul34204aa2005-11-03 09:00:23 +000049 uint32_t md5_state32[4];
50 uint8_t md5_state8[16];
vincentc1a03d42005-09-28 15:47:44 +000051 } md5_st;
52
53#define md5_sta md5_st.md5_state32[0]
54#define md5_stb md5_st.md5_state32[1]
55#define md5_stc md5_st.md5_state32[2]
56#define md5_std md5_st.md5_state32[3]
57#define md5_st8 md5_st.md5_state8
58
59 union {
paul34204aa2005-11-03 09:00:23 +000060 uint64_t md5_count64;
61 uint8_t md5_count8[8];
vincentc1a03d42005-09-28 15:47:44 +000062 } md5_count;
63#define md5_n md5_count.md5_count64
64#define md5_n8 md5_count.md5_count8
65
paul34204aa2005-11-03 09:00:23 +000066 uint md5_i;
67 uint8_t md5_buf[MD5_BUFLEN];
vincentc1a03d42005-09-28 15:47:44 +000068} md5_ctxt;
69
paul34204aa2005-11-03 09:00:23 +000070extern void md5_init (md5_ctxt *);
71extern void md5_loop (md5_ctxt *, const uint8_t *, u_int);
72extern void md5_pad (md5_ctxt *);
73extern void md5_result (uint8_t *, md5_ctxt *);
vincentc1a03d42005-09-28 15:47:44 +000074
75/* compatibility */
76#define MD5_CTX md5_ctxt
77#define MD5Init(x) md5_init((x))
78#define MD5Update(x, y, z) md5_loop((x), (y), (z))
79#define MD5Final(x, y) \
80do { \
81 md5_pad((y)); \
82 md5_result((x), (y)); \
83} while (0)
84
85#endif /* ! _LIBZEBRA_MD5_H_*/