xref: /freebsd/contrib/ntp/libntp/lib/isc/include/isc/md5.h (revision 7ef62cebc2f965b0f640263e179276928885e33d)
1 /*
2  * Copyright (C) 2004-2007, 2009, 2010  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 2000, 2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /* $Id: md5.h,v 1.20 2010/01/07 23:48:54 tbox Exp $ */
19 
20 /*! \file isc/md5.h
21  * \brief This is the header file for the MD5 message-digest algorithm.
22  *
23  * The algorithm is due to Ron Rivest.  This code was
24  * written by Colin Plumb in 1993, no copyright is claimed.
25  * This code is in the public domain; do with it what you wish.
26  *
27  * Equivalent code is available from RSA Data Security, Inc.
28  * This code has been tested against that, and is equivalent,
29  * except that you don't need to include two pages of legalese
30  * with every copy.
31  *
32  * To compute the message digest of a chunk of bytes, declare an
33  * MD5Context structure, pass it to MD5Init, call MD5Update as
34  * needed on buffers full of bytes, and then call MD5Final, which
35  * will fill a supplied 16-byte array with the digest.
36  *
37  * Changed so as no longer to depend on Colin Plumb's `usual.h'
38  * header definitions; now uses stuff from dpkg's config.h
39  *  - Ian Jackson <ijackson@nyx.cs.du.edu>.
40  * Still in the public domain.
41  */
42 
43 #ifndef ISC_MD5_H
44 #define ISC_MD5_H 1
45 
46 #include <isc/lang.h>
47 #include <isc/platform.h>
48 #include <isc/types.h>
49 
50 #define ISC_MD5_DIGESTLENGTH 16U
51 #define ISC_MD5_BLOCK_LENGTH 64U
52 
53 #ifdef ISC_PLATFORM_OPENSSLHASH
54 #include <openssl/evp.h>
55 
56 typedef EVP_MD_CTX isc_md5_t;
57 
58 #else
59 
60 typedef struct {
61 	isc_uint32_t buf[4];
62 	isc_uint32_t bytes[2];
63 	isc_uint32_t in[16];
64 } isc_md5_t;
65 #endif
66 
67 ISC_LANG_BEGINDECLS
68 
69 void
70 isc_md5_init(isc_md5_t *ctx);
71 
72 void
73 isc_md5_invalidate(isc_md5_t *ctx);
74 
75 void
76 isc_md5_update(isc_md5_t *ctx, const unsigned char *buf, unsigned int len);
77 
78 void
79 isc_md5_final(isc_md5_t *ctx, unsigned char *digest);
80 
81 ISC_LANG_ENDDECLS
82 
83 #endif /* ISC_MD5_H */
84