aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_pkey_rsa.c
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2020-02-15 10:08:50 +0000
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-02-16 14:18:18 +1300
commitdb64f53d57109612fe56c981bfab0229e5c7883d (patch)
treee509acd4cd18a100f4b2de2b601e252ba085b45b /ext/openssl/ossl_pkey_rsa.c
parent23b07043e7fde743ff920f8354b5a094fee19a03 (diff)
downloadruby-openssl-db64f53d57109612fe56c981bfab0229e5c7883d.tar.gz
Revert "Fix segfaults in OpenSSL::PKey::RSA#private_{en,de}crypt when private exp not set"
This reverts commit e30b9a27f00338b065e90c6172d1c4509edc2853 (#255) except the added test code. The 'd' value can be NULL when the RSA private key is backed by an OpenSSL engine, such as an HSM. In that case, only 'n' and 'e' are visible from the OpenSSL API. The original issue has been fixed by Pull Request #258 in another way. Reference: https://github.com/ruby/openssl/pull/255 Reference: https://github.com/ruby/openssl/pull/258
Diffstat (limited to 'ext/openssl/ossl_pkey_rsa.c')
-rw-r--r--ext/openssl/ossl_pkey_rsa.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ext/openssl/ossl_pkey_rsa.c b/ext/openssl/ossl_pkey_rsa.c
index e09813a4..761866c6 100644
--- a/ext/openssl/ossl_pkey_rsa.c
+++ b/ext/openssl/ossl_pkey_rsa.c
@@ -488,13 +488,13 @@ static VALUE
ossl_rsa_private_encrypt(int argc, VALUE *argv, VALUE self)
{
RSA *rsa;
- const BIGNUM *rsa_n, *rsa_d;
+ const BIGNUM *rsa_n;
int buf_len, pad;
VALUE str, buffer, padding;
GetRSA(self, rsa);
- RSA_get0_key(rsa, &rsa_n, NULL, &rsa_d);
- if (!rsa_n || !rsa_d)
+ RSA_get0_key(rsa, &rsa_n, NULL, NULL);
+ if (!rsa_n)
ossl_raise(eRSAError, "incomplete RSA");
if (!RSA_PRIVATE(self, rsa))
ossl_raise(eRSAError, "private key needed.");
@@ -522,13 +522,13 @@ static VALUE
ossl_rsa_private_decrypt(int argc, VALUE *argv, VALUE self)
{
RSA *rsa;
- const BIGNUM *rsa_n, *rsa_d;
+ const BIGNUM *rsa_n;
int buf_len, pad;
VALUE str, buffer, padding;
GetRSA(self, rsa);
- RSA_get0_key(rsa, &rsa_n, NULL, &rsa_d);
- if (!rsa_n || !rsa_d)
+ RSA_get0_key(rsa, &rsa_n, NULL, NULL);
+ if (!rsa_n)
ossl_raise(eRSAError, "incomplete RSA");
if (!RSA_PRIVATE(self, rsa))
ossl_raise(eRSAError, "private key needed.");