From f58812a7e22c0ffe04758e660c8f5b60bc65f58c Mon Sep 17 00:00:00 2001 From: gotoyuzo Date: Sun, 5 Oct 2003 13:58:02 +0000 Subject: * lib/ext/openssl/extconf.rb: add check for some engine functions unavailable in OpenSSL-0.9.6. * lib/ext/openssl/ossl_engine.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/openssl/extconf.rb | 4 ++++ ext/openssl/ossl_engine.c | 24 ++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/ChangeLog b/ChangeLog index d15b3ab364..4ac231a5a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sun Oct 5 22:51:23 2003 GOTOU Yuuzou + + * lib/ext/openssl/extconf.rb: add check for some engine functions + unavailable in OpenSSL-0.9.6. + + * lib/ext/openssl/ossl_engine.c: ditto. + Sun Oct 5 17:56:30 2003 Nobuyoshi Nakada * eval.c (rb_eval): fix evaluation order. [ruby-list:38431] diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb index 5ef85beae1..a4239a1225 100644 --- a/ext/openssl/extconf.rb +++ b/ext/openssl/extconf.rb @@ -85,7 +85,11 @@ if try_compile("#define FOO(a, ...) foo(a, ##__VA_ARGS__)\n int x(){FOO(1);FOO(1 $defs.push("-DHAVE_VA_ARGS_MACRO") end if have_header("openssl/engine.h") + have_func("ENGINE_load_builtin_engines") have_func("ENGINE_load_openbsd_dev_crypto") + have_func("ENGINE_get_digest") + have_func("ENGINE_get_cipher") + have_func("ENGINE_cleanup") end have_header("openssl/ocsp.h") have_struct_member("EVP_CIPHER_CTX", "flags", "openssl/evp.h") diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c index 7c52b4b398..91025941b9 100644 --- a/ext/openssl/ossl_engine.c +++ b/ext/openssl/ossl_engine.c @@ -49,6 +49,9 @@ do{\ static VALUE ossl_engine_s_load(int argc, VALUE *argv, VALUE klass) { +#if !defined(HAVE_ENGINE_LOAD_BUILTIN_ENGINES) + return Qnil; +#else VALUE name; rb_scan_args(argc, argv, "01", &name); @@ -68,12 +71,15 @@ ossl_engine_s_load(int argc, VALUE *argv, VALUE klass) OSSL_ENGINE_LOAD_IF_MATCH(openbsd_dev_crypto); #endif rb_raise(eEngineError, "no such engine `%s'", RSTRING(name)->ptr); +#endif /* HAVE_ENGINE_LOAD_BUILTIN_ENGINES */ } static VALUE ossl_engine_s_cleanup(VALUE self) { +#if defined(HAVE_ENGINE_CLEANUP) ENGINE_cleanup(); +#endif return Qnil; } @@ -156,6 +162,7 @@ ossl_engine_finish(VALUE self) static VALUE ossl_engine_get_cipher(VALUE self, VALUE name) { +#if defined(HAVE_ENGINE_GET_CIPHER) ENGINE *e; const EVP_CIPHER *ciph, *tmp; char *s; @@ -170,11 +177,15 @@ ossl_engine_get_cipher(VALUE self, VALUE name) if(!ciph) ossl_raise(eEngineError, NULL); return ossl_cipher_new(ciph); +#else + rb_notimplement(); +#endif } static VALUE ossl_engine_get_digest(VALUE self, VALUE name) { +#if defined(HAVE_ENGINE_GET_DIGEST) ENGINE *e; const EVP_MD *md, *tmp; char *s; @@ -189,6 +200,9 @@ ossl_engine_get_digest(VALUE self, VALUE name) if(!md) ossl_raise(eEngineError, NULL); return ossl_digest_new(md); +#else + rb_notimplement(); +#endif } static VALUE @@ -292,8 +306,18 @@ Init_ossl_engine() DefEngineConst(METHOD_DSA); DefEngineConst(METHOD_DH); DefEngineConst(METHOD_RAND); +#ifdef ENGINE_METHOD_BN_MOD_EXP + DefEngineConst(METHOD_BN_MOD_EXP); +#endif +#ifdef ENGINE_METHOD_BN_MOD_EXP_CRT + DefEngineConst(METHOD_BN_MOD_EXP_CRT); +#endif +#ifdef ENGINE_METHOD_CIPHERS DefEngineConst(METHOD_CIPHERS); +#endif +#ifdef ENGINE_METHOD_DIGESTS DefEngineConst(METHOD_DIGESTS); +#endif DefEngineConst(METHOD_ALL); DefEngineConst(METHOD_NONE); } -- cgit v1.2.3