]> git.sesse.net Git - vlc/blob - include/vlc_tls.h
Client-side anonymous TLS/SSL support
[vlc] / include / vlc_tls.h
1 /*****************************************************************************
2  * tls.c
3  *****************************************************************************
4  * Copyright (C) 2004 VideoLAN
5  * $Id: httpd.c 8263 2004-07-24 09:06:58Z courmisch $
6  *
7  * Authors: Remi Denis-Courmont <courmisch@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #ifndef _VLC_TLS_H
25 # define _VLC_TLS_H
26
27 struct tls_t
28 {
29     VLC_COMMON_MEMBERS
30
31     /* Module properties */
32     module_t  *p_module;
33     void *p_sys;
34
35     tls_server_t * (*pf_server_create) ( tls_t *, const char *, const char * );
36     tls_session_t * (*pf_client_create) ( tls_t *, const char * );
37 };
38
39 struct tls_server_t
40 {
41     tls_t *p_tls;
42     void *p_sys;
43
44     void (*pf_delete) ( tls_server_t * );
45     
46     int (*pf_add_CA) ( tls_server_t *, const char * );
47     int (*pf_add_CRL) ( tls_server_t *, const char * );
48     
49     tls_session_t * (*pf_session_prepare) ( tls_server_t * );
50 };
51
52 struct tls_session_t
53 {
54     tls_t *p_tls;
55     tls_server_t *p_server;
56
57     void *p_sys;
58
59     tls_session_t * (*pf_handshake) ( tls_session_t *, int );
60     void (*pf_close) ( tls_session_t * );
61     int (*pf_send) ( tls_session_t *, const char *, int );
62     int (*pf_recv) ( tls_session_t *, char *, int );
63 };
64
65
66 /*****************************************************************************
67  * tls_ServerCreate:
68  *****************************************************************************
69  * Allocates a whole server's TLS credentials.
70  * Returns NULL on error.
71  *****************************************************************************/
72 # define __tls_ServerCreate( a, b, c ) (((tls_t *)a)->pf_server_create (a, b, c))
73 VLC_EXPORT( tls_server_t *, tls_ServerCreate, ( vlc_object_t *, const char *, const char * ) );
74
75 /*****************************************************************************
76  * tls_ServerAddCA:
77  *****************************************************************************
78  * Adds one or more certificate authorities.
79  * Returns -1 on error, 0 on success.
80  *****************************************************************************/
81 # define tls_ServerAddCA( a, b ) (((tls_server_t *)a)->pf_add_CA (a, b))
82
83
84 /*****************************************************************************
85  * tls_ServerAddCRL:
86  *****************************************************************************
87  * Adds a certificates revocation list to be sent to TLS clients.
88  * Returns -1 on error, 0 on success.
89  *****************************************************************************/
90 # define tls_ServerAddCRL( a, b ) (((tls_server_t *)a)->pf_add_CRL (a, b))
91
92
93 # define __tls_ServerDelete( a ) (((tls_server_t *)a)->pf_delete ( a ))
94 VLC_EXPORT( void, tls_ServerDelete, ( tls_server_t * ) );
95
96
97 # define tls_ServerSessionPrepare( a ) (((tls_server_t *)a)->pf_session_prepare (a))
98
99 # define __tls_ClientCreate( a, b ) (((tls_t *)a)->pf_client_create (a, b ))
100 VLC_EXPORT( tls_session_t *, tls_ClientCreate, ( vlc_object_t *, const char * ) );
101 VLC_EXPORT( void, tls_ClientDelete, ( tls_session_t * ) );
102
103 # define tls_SessionHandshake( a, b ) (((tls_session_t *)a)->pf_handshake (a, b))
104
105 # define tls_SessionClose( a ) (((tls_session_t *)a)->pf_close (a))
106 # define __tls_ClientDelete( a ) tls_SessionClose( a )
107
108 # define tls_Send( a, b, c ) (((tls_session_t *)a)->pf_send (a, b, c ))
109
110 # define tls_Recv( a, b, c ) (((tls_session_t *)a)->pf_recv (a, b, c ))
111
112 #endif