FFmpeg
Functions
asfcrypt.c File Reference
#include <stddef.h>
#include "libavutil/bswap.h"
#include "libavutil/des.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavutil/rc4.h"
#include "asfcrypt.h"

Go to the source code of this file.

Functions

static uint32_t inverse (uint32_t v)
 find multiplicative inverse modulo 2 ^ 32 More...
 
static void multiswap_init (const uint8_t keybuf[48], uint32_t keys[12])
 read keys from keybuf into keys More...
 
static void multiswap_invert_keys (uint32_t keys[12])
 invert the keys so that encryption become decryption keys and the other way round. More...
 
static uint32_t multiswap_step (const uint32_t keys[6], uint32_t v)
 
static uint32_t multiswap_inv_step (const uint32_t keys[6], uint32_t v)
 
static uint64_t multiswap_enc (const uint32_t keys[12], uint64_t key, uint64_t data)
 "MultiSwap" encryption More...
 
static uint64_t multiswap_dec (const uint32_t keys[12], uint64_t key, uint64_t data)
 "MultiSwap" decryption More...
 
void ff_asfcrypt_dec (const uint8_t key[20], uint8_t *data, int len)
 

Function Documentation

◆ inverse()

static uint32_t inverse ( uint32_t  v)
static

find multiplicative inverse modulo 2 ^ 32

Parameters
vnumber to invert, must be odd!
Returns
number so that result * v = 1 (mod 2^32)

Definition at line 36 of file asfcrypt.c.

Referenced by multiswap_invert_keys().

◆ multiswap_init()

static void multiswap_init ( const uint8_t  keybuf[48],
uint32_t  keys[12] 
)
static

read keys from keybuf into keys

Parameters
keybufbuffer containing the keys
keysoutput key array containing the keys for encryption in native endianness

Definition at line 55 of file asfcrypt.c.

Referenced by ff_asfcrypt_dec().

◆ multiswap_invert_keys()

static void multiswap_invert_keys ( uint32_t  keys[12])
static

invert the keys so that encryption become decryption keys and the other way round.

Parameters
keyskey array of ints to invert

Definition at line 67 of file asfcrypt.c.

Referenced by ff_asfcrypt_dec().

◆ multiswap_step()

static uint32_t multiswap_step ( const uint32_t  keys[6],
uint32_t  v 
)
static

Definition at line 76 of file asfcrypt.c.

Referenced by multiswap_enc().

◆ multiswap_inv_step()

static uint32_t multiswap_inv_step ( const uint32_t  keys[6],
uint32_t  v 
)
static

Definition at line 88 of file asfcrypt.c.

Referenced by multiswap_dec().

◆ multiswap_enc()

static uint64_t multiswap_enc ( const uint32_t  keys[12],
uint64_t  key,
uint64_t  data 
)
static

"MultiSwap" encryption

Parameters
keys32 bit numbers in machine endianness, 0-4 and 6-10 must be inverted from decryption
keyanother key, this one must be the same for the decryption
datadata to encrypt
Returns
encrypted data

Definition at line 108 of file asfcrypt.c.

Referenced by ff_asfcrypt_dec().

◆ multiswap_dec()

static uint64_t multiswap_dec ( const uint32_t  keys[12],
uint64_t  key,
uint64_t  data 
)
static

"MultiSwap" decryption

Parameters
keys32 bit numbers in machine endianness, 0-4 and 6-10 must be inverted from encryption
keyanother key, this one must be the same as for the encryption
datadata to decrypt
Returns
decrypted data

Definition at line 132 of file asfcrypt.c.

Referenced by ff_asfcrypt_dec().

◆ ff_asfcrypt_dec()

void ff_asfcrypt_dec ( const uint8_t  key[20],
uint8_t *  data,
int  len 
)