File: courierauthsasl.h

package info (click to toggle)
courier-authlib 0.58-4%2Betch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 16,212 kB
  • ctags: 1,896
  • sloc: ansic: 21,550; sh: 14,071; makefile: 866; perl: 842; cpp: 284
file content (103 lines) | stat: -rw-r--r-- 2,912 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef	courierauthsasl_h
#define	courierauthsasl_h

/*
** Copyright 1998 - 2004 Double Precision, Inc.  See COPYING for
** distribution information.
*/

#include	"courier_auth_config.h"
#include	<sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

static const char courierauthsasl_h_rcsid[]="$Id: courierauthsasl.h,v 1.1 2004/10/21 00:10:49 mrsam Exp $";

/*
	These family of functions are used to implement the SASL interface
	on top of authlib.  It is mainly used by the authentication user
	process to build the authentication request data for authmod()
	based upon the SASL challenge/response interaction.
*/

/*
**	auth_sasl searched for the right method, and calls the appropriate
**	sasl function.  authsasl received the following arguments:
**
**	initresponse -- initial response for the authentication request,
**	if provided.  If provided, the actual response MUST BE PROVIDED
**	in initresponse using base64 encoding!!!
**
**	sasl_func -- the callback function which is used to carry out the
**	SASL conversation.  The function receives a single argument, the
**	base64-encoded challenge.  The callback function must return
**	a malloced pointer to the base64-encoded response, or NULL to abort
**	SASL.
**
**	authsasl returns two values, provided via call by reference:
**	the authtype and authdata, suitable for direct arguments to
**	auth_generic().
*/

int auth_sasl(const char *,		/* Method */
	      const char *,		/* Initial response - base64encoded */
	      char *(*)(const char *, void *),
					/* Callback conversation functions */
	      void *,			/* Passthrough arg */
	      char **,			/* Returned - AUTHTYPE */
	      char **);			/* Returned - AUTHDATA */


	/* INTERNAL FUNCTIONS BELOW */

/*
** The authsasl_info is built dynamically by configure, it lists the supported
** SASL methods.  Each method is implemented by a function that's prototyped
** like this:
**
**  int authsasl_function(const char *method, const char *initresponse,
**      char *(*getresp)(const char *),
**
**	char **authtype,
**	char **authdata)
**
** Normally, there's no need to call the appropriate function directly, as
** authsasl() automatically searches this array, and finds one.
**
*/

struct authsasl_info {
	const char *sasl_method;	/* In uppercase */
	int (*sasl_func)(const char *method, const char *initresponse,
			 char *(*getresp)(const char *, void *),
			 void *,
			 char **,
			 char **);
	} ;

extern struct authsasl_info authsasl_list[];
/* Some convenience functions */

char *authsasl_tobase64(const char *, int);
int authsasl_frombase64(char *);

/* Return values from authsasl */

#define	AUTHSASL_OK	0
#define	AUTHSASL_ERROR	-1	/*
				** System error, usually malloc failure,
				** authsasl reports the error to stderr.
				*/

#define	AUTHSASL_ABORTED -2	/*
				** SASL exchange aborted. authsasl does NOT
				** report any errors.
				*/

#ifdef	__cplusplus
}
#endif

#endif