FFmpeg
Loading...
Searching...
No Matches
tls.h File Reference
#include "libavutil/bprint.h"
#include "libavutil/opt.h"
#include "url.h"

Go to the source code of this file.

Data Structures

struct  TLSShared
 

Macros

#define MAX_CERTIFICATE_SIZE   8192
 Maximum size limit of a certificate and private key size.
 
#define DTLS_CONTENT_TYPE_CHANGE_CIPHER_SPEC   20
 The DTLS content type.
 
#define DTLS_RECORD_LAYER_HEADER_LEN   13
 The DTLS record layer header has a total size of 13 bytes, consisting of ContentType (1 byte), ProtocolVersion (2 bytes), Epoch (2 bytes), SequenceNumber (6 bytes), and Length (2 bytes).
 
#define DTLS_VERSION_10   0xfeff
 The DTLS version number, which is 0xfeff for DTLS 1.0, or 0xfefd for DTLS 1.2.
 
#define DTLS_VERSION_12   0xfefd
 
#define TLS_OPTFL   (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
 
#define FF_TLS_CLIENT_OPTIONS(pstruct, options_field)
 
#define TLS_COMMON_OPTIONS(pstruct, options_field)
 

Functions

int ff_tls_parse_host (TLSShared *s, char *hostname, int hostname_size, int *port_ptr, const char *uri)
 
int ff_tls_open_underlying (TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options)
 
int ff_url_read_all (const char *url, AVBPrint *bp)
 Read all data from the given URL url and store it in the given buffer bp.
 
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)
 
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)
 
int ff_ssl_gen_key_cert (char *key_buf, size_t key_sz, char *cert_buf, size_t cert_sz, char **fingerprint)
 
void ff_gnutls_init (void)
 
void ff_gnutls_deinit (void)
 
int ff_is_dtls_packet (const uint8_t *buf, int size)
 Whether the packet is a DTLS packet, as defined by RFC 5764 Section 5.1.2.
 

Macro Definition Documentation

◆ MAX_CERTIFICATE_SIZE

#define MAX_CERTIFICATE_SIZE   8192

Maximum size limit of a certificate and private key size.

Definition at line 34 of file tls.h.

Referenced by ff_ssl_read_key_cert(), and tls_load_key_cert().

◆ DTLS_CONTENT_TYPE_CHANGE_CIPHER_SPEC

#define DTLS_CONTENT_TYPE_CHANGE_CIPHER_SPEC   20

The DTLS content type.

See https://tools.ietf.org/html/rfc2246#section-6.2.1 change_cipher_spec(20), alert(21), handshake(22), application_data(23)

Definition at line 41 of file tls.h.

Referenced by ff_is_dtls_packet().

◆ DTLS_RECORD_LAYER_HEADER_LEN

#define DTLS_RECORD_LAYER_HEADER_LEN   13

The DTLS record layer header has a total size of 13 bytes, consisting of ContentType (1 byte), ProtocolVersion (2 bytes), Epoch (2 bytes), SequenceNumber (6 bytes), and Length (2 bytes).

See https://datatracker.ietf.org/doc/html/rfc9147#section-4

Definition at line 48 of file tls.h.

Referenced by ff_is_dtls_packet().

◆ DTLS_VERSION_10

#define DTLS_VERSION_10   0xfeff

The DTLS version number, which is 0xfeff for DTLS 1.0, or 0xfefd for DTLS 1.2.

See https://datatracker.ietf.org/doc/html/rfc9147#name-the-dtls-record-layer

Definition at line 53 of file tls.h.

Referenced by ff_is_dtls_packet().

◆ DTLS_VERSION_12

#define DTLS_VERSION_12   0xfefd

Definition at line 54 of file tls.h.

Referenced by ff_is_dtls_packet().

◆ TLS_OPTFL

Definition at line 88 of file tls.h.

◆ FF_TLS_CLIENT_OPTIONS

#define FF_TLS_CLIENT_OPTIONS ( pstruct,
options_field )
Value:
{"ca_file", "Certificate Authority database file", offsetof(pstruct, options_field . ca_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"cafile", "Certificate Authority database file", offsetof(pstruct, options_field . ca_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"tls_verify", "Verify the peer certificate", offsetof(pstruct, options_field . verify), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, .flags = TLS_OPTFL }, \
{"verify", "Verify the peer certificate", offsetof(pstruct, options_field . verify), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, .flags = TLS_OPTFL }, \
{"cert_file", "Certificate file", offsetof(pstruct, options_field . cert_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"cert", "Certificate file", offsetof(pstruct, options_field . cert_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"key_file", "Private key file", offsetof(pstruct, options_field . key_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"key", "Private key file", offsetof(pstruct, options_field . key_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"verifyhost", "Verify against a specific hostname", offsetof(pstruct, options_field . host), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ 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_OPTFL
Definition tls.h:88

Definition at line 90 of file tls.h.

◆ TLS_COMMON_OPTIONS

#define TLS_COMMON_OPTIONS ( pstruct,
options_field )
Value:
{"listen", "Listen for incoming connections", offsetof(pstruct, options_field . listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = TLS_OPTFL }, \
{"http_proxy", "Set proxy to tunnel through", offsetof(pstruct, options_field . http_proxy), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"external_sock", "Use external socket", offsetof(pstruct, options_field . external_sock), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = TLS_OPTFL }, \
{"use_srtp", "Enable use_srtp DTLS extension", offsetof(pstruct, options_field . use_srtp), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = TLS_OPTFL }, \
{"mtu", "Maximum Transmission Unit", offsetof(pstruct, options_field . mtu), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = TLS_OPTFL}, \
{"cert_pem", "Certificate PEM string", offsetof(pstruct, options_field . cert_buf), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"key_pem", "Private key PEM string", offsetof(pstruct, options_field . key_buf), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
FF_TLS_CLIENT_OPTIONS(pstruct, options_field)
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258

Definition at line 101 of file tls.h.

Function Documentation

◆ ff_tls_parse_host()

int ff_tls_parse_host ( TLSShared * s,
char * hostname,
int hostname_size,
int * port_ptr,
const char * uri )

Definition at line 35 of file tls.c.

Referenced by ff_tls_open_underlying(), tls_open(), tls_open(), and tls_open().

◆ ff_tls_open_underlying()

int ff_tls_open_underlying ( TLSShared * c,
URLContext * parent,
const char * uri,
AVDictionary ** options )

Definition at line 54 of file tls.c.

Referenced by ff_tls_open(), tls_open(), tls_open(), tls_open(), tls_open(), and tls_open().

◆ ff_url_read_all()

int ff_url_read_all ( const char * url,
AVBPrint * bp )

Read all data from the given URL url and store it in the given buffer bp.

Definition at line 128 of file tls.c.

Referenced by ff_ssl_read_key_cert(), and tls_load_key_cert().

◆ ff_tls_set_external_socket()

int ff_tls_set_external_socket ( URLContext * h,
URLContext * sock )

Definition at line 366 of file tls_gnutls.c.

Referenced by dtls_initialize().

◆ ff_dtls_export_materials()

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

Definition at line 379 of file tls_gnutls.c.

Referenced by setup_srtp().

◆ 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 115 of file tls_gnutls.c.

Referenced by certificate_key_init().

◆ 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 299 of file tls_gnutls.c.

Referenced by certificate_key_init().

◆ ff_gnutls_init()

void ff_gnutls_init ( void )

Definition at line 348 of file tls_gnutls.c.

Referenced by ff_tls_init(), and tls_open().

◆ ff_gnutls_deinit()

void ff_gnutls_deinit ( void )

Definition at line 359 of file tls_gnutls.c.

Referenced by ff_tls_deinit(), and tls_close().

◆ ff_is_dtls_packet()

int ff_is_dtls_packet ( const uint8_t * buf,
int size )

Whether the packet is a DTLS packet, as defined by RFC 5764 Section 5.1.2.

Definition at line 167 of file tls.c.

Referenced by ice_dtls_handshake(), mbedtls_recv(), and whip_write_packet().