Blowfish in Python?

Reuben Sumner rasumner at iname.com
Sun Feb 27 13:08:53 EST 2000


Tim Peters wrote in message <000a01bf810a$422a7cc0$172d153f at tim>...
>[Markus Stenberg]
>> I think the main reason was the fact that I had to use _long ints_ for
>> calculations, as the normal ints are signed, and apparently the bitwise
>> operators do not work as advertised when bit32 is set (=number is
>> negative). Or that's my theory anyway - my implementation worked with
>> long's and did not work with ints.
>
>Try to whittle this down.  Negative ints are nothing special to the bitwise
>ops, so if they "don't work as advertised" it would be a (very surprising!)
>bug in the implementation.  For example, here's the implementation of int
&:


Even if & is OK, in, for example RC5 you need to do a bunch of "+"
operations modulo 2**32.  At the machine level (or C) this is quite natural.
Unfortunately in Python ints come with overflow detection which gets
triggered here.  When I needed this I resorted to a module in C.  I imagine
that some sort of a uint32_t type with +,-,shift,rotate would be quite handy
for implementing a number of cryptographic primitives.  * would be needed
for RC6 (even just returning the lower 32 bits of the full 64 bit product).

Reuben





More information about the Python-list mailing list