rc4 ksaproc
TRANSCRIPT
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 1/23
W e a k n e s s e s i n t h e K e y S c h e d u l i n g A l g o r i t h m o f
R C 4
S c o t t F l u h r e r
1
, I t s i k M a n t i n
2
, a n d A d i S h a m i r
2
1
C i s c o S y s t e m s , I n c . , 1 7 0 W e s t T a s m a n D r i v e , S a n J o s e , C A 9 5 1 3 4
s f l u h r e r @ c i s c o . c o m
2
C o m p u t e r S c i e n c e d e p a r t m e n t , T h e W e i z m a n n I n s t i t u t e , R e h o v o t 7 6 1 0 0 , I s r a e l .
f i t s i k , s h a m i r g @ w i s d o m . w e i z m a n n . a c . i l
A b s t r a c t . I n t h i s p a p e r w e p r e s e n t s e v e r a l w e a k n e s s e s i n t h e k e y s c h e d u l -
i n g a l g o r i t h m o f R C 4 , a n d d e s c r i b e t h e i r c r y p t a n a l y t i c s i g n i c a n c e . W e
i d e n t i f y a l a r g e n u m b e r o f w e a k k e y s , i n w h i c h k n o w l e d g e o f a s m a l l
n u m b e r o f k e y b i t s s u c e s t o d e t e r m i n e m a n y s t a t e a n d o u t p u t b i t s
w i t h n o n - n e g l i g i b l e p r o b a b i l i t y . W e u s e t h e s e w e a k k e y s t o c o n s t r u c t
n e w d i s t i n g u i s h e r s f o r R C 4 , a n d t o m o u n t r e l a t e d k e y a t t a c k s w i t h p r a c -
t i c a l c o m p l e x i t i e s . F i n a l l y , w e s h o w t h a t R C 4 i s c o m p l e t e l y i n s e c u r e i n a
c o m m o n m o d e o f o p e r a t i o n w h i c h i s u s e d i n t h e w i d e l y d e p l o y e d W i r e d
E q u i v a l e n t P r i v a c y p r o t o c o l ( W E P , w h i c h i s p a r t o f t h e 8 0 2 . 1 1 s t a n d a r d ) ,
i n w h i c h a x e d s e c r e t k e y i s c o n c a t e n a t e d w i t h k n o w n I V m o d i e r s i n
o r d e r t o e n c r y p t d i e r e n t m e s s a g e s . O u r n e w p a s s i v e c i p h e r t e x t - o n l y a t -
t a c k o n t h i s m o d e c a n r e c o v e r a n a r b i t r a r i l y l o n g k e y i n a n e g l i g i b l e
a m o u n t o f t i m e w h i c h g r o w s o n l y l i n e a r l y w i t h i t s s i z e , b o t h f o r 2 4 a n d
1 2 8 b i t I V m o d i e r s .
1 I n t r o d u c t i o n
R C 4 i s t h e m o s t w i d e l y u s e d s t r e a m c i p h e r i n s o f t w a r e a p p l i c a t i o n s . I t w a s
d e s i g n e d b y R o n R i v e s t i n 1 9 8 7 a n d k e p t a s a t r a d e s e c r e t u n t i l i t l e a k e d o u t i n
1 9 9 4 . R C 4 h a s a s e c r e t i n t e r n a l s t a t e w h i c h i s a p e r m u t a t i o n o f a l l t h e N = 2
n
p o s s i b l e n b i t s w o r d s , a l o n g w i t h t w o i n d i c e s i n i t . I n p r a c t i c a l a p p l i c a t i o n s n = 8 ,
a n d t h u s R C 4 h a s a h u g e s t a t e o f l o g
2
( 2
8
! ( 2
8
)
2
) 1 7 0 0 b i t s .
I n t h i s p a p e r w e a n a l y z e t h e K e y S c h e d u l i n g A l g o r i t h m ( K S A ) w h i c h d e r i v e s
t h e i n i t i a l s t a t e f r o m a v a r i a b l e s i z e k e y , a n d d e s c r i b e t w o s i g n i c a n t w e a k n e s s e s
o f t h i s p r o c e s s . T h e r s t w e a k n e s s i s t h e e x i s t e n c e o f l a r g e c l a s s e s o f w e a k k e y s ,
i n w h i c h a s m a l l p a r t o f t h e s e c r e t k e y d e t e r m i n e s a l a r g e n u m b e r o f b i t s o f
t h e i n i t i a l p e r m u t a t i o n ( K S A o u t p u t ) . I n a d d i t i o n , t h e P s e u d o R a n d o m G e n -
e r a t i o n A l g o r i t h m ( P R G A ) t r a n s l a t e s t h e s e p a t t e r n s i n t h e i n i t i a l p e r m u t a t i o n
i n t o p a t t e r n s i n t h e p r e x o f t h e o u t p u t s t r e a m , a n d t h u s R C 4 h a s t h e u n d e s i r -
a b l e p r o p e r t y t h a t f o r t h e s e w e a k k e y s i t s i n i t i a l o u t p u t s a r e d i s p r o p o r t i o n a l l y
a e c t e d b y a s m a l l n u m b e r o f k e y b i t s . T h e s e w e a k k e y s h a v e l e n g t h w h i c h i s
d i v i s i b l e b y s o m e n o n - t r i v i a l p o w e r o f t w o , i . e . , ̀ = 2
q
m f o r s o m e q > 0
1
. W h e n
1
H e r e a n d i n t h e r e s t o f t h e p a p e r ̀ i s t h e n u m b e r o f w o r d s o f K , w h e r e e a c h w o r d
c o n t a i n s n b i t s .
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 2/23
R C 4
n
u s e s s u c h a w e a k k e y o f ̀ w o r d s , x i n g n + q ( ̀ 1 ) + 1 b i t s o f K ( a s a
p a r t i c u l a r p a t t e r n ) d e t e r m i n e s ( q N ) b i t s o f t h e i n i t i a l p e r m u t a t i o n w i t h p r o b -
a b i l i t y o f o n e h a l f a n d d e t e r m i n e s v a r i o u s p r e x e s o f t h e o u t p u t s t r e a m w i t h
v a r i o u s p r o b a b i l i t i e s ( d e p e n d i n g o n t h e i r l e n g t h ) .
T h e s e c o n d w e a k n e s s i s a r e l a t e d k e y v u l n e r a b i l i t y , w h i c h a p p l i e s w h e n p a r t
o f t h e k e y p r e s e n t e d t o t h e K S A i s e x p o s e d t o t h e a t t a c k e r . I t c o n s i s t s o f t h e
o b s e r v a t i o n t h a t w h e n t h e s a m e s e c r e t p a r t o f t h e k e y i s u s e d w i t h n u m e r o u s
d i e r e n t e x p o s e d v a l u e s , a n a t t a c k e r c a n r e d e r i v e t h e s e c r e t p a r t b y a n a l y z i n g
t h e i n i t i a l w o r d o f t h e k e y s t r e a m s w i t h r e l a t i v e l y l i t t l e w o r k . T h i s c o n c a t e n a -
t i o n o f a l o n g t e r m s e c r e t p a r t w i t h a n a t t a c k e r v i s i b l e p a r t i s a c o m m o n l y u s e d
m o d e o f R C 4 , a n d i n p a r t i c u l a r i t i s u s e d i n t h e W E P ( W i r e d E q u i v a l e n t P r i -
v a c y ) p r o t o c o l , w h i c h p r o t e c t s m a n y w i r e l e s s n e t w o r k s . O u r n e w a t t a c k o n t h i s
m o d e i s p r a c t i c a l f o r a n y k e y s i z e a n d f o r a n y m o d i e r s i z e , i n c l u d i n g t h e 2 4 b i t
r e c o m m e n d e d i n t h e o r i g i n a l W E P a n d t h e 1 2 8 b i t r e c o m m e n d e d i n t h e r e v i s e d
v e r s i o n W E P 2 .
T h e p a p e r i s o r g a n i z e d i n t h e f o l l o w i n g w a y : I n S e c t i o n 2 w e d e s c r i b e R C 4
a n d p r e v i o u s r e s u l t s a b o u t i t s s e c u r i t y . I n S e c t i o n 3 w e c o n s i d e r a s l i g h t l y m o d -
i e d v a r i a n t o f t h e K e y S c h e d u l i n g A l g o r i t h m , c a l l e d K S A
, a n d p r o v e t h a t a
p a r t i c u l a r p a t t e r n o f a s m a l l n u m b e r o f k e y b i t s s u c e s t o c o m p l e t e l y d e t e r m i n e
a l a r g e n u m b e r o f s t a t e b i t s . A f t e r w a r d s , w e s h o w t h a t t h i s w e a k n e s s o f K S A
,
w h i c h w e d e n o t e a s t h e i n v a r i a n c e w e a k n e s s , e x i s t s ( i n a w e a k e r f o r m ) a l s o i n
t h e o r i g i n a l K S A . I n S e c t i o n 4 w e s h o w t h a t w i t h h i g h p r o b a b i l i t y , t h e p a t t e r n s
o f i n i t i a l s t a t e s a s s o c i a t e d w i t h t h e s e w e a k k e y s a l s o p r o p a g a t e i n t o t h e r s t
f e w o u t p u t s , a n d t h u s a s m a l l n u m b e r o f w e a k k e y b i t s d e t e r m i n e a l a r g e n u m -
b e r o f b i t s i n t h e o u t p u t s t r e a m . I n S e c t i o n 5 w e d e s c r i b e s e v e r a l c r y p t a n a l y t i c
a p p l i c a t i o n s o f t h e i n v a r i a n c e w e a k n e s s , i n c l u d i n g a n e w t y p e o f d i s t i n g u i s h e r .
I n S e c t i o n s 6 a n d 7 w e d e s c r i b e t h e s e c o n d w e a k n e s s , w h i c h w e d e n o t e a s t h e
I V w e a k n e s s , a n d s h o w t h a t a c o m m o n m e t h o d o f u s i n g R C 4 i s v u l n e r a b l e t o
a p r a c t i c a l a t t a c k d u e t o t h i s w e a k n e s s . I n S e c t i o n 8 , w e s h o w h o w b o t h t h e s e
w e a k n e s s e s c a n s e p a r a t e l y b e u s e d i n a r e l a t e d k e y a t t a c k . I n t h e a p p e n d i c e s , w e
e x a m i n e h o w t h e I V w e a k n e s s c a n b e u s e d t o a t t a c k a r e a l s y s t e m ( a p p e n d i x A ) ,
h o w t h e i n v a r i a n c e w e a k n e s s c a n b e u s e d t o c o n s t r u c t a c i p h e r t e x t - o n l y d i s t i n -
g u i s h e r a n d t o p r o v e t h a t R C 4 h a s l o w s a m p l i n g r e s i s t a n c e ( a p p e n d i c e s B a n d
C ) , a n d h o w t o d e r i v e t h e s e c r e t k e y f r o m a n e a r l y p e r m u t a t i o n s t a t e ( a p p e n d i x
D ) .
2 R C 4 a n d I t s S e c u r i t y
2 . 1 D e s c r i p t i o n o f R C 4
R C 4 c o n s i s t s o f t w o p a r t s ( d e s c r i b e d i n F i g u r e 1 ) : A k e y s c h e d u l i n g a l g o r i t h m
K S A w h i c h t u r n s a r a n d o m k e y ( w h o s e t y p i c a l s i z e i s 4 0 - 2 5 6 b i t s ) i n t o a n i n i t i a l
p e r m u t a t i o n S o f f 0 ; : : : ; N 1 g , a n d a n o u t p u t g e n e r a t i o n p a r t P R G A w h i c h
u s e s t h i s p e r m u t a t i o n t o g e n e r a t e a p s e u d o - r a n d o m o u t p u t s e q u e n c e .
T h e P R G A i n i t i a l i z e s t w o i n d i c e s i a n d j t o 0 , a n d t h e n l o o p s o v e r f o u r
s i m p l e o p e r a t i o n s w h i c h i n c r e m e n t i a s a c o u n t e r , i n c r e m e n t j p s e u d o r a n d o m l y ,
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 3/23
e x c h a n g e t h e t w o v a l u e s o f S p o i n t e d t o b y i a n d j , a n d o u t p u t t h e v a l u e o f S
p o i n t e d t o b y S i ] + S j ]
2
. N o t e t h a t e v e r y e n t r y o f S i s s w a p p e d a t l e a s t o n c e
( p o s s i b l y w i t h i t s e l f ) w i t h i n a n y N c o n s e c u t i v e r o u n d s , a n d t h u s t h e p e r m u t a t i o n
S e v o l v e s f a i r l y r a p i d l y d u r i n g t h e o u t p u t g e n e r a t i o n p r o c e s s .
T h e K S A c o n s i s t s o f N l o o p s t h a t a r e s i m i l a r t o t h e P R G A r o u n d o p e r a t i o n .
I t i n i t i a l i z e s S t o b e t h e i d e n t i t y p e r m u t a t i o n a n d i a n d j t o 0 , a n d a p p l i e s t h e
P R G A r o u n d o p e r a t i o n N t i m e s , s t e p p i n g i a c r o s s S , a n d u p d a t i n g j b y a d d i n g
S i ] a n d t h e n e x t w o r d o f t h e k e y ( i n c y c l i c o r d e r ) . W e w i l l c a l l e a c h r o u n d o f
K S A a s t e p .
K S A ( K )
I n i t i a l i z a t i o n :
F o r i = 0 : : : N 1
S i ] = i
j = 0
S c r a m b l i n g :
F o r i = 0 : : : N 1
j = j + S i ] + K i m o d ̀ ]
S w a p ( S i ] ; S j ] )
P R G A ( K )
I n i t i a l i z a t i o n :
i = 0
j = 0
G e n e r a t i o n l o o p :
i = i + 1
j = j + S i ]
S w a p ( S i ] ; S j ] )
O u t p u t z = S S i ] + S j ] ]
F i g . 1 . T h e K e y S c h e d u l i n g A l g o r i t h m a n d t h e P s e u d o - R a n d o m G e n e r a t i o n A l g o r i t h m
2 . 2 P r e v i o u s A t t a c k s o n R C 4
D u e t o t h e h u g e e e c t i v e k e y o f R C 4 , a t t a c k i n g t h e P R G A s e e m s t o b e i n f e a -
s i b l e ( t h e b e s t k n o w n a t t a c k o n t h i s p a r t r e q u i r e s t i m e t h a t e x c e e d s 2
7 0 0
) . T h e
o n l y p r a c t i c a l r e s u l t s r e l a t e d t o t h e P R G A d e a l w i t h t h e c o n s t r u c t i o n o f d i s -
t i n g u i s h e r s . F l u h r e r a n d M c G r e w d e s c r i b e d i n F M 0 0 ] h o w t o d i s t i n g u i s h R C 4
o u t p u t s f r o m r a n d o m s t r i n g s w i t h 2
3 0
d a t a . A b e t t e r d i s t i n g u i s h e r w h i c h r e -
q u i r e s 2
8
d a t a w a s d e s c r i b e d b y M a n t i n a n d S h a m i r i n M S 0 1 ] . H o w e v e r , t h i s
d i s t i n g u i s h e r c o u l d o n l y b e u s e d t o m o u n t a p a r t i a l a t t a c k o n R C 4 i n b r o a d c a s t
a p p l i c a t i o n s .
T h e f a c t t h a t t h e i n i t i a l i z a t i o n o f R C 4 i s v e r y s i m p l e s t i m u l a t e d c o n s i d e r a b l e
r e s e a r c h o n t h i s m e c h a n i s m o f R C 4 . I n p a r t i c u l a r , R o o s d i s c o v e r e d i n R o o 9 5 ] a
c l a s s o f w e a k k e y s t h a t r e d u c e s t h e i r e e c t i v e s i z e b y v e b i t s , a n d G r o s u l a n d
W a l l a c h s h o w e d i n G W 0 0 ] t h a t f o r l a r g e k e y s w h o s e s i z e i s c l o s e t o N w o r d s ,
R C 4 i s v u l n e r a b l e t o a r e l a t e d k e y a t t a c k .
M o r e a n a l y s i s o f t h e s e c u r i t y o f R C 4 c a n b e f o u n d i n K M P
+
9 8 ] , G o l 9 7 ] a n d
M T 9 8 ] .
2
H e r e a n d i n t h e r e s t o f t h e p a p e r a l l t h e a d d i t i o n s a r e c a r r i e d o u t m o d u l o N
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 4/23
3 T h e I n v a r i a n c e W e a k n e s s
D u e t o s p a c e l i m i t a t i o n s w e p r o v e h e r e t h e i n v a r i a n c e w e a k n e s s o n l y f o r a s i m -
p l i e d v a r i a n t o f t h e K S A , w h i c h w e d e n o t e a s K S A
a n d d e s c r i b e i n F i g u r e 2 .
T h e o n l y d i e r e n c e b e t w e e n t h e m i s t h a t K S A
u p d a t e s i a t t h e b e g i n n i n g o f
t h e l o o p , w h e r e a s K S A u p d a t e s i a t t h e e n d o f t h e l o o p . A f t e r f o r m u l a t i n g a n d
p r o v i n g t h e e x i s t e n c e o f t h i s w e a k n e s s i n K S A
, w e d e s c r i b e t h e m o d i c a t i o n s
r e q u i r e d t o a p p l y t h i s a n a l y s i s t o t h e r e a l K S A .
K S A ( K )
a
F o r i = 0 : : : N 1
S i ] = i
i = 0
j = 0
R e p e a t N t i m e s
j = j + S i ] + K i m o d ̀ ]
S w a p ( S i ] ; S j ] )
i = i + 1
K S A
( K )
F o r i = 0 : : : N 1
S i ] = i
i = 0
j = 0
R e p e a t N t i m e s
i = i + 1
j = j + S i ] + K i m o d ̀ ]
S w a p ( S i ] ; S j ] )
a
K S A i s r e w r i t t e n i n a w a y w h i c h c l a r i e s t h e r e l a t i o n t o K S A
F i g . 2 . K S A v s . K S A
3 . 1 D e n i t i o n s
D e n i t i o n 1 L e t S b e a p e r m u t a t i o n o f f 0 ; : : : ; N 1 g , t b e a n i n d e x i n S a n d
b b e s o m e i n t e g e r . T h e n i f S t ]
m o d b
t , t h e p e r m u t a t i o n S i s s a i d t o b - c o n s e r v e
t h e i n d e x t . O t h e r w i s e , t h e p e r m u t a t i o n S i s s a i d t o b - u n c o n s e r v e t h e i n d e x t .
D e n o t e t h e p e r m u t a t i o n S a n d t h e i n d i c e s i a n d j a f t e r r o u n d t o f K S A
a s S
t
, i
t
a n d j
t
r e s p e c t i v e l y . D e n o t e t h e n u m b e r o f i n d i c e s t h a t a p e r m u t a t i o n b - c o n s e r v e s
a s I
b
( S ) . F o r t h e s a k e o f s i m p l i c i t y , w e o f t e n w r i t e I
t
i n s t e a d o f I
b
( S
t
) .
D e n i t i o n 2 A p e r m u t a t i o n S o f f 0 ; : : : ; N 1 g i s b - c o n s e r v i n g i f I
b
( S ) = N ,
a n d i s a l m o s t b - c o n s e r v i n g i f I
b
( S ) N 2 .
D e n i t i o n 3 L e t b ; ̀ b e i n t e g e r s , a n d l e t K b e a n ̀ w o r d s k e y . T h e n K i s c a l l e d
a b - e x a c t k e y i f f o r a n y i n d e x t K t m o d ̀ ] ( 1 t ) ( m o d b ) . I n c a s e K 0 ] = 1
a n d m s b ( K 1 ] ) = 1 , K i s c a l l e d a s p e c i a l b - e x a c t k e y .
N o t i c e t h a t f o r t h i s c o n d i t i o n t o h o l d , i t i s n e c e s s a r y ( b u t n o t s u c i e n t ) t h a t
b j ̀ .
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 5/23
3 . 2 T h e W e a k n e s s
T h e o r e m 1 L e t q n a n d ̀ b e i n t e g e r s a n d b
d e f
= 2
q
. S u p p o s e t h a t b j ̀ a n d
l e t K b e a b - e x a c t k e y o f ̀ w o r d s . T h e n t h e p e r m u t a t i o n S = K S A
( K ) i s
b - c o n s e r v i n g .
B e f o r e g e t t i n g t o t h e p r o o f i t s e l f , w e w i l l p r o v e a n a u x i l i a r y l e m m a
L e m m a 1 I f i
t + 1
j
t + 1
( m o d b ) , t h e n I
t + 1
= I
t
.
P r o o f : T h e o n l y o p e r a t i o n t h a t m i g h t a e c t S ( a n d m a y b e I ) i s t h e s w a p p i n g o p -
e r a t i o n . H o w e v e r , w h e n i
t + 1
a n d j
t + 1
a r e e q u i v a l e n t ( m o d b ) , S
t + 1
b - c o n s e r v e s
i
t + 1
( j
t + 1
) i f a n d o n l y i f S
t
b - c o n s e r v e d j
t
( i
t
) . T h u s t h e n u m b e r o f i n d i c e s S
b - c o n s e r v e s r e m a i n s t h e s a m e . u t
P r o o f : ( o f T h e o r e m 1 ) W e w i l l p r o v e b y i n d u c t i o n o n t t h a t f o r a n y 1 t N ,
i t t u r n s o u t t h a t I
b
( S
t
) = N a n d i
t
j
t
( m o d b ) . T h i s i n p a r t i c u l a r i m p l i e s t h a t
I
N
= N , w h i c h m a k e s t h e o u t p u t p e r m u t a t i o n b - c o n s e r v i n g .
F o r t = 0 ( b e f o r e t h e r s t r o u n d ) , t h e c l a i m i s t r i v i a l b e c a u s e i
0
= j
0
= 0
a n d S
0
i s t h e i d e n t i t y p e r m u t a t i o n w h i c h i s b - c o n s e r v i n g f o r e v e r y b . S u p p o s e
t h a t j
t
i
t
a n d S
t
i s b - c o n s e r v i n g . T h e n i
t + 1
= i
t
+ 1 a n d
j
t + 1
= j
t
+ S
t
i
t + 1
] + K i
t + 1
m o d ̀ ]
m o d b
i
t
+ i
t + 1
+ ( 1 i
t + 1
) = i
t
+ 1 = i
t + 1
T h u s , i
t + 1
j
t + 1
( m o d b ) a n d b y a p p l y i n g L e m m a 1 w e g e t I
t + 1
= I
t
= N a n d
t h e r e f o r e S
t + 1
i s b - c o n s e r v i n g . u t
K S A
t h u s t r a n s f o r m s s p e c i a l p a t t e r n s i n t h e k e y i n t o c o r r e s p o n d i n g p a t -
t e r n s i n t h e i n i t i a l p e r m u t a t i o n . T h e f r a c t i o n o f d e t e r m i n e d p e r m u t a t i o n b i t s i s
p r o p o r t i o n a l t o t h e f r a c t i o n o f x e d k e y b i t s . F o r e x a m p l e , a p p l y i n g t h i s r e s u l t
t o R C 4
n = 8 ; ̀ = 6
a n d q = 1 , 6 o u t o f t h e 4 8 k e y b i t s c o m p l e t e l y d e t e r m i n e 2 5 2 o u t
o f t h e 1 6 8 4 p e r m u t a t i o n b i t s .
3 . 3 A d j u s t m e n t s t o K S A
T h e s m a l l d i e r e n c e b e t w e e n K S A
a n d K S A ( s e e F i g u r e 2 ) i s e s s e n t i a l i n t h a t
K S A , a p p l i e d t o a b - e x a c t k e y , d o e s n o t p r e s e r v e t h e e q u i v a l e n c e ( m o d b ) o f i
a n d j e v e n a f t e r t h e r s t r o u n d . A n a l y z i n g i t s e x e c u t i o n o n a b - e x a c t k e y g i v e s
j
1
= j
0
+ S
0
i
1
] + K i
1
] = 0 + S
0
0 ] + K 0 ] = K 0 ]
m o d b
1
m o d b
6 0 = i
1
a n d t h u s t h e s t r u c t u r e d e s c r i b e d i n S e c t i o n 3 . 2 c a n n o t b e p r e s e r v e d b y t h e c y c l i c
u s e o f t h e w o r d s o f K . H o w e v e r , t h e i n v a r i a n c e w e a k n e s s c a n b e a d j u s t e d t o t h e
r e a l K S A , a n d t h e p r o p e r m o d i c a t i o n s a r e f o r m u l a t e d i n t h e f o l l o w i n g t h e o r e m :
T h e o r e m 2 L e t q n a n d ̀ b e i n t e g e r s a n d b
d e f
= 2
q
. S u p p o s e t h a t b j ̀ a n d l e t
K b e a s p e c i a l b - e x a c t k e y o f ̀ w o r d s . T h e n
P r K S A ( K ) i s a l m o s t b - c o n s e r v i n g ] 2 = 5
w h e n t h e p r o b a b i l i t y i s o v e r t h e r e s t o f t h e k e y b i t s .
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 6/23
D u e t o s p a c e l i m i t a t i o n s , t h e f o r m a l p r o o f o f t h i s t h e o r e m ( w h i c h i s b a s e d
o n a d e t a i l e d c a s e a n a l y s i s ) w i l l a p p e a r o n l y i n t h e f u l l v e r s i o n o f t h i s p a p e r .
H o w e v e r , w e c a n e x p l a i n t h e i n t u i t i o n b e h i n d t h i s t h e o r e m b y c o n c e n t r a t i n g o n
t h e d i e r e n c e s b e t w e e n T h e o r e m s 1 a n d 2 , w h i c h d e a l w i t h K S A
a n d K S A
r e s p e c t i v e l y . D u r i n g t h e r s t r o u n d , t w o d e v i a t i o n s f r o m K S A
e x e c u t i o n o c -
c u r . T h e r s t o n e i s t h e n o n - e q u i v a l e n c e o f i a n d j w h i c h i s e x p e c t e d t o c a u s e
n o n - e q u i v a l e n t e n t r i e s t o b e s w a p p e d d u r i n g t h e n e x t r o u n d s , t h u s r u i n i n g t h e
d e l i c a t e s t r u c t u r e t h a t w a s p r e s e r v e d s o w e l l d u r i n g K S A
e x e c u t i o n . T h e s e c -
o n d d e v i a t i o n i s t h a t S b - u n c o n s e r v e s t w o o f t h e i n d i c e s , i
1
= 0 a n d j
1
= K 0 ] .
H o w e v e r , w e c a n c a n c e l t h e i j d i s c r e p a n c y b y f o r c i n g K 0 ] ( a n d j
1
) t o 1 . I n t h i s
c a s e , t h e d i s c r e p a n c y i n S j
1
] ( K 1 ] ) c a u s e s a n i m p r o p e r v a l u e t o b e a d d e d t o
j , t h u s r e p a i r i n g i t s n o n - e q u i v a l e n c e t o i d u r i n g t h e s e c o n d r o u n d . A t t h i s p o i n t
t h e r e a r e s t i l l t w o u n c o n s e r v e d i n d i c e s , a n d t h i s a b e r r a t i o n i s d r a g g e d a c r o s s
t h e w h o l e e x e c u t i o n i n t o t h e r e s u l t i n g p e r m u t a t i o n . A l t h o u g h t h e s e c o r r u p t e d
e n t r i e s m i g h t i n t e r f e r e w i t h j u p d a t e s , t h e p s e u d o - r a n d o m j m i g h t r e a c h t h e m
b e f o r e t h e y a r e u s e d t o u p d a t e j ( i . e . , b e f o r e i r e a c h e s t h e m ) , a n d s e n d t h e m i n t o
a r e g i o n i n S w h e r e t h e y c a n n o t a e c t t h e n e x t v a l u e s o f j
3
. T h e p r o b a b i l i t y o f
t h i s l u c k y e v e n t i s a m p l i e d b y t h e f a c t t h a t t h e c o r r u p t e d e n t r i e s a r e i
1
= 0
w h i c h i s n o t t o u c h e d u n t i l t h e t e r m i n a t i o n o f t h e K S A d u e t o i t s d i s t a n c e f r o m
t h e c u r r e n t l o c a t i o n o f i , a n d j
2
= 1 + K 1 ] > N = 2 ( r e c a l l t h a t m s b ( K 1 ] ) = 1 ) ,
t h a t i s f a r f r o m i
1
= 2 , w h i c h g i v e s j m a n y o p p o r t u n i t i e s t o r e a c h i t b e f o r e i
d o e s . T h e p r o b a b i l i t y o f N = 2 p s e u d o r a n d o m j ' s t o r e a c h a n a r b i t r a r y v a l u e c a n
b e b o u n d e d f r o m b e l o w b y 2 / 5 , a n d e x t e n s i v e e x p e r i m e n t a t i o n i n d i c a t e s t h a t
t h i s p r o b a b i l i t y i s a c t u a l l y c l o s e t o o n e h a l f .
4 K e y - O u t p u t C o r r e l a t i o n
I n t h i s s e c t i o n w e w i l l a n a l y z e t h e p r o p a g a t i o n o f t h e w e a k k e y p a t t e r n s i n t o t h e
g e n e r a t e d o u t p u t s . F i r s t w e p r o v e C l a i m 1 w h i c h d e a l s w i t h t h e h i g h l y b i a s e d
b e h a v i o r o f a w e a k e n e d v a r i a n t o f t h e P R G A , a p p l i e d t o a b - c o n s e r v i n g p e r m u -
t a t i o n . N e x t , w e w i l l a r g u e t h a t t h e p r e x o f t h e o u t p u t o f t h e o r i g i n a l P R G A
i s h i g h l y c o r r e l a t e d t o t h e p r e x o f t h e s w a p l e s s v a r i a n t ( o n t h e s a m e i n i t i a l
p e r m u t a t i o n ) , w h i c h i m p l i e s t h e e x i s t e n c e o f b i a s e s i n t h e P R G A d i s t r i b u t i o n
f o r t h e s e w e a k k e y s .
C l a i m 1 L e t R C 4
b e a w e a k e n e d v a r i a n t o f R C 4 w i t h n o s w a p o p e r a t i o n s . L e t
q n , b
d e f
= 2
q
a n d S
0
b e a b - c o n s e r v i n g p e r m u t a t i o n . L e t f X
t
g
1
t = 1
b e t h e o u t p u t
s e q u e n c e g e n e r a t e d b y a p p l y i n g R C 4
t o S
0
, a n d x
t
d e f
= X
t
m o d b . T h e n t h e
s e q u e n c e f x
t
g
1
t = 1
i s c o n s t a n t .
S i n c e t h e r e a r e n o s w a p o p e r a t i o n , t h e p e r m u t a t i o n d o e s n o t c h a n g e a n d r e -
m a i n s b - c o n s e r v i n g t h r o u g h o u t t h e g e n e r a t i o n p r o c e s s . N o t i c e t h a t a l l t h e v a l u e s
3
i f a v a l u e i s p o i n t e d t o b y j b e f o r e t h e s w a p , i t w i l l n o t b e u s e d a s S i ] ( b e f o r e t h e
s w a p ) f o r a t l e a s t N 1 r o u n d s , a n d i n p a r t i c u l a r i t w i l l n o t a e c t t h e v a l u e s o f j
d u r i n g t h e s e r o u n d s .
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 7/23
o f S a r e k n o w n ( m o d b ) , a s w e l l a s t h e i n i t i a l i n d i c e s i = j = 0 0 ( m o d b ) , a n d
t h u s t h e r o u n d o p e r a t i o n ( a n d t h e o u t p u t v a l u e s ) c a n b e s i m u l a t e d ( m o d b ) ,
i n d e p e n d e n t l y o f S . C o n s e q u e n t l y t h e o u t p u t s e q u e n c e ( m o d b ) i s c o n s t a n t , a n d
d e e p e r a n a l y s i s i m p l i e s t h a t i t i s p e r i o d i c w i t h p e r i o d 2 b , a s e x e m p l i e d i n F i g u r e
3 f o r q = 1 .
i j S i ] S j ] S i ] + S j ] O u t
0 0 0 0 0 /
1 1 1 1 0 0
0 1 0 1 1 1
1 0 1 0 1 1
0 0 0 0 0 0
1 1 1 1 0 0
F i g . 3 . T h e r o u n d s o f R C 4
, a p -
p l i e d t o a 2 - c o n s e r v i n g p e r m u t a t i o n
1
s t
w o r d 1 1 1 1
2
n d
w o r d n 3 2 1
3
t h
w o r d n 3 2 1
̀
t h
w o r d n 3 2 1
F i g . 4 . T h e s t a g e i n w h i c h e a c h o n e
o f t h e b i t s i s e x p o s e d d u r i n g t h e r e -
l a t e d k e y a t t a c k
R e c a l l t h a t a t e a c h s t e p o f t h e P R G A , S c h a n g e s i n a t m o s t t w o l o c a t i o n s , a n d
t h u s w e c a n e x p e c t t h e p r e x o f t h e o u t p u t s t r e a m g e n e r a t e d b y R C 4 f r o m s o m e
p e r m u t a t i o n S
0
, t o b e h i g h l y c o r r e l a t e d w i t h t h e s t r e a m g e n e r a t e d f r o m t h e s a m e
S
0
( o r a s l i g h t l y m o d i e d o n e ) b y R C 4
. I n p a r t i c u l a r t h e s t r e a m g e n e r a t e d b y
R C 4 f r o m a n a l m o s t b - c o n s e r v i n g p e r m u t a t i o n i s e x p e c t e d t o b e h i g h l y c o r r e l a t e d
w i t h t h e c o n s t a n t s u b s t r e a m f x
t
g f r o m C l a i m 1 . T h i s c o r r e l a t i o n i s d e m o n s t r a t e d
i n F i g u r e 8 , w h e r e t h e f u n c t i o n h ! P r 1 8 t h Z
t
x
t
m o d 2
q
] ( f o r s p e c i a l
2
q
- e x a c t k e y s ) i s e m p i r i c a l l y e s t i m a t e d f o r n = 8 , ̀ = 1 6 a n d d i e r e n t q ' s . F o r
e x a m p l e , a s p e c i a l 2 - e x a c t k e y c o m p l e t e l y d e t e r m i n e s 2 0 o u t p u t b i t s ( t h e l s b ' s
o f t h e r s t 2 0 o u t p u t s ) w i t h p r o b a b i l i t y 2
4 2
i n s t e a d o f 2
2 0
, a n d a s p e c i a l
1 6 - e x a c t k e y c o m p l e t e l y d e t e r m i n e s 4 0 o u t p u t b i t s ( 4 l s b ' s f r o m e a c h o f t h e r s t
1 0 o u t p u t s ) w i t h p r o b a b i l i t y 2
2 3
, i n s t e a d o f 2
4 0
.
W e h a v e t h u s d e m o n s t r a t e d a s t r o n g p r o b a b i l i s t i c c o r r e l a t i o n b e t w e e n s o m e
b i t s o f t h e s e c r e t k e y a n d s o m e b i t s o f t h e o u t p u t s t r e a m f o r a l a r g e c l a s s o f w e a k
k e y s . I n t h e n e x t s e c t i o n w e d e s c r i b e h o w t o u s e t h i s c o r r e l a t i o n t o c r y p t a n a l y z e
R C 4 .
5 C r y p t a n a l y t i c A p p l i c a t i o n s o f t h e I n v a r i a n c e W e a k n e s s
5 . 1 D i s t i n g u i s h i n g R C 4 S t r e a m s f r o m R a n d o m n e s s
I n M S 0 1 ] M a n t i n a n d S h a m i r d e s c r i b e d a s i g n i c a n t s t a t i s t i c a l b i a s i n t h e s e c -
o n d o u t p u t w o r d o f R C 4 . T h e y u s e d t h i s b i a s t o c o n s t r u c t a n e c i e n t a l g o r i t h m
w h i c h d i s t i n g u i s h e s b e t w e e n R C 4 o u t p u t s a n d t r u l y r a n d o m s e q u e n c e s b y a n a -
l y z i n g o n l y o n e w o r d f r o m O ( N ) d i e r e n t o u t p u t s s t r e a m s . T h i s i s a n e x t r e m e l y
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 8/23
e c i e n t d i s t i n g u i s h e r , b u t i t c a n b e e a s i l y a v o i d e d b y d i s c a r d i n g t h e r s t t w o
w o r d s f r o m e a c h o u t p u t s t r e a m . I f t h e s e t w o w o r d s a r e d i s c a r d e d , t h e b e s t k n o w n
d i s t i n g u i s h e r r e q u i r e s a b o u t 2
3 0
o u t p u t w o r d s ( s e e F M 0 0 ] ) . O u r n e w o b s e r v a t i o n
y i e l d s a s i g n i c a n t l y b e t t e r d i s t i n g u i s h e r f o r m o s t o f t h e t y p i c a l k e y s i z e s . T h e
n e w d i s t i n g u i s h e r i s b a s e d o n t h e f a c t t h a t f o r a s i g n i c a n t f r a c t i o n o f k e y s , a
s i g n i c a n t n u m b e r o f i n i t i a l o u t p u t w o r d s c o n t a i n a n e a s i l y r e c o g n i z a b l e p a t t e r n .
T h i s b i a s i s a t t e n e d w h e n t h e k e y s a r e c h o s e n f r o m a u n i f o r m d i s t r i b u t i o n , b u t
i t d o e s n o t c o m p l e t e l y d i s a p p e a r a n d c a n b e u s e d t o c o n s t r u c t a n e c i e n t d i s -
t i n g u i s h e r e v e n w h e n t h e r s t t w o w o r d s o f e a c h o u t p u t s e q u e n c e a r e d i s c a r d e d .
N o t i c e t h a t t h e p r o b a b i l i t y o f a s p e c i a l 2
q
- e x a c t k e y t o b e t r a n s f o r m e d i n t o a
2
q
- c o n s e r v i n g p e r m u t a t i o n , d o e s n o t d e p e n d o f t h e k e y l e n g t h ̀ ( s e e T h e o r e m 2 ) .
H o w e v e r , t h e n u m b e r o f p r e d e t e r m i n e d b i t s i s l i n e a r i n ̀ , a n d c o n s e q u e n t l y t h e
s i z e o f t h i s b i a s ( a n d t h u s t h e n u m b e r o f r e q u i r e d o u t p u t s ) a l s o d e p e n d s o n ̀ . I n
F i g u r e 5 w e s p e c i f y t h e q u a n t i t y o f d a t a r e q u i r e d f o r a r e l i a b l e d i s t i n g u i s h e r , f o r
d i e r e n t k e y s i z e s . I n p a r t i c u l a r , f o r 6 4 b i t k e y s t h e n e w d i s t i n g u i s h e r r e q u i r e s
o n l y 2
2 1
d a t a i n s t e a d o f t h e p r e v i o u s l y b e s t n u m b e r o f 2
3 0
o u t p u t w o r d s .
I t i s i m p o r t a n t t o n o t i c e t h a t t h e s p e c i e d o u t p u t p a t t e r n s e x t e n d o v e r s e v e r a l
d o z e n o u t p u t w o r d s , a n d t h u s t h e q u a l i t y o f t h e d i s t i n g u i s h e r i s a l m o s t u n a e c t e d
b y d i s c a r d i n g t h e r s t f e w w o r d s . F o r e x a m p l e , d i s c a r d i n g t h e r s t t w o w o r d s
c a u s e s t h e d a t a r e q u i r e d f o r t h e d i s t i n g u i s h e r t o g r o w b y a f a c t o r o f b e t w e e n 2
0 5
a n d 2
2
( d e p e n d i n g o n ̀ ) . A n o t h e r i m p o r t a n t o b s e r v a t i o n i s t h a t t h e b i a s e s i n t h e
l s b ' s d i s t r i b u t i o n c a n b e c o m b i n e d i n a n a t u r a l w a y w i t h t h e b i a s e d d i s t r i b u t i o n
o f t h e l s b ' s o f E n g l i s h t e x t s i n t o a n e c i e n t d i s t i n g u i s h e r o f R C 4 s t r e a m s f r o m
r a n d o m n e s s i n a c i p h e r t e x t - o n l y a t t a c k i n w h i c h t h e a t t a c k e r d o e s n o t k n o w t h e
a c t u a l E n g l i s h p l a i n t e x t w h i c h w a s e n c r y p t e d b y R C 4 . T h i s t y p e o f d i s t i n g u i s h e r s
i s d i s c u s s e d i n A p p e n d i x B .
5 . 2 R C 4 h a s L o w S a m p l i n g R e s i s t a n c e
B i r y u k o v , S h a m i r a n d W a g n e r d e n e d i n B S W 0 0 ] a n e w s e c u r i t y m e a s u r e o f
s t r e a m c i p h e r s , w h i c h t h e y d e n o t e d a s t h e i r S a m p l i n g R e s i s t a n c e . T h e s t r o n g
c o r r e l a t i o n b e t w e e n c l a s s e s o f R C 4 k e y s a n d c o r r e s p o n d i n g o u t p u t p a t t e r n s c a n
b e u s e d t o p r o v e t h a t R C 4 h a s r e l a t i v e l y l o w s a m p l i n g r e s i s t a n c e , w h i c h i m p r o v e s
t h e e c i e n c y o f t i m e / m e m o r y / d a t a t r a d e o a t t a c k s . F u r t h e r d e t a i l s c a n b e f o u n d
i n A p p e n d i x C .
6 R C 4 K e y S e t u p a n d t h e F i r s t W o r d O u t p u t
I n t h i s s e c t i o n , w e c o n s i d e r r e l a t e d k e y a t t a c k s w h e r e t h e a t t a c k e r h a s a c c e s s t o
t h e v a l u e s o f a l l t h e b i t s o f c e r t a i n w o r d s o f t h e k e y . I n p a r t i c u l a r , w e c o n s i d e r t h e
c a s e w h e r e t h e k e y p r e s e n t e d t o t h e K S A i s m a d e u p o f a s e c r e t k e y c o n c a t e n a t e d
w i t h a n a t t a c k e r v i s i b l e v a l u e ( w h i c h w e w i l l r e f e r t o a s a n I n i t i a l i z a t i o n V e c t o r
o r I V ) . W e w i l l s h o w t h a t i f t h e s a m e s e c r e t k e y i s u s e d w i t h n u m e r o u s d i e r e n t
i n i t i a l i z a t i o n v e c t o r s , a n d t h e a t t a c k e r c a n o b t a i n t h e r s t w o r d o f R C 4 o u t p u t
c o r r e s p o n d i n g t o e a c h i n i t i a l i z a t i o n v e c t o r , h e c a n r e c o n s t r u c t t h e s e c r e t k e y w i t h
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 9/23
m i n i m a l e o r t . H o w o f t e n h e c a n d o t h i s , t h e a m o u n t o f e o r t a n d t h e n u m b e r
o f i n i t i a l i z a t i o n v e c t o r s r e q u i r e d d e p e n d s o n t h e o r d e r o f t h e c o n c a t e n a t i o n , t h e
s i z e o f t h e I V , a n d s o m e t i m e s o n t h e v a l u e o f t h e s e c r e t k e y . T h i s o b s e r v a t i o n i s
e s p e c i a l l y i n t e r e s t i n g , a s t h i s m o d e o f o p e r a t i o n i s u s e d b y s e v e r a l c o m m e r c i a l l y
d e p l o y e d e n c r y p t i o n s y s t e m s ( R e i 0 1 ] , L M S o n ] ) a n d t h e r s t w o r d o f p l a i n t e x t s
i s o f t e n a n e a s i l y g u e s s e d c o n s t a n t s u c h a s t h e d a t e , t h e s e n d e r ' s i d e n t i t y , e t c , a n d
t h u s t h e a t t a c k i s p r a c t i c a l e v e n i n a c i p h e r t e x t - o n l y m o d e o f a t t a c k . H o w e v e r ,
t h e w e a k n e s s d o e s n o t e x t e n d t o t h e S e c u r e S o c k e t L a y e r p r o t o c o l t h a t b r o w s e r s
u s e .
I n t e r m s o f k e y s t r e a m o u t p u t , t h i s a t t a c k i s i n t e r e s t e d o n l y i n t h e r s t w o r d
o f o u t p u t f r o m a n y g i v e n s e c r e t k e y a n d I V . H e n c e , w e c a n s i m p l i f y o u r m o d e l
o f t h e o u t p u t . T h e r s t o u t p u t w o r d d e p e n d s o n l y o n t h r e e s p e c i c p e r m u t a t i o n
e l e m e n t s , a s s h o w n i n t h e g u r e b e l o w s h o w i n g t h e s t a t e o f t h e p e r m u t a t i o n
i m m e d i a t e l y a f t e r K S A . W h e n t h o s e t h r e e w o r d s a r e a s s h o w n , t h e v a l u e l a b e l e d
Z w i l l b e o u t p u t a s t h e r s t w o r d .
1 X X + Y
X Y Z
I n a d d i t i o n , i f t h e k e y s e t u p r e a c h e s a s t a g e w h e r e i i s g r e a t e r t h a n o r e q u a l
t o 1 , X = S
i
1 ] a n d X + Y = S
i
1 ] + S
i
S
i
1 ] ] , t h e n ( i f w e m o d e l t h e r e m a i n i n g
s w a p s i n t h e k e y s e t u p a s r a n d o m ) w i t h p r o b a b i l i t y g r e a t e r t h a n e
3
0 : 0 5 ,
n o n e o f t h e e l e m e n t s r e f e r e n c e d b y t h e s e t h r e e v a l u e s w i l l p a r t i c i p a t e i n a n y
f u r t h e r s w a p s , a n d i n t h a t c a s e , t h e v a l u e S S 1 ] + S S 1 ] ] ] w i l l b e o u t p u t a s t h e
r s t w o r d . W i t h p r o b a b i l i t y l e s s t h a n 1 e
3
0 : 9 5 , a t l e a s t o n e o f t h e t h r e e
v a l u e s w i l l p a r t i c i p a t e i n a s w a p , a n d b e s e t t o a n e e c t i v e l y r a n d o m v a l u e , w h i c h
w i l l m a k e t h e o u t p u t v a l u e e e c t i v e l y r a n d o m . W e w i l l r e f e r t o t h i s s i t u a t i o n a s
t h e r e s o l v e d c o n d i t i o n . O u r a t t a c k i n v o l v e s e x a m i n i n g m e s s a g e s w i t h s p e c i c I V
v a l u e s s u c h t h a t , a t s o m e p o i n t , t h e K S A i s i n a r e s o l v e d c o n d i t i o n , a n d w h e r e
t h e v a l u e o f S S 1 ] + S S 1 ] ] ] g i v e s u s i n f o r m a t i o n o n t h e s e c r e t k e y . T h e n , w e
o b s e r v e s u c i e n t l y m a n y I V v a l u e s t h a t t h e a c t u a l v a l u e o f S S 1 ] + S S 1 ] ] ]
o c c u r s d e t e c t a b l y o f t e n .
7 D e t a i l s o f t h e K n o w n I V A t t a c k
7 . 1 I V P r e c e d e s t h e S e c r e t K e y
F i r s t c o n s i d e r t h e c a s e w h e r e t h e I V i s p r e p e n d e d t o t h e s e c r e t k e y . I n t h i s c i r c u m -
s t a n c e , a s s u m i n g w e h a v e a n I w o r d I V , a n d a s e c r e t k e y ( K 0 ] ; K 1 ] ; : : : K ̀ 1 ] ) ,
w e a t t e m p t t o d e r i v e i n f o r m a t i o n o n a p a r t i c u l a r w o r d B o f t h e s e c r e t k e y ( K B ] )
b y s e a r c h i n g f o r I V v a l u e s s u c h t h a t , a f t e r t h e r s t I s t e p s , S
I
1 ] < I a n d
S
I
1 ] + S
I
S
I
1 ] ] = I + B . T h e n , w i t h h i g h l i k e l i h o o d ( p r o b a b i l i t y e
2 B
N
i f w e
m o d e l t h e i n t e r m e d i a t e s w a p s a s r a n d o m ) , w e w i l l b e i n a r e s o l v e d c o n d i t i o n
a f t e r s t e p I + B , a n d t h e n t h e m o s t p r o b a b l e o u t p u t v a l u e w i l l b e
O u t = S
I + B 1
j
I + B
] = S
I + B 1
j
I + B 1
+ K B ] + S
I + B 1
I + B ] ]
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 10/23
O r , i n o t h e r w o r d s , i f w e k n o w t h e v a l u e o f j
I + B 1
a n d S
I + B 1
, t h e n g i v e n t h e
r s t w o r d o u t p u t O u t , w e c a n p r e d i c t t h e v a l u e
K B ] = S
1
I + B 1
O u t ] j
I + B 1
S
I + B 1
I + B ]
w h e r e S
1
t
X ] d e n o t e s t h e l o c a t i o n w i t h i n t h e p e r m u t a t i o n S
t
w h e r e t h e v a l u e
X a p p e a r s . T h i s p r e d i c t i o n i s a c c u r a t e m o r e t h a n 5 % o f t h e t i m e , a n d e e c t i v e l y
r a n d o m l e s s t h a n 9 5 % o f t h e t i m e . B y c o l l e c t i n g s u c i e n t l y m a n y v a l u e s f r o m
d i e r e n t I V s , w e c a n r e c o n s t r u c t K B ] .
I n t h e s i m p l e s t s c e n a r i o ( 3 w o r d c h o s e n I V s ) , t h e a t t a c k w o r k s a s f o l l o w s
4
:
s u p p o s e t h a t w e k n o w t h e r s t A w o r d s o f t h e s e c r e t k e y ( K 3 ] ; : : : ; K A + 2 ] ,
w i t h A = 0 i n i t i a l l y ) , a n d w e w a n t t o k n o w t h e n e x t w o r d K A + 3 ] . W e e x a m -
i n e a s e r i e s o f I V s o f t h e f o r m ( A + 3 ; N 1 ; X ) f o r a p p r o x i m a t e l y 6 0 d i e r e n t
v a l u e s f o r X . A t t h e r s t s t e p , j i s a d v a n c e d b y A + 3 , a n d t h e n S i ] a n d S j ]
a r e s w a p p e d , r e s u l t i n g i n t h e k e y s e t u p s t a t e w h i c h i s s h o w n s c h e m a t i c l y b e l o w ,
w h e r e t h e t o p a r r a y i s t h e c o m b i n e d I V a n d s e c r e t k e y p r e s e n t e d t o t h e K S A ,
a n d t h e b o t t o m a r r a y i s a p o r t i o n o f t h e p e r m u t a t i o n , a n d w h e r e t h e p o s i t i o n s
o f t h e i , j v a r i a b l e s a r e i n d i c a t e d .
A + 3 N 1 X K 3 ] K A + 3 ]
0 1 2 A + 3
A + 3 1 2 0
i
0
j
0
T h e n , o n t h e n e x t s t e p , i i s a d v a n c e d , a n d t h e n t h e a d v a n c e o n j i s c o m p u t e d ,
w h i c h h a p p e n s t o b e 0 . T h e n , S i ] a n d S j ] a r e s w a p p e d , r e s u l t i n g i n t h e b e l o w
s t r u c t u r e :
A + 3 N 1 X K 3 ] K A + 3 ]
0 1 2 A + 3
A + 3 0 2 1
i
1
j
1
T h e n , o n t h e n e x t s t e p , j i s a d v a n c e d b y X + 2 , w h i c h i m p l i e s t h a t e a c h d i s -
t i n c t I V a s s i g n s a d i e r e n t v a l u e t o j , a n d t h u s b e y o n d t h i s p o i n t , e a c h I V a c t s
d i e r e n t l y , a p p r o x i m a t i n g t h e r a n d o m n e s s a s s u m p t i o n m a d e a b o v e . S i n c e t h e
a t t a c k e r k n o w s t h e v a l u e o f X a n d K 3 ] ; : : : K A + 2 ] , h e c a n c o m p u t e t h e e x a c t
b e h a v i o r o f t h e k e y s e t u p u n t i l h e r e a c h e s s t e p A + 3 . A t t h i s p o i n t , h e k n o w s
t h e v a l u e o f j
A + 2
a n d t h e e x a c t v a l u e s o f t h e p e r m u t a t i o n S
A + 2
. I f t h e v a l u e a t
S
A + 2
0 ] o r S
A + 2
1 ] h a s b e e n d i s t u r b e d , t h e a t t a c k e r d i s c a r d s t h i s I V . O t h e r w i s e ,
j i s a d v a n c e d b y S
A + 2
i ] + K A + 3 ] , a n d t h e n t h e s w a p i s d o n e , r e s u l t i n g i n t h e
b e l o w s t r u c t u r e :
A + 3 N 1 X K 3 ] K A + 3 ]
0 1 2 A + 3
A + 3 0 S 2 ] S j ]
i
A + 3
4
T h i s s c e n a r i o w a s r s t p u b l i s h e d b y W a g n e r i n W a g 9 5 ]
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 11/23
T h e a t t a c k e r k n o w s t h e p e r m u t a t i o n S
A + 2
a n d t h e v a l u e o f j
A + 2
. I n a d d i t i o n , i f
h e k n o w s t h e v a l u e o f S
A + 3
A + 3 ] , h e k n o w s i t s l o c a t i o n i n S
A + 2
, w h i c h i s t h e
v a l u e o f j
A + 3
, a n d h e n c e h e w o u l d b e a b l e t o c o m p u t e K A + 3 ] . W e a l s o n o t e
t h a t i
A + 3
h a s n o w s w e p t p a s t 1 , S
A + 3
1 ] a n d S
A + 3
1 ] + S
A + 3
S
A + 3
1 ] ] , a n d t h u s
t h e r e s o l v e d c o n d i t i o n e x i s t s , a n d h e n c e w i t h p r o b a b i l i t y p > 0 : 0 5 , b y e x a m i n i n g
t h e v a l u e o f t h e r s t w o r d o f R C 4 o u t p u t w i t h t h i s I V , t h e a t t a c k e r w i l l o b t a i n
t h e c o r r e c t v a l u e o f K A + 3 ] . H e n c e , b y e x a m i n i n g a p p r o x i m a t e l y 6 0 I V s w i t h
t h e a b o v e c o n g u r a t i o n , t h e a t t a c k e r c a n r e d e r i v e K A ] w i t h a p r o b a b i l i t y o f
s u c c e s s g r e a t e r t h a n 0 . 5 .
B y i t e r a t i n g t h e a b o v e p r o c e s s a c r o s s t h e s e c r e t k e y , t h e a t t a c k e r c a n r e d e r i v e
̀ w o r d s o f s e c r e t k e y u s i n g 6 0 ̀ c h o s e n 3 w o r d I V s .
T h e n e x t t h i n g t o n o t e i s t h a t t h e a t t a c k w o r k s f o r I V s o t h e r t h a n t h o s e i n
t h e s p e c i c ( A + 3 ; N 1 ; X ) f o r m . A n y I w o r d I V t h a t , a f t e r I s t e p s , l e a v e s
S
I
1 ] < I a n d S
I
1 ] + S
I
S
I
1 ] ] = I + B w i l l s u c e f o r t h e a b o v e a t t a c k . I n
a d d i t i o n , s i n c e t h e a t t a c k e r i s a b l e t o s i m u l a t e t h e r s t I s t e p s o f t h e k e y s e t u p ,
h e i s a b l e t o d e t e r m i n e w h i c h I V s h a v e t h i s p r o p e r t y . B y e x a m i n i n g a l l I V s t h a t
h a v e t h i s p r o p e r t y , w e c a n e x t e n d t h i s i n t o a k n o w n I V a t t a c k , w i t h o u t u s i n g
a n e x c e s s i v e n u m b e r o f I V s . T h e p r o b a b i l i t i e s t o n d t h e n e x t w o r d , a n d t h e
e x p e c t e d n u m b e r o f I V s n e e d e d t o o b t a i n 6 0 I V s o f t h e p r o p e r f o r m , a r e g i v e n
i n F i g u r e 6 a t t h e e n d o f t h i s p a p e r .
7 . 2 I V F o l l o w s t h e S e c r e t K e y
I n t h e c a s e t h a t t h e I V i s a p p e n d e d t o t h e s e c r e t k e y , w e n e e d t o t a k e a d i e r e n t
a p p r o a c h . T h e p r e v i o u s a n a l y s i s a t t a c k e d i n d i v i d u a l k e y w o r d s . W h e n t h e I V
f o l l o w s t h e s e c r e t k e y , w h a t w e d o i n s t e a d i s s e l e c t I V s t h a t g i v e u s t h e s t a t e o f
t h e p e r m u t a t i o n a t a n e a r l y p h a s e o f t h e k e y s e t u p , s u c h a s i m m e d i a t e l y a f t e r
t h e s e c r e t k e y h a s b e e n u s e d f o r t h e r s t t i m e . G i v e n t h a t o n l y a f e w s w a p s
h a v e o c c u r r e d u p t o t h a t p o i n t , i t i s r e a s o n a b l y s t r a i g h t - f o r w a r d t o r e c o n s t r u c t
t h o s e s w a p s f r o m t h e p e r m u t a t i o n s t a t e , a n d h e n c e o b t a i n t h e s e c r e t k e y ( s e e
A p p e n d i x D f o r o n e s u c h m e t h o d ) .
T o i l l u s t r a t e t h e a t t a c k i n t h e s i m p l e s t c a s e , s u p p o s e w e h a v e a n A w o r d
s e c r e t k e y , a n d a 2 w o r d I V . F u r t h e r s u p p o s e t h a t t h e s e c r e t k e y w a s w e a k i n
t h e s e n s e t h a t , i m m e d i a t e l y a f t e r A s t e p s o f K S A , S
A
1 ] = X , X < A , a n d
X + S
A
X ] = A . T h i s i s a l o w p r o b a b i l i t y e v e n t ( p 0 : 0 0 0 6 2 i f A = 1 3 ) ,
b u t i t d e p e n d s o n l y o n t h e s e c r e t k e y . F o r s u c h a w e a k s e c r e t k e y , t h e a t t a c k e r
c a n a s s u m e t h e v a l u e o f j
A 1
+ S
A 1
A ] , a n d t h e n e x a m i n e I V s w i t h a r s t
w o r d o f W = Y ( j
A 1
+ S
A 1
A ] ) . W i t h s u c h I V s , t h e v a l u e o f j
A
w i l l b e t h e
p r e s e l e c t e d v a l u e Y . T h e n , S A ] a n d S Y ] a r e s w a p p e d , a n d s o S
A
A ] = A
A 1
Y ] .
H e r e , a s s u m i n g Y w a s n e i t h e r 1 n o r S
A
1 ] , t h e n t h e r e s o l v e d c o n d i t i o n h a s b e e n
e s t a b l i s h e d , a n d w i t h p r o b a b i l i t y > 0 : 0 5 , S
A 1
Y ] w i l l b e t h e r s t w o r d o u t p u t .
T h e n , b y e x a m i n i n g s u c h I V s w i t h t h e s e c o n d w o r d b e i n g a t l e a s t 6 0 d i e r e n t
v a l u e s , w e c a n o b s e r v e t h e o u t p u t a n u m b e r o f t i m e s a n d d e r i v e t h e v a l u e o f
S
A
Y ] w i t h g o o d p r o b a b i l i t y . B y s e l e c t i n g a l l p o s s i b l e v a l u e s o f Y , w e c a n d i r e c t l y
o b s e r v e t h e s t a t e o f t h e S
A
p e r m u t a t i o n , f r o m w h i c h w e c a n r e d e r i v e t h e s e c r e t
k e y . W e w i l l d e n o t e t h i s r e s u l t a s k e y r e c o v e r y .
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 12/23
I f X + S
A
X ] = A + 1 , a s i m i l a r a n a l y s i s w o u l d a p p e a r t o a p p l y . B y a s s u m i n g
S
A
A ] , S
A
A + 1 ] a n d j
A
, w e c a n s w a p S
A + 1
Y ] i n t o S
A + 2
A + 1 ] f o r N 2
d i s t i n c t I V s f o r a n y p a r t i c u l a r Y . H o w e v e r , t h e v a l u e o f j
A + 2
i s a l w a y s t h e s a m e
f o r a n y p a r t i c u l a r Y , a n d s o t h e p r o b a b i l i t i e s t h a t a p a r t i c u l a r I V o u t p u t s t h e
v a l u e S Y ] i s n o t i n d e p e n d e n t l y d i s t r i b u t e d . T h i s e e c t c a u s e s t h e r e a d i n g o f t h e
p e r m u t a t i o n s t a t e t o b e ' n o i s y ' , t h a t i s , f o r s o m e v a l u e s o f Y , w e s e e S Y ] a s t h e
r s t w o r d f a r m o r e o f t e n t h a n o u r a n a l y s i s e x p e c t e d , a n d f o r o t h e r v a l u e s o f Y ,
w e s e e i t f a r l e s s o f t e n . B e c a u s e o f t h i s , s o m e o f t h e e n t r i e s S
A + 1
Y ] c a n n o t b e
r e l i a b l y r e c o v e r e d . S i m u l a t i o n s a s s u m i n g a 1 3 w o r d s e c r e t k e y a n d n = 8 h a v e
s h o w n t h a t a n a v e r a g e o f 1 7 1 w o r d s o f t h e S
A
p e r m u t a t i o n s t a t e c a n b e s u c -
c e s s f u l l y r e c o n s t r u c t e d , i n c l u d i n g a n a v e r a g e o f 8 w o r d s o f ( S
A
0 ] ; : : : ; S
A
1 2 ] ) ,
w h i c h i m m e d i a t e l y g i v e y o u e e c t i v e l y 8 k e y w o r d s . W i t h t h i s i n f o r m a t i o n , t h e
k e y i s r e d u c e d e n o u g h t h a t i t c a n b e b r u t e f o r c e d . W e w i l l d e n o t e t h i s r e s u l t a s
k e y r e d u c t i o n .
I f w e h a v e a 3 w o r d I V , t h e n t h e r e a r e m o r e t y p e s o f w e a k s e c r e t k e y s . F o r
e x a m p l e , c o n s i d e r a s e c r e t k e y w h e r e S
A
1 ] = 1 a n d S
A
A ] = A . T h e n , b y a s -
s u m i n g j
A
, w e c a n e x a m i n e I V w h e r e t h e r s t w o r d h a s a v a l u e W s o t h a t t h e
n e w v a l u e o f j
A + 1
i s 1 , a n d s o S
A
1 ] a n d S
A
A ] a r e s w a p p e d , l e a v i n g t h e s t a t e
a f t e r A + 1 s t e p s t o b e :
K 0 ] K 1 ] K A 1 ] W X Z
0 1 A 1 A A + 1 A + 2
S
A
0 ] A S
A
A 1 ] 1 S
A
A + 1 ] S
A
A + 2 ]
j
A + 1
i
A + 1
T h e n , b y a s s u m i n g S
A
A + 1 ] ( w h i c h w i t h h i g h p r o b a b i l i t y i s A + 1 , a n d
w i l l a l w a y s b e a t m o s t A + 1 ) , w e c a n e x a m i n e I V s w i t h t h e s e c o n d w o r d X =
Y ( 1 + S
A
A + 1 ] ) , f o r a n a r b i t r a r y Y , w h i c h w i l l s w a p t h e v a l u e o f S
A
Y ]
i n t o S
A + 1
A + 1 ] . A s s u m i n g Y i s n ' t e i t h e r 1 o r A , t h e n t h e r e s o l v e d c o n d i t i o n
h a v e b e e n s e t u p , a n d u s i n g a n u m b e r o f v a l u e s f o r t h e t h i r d I V w o r d Z , w e c a n
d e d u c e t h e v a l u e o f S
A + 1
Y ] f o r a n a r b i t r a r y Y , g i v i n g u s t h e p e r m u t a t i o n a f t e r
A s t e p s .
T h e r e a r e a n u m b e r o f o t h e r t y p e s o f w e a k k e y s t h a t t h e a t t a c k e r c a n t a k e
a d v a n t a g e o f , s u m m a r i z e d i n F i g u r e 7 f o u n d a t t h e e n d o f t h i s p a p e r .
T h e l a s t w e a k s e c r e t k e y l i s t e d i n F i g u r e 7 i s e s p e c i a l l y i n t e r e s t i n g , i n t h a t
t h e t e c h n i q u e t h a t e x p o s e s t h e w e a k n e s s i s r a t h e r d i e r e n t t h a n t h a t o f t h e o t h e r
w e a k s e c r e t k e y s l i s t e d . I m m e d i a t e l y a f t e r A s t e p s , t h e s t a t e i s :
K 0 ] K 1 ] K X ] W Z
0 1 X A A + 1
S
A
0 ] X S
A
X ] Z S
A
A + 1 ]
i
A
T h e i n i t i a l I V w o r d c a u s e s S
A
X ] a n d S
A
A ] t o b e s w a p p e d , l e a v i n g t h e s t a t e
a s :
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 13/23
K 0 ] K 1 ] K X ] W Z
0 1 X A A + 1
S
A
0 ] X Z S
A
X ] S
A
A + 1 ]
i
A
N o w , t o i n q u i r e a b o u t t h e v a l u e o f S
X + Z
Y + C o n s t ] , w e e x a m i n e n u m e r o u s
I V s w i t h s e c o n d a n d t h i r d w o r d s t h a t a l l s e t t h e v a l u e o f j
A + 3
t o b e Y . T h e K S A
w i l l c o n t i n u e f o r X + Z ( A + 3 ) m o r e s t e p s u n t i l i n o w p o i n t s t o t h e e l e m e n t
S
X + Z
X + Z ] . A t t h i s p o i n t , s i n c e w e h a v e n ' t g o n e t h r o u g h a g r e a t n u m b e r o f
s t e p s s i n c e w e k n e w t h e v a l u e o f j ( s i n c e X + Z ( A + 3 ) A 4 ) , t h e n w i t h h i g h
p r o b a b i l i t y , j
X + Z + 1
= Y + C o n s t , w h e r e C o n s t i s a c o n s t a n t t e r m t h a t d e p e n d s
o n l y o n t h e s t a t e o f t h e p e r m u t a t i o n S
A + 1
. I f t h i s i s t r u e , t h e n S
X + Z + 1
X + Z ] =
S
X + Z
Y + c o n s t ] , a n d i f t h e e l e m e n t s S 1 ] a n d S X ] h a v e n o t b e e n d i s t u r b e d
( a g a i n , t h i s h a p p e n s w i t h h i g h p r o b a b i l i t y ) , t h e r e s o l v e d c o n d i t i o n h a s b e e n
a c h i e v e d , a n d t h e r s t o u t p u t w o r d w i l l b e b i a s e d t o w a r d s S
X + Z
Y + c o n s t ] .
I n a d d i t i o n , b e c a u s e t h e v a l u e o f c o n s t w i l l b e t h e s a m e i n d e p e n d e n t o f Y , i t s
v a l u e c a n e a s i l y b e d e t e r m i n e d , t h u s a l l o w i n g t h e a t t a c k e r t o o b s e r v e m a n y o f
t h e v a l u e s o f S
X + Z
. T h i s c l a s s o f w e a k k e y s r e q u i r e s f a r m o r e k n o w n I V s t o
e x p l o i t , b u t a l s o o c c u r s r e l a t i v e l y f r e q u e n t l y .
I f w e h a v e a 4 w o r d
5
I V , t h e n t h e s a m e g e n e r a l a p p r o a c h a s t h e p r e v i o u s
a n a l y s i s c a n b e u s e d t o r e c o v e r v i r t u a l l y a l l s e c r e t k e y s , g i v e n s u c i e n t I V s . F i r s t ,
w e a s s u m e j
A 1
, S
A 1
A ] , S
A 1
A + 1 ] , S
A 1
A + 2 ] , S
A 1
A + 3 ]
6
. T h e n , b a s e d
o n t h i s a s s u m p t i o n , w e s e a r c h f o r I V s t h a t , a f t e r A + 4 s t e p s , s e t s S
A + 4
1 ] = X
a n d S
A + 4
X ] = Z f o r X ; Z < A + 4 ; X + Z A + 4 , a n d w e n o t e t h e v a l u e o f
j
A + 4
= Y . T h e n , w e s a v e t h e v a l u e o f X + Z , t h e v a l u e Y a n d t h e v a l u e o u t p u t
a s t h e r s t w o r d f o r t h a t p a r t i c u l a r I V . W i t h n o n t r i v i a l p r o b a b i l i t y , t h e v a l u e o f
t h i s w o r d w i l l b e S
X + Z
Y + c o n s t
X + Z
] , w h e r e c o n s t
X + Z
i s a c o n s t a n t t e r m t h a t
d e p e n d s o n t h e s e c r e t k e y , a n d t h e v a l u e X + Z . S i n c e t h a t v a l u e i s i n d e p e n d e n t
o f t h e I V , w e c a n c o l l e c t n u m e r o u s p o s s i b l e v a l u e s o f S
X + Z
Y + c o n s t
X + Z
] f o r
v a r i o u s v a l u e s o f X + Z , a n d u s e t h a t t o r s t r e c o n s t r u c t c o n s t
X + Z
, a n d t h e n
r e c o n s t r u c t S
X + Z
.
8 R e l a t e d - K e y A t t a c k s o n R C 4
I n t h i s s e c t i o n , w e d i s c u s s t w o r e l a t e d - k e y a t t a c k s b a s e d o n w e a k n e s s e s d i s c u s s e d
p r e v i o u s l y i n t h i s p a p e r . T h e y w o r k w i t h i n t h e f o l l o w i n g m o d e l : t h e a t t a c k e r i s
g i v e n a b l a c k b o x t h a t h a s a r a n d o m l y c h o s e n R C 4 k e y K i n s i d e i t , a n o u t p u t
b u t t o n a n d a n i n p u t t a p e o f j K j w o r d s . I n e a c h s t e p t h e a t t a c k e r c a n e i t h e r p r e s s
t h e o u t p u t b u t t o n t o g e t t h e n e x t o u t p u t w o r d , o r w r i t e o n t h e t a p e , w h i c h
c a u s e s t h e b l a c k - b o x t o r e s t a r t t h e o u t p u t g e n e r a t i o n p r o c e s s w i t h a n e w k e y
d e n e d a s K
0
= K . T h e p u r p o s e o f t h e a t t a c k e r i s t o n d t h e k e y K ( o r
s o m e i n f o r m a t i o n a b o u t i t ) .
5
T h i s a p p r o a c h g e n e r a l i z e s i n t h e o b v i o u s w a y t o l o n g e r I V s .
6
N o t e t h a t S
A 1
x ] x f o r x A . T h i s l i m i t s t h e s i z e o f t h e s e a r c h r e q u i r e d .
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 14/23
8 . 1 R e l a t e d - K e y A t t a c k B a s e d o n t h e I n v a r i a n c e W e a k n e s s
T h i s a t t a c k w o r k s w h e n t h e n u m b e r o f k e y w o r d s , i s a p o w e r o f t w o . I t c o n s i s t s o f
n s t a g e s w h e r e i n s t a g e q t h e q
t h
b i t o f e v e r y k e y w o r d i s e x p o s e d
7
. T h e p r e d i c a t e
C h e c k K e y t a k e s a s i n p u t a n R C 4 b l a c k b o x a n d a p a r a m e t e r q ( t h e s t a g e n u m b e r )
a n d d e c i d e s w h e t h e r t h e k e y i n t h e b o x i s s p e c i a l 2
q
- e x a c t . T h i s p u r p o s e c a n b e
a c h i e v e d b y r a n d o m l y s a m p l i n g k e y b i t s t h a t a r e i r r e l e v a n t f o r t h e 2
q
- e x a c t n e s s o f
t h e k e y a n d e s t i m a t i n g t h e e x p e c t e d l e n g t h o f q - p a t t e r n e d o u t p u t . F o r a s p e c i a l
2
q
- e x a c t k e y t h e e x p e c t e d l e n g t h w i l l b e s i g n i c a n t l y l o n g e r t h a n i n a r a n d o m
o u t p u t ( w h e r e i t i s l e s s t h a n 2 ) a n d t h u s C h e c k K e y w o r k s i n t i m e O ( 1 ) . T h e
p r o c e d u r e E x p a n d t a k e s a s i n p u t a n R C 4 b l a c k b o x a n d a p a r a m e t e r q ( t h e s t a g e
n u m b e r ) , a s s u m e s t h a t t h e k e y i n t h e b o x i s s p e c i a l 2
q 1
- e x a c t , a n d m a k e s i t
s p e c i a l 2
q
- e x a c t . T h e m e t h o d f o r d o i n g s o i s b y e n u m e r a t i n g a l l t h e p o s s i b i l i t i e s
f o r t h e q
t h
b i t s ( 2
̀ 1
s u c h p o s s i b i l i t i e s ) a n d i n v o k i n g C h e c k K e y t o d e c i d e w h e n
t h e k e y i n t h e b o x i s s p e c i a l 2
q
- e x a c t . E x p a n d w o r k s i n a s l i g h t l y d i e r e n t w a y
f o r q = 1 a n d q = n . F o r q = 1 , e x c e p t f o r t h e l s b ' s , i t d e t e r m i n e s t h e c o m p l e t e
K 0 ] ( b y f o r c i n g i t t o 1 ) a n d m s b ( K 1 ] ) . F o r q = n , t h e r e i s o n l y o n e 2
n
- e x a c t
k e y a n d c o n s e q u e n t l y w e c a n c a l c u l a t e t h e o u t p u t p r o d u c e d f r o m t h i s k e y a n d
r e p l a c e C h e c k K e y b y s i m p l e c o m p a r i s o n . T h e t i m e c o m p l e x i t y o f t h i s s t a g e i s
O ( 2
n + ̀
) f o r q = 1 a n d O ( 2
̀ 1
) f o r a n y o t h e r q .
T h e t o t a l t i m e r e q u i r e d f o r t h e a t t a c k i s t h u s O ( 2
n + ̀
) + ( n 1 ) O ( 2
̀
) =
O ( 2
n + ̀
) . F o r t y p i c a l R C 4
n = 8
k e y w i t h 3 2 b y t e s , t h e c o m p l e x i t y o f e x h a u s t i v e
s e a r c h i s c o m p l e t e l y i m p r a c t i c a l ( 2
2 5 6
) , w h e r e a s t h e c o m p l e x i t y o f t h e n e w a t t a c k
i s o n l y O ( 2
n + ̀
) = O ( 2
4 0
) .
8 . 2 R e l a t e d - K e y A t t a c k B a s e d o n K n o w n I V W e a k n e s s
I n t h i s s e c t i o n w e u s e t h e k n o w n I V w e a k n e s s e s t o d e v e l o p a n e c i e n t r e l a t e d
k e y a t t a c k o n R C 4 .
T h e a t t a c k c o n s i s t s o f 3 s t a g e s , w h e r e i n t h e r s t t w o s t a g e s w e g a i n i n f o r m a -
t i o n o n t h e r s t t h r e e w o r d s o f t h e s e c r e t k e y , a n d i n t h e t h i r d s t a g e w e i t e r a t e
d o w n t h e k e y , a n d e x p o s e e a c h w o r d o f t h e k e y s u c c e s s i v e l y . T h e s t a g e s o f t h e
a t t a c k a r e a s f o l l o w s :
S t e p 1 T h i s s t e p a t t e m p t s t o n d v a l u e s o f K 0 ] , K 1 ] s u c h t h a t S
1
1 ] = 1 ,
a n d r e v e a l t h e v a l u e o f K 2 ] . T h e p r o c e d u r e i s t o s e l e c t r a n d o m v a l u e s o f
( X ; Y ) , a n d f o r e a c h s u c h r a n d o m v a l u e , w r i t e o n t o t h e t a p e 2 4 0 v e c t o r s
w i t h t h e i n i t i a l f o u r w o r d s ( X ; Y ; Z ; W ) f o r Z 2 f 0 ; N = 4 ; N = 2 ; 3 N = 4 g a n d
w i t h 6 0 d i s t i n c t r a n d o m v a l u e s o f W , a n d f o r e a c h s u c h v e c t o r , p r e s s t h e
o u t p u t b u t t o n . I f X a n d Y a r e s u c h t h a t S
1
1 ] = 1 ( f o r t h e m o d i e d k e y ) ,
t h e n t h e o u t p u t o f t h e r s t w o r d w i l l b e b i a s e d t o w a r d s 3 + ( K 2 ] Z ) , u n l e s s
t h a t v a l u e h a p p e n s t o b e 1 . H e n c e , f o r a t l e a s t 3 o f t h e s e l e c t e d v a l u e s o f
Z , t h e r s t w o r d o u t p u t s w i l l b e b i a s e d t o w a r d s o n e o f c o n s t , c o n s t + N = 4 ,
c o n s t + N = 2 , c o n s t + 3 N = 4 . T h i s i s d e t e c t a b l e , a n d a l s o b y e x a m i n i n g t h e
v a l u e o f c o n s t , t h e a t t a c k e r c a n r e c o n s t r u c t t h e v a l u e o f K 2 ] . W e e x p e c t t o
t r y N r a n d o m v a l u e s o f ( X ; Y ) b e f o r e n d i n g a p a i r t h a t i s a p p r o p r i a t e .
7
I n f a c t , K 1 ] i s f u l l y r e v e a l e d d u r i n g t h e r s t s t a g e ( s e e F i g u r e 4 )
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 15/23
S t e p 2 T h i s s t e p a t t e m p t s t o n d t h e v a l u e s o f K 0 ] , K 1 ] . T h e p r o c e d u r e i s t o
w r i t e o n t h e t a p e 6 0 v e c t o r s w i t h t h e i n i t i a l f o u r w o r d s ( X ; Y ; Z ; W ) , w h e r e
X , Y a r e t h e v a l u e s r e c o v e r e d i n t h e p r e v i o u s s t e p , Z = ( N 3 ) K 2 ] ,
a n d w i t h 6 0 d i s t i n c t r a n d o m v a l u e s o f W , a n d f o r e a c h s u c h v e c t o r , p r e s s
t h e o u t p u t b u t t o n . T h i s p a r t i c u l a r i n i t i a l s e q u e n c e a s s u r e s t h a t S
2
1 ] = 1
a n d S
2
2 ] = S
1
0 ] = K 0 ] , a n d h e n c e t h e o u t p u t w i l l b e b i a s e d t o w a r d s K 0 ] .
O n c e t h a t h a s b e e n r e c o v e r e d , K 1 ] c a n b e c o m p u t e d .
S t e p 3 T h i s s t e p i t e r a t i v e l y r e c o v e r s i n d i v i d u a l w o r d s o f t h e k e y . I t o p e r a t e s
b y r u n n i n g a s u b p r o c e d u r e t h a t a s s u m e s t h a t w e h a v e a l r e a d y r e c o v e r e d
( K 0 ] ; : : : ; K A 1 ] ) , a n d w a n t t o l e a r n t h e v a l u e o f K A ] . T h e p r o c e d u r e i s
t o w r i t e 6 0 v e c t o r s t h a t h a v e t h e p r o p e r t y t h a t , g i v e n t h e k n o w n v a l u e s o f
( K 0 ] ; : : : ; K A 1 ] ) , t h a t S
A 1
1 ] = X < A a n d X + S
A 1
X ] = A . W i t h
6 0 s u c h v e c t o r s , w e c a n u s e t h e p r o c e d u r e s h o w n i n 7 . 1 t o r e d e r i v e K A ] .
T h e t o t a l t i m e r e q u i r e d f o r t h e a t t a c k i s t h u s ( b e c a u s e 2
n
̀ ) :
S t e p 1 + S t e p 2 + ( ̀ 3 ) S t e p 3 = O ( 2
n + 8
) + 2
6
+ ( ̀ 3 ) 2
6
= O ( 2
n + 8
)
F o r a R C 4 k e y w i t h n = 8 t h e t i m e c o m p l e x i t y i s O ( 2
1 6
) a n d i s e s s e n t i a l l y
i n d e p e n d e n t o f t h e k e y l e n g t h .
8 . 3 C o m p a r i n g t h e A t t a c k s
B o t h a t t a c k s a r e a b l e t o c o m p l e t e l y r e c o n s t r u c t t h e r a n d o m l y c h o s e n R C 4 k e y
8
w i t h a n u m b e r o f c h o s e n k e y s a n d a m o u n t o f w o r k t h a t i s s i g n i c a n t l y b e l o w
t h a t o f b r u t e f o r c e ( e x c e p t f o r e x t r e m e l y s h o r t R C 4 k e y s ) . T h e r s t a t t a c k s c a l e s
u p w a r d s a s t h e k e y g r o w s l o n g e r , w h i l e t h e t i m e c o m p l e x i t y o f t h e s e c o n d a t t a c k
i s i n d e p e n d e n t o f k e y l e n g t h , w i t h a c r o s s - o v e r p o i n t a t ̀ = 8 .
H o w e v e r , d u e t o t h e s e c o n d w o r d w e a k n e s s , f u t u r e i m p l e m e n t a t i o n s o f R C 4
a r e l i k e l y t o d i s c a r d s o m e p r e x o f t h e o u t p u t s t r e a m , a n d i n t h i s c a s e t h e s e c o n d
a t t a c k b e c o m e s d i c u l t t o a p p l y { o u t p u t w o r d x d e p e n d s o n 2 x + 1 p e r m u t a t i o n
e l e m e n t s i m m e d i a t e l y a f t e r K S A , a n d a l l t h e 2 x + 1 e l e m e n t s m u s t o c c u r b e f o r e
t f o r t h e r e s o l v e d c o n d i t i o n t o h o l d . O n t h e o t h e r h a n d , t h e r s t a t t a c k e x t e n d s
w e l l , i n t h a t t h e p r o b a b i l i t y o f t h e o u t p u t w o r d s b e i n g p a t t e r n e d d r o p s m o d e s t l y
a s t h e n u m b e r o f d i s c a r d e d w o r d s i n c r e a s e s .
9 D i s c u s s i o n
S e c t i o n 3 d e s c r i b e s a n i n t e r e s t i n g w e a k n e s s o f R C 4 w h i c h r e s u l t s f r o m t h e s i m -
p l i c i t y o f i t s k e y s c h e d u l i n g a l g o r i t h m . W e r e c o m m e n d t o n e u t r a l i z e t h i s w e a k n e s s
b y d i s c a r d i n g t h e r s t N w o r d s o f e a c h g e n e r a t e d s t r e a m . A f t e r N r o u n d s , e v e r y
e l e m e n t o f S i s s w a p p e d a t l e a s t o n c e a n d t h e p e r m u t a t i o n S a n d t h e i n d e x j
a r e e x p e c t e d t o b e " i n d e p e n d e n t " o f t h e i n i t i a l i z a t i o n p r o c e s s .
S e c t i o n 6 d e s c r i b e s a w e a k n e s s o f R C 4 i n a c o m m o n m o d e o f o p e r a t i o n i n
w h i c h a t t a c k e r v i s i b l e I V ' s a r e c o n c a t e n a t e d w i t h a x e d s e c r e t k e y . I t i s e a s y
8
t h e r s t a t t a c k w o r k s o n l y f o r s o m e k e y l e n g t h s .
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 16/23
t o e x t e n d t h e a t t a c k t o o t h e r s i m p l e t y p e s o f c o m b i n a t i o n o p e r a t o r s ( e . g . , w h e n
w e X O R t h e I V a n d t h e x e d k e y ) w i t h e s s e n t i a l l y t h e s a m e c o m p l e x i t y . W e
r e c o m m e n d t o n e u t r a l i z e t h i s w e a k n e s s b y a v o i d i n g t h i s m o d e o f o p e r a t i o n , o r
b y u s i n g a s e c u r e h a s h t o f o r m t h e k e y p r e s e n t e d t o t h e K S A f r o m t h e I V a n d
s e c r e t k e y .
A A p p l y i n g T h e A t t a c k t o W E P - l i k e C r y p t o s y s t e m s
T h e W i r e d E q u i v a l e n t P r i v a c y ( W E P ) p r o t o c o l i s d e s i g n e d t o p r o v i d e p r i v a c y
t o p a c k e t b a s e d w i r e l e s s n e t w o r k s b a s e d o n t h e 8 0 2 . 1 1 s t a n d a r d ( s e e L M S o n ] ) .
I t e n c r y p t s b y t a k i n g a s e c r e t k e y a n d a p e r - p a c k e t 3 b y t e I V , a n d u s i n g t h e
I V f o l l o w e d b y t h e s e c r e t k e y a s t h e R C 4 k e y . T h e n , i t t r a n s m i t s t h e I V , a n d
t h e R C 4 e n c r y p t e d p a y l o a d . B y u s i n g t h e r e s u l t s f r o m S e c t i o n 7 . 1 , w e c a n s h o w
h o w , b y e x a m i n i n g e n o u g h c i p h e r t e x t p a c k e t s , t o r e c o n s t r u c t t h e s e c r e t k e y f o r
a W E P - l i k e c r y p t o s y s t e m . N o t e t h a t w e h a v e n o t a t t e m p t e d t o a t t a c k a n a c t u a l
W E P c o n n e c t i o n , a n d h e n c e d o n o t c l a i m t h a t W E P i s a c t u a l l y v u l n e r a b l e t o
t h i s a t t a c k .
W e a s s u m e t h a t t h e a t t a c k e r i s a b l e t o r e t r i e v e t h e r s t b y t e o f t h e R C 4
o u t p u t f r o m e a c h p a c k e t
9
. B y t h e a n a l y s i s d o n e i n s e c t i o n 7 . 1 , t o r e c o v e r k e y
b y t e B , t h e a t t a c k e r n e e d s t o k n o w t h e p r e v i o u s k e y b y t e s , a n d t h e n s e a r c h f o r
I V s t h a t s e t s u p t h e p e r m u t a t i o n s u c h t h a t
X = S
B + 3
1 ] < B + 3 ( 1 )
X + S
B + 3
X ] = B + 3
W i t h 6 0 s u c h I V s , t h e a t t a c k e r c a n r e d e r i v e t h e k e y b y t e w i t h r e a s o n a b l e
p r o b a b i l i t y o f s u c c e s s . T h e n u m b e r o f p a c k e t s r e q u i r e d t o o b t a i n t h a t n u m b e r
o f I V s d e p e n d s o n t h e e x a c t I V s t h a t t h e s e n d e r u s e s . A l t h o u g h t h e 8 0 2 . 1 1
s t a n d a r d d o e s n o t s p e c i f y h o w a n i m p l e m e n t a t i o n s h o u l d g e n e r a t e t h e s e I V s ,
c o m m o n p r a c t i c e i s t o u s e a c o u n t e r t o g e n e r a t e t h e m .
A . 1 A n a l y s i s o f I V s G e n e r a t e d b y a L i t t l e E n d i a n C o u n t e r
I f t h e I V s a r e g e n e r a t e d b y a m u l t i b y t e c o u n t e r i n l i t t l e e n d i a n o r d e r ( a n d h e n c e
t h e r s t b y t e o f t h e I V i n c r e m e n t s t h e f a s t e s t ) , t h e n t h e a t t a c k e r c a n s e a r c h f o r
I V s o f t h e f o r m ( B ; 2 5 5 ; N ) f o r 3 B < 8 . I f h e c a n c o l l e c t t h e s e f o r 6 0 d i e r e n t
v a l u e s o f N , t h e n h e c a n d e r i v e t h e s e c r e t k e y w i t h l i t t l e w o r k . T h i s r e q u i r e s
a p p r o x i m a t e l y 4 , 0 0 0 , 0 0 0 p a c k e t s .
9
B e c a u s e o f t h e p a y l o a d f o r m a t u s e d w i t h 8 0 2 . 1 1 , t h e a t t a c k e r t y p i c a l l y d o e s k n o w
t h e r s t b y t e o f e a c h p l a i n t e x t p a y l o a d , a n d h e n c e i s a b l e t o d e r i v e t h e r s t b y t e o f
R C 4 o u t p u t .
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 17/23
A . 2 A n a l y s i s o f I V s G e n e r a t e d b y a B i g E n d i a n C o u n t e r
I f t h e I V s a r e g e n e r a t e d b y a m u l t i b y t e c o u n t e r i n b i g e n d i a n o r d e r ( a n d h e n c e
t h e l a s t b y t e o f t h e I V i n c r e m e n t s t h e f a s t e s t ) , t h e n t h e a t t a c k e r c a n , a s a b o v e ,
s e a r c h f o r I V s o f t h e f o r m ( B ; 2 5 5 ; N ) . T h i s r e q u i r e s a p p r o x i m a t e l y 1 , 0 0 0 , 0 0 0
p a c k e t s t o c o l l e c t t h e r e q u i s i t e I V s , a s s u m i n g t h a t t h e c o u n t e r s t a r t s f r o m z e r o .
H o w e v e r , i f t h e c o u n t e r d o e s n ' t s t a r t f r o m z e r o , t h e a t t a c k e r h a s a n a l t e r -
n a t i v e s t r a t e g y a v a i l a b l e t o h i m . H e c a n a s s u m e t h e r s t s e v e r a l b y t e s o f s e c r e t
k e y , a n d t h e n s e a r c h f o r I V s t h a t s e t u p t h e p e r m u t a t i o n a s i n E q u a t i o n 1 . I f
t h e a t t a c k e r a s s u m e s t h e r s t t w o b y t e s o f s e c r e t k e y , t h e n f o r e a c h i n i t i a l I V
b y t e , t h e r e a r e a p p r o x i m a t e l y 4 s e t t i n g s o f t h e r e m a i n i n g t w o b y t e s t h a t s e t
u p t h e p e r m u t a t i o n a s r e q u i r e d t o r e d e r i v e a p a r t i c u l a r k e y b y t e . H e n c e , w i t h
a p p r o x i m a t e l y 1 , 0 0 0 , 0 0 0 p a c k e t s , a n d a n a d d i t i o n a l 2
1 6
w o r k f a c t o r , h e c a n s t i l l
r e d e r i v e t h e k e y .
I t i s c o m m o n p r a c t i c e i n t h e i n d u s t r y t o e x t e n d t h e l e n g t h o f t h e W E P
s e c r e t k e y ( w h i c h i s s p e c i e d a s 4 0 b i t ) . B e c a u s e t h e a b o v e a t t a c k s r e c o v e r e a c h
k e y b y t e i n d i v i d u a l l y , t h e c o m p l e x i t y o f t h e a t t a c k g r o w s l i n e a r l y r a t h e r t h a n
e x p o n e n t i a l l y w i t h t h e k e y l e n g t h , a n d t h u s e v e n a n e x t r e m e l y l o n g k e y i s n o t
i m m u n e t o t h i s a t t a c k .
B C i p h e r t e x t - O n l y D i s t i n g u i s h e r s b a s e d o n t h e
I n v a r i a n c e W e a k n e s s
T h e d i s t i n g u i s h e r s w e p r e s e n t e d i n S e c t i o n 5 . 1 , a s w e l l a s m o s t o f t h e d i s t i n -
g u i s h e r s m e n t i o n e d i n t h e l i t e r a t u r e ( f o r R C 4 a n d o t h e r s t r e a m c i p h e r s ) a s s u m e
k n o w l e d g e o f t h e p l a i n t e x t i n o r d e r t o i s o l a t e t h e X O R e d k e y s t r e a m .
H o w e v e r , i n p r a c t i c e t h e o n l y i n f o r m a t i o n t h e a t t a c k e r h a s i s t y p i c a l l y s o m e
s t a t i s t i c a l k n o w l e d g e a b o u t t h e p l a i n t e x t , e . g . , t h a t i t c o n t a i n s E n g l i s h t e x t .
C o m b i n i n g t h e n o n - r a n d o m b e h a v i o r s o f t h e p l a i n t e x t a n d t h e k e y - s t r e a m i s n o t
a l w a y s p o s s i b l e , a n d t h e r e a r e c a s e s w h e r e X O R i n g b i a s e d s t r e a m s r e s u l t w i t h
a t o t a l l y r a n d o m s t r e a m , e . g . w h e n o n e s t r e a m i s b i a s e d i n i t s e v e n p o s i t i o n s
a n d t h e o t h e r s t r e a m i s b i a s e d i n i t s o d d p o s i t i o n s . W e p r o v e h e r e t h a t i f t h e
p l a i n t e x t s a r e E n g l i s h t e x t s , i t i s e a s y t o c o n s t r u c t a c i p h e r t e x t - o n l y d i s t i n g u i s h e r
f r o m o u r b i a s e s . T h e i n t u i t i o n o f t h i s c o n s t r u c t i o n i s t h a t t h e b i a s e s d e s c r i b e d
i n S e c t i o n 5 . 1 a r e i n t h e d i s t r i b u t i o n o f t h e l s b ' s , a n d c o n s e q u e n t l y t h e y c a n b e
c o m b i n e d w i t h t h e n o n - r a n d o m d i s t r i b u t i o n o f t h e l s b ' s o f E n g l i s h t e x t s .
T h e r e a r e m a n y m a j o r b i a s e s i n t h e d i s t r i b u t i o n o f t h e l s b ' s o f E n g l i s h t e x t s ,
a n d t h e y c a n b e c o m b i n e d w i t h b i a s e s o f t h e k e y - s t r e a m w o r d s i n v a r i o u s w a y s .
I n T h e o r e m 3 , w e s h o w h o w t o c o m b i n e t h e d i s t r i b u t i o n o f t h e r s t l s b o f t h e
R C 4 o u t p u t s t r e a m , w i t h t h e r s t o r d e r s t a t i s t i c s o f E n g l i s h t e x t s
1 0
:
T h e o r e m 3 L e t C b e t h e c i p h e r t e x t g e n e r a t e d b y R C 4 f r o m a r a n d o m k e y a n d
t h e A S C I I r e p r e s e n t a t i o n o f p l a i n t e x t s , d i s t r i b u t e d a c c o r d i n g t o t h e r s t o r d e r
1 0
S i n c e t h e p u r p o s e o f t h e t h e o r e m i s o n l y t o d e m o n s t r a t e t h i s a p p r o a c h , w e i g n o r e
t h e f a c t t h a t t h e d i s t r i b u t i o n o f t h e r s t c h a r a c t e r s i n a n E n g l i s h s e n t e n c e d i e r s
f r o m t h e d i s t r i b u t i o n o f m i d - t e x t c h a r a c t e r s .
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 18/23
s t a t i s t i c s o f E n g l i s h t e x t s . L e t p b e t h e p r o b a b i l i t y o f a r a n d o m k e y t o b e s p e c i a l
2 - e x a c t . T h e n C c a n b e d i s t i n g u i s h e d f r o m a r a n d o m s t r e a m b y a n a l y z i n g a b o u t
2 0 0
p
2
o u t p u t w o r d s .
F o r e x a m p l e , f o r R C 4
n = 8
w i t h 8 b y t e k e y s , p = 2
1 6
, w h i c h i m p l i e s a r e l i a b l e
c i p h e r t e x t - o n l y d i s t i n g u i s h e r t h a t w o r k s w i t h l e s s t h a n 2
4 0
d a t a . T h e p r o o f o f
T h e o r e m 3 i s b a s e d o n t h e o b s e r v a t i o n t h a t t h e l s b o f a r a n d o m E n g l i s h t e x t
c h a r a c t e r i s z e r o w i t h p r o b a b i l i t y o f a b o u t 5 5 % . T h e f o r m a l p r o o f i s o m i t t e d d u e
t o s p a c e l i m i t a t i o n s .
I t i s i m p o r t a n t t o n o t e t h a t T h e o r e m 3 d o e s n o t u s e a l l t h e s t a t i s t i c a l i n f o r -
m a t i o n w h i c h i s a v a i l a b l e i n e i t h e r t h e k e y - s t r e a m o r t h e p l a i n t e x t d i s t r i b u t i o n s ,
a n d c o n s e q u e n t l y d o e s n o t r e p r e s e n t t h e b e s t p o s s i b l e a t t a c k .
C T h e S a m p l i n g R e s i s t a n c e o f R C 4
M o s t o f t h e T i m e / M e m o r y / D a t a t r a d e o a t t a c k s o n s t r e a m c i p h e r s a r e b a s e d
o n t h e f o l l o w i n g p a r a d i g m . T h e a t t a c k e r k e e p s a d a t a b a s e o f s t a t e , o u t p u t ] p a i r s
( s o r t e d b y o u t p u t ) a n d l o o k u p s e v e r y s u b s e q u e n c e o f t h e o u t p u t s t r e a m i n t h i s
d a t a b a s e . W h e n a ( s u c i e n t l y l o n g ) d a t a b a s e s e q u e n c e i s l o c a t e d i n t h e o u t p u t ,
t h e a t t a c k e r c a n c o n c l u d e t h a t t h e a c t u a l s t a t e i s t h e o n e s t o r e d a l o n g w i t h t h i s
s e q u e n c e a n d p r e d i c t t h e r e s t o f t h e s t r e a m .
A d r a w b a c k o f t h i s a p p r o a c h i s t h a t t h e l a r g e d a t a b a s e m u s t b e s t o r e d i n a
h a r d d i s k ( s ) w h o s e r a n d o m a c c e s s t i m e i s a b o u t a m i l l i o n t i m e s s l o w e r t h a n a
c o m p u t a t i o n a l s t e p . T o i m p r o v e t h a t a t t a c k w e c a n k e e p o n d i s k o n l y s t a t e s t h a t
a r e g u a r a n t e e d t o p r o d u c e o u t p u t s w i t h s o m e r a r e b u t e a s y r e c o g n i z a b l e p r o p e r t y
( e . g . , s t a r t i n g w i t h s o m e p r e x ) . I n t h i s c a s e o n l y o u t p u t s e q u e n c e s t h a t h a v e
t h i s p r o p e r t y h a v e t o b e s e a r c h e d i n t h e d a t a b a s e , a n d t h u s t h e e x p e c t e d t i m e
a n d t h e e x p e c t e d n u m b e r o f d i s k p r o b e s i s s i g n i c a n t l y r e d u c e d .
I n g e n e r a l , p r o d u c i n g a p a i r s t a t e , o u t p u t ] w i t h s u c h a r a r e p r o p e r t y c o s t s
m u c h m o r e t h a n p r o d u c i n g a r a n d o m p a i r . O (
1
p
) r a n d o m s t a t e s a r e r e q u i r e d t o
n d a s i n g l e p a i r , w h e r e p i s t h e p r o b a b i l i t y o f a r a n d o m o u t p u t t o h a v e t h i s p r o p -
e r t y . H o w e v e r , i f w e c a n e c i e n t l y e n u m e r a t e s t a t e s t h a t p r o d u c e s u c h o u t p u t s ,
t h e n u m b e r o f s a m p l e d s t a t e s d e c r e a s e s d r a m a t i c a l l y , a n d t h i s m e t h o d c a n b e
a p p l i e d w i t h o u t s i g n i c a n t a d d i t i o n a l c o s t d u r i n g t h e p r e p r o c e s s i n g s t a g e . T h e
s a m p l i n g r e s i s t a n c e o f a s t r e a m c i p h e r p r o v i d e s a l o w e r b o u n d o n t h e e c i e n c y
o f s u c h e n u m e r a t i o n .
S u c h a n a t t a c k c a n b e a p p l i e d t o R C 4 i n t w o w a y s , b a s e d o n t h e K S A a n d
P R G A p a r t s . A n a t t a c k o n t h e g e n e r a t i o n p a r t c o n s t r u c t s a d a t a b a s e o f p a i r s
R C 4 s t a t e , o u t p u t s u b s t r i n g ] a n d a n a l y z e s a l l t h e s u b s t r i n g s a l o n g a s i n g l e o u t -
p u t s t r e a m . T h e d a t a b a s e c o n s t r u c t i o n i s v e r y s i m p l e s i n c e i t i s e a s y t o e n u m e r a t e
s t a t e s w h i c h p r o d u c e o u t p u t s t h a t h a v e s o m e c o n s t a n t p r e x . H o w e v e r , t h i s e n u -
m e r a t i o n s e e m s t o b e u s e l e s s d u e t o t h e h u g e e e c t i v e k e y o f t h i s p a r t ( 1 6 8 4 b i t s )
w h i c h m a k e s s u c h a t r a d e o a t t a c k c o m p l e t e l y i m p r a c t i c a l . A m o r e p r o m i s i n g
a p p r o a c h i s b a s e d o n t h e K S A p a r t w h i c h u s e s a k e y o f 4 0 - 2 5 6 b i t s a n d m i g h t b e
v u l n e r a b l e t o t r a d e o a t t a c k s . I n t h i s c a s e , t h e p a i r s i n t h e d a t a b a s e a r e s e c r e t
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 19/23
k e y , p r e x o f t h e o u t p u t s t r e a m ] , a n d t h e a t t a c k r e q u i r e s p r e x e s f r o m a l a r g e
n u m b e r o f s t r e a m s ( i n s t e a d o f a s i n g l e l o n g s t r e a m ) .
T h e c o r r e l a t i o n d e s c r i b e d i n S e c t i o n 4 p r o v i d e s a n e c i e n t s a m p l i n g o f k e y s
t h a t a r e m o r e l i k e l y t o p r o d u c e o u t p u t p r e x e s o f t h e p a t t e r n e d t y p e s p e c i e d
a b o v e ( c o n s t a n t ( m o d b ) ) .
F o r e x a m p l e , c o n s i d e r t h e p r o b l e m o f s a m p l i n g M k e y s w h i c h a r e t r a n s -
f o r m e d b y t h e K S A i n t o s t r e a m s w h o s e r s t v e w o r d s a r e x e d ( m o d 1 6 ) . T h i s
p r o p e r t y o f r a n d o m s t r e a m s h a s p r o b a b i l i t y o f 2
2 0
, a n d t h e e x p e c t e d n u m b e r
o f d i s k p r o b e s d u r i n g t h e a c t u a l a t t a c k i s r e d u c e d b y t h i s f a c t o r . F o r s t r e a m
c i p h e r s w i t h h i g h s a m p l i n g r e s i s t a n c e , s u c h a l t e r w o u l d i n c r e a s e t h e p r e p r o -
c e s s i n g t i m e b y a f a c t o r o f o n e m i l l i o n , a s o n e w o u l d h a v e t o s a m p l e a m i l l i o n
r a n d o m k e y s i n o r d e r t o n d a s i n g l e \ g o o d " k e y . F o r R C 4 ( d u e t o t h e i n v a r i a n c e
w e a k n e s s ) , t h e p r e p r o c e s s i n g t i m e i n c r e a s e s b y a f a c t o r o f l e s s t h a n f o u r , a s m o r e
t h a n o n e q u a r t e r o f t h e e x a c t s p e c i a l k e y s p r o d u c e s u c h s t r e a m s . C o n s e q u e n t l y ,
t h e p r e p r o c e s s i n g s t a g e i s a c c e l e r a t e d b y a f a c t o r o f 2
1 8
.
T o s u m m a r i z e t h i s s e c t i o n , w e p r o v e d t h a t R C 4 h a s r e l a t i v e l y l o w S a m p l i n g
R e s i s t a n c e , w h i c h g r e a t l y i m p r o v e s t h e e c i e n c y o f t r a d e o a t t a c k s b a s e d o n i t s
K S A .
D D e r i v i n g t h e S e c r e t K e y f r o m a n E a r l y P e r m u t a t i o n
S t a t e
G i v e n t h e v a l u e s S
A
0 ] ; : : : ; S
A
A 1 ] , o n e m e t h o d t o n d a l l v a l u e s o f K 0 ] ; : : : ; K A
1 ] t h a t r e s u l t i n s u c h a p e r m u t a t i o n i s :
i = 0
S = f 0 ; : : : ; N 1 g
F o r i = 0 : : : A 1
X = S
1
S
A
i ] ]
I f i < X < A
B r a n c h o v e r a l l v a l u e s o f 0 X < A s . t . X I o r
S X ] 6= S
A
X ] , r u n n i n g t h e r e m a i n i n g p a r t o f t h i s
a l g o r i t h m f o r a l l s u c h v a l u e s .
K i ] = X j S i ]
j = X
S w a p ( S i ] , S j ] )
V e r i f y t h a t f S 0 ] ; : : : ; S A 1 ] g = f S
A
0 ] ; : : : ; S
A
A 1 ] g
T h e n u m b e r o f t i m e s t h i s a l g o r i t h m w i l l p e r f o r m a n i t e r a t i o n i s b o u n d e d b y
A
+ 1
, w h e r e i f t h e n u m b e r o f v a l u e s 0 x < A w h e r e S
A
x ] < A . B e c a u s e
i s t y p i c a l l y q u i t e s m a l l , t h i s a l g o r i t h m i s t y p i c a l l y e c i e n t .
A n a l g o r i t h m w i t h a b e t t e r l o w e r b o u n d o n r u n t i m e c o u l d b e g i v e n b y u s i n g
t h e v a l u e s o f S
A
A ] ; : : : ; S
A
N 1 ] .
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 20/23
R e f e r e n c e s
B S W 0 0 ] A . B i r y u k o v , A . S h a m i r , a n d D . W a g n e r . R e a l t i m e c r y p t a n a l y s i s o f a 5 / 1
o n a p c . I n F S E : F a s t S o f t w a r e E n c r y p t i o n , 2 0 0 0 .
F M 0 0 ] F l u h r e r a n d M c G r e w . S t a t i s t i c a l a n a l y s i s o f t h e a l l e g e d r c 4 k e y s t r e a m g e n -
e r a t o r . I n F S E : F a s t S o f t w a r e E n c r y p t i o n , 2 0 0 0 .
G o l 9 7 ] G o l i c . L i n e a r s t a t i s t i c a l w e a k n e s s o f a l l e g e d R C 4 k e y s t r e a m g e n e r a t o r .
I n E U R O C R Y P T : A d v a n c e s i n C r y p t o l o g y : P r o c e e d i n g s o f E U R O C R Y P T ,
1 9 9 7 .
G W 0 0 ] A . L . G r o s u l a n d D . S . W a l l a c h . a r e l a t e d - k e y c r y p t a n a l y s i s o f r c 4 . J u n e
2 0 0 0 .
K M P
+
9 8 ] K n u d s e n , M e i e r , P r e n e e l , R i j m e n , a n d V e r d o o l a e g e . A n a l y s i s m e t h o d s f o r
( a l l e g e d ) R C 4 . I n A S I A C R Y P T : A d v a n c e s i n C r y p t o l o g y { A S I A C R Y P T :
I n t e r n a t i o n a l C o n f e r e n c e o n t h e T h e o r y a n d A p p l i c a t i o n o f C r y p t o l o g y
L N C S , S p r i n g e r - V e r l a g , 1 9 9 8 .
L M S o n ] W i r e l e s s l a n m e d i u m a c c e s s c o n t r o l ( M A C ) a n d p h y s i c a l l a y e r ( P H Y ) s p e c -
i c a t i o n s . ( I E E E S t a n d a r d 8 0 2 . 1 1 ) , 1 9 9 9 E d i t i o n . L . M . S . C . o f t h e I E E E
C o m p u t e r S o c i e t y .
M S 0 1 ] I . M a n t i n a n d A . S h a m i r . A p r a c t i c a l a t t a c k o n b r o a d c a s t R C 4 . I n F S E :
F a s t S o f t w a r e E n c r y p t i o n , 2 0 0 1 .
M T 9 8 ] M i s t e r a n d T a v a r e s . C r y p t a n a l y s i s o f R C 4 - l i k e c i p h e r s . I n S A C : A n n u a l
I n t e r n a t i o n a l W o r k s h o p o n S e l e c t e d A r e a s i n C r y p t o g r a p h y . L N C S , 1 9 9 8 .
R e i 0 1 ] A r n o l d R e i n h o l d . T h e c i p h e r s a b e r h o m e p a g e . 2 0 0 1 .
R o o 9 5 ] A . R o o s . A c l a s s o f w e a k k e y s i n t h e r c 4 s t r e a m c i p h e r . S e p t e m b e r 1 9 9 5 .
W a g 9 5 ] D . W a g n e r . R e : W e a k k e y s i n r c 4 . S e p t e m b e r 1 9 9 5 . P o s t e d t o s c i . c r y p t ,
A r c h i v e d a t h t t p : / / w w w . c s . b e r k e l e y . e d u / d a w / m y - p o s t s / m y - r c 4 - w e a k - k e y s .
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 21/23
` q b k
1
a
k
2
b
p
c
P
R N D
d
P
R C 4
e
D a t a
4 1 2 1 2 1 5 2
3
2
1 5
2 2
1 5
2
1 5
6 1 2 1 4 1 8 2
4
2
1 8
2 2
1 8
2
1 8
8 1 2 1 6 2 1 2
5
2
2 1
2 2
2 1
2
2 1
1 0 1 2 1 8 2 4 2
6
2
2 4
2 2
2 4
2
2 4
1 2 1 2 2 0 2 7 2
7
2
2 7
2 2
2 7
2
2 7
1 4 1 2 2 2 3 0 2
8
2
3 0
2 2
3 0
2
3 0
1 6 1 2 2 4 3 4 2
1 0
2
3 4
2 2
3 4
2
3 4
F i g . 5 . D a t a r e q u i r e d f o r a r e l i a b l e d i s t i n g u i s h e r , f o r d i e r e n t k e y s i z e s
a
n u m b e r o f p r e d e t e r m i n e d b i t s ( q ( ̀ 1 ) + n + 1 )
b
n u m b e r o f d e t e r m i n e d o u t p u t b i t s
c
p r o b a b i l i t y o f t h e s e k
1
k e y b i t s t o d e t e r m i n e t h e s e k
2
o u t p u t b i t s ( t a k e n f r o m F i g u r e 8 )
d
= 2
k
2
e
P
R N D
+ 2
k
1
p
I V L e n g t h P r o b a b i l i t y E x p e c t e d I V s r e q u i r e d
3 4 5 7 1 0
5
1 3 1 0 0 0 0
4 4 5 0 1 0
5
1 3 3 0 0 0 0
5 1 6 5 1 0
4
3 6 4 0 0 0
6 1 6 4 1 0
4
3 6 6 0 0 0
7 2 8 1 1 0
4
2 1 3 0 0 0
8 2 8 0 1 0
4
2 1 4 0 0 0
9 3 9 6 1 0
4
1 5 2 0 0 0
1 0 3 9 4 1 0
4
1 5 2 0 0 0
1 1 5 0 8 1 0
4
1 1 8 0 0 0
1 2 5 0 4 1 0
4
1 1 9 0 0 0
1 3 6 1 6 1 0
4
9 7 5 0 0
1 4 6 1 2 1 0
4
9 8 1 0 0
1 5 7 2 1 1 0
4
8 3 2 0 0
1 6 7 1 8 1 0
4
8 3 6 0 0
F i g . 6 . F o r v a r i o u s p r e p e n d e d I V a n d k n o w n s e c r e t k e y p r e x l e n g t h s , t h e p r o b a b i l i t y
t h a t a r a n d o m I V w i l l g i v e u s i n f o r m a t i o n o n t h e n e x t s e c r e t k e y w o r d , a n d t h e e x p e c t e d
n u m b e r o f I V s r e q u i r e d t o d e r i v e t h e n e x t s e c r e t k e y w o r d .
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 22/23
I V S e t t i n g s
C o n d i t i o n F i r s t S e c o n d T h i r d P r o b a b i l i t y R e s u l t
S
A
1 ] = 1 S w a p w i t h 1 S w a p w i t h Y C y c l e 0 . 0 0 3 7 K e y r e c o v e r y
S
A
A ] = A
S
A
1 ] = 2 S w a p w i t h 1 C y c l e S w a p w i t h Y 0 . 0 0 7 0 K e y r e d u c t i o n
S
A
A + 1 ] = A + 1
S
A
1 ] = X < A S w a p w i t h Y C y c l e C y c l e 0 . 0 0 0 7 K e y r e c o v e r y
S
A
X ] + X = A
S
A
1 ] = X < A C y c l e S w a p w i t h Y C y c l e 0 . 0 0 0 9 K e y r e c o v e r y
S
A
X ] + X = A + 1
S
A
1 ] = X < A C y c l e C y c l e S w a p w i t h Y 0 . 0 0 0 7 K e y r e d u c t i o n
S
A
X ] + X = A + 2
S
A
1 ] = A S w a p w i t h S w a p w i t h Y C y c l e 0 . 0 0 3 7 K e y r e c o v e r y
S
1
A
1 ]
S
A
1 ] = A + 1 S w a p w i t h Y S w a p w i t h C y c l e 0 . 0 0 3 6 K e y r e c o v e r y
S
1
A
N 1 ]
S
A
1 ] = A + 2 C y c l e S w a p w i t h Y S w a p w i t h 0 . 0 0 3 8 K e y r e d u c t i o n
S
1
A
N 1 ]
S
A
1 ] = N 2 S w a p w i t h Y C y c l e S w a p w i t h 1 0 . 0 0 3 4 K e y r e d u c t i o n
S
A
A + 2 ] = A + 2
S
A
1 ] = N 1 S w a p w i t h Y S w a p w i t h 1 C y c l e 0 . 0 0 3 6 K e y r e c o v e r y
S
A
A + 1 ] = A + 1
S
A
1 ] = X < A S w a p w i t h X C y c l e C y c l e 0 . 1 0 0 7 K e y r e d u c t i o n
S
A
A ] = Z
X + Z > A + 2
F i g . 7 . W e a k s e c r e t k e y s w i t h 3 w o r d p o s t x I V s . L i s t e d a r e t h e c o n d i t i o n s o n t h e S
A
p e r m u t a t i o n t h a t d i s t i n g u i s h t h e m , t h e I V p r o p e r t i e s t h a t t h e a t t a c k e r s e a r c h e s f o r t o
r e v e a l S Y ] , t h e p r o b a b i l i t y t h a t t h i s c l a s s o f w e a k k e y w i l l o c c u r w i t h n = 8 a n d a 1 6
w o r d s e c r e t k e y , a n d t h e r e s u l t o f t h e a t t a c k o n t h e w e a k k e y .
8/14/2019 rc4 ksaproc
http://slidepdf.com/reader/full/rc4-ksaproc 23/23
0 10 20 30 40 50 60−30
−25
−20
−15
−10
−5
0
L o g
o f t h e
p r o b a
b i l i t y
o f p a t t e r n e d p
r e f i x
o f s i z e h
h − size of the patterned prefix
q=1q=2q=3q=4
F i g . 8 . T h i s g r a p h d e m o n s t r a t e s t h e p r o b a b i l i t i e s o f s p e c i a l k e y s ( 2
q
- e x a c t w i t h K 0 ] =
1 , m s b ( K 1 ] = 1 ) ) o f R C 4
n = 8 ; ̀ = 1 6
t o p r o d u c e s t r e a m s w i t h l o n g p a t t e r n e d p r e x e s