2 * Copyright (c) 2007, Cameron Rich
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of the axTLS project nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * Enable a subset of openssl compatible functions. We don't aim to be 100%
33 * compatible - just to be able to do basic ports etc.
35 * Only really tested on mini_httpd, so I'm not too sure how extensive this
43 #define WITHOUT_OPENSSL 1
44 #define SSL_OP_NO_SSLv3 0x02000000L
45 #define SSL_OP_NO_SSLv2 0x01000000L
46 #define SSL_FILETYPE_PEM 1
47 #define SSL_VERIFY_NONE 0x00
48 #define SSL_VERIFY_PEER 0x01
49 #define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
50 #define SSL_VERIFY_CLIENT_ONCE 0x03
57 void *SSLv23_server_method(void);
58 void *SSLv3_server_method(void);
59 void *TLSv1_server_method(void);
60 void *SSLv23_client_method(void);
61 void *SSLv3_client_method(void);
62 void *TLSv1_client_method(void);
63 void *SSLv23_method(void);
64 void *TLSv1_method(void);
67 typedef void * (*ssl_func_type_t)(void);
68 typedef void * (*bio_func_type_t)(void);
70 SSL_CTX * SSL_CTX_new(void *meth);
71 void SSL_CTX_free(SSL_CTX * ssl_ctx);
72 SSL * SSL_new(SSL_CTX *ssl_ctx);
73 int SSL_set_fd(SSL *s, int fd);
74 int SSL_accept(SSL *ssl);
75 int SSL_connect(SSL *ssl);
76 void SSL_free(SSL *ssl);
77 int SSL_read(SSL *ssl, void *buf, int num);
78 int SSL_write(SSL *ssl, const void *buf, int num);
79 int SSL_CTX_use_certificate_file(SSL_CTX *ssl_ctx, const char *file, int type);
80 int SSL_CTX_use_PrivateKey_file(SSL_CTX *ssl_ctx, const char *file, int type);
81 int SSL_CTX_use_certificate_ASN1(SSL_CTX *ssl_ctx, int len, const uint8_t *d);
82 int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx,
83 unsigned int sid_ctx_len);
84 int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);
85 int SSL_CTX_use_certificate_chain_file(SSL_CTX *ssl_ctx, const char *file);
86 int SSL_shutdown(SSL *ssl);
88 /*** get/set session ***/
89 SSL_SESSION *SSL_get1_session(SSL *ssl);
90 int SSL_set_session(SSL *ssl, SSL_SESSION *session);
91 void SSL_SESSION_free(SSL_SESSION *session);
92 /*** end get/set session ***/
94 long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
95 void SSL_CTX_set_verify(SSL_CTX *ctx, int mode,
96 int (*verify_callback)(int, void *));
98 void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth);
100 int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
103 void *SSL_load_client_CA_file(const char *file);
105 void SSL_CTX_set_client_CA_list(SSL_CTX *ssl_ctx, void *file);
107 void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, void *cb);
109 void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u);
111 int SSL_peek(SSL *ssl, void *buf, int num);
113 void SSL_set_bio(SSL *ssl, void *rbio, void *wbio);
115 long SSL_get_verify_result(const SSL *ssl);
117 int SSL_state(SSL *ssl);
119 /** end of could do better list */
121 void *SSL_get_peer_certificate(const SSL *ssl);
123 int SSL_clear(SSL *ssl);
126 int SSL_CTX_check_private_key(const SSL_CTX *ctx);
128 int SSL_CTX_set_cipher_list(SSL_CTX *s, const char *str);
130 int SSL_get_error(const SSL *ssl, int ret);
132 void SSL_CTX_set_options(SSL_CTX *ssl_ctx, int option);
133 int SSL_library_init(void );
134 void SSL_load_error_strings(void );
135 void ERR_print_errors_fp(FILE *fp);
137 long SSL_CTX_get_timeout(const SSL_CTX *ssl_ctx);
138 long SSL_CTX_set_timeout(SSL_CTX *ssl_ctx, long t);
139 void BIO_printf(FILE *f, const char *format, ...);
141 void* BIO_s_null(void);
142 FILE *BIO_new(bio_func_type_t func);
144 FILE *BIO_new_fp(FILE *stream, int close_flag);
145 int BIO_free(FILE *a);