summaryrefslogtreecommitdiff
path: root/vchat-tls.h
diff options
context:
space:
mode:
Diffstat (limited to 'vchat-tls.h')
-rw-r--r--vchat-tls.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/vchat-tls.h b/vchat-tls.h
new file mode 100644
index 0000000..2771173
--- /dev/null
+++ b/vchat-tls.h
@@ -0,0 +1,58 @@
1#pragma once
2
3/* prototypes */
4
5typedef int (*vc_askpass_cb_t)(char *, int, int, void *);
6struct vc_x509store_t {
7 char *cafile;
8 char *capath;
9 char *crlfile;
10 vc_askpass_cb_t askpass_callback;
11 char *certfile;
12 char *keyfile;
13 int flags;
14};
15typedef struct vc_x509store_t vc_x509store_t;
16
17void vc_x509store_set_pkeycb(vc_x509store_t *, vc_askpass_cb_t);
18void vc_x509store_setflags(vc_x509store_t *, int);
19void vc_x509store_setkeyfile(vc_x509store_t *, char *);
20void vc_x509store_setcertfile(vc_x509store_t *, char *);
21void vc_x509store_setcafile(vc_x509store_t *, char *);
22void vc_x509store_clearflags(vc_x509store_t *, int);
23void vc_x509store_setcapath(vc_x509store_t *, char *);
24void vc_x509store_setcrlfile(vc_x509store_t *, char *);
25void vc_cleanup_x509store(vc_x509store_t *s);
26
27#if !defined(TLS_LIB_OPENSSL) && !defined(TLS_LIB_MBEDTLS)
28#error \
29 "Neither TLS_LIB_OPENSSL nor TLS_LIB_MBEDTLS are defined. Please select at least one."
30#endif
31
32#ifdef TLS_LIB_OPENSSL
33void vc_openssl_init_x509store(vc_x509store_t *);
34int vc_openssl_connect(int serverfd, vc_x509store_t *);
35ssize_t vc_openssl_sendmessage(const void *buf, size_t size);
36ssize_t vc_openssl_receivemessage(void *buf, size_t size);
37void vc_openssl_cleanup();
38char *vc_openssl_version();
39#endif
40
41#ifdef TLS_LIB_MBEDTLS
42void vc_mbedtls_init_x509store(vc_x509store_t *);
43int vc_mbedtls_connect(int serverfd, vc_x509store_t *);
44ssize_t vc_mbedtls_sendmessage(const void *buf, size_t size);
45ssize_t vc_mbedtls_receivemessage(void *buf, size_t size);
46void vc_mbedtls_cleanup();
47char *vc_mbedtls_version();
48#endif
49
50#define VC_X509S_USE_CAFILE 0x01
51#define VC_X509S_USE_CAPATH 0x02
52#define VC_X509S_USE_CERTIFICATE 0x04
53#define VC_X509S_SSL_VERIFY_NONE 0x10
54#define VC_X509S_SSL_VERIFY_PEER 0x20
55#define VC_X509S_SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x40
56#define VC_X509S_SSL_VERIFY_CLIENT_ONCE 0x80
57#define VC_X509S_SSL_VERIFY_MASK 0xF0
58