Loading lib/Makefile.inc +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ # ########################################################################### LIB_VAUTH_CFILES = vauth/vauth.c LIB_VAUTH_CFILES = vauth/vauth.c vauth/cleartext.c LIB_VAUTH_HFILES = vauth/vauth.h Loading lib/Makefile.vc6 +1 −0 Original line number Diff line number Diff line Loading @@ -621,6 +621,7 @@ X_OBJS= \ $(DIROBJ)\splay.obj \ $(DIROBJ)\ssh.obj \ $(DIROBJ)\vauth.obj \ $(DIROBJ)\cleartext.obj \ $(DIROBJ)\vtls.obj \ $(DIROBJ)\openssl.obj \ $(DIROBJ)\strdup.obj \ Loading lib/curl_sasl.c +0 −113 Original line number Diff line number Diff line Loading @@ -261,119 +261,6 @@ static CURLcode sasl_digest_get_qop_values(const char *options, int *value) } #endif /* !CURL_DISABLE_CRYPTO_AUTH && !USE_WINDOWS_SSPI */ /* * sasl_create_plain_message() * * This is used to generate an already encoded PLAIN message ready * for sending to the recipient. * * Parameters: * * data [in] - The session handle. * userp [in] - The user name. * passdwp [in] - The user's password. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. * outlen [out] - The length of the output message. * * Returns CURLE_OK on success. */ static CURLcode sasl_create_plain_message(struct SessionHandle *data, const char *userp, const char *passwdp, char **outptr, size_t *outlen) { CURLcode result; char *plainauth; size_t ulen; size_t plen; ulen = strlen(userp); plen = strlen(passwdp); plainauth = malloc(2 * ulen + plen + 2); if(!plainauth) { *outlen = 0; *outptr = NULL; return CURLE_OUT_OF_MEMORY; } /* Calculate the reply */ memcpy(plainauth, userp, ulen); plainauth[ulen] = '\0'; memcpy(plainauth + ulen + 1, userp, ulen); plainauth[2 * ulen + 1] = '\0'; memcpy(plainauth + 2 * ulen + 2, passwdp, plen); /* Base64 encode the reply */ result = Curl_base64_encode(data, plainauth, 2 * ulen + plen + 2, outptr, outlen); free(plainauth); return result; } /* * sasl_create_login_message() * * This is used to generate an already encoded LOGIN message containing the * user name or password ready for sending to the recipient. * * Parameters: * * data [in] - The session handle. * valuep [in] - The user name or user's password. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. * outlen [out] - The length of the output message. * * Returns CURLE_OK on success. */ static CURLcode sasl_create_login_message(struct SessionHandle *data, const char *valuep, char **outptr, size_t *outlen) { size_t vlen = strlen(valuep); if(!vlen) { /* Calculate an empty reply */ *outptr = strdup("="); if(*outptr) { *outlen = (size_t) 1; return CURLE_OK; } *outlen = 0; return CURLE_OUT_OF_MEMORY; } /* Base64 encode the value */ return Curl_base64_encode(data, valuep, vlen, outptr, outlen); } /* * sasl_create_external_message() * * This is used to generate an already encoded EXTERNAL message containing * the user name ready for sending to the recipient. * * Parameters: * * data [in] - The session handle. * user [in] - The user name. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. * outlen [out] - The length of the output message. * * Returns CURLE_OK on success. */ static CURLcode sasl_create_external_message(struct SessionHandle *data, const char *user, char **outptr, size_t *outlen) { /* This is the same formatting as the login message. */ return sasl_create_login_message(data, user, outptr, outlen); } #ifndef CURL_DISABLE_CRYPTO_AUTH /* * sasl_decode_cram_md5_message() Loading lib/vauth/cleartext.c 0 → 100644 +157 −0 Original line number Diff line number Diff line /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, 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. * * RFC4616 PLAIN authentication * Draft LOGIN SASL Mechanism <draft-murchison-sasl-login-00.txt> * ***************************************************************************/ #include "curl_setup.h" #include <curl/curl.h> #include "urldata.h" #include "vauth/vauth.h" #include "curl_base64.h" #include "curl_md5.h" #include "warnless.h" #include "strtok.h" #include "strequal.h" #include "rawstr.h" #include "sendf.h" #include "curl_printf.h" /* The last #include files should be: */ #include "curl_memory.h" #include "memdebug.h" /* * sasl_create_plain_message() * * This is used to generate an already encoded PLAIN message ready * for sending to the recipient. * * Parameters: * * data [in] - The session handle. * userp [in] - The user name. * passdwp [in] - The user's password. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. * outlen [out] - The length of the output message. * * Returns CURLE_OK on success. */ CURLcode sasl_create_plain_message(struct SessionHandle *data, const char *userp, const char *passwdp, char **outptr, size_t *outlen) { CURLcode result; char *plainauth; size_t ulen; size_t plen; ulen = strlen(userp); plen = strlen(passwdp); plainauth = malloc(2 * ulen + plen + 2); if(!plainauth) { *outlen = 0; *outptr = NULL; return CURLE_OUT_OF_MEMORY; } /* Calculate the reply */ memcpy(plainauth, userp, ulen); plainauth[ulen] = '\0'; memcpy(plainauth + ulen + 1, userp, ulen); plainauth[2 * ulen + 1] = '\0'; memcpy(plainauth + 2 * ulen + 2, passwdp, plen); /* Base64 encode the reply */ result = Curl_base64_encode(data, plainauth, 2 * ulen + plen + 2, outptr, outlen); free(plainauth); return result; } /* * sasl_create_login_message() * * This is used to generate an already encoded LOGIN message containing the * user name or password ready for sending to the recipient. * * Parameters: * * data [in] - The session handle. * valuep [in] - The user name or user's password. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. * outlen [out] - The length of the output message. * * Returns CURLE_OK on success. */ CURLcode sasl_create_login_message(struct SessionHandle *data, const char *valuep, char **outptr, size_t *outlen) { size_t vlen = strlen(valuep); if(!vlen) { /* Calculate an empty reply */ *outptr = strdup("="); if(*outptr) { *outlen = (size_t) 1; return CURLE_OK; } *outlen = 0; return CURLE_OUT_OF_MEMORY; } /* Base64 encode the value */ return Curl_base64_encode(data, valuep, vlen, outptr, outlen); } /* * sasl_create_external_message() * * This is used to generate an already encoded EXTERNAL message containing * the user name ready for sending to the recipient. * * Parameters: * * data [in] - The session handle. * user [in] - The user name. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. * outlen [out] - The length of the output message. * * Returns CURLE_OK on success. */ CURLcode sasl_create_external_message(struct SessionHandle *data, const char *user, char **outptr, size_t *outlen) { /* This is the same formatting as the login message */ return sasl_create_login_message(data, user, outptr, outlen); } lib/vauth/vauth.h +18 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ #include <curl/curl.h> struct SessionHandle; /* This is used to build a SPN string */ #if !defined(USE_WINDOWS_SSPI) char *Curl_sasl_build_spn(const char *service, const char *instance); Loading @@ -35,4 +37,20 @@ TCHAR *Curl_sasl_build_spn(const char *service, const char *instance); char *Curl_sasl_build_gssapi_spn(const char *service, const char *instance); #endif /* This is used to generate a base64 encoded PLAIN cleartext message */ CURLcode 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 cleartext message */ CURLcode sasl_create_login_message(struct SessionHandle *data, const char *valuep, char **outptr, size_t *outlen); /* This is used to generate a base64 encoded EXTERNAL cleartext message */ CURLcode sasl_create_external_message(struct SessionHandle *data, const char *user, char **outptr, size_t *outlen); #endif /* HEADER_CURL_VAUTH_H */ Loading
lib/Makefile.inc +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ # ########################################################################### LIB_VAUTH_CFILES = vauth/vauth.c LIB_VAUTH_CFILES = vauth/vauth.c vauth/cleartext.c LIB_VAUTH_HFILES = vauth/vauth.h Loading
lib/Makefile.vc6 +1 −0 Original line number Diff line number Diff line Loading @@ -621,6 +621,7 @@ X_OBJS= \ $(DIROBJ)\splay.obj \ $(DIROBJ)\ssh.obj \ $(DIROBJ)\vauth.obj \ $(DIROBJ)\cleartext.obj \ $(DIROBJ)\vtls.obj \ $(DIROBJ)\openssl.obj \ $(DIROBJ)\strdup.obj \ Loading
lib/curl_sasl.c +0 −113 Original line number Diff line number Diff line Loading @@ -261,119 +261,6 @@ static CURLcode sasl_digest_get_qop_values(const char *options, int *value) } #endif /* !CURL_DISABLE_CRYPTO_AUTH && !USE_WINDOWS_SSPI */ /* * sasl_create_plain_message() * * This is used to generate an already encoded PLAIN message ready * for sending to the recipient. * * Parameters: * * data [in] - The session handle. * userp [in] - The user name. * passdwp [in] - The user's password. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. * outlen [out] - The length of the output message. * * Returns CURLE_OK on success. */ static CURLcode sasl_create_plain_message(struct SessionHandle *data, const char *userp, const char *passwdp, char **outptr, size_t *outlen) { CURLcode result; char *plainauth; size_t ulen; size_t plen; ulen = strlen(userp); plen = strlen(passwdp); plainauth = malloc(2 * ulen + plen + 2); if(!plainauth) { *outlen = 0; *outptr = NULL; return CURLE_OUT_OF_MEMORY; } /* Calculate the reply */ memcpy(plainauth, userp, ulen); plainauth[ulen] = '\0'; memcpy(plainauth + ulen + 1, userp, ulen); plainauth[2 * ulen + 1] = '\0'; memcpy(plainauth + 2 * ulen + 2, passwdp, plen); /* Base64 encode the reply */ result = Curl_base64_encode(data, plainauth, 2 * ulen + plen + 2, outptr, outlen); free(plainauth); return result; } /* * sasl_create_login_message() * * This is used to generate an already encoded LOGIN message containing the * user name or password ready for sending to the recipient. * * Parameters: * * data [in] - The session handle. * valuep [in] - The user name or user's password. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. * outlen [out] - The length of the output message. * * Returns CURLE_OK on success. */ static CURLcode sasl_create_login_message(struct SessionHandle *data, const char *valuep, char **outptr, size_t *outlen) { size_t vlen = strlen(valuep); if(!vlen) { /* Calculate an empty reply */ *outptr = strdup("="); if(*outptr) { *outlen = (size_t) 1; return CURLE_OK; } *outlen = 0; return CURLE_OUT_OF_MEMORY; } /* Base64 encode the value */ return Curl_base64_encode(data, valuep, vlen, outptr, outlen); } /* * sasl_create_external_message() * * This is used to generate an already encoded EXTERNAL message containing * the user name ready for sending to the recipient. * * Parameters: * * data [in] - The session handle. * user [in] - The user name. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. * outlen [out] - The length of the output message. * * Returns CURLE_OK on success. */ static CURLcode sasl_create_external_message(struct SessionHandle *data, const char *user, char **outptr, size_t *outlen) { /* This is the same formatting as the login message. */ return sasl_create_login_message(data, user, outptr, outlen); } #ifndef CURL_DISABLE_CRYPTO_AUTH /* * sasl_decode_cram_md5_message() Loading
lib/vauth/cleartext.c 0 → 100644 +157 −0 Original line number Diff line number Diff line /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, 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. * * RFC4616 PLAIN authentication * Draft LOGIN SASL Mechanism <draft-murchison-sasl-login-00.txt> * ***************************************************************************/ #include "curl_setup.h" #include <curl/curl.h> #include "urldata.h" #include "vauth/vauth.h" #include "curl_base64.h" #include "curl_md5.h" #include "warnless.h" #include "strtok.h" #include "strequal.h" #include "rawstr.h" #include "sendf.h" #include "curl_printf.h" /* The last #include files should be: */ #include "curl_memory.h" #include "memdebug.h" /* * sasl_create_plain_message() * * This is used to generate an already encoded PLAIN message ready * for sending to the recipient. * * Parameters: * * data [in] - The session handle. * userp [in] - The user name. * passdwp [in] - The user's password. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. * outlen [out] - The length of the output message. * * Returns CURLE_OK on success. */ CURLcode sasl_create_plain_message(struct SessionHandle *data, const char *userp, const char *passwdp, char **outptr, size_t *outlen) { CURLcode result; char *plainauth; size_t ulen; size_t plen; ulen = strlen(userp); plen = strlen(passwdp); plainauth = malloc(2 * ulen + plen + 2); if(!plainauth) { *outlen = 0; *outptr = NULL; return CURLE_OUT_OF_MEMORY; } /* Calculate the reply */ memcpy(plainauth, userp, ulen); plainauth[ulen] = '\0'; memcpy(plainauth + ulen + 1, userp, ulen); plainauth[2 * ulen + 1] = '\0'; memcpy(plainauth + 2 * ulen + 2, passwdp, plen); /* Base64 encode the reply */ result = Curl_base64_encode(data, plainauth, 2 * ulen + plen + 2, outptr, outlen); free(plainauth); return result; } /* * sasl_create_login_message() * * This is used to generate an already encoded LOGIN message containing the * user name or password ready for sending to the recipient. * * Parameters: * * data [in] - The session handle. * valuep [in] - The user name or user's password. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. * outlen [out] - The length of the output message. * * Returns CURLE_OK on success. */ CURLcode sasl_create_login_message(struct SessionHandle *data, const char *valuep, char **outptr, size_t *outlen) { size_t vlen = strlen(valuep); if(!vlen) { /* Calculate an empty reply */ *outptr = strdup("="); if(*outptr) { *outlen = (size_t) 1; return CURLE_OK; } *outlen = 0; return CURLE_OUT_OF_MEMORY; } /* Base64 encode the value */ return Curl_base64_encode(data, valuep, vlen, outptr, outlen); } /* * sasl_create_external_message() * * This is used to generate an already encoded EXTERNAL message containing * the user name ready for sending to the recipient. * * Parameters: * * data [in] - The session handle. * user [in] - The user name. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. * outlen [out] - The length of the output message. * * Returns CURLE_OK on success. */ CURLcode sasl_create_external_message(struct SessionHandle *data, const char *user, char **outptr, size_t *outlen) { /* This is the same formatting as the login message */ return sasl_create_login_message(data, user, outptr, outlen); }
lib/vauth/vauth.h +18 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ #include <curl/curl.h> struct SessionHandle; /* This is used to build a SPN string */ #if !defined(USE_WINDOWS_SSPI) char *Curl_sasl_build_spn(const char *service, const char *instance); Loading @@ -35,4 +37,20 @@ TCHAR *Curl_sasl_build_spn(const char *service, const char *instance); char *Curl_sasl_build_gssapi_spn(const char *service, const char *instance); #endif /* This is used to generate a base64 encoded PLAIN cleartext message */ CURLcode 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 cleartext message */ CURLcode sasl_create_login_message(struct SessionHandle *data, const char *valuep, char **outptr, size_t *outlen); /* This is used to generate a base64 encoded EXTERNAL cleartext message */ CURLcode sasl_create_external_message(struct SessionHandle *data, const char *user, char **outptr, size_t *outlen); #endif /* HEADER_CURL_VAUTH_H */