On Mon, Jun 20, 2005, Dr. Stephen Henson wrote:
> On Mon, Jun 20, 2005, Richard Levitte - VMS Whacker wrote:
>
> > In message <[EMAIL PROTECTED]> on Mon, 20 Jun 2005 12:11:30 +0200, Beat
> > Jucker <[EMAIL PROTECTED]> said:
> >
> > bj> Given attached BASE64 encoded file openssl will write only 5280
> > bj> decoded bytes instead of the original 5305 bytes as other tools
> > bj> like mimencode, base64, Asn1Editor, web online base64 decoder, ...
> > bj>
> > bj> openssl base64 -d -in text.pem -out text.der
> > bj> --> 5280 instead of 5305 bytes!?
> >
> > I've played with previous incarnations, and noticed that with the
> > latest update for 0.9.7-stable, I get 5305 bytes, while I get 5280
> > bytes with 0.9.8-stable. I compared crypto/evp/bio_b64.c from both
> > branches, and there is virtually no difference, so the problem is
> > somewhere else.
> >
> > I noticed something unusual about your file: the lines are 76
> > characters, when a PEM file usually (or at least by default when
> > output by OpenSSL) has 64 character lines... I have no clue how
> > important that fact is, but I'm going to conduct some tests.
> >
>
> The only significant change is:
>
> http://cvs.openssl.org/chngview?cn=12988
>
> whether this is the problem or it has just triggered a problem elsewhere I
> don't know.
>
Looks like the latter. That example causes problems because the ultimate '='
characters representing EOF are passed in separate calls to
EVP_DecodeUpdate() and EVP_DecodeBlock() ends up being called with an buffer
that is not a multiple of 4 characters in length.
The cause *may* be the line:
if (((i+1) == inl) && (((n&3) == 0) || eof))
which causes processing if only one '=' has been reached at the end of the
input data. Removing the 'eof' check at the end seems to fix this.
Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Funding needed! Details on homepage.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [email protected]
Automated List Manager [EMAIL PROTECTED]