Samba's base64 encoder/decoder
kai at samba.org
Thu Apr 8 00:24:14 MDT 2010
On Thursday 08 April 2010 04:11:34 Mohan Narayanaswamy wrote:
> My application uses libb64 (http://libb64.sourceforge.net/ ) and I am
> facing a problem while sending "KK base64 encoded Type1 SPNEGO blob".
Ah, yet another base64 codec. Nice.
> Libb64 breaks ( inserts "\n" ) the output line after every 76 characters
> and expects the decoder to ignore the "\n". ( most base64 encoders
> claims that this is a standard)
In 2005, I've looked around a bit at existing base64 codecs and found that
they all had slightly different notions of how to encode/decode base64.
However, rfc3548 states that unhandled characters "Implementations MUST reject
the encoding if it contains characters outside the base alphabet when
interpreting base encoded data". It does go on that implementations can chose
to ignore unknown characters like newlines if they state so in their spec.
> But samba's base64 decoder does not seem to ignore the "\n".
Apart from this being fully RFC-compliant, I guess what really messes you up
is the fact that ntlm_auth uses a line-based protocol, as Andrew Bartlett
> Should I use only samba's encode/decode when I play with ntlm_auth ?
As Andrew said, fixing up the newlines should be sufficient. You can of course
also use other base64 codecs that don't add newlines, such as the python
base64 codec or the one used in Wine dlls/secur32/base64_codec.c
I guess this all depends on your use case.
WorldForge developer http://www.worldforge.org/
Wine developer http://wiki.winehq.org/KaiBlin
Samba team member http://www.samba.org/samba/team/
Will code for cotton.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: This is a digitally signed message part.
More information about the samba-technical