santuario-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Pirker <>
Subject base64 elements linebreak
Date Wed, 25 Jan 2006 09:29:42 GMT

While doing interoperability experiments with XML documents
containing digital signatures created with the Apache xmlsec
project libraries (=the libraries contained in the Java WSDP
package), I noticed a difference to other providers

Base64 coded components, e.g. the Modulus of a RSA key or
the SignatureValue itself, get wrapped at column 76.

Why is that?

Digging in the source, e.g., there is:
|private void setSignatureValueElement(byte[] bytes)
|if (base64codedValue.length() > 76) {
|  base64codedValue = "\n"+base64codedValue+"\n";
..of course it wraps.

But why does the output of other libs not linebreak?
Is this decision backed by some standard?

RFC3548, Section 2.1, Line feeds in encoded data,
explains that the 76 come from MIME, not base64 itself.

"For compatibility with older mail gateways, [RFC
2045] suggests that base64 data should have lines
limited to at most 76 characters in length. This
line-length limitation is not mandated in the lexical
forms of base64Binary data and must not be enforced
by XML Schema processors."

While wrapping at 76 appears to do neither good nor
harm in the XML world, I still "feel" this is "ugly".

Large autogenerated XML docs usually contain no
linebreaks and appear on one line.
Except when you sign them with Apache xmlsec, now
they get a few extra linebreaks...

I personally would prefer no linebreaks, but maybe
there was a good reason it was coded that way?


View raw message