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