aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_pkey.c
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-07-20 21:33:30 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-07-20 21:33:30 +0900
commit4b860f5fc9c8742f90e9609274638628c3253bc8 (patch)
tree53ed8f634806d29666e27d38b38dc5ef68d60129 /ext/openssl/ossl_pkey.c
parent5129832790cda2d88ec67a51941b9fc6f709ca2b (diff)
parent66c1da57eb03c19f96f3f1c843ea2a93dca3d243 (diff)
downloadruby-openssl-4b860f5fc9c8742f90e9609274638628c3253bc8.tar.gz
Merge branch 'topic/ssl-check-pkey-private'
* topic/ssl-check-pkey-private: ssl: reject keys without private components ssl: remove unneeded instance variable x509 and key from SSL::SSLSocket pkey: remove unused things
Diffstat (limited to 'ext/openssl/ossl_pkey.c')
-rw-r--r--ext/openssl/ossl_pkey.c20
1 files changed, 2 insertions, 18 deletions
diff --git a/ext/openssl/ossl_pkey.c b/ext/openssl/ossl_pkey.c
index 2058af74..7b237337 100644
--- a/ext/openssl/ossl_pkey.c
+++ b/ext/openssl/ossl_pkey.c
@@ -15,7 +15,7 @@
VALUE mPKey;
VALUE cPKey;
VALUE ePKeyError;
-ID id_private_q;
+static ID id_private_q;
/*
* callback for generating keys
@@ -197,20 +197,6 @@ DupPKeyPtr(VALUE obj)
return pkey;
}
-EVP_PKEY *
-DupPrivPKeyPtr(VALUE obj)
-{
- EVP_PKEY *pkey;
-
- if (rb_funcallv(obj, id_private_q, 0, NULL) != Qtrue) {
- ossl_raise(rb_eArgError, "Private key is needed.");
- }
- SafeGetPKey(obj, pkey);
- EVP_PKEY_up_ref(pkey);
-
- return pkey;
-}
-
/*
* Private
*/
@@ -272,9 +258,7 @@ ossl_pkey_sign(VALUE self, VALUE digest, VALUE data)
VALUE str;
int result;
- if (rb_funcallv(self, id_private_q, 0, NULL) != Qtrue)
- ossl_raise(rb_eArgError, "Private key is needed.");
- GetPKey(self, pkey);
+ pkey = GetPrivPKeyPtr(self);
md = GetDigestPtr(digest);
StringValue(data);
str = rb_str_new(0, EVP_PKEY_size(pkey)+16);