From f1a453af44c914a1215024fce1df2c6addec1dd7 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 26 Jan 2009 10:34:42 +0000 Subject: [PATCH] 2009-01-26 11:34 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * contrib/hbssl/sslctx.c * contrib/hbssl/ssl.c + Added more SSL API. * TODO * Updated. --- harbour/ChangeLog | 8 + harbour/TODO | 36 +-- harbour/contrib/hbssl/ssl.c | 576 ++++++++++++++++++++++++++++++--- harbour/contrib/hbssl/sslctx.c | 341 +++++++++++++++++-- 4 files changed, 865 insertions(+), 96 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8d0ccb7843..aa0ffec344 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,14 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-01-26 11:34 UTC+0100 Viktor Szakats (harbour.01 syenar hu) + * contrib/hbssl/sslctx.c + * contrib/hbssl/ssl.c + + Added more SSL API. + + * TODO + * Updated. + 2009-01-26 10:35 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * contrib/hbssl/tests/test.prg * contrib/hbssl/ssl.c diff --git a/harbour/TODO b/harbour/TODO index 1af5037088..b2dae0185f 100644 --- a/harbour/TODO +++ b/harbour/TODO @@ -10,28 +10,23 @@ Tasks for after v.1 release: ---------------------------- -Assign to: Jean-Francois Lefebvre (JFL) -Detail...: The following need to be added to the OO system: - Class Method, Multiple Constructor, Class init Support. +Assign to: +Detail...: Add GTNET driver which will allow to run Harbour application + remotely. GTNET will be used on server side and on client + side any native GT driver. Status...: Open. *** Assign to: -Detail...: Add missing Clipper virtual memory functions. +Detail...: UNICODE (UTF-8) support. Status...: Open. *** -Assign to: -Detail...: Dynamic multi-language compiler/runtime support. -Status...: Open. - -*** - -Assign to: -Detail...: UNICODE support. -Status...: Open. +Assign to: Ryszard +Detail...: SQLRDD. +Status...: Working on it. *** @@ -64,14 +59,6 @@ Status...: Open. *** -Assign to: -Detail...: Add GTNET driver which will allow to run Harbour application - remotely. GTNET will be used on server side and on client - side any native GT driver. -Status...: Open. - -*** - Assign to: Detail...: Add support for remotely controlled GUI objects so we will be able to create GUI programs with GTNET. @@ -100,9 +87,10 @@ Status...: Open. *** -Assign to: Ryszard -Detail...: SQLRDD. -Status...: Working on it. +Assign to: Jean-Francois Lefebvre (JFL) +Detail...: The following need to be added to the OO system: + Class Method, Multiple Constructor, Class init Support. +Status...: Open. *** diff --git a/harbour/contrib/hbssl/ssl.c b/harbour/contrib/hbssl/ssl.c index 043da1aa5e..a5efaf3237 100644 --- a/harbour/contrib/hbssl/ssl.c +++ b/harbour/contrib/hbssl/ssl.c @@ -236,7 +236,7 @@ HB_FUNC( SSL_GET_CIPHER ) SSL * ssl = hb_SSL_par( 1 ); if( ssl ) - hb_retc_const( SSL_get_cipher( ssl ) ); + hb_retc( SSL_get_cipher( ssl ) ); } else hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); @@ -465,6 +465,38 @@ HB_FUNC( SSL_SET_SSL_METHOD ) hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } +HB_FUNC( SSL_GET_SSL_METHOD ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + { + SSL_METHOD * method = SSL_get_ssl_method( ssl ); + int nMethod; + + if( method == SSLv2_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV2; + else if( method == SSLv2_server_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV2_SERVER; + else if( method == SSLv2_client_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV2_CLIENT; + else if( method == SSLv3_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV3; + else if( method == SSLv3_server_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV3_SERVER; + else if( method == SSLv3_client_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV3_CLIENT; + else if( method == TLSv1_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_TLSV1; + else if( method == TLSv1_server_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_TLSV1_SERVER; + else if( method == TLSv1_client_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_TLSV1_CLIENT; + else if( method == SSLv23_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV23; + else if( method == SSLv23_server_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV23_SERVER; + else if( method == SSLv23_client_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV23_CLIENT; + else nMethod = 0; + + hb_retni( nMethod ); + } + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + HB_FUNC( SSL_GET_CURRENT_CIPHER ) { if( hb_SSL_is( 1 ) ) @@ -536,17 +568,509 @@ HB_FUNC( SSL_GET_CIPHER_VERSION ) hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } +HB_FUNC( SSL_COPY_SESSION_ID ) +{ + if( hb_SSL_is( 1 ) && hb_SSL_is( 2 ) ) + { + SSL * ssl1 = hb_SSL_par( 1 ); + SSL * ssl2 = hb_SSL_par( 2 ); + + if( ssl1 && ssl2 ) + SSL_copy_session_id( ssl1, ssl2 ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_GET_SHARED_CIPHERS ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + { + char buffer[ 128 + 1 ]; /* See: CVE-2006-3738 */ + + buffer[ 0 ] = '\0'; + + hb_retc( SSL_get_shared_ciphers( ssl, buffer, sizeof( buffer ) - 1 ) ); + } + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_ALERT_DESC_STRING ) +{ + hb_retc( SSL_alert_desc_string( hb_parni( 1 ) ) ); +} + +HB_FUNC( SSL_ALERT_DESC_STRING_LONG ) +{ + hb_retc( SSL_alert_desc_string_long( hb_parni( 1 ) ) ); +} + +HB_FUNC( SSL_ALERT_TYPE_STRING ) +{ + hb_retc( SSL_alert_type_string( hb_parni( 1 ) ) ); +} + +HB_FUNC( SSL_ALERT_TYPE_STRING_LONG ) +{ + hb_retc( SSL_alert_type_string_long( hb_parni( 1 ) ) ); +} + +HB_FUNC( SSL_GET_EX_DATA ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retc( SSL_get_ex_data( ssl, hb_parni( 1 ) ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_RSTATE_STRING ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retc( SSL_rstate_string( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_RSTATE_STRING_LONG ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retc( SSL_rstate_string( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_STATE_STRING ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retc( SSL_rstate_string( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_STATE_STRING_LONG ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retc( SSL_rstate_string( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +/* + +HB_FUNC( SSL_GET_PSK_IDENTITY_HINT ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retc( SSL_get_psk_identity_hint( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_GET_PSK_IDENTITY ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retc( SSL_get_psk_identity( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +*/ + +HB_FUNC( SSL_CHECK_PRIVATE_KEY ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_check_private_key( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_GET_ERROR ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_get_error( ssl, hb_parni( 2 ) ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_GET_FD ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_get_fd( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_GET_QUIET_SHUTDOWN ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_get_quiet_shutdown( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_GET_SHUTDOWN ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_get_shutdown( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_GET_READ_AHEAD ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_get_read_ahead( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_GET_STATE ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_get_state( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_GET_VERIFY_MODE ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_get_verify_mode( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_IN_ACCEPT_INIT ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_in_accept_init( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_IN_BEFORE ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_in_before( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_IN_CONNECT_INIT ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_in_connect_init( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_IN_INIT ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_in_init( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_IS_INIT_FINISHED ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_is_init_finished( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_SET_RFD ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_set_rfd( ssl, hb_parni( 2 ) ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_SET_WFD ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retni( SSL_set_wfd( ssl, hb_parni( 2 ) ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_NUM_RENEGOTIATIONS ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retnl( SSL_num_renegotiations( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CLEAR_NUM_RENEGOTIATIONS ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retnl( SSL_clear_num_renegotiations( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_GET_DEFAULT_TIMEOUT ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retnl( SSL_get_default_timeout( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_GET_VERIFY_RESULT ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retnl( SSL_get_verify_result( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_SESSION_REUSED ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + hb_retnl( SSL_session_reused( ssl ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_SET_ACCEPT_STATE ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + SSL_set_accept_state( ssl ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_SET_CONNECT_STATE ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + SSL_set_connect_state( ssl ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_SET_OPTIONS ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + SSL_set_options( ssl, ( unsigned long ) hb_parnl( 2 ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_SET_QUIET_SHUTDOWN ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + SSL_set_quiet_shutdown( ssl, hb_parni( 2 ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_SET_READ_AHEAD ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + SSL_set_read_ahead( ssl, hb_parni( 2 ) /* yes */ ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_SET_SHUTDOWN ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + SSL_set_shutdown( ssl, hb_parni( 2 ) /* mode */ ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_SET_VERIFY_RESULT ) +{ + if( hb_SSL_is( 1 ) ) + { + SSL * ssl = hb_SSL_par( 1 ); + + if( ssl ) + SSL_set_verify_result( ssl, hb_parnl( 2 ) /* arg */ ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + /* int SSL_add_dir_cert_subjects_to_stack(STACK *stack, const char *dir); int SSL_add_file_cert_subjects_to_stack(STACK *stack, const char *file); int SSL_add_client_CA(SSL *ssl, X509 *x); -char *SSL_alert_desc_string(int value); -char *SSL_alert_desc_string_long(int value); -char *SSL_alert_type_string(int value); -char *SSL_alert_type_string_long(int value); -int SSL_check_private_key(const SSL *ssl); -long SSL_clear_num_renegotiations(SSL *ssl); -void SSL_copy_session_id(SSL *t, const SSL *f); long SSL_ctrl(SSL *ssl, int cmd, long larg, char *parg); STACK *SSL_dup_CA_list(STACK *sk); SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl); @@ -554,61 +1078,27 @@ char *SSL_get_app_data(SSL *ssl); X509 *SSL_get_certificate(const SSL *ssl); STACK *SSL_get_ciphers(const SSL *ssl); STACK *SSL_get_client_CA_list(const SSL *ssl); -long SSL_get_default_timeout(const SSL *ssl); -int SSL_get_error(const SSL *ssl, int i); -char *SSL_get_ex_data(const SSL *ssl, int idx); int SSL_get_ex_data_X509_STORE_CTX_idx(void); int SSL_get_ex_new_index(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void)) -int SSL_get_fd(const SSL *ssl); void (*SSL_get_info_callback(const SSL *ssl);)() STACK * SSL_get_peer_cert_chain(const SSL *ssl); X509 * SSL_get_peer_certificate(const SSL *ssl); EVP_PKEY * SSL_get_privatekey(SSL *ssl); -int SSL_get_quiet_shutdown(const SSL *ssl); BIO * SSL_get_rbio(const SSL *ssl); -int SSL_get_read_ahead(const SSL *ssl); SSL_SESSION *SSL_get_session(const SSL *ssl); -char * SSL_get_shared_ciphers(const SSL *ssl, char *buf, int len); -int SSL_get_shutdown(const SSL *ssl); -const SSL_METHOD *SSL_get_ssl_method(SSL *ssl); -int SSL_get_state(const SSL *ssl); int (*SSL_get_verify_callback(const SSL *ssl))(int,X509_STORE_CTX *) -int SSL_get_verify_mode(const SSL *ssl); -long SSL_get_verify_result(const SSL *ssl); BIO * SSL_get_wbio(const SSL *ssl); -int SSL_in_accept_init(SSL *ssl); -int SSL_in_before(SSL *ssl); -int SSL_in_connect_init(SSL *ssl); -int SSL_in_init(SSL *ssl); -int SSL_is_init_finished(SSL *ssl); STACK * SSL_load_client_CA_file(char *file); -void SSL_load_error_strings(void); -long SSL_num_renegotiations(SSL *ssl); -char * SSL_rstate_string(SSL *ssl); -char * SSL_rstate_string_long(SSL *ssl); -long SSL_session_reused(SSL *ssl); -void SSL_set_accept_state(SSL *ssl); void SSL_set_app_data(SSL *ssl, char *arg); void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio); int SSL_set_cipher_list(SSL *ssl, char *str); void SSL_set_client_CA_list(SSL *ssl, STACK *list); -void SSL_set_connect_state(SSL *ssl); int SSL_set_ex_data(SSL *ssl, int idx, char *arg); -int SSL_set_fd(SSL *ssl, int fd); void SSL_set_info_callback(SSL *ssl, void (*cb);(void)) void SSL_set_msg_callback(SSL *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); void SSL_set_msg_callback_arg(SSL *ctx, void *arg); -void SSL_set_options(SSL *ssl, unsigned long op); -void SSL_set_quiet_shutdown(SSL *ssl, int mode); -void SSL_set_read_ahead(SSL *ssl, int yes); -int SSL_set_rfd(SSL *ssl, int fd); int SSL_set_session(SSL *ssl, SSL_SESSION *session); -void SSL_set_shutdown(SSL *ssl, int mode); void SSL_set_verify(SSL *ssl, int mode, int (*callback);(void)) -void SSL_set_verify_result(SSL *ssl, long arg); -int SSL_set_wfd(SSL *ssl, int fd); -char * SSL_state_string(const SSL *ssl); -char * SSL_state_string_long(const SSL *ssl); int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); int SSL_use_PrivateKey_ASN1(int type, SSL *ssl, unsigned char *d, long len); int SSL_use_PrivateKey_file(SSL *ssl, char *file, int type); @@ -621,6 +1111,4 @@ int SSL_use_certificate_file(SSL *ssl, char *file, int type); void SSL_set_psk_client_callback(SSL *ssl, unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len)); int SSL_use_psk_identity_hint(SSL *ssl, const char *hint); void SSL_set_psk_server_callback(SSL *ssl, unsigned int (*callback)(SSL *ssl, const char *identity, unsigned char *psk, int max_psk_len)); -const char *SSL_get_psk_identity_hint(SSL *ssl); -const char *SSL_get_psk_identity(SSL *ssl); */ diff --git a/harbour/contrib/hbssl/sslctx.c b/harbour/contrib/hbssl/sslctx.c index 420a343e10..16058d2765 100644 --- a/harbour/contrib/hbssl/sslctx.c +++ b/harbour/contrib/hbssl/sslctx.c @@ -74,7 +74,7 @@ HB_FUNC( SSLEAY_VERSION ) case HB_SSLEAY_DIR : value = SSLEAY_DIR; break; } - hb_retc_const( SSLeay_version( value ) ); + hb_retc( SSLeay_version( value ) ); } static HB_GARBAGE_FUNC( SSL_CTX_release ) @@ -258,47 +258,337 @@ HB_FUNC( SSL_CTX_SET_SESSION_CACHE_MODE ) hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } +HB_FUNC( SSL_CTX_GET_APP_DATA ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retc( SSL_CTX_get_app_data( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_GET_EX_DATA ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retc( SSL_CTX_get_ex_data( ctx, hb_parni( 2 ) ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_CHECK_PRIVATE_KEY ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_check_private_key( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_GET_QUIET_SHUTDOWN ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_get_quiet_shutdown( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_GET_VERIFY_MODE ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_get_verify_mode( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SESS_ACCEPT ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_sess_accept( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SESS_ACCEPT_GOOD ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_sess_accept_good( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SESS_ACCEPT_RENEGOTIATE ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_sess_accept_renegotiate( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SESS_CACHE_FULL ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_sess_cache_full( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SESS_CB_HITS ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_sess_cb_hits( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SESS_CONNECT ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_sess_connect( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SESS_CONNECT_GOOD ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_sess_connect_good( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SESS_CONNECT_RENEGOTIATE ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_sess_connect_renegotiate( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SESS_GET_CACHE_SIZE ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_sess_get_cache_size( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SESS_HITS ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_sess_hits( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SESS_MISSES ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_sess_misses( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SESS_NUMBER ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_sess_number( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SESS_TIMEOUTS ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_sess_timeouts( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SET_DEFAULT_VERIFY_PATHS ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retni( SSL_CTX_set_default_verify_paths( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_NEED_TMP_RSA ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + hb_retnl( SSL_CTX_need_tmp_RSA( ctx ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SESS_SET_CACHE_SIZE ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + SSL_CTX_sess_set_cache_size( ctx, hb_parni( 2 ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SET_DEFAULT_READ_AHEAD ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + SSL_CTX_set_default_read_ahead( ctx, hb_parni( 2 ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SET_OPTIONS ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + SSL_CTX_set_options( ctx, ( unsigned long ) hb_parnl( 2 ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( SSL_CTX_SET_QUIET_SHUTDOWN ) +{ + if( hb_SSL_CTX_is( 1 ) ) + { + SSL_CTX * ctx = hb_SSL_CTX_par( 1 ); + + if( ctx ) + SSL_CTX_set_quiet_shutdown( ctx, hb_parni( 2 ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + /* X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *); void SSL_CTX_set_cert_store(SSL_CTX *,X509_STORE *); - int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x); long SSL_CTX_add_extra_chain_cert(SSL_CTX *ctx, X509 *x509); -int SSL_CTX_check_private_key(const SSL_CTX *ctx); long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg); -char *SSL_CTX_get_app_data(SSL_CTX *ctx); X509_STORE *SSL_CTX_get_cert_store(SSL_CTX *ctx); STACK *SSL_CTX_get_client_CA_list(const SSL_CTX *ctx); int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey); -char *SSL_CTX_get_ex_data(const SSL_CTX *s, int idx); int SSL_CTX_get_ex_new_index(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void)) void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(SSL *ssl, int cb, int ret); -int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx); -long SSL_CTX_get_timeout(const SSL_CTX *ctx); int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int ok, X509_STORE_CTX *ctx); -int SSL_CTX_get_verify_mode(SSL_CTX *ctx); int SSL_CTX_load_verify_locations(SSL_CTX *ctx, char *CAfile, char *CApath); -long SSL_CTX_need_tmp_RSA(SSL_CTX *ctx); -int SSL_CTX_sess_accept(SSL_CTX *ctx); -int SSL_CTX_sess_accept_good(SSL_CTX *ctx); -int SSL_CTX_sess_accept_renegotiate(SSL_CTX *ctx); -int SSL_CTX_sess_cache_full(SSL_CTX *ctx); -int SSL_CTX_sess_cb_hits(SSL_CTX *ctx); -int SSL_CTX_sess_connect(SSL_CTX *ctx); -int SSL_CTX_sess_connect_good(SSL_CTX *ctx); -int SSL_CTX_sess_connect_renegotiate(SSL_CTX *ctx); -int SSL_CTX_sess_get_cache_size(SSL_CTX *ctx); SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(SSL *ssl, unsigned char *data, int len, int *copy); int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx)(SSL *ssl, SSL_SESSION *sess); void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx)(SSL_CTX *ctx, SSL_SESSION *sess); -int SSL_CTX_sess_hits(SSL_CTX *ctx); -int SSL_CTX_sess_misses(SSL_CTX *ctx); -int SSL_CTX_sess_number(SSL_CTX *ctx); -void SSL_CTX_sess_set_cache_size(SSL_CTX *ctx,t); void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, SSL_SESSION *(*cb)(SSL *ssl, unsigned char *data, int len, int *copy)); void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx, int (*cb)(SSL *ssl, SSL_SESSION *sess)); void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, void (*cb)(SSL_CTX *ctx, SSL_SESSION *sess)); -int SSL_CTX_sess_timeouts(SSL_CTX *ctx); LHASH *SSL_CTX_sessions(SSL_CTX *ctx); void SSL_CTX_set_app_data(SSL_CTX *ctx, void *arg); void SSL_CTX_set_cert_store(SSL_CTX *ctx, X509_STORE *cs); @@ -307,15 +597,10 @@ int SSL_CTX_set_cipher_list(SSL_CTX *ctx, char *str); void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK *list); void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, int (*cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey)); void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, int (*cb);(void)) -void SSL_CTX_set_default_read_ahead(SSL_CTX *ctx, int m); -int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, char *arg); void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*cb)(SSL *ssl, int cb, int ret)); void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); void SSL_CTX_set_msg_callback_arg(SSL_CTX *ctx, void *arg); -void SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op); -void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode); -void SSL_CTX_set_timeout(SSL_CTX *ctx, long t); long SSL_CTX_set_tmp_dh(SSL_CTX* ctx, DH *dh); long SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, DH *(*cb)(void)); long SSL_CTX_set_tmp_rsa(SSL_CTX *ctx, RSA *rsa);