Presentation is loading. Please wait.

Presentation is loading. Please wait.

A toy example for RC4.

Similar presentations


Presentation on theme: "A toy example for RC4."β€” Presentation transcript:

1 A toy example for RC4

2 A toy example for RC4. Initial state /* Initialization */
for i = 0 to 3 do S[i] = i; T[i] = K[i mod keylen]; S (state) 1 2 3 T for π‘˜=2

3 A toy example for RC4 /* Initial Permutation of S */ 1st update
j = 0; for 𝑖=0 to 3 do 𝑗= 𝑗+𝑆 𝑖 +𝑇 𝑖 π‘šπ‘œπ‘‘ 4 ; Swap (𝑆 𝑖 ,𝑆 𝑗 ); For 𝑖=0, 𝑗=0 we get: 𝑗=0+0+2≑2 π‘šπ‘œπ‘‘ 4 : 𝑆 𝑖=0 =0, 𝑆 𝑗=2 =2 1st update For 𝑖=1, 𝑗=2 we get: 𝑗=2+1+2≑1 π‘šπ‘œπ‘‘ 4 : 𝑆 𝑖=1 =1, 𝑆 𝑗=1 = nd update For 𝑖=2, 𝑗=1 we get: 𝑗=1+0+2≑3 π‘šπ‘œπ‘‘ 4 : 𝑆 𝑖=2 =0, 𝑆 𝑗=3 =3 3rd update For 𝑖=3, 𝑗=3 we get: 𝑗=3+0+2≑1 π‘šπ‘œπ‘‘ 4 : 𝑆 𝑖=3 =0, 𝑆 𝑗=1 =1 4th update State 𝑺 (π’Š=𝟎) 2 1 3 State 𝑺 (π’Š=𝟏) 2 1 3 State 𝑺 (π’Š=𝟐) 2 1 3 State 𝑺 (π’Š=πŸ‘) 2 3 1

4 A toy example for RC4 /* Stream Generation */
i, j = 0; while (true) j = (j + S[i]) mod 4; i = (i + 1) mod 4; Swap (S[i], S[j]); t = (S[i] + S[j]) mod 4; k = S[t]; For 𝑖=0, 𝑗=0: 𝑗=0+2≑2 π‘šπ‘œπ‘‘ 4, 𝑖=1; 𝑆 𝑖=1 =0, 𝑆 𝑗=2 =3. Update, compute 𝑑=3 and output 𝑆 3 =1 For 𝑗=2, 𝑖=1: 𝑗=2+3≑1 π‘šπ‘œπ‘‘ 4, 𝑖=2; 𝑆 𝑖=2 =0, 𝑆 𝑗=1 =3. Update compute 𝑑=3, and output 𝑆 3 =1 For 𝑗=1, 𝑖=2: 𝑗=1+3≑0 π‘šπ‘œπ‘‘ 4, 𝑖=3; 𝑆 𝑖=3 =1, 𝑆 𝑗=0 =2. Update compute 𝑑=3, and output 𝑆 3 =2 State 𝑺 2 3 1 State 𝑺 2 3 1 State 𝑺 1 3 2


Download ppt "A toy example for RC4."

Similar presentations


Ads by Google