jabberd2  2.6.1
sha1.h
Go to the documentation of this file.
1 /*
2  * jabberd - Jabber Open Source Server
3  * Copyright (c) 2002-2003 Jeremie Miller, Thomas Muldowney,
4  * Ryan Eatmon, Robert Norris
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
19  */
20 
21 /* sha1 functions */
22 
23 #ifndef INCL_SHA1_H
24 #define INCL_SHA1_H
25 
26 /* jabberd2 Windows DLL */
27 #ifndef JABBERD2_API
28 # ifdef _WIN32
29 # ifdef JABBERD2_EXPORTS
30 # define JABBERD2_API __declspec(dllexport)
31 # else /* JABBERD2_EXPORTS */
32 # define JABBERD2_API __declspec(dllimport)
33 # endif /* JABBERD2_EXPORTS */
34 # else /* _WIN32 */
35 # define JABBERD2_API extern
36 # endif /* _WIN32 */
37 #endif /* JABBERD2_API */
38 
39 /* use OpenSSL functions when available */
40 #ifdef HAVE_SSL
41 #include <openssl/sha.h>
42 
43 #define sha1_state_t SHA_CTX
44 #define sha1_init(c) SHA1_Init(c)
45 #define sha1_append(c, data, len) SHA1_Update(c, data, len);
46 #define sha1_finish(c, md) SHA1_Final(md, c)
47 #define sha1_hash(data, len, md) SHA1(data, len, md);
48 
49 #else
50 
51 #include <inttypes.h>
52 
53 typedef struct sha1_state_s {
54  uint32_t H[5];
55  uint32_t W[80];
56  int lenW;
57  uint32_t sizeHi,sizeLo;
58 } sha1_state_t;
59 
61 JABBERD2_API void sha1_append(sha1_state_t *ctx, const unsigned char *dataIn, int len);
62 JABBERD2_API void sha1_finish(sha1_state_t *ctx, unsigned char hashout[20]);
63 JABBERD2_API void sha1_hash(const unsigned char *dataIn, int len, unsigned char hashout[20]);
64 
65 #endif
66 
67 #endif /* HAVE_SSL */
uint32_t sizeHi
Definition: sha1.h:57
uint32_t H[5]
Definition: sha1.h:54
JABBERD2_API void sha1_hash(const unsigned char *dataIn, int len, unsigned char hashout[20])
Definition: sha1.c:105
JABBERD2_API void sha1_init(sha1_state_t *ctx)
Definition: sha1.c:33
int lenW
Definition: sha1.h:56
JABBERD2_API void sha1_append(sha1_state_t *ctx, const unsigned char *dataIn, int len)
Definition: sha1.c:52
uint32_t sizeLo
Definition: sha1.h:57
#define JABBERD2_API
Definition: sha1.h:35
uint32_t W[80]
Definition: sha1.h:55
JABBERD2_API void sha1_finish(sha1_state_t *ctx, unsigned char hashout[20])
Definition: sha1.c:70
struct sha1_state_s sha1_state_t