1 /*	$NetBSD: hmacmd5.h,v 1.5 2014/12/10 04:38:00 christos Exp $	*/
2 
3 /*
4  * Copyright (C) 2004-2007, 2009, 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: hmacmd5.h,v 1.14 2009/02/06 23:47:42 tbox Exp  */
21 
22 /*! \file isc/hmacmd5.h
23  * \brief This is the header file for the HMAC-MD5 keyed hash algorithm
24  * described in RFC2104.
25  */
26 
27 #ifndef ISC_HMACMD5_H
28 #define ISC_HMACMD5_H 1
29 
30 #include <isc/lang.h>
31 #include <isc/md5.h>
32 #include <isc/platform.h>
33 #include <isc/types.h>
34 
35 #define ISC_HMACMD5_KEYLENGTH 64
36 
37 #ifdef ISC_PLATFORM_OPENSSLHASH
38 #include <openssl/hmac.h>
39 
40 typedef HMAC_CTX isc_hmacmd5_t;
41 
42 #elif PKCS11CRYPTO
43 #include <pk11/pk11.h>
44 
45 typedef pk11_context_t isc_hmacmd5_t;
46 
47 #else
48 
49 typedef struct {
50 	isc_md5_t md5ctx;
51 	unsigned char key[ISC_HMACMD5_KEYLENGTH];
52 } isc_hmacmd5_t;
53 #endif
54 
55 ISC_LANG_BEGINDECLS
56 
57 void
58 isc_hmacmd5_init(isc_hmacmd5_t *ctx, const unsigned char *key,
59 		 unsigned int len);
60 
61 void
62 isc_hmacmd5_invalidate(isc_hmacmd5_t *ctx);
63 
64 void
65 isc_hmacmd5_update(isc_hmacmd5_t *ctx, const unsigned char *buf,
66 		   unsigned int len);
67 
68 void
69 isc_hmacmd5_sign(isc_hmacmd5_t *ctx, unsigned char *digest);
70 
71 isc_boolean_t
72 isc_hmacmd5_verify(isc_hmacmd5_t *ctx, unsigned char *digest);
73 
74 isc_boolean_t
75 isc_hmacmd5_verify2(isc_hmacmd5_t *ctx, unsigned char *digest, size_t len);
76 
77 ISC_LANG_ENDDECLS
78 
79 #endif /* ISC_HMACMD5_H */
80