Re: Blowfish Behaviour

"Frank Pilhofer" <[email protected]>
Newsgroups gmane.comp.security.passwordsafe.devel
Message-ID <[email protected]>
On Tue, 02 Aug 2005 01:39:55 -0400, Wolfgang Keller <[email protected]> wrote:
>
> As to my extra testings, the Blowfish algorithm that I use for my Java
> Pws library (Markus Hahn 2.13) has the same transformative funtion than
> any other Blowfish algorithm (on other environments). This means that
> all test-vector qualifying Blowfish implementations behave identical in
> respect to byte arrays regardless of platform or endianness differences.
>
> Still I have to swap byte order in a 4-byte pattern in order to make
> things running. _I am interested to obtain confirmation if this
> procedure has been introduced by Pws itself_ and is not a consequence of
> platform or language specific circumstance.
>

Check out the definition of the "aword" structure in corelib/BlowFish.h:

   union aword
   {
      unsigned long word;
      unsigned char byte [4];
      struct
      {
         unsigned int byte3:8;
         unsigned int byte2:8;
         unsigned int byte1:8;
         unsigned int byte0:8;
      } w;
   };

As you see, the "w" structure assumes big-endian byte order, thus,
on a little-endian architecture, eventually interpreting integers the
wrong way around.

To compensate for this using a "correct" implementation of the blowfish
algorithm, you have to byte-swap all inputs and outputs to the encrypt
and decrypt operations.

Frank

-- 
Frank Pilhofer, [email protected]


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.