rbs 4.0.0.dev.4 → 4.0.0

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.
Files changed (281) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +14 -14
  3. data/.github/workflows/bundle-update.yml +60 -0
  4. data/.github/workflows/c-check.yml +18 -11
  5. data/.github/workflows/comments.yml +5 -3
  6. data/.github/workflows/dependabot.yml +2 -2
  7. data/.github/workflows/ruby.yml +27 -34
  8. data/.github/workflows/rust.yml +95 -0
  9. data/.github/workflows/typecheck.yml +2 -2
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +1 -1
  12. data/CHANGELOG.md +323 -0
  13. data/README.md +1 -1
  14. data/Rakefile +43 -33
  15. data/Steepfile +1 -0
  16. data/config.yml +426 -24
  17. data/core/array.rbs +307 -227
  18. data/core/basic_object.rbs +9 -8
  19. data/core/binding.rbs +0 -2
  20. data/core/builtin.rbs +2 -2
  21. data/core/class.rbs +6 -5
  22. data/core/comparable.rbs +55 -34
  23. data/core/complex.rbs +104 -78
  24. data/core/dir.rbs +61 -49
  25. data/core/encoding.rbs +12 -15
  26. data/core/enumerable.rbs +179 -87
  27. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  28. data/core/enumerator.rbs +65 -2
  29. data/core/errno.rbs +11 -2
  30. data/core/errors.rbs +58 -29
  31. data/core/exception.rbs +13 -13
  32. data/core/fiber.rbs +74 -54
  33. data/core/file.rbs +280 -177
  34. data/core/file_test.rbs +3 -3
  35. data/core/float.rbs +257 -92
  36. data/core/gc.rbs +425 -281
  37. data/core/hash.rbs +1045 -739
  38. data/core/integer.rbs +135 -137
  39. data/core/io/buffer.rbs +53 -42
  40. data/core/io/wait.rbs +13 -35
  41. data/core/io.rbs +192 -144
  42. data/core/kernel.rbs +216 -155
  43. data/core/marshal.rbs +4 -4
  44. data/core/match_data.rbs +15 -13
  45. data/core/math.rbs +107 -66
  46. data/core/method.rbs +69 -33
  47. data/core/module.rbs +244 -106
  48. data/core/nil_class.rbs +7 -6
  49. data/core/numeric.rbs +74 -63
  50. data/core/object.rbs +9 -11
  51. data/core/object_space.rbs +30 -23
  52. data/core/pathname.rbs +1322 -0
  53. data/core/proc.rbs +95 -58
  54. data/core/process.rbs +222 -202
  55. data/core/ractor.rbs +371 -515
  56. data/core/random.rbs +21 -3
  57. data/core/range.rbs +159 -57
  58. data/core/rational.rbs +60 -89
  59. data/core/rbs/unnamed/argf.rbs +60 -53
  60. data/core/rbs/unnamed/env_class.rbs +19 -14
  61. data/core/rbs/unnamed/main_class.rbs +123 -0
  62. data/core/rbs/unnamed/random.rbs +11 -118
  63. data/core/regexp.rbs +258 -214
  64. data/core/ruby.rbs +53 -0
  65. data/core/ruby_vm.rbs +38 -34
  66. data/core/rubygems/config_file.rbs +5 -5
  67. data/core/rubygems/errors.rbs +4 -71
  68. data/core/rubygems/requirement.rbs +5 -5
  69. data/core/rubygems/rubygems.rbs +16 -82
  70. data/core/rubygems/version.rbs +2 -3
  71. data/core/set.rbs +490 -360
  72. data/core/signal.rbs +26 -16
  73. data/core/string.rbs +3234 -1285
  74. data/core/struct.rbs +27 -26
  75. data/core/symbol.rbs +41 -34
  76. data/core/thread.rbs +135 -67
  77. data/core/time.rbs +81 -50
  78. data/core/trace_point.rbs +41 -35
  79. data/core/true_class.rbs +2 -2
  80. data/core/unbound_method.rbs +24 -16
  81. data/core/warning.rbs +7 -7
  82. data/docs/aliases.md +79 -0
  83. data/docs/collection.md +3 -3
  84. data/docs/config.md +171 -0
  85. data/docs/encoding.md +56 -0
  86. data/docs/gem.md +0 -1
  87. data/docs/inline.md +576 -0
  88. data/docs/sigs.md +3 -3
  89. data/docs/syntax.md +46 -16
  90. data/docs/type_fingerprint.md +21 -0
  91. data/exe/rbs +1 -1
  92. data/ext/rbs_extension/ast_translation.c +544 -116
  93. data/ext/rbs_extension/ast_translation.h +3 -0
  94. data/ext/rbs_extension/class_constants.c +16 -2
  95. data/ext/rbs_extension/class_constants.h +8 -0
  96. data/ext/rbs_extension/extconf.rb +5 -1
  97. data/ext/rbs_extension/legacy_location.c +33 -56
  98. data/ext/rbs_extension/legacy_location.h +37 -0
  99. data/ext/rbs_extension/main.c +44 -35
  100. data/include/rbs/ast.h +448 -173
  101. data/include/rbs/defines.h +27 -0
  102. data/include/rbs/lexer.h +30 -11
  103. data/include/rbs/location.h +25 -44
  104. data/include/rbs/parser.h +6 -6
  105. data/include/rbs/string.h +0 -2
  106. data/include/rbs/util/rbs_allocator.h +34 -13
  107. data/include/rbs/util/rbs_assert.h +12 -1
  108. data/include/rbs/util/rbs_constant_pool.h +0 -3
  109. data/include/rbs/util/rbs_encoding.h +2 -0
  110. data/include/rbs/util/rbs_unescape.h +2 -1
  111. data/include/rbs.h +8 -0
  112. data/lib/rbs/ast/annotation.rb +1 -1
  113. data/lib/rbs/ast/comment.rb +1 -1
  114. data/lib/rbs/ast/declarations.rb +10 -10
  115. data/lib/rbs/ast/members.rb +14 -14
  116. data/lib/rbs/ast/ruby/annotations.rb +293 -3
  117. data/lib/rbs/ast/ruby/comment_block.rb +24 -0
  118. data/lib/rbs/ast/ruby/declarations.rb +198 -3
  119. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  120. data/lib/rbs/ast/ruby/members.rb +532 -22
  121. data/lib/rbs/ast/type_param.rb +24 -4
  122. data/lib/rbs/buffer.rb +20 -15
  123. data/lib/rbs/cli/diff.rb +16 -15
  124. data/lib/rbs/cli/validate.rb +38 -106
  125. data/lib/rbs/cli.rb +52 -19
  126. data/lib/rbs/collection/config/lockfile_generator.rb +14 -2
  127. data/lib/rbs/collection/sources/git.rb +1 -0
  128. data/lib/rbs/definition.rb +1 -1
  129. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  130. data/lib/rbs/definition_builder/method_builder.rb +20 -0
  131. data/lib/rbs/definition_builder.rb +147 -25
  132. data/lib/rbs/diff.rb +7 -1
  133. data/lib/rbs/environment.rb +227 -74
  134. data/lib/rbs/environment_loader.rb +0 -6
  135. data/lib/rbs/errors.rb +27 -18
  136. data/lib/rbs/inline_parser.rb +342 -6
  137. data/lib/rbs/location_aux.rb +1 -1
  138. data/lib/rbs/locator.rb +5 -1
  139. data/lib/rbs/method_type.rb +5 -3
  140. data/lib/rbs/parser_aux.rb +20 -7
  141. data/lib/rbs/prototype/helpers.rb +57 -0
  142. data/lib/rbs/prototype/rb.rb +3 -28
  143. data/lib/rbs/prototype/rbi.rb +3 -20
  144. data/lib/rbs/prototype/runtime.rb +8 -0
  145. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  146. data/lib/rbs/resolver/type_name_resolver.rb +116 -38
  147. data/lib/rbs/subtractor.rb +3 -1
  148. data/lib/rbs/test/type_check.rb +19 -2
  149. data/lib/rbs/type_name.rb +1 -1
  150. data/lib/rbs/types.rb +88 -78
  151. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  152. data/lib/rbs/validator.rb +2 -2
  153. data/lib/rbs/version.rb +1 -1
  154. data/lib/rbs.rb +1 -2
  155. data/lib/rdoc/discover.rb +1 -1
  156. data/lib/rdoc_plugin/parser.rb +1 -1
  157. data/rbs.gemspec +4 -3
  158. data/rust/.gitignore +1 -0
  159. data/rust/Cargo.lock +378 -0
  160. data/rust/Cargo.toml +7 -0
  161. data/rust/ruby-rbs/Cargo.toml +22 -0
  162. data/rust/ruby-rbs/build.rs +764 -0
  163. data/rust/ruby-rbs/examples/locations.rs +60 -0
  164. data/rust/ruby-rbs/src/lib.rs +1 -0
  165. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  166. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  167. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  168. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  169. data/rust/ruby-rbs-sys/build.rs +204 -0
  170. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  171. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  172. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  173. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  174. data/schema/typeParam.json +17 -1
  175. data/sig/ast/ruby/annotations.rbs +315 -4
  176. data/sig/ast/ruby/comment_block.rbs +8 -0
  177. data/sig/ast/ruby/declarations.rbs +102 -4
  178. data/sig/ast/ruby/members.rbs +108 -2
  179. data/sig/cli/diff.rbs +5 -11
  180. data/sig/cli/validate.rbs +12 -8
  181. data/sig/cli.rbs +18 -18
  182. data/sig/definition.rbs +6 -1
  183. data/sig/definition_builder.rbs +2 -0
  184. data/sig/environment.rbs +70 -12
  185. data/sig/errors.rbs +13 -14
  186. data/sig/inline_parser.rbs +39 -2
  187. data/sig/locator.rbs +0 -2
  188. data/sig/manifest.yaml +0 -1
  189. data/sig/method_builder.rbs +3 -1
  190. data/sig/parser.rbs +31 -13
  191. data/sig/prototype/helpers.rbs +2 -0
  192. data/sig/resolver/type_name_resolver.rbs +35 -7
  193. data/sig/source.rbs +3 -3
  194. data/sig/type_param.rbs +13 -8
  195. data/sig/types.rbs +6 -7
  196. data/sig/unit_test/spy.rbs +0 -8
  197. data/sig/unit_test/type_assertions.rbs +11 -0
  198. data/src/ast.c +410 -153
  199. data/src/lexer.c +1392 -1313
  200. data/src/lexer.re +3 -0
  201. data/src/lexstate.c +58 -37
  202. data/src/location.c +8 -48
  203. data/src/parser.c +977 -516
  204. data/src/string.c +0 -48
  205. data/src/util/rbs_allocator.c +89 -71
  206. data/src/util/rbs_assert.c +1 -1
  207. data/src/util/rbs_buffer.c +2 -2
  208. data/src/util/rbs_constant_pool.c +10 -14
  209. data/src/util/rbs_encoding.c +4 -8
  210. data/src/util/rbs_unescape.c +56 -20
  211. data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
  212. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  213. data/stdlib/cgi/0/core.rbs +9 -393
  214. data/stdlib/cgi/0/manifest.yaml +1 -0
  215. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  216. data/stdlib/coverage/0/coverage.rbs +7 -4
  217. data/stdlib/date/0/date.rbs +92 -79
  218. data/stdlib/date/0/date_time.rbs +25 -24
  219. data/stdlib/delegate/0/delegator.rbs +10 -7
  220. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  221. data/stdlib/digest/0/digest.rbs +110 -0
  222. data/stdlib/erb/0/erb.rbs +748 -347
  223. data/stdlib/etc/0/etc.rbs +55 -50
  224. data/stdlib/fileutils/0/fileutils.rbs +158 -139
  225. data/stdlib/forwardable/0/forwardable.rbs +13 -10
  226. data/stdlib/io-console/0/io-console.rbs +2 -2
  227. data/stdlib/json/0/json.rbs +217 -136
  228. data/stdlib/monitor/0/monitor.rbs +3 -3
  229. data/stdlib/net-http/0/net-http.rbs +162 -134
  230. data/stdlib/objspace/0/objspace.rbs +17 -34
  231. data/stdlib/open-uri/0/open-uri.rbs +48 -8
  232. data/stdlib/open3/0/open3.rbs +469 -10
  233. data/stdlib/openssl/0/openssl.rbs +475 -357
  234. data/stdlib/optparse/0/optparse.rbs +26 -17
  235. data/stdlib/pathname/0/pathname.rbs +11 -1381
  236. data/stdlib/pp/0/pp.rbs +9 -8
  237. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  238. data/stdlib/pstore/0/pstore.rbs +35 -30
  239. data/stdlib/psych/0/psych.rbs +65 -12
  240. data/stdlib/psych/0/store.rbs +2 -4
  241. data/stdlib/pty/0/pty.rbs +9 -6
  242. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  243. data/stdlib/rdoc/0/code_object.rbs +2 -1
  244. data/stdlib/rdoc/0/parser.rbs +1 -1
  245. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  246. data/stdlib/rdoc/0/store.rbs +1 -1
  247. data/stdlib/resolv/0/resolv.rbs +25 -68
  248. data/stdlib/ripper/0/ripper.rbs +22 -19
  249. data/stdlib/securerandom/0/manifest.yaml +2 -0
  250. data/stdlib/securerandom/0/securerandom.rbs +7 -20
  251. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  252. data/stdlib/singleton/0/singleton.rbs +3 -0
  253. data/stdlib/socket/0/addrinfo.rbs +7 -7
  254. data/stdlib/socket/0/basic_socket.rbs +3 -3
  255. data/stdlib/socket/0/ip_socket.rbs +10 -8
  256. data/stdlib/socket/0/socket.rbs +23 -10
  257. data/stdlib/socket/0/tcp_server.rbs +1 -1
  258. data/stdlib/socket/0/tcp_socket.rbs +11 -3
  259. data/stdlib/socket/0/udp_socket.rbs +1 -1
  260. data/stdlib/socket/0/unix_server.rbs +1 -1
  261. data/stdlib/stringio/0/stringio.rbs +1177 -85
  262. data/stdlib/strscan/0/string_scanner.rbs +27 -25
  263. data/stdlib/tempfile/0/tempfile.rbs +25 -21
  264. data/stdlib/time/0/time.rbs +8 -6
  265. data/stdlib/timeout/0/timeout.rbs +63 -7
  266. data/stdlib/tsort/0/cyclic.rbs +3 -0
  267. data/stdlib/tsort/0/tsort.rbs +7 -6
  268. data/stdlib/uri/0/common.rbs +42 -20
  269. data/stdlib/uri/0/file.rbs +3 -3
  270. data/stdlib/uri/0/generic.rbs +26 -18
  271. data/stdlib/uri/0/http.rbs +2 -2
  272. data/stdlib/uri/0/ldap.rbs +2 -2
  273. data/stdlib/uri/0/mailto.rbs +3 -3
  274. data/stdlib/uri/0/rfc2396_parser.rbs +12 -12
  275. data/stdlib/zlib/0/deflate.rbs +4 -3
  276. data/stdlib/zlib/0/gzip_reader.rbs +6 -6
  277. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  278. data/stdlib/zlib/0/inflate.rbs +1 -1
  279. data/stdlib/zlib/0/need_dict.rbs +1 -1
  280. data/stdlib/zlib/0/zstream.rbs +1 -0
  281. metadata +50 -6
@@ -120,8 +120,8 @@
120
120
  # supported (see below).
121
121
  #
122
122
  # PKCS5 supports PBKDF2 as it was specified in PKCS#5
123
- # [v2.0](http://www.rsa.com/rsalabs/node.asp?id=2127). It still uses a password,
124
- # a salt, and additionally a number of iterations that will slow the key
123
+ # v2.0[http://www.rsa.com/rsalabs/node.asp?id=2127]. It still uses a password, a
124
+ # salt, and additionally a number of iterations that will slow the key
125
125
  # derivation process down. The slower this is, the more work it requires being
126
126
  # able to brute-force the resulting key.
127
127
  #
@@ -367,7 +367,7 @@
367
367
  # ## SSL and TLS Connections
368
368
  #
369
369
  # Using our created key and certificate we can create an SSL or TLS connection.
370
- # An SSLContext is used to set up an SSL session.
370
+ # An OpenSSL::SSL::SSLContext is used to set up an SSL session.
371
371
  #
372
372
  # context = OpenSSL::SSL::SSLContext.new
373
373
  #
@@ -379,8 +379,8 @@
379
379
  # context.cert = cert
380
380
  # context.key = key
381
381
  #
382
- # Then create an SSLServer with a TCP server socket and the context. Use the
383
- # SSLServer like an ordinary TCP server.
382
+ # Then create an OpenSSL::SSL::SSLServer with a TCP server socket and the
383
+ # context. Use the SSLServer like an ordinary TCP server.
384
384
  #
385
385
  # require 'socket'
386
386
  #
@@ -401,12 +401,13 @@
401
401
  #
402
402
  # ### SSL client
403
403
  #
404
- # An SSL client is created with a TCP socket and the context. SSLSocket#connect
405
- # must be called to initiate the SSL handshake and start encryption. A key and
406
- # certificate are not required for the client socket.
404
+ # An SSL client is created with a TCP socket and the context.
405
+ # OpenSSL::SSL::SSLSocket#connect must be called to initiate the SSL handshake
406
+ # and start encryption. A key and certificate are not required for the client
407
+ # socket.
407
408
  #
408
- # Note that SSLSocket#close doesn't close the underlying socket by default. Set
409
- # SSLSocket#sync_close to true if you want.
409
+ # Note that OpenSSL::SSL::SSLSocket#close doesn't close the underlying socket by
410
+ # default. Set OpenSSL::SSL::SSLSocket#sync_close to true if you want.
410
411
  #
411
412
  # require 'socket'
412
413
  #
@@ -440,8 +441,8 @@
440
441
  # ssl_client.puts "hello server!"
441
442
  # puts ssl_client.gets
442
443
  #
443
- # If the server certificate is invalid or `context.ca_file` is not set when
444
- # verifying peers an OpenSSL::SSL::SSLError will be raised.
444
+ # If the server certificate is invalid or <code>context.ca_file</code> is not
445
+ # set when verifying peers an OpenSSL::SSL::SSLError will be raised.
445
446
  #
446
447
  module OpenSSL
447
448
  # <!--
@@ -455,7 +456,7 @@ module OpenSSL
455
456
  # OpenSSL::Digest("MD5")
456
457
  # # => OpenSSL::Digest::MD5
457
458
  #
458
- # Digest("Foo")
459
+ # OpenSSL::Digest("Foo")
459
460
  # # => NameError: wrong constant name Foo
460
461
  #
461
462
  def self.Digest: (String name) -> singleton(Digest)
@@ -464,12 +465,13 @@ module OpenSSL
464
465
  # rdoc-file=ext/openssl/ossl.c
465
466
  # - OpenSSL.debug -> true | false
466
467
  # -->
468
+ # Returns whether Ruby/OpenSSL's debug mode is currently enabled.
467
469
  #
468
470
  def self.debug: () -> bool
469
471
 
470
472
  # <!--
471
473
  # rdoc-file=ext/openssl/ossl.c
472
- # - OpenSSL.debug = boolean -> boolean
474
+ # - OpenSSL.debug = boolean
473
475
  # -->
474
476
  # Turns on or off debug mode. With debug mode, all errors added to the OpenSSL
475
477
  # error queue will be printed to stderr.
@@ -480,10 +482,14 @@ module OpenSSL
480
482
  # rdoc-file=ext/openssl/ossl.c
481
483
  # - OpenSSL.errors -> [String...]
482
484
  # -->
483
- # See any remaining errors held in queue.
485
+ # Returns any remaining errors held in the OpenSSL thread-local error queue and
486
+ # clears the queue. This should normally return an empty array.
484
487
  #
485
- # Any errors you see here are probably due to a bug in Ruby's OpenSSL
486
- # implementation.
488
+ # This is intended for debugging Ruby/OpenSSL. If you see any errors here, it
489
+ # likely indicates a bug in the extension. Please file an issue at
490
+ # https://github.com/ruby/openssl.
491
+ #
492
+ # For debugging your program, OpenSSL.debug= may be useful.
487
493
  #
488
494
  def self.errors: () -> Array[String]
489
495
 
@@ -491,12 +497,13 @@ module OpenSSL
491
497
  # rdoc-file=ext/openssl/ossl.c
492
498
  # - OpenSSL.fips_mode -> true | false
493
499
  # -->
500
+ # Returns whether the FIPS mode is currently enabled.
494
501
  #
495
502
  def self.fips_mode: () -> bool
496
503
 
497
504
  # <!--
498
505
  # rdoc-file=ext/openssl/ossl.c
499
- # - OpenSSL.fips_mode = boolean -> boolean
506
+ # - OpenSSL.fips_mode = boolean
500
507
  # -->
501
508
  # Turns FIPS mode on or off. Turning on FIPS mode will obviously only have an
502
509
  # effect for FIPS-capable installations of the OpenSSL library. Trying to do so
@@ -510,57 +517,74 @@ module OpenSSL
510
517
 
511
518
  # <!--
512
519
  # rdoc-file=ext/openssl/ossl.c
513
- # - OpenSSL.fixed_length_secure_compare(string, string) -> boolean
520
+ # - OpenSSL.fixed_length_secure_compare(string, string) -> true or false
514
521
  # -->
515
522
  # Constant time memory comparison for fixed length strings, such as results of
516
523
  # HMAC calculations.
517
524
  #
518
525
  # Returns `true` if the strings are identical, `false` if they are of the same
519
- # length but not identical. If the length is different, `ArgumentError` is
520
- # raised.
526
+ # length but not identical. If the length is different, ArgumentError is raised.
521
527
  #
522
528
  def self.fixed_length_secure_compare: (String, String) -> bool
523
529
 
524
530
  # <!--
525
531
  # rdoc-file=ext/openssl/lib/openssl.rb
526
- # - OpenSSL.secure_compare(string, string) -> boolean
532
+ # - OpenSSL.secure_compare(string, string) -> true or false
527
533
  # -->
528
534
  # Constant time memory comparison. Inputs are hashed using SHA-256 to mask the
529
535
  # length of the secret. Returns `true` if the strings are identical, `false`
530
536
  # otherwise.
531
537
  #
538
+ # This method is expensive due to the SHA-256 hashing. In most cases, where the
539
+ # input lengths are known to be equal or are not sensitive,
540
+ # OpenSSL.fixed_length_secure_compare should be used instead.
541
+ #
532
542
  def self.secure_compare: (String a, String b) -> bool
533
543
 
534
544
  # <!-- rdoc-file=ext/openssl/ossl.c -->
535
- # Boolean indicating whether OpenSSL is FIPS-capable or not
545
+ # Boolean indicating whether the OpenSSL library is FIPS-capable or not. Always
546
+ # `true` for OpenSSL 3.0 and later.
547
+ #
548
+ # This is obsolete and will be removed in the future. See also
549
+ # OpenSSL.fips_mode.
536
550
  #
537
551
  OPENSSL_FIPS: bool
538
552
 
553
+ # <!-- rdoc-file=ext/openssl/ossl.c -->
554
+ # OpenSSL library version string currently used at runtime.
555
+ #
539
556
  OPENSSL_LIBRARY_VERSION: String
540
557
 
541
558
  # <!-- rdoc-file=ext/openssl/ossl.c -->
542
- # Version of OpenSSL the ruby OpenSSL extension was built with
559
+ # OpenSSL library version string used to compile the Ruby/OpenSSL extension.
560
+ # This may differ from the version used at runtime.
543
561
  #
544
562
  OPENSSL_VERSION: String
545
563
 
546
564
  # <!-- rdoc-file=ext/openssl/ossl.c -->
547
- # Version number of OpenSSL the ruby OpenSSL extension was built with (base 16).
548
- # The formats are below.
565
+ # OpenSSL library version number used to compile the Ruby/OpenSSL extension.
566
+ # This may differ from the version used at runtime.
549
567
  #
550
- # OpenSSL 3
551
- # : `0xMNN00PP0 (major minor 00 patch 0)`
568
+ # The version number is encoded into a single integer value. The number follows
569
+ # the format:
552
570
  #
553
- # OpenSSL before 3
554
- # : `0xMNNFFPPS (major minor fix patch status)`
571
+ # OpenSSL 3.0.0 or later
572
+ # : `0xMNN00PP0` (major minor 00 patch 0)
573
+ #
574
+ # OpenSSL 1.1.1 or earlier
575
+ # : `0xMNNFFPPS` (major minor fix patch status)
555
576
  #
556
577
  # LibreSSL
557
- # : `0x20000000 (fixed value)`
578
+ # : `0x20000000` (a fixed value)
558
579
  #
559
580
  #
560
581
  # See also the man page OPENSSL_VERSION_NUMBER(3).
561
582
  #
562
583
  OPENSSL_VERSION_NUMBER: Integer
563
584
 
585
+ # <!-- rdoc-file=ext/openssl/lib/openssl/version.rb -->
586
+ # The version string of Ruby/OpenSSL.
587
+ #
564
588
  VERSION: String
565
589
 
566
590
  # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
@@ -588,7 +612,8 @@ module OpenSSL
588
612
  # can only be determined using out-of-band information from the ASN.1 type
589
613
  # declaration. Since this information is normally known when encoding a type,
590
614
  # all sub-classes of ASN1Data offer an additional attribute *tagging* that
591
- # allows to encode a value implicitly (`:IMPLICIT`) or explicitly (`:EXPLICIT`).
615
+ # allows to encode a value implicitly (<code>:IMPLICIT</code>) or explicitly
616
+ # (<code>:EXPLICIT</code>).
592
617
  #
593
618
  # ### Constructive
594
619
  #
@@ -616,18 +641,18 @@ module OpenSSL
616
641
  # When constructing an ASN1Data object the ASN.1 type definition may require
617
642
  # certain elements to be either implicitly or explicitly tagged. This can be
618
643
  # achieved by setting the *tagging* attribute manually for sub-classes of
619
- # ASN1Data. Use the symbol `:IMPLICIT` for implicit tagging and `:EXPLICIT` if
620
- # the element requires explicit tagging.
644
+ # ASN1Data. Use the symbol <code>:IMPLICIT</code> for implicit tagging and
645
+ # <code>:EXPLICIT</code> if the element requires explicit tagging.
621
646
  #
622
647
  # ## Possible values for *tag_class*
623
648
  #
624
649
  # It is possible to create arbitrary ASN1Data objects that also support a
625
650
  # PRIVATE or APPLICATION tag class. Possible values for the *tag_class*
626
651
  # attribute are:
627
- # * `:UNIVERSAL` (the default for untagged values)
628
- # * `:CONTEXT_SPECIFIC` (the default for tagged values)
629
- # * `:APPLICATION`
630
- # * `:PRIVATE`
652
+ # * <code>:UNIVERSAL</code> (the default for untagged values)
653
+ # * <code>:CONTEXT_SPECIFIC</code> (the default for tagged values)
654
+ # * <code>:APPLICATION</code>
655
+ # * <code>:PRIVATE</code>
631
656
  #
632
657
  # ## Tag constants
633
658
  #
@@ -660,7 +685,8 @@ module OpenSSL
660
685
  #
661
686
  # An Array that stores the name of a given tag number. These names are the same
662
687
  # as the name of the tag constant that is additionally defined, e.g.
663
- # `UNIVERSAL_TAG_NAME[2] = "INTEGER"` and `OpenSSL::ASN1::INTEGER = 2`.
688
+ # <code>UNIVERSAL_TAG_NAME[2] = "INTEGER"</code> and
689
+ # <code>OpenSSL::ASN1::INTEGER = 2</code>.
664
690
  #
665
691
  # ## Example usage
666
692
  #
@@ -736,8 +762,8 @@ module OpenSSL
736
762
  # - OpenSSL::ASN1.decode(der) -> ASN1Data
737
763
  # -->
738
764
  # Decodes a BER- or DER-encoded value and creates an ASN1Data instance. *der*
739
- # may be a String or any object that features a `.to_der` method transforming it
740
- # into a BER-/DER-encoded String+
765
+ # may be a String or any object that features a <code>.to_der</code> method
766
+ # transforming it into a BER-/DER-encoded String+
741
767
  #
742
768
  # ## Example
743
769
  # der = File.binread('asn1data')
@@ -868,7 +894,7 @@ module OpenSSL
868
894
  #
869
895
  # An implicitly 1-tagged INTEGER value will be parsed as an ASN1Data with
870
896
  # * *tag* equal to 1
871
- # * *tag_class* equal to `:CONTEXT_SPECIFIC`
897
+ # * *tag_class* equal to <code>:CONTEXT_SPECIFIC</code>
872
898
  # * *value* equal to a String that carries the raw encoding of the INTEGER.
873
899
  # This implies that a subsequent decoding step is required to completely decode
874
900
  # implicitly tagged values.
@@ -877,7 +903,7 @@ module OpenSSL
877
903
  #
878
904
  # An explicitly 1-tagged INTEGER value will be parsed as an ASN1Data with
879
905
  # * *tag* equal to 1
880
- # * *tag_class* equal to `:CONTEXT_SPECIFIC`
906
+ # * *tag_class* equal to <code>:CONTEXT_SPECIFIC</code>
881
907
  # * *value* equal to an Array with one single element, an instance of
882
908
  # OpenSSL::ASN1::Integer, i.e. the inner element is the non-tagged primitive
883
909
  # value, and the tagging is represented in the outer ASN1Data
@@ -931,7 +957,7 @@ module OpenSSL
931
957
  # puts int2.value # => 1
932
958
  #
933
959
  class ASN1Data
934
- # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
960
+ # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
935
961
  # Never `nil`. A boolean value indicating whether the encoding uses indefinite
936
962
  # length (in the case of parsing) or whether an indefinite length form shall be
937
963
  # used (in the encoding case). In DER, every value uses definite length form.
@@ -948,7 +974,7 @@ module OpenSSL
948
974
  #
949
975
  def indefinite_length: () -> bool
950
976
 
951
- # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
977
+ # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
952
978
  # Never `nil`. A boolean value indicating whether the encoding uses indefinite
953
979
  # length (in the case of parsing) or whether an indefinite length form shall be
954
980
  # used (in the encoding case). In DER, every value uses definite length form.
@@ -965,7 +991,7 @@ module OpenSSL
965
991
  #
966
992
  def indefinite_length=: [U] (boolish) -> U
967
993
 
968
- # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
994
+ # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
969
995
  # Never `nil`. A boolean value indicating whether the encoding uses indefinite
970
996
  # length (in the case of parsing) or whether an indefinite length form shall be
971
997
  # used (in the encoding case). In DER, every value uses definite length form.
@@ -982,7 +1008,7 @@ module OpenSSL
982
1008
  #
983
1009
  alias infinite_length indefinite_length
984
1010
 
985
- # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
1011
+ # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
986
1012
  # Never `nil`. A boolean value indicating whether the encoding uses indefinite
987
1013
  # length (in the case of parsing) or whether an indefinite length form shall be
988
1014
  # used (in the encoding case). In DER, every value uses definite length form.
@@ -999,24 +1025,24 @@ module OpenSSL
999
1025
  #
1000
1026
  alias infinite_length= indefinite_length=
1001
1027
 
1002
- # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
1028
+ # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1003
1029
  # An Integer representing the tag number of this ASN1Data. Never `nil`.
1004
1030
  #
1005
1031
  def tag: () -> bn
1006
1032
 
1007
- # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
1033
+ # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1008
1034
  # An Integer representing the tag number of this ASN1Data. Never `nil`.
1009
1035
  #
1010
1036
  def tag=: (::Integer) -> ::Integer
1011
1037
  | (BN) -> BN
1012
1038
 
1013
- # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
1039
+ # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1014
1040
  # A Symbol representing the tag class of this ASN1Data. Never `nil`. See
1015
1041
  # ASN1Data for possible values.
1016
1042
  #
1017
1043
  def tag_class: () -> tag_class
1018
1044
 
1019
- # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
1045
+ # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1020
1046
  # A Symbol representing the tag class of this ASN1Data. Never `nil`. See
1021
1047
  # ASN1Data for possible values.
1022
1048
  #
@@ -1033,13 +1059,13 @@ module OpenSSL
1033
1059
  #
1034
1060
  def to_der: () -> String
1035
1061
 
1036
- # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
1062
+ # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1037
1063
  # Carries the value of a ASN.1 type. Please confer Constructive and Primitive
1038
1064
  # for the mappings between ASN.1 data types and Ruby classes.
1039
1065
  #
1040
1066
  def value: () -> untyped
1041
1067
 
1042
- # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
1068
+ # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1043
1069
  # Carries the value of a ASN.1 type. Please confer Constructive and Primitive
1044
1070
  # for the mappings between ASN.1 data types and Ruby classes.
1045
1071
  #
@@ -1048,7 +1074,7 @@ module OpenSSL
1048
1074
  private
1049
1075
 
1050
1076
  # <!--
1051
- # rdoc-file=ext/openssl/lib/openssl/asn1.rb
1077
+ # rdoc-file=ext/openssl/ossl_asn1.c
1052
1078
  # - OpenSSL::ASN1::ASN1Data.new(value, tag, tag_class) => ASN1Data
1053
1079
  # -->
1054
1080
  # *value*: Please have a look at Constructive and Primitive to see how Ruby
@@ -1120,7 +1146,7 @@ module OpenSSL
1120
1146
  include Enumerable[ASN1Data]
1121
1147
 
1122
1148
  # <!--
1123
- # rdoc-file=ext/openssl/lib/openssl/asn1.rb
1149
+ # rdoc-file=ext/openssl/ossl_asn1.c
1124
1150
  # - asn1_ary.each { |asn1| block } => asn1_ary
1125
1151
  # -->
1126
1152
  # Calls the given block once for each element in self, passing that element as
@@ -1135,15 +1161,17 @@ module OpenSSL
1135
1161
 
1136
1162
  # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1137
1163
  # May be used as a hint for encoding a value either implicitly or explicitly by
1138
- # setting it either to `:IMPLICIT` or to `:EXPLICIT`. *tagging* is not set when
1139
- # a ASN.1 structure is parsed using OpenSSL::ASN1.decode.
1164
+ # setting it either to <code>:IMPLICIT</code> or to <code>:EXPLICIT</code>.
1165
+ # *tagging* is not set when a ASN.1 structure is parsed using
1166
+ # OpenSSL::ASN1.decode.
1140
1167
  #
1141
1168
  def tagging: () -> tagging?
1142
1169
 
1143
1170
  # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1144
1171
  # May be used as a hint for encoding a value either implicitly or explicitly by
1145
- # setting it either to `:IMPLICIT` or to `:EXPLICIT`. *tagging* is not set when
1146
- # a ASN.1 structure is parsed using OpenSSL::ASN1.decode.
1172
+ # setting it either to <code>:IMPLICIT</code> or to <code>:EXPLICIT</code>.
1173
+ # *tagging* is not set when a ASN.1 structure is parsed using
1174
+ # OpenSSL::ASN1.decode.
1147
1175
  #
1148
1176
  def tagging=: (tagging) -> tagging
1149
1177
 
@@ -1169,9 +1197,10 @@ module OpenSSL
1169
1197
  # *tagging*: may be used as an encoding hint to encode a value either explicitly
1170
1198
  # or implicitly, see ASN1 for possible values.
1171
1199
  #
1172
- # *tag_class*: if *tag* and *tagging* are `nil` then this is set to `:UNIVERSAL`
1173
- # by default. If either *tag* or *tagging* are set then `:CONTEXT_SPECIFIC` is
1174
- # used as the default. For possible values please cf. ASN1.
1200
+ # *tag_class*: if *tag* and *tagging* are `nil` then this is set to
1201
+ # <code>:UNIVERSAL</code> by default. If either *tag* or *tagging* are set then
1202
+ # <code>:CONTEXT_SPECIFIC</code> is used as the default. For possible values
1203
+ # please cf. ASN1.
1175
1204
  #
1176
1205
  # ## Example
1177
1206
  # int = OpenSSL::ASN1::Integer.new(42)
@@ -1384,15 +1413,17 @@ module OpenSSL
1384
1413
  class Primitive < OpenSSL::ASN1::ASN1Data
1385
1414
  # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1386
1415
  # May be used as a hint for encoding a value either implicitly or explicitly by
1387
- # setting it either to `:IMPLICIT` or to `:EXPLICIT`. *tagging* is not set when
1388
- # a ASN.1 structure is parsed using OpenSSL::ASN1.decode.
1416
+ # setting it either to <code>:IMPLICIT</code> or to <code>:EXPLICIT</code>.
1417
+ # *tagging* is not set when a ASN.1 structure is parsed using
1418
+ # OpenSSL::ASN1.decode.
1389
1419
  #
1390
1420
  def tagging: () -> tagging?
1391
1421
 
1392
1422
  # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1393
1423
  # May be used as a hint for encoding a value either implicitly or explicitly by
1394
- # setting it either to `:IMPLICIT` or to `:EXPLICIT`. *tagging* is not set when
1395
- # a ASN.1 structure is parsed using OpenSSL::ASN1.decode.
1424
+ # setting it either to <code>:IMPLICIT</code> or to <code>:EXPLICIT</code>.
1425
+ # *tagging* is not set when a ASN.1 structure is parsed using
1426
+ # OpenSSL::ASN1.decode.
1396
1427
  #
1397
1428
  def tagging=: (tagging) -> tagging
1398
1429
 
@@ -1418,9 +1449,10 @@ module OpenSSL
1418
1449
  # *tagging*: may be used as an encoding hint to encode a value either explicitly
1419
1450
  # or implicitly, see ASN1 for possible values.
1420
1451
  #
1421
- # *tag_class*: if *tag* and *tagging* are `nil` then this is set to `:UNIVERSAL`
1422
- # by default. If either *tag* or *tagging* are set then `:CONTEXT_SPECIFIC` is
1423
- # used as the default. For possible values please cf. ASN1.
1452
+ # *tag_class*: if *tag* and *tagging* are `nil` then this is set to
1453
+ # <code>:UNIVERSAL</code> by default. If either *tag* or *tagging* are set then
1454
+ # <code>:CONTEXT_SPECIFIC</code> is used as the default. For possible values
1455
+ # please cf. ASN1.
1424
1456
  #
1425
1457
  # ## Example
1426
1458
  # int = OpenSSL::ASN1::Integer.new(42)
@@ -1487,7 +1519,7 @@ module OpenSSL
1487
1519
  # -->
1488
1520
  # Generates a random prime number of bit length *bits*. If *safe* is set to
1489
1521
  # `true`, generates a safe prime. If *add* is specified, generates a prime that
1490
- # fulfills condition `p % add = rem`.
1522
+ # fulfills condition <code>p % add = rem</code>.
1491
1523
  #
1492
1524
  # ### Parameters
1493
1525
  # * *bits* - integer
@@ -1656,8 +1688,8 @@ module OpenSSL
1656
1688
  # rdoc-file=ext/openssl/ossl_bn.c
1657
1689
  # - bn.eql?(obj) => true or false
1658
1690
  # -->
1659
- # Returns `true` only if *obj* is a `OpenSSL::BN` with the same value as *bn*.
1660
- # Contrast this with OpenSSL::BN#==, which performs type conversions.
1691
+ # Returns `true` only if *obj* is a <code>OpenSSL::BN</code> with the same value
1692
+ # as *bn*. Contrast this with OpenSSL::BN#==, which performs type conversions.
1661
1693
  #
1662
1694
  def eql?: (untyped other) -> bool
1663
1695
 
@@ -1778,7 +1810,8 @@ module OpenSSL
1778
1810
  # -->
1779
1811
  # Performs a Miller-Rabin probabilistic primality test for `bn`.
1780
1812
  #
1781
- # **`checks` parameter is deprecated in version 3.0.** It has no effect.
1813
+ # <strong>`checks` parameter is deprecated in version 3.0.</strong> It has no
1814
+ # effect.
1782
1815
  #
1783
1816
  def prime?: (?int checks) -> bool
1784
1817
 
@@ -1790,7 +1823,7 @@ module OpenSSL
1790
1823
  # -->
1791
1824
  # Performs a Miller-Rabin probabilistic primality test for `bn`.
1792
1825
  #
1793
- # **Deprecated in version 3.0.** Use #prime? instead.
1826
+ # <strong>Deprecated in version 3.0.</strong> Use #prime? instead.
1794
1827
  #
1795
1828
  # `checks` and `trial_div` parameters no longer have any effect.
1796
1829
  #
@@ -1940,8 +1973,8 @@ module OpenSSL
1940
1973
  # rdoc-file=ext/openssl/lib/openssl/buffering.rb
1941
1974
  # - <<(s)
1942
1975
  # -->
1943
- # Writes *s* to the stream. *s* will be converted to a String using `.to_s`
1944
- # method.
1976
+ # Writes *s* to the stream. *s* will be converted to a String using
1977
+ # <code>.to_s</code> method.
1945
1978
  #
1946
1979
  def <<: (String s) -> self
1947
1980
 
@@ -2103,8 +2136,8 @@ module OpenSSL
2103
2136
  #
2104
2137
  # By specifying a keyword argument *exception* to `false`, you can indicate that
2105
2138
  # read_nonblock should not raise an IO::Wait*able exception, but return the
2106
- # symbol `:wait_writable` or `:wait_readable` instead. At EOF, it will return
2107
- # `nil` instead of raising EOFError.
2139
+ # symbol <code>:wait_writable</code> or <code>:wait_readable</code> instead. At
2140
+ # EOF, it will return `nil` instead of raising EOFError.
2108
2141
  #
2109
2142
  def read_nonblock: (Integer maxlen, ?String buf, ?exception: true) -> String
2110
2143
  | (Integer maxlen, ?String buf, exception: false) -> (String | :wait_writable | :wait_readable | nil)
@@ -2181,7 +2214,8 @@ module OpenSSL
2181
2214
  # - write(*s)
2182
2215
  # -->
2183
2216
  # Writes *s* to the stream. If the argument is not a String it will be
2184
- # converted using `.to_s` method. Returns the number of bytes written.
2217
+ # converted using <code>.to_s</code> method. Returns the number of bytes
2218
+ # written.
2185
2219
  #
2186
2220
  def write: (*_ToS s) -> Integer
2187
2221
 
@@ -2223,7 +2257,7 @@ module OpenSSL
2223
2257
  #
2224
2258
  # By specifying a keyword argument *exception* to `false`, you can indicate that
2225
2259
  # write_nonblock should not raise an IO::Wait*able exception, but return the
2226
- # symbol `:wait_writable` or `:wait_readable` instead.
2260
+ # symbol <code>:wait_writable</code> or <code>:wait_readable</code> instead.
2227
2261
  #
2228
2262
  def write_nonblock: (_ToS s, ?exception: true) -> Integer
2229
2263
  | (_ToS s, exception: false) -> (Integer | :wait_writable | :wait_readable | nil)
@@ -2428,24 +2462,28 @@ module OpenSSL
2428
2462
  # prevents malicious modifications of the ciphertext that could otherwise be
2429
2463
  # exploited to modify ciphertexts in ways beneficial to potential attackers.
2430
2464
  #
2431
- # An associated data is used where there is additional information, such as
2432
- # headers or some metadata, that must be also authenticated but not necessarily
2433
- # need to be encrypted. If no associated data is needed for encryption and later
2434
- # decryption, the OpenSSL library still requires a value to be set - "" may be
2435
- # used in case none is available.
2465
+ # Associated data, also called additional authenticated data (AAD), is
2466
+ # optionally used where there is additional information, such as headers or some
2467
+ # metadata, that must be also authenticated but not necessarily need to be
2468
+ # encrypted.
2436
2469
  #
2437
2470
  # An example using the GCM (Galois/Counter Mode). You have 16 bytes *key*, 12
2438
2471
  # bytes (96 bits) *nonce* and the associated data *auth_data*. Be sure not to
2439
2472
  # reuse the *key* and *nonce* pair. Reusing an nonce ruins the security
2440
2473
  # guarantees of GCM mode.
2441
2474
  #
2475
+ # key = OpenSSL::Random.random_bytes(16)
2476
+ # nonce = OpenSSL::Random.random_bytes(12)
2477
+ # auth_data = "authenticated but unencrypted data"
2478
+ # data = "encrypted data"
2479
+ #
2442
2480
  # cipher = OpenSSL::Cipher.new('aes-128-gcm').encrypt
2443
2481
  # cipher.key = key
2444
2482
  # cipher.iv = nonce
2445
2483
  # cipher.auth_data = auth_data
2446
2484
  #
2447
2485
  # encrypted = cipher.update(data) + cipher.final
2448
- # tag = cipher.auth_tag # produces 16 bytes tag by default
2486
+ # tag = cipher.auth_tag(16)
2449
2487
  #
2450
2488
  # Now you are the receiver. You know the *key* and have received *nonce*,
2451
2489
  # *auth_data*, *encrypted* and *tag* through an untrusted network. Note that GCM
@@ -2458,13 +2496,17 @@ module OpenSSL
2458
2496
  # decipher = OpenSSL::Cipher.new('aes-128-gcm').decrypt
2459
2497
  # decipher.key = key
2460
2498
  # decipher.iv = nonce
2461
- # decipher.auth_tag = tag
2499
+ # decipher.auth_tag = tag # could be called at any time before #final
2462
2500
  # decipher.auth_data = auth_data
2463
2501
  #
2464
2502
  # decrypted = decipher.update(encrypted) + decipher.final
2465
2503
  #
2466
2504
  # puts data == decrypted #=> true
2467
2505
  #
2506
+ # Note that other AEAD ciphers may require additional steps, such as setting the
2507
+ # expected tag length (#auth_tag_len=) or the total data length (#ccm_data_len=)
2508
+ # in advance. Make sure to read the relevant man page for details.
2509
+ #
2468
2510
  class Cipher
2469
2511
  # <!--
2470
2512
  # rdoc-file=ext/openssl/ossl_cipher.c
@@ -2476,21 +2518,22 @@ module OpenSSL
2476
2518
 
2477
2519
  # <!--
2478
2520
  # rdoc-file=ext/openssl/ossl_cipher.c
2479
- # - cipher.auth_data = string -> string
2480
- # -->
2481
- # Sets the cipher's additional authenticated data. This field must be set when
2482
- # using AEAD cipher modes such as GCM or CCM. If no associated data shall be
2483
- # used, this method must **still** be called with a value of "". The contents of
2484
- # this field should be non-sensitive data which will be added to the ciphertext
2485
- # to generate the authentication tag which validates the contents of the
2486
- # ciphertext.
2487
- #
2488
- # The AAD must be set prior to encryption or decryption. In encryption mode, it
2489
- # must be set after calling Cipher#encrypt and setting Cipher#key= and
2490
- # Cipher#iv=. When decrypting, the authenticated data must be set after key, iv
2491
- # and especially **after** the authentication tag has been set. I.e. set it only
2492
- # after calling Cipher#decrypt, Cipher#key=, Cipher#iv= and Cipher#auth_tag=
2493
- # first.
2521
+ # - cipher.auth_data = string
2522
+ # -->
2523
+ # Sets additional authenticated data (AAD), also called associated data, for
2524
+ # this Cipher. This method is available for AEAD ciphers.
2525
+ #
2526
+ # The contents of this field should be non-sensitive data which will be added to
2527
+ # the ciphertext to generate the authentication tag which validates the contents
2528
+ # of the ciphertext.
2529
+ #
2530
+ # This method must be called after #key= and #iv= have been set, but before
2531
+ # starting actual encryption or decryption with #update. In some cipher modes,
2532
+ # #auth_tag_len= and #ccm_data_len= may also need to be called before this
2533
+ # method.
2534
+ #
2535
+ # See also the "AEAD Interface" section of the man page EVP_EncryptInit(3). This
2536
+ # method internally calls EVP_CipherUpdate() with the output buffer set to NULL.
2494
2537
  #
2495
2538
  def auth_data=: (String) -> String
2496
2539
 
@@ -2498,42 +2541,54 @@ module OpenSSL
2498
2541
  # rdoc-file=ext/openssl/ossl_cipher.c
2499
2542
  # - cipher.auth_tag(tag_len = 16) -> String
2500
2543
  # -->
2501
- # Gets the authentication tag generated by Authenticated Encryption Cipher modes
2502
- # (GCM for example). This tag may be stored along with the ciphertext, then set
2503
- # on the decryption cipher to authenticate the contents of the ciphertext
2504
- # against changes. If the optional integer parameter *tag_len* is given, the
2505
- # returned tag will be *tag_len* bytes long. If the parameter is omitted, the
2506
- # default length of 16 bytes or the length previously set by #auth_tag_len= will
2507
- # be used. For maximum security, the longest possible should be chosen.
2544
+ # Gets the generated authentication tag. This method is available for AEAD
2545
+ # ciphers, and should be called after encryption has been finalized by calling
2546
+ # #final.
2508
2547
  #
2509
- # The tag may only be retrieved after calling Cipher#final.
2548
+ # The returned tag will be *tag_len* bytes long. Some cipher modes require the
2549
+ # desired length in advance using a separate call to #auth_tag_len=, before
2550
+ # starting encryption.
2551
+ #
2552
+ # See also the "AEAD Interface" section of the man page EVP_EncryptInit(3). This
2553
+ # method internally calls EVP_CIPHER_CTX_ctrl() with EVP_CTRL_AEAD_GET_TAG.
2510
2554
  #
2511
2555
  def auth_tag: (?Integer tag_len) -> String
2512
2556
 
2513
2557
  # <!--
2514
2558
  # rdoc-file=ext/openssl/ossl_cipher.c
2515
- # - cipher.auth_tag = string -> string
2559
+ # - cipher.auth_tag = string
2516
2560
  # -->
2517
- # Sets the authentication tag to verify the integrity of the ciphertext. This
2518
- # can be called only when the cipher supports AE. The tag must be set after
2519
- # calling Cipher#decrypt, Cipher#key= and Cipher#iv=, but before calling
2520
- # Cipher#final. After all decryption is performed, the tag is verified
2521
- # automatically in the call to Cipher#final.
2561
+ # Sets the authentication tag to verify the integrity of the ciphertext.
2562
+ #
2563
+ # The authentication tag must be set before #final is called. The tag is
2564
+ # verified during the #final call.
2522
2565
  #
2523
- # For OCB mode, the tag length must be supplied with #auth_tag_len= beforehand.
2566
+ # Note that, for CCM mode and OCB mode, the expected length of the tag must be
2567
+ # set before starting decryption by a separate call to #auth_tag_len=. The
2568
+ # content of the tag can be provided at any time before #final is called.
2569
+ #
2570
+ # **NOTE**: The caller must ensure that the String passed to this method has the
2571
+ # desired length. Some cipher modes support variable tag lengths, and this
2572
+ # method may accept a truncated tag without raising an exception.
2573
+ #
2574
+ # See also the "AEAD Interface" section of the man page EVP_EncryptInit(3). This
2575
+ # method internally calls EVP_CIPHER_CTX_ctrl() with EVP_CTRL_AEAD_SET_TAG.
2524
2576
  #
2525
2577
  def auth_tag=: (String) -> String
2526
2578
 
2527
2579
  # <!--
2528
2580
  # rdoc-file=ext/openssl/ossl_cipher.c
2529
- # - cipher.auth_tag_len = Integer -> Integer
2581
+ # - cipher.auth_tag_len = integer
2530
2582
  # -->
2531
- # Sets the length of the authentication tag to be generated or to be given for
2532
- # AEAD ciphers that requires it as in input parameter. Note that not all AEAD
2533
- # ciphers support this method.
2583
+ # Sets the length of the expected authentication tag for this Cipher. This
2584
+ # method is available for some of AEAD ciphers that require the length to be set
2585
+ # before starting encryption or decryption, such as CCM mode or OCB mode.
2534
2586
  #
2535
- # In OCB mode, the length must be supplied both when encrypting and when
2536
- # decrypting, and must be before specifying an IV.
2587
+ # For CCM mode and OCB mode, the tag length must be set before #iv= is set.
2588
+ #
2589
+ # See also the "AEAD Interface" section of the man page EVP_EncryptInit(3). This
2590
+ # method internally calls EVP_CIPHER_CTX_ctrl() with EVP_CTRL_AEAD_SET_TAG and a
2591
+ # NULL buffer.
2537
2592
  #
2538
2593
  def auth_tag_len=: (Integer) -> Integer
2539
2594
 
@@ -2541,7 +2596,7 @@ module OpenSSL
2541
2596
  # rdoc-file=ext/openssl/ossl_cipher.c
2542
2597
  # - cipher.authenticated? -> true | false
2543
2598
  # -->
2544
- # Indicated whether this Cipher instance uses an Authenticated Encryption mode.
2599
+ # Indicates whether this Cipher instance uses an AEAD mode.
2545
2600
  #
2546
2601
  def authenticated?: () -> bool
2547
2602
 
@@ -2559,11 +2614,9 @@ module OpenSSL
2559
2614
  # -->
2560
2615
  # Initializes the Cipher for decryption.
2561
2616
  #
2562
- # Make sure to call Cipher#encrypt or Cipher#decrypt before using any of the
2563
- # following methods:
2617
+ # Make sure to call either #encrypt or #decrypt before using the Cipher for any
2618
+ # operation or setting any parameters.
2564
2619
  #
2565
- # #key=, #iv=, #random_key, #random_iv, #pkcs5_keyivgen
2566
- # :
2567
2620
  # Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 0).
2568
2621
  #
2569
2622
  def decrypt: () -> self
@@ -2574,11 +2627,9 @@ module OpenSSL
2574
2627
  # -->
2575
2628
  # Initializes the Cipher for encryption.
2576
2629
  #
2577
- # Make sure to call Cipher#encrypt or Cipher#decrypt before using any of the
2578
- # following methods:
2630
+ # Make sure to call either #encrypt or #decrypt before using the Cipher for any
2631
+ # operation or setting any parameters.
2579
2632
  #
2580
- # #key=, #iv=, #random_key, #random_iv, #pkcs5_keyivgen
2581
- # :
2582
2633
  # Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 1).
2583
2634
  #
2584
2635
  def encrypt: () -> self
@@ -2588,28 +2639,37 @@ module OpenSSL
2588
2639
  # - cipher.final -> string
2589
2640
  # -->
2590
2641
  # Returns the remaining data held in the cipher object. Further calls to
2591
- # Cipher#update or Cipher#final will return garbage. This call should always be
2592
- # made as the last call of an encryption or decryption operation, after having
2593
- # fed the entire plaintext or ciphertext to the Cipher instance.
2642
+ # Cipher#update or Cipher#final are invalid. This call should always be made as
2643
+ # the last call of an encryption or decryption operation, after having fed the
2644
+ # entire plaintext or ciphertext to the Cipher instance.
2645
+ #
2646
+ # When encrypting using an AEAD cipher, the authentication tag can be retrieved
2647
+ # by #auth_tag after #final has been called.
2594
2648
  #
2595
- # If an authenticated cipher was used, a CipherError is raised if the tag could
2596
- # not be authenticated successfully. Only call this method after setting the
2597
- # authentication tag and passing the entire contents of the ciphertext into the
2598
- # cipher.
2649
+ # When decrypting using an AEAD cipher, this method will verify the integrity of
2650
+ # the ciphertext and the associated data with the authentication tag, which must
2651
+ # be set by #auth_tag= prior to calling this method. If the verification fails,
2652
+ # CipherError will be raised.
2599
2653
  #
2600
2654
  def final: () -> String
2601
2655
 
2602
2656
  # <!--
2603
2657
  # rdoc-file=ext/openssl/ossl_cipher.c
2604
- # - cipher.iv = string -> string
2658
+ # - cipher.iv = string
2605
2659
  # -->
2606
2660
  # Sets the cipher IV. Please note that since you should never be using ECB mode,
2607
2661
  # an IV is always explicitly required and should be set prior to encryption. The
2608
- # IV itself can be safely transmitted in public, but it should be unpredictable
2609
- # to prevent certain kinds of attacks. You may use Cipher#random_iv to create a
2610
- # secure random IV.
2662
+ # IV itself can be safely transmitted in public.
2611
2663
  #
2612
- # Only call this method after calling Cipher#encrypt or Cipher#decrypt.
2664
+ # This method expects the String to have the length equal to #iv_len. To use a
2665
+ # different IV length with an AEAD cipher, #iv_len= must be set prior to calling
2666
+ # this method.
2667
+ #
2668
+ # **NOTE**: In OpenSSL API conventions, the IV value may correspond to the
2669
+ # "nonce" instead in some cipher modes. Refer to the OpenSSL man pages for
2670
+ # details.
2671
+ #
2672
+ # See also the man page EVP_CipherInit_ex(3).
2613
2673
  #
2614
2674
  def iv=: (String iv) -> String
2615
2675
 
@@ -2623,17 +2683,20 @@ module OpenSSL
2623
2683
 
2624
2684
  # <!--
2625
2685
  # rdoc-file=ext/openssl/ossl_cipher.c
2626
- # - cipher.iv_len = integer -> integer
2686
+ # - cipher.iv_len = integer
2627
2687
  # -->
2628
- # Sets the IV/nonce length of the Cipher. Normally block ciphers don't allow
2629
- # changing the IV length, but some make use of IV for 'nonce'. You may need this
2630
- # for interoperability with other applications.
2688
+ # Sets the IV/nonce length for this Cipher. This method is available for AEAD
2689
+ # ciphers that support variable IV lengths. This method can be called if a
2690
+ # different IV length than OpenSSL's default is desired, prior to calling #iv=.
2691
+ #
2692
+ # See also the "AEAD Interface" section of the man page EVP_EncryptInit(3). This
2693
+ # method internally calls EVP_CIPHER_CTX_ctrl() with EVP_CTRL_AEAD_SET_IVLEN.
2631
2694
  #
2632
2695
  def iv_len=: (Integer) -> Integer
2633
2696
 
2634
2697
  # <!--
2635
2698
  # rdoc-file=ext/openssl/ossl_cipher.c
2636
- # - cipher.key = string -> string
2699
+ # - cipher.key = string
2637
2700
  # -->
2638
2701
  # Sets the cipher key. To generate a key, you should either use a secure random
2639
2702
  # byte string or, if the key is to be derived from a password, you should rely
@@ -2642,6 +2705,8 @@ module OpenSSL
2642
2705
  #
2643
2706
  # Only call this method after calling Cipher#encrypt or Cipher#decrypt.
2644
2707
  #
2708
+ # See also the man page EVP_CipherInit_ex(3).
2709
+ #
2645
2710
  def key=: (String key) -> String
2646
2711
 
2647
2712
  # <!--
@@ -2654,7 +2719,7 @@ module OpenSSL
2654
2719
 
2655
2720
  # <!--
2656
2721
  # rdoc-file=ext/openssl/ossl_cipher.c
2657
- # - cipher.key_len = integer -> integer
2722
+ # - cipher.key_len = integer
2658
2723
  # -->
2659
2724
  # Sets the key length of the cipher. If the cipher is a fixed length cipher
2660
2725
  # then attempting to set the key length to any value other than the fixed value
@@ -2678,7 +2743,7 @@ module OpenSSL
2678
2743
 
2679
2744
  # <!--
2680
2745
  # rdoc-file=ext/openssl/ossl_cipher.c
2681
- # - cipher.padding = integer -> integer
2746
+ # - cipher.padding = 1 or 0
2682
2747
  # -->
2683
2748
  # Enables or disables padding. By default encryption operations are padded using
2684
2749
  # standard block padding and the padding is checked and removed when decrypting.
@@ -2696,19 +2761,16 @@ module OpenSSL
2696
2761
  # -->
2697
2762
  # Generates and sets the key/IV based on a password.
2698
2763
  #
2699
- # **WARNING**: This method is only PKCS5 v1.5 compliant when using RC2, RC4-40,
2700
- # or DES with MD5 or SHA1. Using anything else (like AES) will generate the
2701
- # key/iv using an OpenSSL specific method. This method is deprecated and should
2702
- # no longer be used. Use a PKCS5 v2 key generation method from OpenSSL::PKCS5
2703
- # instead.
2764
+ # **WARNING**: This method is deprecated and should not be used. This method
2765
+ # corresponds to EVP_BytesToKey(), a non-standard OpenSSL extension of the
2766
+ # legacy PKCS #5 v1.5 key derivation function. See OpenSSL::KDF for other
2767
+ # options to derive keys from passwords.
2704
2768
  #
2705
2769
  # ### Parameters
2706
2770
  # * *salt* must be an 8 byte string if provided.
2707
2771
  # * *iterations* is an integer with a default of 2048.
2708
2772
  # * *digest* is a Digest object that defaults to 'MD5'
2709
2773
  #
2710
- # A minimum of 1000 iterations is recommended.
2711
- #
2712
2774
  def pkcs5_keyivgen: (String pass, ?String salt, ?Integer iterations, ?String digest) -> void
2713
2775
 
2714
2776
  # <!--
@@ -2755,6 +2817,9 @@ module OpenSSL
2755
2817
  # If *buffer* is given, the encryption/decryption result will be written to it.
2756
2818
  # *buffer* will be resized automatically.
2757
2819
  #
2820
+ # **NOTE**: When decrypting using an AEAD cipher, the integrity of the output is
2821
+ # not verified until #final has been called.
2822
+ #
2758
2823
  def update: (String data, ?String buffer) -> String
2759
2824
 
2760
2825
  private
@@ -2863,7 +2928,7 @@ module OpenSSL
2863
2928
  # configuration. See the value of OpenSSL::Config::DEFAULT_CONFIG_FILE for the
2864
2929
  # location of the file for your host.
2865
2930
  #
2866
- # See also http://www.openssl.org/docs/apps/config.html
2931
+ # See also https://docs.openssl.org/master/man5/config/
2867
2932
  #
2868
2933
  class Config
2869
2934
  include Enumerable[[ String, String, String ]]
@@ -3910,7 +3975,7 @@ module OpenSSL
3910
3975
  # short-circuits on evaluation, and is therefore vulnerable to timing attacks.
3911
3976
  # The proper way is to use a method that always takes the same amount of time
3912
3977
  # when comparing two values, thus not leaking any information to potential
3913
- # attackers. To do this, use `OpenSSL.fixed_length_secure_compare`.
3978
+ # attackers. To do this, use <code>OpenSSL.fixed_length_secure_compare</code>.
3914
3979
  #
3915
3980
  module KDF
3916
3981
  # <!--
@@ -3933,8 +3998,8 @@ module OpenSSL
3933
3998
  # : The context and application specific information.
3934
3999
  #
3935
4000
  # *length*
3936
- # : The output length in octets. Must be <= `255 * HashLen`, where HashLen is
3937
- # the length of the hash function output in octets.
4001
+ # : The output length in octets. Must be <= <code>255 * HashLen</code>, where
4002
+ # HashLen is the length of the hash function output in octets.
3938
4003
  #
3939
4004
  # *hash*
3940
4005
  # : The hash function.
@@ -4794,8 +4859,8 @@ module OpenSSL
4794
4859
  #
4795
4860
  #
4796
4861
  # For most responses, clients can check *result* > 0. If a responder doesn't
4797
- # handle nonces `result.nonzero?` may be necessary. A result of `0` is always
4798
- # an error.
4862
+ # handle nonces <code>result.nonzero?</code> may be necessary. A result of `0`
4863
+ # is always an error.
4799
4864
  #
4800
4865
  def check_nonce: (Response response) -> (-1 | 0 | 1 | 2 | 3)
4801
4866
 
@@ -5042,7 +5107,11 @@ module OpenSSL
5042
5107
  end
5043
5108
 
5044
5109
  # <!-- rdoc-file=ext/openssl/ossl.c -->
5045
- # Generic error, common for all classes under OpenSSL module
5110
+ # Generic error class for OpenSSL. All error classes in this library inherit
5111
+ # from this class.
5112
+ #
5113
+ # This class indicates that an error was reported by the underlying OpenSSL
5114
+ # library.
5046
5115
  #
5047
5116
  class OpenSSLError < StandardError
5048
5117
  end
@@ -5147,7 +5216,8 @@ module OpenSSL
5147
5216
  # -->
5148
5217
  # Creates a PKCS #7 enveloped-data structure.
5149
5218
  #
5150
- # Before version 3.3.0, `cipher` was optional and defaulted to `"RC2-40-CBC"`.
5219
+ # Before version 3.3.0, `cipher` was optional and defaulted to
5220
+ # <code>"RC2-40-CBC"</code>.
5151
5221
  #
5152
5222
  # See also the man page PKCS7_encrypt(3).
5153
5223
  #
@@ -5619,8 +5689,8 @@ module OpenSSL
5619
5689
  # result of DH#public_key), then this method needs to be called first in order
5620
5690
  # to generate the per-session keys before performing the actual key exchange.
5621
5691
  #
5622
- # **Deprecated in version 3.0**. This method is incompatible with OpenSSL 3.0.0
5623
- # or later.
5692
+ # <strong>Deprecated in version 3.0</strong>. This method is incompatible with
5693
+ # OpenSSL 3.0.0 or later.
5624
5694
  #
5625
5695
  # See also OpenSSL::PKey.generate_key.
5626
5696
  #
@@ -5642,11 +5712,12 @@ module OpenSSL
5642
5712
  def p: () -> BN
5643
5713
 
5644
5714
  # <!--
5645
- # rdoc-file=ext/openssl/ossl_pkey_dh.c
5715
+ # rdoc-file=ext/openssl/lib/openssl/pkey.rb
5646
5716
  # - dh.params -> hash
5647
5717
  # -->
5648
- # Stores all parameters of key to the hash INSECURE: PRIVATE INFORMATIONS CAN
5649
- # LEAK OUT!!! Don't use :-)) (I's up to you)
5718
+ # Stores all parameters of key to a Hash.
5719
+ #
5720
+ # The hash has keys 'p', 'q', 'g', 'pub_key', and 'priv_key'.
5650
5721
  #
5651
5722
  def params: () -> Hash[String, BN?]
5652
5723
 
@@ -5798,7 +5869,8 @@ module OpenSSL
5798
5869
  #
5799
5870
  # If called without arguments, an empty instance without any parameter or key
5800
5871
  # components is created. Use #set_pqg to manually set the parameters afterwards
5801
- # (and optionally #set_key to set private and public key components).
5872
+ # (and optionally #set_key to set private and public key components). This form
5873
+ # is not compatible with OpenSSL 3.0 or later.
5802
5874
  #
5803
5875
  # If a String is given, tries to parse it as a DER- or PEM- encoded parameters.
5804
5876
  # See also OpenSSL::PKey.read which can parse keys of any kinds.
@@ -5817,14 +5889,15 @@ module OpenSSL
5817
5889
  #
5818
5890
  # Examples:
5819
5891
  # # Creating an instance from scratch
5820
- # # Note that this is deprecated and will not work on OpenSSL 3.0 or later.
5892
+ # # Note that this is deprecated and will result in ArgumentError when
5893
+ # # using OpenSSL 3.0 or later.
5821
5894
  # dh = OpenSSL::PKey::DH.new
5822
5895
  # dh.set_pqg(bn_p, nil, bn_g)
5823
5896
  #
5824
5897
  # # Generating a parameters and a key pair
5825
5898
  # dh = OpenSSL::PKey::DH.new(2048) # An alias of OpenSSL::PKey::DH.generate(2048)
5826
5899
  #
5827
- # # Reading DH parameters
5900
+ # # Reading DH parameters from a PEM-encoded string
5828
5901
  # dh_params = OpenSSL::PKey::DH.new(File.read('parameters.pem')) # loads parameters only
5829
5902
  # dh = OpenSSL::PKey.generate_key(dh_params) # generates a key pair
5830
5903
  #
@@ -5922,8 +5995,8 @@ module OpenSSL
5922
5995
  # will not be available on FIPS-compliant systems.
5923
5996
  #
5924
5997
  #
5925
- # **This method is kept for compatibility.** This should only be used when the
5926
- # traditional, non-standard OpenSSL format is required.
5998
+ # <strong>This method is kept for compatibility.</strong> This should only be
5999
+ # used when the traditional, non-standard OpenSSL format is required.
5927
6000
  #
5928
6001
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
5929
6002
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -5936,11 +6009,12 @@ module OpenSSL
5936
6009
  def p: () -> BN
5937
6010
 
5938
6011
  # <!--
5939
- # rdoc-file=ext/openssl/ossl_pkey_dsa.c
6012
+ # rdoc-file=ext/openssl/lib/openssl/pkey.rb
5940
6013
  # - dsa.params -> hash
5941
6014
  # -->
5942
- # Stores all parameters of key to the hash INSECURE: PRIVATE INFORMATIONS CAN
5943
- # LEAK OUT!!! Don't use :-)) (I's up to you)
6015
+ # Stores all parameters of key to a Hash.
6016
+ #
6017
+ # The hash has keys 'p', 'q', 'g', 'pub_key', and 'priv_key'.
5944
6018
  #
5945
6019
  def params: () -> Hash[String, BN?]
5946
6020
 
@@ -6007,8 +6081,8 @@ module OpenSSL
6007
6081
  # to be an already-computed message digest of the original input data. The
6008
6082
  # signature is issued using the private key of this DSA instance.
6009
6083
  #
6010
- # **Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and
6011
- # PKey::PKey#verify_raw instead.
6084
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#sign_raw
6085
+ # and PKey::PKey#verify_raw instead.
6012
6086
  #
6013
6087
  # `string`
6014
6088
  # : A message digest of the original input data to be signed.
@@ -6036,8 +6110,8 @@ module OpenSSL
6036
6110
  # Verifies whether the signature is valid given the message digest input. It
6037
6111
  # does so by validating `sig` using the public key of this DSA instance.
6038
6112
  #
6039
- # **Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and
6040
- # PKey::PKey#verify_raw instead.
6113
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#sign_raw
6114
+ # and PKey::PKey#verify_raw instead.
6041
6115
  #
6042
6116
  # `digest`
6043
6117
  # : A message digest of the original input data to be signed.
@@ -6055,8 +6129,8 @@ module OpenSSL
6055
6129
  #
6056
6130
  # See #to_pem for details.
6057
6131
  #
6058
- # **This method is kept for compatibility.** This should only be used when the
6059
- # traditional, non-standard OpenSSL format is required.
6132
+ # <strong>This method is kept for compatibility.</strong> This should only be
6133
+ # used when the traditional, non-standard OpenSSL format is required.
6060
6134
  #
6061
6135
  # Consider using #public_to_der or #private_to_der instead.
6062
6136
  #
@@ -6108,8 +6182,8 @@ module OpenSSL
6108
6182
  # will not be available on FIPS-compliant systems.
6109
6183
  #
6110
6184
  #
6111
- # **This method is kept for compatibility.** This should only be used when the
6112
- # traditional, non-standard OpenSSL format is required.
6185
+ # <strong>This method is kept for compatibility.</strong> This should only be
6186
+ # used when the traditional, non-standard OpenSSL format is required.
6113
6187
  #
6114
6188
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
6115
6189
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -6162,8 +6236,8 @@ module OpenSSL
6162
6236
  # will not be available on FIPS-compliant systems.
6163
6237
  #
6164
6238
  #
6165
- # **This method is kept for compatibility.** This should only be used when the
6166
- # traditional, non-standard OpenSSL format is required.
6239
+ # <strong>This method is kept for compatibility.</strong> This should only be
6240
+ # used when the traditional, non-standard OpenSSL format is required.
6167
6241
  #
6168
6242
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
6169
6243
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -6190,7 +6264,8 @@ module OpenSSL
6190
6264
  # Creates a new DSA instance by reading an existing key from *string*.
6191
6265
  #
6192
6266
  # If called without arguments, creates a new instance with no key components
6193
- # set. They can be set individually by #set_pqg and #set_key.
6267
+ # set. They can be set individually by #set_pqg and #set_key. This form is not
6268
+ # compatible with OpenSSL 3.0 or later.
6194
6269
  #
6195
6270
  # If called with a String, tries to parse as DER or PEM encoding of a DSA key.
6196
6271
  # See also OpenSSL::PKey.read which can parse keys of any kinds.
@@ -6301,8 +6376,8 @@ module OpenSSL
6301
6376
  # rdoc-file=ext/openssl/lib/openssl/pkey.rb
6302
6377
  # - key.dsa_sign_asn1(data) -> String
6303
6378
  # -->
6304
- # **Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and
6305
- # PKey::PKey#verify_raw instead.
6379
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#sign_raw
6380
+ # and PKey::PKey#verify_raw instead.
6306
6381
  #
6307
6382
  def dsa_sign_asn1: (String digest) -> String
6308
6383
 
@@ -6310,8 +6385,8 @@ module OpenSSL
6310
6385
  # rdoc-file=ext/openssl/lib/openssl/pkey.rb
6311
6386
  # - key.dsa_verify_asn1(data, sig) -> true | false
6312
6387
  # -->
6313
- # **Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and
6314
- # PKey::PKey#verify_raw instead.
6388
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#sign_raw
6389
+ # and PKey::PKey#verify_raw instead.
6315
6390
  #
6316
6391
  def dsa_verify_asn1: (String digest, String signature) -> bool
6317
6392
 
@@ -6365,8 +6440,8 @@ module OpenSSL
6365
6440
  # will not be available on FIPS-compliant systems.
6366
6441
  #
6367
6442
  #
6368
- # **This method is kept for compatibility.** This should only be used when the
6369
- # SEC 1/RFC 5915 ECPrivateKey format is required.
6443
+ # <strong>This method is kept for compatibility.</strong> This should only be
6444
+ # used when the SEC 1/RFC 5915 ECPrivateKey format is required.
6370
6445
  #
6371
6446
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
6372
6447
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -6491,8 +6566,8 @@ module OpenSSL
6491
6566
  #
6492
6567
  # See #to_pem for details.
6493
6568
  #
6494
- # **This method is kept for compatibility.** This should only be used when the
6495
- # SEC 1/RFC 5915 ECPrivateKey format is required.
6569
+ # <strong>This method is kept for compatibility.</strong> This should only be
6570
+ # used when the SEC 1/RFC 5915 ECPrivateKey format is required.
6496
6571
  #
6497
6572
  # Consider using #public_to_der or #private_to_der instead.
6498
6573
  #
@@ -6544,8 +6619,8 @@ module OpenSSL
6544
6619
  # will not be available on FIPS-compliant systems.
6545
6620
  #
6546
6621
  #
6547
- # **This method is kept for compatibility.** This should only be used when the
6548
- # SEC 1/RFC 5915 ECPrivateKey format is required.
6622
+ # <strong>This method is kept for compatibility.</strong> This should only be
6623
+ # used when the SEC 1/RFC 5915 ECPrivateKey format is required.
6549
6624
  #
6550
6625
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
6551
6626
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -6638,9 +6713,10 @@ module OpenSSL
6638
6713
 
6639
6714
  # <!--
6640
6715
  # rdoc-file=ext/openssl/ossl_pkey_ec.c
6641
- # - group.curve_name => String
6716
+ # - group.curve_name -> string or nil
6642
6717
  # -->
6643
- # Returns the curve name (sn).
6718
+ # Returns the curve name (short name) corresponding to this group, or `nil` if
6719
+ # OpenSSL does not have an OID associated with the group.
6644
6720
  #
6645
6721
  # See the OpenSSL documentation for EC_GROUP_get_curve_name()
6646
6722
  #
@@ -6702,14 +6778,14 @@ module OpenSSL
6702
6778
  #
6703
6779
  # *format* can be one of these:
6704
6780
  #
6705
- # `:compressed`
6781
+ # <code>:compressed</code>
6706
6782
  # : Encoded as z||x, where z is an octet indicating which solution of the
6707
6783
  # equation y is. z will be 0x02 or 0x03.
6708
6784
  #
6709
- # `:uncompressed`
6785
+ # <code>:uncompressed</code>
6710
6786
  # : Encoded as z||x||y, where z is an octet 0x04.
6711
6787
  #
6712
- # `:hybrid`
6788
+ # <code>:hybrid</code>
6713
6789
  # : Encodes as z||x||y, where z is an octet indicating which solution of the
6714
6790
  # equation y is. z will be 0x06 or 0x07.
6715
6791
  #
@@ -6850,18 +6926,16 @@ module OpenSSL
6850
6926
  # <!--
6851
6927
  # rdoc-file=ext/openssl/ossl_pkey_ec.c
6852
6928
  # - point.mul(bn1 [, bn2]) => point
6853
- # - point.mul(bns, points [, bn2]) => point
6854
6929
  # -->
6855
6930
  # Performs elliptic curve point multiplication.
6856
6931
  #
6857
- # The first form calculates `bn1 * point + bn2 * G`, where `G` is the generator
6858
- # of the group of *point*. *bn2* may be omitted, and in that case, the result is
6859
- # just `bn1 * point`.
6932
+ # The first form calculates <code>bn1 * point + bn2 * G</code>, where `G` is the
6933
+ # generator of the group of *point*. *bn2* may be omitted, and in that case, the
6934
+ # result is just <code>bn1 * point</code>.
6860
6935
  #
6861
- # The second form calculates `bns[0] * point + bns[1] * points[0] + ... +
6862
- # bns[-1] * points[-1] + bn2 * G`. *bn2* may be omitted. *bns* must be an array
6863
- # of OpenSSL::BN. *points* must be an array of OpenSSL::PKey::EC::Point. Please
6864
- # note that `points[0]` is not multiplied by `bns[0]`, but `bns[1]`.
6936
+ # Before version 4.0.0, and when compiled with OpenSSL 1.1.1 or older, this
6937
+ # method allowed another form:
6938
+ # point.mul(bns, points [, bn2]) => point
6865
6939
  #
6866
6940
  def mul: (bn bn1, ?bn bn2) -> self
6867
6941
  | (Array[bn] bns, Array[self], ?bn bn2) -> self
@@ -6902,9 +6976,9 @@ module OpenSSL
6902
6976
  #
6903
6977
  # *conversion_form* specifies how the point is converted. Possible values are:
6904
6978
  #
6905
- # * `:compressed`
6906
- # * `:uncompressed`
6907
- # * `:hybrid`
6979
+ # * <code>:compressed</code>
6980
+ # * <code>:uncompressed</code>
6981
+ # * <code>:hybrid</code>
6908
6982
  #
6909
6983
  def to_octet_string: (point_conversion_format) -> String
6910
6984
 
@@ -7103,6 +7177,15 @@ module OpenSSL
7103
7177
  # <!-- rdoc-file=ext/openssl/ossl_pkey.c -->
7104
7178
  # Raised when errors occur during PKey#sign or PKey#verify.
7105
7179
  #
7180
+ # Before version 4.0.0, OpenSSL::PKey::PKeyError had the following subclasses.
7181
+ # These subclasses have been removed and the constants are now defined as
7182
+ # aliases of OpenSSL::PKey::PKeyError.
7183
+ #
7184
+ # * OpenSSL::PKey::DHError
7185
+ # * OpenSSL::PKey::DSAError
7186
+ # * OpenSSL::PKey::ECError
7187
+ # * OpenSSL::PKey::RSAError
7188
+ #
7106
7189
  class PKeyError < OpenSSL::OpenSSLError
7107
7190
  end
7108
7191
 
@@ -7194,8 +7277,8 @@ module OpenSSL
7194
7277
  # will not be available on FIPS-compliant systems.
7195
7278
  #
7196
7279
  #
7197
- # **This method is kept for compatibility.** This should only be used when the
7198
- # PKCS #1 RSAPrivateKey format is required.
7280
+ # <strong>This method is kept for compatibility.</strong> This should only be
7281
+ # used when the PKCS #1 RSAPrivateKey format is required.
7199
7282
  #
7200
7283
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
7201
7284
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -7210,15 +7293,12 @@ module OpenSSL
7210
7293
  def p: () -> BN?
7211
7294
 
7212
7295
  # <!--
7213
- # rdoc-file=ext/openssl/ossl_pkey_rsa.c
7214
- # - rsa.params => hash
7296
+ # rdoc-file=ext/openssl/lib/openssl/pkey.rb
7297
+ # - rsa.params -> hash
7215
7298
  # -->
7216
- # THIS METHOD IS INSECURE, PRIVATE INFORMATION CAN LEAK OUT!!!
7217
- #
7218
- # Stores all parameters of key to the hash. The hash has keys 'n', 'e', 'd',
7219
- # 'p', 'q', 'dmp1', 'dmq1', 'iqmp'.
7299
+ # Stores all parameters of key to a Hash.
7220
7300
  #
7221
- # Don't use :-)) (It's up to you)
7301
+ # The hash has keys 'n', 'e', 'd', 'p', 'q', 'dmp1', 'dmq1', and 'iqmp'.
7222
7302
  #
7223
7303
  def params: () -> Hash[String, BN?]
7224
7304
 
@@ -7239,8 +7319,8 @@ module OpenSSL
7239
7319
  # private key. `padding` defaults to PKCS1_PADDING, which is known to be
7240
7320
  # insecure but is kept for backwards compatibility.
7241
7321
  #
7242
- # **Deprecated in version 3.0**. Consider using PKey::PKey#encrypt and
7243
- # PKey::PKey#decrypt instead.
7322
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#encrypt
7323
+ # and PKey::PKey#decrypt instead.
7244
7324
  #
7245
7325
  def private_decrypt: (String data, ?Integer padding) -> String
7246
7326
 
@@ -7253,8 +7333,8 @@ module OpenSSL
7253
7333
  # which is known to be insecure but is kept for backwards compatibility. The
7254
7334
  # encrypted string output can be decrypted using #public_decrypt.
7255
7335
  #
7256
- # **Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and
7257
- # PKey::PKey#verify_raw, and PKey::PKey#verify_recover instead.
7336
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#sign_raw
7337
+ # and PKey::PKey#verify_raw, and PKey::PKey#verify_recover instead.
7258
7338
  #
7259
7339
  def private_encrypt: (String data, ?Integer padding) -> String
7260
7340
 
@@ -7276,8 +7356,8 @@ module OpenSSL
7276
7356
  # public key. `padding` defaults to PKCS1_PADDING which is known to be insecure
7277
7357
  # but is kept for backwards compatibility.
7278
7358
  #
7279
- # **Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and
7280
- # PKey::PKey#verify_raw, and PKey::PKey#verify_recover instead.
7359
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#sign_raw
7360
+ # and PKey::PKey#verify_raw, and PKey::PKey#verify_recover instead.
7281
7361
  #
7282
7362
  def public_decrypt: (String data, ?Integer padding) -> String
7283
7363
 
@@ -7290,8 +7370,8 @@ module OpenSSL
7290
7370
  # which is known to be insecure but is kept for backwards compatibility. The
7291
7371
  # encrypted string output can be decrypted using #private_decrypt.
7292
7372
  #
7293
- # **Deprecated in version 3.0**. Consider using PKey::PKey#encrypt and
7294
- # PKey::PKey#decrypt instead.
7373
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#encrypt
7374
+ # and PKey::PKey#decrypt instead.
7295
7375
  #
7296
7376
  def public_encrypt: (String data, ?Integer padding) -> String
7297
7377
 
@@ -7315,8 +7395,9 @@ module OpenSSL
7315
7395
  # rdoc-file=ext/openssl/ossl_pkey_rsa.c
7316
7396
  # - rsa.set_crt_params(dmp1, dmq1, iqmp) -> self
7317
7397
  # -->
7318
- # Sets *dmp1*, *dmq1*, *iqmp* for the RSA instance. They are calculated by `d
7319
- # mod (p - 1)`, `d mod (q - 1)` and `q^(-1) mod p` respectively.
7398
+ # Sets *dmp1*, *dmq1*, *iqmp* for the RSA instance. They are calculated by
7399
+ # <code>d mod (p - 1)</code>, <code>d mod (q - 1)</code> and <code>q^(-1) mod
7400
+ # p</code> respectively.
7320
7401
  #
7321
7402
  def set_crt_params: (bn dmp1, bn dmq1, bn iqmp) -> self
7322
7403
 
@@ -7343,7 +7424,7 @@ module OpenSSL
7343
7424
  # Signs *data* using the Probabilistic Signature Scheme (RSA-PSS) and returns
7344
7425
  # the calculated signature.
7345
7426
  #
7346
- # RSAError will be raised if an error occurs.
7427
+ # PKeyError will be raised if an error occurs.
7347
7428
  #
7348
7429
  # See #verify_pss for the verification operation.
7349
7430
  #
@@ -7356,9 +7437,9 @@ module OpenSSL
7356
7437
  #
7357
7438
  # *salt_length*
7358
7439
  # : The length in octets of the salt. Two special values are reserved:
7359
- # `:digest` means the digest length, and `:max` means the maximum possible
7360
- # length for the combination of the private key and the selected message
7361
- # digest algorithm.
7440
+ # <code>:digest</code> means the digest length, and <code>:max</code> means
7441
+ # the maximum possible length for the combination of the private key and the
7442
+ # selected message digest algorithm.
7362
7443
  #
7363
7444
  # *mgf1_hash*
7364
7445
  # : The hash algorithm used in MGF1 (the currently supported mask generation
@@ -7383,8 +7464,8 @@ module OpenSSL
7383
7464
  #
7384
7465
  # See #to_pem for details.
7385
7466
  #
7386
- # **This method is kept for compatibility.** This should only be used when the
7387
- # PKCS #1 RSAPrivateKey format is required.
7467
+ # <strong>This method is kept for compatibility.</strong> This should only be
7468
+ # used when the PKCS #1 RSAPrivateKey format is required.
7388
7469
  #
7389
7470
  # Consider using #public_to_der or #private_to_der instead.
7390
7471
  #
@@ -7436,8 +7517,8 @@ module OpenSSL
7436
7517
  # will not be available on FIPS-compliant systems.
7437
7518
  #
7438
7519
  #
7439
- # **This method is kept for compatibility.** This should only be used when the
7440
- # PKCS #1 RSAPrivateKey format is required.
7520
+ # <strong>This method is kept for compatibility.</strong> This should only be
7521
+ # used when the PKCS #1 RSAPrivateKey format is required.
7441
7522
  #
7442
7523
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
7443
7524
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -7490,8 +7571,8 @@ module OpenSSL
7490
7571
  # will not be available on FIPS-compliant systems.
7491
7572
  #
7492
7573
  #
7493
- # **This method is kept for compatibility.** This should only be used when the
7494
- # PKCS #1 RSAPrivateKey format is required.
7574
+ # <strong>This method is kept for compatibility.</strong> This should only be
7575
+ # used when the PKCS #1 RSAPrivateKey format is required.
7495
7576
  #
7496
7577
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
7497
7578
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -7517,7 +7598,7 @@ module OpenSSL
7517
7598
  # Verifies *data* using the Probabilistic Signature Scheme (RSA-PSS).
7518
7599
  #
7519
7600
  # The return value is `true` if the signature is valid, `false` otherwise.
7520
- # RSAError will be raised if an error occurs.
7601
+ # PKeyError will be raised if an error occurs.
7521
7602
  #
7522
7603
  # See #sign_pss for the signing operation and an example code.
7523
7604
  #
@@ -7530,8 +7611,8 @@ module OpenSSL
7530
7611
  #
7531
7612
  # *salt_length*
7532
7613
  # : The length in octets of the salt. Two special values are reserved:
7533
- # `:digest` means the digest length, and `:auto` means automatically
7534
- # determining the length based on the signature.
7614
+ # <code>:digest</code> means the digest length, and <code>:auto</code> means
7615
+ # automatically determining the length based on the signature.
7535
7616
  #
7536
7617
  # *mgf1_hash*
7537
7618
  # : The hash algorithm used in MGF1.
@@ -7551,7 +7632,7 @@ module OpenSSL
7551
7632
  #
7552
7633
  # If called without arguments, creates a new instance with no key components
7553
7634
  # set. They can be set individually by #set_key, #set_factors, and
7554
- # #set_crt_params.
7635
+ # #set_crt_params. This form is not compatible with OpenSSL 3.0 or later.
7555
7636
  #
7556
7637
  # If called with a String, tries to parse as DER or PEM encoding of an RSA key.
7557
7638
  # Note that if *password* is not specified, but the key is encrypted with a
@@ -7586,10 +7667,17 @@ module OpenSSL
7586
7667
  SSLV23_PADDING: Integer
7587
7668
  end
7588
7669
 
7589
- # <!-- rdoc-file=ext/openssl/ossl_pkey_rsa.c -->
7590
- # Generic exception that is raised if an operation on an RSA PKey fails
7591
- # unexpectedly or in case an instantiation of an instance of RSA fails due to
7592
- # non-conformant input data.
7670
+ # <!-- rdoc-file=ext/openssl/ossl_pkey.c -->
7671
+ # Raised when errors occur during PKey#sign or PKey#verify.
7672
+ #
7673
+ # Before version 4.0.0, OpenSSL::PKey::PKeyError had the following subclasses.
7674
+ # These subclasses have been removed and the constants are now defined as
7675
+ # aliases of OpenSSL::PKey::PKeyError.
7676
+ #
7677
+ # * OpenSSL::PKey::DHError
7678
+ # * OpenSSL::PKey::DSAError
7679
+ # * OpenSSL::PKey::ECError
7680
+ # * OpenSSL::PKey::RSAError
7593
7681
  #
7594
7682
  class RSAError < OpenSSL::PKey::PKeyError
7595
7683
  end
@@ -8029,9 +8117,14 @@ module OpenSSL
8029
8117
  # - ctx.ciphers = [name, ...]
8030
8118
  # - ctx.ciphers = [[name, version, bits, alg_bits], ...]
8031
8119
  # -->
8032
- # Sets the list of available cipher suites for this context. Note in a server
8033
- # context some ciphers require the appropriate certificates. For example, an
8034
- # RSA cipher suite can only be chosen when an RSA certificate is available.
8120
+ # Sets the list of available cipher suites for TLS 1.2 and below for this
8121
+ # context.
8122
+ #
8123
+ # Note in a server context some ciphers require the appropriate certificates.
8124
+ # For example, an RSA cipher suite can only be chosen when an RSA certificate is
8125
+ # available.
8126
+ #
8127
+ # This method does not affect TLS 1.3 connections. See also #ciphersuites=.
8035
8128
  #
8036
8129
  def ciphers=: (Array[[ String, String, Integer, Integer ]] ciphers) -> void
8037
8130
  | (Array[String] ciphers) -> void
@@ -8067,24 +8160,25 @@ module OpenSSL
8067
8160
  #
8068
8161
  def client_cert_cb=: (^(Session) -> [ X509::Certificate, PKey::PKey ]? client_cert_cb) -> void
8069
8162
 
8070
- # <!--
8071
- # rdoc-file=ext/openssl/ossl_ssl.c
8072
- # - ctx.ecdh_curves = curve_list -> curve_list
8073
- # -->
8074
- # Sets the list of "supported elliptic curves" for this context.
8163
+ # <!-- rdoc-file=ext/openssl/ossl_ssl.c -->
8164
+ # Sets the list of supported groups for key agreement for this context.
8165
+ #
8166
+ # For a TLS client, the list is directly used in the "supported_groups"
8167
+ # extension. For a server, the list is used by OpenSSL to determine the set of
8168
+ # shared supported groups. OpenSSL will pick the most appropriate one from it.
8169
+ #
8170
+ # #ecdh_curves= is a deprecated alias for #groups=.
8075
8171
  #
8076
- # For a TLS client, the list is directly used in the Supported Elliptic Curves
8077
- # Extension. For a server, the list is used by OpenSSL to determine the set of
8078
- # shared curves. OpenSSL will pick the most appropriate one from it.
8172
+ # See also the man page SSL_CTX_set1_groups_list(3).
8079
8173
  #
8080
8174
  # ### Example
8081
8175
  # ctx1 = OpenSSL::SSL::SSLContext.new
8082
- # ctx1.ecdh_curves = "X25519:P-256:P-224"
8176
+ # ctx1.groups = "X25519:P-256:P-224"
8083
8177
  # svr = OpenSSL::SSL::SSLServer.new(tcp_svr, ctx1)
8084
8178
  # Thread.new { svr.accept }
8085
8179
  #
8086
8180
  # ctx2 = OpenSSL::SSL::SSLContext.new
8087
- # ctx2.ecdh_curves = "P-256"
8181
+ # ctx2.groups = "P-256"
8088
8182
  # cli = OpenSSL::SSL::SSLSocket.new(tcp_sock, ctx2)
8089
8183
  # cli.connect
8090
8184
  #
@@ -8149,7 +8243,7 @@ module OpenSSL
8149
8243
  def key=: (PKey::PKey) -> PKey::PKey
8150
8244
 
8151
8245
  # <!--
8152
- # rdoc-file=ext/openssl/lib/openssl/ssl.rb
8246
+ # rdoc-file=ext/openssl/ossl_ssl.c
8153
8247
  # - ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
8154
8248
  # - ctx.max_version = :TLS1_2
8155
8249
  # - ctx.max_version = nil
@@ -8160,7 +8254,7 @@ module OpenSSL
8160
8254
  def max_version=: (tls_version version) -> tls_version
8161
8255
 
8162
8256
  # <!--
8163
- # rdoc-file=ext/openssl/lib/openssl/ssl.rb
8257
+ # rdoc-file=ext/openssl/ossl_ssl.c
8164
8258
  # - ctx.min_version = OpenSSL::SSL::TLS1_2_VERSION
8165
8259
  # - ctx.min_version = :TLS1_2
8166
8260
  # - ctx.min_version = nil
@@ -8169,9 +8263,6 @@ module OpenSSL
8169
8263
  # may be specified by an integer constant named OpenSSL::SSL::*_VERSION, a
8170
8264
  # Symbol, or `nil` which means "any version".
8171
8265
  #
8172
- # Be careful that you don't overwrite OpenSSL::SSL::OP_NO_{SSL,TLS}v* options by
8173
- # #options= once you have called #min_version= or #max_version=.
8174
- #
8175
8266
  # ### Example
8176
8267
  # ctx = OpenSSL::SSL::SSLContext.new
8177
8268
  # ctx.min_version = OpenSSL::SSL::TLS1_1_VERSION
@@ -8255,8 +8346,8 @@ module OpenSSL
8255
8346
  # - ctx.options = integer
8256
8347
  # -->
8257
8348
  # Sets various OpenSSL options. The options are a bit field and can be combined
8258
- # with the bitwise OR operator (`|`). Available options are defined as constants
8259
- # in OpenSSL::SSL that begin with `OP_`.
8349
+ # with the bitwise OR operator (<code>|</code>). Available options are defined
8350
+ # as constants in OpenSSL::SSL that begin with `OP_`.
8260
8351
  #
8261
8352
  # For backwards compatibility, passing `nil` has the same effect as passing
8262
8353
  # OpenSSL::SSL::OP_ALL.
@@ -8581,7 +8672,7 @@ module OpenSSL
8581
8672
  #
8582
8673
  def timeout=: (Integer) -> Integer
8583
8674
 
8584
- # <!-- rdoc-file=ext/openssl/lib/openssl/ssl.rb -->
8675
+ # <!-- rdoc-file=ext/openssl/ossl_ssl.c -->
8585
8676
  # A callback invoked when DH parameters are required for ephemeral DH key
8586
8677
  # exchange.
8587
8678
  #
@@ -8591,11 +8682,11 @@ module OpenSSL
8591
8682
  # The callback must return an OpenSSL::PKey::DH instance of the correct key
8592
8683
  # length.
8593
8684
  #
8594
- # **Deprecated in version 3.0.** Use #tmp_dh= instead.
8685
+ # <strong>Deprecated in version 3.0.</strong> Use #tmp_dh= instead.
8595
8686
  #
8596
8687
  def tmp_dh_callback: () -> (^(Session, Integer, Integer) -> PKey::DH | nil)
8597
8688
 
8598
- # <!-- rdoc-file=ext/openssl/lib/openssl/ssl.rb -->
8689
+ # <!-- rdoc-file=ext/openssl/ossl_ssl.c -->
8599
8690
  # A callback invoked when DH parameters are required for ephemeral DH key
8600
8691
  # exchange.
8601
8692
  #
@@ -8605,7 +8696,7 @@ module OpenSSL
8605
8696
  # The callback must return an OpenSSL::PKey::DH instance of the correct key
8606
8697
  # length.
8607
8698
  #
8608
- # **Deprecated in version 3.0.** Use #tmp_dh= instead.
8699
+ # <strong>Deprecated in version 3.0.</strong> Use #tmp_dh= instead.
8609
8700
  #
8610
8701
  def tmp_dh_callback=: (^(Session, Integer, Integer) -> PKey::DH) -> void
8611
8702
 
@@ -8866,8 +8957,8 @@ module OpenSSL
8866
8957
  # rdoc-file=ext/openssl/lib/openssl/ssl.rb
8867
8958
  # - open(remote_host, remote_port, local_host=nil, local_port=nil, context: nil)
8868
8959
  # -->
8869
- # Creates a new instance of SSLSocket. *remote*host_ and *remote*port_ are used
8870
- # to open TCPSocket. If *local*host_ and *local*port_ are specified, then those
8960
+ # Creates a new instance of SSLSocket. _remote_host_ and _remote_port_ are used
8961
+ # to open TCPSocket. If _local_host_ and _local_port_ are specified, then those
8871
8962
  # parameters are used on the local end to establish the connection. If *context*
8872
8963
  # is provided, the SSL Sockets initial params will be taken from the context.
8873
8964
  #
@@ -8911,7 +9002,8 @@ module OpenSSL
8911
9002
  #
8912
9003
  # By specifying a keyword argument *exception* to `false`, you can indicate that
8913
9004
  # accept_nonblock should not raise an IO::WaitReadable or IO::WaitWritable
8914
- # exception, but return the symbol `:wait_readable` or `:wait_writable` instead.
9005
+ # exception, but return the symbol <code>:wait_readable</code> or
9006
+ # <code>:wait_writable</code> instead.
8915
9007
  #
8916
9008
  def accept_nonblock: (?exception: true) -> self
8917
9009
  | (exception: false) -> (self | :wait_readable | :wait_writable)
@@ -8944,7 +9036,7 @@ module OpenSSL
8944
9036
 
8945
9037
  # <!--
8946
9038
  # rdoc-file=ext/openssl/ossl_ssl.c
8947
- # - ssl.client_ca => [x509name, ...]
9039
+ # - ssl.client_ca => [x509name, ...] or nil
8948
9040
  # -->
8949
9041
  # Returns the list of client CAs. Please note that in contrast to
8950
9042
  # SSLContext#client_ca= no array of X509::Certificate is returned but X509::Name
@@ -8982,7 +9074,8 @@ module OpenSSL
8982
9074
  #
8983
9075
  # By specifying a keyword argument *exception* to `false`, you can indicate that
8984
9076
  # connect_nonblock should not raise an IO::WaitReadable or IO::WaitWritable
8985
- # exception, but return the symbol `:wait_readable` or `:wait_writable` instead.
9077
+ # exception, but return the symbol <code>:wait_readable</code> or
9078
+ # <code>:wait_writable</code> instead.
8986
9079
  #
8987
9080
  def connect_nonblock: (?exception: true) -> self
8988
9081
  | (exception: false) -> (self | :wait_readable | :wait_writable)
@@ -9498,9 +9591,10 @@ module OpenSSL
9498
9591
  # Assume we received a timestamp request that has set Request#policy_id to `nil`
9499
9592
  # and Request#cert_requested? to true. The raw request bytes are stored in a
9500
9593
  # variable called `req_raw`. We'd still like to integrate the necessary
9501
- # intermediate certificates (in `inter1.cer` and `inter2.cer`) to simplify
9502
- # validation of the resulting Response. `ts.p12` is a PKCS#12-compatible file
9503
- # including the private key and the timestamping certificate.
9594
+ # intermediate certificates (in <code>inter1.cer</code> and
9595
+ # <code>inter2.cer</code>) to simplify validation of the resulting Response.
9596
+ # <code>ts.p12</code> is a PKCS#12-compatible file including the private key and
9597
+ # the timestamping certificate.
9504
9598
  #
9505
9599
  # req = OpenSSL::Timestamp::Request.new(raw_bytes)
9506
9600
  # p12 = OpenSSL::PKCS12.new(File.binread('ts.p12'), 'pwd')
@@ -9515,65 +9609,33 @@ module OpenSSL
9515
9609
  # fac.additional_certificates = [ inter1, inter2 ]
9516
9610
  # timestamp = fac.create_timestamp(p12.key, p12.certificate, req)
9517
9611
  #
9518
- # ## Attributes
9519
- #
9520
- # ### default_policy_id
9521
- #
9522
- # Request#policy_id will always be preferred over this if present in the
9523
- # Request, only if Request#policy_id is nil default_policy will be used. If none
9524
- # of both is present, a TimestampError will be raised when trying to create a
9525
- # Response.
9526
- #
9527
- # call-seq:
9528
- # factory.default_policy_id = "string" -> string
9529
- # factory.default_policy_id -> string or nil
9530
- #
9531
- # ### serial_number
9532
- #
9533
- # Sets or retrieves the serial number to be used for timestamp creation. Must be
9534
- # present for timestamp creation.
9535
- #
9536
- # call-seq:
9537
- # factory.serial_number = number -> number
9538
- # factory.serial_number -> number or nil
9539
- #
9540
- # ### gen_time
9541
- #
9542
- # Sets or retrieves the Time value to be used in the Response. Must be present
9543
- # for timestamp creation.
9544
- #
9545
- # call-seq:
9546
- # factory.gen_time = Time -> Time
9547
- # factory.gen_time -> Time or nil
9548
- #
9549
- # ### additional_certs
9550
- #
9551
- # Sets or retrieves additional certificates apart from the timestamp certificate
9552
- # (e.g. intermediate certificates) to be added to the Response. Must be an Array
9553
- # of OpenSSL::X509::Certificate.
9554
- #
9555
- # call-seq:
9556
- # factory.additional_certs = [cert1, cert2] -> [ cert1, cert2 ]
9557
- # factory.additional_certs -> array or nil
9558
- #
9559
- # ### allowed_digests
9560
- #
9561
- # Sets or retrieves the digest algorithms that the factory is allowed create
9562
- # timestamps for. Known vulnerable or weak algorithms should not be allowed
9563
- # where possible. Must be an Array of String or OpenSSL::Digest subclass
9564
- # instances.
9565
- #
9566
- # call-seq:
9567
- # factory.allowed_digests = ["sha1", OpenSSL::Digest.new('SHA256').new] -> [ "sha1", OpenSSL::Digest) ]
9568
- # factory.allowed_digests -> array or nil
9569
- #
9570
9612
  class Factory
9613
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9614
+ # Additional certificates apart from the timestamp certificate (e.g.
9615
+ # intermediate certificates) to be added to the Response. Must be an Array of
9616
+ # OpenSSL::X509::Certificate, or `nil`.
9617
+ #
9571
9618
  def additional_certs: () -> Array[X509::Certificate]?
9572
9619
 
9620
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9621
+ # Additional certificates apart from the timestamp certificate (e.g.
9622
+ # intermediate certificates) to be added to the Response. Must be an Array of
9623
+ # OpenSSL::X509::Certificate, or `nil`.
9624
+ #
9573
9625
  def additional_certs=: (Array[X509::Certificate]? certs) -> Array[X509::Certificate]?
9574
9626
 
9627
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9628
+ # The list of digest algorithms that the factory is allowed create timestamps
9629
+ # for. Known vulnerable or weak algorithms should not be allowed where possible.
9630
+ # Must be an Array of String or OpenSSL::Digest subclass instances.
9631
+ #
9575
9632
  def allowed_digests: () -> Array[String | Digest]?
9576
9633
 
9634
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9635
+ # The list of digest algorithms that the factory is allowed create timestamps
9636
+ # for. Known vulnerable or weak algorithms should not be allowed where possible.
9637
+ # Must be an Array of String or OpenSSL::Digest subclass instances.
9638
+ #
9577
9639
  def allowed_digests=: (Array[String | Digest]) -> Array[String | Digest]
9578
9640
 
9579
9641
  # <!--
@@ -9602,16 +9664,48 @@ module OpenSSL
9602
9664
  #
9603
9665
  def create_timestamp: (PKey::PKey key, X509::Certificate cert, Request request) -> Response
9604
9666
 
9667
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9668
+ # A String representing the default policy object identifier, or `nil`.
9669
+ #
9670
+ # Request#policy_id will always be preferred over this if present in the
9671
+ # Request, only if Request#policy_id is `nil` default_policy will be used. If
9672
+ # none of both is present, a TimestampError will be raised when trying to create
9673
+ # a Response.
9674
+ #
9605
9675
  def default_policy_id: () -> String?
9606
9676
 
9677
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9678
+ # A String representing the default policy object identifier, or `nil`.
9679
+ #
9680
+ # Request#policy_id will always be preferred over this if present in the
9681
+ # Request, only if Request#policy_id is `nil` default_policy will be used. If
9682
+ # none of both is present, a TimestampError will be raised when trying to create
9683
+ # a Response.
9684
+ #
9607
9685
  def default_policy_id=: (String) -> String
9608
9686
 
9687
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9688
+ # The Time value to be used in the Response. Must be present for timestamp
9689
+ # creation.
9690
+ #
9609
9691
  def gen_time: () -> Time?
9610
9692
 
9693
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9694
+ # The Time value to be used in the Response. Must be present for timestamp
9695
+ # creation.
9696
+ #
9611
9697
  def gen_time=: (Time) -> Time
9612
9698
 
9699
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9700
+ # The serial number to be used for timestamp creation. Must be present for
9701
+ # timestamp creation. Must be an instance of OpenSSL::BN or Integer.
9702
+ #
9613
9703
  def serial_number: () -> Integer?
9614
9704
 
9705
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9706
+ # The serial number to be used for timestamp creation. Must be present for
9707
+ # timestamp creation. Must be an instance of OpenSSL::BN or Integer.
9708
+ #
9615
9709
  def serial_number=: (Integer) -> Integer
9616
9710
  end
9617
9711
 
@@ -10305,8 +10399,10 @@ module OpenSSL
10305
10399
 
10306
10400
  # <!--
10307
10401
  # rdoc-file=ext/openssl/ossl_x509attr.c
10308
- # - attr.oid => string
10402
+ # - attr.oid -> string
10309
10403
  # -->
10404
+ # Returns the OID of the attribute. Returns the short name or the dotted decimal
10405
+ # notation.
10310
10406
  #
10311
10407
  def oid: () -> String
10312
10408
 
@@ -10468,8 +10564,12 @@ module OpenSSL
10468
10564
 
10469
10565
  # <!--
10470
10566
  # rdoc-file=ext/openssl/ossl_x509crl.c
10471
- # - signature_algorithm()
10567
+ # - crl.signature_algorithm -> string
10472
10568
  # -->
10569
+ # Returns the signature algorithm used to sign this CRL.
10570
+ #
10571
+ # Returns the long name of the signature algorithm, or the dotted decimal
10572
+ # notation if OpenSSL does not define a long name for it.
10473
10573
  #
10474
10574
  def signature_algorithm: () -> String
10475
10575
 
@@ -10649,6 +10749,12 @@ module OpenSSL
10649
10749
  # Compares the two certificates. Note that this takes into account all fields,
10650
10750
  # not just the issuer name and the serial number.
10651
10751
  #
10752
+ # This method uses X509_cmp() from OpenSSL, which compares certificates based on
10753
+ # their cached DER encodings. The comparison can be unreliable if a certificate
10754
+ # is incomplete.
10755
+ #
10756
+ # See also the man page X509_cmp(3).
10757
+ #
10652
10758
  def ==: (self other) -> bool
10653
10759
 
10654
10760
  # <!--
@@ -10682,7 +10788,7 @@ module OpenSSL
10682
10788
  def extensions=: (Array[Extension]) -> Array[Extension]
10683
10789
 
10684
10790
  # <!--
10685
- # rdoc-file=ext/openssl/ossl_x509cert.c
10791
+ # rdoc-file=ext/openssl/lib/openssl/x509.rb
10686
10792
  # - inspect()
10687
10793
  # -->
10688
10794
  #
@@ -10776,6 +10882,12 @@ module OpenSSL
10776
10882
  # rdoc-file=ext/openssl/ossl_x509cert.c
10777
10883
  # - cert.signature_algorithm => string
10778
10884
  # -->
10885
+ # Returns the signature algorithm used to sign this certificate. This returns
10886
+ # the algorithm name found in the TBSCertificate structure, not the outer
10887
+ # Certificate structure.
10888
+ #
10889
+ # Returns the long name of the signature algorithm, or the dotted decimal
10890
+ # notation if OpenSSL does not define a long name for it.
10779
10891
  #
10780
10892
  def signature_algorithm: () -> String
10781
10893
 
@@ -10893,8 +11005,10 @@ module OpenSSL
10893
11005
 
10894
11006
  # <!--
10895
11007
  # rdoc-file=ext/openssl/ossl_x509ext.c
10896
- # - oid()
11008
+ # - ext.oid -> string
10897
11009
  # -->
11010
+ # Returns the OID of the extension. Returns the short name or the dotted decimal
11011
+ # notation.
10898
11012
  #
10899
11013
  def oid: () -> String
10900
11014
 
@@ -11196,11 +11310,11 @@ module OpenSSL
11196
11310
  # Parses the string representation of a distinguished name. Two different forms
11197
11311
  # are supported:
11198
11312
  #
11199
- # * OpenSSL format (`X509_NAME_oneline()`) used by `#to_s`. For example:
11200
- # `/DC=com/DC=example/CN=nobody`
11201
- # * OpenSSL format (`X509_NAME_print()`) used by
11202
- # `#to_s(OpenSSL::X509::Name::COMPAT)`. For example: `DC=com, DC=example,
11203
- # CN=nobody`
11313
+ # * OpenSSL format (<code>X509_NAME_oneline()</code>) used by
11314
+ # <code>#to_s</code>. For example: <code>/DC=com/DC=example/CN=nobody</code>
11315
+ # * OpenSSL format (<code>X509_NAME_print()</code>) used by
11316
+ # <code>#to_s(OpenSSL::X509::Name::COMPAT)</code>. For example:
11317
+ # <code>DC=com, DC=example, CN=nobody</code>
11204
11318
  #
11205
11319
  # Neither of them is standardized and has quirks and inconsistencies in handling
11206
11320
  # of escaped characters or multi-valued RDNs.
@@ -11222,9 +11336,9 @@ module OpenSSL
11222
11336
  def self.parse_rfc2253: (String str, ?template template) -> instance
11223
11337
 
11224
11338
  # <!-- rdoc-file=ext/openssl/ossl_x509name.c -->
11225
- # Compares this Name with *other* and returns `0` if they are the same and `-1`
11226
- # or `+1` if they are greater or less than each other respectively. Returns
11227
- # `nil` if they are not comparable (i.e. different types).
11339
+ # Compares this Name with *other* and returns `0` if they are the same and
11340
+ # <code>-1</code> or ++1+ if they are greater or less than each other
11341
+ # respectively. Returns `nil` if they are not comparable (i.e. different types).
11228
11342
  #
11229
11343
  alias <=> cmp
11230
11344
 
@@ -11266,9 +11380,9 @@ module OpenSSL
11266
11380
  # - name.cmp(other) -> -1 | 0 | 1 | nil
11267
11381
  # - name <=> other -> -1 | 0 | 1 | nil
11268
11382
  # -->
11269
- # Compares this Name with *other* and returns `0` if they are the same and `-1`
11270
- # or `+1` if they are greater or less than each other respectively. Returns
11271
- # `nil` if they are not comparable (i.e. different types).
11383
+ # Compares this Name with *other* and returns `0` if they are the same and
11384
+ # <code>-1</code> or ++1+ if they are greater or less than each other
11385
+ # respectively. Returns `nil` if they are not comparable (i.e. different types).
11272
11386
  #
11273
11387
  def cmp: (untyped other) -> Integer?
11274
11388
 
@@ -11336,14 +11450,14 @@ module OpenSSL
11336
11450
  # * OpenSSL::X509::Name::MULTILINE
11337
11451
  #
11338
11452
  # If *format* is omitted, the largely broken and traditional OpenSSL format
11339
- # (`X509_NAME_oneline()` format) is chosen.
11453
+ # (<code>X509_NAME_oneline()</code> format) is chosen.
11340
11454
  #
11341
- # **Use of this method is discouraged.** None of the formats other than
11342
- # OpenSSL::X509::Name::RFC2253 is standardized and may show an inconsistent
11455
+ # <strong>Use of this method is discouraged.</strong> None of the formats other
11456
+ # than OpenSSL::X509::Name::RFC2253 is standardized and may show an inconsistent
11343
11457
  # behavior through OpenSSL versions.
11344
11458
  #
11345
11459
  # It is recommended to use #to_utf8 instead, which is equivalent to calling
11346
- # `name.to_s(OpenSSL::X509::Name::RFC2253).force_encoding("UTF-8")`.
11460
+ # <code>name.to_s(OpenSSL::X509::Name::RFC2253).force_encoding("UTF-8")</code>.
11347
11461
  #
11348
11462
  def to_s: (?format format) -> String
11349
11463
 
@@ -11547,8 +11661,12 @@ module OpenSSL
11547
11661
 
11548
11662
  # <!--
11549
11663
  # rdoc-file=ext/openssl/ossl_x509req.c
11550
- # - signature_algorithm()
11664
+ # - req.signature_algorithm -> string
11551
11665
  # -->
11666
+ # Returns the signature algorithm used to sign this request.
11667
+ #
11668
+ # Returns the long name of the signature algorithm, or the dotted decimal
11669
+ # notation if OpenSSL does not define a long name for it.
11552
11670
  #
11553
11671
  def signature_algorithm: () -> String
11554
11672