]> git.sur5r.net Git - openldap/blob - include/lutil.h
845509076b0e964785542c5508d8b3fe3c1144d9
[openldap] / include / lutil.h
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2000 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 #ifndef _LUTIL_H
13 #define _LUTIL_H 1
14
15 #include <ldap_cdefs.h>
16 #include <lber_types.h>
17
18 /*
19  * Include file for LDAP utility routine
20  */
21
22 LDAP_BEGIN_DECL
23
24 /* n octets encode into ceiling(n/3) * 4 bytes */
25 /* Avoid floating point math by through extra padding */
26
27 #define LUTIL_BASE64_ENCODE_LEN(n)      ((n)/3 * 4 + 4)
28 #define LUTIL_BASE64_DECODE_LEN(n)      ((n)/4 * 3)
29
30 /* ISC Base64 Routines */
31 /* base64.c */
32
33 LDAP_LUTIL_F( int )
34 lutil_b64_ntop LDAP_P((
35         unsigned char const *,
36         size_t,
37         char *,
38         size_t));
39
40 LDAP_LUTIL_F( int )
41 lutil_b64_pton LDAP_P((
42         char const *,
43         unsigned char *,
44         size_t));
45
46 /* detach.c */
47 LDAP_LUTIL_F( void )
48 lutil_detach LDAP_P((
49         int debug,
50         int do_close));
51
52 /* entropy.c */
53 LDAP_LUTIL_F( int )
54 lutil_entropy LDAP_P((
55         unsigned char *buf,
56         ber_len_t nbytes ));
57
58 /* passwd.c */
59 struct berval; /* avoid pulling in lber.h */
60
61 LDAP_LUTIL_F( int )
62 lutil_authpasswd LDAP_P((
63         const struct berval *passwd,    /* stored password */
64         const struct berval *cred,      /* user supplied value */
65         const char **methods ));
66
67 LDAP_LUTIL_F( int )
68 lutil_authpasswd_hash LDAP_P((
69         const struct berval *cred,
70         struct berval **passwd, /* password to store */
71         struct berval **salt,   /* salt to store */
72         const char *method ));
73
74 #if defined( SLAPD_SPASSWD ) && defined( HAVE_CYRUS_SASL )
75         /* cheat to avoid pulling in <sasl.h> */
76 LDAP_LUTIL_F( struct sasl_conn * ) lutil_passwd_sasl_conn;
77 #endif
78
79 LDAP_LUTIL_F( int )
80 lutil_passwd LDAP_P((
81         const struct berval *passwd,    /* stored password */
82         const struct berval *cred,      /* user supplied value */
83         const char **methods ));
84
85 LDAP_LUTIL_F( struct berval * )
86 lutil_passwd_generate LDAP_P(( ber_len_t ));
87
88 LDAP_LUTIL_F( struct berval * )
89 lutil_passwd_hash LDAP_P((
90         const struct berval *passwd,
91         const char *method ));
92
93 LDAP_LUTIL_F( int )
94 lutil_passwd_scheme LDAP_P((
95         const char *scheme ));
96
97 /* utils.c */
98 LDAP_LUTIL_F( char* )
99 lutil_progname LDAP_P((
100         const char* name,
101         int argc,
102         char *argv[] ));
103
104 /* sockpair.c */
105 LDAP_LUTIL_F( int )
106 lutil_pair( ber_socket_t sd[2] );
107
108 LDAP_END_DECL
109
110 #endif /* _LUTIL_H */