00001 /* 00002 * Copyright (C) 2004-2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC") 00003 * Copyright (C) 2000, 2001 Internet Software Consortium. 00004 * 00005 * Permission to use, copy, modify, and/or distribute this software for any 00006 * purpose with or without fee is hereby granted, provided that the above 00007 * copyright notice and this permission notice appear in all copies. 00008 * 00009 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 00010 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 00011 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 00012 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 00013 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 00014 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00015 * PERFORMANCE OF THIS SOFTWARE. 00016 */ 00017 00018 #ifndef ISC_SHA1_H 00019 #define ISC_SHA1_H 1 00020 00021 /* $Id: sha1.h,v 1.19 2009/02/06 23:47:42 tbox Exp $ */ 00022 00023 /* $NetBSD: sha1.h,v 1.2 1998/05/29 22:55:44 thorpej Exp $ */ 00024 00025 /*! \file isc/sha1.h 00026 * \brief SHA-1 in C 00027 * \author By Steve Reid <steve@edmweb.com> 00028 * \note 100% Public Domain 00029 */ 00030 00031 #include <isc/lang.h> 00032 #include <isc/platform.h> 00033 #include <isc/types.h> 00034 00035 #define ISC_SHA1_DIGESTLENGTH 20U 00036 #define ISC_SHA1_BLOCK_LENGTH 64U 00037 00038 #ifdef ISC_PLATFORM_OPENSSLHASH 00039 #include <openssl/evp.h> 00040 00041 typedef EVP_MD_CTX isc_sha1_t; 00042 00043 #elif PKCS11CRYPTO 00044 #include <pk11/pk11.h> 00045 00046 typedef pk11_context_t isc_sha1_t; 00047 00048 #else 00049 00050 typedef struct { 00051 isc_uint32_t state[5]; 00052 isc_uint32_t count[2]; 00053 unsigned char buffer[ISC_SHA1_BLOCK_LENGTH]; 00054 } isc_sha1_t; 00055 #endif 00056 00057 ISC_LANG_BEGINDECLS 00058 00059 void 00060 isc_sha1_init(isc_sha1_t *ctx); 00061 00062 void 00063 isc_sha1_invalidate(isc_sha1_t *ctx); 00064 00065 void 00066 isc_sha1_update(isc_sha1_t *ctx, const unsigned char *data, unsigned int len); 00067 00068 void 00069 isc_sha1_final(isc_sha1_t *ctx, unsigned char *digest); 00070 00071 ISC_LANG_ENDDECLS 00072 00073 #endif /* ISC_SHA1_H */