45 'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
46 'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
47 'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
48 'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
49 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'+',
'/',
63 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
64 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
65 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63,
66 52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1,-1,-1,-1,
67 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,
68 15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1,
69 -1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
70 41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1
92 unsigned char *begin = (
unsigned char *) out;
93 const unsigned char *inu = (
const unsigned char *) in;
95 while ((inlen >= 3) && (outlen > 4))
98 *out++ =
B64Chars[((inu[0] << 4) & 0x30) | (inu[1] >> 4)];
99 *out++ =
B64Chars[((inu[1] << 2) & 0x3c) | (inu[2] >> 6)];
107 if ((inlen > 0) && (outlen > 4))
109 unsigned char fragment;
112 fragment = (inu[0] << 4) & 0x30;
114 fragment |= inu[1] >> 4;
116 *out++ = (inlen < 2) ?
'=' :
B64Chars[(inu[1] << 2) & 0x3c];
120 return out - (
char *) begin;
137 if (!in || !*in || !out)
144 const unsigned char digit1 = in[0];
147 const unsigned char digit2 = in[1];
154 const unsigned char digit3 = in[2] ? in[2] :
'=';
155 if ((digit3 > 127) || ((digit3 !=
'=') && (
base64val(digit3) ==
BAD)))
157 const unsigned char digit4 = (digit3 ==
'=') ?
'=' : in[3];
158 if ((digit4 > 127) || ((digit4 !=
'=') && (
base64val(digit4) ==
BAD)))
size_t mutt_b64_encode(const char *in, size_t inlen, char *out, size_t outlen)
Convert raw bytes to null-terminated base64 string.
size_t mutt_b64_buffer_encode(struct Buffer *buf, const char *in, size_t len)
Convert raw bytes to null-terminated base64 string.
int mutt_b64_decode(const char *in, char *out, size_t olen)
Convert null-terminated base64 string to raw bytes.
const int Index64[128]
Lookup table for Base64 encoding characters.
int mutt_b64_buffer_decode(struct Buffer *buf, const char *in)
Convert null-terminated base64 string to raw bytes.
static const char B64Chars[64]
Characters of the Base64 encoding.
Conversion to/from base64 encoding.
void buf_seek(struct Buffer *buf, size_t offset)
Set current read/write position to offset from beginning.
void buf_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
General purpose object for storing and parsing strings.
Memory management wrappers.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
String manipulation functions.
String manipulation buffer.
size_t dsize
Length of data.
char * data
Pointer to data.