1 /* $NetBSD: sha1.h,v 1.2 2024/08/18 20:47:14 christos Exp $ */ 2 3 /* 4 * Copyright (C) 2004-2007, 2009 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 #ifndef ISC_SHA1_H 21 #define ISC_SHA1_H 1 22 23 /* Id: sha1.h,v 1.19 2009/02/06 23:47:42 tbox Exp */ 24 25 /* NetBSD: sha1.h,v 1.2 1998/05/29 22:55:44 thorpej Exp */ 26 27 /*! \file isc/sha1.h 28 * \brief SHA-1 in C 29 * \author By Steve Reid <steve (at) edmweb.com> 30 * \note 100% Public Domain 31 */ 32 33 #include <isc/lang.h> 34 #include <isc/platform.h> 35 #include <isc/types.h> 36 37 #define ISC_SHA1_DIGESTLENGTH 20U 38 #define ISC_SHA1_BLOCK_LENGTH 64U 39 40 #ifdef ISC_PLATFORM_OPENSSLHASH 41 #include <openssl/evp.h> 42 43 typedef EVP_MD_CTX isc_sha1_t; 44 45 #else 46 47 typedef struct { 48 isc_uint32_t state[5]; 49 isc_uint32_t count[2]; 50 unsigned char buffer[ISC_SHA1_BLOCK_LENGTH]; 51 } isc_sha1_t; 52 #endif 53 54 ISC_LANG_BEGINDECLS 55 56 void 57 isc_sha1_init(isc_sha1_t *ctx); 58 59 void 60 isc_sha1_invalidate(isc_sha1_t *ctx); 61 62 void 63 isc_sha1_update(isc_sha1_t *ctx, const unsigned char *data, unsigned int len); 64 65 void 66 isc_sha1_final(isc_sha1_t *ctx, unsigned char *digest); 67 68 ISC_LANG_ENDDECLS 69 70 #endif /* ISC_SHA1_H */ 71