S-box
An
s-box (or
substitution box) is a way of reducing
linearity within cryptosystems, in order to defeat certain kinds of
cryptanalysis and are commonly a part of many block ciphers. Essentially, s-boxes are invertible functions that transform a series of input bits in order to reduce linearity, generally through a fixed lookup table (as in the
Data Encryption Standard) or through a lookup table created using key and plaintext material (as in the
Blowfish encryption algorithm and the
Twofish encryption algorithm).
An s-box can often be treated as a simple substitution:
- 1 -> 3
- 2 -> 1
- 3 -> 4
- 4 -> 2
Each input symbol is replaced (substituted) by another. If a "1" goes into the s-box, a "3" comes out. If a "4" goes into the s-box, a "2" comes out. For example, given an input string "14231", we replace the "1" with "3", the "4" with "2", and so on, giving "32143" as output.
In order to decipher the output text, it is simply fed into the s-box in reverse, giving the original inputs.