]> git.sur5r.net Git - openldap/blob - include/lutil_sha1.h
1f335065a0b75b060ba98a7dd9f7437680030645
[openldap] / include / lutil_sha1.h
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms are permitted only
7  * as authorized by the OpenLDAP Public License.  A copy of this
8  * license is available at http://www.OpenLDAP.org/license.html or
9  * in file LICENSE in the top-level directory of the distribution.
10  */
11
12 /* This version is based on:
13  *      $OpenBSD: sha1.h,v 1.8 1997/07/15 01:54:23 millert Exp $        */
14
15 #ifndef _LUTIL_SHA1_H_
16 #define _LUTIL_SHA1_H_
17
18 #include <ldap_cdefs.h>
19 #include <ac/bytes.h>
20
21 LDAP_BEGIN_DECL
22
23 /*
24  * SHA-1 in C
25  * By Steve Reid <steve@edmweb.com>
26  */
27
28 #ifndef LDAP_UINT32
29 #define LDAP_UINT32 1
30 typedef ac_uint4 uint32;
31 #endif
32
33 typedef struct {
34     uint32 state[5];
35     uint32 count[2];  
36     unsigned char buffer[64];
37 } lutil_SHA1_CTX;
38   
39 #ifdef __MINGW32__
40 #   undef LDAP_F_PRE
41 #   ifdef LIBLUTIL_DECL
42 #       define LDAP_F_PRE       extern __declspec(LIBLUTIL_DECL)
43 #   else
44 #       define LDAP_F_PRE       extern
45 #   endif
46 #endif
47
48 LDAP_F( void )
49 lutil_SHA1Transform
50         LDAP_P((uint32 state[5], const unsigned char buffer[64]));
51
52 LDAP_F( void  )
53 lutil_SHA1Init
54         LDAP_P((lutil_SHA1_CTX *context));
55
56 LDAP_F( void  )
57 lutil_SHA1Update
58         LDAP_P((lutil_SHA1_CTX *context, const unsigned char *data, uint32 len));
59
60 LDAP_F( void  )
61 lutil_SHA1Final
62         LDAP_P((unsigned char digest[20], lutil_SHA1_CTX *context));
63
64 LDAP_F( char * )
65 lutil_SHA1End
66         LDAP_P((lutil_SHA1_CTX *, char *));
67
68 LDAP_F( char * )
69 lutil_SHA1File
70         LDAP_P((char *, char *));
71
72 LDAP_F( char * )
73 lutil_SHA1Data
74         LDAP_P((const unsigned char *, size_t, char *));
75
76 LDAP_END_DECL
77
78 #endif /* _LUTIL_SHA1_H_ */