diff options
author | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-06-11 00:59:43 +0000 |
---|---|---|
committer | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-06-11 00:59:43 +0000 |
commit | 60b4f00e727ef639ce092d2e03a93a44c1a0d45f (patch) | |
tree | cfd4eafe37dbf9c36db533a62e98e368b75761e1 | |
parent | 44ccf5c91fdf223a442cd8418edd42f8db6bddba (diff) | |
download | ruby-openssl-history-60b4f00e727ef639ce092d2e03a93a44c1a0d45f.tar.gz |
pkey.c: don't segfault when signing with public key (check added), compile fix
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | ossl_pkey.c | 6 |
2 files changed, 8 insertions, 1 deletions
@@ -3,6 +3,9 @@ ChangeLog for ### CHANGE LOG ### +Tue, 11 Jun 2002 02:58:24 +0200 -- Michal Rokos <m.rokos@sh.cvut.cz> + * pkey.c: don't segfault when signing with public key - check added + Tue, 11 Jun 2002 02:42:25 +0200 -- Michal Rokos <m.rokos@sh.cvut.cz> * extconf.rb: Check for unistd.h * ssl.c: include <unistd.h> is avaible (needed for read(), write()) diff --git a/ossl_pkey.c b/ossl_pkey.c index 795492f..6a4f3ce 100644 --- a/ossl_pkey.c +++ b/ossl_pkey.c @@ -105,7 +105,7 @@ DupPrivPKeyPtr(VALUE obj) SafeGetPKey(obj, pkey); - if (rb_funcall(obj, id_private_q, 0, NULL) = Qtrue) { /* returns Qtrue */ + if (rb_funcall(obj, id_private_q, 0, NULL) == Qtrue) { /* returns Qtrue */ CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY); return pkey; } @@ -173,6 +173,10 @@ ossl_pkey_sign(VALUE self, VALUE digest, VALUE data) int buf_len; VALUE str; + if (rb_funcall(self, id_private_q, 0, NULL) != Qtrue) { + rb_raise(rb_eArgError, "Private key is needed."); + } + GetPKey(self, pkey); md = ossl_digest_get_EVP_MD(digest); |