[前][次][番号順一覧][スレッド一覧]

ruby-changes:19633

From: emboss <ko1@a...>
Date: Sun, 22 May 2011 06:09:58 +0900 (JST)
Subject: [ruby-changes:19633] emboss:r31677 (trunk): * test/openssl/test_x509cert.rb: Merge DSA-related tests from ruby_1_8

emboss	2011-05-22 06:09:51 +0900 (Sun, 22 May 2011)

  New Revision: 31677

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31677

  Log:
    * test/openssl/test_x509cert.rb: Merge DSA-related tests from ruby_1_8
    branch.

  Modified files:
    trunk/ChangeLog
    trunk/test/openssl/test_x509cert.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 31676)
+++ ChangeLog	(revision 31677)
@@ -1,3 +1,8 @@
+Sun May 22 06:07:17 2011  Martin Bosslet  <Martin.Bosslet@g...>
+
+	* test/openssl/test_x509cert.rb: Merge DSA-related tests from ruby_1_8
+	branch.
+
 Sun May 22 04:11:12 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* thread.c (Init_Thread): add a code comment why the meaningless
Index: test/openssl/test_x509cert.rb
===================================================================
--- test/openssl/test_x509cert.rb	(revision 31676)
+++ test/openssl/test_x509cert.rb	(revision 31677)
@@ -171,6 +171,40 @@
     }
   end
 
+  def test_dsig_algorithm_mismatch
+    assert_raise(OpenSSL::X509::CertificateError) do
+      cert = issue_cert(@ca, @rsa2048, 1, Time.now, Time.now+3600, [],
+                        nil, nil, OpenSSL::Digest::DSS1.new)
+    end
+    assert_raise(OpenSSL::X509::CertificateError) do
+      cert = issue_cert(@ca, @dsa512, 1, Time.now, Time.now+3600, [],
+                        nil, nil, OpenSSL::Digest::MD5.new)
+    end
+  end
+
+  def test_dsa_with_sha2
+    begin
+      cert = issue_cert(@ca, @dsa256, 1, Time.now, Time.now+3600, [],
+                        nil, nil, OpenSSL::Digest::SHA256.new)
+      assert_equal("dsa_with_SHA256", cert.signature_algorithm)
+    rescue OpenSSL::X509::CertificateError
+      # dsa_with_sha2 not supported. skip following test.
+      return
+    end
+    # TODO: need more tests for dsa + sha2
+
+    # SHA1 is allowed from OpenSSL 1.0.0 (0.9.8 requires DSS1)
+    cert = issue_cert(@ca, @dsa256, 1, Time.now, Time.now+3600, [],
+                      nil, nil, OpenSSL::Digest::SHA1.new)
+    assert_equal("dsaWithSHA1", cert.signature_algorithm)
+  end
+
+  def test_check_private_key
+    cert = issue_cert(@ca, @rsa2048, 1, Time.now, Time.now+3600, [],
+                      nil, nil, OpenSSL::Digest::SHA1.new)
+    assert_equal(true, cert.check_private_key(@rsa2048))
+  end
+
   private
 
   def certificate_error_returns_false

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]