FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
rtmpdh.c File Reference

RTMP Diffie-Hellmann utilities. More...

#include "config.h"
#include "rtmpdh.h"
#include "libavutil/random_seed.h"

Go to the source code of this file.

Macros

#define P1024
 
#define Q1024
 

Functions

static int dh_is_valid_public_key (FFBigNum y, FFBigNum p, FFBigNum q)
 
av_cold FF_DH * ff_dh_init (int key_len)
 Initialize a Diffie-Hellmann context. More...
 
int ff_dh_generate_public_key (FF_DH *dh)
 Generate a public key. More...
 
int ff_dh_write_public_key (FF_DH *dh, uint8_t *pub_key, int pub_key_len)
 Write the public key into the given buffer. More...
 
int ff_dh_compute_shared_secret_key (FF_DH *dh, const uint8_t *pub_key, int pub_key_len, uint8_t *secret_key, int secret_key_len)
 Compute the shared secret key from the private FF_DH value and the other party's public value. More...
 

Detailed Description

RTMP Diffie-Hellmann utilities.

Definition in file rtmpdh.c.

Macro Definition Documentation

#define P1024
Value:
"FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
"29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
"EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
"E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
"EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381" \
"FFFFFFFFFFFFFFFF"

Definition at line 33 of file rtmpdh.c.

Referenced by ff_dh_init().

#define Q1024
Value:
"7FFFFFFFFFFFFFFFE487ED5110B4611A62633145C06E0E68" \
"948127044533E63A0105DF531D89CD9128A5043CC71A026E" \
"F7CA8CD9E69D218D98158536F92F8A1BA7F09AB6B6A8E122" \
"F242DABB312F3F637A262174D31BF6B585FFAE5B7A035BF6" \
"F71C35FDAD44CFD2D74F9208BE258FF324943328F67329C0" \
"FFFFFFFFFFFFFFFF"

Definition at line 41 of file rtmpdh.c.

Referenced by ff_dh_compute_shared_secret_key(), and ff_dh_generate_public_key().

Function Documentation

static int dh_is_valid_public_key ( FFBigNum  y,
FFBigNum  p,
FFBigNum  q 
)
static

Definition at line 222 of file rtmpdh.c.

Referenced by ff_dh_compute_shared_secret_key(), and ff_dh_generate_public_key().

av_cold FF_DH* ff_dh_init ( int  key_len)

Initialize a Diffie-Hellmann context.

Parameters
key_lenlength of the key
Returns
a new Diffie-Hellmann context on success, NULL otherwise

Definition at line 261 of file rtmpdh.c.

Referenced by ff_rtmpe_gen_pub_key().

int ff_dh_generate_public_key ( FF_DH *  dh)

Generate a public key.

Parameters
dha Diffie-Hellmann context
Returns
zero on success, negative value otherwise

Definition at line 288 of file rtmpdh.c.

Referenced by ff_rtmpe_gen_pub_key().

int ff_dh_write_public_key ( FF_DH *  dh,
uint8_t pub_key,
int  pub_key_len 
)

Write the public key into the given buffer.

Parameters
dha Diffie-Hellmann context, containing the public key to write
pub_keythe buffer where the public key is written
pub_key_lenthe length of the buffer
Returns
zero on success, negative value otherwise

Definition at line 314 of file rtmpdh.c.

Referenced by ff_rtmpe_gen_pub_key().

int ff_dh_compute_shared_secret_key ( FF_DH *  dh,
const uint8_t pub_key,
int  pub_key_len,
uint8_t secret_key,
int  secret_key_len 
)

Compute the shared secret key from the private FF_DH value and the other party's public value.

Parameters
dha Diffie-Hellmann context, containing the private key
pub_keythe buffer containing the public key
pub_key_lenthe length of the public key buffer
secret_keythe buffer where the secret key is written
secret_key_lenthe length of the secret key buffer
Returns
length of the shared secret key on success, negative value otherwise

Definition at line 330 of file rtmpdh.c.

Referenced by ff_rtmpe_compute_secret_key().