openssl 3.2.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +180 -29
  3. data/History.md +76 -0
  4. data/README.md +11 -7
  5. data/ext/openssl/extconf.rb +7 -9
  6. data/ext/openssl/openssl_missing.c +1 -1
  7. data/ext/openssl/openssl_missing.h +1 -1
  8. data/ext/openssl/ossl.c +7 -9
  9. data/ext/openssl/ossl.h +12 -8
  10. data/ext/openssl/ossl_asn1.c +46 -237
  11. data/ext/openssl/ossl_asn1.h +1 -19
  12. data/ext/openssl/ossl_bio.c +1 -1
  13. data/ext/openssl/ossl_bio.h +1 -1
  14. data/ext/openssl/ossl_bn.c +12 -12
  15. data/ext/openssl/ossl_bn.h +1 -2
  16. data/ext/openssl/ossl_cipher.c +5 -5
  17. data/ext/openssl/ossl_cipher.h +1 -4
  18. data/ext/openssl/ossl_config.c +10 -9
  19. data/ext/openssl/ossl_config.h +1 -1
  20. data/ext/openssl/ossl_digest.c +39 -21
  21. data/ext/openssl/ossl_digest.h +1 -4
  22. data/ext/openssl/ossl_engine.c +3 -3
  23. data/ext/openssl/ossl_engine.h +1 -4
  24. data/ext/openssl/ossl_hmac.c +3 -3
  25. data/ext/openssl/ossl_hmac.h +1 -4
  26. data/ext/openssl/ossl_kdf.c +5 -5
  27. data/ext/openssl/ossl_ns_spki.c +8 -8
  28. data/ext/openssl/ossl_ns_spki.h +1 -5
  29. data/ext/openssl/ossl_ocsp.c +8 -8
  30. data/ext/openssl/ossl_ocsp.h +1 -8
  31. data/ext/openssl/ossl_pkcs12.c +54 -3
  32. data/ext/openssl/ossl_pkcs12.h +1 -4
  33. data/ext/openssl/ossl_pkcs7.c +68 -21
  34. data/ext/openssl/ossl_pkcs7.h +2 -22
  35. data/ext/openssl/ossl_pkey.c +1 -1
  36. data/ext/openssl/ossl_pkey.h +3 -14
  37. data/ext/openssl/ossl_pkey_dh.c +2 -2
  38. data/ext/openssl/ossl_pkey_dsa.c +2 -2
  39. data/ext/openssl/ossl_pkey_ec.c +6 -6
  40. data/ext/openssl/ossl_pkey_rsa.c +2 -2
  41. data/ext/openssl/ossl_provider.c +1 -1
  42. data/ext/openssl/ossl_rand.c +3 -3
  43. data/ext/openssl/ossl_rand.h +1 -4
  44. data/ext/openssl/ossl_ssl.c +71 -52
  45. data/ext/openssl/ossl_ssl.h +1 -1
  46. data/ext/openssl/ossl_ts.c +73 -15
  47. data/ext/openssl/ossl_ts.h +1 -1
  48. data/ext/openssl/ossl_x509.c +1 -1
  49. data/ext/openssl/ossl_x509.h +1 -20
  50. data/ext/openssl/ossl_x509attr.c +25 -26
  51. data/ext/openssl/ossl_x509cert.c +42 -3
  52. data/ext/openssl/ossl_x509crl.c +8 -4
  53. data/ext/openssl/ossl_x509ext.c +3 -3
  54. data/ext/openssl/ossl_x509name.c +3 -3
  55. data/ext/openssl/ossl_x509req.c +8 -4
  56. data/ext/openssl/ossl_x509revoked.c +2 -2
  57. data/ext/openssl/ossl_x509store.c +16 -11
  58. data/lib/openssl/asn1.rb +188 -0
  59. data/lib/openssl/bn.rb +1 -1
  60. data/lib/openssl/buffering.rb +13 -3
  61. data/lib/openssl/cipher.rb +1 -1
  62. data/lib/openssl/digest.rb +1 -1
  63. data/lib/openssl/marshal.rb +1 -1
  64. data/lib/openssl/ssl.rb +67 -4
  65. data/lib/openssl/version.rb +1 -1
  66. data/lib/openssl/x509.rb +1 -1
  67. data/lib/openssl.rb +2 -1
  68. metadata +5 -3
  69. /data/{LICENSE.txt → COPYING} +0 -0
@@ -0,0 +1,188 @@
1
+ # frozen_string_literal: true
2
+ #--
3
+ #
4
+ # = Ruby-space definitions that completes C-space funcs for ASN.1
5
+ #
6
+ # = Licence
7
+ # This program is licensed under the same licence as Ruby.
8
+ # (See the file 'COPYING'.)
9
+ #++
10
+
11
+ module OpenSSL
12
+ module ASN1
13
+ class ASN1Data
14
+ #
15
+ # Carries the value of a ASN.1 type.
16
+ # Please confer Constructive and Primitive for the mappings between
17
+ # ASN.1 data types and Ruby classes.
18
+ #
19
+ attr_accessor :value
20
+
21
+ # An Integer representing the tag number of this ASN1Data. Never +nil+.
22
+ attr_accessor :tag
23
+
24
+ # A Symbol representing the tag class of this ASN1Data. Never +nil+.
25
+ # See ASN1Data for possible values.
26
+ attr_accessor :tag_class
27
+
28
+ #
29
+ # Never +nil+. A boolean value indicating whether the encoding uses
30
+ # indefinite length (in the case of parsing) or whether an indefinite
31
+ # length form shall be used (in the encoding case).
32
+ # In DER, every value uses definite length form. But in scenarios where
33
+ # large amounts of data need to be transferred it might be desirable to
34
+ # have some kind of streaming support available.
35
+ # For example, huge OCTET STRINGs are preferably sent in smaller-sized
36
+ # chunks, each at a time.
37
+ # This is possible in BER by setting the length bytes of an encoding
38
+ # to zero and by this indicating that the following value will be
39
+ # sent in chunks. Indefinite length encodings are always constructed.
40
+ # The end of such a stream of chunks is indicated by sending a EOC
41
+ # (End of Content) tag. SETs and SEQUENCEs may use an indefinite length
42
+ # encoding, but also primitive types such as e.g. OCTET STRINGS or
43
+ # BIT STRINGS may leverage this functionality (cf. ITU-T X.690).
44
+ #
45
+ attr_accessor :indefinite_length
46
+
47
+ alias infinite_length indefinite_length
48
+ alias infinite_length= indefinite_length=
49
+
50
+ #
51
+ # :call-seq:
52
+ # OpenSSL::ASN1::ASN1Data.new(value, tag, tag_class) => ASN1Data
53
+ #
54
+ # _value_: Please have a look at Constructive and Primitive to see how Ruby
55
+ # types are mapped to ASN.1 types and vice versa.
56
+ #
57
+ # _tag_: An Integer indicating the tag number.
58
+ #
59
+ # _tag_class_: A Symbol indicating the tag class. Please cf. ASN1 for
60
+ # possible values.
61
+ #
62
+ # == Example
63
+ # asn1_int = OpenSSL::ASN1Data.new(42, 2, :UNIVERSAL) # => Same as OpenSSL::ASN1::Integer.new(42)
64
+ # tagged_int = OpenSSL::ASN1Data.new(42, 0, :CONTEXT_SPECIFIC) # implicitly 0-tagged INTEGER
65
+ #
66
+ def initialize(value, tag, tag_class)
67
+ raise ASN1Error, "invalid tag class" unless tag_class.is_a?(Symbol)
68
+
69
+ @tag = tag
70
+ @value = value
71
+ @tag_class = tag_class
72
+ @indefinite_length = false
73
+ end
74
+ end
75
+
76
+ module TaggedASN1Data
77
+ #
78
+ # May be used as a hint for encoding a value either implicitly or
79
+ # explicitly by setting it either to +:IMPLICIT+ or to +:EXPLICIT+.
80
+ # _tagging_ is not set when a ASN.1 structure is parsed using
81
+ # OpenSSL::ASN1.decode.
82
+ #
83
+ attr_accessor :tagging
84
+
85
+ # :call-seq:
86
+ # OpenSSL::ASN1::Primitive.new(value [, tag, tagging, tag_class ]) => Primitive
87
+ #
88
+ # _value_: is mandatory.
89
+ #
90
+ # _tag_: optional, may be specified for tagged values. If no _tag_ is
91
+ # specified, the UNIVERSAL tag corresponding to the Primitive sub-class
92
+ # is used by default.
93
+ #
94
+ # _tagging_: may be used as an encoding hint to encode a value either
95
+ # explicitly or implicitly, see ASN1 for possible values.
96
+ #
97
+ # _tag_class_: if _tag_ and _tagging_ are +nil+ then this is set to
98
+ # +:UNIVERSAL+ by default. If either _tag_ or _tagging_ are set then
99
+ # +:CONTEXT_SPECIFIC+ is used as the default. For possible values please
100
+ # cf. ASN1.
101
+ #
102
+ # == Example
103
+ # int = OpenSSL::ASN1::Integer.new(42)
104
+ # zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :IMPLICIT)
105
+ # private_explicit_zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :EXPLICIT, :PRIVATE)
106
+ #
107
+ def initialize(value, tag = nil, tagging = nil, tag_class = nil)
108
+ tag ||= ASN1.take_default_tag(self.class)
109
+
110
+ raise ASN1Error, "must specify tag number" unless tag
111
+
112
+ if tagging
113
+ raise ASN1Error, "invalid tagging method" unless tagging.is_a?(Symbol)
114
+ end
115
+
116
+ tag_class ||= tagging ? :CONTEXT_SPECIFIC : :UNIVERSAL
117
+
118
+ raise ASN1Error, "invalid tag class" unless tag_class.is_a?(Symbol)
119
+
120
+ @tagging = tagging
121
+ super(value ,tag, tag_class)
122
+ end
123
+ end
124
+
125
+ class Primitive < ASN1Data
126
+ include TaggedASN1Data
127
+
128
+ undef_method :indefinite_length=
129
+ undef_method :infinite_length=
130
+ end
131
+
132
+ class Constructive < ASN1Data
133
+ include TaggedASN1Data
134
+ include Enumerable
135
+
136
+ # :call-seq:
137
+ # asn1_ary.each { |asn1| block } => asn1_ary
138
+ #
139
+ # Calls the given block once for each element in self, passing that element
140
+ # as parameter _asn1_. If no block is given, an enumerator is returned
141
+ # instead.
142
+ #
143
+ # == Example
144
+ # asn1_ary.each do |asn1|
145
+ # puts asn1
146
+ # end
147
+ #
148
+ def each(&blk)
149
+ @value.each(&blk)
150
+
151
+ self
152
+ end
153
+ end
154
+
155
+ class Boolean < Primitive ; end
156
+ class Integer < Primitive ; end
157
+ class Enumerated < Primitive ; end
158
+
159
+ class BitString < Primitive
160
+ attr_accessor :unused_bits
161
+
162
+ def initialize(*)
163
+ super
164
+
165
+ @unused_bits = 0
166
+ end
167
+ end
168
+
169
+ class EndOfContent < ASN1Data
170
+ def initialize
171
+ super("", 0, :UNIVERSAL)
172
+ end
173
+ end
174
+
175
+ # :nodoc:
176
+ def self.take_default_tag(klass)
177
+ tag = CLASS_TAG_MAP[klass]
178
+
179
+ return tag if tag
180
+
181
+ sklass = klass.superclass
182
+
183
+ return unless sklass
184
+
185
+ take_default_tag(sklass)
186
+ end
187
+ end
188
+ end
data/lib/openssl/bn.rb CHANGED
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # = Licence
12
12
  # This program is licensed under the same licence as Ruby.
13
- # (See the file 'LICENCE'.)
13
+ # (See the file 'COPYING'.)
14
14
  #++
15
15
 
16
16
  module OpenSSL
@@ -8,7 +8,7 @@
8
8
  #
9
9
  #= Licence
10
10
  # This program is licensed under the same licence as Ruby.
11
- # (See the file 'LICENCE'.)
11
+ # (See the file 'COPYING'.)
12
12
  #++
13
13
 
14
14
  ##
@@ -107,6 +107,12 @@ module OpenSSL::Buffering
107
107
  read(1)&.ord
108
108
  end
109
109
 
110
+ # Get the next 8bit byte. Raises EOFError on EOF
111
+ def readbyte
112
+ raise EOFError if eof?
113
+ getbyte
114
+ end
115
+
110
116
  ##
111
117
  # Reads _size_ bytes from the stream. If _buf_ is provided it must
112
118
  # reference a string which will receive the data.
@@ -229,7 +235,7 @@ module OpenSSL::Buffering
229
235
  #
230
236
  # Unlike IO#gets the separator must be provided if a limit is provided.
231
237
 
232
- def gets(eol=$/, limit=nil)
238
+ def gets(eol=$/, limit=nil, chomp: false)
233
239
  idx = @rbuffer.index(eol)
234
240
  until @eof
235
241
  break if idx
@@ -244,7 +250,11 @@ module OpenSSL::Buffering
244
250
  if size && limit && limit >= 0
245
251
  size = [size, limit].min
246
252
  end
247
- consume_rbuff(size)
253
+ line = consume_rbuff(size)
254
+ if chomp && line
255
+ line.chomp!(eol)
256
+ end
257
+ line
248
258
  end
249
259
 
250
260
  ##
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # = Licence
11
11
  # This program is licensed under the same licence as Ruby.
12
- # (See the file 'LICENCE'.)
12
+ # (See the file 'COPYING'.)
13
13
  #++
14
14
 
15
15
  module OpenSSL
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # = Licence
11
11
  # This program is licensed under the same licence as Ruby.
12
- # (See the file 'LICENCE'.)
12
+ # (See the file 'COPYING'.)
13
13
  #++
14
14
 
15
15
  module OpenSSL
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # = Licence
11
11
  # This program is licensed under the same licence as Ruby.
12
- # (See the file 'LICENCE'.)
12
+ # (See the file 'COPYING'.)
13
13
  #++
14
14
  module OpenSSL
15
15
  module Marshal
data/lib/openssl/ssl.rb CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  = Licence
9
9
  This program is licensed under the same licence as Ruby.
10
- (See the file 'LICENCE'.)
10
+ (See the file 'COPYING'.)
11
11
  =end
12
12
 
13
13
  require "openssl/buffering"
@@ -22,7 +22,6 @@ module OpenSSL
22
22
  module SSL
23
23
  class SSLContext
24
24
  DEFAULT_PARAMS = { # :nodoc:
25
- :min_version => OpenSSL::SSL::TLS1_VERSION,
26
25
  :verify_mode => OpenSSL::SSL::VERIFY_PEER,
27
26
  :verify_hostname => true,
28
27
  :options => -> {
@@ -55,6 +54,7 @@ ssbzSibBsu/6iGtCOGEoXJf//////////wIBAg==
55
54
  if !(OpenSSL::OPENSSL_VERSION.start_with?("OpenSSL") &&
56
55
  OpenSSL::OPENSSL_VERSION_NUMBER >= 0x10100000)
57
56
  DEFAULT_PARAMS.merge!(
57
+ min_version: OpenSSL::SSL::TLS1_VERSION,
58
58
  ciphers: %w{
59
59
  ECDHE-ECDSA-AES128-GCM-SHA256
60
60
  ECDHE-RSA-AES128-GCM-SHA256
@@ -125,7 +125,6 @@ ssbzSibBsu/6iGtCOGEoXJf//////////wIBAg==
125
125
  # that this form is deprecated. New applications should use #min_version=
126
126
  # and #max_version= as necessary.
127
127
  def initialize(version = nil)
128
- self.options |= OpenSSL::SSL::OP_ALL
129
128
  self.ssl_version = version if version
130
129
  self.verify_mode = OpenSSL::SSL::VERIFY_NONE
131
130
  self.verify_hostname = false
@@ -145,7 +144,7 @@ ssbzSibBsu/6iGtCOGEoXJf//////////wIBAg==
145
144
  # used.
146
145
  def set_params(params={})
147
146
  params = DEFAULT_PARAMS.merge(params)
148
- self.options = params.delete(:options) # set before min_version/max_version
147
+ self.options |= params.delete(:options) # set before min_version/max_version
149
148
  params.each{|name, value| self.__send__("#{name}=", value) }
150
149
  if self.verify_mode != OpenSSL::SSL::VERIFY_NONE
151
150
  unless self.ca_file or self.ca_path or self.cert_store
@@ -252,6 +251,14 @@ ssbzSibBsu/6iGtCOGEoXJf//////////wIBAg==
252
251
  to_io.peeraddr
253
252
  end
254
253
 
254
+ def local_address
255
+ to_io.local_address
256
+ end
257
+
258
+ def remote_address
259
+ to_io.remote_address
260
+ end
261
+
255
262
  def setsockopt(level, optname, optval)
256
263
  to_io.setsockopt(level, optname, optval)
257
264
  end
@@ -271,6 +278,36 @@ ssbzSibBsu/6iGtCOGEoXJf//////////wIBAg==
271
278
  def do_not_reverse_lookup=(flag)
272
279
  to_io.do_not_reverse_lookup = flag
273
280
  end
281
+
282
+ def close_on_exec=(value)
283
+ to_io.close_on_exec = value
284
+ end
285
+
286
+ def close_on_exec?
287
+ to_io.close_on_exec?
288
+ end
289
+
290
+ def wait(*args)
291
+ to_io.wait(*args)
292
+ end
293
+
294
+ def wait_readable(*args)
295
+ to_io.wait_readable(*args)
296
+ end
297
+
298
+ def wait_writable(*args)
299
+ to_io.wait_writable(*args)
300
+ end
301
+
302
+ if IO.method_defined?(:timeout)
303
+ def timeout
304
+ to_io.timeout
305
+ end
306
+
307
+ def timeout=(value)
308
+ to_io.timeout=(value)
309
+ end
310
+ end
274
311
  end
275
312
 
276
313
  def verify_certificate_identity(cert, hostname)
@@ -421,6 +458,32 @@ ssbzSibBsu/6iGtCOGEoXJf//////////wIBAg==
421
458
  nil
422
459
  end
423
460
 
461
+ # Close the stream for reading.
462
+ # This method is ignored by OpenSSL as there is no reasonable way to
463
+ # implement it, but exists for compatibility with IO.
464
+ def close_read
465
+ # Unsupported and ignored.
466
+ # Just don't read any more.
467
+ end
468
+
469
+ # Closes the stream for writing. The behavior of this method depends on
470
+ # the version of OpenSSL and the TLS protocol in use.
471
+ #
472
+ # - Sends a 'close_notify' alert to the peer.
473
+ # - Does not wait for the peer's 'close_notify' alert in response.
474
+ #
475
+ # In TLS 1.2 and earlier:
476
+ # - On receipt of a 'close_notify' alert, responds with a 'close_notify'
477
+ # alert of its own and close down the connection immediately,
478
+ # discarding any pending writes.
479
+ #
480
+ # Therefore, on TLS 1.2, this method will cause the connection to be
481
+ # completely shut down. On TLS 1.3, the connection will remain open for
482
+ # reading only.
483
+ def close_write
484
+ stop
485
+ end
486
+
424
487
  private
425
488
 
426
489
  def using_anon_cipher?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenSSL
4
- VERSION = "3.2.1"
4
+ VERSION = "3.3.0"
5
5
  end
data/lib/openssl/x509.rb CHANGED
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # = Licence
11
11
  # This program is licensed under the same licence as Ruby.
12
- # (See the file 'LICENCE'.)
12
+ # (See the file 'COPYING'.)
13
13
  #++
14
14
 
15
15
  require_relative 'marshal'
data/lib/openssl.rb CHANGED
@@ -7,12 +7,13 @@
7
7
 
8
8
  = Licence
9
9
  This program is licensed under the same licence as Ruby.
10
- (See the file 'LICENCE'.)
10
+ (See the file 'COPYING'.)
11
11
  =end
12
12
 
13
13
  require 'openssl.so'
14
14
 
15
15
  require_relative 'openssl/bn'
16
+ require_relative 'openssl/asn1'
16
17
  require_relative 'openssl/pkey'
17
18
  require_relative 'openssl/cipher'
18
19
  require_relative 'openssl/digest'
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.1
4
+ version: 3.3.0
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: 2024-12-18 00:00:00.000000000 Z
14
+ date: 2024-12-21 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.
@@ -27,8 +27,8 @@ extra_rdoc_files:
27
27
  files:
28
28
  - BSDL
29
29
  - CONTRIBUTING.md
30
+ - COPYING
30
31
  - History.md
31
- - LICENSE.txt
32
32
  - README.md
33
33
  - ext/openssl/extconf.rb
34
34
  - ext/openssl/openssl_missing.c
@@ -87,6 +87,7 @@ files:
87
87
  - ext/openssl/ossl_x509revoked.c
88
88
  - ext/openssl/ossl_x509store.c
89
89
  - lib/openssl.rb
90
+ - lib/openssl/asn1.rb
90
91
  - lib/openssl/bn.rb
91
92
  - lib/openssl/buffering.rb
92
93
  - lib/openssl/cipher.rb
@@ -101,6 +102,7 @@ files:
101
102
  homepage: https://github.com/ruby/openssl
102
103
  licenses:
103
104
  - Ruby
105
+ - BSD-2-Clause
104
106
  metadata:
105
107
  msys2_mingw_dependencies: openssl
106
108
  post_install_message:
File without changes