57 for (i = 0; i < 12; i++)
58 keys[i] =
AV_RL32(keybuf + (i << 2)) | 1;
69 for (i = 0; i < 5; i++)
71 for (i = 6; i < 11; i++)
79 for (i = 1; i < 5; i++) {
80 v = (v >> 16) | (v << 16);
91 for (i = 4; i > 0; i--) {
93 v = (v >> 16) | (v << 16);
108 uint64_t key, uint64_t
data)
111 uint32_t
b = data >> 32;
117 c = (key >> 32) + tmp;
120 return ((uint64_t)c << 32) | tmp;
132 uint64_t key, uint64_t
data)
136 uint32_t
c = data >> 32;
140 tmp = c - (key >> 32);
144 return ((uint64_t)b << 32) |
a;
151 int num_qwords = len >> 3;
153 uint64_t rc4buff[8] = { 0 };
155 uint32_t ms_keys[12];
159 for (i = 0; i <
len; i++)
168 packetkey =
AV_RN64(&qwords[num_qwords * 8 - 8]);
169 packetkey ^= rc4buff[7];
172 packetkey ^= rc4buff[6];
178 for (i = 0; i < num_qwords - 1; i++, qwords += 8)
181 packetkey = (packetkey << 32) | (packetkey >> 32);
void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Encrypts / decrypts using the DES algorithm.
ptrdiff_t const GLvoid * data
static uint32_t multiswap_inv_step(const uint32_t keys[12], uint32_t v)
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.
static uint32_t multiswap_step(const uint32_t keys[12], uint32_t v)
static void multiswap_init(const uint8_t keybuf[48], uint32_t keys[12])
read keys from keybuf into keys
void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len)
int av_des_init(AVDES *d, const uint8_t *key, int key_bits, av_unused int decrypt)
static void multiswap_invert_keys(uint32_t keys[12])
invert the keys so that encryption become decryption keys and the other way round.
static uint64_t multiswap_enc(const uint32_t keys[12], uint64_t key, uint64_t data)
"MultiSwap" encryption
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.
static uint64_t multiswap_dec(const uint32_t keys[12], uint64_t key, uint64_t data)
"MultiSwap" decryption
static uint32_t inverse(uint32_t v)
find multiplicative inverse modulo 2 ^ 32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32