summaryrefslogtreecommitdiff
path: root/test/openssl/test_pkey_rsa.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/openssl/test_pkey_rsa.rb')
-rw-r--r--test/openssl/test_pkey_rsa.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/openssl/test_pkey_rsa.rb b/test/openssl/test_pkey_rsa.rb
index b24f1d5..93760f7 100644
--- a/test/openssl/test_pkey_rsa.rb
+++ b/test/openssl/test_pkey_rsa.rb
@@ -242,6 +242,17 @@ 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
+ assert_raise(OpenSSL::PKey::PKeyError) {
+ OpenSSL::PKey.read(pem3c) { nil }
+ }
+ end
+
def test_dup
key = OpenSSL::PKey::RSA.generate(256, 17)
key2 = key.dup