summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-06-03 20:45:20 -0700
committerJeremy Evans <code@jeremyevans.net>2019-07-03 16:11:24 -0700
commite30b9a27f00338b065e90c6172d1c4509edc2853 (patch)
tree93755ea113df156e9ab0e1df7bc4457ea164b384 /test
parent5c4391f767b5db55ffa73531ff6449a87b6c1154 (diff)
downloadruby-openssl-e30b9a27f00338b065e90c6172d1c4509edc2853.tar.gz
Fix segfaults in OpenSSL::PKey::RSA#private_{en,de}crypt when private exp not set
The public exp not set would trigger this for #public_{en,de}crypt, but OpenSSL::PKey::RSA#set_key does not allow setting a NULL public exp.
Diffstat (limited to 'test')
-rw-r--r--test/test_pkey_rsa.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/test_pkey_rsa.rb b/test/test_pkey_rsa.rb
index 58558daa..b368a9cb 100644
--- a/test/test_pkey_rsa.rb
+++ b/test/test_pkey_rsa.rb
@@ -4,6 +4,15 @@ require_relative "utils"
if defined?(OpenSSL)
class OpenSSL::TestPKeyRSA < OpenSSL::PKeyTestCase
+ def test_no_private_exp
+ key = OpenSSL::PKey::RSA.new
+ rsa = Fixtures.pkey("rsa2048")
+ key.set_key(rsa.n, rsa.e, nil)
+ key.set_factors(rsa.p, rsa.q)
+ assert_raise(OpenSSL::PKey::RSAError){ key.private_encrypt("foo") }
+ assert_raise(OpenSSL::PKey::RSAError){ key.private_decrypt("foo") }
+ end
+
def test_padding
key = OpenSSL::PKey::RSA.new(512, 3)