xref: /minix3/crypto/external/bsd/openssl/dist/demos/easy_tls/easy-tls.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1ebfedea0SLionel Sambuc /* -*- Mode: C; c-file-style: "bsd" -*- */
2*0a6a1f1dSLionel Sambuc /*-
3ebfedea0SLionel Sambuc  * easy-tls.h -- generic TLS proxy.
4ebfedea0SLionel Sambuc  * Id: easy-tls.h,v 1.1 2001/09/17 19:06:59 bodo Exp
5ebfedea0SLionel Sambuc  */
6ebfedea0SLionel Sambuc /*
7ebfedea0SLionel Sambuc  * (c) Copyright 1999 Bodo Moeller.  All rights reserved.
8ebfedea0SLionel Sambuc  */
9ebfedea0SLionel Sambuc 
10ebfedea0SLionel Sambuc #ifndef HEADER_TLS_H
11ebfedea0SLionel Sambuc # define HEADER_TLS_H
12ebfedea0SLionel Sambuc 
13ebfedea0SLionel Sambuc # ifndef HEADER_SSL_H
14ebfedea0SLionel Sambuc typedef struct ssl_ctx_st SSL_CTX;
15ebfedea0SLionel Sambuc # endif
16ebfedea0SLionel Sambuc 
17ebfedea0SLionel Sambuc # define TLS_INFO_SIZE 512      /* max. # of bytes written to infofd */
18ebfedea0SLionel Sambuc 
19ebfedea0SLionel Sambuc void tls_set_dhe1024(int i, void *apparg);
20*0a6a1f1dSLionel Sambuc /*
21*0a6a1f1dSLionel Sambuc  * Generate DHE parameters: i >= 0 deterministic (i selects seed), i < 0
22*0a6a1f1dSLionel Sambuc  * random (may take a while). tls_create_ctx calls this with random
23*0a6a1f1dSLionel Sambuc  * non-negative i if the application has never called it.
24*0a6a1f1dSLionel Sambuc  */
25ebfedea0SLionel Sambuc 
26ebfedea0SLionel Sambuc void tls_rand_seed(void);
27ebfedea0SLionel Sambuc int tls_rand_seed_from_file(const char *filename, size_t n, void *apparg);
28ebfedea0SLionel Sambuc void tls_rand_seed_from_memory(const void *buf, size_t n);
29ebfedea0SLionel Sambuc 
30*0a6a1f1dSLionel Sambuc struct tls_create_ctx_args {
31ebfedea0SLionel Sambuc     int client_p;
32ebfedea0SLionel Sambuc     const char *certificate_file;
33ebfedea0SLionel Sambuc     const char *key_file;
34ebfedea0SLionel Sambuc     const char *ca_file;
35ebfedea0SLionel Sambuc     int verify_depth;
36ebfedea0SLionel Sambuc     int fail_unless_verified;
37ebfedea0SLionel Sambuc     int export_p;
38ebfedea0SLionel Sambuc };
39ebfedea0SLionel Sambuc struct tls_create_ctx_args tls_create_ctx_defaultargs(void);
40*0a6a1f1dSLionel Sambuc /*
41*0a6a1f1dSLionel Sambuc  * struct tls_create_ctx_args is similar to a conventional argument list, but
42*0a6a1f1dSLionel Sambuc  * it can provide default values and allows for future extension.
43*0a6a1f1dSLionel Sambuc  */
44ebfedea0SLionel Sambuc SSL_CTX *tls_create_ctx(struct tls_create_ctx_args, void *apparg);
45ebfedea0SLionel Sambuc 
46*0a6a1f1dSLionel Sambuc struct tls_start_proxy_args {
47ebfedea0SLionel Sambuc     int fd;
48ebfedea0SLionel Sambuc     int client_p;
49ebfedea0SLionel Sambuc     SSL_CTX *ctx;
50ebfedea0SLionel Sambuc     pid_t *pid;
51ebfedea0SLionel Sambuc     int *infofd;
52ebfedea0SLionel Sambuc };
53ebfedea0SLionel Sambuc struct tls_start_proxy_args tls_start_proxy_defaultargs(void);
54*0a6a1f1dSLionel Sambuc /*
55*0a6a1f1dSLionel Sambuc  * tls_start_proxy return value *MUST* be checked! 0 means ok, otherwise
56*0a6a1f1dSLionel Sambuc  * we've probably run out of some resources.
57*0a6a1f1dSLionel Sambuc  */
58ebfedea0SLionel Sambuc int tls_start_proxy(struct tls_start_proxy_args, void *apparg);
59ebfedea0SLionel Sambuc 
60ebfedea0SLionel Sambuc #endif
61