Skip to content

Commit 4eb4b32

Browse files
committed
Remove support for OpenSSL 0.9.8 and 1.0.0
They are no longer receiving security updates from the OpenSSL development team since 2015-12. We have kept basic compatibility until now because RHEL 5 still uses an (heavily modified) OpenSSL 0.9.8e. The RHEL 5 will reach EOL on 2017-03, thus it is now safe to assume nobody is still using such old versions of OpenSSL.
1 parent c9225b0 commit 4eb4b32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+105
-516
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ script:
1717
matrix:
1818
fast_finish: true
1919
include:
20-
- env: RUBY_VERSION=ruby-2.3 OPENSSL_VERSION=openssl-1.0.0 OSSL_MDEBUG=1
2120
- env: RUBY_VERSION=ruby-2.3 OPENSSL_VERSION=openssl-1.0.1 OSSL_MDEBUG=1
2221
- env: RUBY_VERSION=ruby-2.3 OPENSSL_VERSION=openssl-1.0.2 OSSL_MDEBUG=1
2322
- env: RUBY_VERSION=ruby-2.3 OPENSSL_VERSION=openssl-1.1.0 OSSL_MDEBUG=1

History.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ Version 2.1.0
44
Compatibility notes
55
-------------------
66

7+
* Support for OpenSSL version 0.9.8 and 1.0.0 is completely removed.
8+
79
Supported platforms
810
-------------------
911

10-
* OpenSSL 0.9.8, 1.0.0, 1.0.1, 1.0.2, 1.1.0
12+
* OpenSSL 1.0.1, 1.0.2, 1.1.0
1113
* LibreSSL 2.3, 2.4, 2.5
1214
* Ruby 2.3, 2.4
1315

ext/openssl/extconf.rb

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -47,61 +47,25 @@
4747
end
4848
end
4949

50-
result = checking_for("OpenSSL version is 0.9.8 or later") {
51-
try_static_assert("OPENSSL_VERSION_NUMBER >= 0x00908000L", "openssl/opensslv.h")
52-
}
53-
unless result
54-
raise "OpenSSL 0.9.8 or later required."
55-
end
56-
57-
unless OpenSSL.check_func("SSL_library_init()", "openssl/ssl.h")
58-
raise "Ignore OpenSSL broken by Apple.\nPlease use another openssl. (e.g. using `configure --with-openssl-dir=/path/to/openssl')"
50+
unless checking_for("OpenSSL version is 1.0.1 or later") {
51+
try_static_assert("OPENSSL_VERSION_NUMBER >= 0x10001000L", "openssl/opensslv.h") }
52+
raise "OpenSSL >= 1.0.1 or LibreSSL is required"
5953
end
6054

6155
Logging::message "=== Checking for OpenSSL features... ===\n"
6256
# compile options
6357

64-
# check OPENSSL_NO_{SSL2,SSL3_METHOD} macro: on some environment, these symbols
65-
# exist even if compiled with no-ssl2 or no-ssl3-method.
66-
unless have_macro("OPENSSL_NO_SSL2", "openssl/opensslconf.h")
67-
have_func("SSLv2_method")
68-
end
69-
unless have_macro("OPENSSL_NO_SSL3_METHOD", "openssl/opensslconf.h")
70-
have_func("SSLv3_method")
71-
end
72-
have_func("TLSv1_1_method")
73-
have_func("TLSv1_2_method")
58+
# SSLv2 and SSLv3 may be removed in future versions of OpenSSL, and even macros
59+
# like OPENSSL_NO_SSL2 may not be defined.
60+
have_func("SSLv2_method")
61+
have_func("SSLv3_method")
7462
have_func("RAND_egd")
7563
engines = %w{builtin_engines openbsd_dev_crypto dynamic 4758cca aep atalla chil
7664
cswift nuron sureware ubsec padlock capi gmp gost cryptodev aesni}
7765
engines.each { |name|
7866
OpenSSL.check_func_or_macro("ENGINE_load_#{name}", "openssl/engine.h")
7967
}
8068

81-
# added in 0.9.8X
82-
have_func("EVP_CIPHER_CTX_new")
83-
have_func("EVP_CIPHER_CTX_free")
84-
OpenSSL.check_func_or_macro("SSL_CTX_clear_options", "openssl/ssl.h")
85-
86-
# added in 1.0.0
87-
have_func("ASN1_TIME_adj")
88-
have_func("EVP_CIPHER_CTX_copy")
89-
have_func("EVP_PKEY_base_id")
90-
have_func("HMAC_CTX_copy")
91-
have_func("PKCS5_PBKDF2_HMAC")
92-
have_func("X509_NAME_hash_old")
93-
have_func("X509_STORE_CTX_get0_current_crl")
94-
have_func("X509_STORE_set_verify_cb")
95-
have_func("i2d_ASN1_SET_ANY")
96-
have_func("SSL_SESSION_cmp") # removed
97-
OpenSSL.check_func_or_macro("SSL_set_tlsext_host_name", "openssl/ssl.h")
98-
have_struct_member("CRYPTO_THREADID", "ptr", "openssl/crypto.h")
99-
have_func("EVP_PKEY_get0")
100-
101-
# added in 1.0.1
102-
have_func("SSL_CTX_set_next_proto_select_cb")
103-
have_macro("EVP_CTRL_GCM_GET_TAG", ['openssl/evp.h']) && $defs.push("-DHAVE_AUTHENTICATED_ENCRYPTION")
104-
10569
# added in 1.0.2
10670
have_func("EC_curve_nist2nid")
10771
have_func("X509_REVOKED_dup")

ext/openssl/openssl_missing.c

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -20,73 +20,6 @@
2020

2121
#include "openssl_missing.h"
2222

23-
/* added in 0.9.8X */
24-
#if !defined(HAVE_EVP_CIPHER_CTX_NEW)
25-
EVP_CIPHER_CTX *
26-
ossl_EVP_CIPHER_CTX_new(void)
27-
{
28-
EVP_CIPHER_CTX *ctx = OPENSSL_malloc(sizeof(EVP_CIPHER_CTX));
29-
if (!ctx)
30-
return NULL;
31-
EVP_CIPHER_CTX_init(ctx);
32-
return ctx;
33-
}
34-
#endif
35-
36-
#if !defined(HAVE_EVP_CIPHER_CTX_FREE)
37-
void
38-
ossl_EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
39-
{
40-
if (ctx) {
41-
EVP_CIPHER_CTX_cleanup(ctx);
42-
OPENSSL_free(ctx);
43-
}
44-
}
45-
#endif
46-
47-
/* added in 1.0.0 */
48-
#if !defined(HAVE_EVP_CIPHER_CTX_COPY)
49-
/*
50-
* this function does not exist in OpenSSL yet... or ever?.
51-
* a future version may break this function.
52-
* tested on 0.9.7d.
53-
*/
54-
int
55-
ossl_EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
56-
{
57-
memcpy(out, in, sizeof(EVP_CIPHER_CTX));
58-
59-
#if !defined(OPENSSL_NO_ENGINE)
60-
if (in->engine) ENGINE_add(out->engine);
61-
if (in->cipher_data) {
62-
out->cipher_data = OPENSSL_malloc(in->cipher->ctx_size);
63-
memcpy(out->cipher_data, in->cipher_data, in->cipher->ctx_size);
64-
}
65-
#endif
66-
67-
return 1;
68-
}
69-
#endif
70-
71-
#if !defined(OPENSSL_NO_HMAC)
72-
#if !defined(HAVE_HMAC_CTX_COPY)
73-
int
74-
ossl_HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in)
75-
{
76-
if (!out || !in)
77-
return 0;
78-
79-
memcpy(out, in, sizeof(HMAC_CTX));
80-
81-
EVP_MD_CTX_copy(&out->md_ctx, &in->md_ctx);
82-
EVP_MD_CTX_copy(&out->i_ctx, &in->i_ctx);
83-
EVP_MD_CTX_copy(&out->o_ctx, &in->o_ctx);
84-
85-
return 1;
86-
}
87-
#endif /* HAVE_HMAC_CTX_COPY */
88-
#endif /* NO_HMAC */
89-
9023
/* added in 1.0.2 */
9124
#if !defined(OPENSSL_NO_EC)
9225
#if !defined(HAVE_EC_CURVE_NIST2NID)

ext/openssl/openssl_missing.h

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,6 @@
1212

1313
#include "ruby/config.h"
1414

15-
/* added in 0.9.8X */
16-
#if !defined(HAVE_EVP_CIPHER_CTX_NEW)
17-
EVP_CIPHER_CTX *ossl_EVP_CIPHER_CTX_new(void);
18-
# define EVP_CIPHER_CTX_new ossl_EVP_CIPHER_CTX_new
19-
#endif
20-
21-
#if !defined(HAVE_EVP_CIPHER_CTX_FREE)
22-
void ossl_EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *);
23-
# define EVP_CIPHER_CTX_free ossl_EVP_CIPHER_CTX_free
24-
#endif
25-
26-
#if !defined(HAVE_SSL_CTX_CLEAR_OPTIONS)
27-
# define SSL_CTX_clear_options(ctx, op) ((ctx)->options &= ~(op))
28-
#endif
29-
30-
/* added in 1.0.0 */
31-
#if !defined(HAVE_EVP_PKEY_BASE_ID)
32-
# define EVP_PKEY_base_id(pkey) EVP_PKEY_type((pkey)->type)
33-
#endif
34-
35-
#if !defined(HAVE_EVP_CIPHER_CTX_COPY)
36-
int ossl_EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *, const EVP_CIPHER_CTX *);
37-
# define EVP_CIPHER_CTX_copy ossl_EVP_CIPHER_CTX_copy
38-
#endif
39-
40-
#if !defined(HAVE_HMAC_CTX_COPY)
41-
int ossl_HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in);
42-
# define HMAC_CTX_copy ossl_HMAC_CTX_copy
43-
#endif
44-
45-
#if !defined(HAVE_X509_STORE_CTX_GET0_CURRENT_CRL)
46-
# define X509_STORE_CTX_get0_current_crl(x) ((x)->current_crl)
47-
#endif
48-
49-
#if !defined(HAVE_X509_STORE_SET_VERIFY_CB)
50-
# define X509_STORE_set_verify_cb X509_STORE_set_verify_cb_func
51-
#endif
52-
53-
#if !defined(HAVE_I2D_ASN1_SET_ANY)
54-
# define i2d_ASN1_SET_ANY(sk, x) i2d_ASN1_SET_OF_ASN1_TYPE((sk), (x), \
55-
i2d_ASN1_TYPE, V_ASN1_SET, V_ASN1_UNIVERSAL, 0)
56-
#endif
57-
58-
#if !defined(HAVE_EVP_PKEY_GET0)
59-
# define EVP_PKEY_get0(pk) (pk->pkey.ptr)
60-
#endif
61-
6215
/* added in 1.0.2 */
6316
#if !defined(OPENSSL_NO_EC)
6417
#if !defined(HAVE_EC_CURVE_NIST2NID)
@@ -245,7 +198,7 @@ IMPL_PKEY_GETTER(EC_KEY, ec)
245198
#undef IMPL_KEY_ACCESSOR3
246199
#endif /* HAVE_OPAQUE_OPENSSL */
247200

248-
#if defined(HAVE_AUTHENTICATED_ENCRYPTION) && !defined(EVP_CTRL_AEAD_GET_TAG)
201+
#if !defined(EVP_CTRL_AEAD_GET_TAG)
249202
# define EVP_CTRL_AEAD_GET_TAG EVP_CTRL_GCM_GET_TAG
250203
# define EVP_CTRL_AEAD_SET_TAG EVP_CTRL_GCM_SET_TAG
251204
# define EVP_CTRL_AEAD_SET_IVLEN EVP_CTRL_GCM_SET_IVLEN

ext/openssl/ossl.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -473,19 +473,11 @@ ossl_dyn_destroy_callback(struct CRYPTO_dynlock_value *l, const char *file, int
473473
OPENSSL_free(l);
474474
}
475475

476-
#ifdef HAVE_CRYPTO_THREADID_PTR
477476
static void ossl_threadid_func(CRYPTO_THREADID *id)
478477
{
479478
/* register native thread id */
480479
CRYPTO_THREADID_set_pointer(id, (void *)rb_nativethread_self());
481480
}
482-
#else
483-
static unsigned long ossl_thread_id(void)
484-
{
485-
/* before OpenSSL 1.0, this is 'unsigned long' */
486-
return (unsigned long)rb_nativethread_self();
487-
}
488-
#endif
489481

490482
static void Init_ossl_locks(void)
491483
{
@@ -503,11 +495,7 @@ static void Init_ossl_locks(void)
503495
rb_nativethread_lock_initialize(&ossl_locks[i]);
504496
}
505497

506-
#ifdef HAVE_CRYPTO_THREADID_PTR
507498
CRYPTO_THREADID_set_callback(ossl_threadid_func);
508-
#else
509-
CRYPTO_set_id_callback(ossl_thread_id);
510-
#endif
511499
CRYPTO_set_locking_callback(ossl_lock_callback);
512500
CRYPTO_set_dynlock_create_callback(ossl_dyn_create_callback);
513501
CRYPTO_set_dynlock_lock_callback(ossl_dyn_lock_callback);

ext/openssl/ossl_asn1.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ asn1time_to_time(const ASN1_TIME *time)
7272
return rb_funcall2(rb_cTime, rb_intern("utc"), 6, argv);
7373
}
7474

75-
#if defined(HAVE_ASN1_TIME_ADJ)
7675
void
7776
ossl_time_split(VALUE time, time_t *sec, int *days)
7877
{
@@ -88,13 +87,6 @@ ossl_time_split(VALUE time, time_t *sec, int *days)
8887
*sec = NUM2TIMET(rb_funcall(num, rb_intern("%"), 1, INT2FIX(86400)));
8988
}
9089
}
91-
#else
92-
time_t
93-
time_to_time_t(VALUE time)
94-
{
95-
return (time_t)NUM2TIMET(rb_Integer(time));
96-
}
97-
#endif
9890

9991
/*
10092
* STRING conversion
@@ -269,15 +261,10 @@ obj_to_asn1utime(VALUE time)
269261
time_t sec;
270262
ASN1_UTCTIME *t;
271263

272-
#if defined(HAVE_ASN1_TIME_ADJ)
273264
int off_days;
274265

275266
ossl_time_split(time, &sec, &off_days);
276267
if (!(t = ASN1_UTCTIME_adj(NULL, sec, off_days, 0)))
277-
#else
278-
sec = time_to_time_t(time);
279-
if (!(t = ASN1_UTCTIME_set(NULL, sec)))
280-
#endif
281268
ossl_raise(eASN1Error, NULL);
282269

283270
return t;
@@ -289,15 +276,10 @@ obj_to_asn1gtime(VALUE time)
289276
time_t sec;
290277
ASN1_GENERALIZEDTIME *t;
291278

292-
#if defined(HAVE_ASN1_TIME_ADJ)
293279
int off_days;
294280

295281
ossl_time_split(time, &sec, &off_days);
296282
if (!(t = ASN1_GENERALIZEDTIME_adj(NULL, sec, off_days, 0)))
297-
#else
298-
sec = time_to_time_t(time);
299-
if (!(t = ASN1_GENERALIZEDTIME_set(NULL, sec)))
300-
#endif
301283
ossl_raise(eASN1Error, NULL);
302284

303285
return t;

ext/openssl/ossl_asn1.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@
1414
* ASN1_DATE conversions
1515
*/
1616
VALUE asn1time_to_time(const ASN1_TIME *);
17-
#if defined(HAVE_ASN1_TIME_ADJ)
1817
/* Splits VALUE to seconds and offset days. VALUE is typically a Time or an
1918
* Integer. This is used when updating ASN1_*TIME with ASN1_TIME_adj() or
2019
* X509_time_adj_ex(). We can't use ASN1_TIME_set() and X509_time_adj() because
2120
* they have the Year 2038 issue on sizeof(time_t) == 4 environment */
2221
void ossl_time_split(VALUE, time_t *, int *);
23-
#else
24-
time_t time_to_time_t(VALUE);
25-
#endif
2622

2723
/*
2824
* ASN1_STRING conversions

ext/openssl/ossl_cipher.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,8 @@ ossl_cipher_set_iv(VALUE self, VALUE iv)
512512
StringValue(iv);
513513
GetCipher(self, ctx);
514514

515-
#if defined(HAVE_AUTHENTICATED_ENCRYPTION)
516515
if (EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER)
517516
iv_len = (int)(VALUE)EVP_CIPHER_CTX_get_app_data(ctx);
518-
#endif
519517
if (!iv_len)
520518
iv_len = EVP_CIPHER_CTX_iv_length(ctx);
521519
if (RSTRING_LEN(iv) != iv_len)
@@ -541,14 +539,9 @@ ossl_cipher_is_authenticated(VALUE self)
541539

542540
GetCipher(self, ctx);
543541

544-
#if defined(HAVE_AUTHENTICATED_ENCRYPTION)
545542
return (EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER) ? Qtrue : Qfalse;
546-
#else
547-
return Qfalse;
548-
#endif
549543
}
550544

551-
#ifdef HAVE_AUTHENTICATED_ENCRYPTION
552545
/*
553546
* call-seq:
554547
* cipher.auth_data = string -> string
@@ -722,13 +715,6 @@ ossl_cipher_set_iv_length(VALUE self, VALUE iv_length)
722715

723716
return iv_length;
724717
}
725-
#else
726-
#define ossl_cipher_set_auth_data rb_f_notimplement
727-
#define ossl_cipher_get_auth_tag rb_f_notimplement
728-
#define ossl_cipher_set_auth_tag rb_f_notimplement
729-
#define ossl_cipher_set_auth_tag_len rb_f_notimplement
730-
#define ossl_cipher_set_iv_length rb_f_notimplement
731-
#endif
732718

733719
/*
734720
* call-seq:
@@ -806,10 +792,8 @@ ossl_cipher_iv_length(VALUE self)
806792
int len = 0;
807793

808794
GetCipher(self, ctx);
809-
#if defined(HAVE_AUTHENTICATED_ENCRYPTION)
810795
if (EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER)
811796
len = (int)(VALUE)EVP_CIPHER_CTX_get_app_data(ctx);
812-
#endif
813797
if (!len)
814798
len = EVP_CIPHER_CTX_iv_length(ctx);
815799

0 commit comments

Comments
 (0)