mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-13 17:17:37 -05:00
Support username and password authentication when talking to HTTP
proxies. [originally from svn r1971]
This commit is contained in:
29
misc.c
29
misc.c
@ -50,6 +50,35 @@ char *dupcat(char *s1, ...)
|
||||
return p;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Base64 encoding routine. This is required in public-key writing
|
||||
* but also in HTTP proxy handling, so it's centralised here.
|
||||
*/
|
||||
|
||||
void base64_encode_atom(unsigned char *data, int n, char *out)
|
||||
{
|
||||
static const char base64_chars[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
unsigned word;
|
||||
|
||||
word = data[0] << 16;
|
||||
if (n > 1)
|
||||
word |= data[1] << 8;
|
||||
if (n > 2)
|
||||
word |= data[2];
|
||||
out[0] = base64_chars[(word >> 18) & 0x3F];
|
||||
out[1] = base64_chars[(word >> 12) & 0x3F];
|
||||
if (n > 1)
|
||||
out[2] = base64_chars[(word >> 6) & 0x3F];
|
||||
else
|
||||
out[2] = '=';
|
||||
if (n > 2)
|
||||
out[3] = base64_chars[word & 0x3F];
|
||||
else
|
||||
out[3] = '=';
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Generic routines to deal with send buffers: a linked list of
|
||||
* smallish blocks, with the operations
|
||||
|
Reference in New Issue
Block a user