25 #ifndef yaSSL_openssl_h__
26 #define yaSSL_openssl_h__
29 #include "prefix_ssl.h"
37 #define YASSL_VERSION "2.2.2"
40 #if defined(__cplusplus)
49 #if defined(__cplusplus)
53 #if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE)
60 #if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE)
72 typedef struct SSL SSL;
73 typedef struct SSL_SESSION SSL_SESSION;
74 typedef struct SSL_METHOD SSL_METHOD;
75 typedef struct SSL_CTX SSL_CTX;
76 typedef struct SSL_CIPHER SSL_CIPHER;
78 typedef struct RSA RSA;
80 typedef struct X509 X509;
81 typedef struct X509_NAME X509_NAME;
86 typedef struct BIGNUM BIGNUM;
88 BIGNUM *BN_bin2bn(
const unsigned char*,
int, BIGNUM*);
104 RSA* RSA_generate_key(
int,
unsigned long,
void(*)(
int,
int,
void*),
void*);
118 typedef struct X509_STORE X509_STORE;
119 typedef struct X509_LOOKUP X509_LOOKUP;
121 typedef struct X509_CRL X509_CRL;
122 typedef struct X509_REVOKED X509_REVOKED;
123 typedef struct X509_LOOKUP_METHOD X509_LOOKUP_METHOD;
126 void X509_free(X509*);
130 typedef struct BIO BIO;
140 char* X509_NAME_oneline(X509_NAME*,
char*,
int);
141 X509_NAME* X509_get_issuer_name(X509*);
142 X509_NAME* X509_get_subject_name(X509*);
143 const char* X509_verify_cert_error_string(
long);
145 int X509_LOOKUP_add_dir(X509_LOOKUP*,
const char*,
long);
146 int X509_LOOKUP_load_file(X509_LOOKUP*,
const char*,
long);
147 X509_LOOKUP_METHOD* X509_LOOKUP_hash_dir(
void);
148 X509_LOOKUP_METHOD* X509_LOOKUP_file(
void);
150 X509_LOOKUP* X509_STORE_add_lookup(X509_STORE*, X509_LOOKUP_METHOD*);
151 X509_STORE* X509_STORE_new(
void);
160 X509_V_ERR_CERT_CHAIN_TOO_LONG = 1,
161 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = 2,
162 X509_V_ERR_CERT_NOT_YET_VALID = 3,
163 X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = 4,
164 X509_V_ERR_CERT_HAS_EXPIRED = 5,
165 X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = 6,
166 X509_FILETYPE_PEM = 7,
169 X509_V_ERR_CRL_SIGNATURE_FAILURE = 10,
170 X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = 11,
171 X509_V_ERR_CRL_HAS_EXPIRED = 12,
172 X509_V_ERR_CERT_REVOKED = 13,
173 X509_V_FLAG_CRL_CHECK = 14,
174 X509_V_FLAG_CRL_CHECK_ALL = 15
179 unsigned long ERR_get_error_line_data(
const char**,
int*,
const char**,
int *);
180 void ERR_print_errors_fp(FILE*);
181 char* ERR_error_string(
unsigned long,
char*);
182 void ERR_remove_state(
unsigned long);
183 unsigned long ERR_get_error(
void);
184 unsigned long ERR_peek_error(
void);
185 int ERR_GET_REASON(
int);
190 EVP_R_BAD_DECRYPT = 2
197 #ifndef YASSL_SOCKET_T_DEFINED
198 typedef int YASSL_SOCKET_T;
201 SSL_CTX* SSL_CTX_new(SSL_METHOD*);
202 SSL* SSL_new(SSL_CTX*);
203 int SSL_set_fd (SSL*, YASSL_SOCKET_T);
204 YASSL_SOCKET_T SSL_get_fd(
const SSL*);
205 int SSL_connect(SSL*);
207 int SSL_write(SSL*,
const void*,
int);
208 int SSL_read(SSL*,
void*,
int);
209 int SSL_accept(SSL*);
210 void SSL_CTX_free(SSL_CTX*);
213 int SSL_shutdown(SSL*);
215 void SSL_set_connect_state(SSL*);
216 void SSL_set_accept_state(SSL*);
217 int SSL_do_handshake(SSL*);
219 const char* SSL_get_cipher(SSL*);
220 const char* SSL_get_cipher_name(SSL*);
221 char* SSL_get_shared_ciphers(SSL*,
char*,
int);
222 const char* SSL_get_cipher_list(SSL*,
int);
223 const char* SSL_get_version(SSL*);
224 const char* SSLeay_version(
int);
226 int SSL_get_error(SSL*,
int);
227 void SSL_load_error_strings(
void);
229 int SSL_set_session(SSL *ssl, SSL_SESSION *session);
230 SSL_SESSION* SSL_get_session(SSL* ssl);
231 void SSL_flush_sessions(SSL_CTX *ctx,
long tm);
232 long SSL_SESSION_set_timeout(SSL_SESSION*,
long);
233 long SSL_CTX_set_session_cache_mode(SSL_CTX* ctx,
long mode);
234 X509* SSL_get_peer_certificate(SSL*);
235 long SSL_get_verify_result(SSL*);
239 typedef int (*pem_password_cb)(
char*, int, int,
void*);
241 void SSL_CTX_set_verify(SSL_CTX*,
int, VerifyCallback verify_callback);
242 int SSL_CTX_load_verify_locations(SSL_CTX*,
const char*,
const char*);
243 int SSL_CTX_set_default_verify_paths(SSL_CTX*);
244 int SSL_CTX_check_private_key(SSL_CTX*);
245 int SSL_CTX_set_session_id_context(SSL_CTX*,
const unsigned char*,
248 void SSL_CTX_set_tmp_rsa_callback(SSL_CTX*, RSA*(*)(SSL*,
int,
int));
249 long SSL_CTX_set_options(SSL_CTX*,
long);
250 long SSL_CTX_set_session_cache_mode(SSL_CTX*,
long);
251 long SSL_CTX_set_timeout(SSL_CTX*,
long);
252 int SSL_CTX_use_certificate_chain_file(SSL_CTX*,
const char*);
253 void SSL_CTX_set_default_passwd_cb(SSL_CTX*, pem_password_cb);
254 int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX*,
const char*,
int);
255 void SSL_CTX_set_info_callback(SSL_CTX*,
void (*)());
257 long SSL_CTX_sess_accept(SSL_CTX*);
258 long SSL_CTX_sess_connect(SSL_CTX*);
259 long SSL_CTX_sess_accept_good(SSL_CTX*);
260 long SSL_CTX_sess_connect_good(SSL_CTX*);
261 long SSL_CTX_sess_accept_renegotiate(SSL_CTX*);
262 long SSL_CTX_sess_connect_renegotiate(SSL_CTX*);
263 long SSL_CTX_sess_hits(SSL_CTX*);
264 long SSL_CTX_sess_cb_hits(SSL_CTX*);
265 long SSL_CTX_sess_cache_full(SSL_CTX*);
266 long SSL_CTX_sess_misses(SSL_CTX*);
267 long SSL_CTX_sess_timeouts(SSL_CTX*);
268 long SSL_CTX_sess_number(SSL_CTX*);
269 long SSL_CTX_sess_get_cache_size(SSL_CTX*);
271 int SSL_CTX_get_verify_mode(SSL_CTX*);
272 int SSL_get_verify_mode(SSL*);
273 int SSL_CTX_get_verify_depth(SSL_CTX*);
274 int SSL_get_verify_depth(SSL*);
276 long SSL_get_default_timeout(SSL*);
277 long SSL_CTX_get_session_cache_mode(SSL_CTX*);
278 int SSL_session_reused(SSL*);
280 int SSL_set_rfd(SSL*,
int);
281 int SSL_set_wfd(SSL*,
int);
282 void SSL_set_shutdown(SSL*,
int);
283 void SSL_set_quiet_shutdown(SSL *ssl,
int mode);
284 int SSL_get_quiet_shutdown(SSL *ssl);
286 int SSL_want_read(SSL*);
287 int SSL_want_write(SSL*);
289 int SSL_pending(SSL*);
293 SSL_WOULD_BLOCK = -8,
296 SSL_BAD_FILETYPE = -5,
298 SSL_NOT_IMPLEMENTED = -3,
300 SSL_FATAL_ERROR = -1,
301 SSL_NORMAL_SHUTDOWN = 0,
306 SSL_FILETYPE_ASN1 = 10,
307 SSL_FILETYPE_PEM = 11,
308 SSL_FILETYPE_DEFAULT = 10,
312 SSL_VERIFY_FAIL_IF_NO_PEER_CERT = 2,
313 SSL_VERIFY_CLIENT_ONCE = 4,
315 SSL_SESS_CACHE_OFF = 30,
316 SSL_SESS_CACHE_CLIENT = 31,
317 SSL_SESS_CACHE_SERVER = 32,
318 SSL_SESS_CACHE_BOTH = 33,
319 SSL_SESS_CACHE_NO_AUTO_CLEAR = 34,
320 SSL_SESS_CACHE_NO_INTERNAL_LOOKUP = 35,
322 SSL_OP_MICROSOFT_SESS_ID_BUG = 50,
323 SSL_OP_NETSCAPE_CHALLENGE_BUG = 51,
324 SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG = 52,
325 SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG = 53,
326 SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER = 54,
327 SSL_OP_MSIE_SSLV2_RSA_PADDING = 55,
328 SSL_OP_SSLEAY_080_CLIENT_DH_BUG = 56,
329 SSL_OP_TLS_D5_BUG = 57,
330 SSL_OP_TLS_BLOCK_PADDING_BUG = 58,
331 SSL_OP_TLS_ROLLBACK_BUG = 59,
332 SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS = 60,
334 SSL_OP_SINGLE_DH_USE = 62,
335 SSL_OP_EPHEMERAL_RSA = 63,
336 SSL_OP_NO_SSLv2 = 64,
337 SSL_OP_NO_SSLv3 = 65,
338 SSL_OP_NO_TLSv1 = 66,
339 SSL_OP_PKCS1_CHECK_1 = 67,
340 SSL_OP_PKCS1_CHECK_2 = 68,
341 SSL_OP_NETSCAPE_CA_DN_BUG = 69,
342 SSL_OP_NON_EXPORT_FIRST = 70,
343 SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG = 71,
345 SSL_ERROR_WANT_READ = 80,
346 SSL_ERROR_WANT_WRITE = 81,
347 SSL_ERROR_SYSCALL = 82,
348 SSL_ERROR_WANT_X509_LOOKUP = 83,
349 SSL_ERROR_ZERO_RETURN = 84,
355 SSL_SENT_SHUTDOWN = 93,
356 SSL_RECEIVED_SHUTDOWN = 94,
359 SSL_CB_HANDSHAKE_DONE = 97
364 SSL_METHOD *SSLv3_method(
void);
365 SSL_METHOD *SSLv3_server_method(
void);
366 SSL_METHOD *SSLv3_client_method(
void);
367 SSL_METHOD *TLSv1_server_method(
void);
368 SSL_METHOD *TLSv1_client_method(
void);
369 SSL_METHOD *TLSv1_1_server_method(
void);
370 SSL_METHOD *TLSv1_1_client_method(
void);
371 SSL_METHOD *SSLv23_server_method(
void);
373 int SSL_CTX_use_certificate_file(SSL_CTX*,
const char*,
int);
374 int SSL_CTX_use_PrivateKey_file(SSL_CTX*,
const char*,
int);
375 int SSL_CTX_set_cipher_list(SSL_CTX*,
const char*);
377 long SSL_CTX_sess_set_cache_size(SSL_CTX*,
long);
378 long SSL_CTX_set_tmp_dh(SSL_CTX*,
DH*);
380 void OpenSSL_add_all_algorithms(
void);
381 int SSL_library_init();
382 int SSLeay_add_ssl_algorithms(
void);
385 SSL_CIPHER* SSL_get_current_cipher(SSL*);
386 char* SSL_CIPHER_description(SSL_CIPHER*,
char*,
int);
389 char* SSL_alert_type_string_long(
int);
390 char* SSL_alert_desc_string_long(
int);
391 char* SSL_state_string_long(SSL*);
397 typedef char EVP_CIPHER;
399 typedef struct EVP_PKEY EVP_PKEY;
401 typedef unsigned char DES_cblock[8];
402 typedef const DES_cblock const_DES_cblock;
403 typedef DES_cblock DES_key_schedule;
410 const EVP_MD* EVP_md5(
void);
411 const EVP_CIPHER* EVP_des_ede3_cbc(
void);
413 typedef unsigned char opaque;
415 int EVP_BytesToKey(
const EVP_CIPHER*,
const EVP_MD*,
const opaque*,
416 const opaque*,
int,
int, opaque*, opaque*);
418 void DES_set_key_unchecked(const_DES_cblock*, DES_key_schedule*);
419 void DES_ede3_cbc_encrypt(
const opaque*, opaque*,
long, DES_key_schedule*,
420 DES_key_schedule*, DES_key_schedule*, DES_cblock*,
int);
424 void RAND_screen(
void);
425 const char* RAND_file_name(
char*,
size_t);
426 int RAND_write_file(
const char*);
427 int RAND_load_file(
const char*,
long);
431 int RAND_status(
void);
432 int RAND_bytes(
unsigned char*
buf,
int num);
434 int DES_set_key(const_DES_cblock*, DES_key_schedule*);
435 void DES_set_odd_parity(DES_cblock*);
436 void DES_ecb_encrypt(DES_cblock*, DES_cblock*, DES_key_schedule*,
int);
438 void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX*,
void* userdata);
439 void SSL_SESSION_free(SSL_SESSION* session);
440 int SSL_peek(SSL* ssl,
void*
buf,
int num);
442 X509* SSL_get_certificate(SSL* ssl);
443 EVP_PKEY* SSL_get_privatekey(SSL* ssl);
444 EVP_PKEY* X509_get_pubkey(X509* x);
446 int EVP_PKEY_copy_parameters(EVP_PKEY*
to,
const EVP_PKEY* from);
447 void EVP_PKEY_free(EVP_PKEY* pkey);
448 void ERR_error_string_n(
unsigned long e,
char *
buf,
size_t len);
449 void ERR_free_strings(
void);
450 void EVP_cleanup(
void);
452 void* X509_get_ext_d2i(X509* x,
int nid,
int* crit,
int* idx);
455 #define NID_subject_alt_name 85
456 #define STACK_OF(x) x
486 int X509_NAME_get_index_by_NID(X509_NAME*
name,
int nid,
int lastpos);
488 ASN1_STRING* X509_NAME_ENTRY_get_data(X509_NAME_ENTRY* ne);
489 X509_NAME_ENTRY* X509_NAME_get_entry(X509_NAME*
name,
int loc);
491 #define OPENSSL_malloc(x) malloc(x)
492 #define OPENSSL_free(x) free(x)
494 int ASN1_STRING_to_UTF8(
unsigned char** out,
ASN1_STRING* in);
496 SSL_METHOD* SSLv23_client_method(
void);
497 SSL_METHOD* SSLv2_client_method(
void);
500 SSL_SESSION* SSL_get1_session(SSL* ssl);
503 #define CRYPTO_free(x) free(x)
504 #define ASN1_TIME ASN1_STRING
506 ASN1_TIME* X509_get_notBefore(X509* x);
507 ASN1_TIME* X509_get_notAfter(X509* x);
510 #define ASN1_UTCTIME ASN1_STRING
511 #define NID_commonName 13
512 #define V_ASN1_UTF8STRING 12
515 #define CERTFICATE_ERROR 0x14090086
523 void MD4_Update(
MD4_CTX*,
const void*,
unsigned long);
524 void MD4_Final(
unsigned char*,
MD4_CTX*);
532 void MD5_Update(
MD5_CTX*,
const void*,
unsigned long);
533 void MD5_Final(
unsigned char*,
MD5_CTX*);
535 #define MD5_DIGEST_LENGTH 16
538 #define SSL_DEFAULT_CIPHER_LIST ""
542 int SSL_set_compression(SSL*);
543 char *yaSSL_ASN1_TIME_to_string(ASN1_TIME *time,
char *
buf,
size_t len);
545 #include "transport_types.h"
555 void yaSSL_transport_set_ptr(SSL *,
void *);
556 void yaSSL_transport_set_recv_function(SSL *, yaSSL_recv_func_t);
557 void yaSSL_transport_set_send_function(SSL *, yaSSL_send_func_t);
559 #if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE)