33 int keylen = key_bits >> 3;
36 for (i = 0; i < 256; i++)
40 for (j = 0, i = 0; i < 256; i++, j++) {
41 if (j == keylen) j = 0;
42 y += state[i] + key[j];
43 FFSWAP(uint8_t, state[i], state[y]);
50 void av_rc4_crypt(
AVRC4 *
r, uint8_t *dst,
const uint8_t *src,
int count, uint8_t *iv,
int decrypt) {
51 uint8_t
x = r->
x,
y = r->
y;
54 uint8_t sum = state[
x] + state[
y];
55 FFSWAP(uint8_t, state[x], state[
y]);
56 *dst++ = src ? *src++ ^ state[sum] : state[sum];
void av_rc4_crypt(AVRC4 *r, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Encrypts / decrypts using the RC4 algorithm.
common internal and external API header
int av_rc4_init(AVRC4 *r, const uint8_t *key, int key_bits, int decrypt)
Initializes an AVRC4 context.
#define FFSWAP(type, a, b)