Overview
Two phases in stream cipher:
- key initialization phase.(
KIA) PRSGrunning phase.
Design princinple
Typical stream Ciphers
A5/1 in GSM
Cipher flow:

上图中,A5/1 部分就是基于一个密钥的随机数生成器,它主要由以下三个部分组成:
It uses three
LFSRsgenerating m-sequences of large periodswhich is: $$\displaystyle \begin{cases} f_1(x) = x^{19} + x^5 + x^2 + x + 1 \ f_2(x) = x^{22} + x + 1 \ f_3(x) = x^{23} + x^{16} + x^2 + x +1 \end{cases}$$
Tap positions: $$d_1 = 11, d_2 = 12, d_3 = 13$$.
Majority function.
LFSR working flow:

KIA phase:
- For session key $$K = (k_0, \cdots, k_{63})$$, and a frame counter number $$N = (n_0, \cdots, n_{21})$$. Let
Sbe the concatenation ofKandN. - (这里还有,懒得写了)
A5/1 is very weak. (Weakness: short period, majority rule, short key length.)
E0 in Bluetooth
RC4 in WEP
WEP:
- The wire equivalent privacy (
WEP) algorithm is used to protect wireless communication from eavesdropping; prevent unauthorized access to a wireless network.
KIA phase pseudocode:
| |
PRSG phase pseudocode:
| |
Implement in python from github:
| |
PRSG phase can be illustrated by the following state transition graph:

WG Stream Cipher
The WG stream cipher can be explained as following formula:
Initialize $$a_0, \cdots, a_l$$ with given key with l length.
Updating: $$\displaystyle a_{k+l} = \begin{cases}\displaystyle \sum_{i=0}^{l-1}c_i a_{i+k} + WGperm(a_{k+l-1}) & 0 \le k < 2l,& \text{KIA phase} \ \displaystyle \sum_{i=0}^{l-1} c_i a_{i+k} & k \ge 2l, & \text{running phase}\end{cases}$$
Output: $$s_k = WG(a_{k +2l + l-1})$$
Cipher flow:
