1 #include "sasl.h"
2 #include "sasl_internal.h"
3
4 static const char cusername[] = "Username:";
5 static const char cpassword[] = "Password:";
6
response2(struct sasl_state * ss,const str * response,str * challenge)7 static int response2(struct sasl_state* ss,
8 const str* response, str* challenge)
9 {
10 if (response->len == 0)
11 return SASL_RESP_BAD;
12 return sasl_authenticate_plain(ss, ss->username.s, response->s);
13 (void)challenge;
14 }
15
response1(struct sasl_state * ss,const str * response,str * challenge)16 static int response1(struct sasl_state* ss,
17 const str* response, str* challenge)
18 {
19 if (response->len == 0)
20 return SASL_RESP_BAD;
21 if (!str_copy(&ss->username, response) ||
22 !str_copys(challenge, cpassword))
23 return SASL_TEMP_FAIL;
24 ss->response = response2;
25 return SASL_CHALLENGE;
26 }
27
sasl_login_start(struct sasl_state * ss,const str * response,str * challenge)28 int sasl_login_start(struct sasl_state* ss,
29 const str* response, str* challenge)
30 {
31 if (response)
32 return response1(ss, response, challenge);
33 if (!str_copys(challenge, cusername))
34 return SASL_TEMP_FAIL;
35 ss->response = response1;
36 return SASL_CHALLENGE;
37 }
38