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

ruby-changes:42985

From: rhe <ko1@a...>
Date: Wed, 18 May 2016 17:52:42 +0900 (JST)
Subject: [ruby-changes:42985] rhe:r55059 (trunk): openssl: fix test failure of OpenSSL::TestEC#test_ec_point_mul

rhe	2016-05-18 17:52:37 +0900 (Wed, 18 May 2016)

  New Revision: 55059

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55059

  Log:
    openssl: fix test failure of OpenSSL::TestEC#test_ec_point_mul
    
    * test/openssl/test_pkey_ec.rb (test_ec_point_mul): CentOS 7 patches
    OpenSSL to reject curves defined over a small field.

  Modified files:
    trunk/test/openssl/test_pkey_ec.rb
Index: test/openssl/test_pkey_ec.rb
===================================================================
--- test/openssl/test_pkey_ec.rb	(revision 55058)
+++ test/openssl/test_pkey_ec.rb	(revision 55059)
@@ -185,28 +185,33 @@ class OpenSSL::TestEC < OpenSSL::TestCas https://github.com/ruby/ruby/blob/trunk/test/openssl/test_pkey_ec.rb#L185
   end
 
   def test_ec_point_mul
-    # y^2 = x^3 + 2x + 2 over F_17
-    # generator is (5, 1)
-    group = OpenSSL::PKey::EC::Group.new(:GFp, 17, 2, 2)
-    gen = OpenSSL::PKey::EC::Point.new(group, OpenSSL::BN.new("040501", 16))
-    group.set_generator(gen, 0, 0)
+    begin
+      # y^2 = x^3 + 2x + 2 over F_17
+      # generator is (5, 1)
+      group = OpenSSL::PKey::EC::Group.new(:GFp, 17, 2, 2)
+      gen = OpenSSL::PKey::EC::Point.new(group, OpenSSL::BN.new("040501", 16))
+      group.set_generator(gen, 0, 0)
 
-    # 3 * (6, 3) = (16, 13)
-    point_a = OpenSSL::PKey::EC::Point.new(group, OpenSSL::BN.new("040603", 16))
-    result_a1 = point_a.mul(3.to_bn)
-    assert_equal("04100D", result_a1.to_bn.to_s(16))
-    # 3 * (6, 3) + 3 * (5, 1) = (7, 6)
-    result_a2 = point_a.mul(3.to_bn, 3.to_bn)
-    assert_equal("040706", result_a2.to_bn.to_s(16))
-    # 3 * point_a = 3 * (6, 3) = (16, 13)
-    result_b1 = point_a.mul([3.to_bn], [])
-    assert_equal("04100D", result_b1.to_bn.to_s(16))
-    # 3 * point_a + 2 * point_a = 3 * (6, 3) + 2 * (6, 3) = (7, 11)
-    result_b1 = point_a.mul([3.to_bn, 2.to_bn], [point_a])
-    assert_equal("04070B", result_b1.to_bn.to_s(16))
-    # 3 * point_a + 5 * point_a.group.generator = 3 * (6, 3) + 5 * (5, 1) = (13, 10)
-    result_b1 = point_a.mul([3.to_bn], [], 5)
-    assert_equal("040D0A", result_b1.to_bn.to_s(16))
+      # 3 * (6, 3) = (16, 13)
+      point_a = OpenSSL::PKey::EC::Point.new(group, OpenSSL::BN.new("040603", 16))
+      result_a1 = point_a.mul(3.to_bn)
+      assert_equal("04100D", result_a1.to_bn.to_s(16))
+      # 3 * (6, 3) + 3 * (5, 1) = (7, 6)
+      result_a2 = point_a.mul(3.to_bn, 3.to_bn)
+      assert_equal("040706", result_a2.to_bn.to_s(16))
+      # 3 * point_a = 3 * (6, 3) = (16, 13)
+      result_b1 = point_a.mul([3.to_bn], [])
+      assert_equal("04100D", result_b1.to_bn.to_s(16))
+      # 3 * point_a + 2 * point_a = 3 * (6, 3) + 2 * (6, 3) = (7, 11)
+      result_b1 = point_a.mul([3.to_bn, 2.to_bn], [point_a])
+      assert_equal("04070B", result_b1.to_bn.to_s(16))
+      # 3 * point_a + 5 * point_a.group.generator = 3 * (6, 3) + 5 * (5, 1) = (13, 10)
+      result_b1 = point_a.mul([3.to_bn], [], 5)
+      assert_equal("040D0A", result_b1.to_bn.to_s(16))
+    rescue OpenSSL::PKey::EC::Group::Error
+      # CentOS patches OpenSSL to reject curves defined over Fp where p < 256 bits
+      raise if e.message !~ /unsupported field/
+    end
 
     p256_key = OpenSSL::TestUtils::TEST_KEY_EC_P256V1
     p256_g = p256_key.group

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

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