summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-02 11:20:01 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-02 11:20:01 +0000
commit76c0f01b0fa6748c2d89a247d00c9704c8eaeb56 (patch)
tree7e03cd86f7672237ca774fa77c76dd1d465450b4
parent6f52fccb18e718db4b1409b8fd21507f9046f49e (diff)
merges r29075 from trunk into ruby_1_9_2.
-- * backport r29071 from ruby_1_8; * ext/openssl/ossl_asn1.c (obj_to_asn1bool): fixed ASN1::Boolean encoding issue for OpenSSL 1.0.0 compatibility. ASN1::Boolean.new(false).to_der wrongly generated "\1\1\377" which means 'true'. ASN1_TYPE_set of OpenSSL <= 0.9.8 treats value 0x100 as 'false' but OpenSSL >= 1.0.0 treats it as 'true'. ruby-ossl was using 0x100 for 'false' for backward compatibility. Just use 0x0 for the case OpenSSL >= OpenSSL 0.9.7. * test/openssl/test_asn1.rb: test added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@29389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog16
-rw-r--r--ext/openssl/ossl_asn1.c4
-rw-r--r--test/openssl/test_asn1.rb14
-rw-r--r--version.h2
4 files changed, 35 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 44e9b9befb..4061c8b3fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+Mon Aug 23 13:09:27 2010 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+
+ * backport r29071 from ruby_1_8;
+
+ * ext/openssl/ossl_asn1.c (obj_to_asn1bool): fixed ASN1::Boolean
+ encoding issue for OpenSSL 1.0.0 compatibility.
+ ASN1::Boolean.new(false).to_der wrongly generated "\1\1\377" which
+ means 'true'.
+
+ ASN1_TYPE_set of OpenSSL <= 0.9.8 treats value 0x100 as 'false'
+ but OpenSSL >= 1.0.0 treats it as 'true'. ruby-ossl was using
+ 0x100 for 'false' for backward compatibility. Just use 0x0 for
+ the case OpenSSL >= OpenSSL 0.9.7.
+
+ * test/openssl/test_asn1.rb: test added.
+
Mon Aug 23 22:30:58 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* common.mk (version.o): depends on both of version.h and
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index 6682cb7748..a9ab7e38ce 100644
--- a/ext/openssl/ossl_asn1.c
+++ b/ext/openssl/ossl_asn1.c
@@ -196,7 +196,11 @@ static ID sUNIVERSAL, sAPPLICATION, sCONTEXT_SPECIFIC, sPRIVATE;
static ASN1_BOOLEAN
obj_to_asn1bool(VALUE obj)
{
+#if OPENSSL_VERSION_NUMBER < 0x00907000L
return RTEST(obj) ? 0xff : 0x100;
+#else
+ return RTEST(obj) ? 0xff : 0x0;
+#endif
}
static ASN1_INTEGER*
diff --git a/test/openssl/test_asn1.rb b/test/openssl/test_asn1.rb
index 04bbd7ff5c..9486e09a13 100644
--- a/test/openssl/test_asn1.rb
+++ b/test/openssl/test_asn1.rb
@@ -194,4 +194,18 @@ class OpenSSL::TestASN1 < Test::Unit::TestCase
cululated_sig = key.sign(OpenSSL::Digest::SHA1.new, tbs_cert.to_der)
assert_equal(cululated_sig, sig_val.value)
end
+
+ def test_encode_boolean
+ encode_decode_test(OpenSSL::ASN1::Boolean, [true, false])
+ end
+
+ def test_encode_integer
+ encode_decode_test(OpenSSL::ASN1::Integer, [72, -127, -128, 128, -1, 0, 1, -(2**12345), 2**12345])
+ end
+
+ def encode_decode_test(type, values)
+ values.each do |v|
+ assert_equal(v, OpenSSL::ASN1.decode(type.new(v).to_der).value)
+ end
+ end
end if defined?(OpenSSL)
diff --git a/version.h b/version.h
index 0515f47de2..b3b5f20428 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "1.9.2"
#define RUBY_RELEASE_DATE "2010-10-02"
-#define RUBY_PATCHLEVEL 9
+#define RUBY_PATCHLEVEL 10
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9