# S boxes in Blowfish

I know how the s-boxes in blowfish are initialized, but how is the output sorted, I mean which bit from the input goes where in the box ? and what do mean they have 256 entries if they are 32-bit S-Boxes ?

• Blowfish s-boxes have 256 entries, because they have 8-bit input and 32-bit output. I do not understand other part of the question. – LightBit Nov 29 '15 at 17:32
• Oh hi, I mean for every 8 bit input a 32 bit output is generated right? how is this mapping done ? for example in DES S-Boxes we use the outer and Inner bits method – user29481 Nov 29 '15 at 17:40
• It splits half block in 4 8-bit pieces, which are then used as an input to s-box (each piece goes through different s-box). 32-bit output of s-boxes is than combined. See this picture: upload.wikimedia.org/wikipedia/commons/2/22/… – LightBit Nov 29 '15 at 19:09
• yeah, thanks man but you still didn't get my question :<. I get this part, what I meant is how does the algorithm decide what 8 bits get mapped to which 32 bits ? If the incoming bits are 11110000 how does the S-Box get the output 32 ? – user29481 Nov 29 '15 at 19:39
• Table lookup. Value from 11110000 (240)th position. – LightBit Nov 29 '15 at 20:29

A 32-bit value output is chosen from a table depending on an 8-bit input value.

The s-box within block ciphers is typically implement with a table, with a fixed input and output size. Some ciphers have the same input and output size; for example, for AES, it uses an sbox with 8 bit inputs and outputs, while Serpent uses an sbox with 4 bit inputs and outputs. When the sbox is implemented as a table, the output size defines size of entries and the input size defines number of entries. In the case of Blowfish, the input is 8-bit (and hence there are 256 entries), and the output is 32-bit (and hence each entry is 32 bits long). These sbox contents are generated during key setup.

In C Blowfish s-boxes are defined as:

uint32_t S[256];

• How will it convery the 8 bit input to 32 bit output?? – Sathwika reddy Jan 30 at 4:17
• @Sathwikareddy using table lookup. – LightBit Jan 31 at 18:28