~ubuntu-branches/ubuntu/raring/openvpn/raring-proposed

« back to all changes in this revision

Viewing changes to proxy.c

  • Committer: Bazaar Package Importer
  • Author(s): Alberto Gonzalez Iniesta
  • Date: 2006-04-05 12:17:26 UTC
  • mto: (1.3.3 upstream) (10.1.1 lenny)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20060405121726-btck979dumiwfrte
Tags: upstream-2.0.6
ImportĀ upstreamĀ versionĀ 2.0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include "socket.h"
39
39
#include "fdmisc.h"
40
40
#include "proxy.h"
 
41
#include "base64.h"
41
42
#include "ntlm.h"
42
43
 
43
44
#include "memdbg.h"
192
193
uint8_t *
193
194
make_base64_string2 (const uint8_t *str, int src_len, struct gc_arena *gc)
194
195
{
195
 
  static const char base64_table[] =
196
 
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
197
 
 
198
 
  uint8_t *buf;
199
 
  const uint8_t *src;
200
 
  uint8_t *dst;
201
 
  int bits, data, dst_len;
202
 
 
203
 
  /* make base64 string */
204
 
  dst_len = (src_len + 2) / 3 * 4;
205
 
  buf = gc_malloc (dst_len + 1, false, gc);
206
 
  bits = data = 0;
207
 
  src = str;
208
 
  dst = buf;
209
 
  while (dst_len--)
210
 
    {
211
 
      if (bits < 6)
212
 
        {
213
 
          data = (data << 8) | *src;
214
 
          bits += 8;
215
 
          src++;
216
 
        }
217
 
      *dst++ = base64_table[0x3F & (data >> (bits - 6))];
218
 
      bits -= 6;
219
 
    }
220
 
  *dst = '\0';
221
 
 
222
 
  /* fix-up tail padding */
223
 
  switch (src_len % 3)
224
 
    {
225
 
    case 1:
226
 
      *--dst = '=';
227
 
    case 2:
228
 
      *--dst = '=';
229
 
    }
230
 
  return buf;
 
196
  uint8_t *ret = NULL;
 
197
  char *b64out = NULL;
 
198
  ASSERT (base64_encode ((const void *)str, src_len, &b64out) >= 0);
 
199
  ret = (uint8_t *) string_alloc (b64out, gc);
 
200
  free (b64out);
 
201
  return ret;
231
202
}
232
203
 
233
204
uint8_t *