diff options
Diffstat (limited to 'vchat-tls.h')
-rw-r--r-- | vchat-tls.h | 58 |
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 | |||
5 | typedef int (*vc_askpass_cb_t)(char *, int, int, void *); | ||
6 | struct 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 | }; | ||
15 | typedef struct vc_x509store_t vc_x509store_t; | ||
16 | |||
17 | void vc_x509store_set_pkeycb(vc_x509store_t *, vc_askpass_cb_t); | ||
18 | void vc_x509store_setflags(vc_x509store_t *, int); | ||
19 | void vc_x509store_setkeyfile(vc_x509store_t *, char *); | ||
20 | void vc_x509store_setcertfile(vc_x509store_t *, char *); | ||
21 | void vc_x509store_setcafile(vc_x509store_t *, char *); | ||
22 | void vc_x509store_clearflags(vc_x509store_t *, int); | ||
23 | void vc_x509store_setcapath(vc_x509store_t *, char *); | ||
24 | void vc_x509store_setcrlfile(vc_x509store_t *, char *); | ||
25 | void 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 | ||
33 | void vc_openssl_init_x509store(vc_x509store_t *); | ||
34 | int vc_openssl_connect(int serverfd, vc_x509store_t *); | ||
35 | ssize_t vc_openssl_sendmessage(const void *buf, size_t size); | ||
36 | ssize_t vc_openssl_receivemessage(void *buf, size_t size); | ||
37 | void vc_openssl_cleanup(); | ||
38 | char *vc_openssl_version(); | ||
39 | #endif | ||
40 | |||
41 | #ifdef TLS_LIB_MBEDTLS | ||
42 | void vc_mbedtls_init_x509store(vc_x509store_t *); | ||
43 | int vc_mbedtls_connect(int serverfd, vc_x509store_t *); | ||
44 | ssize_t vc_mbedtls_sendmessage(const void *buf, size_t size); | ||
45 | ssize_t vc_mbedtls_receivemessage(void *buf, size_t size); | ||
46 | void vc_mbedtls_cleanup(); | ||
47 | char *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 | |||