2010-09-21 00:08:53 +04:00
|
|
|
/* contrib/pgcrypto/md5.h */
|
2001-03-22 07:01:46 +03:00
|
|
|
/* $KAME: md5.h,v 1.3 2000/02/22 14:01:18 itojun Exp $ */
|
2000-10-31 16:11:28 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
2001-03-22 07:01:46 +03:00
|
|
|
* notice, this list of conditions and the following disclaimer.
|
2000-10-31 16:11:28 +03:00
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
2001-03-22 07:01:46 +03:00
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2000-10-31 16:11:28 +03:00
|
|
|
* 3. Neither the name of the project nor the names of its contributors
|
2001-03-22 07:01:46 +03:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
2000-10-31 16:11:28 +03:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
2014-05-06 20:12:18 +04:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
2000-10-31 16:11:28 +03:00
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETINET6_MD5_H_
|
|
|
|
#define _NETINET6_MD5_H_
|
|
|
|
|
|
|
|
#define MD5_BUFLEN 64
|
|
|
|
|
2001-03-22 07:01:46 +03:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
2001-01-09 19:07:14 +03:00
|
|
|
uint32 md5_state32[4];
|
|
|
|
uint8 md5_state8[16];
|
2001-03-22 07:01:46 +03:00
|
|
|
} md5_st;
|
2000-10-31 16:11:28 +03:00
|
|
|
|
|
|
|
#define md5_sta md5_st.md5_state32[0]
|
|
|
|
#define md5_stb md5_st.md5_state32[1]
|
|
|
|
#define md5_stc md5_st.md5_state32[2]
|
|
|
|
#define md5_std md5_st.md5_state32[3]
|
|
|
|
#define md5_st8 md5_st.md5_state8
|
|
|
|
|
2001-03-22 07:01:46 +03:00
|
|
|
union
|
|
|
|
{
|
2001-01-09 19:07:14 +03:00
|
|
|
uint64 md5_count64;
|
|
|
|
uint8 md5_count8[8];
|
2001-03-22 07:01:46 +03:00
|
|
|
} md5_count;
|
2000-10-31 16:11:28 +03:00
|
|
|
#define md5_n md5_count.md5_count64
|
|
|
|
#define md5_n8 md5_count.md5_count8
|
|
|
|
|
2001-03-22 07:01:46 +03:00
|
|
|
unsigned int md5_i;
|
|
|
|
uint8 md5_buf[MD5_BUFLEN];
|
2009-06-11 18:49:15 +04:00
|
|
|
} md5_ctxt;
|
2000-10-31 16:11:28 +03:00
|
|
|
|
2001-03-22 07:01:46 +03:00
|
|
|
extern void md5_init(md5_ctxt *);
|
/contrib/pgcrypto:
* remove support for encode() as it is in main tree now
* remove krb5.c
* new 'PX library' architecture
* remove BSD license from my code to let the general
PostgreSQL one to apply
* md5, sha1: ANSIfy, use const where appropriate
* various other formatting and clarity changes
* hmac()
* UN*X-like crypt() - system or internal crypt
* Internal crypt: DES, Extended DES, MD5, Blowfish
crypt-des.c, crypt-md5.c from FreeBSD
crypt-blowfish.c from Solar Designer
* gen_salt() for crypt() - Blowfish, MD5, DES, Extended DES
* encrypt(), decrypt(), encrypt_iv(), decrypt_iv()
* Cipher support in mhash.c, openssl.c
* internal: Blowfish, Rijndael-128 ciphers
* blf.[ch], rijndael.[ch] from OpenBSD
* there will be generated file rijndael-tbl.inc.
Marko Kreen
2001-08-21 04:42:41 +04:00
|
|
|
extern void md5_loop(md5_ctxt *, const uint8 *, unsigned int);
|
2001-03-22 07:01:46 +03:00
|
|
|
extern void md5_pad(md5_ctxt *);
|
|
|
|
extern void md5_result(uint8 *, md5_ctxt *);
|
2000-10-31 16:11:28 +03:00
|
|
|
|
|
|
|
/* compatibility */
|
|
|
|
#define MD5_CTX md5_ctxt
|
|
|
|
#define MD5Init(x) md5_init((x))
|
|
|
|
#define MD5Update(x, y, z) md5_loop((x), (y), (z))
|
|
|
|
#define MD5Final(x, y) \
|
|
|
|
do { \
|
|
|
|
md5_pad((y)); \
|
|
|
|
md5_result((x), (y)); \
|
|
|
|
} while (0)
|
2001-10-28 09:26:15 +03:00
|
|
|
|
2001-11-05 20:46:40 +03:00
|
|
|
#endif /* ! _NETINET6_MD5_H_ */
|