jabberd2
2.2.16
|
00001 /* 00002 * jabberd - Jabber Open Source Server 00003 * Copyright (c) 2002-2003 Jeremie Miller, Thomas Muldowney, 00004 * Ryan Eatmon, Robert Norris 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA 00019 */ 00020 00021 /* sha1 functions */ 00022 00023 #ifndef INCL_SHA1_H 00024 #define INCL_SHA1_H 00025 00026 /* jabberd2 Windows DLL */ 00027 #ifndef JABBERD2_API 00028 # ifdef _WIN32 00029 # ifdef JABBERD2_EXPORTS 00030 # define JABBERD2_API __declspec(dllexport) 00031 # else /* JABBERD2_EXPORTS */ 00032 # define JABBERD2_API __declspec(dllimport) 00033 # endif /* JABBERD2_EXPORTS */ 00034 # else /* _WIN32 */ 00035 # define JABBERD2_API extern 00036 # endif /* _WIN32 */ 00037 #endif /* JABBERD2_API */ 00038 00039 /* use OpenSSL functions when available */ 00040 #ifdef HAVE_SSL 00041 #include <openssl/sha.h> 00042 00043 #define sha1_state_t SHA_CTX 00044 #define sha1_init(c) SHA1_Init(c) 00045 #define sha1_append(c, data, len) SHA1_Update(c, data, len); 00046 #define sha1_finish(c, md) SHA1_Final(md, c) 00047 #define sha1_hash(data, len, md) SHA1(data, len, md); 00048 00049 #else 00050 00051 #include <inttypes.h> 00052 00053 typedef struct sha1_state_s { 00054 uint32_t H[5]; 00055 uint32_t W[80]; 00056 int lenW; 00057 uint32_t sizeHi,sizeLo; 00058 } sha1_state_t; 00059 00060 JABBERD2_API void sha1_init(sha1_state_t *ctx); 00061 JABBERD2_API void sha1_append(sha1_state_t *ctx, const unsigned char *dataIn, int len); 00062 JABBERD2_API void sha1_finish(sha1_state_t *ctx, unsigned char hashout[20]); 00063 JABBERD2_API void sha1_hash(const unsigned char *dataIn, int len, unsigned char hashout[20]); 00064 00065 #endif 00066 00067 #endif /* HAVE_SSL */