FFmpeg
Loading...
Searching...
No Matches
tls_mbedtls.c File Reference
#include <mbedtls/version.h>
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/entropy.h>
#include <mbedtls/net_sockets.h>
#include <mbedtls/platform.h>
#include <mbedtls/ssl.h>
#include <mbedtls/x509_crt.h>
#include <mbedtls/debug.h>
#include <mbedtls/timing.h>
#include "config_components.h"
#include "avformat.h"
#include "internal.h"
#include "network.h"
#include "url.h"
#include "tls.h"
#include "libavutil/mem.h"
#include "libavutil/parseutils.h"
#include "libavutil/avstring.h"
#include "libavutil/random_seed.h"

Go to the source code of this file.

Data Structures

struct  dtls_srtp_keys
 
struct  TLSContext
 

Macros

#define OFFSET(x)
 

Functions

static int mbedtls_x509_fingerprint (char *cert_buf, size_t cert_sz, char **fingerprint)
 
int ff_ssl_read_key_cert (char *key_url, char *cert_url, char *key_buf, size_t key_sz, char *cert_buf, size_t cert_sz, char **fingerprint)
 
static int mbedtls_gen_pkey (mbedtls_pk_context *key)
 
static int mbedtls_gen_x509_cert (mbedtls_pk_context *key, char *cert_buf, size_t cert_sz)
 
int ff_ssl_gen_key_cert (char *key_buf, size_t key_sz, char *cert_buf, size_t cert_sz, char **fingerprint)
 
int ff_tls_set_external_socket (URLContext *h, URLContext *sock)
 
int ff_dtls_export_materials (URLContext *h, char *dtls_srtp_materials, size_t materials_sz)
 
static int tls_close (URLContext *h)
 
static int handle_transport_error (URLContext *h, const char *func_name, int react_on_eagain, int ret)
 
static int mbedtls_send (void *ctx, const unsigned char *buf, size_t len)
 
static int mbedtls_recv (void *ctx, unsigned char *buf, size_t len)
 
static void mbedtls_debug (void *ctx, int lvl, const char *file, int line, const char *msg)
 
static void handle_pk_parse_error (URLContext *h, int ret)
 
static void handle_handshake_error (URLContext *h, int ret)
 
static int tls_handshake (URLContext *h)
 
static int tls_open (URLContext *h, const char *uri, int flags, AVDictionary **options)
 
static int dtls_open (URLContext *h, const char *uri, int flags, AVDictionary **options)
 
static int handle_tls_error (URLContext *h, const char *func_name, int ret)
 
static int tls_read (URLContext *h, uint8_t *buf, int size)
 
static int tls_write (URLContext *h, const uint8_t *buf, int size)
 
static int tls_get_file_handle (URLContext *h)
 
static int tls_get_short_seek (URLContext *h)
 

Variables

static const AVOption options []
 
static const AVClass tls_class
 
const URLProtocol ff_tls_protocol
 
static const AVClass dtls_class
 
const URLProtocol ff_dtls_protocol
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET ( x)
Value:
offsetof(TLSContext, x)

Definition at line 329 of file tls_mbedtls.c.

Function Documentation

◆ mbedtls_x509_fingerprint()

static int mbedtls_x509_fingerprint ( char * cert_buf,
size_t cert_sz,
char ** fingerprint )
static

Definition at line 47 of file tls_mbedtls.c.

Referenced by ff_ssl_gen_key_cert(), and ff_ssl_read_key_cert().

◆ ff_ssl_read_key_cert()

int ff_ssl_read_key_cert ( char * key_url,
char * cert_url,
char * key_buf,
size_t key_sz,
char * cert_buf,
size_t cert_sz,
char ** fingerprint )

Definition at line 76 of file tls_mbedtls.c.

◆ mbedtls_gen_pkey()

static int mbedtls_gen_pkey ( mbedtls_pk_context * key)
static

See RFC 8827 section 6.5, All implementations MUST support DTLS 1.2 with the TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 cipher suite and the P-256 curve.

Definition at line 113 of file tls_mbedtls.c.

Referenced by ff_ssl_gen_key_cert(), and tls_open().

◆ mbedtls_gen_x509_cert()

static int mbedtls_gen_x509_cert ( mbedtls_pk_context * key,
char * cert_buf,
size_t cert_sz )
static

Definition at line 151 of file tls_mbedtls.c.

Referenced by ff_ssl_gen_key_cert(), and tls_open().

◆ ff_ssl_gen_key_cert()

int ff_ssl_gen_key_cert ( char * key_buf,
size_t key_sz,
char * cert_buf,
size_t cert_sz,
char ** fingerprint )

Definition at line 221 of file tls_mbedtls.c.

◆ ff_tls_set_external_socket()

int ff_tls_set_external_socket ( URLContext * h,
URLContext * sock )

Definition at line 268 of file tls_mbedtls.c.

◆ ff_dtls_export_materials()

int ff_dtls_export_materials ( URLContext * h,
char * dtls_srtp_materials,
size_t materials_sz )

Definition at line 302 of file tls_mbedtls.c.

◆ tls_close()

static int tls_close ( URLContext * h)
static

Definition at line 331 of file tls_mbedtls.c.

Referenced by tls_open().

◆ handle_transport_error()

static int handle_transport_error ( URLContext * h,
const char * func_name,
int react_on_eagain,
int ret )
static

Definition at line 349 of file tls_mbedtls.c.

Referenced by mbedtls_recv(), and mbedtls_send().

◆ mbedtls_send()

static int mbedtls_send ( void * ctx,
const unsigned char * buf,
size_t len )
static

Definition at line 366 of file tls_mbedtls.c.

Referenced by tls_open().

◆ mbedtls_recv()

static int mbedtls_recv ( void * ctx,
unsigned char * buf,
size_t len )
static

Definition at line 381 of file tls_mbedtls.c.

Referenced by tls_open().

◆ mbedtls_debug()

static void mbedtls_debug ( void * ctx,
int lvl,
const char * file,
int line,
const char * msg )
static

Definition at line 412 of file tls_mbedtls.c.

Referenced by tls_open().

◆ handle_pk_parse_error()

static void handle_pk_parse_error ( URLContext * h,
int ret )
static

Definition at line 419 of file tls_mbedtls.c.

Referenced by tls_open().

◆ handle_handshake_error()

static void handle_handshake_error ( URLContext * h,
int ret )
static

Definition at line 437 of file tls_mbedtls.c.

Referenced by tls_handshake().

◆ tls_handshake()

static int tls_handshake ( URLContext * h)
static

Definition at line 473 of file tls_mbedtls.c.

Referenced by tls_open().

◆ tls_open()

static int tls_open ( URLContext * h,
const char * uri,
int flags,
AVDictionary ** options )
static

Definition at line 509 of file tls_mbedtls.c.

Referenced by dtls_open().

◆ dtls_open()

static int dtls_open ( URLContext * h,
const char * uri,
int flags,
AVDictionary ** options )
static

Definition at line 716 of file tls_mbedtls.c.

◆ handle_tls_error()

static int handle_tls_error ( URLContext * h,
const char * func_name,
int ret )
static

Definition at line 724 of file tls_mbedtls.c.

Referenced by tls_read(), and tls_write().

◆ tls_read()

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

Definition at line 746 of file tls_mbedtls.c.

◆ tls_write()

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

Definition at line 763 of file tls_mbedtls.c.

◆ tls_get_file_handle()

static int tls_get_file_handle ( URLContext * h)
static

Definition at line 780 of file tls_mbedtls.c.

◆ tls_get_short_seek()

static int tls_get_short_seek ( URLContext * h)
static

Definition at line 786 of file tls_mbedtls.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{"key_password", "Password for the private key file", OFFSET(priv_key_pw), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL },
{ NULL }
}
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
#define TLS_COMMON_OPTIONS(pstruct, options_field)
Definition tls.h:101
#define TLS_OPTFL
Definition tls.h:88

Definition at line 792 of file tls_mbedtls.c.

◆ tls_class

const AVClass tls_class
static
Initial value:
= {
.class_name = "tls",
.item_name = av_default_item_name,
.option = options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 798 of file tls_mbedtls.c.

◆ ff_tls_protocol

const URLProtocol ff_tls_protocol
Initial value:
= {
.name = "tls",
.url_open2 = tls_open,
.url_read = tls_read,
.url_write = tls_write,
.url_close = tls_close,
.url_get_file_handle = tls_get_file_handle,
.url_get_short_seek = tls_get_short_seek,
.priv_data_size = sizeof(TLSContext),
.priv_data_class = &tls_class,
}
#define flags(name, subs,...)
Definition cbs_h264.c:74
static int tls_close(URLContext *h)
Definition tls_gnutls.c:419
static const AVClass tls_class
Definition tls_gnutls.c:764
static int tls_read(URLContext *h, uint8_t *buf, int size)
Definition tls_gnutls.c:707
static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **options)
Definition tls_gnutls.c:532
static int tls_get_short_seek(URLContext *h)
Definition tls_gnutls.c:753
static int tls_write(URLContext *h, const uint8_t *buf, int size)
Definition tls_gnutls.c:724
static int tls_get_file_handle(URLContext *h)
Definition tls_gnutls.c:747
#define URL_PROTOCOL_FLAG_NETWORK
Definition url.h:33

Definition at line 805 of file tls_mbedtls.c.

◆ dtls_class

const AVClass dtls_class
static
Initial value:
= {
.class_name = "dtls",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 818 of file tls_mbedtls.c.

◆ ff_dtls_protocol

const URLProtocol ff_dtls_protocol
Initial value:
= {
.name = "dtls",
.url_open2 = dtls_open,
.url_handshake = tls_handshake,
.url_read = tls_read,
.url_write = tls_write,
.url_close = tls_close,
.url_get_file_handle = tls_get_file_handle,
.url_get_short_seek = tls_get_short_seek,
.priv_data_size = sizeof(TLSContext),
.priv_data_class = &dtls_class,
}
static int tls_handshake(URLContext *h)
Definition tls_gnutls.c:506
static int dtls_open(URLContext *h, const char *uri, int flags, AVDictionary **options)
Definition tls_gnutls.c:699
static const AVClass dtls_class
Definition tls_gnutls.c:784

Definition at line 825 of file tls_mbedtls.c.