rbs 3.9.4 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (348) hide show
  1. checksums.yaml +4 -4
  2. data/.clang-format +75 -0
  3. data/.clangd +2 -0
  4. data/.dockerignore +37 -0
  5. data/.github/dependabot.yml +16 -14
  6. data/.github/workflows/bundle-update.yml +63 -0
  7. data/.github/workflows/c-check.yml +66 -0
  8. data/.github/workflows/comments.yml +5 -3
  9. data/.github/workflows/dependabot.yml +2 -2
  10. data/.github/workflows/jruby.yml +79 -0
  11. data/.github/workflows/release-gems.yml +164 -0
  12. data/.github/workflows/ruby.yml +84 -30
  13. data/.github/workflows/rust.yml +186 -0
  14. data/.github/workflows/truffleruby.yml +54 -0
  15. data/.github/workflows/typecheck.yml +5 -2
  16. data/.github/workflows/wasm.yml +55 -0
  17. data/.github/workflows/windows.yml +9 -3
  18. data/.gitignore +16 -0
  19. data/.rubocop.yml +2 -2
  20. data/CHANGELOG.md +430 -0
  21. data/Dockerfile.jruby +53 -0
  22. data/README.md +41 -4
  23. data/Rakefile +777 -60
  24. data/Steepfile +11 -0
  25. data/config.yml +660 -62
  26. data/core/array.rbs +541 -398
  27. data/core/basic_object.rbs +9 -8
  28. data/core/binding.rbs +0 -2
  29. data/core/builtin.rbs +9 -8
  30. data/core/class.rbs +11 -8
  31. data/core/comparable.rbs +55 -34
  32. data/core/complex.rbs +104 -78
  33. data/core/dir.rbs +61 -49
  34. data/core/encoding.rbs +12 -15
  35. data/core/enumerable.rbs +297 -196
  36. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  37. data/core/enumerator/product.rbs +5 -5
  38. data/core/enumerator.rbs +91 -28
  39. data/core/errno.rbs +11 -2
  40. data/core/errors.rbs +58 -29
  41. data/core/exception.rbs +13 -13
  42. data/core/fiber.rbs +74 -54
  43. data/core/file.rbs +260 -1151
  44. data/core/file_constants.rbs +463 -0
  45. data/core/file_stat.rbs +534 -0
  46. data/core/file_test.rbs +3 -3
  47. data/core/float.rbs +257 -116
  48. data/core/gc.rbs +425 -281
  49. data/core/hash.rbs +1151 -829
  50. data/core/integer.rbs +156 -195
  51. data/core/io/buffer.rbs +53 -42
  52. data/core/io/wait.rbs +13 -35
  53. data/core/io.rbs +220 -154
  54. data/core/kernel.rbs +239 -163
  55. data/core/marshal.rbs +4 -4
  56. data/core/match_data.rbs +16 -14
  57. data/core/math.rbs +107 -66
  58. data/core/method.rbs +69 -33
  59. data/core/module.rbs +302 -150
  60. data/core/nil_class.rbs +7 -6
  61. data/core/numeric.rbs +77 -63
  62. data/core/object.rbs +9 -11
  63. data/core/object_space/weak_key_map.rbs +7 -7
  64. data/core/object_space.rbs +30 -23
  65. data/core/pathname.rbs +1312 -0
  66. data/core/proc.rbs +95 -58
  67. data/core/process.rbs +222 -202
  68. data/core/ractor.rbs +364 -518
  69. data/core/random.rbs +21 -3
  70. data/core/range.rbs +181 -79
  71. data/core/rational.rbs +60 -89
  72. data/core/rbs/ops.rbs +154 -0
  73. data/core/rbs/unnamed/argf.rbs +63 -56
  74. data/core/rbs/unnamed/env_class.rbs +19 -14
  75. data/core/rbs/unnamed/main_class.rbs +123 -0
  76. data/core/rbs/unnamed/random.rbs +11 -118
  77. data/core/regexp.rbs +258 -214
  78. data/core/ruby.rbs +53 -0
  79. data/core/ruby_vm.rbs +78 -34
  80. data/core/rubygems/config_file.rbs +5 -5
  81. data/core/rubygems/errors.rbs +6 -70
  82. data/core/rubygems/requirement.rbs +5 -15
  83. data/core/rubygems/rubygems.rbs +18 -81
  84. data/core/rubygems/specification.rbs +8 -0
  85. data/core/rubygems/version.rbs +2 -163
  86. data/core/set.rbs +493 -363
  87. data/core/signal.rbs +26 -16
  88. data/core/string.rbs +3234 -1285
  89. data/core/struct.rbs +43 -42
  90. data/core/symbol.rbs +41 -34
  91. data/core/thread.rbs +139 -83
  92. data/core/time.rbs +81 -50
  93. data/core/trace_point.rbs +41 -35
  94. data/core/true_class.rbs +2 -2
  95. data/core/unbound_method.rbs +24 -16
  96. data/core/warning.rbs +7 -7
  97. data/docs/CONTRIBUTING.md +2 -1
  98. data/docs/aliases.md +79 -0
  99. data/docs/collection.md +3 -3
  100. data/docs/config.md +171 -0
  101. data/docs/encoding.md +56 -0
  102. data/docs/gem.md +0 -1
  103. data/docs/inline.md +634 -0
  104. data/docs/rbs_by_example.md +20 -20
  105. data/docs/release.md +151 -0
  106. data/docs/rust.md +96 -0
  107. data/docs/sigs.md +3 -3
  108. data/docs/syntax.md +48 -18
  109. data/docs/type_fingerprint.md +21 -0
  110. data/docs/wasm_serialization.md +80 -0
  111. data/exe/rbs +1 -1
  112. data/ext/rbs_extension/ast_translation.c +1855 -0
  113. data/ext/rbs_extension/ast_translation.h +41 -0
  114. data/ext/rbs_extension/class_constants.c +187 -0
  115. data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +23 -1
  116. data/ext/rbs_extension/compat.h +10 -0
  117. data/ext/rbs_extension/extconf.rb +26 -1
  118. data/ext/rbs_extension/legacy_location.c +299 -0
  119. data/ext/rbs_extension/legacy_location.h +82 -0
  120. data/ext/rbs_extension/main.c +603 -23
  121. data/ext/rbs_extension/rbs_extension.h +6 -21
  122. data/ext/rbs_extension/rbs_string_bridging.c +9 -0
  123. data/ext/rbs_extension/rbs_string_bridging.h +24 -0
  124. data/include/rbs/ast.h +1047 -0
  125. data/include/rbs/defines.h +99 -0
  126. data/include/rbs/lexer.h +207 -0
  127. data/include/rbs/location.h +40 -0
  128. data/include/rbs/parser.h +153 -0
  129. data/include/rbs/serialize.h +39 -0
  130. data/include/rbs/string.h +47 -0
  131. data/include/rbs/util/rbs_allocator.h +59 -0
  132. data/include/rbs/util/rbs_assert.h +20 -0
  133. data/include/rbs/util/rbs_buffer.h +83 -0
  134. data/include/rbs/util/rbs_constant_pool.h +6 -70
  135. data/include/rbs/util/rbs_encoding.h +282 -0
  136. data/include/rbs/util/rbs_unescape.h +24 -0
  137. data/include/rbs.h +9 -2
  138. data/lib/rbs/annotate/formatter.rb +3 -13
  139. data/lib/rbs/annotate/rdoc_annotator.rb +30 -32
  140. data/lib/rbs/annotate/rdoc_source.rb +1 -1
  141. data/lib/rbs/ast/annotation.rb +1 -1
  142. data/lib/rbs/ast/comment.rb +1 -1
  143. data/lib/rbs/ast/declarations.rb +10 -10
  144. data/lib/rbs/ast/members.rb +14 -14
  145. data/lib/rbs/ast/ruby/annotations.rb +451 -0
  146. data/lib/rbs/ast/ruby/comment_block.rb +247 -0
  147. data/lib/rbs/ast/ruby/declarations.rb +291 -0
  148. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +28 -0
  149. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  150. data/lib/rbs/ast/ruby/members.rb +762 -0
  151. data/lib/rbs/ast/type_param.rb +24 -4
  152. data/lib/rbs/buffer.rb +142 -20
  153. data/lib/rbs/cli/diff.rb +16 -15
  154. data/lib/rbs/cli/validate.rb +63 -126
  155. data/lib/rbs/cli.rb +59 -29
  156. data/lib/rbs/collection/config/lockfile_generator.rb +28 -3
  157. data/lib/rbs/collection/sources/git.rb +7 -0
  158. data/lib/rbs/definition.rb +6 -1
  159. data/lib/rbs/definition_builder/ancestor_builder.rb +121 -65
  160. data/lib/rbs/definition_builder/method_builder.rb +74 -33
  161. data/lib/rbs/definition_builder.rb +177 -20
  162. data/lib/rbs/diff.rb +7 -1
  163. data/lib/rbs/environment/class_entry.rb +69 -0
  164. data/lib/rbs/environment/module_entry.rb +66 -0
  165. data/lib/rbs/environment.rb +410 -215
  166. data/lib/rbs/environment_loader.rb +2 -8
  167. data/lib/rbs/errors.rb +31 -21
  168. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  169. data/lib/rbs/inline_parser.rb +568 -0
  170. data/lib/rbs/location_aux.rb +36 -4
  171. data/lib/rbs/locator.rb +5 -1
  172. data/lib/rbs/method_type.rb +5 -3
  173. data/lib/rbs/namespace.rb +47 -18
  174. data/lib/rbs/parser_aux.rb +37 -7
  175. data/lib/rbs/prototype/helpers.rb +57 -0
  176. data/lib/rbs/prototype/rb.rb +3 -28
  177. data/lib/rbs/prototype/rbi.rb +196 -45
  178. data/lib/rbs/prototype/runtime.rb +12 -2
  179. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  180. data/lib/rbs/resolver/type_name_resolver.rb +120 -44
  181. data/lib/rbs/rewriter.rb +70 -0
  182. data/lib/rbs/source.rb +99 -0
  183. data/lib/rbs/subtractor.rb +7 -4
  184. data/lib/rbs/test/type_check.rb +25 -3
  185. data/lib/rbs/type_name.rb +34 -21
  186. data/lib/rbs/types.rb +91 -79
  187. data/lib/rbs/unit_test/convertibles.rb +1 -0
  188. data/lib/rbs/unit_test/type_assertions.rb +44 -8
  189. data/lib/rbs/validator.rb +2 -2
  190. data/lib/rbs/version.rb +1 -1
  191. data/lib/rbs/wasm/deserializer.rb +213 -0
  192. data/lib/rbs/wasm/location.rb +61 -0
  193. data/lib/rbs/wasm/parser.rb +137 -0
  194. data/lib/rbs/wasm/runtime.rb +196 -0
  195. data/lib/rbs/wasm/serialization_schema.rb +110 -0
  196. data/lib/rbs.rb +25 -2
  197. data/lib/rbs_jars.rb +39 -0
  198. data/lib/rdoc/discover.rb +1 -1
  199. data/lib/rdoc_plugin/parser.rb +8 -3
  200. data/rbs.gemspec +37 -5
  201. data/schema/typeParam.json +17 -1
  202. data/sig/ancestor_builder.rbs +1 -1
  203. data/sig/annotate/formatter.rbs +2 -2
  204. data/sig/annotate/rdoc_annotater.rbs +13 -10
  205. data/sig/ast/ruby/annotations.rbs +470 -0
  206. data/sig/ast/ruby/comment_block.rbs +127 -0
  207. data/sig/ast/ruby/declarations.rbs +158 -0
  208. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  209. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  210. data/sig/ast/ruby/members.rbs +198 -0
  211. data/sig/buffer.rbs +81 -5
  212. data/sig/cli/diff.rbs +5 -11
  213. data/sig/cli/validate.rbs +12 -8
  214. data/sig/cli.rbs +18 -18
  215. data/sig/collection/config/lockfile_generator.rbs +2 -0
  216. data/sig/definition.rbs +6 -0
  217. data/sig/definition_builder.rbs +3 -1
  218. data/sig/environment/class_entry.rbs +50 -0
  219. data/sig/environment/module_entry.rbs +50 -0
  220. data/sig/environment.rbs +94 -87
  221. data/sig/errors.rbs +26 -20
  222. data/sig/inline_parser/comment_association.rbs +71 -0
  223. data/sig/inline_parser.rbs +126 -0
  224. data/sig/location.rbs +32 -7
  225. data/sig/locator.rbs +0 -2
  226. data/sig/manifest.yaml +0 -2
  227. data/sig/method_builder.rbs +9 -4
  228. data/sig/namespace.rbs +20 -5
  229. data/sig/parser.rbs +77 -13
  230. data/sig/prototype/helpers.rbs +2 -0
  231. data/sig/prototype/rbi.rbs +33 -4
  232. data/sig/resolver/type_name_resolver.rbs +36 -10
  233. data/sig/rewriter.rbs +45 -0
  234. data/sig/source.rbs +48 -0
  235. data/sig/type_param.rbs +13 -8
  236. data/sig/typename.rbs +15 -5
  237. data/sig/types.rbs +10 -8
  238. data/sig/unit_test/spy.rbs +0 -8
  239. data/sig/unit_test/type_assertions.rbs +15 -0
  240. data/sig/wasm/deserializer.rbs +66 -0
  241. data/sig/wasm/serialization_schema.rbs +13 -0
  242. data/src/ast.c +1628 -0
  243. data/src/lexer.c +3221 -0
  244. data/src/lexer.re +155 -0
  245. data/src/lexstate.c +221 -0
  246. data/src/location.c +31 -0
  247. data/src/parser.c +4258 -0
  248. data/src/serialize.c +958 -0
  249. data/src/string.c +41 -0
  250. data/src/util/rbs_allocator.c +171 -0
  251. data/src/util/rbs_assert.c +19 -0
  252. data/src/util/rbs_buffer.c +54 -0
  253. data/src/util/rbs_constant_pool.c +18 -92
  254. data/src/util/rbs_encoding.c +21308 -0
  255. data/src/util/rbs_unescape.c +167 -0
  256. data/stdlib/abbrev/0/array.rbs +1 -1
  257. data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
  258. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  259. data/stdlib/cgi/0/core.rbs +9 -393
  260. data/stdlib/cgi/0/manifest.yaml +1 -0
  261. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  262. data/stdlib/coverage/0/coverage.rbs +7 -4
  263. data/stdlib/csv/0/csv.rbs +5 -5
  264. data/stdlib/date/0/date.rbs +92 -79
  265. data/stdlib/date/0/date_time.rbs +25 -24
  266. data/stdlib/delegate/0/delegator.rbs +11 -7
  267. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  268. data/stdlib/digest/0/digest.rbs +117 -1
  269. data/stdlib/erb/0/erb.rbs +748 -347
  270. data/stdlib/etc/0/etc.rbs +73 -54
  271. data/stdlib/fileutils/0/fileutils.rbs +179 -160
  272. data/stdlib/forwardable/0/forwardable.rbs +13 -10
  273. data/stdlib/io-console/0/io-console.rbs +2 -2
  274. data/stdlib/ipaddr/0/ipaddr.rbs +0 -5
  275. data/stdlib/json/0/json.rbs +232 -185
  276. data/stdlib/monitor/0/monitor.rbs +5 -5
  277. data/stdlib/net-http/0/net-http.rbs +162 -134
  278. data/stdlib/objspace/0/objspace.rbs +17 -34
  279. data/stdlib/open-uri/0/open-uri.rbs +48 -8
  280. data/stdlib/open3/0/open3.rbs +469 -10
  281. data/stdlib/openssl/0/openssl.rbs +521 -397
  282. data/stdlib/optparse/0/optparse.rbs +26 -17
  283. data/stdlib/pathname/0/pathname.rbs +11 -1381
  284. data/stdlib/pp/0/pp.rbs +9 -8
  285. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  286. data/stdlib/pstore/0/pstore.rbs +35 -30
  287. data/stdlib/psych/0/psych.rbs +65 -12
  288. data/stdlib/psych/0/store.rbs +2 -4
  289. data/stdlib/pty/0/pty.rbs +9 -6
  290. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  291. data/stdlib/rdoc/0/code_object.rbs +4 -3
  292. data/stdlib/rdoc/0/comment.rbs +2 -0
  293. data/stdlib/rdoc/0/options.rbs +76 -0
  294. data/stdlib/rdoc/0/parser.rbs +1 -1
  295. data/stdlib/rdoc/0/rdoc.rbs +7 -5
  296. data/stdlib/rdoc/0/store.rbs +2 -2
  297. data/stdlib/resolv/0/resolv.rbs +26 -69
  298. data/stdlib/ripper/0/ripper.rbs +25 -19
  299. data/stdlib/securerandom/0/manifest.yaml +2 -0
  300. data/stdlib/securerandom/0/securerandom.rbs +7 -20
  301. data/stdlib/shellwords/0/shellwords.rbs +3 -3
  302. data/stdlib/singleton/0/singleton.rbs +3 -0
  303. data/stdlib/socket/0/addrinfo.rbs +9 -9
  304. data/stdlib/socket/0/basic_socket.rbs +3 -3
  305. data/stdlib/socket/0/ip_socket.rbs +10 -8
  306. data/stdlib/socket/0/socket.rbs +23 -10
  307. data/stdlib/socket/0/tcp_server.rbs +1 -1
  308. data/stdlib/socket/0/tcp_socket.rbs +11 -3
  309. data/stdlib/socket/0/udp_socket.rbs +1 -1
  310. data/stdlib/socket/0/unix_server.rbs +1 -1
  311. data/stdlib/stringio/0/stringio.rbs +1209 -95
  312. data/stdlib/strscan/0/string_scanner.rbs +101 -80
  313. data/stdlib/tempfile/0/manifest.yaml +3 -0
  314. data/stdlib/tempfile/0/tempfile.rbs +25 -21
  315. data/stdlib/time/0/time.rbs +8 -6
  316. data/stdlib/timeout/0/timeout.rbs +58 -7
  317. data/stdlib/tsort/0/cyclic.rbs +4 -1
  318. data/stdlib/tsort/0/interfaces.rbs +8 -8
  319. data/stdlib/tsort/0/tsort.rbs +16 -15
  320. data/stdlib/uri/0/common.rbs +42 -20
  321. data/stdlib/uri/0/file.rbs +3 -3
  322. data/stdlib/uri/0/generic.rbs +21 -18
  323. data/stdlib/uri/0/http.rbs +2 -2
  324. data/stdlib/uri/0/ldap.rbs +2 -2
  325. data/stdlib/uri/0/mailto.rbs +3 -3
  326. data/stdlib/uri/0/rfc2396_parser.rbs +12 -12
  327. data/stdlib/zlib/0/deflate.rbs +4 -3
  328. data/stdlib/zlib/0/gzip_reader.rbs +8 -8
  329. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  330. data/stdlib/zlib/0/inflate.rbs +1 -1
  331. data/stdlib/zlib/0/need_dict.rbs +1 -1
  332. data/wasm/README.md +60 -0
  333. data/wasm/rbs_wasm.c +423 -0
  334. metadata +131 -19
  335. data/ext/rbs_extension/lexer.c +0 -2728
  336. data/ext/rbs_extension/lexer.h +0 -179
  337. data/ext/rbs_extension/lexer.re +0 -147
  338. data/ext/rbs_extension/lexstate.c +0 -175
  339. data/ext/rbs_extension/location.c +0 -325
  340. data/ext/rbs_extension/location.h +0 -85
  341. data/ext/rbs_extension/parser.c +0 -2982
  342. data/ext/rbs_extension/parser.h +0 -18
  343. data/ext/rbs_extension/parserstate.c +0 -411
  344. data/ext/rbs_extension/parserstate.h +0 -163
  345. data/ext/rbs_extension/unescape.c +0 -32
  346. data/include/rbs/ruby_objs.h +0 -72
  347. data/src/constants.c +0 -153
  348. data/src/ruby_objs.c +0 -799
@@ -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
 
@@ -2067,7 +2100,7 @@ module OpenSSL
2067
2100
  #
2068
2101
  # See IO#read for full details.
2069
2102
  #
2070
- def read: (?Integer? size, ?String buf) -> String?
2103
+ def read: (?Integer? size, ?String? buf) -> String?
2071
2104
 
2072
2105
  # <!--
2073
2106
  # rdoc-file=ext/openssl/lib/openssl/buffering.rb
@@ -2103,11 +2136,11 @@ 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
- def read_nonblock: (Integer maxlen, ?String buf, ?exception: true) -> String
2110
- | (Integer maxlen, ?String buf, exception: false) -> (String | :wait_writable | :wait_readable | nil)
2142
+ def read_nonblock: (Integer maxlen, ?String? buf, ?exception: true) -> String
2143
+ | (Integer maxlen, ?String? buf, exception: false) -> (String | :wait_writable | :wait_readable | nil)
2111
2144
 
2112
2145
  # <!--
2113
2146
  # rdoc-file=ext/openssl/lib/openssl/buffering.rb
@@ -2147,7 +2180,7 @@ module OpenSSL
2147
2180
  #
2148
2181
  # See IO#readpartial for full details.
2149
2182
  #
2150
- def readpartial: (Integer maxlen, ?String buf) -> String
2183
+ def readpartial: (Integer maxlen, ?String? buf) -> String
2151
2184
 
2152
2185
  # <!-- rdoc-file=ext/openssl/lib/openssl/buffering.rb -->
2153
2186
  # The "sync mode" of the SSLSocket.
@@ -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.
2547
+ #
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.
2508
2551
  #
2509
- # The tag may only be retrieved after calling Cipher#final.
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.
2522
2562
  #
2523
- # For OCB mode, the tag length must be supplied with #auth_tag_len= beforehand.
2563
+ # The authentication tag must be set before #final is called. The tag is
2564
+ # verified during the #final call.
2565
+ #
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
  #
@@ -5840,10 +5913,17 @@ module OpenSSL
5840
5913
  def initialize_copy: (self) -> void
5841
5914
  end
5842
5915
 
5843
- # <!-- rdoc-file=ext/openssl/ossl_pkey_dh.c -->
5844
- # Generic exception that is raised if an operation on a DH PKey fails
5845
- # unexpectedly or in case an instantiation of an instance of DH fails due to
5846
- # non-conformant input data.
5916
+ # <!-- rdoc-file=ext/openssl/ossl_pkey.c -->
5917
+ # Raised when errors occur during PKey#sign or PKey#verify.
5918
+ #
5919
+ # Before version 4.0.0, OpenSSL::PKey::PKeyError had the following subclasses.
5920
+ # These subclasses have been removed and the constants are now defined as
5921
+ # aliases of OpenSSL::PKey::PKeyError.
5922
+ #
5923
+ # * OpenSSL::PKey::DHError
5924
+ # * OpenSSL::PKey::DSAError
5925
+ # * OpenSSL::PKey::ECError
5926
+ # * OpenSSL::PKey::RSAError
5847
5927
  #
5848
5928
  class DHError < OpenSSL::PKey::PKeyError
5849
5929
  end
@@ -5922,8 +6002,8 @@ module OpenSSL
5922
6002
  # will not be available on FIPS-compliant systems.
5923
6003
  #
5924
6004
  #
5925
- # **This method is kept for compatibility.** This should only be used when the
5926
- # traditional, non-standard OpenSSL format is required.
6005
+ # <strong>This method is kept for compatibility.</strong> This should only be
6006
+ # used when the traditional, non-standard OpenSSL format is required.
5927
6007
  #
5928
6008
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
5929
6009
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -5936,11 +6016,12 @@ module OpenSSL
5936
6016
  def p: () -> BN
5937
6017
 
5938
6018
  # <!--
5939
- # rdoc-file=ext/openssl/ossl_pkey_dsa.c
6019
+ # rdoc-file=ext/openssl/lib/openssl/pkey.rb
5940
6020
  # - dsa.params -> hash
5941
6021
  # -->
5942
- # Stores all parameters of key to the hash INSECURE: PRIVATE INFORMATIONS CAN
5943
- # LEAK OUT!!! Don't use :-)) (I's up to you)
6022
+ # Stores all parameters of key to a Hash.
6023
+ #
6024
+ # The hash has keys 'p', 'q', 'g', 'pub_key', and 'priv_key'.
5944
6025
  #
5945
6026
  def params: () -> Hash[String, BN?]
5946
6027
 
@@ -6007,8 +6088,8 @@ module OpenSSL
6007
6088
  # to be an already-computed message digest of the original input data. The
6008
6089
  # signature is issued using the private key of this DSA instance.
6009
6090
  #
6010
- # **Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and
6011
- # PKey::PKey#verify_raw instead.
6091
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#sign_raw
6092
+ # and PKey::PKey#verify_raw instead.
6012
6093
  #
6013
6094
  # `string`
6014
6095
  # : A message digest of the original input data to be signed.
@@ -6036,8 +6117,8 @@ module OpenSSL
6036
6117
  # Verifies whether the signature is valid given the message digest input. It
6037
6118
  # does so by validating `sig` using the public key of this DSA instance.
6038
6119
  #
6039
- # **Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and
6040
- # PKey::PKey#verify_raw instead.
6120
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#sign_raw
6121
+ # and PKey::PKey#verify_raw instead.
6041
6122
  #
6042
6123
  # `digest`
6043
6124
  # : A message digest of the original input data to be signed.
@@ -6055,8 +6136,8 @@ module OpenSSL
6055
6136
  #
6056
6137
  # See #to_pem for details.
6057
6138
  #
6058
- # **This method is kept for compatibility.** This should only be used when the
6059
- # traditional, non-standard OpenSSL format is required.
6139
+ # <strong>This method is kept for compatibility.</strong> This should only be
6140
+ # used when the traditional, non-standard OpenSSL format is required.
6060
6141
  #
6061
6142
  # Consider using #public_to_der or #private_to_der instead.
6062
6143
  #
@@ -6108,8 +6189,8 @@ module OpenSSL
6108
6189
  # will not be available on FIPS-compliant systems.
6109
6190
  #
6110
6191
  #
6111
- # **This method is kept for compatibility.** This should only be used when the
6112
- # traditional, non-standard OpenSSL format is required.
6192
+ # <strong>This method is kept for compatibility.</strong> This should only be
6193
+ # used when the traditional, non-standard OpenSSL format is required.
6113
6194
  #
6114
6195
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
6115
6196
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -6162,8 +6243,8 @@ module OpenSSL
6162
6243
  # will not be available on FIPS-compliant systems.
6163
6244
  #
6164
6245
  #
6165
- # **This method is kept for compatibility.** This should only be used when the
6166
- # traditional, non-standard OpenSSL format is required.
6246
+ # <strong>This method is kept for compatibility.</strong> This should only be
6247
+ # used when the traditional, non-standard OpenSSL format is required.
6167
6248
  #
6168
6249
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
6169
6250
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -6190,7 +6271,8 @@ module OpenSSL
6190
6271
  # Creates a new DSA instance by reading an existing key from *string*.
6191
6272
  #
6192
6273
  # 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.
6274
+ # set. They can be set individually by #set_pqg and #set_key. This form is not
6275
+ # compatible with OpenSSL 3.0 or later.
6194
6276
  #
6195
6277
  # If called with a String, tries to parse as DER or PEM encoding of a DSA key.
6196
6278
  # See also OpenSSL::PKey.read which can parse keys of any kinds.
@@ -6229,10 +6311,17 @@ module OpenSSL
6229
6311
  def initialize_copy: (self) -> void
6230
6312
  end
6231
6313
 
6232
- # <!-- rdoc-file=ext/openssl/ossl_pkey_dsa.c -->
6233
- # Generic exception that is raised if an operation on a DSA PKey fails
6234
- # unexpectedly or in case an instantiation of an instance of DSA fails due to
6235
- # non-conformant input data.
6314
+ # <!-- rdoc-file=ext/openssl/ossl_pkey.c -->
6315
+ # Raised when errors occur during PKey#sign or PKey#verify.
6316
+ #
6317
+ # Before version 4.0.0, OpenSSL::PKey::PKeyError had the following subclasses.
6318
+ # These subclasses have been removed and the constants are now defined as
6319
+ # aliases of OpenSSL::PKey::PKeyError.
6320
+ #
6321
+ # * OpenSSL::PKey::DHError
6322
+ # * OpenSSL::PKey::DSAError
6323
+ # * OpenSSL::PKey::ECError
6324
+ # * OpenSSL::PKey::RSAError
6236
6325
  #
6237
6326
  class DSAError < OpenSSL::PKey::PKeyError
6238
6327
  end
@@ -6301,8 +6390,8 @@ module OpenSSL
6301
6390
  # rdoc-file=ext/openssl/lib/openssl/pkey.rb
6302
6391
  # - key.dsa_sign_asn1(data) -> String
6303
6392
  # -->
6304
- # **Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and
6305
- # PKey::PKey#verify_raw instead.
6393
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#sign_raw
6394
+ # and PKey::PKey#verify_raw instead.
6306
6395
  #
6307
6396
  def dsa_sign_asn1: (String digest) -> String
6308
6397
 
@@ -6310,8 +6399,8 @@ module OpenSSL
6310
6399
  # rdoc-file=ext/openssl/lib/openssl/pkey.rb
6311
6400
  # - key.dsa_verify_asn1(data, sig) -> true | false
6312
6401
  # -->
6313
- # **Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and
6314
- # PKey::PKey#verify_raw instead.
6402
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#sign_raw
6403
+ # and PKey::PKey#verify_raw instead.
6315
6404
  #
6316
6405
  def dsa_verify_asn1: (String digest, String signature) -> bool
6317
6406
 
@@ -6365,8 +6454,8 @@ module OpenSSL
6365
6454
  # will not be available on FIPS-compliant systems.
6366
6455
  #
6367
6456
  #
6368
- # **This method is kept for compatibility.** This should only be used when the
6369
- # SEC 1/RFC 5915 ECPrivateKey format is required.
6457
+ # <strong>This method is kept for compatibility.</strong> This should only be
6458
+ # used when the SEC 1/RFC 5915 ECPrivateKey format is required.
6370
6459
  #
6371
6460
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
6372
6461
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -6491,8 +6580,8 @@ module OpenSSL
6491
6580
  #
6492
6581
  # See #to_pem for details.
6493
6582
  #
6494
- # **This method is kept for compatibility.** This should only be used when the
6495
- # SEC 1/RFC 5915 ECPrivateKey format is required.
6583
+ # <strong>This method is kept for compatibility.</strong> This should only be
6584
+ # used when the SEC 1/RFC 5915 ECPrivateKey format is required.
6496
6585
  #
6497
6586
  # Consider using #public_to_der or #private_to_der instead.
6498
6587
  #
@@ -6544,8 +6633,8 @@ module OpenSSL
6544
6633
  # will not be available on FIPS-compliant systems.
6545
6634
  #
6546
6635
  #
6547
- # **This method is kept for compatibility.** This should only be used when the
6548
- # SEC 1/RFC 5915 ECPrivateKey format is required.
6636
+ # <strong>This method is kept for compatibility.</strong> This should only be
6637
+ # used when the SEC 1/RFC 5915 ECPrivateKey format is required.
6549
6638
  #
6550
6639
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
6551
6640
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -6638,9 +6727,10 @@ module OpenSSL
6638
6727
 
6639
6728
  # <!--
6640
6729
  # rdoc-file=ext/openssl/ossl_pkey_ec.c
6641
- # - group.curve_name => String
6730
+ # - group.curve_name -> string or nil
6642
6731
  # -->
6643
- # Returns the curve name (sn).
6732
+ # Returns the curve name (short name) corresponding to this group, or `nil` if
6733
+ # OpenSSL does not have an OID associated with the group.
6644
6734
  #
6645
6735
  # See the OpenSSL documentation for EC_GROUP_get_curve_name()
6646
6736
  #
@@ -6702,14 +6792,14 @@ module OpenSSL
6702
6792
  #
6703
6793
  # *format* can be one of these:
6704
6794
  #
6705
- # `:compressed`
6795
+ # <code>:compressed</code>
6706
6796
  # : Encoded as z||x, where z is an octet indicating which solution of the
6707
6797
  # equation y is. z will be 0x02 or 0x03.
6708
6798
  #
6709
- # `:uncompressed`
6799
+ # <code>:uncompressed</code>
6710
6800
  # : Encoded as z||x||y, where z is an octet 0x04.
6711
6801
  #
6712
- # `:hybrid`
6802
+ # <code>:hybrid</code>
6713
6803
  # : Encodes as z||x||y, where z is an octet indicating which solution of the
6714
6804
  # equation y is. z will be 0x06 or 0x07.
6715
6805
  #
@@ -6850,18 +6940,16 @@ module OpenSSL
6850
6940
  # <!--
6851
6941
  # rdoc-file=ext/openssl/ossl_pkey_ec.c
6852
6942
  # - point.mul(bn1 [, bn2]) => point
6853
- # - point.mul(bns, points [, bn2]) => point
6854
6943
  # -->
6855
6944
  # Performs elliptic curve point multiplication.
6856
6945
  #
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`.
6946
+ # The first form calculates <code>bn1 * point + bn2 * G</code>, where `G` is the
6947
+ # generator of the group of *point*. *bn2* may be omitted, and in that case, the
6948
+ # result is just <code>bn1 * point</code>.
6860
6949
  #
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]`.
6950
+ # Before version 4.0.0, and when compiled with OpenSSL 1.1.1 or older, this
6951
+ # method allowed another form:
6952
+ # point.mul(bns, points [, bn2]) => point
6865
6953
  #
6866
6954
  def mul: (bn bn1, ?bn bn2) -> self
6867
6955
  | (Array[bn] bns, Array[self], ?bn bn2) -> self
@@ -6902,9 +6990,9 @@ module OpenSSL
6902
6990
  #
6903
6991
  # *conversion_form* specifies how the point is converted. Possible values are:
6904
6992
  #
6905
- # * `:compressed`
6906
- # * `:uncompressed`
6907
- # * `:hybrid`
6993
+ # * <code>:compressed</code>
6994
+ # * <code>:uncompressed</code>
6995
+ # * <code>:hybrid</code>
6908
6996
  #
6909
6997
  def to_octet_string: (point_conversion_format) -> String
6910
6998
 
@@ -6937,6 +7025,18 @@ module OpenSSL
6937
7025
  end
6938
7026
  end
6939
7027
 
7028
+ # <!-- rdoc-file=ext/openssl/ossl_pkey.c -->
7029
+ # Raised when errors occur during PKey#sign or PKey#verify.
7030
+ #
7031
+ # Before version 4.0.0, OpenSSL::PKey::PKeyError had the following subclasses.
7032
+ # These subclasses have been removed and the constants are now defined as
7033
+ # aliases of OpenSSL::PKey::PKeyError.
7034
+ #
7035
+ # * OpenSSL::PKey::DHError
7036
+ # * OpenSSL::PKey::DSAError
7037
+ # * OpenSSL::PKey::ECError
7038
+ # * OpenSSL::PKey::RSAError
7039
+ #
6940
7040
  class ECError < OpenSSL::PKey::PKeyError
6941
7041
  end
6942
7042
 
@@ -7103,6 +7203,15 @@ module OpenSSL
7103
7203
  # <!-- rdoc-file=ext/openssl/ossl_pkey.c -->
7104
7204
  # Raised when errors occur during PKey#sign or PKey#verify.
7105
7205
  #
7206
+ # Before version 4.0.0, OpenSSL::PKey::PKeyError had the following subclasses.
7207
+ # These subclasses have been removed and the constants are now defined as
7208
+ # aliases of OpenSSL::PKey::PKeyError.
7209
+ #
7210
+ # * OpenSSL::PKey::DHError
7211
+ # * OpenSSL::PKey::DSAError
7212
+ # * OpenSSL::PKey::ECError
7213
+ # * OpenSSL::PKey::RSAError
7214
+ #
7106
7215
  class PKeyError < OpenSSL::OpenSSLError
7107
7216
  end
7108
7217
 
@@ -7194,8 +7303,8 @@ module OpenSSL
7194
7303
  # will not be available on FIPS-compliant systems.
7195
7304
  #
7196
7305
  #
7197
- # **This method is kept for compatibility.** This should only be used when the
7198
- # PKCS #1 RSAPrivateKey format is required.
7306
+ # <strong>This method is kept for compatibility.</strong> This should only be
7307
+ # used when the PKCS #1 RSAPrivateKey format is required.
7199
7308
  #
7200
7309
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
7201
7310
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -7210,15 +7319,12 @@ module OpenSSL
7210
7319
  def p: () -> BN?
7211
7320
 
7212
7321
  # <!--
7213
- # rdoc-file=ext/openssl/ossl_pkey_rsa.c
7214
- # - rsa.params => hash
7322
+ # rdoc-file=ext/openssl/lib/openssl/pkey.rb
7323
+ # - rsa.params -> hash
7215
7324
  # -->
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'.
7325
+ # Stores all parameters of key to a Hash.
7220
7326
  #
7221
- # Don't use :-)) (It's up to you)
7327
+ # The hash has keys 'n', 'e', 'd', 'p', 'q', 'dmp1', 'dmq1', and 'iqmp'.
7222
7328
  #
7223
7329
  def params: () -> Hash[String, BN?]
7224
7330
 
@@ -7239,8 +7345,8 @@ module OpenSSL
7239
7345
  # private key. `padding` defaults to PKCS1_PADDING, which is known to be
7240
7346
  # insecure but is kept for backwards compatibility.
7241
7347
  #
7242
- # **Deprecated in version 3.0**. Consider using PKey::PKey#encrypt and
7243
- # PKey::PKey#decrypt instead.
7348
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#encrypt
7349
+ # and PKey::PKey#decrypt instead.
7244
7350
  #
7245
7351
  def private_decrypt: (String data, ?Integer padding) -> String
7246
7352
 
@@ -7253,8 +7359,8 @@ module OpenSSL
7253
7359
  # which is known to be insecure but is kept for backwards compatibility. The
7254
7360
  # encrypted string output can be decrypted using #public_decrypt.
7255
7361
  #
7256
- # **Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and
7257
- # PKey::PKey#verify_raw, and PKey::PKey#verify_recover instead.
7362
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#sign_raw
7363
+ # and PKey::PKey#verify_raw, and PKey::PKey#verify_recover instead.
7258
7364
  #
7259
7365
  def private_encrypt: (String data, ?Integer padding) -> String
7260
7366
 
@@ -7276,8 +7382,8 @@ module OpenSSL
7276
7382
  # public key. `padding` defaults to PKCS1_PADDING which is known to be insecure
7277
7383
  # but is kept for backwards compatibility.
7278
7384
  #
7279
- # **Deprecated in version 3.0**. Consider using PKey::PKey#sign_raw and
7280
- # PKey::PKey#verify_raw, and PKey::PKey#verify_recover instead.
7385
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#sign_raw
7386
+ # and PKey::PKey#verify_raw, and PKey::PKey#verify_recover instead.
7281
7387
  #
7282
7388
  def public_decrypt: (String data, ?Integer padding) -> String
7283
7389
 
@@ -7290,8 +7396,8 @@ module OpenSSL
7290
7396
  # which is known to be insecure but is kept for backwards compatibility. The
7291
7397
  # encrypted string output can be decrypted using #private_decrypt.
7292
7398
  #
7293
- # **Deprecated in version 3.0**. Consider using PKey::PKey#encrypt and
7294
- # PKey::PKey#decrypt instead.
7399
+ # <strong>Deprecated in version 3.0</strong>. Consider using PKey::PKey#encrypt
7400
+ # and PKey::PKey#decrypt instead.
7295
7401
  #
7296
7402
  def public_encrypt: (String data, ?Integer padding) -> String
7297
7403
 
@@ -7315,8 +7421,9 @@ module OpenSSL
7315
7421
  # rdoc-file=ext/openssl/ossl_pkey_rsa.c
7316
7422
  # - rsa.set_crt_params(dmp1, dmq1, iqmp) -> self
7317
7423
  # -->
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.
7424
+ # Sets *dmp1*, *dmq1*, *iqmp* for the RSA instance. They are calculated by
7425
+ # <code>d mod (p - 1)</code>, <code>d mod (q - 1)</code> and <code>q^(-1) mod
7426
+ # p</code> respectively.
7320
7427
  #
7321
7428
  def set_crt_params: (bn dmp1, bn dmq1, bn iqmp) -> self
7322
7429
 
@@ -7343,7 +7450,7 @@ module OpenSSL
7343
7450
  # Signs *data* using the Probabilistic Signature Scheme (RSA-PSS) and returns
7344
7451
  # the calculated signature.
7345
7452
  #
7346
- # RSAError will be raised if an error occurs.
7453
+ # PKeyError will be raised if an error occurs.
7347
7454
  #
7348
7455
  # See #verify_pss for the verification operation.
7349
7456
  #
@@ -7356,9 +7463,9 @@ module OpenSSL
7356
7463
  #
7357
7464
  # *salt_length*
7358
7465
  # : 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.
7466
+ # <code>:digest</code> means the digest length, and <code>:max</code> means
7467
+ # the maximum possible length for the combination of the private key and the
7468
+ # selected message digest algorithm.
7362
7469
  #
7363
7470
  # *mgf1_hash*
7364
7471
  # : The hash algorithm used in MGF1 (the currently supported mask generation
@@ -7383,8 +7490,8 @@ module OpenSSL
7383
7490
  #
7384
7491
  # See #to_pem for details.
7385
7492
  #
7386
- # **This method is kept for compatibility.** This should only be used when the
7387
- # PKCS #1 RSAPrivateKey format is required.
7493
+ # <strong>This method is kept for compatibility.</strong> This should only be
7494
+ # used when the PKCS #1 RSAPrivateKey format is required.
7388
7495
  #
7389
7496
  # Consider using #public_to_der or #private_to_der instead.
7390
7497
  #
@@ -7436,8 +7543,8 @@ module OpenSSL
7436
7543
  # will not be available on FIPS-compliant systems.
7437
7544
  #
7438
7545
  #
7439
- # **This method is kept for compatibility.** This should only be used when the
7440
- # PKCS #1 RSAPrivateKey format is required.
7546
+ # <strong>This method is kept for compatibility.</strong> This should only be
7547
+ # used when the PKCS #1 RSAPrivateKey format is required.
7441
7548
  #
7442
7549
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
7443
7550
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -7490,8 +7597,8 @@ module OpenSSL
7490
7597
  # will not be available on FIPS-compliant systems.
7491
7598
  #
7492
7599
  #
7493
- # **This method is kept for compatibility.** This should only be used when the
7494
- # PKCS #1 RSAPrivateKey format is required.
7600
+ # <strong>This method is kept for compatibility.</strong> This should only be
7601
+ # used when the PKCS #1 RSAPrivateKey format is required.
7495
7602
  #
7496
7603
  # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
7497
7604
  # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
@@ -7517,7 +7624,7 @@ module OpenSSL
7517
7624
  # Verifies *data* using the Probabilistic Signature Scheme (RSA-PSS).
7518
7625
  #
7519
7626
  # The return value is `true` if the signature is valid, `false` otherwise.
7520
- # RSAError will be raised if an error occurs.
7627
+ # PKeyError will be raised if an error occurs.
7521
7628
  #
7522
7629
  # See #sign_pss for the signing operation and an example code.
7523
7630
  #
@@ -7530,8 +7637,8 @@ module OpenSSL
7530
7637
  #
7531
7638
  # *salt_length*
7532
7639
  # : 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.
7640
+ # <code>:digest</code> means the digest length, and <code>:auto</code> means
7641
+ # automatically determining the length based on the signature.
7535
7642
  #
7536
7643
  # *mgf1_hash*
7537
7644
  # : The hash algorithm used in MGF1.
@@ -7551,7 +7658,7 @@ module OpenSSL
7551
7658
  #
7552
7659
  # If called without arguments, creates a new instance with no key components
7553
7660
  # set. They can be set individually by #set_key, #set_factors, and
7554
- # #set_crt_params.
7661
+ # #set_crt_params. This form is not compatible with OpenSSL 3.0 or later.
7555
7662
  #
7556
7663
  # If called with a String, tries to parse as DER or PEM encoding of an RSA key.
7557
7664
  # Note that if *password* is not specified, but the key is encrypted with a
@@ -7586,10 +7693,17 @@ module OpenSSL
7586
7693
  SSLV23_PADDING: Integer
7587
7694
  end
7588
7695
 
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.
7696
+ # <!-- rdoc-file=ext/openssl/ossl_pkey.c -->
7697
+ # Raised when errors occur during PKey#sign or PKey#verify.
7698
+ #
7699
+ # Before version 4.0.0, OpenSSL::PKey::PKeyError had the following subclasses.
7700
+ # These subclasses have been removed and the constants are now defined as
7701
+ # aliases of OpenSSL::PKey::PKeyError.
7702
+ #
7703
+ # * OpenSSL::PKey::DHError
7704
+ # * OpenSSL::PKey::DSAError
7705
+ # * OpenSSL::PKey::ECError
7706
+ # * OpenSSL::PKey::RSAError
7593
7707
  #
7594
7708
  class RSAError < OpenSSL::PKey::PKeyError
7595
7709
  end
@@ -8029,9 +8143,14 @@ module OpenSSL
8029
8143
  # - ctx.ciphers = [name, ...]
8030
8144
  # - ctx.ciphers = [[name, version, bits, alg_bits], ...]
8031
8145
  # -->
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.
8146
+ # Sets the list of available cipher suites for TLS 1.2 and below for this
8147
+ # context.
8148
+ #
8149
+ # Note in a server context some ciphers require the appropriate certificates.
8150
+ # For example, an RSA cipher suite can only be chosen when an RSA certificate is
8151
+ # available.
8152
+ #
8153
+ # This method does not affect TLS 1.3 connections. See also #ciphersuites=.
8035
8154
  #
8036
8155
  def ciphers=: (Array[[ String, String, Integer, Integer ]] ciphers) -> void
8037
8156
  | (Array[String] ciphers) -> void
@@ -8067,24 +8186,25 @@ module OpenSSL
8067
8186
  #
8068
8187
  def client_cert_cb=: (^(Session) -> [ X509::Certificate, PKey::PKey ]? client_cert_cb) -> void
8069
8188
 
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.
8189
+ # <!-- rdoc-file=ext/openssl/ossl_ssl.c -->
8190
+ # Sets the list of supported groups for key agreement for this context.
8075
8191
  #
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.
8192
+ # For a TLS client, the list is directly used in the "supported_groups"
8193
+ # extension. For a server, the list is used by OpenSSL to determine the set of
8194
+ # shared supported groups. OpenSSL will pick the most appropriate one from it.
8195
+ #
8196
+ # #ecdh_curves= is a deprecated alias for #groups=.
8197
+ #
8198
+ # See also the man page SSL_CTX_set1_groups_list(3).
8079
8199
  #
8080
8200
  # ### Example
8081
8201
  # ctx1 = OpenSSL::SSL::SSLContext.new
8082
- # ctx1.ecdh_curves = "X25519:P-256:P-224"
8202
+ # ctx1.groups = "X25519:P-256:P-224"
8083
8203
  # svr = OpenSSL::SSL::SSLServer.new(tcp_svr, ctx1)
8084
8204
  # Thread.new { svr.accept }
8085
8205
  #
8086
8206
  # ctx2 = OpenSSL::SSL::SSLContext.new
8087
- # ctx2.ecdh_curves = "P-256"
8207
+ # ctx2.groups = "P-256"
8088
8208
  # cli = OpenSSL::SSL::SSLSocket.new(tcp_sock, ctx2)
8089
8209
  # cli.connect
8090
8210
  #
@@ -8149,7 +8269,7 @@ module OpenSSL
8149
8269
  def key=: (PKey::PKey) -> PKey::PKey
8150
8270
 
8151
8271
  # <!--
8152
- # rdoc-file=ext/openssl/lib/openssl/ssl.rb
8272
+ # rdoc-file=ext/openssl/ossl_ssl.c
8153
8273
  # - ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
8154
8274
  # - ctx.max_version = :TLS1_2
8155
8275
  # - ctx.max_version = nil
@@ -8160,7 +8280,7 @@ module OpenSSL
8160
8280
  def max_version=: (tls_version version) -> tls_version
8161
8281
 
8162
8282
  # <!--
8163
- # rdoc-file=ext/openssl/lib/openssl/ssl.rb
8283
+ # rdoc-file=ext/openssl/ossl_ssl.c
8164
8284
  # - ctx.min_version = OpenSSL::SSL::TLS1_2_VERSION
8165
8285
  # - ctx.min_version = :TLS1_2
8166
8286
  # - ctx.min_version = nil
@@ -8169,9 +8289,6 @@ module OpenSSL
8169
8289
  # may be specified by an integer constant named OpenSSL::SSL::*_VERSION, a
8170
8290
  # Symbol, or `nil` which means "any version".
8171
8291
  #
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
8292
  # ### Example
8176
8293
  # ctx = OpenSSL::SSL::SSLContext.new
8177
8294
  # ctx.min_version = OpenSSL::SSL::TLS1_1_VERSION
@@ -8255,8 +8372,8 @@ module OpenSSL
8255
8372
  # - ctx.options = integer
8256
8373
  # -->
8257
8374
  # 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_`.
8375
+ # with the bitwise OR operator (<code>|</code>). Available options are defined
8376
+ # as constants in OpenSSL::SSL that begin with `OP_`.
8260
8377
  #
8261
8378
  # For backwards compatibility, passing `nil` has the same effect as passing
8262
8379
  # OpenSSL::SSL::OP_ALL.
@@ -8479,7 +8596,7 @@ module OpenSSL
8479
8596
  # The callback is invoked with an SSLSocket. If `false` is returned the session
8480
8597
  # will be removed from the internal cache.
8481
8598
  #
8482
- def session_new_cb: () -> (^(SSLSocket) -> untyped | nil)
8599
+ def session_new_cb: () -> (^(SSLSocket, Session) -> untyped | nil)
8483
8600
 
8484
8601
  # <!-- rdoc-file=ext/openssl/ossl_ssl.c -->
8485
8602
  # A callback invoked when a new session was negotiated.
@@ -8487,7 +8604,7 @@ module OpenSSL
8487
8604
  # The callback is invoked with an SSLSocket. If `false` is returned the session
8488
8605
  # will be removed from the internal cache.
8489
8606
  #
8490
- def session_new_cb=: (^(SSLSocket) -> untyped) -> ^(SSLSocket) -> untyped
8607
+ def session_new_cb=: (^(SSLSocket, Session) -> untyped) -> ^(SSLSocket, Session) -> untyped
8491
8608
 
8492
8609
  # <!--
8493
8610
  # rdoc-file=ext/openssl/ossl_ssl.c
@@ -8581,7 +8698,7 @@ module OpenSSL
8581
8698
  #
8582
8699
  def timeout=: (Integer) -> Integer
8583
8700
 
8584
- # <!-- rdoc-file=ext/openssl/lib/openssl/ssl.rb -->
8701
+ # <!-- rdoc-file=ext/openssl/ossl_ssl.c -->
8585
8702
  # A callback invoked when DH parameters are required for ephemeral DH key
8586
8703
  # exchange.
8587
8704
  #
@@ -8591,11 +8708,11 @@ module OpenSSL
8591
8708
  # The callback must return an OpenSSL::PKey::DH instance of the correct key
8592
8709
  # length.
8593
8710
  #
8594
- # **Deprecated in version 3.0.** Use #tmp_dh= instead.
8711
+ # <strong>Deprecated in version 3.0.</strong> Use #tmp_dh= instead.
8595
8712
  #
8596
8713
  def tmp_dh_callback: () -> (^(Session, Integer, Integer) -> PKey::DH | nil)
8597
8714
 
8598
- # <!-- rdoc-file=ext/openssl/lib/openssl/ssl.rb -->
8715
+ # <!-- rdoc-file=ext/openssl/ossl_ssl.c -->
8599
8716
  # A callback invoked when DH parameters are required for ephemeral DH key
8600
8717
  # exchange.
8601
8718
  #
@@ -8605,7 +8722,7 @@ module OpenSSL
8605
8722
  # The callback must return an OpenSSL::PKey::DH instance of the correct key
8606
8723
  # length.
8607
8724
  #
8608
- # **Deprecated in version 3.0.** Use #tmp_dh= instead.
8725
+ # <strong>Deprecated in version 3.0.</strong> Use #tmp_dh= instead.
8609
8726
  #
8610
8727
  def tmp_dh_callback=: (^(Session, Integer, Integer) -> PKey::DH) -> void
8611
8728
 
@@ -8866,8 +8983,8 @@ module OpenSSL
8866
8983
  # rdoc-file=ext/openssl/lib/openssl/ssl.rb
8867
8984
  # - open(remote_host, remote_port, local_host=nil, local_port=nil, context: nil)
8868
8985
  # -->
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
8986
+ # Creates a new instance of SSLSocket. _remote_host_ and _remote_port_ are used
8987
+ # to open TCPSocket. If _local_host_ and _local_port_ are specified, then those
8871
8988
  # parameters are used on the local end to establish the connection. If *context*
8872
8989
  # is provided, the SSL Sockets initial params will be taken from the context.
8873
8990
  #
@@ -8911,7 +9028,8 @@ module OpenSSL
8911
9028
  #
8912
9029
  # By specifying a keyword argument *exception* to `false`, you can indicate that
8913
9030
  # accept_nonblock should not raise an IO::WaitReadable or IO::WaitWritable
8914
- # exception, but return the symbol `:wait_readable` or `:wait_writable` instead.
9031
+ # exception, but return the symbol <code>:wait_readable</code> or
9032
+ # <code>:wait_writable</code> instead.
8915
9033
  #
8916
9034
  def accept_nonblock: (?exception: true) -> self
8917
9035
  | (exception: false) -> (self | :wait_readable | :wait_writable)
@@ -8944,7 +9062,7 @@ module OpenSSL
8944
9062
 
8945
9063
  # <!--
8946
9064
  # rdoc-file=ext/openssl/ossl_ssl.c
8947
- # - ssl.client_ca => [x509name, ...]
9065
+ # - ssl.client_ca => [x509name, ...] or nil
8948
9066
  # -->
8949
9067
  # Returns the list of client CAs. Please note that in contrast to
8950
9068
  # SSLContext#client_ca= no array of X509::Certificate is returned but X509::Name
@@ -8982,7 +9100,8 @@ module OpenSSL
8982
9100
  #
8983
9101
  # By specifying a keyword argument *exception* to `false`, you can indicate that
8984
9102
  # connect_nonblock should not raise an IO::WaitReadable or IO::WaitWritable
8985
- # exception, but return the symbol `:wait_readable` or `:wait_writable` instead.
9103
+ # exception, but return the symbol <code>:wait_readable</code> or
9104
+ # <code>:wait_writable</code> instead.
8986
9105
  #
8987
9106
  def connect_nonblock: (?exception: true) -> self
8988
9107
  | (exception: false) -> (self | :wait_readable | :wait_writable)
@@ -9142,7 +9261,7 @@ module OpenSSL
9142
9261
  # Reads *length* bytes from the SSL connection. If a pre-allocated *buffer* is
9143
9262
  # provided the data will be written into it.
9144
9263
  #
9145
- def sysread: (Integer length, ?String buffer) -> String
9264
+ def sysread: (Integer length, ?String? buffer) -> String
9146
9265
 
9147
9266
  # <!--
9148
9267
  # rdoc-file=ext/openssl/ossl_ssl.c
@@ -9189,6 +9308,7 @@ module OpenSSL
9189
9308
  # rdoc-file=ext/openssl/ossl_ssl.c
9190
9309
  # - SSLSocket.new(io) => aSSLSocket
9191
9310
  # - SSLSocket.new(io, ctx) => aSSLSocket
9311
+ # - SSLSocket.new(io, ctx, sync_close:) => aSSLSocket
9192
9312
  # -->
9193
9313
  # Creates a new SSL socket from *io* which must be a real IO object (not an
9194
9314
  # IO-like object that responds to read/write).
@@ -9196,6 +9316,10 @@ module OpenSSL
9196
9316
  # If *ctx* is provided the SSL Sockets initial params will be taken from the
9197
9317
  # context.
9198
9318
  #
9319
+ # The optional *sync_close* keyword parameter sets the *sync_close* instance
9320
+ # variable. Setting this to `true` will cause the underlying socket to be closed
9321
+ # when the SSL/TLS connection is shut down.
9322
+ #
9199
9323
  # The OpenSSL::Buffering module provides additional IO methods.
9200
9324
  #
9201
9325
  # This method will freeze the SSLContext if one is provided; however, session
@@ -9498,9 +9622,10 @@ module OpenSSL
9498
9622
  # Assume we received a timestamp request that has set Request#policy_id to `nil`
9499
9623
  # and Request#cert_requested? to true. The raw request bytes are stored in a
9500
9624
  # 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.
9625
+ # intermediate certificates (in <code>inter1.cer</code> and
9626
+ # <code>inter2.cer</code>) to simplify validation of the resulting Response.
9627
+ # <code>ts.p12</code> is a PKCS#12-compatible file including the private key and
9628
+ # the timestamping certificate.
9504
9629
  #
9505
9630
  # req = OpenSSL::Timestamp::Request.new(raw_bytes)
9506
9631
  # p12 = OpenSSL::PKCS12.new(File.binread('ts.p12'), 'pwd')
@@ -9515,65 +9640,33 @@ module OpenSSL
9515
9640
  # fac.additional_certificates = [ inter1, inter2 ]
9516
9641
  # timestamp = fac.create_timestamp(p12.key, p12.certificate, req)
9517
9642
  #
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
9643
  class Factory
9644
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9645
+ # Additional certificates apart from the timestamp certificate (e.g.
9646
+ # intermediate certificates) to be added to the Response. Must be an Array of
9647
+ # OpenSSL::X509::Certificate, or `nil`.
9648
+ #
9571
9649
  def additional_certs: () -> Array[X509::Certificate]?
9572
9650
 
9651
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9652
+ # Additional certificates apart from the timestamp certificate (e.g.
9653
+ # intermediate certificates) to be added to the Response. Must be an Array of
9654
+ # OpenSSL::X509::Certificate, or `nil`.
9655
+ #
9573
9656
  def additional_certs=: (Array[X509::Certificate]? certs) -> Array[X509::Certificate]?
9574
9657
 
9658
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9659
+ # The list of digest algorithms that the factory is allowed create timestamps
9660
+ # for. Known vulnerable or weak algorithms should not be allowed where possible.
9661
+ # Must be an Array of String or OpenSSL::Digest subclass instances.
9662
+ #
9575
9663
  def allowed_digests: () -> Array[String | Digest]?
9576
9664
 
9665
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9666
+ # The list of digest algorithms that the factory is allowed create timestamps
9667
+ # for. Known vulnerable or weak algorithms should not be allowed where possible.
9668
+ # Must be an Array of String or OpenSSL::Digest subclass instances.
9669
+ #
9577
9670
  def allowed_digests=: (Array[String | Digest]) -> Array[String | Digest]
9578
9671
 
9579
9672
  # <!--
@@ -9602,16 +9695,48 @@ module OpenSSL
9602
9695
  #
9603
9696
  def create_timestamp: (PKey::PKey key, X509::Certificate cert, Request request) -> Response
9604
9697
 
9698
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9699
+ # A String representing the default policy object identifier, or `nil`.
9700
+ #
9701
+ # Request#policy_id will always be preferred over this if present in the
9702
+ # Request, only if Request#policy_id is `nil` default_policy will be used. If
9703
+ # none of both is present, a TimestampError will be raised when trying to create
9704
+ # a Response.
9705
+ #
9605
9706
  def default_policy_id: () -> String?
9606
9707
 
9708
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9709
+ # A String representing the default policy object identifier, or `nil`.
9710
+ #
9711
+ # Request#policy_id will always be preferred over this if present in the
9712
+ # Request, only if Request#policy_id is `nil` default_policy will be used. If
9713
+ # none of both is present, a TimestampError will be raised when trying to create
9714
+ # a Response.
9715
+ #
9607
9716
  def default_policy_id=: (String) -> String
9608
9717
 
9718
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9719
+ # The Time value to be used in the Response. Must be present for timestamp
9720
+ # creation.
9721
+ #
9609
9722
  def gen_time: () -> Time?
9610
9723
 
9724
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9725
+ # The Time value to be used in the Response. Must be present for timestamp
9726
+ # creation.
9727
+ #
9611
9728
  def gen_time=: (Time) -> Time
9612
9729
 
9730
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9731
+ # The serial number to be used for timestamp creation. Must be present for
9732
+ # timestamp creation. Must be an instance of OpenSSL::BN or Integer.
9733
+ #
9613
9734
  def serial_number: () -> Integer?
9614
9735
 
9736
+ # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9737
+ # The serial number to be used for timestamp creation. Must be present for
9738
+ # timestamp creation. Must be an instance of OpenSSL::BN or Integer.
9739
+ #
9615
9740
  def serial_number=: (Integer) -> Integer
9616
9741
  end
9617
9742
 
@@ -10296,17 +10421,14 @@ module OpenSSL
10296
10421
 
10297
10422
  extend OpenSSL::Marshal::ClassMethods
10298
10423
 
10299
- # <!--
10300
- # rdoc-file=ext/openssl/lib/openssl/x509.rb
10301
- # - ==(other)
10302
- # -->
10303
- #
10304
10424
  def ==: (self other) -> bool
10305
10425
 
10306
10426
  # <!--
10307
10427
  # rdoc-file=ext/openssl/ossl_x509attr.c
10308
- # - attr.oid => string
10428
+ # - attr.oid -> string
10309
10429
  # -->
10430
+ # Returns the OID of the attribute. Returns the short name or the dotted decimal
10431
+ # notation.
10310
10432
  #
10311
10433
  def oid: () -> String
10312
10434
 
@@ -10366,11 +10488,6 @@ module OpenSSL
10366
10488
 
10367
10489
  extend OpenSSL::Marshal::ClassMethods
10368
10490
 
10369
- # <!--
10370
- # rdoc-file=ext/openssl/lib/openssl/x509.rb
10371
- # - ==(other)
10372
- # -->
10373
- #
10374
10491
  def ==: (self other) -> bool
10375
10492
 
10376
10493
  # <!--
@@ -10468,8 +10585,12 @@ module OpenSSL
10468
10585
 
10469
10586
  # <!--
10470
10587
  # rdoc-file=ext/openssl/ossl_x509crl.c
10471
- # - signature_algorithm()
10588
+ # - crl.signature_algorithm -> string
10472
10589
  # -->
10590
+ # Returns the signature algorithm used to sign this CRL.
10591
+ #
10592
+ # Returns the long name of the signature algorithm, or the dotted decimal
10593
+ # notation if OpenSSL does not define a long name for it.
10473
10594
  #
10474
10595
  def signature_algorithm: () -> String
10475
10596
 
@@ -10649,6 +10770,12 @@ module OpenSSL
10649
10770
  # Compares the two certificates. Note that this takes into account all fields,
10650
10771
  # not just the issuer name and the serial number.
10651
10772
  #
10773
+ # This method uses X509_cmp() from OpenSSL, which compares certificates based on
10774
+ # their cached DER encodings. The comparison can be unreliable if a certificate
10775
+ # is incomplete.
10776
+ #
10777
+ # See also the man page X509_cmp(3).
10778
+ #
10652
10779
  def ==: (self other) -> bool
10653
10780
 
10654
10781
  # <!--
@@ -10682,7 +10809,7 @@ module OpenSSL
10682
10809
  def extensions=: (Array[Extension]) -> Array[Extension]
10683
10810
 
10684
10811
  # <!--
10685
- # rdoc-file=ext/openssl/ossl_x509cert.c
10812
+ # rdoc-file=ext/openssl/lib/openssl/x509.rb
10686
10813
  # - inspect()
10687
10814
  # -->
10688
10815
  #
@@ -10776,6 +10903,12 @@ module OpenSSL
10776
10903
  # rdoc-file=ext/openssl/ossl_x509cert.c
10777
10904
  # - cert.signature_algorithm => string
10778
10905
  # -->
10906
+ # Returns the signature algorithm used to sign this certificate. This returns
10907
+ # the algorithm name found in the TBSCertificate structure, not the outer
10908
+ # Certificate structure.
10909
+ #
10910
+ # Returns the long name of the signature algorithm, or the dotted decimal
10911
+ # notation if OpenSSL does not define a long name for it.
10779
10912
  #
10780
10913
  def signature_algorithm: () -> String
10781
10914
 
@@ -10870,11 +11003,6 @@ module OpenSSL
10870
11003
 
10871
11004
  extend OpenSSL::Marshal::ClassMethods
10872
11005
 
10873
- # <!--
10874
- # rdoc-file=ext/openssl/lib/openssl/x509.rb
10875
- # - ==(other)
10876
- # -->
10877
- #
10878
11006
  def ==: (self other) -> bool
10879
11007
 
10880
11008
  # <!--
@@ -10893,8 +11021,10 @@ module OpenSSL
10893
11021
 
10894
11022
  # <!--
10895
11023
  # rdoc-file=ext/openssl/ossl_x509ext.c
10896
- # - oid()
11024
+ # - ext.oid -> string
10897
11025
  # -->
11026
+ # Returns the OID of the extension. Returns the short name or the dotted decimal
11027
+ # notation.
10898
11028
  #
10899
11029
  def oid: () -> String
10900
11030
 
@@ -11196,11 +11326,11 @@ module OpenSSL
11196
11326
  # Parses the string representation of a distinguished name. Two different forms
11197
11327
  # are supported:
11198
11328
  #
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`
11329
+ # * OpenSSL format (<code>X509_NAME_oneline()</code>) used by
11330
+ # <code>#to_s</code>. For example: <code>/DC=com/DC=example/CN=nobody</code>
11331
+ # * OpenSSL format (<code>X509_NAME_print()</code>) used by
11332
+ # <code>#to_s(OpenSSL::X509::Name::COMPAT)</code>. For example:
11333
+ # <code>DC=com, DC=example, CN=nobody</code>
11204
11334
  #
11205
11335
  # Neither of them is standardized and has quirks and inconsistencies in handling
11206
11336
  # of escaped characters or multi-valued RDNs.
@@ -11222,9 +11352,9 @@ module OpenSSL
11222
11352
  def self.parse_rfc2253: (String str, ?template template) -> instance
11223
11353
 
11224
11354
  # <!-- 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).
11355
+ # Compares this Name with *other* and returns `0` if they are the same and
11356
+ # <code>-1</code> or ++1+ if they are greater or less than each other
11357
+ # respectively. Returns `nil` if they are not comparable (i.e. different types).
11228
11358
  #
11229
11359
  alias <=> cmp
11230
11360
 
@@ -11266,9 +11396,9 @@ module OpenSSL
11266
11396
  # - name.cmp(other) -> -1 | 0 | 1 | nil
11267
11397
  # - name <=> other -> -1 | 0 | 1 | nil
11268
11398
  # -->
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).
11399
+ # Compares this Name with *other* and returns `0` if they are the same and
11400
+ # <code>-1</code> or ++1+ if they are greater or less than each other
11401
+ # respectively. Returns `nil` if they are not comparable (i.e. different types).
11272
11402
  #
11273
11403
  def cmp: (untyped other) -> Integer?
11274
11404
 
@@ -11336,14 +11466,14 @@ module OpenSSL
11336
11466
  # * OpenSSL::X509::Name::MULTILINE
11337
11467
  #
11338
11468
  # If *format* is omitted, the largely broken and traditional OpenSSL format
11339
- # (`X509_NAME_oneline()` format) is chosen.
11469
+ # (<code>X509_NAME_oneline()</code> format) is chosen.
11340
11470
  #
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
11471
+ # <strong>Use of this method is discouraged.</strong> None of the formats other
11472
+ # than OpenSSL::X509::Name::RFC2253 is standardized and may show an inconsistent
11343
11473
  # behavior through OpenSSL versions.
11344
11474
  #
11345
11475
  # 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")`.
11476
+ # <code>name.to_s(OpenSSL::X509::Name::RFC2253).force_encoding("UTF-8")</code>.
11347
11477
  #
11348
11478
  def to_s: (?format format) -> String
11349
11479
 
@@ -11496,11 +11626,6 @@ module OpenSSL
11496
11626
 
11497
11627
  extend OpenSSL::Marshal::ClassMethods
11498
11628
 
11499
- # <!--
11500
- # rdoc-file=ext/openssl/lib/openssl/x509.rb
11501
- # - ==(other)
11502
- # -->
11503
- #
11504
11629
  def ==: (untyped other) -> bool
11505
11630
 
11506
11631
  # <!--
@@ -11547,8 +11672,12 @@ module OpenSSL
11547
11672
 
11548
11673
  # <!--
11549
11674
  # rdoc-file=ext/openssl/ossl_x509req.c
11550
- # - signature_algorithm()
11675
+ # - req.signature_algorithm -> string
11551
11676
  # -->
11677
+ # Returns the signature algorithm used to sign this request.
11678
+ #
11679
+ # Returns the long name of the signature algorithm, or the dotted decimal
11680
+ # notation if OpenSSL does not define a long name for it.
11552
11681
  #
11553
11682
  def signature_algorithm: () -> String
11554
11683
 
@@ -11637,11 +11766,6 @@ module OpenSSL
11637
11766
  end
11638
11767
 
11639
11768
  class Revoked
11640
- # <!--
11641
- # rdoc-file=ext/openssl/lib/openssl/x509.rb
11642
- # - ==(other)
11643
- # -->
11644
- #
11645
11769
  def ==: (untyped other) -> bool
11646
11770
 
11647
11771
  # <!--