Compy 0.2.0
A lightweight RTSP 1.0 server library for embedded systems
Loading...
Searching...
No Matches
tls.h File Reference

RTSPS (RTSP over TLS) support. More...

#include <compy/writer.h>
#include <stddef.h>
#include <unistd.h>
#include <compy/priv/compiler_attrs.h>
Include dependency graph for tls.h:

Go to the source code of this file.

Data Structures

struct  Compy_TlsConfig
 TLS configuration. More...
 

Typedefs

typedef struct Compy_TlsContext Compy_TlsContext
 Opaque TLS context (holds loaded cert/key, shared across connections).
 
typedef struct Compy_TlsConn Compy_TlsConn
 Opaque per-connection TLS state.
 

Functions

Compy_TlsContextCompy_TlsContext_new (Compy_TlsConfig config) COMPY_PRIV_MUST_USE
 Creates a new TLS context from configuration.
 
void Compy_TlsContext_free (Compy_TlsContext *ctx)
 Frees a TLS context.
 
Compy_TlsConnCompy_TlsConn_accept (Compy_TlsContext *ctx, int fd) COMPY_PRIV_MUST_USE
 Performs server-side TLS handshake on fd.
 
Compy_Writer compy_tls_writer (Compy_TlsConn *conn) COMPY_PRIV_MUST_USE
 Creates a Compy_Writer backed by a TLS connection.
 
ssize_t compy_tls_read (Compy_TlsConn *conn, void *buf, size_t len) COMPY_PRIV_MUST_USE
 Reads decrypted data from a TLS connection.
 
int compy_tls_shutdown (Compy_TlsConn *conn)
 Shuts down the TLS connection gracefully.
 
void Compy_TlsConn_free (Compy_TlsConn *conn)
 Frees per-connection TLS state.
 

Detailed Description

RTSPS (RTSP over TLS) support.

Provides server-side TLS for encrypted RTSP signaling. The application creates a TLS context (loading cert/key), accepts TLS connections, and uses the TLS writer for encrypted I/O. The TLS reader decrypts incoming RTSP requests.

Requires a compiled TLS backend (wolfSSL, mbedTLS, OpenSSL, or BearSSL).

Function Documentation

◆ compy_tls_read()

ssize_t compy_tls_read ( Compy_TlsConn conn,
void *  buf,
size_t  len 
)

Reads decrypted data from a TLS connection.

Used by the event-loop integration to read RTSP requests arriving over an encrypted connection.

Parameters
[in]connThe TLS connection.
[out]bufBuffer to read into.
[in]lenMaximum bytes to read.
Precondition
conn != NULL
buf != NULL
Returns
Bytes read, 0 on EOF, -1 on error.

◆ compy_tls_shutdown()

int compy_tls_shutdown ( Compy_TlsConn conn)

Shuts down the TLS connection gracefully.

Returns
0 on success, -1 on error.

◆ compy_tls_writer()

Compy_Writer compy_tls_writer ( Compy_TlsConn conn)

Creates a Compy_Writer backed by a TLS connection.

All data written through this writer is encrypted via TLS before being sent on the underlying socket.

Parameters
[in]connThe TLS connection.
Precondition
conn != NULL

◆ Compy_TlsConn_accept()

Compy_TlsConn * Compy_TlsConn_accept ( Compy_TlsContext ctx,
int  fd 
)

Performs server-side TLS handshake on fd.

This is a blocking call that completes the full TLS handshake.

Parameters
[in]ctxThe TLS context with loaded cert/key.
[in]fdThe connected socket file descriptor.
Precondition
ctx != NULL
fd >= 0
Returns
A new TLS connection, or NULL on handshake failure.

◆ Compy_TlsContext_new()

Compy_TlsContext * Compy_TlsContext_new ( Compy_TlsConfig  config)

Creates a new TLS context from configuration.

Parameters
[in]configCertificate and key file paths.
Precondition
config.cert_path != NULL
config.key_path != NULL
Returns
A new TLS context, or NULL on failure (cert/key load error).