openssl 3.0.0 → 3.0.1

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: d382c0c6e46a7009fa58a8378b052341712f115f73f90c2409fdfa990c5c3a41
4
- data.tar.gz: dc54eb994bb6c4de4e425c32702ec551b5c9d1d677062e629cbf162d171a5dec
3
+ metadata.gz: b75bcd65f8742364f4a513c5ec991648ef6c859b185f2ae87b3eeb1551ab743b
4
+ data.tar.gz: 1e9674192c66fd95a3c201d9afd0d2d755da24ae2847e5abfd68734ba262c811
5
5
  SHA512:
6
- metadata.gz: 8516105c4fb7d40619519c8165d45c602dd6ed65971ad8289ad70e9a7fc89d36c16a801c62ecf7c82e9068f07a3a63df69c3d9faf693796b071c059cdb10f805
7
- data.tar.gz: 5c6cc181f035383b724b6bd5d249e36797c5079482e88efa137e9dc74b0b338fd4be7d6d27d7e39a67054429a64d79305a15146c645ee23c97696f1838640c7a
6
+ metadata.gz: c28bc1d26bb1ae082481d1615d381bd2026b094eae39ddaadbe2791a9bade505bdc0431f19539254f66520feca5b073b675d93c53117b5df880460e029f2641c
7
+ data.tar.gz: b815b33563ece86bc99f7112db593765c8bc32c887511ef5caff77725d64fb3f78e470e1ae4fbec131d04eda464159852aac3373e485d36c47ef32b35f59d99c
data/History.md CHANGED
@@ -1,3 +1,27 @@
1
+ Version 3.0.1
2
+ =============
3
+
4
+ Merged changes in 2.1.4 and 2.2.2. Additionally, the following issues are fixed
5
+ by this release.
6
+
7
+ Bug fixes
8
+ ---------
9
+
10
+ * Add missing type check in OpenSSL::PKey::PKey#sign's optional parameters.
11
+ [[GitHub #531]](https://github.com/ruby/openssl/pull/531)
12
+ * Work around OpenSSL 3.0's HMAC issues with a zero-length key.
13
+ [[GitHub #538]](https://github.com/ruby/openssl/pull/538)
14
+ * Fix a regression in OpenSSL::PKey::DSA.generate's default of 'q' size.
15
+ [[GitHub #483]](https://github.com/ruby/openssl/issues/483)
16
+ [[GitHub #539]](https://github.com/ruby/openssl/pull/539)
17
+ * Restore OpenSSL::PKey.read's ability to decode "openssl ecparam -genkey"
18
+ output when linked against OpenSSL 3.0.
19
+ [[GitHub #535]](https://github.com/ruby/openssl/pull/535)
20
+ [[GitHub #540]](https://github.com/ruby/openssl/pull/540)
21
+ * Restore error checks in OpenSSL::PKey::EC#{to_der,to_pem}.
22
+ [[GitHub #541]](https://github.com/ruby/openssl/pull/541)
23
+
24
+
1
25
  Version 3.0.0
2
26
  =============
3
27
 
@@ -100,6 +124,12 @@ Notable changes
100
124
  [[GitHub #342]](https://github.com/ruby/openssl/issues/342)
101
125
 
102
126
 
127
+ Version 2.2.2
128
+ =============
129
+
130
+ Merged changes in 2.1.4.
131
+
132
+
103
133
  Version 2.2.1
104
134
  =============
105
135
 
@@ -194,6 +224,16 @@ Notable changes
194
224
  [[GitHub #297]](https://github.com/ruby/openssl/pull/297)
195
225
 
196
226
 
227
+ Version 2.1.4
228
+ =============
229
+
230
+ Bug fixes
231
+ ---------
232
+
233
+ * Do not use pkg-config if --with-openssl-dir option is specified.
234
+ [[GitHub #486]](https://github.com/ruby/openssl/pull/486)
235
+
236
+
197
237
  Version 2.1.3
198
238
  =============
199
239
 
@@ -13,7 +13,7 @@
13
13
 
14
14
  require "mkmf"
15
15
 
16
- dir_config("openssl")
16
+ dir_config_given = dir_config("openssl").any?
17
17
  dir_config("kerberos")
18
18
 
19
19
  Logging::message "=== OpenSSL for Ruby configurator ===\n"
@@ -92,7 +92,7 @@ def find_openssl_library
92
92
  end
93
93
 
94
94
  Logging::message "=== Checking for required stuff... ===\n"
95
- pkg_config_found = pkg_config("openssl") && have_header("openssl/ssl.h")
95
+ pkg_config_found = !dir_config_given && pkg_config("openssl") && have_header("openssl/ssl.h")
96
96
 
97
97
  if !pkg_config_found && !find_openssl_library
98
98
  Logging::message "=== Checking for required stuff failed. ===\n"
@@ -169,6 +169,7 @@ have_func("SSL_CTX_set_post_handshake_auth")
169
169
 
170
170
  # added in 1.1.1
171
171
  have_func("EVP_PKEY_check")
172
+ have_func("EVP_PKEY_new_raw_private_key")
172
173
 
173
174
  # added in 3.0.0
174
175
  have_func("SSL_set0_tmp_dh_pkey")
@@ -97,11 +97,19 @@ ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest)
97
97
 
98
98
  GetHMAC(self, ctx);
99
99
  StringValue(key);
100
+ #ifdef HAVE_EVP_PKEY_NEW_RAW_PRIVATE_KEY
101
+ pkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_HMAC, NULL,
102
+ (unsigned char *)RSTRING_PTR(key),
103
+ RSTRING_LENINT(key));
104
+ if (!pkey)
105
+ ossl_raise(eHMACError, "EVP_PKEY_new_raw_private_key");
106
+ #else
100
107
  pkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL,
101
108
  (unsigned char *)RSTRING_PTR(key),
102
109
  RSTRING_LENINT(key));
103
110
  if (!pkey)
104
111
  ossl_raise(eHMACError, "EVP_PKEY_new_mac_key");
112
+ #endif
105
113
  if (EVP_DigestSignInit(ctx, NULL, ossl_evp_get_digestbyname(digest),
106
114
  NULL, pkey) != 1) {
107
115
  EVP_PKEY_free(pkey);
@@ -99,17 +99,56 @@ ossl_pkey_read_generic(BIO *bio, VALUE pass)
99
99
  /* First check DER */
100
100
  if (OSSL_DECODER_from_bio(dctx, bio) == 1)
101
101
  goto out;
102
+ OSSL_BIO_reset(bio);
102
103
 
103
104
  /* Then check PEM; multiple OSSL_DECODER_from_bio() calls may be needed */
104
- OSSL_BIO_reset(bio);
105
105
  if (OSSL_DECODER_CTX_set_input_type(dctx, "PEM") != 1)
106
106
  goto out;
107
- while (OSSL_DECODER_from_bio(dctx, bio) != 1) {
108
- if (BIO_eof(bio))
107
+ /*
108
+ * First check for private key formats. This is to keep compatibility with
109
+ * ruby/openssl < 3.0 which decoded the following as a private key.
110
+ *
111
+ * $ openssl ecparam -name prime256v1 -genkey -outform PEM
112
+ * -----BEGIN EC PARAMETERS-----
113
+ * BggqhkjOPQMBBw==
114
+ * -----END EC PARAMETERS-----
115
+ * -----BEGIN EC PRIVATE KEY-----
116
+ * MHcCAQEEIAG8ugBbA5MHkqnZ9ujQF93OyUfL9tk8sxqM5Wv5tKg5oAoGCCqGSM49
117
+ * AwEHoUQDQgAEVcjhJfkwqh5C7kGuhAf8XaAjVuG5ADwb5ayg/cJijCgs+GcXeedj
118
+ * 86avKpGH84DXUlB23C/kPt+6fXYlitUmXQ==
119
+ * -----END EC PRIVATE KEY-----
120
+ *
121
+ * While the first PEM block is a proper encoding of ECParameters, thus
122
+ * OSSL_DECODER_from_bio() would pick it up, ruby/openssl used to return
123
+ * the latter instead. Existing applications expect this behavior.
124
+ *
125
+ * Note that normally, the input is supposed to contain a single decodable
126
+ * PEM block only, so this special handling should not create a new problem.
127
+ */
128
+ OSSL_DECODER_CTX_set_selection(dctx, EVP_PKEY_KEYPAIR);
129
+ while (1) {
130
+ if (OSSL_DECODER_from_bio(dctx, bio) == 1)
109
131
  goto out;
132
+ if (BIO_eof(bio))
133
+ break;
110
134
  pos2 = BIO_tell(bio);
111
135
  if (pos2 < 0 || pos2 <= pos)
136
+ break;
137
+ ossl_clear_error();
138
+ pos = pos2;
139
+ }
140
+
141
+ OSSL_BIO_reset(bio);
142
+ OSSL_DECODER_CTX_set_selection(dctx, 0);
143
+ while (1) {
144
+ if (OSSL_DECODER_from_bio(dctx, bio) == 1)
112
145
  goto out;
146
+ if (BIO_eof(bio))
147
+ break;
148
+ pos2 = BIO_tell(bio);
149
+ if (pos2 < 0 || pos2 <= pos)
150
+ break;
151
+ ossl_clear_error();
113
152
  pos = pos2;
114
153
  }
115
154
 
@@ -200,6 +239,7 @@ static VALUE
200
239
  pkey_ctx_apply_options0(VALUE args_v)
201
240
  {
202
241
  VALUE *args = (VALUE *)args_v;
242
+ Check_Type(args[1], T_HASH);
203
243
 
204
244
  rb_block_call(args[1], rb_intern("each"), 0, NULL,
205
245
  pkey_ctx_apply_options_i, args[0]);
@@ -414,6 +414,8 @@ ossl_ec_key_export(int argc, VALUE *argv, VALUE self)
414
414
  EC_KEY *ec;
415
415
 
416
416
  GetEC(self, ec);
417
+ if (EC_KEY_get0_public_key(ec) == NULL)
418
+ ossl_raise(eECError, "can't export - no public key set");
417
419
  if (EC_KEY_get0_private_key(ec))
418
420
  return ossl_pkey_export_traditional(argc, argv, self, 0);
419
421
  else
@@ -432,6 +434,8 @@ ossl_ec_key_to_der(VALUE self)
432
434
  EC_KEY *ec;
433
435
 
434
436
  GetEC(self, ec);
437
+ if (EC_KEY_get0_public_key(ec) == NULL)
438
+ ossl_raise(eECError, "can't export - no public key set");
435
439
  if (EC_KEY_get0_private_key(ec))
436
440
  return ossl_pkey_export_traditional(0, NULL, self, 1);
437
441
  else
@@ -642,12 +642,12 @@ ossl_x509_set_extensions(VALUE self, VALUE ary)
642
642
  OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
643
643
  }
644
644
  GetX509(self, x509);
645
- while ((ext = X509_delete_ext(x509, 0)))
646
- X509_EXTENSION_free(ext);
645
+ for (i = X509_get_ext_count(x509); i > 0; i--)
646
+ X509_EXTENSION_free(X509_delete_ext(x509, 0));
647
647
  for (i=0; i<RARRAY_LEN(ary); i++) {
648
648
  ext = GetX509ExtPtr(RARRAY_AREF(ary, i));
649
649
  if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext */
650
- ossl_raise(eX509CertError, NULL);
650
+ ossl_raise(eX509CertError, "X509_add_ext");
651
651
  }
652
652
  }
653
653
 
@@ -474,12 +474,12 @@ ossl_x509crl_set_extensions(VALUE self, VALUE ary)
474
474
  OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
475
475
  }
476
476
  GetX509CRL(self, crl);
477
- while ((ext = X509_CRL_delete_ext(crl, 0)))
478
- X509_EXTENSION_free(ext);
477
+ for (i = X509_CRL_get_ext_count(crl); i > 0; i--)
478
+ X509_EXTENSION_free(X509_CRL_delete_ext(crl, 0));
479
479
  for (i=0; i<RARRAY_LEN(ary); i++) {
480
480
  ext = GetX509ExtPtr(RARRAY_AREF(ary, i)); /* NO NEED TO DUP */
481
481
  if (!X509_CRL_add_ext(crl, ext, -1)) {
482
- ossl_raise(eX509CRLError, NULL);
482
+ ossl_raise(eX509CRLError, "X509_CRL_add_ext");
483
483
  }
484
484
  }
485
485
 
@@ -380,13 +380,13 @@ ossl_x509req_set_attributes(VALUE self, VALUE ary)
380
380
  OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Attr);
381
381
  }
382
382
  GetX509Req(self, req);
383
- while ((attr = X509_REQ_delete_attr(req, 0)))
384
- X509_ATTRIBUTE_free(attr);
383
+ for (i = X509_REQ_get_attr_count(req); i > 0; i--)
384
+ X509_ATTRIBUTE_free(X509_REQ_delete_attr(req, 0));
385
385
  for (i=0;i<RARRAY_LEN(ary); i++) {
386
386
  item = RARRAY_AREF(ary, i);
387
387
  attr = GetX509AttrPtr(item);
388
388
  if (!X509_REQ_add1_attr(req, attr)) {
389
- ossl_raise(eX509ReqError, NULL);
389
+ ossl_raise(eX509ReqError, "X509_REQ_add1_attr");
390
390
  }
391
391
  }
392
392
  return ary;
@@ -223,13 +223,13 @@ ossl_x509revoked_set_extensions(VALUE self, VALUE ary)
223
223
  OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
224
224
  }
225
225
  GetX509Rev(self, rev);
226
- while ((ext = X509_REVOKED_delete_ext(rev, 0)))
227
- X509_EXTENSION_free(ext);
226
+ for (i = X509_REVOKED_get_ext_count(rev); i > 0; i--)
227
+ X509_EXTENSION_free(X509_REVOKED_delete_ext(rev, 0));
228
228
  for (i=0; i<RARRAY_LEN(ary); i++) {
229
229
  item = RARRAY_AREF(ary, i);
230
230
  ext = GetX509ExtPtr(item);
231
231
  if(!X509_REVOKED_add_ext(rev, ext, -1)) {
232
- ossl_raise(eX509RevError, NULL);
232
+ ossl_raise(eX509RevError, "X509_REVOKED_add_ext");
233
233
  }
234
234
  }
235
235
 
data/lib/openssl/pkey.rb CHANGED
@@ -167,8 +167,16 @@ module OpenSSL::PKey
167
167
  # +size+::
168
168
  # The desired key size in bits.
169
169
  def generate(size, &blk)
170
+ # FIPS 186-4 specifies four (L,N) pairs: (1024,160), (2048,224),
171
+ # (2048,256), and (3072,256).
172
+ #
173
+ # q size is derived here with compatibility with
174
+ # DSA_generator_parameters_ex() which previous versions of ruby/openssl
175
+ # used to call.
176
+ qsize = size >= 2048 ? 256 : 160
170
177
  dsaparams = OpenSSL::PKey.generate_parameters("DSA", {
171
178
  "dsa_paramgen_bits" => size,
179
+ "dsa_paramgen_q_bits" => qsize,
172
180
  }, &blk)
173
181
  OpenSSL::PKey.generate_key(dsaparams)
174
182
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenSSL
4
- VERSION = "3.0.0"
4
+ VERSION = "3.0.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openssl
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Bosslet
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2021-12-24 00:00:00.000000000 Z
14
+ date: 2022-09-08 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: It wraps the OpenSSL library.
17
17
  email:
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
- rubygems_version: 3.3.0.dev
120
+ rubygems_version: 3.3.8
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: OpenSSL provides SSL, TLS and general purpose cryptography.