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
42 #define WITHOUT_OPENSSL 1
43 #define SSL_OP_NO_SSLv3 0x02000000L
44 #define SSL_OP_NO_SSLv2 0x01000000L
45 #define SSL_FILETYPE_PEM 1
46 #define SSL_VERIFY_NONE 0x00
47 #define SSL_VERIFY_PEER 0x01
48 #define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
49 #define SSL_VERIFY_CLIENT_ONCE 0x03
56 void *SSLv23_server_method(void);
57 void *SSLv3_server_method(void);
58 void *TLSv1_server_method(void);
59 void *SSLv23_client_method(void);
60 void *SSLv3_client_method(void);
61 void *TLSv1_client_method(void);
62 void *SSLv23_method(void);
63 void *TLSv1_method(void);
66 typedef void * (*ssl_func_type_t)(void);
67 typedef void * (*bio_func_type_t)(void);
69 SSL_CTX * SSL_CTX_new(void *meth);
70 void SSL_CTX_free(SSL_CTX * ssl_ctx);
71 SSL * SSL_new(SSL_CTX *ssl_ctx);
72 int SSL_set_fd(SSL *s, int fd);
73 int SSL_accept(SSL *ssl);
74 int SSL_connect(SSL *ssl);
75 void SSL_free(SSL *ssl);
76 int SSL_read(SSL *ssl, void *buf, int num);
77 int SSL_write(SSL *ssl, const void *buf, int num);
78 int SSL_CTX_use_certificate_file(SSL_CTX *ssl_ctx, const char *file, int type);
79 int SSL_CTX_use_PrivateKey_file(SSL_CTX *ssl_ctx, const char *file, int type);
80 int SSL_CTX_use_certificate_ASN1(SSL_CTX *ssl_ctx, int len, const uint8_t *d);
81 int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx,
82 unsigned int sid_ctx_len);
83 int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);
84 int SSL_CTX_use_certificate_chain_file(SSL_CTX *ssl_ctx, const char *file);
85 int SSL_shutdown(SSL *ssl);
87 /*** get/set session ***/
88 SSL_SESSION *SSL_get1_session(SSL *ssl);
89 int SSL_set_session(SSL *ssl, SSL_SESSION *session);
90 void SSL_SESSION_free(SSL_SESSION *session);
91 /*** end get/set session ***/
93 long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
94 void SSL_CTX_set_verify(SSL_CTX *ctx, int mode,
95 int (*verify_callback)(int, void *));
97 void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth);
99 int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
102 void *SSL_load_client_CA_file(const char *file);
104 void SSL_CTX_set_client_CA_list(SSL_CTX *ssl_ctx, void *file);
106 void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, void *cb);
108 void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u);
110 int SSL_peek(SSL *ssl, void *buf, int num);
112 void SSL_set_bio(SSL *ssl, void *rbio, void *wbio);
114 long SSL_get_verify_result(const SSL *ssl);
116 int SSL_state(SSL *ssl);
118 /** end of could do better list */
120 void *SSL_get_peer_certificate(const SSL *ssl);
122 int SSL_clear(SSL *ssl);
125 int SSL_CTX_check_private_key(const SSL_CTX *ctx);
127 int SSL_CTX_set_cipher_list(SSL_CTX *s, const char *str);
129 int SSL_get_error(const SSL *ssl, int ret);
131 void SSL_CTX_set_options(SSL_CTX *ssl_ctx, int option);
132 int SSL_library_init(void );
133 void SSL_load_error_strings(void );
134 void ERR_print_errors_fp(FILE *fp);
136 long SSL_CTX_get_timeout(const SSL_CTX *ssl_ctx);
137 long SSL_CTX_set_timeout(SSL_CTX *ssl_ctx, long t);
138 void BIO_printf(FILE *f, const char *format, ...);
140 void* BIO_s_null(void);
141 FILE *BIO_new(bio_func_type_t func);
143 FILE *BIO_new_fp(FILE *stream, int close_flag);
144 int BIO_free(FILE *a);