openssl 3.2.0 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5040b959a35f5692d6d19e2bf520e1123da8133fff2f878cfc21c2ff0f145d6e
4
- data.tar.gz: dfee6ebd76e423511aa0fc4630f8120edce8fe79d4f40ee7105ccad12c2d3340
3
+ metadata.gz: d768799eb4f3fb6e1ec8937cdf77c3ab5c5a3c453a8ea38e8886b0c96eb85778
4
+ data.tar.gz: 7e36f7e488cce83fbeae8cea19bb5cc817a10759243c5ce9345a65e0837ba7ca
5
5
  SHA512:
6
- metadata.gz: f542ec360be844382829f4bcc46b5cffdfcaf675b02ecdc1cd15a6e80c061476ee4582fdb201ef2dd0f430806d74036233eef3a5c23e5b4028560ad075ed706b
7
- data.tar.gz: 0173033ebe6efb76b747cc80835cc9530dd664d038256bbdf963d4940b5f3bfad90be313554f548a911ac0977d4bdc33c088dfd3b6fb8e46db7bcd5d2ec34a8c
6
+ metadata.gz: 69dcd674d157588140b6ef64f3996a4a7a0847ddd713550752ac509310430fe5b9463c532c69538cbdc136bcbe934d6e2670a6bd4e2f91283cff18ddd5bf2eb3
7
+ data.tar.gz: 5583751022390d99a99b2179113acd5589366ecc407b50c3a0833ba2873ba3d3037a05644e02ffffb507ea4c3852e90c9f9507a8f65188c96034ed36533e2213
data/History.md CHANGED
@@ -1,3 +1,9 @@
1
+ Version 3.2.1
2
+ =============
3
+
4
+ Merged changes in 3.0.3.
5
+
6
+
1
7
  Version 3.2.0
2
8
  =============
3
9
 
@@ -38,6 +44,12 @@ Notable changes
38
44
  [[GitHub #141]](https://github.com/ruby/openssl/pull/141)
39
45
 
40
46
 
47
+ Version 3.1.1
48
+ =============
49
+
50
+ Merged changes in 3.0.3.
51
+
52
+
41
53
  Version 3.1.0
42
54
  =============
43
55
 
@@ -74,6 +86,31 @@ Notable changes
74
86
  LibreSSL 3.6 and Ed25519 support in LibreSSL 3.7.
75
87
 
76
88
 
89
+ Version 3.0.3
90
+ =============
91
+
92
+ Bug fixes
93
+ ---------
94
+
95
+ * Fix a performance regression introduced in v2.1.3 on a buffered write to
96
+ `SSLSocket`.
97
+ [[GitHub #706]](https://github.com/ruby/openssl/pull/706)
98
+ * Fix `OpenSSL::PKCS7` to handle PKCS#7 structures without content.
99
+ [[GitHub #690]](https://github.com/ruby/openssl/pull/690)
100
+ [[GitHub #752]](https://github.com/ruby/openssl/pull/752)
101
+ * Fix `OpenSSL::ASN1::ObjectId#==` with OIDs without a known name.
102
+ [[GitHub #791]](https://github.com/ruby/openssl/issues/791)
103
+ [[GitHub #792]](https://github.com/ruby/openssl/pull/792)
104
+ * Fix `OpenSSL::X509::Certificate#crl_uris` to handle CDP with multiple CRL
105
+ URIs.
106
+ [[GitHub #775]](https://github.com/ruby/openssl/issues/775)
107
+ [[GitHub #776]](https://github.com/ruby/openssl/pull/776)
108
+ * Fix `OpenSSL::Cipher#update` to always make the output buffer `String`
109
+ independent.
110
+ [[Bug #20937]](https://bugs.ruby-lang.org/issues/20937)
111
+ [[GitHub #824]](https://github.com/ruby/openssl/pull/824)
112
+
113
+
77
114
  Version 3.0.2
78
115
  =============
79
116
 
@@ -457,7 +494,7 @@ Security fixes
457
494
  Bug fixes
458
495
  ---------
459
496
 
460
- * Fixed OpenSSL::PKey::*.{new,generate} immediately aborting if the thread is
497
+ * Fixed OpenSSL::PKey::\*.{new,generate} immediately aborting if the thread is
461
498
  interrupted.
462
499
  [[Bug #14882]](https://bugs.ruby-lang.org/issues/14882)
463
500
  [[GitHub #205]](https://github.com/ruby/openssl/pull/205)
@@ -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);
@@ -345,13 +345,18 @@ module OpenSSL::Buffering
345
345
  @wbuffer << s
346
346
  @wbuffer.force_encoding(Encoding::BINARY)
347
347
  @sync ||= false
348
- if @sync or @wbuffer.size > BLOCK_SIZE
349
- until @wbuffer.empty?
350
- begin
351
- nwrote = syswrite(@wbuffer)
352
- rescue Errno::EAGAIN
353
- retry
348
+ buffer_size = @wbuffer.size
349
+ if @sync or buffer_size > BLOCK_SIZE
350
+ nwrote = 0
351
+ begin
352
+ while nwrote < buffer_size do
353
+ begin
354
+ nwrote += syswrite(@wbuffer[nwrote, buffer_size - nwrote])
355
+ rescue Errno::EAGAIN
356
+ retry
357
+ end
354
358
  end
359
+ ensure
355
360
  @wbuffer[0, nwrote] = ""
356
361
  end
357
362
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenSSL
4
- VERSION = "3.2.0"
4
+ VERSION = "3.2.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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openssl
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.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: 2023-09-21 00:00:00.000000000 Z
14
+ date: 2024-12-18 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: OpenSSL for Ruby provides access to SSL/TLS and general-purpose cryptography
17
17
  based on the OpenSSL library.
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubygems_version: 3.4.10
123
+ rubygems_version: 3.5.22
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: SSL/TLS and general-purpose cryptography for Ruby