3 ** Copyright 2000-2005 Double Precision, Inc. See COPYING for
4 ** distribution information.
7 #include "courier_auth_config.h"
9 #include "random128/random128.h"
10 #include "courierauthsasl.h"
20 extern char *strdupdefdomain(const char *userid
, const char *s1
,
21 const char *s2
, const char *s3
);
23 int authsasl_plain(const char *method
, const char *initresponse
,
24 char *(*getresp
)(const char *, void *),
37 p
=malloc(strlen(initresponse
)+1);
41 return (AUTHSASL_ERROR
);
43 strcpy(p
, initresponse
);
47 p
=authsasl_tobase64("", -1);
51 return (AUTHSASL_ERROR
);
53 uid
=getresp(p
, callback_arg
);
59 return (AUTHSASL_ERROR
);
65 return (AUTHSASL_ABORTED
);
69 if ((n
=authsasl_frombase64(p
)) < 0)
72 return (AUTHSASL_ABORTED
);
83 for (uid
=p
+i
; i
<n
; i
++)
95 return (AUTHSASL_ABORTED
); /* Bad message */
98 if ( (*authtype
=malloc(sizeof(AUTHTYPE_LOGIN
))) == 0)
102 return (AUTHSASL_ERROR
);
105 strcpy( *authtype
, AUTHTYPE_LOGIN
);
107 if ( (*authdata
=strdupdefdomain(uid
, "\n", pw
, "\n")) == 0)
112 return (AUTHSASL_ERROR
);
116 return (AUTHSASL_OK
);