summaryrefslogtreecommitdiff
path: root/ext/openssl
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-05 13:58:02 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-05 13:58:02 +0000
commitf58812a7e22c0ffe04758e660c8f5b60bc65f58c (patch)
tree65575b9f1cc5d236884637712ebba55ea9611152 /ext/openssl
parent474e9004deea5bf8cd321532eb1c054202486ac3 (diff)
* 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
Diffstat (limited to 'ext/openssl')
-rw-r--r--ext/openssl/extconf.rb4
-rw-r--r--ext/openssl/ossl_engine.c24
2 files changed, 28 insertions, 0 deletions
diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb
index 5ef85be..a4239a1 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 7c52b4b..9102594 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);
}