Skip to content

Commit 0ca511e

Browse files
committed
Import Ruby/OpenSSL 2.1.2.
Original patches are written by rhe. Changes since v2.1.1 can be found at the upstream GitHub repository: https://github.com/ruby/openssl/compare/v2.1.1..v2.1.2 Kazuki Yamaguchi (9): pkey: resume key generation after interrupt tool/ruby-openssl-docker: update to latest versions test/test_ssl: fix test failure with TLS 1.3 test/test_x509name: change script encoding to ASCII-8BIT x509name: refactor OpenSSL::X509::Name#to_s x509name: fix handling of X509_NAME_{oneline,print_ex}() return value x509name: fix OpenSSL::X509::Name#{cmp,<=>} Ruby/OpenSSL 2.0.9 Ruby/OpenSSL 2.1.2 nobu (6): no ID cache in Init functions search winsock libraries explicitly openssl: search winsock openssl_missing.h: constified reduce LibreSSL warnings needs openssl/opensslv.h git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@65132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent a2958f6 commit 0ca511e

19 files changed

+155
-40
lines changed

ext/openssl/History.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
Version 2.1.2
2+
=============
3+
4+
Merged changes in 2.0.9.
5+
6+
7+
Version 2.1.1
8+
=============
9+
10+
Merged changes in 2.0.8.
11+
12+
113
Version 2.1.0
214
=============
315

@@ -55,6 +67,29 @@ Notable changes
5567
[[GitHub #177]](https://github.com/ruby/openssl/pull/177)
5668

5769

70+
Version 2.0.9
71+
=============
72+
73+
Security fixes
74+
--------------
75+
76+
* OpenSSL::X509::Name#<=> could incorrectly return 0 (= equal) for non-equal
77+
objects. CVE-2018-16395 is assigned for this issue.
78+
https://hackerone.com/reports/387250
79+
80+
Bug fixes
81+
---------
82+
83+
* Fixed OpenSSL::PKey::*.{new,generate} immediately aborting if the thread is
84+
interrupted.
85+
[[Bug #14882]](https://bugs.ruby-lang.org/issues/14882)
86+
[[GitHub #205]](https://github.com/ruby/openssl/pull/205)
87+
* Fixed OpenSSL::X509::Name#to_s failing with OpenSSL::X509::NameError if
88+
called against an empty instance.
89+
[[GitHub #200]](https://github.com/ruby/openssl/issues/200)
90+
[[GitHub #211]](https://github.com/ruby/openssl/pull/211)
91+
92+
5893
Version 2.0.8
5994
=============
6095

ext/openssl/extconf.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
Logging::message "=== Checking for system dependent stuff... ===\n"
3434
have_library("nsl", "t_open")
3535
have_library("socket", "socket")
36+
if $mswin || $mingw
37+
have_library("ws2_32")
38+
end
3639

3740
Logging::message "=== Checking for required stuff... ===\n"
3841
result = pkg_config("openssl") && have_header("openssl/ssl.h")
@@ -111,6 +114,10 @@ def find_openssl_library
111114
OpenSSL.check_func_or_macro("ENGINE_load_#{name}", "openssl/engine.h")
112115
}
113116

117+
if ($mswin || $mingw) && have_macro("LIBRESSL_VERSION_NUMBER", "openssl/opensslv.h")
118+
$defs.push("-DNOCRYPT")
119+
end
120+
114121
# added in 1.0.2
115122
have_func("EC_curve_nist2nid")
116123
have_func("X509_REVOKED_dup")

ext/openssl/openssl.gemspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
# -*- encoding: utf-8 -*-
2-
# stub: openssl 2.1.1 ruby lib
2+
# stub: openssl 2.1.2 ruby lib
33
# stub: ext/openssl/extconf.rb
44

55
Gem::Specification.new do |s|
66
s.name = "openssl".freeze
7-
s.version = "2.1.1"
7+
s.version = "2.1.2"
88

99
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
1010
s.metadata = { "msys2_mingw_dependencies" => "openssl" } if s.respond_to? :metadata=
1111
s.require_paths = ["lib".freeze]
1212
s.authors = ["Martin Bosslet".freeze, "SHIBATA Hiroshi".freeze, "Zachary Scott".freeze, "Kazuki Yamaguchi".freeze]
13-
s.date = "2018-05-12"
13+
s.date = "2018-10-17"
1414
s.description = "It wraps the OpenSSL library.".freeze
1515
s.email = ["ruby-core@ruby-lang.org".freeze]
1616
s.extensions = ["ext/openssl/extconf.rb".freeze]
17-
s.extra_rdoc_files = ["CONTRIBUTING.md".freeze, "History.md".freeze, "README.md".freeze]
17+
s.extra_rdoc_files = ["CONTRIBUTING.md".freeze, "README.md".freeze, "History.md".freeze]
1818
s.files = ["BSDL".freeze, "CONTRIBUTING.md".freeze, "History.md".freeze, "LICENSE.txt".freeze, "README.md".freeze, "ext/openssl/deprecation.rb".freeze, "ext/openssl/extconf.rb".freeze, "ext/openssl/openssl_missing.c".freeze, "ext/openssl/openssl_missing.h".freeze, "ext/openssl/ossl.c".freeze, "ext/openssl/ossl.h".freeze, "ext/openssl/ossl_asn1.c".freeze, "ext/openssl/ossl_asn1.h".freeze, "ext/openssl/ossl_bio.c".freeze, "ext/openssl/ossl_bio.h".freeze, "ext/openssl/ossl_bn.c".freeze, "ext/openssl/ossl_bn.h".freeze, "ext/openssl/ossl_cipher.c".freeze, "ext/openssl/ossl_cipher.h".freeze, "ext/openssl/ossl_config.c".freeze, "ext/openssl/ossl_config.h".freeze, "ext/openssl/ossl_digest.c".freeze, "ext/openssl/ossl_digest.h".freeze, "ext/openssl/ossl_engine.c".freeze, "ext/openssl/ossl_engine.h".freeze, "ext/openssl/ossl_hmac.c".freeze, "ext/openssl/ossl_hmac.h".freeze, "ext/openssl/ossl_kdf.c".freeze, "ext/openssl/ossl_kdf.h".freeze, "ext/openssl/ossl_ns_spki.c".freeze, "ext/openssl/ossl_ns_spki.h".freeze, "ext/openssl/ossl_ocsp.c".freeze, "ext/openssl/ossl_ocsp.h".freeze, "ext/openssl/ossl_pkcs12.c".freeze, "ext/openssl/ossl_pkcs12.h".freeze, "ext/openssl/ossl_pkcs7.c".freeze, "ext/openssl/ossl_pkcs7.h".freeze, "ext/openssl/ossl_pkey.c".freeze, "ext/openssl/ossl_pkey.h".freeze, "ext/openssl/ossl_pkey_dh.c".freeze, "ext/openssl/ossl_pkey_dsa.c".freeze, "ext/openssl/ossl_pkey_ec.c".freeze, "ext/openssl/ossl_pkey_rsa.c".freeze, "ext/openssl/ossl_rand.c".freeze, "ext/openssl/ossl_rand.h".freeze, "ext/openssl/ossl_ssl.c".freeze, "ext/openssl/ossl_ssl.h".freeze, "ext/openssl/ossl_ssl_session.c".freeze, "ext/openssl/ossl_version.h".freeze, "ext/openssl/ossl_x509.c".freeze, "ext/openssl/ossl_x509.h".freeze, "ext/openssl/ossl_x509attr.c".freeze, "ext/openssl/ossl_x509cert.c".freeze, "ext/openssl/ossl_x509crl.c".freeze, "ext/openssl/ossl_x509ext.c".freeze, "ext/openssl/ossl_x509name.c".freeze, "ext/openssl/ossl_x509req.c".freeze, "ext/openssl/ossl_x509revoked.c".freeze, "ext/openssl/ossl_x509store.c".freeze, "ext/openssl/ruby_missing.h".freeze, "lib/openssl.rb".freeze, "lib/openssl/bn.rb".freeze, "lib/openssl/buffering.rb".freeze, "lib/openssl/cipher.rb".freeze, "lib/openssl/config.rb".freeze, "lib/openssl/digest.rb".freeze, "lib/openssl/pkcs5.rb".freeze, "lib/openssl/pkey.rb".freeze, "lib/openssl/ssl.rb".freeze, "lib/openssl/x509.rb".freeze]
1919
s.homepage = "https://github.com/ruby/openssl".freeze
2020
s.licenses = ["Ruby".freeze]
2121
s.rdoc_options = ["--main".freeze, "README.md".freeze]
2222
s.required_ruby_version = Gem::Requirement.new(">= 2.3.0".freeze)
23-
s.rubygems_version = "2.7.6".freeze
23+
s.rubygems_version = "3.0.0.beta1".freeze
2424
s.summary = "OpenSSL provides SSL, TLS and general purpose cryptography.".freeze
2525

2626
if s.respond_to? :specification_version then

ext/openssl/openssl_missing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void ossl_X509_REQ_get0_signature(const X509_REQ *, const ASN1_BIT_STRING **, co
149149
static inline _type *EVP_PKEY_get0_##_type(EVP_PKEY *pkey) { \
150150
return pkey->pkey._name; }
151151
#define IMPL_KEY_ACCESSOR2(_type, _group, a1, a2, _fail_cond) \
152-
static inline void _type##_get0_##_group(_type *obj, const BIGNUM **a1, const BIGNUM **a2) { \
152+
static inline void _type##_get0_##_group(const _type *obj, const BIGNUM **a1, const BIGNUM **a2) { \
153153
if (a1) *a1 = obj->a1; \
154154
if (a2) *a2 = obj->a2; } \
155155
static inline int _type##_set0_##_group(_type *obj, BIGNUM *a1, BIGNUM *a2) { \
@@ -158,7 +158,7 @@ static inline int _type##_set0_##_group(_type *obj, BIGNUM *a1, BIGNUM *a2) { \
158158
BN_clear_free(obj->a2); obj->a2 = a2; \
159159
return 1; }
160160
#define IMPL_KEY_ACCESSOR3(_type, _group, a1, a2, a3, _fail_cond) \
161-
static inline void _type##_get0_##_group(_type *obj, const BIGNUM **a1, const BIGNUM **a2, const BIGNUM **a3) { \
161+
static inline void _type##_get0_##_group(const _type *obj, const BIGNUM **a1, const BIGNUM **a2, const BIGNUM **a3) { \
162162
if (a1) *a1 = obj->a1; \
163163
if (a2) *a2 = obj->a2; \
164164
if (a3) *a3 = obj->a3; } \

ext/openssl/ossl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ static void Init_ossl_locks(void)
10991099
void
11001100
Init_openssl(void)
11011101
{
1102+
#undef rb_intern
11021103
/*
11031104
* Init timezone info
11041105
*/

ext/openssl/ossl_asn1.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,7 @@ OSSL_ASN1_IMPL_FACTORY_METHOD(EndOfContent)
13601360
void
13611361
Init_ossl_asn1(void)
13621362
{
1363+
#undef rb_intern
13631364
VALUE ary;
13641365
int i;
13651366

ext/openssl/ossl_pkcs12.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ ossl_pkcs12_to_der(VALUE self)
232232
void
233233
Init_ossl_pkcs12(void)
234234
{
235+
#undef rb_intern
235236
#if 0
236237
mOSSL = rb_define_module("OpenSSL");
237238
eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);

ext/openssl/ossl_pkcs7.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,7 @@ ossl_pkcs7ri_get_enc_key(VALUE self)
10421042
void
10431043
Init_ossl_pkcs7(void)
10441044
{
1045+
#undef rb_intern
10451046
#if 0
10461047
mOSSL = rb_define_module("OpenSSL");
10471048
eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);

ext/openssl/ossl_pkey.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@ static ID id_private_q;
2020
/*
2121
* callback for generating keys
2222
*/
23+
static VALUE
24+
call_check_ints0(VALUE arg)
25+
{
26+
rb_thread_check_ints();
27+
return Qnil;
28+
}
29+
30+
static void *
31+
call_check_ints(void *arg)
32+
{
33+
int state;
34+
rb_protect(call_check_ints0, Qnil, &state);
35+
return (void *)(VALUE)state;
36+
}
37+
2338
int
2439
ossl_generate_cb_2(int p, int n, BN_GENCB *cb)
2540
{
@@ -38,19 +53,26 @@ ossl_generate_cb_2(int p, int n, BN_GENCB *cb)
3853
*/
3954
rb_protect(rb_yield, ary, &state);
4055
if (state) {
41-
arg->stop = 1;
4256
arg->state = state;
57+
return 0;
58+
}
59+
}
60+
if (arg->interrupted) {
61+
arg->interrupted = 0;
62+
state = (int)(VALUE)rb_thread_call_with_gvl(call_check_ints, NULL);
63+
if (state) {
64+
arg->state = state;
65+
return 0;
4366
}
4467
}
45-
if (arg->stop) return 0;
4668
return 1;
4769
}
4870

4971
void
5072
ossl_generate_cb_stop(void *ptr)
5173
{
5274
struct ossl_generate_cb_arg *arg = (struct ossl_generate_cb_arg *)ptr;
53-
arg->stop = 1;
75+
arg->interrupted = 1;
5476
}
5577

5678
static void
@@ -389,6 +411,7 @@ ossl_pkey_verify(VALUE self, VALUE digest, VALUE sig, VALUE data)
389411
void
390412
Init_ossl_pkey(void)
391413
{
414+
#undef rb_intern
392415
#if 0
393416
mOSSL = rb_define_module("OpenSSL");
394417
eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);

ext/openssl/ossl_pkey.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extern const rb_data_type_t ossl_evp_pkey_type;
3737

3838
struct ossl_generate_cb_arg {
3939
int yield;
40-
int stop;
40+
int interrupted;
4141
int state;
4242
};
4343
int ossl_generate_cb_2(int p, int n, BN_GENCB *cb);

0 commit comments

Comments
 (0)