aboutsummaryrefslogtreecommitdiff
path: root/lib/pop3.c
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-10-27 16:27:38 +0000
committerSteve Holme <steve_holme@hotmail.com>2013-10-27 16:27:38 +0000
commitb87ba2c94217c0b5da8758b22972ee2d5381f169 (patch)
treed3f5ad23b1e405d65d3ef822126fce44a603533b /lib/pop3.c
parente7a2ba41e33b29c61637275721981adc1c544e7f (diff)
email: Added support for cancelling DIGEST-MD5 authentication
Diffstat (limited to 'lib/pop3.c')
-rw-r--r--lib/pop3.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/lib/pop3.c b/lib/pop3.c
index 79ce43ecb..cd7a4a4d3 100644
--- a/lib/pop3.c
+++ b/lib/pop3.c
@@ -1018,6 +1018,10 @@ static CURLcode pop3_state_auth_digest_resp(struct connectdata *conn,
char *rplyb64 = NULL;
size_t len = 0;
+ char nonce[64];
+ char realm[128];
+ char algorithm[64];
+
(void)instate; /* no use for this yet */
if(pop3code != '+') {
@@ -1028,23 +1032,33 @@ static CURLcode pop3_state_auth_digest_resp(struct connectdata *conn,
/* Get the challenge message */
pop3_get_message(data->state.buffer, &chlg64);
- /* Create the response message */
- result = Curl_sasl_create_digest_md5_message(data, chlg64, conn->user,
- conn->passwd, "pop",
- &rplyb64, &len);
+ /* Decode the challange message */
+ result = Curl_sasl_decode_digest_md5_message(chlg64, nonce, sizeof(nonce),
+ realm, sizeof(realm),
+ algorithm, sizeof(algorithm));
+ if(result || strcmp(algorithm, "md5-sess") != 0) {
+ /* Send the cancellation */
+ result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", "*");
- /* Send the response */
- if(!result) {
- if(rplyb64) {
+ if(!result)
+ state(conn, POP3_AUTH_CANCEL);
+ }
+ else {
+ /* Create the response message */
+ result = Curl_sasl_create_digest_md5_message(data, nonce, realm,
+ conn->user, conn->passwd,
+ "pop", &rplyb64, &len);
+ if(!result && rplyb64) {
+ /* Send the response */
result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", rplyb64);
if(!result)
state(conn, POP3_AUTH_DIGESTMD5_RESP);
}
-
- Curl_safefree(rplyb64);
}
+ Curl_safefree(rplyb64);
+
return result;
}