openssl 3.1.0 → 3.1.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: 239c530562472710697b8da573b8aa64b477c02f5895907220e83e9f09c88fec
4
- data.tar.gz: 62f2d04df3f693b995bf29be9d299c9f916f44a82b5bc5df60e9f46a748990d8
3
+ metadata.gz: 65d16dc88820644059bc2773d3f9ea9511324aa07822a31b2bdf1dfd2306224f
4
+ data.tar.gz: bbd4cdeec2d76994294061804456942b9528d86352375b8d2c4dfea171287ec5
5
5
  SHA512:
6
- metadata.gz: 05f891730a9dea150a2cecedb8decbf7f7dbb500cc825226a635fce8ca195a2dbf036de38dbdb7462cbb18e2e3c8aca337c1e1d9d021a94bbc444312dcf26568
7
- data.tar.gz: 4cff09ce02fc107422829ca552c97cf912f2b5f129c87e37137b153fd2c09d9a231493af7ce32f391c32828b3ffc64bf905adf6a1e3fad943e78ca81048a4f96
6
+ metadata.gz: 3b7477f09b389f6ed8ffc24c5adb43cfe9a19ba2ee6293adc5e1d08199ea3a9365c4006705c4a4c2935e251e6e720af699786f0eda6cebc7fa2ec9826eb1dbcb
7
+ data.tar.gz: 765705e0e698d843b3a2809e957542c76dc414208a762ad58fdfdb6ed9f6400c39c797b0cdc7ad6173fd1d12b4b7c16a448e0a0445fec4efbf190a27318e4340
data/History.md CHANGED
@@ -1,3 +1,9 @@
1
+ Version 3.1.1
2
+ =============
3
+
4
+ Merged changes in 3.0.3.
5
+
6
+
1
7
  Version 3.1.0
2
8
  =============
3
9
 
@@ -34,6 +40,31 @@ Notable changes
34
40
  LibreSSL 3.6 and Ed25519 support in LibreSSL 3.7.
35
41
 
36
42
 
43
+ Version 3.0.3
44
+ =============
45
+
46
+ Bug fixes
47
+ ---------
48
+
49
+ * Fix a performance regression introduced in v2.1.3 on a buffered write to
50
+ `SSLSocket`.
51
+ [[GitHub #706]](https://github.com/ruby/openssl/pull/706)
52
+ * Fix `OpenSSL::PKCS7` to handle PKCS#7 structures without content.
53
+ [[GitHub #690]](https://github.com/ruby/openssl/pull/690)
54
+ [[GitHub #752]](https://github.com/ruby/openssl/pull/752)
55
+ * Fix `OpenSSL::ASN1::ObjectId#==` with OIDs without a known name.
56
+ [[GitHub #791]](https://github.com/ruby/openssl/issues/791)
57
+ [[GitHub #792]](https://github.com/ruby/openssl/pull/792)
58
+ * Fix `OpenSSL::X509::Certificate#crl_uris` to handle CDP with multiple CRL
59
+ URIs.
60
+ [[GitHub #775]](https://github.com/ruby/openssl/issues/775)
61
+ [[GitHub #776]](https://github.com/ruby/openssl/pull/776)
62
+ * Fix `OpenSSL::Cipher#update` to always make the output buffer `String`
63
+ independent.
64
+ [[Bug #20937]](https://bugs.ruby-lang.org/issues/20937)
65
+ [[GitHub #824]](https://github.com/ruby/openssl/pull/824)
66
+
67
+
37
68
  Version 3.0.2
38
69
  =============
39
70
 
@@ -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);
@@ -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
@@ -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.1"
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,17 @@
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.1
5
5
  platform: ruby
6
+ original_platform: ''
6
7
  authors:
7
8
  - Martin Bosslet
8
9
  - SHIBATA Hiroshi
9
10
  - Zachary Scott
10
11
  - Kazuki Yamaguchi
11
- autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2022-12-23 00:00:00.000000000 Z
14
+ date: 2024-12-18 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: It wraps the OpenSSL library.
17
17
  email:
@@ -100,7 +100,6 @@ licenses:
100
100
  - Ruby
101
101
  metadata:
102
102
  msys2_mingw_dependencies: openssl
103
- post_install_message:
104
103
  rdoc_options:
105
104
  - "--main"
106
105
  - README.md
@@ -117,8 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
116
  - !ruby/object:Gem::Version
118
117
  version: '0'
119
118
  requirements: []
120
- rubygems_version: 3.4.0.dev
121
- signing_key:
119
+ rubygems_version: 3.6.1
122
120
  specification_version: 4
123
121
  summary: OpenSSL provides SSL, TLS and general purpose cryptography.
124
122
  test_files: []