xref: /minix3/external/bsd/dhcp/dist/dst/md5.h (revision 83ee113ee0d94f3844d44065af2311604e9a30ad)
1*83ee113eSDavid van Moolenbroek /*	$NetBSD: md5.h,v 1.1.1.2 2014/07/12 11:57:50 spz Exp $	*/
2*83ee113eSDavid van Moolenbroek /* crypto/md/md5.h */
3*83ee113eSDavid van Moolenbroek /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
4*83ee113eSDavid van Moolenbroek  * All rights reserved.
5*83ee113eSDavid van Moolenbroek  *
6*83ee113eSDavid van Moolenbroek  * This package is an SSL implementation written
7*83ee113eSDavid van Moolenbroek  * by Eric Young (eay@cryptsoft.com).
8*83ee113eSDavid van Moolenbroek  * The implementation was written so as to conform with Netscapes SSL.
9*83ee113eSDavid van Moolenbroek  *
10*83ee113eSDavid van Moolenbroek  * This library is free for commercial and non-commercial use as long as
11*83ee113eSDavid van Moolenbroek  * the following conditions are aheared to.  The following conditions
12*83ee113eSDavid van Moolenbroek  * apply to all code found in this distribution, be it the RC4, RSA,
13*83ee113eSDavid van Moolenbroek  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
14*83ee113eSDavid van Moolenbroek  * included with this distribution is covered by the same copyright terms
15*83ee113eSDavid van Moolenbroek  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
16*83ee113eSDavid van Moolenbroek  *
17*83ee113eSDavid van Moolenbroek  * Copyright remains Eric Young's, and as such any Copyright notices in
18*83ee113eSDavid van Moolenbroek  * the code are not to be removed.
19*83ee113eSDavid van Moolenbroek  * If this package is used in a product, Eric Young should be given attribution
20*83ee113eSDavid van Moolenbroek  * as the author of the parts of the library used.
21*83ee113eSDavid van Moolenbroek  * This can be in the form of a textual message at program startup or
22*83ee113eSDavid van Moolenbroek  * in documentation (online or textual) provided with the package.
23*83ee113eSDavid van Moolenbroek  *
24*83ee113eSDavid van Moolenbroek  * Redistribution and use in source and binary forms, with or without
25*83ee113eSDavid van Moolenbroek  * modification, are permitted provided that the following conditions
26*83ee113eSDavid van Moolenbroek  * are met:
27*83ee113eSDavid van Moolenbroek  * 1. Redistributions of source code must retain the copyright
28*83ee113eSDavid van Moolenbroek  *    notice, this list of conditions and the following disclaimer.
29*83ee113eSDavid van Moolenbroek  * 2. Redistributions in binary form must reproduce the above copyright
30*83ee113eSDavid van Moolenbroek  *    notice, this list of conditions and the following disclaimer in the
31*83ee113eSDavid van Moolenbroek  *    documentation and/or other materials provided with the distribution.
32*83ee113eSDavid van Moolenbroek  * 3. All advertising materials mentioning features or use of this software
33*83ee113eSDavid van Moolenbroek  *    must display the following acknowledgement:
34*83ee113eSDavid van Moolenbroek  *    "This product includes cryptographic software written by
35*83ee113eSDavid van Moolenbroek  *     Eric Young (eay@cryptsoft.com)"
36*83ee113eSDavid van Moolenbroek  *    The word 'cryptographic' can be left out if the rouines from the library
37*83ee113eSDavid van Moolenbroek  *    being used are not cryptographic related :-).
38*83ee113eSDavid van Moolenbroek  * 4. If you include any Windows specific code (or a derivative thereof) from
39*83ee113eSDavid van Moolenbroek  *    the apps directory (application code) you must include an acknowledgement:
40*83ee113eSDavid van Moolenbroek  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
41*83ee113eSDavid van Moolenbroek  *
42*83ee113eSDavid van Moolenbroek  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
43*83ee113eSDavid van Moolenbroek  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44*83ee113eSDavid van Moolenbroek  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45*83ee113eSDavid van Moolenbroek  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
46*83ee113eSDavid van Moolenbroek  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47*83ee113eSDavid van Moolenbroek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48*83ee113eSDavid van Moolenbroek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49*83ee113eSDavid van Moolenbroek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50*83ee113eSDavid van Moolenbroek  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51*83ee113eSDavid van Moolenbroek  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52*83ee113eSDavid van Moolenbroek  * SUCH DAMAGE.
53*83ee113eSDavid van Moolenbroek  *
54*83ee113eSDavid van Moolenbroek  * The licence and distribution terms for any publically available version or
55*83ee113eSDavid van Moolenbroek  * derivative of this code cannot be changed.  i.e. this code cannot simply be
56*83ee113eSDavid van Moolenbroek  * copied and put under another distribution licence
57*83ee113eSDavid van Moolenbroek  * [including the GNU Public Licence.]
58*83ee113eSDavid van Moolenbroek  */
59*83ee113eSDavid van Moolenbroek 
60*83ee113eSDavid van Moolenbroek /*
61*83ee113eSDavid van Moolenbroek  * Portions Copyright (c) 2007,2009 by Internet Systems Consortium, Inc. ("ISC")
62*83ee113eSDavid van Moolenbroek  *
63*83ee113eSDavid van Moolenbroek  * Permission to use, copy, modify, and distribute this software for any
64*83ee113eSDavid van Moolenbroek  * purpose with or without fee is hereby granted, provided that the above
65*83ee113eSDavid van Moolenbroek  * copyright notice and this permission notice appear in all copies.
66*83ee113eSDavid van Moolenbroek  *
67*83ee113eSDavid van Moolenbroek  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
68*83ee113eSDavid van Moolenbroek  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
69*83ee113eSDavid van Moolenbroek  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
70*83ee113eSDavid van Moolenbroek  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
71*83ee113eSDavid van Moolenbroek  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
72*83ee113eSDavid van Moolenbroek  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
73*83ee113eSDavid van Moolenbroek  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
74*83ee113eSDavid van Moolenbroek  *
75*83ee113eSDavid van Moolenbroek  *   Internet Systems Consortium, Inc.
76*83ee113eSDavid van Moolenbroek  *   950 Charter Street
77*83ee113eSDavid van Moolenbroek  *   Redwood City, CA 94063
78*83ee113eSDavid van Moolenbroek  *   <info@isc.org>
79*83ee113eSDavid van Moolenbroek  *   https://www.isc.org/
80*83ee113eSDavid van Moolenbroek  */
81*83ee113eSDavid van Moolenbroek 
82*83ee113eSDavid van Moolenbroek #ifndef HEADER_MD5_H
83*83ee113eSDavid van Moolenbroek #define HEADER_MD5_H
84*83ee113eSDavid van Moolenbroek 
85*83ee113eSDavid van Moolenbroek #ifdef  __cplusplus
86*83ee113eSDavid van Moolenbroek extern "C" {
87*83ee113eSDavid van Moolenbroek #endif
88*83ee113eSDavid van Moolenbroek 
89*83ee113eSDavid van Moolenbroek #define MD5_CBLOCK	64
90*83ee113eSDavid van Moolenbroek #define MD5_LBLOCK	16
91*83ee113eSDavid van Moolenbroek #define MD5_BLOCK	16
92*83ee113eSDavid van Moolenbroek #define MD5_LAST_BLOCK  56
93*83ee113eSDavid van Moolenbroek #define MD5_LENGTH_BLOCK 8
94*83ee113eSDavid van Moolenbroek #define MD5_DIGEST_LENGTH 16
95*83ee113eSDavid van Moolenbroek 
96*83ee113eSDavid van Moolenbroek typedef struct MD5state_st
97*83ee113eSDavid van Moolenbroek 	{
98*83ee113eSDavid van Moolenbroek 	unsigned long A,B,C,D;
99*83ee113eSDavid van Moolenbroek 	unsigned long Nl,Nh;
100*83ee113eSDavid van Moolenbroek 	unsigned long data[MD5_LBLOCK];
101*83ee113eSDavid van Moolenbroek 	int num;
102*83ee113eSDavid van Moolenbroek 	} MD5_CTX;
103*83ee113eSDavid van Moolenbroek 
104*83ee113eSDavid van Moolenbroek #ifndef NOPROTO
105*83ee113eSDavid van Moolenbroek void MD5_Init(MD5_CTX *c);
106*83ee113eSDavid van Moolenbroek void MD5_Update(MD5_CTX *c, const unsigned char *data, unsigned long len);
107*83ee113eSDavid van Moolenbroek void MD5_Final(unsigned char *md, MD5_CTX *c);
108*83ee113eSDavid van Moolenbroek unsigned char *MD5(unsigned char *d, unsigned long n, unsigned char *md);
109*83ee113eSDavid van Moolenbroek #else
110*83ee113eSDavid van Moolenbroek void MD5_Init();
111*83ee113eSDavid van Moolenbroek void MD5_Update();
112*83ee113eSDavid van Moolenbroek void MD5_Final();
113*83ee113eSDavid van Moolenbroek unsigned char *MD5();
114*83ee113eSDavid van Moolenbroek #endif
115*83ee113eSDavid van Moolenbroek 
116*83ee113eSDavid van Moolenbroek /* to provide backward compatibleness to RSAREF calls ogud@tis.com 1997/11/14 */
117*83ee113eSDavid van Moolenbroek #define MD5Init(c)             MD5_Init(c)
118*83ee113eSDavid van Moolenbroek #define MD5Update(c,data, len) MD5_Update(c,data,len)
119*83ee113eSDavid van Moolenbroek #define MD5Final(md, c)        MD5_Final(md, c)
120*83ee113eSDavid van Moolenbroek #ifdef  __cplusplus
121*83ee113eSDavid van Moolenbroek }
122*83ee113eSDavid van Moolenbroek #endif
123*83ee113eSDavid van Moolenbroek 
124*83ee113eSDavid van Moolenbroek #endif
125