1/* $OpenLDAP$ */
2/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3 *
4 * Copyright 1998-2011 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/* This version is based on:
17 *	$OpenBSD: sha1.h,v 1.8 1997/07/15 01:54:23 millert Exp $	*/
18
19#ifndef _LUTIL_SHA1_H_
20#define _LUTIL_SHA1_H_
21
22#include <ldap_cdefs.h>
23#include <ac/bytes.h>
24
25#ifdef AC_INT4_TYPE
26
27LDAP_BEGIN_DECL
28
29
30/*
31 * SHA-1 in C
32 * By Steve Reid <steve@edmweb.com>
33 */
34#define LUTIL_SHA1_BYTES 20
35
36/* This code assumes char are 8-bits and uint32 are 32-bits */
37typedef ac_uint4 uint32;
38
39typedef struct {
40    uint32 state[5];
41    uint32 count[2];
42    unsigned char buffer[64];
43} lutil_SHA1_CTX;
44
45LDAP_LUTIL_F( void )
46lutil_SHA1Transform
47	LDAP_P((uint32 state[5], const unsigned char buffer[64]));
48
49LDAP_LUTIL_F( void  )
50lutil_SHA1Init
51	LDAP_P((lutil_SHA1_CTX *context));
52
53LDAP_LUTIL_F( void  )
54lutil_SHA1Update
55	LDAP_P((lutil_SHA1_CTX *context, const unsigned char *data, uint32 len));
56
57LDAP_LUTIL_F( void  )
58lutil_SHA1Final
59	LDAP_P((unsigned char digest[20], lutil_SHA1_CTX *context));
60
61LDAP_LUTIL_F( char * )
62lutil_SHA1End
63	LDAP_P((lutil_SHA1_CTX *, char *));
64
65LDAP_LUTIL_F( char * )
66lutil_SHA1File
67	LDAP_P((char *, char *));
68
69LDAP_LUTIL_F( char * )
70lutil_SHA1Data
71	LDAP_P((const unsigned char *, size_t, char *));
72
73LDAP_END_DECL
74
75#endif /* AC_INT4_TYPE */
76
77#endif /* _LUTIL_SHA1_H_ */
78