2 * Copyright (C) 2005-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
17 /* $Id: hmacsha.h,v 1.9 2009-02-06 23:47:42 tbox Exp $ */
19 /*! \file isc/hmacsha.h
20 * This is the header file for the HMAC-SHA1, HMAC-SHA224, HMAC-SHA256,
21 * HMAC-SHA334 and HMAC-SHA512 hash algorithm described in RFC 2104.
25 #define ISC_HMACSHA_H 1
28 #include <isc/platform.h>
31 #include <isc/types.h>
33 #define ISC_HMACSHA1_KEYLENGTH ISC_SHA1_BLOCK_LENGTH
34 #define ISC_HMACSHA224_KEYLENGTH ISC_SHA224_BLOCK_LENGTH
35 #define ISC_HMACSHA256_KEYLENGTH ISC_SHA256_BLOCK_LENGTH
36 #define ISC_HMACSHA384_KEYLENGTH ISC_SHA384_BLOCK_LENGTH
37 #define ISC_HMACSHA512_KEYLENGTH ISC_SHA512_BLOCK_LENGTH
39 #ifdef ISC_PLATFORM_OPENSSLHASH
40 #include <openssl/hmac.h>
42 typedef HMAC_CTX isc_hmacsha1_t;
43 typedef HMAC_CTX isc_hmacsha224_t;
44 typedef HMAC_CTX isc_hmacsha256_t;
45 typedef HMAC_CTX isc_hmacsha384_t;
46 typedef HMAC_CTX isc_hmacsha512_t;
52 unsigned char key[ISC_HMACSHA1_KEYLENGTH];
56 isc_sha224_t sha224ctx;
57 unsigned char key[ISC_HMACSHA224_KEYLENGTH];
61 isc_sha256_t sha256ctx;
62 unsigned char key[ISC_HMACSHA256_KEYLENGTH];
66 isc_sha384_t sha384ctx;
67 unsigned char key[ISC_HMACSHA384_KEYLENGTH];
71 isc_sha512_t sha512ctx;
72 unsigned char key[ISC_HMACSHA512_KEYLENGTH];
79 isc_hmacsha1_init(isc_hmacsha1_t *ctx, const unsigned char *key,
83 isc_hmacsha1_invalidate(isc_hmacsha1_t *ctx);
86 isc_hmacsha1_update(isc_hmacsha1_t *ctx, const unsigned char *buf,
90 isc_hmacsha1_sign(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len);
93 isc_hmacsha1_verify(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len);
97 isc_hmacsha224_init(isc_hmacsha224_t *ctx, const unsigned char *key,
101 isc_hmacsha224_invalidate(isc_hmacsha224_t *ctx);
104 isc_hmacsha224_update(isc_hmacsha224_t *ctx, const unsigned char *buf,
108 isc_hmacsha224_sign(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len);
111 isc_hmacsha224_verify(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len);
115 isc_hmacsha256_init(isc_hmacsha256_t *ctx, const unsigned char *key,
119 isc_hmacsha256_invalidate(isc_hmacsha256_t *ctx);
122 isc_hmacsha256_update(isc_hmacsha256_t *ctx, const unsigned char *buf,
126 isc_hmacsha256_sign(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len);
129 isc_hmacsha256_verify(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len);
133 isc_hmacsha384_init(isc_hmacsha384_t *ctx, const unsigned char *key,
137 isc_hmacsha384_invalidate(isc_hmacsha384_t *ctx);
140 isc_hmacsha384_update(isc_hmacsha384_t *ctx, const unsigned char *buf,
144 isc_hmacsha384_sign(isc_hmacsha384_t *ctx, unsigned char *digest, size_t len);
147 isc_hmacsha384_verify(isc_hmacsha384_t *ctx, unsigned char *digest, size_t len);
151 isc_hmacsha512_init(isc_hmacsha512_t *ctx, const unsigned char *key,
155 isc_hmacsha512_invalidate(isc_hmacsha512_t *ctx);
158 isc_hmacsha512_update(isc_hmacsha512_t *ctx, const unsigned char *buf,
162 isc_hmacsha512_sign(isc_hmacsha512_t *ctx, unsigned char *digest, size_t len);
165 isc_hmacsha512_verify(isc_hmacsha512_t *ctx, unsigned char *digest, size_t len);
169 #endif /* ISC_HMACSHA_H */