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