From 9098be4970b4afcaa9061b4fd749fadcb28581bf Mon Sep 17 00:00:00 2001 From: gotoyuzo Date: Sun, 18 Sep 2005 22:56:11 +0000 Subject: * ext/openssl/ossl_pkey.h, ossl_pkey_rsa.c, ossl_pkey_dsa.c: an instance variable "private" is added to OpenSSL::PKey class. this ivar is a flag that shows whether there is a private key in the instance. * ext/openssl/ossl_engine.c: (ossl_engine_load_privkey): set private key flag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/openssl/test_pkey_rsa.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/openssl') diff --git a/test/openssl/test_pkey_rsa.rb b/test/openssl/test_pkey_rsa.rb index 36eb2b77eb..401cb6c3e0 100644 --- a/test/openssl/test_pkey_rsa.rb +++ b/test/openssl/test_pkey_rsa.rb @@ -33,6 +33,17 @@ class OpenSSL::TestPKeyRSA < Test::Unit::TestCase assert_raise(ArgumentError){ key.private_encrypt("hi", 1, nil) } assert_raise(OpenSSL::PKey::RSAError){ key.private_encrypt(plain0, 666) } end + + def test_private + key = OpenSSL::PKey::RSA.new(512, 3) + assert(key.private?) + key2 = OpenSSL::PKey::RSA.new(key.to_der) + assert(key2.private?) + key3 = key.public_key + assert(!key3.private?) + key4 = OpenSSL::PKey::RSA.new(key3.to_der) + assert(!key4.private?) + end end end -- cgit v1.2.3