FFmpeg
Data Structures | Macros | Functions | Variables
rtmpcrypt.c File Reference
#include "libavutil/blowfish.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/rc4.h"
#include "libavutil/xtea.h"
#include "internal.h"
#include "rtmp.h"
#include "rtmpdh.h"
#include "rtmpcrypt.h"
#include "url.h"

Go to the source code of this file.

Data Structures

struct  RTMPEContext
 

Macros

#define OFFSET(x)   offsetof(RTMPEContext, x)
 
#define DEC   AV_OPT_FLAG_DECODING_PARAM
 

Functions

int ff_rtmpe_gen_pub_key (URLContext *h, uint8_t *buf)
 Initialize the Diffie-Hellmann context and generate the public key. More...
 
int ff_rtmpe_compute_secret_key (URLContext *h, const uint8_t *serverdata, const uint8_t *clientdata, int type)
 Compute the shared secret key and initialize the RC4 encryption. More...
 
static void rtmpe8_sig (const uint8_t *in, uint8_t *out, int key_id)
 
static void rtmpe9_sig (const uint8_t *in, uint8_t *out, int key_id)
 
void ff_rtmpe_encrypt_sig (URLContext *h, uint8_t *sig, const uint8_t *digest, int type)
 Encrypt the signature. More...
 
int ff_rtmpe_update_keystream (URLContext *h)
 Update the keystream and set RC4 keys for encryption. More...
 
static int rtmpe_close (URLContext *h)
 
static int rtmpe_open (URLContext *h, const char *uri, int flags)
 
static int rtmpe_read (URLContext *h, uint8_t *buf, int size)
 
static int rtmpe_write (URLContext *h, const uint8_t *buf, int size)
 

Variables

static const uint8_t rtmpe8_keys [16][16]
 
static const uint8_t rtmpe9_keys [16][24]
 
static const AVOption ffrtmpcrypt_options []
 
static const AVClass ffrtmpcrypt_class
 
const URLProtocol ff_ffrtmpcrypt_protocol
 

Detailed Description

RTMPE protocol

Definition in file rtmpcrypt.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(RTMPEContext, x)

Definition at line 313 of file rtmpcrypt.c.

◆ DEC

#define DEC   AV_OPT_FLAG_DECODING_PARAM

Definition at line 314 of file rtmpcrypt.c.

Function Documentation

◆ ff_rtmpe_gen_pub_key()

int ff_rtmpe_gen_pub_key ( URLContext h,
uint8_t *  buf 
)

Initialize the Diffie-Hellmann context and generate the public key.

Parameters
han URLContext
bufhandshake data (1536 bytes)
Returns
zero on success, negative value otherwise

Definition at line 122 of file rtmpcrypt.c.

Referenced by rtmp_handshake().

◆ ff_rtmpe_compute_secret_key()

int ff_rtmpe_compute_secret_key ( URLContext h,
const uint8_t *  serverdata,
const uint8_t *  clientdata,
int  type 
)

Compute the shared secret key and initialize the RC4 encryption.

Parameters
han URLContext
serverdataserver data (1536 bytes)
clientdataclient data (1536 bytes)
typethe position of the server digest
Returns
zero on success, negative value otherwise

Definition at line 145 of file rtmpcrypt.c.

Referenced by rtmp_handshake().

◆ rtmpe8_sig()

static void rtmpe8_sig ( const uint8_t *  in,
uint8_t *  out,
int  key_id 
)
static

Definition at line 184 of file rtmpcrypt.c.

Referenced by ff_rtmpe_encrypt_sig().

◆ rtmpe9_sig()

static void rtmpe9_sig ( const uint8_t *  in,
uint8_t *  out,
int  key_id 
)
static

Definition at line 192 of file rtmpcrypt.c.

Referenced by ff_rtmpe_encrypt_sig().

◆ ff_rtmpe_encrypt_sig()

void ff_rtmpe_encrypt_sig ( URLContext h,
uint8_t *  signature,
const uint8_t *  digest,
int  type 
)

Encrypt the signature.

Parameters
han URLContext
signaturethe signature to encrypt
digestthe digest used for finding the encryption key
typetype of encryption (8 for XTEA, 9 for Blowfish)

Definition at line 207 of file rtmpcrypt.c.

Referenced by rtmp_handshake().

◆ ff_rtmpe_update_keystream()

int ff_rtmpe_update_keystream ( URLContext h)

Update the keystream and set RC4 keys for encryption.

Parameters
han URLContext
Returns
zero on success, negative value otherwise

Definition at line 223 of file rtmpcrypt.c.

Referenced by rtmp_handshake().

◆ rtmpe_close()

static int rtmpe_close ( URLContext h)
static

Definition at line 238 of file rtmpcrypt.c.

Referenced by rtmpe_open().

◆ rtmpe_open()

static int rtmpe_open ( URLContext h,
const char *  uri,
int  flags 
)
static

Definition at line 248 of file rtmpcrypt.c.

◆ rtmpe_read()

static int rtmpe_read ( URLContext h,
uint8_t *  buf,
int  size 
)
static

Definition at line 277 of file rtmpcrypt.c.

◆ rtmpe_write()

static int rtmpe_write ( URLContext h,
const uint8_t *  buf,
int  size 
)
static

Definition at line 297 of file rtmpcrypt.c.

Variable Documentation

◆ rtmpe8_keys

const uint8_t rtmpe8_keys[16][16]
static

Definition at line 52 of file rtmpcrypt.c.

Referenced by rtmpe8_sig().

◆ rtmpe9_keys

const uint8_t rtmpe9_keys[16][24]
static

Definition at line 87 of file rtmpcrypt.c.

Referenced by rtmpe9_sig().

◆ ffrtmpcrypt_options

const AVOption ffrtmpcrypt_options[]
static
Initial value:
= {
{"ffrtmpcrypt_tunneling", "Use a HTTP tunneling connection (RTMPTE).", OFFSET(tunneling), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC},
{ NULL },
}

Definition at line 316 of file rtmpcrypt.c.

◆ ffrtmpcrypt_class

const AVClass ffrtmpcrypt_class
static
Initial value:
= {
.class_name = "ffrtmpcrypt",
.item_name = av_default_item_name,
}

Definition at line 321 of file rtmpcrypt.c.

◆ ff_ffrtmpcrypt_protocol

const URLProtocol ff_ffrtmpcrypt_protocol
Initial value:
= {
.name = "ffrtmpcrypt",
.url_open = rtmpe_open,
.url_read = rtmpe_read,
.url_write = rtmpe_write,
.url_close = rtmpe_close,
.priv_data_size = sizeof(RTMPEContext),
.priv_data_class = &ffrtmpcrypt_class,
}

Definition at line 328 of file rtmpcrypt.c.

URL_PROTOCOL_FLAG_NETWORK
#define URL_PROTOCOL_FLAG_NETWORK
Definition: url.h:33
ffrtmpcrypt_class
static const AVClass ffrtmpcrypt_class
Definition: rtmpcrypt.c:321
DEC
#define DEC
Definition: rtmpcrypt.c:314
rtmpe_read
static int rtmpe_read(URLContext *h, uint8_t *buf, int size)
Definition: rtmpcrypt.c:277
rtmpe_close
static int rtmpe_close(URLContext *h)
Definition: rtmpcrypt.c:238
ffrtmpcrypt_options
static const AVOption ffrtmpcrypt_options[]
Definition: rtmpcrypt.c:316
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
OFFSET
#define OFFSET(x)
Definition: rtmpcrypt.c:313
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
RTMPEContext
Definition: rtmpcrypt.c:42
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
rtmpe_open
static int rtmpe_open(URLContext *h, const char *uri, int flags)
Definition: rtmpcrypt.c:248
rtmpe_write
static int rtmpe_write(URLContext *h, const uint8_t *buf, int size)
Definition: rtmpcrypt.c:297