1 //
2 //  btls-ssl-ctx.h
3 //  MonoBtls
4 //
5 //  Created by Martin Baulig on 4/11/16.
6 //  Copyright © 2016 Xamarin. All rights reserved.
7 //
8 
9 #ifndef __btls_ssl_ctx__btls_ssl_ctx__
10 #define __btls_ssl_ctx__btls_ssl_ctx__
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include <openssl/ssl.h>
16 #include <btls-util.h>
17 
18 typedef struct MonoBtlsBio MonoBtlsBio;
19 typedef struct MonoBtlsX509Chain MonoBtlsX509Chain;
20 typedef struct MonoBtlsX509Crl MonoBtlsX509Crl;
21 typedef struct MonoBtlsX509Lookup MonoBtlsX509Lookup;
22 typedef struct MonoBtlsX509LookupMono MonoBtlsX509LookupMono;
23 typedef struct MonoBtlsX509Name MonoBtlsX509Name;
24 typedef struct MonoBtlsX509Store MonoBtlsX509Store;
25 typedef struct MonoBtlsX509StoreCtx MonoBtlsX509StoreCtx;
26 typedef struct MonoBtlsX509Revoked MonoBtlsX509Revoked;
27 typedef struct MonoBtlsX509VerifyParam MonoBtlsX509VerifyParam;
28 typedef struct MonoBtlsPkcs12 MonoBtlsPkcs12;
29 typedef struct MonoBtlsSsl MonoBtlsSsl;
30 typedef struct MonoBtlsSslCtx MonoBtlsSslCtx;
31 
32 typedef int (* MonoBtlsVerifyFunc) (void *instance, int preverify_ok, X509_STORE_CTX *ctx);
33 typedef int (* MonoBtlsSelectFunc) (void *instance);
34 
35 MonoBtlsSslCtx *
36 mono_btls_ssl_ctx_new (void);
37 
38 MonoBtlsSslCtx *
39 mono_btls_ssl_ctx_up_ref (MonoBtlsSslCtx *ctx);
40 
41 int
42 mono_btls_ssl_ctx_free (MonoBtlsSslCtx *ctx);
43 
44 void
45 mono_btls_ssl_ctx_initialize (MonoBtlsSslCtx *ctx, void *instance);
46 
47 SSL_CTX *
48 mono_btls_ssl_ctx_get_ctx (MonoBtlsSslCtx *ctx);
49 
50 int
51 mono_btls_ssl_ctx_debug_printf (MonoBtlsSslCtx *ctx, const char *format, ...);
52 
53 int
54 mono_btls_ssl_ctx_is_debug_enabled (MonoBtlsSslCtx *ctx);
55 
56 void
57 mono_btls_ssl_ctx_set_cert_verify_callback (MonoBtlsSslCtx *ptr, MonoBtlsVerifyFunc func, int cert_required);
58 
59 void
60 mono_btls_ssl_ctx_set_cert_select_callback (MonoBtlsSslCtx *ptr, MonoBtlsSelectFunc func);
61 
62 void
63 mono_btls_ssl_ctx_set_debug_bio (MonoBtlsSslCtx *ctx, BIO *debug_bio);
64 
65 X509_STORE *
66 mono_btls_ssl_ctx_peek_store (MonoBtlsSslCtx *ctx);
67 
68 void
69 mono_btls_ssl_ctx_set_min_version (MonoBtlsSslCtx *ctx, int version);
70 
71 void
72 mono_btls_ssl_ctx_set_max_version (MonoBtlsSslCtx *ctx, int version);
73 
74 int
75 mono_btls_ssl_ctx_is_cipher_supported (MonoBtlsSslCtx *ctx, uint16_t value);
76 
77 int
78 mono_btls_ssl_ctx_set_ciphers (MonoBtlsSslCtx *ctx, int count, const uint16_t *data,
79 				   int allow_unsupported);
80 
81 int
82 mono_btls_ssl_ctx_set_verify_param (MonoBtlsSslCtx *ctx, const MonoBtlsX509VerifyParam *param);
83 
84 #endif /* __btls_ssl_ctx__btls_ssl_ctx__ */
85