aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-09-23 01:15:13 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-09-23 18:31:07 +0900
commit0e49794521db899ab25774e932f83d6ce452a8ec (patch)
tree28601eaf1403a2a7ca293add5eb24b9a8ba946ee /test
parent6ee36c1403ce410688d2d0f918e2c6d7dc5d1cb3 (diff)
downloadruby-openssl-0e49794521db899ab25774e932f83d6ce452a8ec.tar.gz
pkey: make PKey#verify check the existence of the public key
Check existence of the public key in the PKey object before starting verifying a signature. For RSA keys, EVP_VerifyFinal() internally calls RSA_size(), which requires the existence of RSA::n. Since we allow instatiating PKey::RSA without any key materials, calling PKey#verify against an empty PKey::RSA causes segfault. Reference: https://bugs.ruby-lang.org/issues/12783
Diffstat (limited to 'test')
-rw-r--r--test/test_pkey.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/test_pkey.rb b/test/test_pkey.rb
index 79647c8f..ba61fa26 100644
--- a/test/test_pkey.rb
+++ b/test/test_pkey.rb
@@ -44,6 +44,13 @@ class OpenSSL::TestPKey < OpenSSL::PKeyTestCase
end
end
end
+
+ def test_verify_empty_rsa
+ rsa = OpenSSL::PKey::RSA.new
+ assert_raise(OpenSSL::PKey::PKeyError, "[Bug #12783]") {
+ rsa.verify("SHA1", "a", "b")
+ }
+ end
end
end