41 #include "netif/ppp/ppp_opts.h" 42 #if PPP_SUPPORT && LWIP_INCLUDED_POLARSSL_ARC4 48 void arc4_setup( arc4_context *ctx,
unsigned char *key,
int keylen )
57 for( i = 0; i < 256; i++ )
58 m[i] = (
unsigned char) i;
62 for( i = 0; i < 256; i++, k++ )
64 if( k >= keylen ) k = 0;
67 j = ( j + a + key[k] ) & 0xFF;
69 m[j] = (
unsigned char) a;
76 void arc4_crypt( arc4_context *ctx,
unsigned char *buf,
int buflen )
85 for( i = 0; i < buflen; i++ )
87 x = ( x + 1 ) & 0xFF; a = m[x];
88 y = ( y + a ) & 0xFF; b = m[y];
90 m[x] = (
unsigned char) b;
91 m[y] = (
unsigned char) a;
93 buf[i] = (
unsigned char)
94 ( buf[i] ^ m[(
unsigned char)( a + b )] );