Stream Cipher
A stream cipher is a symmetric key cipher where plaintext digits are combined with a pseudorandom cipher digit stream. In a stream cipher, each plaintext digit is encrypted one at a time with the corresponding digit of the key stream, to give a digit of the cipher text stream.
One time pad
In Cryptography, one time pad is an encryption technique that cannot be cracked, but requires the use of one-time pre-shared key the same size as the message being sent. For OTP, encryption and decryption is defined as:
The one time pad is the only example of perfect secrecy, in this technique, brute force is pointless. Here is an example of how to solve a one time pad encryption:
|
|
At first, we know that the message “attack at dawn” convert to “09e1c5f70a65ac519458e7e53f36”, so we assign “attack at dawn” to m1, and “09e1c5f70a65ac519458e7e53f36” to c1. Because c1 is the encrypted result of m1, so
In this problem, m2 = “attack at dawn”, and we know:
So we can get the the OPT key of message “attack at dusk”. To implement it with the python code is:
However, it lacks in portability-the key is the same size as the message and convenience- you must never reuse the key. Modern stream ciphers attempt to approximate the one-time pad with a pseudorandom key stream, in OTP with a pseudorandom key, which is smaller than |M|.
Block cipher
Block ciphers use a key to encrypt a fixed-size block of plaintext into a fixed-size block of ciphertext. They are usually more computationally expensive than stream ciphers, but have numerous benefits.
Claude Shannon suggested that all that was required for a strong cipher was repeated substation and permutation. SP-Networks combine a substitution process with a permutation into a single round.
- Substitution Boxes: Add confusion by replacing value with other values using a lookup table.
- Permutation Boxes: Add diffusion by moving values around from input to output.