[Zlib-devel] Blowfish transparent encryptography in zlib

jbowler at acm.org jbowler at acm.org
Sat Jul 31 13:23:20 EDT 2010


From: Moises Beck
>For this purpose I would like to modify zlib to support transparent
blowfish encryptography.
>I have some doubts if is it easy to do that as zlib must be modified to do
reads and writes in
>files respecting an eigth byte boundary (blowfish block size). 

Don't use the 'gz' APIs, use the standard inflate API - then you control the
buffering.

I've done this before, it's easy; it's just necessary to remember that the
compressed image size prior to encryption gets rounded up to the next
multiple of 8 (or 16, or whatever your favorite encryption algorithm uses as
a block size).  Zlib (inflate) doesn't care if it gets extra bytes - it's
self terminating - that makes it even easier.  (In other cases, where you
have to be able to retrieve the original length the standard technique is to
store a last block ending with a byte containing the count of extra bytes -
1-8 including the count byte.)

John Bowler <jbowler at acm.org>






More information about the Zlib-devel mailing list