openssl 3.1.0 → 3.1.2

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: 239c530562472710697b8da573b8aa64b477c02f5895907220e83e9f09c88fec
4
- data.tar.gz: 62f2d04df3f693b995bf29be9d299c9f916f44a82b5bc5df60e9f46a748990d8
3
+ metadata.gz: dbe917c45b0e60c1735c892a39e0b4868e596b9ed2ca8cebad6b9ed4aa83ad65
4
+ data.tar.gz: 71d418aea139e127f3dff2034ddf23aa4123b5ff557318830a3cbf6a25ae71dc
5
5
  SHA512:
6
- metadata.gz: 05f891730a9dea150a2cecedb8decbf7f7dbb500cc825226a635fce8ca195a2dbf036de38dbdb7462cbb18e2e3c8aca337c1e1d9d021a94bbc444312dcf26568
7
- data.tar.gz: 4cff09ce02fc107422829ca552c97cf912f2b5f129c87e37137b153fd2c09d9a231493af7ce32f391c32828b3ffc64bf905adf6a1e3fad943e78ca81048a4f96
6
+ metadata.gz: 5301e268ece1b30929810331c436a3946817f3805d2a60eca1f3d112342080db124a5f722c81eb5724a0b7e75890c74bb9bf308a1f73d6103a0169e56ef9147d
7
+ data.tar.gz: 5ac8d51298e646478c15fa41d0f3376a3a261513ad5eaa4c902d428ac92488b824db450e6136a8f88c37d50c8c6a63a850fe418b6d407c8698d03f8a1a3b4b77
data/History.md CHANGED
@@ -1,3 +1,26 @@
1
+ Version 3.1.2
2
+ =============
3
+
4
+ Bug fixes
5
+ ---------
6
+
7
+ * Fix crash when attempting to export an incomplete `OpenSSL::PKey::DSA` key.
8
+ [[GitHub #845]](https://github.com/ruby/openssl/issues/845)
9
+ [[GitHub #847]](https://github.com/ruby/openssl/pull/847)
10
+ * Remove the `OpenSSL::X509::V_FLAG_CRL_CHECK_ALL` flag from the default store
11
+ used by `OpenSSL::SSL::SSLContext#set_params`. It causes certificate
12
+ verification to fail with OpenSSL 3.6.0. It has no effect with any other
13
+ OpenSSL versions.
14
+ [[GitHub #949]](https://github.com/ruby/openssl/issues/949)
15
+ [[GitHub #950]](https://github.com/ruby/openssl/pull/950)
16
+
17
+
18
+ Version 3.1.1
19
+ =============
20
+
21
+ Merged changes in 3.0.3.
22
+
23
+
1
24
  Version 3.1.0
2
25
  =============
3
26
 
@@ -34,6 +57,31 @@ Notable changes
34
57
  LibreSSL 3.6 and Ed25519 support in LibreSSL 3.7.
35
58
 
36
59
 
60
+ Version 3.0.3
61
+ =============
62
+
63
+ Bug fixes
64
+ ---------
65
+
66
+ * Fix a performance regression introduced in v2.1.3 on a buffered write to
67
+ `SSLSocket`.
68
+ [[GitHub #706]](https://github.com/ruby/openssl/pull/706)
69
+ * Fix `OpenSSL::PKCS7` to handle PKCS#7 structures without content.
70
+ [[GitHub #690]](https://github.com/ruby/openssl/pull/690)
71
+ [[GitHub #752]](https://github.com/ruby/openssl/pull/752)
72
+ * Fix `OpenSSL::ASN1::ObjectId#==` with OIDs without a known name.
73
+ [[GitHub #791]](https://github.com/ruby/openssl/issues/791)
74
+ [[GitHub #792]](https://github.com/ruby/openssl/pull/792)
75
+ * Fix `OpenSSL::X509::Certificate#crl_uris` to handle CDP with multiple CRL
76
+ URIs.
77
+ [[GitHub #775]](https://github.com/ruby/openssl/issues/775)
78
+ [[GitHub #776]](https://github.com/ruby/openssl/pull/776)
79
+ * Fix `OpenSSL::Cipher#update` to always make the output buffer `String`
80
+ independent.
81
+ [[Bug #20937]](https://bugs.ruby-lang.org/issues/20937)
82
+ [[GitHub #824]](https://github.com/ruby/openssl/pull/824)
83
+
84
+
37
85
  Version 3.0.2
38
86
  =============
39
87
 
@@ -1298,30 +1298,6 @@ ossl_asn1obj_get_ln(VALUE self)
1298
1298
  return ret;
1299
1299
  }
1300
1300
 
1301
- /*
1302
- * call-seq:
1303
- * oid == other_oid => true or false
1304
- *
1305
- * Returns +true+ if _other_oid_ is the same as _oid_
1306
- */
1307
- static VALUE
1308
- ossl_asn1obj_eq(VALUE self, VALUE other)
1309
- {
1310
- VALUE valSelf, valOther;
1311
- int nidSelf, nidOther;
1312
-
1313
- valSelf = ossl_asn1_get_value(self);
1314
- valOther = ossl_asn1_get_value(other);
1315
-
1316
- if ((nidSelf = OBJ_txt2nid(StringValueCStr(valSelf))) == NID_undef)
1317
- ossl_raise(eASN1Error, "OBJ_txt2nid");
1318
-
1319
- if ((nidOther = OBJ_txt2nid(StringValueCStr(valOther))) == NID_undef)
1320
- ossl_raise(eASN1Error, "OBJ_txt2nid");
1321
-
1322
- return nidSelf == nidOther ? Qtrue : Qfalse;
1323
- }
1324
-
1325
1301
  static VALUE
1326
1302
  asn1obj_get_oid_i(VALUE vobj)
1327
1303
  {
@@ -1366,6 +1342,25 @@ ossl_asn1obj_get_oid(VALUE self)
1366
1342
  return str;
1367
1343
  }
1368
1344
 
1345
+ /*
1346
+ * call-seq:
1347
+ * oid == other_oid => true or false
1348
+ *
1349
+ * Returns +true+ if _other_oid_ is the same as _oid_.
1350
+ */
1351
+ static VALUE
1352
+ ossl_asn1obj_eq(VALUE self, VALUE other)
1353
+ {
1354
+ VALUE oid1, oid2;
1355
+
1356
+ if (!rb_obj_is_kind_of(other, cASN1ObjectId))
1357
+ return Qfalse;
1358
+
1359
+ oid1 = ossl_asn1obj_get_oid(self);
1360
+ oid2 = ossl_asn1obj_get_oid(other);
1361
+ return rb_str_equal(oid1, oid2);
1362
+ }
1363
+
1369
1364
  #define OSSL_ASN1_IMPL_FACTORY_METHOD(klass) \
1370
1365
  static VALUE ossl_asn1_##klass(int argc, VALUE *argv, VALUE self)\
1371
1366
  { return rb_funcall3(cASN1##klass, rb_intern("new"), argc, argv); }
@@ -386,22 +386,37 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self)
386
386
  in = (unsigned char *)RSTRING_PTR(data);
387
387
  in_len = RSTRING_LEN(data);
388
388
  GetCipher(self, ctx);
389
- out_len = in_len+EVP_CIPHER_CTX_block_size(ctx);
390
- if (out_len <= 0) {
389
+
390
+ /*
391
+ * As of OpenSSL 3.2, there is no reliable way to determine the required
392
+ * output buffer size for arbitrary cipher modes.
393
+ * https://github.com/openssl/openssl/issues/22628
394
+ *
395
+ * in_len+block_size is usually sufficient, but AES key wrap with padding
396
+ * ciphers require in_len+15 even though they have a block size of 8 bytes.
397
+ *
398
+ * Using EVP_MAX_BLOCK_LENGTH (32) as a safe upper bound for ciphers
399
+ * currently implemented in OpenSSL, but this can change in the future.
400
+ */
401
+ if (in_len > LONG_MAX - EVP_MAX_BLOCK_LENGTH) {
391
402
  ossl_raise(rb_eRangeError,
392
403
  "data too big to make output buffer: %ld bytes", in_len);
393
404
  }
405
+ out_len = in_len + EVP_MAX_BLOCK_LENGTH;
394
406
 
395
407
  if (NIL_P(str)) {
396
408
  str = rb_str_new(0, out_len);
397
409
  } else {
398
410
  StringValue(str);
399
- rb_str_resize(str, out_len);
411
+ if ((long)rb_str_capacity(str) >= out_len)
412
+ rb_str_modify(str);
413
+ else
414
+ rb_str_modify_expand(str, out_len - RSTRING_LEN(str));
400
415
  }
401
416
 
402
417
  if (!ossl_cipher_update_long(ctx, (unsigned char *)RSTRING_PTR(str), &out_len, in, in_len))
403
418
  ossl_raise(eCipherError, NULL);
404
- assert(out_len < RSTRING_LEN(str));
419
+ assert(out_len <= RSTRING_LEN(str));
405
420
  rb_str_set_len(str, out_len);
406
421
 
407
422
  return str;
@@ -232,6 +232,7 @@ ossl_digest_finish(int argc, VALUE *argv, VALUE self)
232
232
  str = rb_str_new(NULL, out_len);
233
233
  } else {
234
234
  StringValue(str);
235
+ rb_str_modify(str);
235
236
  rb_str_resize(str, out_len);
236
237
  }
237
238
 
@@ -165,7 +165,13 @@ ossl_pkcs7_s_read_smime(VALUE klass, VALUE arg)
165
165
  out = NULL;
166
166
  pkcs7 = SMIME_read_PKCS7(in, &out);
167
167
  BIO_free(in);
168
- if(!pkcs7) ossl_raise(ePKCS7Error, NULL);
168
+ if (!pkcs7)
169
+ ossl_raise(ePKCS7Error, "Could not parse the PKCS7");
170
+ if (!pkcs7->d.ptr) {
171
+ PKCS7_free(pkcs7);
172
+ ossl_raise(ePKCS7Error, "No content in PKCS7");
173
+ }
174
+
169
175
  data = out ? ossl_membio2str(out) : Qnil;
170
176
  SetPKCS7(ret, pkcs7);
171
177
  ossl_pkcs7_set_data(ret, data);
@@ -346,6 +352,10 @@ ossl_pkcs7_initialize(int argc, VALUE *argv, VALUE self)
346
352
  BIO_free(in);
347
353
  if (!p7)
348
354
  ossl_raise(rb_eArgError, "Could not parse the PKCS7");
355
+ if (!p7->d.ptr) {
356
+ PKCS7_free(p7);
357
+ ossl_raise(rb_eArgError, "No content in PKCS7");
358
+ }
349
359
 
350
360
  RTYPEDDATA_DATA(self) = p7;
351
361
  PKCS7_free(p7_orig);
@@ -807,6 +807,7 @@ ossl_pkey_export_spki(VALUE self, int to_der)
807
807
  BIO *bio;
808
808
 
809
809
  GetPKey(self, pkey);
810
+ ossl_pkey_check_public_key(pkey);
810
811
  bio = BIO_new(BIO_s_mem());
811
812
  if (!bio)
812
813
  ossl_raise(ePKeyError, "BIO_new");
@@ -483,7 +483,7 @@ static VALUE ossl_ec_key_check_key(VALUE self)
483
483
  #ifdef HAVE_EVP_PKEY_CHECK
484
484
  EVP_PKEY *pkey;
485
485
  EVP_PKEY_CTX *pctx;
486
- EC_KEY *ec;
486
+ const EC_KEY *ec;
487
487
 
488
488
  GetPKey(self, pkey);
489
489
  GetEC(self, ec);
@@ -348,13 +348,18 @@ module OpenSSL::Buffering
348
348
  @wbuffer << s
349
349
  @wbuffer.force_encoding(Encoding::BINARY)
350
350
  @sync ||= false
351
- if @sync or @wbuffer.size > BLOCK_SIZE
352
- until @wbuffer.empty?
353
- begin
354
- nwrote = syswrite(@wbuffer)
355
- rescue Errno::EAGAIN
356
- retry
351
+ buffer_size = @wbuffer.size
352
+ if @sync or buffer_size > BLOCK_SIZE
353
+ nwrote = 0
354
+ begin
355
+ while nwrote < buffer_size do
356
+ begin
357
+ nwrote += syswrite(@wbuffer[nwrote, buffer_size - nwrote])
358
+ rescue Errno::EAGAIN
359
+ retry
360
+ end
357
361
  end
362
+ ensure
358
363
  @wbuffer[0, nwrote] = ""
359
364
  end
360
365
  end
data/lib/openssl/ssl.rb CHANGED
@@ -92,7 +92,6 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
92
92
 
93
93
  DEFAULT_CERT_STORE = OpenSSL::X509::Store.new # :nodoc:
94
94
  DEFAULT_CERT_STORE.set_default_paths
95
- DEFAULT_CERT_STORE.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL
96
95
 
97
96
  # A callback invoked when DH parameters are required for ephemeral DH key
98
97
  # exchange.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenSSL
4
- VERSION = "3.1.0"
4
+ VERSION = "3.1.2"
5
5
  end
data/lib/openssl/x509.rb CHANGED
@@ -122,8 +122,8 @@ module OpenSSL
122
122
  include Helpers
123
123
 
124
124
  # Get the distributionPoint fullName URI from the certificate's CRL
125
- # distribution points extension, as described in RFC5280 Section
126
- # 4.2.1.13
125
+ # distribution points extension, as described in RFC 5280 Section
126
+ # 4.2.1.13.
127
127
  #
128
128
  # Returns an array of strings or nil or raises ASN1::ASN1Error.
129
129
  def crl_uris
@@ -135,19 +135,19 @@ module OpenSSL
135
135
  raise ASN1::ASN1Error, "invalid extension"
136
136
  end
137
137
 
138
- crl_uris = cdp_asn1.map do |crl_distribution_point|
138
+ crl_uris = cdp_asn1.flat_map do |crl_distribution_point|
139
139
  distribution_point = crl_distribution_point.value.find do |v|
140
140
  v.tag_class == :CONTEXT_SPECIFIC && v.tag == 0
141
141
  end
142
142
  full_name = distribution_point&.value&.find do |v|
143
143
  v.tag_class == :CONTEXT_SPECIFIC && v.tag == 0
144
144
  end
145
- full_name&.value&.find do |v|
145
+ full_name&.value&.select do |v|
146
146
  v.tag_class == :CONTEXT_SPECIFIC && v.tag == 6 # uniformResourceIdentifier
147
147
  end
148
148
  end
149
149
 
150
- crl_uris&.map(&:value)
150
+ crl_uris.empty? ? nil : crl_uris.map(&:value)
151
151
  end
152
152
  end
153
153
 
metadata CHANGED
@@ -1,17 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openssl
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Bosslet
8
8
  - SHIBATA Hiroshi
9
9
  - Zachary Scott
10
10
  - Kazuki Yamaguchi
11
- autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2022-12-23 00:00:00.000000000 Z
13
+ date: 1980-01-02 00:00:00.000000000 Z
15
14
  dependencies: []
16
15
  description: It wraps the OpenSSL library.
17
16
  email:
@@ -100,7 +99,6 @@ licenses:
100
99
  - Ruby
101
100
  metadata:
102
101
  msys2_mingw_dependencies: openssl
103
- post_install_message:
104
102
  rdoc_options:
105
103
  - "--main"
106
104
  - README.md
@@ -117,8 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
115
  - !ruby/object:Gem::Version
118
116
  version: '0'
119
117
  requirements: []
120
- rubygems_version: 3.4.0.dev
121
- signing_key:
118
+ rubygems_version: 3.8.0.dev
122
119
  specification_version: 4
123
120
  summary: OpenSSL provides SSL, TLS and general purpose cryptography.
124
121
  test_files: []