From 3a92de56362dcf39895e3781429fcc4c6877105b Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Wed, 2 Apr 2014 20:53:43 +0100 Subject: sasl: Combined DIGEST-MD5 message decoding and generation --- lib/imap.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) (limited to 'lib/imap.c') diff --git a/lib/imap.c b/lib/imap.c index 6f7238385..a3dd49926 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -1110,10 +1110,6 @@ static CURLcode imap_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(imapcode != '+') { @@ -1124,29 +1120,25 @@ static CURLcode imap_state_auth_digest_resp(struct connectdata *conn, /* Get the challenge message */ imap_get_message(data->state.buffer, &chlg64); - /* 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.imapc.pp, "%s", "*"); + /* Create the response message */ + result = Curl_sasl_create_digest_md5_message(data, chlg64, + conn->user, conn->passwd, + "imap", &rplyb64, &len); + if(result) { + if(result == CURLE_BAD_CONTENT_ENCODING) { + /* Send the cancellation */ + result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", "*"); - if(!result) - state(conn, IMAP_AUTHENTICATE_CANCEL); + if(!result) + state(conn, IMAP_AUTHENTICATE_CANCEL); + } } else { - /* Create the response message */ - result = Curl_sasl_create_digest_md5_message(data, nonce, realm, - conn->user, conn->passwd, - "imap", &rplyb64, &len); - if(!result && rplyb64) { - /* Send the response */ - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", rplyb64); + /* Send the response */ + result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", rplyb64); - if(!result) - state(conn, IMAP_AUTHENTICATE_DIGESTMD5_RESP); - } + if(!result) + state(conn, IMAP_AUTHENTICATE_DIGESTMD5_RESP); } Curl_safefree(rplyb64); -- cgit v1.2.3