Header And Logo

PostgreSQL
| The world's most advanced open source database.

md5.h

Go to the documentation of this file.
00001 /*  contrib/pgcrypto/md5.h */
00002 /*     $KAME: md5.h,v 1.3 2000/02/22 14:01:18 itojun Exp $     */
00003 
00004 /*
00005  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  * 3. Neither the name of the project nor the names of its contributors
00017  *    may be used to endorse or promote products derived from this software
00018  *    without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
00021  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00022  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00023  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
00024  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00025  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00026  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00027  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00028  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00029  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00030  * SUCH DAMAGE.
00031  */
00032 
00033 #ifndef _NETINET6_MD5_H_
00034 #define _NETINET6_MD5_H_
00035 
00036 #define MD5_BUFLEN  64
00037 
00038 typedef struct
00039 {
00040     union
00041     {
00042         uint32      md5_state32[4];
00043         uint8       md5_state8[16];
00044     }           md5_st;
00045 
00046 #define md5_sta     md5_st.md5_state32[0]
00047 #define md5_stb     md5_st.md5_state32[1]
00048 #define md5_stc     md5_st.md5_state32[2]
00049 #define md5_std     md5_st.md5_state32[3]
00050 #define md5_st8     md5_st.md5_state8
00051 
00052     union
00053     {
00054         uint64      md5_count64;
00055         uint8       md5_count8[8];
00056     }           md5_count;
00057 #define md5_n   md5_count.md5_count64
00058 #define md5_n8  md5_count.md5_count8
00059 
00060     unsigned int md5_i;
00061     uint8       md5_buf[MD5_BUFLEN];
00062 } md5_ctxt;
00063 
00064 extern void md5_init(md5_ctxt *);
00065 extern void md5_loop(md5_ctxt *, const uint8 *, unsigned int);
00066 extern void md5_pad(md5_ctxt *);
00067 extern void md5_result(uint8 *, md5_ctxt *);
00068 
00069 /* compatibility */
00070 #define MD5_CTX     md5_ctxt
00071 #define MD5Init(x)  md5_init((x))
00072 #define MD5Update(x, y, z)  md5_loop((x), (y), (z))
00073 #define MD5Final(x, y) \
00074 do {                \
00075     md5_pad((y));       \
00076     md5_result((x), (y));   \
00077 } while (0)
00078 
00079 #endif   /* ! _NETINET6_MD5_H_ */