tls.h 1.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/* Icecast
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
 * Copyright 2016,      Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
 */

#ifndef __TLS_H__
#define __TLS_H__

12 13
#include "common/net/sock.h"

14 15 16 17 18 19
/* Do we have TLS Support? */
#if defined(HAVE_OPENSSL)
#define ICECAST_CAP_TLS
#endif


20
typedef struct tls_ctx_tag tls_ctx_t;
21
typedef struct tls_tag tls_t;
22

23 24 25
/* Check for a specific implementation. Returns 0 if supported, 1 if unsupported and -1 on error. */
int        tls_check_impl(const char *impl);

26 27 28 29 30 31 32
void       tls_initialize(void);
void       tls_shutdown(void);

tls_ctx_t *tls_ctx_new(const char *cert_file, const char *key_file, const char *cipher_list);
void       tls_ctx_ref(tls_ctx_t *ctx);
void       tls_ctx_unref(tls_ctx_t *ctx);

33 34 35 36 37 38 39 40 41 42 43 44 45
tls_t     *tls_new(tls_ctx_t *ctx);
void       tls_ref(tls_t *tls);
void       tls_unref(tls_t *tls);

void       tls_set_incoming(tls_t *tls);
void       tls_set_socket(tls_t *tls, sock_t sock);

int        tls_want_io(tls_t *tls);

int        tls_got_shutdown(tls_t *tls);

ssize_t    tls_read(tls_t *tls, void *buffer, size_t len);
ssize_t    tls_write(tls_t *tls, const void *buffer, size_t len);
46 47

#endif