openssl 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b75bcd65f8742364f4a513c5ec991648ef6c859b185f2ae87b3eeb1551ab743b
4
- data.tar.gz: 1e9674192c66fd95a3c201d9afd0d2d755da24ae2847e5abfd68734ba262c811
3
+ metadata.gz: 239c530562472710697b8da573b8aa64b477c02f5895907220e83e9f09c88fec
4
+ data.tar.gz: 62f2d04df3f693b995bf29be9d299c9f916f44a82b5bc5df60e9f46a748990d8
5
5
  SHA512:
6
- metadata.gz: c28bc1d26bb1ae082481d1615d381bd2026b094eae39ddaadbe2791a9bade505bdc0431f19539254f66520feca5b073b675d93c53117b5df880460e029f2641c
7
- data.tar.gz: b815b33563ece86bc99f7112db593765c8bc32c887511ef5caff77725d64fb3f78e470e1ae4fbec131d04eda464159852aac3373e485d36c47ef32b35f59d99c
6
+ metadata.gz: 05f891730a9dea150a2cecedb8decbf7f7dbb500cc825226a635fce8ca195a2dbf036de38dbdb7462cbb18e2e3c8aca337c1e1d9d021a94bbc444312dcf26568
7
+ data.tar.gz: 4cff09ce02fc107422829ca552c97cf912f2b5f129c87e37137b153fd2c09d9a231493af7ce32f391c32828b3ffc64bf905adf6a1e3fad943e78ca81048a4f96
data/CONTRIBUTING.md CHANGED
@@ -17,7 +17,7 @@ When reporting a bug, please make sure you include:
17
17
  * Ruby version (`ruby -v`)
18
18
  * `openssl` gem version (`gem list openssl` and `OpenSSL::VERSION`)
19
19
  * OpenSSL library version (`OpenSSL::OPENSSL_VERSION`)
20
- * A sample file that illustrates the problem or link to the repository or
20
+ * A sample file that illustrates the problem or link to the repository or
21
21
  gem that is associated with the bug.
22
22
 
23
23
  There are a number of unresolved issues and feature requests for openssl that
data/History.md CHANGED
@@ -1,3 +1,53 @@
1
+ Version 3.1.0
2
+ =============
3
+
4
+ Ruby/OpenSSL 3.1 will be maintained for the lifetime of Ruby 3.2.
5
+
6
+ Merged bug fixes in 2.2.3 and 3.0.2. Among the new features and changes are:
7
+
8
+ Notable changes
9
+ ---------------
10
+
11
+ * Add `OpenSSL::SSL::SSLContext#ciphersuites=` to allow setting TLS 1.3 cipher
12
+ suites.
13
+ [[GitHub #493]](https://github.com/ruby/openssl/pull/493)
14
+ * Add `OpenSSL::SSL::SSLSocket#export_keying_material` for exporting keying
15
+ material of the session, as defined in RFC 5705.
16
+ [[GitHub #530]](https://github.com/ruby/openssl/pull/530)
17
+ * Add `OpenSSL::SSL::SSLContext#keylog_cb=` for setting the TLS key logging
18
+ callback, which is useful for supporting NSS's SSLKEYLOGFILE debugging output.
19
+ [[GitHub #536]](https://github.com/ruby/openssl/pull/536)
20
+ * Remove the default digest algorithm from `OpenSSL::OCSP::BasicResponse#sign`
21
+ and `OpenSSL::OCSP::Request#sign`. Omitting the 5th parameter of these
22
+ methods used to be equivalent of specifying SHA-1. This default value is now
23
+ removed and we will let the underlying OpenSSL library decide instead.
24
+ [[GitHub #507]](https://github.com/ruby/openssl/pull/507)
25
+ * Add `OpenSSL::BN#mod_sqrt`.
26
+ [[GitHub #553]](https://github.com/ruby/openssl/pull/553)
27
+ * Allow calling `OpenSSL::Cipher#update` with an empty string. This was
28
+ prohibited to workaround an ancient bug in OpenSSL.
29
+ [[GitHub #568]](https://github.com/ruby/openssl/pull/568)
30
+ * Fix build on platforms without socket support, such as WASI. `OpenSSL::SSL`
31
+ will not be defined if OpenSSL is compiled with `OPENSSL_NO_SOCK`.
32
+ [[GitHub #558]](https://github.com/ruby/openssl/pull/558)
33
+ * Improve support for recent LibreSSL versions. This includes HKDF support in
34
+ LibreSSL 3.6 and Ed25519 support in LibreSSL 3.7.
35
+
36
+
37
+ Version 3.0.2
38
+ =============
39
+
40
+ Merged changes in 2.2.3. Additionally, the following issues are fixed by this
41
+ release.
42
+
43
+ Bug fixes
44
+ ---------
45
+
46
+ * Fix OpenSSL::PKey::EC#check_key not working correctly on OpenSSL 3.0.
47
+ [[GitHub #563]](https://github.com/ruby/openssl/issues/563)
48
+ [[GitHub #580]](https://github.com/ruby/openssl/pull/580)
49
+
50
+
1
51
  Version 3.0.1
2
52
  =============
3
53
 
@@ -124,6 +174,21 @@ Notable changes
124
174
  [[GitHub #342]](https://github.com/ruby/openssl/issues/342)
125
175
 
126
176
 
177
+ Version 2.2.3
178
+ =============
179
+
180
+ Bug fixes
181
+ ---------
182
+
183
+ * Fix serveral methods in OpenSSL::PKey::EC::Point attempting to raise an error
184
+ with an incorrect class, which would end up with a TypeError.
185
+ [[GitHub #570]](https://github.com/ruby/openssl/pull/570)
186
+ * Fix OpenSSL::PKey::EC::Point#eql? and OpenSSL::PKey::EC::Group#eql?
187
+ incorrectly treated OpenSSL's internal errors as "not equal".
188
+ [[GitHub #564]](https://github.com/ruby/openssl/pull/564)
189
+ * Fix build with LibreSSL 3.5 or later.
190
+
191
+
127
192
  Version 2.2.2
128
193
  =============
129
194
 
@@ -25,8 +25,9 @@ Logging::message "=== OpenSSL for Ruby configurator ===\n"
25
25
  if with_config("debug") or enable_config("debug")
26
26
  $defs.push("-DOSSL_DEBUG")
27
27
  end
28
+ $defs.push("-D""OPENSSL_SUPPRESS_DEPRECATED")
28
29
 
29
- have_func("rb_io_maybe_wait") # Ruby 3.1
30
+ have_func("rb_io_maybe_wait(0, Qnil, Qnil, Qnil)", "ruby/io.h") # Ruby 3.1
30
31
 
31
32
  Logging::message "=== Checking for system dependent stuff... ===\n"
32
33
  have_library("nsl", "t_open")
@@ -120,8 +121,13 @@ if is_libressl && ($mswin || $mingw)
120
121
  end
121
122
 
122
123
  Logging::message "=== Checking for OpenSSL features... ===\n"
124
+ evp_h = "openssl/evp.h".freeze
125
+ x509_h = "openssl/x509.h".freeze
126
+ ts_h = "openssl/ts.h".freeze
127
+ ssl_h = "openssl/ssl.h".freeze
128
+
123
129
  # compile options
124
- have_func("RAND_egd")
130
+ have_func("RAND_egd()", "openssl/rand.h")
125
131
  engines = %w{dynamic 4758cca aep atalla chil
126
132
  cswift nuron sureware ubsec padlock capi gmp gost cryptodev}
127
133
  engines.each { |name|
@@ -132,55 +138,56 @@ engines.each { |name|
132
138
  if !have_struct_member("SSL", "ctx", "openssl/ssl.h") || is_libressl
133
139
  $defs.push("-DHAVE_OPAQUE_OPENSSL")
134
140
  end
135
- have_func("EVP_MD_CTX_new")
136
- have_func("EVP_MD_CTX_free")
137
- have_func("EVP_MD_CTX_pkey_ctx")
138
- have_func("X509_STORE_get_ex_data")
139
- have_func("X509_STORE_set_ex_data")
140
- have_func("X509_STORE_get_ex_new_index")
141
- have_func("X509_CRL_get0_signature")
142
- have_func("X509_REQ_get0_signature")
143
- have_func("X509_REVOKED_get0_serialNumber")
144
- have_func("X509_REVOKED_get0_revocationDate")
145
- have_func("X509_get0_tbs_sigalg")
146
- have_func("X509_STORE_CTX_get0_untrusted")
147
- have_func("X509_STORE_CTX_get0_cert")
148
- have_func("X509_STORE_CTX_get0_chain")
149
- have_func("OCSP_SINGLERESP_get0_id")
150
- have_func("SSL_CTX_get_ciphers")
151
- have_func("X509_up_ref")
152
- have_func("X509_CRL_up_ref")
153
- have_func("X509_STORE_up_ref")
154
- have_func("SSL_SESSION_up_ref")
155
- have_func("EVP_PKEY_up_ref")
156
- have_func("SSL_CTX_set_min_proto_version(NULL, 0)", "openssl/ssl.h")
157
- have_func("SSL_CTX_get_security_level")
158
- have_func("X509_get0_notBefore")
159
- have_func("SSL_SESSION_get_protocol_version")
160
- have_func("TS_STATUS_INFO_get0_status")
161
- have_func("TS_STATUS_INFO_get0_text")
162
- have_func("TS_STATUS_INFO_get0_failure_info")
163
- have_func("TS_VERIFY_CTS_set_certs(NULL, NULL)", "openssl/ts.h")
164
- have_func("TS_VERIFY_CTX_set_store")
165
- have_func("TS_VERIFY_CTX_add_flags")
166
- have_func("TS_RESP_CTX_set_time_cb")
167
- have_func("EVP_PBE_scrypt")
168
- have_func("SSL_CTX_set_post_handshake_auth")
141
+ have_func("EVP_MD_CTX_new()", evp_h)
142
+ have_func("EVP_MD_CTX_free(NULL)", evp_h)
143
+ have_func("EVP_MD_CTX_pkey_ctx(NULL)", evp_h)
144
+ have_func("X509_STORE_get_ex_data(NULL, 0)", x509_h)
145
+ have_func("X509_STORE_set_ex_data(NULL, 0, NULL)", x509_h)
146
+ have_func("X509_STORE_get_ex_new_index(0, NULL, NULL, NULL, NULL)", x509_h)
147
+ have_func("X509_CRL_get0_signature(NULL, NULL, NULL)", x509_h)
148
+ have_func("X509_REQ_get0_signature(NULL, NULL, NULL)", x509_h)
149
+ have_func("X509_REVOKED_get0_serialNumber(NULL)", x509_h)
150
+ have_func("X509_REVOKED_get0_revocationDate(NULL)", x509_h)
151
+ have_func("X509_get0_tbs_sigalg(NULL)", x509_h)
152
+ have_func("X509_STORE_CTX_get0_untrusted(NULL)", x509_h)
153
+ have_func("X509_STORE_CTX_get0_cert(NULL)", x509_h)
154
+ have_func("X509_STORE_CTX_get0_chain(NULL)", x509_h)
155
+ have_func("OCSP_SINGLERESP_get0_id(NULL)", "openssl/ocsp.h")
156
+ have_func("SSL_CTX_get_ciphers(NULL)", ssl_h)
157
+ have_func("X509_up_ref(NULL)", x509_h)
158
+ have_func("X509_CRL_up_ref(NULL)", x509_h)
159
+ have_func("X509_STORE_up_ref(NULL)", x509_h)
160
+ have_func("SSL_SESSION_up_ref(NULL)", ssl_h)
161
+ have_func("EVP_PKEY_up_ref(NULL)", evp_h)
162
+ have_func("SSL_CTX_set_min_proto_version(NULL, 0)", ssl_h)
163
+ have_func("SSL_CTX_get_security_level(NULL)", ssl_h)
164
+ have_func("X509_get0_notBefore(NULL)", x509_h)
165
+ have_func("SSL_SESSION_get_protocol_version(NULL)", ssl_h)
166
+ have_func("TS_STATUS_INFO_get0_status(NULL)", ts_h)
167
+ have_func("TS_STATUS_INFO_get0_text(NULL)", ts_h)
168
+ have_func("TS_STATUS_INFO_get0_failure_info(NULL)", ts_h)
169
+ have_func("TS_VERIFY_CTS_set_certs(NULL, NULL)", ts_h)
170
+ have_func("TS_VERIFY_CTX_set_store(NULL, NULL)", ts_h)
171
+ have_func("TS_VERIFY_CTX_add_flags(NULL, 0)", ts_h)
172
+ have_func("TS_RESP_CTX_set_time_cb(NULL, NULL, NULL)", ts_h)
173
+ have_func("EVP_PBE_scrypt(\"\", 0, (unsigned char *)\"\", 0, 0, 0, 0, 0, NULL, 0)", evp_h)
174
+ have_func("SSL_CTX_set_post_handshake_auth(NULL, 0)", ssl_h)
169
175
 
170
176
  # added in 1.1.1
171
- have_func("EVP_PKEY_check")
172
- have_func("EVP_PKEY_new_raw_private_key")
177
+ have_func("EVP_PKEY_check(NULL)", evp_h)
178
+ have_func("EVP_PKEY_new_raw_private_key(0, NULL, (unsigned char *)\"\", 0)", evp_h)
179
+ have_func("SSL_CTX_set_ciphersuites(NULL, \"\")", ssl_h)
173
180
 
174
181
  # added in 3.0.0
175
- have_func("SSL_set0_tmp_dh_pkey")
176
- have_func("ERR_get_error_all")
177
- have_func("TS_VERIFY_CTX_set_certs(NULL, NULL)", "openssl/ts.h")
178
- have_func("SSL_CTX_load_verify_file")
179
- have_func("BN_check_prime")
180
- have_func("EVP_MD_CTX_get0_md")
181
- have_func("EVP_MD_CTX_get_pkey_ctx")
182
- have_func("EVP_PKEY_eq")
183
- have_func("EVP_PKEY_dup")
182
+ have_func("SSL_set0_tmp_dh_pkey(NULL, NULL)", ssl_h)
183
+ have_func("ERR_get_error_all(NULL, NULL, NULL, NULL, NULL)", "openssl/err.h")
184
+ have_func("TS_VERIFY_CTX_set_certs(NULL, NULL)", ts_h)
185
+ have_func("SSL_CTX_load_verify_file(NULL, \"\")", ssl_h)
186
+ have_func("BN_check_prime(NULL, NULL, NULL)", "openssl/bn.h")
187
+ have_func("EVP_MD_CTX_get0_md(NULL)", evp_h)
188
+ have_func("EVP_MD_CTX_get_pkey_ctx(NULL)", evp_h)
189
+ have_func("EVP_PKEY_eq(NULL, NULL)", evp_h)
190
+ have_func("EVP_PKEY_dup(NULL)", evp_h)
184
191
 
185
192
  Logging::message "=== Checking done. ===\n"
186
193
 
data/ext/openssl/ossl.h CHANGED
@@ -43,13 +43,19 @@
43
43
  #ifndef LIBRESSL_VERSION_NUMBER
44
44
  # define OSSL_IS_LIBRESSL 0
45
45
  # define OSSL_OPENSSL_PREREQ(maj, min, pat) \
46
- (OPENSSL_VERSION_NUMBER >= (maj << 28) | (min << 20) | (pat << 12))
46
+ (OPENSSL_VERSION_NUMBER >= ((maj << 28) | (min << 20) | (pat << 12)))
47
47
  # define OSSL_LIBRESSL_PREREQ(maj, min, pat) 0
48
48
  #else
49
49
  # define OSSL_IS_LIBRESSL 1
50
50
  # define OSSL_OPENSSL_PREREQ(maj, min, pat) 0
51
51
  # define OSSL_LIBRESSL_PREREQ(maj, min, pat) \
52
- (LIBRESSL_VERSION_NUMBER >= (maj << 28) | (min << 20) | (pat << 12))
52
+ (LIBRESSL_VERSION_NUMBER >= ((maj << 28) | (min << 20) | (pat << 12)))
53
+ #endif
54
+
55
+ #if OSSL_OPENSSL_PREREQ(3, 0, 0)
56
+ # define OSSL_3_const const
57
+ #else
58
+ # define OSSL_3_const /* const */
53
59
  #endif
54
60
 
55
61
  #if !defined(OPENSSL_NO_ENGINE) && !OSSL_OPENSSL_PREREQ(3, 0, 0)
@@ -509,7 +509,8 @@ ossl_asn1_get_asn1type(VALUE obj)
509
509
  ASN1_TYPE *ret;
510
510
  VALUE value, rflag;
511
511
  void *ptr;
512
- void (*free_func)();
512
+ typedef void free_func_type(void *);
513
+ free_func_type *free_func;
513
514
  int tag;
514
515
 
515
516
  tag = ossl_asn1_default_tag(obj);
@@ -522,16 +523,16 @@ ossl_asn1_get_asn1type(VALUE obj)
522
523
  case V_ASN1_INTEGER: /* FALLTHROUGH */
523
524
  case V_ASN1_ENUMERATED:
524
525
  ptr = obj_to_asn1int(value);
525
- free_func = ASN1_INTEGER_free;
526
+ free_func = (free_func_type *)ASN1_INTEGER_free;
526
527
  break;
527
528
  case V_ASN1_BIT_STRING:
528
529
  rflag = rb_attr_get(obj, sivUNUSED_BITS);
529
530
  ptr = obj_to_asn1bstr(value, NUM2INT(rflag));
530
- free_func = ASN1_BIT_STRING_free;
531
+ free_func = (free_func_type *)ASN1_BIT_STRING_free;
531
532
  break;
532
533
  case V_ASN1_NULL:
533
534
  ptr = obj_to_asn1null(value);
534
- free_func = ASN1_NULL_free;
535
+ free_func = (free_func_type *)ASN1_NULL_free;
535
536
  break;
536
537
  case V_ASN1_OCTET_STRING: /* FALLTHROUGH */
537
538
  case V_ASN1_UTF8STRING: /* FALLTHROUGH */
@@ -546,24 +547,24 @@ ossl_asn1_get_asn1type(VALUE obj)
546
547
  case V_ASN1_UNIVERSALSTRING: /* FALLTHROUGH */
547
548
  case V_ASN1_BMPSTRING:
548
549
  ptr = obj_to_asn1str(value);
549
- free_func = ASN1_STRING_free;
550
+ free_func = (free_func_type *)ASN1_STRING_free;
550
551
  break;
551
552
  case V_ASN1_OBJECT:
552
553
  ptr = obj_to_asn1obj(value);
553
- free_func = ASN1_OBJECT_free;
554
+ free_func = (free_func_type *)ASN1_OBJECT_free;
554
555
  break;
555
556
  case V_ASN1_UTCTIME:
556
557
  ptr = obj_to_asn1utime(value);
557
- free_func = ASN1_TIME_free;
558
+ free_func = (free_func_type *)ASN1_TIME_free;
558
559
  break;
559
560
  case V_ASN1_GENERALIZEDTIME:
560
561
  ptr = obj_to_asn1gtime(value);
561
- free_func = ASN1_TIME_free;
562
+ free_func = (free_func_type *)ASN1_TIME_free;
562
563
  break;
563
564
  case V_ASN1_SET: /* FALLTHROUGH */
564
565
  case V_ASN1_SEQUENCE:
565
566
  ptr = obj_to_asn1derstr(obj);
566
- free_func = ASN1_STRING_free;
567
+ free_func = (free_func_type *)ASN1_STRING_free;
567
568
  break;
568
569
  default:
569
570
  ossl_raise(eASN1Error, "unsupported ASN.1 type");
@@ -1522,7 +1523,7 @@ Init_ossl_asn1(void)
1522
1523
  *
1523
1524
  * An Array that stores the name of a given tag number. These names are
1524
1525
  * the same as the name of the tag constant that is additionally defined,
1525
- * e.g. +UNIVERSAL_TAG_NAME[2] = "INTEGER"+ and +OpenSSL::ASN1::INTEGER = 2+.
1526
+ * e.g. <tt>UNIVERSAL_TAG_NAME[2] = "INTEGER"</tt> and <tt>OpenSSL::ASN1::INTEGER = 2</tt>.
1526
1527
  *
1527
1528
  * == Example usage
1528
1529
  *
@@ -577,22 +577,33 @@ BIGNUM_2c(gcd)
577
577
  */
578
578
  BIGNUM_2c(mod_sqr)
579
579
 
580
+ #define BIGNUM_2cr(func) \
581
+ static VALUE \
582
+ ossl_bn_##func(VALUE self, VALUE other) \
583
+ { \
584
+ BIGNUM *bn1, *bn2 = GetBNPtr(other), *result; \
585
+ VALUE obj; \
586
+ GetBN(self, bn1); \
587
+ obj = NewBN(rb_obj_class(self)); \
588
+ if (!(result = BN_##func(NULL, bn1, bn2, ossl_bn_ctx))) \
589
+ ossl_raise(eBNError, NULL); \
590
+ SetBN(obj, result); \
591
+ return obj; \
592
+ }
593
+
580
594
  /*
595
+ * Document-method: OpenSSL::BN#mod_sqrt
596
+ * call-seq:
597
+ * bn.mod_sqrt(bn2) => aBN
598
+ */
599
+ BIGNUM_2cr(mod_sqrt)
600
+
601
+ /*
602
+ * Document-method: OpenSSL::BN#mod_inverse
581
603
  * call-seq:
582
604
  * bn.mod_inverse(bn2) => aBN
583
605
  */
584
- static VALUE
585
- ossl_bn_mod_inverse(VALUE self, VALUE other)
586
- {
587
- BIGNUM *bn1, *bn2 = GetBNPtr(other), *result;
588
- VALUE obj;
589
- GetBN(self, bn1);
590
- obj = NewBN(rb_obj_class(self));
591
- if (!(result = BN_mod_inverse(NULL, bn1, bn2, ossl_bn_ctx)))
592
- ossl_raise(eBNError, "BN_mod_inverse");
593
- SetBN(obj, result);
594
- return obj;
595
- }
606
+ BIGNUM_2cr(mod_inverse)
596
607
 
597
608
  /*
598
609
  * call-seq:
@@ -1234,6 +1245,7 @@ Init_ossl_bn(void)
1234
1245
  rb_define_method(cBN, "mod_sub", ossl_bn_mod_sub, 2);
1235
1246
  rb_define_method(cBN, "mod_mul", ossl_bn_mod_mul, 2);
1236
1247
  rb_define_method(cBN, "mod_sqr", ossl_bn_mod_sqr, 1);
1248
+ rb_define_method(cBN, "mod_sqrt", ossl_bn_mod_sqrt, 1);
1237
1249
  rb_define_method(cBN, "**", ossl_bn_exp, 1);
1238
1250
  rb_define_method(cBN, "mod_exp", ossl_bn_mod_exp, 2);
1239
1251
  rb_define_method(cBN, "gcd", ossl_bn_gcd, 1);
@@ -384,8 +384,7 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self)
384
384
 
385
385
  StringValue(data);
386
386
  in = (unsigned char *)RSTRING_PTR(data);
387
- if ((in_len = RSTRING_LEN(data)) == 0)
388
- ossl_raise(rb_eArgError, "data must not be empty");
387
+ in_len = RSTRING_LEN(data);
389
388
  GetCipher(self, ctx);
390
389
  out_len = in_len+EVP_CIPHER_CTX_block_size(ctx);
391
390
  if (out_len <= 0) {
@@ -3,7 +3,7 @@
3
3
  * Copyright (C) 2007, 2017 Ruby/OpenSSL Project Authors
4
4
  */
5
5
  #include "ossl.h"
6
- #if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
6
+ #if OSSL_OPENSSL_PREREQ(1, 1, 0) || OSSL_LIBRESSL_PREREQ(3, 6, 0)
7
7
  # include <openssl/kdf.h>
8
8
  #endif
9
9
 
@@ -141,7 +141,7 @@ kdf_scrypt(int argc, VALUE *argv, VALUE self)
141
141
  }
142
142
  #endif
143
143
 
144
- #if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
144
+ #if OSSL_OPENSSL_PREREQ(1, 1, 0) || OSSL_LIBRESSL_PREREQ(3, 6, 0)
145
145
  /*
146
146
  * call-seq:
147
147
  * KDF.hkdf(ikm, salt:, info:, length:, hash:) -> String
@@ -305,7 +305,7 @@ Init_ossl_kdf(void)
305
305
  #if defined(HAVE_EVP_PBE_SCRYPT)
306
306
  rb_define_module_function(mKDF, "scrypt", kdf_scrypt, -1);
307
307
  #endif
308
- #if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
308
+ #if OSSL_OPENSSL_PREREQ(1, 1, 0) || OSSL_LIBRESSL_PREREQ(3, 6, 0)
309
309
  rb_define_module_function(mKDF, "hkdf", kdf_hkdf, -1);
310
310
  #endif
311
311
  }
@@ -382,7 +382,7 @@ ossl_ocspreq_sign(int argc, VALUE *argv, VALUE self)
382
382
  if (!NIL_P(flags))
383
383
  flg = NUM2INT(flags);
384
384
  if (NIL_P(digest))
385
- md = EVP_sha1();
385
+ md = NULL;
386
386
  else
387
387
  md = ossl_evp_get_digestbyname(digest);
388
388
  if (NIL_P(certs))
@@ -1033,7 +1033,7 @@ ossl_ocspbres_sign(int argc, VALUE *argv, VALUE self)
1033
1033
  if (!NIL_P(flags))
1034
1034
  flg = NUM2INT(flags);
1035
1035
  if (NIL_P(digest))
1036
- md = EVP_sha1();
1036
+ md = NULL;
1037
1037
  else
1038
1038
  md = ossl_evp_get_digestbyname(digest);
1039
1039
  if (NIL_P(certs))
@@ -710,7 +710,7 @@ ossl_pkey_export_traditional(int argc, VALUE *argv, VALUE self, int to_der)
710
710
  }
711
711
  }
712
712
  else {
713
- #if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
713
+ #if OSSL_OPENSSL_PREREQ(1, 1, 0) || OSSL_LIBRESSL_PREREQ(3, 5, 0)
714
714
  if (!PEM_write_bio_PrivateKey_traditional(bio, pkey, enc, NULL, 0,
715
715
  ossl_pem_passwd_cb,
716
716
  (void *)pass)) {
@@ -951,7 +951,7 @@ ossl_pkey_sign(int argc, VALUE *argv, VALUE self)
951
951
  rb_jump_tag(state);
952
952
  }
953
953
  }
954
- #if OPENSSL_VERSION_NUMBER >= 0x10101000 && !defined(LIBRESSL_VERSION_NUMBER)
954
+ #if OSSL_OPENSSL_PREREQ(1, 1, 1) || OSSL_LIBRESSL_PREREQ(3, 4, 0)
955
955
  if (EVP_DigestSign(ctx, NULL, &siglen, (unsigned char *)RSTRING_PTR(data),
956
956
  RSTRING_LEN(data)) < 1) {
957
957
  EVP_MD_CTX_free(ctx);
@@ -1056,7 +1056,7 @@ ossl_pkey_verify(int argc, VALUE *argv, VALUE self)
1056
1056
  rb_jump_tag(state);
1057
1057
  }
1058
1058
  }
1059
- #if OPENSSL_VERSION_NUMBER >= 0x10101000 && !defined(LIBRESSL_VERSION_NUMBER)
1059
+ #if OSSL_OPENSSL_PREREQ(1, 1, 1) || OSSL_LIBRESSL_PREREQ(3, 4, 0)
1060
1060
  ret = EVP_DigestVerify(ctx, (unsigned char *)RSTRING_PTR(sig),
1061
1061
  RSTRING_LEN(sig), (unsigned char *)RSTRING_PTR(data),
1062
1062
  RSTRING_LEN(data));
@@ -92,7 +92,7 @@ void Init_ossl_ec(void);
92
92
  */ \
93
93
  static VALUE ossl_##_keytype##_get_##_name(VALUE self) \
94
94
  { \
95
- _type *obj; \
95
+ const _type *obj; \
96
96
  const BIGNUM *bn; \
97
97
  \
98
98
  Get##_type(self, obj); \
@@ -178,7 +178,7 @@ ossl_dh_initialize_copy(VALUE self, VALUE other)
178
178
  static VALUE
179
179
  ossl_dh_is_public(VALUE self)
180
180
  {
181
- DH *dh;
181
+ OSSL_3_const DH *dh;
182
182
  const BIGNUM *bn;
183
183
 
184
184
  GetDH(self, dh);
@@ -197,14 +197,14 @@ ossl_dh_is_public(VALUE self)
197
197
  static VALUE
198
198
  ossl_dh_is_private(VALUE self)
199
199
  {
200
- DH *dh;
200
+ OSSL_3_const DH *dh;
201
201
  const BIGNUM *bn;
202
202
 
203
203
  GetDH(self, dh);
204
204
  DH_get0_key(dh, NULL, &bn);
205
205
 
206
206
  #if !defined(OPENSSL_NO_ENGINE)
207
- return (bn || DH_get0_engine(dh)) ? Qtrue : Qfalse;
207
+ return (bn || DH_get0_engine((DH *)dh)) ? Qtrue : Qfalse;
208
208
  #else
209
209
  return bn ? Qtrue : Qfalse;
210
210
  #endif
@@ -223,7 +223,7 @@ ossl_dh_is_private(VALUE self)
223
223
  static VALUE
224
224
  ossl_dh_export(VALUE self)
225
225
  {
226
- DH *dh;
226
+ OSSL_3_const DH *dh;
227
227
  BIO *out;
228
228
  VALUE str;
229
229
 
@@ -252,7 +252,7 @@ ossl_dh_export(VALUE self)
252
252
  static VALUE
253
253
  ossl_dh_to_der(VALUE self)
254
254
  {
255
- DH *dh;
255
+ OSSL_3_const DH *dh;
256
256
  unsigned char *p;
257
257
  long len;
258
258
  VALUE str;
@@ -280,7 +280,7 @@ ossl_dh_to_der(VALUE self)
280
280
  static VALUE
281
281
  ossl_dh_get_params(VALUE self)
282
282
  {
283
- DH *dh;
283
+ OSSL_3_const DH *dh;
284
284
  VALUE hash;
285
285
  const BIGNUM *p, *q, *g, *pub_key, *priv_key;
286
286
 
@@ -24,7 +24,7 @@
24
24
  } while (0)
25
25
 
26
26
  static inline int
27
- DSA_HAS_PRIVATE(DSA *dsa)
27
+ DSA_HAS_PRIVATE(OSSL_3_const DSA *dsa)
28
28
  {
29
29
  const BIGNUM *bn;
30
30
  DSA_get0_key(dsa, NULL, &bn);
@@ -32,7 +32,7 @@ DSA_HAS_PRIVATE(DSA *dsa)
32
32
  }
33
33
 
34
34
  static inline int
35
- DSA_PRIVATE(VALUE obj, DSA *dsa)
35
+ DSA_PRIVATE(VALUE obj, OSSL_3_const DSA *dsa)
36
36
  {
37
37
  return DSA_HAS_PRIVATE(dsa) || OSSL_PKEY_IS_PRIVATE(obj);
38
38
  }
@@ -179,7 +179,7 @@ ossl_dsa_initialize_copy(VALUE self, VALUE other)
179
179
  static VALUE
180
180
  ossl_dsa_is_public(VALUE self)
181
181
  {
182
- DSA *dsa;
182
+ const DSA *dsa;
183
183
  const BIGNUM *bn;
184
184
 
185
185
  GetDSA(self, dsa);
@@ -198,7 +198,7 @@ ossl_dsa_is_public(VALUE self)
198
198
  static VALUE
199
199
  ossl_dsa_is_private(VALUE self)
200
200
  {
201
- DSA *dsa;
201
+ OSSL_3_const DSA *dsa;
202
202
 
203
203
  GetDSA(self, dsa);
204
204
 
@@ -225,7 +225,7 @@ ossl_dsa_is_private(VALUE self)
225
225
  static VALUE
226
226
  ossl_dsa_export(int argc, VALUE *argv, VALUE self)
227
227
  {
228
- DSA *dsa;
228
+ OSSL_3_const DSA *dsa;
229
229
 
230
230
  GetDSA(self, dsa);
231
231
  if (DSA_HAS_PRIVATE(dsa))
@@ -244,7 +244,7 @@ ossl_dsa_export(int argc, VALUE *argv, VALUE self)
244
244
  static VALUE
245
245
  ossl_dsa_to_der(VALUE self)
246
246
  {
247
- DSA *dsa;
247
+ OSSL_3_const DSA *dsa;
248
248
 
249
249
  GetDSA(self, dsa);
250
250
  if (DSA_HAS_PRIVATE(dsa))
@@ -265,7 +265,7 @@ ossl_dsa_to_der(VALUE self)
265
265
  static VALUE
266
266
  ossl_dsa_get_params(VALUE self)
267
267
  {
268
- DSA *dsa;
268
+ OSSL_3_const DSA *dsa;
269
269
  VALUE hash;
270
270
  const BIGNUM *p, *q, *g, *pub_key, *priv_key;
271
271