FFmpeg
Loading...
Searching...
No Matches
tls_schannel.c File Reference
#include "config.h"
#include "config_components.h"
#include "libavutil/mem.h"
#include "avformat.h"
#include "internal.h"
#include "network.h"
#include "os_support.h"
#include "url.h"
#include "tls.h"
#include <windows.h>
#include <security.h>
#include <schnlsp.h>
#include <sddl.h>

Go to the source code of this file.

Data Structures

struct  TLSContext
 

Macros

#define SECURITY_WIN32
 Based on the CURL SChannel module.
 
#define SCHANNEL_INITIAL_BUFFER_SIZE   4096
 
#define SCHANNEL_FREE_BUFFER_SIZE   1024
 
#define SECBUFFER_ALERT   17
 
#define FF_NCRYPT_TEMP_KEY_NAME   L"FFMPEG_TEMP_TLS_KEY"
 
#define OFFSET(x)
 

Functions

static int der_to_pem (const char *data, size_t len, const char *header, char *buf, size_t bufsize)
 
static int pem_to_der (const char *pem, char **buf, int *out_len)
 
static int der_to_fingerprint (const char *data, size_t len, char **fingerprint)
 
static int tls_gen_self_signed (NCRYPT_KEY_HANDLE *key, PCCERT_CONTEXT *crtctx)
 
static int tls_export_key_cert (NCRYPT_KEY_HANDLE key, PCCERT_CONTEXT crtctx, 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)
 
static int tls_import_key_cert (char *key_buf, char *cert_buf, NCRYPT_KEY_HANDLE *key, PCCERT_CONTEXT *crtctx)
 
static int tls_cert_from_store (void *logctx, const char *cert_store_name, const char *cert_subj, PCCERT_CONTEXT *crtctx)
 
static int tls_load_key_cert (char *key_url, char *cert_url, NCRYPT_KEY_HANDLE *key, PCCERT_CONTEXT *crtctx)
 
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_tls_set_external_socket (URLContext *h, URLContext *sock)
 
int ff_dtls_export_materials (URLContext *h, char *dtls_srtp_materials, size_t materials_sz)
 
static void init_sec_buffer (SecBuffer *buffer, unsigned long type, void *data, unsigned long size)
 
static void init_sec_buffer_desc (SecBufferDesc *desc, SecBuffer *buffers, unsigned long buffer_count)
 
static int tls_process_send_buffer (URLContext *h)
 
static int tls_shutdown_client (URLContext *h)
 
static int tls_close (URLContext *h)
 
static int tls_handshake_loop (URLContext *h, int initial)
 
static int tls_client_handshake (URLContext *h)
 
static int tls_server_handshake (URLContext *h)
 
static int tls_handshake (URLContext *h)
 
static int tls_open (URLContext *h, const char *uri, int flags, AVDictionary **options)
 
static int tls_read (URLContext *h, uint8_t *buf, int len)
 
static int tls_write (URLContext *h, const uint8_t *buf, int len)
 
static int tls_get_file_handle (URLContext *h)
 
static int tls_get_short_seek (URLContext *h)
 

Variables

static const AVOption options []
 

Macro Definition Documentation

◆ SECURITY_WIN32

#define SECURITY_WIN32

Based on the CURL SChannel module.

Definition at line 34 of file tls_schannel.c.

◆ SCHANNEL_INITIAL_BUFFER_SIZE

#define SCHANNEL_INITIAL_BUFFER_SIZE   4096

Definition at line 40 of file tls_schannel.c.

Referenced by tls_handshake_loop().

◆ SCHANNEL_FREE_BUFFER_SIZE

#define SCHANNEL_FREE_BUFFER_SIZE   1024

Definition at line 41 of file tls_schannel.c.

Referenced by tls_handshake_loop(), and tls_read().

◆ SECBUFFER_ALERT

#define SECBUFFER_ALERT   17

Definition at line 45 of file tls_schannel.c.

Referenced by tls_handshake_loop().

◆ FF_NCRYPT_TEMP_KEY_NAME

#define FF_NCRYPT_TEMP_KEY_NAME   L"FFMPEG_TEMP_TLS_KEY"

Definition at line 61 of file tls_schannel.c.

Referenced by tls_gen_self_signed(), and tls_import_key_cert().

◆ OFFSET

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

Definition at line 1449 of file tls_schannel.c.

Function Documentation

◆ der_to_pem()

static int der_to_pem ( const char * data,
size_t len,
const char * header,
char * buf,
size_t bufsize )
static

Definition at line 63 of file tls_schannel.c.

Referenced by tls_export_key_cert().

◆ pem_to_der()

static int pem_to_der ( const char * pem,
char ** buf,
int * out_len )
static

Definition at line 104 of file tls_schannel.c.

Referenced by tls_import_key_cert().

◆ der_to_fingerprint()

static int der_to_fingerprint ( const char * data,
size_t len,
char ** fingerprint )
static

Definition at line 127 of file tls_schannel.c.

Referenced by tls_export_key_cert().

◆ tls_gen_self_signed()

static int tls_gen_self_signed ( NCRYPT_KEY_HANDLE * key,
PCCERT_CONTEXT * crtctx )
static

Definition at line 148 of file tls_schannel.c.

Referenced by ff_ssl_gen_key_cert(), and tls_open().

◆ tls_export_key_cert()

static int tls_export_key_cert ( NCRYPT_KEY_HANDLE key,
PCCERT_CONTEXT crtctx,
char * key_buf,
size_t key_sz,
char * cert_buf,
size_t cert_sz,
char ** fingerprint )
static

Definition at line 327 of file tls_schannel.c.

Referenced by ff_ssl_gen_key_cert(), and ff_ssl_read_key_cert().

◆ 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 373 of file tls_schannel.c.

Referenced by certificate_key_init().

◆ tls_import_key_cert()

static int tls_import_key_cert ( char * key_buf,
char * cert_buf,
NCRYPT_KEY_HANDLE * key,
PCCERT_CONTEXT * crtctx )
static

Definition at line 396 of file tls_schannel.c.

Referenced by tls_load_key_cert(), and tls_open().

◆ tls_cert_from_store()

static int tls_cert_from_store ( void * logctx,
const char * cert_store_name,
const char * cert_subj,
PCCERT_CONTEXT * crtctx )
static

Definition at line 508 of file tls_schannel.c.

Referenced by tls_open().

◆ tls_load_key_cert()

static int tls_load_key_cert ( char * key_url,
char * cert_url,
NCRYPT_KEY_HANDLE * key,
PCCERT_CONTEXT * crtctx )
static

Definition at line 534 of file tls_schannel.c.

Referenced by ff_ssl_read_key_cert(), and tls_open().

◆ 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 566 of file tls_schannel.c.

Referenced by certificate_key_init().

◆ ff_tls_set_external_socket()

int ff_tls_set_external_socket ( URLContext * h,
URLContext * sock )

Definition at line 624 of file tls_schannel.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 637 of file tls_schannel.c.

Referenced by setup_srtp().

◆ init_sec_buffer()

static void init_sec_buffer ( SecBuffer * buffer,
unsigned long type,
void * data,
unsigned long size )
static

◆ init_sec_buffer_desc()

static void init_sec_buffer_desc ( SecBufferDesc * desc,
SecBuffer * buffers,
unsigned long buffer_count )
static

◆ tls_process_send_buffer()

static int tls_process_send_buffer ( URLContext * h)
static

Definition at line 699 of file tls_schannel.c.

Referenced by tls_shutdown_client(), and tls_write().

◆ tls_shutdown_client()

static int tls_shutdown_client ( URLContext * h)
static

Definition at line 728 of file tls_schannel.c.

Referenced by tls_close().

◆ tls_close()

static int tls_close ( URLContext * h)
static

Definition at line 789 of file tls_schannel.c.

Referenced by tls_open().

◆ tls_handshake_loop()

static int tls_handshake_loop ( URLContext * h,
int initial )
static

Definition at line 818 of file tls_schannel.c.

Referenced by tls_client_handshake(), tls_read(), and tls_server_handshake().

◆ tls_client_handshake()

static int tls_client_handshake ( URLContext * h)
static

Definition at line 1014 of file tls_schannel.c.

Referenced by tls_handshake().

◆ tls_server_handshake()

static int tls_server_handshake ( URLContext * h)
static

Definition at line 1061 of file tls_schannel.c.

Referenced by tls_handshake().

◆ tls_handshake()

static int tls_handshake ( URLContext * h)
static

Definition at line 1078 of file tls_schannel.c.

Referenced by tls_open().

◆ tls_open()

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

Definition at line 1112 of file tls_schannel.c.

◆ tls_read()

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

Definition at line 1213 of file tls_schannel.c.

◆ tls_write()

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

Definition at line 1367 of file tls_schannel.c.

◆ tls_get_file_handle()

static int tls_get_file_handle ( URLContext * h)
static

Definition at line 1435 of file tls_schannel.c.

◆ tls_get_short_seek()

static int tls_get_short_seek ( URLContext * h)
static

Definition at line 1442 of file tls_schannel.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "cert_store_subject", "Load certificate (and associated key) from users keystore by subject",
OFFSET(cert_store_subject), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL },
{ "cert_store_name", "Name of the specific cert store to search in (for cert_store_subject)",
OFFSET(cert_store_name), AV_OPT_TYPE_STRING, { .str = "MY" }, .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 1450 of file tls_schannel.c.