Go to the documentation of this file.
58 for (
i = 0;
i < 12;
i++)
70 for (
i = 0;
i < 5;
i++)
72 for (
i = 6;
i < 11;
i++)
80 for (
i = 1;
i < 5;
i++) {
81 v = (v >> 16) | (v << 16);
92 for (
i = 4;
i > 0;
i--) {
94 v = (v >> 16) | (v << 16);
112 uint32_t
b =
data >> 32;
121 return ((uint64_t)
c << 32) |
tmp;
137 uint32_t
c =
data >> 32;
145 return ((uint64_t)
b << 32) |
a;
152 int num_qwords =
len >> 3;
153 uint8_t *qwords =
data;
154 uint64_t rc4buff[8] = { 0 };
156 uint32_t ms_keys[12];
176 packetkey =
AV_RN64(&qwords[num_qwords * 8 - 8]);
177 packetkey ^= rc4buff[7];
179 av_des_crypt(des, (uint8_t *)&packetkey, (uint8_t *)&packetkey, 1,
NULL, 1);
180 packetkey ^= rc4buff[6];
186 for (
i = 0;
i < num_qwords - 1;
i++, qwords += 8)
189 packetkey = (packetkey << 32) | (packetkey >> 32);
int av_des_init(AVDES *d, const uint8_t *key, int key_bits, av_unused int decrypt)
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.
static void multiswap_invert_keys(uint32_t keys[12])
invert the keys so that encryption become decryption keys and the other way round.
static uint32_t multiswap_inv_step(const uint32_t keys[12], uint32_t v)
static uint64_t multiswap_enc(const uint32_t keys[12], uint64_t key, uint64_t data)
"MultiSwap" encryption
static uint64_t multiswap_dec(const uint32_t keys[12], uint64_t key, uint64_t data)
"MultiSwap" decryption
static void multiswap_init(const uint8_t keybuf[48], uint32_t keys[12])
read keys from keybuf into keys
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
AVRC4 * av_rc4_alloc(void)
Allocate an AVRC4 context.
AVDES * av_des_alloc(void)
Allocate an AVDES context.
#define i(width, name, range_min, range_max)
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_rc4_init(AVRC4 *r, const uint8_t *key, int key_bits, int decrypt)
Initializes an AVRC4 context.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
static uint32_t multiswap_step(const uint32_t keys[12], uint32_t v)
static uint32_t inverse(uint32_t v)
find multiplicative inverse modulo 2 ^ 32
void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len)