How does DES actually manage to work? The trick is that
DES' S-boxes do not, in a logical sense, have 6-bit
input blocks. Logically, DES' S-boxes take 4-bit input
values; but they also accept two extra bits that index
which of four possible S-box functions to use for the
transform. So, 4-bits are transformed into a different 4-bits,
but the manner in which they are transformed depends on two
other key-like bits in the lookup table. We maintain
reversibility just so long as we are able to find those same
two index bits on our way back through the decryption.
Where do DES' S-box index bits come from?
One possibility would be to derive these index bits from the
key; and such would not be unreasonable in algorithm design.
But what DES does instead is borrow copies of the bits
in neighboring input blocks to the same round of parallel
S-boxes, and use those as index bits. A wonderful byproduct
of this element of DES' design is that it creates a
very strong avalanche effect when round input bits are
allowed to affect the transformations other input bits
undergo.