1 /* $Id: authsaslplain.c,v 1.3 2005/07/02 15:40:28 mrsam Exp $ */
4 ** Copyright 2000-2005 Double Precision, Inc. See COPYING for
5 ** distribution information.
8 #include "courier_auth_config.h"
10 #include "random128/random128.h"
11 #include "courierauthsasl.h"
21 extern char *strdupdefdomain(const char *userid
, const char *s1
,
22 const char *s2
, const char *s3
);
24 int authsasl_plain(const char *method
, const char *initresponse
,
25 char *(*getresp
)(const char *, void *),
38 p
=malloc(strlen(initresponse
)+1);
42 return (AUTHSASL_ERROR
);
44 strcpy(p
, initresponse
);
48 p
=authsasl_tobase64("", -1);
52 return (AUTHSASL_ERROR
);
54 uid
=getresp(p
, callback_arg
);
60 return (AUTHSASL_ERROR
);
66 return (AUTHSASL_ABORTED
);
70 if ((n
=authsasl_frombase64(p
)) < 0)
73 return (AUTHSASL_ABORTED
);
84 for (uid
=p
+i
; i
<n
; i
++)
96 return (AUTHSASL_ABORTED
); /* Bad message */
99 if ( (*authtype
=malloc(sizeof(AUTHTYPE_LOGIN
))) == 0)
103 return (AUTHSASL_ERROR
);
106 strcpy( *authtype
, AUTHTYPE_LOGIN
);
108 if ( (*authdata
=strdupdefdomain(uid
, "\n", pw
, "\n")) == 0)
113 return (AUTHSASL_ERROR
);
117 return (AUTHSASL_OK
);