]> git.sur5r.net Git - openldap/blob - include/lutil_hash.h
Merge remote-tracking branch 'origin/mdb.master'
[openldap] / include / lutil_hash.h
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1998-2013 The OpenLDAP Foundation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.
10  *
11  * A copy of this license is available in file LICENSE in the
12  * top-level directory of the distribution or, alternatively, at
13  * <http://www.OpenLDAP.org/license.html>.
14  */
15
16 #ifndef _LUTIL_HASH_H_
17 #define _LUTIL_HASH_H_
18
19 #include <lber_types.h>
20
21 LDAP_BEGIN_DECL
22
23 #define LUTIL_HASH_BYTES 4
24
25 #ifdef HAVE_LONG_LONG
26
27 typedef union lutil_HASHContext {
28         ber_uint_t hash;
29         unsigned long long hash64;
30 } lutil_HASH_CTX;
31
32 #else /* !HAVE_LONG_LONG */
33
34 typedef struct lutil_HASHContext {
35         ber_uint_t hash;
36 } lutil_HASH_CTX;
37
38 #endif /* HAVE_LONG_LONG */
39
40 LDAP_LUTIL_F( void )
41 lutil_HASHInit LDAP_P((
42         lutil_HASH_CTX *context));
43
44 LDAP_LUTIL_F( void )
45 lutil_HASHUpdate LDAP_P((
46         lutil_HASH_CTX *context,
47         unsigned char const *buf,
48         ber_len_t len));
49
50 LDAP_LUTIL_F( void )
51 lutil_HASHFinal LDAP_P((
52         unsigned char digest[LUTIL_HASH_BYTES],
53         lutil_HASH_CTX *context));
54
55 #ifdef HAVE_LONG_LONG
56
57 #define LUTIL_HASH64_BYTES      8
58
59 LDAP_LUTIL_F( void )
60 lutil_HASH64Init LDAP_P((
61         lutil_HASH_CTX *context));
62
63 LDAP_LUTIL_F( void )
64 lutil_HASH64Update LDAP_P((
65         lutil_HASH_CTX *context,
66         unsigned char const *buf,
67         ber_len_t len));
68
69 LDAP_LUTIL_F( void )
70 lutil_HASH64Final LDAP_P((
71         unsigned char digest[LUTIL_HASH64_BYTES],
72         lutil_HASH_CTX *context));
73
74 #endif /* HAVE_LONG_LONG */
75
76 LDAP_END_DECL
77
78 #endif /* _LUTIL_HASH_H_ */