aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2005-05-20 08:51:45 +0000
committerRoger Dingledine <arma@torproject.org>2005-05-20 08:51:45 +0000
commitf0e309e5bdb9227ed73a59e983da83771c062941 (patch)
tree8b34cccb7501e269d254901af3f8c30cc891c018 /src/or/connection.c
parent918c5a9115c1e39e8ef28e6241cfcd7bdaf5374b (diff)
downloadtor-f0e309e5bdb9227ed73a59e983da83771c062941.tar
tor-f0e309e5bdb9227ed73a59e983da83771c062941.tar.gz
add HttpProxyAuthenticator config option too
svn:r4272
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 1b14670a0..7ecff7ba1 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -1559,6 +1559,28 @@ int connection_send_destroy(uint16_t circ_id, connection_t *conn) {
return 0;
}
+/** Alloocates a base64'ed authenticator for use in http or https
+ * auth, based on the input string <b>authenticator</b>. Returns it
+ * if success, else returns NULL. */
+char *
+alloc_http_authenticator(const char *authenticator) {
+ /* an authenticator in Basic authentication
+ * is just the string "username:password" */
+ const int authenticator_length = strlen(authenticator);
+ /* The base64_encode function needs a minimum buffer length
+ * of 66 bytes. */
+ const int base64_authenticator_length = (authenticator_length/48+1)*66;
+ char *base64_authenticator = tor_malloc(base64_authenticator_length);
+ if (base64_encode(base64_authenticator, base64_authenticator_length,
+ authenticator, authenticator_length) < 0) {
+ tor_free(base64_authenticator); /* free and set to null */
+ } else {
+ /* remove extra \n at end of encoding */
+ base64_authenticator[strlen(base64_authenticator) - 1] = 0;
+ }
+ return base64_authenticator;
+}
+
/** Process new bytes that have arrived on conn-\>inbuf.
*
* This function just passes conn to the connection-specific