From 6f7b5ffe6f5f33d841e4f8d58214b685023118fa Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 23 Apr 2010 08:37:55 +0000 Subject: * ext/openssl/ossl_config.c: OpenSSL 1.0.0 support. * ext/openssl/extconf.rb: check some functions added/removed at OpenSSL 1.0.0. * ext/openssl/ossl_engine.c (ossl_engine_s_load): use engines which exists. * ext/openssl/ossl_ssl_session (SSL_SESSION_cmp): removed at 1.0.0, so implement compatible fuction here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/openssl/extconf.rb | 9 +++++++++ ext/openssl/ossl_config.c | 23 ++++++++++++++--------- ext/openssl/ossl_engine.c | 18 ++++++++++++++++++ ext/openssl/ossl_ssl_session.c | 10 ++++++++++ 4 files changed, 51 insertions(+), 9 deletions(-) (limited to 'ext') diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb index 993d9e9f18..bab92521a7 100644 --- a/ext/openssl/extconf.rb +++ b/ext/openssl/extconf.rb @@ -95,6 +95,7 @@ have_func("X509_STORE_get_ex_data") have_func("X509_STORE_set_ex_data") have_func("OBJ_NAME_do_all_sorted") have_func("SSL_SESSION_get_id") +have_func("SSL_SESSION_cmp") have_func("OPENSSL_cleanse") unless have_func("SSL_set_tlsext_host_name", ['openssl/ssl.h']) have_macro("SSL_set_tlsext_host_name", ['openssl/ssl.h']) && $defs.push("-DHAVE_SSL_SET_TLSEXT_HOST_NAME") @@ -109,6 +110,14 @@ if have_header("openssl/engine.h") have_func("ENGINE_get_digest") have_func("ENGINE_get_cipher") have_func("ENGINE_cleanup") + have_func("ENGINE_load_4758cca") + have_func("ENGINE_load_aep") + have_func("ENGINE_load_atalla") + have_func("ENGINE_load_chil") + have_func("ENGINE_load_cswift") + have_func("ENGINE_load_nuron") + have_func("ENGINE_load_sureware") + have_func("ENGINE_load_ubsec") end if try_compile(< diff --git a/ext/openssl/ossl_config.c b/ext/openssl/ossl_config.c index aae3b94a7e..91faacf94b 100644 --- a/ext/openssl/ossl_config.c +++ b/ext/openssl/ossl_config.c @@ -314,13 +314,14 @@ ossl_config_get_section_old(VALUE self, VALUE section) #ifdef IMPLEMENT_LHASH_DOALL_ARG_FN static void -get_conf_section(CONF_VALUE *cv, VALUE ary) +get_conf_section_doall_arg(CONF_VALUE *cv, void *tmp) { + VALUE ary = (VALUE)tmp; if(cv->name) return; rb_ary_push(ary, rb_str_new2(cv->section)); } -static IMPLEMENT_LHASH_DOALL_ARG_FN(get_conf_section, CONF_VALUE*, VALUE) +static IMPLEMENT_LHASH_DOALL_ARG_FN(get_conf_section, CONF_VALUE, void) static VALUE ossl_config_get_sections(VALUE self) @@ -330,14 +331,16 @@ ossl_config_get_sections(VALUE self) GetConfig(self, conf); ary = rb_ary_new(); - lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(get_conf_section), (void*)ary); + lh_doall_arg((_LHASH *)conf->data, LHASH_DOALL_ARG_FN(get_conf_section), + (void*)ary); return ary; } static void -dump_conf_value(CONF_VALUE *cv, VALUE str) +dump_conf_value_doall_arg(CONF_VALUE *cv, void *tmp) { + VALUE str = (VALUE)tmp; STACK_OF(CONF_VALUE) *sk; CONF_VALUE *v; int i, num; @@ -358,7 +361,7 @@ dump_conf_value(CONF_VALUE *cv, VALUE str) rb_str_cat2(str, "\n"); } -static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_conf_value, CONF_VALUE*, VALUE) +static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_conf_value, CONF_VALUE, void) static VALUE dump_conf(CONF *conf) @@ -366,7 +369,8 @@ dump_conf(CONF *conf) VALUE str; str = rb_str_new(0, 0); - lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_conf_value), (void*)str); + lh_doall_arg((_LHASH *)conf->data, LHASH_DOALL_ARG_FN(dump_conf_value), + (void*)str); return str; } @@ -382,7 +386,7 @@ ossl_config_to_s(VALUE self) } static void -each_conf_value(CONF_VALUE *cv, void* dummy) +each_conf_value_doall_arg(CONF_VALUE *cv, void *dummy) { STACK_OF(CONF_VALUE) *sk; CONF_VALUE *v; @@ -402,7 +406,7 @@ each_conf_value(CONF_VALUE *cv, void* dummy) } } -static IMPLEMENT_LHASH_DOALL_ARG_FN(each_conf_value, CONF_VALUE*, void*) +static IMPLEMENT_LHASH_DOALL_ARG_FN(each_conf_value, CONF_VALUE, void *) static VALUE ossl_config_each(VALUE self) @@ -412,7 +416,8 @@ ossl_config_each(VALUE self) RETURN_ENUMERATOR(self, 0, 0); GetConfig(self, conf); - lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(each_conf_value), (void*)NULL); + lh_doall_arg((_LHASH *)conf->data, LHASH_DOALL_ARG_FN(each_conf_value), + (void*)NULL); return self; } diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c index 57e7971b98..3b48119b7f 100644 --- a/ext/openssl/ossl_engine.c +++ b/ext/openssl/ossl_engine.c @@ -61,16 +61,34 @@ ossl_engine_s_load(int argc, VALUE *argv, VALUE klass) } StringValue(name); #ifndef OPENSSL_NO_STATIC_ENGINE +#if HAVE_ENGINE_LOAD_DYNAMIC OSSL_ENGINE_LOAD_IF_MATCH(dynamic); +#endif +#if HAVE_ENGINE_LOAD_CSWIFT OSSL_ENGINE_LOAD_IF_MATCH(cswift); +#endif +#if HAVE_ENGINE_LOAD_CHIL OSSL_ENGINE_LOAD_IF_MATCH(chil); +#endif +#if HAVE_ENGINE_LOAD_ATALLA OSSL_ENGINE_LOAD_IF_MATCH(atalla); +#endif +#if HAVE_ENGINE_LOAD_NURON OSSL_ENGINE_LOAD_IF_MATCH(nuron); +#endif +#if HAVE_ENGINE_LOAD_UBSEC OSSL_ENGINE_LOAD_IF_MATCH(ubsec); +#endif +#if HAVE_ENGINE_LOAD_AEP OSSL_ENGINE_LOAD_IF_MATCH(aep); +#endif +#if HAVE_ENGINE_LOAD_SUREWARE OSSL_ENGINE_LOAD_IF_MATCH(sureware); +#endif +#if HAVE_ENGINE_LOAD_4758CCA OSSL_ENGINE_LOAD_IF_MATCH(4758cca); #endif +#endif #ifdef HAVE_ENGINE_LOAD_OPENBSD_DEV_CRYPTO OSSL_ENGINE_LOAD_IF_MATCH(openbsd_dev_crypto); #endif diff --git a/ext/openssl/ossl_ssl_session.c b/ext/openssl/ossl_ssl_session.c index 21aafede9c..26a1f67f55 100644 --- a/ext/openssl/ossl_ssl_session.c +++ b/ext/openssl/ossl_ssl_session.c @@ -72,6 +72,16 @@ static VALUE ossl_ssl_session_initialize(VALUE self, VALUE arg1) return self; } +#if HAVE_SSL_SESSION_CMP == 0 +static int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b) +{ + if (a->ssl_version != b->ssl_version || + a->session_id_length != b->session_id_length) + return 1; + return memcmp(a->session_id,b-> session_id, a->session_id_length); +} +#endif + /* * call-seq: * session1 == session2 -> boolean -- cgit v1.2.3