Re: Blowfish Sign Extension implementation risk

From: William Wallace (msm30_at_yahoo.com)
Date: 04/30/04


Date: 29 Apr 2004 20:10:09 -0700

Tom St Denis <tom@securescience.net> wrote in message news:<Rs4kc.316708$2oI1.177921@twister01.bloor.is.net.cable.rogers.com>...
> Tom St Denis wrote:
> > I didn't say you said that. I put that in quotes to capture the essence
> > of the thread. That you think XOR is the solution to the problem at
> > hand. Then you get all defensive when I suggest that just implementing
> > the algorithm correctly in the first place is the better course of action.
>
> I want to add something here I think you overlooked.
>
> In the Blowfish paper he doesn't specify that a key must be loaded by
> shifting and OR'ing. He specifies a key is loaded in network byte order
> into 18 32-bit variables.
>

Yes, I think you made that point twice in this thread. I haven't read
his paper, but I have read two Dr. Dobbs articles, and two applied
cryptography books, by Bruce. In the 2nd edition, he says:

(2) XOR P1 with the first 32 bits of the key, XOR P2 with the second
32 bits of the key, an so on for all bits of the key (up to P18).
Repeatedly cycle through the key bits until the entire P-array has
been XORed with the key bits.

So, you have a point. However, does your implementation follow that
description? I highly doubt it, but it might. Specifically, this
step says key *bits*, not key bytes. Do you allow, for example, a
121-bit key in your crypto library? Do you rotate key bits or key
bytes before XORing into the P array? Or do you follow Bruce's code
from the 2nd edition. Specifically:

for(k=0;k<4;k++){
  data = (data <<8) | k[j]; /* note, 2nd edition has sign extension
bug too */
//...
}

Again, let me be very clear in my question: Does your implementation
follow his written description, or the source code?

> In the relevence of this thread that's a big difference.

Maybe, maybe not. Depends on how you answer the last question.

> You're claiming [from what I gather] that Blowfish wasn't designed
> robustly because an implementation is wrong.

No, I claimed that the algorithm could have been designed to be more
robust to implementation errors than it was, as was one of the stated
goals (see Dr. Dobbs, April, 1994). You have a point that I might be
including Bruce's de facto reference implementation as part of the
algorithm description, since the algorithm, as it is available to the
mainstream, was published with C source code (again, see Dr. Dobbs,
Applied Cryptography, etc.).

> I'm simply stating that the implementation is wrong and the design [while
> terse and lacking test vectors] is correct.

Good point. But I am interested, is your implementation correct? Do
you shift in key bits? Or do you interpret (2) above to mean that the
key must be mod 32 bits? Or did you look at the C source code
provided by Bruce for a clue?

>
> Tom



Relevant Pages

  • Re: Blowfish Sign Extension implementation risk
    ... > cryptography books, by Bruce. ... I definitely didn't use his source code ... > algorithm description, since the algorithm, as it is available to the ... > mainstream, was published with C source code (again, see Dr. Dobbs, ...
    (sci.crypt)
  • Re: re:Algorithm
    ... > Lol you don't get to see my source code for 2 reasons. ... Cryptography is all about analyzing and reviewing the ... When you don't post your algorithm, then how are you going to ...
    (sci.crypt)
  • Re: How much must be revealed
    ... You can convince peope to trust your /algorithm/ by publishing it. ... You can convince people that you are not a liar by providing source code. ... Not only because the algorithm cannot be ... Microsoft-built crypto software in the black. ...
    (sci.crypt)
  • Re: URLs
    ... Tom B. wrote ... ... Gravity source code and compiled binaries are released under the ... this list of conditions and the following disclaimer. ... CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, ...
    (uk.test)
  • Re: How to write a program to track the value of a certain variable at run-time using debug feat
    ... debug tools for my purpose. ... research I have written an algorithm to solve numerical functions. ... change without knowning anything about user source code. ... Find out which global variables are being used by f (I can do that ...
    (comp.os.linux.development.apps)