1 /*****************************************************************************
2 * vlc_tls.h: Transport Layer Security API
3 *****************************************************************************
4 * Copyright (C) 2004-2011 RĂ©mi Denis-Courmont
5 * Copyright (C) 2005-2006 VLC authors and VideoLAN
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
20 *****************************************************************************/
27 * This file defines Transport Layer Security API (TLS) in vlc
30 # include <vlc_network.h>
32 typedef struct vlc_tls vlc_tls_t;
33 typedef struct vlc_tls_sys vlc_tls_sys_t;
34 typedef struct vlc_tls_creds vlc_tls_creds_t;
35 typedef struct vlc_tls_creds_sys vlc_tls_creds_sys_t;
43 module_t *module; /**< Plugin handle (client) */
47 struct virtual_socket_t sock;
48 int (*handshake) (struct vlc_tls *);
51 VLC_API vlc_tls_t *vlc_tls_ClientCreate (vlc_object_t *, int fd,
52 const char *hostname);
53 VLC_API void vlc_tls_ClientDelete (vlc_tls_t *);
55 /* NOTE: It is assumed that a->sock.p_sys = a */
56 # define tls_Send( a, b, c ) (((vlc_tls_t *)a)->sock.pf_send (a, b, c))
58 # define tls_Recv( a, b, c ) (((vlc_tls_t *)a)->sock.pf_recv (a, b, c))
61 /** TLS credentials (certificate, private and trust settings) */
67 vlc_tls_creds_sys_t *sys;
69 int (*add_CA) (vlc_tls_creds_t *, const char *path);
70 int (*add_CRL) (vlc_tls_creds_t *, const char *path);
72 int (*open) (vlc_tls_creds_t *, vlc_tls_t *, int fd);
73 void (*close) (vlc_tls_creds_t *, vlc_tls_t *);
76 vlc_tls_creds_t *vlc_tls_ServerCreate (vlc_object_t *,
77 const char *cert, const char *key);
78 void vlc_tls_Delete (vlc_tls_creds_t *);
79 #define vlc_tls_ServerDelete vlc_tls_Delete
80 int vlc_tls_ServerAddCA (vlc_tls_creds_t *srv, const char *path);
81 int vlc_tls_ServerAddCRL (vlc_tls_creds_t *srv, const char *path);
83 vlc_tls_t *vlc_tls_ServerSessionCreate (vlc_tls_creds_t *, int fd);
84 int vlc_tls_ServerSessionHandshake (vlc_tls_t *);
85 void vlc_tls_ServerSessionDelete (vlc_tls_t *);