summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authoremboss <emboss@ruby-lang.org>2012-06-10 01:23:21 +0000
committeremboss <emboss@ruby-lang.org>2012-06-10 01:23:21 +0000
commit2b62bd7a5b1479d3ffb2385e9afa742b5dfb863a (patch)
tree400eb8a27b2374c823778ecdfd3beafbaccd1b95 /test
parente358614cd1dcabce348ca4ebbdac740a04e2eedc (diff)
downloadruby-openssl-history-2b62bd7a5b1479d3ffb2385e9afa742b5dfb863a.tar.gz
* ext/openssl/ossl.c
ext/openssl/ossl_pkey_rsa.c ext/openssl/ossl_pkey_dsa.c ext/openssl/ossl_pkey_ec.c: Forbid export passwords that are less than four characters long, as OpenSSL itself does not allow this. Issue found by Eric Hodel. * ext/openssl/ossl_pkey_ec.c: Add export as an alias of to_pem, following the PKey interface contract. * test/openssl/test_pkey_dsa.rb test/openssl/test_pkey_rsa.rb test/openssl/test_pkey_ec.rb: Add tests that assert correct behaviour when dealing with passwords that are less than four characters long. [ruby-core: 42281][ruby-trunk - Bug #5951] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/test_pkey_dsa.rb9
-rw-r--r--test/test_pkey_ec.rb9
-rw-r--r--test/test_pkey_rsa.rb9
3 files changed, 27 insertions, 0 deletions
diff --git a/test/test_pkey_dsa.rb b/test/test_pkey_dsa.rb
index 4bf64a5..555637e 100644
--- a/test/test_pkey_dsa.rb
+++ b/test/test_pkey_dsa.rb
@@ -218,6 +218,15 @@ YNMbNw==
assert_equal([], OpenSSL.errors)
end
+ def test_export_password_length
+ key = OpenSSL::TestUtils::TEST_KEY_DSA256
+ assert_raise(OpenSSL::OpenSSLError) do
+ key.export(OpenSSL::Cipher.new('AES-128-CBC'), 'sec')
+ end
+ pem = key.export(OpenSSL::Cipher.new('AES-128-CBC'), 'secr')
+ assert(pem)
+ end
+
private
def check_sign_verify(digest)
diff --git a/test/test_pkey_ec.rb b/test/test_pkey_ec.rb
index e63f617..a663bb0 100644
--- a/test/test_pkey_ec.rb
+++ b/test/test_pkey_ec.rb
@@ -175,6 +175,15 @@ class OpenSSL::TestEC < Test::Unit::TestCase
assert_equal([], OpenSSL.errors)
end
+ def test_export_password_length
+ key = OpenSSL::TestUtils::TEST_KEY_EC_P256V1
+ assert_raise(OpenSSL::OpenSSLError) do
+ key.export(OpenSSL::Cipher.new('AES-128-CBC'), 'sec')
+ end
+ pem = key.export(OpenSSL::Cipher.new('AES-128-CBC'), 'secr')
+ assert(pem)
+ end
+
# test Group: asn1_flag, point_conversion
end
diff --git a/test/test_pkey_rsa.rb b/test/test_pkey_rsa.rb
index 815f49b..1881525 100644
--- a/test/test_pkey_rsa.rb
+++ b/test/test_pkey_rsa.rb
@@ -244,6 +244,15 @@ AwEAAQ==
assert_equal([], OpenSSL.errors)
end
+ def test_export_password_length
+ key = OpenSSL::TestUtils::TEST_KEY_RSA1024
+ assert_raise(OpenSSL::OpenSSLError) do
+ key.export(OpenSSL::Cipher.new('AES-128-CBC'), 'sec')
+ end
+ pem = key.export(OpenSSL::Cipher.new('AES-128-CBC'), 'secr')
+ assert(pem)
+ end
+
private
def check_PUBKEY(asn1, key)