Cryptography has a very vast and an interesting history. In history, cryptography was used by diplomats, lovers, and the military, among which the military played the most important role in improving the existing techniques, and developing new techniques of encryption and decryption.
Traditional cryptography used transposition and substitution techniques with very long keys to decrypt the information. The traditional encryption and decryption model included the text to be encrypted, an encryption key and a decryption key. The message to be encrypted was transformed by a function that was parameterized by a key.
The output of encryption of data was known as cipher text, which was then transferred/transmitted by some means. At the other end, the intended receiver could decrypt the information (cipher text) using the decryption key, and the original information was recovered from the cipher text.
There were many methods used to encrypt and decrypt the information, but the most important part was the key. The key design was a major issue.
Traditionally the encryption and decryption algorithms relied on very long keys for security. Nowadays, the encryption algorithm is made so complex that even if anyone succeeds in collecting large data (encrypted/cipher text), he will not be able to use it, and won't even be able to understand anything from the same.
The transposition and substitutions are implemented with simple circuits, which use permutations of input lines and generate some altered output; this device is known as the P-box. This P-box is used to effect a transposition on an 8-bit (or more) input.
Let us take an example: if we have 8-bit input: 01234567, the P-box is configured in such a way that if these 8-bits are input to the P-box, the output that we will get is 25764031. In simple words, the position of the bits are changed. Thus, a P-box is used to perform any transposition in nearly no time.
The next thing, i.e., substitution, is performed by a device called S-box. For example, if we take a simple S-box which consists of a 3 to 8 bit decoder at the input, a P-box and 8 to 3 encoder at the output, i.e., if we enter a 3-bit plain text at the input, a 3-bit cipher text will be received as an output.
The 3 to 8 decoder will transform 3-bit data to 8-bit data, and this data will be transformed internally, the 3-bit input selects one of the 8 lines existing from the first stage and sets it to 1; all the other lines are 0. Then this received data will be encoded into 3-bit data using the 8 to 3 bit encoder.
The device used for transposing the 8-bit data is a P-box, the working of which we just discussed earlier. The third stage in S-box encodes the input line that is selected by P-box into binary again.
Thus, if an octal number is selected, e.g., 01234567 as an input, then the output sequence will be 34621705, where 0 is replaced by 3, 1 by 4 and so on. Thus, by using appropriate wiring of P-box inside the S-box, any substitution can be accomplished.
This method seems to be very easy and powerless at first glance, but an appropriate combination of these basic elements, cascaded in proper way gives a very powerful encryption and decryption mechanism.
For example, consider that we want to encrypt 12-bit data, so 12 input lines are transposed by first stage, then take 4 S-boxes as second stage, which will map 12 bit number onto another 12 bit number with the help of 4 3-bit substitution boxes. Then P-box is used as a next stage to transpose the data.
This specific arrangement is used to create a "Product Cipher" box, which combines P-box and S-box arrangements. If we add sufficiently large number of stages in the product cipher, the output can be made to be an exceedingly complicated function of the input.