From 978b808f7d636aa2540a351fc776287b49dcaa8a Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Fri, 25 May 2012 21:49:25 +0100 Subject: smtp: Moved auth-mechanism constants into a separate header file Move the SMTP_AUTH constants into a separate header file in preparation for adding SASL based authentication to POP3 as the two protocols will need to share them. --- lib/curl_sasl.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 lib/curl_sasl.h (limited to 'lib/curl_sasl.h') diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h new file mode 100644 index 000000000..dbbbad440 --- /dev/null +++ b/lib/curl_sasl.h @@ -0,0 +1,36 @@ +#ifndef HEADER_CURL_SASL_H +#define HEADER_CURL_SASL_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2012, 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 + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "pingpong.h" + +/* Authentication mechanism flags */ +#define SMTP_AUTH_LOGIN 0x0001 +#define SMTP_AUTH_PLAIN 0x0002 +#define SMTP_AUTH_CRAM_MD5 0x0004 +#define SMTP_AUTH_DIGEST_MD5 0x0008 +#define SMTP_AUTH_GSSAPI 0x0010 +#define SMTP_AUTH_EXTERNAL 0x0020 +#define SMTP_AUTH_NTLM 0x0040 + +#endif /* HEADER_CURL_SASL_H */ -- cgit v1.2.1 From 9c480490f7559e169cea59754480f87d2763e2c2 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Fri, 25 May 2012 21:58:17 +0100 Subject: sasl: Re-factored auth-mechanism constants to be more generic --- lib/curl_sasl.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/curl_sasl.h') diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index dbbbad440..b0d4d365e 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -25,12 +25,12 @@ #include "pingpong.h" /* Authentication mechanism flags */ -#define SMTP_AUTH_LOGIN 0x0001 -#define SMTP_AUTH_PLAIN 0x0002 -#define SMTP_AUTH_CRAM_MD5 0x0004 -#define SMTP_AUTH_DIGEST_MD5 0x0008 -#define SMTP_AUTH_GSSAPI 0x0010 -#define SMTP_AUTH_EXTERNAL 0x0020 -#define SMTP_AUTH_NTLM 0x0040 +#define SASL_AUTH_LOGIN 0x0001 +#define SASL_AUTH_PLAIN 0x0002 +#define SASL_AUTH_CRAM_MD5 0x0004 +#define SASL_AUTH_DIGEST_MD5 0x0008 +#define SASL_AUTH_GSSAPI 0x0010 +#define SASL_AUTH_EXTERNAL 0x0020 +#define SASL_AUTH_NTLM 0x0040 #endif /* HEADER_CURL_SASL_H */ -- cgit v1.2.1 From 8e860c16625d65b63042731f5c343775bcb34983 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Wed, 30 May 2012 20:52:52 +0100 Subject: sasl: Moved plain text authentication message creation from smtp.c Moved the plain text message creation from smtp.c into the sasl module to allow for use by other modules such as pop3. --- lib/curl_sasl.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/curl_sasl.h') diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index b0d4d365e..236645657 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -33,4 +33,10 @@ #define SASL_AUTH_EXTERNAL 0x0020 #define SASL_AUTH_NTLM 0x0040 +/* This is to generate a base64 encoded plain authentication message */ +CURLcode Curl_sasl_create_plain_message(struct SessionHandle *data, + const char* userp, + const char* passwdp, + char **outptr, size_t *outlen); + #endif /* HEADER_CURL_SASL_H */ -- cgit v1.2.1 From 54d484e136d43b50934cc906804662e780adc3fa Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Thu, 31 May 2012 23:11:54 +0100 Subject: sasl: Moved login authentication message creation from smtp.c Moved the login message creation from smtp.c into the sasl module to allow for use by other modules such as pop3. --- lib/curl_sasl.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/curl_sasl.h') diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index 236645657..dfe69ceda 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -33,10 +33,16 @@ #define SASL_AUTH_EXTERNAL 0x0020 #define SASL_AUTH_NTLM 0x0040 -/* This is to generate a base64 encoded plain authentication message */ +/* This is used to generate a base64 encoded plain authentication message */ CURLcode Curl_sasl_create_plain_message(struct SessionHandle *data, const char* userp, const char* passwdp, char **outptr, size_t *outlen); +/* This is used to generate a base64 encoded login authentication message + containing either the user name or password details */ +CURLcode Curl_sasl_create_login_message(struct SessionHandle *data, + const char* valuep, char **outptr, + size_t *outlen); + #endif /* HEADER_CURL_SASL_H */ -- cgit v1.2.1 From d9ca9e9869e8dd5559b36ffec608c847f154e40a Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Sat, 2 Jun 2012 11:07:58 +0100 Subject: sasl: Moved ntlm authentication message handling from smtp.c Moved the ntlm message creation and decoding from smtp.c into the sasl module to allow for use by other modules such as pop3. --- lib/curl_sasl.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lib/curl_sasl.h') diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index dfe69ceda..43f853d77 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -45,4 +45,27 @@ CURLcode Curl_sasl_create_login_message(struct SessionHandle *data, const char* valuep, char **outptr, size_t *outlen); +#ifdef USE_NTLM +/* This is used to generate a base64 encoded NTLM type-1 message */ +CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp, + const char *passwdp, + struct ntlmdata *ntlm, + char **outptr, + size_t *outlen); + +/* This is used to decode an incoming NTLM type-2 message and generate a + base64 encoded type-3 response */ +CURLcode Curl_sasl_decode_ntlm_type2_message(struct SessionHandle *data, + const char *type2msg, + const char *userp, + const char *passwdp, + struct ntlmdata *ntlm, + char **outptr, size_t *outlen); + +#endif /* USE_NTLM */ + +/* This is used to cleanup any libraries or curl modules used by the sasl + functions */ +void Curl_sasl_cleanup(struct connectdata *conn, unsigned int authused); + #endif /* HEADER_CURL_SASL_H */ -- cgit v1.2.1 From 6f964e4f0625177d9fdef61cc72de9d46328ace5 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Sat, 2 Jun 2012 11:09:59 +0100 Subject: sasl: Small comment style tidy up following ntlm commit --- lib/curl_sasl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/curl_sasl.h') diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index 43f853d77..f1b104f30 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -33,13 +33,13 @@ #define SASL_AUTH_EXTERNAL 0x0020 #define SASL_AUTH_NTLM 0x0040 -/* This is used to generate a base64 encoded plain authentication message */ +/* This is used to generate a base64 encoded PLAIN authentication message */ CURLcode Curl_sasl_create_plain_message(struct SessionHandle *data, const char* userp, const char* passwdp, char **outptr, size_t *outlen); -/* This is used to generate a base64 encoded login authentication message +/* This is used to generate a base64 encoded LOGIN authentication message containing either the user name or password details */ CURLcode Curl_sasl_create_login_message(struct SessionHandle *data, const char* valuep, char **outptr, -- cgit v1.2.1 From cfa81b8fb00928a88ed4b76807f564d3a895a493 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Sat, 2 Jun 2012 14:03:55 +0100 Subject: sasl: Corrected variable names in comments and parameters --- lib/curl_sasl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/curl_sasl.h') diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index f1b104f30..572eaed74 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -56,7 +56,7 @@ CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp, /* This is used to decode an incoming NTLM type-2 message and generate a base64 encoded type-3 response */ CURLcode Curl_sasl_decode_ntlm_type2_message(struct SessionHandle *data, - const char *type2msg, + const char *header, const char *userp, const char *passwdp, struct ntlmdata *ntlm, -- cgit v1.2.1 From c12a414b21f22fca0b1b6860b464d45368152d56 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Sun, 3 Jun 2012 17:21:49 +0100 Subject: sasl: Moved cram-md5 authentication message creation from smtp.c Moved the cram-md5 message creation from smtp.c into the sasl module to allow for use by other modules such as pop3. --- lib/curl_sasl.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/curl_sasl.h') diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index 572eaed74..567b44bb6 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -45,6 +45,15 @@ CURLcode Curl_sasl_create_login_message(struct SessionHandle *data, const char* valuep, char **outptr, size_t *outlen); +#ifndef CURL_DISABLE_CRYPTO_AUTH +/* This is used to generate a base64 encoded CRAM-MD5 message */ +CURLcode Curl_sasl_create_cram_md5_message(struct SessionHandle *data, + const char* chlg64, + const char* user, + const char* passwdp, + char **outptr, size_t *outlen); +#endif + #ifdef USE_NTLM /* This is used to generate a base64 encoded NTLM type-1 message */ CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp, -- cgit v1.2.1 From 58987556d5fecb6f634fbfd56c6f73ba0a4cedf2 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Mon, 4 Jun 2012 10:49:55 +0100 Subject: sasl: Small code tidy up before moving digest-md5 over Correction of comments and variable names. --- lib/curl_sasl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/curl_sasl.h') diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index 567b44bb6..c9b605310 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -46,7 +46,7 @@ CURLcode Curl_sasl_create_login_message(struct SessionHandle *data, size_t *outlen); #ifndef CURL_DISABLE_CRYPTO_AUTH -/* This is used to generate a base64 encoded CRAM-MD5 message */ +/* This is used to generate a base64 encoded CRAM-MD5 response message */ CURLcode Curl_sasl_create_cram_md5_message(struct SessionHandle *data, const char* chlg64, const char* user, -- cgit v1.2.1 From 665e16899ce6629097ce884722d9ef17b6708354 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Mon, 4 Jun 2012 10:53:18 +0100 Subject: sasl: Moved digest-md5 authentication message creation from smtp.c Moved the digest-md5 message creation from smtp.c into the sasl module to allow for use by other modules such as pop3. --- lib/curl_sasl.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/curl_sasl.h') diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index c9b605310..892da81ec 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -52,6 +52,13 @@ CURLcode Curl_sasl_create_cram_md5_message(struct SessionHandle *data, const char* user, const char* passwdp, char **outptr, size_t *outlen); + +/* This is used to generate a base64 encoded DIGEST-MD5 response message */ +CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data, + const char* chlg64, + const char* user, + const char* passwdp, + char **outptr, size_t *outlen); #endif #ifdef USE_NTLM -- cgit v1.2.1 From bf51b8c07af9f6eb16c82673c66ce7402c067172 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Mon, 4 Jun 2012 20:22:06 +0100 Subject: sasl: Added service parameter to Curl_sasl_create_digest_md5_message() Added a service type parameter to Curl_sasl_create_digest_md5_message() to allow the function to be used by different services rather than being hard coded to "smtp". --- lib/curl_sasl.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/curl_sasl.h') diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index 892da81ec..97e9bcd75 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -58,6 +58,7 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data, const char* chlg64, const char* user, const char* passwdp, + const char* service, char **outptr, size_t *outlen); #endif -- cgit v1.2.1 From 64510fe917be0508bb4fa381af966ece7dfd4775 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Mon, 4 Jun 2012 22:25:45 +0100 Subject: sasl: Renamed Curl_sasl_decode_ntlm_type2_message() For consistency with other SASL based functions renamed this function to Curl_sasl_create_ntlm_type3_message() which better describes its usage. --- lib/curl_sasl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/curl_sasl.h') diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index 97e9bcd75..314f6c8ab 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -72,7 +72,7 @@ CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp, /* This is used to decode an incoming NTLM type-2 message and generate a base64 encoded type-3 response */ -CURLcode Curl_sasl_decode_ntlm_type2_message(struct SessionHandle *data, +CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data, const char *header, const char *userp, const char *passwdp, -- cgit v1.2.1 From 0cd8c287a46420768a5b11406638316f859a4873 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Fri, 8 Jun 2012 19:52:28 +0100 Subject: sasl: Re-factored mechanism constants in preparation for APOP work --- lib/curl_sasl.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/curl_sasl.h') diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index 314f6c8ab..469c9a1e4 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -25,13 +25,13 @@ #include "pingpong.h" /* Authentication mechanism flags */ -#define SASL_AUTH_LOGIN 0x0001 -#define SASL_AUTH_PLAIN 0x0002 -#define SASL_AUTH_CRAM_MD5 0x0004 -#define SASL_AUTH_DIGEST_MD5 0x0008 -#define SASL_AUTH_GSSAPI 0x0010 -#define SASL_AUTH_EXTERNAL 0x0020 -#define SASL_AUTH_NTLM 0x0040 +#define SASL_MECH_LOGIN 0x0001 +#define SASL_MECH_PLAIN 0x0002 +#define SASL_MECH_CRAM_MD5 0x0004 +#define SASL_MECH_DIGEST_MD5 0x0008 +#define SASL_MECH_GSSAPI 0x0010 +#define SASL_MECH_EXTERNAL 0x0020 +#define SASL_MECH_NTLM 0x0040 /* This is used to generate a base64 encoded PLAIN authentication message */ CURLcode Curl_sasl_create_plain_message(struct SessionHandle *data, -- cgit v1.2.1