Evaluate a cipher’s secrecy
A cipher with message space and ciphertext space is perfectly secret if
or, equivalently, if
Example: Shift cipher
The shift cipher is not perfectly secret.
Imagine 2 possible messages:
The ciphertext cannot have been generated by , for the amount of shift applied to the letters is different.
One-time pad
The one-time pad is a perfectly secret cipher.
where is a random key of length .
Pros and cons of the one-time pad
Pros | Cons |
---|---|
Perfect secrecy | Key must be as long as the message |
Simple and fast | Key must be truly random |
Key must be shared securely | |
Key must only be used once |
Stream ciphers
A stream cipher is a symmetric key cipher where the plaintext is encrypted using a pseudorandom stream of bit originating from a short seed.
Loading diagram...
Necessity of a nonce
A nonce is a unique value that must be used only once. It must be included in the encryption and decryption processes to prevent replay attacks.
If we only rely on the key, two subsequent encryptions will reveal information about the plaintext.
Adding a nonce
Stream cipher must also consider the nonce in the encryption and decryption processes. The nonce is not secret and can be sent in the clear.
The combination (key, nonce) must be unique for each encryption request.
Random number generators
True randomness is difficult to achieve for computers. Instead, we rely on pseudorandom generators (PRGs) which expand a short seed into a long pseudorandom sequence of bits.
Characteristics of a good PRG
- Expansion: the output must be longer than the seed.
- Indistinguishable: the output must be indistinguishable from true randomness.
- Efficiency: the output must be generated quickly (polynomial time).
- Repeatability: the same seed must always produce the same output.
- Unpredictability: a small change in the seed must produce a completely different output.
Linear feedback shift registers
A linear feedback shift register (LFSR) is a simple PRG that generates a sequence of bits by shifting the bits of a register, producing a bit from the right and introducing a new one from the left.
Can be used to generate a pseudorandom stream of bits.
Loading diagram...
Connection polynomial
Not all bits of the state contribute in generating the next bit. They are determined by the connection polynomial.
For example, the polynomial
determines that only bits , , and participate in generating the next bit.
Loading diagram...
Example: LFSR
Consider the LFSR with polynomial and initial state . What appears at the output after 3 ticks?
Loading diagram...
- Output: . New state:
- Output: . New state:
- Output: . New state:
Period of an LFSR
The sequence of bits generated by a LFSR repeats after a certain number of ticks.
For an -bit LFSR, the maximum period is .
The period is determined by the irreducibility of its polynomial and the smallest value such that divides the polynomial .
LFSR are not secure for cryptographic purposes, as the output can be predicted by just observing the output.