summaryrefslogtreecommitdiff
path: root/lib/curl_sasl.h
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-09-24 20:12:48 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-09-24 20:12:50 +0100
commit733a4419d0b519e54e74cc6187580138bfae3db7 (patch)
treef8c54cf32bc258f26ab695b8ab3e400a31b3f471 /lib/curl_sasl.h
parent77dc4ba87793a02d283bd3d2db81d0e60f3fec50 (diff)
downloadcurl-733a4419d0b519e54e74cc6187580138bfae3db7.tar.gz
sasl: Centralised the authentication mechanism strings
Moved the standard SASL mechanism strings into curl_sasl.h rather than hard coding the same values over and over again in the protocols that use SASL authentication. For more information about the mechanism strings see: http://www.iana.org/assignments/sasl-mechanisms
Diffstat (limited to 'lib/curl_sasl.h')
-rw-r--r--lib/curl_sasl.h35
1 files changed, 25 insertions, 10 deletions
diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h
index 1cac8fd63..2b6a5a26a 100644
--- a/lib/curl_sasl.h
+++ b/lib/curl_sasl.h
@@ -24,20 +24,35 @@
#include "pingpong.h"
-/* Authentication mechanism flags */
-#define SASL_MECH_LOGIN (1 << 0)
-#define SASL_MECH_PLAIN (1 << 1)
-#define SASL_MECH_CRAM_MD5 (1 << 2)
-#define SASL_MECH_DIGEST_MD5 (1 << 3)
-#define SASL_MECH_GSSAPI (1 << 4)
-#define SASL_MECH_EXTERNAL (1 << 5)
-#define SASL_MECH_NTLM (1 << 6)
-#define SASL_MECH_XOAUTH2 (1 << 7)
-
/* Authentication mechanism values */
#define SASL_AUTH_NONE 0
#define SASL_AUTH_ANY ~0U
+/* Authentication mechanism flags */
+#define SASL_MECH_LOGIN (1 << 0)
+#define SASL_MECH_PLAIN (1 << 1)
+#define SASL_MECH_CRAM_MD5 (1 << 2)
+#define SASL_MECH_DIGEST_MD5 (1 << 3)
+#define SASL_MECH_GSSAPI (1 << 4)
+#define SASL_MECH_EXTERNAL (1 << 5)
+#define SASL_MECH_NTLM (1 << 6)
+#define SASL_MECH_XOAUTH2 (1 << 7)
+
+/* Authentication mechanism strings */
+#define SASL_MECH_STRING_LOGIN "LOGIN"
+#define SASL_MECH_STRING_PLAIN "PLAIN"
+#define SASL_MECH_STRING_CRAM_MD5 "CRAM-MD5"
+#define SASL_MECH_STRING_DIGEST_MD5 "DIGEST-MD5"
+#define SASL_MECH_STRING_GSSAPI "GSSAPI"
+#define SASL_MECH_STRING_EXTERNAL "EXTERNAL"
+#define SASL_MECH_STRING_NTLM "NTLM"
+#define SASL_MECH_STRING_XOAUTH2 "XOAUTH2"
+
+/* This is used to test whether the line starts with the given mechanism */
+#define sasl_mech_equal(line, wordlen, mech) \
+ (wordlen == (sizeof(mech) - 1) / sizeof(char) && \
+ !memcmp(line, mech, wordlen))
+
/* This is used to generate a base64 encoded PLAIN authentication message */
CURLcode Curl_sasl_create_plain_message(struct SessionHandle *data,
const char *userp,