aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_pkey_rsa.rb
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2017-07-21 14:47:50 +0900
committerKazuki Yamaguchi <k@rhe.jp>2017-07-22 21:54:29 +0900
commita896c3d1dfa090e92dec1abf8ac12843af6af721 (patch)
tree768a181b9267ac4ca9b9a9ffefe0e2c60d1974a7 /test/test_pkey_rsa.rb
parent26f928baa819cf06a3efd435a8ec28731d1da3f8 (diff)
downloadruby-openssl-a896c3d1dfa090e92dec1abf8ac12843af6af721.tar.gz
ossl_pem_passwd_cb: relax passphrase length constraint
The minimum passphrase length of 4 bytes is only a limitation of PEM_def_callback() which isn't relevant here. Commit f38501249f33 introduced this bug.
Diffstat (limited to 'test/test_pkey_rsa.rb')
-rw-r--r--test/test_pkey_rsa.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/test_pkey_rsa.rb b/test/test_pkey_rsa.rb
index b24f1d55..381e7603 100644
--- a/test/test_pkey_rsa.rb
+++ b/test/test_pkey_rsa.rb
@@ -242,6 +242,14 @@ class OpenSSL::TestPKeyRSA < OpenSSL::PKeyTestCase
assert_equal pem, dup_public(RSA1024).export
end
+ def test_pem_passwd
+ key = RSA1024
+ pem3c = key.to_pem("aes-128-cbc", "key")
+ assert_match (/ENCRYPTED/), pem3c
+ assert_equal key.to_der, OpenSSL::PKey.read(pem3c, "key").to_der
+ assert_equal key.to_der, OpenSSL::PKey.read(pem3c) { "key" }.to_der
+ end
+
def test_dup
key = OpenSSL::PKey::RSA.generate(256, 17)
key2 = key.dup