55 for (i = 0; i < 12; i++)
56 keys[i] =
AV_RL32(keybuf + (i << 2)) | 1;
66 for (i = 0; i < 5; i++)
68 for (i = 6; i < 11; i++)
75 for (i = 1; i < 5; i++) {
76 v = (v >> 16) | (v << 16);
86 for (i = 4; i > 0; i--) {
88 v = (v >> 16) | (v << 16);
104 uint32_t
b = data >> 32;
110 c = (key >> 32) + tmp;
113 return ((uint64_t)c << 32) | tmp;
127 uint32_t c = data >> 32;
131 tmp = c - (key >> 32);
135 return ((uint64_t)b << 32) |
a;
141 int num_qwords = len >> 3;
142 uint8_t *qwords =
data;
145 uint32_t ms_keys[12];
149 for (i = 0; i <
len; i++)
154 memset(rc4buff, 0,
sizeof(rc4buff));
159 packetkey =
AV_RN64(&qwords[num_qwords*8 - 8]);
160 packetkey ^= rc4buff[7];
162 av_des_crypt(&des, (uint8_t *)&packetkey, (uint8_t *)&packetkey, 1,
NULL, 1);
163 packetkey ^= rc4buff[6];
169 for (i = 0; i < num_qwords - 1; i++, qwords += 8)
172 packetkey = (packetkey << 32) | (packetkey >> 32);
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.
int av_des_init(AVDES *d, const uint8_t *key, int key_bits, int decrypt)
Initializes an AVDES context.
static uint32_t multiswap_inv_step(const uint32_t keys[12], uint32_t v)
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)
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
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.
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