3 static int decode64tab_init
=0;
4 static char decode64tab
[256];
7 ** Copyright 1998 - 1999 Double Precision, Inc.
8 ** See COPYING for distribution information.
11 int authsasl_frombase64(char *base64buf
)
15 if (!decode64tab_init
)
17 for (i
=0; i
<256; i
++) decode64tab
[i
]=100;
20 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[i
]) ]=i
;
24 for (j
=0; base64buf
[j
]; j
++)
25 if (decode64tab
[(unsigned char)base64buf
[j
]] >= 100)
28 if (base64buf
[j
] && base64buf
[j
+1] && base64buf
[j
+2])
30 while (base64buf
[j
] == '=') ++j
;
31 if (j
% 4) return (-1);
35 for (j
=0; j
<i
; j
+= 4)
37 int w
=decode64tab
[(int)(unsigned char)base64buf
[j
]];
38 int x
=decode64tab
[(int)(unsigned char)base64buf
[j
+1]];
39 int y
=decode64tab
[(int)(unsigned char)base64buf
[j
+2]];
40 int z
=decode64tab
[(int)(unsigned char)base64buf
[j
+3]];
43 a
= (w
<< 2) | (x
>> 4);
44 b
= (x
<< 4) | (y
>> 2);
47 if ( base64buf
[j
+2] != '=')
49 if ( base64buf
[j
+3] != '=')