这篇教程C++ Curl_base64_encode函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中Curl_base64_encode函数的典型用法代码示例。如果您正苦于以下问题:C++ Curl_base64_encode函数的具体用法?C++ Curl_base64_encode怎么用?C++ Curl_base64_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了Curl_base64_encode函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: Curl_sasl_create_plain_message/* * Curl_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 Curl_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); Curl_safefree(plainauth); return result;}
开发者ID:08142008,项目名称:curl,代码行数:50,
示例2: Curl_auth_create_spnego_message/* * Curl_auth_create_spnego_message() * * This is used to generate an already encoded SPNEGO (Negotiate) response * message ready for sending to the recipient. * * Parameters: * * data [in] - The session handle. * nego [in/out] - The Negotiate data struct being used and modified. * 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 Curl_auth_create_spnego_message(struct SessionHandle *data, struct negotiatedata *nego, char **outptr, size_t *outlen){ CURLcode result; OM_uint32 minor_status; /* Base64 encode the already generated response */ result = Curl_base64_encode(data, nego->output_token.value, nego->output_token.length, outptr, outlen); if(result) { gss_release_buffer(&minor_status, &nego->output_token); nego->output_token.value = NULL; nego->output_token.length = 0; return result; } if(!*outptr || !*outlen) { gss_release_buffer(&minor_status, &nego->output_token); nego->output_token.value = NULL; nego->output_token.length = 0; return CURLE_REMOTE_ACCESS_DENIED; } return CURLE_OK;}
开发者ID:fzls,项目名称:curl,代码行数:47,
示例3: Curl_sasl_create_plain_message/* * Curl_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 Curl_sasl_create_plain_message(struct SessionHandle *data, const char* userp, const char* passwdp, char **outptr, size_t *outlen){ char plainauth[2 * MAX_CURL_USER_LENGTH + MAX_CURL_PASSWORD_LENGTH]; size_t ulen; size_t plen; ulen = strlen(userp); plen = strlen(passwdp); if(2 * ulen + plen + 2 > sizeof(plainauth)) { *outlen = 0; *outptr = NULL; /* Plainauth too small */ 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 */ return Curl_base64_encode(data, plainauth, 2 * ulen + plen + 2, outptr, outlen);}
开发者ID:2or3,项目名称:PlaygroundOSS,代码行数:48,
示例4: Curl_auth_create_oauth_bearer_message/* * Curl_auth_create_oauth_bearer_message() * * This is used to generate an already encoded OAuth 2.0 message ready for * sending to the recipient. * * Parameters: * * data[in] - The session handle. * user[in] - The user name. * host[in] - The host name(for OAUTHBEARER). * port[in] - The port(for OAUTHBEARER when not Port 80). * bearer[in] - The bearer token. * 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 Curl_auth_create_oauth_bearer_message(struct Curl_easy *data, const char *user, const char *host, const long port, const char *bearer, char **outptr, size_t *outlen){ CURLcode result = CURLE_OK; char *oauth = NULL; /* Generate the message */ if(host == NULL && (port == 0 || port == 80)) oauth = aprintf("user=%s/1auth=Bearer %s/1/1", user, bearer); else if(port == 0 || port == 80) oauth = aprintf("user=%s/1host=%s/1auth=Bearer %s/1/1", user, host, bearer); else oauth = aprintf("user=%s/1host=%s/1port=%ld/1auth=Bearer %s/1/1", user, host, port, bearer); if(!oauth) return CURLE_OUT_OF_MEMORY; /* Base64 encode the reply */ result = Curl_base64_encode(data, oauth, strlen(oauth), outptr, outlen); free(oauth); return result;}
开发者ID:nhinze,项目名称:rhodes,代码行数:48,
示例5: Curl_output_negotiateCURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy){ struct negotiatedata *neg_ctx = proxy?&conn->data->state.proxyneg: &conn->data->state.negotiate; char *encoded = NULL; size_t len = 0; char *userp; CURLcode error; error = Curl_base64_encode(conn->data, (const char*)neg_ctx->output_token, neg_ctx->output_token_length, &encoded, &len); if(error) return error; if(len == 0) return CURLE_REMOTE_ACCESS_DENIED; userp = aprintf("%sAuthorization: %s %s/r/n", proxy ? "Proxy-" : "", neg_ctx->protocol, encoded); if(proxy) conn->allocptr.proxyuserpwd = userp; else conn->allocptr.userpwd = userp; free(encoded); Curl_cleanup_negotiate (conn->data); return (userp == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK;}
开发者ID:Napoleon314,项目名称:Venus2D,代码行数:30,
示例6: Curl_output_negotiateCURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy){ struct negotiatedata *neg_ctx = proxy?&conn->data->state.proxyneg: &conn->data->state.negotiate; char *encoded = NULL; int len;#ifdef HAVE_SPNEGO /* Handle SPNEGO */ if(checkprefix("Negotiate", neg_ctx->protocol)) { ASN1_OBJECT * object = NULL; int rc = 1; unsigned char * spnegoToken = NULL; size_t spnegoTokenLength = 0; unsigned char * responseToken = NULL; size_t responseTokenLength = 0; responseToken = malloc(neg_ctx->output_token.length); if( responseToken == NULL) return CURLE_OUT_OF_MEMORY; memcpy(responseToken, neg_ctx->output_token.value, neg_ctx->output_token.length); responseTokenLength = neg_ctx->output_token.length; object=OBJ_txt2obj ("1.2.840.113554.1.2.2", 1); if(!makeSpnegoInitialToken (object, responseToken, responseTokenLength, &spnegoToken, &spnegoTokenLength)) { free(responseToken); responseToken = NULL; infof(conn->data, "Make SPNEGO Initial Token failed/n"); } else { free(neg_ctx->output_token.value); responseToken = NULL; neg_ctx->output_token.value = malloc(spnegoTokenLength); memcpy(neg_ctx->output_token.value, spnegoToken,spnegoTokenLength); neg_ctx->output_token.length = spnegoTokenLength; free(spnegoToken); spnegoToken = NULL; infof(conn->data, "Make SPNEGO Initial Token succeeded/n"); } }#endif len = Curl_base64_encode(conn->data, neg_ctx->output_token.value, neg_ctx->output_token.length, &encoded); if(len == 0) return CURLE_OUT_OF_MEMORY; conn->allocptr.userpwd = aprintf("%sAuthorization: %s %s/r/n", proxy ? "Proxy-" : "", neg_ctx->protocol, encoded); free(encoded); Curl_cleanup_negotiate (conn->data); return (conn->allocptr.userpwd == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK;}
开发者ID:RayPlante,项目名称:usvirtualobservatory,代码行数:60,
示例7: Curl_sasl_create_ntlm_type3_message/** Curl_sasl_create_ntlm_type3_message()** This is used to generate an already encoded NTLM type-3 message ready for* sending to the recipient.** Parameters:** data [in] - The session handle.* userp [in] - The user name in the format User or Domain/User.* passdwp [in] - The user's password.* ntlm [in/out] - The ntlm data struct being used and modified.* 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 Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data, const char *userp, const char *passwdp, struct ntlmdata *ntlm, char **outptr, size_t *outlen){ CURLcode result = CURLE_OK; SecBuffer type_2_buf; SecBuffer type_3_buf; SecBufferDesc type_2_desc; SecBufferDesc type_3_desc; SECURITY_STATUS status; unsigned long attrs; TimeStamp expiry; /* For Windows 9x compatibility of SSPI calls */ (void) passwdp; (void) userp; /* Setup the type-2 "input" security buffer */ type_2_desc.ulVersion = SECBUFFER_VERSION; type_2_desc.cBuffers = 1; type_2_desc.pBuffers = &type_2_buf; type_2_buf.BufferType = SECBUFFER_TOKEN; type_2_buf.pvBuffer = ntlm->input_token; type_2_buf.cbBuffer = curlx_uztoul(ntlm->input_token_len); /* Setup the type-3 "output" security buffer */ type_3_desc.ulVersion = SECBUFFER_VERSION; type_3_desc.cBuffers = 1; type_3_desc.pBuffers = &type_3_buf; type_3_buf.BufferType = SECBUFFER_TOKEN; type_3_buf.pvBuffer = ntlm->output_token; type_3_buf.cbBuffer = curlx_uztoul(ntlm->token_max); /* Generate our type-3 message */ status = s_pSecFn->InitializeSecurityContext(ntlm->credentials, ntlm->context, (TCHAR *) TEXT(""), 0, 0, SECURITY_NETWORK_DREP, &type_2_desc, 0, ntlm->context, &type_3_desc, &attrs, &expiry); if(status != SEC_E_OK) { infof(data, "NTLM handshake failure (type-3 message): Status=%x/n", status); return CURLE_RECV_ERROR; } /* Base64 encode the response */ result = Curl_base64_encode(data, (char *) ntlm->output_token, type_3_buf.cbBuffer, outptr, outlen); Curl_sasl_ntlm_cleanup(ntlm); return result;}
开发者ID:AndyUI,项目名称:curl,代码行数:76,
示例8: do_sec_send/* FIXME: We don't check for errors nor report any! */static void do_sec_send(struct connectdata *conn, curl_socket_t fd, const char *from, int length){ int bytes, htonl_bytes; /* 32-bit integers for htonl */ char *buffer = NULL; char *cmd_buffer; size_t cmd_size = 0; CURLcode error; enum protection_level prot_level = conn->data_prot; bool iscmd = (prot_level == PROT_CMD)?TRUE:FALSE; DEBUGASSERT(prot_level > PROT_NONE && prot_level < PROT_LAST); if(iscmd) { if(!strncmp(from, "PASS ", 5) || !strncmp(from, "ACCT ", 5)) prot_level = PROT_PRIVATE; else prot_level = conn->command_prot; } bytes = conn->mech->encode(conn->app_data, from, length, prot_level, (void **)&buffer); if(!buffer || bytes <= 0) return; /* error */ if(iscmd) { error = Curl_base64_encode(conn->data, buffer, curlx_sitouz(bytes), &cmd_buffer, &cmd_size); if(error) { free(buffer); return; /* error */ } if(cmd_size > 0) { static const char *enc = "ENC "; static const char *mic = "MIC "; if(prot_level == PROT_PRIVATE) socket_write(conn, fd, enc, 4); else socket_write(conn, fd, mic, 4); socket_write(conn, fd, cmd_buffer, cmd_size); socket_write(conn, fd, "/r/n", 2); infof(conn->data, "Send: %s%s/n", prot_level == PROT_PRIVATE?enc:mic, cmd_buffer); free(cmd_buffer); } } else { htonl_bytes = htonl(bytes); socket_write(conn, fd, &htonl_bytes, sizeof(htonl_bytes)); socket_write(conn, fd, buffer, curlx_sitouz(bytes)); } free(buffer);}
开发者ID:Andersbakken,项目名称:curl,代码行数:54,
示例9: smtp_auth_login_userstatic size_t smtp_auth_login_user(struct connectdata * conn, char * * outptr){ size_t ulen; ulen = strlen(conn->user); if(!ulen) { *outptr = strdup("="); return *outptr? 1: 0; } return Curl_base64_encode(conn->data, conn->user, ulen, outptr);}
开发者ID:wnpllrzodiac,项目名称:transmission,代码行数:13,
示例10: Curl_sasl_create_cram_md5_message/* * Curl_sasl_create_cram_md5_message() * * This is used to generate an already encoded CRAM-MD5 response message ready * for sending to the recipient. * * Parameters: * * data [in] - The session handle. * chlg64 [in] - Pointer to the base64 encoded challenge buffer. * 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 Curl_sasl_create_cram_md5_message(struct SessionHandle *data, const char* chlg64, const char* userp, const char* passwdp, char **outptr, size_t *outlen){ CURLcode result = CURLE_OK; size_t chlg64len = strlen(chlg64); unsigned char *chlg = (unsigned char *) NULL; size_t chlglen = 0; HMAC_context *ctxt; unsigned char digest[MD5_DIGEST_LEN]; char response[MAX_CURL_USER_LENGTH + 2 * MD5_DIGEST_LEN + 1]; /* Decode the challenge if necessary */ if(chlg64len && *chlg64 != '=') { result = Curl_base64_decode(chlg64, &chlg, &chlglen); if(result) return result; } /* Compute the digest using the password as the key */ ctxt = Curl_HMAC_init(Curl_HMAC_MD5, (const unsigned char *) passwdp, curlx_uztoui(strlen(passwdp))); if(!ctxt) { Curl_safefree(chlg); return CURLE_OUT_OF_MEMORY; } /* Update the digest with the given challenge */ if(chlglen > 0) Curl_HMAC_update(ctxt, chlg, curlx_uztoui(chlglen)); Curl_safefree(chlg); /* Finalise the digest */ Curl_HMAC_final(ctxt, digest); /* Prepare the response */ snprintf(response, sizeof(response), "%s %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", userp, digest[0], digest[1], digest[2], digest[3], digest[4], digest[5], digest[6], digest[7], digest[8], digest[9], digest[10], digest[11], digest[12], digest[13], digest[14], digest[15]); /* Base64 encode the reply */ return Curl_base64_encode(data, response, 0, outptr, outlen);}
开发者ID:2or3,项目名称:PlaygroundOSS,代码行数:69,
示例11: smtp_auth_login_userstatic CURLcode smtp_auth_login_user(struct connectdata *conn, char **outptr, size_t *outlen){ size_t ulen = strlen(conn->user); if(!ulen) { *outptr = strdup("="); if(*outptr) { *outlen = (size_t) 1; return CURLE_OK; } *outlen = 0; return CURLE_OUT_OF_MEMORY; } return Curl_base64_encode(conn->data, conn->user, ulen, outptr, outlen);}
开发者ID:bhalder,项目名称:Optimized-Webserver,代码行数:17,
示例12: sasl_create_cram_md5_message/* * sasl_create_cram_md5_message() * * This is used to generate an already encoded CRAM-MD5 response message ready * for sending to the recipient. * * Parameters: * * data [in] - The session handle. * chlg [in] - The challenge. * 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_cram_md5_message(struct SessionHandle *data, const char *chlg, const char *userp, const char *passwdp, char **outptr, size_t *outlen){ CURLcode result = CURLE_OK; size_t chlglen = 0; HMAC_context *ctxt; unsigned char digest[MD5_DIGEST_LEN]; char *response; if(chlg) chlglen = strlen(chlg); /* Compute the digest using the password as the key */ ctxt = Curl_HMAC_init(Curl_HMAC_MD5, (const unsigned char *) passwdp, curlx_uztoui(strlen(passwdp))); if(!ctxt) return CURLE_OUT_OF_MEMORY; /* Update the digest with the given challenge */ if(chlglen > 0) Curl_HMAC_update(ctxt, (const unsigned char *) chlg, curlx_uztoui(chlglen)); /* Finalise the digest */ Curl_HMAC_final(ctxt, digest); /* Generate the response */ response = aprintf( "%s %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", userp, digest[0], digest[1], digest[2], digest[3], digest[4], digest[5], digest[6], digest[7], digest[8], digest[9], digest[10], digest[11], digest[12], digest[13], digest[14], digest[15]); if(!response) return CURLE_OUT_OF_MEMORY; /* Base64 encode the response */ result = Curl_base64_encode(data, response, 0, outptr, outlen); free(response); return result;}
开发者ID:dustymabe,项目名称:curl,代码行数:64,
示例13: Curl_http2_request/* * Append headers to ask for a HTTP1.1 to HTTP2 upgrade. */CURLcode Curl_http2_request(Curl_send_buffer *req, struct connectdata *conn){ uint8_t binsettings[80]; CURLcode result; ssize_t binlen; char *base64; size_t blen; if(!conn->proto.httpc.h2) { /* The nghttp2 session is not yet setup, do it */ int rc = nghttp2_session_client_new(&conn->proto.httpc.h2, &callbacks, &conn); if(rc) { failf(conn->data, "Couldn't initialize nghttp2!"); return CURLE_OUT_OF_MEMORY; /* most likely at least */ } } /* As long as we have a fixed set of settings, we don't have to dynamically * figure out the base64 strings since it'll always be the same. However, * the settings will likely not be fixed every time in the future. */ /* this returns number of bytes it wrote */ binlen = nghttp2_pack_settings_payload(binsettings, settings, sizeof(settings)/sizeof(settings[0])); if(!binlen) { failf(conn->data, "nghttp2 unexpectedly failed on pack_settings_payload"); return CURLE_FAILED_INIT; } result = Curl_base64_encode(conn->data, (const char *)binsettings, binlen, &base64, &blen); if(result) return result; result = Curl_add_bufferf(req, "Connection: Upgrade, HTTP2-Settings/r/n" "Upgrade: HTTP/2.0/r/n" "HTTP2-Settings: %s/r/n", base64); free(base64); return result;}
开发者ID:zhanghama,项目名称:curl,代码行数:48,
示例14: Curl_auth_create_plain_message/* * Curl_auth_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 Curl_auth_create_plain_message(struct Curl_easy *data, const char *userp, const char *passwdp, char **outptr, size_t *outlen){ CURLcode result; char *plainauth; size_t ulen; size_t plen; size_t plainlen; *outlen = 0; *outptr = NULL; ulen = strlen(userp); plen = strlen(passwdp); /* Compute binary message length, checking for overflows. */ plainlen = 2 * ulen; if(plainlen < ulen) return CURLE_OUT_OF_MEMORY; plainlen += plen; if(plainlen < plen) return CURLE_OUT_OF_MEMORY; plainlen += 2; if(plainlen < 2) return CURLE_OUT_OF_MEMORY; plainauth = malloc(plainlen); if(!plainauth) 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, plainlen, outptr, outlen); free(plainauth); return result;}
开发者ID:Andersbakken,项目名称:curl,代码行数:61,
示例15: smtp_auth_plain_datastatic size_t smtp_auth_plain_data(struct connectdata * conn, char * * outptr){ char plainauth[2 * MAX_CURL_USER_LENGTH + MAX_CURL_PASSWORD_LENGTH]; size_t ulen; size_t plen; ulen = strlen(conn->user); plen = strlen(conn->passwd); if(2 * ulen + plen + 2 > sizeof plainauth) return 0; memcpy(plainauth, conn->user, ulen); plainauth[ulen] = '/0'; memcpy(plainauth + ulen + 1, conn->user, ulen); plainauth[2 * ulen + 1] = '/0'; memcpy(plainauth + 2 * ulen + 2, conn->passwd, plen); return Curl_base64_encode(conn->data, plainauth, 2 * ulen + plen + 2, outptr);}
开发者ID:wnpllrzodiac,项目名称:transmission,代码行数:19,
示例16: Curl_http2_request_upgrade/* * Append headers to ask for a HTTP1.1 to HTTP2 upgrade. */CURLcode Curl_http2_request_upgrade(Curl_send_buffer *req, struct connectdata *conn){ CURLcode result; ssize_t binlen; char *base64; size_t blen; struct SingleRequest *k = &conn->data->req; uint8_t *binsettings = conn->proto.httpc.binsettings; Curl_http2_init(conn); /* As long as we have a fixed set of settings, we don't have to dynamically * figure out the base64 strings since it'll always be the same. However, * the settings will likely not be fixed every time in the future. */ /* this returns number of bytes it wrote */ binlen = nghttp2_pack_settings_payload(binsettings, H2_BINSETTINGS_LEN, settings, sizeof(settings)/sizeof(settings[0])); if(!binlen) { failf(conn->data, "nghttp2 unexpectedly failed on pack_settings_payload"); return CURLE_FAILED_INIT; } conn->proto.httpc.binlen = binlen; result = Curl_base64_encode(conn->data, (const char *)binsettings, binlen, &base64, &blen); if(result) return result; result = Curl_add_bufferf(req, "Connection: Upgrade, HTTP2-Settings/r/n" "Upgrade: %s/r/n" "HTTP2-Settings: %s/r/n", NGHTTP2_PROTO_VERSION_ID, base64); free(base64); k->upgr101 = UPGR101_REQUESTED; return result;}
开发者ID:Angelcold,项目名称:curl,代码行数:46,
示例17: Curl_output_negotiateCURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy){ struct negotiatedata *neg_ctx = proxy?&conn->data->state.proxyneg: &conn->data->state.negotiate; char *encoded = NULL; size_t len = 0; char *userp; CURLcode result; OM_uint32 discard_st; result = Curl_base64_encode(conn->data, neg_ctx->output_token.value, neg_ctx->output_token.length, &encoded, &len); if(result) { gss_release_buffer(&discard_st, &neg_ctx->output_token); neg_ctx->output_token.value = NULL; neg_ctx->output_token.length = 0; return result; } if(!encoded || !len) { gss_release_buffer(&discard_st, &neg_ctx->output_token); neg_ctx->output_token.value = NULL; neg_ctx->output_token.length = 0; return CURLE_REMOTE_ACCESS_DENIED; } userp = aprintf("%sAuthorization: Negotiate %s/r/n", proxy ? "Proxy-" : "", encoded); if(proxy) { Curl_safefree(conn->allocptr.proxyuserpwd); conn->allocptr.proxyuserpwd = userp; } else { Curl_safefree(conn->allocptr.userpwd); conn->allocptr.userpwd = userp; } free(encoded); return (userp == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK;}
开发者ID:AVGirl,项目名称:wingup,代码行数:43,
示例18: Curl_auth_create_spnego_message/* * Curl_auth_create_spnego_message() * * This is used to generate an already encoded SPNEGO (Negotiate) response * message ready for sending to the recipient. * * Parameters: * * data [in] - The session handle. * nego [in/out] - The Negotiate data struct being used and modified. * 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 Curl_auth_create_spnego_message(struct Curl_easy *data, struct negotiatedata *nego, char **outptr, size_t *outlen){ CURLcode result; /* Base64 encode the already generated response */ result = Curl_base64_encode(data, (const char*) nego->output_token, nego->output_token_length, outptr, outlen); if(result) return result; if(!*outptr || !*outlen) return CURLE_REMOTE_ACCESS_DENIED; return CURLE_OK;}
开发者ID:2px,项目名称:curl,代码行数:36,
示例19: Curl_sasl_create_xoauth2_message/* * Curl_sasl_create_xoauth2_message() * * This is used to generate an already encoded OAuth 2.0 message ready for * sending to the recipient. * * Parameters: * * data [in] - The session handle. * user [in] - The user name. * bearer [in] - The bearer token. * 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 Curl_sasl_create_xoauth2_message(struct SessionHandle *data, const char *user, const char *bearer, char **outptr, size_t *outlen){ CURLcode result = CURLE_OK; char *xoauth = NULL; /* Generate the message */ xoauth = aprintf("user=%s/1auth=Bearer %s/1/1", user, bearer); if(!xoauth) return CURLE_OUT_OF_MEMORY; /* Base64 encode the reply */ result = Curl_base64_encode(data, xoauth, strlen(xoauth), outptr, outlen); Curl_safefree(xoauth); return result;}
开发者ID:08142008,项目名称:curl,代码行数:37,
示例20: Curl_sasl_create_login_message/* * Curl_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 Curl_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);}
开发者ID:08142008,项目名称:curl,代码行数:37,
示例21: smtp_state_authpasswd_resp/* for responses to user entry of AUTH LOGIN. */static CURLcode smtp_state_authpasswd_resp(struct connectdata *conn, int smtpcode, smtpstate instate){ CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; size_t plen; size_t l; char *authpasswd; (void)instate; /* no use for this yet */ if(smtpcode != 334) { failf(data, "Access denied: %d", smtpcode); result = CURLE_LOGIN_DENIED; } else { plen = strlen(conn->passwd); if(!plen) result = Curl_pp_sendf(&conn->proto.smtpc.pp, "="); else { l = Curl_base64_encode(data, conn->passwd, plen, &authpasswd); if(!l) result = CURLE_OUT_OF_MEMORY; else { result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", authpasswd); free(authpasswd); if(!result) state(conn, SMTP_AUTH); } } } return result;}
开发者ID:wnpllrzodiac,项目名称:transmission,代码行数:39,
示例22: smtp_auth_plain_datastatic CURLcode smtp_auth_plain_data(struct connectdata *conn, char **outptr, size_t *outlen){ char plainauth[2 * MAX_CURL_USER_LENGTH + MAX_CURL_PASSWORD_LENGTH]; size_t ulen; size_t plen; ulen = strlen(conn->user); plen = strlen(conn->passwd); if(2 * ulen + plen + 2 > sizeof plainauth) { *outlen = 0; *outptr = NULL; return CURLE_OUT_OF_MEMORY; /* plainauth too small */ } memcpy(plainauth, conn->user, ulen); plainauth[ulen] = '/0'; memcpy(plainauth + ulen + 1, conn->user, ulen); plainauth[2 * ulen + 1] = '/0'; memcpy(plainauth + 2 * ulen + 2, conn->passwd, plen); return Curl_base64_encode(conn->data, plainauth, 2 * ulen + plen + 2, outptr, outlen);}
开发者ID:bhalder,项目名称:Optimized-Webserver,代码行数:24,
示例23: Curl_output_digestCURLcode Curl_output_digest(struct connectdata *conn, bool proxy, const unsigned char *request, const unsigned char *uripath){ /* We have a Digest setup for this, use it! Now, to get all the details for this sorted out, I must urge you dear friend to read up on the RFC2617 section 3.2.2, */ unsigned char md5buf[16]; /* 16 bytes/128 bits */ unsigned char request_digest[33]; unsigned char *md5this; unsigned char *ha1; unsigned char ha2[33];/* 32 digits and 1 zero byte */ char cnoncebuf[7]; char *cnonce; char *tmp = NULL; struct timeval now; char **allocuserpwd; const char *userp; const char *passwdp; struct auth *authp; struct SessionHandle *data = conn->data; struct digestdata *d;#ifdef CURL_DOES_CONVERSIONS CURLcode rc;/* The CURL_OUTPUT_DIGEST_CONV macro below is for non-ASCII machines. It converts digest text to ASCII so the MD5 will be correct for what ultimately goes over the network.*/#define CURL_OUTPUT_DIGEST_CONV(a, b) / rc = Curl_convert_to_network(a, (char *)b, strlen((const char*)b)); / if(rc != CURLE_OK) { / free(b); / return rc; / }#else#define CURL_OUTPUT_DIGEST_CONV(a, b)#endif /* CURL_DOES_CONVERSIONS */ if(proxy) { d = &data->state.proxydigest; allocuserpwd = &conn->allocptr.proxyuserpwd; userp = conn->proxyuser; passwdp = conn->proxypasswd; authp = &data->state.authproxy; } else { d = &data->state.digest; allocuserpwd = &conn->allocptr.userpwd; userp = conn->user; passwdp = conn->passwd; authp = &data->state.authhost; } if(*allocuserpwd) { Curl_safefree(*allocuserpwd); *allocuserpwd = NULL; } /* not set means empty */ if(!userp) userp=""; if(!passwdp) passwdp=""; if(!d->nonce) { authp->done = FALSE; return CURLE_OK; } authp->done = TRUE; if(!d->nc) d->nc = 1; if(!d->cnonce) { /* Generate a cnonce */ now = Curl_tvnow(); snprintf(cnoncebuf, sizeof(cnoncebuf), "%06ld", (long)now.tv_sec); if(Curl_base64_encode(data, cnoncebuf, strlen(cnoncebuf), &cnonce)) d->cnonce = cnonce; else return CURLE_OUT_OF_MEMORY; } /* if the algorithm is "MD5" or unspecified (which then defaults to MD5): A1 = unq(username-value) ":" unq(realm-value) ":" passwd if the algorithm is "MD5-sess" then: A1 = H( unq(username-value) ":" unq(realm-value) ":" passwd ) ":" unq(nonce-value) ":" unq(cnonce-value) */ md5this = (unsigned char *) aprintf("%s:%s:%s", userp, d->realm, passwdp);//.........这里部分代码省略.........
开发者ID:WiseMan787,项目名称:ralink_sdk,代码行数:101,
示例24: krb5_authstatic intkrb5_auth(void *app_data, struct connectdata *conn){ int ret; char *p; const char *host = conn->dns_entry->addr->ai_canonname; ssize_t nread; curl_socklen_t l = sizeof(conn->local_addr); struct SessionHandle *data = conn->data; CURLcode result; const char *service = "ftp", *srv_host = "host"; gss_buffer_desc gssbuf, _gssresp, *gssresp; OM_uint32 maj, min; gss_name_t gssname; gss_ctx_id_t *context = app_data; struct gss_channel_bindings_struct chan; if(getsockname(conn->sock[FIRSTSOCKET], (struct sockaddr *)LOCAL_ADDR, &l) < 0) perror("getsockname()"); chan.initiator_addrtype = GSS_C_AF_INET; chan.initiator_address.length = l - 4; chan.initiator_address.value = &((struct sockaddr_in *)LOCAL_ADDR)->sin_addr.s_addr; chan.acceptor_addrtype = GSS_C_AF_INET; chan.acceptor_address.length = l - 4; chan.acceptor_address.value = &((struct sockaddr_in *)REMOTE_ADDR)->sin_addr.s_addr; chan.application_data.length = 0; chan.application_data.value = NULL; /* this loop will execute twice (once for service, once for host) */ while(1) { /* this really shouldn't be repeated here, but can't help it */ if(service == srv_host) { result = Curl_ftpsendf(conn, "AUTH GSSAPI"); if(result) return -2; if(Curl_GetFTPResponse(&nread, conn, NULL)) return -1; if(data->state.buffer[0] != '3') return -1; } gssbuf.value = data->state.buffer; gssbuf.length = snprintf(gssbuf.value, BUFSIZE, "%[email C++ Curl_client_write函数代码示例 C++ Curl_base64_decode函数代码示例
|