summaryrefslogtreecommitdiff
path: root/vchat-tls.h
blob: 27711734cc8106b0ba9df8aea89a86c547b7fa1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once

/* prototypes */

typedef int (*vc_askpass_cb_t)(char *, int, int, void *);
struct vc_x509store_t {
  char *cafile;
  char *capath;
  char *crlfile;
  vc_askpass_cb_t askpass_callback;
  char *certfile;
  char *keyfile;
  int flags;
};
typedef struct vc_x509store_t vc_x509store_t;

void vc_x509store_set_pkeycb(vc_x509store_t *, vc_askpass_cb_t);
void vc_x509store_setflags(vc_x509store_t *, int);
void vc_x509store_setkeyfile(vc_x509store_t *, char *);
void vc_x509store_setcertfile(vc_x509store_t *, char *);
void vc_x509store_setcafile(vc_x509store_t *, char *);
void vc_x509store_clearflags(vc_x509store_t *, int);
void vc_x509store_setcapath(vc_x509store_t *, char *);
void vc_x509store_setcrlfile(vc_x509store_t *, char *);
void vc_cleanup_x509store(vc_x509store_t *s);

#if !defined(TLS_LIB_OPENSSL) && !defined(TLS_LIB_MBEDTLS)
#error                                                                         \
    "Neither TLS_LIB_OPENSSL nor TLS_LIB_MBEDTLS are defined. Please select at least one."
#endif

#ifdef TLS_LIB_OPENSSL
void vc_openssl_init_x509store(vc_x509store_t *);
int vc_openssl_connect(int serverfd, vc_x509store_t *);
ssize_t vc_openssl_sendmessage(const void *buf, size_t size);
ssize_t vc_openssl_receivemessage(void *buf, size_t size);
void vc_openssl_cleanup();
char *vc_openssl_version();
#endif

#ifdef TLS_LIB_MBEDTLS
void vc_mbedtls_init_x509store(vc_x509store_t *);
int vc_mbedtls_connect(int serverfd, vc_x509store_t *);
ssize_t vc_mbedtls_sendmessage(const void *buf, size_t size);
ssize_t vc_mbedtls_receivemessage(void *buf, size_t size);
void vc_mbedtls_cleanup();
char *vc_mbedtls_version();
#endif

#define VC_X509S_USE_CAFILE                        0x01
#define VC_X509S_USE_CAPATH                        0x02
#define VC_X509S_USE_CERTIFICATE                   0x04
#define VC_X509S_SSL_VERIFY_NONE                   0x10
#define VC_X509S_SSL_VERIFY_PEER                   0x20
#define VC_X509S_SSL_VERIFY_FAIL_IF_NO_PEER_CERT   0x40
#define VC_X509S_SSL_VERIFY_CLIENT_ONCE            0x80
#define VC_X509S_SSL_VERIFY_MASK                   0xF0