S-boxes in Blowfish
Results 1 to 4 of 4

Thread: S-boxes in Blowfish

  1. #1
    Member
    Join Date
    Sep 2003
    Posts
    76

    S-boxes in Blowfish

    Hey there, Im just working on a project for a crypto class and I decided to implement blowfish on VHDL(Hardware Description Language) to run on a hardware piece. Anyways, the real question is that the blowfish algorithm initializes its famous 4 S-boxes and a P array with the hex values of the decimal part of pi. I have found some programs which calculate pi with enough accuracy to get enough values for initialization of these S-boxes (they are 4 each with 256 32 bit entries). Problem is I dont know how to change this number later to hex or even binary. Any help here would be greatly appreciated.
    I know I haven't given much information on the algorithm but it is not really necessary to understand what I need.
    I Speak in frequencies even dogs have trouble hearing


  2. #2
    Senior Member
    Join Date
    Jul 2003
    Posts
    634
    hey sounds like a cool project, are you gonna have two cpld or fpga's? one encrypting and on decrypting?

    I found this page,

    http://www.ee.ualberta.ca/~elliott/e...sh_encryption/
    http://personal.sip.fi/~lm/c2txt2c/blowfish.txt <---hehehe
    http://www.packetstormsecurity.org/crypt/blowfish/

    dunno whether there any help...

    i2c

  3. #3
    Senior Member
    Join Date
    Mar 2004
    Posts
    557
    Hi

    An excellent list of the initialisation numbers for the 18x32bit P and the 4 256x32bit S-boxes
    can be obtained here[1], in a useful format.

    How is this computed?

    The starting point chosen by Bruce is the number: Pi - 3 = 0.14159265...

    How can this number be assembled in hex-base? As follows:


    First digit: 1/16 = 0.0625


    Q: How often does that fit into this number 0.14159...?
    A: 2 times.

    Code:
    0.14159265 - 2* 1/16 = 0.01659265...
    Note: This number 0.01659265... is smaller than 1/16, and thus has to
    be "approximated" using the next smaller possibility: 1/(16^2)


    Second digit: 1/(16^2) = 0.00390625


    Q: How often does that fit into the rest-term 0.01659265...
    A: 4 times

    Code:
    0.14159265 - 2* 1/16 - 4*1/(16^2) = 0.0009676535...

    Third digit: 1/(16^3) = 0.00024414...


    Q: How often does that fit into the rest-term 0.000967653...
    A: 3 times

    and the fourth digit: 15 times. 15 in hexadezimal notation is F.

    Thus: 24 3F ...
    etcetc

    The initialisation starts with P, then S0, S1, S2 and finally S3.


    Cheers.

    [1] http://www.sstorie.com/school/cs4821...owfishSPInit.h
    If the only tool you have is a hammer, you tend to see every problem as a nail.
    (Abraham Maslow, Psychologist, 1908-70)

  4. #4
    Member
    Join Date
    Sep 2003
    Posts
    76
    Thanks a lot guys, definitely going to help. Oh and i2c, ill be using fpga's .
    I Speak in frequencies even dogs have trouble hearing


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •