mirror of
https://github.com/ruby/ruby.git
synced 2025-09-18 18:13:58 +02:00
* ext/openssl/ossl_pkey_ec.c: Ensure compatibility to builds of OpenSSL with OPENSSL_NO_EC2M defined, but OPENSSL_NO_EC not defined. * test/openssl/test_pkey_ec.rb: Iterate over built-in curves (and assert their non-emptiness!) instead of hard-coding them, as this may cause problems with respect to the different availability of individual curves in individual OpenSSL builds. [ruby-core:54881] [Bug #8384] Thanks to Vit Ondruch for providing the patch! * test/openssl/test_pkey_ec.rb: Skip tests for "Oakley" curves as they are not suitable for ECDSA. [ruby-core:54881] [Bug #8384] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d39041bab5
commit
f895841e2c
4 changed files with 44 additions and 17 deletions
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
||||||
|
Thu Oct 31 22:28:04 2013 Martin Bosslet <Martin.Bosslet@gmail.com>
|
||||||
|
|
||||||
|
* test/openssl/test_pkey_ec.rb: Skip tests for "Oakley" curves as
|
||||||
|
they are not suitable for ECDSA.
|
||||||
|
[ruby-core:54881] [Bug #8384]
|
||||||
|
|
||||||
|
Thu Oct 31 22:28:04 2013 Martin Bosslet <Martin.Bosslet@gmail.com>
|
||||||
|
|
||||||
|
* ext/openssl/ossl_pkey_ec.c: Ensure compatibility to builds of
|
||||||
|
OpenSSL with OPENSSL_NO_EC2M defined, but OPENSSL_NO_EC not
|
||||||
|
defined.
|
||||||
|
* test/openssl/test_pkey_ec.rb: Iterate over built-in curves
|
||||||
|
(and assert their non-emptiness!) instead of hard-coding them, as
|
||||||
|
this may cause problems with respect to the different availability
|
||||||
|
of individual curves in individual OpenSSL builds.
|
||||||
|
[ruby-core:54881] [Bug #8384]
|
||||||
|
|
||||||
|
Thanks to Vit Ondruch for providing the patch!
|
||||||
|
|
||||||
Sun Oct 27 01:04:28 2013 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
|
Sun Oct 27 01:04:28 2013 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
|
||||||
|
|
||||||
* lib/rubygems: Update to RubyGems 2.0.13. [ruby-core:58031]
|
* lib/rubygems: Update to RubyGems 2.0.13. [ruby-core:58031]
|
||||||
|
|
|
@ -762,8 +762,10 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
|
||||||
method = EC_GFp_mont_method();
|
method = EC_GFp_mont_method();
|
||||||
} else if (id == s_GFp_nist) {
|
} else if (id == s_GFp_nist) {
|
||||||
method = EC_GFp_nist_method();
|
method = EC_GFp_nist_method();
|
||||||
|
#if !defined(OPENSSL_NO_EC2M)
|
||||||
} else if (id == s_GF2m_simple) {
|
} else if (id == s_GF2m_simple) {
|
||||||
method = EC_GF2m_simple_method();
|
method = EC_GF2m_simple_method();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (method) {
|
if (method) {
|
||||||
|
@ -817,8 +819,10 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
|
||||||
|
|
||||||
if (id == s_GFp) {
|
if (id == s_GFp) {
|
||||||
new_curve = EC_GROUP_new_curve_GFp;
|
new_curve = EC_GROUP_new_curve_GFp;
|
||||||
|
#if !defined(OPENSSL_NO_EC2M)
|
||||||
} else if (id == s_GF2m) {
|
} else if (id == s_GF2m) {
|
||||||
new_curve = EC_GROUP_new_curve_GF2m;
|
new_curve = EC_GROUP_new_curve_GF2m;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
ossl_raise(rb_eArgError, "unknown symbol, must be :GFp or :GF2m");
|
ossl_raise(rb_eArgError, "unknown symbol, must be :GFp or :GF2m");
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,28 +7,29 @@ class OpenSSL::TestEC < Test::Unit::TestCase
|
||||||
@data1 = 'foo'
|
@data1 = 'foo'
|
||||||
@data2 = 'bar' * 1000 # data too long for DSA sig
|
@data2 = 'bar' * 1000 # data too long for DSA sig
|
||||||
|
|
||||||
@group1 = OpenSSL::PKey::EC::Group.new('secp112r1')
|
@groups = []
|
||||||
@group2 = OpenSSL::PKey::EC::Group.new('sect163k1')
|
@keys = []
|
||||||
@group3 = OpenSSL::PKey::EC::Group.new('prime256v1')
|
|
||||||
|
|
||||||
@key1 = OpenSSL::PKey::EC.new
|
OpenSSL::PKey::EC.builtin_curves.each do |curve, comment|
|
||||||
@key1.group = @group1
|
next if curve.start_with?("Oakley") # Oakley curves are not suitable for ECDSA
|
||||||
@key1.generate_key
|
group = OpenSSL::PKey::EC::Group.new(curve)
|
||||||
|
|
||||||
@key2 = OpenSSL::PKey::EC.new(@group2.curve_name)
|
key = OpenSSL::PKey::EC.new(group)
|
||||||
@key2.generate_key
|
key.generate_key
|
||||||
|
|
||||||
@key3 = OpenSSL::PKey::EC.new(@group3)
|
@groups << group
|
||||||
@key3.generate_key
|
@keys << key
|
||||||
|
end
|
||||||
@groups = [@group1, @group2, @group3]
|
|
||||||
@keys = [@key1, @key2, @key3]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def compare_keys(k1, k2)
|
def compare_keys(k1, k2)
|
||||||
assert_equal(k1.to_pem, k2.to_pem)
|
assert_equal(k1.to_pem, k2.to_pem)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_builtin_curves
|
||||||
|
assert(!OpenSSL::PKey::EC.builtin_curves.empty?)
|
||||||
|
end
|
||||||
|
|
||||||
def test_curve_names
|
def test_curve_names
|
||||||
@groups.each_with_index do |group, idx|
|
@groups.each_with_index do |group, idx|
|
||||||
key = @keys[idx]
|
key = @keys[idx]
|
||||||
|
@ -44,11 +45,12 @@ class OpenSSL::TestEC < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_encoding
|
def test_group_encoding
|
||||||
for group in @groups
|
for group in @groups
|
||||||
for meth in [:to_der, :to_pem]
|
for meth in [:to_der, :to_pem]
|
||||||
txt = group.send(meth)
|
txt = group.send(meth)
|
||||||
gr = OpenSSL::PKey::EC::Group.new(txt)
|
gr = OpenSSL::PKey::EC::Group.new(txt)
|
||||||
|
|
||||||
assert_equal(txt, gr.send(meth))
|
assert_equal(txt, gr.send(meth))
|
||||||
|
|
||||||
assert_equal(group.generator.to_bn, gr.generator.to_bn)
|
assert_equal(group.generator.to_bn, gr.generator.to_bn)
|
||||||
|
@ -58,7 +60,9 @@ class OpenSSL::TestEC < Test::Unit::TestCase
|
||||||
assert_equal(group.degree, gr.degree)
|
assert_equal(group.degree, gr.degree)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_key_encoding
|
||||||
for key in @keys
|
for key in @keys
|
||||||
group = key.group
|
group = key.group
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#define RUBY_VERSION "2.0.0"
|
#define RUBY_VERSION "2.0.0"
|
||||||
#define RUBY_RELEASE_DATE "2013-10-27"
|
#define RUBY_RELEASE_DATE "2013-10-31"
|
||||||
#define RUBY_PATCHLEVEL 342
|
#define RUBY_PATCHLEVEL 343
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2013
|
#define RUBY_RELEASE_YEAR 2013
|
||||||
#define RUBY_RELEASE_MONTH 10
|
#define RUBY_RELEASE_MONTH 10
|
||||||
#define RUBY_RELEASE_DAY 27
|
#define RUBY_RELEASE_DAY 31
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue