@@ -31,38 +31,38 @@ typedef unsigned int u32;
31
31
* encryption/decryption.
32
32
*/
33
33
FORCE_INLINE void rc4_skip (const u8 * key , size_t keylen , size_t skip ,
34
- u8 * data , size_t data_len )
34
+ u8 * data , size_t data_len )
35
35
{
36
- u32 i , j , k ;
37
- u8 S [256 ], * pos ;
38
- size_t kpos ;
39
- /* Setup RC4 state */
40
- for (i = 0 ; i < 256 ; i ++ )
41
- S [i ] = i ;
42
- j = 0 ;
43
- kpos = 0 ;
44
- for (i = 0 ; i < 256 ; i ++ ) {
45
- j = (j + S [i ] + key [kpos ]) & 0xff ;
46
- kpos ++ ;
47
- if (kpos >= keylen )
48
- kpos = 0 ;
49
- S_SWAP (i , j );
50
- }
51
- /* Skip the start of the stream */
52
- i = j = 0 ;
53
- for (k = 0 ; k < skip ; k ++ ) {
54
- i = (i + 1 ) & 0xff ;
55
- j = (j + S [i ]) & 0xff ;
56
- S_SWAP (i , j );
57
- }
58
- /* Apply RC4 to data */
59
- pos = data ;
60
- for (k = 0 ; k < data_len ; k ++ ) {
61
- i = (i + 1 ) & 0xff ;
62
- j = (j + S [i ]) & 0xff ;
63
- S_SWAP (i , j );
64
- * pos ++ ^= S [(S [i ] + S [j ]) & 0xff ];
65
- }
36
+ u32 i , j , k ;
37
+ u8 S [256 ], * pos ;
38
+ size_t kpos ;
39
+ /* Setup RC4 state */
40
+ for (i = 0 ; i < 256 ; i ++ )
41
+ S [i ] = i ;
42
+ j = 0 ;
43
+ kpos = 0 ;
44
+ for (i = 0 ; i < 256 ; i ++ ) {
45
+ j = (j + S [i ] + key [kpos ]) & 0xff ;
46
+ kpos ++ ;
47
+ if (kpos >= keylen )
48
+ kpos = 0 ;
49
+ S_SWAP (i , j );
50
+ }
51
+ /* Skip the start of the stream */
52
+ i = j = 0 ;
53
+ for (k = 0 ; k < skip ; k ++ ) {
54
+ i = (i + 1 ) & 0xff ;
55
+ j = (j + S [i ]) & 0xff ;
56
+ S_SWAP (i , j );
57
+ }
58
+ /* Apply RC4 to data */
59
+ pos = data ;
60
+ for (k = 0 ; k < data_len ; k ++ ) {
61
+ i = (i + 1 ) & 0xff ;
62
+ j = (j + S [i ]) & 0xff ;
63
+ S_SWAP (i , j );
64
+ * pos ++ ^= S [(S [i ] + S [j ]) & 0xff ];
65
+ }
66
66
}
67
67
/**
68
68
* rc4 - XOR RC4 stream to given data
@@ -76,5 +76,5 @@ FORCE_INLINE void rc4_skip(const u8 *key, size_t keylen, size_t skip,
76
76
*/
77
77
FORCE_INLINE void rc4 (u8 * buf , size_t len , const u8 * key , size_t key_len )
78
78
{
79
- rc4_skip (key , key_len , 0 , buf , len );
79
+ rc4_skip (key , key_len , 0 , buf , len );
80
80
}
0 commit comments