Samba's base64 encoder/decoder

Mohan Narayanaswamy mohann at silver-peak.com
Fri Apr 9 13:48:35 MDT 2010


Hi Kai and Andrew ,

Thanks for the help.
Wine's base64 codec works for me.

Regards,
Mohan
-----Original Message-----
From: Kai Blin [mailto:kai at samba.org] 
Sent: Wednesday, April 07, 2010 11:24 PM
To: samba-technical at lists.samba.org
Cc: Mohan Narayanaswamy
Subject: Re: Samba's base64 encoder/decoder

On Thursday 08 April 2010 04:11:34 Mohan Narayanaswamy wrote:

Hi Mohan,

> 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 already mentioned.

> 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.
Cheers,
Kai

--
Kai Blin
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.



More information about the samba-technical mailing list