vincent | c1a03d4 | 2005-09-28 15:47:44 +0000 | [diff] [blame] | 1 | /* $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 $ */ |
paul | 7d0b0c4 | 2006-01-17 17:40:45 +0000 | [diff] [blame] | 3 | /* $Id: md5.h,v 1.3 2006/01/17 17:40:45 paul Exp $ */ |
vincent | c1a03d4 | 2005-09-28 15:47:44 +0000 | [diff] [blame] | 4 | |
| 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 | |
| 47 | typedef struct { |
| 48 | union { |
paul | 34204aa | 2005-11-03 09:00:23 +0000 | [diff] [blame] | 49 | uint32_t md5_state32[4]; |
| 50 | uint8_t md5_state8[16]; |
vincent | c1a03d4 | 2005-09-28 15:47:44 +0000 | [diff] [blame] | 51 | } 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 { |
paul | 34204aa | 2005-11-03 09:00:23 +0000 | [diff] [blame] | 60 | uint64_t md5_count64; |
| 61 | uint8_t md5_count8[8]; |
vincent | c1a03d4 | 2005-09-28 15:47:44 +0000 | [diff] [blame] | 62 | } md5_count; |
| 63 | #define md5_n md5_count.md5_count64 |
| 64 | #define md5_n8 md5_count.md5_count8 |
| 65 | |
paul | 34204aa | 2005-11-03 09:00:23 +0000 | [diff] [blame] | 66 | uint md5_i; |
| 67 | uint8_t md5_buf[MD5_BUFLEN]; |
vincent | c1a03d4 | 2005-09-28 15:47:44 +0000 | [diff] [blame] | 68 | } md5_ctxt; |
| 69 | |
paul | 34204aa | 2005-11-03 09:00:23 +0000 | [diff] [blame] | 70 | extern void md5_init (md5_ctxt *); |
paul | 7d0b0c4 | 2006-01-17 17:40:45 +0000 | [diff] [blame] | 71 | extern void md5_loop (md5_ctxt *, const void *, u_int); |
paul | 34204aa | 2005-11-03 09:00:23 +0000 | [diff] [blame] | 72 | extern void md5_pad (md5_ctxt *); |
| 73 | extern void md5_result (uint8_t *, md5_ctxt *); |
vincent | c1a03d4 | 2005-09-28 15:47:44 +0000 | [diff] [blame] | 74 | |
| 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) \ |
| 80 | do { \ |
| 81 | md5_pad((y)); \ |
| 82 | md5_result((x), (y)); \ |
| 83 | } while (0) |
| 84 | |
| 85 | #endif /* ! _LIBZEBRA_MD5_H_*/ |