hmacsha.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2005-2007, 2009, 2014  Internet Systems Consortium, Inc. ("ISC")
00003  *
00004  * Permission to use, copy, modify, and/or distribute this software for any
00005  * purpose with or without fee is hereby granted, provided that the above
00006  * copyright notice and this permission notice appear in all copies.
00007  *
00008  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00009  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00010  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00011  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00012  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00013  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00014  * PERFORMANCE OF THIS SOFTWARE.
00015  */
00016 
00017 /* $Id: hmacsha.h,v 1.9 2009/02/06 23:47:42 tbox Exp $ */
00018 
00019 /*! \file isc/hmacsha.h
00020  * This is the header file for the HMAC-SHA1, HMAC-SHA224, HMAC-SHA256,
00021  * HMAC-SHA334 and HMAC-SHA512 hash algorithm described in RFC 2104.
00022  */
00023 
00024 #ifndef ISC_HMACSHA_H
00025 #define ISC_HMACSHA_H 1
00026 
00027 #include <isc/lang.h>
00028 #include <isc/platform.h>
00029 #include <isc/sha1.h>
00030 #include <isc/sha2.h>
00031 #include <isc/types.h>
00032 
00033 #define ISC_HMACSHA1_KEYLENGTH ISC_SHA1_BLOCK_LENGTH
00034 #define ISC_HMACSHA224_KEYLENGTH ISC_SHA224_BLOCK_LENGTH
00035 #define ISC_HMACSHA256_KEYLENGTH ISC_SHA256_BLOCK_LENGTH
00036 #define ISC_HMACSHA384_KEYLENGTH ISC_SHA384_BLOCK_LENGTH
00037 #define ISC_HMACSHA512_KEYLENGTH ISC_SHA512_BLOCK_LENGTH
00038 
00039 #ifdef ISC_PLATFORM_OPENSSLHASH
00040 #include <openssl/hmac.h>
00041 
00042 typedef HMAC_CTX isc_hmacsha1_t;
00043 typedef HMAC_CTX isc_hmacsha224_t;
00044 typedef HMAC_CTX isc_hmacsha256_t;
00045 typedef HMAC_CTX isc_hmacsha384_t;
00046 typedef HMAC_CTX isc_hmacsha512_t;
00047 
00048 #elif PKCS11CRYPTO
00049 #include <pk11/pk11.h>
00050 
00051 typedef pk11_context_t isc_hmacsha1_t;
00052 typedef pk11_context_t isc_hmacsha224_t;
00053 typedef pk11_context_t isc_hmacsha256_t;
00054 typedef pk11_context_t isc_hmacsha384_t;
00055 typedef pk11_context_t isc_hmacsha512_t;
00056 
00057 #else
00058 
00059 typedef struct {
00060         isc_sha1_t sha1ctx;
00061         unsigned char key[ISC_HMACSHA1_KEYLENGTH];
00062 } isc_hmacsha1_t;
00063 
00064 typedef struct {
00065         isc_sha224_t sha224ctx;
00066         unsigned char key[ISC_HMACSHA224_KEYLENGTH];
00067 } isc_hmacsha224_t;
00068 
00069 typedef struct {
00070         isc_sha256_t sha256ctx;
00071         unsigned char key[ISC_HMACSHA256_KEYLENGTH];
00072 } isc_hmacsha256_t;
00073 
00074 typedef struct {
00075         isc_sha384_t sha384ctx;
00076         unsigned char key[ISC_HMACSHA384_KEYLENGTH];
00077 } isc_hmacsha384_t;
00078 
00079 typedef struct {
00080         isc_sha512_t sha512ctx;
00081         unsigned char key[ISC_HMACSHA512_KEYLENGTH];
00082 } isc_hmacsha512_t;
00083 #endif
00084 
00085 ISC_LANG_BEGINDECLS
00086 
00087 void
00088 isc_hmacsha1_init(isc_hmacsha1_t *ctx, const unsigned char *key,
00089                   unsigned int len);
00090 
00091 void
00092 isc_hmacsha1_invalidate(isc_hmacsha1_t *ctx);
00093 
00094 void
00095 isc_hmacsha1_update(isc_hmacsha1_t *ctx, const unsigned char *buf,
00096                     unsigned int len);
00097 
00098 void
00099 isc_hmacsha1_sign(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len);
00100 
00101 isc_boolean_t
00102 isc_hmacsha1_verify(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len);
00103 
00104 
00105 void
00106 isc_hmacsha224_init(isc_hmacsha224_t *ctx, const unsigned char *key,
00107                     unsigned int len);
00108 
00109 void
00110 isc_hmacsha224_invalidate(isc_hmacsha224_t *ctx);
00111 
00112 void
00113 isc_hmacsha224_update(isc_hmacsha224_t *ctx, const unsigned char *buf,
00114                       unsigned int len);
00115 
00116 void
00117 isc_hmacsha224_sign(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len);
00118 
00119 isc_boolean_t
00120 isc_hmacsha224_verify(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len);
00121 
00122 
00123 void
00124 isc_hmacsha256_init(isc_hmacsha256_t *ctx, const unsigned char *key,
00125                     unsigned int len);
00126 
00127 void
00128 isc_hmacsha256_invalidate(isc_hmacsha256_t *ctx);
00129 
00130 void
00131 isc_hmacsha256_update(isc_hmacsha256_t *ctx, const unsigned char *buf,
00132                       unsigned int len);
00133 
00134 void
00135 isc_hmacsha256_sign(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len);
00136 
00137 isc_boolean_t
00138 isc_hmacsha256_verify(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len);
00139 
00140 
00141 void
00142 isc_hmacsha384_init(isc_hmacsha384_t *ctx, const unsigned char *key,
00143                     unsigned int len);
00144 
00145 void
00146 isc_hmacsha384_invalidate(isc_hmacsha384_t *ctx);
00147 
00148 void
00149 isc_hmacsha384_update(isc_hmacsha384_t *ctx, const unsigned char *buf,
00150                       unsigned int len);
00151 
00152 void
00153 isc_hmacsha384_sign(isc_hmacsha384_t *ctx, unsigned char *digest, size_t len);
00154 
00155 isc_boolean_t
00156 isc_hmacsha384_verify(isc_hmacsha384_t *ctx, unsigned char *digest, size_t len);
00157 
00158 
00159 void
00160 isc_hmacsha512_init(isc_hmacsha512_t *ctx, const unsigned char *key,
00161                     unsigned int len);
00162 
00163 void
00164 isc_hmacsha512_invalidate(isc_hmacsha512_t *ctx);
00165 
00166 void
00167 isc_hmacsha512_update(isc_hmacsha512_t *ctx, const unsigned char *buf,
00168                       unsigned int len);
00169 
00170 void
00171 isc_hmacsha512_sign(isc_hmacsha512_t *ctx, unsigned char *digest, size_t len);
00172 
00173 isc_boolean_t
00174 isc_hmacsha512_verify(isc_hmacsha512_t *ctx, unsigned char *digest, size_t len);
00175 
00176 ISC_LANG_ENDDECLS
00177 
00178 #endif /* ISC_HMACSHA_H */

Generated on Tue Apr 28 17:41:04 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha